@@ -378,9 +378,6 @@ static HEVCFrame *find_ref_idx(HEVCContext *s, int poc, uint8_t use_msb)
}
}
- if (s->nal_unit_type != HEVC_NAL_CRA_NUT && !IS_BLA(s))
- av_log(s->avctx, AV_LOG_ERROR,
- "Could not find ref with POC %d\n", poc);
return NULL;
}
@@ -426,7 +423,7 @@ 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, uint8_t use_msb)
+ int poc, int ref_flag, uint8_t use_msb, enum RPSType rps_type)
{
HEVCFrame *ref = find_ref_idx(s, poc, use_msb);
@@ -434,6 +431,15 @@ static int add_candidate_ref(HEVCContext *s, RefPicList *list,
return AVERROR_INVALIDDATA;
if (!ref) {
+ int allow_missing = !(rps_type == ST_CURR_BEF || rps_type == ST_CURR_AFT ||
+ rps_type == LT_CURR);
+
+ /* skip generating missing refs in foll lists as they are not used by current frame */
+ if (allow_missing)
+ return 0;
+
+ av_log(s->avctx, AV_LOG_ERROR, "Could not find ref with POC %d\n", poc);
+
ref = generate_missing_ref(s, poc);
if (!ref)
return AVERROR(ENOMEM);
@@ -484,7 +490,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, 1);
+ ret = add_candidate_ref(s, &rps[list], poc, HEVC_FRAME_FLAG_SHORT_REF, 1, list);
if (ret < 0)
goto fail;
}
@@ -494,7 +500,8 @@ 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, long_rps->poc_msb_present[i]);
+ ret = add_candidate_ref(s, &rps[list], poc, HEVC_FRAME_FLAG_LONG_REF, long_rps->poc_msb_present[i],
+ list);
if (ret < 0)
goto fail;
}