int ff_wmv2_decode_secondary_picture_header(MpegEncContext *s)

{

    Wmv2Context *const w = (Wmv2Context *) s;



    if (s->pict_type == AV_PICTURE_TYPE_I) {

        if (w->j_type_bit)

            w->j_type = get_bits1(&s->gb);

        else

            w->j_type = 0; // FIXME check



        if (!w->j_type) {

            if (w->per_mb_rl_bit)

                s->per_mb_rl_table = get_bits1(&s->gb);

            else

                s->per_mb_rl_table = 0;



            if (!s->per_mb_rl_table) {

                s->rl_chroma_table_index = decode012(&s->gb);

                s->rl_table_index        = decode012(&s->gb);

            }



            s->dc_table_index = get_bits1(&s->gb);

        }

        s->inter_intra_pred = 0;

        s->no_rounding      = 1;

        if (s->avctx->debug & FF_DEBUG_PICT_INFO) {

            av_log(s->avctx, AV_LOG_DEBUG,

                   "qscale:%d rlc:%d rl:%d dc:%d mbrl:%d j_type:%d \n",

                   s->qscale, s->rl_chroma_table_index, s->rl_table_index,

                   s->dc_table_index, s->per_mb_rl_table, w->j_type);

        }

    } else {

        int cbp_index;

        w->j_type = 0;



        parse_mb_skip(w);

        cbp_index = decode012(&s->gb);

        if (s->qscale <= 10) {

            int map[3]         = { 0, 2, 1 };

            w->cbp_table_index = map[cbp_index];

        } else if (s->qscale <= 20) {

            int map[3]         = { 1, 0, 2 };

            w->cbp_table_index = map[cbp_index];

        } else {

            int map[3]         = {2,1,0};

            w->cbp_table_index = map[cbp_index];

        }



        if (w->mspel_bit)

            s->mspel = get_bits1(&s->gb);

        else

            s->mspel = 0; // FIXME check



        if (w->abt_flag) {

            w->per_mb_abt = get_bits1(&s->gb) ^ 1;

            if (!w->per_mb_abt)

                w->abt_type = decode012(&s->gb);

        }



        if (w->per_mb_rl_bit)

            s->per_mb_rl_table = get_bits1(&s->gb);

        else

            s->per_mb_rl_table = 0;



        if (!s->per_mb_rl_table) {

            s->rl_table_index        = decode012(&s->gb);

            s->rl_chroma_table_index = s->rl_table_index;

        }



        s->dc_table_index   = get_bits1(&s->gb);

        s->mv_table_index   = get_bits1(&s->gb);



        s->inter_intra_pred = 0; // (s->width * s->height < 320 * 240 && s->bit_rate <= II_BITRATE);

        s->no_rounding     ^= 1;



        if (s->avctx->debug & FF_DEBUG_PICT_INFO) {

            av_log(s->avctx, AV_LOG_DEBUG,

                   "rl:%d rlc:%d dc:%d mv:%d mbrl:%d qp:%d mspel:%d "

                   "per_mb_abt:%d abt_type:%d cbp:%d ii:%d\n",

                   s->rl_table_index, s->rl_chroma_table_index,

                   s->dc_table_index, s->mv_table_index,

                   s->per_mb_rl_table, s->qscale, s->mspel,

                   w->per_mb_abt, w->abt_type, w->cbp_table_index,

                   s->inter_intra_pred);

        }

    }

    s->esc3_level_length = 0;

    s->esc3_run_length   = 0;

    s->picture_number++; // FIXME ?



    if (w->j_type) {

        ff_intrax8_decode_picture(&w->x8, 2 * s->qscale, (s->qscale - 1) | 1);



        ff_er_add_slice(&w->s.er, 0, 0,

                        (w->s.mb_x >> 1) - 1, (w->s.mb_y >> 1) - 1,

                        ER_MB_END);

        return 1;

    }



    return 0;

}

int ff_wmv2_decode_secondary_picture_header(MpegEncContext *s)

{

    Wmv2Context *const w = (Wmv2Context *) s;



    if (s->pict_type == AV_PICTURE_TYPE_I) {

        if (w->j_type_bit)

            w->j_type = get_bits1(&s->gb);

        else

            w->j_type = 0; 



        if (!w->j_type) {

            if (w->per_mb_rl_bit)

                s->per_mb_rl_table = get_bits1(&s->gb);

            else

                s->per_mb_rl_table = 0;



            if (!s->per_mb_rl_table) {

                s->rl_chroma_table_index = decode012(&s->gb);

                s->rl_table_index        = decode012(&s->gb);

            }



            s->dc_table_index = get_bits1(&s->gb);

        }

        s->inter_intra_pred = 0;

        s->no_rounding      = 1;

        if (s->avctx->debug & FF_DEBUG_PICT_INFO) {

            av_log(s->avctx, AV_LOG_DEBUG,

                   "qscale:%d rlc:%d rl:%d dc:%d mbrl:%d j_type:%d \n",

                   s->qscale, s->rl_chroma_table_index, s->rl_table_index,

                   s->dc_table_index, s->per_mb_rl_table, w->j_type);

        }

    } else {

        int cbp_index;

        w->j_type = 0;



        parse_mb_skip(w);

        cbp_index = decode012(&s->gb);

        if (s->qscale <= 10) {

            int map[3]         = { 0, 2, 1 };

            w->cbp_table_index = map[cbp_index];

        } else if (s->qscale <= 20) {

            int map[3]         = { 1, 0, 2 };

            w->cbp_table_index = map[cbp_index];

        } else {

            int map[3]         = {2,1,0};

            w->cbp_table_index = map[cbp_index];

        }



        if (w->mspel_bit)

            s->mspel = get_bits1(&s->gb);

        else

            s->mspel = 0; 



        if (w->abt_flag) {

            w->per_mb_abt = get_bits1(&s->gb) ^ 1;

            if (!w->per_mb_abt)

                w->abt_type = decode012(&s->gb);

        }



        if (w->per_mb_rl_bit)

            s->per_mb_rl_table = get_bits1(&s->gb);

        else

            s->per_mb_rl_table = 0;



        if (!s->per_mb_rl_table) {

            s->rl_table_index        = decode012(&s->gb);

            s->rl_chroma_table_index = s->rl_table_index;

        }



        s->dc_table_index   = get_bits1(&s->gb);

        s->mv_table_index   = get_bits1(&s->gb);



        s->inter_intra_pred = 0; 

        s->no_rounding     ^= 1;



        if (s->avctx->debug & FF_DEBUG_PICT_INFO) {

            av_log(s->avctx, AV_LOG_DEBUG,

                   "rl:%d rlc:%d dc:%d mv:%d mbrl:%d qp:%d mspel:%d "

                   "per_mb_abt:%d abt_type:%d cbp:%d ii:%d\n",

                   s->rl_table_index, s->rl_chroma_table_index,

                   s->dc_table_index, s->mv_table_index,

                   s->per_mb_rl_table, s->qscale, s->mspel,

                   w->per_mb_abt, w->abt_type, w->cbp_table_index,

                   s->inter_intra_pred);

        }

    }

    s->esc3_level_length = 0;

    s->esc3_run_length   = 0;

    s->picture_number++; 



    if (w->j_type) {

        ff_intrax8_decode_picture(&w->x8, 2 * s->qscale, (s->qscale - 1) | 1);



        ff_er_add_slice(&w->s.er, 0, 0,

                        (w->s.mb_x >> 1) - 1, (w->s.mb_y >> 1) - 1,

                        ER_MB_END);

        return 1;

    }



    return 0;

}

int FUNC_0(MpegEncContext *VAR_0)

{

    Wmv2Context *const w = (Wmv2Context *) VAR_0;



    if (VAR_0->pict_type == AV_PICTURE_TYPE_I) {

        if (w->j_type_bit)

            w->j_type = get_bits1(&VAR_0->gb);

        else

            w->j_type = 0; 



        if (!w->j_type) {

            if (w->per_mb_rl_bit)

                VAR_0->per_mb_rl_table = get_bits1(&VAR_0->gb);

            else

                VAR_0->per_mb_rl_table = 0;



            if (!VAR_0->per_mb_rl_table) {

                VAR_0->rl_chroma_table_index = decode012(&VAR_0->gb);

                VAR_0->rl_table_index        = decode012(&VAR_0->gb);

            }



            VAR_0->dc_table_index = get_bits1(&VAR_0->gb);

        }

        VAR_0->inter_intra_pred = 0;

        VAR_0->no_rounding      = 1;

        if (VAR_0->avctx->debug & FF_DEBUG_PICT_INFO) {

            av_log(VAR_0->avctx, AV_LOG_DEBUG,

                   "qscale:%d rlc:%d rl:%d dc:%d mbrl:%d j_type:%d \n",

                   VAR_0->qscale, VAR_0->rl_chroma_table_index, VAR_0->rl_table_index,

                   VAR_0->dc_table_index, VAR_0->per_mb_rl_table, w->j_type);

        }

    } else {

        int VAR_1;

        w->j_type = 0;



        parse_mb_skip(w);

        VAR_1 = decode012(&VAR_0->gb);

        if (VAR_0->qscale <= 10) {

            int VAR_3[3]         = { 0, 2, 1 };

            w->cbp_table_index = VAR_3[VAR_1];

        } else if (VAR_0->qscale <= 20) {

            int VAR_3[3]         = { 1, 0, 2 };

            w->cbp_table_index = VAR_3[VAR_1];

        } else {

            int VAR_3[3]         = {2,1,0};

            w->cbp_table_index = VAR_3[VAR_1];

        }



        if (w->mspel_bit)

            VAR_0->mspel = get_bits1(&VAR_0->gb);

        else

            VAR_0->mspel = 0; 



        if (w->abt_flag) {

            w->per_mb_abt = get_bits1(&VAR_0->gb) ^ 1;

            if (!w->per_mb_abt)

                w->abt_type = decode012(&VAR_0->gb);

        }



        if (w->per_mb_rl_bit)

            VAR_0->per_mb_rl_table = get_bits1(&VAR_0->gb);

        else

            VAR_0->per_mb_rl_table = 0;



        if (!VAR_0->per_mb_rl_table) {

            VAR_0->rl_table_index        = decode012(&VAR_0->gb);

            VAR_0->rl_chroma_table_index = VAR_0->rl_table_index;

        }



        VAR_0->dc_table_index   = get_bits1(&VAR_0->gb);

        VAR_0->mv_table_index   = get_bits1(&VAR_0->gb);



        VAR_0->inter_intra_pred = 0; 

        VAR_0->no_rounding     ^= 1;



        if (VAR_0->avctx->debug & FF_DEBUG_PICT_INFO) {

            av_log(VAR_0->avctx, AV_LOG_DEBUG,

                   "rl:%d rlc:%d dc:%d mv:%d mbrl:%d qp:%d mspel:%d "

                   "per_mb_abt:%d abt_type:%d cbp:%d ii:%d\n",

                   VAR_0->rl_table_index, VAR_0->rl_chroma_table_index,

                   VAR_0->dc_table_index, VAR_0->mv_table_index,

                   VAR_0->per_mb_rl_table, VAR_0->qscale, VAR_0->mspel,

                   w->per_mb_abt, w->abt_type, w->cbp_table_index,

                   VAR_0->inter_intra_pred);

        }

    }

    VAR_0->esc3_level_length = 0;

    VAR_0->esc3_run_length   = 0;

    VAR_0->picture_number++; 



    if (w->j_type) {

        ff_intrax8_decode_picture(&w->x8, 2 * VAR_0->qscale, (VAR_0->qscale - 1) | 1);



        ff_er_add_slice(&w->VAR_0.er, 0, 0,

                        (w->VAR_0.mb_x >> 1) - 1, (w->VAR_0.mb_y >> 1) - 1,

                        ER_MB_END);

        return 1;

    }



    return 0;

}

int FUNC_0(MpegEncContext *VAR_0)
{ Wmv2Context *const w = (Wmv2Context *) VAR_0; if (VAR_0->pict_type == AV_PICTURE_TYPE_I) { if (w->j_type_bit)
w->j_type = get_bits1(&VAR_0->gb); else
w->j_type = 0; if (!w->j_type) { if (w->per_mb_rl_bit)
VAR_0->per_mb_rl_table = get_bits1(&VAR_0->gb); else
VAR_0->per_mb_rl_table = 0; if (!VAR_0->per_mb_rl_table) { VAR_0->rl_chroma_table_index = decode012(&VAR_0->gb); VAR_0->rl_table_index        = decode012(&VAR_0->gb); } VAR_0->dc_table_index = get_bits1(&VAR_0->gb); } VAR_0->inter_intra_pred = 0; VAR_0->no_rounding      = 1; if (VAR_0->avctx->debug & FF_DEBUG_PICT_INFO) { av_log(VAR_0->avctx, AV_LOG_DEBUG,
"qscale:%d rlc:%d rl:%d dc:%d mbrl:%d j_type:%d \n",
VAR_0->qscale, VAR_0->rl_chroma_table_index, VAR_0->rl_table_index,
VAR_0->dc_table_index, VAR_0->per_mb_rl_table, w->j_type); } } else { int VAR_1; w->j_type = 0; parse_mb_skip(w); VAR_1 = decode012(&VAR_0->gb); if (VAR_0->qscale <= 10) { int VAR_3[3]         = { 0, 2, 1 }; w->cbp_table_index = VAR_3[VAR_1]; } else if (VAR_0->qscale <= 20) { int VAR_3[3]         = { 1, 0, 2 }; w->cbp_table_index = VAR_3[VAR_1]; } else { int VAR_3[3]         = {2,1,0}; w->cbp_table_index = VAR_3[VAR_1]; } if (w->mspel_bit)
VAR_0->mspel = get_bits1(&VAR_0->gb); else
VAR_0->mspel = 0; if (w->abt_flag) { w->per_mb_abt = get_bits1(&VAR_0->gb) ^ 1; if (!w->per_mb_abt)
w->abt_type = decode012(&VAR_0->gb); } if (w->per_mb_rl_bit)
VAR_0->per_mb_rl_table = get_bits1(&VAR_0->gb); else
VAR_0->per_mb_rl_table = 0; if (!VAR_0->per_mb_rl_table) { VAR_0->rl_table_index        = decode012(&VAR_0->gb); VAR_0->rl_chroma_table_index = VAR_0->rl_table_index; } VAR_0->dc_table_index   = get_bits1(&VAR_0->gb); VAR_0->mv_table_index   = get_bits1(&VAR_0->gb); VAR_0->inter_intra_pred = 0; VAR_0->no_rounding     ^= 1; if (VAR_0->avctx->debug & FF_DEBUG_PICT_INFO) { av_log(VAR_0->avctx, AV_LOG_DEBUG,
"rl:%d rlc:%d dc:%d mv:%d mbrl:%d qp:%d mspel:%d "
"per_mb_abt:%d abt_type:%d cbp:%d ii:%d\n",
VAR_0->rl_table_index, VAR_0->rl_chroma_table_index,
VAR_0->dc_table_index, VAR_0->mv_table_index,
VAR_0->per_mb_rl_table, VAR_0->qscale, VAR_0->mspel,
w->per_mb_abt, w->abt_type, w->cbp_table_index,
VAR_0->inter_intra_pred); } } VAR_0->esc3_level_length = 0; VAR_0->esc3_run_length   = 0; VAR_0->picture_number++; if (w->j_type) { ff_intrax8_decode_picture(&w->x8, 2 * VAR_0->qscale, (VAR_0->qscale - 1) | 1); ff_er_add_slice(&w->VAR_0.er, 0, 0,
(w->VAR_0.mb_x >> 1) - 1, (w->VAR_0.mb_y >> 1) - 1,
ER_MB_END); return 1; } return 0; }