ffmpeg | branch: master | Niklas Haas <g...@haasn.dev> | Sun Jun  9 16:43:29 
2024 +0200| [7bf08a5b2d379bc9e4f4422788195f5421b3d72a] | committer: Niklas Haas

avcodec/dovi_rpu: simplify vdr type

Storing the color metadata alongside the data mapping is no longer
needed, so we can simplify this array's type.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7bf08a5b2d379bc9e4f4422788195f5421b3d72a
---

 libavcodec/dovi_rpu.h    |  7 +------
 libavcodec/dovi_rpudec.c |  6 +++---
 libavcodec/dovi_rpuenc.c | 10 +++++-----
 3 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/libavcodec/dovi_rpu.h b/libavcodec/dovi_rpu.h
index da9bd67cde..058d50c64f 100644
--- a/libavcodec/dovi_rpu.h
+++ b/libavcodec/dovi_rpu.h
@@ -75,7 +75,7 @@ typedef struct DOVIContext {
      * Private fields internal to dovi_rpu.c
      */
     AVDOVIColorMetadata *dm; ///< RefStruct
-    struct DOVIVdr *vdr[DOVI_MAX_DM_ID+1]; ///< RefStruct references
+    AVDOVIDataMapping *vdr[DOVI_MAX_DM_ID+1]; ///< RefStruct references
     uint8_t *rpu_buf; ///< temporary buffer
     unsigned rpu_buf_sz;
 
@@ -127,11 +127,6 @@ int ff_dovi_configure(DOVIContext *s, AVCodecContext 
*avctx);
  * The following section is for internal use only. *
  ***************************************************/
 
-typedef struct DOVIVdr {
-    AVDOVIDataMapping mapping;
-    AVDOVIColorMetadata color;
-} DOVIVdr;
-
 enum {
     RPU_COEFF_FIXED = 0,
     RPU_COEFF_FLOAT = 1,
diff --git a/libavcodec/dovi_rpudec.c b/libavcodec/dovi_rpudec.c
index 43b62f4357..8146a918b0 100644
--- a/libavcodec/dovi_rpudec.c
+++ b/libavcodec/dovi_rpudec.c
@@ -465,18 +465,18 @@ int ff_dovi_rpu_parse(DOVIContext *s, const uint8_t *rpu, 
size_t rpu_size,
                    prev_vdr_rpu_id);
             goto fail;
         }
-        s->mapping = &s->vdr[prev_vdr_rpu_id]->mapping;
+        s->mapping = s->vdr[prev_vdr_rpu_id];
     } else {
         AVDOVIDataMapping *mapping;
         int vdr_rpu_id = get_ue_golomb_31(gb);
         VALIDATE(vdr_rpu_id, 0, DOVI_MAX_DM_ID);
         if (!s->vdr[vdr_rpu_id]) {
-            s->vdr[vdr_rpu_id] = ff_refstruct_allocz(sizeof(DOVIVdr));
+            s->vdr[vdr_rpu_id] = 
ff_refstruct_allocz(sizeof(AVDOVIDataMapping));
             if (!s->vdr[vdr_rpu_id])
                 return AVERROR(ENOMEM);
         }
 
-        s->mapping = mapping = &s->vdr[vdr_rpu_id]->mapping;
+        s->mapping = mapping = s->vdr[vdr_rpu_id];
         mapping->vdr_rpu_id = vdr_rpu_id;
         mapping->mapping_color_space = get_ue_golomb_31(gb);
         mapping->mapping_chroma_format_idc = get_ue_golomb_31(gb);
diff --git a/libavcodec/dovi_rpuenc.c b/libavcodec/dovi_rpuenc.c
index 3fd9046453..7715ce4248 100644
--- a/libavcodec/dovi_rpuenc.c
+++ b/libavcodec/dovi_rpuenc.c
@@ -465,7 +465,7 @@ int ff_dovi_rpu_generate(DOVIContext *s, const 
AVDOVIMetadata *metadata,
 
     vdr_rpu_id = -1;
     for (int i = 0; i <= DOVI_MAX_DM_ID; i++) {
-        if (s->vdr[i] && !memcmp(&s->vdr[i]->mapping, mapping, 
sizeof(*mapping))) {
+        if (s->vdr[i] && !memcmp(s->vdr[i], mapping, sizeof(*mapping))) {
             vdr_rpu_id = i;
             break;
         } else if (vdr_rpu_id < 0 && (!s->vdr[i] || i == DOVI_MAX_DM_ID)) {
@@ -474,7 +474,7 @@ int ff_dovi_rpu_generate(DOVIContext *s, const 
AVDOVIMetadata *metadata,
     }
 
     if (!s->vdr[vdr_rpu_id]) {
-        s->vdr[vdr_rpu_id] = ff_refstruct_allocz(sizeof(DOVIVdr));
+        s->vdr[vdr_rpu_id] = ff_refstruct_allocz(sizeof(AVDOVIDataMapping));
         if (!s->vdr[vdr_rpu_id])
             return AVERROR(ENOMEM);
     }
@@ -507,7 +507,7 @@ int ff_dovi_rpu_generate(DOVIContext *s, const 
AVDOVIMetadata *metadata,
     }
 
     vdr_dm_metadata_present = memcmp(color, &ff_dovi_color_default, 
sizeof(*color));
-    use_prev_vdr_rpu = !memcmp(&s->vdr[vdr_rpu_id]->mapping, mapping, 
sizeof(*mapping));
+    use_prev_vdr_rpu = !memcmp(s->vdr[vdr_rpu_id], mapping, sizeof(*mapping));
 
     if (vdr_dm_metadata_present && !s->dm) {
         s->dm = ff_refstruct_allocz(sizeof(AVDOVIColorMetadata));
@@ -563,7 +563,7 @@ int ff_dovi_rpu_generate(DOVIContext *s, const 
AVDOVIMetadata *metadata,
     put_bits(pb, 1, vdr_dm_metadata_present);
     put_bits(pb, 1, use_prev_vdr_rpu);
     set_ue_golomb(pb, vdr_rpu_id);
-    s->mapping = &s->vdr[vdr_rpu_id]->mapping;
+    s->mapping = s->vdr[vdr_rpu_id];
 
     profile = s->cfg.dv_profile ? s->cfg.dv_profile : 
ff_dovi_guess_profile_hevc(hdr);
 
@@ -629,7 +629,7 @@ int ff_dovi_rpu_generate(DOVIContext *s, const 
AVDOVIMetadata *metadata,
             }
         }
 
-        memcpy(&s->vdr[vdr_rpu_id]->mapping, mapping, sizeof(*mapping));
+        memcpy(s->vdr[vdr_rpu_id], mapping, sizeof(*mapping));
     }
 
     if (vdr_dm_metadata_present) {

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

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

Reply via email to