⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mp4dpars.c

📁 Intel提供的在Sitsang等嵌入式开发平台上使用Linux操作系统
💻 C
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************//               INTEL CORPORATION PROPRIETARY INFORMATION//  This software is supplied under the terms of a license agreement or//  nondisclosure agreement with Intel Corporation and may not be copied//  or disclosed except in accordance with the terms of that agreement.//        Copyright (c) 2003 Intel Corporation. All Rights Reserved.////  Description:    Stream syntax parsing functions of MPEG-4 video decoder//                  sample code for Intel(R) Integrated Performance Primitives.//  Functions List://		parse_mb_mpeg4()//		parse_gov_mpeg4()//		parse_vop_header_mpeg4()//      parse_voandvol_header_mpeg4()******************************************************************************/#include "sampmp4.h"/******************************************************************************// Name:            parse_mb_mpeg4// Description:     parsing the MB header which is stored in the vop_infor// Input Arguments: //      stream_buf  - Pointer to the source compressed video bitstream//      vop_infor   - Pointer to the vop information struct//      vop_type    - Current vop coding type////  Output Arguments://      stream_buf  - Pointer to the updated source video stream after the MB//                    header is decoded   //      vop_infor   - Pointer to the updated vop information struct////  Returns:    //      SAMPLE_STATUS_NOERR     If succeeds//      SAMPLE_STATUS_ERR       If stream parsing error occurs******************************************************************************/sample_status parse_mb_mpeg4(sample_bitstream *stream_buf, mp4_dec_vop_infor *vop_infor, int vop_type){    Ipp32u  code    = 0;    int     dquant  = 0;    int     vlc_end = 0;    const mp4_tree_node *cur_node = NULL;    vop_infor->cbpy = 0;    vop_infor->cbpc = 0;    /* PVOP */    if (IVOP != vop_type) {        /* 1 bit not_coded */        vop_infor->mb_not_coded = get_bits_mpeg4(stream_buf, 1);        if (vop_infor->mb_not_coded) {            vop_infor->mb_type = IPP_VIDEO_INTER;            return SAMPLE_STATUS_NOERR;        }        /* mcbpc vlc: B.1.2, Table B-7, ISO/IEC 14496-2:2001(E) */        cur_node = mcbpc_pvop_vlc_tbl;        do {            code = get_bits_mpeg4(stream_buf, 1);            if (0 == code) {                if (0 == cur_node->c0_end) {                    cur_node = cur_node->next0_node_symbol + mcbpc_pvop_vlc_tbl;                } else {                    vop_infor->cbpc    = (cur_node->next0_node_symbol) & 0x3;                    vop_infor->mb_type = (cur_node->next0_node_symbol) >> 2;                    vlc_end = 1;                }            } else {                if (0 == cur_node->c1_end) {                    cur_node = cur_node->next1_node_symbol + mcbpc_pvop_vlc_tbl;                } else {                    vop_infor->cbpc    = (cur_node->next1_node_symbol) & 0x3;                    vop_infor->mb_type = (cur_node->next1_node_symbol) >> 2;                    vlc_end = 1;                }            }        } while (!vlc_end);    } else { /* IVOP */                /* mcbpc vlc: B.1.2, Table B-6, ISO/IEC 14496-2:2001(E) */        do {            /* prefetch 9 bits */            code = get_bits_mpeg4(stream_buf, 9);            if (64 <= code) {                vop_infor->mb_type = IPP_VIDEO_INTRA;                vop_infor->cbpc = code >> 6;                                if (4 <= vop_infor->cbpc) {                    vop_infor->cbpc = 0;                    rewind_buffer_mpeg4(stream_buf, 8);                } else {                    rewind_buffer_mpeg4(stream_buf, 6);                }            } else {                if (1 == code) {                                    vop_infor->mb_type = MPEG4_MB_STUFF;                } else {                    vop_infor->mb_type = IPP_VIDEO_INTRA_Q;                                        vop_infor->cbpc = code >> 3;                    if (4 <= vop_infor->cbpc) {                        vop_infor->cbpc = 0;                        rewind_buffer_mpeg4(stream_buf, 5);                    } else {                        rewind_buffer_mpeg4(stream_buf, 3);                    }                }            }        } while (MPEG4_MB_STUFF == vop_infor->mb_type);    }        /* 1 bit ac_pred_flag */    if ((IPP_VIDEO_INTRA == vop_infor->mb_type) ||        (IPP_VIDEO_INTRA_Q == vop_infor->mb_type)) {        vop_infor->ac_pred_flag = get_bits_mpeg4(stream_buf, 1);    }        /* cbpy vlc: B.1.2, Table B-8, ISO/IEC 14496-2:2001(E) */    /* prefetch 4 bits */    code = get_bits_mpeg4(stream_buf, 4);    if ((12 > code) && (2 < code)) {        vop_infor->cbpy = cbpy4_intra_tbl[code];    } else if (12 <= code) {        vop_infor->cbpy = cbpy4_intra_tbl[12];        rewind_buffer_mpeg4(stream_buf, 2);    } else if (2 == code) {        code = get_bits_mpeg4(stream_buf, 1);        vop_infor->cbpy = 2 - code;    } else if (1 == code) {        code = get_bits_mpeg4(stream_buf, 1);        vop_infor->cbpy = 8 >> code;    } else {        code = get_bits_mpeg4(stream_buf, 2);        if (2 > code) {            return SAMPLE_STATUS_ERR;        } else {            vop_infor->cbpy = 3 * code;        }    }    /* inter-MB */    if ((IPP_VIDEO_INTRA != vop_infor->mb_type) &&        (IPP_VIDEO_INTRA_Q != vop_infor->mb_type)) {        vop_infor->cbpy = 15 - vop_infor->cbpy;    }    /* dquant */    if ((IPP_VIDEO_INTER_Q == vop_infor->mb_type) ||        (IPP_VIDEO_INTRA_Q == vop_infor->mb_type))    {        /* Get 2 bit dquant in intra_Q or inter_Q type */        dquant = (int)get_bits_mpeg4(stream_buf, 2);        if (2 <= dquant) {            dquant  = - 1 + dquant;        } else {            dquant  = - 1 - dquant;        }        code = vop_infor->cur_qp + dquant;        CLIP_VIDEO_I(code, 1, 31);        vop_infor->cur_qp = (Ipp8u)code;    }    return SAMPLE_STATUS_NOERR;}/******************************************************************************// Name:            parse_gov_mpeg4// Description:     Parse group of video object plane from bitstream// Input Arguments: //      stream_buf  - Pointer to the source compressed video bitstream//      dec_state   - Pointer to the general state structure of MPEG-4 decoder////  Output Arguments://      stream_buf  - Pointer to the updated source video stream after the VO //                    and VOL header is decoded   //      dec_state   - Pointer to the updated general state structure of MPEG-4//                    decoder////  Returns:    //      SAMPLE_STATUS_NOERR     If succeeds//      SAMPLE_STATUS_ERR       If stream parsing error occurs******************************************************************************/sample_status parse_gov_mpeg4(sample_bitstream *stream_buf, mp4_dec_state *dec_state){    /* 5 bit time_code_hours */    dec_state->hour   = get_bits_mpeg4(stream_buf, 5);    /* 6 bit time_code_minutes */    dec_state->minute = get_bits_mpeg4(stream_buf, 6);    /* marker_bit */    ASSERT_MARKER_BIT(stream_buf);    /* 6 bit time_code_seconds */    dec_state->second = get_bits_mpeg4(stream_buf, 6);    dec_state->modulo_base_disp = dec_state->hour * 3600        + dec_state->minute * 60 + dec_state->second;    dec_state->modulo_base_decd = dec_state->modulo_base_disp;    /* 1 bit closed_gov */    dec_state->closed_gov  = get_bits_mpeg4(stream_buf, 1);    /* 1 bit broken_link */    dec_state->broken_link = get_bits_mpeg4(stream_buf, 1);        return SAMPLE_STATUS_NOERR;}/******************************************************************************// Name:            parse_vop_header_mpeg4// Description:     Parse video object plane header from bitstream// Input Arguments: //      stream_buf  - Pointer to the source compressed video bitstream//      dec_state   - Pointer to the general state struct of MPEG-4 decoder//      vop_infor   - Pointer to the vop information struct////  Output Arguments://      stream_buf  - Pointer to the updated source video stream after the VOP//                    header is decoded//      dec_state   - Pointer to the updated general state struct of MPEG-4//                    decoder//      vop_infor   - Pointer to the updated vop information struct////  Returns://      SAMPLE_STATUS_NOERR             If succeeds//      SAMPLE_STATUS_ERR               If stream parsing error occurs//      SAMPLE_STATUS_NOTSUPPORTED_ERR  If stream syntax is not supported by//                                      current sample decoder******************************************************************************/sample_status parse_vop_header_mpeg4(sample_bitstream  *stream_buf, mp4_dec_state *dec_state, mp4_dec_vop_infor *vop_infor){    Ipp32u  code;    int     modulo_inc, delta_base, cur_time_sec;           /* 2 bit vop_coding_type */    dec_state->vop_coding_type = get_bits_mpeg4(stream_buf, 2);    if ((IVOP != dec_state->vop_coding_type) && (PVOP        != dec_state->vop_coding_type)) {        return SAMPLE_STATUS_NOTSUPPORTED_ERR;    }    /* modulo_time_base */    modulo_inc = 0;    do {        code = get_bits_mpeg4(stream_buf, 1);        if (code) {            modulo_inc++;        }    } while (0 != code);    delta_base = dec_state->modulo_base_decd;    cur_time_sec = modulo_inc + delta_base;    /* marker_bit */    ASSERT_MARKER_BIT(stream_buf);    /* numbits_time_incr bit vop_time_increment */    vop_infor->vop_time_inc = get_bits_mpeg4(stream_buf,        dec_state->numbits_time_incr);    dec_state->modulo_base_disp = dec_state->modulo_base_decd;          dec_state->modulo_base_decd = cur_time_sec;    dec_state->cur_frame_no = cur_time_sec * dec_state->clock_rate +         vop_infor->vop_time_inc;    /* marker_bit */    ASSERT_MARKER_BIT(stream_buf);    /* 1 bit vop_coded */    dec_state->vop_coded = get_bits_mpeg4(stream_buf, 1);    if (0 == dec_state->vop_coded) {        return SAMPLE_STATUS_NOERR;    }    /* 1 bit vop_rounding_type */    if (PVOP == dec_state->vop_coding_type) {        dec_state->rounding = get_bits_mpeg4(stream_buf, 1);    } else {        dec_state->rounding = 0;    }    /* 3 bit intra_dc_vlc_thr */    dec_state->intra_dc_thr = get_bits_mpeg4(stream_buf, 3);    /* 5 bit vop_quant */    /* not_8_bit is not supported, so the quant_precision is always 5 */    dec_state->vop_quant = (Ipp8u)get_bits_mpeg4(stream_buf, 5);    /* 3 bit vop_fcode_forward */    if (IVOP == dec_state->vop_coding_type) {        vop_infor->fcode_fwd = 1;            } else {        vop_infor->fcode_fwd = get_bits_mpeg4(stream_buf, 3);    }    /* turns into motion_shape_texture() */    return SAMPLE_STATUS_NOERR;}/******************************************************************************// Name:            parse_voandvol_header_mpeg4// Description:     Parse visual object and visual object layer header from //                  bitstream// Input Arguments: //      stream_buf  - Pointer to the source compressed video bitstream//      dec_state   - Pointer to the general state structure of MPEG-4 decoder////  Output Arguments://      stream_buf  - Pointer to the updated source video stream after the VO

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -