---
 doc/bitstream_filters.texi     | 17 +++++++++++++++++
 libavcodec/h264_metadata_bsf.c | 25 +++++++++++++++++++++++++
 2 files changed, 42 insertions(+)

diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi
index 60e729484d..0ff76b86f0 100644
--- a/doc/bitstream_filters.texi
+++ b/doc/bitstream_filters.texi
@@ -285,6 +285,23 @@ level_idc value (for example, @samp{42}), or the special 
name @samp{auto}
 indicating that the filter should attempt to guess the level from the
 input stream properties.
 
+@item mastering_display
+@item content_light_level
+Manipulate mastering display colour volume (see H.264 section D.2.29)
+and content light level info (see H.264 section D.2.31) SEI messages in
+the stream.
+
+Possible actions:
+@table @samp
+@item insert
+Insert this type of message, taking the values from packet side-data.
+@item remove
+Remove all instances of this message.
+@item extract
+Extract the content of this type of message, attaching it to the packets
+as side-data.
+@end table
+
 @end table
 
 @section h264_mp4toannexb
diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c
index 6511c4b776..069d65432e 100644
--- a/libavcodec/h264_metadata_bsf.c
+++ b/libavcodec/h264_metadata_bsf.c
@@ -78,6 +78,9 @@ typedef struct H264MetadataContext {
     int flip;
 
     int level;
+
+    int mastering_display;
+    int content_light_level;
 } H264MetadataContext;
 
 
@@ -449,6 +452,20 @@ static int h264_metadata_update_fragment(AVBSFContext 
*bsf, AVPacket *pkt,
             return err;
     }
 
+    if (pkt) {
+        err = ff_cbs_bsf_apply_metadata(bsf, pkt, au,
+                                        CBS_METADATA_MASTERING_DISPLAY,
+                                        ctx->mastering_display);
+        if (err < 0)
+            return err;
+
+        err = ff_cbs_bsf_apply_metadata(bsf, pkt, au,
+                                        CBS_METADATA_CONTENT_LIGHT_LEVEL,
+                                        ctx->content_light_level);
+        if (err < 0)
+            return err;
+    }
+
     if (pkt)
         ctx->done_first_au = 1;
 
@@ -609,6 +626,14 @@ static const AVOption h264_metadata_options[] = {
     { LEVEL("6.2", 62) },
 #undef LEVEL
 
+    BSF_ELEMENT_OPTIONS_PIRE("mastering_display",
+                             "Mastering display colour volume SEI",
+                             mastering_display, FLAGS),
+
+    BSF_ELEMENT_OPTIONS_PIRE("content_light_level",
+                             "Content light level information SEI",
+                             content_light_level, FLAGS),
+
     { NULL }
 };
 
-- 
2.30.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-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to