static int advanced_decode_picture_header(VC9Context *v)

{

    static const int type_table[4] = { P_TYPE, B_TYPE, I_TYPE, BI_TYPE };

    int type, i, ret;



    if (v->interlace)

    {

        v->fcm = get_bits(&v->gb, 1);

        if (v->fcm) v->fcm = 2+get_bits(&v->gb, 1);

    }



    type = get_prefix(&v->gb, 0, 4);

    if (type > 4 || type < 0) return FRAME_SKIPED;

    v->pict_type = type_table[type];

    av_log(v->avctx, AV_LOG_INFO, "AP Frame Type: %i\n", v->pict_type);



    if (v->tfcntrflag) v->tfcntr = get_bits(&v->gb, 8);

    if (v->broadcast)

    {

        if (!v->interlace) v->rptfrm = get_bits(&v->gb, 2);

        else

        {

            v->tff = get_bits(&v->gb, 1);

            v->rff = get_bits(&v->gb, 1);

        }

    }



    if (v->panscanflag)

    {

#if 0

        for (i=0; i<v->numpanscanwin; i++)

        {

            v->topleftx[i] = get_bits(&v->gb, 16);

            v->toplefty[i] = get_bits(&v->gb, 16);

            v->bottomrightx[i] = get_bits(&v->gb, 16);

            v->bottomrighty[i] = get_bits(&v->gb, 16);

        }

#else

        skip_bits(&v->gb, 16*4*v->numpanscanwin);

#endif

    }

    v->rndctrl = get_bits(&v->gb, 1);

    v->uvsamp = get_bits(&v->gb, 1);

    if (v->finterpflag == 1) v->interpfrm = get_bits(&v->gb, 1);



    switch(v->pict_type)

    {

    case I_TYPE: if (decode_i_picture_header(v) < 0) return -1;

    case P_TYPE: if (decode_p_picture_header(v) < 0) return -1;

    case BI_TYPE:

    case B_TYPE: if (decode_b_picture_header(v) < 0) return FRAME_SKIPED;

    default: break;

    }



    /* AC/DC Syntax */

    v->transacfrm = get_bits(&v->gb, 1);

    if (v->transacfrm) v->transacfrm += get_bits(&v->gb, 1);

    if (v->pict_type == I_TYPE || v->pict_type == BI_TYPE)

    {

        v->transacfrm2 = get_bits(&v->gb, 1);

        if (v->transacfrm2) v->transacfrm2 += get_bits(&v->gb, 1);

    }

    v->transacdctab = get_bits(&v->gb, 1);

    if (v->pict_type == I_TYPE) vop_dquant_decoding(v);



    return 0;

}

static int advanced_decode_picture_header(VC9Context *v)

{

    static const int type_table[4] = { P_TYPE, B_TYPE, I_TYPE, BI_TYPE };

    int type, i, ret;



    if (v->interlace)

    {

        v->fcm = get_bits(&v->gb, 1);

        if (v->fcm) v->fcm = 2+get_bits(&v->gb, 1);

    }



    type = get_prefix(&v->gb, 0, 4);

    if (type > 4 || type < 0) return FRAME_SKIPED;

    v->pict_type = type_table[type];

    av_log(v->avctx, AV_LOG_INFO, "AP Frame Type: %i\n", v->pict_type);



    if (v->tfcntrflag) v->tfcntr = get_bits(&v->gb, 8);

    if (v->broadcast)

    {

        if (!v->interlace) v->rptfrm = get_bits(&v->gb, 2);

        else

        {

            v->tff = get_bits(&v->gb, 1);

            v->rff = get_bits(&v->gb, 1);

        }

    }



    if (v->panscanflag)

    {

#if 0

        for (i=0; i<v->numpanscanwin; i++)

        {

            v->topleftx[i] = get_bits(&v->gb, 16);

            v->toplefty[i] = get_bits(&v->gb, 16);

            v->bottomrightx[i] = get_bits(&v->gb, 16);

            v->bottomrighty[i] = get_bits(&v->gb, 16);

        }

#else

        skip_bits(&v->gb, 16*4*v->numpanscanwin);

#endif

    }

    v->rndctrl = get_bits(&v->gb, 1);

    v->uvsamp = get_bits(&v->gb, 1);

    if (v->finterpflag == 1) v->interpfrm = get_bits(&v->gb, 1);



    switch(v->pict_type)

    {

    case I_TYPE: if (decode_i_picture_header(v) < 0) return -1;

    case P_TYPE: if (decode_p_picture_header(v) < 0) return -1;

    case BI_TYPE:

    case B_TYPE: if (decode_b_picture_header(v) < 0) return FRAME_SKIPED;

    default: break;

    }



    

    v->transacfrm = get_bits(&v->gb, 1);

    if (v->transacfrm) v->transacfrm += get_bits(&v->gb, 1);

    if (v->pict_type == I_TYPE || v->pict_type == BI_TYPE)

    {

        v->transacfrm2 = get_bits(&v->gb, 1);

        if (v->transacfrm2) v->transacfrm2 += get_bits(&v->gb, 1);

    }

    v->transacdctab = get_bits(&v->gb, 1);

    if (v->pict_type == I_TYPE) vop_dquant_decoding(v);



    return 0;

}

static int FUNC_0(VC9Context *VAR_0)

{

    static const int VAR_1[4] = { P_TYPE, B_TYPE, I_TYPE, BI_TYPE };

    int VAR_2, VAR_3, VAR_4;



    if (VAR_0->interlace)

    {

        VAR_0->fcm = get_bits(&VAR_0->gb, 1);

        if (VAR_0->fcm) VAR_0->fcm = 2+get_bits(&VAR_0->gb, 1);

    }



    VAR_2 = get_prefix(&VAR_0->gb, 0, 4);

    if (VAR_2 > 4 || VAR_2 < 0) return FRAME_SKIPED;

    VAR_0->pict_type = VAR_1[VAR_2];

    av_log(VAR_0->avctx, AV_LOG_INFO, "AP Frame Type: %VAR_3\n", VAR_0->pict_type);



    if (VAR_0->tfcntrflag) VAR_0->tfcntr = get_bits(&VAR_0->gb, 8);

    if (VAR_0->broadcast)

    {

        if (!VAR_0->interlace) VAR_0->rptfrm = get_bits(&VAR_0->gb, 2);

        else

        {

            VAR_0->tff = get_bits(&VAR_0->gb, 1);

            VAR_0->rff = get_bits(&VAR_0->gb, 1);

        }

    }



    if (VAR_0->panscanflag)

    {

#if 0

        for (VAR_3=0; VAR_3<VAR_0->numpanscanwin; VAR_3++)

        {

            VAR_0->topleftx[VAR_3] = get_bits(&VAR_0->gb, 16);

            VAR_0->toplefty[VAR_3] = get_bits(&VAR_0->gb, 16);

            VAR_0->bottomrightx[VAR_3] = get_bits(&VAR_0->gb, 16);

            VAR_0->bottomrighty[VAR_3] = get_bits(&VAR_0->gb, 16);

        }

#else

        skip_bits(&VAR_0->gb, 16*4*VAR_0->numpanscanwin);

#endif

    }

    VAR_0->rndctrl = get_bits(&VAR_0->gb, 1);

    VAR_0->uvsamp = get_bits(&VAR_0->gb, 1);

    if (VAR_0->finterpflag == 1) VAR_0->interpfrm = get_bits(&VAR_0->gb, 1);



    switch(VAR_0->pict_type)

    {

    case I_TYPE: if (decode_i_picture_header(VAR_0) < 0) return -1;

    case P_TYPE: if (decode_p_picture_header(VAR_0) < 0) return -1;

    case BI_TYPE:

    case B_TYPE: if (decode_b_picture_header(VAR_0) < 0) return FRAME_SKIPED;

    default: break;

    }



    

    VAR_0->transacfrm = get_bits(&VAR_0->gb, 1);

    if (VAR_0->transacfrm) VAR_0->transacfrm += get_bits(&VAR_0->gb, 1);

    if (VAR_0->pict_type == I_TYPE || VAR_0->pict_type == BI_TYPE)

    {

        VAR_0->transacfrm2 = get_bits(&VAR_0->gb, 1);

        if (VAR_0->transacfrm2) VAR_0->transacfrm2 += get_bits(&VAR_0->gb, 1);

    }

    VAR_0->transacdctab = get_bits(&VAR_0->gb, 1);

    if (VAR_0->pict_type == I_TYPE) vop_dquant_decoding(VAR_0);



    return 0;

}

static int FUNC_0(VC9Context *VAR_0)
{ static const int VAR_1[4] = { P_TYPE, B_TYPE, I_TYPE, BI_TYPE }; int VAR_2, VAR_3, VAR_4; if (VAR_0->interlace)
{ VAR_0->fcm = get_bits(&VAR_0->gb, 1); if (VAR_0->fcm) VAR_0->fcm = 2+get_bits(&VAR_0->gb, 1); } VAR_2 = get_prefix(&VAR_0->gb, 0, 4); if (VAR_2 > 4 || VAR_2 < 0) return FRAME_SKIPED; VAR_0->pict_type = VAR_1[VAR_2]; av_log(VAR_0->avctx, AV_LOG_INFO, "AP Frame Type: %VAR_3\n", VAR_0->pict_type); if (VAR_0->tfcntrflag) VAR_0->tfcntr = get_bits(&VAR_0->gb, 8); if (VAR_0->broadcast)
{ if (!VAR_0->interlace) VAR_0->rptfrm = get_bits(&VAR_0->gb, 2); else
{ VAR_0->tff = get_bits(&VAR_0->gb, 1); VAR_0->rff = get_bits(&VAR_0->gb, 1); } } if (VAR_0->panscanflag)
{ #if 0
for (VAR_3=0; VAR_3<VAR_0->numpanscanwin; VAR_3++) { VAR_0->topleftx[VAR_3] = get_bits(&VAR_0->gb, 16); VAR_0->toplefty[VAR_3] = get_bits(&VAR_0->gb, 16); VAR_0->bottomrightx[VAR_3] = get_bits(&VAR_0->gb, 16); VAR_0->bottomrighty[VAR_3] = get_bits(&VAR_0->gb, 16); } #else
skip_bits(&VAR_0->gb, 16*4*VAR_0->numpanscanwin); #endif
} VAR_0->rndctrl = get_bits(&VAR_0->gb, 1); VAR_0->uvsamp = get_bits(&VAR_0->gb, 1); if (VAR_0->finterpflag == 1) VAR_0->interpfrm = get_bits(&VAR_0->gb, 1); switch(VAR_0->pict_type)
{ case I_TYPE: if (decode_i_picture_header(VAR_0) < 0) return -1; case P_TYPE: if (decode_p_picture_header(VAR_0) < 0) return -1; case BI_TYPE:
case B_TYPE: if (decode_b_picture_header(VAR_0) < 0) return FRAME_SKIPED; default: break; } VAR_0->transacfrm = get_bits(&VAR_0->gb, 1); if (VAR_0->transacfrm) VAR_0->transacfrm += get_bits(&VAR_0->gb, 1); if (VAR_0->pict_type == I_TYPE || VAR_0->pict_type == BI_TYPE)
{ VAR_0->transacfrm2 = get_bits(&VAR_0->gb, 1); if (VAR_0->transacfrm2) VAR_0->transacfrm2 += get_bits(&VAR_0->gb, 1); } VAR_0->transacdctab = get_bits(&VAR_0->gb, 1); if (VAR_0->pict_type == I_TYPE) vop_dquant_decoding(VAR_0); return 0; }