diff mbox series

[FFmpeg-devel,v2,3/4] lavc/hevc_refs: exclude current frame from long term refs

Message ID 20220614012302.2808428-3-fei.w.wang@intel.com
State New
Headers show
Series [FFmpeg-devel,v2,1/4] lavc/hevc_refs: fix dpb logical for IRAP | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Wang, Fei W June 14, 2022, 1:23 a.m. UTC
From: Xu Guangxin <guangxin.xu@intel.com>

suppose
a. You have 3 frames, 0, 1, 4096.
b. The ltMask is 0xfff and use_msb is 0.
c. The 0, 1 are lt refs for 4096.
d. you are decoding frame 4096, and get the 0 frame.
Since 4096 & ltMask is 0 too, even you want get 0, find_ref_idx may give you 4096.
add_candidate_ref will report an error for this

Tested-by: Fei Wang <fei.w.wang@intel.com>
Signed-off-by: Xu Guangxin <guangxin.xu@intel.com>
---
 libavcodec/hevc_refs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Xiang, Haihao July 14, 2022, 5:02 a.m. UTC | #1
On Tue, 2022-06-14 at 09:23 +0800, Fei Wang wrote:
> From: Xu Guangxin <guangxin.xu@intel.com>
> 
> suppose
> a. You have 3 frames, 0, 1, 4096.
> b. The ltMask is 0xfff and use_msb is 0.
> c. The 0, 1 are lt refs for 4096.
> d. you are decoding frame 4096, and get the 0 frame.
> Since 4096 & ltMask is 0 too, even you want get 0, find_ref_idx may give you
> 4096.
> add_candidate_ref will report an error for this
> 
> Tested-by: Fei Wang <fei.w.wang@intel.com>
> Signed-off-by: Xu Guangxin <guangxin.xu@intel.com>
> ---
>  libavcodec/hevc_refs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c
> index 89053fd1a2..b3d5f96043 100644
> --- a/libavcodec/hevc_refs.c
> +++ b/libavcodec/hevc_refs.c
> @@ -386,7 +386,7 @@ static HEVCFrame *find_ref_idx(HEVCContext *s, int poc,
> uint8_t use_msb)
>      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 & mask) == poc)
> +            if ((ref->poc & mask) == poc && (use_msb || ref->poc != s->poc))
>                  return ref;
>          }
>      }

LGTM

-Haihao
diff mbox series

Patch

diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c
index 89053fd1a2..b3d5f96043 100644
--- a/libavcodec/hevc_refs.c
+++ b/libavcodec/hevc_refs.c
@@ -386,7 +386,7 @@  static HEVCFrame *find_ref_idx(HEVCContext *s, int poc, uint8_t use_msb)
     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 & mask) == poc)
+            if ((ref->poc & mask) == poc && (use_msb || ref->poc != s->poc))
                 return ref;
         }
     }