[FFmpeg-devel] [PATCH 6/6] doc/examples/transcode: introduce timestamp logging

2023-09-01 Thread Stefano Sabatini
Aid timestamp debugging.
---
 doc/examples/transcode.c | 45 
 1 file changed, 36 insertions(+), 9 deletions(-)

diff --git a/doc/examples/transcode.c b/doc/examples/transcode.c
index b4b2d3c4c9..983a8f2845 100644
--- a/doc/examples/transcode.c
+++ b/doc/examples/transcode.c
@@ -37,6 +37,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static AVFormatContext *ifmt_ctx;
 static AVFormatContext *ofmt_ctx;
@@ -435,6 +436,28 @@ static int init_filters(void)
 return 0;
 }
 
+static void log_packet(AVPacket *pkt, const AVFormatContext *fmt_ctx, const 
char *tag)
+{
+AVRational *time_base = _ctx->streams[pkt->stream_index]->time_base;
+
+av_log(NULL, AV_LOG_INFO,
+   "%s [pkt] stream:%d tb:%d/%d pts_time:%s dts_time:%s\n",
+   tag, pkt->stream_index, time_base->num, time_base->den,
+   av_ts2timestr(pkt->pts, time_base),
+   av_ts2timestr(pkt->dts, time_base));
+}
+
+static void log_frame(AVFrame *frame, int stream_index, const char *tag)
+{
+AVRational *time_base = >time_base;
+
+av_log(NULL, AV_LOG_INFO,
+   "%s [frame] stream:%d tb:%d/%d pts_time:%s dts_time:%s\n",
+   tag, stream_index, time_base->num, time_base->den,
+   av_ts2timestr(frame->pts, time_base),
+   av_ts2timestr(frame->pkt_dts, time_base));
+}
+
 static int encode_write_frame(unsigned int stream_index, int flush)
 {
 StreamContext *stream = _ctx[stream_index];
@@ -443,16 +466,16 @@ static int encode_write_frame(unsigned int stream_index, 
int flush)
 AVPacket *enc_pkt = filter->enc_pkt;
 int ret;
 
-av_log(NULL, AV_LOG_INFO, "Encoding frame\n");
 /* encode filtered frame */
 av_packet_unref(enc_pkt);
 
-if (filt_frame && filt_frame->pts != AV_NOPTS_VALUE)
+if (filt_frame && filt_frame->pts != AV_NOPTS_VALUE) {
 filt_frame->pts = av_rescale_q(filt_frame->pts, filt_frame->time_base,
stream->enc_ctx->time_base);
+log_frame(filt_frame, stream_index, "encoder <-");
+}
 
 ret = avcodec_send_frame(stream->enc_ctx, filt_frame);
-
 if (ret < 0)
 return ret;
 
@@ -468,8 +491,8 @@ static int encode_write_frame(unsigned int stream_index, 
int flush)
  stream->enc_ctx->time_base,
  ofmt_ctx->streams[stream_index]->time_base);
 
-av_log(NULL, AV_LOG_DEBUG, "Muxing frame\n");
 /* mux encoded frame */
+log_packet(enc_pkt, ofmt_ctx, "muxer <-");
 ret = av_interleaved_write_frame(ofmt_ctx, enc_pkt);
 }
 
@@ -481,8 +504,11 @@ static int filter_encode_write_frame(AVFrame *frame, 
unsigned int stream_index)
 FilteringContext *filter = _ctx[stream_index];
 int ret;
 
-av_log(NULL, AV_LOG_INFO, "Pushing decoded frame to filters\n");
 /* push the decoded frame into the filtergraph */
+if (frame) {
+log_frame(frame, stream_index, "filters <-");
+}
+
 ret = av_buffersrc_add_frame(filter->buffersrc_ctx, frame);
 if (ret < 0) {
 av_log(NULL, AV_LOG_ERROR, "Error while feeding the filtergraph\n");
@@ -491,7 +517,6 @@ static int filter_encode_write_frame(AVFrame *frame, 
unsigned int stream_index)
 
 /* pull filtered frames from the filtergraph */
 while (1) {
-av_log(NULL, AV_LOG_INFO, "Pulling filtered frame from filters\n");
 ret = av_buffersink_get_frame(filter->buffersink_ctx, 
filter->filtered_frame);
 if (ret < 0) {
 /* if no more frames for output - returns AVERROR(EAGAIN)
@@ -505,6 +530,8 @@ static int filter_encode_write_frame(AVFrame *frame, 
unsigned int stream_index)
 
 filter->filtered_frame->time_base = 
av_buffersink_get_time_base(filter->buffersink_ctx);;
 filter->filtered_frame->pict_type = AV_PICTURE_TYPE_NONE;
+
+log_frame(filter->filtered_frame, stream_index, "filters ->");
 ret = encode_write_frame(stream_index, 0);
 av_frame_unref(filter->filtered_frame);
 if (ret < 0)
@@ -549,13 +576,11 @@ int main(int argc, char **argv)
 if ((ret = av_read_frame(ifmt_ctx, packet)) < 0)
 break;
 stream_index = packet->stream_index;
-av_log(NULL, AV_LOG_DEBUG, "Demuxer gave frame of stream_index %u\n", 
stream_index);
+log_packet(packet, ifmt_ctx, "demuxer ->");
 
 if (filter_ctx[stream_index].filter_graph) {
 StreamContext *stream = _ctx[stream_index];
 
-av_log(NULL, AV_LOG_DEBUG, "Going to reencode the frame\n");
-
 ret = avcodec_send_packet(stream->dec_ctx, packet);
 if (ret < 0) {
 av_log(NULL, AV_LOG_ERROR, "Decoding failed\n");
@@ -569,6 +594,7 @@ int main(int argc, char **argv)
 else if (ret < 0)
 goto end;
 
+log_frame(stream->dec_frame, stream_index, "decoder ->");
 stream->dec_frame->pts = 

[FFmpeg-devel] [PATCH 5/6] doc/examples/transcode: use av_buffersrc_add_frame()

2023-09-01 Thread Stefano Sabatini
Favor it over av_buffersrc_add_frame_flags, simplify.
---
 doc/examples/transcode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/examples/transcode.c b/doc/examples/transcode.c
index aa6594f4ec..b4b2d3c4c9 100644
--- a/doc/examples/transcode.c
+++ b/doc/examples/transcode.c
@@ -483,7 +483,7 @@ static int filter_encode_write_frame(AVFrame *frame, 
unsigned int stream_index)
 
 av_log(NULL, AV_LOG_INFO, "Pushing decoded frame to filters\n");
 /* push the decoded frame into the filtergraph */
-ret = av_buffersrc_add_frame_flags(filter->buffersrc_ctx, frame, 0);
+ret = av_buffersrc_add_frame(filter->buffersrc_ctx, frame);
 if (ret < 0) {
 av_log(NULL, AV_LOG_ERROR, "Error while feeding the filtergraph\n");
 return ret;
-- 
2.34.1

___
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".


[FFmpeg-devel] [PATCH 2/6] doc/examples/transcode: apply style fixes

2023-09-01 Thread Stefano Sabatini
---
 doc/examples/transcode.c | 95 +---
 1 file changed, 49 insertions(+), 46 deletions(-)

diff --git a/doc/examples/transcode.c b/doc/examples/transcode.c
index ed6ac9fa03..9af5674953 100644
--- a/doc/examples/transcode.c
+++ b/doc/examples/transcode.c
@@ -82,19 +82,23 @@ static int open_input_file(const char *filename)
 AVStream *stream = ifmt_ctx->streams[i];
 const AVCodec *dec = avcodec_find_decoder(stream->codecpar->codec_id);
 AVCodecContext *codec_ctx;
+
 if (!dec) {
 av_log(NULL, AV_LOG_ERROR, "Failed to find decoder for stream 
#%u\n", i);
 return AVERROR_DECODER_NOT_FOUND;
 }
+
 codec_ctx = avcodec_alloc_context3(dec);
 if (!codec_ctx) {
-av_log(NULL, AV_LOG_ERROR, "Failed to allocate the decoder context 
for stream #%u\n", i);
+av_log(NULL, AV_LOG_ERROR,
+   "Failed to allocate the decoder context for stream #%u\n", 
i);
 return AVERROR(ENOMEM);
 }
+
 ret = avcodec_parameters_to_context(codec_ctx, stream->codecpar);
 if (ret < 0) {
-av_log(NULL, AV_LOG_ERROR, "Failed to copy decoder parameters to 
input decoder context "
-   "for stream #%u\n", i);
+av_log(NULL, AV_LOG_ERROR,
+   "Failed to copy decoder parameters to input decoder context 
for stream #%u\n", i);
 return ret;
 }
 
@@ -103,8 +107,7 @@ static int open_input_file(const char *filename)
 codec_ctx->pkt_timebase = stream->time_base;
 
 /* Reencode video & audio and remux subtitles etc. */
-if (codec_ctx->codec_type == AVMEDIA_TYPE_VIDEO
-|| codec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
+if (codec_ctx->codec_type == AVMEDIA_TYPE_VIDEO || 
codec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
 if (codec_ctx->codec_type == AVMEDIA_TYPE_VIDEO)
 codec_ctx->framerate = av_guess_frame_rate(ifmt_ctx, stream, 
NULL);
 /* Open decoder */
@@ -141,7 +144,6 @@ static int open_output_file(const char *filename)
 return AVERROR_UNKNOWN;
 }
 
-
 for (i = 0; i < ifmt_ctx->nb_streams; i++) {
 out_stream = avformat_new_stream(ofmt_ctx, NULL);
 if (!out_stream) {
@@ -152,8 +154,7 @@ static int open_output_file(const char *filename)
 in_stream = ifmt_ctx->streams[i];
 dec_ctx = stream_ctx[i].dec_ctx;
 
-if (dec_ctx->codec_type == AVMEDIA_TYPE_VIDEO
-|| dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
+if (dec_ctx->codec_type == AVMEDIA_TYPE_VIDEO || dec_ctx->codec_type 
== AVMEDIA_TYPE_AUDIO) {
 /* in this example, we choose transcoding to same codec */
 encoder = avcodec_find_encoder(dec_ctx->codec_id);
 if (!encoder) {
@@ -241,8 +242,8 @@ static int open_output_file(const char *filename)
 return 0;
 }
 
-static int init_filter(FilteringContext* fctx, AVCodecContext *dec_ctx,
-AVCodecContext *enc_ctx, const char *filter_spec)
+static int init_filter(FilteringContext *fctx, AVCodecContext *dec_ctx,
+   AVCodecContext *enc_ctx, const char *filter_spec)
 {
 char args[512];
 int ret = 0;
@@ -269,29 +270,29 @@ static int init_filter(FilteringContext* fctx, 
AVCodecContext *dec_ctx,
 }
 
 snprintf(args, sizeof(args),
-
"video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:pixel_aspect=%d/%d",
-dec_ctx->width, dec_ctx->height, dec_ctx->pix_fmt,
-dec_ctx->pkt_timebase.num, dec_ctx->pkt_timebase.den,
-dec_ctx->sample_aspect_ratio.num,
-dec_ctx->sample_aspect_ratio.den);
+ 
"video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:pixel_aspect=%d/%d",
+ dec_ctx->width, dec_ctx->height, dec_ctx->pix_fmt,
+ dec_ctx->time_base.num, dec_ctx->time_base.den,
+ dec_ctx->sample_aspect_ratio.num,
+ dec_ctx->sample_aspect_ratio.den);
 
 ret = avfilter_graph_create_filter(_ctx, buffersrc, "in",
-args, NULL, filter_graph);
+   args, NULL, filter_graph);
 if (ret < 0) {
 av_log(NULL, AV_LOG_ERROR, "Cannot create buffer source\n");
 goto end;
 }
 
 ret = avfilter_graph_create_filter(_ctx, buffersink, "out",
-NULL, NULL, filter_graph);
+   NULL, NULL, filter_graph);
 if (ret < 0) {
 av_log(NULL, AV_LOG_ERROR, "Cannot create buffer sink\n");
 goto end;
 }
 
 ret = av_opt_set_bin(buffersink_ctx, "pix_fmts",
-(uint8_t*)_ctx->pix_fmt, sizeof(enc_ctx->pix_fmt),
-AV_OPT_SEARCH_CHILDREN);
+ (uint8_t*)_ctx->pix_fmt, 
sizeof(enc_ctx->pix_fmt),
+ 

[FFmpeg-devel] [PATCH 4/6] doc/examples/transcode: improve reporting when the encoder is not found

2023-09-01 Thread Stefano Sabatini
Also return EINVAL in place of INVALIDDATA.
---
 doc/examples/transcode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/examples/transcode.c b/doc/examples/transcode.c
index 1ec4a3c230..aa6594f4ec 100644
--- a/doc/examples/transcode.c
+++ b/doc/examples/transcode.c
@@ -161,8 +161,8 @@ static int open_output_file(const char *filename)
 /* in this example, we choose transcoding to same codec */
 encoder = avcodec_find_encoder(dec_ctx->codec_id);
 if (!encoder) {
-av_log(NULL, AV_LOG_FATAL, "Necessary encoder not found\n");
-return AVERROR_INVALIDDATA;
+av_log(NULL, AV_LOG_FATAL, "Necessary encoder with ID %d not 
found\n", dec_ctx->codec_id);
+return AVERROR(EINVAL);
 }
 enc_ctx = avcodec_alloc_context3(encoder);
 if (!enc_ctx) {
-- 
2.34.1

___
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".


[FFmpeg-devel] [PATCH 3/6] doc/examples/transcode: factorize codec_type definition

2023-09-01 Thread Stefano Sabatini
---
 doc/examples/transcode.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/doc/examples/transcode.c b/doc/examples/transcode.c
index 9af5674953..1ec4a3c230 100644
--- a/doc/examples/transcode.c
+++ b/doc/examples/transcode.c
@@ -82,6 +82,7 @@ static int open_input_file(const char *filename)
 AVStream *stream = ifmt_ctx->streams[i];
 const AVCodec *dec = avcodec_find_decoder(stream->codecpar->codec_id);
 AVCodecContext *codec_ctx;
+enum AVMediaType codec_type;
 
 if (!dec) {
 av_log(NULL, AV_LOG_ERROR, "Failed to find decoder for stream 
#%u\n", i);
@@ -105,11 +106,13 @@ static int open_input_file(const char *filename)
 /* Inform the decoder about the timebase for the packet timestamps.
  * This is highly recommended, but not mandatory. */
 codec_ctx->pkt_timebase = stream->time_base;
+codec_type = codec_ctx->codec_type;
 
 /* Reencode video & audio and remux subtitles etc. */
-if (codec_ctx->codec_type == AVMEDIA_TYPE_VIDEO || 
codec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
-if (codec_ctx->codec_type == AVMEDIA_TYPE_VIDEO)
+if (codec_type == AVMEDIA_TYPE_VIDEO || codec_type == 
AVMEDIA_TYPE_AUDIO) {
+if (codec_type == AVMEDIA_TYPE_VIDEO)
 codec_ctx->framerate = av_guess_frame_rate(ifmt_ctx, stream, 
NULL);
+
 /* Open decoder */
 ret = avcodec_open2(codec_ctx, dec, NULL);
 if (ret < 0) {
-- 
2.34.1

___
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".


[FFmpeg-devel] [PATCH 1/6] libavcodec/avcodec.h: fix typos in AVCodecContext.pkt_timebase description

2023-09-01 Thread Stefano Sabatini
---
 libavcodec/avcodec.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 649411ac79..070e36795d 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1794,9 +1794,9 @@ typedef struct AVCodecContext {
 enum AVPixelFormat sw_pix_fmt;
 
 /**
- * Timebase in which pkt_dts/pts and AVPacket.dts/pts are.
- * - encoding unused.
- * - decoding set by user.
+ * Timebase in which pkt_dts/pts and AVPacket.dts/pts are expressed.
+ * - encoding: unused.
+ * - decoding: set by user.
  */
 AVRational pkt_timebase;
 
-- 
2.34.1

___
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".


Re: [FFmpeg-devel] [PATCH v3] wmavoice: convert DCT-I/DST-I to lavu/tx

2023-09-01 Thread Lynne
Sep 1, 2023, 06:39 by d...@lynne.ee:

> Added a patch to fix scaling of R2R transforms and
> improved table generation precision slightly.
>
> Planning to push this at the end of today, as it has been
> on the mailing list for over a month with two LGTMs.
>

Pushed patchset along with the last version of the deprecation
patch.
Conformance of all of the new, as well as the old API can be tested
via the usual tool: https://github.com/cyanreg/lavu_fft_test
Thanks for all the reviews and opinions.
LTO builds should already see a substantial drop in file size.
As for the rest, the upcoming patches to remove the dead code
will take care of that.
___
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".


[FFmpeg-devel] [PATCH v4 13/13] avcodec/libx265: add support for writing out CLL and MDCV

2023-09-01 Thread Jan Ekström
The newer of these two are the separate integers for content light
level, introduced in 3952bf3e98c76c31594529a3fe34e056d3e3e2ea ,
with X265_BUILD 75. As we already require X265_BUILD of at least
89, no further conditions are required.
---
 libavcodec/libx265.c | 87 
 tests/fate/enc_external.mak  |  5 +++
 tests/ref/fate/libx265-hdr10 | 16 +++
 3 files changed, 108 insertions(+)
 create mode 100644 tests/ref/fate/libx265-hdr10

diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index 873b3021ee..eb4a42b06c 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -28,9 +28,11 @@
 #include 
 
 #include "libavutil/avassert.h"
+#include "libavutil/bprint.h"
 #include "libavutil/buffer.h"
 #include "libavutil/internal.h"
 #include "libavutil/common.h"
+#include "libavutil/mastering_display_metadata.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "avcodec.h"
@@ -179,6 +181,84 @@ static av_cold int libx265_param_parse_int(AVCodecContext 
*avctx,
 return 0;
 }
 
+static int handle_mdcv(const AVClass **avcl, const x265_api *api,
+   x265_param *params,
+   const AVMasteringDisplayMetadata *mdcv)
+{
+int ret = AVERROR_BUG;
+AVBPrint buf;
+av_bprint_init(, 0, AV_BPRINT_SIZE_AUTOMATIC);
+
+// G(%hu,%hu)B(%hu,%hu)R(%hu,%hu)WP(%hu,%hu)L(%u,%u)
+av_bprintf(
+,
+"G(%"PRId64",%"PRId64")B(%"PRId64",%"PRId64")R(%"PRId64",%"PRId64")"
+"WP(%"PRId64",%"PRId64")L(%"PRId64",%"PRId64")",
+av_rescale_q(1, mdcv->display_primaries[1][0], (AVRational){ 1, 5 
}),
+av_rescale_q(1, mdcv->display_primaries[1][1], (AVRational){ 1, 5 
}),
+av_rescale_q(1, mdcv->display_primaries[2][0], (AVRational){ 1, 5 
}),
+av_rescale_q(1, mdcv->display_primaries[2][1], (AVRational){ 1, 5 
}),
+av_rescale_q(1, mdcv->display_primaries[0][0], (AVRational){ 1, 5 
}),
+av_rescale_q(1, mdcv->display_primaries[0][1], (AVRational){ 1, 5 
}),
+av_rescale_q(1, mdcv->white_point[0], (AVRational){ 1, 5 }),
+av_rescale_q(1, mdcv->white_point[1], (AVRational){ 1, 5 }),
+av_rescale_q(1, mdcv->max_luminance,  (AVRational){ 1, 1 }),
+av_rescale_q(1, mdcv->min_luminance,  (AVRational){ 1, 1 }));
+
+if (!av_bprint_is_complete()) {
+av_log(avcl, AV_LOG_ERROR,
+  "MDCV string too long for its available space!\n");
+ret = AVERROR(ENOMEM);
+goto end;
+}
+
+if (api->param_parse(params, "master-display", buf.str) ==
+X265_PARAM_BAD_VALUE) {
+av_log(avcl, AV_LOG_ERROR,
+   "Invalid value \"%s\" for param \"master-display\".\n",
+   buf.str);
+ret = AVERROR(EINVAL);
+goto end;
+}
+
+ret = 0;
+
+end:
+av_bprint_finalize(, NULL);
+
+return ret;
+}
+
+static int handle_side_data(AVCodecContext *avctx, const x265_api *api,
+x265_param *params)
+{
+const AVFrameSideDataSet set = avctx->frame_sd_set;
+const AVFrameSideData *cll_sd =
+av_frame_side_data_set_get_item(
+set, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL);
+const AVFrameSideData *mdcv_sd =
+av_frame_side_data_set_get_item(
+set, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA);
+
+if (cll_sd) {
+const AVContentLightMetadata *cll =
+(AVContentLightMetadata *)cll_sd->data;
+
+params->maxCLL  = cll->MaxCLL;
+params->maxFALL = cll->MaxFALL;
+}
+
+if (mdcv_sd) {
+int ret = handle_mdcv(
+>av_class, api, params,
+(AVMasteringDisplayMetadata *)mdcv_sd->data);
+if (ret < 0)
+return ret;
+}
+
+return 0;
+}
+
 static av_cold int libx265_encode_init(AVCodecContext *avctx)
 {
 libx265Context *ctx = avctx->priv_data;
@@ -339,6 +419,13 @@ FF_ENABLE_DEPRECATION_WARNINGS
 return AVERROR_BUG;
 }
 
+ret = handle_side_data(avctx, ctx->api, ctx->params);
+if (ret < 0) {
+av_log(avctx, AV_LOG_ERROR, "Failed handling side data! (%s)\n",
+   av_err2str(ret));
+return ret;
+}
+
 if (ctx->crf >= 0) {
 char crf[6];
 
diff --git a/tests/fate/enc_external.mak b/tests/fate/enc_external.mak
index 4095a4b51a..30021efbcd 100644
--- a/tests/fate/enc_external.mak
+++ b/tests/fate/enc_external.mak
@@ -12,5 +12,10 @@ FATE_ENC_EXTERNAL-$(call ENCDEC, LIBX264 HEVC, MOV, 
LIBX264_HDR10 HEVC_DEMUXER H
 fate-libx264-hdr10: CMD = enc_external 
$(TARGET_SAMPLES)/hevc/hdr10_plus_h265_sample.hevc \
 mp4 "-c:v libx264" "-show_frames -show_entries frame=side_data_list -of 
flat"
 
+# test for x265 MDCV and CLL passthrough during encoding
+FATE_ENC_EXTERNAL-$(call ENCDEC, LIBX265 HEVC, MOV, HEVC_DEMUXER) += 
fate-libx265-hdr10
+fate-libx265-hdr10: CMD = enc_external 
$(TARGET_SAMPLES)/hevc/hdr10_plus_h265_sample.hevc \
+mp4 

[FFmpeg-devel] [PATCH v4 12/13] avcodec/libx264: add support for writing out CLL and MDCV

2023-09-01 Thread Jan Ekström
Both of these two structures were first available with X264_BUILD
163, so make relevant functionality conditional on the version
being at least such.

Keep handle_side_data available in all cases as this way X264_init
does not require additional version based conditions within it.

Finally, add a FATE test which verifies that pass-through of the
MDCV/CLL side data is working during encoding.
---
 configure|  2 +
 libavcodec/libx264.c | 78 
 tests/fate/enc_external.mak  |  5 +++
 tests/ref/fate/libx264-hdr10 | 15 +++
 4 files changed, 100 insertions(+)
 create mode 100644 tests/ref/fate/libx264-hdr10

diff --git a/configure b/configure
index bd7f7697c8..432f2f8144 100755
--- a/configure
+++ b/configure
@@ -2518,6 +2518,7 @@ CONFIG_EXTRA="
 jpegtables
 lgplv3
 libx262
+libx264_hdr10
 llauddsp
 llviddsp
 llvidencdsp
@@ -6844,6 +6845,7 @@ enabled libx264   && require_pkg_config libx264 
x264 "stdint.h x264.h" x
  require_cpp_condition libx264 x264.h "X264_BUILD 
>= 122" && {
  [ "$toolchain" != "msvc" ] ||
  require_cpp_condition libx264 x264.h "X264_BUILD 
>= 158"; } &&
+ check_cpp_condition libx264_hdr10 x264.h 
"X264_BUILD >= 163" &&
  check_cpp_condition libx262 x264.h "X264_MPEG2"
 enabled libx265   && require_pkg_config libx265 x265 x265.h 
x265_api_get &&
  require_cpp_condition libx265 x265.h "X265_BUILD 
>= 89"
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index ce849d6c9a..f311c7b087 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -25,6 +25,7 @@
 #include "libavutil/eval.h"
 #include "libavutil/internal.h"
 #include "libavutil/opt.h"
+#include "libavutil/mastering_display_metadata.h"
 #include "libavutil/mem.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/stereo3d.h"
@@ -842,6 +843,81 @@ static int convert_pix_fmt(enum AVPixelFormat pix_fmt)
 return AVERROR(EINVAL);\
 }
 
+#if CONFIG_LIBX264_HDR10
+static void handle_mdcv(x264_param_t *params,
+const AVMasteringDisplayMetadata *mdcv)
+{
+if (!mdcv->has_primaries && !mdcv->has_luminance)
+return;
+
+params->mastering_display.b_mastering_display = 1;
+
+if (mdcv->has_primaries) {
+int *const points[][2] = {
+{
+>mastering_display.i_red_x,
+>mastering_display.i_red_y
+},
+{
+>mastering_display.i_green_x,
+>mastering_display.i_green_y
+},
+{
+>mastering_display.i_blue_x,
+>mastering_display.i_blue_y
+},
+};
+
+for (int i = 0; i < 3; i++) {
+const AVRational *src = mdcv->display_primaries[i];
+int *dst[2] = { points[i][0], points[i][1] };
+
+*dst[0] = av_rescale_q(1, src[0], (AVRational){ 1, 5 });
+*dst[1] = av_rescale_q(1, src[1], (AVRational){ 1, 5 });
+}
+
+params->mastering_display.i_white_x =
+av_rescale_q(1, mdcv->white_point[0], (AVRational){ 1, 5 });
+params->mastering_display.i_white_y =
+av_rescale_q(1, mdcv->white_point[1], (AVRational){ 1, 5 });
+}
+
+if (mdcv->has_luminance) {
+params->mastering_display.i_display_max =
+av_rescale_q(1, mdcv->max_luminance, (AVRational){ 1, 1 });
+params->mastering_display.i_display_min =
+av_rescale_q(1, mdcv->min_luminance, (AVRational){ 1, 1 });
+}
+}
+#endif // CONFIG_LIBX264_HDR10
+
+static void handle_side_data(AVCodecContext *avctx, x264_param_t *params)
+{
+#if CONFIG_LIBX264_HDR10
+const AVFrameSideDataSet set = avctx->frame_sd_set;
+const AVFrameSideData *cll_sd =
+av_frame_side_data_set_get_item(
+set, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL);
+const AVFrameSideData *mdcv_sd =
+av_frame_side_data_set_get_item(
+set, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA);
+
+if (cll_sd) {
+const AVContentLightMetadata *cll =
+(AVContentLightMetadata *)cll_sd->data;
+
+params->content_light_level.i_max_cll  = cll->MaxCLL;
+params->content_light_level.i_max_fall = cll->MaxFALL;
+
+params->content_light_level.b_cll = 1;
+}
+
+if (mdcv_sd) {
+handle_mdcv(params, (AVMasteringDisplayMetadata *)mdcv_sd->data);
+}
+#endif // CONFIG_LIBX264_HDR10
+}
+
 static av_cold int X264_init(AVCodecContext *avctx)
 {
 X264Context *x4 = avctx->priv_data;
@@ -1142,6 +1218,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
 if (avctx->chroma_sample_location != AVCHROMA_LOC_UNSPECIFIED)
 x4->params.vui.i_chroma_loc = avctx->chroma_sample_location - 1;
 
+handle_side_data(avctx, >params);
+
 if 

[FFmpeg-devel] [PATCH v4 11/13] avcodec/libsvtav1: add support for writing out CLL and MDCV

2023-09-01 Thread Jan Ekström
These two were added in 28e23d7f348c78d49a726c7469f9d4e38edec341
and 3558c1f2e97455e0b89edef31b9a72ab7fa30550 for version 0.9.0 of
SVT-AV1, which is also our minimum requirement right now.

In other words, no additional version limiting conditions seem
to be required.

Additionally, add a FATE test which verifies that pass-through of
the MDCV/CLL side data is working during encoding.
---
 libavcodec/libsvtav1.c | 67 ++
 tests/fate/enc_external.mak|  5 +++
 tests/ref/fate/libsvtav1-hdr10 | 14 +++
 3 files changed, 86 insertions(+)
 create mode 100644 tests/ref/fate/libsvtav1-hdr10

diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c
index f2b73361d8..a56845c078 100644
--- a/libavcodec/libsvtav1.c
+++ b/libavcodec/libsvtav1.c
@@ -27,6 +27,8 @@
 #include "libavutil/common.h"
 #include "libavutil/frame.h"
 #include "libavutil/imgutils.h"
+#include "libavutil/intreadwrite.h"
+#include "libavutil/mastering_display_metadata.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/avassert.h"
@@ -146,6 +148,69 @@ static int alloc_buffer(EbSvtAv1EncConfiguration *config, 
SvtContext *svt_enc)
 
 }
 
+static void handle_mdcv(struct EbSvtAv1MasteringDisplayInfo *dst,
+const AVMasteringDisplayMetadata *mdcv)
+{
+if (mdcv->has_primaries) {
+const struct EbSvtAv1ChromaPoints *const points[] = {
+>r,
+>g,
+>b,
+};
+
+for (int i = 0; i < 3; i++) {
+const struct EbSvtAv1ChromaPoints *dst = points[i];
+const AVRational *src = mdcv->display_primaries[i];
+
+AV_WB16(>x,
+av_rescale_q(1, src[0], (AVRational){ 1, (1 << 16) }));
+AV_WB16(>y,
+av_rescale_q(1, src[1], (AVRational){ 1, (1 << 16) }));
+}
+
+AV_WB16(>white_point.x,
+av_rescale_q(1, mdcv->white_point[0],
+ (AVRational){ 1, (1 << 16) }));
+AV_WB16(>white_point.y,
+av_rescale_q(1, mdcv->white_point[1],
+ (AVRational){ 1, (1 << 16) }));
+}
+
+if (mdcv->has_luminance) {
+AV_WB32(>max_luma,
+av_rescale_q(1, mdcv->max_luminance,
+ (AVRational){ 1, (1 << 8) }));
+AV_WB32(>min_luma,
+av_rescale_q(1, mdcv->min_luminance,
+ (AVRational){ 1, (1 << 14) }));
+}
+}
+
+static void handle_side_data(AVCodecContext *avctx,
+ EbSvtAv1EncConfiguration *param)
+{
+const AVFrameSideDataSet set = avctx->frame_sd_set;
+const AVFrameSideData *cll_sd =
+av_frame_side_data_set_get_item(
+set, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL);
+const AVFrameSideData *mdcv_sd =
+av_frame_side_data_set_get_item(
+set, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA);
+
+if (cll_sd) {
+const AVContentLightMetadata *cll =
+(AVContentLightMetadata *)cll_sd->data;
+
+AV_WB16(>content_light_level.max_cll, cll->MaxCLL);
+AV_WB16(>content_light_level.max_fall, cll->MaxFALL);
+}
+
+if (mdcv_sd) {
+handle_mdcv(>mastering_display,
+(AVMasteringDisplayMetadata *)mdcv_sd->data);
+}
+}
+
 static int config_enc_params(EbSvtAv1EncConfiguration *param,
  AVCodecContext *avctx)
 {
@@ -273,6 +338,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
 /* 2 = IDR, closed GOP, 1 = CRA, open GOP */
 param->intra_refresh_type = avctx->flags & AV_CODEC_FLAG_CLOSED_GOP ? 2 : 
1;
 
+handle_side_data(avctx, param);
+
 #if SVT_AV1_CHECK_VERSION(0, 9, 1)
 while ((en = av_dict_get(svt_enc->svtav1_opts, "", en, 
AV_DICT_IGNORE_SUFFIX))) {
 EbErrorType ret = svt_av1_enc_parse_parameter(param, en->key, 
en->value);
diff --git a/tests/fate/enc_external.mak b/tests/fate/enc_external.mak
index 7eabebcc51..d787941c16 100644
--- a/tests/fate/enc_external.mak
+++ b/tests/fate/enc_external.mak
@@ -2,5 +2,10 @@ FATE_ENC_EXTERNAL-$(call ENCDEC, LIBX264 H264, MOV, 
H264_DEMUXER) += fate-libx26
 fate-libx264-simple: CMD = enc_external 
$(TARGET_SAMPLES)/h264-conformance/BA1_Sony_D.jsv \
 mp4 "-c:v libx264" "-show_entries frame=width,height,pix_fmt,pts,pkt_dts 
-of flat"
 
+# test for SVT-AV1 MDCV and CLL passthrough during encoding
+FATE_ENC_EXTERNAL-$(call ENCDEC, LIBSVTAV1 HEVC, MOV, HEVC_DEMUXER 
LIBDAV1D_DECODER) += fate-libsvtav1-hdr10
+fate-libsvtav1-hdr10: CMD = enc_external 
$(TARGET_SAMPLES)/hevc/hdr10_plus_h265_sample.hevc \
+mp4 "-c:v libsvtav1" "-show_frames -show_entries frame=side_data_list -of 
flat"
+
 FATE_SAMPLES_FFMPEG_FFPROBE += $(FATE_ENC_EXTERNAL-yes)
 fate-enc-external: $(FATE_ENC_EXTERNAL-yes)
diff --git a/tests/ref/fate/libsvtav1-hdr10 b/tests/ref/fate/libsvtav1-hdr10
new file mode 100644
index 00..6f0d34903b
--- /dev/null
+++ 

[FFmpeg-devel] [PATCH v4 10/13] ffmpeg: pass first video AVFrame's side data to encoder

2023-09-01 Thread Jan Ekström
This enables further configuration of output based on the results
of input decoding and filtering in a similar manner as the color
information.
---
 fftools/ffmpeg_enc.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c
index f28884e50c..0d022700cf 100644
--- a/fftools/ffmpeg_enc.c
+++ b/fftools/ffmpeg_enc.c
@@ -356,6 +356,19 @@ int enc_open(OutputStream *ost, AVFrame *frame)
 enc_ctx->colorspace = frame->colorspace;
 enc_ctx->chroma_sample_location = frame->chroma_location;
 
+ret = av_frame_side_data_set_extend(
+_ctx->frame_sd_set,
+(const AVFrameSideDataSet){
+.sd= frame->side_data,
+.nb_sd = frame->nb_side_data
+},
+AV_FRAME_SIDE_DATA_SET_FLAG_NO_DUPLICATES);
+if (ret < 0) {
+av_log(NULL, AV_LOG_ERROR, "failed to configure video encoder: 
%s!\n",
+   av_err2str(ret));
+return ret;
+}
+
 // Field order: autodetection
 if (enc_ctx->flags & (AV_CODEC_FLAG_INTERLACED_DCT | 
AV_CODEC_FLAG_INTERLACED_ME) &&
 ost->top_field_first >= 0)
-- 
2.41.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".


[FFmpeg-devel] [PATCH v4 09/13] avcodec: add side data set to AVCodecContext

2023-09-01 Thread Jan Ekström
This allows configuring an encoder by using AVFrameSideData.
---
 libavcodec/avcodec.h | 7 +++
 libavcodec/options.c | 1 +
 2 files changed, 8 insertions(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 649411ac79..ce673a4e65 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2100,6 +2100,13 @@ typedef struct AVCodecContext {
  *   an error.
  */
 int64_t frame_num;
+
+/**
+ * Set containing static side data, such as HDR10 CLL / MDCV structures.
+ * - encoding: set by user
+ * - decoding: unused
+ */
+AVFrameSideDataSet frame_sd_set;
 } AVCodecContext;
 
 /**
diff --git a/libavcodec/options.c b/libavcodec/options.c
index a9b35ee1c3..e42a29e834 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -180,6 +180,7 @@ void avcodec_free_context(AVCodecContext **pavctx)
 av_freep(>inter_matrix);
 av_freep(>rc_override);
 av_channel_layout_uninit(>ch_layout);
+av_frame_side_data_set_uninit(>frame_sd_set);
 
 av_freep(pavctx);
 }
-- 
2.41.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".


[FFmpeg-devel] [PATCH v4 08/13] avutil/frame: add helper for extending a set of side data

2023-09-01 Thread Jan Ekström
Additionally, extend the side data set FATE test to check for the
invalid use case of extending a set by itself.
---
 libavutil/frame.c   | 32 
 libavutil/frame.h   | 15 +++
 libavutil/tests/side_data_set.c | 16 
 tests/ref/fate/side_data_set|  7 +++
 4 files changed, 70 insertions(+)

diff --git a/libavutil/frame.c b/libavutil/frame.c
index 5f74e0172b..898c749631 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -879,6 +879,38 @@ AVFrameSideData 
*av_frame_side_data_set_new_item(AVFrameSideDataSet *set,
 return ret;
 }
 
+int av_frame_side_data_set_extend(AVFrameSideDataSet *dst,
+  const AVFrameSideDataSet src,
+  unsigned int flags)
+{
+if (src.nb_sd > 0 && src.nb_sd == dst->nb_sd &&
+src.sd == dst->sd)
+return AVERROR(EINVAL);
+
+for (int i = 0; i < src.nb_sd; i++) {
+const AVFrameSideData *sd_src = src.sd[i];
+AVBufferRef   *buf= av_buffer_ref(sd_src->buf);
+AVFrameSideData   *sd_dst =
+add_side_data_to_set_from_buf(dst, sd_src->type, buf);
+if (!sd_dst) {
+av_buffer_unref();
+av_frame_side_data_set_uninit(dst);
+return AVERROR(ENOMEM);
+}
+
+{
+int ret = av_dict_copy(_dst->metadata, sd_src->metadata, 0);
+if (ret < 0) {
+av_frame_side_data_set_uninit(dst);
+return ret;
+}
+}
+
+}
+
+return 0;
+}
+
 AVFrameSideData *av_frame_side_data_set_get_item(const AVFrameSideDataSet set,
  enum AVFrameSideDataType type)
 {
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 8ecdf82f33..e16941c5a5 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -1085,6 +1085,21 @@ AVFrameSideData 
*av_frame_side_data_set_new_item(AVFrameSideDataSet *set,
  size_t size,
  unsigned int flags);
 
+/**
+ * Add multiple side data entries to a set in one go.
+ *
+ * @param dst a set to which the side data should be added
+ * @param src a set from which the side data should be copied from
+ * @param flags Some combination of AV_FRAME_SIDE_DATA_SET_FLAG_* flags, or 0.
+ *
+ * @return negative error code on failure, >=0 on success.
+ *
+ * @see av_frame_side_data_set_new_item regarding the flags.
+ */
+int av_frame_side_data_set_extend(AVFrameSideDataSet *dst,
+  const AVFrameSideDataSet src,
+  unsigned int flags);
+
 /**
  * Get a side data entry of a specific type from a set.
  *
diff --git a/libavutil/tests/side_data_set.c b/libavutil/tests/side_data_set.c
index 056d79f655..0c9ceed962 100644
--- a/libavutil/tests/side_data_set.c
+++ b/libavutil/tests/side_data_set.c
@@ -91,6 +91,22 @@ int main(void)
 puts("\nFinal state after a single 'no-duplicates' addition:");
 print_clls(set);
 
+{
+AVFrameSideDataSet dst_set = { 0 };
+av_assert0(av_frame_side_data_set_extend(_set, set, 0) >= 0);
+
+puts("\nState of the copied set:");
+print_clls(dst_set);
+
+av_frame_side_data_set_uninit(_set);
+}
+
+{
+int ret = av_frame_side_data_set_extend(, set, 0);
+printf("\nResult of trying to extend a set by itself: %s\n",
+   av_err2str(ret));
+}
+
 av_frame_side_data_set_uninit();
 
 return 0;
diff --git a/tests/ref/fate/side_data_set b/tests/ref/fate/side_data_set
index 7d8c684d8f..3050b31014 100644
--- a/tests/ref/fate/side_data_set
+++ b/tests/ref/fate/side_data_set
@@ -12,3 +12,10 @@ Final state after a single 'no-duplicates' addition:
 sd 0, Ambient viewing environment
 sd 1, Spherical Mapping
 sd 2, Content light level metadata: MaxCLL: 1337
+
+State of the copied set:
+sd 0, Ambient viewing environment
+sd 1, Spherical Mapping
+sd 2, Content light level metadata: MaxCLL: 1337
+
+Result of trying to extend a set by itself: Invalid argument
-- 
2.41.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".


[FFmpeg-devel] [PATCH v4 07/13] avutil/frame: add helper for getting side data from set

2023-09-01 Thread Jan Ekström
---
 libavutil/frame.c | 22 +-
 libavutil/frame.h | 12 
 2 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/libavutil/frame.c b/libavutil/frame.c
index f64ddb3645..5f74e0172b 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -879,16 +879,28 @@ AVFrameSideData 
*av_frame_side_data_set_new_item(AVFrameSideDataSet *set,
 return ret;
 }
 
-AVFrameSideData *av_frame_get_side_data(const AVFrame *frame,
-enum AVFrameSideDataType type)
+AVFrameSideData *av_frame_side_data_set_get_item(const AVFrameSideDataSet set,
+ enum AVFrameSideDataType type)
 {
-for (int i = 0; i < frame->nb_side_data; i++) {
-if (frame->side_data[i]->type == type)
-return frame->side_data[i];
+for (int i = 0; i < set.nb_sd; i++) {
+if (set.sd[i]->type == type)
+return set.sd[i];
 }
 return NULL;
 }
 
+AVFrameSideData *av_frame_get_side_data(const AVFrame *frame,
+enum AVFrameSideDataType type)
+{
+return av_frame_side_data_set_get_item(
+(const AVFrameSideDataSet){
+.sd= frame->side_data,
+.nb_sd = frame->nb_side_data
+},
+type
+);
+}
+
 static int frame_copy_video(AVFrame *dst, const AVFrame *src)
 {
 const uint8_t *src_data[4];
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 5aed08b796..8ecdf82f33 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -1085,6 +1085,18 @@ AVFrameSideData 
*av_frame_side_data_set_new_item(AVFrameSideDataSet *set,
  size_t size,
  unsigned int flags);
 
+/**
+ * Get a side data entry of a specific type from a set.
+ *
+ * @param set the set from which side data should be queried from
+ * @param type type of side data to be queried
+ *
+ * @return a pointer to the side data of a given type on success, NULL if there
+ * is no side data with such type in this set.
+ */
+AVFrameSideData *av_frame_side_data_set_get_item(const AVFrameSideDataSet set,
+ enum AVFrameSideDataType 
type);
+
 /**
  * @}
  */
-- 
2.41.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".


[FFmpeg-devel] [PATCH v4 06/13] avutil/frame: add helper for adding side data to set

2023-09-01 Thread Jan Ekström
Additionally, add an API test to check that the no-duplicates
addition works after duplicates have been inserted.
---
 libavutil/Makefile  |  1 +
 libavutil/frame.c   | 18 ++
 libavutil/frame.h   | 20 +++
 libavutil/tests/side_data_set.c | 97 +
 tests/fate/libavutil.mak|  4 ++
 tests/ref/fate/side_data_set| 14 +
 6 files changed, 154 insertions(+)
 create mode 100644 libavutil/tests/side_data_set.c
 create mode 100644 tests/ref/fate/side_data_set

diff --git a/libavutil/Makefile b/libavutil/Makefile
index 7828c94dc5..339eaf3539 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -264,6 +264,7 @@ TESTPROGS = adler32 
\
 ripemd  \
 sha \
 sha512  \
+side_data_set   \
 softfloat   \
 tree\
 twofish \
diff --git a/libavutil/frame.c b/libavutil/frame.c
index 0b1a8e5244..f64ddb3645 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -861,6 +861,24 @@ AVFrameSideData *av_frame_new_side_data(AVFrame *frame,
 return ret;
 }
 
+AVFrameSideData *av_frame_side_data_set_new_item(AVFrameSideDataSet *set,
+ enum AVFrameSideDataType type,
+ size_t size,
+ unsigned int flags)
+{
+AVBufferRef *buf = av_buffer_alloc(size);
+AVFrameSideData *ret = NULL;
+
+if (flags & AV_FRAME_SIDE_DATA_SET_FLAG_NO_DUPLICATES)
+remove_side_data(>sd, >nb_sd, type);
+
+ret = add_side_data_to_set_from_buf(set, type, buf);
+if (!ret)
+av_buffer_unref();
+
+return ret;
+}
+
 AVFrameSideData *av_frame_get_side_data(const AVFrame *frame,
 enum AVFrameSideDataType type)
 {
diff --git a/libavutil/frame.h b/libavutil/frame.h
index dc87d38adc..5aed08b796 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -1065,6 +1065,26 @@ const char *av_frame_side_data_name(enum 
AVFrameSideDataType type);
  */
 void av_frame_side_data_set_uninit(AVFrameSideDataSet *set);
 
+#define AV_FRAME_SIDE_DATA_SET_FLAG_NO_DUPLICATES (1 << 0)
+
+/**
+ * Add a new side data entry to a set.
+ *
+ * @param set a set to which the side data should be added
+ * @param type type of the added side data
+ * @param size size of the side data
+ * @param flags Some combination of AV_FRAME_SIDE_DATA_SET_FLAG_* flags, or 0.
+ *
+ * @return newly added side data on success, NULL on error. In case of
+ * AV_FRAME_SIDE_DATA_SET_FLAG_NO_DUPLICATES being set, entries
+ * of matching AVFrameSideDataType will be removed before the
+ * addition is attempted.
+ */
+AVFrameSideData *av_frame_side_data_set_new_item(AVFrameSideDataSet *set,
+ enum AVFrameSideDataType type,
+ size_t size,
+ unsigned int flags);
+
 /**
  * @}
  */
diff --git a/libavutil/tests/side_data_set.c b/libavutil/tests/side_data_set.c
new file mode 100644
index 00..056d79f655
--- /dev/null
+++ b/libavutil/tests/side_data_set.c
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2023 Jan Ekström 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+#include "libavutil/frame.c"
+#include "libavutil/mastering_display_metadata.h"
+
+static void print_clls(const AVFrameSideDataSet set)
+{
+for (int i = 0; i < set.nb_sd; i++) {
+AVFrameSideData *sd = set.sd[i];
+
+printf("sd %d, %s",
+   i, av_frame_side_data_name(sd->type));
+
+if (sd->type != AV_FRAME_DATA_CONTENT_LIGHT_LEVEL) {
+putchar('\n');
+continue;
+}
+
+printf(": MaxCLL: %u\n",
+ 

[FFmpeg-devel] [PATCH v4 05/13] avutil/frame: split side data removal out to non-AVFrame function

2023-09-01 Thread Jan Ekström
This will make it possible to reuse logic in further commits.
---
 libavutil/frame.c | 24 
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/libavutil/frame.c b/libavutil/frame.c
index 9eff851d64..0b1a8e5244 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -95,6 +95,21 @@ void av_frame_side_data_set_uninit(AVFrameSideDataSet *set)
 wipe_side_data(>sd, >nb_sd);
 }
 
+static void remove_side_data(AVFrameSideData ***sd, int *nb_side_data,
+ const enum AVFrameSideDataType type)
+{
+for (int i = *nb_side_data - 1; i >= 0; i--) {
+AVFrameSideData *entry = ((*sd)[i]);
+if (entry->type != type)
+continue;
+
+free_side_data();
+
+((*sd)[i]) = ((*sd)[*nb_side_data - 1]);
+(*nb_side_data)--;
+}
+}
+
 AVFrame *av_frame_alloc(void)
 {
 AVFrame *frame = av_malloc(sizeof(*frame));
@@ -945,14 +960,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
 void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type)
 {
-for (int i = frame->nb_side_data - 1; i >= 0; i--) {
-AVFrameSideData *sd = frame->side_data[i];
-if (sd->type == type) {
-free_side_data(>side_data[i]);
-frame->side_data[i] = frame->side_data[frame->nb_side_data - 1];
-frame->nb_side_data--;
-}
-}
+remove_side_data(>side_data, >nb_side_data, type);
 }
 
 const char *av_frame_side_data_name(enum AVFrameSideDataType type)
-- 
2.41.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".


[FFmpeg-devel] [PATCH v4 04/13] avutil/frame: split side_data_from_buf to base and AVFrame func

2023-09-01 Thread Jan Ekström
---
 libavutil/frame.c | 31 +++
 1 file changed, 23 insertions(+), 8 deletions(-)

diff --git a/libavutil/frame.c b/libavutil/frame.c
index b03f8d6c73..9eff851d64 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -787,23 +787,22 @@ FF_ENABLE_DEPRECATION_WARNINGS
 return NULL;
 }
 
-AVFrameSideData *av_frame_new_side_data_from_buf(AVFrame *frame,
- enum AVFrameSideDataType type,
- AVBufferRef *buf)
+static AVFrameSideData *add_side_data_to_set_from_buf(AVFrameSideDataSet *set,
+  enum AVFrameSideDataType 
type,
+  AVBufferRef *buf)
 {
 AVFrameSideData *ret, **tmp;
 
 if (!buf)
 return NULL;
 
-if (frame->nb_side_data > INT_MAX / sizeof(*frame->side_data) - 1)
+if (set->nb_sd > INT_MAX / sizeof(*set->sd) - 1)
 return NULL;
 
-tmp = av_realloc(frame->side_data,
- (frame->nb_side_data + 1) * sizeof(*frame->side_data));
+tmp = av_realloc(set->sd, (set->nb_sd + 1) * sizeof(*set->sd));
 if (!tmp)
 return NULL;
-frame->side_data = tmp;
+set->sd = tmp;
 
 ret = av_mallocz(sizeof(*ret));
 if (!ret)
@@ -814,7 +813,23 @@ AVFrameSideData *av_frame_new_side_data_from_buf(AVFrame 
*frame,
 ret->size = buf->size;
 ret->type = type;
 
-frame->side_data[frame->nb_side_data++] = ret;
+set->sd[set->nb_sd++] = ret;
+
+return ret;
+}
+
+AVFrameSideData *av_frame_new_side_data_from_buf(AVFrame *frame,
+ enum AVFrameSideDataType type,
+ AVBufferRef *buf)
+{
+AVFrameSideDataSet set = {
+.sd= frame->side_data,
+.nb_sd = frame->nb_side_data,
+};
+AVFrameSideData *ret = add_side_data_to_set_from_buf(, type, buf);
+
+frame->side_data= set.sd;
+frame->nb_side_data = set.nb_sd;
 
 return ret;
 }
-- 
2.41.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".


[FFmpeg-devel] [PATCH v4 03/13] avutil/frame: add helper for uninitializing side data sets

2023-09-01 Thread Jan Ekström
---
 libavutil/frame.c | 5 +
 libavutil/frame.h | 8 
 2 files changed, 13 insertions(+)

diff --git a/libavutil/frame.c b/libavutil/frame.c
index 4b8481b756..b03f8d6c73 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -90,6 +90,11 @@ static void frame_side_data_wipe(AVFrame *frame)
 wipe_side_data(>side_data, >nb_side_data);
 }
 
+void av_frame_side_data_set_uninit(AVFrameSideDataSet *set)
+{
+wipe_side_data(>sd, >nb_sd);
+}
+
 AVFrame *av_frame_alloc(void)
 {
 AVFrame *frame = av_malloc(sizeof(*frame));
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 6155226c1d..dc87d38adc 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -1057,6 +1057,14 @@ int av_frame_apply_cropping(AVFrame *frame, int flags);
  */
 const char *av_frame_side_data_name(enum AVFrameSideDataType type);
 
+/**
+ * Free all side data items and their contents, then zeroes out the
+ * struct values.
+ *
+ * @param set the set which should be uninitialized
+ */
+void av_frame_side_data_set_uninit(AVFrameSideDataSet *set);
+
 /**
  * @}
  */
-- 
2.41.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".


[FFmpeg-devel] [PATCH v4 02/13] avutil/frame: split side data list wiping out to non-AVFrame function

2023-09-01 Thread Jan Ekström
This will make it possible to to reuse logic in further commits.
---
 libavutil/frame.c | 23 ++-
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/libavutil/frame.c b/libavutil/frame.c
index b6cee2d886..4b8481b756 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -75,14 +75,19 @@ static void free_side_data(AVFrameSideData **ptr_sd)
 av_freep(ptr_sd);
 }
 
-static void wipe_side_data(AVFrame *frame)
+static void wipe_side_data(AVFrameSideData ***sd, int *nb_side_data)
 {
-for (int i = 0; i < frame->nb_side_data; i++) {
-free_side_data(>side_data[i]);
+for (int i = 0; i < *nb_side_data; i++) {
+free_side_data(&((*sd)[i]));
 }
-frame->nb_side_data = 0;
+*nb_side_data = 0;
+
+av_freep(sd);
+}
 
-av_freep(>side_data);
+static void frame_side_data_wipe(AVFrame *frame)
+{
+wipe_side_data(>side_data, >nb_side_data);
 }
 
 AVFrame *av_frame_alloc(void)
@@ -337,7 +342,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 sd_dst = av_frame_new_side_data(dst, sd_src->type,
 sd_src->size);
 if (!sd_dst) {
-wipe_side_data(dst);
+frame_side_data_wipe(dst);
 return AVERROR(ENOMEM);
 }
 memcpy(sd_dst->data, sd_src->data, sd_src->size);
@@ -346,7 +351,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 sd_dst = av_frame_new_side_data_from_buf(dst, sd_src->type, ref);
 if (!sd_dst) {
 av_buffer_unref();
-wipe_side_data(dst);
+frame_side_data_wipe(dst);
 return AVERROR(ENOMEM);
 }
 }
@@ -525,7 +530,7 @@ FF_DISABLE_DEPRECATION_WARNINGS
 FF_ENABLE_DEPRECATION_WARNINGS
 #endif
 
-wipe_side_data(dst);
+frame_side_data_wipe(dst);
 av_dict_free(>metadata);
 ret = frame_copy_props(dst, src, 0);
 if (ret < 0)
@@ -624,7 +629,7 @@ void av_frame_unref(AVFrame *frame)
 if (!frame)
 return;
 
-wipe_side_data(frame);
+frame_side_data_wipe(frame);
 
 for (int i = 0; i < FF_ARRAY_ELEMS(frame->buf); i++)
 av_buffer_unref(>buf[i]);
-- 
2.41.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".


[FFmpeg-devel] [PATCH v4 00/13] encoder AVCodecContext configuration side data

2023-09-01 Thread Jan Ekström
Differences to v3:
1. rebased on top of current master
2. limited libx264 HDR10 metadata FATE test to BUILD >=163
3. renamed the set variable to `frame_sd_set` as per request from James on IRC
4. adopted various things noted by Andreas in reviews for various patches
5. extended side data set FATE test to also test av_frame_side_data_set_extend

Comparison URL (mostly configure and wrappers, avutil/frame.c):
https://github.com/jeeb/ffmpeg/compare/avcodec_cll_mdcv_side_data_v3..avcodec_cll_mdcv_side_data_v4

This patch set I've now been working for a while since I felt like it was weird
we couldn't pass through information such as static HDR metadata to encoders
from decoded input. This initial version adds the necessary framework, as well
as adds static HDR metadata support for libsvtav1, libx264 as well as libx265
wrappers.

An alternative to this would be to make encoders only properly initialize when
they receive the first AVFrame, but that seems to be a bigger, nastier change
than introducing an AVFrameSideDataSet in avctx as everything seems to
presume that extradata etc are available after opening the encoder.

Note: Any opinions on whether FFCodec or AVCodec should have
  handled_side_data list, so that if format specific generic logic is
  added, it could be checked whether the codec itself handles this side
  data? This could also be utilized to list handled side data from f.ex.
  `ffmpeg -h encoder=libsvtav1`.

Jan

Jan Ekström (13):
  avutil/frame: add AVFrameSideDataSet for passing sets of side data
  avutil/frame: split side data list wiping out to non-AVFrame function
  avutil/frame: add helper for uninitializing side data sets
  avutil/frame: split side_data_from_buf to base and AVFrame func
  avutil/frame: split side data removal out to non-AVFrame function
  avutil/frame: add helper for adding side data to set
  avutil/frame: add helper for getting side data from set
  avutil/frame: add helper for extending a set of side data
  avcodec: add side data set to AVCodecContext
  ffmpeg: pass first video AVFrame's side data to encoder
  avcodec/libsvtav1: add support for writing out CLL and MDCV
  avcodec/libx264: add support for writing out CLL and MDCV
  avcodec/libx265: add support for writing out CLL and MDCV

 configure   |   2 +
 fftools/ffmpeg_enc.c|  13 +++
 libavcodec/avcodec.h|   7 ++
 libavcodec/libsvtav1.c  |  67 ++
 libavcodec/libx264.c|  78 
 libavcodec/libx265.c|  87 ++
 libavcodec/options.c|   1 +
 libavutil/Makefile  |   1 +
 libavutil/frame.c   | 155 +---
 libavutil/frame.h   |  63 +
 libavutil/tests/side_data_set.c | 113 +++
 tests/fate/enc_external.mak |  15 
 tests/fate/libavutil.mak|   4 +
 tests/ref/fate/libsvtav1-hdr10  |  14 +++
 tests/ref/fate/libx264-hdr10|  15 
 tests/ref/fate/libx265-hdr10|  16 
 tests/ref/fate/side_data_set|  21 +
 17 files changed, 642 insertions(+), 30 deletions(-)
 create mode 100644 libavutil/tests/side_data_set.c
 create mode 100644 tests/ref/fate/libsvtav1-hdr10
 create mode 100644 tests/ref/fate/libx264-hdr10
 create mode 100644 tests/ref/fate/libx265-hdr10
 create mode 100644 tests/ref/fate/side_data_set

-- 
2.41.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".


[FFmpeg-devel] [PATCH v4 01/13] avutil/frame: add AVFrameSideDataSet for passing sets of side data

2023-09-01 Thread Jan Ekström
---
 libavutil/frame.h | 8 
 1 file changed, 8 insertions(+)

diff --git a/libavutil/frame.h b/libavutil/frame.h
index c0c1b23db7..6155226c1d 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -251,6 +251,14 @@ typedef struct AVFrameSideData {
 AVBufferRef *buf;
 } AVFrameSideData;
 
+/**
+ * Structure to hold a set of AVFrameSideData
+ */
+typedef struct AVFrameSideDataSet {
+AVFrameSideData **sd;
+intnb_sd;
+} AVFrameSideDataSet;
+
 /**
  * Structure describing a single Region Of Interest.
  *
-- 
2.41.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".


Re: [FFmpeg-devel] [PATCH] lsws/swscale.h: introduce sws_get_gaussian_vec

2023-09-01 Thread Stefano Sabatini
On date Friday 2023-09-01 18:54:40 +0200, Michael Niedermayer wrote:
> On Thu, Aug 31, 2023 at 07:16:20PM +0200, Stefano Sabatini wrote:
[...]
> > +/**
> > + * Compute and return a normalized Gaussian vector.
> > + *
> > + * @param vecp: pointer where the computed vector is put in case of
> > + *success
> > + * @param standard_deviation the standard deviation used to generate
> > + *the Gaussian vector, must be a non-negative value
> > + * @param quality the quality of the generated Gaussian vector, must
> > + *be a non-negative value. It affects the lenght of the generated
> > + *vector. A value equal to 3 corresponds to high quality.
> > + * @param log_ctx a pointer to an arbitrary struct of which the first
> > + *field is a pointer to an AVClass struct (used for av_log)
> > + *used for logging, can be NULL
> > + *
> > + * @return a negative error code on error, non negative otherwise
> > + */
> > +int sws_get_gaussian_vec(SwsVector **vecp,
> > + double standard_deviation, double quality,
> > + void *log_ctx);
> 
> which of the two do you consider better?
> 
> First, here the central part we return is the vector
> 
> SwsVector *gaus_vec = sws_getGaussianVec(NULL, 1, 2);
> SwsVector *temp_vec = sws_ConvolveVec(NULL, in_vec, gaus_vec);
> sws_averageVec(temp_vec, temp_vec, in_vec);
> 
> av_free(gaus_vec);
> return temp_vec; // Error checking here happens by temp_vec being NULL in all 
> cases of error
> 
> vs.
> 
> Second, here the central part we return is the error code
> 
> SwsVector *gaus_vec = NULL;
> SwsVector *temp_vec = NULL;
> int err = sws_getGaussianVec(_vec, 1, 2);
> if (err<0)
> goto fail;
> 
> err = sws_ConvolveVec(_vec, in_vec, gaus_vec);
> if (err<0)
> goto fail;
> 
> err = sws_averageVec(_vec, temp_vec, in_vec);
> if (err<0)
> goto fail;

The latter pattern enables differentiation between error codes (ENOMEM
or EINVAL) and provides feedback in the log message. With the former
you only know if it fails, but you don't know why (relevant in case
e.g. we make the parameter tunable by a filter and we don't want to
add additional validation and logging at the filter level).
___
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".


Re: [FFmpeg-devel] [PATCH 4/6] doc/developer: add a code behaviour section to development policy

2023-09-01 Thread Stefano Sabatini
On date Friday 2023-09-01 20:10:11 +0300, Rémi Denis-Courmont wrote:
> Le torstaina 31. elokuuta 2023, 18.28.48 EEST Stefano Sabatini a écrit :
> > On date Tuesday 2023-08-29 10:34:45 +0200, Anton Khirnov wrote:
> > > Quoting Stefano Sabatini (2023-08-27 14:38:44)
> > > 
> > > > Il sab 26 ago 2023, 20:08 Anton Khirnov  ha scritto:
> > > > > Document our longstanding de facto policies on things like
> > > > > correctness,
> > > > > thread-safety, UB, etc.
> > > > 
> > > > UB?
> > > 
> > > undefined behavior
> > 
> > yes, let's avoid acronyms
> 
> I think that developers should know common accronyms of the primary 
> programming language of the project, and it is totally reasonable to expect 
> that they are.
> 
> And yes, UB is a very well known accronym in this context. In my experience, 
> people who don't know the accronym don't know the concept either, so spelling 
> it out wouldn't even help.
> 
> TBH, this one is on you.

In general, it's good practice to avoid unnecessary use of acronyms as
they add ambiguity with very small gain (some fraction of a second
when typing and a few bytes in storage size). Also note that the
acronym is only used in the commit log and spelled out in the texi
file. That said, I'm not blocking on this but I added the note since
it was not very clear from the context when reading it.
___
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".


Re: [FFmpeg-devel] [PATCH] lsws/swscale.h: introduce sws_get_gaussian_vec

2023-09-01 Thread Stefano Sabatini
On date Friday 2023-09-01 17:50:56 +0200, Anton Khirnov wrote:
> Quoting Stefano Sabatini (2023-08-31 17:06:06)
> > On date Saturday 2023-08-26 17:15:36 +0200, Anton Khirnov wrote:
> > > Quoting Stefano Sabatini (2023-08-26 14:23:28)
> > > > Use in place of sws_getGaussianVec.
> > > > 
> > > > The new function enable better log handling, and provide better naming
> > > > for the variance variable, now named standard_deviation to reflect the
> > > > meaning of the parameter.
> > > 
> > 
> > > Logging to NULL does not seem like an improvement to me.
> > 
> > Adding the log_ctx.
> > 
> > > Renaming a function parameter does not require an API break.
> > 
> > The main point was improving the naming of the variable, but while at
> > it I'm also adding the logging context and providing a return code to
> > specify an error failure, and moving to snake_case convention which is
> > the one used by the new API additions.
> 
> As I already said above - function parameter names in a prototype are
> purely cosmetic and have no effect on anything besides doxygen. You can
> change them at will and even remove them entirely without breaking API
> or ABI.
> 

> The other reasons do not strike me as strong enough to warrant an API
> break.

I disagree on this: the function is probably only used internally and
by libavfilter, and the migration is trivial enough so should cause no
disruption anyway.
___
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".


[FFmpeg-devel] [PATCH] fate: add rka test

2023-09-01 Thread Paul B Mahol
Patch attached.
From 74bd7f508208a3631f25874167355929d859a93b Mon Sep 17 00:00:00 2001
From: Paul B Mahol 
Date: Fri, 1 Sep 2023 19:38:10 +0200
Subject: [PATCH] fate: add rka test

Signed-off-by: Paul B Mahol 
---
 tests/fate/lossless-audio.mak | 3 +++
 tests/ref/fate/lossless-rka   | 1 +
 2 files changed, 4 insertions(+)
 create mode 100644 tests/ref/fate/lossless-rka

diff --git a/tests/fate/lossless-audio.mak b/tests/fate/lossless-audio.mak
index 435119d777..86327e1167 100644
--- a/tests/fate/lossless-audio.mak
+++ b/tests/fate/lossless-audio.mak
@@ -10,6 +10,9 @@ fate-ralf: CMD = md5 -i $(TARGET_SAMPLES)/lossless-audio/luckynight-partial.rmvb
 FATE_SAMPLES_LOSSLESS_AUDIO-$(call DEMDEC, SHORTEN, SHORTEN) += fate-lossless-shorten
 fate-lossless-shorten: CMD = md5 -i $(TARGET_SAMPLES)/lossless-audio/luckynight-partial.shn -f s16le -af aresample
 
+FATE_SAMPLES_LOSSLESS_AUDIO-$(call DEMDEC, RKA, RKA) += fate-lossless-rka
+fate-lossless-rka: CMD = md5 -i $(TARGET_SAMPLES)/lossless-audio/luckynight-partial.rka -f s16le -af aresample
+
 FATE_SAMPLES_LOSSLESS_AUDIO-$(call DEMDEC, TAK, TAK) += fate-lossless-tak
 fate-lossless-tak: CMD = crc -i $(TARGET_SAMPLES)/lossless-audio/luckynight-partial.tak -af aresample
 
diff --git a/tests/ref/fate/lossless-rka b/tests/ref/fate/lossless-rka
new file mode 100644
index 00..6281924c41
--- /dev/null
+++ b/tests/ref/fate/lossless-rka
@@ -0,0 +1 @@
+97223f65c91213694a660d52f87f35aa
-- 
2.39.1

___
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".


Re: [FFmpeg-devel] [PATCH 4/6] doc/developer: add a code behaviour section to development policy

2023-09-01 Thread Paul B Mahol
On Fri, Sep 1, 2023 at 7:16 PM Rémi Denis-Courmont  wrote:

> Le torstaina 31. elokuuta 2023, 18.28.48 EEST Stefano Sabatini a écrit :
> > On date Tuesday 2023-08-29 10:34:45 +0200, Anton Khirnov wrote:
> > > Quoting Stefano Sabatini (2023-08-27 14:38:44)
> > >
> > > > Il sab 26 ago 2023, 20:08 Anton Khirnov  ha
> scritto:
> > > > > Document our longstanding de facto policies on things like
> > > > > correctness,
> > > > > thread-safety, UB, etc.
> > > >
> > > > UB?
> > >
> > > undefined behavior
> >
> > yes, let's avoid acronyms
>
> I think that developers should know common accronyms of the primary
> programming language of the project, and it is totally reasonable to
> expect
> that they are.
>
> And yes, UB is a very well known accronym in this context. In my
> experience,
> people who don't know the accronym don't know the concept either, so
> spelling
> it out wouldn't even help.
>
> TBH, this one is on you.
>

TBH, novice and newbies lack bunch of general and specific knowledge anyway.


>
> --
> レミ・デニ-クールモン
> http://www.remlab.net/
>
>
>
> ___
> 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".
>
___
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".


Re: [FFmpeg-devel] [PATCH 4/6] doc/developer: add a code behaviour section to development policy

2023-09-01 Thread Rémi Denis-Courmont
Le torstaina 31. elokuuta 2023, 18.28.48 EEST Stefano Sabatini a écrit :
> On date Tuesday 2023-08-29 10:34:45 +0200, Anton Khirnov wrote:
> > Quoting Stefano Sabatini (2023-08-27 14:38:44)
> > 
> > > Il sab 26 ago 2023, 20:08 Anton Khirnov  ha scritto:
> > > > Document our longstanding de facto policies on things like
> > > > correctness,
> > > > thread-safety, UB, etc.
> > > 
> > > UB?
> > 
> > undefined behavior
> 
> yes, let's avoid acronyms

I think that developers should know common accronyms of the primary 
programming language of the project, and it is totally reasonable to expect 
that they are.

And yes, UB is a very well known accronym in this context. In my experience, 
people who don't know the accronym don't know the concept either, so spelling 
it out wouldn't even help.

TBH, this one is on you.

-- 
レミ・デニ-クールモン
http://www.remlab.net/



___
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".


Re: [FFmpeg-devel] [PATCH 4/6] doc/developer: add a code behaviour section to development policy

2023-09-01 Thread Michael Niedermayer
On Thu, Aug 31, 2023 at 05:28:48PM +0200, Stefano Sabatini wrote:
> On date Tuesday 2023-08-29 10:34:45 +0200, Anton Khirnov wrote:
> > Quoting Stefano Sabatini (2023-08-27 14:38:44)
> > > Il sab 26 ago 2023, 20:08 Anton Khirnov  ha scritto:
> > > 
> > > > Document our longstanding de facto policies on things like correctness,
> > > > thread-safety, UB, etc.
> > > >
> > > 
> > > UB?
> > 
> > undefined behavior
> 
> yes, let's avoid acronyms

+1 (unless they are very widely established or not critical to the understaning
of the text, like ISO in ISO C)

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Concerning the gods, I have no means of knowing whether they exist or not
or of what sort they may be, because of the obscurity of the subject, and
the brevity of human life -- Protagoras


signature.asc
Description: PGP signature
___
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".


Re: [FFmpeg-devel] [PATCH] lsws/swscale.h: introduce sws_get_gaussian_vec

2023-09-01 Thread Michael Niedermayer
On Thu, Aug 31, 2023 at 07:16:20PM +0200, Stefano Sabatini wrote:
> On date Thursday 2023-08-31 18:51:52 +0200, Andreas Rheinhardt wrote:
> > Stefano Sabatini:
> > > +int sws_get_gaussian_vec(SwsVector **vecp,
> > > + AVClass *log_ctx,
> > > + double standard_deviation, double quality);
> > >  
> > 
> > Seriously? A pointer to an AVClass as log_ctx? It is actually AVClass**
> > (the logcontext must have a pointer to an AVClass as its first member),
> > but we always use NULL.
> 
> Sorry, sloppy editing on my side.
> 
> > Apart from that: I am not really convinced that the improvement is worth
> > the hassle.
> 
> This is not a high-profile function (probably it's never used outside
> lavfi) and provides an opportunity to move the API to the correct
> direction.

>  doc/APIchanges |3 +++
>  libswscale/swscale.h   |   27 ++-
>  libswscale/utils.c |   42 +-
>  libswscale/version.h   |2 +-
>  libswscale/version_major.h |4 
>  5 files changed, 67 insertions(+), 11 deletions(-)
> b91b721cea2752b28a51aaeab2a464b2699dfb49  
> 0001-lsws-swscale.h-introduce-sws_get_gaussian_vec.patch
> From 69c33f62e15de3d199d54187d38c0856418f0981 Mon Sep 17 00:00:00 2001
> From: Stefano Sabatini 
> Date: Sat, 26 Aug 2023 14:20:35 +0200
> Subject: [PATCH 1/2] lsws/swscale.h: introduce sws_get_gaussian_vec
> 
> Use in place of sws_getGaussianVec.
> 
> The new function enable better error handling, and provide better naming
> for the variance variable, now named standard_deviation to reflect the
> meaning of the parameter.
> ---
>  doc/APIchanges |  3 +++
>  libswscale/swscale.h   | 27 +++-
>  libswscale/utils.c | 42 ++
>  libswscale/version.h   |  2 +-
>  libswscale/version_major.h |  4 
>  5 files changed, 67 insertions(+), 11 deletions(-)
> 
> diff --git a/doc/APIchanges b/doc/APIchanges
> index ad1efe708d..bad2d61027 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2023-02-09
>  
>  API changes, most recent first:
>  
> +2023-08-26 - xx - lsws 7.4.100 - swscale.h
> +  Introduce sws_get_gaussian_vec, use in place of sws_getGaussianVec.
> +
>  2023-08-18 - xx - lavu 58.17.100 - channel_layout.h
>All AV_CHANNEL_LAYOUT_* macros are now compatible with C++ 17 and older.
>  
> diff --git a/libswscale/swscale.h b/libswscale/swscale.h
> index 9d4612aaf3..55f2fc4a48 100644
> --- a/libswscale/swscale.h
> +++ b/libswscale/swscale.h
> @@ -355,11 +355,36 @@ int sws_getColorspaceDetails(struct SwsContext *c, int 
> **inv_table,
>   */
>  SwsVector *sws_allocVec(int length);
>  
> +#if FF_API_SWS_GET_GAUSSIAN_VEC
>  /**
> - * Return a normalized Gaussian curve used to filter stuff
> + * Return a normalized Gaussian curve used to filter stuff.
> + *
>   * quality = 3 is high quality, lower is lower quality.
> + * @deprecated use sws_get_gaussian_vector()
>   */
> +attribute_deprecated
>  SwsVector *sws_getGaussianVec(double variance, double quality);
> +#endif
> +
> +/**
> + * Compute and return a normalized Gaussian vector.
> + *
> + * @param vecp: pointer where the computed vector is put in case of
> + *success
> + * @param standard_deviation the standard deviation used to generate
> + *the Gaussian vector, must be a non-negative value
> + * @param quality the quality of the generated Gaussian vector, must
> + *be a non-negative value. It affects the lenght of the generated
> + *vector. A value equal to 3 corresponds to high quality.
> + * @param log_ctx a pointer to an arbitrary struct of which the first
> + *field is a pointer to an AVClass struct (used for av_log)
> + *used for logging, can be NULL
> + *
> + * @return a negative error code on error, non negative otherwise
> + */
> +int sws_get_gaussian_vec(SwsVector **vecp,
> + double standard_deviation, double quality,
> + void *log_ctx);

which of the two do you consider better?

First, here the central part we return is the vector

SwsVector *gaus_vec = sws_getGaussianVec(NULL, 1, 2);
SwsVector *temp_vec = sws_ConvolveVec(NULL, in_vec, gaus_vec);
sws_averageVec(temp_vec, temp_vec, in_vec);

av_free(gaus_vec);
return temp_vec; // Error checking here happens by temp_vec being NULL in all 
cases of error

vs.

Second, here the central part we return is the error code

SwsVector *gaus_vec = NULL;
SwsVector *temp_vec = NULL;
int err = sws_getGaussianVec(_vec, 1, 2);
if (err<0)
goto fail;

err = sws_ConvolveVec(_vec, in_vec, gaus_vec);
if (err<0)
goto fail;

err = sws_averageVec(_vec, temp_vec, in_vec);
if (err<0)
goto fail;

*ret_argument = temp_vec
return 0;
fail:
av_free(gaus_vec)
av_free(temp_vec)
return ret;

thx

[...]

-- 
Michael GnuPG 

Re: [FFmpeg-devel] [PATCH] lsws/swscale.h: introduce sws_get_gaussian_vec

2023-09-01 Thread Anton Khirnov
Quoting Stefano Sabatini (2023-08-31 17:06:06)
> On date Saturday 2023-08-26 17:15:36 +0200, Anton Khirnov wrote:
> > Quoting Stefano Sabatini (2023-08-26 14:23:28)
> > > Use in place of sws_getGaussianVec.
> > > 
> > > The new function enable better log handling, and provide better naming
> > > for the variance variable, now named standard_deviation to reflect the
> > > meaning of the parameter.
> > 
> 
> > Logging to NULL does not seem like an improvement to me.
> 
> Adding the log_ctx.
> 
> > Renaming a function parameter does not require an API break.
> 
> The main point was improving the naming of the variable, but while at
> it I'm also adding the logging context and providing a return code to
> specify an error failure, and moving to snake_case convention which is
> the one used by the new API additions.

As I already said above - function parameter names in a prototype are
purely cosmetic and have no effect on anything besides doxygen. You can
change them at will and even remove them entirely without breaking API
or ABI.

The other reasons do not strike me as strong enough to warrant an API
break.

-- 
Anton Khirnov
___
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".


[FFmpeg-devel] [PATCH 2/3] ffprobe: correct section name for side data piece

2023-09-01 Thread Stefano Sabatini
---
 fftools/ffprobe.c  |  2 +-
 tests/ref/fate/hevc-dv-rpu | 80 +++---
 2 files changed, 41 insertions(+), 41 deletions(-)

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 547e299312..7eb4d20a17 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -246,7 +246,7 @@ static struct section sections[] = {
 [SECTION_ID_FRAME_SIDE_DATA_COMPONENT_LIST] = { 
SECTION_ID_FRAME_SIDE_DATA_COMPONENT_LIST, "components", SECTION_FLAG_IS_ARRAY, 
{ SECTION_ID_FRAME_SIDE_DATA_COMPONENT, -1 } },
 [SECTION_ID_FRAME_SIDE_DATA_COMPONENT] =  { 
SECTION_ID_FRAME_SIDE_DATA_COMPONENT, "component", 0, { 
SECTION_ID_FRAME_SIDE_DATA_PIECE_LIST, -1 } },
 [SECTION_ID_FRAME_SIDE_DATA_PIECE_LIST] =   { 
SECTION_ID_FRAME_SIDE_DATA_PIECE_LIST, "pieces", SECTION_FLAG_IS_ARRAY, { 
SECTION_ID_FRAME_SIDE_DATA_PIECE, -1 } },
-[SECTION_ID_FRAME_SIDE_DATA_PIECE] ={ 
SECTION_ID_FRAME_SIDE_DATA_PIECE, "section", 0, { -1 } },
+[SECTION_ID_FRAME_SIDE_DATA_PIECE] ={ 
SECTION_ID_FRAME_SIDE_DATA_PIECE, "piece", 0, { -1 } },
 [SECTION_ID_FRAME_LOGS] = { SECTION_ID_FRAME_LOGS, "logs", 
SECTION_FLAG_IS_ARRAY, { SECTION_ID_FRAME_LOG, -1 } },
 [SECTION_ID_FRAME_LOG] =  { SECTION_ID_FRAME_LOG, "log", 0, { -1 
},  },
 [SECTION_ID_LIBRARY_VERSIONS] =   { SECTION_ID_LIBRARY_VERSIONS, 
"library_versions", SECTION_FLAG_IS_ARRAY, { SECTION_ID_LIBRARY_VERSION, -1 } },
diff --git a/tests/ref/fate/hevc-dv-rpu b/tests/ref/fate/hevc-dv-rpu
index aaf0223eab..f6ed14e24f 100644
--- a/tests/ref/fate/hevc-dv-rpu
+++ b/tests/ref/fate/hevc-dv-rpu
@@ -37,74 +37,74 @@ num_x_partitions=1
 num_y_partitions=1
 [COMPONENT]
 pivots=63 132 362 618 874 911 927 935 942
-[SECTION]
+[PIECE]
 mapping_idc=0
 mapping_idc_name=polynomial
 poly_order=2
 poly_coef=-409680 16721463 -20276640
-[/SECTION]
-[SECTION]
+[/PIECE]
+[PIECE]
 mapping_idc=0
 mapping_idc_name=polynomial
 poly_order=2
 poly_coef=-119056 13575212 -12867889
-[/SECTION]
-[SECTION]
+[/PIECE]
+[PIECE]
 mapping_idc=0
 mapping_idc_name=polynomial
 poly_order=2
 poly_coef=1317527 5338528 -948122
-[/SECTION]
-[SECTION]
+[/PIECE]
+[PIECE]
 mapping_idc=0
 mapping_idc_name=polynomial
 poly_order=2
 poly_coef=2119979 2065496 2288524
-[/SECTION]
-[SECTION]
+[/PIECE]
+[PIECE]
 mapping_idc=0
 mapping_idc_name=polynomial
 poly_order=2
 poly_coef=7982780 -11367226 9973944
-[/SECTION]
-[SECTION]
+[/PIECE]
+[PIECE]
 mapping_idc=0
 mapping_idc_name=polynomial
 poly_order=2
 poly_coef=53792084 -114243184 67724328
-[/SECTION]
-[SECTION]
+[/PIECE]
+[PIECE]
 mapping_idc=0
 mapping_idc_name=polynomial
 poly_order=2
 poly_coef=112973872 -244837568 139764480
-[/SECTION]
-[SECTION]
+[/PIECE]
+[PIECE]
 mapping_idc=0
 mapping_idc_name=polynomial
 poly_order=2
 poly_coef=236828416 -518849056 291306944
-[/SECTION]
+[/PIECE]
 [/COMPONENT]
 [COMPONENT]
 pivots=0 1023
-[SECTION]
+[PIECE]
 mapping_idc=1
 mapping_idc_name=mmr
 mmr_order=3
 mmr_constant=-4200453
 mmr_coef=9094176 31944476 739652 -27103344 -3431599 -11015088 22758042 
-2028643 -30021218 -906885 26272992 7291404 16488745 -78087176 -148 
12496543 762460 -4281948 -5768035 -7843163 103636960
-[/SECTION]
+[/PIECE]
 [/COMPONENT]
 [COMPONENT]
 pivots=0 1023
-[SECTION]
+[PIECE]
 mapping_idc=1
 mapping_idc_name=mmr
 mmr_order=3
 mmr_constant=-10387889
 mmr_coef=29604202 3214133 46206184 -8564340 -53383996 1628407 5426045 
-21634202 -5251953 -50812292 19221972 76726656 -425892 -35041240 5917361 
2863974 25030554 -14404292 -41230120 1229046 53575140
-[/SECTION]
+[/PIECE]
 [/COMPONENT]
 dm_metadata_id=0
 scene_refresh_flag=1
@@ -160,74 +160,74 @@ num_x_partitions=1
 num_y_partitions=1
 [COMPONENT]
 pivots=63 132 362 618 874 911 927 935 942
-[SECTION]
+[PIECE]
 mapping_idc=0
 mapping_idc_name=polynomial
 poly_order=2
 poly_coef=-409680 16721463 -20276640
-[/SECTION]
-[SECTION]
+[/PIECE]
+[PIECE]
 mapping_idc=0
 mapping_idc_name=polynomial
 poly_order=2
 poly_coef=-119056 13575212 -12867889
-[/SECTION]
-[SECTION]
+[/PIECE]
+[PIECE]
 mapping_idc=0
 mapping_idc_name=polynomial
 poly_order=2
 poly_coef=1317527 5338528 -948122
-[/SECTION]
-[SECTION]
+[/PIECE]
+[PIECE]
 mapping_idc=0
 mapping_idc_name=polynomial
 poly_order=2
 poly_coef=2119979 2065496 2288524
-[/SECTION]
-[SECTION]
+[/PIECE]
+[PIECE]
 mapping_idc=0
 mapping_idc_name=polynomial
 poly_order=2
 poly_coef=7982780 -11367226 9973944
-[/SECTION]
-[SECTION]
+[/PIECE]
+[PIECE]
 mapping_idc=0
 mapping_idc_name=polynomial
 poly_order=2
 poly_coef=53792084 -114243184 67724328
-[/SECTION]
-[SECTION]
+[/PIECE]
+[PIECE]
 mapping_idc=0
 mapping_idc_name=polynomial
 poly_order=2
 poly_coef=112973872 -244837568 139764480
-[/SECTION]
-[SECTION]
+[/PIECE]
+[PIECE]
 mapping_idc=0
 mapping_idc_name=polynomial
 poly_order=2
 poly_coef=236828416 -518849056 291306944
-[/SECTION]
+[/PIECE]
 [/COMPONENT]
 [COMPONENT]
 pivots=0 1023
-[SECTION]
+[PIECE]
 mapping_idc=1
 mapping_idc_name=mmr
 mmr_order=3
 mmr_constant=-4200453
 mmr_coef=9094176 31944476 

[FFmpeg-devel] [PATCH 1/3] ffprobe: factorize side data printing to dedicated function

2023-09-01 Thread Stefano Sabatini
---
 fftools/ffprobe.c | 163 --
 1 file changed, 85 insertions(+), 78 deletions(-)

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 4fcfe1164b..547e299312 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -2578,6 +2578,89 @@ static void show_subtitle(WriterContext *w, AVSubtitle 
*sub, AVStream *stream,
 fflush(stdout);
 }
 
+static void print_frame_side_data(WriterContext *w,
+  AVFrame *frame,
+  AVStream *stream)
+{
+int i;
+
+writer_print_section_header(w, SECTION_ID_FRAME_SIDE_DATA_LIST);
+
+for (i = 0; i < frame->nb_side_data; i++) {
+AVFrameSideData *sd = frame->side_data[i];
+const char *name;
+
+writer_print_section_header(w, SECTION_ID_FRAME_SIDE_DATA);
+name = av_frame_side_data_name(sd->type);
+print_str("side_data_type", name ? name : "unknown");
+if (sd->type == AV_FRAME_DATA_DISPLAYMATRIX && sd->size >= 9*4) {
+double rotation = av_display_rotation_get((int32_t *)sd->data);
+if (isnan(rotation))
+rotation = 0;
+writer_print_integers(w, "displaymatrix", sd->data, 9, " %11d", 3, 
4, 1);
+print_int("rotation", rotation);
+} else if (sd->type == AV_FRAME_DATA_AFD && sd->size > 0) {
+print_int("active_format", *sd->data);
+} else if (sd->type == AV_FRAME_DATA_GOP_TIMECODE && sd->size >= 8) {
+char tcbuf[AV_TIMECODE_STR_SIZE];
+av_timecode_make_mpeg_tc_string(tcbuf, *(int64_t *)(sd->data));
+print_str("timecode", tcbuf);
+} else if (sd->type == AV_FRAME_DATA_S12M_TIMECODE && sd->size == 16) {
+uint32_t *tc = (uint32_t*)sd->data;
+int m = FFMIN(tc[0],3);
+writer_print_section_header(w, 
SECTION_ID_FRAME_SIDE_DATA_TIMECODE_LIST);
+for (int j = 1; j <= m ; j++) {
+char tcbuf[AV_TIMECODE_STR_SIZE];
+av_timecode_make_smpte_tc_string2(tcbuf, 
stream->avg_frame_rate, tc[j], 0, 0);
+writer_print_section_header(w, 
SECTION_ID_FRAME_SIDE_DATA_TIMECODE);
+print_str("value", tcbuf);
+writer_print_section_footer(w);
+}
+writer_print_section_footer(w);
+} else if (sd->type == AV_FRAME_DATA_MASTERING_DISPLAY_METADATA) {
+AVMasteringDisplayMetadata *metadata = (AVMasteringDisplayMetadata 
*)sd->data;
+
+if (metadata->has_primaries) {
+print_q("red_x", metadata->display_primaries[0][0], '/');
+print_q("red_y", metadata->display_primaries[0][1], '/');
+print_q("green_x", metadata->display_primaries[1][0], '/');
+print_q("green_y", metadata->display_primaries[1][1], '/');
+print_q("blue_x", metadata->display_primaries[2][0], '/');
+print_q("blue_y", metadata->display_primaries[2][1], '/');
+
+print_q("white_point_x", metadata->white_point[0], '/');
+print_q("white_point_y", metadata->white_point[1], '/');
+}
+
+if (metadata->has_luminance) {
+print_q("min_luminance", metadata->min_luminance, '/');
+print_q("max_luminance", metadata->max_luminance, '/');
+}
+} else if (sd->type == AV_FRAME_DATA_DYNAMIC_HDR_PLUS) {
+AVDynamicHDRPlus *metadata = (AVDynamicHDRPlus *)sd->data;
+print_dynamic_hdr10_plus(w, metadata);
+} else if (sd->type == AV_FRAME_DATA_CONTENT_LIGHT_LEVEL) {
+AVContentLightMetadata *metadata = (AVContentLightMetadata 
*)sd->data;
+print_int("max_content", metadata->MaxCLL);
+print_int("max_average", metadata->MaxFALL);
+} else if (sd->type == AV_FRAME_DATA_ICC_PROFILE) {
+const AVDictionaryEntry *tag = av_dict_get(sd->metadata, "name", 
NULL, AV_DICT_MATCH_CASE);
+if (tag)
+print_str(tag->key, tag->value);
+print_int("size", sd->size);
+} else if (sd->type == AV_FRAME_DATA_DOVI_METADATA) {
+print_dovi_metadata(w, (const AVDOVIMetadata *)sd->data);
+} else if (sd->type == AV_FRAME_DATA_DYNAMIC_HDR_VIVID) {
+AVDynamicHDRVivid *metadata = (AVDynamicHDRVivid *)sd->data;
+print_dynamic_hdr_vivid(w, metadata);
+} else if (sd->type == AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT) {
+print_ambient_viewing_environment(w, (const 
AVAmbientViewingEnvironment *)sd->data);
+}
+writer_print_section_footer(w);
+}
+writer_print_section_footer(w);
+}
+
 static void show_frame(WriterContext *w, AVFrame *frame, AVStream *stream,
AVFormatContext *fmt_ctx)
 {
@@ -2585,7 +2668,6 @@ static void show_frame(WriterContext *w, AVFrame *frame, 
AVStream *stream,
 AVBPrint pbuf;
 

[FFmpeg-devel] [PATCH] lavu/avstring: fix typo in av_strireplace function doxy

2023-09-01 Thread Stefano Sabatini
---
 libavutil/avstring.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/avstring.h b/libavutil/avstring.h
index e260263763..9b187e8d92 100644
--- a/libavutil/avstring.h
+++ b/libavutil/avstring.h
@@ -265,7 +265,7 @@ int av_strncasecmp(const char *a, const char *b, size_t n);
 
 /**
  * Locale-independent strings replace.
- * @note This means only ASCII-range characters are replace
+ * @note This means only ASCII-range characters are replaced.
  */
 char *av_strireplace(const char *str, const char *from, const char *to);
 
-- 
2.34.1

___
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".


Re: [FFmpeg-devel] [PATCH v4 0/4] Add passthrough support for SCTE-35

2023-09-01 Thread Dennis Mungai
On Tue, 8 Aug 2023 at 18:30, Dennis Mungai  wrote:

> On Tue, 8 Aug 2023, 17:31 Devin Heitmueller, <
> devin.heitmuel...@ltnglobal.com> wrote:
>
>> On Fri, Aug 4, 2023 at 7:16 AM Devin Heitmueller
>>  wrote:
>> >
>> > On Mon, Jul 31, 2023 at 9:38 AM Devin Heitmueller
>> >  wrote:
>> > >
>> > > Properly set up the MPEG-TS mux and recalculate the pts_adjust field
>> > > in SCTE_35 packets, such that a user can transparently pass through
>> > > SCTE-35 streams when both the input and output are MPEG-TS.
>> > >
>> > > This patch series updated to reflect feedback from James Almer.
>> > >
>> > > Devin Heitmueller (4):
>> > >   avcodec: Add new side data type to contain original PTS value
>> > >   mpegts: Stash original PTS for SCTE-35 sections for processing later
>> > >   mpegtsenc: Add support for output of SCTE-35 streams over TS
>> > >   bsf: Add new bitstream filter to set SCTE-35 pts_adjustment when
>> > > reclocking
>> > >
>> > >  doc/bitstream_filters.texi   |   9 
>> > >  libavcodec/Makefile  |   1 +
>> > >  libavcodec/bitstream_filters.c   |   1 +
>> > >  libavcodec/defs.h|  12 +
>> > >  libavcodec/packet.h  |  11 +
>> > >  libavcodec/scte35ptsadjust_bsf.c | 100
>> +++
>> > >  libavformat/mpegts.c |  11 -
>> > >  libavformat/mpegts.h |   1 +
>> > >  libavformat/mpegtsenc.c  |  76 +++--
>> > >  libavformat/mux.c|   6 ++-
>> > >  10 files changed, 221 insertions(+), 7 deletions(-)
>> > >  create mode 100644 libavcodec/scte35ptsadjust_bsf.c
>> > >
>> > > --
>> > > 1.8.3.1
>> > >
>> >
>> > ping.
>>
>> If nobody has any additional feedback, could I please get somebody to
>> merge this series?
>>
>> Thanks,
>>
>> Devin
>>
>> --
>> Devin Heitmueller, Senior Software Engineer
>> LTN Global Communications
>> o: +1 (301) 363-1001
>> w: https://ltnglobal.com  e: devin.heitmuel...@ltnglobal.com
>
>
>
> Is there anything blocking this patch(set) from bring merged upstream?
>


Hello,

Any feedback on this patch-set, so far?
Is there anything blocking it from being merged? Any pending reviews?

-Dennis.
___
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".