[FFmpeg-devel] [PATCH 24/27] av1_metadata_bsf: Support HDR metadata
Mark Thompson
sw at jkqxz.net
Fri Jan 1 23:35:34 EET 2021
---
doc/bitstream_filters.texi | 17 +++++++++++++++++
libavcodec/av1_metadata_bsf.c | 26 ++++++++++++++++++++++++++
2 files changed, 43 insertions(+)
diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi
index 4c9a42c24a..3fea06fca7 100644
--- a/doc/bitstream_filters.texi
+++ b/doc/bitstream_filters.texi
@@ -90,6 +90,23 @@ has a fixed framerate. Ignored if @option{tick_rate} is not also set.
@item delete_padding
Deletes Padding OBUs.
+ at item hdr_cll
+ at item hdr_mdcv
+Manipulate content light level (see AV1 section 6.7.3) and mastering
+display colour volume (see AV1 section 6.7.4) metadata messages in the
+stream.
+
+Possible actions:
+ at table @samp
+ at item insert
+Insert this type of message, taking the values from packet side-data.
+ at item remove
+Remove all instances of this message.
+ at item extract
+Extract the content of this type of message, attaching it to the packets
+as side-data.
+ at end table
+
@end table
@section chomp
diff --git a/libavcodec/av1_metadata_bsf.c b/libavcodec/av1_metadata_bsf.c
index 31fd4f0f41..8ac6e32b59 100644
--- a/libavcodec/av1_metadata_bsf.c
+++ b/libavcodec/av1_metadata_bsf.c
@@ -23,6 +23,7 @@
#include "cbs.h"
#include "cbs_bsf.h"
#include "cbs_av1.h"
+#include "cbs_metadata.h"
typedef struct AV1MetadataContext {
CBSBSFContext common;
@@ -40,6 +41,9 @@ typedef struct AV1MetadataContext {
int num_ticks_per_picture;
int delete_padding;
+
+ int hdr_cll;
+ int hdr_mdcv;
} AV1MetadataContext;
@@ -143,6 +147,20 @@ static int av1_metadata_update_fragment(AVBSFContext *bsf, AVPacket *pkt,
}
}
+ if (pkt) {
+ err = ff_cbs_bsf_apply_metadata(bsf, pkt, frag,
+ CBS_METADATA_CONTENT_LIGHT_LEVEL,
+ ctx->hdr_mdcv);
+ if (err < 0)
+ return err;
+
+ err = ff_cbs_bsf_apply_metadata(bsf, pkt, frag,
+ CBS_METADATA_MASTERING_DISPLAY,
+ ctx->hdr_mdcv);
+ if (err < 0)
+ return err;
+ }
+
return 0;
}
@@ -203,6 +221,14 @@ static const AVOption av1_metadata_options[] = {
OFFSET(delete_padding), AV_OPT_TYPE_BOOL,
{ .i64 = 0 }, 0, 1, FLAGS},
+ BSF_ELEMENT_OPTIONS_PIRE("hdr_cll",
+ "HDR content light level metadata",
+ hdr_cll, "cll"),
+
+ BSF_ELEMENT_OPTIONS_PIRE("hdr_mdcv",
+ "HDR mastering display colour volume metadata",
+ hdr_mdcv, "mdcv"),
+
{ NULL }
};
--
2.29.2
More information about the ffmpeg-devel
mailing list