int ff_generate_sliding_window_mmcos(H264Context *h, int first_slice)

{

    MMCO mmco_temp[MAX_MMCO_COUNT], *mmco = first_slice ? h->mmco : mmco_temp;

    int mmco_index = 0, i;



    assert(h->long_ref_count + h->short_ref_count <= h->sps.ref_frame_count);



    if (h->short_ref_count &&

        h->long_ref_count + h->short_ref_count == h->sps.ref_frame_count &&

        !(FIELD_PICTURE(h) && !h->first_field && h->cur_pic_ptr->reference)) {

        mmco[0].opcode        = MMCO_SHORT2UNUSED;

        mmco[0].short_pic_num = h->short_ref[h->short_ref_count - 1]->frame_num;

        mmco_index            = 1;

        if (FIELD_PICTURE(h)) {

            mmco[0].short_pic_num *= 2;

            mmco[1].opcode         = MMCO_SHORT2UNUSED;

            mmco[1].short_pic_num  = mmco[0].short_pic_num + 1;

            mmco_index             = 2;

        }

    }



    if (first_slice) {

        h->mmco_index = mmco_index;

    } else if (!first_slice && mmco_index >= 0 &&

               (mmco_index != h->mmco_index ||

                (i = check_opcodes(h->mmco, mmco_temp, mmco_index)))) {

        av_log(h->avctx, AV_LOG_ERROR,

               "Inconsistent MMCO state between slices [%d, %d, %d]\n",

               mmco_index, h->mmco_index, i);

        return AVERROR_INVALIDDATA;

    }

    return 0;

}

int ff_generate_sliding_window_mmcos(H264Context *h, int first_slice)

{

    MMCO mmco_temp[MAX_MMCO_COUNT], *mmco = first_slice ? h->mmco : mmco_temp;

    int mmco_index = 0, i;



    assert(h->long_ref_count + h->short_ref_count <= h->sps.ref_frame_count);



    if (h->short_ref_count &&

        h->long_ref_count + h->short_ref_count == h->sps.ref_frame_count &&

        !(FIELD_PICTURE(h) && !h->first_field && h->cur_pic_ptr->reference)) {

        mmco[0].opcode        = MMCO_SHORT2UNUSED;

        mmco[0].short_pic_num = h->short_ref[h->short_ref_count - 1]->frame_num;

        mmco_index            = 1;

        if (FIELD_PICTURE(h)) {

            mmco[0].short_pic_num *= 2;

            mmco[1].opcode         = MMCO_SHORT2UNUSED;

            mmco[1].short_pic_num  = mmco[0].short_pic_num + 1;

            mmco_index             = 2;

        }

    }



    if (first_slice) {

        h->mmco_index = mmco_index;

    } else if (!first_slice && mmco_index >= 0 &&

               (mmco_index != h->mmco_index ||

                (i = check_opcodes(h->mmco, mmco_temp, mmco_index)))) {

        av_log(h->avctx, AV_LOG_ERROR,

               "Inconsistent MMCO state between slices [%d, %d, %d]\n",

               mmco_index, h->mmco_index, i);

        return AVERROR_INVALIDDATA;

    }

    return 0;

}

    int mmco_index = 0, i;
int FUNC_0(H264Context *VAR_0, int VAR_1)

{

    MMCO mmco_temp[MAX_MMCO_COUNT], *mmco = VAR_1 ? VAR_0->mmco : mmco_temp;

    int VAR_2 = 0, VAR_3;



    assert(VAR_0->long_ref_count + VAR_0->short_ref_count <= VAR_0->sps.ref_frame_count);



    if (VAR_0->short_ref_count &&

        VAR_0->long_ref_count + VAR_0->short_ref_count == VAR_0->sps.ref_frame_count &&

        !(FIELD_PICTURE(VAR_0) && !VAR_0->first_field && VAR_0->cur_pic_ptr->reference)) {

        mmco[0].opcode        = MMCO_SHORT2UNUSED;

        mmco[0].short_pic_num = VAR_0->short_ref[VAR_0->short_ref_count - 1]->frame_num;

        VAR_2            = 1;

        if (FIELD_PICTURE(VAR_0)) {

            mmco[0].short_pic_num *= 2;

            mmco[1].opcode         = MMCO_SHORT2UNUSED;

            mmco[1].short_pic_num  = mmco[0].short_pic_num + 1;

            VAR_2             = 2;

        }

    }



    if (VAR_1) {

        VAR_0->VAR_2 = VAR_2;

    } else if (!VAR_1 && VAR_2 >= 0 &&

               (VAR_2 != VAR_0->VAR_2 ||

                (VAR_3 = check_opcodes(VAR_0->mmco, mmco_temp, VAR_2)))) {

        av_log(VAR_0->avctx, AV_LOG_ERROR,

               "Inconsistent MMCO state between slices [%d, %d, %d]\n",

               VAR_2, VAR_0->VAR_2, VAR_3);

        return AVERROR_INVALIDDATA;

    }

    return 0;

}

int FUNC_0(H264Context *VAR_0, int VAR_1)
{ MMCO mmco_temp[MAX_MMCO_COUNT], *mmco = VAR_1 ? VAR_0->mmco : mmco_temp; int VAR_2 = 0, VAR_3; assert(VAR_0->long_ref_count + VAR_0->short_ref_count <= VAR_0->sps.ref_frame_count); if (VAR_0->short_ref_count &&
VAR_0->long_ref_count + VAR_0->short_ref_count == VAR_0->sps.ref_frame_count &&
!(FIELD_PICTURE(VAR_0) && !VAR_0->first_field && VAR_0->cur_pic_ptr->reference)) { mmco[0].opcode        = MMCO_SHORT2UNUSED; mmco[0].short_pic_num = VAR_0->short_ref[VAR_0->short_ref_count - 1]->frame_num; VAR_2            = 1; if (FIELD_PICTURE(VAR_0)) { mmco[0].short_pic_num *= 2; mmco[1].opcode         = MMCO_SHORT2UNUSED; mmco[1].short_pic_num  = mmco[0].short_pic_num + 1; VAR_2             = 2; } } if (VAR_1) { VAR_0->VAR_2 = VAR_2; } else if (!VAR_1 && VAR_2 >= 0 && (VAR_2 != VAR_0->VAR_2 ||
(VAR_3 = check_opcodes(VAR_0->mmco, mmco_temp, VAR_2)))) { av_log(VAR_0->avctx, AV_LOG_ERROR,
"Inconsistent MMCO state between slices [%d, %d, %d]\n",
VAR_2, VAR_0->VAR_2, VAR_3); return AVERROR_INVALIDDATA; } return 0; }