static int add_candidate_ref(HEVCContext *s, RefPicList *list,

                             int poc, int ref_flag)

{

    HEVCFrame *ref = find_ref_idx(s, poc);



    if (ref == s->ref)

        return AVERROR_INVALIDDATA;



    if (!ref) {

        ref = generate_missing_ref(s, poc);

        if (!ref)

            return AVERROR(ENOMEM);

    }



    list->list[list->nb_refs] = ref->poc;

    list->ref[list->nb_refs]  = ref;

    list->nb_refs++;



    mark_ref(ref, ref_flag);

    return 0;

}

static int add_candidate_ref(HEVCContext *s, RefPicList *list,

                             int poc, int ref_flag)

{

    HEVCFrame *ref = find_ref_idx(s, poc);



    if (ref == s->ref)

        return AVERROR_INVALIDDATA;



    if (!ref) {

        ref = generate_missing_ref(s, poc);

        if (!ref)

            return AVERROR(ENOMEM);

    }



    list->list[list->nb_refs] = ref->poc;

    list->ref[list->nb_refs]  = ref;

    list->nb_refs++;



    mark_ref(ref, ref_flag);

    return 0;

}

    if (ref == s->ref)
static int FUNC_0(HEVCContext *VAR_0, RefPicList *VAR_1,

                             int VAR_2, int VAR_3)

{

    HEVCFrame *ref = find_ref_idx(VAR_0, VAR_2);



    if (ref == VAR_0->ref)

        return AVERROR_INVALIDDATA;



    if (!ref) {

        ref = generate_missing_ref(VAR_0, VAR_2);

        if (!ref)

            return AVERROR(ENOMEM);

    }



    VAR_1->VAR_1[VAR_1->nb_refs] = ref->VAR_2;

    VAR_1->ref[VAR_1->nb_refs]  = ref;

    VAR_1->nb_refs++;



    mark_ref(ref, VAR_3);

    return 0;

}

static int FUNC_0(HEVCContext *VAR_0, RefPicList *VAR_1,
int VAR_2, int VAR_3)
{ HEVCFrame *ref = find_ref_idx(VAR_0, VAR_2); if (ref == VAR_0->ref)
return AVERROR_INVALIDDATA; if (!ref) { ref = generate_missing_ref(VAR_0, VAR_2); if (!ref)
return AVERROR(ENOMEM); } VAR_1->VAR_1[VAR_1->nb_refs] = ref->VAR_2; VAR_1->ref[VAR_1->nb_refs]  = ref; VAR_1->nb_refs++; mark_ref(ref, VAR_3); return 0; }