int ff_h264_decode_ref_pic_marking(const H264Context *h, H264SliceContext *sl,

                                   GetBitContext *gb)

{

    int i;

    MMCO *mmco = sl->mmco;

    int nb_mmco = 0;



    if (h->nal_unit_type == NAL_IDR_SLICE) { // FIXME fields

        skip_bits1(gb); // broken_link

        if (get_bits1(gb)) {

            mmco[0].opcode   = MMCO_LONG;

            mmco[0].long_arg = 0;

            nb_mmco          = 1;

        }

        sl->explicit_ref_marking = 1;

    } else {

        sl->explicit_ref_marking = get_bits1(gb);

        if (sl->explicit_ref_marking) {

            for (i = 0; i < MAX_MMCO_COUNT; i++) {

                MMCOOpcode opcode = get_ue_golomb_31(gb);



                mmco[i].opcode = opcode;

                if (opcode == MMCO_SHORT2UNUSED || opcode == MMCO_SHORT2LONG) {

                    mmco[i].short_pic_num =

                        (sl->curr_pic_num - get_ue_golomb(gb) - 1) &

                            (sl->max_pic_num - 1);

#if 0

                    if (mmco[i].short_pic_num >= h->short_ref_count ||

                        !h->short_ref[mmco[i].short_pic_num]) {

                        av_log(s->avctx, AV_LOG_ERROR,

                               "illegal short ref in memory management control "

                               "operation %d\n", mmco);

                        return -1;

                    }

#endif

                }

                if (opcode == MMCO_SHORT2LONG || opcode == MMCO_LONG2UNUSED ||

                    opcode == MMCO_LONG || opcode == MMCO_SET_MAX_LONG) {

                    unsigned int long_arg = get_ue_golomb_31(gb);

                    if (long_arg >= 32 ||

                        (long_arg >= 16 && !(opcode == MMCO_SET_MAX_LONG &&

                                             long_arg == 16) &&

                         !(opcode == MMCO_LONG2UNUSED && FIELD_PICTURE(h)))) {

                        av_log(h->avctx, AV_LOG_ERROR,

                               "illegal long ref in memory management control "

                               "operation %d\n", opcode);

                        return -1;

                    }

                    mmco[i].long_arg = long_arg;

                }



                if (opcode > (unsigned) MMCO_LONG) {

                    av_log(h->avctx, AV_LOG_ERROR,

                           "illegal memory management control operation %d\n",

                           opcode);

                    return -1;

                }

                if (opcode == MMCO_END)

                    break;

            }

            nb_mmco = i;

        }

    }



    sl->nb_mmco = nb_mmco;



    return 0;

}

int ff_h264_decode_ref_pic_marking(const H264Context *h, H264SliceContext *sl,

                                   GetBitContext *gb)

{

    int i;

    MMCO *mmco = sl->mmco;

    int nb_mmco = 0;



    if (h->nal_unit_type == NAL_IDR_SLICE) { 

        skip_bits1(gb); 

        if (get_bits1(gb)) {

            mmco[0].opcode   = MMCO_LONG;

            mmco[0].long_arg = 0;

            nb_mmco          = 1;

        }

        sl->explicit_ref_marking = 1;

    } else {

        sl->explicit_ref_marking = get_bits1(gb);

        if (sl->explicit_ref_marking) {

            for (i = 0; i < MAX_MMCO_COUNT; i++) {

                MMCOOpcode opcode = get_ue_golomb_31(gb);



                mmco[i].opcode = opcode;

                if (opcode == MMCO_SHORT2UNUSED || opcode == MMCO_SHORT2LONG) {

                    mmco[i].short_pic_num =

                        (sl->curr_pic_num - get_ue_golomb(gb) - 1) &

                            (sl->max_pic_num - 1);

#if 0

                    if (mmco[i].short_pic_num >= h->short_ref_count ||

                        !h->short_ref[mmco[i].short_pic_num]) {

                        av_log(s->avctx, AV_LOG_ERROR,

                               "illegal short ref in memory management control "

                               "operation %d\n", mmco);

                        return -1;

                    }

#endif

                }

                if (opcode == MMCO_SHORT2LONG || opcode == MMCO_LONG2UNUSED ||

                    opcode == MMCO_LONG || opcode == MMCO_SET_MAX_LONG) {

                    unsigned int long_arg = get_ue_golomb_31(gb);

                    if (long_arg >= 32 ||

                        (long_arg >= 16 && !(opcode == MMCO_SET_MAX_LONG &&

                                             long_arg == 16) &&

                         !(opcode == MMCO_LONG2UNUSED && FIELD_PICTURE(h)))) {

                        av_log(h->avctx, AV_LOG_ERROR,

                               "illegal long ref in memory management control "

                               "operation %d\n", opcode);

                        return -1;

                    }

                    mmco[i].long_arg = long_arg;

                }



                if (opcode > (unsigned) MMCO_LONG) {

                    av_log(h->avctx, AV_LOG_ERROR,

                           "illegal memory management control operation %d\n",

                           opcode);

                    return -1;

                }

                if (opcode == MMCO_END)

                    break;

            }

            nb_mmco = i;

        }

    }



    sl->nb_mmco = nb_mmco;



    return 0;

}

int FUNC_0(const H264Context *VAR_0, H264SliceContext *VAR_1,

                                   GetBitContext *VAR_2)

{

    int VAR_3;

    MMCO *mmco = VAR_1->mmco;

    int VAR_4 = 0;



    if (VAR_0->nal_unit_type == NAL_IDR_SLICE) { 

        skip_bits1(VAR_2); 

        if (get_bits1(VAR_2)) {

            mmco[0].opcode   = MMCO_LONG;

            mmco[0].long_arg = 0;

            VAR_4          = 1;

        }

        VAR_1->explicit_ref_marking = 1;

    } else {

        VAR_1->explicit_ref_marking = get_bits1(VAR_2);

        if (VAR_1->explicit_ref_marking) {

            for (VAR_3 = 0; VAR_3 < MAX_MMCO_COUNT; VAR_3++) {

                MMCOOpcode opcode = get_ue_golomb_31(VAR_2);



                mmco[VAR_3].opcode = opcode;

                if (opcode == MMCO_SHORT2UNUSED || opcode == MMCO_SHORT2LONG) {

                    mmco[VAR_3].short_pic_num =

                        (VAR_1->curr_pic_num - get_ue_golomb(VAR_2) - 1) &

                            (VAR_1->max_pic_num - 1);

#if 0

                    if (mmco[VAR_3].short_pic_num >= VAR_0->short_ref_count ||

                        !VAR_0->short_ref[mmco[VAR_3].short_pic_num]) {

                        av_log(s->avctx, AV_LOG_ERROR,

                               "illegal short ref in memory management control "

                               "operation %d\n", mmco);

                        return -1;

                    }

#endif

                }

                if (opcode == MMCO_SHORT2LONG || opcode == MMCO_LONG2UNUSED ||

                    opcode == MMCO_LONG || opcode == MMCO_SET_MAX_LONG) {

                    unsigned int long_arg = get_ue_golomb_31(VAR_2);

                    if (long_arg >= 32 ||

                        (long_arg >= 16 && !(opcode == MMCO_SET_MAX_LONG &&

                                             long_arg == 16) &&

                         !(opcode == MMCO_LONG2UNUSED && FIELD_PICTURE(VAR_0)))) {

                        av_log(VAR_0->avctx, AV_LOG_ERROR,

                               "illegal long ref in memory management control "

                               "operation %d\n", opcode);

                        return -1;

                    }

                    mmco[VAR_3].long_arg = long_arg;

                }



                if (opcode > (unsigned) MMCO_LONG) {

                    av_log(VAR_0->avctx, AV_LOG_ERROR,

                           "illegal memory management control operation %d\n",

                           opcode);

                    return -1;

                }

                if (opcode == MMCO_END)

                    break;

            }

            VAR_4 = VAR_3;

        }

    }



    VAR_1->VAR_4 = VAR_4;



    return 0;

}

int FUNC_0(const H264Context *VAR_0, H264SliceContext *VAR_1,
GetBitContext *VAR_2)
{ int VAR_3; MMCO *mmco = VAR_1->mmco; int VAR_4 = 0; if (VAR_0->nal_unit_type == NAL_IDR_SLICE) { skip_bits1(VAR_2); if (get_bits1(VAR_2)) { mmco[0].opcode   = MMCO_LONG; mmco[0].long_arg = 0; VAR_4          = 1; } VAR_1->explicit_ref_marking = 1; } else { VAR_1->explicit_ref_marking = get_bits1(VAR_2); if (VAR_1->explicit_ref_marking) { for (VAR_3 = 0; VAR_3 < MAX_MMCO_COUNT; VAR_3++) { MMCOOpcode opcode = get_ue_golomb_31(VAR_2); mmco[VAR_3].opcode = opcode; if (opcode == MMCO_SHORT2UNUSED || opcode == MMCO_SHORT2LONG) { mmco[VAR_3].short_pic_num =
(VAR_1->curr_pic_num - get_ue_golomb(VAR_2) - 1) &
(VAR_1->max_pic_num - 1); #if 0
if (mmco[VAR_3].short_pic_num >= VAR_0->short_ref_count ||
!VAR_0->short_ref[mmco[VAR_3].short_pic_num]) { av_log(s->avctx, AV_LOG_ERROR,
"illegal short ref in memory management control "
"operation %d\n", mmco); return -1; } #endif
} if (opcode == MMCO_SHORT2LONG || opcode == MMCO_LONG2UNUSED ||
opcode == MMCO_LONG || opcode == MMCO_SET_MAX_LONG) { unsigned int long_arg = get_ue_golomb_31(VAR_2); if (long_arg >= 32 ||
(long_arg >= 16 && !(opcode == MMCO_SET_MAX_LONG &&
long_arg == 16) &&
!(opcode == MMCO_LONG2UNUSED && FIELD_PICTURE(VAR_0)))) { av_log(VAR_0->avctx, AV_LOG_ERROR,
"illegal long ref in memory management control "
"operation %d\n", opcode); return -1; } mmco[VAR_3].long_arg = long_arg; } if (opcode > (unsigned) MMCO_LONG) { av_log(VAR_0->avctx, AV_LOG_ERROR,
"illegal memory management control operation %d\n",
opcode); return -1; } if (opcode == MMCO_END)
break; } VAR_4 = VAR_3; } } VAR_1->VAR_4 = VAR_4; return 0; }