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

📄 vc9.c

📁 ffmpeg源码分析
💻 C
📖 第 1 页 / 共 5 页
字号:
        else        {            if (!v->mv_mode)            {                if (get_bits(gb, 1))                     av_log(v->s.avctx, AV_LOG_ERROR,                            "mv_mode for highquant B frame was %i\n", v->mv_mode);            }            v->mv_mode = 1-v->mv_mode; //To match (pq < 13) mapping        }    }    return 0;}/** B and BI frame header decoding, secondary part * @see Tables 11+12, p62-65 * @param v VC9 context * @return Status * @warning Also handles BI frames * @warning To call once all MB arrays are allocated * @todo Support Advanced Profile headers */static int decode_b_picture_secondary_header(VC9Context *v){    GetBitContext *gb = &v->s.gb;    int status;    status = bitplane_decoding(&v->skip_mb_plane, v);    if (status < 0) return -1;#if TRACE    if (v->mv_mode == MV_PMODE_MIXED_MV)    {        status = bitplane_decoding(&v->mv_type_mb_plane, v);        if (status < 0)            return -1;#if TRACE        av_log(v->s.avctx, AV_LOG_DEBUG, "MB MV Type plane encoding: "               "Imode: %i, Invert: %i\n", status>>1, status&1);#endif    }    //bitplane    status = bitplane_decoding(&v->direct_mb_plane, v);    if (status < 0) return -1;#if TRACE    av_log(v->s.avctx, AV_LOG_DEBUG, "MB Direct plane encoding: "           "Imode: %i, Invert: %i\n", status>>1, status&1);#endif    av_log(v->s.avctx, AV_LOG_DEBUG, "Skip MB plane encoding: "           "Imode: %i, Invert: %i\n", status>>1, status&1);#endif    /* FIXME: what is actually chosen for B frames ? */    v->s.mv_table_index = get_bits(gb, 2); //but using vc9_ tables    v->cbpcy_vlc = &vc9_cbpcy_p_vlc[get_bits(gb, 2)];    if (v->dquant)    {        vop_dquant_decoding(v);    }    if (v->vstransform)    {        v->ttmbf = get_bits(gb, 1);        if (v->ttmbf)        {            v->ttfrm = get_bits(gb, 2);            av_log(v->s.avctx, AV_LOG_INFO, "Transform used: %ix%i\n",                   (v->ttfrm & 2) ? 4 : 8, (v->ttfrm & 1) ? 4 : 8);        }    }    /* Epilog (AC/DC syntax) should be done in caller */    return 0;}/** I frame header decoding, primary part * @see Tables 5+7, p53-54 and 55-57 * @param v VC9 context * @return Status * @todo Support Advanced Profile headers */static int decode_i_picture_primary_header(VC9Context *v){    GetBitContext *gb = &v->s.gb;    int pqindex;    /* Prolog common to all frametypes should be done in caller */    //BF = Buffer Fullness    if (v->profile < PROFILE_ADVANCED && get_bits(gb, 7))    {        av_log(v->s.avctx, AV_LOG_DEBUG, "I BufferFullness not 0\n");    }    /* Quantizer stuff */    pqindex = get_bits(gb, 5);    if (v->quantizer_mode == QUANT_FRAME_IMPLICIT)        v->pq = pquant_table[0][pqindex];    else    {        v->pq = pquant_table[v->quantizer_mode-1][pqindex];    }    if (pqindex < 9) v->halfpq = get_bits(gb, 1);    if (v->quantizer_mode == QUANT_FRAME_EXPLICIT)        v->pquantizer = get_bits(gb, 1);    av_log(v->s.avctx, AV_LOG_DEBUG, "I frame: QP=%i (+%i/2)\n",           v->pq, v->halfpq);    return 0;}/** I frame header decoding, secondary part * @param v VC9 context * @return Status * @warning Not called in A/S/C profiles, it seems * @todo Support Advanced Profile headers */static int decode_i_picture_secondary_header(VC9Context *v){#if HAS_ADVANCED_PROFILE    int status;    if (v->profile == PROFILE_ADVANCED)    {        v->s.ac_pred = get_bits(&v->s.gb, 1);        if (v->postprocflag) v->postproc = get_bits(&v->s.gb, 1);        /* 7.1.1.34 + 8.5.2 */        if (v->overlap && v->pq<9)        {            v->condover = get_bits(&v->s.gb, 1);            if (v->condover)            {                v->condover = 2+get_bits(&v->s.gb, 1);                if (v->condover == 3)                {                    status = bitplane_decoding(&v->over_flags_plane, v);                    if (status < 0) return -1;#  if TRACE                    av_log(v->s.avctx, AV_LOG_DEBUG, "Overflags plane encoding: "                           "Imode: %i, Invert: %i\n", status>>1, status&1);#  endif                }            }        }    }#endif    /* Epilog (AC/DC syntax) should be done in caller */    return 0;}/** P frame header decoding, primary part * @see Tables 5+7, p53-54 and 55-57 * @param v VC9 context * @todo Support Advanced Profile headers * @return Status */static int decode_p_picture_primary_header(VC9Context *v){    /* INTERFRM, FRMCNT, RANGEREDFRM read in caller */    GetBitContext *gb = &v->s.gb;    int lowquant, pqindex;    pqindex = get_bits(gb, 5);    if (v->quantizer_mode == QUANT_FRAME_IMPLICIT)        v->pq = pquant_table[0][pqindex];    else    {        v->pq = pquant_table[v->quantizer_mode-1][pqindex];    }    if (pqindex < 9) v->halfpq = get_bits(gb, 1);    if (v->quantizer_mode == QUANT_FRAME_EXPLICIT)        v->pquantizer = get_bits(gb, 1);    av_log(v->s.avctx, AV_LOG_DEBUG, "P Frame: QP=%i (+%i/2)\n",           v->pq, v->halfpq);    if (v->extended_mv == 1) v->mvrange = get_prefix(gb, 0, 3);#if HAS_ADVANCED_PROFILE    if (v->profile == PROFILE_ADVANCED)    {        if (v->postprocflag) v->postproc = get_bits(gb, 1);    }    else#endif        if (v->multires) v->respic = get_bits(gb, 2);    lowquant = (v->pquantizer>12) ? 0 : 1;    v->mv_mode = mv_pmode_table[lowquant][get_prefix(gb, 1, 4)];    if (v->mv_mode == MV_PMODE_INTENSITY_COMP)    {        v->mv_mode2 = mv_pmode_table[lowquant][get_prefix(gb, 1, 3)];        v->lumscale = get_bits(gb, 6);        v->lumshift = get_bits(gb, 6);    }    return 0;}/** P frame header decoding, secondary part * @see Tables 5+7, p53-54 and 55-57 * @param v VC9 context * @warning To call once all MB arrays are allocated * @return Status */static int decode_p_picture_secondary_header(VC9Context *v){    GetBitContext *gb = &v->s.gb;    int status = 0;    if ((v->mv_mode == MV_PMODE_INTENSITY_COMP &&         v->mv_mode2 == MV_PMODE_MIXED_MV)        || v->mv_mode == MV_PMODE_MIXED_MV)    {        status = bitplane_decoding(&v->mv_type_mb_plane, v);        if (status < 0) return -1;#if TRACE        av_log(v->s.avctx, AV_LOG_DEBUG, "MB MV Type plane encoding: "               "Imode: %i, Invert: %i\n", status>>1, status&1);#endif    }    status = bitplane_decoding(&v->skip_mb_plane, v);    if (status < 0) return -1;#if TRACE    av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: "           "Imode: %i, Invert: %i\n", status>>1, status&1);#endif    /* Hopefully this is correct for P frames */    v->s.mv_table_index =get_bits(gb, 2); //but using vc9_ tables    v->cbpcy_vlc = &vc9_cbpcy_p_vlc[get_bits(gb, 2)];    if (v->dquant)    {        av_log(v->s.avctx, AV_LOG_INFO, "VOP DQuant info\n");        vop_dquant_decoding(v);    }    v->ttfrm = 0; //FIXME Is that so ?    if (v->vstransform)    {        v->ttmbf = get_bits(gb, 1);        if (v->ttmbf)        {            v->ttfrm = get_bits(gb, 2);            av_log(v->s.avctx, AV_LOG_INFO, "Transform used: %ix%i\n",                   (v->ttfrm & 2) ? 4 : 8, (v->ttfrm & 1) ? 4 : 8);        }    }    /* Epilog (AC/DC syntax) should be done in caller */    return 0;}/** @} */ //End of group all_frm_hdr/***********************************************************************//** * @defgroup std_frame_hdr VC9 Simple/Main Profiles header decoding * @brief Part of the frame header decoding belonging to Simple/Main Profiles * @warning Only pro/epilog differs between Simple/Main and Advanced => *          check caller * @{ *//** Frame header decoding, first part, in Simple and Main profiles * @see Tables 5+7, p53-54 and 55-57 * @param v VC9 context * @todo FIXME: RANGEREDFRM element not read if BI frame from Table6, P54 *              However, 7.1.1.8 says "all frame types, for main profiles" * @return Status */static int standard_decode_picture_primary_header(VC9Context *v){    GetBitContext *gb = &v->s.gb;    int status = 0;    if (v->finterpflag) v->interpfrm = get_bits(gb, 1);    skip_bits(gb, 2); //framecnt unused    if (v->rangered) v->rangeredfrm = get_bits(gb, 1);    v->s.pict_type = get_bits(gb, 1);    if (v->s.avctx->max_b_frames)    {        if (!v->s.pict_type)        {            if (get_bits(gb, 1)) v->s.pict_type = I_TYPE;            else v->s.pict_type = B_TYPE;        }        else v->s.pict_type = P_TYPE;    }    else v->s.pict_type++;    switch (v->s.pict_type)    {    case I_TYPE: status = decode_i_picture_primary_header(v); break;    case P_TYPE: status = decode_p_picture_primary_header(v); break;    case BI_TYPE: //Same as B    case B_TYPE: status = decode_b_picture_primary_header(v); break;    }    if (status == FRAME_SKIPPED)    {      av_log(v->s.avctx, AV_LOG_INFO, "Skipping frame...\n");      return status;    }    return 0;}/** Frame header decoding, secondary part * @param v VC9 context * @warning To call once all MB arrays are allocated * @return Status */static int standard_decode_picture_secondary_header(VC9Context *v){    GetBitContext *gb = &v->s.gb;    int status = 0;    switch (v->s.pict_type)    {    case P_TYPE: status = decode_p_picture_secondary_header(v); break;    case B_TYPE: status = decode_b_picture_secondary_header(v); break;    case BI_TYPE:    case I_TYPE: break; //Nothing needed as it's done in the epilog    }    if (status < 0) return FRAME_SKIPPED;    /* AC Syntax */    v->c_ac_table_index = decode012(gb);    if (v->s.pict_type == I_TYPE || v->s.pict_type == BI_TYPE)    {        v->y_ac_table_index = decode012(gb);    }    /* DC Syntax */    v->s.dc_table_index = decode012(gb);    return 0;}/** @} */ //End for group std_frame_hdr#if HAS_ADVANCED_PROFILE/***********************************************************************//** * @defgroup adv_frame_hdr VC9 Advanced Profile header decoding * @brief Part of the frame header decoding belonging to Advanced Profiles * @warning Only pro/epilog differs between Simple/Main and Advanced => *          check caller * @{ *//** Frame header decoding, primary part * @param v VC9 context * @return Status */static int advanced_decode_picture_primary_header(VC9Context *v){    GetBitContext *gb = &v->s.gb;    static const int type_table[4] = { P_TYPE, B_TYPE, I_TYPE, BI_TYPE };    int type;    if (v->interlace)    {        v->fcm = get_bits(gb, 1);        if (v->fcm) v->fcm = 2+get_bits(gb, 1);    }    type = get_prefix(gb, 0, 4);    if (type > 4 || type < 0) return FRAME_SKIPPED;    v->s.pict_type = type_table[type];    av_log(v->s.avctx, AV_LOG_INFO, "AP Frame Type: %i\n", v->s.pict_type);    if (v->tfcntrflag) v->tfcntr = get_bits(gb, 8);    if (v->broadcast)    {        if (!v->interlace) v->rptfrm = get_bits(gb, 2);        else        {            v->tff = get_bits(gb, 1);            v->rff = get_bits(gb, 1);        }    }    if (v->panscanflag)    {#if 0        for (i=0; i<v->numpanscanwin; i++)        {            v->topleftx[i] = get_bits(gb, 16);            v->toplefty[i] = get_bits(gb, 16);            v->bottomrightx[i] = get_bits(gb, 16);            v->bottomrighty[i] = get_bits(gb, 16);        }#else        skip_bits(gb, 16*4*v->numpanscanwin);#endif    }    v->s.no_rounding = !get_bits(gb, 1);    v->uvsamp = get_bits(gb, 1);    if (v->finterpflag == 1) v->interpfrm = get_bits(gb, 1);    switch(v->s.pict_type)    {    case I_TYPE: if (decode_i_picture_primary_header(v) < 0) return -1;    case P_TYPE: if (decode_p_picture_primary_header(v) < 0) return -1;    case BI_TYPE:    case B_TYPE: if (decode_b_picture_primary_header(v) < 0) return FRAME_SKIPPED;    default: return -1;    }}/** Frame header decoding, secondary part * @param v VC9 context * @return Status */static int advanced_decode_picture_secondary_header(VC9Context *v){    GetBitContext *gb = &v->s.gb;    int status = 0;    switch(v->s.pict_type)

⌨️ 快捷键说明

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