Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 01/11] lavc/hevcdec: move handling of byte alignment at the end of slice header
@ 2024-05-31 17:47 Anton Khirnov
  2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 02/11] lavc/hevcdec: drop a useless condition Anton Khirnov
                   ` (9 more replies)
  0 siblings, 10 replies; 14+ messages in thread
From: Anton Khirnov @ 2024-05-31 17:47 UTC (permalink / raw)
  To: ffmpeg-devel

Do it in hls_slice_header() rather than cabac_init_decoder() - the
former is a more logical place as according the spec the byte alignment
is a part of the slice header, not slice data. Avoids a second instance
of alignment handling in vaapi_hevc.

Also, check that alignment_bit_equal_to_one is, in fact, equal to one.
---
 libavcodec/hevc_cabac.c | 2 --
 libavcodec/hevcdec.c    | 7 +++++++
 libavcodec/hevcdec.h    | 1 +
 libavcodec/vaapi_hevc.c | 4 +---
 4 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/libavcodec/hevc_cabac.c b/libavcodec/hevc_cabac.c
index 2e639a7e41..3f95c9ca05 100644
--- a/libavcodec/hevc_cabac.c
+++ b/libavcodec/hevc_cabac.c
@@ -430,8 +430,6 @@ static int cabac_reinit(HEVCLocalContext *lc)
 static int cabac_init_decoder(HEVCLocalContext *lc)
 {
     GetBitContext *gb = &lc->gb;
-    skip_bits(gb, 1);
-    align_get_bits(gb);
     return ff_init_cabac_decoder(&lc->cc,
                           gb->buffer + get_bits_count(gb) / 8,
                           (get_bits_left(gb) + 7) / 8);
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index ff9a418926..ad2cbd7ece 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -1005,6 +1005,13 @@ static int hls_slice_header(HEVCContext *s)
             skip_bits(gb, 8);  // slice_header_extension_data_byte
     }
 
+    ret = get_bits1(gb);
+    if (!ret) {
+        av_log(s->avctx, AV_LOG_ERROR, "alignment_bit_equal_to_one=0\n");
+        return AVERROR_INVALIDDATA;
+    }
+    sh->data_offset = align_get_bits(gb) - gb->buffer;
+
     // Inferred parameters
     sh->slice_qp = 26U + s->ps.pps->pic_init_qp_minus26 + sh->slice_qp_delta;
     if (sh->slice_qp > 51 ||
diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h
index 5aa3d40450..3824bf621b 100644
--- a/libavcodec/hevcdec.h
+++ b/libavcodec/hevcdec.h
@@ -277,6 +277,7 @@ typedef struct SliceHeader {
     int16_t chroma_offset_l1[16][2];
 
     int slice_ctb_addr_rs;
+    unsigned data_offset;
 } SliceHeader;
 
 typedef struct CodingUnit {
diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
index 0f5dd50351..f0a0f295d9 100644
--- a/libavcodec/vaapi_hevc.c
+++ b/libavcodec/vaapi_hevc.c
@@ -485,9 +485,7 @@ static int vaapi_hevc_decode_slice(AVCodecContext *avctx,
         .slice_data_size               = size,
         .slice_data_offset             = 0,
         .slice_data_flag               = VA_SLICE_DATA_FLAG_ALL,
-        /* Add 1 to the bits count here to account for the byte_alignment bit, which
-         * always is at least one bit and not accounted for otherwise. */
-        .slice_data_byte_offset        = (get_bits_count(&h->HEVClc->gb) + 1 + 7) / 8,
+        .slice_data_byte_offset        = sh->data_offset,
         .slice_segment_address         = sh->slice_segment_addr,
         .slice_qp_delta                = sh->slice_qp_delta,
         .slice_cb_qp_offset            = sh->slice_cb_qp_offset,
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [FFmpeg-devel] [PATCH 02/11] lavc/hevcdec: drop a useless condition
  2024-05-31 17:47 [FFmpeg-devel] [PATCH 01/11] lavc/hevcdec: move handling of byte alignment at the end of slice header Anton Khirnov
@ 2024-05-31 17:47 ` Anton Khirnov
  2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 03/11] lavc/hevcdec: include first row in SliceHeader.offset/size Anton Khirnov
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Anton Khirnov @ 2024-05-31 17:47 UTC (permalink / raw)
  To: ffmpeg-devel

hls_slice_data_wpp() is only called when num_entry_point_offsets>0
---
 libavcodec/hevcdec.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index ad2cbd7ece..d3715f9de7 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -2742,16 +2742,15 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal)
         s->sh.offset[i - 1] = offset;
 
     }
-    if (s->sh.num_entry_point_offsets != 0) {
-        offset += s->sh.entry_point_offset[s->sh.num_entry_point_offsets - 1] - cmpt;
-        if (length < offset) {
-            av_log(s->avctx, AV_LOG_ERROR, "entry_point_offset table is corrupted\n");
-            return AVERROR_INVALIDDATA;
-        }
-        s->sh.size[s->sh.num_entry_point_offsets - 1] = length - offset;
-        s->sh.offset[s->sh.num_entry_point_offsets - 1] = offset;
 
+    offset += s->sh.entry_point_offset[s->sh.num_entry_point_offsets - 1] - cmpt;
+    if (length < offset) {
+        av_log(s->avctx, AV_LOG_ERROR, "entry_point_offset table is corrupted\n");
+        return AVERROR_INVALIDDATA;
     }
+    s->sh.size[s->sh.num_entry_point_offsets - 1] = length - offset;
+    s->sh.offset[s->sh.num_entry_point_offsets - 1] = offset;
+
     s->data = data;
 
     for (i = 1; i < s->threads_number; i++) {
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [FFmpeg-devel] [PATCH 03/11] lavc/hevcdec: include first row in SliceHeader.offset/size
  2024-05-31 17:47 [FFmpeg-devel] [PATCH 01/11] lavc/hevcdec: move handling of byte alignment at the end of slice header Anton Khirnov
  2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 02/11] lavc/hevcdec: drop a useless condition Anton Khirnov
@ 2024-05-31 17:47 ` Anton Khirnov
  2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 04/11] lavc/hevcdec: drop HEVCLocalContext.gb Anton Khirnov
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Anton Khirnov @ 2024-05-31 17:47 UTC (permalink / raw)
  To: ffmpeg-devel

Will be useful in the following commit.
---
 libavcodec/hevcdec.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index d3715f9de7..42fd33961b 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -975,8 +975,8 @@ static int hls_slice_header(HEVCContext *s)
             av_freep(&sh->offset);
             av_freep(&sh->size);
             sh->entry_point_offset = av_malloc_array(sh->num_entry_point_offsets, sizeof(unsigned));
-            sh->offset = av_malloc_array(sh->num_entry_point_offsets, sizeof(int));
-            sh->size = av_malloc_array(sh->num_entry_point_offsets, sizeof(int));
+            sh->offset             = av_malloc_array(sh->num_entry_point_offsets + 1, sizeof(int));
+            sh->size               = av_malloc_array(sh->num_entry_point_offsets + 1, sizeof(int));
             if (!sh->entry_point_offset || !sh->offset || !sh->size) {
                 sh->num_entry_point_offsets = 0;
                 av_log(s->avctx, AV_LOG_ERROR, "Failed to allocate memory\n");
@@ -2608,10 +2608,10 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *hevc_lclist,
     int ret;
 
     if(ctb_row) {
-        ret = init_get_bits8(&lc->gb, s->data + s->sh.offset[ctb_row - 1], s->sh.size[ctb_row - 1]);
+        ret = init_get_bits8(&lc->gb, s->data + s->sh.offset[ctb_row], s->sh.size[ctb_row]);
         if (ret < 0)
             goto error;
-        ff_init_cabac_decoder(&lc->cc, s->data + s->sh.offset[(ctb_row)-1], s->sh.size[ctb_row - 1]);
+        ff_init_cabac_decoder(&lc->cc, s->data + s->sh.offset[ctb_row], s->sh.size[ctb_row]);
     }
 
     while(more_data && ctb_addr_ts < s->ps.sps->ctb_size) {
@@ -2738,8 +2738,8 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal)
                 cmpt++;
             }
         }
-        s->sh.size[i - 1] = s->sh.entry_point_offset[i] - cmpt;
-        s->sh.offset[i - 1] = offset;
+        s->sh.size[i]   = s->sh.entry_point_offset[i] - cmpt;
+        s->sh.offset[i] = offset;
 
     }
 
@@ -2748,8 +2748,11 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal)
         av_log(s->avctx, AV_LOG_ERROR, "entry_point_offset table is corrupted\n");
         return AVERROR_INVALIDDATA;
     }
-    s->sh.size[s->sh.num_entry_point_offsets - 1] = length - offset;
-    s->sh.offset[s->sh.num_entry_point_offsets - 1] = offset;
+    s->sh.size  [s->sh.num_entry_point_offsets] = length - offset;
+    s->sh.offset[s->sh.num_entry_point_offsets] = offset;
+
+    s->sh.offset[0] = s->sh.data_offset;
+    s->sh.size[0]   = s->sh.offset[1] - s->sh.offset[0];
 
     s->data = data;
 
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [FFmpeg-devel] [PATCH 04/11] lavc/hevcdec: drop HEVCLocalContext.gb
  2024-05-31 17:47 [FFmpeg-devel] [PATCH 01/11] lavc/hevcdec: move handling of byte alignment at the end of slice header Anton Khirnov
  2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 02/11] lavc/hevcdec: drop a useless condition Anton Khirnov
  2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 03/11] lavc/hevcdec: include first row in SliceHeader.offset/size Anton Khirnov
@ 2024-05-31 17:47 ` Anton Khirnov
  2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 05/11] lavc/hevcdec: drop HEVCContext.HEVClc Anton Khirnov
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Anton Khirnov @ 2024-05-31 17:47 UTC (permalink / raw)
  To: ffmpeg-devel

In all HEVCLocalContext instances except the first one, the bitreader is
never used for actually reading bits, but merely for passing the buffer
to ff_init_cabac_decoder(), which is better done directly.

The instance that actually is used for bitreading gets moved to stack in
decode_nal_unit(), which makes its lifetime clearer.
---
 libavcodec/hevc_cabac.c | 17 +++++-----------
 libavcodec/hevcdec.c    | 43 +++++++++++++++++++----------------------
 libavcodec/hevcdec.h    |  4 ++--
 3 files changed, 27 insertions(+), 37 deletions(-)

diff --git a/libavcodec/hevc_cabac.c b/libavcodec/hevc_cabac.c
index 3f95c9ca05..71bd678972 100644
--- a/libavcodec/hevc_cabac.c
+++ b/libavcodec/hevc_cabac.c
@@ -427,14 +427,6 @@ static int cabac_reinit(HEVCLocalContext *lc)
     return skip_bytes(&lc->cc, 0) == NULL ? AVERROR_INVALIDDATA : 0;
 }
 
-static int cabac_init_decoder(HEVCLocalContext *lc)
-{
-    GetBitContext *gb = &lc->gb;
-    return ff_init_cabac_decoder(&lc->cc,
-                          gb->buffer + get_bits_count(gb) / 8,
-                          (get_bits_left(gb) + 7) / 8);
-}
-
 static void cabac_init_state(HEVCLocalContext *lc, const HEVCContext *s)
 {
     int init_type = 2 - s->sh.slice_type;
@@ -459,12 +451,13 @@ static void cabac_init_state(HEVCLocalContext *lc, const HEVCContext *s)
         lc->stat_coeff[i] = 0;
 }
 
-int ff_hevc_cabac_init(HEVCLocalContext *lc, int ctb_addr_ts)
+int ff_hevc_cabac_init(HEVCLocalContext *lc, int ctb_addr_ts,
+                       const uint8_t *data, size_t size)
 {
     const HEVCContext *const s = lc->parent;
 
     if (ctb_addr_ts == s->ps.pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs]) {
-        int ret = cabac_init_decoder(lc);
+        int ret = ff_init_cabac_decoder(&lc->cc, data, size);
         if (ret < 0)
             return ret;
         if (s->sh.dependent_slice_segment_flag == 0 ||
@@ -488,7 +481,7 @@ int ff_hevc_cabac_init(HEVCLocalContext *lc, int ctb_addr_ts)
             if (s->threads_number == 1)
                 ret = cabac_reinit(lc);
             else {
-                ret = cabac_init_decoder(lc);
+                ret = ff_init_cabac_decoder(&lc->cc, data, size);
             }
             if (ret < 0)
                 return ret;
@@ -501,7 +494,7 @@ int ff_hevc_cabac_init(HEVCLocalContext *lc, int ctb_addr_ts)
                 if (s->threads_number == 1)
                     ret = cabac_reinit(lc);
                 else {
-                    ret = cabac_init_decoder(lc);
+                    ret = ff_init_cabac_decoder(&lc->cc, data, size);
                 }
                 if (ret < 0)
                     return ret;
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 42fd33961b..0a9443505a 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -593,9 +593,8 @@ fail:
     return ret;
 }
 
-static int hls_slice_header(HEVCContext *s)
+static int hls_slice_header(HEVCContext *s, GetBitContext *gb)
 {
-    GetBitContext *gb = &s->HEVClc->gb;
     SliceHeader *sh   = &s->sh;
     int i, ret;
 
@@ -2533,9 +2532,11 @@ static void hls_decode_neighbour(HEVCLocalContext *lc, int x_ctb, int y_ctb,
     lc->ctb_up_left_flag = ((x_ctb > 0) && (y_ctb > 0)  && (ctb_addr_in_slice-1 >= s->ps.sps->ctb_width) && (s->ps.pps->tile_id[ctb_addr_ts] == s->ps.pps->tile_id[s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs-1 - s->ps.sps->ctb_width]]));
 }
 
-static int hls_decode_entry(HEVCContext *s)
+static int hls_decode_entry(HEVCContext *s, GetBitContext *gb)
 {
     HEVCLocalContext *const lc = s->HEVClc;
+    const uint8_t *slice_data = gb->buffer + s->sh.data_offset;
+    const size_t   slice_size = gb->buffer_end - gb->buffer - s->sh.data_offset;
     int ctb_size    = 1 << s->ps.sps->log2_ctb_size;
     int more_data   = 1;
     int x_ctb       = 0;
@@ -2563,7 +2564,7 @@ static int hls_decode_entry(HEVCContext *s)
         y_ctb = (ctb_addr_rs / ((s->ps.sps->width + ctb_size - 1) >> s->ps.sps->log2_ctb_size)) << s->ps.sps->log2_ctb_size;
         hls_decode_neighbour(lc, x_ctb, y_ctb, ctb_addr_ts);
 
-        ret = ff_hevc_cabac_init(lc, ctb_addr_ts);
+        ret = ff_hevc_cabac_init(lc, ctb_addr_ts, slice_data, slice_size);
         if (ret < 0) {
             s->tab_slice_address[ctb_addr_rs] = -1;
             return ret;
@@ -2605,14 +2606,14 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *hevc_lclist,
     int ctb_addr_rs = s->sh.slice_ctb_addr_rs + ctb_row * ((s->ps.sps->width + ctb_size - 1) >> s->ps.sps->log2_ctb_size);
     int ctb_addr_ts = s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs];
     int thread = ctb_row % s->threads_number;
+
+    const uint8_t *data      = s->data + s->sh.offset[ctb_row];
+    const size_t   data_size = s->sh.size[ctb_row];
+
     int ret;
 
-    if(ctb_row) {
-        ret = init_get_bits8(&lc->gb, s->data + s->sh.offset[ctb_row], s->sh.size[ctb_row]);
-        if (ret < 0)
-            goto error;
-        ff_init_cabac_decoder(&lc->cc, s->data + s->sh.offset[ctb_row], s->sh.size[ctb_row]);
-    }
+    if (ctb_row)
+        ff_init_cabac_decoder(&lc->cc, data, data_size);
 
     while(more_data && ctb_addr_ts < s->ps.sps->ctb_size) {
         int x_ctb = (ctb_addr_rs % s->ps.sps->ctb_width) << s->ps.sps->log2_ctb_size;
@@ -2630,7 +2631,7 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *hevc_lclist,
             return 0;
         }
 
-        ret = ff_hevc_cabac_init(lc, ctb_addr_ts);
+        ret = ff_hevc_cabac_init(lc, ctb_addr_ts, data, data_size);
         if (ret < 0)
             goto error;
         hls_sao_param(lc, x_ctb >> s->ps.sps->log2_ctb_size, y_ctb >> s->ps.sps->log2_ctb_size);
@@ -2681,7 +2682,6 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal)
 {
     const uint8_t *data = nal->data;
     int length          = nal->size;
-    HEVCLocalContext *lc;
     int *ret;
     int64_t offset;
     int64_t startheader, cmpt = 0;
@@ -2719,8 +2719,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal)
         s->nb_local_ctx = s->threads_number;
     }
 
-    lc     = &s->local_ctx[0];
-    offset = (lc->gb.index >> 3);
+    offset = s->sh.data_offset;
 
     for (j = 0, cmpt = 0, startheader = offset + s->sh.entry_point_offset[0]; j < nal->skipped_bytes; j++) {
         if (nal->skipped_bytes_pos[j] >= offset && nal->skipped_bytes_pos[j] < startheader) {
@@ -2981,11 +2980,9 @@ static int hevc_frame_end(HEVCContext *s)
 
 static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal)
 {
-    HEVCLocalContext *lc = s->HEVClc;
-    GetBitContext *gb    = &lc->gb;
+    GetBitContext     gb = nal->gb;
     int ctb_addr_ts, ret;
 
-    *gb              = nal->gb;
     s->nal_unit_type = nal->type;
     s->temporal_id   = nal->temporal_id;
 
@@ -2997,7 +2994,7 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal)
             if (ret < 0)
                 goto fail;
         }
-        ret = ff_hevc_decode_nal_vps(gb, s->avctx, &s->ps);
+        ret = ff_hevc_decode_nal_vps(&gb, s->avctx, &s->ps);
         if (ret < 0)
             goto fail;
         break;
@@ -3008,7 +3005,7 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal)
             if (ret < 0)
                 goto fail;
         }
-        ret = ff_hevc_decode_nal_sps(gb, s->avctx, &s->ps,
+        ret = ff_hevc_decode_nal_sps(&gb, s->avctx, &s->ps,
                                      s->apply_defdispwin);
         if (ret < 0)
             goto fail;
@@ -3020,7 +3017,7 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal)
             if (ret < 0)
                 goto fail;
         }
-        ret = ff_hevc_decode_nal_pps(gb, s->avctx, &s->ps);
+        ret = ff_hevc_decode_nal_pps(&gb, s->avctx, &s->ps);
         if (ret < 0)
             goto fail;
         break;
@@ -3032,7 +3029,7 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal)
             if (ret < 0)
                 goto fail;
         }
-        ret = ff_hevc_decode_nal_sei(gb, s->avctx, &s->sei, &s->ps, s->nal_unit_type);
+        ret = ff_hevc_decode_nal_sei(&gb, s->avctx, &s->sei, &s->ps, s->nal_unit_type);
         if (ret < 0)
             goto fail;
         break;
@@ -3052,7 +3049,7 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal)
     case HEVC_NAL_RADL_R:
     case HEVC_NAL_RASL_N:
     case HEVC_NAL_RASL_R:
-        ret = hls_slice_header(s);
+        ret = hls_slice_header(s, &gb);
         if (ret < 0)
             return ret;
         if (ret == 1) {
@@ -3134,7 +3131,7 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal)
             if (s->threads_number > 1 && s->sh.num_entry_point_offsets > 0)
                 ctb_addr_ts = hls_slice_data_wpp(s, nal);
             else
-                ctb_addr_ts = hls_decode_entry(s);
+                ctb_addr_ts = hls_decode_entry(s, &gb);
             if (ctb_addr_ts >= (s->ps.sps->ctb_width * s->ps.sps->ctb_height)) {
                 ret = hevc_frame_end(s);
                 if (ret < 0)
diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h
index 3824bf621b..0ed51a5392 100644
--- a/libavcodec/hevcdec.h
+++ b/libavcodec/hevcdec.h
@@ -394,7 +394,6 @@ typedef struct HEVCLocalContext {
     void *logctx;
     const struct HEVCContext *parent;
 
-    GetBitContext gb;
     CABACContext cc;
 
     /**
@@ -583,7 +582,8 @@ int ff_hevc_frame_rps(HEVCContext *s);
 int ff_hevc_slice_rpl(HEVCContext *s);
 
 void ff_hevc_save_states(HEVCLocalContext *lc, int ctb_addr_ts);
-int ff_hevc_cabac_init(HEVCLocalContext *lc, int ctb_addr_ts);
+int ff_hevc_cabac_init(HEVCLocalContext *lc, int ctb_addr_ts,
+                       const uint8_t *data, size_t size);
 int ff_hevc_sao_merge_flag_decode(HEVCLocalContext *lc);
 int ff_hevc_sao_type_idx_decode(HEVCLocalContext *lc);
 int ff_hevc_sao_band_position_decode(HEVCLocalContext *lc);
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [FFmpeg-devel] [PATCH 05/11] lavc/hevcdec: drop HEVCContext.HEVClc
  2024-05-31 17:47 [FFmpeg-devel] [PATCH 01/11] lavc/hevcdec: move handling of byte alignment at the end of slice header Anton Khirnov
                   ` (2 preceding siblings ...)
  2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 04/11] lavc/hevcdec: drop HEVCLocalContext.gb Anton Khirnov
@ 2024-05-31 17:47 ` Anton Khirnov
  2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 06/11] lavc/hevcdec: rename HEVCContext.ref to cur_frame Anton Khirnov
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Anton Khirnov @ 2024-05-31 17:47 UTC (permalink / raw)
  To: ffmpeg-devel

It is merely a pointer to local_ctx[0], which we can just as well use
directly.
---
 libavcodec/hevcdec.c | 24 ++++++++++--------------
 libavcodec/hevcdec.h |  2 --
 2 files changed, 10 insertions(+), 16 deletions(-)

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 0a9443505a..75d0ed613a 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -1036,14 +1036,14 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb)
         return AVERROR_INVALIDDATA;
     }
 
-    s->HEVClc->first_qp_group = !s->sh.dependent_slice_segment_flag;
+    s->local_ctx[0].first_qp_group = !s->sh.dependent_slice_segment_flag;
 
     if (!s->ps.pps->cu_qp_delta_enabled_flag)
-        s->HEVClc->qp_y = s->sh.slice_qp;
+        s->local_ctx[0].qp_y = s->sh.slice_qp;
 
     s->slice_initialized = 1;
-    s->HEVClc->tu.cu_qp_offset_cb = 0;
-    s->HEVClc->tu.cu_qp_offset_cr = 0;
+    s->local_ctx[0].tu.cu_qp_offset_cb = 0;
+    s->local_ctx[0].tu.cu_qp_offset_cr = 0;
 
     return 0;
 }
@@ -2534,7 +2534,7 @@ static void hls_decode_neighbour(HEVCLocalContext *lc, int x_ctb, int y_ctb,
 
 static int hls_decode_entry(HEVCContext *s, GetBitContext *gb)
 {
-    HEVCLocalContext *const lc = s->HEVClc;
+    HEVCLocalContext *const lc = &s->local_ctx[0];
     const uint8_t *slice_data = gb->buffer + s->sh.data_offset;
     const size_t   slice_size = gb->buffer_end - gb->buffer - s->sh.data_offset;
     int ctb_size    = 1 << s->ps.sps->log2_ctb_size;
@@ -2704,7 +2704,6 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal)
         memcpy(tmp, s->local_ctx, sizeof(*s->local_ctx) * s->nb_local_ctx);
         av_free(s->local_ctx);
         s->local_ctx = tmp;
-        s->HEVClc    = &s->local_ctx[0];
 
         for (unsigned i = s->nb_local_ctx; i < s->threads_number; i++) {
             tmp = &s->local_ctx[i];
@@ -2757,7 +2756,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal)
 
     for (i = 1; i < s->threads_number; i++) {
         s->local_ctx[i].first_qp_group = 1;
-        s->local_ctx[i].qp_y = s->HEVClc->qp_y;
+        s->local_ctx[i].qp_y = s->local_ctx[0].qp_y;
     }
 
     atomic_store(&s->wpp_err, 0);
@@ -2868,7 +2867,6 @@ static int set_side_data(HEVCContext *s)
 
 static int hevc_frame_start(HEVCContext *s)
 {
-    HEVCLocalContext *lc = s->HEVClc;
     int pic_size_in_ctb  = ((s->ps.sps->width  >> s->ps.sps->log2_min_cb_size) + 1) *
                            ((s->ps.sps->height >> s->ps.sps->log2_min_cb_size) + 1);
     int ret;
@@ -2885,7 +2883,7 @@ static int hevc_frame_start(HEVCContext *s)
     s->no_rasl_output_flag = IS_IDR(s) || IS_BLA(s) || (s->nal_unit_type == HEVC_NAL_CRA_NUT && s->last_eos);
 
     if (s->ps.pps->tiles_enabled_flag)
-        lc->end_of_tiles_x = s->ps.pps->column_width[0] << s->ps.sps->log2_ctb_size;
+        s->local_ctx[0].end_of_tiles_x = s->ps.pps->column_width[0] << s->ps.sps->log2_ctb_size;
 
     ret = ff_hevc_set_new_ref(s, &s->frame, s->poc);
     if (ret < 0)
@@ -3505,11 +3503,9 @@ static av_cold int hevc_init_context(AVCodecContext *avctx)
         return AVERROR(ENOMEM);
     s->nb_local_ctx = 1;
 
-    s->HEVClc = &s->local_ctx[0];
-
-    s->HEVClc->parent = s;
-    s->HEVClc->logctx = avctx;
-    s->HEVClc->common_cabac_state = &s->cabac;
+    s->local_ctx[0].parent = s;
+    s->local_ctx[0].logctx = avctx;
+    s->local_ctx[0].common_cabac_state = &s->cabac;
 
     s->output_frame = av_frame_alloc();
     if (!s->output_frame)
diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h
index 0ed51a5392..6957cd1091 100644
--- a/libavcodec/hevcdec.h
+++ b/libavcodec/hevcdec.h
@@ -452,8 +452,6 @@ typedef struct HEVCContext {
     HEVCLocalContext     *local_ctx;
     unsigned           nb_local_ctx;
 
-    HEVCLocalContext    *HEVClc;
-
     uint8_t             threads_type;
     uint8_t             threads_number;
 
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [FFmpeg-devel] [PATCH 06/11] lavc/hevcdec: rename HEVCContext.ref to cur_frame
  2024-05-31 17:47 [FFmpeg-devel] [PATCH 01/11] lavc/hevcdec: move handling of byte alignment at the end of slice header Anton Khirnov
                   ` (3 preceding siblings ...)
  2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 05/11] lavc/hevcdec: drop HEVCContext.HEVClc Anton Khirnov
@ 2024-05-31 17:47 ` Anton Khirnov
  2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 07/11] lavc/hevcdec: rename HEVCFrame.frame to just f Anton Khirnov
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Anton Khirnov @ 2024-05-31 17:47 UTC (permalink / raw)
  To: ffmpeg-devel

Since it stores a pointer to the current frame.
---
 libavcodec/dxva2_hevc.c        | 12 +++---
 libavcodec/hevc_filter.c       | 34 ++++++++---------
 libavcodec/hevc_mvs.c          | 20 +++++-----
 libavcodec/hevc_refs.c         | 18 ++++-----
 libavcodec/hevcdec.c           | 68 +++++++++++++++++-----------------
 libavcodec/hevcdec.h           |  2 +-
 libavcodec/hevcpred_template.c |  2 +-
 libavcodec/nvdec_hevc.c        |  6 +--
 libavcodec/vaapi_hevc.c        | 18 ++++-----
 libavcodec/vdpau_hevc.c        | 10 ++---
 libavcodec/vulkan_hevc.c       |  6 +--
 11 files changed, 98 insertions(+), 98 deletions(-)

diff --git a/libavcodec/dxva2_hevc.c b/libavcodec/dxva2_hevc.c
index b500d7917a..2d6c2f812f 100644
--- a/libavcodec/dxva2_hevc.c
+++ b/libavcodec/dxva2_hevc.c
@@ -61,7 +61,7 @@ void ff_dxva2_hevc_fill_picture_parameters(const AVCodecContext *avctx, AVDXVACo
                                     DXVA_PicParams_HEVC *pp)
 {
     const HEVCContext *h = avctx->priv_data;
-    const HEVCFrame *current_picture = h->ref;
+    const HEVCFrame *current_picture = h->cur_frame;
     const HEVCSPS *sps = h->ps.sps;
     const HEVCPPS *pps = h->ps.pps;
     int i, j;
@@ -245,7 +245,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx,
 {
     const HEVCContext *h = avctx->priv_data;
     AVDXVAContext *ctx = DXVA_CONTEXT(avctx);
-    const HEVCFrame *current_picture = h->ref;
+    const HEVCFrame *current_picture = h->cur_frame;
     struct hevc_dxva2_picture_context *ctx_pic = current_picture->hwaccel_picture_private;
     DXVA_Slice_HEVC_Short *slice = NULL;
     void     *dxva_data_ptr;
@@ -364,7 +364,7 @@ static int dxva2_hevc_start_frame(AVCodecContext *avctx,
 {
     const HEVCContext *h = avctx->priv_data;
     AVDXVAContext *ctx = DXVA_CONTEXT(avctx);
-    struct hevc_dxva2_picture_context *ctx_pic = h->ref->hwaccel_picture_private;
+    struct hevc_dxva2_picture_context *ctx_pic = h->cur_frame->hwaccel_picture_private;
 
     if (!DXVA_CONTEXT_VALID(avctx, ctx))
         return -1;
@@ -387,7 +387,7 @@ static int dxva2_hevc_decode_slice(AVCodecContext *avctx,
                                    uint32_t size)
 {
     const HEVCContext *h = avctx->priv_data;
-    const HEVCFrame *current_picture = h->ref;
+    const HEVCFrame *current_picture = h->cur_frame;
     struct hevc_dxva2_picture_context *ctx_pic = current_picture->hwaccel_picture_private;
     unsigned position;
 
@@ -408,14 +408,14 @@ static int dxva2_hevc_decode_slice(AVCodecContext *avctx,
 static int dxva2_hevc_end_frame(AVCodecContext *avctx)
 {
     HEVCContext *h = avctx->priv_data;
-    struct hevc_dxva2_picture_context *ctx_pic = h->ref->hwaccel_picture_private;
+    struct hevc_dxva2_picture_context *ctx_pic = h->cur_frame->hwaccel_picture_private;
     int scale = ctx_pic->pp.dwCodingParamToolFlags & 1;
     int ret;
 
     if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0)
         return -1;
 
-    ret = ff_dxva2_common_end_frame(avctx, h->ref->frame,
+    ret = ff_dxva2_common_end_frame(avctx, h->cur_frame->frame,
                                     &ctx_pic->pp, sizeof(ctx_pic->pp),
                                     scale ? &ctx_pic->qm : NULL, scale ? sizeof(ctx_pic->qm) : 0,
                                     commit_bitstream_and_slice_buffer);
diff --git a/libavcodec/hevc_filter.c b/libavcodec/hevc_filter.c
index 6bc3019147..0ba419a7b8 100644
--- a/libavcodec/hevc_filter.c
+++ b/libavcodec/hevc_filter.c
@@ -661,8 +661,8 @@ static int boundary_strength(const HEVCContext *s, const MvField *curr, const Mv
 {
     if (curr->pred_flag == PF_BI &&  neigh->pred_flag == PF_BI) {
         // same L0 and L1
-        if (s->ref->refPicList[0].list[curr->ref_idx[0]] == neigh_refPicList[0].list[neigh->ref_idx[0]]  &&
-            s->ref->refPicList[0].list[curr->ref_idx[0]] == s->ref->refPicList[1].list[curr->ref_idx[1]] &&
+        if (s->cur_frame->refPicList[0].list[curr->ref_idx[0]] == neigh_refPicList[0].list[neigh->ref_idx[0]]  &&
+            s->cur_frame->refPicList[0].list[curr->ref_idx[0]] == s->cur_frame->refPicList[1].list[curr->ref_idx[1]] &&
             neigh_refPicList[0].list[neigh->ref_idx[0]] == neigh_refPicList[1].list[neigh->ref_idx[1]]) {
             if ((FFABS(neigh->mv[0].x - curr->mv[0].x) >= 4 || FFABS(neigh->mv[0].y - curr->mv[0].y) >= 4 ||
                  FFABS(neigh->mv[1].x - curr->mv[1].x) >= 4 || FFABS(neigh->mv[1].y - curr->mv[1].y) >= 4) &&
@@ -671,15 +671,15 @@ static int boundary_strength(const HEVCContext *s, const MvField *curr, const Mv
                 return 1;
             else
                 return 0;
-        } else if (neigh_refPicList[0].list[neigh->ref_idx[0]] == s->ref->refPicList[0].list[curr->ref_idx[0]] &&
-                   neigh_refPicList[1].list[neigh->ref_idx[1]] == s->ref->refPicList[1].list[curr->ref_idx[1]]) {
+        } else if (neigh_refPicList[0].list[neigh->ref_idx[0]] == s->cur_frame->refPicList[0].list[curr->ref_idx[0]] &&
+                   neigh_refPicList[1].list[neigh->ref_idx[1]] == s->cur_frame->refPicList[1].list[curr->ref_idx[1]]) {
             if (FFABS(neigh->mv[0].x - curr->mv[0].x) >= 4 || FFABS(neigh->mv[0].y - curr->mv[0].y) >= 4 ||
                 FFABS(neigh->mv[1].x - curr->mv[1].x) >= 4 || FFABS(neigh->mv[1].y - curr->mv[1].y) >= 4)
                 return 1;
             else
                 return 0;
-        } else if (neigh_refPicList[1].list[neigh->ref_idx[1]] == s->ref->refPicList[0].list[curr->ref_idx[0]] &&
-                   neigh_refPicList[0].list[neigh->ref_idx[0]] == s->ref->refPicList[1].list[curr->ref_idx[1]]) {
+        } else if (neigh_refPicList[1].list[neigh->ref_idx[1]] == s->cur_frame->refPicList[0].list[curr->ref_idx[0]] &&
+                   neigh_refPicList[0].list[neigh->ref_idx[0]] == s->cur_frame->refPicList[1].list[curr->ref_idx[1]]) {
             if (FFABS(neigh->mv[1].x - curr->mv[0].x) >= 4 || FFABS(neigh->mv[1].y - curr->mv[0].y) >= 4 ||
                 FFABS(neigh->mv[0].x - curr->mv[1].x) >= 4 || FFABS(neigh->mv[0].y - curr->mv[1].y) >= 4)
                 return 1;
@@ -694,10 +694,10 @@ static int boundary_strength(const HEVCContext *s, const MvField *curr, const Mv
 
         if (curr->pred_flag & 1) {
             A     = curr->mv[0];
-            ref_A = s->ref->refPicList[0].list[curr->ref_idx[0]];
+            ref_A = s->cur_frame->refPicList[0].list[curr->ref_idx[0]];
         } else {
             A     = curr->mv[1];
-            ref_A = s->ref->refPicList[1].list[curr->ref_idx[1]];
+            ref_A = s->cur_frame->refPicList[1].list[curr->ref_idx[1]];
         }
 
         if (neigh->pred_flag & 1) {
@@ -724,7 +724,7 @@ void ff_hevc_deblocking_boundary_strengths(HEVCLocalContext *lc, int x0, int y0,
                                            int log2_trafo_size)
 {
     const HEVCContext *s = lc->parent;
-    const MvField *tab_mvf = s->ref->tab_mvf;
+    const MvField *tab_mvf = s->cur_frame->tab_mvf;
     int log2_min_pu_size = s->ps.sps->log2_min_pu_size;
     int log2_min_tu_size = s->ps.sps->log2_min_tb_size;
     int min_pu_width     = s->ps.sps->min_pu_width;
@@ -746,8 +746,8 @@ void ff_hevc_deblocking_boundary_strengths(HEVCLocalContext *lc, int x0, int y0,
 
     if (boundary_upper) {
         const RefPicList *rpl_top = (lc->boundary_flags & BOUNDARY_UPPER_SLICE) ?
-                                    ff_hevc_get_ref_list(s, s->ref, x0, y0 - 1) :
-                                    s->ref->refPicList;
+                                    ff_hevc_get_ref_list(s, s->cur_frame, x0, y0 - 1) :
+                                    s->cur_frame->refPicList;
         int yp_pu = (y0 - 1) >> log2_min_pu_size;
         int yq_pu =  y0      >> log2_min_pu_size;
         int yp_tu = (y0 - 1) >> log2_min_tu_size;
@@ -784,8 +784,8 @@ void ff_hevc_deblocking_boundary_strengths(HEVCLocalContext *lc, int x0, int y0,
 
     if (boundary_left) {
         const RefPicList *rpl_left = (lc->boundary_flags & BOUNDARY_LEFT_SLICE) ?
-                                     ff_hevc_get_ref_list(s, s->ref, x0 - 1, y0) :
-                                     s->ref->refPicList;
+                                     ff_hevc_get_ref_list(s, s->cur_frame, x0 - 1, y0) :
+                                     s->cur_frame->refPicList;
         int xp_pu = (x0 - 1) >> log2_min_pu_size;
         int xq_pu =  x0      >> log2_min_pu_size;
         int xp_tu = (x0 - 1) >> log2_min_tu_size;
@@ -810,7 +810,7 @@ void ff_hevc_deblocking_boundary_strengths(HEVCLocalContext *lc, int x0, int y0,
     }
 
     if (log2_trafo_size > log2_min_pu_size && !is_intra) {
-        const RefPicList *rpl = s->ref->refPicList;
+        const RefPicList *rpl = s->cur_frame->refPicList;
 
         // bs for TU internal horizontal PU boundaries
         for (j = 8; j < (1 << log2_trafo_size); j += 8) {
@@ -874,15 +874,15 @@ void ff_hevc_hls_filter(HEVCLocalContext *lc, int x, int y, int ctb_size)
         if (y && x_end) {
             sao_filter_CTB(lc, s, x, y - ctb_size);
             if (s->threads_type & FF_THREAD_FRAME )
-                ff_progress_frame_report(&s->ref->tf, y);
+                ff_progress_frame_report(&s->cur_frame->tf, y);
         }
         if (x_end && y_end) {
             sao_filter_CTB(lc, s, x , y);
             if (s->threads_type & FF_THREAD_FRAME )
-                ff_progress_frame_report(&s->ref->tf, y + ctb_size);
+                ff_progress_frame_report(&s->cur_frame->tf, y + ctb_size);
         }
     } else if (s->threads_type & FF_THREAD_FRAME && x_end)
-        ff_progress_frame_report(&s->ref->tf, y + ctb_size - 4);
+        ff_progress_frame_report(&s->cur_frame->tf, y + ctb_size - 4);
 }
 
 void ff_hevc_hls_filters(HEVCLocalContext *lc, int x_ctb, int y_ctb, int ctb_size)
diff --git a/libavcodec/hevc_mvs.c b/libavcodec/hevc_mvs.c
index 5591919e2e..b56f0bece5 100644
--- a/libavcodec/hevc_mvs.c
+++ b/libavcodec/hevc_mvs.c
@@ -165,7 +165,7 @@ static int derive_temporal_colocated_mvs(const HEVCContext *s, MvField temp_col,
                                          int refIdxLx, Mv *mvLXCol, int X,
                                          int colPic, const RefPicList *refPicList_col)
 {
-    const RefPicList *refPicList = s->ref->refPicList;
+    const RefPicList *refPicList = s->cur_frame->refPicList;
 
     if (temp_col.pred_flag == PF_INTRA)
         return 0;
@@ -291,8 +291,8 @@ static void derive_spatial_merge_candidates(HEVCLocalContext *lc, const HEVCCont
                                             int merge_idx,
                                             struct MvField mergecandlist[])
 {
-    const RefPicList *refPicList = s->ref->refPicList;
-    const MvField *tab_mvf       = s->ref->tab_mvf;
+    const RefPicList *refPicList = s->cur_frame->refPicList;
+    const MvField *tab_mvf       = s->cur_frame->tab_mvf;
 
     const int min_pu_width = s->ps.sps->min_pu_width;
 
@@ -514,8 +514,8 @@ static av_always_inline void dist_scale(const HEVCContext *s, Mv *mv,
                                         int min_pu_width, int x, int y,
                                         int elist, int ref_idx_curr, int ref_idx)
 {
-    const RefPicList *refPicList = s->ref->refPicList;
-    const MvField *tab_mvf       = s->ref->tab_mvf;
+    const RefPicList *refPicList = s->cur_frame->refPicList;
+    const MvField *tab_mvf       = s->cur_frame->tab_mvf;
     int ref_pic_elist      = refPicList[elist].list[TAB_MVF(x, y).ref_idx[elist]];
     int ref_pic_curr       = refPicList[ref_idx_curr].list[ref_idx];
 
@@ -530,10 +530,10 @@ static av_always_inline void dist_scale(const HEVCContext *s, Mv *mv,
 static int mv_mp_mode_mx(const HEVCContext *s, int x, int y, int pred_flag_index,
                          Mv *mv, int ref_idx_curr, int ref_idx)
 {
-    const MvField *tab_mvf = s->ref->tab_mvf;
+    const MvField *tab_mvf = s->cur_frame->tab_mvf;
     int min_pu_width = s->ps.sps->min_pu_width;
 
-    const RefPicList *refPicList = s->ref->refPicList;
+    const RefPicList *refPicList = s->cur_frame->refPicList;
 
     if (((TAB_MVF(x, y).pred_flag) & (1 << pred_flag_index)) &&
         refPicList[pred_flag_index].list[TAB_MVF(x, y).ref_idx[pred_flag_index]] == refPicList[ref_idx_curr].list[ref_idx]) {
@@ -546,10 +546,10 @@ static int mv_mp_mode_mx(const HEVCContext *s, int x, int y, int pred_flag_index
 static int mv_mp_mode_mx_lt(const HEVCContext *s, int x, int y, int pred_flag_index,
                             Mv *mv, int ref_idx_curr, int ref_idx)
 {
-    const MvField *tab_mvf = s->ref->tab_mvf;
+    const MvField *tab_mvf = s->cur_frame->tab_mvf;
     int min_pu_width = s->ps.sps->min_pu_width;
 
-    const RefPicList *refPicList = s->ref->refPicList;
+    const RefPicList *refPicList = s->cur_frame->refPicList;
 
     if ((TAB_MVF(x, y).pred_flag) & (1 << pred_flag_index)) {
         int currIsLongTerm     = refPicList[ref_idx_curr].isLongTerm[ref_idx];
@@ -586,7 +586,7 @@ void ff_hevc_luma_mv_mvp_mode(HEVCLocalContext *lc, int x0, int y0, int nPbW,
                               int mvp_lx_flag, int LX)
 {
     const HEVCContext *const s = lc->parent;
-    const MvField *const tab_mvf = s->ref->tab_mvf;
+    const MvField *const tab_mvf = s->cur_frame->tab_mvf;
     int isScaledFlag_L0 = 0;
     int availableFlagLXA0 = 1;
     int availableFlagLXB0 = 1;
diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c
index d6dc2f9e0a..ca4b2b8bfd 100644
--- a/libavcodec/hevc_refs.c
+++ b/libavcodec/hevc_refs.c
@@ -144,7 +144,7 @@ int ff_hevc_set_new_ref(HEVCContext *s, AVFrame **frame, int poc)
         return AVERROR(ENOMEM);
 
     *frame = ref->frame;
-    s->ref = ref;
+    s->cur_frame = ref;
     s->collocated_ref = NULL;
 
     if (s->sh.pic_output_flag)
@@ -282,7 +282,7 @@ void ff_hevc_bump_frame(HEVCContext *s)
 
 static int init_slice_rpl(HEVCContext *s)
 {
-    HEVCFrame *frame = s->ref;
+    HEVCFrame *frame = s->cur_frame;
     int ctb_count    = frame->ctb_count;
     int ctb_addr_ts  = s->ps.pps->ctb_addr_rs_to_ts[s->sh.slice_segment_addr];
     int i;
@@ -318,7 +318,7 @@ int ff_hevc_slice_rpl(HEVCContext *s)
 
     for (list_idx = 0; list_idx < nb_list; list_idx++) {
         RefPicList  rpl_tmp = { { 0 } };
-        RefPicList *rpl     = &s->ref->refPicList[list_idx];
+        RefPicList *rpl     = &s->cur_frame->refPicList[list_idx];
 
         /* The order of the elements is
          * ST_CURR_BEF - ST_CURR_AFT - LT_CURR for the L0 and
@@ -340,8 +340,8 @@ int ff_hevc_slice_rpl(HEVCContext *s)
             }
             // Construct RefPicList0, RefPicList1 (8-8, 8-10)
             if (s->ps.pps->pps_curr_pic_ref_enabled_flag && rpl_tmp.nb_refs < HEVC_MAX_REFS) {
-                rpl_tmp.list[rpl_tmp.nb_refs]           = s->ref->poc;
-                rpl_tmp.ref[rpl_tmp.nb_refs]            = s->ref;
+                rpl_tmp.list[rpl_tmp.nb_refs]           = s->cur_frame->poc;
+                rpl_tmp.ref[rpl_tmp.nb_refs]            = s->cur_frame;
                 rpl_tmp.isLongTerm[rpl_tmp.nb_refs]     = 1;
                 rpl_tmp.nb_refs++;
             }
@@ -371,8 +371,8 @@ int ff_hevc_slice_rpl(HEVCContext *s)
         if (s->ps.pps->pps_curr_pic_ref_enabled_flag &&
             !sh->rpl_modification_flag[list_idx] &&
             rpl_tmp.nb_refs > sh->nb_refs[L0]) {
-            rpl->list[sh->nb_refs[L0] - 1] = s->ref->poc;
-            rpl->ref[sh->nb_refs[L0] - 1]  = s->ref;
+            rpl->list[sh->nb_refs[L0] - 1] = s->cur_frame->poc;
+            rpl->ref[sh->nb_refs[L0] - 1]  = s->cur_frame;
         }
 
         if (sh->collocated_list == list_idx &&
@@ -448,7 +448,7 @@ static int add_candidate_ref(HEVCContext *s, RefPicList *list,
 {
     HEVCFrame *ref = find_ref_idx(s, poc, use_msb);
 
-    if (ref == s->ref || list->nb_refs >= HEVC_MAX_REFS)
+    if (ref == s->cur_frame || list->nb_refs >= HEVC_MAX_REFS)
         return AVERROR_INVALIDDATA;
 
     if (!ref) {
@@ -483,7 +483,7 @@ int ff_hevc_frame_rps(HEVCContext *s)
     for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) {
         HEVCFrame *frame = &s->DPB[i];
 
-        if (frame == s->ref)
+        if (frame == s->cur_frame)
             continue;
 
         mark_ref(frame, 0);
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 75d0ed613a..39c23b532d 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -600,7 +600,7 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb)
 
     // Coded parameters
     sh->first_slice_in_pic_flag = get_bits1(gb);
-    if (s->ref && sh->first_slice_in_pic_flag) {
+    if (s->cur_frame && sh->first_slice_in_pic_flag) {
         av_log(s->avctx, AV_LOG_ERROR, "Two slices reporting being the first in the same frame.\n");
         return 1; // This slice will be skipped later, do not corrupt state
     }
@@ -1935,8 +1935,8 @@ static void hls_prediction_unit(HEVCLocalContext *lc, int x0, int y0,
 
     int min_pu_width = s->ps.sps->min_pu_width;
 
-    MvField *tab_mvf = s->ref->tab_mvf;
-    const RefPicList *refPicList = s->ref->refPicList;
+    MvField *tab_mvf = s->cur_frame->tab_mvf;
+    const RefPicList *refPicList = s->cur_frame->refPicList;
     const HEVCFrame *ref0 = NULL, *ref1 = NULL;
     uint8_t *dst0 = POS(0, x0, y0);
     uint8_t *dst1 = POS(1, x0, y0);
@@ -2066,7 +2066,7 @@ static int luma_intra_pred_mode(HEVCLocalContext *lc, int x0, int y0, int pu_siz
 
     int y_ctb = (y0 >> (s->ps.sps->log2_ctb_size)) << (s->ps.sps->log2_ctb_size);
 
-    MvField *tab_mvf = s->ref->tab_mvf;
+    MvField *tab_mvf = s->cur_frame->tab_mvf;
     int intra_pred_mode;
     int candidate[3];
     int i, j;
@@ -2221,7 +2221,7 @@ static void intra_prediction_unit_default_value(HEVCLocalContext *lc,
     int pb_size          = 1 << log2_cb_size;
     int size_in_pus      = pb_size >> s->ps.sps->log2_min_pu_size;
     int min_pu_width     = s->ps.sps->min_pu_width;
-    MvField *tab_mvf     = s->ref->tab_mvf;
+    MvField *tab_mvf     = s->cur_frame->tab_mvf;
     int x_pu             = x0 >> s->ps.sps->log2_min_pu_size;
     int y_pu             = y0 >> s->ps.sps->log2_min_pu_size;
     int j, k;
@@ -2780,7 +2780,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal)
 
 static int set_side_data(HEVCContext *s)
 {
-    AVFrame *out = s->ref->frame;
+    AVFrame *out = s->cur_frame->frame;
     int ret;
 
     // Decrement the mastering display and content light level flag when IRAP
@@ -2797,7 +2797,7 @@ static int set_side_data(HEVCContext *s)
     ret = ff_h2645_sei_to_frame(out, &s->sei.common, AV_CODEC_ID_HEVC, s->avctx,
                                 &s->ps.sps->vui.common,
                                 s->ps.sps->bit_depth, s->ps.sps->bit_depth_chroma,
-                                s->ref->poc /* no poc_offset in HEVC */);
+                                s->cur_frame->poc /* no poc_offset in HEVC */);
     if (ret < 0)
         return ret;
 
@@ -2896,12 +2896,12 @@ static int hevc_frame_start(HEVCContext *s)
     }
 
     if (IS_IRAP(s))
-        s->ref->frame->flags |= AV_FRAME_FLAG_KEY;
+        s->cur_frame->frame->flags |= AV_FRAME_FLAG_KEY;
     else
-        s->ref->frame->flags &= ~AV_FRAME_FLAG_KEY;
+        s->cur_frame->frame->flags &= ~AV_FRAME_FLAG_KEY;
 
-    s->ref->needs_fg = (s->sei.common.film_grain_characteristics.present ||
-                        s->sei.common.aom_film_grain.enable) &&
+    s->cur_frame->needs_fg = (s->sei.common.film_grain_characteristics.present ||
+                              s->sei.common.aom_film_grain.enable) &&
         !(s->avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN) &&
         !s->avctx->hwaccel;
 
@@ -2909,21 +2909,21 @@ static int hevc_frame_start(HEVCContext *s)
     if (ret < 0)
         goto fail;
 
-    if (s->ref->needs_fg &&
+    if (s->cur_frame->needs_fg &&
         (s->sei.common.film_grain_characteristics.present &&
          !ff_h274_film_grain_params_supported(s->sei.common.film_grain_characteristics.model_id,
-                                              s->ref->frame->format)
-         || !av_film_grain_params_select(s->ref->frame))) {
+                                              s->cur_frame->frame->format) ||
+         !av_film_grain_params_select(s->cur_frame->frame))) {
         av_log_once(s->avctx, AV_LOG_WARNING, AV_LOG_DEBUG, &s->film_grain_warning_shown,
                     "Unsupported film grain parameters. Ignoring film grain.\n");
-        s->ref->needs_fg = 0;
+        s->cur_frame->needs_fg = 0;
     }
 
-    if (s->ref->needs_fg) {
-        s->ref->frame_grain->format = s->ref->frame->format;
-        s->ref->frame_grain->width = s->ref->frame->width;
-        s->ref->frame_grain->height = s->ref->frame->height;
-        if ((ret = ff_thread_get_buffer(s->avctx, s->ref->frame_grain, 0)) < 0)
+    if (s->cur_frame->needs_fg) {
+        s->cur_frame->frame_grain->format = s->cur_frame->frame->format;
+        s->cur_frame->frame_grain->width  = s->cur_frame->frame->width;
+        s->cur_frame->frame_grain->height = s->cur_frame->frame->height;
+        if ((ret = ff_thread_get_buffer(s->avctx, s->cur_frame->frame_grain, 0)) < 0)
             goto fail;
     }
 
@@ -2943,15 +2943,15 @@ static int hevc_frame_start(HEVCContext *s)
     return 0;
 
 fail:
-    if (s->ref)
-        ff_hevc_unref_frame(s->ref, ~0);
-    s->ref = s->collocated_ref = NULL;
+    if (s->cur_frame)
+        ff_hevc_unref_frame(s->cur_frame, ~0);
+    s->cur_frame = s->collocated_ref = NULL;
     return ret;
 }
 
 static int hevc_frame_end(HEVCContext *s)
 {
-    HEVCFrame *out = s->ref;
+    HEVCFrame *out = s->cur_frame;
     const AVFilmGrainParams *fgp;
     av_unused int ret;
 
@@ -3086,7 +3086,7 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal)
             ret = hevc_frame_start(s);
             if (ret < 0)
                 return ret;
-        } else if (!s->ref) {
+        } else if (!s->cur_frame) {
             av_log(s->avctx, AV_LOG_ERROR, "First slice in a frame missing.\n");
             goto fail;
         }
@@ -3169,7 +3169,7 @@ static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length)
     int i, ret = 0;
     int eos_at_start = 1;
 
-    s->ref = s->collocated_ref = NULL;
+    s->cur_frame = s->collocated_ref = NULL;
     s->last_eos = s->eos;
     s->eos = 0;
     s->overlap = 0;
@@ -3248,8 +3248,8 @@ static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length)
     }
 
 fail:
-    if (s->ref && s->threads_type == FF_THREAD_FRAME)
-        ff_progress_frame_report(&s->ref->tf, INT_MAX);
+    if (s->cur_frame && s->threads_type == FF_THREAD_FRAME)
+        ff_progress_frame_report(&s->cur_frame->tf, INT_MAX);
 
     return ret;
 }
@@ -3384,25 +3384,25 @@ static int hevc_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
                    old, s->dovi_ctx.cfg.dv_profile);
     }
 
-    s->ref = s->collocated_ref = NULL;
+    s->cur_frame = s->collocated_ref = NULL;
     ret    = decode_nal_units(s, avpkt->data, avpkt->size);
     if (ret < 0)
         return ret;
 
     if (avctx->hwaccel) {
-        if (s->ref && (ret = FF_HW_SIMPLE_CALL(avctx, end_frame)) < 0) {
+        if (s->cur_frame && (ret = FF_HW_SIMPLE_CALL(avctx, end_frame)) < 0) {
             av_log(avctx, AV_LOG_ERROR,
                    "hardware accelerator failed to decode picture\n");
-            ff_hevc_unref_frame(s->ref, ~0);
+            ff_hevc_unref_frame(s->cur_frame, ~0);
             return ret;
         }
     } else {
         /* verify the SEI checksum */
-        if (avctx->err_recognition & AV_EF_CRCCHECK && s->ref && s->is_decoded &&
+        if (avctx->err_recognition & AV_EF_CRCCHECK && s->cur_frame && s->is_decoded &&
             s->sei.picture_hash.is_md5) {
-            ret = verify_md5(s, s->ref->frame);
+            ret = verify_md5(s, s->cur_frame->frame);
             if (ret < 0 && avctx->err_recognition & AV_EF_EXPLODE) {
-                ff_hevc_unref_frame(s->ref, ~0);
+                ff_hevc_unref_frame(s->cur_frame, ~0);
                 return ret;
             }
         }
diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h
index 6957cd1091..0e44a72174 100644
--- a/libavcodec/hevcdec.h
+++ b/libavcodec/hevcdec.h
@@ -481,7 +481,7 @@ typedef struct HEVCContext {
     DBParams *deblock;
     enum HEVCNALUnitType nal_unit_type;
     int temporal_id;  ///< temporal_id_plus1 - 1
-    HEVCFrame *ref;
+    HEVCFrame *cur_frame;
     HEVCFrame *collocated_ref;
     HEVCFrame DPB[32];
     int poc;
diff --git a/libavcodec/hevcpred_template.c b/libavcodec/hevcpred_template.c
index 9082a816e0..4e96ac3423 100644
--- a/libavcodec/hevcpred_template.c
+++ b/libavcodec/hevcpred_template.c
@@ -33,7 +33,7 @@ static av_always_inline void FUNC(intra_pred)(HEVCLocalContext *lc, int x0, int
 #define PU(x) \
     ((x) >> s->ps.sps->log2_min_pu_size)
 #define MVF(x, y) \
-    (s->ref->tab_mvf[(x) + (y) * min_pu_width])
+    (s->cur_frame->tab_mvf[(x) + (y) * min_pu_width])
 #define MVF_PU(x, y) \
     MVF(PU(x0 + ((x) * (1 << hshift))), PU(y0 + ((y) * (1 << vshift))))
 #define IS_INTRA(x, y) \
diff --git a/libavcodec/nvdec_hevc.c b/libavcodec/nvdec_hevc.c
index 3d704666d0..57d5ea17b1 100644
--- a/libavcodec/nvdec_hevc.c
+++ b/libavcodec/nvdec_hevc.c
@@ -84,11 +84,11 @@ static int nvdec_hevc_start_frame(AVCodecContext *avctx,
 
     int i, j, dpb_size, ret;
 
-    ret = ff_nvdec_start_frame(avctx, s->ref->frame);
+    ret = ff_nvdec_start_frame(avctx, s->cur_frame->frame);
     if (ret < 0)
         return ret;
 
-    fdd = (FrameDecodeData*)s->ref->frame->private_ref->data;
+    fdd = (FrameDecodeData*)s->cur_frame->frame->private_ref->data;
     cf  = (NVDECFrame*)fdd->hwaccel_priv;
 
     *pp = (CUVIDPICPARAMS) {
@@ -191,7 +191,7 @@ static int nvdec_hevc_start_frame(AVCodecContext *avctx,
             .NumPocStCurrBefore                           = s->rps[ST_CURR_BEF].nb_refs,
             .NumPocStCurrAfter                            = s->rps[ST_CURR_AFT].nb_refs,
             .NumPocLtCurr                                 = s->rps[LT_CURR].nb_refs,
-            .CurrPicOrderCntVal                           = s->ref->poc,
+            .CurrPicOrderCntVal                           = s->cur_frame->poc,
         },
     };
 
diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
index f0a0f295d9..8ff226b980 100644
--- a/libavcodec/vaapi_hevc.c
+++ b/libavcodec/vaapi_hevc.c
@@ -71,7 +71,7 @@ static void fill_vaapi_pic(VAPictureHEVC *va_pic, const HEVCFrame *pic, int rps_
 static int find_frame_rps_type(const HEVCContext *h, const HEVCFrame *pic)
 {
     VASurfaceID pic_surf = ff_vaapi_get_surface_id(pic->frame);
-    const HEVCFrame *current_picture = h->ref;
+    const HEVCFrame *current_picture = h->cur_frame;
     int i;
 
     for (i = 0; i < h->rps[ST_CURR_BEF].nb_refs; i++) {
@@ -97,7 +97,7 @@ static int find_frame_rps_type(const HEVCContext *h, const HEVCFrame *pic)
 
 static void fill_vaapi_reference_frames(const HEVCContext *h, VAPictureParameterBufferHEVC *pp)
 {
-    const HEVCFrame *current_picture = h->ref;
+    const HEVCFrame *current_picture = h->cur_frame;
     int i, j, rps_type;
 
     for (i = 0, j = 0; i < FF_ARRAY_ELEMS(pp->ReferenceFrames); i++) {
@@ -124,7 +124,7 @@ static int vaapi_hevc_start_frame(AVCodecContext          *avctx,
                                   av_unused uint32_t       size)
 {
     const HEVCContext        *h = avctx->priv_data;
-    VAAPIDecodePictureHEVC *pic = h->ref->hwaccel_picture_private;
+    VAAPIDecodePictureHEVC *pic = h->cur_frame->hwaccel_picture_private;
     const HEVCSPS          *sps = h->ps.sps;
     const HEVCPPS          *pps = h->ps.pps;
 
@@ -137,7 +137,7 @@ static int vaapi_hevc_start_frame(AVCodecContext          *avctx,
 
     VAPictureParameterBufferHEVC *pic_param = (VAPictureParameterBufferHEVC *)&pic->pic_param;
 
-    pic->pic.output_surface = ff_vaapi_get_surface_id(h->ref->frame);
+    pic->pic.output_surface = ff_vaapi_get_surface_id(h->cur_frame->frame);
 
     *pic_param = (VAPictureParameterBufferHEVC) {
         .pic_width_in_luma_samples                    = sps->width,
@@ -206,7 +206,7 @@ static int vaapi_hevc_start_frame(AVCodecContext          *avctx,
         },
     };
 
-    fill_vaapi_pic(&pic_param->CurrPic, h->ref, 0);
+    fill_vaapi_pic(&pic_param->CurrPic, h->cur_frame, 0);
     fill_vaapi_reference_frames(h, pic_param);
 
     if (pps->tiles_enabled_flag) {
@@ -343,7 +343,7 @@ fail:
 static int vaapi_hevc_end_frame(AVCodecContext *avctx)
 {
     const HEVCContext        *h = avctx->priv_data;
-    VAAPIDecodePictureHEVC *pic = h->ref->hwaccel_picture_private;
+    VAAPIDecodePictureHEVC *pic = h->cur_frame->hwaccel_picture_private;
     VASliceParameterBufferHEVC *last_slice_param = (VASliceParameterBufferHEVC *)&pic->last_slice_param;
     int ret;
 
@@ -435,7 +435,7 @@ static void fill_pred_weight_table(AVCodecContext *avctx,
 
 static uint8_t get_ref_pic_index(const HEVCContext *h, const HEVCFrame *frame)
 {
-    VAAPIDecodePictureHEVC *pic = h->ref->hwaccel_picture_private;
+    VAAPIDecodePictureHEVC *pic = h->cur_frame->hwaccel_picture_private;
     VAPictureParameterBufferHEVC *pp = (VAPictureParameterBufferHEVC *)&pic->pic_param;
     uint8_t i;
 
@@ -458,7 +458,7 @@ static int vaapi_hevc_decode_slice(AVCodecContext *avctx,
 {
     const HEVCContext        *h = avctx->priv_data;
     const SliceHeader       *sh = &h->sh;
-    VAAPIDecodePictureHEVC *pic = h->ref->hwaccel_picture_private;
+    VAAPIDecodePictureHEVC *pic = h->cur_frame->hwaccel_picture_private;
     VASliceParameterBufferHEVC *last_slice_param = (VASliceParameterBufferHEVC *)&pic->last_slice_param;
 
     int slice_param_size = avctx->profile >= AV_PROFILE_HEVC_REXT ?
@@ -515,7 +515,7 @@ static int vaapi_hevc_decode_slice(AVCodecContext *avctx,
     memset(last_slice_param->RefPicList, 0xFF, sizeof(last_slice_param->RefPicList));
 
     for (list_idx = 0; list_idx < nb_list; list_idx++) {
-        RefPicList *rpl = &h->ref->refPicList[list_idx];
+        RefPicList *rpl = &h->cur_frame->refPicList[list_idx];
 
         for (i = 0; i < rpl->nb_refs; i++)
             last_slice_param->RefPicList[list_idx][i] = get_ref_pic_index(h, rpl->ref[i]);
diff --git a/libavcodec/vdpau_hevc.c b/libavcodec/vdpau_hevc.c
index b029f9c42e..acee077cfa 100644
--- a/libavcodec/vdpau_hevc.c
+++ b/libavcodec/vdpau_hevc.c
@@ -35,7 +35,7 @@ static int vdpau_hevc_start_frame(AVCodecContext *avctx,
                                   const uint8_t *buffer, uint32_t size)
 {
     HEVCContext *h = avctx->priv_data;
-    HEVCFrame *pic = h->ref;
+    HEVCFrame *pic = h->cur_frame;
     struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
 
     VdpPictureInfoHEVC *info = &pic_ctx->info.hevc;
@@ -238,7 +238,7 @@ static int vdpau_hevc_start_frame(AVCodecContext *avctx,
     }
     for (size_t i = 0, j = 0; i < FF_ARRAY_ELEMS(h->DPB); i++) {
         const HEVCFrame *frame = &h->DPB[i];
-        if (frame != h->ref && (frame->flags & (HEVC_FRAME_FLAG_LONG_REF |
+        if (frame != h->cur_frame && (frame->flags & (HEVC_FRAME_FLAG_LONG_REF |
                                                 HEVC_FRAME_FLAG_SHORT_REF))) {
             if (j > 15) {
                 av_log(avctx, AV_LOG_WARNING,
@@ -403,7 +403,7 @@ static int vdpau_hevc_decode_slice(AVCodecContext *avctx,
                                    const uint8_t *buffer, uint32_t size)
 {
     HEVCContext *h = avctx->priv_data;
-    struct vdpau_picture_context *pic_ctx = h->ref->hwaccel_picture_private;
+    struct vdpau_picture_context *pic_ctx = h->cur_frame->hwaccel_picture_private;
     int val;
 
     val = ff_vdpau_add_buffer(pic_ctx, start_code_prefix, 3);
@@ -420,10 +420,10 @@ static int vdpau_hevc_decode_slice(AVCodecContext *avctx,
 static int vdpau_hevc_end_frame(AVCodecContext *avctx)
 {
     HEVCContext *h = avctx->priv_data;
-    struct vdpau_picture_context *pic_ctx = h->ref->hwaccel_picture_private;
+    struct vdpau_picture_context *pic_ctx = h->cur_frame->hwaccel_picture_private;
     int val;
 
-    val = ff_vdpau_common_end_frame(avctx, h->ref->frame, pic_ctx);
+    val = ff_vdpau_common_end_frame(avctx, h->cur_frame->frame, pic_ctx);
     if (val < 0)
         return val;
 
diff --git a/libavcodec/vulkan_hevc.c b/libavcodec/vulkan_hevc.c
index 5583f56285..1a12f14652 100644
--- a/libavcodec/vulkan_hevc.c
+++ b/libavcodec/vulkan_hevc.c
@@ -731,7 +731,7 @@ static int vk_hevc_start_frame(AVCodecContext          *avctx,
 {
     int err;
     HEVCContext *h = avctx->priv_data;
-    HEVCFrame *pic = h->ref;
+    HEVCFrame *pic = h->cur_frame;
     FFVulkanDecodeContext *dec = avctx->internal->hwaccel_priv_data;
     HEVCVulkanDecodePicture *hp = pic->hwaccel_picture_private;
     FFVulkanDecodePicture *vp = &hp->vp;
@@ -851,7 +851,7 @@ static int vk_hevc_decode_slice(AVCodecContext *avctx,
                                 uint32_t        size)
 {
     const HEVCContext *h = avctx->priv_data;
-    HEVCVulkanDecodePicture *hp = h->ref->hwaccel_picture_private;
+    HEVCVulkanDecodePicture *hp = h->cur_frame->hwaccel_picture_private;
     FFVulkanDecodePicture *vp = &hp->vp;
 
     int err = ff_vk_decode_add_slice(avctx, vp, data, size, 1,
@@ -867,7 +867,7 @@ static int vk_hevc_end_frame(AVCodecContext *avctx)
 {
     const HEVCContext *h = avctx->priv_data;
     FFVulkanDecodeContext *dec = avctx->internal->hwaccel_priv_data;
-    HEVCFrame *pic = h->ref;
+    HEVCFrame *pic = h->cur_frame;
     HEVCVulkanDecodePicture *hp = pic->hwaccel_picture_private;
     FFVulkanDecodePicture *vp = &hp->vp;
     FFVulkanDecodePicture *rvp[HEVC_MAX_REFS] = { 0 };
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [FFmpeg-devel] [PATCH 07/11] lavc/hevcdec: rename HEVCFrame.frame to just f
  2024-05-31 17:47 [FFmpeg-devel] [PATCH 01/11] lavc/hevcdec: move handling of byte alignment at the end of slice header Anton Khirnov
                   ` (4 preceding siblings ...)
  2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 06/11] lavc/hevcdec: rename HEVCContext.ref to cur_frame Anton Khirnov
@ 2024-05-31 17:47 ` Anton Khirnov
  2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 08/11] lavc/hevcdec: drop HEVCContext.frame Anton Khirnov
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Anton Khirnov @ 2024-05-31 17:47 UTC (permalink / raw)
  To: ffmpeg-devel

This is shorter, loses no information, and is consistent with other
similar structs.
---
 libavcodec/dxva2_hevc.c  |  8 +++----
 libavcodec/hevc_refs.c   | 34 +++++++++++++--------------
 libavcodec/hevcdec.c     | 50 ++++++++++++++++++++--------------------
 libavcodec/hevcdec.h     |  2 +-
 libavcodec/nvdec_hevc.c  |  6 ++---
 libavcodec/vaapi_hevc.c  | 18 +++++++--------
 libavcodec/vdpau_hevc.c  | 10 ++++----
 libavcodec/vulkan_hevc.c | 10 ++++----
 8 files changed, 69 insertions(+), 69 deletions(-)

diff --git a/libavcodec/dxva2_hevc.c b/libavcodec/dxva2_hevc.c
index 2d6c2f812f..08b3b1e785 100644
--- a/libavcodec/dxva2_hevc.c
+++ b/libavcodec/dxva2_hevc.c
@@ -170,7 +170,7 @@ void ff_dxva2_hevc_fill_picture_parameters(const AVCodecContext *avctx, AVDXVACo
         }
 
         if (frame) {
-            fill_picture_entry(&pp->RefPicList[i], ff_dxva2_get_surface_index(avctx, ctx, frame->frame, 0), !!(frame->flags & HEVC_FRAME_FLAG_LONG_REF));
+            fill_picture_entry(&pp->RefPicList[i], ff_dxva2_get_surface_index(avctx, ctx, frame->f, 0), !!(frame->flags & HEVC_FRAME_FLAG_LONG_REF));
             pp->PicOrderCntValList[i] = frame->poc;
         } else {
             pp->RefPicList[i].bPicEntry = 0xff;
@@ -178,7 +178,7 @@ void ff_dxva2_hevc_fill_picture_parameters(const AVCodecContext *avctx, AVDXVACo
         }
     }
 
-    fill_picture_entry(&pp->CurrPic, ff_dxva2_get_surface_index(avctx, ctx, current_picture->frame, 1), 0);
+    fill_picture_entry(&pp->CurrPic, ff_dxva2_get_surface_index(avctx, ctx, current_picture->f, 1), 0);
 
     #define DO_REF_LIST(ref_idx, ref_list) { \
         const RefPicList *rpl = &h->rps[ref_idx]; \
@@ -187,7 +187,7 @@ void ff_dxva2_hevc_fill_picture_parameters(const AVCodecContext *avctx, AVDXVACo
             while (!frame && j < rpl->nb_refs) \
                 frame = rpl->ref[j++]; \
             if (frame && frame->flags & (HEVC_FRAME_FLAG_LONG_REF | HEVC_FRAME_FLAG_SHORT_REF)) \
-                pp->ref_list[i] = get_refpic_index(pp, ff_dxva2_get_surface_index(avctx, ctx, frame->frame, 0)); \
+                pp->ref_list[i] = get_refpic_index(pp, ff_dxva2_get_surface_index(avctx, ctx, frame->f, 0)); \
             else \
                 pp->ref_list[i] = 0xff; \
         } \
@@ -415,7 +415,7 @@ static int dxva2_hevc_end_frame(AVCodecContext *avctx)
     if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0)
         return -1;
 
-    ret = ff_dxva2_common_end_frame(avctx, h->cur_frame->frame,
+    ret = ff_dxva2_common_end_frame(avctx, h->cur_frame->f,
                                     &ctx_pic->pp, sizeof(ctx_pic->pp),
                                     scale ? &ctx_pic->qm : NULL, scale ? sizeof(ctx_pic->qm) : 0,
                                     commit_bitstream_and_slice_buffer);
diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c
index ca4b2b8bfd..6019818cf0 100644
--- a/libavcodec/hevc_refs.c
+++ b/libavcodec/hevc_refs.c
@@ -79,7 +79,7 @@ static HEVCFrame *alloc_frame(HEVCContext *s)
     int i, j, ret;
     for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) {
         HEVCFrame *frame = &s->DPB[i];
-        if (frame->frame)
+        if (frame->f)
             continue;
 
         ret = ff_progress_frame_get_buffer(s->avctx, &frame->tf,
@@ -104,10 +104,10 @@ static HEVCFrame *alloc_frame(HEVCContext *s)
             frame->rpl_tab[j] = frame->rpl;
 
         if (s->sei.picture_timing.picture_struct == AV_PICTURE_STRUCTURE_TOP_FIELD)
-            frame->frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
+            frame->f->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
         if ((s->sei.picture_timing.picture_struct == AV_PICTURE_STRUCTURE_TOP_FIELD) ||
             (s->sei.picture_timing.picture_struct == AV_PICTURE_STRUCTURE_BOTTOM_FIELD))
-            frame->frame->flags |= AV_FRAME_FLAG_INTERLACED;
+            frame->f->flags |= AV_FRAME_FLAG_INTERLACED;
 
         ret = ff_hwaccel_frame_priv_alloc(s->avctx, &frame->hwaccel_picture_private);
         if (ret < 0)
@@ -131,7 +131,7 @@ int ff_hevc_set_new_ref(HEVCContext *s, AVFrame **frame, int poc)
     for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) {
         HEVCFrame *frame = &s->DPB[i];
 
-        if (frame->frame && frame->sequence == s->seq_decode &&
+        if (frame->f && frame->sequence == s->seq_decode &&
             frame->poc == poc) {
             av_log(s->avctx, AV_LOG_ERROR, "Duplicate POC in a sequence: %d.\n",
                    poc);
@@ -143,7 +143,7 @@ int ff_hevc_set_new_ref(HEVCContext *s, AVFrame **frame, int poc)
     if (!ref)
         return AVERROR(ENOMEM);
 
-    *frame = ref->frame;
+    *frame = ref->f;
     s->cur_frame = ref;
     s->collocated_ref = NULL;
 
@@ -154,10 +154,10 @@ int ff_hevc_set_new_ref(HEVCContext *s, AVFrame **frame, int poc)
 
     ref->poc      = poc;
     ref->sequence = s->seq_decode;
-    ref->frame->crop_left   = s->ps.sps->output_window.left_offset;
-    ref->frame->crop_right  = s->ps.sps->output_window.right_offset;
-    ref->frame->crop_top    = s->ps.sps->output_window.top_offset;
-    ref->frame->crop_bottom = s->ps.sps->output_window.bottom_offset;
+    ref->f->crop_left   = s->ps.sps->output_window.left_offset;
+    ref->f->crop_right  = s->ps.sps->output_window.right_offset;
+    ref->f->crop_top    = s->ps.sps->output_window.top_offset;
+    ref->f->crop_bottom = s->ps.sps->output_window.bottom_offset;
 
     return 0;
 }
@@ -212,7 +212,7 @@ int ff_hevc_output_frame(HEVCContext *s, AVFrame *out, int flush)
         if (nb_output) {
             HEVCFrame *frame = &s->DPB[min_idx];
 
-            ret = av_frame_ref(out, frame->needs_fg ? frame->frame_grain : frame->frame);
+            ret = av_frame_ref(out, frame->needs_fg ? frame->frame_grain : frame->f);
             if (frame->flags & HEVC_FRAME_FLAG_BUMPING)
                 ff_hevc_unref_frame(frame, HEVC_FRAME_FLAG_OUTPUT | HEVC_FRAME_FLAG_BUMPING);
             else
@@ -220,7 +220,7 @@ int ff_hevc_output_frame(HEVCContext *s, AVFrame *out, int flush)
             if (ret < 0)
                 return ret;
 
-            if (frame->needs_fg && (ret = av_frame_copy_props(out, frame->frame)) < 0)
+            if (frame->needs_fg && (ret = av_frame_copy_props(out, frame->f)) < 0)
                 return ret;
 
             if (!(s->avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN))
@@ -390,7 +390,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 && ref->sequence == s->seq_decode) {
+        if (ref->f && ref->sequence == s->seq_decode) {
             if ((ref->poc & mask) == poc && (use_msb || ref->poc != s->poc))
                 return ref;
         }
@@ -419,13 +419,13 @@ static HEVCFrame *generate_missing_ref(HEVCContext *s, int poc)
 
     if (!s->avctx->hwaccel) {
         if (!s->ps.sps->pixel_shift) {
-            for (i = 0; frame->frame->data[i]; i++)
-                memset(frame->frame->data[i], 1 << (s->ps.sps->bit_depth - 1),
-                       frame->frame->linesize[i] * AV_CEIL_RSHIFT(s->ps.sps->height, s->ps.sps->vshift[i]));
+            for (i = 0; frame->f->data[i]; i++)
+                memset(frame->f->data[i], 1 << (s->ps.sps->bit_depth - 1),
+                       frame->f->linesize[i] * AV_CEIL_RSHIFT(s->ps.sps->height, s->ps.sps->vshift[i]));
         } else {
-            for (i = 0; frame->frame->data[i]; i++)
+            for (i = 0; frame->f->data[i]; i++)
                 for (y = 0; y < (s->ps.sps->height >> s->ps.sps->vshift[i]); y++) {
-                    uint8_t *dst = frame->frame->data[i] + y * frame->frame->linesize[i];
+                    uint8_t *dst = frame->f->data[i] + y * frame->f->linesize[i];
                     AV_WN16(dst, 1 << (s->ps.sps->bit_depth - 1));
                     av_memcpy_backptr(dst + 2, 2, 2*(s->ps.sps->width >> s->ps.sps->hshift[i]) - 2);
                 }
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 39c23b532d..6283abbbe8 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -1975,13 +1975,13 @@ static void hls_prediction_unit(HEVCLocalContext *lc, int x0, int y0,
 
     if (current_mv.pred_flag & PF_L0) {
         ref0 = refPicList[0].ref[current_mv.ref_idx[0]];
-        if (!ref0 || !ref0->frame)
+        if (!ref0 || !ref0->f)
             return;
         hevc_await_progress(s, ref0, &current_mv.mv[0], y0, nPbH);
     }
     if (current_mv.pred_flag & PF_L1) {
         ref1 = refPicList[1].ref[current_mv.ref_idx[1]];
-        if (!ref1 || !ref1->frame)
+        if (!ref1 || !ref1->f)
             return;
         hevc_await_progress(s, ref1, &current_mv.mv[1], y0, nPbH);
     }
@@ -1992,16 +1992,16 @@ static void hls_prediction_unit(HEVCLocalContext *lc, int x0, int y0,
         int nPbW_c = nPbW >> s->ps.sps->hshift[1];
         int nPbH_c = nPbH >> s->ps.sps->vshift[1];
 
-        luma_mc_uni(lc, dst0, s->frame->linesize[0], ref0->frame,
+        luma_mc_uni(lc, dst0, s->frame->linesize[0], ref0->f,
                     &current_mv.mv[0], x0, y0, nPbW, nPbH,
                     s->sh.luma_weight_l0[current_mv.ref_idx[0]],
                     s->sh.luma_offset_l0[current_mv.ref_idx[0]]);
 
         if (s->ps.sps->chroma_format_idc) {
-            chroma_mc_uni(lc, dst1, s->frame->linesize[1], ref0->frame->data[1], ref0->frame->linesize[1],
+            chroma_mc_uni(lc, dst1, s->frame->linesize[1], ref0->f->data[1], ref0->f->linesize[1],
                           0, x0_c, y0_c, nPbW_c, nPbH_c, &current_mv,
                           s->sh.chroma_weight_l0[current_mv.ref_idx[0]][0], s->sh.chroma_offset_l0[current_mv.ref_idx[0]][0]);
-            chroma_mc_uni(lc, dst2, s->frame->linesize[2], ref0->frame->data[2], ref0->frame->linesize[2],
+            chroma_mc_uni(lc, dst2, s->frame->linesize[2], ref0->f->data[2], ref0->f->linesize[2],
                           0, x0_c, y0_c, nPbW_c, nPbH_c, &current_mv,
                           s->sh.chroma_weight_l0[current_mv.ref_idx[0]][1], s->sh.chroma_offset_l0[current_mv.ref_idx[0]][1]);
         }
@@ -2011,17 +2011,17 @@ static void hls_prediction_unit(HEVCLocalContext *lc, int x0, int y0,
         int nPbW_c = nPbW >> s->ps.sps->hshift[1];
         int nPbH_c = nPbH >> s->ps.sps->vshift[1];
 
-        luma_mc_uni(lc, dst0, s->frame->linesize[0], ref1->frame,
+        luma_mc_uni(lc, dst0, s->frame->linesize[0], ref1->f,
                     &current_mv.mv[1], x0, y0, nPbW, nPbH,
                     s->sh.luma_weight_l1[current_mv.ref_idx[1]],
                     s->sh.luma_offset_l1[current_mv.ref_idx[1]]);
 
         if (s->ps.sps->chroma_format_idc) {
-            chroma_mc_uni(lc, dst1, s->frame->linesize[1], ref1->frame->data[1], ref1->frame->linesize[1],
+            chroma_mc_uni(lc, dst1, s->frame->linesize[1], ref1->f->data[1], ref1->f->linesize[1],
                           1, x0_c, y0_c, nPbW_c, nPbH_c, &current_mv,
                           s->sh.chroma_weight_l1[current_mv.ref_idx[1]][0], s->sh.chroma_offset_l1[current_mv.ref_idx[1]][0]);
 
-            chroma_mc_uni(lc, dst2, s->frame->linesize[2], ref1->frame->data[2], ref1->frame->linesize[2],
+            chroma_mc_uni(lc, dst2, s->frame->linesize[2], ref1->f->data[2], ref1->f->linesize[2],
                           1, x0_c, y0_c, nPbW_c, nPbH_c, &current_mv,
                           s->sh.chroma_weight_l1[current_mv.ref_idx[1]][1], s->sh.chroma_offset_l1[current_mv.ref_idx[1]][1]);
         }
@@ -2031,15 +2031,15 @@ static void hls_prediction_unit(HEVCLocalContext *lc, int x0, int y0,
         int nPbW_c = nPbW >> s->ps.sps->hshift[1];
         int nPbH_c = nPbH >> s->ps.sps->vshift[1];
 
-        luma_mc_bi(lc, dst0, s->frame->linesize[0], ref0->frame,
+        luma_mc_bi(lc, dst0, s->frame->linesize[0], ref0->f,
                    &current_mv.mv[0], x0, y0, nPbW, nPbH,
-                   ref1->frame, &current_mv.mv[1], &current_mv);
+                   ref1->f, &current_mv.mv[1], &current_mv);
 
         if (s->ps.sps->chroma_format_idc) {
-            chroma_mc_bi(lc, dst1, s->frame->linesize[1], ref0->frame, ref1->frame,
+            chroma_mc_bi(lc, dst1, s->frame->linesize[1], ref0->f, ref1->f,
                          x0_c, y0_c, nPbW_c, nPbH_c, &current_mv, 0);
 
-            chroma_mc_bi(lc, dst2, s->frame->linesize[2], ref0->frame, ref1->frame,
+            chroma_mc_bi(lc, dst2, s->frame->linesize[2], ref0->f, ref1->f,
                          x0_c, y0_c, nPbW_c, nPbH_c, &current_mv, 1);
         }
     }
@@ -2780,7 +2780,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal)
 
 static int set_side_data(HEVCContext *s)
 {
-    AVFrame *out = s->cur_frame->frame;
+    AVFrame *out = s->cur_frame->f;
     int ret;
 
     // Decrement the mastering display and content light level flag when IRAP
@@ -2896,9 +2896,9 @@ static int hevc_frame_start(HEVCContext *s)
     }
 
     if (IS_IRAP(s))
-        s->cur_frame->frame->flags |= AV_FRAME_FLAG_KEY;
+        s->cur_frame->f->flags |= AV_FRAME_FLAG_KEY;
     else
-        s->cur_frame->frame->flags &= ~AV_FRAME_FLAG_KEY;
+        s->cur_frame->f->flags &= ~AV_FRAME_FLAG_KEY;
 
     s->cur_frame->needs_fg = (s->sei.common.film_grain_characteristics.present ||
                               s->sei.common.aom_film_grain.enable) &&
@@ -2912,17 +2912,17 @@ static int hevc_frame_start(HEVCContext *s)
     if (s->cur_frame->needs_fg &&
         (s->sei.common.film_grain_characteristics.present &&
          !ff_h274_film_grain_params_supported(s->sei.common.film_grain_characteristics.model_id,
-                                              s->cur_frame->frame->format) ||
-         !av_film_grain_params_select(s->cur_frame->frame))) {
+                                              s->cur_frame->f->format) ||
+         !av_film_grain_params_select(s->cur_frame->f))) {
         av_log_once(s->avctx, AV_LOG_WARNING, AV_LOG_DEBUG, &s->film_grain_warning_shown,
                     "Unsupported film grain parameters. Ignoring film grain.\n");
         s->cur_frame->needs_fg = 0;
     }
 
     if (s->cur_frame->needs_fg) {
-        s->cur_frame->frame_grain->format = s->cur_frame->frame->format;
-        s->cur_frame->frame_grain->width  = s->cur_frame->frame->width;
-        s->cur_frame->frame_grain->height = s->cur_frame->frame->height;
+        s->cur_frame->frame_grain->format = s->cur_frame->f->format;
+        s->cur_frame->frame_grain->width  = s->cur_frame->f->width;
+        s->cur_frame->frame_grain->height = s->cur_frame->f->height;
         if ((ret = ff_thread_get_buffer(s->avctx, s->cur_frame->frame_grain, 0)) < 0)
             goto fail;
     }
@@ -2957,17 +2957,17 @@ static int hevc_frame_end(HEVCContext *s)
 
     if (out->needs_fg) {
         av_assert0(out->frame_grain->buf[0]);
-        fgp = av_film_grain_params_select(out->frame);
+        fgp = av_film_grain_params_select(out->f);
         switch (fgp->type) {
         case AV_FILM_GRAIN_PARAMS_NONE:
             av_assert0(0);
             return AVERROR_BUG;
         case AV_FILM_GRAIN_PARAMS_H274:
-            ret = ff_h274_apply_film_grain(out->frame_grain, out->frame,
+            ret = ff_h274_apply_film_grain(out->frame_grain, out->f,
                                            &s->h274db, fgp);
             break;
         case AV_FILM_GRAIN_PARAMS_AV1:
-            ret = ff_aom_apply_film_grain(out->frame_grain, out->frame, fgp);
+            ret = ff_aom_apply_film_grain(out->frame_grain, out->f, fgp);
             break;
         }
         av_assert1(ret >= 0);
@@ -3400,7 +3400,7 @@ static int hevc_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
         /* verify the SEI checksum */
         if (avctx->err_recognition & AV_EF_CRCCHECK && s->cur_frame && s->is_decoded &&
             s->sei.picture_hash.is_md5) {
-            ret = verify_md5(s, s->cur_frame->frame);
+            ret = verify_md5(s, s->cur_frame->f);
             if (ret < 0 && avctx->err_recognition & AV_EF_EXPLODE) {
                 ff_hevc_unref_frame(s->cur_frame, ~0);
                 return ret;
@@ -3543,7 +3543,7 @@ static int hevc_update_thread_context(AVCodecContext *dst,
 
     for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) {
         ff_hevc_unref_frame(&s->DPB[i], ~0);
-        if (s0->DPB[i].frame) {
+        if (s0->DPB[i].f) {
             ret = hevc_ref_frame(&s->DPB[i], &s0->DPB[i]);
             if (ret < 0)
                 return ret;
diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h
index 0e44a72174..3eb8451734 100644
--- a/libavcodec/hevcdec.h
+++ b/libavcodec/hevcdec.h
@@ -355,7 +355,7 @@ typedef struct DBParams {
 typedef struct HEVCFrame {
     union {
         struct {
-            AVFrame *frame;
+            AVFrame *f;
         };
         ProgressFrame tf;
     };
diff --git a/libavcodec/nvdec_hevc.c b/libavcodec/nvdec_hevc.c
index 57d5ea17b1..381f8da97e 100644
--- a/libavcodec/nvdec_hevc.c
+++ b/libavcodec/nvdec_hevc.c
@@ -34,7 +34,7 @@
 
 static void dpb_add(CUVIDHEVCPICPARAMS *pp, int idx, const HEVCFrame *src)
 {
-    FrameDecodeData *fdd = (FrameDecodeData*)src->frame->private_ref->data;
+    FrameDecodeData *fdd = (FrameDecodeData*)src->f->private_ref->data;
     const NVDECFrame *cf = fdd->hwaccel_priv;
 
     pp->RefPicIdx[idx]      = cf ? cf->idx : -1;
@@ -84,11 +84,11 @@ static int nvdec_hevc_start_frame(AVCodecContext *avctx,
 
     int i, j, dpb_size, ret;
 
-    ret = ff_nvdec_start_frame(avctx, s->cur_frame->frame);
+    ret = ff_nvdec_start_frame(avctx, s->cur_frame->f);
     if (ret < 0)
         return ret;
 
-    fdd = (FrameDecodeData*)s->cur_frame->frame->private_ref->data;
+    fdd = (FrameDecodeData*)s->cur_frame->f->private_ref->data;
     cf  = (NVDECFrame*)fdd->hwaccel_priv;
 
     *pp = (CUVIDPICPARAMS) {
diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
index 8ff226b980..ae099a481c 100644
--- a/libavcodec/vaapi_hevc.c
+++ b/libavcodec/vaapi_hevc.c
@@ -53,39 +53,39 @@ static void init_vaapi_pic(VAPictureHEVC *va_pic)
 
 static void fill_vaapi_pic(VAPictureHEVC *va_pic, const HEVCFrame *pic, int rps_type)
 {
-    va_pic->picture_id    = ff_vaapi_get_surface_id(pic->frame);
+    va_pic->picture_id    = ff_vaapi_get_surface_id(pic->f);
     va_pic->pic_order_cnt = pic->poc;
     va_pic->flags         = rps_type;
 
     if (pic->flags & HEVC_FRAME_FLAG_LONG_REF)
         va_pic->flags |= VA_PICTURE_HEVC_LONG_TERM_REFERENCE;
 
-    if (pic->frame->flags & AV_FRAME_FLAG_INTERLACED) {
+    if (pic->f->flags & AV_FRAME_FLAG_INTERLACED) {
         va_pic->flags |= VA_PICTURE_HEVC_FIELD_PIC;
 
-        if (!(pic->frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST))
+        if (!(pic->f->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST))
             va_pic->flags |= VA_PICTURE_HEVC_BOTTOM_FIELD;
     }
 }
 
 static int find_frame_rps_type(const HEVCContext *h, const HEVCFrame *pic)
 {
-    VASurfaceID pic_surf = ff_vaapi_get_surface_id(pic->frame);
+    VASurfaceID pic_surf = ff_vaapi_get_surface_id(pic->f);
     const HEVCFrame *current_picture = h->cur_frame;
     int i;
 
     for (i = 0; i < h->rps[ST_CURR_BEF].nb_refs; i++) {
-        if (pic_surf == ff_vaapi_get_surface_id(h->rps[ST_CURR_BEF].ref[i]->frame))
+        if (pic_surf == ff_vaapi_get_surface_id(h->rps[ST_CURR_BEF].ref[i]->f))
             return VA_PICTURE_HEVC_RPS_ST_CURR_BEFORE;
     }
 
     for (i = 0; i < h->rps[ST_CURR_AFT].nb_refs; i++) {
-        if (pic_surf == ff_vaapi_get_surface_id(h->rps[ST_CURR_AFT].ref[i]->frame))
+        if (pic_surf == ff_vaapi_get_surface_id(h->rps[ST_CURR_AFT].ref[i]->f))
             return VA_PICTURE_HEVC_RPS_ST_CURR_AFTER;
     }
 
     for (i = 0; i < h->rps[LT_CURR].nb_refs; i++) {
-        if (pic_surf == ff_vaapi_get_surface_id(h->rps[LT_CURR].ref[i]->frame))
+        if (pic_surf == ff_vaapi_get_surface_id(h->rps[LT_CURR].ref[i]->f))
             return VA_PICTURE_HEVC_RPS_LT_CURR;
     }
 
@@ -137,7 +137,7 @@ static int vaapi_hevc_start_frame(AVCodecContext          *avctx,
 
     VAPictureParameterBufferHEVC *pic_param = (VAPictureParameterBufferHEVC *)&pic->pic_param;
 
-    pic->pic.output_surface = ff_vaapi_get_surface_id(h->cur_frame->frame);
+    pic->pic.output_surface = ff_vaapi_get_surface_id(h->cur_frame->f);
 
     *pic_param = (VAPictureParameterBufferHEVC) {
         .pic_width_in_luma_samples                    = sps->width,
@@ -445,7 +445,7 @@ static uint8_t get_ref_pic_index(const HEVCContext *h, const HEVCFrame *frame)
     for (i = 0; i < FF_ARRAY_ELEMS(pp->ReferenceFrames); i++) {
         VASurfaceID pid = pp->ReferenceFrames[i].picture_id;
         int poc = pp->ReferenceFrames[i].pic_order_cnt;
-        if (pid != VA_INVALID_ID && pid == ff_vaapi_get_surface_id(frame->frame) && poc == frame->poc)
+        if (pid != VA_INVALID_ID && pid == ff_vaapi_get_surface_id(frame->f) && poc == frame->poc)
             return i;
     }
 
diff --git a/libavcodec/vdpau_hevc.c b/libavcodec/vdpau_hevc.c
index acee077cfa..0fec877570 100644
--- a/libavcodec/vdpau_hevc.c
+++ b/libavcodec/vdpau_hevc.c
@@ -248,7 +248,7 @@ static int vdpau_hevc_start_frame(AVCodecContext *avctx,
             }
             /* Array of video reference surfaces.
                Set any unused positions to VDP_INVALID_HANDLE. */
-            info->RefPics[j] = ff_vdpau_get_surface_id(frame->frame);
+            info->RefPics[j] = ff_vdpau_get_surface_id(frame->f);
             /* Array of picture order counts. These correspond to positions
                in the RefPics array. */
             info->PicOrderCntVal[j] = frame->poc;
@@ -295,7 +295,7 @@ static int vdpau_hevc_start_frame(AVCodecContext *avctx,
         HEVCFrame *frame = h->rps[ST_CURR_BEF].ref[i];
         if (frame) {
             uint8_t found = 0;
-            uintptr_t id = ff_vdpau_get_surface_id(frame->frame);
+            uintptr_t id = ff_vdpau_get_surface_id(frame->f);
             for (size_t k = 0; k < 16; k++) {
                 if (id == info->RefPics[k]) {
                     info->RefPicSetStCurrBefore[j] = k;
@@ -318,7 +318,7 @@ static int vdpau_hevc_start_frame(AVCodecContext *avctx,
         HEVCFrame *frame = h->rps[ST_CURR_AFT].ref[i];
         if (frame) {
             uint8_t found = 0;
-            uintptr_t id = ff_vdpau_get_surface_id(frame->frame);
+            uintptr_t id = ff_vdpau_get_surface_id(frame->f);
             for (size_t k = 0; k < 16; k++) {
                 if (id == info->RefPics[k]) {
                     info->RefPicSetStCurrAfter[j] = k;
@@ -341,7 +341,7 @@ static int vdpau_hevc_start_frame(AVCodecContext *avctx,
         HEVCFrame *frame = h->rps[LT_CURR].ref[i];
         if (frame) {
             uint8_t found = 0;
-            uintptr_t id = ff_vdpau_get_surface_id(frame->frame);
+            uintptr_t id = ff_vdpau_get_surface_id(frame->f);
             for (size_t k = 0; k < 16; k++) {
                 if (id == info->RefPics[k]) {
                     info->RefPicSetLtCurr[j] = k;
@@ -423,7 +423,7 @@ static int vdpau_hevc_end_frame(AVCodecContext *avctx)
     struct vdpau_picture_context *pic_ctx = h->cur_frame->hwaccel_picture_private;
     int val;
 
-    val = ff_vdpau_common_end_frame(avctx, h->cur_frame->frame, pic_ctx);
+    val = ff_vdpau_common_end_frame(avctx, h->cur_frame->f, pic_ctx);
     if (val < 0)
         return val;
 
diff --git a/libavcodec/vulkan_hevc.c b/libavcodec/vulkan_hevc.c
index 1a12f14652..f994b94e7e 100644
--- a/libavcodec/vulkan_hevc.c
+++ b/libavcodec/vulkan_hevc.c
@@ -139,7 +139,7 @@ static int vk_hevc_fill_pict(AVCodecContext *avctx, HEVCFrame **ref_src,
     HEVCVulkanDecodePicture *hp = pic->hwaccel_picture_private;
     FFVulkanDecodePicture *vkpic = &hp->vp;
 
-    int err = ff_vk_decode_prepare_frame(dec, pic->frame, vkpic, is_current,
+    int err = ff_vk_decode_prepare_frame(dec, pic->f, vkpic, is_current,
                                          dec->dedicated_dpb);
     if (err < 0)
         return err;
@@ -160,7 +160,7 @@ static int vk_hevc_fill_pict(AVCodecContext *avctx, HEVCFrame **ref_src,
     *ref = (VkVideoPictureResourceInfoKHR) {
         .sType = VK_STRUCTURE_TYPE_VIDEO_PICTURE_RESOURCE_INFO_KHR,
         .codedOffset = (VkOffset2D){ 0, 0 },
-        .codedExtent = (VkExtent2D){ pic->frame->width, pic->frame->height },
+        .codedExtent = (VkExtent2D){ pic->f->width, pic->f->height },
         .baseArrayLayer = dec->layered_dpb ? pic_id : 0,
         .imageViewBinding = vkpic->img_view_ref,
     };
@@ -837,7 +837,7 @@ static int vk_hevc_start_frame(AVCodecContext          *avctx,
         .dstPictureResource = (VkVideoPictureResourceInfoKHR) {
             .sType = VK_STRUCTURE_TYPE_VIDEO_PICTURE_RESOURCE_INFO_KHR,
             .codedOffset = (VkOffset2D){ 0, 0 },
-            .codedExtent = (VkExtent2D){ pic->frame->width, pic->frame->height },
+            .codedExtent = (VkExtent2D){ pic->f->width, pic->f->height },
             .baseArrayLayer = 0,
             .imageViewBinding = vp->img_view_out,
         },
@@ -904,14 +904,14 @@ static int vk_hevc_end_frame(AVCodecContext *avctx)
 
     for (int i = 0; i < vp->decode_info.referenceSlotCount; i++) {
         HEVCVulkanDecodePicture *rfhp = hp->ref_src[i]->hwaccel_picture_private;
-        rav[i] = hp->ref_src[i]->frame;
+        rav[i] = hp->ref_src[i]->f;
         rvp[i] = &rfhp->vp;
     }
 
     av_log(avctx, AV_LOG_VERBOSE, "Decoding frame, %"SIZE_SPECIFIER" bytes, %i slices\n",
            vp->slices_size, hp->h265_pic_info.sliceSegmentCount);
 
-    return ff_vk_decode_frame(avctx, pic->frame, vp, rav, rvp);
+    return ff_vk_decode_frame(avctx, pic->f, vp, rav, rvp);
 }
 
 static void vk_hevc_free_frame_priv(FFRefStructOpaque _hwctx, void *data)
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [FFmpeg-devel] [PATCH 08/11] lavc/hevcdec: drop HEVCContext.frame
  2024-05-31 17:47 [FFmpeg-devel] [PATCH 01/11] lavc/hevcdec: move handling of byte alignment at the end of slice header Anton Khirnov
                   ` (5 preceding siblings ...)
  2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 07/11] lavc/hevcdec: rename HEVCFrame.frame to just f Anton Khirnov
@ 2024-05-31 17:47 ` Anton Khirnov
  2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 09/11] lavc/hevc*: move to hevc/ subdir Anton Khirnov
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Anton Khirnov @ 2024-05-31 17:47 UTC (permalink / raw)
  To: ffmpeg-devel

It is merely a redundant pointer to cur_frame->f
---
 libavcodec/hevc_cabac.c        |  4 +--
 libavcodec/hevc_filter.c       | 39 +++++++++++--------------
 libavcodec/hevc_refs.c         |  3 +-
 libavcodec/hevcdec.c           | 53 +++++++++++++++++-----------------
 libavcodec/hevcdec.h           |  3 +-
 libavcodec/hevcpred_template.c |  4 +--
 6 files changed, 50 insertions(+), 56 deletions(-)

diff --git a/libavcodec/hevc_cabac.c b/libavcodec/hevc_cabac.c
index 71bd678972..c9da4d7fc1 100644
--- a/libavcodec/hevc_cabac.c
+++ b/libavcodec/hevc_cabac.c
@@ -1002,10 +1002,10 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, int x0, int y0,
 
     const uint8_t *scan_x_cg, *scan_y_cg, *scan_x_off, *scan_y_off;
 
-    ptrdiff_t stride = s->frame->linesize[c_idx];
+    ptrdiff_t stride = s->cur_frame->f->linesize[c_idx];
     int hshift = s->ps.sps->hshift[c_idx];
     int vshift = s->ps.sps->vshift[c_idx];
-    uint8_t *dst = &s->frame->data[c_idx][(y0 >> vshift) * stride +
+    uint8_t *dst = &s->cur_frame->f->data[c_idx][(y0 >> vshift) * stride +
                                           ((x0 >> hshift) << s->ps.sps->pixel_shift)];
     int16_t *coeffs = (int16_t*)(c_idx ? lc->edge_emu_buffer2 : lc->edge_emu_buffer);
     uint8_t significant_coeff_group_flag[8][8] = {{0}};
diff --git a/libavcodec/hevc_filter.c b/libavcodec/hevc_filter.c
index 0ba419a7b8..db7525170d 100644
--- a/libavcodec/hevc_filter.c
+++ b/libavcodec/hevc_filter.c
@@ -315,13 +315,13 @@ static void sao_filter_CTB(HEVCLocalContext *lc, const HEVCContext *s, int x, in
     for (c_idx = 0; c_idx < (s->ps.sps->chroma_format_idc ? 3 : 1); c_idx++) {
         int x0       = x >> s->ps.sps->hshift[c_idx];
         int y0       = y >> s->ps.sps->vshift[c_idx];
-        ptrdiff_t stride_src = s->frame->linesize[c_idx];
+        ptrdiff_t stride_src = s->cur_frame->f->linesize[c_idx];
         int ctb_size_h = (1 << (s->ps.sps->log2_ctb_size)) >> s->ps.sps->hshift[c_idx];
         int ctb_size_v = (1 << (s->ps.sps->log2_ctb_size)) >> s->ps.sps->vshift[c_idx];
         int width    = FFMIN(ctb_size_h, (s->ps.sps->width  >> s->ps.sps->hshift[c_idx]) - x0);
         int height   = FFMIN(ctb_size_v, (s->ps.sps->height >> s->ps.sps->vshift[c_idx]) - y0);
         int tab      = sao_tab[(FFALIGN(width, 8) >> 3) - 1];
-        uint8_t *src = &s->frame->data[c_idx][y0 * stride_src + (x0 << s->ps.sps->pixel_shift)];
+        uint8_t *src = &s->cur_frame->f->data[c_idx][y0 * stride_src + (x0 << s->ps.sps->pixel_shift)];
         ptrdiff_t stride_dst;
         uint8_t *dst;
 
@@ -484,6 +484,9 @@ static int get_pcm(const HEVCContext *s, int x, int y)
 
 static void deblocking_filter_CTB(const HEVCContext *s, int x0, int y0)
 {
+    uint8_t **data     = s->cur_frame->f->data;
+    int      *linesize = s->cur_frame->f->linesize;
+
     uint8_t *src;
     int x, y;
     int chroma, beta;
@@ -537,18 +540,16 @@ static void deblocking_filter_CTB(const HEVCContext *s, int x0, int y0)
 
                 tc[0]   = bs0 ? TC_CALC(qp, bs0) : 0;
                 tc[1]   = bs1 ? TC_CALC(qp, bs1) : 0;
-                src     = &s->frame->data[LUMA][y * s->frame->linesize[LUMA] + (x << s->ps.sps->pixel_shift)];
+                src     = &data[LUMA][y * linesize[LUMA] + (x << s->ps.sps->pixel_shift)];
                 if (pcmf) {
                     no_p[0] = get_pcm(s, x - 1, y);
                     no_p[1] = get_pcm(s, x - 1, y + 4);
                     no_q[0] = get_pcm(s, x, y);
                     no_q[1] = get_pcm(s, x, y + 4);
-                    s->hevcdsp.hevc_v_loop_filter_luma_c(src,
-                                                         s->frame->linesize[LUMA],
+                    s->hevcdsp.hevc_v_loop_filter_luma_c(src, linesize[LUMA],
                                                          beta, tc, no_p, no_q);
                 } else
-                    s->hevcdsp.hevc_v_loop_filter_luma(src,
-                                                       s->frame->linesize[LUMA],
+                    s->hevcdsp.hevc_v_loop_filter_luma(src, linesize[LUMA],
                                                        beta, tc, no_p, no_q);
             }
         }
@@ -569,18 +570,16 @@ static void deblocking_filter_CTB(const HEVCContext *s, int x0, int y0)
                 beta = betatable[av_clip(qp + beta_offset, 0, MAX_QP)];
                 tc[0]   = bs0 ? TC_CALC(qp, bs0) : 0;
                 tc[1]   = bs1 ? TC_CALC(qp, bs1) : 0;
-                src     = &s->frame->data[LUMA][y * s->frame->linesize[LUMA] + (x << s->ps.sps->pixel_shift)];
+                src     = &data[LUMA][y * linesize[LUMA] + (x << s->ps.sps->pixel_shift)];
                 if (pcmf) {
                     no_p[0] = get_pcm(s, x, y - 1);
                     no_p[1] = get_pcm(s, x + 4, y - 1);
                     no_q[0] = get_pcm(s, x, y);
                     no_q[1] = get_pcm(s, x + 4, y);
-                    s->hevcdsp.hevc_h_loop_filter_luma_c(src,
-                                                         s->frame->linesize[LUMA],
+                    s->hevcdsp.hevc_h_loop_filter_luma_c(src, linesize[LUMA],
                                                          beta, tc, no_p, no_q);
                 } else
-                    s->hevcdsp.hevc_h_loop_filter_luma(src,
-                                                       s->frame->linesize[LUMA],
+                    s->hevcdsp.hevc_h_loop_filter_luma(src, linesize[LUMA],
                                                        beta, tc, no_p, no_q);
             }
         }
@@ -603,18 +602,16 @@ static void deblocking_filter_CTB(const HEVCContext *s, int x0, int y0)
 
                         c_tc[0] = (bs0 == 2) ? chroma_tc(s, qp0, chroma, tc_offset) : 0;
                         c_tc[1] = (bs1 == 2) ? chroma_tc(s, qp1, chroma, tc_offset) : 0;
-                        src       = &s->frame->data[chroma][(y >> s->ps.sps->vshift[chroma]) * s->frame->linesize[chroma] + ((x >> s->ps.sps->hshift[chroma]) << s->ps.sps->pixel_shift)];
+                        src       = &data[chroma][(y >> s->ps.sps->vshift[chroma]) * linesize[chroma] + ((x >> s->ps.sps->hshift[chroma]) << s->ps.sps->pixel_shift)];
                         if (pcmf) {
                             no_p[0] = get_pcm(s, x - 1, y);
                             no_p[1] = get_pcm(s, x - 1, y + (4 * v));
                             no_q[0] = get_pcm(s, x, y);
                             no_q[1] = get_pcm(s, x, y + (4 * v));
-                            s->hevcdsp.hevc_v_loop_filter_chroma_c(src,
-                                                                   s->frame->linesize[chroma],
+                            s->hevcdsp.hevc_v_loop_filter_chroma_c(src, linesize[chroma],
                                                                    c_tc, no_p, no_q);
                         } else
-                            s->hevcdsp.hevc_v_loop_filter_chroma(src,
-                                                                 s->frame->linesize[chroma],
+                            s->hevcdsp.hevc_v_loop_filter_chroma(src, linesize[chroma],
                                                                  c_tc, no_p, no_q);
                     }
                 }
@@ -636,18 +633,16 @@ static void deblocking_filter_CTB(const HEVCContext *s, int x0, int y0)
 
                         c_tc[0]   = bs0 == 2 ? chroma_tc(s, qp0, chroma, tc_offset)     : 0;
                         c_tc[1]   = bs1 == 2 ? chroma_tc(s, qp1, chroma, cur_tc_offset) : 0;
-                        src       = &s->frame->data[chroma][(y >> s->ps.sps->vshift[1]) * s->frame->linesize[chroma] + ((x >> s->ps.sps->hshift[1]) << s->ps.sps->pixel_shift)];
+                        src       = &data[chroma][(y >> s->ps.sps->vshift[1]) * linesize[chroma] + ((x >> s->ps.sps->hshift[1]) << s->ps.sps->pixel_shift)];
                         if (pcmf) {
                             no_p[0] = get_pcm(s, x,           y - 1);
                             no_p[1] = get_pcm(s, x + (4 * h), y - 1);
                             no_q[0] = get_pcm(s, x,           y);
                             no_q[1] = get_pcm(s, x + (4 * h), y);
-                            s->hevcdsp.hevc_h_loop_filter_chroma_c(src,
-                                                                   s->frame->linesize[chroma],
+                            s->hevcdsp.hevc_h_loop_filter_chroma_c(src, linesize[chroma],
                                                                    c_tc, no_p, no_q);
                         } else
-                            s->hevcdsp.hevc_h_loop_filter_chroma(src,
-                                                                 s->frame->linesize[chroma],
+                            s->hevcdsp.hevc_h_loop_filter_chroma(src, linesize[chroma],
                                                                  c_tc, no_p, no_q);
                     }
                 }
diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c
index 6019818cf0..39ce70ca39 100644
--- a/libavcodec/hevc_refs.c
+++ b/libavcodec/hevc_refs.c
@@ -122,7 +122,7 @@ fail:
     return NULL;
 }
 
-int ff_hevc_set_new_ref(HEVCContext *s, AVFrame **frame, int poc)
+int ff_hevc_set_new_ref(HEVCContext *s, int poc)
 {
     HEVCFrame *ref;
     int i;
@@ -143,7 +143,6 @@ int ff_hevc_set_new_ref(HEVCContext *s, AVFrame **frame, int poc)
     if (!ref)
         return AVERROR(ENOMEM);
 
-    *frame = ref->f;
     s->cur_frame = ref;
     s->collocated_ref = NULL;
 
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 6283abbbe8..173810883d 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -1258,14 +1258,14 @@ static int hls_transform_unit(HEVCLocalContext *lc, int x0, int y0,
                                                 log2_trafo_size_c, scan_idx_c, 1);
                 else
                     if (lc->tu.cross_pf) {
-                        ptrdiff_t stride = s->frame->linesize[1];
+                        ptrdiff_t stride = s->cur_frame->f->linesize[1];
                         int hshift = s->ps.sps->hshift[1];
                         int vshift = s->ps.sps->vshift[1];
                         const int16_t *coeffs_y = (int16_t*)lc->edge_emu_buffer;
                         int16_t *coeffs   = (int16_t*)lc->edge_emu_buffer2;
                         int size = 1 << log2_trafo_size_c;
 
-                        uint8_t *dst = &s->frame->data[1][(y0 >> vshift) * stride +
+                        uint8_t *dst = &s->cur_frame->f->data[1][(y0 >> vshift) * stride +
                                                               ((x0 >> hshift) << s->ps.sps->pixel_shift)];
                         for (i = 0; i < (size * size); i++) {
                             coeffs[i] = ((lc->tu.res_scale_val * coeffs_y[i]) >> 3);
@@ -1288,14 +1288,14 @@ static int hls_transform_unit(HEVCLocalContext *lc, int x0, int y0,
                                                 log2_trafo_size_c, scan_idx_c, 2);
                 else
                     if (lc->tu.cross_pf) {
-                        ptrdiff_t stride = s->frame->linesize[2];
+                        ptrdiff_t stride = s->cur_frame->f->linesize[2];
                         int hshift = s->ps.sps->hshift[2];
                         int vshift = s->ps.sps->vshift[2];
                         const int16_t *coeffs_y = (int16_t*)lc->edge_emu_buffer;
                         int16_t *coeffs   = (int16_t*)lc->edge_emu_buffer2;
                         int size = 1 << log2_trafo_size_c;
 
-                        uint8_t *dst = &s->frame->data[2][(y0 >> vshift) * stride +
+                        uint8_t *dst = &s->cur_frame->f->data[2][(y0 >> vshift) * stride +
                                                           ((x0 >> hshift) << s->ps.sps->pixel_shift)];
                         for (i = 0; i < (size * size); i++) {
                             coeffs[i] = ((lc->tu.res_scale_val * coeffs_y[i]) >> 3);
@@ -1502,12 +1502,12 @@ static int hls_pcm_sample(HEVCLocalContext *lc, int x0, int y0, int log2_cb_size
     const HEVCContext *const s = lc->parent;
     GetBitContext gb;
     int cb_size   = 1 << log2_cb_size;
-    ptrdiff_t stride0 = s->frame->linesize[0];
-    ptrdiff_t stride1 = s->frame->linesize[1];
-    ptrdiff_t stride2 = s->frame->linesize[2];
-    uint8_t *dst0 = &s->frame->data[0][y0 * stride0 + (x0 << s->ps.sps->pixel_shift)];
-    uint8_t *dst1 = &s->frame->data[1][(y0 >> s->ps.sps->vshift[1]) * stride1 + ((x0 >> s->ps.sps->hshift[1]) << s->ps.sps->pixel_shift)];
-    uint8_t *dst2 = &s->frame->data[2][(y0 >> s->ps.sps->vshift[2]) * stride2 + ((x0 >> s->ps.sps->hshift[2]) << s->ps.sps->pixel_shift)];
+    ptrdiff_t stride0 = s->cur_frame->f->linesize[0];
+    ptrdiff_t stride1 = s->cur_frame->f->linesize[1];
+    ptrdiff_t stride2 = s->cur_frame->f->linesize[2];
+    uint8_t *dst0 = &s->cur_frame->f->data[0][y0 * stride0 + (x0 << s->ps.sps->pixel_shift)];
+    uint8_t *dst1 = &s->cur_frame->f->data[1][(y0 >> s->ps.sps->vshift[1]) * stride1 + ((x0 >> s->ps.sps->hshift[1]) << s->ps.sps->pixel_shift)];
+    uint8_t *dst2 = &s->cur_frame->f->data[2][(y0 >> s->ps.sps->vshift[2]) * stride2 + ((x0 >> s->ps.sps->hshift[2]) << s->ps.sps->pixel_shift)];
 
     int length         = cb_size * cb_size * s->ps.sps->pcm.bit_depth +
                          (((cb_size >> s->ps.sps->hshift[1]) * (cb_size >> s->ps.sps->vshift[1])) +
@@ -1576,7 +1576,7 @@ static void luma_mc_uni(HEVCLocalContext *lc, uint8_t *dst, ptrdiff_t dststride,
     if (x_off < QPEL_EXTRA_BEFORE || y_off < QPEL_EXTRA_AFTER ||
         x_off >= pic_width - block_w - QPEL_EXTRA_AFTER ||
         y_off >= pic_height - block_h - QPEL_EXTRA_AFTER ||
-        ref == s->frame) {
+        ref == s->cur_frame->f) {
         const ptrdiff_t edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->ps.sps->pixel_shift;
         int offset     = QPEL_EXTRA_BEFORE * srcstride       + (QPEL_EXTRA_BEFORE << s->ps.sps->pixel_shift);
         int buf_offset = QPEL_EXTRA_BEFORE * edge_emu_stride + (QPEL_EXTRA_BEFORE << s->ps.sps->pixel_shift);
@@ -1726,7 +1726,7 @@ static void chroma_mc_uni(HEVCLocalContext *lc, uint8_t *dst0,
     intptr_t my          = av_mod_uintp2(mv->y, 2 + vshift);
     intptr_t _mx         = mx << (1 - hshift);
     intptr_t _my         = my << (1 - vshift);
-    int emu              = src0 == s->frame->data[1] || src0 == s->frame->data[2];
+    int emu              = src0 == s->cur_frame->f->data[1] || src0 == s->cur_frame->f->data[2];
 
     x_off += mv->x >> (2 + hshift);
     y_off += mv->y >> (2 + vshift);
@@ -1852,11 +1852,11 @@ static void chroma_mc_bi(HEVCLocalContext *lc, uint8_t *dst0, ptrdiff_t dststrid
     s->hevcdsp.put_hevc_epel[idx][!!my0][!!mx0](lc->tmp, src1, src1stride,
                                                 block_h, _mx0, _my0, block_w);
     if (!weight_flag)
-        s->hevcdsp.put_hevc_epel_bi[idx][!!my1][!!mx1](dst0, s->frame->linesize[cidx+1],
+        s->hevcdsp.put_hevc_epel_bi[idx][!!my1][!!mx1](dst0, s->cur_frame->f->linesize[cidx+1],
                                                        src2, src2stride, lc->tmp,
                                                        block_h, _mx1, _my1, block_w);
     else
-        s->hevcdsp.put_hevc_epel_bi_w[idx][!!my1][!!mx1](dst0, s->frame->linesize[cidx+1],
+        s->hevcdsp.put_hevc_epel_bi_w[idx][!!my1][!!mx1](dst0, s->cur_frame->f->linesize[cidx+1],
                                                          src2, src2stride, lc->tmp,
                                                          block_h,
                                                          s->sh.chroma_log2_weight_denom,
@@ -1927,7 +1927,7 @@ static void hls_prediction_unit(HEVCLocalContext *lc, int x0, int y0,
                                 int log2_cb_size, int partIdx, int idx)
 {
 #define POS(c_idx, x, y)                                                              \
-    &s->frame->data[c_idx][((y) >> s->ps.sps->vshift[c_idx]) * s->frame->linesize[c_idx] + \
+    &s->cur_frame->f->data[c_idx][((y) >> s->ps.sps->vshift[c_idx]) * linesize[c_idx] + \
                            (((x) >> s->ps.sps->hshift[c_idx]) << s->ps.sps->pixel_shift)]
     const HEVCContext *const s = lc->parent;
     int merge_idx = 0;
@@ -1938,6 +1938,7 @@ static void hls_prediction_unit(HEVCLocalContext *lc, int x0, int y0,
     MvField *tab_mvf = s->cur_frame->tab_mvf;
     const RefPicList *refPicList = s->cur_frame->refPicList;
     const HEVCFrame *ref0 = NULL, *ref1 = NULL;
+    const int *linesize = s->cur_frame->f->linesize;
     uint8_t *dst0 = POS(0, x0, y0);
     uint8_t *dst1 = POS(1, x0, y0);
     uint8_t *dst2 = POS(2, x0, y0);
@@ -1992,16 +1993,16 @@ static void hls_prediction_unit(HEVCLocalContext *lc, int x0, int y0,
         int nPbW_c = nPbW >> s->ps.sps->hshift[1];
         int nPbH_c = nPbH >> s->ps.sps->vshift[1];
 
-        luma_mc_uni(lc, dst0, s->frame->linesize[0], ref0->f,
+        luma_mc_uni(lc, dst0, linesize[0], ref0->f,
                     &current_mv.mv[0], x0, y0, nPbW, nPbH,
                     s->sh.luma_weight_l0[current_mv.ref_idx[0]],
                     s->sh.luma_offset_l0[current_mv.ref_idx[0]]);
 
         if (s->ps.sps->chroma_format_idc) {
-            chroma_mc_uni(lc, dst1, s->frame->linesize[1], ref0->f->data[1], ref0->f->linesize[1],
+            chroma_mc_uni(lc, dst1, linesize[1], ref0->f->data[1], ref0->f->linesize[1],
                           0, x0_c, y0_c, nPbW_c, nPbH_c, &current_mv,
                           s->sh.chroma_weight_l0[current_mv.ref_idx[0]][0], s->sh.chroma_offset_l0[current_mv.ref_idx[0]][0]);
-            chroma_mc_uni(lc, dst2, s->frame->linesize[2], ref0->f->data[2], ref0->f->linesize[2],
+            chroma_mc_uni(lc, dst2, linesize[2], ref0->f->data[2], ref0->f->linesize[2],
                           0, x0_c, y0_c, nPbW_c, nPbH_c, &current_mv,
                           s->sh.chroma_weight_l0[current_mv.ref_idx[0]][1], s->sh.chroma_offset_l0[current_mv.ref_idx[0]][1]);
         }
@@ -2011,17 +2012,17 @@ static void hls_prediction_unit(HEVCLocalContext *lc, int x0, int y0,
         int nPbW_c = nPbW >> s->ps.sps->hshift[1];
         int nPbH_c = nPbH >> s->ps.sps->vshift[1];
 
-        luma_mc_uni(lc, dst0, s->frame->linesize[0], ref1->f,
+        luma_mc_uni(lc, dst0, linesize[0], ref1->f,
                     &current_mv.mv[1], x0, y0, nPbW, nPbH,
                     s->sh.luma_weight_l1[current_mv.ref_idx[1]],
                     s->sh.luma_offset_l1[current_mv.ref_idx[1]]);
 
         if (s->ps.sps->chroma_format_idc) {
-            chroma_mc_uni(lc, dst1, s->frame->linesize[1], ref1->f->data[1], ref1->f->linesize[1],
+            chroma_mc_uni(lc, dst1, linesize[1], ref1->f->data[1], ref1->f->linesize[1],
                           1, x0_c, y0_c, nPbW_c, nPbH_c, &current_mv,
                           s->sh.chroma_weight_l1[current_mv.ref_idx[1]][0], s->sh.chroma_offset_l1[current_mv.ref_idx[1]][0]);
 
-            chroma_mc_uni(lc, dst2, s->frame->linesize[2], ref1->f->data[2], ref1->f->linesize[2],
+            chroma_mc_uni(lc, dst2, linesize[2], ref1->f->data[2], ref1->f->linesize[2],
                           1, x0_c, y0_c, nPbW_c, nPbH_c, &current_mv,
                           s->sh.chroma_weight_l1[current_mv.ref_idx[1]][1], s->sh.chroma_offset_l1[current_mv.ref_idx[1]][1]);
         }
@@ -2031,15 +2032,15 @@ static void hls_prediction_unit(HEVCLocalContext *lc, int x0, int y0,
         int nPbW_c = nPbW >> s->ps.sps->hshift[1];
         int nPbH_c = nPbH >> s->ps.sps->vshift[1];
 
-        luma_mc_bi(lc, dst0, s->frame->linesize[0], ref0->f,
+        luma_mc_bi(lc, dst0, linesize[0], ref0->f,
                    &current_mv.mv[0], x0, y0, nPbW, nPbH,
                    ref1->f, &current_mv.mv[1], &current_mv);
 
         if (s->ps.sps->chroma_format_idc) {
-            chroma_mc_bi(lc, dst1, s->frame->linesize[1], ref0->f, ref1->f,
+            chroma_mc_bi(lc, dst1, linesize[1], ref0->f, ref1->f,
                          x0_c, y0_c, nPbW_c, nPbH_c, &current_mv, 0);
 
-            chroma_mc_bi(lc, dst2, s->frame->linesize[2], ref0->f, ref1->f,
+            chroma_mc_bi(lc, dst2, linesize[2], ref0->f, ref1->f,
                          x0_c, y0_c, nPbW_c, nPbH_c, &current_mv, 1);
         }
     }
@@ -2885,7 +2886,7 @@ static int hevc_frame_start(HEVCContext *s)
     if (s->ps.pps->tiles_enabled_flag)
         s->local_ctx[0].end_of_tiles_x = s->ps.pps->column_width[0] << s->ps.sps->log2_ctb_size;
 
-    ret = ff_hevc_set_new_ref(s, &s->frame, s->poc);
+    ret = ff_hevc_set_new_ref(s, s->poc);
     if (ret < 0)
         goto fail;
 
@@ -2927,7 +2928,7 @@ static int hevc_frame_start(HEVCContext *s)
             goto fail;
     }
 
-    s->frame->pict_type = 3 - s->sh.slice_type;
+    s->cur_frame->f->pict_type = 3 - s->sh.slice_type;
 
     if (!IS_IRAP(s))
         ff_hevc_bump_frame(s);
diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h
index 3eb8451734..0cd6b8c2b4 100644
--- a/libavcodec/hevcdec.h
+++ b/libavcodec/hevcdec.h
@@ -461,7 +461,6 @@ typedef struct HEVCContext {
     /** 1 if the independent slice segment header was successfully parsed */
     uint8_t slice_initialized;
 
-    AVFrame *frame;
     AVFrame *output_frame;
     uint8_t *sao_pixel_buffer_h[3];
     uint8_t *sao_pixel_buffer_v[3];
@@ -618,7 +617,7 @@ int ff_hevc_res_scale_sign_flag(HEVCLocalContext *lc, int idx);
  */
 int ff_hevc_frame_nb_refs(const HEVCContext *s);
 
-int ff_hevc_set_new_ref(HEVCContext *s, AVFrame **frame, int poc);
+int ff_hevc_set_new_ref(HEVCContext *s, int poc);
 
 static av_always_inline int ff_hevc_nal_is_nonref(enum HEVCNALUnitType type)
 {
diff --git a/libavcodec/hevcpred_template.c b/libavcodec/hevcpred_template.c
index 4e96ac3423..a1f8cf150e 100644
--- a/libavcodec/hevcpred_template.c
+++ b/libavcodec/hevcpred_template.c
@@ -87,8 +87,8 @@ do {                                  \
 
     int cur_tb_addr = MIN_TB_ADDR_ZS(x_tb, y_tb);
 
-    ptrdiff_t stride = s->frame->linesize[c_idx] / sizeof(pixel);
-    pixel *src = (pixel*)s->frame->data[c_idx] + x + y * stride;
+    ptrdiff_t stride = s->cur_frame->f->linesize[c_idx] / sizeof(pixel);
+    pixel *src = (pixel*)s->cur_frame->f->data[c_idx] + x + y * stride;
 
     int min_pu_width = s->ps.sps->min_pu_width;
 
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [FFmpeg-devel] [PATCH 09/11] lavc/hevc*: move to hevc/ subdir
  2024-05-31 17:47 [FFmpeg-devel] [PATCH 01/11] lavc/hevcdec: move handling of byte alignment at the end of slice header Anton Khirnov
                   ` (6 preceding siblings ...)
  2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 08/11] lavc/hevcdec: drop HEVCContext.frame Anton Khirnov
@ 2024-05-31 17:47 ` Anton Khirnov
  2024-06-02  0:39   ` James Almer
  2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 10/11] lavc/hevcdec: deduplicate calling hwaccel decode_params() Anton Khirnov
  2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 11/11] lavc/hevcdec: drop unused HEVCContext.width/height Anton Khirnov
  9 siblings, 1 reply; 14+ messages in thread
From: Anton Khirnov @ 2024-05-31 17:47 UTC (permalink / raw)
  To: ffmpeg-devel

---
 libavcodec/Makefile                           | 12 ++-----
 libavcodec/aarch64/hevcdsp_init_aarch64.c     |  2 +-
 libavcodec/arm/hevcdsp_arm.h                  |  2 +-
 libavcodec/arm/hevcdsp_init_arm.c             |  2 +-
 libavcodec/arm/hevcdsp_init_neon.c            |  2 +-
 libavcodec/bsf/extract_extradata.c            |  3 +-
 libavcodec/bsf/h265_metadata.c                |  3 +-
 libavcodec/bsf/hevc_mp4toannexb.c             |  3 +-
 libavcodec/bsf/remove_extradata.c             |  3 +-
 libavcodec/cbs_h2645.c                        |  2 +-
 libavcodec/cbs_h265.h                         |  3 +-
 libavcodec/d3d12va_hevc.c                     |  4 +--
 libavcodec/dxva2_hevc.c                       |  4 +--
 libavcodec/h2645_parse.c                      |  3 +-
 libavcodec/hevc/Makefile                      | 36 +++++++++++++++++++
 libavcodec/{hevc_cabac.c => hevc/cabac.c}     |  2 +-
 libavcodec/{hevc_data.c => hevc/data.c}       |  2 +-
 libavcodec/{hevc_data.h => hevc/data.h}       |  0
 libavcodec/{hevcdsp.c => hevc/dsp.c}          | 10 +++---
 libavcodec/{hevcdsp.h => hevc/dsp.h}          |  8 ++---
 .../dsp_template.c}                           |  2 +-
 libavcodec/{hevc_filter.c => hevc/filter.c}   |  0
 libavcodec/{ => hevc}/hevc.h                  |  6 ++--
 libavcodec/{ => hevc}/hevcdec.c               |  2 +-
 libavcodec/{ => hevc}/hevcdec.h               | 33 ++++++++---------
 libavcodec/{hevc_mvs.c => hevc/mvs.c}         |  0
 libavcodec/{hevc_parse.c => hevc/parse.c}     |  2 +-
 libavcodec/{hevc_parse.h => hevc/parse.h}     |  4 +--
 libavcodec/{hevc_parser.c => hevc/parser.c}   |  6 ++--
 libavcodec/{hevcpred.c => hevc/pred.c}        | 10 +++---
 libavcodec/{hevcpred.h => hevc/pred.h}        |  6 ++--
 .../pred_template.c}                          |  2 +-
 libavcodec/{hevc_ps.c => hevc/ps.c}           |  4 +--
 libavcodec/{hevc_ps.h => hevc/ps.h}           |  7 ++--
 libavcodec/{hevc_ps_enc.c => hevc/ps_enc.c}   |  2 +-
 libavcodec/{hevc_refs.c => hevc/refs.c}       |  0
 libavcodec/{hevc_sei.c => hevc/sei.c}         |  4 +--
 libavcodec/{hevc_sei.h => hevc/sei.h}         |  7 ++--
 libavcodec/loongarch/hevcdsp_lasx.h           |  2 +-
 libavcodec/loongarch/hevcdsp_lsx.h            |  2 +-
 libavcodec/mediacodecdec.c                    |  2 +-
 libavcodec/mips/hevcdsp_mips.h                |  2 +-
 libavcodec/mips/hevcdsp_mmi.c                 |  2 +-
 libavcodec/mips/hevcpred_mips.h               |  2 +-
 libavcodec/mips/hevcpred_msa.c                |  2 +-
 libavcodec/nvdec_hevc.c                       |  4 +--
 libavcodec/nvenc.c                            |  2 +-
 libavcodec/ppc/hevcdsp.c                      |  2 +-
 libavcodec/qsvenc_hevc.c                      |  5 +--
 libavcodec/vaapi_encode_h265.c                |  3 +-
 libavcodec/vaapi_hevc.c                       |  3 +-
 libavcodec/vdpau_hevc.c                       |  4 +--
 libavcodec/videotoolbox.c                     |  2 +-
 libavcodec/vulkan_hevc.c                      |  6 ++--
 libavcodec/x86/hevcdsp_init.c                 |  2 +-
 libavformat/hevc.c                            |  2 +-
 libavformat/hevcdec.c                         |  2 +-
 libavformat/mov.c                             |  2 +-
 libavformat/mpegtsenc.c                       |  2 +-
 tests/checkasm/hevc_add_res.c                 |  2 +-
 tests/checkasm/hevc_deblock.c                 |  2 +-
 tests/checkasm/hevc_idct.c                    |  2 +-
 tests/checkasm/hevc_pel.c                     |  2 +-
 tests/checkasm/hevc_sao.c                     |  2 +-
 64 files changed, 154 insertions(+), 114 deletions(-)
 create mode 100644 libavcodec/hevc/Makefile
 rename libavcodec/{hevc_cabac.c => hevc/cabac.c} (99%)
 rename libavcodec/{hevc_data.c => hevc/data.c} (98%)
 rename libavcodec/{hevc_data.h => hevc/data.h} (100%)
 rename libavcodec/{hevcdsp.c => hevc/dsp.c} (99%)
 rename libavcodec/{hevcdsp.h => hevc/dsp.h} (98%)
 rename libavcodec/{hevcdsp_template.c => hevc/dsp_template.c} (99%)
 rename libavcodec/{hevc_filter.c => hevc/filter.c} (100%)
 rename libavcodec/{ => hevc}/hevc.h (98%)
 rename libavcodec/{ => hevc}/hevcdec.c (99%)
 rename libavcodec/{ => hevc}/hevcdec.h (97%)
 rename libavcodec/{hevc_mvs.c => hevc/mvs.c} (100%)
 rename libavcodec/{hevc_parse.c => hevc/parse.c} (99%)
 rename libavcodec/{hevc_parse.h => hevc/parse.h} (96%)
 rename libavcodec/{hevc_parser.c => hevc/parser.c} (99%)
 rename libavcodec/{hevcpred.c => hevc/pred.c} (93%)
 rename libavcodec/{hevcpred.h => hevc/pred.h} (94%)
 rename libavcodec/{hevcpred_template.c => hevc/pred_template.c} (99%)
 rename libavcodec/{hevc_ps.c => hevc/ps.c} (99%)
 rename libavcodec/{hevc_ps.h => hevc/ps.h} (99%)
 rename libavcodec/{hevc_ps_enc.c => hevc/ps_enc.c} (99%)
 rename libavcodec/{hevc_refs.c => hevc/refs.c} (100%)
 rename libavcodec/{hevc_sei.c => hevc/sei.c} (99%)
 rename libavcodec/{hevc_sei.h => hevc/sei.h} (96%)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 2443d2c6fd..8ab4398b6c 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -65,6 +65,7 @@ OBJS = ac3_parser.o                                                     \
 
 # subsystems
 include $(SRC_PATH)/libavcodec/aac/Makefile
+include $(SRC_PATH)/libavcodec/hevc/Makefile
 include $(SRC_PATH)/libavcodec/vvc/Makefile
 -include $(SRC_PATH)/libavcodec/$(ARCH)/vvc/Makefile
 OBJS-$(CONFIG_AANDCTTABLES)            += aandcttab.o
@@ -105,10 +106,6 @@ OBJS-$(CONFIG_H264PARSE)               += h264_parse.o h264_ps.o h264data.o \
 OBJS-$(CONFIG_H264PRED)                += h264pred.o
 OBJS-$(CONFIG_H264QPEL)                += h264qpel.o
 OBJS-$(CONFIG_H264_SEI)                += h264_sei.o h2645_sei.o
-OBJS-$(CONFIG_HEVCPARSE)               += hevc_parse.o hevc_ps.o hevc_data.o \
-                                          h2645data.o h2645_parse.o h2645_vui.o
-OBJS-$(CONFIG_HEVC_SEI)                += hevc_sei.o h2645_sei.o \
-                                          dynamic_hdr_vivid.o aom_film_grain.o
 OBJS-$(CONFIG_HPELDSP)                 += hpeldsp.o
 OBJS-$(CONFIG_HUFFMAN)                 += huffman.o
 OBJS-$(CONFIG_HUFFYUVDSP)              += huffyuvdsp.o
@@ -430,10 +427,6 @@ OBJS-$(CONFIG_HCA_DECODER)             += hcadec.o
 OBJS-$(CONFIG_HCOM_DECODER)            += hcom.o
 OBJS-$(CONFIG_HDR_DECODER)             += hdrdec.o
 OBJS-$(CONFIG_HDR_ENCODER)             += hdrenc.o
-OBJS-$(CONFIG_HEVC_DECODER)            += hevcdec.o hevc_mvs.o \
-                                          hevc_cabac.o hevc_refs.o hevcpred.o    \
-                                          hevcdsp.o hevc_filter.o hevc_data.o \
-                                          h274.o aom_film_grain.o
 OBJS-$(CONFIG_HEVC_AMF_ENCODER)        += amfenc_hevc.o
 OBJS-$(CONFIG_HEVC_CUVID_DECODER)      += cuviddec.o
 OBJS-$(CONFIG_HEVC_MEDIACODEC_DECODER) += mediacodecdec.o
@@ -441,7 +434,7 @@ OBJS-$(CONFIG_HEVC_MEDIACODEC_ENCODER) += mediacodecenc.o
 OBJS-$(CONFIG_HEVC_MF_ENCODER)         += mfenc.o mf_utils.o
 OBJS-$(CONFIG_HEVC_NVENC_ENCODER)      += nvenc_hevc.o nvenc.o
 OBJS-$(CONFIG_HEVC_QSV_DECODER)        += qsvdec.o
-OBJS-$(CONFIG_HEVC_QSV_ENCODER)        += qsvenc_hevc.o hevc_ps_enc.o
+OBJS-$(CONFIG_HEVC_QSV_ENCODER)        += qsvenc_hevc.o hevc/ps_enc.o
 OBJS-$(CONFIG_HEVC_RKMPP_DECODER)      += rkmppdec.o
 OBJS-$(CONFIG_HEVC_VAAPI_ENCODER)      += vaapi_encode_h265.o h265_profile_level.o \
                                           h2645data.o
@@ -1199,7 +1192,6 @@ OBJS-$(CONFIG_GSM_PARSER)              += gsm_parser.o
 OBJS-$(CONFIG_H261_PARSER)             += h261_parser.o
 OBJS-$(CONFIG_H263_PARSER)             += h263_parser.o
 OBJS-$(CONFIG_H264_PARSER)             += h264_parser.o h264data.o
-OBJS-$(CONFIG_HEVC_PARSER)             += hevc_parser.o
 OBJS-$(CONFIG_HDR_PARSER)              += hdr_parser.o
 OBJS-$(CONFIG_IPU_PARSER)              += ipu_parser.o
 OBJS-$(CONFIG_JPEG2000_PARSER)         += jpeg2000_parser.o
diff --git a/libavcodec/aarch64/hevcdsp_init_aarch64.c b/libavcodec/aarch64/hevcdsp_init_aarch64.c
index e24dd0cbda..e8c911deb4 100644
--- a/libavcodec/aarch64/hevcdsp_init_aarch64.c
+++ b/libavcodec/aarch64/hevcdsp_init_aarch64.c
@@ -24,7 +24,7 @@
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
 #include "libavutil/aarch64/cpu.h"
-#include "libavcodec/hevcdsp.h"
+#include "libavcodec/hevc/dsp.h"
 
 void ff_hevc_v_loop_filter_chroma_8_neon(uint8_t *_pix, ptrdiff_t _stride,
                                          const int *_tc, const uint8_t *_no_p, const uint8_t *_no_q);
diff --git a/libavcodec/arm/hevcdsp_arm.h b/libavcodec/arm/hevcdsp_arm.h
index 47cdfa574d..de2303314c 100644
--- a/libavcodec/arm/hevcdsp_arm.h
+++ b/libavcodec/arm/hevcdsp_arm.h
@@ -19,7 +19,7 @@
 #ifndef AVCODEC_ARM_HEVCDSP_ARM_H
 #define AVCODEC_ARM_HEVCDSP_ARM_H
 
-#include "libavcodec/hevcdsp.h"
+#include "libavcodec/hevc/dsp.h"
 
 void ff_hevc_dsp_init_neon(HEVCDSPContext *c, const int bit_depth);
 
diff --git a/libavcodec/arm/hevcdsp_init_arm.c b/libavcodec/arm/hevcdsp_init_arm.c
index e8fa1f79ac..5e5da5ac6b 100644
--- a/libavcodec/arm/hevcdsp_init_arm.c
+++ b/libavcodec/arm/hevcdsp_init_arm.c
@@ -22,7 +22,7 @@
 #include "libavutil/cpu.h"
 #include "libavutil/arm/cpu.h"
 
-#include "libavcodec/hevcdsp.h"
+#include "libavcodec/hevc/dsp.h"
 #include "hevcdsp_arm.h"
 
 av_cold void ff_hevc_dsp_init_arm(HEVCDSPContext *c, const int bit_depth)
diff --git a/libavcodec/arm/hevcdsp_init_neon.c b/libavcodec/arm/hevcdsp_init_neon.c
index 1f26fc6454..6f113618c0 100644
--- a/libavcodec/arm/hevcdsp_init_neon.c
+++ b/libavcodec/arm/hevcdsp_init_neon.c
@@ -20,7 +20,7 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/arm/cpu.h"
-#include "libavcodec/hevcdsp.h"
+#include "libavcodec/hevc/dsp.h"
 #include "libavcodec/avcodec.h"
 #include "hevcdsp_arm.h"
 
diff --git a/libavcodec/bsf/extract_extradata.c b/libavcodec/bsf/extract_extradata.c
index c3c98c7d77..b037990562 100644
--- a/libavcodec/bsf/extract_extradata.c
+++ b/libavcodec/bsf/extract_extradata.c
@@ -29,11 +29,12 @@
 #include "bytestream.h"
 #include "h2645_parse.h"
 #include "h264.h"
-#include "hevc.h"
 #include "startcode.h"
 #include "vc1_common.h"
 #include "vvc.h"
 
+#include "hevc/hevc.h"
+
 typedef struct ExtractExtradataContext {
     const AVClass *class;
 
diff --git a/libavcodec/bsf/h265_metadata.c b/libavcodec/bsf/h265_metadata.c
index c9e1cc3eed..87bdac5f1e 100644
--- a/libavcodec/bsf/h265_metadata.c
+++ b/libavcodec/bsf/h265_metadata.c
@@ -25,9 +25,10 @@
 #include "cbs_bsf.h"
 #include "cbs_h265.h"
 #include "h2645data.h"
-#include "hevc.h"
 #include "h265_profile_level.h"
 
+#include "hevc/hevc.h"
+
 enum {
     LEVEL_UNSET = -2,
     LEVEL_AUTO  = -1,
diff --git a/libavcodec/bsf/hevc_mp4toannexb.c b/libavcodec/bsf/hevc_mp4toannexb.c
index 8eec18f31e..f281185769 100644
--- a/libavcodec/bsf/hevc_mp4toannexb.c
+++ b/libavcodec/bsf/hevc_mp4toannexb.c
@@ -28,7 +28,8 @@
 #include "bsf_internal.h"
 #include "bytestream.h"
 #include "defs.h"
-#include "hevc.h"
+
+#include "hevc/hevc.h"
 
 #define MIN_HEVCC_LENGTH 23
 
diff --git a/libavcodec/bsf/remove_extradata.c b/libavcodec/bsf/remove_extradata.c
index 3010eba058..b4a0359434 100644
--- a/libavcodec/bsf/remove_extradata.c
+++ b/libavcodec/bsf/remove_extradata.c
@@ -25,10 +25,11 @@
 #include "bsf.h"
 #include "bsf_internal.h"
 #include "h264.h"
-#include "hevc.h"
 #include "startcode.h"
 #include "vc1_common.h"
 
+#include "hevc/hevc.h"
+
 enum RemoveFreq {
     REMOVE_FREQ_KEYFRAME,
     REMOVE_FREQ_ALL,
diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index 1a45d424ba..c5f167334d 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -28,10 +28,10 @@
 #include "cbs_h266.h"
 #include "h264.h"
 #include "h2645_parse.h"
-#include "hevc.h"
 #include "refstruct.h"
 #include "vvc.h"
 
+#include "hevc/hevc.h"
 
 static int cbs_read_ue_golomb(CodedBitstreamContext *ctx, GetBitContext *gbc,
                               const char *name, const int *subscripts,
diff --git a/libavcodec/cbs_h265.h b/libavcodec/cbs_h265.h
index 1b1195f198..91a5a55317 100644
--- a/libavcodec/cbs_h265.h
+++ b/libavcodec/cbs_h265.h
@@ -24,7 +24,8 @@
 
 #include "cbs_h2645.h"
 #include "cbs_sei.h"
-#include "hevc.h"
+
+#include "hevc/hevc.h"
 
 typedef struct H265RawNALUnitHeader {
     uint8_t nal_unit_type;
diff --git a/libavcodec/d3d12va_hevc.c b/libavcodec/d3d12va_hevc.c
index a4964a05c6..c04a103f86 100644
--- a/libavcodec/d3d12va_hevc.c
+++ b/libavcodec/d3d12va_hevc.c
@@ -24,8 +24,8 @@
 
 #include "libavutil/avassert.h"
 #include "libavutil/hwcontext_d3d12va_internal.h"
-#include "hevc_data.h"
-#include "hevcdec.h"
+#include "hevc/data.h"
+#include "hevc/hevcdec.h"
 #include "dxva2_internal.h"
 #include "d3d12va_decode.h"
 #include <dxva.h>
diff --git a/libavcodec/dxva2_hevc.c b/libavcodec/dxva2_hevc.c
index 08b3b1e785..2f4073edd6 100644
--- a/libavcodec/dxva2_hevc.c
+++ b/libavcodec/dxva2_hevc.c
@@ -25,8 +25,8 @@
 #include "libavutil/avassert.h"
 
 #include "dxva2_internal.h"
-#include "hevc_data.h"
-#include "hevcdec.h"
+#include "hevc/data.h"
+#include "hevc/hevcdec.h"
 #include "hwaccel_internal.h"
 
 #define MAX_SLICES 256
diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c
index 9f66f079c2..2341f0e0a7 100644
--- a/libavcodec/h2645_parse.c
+++ b/libavcodec/h2645_parse.c
@@ -27,11 +27,12 @@
 #include "libavutil/mem.h"
 
 #include "bytestream.h"
-#include "hevc.h"
 #include "h264.h"
 #include "h2645_parse.h"
 #include "vvc.h"
 
+#include "hevc/hevc.h"
+
 int ff_h2645_extract_rbsp(const uint8_t *src, int length,
                           H2645RBSP *rbsp, H2645NAL *nal, int small_padding)
 {
diff --git a/libavcodec/hevc/Makefile b/libavcodec/hevc/Makefile
new file mode 100644
index 0000000000..9c385ef3da
--- /dev/null
+++ b/libavcodec/hevc/Makefile
@@ -0,0 +1,36 @@
+clean::
+	$(RM) $(CLEANSUFFIXES:%=libavcodec/hevc/%)
+
+OBJS-$(CONFIG_HEVC_DECODER) += \
+    aom_film_grain.o           \
+    h274.o                     \
+    hevc/cabac.o               \
+    hevc/data.o                \
+    hevc/dsp.o                 \
+    hevc/filter.o              \
+    hevc/hevcdec.o             \
+    hevc/mvs.o                 \
+    hevc/pred.o                \
+    hevc/refs.o                \
+
+OBJS-$(CONFIG_HEVC_PARSER) += \
+    hevc/parser.o             \
+
+
+OBJS-$(CONFIG_HEVCPARSE) += \
+    h2645data.o             \
+    h2645_parse.o           \
+    h2645_vui.o             \
+    hevc/data.o             \
+    hevc/parse.o            \
+    hevc/ps.o               \
+
+
+OBJS-$(CONFIG_HEVC_SEI) +=  \
+    hevc/sei.o              \
+    h2645_sei.o             \
+    dynamic_hdr_vivid.o     \
+    aom_film_grain.o        \
+
+
+libavcodec/hevc/%.o: CPPFLAGS += -I$(SRC_PATH)/libavcodec/
diff --git a/libavcodec/hevc_cabac.c b/libavcodec/hevc/cabac.c
similarity index 99%
rename from libavcodec/hevc_cabac.c
rename to libavcodec/hevc/cabac.c
index c9da4d7fc1..37f144758a 100644
--- a/libavcodec/hevc_cabac.c
+++ b/libavcodec/hevc/cabac.c
@@ -25,7 +25,7 @@
 #include "libavutil/common.h"
 
 #include "cabac_functions.h"
-#include "hevc_data.h"
+#include "data.h"
 #include "hevc.h"
 #include "hevcdec.h"
 
diff --git a/libavcodec/hevc_data.c b/libavcodec/hevc/data.c
similarity index 98%
rename from libavcodec/hevc_data.c
rename to libavcodec/hevc/data.c
index 1633a41c13..8a4f74c3cb 100644
--- a/libavcodec/hevc_data.c
+++ b/libavcodec/hevc/data.c
@@ -20,7 +20,7 @@
 
 #include <stdint.h>
 
-#include "hevc_data.h"
+#include "data.h"
 
 const uint8_t ff_hevc_diag_scan4x4_x[16] = {
     0, 0, 1, 0,
diff --git a/libavcodec/hevc_data.h b/libavcodec/hevc/data.h
similarity index 100%
rename from libavcodec/hevc_data.h
rename to libavcodec/hevc/data.h
diff --git a/libavcodec/hevcdsp.c b/libavcodec/hevc/dsp.c
similarity index 99%
rename from libavcodec/hevcdsp.c
rename to libavcodec/hevc/dsp.c
index 630fdc012e..60f059292c 100644
--- a/libavcodec/hevcdsp.c
+++ b/libavcodec/hevc/dsp.c
@@ -22,7 +22,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "hevcdsp.h"
+#include "dsp.h"
 
 static const int8_t transform[32][32] = {
     { 64,  64,  64,  64,  64,  64,  64,  64,  64,  64,  64,  64,  64,  64,  64,  64,
@@ -110,19 +110,19 @@ DECLARE_ALIGNED(16, const int8_t, ff_hevc_qpel_filters)[4][16] = {
 };
 
 #define BIT_DEPTH 8
-#include "hevcdsp_template.c"
+#include "dsp_template.c"
 #undef BIT_DEPTH
 
 #define BIT_DEPTH 9
-#include "hevcdsp_template.c"
+#include "dsp_template.c"
 #undef BIT_DEPTH
 
 #define BIT_DEPTH 10
-#include "hevcdsp_template.c"
+#include "dsp_template.c"
 #undef BIT_DEPTH
 
 #define BIT_DEPTH 12
-#include "hevcdsp_template.c"
+#include "dsp_template.c"
 #undef BIT_DEPTH
 
 void ff_hevc_dsp_init(HEVCDSPContext *hevcdsp, int bit_depth)
diff --git a/libavcodec/hevcdsp.h b/libavcodec/hevc/dsp.h
similarity index 98%
rename from libavcodec/hevcdsp.h
rename to libavcodec/hevc/dsp.h
index a5933dcac4..02b8e0e8e2 100644
--- a/libavcodec/hevcdsp.h
+++ b/libavcodec/hevc/dsp.h
@@ -22,12 +22,12 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#ifndef AVCODEC_HEVCDSP_H
-#define AVCODEC_HEVCDSP_H
+#ifndef AVCODEC_HEVC_DSP_H
+#define AVCODEC_HEVC_DSP_H
 
 #include "libavutil/mem_internal.h"
 
-#include "get_bits.h"
+#include "libavcodec/get_bits.h"
 
 #define MAX_PB_SIZE 64
 
@@ -137,4 +137,4 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth);
 void ff_hevc_dsp_init_mips(HEVCDSPContext *c, const int bit_depth);
 void ff_hevc_dsp_init_loongarch(HEVCDSPContext *c, const int bit_depth);
 
-#endif /* AVCODEC_HEVCDSP_H */
+#endif /* AVCODEC_HEVC_DSP_H */
diff --git a/libavcodec/hevcdsp_template.c b/libavcodec/hevc/dsp_template.c
similarity index 99%
rename from libavcodec/hevcdsp_template.c
rename to libavcodec/hevc/dsp_template.c
index 121c44c401..aebccd1a0c 100644
--- a/libavcodec/hevcdsp_template.c
+++ b/libavcodec/hevc/dsp_template.c
@@ -24,7 +24,7 @@
 #include "hevcdec.h"
 
 #include "bit_depth_template.c"
-#include "hevcdsp.h"
+#include "dsp.h"
 #include "h26x/h2656_sao_template.c"
 #include "h26x/h2656_inter_template.c"
 
diff --git a/libavcodec/hevc_filter.c b/libavcodec/hevc/filter.c
similarity index 100%
rename from libavcodec/hevc_filter.c
rename to libavcodec/hevc/filter.c
diff --git a/libavcodec/hevc.h b/libavcodec/hevc/hevc.h
similarity index 98%
rename from libavcodec/hevc.h
rename to libavcodec/hevc/hevc.h
index 6b454a75c1..9fdbc0a224 100644
--- a/libavcodec/hevc.h
+++ b/libavcodec/hevc/hevc.h
@@ -18,8 +18,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#ifndef AVCODEC_HEVC_H
-#define AVCODEC_HEVC_H
+#ifndef AVCODEC_HEVC_HEVC_H
+#define AVCODEC_HEVC_HEVC_H
 
 /**
  * Table 7-1 – NAL unit type codes and NAL unit type classes in
@@ -160,4 +160,4 @@ enum {
 };
 
 
-#endif /* AVCODEC_HEVC_H */
+#endif /* AVCODEC_HEVC_HEVC_H */
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevc/hevcdec.c
similarity index 99%
rename from libavcodec/hevcdec.c
rename to libavcodec/hevc/hevcdec.c
index 173810883d..4a07fa6612 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -43,7 +43,7 @@
 #include "decode.h"
 #include "golomb.h"
 #include "hevc.h"
-#include "hevc_parse.h"
+#include "parse.h"
 #include "hevcdec.h"
 #include "hwaccel_internal.h"
 #include "hwconfig.h"
diff --git a/libavcodec/hevcdec.h b/libavcodec/hevc/hevcdec.h
similarity index 97%
rename from libavcodec/hevcdec.h
rename to libavcodec/hevc/hevcdec.h
index 0cd6b8c2b4..8208268460 100644
--- a/libavcodec/hevcdec.h
+++ b/libavcodec/hevc/hevcdec.h
@@ -20,28 +20,29 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#ifndef AVCODEC_HEVCDEC_H
-#define AVCODEC_HEVCDEC_H
+#ifndef AVCODEC_HEVC_HEVCDEC_H
+#define AVCODEC_HEVC_HEVCDEC_H
 
 #include <stdatomic.h>
 
 #include "libavutil/buffer.h"
 #include "libavutil/mem_internal.h"
 
-#include "avcodec.h"
-#include "bswapdsp.h"
-#include "cabac.h"
-#include "dovi_rpu.h"
-#include "get_bits.h"
-#include "hevcpred.h"
-#include "h2645_parse.h"
+#include "libavcodec/avcodec.h"
+#include "libavcodec/bswapdsp.h"
+#include "libavcodec/cabac.h"
+#include "libavcodec/dovi_rpu.h"
+#include "libavcodec/get_bits.h"
+#include "libavcodec/h2645_parse.h"
+#include "libavcodec/h274.h"
+#include "libavcodec/progressframe.h"
+#include "libavcodec/videodsp.h"
+
+#include "dsp.h"
 #include "hevc.h"
-#include "hevc_ps.h"
-#include "hevc_sei.h"
-#include "hevcdsp.h"
-#include "h274.h"
-#include "progressframe.h"
-#include "videodsp.h"
+#include "pred.h"
+#include "ps.h"
+#include "sei.h"
 
 #define SHIFT_CTB_WPP 2
 
@@ -675,4 +676,4 @@ extern const uint8_t ff_hevc_qpel_extra_before[4];
 extern const uint8_t ff_hevc_qpel_extra_after[4];
 extern const uint8_t ff_hevc_qpel_extra[4];
 
-#endif /* AVCODEC_HEVCDEC_H */
+#endif /* AVCODEC_HEVC_HEVCDEC_H */
diff --git a/libavcodec/hevc_mvs.c b/libavcodec/hevc/mvs.c
similarity index 100%
rename from libavcodec/hevc_mvs.c
rename to libavcodec/hevc/mvs.c
diff --git a/libavcodec/hevc_parse.c b/libavcodec/hevc/parse.c
similarity index 99%
rename from libavcodec/hevc_parse.c
rename to libavcodec/hevc/parse.c
index 7bc28fd081..53b040d964 100644
--- a/libavcodec/hevc_parse.c
+++ b/libavcodec/hevc/parse.c
@@ -19,7 +19,7 @@
 #include "bytestream.h"
 #include "h2645_parse.h"
 #include "hevc.h"
-#include "hevc_parse.h"
+#include "parse.h"
 
 static int hevc_decode_nal_units(const uint8_t *buf, int buf_size, HEVCParamSets *ps,
                                  HEVCSEI *sei, int is_nalff, int nal_length_size,
diff --git a/libavcodec/hevc_parse.h b/libavcodec/hevc/parse.h
similarity index 96%
rename from libavcodec/hevc_parse.h
rename to libavcodec/hevc/parse.h
index 4ab96ab1cb..b3bcbde500 100644
--- a/libavcodec/hevc_parse.h
+++ b/libavcodec/hevc/parse.h
@@ -26,8 +26,8 @@
 
 #include <stdint.h>
 
-#include "hevc_ps.h"
-#include "hevc_sei.h"
+#include "ps.h"
+#include "sei.h"
 
 int ff_hevc_decode_extradata(const uint8_t *data, int size, HEVCParamSets *ps,
                              HEVCSEI *sei, int *is_nalff, int *nal_length_size,
diff --git a/libavcodec/hevc_parser.c b/libavcodec/hevc/parser.c
similarity index 99%
rename from libavcodec/hevc_parser.c
rename to libavcodec/hevc/parser.c
index 73fc5d6372..056e1b4aa4 100644
--- a/libavcodec/hevc_parser.c
+++ b/libavcodec/hevc/parser.c
@@ -25,9 +25,9 @@
 
 #include "golomb.h"
 #include "hevc.h"
-#include "hevc_parse.h"
-#include "hevc_ps.h"
-#include "hevc_sei.h"
+#include "parse.h"
+#include "ps.h"
+#include "sei.h"
 #include "h2645_parse.h"
 #include "parser.h"
 
diff --git a/libavcodec/hevcpred.c b/libavcodec/hevc/pred.c
similarity index 93%
rename from libavcodec/hevcpred.c
rename to libavcodec/hevc/pred.c
index 16b012f46c..8d588382fa 100644
--- a/libavcodec/hevcpred.c
+++ b/libavcodec/hevc/pred.c
@@ -22,22 +22,22 @@
 
 #include "hevcdec.h"
 
-#include "hevcpred.h"
+#include "pred.h"
 
 #define BIT_DEPTH 8
-#include "hevcpred_template.c"
+#include "pred_template.c"
 #undef BIT_DEPTH
 
 #define BIT_DEPTH 9
-#include "hevcpred_template.c"
+#include "pred_template.c"
 #undef BIT_DEPTH
 
 #define BIT_DEPTH 10
-#include "hevcpred_template.c"
+#include "pred_template.c"
 #undef BIT_DEPTH
 
 #define BIT_DEPTH 12
-#include "hevcpred_template.c"
+#include "pred_template.c"
 #undef BIT_DEPTH
 
 void ff_hevc_pred_init(HEVCPredContext *hpc, int bit_depth)
diff --git a/libavcodec/hevcpred.h b/libavcodec/hevc/pred.h
similarity index 94%
rename from libavcodec/hevcpred.h
rename to libavcodec/hevc/pred.h
index b1b1dc4f3a..b60d8176ae 100644
--- a/libavcodec/hevcpred.h
+++ b/libavcodec/hevc/pred.h
@@ -20,8 +20,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#ifndef AVCODEC_HEVCPRED_H
-#define AVCODEC_HEVCPRED_H
+#ifndef AVCODEC_HEVC_PRED_H
+#define AVCODEC_HEVC_PRED_H
 
 #include <stddef.h>
 #include <stdint.h>
@@ -43,4 +43,4 @@ typedef struct HEVCPredContext {
 void ff_hevc_pred_init(HEVCPredContext *hpc, int bit_depth);
 void ff_hevc_pred_init_mips(HEVCPredContext *hpc, int bit_depth);
 
-#endif /* AVCODEC_HEVCPRED_H */
+#endif /* AVCODEC_HEVC_PRED_H */
diff --git a/libavcodec/hevcpred_template.c b/libavcodec/hevc/pred_template.c
similarity index 99%
rename from libavcodec/hevcpred_template.c
rename to libavcodec/hevc/pred_template.c
index a1f8cf150e..fe9a22614a 100644
--- a/libavcodec/hevcpred_template.c
+++ b/libavcodec/hevc/pred_template.c
@@ -23,7 +23,7 @@
 #include "libavutil/pixdesc.h"
 
 #include "bit_depth_template.c"
-#include "hevcpred.h"
+#include "pred.h"
 
 #define POS(x, y) src[(x) + stride * (y)]
 
diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc/ps.c
similarity index 99%
rename from libavcodec/hevc_ps.c
rename to libavcodec/hevc/ps.c
index 7b486ce0af..03f18dcfee 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc/ps.c
@@ -27,8 +27,8 @@
 #include "libavutil/mem.h"
 #include "golomb.h"
 #include "h2645_vui.h"
-#include "hevc_data.h"
-#include "hevc_ps.h"
+#include "data.h"
+#include "ps.h"
 #include "refstruct.h"
 
 static const uint8_t default_scaling_list_intra[] = {
diff --git a/libavcodec/hevc_ps.h b/libavcodec/hevc/ps.h
similarity index 99%
rename from libavcodec/hevc_ps.h
rename to libavcodec/hevc/ps.h
index d06d7cf1d4..99d70cefd2 100644
--- a/libavcodec/hevc_ps.h
+++ b/libavcodec/hevc/ps.h
@@ -26,9 +26,10 @@
 #include "libavutil/pixfmt.h"
 #include "libavutil/rational.h"
 
-#include "avcodec.h"
-#include "get_bits.h"
-#include "h2645_vui.h"
+#include "libavcodec/avcodec.h"
+#include "libavcodec/get_bits.h"
+#include "libavcodec/h2645_vui.h"
+
 #include "hevc.h"
 
 typedef struct HEVCSublayerHdrParams {
diff --git a/libavcodec/hevc_ps_enc.c b/libavcodec/hevc/ps_enc.c
similarity index 99%
rename from libavcodec/hevc_ps_enc.c
rename to libavcodec/hevc/ps_enc.c
index 72641b2ffb..7fbcb3ba4e 100644
--- a/libavcodec/hevc_ps_enc.c
+++ b/libavcodec/hevc/ps_enc.c
@@ -19,7 +19,7 @@
  */
 
 #include "put_golomb.h"
-#include "hevc_ps.h"
+#include "ps.h"
 #include "put_bits.h"
 
 static void write_ptl_layer(PutBitContext *pb, PTLCommon *ptl)
diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc/refs.c
similarity index 100%
rename from libavcodec/hevc_refs.c
rename to libavcodec/hevc/refs.c
diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc/sei.c
similarity index 99%
rename from libavcodec/hevc_sei.c
rename to libavcodec/hevc/sei.c
index abdb52acd3..e39ac0c38a 100644
--- a/libavcodec/hevc_sei.c
+++ b/libavcodec/hevc/sei.c
@@ -24,8 +24,8 @@
 
 #include "bytestream.h"
 #include "golomb.h"
-#include "hevc_ps.h"
-#include "hevc_sei.h"
+#include "ps.h"
+#include "sei.h"
 
 static int decode_nal_sei_decoded_picture_hash(HEVCSEIPictureHash *s,
                                                GetByteContext *gb)
diff --git a/libavcodec/hevc_sei.h b/libavcodec/hevc/sei.h
similarity index 96%
rename from libavcodec/hevc_sei.h
rename to libavcodec/hevc/sei.h
index a23a64ec4f..c97d22d423 100644
--- a/libavcodec/hevc_sei.h
+++ b/libavcodec/hevc/sei.h
@@ -25,10 +25,11 @@
 
 #include "libavutil/buffer.h"
 
-#include "get_bits.h"
+#include "libavcodec/get_bits.h"
+#include "libavcodec/h2645_sei.h"
+#include "libavcodec/sei.h"
+
 #include "hevc.h"
-#include "h2645_sei.h"
-#include "sei.h"
 
 
 typedef enum {
diff --git a/libavcodec/loongarch/hevcdsp_lasx.h b/libavcodec/loongarch/hevcdsp_lasx.h
index 714cbf5880..907ee9f4bb 100644
--- a/libavcodec/loongarch/hevcdsp_lasx.h
+++ b/libavcodec/loongarch/hevcdsp_lasx.h
@@ -22,7 +22,7 @@
 #ifndef AVCODEC_LOONGARCH_HEVCDSP_LASX_H
 #define AVCODEC_LOONGARCH_HEVCDSP_LASX_H
 
-#include "libavcodec/hevcdsp.h"
+#include "libavcodec/hevc/dsp.h"
 
 #define PEL_UNI_W(PEL, DIR, WIDTH)                                       \
 void ff_hevc_put_hevc_##PEL##_uni_w_##DIR##WIDTH##_8_lasx(uint8_t *dst,  \
diff --git a/libavcodec/loongarch/hevcdsp_lsx.h b/libavcodec/loongarch/hevcdsp_lsx.h
index a5ef237b5d..cf2a519e94 100644
--- a/libavcodec/loongarch/hevcdsp_lsx.h
+++ b/libavcodec/loongarch/hevcdsp_lsx.h
@@ -23,7 +23,7 @@
 #ifndef AVCODEC_LOONGARCH_HEVCDSP_LSX_H
 #define AVCODEC_LOONGARCH_HEVCDSP_LSX_H
 
-#include "libavcodec/hevcdsp.h"
+#include "libavcodec/hevc/dsp.h"
 
 #define MC(PEL, DIR, WIDTH)                                               \
 void ff_hevc_put_hevc_##PEL##_##DIR##WIDTH##_8_lsx(int16_t *dst,          \
diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c
index df8d40dd10..6d8dc600fe 100644
--- a/libavcodec/mediacodecdec.c
+++ b/libavcodec/mediacodecdec.c
@@ -38,7 +38,7 @@
 #include "decode.h"
 #include "h264_parse.h"
 #include "h264_ps.h"
-#include "hevc_parse.h"
+#include "hevc/parse.h"
 #include "hwconfig.h"
 #include "internal.h"
 #include "jni.h"
diff --git a/libavcodec/mips/hevcdsp_mips.h b/libavcodec/mips/hevcdsp_mips.h
index a8f78ff73a..0498938028 100644
--- a/libavcodec/mips/hevcdsp_mips.h
+++ b/libavcodec/mips/hevcdsp_mips.h
@@ -21,7 +21,7 @@
 #ifndef AVCODEC_MIPS_HEVCDSP_MIPS_H
 #define AVCODEC_MIPS_HEVCDSP_MIPS_H
 
-#include "libavcodec/hevcdsp.h"
+#include "libavcodec/hevc/dsp.h"
 
 #define MC(PEL, DIR, WIDTH)                                                 \
 void ff_hevc_put_hevc_##PEL##_##DIR##WIDTH##_8_msa(int16_t *dst,            \
diff --git a/libavcodec/mips/hevcdsp_mmi.c b/libavcodec/mips/hevcdsp_mmi.c
index 7ece7b9be0..6ff52187e5 100644
--- a/libavcodec/mips/hevcdsp_mmi.c
+++ b/libavcodec/mips/hevcdsp_mmi.c
@@ -18,7 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavcodec/hevcdec.h"
+#include "libavcodec/hevc/hevcdec.h"
 #include "libavcodec/bit_depth_template.c"
 #include "libavcodec/mips/hevcdsp_mips.h"
 #include "libavutil/mips/mmiutils.h"
diff --git a/libavcodec/mips/hevcpred_mips.h b/libavcodec/mips/hevcpred_mips.h
index 6848700010..220ab307af 100644
--- a/libavcodec/mips/hevcpred_mips.h
+++ b/libavcodec/mips/hevcpred_mips.h
@@ -21,7 +21,7 @@
 #ifndef AVCODEC_MIPS_HEVCPRED_MIPS_H
 #define AVCODEC_MIPS_HEVCPRED_MIPS_H
 
-#include "libavcodec/hevcpred.h"
+#include "libavcodec/hevc/pred.h"
 
 void ff_hevc_intra_pred_planar_0_msa(uint8_t *dst,
                                      const uint8_t *src_top,
diff --git a/libavcodec/mips/hevcpred_msa.c b/libavcodec/mips/hevcpred_msa.c
index d9137519ad..a4c795a578 100644
--- a/libavcodec/mips/hevcpred_msa.c
+++ b/libavcodec/mips/hevcpred_msa.c
@@ -18,7 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavcodec/hevcdec.h"
+#include "libavcodec/hevc/dec.h"
 #include "libavutil/mips/generic_macros_msa.h"
 #include "hevcpred_mips.h"
 
diff --git a/libavcodec/nvdec_hevc.c b/libavcodec/nvdec_hevc.c
index 381f8da97e..1d23f2ab56 100644
--- a/libavcodec/nvdec_hevc.c
+++ b/libavcodec/nvdec_hevc.c
@@ -28,8 +28,8 @@
 #include "nvdec.h"
 #include "decode.h"
 #include "internal.h"
-#include "hevcdec.h"
-#include "hevc_data.h"
+#include "hevc/hevcdec.h"
+#include "hevc/data.h"
 #include "hwaccel_internal.h"
 
 static void dpb_add(CUVIDHEVCPICPARAMS *pp, int idx, const HEVCFrame *src)
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index e48224347d..a9945355ba 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -23,7 +23,7 @@
 #include "config_components.h"
 
 #include "nvenc.h"
-#include "hevc_sei.h"
+#include "hevc/sei.h"
 #if CONFIG_AV1_NVENC_ENCODER
 #include "av1.h"
 #endif
diff --git a/libavcodec/ppc/hevcdsp.c b/libavcodec/ppc/hevcdsp.c
index c1d562a409..7b032ef263 100644
--- a/libavcodec/ppc/hevcdsp.c
+++ b/libavcodec/ppc/hevcdsp.c
@@ -26,7 +26,7 @@
 #include "libavutil/ppc/cpu.h"
 #include "libavutil/ppc/util_altivec.h"
 
-#include "libavcodec/hevcdsp.h"
+#include "libavcodec/hevc/dsp.h"
 
 #if HAVE_ALTIVEC
 static const vec_s16 trans4[4] = {
diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c
index 40cff6335a..e6c038e67d 100644
--- a/libavcodec/qsvenc_hevc.c
+++ b/libavcodec/qsvenc_hevc.c
@@ -33,12 +33,13 @@
 #include "bytestream.h"
 #include "codec_internal.h"
 #include "get_bits.h"
-#include "hevc.h"
-#include "hevcdec.h"
 #include "h2645_parse.h"
 #include "qsv.h"
 #include "qsvenc.h"
 
+#include "hevc/hevc.h"
+#include "hevc/ps.h"
+
 enum LoadPlugin {
     LOAD_PLUGIN_NONE,
     LOAD_PLUGIN_HEVC_SW,
diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
index 2f59161346..c0dc3fca5f 100644
--- a/libavcodec/vaapi_encode_h265.c
+++ b/libavcodec/vaapi_encode_h265.c
@@ -35,9 +35,10 @@
 #include "codec_internal.h"
 #include "h2645data.h"
 #include "h265_profile_level.h"
-#include "hevc.h"
 #include "vaapi_encode.h"
 
+#include "hevc/hevc.h"
+
 enum {
     SEI_MASTERING_DISPLAY       = 0x08,
     SEI_CONTENT_LIGHT_LEVEL     = 0x10,
diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
index ae099a481c..051762bfef 100644
--- a/libavcodec/vaapi_hevc.c
+++ b/libavcodec/vaapi_hevc.c
@@ -24,12 +24,13 @@
 #include <va/va_dec_hevc.h>
 
 #include "avcodec.h"
-#include "hevcdec.h"
 #include "hwaccel_internal.h"
 #include "vaapi_decode.h"
 #include "vaapi_hevc.h"
 #include "h265_profile_level.h"
 
+#include "hevc/hevcdec.h"
+
 typedef struct VAAPIDecodePictureHEVC {
 #if VA_CHECK_VERSION(1, 2, 0)
     VAPictureParameterBufferHEVCExtension pic_param;
diff --git a/libavcodec/vdpau_hevc.c b/libavcodec/vdpau_hevc.c
index 0fec877570..f7cf1bd9c0 100644
--- a/libavcodec/vdpau_hevc.c
+++ b/libavcodec/vdpau_hevc.c
@@ -23,8 +23,8 @@
 #include <vdpau/vdpau.h>
 
 #include "avcodec.h"
-#include "hevc_data.h"
-#include "hevcdec.h"
+#include "hevc/data.h"
+#include "hevc/hevcdec.h"
 #include "hwaccel_internal.h"
 #include "vdpau.h"
 #include "vdpau_internal.h"
diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
index d6990a39c0..62dc2da89b 100644
--- a/libavcodec/videotoolbox.c
+++ b/libavcodec/videotoolbox.c
@@ -33,7 +33,7 @@
 #include "decode.h"
 #include "internal.h"
 #include "h264dec.h"
-#include "hevcdec.h"
+#include "hevc/hevcdec.h"
 #include "hwaccel_internal.h"
 #include "mpegvideo.h"
 #include "proresdec.h"
diff --git a/libavcodec/vulkan_hevc.c b/libavcodec/vulkan_hevc.c
index f994b94e7e..aa721493b0 100644
--- a/libavcodec/vulkan_hevc.c
+++ b/libavcodec/vulkan_hevc.c
@@ -17,9 +17,9 @@
  */
 
 #include "libavutil/mem.h"
-#include "hevcdec.h"
-#include "hevc_data.h"
-#include "hevc_ps.h"
+#include "hevc/hevcdec.h"
+#include "hevc/data.h"
+#include "hevc/ps.h"
 
 #include "vulkan_decode.h"
 
diff --git a/libavcodec/x86/hevcdsp_init.c b/libavcodec/x86/hevcdsp_init.c
index f5bc342cd5..2c0fca303e 100644
--- a/libavcodec/x86/hevcdsp_init.c
+++ b/libavcodec/x86/hevcdsp_init.c
@@ -26,7 +26,7 @@
 #include "libavutil/mem_internal.h"
 #include "libavutil/x86/asm.h"
 #include "libavutil/x86/cpu.h"
-#include "libavcodec/hevcdsp.h"
+#include "libavcodec/hevc/dsp.h"
 #include "libavcodec/x86/hevcdsp.h"
 #include "libavcodec/x86/h26x/h2656dsp.h"
 
diff --git a/libavformat/hevc.c b/libavformat/hevc.c
index 395907807f..8ab0155f63 100644
--- a/libavformat/hevc.c
+++ b/libavformat/hevc.c
@@ -20,7 +20,7 @@
 
 #include "libavcodec/get_bits.h"
 #include "libavcodec/golomb.h"
-#include "libavcodec/hevc.h"
+#include "libavcodec/hevc/hevc.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/mem.h"
 #include "avc.h"
diff --git a/libavformat/hevcdec.c b/libavformat/hevcdec.c
index 255f03bc48..4fc4068cd5 100644
--- a/libavformat/hevcdec.c
+++ b/libavformat/hevcdec.c
@@ -19,7 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavcodec/hevc.h"
+#include "libavcodec/hevc/hevc.h"
 
 #include "avformat.h"
 #include "rawdec.h"
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 45eca74d1d..160e9626d7 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -52,7 +52,7 @@
 #include "libavutil/uuid.h"
 #include "libavcodec/ac3tab.h"
 #include "libavcodec/flac.h"
-#include "libavcodec/hevc.h"
+#include "libavcodec/hevc/hevc.h"
 #include "libavcodec/mpegaudiodecheader.h"
 #include "libavcodec/mlp_parse.h"
 #include "avformat.h"
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 99ce3416f1..215783f324 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -32,7 +32,7 @@
 #include "libavcodec/bytestream.h"
 #include "libavcodec/defs.h"
 #include "libavcodec/h264.h"
-#include "libavcodec/hevc.h"
+#include "libavcodec/hevc/hevc.h"
 #include "libavcodec/vvc.h"
 #include "libavcodec/startcode.h"
 
diff --git a/tests/checkasm/hevc_add_res.c b/tests/checkasm/hevc_add_res.c
index 9dec3705c1..6388d5b12c 100644
--- a/tests/checkasm/hevc_add_res.c
+++ b/tests/checkasm/hevc_add_res.c
@@ -23,7 +23,7 @@
 #include "libavutil/intreadwrite.h"
 #include "libavutil/mem_internal.h"
 
-#include "libavcodec/hevcdsp.h"
+#include "libavcodec/hevc/dsp.h"
 
 #include "checkasm.h"
 
diff --git a/tests/checkasm/hevc_deblock.c b/tests/checkasm/hevc_deblock.c
index c7f4f7e9ab..89dd8a308b 100644
--- a/tests/checkasm/hevc_deblock.c
+++ b/tests/checkasm/hevc_deblock.c
@@ -22,7 +22,7 @@
 #include "libavutil/macros.h"
 #include "libavutil/mem_internal.h"
 
-#include "libavcodec/hevcdsp.h"
+#include "libavcodec/hevc/dsp.h"
 
 #include "checkasm.h"
 
diff --git a/tests/checkasm/hevc_idct.c b/tests/checkasm/hevc_idct.c
index 9da8b858a0..2bd7ae9409 100644
--- a/tests/checkasm/hevc_idct.c
+++ b/tests/checkasm/hevc_idct.c
@@ -23,7 +23,7 @@
 #include "libavutil/intreadwrite.h"
 #include "libavutil/mem_internal.h"
 
-#include "libavcodec/hevcdsp.h"
+#include "libavcodec/hevc/dsp.h"
 
 #include "checkasm.h"
 
diff --git a/tests/checkasm/hevc_pel.c b/tests/checkasm/hevc_pel.c
index aebdf104e6..d9fa56d420 100644
--- a/tests/checkasm/hevc_pel.c
+++ b/tests/checkasm/hevc_pel.c
@@ -21,7 +21,7 @@
 
 #include <string.h>
 #include "checkasm.h"
-#include "libavcodec/hevcdsp.h"
+#include "libavcodec/hevc/dsp.h"
 #include "libavutil/common.h"
 #include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"
diff --git a/tests/checkasm/hevc_sao.c b/tests/checkasm/hevc_sao.c
index 21c22b9749..ad47423f10 100644
--- a/tests/checkasm/hevc_sao.c
+++ b/tests/checkasm/hevc_sao.c
@@ -23,7 +23,7 @@
 #include "libavutil/intreadwrite.h"
 #include "libavutil/mem_internal.h"
 
-#include "libavcodec/hevcdsp.h"
+#include "libavcodec/hevc/dsp.h"
 
 #include "checkasm.h"
 
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [FFmpeg-devel] [PATCH 10/11] lavc/hevcdec: deduplicate calling hwaccel decode_params()
  2024-05-31 17:47 [FFmpeg-devel] [PATCH 01/11] lavc/hevcdec: move handling of byte alignment at the end of slice header Anton Khirnov
                   ` (7 preceding siblings ...)
  2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 09/11] lavc/hevc*: move to hevc/ subdir Anton Khirnov
@ 2024-05-31 17:47 ` Anton Khirnov
  2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 11/11] lavc/hevcdec: drop unused HEVCContext.width/height Anton Khirnov
  9 siblings, 0 replies; 14+ messages in thread
From: Anton Khirnov @ 2024-05-31 17:47 UTC (permalink / raw)
  To: ffmpeg-devel

---
 libavcodec/hevc/hevcdec.c | 36 ++++++++++++------------------------
 1 file changed, 12 insertions(+), 24 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 4a07fa6612..4e0df4d033 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -2985,49 +2985,37 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal)
     s->nal_unit_type = nal->type;
     s->temporal_id   = nal->temporal_id;
 
+    if (FF_HW_HAS_CB(s->avctx, decode_params) &&
+        (s->nal_unit_type == HEVC_NAL_VPS ||
+         s->nal_unit_type == HEVC_NAL_SPS ||
+         s->nal_unit_type == HEVC_NAL_PPS ||
+         s->nal_unit_type == HEVC_NAL_SEI_PREFIX ||
+         s->nal_unit_type == HEVC_NAL_SEI_SUFFIX)) {
+        ret = FF_HW_CALL(s->avctx, decode_params,
+                         nal->type, nal->raw_data, nal->raw_size);
+        if (ret < 0)
+            goto fail;
+    }
+
     switch (s->nal_unit_type) {
     case HEVC_NAL_VPS:
-        if (FF_HW_HAS_CB(s->avctx, decode_params)) {
-            ret = FF_HW_CALL(s->avctx, decode_params,
-                             nal->type, nal->raw_data, nal->raw_size);
-            if (ret < 0)
-                goto fail;
-        }
         ret = ff_hevc_decode_nal_vps(&gb, s->avctx, &s->ps);
         if (ret < 0)
             goto fail;
         break;
     case HEVC_NAL_SPS:
-        if (FF_HW_HAS_CB(s->avctx, decode_params)) {
-            ret = FF_HW_CALL(s->avctx, decode_params,
-                             nal->type, nal->raw_data, nal->raw_size);
-            if (ret < 0)
-                goto fail;
-        }
         ret = ff_hevc_decode_nal_sps(&gb, s->avctx, &s->ps,
                                      s->apply_defdispwin);
         if (ret < 0)
             goto fail;
         break;
     case HEVC_NAL_PPS:
-        if (FF_HW_HAS_CB(s->avctx, decode_params)) {
-            ret = FF_HW_CALL(s->avctx, decode_params,
-                             nal->type, nal->raw_data, nal->raw_size);
-            if (ret < 0)
-                goto fail;
-        }
         ret = ff_hevc_decode_nal_pps(&gb, s->avctx, &s->ps);
         if (ret < 0)
             goto fail;
         break;
     case HEVC_NAL_SEI_PREFIX:
     case HEVC_NAL_SEI_SUFFIX:
-        if (FF_HW_HAS_CB(s->avctx, decode_params)) {
-            ret = FF_HW_CALL(s->avctx, decode_params,
-                             nal->type, nal->raw_data, nal->raw_size);
-            if (ret < 0)
-                goto fail;
-        }
         ret = ff_hevc_decode_nal_sei(&gb, s->avctx, &s->sei, &s->ps, s->nal_unit_type);
         if (ret < 0)
             goto fail;
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [FFmpeg-devel] [PATCH 11/11] lavc/hevcdec: drop unused HEVCContext.width/height
  2024-05-31 17:47 [FFmpeg-devel] [PATCH 01/11] lavc/hevcdec: move handling of byte alignment at the end of slice header Anton Khirnov
                   ` (8 preceding siblings ...)
  2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 10/11] lavc/hevcdec: deduplicate calling hwaccel decode_params() Anton Khirnov
@ 2024-05-31 17:47 ` Anton Khirnov
  2024-05-31 19:11   ` Vittorio Giovara
  9 siblings, 1 reply; 14+ messages in thread
From: Anton Khirnov @ 2024-05-31 17:47 UTC (permalink / raw)
  To: ffmpeg-devel

---
 libavcodec/hevc/hevcdec.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.h b/libavcodec/hevc/hevcdec.h
index 8208268460..33ad4ac0aa 100644
--- a/libavcodec/hevc/hevcdec.h
+++ b/libavcodec/hevc/hevcdec.h
@@ -456,9 +456,6 @@ typedef struct HEVCContext {
     uint8_t             threads_type;
     uint8_t             threads_number;
 
-    int                 width;
-    int                 height;
-
     /** 1 if the independent slice segment header was successfully parsed */
     uint8_t slice_initialized;
 
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [FFmpeg-devel] [PATCH 11/11] lavc/hevcdec: drop unused HEVCContext.width/height
  2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 11/11] lavc/hevcdec: drop unused HEVCContext.width/height Anton Khirnov
@ 2024-05-31 19:11   ` Vittorio Giovara
  0 siblings, 0 replies; 14+ messages in thread
From: Vittorio Giovara @ 2024-05-31 19:11 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Fri, May 31, 2024 at 7:49 PM Anton Khirnov <anton@khirnov.net> wrote:

> ---
>  libavcodec/hevc/hevcdec.h | 3 ---
>  1 file changed, 3 deletions(-)
>
> diff --git a/libavcodec/hevc/hevcdec.h b/libavcodec/hevc/hevcdec.h
> index 8208268460..33ad4ac0aa 100644
> --- a/libavcodec/hevc/hevcdec.h
> +++ b/libavcodec/hevc/hevcdec.h
> @@ -456,9 +456,6 @@ typedef struct HEVCContext {
>      uint8_t             threads_type;
>      uint8_t             threads_number;
>
> -    int                 width;
> -    int                 height;
> -
>      /** 1 if the independent slice segment header was successfully parsed
> */
>      uint8_t slice_initialized;
>

Set looks mostly harmless, so lgtm
-- 
Vittorio
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [FFmpeg-devel] [PATCH 09/11] lavc/hevc*: move to hevc/ subdir
  2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 09/11] lavc/hevc*: move to hevc/ subdir Anton Khirnov
@ 2024-06-02  0:39   ` James Almer
  2024-06-02  6:50     ` Anton Khirnov
  0 siblings, 1 reply; 14+ messages in thread
From: James Almer @ 2024-06-02  0:39 UTC (permalink / raw)
  To: ffmpeg-devel

On 5/31/2024 2:47 PM, Anton Khirnov wrote:
> ---
>   libavcodec/Makefile                           | 12 ++-----
>   libavcodec/aarch64/hevcdsp_init_aarch64.c     |  2 +-
>   libavcodec/arm/hevcdsp_arm.h                  |  2 +-
>   libavcodec/arm/hevcdsp_init_arm.c             |  2 +-
>   libavcodec/arm/hevcdsp_init_neon.c            |  2 +-
>   libavcodec/bsf/extract_extradata.c            |  3 +-
>   libavcodec/bsf/h265_metadata.c                |  3 +-
>   libavcodec/bsf/hevc_mp4toannexb.c             |  3 +-
>   libavcodec/bsf/remove_extradata.c             |  3 +-
>   libavcodec/cbs_h2645.c                        |  2 +-
>   libavcodec/cbs_h265.h                         |  3 +-
>   libavcodec/d3d12va_hevc.c                     |  4 +--
>   libavcodec/dxva2_hevc.c                       |  4 +--
>   libavcodec/h2645_parse.c                      |  3 +-
>   libavcodec/hevc/Makefile                      | 36 +++++++++++++++++++
>   libavcodec/{hevc_cabac.c => hevc/cabac.c}     |  2 +-
>   libavcodec/{hevc_data.c => hevc/data.c}       |  2 +-
>   libavcodec/{hevc_data.h => hevc/data.h}       |  0
>   libavcodec/{hevcdsp.c => hevc/dsp.c}          | 10 +++---
>   libavcodec/{hevcdsp.h => hevc/dsp.h}          |  8 ++---
>   .../dsp_template.c}                           |  2 +-
>   libavcodec/{hevc_filter.c => hevc/filter.c}   |  0
>   libavcodec/{ => hevc}/hevc.h                  |  6 ++--
>   libavcodec/{ => hevc}/hevcdec.c               |  2 +-
>   libavcodec/{ => hevc}/hevcdec.h               | 33 ++++++++---------
>   libavcodec/{hevc_mvs.c => hevc/mvs.c}         |  0
>   libavcodec/{hevc_parse.c => hevc/parse.c}     |  2 +-
>   libavcodec/{hevc_parse.h => hevc/parse.h}     |  4 +--
>   libavcodec/{hevc_parser.c => hevc/parser.c}   |  6 ++--
>   libavcodec/{hevcpred.c => hevc/pred.c}        | 10 +++---
>   libavcodec/{hevcpred.h => hevc/pred.h}        |  6 ++--
>   .../pred_template.c}                          |  2 +-
>   libavcodec/{hevc_ps.c => hevc/ps.c}           |  4 +--
>   libavcodec/{hevc_ps.h => hevc/ps.h}           |  7 ++--
>   libavcodec/{hevc_ps_enc.c => hevc/ps_enc.c}   |  2 +-
>   libavcodec/{hevc_refs.c => hevc/refs.c}       |  0
>   libavcodec/{hevc_sei.c => hevc/sei.c}         |  4 +--
>   libavcodec/{hevc_sei.h => hevc/sei.h}         |  7 ++--
>   libavcodec/loongarch/hevcdsp_lasx.h           |  2 +-
>   libavcodec/loongarch/hevcdsp_lsx.h            |  2 +-
>   libavcodec/mediacodecdec.c                    |  2 +-
>   libavcodec/mips/hevcdsp_mips.h                |  2 +-
>   libavcodec/mips/hevcdsp_mmi.c                 |  2 +-
>   libavcodec/mips/hevcpred_mips.h               |  2 +-
>   libavcodec/mips/hevcpred_msa.c                |  2 +-
>   libavcodec/nvdec_hevc.c                       |  4 +--
>   libavcodec/nvenc.c                            |  2 +-
>   libavcodec/ppc/hevcdsp.c                      |  2 +-
>   libavcodec/qsvenc_hevc.c                      |  5 +--
>   libavcodec/vaapi_encode_h265.c                |  3 +-
>   libavcodec/vaapi_hevc.c                       |  3 +-
>   libavcodec/vdpau_hevc.c                       |  4 +--
>   libavcodec/videotoolbox.c                     |  2 +-
>   libavcodec/vulkan_hevc.c                      |  6 ++--
>   libavcodec/x86/hevcdsp_init.c                 |  2 +-
>   libavformat/hevc.c                            |  2 +-
>   libavformat/hevcdec.c                         |  2 +-
>   libavformat/mov.c                             |  2 +-
>   libavformat/mpegtsenc.c                       |  2 +-
>   tests/checkasm/hevc_add_res.c                 |  2 +-
>   tests/checkasm/hevc_deblock.c                 |  2 +-
>   tests/checkasm/hevc_idct.c                    |  2 +-
>   tests/checkasm/hevc_pel.c                     |  2 +-
>   tests/checkasm/hevc_sao.c                     |  2 +-
>   64 files changed, 154 insertions(+), 114 deletions(-)
>   create mode 100644 libavcodec/hevc/Makefile
>   rename libavcodec/{hevc_cabac.c => hevc/cabac.c} (99%)
>   rename libavcodec/{hevc_data.c => hevc/data.c} (98%)
>   rename libavcodec/{hevc_data.h => hevc/data.h} (100%)
>   rename libavcodec/{hevcdsp.c => hevc/dsp.c} (99%)
>   rename libavcodec/{hevcdsp.h => hevc/dsp.h} (98%)
>   rename libavcodec/{hevcdsp_template.c => hevc/dsp_template.c} (99%)
>   rename libavcodec/{hevc_filter.c => hevc/filter.c} (100%)
>   rename libavcodec/{ => hevc}/hevc.h (98%)
>   rename libavcodec/{ => hevc}/hevcdec.c (99%)
>   rename libavcodec/{ => hevc}/hevcdec.h (97%)
>   rename libavcodec/{hevc_mvs.c => hevc/mvs.c} (100%)
>   rename libavcodec/{hevc_parse.c => hevc/parse.c} (99%)
>   rename libavcodec/{hevc_parse.h => hevc/parse.h} (96%)
>   rename libavcodec/{hevc_parser.c => hevc/parser.c} (99%)
>   rename libavcodec/{hevcpred.c => hevc/pred.c} (93%)
>   rename libavcodec/{hevcpred.h => hevc/pred.h} (94%)
>   rename libavcodec/{hevcpred_template.c => hevc/pred_template.c} (99%)
>   rename libavcodec/{hevc_ps.c => hevc/ps.c} (99%)
>   rename libavcodec/{hevc_ps.h => hevc/ps.h} (99%)
>   rename libavcodec/{hevc_ps_enc.c => hevc/ps_enc.c} (99%)
>   rename libavcodec/{hevc_refs.c => hevc/refs.c} (100%)
>   rename libavcodec/{hevc_sei.c => hevc/sei.c} (99%)
>   rename libavcodec/{hevc_sei.h => hevc/sei.h} (96%)

To be in line with vvc, you'd also need to move the x86/ files to their 
own hevc folder.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [FFmpeg-devel] [PATCH 09/11] lavc/hevc*: move to hevc/ subdir
  2024-06-02  0:39   ` James Almer
@ 2024-06-02  6:50     ` Anton Khirnov
  0 siblings, 0 replies; 14+ messages in thread
From: Anton Khirnov @ 2024-06-02  6:50 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Quoting James Almer (2024-06-02 02:39:36)
> To be in line with vvc, you'd also need to move the x86/ files to their 
> own hevc folder.

I considered that, but the patch already seemed big enough and I didn't
want to risk even more arch-specific breakage and/or bikeshedding. So
I'd rather leave this for later.

-- 
Anton Khirnov
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2024-06-02  6:50 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-31 17:47 [FFmpeg-devel] [PATCH 01/11] lavc/hevcdec: move handling of byte alignment at the end of slice header Anton Khirnov
2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 02/11] lavc/hevcdec: drop a useless condition Anton Khirnov
2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 03/11] lavc/hevcdec: include first row in SliceHeader.offset/size Anton Khirnov
2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 04/11] lavc/hevcdec: drop HEVCLocalContext.gb Anton Khirnov
2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 05/11] lavc/hevcdec: drop HEVCContext.HEVClc Anton Khirnov
2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 06/11] lavc/hevcdec: rename HEVCContext.ref to cur_frame Anton Khirnov
2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 07/11] lavc/hevcdec: rename HEVCFrame.frame to just f Anton Khirnov
2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 08/11] lavc/hevcdec: drop HEVCContext.frame Anton Khirnov
2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 09/11] lavc/hevc*: move to hevc/ subdir Anton Khirnov
2024-06-02  0:39   ` James Almer
2024-06-02  6:50     ` Anton Khirnov
2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 10/11] lavc/hevcdec: deduplicate calling hwaccel decode_params() Anton Khirnov
2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 11/11] lavc/hevcdec: drop unused HEVCContext.width/height Anton Khirnov
2024-05-31 19:11   ` Vittorio Giovara

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git