[FFmpeg-devel,v2,1/2] lavc/hevcdec: Put slice address checking after hwaccel decode slice

Message ID 20240619022722.1054455-1-fei.w.wang@intel.com
State New
Headers
Series [FFmpeg-devel,v2,1/2] lavc/hevcdec: Put slice address checking after hwaccel decode slice |

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Wang, Fei W June 19, 2024, 2:27 a.m. UTC
From: Fei Wang <fei.w.wang@intel.com>

Slice address tab only been updated in software decode slice data.

Fixes hwaccel decoding after d725c737fe2a19091b481d4d115fd939e0a674b2.

Signed-off-by: Fei Wang <fei.w.wang@intel.com>
---
 libavcodec/hevc/hevcdec.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
  

Comments

Wang, Fei W June 21, 2024, 5:11 a.m. UTC | #1
On Wed, 2024-06-19 at 10:27 +0800, fei.w.wang@intel.com wrote:
> From: Fei Wang <fei.w.wang@intel.com>
> 
> Slice address tab only been updated in software decode slice data.
> 
> Fixes hwaccel decoding after
> d725c737fe2a19091b481d4d115fd939e0a674b2.
> 
> Signed-off-by: Fei Wang <fei.w.wang@intel.com>
> ---
>  libavcodec/hevc/hevcdec.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
> index 1d2e53afc3..39beb7e4dc 100644
> --- a/libavcodec/hevc/hevcdec.c
> +++ b/libavcodec/hevc/hevcdec.c
> @@ -2770,15 +2770,6 @@ static int decode_slice_data(HEVCContext *s,
> const H2645NAL *nal, GetBitContext
>      const HEVCPPS *pps = s->pps;
>      int ret;
>  
> -    if (s->sh.dependent_slice_segment_flag) {
> -        int ctb_addr_ts = pps->ctb_addr_rs_to_ts[s-
> >sh.slice_ctb_addr_rs];
> -        int prev_rs = pps->ctb_addr_ts_to_rs[ctb_addr_ts - 1];
> -        if (s->tab_slice_address[prev_rs] != s->sh.slice_addr) {
> -            av_log(s->avctx, AV_LOG_ERROR, "Previous slice segment
> missing\n");
> -            return AVERROR_INVALIDDATA;
> -        }
> -    }
> -
>      if (!s->sh.dependent_slice_segment_flag && s->sh.slice_type !=
> HEVC_SLICE_I) {
>          ret = ff_hevc_slice_rpl(s);
>          if (ret < 0) {
> @@ -2799,6 +2790,15 @@ static int decode_slice_data(HEVCContext *s,
> const H2645NAL *nal, GetBitContext
>          return AVERROR_PATCHWELCOME;
>      }
>  
> +    if (s->sh.dependent_slice_segment_flag) {
> +        int ctb_addr_ts = pps->ctb_addr_rs_to_ts[s-
> >sh.slice_ctb_addr_rs];
> +        int prev_rs = pps->ctb_addr_ts_to_rs[ctb_addr_ts - 1];
> +        if (s->tab_slice_address[prev_rs] != s->sh.slice_addr) {
> +            av_log(s->avctx, AV_LOG_ERROR, "Previous slice segment
> missing\n");
> +            return AVERROR_INVALIDDATA;
> +        }
> +    }
> +

Ping for review/merge.

Thanks
Fei

>      s->local_ctx[0].first_qp_group = !s-
> >sh.dependent_slice_segment_flag;
>  
>      if (!pps->cu_qp_delta_enabled_flag)
  

Patch

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 1d2e53afc3..39beb7e4dc 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -2770,15 +2770,6 @@  static int decode_slice_data(HEVCContext *s, const H2645NAL *nal, GetBitContext
     const HEVCPPS *pps = s->pps;
     int ret;
 
-    if (s->sh.dependent_slice_segment_flag) {
-        int ctb_addr_ts = pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs];
-        int prev_rs = pps->ctb_addr_ts_to_rs[ctb_addr_ts - 1];
-        if (s->tab_slice_address[prev_rs] != s->sh.slice_addr) {
-            av_log(s->avctx, AV_LOG_ERROR, "Previous slice segment missing\n");
-            return AVERROR_INVALIDDATA;
-        }
-    }
-
     if (!s->sh.dependent_slice_segment_flag && s->sh.slice_type != HEVC_SLICE_I) {
         ret = ff_hevc_slice_rpl(s);
         if (ret < 0) {
@@ -2799,6 +2790,15 @@  static int decode_slice_data(HEVCContext *s, const H2645NAL *nal, GetBitContext
         return AVERROR_PATCHWELCOME;
     }
 
+    if (s->sh.dependent_slice_segment_flag) {
+        int ctb_addr_ts = pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs];
+        int prev_rs = pps->ctb_addr_ts_to_rs[ctb_addr_ts - 1];
+        if (s->tab_slice_address[prev_rs] != s->sh.slice_addr) {
+            av_log(s->avctx, AV_LOG_ERROR, "Previous slice segment missing\n");
+            return AVERROR_INVALIDDATA;
+        }
+    }
+
     s->local_ctx[0].first_qp_group = !s->sh.dependent_slice_segment_flag;
 
     if (!pps->cu_qp_delta_enabled_flag)