Re: [FFmpeg-devel] [PATCH 9/9] avcodec/vp3: Replace check by assert

2024-05-18 Thread Peter Ross
On Sat, May 18, 2024 at 05:57:43AM +0200, Michael Niedermayer wrote:
> Fixes: CID1452425 Logically dead code
> 
> Sponsored-by: Sovereign Tech Fund
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/vp3.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
> index 09527607767..d03a1c9dbc1 100644
> --- a/libavcodec/vp3.c
> +++ b/libavcodec/vp3.c
> @@ -2001,8 +2001,7 @@ static int vp4_mc_loop_filter(Vp3DecodeContext *s, int 
> plane, int motion_x, int
>  x_offset = (-(x + 2) & 7) + 2;
>  y_offset = (-(y + 2) & 7) + 2;
>  
> -if (x_offset > 8 + x_subpel && y_offset > 8 + y_subpel)
> -return 0;
> +av_assert1(!(x_offset > 8 + x_subpel && y_offset > 8 + y_subpel));
>  

ok

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)


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 v3 1/2][GSoC 2024] libavcodec/x86/vvc: Add AVX2 DMVR SAD functions for VVC

2024-05-18 Thread Wu Jianhua
> 发件人: ffmpeg-devel  代表 Stone Chen 
> 
> 发送时间: 2024年5月14日 13:40
> 收件人: ffmpeg-devel@ffmpeg.org
> 抄送: Stone Chen
> 主题: [FFmpeg-devel] [PATCH v3 1/2][GSoC 2024] libavcodec/x86/vvc: Add AVX2 
> DMVR SAD functions for VVC
> 
> Implements AVX2 DMVR (decoder-side motion vector refinement) SAD functions. 
> DMVR SAD is only calculated if w >= 8, h >= 8, and w * h > 128. > > To reduce 
> complexity, SAD is only calculated on even rows. This is calculated for all 
> video bitdepths, but the values passed to the function are always > 16bit 
> (even if the original video bitdepth is 8). The AVX2 implementation uses 
> min/max/sub.
> 
> Benchmarks ( AMD 7940HS )
> Before:
> BQTerrace_1920x1080_60_10_420_22_RA.vvc | 80.7 |
> Chimera_8bit_1080P_1000_frames.vvc | 158.0 |
> NovosobornayaSquare_1920x1080.bin | 159.7 |
> RitualDance_1920x1080_60_10_420_37_RA.266 | 146.3 |
> 
> After:
> BQTerrace_1920x1080_60_10_420_22_RA.vvc | 82.7 |
> Chimera_8bit_1080P_1000_frames.vvc | 167.0 |
> NovosobornayaSquare_1920x1080.bin | 166.3 |
> RitualDance_1920x1080_60_10_420_37_RA.266 | 154.0 |
> ---

LGTM. Thanks for your efforts.
___
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] lavd/v4l2: Use proper field type for second parameter of ioctl() with BSD's

2024-05-18 Thread Brad Smith

Can this be backported to 7, 6, 5 and 4.4 releases?

On 2024-05-05 11:59 p.m., Brad Smith wrote:

lavd/v4l2: Use proper field type for second parameter of ioctl() with BSD's

The proper type was used until 73251678c83cbe24d08264da693411b166239bc7.

This covers all of the OS's that currently have V4L2 support, permutations
of Linux glibc/musl, Android bionic, FreeBSD, NetBSD, OpenBSD, Solaris.

Copied from FreeBSD ports patch.

Signed-off-by: Brad Smith 
---
  libavdevice/v4l2.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
index 3706582bc6..74f43ef6a9 100644
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -108,10 +108,10 @@ struct video_data {
  int (*open_f)(const char *file, int oflag, ...);
  int (*close_f)(int fd);
  int (*dup_f)(int fd);
-#ifdef __GLIBC__
-int (*ioctl_f)(int fd, unsigned long int request, ...);
-#else
+#if defined(__sun) || defined(__BIONIC__) || defined(__musl__) /* POSIX-like */
  int (*ioctl_f)(int fd, int request, ...);
+#else
+int (*ioctl_f)(int fd, unsigned long int request, ...);
  #endif
  ssize_t (*read_f)(int fd, void *buffer, size_t n);
  void *(*mmap_f)(void *start, size_t length, int prot, int flags, int fd, 
int64_t offset);

___
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 01/11] avfilter/dnn: Refactor DNN parameter configuration system

2024-05-18 Thread Guo, Yejun



> -Original Message-
> From: ffmpeg-devel  On Behalf Of Zhao
> Zhili
> Sent: Wednesday, May 8, 2024 12:08 AM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Zhao Zhili 
> Subject: [FFmpeg-devel] [PATCH v4 01/11] avfilter/dnn: Refactor DNN
> parameter configuration system
> 
> From: Zhao Zhili 
> 
> This patch trying to resolve mulitiple issues related to parameter
> configuration:
> 
> Firstly, each DNN filters duplicate DNN_COMMON_OPTIONS, which should
> be the common options of backend.
> 
> Secondly, backend options are hidden behind the scene. It's a
> AV_OPT_TYPE_STRING backend_configs for user, and parsed by each
> backend. We don't know each backend support what kind of options
> from the help message.
> 
> Third, DNN backends duplicate DNN_BACKEND_COMMON_OPTIONS.
> 
> Last but not the least, pass backend options via AV_OPT_TYPE_STRING
> makes it hard to pass AV_OPT_TYPE_BINARY to backend, if not impossible.
> 
> This patch puts backend common options and each backend options inside
> DnnContext to reduce code duplication, make options user friendly, and
> easy to extend for future usecase.
> 
This patch 01 LGTM, will push soon, thanks.
___
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] lavd/v4l2: Use proper field type for second parameter of ioctl() with BSD's

2024-05-18 Thread Dennis Mungai
On Sat, 18 May 2024, 14:27 Brad Smith, 
wrote:

> Can this be backported to 7, 6, 5 and 4.4 releases?
>
> On 2024-05-05 11:59 p.m., Brad Smith wrote:
> > lavd/v4l2: Use proper field type for second parameter of ioctl() with
> BSD's
> >
> > The proper type was used until 73251678c83cbe24d08264da693411b166239bc7.
> >
> > This covers all of the OS's that currently have V4L2 support,
> permutations
> > of Linux glibc/musl, Android bionic, FreeBSD, NetBSD, OpenBSD, Solaris.
> >
> > Copied from FreeBSD ports patch.
> >
> > Signed-off-by: Brad Smith 
> > ---
> >   libavdevice/v4l2.c | 6 +++---
> >   1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
> > index 3706582bc6..74f43ef6a9 100644
> > --- a/libavdevice/v4l2.c
> > +++ b/libavdevice/v4l2.c
> > @@ -108,10 +108,10 @@ struct video_data {
> >   int (*open_f)(const char *file, int oflag, ...);
> >   int (*close_f)(int fd);
> >   int (*dup_f)(int fd);
> > -#ifdef __GLIBC__
> > -int (*ioctl_f)(int fd, unsigned long int request, ...);
> > -#else
> > +#if defined(__sun) || defined(__BIONIC__) || defined(__musl__) /*
> POSIX-like */
> >   int (*ioctl_f)(int fd, int request, ...);
> > +#else
> > +int (*ioctl_f)(int fd, unsigned long int request, ...);
> >   #endif
> >   ssize_t (*read_f)(int fd, void *buffer, size_t n);
> >   void *(*mmap_f)(void *start, size_t length, int prot, int flags,
> int fd, int64_t offset);
> _".
>


Seconded, a backport would be ideal for prior releases.

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

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


Re: [FFmpeg-devel] [PATCH v3 1/2][GSoC 2024] libavcodec/x86/vvc: Add AVX2 DMVR SAD functions for VVC

2024-05-18 Thread Ronald S. Bultje
Hi,

On Tue, May 14, 2024 at 4:40 PM Stone Chen  wrote:

> Implements AVX2 DMVR (decoder-side motion vector refinement) SAD
> functions. DMVR SAD is only calculated if w >= 8, h >= 8, and w * h > 128.
> To reduce complexity, SAD is only calculated on even rows. This is
> calculated for all video bitdepths, but the values passed to the function
> are always 16bit (even if the original video bitdepth is 8). The AVX2
> implementation uses min/max/sub.
>
> Benchmarks ( AMD 7940HS )
> Before:
> BQTerrace_1920x1080_60_10_420_22_RA.vvc | 80.7 |
> Chimera_8bit_1080P_1000_frames.vvc | 158.0 |
> NovosobornayaSquare_1920x1080.bin | 159.7 |
> RitualDance_1920x1080_60_10_420_37_RA.266 | 146.3 |
>
> After:
> BQTerrace_1920x1080_60_10_420_22_RA.vvc | 82.7 |
> Chimera_8bit_1080P_1000_frames.vvc | 167.0 |
> NovosobornayaSquare_1920x1080.bin | 166.3 |
> RitualDance_1920x1080_60_10_420_37_RA.266 | 154.0 |
>

I assume these are FPS benchmarks? Can you provide checkasm --bench output
for these functions also?

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

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


Re: [FFmpeg-devel] [PATCH v3 1/2][GSoC 2024] libavcodec/x86/vvc: Add AVX2 DMVR SAD functions for VVC

2024-05-18 Thread Stone Chen
On Sat, May 18, 2024 at 9:04 AM Ronald S. Bultje  wrote:

> Hi,
>
> On Tue, May 14, 2024 at 4:40 PM Stone Chen 
> wrote:
>
>> Implements AVX2 DMVR (decoder-side motion vector refinement) SAD
>> functions. DMVR SAD is only calculated if w >= 8, h >= 8, and w * h > 128.
>> To reduce complexity, SAD is only calculated on even rows. This is
>> calculated for all video bitdepths, but the values passed to the function
>> are always 16bit (even if the original video bitdepth is 8). The AVX2
>> implementation uses min/max/sub.
>>
>> Benchmarks ( AMD 7940HS )
>> Before:
>> BQTerrace_1920x1080_60_10_420_22_RA.vvc | 80.7 |
>> Chimera_8bit_1080P_1000_frames.vvc | 158.0 |
>> NovosobornayaSquare_1920x1080.bin | 159.7 |
>> RitualDance_1920x1080_60_10_420_37_RA.266 | 146.3 |
>>
>> After:
>> BQTerrace_1920x1080_60_10_420_22_RA.vvc | 82.7 |
>> Chimera_8bit_1080P_1000_frames.vvc | 167.0 |
>> NovosobornayaSquare_1920x1080.bin | 166.3 |
>> RitualDance_1920x1080_60_10_420_37_RA.266 | 154.0 |
>>
>
> I assume these are FPS benchmarks? Can you provide checkasm --bench output
> for these functions also?
>
> Ronald
>

Hi Ronald,

Correct those are FPS benchmarks. There's a separate patch that has the
checkasm --bench (Add check_vvc_sad to vvc_mc.c), in the commit message.
I've c&p the benchmark snippit below:


> vvc_sad_8x8_c: 63.0
> vvc_sad_8x8_avx2: 3.0
> vvc_sad_16x16_c: 263.0
> vvc_sad_16x16_avx2: 23.0
> vvc_sad_32x32_c: 1003.0
> vvc_sad_32x32_avx2: 83.0
> vvc_sad_64x64_c: 3923.0
> vvc_sad_64x64_avx2: 373.0
> vvc_sad_128x128_c: 17533.0
> vvc_sad_128x128_avx2: 1683.0


Also your blogpost was very helpful for getting started with asm!

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

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


Re: [FFmpeg-devel] [PATCH v3 2/2] avcodec: add external dec libvvdec for H266/VVC

2024-05-18 Thread Nuo Mi
On Sat, May 18, 2024 at 1:20 AM Cosmin Stejerean via ffmpeg-devel <
ffmpeg-devel@ffmpeg.org> wrote:

>
>
> > On May 14, 2024, at 9:28 AM, Lynne via ffmpeg-devel <
> ffmpeg-devel@ffmpeg.org> wrote:
> >
> > On 14/05/2024 17:09, Christian Bartnik wrote:
> >> From: Thomas Siedel 
> >> Add external decoder VVdeC for H266/VVC decoding.
> >> Register new decoder libvvdec.
> >> Add libvvdec to wrap the vvdec interface.
> >> Enable decoder by adding --enable-libvvdec in configure step.
> >> Co-authored-by: Christian Bartnik chris1031...@gmail.com
> >> Signed-off-by: Christian Bartnik 
> >> ---
> >>  configure  |   5 +
> >>  libavcodec/Makefile|   1 +
> >>  libavcodec/allcodecs.c |   1 +
> >>  libavcodec/libvvdec.c  | 617 +
> >>  4 files changed, 624 insertions(+)
> >>  create mode 100644 libavcodec/libvvdec.c
> >
> > I would prefer to have this one skipped, as initially suggested.
>
> Why? I tried to look back through the list but didn't see anything.
>
Hi Cosmin,
This happened many years ago. See the discussion here:
https://patchwork.ffmpeg.org/project/ffmpeg/patch/20201221060710.12230-6-nuomi2...@gmail.com/#60589
Now that we have an internal vvc decoder, we can focus on improving it.
As for the encoder, it is far more complex than the decoder. Reasonable to
wrapper other libraries just like libx264 and libx265...

>
> - Cosmin
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 8/9] avcodec/vp8: Forward return of ff_vpx_init_range_decoder()

2024-05-18 Thread Ronald S. Bultje
Hi,

On Fri, May 17, 2024 at 11:59 PM Michael Niedermayer 
wrote:

> Fixes: CID1507483 Unchecked return value
>
> Sponsored-by: Sovereign Tech Fund
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/vp8.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
> index 19f32b34006..8e91613068a 100644
> --- a/libavcodec/vp8.c
> +++ b/libavcodec/vp8.c
> @@ -341,9 +341,8 @@ static int setup_partitions(VP8Context *s, const
> uint8_t *buf, int buf_size)
>  }
>
>  s->coeff_partition_size[i] = buf_size;
> -ff_vpx_init_range_decoder(&s->coeff_partition[i], buf, buf_size);
>
> -return 0;
> +return ff_vpx_init_range_decoder(&s->coeff_partition[i], buf,
> buf_size);
>  }
>
>  static void vp7_get_quants(VP8Context *s)
> --
> 2.45.1
>

OK.

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

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


[FFmpeg-devel] [PATCH 1/3] avfilter/vf_signalstats: Use av_dict_set_int() where appropriate

2024-05-18 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/vf_signalstats.c | 80 ++--
 1 file changed, 40 insertions(+), 40 deletions(-)

diff --git a/libavfilter/vf_signalstats.c b/libavfilter/vf_signalstats.c
index c2358c66cb..960899596f 100644
--- a/libavfilter/vf_signalstats.c
+++ b/libavfilter/vf_signalstats.c
@@ -720,40 +720,40 @@ static int filter_frame8(AVFilterLink *link, AVFrame *in)
 av_dict_set(&out->metadata, "lavfi.signalstats." key, metabuf, 0);   \
 } while (0)
 
-SET_META("YMIN","%d", miny);
-SET_META("YLOW","%d", lowy);
+av_dict_set_int(&out->metadata, "lavfi.signalstats.YMIN", miny, 0);
+av_dict_set_int(&out->metadata, "lavfi.signalstats.YLOW", lowy, 0);
 SET_META("YAVG","%g", 1.0 * toty / s->fs);
-SET_META("YHIGH",   "%d", highy);
-SET_META("YMAX","%d", maxy);
+av_dict_set_int(&out->metadata, "lavfi.signalstats.YHIGH", highy, 0);
+av_dict_set_int(&out->metadata, "lavfi.signalstats.YMAX", maxy, 0);
 
-SET_META("UMIN","%d", minu);
-SET_META("ULOW","%d", lowu);
+av_dict_set_int(&out->metadata, "lavfi.signalstats.UMIN", minu, 0);
+av_dict_set_int(&out->metadata, "lavfi.signalstats.ULOW", lowu, 0);
 SET_META("UAVG","%g", 1.0 * totu / s->cfs);
-SET_META("UHIGH",   "%d", highu);
-SET_META("UMAX","%d", maxu);
+av_dict_set_int(&out->metadata, "lavfi.signalstats.UHIGH", highu, 0);
+av_dict_set_int(&out->metadata, "lavfi.signalstats.UMAX", maxu, 0);
 
-SET_META("VMIN","%d", minv);
-SET_META("VLOW","%d", lowv);
+av_dict_set_int(&out->metadata, "lavfi.signalstats.VMIN", minv, 0);
+av_dict_set_int(&out->metadata, "lavfi.signalstats.VLOW", lowv, 0);
 SET_META("VAVG","%g", 1.0 * totv / s->cfs);
-SET_META("VHIGH",   "%d", highv);
-SET_META("VMAX","%d", maxv);
+av_dict_set_int(&out->metadata, "lavfi.signalstats.VHIGH", highv, 0);
+av_dict_set_int(&out->metadata, "lavfi.signalstats.VMAX", maxv, 0);
 
-SET_META("SATMIN",  "%d", minsat);
-SET_META("SATLOW",  "%d", lowsat);
+av_dict_set_int(&out->metadata, "lavfi.signalstats.SATMIN", minsat, 0);
+av_dict_set_int(&out->metadata, "lavfi.signalstats.SATLOW", lowsat, 0);
 SET_META("SATAVG",  "%g", 1.0 * totsat / s->cfs);
-SET_META("SATHIGH", "%d", highsat);
-SET_META("SATMAX",  "%d", maxsat);
+av_dict_set_int(&out->metadata, "lavfi.signalstats.SATHIGH", highsat, 0);
+av_dict_set_int(&out->metadata, "lavfi.signalstats.SATMAX", maxsat, 0);
 
-SET_META("HUEMED",  "%d", medhue);
+av_dict_set_int(&out->metadata, "lavfi.signalstats.HUEMED", medhue, 0);
 SET_META("HUEAVG",  "%g", 1.0 * tothue / s->cfs);
 
 SET_META("YDIF","%g", 1.0 * dify / s->fs);
 SET_META("UDIF","%g", 1.0 * difu / s->cfs);
 SET_META("VDIF","%g", 1.0 * difv / s->cfs);
 
-SET_META("YBITDEPTH", "%d", compute_bit_depth(masky));
-SET_META("UBITDEPTH", "%d", compute_bit_depth(masku));
-SET_META("VBITDEPTH", "%d", compute_bit_depth(maskv));
+av_dict_set_int(&out->metadata, "lavfi.signalstats.YBITDEPTH", 
compute_bit_depth(masky), 0);
+av_dict_set_int(&out->metadata, "lavfi.signalstats.UBITDEPTH", 
compute_bit_depth(masku), 0);
+av_dict_set_int(&out->metadata, "lavfi.signalstats.VBITDEPTH", 
compute_bit_depth(maskv), 0);
 
 for (fil = 0; fil < FILT_NUMB; fil ++) {
 if (s->filters & 1frame_prev = av_frame_clone(in);
 
-SET_META("YMIN","%d", miny);
-SET_META("YLOW","%d", lowy);
+av_dict_set_int(&out->metadata, "lavfi.signalstats.YMIN", miny, 0);
+av_dict_set_int(&out->metadata, "lavfi.signalstats.YLOW", lowy, 0);
 SET_META("YAVG","%g", 1.0 * toty / s->fs);
-SET_META("YHIGH",   "%d", highy);
-SET_META("YMAX","%d", maxy);
+av_dict_set_int(&out->metadata, "lavfi.signalstats.YHIGH", highy, 0);
+av_dict_set_int(&out->metadata, "lavfi.signalstats.YMAX", maxy, 0);
 
-SET_META("UMIN","%d", minu);
-SET_META("ULOW","%d", lowu);
+av_dict_set_int(&out->metadata, "lavfi.signalstats.UMIN", minu, 0);
+av_dict_set_int(&out->metadata, "lavfi.signalstats.ULOW", lowu, 0);
 SET_META("UAVG","%g", 1.0 * totu / s->cfs);
-SET_META("UHIGH",   "%d", highu);
-SET_META("UMAX","%d", maxu);
+av_dict_set_int(&out->metadata, "lavfi.signalstats.UHIGH", highu, 0);
+av_dict_set_int(&out->metadata, "lavfi.signalstats.UMAX", maxu, 0);
 
-SET_META("VMIN","%d", minv);
-SET_META("VLOW","%d", lowv);
+av_dict_set_int(&out->metadata, "lavfi.signalstats.VMIN", minv, 0);
+av_dict_set_int(&out->metadata, "lavfi.signalstats.VLOW", lowv, 0);
 SET_META("VAVG","%g", 1.0 * totv / s->cfs);
-SET_META("VHIGH",   "%d", highv);
-SET_META("VMAX","%d", maxv);
+av_dict_set_int(&out->metadata, "lavfi.signalstats.VHIGH", highv, 0);
+av_dict_set_int(&out->metadata, "lavfi.signalstats.VMAX", maxv, 0);
 
-

[FFmpeg-devel] [PATCH 2/3] avfilter/vf_signalstats: Deduplicate <= 8 and > 8 bit code

2024-05-18 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/vf_signalstats.c | 279 ++-
 1 file changed, 43 insertions(+), 236 deletions(-)

diff --git a/libavfilter/vf_signalstats.c b/libavfilter/vf_signalstats.c
index 960899596f..1bdc6a42ba 100644
--- a/libavfilter/vf_signalstats.c
+++ b/libavfilter/vf_signalstats.c
@@ -538,7 +538,7 @@ static unsigned compute_bit_depth(uint16_t mask)
 return av_popcount(mask);
 }
 
-static int filter_frame8(AVFilterLink *link, AVFrame *in)
+static int filter_frame(AVFilterLink *link, AVFrame *in)
 {
 AVFilterContext *ctx = link->dst;
 SignalstatsContext *s = ctx->priv;
@@ -563,20 +563,17 @@ static int filter_frame8(AVFilterLink *link, AVFrame *in)
 int accy, accu, accv;
 int accsat, acchue = 0;
 int medhue, maxhue;
-int toty = 0, totu = 0, totv = 0, totsat=0;
-int tothue = 0;
-int dify = 0, difu = 0, difv = 0;
+int64_t toty = 0, totu = 0, totv = 0, totsat=0;
+int64_t tothue = 0;
+int64_t dify = 0, difu = 0, difv = 0;
 uint16_t masky = 0, masku = 0, maskv = 0;
-int ret;
+
 int filtot[FILT_NUMB] = {0};
 AVFrame *prev;
-
+int ret;
 AVFrame *sat = s->frame_sat;
 AVFrame *hue = s->frame_hue;
-const uint8_t *p_sat = sat->data[0];
-const uint8_t *p_hue = hue->data[0];
-const int lsz_sat = sat->linesize[0];
-const int lsz_hue = hue->linesize[0];
+const int hbd = s->depth > 8;
 ThreadDataHueSatMetrics td_huesat = {
 .src = in,
 .dst_sat = sat,
@@ -602,38 +599,45 @@ static int filter_frame8(AVFilterLink *link, AVFrame *in)
 }
 }
 
-ff_filter_execute(ctx, compute_sat_hue_metrics8, &td_huesat,
+ff_filter_execute(ctx, hbd ? compute_sat_hue_metrics16
+   : compute_sat_hue_metrics8, &td_huesat,
   NULL, FFMIN(s->chromah, ff_filter_get_nb_threads(ctx)));
 
-// Calculate luma histogram and difference with previous frame or field.
 memset(s->histy, 0, s->maxsize * sizeof(*s->histy));
+memset(s->histu, 0, s->maxsize * sizeof(*s->histu));
+memset(s->histv, 0, s->maxsize * sizeof(*s->histv));
+memset(s->histsat, 0, s->maxsize * sizeof(*s->histsat));
+
+if (hbd) {
+const uint16_t *p_sat = (uint16_t *)sat->data[0];
+const uint16_t *p_hue = (uint16_t *)hue->data[0];
+const int lsz_sat = sat->linesize[0] / 2;
+const int lsz_hue = hue->linesize[0] / 2;
+// Calculate luma histogram and difference with previous frame or field.
 for (j = 0; j < link->h; j++) {
 for (i = 0; i < link->w; i++) {
-const int yuv = in->data[0][w + i];
+const int yuv = AV_RN16(in->data[0] + w + i * 2);
 
 masky |= yuv;
 histy[yuv]++;
-dify += abs(yuv - prev->data[0][pw + i]);
+dify += abs(yuv - (int)AV_RN16(prev->data[0] + pw + i * 2));
 }
 w  += in->linesize[0];
 pw += prev->linesize[0];
 }
 
 // Calculate chroma histogram and difference with previous frame or field.
-memset(s->histu, 0, s->maxsize * sizeof(*s->histu));
-memset(s->histv, 0, s->maxsize * sizeof(*s->histv));
-memset(s->histsat, 0, s->maxsize * sizeof(*s->histsat));
 for (j = 0; j < s->chromah; j++) {
 for (i = 0; i < s->chromaw; i++) {
-const int yuvu = in->data[1][cw+i];
-const int yuvv = in->data[2][cw+i];
+const int yuvu = AV_RN16(in->data[1] + cw + i * 2);
+const int yuvv = AV_RN16(in->data[2] + cw + i * 2);
 
 masku |= yuvu;
 maskv |= yuvv;
 histu[yuvu]++;
-difu += abs(yuvu - prev->data[1][cpw+i]);
+difu += abs(yuvu - (int)AV_RN16(prev->data[1] + cpw + i * 2));
 histv[yuvv]++;
-difv += abs(yuvv - prev->data[2][cpw+i]);
+difv += abs(yuvv - (int)AV_RN16(prev->data[2] + cpw + i * 2));
 
 histsat[p_sat[i]]++;
 histhue[((int16_t*)p_hue)[i]]++;
@@ -643,228 +647,36 @@ static int filter_frame8(AVFilterLink *link, AVFrame *in)
 p_sat += lsz_sat;
 p_hue += lsz_hue;
 }
-
-for (fil = 0; fil < FILT_NUMB; fil ++) {
-if (s->filters & 1jobs_rets, 0, s->nb_jobs * sizeof(*s->jobs_rets));
-ff_filter_execute(ctx, filters_def[fil].process8,
-  &td, s->jobs_rets, s->nb_jobs);
-for (i = 0; i < s->nb_jobs; i++)
-filtot[fil] += s->jobs_rets[i];
-}
-}
-
-// find low / high based on histogram percentile
-// these only need to be calculated once.
-
-lowp   = lrint(s->fs  * 10 / 100.);
-highp  = lrint(s->fs  * 90 / 100.);
-clowp  = lrint(s->cfs * 10 / 100.);
-chighp = lrint(s->cfs * 90 / 100.);
-
-accy = accu = accv = accsat = 0;
-for (fil = 0; fil < s->maxsize; fil++) {
-if (miny   < 0 && histy[fil])   miny =

[FFmpeg-devel] [PATCH 3/3] avfilter/vf_signalstats: Reindent after the previous commit

2024-05-18 Thread Andreas Rheinhardt
Also use loop scope for iterators while just at it.

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/vf_signalstats.c | 143 +--
 1 file changed, 71 insertions(+), 72 deletions(-)

diff --git a/libavfilter/vf_signalstats.c b/libavfilter/vf_signalstats.c
index 1bdc6a42ba..50c9df4298 100644
--- a/libavfilter/vf_signalstats.c
+++ b/libavfilter/vf_signalstats.c
@@ -544,7 +544,6 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
 SignalstatsContext *s = ctx->priv;
 AVFilterLink *outlink = ctx->outputs[0];
 AVFrame *out = in;
-int i, j;
 int  w = 0,  cw = 0, // in
 pw = 0, cpw = 0; // prev
 int fil;
@@ -609,83 +608,83 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
 memset(s->histsat, 0, s->maxsize * sizeof(*s->histsat));
 
 if (hbd) {
-const uint16_t *p_sat = (uint16_t *)sat->data[0];
-const uint16_t *p_hue = (uint16_t *)hue->data[0];
-const int lsz_sat = sat->linesize[0] / 2;
-const int lsz_hue = hue->linesize[0] / 2;
-// Calculate luma histogram and difference with previous frame or field.
-for (j = 0; j < link->h; j++) {
-for (i = 0; i < link->w; i++) {
-const int yuv = AV_RN16(in->data[0] + w + i * 2);
-
-masky |= yuv;
-histy[yuv]++;
-dify += abs(yuv - (int)AV_RN16(prev->data[0] + pw + i * 2));
+const uint16_t *p_sat = (uint16_t *)sat->data[0];
+const uint16_t *p_hue = (uint16_t *)hue->data[0];
+const int lsz_sat = sat->linesize[0] / 2;
+const int lsz_hue = hue->linesize[0] / 2;
+// Calculate luma histogram and difference with previous frame or 
field.
+for (int j = 0; j < link->h; j++) {
+for (int i = 0; i < link->w; i++) {
+const int yuv = AV_RN16(in->data[0] + w + i * 2);
+
+masky |= yuv;
+histy[yuv]++;
+dify += abs(yuv - (int)AV_RN16(prev->data[0] + pw + i * 2));
+}
+w  += in->linesize[0];
+pw += prev->linesize[0];
 }
-w  += in->linesize[0];
-pw += prev->linesize[0];
-}
 
-// Calculate chroma histogram and difference with previous frame or field.
-for (j = 0; j < s->chromah; j++) {
-for (i = 0; i < s->chromaw; i++) {
-const int yuvu = AV_RN16(in->data[1] + cw + i * 2);
-const int yuvv = AV_RN16(in->data[2] + cw + i * 2);
-
-masku |= yuvu;
-maskv |= yuvv;
-histu[yuvu]++;
-difu += abs(yuvu - (int)AV_RN16(prev->data[1] + cpw + i * 2));
-histv[yuvv]++;
-difv += abs(yuvv - (int)AV_RN16(prev->data[2] + cpw + i * 2));
-
-histsat[p_sat[i]]++;
-histhue[((int16_t*)p_hue)[i]]++;
+// Calculate chroma histogram and difference with previous frame or 
field.
+for (int j = 0; j < s->chromah; j++) {
+for (int i = 0; i < s->chromaw; i++) {
+const int yuvu = AV_RN16(in->data[1] + cw + i * 2);
+const int yuvv = AV_RN16(in->data[2] + cw + i * 2);
+
+masku |= yuvu;
+maskv |= yuvv;
+histu[yuvu]++;
+difu += abs(yuvu - (int)AV_RN16(prev->data[1] + cpw + i * 2));
+histv[yuvv]++;
+difv += abs(yuvv - (int)AV_RN16(prev->data[2] + cpw + i * 2));
+
+histsat[p_sat[i]]++;
+histhue[((int16_t*)p_hue)[i]]++;
+}
+cw  += in->linesize[1];
+cpw += prev->linesize[1];
+p_sat += lsz_sat;
+p_hue += lsz_hue;
 }
-cw  += in->linesize[1];
-cpw += prev->linesize[1];
-p_sat += lsz_sat;
-p_hue += lsz_hue;
-}
 } else {
-const uint8_t *p_sat = sat->data[0];
-const uint8_t *p_hue = hue->data[0];
-const int lsz_sat = sat->linesize[0];
-const int lsz_hue = hue->linesize[0];
-// Calculate luma histogram and difference with previous frame or field.
-for (j = 0; j < link->h; j++) {
-for (i = 0; i < link->w; i++) {
-const int yuv = in->data[0][w + i];
-
-masky |= yuv;
-histy[yuv]++;
-dify += abs(yuv - prev->data[0][pw + i]);
+const uint8_t *p_sat = sat->data[0];
+const uint8_t *p_hue = hue->data[0];
+const int lsz_sat = sat->linesize[0];
+const int lsz_hue = hue->linesize[0];
+// Calculate luma histogram and difference with previous frame or 
field.
+for (int j = 0; j < link->h; j++) {
+for (int i = 0; i < link->w; i++) {
+const int yuv = in->data[0][w + i];
+
+masky |= yuv;
+histy[yuv]++;
+dify += abs(yuv - prev->data[0][pw + i]);
+}
+w  += in->linesize[0];
+pw += prev->linesize[0];
 }
-w  += in->linesize[0];
-pw += prev-

Re: [FFmpeg-devel] [PATCH v3 1/2][GSoC 2024] libavcodec/x86/vvc: Add AVX2 DMVR SAD functions for VVC

2024-05-18 Thread Ronald S. Bultje
Hi,

On Tue, May 14, 2024 at 4:40 PM Stone Chen  wrote:

> +vvc_sad_8:
> +.loop_height:
> +movu  xm0, [src1q]
> +movu  xm1, [src2q]
> +MIN_MAX_SAD   xm2, xm0, xm1
> +vpmovzxwd  m1, xm1
> +vpaddd m3, m1
>
[..]

> +vvc_sad_16_128:
> +.loop_height:
>
[..]

> +.loop_width:
> +movu  xm0, [src1q]
> +movu  xm1, [src2q]
> +MIN_MAX_SAD   xm2, xm0, xm1
> +vpmovzxwd  m1, xm1
> +vpaddd m3, m1
>

Wouldn't it be more efficient if the main loops did a full register worth
at a time?

vpbroadcastd m4, [pw_1]
loop:
movu m0, [src1q]
movu m1, [src2q]
MIN_MAX_SAD m2, m0, m1
pmaddwd m1, m4
paddd m3, m1

(And then for w8, load 2 rows per iteration using movu xmN, [row0] and
vinserti128 mN, [row1], 1.)

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

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


[FFmpeg-devel] [PATCH 1/2] lavc/startcode: add R-V V startcode_find_candidate

2024-05-18 Thread Rémi Denis-Courmont
---
 libavcodec/riscv/Makefile|  1 +
 libavcodec/riscv/h264dsp_init.c  |  5 
 libavcodec/riscv/startcode_rvv.S | 44 
 libavcodec/riscv/vc1dsp_init.c   | 20 +--
 4 files changed, 62 insertions(+), 8 deletions(-)
 create mode 100644 libavcodec/riscv/startcode_rvv.S

diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile
index 697c10269a..07d5c2915d 100644
--- a/libavcodec/riscv/Makefile
+++ b/libavcodec/riscv/Makefile
@@ -53,6 +53,7 @@ RVV-OBJS-$(CONFIG_RV34DSP) += riscv/rv34dsp_rvv.o
 OBJS-$(CONFIG_RV40_DECODER) += riscv/rv40dsp_init.o
 RVV-OBJS-$(CONFIG_RV40_DECODER) += riscv/rv40dsp_rvv.o
 RV-OBJS-$(CONFIG_STARTCODE) += riscv/startcode_rvb.o
+RVV-OBJS-$(CONFIG_STARTCODE) += riscv/startcode_rvv.o
 OBJS-$(CONFIG_SVQ1_ENCODER) += riscv/svqenc_init.o
 RVV-OBJS-$(CONFIG_SVQ1_ENCODER) += riscv/svqenc_rvv.o
 OBJS-$(CONFIG_TAK_DECODER) += riscv/takdsp_init.o
diff --git a/libavcodec/riscv/h264dsp_init.c b/libavcodec/riscv/h264dsp_init.c
index 60c84734cd..dbbf3db400 100644
--- a/libavcodec/riscv/h264dsp_init.c
+++ b/libavcodec/riscv/h264dsp_init.c
@@ -27,6 +27,7 @@
 #include "libavcodec/h264dsp.h"
 
 extern int ff_startcode_find_candidate_rvb(const uint8_t *, int);
+extern int ff_startcode_find_candidate_rvv(const uint8_t *, int);
 
 av_cold void ff_h264dsp_init_riscv(H264DSPContext *dsp, const int bit_depth,
const int chroma_format_idc)
@@ -36,5 +37,9 @@ av_cold void ff_h264dsp_init_riscv(H264DSPContext *dsp, const 
int bit_depth,
 
 if (flags & AV_CPU_FLAG_RVB_BASIC)
 dsp->startcode_find_candidate = ff_startcode_find_candidate_rvb;
+# if HAVE_RVV
+if (flags & AV_CPU_FLAG_RVV_I32)
+dsp->startcode_find_candidate = ff_startcode_find_candidate_rvv;
+# endif
 #endif
 }
diff --git a/libavcodec/riscv/startcode_rvv.S b/libavcodec/riscv/startcode_rvv.S
new file mode 100644
index 00..7c43b1d7f3
--- /dev/null
+++ b/libavcodec/riscv/startcode_rvv.S
@@ -0,0 +1,44 @@
+/*
+ * Copyright © 2024 Rémi Denis-Courmont.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *this list of conditions and the following disclaimer in the documentation
+ *and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "libavutil/riscv/asm.S"
+
+func ff_startcode_find_candidate_rvv, zve32x
+mv   t0, a0
+1:
+vsetvli  t1, a1, e8, m8, ta, ma
+vle8.v   v8, (t0)
+sub  a1, a1, t1
+vmseq.vi v0, v8, 0
+vfirst.m t2, v0
+bgez t2, 2f
+add  t0, t0, t1
+bnez a1, 1b
+2:
+add  t0, t0, t2
+sub  a0, t0, a0
+ret
+endfunc
diff --git a/libavcodec/riscv/vc1dsp_init.c b/libavcodec/riscv/vc1dsp_init.c
index d82f7efbc2..8ef0c1f40f 100644
--- a/libavcodec/riscv/vc1dsp_init.c
+++ b/libavcodec/riscv/vc1dsp_init.c
@@ -34,6 +34,7 @@ void ff_put_pixels8x8_rvi(uint8_t *dst, const uint8_t *src, 
ptrdiff_t line_size,
 void ff_avg_pixels16x16_rvv(uint8_t *dst, const uint8_t *src, ptrdiff_t 
line_size, int rnd);
 void ff_avg_pixels8x8_rvv(uint8_t *dst, const uint8_t *src, ptrdiff_t 
line_size, int rnd);
 int ff_startcode_find_candidate_rvb(const uint8_t *, int);
+int ff_startcode_find_candidate_rvv(const uint8_t *, int);
 
 av_cold void ff_vc1dsp_init_riscv(VC1DSPContext *dsp)
 {
@@ -49,15 +50,18 @@ av_cold void ff_vc1dsp_init_riscv(VC1DSPContext *dsp)
 if (flags & AV_CPU_FLAG_RVB_BASIC)
 dsp->startcode_find_candidate = ff_startcode_find_candidate_rvb;
 # if HAVE_RVV
-if (flags & AV_CPU_FLAG_RVV_I32 && ff_rv_vlen_least(128)) {
-dsp->vc1_inv_trans_4x8_dc = ff_vc1_inv_trans_4x8_dc_rvv;
-dsp->vc1_inv_trans_4x4_dc = ff_vc1_inv_trans_4x4_dc_rvv;
-dsp->avg_vc1_mspel_pixels_tab[0][0] = ff_avg_pixels16x16_rvv;
-if (flags & AV_CPU_FLAG_RVV_I64) {
-   

[FFmpeg-devel] [PATCH 2/2] lavc/vp8dsp: fix .irp use with LLVM as

2024-05-18 Thread Rémi Denis-Courmont
---
 libavcodec/riscv/vp8dsp_rvv.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/riscv/vp8dsp_rvv.S b/libavcodec/riscv/vp8dsp_rvv.S
index 4d7a9f6a2d..0ba9fa443d 100644
--- a/libavcodec/riscv/vp8dsp_rvv.S
+++ b/libavcodec/riscv/vp8dsp_rvv.S
@@ -171,7 +171,7 @@ endconst
 li  t1, 6
 mul t0, t0, t1
 add t0, t0, t2
-.irp n 1,2,3,4
+.irp n,1,2,3,4
 lb  t\n, \n(t0)
 .endr
 .ifc \size,6
@@ -236,7 +236,7 @@ func ff_put_vp8_epel\len\()_\type\()\size\()_rvv, zve32x
 endfunc
 .endm
 
-.irp len 16,8,4
+.irp len,16,8,4
 put_vp8_bilin_h_v \len h a5
 put_vp8_bilin_h_v \len v a6
 put_vp8_bilin_hv \len
-- 
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 1/2] lavc/startcode: add R-V V startcode_find_candidate

2024-05-18 Thread Rémi Denis-Courmont
Wrong patch sent, disregard

-- 
Rémi Denis-Courmont
http://www.remlab.net/



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

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


[FFmpeg-devel] [PATCH] lavc/vp9_intra: fix .irp use with LLVM as

2024-05-18 Thread Rémi Denis-Courmont
---
 libavcodec/riscv/vp9_intra_rvv.S | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/libavcodec/riscv/vp9_intra_rvv.S b/libavcodec/riscv/vp9_intra_rvv.S
index 280c497687..7b3c22b99a 100644
--- a/libavcodec/riscv/vp9_intra_rvv.S
+++ b/libavcodec/riscv/vp9_intra_rvv.S
@@ -124,12 +124,12 @@ func ff_h_32x32_rvv, zve32x
 vsetvli  zero, t0, e8, m2, ta, ma
 
 .rept 2
-.irp n 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30
+.irp n, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30
 lbu  t1, (a2)
 addi a2, a2, -1
 vmv.v.x  v\n, t1
 .endr
-.irp n 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30
+.irp n, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30
 vse8.v   v\n, (a0)
 add  a0, a0, a1
 .endr
@@ -142,12 +142,12 @@ func ff_h_16x16_rvv, zve32x
 addi a2, a2, 15
 vsetivli zero, 16, e8, m1, ta, ma
 
-.irp n 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23
+.irp n, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23
 lbu  t1, (a2)
 addi a2, a2, -1
 vmv.v.x  v\n, t1
 .endr
-.irp n 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22
+.irp n, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22
 vse8.v   v\n, (a0)
 add  a0, a0, a1
 .endr
@@ -160,12 +160,12 @@ func ff_h_8x8_rvv, zve32x
 addi a2, a2, 7
 vsetivli zero, 8, e8, mf2, ta, ma
 
-.irp n 8, 9, 10, 11, 12, 13, 14, 15
+.irp n, 8, 9, 10, 11, 12, 13, 14, 15
 lbu  t1, (a2)
 addi a2, a2, -1
 vmv.v.x  v\n, t1
 .endr
-.irp n 8, 9, 10, 11, 12, 13, 14
+.irp n, 8, 9, 10, 11, 12, 13, 14
 vse8.v   v\n, (a0)
 add  a0, a0, a1
 .endr
@@ -193,7 +193,7 @@ func ff_tm_32x32_rvv, zve32x
 lbu  a4, -1(a3)
 li   t5, 32
 
-.irp offset 31, 23, 15, 7
+.irp offset, 31, 23, 15, 7
 vsetvli  zero, t5, e16, m4, ta, ma
 vle8.v   v8, (a3)
 vzext.vf2v28, v8
@@ -201,7 +201,7 @@ func ff_tm_32x32_rvv, zve32x
 tm_sum4  v0, v4, v8, v12, v28, \offset
 tm_sum4  v16, v20, v24, v28, v28, (\offset-4)
 
-.irp n 0, 4, 8, 12, 16, 20, 24, 28
+.irp n, 0, 4, 8, 12, 16, 20, 24, 28
 vmax.vx  v\n, v\n, zero
 .endr
 
@@ -227,12 +227,12 @@ func ff_tm_16x16_rvv, zve32x
 tm_sum4   v16, v18, v20, v22, v30, 7
 tm_sum4   v24, v26, v28, v30, v30, 3
 
-.irp n 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30
+.irp n, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30
 vmax.vx  v\n, v\n, zero
 .endr
 
 vsetvli  zero, zero, e8, m1, ta, ma
-.irp n 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28
+.irp n, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28
 vnclipu.wi   v\n, v\n, 0
 vse8.v   v\n, (a0)
 add  a0, a0, a1
@@ -252,12 +252,12 @@ func ff_tm_8x8_rvv, zve32x
 tm_sum4  v16, v17, v18, v19, v28, 7
 tm_sum4  v20, v21, v22, v23, v28, 3
 
-.irp n 16, 17, 18, 19, 20, 21, 22, 23
+.irp n, 16, 17, 18, 19, 20, 21, 22, 23
 vmax.vx  v\n, v\n, zero
 .endr
 
 vsetvli  zero, zero, e8, mf2, ta, ma
-.irp n 16, 17, 18, 19, 20, 21, 22
+.irp n, 16, 17, 18, 19, 20, 21, 22
 vnclipu.wi   v\n, v\n, 0
 vse8.v   v\n, (a0)
 add  a0, a0, a1
@@ -276,12 +276,12 @@ func ff_tm_4x4_rvv, zve32x
 
 tm_sum4  v16, v17, v18, v19, v28, 3
 
-.irp n 16, 17, 18, 19
+.irp n, 16, 17, 18, 19
 vmax.vx  v\n, v\n, zero
 .endr
 
 vsetvli  zero, zero, e8, mf4, ta, ma
-.irp n 16, 17, 18
+.irp n, 16, 17, 18
 vnclipu.wi   v\n, v\n, 0
 vse8.v   v\n, (a0)
 add  a0, a0, a1
-- 
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 v3 6/9] lavc/vp9dsp: R-V V mc bilin h v

2024-05-18 Thread Rémi Denis-Courmont
Le maanantaina 13. toukokuuta 2024, 19.59.23 EEST u...@foxmail.com a écrit :
> From: sunyuechi 
> 
> C908:
> vp9_avg_bilin_4h_8bpp_c: 5.2
> vp9_avg_bilin_4h_8bpp_rvv_i64: 2.2
> vp9_avg_bilin_4v_8bpp_c: 5.5
> vp9_avg_bilin_4v_8bpp_rvv_i64: 2.2
> vp9_avg_bilin_8h_8bpp_c: 20.0
> vp9_avg_bilin_8h_8bpp_rvv_i64: 4.5
> vp9_avg_bilin_8v_8bpp_c: 21.0
> vp9_avg_bilin_8v_8bpp_rvv_i64: 4.2
> vp9_avg_bilin_16h_8bpp_c: 78.2
> vp9_avg_bilin_16h_8bpp_rvv_i64: 9.0
> vp9_avg_bilin_16v_8bpp_c: 82.0
> vp9_avg_bilin_16v_8bpp_rvv_i64: 9.0
> vp9_avg_bilin_32h_8bpp_c: 325.5
> vp9_avg_bilin_32h_8bpp_rvv_i64: 26.2
> vp9_avg_bilin_32v_8bpp_c: 326.2
> vp9_avg_bilin_32v_8bpp_rvv_i64: 26.2
> vp9_avg_bilin_64h_8bpp_c: 1265.7
> vp9_avg_bilin_64h_8bpp_rvv_i64: 91.5
> vp9_avg_bilin_64v_8bpp_c: 1317.0
> vp9_avg_bilin_64v_8bpp_rvv_i64: 91.2
> vp9_put_bilin_4h_8bpp_c: 4.5
> vp9_put_bilin_4h_8bpp_rvv_i64: 1.7
> vp9_put_bilin_4v_8bpp_c: 4.7
> vp9_put_bilin_4v_8bpp_rvv_i64: 1.7
> vp9_put_bilin_8h_8bpp_c: 17.0
> vp9_put_bilin_8h_8bpp_rvv_i64: 3.5
> vp9_put_bilin_8v_8bpp_c: 18.0
> vp9_put_bilin_8v_8bpp_rvv_i64: 3.5
> vp9_put_bilin_16h_8bpp_c: 65.2
> vp9_put_bilin_16h_8bpp_rvv_i64: 7.5
> vp9_put_bilin_16v_8bpp_c: 85.7
> vp9_put_bilin_16v_8bpp_rvv_i64: 7.5
> vp9_put_bilin_32h_8bpp_c: 257.5
> vp9_put_bilin_32h_8bpp_rvv_i64: 23.5
> vp9_put_bilin_32v_8bpp_c: 274.5
> vp9_put_bilin_32v_8bpp_rvv_i64: 23.5
> vp9_put_bilin_64h_8bpp_c: 1040.5
> vp9_put_bilin_64h_8bpp_rvv_i64: 82.5
> vp9_put_bilin_64v_8bpp_c: 1108.7
> vp9_put_bilin_64v_8bpp_rvv_i64: 82.2
> ---
>  libavcodec/riscv/vp9_mc_rvv.S  | 43 ++
>  libavcodec/riscv/vp9dsp_init.c | 21 +
>  2 files changed, 64 insertions(+)
> 
> diff --git a/libavcodec/riscv/vp9_mc_rvv.S b/libavcodec/riscv/vp9_mc_rvv.S
> index 5d917e7b98..986cc3760d 100644
> --- a/libavcodec/riscv/vp9_mc_rvv.S
> +++ b/libavcodec/riscv/vp9_mc_rvv.S
> @@ -53,6 +53,49 @@ func ff_avg\len\()_rvv, zve32x
>  endfunc
>  .endm
> 
> +.macro bilin_load dst len op type mn
> +.ifc \type,v
> +add t5, a2, a3
> +.elseif \type == h
> +addit5, a2, 1
> +.endif
> +vle8.v  v8, (a2)
> +vle8.v  v0, (t5)
> +vwmulu.vx   v16, v0, \mn
> +vwmaccsu.vx v16, t1, v8
> +vwadd.wxv16, v16, t4
> +vnsra.wiv16, v16, 4
> +vadd.vv \dst, v16, v8
> +.ifc \op,avg
> +vle8.v  v16, (a0)
> +vaaddu.vv   \dst, \dst, v16
> +.endif
> +.endm
> +
> +.macro bilin_h_v len op type mn
> +func ff_\op\()_bilin_\len\()\type\()_rvv, zve32x
> +.ifc \op,avg
> +csrwi   vxrm, 0
> +.endif
> +vsetvlstatic8   \len t0 64
> +li  t4, 8
> +neg t1, \mn
> +1:
> +addia4, a4, -1
> +bilin_load  v0, \len, \op, \type, \mn
> +vse8.v  v0, (a0)
> +add a2, a2, a3
> +add a0, a0, a1
> +bneza4, 1b
> +
> +ret
> +endfunc
> +.endm
> +
>  .irp len 64, 32, 16, 8, 4

Missing comma after len

>  copy_avg \len
> +.irp op put avg
> +bilin_h_v \len \op h a5
> +bilin_h_v \len \op v a6
> +.endr
>  .endr
> diff --git a/libavcodec/riscv/vp9dsp_init.c b/libavcodec/riscv/vp9dsp_init.c
> index 1922484a1d..ec6db51774 100644
> --- a/libavcodec/riscv/vp9dsp_init.c
> +++ b/libavcodec/riscv/vp9dsp_init.c
> @@ -63,6 +63,27 @@ static av_cold void vp9dsp_mc_init_riscv(VP9DSPContext
> *dsp, int bpp) init_fpel(3, 8);
>  init_fpel(4, 4);
> 
> +dsp->mc[0][FILTER_BILINEAR ][0][0][1] = ff_put_bilin_64v_rvv;
> +dsp->mc[0][FILTER_BILINEAR ][0][1][0] = ff_put_bilin_64h_rvv;
> +dsp->mc[0][FILTER_BILINEAR ][1][0][1] = ff_avg_bilin_64v_rvv;
> +dsp->mc[0][FILTER_BILINEAR ][1][1][0] = ff_avg_bilin_64h_rvv;
> +dsp->mc[1][FILTER_BILINEAR ][0][0][1] = ff_put_bilin_32v_rvv;
> +dsp->mc[1][FILTER_BILINEAR ][0][1][0] = ff_put_bilin_32h_rvv;
> +dsp->mc[1][FILTER_BILINEAR ][1][0][1] = ff_avg_bilin_32v_rvv;
> +dsp->mc[1][FILTER_BILINEAR ][1][1][0] = ff_avg_bilin_32h_rvv;
> +dsp->mc[2][FILTER_BILINEAR ][0][0][1] = ff_put_bilin_16v_rvv;
> +dsp->mc[2][FILTER_BILINEAR ][0][1][0] = ff_put_bilin_16h_rvv;
> +dsp->mc[2][FILTER_BILINEAR ][1][0][1] = ff_avg_bilin_16v_rvv;
> +dsp->mc[2][FILTER_BILINEAR ][1][1][0] = ff_avg_bilin_16h_rvv;
> +dsp->mc[3][FILTER_BILINEAR ][0][0][1] = ff_put_bilin_8v_rvv;
> +dsp->mc[3][FILTER_BILINEAR ][0][1][0] = ff_put_bilin_8h_rvv;
> +dsp->mc[3][FILTER_BILINEAR ][1][0][1] = ff_avg_bilin_8v_rvv;
> +dsp->mc[3][FILTER_BILINEAR ][1][1][0] = ff_avg_bilin_8h_rvv;
> +dsp->mc[4][FILTER_BILINEAR ][0][0][1] = ff_put_bilin_4v_rvv;
> +dsp->mc[4][FILTER_BILINEAR ][0][1][0] = ff_put_bilin_4h_rvv;
> +dsp->mc[4][FILTER_BILINEAR ][1][0][1] = ff_avg_bilin_4v_rvv;
> +dsp->mc[4][FILTER_BILINEAR ][1][1][0] = ff_avg_bilin_4h_rvv;
> +
>  #undef

[FFmpeg-devel] [PATCH 1/5] fftools/ffmpeg_demux: also set -ch_layout avcodec option for -ch_layout CLI param

2024-05-18 Thread Marton Balint
The code only set the channel layout of the AVFormatContext, so the user could
not override the channel layout if the demuxer did not have such parameter.
Let's set the specified channel layouts as codec options as well.

Fixes ticket #11016.

A regression since 639c2f00497257cb60ecaeeac1aacfa80df3be06.

Signed-off-by: Marton Balint 
---
 doc/ffmpeg.texi|  7 ---
 fftools/ffmpeg_demux.c | 46 +-
 2 files changed, 32 insertions(+), 21 deletions(-)

diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index da37e3ad37..83db6584fd 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -1689,9 +1689,10 @@ demuxers and is mapped to the corresponding demuxer 
options.
 @item -aq @var{q} (@emph{output})
 Set the audio quality (codec-specific, VBR). This is an alias for -q:a.
 @item -ac[:@var{stream_specifier}] @var{channels} 
(@emph{input/output,per-stream})
-Set the number of audio channels. For output streams it is set by
-default to the number of input audio channels. For input streams
-this option only makes sense for audio grabbing devices and raw demuxers
+Set the number of audio channels. For output streams it is set by default to
+the number of input audio channels. For input streams it overrides the number
+of channels if the decoder allows it. When used without a stream specifier it
+also sets the input channel count for audio grabbing devices and raw demuxers
 and is mapped to the corresponding demuxer options.
 @item -an (@emph{input/output})
 As an input option, blocks all audio streams of a file from being filtered or
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index cba63dab5f..6e23079ceb 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -1524,6 +1524,33 @@ static Demuxer *demux_alloc(void)
 return d;
 }
 
+static int set_input_ch_layout_opts(const OptionsContext *o)
+{
+/* "ch_layout" is only a valid format option for some formats, but we set
+ * it anyway, because it is also a codec option and we don't report
+ * unconsumed format options if they are codec options as well. */
+for (int i = 0; i < o->audio_channels.nb_opt; i++) {
+char val[32];
+char *spec = o->audio_channels.opt[i].specifier;
+char *key = av_asprintf("ch_layout%s%s", spec[0] ? ":" : "", spec);
+if (!key)
+return AVERROR(ENOMEM);
+snprintf(val, sizeof(val), "%dC", o->audio_channels.opt[i].u.i);
+av_dict_set(&o->g->format_opts, key, val, 0);
+av_dict_set(&o->g->codec_opts,  key, val, AV_DICT_DONT_STRDUP_KEY);
+}
+for (int i = 0; i < o->audio_ch_layouts.nb_opt; i++) {
+char *val = o->audio_ch_layouts.opt[i].u.str;
+char *spec = o->audio_ch_layouts.opt[i].specifier;
+char *key = av_asprintf("ch_layout%s%s", spec[0] ? ":" : "", spec);
+if (!key)
+return AVERROR(ENOMEM);
+av_dict_set(&o->g->format_opts, key, val, 0);
+av_dict_set(&o->g->codec_opts,  key, val, AV_DICT_DONT_STRDUP_KEY);
+}
+return 0;
+}
+
 int ifile_open(const OptionsContext *o, const char *filename, Scheduler *sch)
 {
 Demuxer   *d;
@@ -1592,24 +1619,6 @@ int ifile_open(const OptionsContext *o, const char 
*filename, Scheduler *sch)
 if (o->audio_sample_rate.nb_opt) {
 av_dict_set_int(&o->g->format_opts, "sample_rate", 
o->audio_sample_rate.opt[o->audio_sample_rate.nb_opt - 1].u.i, 0);
 }
-if (o->audio_channels.nb_opt) {
-const AVClass *priv_class;
-if (file_iformat && (priv_class = file_iformat->priv_class) &&
-av_opt_find(&priv_class, "ch_layout", NULL, 0,
-AV_OPT_SEARCH_FAKE_OBJ)) {
-char buf[32];
-snprintf(buf, sizeof(buf), "%dC", 
o->audio_channels.opt[o->audio_channels.nb_opt - 1].u.i);
-av_dict_set(&o->g->format_opts, "ch_layout", buf, 0);
-}
-}
-if (o->audio_ch_layouts.nb_opt) {
-const AVClass *priv_class;
-if (file_iformat && (priv_class = file_iformat->priv_class) &&
-av_opt_find(&priv_class, "ch_layout", NULL, 0,
-AV_OPT_SEARCH_FAKE_OBJ)) {
-av_dict_set(&o->g->format_opts, "ch_layout", 
o->audio_ch_layouts.opt[o->audio_ch_layouts.nb_opt - 1].u.str, 0);
-}
-}
 if (o->frame_rates.nb_opt) {
 const AVClass *priv_class;
 /* set the format-level framerate option;
@@ -1626,6 +1635,7 @@ int ifile_open(const OptionsContext *o, const char 
*filename, Scheduler *sch)
 }
 if (o->frame_pix_fmts.nb_opt)
 av_dict_set(&o->g->format_opts, "pixel_format", 
o->frame_pix_fmts.opt[o->frame_pix_fmts.nb_opt - 1].u.str, 0);
+ret = set_input_ch_layout_opts(o);
 
 video_codec_name= opt_match_per_type_str(&o->codec_names, 'v');
 audio_codec_name= opt_match_per_type_str(&o->codec_names, 'a');
-- 
2.35.3

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmp

[FFmpeg-devel] [PATCH 2/5] doc/ffmpeg: document -channel_layout/ch_layout options

2024-05-18 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 doc/ffmpeg.texi | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index 83db6584fd..9b490f523f 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -1720,6 +1720,16 @@ This is an alias for @code{-filter:a}, see the 
@ref{filter_option,,-filter optio
 @table @option
 @item -atag @var{fourcc/tag} (@emph{output})
 Force audio tag/fourcc. This is an alias for @code{-tag:a}.
+@item -ch_layout[:@var{stream_specifier}] @var{layout} 
(@emph{input/output,per-stream})
+@item -channel_layout[:@var{stream_specifier}] @var{layout} 
(@emph{input/output,per-stream})
+Set the audio channel layout. For output streams it is set by default to the
+input channel layout. For input streams it overrides the channel layout if the
+decoder allows it. When used without a stream specifier it also sets the input
+channel layout for audio grabbing devices and raw demuxers and is mapped to the
+corresponding demuxer options.
+
+Note that specifying a channel layout also sets the channel count and this
+option has precedence over the @code{-ac} option.
 @item -guess_layout_max @var{channels} (@emph{input,per-stream})
 If some input channel layout is not known, try to guess only if it
 corresponds to at most the specified number of channels. For example, 2
-- 
2.35.3

___
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] fftools: move check_avoptions and remove_avoptions to cmdutils

2024-05-18 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 fftools/cmdutils.c | 20 
 fftools/cmdutils.h |  6 ++
 fftools/ffmpeg.c   | 20 
 fftools/ffmpeg.h   |  3 ---
 4 files changed, 26 insertions(+), 23 deletions(-)

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index a8f5c6d89b..8953b21e23 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -1146,3 +1146,23 @@ char *file_read(const char *filename)
 return NULL;
 return str;
 }
+
+void remove_avoptions(AVDictionary **a, AVDictionary *b)
+{
+const AVDictionaryEntry *t = NULL;
+
+while ((t = av_dict_iterate(b, t))) {
+av_dict_set(a, t->key, NULL, AV_DICT_MATCH_CASE);
+}
+}
+
+int check_avoptions(AVDictionary *m)
+{
+const AVDictionaryEntry *t;
+if ((t = av_dict_get(m, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
+av_log(NULL, AV_LOG_FATAL, "Option %s not found.\n", t->key);
+return AVERROR_OPTION_NOT_FOUND;
+}
+
+return 0;
+}
diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h
index d0c773663b..2125f791d0 100644
--- a/fftools/cmdutils.h
+++ b/fftools/cmdutils.h
@@ -483,4 +483,10 @@ double get_rotation(const int32_t *displaymatrix);
 /* read file contents into a string */
 char *file_read(const char *filename);
 
+/* Remove keys in dictionary b from dictionary a */
+void remove_avoptions(AVDictionary **a, AVDictionary *b);
+
+/* Check if any keys exist in dictionary m */
+int check_avoptions(AVDictionary *m);
+
 #endif /* FFTOOLS_CMDUTILS_H */
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 1f50ed6805..88ce3007e8 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -473,26 +473,6 @@ const FrameData *packet_data_c(AVPacket *pkt)
 return ret < 0 ? NULL : (const FrameData*)pkt->opaque_ref->data;
 }
 
-void remove_avoptions(AVDictionary **a, AVDictionary *b)
-{
-const AVDictionaryEntry *t = NULL;
-
-while ((t = av_dict_iterate(b, t))) {
-av_dict_set(a, t->key, NULL, AV_DICT_MATCH_CASE);
-}
-}
-
-int check_avoptions(AVDictionary *m)
-{
-const AVDictionaryEntry *t;
-if ((t = av_dict_get(m, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
-av_log(NULL, AV_LOG_FATAL, "Option %s not found.\n", t->key);
-return AVERROR_OPTION_NOT_FOUND;
-}
-
-return 0;
-}
-
 void update_benchmark(const char *fmt, ...)
 {
 if (do_benchmark_all) {
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 885a7c0c10..fe75706afd 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -710,9 +710,6 @@ void term_exit(void);
 
 void show_usage(void);
 
-void remove_avoptions(AVDictionary **a, AVDictionary *b);
-int check_avoptions(AVDictionary *m);
-
 int assert_file_overwrite(const char *filename);
 AVDictionary *strip_specifiers(const AVDictionary *dict);
 int find_codec(void *logctx, const char *name,
-- 
2.35.3

___
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/5] fftools/ffplay: use cmdutils code for checking remaining avoptions

2024-05-18 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 fftools/ffplay.c | 13 -
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index b9d11eecee..ff48fa5f8c 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -2626,7 +2626,6 @@ static int stream_component_open(VideoState *is, int 
stream_index)
 const AVCodec *codec;
 const char *forced_codec_name = NULL;
 AVDictionary *opts = NULL;
-const AVDictionaryEntry *t = NULL;
 int sample_rate;
 AVChannelLayout ch_layout = { 0 };
 int ret = 0;
@@ -2694,11 +2693,9 @@ static int stream_component_open(VideoState *is, int 
stream_index)
 if ((ret = avcodec_open2(avctx, codec, &opts)) < 0) {
 goto fail;
 }
-if ((t = av_dict_get(opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
-av_log(NULL, AV_LOG_ERROR, "Option %s not found.\n", t->key);
-ret =  AVERROR_OPTION_NOT_FOUND;
+ret = check_avoptions(opts);
+if (ret < 0)
 goto fail;
-}
 
 is->eof = 0;
 ic->streams[stream_index]->discard = AVDISCARD_DEFAULT;
@@ -2862,11 +2859,9 @@ static int read_thread(void *arg)
 if (scan_all_pmts_set)
 av_dict_set(&format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE);
 
-if ((t = av_dict_get(format_opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
-av_log(NULL, AV_LOG_ERROR, "Option %s not found.\n", t->key);
-ret = AVERROR_OPTION_NOT_FOUND;
+ret = check_avoptions(format_opts);
+if (ret < 0)
 goto fail;
-}
 is->ic = ic;
 
 if (genpts)
-- 
2.35.3

___
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/5] fftools/ffplay: allow unused format options which are also codec options

2024-05-18 Thread Marton Balint
Same as it is handled in ffmpeg, allows using -ch_layout codec option.

Signed-off-by: Marton Balint 
---
 fftools/ffplay.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index ff48fa5f8c..1d0511b254 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -2858,6 +2858,7 @@ static int read_thread(void *arg)
 }
 if (scan_all_pmts_set)
 av_dict_set(&format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE);
+remove_avoptions(&format_opts, codec_opts);
 
 ret = check_avoptions(format_opts);
 if (ret < 0)
-- 
2.35.3

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

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


Re: [FFmpeg-devel] [PATCH 1/3] avformat/mp3dec: only call ffio_ensure_seekback once

2024-05-18 Thread Marton Balint




On Tue, 14 May 2024, Marton Balint wrote:


Otherwise the subsequent ffio_ensure_seekback calls destroy the buffer of the
earlier. The worst case ~66kB seekback is so small it is easier to request it
entirely.

Fixes ticket #10837, a regression since
0d17f5228f4d3854066ec1001f69c7d1714b0df9.


Will apply the series in 1-2 days.

Regards,
Marton



Signed-off-by: Marton Balint 
---
libavformat/mp3dec.c | 8 +---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
index ec6cf567bc..78d6c8c71c 100644
--- a/libavformat/mp3dec.c
+++ b/libavformat/mp3dec.c
@@ -32,6 +32,7 @@
#include "replaygain.h"

#include "libavcodec/codec_id.h"
+#include "libavcodec/mpegaudio.h"
#include "libavcodec/mpegaudiodecheader.h"

#define XING_FLAG_FRAMES 0x01
@@ -400,15 +401,16 @@ static int mp3_read_header(AVFormatContext *s)
if (ret < 0)
return ret;

+ret = ffio_ensure_seekback(s->pb, 64 * 1024 + MPA_MAX_CODED_FRAME_SIZE + 
4);
+if (ret < 0)
+return ret;
+
off = avio_tell(s->pb);
for (i = 0; i < 64 * 1024; i++) {
uint32_t header, header2;
int frame_size;
-if (!(i&1023))
-ffio_ensure_seekback(s->pb, i + 1024 + 4);
frame_size = check(s->pb, off + i, &header);
if (frame_size > 0) {
-ffio_ensure_seekback(s->pb, i + 1024 + frame_size + 4);
ret = check(s->pb, off + i + frame_size, &header2);
if (ret >= 0 &&
(header & MP3_MASK) == (header2 & MP3_MASK))
--
2.35.3

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

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


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

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


Re: [FFmpeg-devel] [PATCH 1/4] avcodec/adts_parser: Don't presume buffer to be padded

2024-05-18 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> The documentation of av_adts_header_parse() does not require
> the buffer to be padded at all.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/adts_parser.c | 7 ++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/adts_parser.c b/libavcodec/adts_parser.c
> index 6c22c86ef2..81e2669149 100644
> --- a/libavcodec/adts_parser.c
> +++ b/libavcodec/adts_parser.c
> @@ -28,9 +28,14 @@
>  int av_adts_header_parse(const uint8_t *buf, uint32_t *samples, uint8_t 
> *frames)
>  {
>  #if CONFIG_ADTS_HEADER
> +uint8_t tmpbuf[AV_AAC_ADTS_HEADER_SIZE + AV_INPUT_BUFFER_PADDING_SIZE];
>  GetBitContext gb;
>  AACADTSHeaderInfo hdr;
> -int err = init_get_bits8(&gb, buf, AV_AAC_ADTS_HEADER_SIZE);
> +int err;
> +if (!buf)
> +return AVERROR(EINVAL);
> +memcpy(tmpbuf, buf, AV_AAC_ADTS_HEADER_SIZE);
> +err = init_get_bits8(&gb, tmpbuf, AV_AAC_ADTS_HEADER_SIZE);
>  if (err < 0)
>  return err;
>  err = ff_adts_header_parse(&gb, &hdr);

Will apply this patchset with the remarks by Andrew and James addressed
tomorrow unless there are objections.

- Andreas

___
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] doc/developer: add examples to clarify code style

2024-05-18 Thread Marvin Scholz
Given the frequency that new developers, myself included, get the
code style wrong, it is useful to add some examples to clarify how
things should be done.
---
 doc/developer.texi | 57 +-
 1 file changed, 56 insertions(+), 1 deletion(-)

diff --git a/doc/developer.texi b/doc/developer.texi
index 63835dfa06..d7bf3f9cb8 100644
--- a/doc/developer.texi
+++ b/doc/developer.texi
@@ -115,7 +115,7 @@ Objective-C where required for interacting with 
macOS-specific interfaces.
 
 @section Code formatting conventions
 
-There are the following guidelines regarding the indentation in files:
+There are the following guidelines regarding the code style in files:
 
 @itemize @bullet
 @item
@@ -135,6 +135,61 @@ K&R coding style is used.
 @end itemize
 The presentation is one inspired by 'indent -i4 -kr -nut'.
 
+@subsection Examples
+Some notable examples to illustrate common code style in FFmpeg:
+
+@itemize @bullet
+
+@item
+Spaces around @code{if}/@code{do}/@code{while}/@code{for} conditions and 
assigments:
+
+@example c
+if (condition)
+av_foo();
+@end example
+
+@example c
+for (size_t i = 0; i < len; i++)
+av_bar(i);
+@end example
+
+@example c
+size_t size = 0;
+@end example
+
+However no spaces between the parentheses and condition, unless it helps
+readability of complex conditions, so the following should not be done:
+
+@example c
+// Wrong:
+if ( cond )
+av_foo();
+@end example
+
+@item
+No unnecessary parentheses, unless it helps readability:
+
+@example c
+flags = s->mb_x ? RIGHT_EDGE : LEFT_EDGE | RIGHT_EDGE;
+@end example
+
+@item
+No braces around single-line blocks:
+
+@example c
+if (bits_pixel == 24)
+avctx->pix_fmt = AV_PIX_FMT_BGR24;
+else if (bits_pixel == 8)
+avctx->pix_fmt = AV_PIX_FMT_GRAY8;
+else @{
+av_log(avctx, AV_LOG_ERROR, "Invalid pixel format.\n");
+return AVERROR_INVALIDDATA;
+@}
+@end example
+
+@end itemize
+
+
 @subsection Vim configuration
 In order to configure Vim to follow FFmpeg formatting conventions, paste
 the following snippet into your @file{.vimrc}:

base-commit: 86e418ffd7bbdc0530e1e4d5bd7534b6e03b5b05
-- 
2.39.3 (Apple Git-145)
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH v4 3/5] lavc/vp9dsp: R-V V mc tap h v

2024-05-18 Thread uk7b
From: sunyuechi 

 C908   X60
vp9_avg_8tap_smooth_4h_8bpp_c  :   13.0   11.2
vp9_avg_8tap_smooth_4h_8bpp_rvv_i32:5.04.2
vp9_avg_8tap_smooth_4v_8bpp_c  :   13.7   12.5
vp9_avg_8tap_smooth_4v_8bpp_rvv_i32:5.04.2
vp9_avg_8tap_smooth_8h_8bpp_c  :   49.5   42.2
vp9_avg_8tap_smooth_8h_8bpp_rvv_i32:9.28.5
vp9_avg_8tap_smooth_8v_8bpp_c  :   66.5   45.0
vp9_avg_8tap_smooth_8v_8bpp_rvv_i32:9.58.5
vp9_avg_8tap_smooth_16h_8bpp_c :  192.7  166.5
vp9_avg_8tap_smooth_16h_8bpp_rvv_i32   :   21.2   18.7
vp9_avg_8tap_smooth_16v_8bpp_c :  192.2  175.7
vp9_avg_8tap_smooth_16v_8bpp_rvv_i32   :   21.5   19.0
vp9_avg_8tap_smooth_32h_8bpp_c :  780.2  663.7
vp9_avg_8tap_smooth_32h_8bpp_rvv_i32   :   83.5   60.0
vp9_avg_8tap_smooth_32v_8bpp_c :  770.5  689.2
vp9_avg_8tap_smooth_32v_8bpp_rvv_i32   :   67.2   60.0
vp9_avg_8tap_smooth_64h_8bpp_c : 3115.5 2647.2
vp9_avg_8tap_smooth_64h_8bpp_rvv_i32   :  283.5  119.2
vp9_avg_8tap_smooth_64v_8bpp_c : 3082.2 2729.0
vp9_avg_8tap_smooth_64v_8bpp_rvv_i32   :  305.2  119.0
vp9_put_8tap_smooth_4h_8bpp_c  :   11.29.7
vp9_put_8tap_smooth_4h_8bpp_rvv_i32:4.24.0
vp9_put_8tap_smooth_4v_8bpp_c  :   11.7   10.7
vp9_put_8tap_smooth_4v_8bpp_rvv_i32:4.24.0
vp9_put_8tap_smooth_8h_8bpp_c  :   42.0   37.5
vp9_put_8tap_smooth_8h_8bpp_rvv_i32:8.57.7
vp9_put_8tap_smooth_8v_8bpp_c  :   44.2   38.7
vp9_put_8tap_smooth_8v_8bpp_rvv_i32:8.57.7
vp9_put_8tap_smooth_16h_8bpp_c :  165.7  147.2
vp9_put_8tap_smooth_16h_8bpp_rvv_i32   :   19.5   17.5
vp9_put_8tap_smooth_16v_8bpp_c :  169.0  149.7
vp9_put_8tap_smooth_16v_8bpp_rvv_i32   :   19.7   17.5
vp9_put_8tap_smooth_32h_8bpp_c :  659.7  586.7
vp9_put_8tap_smooth_32h_8bpp_rvv_i32   :   64.2   57.2
vp9_put_8tap_smooth_32v_8bpp_c :  680.5  591.2
vp9_put_8tap_smooth_32v_8bpp_rvv_i32   :   64.2   57.2
vp9_put_8tap_smooth_64h_8bpp_c : 2681.5 2339.0
vp9_put_8tap_smooth_64h_8bpp_rvv_i32   :  255.5  114.2
vp9_put_8tap_smooth_64v_8bpp_c : 2709.7 2348.7
vp9_put_8tap_smooth_64v_8bpp_rvv_i32   :  255.5  114.0
---
 libavcodec/riscv/vp9_mc_rvv.S  | 243 +
 libavcodec/riscv/vp9dsp.h  |  72 ++
 libavcodec/riscv/vp9dsp_init.c |  40 +-
 3 files changed, 329 insertions(+), 26 deletions(-)

diff --git a/libavcodec/riscv/vp9_mc_rvv.S b/libavcodec/riscv/vp9_mc_rvv.S
index b0052c0ece..9d7caeb005 100644
--- a/libavcodec/riscv/vp9_mc_rvv.S
+++ b/libavcodec/riscv/vp9_mc_rvv.S
@@ -36,6 +36,18 @@
 .endif
 .endm
 
+.macro vsetvlstatic16 len
+.ifc \len,4
+vsetvli zero, zero, e16, mf2, ta, ma
+.elseif \len == 8
+vsetvli zero, zero, e16, m1, ta, ma
+.elseif \len == 16
+vsetvli zero, zero, e16, m2, ta, ma
+.else
+vsetvli zero, zero, e16, m4, ta, ma
+.endif
+.endm
+
 .macro copy_avg len
 func ff_avg\len\()_rvv, zve32x
 csrwi   vxrm, 0
@@ -92,10 +104,241 @@ func ff_\op\()_bilin_\len\()\type\()_rvv, zve32x
 endfunc
 .endm
 
+const subpel_filters_regular
+.byte  0,  0,   0, 128,   0,   0,  0,  0
+.byte  0,  1,  -5, 126,   8,  -3,  1,  0
+.byte -1,  3, -10, 122,  18,  -6,  2,  0
+.byte -1,  4, -13, 118,  27,  -9,  3, -1
+.byte -1,  4, -16, 112,  37, -11,  4, -1
+.byte -1,  5, -18, 105,  48, -14,  4, -1
+.byte -1,  5, -19,  97,  58, -16,  5, -1
+.byte -1,  6, -19,  88,  68, -18,  5, -1
+.byte -1,  6, -19,  78,  78, -19,  6, -1
+.byte -1,  5, -18,  68,  88, -19,  6, -1
+.byte -1,  5, -16,  58,  97, -19,  5, -1
+.byte -1,  4, -14,  48, 105, -18,  5, -1
+.byte -1,  4, -11,  37, 112, -16,  4, -1
+.byte -1,  3,  -9,  27, 118, -13,  4, -1
+.byte  0,  2,  -6,  18, 122, -10,  3, -1
+.byte  0,  1,  -3,   8, 126,  -5,  1,  0
+subpel_filters_sharp:
+.byte  0,  0,   0, 128,   0,   0,  0,  0
+.byte -1,  3,  -7, 127,   8,  -3,  1,  0
+.byte -2,  5, -13, 125,  17,  -6,  3, -1
+.byte -3,  7, -17, 121,  27, -10,  5, -2
+.byte -4,  9, -20, 115,  37, -13,  6, -2
+.byte -4, 10, -23, 108,  48, -16,  8, -3
+.byte -4, 10, -24, 100,  59, -19,  9, -3
+.byte -4, 11, -24,  90,  70, -21, 10, -4
+.byte -4, 11, -23,  80,  80, -23, 11, -4

[FFmpeg-devel] [PATCH v4 5/5] lavc/vp9dsp: R-V V mc tap hv

2024-05-18 Thread uk7b
From: sunyuechi 

 C908   X60
vp9_avg_8tap_smooth_4hv_8bpp_c :   32.0   28.2
vp9_avg_8tap_smooth_4hv_8bpp_rvv_i32   :   15.0   13.2
vp9_avg_8tap_smooth_8hv_8bpp_c :   98.0   86.2
vp9_avg_8tap_smooth_8hv_8bpp_rvv_i32   :   23.7   21.0
vp9_avg_8tap_smooth_16hv_8bpp_c:  355.5  297.0
vp9_avg_8tap_smooth_16hv_8bpp_rvv_i32  :   62.7   41.2
vp9_avg_8tap_smooth_32hv_8bpp_c: 1273.0 1099.7
vp9_avg_8tap_smooth_32hv_8bpp_rvv_i32  :  133.7  119.2
vp9_avg_8tap_smooth_64hv_8bpp_c: 4933.0 4240.5
vp9_avg_8tap_smooth_64hv_8bpp_rvv_i32  :  506.7  227.0
vp9_put_8tap_smooth_4hv_8bpp_c :   30.2   27.0
vp9_put_8tap_smooth_4hv_8bpp_rvv_i32   :   14.5   12.7
vp9_put_8tap_smooth_8hv_8bpp_c :   91.2   81.2
vp9_put_8tap_smooth_8hv_8bpp_rvv_i32   :   22.7   20.2
vp9_put_8tap_smooth_16hv_8bpp_c:  329.2  277.7
vp9_put_8tap_smooth_16hv_8bpp_rvv_i32  :   44.7   40.0
vp9_put_8tap_smooth_32hv_8bpp_c: 1183.7 1022.7
vp9_put_8tap_smooth_32hv_8bpp_rvv_i32  :  130.7  116.5
vp9_put_8tap_smooth_64hv_8bpp_c: 4502.7 3954.5
vp9_put_8tap_smooth_64hv_8bpp_rvv_i32  :  496.0  224.7
---
 libavcodec/riscv/vp9_mc_rvv.S  | 75 ++
 libavcodec/riscv/vp9dsp_init.c |  8 
 2 files changed, 83 insertions(+)

diff --git a/libavcodec/riscv/vp9_mc_rvv.S b/libavcodec/riscv/vp9_mc_rvv.S
index d2c9393fc9..8dba76297b 100644
--- a/libavcodec/riscv/vp9_mc_rvv.S
+++ b/libavcodec/riscv/vp9_mc_rvv.S
@@ -362,6 +362,77 @@ func ff_\op\()_8tap_\name\()_\len\()\type\()_rvv\vlen\(), 
zve32x
 endfunc
 .endm
 
+#if __riscv_xlen == 64
+.macro epel_hv_once len name op
+sub a2, a2, a3
+sub a2, a2, a3
+sub a2, a2, a3
+.irp n,0,2,4,6,8,10,12,14
+epel_load_inc   v\n \len put \name h 1 t
+.endr
+addia4, a4, -1
+1:
+addia4, a4, -1
+epel_load   v30 \len \op \name v 0 s
+vse8.v  v30, (a0)
+vmv.v.v v0, v2
+vmv.v.v v2, v4
+vmv.v.v v4, v6
+vmv.v.v v6, v8
+vmv.v.v v8, v10
+vmv.v.v v10, v12
+vmv.v.v v12, v14
+epel_load   v14 \len put \name h 1 t
+add a2, a2, a3
+add a0, a0, a1
+bneza4, 1b
+epel_load   v30 \len \op \name v 0 s
+vse8.v  v30, (a0)
+.endm
+
+.macro epel_hv op name len vlen
+func ff_\op\()_8tap_\name\()_\len\()hv_rvv\vlen\(), zve32x
+addisp, sp, -64
+.irp n,0,1,2,3,4,5,6,7
+sd  s\n, \n\()<<3(sp)
+.endr
+.if \len == 64 && \vlen < 256
+addisp, sp, -48
+.irp n,0,1,2,3,4,5
+sd  a\n, \n\()<<3(sp)
+.endr
+.endif
+.ifc \op,avg
+csrwi   vxrm, 0
+.endif
+epel_filter \name h t
+epel_filter \name v s
+.if \vlen < 256
+vsetvlstatic8   \len a6 32 m2
+.else
+vsetvlstatic8   \len a6 64 m2
+.endif
+epel_hv_once\len \name \op
+.if \len == 64 && \vlen < 256
+.irp n,0,1,2,3,4,5
+ld  a\n, \n\()<<3(sp)
+.endr
+addisp, sp, 48
+addia0, a0, 32
+addia2, a2, 32
+epel_filter \name h t
+epel_hv_once\len \name \op
+.endif
+.irp n,0,1,2,3,4,5,6,7
+ld  s\n, \n\()<<3(sp)
+.endr
+addisp, sp, 64
+
+ret
+endfunc
+.endm
+#endif
+
 .irp len, 64, 32, 16, 8, 4
 copy_avg \len
 .irp op, put, avg
@@ -373,6 +444,10 @@ endfunc
 epel \len \op \name \type 128
 epel \len \op \name \type 256
 .endr
+#if __riscv_xlen == 64
+epel_hv \op \name \len 128
+epel_hv \op \name \len 256
+#endif
 .endr
 .endr
 .endr
diff --git a/libavcodec/riscv/vp9dsp_init.c b/libavcodec/riscv/vp9dsp_init.c
index 09519f4005..fe05d118de 100644
--- a/libavcodec/riscv/vp9dsp_init.c
+++ b/libavcodec/riscv/vp9dsp_init.c
@@ -118,6 +118,10 @@ static av_cold void vp9dsp_mc_init_riscv(VP9DSPContext 
*dsp, int bpp)
 if (flags & AV_CPU_FLAG_RVB_ADDR) {
 init_subpel2(0, 0, 1, v, put, 128);
 init_subpel2(1, 0, 1, v, avg, 128);
+# if __riscv_xlen == 64
+init_subpel2(0, 1, 1, hv, put, 128);
+init_subpel2(1, 1, 1, hv, avg, 128);
+# endif
 }
 
 }
@@ -128,6 +132,10 @@ static av_cold void vp9dsp_mc_init

[FFmpeg-devel] [PATCH v4 2/5] lavc/vp9dsp: R-V V mc bilin h v

2024-05-18 Thread uk7b
From: sunyuechi 

C908:
vp9_avg_bilin_4h_8bpp_c: 5.2
vp9_avg_bilin_4h_8bpp_rvv_i64: 2.2
vp9_avg_bilin_4v_8bpp_c: 5.5
vp9_avg_bilin_4v_8bpp_rvv_i64: 2.2
vp9_avg_bilin_8h_8bpp_c: 20.0
vp9_avg_bilin_8h_8bpp_rvv_i64: 4.5
vp9_avg_bilin_8v_8bpp_c: 21.0
vp9_avg_bilin_8v_8bpp_rvv_i64: 4.2
vp9_avg_bilin_16h_8bpp_c: 78.2
vp9_avg_bilin_16h_8bpp_rvv_i64: 9.0
vp9_avg_bilin_16v_8bpp_c: 82.0
vp9_avg_bilin_16v_8bpp_rvv_i64: 9.0
vp9_avg_bilin_32h_8bpp_c: 325.5
vp9_avg_bilin_32h_8bpp_rvv_i64: 26.2
vp9_avg_bilin_32v_8bpp_c: 326.2
vp9_avg_bilin_32v_8bpp_rvv_i64: 26.2
vp9_avg_bilin_64h_8bpp_c: 1265.7
vp9_avg_bilin_64h_8bpp_rvv_i64: 91.5
vp9_avg_bilin_64v_8bpp_c: 1317.0
vp9_avg_bilin_64v_8bpp_rvv_i64: 91.2
vp9_put_bilin_4h_8bpp_c: 4.5
vp9_put_bilin_4h_8bpp_rvv_i64: 1.7
vp9_put_bilin_4v_8bpp_c: 4.7
vp9_put_bilin_4v_8bpp_rvv_i64: 1.7
vp9_put_bilin_8h_8bpp_c: 17.0
vp9_put_bilin_8h_8bpp_rvv_i64: 3.5
vp9_put_bilin_8v_8bpp_c: 18.0
vp9_put_bilin_8v_8bpp_rvv_i64: 3.5
vp9_put_bilin_16h_8bpp_c: 65.2
vp9_put_bilin_16h_8bpp_rvv_i64: 7.5
vp9_put_bilin_16v_8bpp_c: 85.7
vp9_put_bilin_16v_8bpp_rvv_i64: 7.5
vp9_put_bilin_32h_8bpp_c: 257.5
vp9_put_bilin_32h_8bpp_rvv_i64: 23.5
vp9_put_bilin_32v_8bpp_c: 274.5
vp9_put_bilin_32v_8bpp_rvv_i64: 23.5
vp9_put_bilin_64h_8bpp_c: 1040.5
vp9_put_bilin_64h_8bpp_rvv_i64: 82.5
vp9_put_bilin_64v_8bpp_c: 1108.7
vp9_put_bilin_64v_8bpp_rvv_i64: 82.2
---
 libavcodec/riscv/vp9_mc_rvv.S  | 43 ++
 libavcodec/riscv/vp9dsp_init.c | 21 +
 2 files changed, 64 insertions(+)

diff --git a/libavcodec/riscv/vp9_mc_rvv.S b/libavcodec/riscv/vp9_mc_rvv.S
index 7811cd9928..b0052c0ece 100644
--- a/libavcodec/riscv/vp9_mc_rvv.S
+++ b/libavcodec/riscv/vp9_mc_rvv.S
@@ -53,6 +53,49 @@ func ff_avg\len\()_rvv, zve32x
 endfunc
 .endm
 
+.macro bilin_load dst len op type mn
+.ifc \type,v
+add t5, a2, a3
+.else
+addit5, a2, 1
+.endif
+vle8.v  v8, (a2)
+vle8.v  v0, (t5)
+vwmulu.vx   v16, v0, \mn
+vwmaccsu.vx v16, t1, v8
+vwadd.wxv16, v16, t4
+vnsra.wiv16, v16, 4
+vadd.vv \dst, v16, v8
+.ifc \op,avg
+vle8.v  v16, (a0)
+vaaddu.vv   \dst, \dst, v16
+.endif
+.endm
+
+.macro bilin_h_v len op type mn
+func ff_\op\()_bilin_\len\()\type\()_rvv, zve32x
+.ifc \op,avg
+csrwi   vxrm, 0
+.endif
+vsetvlstatic8   \len t0 64
+li  t4, 8
+neg t1, \mn
+1:
+addia4, a4, -1
+bilin_load  v0, \len, \op, \type, \mn
+vse8.v  v0, (a0)
+add a2, a2, a3
+add a0, a0, a1
+bneza4, 1b
+
+ret
+endfunc
+.endm
+
 .irp len, 64, 32, 16, 8, 4
 copy_avg \len
+.irp op, put, avg
+bilin_h_v \len \op h a5
+bilin_h_v \len \op v a6
+.endr
 .endr
diff --git a/libavcodec/riscv/vp9dsp_init.c b/libavcodec/riscv/vp9dsp_init.c
index 6bfe23563a..565b68959f 100644
--- a/libavcodec/riscv/vp9dsp_init.c
+++ b/libavcodec/riscv/vp9dsp_init.c
@@ -63,6 +63,27 @@ static av_cold void vp9dsp_mc_init_riscv(VP9DSPContext *dsp, 
int bpp)
 init_fpel(3, 8);
 init_fpel(4, 4);
 
+dsp->mc[0][FILTER_BILINEAR ][0][0][1] = ff_put_bilin_64v_rvv;
+dsp->mc[0][FILTER_BILINEAR ][0][1][0] = ff_put_bilin_64h_rvv;
+dsp->mc[0][FILTER_BILINEAR ][1][0][1] = ff_avg_bilin_64v_rvv;
+dsp->mc[0][FILTER_BILINEAR ][1][1][0] = ff_avg_bilin_64h_rvv;
+dsp->mc[1][FILTER_BILINEAR ][0][0][1] = ff_put_bilin_32v_rvv;
+dsp->mc[1][FILTER_BILINEAR ][0][1][0] = ff_put_bilin_32h_rvv;
+dsp->mc[1][FILTER_BILINEAR ][1][0][1] = ff_avg_bilin_32v_rvv;
+dsp->mc[1][FILTER_BILINEAR ][1][1][0] = ff_avg_bilin_32h_rvv;
+dsp->mc[2][FILTER_BILINEAR ][0][0][1] = ff_put_bilin_16v_rvv;
+dsp->mc[2][FILTER_BILINEAR ][0][1][0] = ff_put_bilin_16h_rvv;
+dsp->mc[2][FILTER_BILINEAR ][1][0][1] = ff_avg_bilin_16v_rvv;
+dsp->mc[2][FILTER_BILINEAR ][1][1][0] = ff_avg_bilin_16h_rvv;
+dsp->mc[3][FILTER_BILINEAR ][0][0][1] = ff_put_bilin_8v_rvv;
+dsp->mc[3][FILTER_BILINEAR ][0][1][0] = ff_put_bilin_8h_rvv;
+dsp->mc[3][FILTER_BILINEAR ][1][0][1] = ff_avg_bilin_8v_rvv;
+dsp->mc[3][FILTER_BILINEAR ][1][1][0] = ff_avg_bilin_8h_rvv;
+dsp->mc[4][FILTER_BILINEAR ][0][0][1] = ff_put_bilin_4v_rvv;
+dsp->mc[4][FILTER_BILINEAR ][0][1][0] = ff_put_bilin_4h_rvv;
+dsp->mc[4][FILTER_BILINEAR ][1][0][1] = ff_avg_bilin_4v_rvv;
+dsp->mc[4][FILTER_BILINEAR ][1][1][0] = ff_avg_bilin_4h_rvv;
+
 #undef init_fpel
 }
 #endif
-- 
2.45.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 v4 1/5] lavc/vp9dsp: R-V V mc avg

2024-05-18 Thread uk7b
From: sunyuechi 

C908:
vp9_avg4_8bpp_c: 1.2
vp9_avg4_8bpp_rvv_i64: 1.0
vp9_avg8_8bpp_c: 3.7
vp9_avg8_8bpp_rvv_i64: 1.5
vp9_avg16_8bpp_c: 14.7
vp9_avg16_8bpp_rvv_i64: 3.5
vp9_avg32_8bpp_c: 57.7
vp9_avg32_8bpp_rvv_i64: 10.0
vp9_avg64_8bpp_c: 229.0
vp9_avg64_8bpp_rvv_i64: 31.7
---
 libavcodec/riscv/Makefile  |  3 +-
 libavcodec/riscv/vp9_mc_rvv.S  | 58 ++
 libavcodec/riscv/vp9dsp_init.c | 18 +++
 3 files changed, 78 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/riscv/vp9_mc_rvv.S

diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile
index 27b268ae39..4739d83522 100644
--- a/libavcodec/riscv/Makefile
+++ b/libavcodec/riscv/Makefile
@@ -65,6 +65,7 @@ RVV-OBJS-$(CONFIG_VP8DSP) += riscv/vp8dsp_rvv.o
 OBJS-$(CONFIG_VP9_DECODER) += riscv/vp9dsp_init.o
 RV-OBJS-$(CONFIG_VP9_DECODER) += riscv/vp9_intra_rvi.o \
  riscv/vp9_mc_rvi.o
-RVV-OBJS-$(CONFIG_VP9_DECODER) += riscv/vp9_intra_rvv.o
+RVV-OBJS-$(CONFIG_VP9_DECODER) += riscv/vp9_intra_rvv.o \
+  riscv/vp9_mc_rvv.o
 OBJS-$(CONFIG_VORBIS_DECODER) += riscv/vorbisdsp_init.o
 RVV-OBJS-$(CONFIG_VORBIS_DECODER) += riscv/vorbisdsp_rvv.o
diff --git a/libavcodec/riscv/vp9_mc_rvv.S b/libavcodec/riscv/vp9_mc_rvv.S
new file mode 100644
index 00..7811cd9928
--- /dev/null
+++ b/libavcodec/riscv/vp9_mc_rvv.S
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2024 Institue of Software Chinese Academy of Sciences (ISCAS).
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/riscv/asm.S"
+
+.macro vsetvlstatic8 len an maxlen mn=m4
+.if \len == 4
+vsetivlizero, \len, e8, mf4, ta, ma
+.elseif \len == 8
+vsetivlizero, \len, e8, mf2, ta, ma
+.elseif \len == 16
+vsetivlizero, \len, e8, m1, ta, ma
+.elseif \len == 32
+li  \an, \len
+vsetvli zero, \an, e8, m2, ta, ma
+.elseif \len == 64
+li  \an, \maxlen
+vsetvli zero, \an, e8, \mn, ta, ma
+.endif
+.endm
+
+.macro copy_avg len
+func ff_avg\len\()_rvv, zve32x
+csrwi   vxrm, 0
+vsetvlstatic8   \len t0 64
+1:
+vle8.v  v8, (a2)
+vle8.v  v16, (a0)
+vaaddu.vv   v8, v8, v16
+addia4, a4, -1
+vse8.v  v8, (a0)
+add a2, a2, a3
+add a0, a0, a1
+bneza4, 1b
+ret
+endfunc
+.endm
+
+.irp len, 64, 32, 16, 8, 4
+copy_avg \len
+.endr
diff --git a/libavcodec/riscv/vp9dsp_init.c b/libavcodec/riscv/vp9dsp_init.c
index ab99294d44..6bfe23563a 100644
--- a/libavcodec/riscv/vp9dsp_init.c
+++ b/libavcodec/riscv/vp9dsp_init.c
@@ -48,6 +48,24 @@ static av_cold void vp9dsp_mc_init_riscv(VP9DSPContext *dsp, 
int bpp)
 }
 # endif
 
+#if HAVE_RVV
+if (bpp == 8 && (flags & AV_CPU_FLAG_RVV_I32) && ff_rv_vlen_least(128)) {
+
+#define init_fpel(idx1, sz)   \
+dsp->mc[idx1][FILTER_8TAP_SMOOTH ][1][0][0] = ff_avg##sz##_rvv;  \
+dsp->mc[idx1][FILTER_8TAP_REGULAR][1][0][0] = ff_avg##sz##_rvv;  \
+dsp->mc[idx1][FILTER_8TAP_SHARP  ][1][0][0] = ff_avg##sz##_rvv;  \
+dsp->mc[idx1][FILTER_BILINEAR][1][0][0] = ff_avg##sz##_rvv
+
+init_fpel(0, 64);
+init_fpel(1, 32);
+init_fpel(2, 16);
+init_fpel(3, 8);
+init_fpel(4, 4);
+
+#undef init_fpel
+}
+#endif
 #endif
 }
 
-- 
2.45.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 v4 4/5] lavc/vp9dsp: R-V V mc bilin hv

2024-05-18 Thread uk7b
From: sunyuechi 

C908:
vp9_avg_bilin_4hv_8bpp_c: 11.0
vp9_avg_bilin_4hv_8bpp_rvv_i64: 3.7
vp9_avg_bilin_8hv_8bpp_c: 38.7
vp9_avg_bilin_8hv_8bpp_rvv_i64: 7.2
vp9_avg_bilin_16hv_8bpp_c: 147.0
vp9_avg_bilin_16hv_8bpp_rvv_i64: 14.2
vp9_avg_bilin_32hv_8bpp_c: 574.5
vp9_avg_bilin_32hv_8bpp_rvv_i64: 42.7
vp9_avg_bilin_64hv_8bpp_c: 2311.5
vp9_avg_bilin_64hv_8bpp_rvv_i64: 201.7
vp9_put_bilin_4hv_8bpp_c: 10.0
vp9_put_bilin_4hv_8bpp_rvv_i64: 3.2
vp9_put_bilin_8hv_8bpp_c: 35.2
vp9_put_bilin_8hv_8bpp_rvv_i64: 6.5
vp9_put_bilin_16hv_8bpp_c: 133.7
vp9_put_bilin_16hv_8bpp_rvv_i64: 13.0
vp9_put_bilin_32hv_8bpp_c: 538.2
vp9_put_bilin_32hv_8bpp_rvv_i64: 39.7
vp9_put_bilin_64hv_8bpp_c: 2114.0
vp9_put_bilin_64hv_8bpp_rvv_i64: 153.7
---
 libavcodec/riscv/vp9_mc_rvv.S  | 34 ++
 libavcodec/riscv/vp9dsp_init.c | 10 ++
 2 files changed, 44 insertions(+)

diff --git a/libavcodec/riscv/vp9_mc_rvv.S b/libavcodec/riscv/vp9_mc_rvv.S
index 9d7caeb005..d2c9393fc9 100644
--- a/libavcodec/riscv/vp9_mc_rvv.S
+++ b/libavcodec/riscv/vp9_mc_rvv.S
@@ -104,6 +104,39 @@ func ff_\op\()_bilin_\len\()\type\()_rvv, zve32x
 endfunc
 .endm
 
+.macro bilin_hv len op
+func ff_\op\()_bilin_\len\()hv_rvv, zve32x
+.ifc \op,avg
+csrwi   vxrm, 0
+.endif
+vsetvlstatic8   \len t0 64
+neg t1, a5
+neg t2, a6
+li  t4, 8
+bilin_load  v24, \len, put, h, a5
+add a2, a2, a3
+1:
+addia4, a4, -1
+bilin_load  v4, \len, put, h, a5
+vwmulu.vx   v16, v4, a6
+vwmaccsu.vx v16, t2, v24
+vwadd.wxv16, v16, t4
+vnsra.wiv16, v16, 4
+vadd.vv v0, v16, v24
+.ifc \op,avg
+vle8.v  v16, (a0)
+vaaddu.vv   v0, v0, v16
+.endif
+vse8.v  v0, (a0)
+vmv.v.v v24, v4
+add a2, a2, a3
+add a0, a0, a1
+bneza4, 1b
+
+ret
+endfunc
+.endm
+
 const subpel_filters_regular
 .byte  0,  0,   0, 128,   0,   0,  0,  0
 .byte  0,  1,  -5, 126,   8,  -3,  1,  0
@@ -334,6 +367,7 @@ endfunc
 .irp op, put, avg
 bilin_h_v \len \op h a5
 bilin_h_v \len \op v a6
+bilin_hv \len \op
 .irp name, regular, sharp, smooth
 .irp type, h, v
 epel \len \op \name \type 128
diff --git a/libavcodec/riscv/vp9dsp_init.c b/libavcodec/riscv/vp9dsp_init.c
index 931b92928a..09519f4005 100644
--- a/libavcodec/riscv/vp9dsp_init.c
+++ b/libavcodec/riscv/vp9dsp_init.c
@@ -104,6 +104,16 @@ static av_cold void vp9dsp_mc_init_riscv(VP9DSPContext 
*dsp, int bpp)
 dsp->mc[4][FILTER_BILINEAR ][0][1][0] = ff_put_bilin_4h_rvv;
 dsp->mc[4][FILTER_BILINEAR ][1][0][1] = ff_avg_bilin_4v_rvv;
 dsp->mc[4][FILTER_BILINEAR ][1][1][0] = ff_avg_bilin_4h_rvv;
+dsp->mc[0][FILTER_BILINEAR ][0][1][1] = ff_put_bilin_64hv_rvv;
+dsp->mc[0][FILTER_BILINEAR ][1][1][1] = ff_avg_bilin_64hv_rvv;
+dsp->mc[1][FILTER_BILINEAR ][0][1][1] = ff_put_bilin_32hv_rvv;
+dsp->mc[1][FILTER_BILINEAR ][1][1][1] = ff_avg_bilin_32hv_rvv;
+dsp->mc[2][FILTER_BILINEAR ][0][1][1] = ff_put_bilin_16hv_rvv;
+dsp->mc[2][FILTER_BILINEAR ][1][1][1] = ff_avg_bilin_16hv_rvv;
+dsp->mc[3][FILTER_BILINEAR ][0][1][1] = ff_put_bilin_8hv_rvv;
+dsp->mc[3][FILTER_BILINEAR ][1][1][1] = ff_avg_bilin_8hv_rvv;
+dsp->mc[4][FILTER_BILINEAR ][0][1][1] = ff_put_bilin_4hv_rvv;
+dsp->mc[4][FILTER_BILINEAR ][1][1][1] = ff_avg_bilin_4hv_rvv;
 
 if (flags & AV_CPU_FLAG_RVB_ADDR) {
 init_subpel2(0, 0, 1, v, put, 128);
-- 
2.45.1

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

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


Re: [FFmpeg-devel] [PATCH v4 1/5] lavc/vp9dsp: R-V V mc avg

2024-05-18 Thread flow gg
Fixed issues with .irp and comma, as well as the ifc issue (same
modifications as previously done for vp8).

 于2024年5月19日周日 02:16写道:

> From: sunyuechi 
>
> C908:
> vp9_avg4_8bpp_c: 1.2
> vp9_avg4_8bpp_rvv_i64: 1.0
> vp9_avg8_8bpp_c: 3.7
> vp9_avg8_8bpp_rvv_i64: 1.5
> vp9_avg16_8bpp_c: 14.7
> vp9_avg16_8bpp_rvv_i64: 3.5
> vp9_avg32_8bpp_c: 57.7
> vp9_avg32_8bpp_rvv_i64: 10.0
> vp9_avg64_8bpp_c: 229.0
> vp9_avg64_8bpp_rvv_i64: 31.7
> ---
>  libavcodec/riscv/Makefile  |  3 +-
>  libavcodec/riscv/vp9_mc_rvv.S  | 58 ++
>  libavcodec/riscv/vp9dsp_init.c | 18 +++
>  3 files changed, 78 insertions(+), 1 deletion(-)
>  create mode 100644 libavcodec/riscv/vp9_mc_rvv.S
>
> diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile
> index 27b268ae39..4739d83522 100644
> --- a/libavcodec/riscv/Makefile
> +++ b/libavcodec/riscv/Makefile
> @@ -65,6 +65,7 @@ RVV-OBJS-$(CONFIG_VP8DSP) += riscv/vp8dsp_rvv.o
>  OBJS-$(CONFIG_VP9_DECODER) += riscv/vp9dsp_init.o
>  RV-OBJS-$(CONFIG_VP9_DECODER) += riscv/vp9_intra_rvi.o \
>   riscv/vp9_mc_rvi.o
> -RVV-OBJS-$(CONFIG_VP9_DECODER) += riscv/vp9_intra_rvv.o
> +RVV-OBJS-$(CONFIG_VP9_DECODER) += riscv/vp9_intra_rvv.o \
> +  riscv/vp9_mc_rvv.o
>  OBJS-$(CONFIG_VORBIS_DECODER) += riscv/vorbisdsp_init.o
>  RVV-OBJS-$(CONFIG_VORBIS_DECODER) += riscv/vorbisdsp_rvv.o
> diff --git a/libavcodec/riscv/vp9_mc_rvv.S b/libavcodec/riscv/vp9_mc_rvv.S
> new file mode 100644
> index 00..7811cd9928
> --- /dev/null
> +++ b/libavcodec/riscv/vp9_mc_rvv.S
> @@ -0,0 +1,58 @@
> +/*
> + * Copyright (c) 2024 Institue of Software Chinese Academy of Sciences
> (ISCAS).
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> 02110-1301 USA
> + */
> +
> +#include "libavutil/riscv/asm.S"
> +
> +.macro vsetvlstatic8 len an maxlen mn=m4
> +.if \len == 4
> +vsetivlizero, \len, e8, mf4, ta, ma
> +.elseif \len == 8
> +vsetivlizero, \len, e8, mf2, ta, ma
> +.elseif \len == 16
> +vsetivlizero, \len, e8, m1, ta, ma
> +.elseif \len == 32
> +li  \an, \len
> +vsetvli zero, \an, e8, m2, ta, ma
> +.elseif \len == 64
> +li  \an, \maxlen
> +vsetvli zero, \an, e8, \mn, ta, ma
> +.endif
> +.endm
> +
> +.macro copy_avg len
> +func ff_avg\len\()_rvv, zve32x
> +csrwi   vxrm, 0
> +vsetvlstatic8   \len t0 64
> +1:
> +vle8.v  v8, (a2)
> +vle8.v  v16, (a0)
> +vaaddu.vv   v8, v8, v16
> +addia4, a4, -1
> +vse8.v  v8, (a0)
> +add a2, a2, a3
> +add a0, a0, a1
> +bneza4, 1b
> +ret
> +endfunc
> +.endm
> +
> +.irp len, 64, 32, 16, 8, 4
> +copy_avg \len
> +.endr
> diff --git a/libavcodec/riscv/vp9dsp_init.c
> b/libavcodec/riscv/vp9dsp_init.c
> index ab99294d44..6bfe23563a 100644
> --- a/libavcodec/riscv/vp9dsp_init.c
> +++ b/libavcodec/riscv/vp9dsp_init.c
> @@ -48,6 +48,24 @@ static av_cold void vp9dsp_mc_init_riscv(VP9DSPContext
> *dsp, int bpp)
>  }
>  # endif
>
> +#if HAVE_RVV
> +if (bpp == 8 && (flags & AV_CPU_FLAG_RVV_I32) &&
> ff_rv_vlen_least(128)) {
> +
> +#define init_fpel(idx1, sz)   \
> +dsp->mc[idx1][FILTER_8TAP_SMOOTH ][1][0][0] = ff_avg##sz##_rvv;  \
> +dsp->mc[idx1][FILTER_8TAP_REGULAR][1][0][0] = ff_avg##sz##_rvv;  \
> +dsp->mc[idx1][FILTER_8TAP_SHARP  ][1][0][0] = ff_avg##sz##_rvv;  \
> +dsp->mc[idx1][FILTER_BILINEAR][1][0][0] = ff_avg##sz##_rvv
> +
> +init_fpel(0, 64);
> +init_fpel(1, 32);
> +init_fpel(2, 16);
> +init_fpel(3, 8);
> +init_fpel(4, 4);
> +
> +#undef init_fpel
> +}
> +#endif
>  #endif
>  }
>
> --
> 2.45.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 mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/

Re: [FFmpeg-devel] [PATCH v3 6/9] lavc/vp9dsp: R-V V mc bilin h v

2024-05-18 Thread flow gg
fixed in v4

Rémi Denis-Courmont  于2024年5月18日周六 23:56写道:

> Le maanantaina 13. toukokuuta 2024, 19.59.23 EEST u...@foxmail.com a
> écrit :
> > From: sunyuechi 
> >
> > C908:
> > vp9_avg_bilin_4h_8bpp_c: 5.2
> > vp9_avg_bilin_4h_8bpp_rvv_i64: 2.2
> > vp9_avg_bilin_4v_8bpp_c: 5.5
> > vp9_avg_bilin_4v_8bpp_rvv_i64: 2.2
> > vp9_avg_bilin_8h_8bpp_c: 20.0
> > vp9_avg_bilin_8h_8bpp_rvv_i64: 4.5
> > vp9_avg_bilin_8v_8bpp_c: 21.0
> > vp9_avg_bilin_8v_8bpp_rvv_i64: 4.2
> > vp9_avg_bilin_16h_8bpp_c: 78.2
> > vp9_avg_bilin_16h_8bpp_rvv_i64: 9.0
> > vp9_avg_bilin_16v_8bpp_c: 82.0
> > vp9_avg_bilin_16v_8bpp_rvv_i64: 9.0
> > vp9_avg_bilin_32h_8bpp_c: 325.5
> > vp9_avg_bilin_32h_8bpp_rvv_i64: 26.2
> > vp9_avg_bilin_32v_8bpp_c: 326.2
> > vp9_avg_bilin_32v_8bpp_rvv_i64: 26.2
> > vp9_avg_bilin_64h_8bpp_c: 1265.7
> > vp9_avg_bilin_64h_8bpp_rvv_i64: 91.5
> > vp9_avg_bilin_64v_8bpp_c: 1317.0
> > vp9_avg_bilin_64v_8bpp_rvv_i64: 91.2
> > vp9_put_bilin_4h_8bpp_c: 4.5
> > vp9_put_bilin_4h_8bpp_rvv_i64: 1.7
> > vp9_put_bilin_4v_8bpp_c: 4.7
> > vp9_put_bilin_4v_8bpp_rvv_i64: 1.7
> > vp9_put_bilin_8h_8bpp_c: 17.0
> > vp9_put_bilin_8h_8bpp_rvv_i64: 3.5
> > vp9_put_bilin_8v_8bpp_c: 18.0
> > vp9_put_bilin_8v_8bpp_rvv_i64: 3.5
> > vp9_put_bilin_16h_8bpp_c: 65.2
> > vp9_put_bilin_16h_8bpp_rvv_i64: 7.5
> > vp9_put_bilin_16v_8bpp_c: 85.7
> > vp9_put_bilin_16v_8bpp_rvv_i64: 7.5
> > vp9_put_bilin_32h_8bpp_c: 257.5
> > vp9_put_bilin_32h_8bpp_rvv_i64: 23.5
> > vp9_put_bilin_32v_8bpp_c: 274.5
> > vp9_put_bilin_32v_8bpp_rvv_i64: 23.5
> > vp9_put_bilin_64h_8bpp_c: 1040.5
> > vp9_put_bilin_64h_8bpp_rvv_i64: 82.5
> > vp9_put_bilin_64v_8bpp_c: 1108.7
> > vp9_put_bilin_64v_8bpp_rvv_i64: 82.2
> > ---
> >  libavcodec/riscv/vp9_mc_rvv.S  | 43 ++
> >  libavcodec/riscv/vp9dsp_init.c | 21 +
> >  2 files changed, 64 insertions(+)
> >
> > diff --git a/libavcodec/riscv/vp9_mc_rvv.S
> b/libavcodec/riscv/vp9_mc_rvv.S
> > index 5d917e7b98..986cc3760d 100644
> > --- a/libavcodec/riscv/vp9_mc_rvv.S
> > +++ b/libavcodec/riscv/vp9_mc_rvv.S
> > @@ -53,6 +53,49 @@ func ff_avg\len\()_rvv, zve32x
> >  endfunc
> >  .endm
> >
> > +.macro bilin_load dst len op type mn
> > +.ifc \type,v
> > +add t5, a2, a3
> > +.elseif \type == h
> > +addit5, a2, 1
> > +.endif
> > +vle8.v  v8, (a2)
> > +vle8.v  v0, (t5)
> > +vwmulu.vx   v16, v0, \mn
> > +vwmaccsu.vx v16, t1, v8
> > +vwadd.wxv16, v16, t4
> > +vnsra.wiv16, v16, 4
> > +vadd.vv \dst, v16, v8
> > +.ifc \op,avg
> > +vle8.v  v16, (a0)
> > +vaaddu.vv   \dst, \dst, v16
> > +.endif
> > +.endm
> > +
> > +.macro bilin_h_v len op type mn
> > +func ff_\op\()_bilin_\len\()\type\()_rvv, zve32x
> > +.ifc \op,avg
> > +csrwi   vxrm, 0
> > +.endif
> > +vsetvlstatic8   \len t0 64
> > +li  t4, 8
> > +neg t1, \mn
> > +1:
> > +addia4, a4, -1
> > +bilin_load  v0, \len, \op, \type, \mn
> > +vse8.v  v0, (a0)
> > +add a2, a2, a3
> > +add a0, a0, a1
> > +bneza4, 1b
> > +
> > +ret
> > +endfunc
> > +.endm
> > +
> >  .irp len 64, 32, 16, 8, 4
>
> Missing comma after len
>
> >  copy_avg \len
> > +.irp op put avg
> > +bilin_h_v \len \op h a5
> > +bilin_h_v \len \op v a6
> > +.endr
> >  .endr
> > diff --git a/libavcodec/riscv/vp9dsp_init.c
> b/libavcodec/riscv/vp9dsp_init.c
> > index 1922484a1d..ec6db51774 100644
> > --- a/libavcodec/riscv/vp9dsp_init.c
> > +++ b/libavcodec/riscv/vp9dsp_init.c
> > @@ -63,6 +63,27 @@ static av_cold void vp9dsp_mc_init_riscv(VP9DSPContext
> > *dsp, int bpp) init_fpel(3, 8);
> >  init_fpel(4, 4);
> >
> > +dsp->mc[0][FILTER_BILINEAR ][0][0][1] = ff_put_bilin_64v_rvv;
> > +dsp->mc[0][FILTER_BILINEAR ][0][1][0] = ff_put_bilin_64h_rvv;
> > +dsp->mc[0][FILTER_BILINEAR ][1][0][1] = ff_avg_bilin_64v_rvv;
> > +dsp->mc[0][FILTER_BILINEAR ][1][1][0] = ff_avg_bilin_64h_rvv;
> > +dsp->mc[1][FILTER_BILINEAR ][0][0][1] = ff_put_bilin_32v_rvv;
> > +dsp->mc[1][FILTER_BILINEAR ][0][1][0] = ff_put_bilin_32h_rvv;
> > +dsp->mc[1][FILTER_BILINEAR ][1][0][1] = ff_avg_bilin_32v_rvv;
> > +dsp->mc[1][FILTER_BILINEAR ][1][1][0] = ff_avg_bilin_32h_rvv;
> > +dsp->mc[2][FILTER_BILINEAR ][0][0][1] = ff_put_bilin_16v_rvv;
> > +dsp->mc[2][FILTER_BILINEAR ][0][1][0] = ff_put_bilin_16h_rvv;
> > +dsp->mc[2][FILTER_BILINEAR ][1][0][1] = ff_avg_bilin_16v_rvv;
> > +dsp->mc[2][FILTER_BILINEAR ][1][1][0] = ff_avg_bilin_16h_rvv;
> > +dsp->mc[3][FILTER_BILINEAR ][0][0][1] = ff_put_bilin_8v_rvv;
> > +dsp->mc[3][FILTER_BILINEAR ][0][1][0] = ff_put_bilin_8h_rvv;
> > +dsp->mc[3][FILTER_BILINEAR ][1][0][1] = ff_avg_bilin_8v_rvv;
> > +dsp->mc[3][FILTER_BILINEAR ]

Re: [FFmpeg-devel] [PATCH] doc/developer: add examples to clarify code style

2024-05-18 Thread Andrew Sayers
I would have found this very helpful!

On Sat, May 18, 2024 at 07:00:50PM +0200, Marvin Scholz wrote:
> Given the frequency that new developers, myself included, get the
> code style wrong, it is useful to add some examples to clarify how
> things should be done.
> ---
>  doc/developer.texi | 57 +-
>  1 file changed, 56 insertions(+), 1 deletion(-)
> 
> diff --git a/doc/developer.texi b/doc/developer.texi
> index 63835dfa06..d7bf3f9cb8 100644
> --- a/doc/developer.texi
> +++ b/doc/developer.texi
> @@ -115,7 +115,7 @@ Objective-C where required for interacting with 
> macOS-specific interfaces.
>  
>  @section Code formatting conventions
>  
> -There are the following guidelines regarding the indentation in files:
> +There are the following guidelines regarding the code style in files:
>  
>  @itemize @bullet
>  @item
> @@ -135,6 +135,61 @@ K&R coding style is used.
>  @end itemize
>  The presentation is one inspired by 'indent -i4 -kr -nut'.
>  
> +@subsection Examples
> +Some notable examples to illustrate common code style in FFmpeg:
> +
> +@itemize @bullet
> +
> +@item
> +Spaces around @code{if}/@code{do}/@code{while}/@code{for} conditions and 
> assigments:

s/assigments/assignments/

Also, this might be more readable as "Space around assignments and after
@code{if}... keywords"?  On first pass, I assumed this was telling me
`( condition )` is correct, then had to re-read when the example showed
it wasn't.

> +
> +@example c
> +if (condition)

`condition` here differs from `cond` below, despite conveying the same meaning.
Either word is fine so long as it's the same word in both places.

> +av_foo();
> +@end example
> +
> +@example c
> +for (size_t i = 0; i < len; i++)

This lightly implies we prefer `i < len` over `i != len` and `i++` over `++i`.
Is that something people round here have strong opinions about?  Maybe iterate
over a linked list if this is a controversial question?

> +av_bar(i);
> +@end example
> +
> +@example c
> +size_t size = 0;
> +@end example
> +
> +However no spaces between the parentheses and condition, unless it helps
> +readability of complex conditions, so the following should not be done:
> +
> +@example c
> +// Wrong:

Nitpick: if you're going to say "// Wrong" here, it might be better to introduce
the mechanism with some "// Good"s or something above.  The consistency reduces
cognitive load on the learner, and it's a good excuse to add a little positivity
to a nerve-wracking experience.

> +if ( cond )
> +av_foo();
> +@end example
> +
> +@item
> +No unnecessary parentheses, unless it helps readability:
> +
> +@example c
> +flags = s->mb_x ? RIGHT_EDGE : LEFT_EDGE | RIGHT_EDGE;
> +@end example

Can the example use "+" or "*" instead of "|"?  I've had so many bugs where
I got the precedence wrong, I'm not sure whether this is supposed to be a good
or bad example of readability.

> +
> +@item
> +No braces around single-line blocks:
> +
> +@example c
> +if (bits_pixel == 24)
> +avctx->pix_fmt = AV_PIX_FMT_BGR24;
> +else if (bits_pixel == 8)
> +avctx->pix_fmt = AV_PIX_FMT_GRAY8;
> +else @{
> +av_log(avctx, AV_LOG_ERROR, "Invalid pixel format.\n");
> +return AVERROR_INVALIDDATA;
> +@}
> +@end example
> +
> +@end itemize
> +
> +
>  @subsection Vim configuration
>  In order to configure Vim to follow FFmpeg formatting conventions, paste
>  the following snippet into your @file{.vimrc}:

Some other things that could help (in decreasing order of importance)...

* if you find a piece of code that looks wrong, should you...
  a) ignore the guide and match your style to the surroundings?
  b) follow the guide and accept the file will look inconsistent?
  c) add an extra patch to fix the formatting?

(I suspect the answer is (b), but could well be wrong)

* example of brace style for both functions and structs
  (as a newbie you don't know if you're about to meet one of those people
  who get all bent out of shape when they see a bracket on a line on its own
  )

* prefer `foo=bar; if (foo)` over `if ((foo=bar))`
  (the latter is sadly used in the code, but is a speedbump for reviewers)

* `foo *bar`, not `foo* bar`
  (I always forget this, not important if it's just me)

Also, way outside the scope of this patch, but a linter that checks these things
would be very much appreciated.  There's a lot to get wrong with your first 
patch,
and a program that just said "yep that's formatted correctly" might save a 
newbie
enough time to learn git-send-email instead.
___
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] checkasm: add h263dsp.{h,v}_loop_filter

2024-05-18 Thread Rémi Denis-Courmont
---
 tests/checkasm/Makefile   |  1 +
 tests/checkasm/checkasm.c |  3 ++
 tests/checkasm/checkasm.h |  1 +
 tests/checkasm/h263dsp.c  | 62 +++
 tests/fate/checkasm.mak   |  1 +
 5 files changed, 68 insertions(+)
 create mode 100644 tests/checkasm/h263dsp.c

diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
index 92624aab0a..1dc770e9da 100644
--- a/tests/checkasm/Makefile
+++ b/tests/checkasm/Makefile
@@ -7,6 +7,7 @@ AVCODECOBJS-$(CONFIG_BSWAPDSP)  += bswapdsp.o
 AVCODECOBJS-$(CONFIG_FDCTDSP)   += fdctdsp.o
 AVCODECOBJS-$(CONFIG_FMTCONVERT)+= fmtconvert.o
 AVCODECOBJS-$(CONFIG_G722DSP)   += g722dsp.o
+AVCODECOBJS-$(CONFIG_H263DSP)   += h263dsp.o
 AVCODECOBJS-$(CONFIG_H264CHROMA)+= h264chroma.o
 AVCODECOBJS-$(CONFIG_H264DSP)   += h264dsp.o
 AVCODECOBJS-$(CONFIG_H264PRED)  += h264pred.o
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index 31ca9f6e2b..92c9e44df7 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -118,6 +118,9 @@ static const struct {
 #if CONFIG_G722DSP
 { "g722dsp", checkasm_check_g722dsp },
 #endif
+#if CONFIG_H263DSP
+{ "h263dsp", checkasm_check_h263dsp },
+#endif
 #if CONFIG_H264CHROMA
 { "h264chroma", checkasm_check_h264chroma },
 #endif
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index 07fcc751ff..334fb79734 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -91,6 +91,7 @@ void checkasm_check_flacdsp(void);
 void checkasm_check_float_dsp(void);
 void checkasm_check_fmtconvert(void);
 void checkasm_check_g722dsp(void);
+void checkasm_check_h263dsp(void);
 void checkasm_check_h264chroma(void);
 void checkasm_check_h264dsp(void);
 void checkasm_check_h264pred(void);
diff --git a/tests/checkasm/h263dsp.c b/tests/checkasm/h263dsp.c
new file mode 100644
index 00..2d0957a90b
--- /dev/null
+++ b/tests/checkasm/h263dsp.c
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2024 Rémi Denis-Courmont
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include 
+
+#include "checkasm.h"
+
+#include "libavcodec/h263dsp.h"
+#include "libavutil/mem.h"
+#include "libavutil/mem_internal.h"
+
+typedef void (*filter)(uint8_t *src, int stride, int qscale);
+
+static void check_loop_filter(char dim, filter func)
+{
+LOCAL_ALIGNED_16(uint8_t, buf0, [32 * 32]);
+LOCAL_ALIGNED_16(uint8_t, buf1, [32 * 32]);
+int qscale = rnd() % 32;
+
+declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *, int, int);
+
+for (size_t y = 0; y < 32; y++)
+for (size_t x = 0; x < 32; x++)
+buf0[y * 32 + x] = buf1[y * 32 + x] = rnd();
+
+if (check_func(func, "h263dsp.%c_loop_filter", dim)) {
+call_ref(buf0 + 8 * 33, 32, qscale);
+call_new(buf1 + 8 * 33, 32, qscale);
+
+if (memcmp(buf0, buf1, 32 * 32))
+fail();
+
+bench_new(buf1 + 8 * 33, 32, 1);
+}
+}
+
+void checkasm_check_h263dsp(void)
+{
+H263DSPContext ctx;
+
+ff_h263dsp_init(&ctx);
+check_loop_filter('h', ctx.h263_h_loop_filter);
+check_loop_filter('v', ctx.h263_v_loop_filter);
+report("loop_filter");
+}
diff --git a/tests/fate/checkasm.mak b/tests/fate/checkasm.mak
index d021e124d1..8d2705165a 100644
--- a/tests/fate/checkasm.mak
+++ b/tests/fate/checkasm.mak
@@ -14,6 +14,7 @@ FATE_CHECKASM = fate-checkasm-aacencdsp   
  \
 fate-checkasm-float_dsp \
 fate-checkasm-fmtconvert\
 fate-checkasm-g722dsp   \
+fate-checkasm-h263dsp   \
 fate-checkasm-h264chroma\
 fate-checkasm-h264dsp   \
 fate-checkasm-h264pred  \
-- 
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 v3 2/2] avcodec: add external dec libvvdec for H266/VVC

2024-05-18 Thread Cosmin Stejerean via ffmpeg-devel


> On May 18, 2024, at 7:04 AM, Nuo Mi  wrote:
> 
> This happened many years ago. See the discussion here:
> https://patchwork.ffmpeg.org/project/ffmpeg/patch/20201221060710.12230-6-nuomi2...@gmail.com/#60589
> Now that we have an internal vvc decoder, we can focus on improving it.
> As for the encoder, it is far more complex than the decoder. Reasonable to
> wrapper other libraries just like libx264 and libx265...

I'm all for improving the internal decoder, and I agree that the internal 
decoder should be preferred and be used by default, but it's not clear why that 
should preclude adding an external decoder as an option.

Sometimes bugs are found in the internal decoders or some functionality may be 
missing, and having the option to fallback to an external decoder as a 
workaround is very useful in practice.

For example there's a native AAC decoder in ffmpeg but it's still useful to 
have FDK-AAC available for decoding when running into edge cases on the native 
AAC decoder, or to decode USAC while the new decoder is under development, etc.

- Cosmin
___
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/jpeg2000dec: fix HT block decoder issue #10905

2024-05-18 Thread Michael Niedermayer
On Fri, May 17, 2024 at 08:00:16PM +, WATANABE Osamu wrote:
> Signed-off-by: Pierre-Anthony Lemieux 
> ---
> libavcodec/jpeg2000htdec.c   | 122 ---
> tests/ref/fate/jpeg2000dec-ds0_ht_01_b11 |   2 +-
> 2 files changed, 63 insertions(+), 61 deletions(-)
> 
> diff --git a/libavcodec/jpeg2000htdec.c b/libavcodec/jpeg2000htdec.c
> index fa704b665e..62f70c32a8 100644
> --- a/libavcodec/jpeg2000htdec.c
> +++ b/libavcodec/jpeg2000htdec.c
> @@ -196,7 +196,7 @@ static void jpeg2000_bitbuf_refill_forward(StateVars 
> *buffer, const uint8_t *arr
> while (buffer->bits_left < 32) {
> buffer->tmp = 0xFF;
> buffer->bits = (buffer->last == 0xFF) ? 7 : 8;
> -if (buffer->pos <= length) {
> +if (buffer->pos < length) {
> buffer->tmp = array[buffer->pos];
> buffer->pos += 1;
> buffer->last = buffer->tmp;
> @@ -508,17 +508,17 @@ static int jpeg2000_decode_sig_emb(const 
> Jpeg2000DecoderContext *s, MelDecoderSt
> }
> 
> av_always_inline
> -static int jpeg2000_get_state(int x1, int x2, int width, int shift_by,
> +static int jpeg2000_get_state(int x1, int x2, int stride, int shift_by,

the first whitespace seems to have been lost this makes git reject the patch

Applying: avcodec/jpeg2000dec: fix HT block decoder issue #10905
error: corrupt patch at line 20
error: could not build fake ancestor

thx

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

What does censorship reveal? It reveals fear. -- Julian Assange


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] avcodec/vc1_parser: Check init_get_bits8()

2024-05-18 Thread Michael Niedermayer
On Fri, May 17, 2024 at 10:16:27PM +0200, Andreas Rheinhardt wrote:
> Addresses Coverity issue #1441935.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/vc1_parser.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)

seems i didnt see this one, as i send a patch for this too
anyway your LGTM

thx

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

I know you won't believe me, but the highest form of Human Excellence is
to question oneself and others. -- 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".


Re: [FFmpeg-devel] [PATCH 2/9] avcodec/tiff: Assert init_get_bits8() success in unpack_gray()

2024-05-18 Thread Michael Niedermayer
On Sat, May 18, 2024 at 08:02:28AM +0200, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > Helps: CID1441939 Unchecked return value
> > 
> > Sponsored-by: Sovereign Tech Fund
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavcodec/tiff.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
> > index ca7e9f6aba9..31de6ad7308 100644
> > --- a/libavcodec/tiff.c
> > +++ b/libavcodec/tiff.c
> > @@ -457,7 +457,8 @@ static void unpack_gray(TiffContext *s, AVFrame *p,
> >  GetBitContext gb;
> >  uint16_t *dst = (uint16_t *)(p->data[0] + lnum * p->linesize[0]);
> >  
> > -init_get_bits8(&gb, src, width);
> > +int ret = init_get_bits8(&gb, src, width);
> > +av_assert1(ret >= 0);
> >  
> >  for (int i = 0; i < s->width; i++) {
> >  dst[i] = get_bits(&gb, bpp);
> 
> What guarantees that this is not triggered?

Several arguments, first one is simply that linesize*allocated_height must be 
addressable with an int index
which in practice ends on the check "stride*(uint64_t)(h+128) >= INT_MAX" in 
av_image_check_size2

so I would expect a width * 8 not to overflow if a stride * (h+128) cannot
(this is a bit fuzzy as our width can contain some subsampling factors though i
doubt they can be that large)

the 2nd is that
int width = ((s->width * s->bpp) + 7) >> 3;
or teh alethernative path contains a av_assert0(width <= bytes_per_row);
where int bytes_per_row = (((s->width - 1) / s->subsampling[0] + 1) * s->bpp *
s->subsampling[0] * s->subsampling[1] + 7) >> 3;
both are integers divided by 8 so i would expect no overflow on a multiply by 8

thx

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

The bravest are surely those who have the clearest vision
of what is before them, glory and danger alike, and yet
notwithstanding go out to meet it. -- Thucydides


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 4/6] lavf/tls_mbedtls: fix handling of certification validation failures

2024-05-18 Thread Michael Niedermayer
On Fri, May 17, 2024 at 10:34:41AM +0200, Sfan5 wrote:
> We manually check the verification status after the handshake has completed
> using mbedtls_ssl_get_verify_result(). However with VERIFY_REQUIRED
> mbedtls_ssl_handshake() already returns an error, so this code is never
> reached.
> Fix that by using VERIFY_OPTIONAL, which performs the verification but
> does not abort the handshake.
> 
> Signed-off-by: sfan5 
> ---
>  libavformat/tls_mbedtls.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/tls_mbedtls.c b/libavformat/tls_mbedtls.c
> index 9508fe3436..67d5c568b9 100644
> --- a/libavformat/tls_mbedtls.c
> +++ b/libavformat/tls_mbedtls.c
> @@ -263,8 +263,9 @@ static int tls_open(URLContext *h, const char *uri, int
> flags, AVDictionary **op
>  goto fail;
>  }
>  +// not VERIFY_REQUIRED because we manually check after handshake
>  mbedtls_ssl_conf_authmode(&tls_ctx->ssl_config,
> -  shr->verify ? MBEDTLS_SSL_VERIFY_REQUIRED :
> MBEDTLS_SSL_VERIFY_NONE);
> +  shr->verify ? MBEDTLS_SSL_VERIFY_OPTIONAL :
> MBEDTLS_SSL_VERIFY_NONE);
>  mbedtls_ssl_conf_rng(&tls_ctx->ssl_config, mbedtls_ctr_drbg_random,
> &tls_ctx->ctr_drbg_context);
>  mbedtls_ssl_conf_ca_chain(&tls_ctx->ssl_config, &tls_ctx->ca_cert,
> NULL);

This patch looks corrupted by extra line breaks

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

There will always be a question for which you do not know the correct answer.


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] lavd/v4l2: Use proper field type for second parameter of ioctl() with BSD's

2024-05-18 Thread Michael Niedermayer
On Sat, May 18, 2024 at 07:27:35AM -0400, Brad Smith wrote:
> Can this be backported to 7, 6, 5 and 4.4 releases?

yes and everyone who has write access to master also has write access to
the releases branches!

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

There will always be a question for which you do not know the correct answer.


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 1/5] fftools/ffmpeg_demux: also set -ch_layout avcodec option for -ch_layout CLI param

2024-05-18 Thread Michael Niedermayer
On Sat, May 18, 2024 at 06:11:12PM +0200, Marton Balint wrote:
> The code only set the channel layout of the AVFormatContext, so the user could
> not override the channel layout if the demuxer did not have such parameter.
> Let's set the specified channel layouts as codec options as well.
> 
> Fixes ticket #11016.
> 
> A regression since 639c2f00497257cb60ecaeeac1aacfa80df3be06.
> 
> Signed-off-by: Marton Balint 

breaks:
./ffmpeg  -f u8 -ar 8000 -ac 1 -i /dev/zero  -acodec aac -y  -t 1   -b:a 48k 
/tmp/aac.nut

[aac @ 0x55d4ed264800] Unsupported channel layout "1 channels"
[aac @ 0x55d4ed264800] Qavg: nan
[aost#0:0/aac @ 0x55d4ed24d800] Error while opening encoder - maybe incorrect 
parameters such as bit_rate, rate, width or height.
[af#0:0 @ 0x55d4ed264cc0] Error sending frames to consumers: Invalid argument
[af#0:0 @ 0x55d4ed264cc0] Task finished with error code: -22 (Invalid argument)
[af#0:0 @ 0x55d4ed264cc0] Terminating thread with return code -22 (Invalid 
argument)
[aost#0:0/aac @ 0x55d4ed24d800] Could not open encoder before EOF
[aost#0:0/aac @ 0x55d4ed24d800] Task finished with error code: -22 (Invalid 
argument)
[aost#0:0/aac @ 0x55d4ed24d800] Terminating thread with return code -22 
(Invalid argument)
[out#0/nut @ 0x55d4ed254040] Nothing was written into output file, because at 
least one of its streams received no packets.
size=   0KiB time=N/A bitrate=N/A speed=N/A

thx

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

Complexity theory is the science of finding the exact solution to an
approximation. Benchmarking OTOH is finding an approximation of the exact


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] lavd/v4l2: Use proper field type for second parameter of ioctl() with BSD's

2024-05-18 Thread Brad Smith

yes and everyone who has write access to master also has write access to
the releases branches!

thx



Ok, I don't mind helping out here.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH] configure: enable ffnvcodec, nvenc, nvdec for FreeBSD

2024-05-18 Thread Brad Smith
configure: enable ffnvcodec, nvenc, nvdec for FreeBSD

Signed-off-by: Brad Smith 
---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index b16722d83d..96b181fd21 100755
--- a/configure
+++ b/configure
@@ -7350,7 +7350,7 @@ fi
 
 if enabled x86; then
 case $target_os in
-mingw32*|mingw64*|win32|win64|linux|cygwin*)
+freebsd|mingw32*|mingw64*|win32|win64|linux|cygwin*)
 ;;
 *)
 disable ffnvcodec cuvid nvdec nvenc
-- 
2.45.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] lavu/version: fix minor version

2024-05-18 Thread Xiang, Haihao
On Vr, 2024-05-17 at 13:05 +0800, Xiang, Haihao wrote:
> From: Haihao Xiang 
> 
> The latest version should be 59.18.100 since commit 01c5f4ad
> 
> $ git diff 01c5f4ad~1..HEAD doc/APIchanges
> ...
> +2024-05-10 - x - lavu 59.18.100 - cpu.h
> +  Add AV_CPU_FLAG_RV_ZVBB.
> +
> 
> Signed-off-by: Haihao Xiang 
> ---
>  libavutil/version.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavutil/version.h b/libavutil/version.h
> index 3b5a2e7aaa..b9b9baf98c 100644
> --- a/libavutil/version.h
> +++ b/libavutil/version.h
> @@ -79,7 +79,7 @@
>   */
>  
>  #define LIBAVUTIL_VERSION_MAJOR  59
> -#define LIBAVUTIL_VERSION_MINOR  17
> +#define LIBAVUTIL_VERSION_MINOR  18
>  #define LIBAVUTIL_VERSION_MICRO 100
>  
>  #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \

Will apply,

- Haihao

___
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/9] avcodec/vqcdec: Check init_get_bits8() for failure

2024-05-18 Thread Michael Niedermayer
Fixes: CID1516090 Unchecked return value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer 
---
 libavcodec/vqcdec.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavcodec/vqcdec.c b/libavcodec/vqcdec.c
index 5c6cab3c1ab..bb69844327d 100644
--- a/libavcodec/vqcdec.c
+++ b/libavcodec/vqcdec.c
@@ -147,10 +147,13 @@ static int decode_vectors(VqcContext * s, const uint8_t * 
buf, int size, int wid
 GetBitContext gb;
 uint8_t * vectors = s->vectors;
 uint8_t * vectors_end = s->vectors + (width * height * 3) / 2;
+int ret;
 
 memset(vectors, 0, 3 * width * height / 2);
 
-init_get_bits8(&gb, buf, size);
+ret = init_get_bits8(&gb, buf, size);
+if (ret < 0)
+return ret;
 
 for (int i = 0; i < 3 * width * height / 2 / 32; i++) {
 uint8_t * dst = vectors;
-- 
2.45.1

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

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


[FFmpeg-devel] [PATCH 2/9] avcodec/vvc/ctu: Simplify code at the end of pred_mode_decode()

2024-05-18 Thread Michael Niedermayer
This simplification assumes that the code is correct

Fixes: CID1560036 Logically dead code

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer 
---
 libavcodec/vvc/ctu.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/libavcodec/vvc/ctu.c b/libavcodec/vvc/ctu.c
index 53f92ca10f7..7495ced0d5a 100644
--- a/libavcodec/vvc/ctu.c
+++ b/libavcodec/vvc/ctu.c
@@ -1080,12 +1080,10 @@ static PredMode pred_mode_decode(VVCLocalContext *lc,
 }
 if (pred_mode_ibc_flag)
 pred_mode = MODE_IBC;
+return pred_mode;
 } else {
-pred_mode_flag = is_4x4 || mode_type == MODE_TYPE_INTRA ||
-mode_type != MODE_TYPE_INTER || IS_I(rsh);
-pred_mode = pred_mode_flag ? MODE_INTRA : MODE_INTER;
+return MODE_INTRA;
 }
-return pred_mode;
 }
 
 static void sbt_info(VVCLocalContext *lc, const VVCSPS *sps)
-- 
2.45.1

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

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


[FFmpeg-devel] [PATCH 3/9] avcodec/vvc/ctu: Simplify pred_mode_plt_flag

2024-05-18 Thread Michael Niedermayer
Fixes: CID1560039 Logically dead code

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer 
---
 libavcodec/vvc/ctu.c | 23 ++-
 1 file changed, 6 insertions(+), 17 deletions(-)

diff --git a/libavcodec/vvc/ctu.c b/libavcodec/vvc/ctu.c
index 7495ced0d5a..b7089b9a004 100644
--- a/libavcodec/vvc/ctu.c
+++ b/libavcodec/vvc/ctu.c
@@ -1793,7 +1793,6 @@ static int hls_coding_unit(VVCLocalContext *lc, int x0, 
int y0, int cb_width, in
 const int hs= sps->hshift[CHROMA];
 const int vs= sps->vshift[CHROMA];
 const int is_128= cb_width > 64 || cb_height > 64;
-int pred_mode_plt_flag  = 0;
 int ret;
 
 CodingUnit *cu = add_cu(lc, x0, y0, cb_width, cb_height, cqt_depth, 
tree_type);
@@ -1811,7 +1810,7 @@ static int hls_coding_unit(VVCLocalContext *lc, int x0, 
int y0, int cb_width, in
 mode_type != MODE_TYPE_INTER && ((cb_width * cb_height) >
 (tree_type != DUAL_TREE_CHROMA ? 16 : (16 << hs << vs))) &&
 (mode_type != MODE_TYPE_INTRA || tree_type != DUAL_TREE_CHROMA)) {
-pred_mode_plt_flag = ff_vvc_pred_mode_plt_flag(lc);
+int pred_mode_plt_flag = ff_vvc_pred_mode_plt_flag(lc);
 if (pred_mode_plt_flag) {
 avpriv_report_missing_feature(fc->log_ctx, "Palette");
 return AVERROR_PATCHWELCOME;
@@ -1823,31 +1822,21 @@ static int hls_coding_unit(VVCLocalContext *lc, int x0, 
int y0, int cb_width, in
 }
 if (cu->pred_mode == MODE_INTRA || cu->pred_mode == MODE_PLT) {
 if (tree_type == SINGLE_TREE || tree_type == DUAL_TREE_LUMA) {
-if (pred_mode_plt_flag) {
-avpriv_report_missing_feature(fc->log_ctx, "Palette");
-return AVERROR_PATCHWELCOME;
-} else {
-intra_luma_pred_modes(lc);
-}
+intra_luma_pred_modes(lc);
 ff_vvc_set_intra_mvf(lc, 0);
 }
 if ((tree_type == SINGLE_TREE || tree_type == DUAL_TREE_CHROMA) && 
sps->r->sps_chroma_format_idc) {
-if (pred_mode_plt_flag && tree_type == DUAL_TREE_CHROMA) {
-avpriv_report_missing_feature(fc->log_ctx, "Palette");
-return AVERROR_PATCHWELCOME;
-} else if (!pred_mode_plt_flag) {
-if (!cu->act_enabled_flag)
-intra_chroma_pred_modes(lc);
-}
+if (!cu->act_enabled_flag)
+intra_chroma_pred_modes(lc);
 }
 } else if (tree_type != DUAL_TREE_CHROMA) { /* MODE_INTER or MODE_IBC */
 if ((ret = inter_data(lc)) < 0)
 return ret;
 }
-if (cu->pred_mode != MODE_INTRA && !pred_mode_plt_flag && 
!lc->cu->pu.general_merge_flag)
+if (cu->pred_mode != MODE_INTRA && !lc->cu->pu.general_merge_flag)
 cu->coded_flag = ff_vvc_cu_coded_flag(lc);
 else
-cu->coded_flag = !(cu->skip_flag || pred_mode_plt_flag);
+cu->coded_flag = !(cu->skip_flag);
 
 if (cu->coded_flag) {
 sbt_info(lc, sps);
-- 
2.45.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 4/9] avcodec/vvc/ctu: Remove dead ret check

2024-05-18 Thread Michael Niedermayer
Fixes: CID1560040 Logically dead code

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer 
---
 libavcodec/vvc/ctu.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavcodec/vvc/ctu.c b/libavcodec/vvc/ctu.c
index b7089b9a004..89eb9d338c7 100644
--- a/libavcodec/vvc/ctu.c
+++ b/libavcodec/vvc/ctu.c
@@ -1854,8 +1854,6 @@ static int hls_coding_unit(VVCLocalContext *lc, int x0, 
int y0, int cb_width, in
 cu->lfnst_idx = lfnst_idx_decode(lc);
 cu->mts_idx = mts_idx_decode(lc);
 set_qp_c(lc);
-if (ret < 0)
-return ret;
 } else {
 ret = skipped_transform_tree_unit(lc);
 if (ret < 0)
-- 
2.45.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 5/9] avcodec/vvc/dec: Remove constant eos_at_start

2024-05-18 Thread Michael Niedermayer
Fixes: CID1560041 'Constant' variable guards dead code

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer 
---
 libavcodec/vvc/dec.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/libavcodec/vvc/dec.c b/libavcodec/vvc/dec.c
index 25cdb39cabb..d262d310125 100644
--- a/libavcodec/vvc/dec.c
+++ b/libavcodec/vvc/dec.c
@@ -825,7 +825,6 @@ static int decode_nal_units(VVCContext *s, VVCFrameContext 
*fc, AVPacket *avpkt)
 const CodedBitstreamH266Context *h266 = s->cbc->priv_data;
 CodedBitstreamFragment *frame = &s->current_frame;
 int ret = 0;
-int eos_at_start = 1;
 s->last_eos = s->eos;
 s->eos = 0;
 
@@ -841,10 +840,7 @@ static int decode_nal_units(VVCContext *s, VVCFrameContext 
*fc, AVPacket *avpkt)
 const CodedBitstreamUnit *unit = frame->units + i;
 
 if (unit->type == VVC_EOB_NUT || unit->type == VVC_EOS_NUT) {
-if (eos_at_start)
-s->last_eos = 1;
-else
-s->eos = 1;
+s->last_eos = 1;
 } else {
 ret = decode_nal_unit(s, fc, nal, unit);
 if (ret < 0) {
-- 
2.45.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 6/9] avcodec/vvc/dec: Check init_get_bits8() for failure

2024-05-18 Thread Michael Niedermayer
Fixes: CID1560042 Unchecked return value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer 
---
 libavcodec/vvc/dec.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavcodec/vvc/dec.c b/libavcodec/vvc/dec.c
index d262d310125..f2ede490c8b 100644
--- a/libavcodec/vvc/dec.c
+++ b/libavcodec/vvc/dec.c
@@ -514,6 +514,7 @@ static int slice_init_entry_points(SliceContext *sc,
 int nb_eps= sh->r->num_entry_points + 1;
 int ctu_addr  = 0;
 GetBitContext gb;
+int ret;
 
 if (sc->nb_eps != nb_eps) {
 eps_free(sc);
@@ -523,7 +524,9 @@ static int slice_init_entry_points(SliceContext *sc,
 sc->nb_eps = nb_eps;
 }
 
-init_get_bits8(&gb, slice->data, slice->data_size);
+ret = init_get_bits8(&gb, slice->data, slice->data_size);
+if (ret < 0)
+return ret;
 for (int i = 0; i < sc->nb_eps; i++)
 {
 EntryPoint *ep = sc->eps + i;
-- 
2.45.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 7/9] avcodec/vvc/mvs: Initialize mvf

2024-05-18 Thread Michael Niedermayer
This might not be needed for correctness but it could
help general reproducability of issues

Related to: CID1560037 Uninitialized scalar variable
Related to: CID1560044 Uninitialized scalar variable

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer 
---
 libavcodec/vvc/mvs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/vvc/mvs.c b/libavcodec/vvc/mvs.c
index fe7d9234603..521cf96a896 100644
--- a/libavcodec/vvc/mvs.c
+++ b/libavcodec/vvc/mvs.c
@@ -411,7 +411,7 @@ void ff_vvc_store_sb_mvs(const VVCLocalContext *lc, 
PredictionUnit *pu)
 const int sbw = cu->cb_width / mi->num_sb_x;
 const int sbh = cu->cb_height / mi->num_sb_y;
 SubblockParams params[2];
-MvField mvf;
+MvField mvf = {0};
 
 mvf.pred_flag = mi->pred_flag;
 mvf.bcw_idx = mi->bcw_idx;
@@ -504,7 +504,7 @@ void ff_vvc_store_mvf(const VVCLocalContext *lc, const 
MvField *mvf)
 void ff_vvc_store_mv(const VVCLocalContext *lc, const MotionInfo *mi)
 {
 const CodingUnit *cu = lc->cu;
-MvField mvf;
+MvField mvf = {0};
 
 mvf.hpel_if_idx = mi->hpel_if_idx;
 mvf.bcw_idx = mi->bcw_idx;
-- 
2.45.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 8/9] avcodec/wavpack: Remove dead assignments

2024-05-18 Thread Michael Niedermayer
Fixes: CID1442018 Unused value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer 
---
 libavcodec/wavpack.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c
index d4cf489c0fa..bf9aa0cdcec 100644
--- a/libavcodec/wavpack.c
+++ b/libavcodec/wavpack.c
@@ -1418,13 +1418,13 @@ static int wavpack_decode_block(AVCodecContext *avctx, 
AVFrame *frame, int block
 chmask = bytestream2_get_le32(&gb);
 break;
 case 4:
-size = bytestream2_get_byte(&gb);
+bytestream2_get_byte(&gb);
 chan  |= (bytestream2_get_byte(&gb) & 0xF) << 8;
 chan  += 1;
 chmask = bytestream2_get_le24(&gb);
 break;
 case 5:
-size = bytestream2_get_byte(&gb);
+bytestream2_get_byte(&gb);
 chan  |= (bytestream2_get_byte(&gb) & 0xF) << 8;
 chan  += 1;
 chmask = bytestream2_get_le32(&gb);
-- 
2.45.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 9/9] avcodec/wavpackenc: Use unsigned for potential 31bit shift

2024-05-18 Thread Michael Niedermayer
Fixes: CID1465481 Unintentional integer overflow

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer 
---
 libavcodec/wavpackenc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/wavpackenc.c b/libavcodec/wavpackenc.c
index ba0371592d9..e99ab951d41 100644
--- a/libavcodec/wavpackenc.c
+++ b/libavcodec/wavpackenc.c
@@ -1979,7 +1979,7 @@ static void encode_flush(WavPackEncodeContext *s)
 put_bits(pb, 31, 0x7FFF);
 cbits -= 31;
 } else {
-put_bits(pb, cbits, (1 << cbits) - 1);
+put_bits(pb, cbits, (1U << cbits) - 1);
 cbits = 0;
 }
 } while (cbits);
@@ -2008,7 +2008,7 @@ static void encode_flush(WavPackEncodeContext *s)
 put_bits(pb, 31, 0x7FFF);
 cbits -= 31;
 } else {
-put_bits(pb, cbits, (1 << cbits) - 1);
+put_bits(pb, cbits, (1U << cbits) - 1);
 cbits = 0;
 }
 } while (cbits);
-- 
2.45.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 1/9] avcodec/vqcdec: Check init_get_bits8() for failure

2024-05-18 Thread Peter Ross
On Sun, May 19, 2024 at 04:49:07AM +0200, Michael Niedermayer wrote:
> Fixes: CID1516090 Unchecked return value
> 
> Sponsored-by: Sovereign Tech Fund
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/vqcdec.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/vqcdec.c b/libavcodec/vqcdec.c
> index 5c6cab3c1ab..bb69844327d 100644
> --- a/libavcodec/vqcdec.c
> +++ b/libavcodec/vqcdec.c
> @@ -147,10 +147,13 @@ static int decode_vectors(VqcContext * s, const uint8_t 
> * buf, int size, int wid
>  GetBitContext gb;
>  uint8_t * vectors = s->vectors;
>  uint8_t * vectors_end = s->vectors + (width * height * 3) / 2;
> +int ret;
>  
>  memset(vectors, 0, 3 * width * height / 2);
>  
> -init_get_bits8(&gb, buf, size);
> +ret = init_get_bits8(&gb, buf, size);
> +if (ret < 0)
> +return ret;
>  
>  for (int i = 0; i < 3 * width * height / 2 / 32; i++) {
>  uint8_t * dst = vectors;

ok

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)


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 v3 2/2] avcodec: add external dec libvvdec for H266/VVC

2024-05-18 Thread Rémi Denis-Courmont
Hi,

Le 18 mai 2024 21:55:04 GMT+03:00, Cosmin Stejerean via ffmpeg-devel 
 a écrit :
>
>
>> On May 18, 2024, at 7:04 AM, Nuo Mi  wrote:
>> 
>> This happened many years ago. See the discussion here:
>> https://patchwork.ffmpeg.org/project/ffmpeg/patch/20201221060710.12230-6-nuomi2...@gmail.com/#60589
>> Now that we have an internal vvc decoder, we can focus on improving it.
>> As for the encoder, it is far more complex than the decoder. Reasonable to
>> wrapper other libraries just like libx264 and libx265...
>
>I'm all for improving the internal decoder, and I agree that the internal 
>decoder should be preferred and be used by default, but it's not clear why 
>that should preclude adding an external decoder as an option.

Adding a disabled-by-default decoder is adding bloat, if there is not a 
specific known reason why that is needed.

This is especially true for video decoders, where the external decoders 
typically will have no or worse optimisations for DSP functions, no thread 
support (or not accessible via libavcodec), and no integration with hwaccel.

The later point has become a problem even with dav1d...

>Sometimes bugs are found in the internal decoders

Providing a non-default choice is a poor excuse for a bug. Most users won't 
know how to do that, and many FFmpeg reverse dependencies don't even allow it.

> or some functionality may be missing, and having the option to fallback to an 
> external decoder as a workaround is very useful in practice.

That I can agree, but what do you find missing in the VVC decoder compared to 
libvvcdec?
___
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".