Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Subject: [FFmpeg-devel] [PATCH 05/42] avcodec/hevc_ps: Use RefStruct API for parameter sets
Date: Tue, 19 Sep 2023 21:56:57 +0200
Message-ID: <AS8P250MB07449E3C118B5A518C36A8FE8FFAA@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <AS8P250MB074487CAD933FE4F6325C8EB8FFAA@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM>

Avoids allocations and error checks for these allocations;
e.g. syncing buffers across threads can't fail any more
and needn't be checked. It also gets rid of casts and
indirections.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/hevc_parser.c   |  8 ++--
 libavcodec/hevc_ps.c       | 80 ++++++++++++++++----------------------
 libavcodec/hevc_ps.h       | 10 ++---
 libavcodec/hevc_sei.c      |  5 +--
 libavcodec/hevcdec.c       | 36 +++++++----------
 libavcodec/mediacodecdec.c |  6 +--
 libavcodec/videotoolbox.c  |  4 +-
 libavcodec/vulkan_hevc.c   | 16 ++++----
 8 files changed, 72 insertions(+), 93 deletions(-)

diff --git a/libavcodec/hevc_parser.c b/libavcodec/hevc_parser.c
index 59f9a0ff3e..87270cffb4 100644
--- a/libavcodec/hevc_parser.c
+++ b/libavcodec/hevc_parser.c
@@ -77,15 +77,15 @@ static int hevc_parse_slice_header(AVCodecParserContext *s, H2645NAL *nal,
         av_log(avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", pps_id);
         return AVERROR_INVALIDDATA;
     }
-    ps->pps = (HEVCPPS*)ps->pps_list[pps_id]->data;
+    ps->pps = ps->pps_list[pps_id];
 
     if (ps->pps->sps_id >= HEVC_MAX_SPS_COUNT || !ps->sps_list[ps->pps->sps_id]) {
         av_log(avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", ps->pps->sps_id);
         return AVERROR_INVALIDDATA;
     }
-    if (ps->sps != (HEVCSPS*)ps->sps_list[ps->pps->sps_id]->data) {
-        ps->sps = (HEVCSPS*)ps->sps_list[ps->pps->sps_id]->data;
-        ps->vps = (HEVCVPS*)ps->vps_list[ps->sps->vps_id]->data;
+    if (ps->sps != ps->sps_list[ps->pps->sps_id]) {
+        ps->sps  = ps->sps_list[ps->pps->sps_id];
+        ps->vps  = ps->vps_list[ps->sps->vps_id];
     }
     ow  = &ps->sps->output_window;
 
diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 7507d2bf9c..a6b64b92e3 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -28,6 +28,7 @@
 #include "h2645_vui.h"
 #include "hevc_data.h"
 #include "hevc_ps.h"
+#include "refstruct.h"
 
 static const uint8_t default_scaling_list_intra[] = {
     16, 16, 16, 16, 17, 18, 21, 24,
@@ -61,40 +62,40 @@ static const uint8_t hevc_sub_height_c[] = {
 
 static void remove_pps(HEVCParamSets *s, int id)
 {
-    if (s->pps_list[id] && s->pps == (const HEVCPPS*)s->pps_list[id]->data)
+    if (s->pps == s->pps_list[id])
         s->pps = NULL;
-    av_buffer_unref(&s->pps_list[id]);
+    ff_refstruct_unref(&s->pps_list[id]);
 }
 
 static void remove_sps(HEVCParamSets *s, int id)
 {
     int i;
     if (s->sps_list[id]) {
-        if (s->sps == (const HEVCSPS*)s->sps_list[id]->data)
+        if (s->sps == s->sps_list[id])
             s->sps = NULL;
 
         /* drop all PPS that depend on this SPS */
         for (i = 0; i < FF_ARRAY_ELEMS(s->pps_list); i++)
-            if (s->pps_list[i] && ((HEVCPPS*)s->pps_list[i]->data)->sps_id == id)
+            if (s->pps_list[i] && s->pps_list[i]->sps_id == id)
                 remove_pps(s, i);
 
-        av_assert0(!(s->sps_list[id] && s->sps == (HEVCSPS*)s->sps_list[id]->data));
+        av_assert0(!(s->sps_list[id] && s->sps == s->sps_list[id]));
+        ff_refstruct_unref(&s->sps_list[id]);
     }
-    av_buffer_unref(&s->sps_list[id]);
 }
 
 static void remove_vps(HEVCParamSets *s, int id)
 {
     int i;
     if (s->vps_list[id]) {
-        if (s->vps == (const HEVCVPS*)s->vps_list[id]->data)
+        if (s->vps == s->vps_list[id])
             s->vps = NULL;
 
         for (i = 0; i < FF_ARRAY_ELEMS(s->sps_list); i++)
-            if (s->sps_list[i] && ((HEVCSPS*)s->sps_list[i]->data)->vps_id == id)
+            if (s->sps_list[i] && s->sps_list[i]->vps_id == id)
                 remove_sps(s, i);
+        ff_refstruct_unref(&s->vps_list[id]);
     }
-    av_buffer_unref(&s->vps_list[id]);
 }
 
 int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx,
@@ -442,12 +443,10 @@ int ff_hevc_decode_nal_vps(GetBitContext *gb, AVCodecContext *avctx,
     int i,j;
     int vps_id = 0;
     ptrdiff_t nal_size;
-    HEVCVPS *vps;
-    AVBufferRef *vps_buf = av_buffer_allocz(sizeof(*vps));
+    HEVCVPS *vps = ff_refstruct_allocz(sizeof(*vps));
 
-    if (!vps_buf)
+    if (!vps)
         return AVERROR(ENOMEM);
-    vps = (HEVCVPS*)vps_buf->data;
 
     av_log(avctx, AV_LOG_DEBUG, "Decoding VPS\n");
 
@@ -553,17 +552,17 @@ int ff_hevc_decode_nal_vps(GetBitContext *gb, AVCodecContext *avctx,
     }
 
     if (ps->vps_list[vps_id] &&
-        !memcmp(ps->vps_list[vps_id]->data, vps_buf->data, vps_buf->size)) {
-        av_buffer_unref(&vps_buf);
+        !memcmp(ps->vps_list[vps_id], vps, sizeof(*vps))) {
+        ff_refstruct_unref(&vps);
     } else {
         remove_vps(ps, vps_id);
-        ps->vps_list[vps_id] = vps_buf;
+        ps->vps_list[vps_id] = vps;
     }
 
     return 0;
 
 err:
-    av_buffer_unref(&vps_buf);
+    ff_refstruct_unref(&vps);
     return AVERROR_INVALIDDATA;
 }
 
@@ -851,7 +850,8 @@ static int map_pixel_format(AVCodecContext *avctx, HEVCSPS *sps)
 }
 
 int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id,
-                      int apply_defdispwin, AVBufferRef **vps_list, AVCodecContext *avctx)
+                      int apply_defdispwin, const HEVCVPS * const *vps_list,
+                      AVCodecContext *avctx)
 {
     HEVCWindow *ow;
     int ret = 0;
@@ -1269,15 +1269,13 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id,
 int ff_hevc_decode_nal_sps(GetBitContext *gb, AVCodecContext *avctx,
                            HEVCParamSets *ps, int apply_defdispwin)
 {
-    HEVCSPS *sps;
-    AVBufferRef *sps_buf = av_buffer_allocz(sizeof(*sps));
+    HEVCSPS *sps = ff_refstruct_allocz(sizeof(*sps));
     unsigned int sps_id;
     int ret;
     ptrdiff_t nal_size;
 
-    if (!sps_buf)
+    if (!sps)
         return AVERROR(ENOMEM);
-    sps = (HEVCSPS*)sps_buf->data;
 
     av_log(avctx, AV_LOG_DEBUG, "Decoding SPS\n");
 
@@ -1296,7 +1294,7 @@ int ff_hevc_decode_nal_sps(GetBitContext *gb, AVCodecContext *avctx,
                             apply_defdispwin,
                             ps->vps_list, avctx);
     if (ret < 0) {
-        av_buffer_unref(&sps_buf);
+        ff_refstruct_unref(&sps);
         return ret;
     }
 
@@ -1314,19 +1312,19 @@ int ff_hevc_decode_nal_sps(GetBitContext *gb, AVCodecContext *avctx,
      * original one.
      * otherwise drop all PPSes that depend on it */
     if (ps->sps_list[sps_id] &&
-        !memcmp(ps->sps_list[sps_id]->data, sps_buf->data, sps_buf->size)) {
-        av_buffer_unref(&sps_buf);
+        !memcmp(ps->sps_list[sps_id], sps, sizeof(*sps))) {
+        ff_refstruct_unref(&sps);
     } else {
         remove_sps(ps, sps_id);
-        ps->sps_list[sps_id] = sps_buf;
+        ps->sps_list[sps_id] = sps;
     }
 
     return 0;
 }
 
-static void hevc_pps_free(void *opaque, uint8_t *data)
+static void hevc_pps_free(FFRefStructOpaque unused, void *obj)
 {
-    HEVCPPS *pps = (HEVCPPS*)data;
+    HEVCPPS *pps = obj;
 
     av_freep(&pps->column_width);
     av_freep(&pps->row_height);
@@ -1338,8 +1336,6 @@ static void hevc_pps_free(void *opaque, uint8_t *data)
     av_freep(&pps->tile_pos_rs);
     av_freep(&pps->tile_id);
     av_freep(&pps->min_tb_addr_zs_tab);
-
-    av_freep(&pps);
 }
 
 static void colour_mapping_octants(GetBitContext *gb, HEVCPPS *pps, int inp_depth,
@@ -1742,19 +1738,11 @@ int ff_hevc_decode_nal_pps(GetBitContext *gb, AVCodecContext *avctx,
     ptrdiff_t nal_size;
     unsigned log2_parallel_merge_level_minus2;
 
-    AVBufferRef *pps_buf;
-    HEVCPPS *pps = av_mallocz(sizeof(*pps));
+    HEVCPPS *pps = ff_refstruct_alloc_ext(sizeof(*pps), 0, NULL, hevc_pps_free);
 
     if (!pps)
         return AVERROR(ENOMEM);
 
-    pps_buf = av_buffer_create((uint8_t *)pps, sizeof(*pps),
-                               hevc_pps_free, NULL, 0);
-    if (!pps_buf) {
-        av_freep(&pps);
-        return AVERROR(ENOMEM);
-    }
-
     av_log(avctx, AV_LOG_DEBUG, "Decoding PPS\n");
 
     nal_size = gb->buffer_end - gb->buffer;
@@ -1796,8 +1784,8 @@ int ff_hevc_decode_nal_pps(GetBitContext *gb, AVCodecContext *avctx,
         ret = AVERROR_INVALIDDATA;
         goto err;
     }
-    sps = (HEVCSPS *)ps->sps_list[pps->sps_id]->data;
-    vps = (HEVCVPS *)ps->vps_list[sps->vps_id]->data;
+    sps = ps->sps_list[pps->sps_id];
+    vps = ps->vps_list[sps->vps_id];
 
     pps->dependent_slice_segments_enabled_flag = get_bits1(gb);
     pps->output_flag_present_flag              = get_bits1(gb);
@@ -1998,12 +1986,12 @@ int ff_hevc_decode_nal_pps(GetBitContext *gb, AVCodecContext *avctx,
     }
 
     remove_pps(ps, pps_id);
-    ps->pps_list[pps_id] = pps_buf;
+    ps->pps_list[pps_id] = pps;
 
     return 0;
 
 err:
-    av_buffer_unref(&pps_buf);
+    ff_refstruct_unref(&pps);
     return ret;
 }
 
@@ -2012,11 +2000,11 @@ void ff_hevc_ps_uninit(HEVCParamSets *ps)
     int i;
 
     for (i = 0; i < FF_ARRAY_ELEMS(ps->vps_list); i++)
-        av_buffer_unref(&ps->vps_list[i]);
+        ff_refstruct_unref(&ps->vps_list[i]);
     for (i = 0; i < FF_ARRAY_ELEMS(ps->sps_list); i++)
-        av_buffer_unref(&ps->sps_list[i]);
+        ff_refstruct_unref(&ps->sps_list[i]);
     for (i = 0; i < FF_ARRAY_ELEMS(ps->pps_list); i++)
-        av_buffer_unref(&ps->pps_list[i]);
+        ff_refstruct_unref(&ps->pps_list[i]);
 
     ps->sps = NULL;
     ps->pps = NULL;
diff --git a/libavcodec/hevc_ps.h b/libavcodec/hevc_ps.h
index ef11e51ee7..786c896709 100644
--- a/libavcodec/hevc_ps.h
+++ b/libavcodec/hevc_ps.h
@@ -23,7 +23,6 @@
 
 #include <stdint.h>
 
-#include "libavutil/buffer.h"
 #include "libavutil/pixfmt.h"
 #include "libavutil/rational.h"
 
@@ -437,9 +436,9 @@ typedef struct HEVCPPS {
 } HEVCPPS;
 
 typedef struct HEVCParamSets {
-    AVBufferRef *vps_list[HEVC_MAX_VPS_COUNT];
-    AVBufferRef *sps_list[HEVC_MAX_SPS_COUNT];
-    AVBufferRef *pps_list[HEVC_MAX_PPS_COUNT];
+    const HEVCVPS *vps_list[HEVC_MAX_VPS_COUNT]; ///< RefStruct references
+    const HEVCSPS *sps_list[HEVC_MAX_SPS_COUNT]; ///< RefStruct references
+    const HEVCPPS *pps_list[HEVC_MAX_PPS_COUNT]; ///< RefStruct references
 
     /* currently active parameter sets */
     const HEVCVPS *vps;
@@ -457,7 +456,8 @@ typedef struct HEVCParamSets {
  *                 to an existing VPS
  */
 int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id,
-                      int apply_defdispwin, AVBufferRef **vps_list, AVCodecContext *avctx);
+                      int apply_defdispwin, const HEVCVPS * const *vps_list,
+                      AVCodecContext *avctx);
 
 int ff_hevc_decode_nal_vps(GetBitContext *gb, AVCodecContext *avctx,
                            HEVCParamSets *ps);
diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c
index 351e699726..abdb52acd3 100644
--- a/libavcodec/hevc_sei.c
+++ b/libavcodec/hevc_sei.c
@@ -53,11 +53,10 @@ static int decode_nal_sei_pic_timing(HEVCSEI *s, GetBitContext *gb,
                                      const HEVCParamSets *ps, void *logctx)
 {
     HEVCSEIPictureTiming *h = &s->picture_timing;
-    HEVCSPS *sps;
+    const HEVCSPS *sps = ps->sps_list[s->active_seq_parameter_set_id];
 
-    if (!ps->sps_list[s->active_seq_parameter_set_id])
+    if (!sps)
         return(AVERROR(ENOMEM));
-    sps = (HEVCSPS*)ps->sps_list[s->active_seq_parameter_set_id]->data;
 
     if (sps->vui.frame_field_info_present_flag) {
         int pic_struct = get_bits(gb, 4);
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 81b9c5e089..d64055e1f9 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -50,6 +50,7 @@
 #include "hwconfig.h"
 #include "internal.h"
 #include "profiles.h"
+#include "refstruct.h"
 #include "thread.h"
 #include "threadframe.h"
 
@@ -326,7 +327,7 @@ static void export_stream_params(HEVCContext *s, const HEVCSPS *sps)
 {
     AVCodecContext *avctx = s->avctx;
     const HEVCParamSets *ps = &s->ps;
-    const HEVCVPS *vps = (const HEVCVPS*)ps->vps_list[sps->vps_id]->data;
+    const HEVCVPS *vps = ps->vps_list[sps->vps_id];
     const HEVCWindow *ow = &sps->output_window;
     unsigned int num = 0, den = 0;
 
@@ -573,7 +574,7 @@ static int set_sps(HEVCContext *s, const HEVCSPS *sps,
     }
 
     s->ps.sps = sps;
-    s->ps.vps = (HEVCVPS*) s->ps.vps_list[s->ps.sps->vps_id]->data;
+    s->ps.vps = s->ps.vps_list[s->ps.sps->vps_id];
 
     return 0;
 
@@ -616,16 +617,16 @@ static int hls_slice_header(HEVCContext *s)
         return AVERROR_INVALIDDATA;
     }
     if (!sh->first_slice_in_pic_flag &&
-        s->ps.pps != (HEVCPPS*)s->ps.pps_list[sh->pps_id]->data) {
+        s->ps.pps != s->ps.pps_list[sh->pps_id]) {
         av_log(s->avctx, AV_LOG_ERROR, "PPS changed between slices.\n");
         return AVERROR_INVALIDDATA;
     }
-    s->ps.pps = (HEVCPPS*)s->ps.pps_list[sh->pps_id]->data;
+    s->ps.pps = s->ps.pps_list[sh->pps_id];
     if (s->nal_unit_type == HEVC_NAL_CRA_NUT && s->last_eos == 1)
         sh->no_output_of_prior_pics_flag = 1;
 
-    if (s->ps.sps != (HEVCSPS*)s->ps.sps_list[s->ps.pps->sps_id]->data) {
-        const HEVCSPS *sps = (HEVCSPS*)s->ps.sps_list[s->ps.pps->sps_id]->data;
+    if (s->ps.sps != s->ps.sps_list[s->ps.pps->sps_id]) {
+        const HEVCSPS *sps = s->ps.sps_list[s->ps.pps->sps_id];
         enum AVPixelFormat pix_fmt;
 
         ff_hevc_clear_refs(s);
@@ -3301,7 +3302,7 @@ static int hevc_decode_extradata(HEVCContext *s, uint8_t *buf, int length, int f
     /* export stream parameters from the first SPS */
     for (i = 0; i < FF_ARRAY_ELEMS(s->ps.sps_list); i++) {
         if (first && s->ps.sps_list[i]) {
-            const HEVCSPS *sps = (const HEVCSPS*)s->ps.sps_list[i]->data;
+            const HEVCSPS *sps = s->ps.sps_list[i];
             export_stream_params(s, sps);
             break;
         }
@@ -3539,23 +3540,14 @@ static int hevc_update_thread_context(AVCodecContext *dst,
 
     if (s->ps.sps != s0->ps.sps)
         s->ps.sps = NULL;
-    for (i = 0; i < FF_ARRAY_ELEMS(s->ps.vps_list); i++) {
-        ret = av_buffer_replace(&s->ps.vps_list[i], s0->ps.vps_list[i]);
-        if (ret < 0)
-            return ret;
-    }
+    for (int i = 0; i < FF_ARRAY_ELEMS(s->ps.vps_list); i++)
+        ff_refstruct_replace(&s->ps.vps_list[i], s0->ps.vps_list[i]);
 
-    for (i = 0; i < FF_ARRAY_ELEMS(s->ps.sps_list); i++) {
-        ret = av_buffer_replace(&s->ps.sps_list[i], s0->ps.sps_list[i]);
-        if (ret < 0)
-            return ret;
-    }
+    for (int i = 0; i < FF_ARRAY_ELEMS(s->ps.sps_list); i++)
+        ff_refstruct_replace(&s->ps.sps_list[i], s0->ps.sps_list[i]);
 
-    for (i = 0; i < FF_ARRAY_ELEMS(s->ps.pps_list); i++) {
-        ret = av_buffer_replace(&s->ps.pps_list[i], s0->ps.pps_list[i]);
-        if (ret < 0)
-            return ret;
-    }
+    for (int i = 0; i < FF_ARRAY_ELEMS(s->ps.pps_list); i++)
+        ff_refstruct_replace(&s->ps.pps_list[i], s0->ps.pps_list[i]);
 
     if (s->ps.sps != s0->ps.sps)
         if ((ret = set_sps(s, s0->ps.sps, src->pix_fmt)) < 0)
diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c
index 52b3a2c1f7..b8587289a2 100644
--- a/libavcodec/mediacodecdec.c
+++ b/libavcodec/mediacodecdec.c
@@ -223,21 +223,21 @@ static int hevc_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
 
     for (i = 0; i < HEVC_MAX_VPS_COUNT; i++) {
         if (ps.vps_list[i]) {
-            vps = (const HEVCVPS*)ps.vps_list[i]->data;
+            vps = ps.vps_list[i];
             break;
         }
     }
 
     for (i = 0; i < HEVC_MAX_PPS_COUNT; i++) {
         if (ps.pps_list[i]) {
-            pps = (const HEVCPPS*)ps.pps_list[i]->data;
+            pps = ps.pps_list[i];
             break;
         }
     }
 
     if (pps) {
         if (ps.sps_list[pps->sps_id]) {
-            sps = (const HEVCSPS*)ps.sps_list[pps->sps_id]->data;
+            sps = ps.sps_list[pps->sps_id];
         }
     }
 
diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
index 963379d483..43fd2e3fea 100644
--- a/libavcodec/videotoolbox.c
+++ b/libavcodec/videotoolbox.c
@@ -246,7 +246,7 @@ CFDataRef ff_videotoolbox_hvcc_extradata_create(AVCodecContext *avctx)
 #define COUNT_SIZE_PS(T, t) \
     for (i = 0; i < HEVC_MAX_##T##PS_COUNT; i++) { \
         if (h->ps.t##ps_list[i]) { \
-            const HEVC##T##PS *lps = (const HEVC##T##PS *)h->ps.t##ps_list[i]->data; \
+            const HEVC##T##PS *lps = h->ps.t##ps_list[i]; \
             vt_extradata_size += 2 + escape_ps(NULL, lps->data, lps->data_size); \
             num_##t##ps++; \
         } \
@@ -369,7 +369,7 @@ CFDataRef ff_videotoolbox_hvcc_extradata_create(AVCodecContext *avctx)
     p += 3; \
     for (i = 0; i < HEVC_MAX_##T##PS_COUNT; i++) { \
         if (h->ps.t##ps_list[i]) { \
-            const HEVC##T##PS *lps = (const HEVC##T##PS *)h->ps.t##ps_list[i]->data; \
+            const HEVC##T##PS *lps = h->ps.t##ps_list[i]; \
             int size = escape_ps(p + 2, lps->data, lps->data_size); \
             /* unsigned int(16) nalUnitLength; */ \
             AV_WB16(p, size); \
diff --git a/libavcodec/vulkan_hevc.c b/libavcodec/vulkan_hevc.c
index 52f223ceb2..395cbd3008 100644
--- a/libavcodec/vulkan_hevc.c
+++ b/libavcodec/vulkan_hevc.c
@@ -70,14 +70,14 @@ typedef struct HEVCHeaderSet {
 
 static int alloc_hevc_header_structs(FFVulkanDecodeContext *s,
                                      int nb_vps,
-                                     AVBufferRef * const vps_list[HEVC_MAX_VPS_COUNT])
+                                     const HEVCVPS * const vps_list[HEVC_MAX_VPS_COUNT])
 {
     uint8_t *data_ptr;
     HEVCHeaderSet *hdr;
 
     size_t buf_size = sizeof(HEVCHeaderSet) + nb_vps*sizeof(HEVCHeaderVPS);
     for (int i = 0; i < nb_vps; i++) {
-        const HEVCVPS *vps = (const HEVCVPS *)vps_list[i]->data;
+        const HEVCVPS *vps = vps_list[i];
         buf_size += sizeof(HEVCHeaderVPSSet)*vps->vps_num_hrd_parameters;
     }
 
@@ -96,7 +96,7 @@ static int alloc_hevc_header_structs(FFVulkanDecodeContext *s,
     hdr->hvps = (HEVCHeaderVPS *)(data_ptr + sizeof(HEVCHeaderSet));
     data_ptr += sizeof(HEVCHeaderSet) + nb_vps*sizeof(HEVCHeaderVPS);
     for (int i = 0; i < nb_vps; i++) {
-        const HEVCVPS *vps = (const HEVCVPS *)vps_list[i]->data;
+        const HEVCVPS *vps = vps_list[i];
         hdr->hvps[i].sls = (HEVCHeaderVPSSet *)data_ptr;
         data_ptr += sizeof(HEVCHeaderVPSSet)*vps->vps_num_hrd_parameters;
     }
@@ -673,7 +673,7 @@ static int vk_hevc_create_params(AVCodecContext *avctx, AVBufferRef **buf)
 
     /* SPS list */
     for (int i = 0; h->ps.sps_list[i]; i++) {
-        const HEVCSPS *sps_l = (const HEVCSPS *)h->ps.sps_list[i]->data;
+        const HEVCSPS *sps_l = h->ps.sps_list[i];
         set_sps(sps_l, i, &hdr->hsps[i].scaling, &hdr->hsps[i].vui_header,
                 &hdr->hsps[i].vui, &hdr->sps[i], hdr->hsps[i].nal_hdr,
                 hdr->hsps[i].vcl_hdr, &hdr->hsps[i].ptl, &hdr->hsps[i].dpbm,
@@ -683,15 +683,15 @@ static int vk_hevc_create_params(AVCodecContext *avctx, AVBufferRef **buf)
 
     /* PPS list */
     for (int i = 0; h->ps.pps_list[i]; i++) {
-        const HEVCPPS *pps_l = (const HEVCPPS *)h->ps.pps_list[i]->data;
-        const HEVCSPS *sps_l = (const HEVCSPS *)h->ps.sps_list[pps_l->sps_id]->data;
+        const HEVCPPS *pps_l = h->ps.pps_list[i];
+        const HEVCSPS *sps_l = h->ps.sps_list[pps_l->sps_id];
         set_pps(pps_l, sps_l, &hdr->hpps[i].scaling, &hdr->pps[i], &hdr->hpps[i].pal);
         h265_params_info.stdPPSCount++;
     }
 
     /* VPS list */
     for (int i = 0; i < nb_vps; i++) {
-        const HEVCVPS *vps_l = (const HEVCVPS *)h->ps.vps_list[i]->data;
+        const HEVCVPS *vps_l = h->ps.vps_list[i];
         set_vps(vps_l, &hdr->vps[i], &hdr->hvps[i].ptl, &hdr->hvps[i].dpbm,
                 hdr->hvps[i].hdr, hdr->hvps[i].sls);
         h265_params_info.stdVPSCount++;
@@ -871,7 +871,7 @@ static int vk_hevc_end_frame(AVCodecContext *avctx)
         if (!pps) {
             unsigned int pps_id = h->sh.pps_id;
             if (pps_id < HEVC_MAX_PPS_COUNT && h->ps.pps_list[pps_id] != NULL)
-                pps = (const HEVCPPS *)h->ps.pps_list[pps_id]->data;
+                pps = h->ps.pps_list[pps_id];
         }
 
         if (!pps) {
-- 
2.34.1

_______________________________________________
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".

  parent reply	other threads:[~2023-09-19 19:57 UTC|newest]

Thread overview: 106+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-19 19:38 [FFmpeg-devel] [PATCH 00/42] New API for reference counting and ThreadFrames Andreas Rheinhardt
2023-09-19 19:56 ` [FFmpeg-devel] [PATCH 01/42] tests/fate-run: Ensure that THREADS=random is actually random Andreas Rheinhardt
2023-09-25 20:01   ` Andreas Rheinhardt
2023-09-19 19:56 ` [FFmpeg-devel] [PATCH 02/42] avcodec/refstruct: Add simple API for refcounted objects Andreas Rheinhardt
2023-09-21 19:58   ` Nicolas George
2023-09-21 23:07     ` Andreas Rheinhardt
2023-10-06 18:24   ` Andreas Rheinhardt
2023-10-06 19:43     ` Nicolas George
2023-10-06 20:20       ` Andreas Rheinhardt
2023-10-06 20:37         ` Nicolas George
2023-10-06 20:50           ` Andreas Rheinhardt
2023-10-06 21:22             ` Nicolas George
2023-10-07 21:03   ` James Almer
2023-09-19 19:56 ` [FFmpeg-devel] [PATCH 03/42] avcodec/get_buffer: Use RefStruct API for FramePool Andreas Rheinhardt
2023-09-28 12:36   ` Anton Khirnov
2023-09-19 19:56 ` [FFmpeg-devel] [PATCH 04/42] avcodec/h264_ps: Use RefStruct API for SPS/PPS Andreas Rheinhardt
2023-09-28 13:03   ` Anton Khirnov
2023-09-28 15:49     ` Andreas Rheinhardt
2023-10-02  9:39       ` Anton Khirnov
2023-09-19 19:56 ` Andreas Rheinhardt [this message]
2023-09-28 13:13   ` [FFmpeg-devel] [PATCH 05/42] avcodec/hevc_ps: Use RefStruct API for parameter sets Anton Khirnov
2023-09-19 19:56 ` [FFmpeg-devel] [PATCH 06/42] avcodec/vp8: Use RefStruct API for seg_map Andreas Rheinhardt
2023-10-02  9:44   ` Anton Khirnov
2023-10-02 10:04     ` Andreas Rheinhardt
2023-10-02 10:14       ` Anton Khirnov
2023-09-19 19:56 ` [FFmpeg-devel] [PATCH 07/42] avcodec/wavpack: Use RefStruct API for DSD context Andreas Rheinhardt
2023-10-02  9:46   ` Anton Khirnov
2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 08/42] avcodec/dovi_rpu: Use RefStruct API for Vdr data Andreas Rheinhardt
2023-10-02  9:51   ` Anton Khirnov
2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 09/42] avcodec/refstruct: Allow checking for exclusive ownership Andreas Rheinhardt
2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 10/42] avcodec/cbs: Use RefStruct-API for unit content Andreas Rheinhardt
2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 11/42] avcodec/cbs_sei: Use RefStruct API for SEI messages Andreas Rheinhardt
2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 12/42] avcodec/decode: Use RefStruct API for hwaccel_picture_private Andreas Rheinhardt
2023-10-02 10:39   ` Anton Khirnov
2023-10-02 12:30   ` Lynne
2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 13/42] avcodec/vulkan_decode: Use RefStruct API for shared_ref Andreas Rheinhardt
2023-10-02 12:31   ` Lynne
2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 14/42] avcodec/hevcdec: Use RefStruct API for RefPicListTap buffer Andreas Rheinhardt
2023-10-02 10:47   ` Anton Khirnov
2023-10-02 11:07     ` Andreas Rheinhardt
2023-10-04  8:10       ` Anton Khirnov
2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 15/42] avcodec/pthread_frame: Use RefStruct API for ThreadFrame.progress Andreas Rheinhardt
2023-10-02 11:01   ` Anton Khirnov
2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 16/42] avcodec/nvdec: Use RefStruct API for decoder_ref Andreas Rheinhardt
2023-10-02 10:58   ` Anton Khirnov
2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 17/42] avcodec/refstruct: Add RefStruct pool API Andreas Rheinhardt
2023-09-20 19:58   ` Michael Niedermayer
2023-09-21  0:28     ` Andreas Rheinhardt
2023-10-04  8:39   ` Anton Khirnov
2023-10-04 11:09     ` Andreas Rheinhardt
2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 18/42] avcodec/h264dec: Use RefStruct-pool API instead of AVBufferPool API Andreas Rheinhardt
2023-10-04 14:07   ` Anton Khirnov
2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 19/42] avcodec/hevcdec: " Andreas Rheinhardt
2023-10-04 14:12   ` Anton Khirnov
2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 20/42] avcodec/nvdec: Use RefStruct-pool API for decoder pool Andreas Rheinhardt
2023-10-04 14:28   ` Anton Khirnov
2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 21/42] avcodec/refstruct: Allow to always return zeroed pool entries Andreas Rheinhardt
2023-10-12 12:45   ` Anton Khirnov
2023-10-12 13:25     ` Andreas Rheinhardt
2023-10-12 13:56       ` Anton Khirnov
2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 22/42] avcodec/vp9: Use RefStruct-pool API for extradata Andreas Rheinhardt
2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 23/42] avcodec/vaapi_encode: Use RefStruct pool API, stop abusing AVBuffer API Andreas Rheinhardt
2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 24/42] avcodec/refstruct: Allow to share pools Andreas Rheinhardt
2023-10-12 13:04   ` Anton Khirnov
2023-10-12 13:51     ` Andreas Rheinhardt
2023-10-12 14:04       ` Anton Khirnov
2023-10-12 14:10         ` Andreas Rheinhardt
2023-10-12 17:09         ` Andreas Rheinhardt
2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 25/42] avcodec/vp9: Join extradata buffer pools Andreas Rheinhardt
2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 26/42] avcodec/refstruct: Allow to use a dynamic opaque Andreas Rheinhardt
2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 27/42] avcodec/pthread_frame: Add new progress API Andreas Rheinhardt
2023-10-21 10:34   ` Anton Khirnov
2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 28/42] avcodec/mimic: Switch to ProgressFrames Andreas Rheinhardt
2023-10-21 10:38   ` Anton Khirnov
2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 29/42] avcodec/vp3: " Andreas Rheinhardt
2023-10-21 10:48   ` Anton Khirnov
2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 30/42] avcodec/vp9: " Andreas Rheinhardt
2023-10-21 11:04   ` Anton Khirnov
2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 31/42] avcodec/vp9: Fix race when attaching side-data for show-existing frame Andreas Rheinhardt
2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 32/42] avcodec/vp9: Reduce wait times Andreas Rheinhardt
2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 33/42] avcodec/vp9: Simplify replacing VP9Frame Andreas Rheinhardt
2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 34/42] avcodec/vp9: Replace atomic_store() by atomic_init() Andreas Rheinhardt
2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 35/42] avcodec/threadprogress: Add new API for frame-threaded progress Andreas Rheinhardt
2023-09-20 19:44   ` Michael Niedermayer
2023-09-21  0:28     ` Andreas Rheinhardt
2023-10-25 13:25   ` Anton Khirnov
2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 36/42] avcodec/wavpack: Use ThreadProgress API Andreas Rheinhardt
2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 37/42] avcodec/vp8: Convert to ProgressFrame API Andreas Rheinhardt
2023-10-25 13:35   ` Anton Khirnov
2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 38/42] avcodec/codec_internal: Remove FF_CODEC_CAP_ALLOCATE_PROGRESS Andreas Rheinhardt
2023-10-25 13:38   ` Anton Khirnov
2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 39/42] avcodec/hevcdec: Move collocated_ref to HEVCContext Andreas Rheinhardt
2023-10-25 13:42   ` Anton Khirnov
2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 40/42] avcodec/hevcdec: Switch to ProgressFrames Andreas Rheinhardt
2023-11-09  9:50   ` Anton Khirnov
2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 41/42] avcodec/pngdec: " Andreas Rheinhardt
2023-11-09  9:52   ` Anton Khirnov
2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 42/42] avcodec/ffv1dec: " Andreas Rheinhardt
2023-11-09  9:56   ` Anton Khirnov
2023-10-02 18:13 ` [FFmpeg-devel] [PATCH 43/49] avcodec/qsv: Use RefStruct API for memory id (mids) array Andreas Rheinhardt
2023-10-02 18:13 ` [FFmpeg-devel] [PATCH 44/49] avcodec/rkmppdec: Fix double-free on error Andreas Rheinhardt
2023-10-02 18:13 ` [FFmpeg-devel] [PATCH 45/49] avcodec/rkmppdec: Check av_buffer_ref() Andreas Rheinhardt
2023-10-02 18:13 ` [FFmpeg-devel] [PATCH 46/49] avcodec/rkmppdec: Use RefStruct API for references to decoder itself Andreas Rheinhardt
2023-10-02 18:13 ` [FFmpeg-devel] [PATCH 47/49] avcodec/rkmppdec: Allocate AVDRMFrameDescriptor and frame ctx jointly Andreas Rheinhardt
2023-10-02 18:13 ` [FFmpeg-devel] [PATCH 48/49] avcodec/v4l2_m2m: Remove redundant av_frame_unref() Andreas Rheinhardt
2023-10-02 18:13 ` [FFmpeg-devel] [PATCH 49/49] avcodec/v4l2_(m2m|buffers): Use RefStruct API for context references Andreas Rheinhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AS8P250MB07449E3C118B5A518C36A8FE8FFAA@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM \
    --to=andreas.rheinhardt@outlook.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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