Re: [FFmpeg-devel] [PATCH 2/5] MAINTAINERS: some random updating

2024-08-29 Thread Rémi Denis-Courmont
No objections but IMO Alpha should be removed rather than blanked, given that 
it's indeed been removed...
___
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 v2 1/2] avformat/mxfenc: Fix guess frame_rate

2024-08-29 Thread Nicolas Gaullier
>De : ffmpeg-devel  De la part de Tomas Härdin
>Envoyé : lundi 26 août 2024 11:52
>
>This is probably fine for now, but it should be said that frame rate and 
>EditRate are not necessarily the same. We might want an explicit EditRate 
>option. But we can wait for users to actually request that feature
>
>/Tomas

It seems nobody objected, can this patch be applied ?
There is also a second patch in this serie for the corresponding fate tests 
"cleanup"; this is just in my mind to avoid confusing command lines arguments 
that don't take effect. Can you review it ?

Thank you
Nicolas
___
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/2] avcodec/jpeg2000dec: Fix FF_DWT97_INT to pass the conformance testing defined in ISO/IEC 15444-4.

2024-08-29 Thread Osamu Watanabe
From: OSAMU WATANABE 

This commit fixes the problem described below on the integer version of the 
inverse DWT processing (FF_DWT97_INT, https://trac.ffmpeg.org/ticket/10123), 
which is activated with `-flags +bitexact`.

- Problem
  - The tests for the following codestreams were filed with `-flags +bitexact`.
- p0_04.j2k, p0_05.j2k, p0_09.j2k, p1_02.j2k, p1_03.j2k, p1_06.j2k.
- ds0_ht_04_b11.j2k, ds0_ht_04_b12.j2k, ds0_ht_05_b11.j2k, 
ds0_ht_05_b12.j2k, ds0_ht_09_b11.j2k, ds1_ht_02_b11.j2k, ds1_ht_02_b12.j2k, 
ds1_ht_03_b11.j2k, ds1_ht_03_b12.j2k, ds1_ht_06_b11.j2k.

Co-authored-by: Pierre-Anthony Lemieux 
Signed-off-by: Osamu Watanabe 
---
 libavcodec/jpeg2000.c|  7 +++
 libavcodec/jpeg2000dec.c |  4 +++-
 libavcodec/jpeg2000dwt.c | 22 ++
 3 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/libavcodec/jpeg2000.c b/libavcodec/jpeg2000.c
index d6ffb02319..2d093e4705 100644
--- a/libavcodec/jpeg2000.c
+++ b/libavcodec/jpeg2000.c
@@ -260,9 +260,8 @@ static void init_band_stepsize(AVCodecContext *avctx,
 band->f_stepsize *= F_LFTG_X * F_LFTG_X * 4;
 break;
 }
-if (codsty->transform == FF_DWT97) {
-band->f_stepsize *= pow(F_LFTG_K, 2*(codsty->nreslevels2decode - 
reslevelno) + lband - 2);
-}
+// scaling
+band->f_stepsize *= pow(F_LFTG_K, 2*(codsty->nreslevels2decode - 
reslevelno) + lband - 2);
 }
 
 if (band->f_stepsize > (INT_MAX >> 15)) {
@@ -270,7 +269,7 @@ static void init_band_stepsize(AVCodecContext *avctx,
 av_log(avctx, AV_LOG_ERROR, "stepsize out of range\n");
 }
 
-band->i_stepsize = band->f_stepsize * (1 << 15);
+band->i_stepsize = lrint(band->f_stepsize * (1 << 15) + 0.5f);
 
 /* FIXME: In OpenJPEG code stepsize = stepsize * 0.5. Why?
  * If not set output of entropic decoder is not correct. */
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 2e09b279dc..6af8c764d0 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -2136,7 +2136,9 @@ static void dequantization_int_97(int x, int y, 
Jpeg2000Cblk *cblk,
 int32_t *datap = &comp->i_data[(comp->coord[0][1] - comp->coord[0][0]) 
* (y + j) + x];
 int *src = t1->data + j*t1->stride;
 for (i = 0; i < w; ++i)
-datap[i] = (src[i] * (int64_t)band->i_stepsize + (1<<15)) >> 16;
+// Shifting down to 1 bit above from the binary point.
+// This is mandatory for FF_DWT97_INT to pass the conformance 
testing.
+datap[i] = (int32_t)(src[i] * (int64_t)band->i_stepsize + (1 << 
14)) >> 15;
 }
 }
 
diff --git a/libavcodec/jpeg2000dwt.c b/libavcodec/jpeg2000dwt.c
index 34e33553f7..256de264f3 100644
--- a/libavcodec/jpeg2000dwt.c
+++ b/libavcodec/jpeg2000dwt.c
@@ -39,7 +39,7 @@
 
 /* Lifting parameters in integer format.
  * Computed as param = (float param) * (1 << 16) */
-#define I_LFTG_ALPHA  103949ll
+#define I_LFTG_ALPHA   38413ll // = 103949 - 65536, (= 1.586 - 1.0)
 #define I_LFTG_BETA 3472ll
 #define I_LFTG_GAMMA   57862ll
 #define I_LFTG_DELTA   29066ll
@@ -471,8 +471,11 @@ static void sr_1d97_int(int32_t *p, int i0, int i1)
 for (i = (i0 >> 1); i < (i1 >> 1) + 1; i++)
 p[2 * i] += (I_LFTG_BETA  * (p[2 * i - 1] + (int64_t)p[2 * i + 1]) 
+ (1 << 15)) >> 16;
 /* step 6 */
-for (i = (i0 >> 1); i < (i1 >> 1); i++)
-p[2 * i + 1] += (I_LFTG_ALPHA * (p[2 * i] + (int64_t)p[2 * i + 2]) 
+ (1 << 15)) >> 16;
+for (i = (i0 >> 1); i < (i1 >> 1); i++) {
+int64_t sum = p[2 * i] + (int64_t) p[2 * i + 2];
+p[2 * i + 1] += sum;
+p[2 * i + 1] += (I_LFTG_ALPHA * sum + (1 << 15)) >> 16;
+}
 }
 
 static void dwt_decode97_int(DWTContext *s, int32_t *t)
@@ -500,9 +503,9 @@ static void dwt_decode97_int(DWTContext *s, int32_t *t)
 l = line + mh;
 for (lp = 0; lp < lv; lp++) {
 int i, j = 0;
-// rescale with interleaving
+// interleaving
 for (i = mh; i < lh; i += 2, j++)
-l[i] = ((data[w * lp + j] * I_LFTG_K) + (1 << 15)) >> 16;
+l[i] = data[w * lp + j];
 for (i = 1 - mh; i < lh; i += 2, j++)
 l[i] = data[w * lp + j];
 
@@ -516,9 +519,9 @@ static void dwt_decode97_int(DWTContext *s, int32_t *t)
 l = line + mv;
 for (lp = 0; lp < lh; lp++) {
 int i, j = 0;
-// rescale with interleaving
+// interleaving
 for (i = mv; i < lv; i += 2, j++)
-l[i] = ((data[w * j + lp] * I_LFTG_K) + (1 << 15)) >> 16;
+l[i] = data[w * j + lp];
 for (i = 1 - mv; i < lv; i += 2, j++)
 l[i] = data[w * j + lp];
 
@@ -530,7 +533,10 @@ static void dwt_decode97_int(DWTContext *s, int32_t *t)
 }
 
 for (i = 0; i < w * h; i++)
-data[i] = (data[i] + ((1LL<>1)) >> I_PRESHIFT;
+// Shifting down to the bin

[FFmpeg-devel] [PATCH 2/2] avcodec/jpeg2000dec: Update FATE refs for conformance testing defined in ISO/IEC 15444-4

2024-08-29 Thread Osamu Watanabe
The FATE refs are updated to reflect changes in the [PATCH 1/2].

Signed-off-by: Osamu Watanabe 
---
 tests/ref/fate/jpeg2000dec-p0_04 | 2 +-
 tests/ref/fate/jpeg2000dec-p0_05 | 2 +-
 tests/ref/fate/jpeg2000dec-p0_09 | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/ref/fate/jpeg2000dec-p0_04 b/tests/ref/fate/jpeg2000dec-p0_04
index 5de7880c44..c293084a50 100644
--- a/tests/ref/fate/jpeg2000dec-p0_04
+++ b/tests/ref/fate/jpeg2000dec-p0_04
@@ -3,4 +3,4 @@
 #codec_id 0: rawvideo
 #dimensions 0: 640x480
 #sar 0: 0/1
-0,  0,  0,1,   921600, 0x097d9665
+0,  0,  0,1,   921600, 0x8577ffee
diff --git a/tests/ref/fate/jpeg2000dec-p0_05 b/tests/ref/fate/jpeg2000dec-p0_05
index bb215043a1..bd5cc4b77a 100644
--- a/tests/ref/fate/jpeg2000dec-p0_05
+++ b/tests/ref/fate/jpeg2000dec-p0_05
@@ -3,4 +3,4 @@
 #codec_id 0: rawvideo
 #dimensions 0: 1024x1024
 #sar 0: 0/1
-0,  0,  0,1,  2621440, 0x081f5048
+0,  0,  0,1,  2621440, 0x99604189
diff --git a/tests/ref/fate/jpeg2000dec-p0_09 b/tests/ref/fate/jpeg2000dec-p0_09
index 1755e7cc7d..ff78bf9dc7 100644
--- a/tests/ref/fate/jpeg2000dec-p0_09
+++ b/tests/ref/fate/jpeg2000dec-p0_09
@@ -3,4 +3,4 @@
 #codec_id 0: rawvideo
 #dimensions 0: 17x37
 #sar 0: 0/1
-0,  0,  0,1,  629, 0x5c9c389d
+0,  0,  0,1,  629, 0xf35d38d6
-- 
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/8] lavfi/aeval: convert to query_func2()

2024-08-29 Thread Anton Khirnov
Drop redundant ff_set_common_all_channel_counts() /
ff_set_common_all_samplerates() calls, since those happen implicitly in
generic code.
---
 libavfilter/aeval.c | 37 ++---
 1 file changed, 18 insertions(+), 19 deletions(-)

diff --git a/libavfilter/aeval.c b/libavfilter/aeval.c
index 9fb6354ed3..0e7ba8df80 100644
--- a/libavfilter/aeval.c
+++ b/libavfilter/aeval.c
@@ -242,23 +242,25 @@ static int config_props(AVFilterLink *outlink)
 return 0;
 }
 
-static int query_formats(AVFilterContext *ctx)
+static int query_formats(const AVFilterContext *ctx,
+ AVFilterFormatsConfig **cfg_in,
+ AVFilterFormatsConfig **cfg_out)
 {
-EvalContext *eval = ctx->priv;
+const EvalContext *eval = ctx->priv;
 static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_DBLP, 
AV_SAMPLE_FMT_NONE };
 AVChannelLayout chlayouts[] = { eval->chlayout.nb_channels ? 
eval->chlayout : FF_COUNT2LAYOUT(eval->nb_channels), { 0 } };
 int sample_rates[] = { eval->sample_rate, -1 };
 int ret;
 
-ret = ff_set_common_formats_from_list(ctx, sample_fmts);
+ret = ff_set_common_formats_from_list2(ctx, cfg_in, cfg_out, sample_fmts);
 if (ret < 0)
 return ret;
 
-ret = ff_set_common_channel_layouts_from_list(ctx, chlayouts);
+ret = ff_set_common_channel_layouts_from_list2(ctx, cfg_in, cfg_out, 
chlayouts);
 if (ret < 0)
 return ret;
 
-return ff_set_common_samplerates_from_list(ctx, sample_rates);
+return ff_set_common_samplerates_from_list2(ctx, cfg_in, cfg_out, 
sample_rates);
 }
 
 static int activate(AVFilterContext *ctx)
@@ -327,7 +329,7 @@ const AVFilter ff_asrc_aevalsrc = {
 .priv_size = sizeof(EvalContext),
 .inputs= NULL,
 FILTER_OUTPUTS(aevalsrc_outputs),
-FILTER_QUERY_FUNC(query_formats),
+FILTER_QUERY_FUNC2(query_formats),
 .priv_class= &aevalsrc_class,
 };
 
@@ -345,12 +347,12 @@ static const AVOption aeval_options[]= {
 
 AVFILTER_DEFINE_CLASS(aeval);
 
-static int aeval_query_formats(AVFilterContext *ctx)
+static int aeval_query_formats(const AVFilterContext *ctx,
+   AVFilterFormatsConfig **cfg_in,
+   AVFilterFormatsConfig **cfg_out)
 {
 AVFilterChannelLayouts *layouts;
-AVFilterLink *inlink  = ctx->inputs[0];
-AVFilterLink *outlink  = ctx->outputs[0];
-EvalContext *eval = ctx->priv;
+const EvalContext *eval = ctx->priv;
 static const enum AVSampleFormat sample_fmts[] = {
 AV_SAMPLE_FMT_DBLP, AV_SAMPLE_FMT_NONE
 };
@@ -358,25 +360,22 @@ static int aeval_query_formats(AVFilterContext *ctx)
 
 // inlink supports any channel layout
 layouts = ff_all_channel_counts();
-if ((ret = ff_channel_layouts_ref(layouts, 
&inlink->outcfg.channel_layouts)) < 0)
+if ((ret = ff_channel_layouts_ref(layouts, &cfg_in[0]->channel_layouts)) < 
0)
 return ret;
 
-if (eval->same_chlayout) {
-if ((ret = ff_set_common_all_channel_counts(ctx)) < 0)
-return ret;
-} else {
+if (!eval->same_chlayout) {
 // outlink supports only requested output channel layout
 layouts = NULL;
 if ((ret = ff_add_channel_layout(&layouts, 
&FF_COUNT2LAYOUT(eval->nb_channels))) < 0)
 return ret;
-if ((ret = ff_channel_layouts_ref(layouts, 
&outlink->incfg.channel_layouts)) < 0)
+if ((ret = ff_channel_layouts_ref(layouts, 
&cfg_out[0]->channel_layouts)) < 0)
 return ret;
 }
 
-if ((ret = ff_set_common_formats_from_list(ctx, sample_fmts)) < 0)
+if ((ret = ff_set_common_formats_from_list2(ctx, cfg_in, cfg_out, 
sample_fmts)) < 0)
 return ret;
 
-return ff_set_common_all_samplerates(ctx);
+return 0;
 }
 
 static int aeval_config_output(AVFilterLink *outlink)
@@ -471,7 +470,7 @@ const AVFilter ff_af_aeval = {
 .priv_size = sizeof(EvalContext),
 FILTER_INPUTS(aeval_inputs),
 FILTER_OUTPUTS(aeval_outputs),
-FILTER_QUERY_FUNC(aeval_query_formats),
+FILTER_QUERY_FUNC2(aeval_query_formats),
 .priv_class= &aeval_class,
 .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC,
 };
-- 
2.43.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 3/8] lavfi/af_aap: convert to query_func2()

2024-08-29 Thread Anton Khirnov
Drop redundant ff_set_common_all_channel_counts() /
ff_set_common_all_samplerates() calls, since those happen implicitly in
generic code.
---
 libavfilter/af_aap.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavfilter/af_aap.c b/libavfilter/af_aap.c
index 352f10cd8c..05608d7fbb 100644
--- a/libavfilter/af_aap.c
+++ b/libavfilter/af_aap.c
@@ -95,9 +95,11 @@ static const AVOption aap_options[] = {
 
 AVFILTER_DEFINE_CLASS(aap);
 
-static int query_formats(AVFilterContext *ctx)
+static int query_formats(const AVFilterContext *ctx,
+ AVFilterFormatsConfig **cfg_in,
+ AVFilterFormatsConfig **cfg_out)
 {
-AudioAPContext *s = ctx->priv;
+const AudioAPContext *s = ctx->priv;
 static const enum AVSampleFormat sample_fmts[3][3] = {
 { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_DBLP, AV_SAMPLE_FMT_NONE },
 { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE },
@@ -105,13 +107,11 @@ static int query_formats(AVFilterContext *ctx)
 };
 int ret;
 
-if ((ret = ff_set_common_all_channel_counts(ctx)) < 0)
+if ((ret = ff_set_common_formats_from_list2(ctx, cfg_in, cfg_out,
+sample_fmts[s->precision])) < 
0)
 return ret;
 
-if ((ret = ff_set_common_formats_from_list(ctx, 
sample_fmts[s->precision])) < 0)
-return ret;
-
-return ff_set_common_all_samplerates(ctx);
+return 0;
 }
 
 static int activate(AVFilterContext *ctx)
@@ -325,7 +325,7 @@ const AVFilter ff_af_aap = {
 .activate   = activate,
 FILTER_INPUTS(inputs),
 FILTER_OUTPUTS(outputs),
-FILTER_QUERY_FUNC(query_formats),
+FILTER_QUERY_FUNC2(query_formats),
 .flags  = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL |
   AVFILTER_FLAG_SLICE_THREADS,
 .process_command = ff_filter_process_command,
-- 
2.43.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 4/8] lavfi/af_acrossover: convert to query_func2()

2024-08-29 Thread Anton Khirnov
Drop redundant ff_set_common_all_channel_counts() /
ff_set_common_all_samplerates() calls, since those happen implicitly in
generic code.
---
 libavfilter/af_acrossover.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavfilter/af_acrossover.c b/libavfilter/af_acrossover.c
index 48ff002006..3fd5c1d246 100644
--- a/libavfilter/af_acrossover.c
+++ b/libavfilter/af_acrossover.c
@@ -108,9 +108,11 @@ static const AVOption acrossover_options[] = {
 
 AVFILTER_DEFINE_CLASS(acrossover);
 
-static int query_formats(AVFilterContext *ctx)
+static int query_formats(const AVFilterContext *ctx,
+ AVFilterFormatsConfig **cfg_in,
+ AVFilterFormatsConfig **cfg_out)
 {
-AudioCrossoverContext *s = ctx->priv;
+const AudioCrossoverContext *s = ctx->priv;
 static const enum AVSampleFormat auto_sample_fmts[] = {
 AV_SAMPLE_FMT_FLTP,
 AV_SAMPLE_FMT_DBLP,
@@ -121,9 +123,7 @@ static int query_formats(AVFilterContext *ctx)
 AV_SAMPLE_FMT_NONE
 };
 const enum AVSampleFormat *sample_fmts_list = sample_fmts;
-int ret = ff_set_common_all_channel_counts(ctx);
-if (ret < 0)
-return ret;
+int ret;
 
 switch (s->precision) {
 case 0:
@@ -138,11 +138,11 @@ static int query_formats(AVFilterContext *ctx)
 default:
 break;
 }
-ret = ff_set_common_formats_from_list(ctx, sample_fmts_list);
+ret = ff_set_common_formats_from_list2(ctx, cfg_in, cfg_out, 
sample_fmts_list);
 if (ret < 0)
 return ret;
 
-return ff_set_common_all_samplerates(ctx);
+return 0;
 }
 
 static int parse_gains(AVFilterContext *ctx)
@@ -627,7 +627,7 @@ const AVFilter ff_af_acrossover = {
 .uninit = uninit,
 FILTER_INPUTS(inputs),
 .outputs= NULL,
-FILTER_QUERY_FUNC(query_formats),
+FILTER_QUERY_FUNC2(query_formats),
 .flags  = AVFILTER_FLAG_DYNAMIC_OUTPUTS |
   AVFILTER_FLAG_SLICE_THREADS,
 };
-- 
2.43.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 5/8] lavfi/af_adynamicequalizer: convert to query_func2()

2024-08-29 Thread Anton Khirnov
Drop redundant ff_set_common_all_channel_counts() /
ff_set_common_all_samplerates() calls, since those happen implicitly in
generic code.
---
 libavfilter/af_adynamicequalizer.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavfilter/af_adynamicequalizer.c 
b/libavfilter/af_adynamicequalizer.c
index 7a102cad22..ba03faff60 100644
--- a/libavfilter/af_adynamicequalizer.c
+++ b/libavfilter/af_adynamicequalizer.c
@@ -110,9 +110,11 @@ typedef struct AudioDynamicEqualizerContext {
 ChannelContext *cc;
 } AudioDynamicEqualizerContext;
 
-static int query_formats(AVFilterContext *ctx)
+static int query_formats(const AVFilterContext *ctx,
+ AVFilterFormatsConfig **cfg_in,
+ AVFilterFormatsConfig **cfg_out)
 {
-AudioDynamicEqualizerContext *s = ctx->priv;
+const AudioDynamicEqualizerContext *s = ctx->priv;
 static const enum AVSampleFormat sample_fmts[3][3] = {
 { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_DBLP, AV_SAMPLE_FMT_NONE },
 { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE },
@@ -120,13 +122,11 @@ static int query_formats(AVFilterContext *ctx)
 };
 int ret;
 
-if ((ret = ff_set_common_all_channel_counts(ctx)) < 0)
+if ((ret = ff_set_common_formats_from_list2(ctx, cfg_in, cfg_out,
+sample_fmts[s->precision])) < 
0)
 return ret;
 
-if ((ret = ff_set_common_formats_from_list(ctx, 
sample_fmts[s->precision])) < 0)
-return ret;
-
-return ff_set_common_all_samplerates(ctx);
+return 0;
 }
 
 static double get_coef(double x, double sr)
@@ -281,7 +281,7 @@ const AVFilter ff_af_adynamicequalizer = {
 .uninit  = uninit,
 FILTER_INPUTS(inputs),
 FILTER_OUTPUTS(ff_audio_default_filterpad),
-FILTER_QUERY_FUNC(query_formats),
+FILTER_QUERY_FUNC2(query_formats),
 .flags   = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL |
AVFILTER_FLAG_SLICE_THREADS,
 .process_command = ff_filter_process_command,
-- 
2.43.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 6/8] lavfi/af_afir: convert to query_func2()

2024-08-29 Thread Anton Khirnov
Drop redundant ff_set_common_all_channel_counts() /
ff_set_common_all_samplerates() calls, since those happen implicitly in
generic code.
---
 libavfilter/af_afir.c | 25 -
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/libavfilter/af_afir.c b/libavfilter/af_afir.c
index 8ab4d544a8..c641893d4a 100644
--- a/libavfilter/af_afir.c
+++ b/libavfilter/af_afir.c
@@ -539,9 +539,11 @@ static int activate(AVFilterContext *ctx)
 return FFERROR_NOT_READY;
 }
 
-static int query_formats(AVFilterContext *ctx)
+static int query_formats(const AVFilterContext *ctx,
+ AVFilterFormatsConfig **cfg_in,
+ AVFilterFormatsConfig **cfg_out)
 {
-AudioFIRContext *s = ctx->priv;
+const AudioFIRContext *s = ctx->priv;
 static const enum AVSampleFormat sample_fmts[3][3] = {
 { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_DBLP, AV_SAMPLE_FMT_NONE },
 { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE },
@@ -549,32 +551,29 @@ static int query_formats(AVFilterContext *ctx)
 };
 int ret;
 
-if (s->ir_format) {
-ret = ff_set_common_all_channel_counts(ctx);
-if (ret < 0)
-return ret;
-} else {
+if (!s->ir_format) {
 AVFilterChannelLayouts *mono = NULL;
 AVFilterChannelLayouts *layouts = ff_all_channel_counts();
 
-if ((ret = ff_channel_layouts_ref(layouts, 
&ctx->inputs[0]->outcfg.channel_layouts)) < 0)
+if ((ret = ff_channel_layouts_ref(layouts, 
&cfg_in[0]->channel_layouts)) < 0)
 return ret;
-if ((ret = ff_channel_layouts_ref(layouts, 
&ctx->outputs[0]->incfg.channel_layouts)) < 0)
+if ((ret = ff_channel_layouts_ref(layouts, 
&cfg_out[0]->channel_layouts)) < 0)
 return ret;
 
 ret = ff_add_channel_layout(&mono, 
&(AVChannelLayout)AV_CHANNEL_LAYOUT_MONO);
 if (ret)
 return ret;
 for (int i = 1; i < ctx->nb_inputs; i++) {
-if ((ret = ff_channel_layouts_ref(mono, 
&ctx->inputs[i]->outcfg.channel_layouts)) < 0)
+if ((ret = ff_channel_layouts_ref(mono, 
&cfg_in[i]->channel_layouts)) < 0)
 return ret;
 }
 }
 
-if ((ret = ff_set_common_formats_from_list(ctx, 
sample_fmts[s->precision])) < 0)
+if ((ret = ff_set_common_formats_from_list2(ctx, cfg_in, cfg_out,
+sample_fmts[s->precision])) < 
0)
 return ret;
 
-return ff_set_common_all_samplerates(ctx);
+return 0;
 }
 
 static int config_output(AVFilterLink *outlink)
@@ -783,7 +782,7 @@ const AVFilter ff_af_afir = {
 .description   = NULL_IF_CONFIG_SMALL("Apply Finite Impulse Response 
filter with supplied coefficients in additional stream(s)."),
 .priv_size = sizeof(AudioFIRContext),
 .priv_class= &afir_class,
-FILTER_QUERY_FUNC(query_formats),
+FILTER_QUERY_FUNC2(query_formats),
 FILTER_OUTPUTS(outputs),
 .init  = init,
 .activate  = activate,
-- 
2.43.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 1/8] lavfi: add query_func2()

2024-08-29 Thread Anton Khirnov
It differs from query_func() in accepting arrays of input/output format
configurations to be filled as callback parameters. This allows to mark
the filter context as const, ensuring it is not modified by this
function, as it is not supposed to have any side effects beyond
returning the supported formats.
---
 libavfilter/avfilter.h   |  85 +++-
 libavfilter/avfiltergraph.c  |  43 ++
 libavfilter/filters.h|   4 +
 libavfilter/formats.c| 147 +++
 libavfilter/formats.h|  84 
 libavfilter/tests/filtfmts.c |  19 -
 6 files changed, 346 insertions(+), 36 deletions(-)

diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index 549fe6ce3a..1401577c50 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -98,6 +98,41 @@ const char *avfilter_pad_get_name(const AVFilterPad *pads, 
int pad_idx);
  */
 enum AVMediaType avfilter_pad_get_type(const AVFilterPad *pads, int pad_idx);
 
+/**
+ * Lists of formats / etc. supported by an end of a link.
+ *
+ * This structure is directly part of AVFilterLink, in two copies:
+ * one for the source filter, one for the destination filter.
+
+ * These lists are used for negotiating the format to actually be used,
+ * which will be loaded into the format and channel_layout members of
+ * AVFilterLink, when chosen.
+ */
+typedef struct AVFilterFormatsConfig {
+
+/**
+ * List of supported formats (pixel or sample).
+ */
+AVFilterFormats *formats;
+
+/**
+ * Lists of supported sample rates, only for audio.
+ */
+AVFilterFormats  *samplerates;
+
+/**
+ * Lists of supported channel layouts, only for audio.
+ */
+AVFilterChannelLayouts  *channel_layouts;
+
+/**
+ * Lists of supported YUV color metadata, only for YUV video.
+ */
+AVFilterFormats *color_spaces;  ///< AVColorSpace
+AVFilterFormats *color_ranges;  ///< AVColorRange
+
+} AVFilterFormatsConfig;
+
 /**
  * The number of the filter inputs is not determined just by AVFilter.inputs.
  * The filter might add additional inputs during initialization depending on 
the
@@ -324,6 +359,21 @@ typedef struct AVFilter {
  * AVERROR code otherwise
  */
 int (*query_func)(AVFilterContext *);
+
+/**
+ * Same as query_func(), except this function writes the results into
+ * provided arrays.
+ *
+ * @param cfg_in  array of input format configurations with as many
+ *members as the filters has inputs (NULL when there 
are
+ *no inputs);
+ * @param cfg_out array of output format configurations with as many
+ *members as the filters has outputs (NULL when there
+ *are no outputs);
+ */
+int (*query_func2)(const AVFilterContext *,
+   struct AVFilterFormatsConfig **cfg_in,
+   struct AVFilterFormatsConfig **cfg_out);
 /**
  * A pointer to an array of admissible pixel formats delimited
  * by AV_PIX_FMT_NONE. The generic code will use this list
@@ -492,41 +542,6 @@ struct AVFilterContext {
 int extra_hw_frames;
 };
 
-/**
- * Lists of formats / etc. supported by an end of a link.
- *
- * This structure is directly part of AVFilterLink, in two copies:
- * one for the source filter, one for the destination filter.
-
- * These lists are used for negotiating the format to actually be used,
- * which will be loaded into the format and channel_layout members of
- * AVFilterLink, when chosen.
- */
-typedef struct AVFilterFormatsConfig {
-
-/**
- * List of supported formats (pixel or sample).
- */
-AVFilterFormats *formats;
-
-/**
- * Lists of supported sample rates, only for audio.
- */
-AVFilterFormats  *samplerates;
-
-/**
- * Lists of supported channel layouts, only for audio.
- */
-AVFilterChannelLayouts  *channel_layouts;
-
-/**
- * Lists of supported YUV color metadata, only for YUV video.
- */
-AVFilterFormats *color_spaces;  ///< AVColorSpace
-AVFilterFormats *color_ranges;  ///< AVColorRange
-
-} AVFilterFormatsConfig;
-
 /**
  * A link between two filters. This contains pointers to the source and
  * destination filters between which this link exists, and the indexes of
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index 68e392b826..215e2e7d6e 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -352,6 +352,49 @@ static int filter_query_formats(AVFilterContext *ctx)
ctx->name, av_err2str(ret));
 return ret;
 }
+} else if (ctx->filter->formats_state == FF_FILTER_FORMATS_QUERY_FUNC2) {
+AVFilterFormatsConfig *cfg_in_stack[64], *cfg_out_stack[64];
+AVFilterFormatsConfig **cfg_in_dyn = NULL, **cfg_out_dyn = NULL;
+AVF

[FFmpeg-devel] [PATCH 8/8] lavfi/af_aformat: convert to query_func2()

2024-08-29 Thread Anton Khirnov
---
 libavfilter/af_aformat.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/libavfilter/af_aformat.c b/libavfilter/af_aformat.c
index dcedff7b70..a7d05a9ce8 100644
--- a/libavfilter/af_aformat.c
+++ b/libavfilter/af_aformat.c
@@ -104,25 +104,27 @@ static av_cold int init(AVFilterContext *ctx)
 return 0;
 }
 
-static int query_formats(AVFilterContext *ctx)
+static int query_formats(const AVFilterContext *ctx,
+ AVFilterFormatsConfig **cfg_in,
+ AVFilterFormatsConfig **cfg_out)
 {
-AFormatContext *s = ctx->priv;
+const AFormatContext *s = ctx->priv;
 int ret;
 
 if (s->nb_formats) {
-ret = ff_set_common_formats_from_list(ctx, s->formats);
+ret = ff_set_common_formats_from_list2(ctx, cfg_in, cfg_out, 
s->formats);
 if (ret < 0)
 return ret;
 }
 
 if (s->nb_sample_rates) {
-ret = ff_set_common_samplerates_from_list(ctx, s->sample_rates);
+ret = ff_set_common_samplerates_from_list2(ctx, cfg_in, cfg_out, 
s->sample_rates);
 if (ret < 0)
 return ret;
 }
 
 if (s->nb_channel_layouts) {
-ret = ff_set_common_channel_layouts_from_list(ctx, s->channel_layouts);
+ret = ff_set_common_channel_layouts_from_list2(ctx, cfg_in, cfg_out, 
s->channel_layouts);
 if (ret < 0)
 return ret;
 }
@@ -139,5 +141,5 @@ const AVFilter ff_af_aformat = {
 .flags = AVFILTER_FLAG_METADATA_ONLY,
 FILTER_INPUTS(ff_audio_default_filterpad),
 FILTER_OUTPUTS(ff_audio_default_filterpad),
-FILTER_QUERY_FUNC(query_formats),
+FILTER_QUERY_FUNC2(query_formats),
 };
-- 
2.43.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 7/8] lavfi/af_aformat: change options from strings to arrays

2024-08-29 Thread Anton Khirnov
Allows to drop custom parsing code, and also the assumption that
query_formats() is not called more than once.
---
 libavfilter/af_aformat.c | 168 ---
 1 file changed, 67 insertions(+), 101 deletions(-)

diff --git a/libavfilter/af_aformat.c b/libavfilter/af_aformat.c
index b4cf5f1426..dcedff7b70 100644
--- a/libavfilter/af_aformat.c
+++ b/libavfilter/af_aformat.c
@@ -26,6 +26,7 @@
 #include "libavutil/avstring.h"
 #include "libavutil/channel_layout.h"
 #include "libavutil/common.h"
+#include "libavutil/mem.h"
 #include "libavutil/opt.h"
 
 #include "audio.h"
@@ -36,138 +37,103 @@
 typedef struct AFormatContext {
 const AVClass   *class;
 
-AVFilterFormats *formats;
-AVFilterFormats *sample_rates;
-AVFilterChannelLayouts *channel_layouts;
+enum AVSampleFormat *formats;
+unsigned  nb_formats;
 
-char *formats_str;
-char *sample_rates_str;
-char *channel_layouts_str;
+int *sample_rates;
+unsigned  nb_sample_rates;
+
+AVChannelLayout *channel_layouts;
+unsigned  nb_channel_layouts;
 } AFormatContext;
 
+static const AVOptionArrayDef array_def = { .sep = '|' };
+
 #define OFFSET(x) offsetof(AFormatContext, x)
 #define A AV_OPT_FLAG_AUDIO_PARAM
 #define F AV_OPT_FLAG_FILTERING_PARAM
 static const AVOption aformat_options[] = {
-{ "sample_fmts", "A '|'-separated list of sample formats.",  
OFFSET(formats_str), AV_OPT_TYPE_STRING, .flags = A|F },
-{ "f",   "A '|'-separated list of sample formats.",  
OFFSET(formats_str), AV_OPT_TYPE_STRING, .flags = A|F },
-{ "sample_rates","A '|'-separated list of sample rates.",
OFFSET(sample_rates_str),AV_OPT_TYPE_STRING, .flags = A|F },
-{ "r",   "A '|'-separated list of sample rates.",
OFFSET(sample_rates_str),AV_OPT_TYPE_STRING, .flags = A|F },
-{ "channel_layouts", "A '|'-separated list of channel layouts.", 
OFFSET(channel_layouts_str), AV_OPT_TYPE_STRING, .flags = A|F },
-{ "cl",  "A '|'-separated list of channel layouts.", 
OFFSET(channel_layouts_str), AV_OPT_TYPE_STRING, .flags = A|F },
+{ "sample_fmts", "A '|'-separated list of sample formats.",  
OFFSET(formats),
+AV_OPT_TYPE_SAMPLE_FMT | AV_OPT_TYPE_FLAG_ARRAY, .default_val.arr = 
&array_def, .flags = A|F },
+{ "f",   "A '|'-separated list of sample formats.",  
OFFSET(formats),
+AV_OPT_TYPE_SAMPLE_FMT | AV_OPT_TYPE_FLAG_ARRAY, .default_val.arr = 
&array_def, .flags = A|F },
+{ "sample_rates","A '|'-separated list of sample rates.",
OFFSET(sample_rates),
+AV_OPT_TYPE_INT | AV_OPT_TYPE_FLAG_ARRAY, .default_val.arr = 
&array_def, .min = 1, .max = INT_MAX, .flags = A|F },
+{ "r",   "A '|'-separated list of sample rates.",
OFFSET(sample_rates),
+AV_OPT_TYPE_INT | AV_OPT_TYPE_FLAG_ARRAY, .default_val.arr = 
&array_def, .min = 1, .max = INT_MAX, .flags = A|F },
+{ "channel_layouts", "A '|'-separated list of channel layouts.", 
OFFSET(channel_layouts),
+AV_OPT_TYPE_CHLAYOUT | AV_OPT_TYPE_FLAG_ARRAY, .default_val.arr = 
&array_def, .flags = A|F },
+{ "cl",  "A '|'-separated list of channel layouts.", 
OFFSET(channel_layouts),
+AV_OPT_TYPE_CHLAYOUT | AV_OPT_TYPE_FLAG_ARRAY, .default_val.arr = 
&array_def, .flags = A|F },
 { NULL }
 };
 
 AVFILTER_DEFINE_CLASS(aformat);
 
-#define PARSE_FORMATS(str, type, list, add_to_list, get_fmt, none, desc)\
-do {\
-char *next, *cur = str; \
-int ret;\
-\
-while (cur) {   \
-type fmt;   \
-next = strchr(cur, '|');\
-if (next)   \
-*next++ = 0;\
-\
-if ((fmt = get_fmt(cur)) == none) { \
-av_log(ctx, AV_LOG_ERROR, "Error parsing " desc ": %s.\n", cur);\
-return AVERROR(EINVAL); \
-}   \
-if ((ret = add_to_list(&list, fmt)) < 0) {  \
-return ret; \
-}   \
-\
-cur = next; 

[FFmpeg-devel] [PATCH] lavc/opus*: move to opus/ subdir

2024-08-29 Thread Anton Khirnov
---
 libavcodec/Makefile   | 10 ++-
 libavcodec/aarch64/opusdsp_init.c |  2 +-
 libavcodec/opus/Makefile  | 30 +++
 libavcodec/{opus_celt.c => opus/celt.c}   |  6 ++--
 libavcodec/{opus_celt.h => opus/celt.h}   |  7 +++--
 libavcodec/{opusdec.c => opus/dec.c}  | 10 +++
 .../{opusdec_celt.c => opus/dec_celt.c}   |  6 ++--
 libavcodec/{opusdsp.c => opus/dsp.c}  |  2 +-
 libavcodec/{opusdsp.h => opus/dsp.h}  |  6 ++--
 libavcodec/{opusenc.c => opus/enc.c}  |  8 ++---
 libavcodec/{opusenc.h => opus/enc.h}  |  6 ++--
 libavcodec/{opusenc_psy.c => opus/enc_psy.c}  |  8 ++---
 libavcodec/{opusenc_psy.h => opus/enc_psy.h}  | 12 
 .../{opusenc_utils.h => opus/enc_utils.h} |  6 ++--
 libavcodec/{ => opus}/opus.h  |  6 ++--
 libavcodec/{opus_parse.c => opus/parse.c} |  2 +-
 libavcodec/{opus_parse.h => opus/parse.h} |  2 +-
 libavcodec/{opus_parser.c => opus/parser.c}   |  2 +-
 libavcodec/{opus_pvq.c => opus/pvq.c} |  4 +--
 libavcodec/{opus_pvq.h => opus/pvq.h} |  2 +-
 libavcodec/{opus_rc.c => opus/rc.c}   |  2 +-
 libavcodec/{opus_rc.h => opus/rc.h}   |  4 ++-
 libavcodec/{opus_silk.c => opus/silk.c}   |  6 ++--
 libavcodec/{opus_silk.h => opus/silk.h}   |  2 +-
 libavcodec/{opustab.c => opus/tab.c}  |  2 +-
 libavcodec/{opustab.h => opus/tab.h}  |  6 ++--
 libavcodec/riscv/opusdsp_init.c   |  2 +-
 libavcodec/x86/celt_pvq_init.c|  2 +-
 libavcodec/x86/opusdsp_init.c |  2 +-
 libavformat/mpegts.c  |  2 +-
 tests/checkasm/opusdsp.c  |  4 +--
 31 files changed, 100 insertions(+), 71 deletions(-)
 create mode 100644 libavcodec/opus/Makefile
 rename libavcodec/{opus_celt.c => opus/celt.c} (99%)
 rename libavcodec/{opus_celt.h => opus/celt.h} (98%)
 rename libavcodec/{opusdec.c => opus/dec.c} (99%)
 rename libavcodec/{opusdec_celt.c => opus/dec_celt.c} (99%)
 rename libavcodec/{opusdsp.c => opus/dsp.c} (98%)
 rename libavcodec/{opusdsp.h => opus/dsp.h} (92%)
 rename libavcodec/{opusenc.c => opus/enc.c} (99%)
 rename libavcodec/{opusenc.h => opus/enc.h} (94%)
 rename libavcodec/{opusenc_psy.c => opus/enc_psy.c} (99%)
 rename libavcodec/{opusenc_psy.h => opus/enc_psy.h} (94%)
 rename libavcodec/{opusenc_utils.h => opus/enc_utils.h} (96%)
 rename libavcodec/{ => opus}/opus.h (94%)
 rename libavcodec/{opus_parse.c => opus/parse.c} (99%)
 rename libavcodec/{opus_parse.h => opus/parse.h} (98%)
 rename libavcodec/{opus_parser.c => opus/parser.c} (99%)
 rename libavcodec/{opus_pvq.c => opus/pvq.c} (99%)
 rename libavcodec/{opus_pvq.h => opus/pvq.h} (98%)
 rename libavcodec/{opus_rc.c => opus/rc.c} (99%)
 rename libavcodec/{opus_rc.h => opus/rc.h} (99%)
 rename libavcodec/{opus_silk.c => opus/silk.c} (99%)
 rename libavcodec/{opus_silk.h => opus/silk.h} (98%)
 rename libavcodec/{opustab.c => opus/tab.c} (99%)
 rename libavcodec/{opustab.h => opus/tab.h} (98%)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3b4b8681f5..c80d29fe0f 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -66,6 +66,7 @@ OBJS = ac3_parser.o   
  \
 # subsystems
 include $(SRC_PATH)/libavcodec/aac/Makefile
 include $(SRC_PATH)/libavcodec/hevc/Makefile
+include $(SRC_PATH)/libavcodec/opus/Makefile
 include $(SRC_PATH)/libavcodec/vvc/Makefile
 -include $(SRC_PATH)/libavcodec/$(ARCH)/vvc/Makefile
 OBJS-$(CONFIG_AANDCTTABLES)+= aandcttab.o
@@ -576,11 +577,7 @@ OBJS-$(CONFIG_NELLYMOSER_ENCODER)  += nellymoserenc.o 
nellymoser.o
 OBJS-$(CONFIG_NOTCHLC_DECODER) += notchlc.o
 OBJS-$(CONFIG_NUV_DECODER) += nuv.o rtjpeg.o jpegquanttables.o
 OBJS-$(CONFIG_ON2AVC_DECODER)  += on2avc.o on2avcdata.o
-OBJS-$(CONFIG_OPUS_DECODER)+= opusdec.o opusdec_celt.o opus_celt.o 
\
-  opus_pvq.o opus_silk.o opustab.o 
vorbis_data.o \
-  opusdsp.o opus_parse.o opus_rc.o
-OBJS-$(CONFIG_OPUS_ENCODER)+= opusenc.o opusenc_psy.o opus_celt.o \
-  opus_pvq.o opus_rc.o opustab.o
+OBJS-$(CONFIG_OPUS_DECODER)+= vorbis_data.o
 OBJS-$(CONFIG_OSQ_DECODER) += osq.o
 OBJS-$(CONFIG_PAF_AUDIO_DECODER)   += pafaudio.o
 OBJS-$(CONFIG_PAF_VIDEO_DECODER)   += pafvideo.o
@@ -1213,8 +1210,7 @@ OBJS-$(CONFIG_MPEG4VIDEO_PARSER)   += 
mpeg4video_parser.o h263.o \
 OBJS-$(CONFIG_MPEGAUDIO_PARSER)+= mpegaudio_parser.o
 OBJS-$(CONFIG_MPEGVIDEO_PARSER)+= mpegvideo_parser.o\
   mpeg12.o mpeg12data.o
-OBJS-$(CONFIG_OPUS_PARSER) += opus_parser.o opus_parse.o \
-  vorbis_data.o
+OBJS-$(CONFIG_OPUS_PARSER)

Re: [FFmpeg-devel] [PATCH 4/4] swscale/aarch64/rgb2rgb: add neon implementation for rgb24toyv12

2024-08-29 Thread Martin Storsjö

On Thu, 29 Aug 2024, Ramiro Polla wrote:


On Wed, Aug 28, 2024 at 11:23 PM Martin Storsjö  wrote:

On Wed, 28 Aug 2024, Ramiro Polla wrote:



+2:
+// load first line
+ld3 {v16.8b, v17.8b, v18.8b}, [x0], #24
+ld3 {v19.8b, v20.8b, v21.8b}, [x0], #24


Hmm, can't we do just one single ld3 with .16b registers, instead of two
separate ones?

If you want to keep the same register layout as now, load into v19-v21,
then do "uxtl v16.8h, v19.8b; uxtl2 v19.8h, v19.16b".


Thanks, that made it faster.


+uxtlv16.8h, v16.8b  // v16 = B11
+uxtlv17.8h, v17.8b  // v17 = G11
+uxtlv18.8h, v18.8b  // v18 = R11
+uxtlv19.8h, v19.8b  // v19 = B12
+uxtlv20.8h, v20.8b  // v20 = G12
+uxtlv21.8h, v21.8b  // v21 = R12
+
+// calculate Y values for first line
+rgbconv16   v24, v16, v17, v18, BY, GY, RY // v24 = Y11
+rgbconv16   v25, v19, v20, v21, BY, GY, RY // v25 = Y12
+
+// pairwise add and save rgb values to calculate average
+addpv5.8h, v16.8h, v19.8h
+addpv6.8h, v17.8h, v20.8h
+addpv7.8h, v18.8h, v21.8h
+
+// load second line
+ld3 {v16.8b, v17.8b, v18.8b}, [x10], #24
+ld3 {v19.8b, v20.8b, v21.8b}, [x10], #24


It's a shame we can't start this load earlier. But as essentially
everything depends on the input as it is, in v16-v21, we'd pretty much
need to use different registers here in order to do that.

If you wanted to, you could try loading earlier, into different registers
(I think v26-v31 are free at this point?), while then doing the uxtl into
the same registers as before, which shouldn't require any further changes.


Thanks, that also led to a small improvement.

New patch attached.


The new version LGTM, thanks!

// Martin
___
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 2/2] aarch64/vvc: Bind h26x/sao filter implementation to vvc

2024-08-29 Thread Martin Storsjö

On Wed, 28 Aug 2024, Zhao Zhili wrote:


From: Zhao Zhili 

---
libavcodec/aarch64/h26x/dsp.h |  6 +++-
libavcodec/aarch64/h26x/sao_neon.S| 44 +--
libavcodec/aarch64/hevcdsp_init_aarch64.c |  2 +-
libavcodec/aarch64/vvc/Makefile   |  5 +--
libavcodec/aarch64/vvc/dsp_init.c |  6 
5 files changed, 48 insertions(+), 15 deletions(-)


These two patches look reasonable to me.

// Martin

___
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 08/10] MAINTAINERS: Add S field based on the linux kernel MAINTAINERs

2024-08-29 Thread Ronald S. Bultje
Hi,

On Wed, Aug 28, 2024 at 1:25 PM Michael Niedermayer 
wrote:

> +(T ) *SCM* tree type and location.
> +  Type is one of: git, hg, quilt, stgit, topgit
>

S (see subject) or T (see text)? One of them is contradicting the other.

Ronald
___
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] Enable D3D11 texture input to the MF encoder

2024-08-29 Thread erik
Hi;

Been a while since I submitted something.

Attached patch enabled D3D11 input for the MF encoder. 

Regards

Erik


0001-Allow-the-h264_mf-encoder-to-use-ID3D11Texture2D-fra.patch
Description: Binary data
___
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] configure: improve check for POSIX ioctl

2024-08-29 Thread Ramiro Polla
Instead of relying on system #ifdefs which may or may not be correct,
detect the POSIX ioctl signature at configure time.
---
 configure  | 2 ++
 libavdevice/v4l2.c | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 63f0429b02..ebbec49993 100755
--- a/configure
+++ b/configure
@@ -2524,6 +2524,7 @@ HAVE_LIST="
 opencl_videotoolbox
 perl
 pod2man
+posix_ioctl
 texi2html
 xmllint
 zlib_gzip
@@ -7158,6 +7159,7 @@ xmllint --version  > /dev/null 2>&1 && enable xmllint   
|| disable xmllint
 check_headers linux/fb.h
 check_headers linux/videodev2.h
 test_code cc linux/videodev2.h "struct v4l2_frmsizeenum vfse; 
vfse.discrete.width = 0;" && enable_sanitized struct_v4l2_frmivalenum_discrete
+test_code cc sys/ioctl.h "int ioctl(int, int, ...);" && enable posix_ioctl
 
 # check V4L2 codecs available in the API
 if enabled v4l2_m2m; then
diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
index 42d4b97c8f..0ae6872338 100644
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -111,7 +111,7 @@ struct video_data {
 int (*open_f)(const char *file, int oflag, ...);
 int (*close_f)(int fd);
 int (*dup_f)(int fd);
-#if defined(__sun) || defined(__BIONIC__) || defined(__musl__) /* POSIX-like */
+#if HAVE_POSIX_IOCTL
 int (*ioctl_f)(int fd, int request, ...);
 #else
 int (*ioctl_f)(int fd, unsigned long int request, ...);
-- 
2.30.2

___
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] Can't use __musl__ macro

2024-08-29 Thread Ramiro Polla
Hi,

On Mon, Aug 12, 2024 at 7:16 AM Lance Fredrickson
 wrote:
> In commit 9e674b31606c805dd31b4bb754364a72a5877238 of ffmpeg this change
> tries to detect musl libc by way of a "__musl__" macro.  This macro
> however, doesn't exist in musl. This results in an "incompatible pointer
> type" error under gcc-14.2 as detection falls through to the #else
> definition. This was in version 6.1.2 and looks like it is still present
> in master.  I can't say what the correct fix would be, I just manually
> patched for now.

musl tries to make itself undetectable. Instead of relying on system
#ifdefs which may or may not be correct, we should instead check for
the proper signature at configure time.

I sent a patch for this (look for the thread "[PATCH] configure:
improve check for POSIX ioctl").

I tested it with musl, glibc, and the android ndk. Brad, could you
test that this works as expected on BSD?

Thanks,
Ramiro
___
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] configure: improve check for POSIX ioctl

2024-08-29 Thread James Almer

On 8/29/2024 10:40 AM, Ramiro Polla wrote:

Instead of relying on system #ifdefs which may or may not be correct,
detect the POSIX ioctl signature at configure time.
---
  configure  | 2 ++
  libavdevice/v4l2.c | 2 +-
  2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 63f0429b02..ebbec49993 100755
--- a/configure
+++ b/configure
@@ -2524,6 +2524,7 @@ HAVE_LIST="
  opencl_videotoolbox
  perl
  pod2man
+posix_ioctl
  texi2html
  xmllint
  zlib_gzip
@@ -7158,6 +7159,7 @@ xmllint --version  > /dev/null 2>&1 && enable xmllint   
|| disable xmllint
  check_headers linux/fb.h
  check_headers linux/videodev2.h
  test_code cc linux/videodev2.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 
0;" && enable_sanitized struct_v4l2_frmivalenum_discrete
+test_code cc sys/ioctl.h "int ioctl(int, int, ...);" && enable posix_ioctl


Is this check going to fail for the targets where ioctl_f has request as 
an unsigned long int?


  
  # check V4L2 codecs available in the API

  if enabled v4l2_m2m; then
diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
index 42d4b97c8f..0ae6872338 100644
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -111,7 +111,7 @@ struct video_data {
  int (*open_f)(const char *file, int oflag, ...);
  int (*close_f)(int fd);
  int (*dup_f)(int fd);
-#if defined(__sun) || defined(__BIONIC__) || defined(__musl__) /* POSIX-like */
+#if HAVE_POSIX_IOCTL
  int (*ioctl_f)(int fd, int request, ...);
  #else
  int (*ioctl_f)(int fd, unsigned long int request, ...);


___
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] avcodec: add Mediacodec audio decoders support

2024-08-29 Thread Zhao Zhili



> On Aug 26, 2024, at 20:54, Matthieu Bouron  wrote:
> 
> ---
> 
> Diff with v2:
> - Dropped flac/vorbis/opus support

LGTM.

> 
> ---
> configure |   8 +
> libavcodec/Makefile   |   4 +
> libavcodec/allcodecs.c|   4 +
> libavcodec/mediacodecdec.c| 102 -
> libavcodec/mediacodecdec_common.c | 333 +++---
> 5 files changed, 420 insertions(+), 31 deletions(-)
> 
> diff --git a/configure b/configure
> index 0fd7901581..e454b44655 100755
> --- a/configure
> +++ b/configure
> @@ -3324,8 +3324,14 @@ amf_deps_any="libdl LoadLibrary"
> nvenc_deps="ffnvcodec"
> nvenc_deps_any="libdl LoadLibrary"
> 
> +aac_mediacodec_decoder_deps="mediacodec"
> +aac_mediacodec_decoder_select="aac_adtstoasc_bsf aac_parser"
> aac_mf_encoder_deps="mediafoundation"
> ac3_mf_encoder_deps="mediafoundation"
> +amrnb_mediacodec_decoder_deps="mediacodec"
> +amrnb_mediacodec_decoder_select="amr_parser"
> +amrwb_mediacodec_decoder_deps="mediacodec"
> +amrwb_mediacodec_decoder_select="amr_parser"
> av1_amf_encoder_deps="amf"
> av1_cuvid_decoder_deps="cuvid CUVIDAV1PICPARAMS"
> av1_mediacodec_decoder_deps="mediacodec"
> @@ -3387,6 +3393,8 @@ mjpeg_qsv_encoder_select="qsvenc"
> mjpeg_vaapi_encoder_deps="VAEncPictureParameterBufferJPEG"
> mjpeg_vaapi_encoder_select="cbs_jpeg jpegtables vaapi_encode"
> mp3_mf_encoder_deps="mediafoundation"
> +mp3_mediacodec_decoder_deps="mediacodec"
> +mp3_mediacodec_decoder_select="mpegaudioheader"
> mpeg1_cuvid_decoder_deps="cuvid"
> mpeg1_v4l2m2m_decoder_deps="v4l2_m2m mpeg1_v4l2_m2m"
> mpeg2_cuvid_decoder_deps="cuvid"
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index 262d0a3d3e..eab8bfac01 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -197,6 +197,7 @@ OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o 
> aaccoder.o aacenctab.o\
>   aacenc_pred.o \
>   psymodel.o kbdwin.o \
>   mpeg4audio_sample_rates.o
> +OBJS-$(CONFIG_AAC_MEDIACODEC_DECODER)  += mediacodecdec.o
> OBJS-$(CONFIG_AAC_MF_ENCODER)  += mfenc.o mf_utils.o
> OBJS-$(CONFIG_AASC_DECODER)+= aasc.o msrledec.o
> OBJS-$(CONFIG_AC3_DECODER) += ac3dec_float.o ac3dec_data.o ac3.o \
> @@ -223,6 +224,8 @@ OBJS-$(CONFIG_AMRWB_DECODER)   += amrwbdec.o 
> celp_filters.o   \
>   celp_math.o acelp_filters.o \
>   acelp_vectors.o \
>   acelp_pitch_delay.o
> +OBJS-$(CONFIG_AMRNB_MEDIACODEC_DECODER) += mediacodecdec.o
> +OBJS-$(CONFIG_AMRWB_MEDIACODEC_DECODER) += mediacodecdec.o
> OBJS-$(CONFIG_AMV_ENCODER) += mjpegenc.o mjpegenc_common.o
> OBJS-$(CONFIG_ANM_DECODER) += anm.o
> OBJS-$(CONFIG_ANULL_DECODER)   += null.o
> @@ -521,6 +524,7 @@ OBJS-$(CONFIG_MP2FIXED_ENCODER)+= 
> mpegaudioenc_fixed.o mpegaudio.o \
>   mpegaudiotabs.o
> OBJS-$(CONFIG_MP2FLOAT_DECODER)+= mpegaudiodec_float.o
> OBJS-$(CONFIG_MP3_DECODER) += mpegaudiodec_fixed.o
> +OBJS-$(CONFIG_MP3_MEDIACODEC_DECODER)  += mediacodecdec.o
> OBJS-$(CONFIG_MP3_MF_ENCODER)  += mfenc.o mf_utils.o
> OBJS-$(CONFIG_MP3ADU_DECODER)  += mpegaudiodec_fixed.o
> OBJS-$(CONFIG_MP3ADUFLOAT_DECODER) += mpegaudiodec_float.o
> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> index 09385be4ee..563afde355 100644
> --- a/libavcodec/allcodecs.c
> +++ b/libavcodec/allcodecs.c
> @@ -822,8 +822,11 @@ extern const FFCodec ff_idf_decoder;
> 
> /* external libraries, that shouldn't be used by default if one of the
>  * above is available */
> +extern const FFCodec ff_aac_mediacodec_decoder;
> extern const FFCodec ff_aac_mf_encoder;
> extern const FFCodec ff_ac3_mf_encoder;
> +extern const FFCodec ff_amrnb_mediacodec_decoder;
> +extern const FFCodec ff_amrwb_mediacodec_decoder;
> extern const FFCodec ff_h263_v4l2m2m_encoder;
> extern const FFCodec ff_libaom_av1_decoder;
> /* hwaccel hooks only, so prefer external decoders */
> @@ -863,6 +866,7 @@ extern const FFCodec ff_mjpeg_cuvid_decoder;
> extern const FFCodec ff_mjpeg_qsv_encoder;
> extern const FFCodec ff_mjpeg_qsv_decoder;
> extern const FFCodec ff_mjpeg_vaapi_encoder;
> +extern const FFCodec ff_mp3_mediacodec_decoder;
> extern const FFCodec ff_mp3_mf_encoder;
> extern const FFCodec ff_mpeg1_cuvid_decoder;
> extern const FFCodec ff_mpeg2_cuvid_decoder;
> diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c
> index 6d8dc600fe..6e1e7034ca 100644
> --- a/libavcodec/mediacodecdec.c
> +++ b/libavcodec/mediacodecdec.c
> @@ -291,7 +291,11 @@ done:
> CONFIG_MPEG4_MEDIACODEC_DECODER || \
> CONFIG_VP8_MEDIACODEC_DECODER   || \
> CONFIG_VP9_MEDIACODEC_DECODER   || \
> -CONFIG_AV1_MEDIACODEC_DECODER
> +CONFIG_AV1_

Re: [FFmpeg-devel] [PATCH 2/2] avcodec/jpeg2000dec: Update FATE refs for conformance testing defined in ISO/IEC 15444-4

2024-08-29 Thread Pierre-Anthony Lemieux
On Thu, Aug 29, 2024 at 1:29 AM Osamu Watanabe
 wrote:
>
> The FATE refs are updated to reflect changes in the [PATCH 1/2].

It looks like the fate-j2k-dwt and fate-jpeg2000-dcinema fate files
need to be regenerated as well.

>
> Signed-off-by: Osamu Watanabe 
> ---
>  tests/ref/fate/jpeg2000dec-p0_04 | 2 +-
>  tests/ref/fate/jpeg2000dec-p0_05 | 2 +-
>  tests/ref/fate/jpeg2000dec-p0_09 | 2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/tests/ref/fate/jpeg2000dec-p0_04 
> b/tests/ref/fate/jpeg2000dec-p0_04
> index 5de7880c44..c293084a50 100644
> --- a/tests/ref/fate/jpeg2000dec-p0_04
> +++ b/tests/ref/fate/jpeg2000dec-p0_04
> @@ -3,4 +3,4 @@
>  #codec_id 0: rawvideo
>  #dimensions 0: 640x480
>  #sar 0: 0/1
> -0,  0,  0,1,   921600, 0x097d9665
> +0,  0,  0,1,   921600, 0x8577ffee
> diff --git a/tests/ref/fate/jpeg2000dec-p0_05 
> b/tests/ref/fate/jpeg2000dec-p0_05
> index bb215043a1..bd5cc4b77a 100644
> --- a/tests/ref/fate/jpeg2000dec-p0_05
> +++ b/tests/ref/fate/jpeg2000dec-p0_05
> @@ -3,4 +3,4 @@
>  #codec_id 0: rawvideo
>  #dimensions 0: 1024x1024
>  #sar 0: 0/1
> -0,  0,  0,1,  2621440, 0x081f5048
> +0,  0,  0,1,  2621440, 0x99604189
> diff --git a/tests/ref/fate/jpeg2000dec-p0_09 
> b/tests/ref/fate/jpeg2000dec-p0_09
> index 1755e7cc7d..ff78bf9dc7 100644
> --- a/tests/ref/fate/jpeg2000dec-p0_09
> +++ b/tests/ref/fate/jpeg2000dec-p0_09
> @@ -3,4 +3,4 @@
>  #codec_id 0: rawvideo
>  #dimensions 0: 17x37
>  #sar 0: 0/1
> -0,  0,  0,1,  629, 0x5c9c389d
> +0,  0,  0,1,  629, 0xf35d38d6
> --
> 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] configure: improve check for POSIX ioctl

2024-08-29 Thread Ramiro Polla
On Thu, Aug 29, 2024 at 7:10 PM James Almer  wrote:
> On 8/29/2024 10:40 AM, Ramiro Polla wrote:
> > Instead of relying on system #ifdefs which may or may not be correct,
> > detect the POSIX ioctl signature at configure time.
> > ---
> >   configure  | 2 ++
> >   libavdevice/v4l2.c | 2 +-
> >   2 files changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/configure b/configure
> > index 63f0429b02..ebbec49993 100755
> > --- a/configure
> > +++ b/configure
> > @@ -2524,6 +2524,7 @@ HAVE_LIST="
> >   opencl_videotoolbox
> >   perl
> >   pod2man
> > +posix_ioctl
> >   texi2html
> >   xmllint
> >   zlib_gzip
> > @@ -7158,6 +7159,7 @@ xmllint --version  > /dev/null 2>&1 && enable xmllint 
> >   || disable xmllint
> >   check_headers linux/fb.h
> >   check_headers linux/videodev2.h
> >   test_code cc linux/videodev2.h "struct v4l2_frmsizeenum vfse; 
> > vfse.discrete.width = 0;" && enable_sanitized 
> > struct_v4l2_frmivalenum_discrete
> > +test_code cc sys/ioctl.h "int ioctl(int, int, ...);" && enable posix_ioctl
>
> Is this check going to fail for the targets where ioctl_f has request as
> an unsigned long int?

Yes. This is from config.log:

/tmp/ffconf.S7gHklXc/test.c: In function 'main':
/tmp/ffconf.S7gHklXc/test.c:2:22: error: conflicting types for
'ioctl'; have 'int(int,  int, ...)'
2 | int main(void) { int ioctl(int, int, ...);; return 0; }
  |  ^
In file included from /tmp/ffconf.S7gHklXc/test.c:1:
/usr/include/x86_64-linux-gnu/sys/ioctl.h:42:12: note: previous
declaration of 'ioctl' with type 'int(int,  long unsigned int, ...)'
   42 | extern int ioctl (int __fd, unsigned long int __request, ...) __THROW;
  |^
___
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] configure: improve check for POSIX ioctl

2024-08-29 Thread James Almer

On 8/29/2024 2:18 PM, Ramiro Polla wrote:

On Thu, Aug 29, 2024 at 7:10 PM James Almer  wrote:

On 8/29/2024 10:40 AM, Ramiro Polla wrote:

Instead of relying on system #ifdefs which may or may not be correct,
detect the POSIX ioctl signature at configure time.
---
   configure  | 2 ++
   libavdevice/v4l2.c | 2 +-
   2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 63f0429b02..ebbec49993 100755
--- a/configure
+++ b/configure
@@ -2524,6 +2524,7 @@ HAVE_LIST="
   opencl_videotoolbox
   perl
   pod2man
+posix_ioctl
   texi2html
   xmllint
   zlib_gzip
@@ -7158,6 +7159,7 @@ xmllint --version  > /dev/null 2>&1 && enable xmllint   
|| disable xmllint
   check_headers linux/fb.h
   check_headers linux/videodev2.h
   test_code cc linux/videodev2.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 
0;" && enable_sanitized struct_v4l2_frmivalenum_discrete
+test_code cc sys/ioctl.h "int ioctl(int, int, ...);" && enable posix_ioctl


Is this check going to fail for the targets where ioctl_f has request as
an unsigned long int?


Yes. This is from config.log:

/tmp/ffconf.S7gHklXc/test.c: In function 'main':
/tmp/ffconf.S7gHklXc/test.c:2:22: error: conflicting types for
'ioctl'; have 'int(int,  int, ...)'
 2 | int main(void) { int ioctl(int, int, ...);; return 0; }
   |  ^
In file included from /tmp/ffconf.S7gHklXc/test.c:1:
/usr/include/x86_64-linux-gnu/sys/ioctl.h:42:12: note: previous
declaration of 'ioctl' with type 'int(int,  long unsigned int, ...)'
42 | extern int ioctl (int __fd, unsigned long int __request, ...) __THROW;
   |^


Cool. Should be ok then. Just remove the colon at the end of the check 
since test_code() will add one. Some compiler settings like -pedantic 
may complain about it, so better safe than sorry.


___
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] avcodec/mpegvideo: remove redundant workaround to recalculate last nonzero coefficient

2024-08-29 Thread Michael Niedermayer
On Wed, Aug 28, 2024 at 02:14:33PM +0200, Ramiro Polla wrote:
> On Thu, Aug 22, 2024 at 1:24 AM Ramiro Polla  wrote:
> > The x86 optimized dct_quantize only calculates the last nonzero
> > coefficient correctly if the zigzag scan order is used. For the
> > alternate scan order, this value is incorrect.
> >
> > To work around this, the dct_unquantize functions process the entire
> > block if the alternate scan order is used.
> >
> > But a second workaround (bb198e198ab) was added that recalculates the
> > last nonzero coefficient after dct_quantize is called if the alternate
> > scan order is used.
> >
> > This commit removes the first workaround, which became redundant.
> > ---
> >  libavcodec/mpegvideo.c | 9 +++--
> >  libavcodec/x86/mpegvideo.c | 6 ++
> >  2 files changed, 5 insertions(+), 10 deletions(-)
> 
> Michael, could you please check if my analysis and the changes are correct?

If you tested it and it works it has to be correct.
This would result in significant errors if it was wrong

thx

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

The misfortune of the wise is better than the prosperity of the fool.
-- Epicurus


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] lavc/opus*: move to opus/ subdir

2024-08-29 Thread Lynne via ffmpeg-devel

On 29/08/2024 11:34, Anton Khirnov wrote:

---
  libavcodec/Makefile   | 10 ++-
  libavcodec/aarch64/opusdsp_init.c |  2 +-
  libavcodec/opus/Makefile  | 30 +++
  libavcodec/{opus_celt.c => opus/celt.c}   |  6 ++--
  libavcodec/{opus_celt.h => opus/celt.h}   |  7 +++--
  libavcodec/{opusdec.c => opus/dec.c}  | 10 +++
  .../{opusdec_celt.c => opus/dec_celt.c}   |  6 ++--
  libavcodec/{opusdsp.c => opus/dsp.c}  |  2 +-
  libavcodec/{opusdsp.h => opus/dsp.h}  |  6 ++--
  libavcodec/{opusenc.c => opus/enc.c}  |  8 ++---
  libavcodec/{opusenc.h => opus/enc.h}  |  6 ++--
  libavcodec/{opusenc_psy.c => opus/enc_psy.c}  |  8 ++---
  libavcodec/{opusenc_psy.h => opus/enc_psy.h}  | 12 
  .../{opusenc_utils.h => opus/enc_utils.h} |  6 ++--
  libavcodec/{ => opus}/opus.h  |  6 ++--
  libavcodec/{opus_parse.c => opus/parse.c} |  2 +-
  libavcodec/{opus_parse.h => opus/parse.h} |  2 +-
  libavcodec/{opus_parser.c => opus/parser.c}   |  2 +-
  libavcodec/{opus_pvq.c => opus/pvq.c} |  4 +--
  libavcodec/{opus_pvq.h => opus/pvq.h} |  2 +-
  libavcodec/{opus_rc.c => opus/rc.c}   |  2 +-
  libavcodec/{opus_rc.h => opus/rc.h}   |  4 ++-
  libavcodec/{opus_silk.c => opus/silk.c}   |  6 ++--
  libavcodec/{opus_silk.h => opus/silk.h}   |  2 +-
  libavcodec/{opustab.c => opus/tab.c}  |  2 +-
  libavcodec/{opustab.h => opus/tab.h}  |  6 ++--
  libavcodec/riscv/opusdsp_init.c   |  2 +-
  libavcodec/x86/celt_pvq_init.c|  2 +-
  libavcodec/x86/opusdsp_init.c |  2 +-
  libavformat/mpegts.c  |  2 +-
  tests/checkasm/opusdsp.c  |  4 +--
  31 files changed, 100 insertions(+), 71 deletions(-)
  create mode 100644 libavcodec/opus/Makefile
  rename libavcodec/{opus_celt.c => opus/celt.c} (99%)
  rename libavcodec/{opus_celt.h => opus/celt.h} (98%)
  rename libavcodec/{opusdec.c => opus/dec.c} (99%)
  rename libavcodec/{opusdec_celt.c => opus/dec_celt.c} (99%)
  rename libavcodec/{opusdsp.c => opus/dsp.c} (98%)
  rename libavcodec/{opusdsp.h => opus/dsp.h} (92%)
  rename libavcodec/{opusenc.c => opus/enc.c} (99%)
  rename libavcodec/{opusenc.h => opus/enc.h} (94%)
  rename libavcodec/{opusenc_psy.c => opus/enc_psy.c} (99%)
  rename libavcodec/{opusenc_psy.h => opus/enc_psy.h} (94%)
  rename libavcodec/{opusenc_utils.h => opus/enc_utils.h} (96%)
  rename libavcodec/{ => opus}/opus.h (94%)
  rename libavcodec/{opus_parse.c => opus/parse.c} (99%)
  rename libavcodec/{opus_parse.h => opus/parse.h} (98%)
  rename libavcodec/{opus_parser.c => opus/parser.c} (99%)
  rename libavcodec/{opus_pvq.c => opus/pvq.c} (99%)
  rename libavcodec/{opus_pvq.h => opus/pvq.h} (98%)
  rename libavcodec/{opus_rc.c => opus/rc.c} (99%)
  rename libavcodec/{opus_rc.h => opus/rc.h} (99%)
  rename libavcodec/{opus_silk.c => opus/silk.c} (99%)
  rename libavcodec/{opus_silk.h => opus/silk.h} (98%)
  rename libavcodec/{opustab.c => opus/tab.c} (99%)
  rename libavcodec/{opustab.h => opus/tab.h} (98%)



Sure.
LGTM.


OpenPGP_0xA2FEA5F03F034464.asc
Description: OpenPGP public key


OpenPGP_signature.asc
Description: OpenPGP digital 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 38/42] fftools/ffmpeg: add support for multiview video

2024-08-29 Thread Michael Niedermayer
On Tue, Aug 27, 2024 at 05:05:18PM +0200, Anton Khirnov wrote:
> This extends the syntax for specifying input streams in -map and complex
> filtergraph labels, to allow selecting a view by view ID, index, or
> position. The corresponding decoder is then set up to decode the
> appropriate view and send frames for that view to the correct
> filtergraph input(s).
> ---
>  doc/ffmpeg.texi   |  30 +++-
>  fftools/cmdutils.c|   2 +-
>  fftools/cmdutils.h|   2 +
>  fftools/ffmpeg.h  |  45 -
>  fftools/ffmpeg_dec.c  | 355 +-
>  fftools/ffmpeg_demux.c|  24 ++-
>  fftools/ffmpeg_filter.c   |  71 +---
>  fftools/ffmpeg_mux_init.c |  29 +++-
>  fftools/ffmpeg_opt.c  |  70 +++-
>  9 files changed, 575 insertions(+), 53 deletions(-)

breaks build on mingw64

src/fftools/ffmpeg_dec.c: In function ‘packet_decode’:
src/fftools/ffmpeg_dec.c:811:19: error: implicit declaration of function ‘ffs’ 
[-Werror=implicit-function-declaration]
  811 | pos = ffs(outputs_mask) - 1;
  |   ^~~
cc1: some warnings being treated as errors
make: *** [src/ffbuild/common.mak:81: fftools/ffmpeg_dec.o] Error 1
make: *** Waiting for unfinished jobs

thx

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

Democracy is the form of government in which you can choose your dictator


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 2/2] avcodec/jpeg2000dec: Update FATE refs for conformance testing defined in ISO/IEC 15444-4

2024-08-29 Thread WATANABE Osamu
Hi Pierre,

Thanks for pointing it out.
I will include them and then submit v2 of the patch set.

Best,
Osamu

> 2024/08/30 1:52、Pierre-Anthony Lemieux のメール:
> 
> ?On Thu, Aug 29, 2024 at 1:29?AM Osamu Watanabe
>  wrote:
>> 
>> The FATE refs are updated to reflect changes in the [PATCH 1/2].
> 
> It looks like the fate-j2k-dwt and fate-jpeg2000-dcinema fate files
> need to be regenerated as well.
> 
>> 
>> Signed-off-by: Osamu Watanabe 
>> ---
>> tests/ref/fate/jpeg2000dec-p0_04 | 2 +-
>> tests/ref/fate/jpeg2000dec-p0_05 | 2 +-
>> tests/ref/fate/jpeg2000dec-p0_09 | 2 +-
>> 3 files changed, 3 insertions(+), 3 deletions(-)
>> 
>> diff --git a/tests/ref/fate/jpeg2000dec-p0_04 
>> b/tests/ref/fate/jpeg2000dec-p0_04
>> index 5de7880c44..c293084a50 100644
>> --- a/tests/ref/fate/jpeg2000dec-p0_04
>> +++ b/tests/ref/fate/jpeg2000dec-p0_04
>> @@ -3,4 +3,4 @@
>> #codec_id 0: rawvideo
>> #dimensions 0: 640x480
>> #sar 0: 0/1
>> -0,  0,  0,1,   921600, 0x097d9665
>> +0,  0,  0,1,   921600, 0x8577ffee
>> diff --git a/tests/ref/fate/jpeg2000dec-p0_05 
>> b/tests/ref/fate/jpeg2000dec-p0_05
>> index bb215043a1..bd5cc4b77a 100644
>> --- a/tests/ref/fate/jpeg2000dec-p0_05
>> +++ b/tests/ref/fate/jpeg2000dec-p0_05
>> @@ -3,4 +3,4 @@
>> #codec_id 0: rawvideo
>> #dimensions 0: 1024x1024
>> #sar 0: 0/1
>> -0,  0,  0,1,  2621440, 0x081f5048
>> +0,  0,  0,1,  2621440, 0x99604189
>> diff --git a/tests/ref/fate/jpeg2000dec-p0_09 
>> b/tests/ref/fate/jpeg2000dec-p0_09
>> index 1755e7cc7d..ff78bf9dc7 100644
>> --- a/tests/ref/fate/jpeg2000dec-p0_09
>> +++ b/tests/ref/fate/jpeg2000dec-p0_09
>> @@ -3,4 +3,4 @@
>> #codec_id 0: rawvideo
>> #dimensions 0: 17x37
>> #sar 0: 0/1
>> -0,  0,  0,1,  629, 0x5c9c389d
>> +0,  0,  0,1,  629, 0xf35d38d6
>> --
>> 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 38/42] fftools/ffmpeg: add support for multiview video

2024-08-29 Thread James Almer

On 8/29/2024 8:26 PM, Michael Niedermayer wrote:

On Tue, Aug 27, 2024 at 05:05:18PM +0200, Anton Khirnov wrote:

This extends the syntax for specifying input streams in -map and complex
filtergraph labels, to allow selecting a view by view ID, index, or
position. The corresponding decoder is then set up to decode the
appropriate view and send frames for that view to the correct
filtergraph input(s).
---
  doc/ffmpeg.texi   |  30 +++-
  fftools/cmdutils.c|   2 +-
  fftools/cmdutils.h|   2 +
  fftools/ffmpeg.h  |  45 -
  fftools/ffmpeg_dec.c  | 355 +-
  fftools/ffmpeg_demux.c|  24 ++-
  fftools/ffmpeg_filter.c   |  71 +---
  fftools/ffmpeg_mux_init.c |  29 +++-
  fftools/ffmpeg_opt.c  |  70 +++-
  9 files changed, 575 insertions(+), 53 deletions(-)


breaks build on mingw64

src/fftools/ffmpeg_dec.c: In function ‘packet_decode’:
src/fftools/ffmpeg_dec.c:811:19: error: implicit declaration of function ‘ffs’ 
[-Werror=implicit-function-declaration]
   811 | pos = ffs(outputs_mask) - 1;
   |   ^~~
cc1: some warnings being treated as errors
make: *** [src/ffbuild/common.mak:81: fftools/ffmpeg_dec.o] Error 1
make: *** Waiting for unfinished jobs

thx


Would ff_clz(outputs_mask) work here?

___
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/2] avformat/isom: make the parameter used for loging in ff_mp4_read_descr() a pointer to void

2024-08-29 Thread James Almer
Signed-off-by: James Almer 
---
 libavformat/isom.c | 4 ++--
 libavformat/isom.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavformat/isom.c b/libavformat/isom.c
index 74bb13dc96..65d71ed9d0 100644
--- a/libavformat/isom.c
+++ b/libavformat/isom.c
@@ -292,12 +292,12 @@ int ff_mp4_read_descr_len(AVIOContext *pb)
 return len;
 }
 
-int ff_mp4_read_descr(AVFormatContext *fc, AVIOContext *pb, int *tag)
+int ff_mp4_read_descr(void *logctx, AVIOContext *pb, int *tag)
 {
 int len;
 *tag = avio_r8(pb);
 len = ff_mp4_read_descr_len(pb);
-av_log(fc, AV_LOG_TRACE, "MPEG-4 description: tag=0x%02x len=%d\n", *tag, 
len);
+av_log(logctx, AV_LOG_TRACE, "MPEG-4 description: tag=0x%02x len=%d\n", 
*tag, len);
 return len;
 }
 
diff --git a/libavformat/isom.h b/libavformat/isom.h
index 5b6125a908..ceb3aa2f49 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -363,7 +363,7 @@ typedef struct MOVContext {
 } MOVContext;
 
 int ff_mp4_read_descr_len(AVIOContext *pb);
-int ff_mp4_read_descr(AVFormatContext *fc, AVIOContext *pb, int *tag);
+int ff_mp4_read_descr(void *logctx, AVIOContext *pb, int *tag);
 int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, 
AVIOContext *pb);
 void ff_mp4_parse_es_descr(AVIOContext *pb, int *es_id);
 
-- 
2.46.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 2/2] avformat/iamf_parse: fix parsing AAC DecoderConfigDescriptor

2024-08-29 Thread James Almer
Use ff_mp4_read_descr() to read both the tags and the vlc value
that comes after it, which was not being taken into account.

Ref: https://github.com/AOMediaCodec/libiamf/issues/119

Signed-off-by: James Almer 
---
 libavformat/iamf_parse.c | 21 +
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/libavformat/iamf_parse.c b/libavformat/iamf_parse.c
index 080c1a457a..8890bcf7ae 100644
--- a/libavformat/iamf_parse.c
+++ b/libavformat/iamf_parse.c
@@ -62,12 +62,12 @@ static int aac_decoder_config(IAMFCodecConfig *codec_config,
 {
 MPEG4AudioConfig cfg = { 0 };
 int object_type_id, codec_id, stream_type;
-int ret, tag, left;
+int ret, tag;
 
 if (codec_config->audio_roll_distance >= 0)
 return AVERROR_INVALIDDATA;
 
-tag = avio_r8(pb);
+ff_mp4_read_descr(logctx, pb, &tag);
 if (tag != MP4DecConfigDescrTag)
 return AVERROR_INVALIDDATA;
 
@@ -87,22 +87,19 @@ static int aac_decoder_config(IAMFCodecConfig *codec_config,
 if (codec_id && codec_id != codec_config->codec_id)
 return AVERROR_INVALIDDATA;
 
-tag = avio_r8(pb);
-if (tag != MP4DecSpecificDescrTag)
-return AVERROR_INVALIDDATA;
-
-left = len - avio_tell(pb);
-if (left <= 0)
+len = ff_mp4_read_descr(logctx, pb, &tag);
+if (tag != MP4DecSpecificDescrTag ||
+!len || (uint64_t)len > (1<<30))
 return AVERROR_INVALIDDATA;
 
 // We pad extradata here because avpriv_mpeg4audio_get_config2() needs it.
-codec_config->extradata = av_malloc((size_t)left + 
AV_INPUT_BUFFER_PADDING_SIZE);
+codec_config->extradata = av_malloc((size_t)len + 
AV_INPUT_BUFFER_PADDING_SIZE);
 if (!codec_config->extradata)
 return AVERROR(ENOMEM);
 
-codec_config->extradata_size = avio_read(pb, codec_config->extradata, 
left);
-if (codec_config->extradata_size < left)
-return AVERROR_INVALIDDATA;
+codec_config->extradata_size = ffio_read_size(pb, codec_config->extradata, 
len);
+if (ret < 0)
+return ret;
 memset(codec_config->extradata + codec_config->extradata_size, 0,
AV_INPUT_BUFFER_PADDING_SIZE);
 
-- 
2.46.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 v2 1/2] avcodec/jpeg2000dec: Fix FF_DWT97_INT to pass the conformance testing defined in ISO/IEC 15444-4.

2024-08-29 Thread Osamu Watanabe
From: OSAMU WATANABE 

This commit fixes the problem described below on the integer version of the 
inverse DWT processing (FF_DWT97_INT, https://trac.ffmpeg.org/ticket/10123), 
which is activated with `-flags +bitexact`.

- Problem
  - The tests for the following codestreams were filed with `-flags +bitexact`.
- p0_04.j2k, p0_05.j2k, p0_09.j2k, p1_02.j2k, p1_03.j2k, p1_06.j2k.
- ds0_ht_04_b11.j2k, ds0_ht_04_b12.j2k, ds0_ht_05_b11.j2k, 
ds0_ht_05_b12.j2k, ds0_ht_09_b11.j2k, ds1_ht_02_b11.j2k, ds1_ht_02_b12.j2k, 
ds1_ht_03_b11.j2k, ds1_ht_03_b12.j2k, ds1_ht_06_b11.j2k.

Co-authored-by: Pierre-Anthony Lemieux 
Signed-off-by: Osamu Watanabe 
---
 libavcodec/jpeg2000.c|  7 +++
 libavcodec/jpeg2000dec.c |  4 +++-
 libavcodec/jpeg2000dwt.c | 22 ++
 3 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/libavcodec/jpeg2000.c b/libavcodec/jpeg2000.c
index d6ffb02319..2d093e4705 100644
--- a/libavcodec/jpeg2000.c
+++ b/libavcodec/jpeg2000.c
@@ -260,9 +260,8 @@ static void init_band_stepsize(AVCodecContext *avctx,
 band->f_stepsize *= F_LFTG_X * F_LFTG_X * 4;
 break;
 }
-if (codsty->transform == FF_DWT97) {
-band->f_stepsize *= pow(F_LFTG_K, 2*(codsty->nreslevels2decode - 
reslevelno) + lband - 2);
-}
+// scaling
+band->f_stepsize *= pow(F_LFTG_K, 2*(codsty->nreslevels2decode - 
reslevelno) + lband - 2);
 }
 
 if (band->f_stepsize > (INT_MAX >> 15)) {
@@ -270,7 +269,7 @@ static void init_band_stepsize(AVCodecContext *avctx,
 av_log(avctx, AV_LOG_ERROR, "stepsize out of range\n");
 }
 
-band->i_stepsize = band->f_stepsize * (1 << 15);
+band->i_stepsize = lrint(band->f_stepsize * (1 << 15) + 0.5f);
 
 /* FIXME: In OpenJPEG code stepsize = stepsize * 0.5. Why?
  * If not set output of entropic decoder is not correct. */
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 2e09b279dc..6af8c764d0 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -2136,7 +2136,9 @@ static void dequantization_int_97(int x, int y, 
Jpeg2000Cblk *cblk,
 int32_t *datap = &comp->i_data[(comp->coord[0][1] - comp->coord[0][0]) 
* (y + j) + x];
 int *src = t1->data + j*t1->stride;
 for (i = 0; i < w; ++i)
-datap[i] = (src[i] * (int64_t)band->i_stepsize + (1<<15)) >> 16;
+// Shifting down to 1 bit above from the binary point.
+// This is mandatory for FF_DWT97_INT to pass the conformance 
testing.
+datap[i] = (int32_t)(src[i] * (int64_t)band->i_stepsize + (1 << 
14)) >> 15;
 }
 }
 
diff --git a/libavcodec/jpeg2000dwt.c b/libavcodec/jpeg2000dwt.c
index 34e33553f7..256de264f3 100644
--- a/libavcodec/jpeg2000dwt.c
+++ b/libavcodec/jpeg2000dwt.c
@@ -39,7 +39,7 @@
 
 /* Lifting parameters in integer format.
  * Computed as param = (float param) * (1 << 16) */
-#define I_LFTG_ALPHA  103949ll
+#define I_LFTG_ALPHA   38413ll // = 103949 - 65536, (= 1.586 - 1.0)
 #define I_LFTG_BETA 3472ll
 #define I_LFTG_GAMMA   57862ll
 #define I_LFTG_DELTA   29066ll
@@ -471,8 +471,11 @@ static void sr_1d97_int(int32_t *p, int i0, int i1)
 for (i = (i0 >> 1); i < (i1 >> 1) + 1; i++)
 p[2 * i] += (I_LFTG_BETA  * (p[2 * i - 1] + (int64_t)p[2 * i + 1]) 
+ (1 << 15)) >> 16;
 /* step 6 */
-for (i = (i0 >> 1); i < (i1 >> 1); i++)
-p[2 * i + 1] += (I_LFTG_ALPHA * (p[2 * i] + (int64_t)p[2 * i + 2]) 
+ (1 << 15)) >> 16;
+for (i = (i0 >> 1); i < (i1 >> 1); i++) {
+int64_t sum = p[2 * i] + (int64_t) p[2 * i + 2];
+p[2 * i + 1] += sum;
+p[2 * i + 1] += (I_LFTG_ALPHA * sum + (1 << 15)) >> 16;
+}
 }
 
 static void dwt_decode97_int(DWTContext *s, int32_t *t)
@@ -500,9 +503,9 @@ static void dwt_decode97_int(DWTContext *s, int32_t *t)
 l = line + mh;
 for (lp = 0; lp < lv; lp++) {
 int i, j = 0;
-// rescale with interleaving
+// interleaving
 for (i = mh; i < lh; i += 2, j++)
-l[i] = ((data[w * lp + j] * I_LFTG_K) + (1 << 15)) >> 16;
+l[i] = data[w * lp + j];
 for (i = 1 - mh; i < lh; i += 2, j++)
 l[i] = data[w * lp + j];
 
@@ -516,9 +519,9 @@ static void dwt_decode97_int(DWTContext *s, int32_t *t)
 l = line + mv;
 for (lp = 0; lp < lh; lp++) {
 int i, j = 0;
-// rescale with interleaving
+// interleaving
 for (i = mv; i < lv; i += 2, j++)
-l[i] = ((data[w * j + lp] * I_LFTG_K) + (1 << 15)) >> 16;
+l[i] = data[w * j + lp];
 for (i = 1 - mv; i < lv; i += 2, j++)
 l[i] = data[w * j + lp];
 
@@ -530,7 +533,10 @@ static void dwt_decode97_int(DWTContext *s, int32_t *t)
 }
 
 for (i = 0; i < w * h; i++)
-data[i] = (data[i] + ((1LL<>1)) >> I_PRESHIFT;
+// Shifting down to the bin

[FFmpeg-devel] [PATCH v2 2/2] avcodec/jpeg2000dec: Update to JPEG 2000 related FATE refs with the fix of FF_DWT97_INT (integer implementation of inverse DWT 97)

2024-08-29 Thread Osamu Watanabe
Signed-off-by: Osamu Watanabe 
---
 tests/ref/fate/j2k-dwt   | 59 
 tests/ref/fate/jpeg2000-dcinema  |  4 +--
 tests/ref/fate/jpeg2000dec-p0_04 |  2 +-
 tests/ref/fate/jpeg2000dec-p0_05 |  2 +-
 tests/ref/fate/jpeg2000dec-p0_09 |  2 +-
 5 files changed, 5 insertions(+), 64 deletions(-)

diff --git a/tests/ref/fate/j2k-dwt b/tests/ref/fate/j2k-dwt
index 42415f00f9..a2ffc9a050 100644
--- a/tests/ref/fate/j2k-dwt
+++ b/tests/ref/fate/j2k-dwt
@@ -1,60 +1 @@
 5/3i, decomp:15 border 151 170 140 183 milli-err2:0
-9/7i, decomp:15 border 151 170 140 183 milli-err2:  544
-9/7f, decomp:15 border 151 170 140 183 err2:   0.000
-5/3i, decomp:21 border 173 201  81 189 milli-err2:0
-9/7i, decomp:21 border 173 201  81 189 milli-err2:  592
-9/7f, decomp:21 border 173 201  81 189 err2:   0.000
-5/3i, decomp:22 border 213 227  76 245 milli-err2:0
-9/7i, decomp:22 border 213 227  76 245 milli-err2:  533
-9/7f, decomp:22 border 213 227  76 245 err2:   0.000
-5/3i, decomp:13 border 134 157 184 203 milli-err2:0
-9/7i, decomp:13 border 134 157 184 203 milli-err2:  535
-9/7f, decomp:13 border 134 157 184 203 err2:   0.000
-5/3i, decomp: 1 border 204 237   6 106 milli-err2:0
-9/7i, decomp: 1 border 204 237   6 106 milli-err2:  219
-9/7f, decomp: 1 border 204 237   6 106 err2:   0.000
-5/3i, decomp:28 border  76 211  13 210 milli-err2:0
-9/7i, decomp:28 border  76 211  13 210 milli-err2:  791
-9/7f, decomp:28 border  76 211  13 210 err2:   0.000
-5/3i, decomp:21 border  76  99  43 123 milli-err2:0
-9/7i, decomp:21 border  76  99  43 123 milli-err2:  686
-9/7f, decomp:21 border  76  99  43 123 err2:   0.000
-5/3i, decomp:15 border 192 243 174 204 milli-err2:0
-9/7i, decomp:15 border 192 243 174 204 milli-err2:  476
-9/7f, decomp:15 border 192 243 174 204 err2:   0.000
-5/3i, decomp:21 border  17  68  93 204 milli-err2:0
-9/7i, decomp:21 border  17  68  93 204 milli-err2:  633
-9/7f, decomp:21 border  17  68  93 204 err2:   0.000
-5/3i, decomp:11 border 142 168  82 174 milli-err2:0
-9/7i, decomp:11 border 142 168  82 174 milli-err2:  696
-9/7f, decomp:11 border 142 168  82 174 err2:   0.000
-5/3i, decomp:23 border 142 209 171 235 milli-err2:0
-9/7i, decomp:23 border 142 209 171 235 milli-err2:  626
-9/7f, decomp:23 border 142 209 171 235 err2:   0.000
-5/3i, decomp:30 border  37 185  79 245 milli-err2:0
-9/7i, decomp:30 border  37 185  79 245 milli-err2:  953
-9/7f, decomp:30 border  37 185  79 245 err2:   0.000
-5/3i, decomp: 5 border 129 236  30 243 milli-err2:0
-9/7i, decomp: 5 border 129 236  30 243 milli-err2:  620
-9/7f, decomp: 5 border 129 236  30 243 err2:   0.000
-5/3i, decomp:10 border   5 160 146 247 milli-err2:0
-9/7i, decomp:10 border   5 160 146 247 milli-err2:  797
-9/7f, decomp:10 border   5 160 146 247 err2:   0.000
-5/3i, decomp: 5 border 104 162   6  47 milli-err2:0
-9/7i, decomp: 5 border 104 162   6  47 milli-err2:  603
-9/7f, decomp: 5 border 104 162   6  47 err2:   0.000
-5/3i, decomp:24 border  78 250 102 218 milli-err2:0
-9/7i, decomp:24 border  78 250 102 218 milli-err2:  836
-9/7f, decomp:24 border  78 250 102 218 err2:   0.000
-5/3i, decomp:28 border  86  98  56  79 milli-err2:0
-9/7i, decomp:28 border  86  98  56  79 milli-err2:  597
-9/7f, decomp:28 border  86  98  56  79 err2:   0.000
-5/3i, decomp: 6 border  95 238 197 214 milli-err2:0
-9/7i, decomp: 6 border  95 238 197 214 milli-err2:  478
-9/7f, decomp: 6 border  95 238 197 214 err2:   0.000
-5/3i, decomp:17 border  77 169  93 165 milli-err2:0
-9/7i, decomp:17 border  77 169  93 165 milli-err2:  616
-9/7f, decomp:17 border  77 169  93 165 err2:   0.000
-5/3i, decomp:22 border 178 187   7 119 milli-err2:0
-9/7i, decomp:22 border 178 187   7 119 milli-err2:  392
-9/7f, decomp:22 border 178 187   7 119 err2:   0.000
diff --git a/tests/ref/fate/jpeg2000-dcinema b/tests/ref/fate/jpeg2000-dcinema
index cdf8cd4fc6..217b8c8377 100644
--- a/tests/ref/fate/jpeg2000-dcinema
+++ b/tests/ref/fate/jpeg2000-dcinema
@@ -3,5 +3,5 @@
 #codec_id 0: rawvideo
 #dimensions 0: 1920x1080
 #sar 0: 1/1
-0,  0,  0,1, 12441600, 0xfcf6a127
-0,  1,  1,1, 12441600, 0x577b6a64
+0,  0,  0,1, 12441600, 0x9c79568e
+0,  1,  1,1, 12441600, 0xd96342dd
diff --git a/tests/ref/fate/jpeg2000dec-p0_04 b/tests/ref/fate/jpeg2000dec-p0_04
index 5de7880c44..c293084a50 100644
--- a/tests/ref/fate/jpeg2000dec-p0_04
+++ b/tests/ref/fate/jpeg2000dec-p0_04
@@ -3,4 +3,4 @@
 #codec_id 0: rawvideo
 #

Re: [FFmpeg-devel] [PATCH 28/42] lavc/hevc/ps: implement SPS parsing for nuh_layer_id>0

2024-08-29 Thread James Almer

On 8/27/2024 12:05 PM, Anton Khirnov wrote:

Cf. F.7.3.2.2 "Sequence parameter set RBSP syntax", which extends normal
SPS parsing with special clauses depending on MultiLayerExtSpsFlag.
---
  libavcodec/hevc/hevcdec.c |  2 +-
  libavcodec/hevc/parse.c   |  3 +-
  libavcodec/hevc/parser.c  |  2 +-
  libavcodec/hevc/ps.c  | 62 +++
  libavcodec/hevc/ps.h  |  7 +++--
  libavcodec/qsvenc_hevc.c  |  2 +-
  6 files changed, 65 insertions(+), 13 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 6b596f1573..260b9abef0 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -3256,7 +3256,7 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL 
*nal)
  break;
  case HEVC_NAL_SPS:
  ret = ff_hevc_decode_nal_sps(&gb, s->avctx, &s->ps,
- s->apply_defdispwin);
+ nal->nuh_layer_id, s->apply_defdispwin);
  if (ret < 0)
  goto fail;
  break;
diff --git a/libavcodec/hevc/parse.c b/libavcodec/hevc/parse.c
index ec8d1aeacf..ad84b7b152 100644
--- a/libavcodec/hevc/parse.c
+++ b/libavcodec/hevc/parse.c
@@ -49,7 +49,8 @@ static int hevc_decode_nal_units(const uint8_t *buf, int 
buf_size, HEVCParamSets
  goto done;
  break;
  case HEVC_NAL_SPS:
-ret = ff_hevc_decode_nal_sps(&nal->gb, logctx, ps, 
apply_defdispwin);
+ret = ff_hevc_decode_nal_sps(&nal->gb, logctx, ps,
+ nal->nuh_layer_id, apply_defdispwin);
  if (ret < 0)
  goto done;
  break;
diff --git a/libavcodec/hevc/parser.c b/libavcodec/hevc/parser.c
index 8db56e259e..a10f38941b 100644
--- a/libavcodec/hevc/parser.c
+++ b/libavcodec/hevc/parser.c
@@ -209,7 +209,7 @@ static int parse_nal_units(AVCodecParserContext *s, const 
uint8_t *buf,
  ff_hevc_decode_nal_vps(gb, avctx, ps);
  break;
  case HEVC_NAL_SPS:
-ff_hevc_decode_nal_sps(gb, avctx, ps, 1);
+ff_hevc_decode_nal_sps(gb, avctx, ps, nal->nuh_layer_id, 1);
  break;
  case HEVC_NAL_PPS:
  ff_hevc_decode_nal_pps(gb, avctx, ps);
diff --git a/libavcodec/hevc/ps.c b/libavcodec/hevc/ps.c
index 0e084958be..0b34dd10a8 100644
--- a/libavcodec/hevc/ps.c
+++ b/libavcodec/hevc/ps.c
@@ -1145,12 +1145,12 @@ static int map_pixel_format(AVCodecContext *avctx, 
HEVCSPS *sps)
  }
  
  int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id,

-  int apply_defdispwin, const HEVCVPS * const *vps_list,
-  AVCodecContext *avctx)
+  unsigned nuh_layer_id, int apply_defdispwin,
+  const HEVCVPS * const *vps_list, AVCodecContext *avctx)
  {
  HEVCWindow *ow;
  int ret = 0;
-int bit_depth_chroma, start, num_comps;
+int bit_depth_chroma, num_comps, multi_layer_ext;
  int i;
  
  // Coded parameters

@@ -1167,16 +1167,26 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, 
unsigned int *sps_id,
  }
  
  sps->max_sub_layers = get_bits(gb, 3) + 1;

+multi_layer_ext = nuh_layer_id > 0 &&
+  sps->max_sub_layers == HEVC_MAX_SUB_LAYERS + 1;
+if (multi_layer_ext) {
+if (!sps->vps)
+return AVERROR(EINVAL);
+
+sps->max_sub_layers = sps->vps->vps_max_sub_layers;
+}
  if (sps->max_sub_layers > HEVC_MAX_SUB_LAYERS) {


Not strictly related to this patch, but sps->max_sub_layers should 
always be <= vps->vps_max_sub_layers (see F.7.4.3.2.1). So the presence 
of vps should be checked for.



  av_log(avctx, AV_LOG_ERROR, "sps_max_sub_layers out of range: %d\n",
 sps->max_sub_layers);
  return AVERROR_INVALIDDATA;
  }
  
+if (!multi_layer_ext) {

  sps->temporal_id_nesting = get_bits(gb, 1);


Similarly (not strictly related to this patch), this needs to be 1 if 
sps->max_sub_layers is 0 or if vps->vps_temporal_id_nesting_flag is 1.


  
  if ((ret = parse_ptl(gb, avctx, 1, &sps->ptl, sps->max_sub_layers)) < 0)

  return ret;
+}


(Actually related this time) If multi_layer_ext is true, 
sps->temporal_id_nesting needs to be set to 
vps->vps_temporal_id_nesting_flag when sps->max_sub_layers > 1, or 
hardcoded to 1 if it's 1.


  
  *sps_id = get_ue_golomb_long(gb);

  if (*sps_id >= HEVC_MAX_SPS_COUNT) {
@@ -1184,6 +1194,28 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, 
unsigned int *sps_id,
  return AVERROR_INVALIDDATA;
  }
  
+if (multi_layer_ext) {

+const RepFormat *rf = &sps->vps->rep_format;
+
+if (get_bits1(gb) &&// update_rep_format_flag
+get_bits(gb, 8)) {  // sps_rep_format_idx
+av_log(avctx, AV_LOG_ERROR, "sps_rep_format_idx!=0\n");
+return AVERROR_PATCHWELCOME;

Re: [FFmpeg-devel] [PATCH 25/42] avcodec/hevc/sei: add support for 3D Reference Displays Information SEI

2024-08-29 Thread James Almer

On 8/27/2024 12:05 PM, Anton Khirnov wrote:

From: James Almer 

Signed-off-by: James Almer 
---
  libavcodec/hevc/sei.c | 55 +++
  libavcodec/hevc/sei.h | 17 +
  2 files changed, 72 insertions(+)

diff --git a/libavcodec/hevc/sei.c b/libavcodec/hevc/sei.c
index e39ac0c38a..6c2b55b43c 100644
--- a/libavcodec/hevc/sei.c
+++ b/libavcodec/hevc/sei.c
@@ -150,6 +150,59 @@ static int decode_nal_sei_timecode(HEVCSEITimeCode *s, 
GetBitContext *gb)
  return 0;
  }
  
+static int decode_nal_sei_3d_reference_displays_info(HEVCSEITDRDI *s, GetBitContext *gb)

+{
+s->prec_ref_display_width = get_ue_golomb(gb);
+if (s->prec_ref_display_width > 31)
+return AVERROR_INVALIDDATA;
+s->ref_viewing_distance_flag = get_bits1(gb);
+if (s->ref_viewing_distance_flag) {
+s->prec_ref_viewing_dist = get_ue_golomb(gb);
+if (s->prec_ref_viewing_dist > 31)
+return AVERROR_INVALIDDATA;
+}
+s->num_ref_displays = get_ue_golomb(gb);
+if (s->num_ref_displays > 31)
+return AVERROR_INVALIDDATA;
+s->num_ref_displays += 1;
+
+for (int i = 0; i < s->num_ref_displays; i++) {
+int length;
+s->left_view_id[i] = get_ue_golomb(gb);
+s->right_view_id[i] = get_ue_golomb(gb);
+s->exponent_ref_display_width[i] = get_bits(gb, 6);
+if (s->exponent_ref_display_width[i] > 62)
+return AVERROR_INVALIDDATA;
+else if (!s->exponent_ref_display_width[i])
+length = FFMAX(0, (int)s->prec_ref_display_width - 30);
+else
+length = FFMAX(0, (int)s->exponent_ref_display_width[i] +
+  (int)s->prec_ref_display_width - 31);
+s->mantissa_ref_display_width[i] = get_bits_long(gb, length);
+if (s->ref_viewing_distance_flag) {
+s->exponent_ref_viewing_distance[i] = get_bits(gb, 6);
+if (s->exponent_ref_viewing_distance[i] > 62)
+return AVERROR_INVALIDDATA;
+else if (!s->exponent_ref_viewing_distance[i])
+length = FFMAX(0, (int)s->prec_ref_viewing_dist - 30);
+else
+length = FFMAX(0, (int)s->exponent_ref_viewing_distance[i] +
+  (int)s->prec_ref_viewing_dist - 31);
+s->mantissa_ref_viewing_distance[i] = get_bits_long(gb, length);
+}
+s->additional_shift_present_flag[i] = get_bits1(gb);
+if (s->additional_shift_present_flag[i]) {
+s->num_sample_shift[i] = get_bits(gb, 10);
+if (s->num_sample_shift[i] > 1023)
+return AVERROR_INVALIDDATA;
+s->num_sample_shift[i] -= 512;
+}
+}
+s->three_dimensional_reference_displays_extension_flag = get_bits1(gb);
+
+return 0;
+}
+
  static int decode_nal_sei_prefix(GetBitContext *gb, GetByteContext *gbyte,
   void *logctx, HEVCSEI *s,
   const HEVCParamSets *ps, int type)
@@ -163,6 +216,8 @@ static int decode_nal_sei_prefix(GetBitContext *gb, 
GetByteContext *gbyte,
  return decode_nal_sei_active_parameter_sets(s, gb, logctx);
  case SEI_TYPE_TIME_CODE:
  return decode_nal_sei_timecode(&s->timecode, gb);
+case SEI_TYPE_THREE_DIMENSIONAL_REFERENCE_DISPLAYS_INFO:
+return decode_nal_sei_3d_reference_displays_info(&s->tdrdi, gb);
  default: {
  int ret = ff_h2645_sei_message_decode(&s->common, type, 
AV_CODEC_ID_HEVC,
gb, gbyte, logctx);
diff --git a/libavcodec/hevc/sei.h b/libavcodec/hevc/sei.h
index c97d22d423..a233d432cc 100644
--- a/libavcodec/hevc/sei.h
+++ b/libavcodec/hevc/sei.h
@@ -79,12 +79,29 @@ typedef struct HEVCSEITimeCode {
  int32_t  time_offset_value[3];
  } HEVCSEITimeCode;
  
+typedef struct HEVCSEITDRDI {

+uint8_t prec_ref_display_width;
+uint8_t ref_viewing_distance_flag;
+uint8_t prec_ref_viewing_dist;
+uint8_t num_ref_displays;
+uint8_t left_view_id[31];
+uint8_t right_view_id[31];


Should be uint16_t, like you found out.


+uint8_t exponent_ref_display_width[31];
+uint8_t mantissa_ref_display_width[31];
+uint8_t exponent_ref_viewing_distance[31];
+uint8_t mantissa_ref_viewing_distance[31];
+uint8_t additional_shift_present_flag[31];
+int16_t num_sample_shift[31];
+uint8_t three_dimensional_reference_displays_extension_flag;
+} HEVCSEITDRDI;
+
  typedef struct HEVCSEI {
  H2645SEI common;
  HEVCSEIPictureHash picture_hash;
  HEVCSEIPictureTiming picture_timing;
  int active_seq_parameter_set_id;
  HEVCSEITimeCode timecode;
+HEVCSEITDRDI tdrdi;
  } HEVCSEI;
  
  struct HEVCParamSets;


___
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...@ffmpe

Re: [FFmpeg-devel] Can't use __musl__ macro

2024-08-29 Thread Brad Smith

On 2024-08-29 9:47 a.m., Ramiro Polla wrote:

Hi,

On Mon, Aug 12, 2024 at 7:16 AM Lance Fredrickson
 wrote:

In commit 9e674b31606c805dd31b4bb754364a72a5877238 of ffmpeg this change
tries to detect musl libc by way of a "__musl__" macro.  This macro
however, doesn't exist in musl. This results in an "incompatible pointer
type" error under gcc-14.2 as detection falls through to the #else
definition. This was in version 6.1.2 and looks like it is still present
in master.  I can't say what the correct fix would be, I just manually
patched for now.

musl tries to make itself undetectable. Instead of relying on system
#ifdefs which may or may not be correct, we should instead check for
the proper signature at configure time.

I sent a patch for this (look for the thread "[PATCH] configure:
improve check for POSIX ioctl").

I tested it with musl, glibc, and the android ndk. Brad, could you
test that this works as expected on BSD?


Here is the config output.. test_code cc sys/ioctl.h int ioctl(int, int, 
...); test_cc BEGIN /tmp/ffconf.of6GnZkt/test.c 1 #include  
2 int main(void) { int ioctl(int, int, ...);; return 0; } END 
/tmp/ffconf.of6GnZkt/test.c cc -D_ISOC11_SOURCE -D_FILE_OFFSET_BITS=64 
-D_LARGEFILE_SOURCE -DPIC -std=c17 -fomit-frame-pointer -fPIC 
-I/usr/X11R6/include -I/usr/X11R6/include -I/usr/X11R6/include -pthread 
-I/usr/X11R6/include -I/usr/X11R6/include/libdrm -c -o 
/tmp/ffconf.of6GnZkt/test.o /tmp/ffc onf.of6GnZkt/test.c 
/tmp/ffconf.of6GnZkt/test.c:2:22: error: conflicting types for 'ioctl' 
int main(void) { int ioctl(int, int, ...);; return 0; } ^ 
/usr/include/sys/ioctl.h:52:5: note: previous declaration is here int 
ioctl(int, unsigned long, ...); ^ 1 error generated.

___
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 v2 2/2] avcodec/jpeg2000dec: Update to JPEG 2000 related FATE refs with the fix of FF_DWT97_INT (integer implementation of inverse DWT 97)

2024-08-29 Thread Pierre-Anthony Lemieux
Looks like more files need to be regenerated:

tests/ref/vsynth/vsynth1-jpeg2000-97
tests/ref/vsynth/vsynth2-jpeg2000-97
tests/ref/vsynth/vsynth3-jpeg2000-97
tests/ref/vsynth/vsynth_lena-jpeg2000-97

On Thu, Aug 29, 2024 at 7:07 PM Osamu Watanabe
 wrote:
>
> Signed-off-by: Osamu Watanabe 
> ---
>  tests/ref/fate/j2k-dwt   | 59 
>  tests/ref/fate/jpeg2000-dcinema  |  4 +--
>  tests/ref/fate/jpeg2000dec-p0_04 |  2 +-
>  tests/ref/fate/jpeg2000dec-p0_05 |  2 +-
>  tests/ref/fate/jpeg2000dec-p0_09 |  2 +-
>  5 files changed, 5 insertions(+), 64 deletions(-)
>
> diff --git a/tests/ref/fate/j2k-dwt b/tests/ref/fate/j2k-dwt
> index 42415f00f9..a2ffc9a050 100644
> --- a/tests/ref/fate/j2k-dwt
> +++ b/tests/ref/fate/j2k-dwt
> @@ -1,60 +1 @@
>  5/3i, decomp:15 border 151 170 140 183 milli-err2:0
> -9/7i, decomp:15 border 151 170 140 183 milli-err2:  544
> -9/7f, decomp:15 border 151 170 140 183 err2:   0.000
> -5/3i, decomp:21 border 173 201  81 189 milli-err2:0
> -9/7i, decomp:21 border 173 201  81 189 milli-err2:  592
> -9/7f, decomp:21 border 173 201  81 189 err2:   0.000
> -5/3i, decomp:22 border 213 227  76 245 milli-err2:0
> -9/7i, decomp:22 border 213 227  76 245 milli-err2:  533
> -9/7f, decomp:22 border 213 227  76 245 err2:   0.000
> -5/3i, decomp:13 border 134 157 184 203 milli-err2:0
> -9/7i, decomp:13 border 134 157 184 203 milli-err2:  535
> -9/7f, decomp:13 border 134 157 184 203 err2:   0.000
> -5/3i, decomp: 1 border 204 237   6 106 milli-err2:0
> -9/7i, decomp: 1 border 204 237   6 106 milli-err2:  219
> -9/7f, decomp: 1 border 204 237   6 106 err2:   0.000
> -5/3i, decomp:28 border  76 211  13 210 milli-err2:0
> -9/7i, decomp:28 border  76 211  13 210 milli-err2:  791
> -9/7f, decomp:28 border  76 211  13 210 err2:   0.000
> -5/3i, decomp:21 border  76  99  43 123 milli-err2:0
> -9/7i, decomp:21 border  76  99  43 123 milli-err2:  686
> -9/7f, decomp:21 border  76  99  43 123 err2:   0.000
> -5/3i, decomp:15 border 192 243 174 204 milli-err2:0
> -9/7i, decomp:15 border 192 243 174 204 milli-err2:  476
> -9/7f, decomp:15 border 192 243 174 204 err2:   0.000
> -5/3i, decomp:21 border  17  68  93 204 milli-err2:0
> -9/7i, decomp:21 border  17  68  93 204 milli-err2:  633
> -9/7f, decomp:21 border  17  68  93 204 err2:   0.000
> -5/3i, decomp:11 border 142 168  82 174 milli-err2:0
> -9/7i, decomp:11 border 142 168  82 174 milli-err2:  696
> -9/7f, decomp:11 border 142 168  82 174 err2:   0.000
> -5/3i, decomp:23 border 142 209 171 235 milli-err2:0
> -9/7i, decomp:23 border 142 209 171 235 milli-err2:  626
> -9/7f, decomp:23 border 142 209 171 235 err2:   0.000
> -5/3i, decomp:30 border  37 185  79 245 milli-err2:0
> -9/7i, decomp:30 border  37 185  79 245 milli-err2:  953
> -9/7f, decomp:30 border  37 185  79 245 err2:   0.000
> -5/3i, decomp: 5 border 129 236  30 243 milli-err2:0
> -9/7i, decomp: 5 border 129 236  30 243 milli-err2:  620
> -9/7f, decomp: 5 border 129 236  30 243 err2:   0.000
> -5/3i, decomp:10 border   5 160 146 247 milli-err2:0
> -9/7i, decomp:10 border   5 160 146 247 milli-err2:  797
> -9/7f, decomp:10 border   5 160 146 247 err2:   0.000
> -5/3i, decomp: 5 border 104 162   6  47 milli-err2:0
> -9/7i, decomp: 5 border 104 162   6  47 milli-err2:  603
> -9/7f, decomp: 5 border 104 162   6  47 err2:   0.000
> -5/3i, decomp:24 border  78 250 102 218 milli-err2:0
> -9/7i, decomp:24 border  78 250 102 218 milli-err2:  836
> -9/7f, decomp:24 border  78 250 102 218 err2:   0.000
> -5/3i, decomp:28 border  86  98  56  79 milli-err2:0
> -9/7i, decomp:28 border  86  98  56  79 milli-err2:  597
> -9/7f, decomp:28 border  86  98  56  79 err2:   0.000
> -5/3i, decomp: 6 border  95 238 197 214 milli-err2:0
> -9/7i, decomp: 6 border  95 238 197 214 milli-err2:  478
> -9/7f, decomp: 6 border  95 238 197 214 err2:   0.000
> -5/3i, decomp:17 border  77 169  93 165 milli-err2:0
> -9/7i, decomp:17 border  77 169  93 165 milli-err2:  616
> -9/7f, decomp:17 border  77 169  93 165 err2:   0.000
> -5/3i, decomp:22 border 178 187   7 119 milli-err2:0
> -9/7i, decomp:22 border 178 187   7 119 milli-err2:  392
> -9/7f, decomp:22 border 178 187   7 119 err2:   0.000
> diff --git a/tests/ref/fate/jpeg2000-dcinema b/tests/ref/fate/jpeg2000-dcinema
> index cdf8cd4fc6..217b8c8377 100644
> --- a/tests/ref/fate/jpeg2000-dcinema
> +++ b/tests/ref/fate/jpeg2000-dcinema
> @@ -3,5 +3,5 @@
>  #codec_id 0: rawvideo
>  #dimensions 0: 1920x1080
>  #sar 0: 1/1
> -0,  0,  0,1, 12441600, 0x

Re: [FFmpeg-devel] [PATCH v2] avfilter/vf_libvmaf: Add metadata propagation support

2024-08-29 Thread Kyle Swanson
Hi,


On Mon, Aug 26, 2024 at 10:51=E2=80=AFAM Yigithan Yigit
 wrote:
>
> ---
>  libavfilter/vf_libvmaf.c | 328 ++-
>  1 file changed, 326 insertions(+), 2 deletions(-)
>
> diff --git a/libavfilter/vf_libvmaf.c b/libavfilter/vf_libvmaf.c
> index f655092b20..e6707aff53 100644
> --- a/libavfilter/vf_libvmaf.c
> +++ b/libavfilter/vf_libvmaf.c
> @@ -27,8 +27,11 @@
>  #include "config_components.h"
>
>  #include 
> +#include 
>
>  #include "libavutil/avstring.h"
> +#include "libavutil/dict.h"
> +#include "libavutil/frame.h"
>  #include "libavutil/mem.h"
>  #include "libavutil/opt.h"
>  #include "libavutil/pixdesc.h"
> @@ -46,6 +49,31 @@
>  #include "libavutil/hwcontext_cuda_internal.h"
>  #endif
>
> +#define VMAF_VERSION_INT_VER(major, minor, patch) \
> +((major) * 1 + (minor) * 100 + (patch))
> +
> +#if VMAF_VERSION_INT_VER(VMAF_API_VERSION_MAJOR, VMAF_API_VERSION_MINOR,=
 VMAF_API_VERSION_PATCH) > VMAF_VERSION_INT_VER(3, 0, 0)
> +#define CONFIG_LIBVMAF_METADATA_ENABLED 1
> +#else
> +#define CONFIG_LIBVMAF_METADATA_ENABLED 0
> +#endif

You should be able to check pkg_cfg and set this
CONFIG_LIBVMAF_METADATA_ENABLED define from the configure script.

> +
> +#if CONFIG_LIBVMAF_METADATA_ENABLED
> +#include 
> +
> +typedef struct FrameList {
> +AVFrame *frame;
> +unsigned frame_number;
> +unsigned propagated_handlers_cnt;
> +struct FrameList *next;
> +} FrameList;
> +
> +typedef struct CallbackStruct {
> +struct LIBVMAFContext *s;
> +FrameList *frame_list;
> +} CallbackStruct;
> +#endif
> +
>  typedef struct LIBVMAFContext {
>  const AVClass *class;
>  FFFrameSync fs;
> @@ -56,8 +84,19 @@ typedef struct LIBVMAFContext {
>  int n_subsample;
>  char *model_cfg;
>  char *feature_cfg;
> +#if CONFIG_LIBVMAF_METADATA_ENABLED
> +char *metadata_feature_cfg;
> +struct {
> +VmafMetadataConfiguration *metadata_cfgs;
> +unsigned metadata_cfg_cnt;
> +} metadata_cfg_list;
> +CallbackStruct *cb;
> +atomic_uint outlink_eof;
> +atomic_uint eof_frame;
> +#endif
>  VmafContext *vmaf;
>  VmafModel **model;
> +int flushed;
>  unsigned model_cnt;
>  unsigned frame_cnt;
>  unsigned bpc;
> @@ -77,6 +116,9 @@ static const AVOption libvmaf_options[] =3D {
>  {"n_subsample", "Set interval for frame subsampling used when comput=
ing vmaf.", OFFSET(n_subsample), AV_OPT_TYPE_INT, {.i64=3D1}, 1, UINT_M=
AX, FLAGS},
>  {"model",  "Set the model to be used for computing vmaf.",  =
OFFSET(model_cfg), AV_OPT_TYPE_STRING, {.str=3D"version=3Dv=
maf_v0.6.1"}, 0, 1, FLAGS},
>  {"feature",  "Set the feature to be used for computing vmaf.",  =
OFFSET(feature_cfg), AV_OPT_TYPE_STRING, {.str=3DNULL}, 0, =
1, FLAGS},
> +#if CONFIG_LIBVMAF_METADATA_ENABLED
> +{"metadata_handler",  "Set the feature to be propagated as metadata.=
",  OFFSET(metadata_feature_cfg), AV_OPT_TYPE_STRING, {.str=3D"=
name=3Dvmaf"}, 0, 1, FLAGS},

Would be better to make this option a bool. When true, propagate all
registered features and models. You can read the names during init,
they should be available inside `parse_models()` and
`parse_features()`.

> +#endif
>  { NULL }
>  };
>
> @@ -105,6 +147,123 @@ static enum VmafPixelFormat pix_fmt_map(enum AVPixe=
lFormat av_pix_fmt)
>  }
>  }
>
> +#if CONFIG_LIBVMAF_METADATA_ENABLED
> +static int add_to_frame_list(FrameList **head, AVFrame *frame, unsigned =
frame_number)
> +{
> +FrameList *new_frame =3D av_malloc(sizeof(FrameList));
> +if (!new_frame)
> +return AVERROR(ENOMEM);
> +
> +new_frame->frame =3D frame;
> +new_frame->frame_number =3D frame_number;
> +new_frame->propagated_handlers_cnt =3D 0;
> +new_frame->next =3D NULL;
> +
> +if (*head =3D=3D NULL) {
> +*head =3D new_frame;
> +} else {
> +FrameList *current =3D *head;
> +while (current->next !=3D NULL) {
> +current =3D current->next;
> +}
> +current->next =3D new_frame;
> +}
> +
> +return 0;
> +}
> +
> +static int remove_from_frame_list(FrameList **frame_list, unsigned frame=
_number)
> +{
> +FrameList *cur =3D *frame_list;
> +FrameList *prev =3D NULL;
> +
> +while (cur) {
> +if (cur->frame_number =3D=3D frame_number) {
> +if (prev)
> +prev->next =3D cur->next;
> +else
> +*frame_list =3D cur->next;
> +av_free(cur);
> +return 0;
> +}
> +prev =3D cur;
> +cur =3D cur->next;
> +}
> +
> +return AVERROR(EINVAL);
> +}
> +
> +static int free_frame_list(FrameList **frame_list)
> +{
> +FrameList *cur =3D *frame_list;
> +while (cur) {
> +FrameList *next =3D cur->next;
> +av_frame_free(&cur->frame);
> +av_free(cur);
> +cur =3D next;
> +}
> +*frame_list =3D NULL;
> +return 0;
> +}