diff mbox series

[FFmpeg-devel,29/39] lavc/hevcdec: move calling hwaccel decode_slice to decode_slice_data()

Message ID 20240607130135.9088-29-anton@khirnov.net
State New
Headers show
Series [FFmpeg-devel,01/39] lavc/hevcdec: do not free SliceHeader arrays in pic_arrays_free() | expand

Commit Message

Anton Khirnov June 7, 2024, 1:01 p.m. UTC
From decode_nal_unit(), as that is a more appropriate place for it.
---
 libavcodec/hevc/hevcdec.c | 38 +++++++++++++++++---------------------
 1 file changed, 17 insertions(+), 21 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 0bf68ea45c..c148244361 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -2811,6 +2811,15 @@  static int decode_slice_data(HEVCContext *s, const H2645NAL *nal, GetBitContext
         }
     }
 
+    if (s->avctx->hwaccel)
+        return FF_HW_CALL(s->avctx, decode_slice, nal->raw_data, nal->raw_size);
+
+    if (s->avctx->profile == AV_PROFILE_HEVC_SCC) {
+        av_log(s->avctx, AV_LOG_ERROR,
+               "SCC profile is not yet implemented in hevc native decoder.\n");
+        return AVERROR_PATCHWELCOME;
+    }
+
     s->local_ctx[0].first_qp_group = !s->sh.dependent_slice_segment_flag;
 
     if (!pps->cu_qp_delta_enabled_flag)
@@ -3152,30 +3161,17 @@  static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal)
             }
         }
 
-        if (s->avctx->hwaccel) {
-            ret = FF_HW_CALL(s->avctx, decode_slice, nal->raw_data, nal->raw_size);
+        ctb_addr_ts = decode_slice_data(s, nal, &gb);
+        if (ctb_addr_ts >= s->cur_frame->ctb_count) {
+            ret = hevc_frame_end(s);
             if (ret < 0)
                 goto fail;
-        } else {
-            if (s->avctx->profile == AV_PROFILE_HEVC_SCC) {
-                av_log(s->avctx, AV_LOG_ERROR,
-                       "SCC profile is not yet implemented in hevc native decoder.\n");
-                ret = AVERROR_PATCHWELCOME;
-                goto fail;
-            }
+            s->is_decoded = 1;
+        }
 
-            ctb_addr_ts = decode_slice_data(s, nal, &gb);
-            if (ctb_addr_ts >= s->cur_frame->ctb_count) {
-                ret = hevc_frame_end(s);
-                if (ret < 0)
-                    goto fail;
-                s->is_decoded = 1;
-            }
-
-            if (ctb_addr_ts < 0) {
-                ret = ctb_addr_ts;
-                goto fail;
-            }
+        if (ctb_addr_ts < 0) {
+            ret = ctb_addr_ts;
+            goto fail;
         }
         break;
     case HEVC_NAL_EOS_NUT: