static int decode_b_picture_primary_header(VC9Context *v)

{

    GetBitContext *gb = &v->s.gb;

    int pqindex;



    /* Prolog common to all frametypes should be done in caller */

    if (v->profile == PROFILE_SIMPLE)

    {

        av_log(v->s.avctx, AV_LOG_ERROR, "Found a B frame while in Simple Profile!\n");

        return FRAME_SKIPED;

    }

    v->bfraction = vc9_bfraction_lut[get_vlc2(gb, vc9_bfraction_vlc.table,

                                              VC9_BFRACTION_VLC_BITS, 2)];

    if (v->bfraction < -1)

    {

        av_log(v->s.avctx, AV_LOG_ERROR, "Invalid BFRaction\n");

        return FRAME_SKIPED;

    }

    else if (!v->bfraction)

    {

        /* We actually have a BI frame */

        v->s.pict_type = BI_TYPE;

        v->buffer_fullness = get_bits(gb, 7);

    }



    /* Read the quantization 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);



    if (v->profile > PROFILE_MAIN)

    {

        if (v->postprocflag) v->postproc = get_bits(gb, 2);

        if (v->extended_mv == 1 && v->s.pict_type != BI_TYPE)

            v->mvrange = get_prefix(gb, 0, 3);

    }

    else

    {

        if (v->extended_mv == 1)

            v->mvrange = get_prefix(gb, 0, 3);

    }

    /* Read the MV mode */

    if (v->s.pict_type != BI_TYPE)

    {

        v->mv_mode = get_bits(gb, 1);

        if (v->pq < 13)

        {

            if (!v->mv_mode)

            {

                v->mv_mode = get_bits(gb, 2);

                if (v->mv_mode)

                av_log(v->s.avctx, AV_LOG_ERROR,

                       "mv_mode for lowquant B frame was %i\n", v->mv_mode);

            }

        }

        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;

}

static int decode_b_picture_primary_header(VC9Context *v)

{

    GetBitContext *gb = &v->s.gb;

    int pqindex;



    

    if (v->profile == PROFILE_SIMPLE)

    {

        av_log(v->s.avctx, AV_LOG_ERROR, "Found a B frame while in Simple Profile!\n");

        return FRAME_SKIPED;

    }

    v->bfraction = vc9_bfraction_lut[get_vlc2(gb, vc9_bfraction_vlc.table,

                                              VC9_BFRACTION_VLC_BITS, 2)];

    if (v->bfraction < -1)

    {

        av_log(v->s.avctx, AV_LOG_ERROR, "Invalid BFRaction\n");

        return FRAME_SKIPED;

    }

    else if (!v->bfraction)

    {

        

        v->s.pict_type = BI_TYPE;

        v->buffer_fullness = get_bits(gb, 7);

    }



    

    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);



    if (v->profile > PROFILE_MAIN)

    {

        if (v->postprocflag) v->postproc = get_bits(gb, 2);

        if (v->extended_mv == 1 && v->s.pict_type != BI_TYPE)

            v->mvrange = get_prefix(gb, 0, 3);

    }

    else

    {

        if (v->extended_mv == 1)

            v->mvrange = get_prefix(gb, 0, 3);

    }

    

    if (v->s.pict_type != BI_TYPE)

    {

        v->mv_mode = get_bits(gb, 1);

        if (v->pq < 13)

        {

            if (!v->mv_mode)

            {

                v->mv_mode = get_bits(gb, 2);

                if (v->mv_mode)

                av_log(v->s.avctx, AV_LOG_ERROR,

                       "mv_mode for lowquant B frame was %i\n", v->mv_mode);

            }

        }

        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; 

        }

    }



    return 0;

}

    if (v->profile > PROFILE_MAIN)     GetBitContext *gb = &v->s.gb;     GetBitContext *gb = &v->s.gb;     if (v->profile > PROFILE_MAIN)     if (v->profile > PROFILE_MAIN)     if (v->profile > PROFILE_MAIN)     if (v->profile > PROFILE_MAIN)     if (v->profile > PROFILE_MAIN)     if (v->profile > PROFILE_MAIN)     if (v->profile > PROFILE_MAIN)
static int FUNC_0(VC9Context *VAR_0)

{

    GetBitContext *gb = &VAR_0->s.gb;

    int VAR_1;



    

    if (VAR_0->profile == PROFILE_SIMPLE)

    {

        av_log(VAR_0->s.avctx, AV_LOG_ERROR, "Found a B frame while in Simple Profile!\n");

        return FRAME_SKIPED;

    }

    VAR_0->bfraction = vc9_bfraction_lut[get_vlc2(gb, vc9_bfraction_vlc.table,

                                              VC9_BFRACTION_VLC_BITS, 2)];

    if (VAR_0->bfraction < -1)

    {

        av_log(VAR_0->s.avctx, AV_LOG_ERROR, "Invalid BFRaction\n");

        return FRAME_SKIPED;

    }

    else if (!VAR_0->bfraction)

    {

        

        VAR_0->s.pict_type = BI_TYPE;

        VAR_0->buffer_fullness = get_bits(gb, 7);

    }



    

    VAR_1 = get_bits(gb, 5);

    if (VAR_0->quantizer_mode == QUANT_FRAME_IMPLICIT)

        VAR_0->pq = pquant_table[0][VAR_1];

    else

    {

        VAR_0->pq = pquant_table[VAR_0->quantizer_mode-1][VAR_1];

    }

    if (VAR_1 < 9) VAR_0->halfpq = get_bits(gb, 1);

    if (VAR_0->quantizer_mode == QUANT_FRAME_EXPLICIT)

        VAR_0->pquantizer = get_bits(gb, 1);



    if (VAR_0->profile > PROFILE_MAIN)

    {

        if (VAR_0->postprocflag) VAR_0->postproc = get_bits(gb, 2);

        if (VAR_0->extended_mv == 1 && VAR_0->s.pict_type != BI_TYPE)

            VAR_0->mvrange = get_prefix(gb, 0, 3);

    }

    else

    {

        if (VAR_0->extended_mv == 1)

            VAR_0->mvrange = get_prefix(gb, 0, 3);

    }

    

    if (VAR_0->s.pict_type != BI_TYPE)

    {

        VAR_0->mv_mode = get_bits(gb, 1);

        if (VAR_0->pq < 13)

        {

            if (!VAR_0->mv_mode)

            {

                VAR_0->mv_mode = get_bits(gb, 2);

                if (VAR_0->mv_mode)

                av_log(VAR_0->s.avctx, AV_LOG_ERROR,

                       "mv_mode for lowquant B frame was %i\n", VAR_0->mv_mode);

            }

        }

        else

        {

            if (!VAR_0->mv_mode)

            {

                if (get_bits(gb, 1))

                     av_log(VAR_0->s.avctx, AV_LOG_ERROR,

                            "mv_mode for highquant B frame was %i\n", VAR_0->mv_mode);

            }

            VAR_0->mv_mode = 1-VAR_0->mv_mode; 

        }

    }



    return 0;

}

static int FUNC_0(VC9Context *VAR_0)
{ GetBitContext *gb = &VAR_0->s.gb; int VAR_1; if (VAR_0->profile == PROFILE_SIMPLE)
{ av_log(VAR_0->s.avctx, AV_LOG_ERROR, "Found a B frame while in Simple Profile!\n"); return FRAME_SKIPED; } VAR_0->bfraction = vc9_bfraction_lut[get_vlc2(gb, vc9_bfraction_vlc.table,
VC9_BFRACTION_VLC_BITS, 2)]; if (VAR_0->bfraction < -1)
{ av_log(VAR_0->s.avctx, AV_LOG_ERROR, "Invalid BFRaction\n"); return FRAME_SKIPED; } else if (!VAR_0->bfraction)
{ VAR_0->s.pict_type = BI_TYPE; VAR_0->buffer_fullness = get_bits(gb, 7); } VAR_1 = get_bits(gb, 5); if (VAR_0->quantizer_mode == QUANT_FRAME_IMPLICIT)
VAR_0->pq = pquant_table[0][VAR_1]; else
{ VAR_0->pq = pquant_table[VAR_0->quantizer_mode-1][VAR_1]; } if (VAR_1 < 9) VAR_0->halfpq = get_bits(gb, 1); if (VAR_0->quantizer_mode == QUANT_FRAME_EXPLICIT)
VAR_0->pquantizer = get_bits(gb, 1); if (VAR_0->profile > PROFILE_MAIN)
{ if (VAR_0->postprocflag) VAR_0->postproc = get_bits(gb, 2); if (VAR_0->extended_mv == 1 && VAR_0->s.pict_type != BI_TYPE)
VAR_0->mvrange = get_prefix(gb, 0, 3); } else
{ if (VAR_0->extended_mv == 1)
VAR_0->mvrange = get_prefix(gb, 0, 3); } if (VAR_0->s.pict_type != BI_TYPE)
{ VAR_0->mv_mode = get_bits(gb, 1); if (VAR_0->pq < 13)
{ if (!VAR_0->mv_mode)
{ VAR_0->mv_mode = get_bits(gb, 2); if (VAR_0->mv_mode)
av_log(VAR_0->s.avctx, AV_LOG_ERROR,
"mv_mode for lowquant B frame was %i\n", VAR_0->mv_mode); } } else
{ if (!VAR_0->mv_mode)
{ if (get_bits(gb, 1))
av_log(VAR_0->s.avctx, AV_LOG_ERROR,
"mv_mode for highquant B frame was %i\n", VAR_0->mv_mode); } VAR_0->mv_mode = 1-VAR_0->mv_mode; } } return 0; }