diff options
author | Xu Guangxin <guangxin.xu@intel.com> | 2022-07-15 13:06:42 +0800 |
---|---|---|
committer | Haihao Xiang <haihao.xiang@intel.com> | 2022-07-27 10:54:38 +0800 |
commit | 99501b50157702af191a6cc8d0ddb89663d69d61 (patch) | |
tree | fab8c12f1c41e62c048e3173dc9927fd10e2e47a /libavcodec/hevc_refs.c | |
parent | 6c12fe0ddaf5bf9914027f1f4acfc196008c9aba (diff) |
lavc/hevcdec: do not let missing ref frames invovled in dpb process
We will generate a new frame for a missed reference. The frame can only
be used for reference. We assign an invalid decode sequence to it, so
it will not be involved in any dpb process.
Tested-by: Fei Wang <fei.w.wang@intel.com>
Signed-off-by: Fei Wang <fei.w.wang@intel.com>
Signed-off-by: Xu Guangxin <guangxin.xu@intel.com>
Diffstat (limited to 'libavcodec/hevc_refs.c')
-rw-r--r-- | libavcodec/hevc_refs.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c index 2b0468d6c4..5282716a61 100644 --- a/libavcodec/hevc_refs.c +++ b/libavcodec/hevc_refs.c @@ -173,6 +173,16 @@ int ff_hevc_set_new_ref(HEVCContext *s, AVFrame **frame, int poc) return 0; } +static void unref_missing_refs(HEVCContext *s) +{ + for (int i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) { + HEVCFrame *frame = &s->DPB[i]; + if (frame->sequence == HEVC_SEQUENCE_COUNTER_INVALID) { + ff_hevc_unref_frame(s, frame, ~0); + } + } +} + int ff_hevc_output_frame(HEVCContext *s, AVFrame *out, int flush) { if (IS_IRAP(s) && s->no_rasl_output_flag == 1) { @@ -233,7 +243,7 @@ int ff_hevc_output_frame(HEVCContext *s, AVFrame *out, int flush) } if (s->seq_output != s->seq_decode) - s->seq_output = (s->seq_output + 1) & 0xff; + s->seq_output = (s->seq_output + 1) & HEVC_SEQUENCE_COUNTER_MASK; else break; } while (1); @@ -419,7 +429,7 @@ static HEVCFrame *generate_missing_ref(HEVCContext *s, int poc) } frame->poc = poc; - frame->sequence = s->seq_decode; + frame->sequence = HEVC_SEQUENCE_COUNTER_INVALID; frame->flags = 0; if (s->threads_type == FF_THREAD_FRAME) @@ -463,6 +473,8 @@ int ff_hevc_frame_rps(HEVCContext *s) return 0; } + unref_missing_refs(s); + /* clear the reference flags on all frames except the current one */ for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) { HEVCFrame *frame = &s->DPB[i]; |