[FFmpeg-devel] [PATCH] tools/target_enc_fuzzer: Add slices and level for FFv1

2024-08-11 Thread Michael Niedermayer
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer 
---
 tools/target_enc_fuzzer.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/target_enc_fuzzer.c b/tools/target_enc_fuzzer.c
index 059d7830710..59c2db4bb42 100644
--- a/tools/target_enc_fuzzer.c
+++ b/tools/target_enc_fuzzer.c
@@ -149,6 +149,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
size) {
 av_dict_set_int(&opts, "coder", coder, 0);
 av_dict_set_int(&opts, "context", bytestream2_get_byte(&gbc)&1, 0);
 av_dict_set_int(&opts, "slicecrc", bytestream2_get_byte(&gbc)&1, 
0);
+ctx->slices = bytestream2_get_byte(&gbc);
+ctx->level = bytestream2_get_byte(&gbc) % 6 - 1;
 break;}
 }
 }
-- 
2.45.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] [PATCH v3 2/2] libavformat/vapoursynth: Update to API version 4, load library at runtime

2024-08-11 Thread Stefan Oltmanns via ffmpeg-devel

Am 30.07.24 um 16:12 schrieb Ramiro Polla:

On Mon, Jul 29, 2024 at 5:56 AM Stefan Oltmanns via ffmpeg-devel
 wrote:

Am 28.07.24 um 15:15 schrieb Ramiro Polla:

I think calling win32_dlopen() with a full path will be problematic for
systems without KB2533623. win32_dlopen() might need to be fixed in a
separate patch.


Yes, win32_dlopen would need to check if a full path is already given
and if yes skip all the stuff to determine it's own and system32 path,
but instead just use the given parameter directly. To check if it's a
full path it should be enough to check if it either starts with "\??\"
(NT-style path) or if the second character is ":" (win32 style path).

But is this really is needed for an operating system that reached
support end over 4 years ago and does not have a security patch applied
released over 13 years ago?
I don't know what ffmpeg's exact policy is in this case, just asking.


Makes sense. I sent a patchset to clean this, but I haven't been able
to test on a real Windows system.

I'll test the vapoursynth patches later on Linux.



Any progress on this? Anything I can do?

Best regards
Stefan
___
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] lavc/libx265: unbreak build for X265_BUILD >= 210

2024-08-11 Thread Gyan Doshi
x265 added support for alpha starting with build 210.
While doing so, x265_encoder_encode() changed its fifth arg to
an array of pointers to x265_picture. This broke building lavc/libx265.c

This patch simply unbreaks the build and maintains existing single-layer
non-alpha encoding support.

Fixes #11130
---
 libavcodec/libx265.c | 40 ++--
 1 file changed, 30 insertions(+), 10 deletions(-)

diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index 0dc7ab6eeb..3bc3b5a03e 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -661,7 +661,13 @@ static int libx265_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 {
 libx265Context *ctx = avctx->priv_data;
 x265_picture x265pic;
-x265_picture x265pic_out = { 0 };
+#if X265_BUILD >= 210
+x265_picture x265pic_layers_out[MAX_SCALABLE_LAYERS];
+x265_picture* x265pic_lyrptr_out[MAX_SCALABLE_LAYERS];
+#else
+x265_picture x265pic_solo_out = { 0 };
+#endif
+x265_picture* x265pic_out;
 x265_nal *nal;
 x265_sei *sei;
 uint8_t *dst;
@@ -798,8 +804,16 @@ static int libx265_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 #endif
 }
 
+#if X265_BUILD >= 210
+for (i = 0; i < MAX_SCALABLE_LAYERS; i++)
+x265pic_lyrptr_out[i] = &x265pic_layers_out[i];
+
+ret = ctx->api->encoder_encode(ctx->encoder, &nal, &nnal,
+   pic ? &x265pic : NULL, x265pic_lyrptr_out);
+#else
 ret = ctx->api->encoder_encode(ctx->encoder, &nal, &nnal,
-   pic ? &x265pic : NULL, &x265pic_out);
+   pic ? &x265pic : NULL, &x265pic_solo_out);
+#endif
 
 for (i = 0; i < sei->numPayloads; i++)
 av_free(sei->payloads[i].payload);
@@ -829,10 +843,16 @@ static int libx265_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 pkt->flags |= AV_PKT_FLAG_KEY;
 }
 
-pkt->pts = x265pic_out.pts;
-pkt->dts = x265pic_out.dts;
+#if X265_BUILD >= 210
+x265pic_out = x265pic_lyrptr_out[0];
+#else
+x265pic_out = &x265pic_solo_out;
+#endif
+
+pkt->pts = x265pic_out->pts;
+pkt->dts = x265pic_out->dts;
 
-switch (x265pic_out.sliceType) {
+switch (x265pic_out->sliceType) {
 case X265_TYPE_IDR:
 case X265_TYPE_I:
 pict_type = AV_PICTURE_TYPE_I;
@@ -850,16 +870,16 @@ static int libx265_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 }
 
 #if X265_BUILD >= 130
-if (x265pic_out.sliceType == X265_TYPE_B)
+if (x265pic_out->sliceType == X265_TYPE_B)
 #else
-if (x265pic_out.frameData.sliceType == 'b')
+if (x265pic_out->frameData.sliceType == 'b')
 #endif
 pkt->flags |= AV_PKT_FLAG_DISPOSABLE;
 
-ff_side_data_set_encoder_stats(pkt, x265pic_out.frameData.qp * 
FF_QP2LAMBDA, NULL, 0, pict_type);
+ff_side_data_set_encoder_stats(pkt, x265pic_out->frameData.qp * 
FF_QP2LAMBDA, NULL, 0, pict_type);
 
-if (x265pic_out.userData) {
-int idx = (int)(intptr_t)x265pic_out.userData - 1;
+if (x265pic_out->userData) {
+int idx = (int)(intptr_t)x265pic_out->userData - 1;
 ReorderedData *rd = &ctx->rd[idx];
 
 pkt->duration   = rd->duration;
-- 
2.44.0

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

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


Re: [FFmpeg-devel] [PATCH 1/3] avformat/lmlm4: Move subtraction after check

2024-08-11 Thread Michael Niedermayer
On Sat, Jul 13, 2024 at 05:51:03PM +0200, Michael Niedermayer wrote:
> This is not a bugfix in code but coverity only, it does look a little nicer 
> though
> 
> Fixes: CID732224
> 
> Sponsored-by: Sovereign Tech Fund
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/lmlm4.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

will apply patchset

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

Those who are best at talking, realize last or never when they are wrong.


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 v2] avfilter/af_surround: Check output format

2024-08-11 Thread Michael Niedermayer
On Fri, Jul 12, 2024 at 10:18:09PM +0200, Michael Niedermayer wrote:
> Fixes: CID1516994 Out-of-bounds access
> Fixes: CID1516996 Out-of-bounds access
> Fixes: CID1516999 Out-of-bounds access
> 
> Sponsored-by: Sovereign Tech Fund
> Signed-off-by: Michael Niedermayer 
> ---
>  libavfilter/af_surround.c | 25 +
>  1 file changed, 25 insertions(+)

will apply

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

While the State exists there can be no freedom; when there is freedom there
will be no State. -- Vladimir Lenin


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 3/6] avfilter/vf_tpad: Dont clone NULL

2024-08-11 Thread Michael Niedermayer
On Thu, Jul 11, 2024 at 12:50:09AM +0200, Michael Niedermayer wrote:
> untested
> 
> Fixes: CID1440836 Dereference after null check

will apply patchset except this


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

No snowflake in an avalanche ever feels responsible. -- Voltaire


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 10/11] avcodec/aac/aacdec_usac: Avoid doing the same thing twice each iteration

2024-08-11 Thread Michael Niedermayer
On Sun, Jul 21, 2024 at 03:56:16PM +0200, Michael Niedermayer wrote:
> On Mon, Jul 01, 2024 at 01:12:49AM +0200, Michael Niedermayer wrote:
> > This requires review by the author of the code, i have just changed
> > this so it looks plausible, this needs to be checked against the spec
> > 
> > Fixes: CID1603194 Logically dead code
> > 
> > Sponsored-by: Sovereign Tech Fund
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavcodec/aac/aacdec_usac.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> ping

hello ?

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The day soldiers stop bringing you their problems is the day you have stopped 
leading them. They have either lost confidence that you can help or concluded 
you do not care. Either case is a failure of leadership. - Colin Powell


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 04/17] avcodec/dxva2: initialize hr in ff_dxva2_common_end_frame()

2024-08-11 Thread Michael Niedermayer
On Sun, Jul 07, 2024 at 09:48:40PM +0200, Michael Niedermayer wrote:
> On Sun, Jun 02, 2024 at 10:27:55PM +0200, Michael Niedermayer wrote:
> > On Sun, Jun 02, 2024 at 09:10:33PM +0200, Andreas Rheinhardt wrote:
> > > Michael Niedermayer:
> > > > Fixes: CID1591924 Uninitialized scalar variable
> > > > Fixes: CID1591938 Uninitialized scalar variable
> > > > 
> > > > Sponsored-by: Sovereign Tech Fund
> > > > Signed-off-by: Michael Niedermayer 
> > > > ---
> > > >  libavcodec/dxva2.c | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > > 
> > > > diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c
> > > > index 1a33c8bbac7..22ecd5acafe 100644
> > > > --- a/libavcodec/dxva2.c
> > > > +++ b/libavcodec/dxva2.c
> > > > @@ -906,7 +906,7 @@ int ff_dxva2_common_end_frame(AVCodecContext 
> > > > *avctx, AVFrame *frame,
> > > >  #endif
> > > >  DECODER_BUFFER_DESC *buffer = NULL, *buffer_slice = 
> > > > NULL;
> > > >  int result, runs = 0;
> > > > -HRESULT hr;
> > > > +HRESULT hr = -1;
> > > >  unsigned type;
> > > >  FFDXVASharedContext *sctx = DXVA_SHARED_CONTEXT(avctx);
> > > >  
> > > 
> > > It seems to me that this (and other patches in this set) is not a real
> > > fix of a bug. These functions are called either with a D3D11 pix fmt or
> > > with AV_PIX_FMT_DXVA2_VLD, so these variables are initialized before
> > > their use.
> > 
> > If they are called with another pixel format then its exploitable
> > maybe that cannot happen currently
> > 
> > But if or if not. Initializing these variables makes the code simply
> > more robust and also if it happens a NULL is easier to debug than
> > uninitialized variables. The assumtions that need to be true for
> > them to be initialized are not entirely trivial.
> > 
> > ill drop the patches from what i wanted to apply currently but i still
> > think they should be applied.
> 
> > I can change the commit message if you can suggest something else ?
> 
> ping
> does anyone object to the patches ?
> does someone want a different commit message ? if so which ?

apparently noone cares so i will apply them with the "fixed" replaced
by "related" or something like that

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Some people wanted to paint the bikeshed green, some blue and some pink.
People argued and fought, when they finally agreed, only rust was left.


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 3/3] checkasm: add tests for vvc dmvr

2024-08-11 Thread Nuo Mi
will apply next week if there are no objections

On Fri, Jul 26, 2024 at 3:42 PM Nuo Mi  wrote:

>
>
> On Fri, Jul 26, 2024 at 9:36 AM James Almer  wrote:
>
>> On 7/25/2024 10:35 AM, Nuo Mi wrote:
>> > dmvr_8_12x20_c: 186.2
>> > dmvr_8_12x20_avx2: 25.7
>> > dmvr_8_20x12_c: 181.7
>> > dmvr_8_20x12_avx2: 25.2
>> > dmvr_8_20x20_c: 283.2
>> > dmvr_8_20x20_avx2: 32.0
>> > dmvr_10_12x20_c: 90.0
>> > dmvr_10_12x20_avx2: 15.7
>> > dmvr_10_20x12_c: 41.0
>> > dmvr_10_20x12_avx2: 14.7
>> > dmvr_10_20x20_c: 81.5
>> > dmvr_10_20x20_avx2: 26.7
>> > dmvr_12_12x20_c: 190.7
>> > dmvr_12_12x20_avx2: 20.2
>> > dmvr_12_20x12_c: 187.2
>> > dmvr_12_20x12_avx2: 20.2
>> > dmvr_12_20x20_c: 292.7
>> > dmvr_12_20x20_avx2: 27.2
>> > dmvr_h_8_12x20_c: 317.0
>> > dmvr_h_8_12x20_avx2: 37.0
>> > dmvr_h_8_20x12_c: 340.0
>> > dmvr_h_8_20x12_avx2: 41.0
>> > dmvr_h_8_20x20_c: 540.7
>> > dmvr_h_8_20x20_avx2: 64.0
>> > dmvr_h_10_12x20_c: 322.7
>> > dmvr_h_10_12x20_avx2: 30.7
>> > dmvr_h_10_20x12_c: 344.2
>> > dmvr_h_10_20x12_avx2: 34.0
>> > dmvr_h_10_20x20_c: 529.0
>> > dmvr_h_10_20x20_avx2: 51.5
>> > dmvr_h_12_12x20_c: 326.7
>> > dmvr_h_12_12x20_avx2: 33.5
>> > dmvr_h_12_20x12_c: 331.7
>> > dmvr_h_12_20x12_avx2: 51.2
>> > dmvr_h_12_20x20_c: 534.0
>> > dmvr_h_12_20x20_avx2: 62.7
>> > dmvr_hv_8_12x20_c: 650.0
>> > dmvr_hv_8_12x20_avx2: 57.2
>> > dmvr_hv_8_20x12_c: 676.2
>> > dmvr_hv_8_20x12_avx2: 70.0
>> > dmvr_hv_8_20x20_c: 1068.5
>> > dmvr_hv_8_20x20_avx2: 103.2
>> > dmvr_hv_10_12x20_c: 649.0
>> > dmvr_hv_10_12x20_avx2: 48.2
>> > dmvr_hv_10_20x12_c: 677.7
>> > dmvr_hv_10_20x12_avx2: 59.7
>> > dmvr_hv_10_20x20_c: 1093.5
>> > dmvr_hv_10_20x20_avx2: 91.7
>> > dmvr_hv_12_12x20_c: 660.0
>> > dmvr_hv_12_12x20_avx2: 58.7
>> > dmvr_hv_12_20x12_c: 682.7
>> > dmvr_hv_12_20x12_avx2: 72.0
>> > dmvr_hv_12_20x20_c: 1094.0
>> > dmvr_hv_12_20x20_avx2: 113.2
>> > dmvr_v_8_12x20_c: 325.7
>> > dmvr_v_8_12x20_avx2: 31.2
>> > dmvr_v_8_20x12_c: 326.2
>> > dmvr_v_8_20x12_avx2: 38.5
>> > dmvr_v_8_20x20_c: 538.5
>> > dmvr_v_8_20x20_avx2: 54.2
>> > dmvr_v_10_12x20_c: 318.5
>> > dmvr_v_10_12x20_avx2: 23.7
>> > dmvr_v_10_20x12_c: 330.7
>> > dmvr_v_10_20x12_avx2: 40.5
>> > dmvr_v_10_20x20_c: 567.5
>> > dmvr_v_10_20x20_avx2: 48.0
>> > dmvr_v_12_12x20_c: 335.2
>> > dmvr_v_12_12x20_avx2: 30.0
>> > dmvr_v_12_20x12_c: 330.2
>> > dmvr_v_12_20x12_avx2: 39.5
>> > dmvr_v_12_20x20_c: 535.2
>> > dmvr_v_12_20x20_avx2: 60.0
>> > ---
>> >   tests/checkasm/vvc_mc.c | 59 +
>> >   1 file changed, 59 insertions(+)
>> >
>> > diff --git a/tests/checkasm/vvc_mc.c b/tests/checkasm/vvc_mc.c
>> > index bc6b580f42..62fa6aa7d0 100644
>> > --- a/tests/checkasm/vvc_mc.c
>> > +++ b/tests/checkasm/vvc_mc.c
>> > @@ -324,6 +324,64 @@ static void check_avg(void)
>> >   report("avg");
>> >   }
>> >
>> > +#define SR_RANGE 2
>> > +static void check_dmvr(void)
>> > +{
>> > +LOCAL_ALIGNED_32(uint16_t, dst0, [DST_BUF_SIZE]);
>> > +LOCAL_ALIGNED_32(uint16_t, dst1, [DST_BUF_SIZE]);
>> > +LOCAL_ALIGNED_32(uint8_t,  src0, [SRC_BUF_SIZE]);
>> > +LOCAL_ALIGNED_32(uint8_t,  src1, [SRC_BUF_SIZE]);
>> > +const int dst_stride = MAX_PB_SIZE * sizeof(int16_t);
>> > +
>> > +VVCDSPContext c;
>> > +declare_func(void, int16_t *dst, const uint8_t *src, ptrdiff_t
>> src_stride, int height,
>> > +intptr_t mx, intptr_t my, int width);
>> > +
>> > +for (int bit_depth = 8; bit_depth <= 12; bit_depth += 2) {
>> > +ff_vvc_dsp_init(&c, bit_depth);
>> > +randomize_pixels(src0, src1, SRC_BUF_SIZE);
>> > +for (int i = 0; i < 2; i++) {
>> > +for (int j = 0; j < 2; j++) {
>> > +for (int h = 8; h <= 16; h *= 2) {
>> > +for (int w = 8; w <= 16; w *= 2) {
>> > +const int pred_w = w + 2 * SR_RANGE;
>> > +const int pred_h = h + 2 * SR_RANGE;
>> > +const int mx = rnd() %
>> VVC_INTER_LUMA_DMVR_FACTS;
>> > +const int my = rnd() %
>> VVC_INTER_LUMA_DMVR_FACTS;
>> > +const char *type;
>> > +
>> > +if (w * h < 128)
>> > +continue;
>>
>> So h == 8 && w == 8 is not tested?
>>
> Hi James,
> thank you for the review.
>
> Yes, DMVR operates on subblocks with a maximum size of 16x16, and it also
> requires that the width multiplied by the height be at least 128.
> Therefore, only block sizes of 8x16, 16x8, and 16x16 are valid.
>
> see:
> 8.5.1 General decoding process for coding units coded in inter prediction
> mode
> and
> https://vicuesoft.com/blog/titles/DMVR_in_VVC/
>
Will apply this next week.
Thank you

>
>
>
>>
>> > +
>> > +switch ((j << 1) | i) {
>> > +case 0: type = "dmvr";break; // 0 0
>> > +case 1: type = "dmvr_h";  break; // 0 1
>> > +case 2: type = "dmvr_v";  break; // 1 0
>> > +  

Re: [FFmpeg-devel] [PATCH 11/11] avcodec/vvcdec: move frame tab memset from the main thread to worker threads

2024-08-11 Thread Nuo Mi
On Sun, Jul 28, 2024 at 11:19 AM Nuo Mi  wrote:

> memset tables in the main thread can become a bottleneck for the decoder.
> For example, if it takes 1% of the processing time for one core, the
> maximum achievable FPS will be 100.
> Move the memeset to worker threads will fix the issue.
>
will apply next week if there are no objections

> ---
>  libavcodec/vvc/dec.c|  13 -
>  libavcodec/vvc/thread.c | 122 
>  libavcodec/vvc/thread.h |   1 +
>  3 files changed, 85 insertions(+), 51 deletions(-)
>
> diff --git a/libavcodec/vvc/dec.c b/libavcodec/vvc/dec.c
> index 575bcfa33d..d34713296d 100644
> --- a/libavcodec/vvc/dec.c
> +++ b/libavcodec/vvc/dec.c
> @@ -82,7 +82,13 @@ static int tl_create(TabList *l)
>  if (!*t->tab)
>  return AVERROR(ENOMEM);
>  }
> -} else if (l->zero) {
> +}
> +return 0;
> +}
> +
> +static int tl_zero(TabList *l)
> +{
> +if (l->zero) {
>  for (int i = 0; i < l->nb_tabs; i++) {
>  Tab *t = l->tabs + i;
>  memset(*t->tab, 0, t->size);
> @@ -404,6 +410,11 @@ static int pic_arrays_init(VVCContext *s,
> VVCFrameContext *fc)
>  return 0;
>  }
>
> +int ff_vvc_per_frame_init(VVCFrameContext *fc)
> +{
> +return frame_context_for_each_tl(fc, tl_zero);
> +}
> +
>  static int min_positive(const int idx, const int diff, const int min_diff)
>  {
>  return diff > 0 && (idx < 0 || diff < min_diff);
> diff --git a/libavcodec/vvc/thread.c b/libavcodec/vvc/thread.c
> index 28065d726f..74f8e4e9d0 100644
> --- a/libavcodec/vvc/thread.c
> +++ b/libavcodec/vvc/thread.c
> @@ -40,6 +40,7 @@ typedef struct ProgressListener {
>  } ProgressListener;
>
>  typedef enum VVCTaskStage {
> +VVC_TASK_STAGE_INIT,// for CTU(0, 0) only
>  VVC_TASK_STAGE_PARSE,
>  VVC_TASK_STAGE_INTER,
>  VVC_TASK_STAGE_RECON,
> @@ -175,10 +176,14 @@ static int task_has_target_score(VVCTask *t, const
> VVCTaskStage stage, const uin
>  uint8_t target = 0;
>  VVCFrameContext *fc = t->fc;
>
> +if (stage == VVC_TASK_STAGE_INIT)
> +return 1;
> +
>  if (stage == VVC_TASK_STAGE_PARSE) {
> -const H266RawSPS *rsps = fc->ps.sps->r;
> -const int wpp = rsps->sps_entropy_coding_sync_enabled_flag &&
> !is_first_row(fc, t->rx, t->ry);
> -target = 2 + wpp - 1;   //left parse +
> colocation + wpp - no previous stage
> +const H266RawSPS *rsps   = fc->ps.sps->r;
> +const int wpp=
> rsps->sps_entropy_coding_sync_enabled_flag && !is_first_row(fc, t->rx,
> t->ry);
> +const int no_prev_stage  = t->rs > 0;
> +target = 2 + wpp - no_prev_stage;
>  //left parse + colocation + wpp - no_prev_stage
>  } else if (stage == VVC_TASK_STAGE_INTER) {
>  target = atomic_load(&t->target_inter_score);
>  } else {
> @@ -399,6 +404,55 @@ static int task_priority_higher(const AVTask *_a,
> const AVTask *_b)
>  return a->ry < b->ry;
>  }
>
> +static void check_colocation(VVCContext *s, VVCTask *t)
> +{
> +const VVCFrameContext *fc = t->fc;
> +
> +if (fc->ps.ph.r->ph_temporal_mvp_enabled_flag ||
> fc->ps.sps->r->sps_sbtmvp_enabled_flag) {
> +VVCFrame *col   = fc->ref->collocated_ref;
> +const int first_col = t->rx == fc->ps.pps->ctb_to_col_bd[t->rx];
> +if (col && first_col) {
> +//we depend on bottom and right boundary, do not - 1 for y
> +const int y = (t->ry << fc->ps.sps->ctb_log2_size_y);
> +add_progress_listener(col, &t->col_listener, t, s,
> VVC_PROGRESS_MV, y);
> +return;
> +}
> +}
> +frame_thread_add_score(s, fc->ft, t->rx, t->ry, VVC_TASK_STAGE_PARSE);
> +}
> +
> +static void submit_entry_point(VVCContext *s, VVCFrameThread *ft,
> SliceContext *sc, EntryPoint *ep)
> +{
> +const int rs = sc->sh.ctb_addr_in_curr_slice[ep->ctu_start];
> +VVCTask *t   = ft->tasks + rs;
> +
> +frame_thread_add_score(s, ft, t->rx, t->ry, VVC_TASK_STAGE_PARSE);
> +}
> +
> +static int run_init(VVCContext *s, VVCLocalContext *lc, VVCTask *t)
> +{
> +VVCFrameContext *fc = lc->fc;
> +VVCFrameThread *ft  = fc->ft;
> +const int ret   = ff_vvc_per_frame_init(fc);
> +
> +if (ret < 0)
> +return ret;
> +
> +for (int i = 0; i < fc->nb_slices; i++) {
> +SliceContext *sc = fc->slices[i];
> +for (int j = 0; j < sc->nb_eps; j++) {
> +EntryPoint *ep = sc->eps + j;
> +for (int k = ep->ctu_start; k < ep->ctu_end; k++) {
> +const int rs = sc->sh.ctb_addr_in_curr_slice[k];
> +VVCTask *t   = ft->tasks + rs;
> +check_colocation(s, t);
> +}
> +submit_entry_point(s, ft, sc, ep);
> +}
> +}
> +return 0;
> +}
> +
>  static void report_frame_progress(VVCFrameContext *fc,
> const int ry, const VVCProgress idx)
>  {
> @@ -547,6 +601,7 @@ static

[FFmpeg-devel] [PATCH 01/10] lavfi: set AVFilterLink.graph on link creation

2024-08-11 Thread Anton Khirnov
There is no reason to delay this.
---
 libavfilter/avfilter.c  | 1 +
 libavfilter/avfiltergraph.c | 2 --
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 2dc8820184..c4bd134fb2 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -185,6 +185,7 @@ int avfilter_link(AVFilterContext *src, unsigned srcpad,
 link->srcpad  = &src->output_pads[srcpad];
 link->dstpad  = &dst->input_pads[dstpad];
 link->type= src->output_pads[srcpad].type;
+link->graph   = src->graph;
 av_assert0(AV_PIX_FMT_NONE == -1 && AV_SAMPLE_FMT_NONE == -1);
 link->format  = -1;
 link->colorspace = AVCOL_SPC_UNSPECIFIED;
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index bd3bed9a35..2791ffa64a 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -1208,11 +1208,9 @@ static int graph_config_pointers(AVFilterGraph *graph, 
void *log_ctx)
 for (i = 0; i < graph->nb_filters; i++) {
 f = graph->filters[i];
 for (j = 0; j < f->nb_inputs; j++) {
-f->inputs[j]->graph = graph;
 ff_link_internal(f->inputs[j])->age_index  = -1;
 }
 for (j = 0; j < f->nb_outputs; j++) {
-f->outputs[j]->graph= graph;
 ff_link_internal(f->outputs[j])->age_index = -1;
 }
 if (!f->nb_outputs) {
-- 
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 02/10] lavfi: add a new struct for private link properties

2024-08-11 Thread Anton Khirnov
Specifically those that should be visible to filters, but hidden from
API callers. Such properties are currently located at the end of the
public AVFilterLink struct, demarcated by a comment marking them as
private. However it is generally better to hide them explicitly, using
the same pattern already employed in avformat or avcodec.

The new struct is currently trivial, but will become more useful in
following commits.
---
 libavfilter/avfilter.c  | 10 +-
 libavfilter/avfilter_internal.h |  3 ++-
 libavfilter/avfiltergraph.c | 10 +-
 libavfilter/filters.h   | 10 ++
 4 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index c4bd134fb2..80c9cf7b51 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -176,7 +176,7 @@ int avfilter_link(AVFilterContext *src, unsigned srcpad,
 li = av_mallocz(sizeof(*li));
 if (!li)
 return AVERROR(ENOMEM);
-link = &li->l;
+link = &li->l.pub;
 
 src->outputs[srcpad] = dst->inputs[dstpad] = link;
 
@@ -222,7 +222,7 @@ int avfilter_config_links(AVFilterContext *filter)
 
 static void update_link_current_pts(FilterLinkInternal *li, int64_t pts)
 {
-AVFilterLink *const link = &li->l;
+AVFilterLink *const link = &li->l.pub;
 
 if (pts == AV_NOPTS_VALUE)
 return;
@@ -1077,7 +1077,7 @@ static int samples_ready(FilterLinkInternal *link, 
unsigned min)
 static int take_samples(FilterLinkInternal *li, unsigned min, unsigned max,
 AVFrame **rframe)
 {
-AVFilterLink *link = &li->l;
+AVFilterLink *link = &li->l.pub;
 AVFrame *frame0, *frame, *buf;
 unsigned nb_samples, nb_frames, i, p;
 int ret;
@@ -1169,7 +1169,7 @@ static int ff_filter_frame_to_filter(AVFilterLink *link)
 
 static int forward_status_change(AVFilterContext *filter, FilterLinkInternal 
*li_in)
 {
-AVFilterLink *in = &li_in->l;
+AVFilterLink *in = &li_in->l.pub;
 unsigned out = 0, progress = 0;
 int ret;
 
@@ -1431,7 +1431,7 @@ int ff_inlink_check_available_samples(AVFilterLink *link, 
unsigned min)
 
 static void consume_update(FilterLinkInternal *li, const AVFrame *frame)
 {
-AVFilterLink *const link = &li->l;
+AVFilterLink *const link = &li->l.pub;
 update_link_current_pts(li, frame->pts);
 ff_inlink_process_commands(link, frame);
 if (link == link->dst->inputs[0])
diff --git a/libavfilter/avfilter_internal.h b/libavfilter/avfilter_internal.h
index 2c31c3e7de..7084411d68 100644
--- a/libavfilter/avfilter_internal.h
+++ b/libavfilter/avfilter_internal.h
@@ -28,10 +28,11 @@
 #include 
 
 #include "avfilter.h"
+#include "filters.h"
 #include "framequeue.h"
 
 typedef struct FilterLinkInternal {
-AVFilterLink l;
+FilterLink l;
 
 struct FFFramePool *frame_pool;
 
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index 2791ffa64a..47655703cd 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -1326,7 +1326,7 @@ static void heap_bubble_up(FFFilterGraph *graph,
 
 while (index) {
 int parent = (index - 1) >> 1;
-if (links[parent]->l.current_pts_us >= li->l.current_pts_us)
+if (links[parent]->l.pub.current_pts_us >= li->l.pub.current_pts_us)
 break;
 links[index] = links[parent];
 links[index]->age_index = index;
@@ -1348,9 +1348,9 @@ static void heap_bubble_down(FFFilterGraph *graph,
 if (child >= graph->sink_links_count)
 break;
 if (child + 1 < graph->sink_links_count &&
-links[child + 1]->l.current_pts_us < 
links[child]->l.current_pts_us)
+links[child + 1]->l.pub.current_pts_us < 
links[child]->l.pub.current_pts_us)
 child++;
-if (li->l.current_pts_us < links[child]->l.current_pts_us)
+if (li->l.pub.current_pts_us < links[child]->l.pub.current_pts_us)
 break;
 links[index] = links[child];
 links[index]->age_index = index;
@@ -1372,13 +1372,13 @@ int avfilter_graph_request_oldest(AVFilterGraph *graph)
 {
 FFFilterGraph *graphi = fffiltergraph(graph);
 FilterLinkInternal *oldesti = graphi->sink_links[0];
-AVFilterLink *oldest = &oldesti->l;
+AVFilterLink *oldest = &oldesti->l.pub;
 int64_t frame_count;
 int r;
 
 while (graphi->sink_links_count) {
 oldesti = graphi->sink_links[0];
-oldest  = &oldesti->l;
+oldest  = &oldesti->l.pub;
 if (oldest->dst->filter->activate) {
 r = av_buffersink_get_frame_flags(oldest->dst, NULL,
   AV_BUFFERSINK_FLAG_PEEK);
diff --git a/libavfilter/filters.h b/libavfilter/filters.h
index 86bc49d459..2c856fead7 100644
--- a/libavfilter/filters.h
+++ b/libavfilter/filters.h
@@ -33,6 +33,16 @@
  */
 #define FFERROR_NOT_READY FFERRTAG('N','R','D','Y')
 
+/**
+ * Link properties exposed to filter code, but not external callers.
+

[FFmpeg-devel] [PATCH 04/10] lavfi/vf_*_cuda: do not access hw contexts before checking they exist

2024-08-11 Thread Anton Khirnov
The checks are performed in init_processing_chain().
---
 libavfilter/vf_bilateral_cuda.c  | 13 -
 libavfilter/vf_chromakey_cuda.c  | 13 -
 libavfilter/vf_colorspace_cuda.c | 14 --
 libavfilter/vf_scale_cuda.c  | 13 -
 4 files changed, 32 insertions(+), 21 deletions(-)

diff --git a/libavfilter/vf_bilateral_cuda.c b/libavfilter/vf_bilateral_cuda.c
index ba008b517a..037227af93 100644
--- a/libavfilter/vf_bilateral_cuda.c
+++ b/libavfilter/vf_bilateral_cuda.c
@@ -249,17 +249,20 @@ static av_cold int 
cuda_bilateral_config_props(AVFilterLink *outlink)
 AVFilterContext *ctx = outlink->src;
 AVFilterLink *inlink = outlink->src->inputs[0];
 CUDABilateralContext *s  = ctx->priv;
-AVHWFramesContext *frames_ctx = 
(AVHWFramesContext*)inlink->hw_frames_ctx->data;
-AVCUDADeviceContext *device_hwctx = frames_ctx->device_ctx->hwctx;
+AVHWFramesContext *frames_ctx;
+AVCUDADeviceContext *device_hwctx;
 int ret;
 
-s->hwctx = device_hwctx;
-s->cu_stream = s->hwctx->stream;
-
 ret = init_processing_chain(ctx, inlink->w, inlink->h);
 if (ret < 0)
 return ret;
 
+frames_ctx   = (AVHWFramesContext*)inlink->hw_frames_ctx->data;
+device_hwctx = frames_ctx->device_ctx->hwctx;
+
+s->hwctx = device_hwctx;
+s->cu_stream = s->hwctx->stream;
+
 outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
 
 // the window_size makes more sense when it is odd, so add 1 if even
diff --git a/libavfilter/vf_chromakey_cuda.c b/libavfilter/vf_chromakey_cuda.c
index ac644caea7..e38521be0d 100644
--- a/libavfilter/vf_chromakey_cuda.c
+++ b/libavfilter/vf_chromakey_cuda.c
@@ -259,13 +259,10 @@ static av_cold int 
cudachromakey_config_props(AVFilterLink *outlink)
 AVFilterContext *ctx = outlink->src;
 AVFilterLink *inlink = outlink->src->inputs[0];
 ChromakeyCUDAContext *s = ctx->priv;
-AVHWFramesContext *frames_ctx = (AVHWFramesContext 
*)inlink->hw_frames_ctx->data;
-AVCUDADeviceContext *device_hwctx = frames_ctx->device_ctx->hwctx;
+AVHWFramesContext *frames_ctx;
+AVCUDADeviceContext *device_hwctx;
 int ret;
 
-s->hwctx = device_hwctx;
-s->cu_stream = s->hwctx->stream;
-
 if (s->is_yuv) {
 s->chromakey_uv[0] = s->chromakey_rgba[1];
 s->chromakey_uv[1] = s->chromakey_rgba[2];
@@ -278,6 +275,12 @@ static av_cold int cudachromakey_config_props(AVFilterLink 
*outlink)
 if (ret < 0)
 return ret;
 
+frames_ctx = (AVHWFramesContext *)inlink->hw_frames_ctx->data;
+device_hwctx = frames_ctx->device_ctx->hwctx;
+
+s->hwctx = device_hwctx;
+s->cu_stream = s->hwctx->stream;
+
 outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
 
 ret = cudachromakey_load_functions(ctx);
diff --git a/libavfilter/vf_colorspace_cuda.c b/libavfilter/vf_colorspace_cuda.c
index 5ad81e959c..3949cb7ed8 100644
--- a/libavfilter/vf_colorspace_cuda.c
+++ b/libavfilter/vf_colorspace_cuda.c
@@ -226,14 +226,10 @@ static av_cold int 
cudacolorspace_config_props(AVFilterLink* outlink)
 AVFilterContext* ctx = outlink->src;
 AVFilterLink* inlink = outlink->src->inputs[0];
 CUDAColorspaceContext* s = ctx->priv;
-AVHWFramesContext* frames_ctx =
-(AVHWFramesContext*)inlink->hw_frames_ctx->data;
-AVCUDADeviceContext* device_hwctx = frames_ctx->device_ctx->hwctx;
+AVHWFramesContext* frames_ctx;
+AVCUDADeviceContext* device_hwctx;
 int ret;
 
-s->hwctx = device_hwctx;
-s->cu_stream = s->hwctx->stream;
-
 outlink->w = inlink->w;
 outlink->h = inlink->h;
 
@@ -241,6 +237,12 @@ static av_cold int 
cudacolorspace_config_props(AVFilterLink* outlink)
 if (ret < 0)
 return ret;
 
+frames_ctx = (AVHWFramesContext*)inlink->hw_frames_ctx->data;
+device_hwctx = frames_ctx->device_ctx->hwctx;
+
+s->hwctx = device_hwctx;
+s->cu_stream = s->hwctx->stream;
+
 if (inlink->sample_aspect_ratio.num) {
 outlink->sample_aspect_ratio = av_mul_q(
 (AVRational){outlink->h * inlink->w, outlink->w * inlink->h},
diff --git a/libavfilter/vf_scale_cuda.c b/libavfilter/vf_scale_cuda.c
index 5571a52b1e..68d17072e3 100644
--- a/libavfilter/vf_scale_cuda.c
+++ b/libavfilter/vf_scale_cuda.c
@@ -349,14 +349,11 @@ static av_cold int cudascale_config_props(AVFilterLink 
*outlink)
 AVFilterContext *ctx = outlink->src;
 AVFilterLink *inlink = outlink->src->inputs[0];
 CUDAScaleContext *s  = ctx->priv;
-AVHWFramesContext *frames_ctx = 
(AVHWFramesContext*)inlink->hw_frames_ctx->data;
-AVCUDADeviceContext *device_hwctx = frames_ctx->device_ctx->hwctx;
+AVHWFramesContext *frames_ctx;
+AVCUDADeviceContext *device_hwctx;
 int w, h;
 int ret;
 
-s->hwctx = device_hwctx;
-s->cu_stream = s->hwctx->stream;
-
 if ((ret = ff_scale_eval_dimensions(s,
 s->w_expr, s->h_expr,
   

[FFmpeg-devel] [PATCH 06/10] lavfi: move AVFilterLink.current_pts(_us) to FilterLink

2024-08-11 Thread Anton Khirnov
---
 libavfilter/avfilter.c   | 14 +++---
 libavfilter/avfilter.h   | 12 
 libavfilter/avfiltergraph.c  |  6 +++---
 libavfilter/f_graphmonitor.c |  5 +++--
 libavfilter/filters.h| 12 
 5 files changed, 25 insertions(+), 24 deletions(-)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index de74fc2abf..9b72b6162f 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -228,8 +228,8 @@ static void update_link_current_pts(FilterLinkInternal *li, 
int64_t pts)
 
 if (pts == AV_NOPTS_VALUE)
 return;
-link->current_pts = pts;
-link->current_pts_us = av_rescale_q(pts, link->time_base, AV_TIME_BASE_Q);
+li->l.current_pts = pts;
+li->l.current_pts_us = av_rescale_q(pts, link->time_base, AV_TIME_BASE_Q);
 /* TODO use duration */
 if (link->graph && li->age_index >= 0)
 ff_avfilter_graph_update_heap(link->graph, li);
@@ -349,8 +349,8 @@ int ff_filter_config_links(AVFilterContext *filter)
 }
 
 inlink = link->src->nb_inputs ? link->src->inputs[0] : NULL;
-link->current_pts =
-link->current_pts_us = AV_NOPTS_VALUE;
+li->l.current_pts =
+li->l.current_pts_us = AV_NOPTS_VALUE;
 
 switch (li->init_state) {
 case AVLINK_INIT:
@@ -503,7 +503,7 @@ static int64_t guess_status_pts(AVFilterContext *ctx, int 
status, AVRational lin
 for (i = 0; i < ctx->nb_inputs; i++) {
 FilterLinkInternal * const li = ff_link_internal(ctx->inputs[i]);
 if (li->status_out == status)
-r = FFMIN(r, av_rescale_q(ctx->inputs[i]->current_pts, 
ctx->inputs[i]->time_base, link_time_base));
+r = FFMIN(r, av_rescale_q(li->l.current_pts, 
ctx->inputs[i]->time_base, link_time_base));
 }
 if (r < INT64_MAX)
 return r;
@@ -1396,7 +1396,7 @@ int ff_filter_activate(AVFilterContext *filter)
 int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t 
*rpts)
 {
 FilterLinkInternal * const li = ff_link_internal(link);
-*rpts = link->current_pts;
+*rpts = li->l.current_pts;
 if (ff_framequeue_queued_frames(&li->fifo))
 return *rstatus = 0;
 if (li->status_out)
@@ -1405,7 +1405,7 @@ int ff_inlink_acknowledge_status(AVFilterLink *link, int 
*rstatus, int64_t *rpts
 return *rstatus = 0;
 *rstatus = li->status_out = li->status_in;
 update_link_current_pts(li, li->status_in_pts);
-*rpts = link->current_pts;
+*rpts = li->l.current_pts;
 return 1;
 }
 
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index bf9a682bb7..0d1fdf980b 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -600,18 +600,6 @@ struct AVFilterLink {
  */
 struct AVFilterGraph *graph;
 
-/**
- * Current timestamp of the link, as defined by the most recent
- * frame(s), in link time_base units.
- */
-int64_t current_pts;
-
-/**
- * Current timestamp of the link, as defined by the most recent
- * frame(s), in AV_TIME_BASE units.
- */
-int64_t current_pts_us;
-
 /**
  * Frame rate of the stream on the link, or 1/0 if unknown or variable;
  * if left to 0/0, will be automatically copied from the first input
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index 47655703cd..e589ac2415 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -1326,7 +1326,7 @@ static void heap_bubble_up(FFFilterGraph *graph,
 
 while (index) {
 int parent = (index - 1) >> 1;
-if (links[parent]->l.pub.current_pts_us >= li->l.pub.current_pts_us)
+if (links[parent]->l.current_pts_us >= li->l.current_pts_us)
 break;
 links[index] = links[parent];
 links[index]->age_index = index;
@@ -1348,9 +1348,9 @@ static void heap_bubble_down(FFFilterGraph *graph,
 if (child >= graph->sink_links_count)
 break;
 if (child + 1 < graph->sink_links_count &&
-links[child + 1]->l.pub.current_pts_us < 
links[child]->l.pub.current_pts_us)
+links[child + 1]->l.current_pts_us < 
links[child]->l.current_pts_us)
 child++;
-if (li->l.pub.current_pts_us < links[child]->l.pub.current_pts_us)
+if (li->l.current_pts_us < links[child]->l.current_pts_us)
 break;
 links[index] = links[child];
 links[index]->age_index = index;
diff --git a/libavfilter/f_graphmonitor.c b/libavfilter/f_graphmonitor.c
index 3996261318..06573dbb96 100644
--- a/libavfilter/f_graphmonitor.c
+++ b/libavfilter/f_graphmonitor.c
@@ -258,8 +258,9 @@ static int draw_items(AVFilterContext *ctx,
   size_t frames)
 {
 GraphMonitorContext *s = ctx->priv;
+FilterLink *fl = ff_filter_link(l);
 int64_t previous_pts_us = s->cache[s->cache_index].previous_pts_us;
-int64_t current_pts_us = l->current_pts_us;
+int64_t current_pts_us = fl->current_pts_us;
 cons

[FFmpeg-devel] [PATCH 05/10] lavfi: move AVFilterLink.hw_frames_ctx to FilterLink

2024-08-11 Thread Anton Khirnov
---
 libavfilter/avfilter.c  | 24 +++-
 libavfilter/avfilter.h  |  6 --
 libavfilter/buffersink.c|  7 ++-
 libavfilter/buffersrc.c |  5 +++--
 libavfilter/filters.h   |  8 
 libavfilter/opencl.c| 11 +++
 libavfilter/qsvvpp.c| 19 ---
 libavfilter/vaapi_vpp.c | 23 ++-
 libavfilter/vf_bilateral_cuda.c | 14 +-
 libavfilter/vf_bwdif_cuda.c | 16 ++--
 libavfilter/vf_bwdif_vulkan.c   | 15 +--
 libavfilter/vf_chromakey_cuda.c | 15 +--
 libavfilter/vf_colorspace_cuda.c| 14 +-
 libavfilter/vf_deshake_opencl.c |  3 ++-
 libavfilter/vf_hwdownload.c |  6 --
 libavfilter/vf_hwmap.c  | 22 +-
 libavfilter/vf_hwupload.c   | 17 ++---
 libavfilter/vf_hwupload_cuda.c  | 11 +++
 libavfilter/vf_libplacebo.c |  3 ++-
 libavfilter/vf_libvmaf.c|  7 +--
 libavfilter/vf_overlay_cuda.c   | 11 +++
 libavfilter/vf_overlay_qsv.c| 10 +++---
 libavfilter/vf_overlay_vaapi.c  |  4 +++-
 libavfilter/vf_scale_cuda.c | 16 ++--
 libavfilter/vf_scale_npp.c  | 21 +
 libavfilter/vf_scale_vt.c   | 14 +-
 libavfilter/vf_sharpen_npp.c| 19 ---
 libavfilter/vf_stack_qsv.c  | 10 ++
 libavfilter/vf_stack_vaapi.c| 10 ++
 libavfilter/vf_thumbnail_cuda.c | 11 +++
 libavfilter/vf_transpose_npp.c  | 24 +++-
 libavfilter/vf_transpose_opencl.c   |  9 ++---
 libavfilter/vf_transpose_vaapi.c|  7 +--
 libavfilter/vf_transpose_vt.c   | 20 +---
 libavfilter/vf_transpose_vulkan.c   |  8 ++--
 libavfilter/vf_vpp_qsv.c| 16 +---
 libavfilter/vf_yadif_cuda.c | 16 ++--
 libavfilter/vf_yadif_videotoolbox.m | 15 +--
 libavfilter/video.c |  6 +++---
 libavfilter/vsrc_ddagrab.c  |  6 --
 libavfilter/vsrc_testsrc_vulkan.c   |  5 +++--
 libavfilter/vulkan_filter.c | 15 +--
 42 files changed, 326 insertions(+), 193 deletions(-)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 75e9bf6724..de74fc2abf 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -206,6 +206,8 @@ static void link_free(AVFilterLink **link)
 ff_frame_pool_uninit(&li->frame_pool);
 av_channel_layout_uninit(&(*link)->ch_layout);
 
+av_buffer_unref(&li->l.hw_frames_ctx);
+
 av_freep(link);
 }
 
@@ -411,13 +413,18 @@ int ff_filter_config_links(AVFilterContext *filter)
 link->time_base = (AVRational) {1, link->sample_rate};
 }
 
-if (link->src->nb_inputs && link->src->inputs[0]->hw_frames_ctx &&
+if (link->src->nb_inputs &&
 !(link->src->filter->flags_internal & 
FF_FILTER_FLAG_HWFRAME_AWARE)) {
-av_assert0(!link->hw_frames_ctx &&
+FilterLink *l0 = ff_filter_link(link->src->inputs[0]);
+
+av_assert0(!li->l.hw_frames_ctx &&
"should not be set by non-hwframe-aware filter");
-link->hw_frames_ctx = 
av_buffer_ref(link->src->inputs[0]->hw_frames_ctx);
-if (!link->hw_frames_ctx)
-return AVERROR(ENOMEM);
+
+if (l0->hw_frames_ctx) {
+li->l.hw_frames_ctx = av_buffer_ref(l0->hw_frames_ctx);
+if (!li->l.hw_frames_ctx)
+return AVERROR(ENOMEM);
+}
 }
 
 if ((config_link = link->dstpad->config_props))
@@ -765,8 +772,6 @@ static void free_link(AVFilterLink *link)
 if (link->dst)
 link->dst->inputs[link->dstpad - link->dst->input_pads] = NULL;
 
-av_buffer_unref(&link->hw_frames_ctx);
-
 ff_formats_unref(&link->incfg.formats);
 ff_formats_unref(&link->outcfg.formats);
 ff_formats_unref(&link->incfg.color_spaces);
@@ -1615,12 +1620,13 @@ const AVClass *avfilter_get_class(void)
 int ff_filter_init_hw_frames(AVFilterContext *avctx, AVFilterLink *link,
  int default_pool_size)
 {
+FilterLink *l = ff_filter_link(link);
 AVHWFramesContext *frames;
 
 // Must already be set by caller.
-av_assert0(link->hw_frames_ctx);
+av_assert0(l->hw_frames_ctx);
 
-frames = (AVHWFramesContext*)link->hw_frames_ctx->data;
+frames = (AVHWFramesContext*)l->hw_frames_ctx->data;
 
 if (frames->initial_pool_size == 0) {
 // Dynamic allocation is necessarily supported.
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index 2624b0cfca..bf9a682bb7 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfil

[FFmpeg-devel] [PATCH 08/10] lavfi: move AVFilterLink.{frame, sample}_count_{in, out} to FilterLink

2024-08-11 Thread Anton Khirnov
---
 libavfilter/af_adrc.c |  3 ++-
 libavfilter/af_afftdn.c   |  3 ++-
 libavfilter/af_ashowinfo.c|  4 +++-
 libavfilter/af_dynaudnorm.c   |  3 ++-
 libavfilter/af_volume.c   |  4 +++-
 libavfilter/asrc_sine.c   |  3 ++-
 libavfilter/avf_showfreqs.c   |  5 +++--
 libavfilter/avfilter.c| 16 +---
 libavfilter/avfilter.h| 10 --
 libavfilter/avfiltergraph.c   |  4 ++--
 libavfilter/f_graphmonitor.c  | 24 
 libavfilter/f_latency.c   |  6 --
 libavfilter/f_loop.c  |  6 --
 libavfilter/f_metadata.c  |  6 --
 libavfilter/f_segment.c   | 10 ++
 libavfilter/f_select.c|  4 +++-
 libavfilter/f_sendcmd.c   |  4 +++-
 libavfilter/f_streamselect.c  |  3 ++-
 libavfilter/filters.h | 10 ++
 libavfilter/qrencode.c|  3 ++-
 libavfilter/vf_bbox.c |  4 +++-
 libavfilter/vf_blackdetect.c  |  4 +++-
 libavfilter/vf_blend.c|  3 ++-
 libavfilter/vf_blockdetect.c  |  5 -
 libavfilter/vf_blurdetect.c   |  5 -
 libavfilter/vf_crop.c |  4 +++-
 libavfilter/vf_datascope.c|  4 +++-
 libavfilter/vf_delogo.c   |  4 +++-
 libavfilter/vf_detelecine.c   |  3 ++-
 libavfilter/vf_drawtext.c |  8 +---
 libavfilter/vf_eq.c   |  3 ++-
 libavfilter/vf_fade.c | 10 ++
 libavfilter/vf_fftfilt.c  |  4 +++-
 libavfilter/vf_fieldhint.c| 17 ++---
 libavfilter/vf_fieldmatch.c   |  7 ---
 libavfilter/vf_find_rect.c|  5 -
 libavfilter/vf_framestep.c|  3 ++-
 libavfilter/vf_freezeframes.c |  8 +---
 libavfilter/vf_geq.c  |  5 -
 libavfilter/vf_hue.c  |  3 ++-
 libavfilter/vf_libplacebo.c   |  6 --
 libavfilter/vf_overlay.c  |  4 +++-
 libavfilter/vf_overlay_cuda.c |  3 ++-
 libavfilter/vf_perspective.c  |  7 +--
 libavfilter/vf_quirc.c|  3 ++-
 libavfilter/vf_rotate.c   |  4 +++-
 libavfilter/vf_scale.c| 12 
 libavfilter/vf_scale_npp.c|  8 +---
 libavfilter/vf_showinfo.c |  3 ++-
 libavfilter/vf_swaprect.c |  4 +++-
 libavfilter/vf_telecine.c |  3 ++-
 libavfilter/vf_tinterlace.c   |  7 ---
 libavfilter/vf_vignette.c |  3 ++-
 libavfilter/vf_weave.c|  3 ++-
 libavfilter/vf_zoompan.c  |  9 ++---
 libavfilter/vsrc_mptestsrc.c  |  5 +++--
 56 files changed, 208 insertions(+), 116 deletions(-)

diff --git a/libavfilter/af_adrc.c b/libavfilter/af_adrc.c
index 7a7d5e0370..e11db05f70 100644
--- a/libavfilter/af_adrc.c
+++ b/libavfilter/af_adrc.c
@@ -363,6 +363,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 {
 AVFilterContext *ctx = inlink->dst;
 AVFilterLink *outlink = ctx->outputs[0];
+FilterLink *outl = ff_filter_link(outlink);
 AudioDRCContext *s = ctx->priv;
 AVFrame *out;
 int ret;
@@ -373,7 +374,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 goto fail;
 }
 
-s->var_values[VAR_SN] = outlink->sample_count_in;
+s->var_values[VAR_SN] = outl->sample_count_in;
 s->var_values[VAR_T] = s->var_values[VAR_SN] * 
(double)1/outlink->sample_rate;
 
 s->in = in;
diff --git a/libavfilter/af_afftdn.c b/libavfilter/af_afftdn.c
index a2e6ca6107..fd6b2b2685 100644
--- a/libavfilter/af_afftdn.c
+++ b/libavfilter/af_afftdn.c
@@ -355,8 +355,9 @@ static void process_frame(AVFilterContext *ctx,
   double *prior, double *prior_band_excit, int 
track_noise)
 {
 AVFilterLink *outlink = ctx->outputs[0];
+FilterLink  *outl = ff_filter_link(outlink);
 const double *abs_var = dnch->abs_var;
-const double ratio = outlink->frame_count_out ? s->ratio : 1.0;
+const double ratio = outl->frame_count_out ? s->ratio : 1.0;
 const double rratio = 1. - ratio;
 const int *bin2band = s->bin2band;
 double *noisy_data = dnch->noisy_data;
diff --git a/libavfilter/af_ashowinfo.c b/libavfilter/af_ashowinfo.c
index de3c81f90b..9ca97c609f 100644
--- a/libavfilter/af_ashowinfo.c
+++ b/libavfilter/af_ashowinfo.c
@@ -38,6 +38,7 @@
 
 #include "audio.h"
 #include "avfilter.h"
+#include "filters.h"
 #include "internal.h"
 
 typedef struct AShowInfoContext {
@@ -173,6 +174,7 @@ static void dump_unknown(AVFilterContext *ctx, 
AVFrameSideData *sd)
 
 static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
 {
+FilterLink  *inl = ff_filter_link(inlink);
 AVFilterContext *ctx = inlink->dst;
 AShowInfoContext *s  = ctx->priv;
 char chlayout_str[128];
@@ -203,7 +205,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
"n:%"PRId64" pts:%s pts_time:%s "
"fmt:%s channels:%d chlayout:%s rate:%d nb_samples:%d "
"checksum:%08"PRIX32" ",
-   inlink->frame_count_out,
+   inl->frame_count_out,
av_ts2str(buf->pts), av_ts2timestr(buf->pts, &inlink->time_base),
av_get_sample_fmt_name(buf->format), buf->c

[FFmpeg-devel] [PATCH 10/10] lavfi: move AVFilterLink.graph to FilterLink

2024-08-11 Thread Anton Khirnov
---
 libavfilter/avfilter.c  | 6 +++---
 libavfilter/avfilter.h  | 5 -
 libavfilter/avfiltergraph.c | 2 +-
 libavfilter/f_sendcmd.c | 2 +-
 libavfilter/filters.h   | 5 +
 5 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 055db01e02..43d7c9f4ab 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -185,7 +185,7 @@ int avfilter_link(AVFilterContext *src, unsigned srcpad,
 link->srcpad  = &src->output_pads[srcpad];
 link->dstpad  = &dst->input_pads[dstpad];
 link->type= src->output_pads[srcpad].type;
-link->graph   = src->graph;
+li->l.graph   = src->graph;
 av_assert0(AV_PIX_FMT_NONE == -1 && AV_SAMPLE_FMT_NONE == -1);
 link->format  = -1;
 link->colorspace = AVCOL_SPC_UNSPECIFIED;
@@ -231,8 +231,8 @@ static void update_link_current_pts(FilterLinkInternal *li, 
int64_t pts)
 li->l.current_pts = pts;
 li->l.current_pts_us = av_rescale_q(pts, link->time_base, AV_TIME_BASE_Q);
 /* TODO use duration */
-if (link->graph && li->age_index >= 0)
-ff_avfilter_graph_update_heap(link->graph, li);
+if (li->l.graph && li->age_index >= 0)
+ff_avfilter_graph_update_heap(li->l.graph, li);
 }
 
 void ff_filter_set_ready(AVFilterContext *filter, unsigned priority)
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index a91b543f5e..549fe6ce3a 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -594,11 +594,6 @@ struct AVFilterLink {
  * Lists of supported formats / etc. supported by the output filter.
  */
 AVFilterFormatsConfig outcfg;
-
-/**
- * Graph the filter belongs to.
- */
-struct AVFilterGraph *graph;
 };
 
 /**
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index 2d46dd7637..6bfcc42430 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -106,7 +106,7 @@ void ff_filter_graph_remove_filter(AVFilterGraph *graph, 
AVFilterContext *filter
 filter->graph = NULL;
 for (j = 0; jnb_outputs; j++)
 if (filter->outputs[j])
-filter->outputs[j]->graph = NULL;
+ff_filter_link(filter->outputs[j])->graph = NULL;
 
 return;
 }
diff --git a/libavfilter/f_sendcmd.c b/libavfilter/f_sendcmd.c
index 86f9d522e9..8ba0878e81 100644
--- a/libavfilter/f_sendcmd.c
+++ b/libavfilter/f_sendcmd.c
@@ -567,7 +567,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 av_log(ctx, AV_LOG_VERBOSE,
"Processing command #%d target:%s command:%s 
arg:%s\n",
cmd->index, cmd->target, cmd->command, cmd_arg);
-ret = avfilter_graph_send_command(inlink->graph,
+ret = avfilter_graph_send_command(inl->graph,
   cmd->target, 
cmd->command, cmd_arg,
   buf, sizeof(buf),
   AVFILTER_CMD_FLAG_ONE);
diff --git a/libavfilter/filters.h b/libavfilter/filters.h
index 36164c171e..ab16047e12 100644
--- a/libavfilter/filters.h
+++ b/libavfilter/filters.h
@@ -42,6 +42,11 @@
 typedef struct FilterLink {
 AVFilterLink pub;
 
+/**
+ * Graph the filter belongs to.
+ */
+struct AVFilterGraph *graph;
+
 /**
  * Current timestamp of the link, as defined by the most recent
  * frame(s), in link time_base units.
-- 
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 03/10] lavfi: move AVFilterLink.m{ax, in}_samples to FilterLink

2024-08-11 Thread Anton Khirnov
Also, document who sets these fields and when.
---
 libavfilter/af_firequalizer.c |  4 +++-
 libavfilter/af_lv2.c  |  3 ++-
 libavfilter/af_replaygain.c   |  6 --
 libavfilter/avfilter.c| 13 +++--
 libavfilter/avfilter.h| 15 ---
 libavfilter/buffersink.c  |  5 +++--
 libavfilter/filters.h | 21 +
 7 files changed, 40 insertions(+), 27 deletions(-)

diff --git a/libavfilter/af_firequalizer.c b/libavfilter/af_firequalizer.c
index 5108edca48..b889872775 100644
--- a/libavfilter/af_firequalizer.c
+++ b/libavfilter/af_firequalizer.c
@@ -26,6 +26,7 @@
 #include "libavutil/avassert.h"
 #include "libavutil/tx.h"
 #include "avfilter.h"
+#include "filters.h"
 #include "internal.h"
 #include "audio.h"
 
@@ -725,6 +726,7 @@ static int generate_kernel(AVFilterContext *ctx, const char 
*gain, const char *g
 
 static int config_input(AVFilterLink *inlink)
 {
+FilterLink *l = ff_filter_link(inlink);
 AVFilterContext *ctx = inlink->dst;
 FIREqualizerContext *s = ctx->priv;
 float iscale, scale = 1.f;
@@ -824,7 +826,7 @@ static int config_input(AVFilterLink *inlink)
inlink->sample_rate, inlink->ch_layout.nb_channels, 
s->analysis_rdft_len, s->rdft_len, s->fir_len, s->nsamples_max);
 
 if (s->fixed)
-inlink->min_samples = inlink->max_samples = s->nsamples_max;
+l->min_samples = l->max_samples = s->nsamples_max;
 
 return generate_kernel(ctx, SELECT_GAIN(s), SELECT_GAIN_ENTRY(s));
 }
diff --git a/libavfilter/af_lv2.c b/libavfilter/af_lv2.c
index a5980d5e9c..f9425a5828 100644
--- a/libavfilter/af_lv2.c
+++ b/libavfilter/af_lv2.c
@@ -34,6 +34,7 @@
 #include "libavutil/opt.h"
 #include "audio.h"
 #include "avfilter.h"
+#include "filters.h"
 #include "formats.h"
 #include "internal.h"
 
@@ -381,7 +382,7 @@ static int config_output(AVFilterLink *outlink)
 (lilv_plugin_has_feature(s->plugin, s->powerOf2BlockLength) ||
  lilv_plugin_has_feature(s->plugin, s->fixedBlockLength) ||
  lilv_plugin_has_feature(s->plugin, s->boundedBlockLength))) {
-AVFilterLink *inlink = ctx->inputs[0];
+FilterLink *inlink = ff_filter_link(ctx->inputs[0]);
 
 inlink->min_samples = inlink->max_samples = 4096;
 }
diff --git a/libavfilter/af_replaygain.c b/libavfilter/af_replaygain.c
index 266121e2c0..e7b0330e6c 100644
--- a/libavfilter/af_replaygain.c
+++ b/libavfilter/af_replaygain.c
@@ -30,6 +30,7 @@
 #include "libavutil/opt.h"
 #include "audio.h"
 #include "avfilter.h"
+#include "filters.h"
 #include "formats.h"
 #include "internal.h"
 
@@ -349,6 +350,7 @@ static int query_formats(AVFilterContext *ctx)
 
 static int config_input(AVFilterLink *inlink)
 {
+FilterLink *l = ff_filter_link(inlink);
 AVFilterContext *ctx = inlink->dst;
 ReplayGainContext *s = ctx->priv;
 int i;
@@ -366,8 +368,8 @@ static int config_input(AVFilterLink *inlink)
 
 s->yule_hist_i   = 20;
 s->butter_hist_i = 4;
-inlink->min_samples =
-inlink->max_samples = inlink->sample_rate / 20;
+l->min_samples =
+l->max_samples = inlink->sample_rate / 20;
 
 return 0;
 }
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 80c9cf7b51..75e9bf6724 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -1077,14 +1077,15 @@ static int samples_ready(FilterLinkInternal *link, 
unsigned min)
 static int take_samples(FilterLinkInternal *li, unsigned min, unsigned max,
 AVFrame **rframe)
 {
-AVFilterLink *link = &li->l.pub;
+FilterLink *l = &li->l;
+AVFilterLink *link = &l->pub;
 AVFrame *frame0, *frame, *buf;
 unsigned nb_samples, nb_frames, i, p;
 int ret;
 
 /* Note: this function relies on no format changes and must only be
called with enough samples. */
-av_assert1(samples_ready(li, link->min_samples));
+av_assert1(samples_ready(li, l->min_samples));
 frame0 = frame = ff_framequeue_peek(&li->fifo, 0);
 if (!li->fifo.samples_skipped && frame->nb_samples >= min && 
frame->nb_samples <= max) {
 *rframe = ff_framequeue_take(&li->fifo);
@@ -1142,8 +1143,8 @@ static int ff_filter_frame_to_filter(AVFilterLink *link)
 int ret;
 
 av_assert1(ff_framequeue_queued_frames(&li->fifo));
-ret = link->min_samples ?
-  ff_inlink_consume_samples(link, link->min_samples, 
link->max_samples, &frame) :
+ret = li->l.min_samples ?
+  ff_inlink_consume_samples(link, li->l.min_samples, 
li->l.max_samples, &frame) :
   ff_inlink_consume_frame(link, &frame);
 av_assert1(ret);
 if (ret < 0) {
@@ -1218,8 +1219,8 @@ static int ff_filter_activate_default(AVFilterContext 
*filter)
 }
 
 for (i = 0; i < filter->nb_inputs; i++) {
-if (samples_ready(ff_link_internal(filter->inputs[i]),
-  filter->inputs[i]->min_samples)) {
+FilterLinkInternal *li = ff_link_internal(filter->inputs[i]);
+if (samples_

[FFmpeg-devel] [PATCH 09/10] lavfi: move AVFilterLink.frame_wanted_out to FilterLinkInternal

2024-08-11 Thread Anton Khirnov
---
 libavfilter/avfilter.c  | 22 ++
 libavfilter/avfilter.h  |  7 ---
 libavfilter/avfilter_internal.h |  7 +++
 libavfilter/avfiltergraph.c |  2 +-
 libavfilter/buffersink.c|  3 ++-
 libavfilter/filters.h   |  5 +
 6 files changed, 25 insertions(+), 21 deletions(-)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 9a01bc1c4e..055db01e02 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -264,7 +264,7 @@ void ff_avfilter_link_set_in_status(AVFilterLink *link, int 
status, int64_t pts)
 av_assert0(!li->status_in);
 li->status_in = status;
 li->status_in_pts = pts;
-link->frame_wanted_out = 0;
+li->frame_wanted_out = 0;
 li->frame_blocked_in = 0;
 filter_unblock(link->dst);
 ff_filter_set_ready(link->dst, 200);
@@ -278,7 +278,7 @@ static void link_set_out_status(AVFilterLink *link, int 
status, int64_t pts)
 {
 FilterLinkInternal * const li = ff_link_internal(link);
 
-av_assert0(!link->frame_wanted_out);
+av_assert0(!li->frame_wanted_out);
 av_assert0(!li->status_out);
 li->status_out = status;
 if (pts != AV_NOPTS_VALUE)
@@ -481,7 +481,7 @@ int ff_request_frame(AVFilterLink *link)
 return li->status_out;
 if (li->status_in) {
 if (ff_framequeue_queued_frames(&li->fifo)) {
-av_assert1(!link->frame_wanted_out);
+av_assert1(!li->frame_wanted_out);
 av_assert1(link->dst->ready >= 300);
 return 0;
 } else {
@@ -492,7 +492,7 @@ int ff_request_frame(AVFilterLink *link)
 return li->status_out;
 }
 }
-link->frame_wanted_out = 1;
+li->frame_wanted_out = 1;
 ff_filter_set_ready(link->src, 100);
 return 0;
 }
@@ -1058,7 +1058,7 @@ int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
link->time_base);
 }
 
-li->frame_blocked_in = link->frame_wanted_out = 0;
+li->frame_blocked_in = li->frame_wanted_out = 0;
 li->l.frame_count_in++;
 li->l.sample_count_in += frame->nb_samples;
 filter_unblock(link->dst);
@@ -1241,7 +1241,7 @@ static int ff_filter_activate_default(AVFilterContext 
*filter)
 }
 for (i = 0; i < filter->nb_outputs; i++) {
 FilterLinkInternal * const li = ff_link_internal(filter->outputs[i]);
-if (filter->outputs[i]->frame_wanted_out &&
+if (li->frame_wanted_out &&
 !li->frame_blocked_in) {
 return ff_request_frame_to_filter(filter->outputs[i]);
 }
@@ -1581,7 +1581,7 @@ void ff_inlink_request_frame(AVFilterLink *link)
 av_unused FilterLinkInternal *li = ff_link_internal(link);
 av_assert1(!li->status_in);
 av_assert1(!li->status_out);
-link->frame_wanted_out = 1;
+li->frame_wanted_out = 1;
 ff_filter_set_ready(link->src, 100);
 }
 
@@ -1590,7 +1590,7 @@ void ff_inlink_set_status(AVFilterLink *link, int status)
 FilterLinkInternal * const li = ff_link_internal(link);
 if (li->status_out)
 return;
-link->frame_wanted_out = 0;
+li->frame_wanted_out = 0;
 li->frame_blocked_in = 0;
 link_set_out_status(link, status, AV_NOPTS_VALUE);
 while (ff_framequeue_queued_frames(&li->fifo)) {
@@ -1642,3 +1642,9 @@ int ff_filter_init_hw_frames(AVFilterContext *avctx, 
AVFilterLink *link,
 
 return 0;
 }
+
+int ff_outlink_frame_wanted(AVFilterLink *link)
+{
+FilterLinkInternal * const li = ff_link_internal(link);
+return li->frame_wanted_out;
+}
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index 176498cdb4..a91b543f5e 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -599,13 +599,6 @@ struct AVFilterLink {
  * Graph the filter belongs to.
  */
 struct AVFilterGraph *graph;
-
-/**
- * True if a frame is currently wanted on the output of this filter.
- * Set when ff_request_frame() is called by the output,
- * cleared when a frame is filtered.
- */
-int frame_wanted_out;
 };
 
 /**
diff --git a/libavfilter/avfilter_internal.h b/libavfilter/avfilter_internal.h
index 7084411d68..974024254f 100644
--- a/libavfilter/avfilter_internal.h
+++ b/libavfilter/avfilter_internal.h
@@ -67,6 +67,13 @@ typedef struct FilterLinkInternal {
  */
 int status_out;
 
+/**
+ * True if a frame is currently wanted on the output of this filter.
+ * Set when ff_request_frame() is called by the output,
+ * cleared when a frame is filtered.
+ */
+int frame_wanted_out;
+
 /**
  * Index in the age array.
  */
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index 18a3f54759..2d46dd7637 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -1406,7 +1406,7 @@ int avfilter_graph_request_oldest(AVFilterGraph *graph)
 while (frame_count == oldesti->l.frame_count_out) {
 r = ff_filter_graph_run_once(graph);
 if (r == 

[FFmpeg-devel] [PATCH 07/10] lavfi: move AVFilterLink.frame_rate to FilterLink

2024-08-11 Thread Anton Khirnov
Co-developed-by: James Almer 
---
 libavfilter/af_aiir.c  |  6 --
 libavfilter/avf_a3dscope.c |  5 +++--
 libavfilter/avf_abitscope.c|  5 +++--
 libavfilter/avf_ahistogram.c   |  5 +++--
 libavfilter/avf_aphasemeter.c  |  5 +++--
 libavfilter/avf_avectorscope.c |  5 +++--
 libavfilter/avf_concat.c   | 11 +++
 libavfilter/avf_showcqt.c  |  3 ++-
 libavfilter/avf_showcwt.c  |  5 +++--
 libavfilter/avf_showfreqs.c|  5 +++--
 libavfilter/avf_showspatial.c  |  5 +++--
 libavfilter/avf_showspectrum.c |  5 +++--
 libavfilter/avf_showvolume.c   |  5 +++--
 libavfilter/avf_showwaves.c| 11 ++-
 libavfilter/avfilter.c |  6 --
 libavfilter/avfilter.h | 13 -
 libavfilter/buffersink.c   |  8 +++-
 libavfilter/buffersrc.c|  2 +-
 libavfilter/f_drawgraph.c  |  6 --
 libavfilter/f_ebur128.c|  5 +++--
 libavfilter/f_graphmonitor.c   |  5 +++--
 libavfilter/f_interleave.c |  3 ++-
 libavfilter/f_loop.c   |  3 ++-
 libavfilter/f_streamselect.c   |  4 +++-
 libavfilter/filters.h  | 15 +++
 libavfilter/qrencode.c |  4 +++-
 libavfilter/qsvvpp.c   | 10 +-
 libavfilter/setpts.c   |  9 ++---
 libavfilter/src_avsynctest.c   |  3 ++-
 libavfilter/src_movie.c|  3 ++-
 libavfilter/stack_internal.c   | 12 +++-
 libavfilter/vaf_spectrumsynth.c| 10 ++
 libavfilter/vf_alphamerge.c|  4 +++-
 libavfilter/vf_blend.c |  5 -
 libavfilter/vf_blend_vulkan.c  |  6 +-
 libavfilter/vf_bm3d.c  |  4 +++-
 libavfilter/vf_ccrepack.c  |  4 +++-
 libavfilter/vf_colormap.c  |  5 -
 libavfilter/vf_convolve.c  |  5 -
 libavfilter/vf_coreimage.m |  4 +++-
 libavfilter/vf_corr.c  |  5 -
 libavfilter/vf_decimate.c  |  8 +---
 libavfilter/vf_deinterlace_vaapi.c |  7 +--
 libavfilter/vf_dejudder.c  |  5 -
 libavfilter/vf_deshake_opencl.c|  5 +++--
 libavfilter/vf_detelecine.c|  9 ++---
 libavfilter/vf_displace.c  |  5 -
 libavfilter/vf_eq.c|  7 +--
 libavfilter/vf_estdif.c|  8 ++--
 libavfilter/vf_fieldmatch.c|  4 +++-
 libavfilter/vf_fps.c   | 12 +++-
 libavfilter/vf_framepack.c | 18 +++---
 libavfilter/vf_framerate.c |  3 ++-
 libavfilter/vf_framestep.c | 11 +++
 libavfilter/vf_freezedetect.c  |  3 ++-
 libavfilter/vf_freezeframes.c  |  4 +++-
 libavfilter/vf_frei0r.c|  4 +++-
 libavfilter/vf_fsync.c |  3 ++-
 libavfilter/vf_guided.c|  4 +++-
 libavfilter/vf_hue.c   |  6 --
 libavfilter/vf_hysteresis.c|  5 -
 libavfilter/vf_identity.c  |  5 -
 libavfilter/vf_libplacebo.c| 17 +++--
 libavfilter/vf_libvmaf.c   |  4 +++-
 libavfilter/vf_limitdiff.c |  5 -
 libavfilter/vf_lut2.c  |  5 -
 libavfilter/vf_maskedclamp.c   |  5 -
 libavfilter/vf_maskedmerge.c   |  5 -
 libavfilter/vf_maskedminmax.c  |  5 -
 libavfilter/vf_maskedthreshold.c   |  5 -
 libavfilter/vf_mergeplanes.c   |  5 -
 libavfilter/vf_midequalizer.c  |  5 -
 libavfilter/vf_minterpolate.c  |  4 +++-
 libavfilter/vf_mix.c   |  6 --
 libavfilter/vf_morpho.c|  5 -
 libavfilter/vf_multiply.c  |  5 -
 libavfilter/vf_nnedi.c | 12 
 libavfilter/vf_overlay_qsv.c   |  5 +++--
 libavfilter/vf_premultiply.c   |  4 +++-
 libavfilter/vf_psnr.c  |  5 -
 libavfilter/vf_remap.c |  5 -
 libavfilter/vf_remap_opencl.c  |  5 -
 libavfilter/vf_repeatfields.c  |  4 +++-
 libavfilter/vf_scale.c |  5 -
 libavfilter/vf_scale_npp.c |  3 ++-
 libavfilter/vf_separatefields.c|  6 --
 libavfilter/vf_showinfo.c  | 11 +++
 libavfilter/vf_signature.c |  5 -
 libavfilter/vf_ssim.c  |  5 -
 libavfilter/vf_ssim360.c   |  5 -
 libavfilter/vf_stack.c | 15 +--
 libavfilter/vf_stereo3d.c  |  7 +--
 libavfilter/vf_telecine.c  | 10 ++
 libavfilter/vf_threshold.c |  5 -
 libavfilter/vf_tile.c  |  6 --
 libavfilter/vf_tinterlace.c| 14 +-
 libavfilter/vf_tpad.c  | 12 +++-
 libavfilter/vf_untile.c|  8 +---
 libavfilter/vf_varblur.c   |  5 -
 libavfilter/vf_vif.c   |  5 -
 libavfilter/vf_vignette.c  |  6 --
 libavfilter/vf_vpp_qsv.c   | 15 +--
 libavfilter/vf_w3fdif.c

[FFmpeg-devel] avformat/mxf: improve parsing

2024-08-11 Thread Marc-Antoine ARNAUD
-- 
Marc-Antoine ARNAUD
CEO & Founder

mobile:  +33 6 84 71 84 45
email: arnaud.marc-anto...@luminvent.com
website:  luminvent.com


0002-avformat-mxf-stop-parsing-if-index-table-is-coherent.patch
Description: Binary data


0001-avformat-mxf-start-to-add-mxf_inspect_mode-and-skip-.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".


Re: [FFmpeg-devel] avformat/mxf: improve parsing

2024-08-11 Thread Marc-Antoine ARNAUD
Yes but it's incorrect for now regarding
https://ffmpeg.org/pipermail/ffmpeg-devel/2024-August/thread.html
And the CI build is not started:
https://patchwork.ffmpeg.org/project/ffmpeg/list/

I have to send another email ...


Le dim. 11 août 2024 à 17:52, Robert Nagy  a
écrit :

> Thx. Did you send them to mailing list?
>
> On Sun, 11 Aug 2024 at 17:47, Marc-Antoine ARNAUD <
> marc-antoine.arn...@luminvent.com> wrote:
>
>> --
>> Marc-Antoine ARNAUD
>> CEO & Founder
>>
>> mobile:  +33 6 84 71 84 45
>> email: arnaud.marc-anto...@luminvent.com
>> website:  luminvent.com
>>
>

-- 
Marc-Antoine ARNAUD
CEO & Founder

mobile:  +33 6 84 71 84 45 <+33+6+84+71+84+45>
email: arnaud 
.marc-anto...@luminvent.com 

website:  luminvent.com
___
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] avformat/mxf: improve parsing

2024-08-11 Thread Marc-Antoine ARNAUD
-- 
Marc-Antoine ARNAUD
CEO & Founder

mobile:  +33 6 84 71 84 45
email: arnaud.marc-anto...@luminvent.com
website:  luminvent.com
--- Begin Message ---
sponsored by nxtedition

Signed-off-by: Marc-Antoine Arnaud 
---
 libavformat/mxfdec.c | 56 
 1 file changed, 56 insertions(+)

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index df958819300..83f9e5fc9e0 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -2063,6 +2063,52 @@ static int mxf_compute_ptses_fake_index(MXFContext *mxf, 
MXFIndexTable *index_ta
 return 0;
 }
 
+static int mxf_validate_coherent_index_tables(MXFContext *mxf, int 
*is_coherent) {
+  int i, j, ret, nb_sorted_segments = 0;
+  MXFIndexTable *index_tables;
+  int nb_index_tables = 0;
+  int coherent_index_tables = 1;
+  MXFIndexTableSegment **sorted_segments = NULL;
+
+  ret = mxf_get_sorted_table_segments(mxf, &nb_sorted_segments, 
&sorted_segments);
+
+  index_tables = av_calloc(nb_index_tables, sizeof(MXFIndexTable));
+  if (!index_tables) {
+  av_log(mxf->fc, AV_LOG_ERROR, "failed to allocate index tables\n");
+  av_free(sorted_segments);
+  return AVERROR(ENOMEM);
+  }
+
+  /* distribute sorted segments to index tables */
+  for (i = j = 0; i < nb_sorted_segments; i++) {
+  if (i != 0 && sorted_segments[i-1]->index_sid != 
sorted_segments[i]->index_sid) {
+  /* next IndexSID */
+  j++;
+  }
+
+  index_tables[j].nb_segments++;
+  }
+
+  for (i = j = 0; j < nb_index_tables; i += index_tables[j++].nb_segments) 
{
+  if (sorted_segments[i]->index_start_position) {
+  av_log(mxf->fc, AV_LOG_WARNING, "IndexSID %i starts at EditUnit 
%"PRId64" - seeking may not work as expected\n",
+ sorted_segments[i]->index_sid, 
sorted_segments[i]->index_start_position);
+  coherent_index_tables = 0;
+  }
+  }
+
+  av_free(sorted_segments);
+
+  if (ret == 0 && coherent_index_tables) {
+*is_coherent = 1;
+  } else {
+*is_coherent = 0;
+  }
+
+  return 0;
+}
+
+
 /**
  * Sorts and collects index table segments into index tables.
  * Also computes PTSes if possible.
@@ -3752,6 +3798,16 @@ static int mxf_read_header(AVFormatContext *s)
 if (!essence_offset)
 essence_offset = klv.offset;
 
+if (mxf->mxf_inspect_mode == 1) {
+int ret_local, coherent_index_tables;
+ret_local = mxf_validate_coherent_index_tables(mxf, 
&coherent_index_tables);
+
+// Break only if index table is coherent
+if (ret_local == 0 && coherent_index_tables == 1) {
+  break;
+}
+}
+
 /* seek to footer, previous partition or stop */
 if (mxf_parse_handle_essence(mxf) <= 0)
 break;
-- 
2.39.3 (Apple Git-146)

--- End Message ---
--- Begin Message ---
Signed-off-by: Marc-Antoine Arnaud 
---
 libavformat/mxfdec.c | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index a5863445ab5..df958819300 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -321,6 +321,7 @@ typedef struct MXFContext {
 int nb_index_tables;
 MXFIndexTable *index_tables;
 int eia608_extract;
+int mxf_inspect_mode;
 } MXFContext;
 
 /* NOTE: klv_offset is not set (-1) for local keys */
@@ -3713,7 +3714,9 @@ static int mxf_read_header(AVFormatContext *s)
 return AVERROR_INVALIDDATA;
 mxf->run_in = run_in;
 
-mxf_read_random_index_pack(s);
+if (mxf->mxf_inspect_mode == 0) {
+mxf_read_random_index_pack(s);
+}
 
 while (!avio_feof(s->pb)) {
 const MXFMetadataReadTableEntry *metadata;
@@ -4261,6 +4264,15 @@ static const AVOption options[] = {
 { "eia608_extract", "extract eia 608 captions from s436m track",
   offsetof(MXFContext, eia608_extract), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1,
   AV_OPT_FLAG_DECODING_PARAM },
+{ "mxf_inspect_mode", "the way to inspect MXF file",
+  offsetof(MXFContext, mxf_inspect_mode), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 
1,
+  AV_OPT_FLAG_DECODING_PARAM, .unit = "mxf_inspect_mode" },
+{ "rip", "Parse RIP, then every body partition",
+  0, AV_OPT_TYPE_CONST, {.i64 = 0}, INT_MIN, INT_MAX,
+  AV_OPT_FLAG_DECODING_PARAM, .unit = "mxf_inspect_mode" },
+{ "header", "Parse Header, first partition and next partitions if needed",
+  0, AV_OPT_TYPE_CONST, {.i64 = 1}, INT_MIN, INT_MAX,
+  AV_OPT_FLAG_DECODING_PARAM, .unit = "mxf_inspect_mode" },
 { NULL },
 };
 
-- 
2.39.3 (Apple Git-146)

--- End Message ---
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or 

Re: [FFmpeg-devel] PATCH: Fallback to NV12 format in VAAPI drivers

2024-08-11 Thread Mark Thompson
On 10/08/2024 09:51, Lluís Batlle i Rossell wrote:
> On Fri, Aug 09, 2024 at 09:43:53AM +0200, Lluís Batlle i Rossell wrote:
>> On Fri, Aug 09, 2024 at 11:49:54AM +0800, Zhao Zhili wrote:
 vaapi drivers often lack proper image converesions and not all
 situations allow vagetimage or vaputimage with the image formats
 reported by the api. nv12 seems allowed in all circumstances.

 with this change now one can use the hwaccel directly without
 explicit conversions to nv12 for frame downloading to work.

 gstreamer adopted a similar approach:
 https://bugzilla.gnome.org/show_bug.cgi?id=752958
>>>
>>> Isn’t it break all pixel formats with bit depth > 8?
>>> I think we already have hwcontext API to select sw_format, this isn’t a bug
>>> inside ffmpeg.
>>
>> Correct... I didn't think of the need beyond NV12.
>>
>> What if I redo the patch so I keep all formats, but I simply move NV12 to
>> the first place? That will make ffmpeg pick NV12 as default if NONE
>> specified.
> 
> I attach a different patch, so NV12 is only picked in case the dst format
> is NONE.

What are the surface formats where this actually gets used, and on what 
hardware and driver?

It seems probably ok if this were restricted to 4:2:0 8-bit formats (as a 
surprise implicit downsample which can't be told anything about the source 
format seems very bad), but then what is it actually covering?

Thanks,

- Mark
___
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/cbs_vp9: Try to store fewer than 2 things in the same bit

2024-08-11 Thread Mark Thompson
On 08/08/2024 00:53, Michael Niedermayer wrote:
> Fixes: use of uninitialized value
> Fixes: 
> 70907/clusterfuzz-testcase-minimized-ffmpeg_BSF_VP9_METADATA_fuzzer-6339363208757248
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/cbs_vp9.c | 9 ++---
>  libavcodec/cbs_vp9.h | 3 +++
>  libavcodec/cbs_vp9_syntax_template.c | 6 +++---
>  3 files changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/libavcodec/cbs_vp9.c b/libavcodec/cbs_vp9.c
> index 816d06da04d..7b8bc9c7985 100644
> --- a/libavcodec/cbs_vp9.c
> +++ b/libavcodec/cbs_vp9.c
> @@ -541,9 +541,12 @@ static int 
> cbs_vp9_assemble_fragment(CodedBitstreamContext *ctx,
>  size_len = av_log2(max) / 8 + 1;
>  av_assert0(size_len <= 4);
>  
> -sfi.superframe_marker= VP9_SUPERFRAME_MARKER;
> -sfi.bytes_per_framesize_minus_1  = size_len - 1;
> -sfi.frames_in_superframe_minus_1 = frag->nb_units - 1;
> +sfi.superframe_marker=
> +sfi.superframe_marker_2  = VP9_SUPERFRAME_MARKER;
> +sfi.bytes_per_framesize_minus_1  =
> +sfi.bytes_per_framesize_minus_1_2= size_len - 1;
> +sfi.frames_in_superframe_minus_1   =
> +sfi.frames_in_superframe_minus_1_2 = frag->nb_units - 1;
>  
>  size = 2;
>  for (i = 0; i < frag->nb_units; i++) {
> diff --git a/libavcodec/cbs_vp9.h b/libavcodec/cbs_vp9.h
> index af15eb4bace..428662a8cdb 100644
> --- a/libavcodec/cbs_vp9.h
> +++ b/libavcodec/cbs_vp9.h
> @@ -174,6 +174,9 @@ typedef struct VP9RawSuperframeIndex {
>  uint8_t bytes_per_framesize_minus_1;
>  uint8_t frames_in_superframe_minus_1;
>  uint32_t frame_sizes[VP9_MAX_FRAMES_IN_SUPERFRAME];
> +uint8_t superframe_marker_2;
> +uint8_t bytes_per_framesize_minus_1_2;
> +uint8_t frames_in_superframe_minus_1_2;
>  } VP9RawSuperframeIndex;
>  
>  typedef struct VP9RawSuperframe {
> diff --git a/libavcodec/cbs_vp9_syntax_template.c 
> b/libavcodec/cbs_vp9_syntax_template.c
> index 2f08eccf180..3f542d0c5d5 100644
> --- a/libavcodec/cbs_vp9_syntax_template.c
> +++ b/libavcodec/cbs_vp9_syntax_template.c
> @@ -421,9 +421,9 @@ static int FUNC(superframe_index)(CodedBitstreamContext 
> *ctx, RWContext *rw,
>  frame_sizes[i], 1, i);
>  }
>  
> -f(3, superframe_marker);
> -f(2, bytes_per_framesize_minus_1);
> -f(3, frames_in_superframe_minus_1);
> +f(3, superframe_marker_2);
> +f(2, bytes_per_framesize_minus_1_2);
> +f(3, frames_in_superframe_minus_1_2);

This gets the syntax element names wrong in traces.

>  
>  return 0;
>  }

The two instances of the syntax elements must be identical, if they aren't then 
the file is invalid.

The correct fix therefore would be to constrain the second read values to be 
identical to the first, not to introduce new syntax elements not in the 
standard to cover the invalid case.

Thanks,

- Mark
___
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] cbs_vp9: Ensure that the two superframe_header instances are identical

2024-08-11 Thread Mark Thompson
Fixes: use of uninitialized value
Fixes: 
70907/clusterfuzz-testcase-minimized-ffmpeg_BSF_VP9_METADATA_fuzzer-6339363208757248

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
---
On 11/08/2024 19:05, Mark Thompson wrote:
> The correct fix therefore would be to constrain the second read values to be 
> identical to the first, not to introduce new syntax elements not in the 
> standard to cover the invalid case.

Like this.  (Marked in the same way as your suggested patch based on my 
assumption that it fixes the problem - please check.)

Trace output is correct in the normal case, and catches the error in the bad 
one:

[trace_headers @ 0x55a0f5decb40] Packet: 11971 bytes, pts 366, dts 366.
[trace_headers @ 0x55a0f5decb40] Superframe Index
[trace_headers @ 0x55a0f5decb40] 0   superframe_marker  
   110 = 6
[trace_headers @ 0x55a0f5decb40] 3   bytes_per_framesize_minus_1
01 = 1
[trace_headers @ 0x55a0f5decb40] 5   frames_in_superframe_minus_1   
   001 = 1
[trace_headers @ 0x55a0f5decb40] 8   frame_sizes[0] 
  10101110 = 11964
[trace_headers @ 0x55a0f5decb40] 24  frame_sizes[1] 
  0001 = 1
[trace_headers @ 0x55a0f5decb40] 40  superframe_marker  
   110 = 6
[trace_headers @ 0x55a0f5decb40] 43  bytes_per_framesize_minus_1
01 = 1
[trace_headers @ 0x55a0f5decb40] 45  frames_in_superframe_minus_1   
   001 = 1

or

[trace_headers @ 0x555af04d7b40] Packet: 11971 bytes, pts 366, dts 366.
[trace_headers @ 0x555af04d7b40] Superframe Index
[trace_headers @ 0x555af04d7b40] 0   superframe_marker  
   110 = 6
[trace_headers @ 0x555af04d7b40] 3   bytes_per_framesize_minus_1
01 = 1
[trace_headers @ 0x555af04d7b40] 5   frames_in_superframe_minus_1   
   001 = 1
[trace_headers @ 0x555af04d7b40] 8   frame_sizes[0] 
  10101110 = 11964
[trace_headers @ 0x555af04d7b40] 24  frame_sizes[1] 
  0001 = 1
[trace_headers @ 0x555af04d7b40] 40  superframe_marker  
   110 = 6
[trace_headers @ 0x555af04d7b40] 43  bytes_per_framesize_minus_1
10 = 2
[trace_headers @ 0x555af04d7b40] bytes_per_framesize_minus_1 out of range: 2, 
but must be in [1,1].
[vost#0:0/copy @ 0x555af0538400] Error applying bitstream filters to a packet: 
Invalid data found when processing input

Thanks,

- Mark

 libavcodec/cbs_vp9_syntax_template.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/libavcodec/cbs_vp9_syntax_template.c 
b/libavcodec/cbs_vp9_syntax_template.c
index 2f08eccf18..5ed3c700dc 100644
--- a/libavcodec/cbs_vp9_syntax_template.c
+++ b/libavcodec/cbs_vp9_syntax_template.c
@@ -421,9 +421,14 @@ static int FUNC(superframe_index)(CodedBitstreamContext 
*ctx, RWContext *rw,
 frame_sizes[i], 1, i);
 }

-f(3, superframe_marker);
-f(2, bytes_per_framesize_minus_1);
-f(3, frames_in_superframe_minus_1);
+// Second instance of the superframe header must be identical
+// to the first.
+fixed(3,   superframe_marker,
+  current->superframe_marker);
+fixed(2,   bytes_per_framesize_minus_1,
+  current->bytes_per_framesize_minus_1);
+fixed(3,   frames_in_superframe_minus_1,
+  current->frames_in_superframe_minus_1);

 return 0;
 }
-- 
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".


Re: [FFmpeg-devel] [PATCH] avcodec/av1_vaapi: Enable AV1Profile2 VAAPI support.

2024-08-11 Thread Mark Thompson
On 30/07/2024 21:02, David (Ming Qiang) Wu via ffmpeg-devel wrote:
> AV1Profile2 VAAPI is supported and tested on AMD VCN5.
> 
> Signed-off-by: David (Ming Qiang) Wu 
> ---
>  libavcodec/av1dec.c   | 3 +++
>  libavcodec/vaapi_decode.c | 3 +++
>  2 files changed, 6 insertions(+)
> 
> diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
> index 1d5b9ef4f4..77f63661a0 100644
> --- a/libavcodec/av1dec.c
> +++ b/libavcodec/av1dec.c
> @@ -599,6 +599,9 @@ static int get_pixel_format(AVCodecContext *avctx)
>  case AV_PIX_FMT_YUV420P12:
>  #if CONFIG_AV1_VULKAN_HWACCEL
>  *fmtp++ = AV_PIX_FMT_VULKAN;
> +#endif
> +#if CONFIG_AV1_VAAPI_HWACCEL
> +*fmtp++ = AV_PIX_FMT_VAAPI;
>  #endif
>  break;
>  case AV_PIX_FMT_YUV422P:
> diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
> index a59194340f..a077e47326 100644
> --- a/libavcodec/vaapi_decode.c
> +++ b/libavcodec/vaapi_decode.c
> @@ -448,6 +448,9 @@ static const struct {
>  MAP(AV1, AV1_MAIN,AV1Profile0),
>  MAP(AV1, AV1_HIGH,AV1Profile1),
>  #endif
> +#if VA_CHECK_VERSION(1, 23, 0)
> +MAP(AV1, AV1_PROFESSIONAL,   AV1Profile2),
> +#endif
>  
>  #undef MAP
>  };

Based on  this 
is supporting profile 2 only for 4:2:0 12-bit, and therefore can't advertise 
profile 2 generally for the decoder because that would imply support for all 
4:2:2 and 4:4:4 cases as well.

I think this wants something added to VAAPI in order to be able to advertise 
partial support for a profile?

(It would be very confusing if we got "AV1Profile2" in VAAPI meaning only 4:2:0 
12-bit and then have to add a separate "AV1Profile2exceptreallythistime" to 
meant actual AV1 profile 2.)

Thanks,

- Mark
___
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/av1_vaapi: Enable AV1Profile2 VAAPI support.

2024-08-11 Thread Mark Thompson
On 11/08/2024 19:27, Mark Thompson wrote:
> On 30/07/2024 21:02, David (Ming Qiang) Wu via ffmpeg-devel wrote:
>> AV1Profile2 VAAPI is supported and tested on AMD VCN5.
>>
>> Signed-off-by: David (Ming Qiang) Wu 
>> ---
>>  libavcodec/av1dec.c   | 3 +++
>>  libavcodec/vaapi_decode.c | 3 +++
>>  2 files changed, 6 insertions(+)
>>
>> diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
>> index 1d5b9ef4f4..77f63661a0 100644
>> --- a/libavcodec/av1dec.c
>> +++ b/libavcodec/av1dec.c
>> @@ -599,6 +599,9 @@ static int get_pixel_format(AVCodecContext *avctx)
>>  case AV_PIX_FMT_YUV420P12:
>>  #if CONFIG_AV1_VULKAN_HWACCEL
>>  *fmtp++ = AV_PIX_FMT_VULKAN;
>> +#endif
>> +#if CONFIG_AV1_VAAPI_HWACCEL
>> +*fmtp++ = AV_PIX_FMT_VAAPI;
>>  #endif
>>  break;
>>  case AV_PIX_FMT_YUV422P:
>> diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
>> index a59194340f..a077e47326 100644
>> --- a/libavcodec/vaapi_decode.c
>> +++ b/libavcodec/vaapi_decode.c
>> @@ -448,6 +448,9 @@ static const struct {
>>  MAP(AV1, AV1_MAIN,AV1Profile0),
>>  MAP(AV1, AV1_HIGH,AV1Profile1),
>>  #endif
>> +#if VA_CHECK_VERSION(1, 23, 0)
>> +MAP(AV1, AV1_PROFESSIONAL,  AV1Profile2),
>> +#endif
>>  
>>  #undef MAP
>>  };
> 
> Based on  
> this is supporting profile 2 only for 4:2:0 12-bit, and therefore can't 
> advertise profile 2 generally for the decoder because that would imply 
> support for all 4:2:2 and 4:4:4 cases as well.
> 
> I think this wants something added to VAAPI in order to be able to advertise 
> partial support for a profile?
> 
> (It would be very confusing if we got "AV1Profile2" in VAAPI meaning only 
> 4:2:0 12-bit and then have to add a separate 
> "AV1Profile2exceptreallythistime" to meant actual AV1 profile 2.)

I commented in .

Please fix this before it get further in Mesa, having a version reporting 
incorrect decoder capabilities which we need to hack around elsewhere would be 
non-ideal.

Thanks,

- Mark
___
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] avformat/movenc: use stream indexes when generating track ids

2024-08-11 Thread Marton Balint




On Sat, 3 Aug 2024, James Almer wrote:


In some scenarios nb_tracks isn't the same as nb_streams, so a given id may end
up being used for two separate streams.

e.g. when muxing an IAMF track followed by a video track, if the IAMF track
consists of several streams, the video track would end up having an id of 2,
which may also be used by one of the IAMF streams.

Signed-off-by: James Almer 
---
libavformat/movenc.c | 6 +-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 8e4a037e46..8d91059081 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -4944,11 +4944,15 @@ static int mov_setup_track_ids(MOVMuxContext *mov, 
AVFormatContext *s)
mov->tracks[i].track_id = i >= mov->nb_streams ? 
++next_generated_track_id : mov->tracks[i].st->id;
}
} else {
+int last_track_id = 0;
for (i = 0; i < mov->nb_tracks; i++) {
if (mov->tracks[i].entry <= 0 && !(mov->flags & 
FF_MOV_FLAG_FRAGMENT))
continue;

-mov->tracks[i].track_id = i + 1;
+last_track_id =
+mov->tracks[i].track_id = (mov->tracks[i].st
+   ? FFMAX(mov->tracks[i].st->index, 
last_track_id)
+   : FFMAX((i ? mov->tracks[i - 
1].track_id : i), last_track_id)) + 1;


Are you sure mov->tracks[i-1].track_id is always initialized? Because 
there is a condition above which can skip certain tracks. Maybe it would 
be safer to use last_track_id instead of mov->tracks[i-1].track_id ?


Thanks,
Marton
___
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 1/2 v2] avformat/avisynth: remove atexit() handler

2024-08-11 Thread Stephen Hutchinson

On 7/28/24 11:59 AM, Stephen Hutchinson wrote:

On 7/28/24 9:38 AM, Ramiro Polla wrote:
@@ -1134,6 +1089,7 @@ static av_cold int 
avisynth_read_close(AVFormatContext *s)

  return AVERROR_UNKNOWN;

  avisynth_context_destroy(s->priv_data);
+    dlclose(avs_library.library);


Maybe it's best to wrap this around an if (avs_library.library).



True. I had tried toying around with C11 _Thread_local since we now
use C17 as the default std, and in that case there was what I presume
was a double free happening that required adding a check for whether
avs_library.library still existed.  As that hadn't been happening prior
to that test I didn't really think much of it, but yeah, it would
make sense to check it anyway.

I abandoned that general idea after 1) finding out that while GCC and
Clang are fine, MSVC doesn't seem to yet (or if it does, only the
most recent versions of MSVC 2022 do) 2) C23 renamed it to thread_local,
and most importantly, 3) I probably hadn't quite used it entirely
correctly, because while the script could be parsed and played back just
fine, trying to encode anything from it would segfault.



I had been ready to push the first two patches two weeks ago, but
the addition of #s 3 and 4 delayed that so I could test a bit more.
I didn't run into any issues with the two newer patches either, so
I'll wait another couple days for any additional comments before
pushing the whole set.
___
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: Fallback to NV12 format in VAAPI drivers

2024-08-11 Thread Lluís Batlle i Rossell
On Sun, Aug 11, 2024 at 06:57:49PM +0100, Mark Thompson wrote:
> On 10/08/2024 09:51, Lluís Batlle i Rossell wrote:
> > On Fri, Aug 09, 2024 at 09:43:53AM +0200, Lluís Batlle i Rossell wrote:
> >> On Fri, Aug 09, 2024 at 11:49:54AM +0800, Zhao Zhili wrote:
>  vaapi drivers often lack proper image converesions and not all
>  situations allow vagetimage or vaputimage with the image formats
>  reported by the api. nv12 seems allowed in all circumstances.
> 
>  with this change now one can use the hwaccel directly without
>  explicit conversions to nv12 for frame downloading to work.
> 
>  gstreamer adopted a similar approach:
>  https://bugzilla.gnome.org/show_bug.cgi?id=752958
> >>>
> >>> Isn’t it break all pixel formats with bit depth > 8?
> >>> I think we already have hwcontext API to select sw_format, this isn’t a 
> >>> bug
> >>> inside ffmpeg.
> >>
> >> Correct... I didn't think of the need beyond NV12.
> >>
> >> What if I redo the patch so I keep all formats, but I simply move NV12 to
> >> the first place? That will make ffmpeg pick NV12 as default if NONE
> >> specified.
> > 
> > I attach a different patch, so NV12 is only picked in case the dst format
> > is NONE.
> 
> What are the surface formats where this actually gets used, and on what 
> hardware and driver?
> 
> It seems probably ok if this were restricted to 4:2:0 8-bit formats (as a 
> surprise implicit downsample which can't be told anything about the source 
> format seems very bad), but then what is it actually covering?
> 

I have found that webcams doing mjpeg get the hw frames as yuv422, and
despite yuv422 is announced in ImageFormats, vaGetImage cannot download
it, with a pair of Intel cpus I tried. I looked at the driver code and
it looked broad.

So with the patches I'm exploring what can be a good approach to this
problem: va drivers report formats that maybe work through vaPutImage, but
not with vaGetImage, for what I've seen.

The immediate user problem of that is that operations using hwaccel vaapi
with mjpeg will end up failing, unless you specify an output format that
actually works. Otherwise, the vaGetImage operation says "not
implemented". So mjpeg hw decoding will not work unless
"-hwaccel_output_format" is given, or proper format is given to hwdownload
in filters.
___
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] tools/target_enc_fuzzer: Add slices and level for FFv1

2024-08-11 Thread Kacper Michajlow
On Sun, 11 Aug 2024 at 10:59, Michael Niedermayer
 wrote:
>
> Sponsored-by: Sovereign Tech Fund
> Signed-off-by: Michael Niedermayer 
> ---
>  tools/target_enc_fuzzer.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/tools/target_enc_fuzzer.c b/tools/target_enc_fuzzer.c
> index 059d7830710..59c2db4bb42 100644
> --- a/tools/target_enc_fuzzer.c
> +++ b/tools/target_enc_fuzzer.c
> @@ -149,6 +149,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
> size) {
>  av_dict_set_int(&opts, "coder", coder, 0);
>  av_dict_set_int(&opts, "context", bytestream2_get_byte(&gbc)&1, 
> 0);
>  av_dict_set_int(&opts, "slicecrc", bytestream2_get_byte(&gbc)&1, 
> 0);
> +ctx->slices = bytestream2_get_byte(&gbc);
> +ctx->level = bytestream2_get_byte(&gbc) % 6 - 1;

Note sure that's correct. Depending on the codec numeric level value
may differ, but generally it has higher value. Like 62 for "6.2" in
h264 case, or 186 for "6.2" for h265 case. I would just remove `% 6 -
1` and let fuzzer find interesting values for each codec.

- Kacper

>  break;}
>  }
>  }
> --
> 2.45.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".
___
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] tools/target_enc_fuzzer: Add slices and level for FFv1

2024-08-11 Thread Kacper Michajlow
On Mon, 12 Aug 2024 at 02:06, Kacper Michajlow  wrote:
>
> On Sun, 11 Aug 2024 at 10:59, Michael Niedermayer
>  wrote:
> >
> > Sponsored-by: Sovereign Tech Fund
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  tools/target_enc_fuzzer.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/tools/target_enc_fuzzer.c b/tools/target_enc_fuzzer.c
> > index 059d7830710..59c2db4bb42 100644
> > --- a/tools/target_enc_fuzzer.c
> > +++ b/tools/target_enc_fuzzer.c
> > @@ -149,6 +149,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
> > size) {
> >  av_dict_set_int(&opts, "coder", coder, 0);
> >  av_dict_set_int(&opts, "context", 
> > bytestream2_get_byte(&gbc)&1, 0);
> >  av_dict_set_int(&opts, "slicecrc", 
> > bytestream2_get_byte(&gbc)&1, 0);
> > +ctx->slices = bytestream2_get_byte(&gbc);
> > +ctx->level = bytestream2_get_byte(&gbc) % 6 - 1;
>
> Note sure that's correct. Depending on the codec numeric level value
> may differ, but generally it has higher value. Like 62 for "6.2" in
> h264 case, or 186 for "6.2" for h265 case. I would just remove `% 6 -
> 1` and let fuzzer find interesting values for each codec.

Oh, sorry. From the diff I couldn't see that it is in `case
AV_CODEC_ID_FFV1`, so my remark is invalid. Still might be useful to
also test invalid `level` values.

> - Kacper
>
> >  break;}
> >  }
> >  }
> > --
> > 2.45.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".
___
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] Can't use __musl__ macro

2024-08-11 Thread Lance Fredrickson

Hi all,  I use ffmpeg by way of minidlna.

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.


thanks,
Lance Fredrickson
___
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] avformat/movenc: don't look at previous track_id as it may not be set

2024-08-11 Thread James Almer
Signed-off-by: James Almer 
---
 libavformat/movenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 8d91059081..d20e45cf81 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -4952,7 +4952,7 @@ static int mov_setup_track_ids(MOVMuxContext *mov, 
AVFormatContext *s)
 last_track_id =
 mov->tracks[i].track_id = (mov->tracks[i].st
? FFMAX(mov->tracks[i].st->index, 
last_track_id)
-   : FFMAX((i ? mov->tracks[i - 
1].track_id : i), last_track_id)) + 1;
+   : FFMAX(i, last_track_id)) + 1;
 }
 }
 
-- 
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".