Re: [libav-devel] [PATCH 05/14] lavc: Add h264_metadata bitstream filter

2017-08-12 Thread Hendrik Leppkes
On Sat, Aug 12, 2017 at 10:51 AM, Diego Biurrun  wrote:
> On Fri, Aug 11, 2017 at 12:37:00AM +0100, Mark Thompson wrote:
>> --- /dev/null
>> +++ b/libavcodec/h264_metadata_bsf.c
>> @@ -0,0 +1,511 @@
>> +
>> +typedef struct H264MetadataContext {
>> +const AVClass *class;
>
> Isn't the class member unused? Or did I just miss where this is used for 
> logging?
>

The priv_data of a BSF needs to have an AVClass member for AVOption support.

- Hendrik
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 05/14] lavc: Add h264_metadata bitstream filter

2017-08-12 Thread Diego Biurrun
On Fri, Aug 11, 2017 at 12:37:00AM +0100, Mark Thompson wrote:
> --- /dev/null
> +++ b/libavcodec/h264_metadata_bsf.c
> @@ -0,0 +1,511 @@
> +
> +typedef struct H264MetadataContext {
> +const AVClass *class;

Isn't the class member unused? Or did I just miss where this is used for 
logging?

Diego
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [PATCH 05/14] lavc: Add h264_metadata bitstream filter

2017-08-10 Thread Mark Thompson
This is able to modify some header metadata found in the SPS/VUI,
and can also add/remove AUDs and insert user data in SEI NAL units.
---
The frame_rate option is renamed tick_rate to be more consistent with what is 
actually in the stream.

Crop unit has been changed to pixels rather than the subsample units used in 
the stream.


 configure  |   1 +
 doc/bitstream_filters.texi |  63 +
 libavcodec/Makefile|   1 +
 libavcodec/bitstream_filters.c |   1 +
 libavcodec/h264_metadata_bsf.c | 511 +
 5 files changed, 577 insertions(+)
 create mode 100644 libavcodec/h264_metadata_bsf.c

diff --git a/configure b/configure
index 13dd7f54e..f3d616800 100755
--- a/configure
+++ b/configure
@@ -2323,6 +2323,7 @@ vc1_parser_select="vc1dsp"
 
 # bitstream_filters
 aac_adtstoasc_bsf_select="adts_header"
+h264_metadata_bsf_select="cbs_h264"
 mjpeg2jpeg_bsf_select="jpegtables"
 trace_headers_bsf_select="cbs_h264 cbs_h265"
 
diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi
index 119a2267a..08f2f390c 100644
--- a/doc/bitstream_filters.texi
+++ b/doc/bitstream_filters.texi
@@ -39,6 +39,69 @@ When this option is enabled, the long-term headers are 
removed from the
 bitstream after extraction.
 @end table
 
+@section h264_metadata
+
+Modify metadata embedded in an H.264 stream.
+
+@table @option
+@item aud
+Insert or remove AUD NAL units in all access units of the stream.
+
+@table @samp
+@item insert
+@item remove
+@end table
+
+@item sample_aspect_ratio
+Set the sample aspect ratio of the stream in the VUI parameters.
+
+@item video_format
+@item video_full_range_flag
+Set the video format in the stream (see H.264 section E.2.1 and
+table E-2).
+
+@item colour_primaries
+@item transfer_characteristics
+@item matrix_coefficients
+Set the colour description in the stream (see H.264 section E.2.1
+and tables E-3, E-4 and E-5).
+
+@item chroma_sample_loc_type
+Set the chroma sample location in the stream (see H.264 section
+E.2.1 and figure E-1).
+
+@item tick_rate
+Set the tick rate (num_units_in_tick / time_scale) in the VUI
+parameters.  This is the smallest time unit representable in the
+stream, and in many cases represents the field rate of the stream
+(double the frame rate).
+@item fixed_frame_rate_flag
+Set whether the stream has fixed framerate - typically this indicates
+that the framerate is exactly half the tick rate, but the exact
+meaning is dependent on interlacing and the picture structure (see
+H.264 section E.2.1 and table E-6).
+
+@item crop_left
+@item crop_right
+@item crop_top
+@item crop_bottom
+Set the frame cropping offsets in the SPS.  These values will replace
+the current ones if the stream is already cropped.
+
+These fields are set in pixels.  Note that some sizes may not be
+representable if the chroma is subsampled or the stream is interlaced
+(see H.264 section 7.4.2.1.1).
+
+@item sei_user_data
+Insert a string as SEI unregistered user data.  The argument must
+be of the form @emph{UUID+string}, where the UUID is as hex digits
+possibly separated by hyphens, and the string can be anything.
+
+For example, @samp{086f3693-b7b3-4f2c-9653-21492feee5b8+hello} will
+insert the string ``hello'' associated with the given UUID.
+
+@end table
+
 @section h264_mp4toannexb
 
 @section imx_dump_header
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 09772a85f..c76dffe05 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -776,6 +776,7 @@ OBJS-$(CONFIG_CHOMP_BSF)  += chomp_bsf.o
 OBJS-$(CONFIG_DUMP_EXTRADATA_BSF) += dump_extradata_bsf.o
 OBJS-$(CONFIG_EXTRACT_EXTRADATA_BSF)  += extract_extradata_bsf.o\
  h2645_parse.o
+OBJS-$(CONFIG_H264_METADATA_BSF)  += h264_metadata_bsf.o
 OBJS-$(CONFIG_H264_MP4TOANNEXB_BSF)   += h264_mp4toannexb_bsf.o
 OBJS-$(CONFIG_HEVC_MP4TOANNEXB_BSF)   += hevc_mp4toannexb_bsf.o
 OBJS-$(CONFIG_IMX_DUMP_HEADER_BSF)+= imx_dump_header_bsf.o
diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c
index 2e423acaf..4ad50508c 100644
--- a/libavcodec/bitstream_filters.c
+++ b/libavcodec/bitstream_filters.c
@@ -28,6 +28,7 @@ extern const AVBitStreamFilter ff_aac_adtstoasc_bsf;
 extern const AVBitStreamFilter ff_chomp_bsf;
 extern const AVBitStreamFilter ff_dump_extradata_bsf;
 extern const AVBitStreamFilter ff_extract_extradata_bsf;
+extern const AVBitStreamFilter ff_h264_metadata_bsf;
 extern const AVBitStreamFilter ff_h264_mp4toannexb_bsf;
 extern const AVBitStreamFilter ff_hevc_mp4toannexb_bsf;
 extern const AVBitStreamFilter ff_imx_dump_header_bsf;
diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c
new file mode 100644
index 0..25145d676
--- /dev/null
+++ b/libavcodec/h264_metadata_bsf.c
@@ -0,0 +1,511 @@
+/*
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it