[FFmpeg-cvslog] lavfi/vf_libplacebo: switch to new pl_options struct

2023-08-27 Thread Niklas Haas
ffmpeg | branch: master | Niklas Haas  | Fri Aug 18 18:25:29 
2023 +0200| [816983d951caefc81799a76b25219994209f] | committer: Niklas Haas

lavfi/vf_libplacebo: switch to new pl_options struct

This new upstream struct simplifies params struct management by allowing
them to all be contained in a single dynamically allocated struct. This
commit switches to the new API in a backwards-compatible way.

The only nontrivial change that was required was to handle
`sigmoid_params` in a way consistent with the rest of the params
structs, instead of setting it directly to the upstream default.

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

 libavfilter/vf_libplacebo.c | 89 +
 1 file changed, 57 insertions(+), 32 deletions(-)

diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c
index 3487991053..b9effdbad9 100644
--- a/libavfilter/vf_libplacebo.c
+++ b/libavfilter/vf_libplacebo.c
@@ -42,6 +42,25 @@ static inline AVFrame *pl_get_mapped_avframe(const struct 
pl_frame *frame)
 }
 #endif
 
+#if PL_API_VER >= 309
+#include 
+#else
+typedef struct pl_options_t {
+// Backwards compatibility shim of this struct
+struct pl_render_params params;
+struct pl_deband_params deband_params;
+struct pl_sigmoid_params sigmoid_params;
+struct pl_color_adjustment color_adjustment;
+struct pl_peak_detect_params peak_detect_params;
+struct pl_color_map_params color_map_params;
+struct pl_dither_params dither_params;
+struct pl_cone_params cone_params;
+} *pl_options;
+
+#define pl_options_alloc(log) av_mallocz(sizeof(struct pl_options_t))
+#define pl_options_free(ptr)  av_freep(ptr)
+#endif
+
 enum {
 TONE_MAP_AUTO,
 TONE_MAP_CLIP,
@@ -175,7 +194,7 @@ typedef struct LibplaceboContext {
 int color_trc;
 
 /* pl_render_params */
-struct pl_render_params params;
+pl_options opts;
 char *upscaler;
 char *downscaler;
 char *frame_mixer;
@@ -190,7 +209,6 @@ typedef struct LibplaceboContext {
 int disable_fbos;
 
 /* pl_deband_params */
-struct pl_deband_params deband_params;
 int deband;
 int deband_iterations;
 float deband_threshold;
@@ -198,7 +216,6 @@ typedef struct LibplaceboContext {
 float deband_grain;
 
 /* pl_color_adjustment */
-struct pl_color_adjustment color_adjustment;
 float brightness;
 float contrast;
 float saturation;
@@ -206,7 +223,6 @@ typedef struct LibplaceboContext {
 float gamma;
 
 /* pl_peak_detect_params */
-struct pl_peak_detect_params peak_detect_params;
 int peakdetect;
 float smoothing;
 float min_peak;
@@ -215,7 +231,6 @@ typedef struct LibplaceboContext {
 float percentile;
 
 /* pl_color_map_params */
-struct pl_color_map_params color_map_params;
 int gamut_mode;
 int tonemapping;
 float tonemapping_param;
@@ -239,13 +254,11 @@ typedef struct LibplaceboContext {
 #endif
 
 /* pl_dither_params */
-struct pl_dither_params dither_params;
 int dithering;
 int dither_lut_size;
 int dither_temporal;
 
 /* pl_cone_params */
-struct pl_cone_params cone_params;
 int cones;
 float cone_str;
 
@@ -363,6 +376,7 @@ static int update_settings(AVFilterContext *ctx)
 {
 int err = 0;
 LibplaceboContext *s = ctx->priv;
+pl_options opts = s->opts;
 int gamut_mode = s->gamut_mode;
 uint8_t color_rgba[4];
 
@@ -394,14 +408,16 @@ static int update_settings(AVFilterContext *ctx)
 
 RET(av_parse_color(color_rgba, s->fillcolor, -1, s));
 
-s->deband_params = *pl_deband_params(
+opts->deband_params = *pl_deband_params(
 .iterations = s->deband_iterations,
 .threshold = s->deband_threshold,
 .radius = s->deband_radius,
 .grain = s->deband_grain,
 );
 
-s->color_adjustment = (struct pl_color_adjustment) {
+opts->sigmoid_params = pl_sigmoid_default_params;
+
+opts->color_adjustment = (struct pl_color_adjustment) {
 .brightness = s->brightness,
 .contrast = s->contrast,
 .saturation = s->saturation,
@@ -409,7 +425,7 @@ static int update_settings(AVFilterContext *ctx)
 .gamma = s->gamma,
 };
 
-s->peak_detect_params = *pl_peak_detect_params(
+opts->peak_detect_params = *pl_peak_detect_params(
 .smoothing_period = s->smoothing,
 .minimum_peak = s->min_peak,
 .scene_threshold_low = s->scene_low,
@@ -422,7 +438,7 @@ static int update_settings(AVFilterContext *ctx)
 #endif
 );
 
-s->color_map_params = *pl_color_map_params(
+opts->color_map_params = *pl_color_map_params(
 #if FF_API_LIBPLACEBO_OPTS
 # if PL_API_VER >= 269
 .hybrid_mix = hybrid_mix,
@@ -441,20 +457,20 @@ static int update_settings(AVFilterContext *ctx)
 #endif
 );
 
-set_gamut_mode(&s->color_map_params, gamut_mode);
+set_gamut_mode(&opts->color_map_params, gamut_mode);
 
-s-

[FFmpeg-cvslog] lavfi/vf_libplacebo: add extra_opts AVDictionary

2023-08-27 Thread Niklas Haas
ffmpeg | branch: master | Niklas Haas  | Fri Aug 18 18:48:43 
2023 +0200| [3c9dc009b6e5a82e9d2035d14a287ed532378658] | committer: Niklas Haas

lavfi/vf_libplacebo: add extra_opts AVDictionary

Can be used to configure libplacebo's underlying raw options, which
sometimes includes new or advanced / in-depth settings not (yet) exposed
by vf_libplacebo.

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

 doc/filters.texi| 10 ++
 libavfilter/vf_libplacebo.c | 13 +
 2 files changed, 23 insertions(+)

diff --git a/doc/filters.texi b/doc/filters.texi
index 90e6c433c4..14a6be49ac 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -16320,6 +16320,16 @@ Render frames with rounded corners. The value, given 
as a float ranging from
 square to fully circular. In other words, it gives the radius divided by half
 the smaller side length. Defaults to @code{0.0}.
 
+@item extra_opts
+Pass extra libplacebo internal configuration options. These can be specified
+as a list of @var{key}=@var{value} pairs separated by ':'. The following 
example
+shows how to configure a custom filter kernel ("EWA LanczosSharp") and use it
+to double the input image resolution:
+
+@example
+-vf 
"libplacebo=w=iw*2:h=ih*2:extra_opts='upscaler=custom\:upscaler_preset=ewa_lanczos\:upscaler_blur=0.9812505644269356'"
+@end example
+
 @item colorspace
 @item color_primaries
 @item color_trc
diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c
index b9effdbad9..942c321042 100644
--- a/libavfilter/vf_libplacebo.c
+++ b/libavfilter/vf_libplacebo.c
@@ -192,6 +192,7 @@ typedef struct LibplaceboContext {
 int color_range;
 int color_primaries;
 int color_trc;
+AVDictionary *extra_opts;
 
 /* pl_render_params */
 pl_options opts;
@@ -376,6 +377,7 @@ static int update_settings(AVFilterContext *ctx)
 {
 int err = 0;
 LibplaceboContext *s = ctx->priv;
+AVDictionaryEntry *e = NULL;
 pl_options opts = s->opts;
 int gamut_mode = s->gamut_mode;
 uint8_t color_rgba[4];
@@ -505,6 +507,16 @@ static int update_settings(AVFilterContext *ctx)
 RET(find_scaler(ctx, &opts->params.upscaler, s->upscaler, 0));
 RET(find_scaler(ctx, &opts->params.downscaler, s->downscaler, 0));
 RET(find_scaler(ctx, &opts->params.frame_mixer, s->frame_mixer, 1));
+
+#if PL_API_VER >= 309
+while ((e = av_dict_get(s->extra_opts, "", e, AV_DICT_IGNORE_SUFFIX))) {
+if (!pl_options_set_str(s->opts, e->key, e->value)) {
+err = AVERROR(EINVAL);
+goto fail;
+}
+}
+#endif
+
 return 0;
 
 fail:
@@ -1322,6 +1334,7 @@ static const AVOption libplacebo_options[] = {
 { "pad_crop_ratio", "ratio between padding and cropping when normalizing 
SAR (0=pad, 1=crop)", OFFSET(pad_crop_ratio), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 
0.0, 1.0, DYNAMIC },
 { "fillcolor", "Background fill color", OFFSET(fillcolor), 
AV_OPT_TYPE_STRING, {.str = "black"}, .flags = DYNAMIC },
 { "corner_rounding", "Corner rounding radius", OFFSET(corner_rounding), 
AV_OPT_TYPE_FLOAT, {.dbl = 0.0}, 0.0, 1.0, .flags = DYNAMIC },
+{ "extra_opts", "Pass extra libplacebo-specific options using a 
:-separated list of key=value pairs", OFFSET(extra_opts), AV_OPT_TYPE_DICT, 
.flags = DYNAMIC },
 
 {"colorspace", "select colorspace", OFFSET(colorspace), AV_OPT_TYPE_INT, 
{.i64=-1}, -1, AVCOL_SPC_NB-1, DYNAMIC, "colorspace"},
 {"auto", "keep the same colorspace",  0, AV_OPT_TYPE_CONST, {.i64=-1}, 
 INT_MIN, INT_MAX, STATIC, "colorspace"},

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] lavc/libx264: replace ITU-T T35(A/53 CC) SEI type by enum value

2023-08-27 Thread Jun Zhao
ffmpeg | branch: master | Jun Zhao  | Tue Aug 15 17:56:13 
2023 +0800| [c48ec95ba310fa7debb317b8790b387b6256d2c5] | committer: Jun Zhao

lavc/libx264: replace ITU-T T35(A/53 CC) SEI type by enum value

replace ITU-T T35(A/53 CC) SEI type by enum value

Reviewed-by: Kieran Kunhya 
Signed-off-by: Jun Zhao 

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

 libavcodec/libx264.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 1a7dc7bdd5..ce849d6c9a 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -563,7 +563,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
 sei->payloads[0].payload_size = sei_size;
 sei->payloads[0].payload  = sei_data;
-sei->payloads[0].payload_type = 4;
+sei->payloads[0].payload_type = 
SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35;
 sei->num_payloads = 1;
 }
 }

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/apedec: Implement interim mode detection

2023-08-27 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Sat 
Aug 26 14:27:49 2023 +0200| [86c092a0edcb3133e7e62fa30d19e80da8e7e849] | 
committer: Michael Niedermayer

avcodec/apedec: Implement interim mode detection

Fixes: NoLegacy.ape
Found-by: Matt Ashland 
Signed-off-by: Michael Niedermayer 

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

 libavcodec/apedec.c | 106 +---
 1 file changed, 84 insertions(+), 22 deletions(-)

diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
index 8bd625ca05..62cb397490 100644
--- a/libavcodec/apedec.c
+++ b/libavcodec/apedec.c
@@ -171,6 +171,9 @@ typedef struct APEContext {
 int32_t *decoded_buffer;
 int decoded_size;
 int32_t *decoded[MAX_CHANNELS];  ///< decoded data for each channel
+int32_t *interim_buffer;
+int interim_size;
+int32_t *interim[MAX_CHANNELS];  ///< decoded data for each channel
 int blocks_per_loop; ///< maximum number of samples to 
decode for each call
 
 int16_t* filterbuf[APE_FILTER_LEVELS];   ///< filter memory
@@ -187,6 +190,7 @@ typedef struct APEContext {
 const uint8_t *ptr;  ///< current position in frame 
data
 
 int error;
+int interim_mode;
 
 void (*entropy_decode_mono)(struct APEContext *ctx, int blockstodecode);
 void (*entropy_decode_stereo)(struct APEContext *ctx, int blockstodecode);
@@ -223,6 +227,7 @@ static av_cold int ape_decode_close(AVCodecContext *avctx)
 av_freep(&s->filterbuf[i]);
 
 av_freep(&s->decoded_buffer);
+av_freep(&s->interim_buffer);
 av_freep(&s->data);
 s->decoded_size = s->data_size = 0;
 
@@ -248,12 +253,15 @@ static av_cold int ape_decode_init(AVCodecContext *avctx)
 switch (s->bps) {
 case 8:
 avctx->sample_fmt = AV_SAMPLE_FMT_U8P;
+s->interim_mode = 0;
 break;
 case 16:
 avctx->sample_fmt = AV_SAMPLE_FMT_S16P;
+s->interim_mode = 0;
 break;
 case 24:
 avctx->sample_fmt = AV_SAMPLE_FMT_S32P;
+s->interim_mode = -1;
 break;
 default:
 avpriv_request_sample(avctx,
@@ -1181,7 +1189,7 @@ static av_always_inline int 
predictor_update_filter(APEPredictor64 *p,
 const int decoded, const 
int filter,
 const int delayA,  const 
int delayB,
 const int adaptA,  const 
int adaptB,
-int compression_level)
+int interim_mode)
 {
 int64_t predictionA, predictionB;
 int32_t sign;
@@ -1209,7 +1217,7 @@ static av_always_inline int 
predictor_update_filter(APEPredictor64 *p,
   p->buf[delayB - 3] * p->coeffsB[filter][3] +
   p->buf[delayB - 4] * p->coeffsB[filter][4];
 
-if (compression_level < COMPRESSION_LEVEL_INSANE) {
+if (interim_mode < 1) {
 predictionA = (int32_t)predictionA;
 predictionB = (int32_t)predictionB;
 p->lastA[filter] = decoded + ((int32_t)(predictionA + (predictionB >> 
1)) >> 10);
@@ -1234,33 +1242,74 @@ static av_always_inline int 
predictor_update_filter(APEPredictor64 *p,
 
 static void predictor_decode_stereo_3950(APEContext *ctx, int count)
 {
-APEPredictor64 *p = &ctx->predictor64;
-int32_t *decoded0 = ctx->decoded[0];
-int32_t *decoded1 = ctx->decoded[1];
+APEPredictor64 *p_default = &ctx->predictor64;
+APEPredictor64 p_interim;
+int lcount = count;
+int num_passes = 1;
 
 ape_apply_filters(ctx, ctx->decoded[0], ctx->decoded[1], count);
+if (ctx->interim_mode == -1) {
+p_interim = *p_default;
+num_passes ++;
+memcpy(ctx->interim[0], ctx->decoded[0], 
sizeof(*ctx->interim[0])*count);
+memcpy(ctx->interim[1], ctx->decoded[1], 
sizeof(*ctx->interim[1])*count);
+}
 
-while (count--) {
-/* Predictor Y */
-*decoded0 = predictor_update_filter(p, *decoded0, 0, YDELAYA, YDELAYB,
-YADAPTCOEFFSA, YADAPTCOEFFSB,
-ctx->compression_level);
-decoded0++;
-*decoded1 = predictor_update_filter(p, *decoded1, 1, XDELAYA, XDELAYB,
-XADAPTCOEFFSA, XADAPTCOEFFSB,
-ctx->compression_level);
-decoded1++;
+for (int pass = 0; pass < num_passes; pass++) {
+int32_t *decoded0, *decoded1;
+int interim_mode = ctx->interim_mode > 0 || pass;
+APEPredictor64 *p;
 
-/* Combined */
-p->buf++;
+if (pass) {
+p= &p_interim;
+decoded0 = ctx->interim[0];
+decoded1 = ctx->interim[1];
+} else {
+ 

[FFmpeg-cvslog] avcodec/apedec: remove unused variable

2023-08-27 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Sat 
Aug 26 01:59:26 2023 +0200| [7995e175b844198eb73954f0befda5703a7b7a3d] | 
committer: Michael Niedermayer

avcodec/apedec: remove unused variable

Signed-off-by: Michael Niedermayer 

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

 libavcodec/apedec.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
index a9d5eb7f33..8bd625ca05 100644
--- a/libavcodec/apedec.c
+++ b/libavcodec/apedec.c
@@ -145,8 +145,6 @@ typedef struct APEPredictor64 {
 uint64_t coeffsA[2][4];  ///< adaption coefficients
 uint64_t coeffsB[2][5];  ///< adaption coefficients
 int64_t historybuffer[HISTORY_SIZE + PREDICTOR_SIZE];
-
-unsigned int sample_pos;
 } APEPredictor64;
 
 /** Decoder context */
@@ -860,8 +858,6 @@ static void init_predictor_decoder(APEContext *ctx)
 p64->lastA[0]   = p64->lastA[1]   = 0;
 
 p->sample_pos = 0;
-
-p64->sample_pos = 0;
 }
 
 /** Get inverse sign of integer (-1 for positive, 1 for negative and 0 for 
zero) */

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] tests/fate: Add NoLegacy-cut.ape test

2023-08-27 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Sat 
Aug 26 20:21:32 2023 +0200| [b5273c619dc63ed4f4853aa4652097923e46a101] | 
committer: Michael Niedermayer

tests/fate: Add NoLegacy-cut.ape test

Signed-off-by: Michael Niedermayer 

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

 tests/fate/monkeysaudio.mak | 3 +++
 tests/ref/fate/lossless-monkeysaudio-legacy | 1 +
 2 files changed, 4 insertions(+)

diff --git a/tests/fate/monkeysaudio.mak b/tests/fate/monkeysaudio.mak
index d75937ec02..03c646cd47 100644
--- a/tests/fate/monkeysaudio.mak
+++ b/tests/fate/monkeysaudio.mak
@@ -16,5 +16,8 @@ $(foreach N,$(APE_VERSIONS),$(eval $(call 
FATE_APE_SUITE,$(N
 FATE_APE += fate-lossless-monkeysaudio-399
 fate-lossless-monkeysaudio-399: CMD = md5 -i 
$(TARGET_SAMPLES)/lossless-audio/luckynight-partial.ape -f s16le -af aresample
 
+FATE_APE += fate-lossless-monkeysaudio-legacy
+fate-lossless-monkeysaudio-legacy: CMD = md5 -i 
$(TARGET_SAMPLES)/lossless-audio/NoLegacy-cut.ape -f s32le -af aresample
+
 FATE_SAMPLES_AVCONV-$(call DEMDEC, APE, APE) += $(FATE_APE)
 fate-lossless-monkeysaudio: $(FATE_APE)
diff --git a/tests/ref/fate/lossless-monkeysaudio-legacy 
b/tests/ref/fate/lossless-monkeysaudio-legacy
new file mode 100644
index 00..33d4b56204
--- /dev/null
+++ b/tests/ref/fate/lossless-monkeysaudio-legacy
@@ -0,0 +1 @@
+2cd8a60478c77382dfed8b8bdf1f70e4

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".