[FFmpeg-cvslog] avcodec/dovi_rpuenc: add a flag to enable compression

Niklas Haas git at videolan.org
Fri Aug 16 12:51:58 EEST 2024


ffmpeg | branch: master | Niklas Haas <git at haasn.dev> | Tue Jun 18 17:23:28 2024 +0200| [ae3a78593df2b41f4163496f0bdf73c01d73c9a6] | committer: Niklas Haas

avcodec/dovi_rpuenc: add a flag to enable compression

Keyframes must reset the metadata compression state, so we need to
also signal this at rpu generation time.

Default to uncompressed, because encoders cannot generally know if
a given frame will be a keyframe before they finish encoding, but also
cannot retroactively attach the RPU. (Within the confines of current
APIs)

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

 libavcodec/dovi_rpu.h    | 1 +
 libavcodec/dovi_rpuenc.c | 6 +++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/libavcodec/dovi_rpu.h b/libavcodec/dovi_rpu.h
index 226a769bff..e2e7635cfb 100644
--- a/libavcodec/dovi_rpu.h
+++ b/libavcodec/dovi_rpu.h
@@ -126,6 +126,7 @@ int ff_dovi_configure(DOVIContext *s, AVCodecContext *avctx);
 enum {
     FF_DOVI_WRAP_NAL        = 1 << 0, ///< wrap inside NAL RBSP
     FF_DOVI_WRAP_T35        = 1 << 1, ///< wrap inside T.35+EMDF
+    FF_DOVI_COMPRESS_RPU    = 1 << 2, ///< enable compression for this RPU
 };
 
 /**
diff --git a/libavcodec/dovi_rpuenc.c b/libavcodec/dovi_rpuenc.c
index 73db9437a0..0d4e613a72 100644
--- a/libavcodec/dovi_rpuenc.c
+++ b/libavcodec/dovi_rpuenc.c
@@ -444,6 +444,7 @@ int ff_dovi_rpu_generate(DOVIContext *s, const AVDOVIMetadata *metadata,
     int vdr_dm_metadata_present, vdr_rpu_id, use_prev_vdr_rpu, profile,
         buffer_size, rpu_size, pad, zero_run;
     int num_ext_blocks_v1, num_ext_blocks_v2;
+    int dv_md_compression = s->cfg.dv_md_compression;
     uint32_t crc;
     uint8_t *dst;
     if (!metadata) {
@@ -463,6 +464,9 @@ int ff_dovi_rpu_generate(DOVIContext *s, const AVDOVIMetadata *metadata,
         return AVERROR_INVALIDDATA;
     }
 
+    if (!(flags & FF_DOVI_COMPRESS_RPU))
+        dv_md_compression = AV_DOVI_COMPRESSION_NONE;
+
     vdr_rpu_id = mapping->vdr_rpu_id;
     use_prev_vdr_rpu = 0;
 
@@ -472,7 +476,7 @@ int ff_dovi_rpu_generate(DOVIContext *s, const AVDOVIMetadata *metadata,
             return AVERROR(ENOMEM);
     }
 
-    switch (s->cfg.dv_md_compression) {
+    switch (dv_md_compression) {
     case AV_DOVI_COMPRESSION_LIMITED:
         /* Limited metadata compression requires vdr_rpi_id == 0 */
         if (vdr_rpu_id != 0)



More information about the ffmpeg-cvslog mailing list