Re: [FFmpeg-devel] [PATCH 2/2] lavc/vvc_mc: R-V V dmvr

2024-09-28 Thread Rémi Denis-Courmont


Le 28 septembre 2024 12:42:37 GMT+03:00, flow gg  a écrit 
:
>> Is 4x unroll really faster than 2x here? We don't typically unroll 4x
>> manually.
>
>I first did 2x and then changed it to 4x. The test results are similar, and
>I'm not sure how to choose between them...

At similar speed, shorter code is better.

>> t5 seems to be 8-bit, so vwmulu.vx should work better here? Since you
>> leveraged it in the previous function, I'm a bit confused why not here,
>TBH.
>> Likewise vwmaccu.vx.
>
>DMVR doesn't have right shifts, but DMVR_h, _v, and _hv do.
>So DMVR only needs one vset, while the others, if using widen, require vset
>switching.

Sure but so what? vsetvli/vsetivli is pretty fast (unlike vsetvl), and in this 
case the code would be shorter. Or are you trying to factor the code for 
different VTYPEs?

>> Missing rounding opportunity, vssra.vi should work better here.
>> Same comments.
>
>Okay, Updated it.
>
>Rémi Denis-Courmont  于2024年9月28日周六 14:56写道:
>
>> Hi,
>>
>> Le perjantaina 27. syyskuuta 2024, 20.09.30 EEST u...@foxmail.com a écrit
>> :
>> > From: sunyuechi 
>> >
>> >  k230   banana_f3
>> > dmvr_8_12x20_c:   628.5 ( 1.00x)624.1 ( 1.00x)
>> > dmvr_8_12x20_rvv_i32: 137.5 ( 4.57x)92.9 ( 6.72x)
>> > dmvr_8_20x12_c:   609.7 ( 1.00x)655.4 ( 1.00x)
>> > dmvr_8_20x12_rvv_i32: 146.7 ( 4.16x)82.4 ( 7.95x)
>> > dmvr_8_20x20_c:   998.7 ( 1.00x)1092.9 ( 1.00x)
>> > dmvr_8_20x20_rvv_i32: 221.0 ( 4.52x)144.9 ( 7.54x)
>> > dmvr_h_8_12x20_c:2008.0 ( 1.00x)1999.2 ( 1.00x)
>> > dmvr_h_8_12x20_rvv_i32:   285.7 ( 7.03x)207.4 ( 9.64x)
>> > dmvr_h_8_20x12_c:1989.5 ( 1.00x)2009.7 ( 1.00x)
>> > dmvr_h_8_20x12_rvv_i32:   322.7 ( 6.16x)176.2 (11.41x)
>> > dmvr_h_8_20x20_c:3304.2 ( 1.00x)3342.9 ( 1.00x)
>> > dmvr_h_8_20x20_rvv_i32:   526.5 ( 6.28x)290.6 (11.50x)
>> > dmvr_hv_8_12x20_c:   3609.7 ( 1.00x)3603.4 ( 1.00x)
>> > dmvr_hv_8_12x20_rvv_i32:  554.2 ( 6.51x)467.9 ( 7.70x)
>> > dmvr_hv_8_20x12_c:   3637.5 ( 1.00x)3624.4 ( 1.00x)
>> > dmvr_hv_8_20x12_rvv_i32:  489.5 ( 7.43x)342.6 (10.58x)
>> > dmvr_hv_8_20x20_c:   6794.7 ( 1.00x)5936.9 ( 1.00x)
>> > dmvr_hv_8_20x20_rvv_i32:  785.7 ( 8.65x)561.4 (10.58x)
>> > dmvr_v_8_12x20_c:2156.0 ( 1.00x)2155.2 ( 1.00x)
>> > dmvr_v_8_12x20_rvv_i32:   295.0 ( 7.31x)207.4 (10.39x)
>> > dmvr_v_8_20x12_c:2137.5 ( 1.00x)2165.7 ( 1.00x)
>> > dmvr_v_8_20x12_rvv_i32:   322.7 ( 6.62x)186.7 (11.60x)
>> > dmvr_v_8_20x20_c:3554.2 ( 1.00x)3593.2 ( 1.00x)
>> > dmvr_v_8_20x20_rvv_i32:   535.7 ( 6.63x)290.6 (12.36x)
>> > ---
>> >  libavcodec/riscv/vvc/vvc_mc_rvv.S  | 141 +
>> >  libavcodec/riscv/vvc/vvcdsp_init.c |  22 +
>> >  2 files changed, 163 insertions(+)
>> >
>> > diff --git a/libavcodec/riscv/vvc/vvc_mc_rvv.S
>> > b/libavcodec/riscv/vvc/vvc_mc_rvv.S index 18532616d9..a5e20cbc67 100644
>> > --- a/libavcodec/riscv/vvc/vvc_mc_rvv.S
>> > +++ b/libavcodec/riscv/vvc/vvc_mc_rvv.S
>> > @@ -285,3 +285,144 @@ endfunc
>> >  func_w_avg 128
>> >  func_w_avg 256
>> >  #endif
>> > +
>> > +func dmvr zve32x, zbb, zba
>> > +lpad0
>> > +lit0, 4
>> > +1:
>> > +add   t1, a1, a2
>> > +addi  t4, a0, 128*2
>> > +add   t2, t1, a2
>> > +addi  t5, a0, 128*2*2
>> > +add   t3, t2, a2
>> > +addi  t6, a0, 128*2*3
>> > +vle8.vv0, (a1)
>> > +vle8.vv4, (t1)
>> > +vle8.vv8, (t2)
>> > +vle8.vv12, (t3)
>> > +addi  a3, a3, -4
>> > +vwmulu.vx v16, v0, t0
>> > +vwmulu.vx v20, v4, t0
>> > +vwmulu.vx v24, v8, t0
>> > +vwmulu.vx v28, v12, t0
>> > +vse16.v   v16, (a0)
>> > +vse16.v   v20, (t4)
>> > +vse16.v   v24, (t5)
>> > +vse16.v   v28, (t6)
>> > +sh2adda1, a2, a1
>> > +add   a0, a0, 128*2*4
>> > +bnez  a3, 1b
>> > +ret
>> > +endfunc
>>
>> Is 4x unroll really faster than 2x here? We don't typically unroll 4x
>> manually.
>>
>> > +
>> > +.macro dmvr_h_v mn, type
>> > +lla   t4, ff_vvc_inter_luma_dmvr_filters
>> > +sh1addt4, \mn, t4
>> > +lbu   t5, (t4)
>> > +lbu   t6, 1(t4)
>> > +1:
>> > +.ifc \type,h
>> > +addi  t0, a1, 1
>> > +add

Re: [FFmpeg-devel] [PATCH] avcodec/amfenc: Fix inverted loop filter option

2024-09-28 Thread Dmitrii Ovchinnikov
Thanks for the fix. Merged.
___
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 12/17] lavu/opt: avoid accidentally propagating spurious errors

2024-09-28 Thread Anton Khirnov
Pushed the set up to this patch, will wait a few more days for the rest
in case someone wants to comment on the API changes.

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

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


Re: [FFmpeg-devel] [PATCH 2/2] lavc/vvc_mc: R-V V dmvr

2024-09-28 Thread flow gg
> At similar speed, shorter code is better.

Okay, updated it.

> Sure but so what? vsetvli/vsetivli is pretty fast (unlike vsetvl), and in
this case the code would be shorter. Or are you trying to factor the code
for different VTYPEs?

I mistakenly thought these vsets would slow things down.. after updating,
it has indeed become faster.

Rémi Denis-Courmont  于2024年9月28日周六 21:49写道:

>
>
> Le 28 septembre 2024 12:42:37 GMT+03:00, flow gg  a
> écrit :
> >> Is 4x unroll really faster than 2x here? We don't typically unroll 4x
> >> manually.
> >
> >I first did 2x and then changed it to 4x. The test results are similar,
> and
> >I'm not sure how to choose between them...
>
> At similar speed, shorter code is better.
>
> >> t5 seems to be 8-bit, so vwmulu.vx should work better here? Since you
> >> leveraged it in the previous function, I'm a bit confused why not here,
> >TBH.
> >> Likewise vwmaccu.vx.
> >
> >DMVR doesn't have right shifts, but DMVR_h, _v, and _hv do.
> >So DMVR only needs one vset, while the others, if using widen, require
> vset
> >switching.
>
> Sure but so what? vsetvli/vsetivli is pretty fast (unlike vsetvl), and in
> this case the code would be shorter. Or are you trying to factor the code
> for different VTYPEs?
>
> >> Missing rounding opportunity, vssra.vi should work better here.
> >> Same comments.
> >
> >Okay, Updated it.
> >
> >Rémi Denis-Courmont  于2024年9月28日周六 14:56写道:
> >
> >> Hi,
> >>
> >> Le perjantaina 27. syyskuuta 2024, 20.09.30 EEST u...@foxmail.com a
> écrit
> >> :
> >> > From: sunyuechi 
> >> >
> >> >  k230   banana_f3
> >> > dmvr_8_12x20_c:   628.5 ( 1.00x)624.1 ( 1.00x)
> >> > dmvr_8_12x20_rvv_i32: 137.5 ( 4.57x)92.9 ( 6.72x)
> >> > dmvr_8_20x12_c:   609.7 ( 1.00x)655.4 ( 1.00x)
> >> > dmvr_8_20x12_rvv_i32: 146.7 ( 4.16x)82.4 ( 7.95x)
> >> > dmvr_8_20x20_c:   998.7 ( 1.00x)1092.9 (
> 1.00x)
> >> > dmvr_8_20x20_rvv_i32: 221.0 ( 4.52x)144.9 ( 7.54x)
> >> > dmvr_h_8_12x20_c:2008.0 ( 1.00x)1999.2 (
> 1.00x)
> >> > dmvr_h_8_12x20_rvv_i32:   285.7 ( 7.03x)207.4 ( 9.64x)
> >> > dmvr_h_8_20x12_c:1989.5 ( 1.00x)2009.7 (
> 1.00x)
> >> > dmvr_h_8_20x12_rvv_i32:   322.7 ( 6.16x)176.2 (11.41x)
> >> > dmvr_h_8_20x20_c:3304.2 ( 1.00x)3342.9 (
> 1.00x)
> >> > dmvr_h_8_20x20_rvv_i32:   526.5 ( 6.28x)290.6 (11.50x)
> >> > dmvr_hv_8_12x20_c:   3609.7 ( 1.00x)3603.4 (
> 1.00x)
> >> > dmvr_hv_8_12x20_rvv_i32:  554.2 ( 6.51x)467.9 ( 7.70x)
> >> > dmvr_hv_8_20x12_c:   3637.5 ( 1.00x)3624.4 (
> 1.00x)
> >> > dmvr_hv_8_20x12_rvv_i32:  489.5 ( 7.43x)342.6 (10.58x)
> >> > dmvr_hv_8_20x20_c:   6794.7 ( 1.00x)5936.9 (
> 1.00x)
> >> > dmvr_hv_8_20x20_rvv_i32:  785.7 ( 8.65x)561.4 (10.58x)
> >> > dmvr_v_8_12x20_c:2156.0 ( 1.00x)2155.2 (
> 1.00x)
> >> > dmvr_v_8_12x20_rvv_i32:   295.0 ( 7.31x)207.4 (10.39x)
> >> > dmvr_v_8_20x12_c:2137.5 ( 1.00x)2165.7 (
> 1.00x)
> >> > dmvr_v_8_20x12_rvv_i32:   322.7 ( 6.62x)186.7 (11.60x)
> >> > dmvr_v_8_20x20_c:3554.2 ( 1.00x)3593.2 (
> 1.00x)
> >> > dmvr_v_8_20x20_rvv_i32:   535.7 ( 6.63x)290.6 (12.36x)
> >> > ---
> >> >  libavcodec/riscv/vvc/vvc_mc_rvv.S  | 141
> +
> >> >  libavcodec/riscv/vvc/vvcdsp_init.c |  22 +
> >> >  2 files changed, 163 insertions(+)
> >> >
> >> > diff --git a/libavcodec/riscv/vvc/vvc_mc_rvv.S
> >> > b/libavcodec/riscv/vvc/vvc_mc_rvv.S index 18532616d9..a5e20cbc67
> 100644
> >> > --- a/libavcodec/riscv/vvc/vvc_mc_rvv.S
> >> > +++ b/libavcodec/riscv/vvc/vvc_mc_rvv.S
> >> > @@ -285,3 +285,144 @@ endfunc
> >> >  func_w_avg 128
> >> >  func_w_avg 256
> >> >  #endif
> >> > +
> >> > +func dmvr zve32x, zbb, zba
> >> > +lpad0
> >> > +lit0, 4
> >> > +1:
> >> > +add   t1, a1, a2
> >> > +addi  t4, a0, 128*2
> >> > +add   t2, t1, a2
> >> > +addi  t5, a0, 128*2*2
> >> > +add   t3, t2, a2
> >> > +addi  t6, a0, 128*2*3
> >> > +vle8.vv0, (a1)
> >> > +vle8.vv4, (t1)
> >> > +vle8.vv8, (t2)
> >> > +vle8.vv12, (t3)
> >> > +addi  a3, a3, -4
> >> > +vwmulu.vx v16, v0, t0
> >> > +vwmulu.vx v20, v4, t0
> >> > +vwmulu.vx v24, v8, t0
> >> > +vwmulu.vx v28, v12, t0
> >> > +vse16.v   v16, (a0)
> >> > +vse16.v   v20, (t4)
> >> > +vse16.v   v24, (t5)
> >> > +  

[FFmpeg-devel] [PATCH 2/2] lavc/vvc_mc: R-V V dmvr

2024-09-28 Thread uk7b
From: sunyuechi 

 k230   banana_f3
dmvr_8_12x20_c:   619.3 ( 1.00x)624.1 ( 1.00x)
dmvr_8_12x20_rvv_i32: 128.6 ( 4.82x)103.4 ( 6.04x)
dmvr_8_20x12_c:   610.0 ( 1.00x)665.6 ( 1.00x)
dmvr_8_20x12_rvv_i32: 137.6 ( 4.44x)92.9 ( 7.17x)
dmvr_8_20x20_c:  1008.0 ( 1.00x)1082.7 ( 1.00x)
dmvr_8_20x20_rvv_i32: 221.1 ( 4.56x)155.4 ( 6.97x)
dmvr_h_8_12x20_c:2008.0 ( 1.00x)2009.7 ( 1.00x)
dmvr_h_8_12x20_rvv_i32:   239.6 ( 8.38x)186.7 (10.77x)
dmvr_h_8_20x12_c:1989.5 ( 1.00x)2009.4 ( 1.00x)
dmvr_h_8_20x12_rvv_i32:   230.3 ( 8.64x)155.4 (12.93x)
dmvr_h_8_20x20_c:3304.1 ( 1.00x)3342.9 ( 1.00x)
dmvr_h_8_20x20_rvv_i32:   378.3 ( 8.73x)248.9 (13.43x)
dmvr_hv_8_12x20_c:   3609.8 ( 1.00x)3603.4 ( 1.00x)
dmvr_hv_8_12x20_rvv_i32:  369.1 ( 9.78x)322.1 (11.19x)
dmvr_hv_8_20x12_c:   3628.3 ( 1.00x)3624.2 ( 1.00x)
dmvr_hv_8_20x12_rvv_i32:  322.8 (11.24x)238.7 (15.19x)
dmvr_hv_8_20x20_c:   5933.8 ( 1.00x)5936.6 ( 1.00x)
dmvr_hv_8_20x20_rvv_i32:  526.5 (11.27x)374.1 (15.87x)
dmvr_v_8_12x20_c:2156.3 ( 1.00x)2155.4 ( 1.00x)
dmvr_v_8_12x20_rvv_i32:   239.6 ( 9.00x)176.2 (12.24x)
dmvr_v_8_20x12_c:2137.6 ( 1.00x)2165.9 ( 1.00x)
dmvr_v_8_20x12_rvv_i32:   230.3 ( 9.28x)155.2 (13.96x)
dmvr_v_8_20x20_c:4183.8 ( 1.00x)3592.9 ( 1.00x)
dmvr_v_8_20x20_rvv_i32:   369.3 (11.33x)249.2 (14.42x)
---
 libavcodec/riscv/vvc/vvc_mc_rvv.S  | 120 +
 libavcodec/riscv/vvc/vvcdsp_init.c |  22 ++
 2 files changed, 142 insertions(+)

diff --git a/libavcodec/riscv/vvc/vvc_mc_rvv.S 
b/libavcodec/riscv/vvc/vvc_mc_rvv.S
index 18532616d9..2c634af48f 100644
--- a/libavcodec/riscv/vvc/vvc_mc_rvv.S
+++ b/libavcodec/riscv/vvc/vvc_mc_rvv.S
@@ -285,3 +285,123 @@ endfunc
 func_w_avg 128
 func_w_avg 256
 #endif
+
+func dmvr zve32x, zbb, zba
+lpad0
+lit0, 4
+1:
+add   t1, a1, a2
+addi  t4, a0, 128*2
+vle8.vv0, (a1)
+vle8.vv4, (t1)
+addi  a3, a3, -2
+vwmulu.vx v16, v0, t0
+vwmulu.vx v20, v4, t0
+vse16.v   v16, (a0)
+vse16.v   v20, (t4)
+sh1adda1, a2, a1
+add   a0, a0, 128*2*2
+bnez  a3, 1b
+ret
+endfunc
+
+.macro dmvr_h_v mn, type, w, vlen
+dmvr_\type\vlen\w:
+lla   t4, ff_vvc_inter_luma_dmvr_filters
+sh1addt4, \mn, t4
+lbu   t5, (t4)
+lbu   t6, 1(t4)
+1:
+vsetvlstatic8 \w, \vlen
+.ifc \type,h
+addi  t0, a1, 1
+addi  t1, a1, 2
+.else
+add   t0, a1, a2
+add   t1, t0, a2
+.endif
+vle8.vv0, (a1)
+vle8.vv4, (t0)
+vle8.vv8, (t1)
+addi  a3, a3, -2
+addi  t2, a0, 128*2
+vwmulu.vx v12, v0, t5
+vwmulu.vx v24, v4, t5
+vwmaccu.vxv12, t6, v4
+vwmaccu.vxv24, t6, v8
+vsetvlstatic16\w, \vlen
+vssrl.vi  v12, v12, 2
+vssrl.vi  v24, v24, 2
+vse16.v   v12, (a0)
+vse16.v   v24, (t2)
+add   a0, a0, 128*4
+sh1adda1, a2, a1
+bnez  a3, 1b
+ret
+.endm
+
+.macro dmvr_load_h dst, filter0, filter1, w, vlen
+vsetvlstatic8 \w, \vlen
+addi  a6, a1, 1
+vle8.v\dst, (a1)
+vle8.vv2, (a6)
+vwmulu.vx v4, \dst, \filter0
+vwmaccu.vxv4, \filter1, v2
+vsetvlstatic16\w, \vlen
+vssrl.vi  \dst, v4, 2
+.endm
+
+.macro dmvr_hv w, vlen
+dmvr_hv\vlen\w:
+lla   t0, ff_vvc_inter_luma_dmvr_filters
+sh1addt1, a4, t0
+sh1addt2, a5, t0
+lbu   t3, (t1)  // filter[mx][0]
+lbu   t4, 1(t1) // filter[mx][1]
+lbu   t5, (t2)  // filter[my][0]
+lbu   t6, 1(t2) // filter[my][1]
+dmvr_load_h   v12, t3, t4, \w, \vlen
+add   a1, a1, a2
+1:
+vmul.vx   v28, v12, t5
+addi  a3, a3, -1
+dmvr_load_h   v12, t3, t4, \w, \vlen
+vmacc.vx  v28, t6, v12
+vssrl.vi  

Re: [FFmpeg-devel] [RFC] 7.1 Release

2024-09-28 Thread Filip Mašić
On Fri, 27 Sept 2024 at 00:51, Michael Niedermayer 
wrote:

> On Thu, Sep 26, 2024 at 12:27:58PM +0100, Filip Mašić wrote:
> > On Tue, 24 Sept 2024 at 23:48, Michael Niedermayer <
> mich...@niedermayer.cc>
> > wrote:
> >
> > > if someone can help with reviewing and applying, thats certainly
> welcome
> > > I dont think i will find the time for alot of non trivial patches
> before
> > > the release but a bigger problem is that the release branch is for
> bugfixes
> > > mainly not for feature additions, exceptions are possible, and i would
> not
> > > mind if people want this, but as said i wont have the time for this,
> theres
> > > too many other things iam trying to work on, someone else would have
> to do
> > > this
> > >
> > > thx
> > >
> >
> > Hi,
> >
> > Does this mean this non-breaking bugfix will be merged?
> > https://ffmpeg.org/pipermail/ffmpeg-devel/2024-September/333854.html
> > https://ffmpeg.org/pipermail/ffmpeg-devel/2024-September/333857.html
> > It's 9 days old if that matters. I wanted to know when I'll be able to
> use
> > it.
>
> if someone applies it and backports, yes.
>
> thx
>

OK but, who is someone? Is it the maintainer? Who's been assigned to the
merge request? How many days are meant to pass since the patch is sent in
and who is meant to be pinged with it?

I'm just confused.
___
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] avformat/hlsenc: Respect `omit_endlist` flag in subtitle playlists

2024-09-28 Thread Jonathan Baecker
Ensure that when the `-hls_flags omit_endlist` option is set,
the `#EXT-X-ENDLIST` tag is also omitted from the `stream_vtt.m3u8`
subtitle playlist. This maintains consistency with the behavior
in other playlists when `omit_endlist` is specified.
---
 libavformat/hlsenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 1e932b7..528ba0f 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -1676,7 +1676,7 @@ static int hls_window(AVFormatContext *s, int last, 
VariantStream *vs)
 }
 }

-if (last)
+if (last && (hls->flags & HLS_OMIT_ENDLIST)==0)
 ff_hls_write_end_list(hls->sub_m3u8_out);

 }
--
2.46.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 v2] avformat/hlsenc: Respect `append_list` flag in subtitle playlists

2024-09-28 Thread Jonathan Baecker
Ensure that when the `-hls_flags append_list` option is set,
that *.vtt files in stream_vtt.m3u8 are correctly updated.

This fixes https://trac.ffmpeg.org/ticket/11208

Is a bit of an ugly fix, let me know what you think.
---
 libavformat/hlsenc.c | 37 +
 1 file changed, 37 insertions(+)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 1e932b7..e93af4c 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -1202,6 +1202,22 @@ static int hls_append_segment(struct AVFormatContext *s, 
HLSContext *hls,
 return 0;
 }

+static int extract_number(const char *filename) {
+const char *dot = strrchr(filename, '.');
+const char *num_start = dot - 1;
+
+while (num_start > filename && *num_start >= '0' && *num_start <= '9') {
+num_start--;
+}
+
+num_start++;
+
+if (num_start == dot)
+return -1;
+
+return atoi(num_start);
+}
+
 static int parse_playlist(AVFormatContext *s, const char *url, VariantStream 
*vs)
 {
 HLSContext *hls = s->priv_data;
@@ -1294,6 +1310,27 @@ static int parse_playlist(AVFormatContext *s, const char 
*url, VariantStream *vs
 ret = AVERROR(ENOMEM);
 goto fail;
 }
+if (vs->has_subtitle) {
+int vtt_index = extract_number(line);
+char *vtt_file = 
av_asprintf(av_basename(vs->vtt_basename), vtt_index);
+char *new_vtt;
+
+if (!vtt_file) {
+ret = AVERROR(ENOMEM);
+goto fail;
+}
+
+new_vtt = av_strdup(vtt_file);
+av_free(vtt_file);
+
+if (!new_vtt) {
+ret = AVERROR(ENOMEM);
+goto fail;
+}
+
+ff_format_set_url(vs->vtt_avf, new_vtt);
+}
+
 ff_format_set_url(vs->avf, new_file);
 is_segment = 0;
 new_start_pos = avio_tell(vs->avf->pb);
--
2.46.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] ppc: Recognize the PPC VSX and Power8 CPU flags

2024-09-28 Thread Sean McGovern
Hi Brad,


On Fri, Sep 27, 2024, 22:16 Brad Smith 
wrote:

> ping.
>
> On 2024-09-21 5:05 a.m., Brad Smith wrote:
> > ppc: Recognize the PPC VSX and Power8 CPU flags
> >
> > Signed-off-by: Brad Smith 
> > ---
> >   libavutil/cpu.c   | 2 ++
> >   libavutil/tests/cpu.c | 2 ++
> >   2 files changed, 4 insertions(+)
> >
> > diff --git a/libavutil/cpu.c b/libavutil/cpu.c
> > index df00bd541f..44cbb9e9ff 100644
> > --- a/libavutil/cpu.c
> > +++ b/libavutil/cpu.c
> > @@ -120,6 +120,8 @@ int av_parse_cpu_caps(unsigned *flags, const char *s)
> >   { "flags"   , NULL, 0, AV_OPT_TYPE_FLAGS, { .i64 = 0 },
> INT64_MIN, INT64_MAX, .unit = "flags" },
> >   #if   ARCH_PPC
> >   { "altivec" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 =
> AV_CPU_FLAG_ALTIVEC  },.unit = "flags" },
> > +{ "vsx" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 =
> AV_CPU_FLAG_VSX  },.unit = "flags" },
> > +{ "power8"  , NULL, 0, AV_OPT_TYPE_CONST, { .i64 =
> AV_CPU_FLAG_POWER8   },.unit = "flags" },
> >   #elif ARCH_X86
> >   { "mmx" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 =
> AV_CPU_FLAG_MMX  },.unit = "flags" },
> >   { "mmx2", NULL, 0, AV_OPT_TYPE_CONST, { .i64 =
> AV_CPU_FLAG_MMX2 },.unit = "flags" },
> > diff --git a/libavutil/tests/cpu.c b/libavutil/tests/cpu.c
> > index 0a459c1d9e..53e9f99950 100644
> > --- a/libavutil/tests/cpu.c
> > +++ b/libavutil/tests/cpu.c
> > @@ -51,6 +51,8 @@ static const struct {
> >   { AV_CPU_FLAG_SETEND,"setend" },
> >   #elif ARCH_PPC
> >   { AV_CPU_FLAG_ALTIVEC,   "altivec"},
> > +{ AV_CPU_FLAG_VSX,   "vsx"},
> > +{ AV_CPU_FLAG_POWER8,"power8" },
> >   #elif ARCH_MIPS
> >   { AV_CPU_FLAG_MMI,   "mmi"},
> >   { AV_CPU_FLAG_MSA,   "msa"},
> ___
> 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".
>

I have not tested this but it looks OK to me. Sorry for the delay.

-- Sean McGovern
___
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/amfenc: Fix inverted loop filter option

2024-09-28 Thread Cameron Gutman
On Sat, Sep 28, 2024 at 9:04 AM Dmitrii Ovchinnikov
 wrote:
>
> Thanks for the fix. Merged.

Thanks Dmitrii, can you cherry-pick this bugfix and the fix for
supported HEVC color ranges to release/7.1 (if you agree they are
suitable for backporting)?
___
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/5] compat: add a fallback implementation of C23 stdckdint.h

2024-09-28 Thread Michael Niedermayer
On Thu, Sep 26, 2024 at 10:44:32PM -0300, James Almer wrote:
[...]
> index 78d3a2e0fa..ab6182bf4c 100644
> --- a/tests/ref/fate/source
> +++ b/tests/ref/fate/source
> @@ -25,6 +25,7 @@ compat/djgpp/math.h
>  compat/float/float.h
>  compat/float/limits.h
>  compat/stdbit/stdbit.h
> +compat/stdckdint/stdckdint.h
>  libavcodec/bitstream_template.h
>  tools/decode_simple.h
>  Use of av_clip() where av_clip_uintp2() could be used:

breaks here apparently:
--- ./tests/ref/fate/source 2024-09-28 00:42:07.336118776 +0200
+++ tests/data/fate/source  2024-09-28 23:20:59.576782029 +0200
@@ -1,4 +1,5 @@
 Files without standard license headers:
+compat/stdckdint/stdckdint.h
 libavcodec/file_open.c
 libavcodec/interplayacm.c
 libavcodec/log2_tab.c


 thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If one takes all money from those who grow wealth and gives it to those who
do not grow wealth, 10 years later, almost the same people who where wealthy
will be wealthy again, the same people who where poor will be poor again.


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


[FFmpeg-devel] [PATCH] libavformat/hlsplaylist: add subtitle_varname for naming subtitle streams

2024-09-28 Thread Jonathan Baecker
If 'sname:*' is set in the var_stream_map variable, use it as
the NAME attribute for subtitles. This improves the naming of
subtitle streams in HTML players, providing clearer and more
descriptive labels for users.
---
 doc/muxers.texi   | 5 +++--
 libavformat/hlsenc.c  | 7 ++-
 libavformat/hlsplaylist.c | 9 +++--
 libavformat/hlsplaylist.h | 2 +-
 4 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index ce93ba1488..04b7f20b7e 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -2436,13 +2436,14 @@ ffmpeg -re -i in.ts -b:a:0 32k -b:a:1 64k -b:v:0 1000k \
 @item
 Create a single variant stream. Add the @code{#EXT-X-MEDIA} tag with
 @code{TYPE=SUBTITLES} in the master playlist with webvtt subtitle group name
-'subtitle'. Make sure the input file has one text subtitle stream at least.
+'subtitle' and optional subtitle name, e.g. 'English'. Make sure the input
+file has one text subtitle stream at least.
 @example
 ffmpeg -y -i input_with_subtitle.mkv \
  -b:v:0 5250k -c:v h264 -pix_fmt yuv420p -profile:v main -level 4.1 \
  -b:a:0 256k \
  -c:s webvtt -c:a mp2 -ar 48000 -ac 2 -map 0:v -map 0:a:0 -map 0:s:0 \
- -f hls -var_stream_map "v:0,a:0,s:0,sgroup:subtitle" \
+ -f hls -var_stream_map "v:0,a:0,s:0,sgroup:subtitle,sname:English" \
  -master_pl_name master.m3u8 -t 300 -hls_time 10 -hls_init_time 4 
-hls_list_size \
  10 -master_pl_publish_rate 10 -hls_flags \
  delete_segments+discont_start+split_by_time ./tmp/video.m3u8
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 1e932b7b0e..7b2145f5bf 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -189,6 +189,7 @@ typedef struct VariantStream {
 const char *sgroup;   /* subtitle group name */
 const char *ccgroup;  /* closed caption group name */
 const char *varname;  /* variant name */
+const char *subtitle_varname;  /* subtitle variant name */
 } VariantStream;

 typedef struct ClosedCaptionsStream {
@@ -1533,7 +1534,8 @@ static int create_master_playlist(AVFormatContext *s,
 break;
 }

-ff_hls_write_subtitle_rendition(hls->m3u8_out, sgroup, 
vtt_m3u8_rel_name, vs->language, i, hls->has_default_key ? vs->is_default : 1);
+ff_hls_write_subtitle_rendition(hls->m3u8_out, sgroup, 
vtt_m3u8_rel_name, vs->language,
+vs->subtitle_varname, i, hls->has_default_key ? 
vs->is_default : 1);
 }

 if (!hls->has_default_key || !hls->has_video_m3u8) {
@@ -2107,6 +2109,9 @@ static int parse_variant_stream_mapstring(AVFormatContext 
*s)
 } else if (av_strstart(keyval, "name:", &val)) {
 vs->varname  = val;
 continue;
+} else if (av_strstart(keyval, "sname:", &val)) {
+vs->subtitle_varname  = val;
+continue;
 } else if (av_strstart(keyval, "agroup:", &val)) {
 vs->agroup   = val;
 continue;
diff --git a/libavformat/hlsplaylist.c b/libavformat/hlsplaylist.c
index f8a6977702..17b93a5ef1 100644
--- a/libavformat/hlsplaylist.c
+++ b/libavformat/hlsplaylist.c
@@ -57,13 +57,18 @@ void ff_hls_write_audio_rendition(AVIOContext *out, const 
char *agroup,

 void ff_hls_write_subtitle_rendition(AVIOContext *out, const char *sgroup,
  const char *filename, const char 
*language,
- int name_id, int is_default)
+ const char *sname, int name_id, int 
is_default)
 {
 if (!out || !filename)
 return;

 avio_printf(out, "#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID=\"%s\"", sgroup);
-avio_printf(out, ",NAME=\"subtitle_%d\",DEFAULT=%s,", name_id, is_default 
? "YES" : "NO");
+if (sname) {
+avio_printf(out, ",NAME=\"%s\",", sname);
+} else {
+avio_printf(out, ",NAME=\"subtitle_%d\",", name_id);
+}
+avio_printf(out, "DEFAULT=%s,", is_default ? "YES" : "NO");
 if (language) {
 avio_printf(out, "LANGUAGE=\"%s\",", language);
 }
diff --git a/libavformat/hlsplaylist.h b/libavformat/hlsplaylist.h
index d7aa44d8dc..ec44e5a0ae 100644
--- a/libavformat/hlsplaylist.h
+++ b/libavformat/hlsplaylist.h
@@ -41,7 +41,7 @@ void ff_hls_write_audio_rendition(AVIOContext *out, const 
char *agroup,
   int name_id, int is_default, int 
nb_channels);
 void ff_hls_write_subtitle_rendition(AVIOContext *out, const char *sgroup,
  const char *filename, const char 
*language,
- int name_id, int is_default);
+ const char *sname, int name_id, int 
is_default);
 void ff_hls_write_stream_info(AVStream *st, AVIOContext *out, int bandwidth,
   int avg_bandwidth,
   const char *filename, const char *agroup,
--
2.46.1

_

Re: [FFmpeg-devel] [PATCH v2 12/16] swscale/range_convert: fix mpeg ranges in yuv range conversion for non-8-bit pixel formats

2024-09-28 Thread Michael Niedermayer
On Fri, Sep 27, 2024 at 02:52:37PM +0200, Ramiro Polla wrote:
> There is an issue with the constants used in YUV to YUV range conversion,
> where the upper bound is not respected when converting to mpeg range.
> 
> With this commit, the constants are calculated at runtime, depending on
> the bit depth. This approach also allows us to more easily understand how
> the constants are derived.
> 
> For bit depths <= 14, the number of fixed point bits has been set to 14
> for all conversions, to simplify the code.
> For bit depths > 14, the number of fixed points bits has been raised and
> set to 18, to allow for the conversion to be accurate enough for the mpeg
> range to be respected.
> 
> The convert functions now take the conversion constants (coeff and offset)
> as function arguments.
> For bit depths <= 14, offset is 32-bit.
> For bit depths > 14, offset is 64-bit.
> 
> x86_64:
> chrRangeFromJpeg8_1920_c:5804.5  5845.2 ( 0.99x)
> chrRangeFromJpeg16_1920_c:   5792.8  5809.1 ( 1.00x)
> chrRangeToJpeg8_1920_c:  9388.6  9462.2 ( 0.99x)
> chrRangeToJpeg16_1920_c: 5796.5  9261.5 ( 0.63x)
> lumRangeFromJpeg8_1920_c:4147.9  4191.4 ( 0.99x)
> lumRangeFromJpeg16_1920_c:   4529.0  4143.4 ( 1.09x)
> lumRangeToJpeg8_1920_c:  5694.1  5720.5 ( 1.00x)
> lumRangeToJpeg16_1920_c: 5334.2  5139.5 ( 1.04x)
> 
> aarch64 A55:
> chrRangeFromJpeg8_1920_c:   28833.8 28834.8 ( 1.00x)
> chrRangeFromJpeg16_1920_c:  28842.8 28840.6 ( 1.00x)
> chrRangeToJpeg8_1920_c: 23070.6 23072.5 ( 1.00x)
> chrRangeToJpeg16_1920_c:17313.8 23075.1 ( 0.75x)
> lumRangeFromJpeg8_1920_c:   15388.1 15386.7 ( 1.00x)
> lumRangeFromJpeg16_1920_c:  15388.0 15383.8 ( 1.00x)
> lumRangeToJpeg8_1920_c: 19226.2 19223.6 ( 1.00x)
> lumRangeToJpeg16_1920_c:19225.5 19225.5 ( 1.00x)
> 
> aarch64 A76:
> chrRangeFromJpeg8_1920_c:6317.8  6318.5 ( 1.00x)
> chrRangeFromJpeg16_1920_c:   6322.9  6323.5 ( 1.00x)
> chrRangeToJpeg8_1920_c:  9287.1  9170.0 ( 1.01x)
> chrRangeToJpeg16_1920_c: 6104.9  9195.6 ( 0.66x)
> lumRangeFromJpeg8_1920_c:4359.1  4425.5 ( 0.98x)
> lumRangeFromJpeg16_1920_c:   4358.8  4436.8 ( 0.98x)
> lumRangeToJpeg8_1920_c:  5957.2  6017.2 ( 0.99x)
> lumRangeToJpeg16_1920_c: 6072.5  6017.2 ( 1.01x)
> 
> NOTE: all simd optimizations for range_convert have been disabled.
>   they will be re-enabled when they are fixed for each architecture.
> 
> NOTE2: the same issue still exists in rgb2yuv conversions, which is not
>addressed in this commit.
> ---
>  libswscale/aarch64/swscale.c  |   5 +
>  libswscale/hscale.c   |   6 +-
>  libswscale/swscale.c  | 103 --
>  libswscale/swscale_internal.h |  10 +-
>  libswscale/x86/swscale.c  |   5 +
>  tests/checkasm/sw_range_convert.c |  74 ++-
>  .../fate/filter-alphaextract_alphamerge_rgb   | 100 +-
>  tests/ref/fate/filter-pixdesc-gray10be|   2 +-
>  tests/ref/fate/filter-pixdesc-gray10le|   2 +-
>  tests/ref/fate/filter-pixdesc-gray12be|   2 +-
>  tests/ref/fate/filter-pixdesc-gray12le|   2 +-
>  tests/ref/fate/filter-pixdesc-gray14be|   2 +-
>  tests/ref/fate/filter-pixdesc-gray14le|   2 +-
>  tests/ref/fate/filter-pixdesc-gray16be|   2 +-
>  tests/ref/fate/filter-pixdesc-gray16le|   2 +-
>  tests/ref/fate/filter-pixdesc-gray9be |   2 +-
>  tests/ref/fate/filter-pixdesc-gray9le |   2 +-
>  tests/ref/fate/filter-pixdesc-ya16be  |   2 +-
>  tests/ref/fate/filter-pixdesc-ya16le  |   2 +-
>  tests/ref/fate/filter-pixdesc-yuvj411p|   2 +-
>  tests/ref/fate/filter-pixdesc-yuvj420p|   2 +-
>  tests/ref/fate/filter-pixdesc-yuvj422p|   2 +-
>  tests/ref/fate/filter-pixdesc-yuvj440p|   2 +-
>  tests/ref/fate/filter-pixdesc-yuvj444p|   2 +-
>  tests/ref/fate/filter-pixfmts-copy|  34 ++--
>  tests/ref/fate/filter-pixfmts-crop|  34 ++--
>  tests/ref/fate/filter-pixfmts-field   |  34 ++--
>  tests/ref/fate/filter-pixfmts-fieldorder  |  30 +--
>  tests/ref/fate/filter-pixfmts-hflip   |  34 ++--
>  tests/ref/fate/filter-pixfmts-il  |  34 ++--
>  tests/ref/fate/filter-pixfmts-lut |  18 +-
>  tests/ref/fate/filter-pixfmts-null|  34 ++--
>  tests/ref/fate/filter-pixfmts-pad |  22 +--
>  tests/ref/fate/filter-pixfmts-pullup  |  10 +-
>  tests/ref/fate/filter-pixfmts-rotate  |   4 +-
>  tests/ref/fate/filter-pixfmts-scale   |  34 ++--
>  tests/ref/fate/filter-pixfmts-swapuv  |  10 +-
>  .../ref/fate/filter-pixfmts-tinterlace_cvlpf  |   8 +-
>  .../ref/fate/filter-pixfmts-tinterlace_merge  |   8 +-
>  tests/ref/fate/filter-pixfmts-tinterlace_pad  |   8 +-
>  tests/ref/fate/filter-pixfmts-tinterlace_vlpf |   8 +-
>  tests/ref/fate/filter-pixfmts-transpose   |  28 +--
>  tests/ref/fa

Re: [FFmpeg-devel] [PATCH 10/14] swscale/range_convert: fix mpeg ranges in yuv range conversion for non-8-bit pixel formats

2024-09-28 Thread Christophe Gisquet
Hello,

Le lun. 23 sept. 2024 à 16:19, Ramiro Polla  a écrit :
> For bit depths <= 14, amax is 16-bit and offset is 32-bit.
> For bit depths > 14, amax is 32-bit and offset is 64-bit.

[...]

> -static void chrRangeToJpeg_c(int16_t *dstU, int16_t *dstV, int width)
> +static void chrRangeToJpeg_c(int16_t *dstU, int16_t *dstV, int width,
> + int amax, int coeff, int64_t _offset)
>  {
> +int offset = _offset;
>  int i;
>  for (i = 0; i < width; i++) {
> -dstU[i] = (FFMIN(dstU[i], 30775) * 4663 - 9289992) >> 12; // -264
> -dstV[i] = (FFMIN(dstV[i], 30775) * 4663 - 9289992) >> 12; // -264
> +dstU[i] = (FFMIN(dstU[i], amax) * coeff + offset) >> 14;
> +dstV[i] = (FFMIN(dstV[i], amax) * coeff + offset) >> 14;
>  }
>  }
>
> -static void chrRangeFromJpeg_c(int16_t *dstU, int16_t *dstV, int width)
> +static void chrRangeFromJpeg_c(int16_t *dstU, int16_t *dstV, int width,
> +   int amax, int coeff, int64_t _offset)
>  {
> +int offset = _offset;
>  int i;
>  for (i = 0; i < width; i++) {
> -dstU[i] = (dstU[i] * 1799 + 4081085) >> 11; // 1469
> -dstV[i] = (dstV[i] * 1799 + 4081085) >> 11; // 1469
> +dstU[i] = (dstU[i] * coeff + offset) >> 14;
> +dstV[i] = (dstV[i] * coeff + offset) >> 14;
>  }
>  }
>
> -static void lumRangeToJpeg_c(int16_t *dst, int width)
> +static void lumRangeToJpeg_c(int16_t *dst, int width,
> + int amax, int coeff, int64_t _offset)
>  {
> +int offset = _offset;
>  int i;
>  for (i = 0; i < width; i++)
> -dst[i] = (FFMIN(dst[i], 30189) * 19077 - 39057361) >> 14;
> +dst[i] = (FFMIN(dst[i], amax) * coeff + offset) >> 14;
>  }

I'm a bit surprised by some of these formulas and the range you assert
above. Somehow you make it clear by casting the offset parameters to
narrower types, so all of the following is a non-issue.

So, maybe some cases are special and so on, and you are working within
some API constrain, but the code excerpts bother me a bit:
* If dst as input is 16 bits, I don't see why amax would really be an
int (except native integer etc)
* If dst[i] = anything >> 14, with dst[i] 16 bits, you want "anything"
to be at most of 30 bits of dynamics. offset doesn't sound like it
could be of a wider range, and not 64 bits.
* Any version that does treat things as 64 bits computations, will
essentially halve the likely throughput of the SIMD, besides
potentially using way slower computations and restricting these to
fewer archs.

I expect you know that, but I'd have expected an intermediate type of
functions with parameters eg '(int16_t *dst, int width, int16_t amax,
int16_t coeff, int32_t _offset)'
Maybe to avoid issues with the weird Win ABI where the MSBs can be
garbage, that can indeed be '(int16_t *dst, ptrdiff_t width, int amax,
int16_t coeff, int32_t _offset)'.

With regards,
-- 
Christophe
___
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/5] lavu/opt: consolidate common prologue for av_opt_set*()

2024-09-28 Thread Anton Khirnov
The options-setting functions share several operations at their
beginnings - locating the option and the object to operate on, handling
the read-only and deprecated flags, and constructing the pointer to the
target value. Some of the functions also do not perform some of the
checks, although they should. E.g. a deprecation warning is currently
only printed for av_opt_set().

Introduce a prologue function that is called from every av_opt_set*()
and performs all these common initialization operations.
---
 libavutil/opt.c | 183 +---
 1 file changed, 97 insertions(+), 86 deletions(-)

diff --git a/libavutil/opt.c b/libavutil/opt.c
index 2b66318f92..81cb4b10f4 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -155,6 +155,49 @@ static void opt_free_array(const AVOption *o, void 
*parray, unsigned *count)
 *count = 0;
 }
 
+/**
+ * Perform common setup for option-setting functions.
+ *
+ * @param require_type when non-0, require the option to be of this type
+ * @param ptgt target object is written here
+ * @param po   the option is written here
+ * @param pdst pointer to option value is written here
+ */
+static int opt_set_init(void *obj, const char *name, int search_flags,
+int require_type,
+void **ptgt, const AVOption **po, void **pdst)
+{
+const AVOption *o;
+void *tgt;
+
+o = av_opt_find2(obj, name, NULL, 0, search_flags, &tgt);
+if (!o || !tgt)
+return AVERROR_OPTION_NOT_FOUND;
+
+if (o->flags & AV_OPT_FLAG_READONLY)
+return AVERROR(EINVAL);
+
+if (require_type && (o->type != require_type)) {
+av_log(obj, AV_LOG_ERROR,
+   "Tried to set option '%s' of type %s from value of type %s, "
+   "this is not supported\n", o->name, opt_type_desc[o->type].name,
+   opt_type_desc[require_type].name);
+return AVERROR(EINVAL);
+}
+
+if (o->flags & AV_OPT_FLAG_DEPRECATED)
+av_log(obj, AV_LOG_WARNING, "The \"%s\" option is deprecated: %s\n", 
name, o->help);
+
+if (po)
+*po   = o;
+if (ptgt)
+*ptgt = tgt;
+if (pdst)
+*pdst = ((uint8_t *)tgt) + o->offset;
+
+return 0;
+}
+
 static int read_number(const AVOption *o, const void *dst, double *num, int 
*den, int64_t *intnum)
 {
 switch (TYPE_BASE(o->type)) {
@@ -751,17 +794,12 @@ fail:
 int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
 {
 void *dst, *target_obj;
-const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, 
&target_obj);
-if (!o || !target_obj)
-return AVERROR_OPTION_NOT_FOUND;
+const AVOption *o;
+int ret;
 
-if (o->flags & AV_OPT_FLAG_READONLY)
-return AVERROR(EINVAL);
-
-if (o->flags & AV_OPT_FLAG_DEPRECATED)
-av_log(obj, AV_LOG_WARNING, "The \"%s\" option is deprecated: %s\n", 
name, o->help);
-
-dst = ((uint8_t *)target_obj) + o->offset;
+ret = opt_set_init(obj, name, search_flags, 0, &target_obj, &o, &dst);
+if (ret < 0)
+return ret;
 
 return ((o->type & AV_OPT_TYPE_FLAG_ARRAY) ?
 opt_set_array : opt_set_elem)(obj, target_obj, o, val, dst);
@@ -785,55 +823,50 @@ OPT_EVAL_NUMBER(double, AV_OPT_TYPE_DOUBLE,   double)
 OPT_EVAL_NUMBER(q,  AV_OPT_TYPE_RATIONAL, AVRational)
 
 static int set_number(void *obj, const char *name, double num, int den, 
int64_t intnum,
-  int search_flags)
+  int search_flags, int require_type)
 {
-void *dst, *target_obj;
-const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, 
&target_obj);
+void *dst;
+const AVOption *o;
+int ret;
 
-if (!o || !target_obj)
-return AVERROR_OPTION_NOT_FOUND;
+ret = opt_set_init(obj, name, search_flags, require_type, NULL, &o, &dst);
+if (ret < 0)
+return ret;
 
-if ((o->flags & AV_OPT_FLAG_READONLY) || (o->type & 
AV_OPT_TYPE_FLAG_ARRAY))
-return AVERROR(EINVAL);
-
-dst = ((uint8_t *)target_obj) + o->offset;
 return write_number(obj, o, dst, num, den, intnum);
 }
 
 int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
 {
-return set_number(obj, name, 1, 1, val, search_flags);
+return set_number(obj, name, 1, 1, val, search_flags, 0);
 }
 
 int av_opt_set_double(void *obj, const char *name, double val, int 
search_flags)
 {
-return set_number(obj, name, val, 1, 1, search_flags);
+return set_number(obj, name, val, 1, 1, search_flags, 0);
 }
 
 int av_opt_set_q(void *obj, const char *name, AVRational val, int search_flags)
 {
-return set_number(obj, name, val.num, val.den, 1, search_flags);
+return set_number(obj, name, val.num, val.den, 1, search_flags, 0);
 }
 
 int av_opt_set_bin(void *obj, const char *name, const uint8_t *val, int len, 
int search_flags)
 {
-void *target_obj;
-const AVOption *o = av_opt_find2(obj, name, 

[FFmpeg-devel] [PATCH 4/5] lavu/log, opt: detect setting non-runtime options post-init

2024-09-28 Thread Anton Khirnov
Add a mechanism to AVClass to allow objects to signal their state to
generic code. When an object flags itself with the 'initialized' state,
print an error (and fail, after the next major bump) if the caller
attempts to set non-runtime options.
---
 doc/APIchanges  |  3 +++
 libavutil/log.h | 18 ++
 libavutil/opt.c | 33 +
 libavutil/version.h |  2 +-
 4 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index ddd4e6c9e0..9974a5ede2 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07
 
 API changes, most recent first:
 
+2024-10-xx - xx - lavu 59.41.100 - log.h
+  Add AVClass.state_flags_offset and AV_CLASS_STATE_INITIALIZED.
+
  8< - FFmpeg 7.1 was cut here  8< -
 
 2024-09-23 - 6940a6de2f0 - lavu 59.38.100 - frame.h
diff --git a/libavutil/log.h b/libavutil/log.h
index c6b47cc054..63b3283223 100644
--- a/libavutil/log.h
+++ b/libavutil/log.h
@@ -46,6 +46,15 @@ typedef enum {
 AV_CLASS_CATEGORY_NB  ///< not part of ABI/API
 }AVClassCategory;
 
+enum AVClassStateFlags {
+/**
+ * Object initialization has finished and it is now in the 'runtime' stage.
+ * This affects e.g. what options can be set on the object (only
+ * AV_OPT_FLAG_RUNTIME_PARAM options can be set on initialized objects).
+ */
+AV_CLASS_STATE_INITIALIZED = (1 << 0),
+};
+
 #define AV_IS_INPUT_DEVICE(category) \
 (((category) == AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT) || \
  ((category) == AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT) || \
@@ -155,6 +164,15 @@ typedef struct AVClass {
  *   instance of this class.
  */
 const struct AVClass* (*child_class_iterate)(void **iter);
+
+/**
+ * When non-zero, offset in the object to an unsigned int holding object
+ * state flags, a combination of AVClassStateFlags values. The flags are
+ * updated by the object to signal its state to the generic code.
+ *
+ * Added in version 59.41.100.
+ */
+int state_flags_offset;
 } AVClass;
 
 /**
diff --git a/libavutil/opt.c b/libavutil/opt.c
index 81cb4b10f4..b85af68eff 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -185,6 +185,39 @@ static int opt_set_init(void *obj, const char *name, int 
search_flags,
 return AVERROR(EINVAL);
 }
 
+if (!(o->flags & AV_OPT_FLAG_RUNTIME_PARAM)) {
+unsigned *state_flags = NULL;
+const AVClass *class;
+
+// try state flags first from the target (child), then from its parent
+class = *(const AVClass**)tgt;
+if (
+#if LIBAVUTIL_VERSION_MAJOR < 60
+class->version >= AV_VERSION_INT(59, 41, 100) &&
+#endif
+class->state_flags_offset)
+state_flags = (unsigned*)((uint8_t*)tgt + 
class->state_flags_offset);
+
+if (!state_flags && obj != tgt) {
+class = *(const AVClass**)obj;
+if (
+#if LIBAVUTIL_VERSION_MAJOR < 60
+class->version >= AV_VERSION_INT(59, 41, 100) &&
+#endif
+class->state_flags_offset)
+state_flags = (unsigned*)((uint8_t*)obj + 
class->state_flags_offset);
+}
+
+if (state_flags && (*state_flags & AV_CLASS_STATE_INITIALIZED)) {
+av_log(obj, AV_LOG_ERROR, "Option '%s' is not a runtime option and 
"
+   "so cannot be set after the object has been initialized\n",
+   o->name);
+#if LIBAVUTIL_VERSION_MAJOR >= 60
+return AVERROR(EINVAL);
+#endif
+}
+}
+
 if (o->flags & AV_OPT_FLAG_DEPRECATED)
 av_log(obj, AV_LOG_WARNING, "The \"%s\" option is deprecated: %s\n", 
name, o->help);
 
diff --git a/libavutil/version.h b/libavutil/version.h
index 1ae3f4ef87..f08a42f3d1 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  59
-#define LIBAVUTIL_VERSION_MINOR  40
+#define LIBAVUTIL_VERSION_MINOR  41
 #define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
-- 
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/5] lavu/class: improve AVClass doxy

2024-09-28 Thread Anton Khirnov
---
 libavutil/log.h | 43 +++
 1 file changed, 27 insertions(+), 16 deletions(-)

diff --git a/libavutil/log.h b/libavutil/log.h
index ab7ceabe22..c6b47cc054 100644
--- a/libavutil/log.h
+++ b/libavutil/log.h
@@ -77,7 +77,9 @@ typedef struct AVClass {
 const char* (*item_name)(void* ctx);
 
 /**
- * a pointer to the first option specified in the class if any or NULL
+ * An array of options for the structure or NULL.
+ * When non-NULL, the array must be terminated by an option with a NULL
+ * name.
  *
  * @see av_set_default_options()
  */
@@ -85,43 +87,50 @@ typedef struct AVClass {
 
 /**
  * LIBAVUTIL_VERSION with which this structure was created.
- * This is used to allow fields to be added without requiring major
- * version bumps everywhere.
+ * This is used to allow fields to be added to AVClass without requiring
+ * major version bumps everywhere.
  */
 
 int version;
 
 /**
- * Offset in the structure where log_level_offset is stored.
- * 0 means there is no such variable
+ * Offset in the structure where the log level offset is stored. The log
+ * level offset is added to the log level for logging with this object as
+ * the context.
+ *
+ * 0 means there is no such variable.
  */
 int log_level_offset_offset;
 
 /**
  * Offset in the structure where a pointer to the parent context for
  * logging is stored. For example a decoder could pass its AVCodecContext
- * to eval as such a parent context, which an av_log() implementation
+ * to eval as such a parent context, which an ::av_log() implementation
  * could then leverage to display the parent context.
- * The offset can be NULL.
+ *
+ * When the pointer is NULL, or this offset is zero, the object is assumed
+ * to have no parent.
  */
 int parent_log_context_offset;
 
 /**
- * Category used for visualization (like color)
- * This is only set if the category is equal for all objects using this 
class.
- * available since version (51 << 16 | 56 << 8 | 100)
+ * Category used for visualization (like color).
+ *
+ * Only used when ::get_category() is NULL. Use this field when all
+ * instances of this class have the same category, use ::get_category()
+ * otherwise.
  */
 AVClassCategory category;
 
 /**
- * Callback to return the category.
- * available since version (51 << 16 | 59 << 8 | 100)
+ * Callback to return the instance category. Use this callback when
+ * different instances of this class may have different categories,
+ * ::category otherwise.
  */
 AVClassCategory (*get_category)(void* ctx);
 
 /**
  * Callback to return the supported/allowed ranges.
- * available since version (52.12)
  */
 int (*query_ranges)(struct AVOptionRanges **, void *obj, const char *key, 
int flags);
 
@@ -139,9 +148,11 @@ typedef struct AVClass {
  * @return AVClass for the next AVOptions-enabled child or NULL if there 
are
  * no more such children.
  *
- * @note The difference between child_next and this is that child_next
- *   iterates over _already existing_ objects, while 
child_class_iterate
- *   iterates over _all possible_ children.
+ * @note The difference between ::child_next() and ::child_class_iterate()
+ *   is that ::child_next() iterates over _actual_ children of an
+ *   _existing_ object instance, while ::child_class_iterate() iterates
+ *   over the classes of all _potential_ children of any possible
+ *   instance of this class.
  */
 const struct AVClass* (*child_class_iterate)(void **iter);
 } AVClass;
-- 
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 2/5] lavu/opt: combine option type size+name into a single descriptor

2024-09-28 Thread Anton Khirnov
Makes it easier to handle options generically and will be useful in
future commits.
---
 libavutil/opt.c | 84 +++--
 1 file changed, 33 insertions(+), 51 deletions(-)

diff --git a/libavutil/opt.c b/libavutil/opt.c
index 45db4f484f..2b66318f92 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -58,26 +58,29 @@ const AVOption *av_opt_next(const void *obj, const AVOption 
*last)
 return NULL;
 }
 
-static const size_t opt_elem_size[] = {
-[AV_OPT_TYPE_FLAGS] = sizeof(unsigned),
-[AV_OPT_TYPE_INT]   = sizeof(int),
-[AV_OPT_TYPE_INT64] = sizeof(int64_t),
-[AV_OPT_TYPE_UINT]  = sizeof(unsigned),
-[AV_OPT_TYPE_UINT64]= sizeof(uint64_t),
-[AV_OPT_TYPE_DOUBLE]= sizeof(double),
-[AV_OPT_TYPE_FLOAT] = sizeof(float),
-[AV_OPT_TYPE_STRING]= sizeof(char *),
-[AV_OPT_TYPE_RATIONAL]  = sizeof(AVRational),
-[AV_OPT_TYPE_BINARY]= sizeof(uint8_t *),
-[AV_OPT_TYPE_DICT]  = sizeof(AVDictionary *),
-[AV_OPT_TYPE_IMAGE_SIZE]= sizeof(int[2]),
-[AV_OPT_TYPE_VIDEO_RATE]= sizeof(AVRational),
-[AV_OPT_TYPE_PIXEL_FMT] = sizeof(int),
-[AV_OPT_TYPE_SAMPLE_FMT]= sizeof(int),
-[AV_OPT_TYPE_DURATION]  = sizeof(int64_t),
-[AV_OPT_TYPE_COLOR] = sizeof(uint8_t[4]),
-[AV_OPT_TYPE_CHLAYOUT]  = sizeof(AVChannelLayout),
-[AV_OPT_TYPE_BOOL]  = sizeof(int),
+static const struct {
+size_t  size;
+const char *name;
+} opt_type_desc[] = {
+[AV_OPT_TYPE_FLAGS] = { sizeof(unsigned),   "" },
+[AV_OPT_TYPE_INT]   = { sizeof(int),"" },
+[AV_OPT_TYPE_INT64] = { sizeof(int64_t),"" },
+[AV_OPT_TYPE_UINT]  = { sizeof(unsigned),   "" },
+[AV_OPT_TYPE_UINT64]= { sizeof(uint64_t),   "" },
+[AV_OPT_TYPE_DOUBLE]= { sizeof(double), "" },
+[AV_OPT_TYPE_FLOAT] = { sizeof(float),  "" },
+[AV_OPT_TYPE_STRING]= { sizeof(char *), "" },
+[AV_OPT_TYPE_RATIONAL]  = { sizeof(AVRational), "" },
+[AV_OPT_TYPE_BINARY]= { sizeof(uint8_t *),  "" },
+[AV_OPT_TYPE_DICT]  = { sizeof(AVDictionary *), "" },
+[AV_OPT_TYPE_IMAGE_SIZE]= { sizeof(int[2]), "" },
+[AV_OPT_TYPE_VIDEO_RATE]= { sizeof(AVRational), "" },
+[AV_OPT_TYPE_PIXEL_FMT] = { sizeof(int),"" },
+[AV_OPT_TYPE_SAMPLE_FMT]= { sizeof(int),"" },
+[AV_OPT_TYPE_DURATION]  = { sizeof(int64_t),"" },
+[AV_OPT_TYPE_COLOR] = { sizeof(uint8_t[4]), "" },
+[AV_OPT_TYPE_CHLAYOUT]  = { sizeof(AVChannelLayout),"" 
},
+[AV_OPT_TYPE_BOOL]  = { sizeof(int),"" },
 };
 
 // option is plain old data
@@ -114,7 +117,7 @@ static uint8_t opt_array_sep(const AVOption *o)
 static void *opt_array_pelem(const AVOption *o, void *array, unsigned idx)
 {
 av_assert1(o->type & AV_OPT_TYPE_FLAG_ARRAY);
-return (uint8_t *)array + idx * opt_elem_size[TYPE_BASE(o->type)];
+return (uint8_t *)array + idx * opt_type_desc[TYPE_BASE(o->type)].size;
 }
 
 static unsigned *opt_array_pcount(const void *parray)
@@ -670,7 +673,7 @@ static int opt_set_array(void *obj, void *target_obj, const 
AVOption *o,
  const char *val, void *dst)
 {
 const AVOptionArrayDef *arr = o->default_val.arr;
-const size_t  elem_size = opt_elem_size[TYPE_BASE(o->type)];
+const size_t  elem_size = opt_type_desc[TYPE_BASE(o->type)].size;
 const uint8_t   sep = opt_array_sep(o);
 uint8_t*str = NULL;
 
@@ -1441,36 +1444,15 @@ static char *get_opt_flags_string(void *obj, const char 
*unit, int64_t value)
 static void log_type(void *av_log_obj, const AVOption *o,
  enum AVOptionType parent_type)
 {
-const char *desc[] = {
-[AV_OPT_TYPE_FLAGS] = "",
-[AV_OPT_TYPE_INT]   = "",
-[AV_OPT_TYPE_INT64] = "",
-[AV_OPT_TYPE_UINT]  = "",
-[AV_OPT_TYPE_UINT64]= "",
-[AV_OPT_TYPE_DOUBLE]= "",
-[AV_OPT_TYPE_FLOAT] = "",
-[AV_OPT_TYPE_STRING]= "",
-[AV_OPT_TYPE_RATIONAL]  = "",
-[AV_OPT_TYPE_BINARY]= "",
-[AV_OPT_TYPE_DICT]  = "",
-[AV_OPT_TYPE_IMAGE_SIZE]= "",
-[AV_OPT_TYPE_VIDEO_RATE]= "",
-[AV_OPT_TYPE_PIXEL_FMT] = "",
-[AV_OPT_TYPE_SAMPLE_FMT]= "",
-[AV_OPT_TYPE_DURATION]  = "",
-[AV_OPT_TYPE_COLOR] = "",
-[AV_OPT_TYPE_CHLAYOUT]  = "",
-[AV_OPT_TYPE_BOOL]  = "",
-};
 const enum AVOptionType type = TYPE_BASE(o->type);
 
 if (o->type == AV_OPT_TYPE_CONST && TYPE_BASE(parent_type) == 
AV_OPT_TYPE_INT)
 av_log(av_log_obj, AV_LOG_INFO, "%

[FFmpeg-devel] [PATCH 5/5] lavfi/avfilter: export AVFilter initialization state

2024-09-28 Thread Anton Khirnov
This will allow the AVOption code to detect setting non-runtime options
after the filter has been initialized.
---
 libavfilter/avfilter.c  | 8 +---
 libavfilter/avfilter_internal.h | 5 ++---
 libavfilter/graphparser.c   | 3 ++-
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 8a2a9e0593..dc06ebab4d 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -159,7 +159,8 @@ int avfilter_link(AVFilterContext *src, unsigned srcpad,
 src->outputs[srcpad]  || dst->inputs[dstpad])
 return AVERROR(EINVAL);
 
-if (!fffilterctx(src)->initialized || !fffilterctx(dst)->initialized) {
+if (!(fffilterctx(src)->state_flags & AV_CLASS_STATE_INITIALIZED) ||
+!(fffilterctx(dst)->state_flags & AV_CLASS_STATE_INITIALIZED)) {
 av_log(src, AV_LOG_ERROR, "Filters must be initialized before 
linking.\n");
 return AVERROR(EINVAL);
 }
@@ -676,6 +677,7 @@ static const AVClass avfilter_class = {
 .child_next = filter_child_next,
 .child_class_iterate = filter_child_class_iterate,
 .option   = avfilter_options,
+.state_flags_offset = offsetof(FFFilterContext, state_flags),
 };
 
 static int default_execute(AVFilterContext *ctx, avfilter_action_func *func, 
void *arg,
@@ -909,7 +911,7 @@ int avfilter_init_dict(AVFilterContext *ctx, AVDictionary 
**options)
 FFFilterContext *ctxi = fffilterctx(ctx);
 int ret = 0;
 
-if (ctxi->initialized) {
+if (ctxi->state_flags & AV_CLASS_STATE_INITIALIZED) {
 av_log(ctx, AV_LOG_ERROR, "Filter already initialized\n");
 return AVERROR(EINVAL);
 }
@@ -940,7 +942,7 @@ int avfilter_init_dict(AVFilterContext *ctx, AVDictionary 
**options)
 return ret;
 }
 
-ctxi->initialized = 1;
+ctxi->state_flags |= AV_CLASS_STATE_INITIALIZED;
 
 return 0;
 }
diff --git a/libavfilter/avfilter_internal.h b/libavfilter/avfilter_internal.h
index ec3933b1d1..9ba890a70c 100644
--- a/libavfilter/avfilter_internal.h
+++ b/libavfilter/avfilter_internal.h
@@ -100,9 +100,8 @@ typedef struct FFFilterContext {
 
 avfilter_execute_func *execute;
 
-// 1 when avfilter_init_*() was successfully called on this filter
-// 0 otherwise
-int initialized;
+// AV_CLASS_STATE_FLAG_*
+unsigned state_flags;
 } FFFilterContext;
 
 static inline FFFilterContext *fffilterctx(AVFilterContext *ctx)
diff --git a/libavfilter/graphparser.c b/libavfilter/graphparser.c
index 912804ecd6..a23e26d2e3 100644
--- a/libavfilter/graphparser.c
+++ b/libavfilter/graphparser.c
@@ -627,7 +627,8 @@ int avfilter_graph_segment_init(AVFilterGraphSegment *seg, 
int flags)
 
 if (p->filter_name)
 return fail_creation_pending(seg, p->filter_name, __func__);
-if (!p->filter || fffilterctx(p->filter)->initialized)
+if (!p->filter ||
+(fffilterctx(p->filter)->state_flags & 
AV_CLASS_STATE_INITIALIZED))
 continue;
 
 ret = avfilter_init_dict(p->filter, NULL);
-- 
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 v4] avcodec/riscv: add h264 qpel

2024-09-28 Thread Rémi Denis-Courmont
LGTM!
___
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/14] swscale/range_convert: fix mpeg ranges in yuv range conversion for non-8-bit pixel formats

2024-09-28 Thread Ramiro Polla
Hi Christophe,

On Sat, Sep 28, 2024 at 3:21 PM Christophe Gisquet
 wrote:
> Le lun. 23 sept. 2024 à 16:19, Ramiro Polla  a écrit :
> > For bit depths <= 14, amax is 16-bit and offset is 32-bit.
> > For bit depths > 14, amax is 32-bit and offset is 64-bit.
>
> [...]
>
> > -static void chrRangeToJpeg_c(int16_t *dstU, int16_t *dstV, int width)
> > +static void chrRangeToJpeg_c(int16_t *dstU, int16_t *dstV, int width,
> > + int amax, int coeff, int64_t _offset)
> >  {
> > +int offset = _offset;
> >  int i;
> >  for (i = 0; i < width; i++) {
> > -dstU[i] = (FFMIN(dstU[i], 30775) * 4663 - 9289992) >> 12; // -264
> > -dstV[i] = (FFMIN(dstV[i], 30775) * 4663 - 9289992) >> 12; // -264
> > +dstU[i] = (FFMIN(dstU[i], amax) * coeff + offset) >> 14;
> > +dstV[i] = (FFMIN(dstV[i], amax) * coeff + offset) >> 14;
> >  }
> >  }
> >
> > -static void chrRangeFromJpeg_c(int16_t *dstU, int16_t *dstV, int width)
> > +static void chrRangeFromJpeg_c(int16_t *dstU, int16_t *dstV, int width,
> > +   int amax, int coeff, int64_t _offset)
> >  {
> > +int offset = _offset;
> >  int i;
> >  for (i = 0; i < width; i++) {
> > -dstU[i] = (dstU[i] * 1799 + 4081085) >> 11; // 1469
> > -dstV[i] = (dstV[i] * 1799 + 4081085) >> 11; // 1469
> > +dstU[i] = (dstU[i] * coeff + offset) >> 14;
> > +dstV[i] = (dstV[i] * coeff + offset) >> 14;
> >  }
> >  }
> >
> > -static void lumRangeToJpeg_c(int16_t *dst, int width)
> > +static void lumRangeToJpeg_c(int16_t *dst, int width,
> > + int amax, int coeff, int64_t _offset)
> >  {
> > +int offset = _offset;
> >  int i;
> >  for (i = 0; i < width; i++)
> > -dst[i] = (FFMIN(dst[i], 30189) * 19077 - 39057361) >> 14;
> > +dst[i] = (FFMIN(dst[i], amax) * coeff + offset) >> 14;
> >  }
>
> I'm a bit surprised by some of these formulas and the range you assert
> above. Somehow you make it clear by casting the offset parameters to
> narrower types, so all of the following is a non-issue.
>
> So, maybe some cases are special and so on, and you are working within
> some API constrain, but the code excerpts bother me a bit:
> * If dst as input is 16 bits, I don't see why amax would really be an
> int (except native integer etc)
> * If dst[i] = anything >> 14, with dst[i] 16 bits, you want "anything"
> to be at most of 30 bits of dynamics. offset doesn't sound like it
> could be of a wider range, and not 64 bits.
> * Any version that does treat things as 64 bits computations, will
> essentially halve the likely throughput of the SIMD, besides
> potentially using way slower computations and restricting these to
> fewer archs.
>
> I expect you know that, but I'd have expected an intermediate type of
> functions with parameters eg '(int16_t *dst, int width, int16_t amax,
> int16_t coeff, int32_t _offset)'
> Maybe to avoid issues with the weird Win ABI where the MSBs can be
> garbage, that can indeed be '(int16_t *dst, ptrdiff_t width, int amax,
> int16_t coeff, int32_t _offset)'.

I think you missed that the internal representation (the contents of
dst) is 15 bits for bit_depth <= 14, and 19 bits for bit_depth > 14.
It is confusing, but when I say bit depths > 14, I mean input bit
depths > 14, which have an internal representation of 19 bits (and
therefore the contents of dst are int32_t). Look at chrRangeToJpeg16_c
for example.

For bit depth > 14, I had to raise the precision of the calculation in
order to respect the mpeg range. In this case, the shift is 18 bits
instead of 14, and the offset becomes greater than 32 bits.

These are the actual values calculated for each case (hopefully my
mail client doesn't mangle them):
lum from  8 coeff  14071 (0x0036f7) offset 33553280 ( 0x0001fffb80)
chr from  8 coeff  14393 (0x003839) offset 33528960 ( 0x0001ff9c80)
lum to8 coeff  19078 (0x004a86) offset-39092480 (-0x0002548100)
chr to8 coeff  18652 (0x0048dc) offset-38215680 (-0x0002472000)
lum from 10 coeff  14030 (0x0036ce) offset 33544640 ( 0x0001ffd9c0)
chr from 10 coeff  14350 (0x00380e) offset 33554880 ( 0x00020001c0)
lum to   10 coeff  19134 (0x004abe) offset-39204096 (-0x0002563500)
chr to   10 coeff  18707 (0x004913) offset-38332416 (-0x000248e800)
lum from 12 coeff  14020 (0x0036c4) offset 33535520 ( 0x0001ffb620)
chr from 12 coeff  14340 (0x003804) offset 33538080 ( 0x0001ffc020)
lum to   12 coeff  19148 (0x004acc) offset-39232000 (-0x000256a200)
chr to   12 coeff  18720 (0x004920) offset-38338560 (-0x000249)
lum from 14 coeff  14017 (0x0036c1) offset 33549698 ( 0x0001ffed82)
chr from 14 coeff  14337 (0x003801) offset 33550338 ( 0x0001fff002)
lum to   14 coeff  19151 (0x004acf) offset-39223936 (-0x0002568280)
chr to   14 coeff  18723 (0x004923) offset-38332416 (-0x000248e800)
lum from 16 coeff 224260 (0x036c04) offset   8589631520 ( 0x01

Re: [FFmpeg-devel] [PATCH v9 1/6] libavcodec/: Add ID and desc for DNxUncompressed

2024-09-28 Thread Michael Niedermayer
On Mon, Sep 23, 2024 at 11:16:42AM +0200, Martin Schitter wrote:
> Patchset for DNxUncomprressed decoder.
> 
> v9 includes changes to fix issues mentioned in Marton Balints review.
> 
> ---
>  libavcodec/codec_desc.c | 7 +++
>  libavcodec/codec_id.h   | 1 +
>  libavcodec/version.c| 2 +-
>  3 files changed, 9 insertions(+), 1 deletion(-)

I intend to apply this patchset after the release if i see no further comments
(and if i dont see any major issues when i look at it, which i did not yet)
that said if someone applies it before me, thats even better

thx

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

The smallest minority on earth is the individual. Those who deny 
individual rights cannot claim to be defenders of minorities. - Ayn Rand


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 02/10] MAINTAINERS: aacdec seems unmaintained, aacdec_usac seems maintained by Lynne

2024-09-28 Thread Michael Niedermayer
On Sat, Sep 28, 2024 at 06:00:11AM +0200, Lynne via ffmpeg-devel wrote:
> On 22/09/2024 23:56, Michael Niedermayer wrote:
> > CC: Lynne 
> > Signed-off-by: Michael Niedermayer 
> > ---
> >   MAINTAINERS | 2 ++
> >   1 file changed, 2 insertions(+)
> > 
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index 5b6fbfdc48d..882ecae1d32 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -146,6 +146,8 @@ Codecs:
> > 4xm.c [2] Michael Niedermayer
> > 8bps.cRoberto Togni
> > 8svx.cJaikrishnan Menon
> > +  aacdec*   [0]
> > +  aacdec_usac*  Lynne
> > aacenc*, aaccoder.c   Rostislav Pehlivanov
> > adpcm.c   Zane van Iperen
> > alacenc.c Jaikrishnan Menon
> 
> I pretty much rewrote aacdec while refactoring, I maintain it.

prefect, great, please update the entry in MAINTAINERS

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Those who are too smart to engage in politics are punished by being
governed by those who are dumber. -- Plato 


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 v6 4/5] libavcodec/dnxucdec: DNxUncompressed decoder

2024-09-28 Thread Michael Niedermayer
On Sat, Sep 28, 2024 at 12:35:13PM +0200, martin schitter wrote:
> I know, you are all busy with 7.1 release cleanup, but could you please take
> another look at my DNxUncompressed patches and merge them.
> 
> I always fixed the change requests reported by reviewers within 24 hours,
> and most of them were in fact really trivial and of cosmetic nature anyway,
> but in the meanwhile a few weeks passed by and my contribution is still not
> merged! :(

make sure you add yourself to the MAINTAINER file, so once it is merged
you would then be less dependant on other people having time

thx

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

Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle


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 1/2] avformat/internal: Add ff_get_frame_filename

2024-09-28 Thread Michael Niedermayer
On Mon, Sep 23, 2024 at 11:14:19PM +0800, Zhao Zhili wrote:
> From: Zhao Zhili 
> 
> It's similar to av_get_frame_filename2 but with int64_t number
> support. Make av_get_frame_filename* a wrapper over
> ff_get_frame_filename.
> 
> Co-authored-by: Filip Mašić 
> ---
>  libavformat/internal.h | 16 
>  libavformat/utils.c| 11 ---
>  2 files changed, 24 insertions(+), 3 deletions(-)

probably ok

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

The educated differ from the uneducated as much as the living from the
dead. -- Aristotle 


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 2/2] avformat/img2enc: Fix integer truncation when frame_pts is enabled

2024-09-28 Thread Michael Niedermayer
On Tue, Sep 24, 2024 at 12:16:13AM +0800, Zhao Zhili wrote:
> From: Zhao Zhili 
> 
> ---
>  libavformat/img2enc.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)

probably ok

thx

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

"Nothing to hide" only works if the folks in power share the values of
you and everyone you know entirely and always will -- Tom Scott



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 1/2] avformat/internal: Add ff_get_frame_filename

2024-09-28 Thread Michael Niedermayer
On Tue, Sep 24, 2024 at 06:15:57PM +0100, Filip Mašić wrote:
> On Mon, 23 Sept 2024 at 16:14, Zhao Zhili  wrote:
> 
> > From: Zhao Zhili 
> >
> > It's similar to av_get_frame_filename2 but with int64_t number
> > support. Make av_get_frame_filename* a wrapper over
> > ff_get_frame_filename.
> >
> > Co-authored-by: Filip Mašić 
> > ---
> >  libavformat/internal.h | 16 
> >  libavformat/utils.c| 11 ---
> >  2 files changed, 24 insertions(+), 3 deletions(-)
> >
> > diff --git a/libavformat/internal.h b/libavformat/internal.h
> > index 8e8971bfeb..6c026f08a0 100644
> > --- a/libavformat/internal.h
> > +++ b/libavformat/internal.h
> > @@ -745,6 +745,22 @@ void ff_format_set_url(AVFormatContext *s, char *url);
> >   */
> >  int ff_match_url_ext(const char *url, const char *extensions);
> >
> > +/**
> > + * Return in 'buf' the path with '%d' replaced by a number.
> > + *
> > + * Also handles the '%0nd' format where 'n' is the total number
> > + * of digits and '%%'.
> > + *
> > + * @param buf destination buffer
> > + * @param buf_size destination buffer size
> > + * @param path path with substitution template
> > + * @param number the number to substitute
> > + * @param flags AV_FRAME_FILENAME_FLAGS_*
> > + * @return 0 if OK, -1 on format error
> > + */
> > +int ff_get_frame_filename(char *buf, int buf_size, const char *path,
> > +  int64_t number, int flags);
> > +
> >  struct FFOutputFormat;
> >  struct FFInputFormat;
> >  void avpriv_register_devices(const struct FFOutputFormat * const o[],
> > diff --git a/libavformat/utils.c b/libavformat/utils.c
> > index e9ded627ad..e892e8bde7 100644
> > --- a/libavformat/utils.c
> > +++ b/libavformat/utils.c
> > @@ -280,7 +280,7 @@ uint64_t ff_parse_ntp_time(uint64_t ntp_ts)
> >  return (sec * 100) + usec;
> >  }
> >
> > -int av_get_frame_filename2(char *buf, int buf_size, const char *path, int
> > number, int flags)
> > +int ff_get_frame_filename(char *buf, int buf_size, const char *path,
> > int64_t number, int flags)
> >  {
> >  const char *p;
> >  char *q, buf1[20], c;
> > @@ -313,7 +313,7 @@ int av_get_frame_filename2(char *buf, int buf_size,
> > const char *path, int number
> >  percentd_found = 1;
> >  if (number < 0)
> >  nd += 1;
> > -snprintf(buf1, sizeof(buf1), "%0*d", nd, number);
> > +snprintf(buf1, sizeof(buf1), "%0*" PRId64, nd, number);
> >  len = strlen(buf1);
> >  if ((q - buf + len) > buf_size - 1)
> >  goto fail;
> > @@ -338,9 +338,14 @@ fail:
> >  return -1;
> >  }
> >
> > +int av_get_frame_filename2(char *buf, int buf_size, const char *path, int
> > number, int flags)
> > +{
> > +return ff_get_frame_filename(buf, buf_size, path, number, flags);
> > +}
> > +
> >  int av_get_frame_filename(char *buf, int buf_size, const char *path, int
> > number)
> >  {
> > -return av_get_frame_filename2(buf, buf_size, path, number, 0);
> > +return ff_get_frame_filename(buf, buf_size, path, number, 0);
> >  }
> >
> >  void av_url_split(char *proto, int proto_size,
> > --
> > 2.42.0
> 
> 
> So if I understand correctly, since there's no API change, this will be
> merged in some version 7.1.1?

maybe


> When will this version be released?

at some point after 7.1

thx

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

He who knows, does not speak. He who speaks, does not know. -- Lao Tsu


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] [RFC] 7.1 Release

2024-09-28 Thread Michael Niedermayer
On Tue, Sep 24, 2024 at 05:47:54PM +0200, Michael Niedermayer wrote:
> On Wed, Aug 14, 2024 at 02:41:55PM +0200, Michael Niedermayer wrote:
> > Hi all
> > 
> > Are there any upcoming LTS releases that want to/could include FFmpeg 7.1 ?
> > If so please reply here and list the date before which we would have to
> > finish the 7.1 release so it can be included with no problems
> > 
> > Otherwise, are there any preferrances of the general/approximate release 
> > date?
> 
> all blocking issues where closed, excpet one long standing one, so
> 
> release/7.1 Branch finally made
> 
> I intend to make the 7.1 release from that branch within a week!

I intend to make the 7.1 release in the next 48h or so, maybe tomorrow
(could be delayed if something unxpected happens of course)


thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I am the wisest man alive, for I know one thing, and that is that I know
nothing. -- Socrates


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


[FFmpeg-devel] [PATCH 4/9] fftools/ffmpeg_mux: move OutputStream.enc_ctx to Encoder

2024-09-28 Thread Anton Khirnov
The encoding AVCodecContext is a part of the encoder, and so should live
there.
---
 fftools/ffmpeg.c  |  6 ++--
 fftools/ffmpeg.h  |  3 +-
 fftools/ffmpeg_enc.c  | 33 ++--
 fftools/ffmpeg_mux.c  |  8 ++---
 fftools/ffmpeg_mux_init.c | 66 ++-
 5 files changed, 62 insertions(+), 54 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 420ba3c6e4..dc321fb4a2 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -728,7 +728,7 @@ static void print_stream_maps(void)
 av_log(NULL, AV_LOG_INFO, " (graph %d)", 
ost->filter->graph->index);
 
 av_log(NULL, AV_LOG_INFO, " -> Stream #%d:%d (%s)\n", 
ost->file->index,
-   ost->index, ost->enc_ctx->codec->name);
+   ost->index, ost->enc->enc_ctx->codec->name);
 continue;
 }
 
@@ -737,9 +737,9 @@ static void print_stream_maps(void)
ost->ist->index,
ost->file->index,
ost->index);
-if (ost->enc_ctx) {
+if (ost->enc) {
 const AVCodec *in_codec= ost->ist->dec;
-const AVCodec *out_codec   = ost->enc_ctx->codec;
+const AVCodec *out_codec   = ost->enc->enc_ctx->codec;
 const char *decoder_name   = "?";
 const char *in_codec_name  = "?";
 const char *encoder_name   = "?";
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 9aeb217e73..c796de19f5 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -572,6 +572,8 @@ typedef struct KeyframeForceCtx {
 typedef struct Encoder {
 const AVClass  *class;
 
+AVCodecContext *enc_ctx;
+
 // number of frames/samples sent to the encoder
 uint64_tframes_encoded;
 uint64_tsamples_encoded;
@@ -602,7 +604,6 @@ typedef struct OutputStream {
 AVStream *st;/* stream in the output file */
 
 Encoder *enc;
-AVCodecContext *enc_ctx;
 
 /* video only */
 #if FFMPEG_OPT_TOP
diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c
index c8623ed343..a46af4dce1 100644
--- a/fftools/ffmpeg_enc.c
+++ b/fftools/ffmpeg_enc.c
@@ -75,6 +75,10 @@ void enc_free(Encoder **penc)
 if (!enc)
 return;
 
+if (enc->enc_ctx)
+av_freep(&enc->enc_ctx->stats_in);
+avcodec_free_context(&enc->enc_ctx);
+
 av_freep(penc);
 }
 
@@ -96,6 +100,7 @@ int enc_alloc(Encoder **penc, const AVCodec *codec,
   Scheduler *sch, unsigned sch_idx, void *log_parent)
 {
 EncoderPriv *ep;
+int ret = 0;
 
 *penc = NULL;
 
@@ -111,9 +116,18 @@ int enc_alloc(Encoder **penc, const AVCodec *codec,
 
 snprintf(ep->log_name, sizeof(ep->log_name), "enc:%s", codec->name);
 
+ep->e.enc_ctx = avcodec_alloc_context3(codec);
+if (!ep->e.enc_ctx) {
+ret = AVERROR(ENOMEM);
+goto fail;
+}
+
 *penc = &ep->e;
 
 return 0;
+fail:
+enc_free((Encoder**)&ep);
+return ret;
 }
 
 static int hw_device_setup_for_encode(Encoder *e, AVCodecContext *enc_ctx,
@@ -173,7 +187,7 @@ int enc_open(void *opaque, const AVFrame *frame)
 InputStream *ist = ost->ist;
 Encoder  *e = ost->enc;
 EncoderPriv *ep = ep_from_enc(e);
-AVCodecContext *enc_ctx = ost->enc_ctx;
+AVCodecContext *enc_ctx = e->enc_ctx;
 Decoder*dec = NULL;
 const AVCodec  *enc = enc_ctx->codec;
 OutputFile  *of = ost->file;
@@ -372,7 +386,7 @@ static int do_subtitle_out(OutputFile *of, OutputStream 
*ost, const AVSubtitle *
 if ((of->start_time != AV_NOPTS_VALUE && sub->pts < of->start_time))
 return 0;
 
-enc = ost->enc_ctx;
+enc = e->enc_ctx;
 
 /* Note: DVB subtitle need one packet to draw them and one other
packet to clear them */
@@ -524,10 +538,11 @@ static inline double psnr(double d)
 
 static int update_video_stats(OutputStream *ost, const AVPacket *pkt, int 
write_vstats)
 {
-EncoderPriv   *ep = ep_from_enc(ost->enc);
+Encoder*e = ost->enc;
+EncoderPriv   *ep = ep_from_enc(e);
 const uint8_t *sd = av_packet_get_side_data(pkt, AV_PKT_DATA_QUALITY_STATS,
 NULL);
-AVCodecContext *enc = ost->enc_ctx;
+AVCodecContext *enc = e->enc_ctx;
 enum AVPictureType pict_type;
 int64_t frame_number;
 double ti1, bitrate, avg_bitrate;
@@ -591,7 +606,7 @@ static int encode_frame(OutputFile *of, OutputStream *ost, 
AVFrame *frame,
 {
 Encoder*e = ost->enc;
 EncoderPriv   *ep = ep_from_enc(e);
-AVCodecContext   *enc = ost->enc_ctx;
+AVCodecContext   *enc = e->enc_ctx;
 const char *type_desc = av_get_media_type_string(enc->codec_type);
 const char*action = frame ? "encode" : "flush";
 int ret;
@@ -775,7 +790,7 @@ static int frame_encode(OutputStream *ost, AVFrame *frame, 
AVPacket *pkt)
 return AVERROR_EOF;
 

[FFmpeg-devel] [PATCH 1/9] fftools/ffmpeg_demux: drop InputStream.[nb_]outputs

2024-09-28 Thread Anton Khirnov
It is write-only after d119ae2fd82a494d9430ff4d4fc262961a68c598.
---
 fftools/ffmpeg.h   | 8 
 fftools/ffmpeg_demux.c | 7 ---
 2 files changed, 15 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index b5c95439e5..13e0fd14cd 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -463,14 +463,6 @@ typedef struct InputStream {
  * currently video and audio only */
 InputFilter **filters;
 intnb_filters;
-
-/*
- * Output targets that do not go through lavfi, i.e. subtitles or
- * streamcopy. Those two cases are distinguished by the OutputStream
- * having an encoder or not.
- */
-struct OutputStream **outputs;
-intnb_outputs;
 } InputStream;
 
 typedef struct InputFile {
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index 13aef15eab..9a3ae67e3a 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -840,7 +840,6 @@ static void ist_free(InputStream **pist)
 
 av_dict_free(&ds->decoder_opts);
 av_freep(&ist->filters);
-av_freep(&ist->outputs);
 av_freep(&ds->dec_opts.hwaccel_device);
 
 avcodec_parameters_free(&ist->par);
@@ -985,12 +984,6 @@ int ist_output_add(InputStream *ist, OutputStream *ost)
 if (ret < 0)
 return ret;
 
-ret = GROW_ARRAY(ist->outputs, ist->nb_outputs);
-if (ret < 0)
-return ret;
-
-ist->outputs[ist->nb_outputs - 1] = ost;
-
 return ost->enc ? ds->sch_idx_dec : ds->sch_idx_stream;
 }
 
-- 
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 2/9] fftools/ffmpeg_demux: drop ist_output_add()

2024-09-28 Thread Anton Khirnov
It is now a trivial wrapper over ist_use(), so export that directly.
---
 fftools/ffmpeg.h  |  3 ++-
 fftools/ffmpeg_demux.c| 17 ++---
 fftools/ffmpeg_mux_init.c | 17 +
 3 files changed, 13 insertions(+), 24 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 13e0fd14cd..d12b0e0d88 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -870,7 +870,8 @@ int64_t of_filesize(OutputFile *of);
 int ifile_open(const OptionsContext *o, const char *filename, Scheduler *sch);
 void ifile_close(InputFile **f);
 
-int ist_output_add(InputStream *ist, OutputStream *ost);
+int ist_use(InputStream *ist, int decoding_needed,
+const ViewSpecifier *vs, SchedulerNode *src);
 int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple,
const ViewSpecifier *vs, InputFilterOptions *opts,
SchedulerNode *src);
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index 9a3ae67e3a..364f148f60 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -873,8 +873,8 @@ void ifile_close(InputFile **pf)
 av_freep(pf);
 }
 
-static int ist_use(InputStream *ist, int decoding_needed,
-   const ViewSpecifier *vs, SchedulerNode *src)
+int ist_use(InputStream *ist, int decoding_needed,
+const ViewSpecifier *vs, SchedulerNode *src)
 {
 Demuxer  *d = demuxer_from_ifile(ist->file);
 DemuxStream *ds = ds_from_ist(ist);
@@ -974,19 +974,6 @@ static int ist_use(InputStream *ist, int decoding_needed,
 return 0;
 }
 
-int ist_output_add(InputStream *ist, OutputStream *ost)
-{
-DemuxStream *ds = ds_from_ist(ist);
-SchedulerNode src;
-int ret;
-
-ret = ist_use(ist, ost->enc ? DECODING_FOR_OST : 0, NULL, &src);
-if (ret < 0)
-return ret;
-
-return ost->enc ? ds->sch_idx_dec : ds->sch_idx_stream;
-}
-
 int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple,
const ViewSpecifier *vs, InputFilterOptions *opts,
SchedulerNode *src)
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index ec9f328e90..2541be59da 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -1537,18 +1537,19 @@ static int ost_add(Muxer *mux, const OptionsContext *o, 
enum AVMediaType type,
 if (ret < 0)
 goto fail;
 } else if (ost->ist) {
-int sched_idx = ist_output_add(ost->ist, ost);
-if (sched_idx < 0) {
+SchedulerNode src;
+
+ret = ist_use(ost->ist, !!ost->enc, NULL, &src);
+if (ret < 0) {
 av_log(ost, AV_LOG_ERROR,
"Error binding an input stream\n");
-ret = sched_idx;
 goto fail;
 }
-ms->sch_idx_src = sched_idx;
+ms->sch_idx_src = src.idx;
 
 if (ost->enc) {
-ret = sch_connect(mux->sch, SCH_DEC_OUT(sched_idx, 0),
-SCH_ENC(ms->sch_idx_enc));
+ret = sch_connect(mux->sch,
+  src, SCH_ENC(ms->sch_idx_enc));
 if (ret < 0)
 goto fail;
 
@@ -1557,8 +1558,8 @@ static int ost_add(Muxer *mux, const OptionsContext *o, 
enum AVMediaType type,
 if (ret < 0)
 goto fail;
 } else {
-ret = sch_connect(mux->sch, SCH_DSTREAM(ost->ist->file->index, 
sched_idx),
-SCH_MSTREAM(ost->file->index, 
ms->sch_idx));
+ret = sch_connect(mux->sch,
+  src, SCH_MSTREAM(ost->file->index, ms->sch_idx));
 if (ret < 0)
 goto fail;
 }
-- 
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/9] fftools/ffmpeg: drop unused OSTFinished

2024-09-28 Thread Anton Khirnov
---
 fftools/ffmpeg.h | 5 -
 1 file changed, 5 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index c796de19f5..0f5809b752 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -541,11 +541,6 @@ typedef struct EncStats {
 
 extern const char *const forced_keyframes_const_names[];
 
-typedef enum {
-ENCODER_FINISHED = 1,
-MUXER_FINISHED = 2,
-} OSTFinished ;
-
 enum {
 KF_FORCE_SOURCE = 1,
 #if FFMPEG_OPT_FORCE_KF_SOURCE_NO_DROP
-- 
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/9] fftools/ffmpeg_mux_init: do not export forced_keyframes_const_names[]

2024-09-28 Thread Anton Khirnov
It is only used in this file.
---
 fftools/ffmpeg.h  | 2 --
 fftools/ffmpeg_mux_init.c | 2 +-
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 0f5809b752..9439be0f41 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -539,8 +539,6 @@ typedef struct EncStats {
 int lock_initialized;
 } EncStats;
 
-extern const char *const forced_keyframes_const_names[];
-
 enum {
 KF_FORCE_SOURCE = 1,
 #if FFMPEG_OPT_FORCE_KF_SOURCE_NO_DROP
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 033fa6aba8..117b1a4338 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -3087,7 +3087,7 @@ finish:
 return ret;
 }
 
-const char *const forced_keyframes_const_names[] = {
+static const char *const forced_keyframes_const_names[] = {
 "n",
 "n_forced",
 "prev_forced_n",
-- 
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/9] fftools/ffmpeg_enc: split Encoder into a private and public part

2024-09-28 Thread Anton Khirnov
Similar to what was previously done for other components, e.g. decoders
(see 3b84140a1bb5a5b3044915888a40a7b619921633).

Start by moving {samples,frames}_encoded into the public struct.
---
 fftools/ffmpeg.h | 11 +++---
 fftools/ffmpeg_enc.c | 86 +---
 fftools/ffmpeg_mux.c |  4 +--
 3 files changed, 58 insertions(+), 43 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index d12b0e0d88..9aeb217e73 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -569,7 +569,13 @@ typedef struct KeyframeForceCtx {
 int  dropped_keyframe;
 } KeyframeForceCtx;
 
-typedef struct Encoder Encoder;
+typedef struct Encoder {
+const AVClass  *class;
+
+// number of frames/samples sent to the encoder
+uint64_tframes_encoded;
+uint64_tsamples_encoded;
+} Encoder;
 
 enum CroppingType {
 CROP_DISABLED = 0,
@@ -621,9 +627,6 @@ typedef struct OutputStream {
 /* stats */
 // number of packets send to the muxer
 atomic_uint_least64_t packets_written;
-// number of frames/samples sent to the encoder
-uint64_t frames_encoded;
-uint64_t samples_encoded;
 
 /* packet quality factor */
 atomic_int quality;
diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c
index 4b3efb8db1..c8623ed343 100644
--- a/fftools/ffmpeg_enc.c
+++ b/fftools/ffmpeg_enc.c
@@ -38,8 +38,9 @@
 
 #include "libavcodec/avcodec.h"
 
-struct Encoder {
-const AVClass *class;
+typedef struct EncoderPriv {
+Encodere;
+
 void  *log_parent;
 char   log_name[32];
 
@@ -54,7 +55,12 @@ struct Encoder {
 
 Scheduler  *sch;
 unsignedsch_idx;
-};
+} EncoderPriv;
+
+static EncoderPriv *ep_from_enc(Encoder *enc)
+{
+return (EncoderPriv*)enc;
+}
 
 // data that is local to the decoder thread and not visible outside of it
 typedef struct EncoderThread {
@@ -74,38 +80,38 @@ void enc_free(Encoder **penc)
 
 static const char *enc_item_name(void *obj)
 {
-const Encoder *e = obj;
+const EncoderPriv *ep = obj;
 
-return e->log_name;
+return ep->log_name;
 }
 
 static const AVClass enc_class = {
 .class_name= "Encoder",
 .version   = LIBAVUTIL_VERSION_INT,
-.parent_log_context_offset = offsetof(Encoder, log_parent),
+.parent_log_context_offset = offsetof(EncoderPriv, log_parent),
 .item_name = enc_item_name,
 };
 
 int enc_alloc(Encoder **penc, const AVCodec *codec,
   Scheduler *sch, unsigned sch_idx, void *log_parent)
 {
-Encoder *enc;
+EncoderPriv *ep;
 
 *penc = NULL;
 
-enc = av_mallocz(sizeof(*enc));
-if (!enc)
+ep = av_mallocz(sizeof(*ep));
+if (!ep)
 return AVERROR(ENOMEM);
 
-enc->class  = &enc_class;
-enc->log_parent = log_parent;
+ep->e.class= &enc_class;
+ep->log_parent = log_parent;
 
-enc->sch = sch;
-enc->sch_idx = sch_idx;
+ep->sch = sch;
+ep->sch_idx = sch_idx;
 
-snprintf(enc->log_name, sizeof(enc->log_name), "enc:%s", codec->name);
+snprintf(ep->log_name, sizeof(ep->log_name), "enc:%s", codec->name);
 
-*penc = enc;
+*penc = &ep->e;
 
 return 0;
 }
@@ -166,6 +172,7 @@ int enc_open(void *opaque, const AVFrame *frame)
 OutputStream *ost = opaque;
 InputStream *ist = ost->ist;
 Encoder  *e = ost->enc;
+EncoderPriv *ep = ep_from_enc(e);
 AVCodecContext *enc_ctx = ost->enc_ctx;
 Decoder*dec = NULL;
 const AVCodec  *enc = enc_ctx->codec;
@@ -174,7 +181,7 @@ int enc_open(void *opaque, const AVFrame *frame)
 int frame_samples = 0;
 int ret;
 
-if (e->opened)
+if (ep->opened)
 return 0;
 
 // frame is always non-NULL for audio and video
@@ -320,7 +327,7 @@ int enc_open(void *opaque, const AVFrame *frame)
 return ret;
 }
 
-e->opened = 1;
+ep->opened = 1;
 
 if (enc_ctx->frame_size)
 frame_samples = enc_ctx->frame_size;
@@ -352,6 +359,7 @@ static int do_subtitle_out(OutputFile *of, OutputStream 
*ost, const AVSubtitle *
AVPacket *pkt)
 {
 Encoder *e = ost->enc;
+EncoderPriv *ep = ep_from_enc(e);
 int subtitle_out_max_size = 1024 * 1024;
 int subtitle_out_size, nb, i, ret;
 AVCodecContext *enc;
@@ -403,7 +411,7 @@ static int do_subtitle_out(OutputFile *of, OutputStream 
*ost, const AVSubtitle *
 local_sub.rects += i;
 }
 
-ost->frames_encoded++;
+e->frames_encoded++;
 
 subtitle_out_size = avcodec_encode_subtitle(enc, pkt->data, pkt->size, 
&local_sub);
 if (subtitle_out_size < 0) {
@@ -425,7 +433,7 @@ static int do_subtitle_out(OutputFile *of, OutputStream 
*ost, const AVSubtitle *
 }
 pkt->dts = pkt->pts;
 
-ret = sch_enc_send(e->sch, e->sch_idx, pkt);
+ret = sch_enc_send(ep->sch, ep->sch_idx, pkt);
 

[FFmpeg-devel] [PATCH 7/9] fftools/ffmpeg_mux_init: move the check for filtering+streamcopy

2024-09-28 Thread Anton Khirnov
To streamcopy_init().

This will allow to simplify the control flow in ost_add() by moving the
ost_get_filters() call (which previously had to handle both encoding and
streamcopy streams) to ost_bind_filter() (which is only called for
audio/video encoding).

Also, return EINVAL rather than ENOSYS, as trying to combine filtering
with streamcopy is a parameter error.
---
 fftools/ffmpeg_mux_init.c | 52 ++-
 1 file changed, 29 insertions(+), 23 deletions(-)

diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 117b1a4338..1ddd1d7492 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -424,27 +424,6 @@ static int ost_get_filters(const OptionsContext *o, 
AVFormatContext *oc,
 #endif
 opt_match_per_stream_str(ost, &o->filters, oc, ost->st, &filters);
 
-if (!ost->enc) {
-if (
-#if FFMPEG_OPT_FILTER_SCRIPT
-filters_script ||
-#endif
-filters) {
-av_log(ost, AV_LOG_ERROR,
-   "%s '%s' was specified, but codec copy was selected. "
-   "Filtering and streamcopy cannot be used together.\n",
-#if FFMPEG_OPT_FILTER_SCRIPT
-   filters ? "Filtergraph" : "Filtergraph script",
-   filters ? filters : filters_script
-#else
-   "Filtergraph", filters
-#endif
-   );
-return AVERROR(ENOSYS);
-}
-return 0;
-}
-
 if (!ost->ist) {
 if (
 #if FFMPEG_OPT_FILTER_SCRIPT
@@ -1028,7 +1007,8 @@ ost_bind_filter(const Muxer *mux, MuxStream *ms, 
OutputFilter *ofilter,
 return ret;
 }
 
-static int streamcopy_init(const Muxer *mux, OutputStream *ost, AVDictionary 
**encoder_opts)
+static int streamcopy_init(const OptionsContext *o, const Muxer *mux,
+   OutputStream *ost, AVDictionary **encoder_opts)
 {
 MuxStream   *ms = ms_from_ost(ost);
 
@@ -1044,6 +1024,32 @@ static int streamcopy_init(const Muxer *mux, 
OutputStream *ost, AVDictionary **e
 
 int ret = 0;
 
+const char *filters = NULL;
+#if FFMPEG_OPT_FILTER_SCRIPT
+const char *filters_script = NULL;
+
+opt_match_per_stream_str(ost, &o->filter_scripts, mux->fc, ost->st, 
&filters_script);
+#endif
+opt_match_per_stream_str(ost, &o->filters, mux->fc, ost->st, &filters);
+
+if (
+#if FFMPEG_OPT_FILTER_SCRIPT
+filters_script ||
+#endif
+filters) {
+av_log(ost, AV_LOG_ERROR,
+   "%s '%s' was specified, but codec copy was selected. "
+   "Filtering and streamcopy cannot be used together.\n",
+#if FFMPEG_OPT_FILTER_SCRIPT
+   filters ? "Filtergraph" : "Filtergraph script",
+   filters ? filters : filters_script
+#else
+   "Filtergraph", filters
+#endif
+   );
+return AVERROR(EINVAL);
+}
+
 codec_ctx = avcodec_alloc_context3(NULL);
 if (!codec_ctx)
 return AVERROR(ENOMEM);
@@ -1562,7 +1568,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, 
enum AVMediaType type,
 }
 
 if (ost->ist && !ost->enc) {
-ret = streamcopy_init(mux, ost, &encoder_opts);
+ret = streamcopy_init(o, mux, ost, &encoder_opts);
 if (ret < 0)
 goto fail;
 }
-- 
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 9/9] fftools/ffmpeg_mux_init: consolidate connecting source to mux stream

2024-09-28 Thread Anton Khirnov
---
 fftools/ffmpeg_mux_init.c | 37 ++---
 1 file changed, 18 insertions(+), 19 deletions(-)

diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 50ce45ef1b..944176ca5d 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -899,7 +899,8 @@ ost_bind_filter(const Muxer *mux, MuxStream *ms, 
OutputFilter *ofilter,
 const OptionsContext *o,
 AVRational enc_tb, enum VideoSyncMethod vsync_method,
 int keep_pix_fmt, int autoscale, int threads_manual,
-const ViewSpecifier *vs)
+const ViewSpecifier *vs,
+SchedulerNode *src)
 {
 OutputStream   *ost = &ms->ost;
 AVCodecContext *enc_ctx = ost->enc->enc_ctx;
@@ -1005,12 +1006,9 @@ ost_bind_filter(const Muxer *mux, MuxStream *ms, 
OutputFilter *ofilter,
 if (ret < 0)
 return ret;
 
-ret = sch_connect(mux->sch, SCH_ENC(ms->sch_idx_enc),
-SCH_MSTREAM(mux->sch_idx, ms->sch_idx));
-if (ret < 0)
-return ret;
+*src = SCH_ENC(ms->sch_idx_enc);
 
-return ret;
+return 0;
 }
 
 static int streamcopy_init(const OptionsContext *o, const Muxer *mux,
@@ -1188,6 +1186,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, 
enum AVMediaType type,
 OutputStream *ost;
 const AVCodec *enc;
 AVStream *st;
+SchedulerNode src = { .type = SCH_NODE_TYPE_NONE };
 AVDictionary *encoder_opts = NULL;
 int ret = 0, keep_pix_fmt = 0, autoscale = 1;
 int threads_manual = 0;
@@ -1535,12 +1534,10 @@ static int ost_add(Muxer *mux, const OptionsContext *o, 
enum AVMediaType type,
 if (ost->enc &&
 (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) {
 ret = ost_bind_filter(mux, ms, ofilter, o, enc_tb, vsync_method,
-  keep_pix_fmt, autoscale, threads_manual, vs);
+  keep_pix_fmt, autoscale, threads_manual, vs, 
&src);
 if (ret < 0)
 goto fail;
 } else if (ost->ist) {
-SchedulerNode src;
-
 ret = ist_use(ost->ist, !!ost->enc, NULL, &src);
 if (ret < 0) {
 av_log(ost, AV_LOG_ERROR,
@@ -1549,24 +1546,26 @@ static int ost_add(Muxer *mux, const OptionsContext *o, 
enum AVMediaType type,
 }
 ms->sch_idx_src = src.idx;
 
+// src refers to a decoder for transcoding, demux stream otherwise
 if (ost->enc) {
 ret = sch_connect(mux->sch,
   src, SCH_ENC(ms->sch_idx_enc));
 if (ret < 0)
 goto fail;
-
-ret = sch_connect(mux->sch, SCH_ENC(ms->sch_idx_enc),
-SCH_MSTREAM(mux->sch_idx, 
ms->sch_idx));
-if (ret < 0)
-goto fail;
-} else {
-ret = sch_connect(mux->sch,
-  src, SCH_MSTREAM(ost->file->index, ms->sch_idx));
-if (ret < 0)
-goto fail;
+src = SCH_ENC(ms->sch_idx_enc);
 }
 }
 
+if (src.type != SCH_NODE_TYPE_NONE) {
+ret = sch_connect(mux->sch,
+  src, SCH_MSTREAM(mux->sch_idx, ms->sch_idx));
+if (ret < 0)
+goto fail;
+} else {
+// only attachment streams don't have a source
+av_assert0(type == AVMEDIA_TYPE_ATTACHMENT && ms->sch_idx < 0);
+}
+
 if (ost->ist && !ost->enc) {
 ret = streamcopy_init(o, mux, ost, &encoder_opts);
 if (ret < 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".


[FFmpeg-devel] [PATCH 8/9] fftools/ffmpeg_mux_init: move the ost_get_filters() call to ost_bind_filter()

2024-09-28 Thread Anton Khirnov
That is a more appropriate place for it.
---
 fftools/ffmpeg_mux_init.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 1ddd1d7492..50ce45ef1b 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -896,7 +896,7 @@ static int new_stream_subtitle(Muxer *mux, const 
OptionsContext *o,
 
 static int
 ost_bind_filter(const Muxer *mux, MuxStream *ms, OutputFilter *ofilter,
-const OptionsContext *o, char *filters,
+const OptionsContext *o,
 AVRational enc_tb, enum VideoSyncMethod vsync_method,
 int keep_pix_fmt, int autoscale, int threads_manual,
 const ViewSpecifier *vs)
@@ -904,6 +904,7 @@ ost_bind_filter(const Muxer *mux, MuxStream *ms, 
OutputFilter *ofilter,
 OutputStream   *ost = &ms->ost;
 AVCodecContext *enc_ctx = ost->enc->enc_ctx;
 char name[16];
+char *filters = NULL;
 int ret;
 
 OutputFilterOptions opts = {
@@ -985,7 +986,12 @@ ost_bind_filter(const Muxer *mux, MuxStream *ms, 
OutputFilter *ofilter,
 return ret;
 }
 
+ret = ost_get_filters(o, mux->fc, ost, &filters);
+if (ret < 0)
+return ret;
+
 if (ofilter) {
+av_assert0(!filters);
 ost->filter = ofilter;
 ret = ofilter_bind_enc(ofilter, ms->sch_idx_enc, &opts);
 } else {
@@ -1188,7 +1194,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, 
enum AVMediaType type,
 AVRational enc_tb = { 0, 0 };
 enum VideoSyncMethod vsync_method = VSYNC_AUTO;
 const char *bsfs = NULL, *time_base = NULL, *codec_tag = NULL;
-char *filters = NULL, *next;
+char  *next;
 double qscale = -1;
 
 st = avformat_new_stream(oc, NULL);
@@ -1526,15 +1532,9 @@ static int ost_add(Muxer *mux, const OptionsContext *o, 
enum AVMediaType type,
 if (ret < 0)
 goto fail;
 
-if (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO) {
-ret = ost_get_filters(o, oc, ost, &filters);
-if (ret < 0)
-goto fail;
-}
-
 if (ost->enc &&
 (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) {
-ret = ost_bind_filter(mux, ms, ofilter, o, filters, enc_tb, 
vsync_method,
+ret = ost_bind_filter(mux, ms, ofilter, o, enc_tb, vsync_method,
   keep_pix_fmt, autoscale, threads_manual, vs);
 if (ret < 0)
 goto fail;
-- 
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 2/2] lavc/vvc_mc: R-V V dmvr

2024-09-28 Thread uk7b
From: sunyuechi 

 k230   banana_f3
dmvr_8_12x20_c:   626.5 ( 1.00x)621.7 ( 1.00x)
dmvr_8_12x20_rvv_i32: 126.3 ( 4.96x)79.9 ( 7.78x)
dmvr_8_20x12_c:   608.0 ( 1.00x)652.9 ( 1.00x)
dmvr_8_20x12_rvv_i32: 135.5 ( 4.49x)90.4 ( 7.22x)
dmvr_8_20x20_c:  1006.0 ( 1.00x)1079.9 ( 1.00x)
dmvr_8_20x20_rvv_i32: 228.3 ( 4.41x)142.4 ( 7.58x)
dmvr_h_8_12x20_c:2005.8 ( 1.00x)2007.2 ( 1.00x)
dmvr_h_8_12x20_rvv_i32:   274.5 ( 7.31x)184.2 (10.90x)
dmvr_h_8_20x12_c:1987.5 ( 1.00x)2006.9 ( 1.00x)
dmvr_h_8_20x12_rvv_i32:   302.3 ( 6.58x)173.7 (11.56x)
dmvr_h_8_20x20_c:3302.3 ( 1.00x)3340.4 ( 1.00x)
dmvr_h_8_20x20_rvv_i32:   487.5 ( 6.77x)267.4 (12.49x)
dmvr_hv_8_12x20_c:   3607.8 ( 1.00x)3600.7 ( 1.00x)
dmvr_hv_8_12x20_rvv_i32:  459.8 ( 7.85x)371.7 ( 9.69x)
dmvr_hv_8_20x12_c:   3626.3 ( 1.00x)3621.7 ( 1.00x)
dmvr_hv_8_20x12_rvv_i32:  422.8 ( 8.58x)298.7 (12.13x)
dmvr_hv_8_20x20_c:   5931.8 ( 1.00x)5934.4 ( 1.00x)
dmvr_hv_8_20x20_rvv_i32:  672.5 ( 8.82x)475.9 (12.47x)
dmvr_v_8_12x20_c:2154.0 ( 1.00x)2152.9 ( 1.00x)
dmvr_v_8_12x20_rvv_i32:   274.5 ( 7.85x)183.9 (11.71x)
dmvr_v_8_20x12_c:2774.5 ( 1.00x)2152.9 ( 1.00x)
dmvr_v_8_20x12_rvv_i32:   302.3 ( 9.18x)173.7 (12.40x)
dmvr_v_8_20x20_c:3552.0 ( 1.00x)3590.4 ( 1.00x)
dmvr_v_8_20x20_rvv_i32:   487.5 ( 7.29x)267.4 (13.43x)
---
 libavcodec/riscv/vvc/vvc_mc_rvv.S  | 139 +
 libavcodec/riscv/vvc/vvcdsp_init.c |  22 +
 2 files changed, 161 insertions(+)

diff --git a/libavcodec/riscv/vvc/vvc_mc_rvv.S 
b/libavcodec/riscv/vvc/vvc_mc_rvv.S
index 18532616d9..61fe840c4d 100644
--- a/libavcodec/riscv/vvc/vvc_mc_rvv.S
+++ b/libavcodec/riscv/vvc/vvc_mc_rvv.S
@@ -285,3 +285,142 @@ endfunc
 func_w_avg 128
 func_w_avg 256
 #endif
+
+func dmvr zve32x, zbb, zba
+lpad0
+lit0, 4
+1:
+add   t1, a1, a2
+addi  t4, a0, 128*2
+add   t2, t1, a2
+addi  t5, a0, 128*2*2
+add   t3, t2, a2
+addi  t6, a0, 128*2*3
+vle8.vv0, (a1)
+vle8.vv4, (t1)
+vle8.vv8, (t2)
+vle8.vv12, (t3)
+addi  a3, a3, -4
+vwmulu.vx v16, v0, t0
+vwmulu.vx v20, v4, t0
+vwmulu.vx v24, v8, t0
+vwmulu.vx v28, v12, t0
+vse16.v   v16, (a0)
+vse16.v   v20, (t4)
+vse16.v   v24, (t5)
+vse16.v   v28, (t6)
+sh2adda1, a2, a1
+add   a0, a0, 128*2*4
+bnez  a3, 1b
+ret
+endfunc
+
+.macro dmvr_h_v mn, type
+lla   t4, ff_vvc_inter_luma_dmvr_filters
+sh1addt4, \mn, t4
+lbu   t5, (t4)
+lbu   t6, 1(t4)
+1:
+.ifc \type,h
+addi  t0, a1, 1
+addi  t1, a1, 2
+.else
+add   t0, a1, a2
+add   t1, t0, a2
+.endif
+vle8.vv0, (a1)
+vle8.vv4, (t0)
+vle8.vv8, (t1)
+addi  a3, a3, -2
+vzext.vf2 v12, v0
+vzext.vf2 v16, v4
+vzext.vf2 v20, v8
+addi  t2, a0, 128*2
+vmul.vx   v12, v12, t5
+vmul.vx   v24, v16, t5
+vmacc.vx  v12, t6, v16
+vmacc.vx  v24, t6, v20
+vssrl.vi  v12, v12, 2
+vssrl.vi  v24, v24, 2
+vse16.v   v12, (a0)
+vse16.v   v24, (t2)
+add   a0, a0, 128*4
+sh1adda1, a2, a1
+bnez  a3, 1b
+ret
+.endm
+
+func dmvr_h zve32x, zbb, zba
+lpad0
+dmvr_h_v a4, h
+endfunc
+
+func dmvr_v zve32x, zbb, zba
+lpad0
+dmvr_h_v a5, v
+endfunc
+
+.macro dmvr_load_h dst, filter0, filter1
+addi  a6, a1, 1
+vle8.v\dst, (a1)
+vle8.vv2, (a6)
+vzext.vf2 v4, \dst
+vzext.vf2 v8, v2
+vmul.vx   \dst, v4, \filter0
+vmacc.vx  \dst, \filter1, v8
+vssrl.vi  \dst, \dst, 2
+.endm
+
+func dmvr_hv zve32x, zbb, zba
+lpad0
+lla   t0, ff_vvc_inter_luma_dmvr_filters
+sh1addt1, a4, t0
+sh1a

Re: [FFmpeg-devel] [PATCH 2/2] lavc/vvc_mc: R-V V dmvr

2024-09-28 Thread flow gg
> Is 4x unroll really faster than 2x here? We don't typically unroll 4x
> manually.

I first did 2x and then changed it to 4x. The test results are similar, and
I'm not sure how to choose between them...

> t5 seems to be 8-bit, so vwmulu.vx should work better here? Since you
> leveraged it in the previous function, I'm a bit confused why not here,
TBH.
> Likewise vwmaccu.vx.

DMVR doesn't have right shifts, but DMVR_h, _v, and _hv do.
So DMVR only needs one vset, while the others, if using widen, require vset
switching.

> Missing rounding opportunity, vssra.vi should work better here.
> Same comments.

Okay, Updated it.

Rémi Denis-Courmont  于2024年9月28日周六 14:56写道:

> Hi,
>
> Le perjantaina 27. syyskuuta 2024, 20.09.30 EEST u...@foxmail.com a écrit
> :
> > From: sunyuechi 
> >
> >  k230   banana_f3
> > dmvr_8_12x20_c:   628.5 ( 1.00x)624.1 ( 1.00x)
> > dmvr_8_12x20_rvv_i32: 137.5 ( 4.57x)92.9 ( 6.72x)
> > dmvr_8_20x12_c:   609.7 ( 1.00x)655.4 ( 1.00x)
> > dmvr_8_20x12_rvv_i32: 146.7 ( 4.16x)82.4 ( 7.95x)
> > dmvr_8_20x20_c:   998.7 ( 1.00x)1092.9 ( 1.00x)
> > dmvr_8_20x20_rvv_i32: 221.0 ( 4.52x)144.9 ( 7.54x)
> > dmvr_h_8_12x20_c:2008.0 ( 1.00x)1999.2 ( 1.00x)
> > dmvr_h_8_12x20_rvv_i32:   285.7 ( 7.03x)207.4 ( 9.64x)
> > dmvr_h_8_20x12_c:1989.5 ( 1.00x)2009.7 ( 1.00x)
> > dmvr_h_8_20x12_rvv_i32:   322.7 ( 6.16x)176.2 (11.41x)
> > dmvr_h_8_20x20_c:3304.2 ( 1.00x)3342.9 ( 1.00x)
> > dmvr_h_8_20x20_rvv_i32:   526.5 ( 6.28x)290.6 (11.50x)
> > dmvr_hv_8_12x20_c:   3609.7 ( 1.00x)3603.4 ( 1.00x)
> > dmvr_hv_8_12x20_rvv_i32:  554.2 ( 6.51x)467.9 ( 7.70x)
> > dmvr_hv_8_20x12_c:   3637.5 ( 1.00x)3624.4 ( 1.00x)
> > dmvr_hv_8_20x12_rvv_i32:  489.5 ( 7.43x)342.6 (10.58x)
> > dmvr_hv_8_20x20_c:   6794.7 ( 1.00x)5936.9 ( 1.00x)
> > dmvr_hv_8_20x20_rvv_i32:  785.7 ( 8.65x)561.4 (10.58x)
> > dmvr_v_8_12x20_c:2156.0 ( 1.00x)2155.2 ( 1.00x)
> > dmvr_v_8_12x20_rvv_i32:   295.0 ( 7.31x)207.4 (10.39x)
> > dmvr_v_8_20x12_c:2137.5 ( 1.00x)2165.7 ( 1.00x)
> > dmvr_v_8_20x12_rvv_i32:   322.7 ( 6.62x)186.7 (11.60x)
> > dmvr_v_8_20x20_c:3554.2 ( 1.00x)3593.2 ( 1.00x)
> > dmvr_v_8_20x20_rvv_i32:   535.7 ( 6.63x)290.6 (12.36x)
> > ---
> >  libavcodec/riscv/vvc/vvc_mc_rvv.S  | 141 +
> >  libavcodec/riscv/vvc/vvcdsp_init.c |  22 +
> >  2 files changed, 163 insertions(+)
> >
> > diff --git a/libavcodec/riscv/vvc/vvc_mc_rvv.S
> > b/libavcodec/riscv/vvc/vvc_mc_rvv.S index 18532616d9..a5e20cbc67 100644
> > --- a/libavcodec/riscv/vvc/vvc_mc_rvv.S
> > +++ b/libavcodec/riscv/vvc/vvc_mc_rvv.S
> > @@ -285,3 +285,144 @@ endfunc
> >  func_w_avg 128
> >  func_w_avg 256
> >  #endif
> > +
> > +func dmvr zve32x, zbb, zba
> > +lpad0
> > +lit0, 4
> > +1:
> > +add   t1, a1, a2
> > +addi  t4, a0, 128*2
> > +add   t2, t1, a2
> > +addi  t5, a0, 128*2*2
> > +add   t3, t2, a2
> > +addi  t6, a0, 128*2*3
> > +vle8.vv0, (a1)
> > +vle8.vv4, (t1)
> > +vle8.vv8, (t2)
> > +vle8.vv12, (t3)
> > +addi  a3, a3, -4
> > +vwmulu.vx v16, v0, t0
> > +vwmulu.vx v20, v4, t0
> > +vwmulu.vx v24, v8, t0
> > +vwmulu.vx v28, v12, t0
> > +vse16.v   v16, (a0)
> > +vse16.v   v20, (t4)
> > +vse16.v   v24, (t5)
> > +vse16.v   v28, (t6)
> > +sh2adda1, a2, a1
> > +add   a0, a0, 128*2*4
> > +bnez  a3, 1b
> > +ret
> > +endfunc
>
> Is 4x unroll really faster than 2x here? We don't typically unroll 4x
> manually.
>
> > +
> > +.macro dmvr_h_v mn, type
> > +lla   t4, ff_vvc_inter_luma_dmvr_filters
> > +sh1addt4, \mn, t4
> > +lbu   t5, (t4)
> > +lbu   t6, 1(t4)
> > +1:
> > +.ifc \type,h
> > +addi  t0, a1, 1
> > +addi  t1, a1, 2
> > +.else
> > +add   t0, a1, a2
> > +add   t1, t0, a2
> > +.endif
> > +vle8.vv0, (a1)
> > +vle8.vv4, (t0)
> > +vle8.vv8, (t1)
> > +addi  a3, a3, -2
> > +vzext.vf2 v12, v0
> > +vzext.vf2 v16, v4
> > +v

Re: [FFmpeg-devel] [PATCH v6 4/5] libavcodec/dnxucdec: DNxUncompressed decoder

2024-09-28 Thread martin schitter
I know, you are all busy with 7.1 release cleanup, but could you please 
take another look at my DNxUncompressed patches and merge them.


I always fixed the change requests reported by reviewers within 24 
hours, and most of them were in fact really trivial and of cosmetic 
nature anyway, but in the meanwhile a few weeks passed by and my 
contribution is still not merged! :(


For the changes from Monday (v9) I still have not got any reaction.
(https://ffmpeg.org//pipermail/ffmpeg-devel/2024-September/333806.html)

It would be really glad if you could finally accept the code or at lest 
report all the needed improvements in a finally solvable manner.


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