X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fhevc_refs.c;h=4f6d985ae604fc46b000bc72bbc82630c449c00b;hb=e83717e63eab1f1b78dc0990e5b8e927097fca29;hp=7870a72fd6d2c12c890c55d64dafef0f4907d32f;hpb=da8936969fe695a042282d5686e12227745d299a;p=ffmpeg diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c index 7870a72fd6d..4f6d985ae60 100644 --- a/libavcodec/hevc_refs.c +++ b/libavcodec/hevc_refs.c @@ -358,23 +358,15 @@ int ff_hevc_slice_rpl(HEVCContext *s) return 0; } -static HEVCFrame *find_ref_idx(HEVCContext *s, int poc) +static HEVCFrame *find_ref_idx(HEVCContext *s, int poc, uint8_t use_msb) { + int mask = use_msb ? ~0 : (1 << s->ps.sps->log2_max_poc_lsb) - 1; int i; - int LtMask = (1 << s->ps.sps->log2_max_poc_lsb) - 1; - - for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) { - HEVCFrame *ref = &s->DPB[i]; - if (ref->frame->buf[0] && (ref->sequence == s->seq_decode)) { - if ((ref->poc & LtMask) == poc) - return ref; - } - } for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) { HEVCFrame *ref = &s->DPB[i]; if (ref->frame->buf[0] && ref->sequence == s->seq_decode) { - if (ref->poc == poc || (ref->poc & LtMask) == poc) + if ((ref->poc & mask) == poc) return ref; } } @@ -427,9 +419,9 @@ static HEVCFrame *generate_missing_ref(HEVCContext *s, int poc) /* add a reference with the given poc to the list and mark it as used in DPB */ static int add_candidate_ref(HEVCContext *s, RefPicList *list, - int poc, int ref_flag) + int poc, int ref_flag, uint8_t use_msb) { - HEVCFrame *ref = find_ref_idx(s, poc); + HEVCFrame *ref = find_ref_idx(s, poc, use_msb); if (ref == s->ref || list->nb_refs >= HEVC_MAX_REFS) return AVERROR_INVALIDDATA; @@ -485,7 +477,7 @@ int ff_hevc_frame_rps(HEVCContext *s) else list = ST_CURR_AFT; - ret = add_candidate_ref(s, &rps[list], poc, HEVC_FRAME_FLAG_SHORT_REF); + ret = add_candidate_ref(s, &rps[list], poc, HEVC_FRAME_FLAG_SHORT_REF, 1); if (ret < 0) goto fail; } @@ -495,7 +487,7 @@ int ff_hevc_frame_rps(HEVCContext *s) int poc = long_rps->poc[i]; int list = long_rps->used[i] ? LT_CURR : LT_FOLL; - ret = add_candidate_ref(s, &rps[list], poc, HEVC_FRAME_FLAG_LONG_REF); + ret = add_candidate_ref(s, &rps[list], poc, HEVC_FRAME_FLAG_LONG_REF, long_rps->poc_msb_present[i]); if (ret < 0) goto fail; }