Re: [FFmpeg-devel] [PATCH 1/2] configure: permit POWER9 cpu flags

2024-07-13 Thread Rémi Denis-Courmont
Le torstaina 4. heinäkuuta 2024, 4.23.29 EEST Sean McGovern a écrit :
> ---
>  configure | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/configure b/configure
> index b28221f258..bbda7a02cb 100755
> --- a/configure
> +++ b/configure
> @@ -5493,7 +5493,7 @@ elif enabled ppc; then
>  cpuflags="-mcpu=$cpu"
>  disable vsx
>  ;;
> -power[7-8]*)
> +power[7-9]*)
>  cpuflags="-mcpu=$cpu"
>  ;;
>  cell)

IMO, the CPU should just be passed as, well, CPU by default - like AArch64 
already does. PPC does not have that many CPU types. But generally speaking, 
keeping up with all CPU model names that GCC and Clang seems like a very vain 
and fruitless exercise.

Of course we can keep special case matching for *existing* special values that 
FFmpeg has historically accepted, but lets maybe stop adding new ones?

-- 
レミ・デニ-クールモン
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".


Re: [FFmpeg-devel] [PATCH] lavc/flacdsp: implement wasted32 DSP function for VSX on POWER

2024-07-13 Thread Rémi Denis-Courmont
Le sunnuntaina 7. heinäkuuta 2024, 21.21.26 EEST Sean McGovern a écrit :
> RaptorCS POWER9 (8c4t) @ 2.2GHz:
> flac_wasted_32_c: 50.1
> flac_wasted_32_vsx: 14.1
> ---
>  libavcodec/flacdsp.c  |  2 ++
>  libavcodec/flacdsp.h  |  1 +
>  libavcodec/ppc/Makefile   |  2 ++
>  libavcodec/ppc/flacdsp_init.c | 38 +
>  libavcodec/ppc/flacdsp_vsx.c  | 53 +++
>  5 files changed, 96 insertions(+)
>  create mode 100644 libavcodec/ppc/flacdsp_init.c
>  create mode 100644 libavcodec/ppc/flacdsp_vsx.c
> 
> diff --git a/libavcodec/flacdsp.c b/libavcodec/flacdsp.c
> index f5362bf66f..b63d55ddcd 100644
> --- a/libavcodec/flacdsp.c
> +++ b/libavcodec/flacdsp.c
> @@ -156,5 +156,7 @@ av_cold void ff_flacdsp_init(FLACDSPContext *c, enum
> AVSampleFormat fmt, int cha ff_flacdsp_init_riscv(c, fmt, channels);
>  #elif ARCH_X86
>  ff_flacdsp_init_x86(c, fmt, channels);
> +#elif ARCH_PPC
> +ff_flacdsp_init_ppc(c, fmt, channels);
>  #endif
>  }
> diff --git a/libavcodec/flacdsp.h b/libavcodec/flacdsp.h
> index 3b7b35a112..941536ef16 100644
> --- a/libavcodec/flacdsp.h
> +++ b/libavcodec/flacdsp.h
> @@ -45,5 +45,6 @@ void ff_flacdsp_init(FLACDSPContext *c, enum
> AVSampleFormat fmt, int channels); void ff_flacdsp_init_arm(FLACDSPContext
> *c, enum AVSampleFormat fmt, int channels); void
> ff_flacdsp_init_riscv(FLACDSPContext *c, enum AVSampleFormat fmt, int
> channels); void ff_flacdsp_init_x86(FLACDSPContext *c, enum AVSampleFormat
> fmt, int channels); +void ff_flacdsp_init_ppc(FLACDSPContext *c, enum
> AVSampleFormat fmt, int channels);
> 
>  #endif /* AVCODEC_FLACDSP_H */
> diff --git a/libavcodec/ppc/Makefile b/libavcodec/ppc/Makefile
> index 10b9ca60da..7f81a8aa34 100644
> --- a/libavcodec/ppc/Makefile
> +++ b/libavcodec/ppc/Makefile
> @@ -2,6 +2,8 @@
>  OBJS-$(CONFIG_AUDIODSP)+= ppc/audiodsp.o
>  OBJS-$(CONFIG_BLOCKDSP)+= ppc/blockdsp.o
>  OBJS-$(CONFIG_FDCTDSP) += ppc/fdctdsp.o
> +OBJS-$(CONFIG_FLAC_DECODER)+= ppc/flacdsp_init.o
> +VSX-OBJS-$(CONFIG_FLAC_DECODER)+= ppc/flacdsp_vsx.o
>  OBJS-$(CONFIG_FMTCONVERT)  += ppc/fmtconvert_altivec.o
>  OBJS-$(CONFIG_H264CHROMA)  += ppc/h264chroma_init.o
>  OBJS-$(CONFIG_H264DSP) += ppc/h264dsp.o
> ppc/hpeldsp_altivec.o diff --git a/libavcodec/ppc/flacdsp_init.c
> b/libavcodec/ppc/flacdsp_init.c new file mode 100644
> index 00..526bbf
> --- /dev/null
> +++ b/libavcodec/ppc/flacdsp_init.c
> @@ -0,0 +1,38 @@
> +/*
> + * Copyright (c) 2024 Sean McGovern 
> + *
> + * 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 "config.h"
> +
> +#include "libavutil/attributes.h"
> +#include "libavutil/cpu.h"
> +#include "libavutil/ppc/cpu.h"
> +#include "libavcodec/flacdsp.h"
> +
> +void ff_flac_wasted32_vsx(int32_t *, int wasted, int len);
> +
> +av_cold void ff_flacdsp_init_ppc(FLACDSPContext *c, enum AVSampleFormat
> fmt, int channels) +{
> +#if HAVE_VSX
> +if (!PPC_VSX(av_get_cpu_flags()))
> +return;
> +
> +c->wasted32 = ff_flac_wasted32_vsx;
> +#endif
> +}
> diff --git a/libavcodec/ppc/flacdsp_vsx.c b/libavcodec/ppc/flacdsp_vsx.c
> new file mode 100644
> index 00..7464108c45
> --- /dev/null
> +++ b/libavcodec/ppc/flacdsp_vsx.c
> @@ -0,0 +1,53 @@
> +/*
> + * Copyright (c) 2024 Sean McGovern 
> + *
> + * 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 "config.h"
> +
> +#

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

2024-07-13 Thread Rémi Denis-Courmont
Le lauantaina 15. kesäkuuta 2024, 14.50.33 EEST u...@foxmail.com a écrit :
> From: sunyuechi 

OK, so I realise that this review is very late, but...

TBH it is very hard to review this due to the large extents of code 
conditionals. This should avoidable at least partly. You can name macros for 
each filter and then expand those macros instead of using if's.

Besides in my experience, it is more readable to leave the loads/stores to the 
outer function or macros and factor only the calculations, whenever you need 
to apply the same maths vertically and/or horizontally. This also sometimes 
enables actually using shared code, e.g., the H.263 loop filter or the VC-1 
ITX.

Lastly this seems to both add new optimisations *and* add specialisations for 
256-bit vectors, which really should be separate patches, but maybe I just 
don't understand the code. In any case, that would not really match with the 
patch description.


>  C908   X60
> vp9_avg_8tap_smooth_4h_8bpp_c  :   12.7   11.2
> vp9_avg_8tap_smooth_4h_8bpp_rvv_i32:4.74.2
> vp9_avg_8tap_smooth_4v_8bpp_c  :   29.7   12.5
> vp9_avg_8tap_smooth_4v_8bpp_rvv_i32:4.74.2
> vp9_avg_8tap_smooth_8h_8bpp_c  :   48.7   42.2
> vp9_avg_8tap_smooth_8h_8bpp_rvv_i32:9.58.5
> vp9_avg_8tap_smooth_8v_8bpp_c  :   49.7   45.5
> vp9_avg_8tap_smooth_8v_8bpp_rvv_i32:9.58.5
> vp9_avg_8tap_smooth_16h_8bpp_c :  192.0  166.5
> vp9_avg_8tap_smooth_16h_8bpp_rvv_i32   :   21.7   19.5
> vp9_avg_8tap_smooth_16v_8bpp_c :  191.2  175.2
> vp9_avg_8tap_smooth_16v_8bpp_rvv_i32   :   21.2   19.0
> vp9_avg_8tap_smooth_32h_8bpp_c :  780.2  663.2
> vp9_avg_8tap_smooth_32h_8bpp_rvv_i32   :   68.2   60.5
> vp9_avg_8tap_smooth_32v_8bpp_c :  770.0  685.7
> vp9_avg_8tap_smooth_32v_8bpp_rvv_i32   :   67.0   59.5
> vp9_avg_8tap_smooth_64h_8bpp_c : 3116.2 2648.2
> vp9_avg_8tap_smooth_64h_8bpp_rvv_i32   :  270.7  120.7
> vp9_avg_8tap_smooth_64v_8bpp_c : 3058.5 2731.7
> vp9_avg_8tap_smooth_64v_8bpp_rvv_i32   :  266.5  119.0
> vp9_put_8tap_smooth_4h_8bpp_c  :   11.09.7
> vp9_put_8tap_smooth_4h_8bpp_rvv_i32:4.23.7
> vp9_put_8tap_smooth_4v_8bpp_c  :   11.7   10.5
> vp9_put_8tap_smooth_4v_8bpp_rvv_i32:4.03.7
> 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  :   43.5   38.5
> vp9_put_8tap_smooth_8v_8bpp_rvv_i32:8.77.7
> vp9_put_8tap_smooth_16h_8bpp_c :  181.7  147.2
> vp9_put_8tap_smooth_16h_8bpp_rvv_i32   :   20.0   18.0
> vp9_put_8tap_smooth_16v_8bpp_c :  168.5  149.7
> vp9_put_8tap_smooth_16v_8bpp_rvv_i32   :   19.7   17.5
> vp9_put_8tap_smooth_32h_8bpp_c :  675.0  586.5
> vp9_put_8tap_smooth_32h_8bpp_rvv_i32   :   65.2   58.0
> vp9_put_8tap_smooth_32v_8bpp_c :  664.7  591.2
> vp9_put_8tap_smooth_32v_8bpp_rvv_i32   :   64.0   57.0
> vp9_put_8tap_smooth_64h_8bpp_c : 2696.2 2339.0
> vp9_put_8tap_smooth_64h_8bpp_rvv_i32   :  259.7  115.7
> vp9_put_8tap_smooth_64v_8bpp_c : 2691.0 2348.5
> vp9_put_8tap_smooth_64v_8bpp_rvv_i32   :  255.5  114.0
> ---
>  libavcodec/riscv/vp9_mc_rvv.S  | 200 +
>  libavcodec/riscv/vp9dsp.h  |  72 
>  libavcodec/riscv/vp9dsp_init.c |  38 ++-
>  3 files changed, 285 insertions(+), 25 deletions(-)
> 
> diff --git a/libavcodec/riscv/vp9_mc_rvv.S b/libavcodec/riscv/vp9_mc_rvv.S
> index 5241562531..5e81301aa5 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_vp9_avg\len\()_rvv, zve32x
>  csrwi   vxrm, 0
> @@ -181,8 +193,196 @@ func ff_\op\()_vp9_bilin_64hv_rvv, zve32x
>  endfunc
>  .endm
> 
> +.equ ff_vp9_subpel_filters_smooth, ff_vp9_subpel_filters
> +.equ ff_vp9_subpel_filters_regular, ff_vp9_subpel_filters + 16*8*2
> +.equ ff_vp9_subpel_filters_sharp, ff_vp9_subpel_filters + 16*8*2*2
> +
> +.macro epel_filter name, type, re

Re: [FFmpeg-devel] [PATCH v4 1/3] avcodec/jpeg2000dec: Add support for CAP and CPF markers

2024-07-13 Thread WATANABE Osamu
> @Osamu, did you check if the decoded images fall within the tolerances
> specified in 15444-4?

Yes, I did. It has been confirmed that the decoder passes all the test cases 
defined in 15444-4.
The errors (PAE and MSE) in the reconstructed images are within the allowable 
tolerances.



> On Jul 12, 2024, at 13:57, Pierre-Anthony Lemieux  wrote:
> 
> I checked that the patch results in FFMPEG decoding without error the
> additional conformance codestreams at [1].
> 
> [1] https://ffmpeg.org/pipermail/ffmpeg-devel/2024-June/329727.html
> 
> @Osamu, did you check if the decoded images fall within the tolerances
> specified in 15444-4?
> 
> There is an errant space character at the end of four lines for some
> reason. I can fix that before merging.
> 
> Any other comments? If not, I plan to merge sometime this week, and
> plan to then submit a patch to add the conformance codestream to FATE.
> 
> On Mon, Jun 24, 2024 at 6:37?AM Osamu Watanabe
>  wrote:
>> 
>> This commit adds support for CAP and CPF markers.
>> 
>> The previous version
>> (v3, https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=12246)
>> was wrongly separated. I have fixed the way to separation.
>> 
>> The changes are essentially the same as v2
>> (https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=12199).
>> The suggested modifications have been made according to the discussion
>> on this mailing list.
>> 
>> Signed-off-by: Osamu Watanabe 
>> ---
>> libavcodec/jpeg2000.h|   8 +++
>> libavcodec/jpeg2000dec.c | 112 ++-
>> libavcodec/jpeg2000dec.h |   7 +++
>> 3 files changed, 126 insertions(+), 1 deletion(-)
>> 
>> diff --git a/libavcodec/jpeg2000.h b/libavcodec/jpeg2000.h
>> index d004c08f10..4bdc38df7c 100644
>> --- a/libavcodec/jpeg2000.h
>> +++ b/libavcodec/jpeg2000.h
>> @@ -37,12 +37,14 @@
>> 
>> enum Jpeg2000Markers {
>> JPEG2000_SOC = 0xff4f, // start of codestream
>> +JPEG2000_CAP = 0xff50, // extended capabilities
>> JPEG2000_SIZ = 0xff51, // image and tile size
>> JPEG2000_COD,  // coding style default
>> JPEG2000_COC,  // coding style component
>> JPEG2000_TLM = 0xff55, // tile-part length, main header
>> JPEG2000_PLM = 0xff57, // packet length, main header
>> JPEG2000_PLT,  // packet length, tile-part header
>> +JPEG2000_CPF,  // corresponding profile
>> JPEG2000_QCD = 0xff5c, // quantization default
>> JPEG2000_QCC,  // quantization component
>> JPEG2000_RGN,  // region of interest
>> @@ -58,6 +60,12 @@ enum Jpeg2000Markers {
>> JPEG2000_EOC = 0xffd9, // end of codestream
>> };
>> 
>> +enum JPEG2000_Ccap15_b14_15_params {
>> +HTJ2K_HTONLY = 0,  // HTONLY, bit 14 and 15 are 0
>> +HTJ2K_HTDECLARED,  // HTDECLARED, bit 14 = 1 and bit 15 = 0
>> +HTJ2K_MIXED = 3,   // MIXED, bit 14 and 15 are 1
>> +};
>> +
>> #define JPEG2000_SOP_FIXED_BYTES 0xFF910004
>> #define JPEG2000_SOP_BYTE_LENGTH 6
>> 
>> diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
>> index 091931b1ff..d1046661c4 100644
>> --- a/libavcodec/jpeg2000dec.c
>> +++ b/libavcodec/jpeg2000dec.c
>> @@ -408,6 +408,73 @@ static int get_siz(Jpeg2000DecoderContext *s)
>> s->avctx->bits_per_raw_sample = s->precision;
>> return 0;
>> }
>> +/* get extended capabilities (CAP) marker segment */
>> +static int get_cap(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c)
>> +{
>> +uint32_t Pcap;
>> +uint16_t Ccap_i[32] = { 0 };
>> +uint16_t Ccap_15;
>> +uint8_t P;
>> +
>> +if (bytestream2_get_bytes_left(&s->g) < 6) {
>> +av_log(s->avctx, AV_LOG_ERROR, "Insufficient space for CAP\n");
>> +return AVERROR_INVALIDDATA;
>> +}
>> +
>> +Pcap = bytestream2_get_be32u(&s->g);
>> +s->isHT = (Pcap >> (31 - (15 - 1))) & 1;
>> +for (int i = 0; i < 32; i++) {
>> +if ((Pcap >> (31 - i)) & 1)
>> +Ccap_i[i] = bytestream2_get_be16u(&s->g);
>> +}
>> +Ccap_15 = Ccap_i[14];
>> +if (s->isHT == 1) {
>> +av_log(s->avctx, AV_LOG_INFO, "This is an HTJ2K codestream.\n");
>> +// Bits 14-15
>> +switch ((Ccap_15 >> 14) & 0x3) {
>> +case 0x3:
>> +s->Ccap15_b14_15 = HTJ2K_MIXED;
>> +break;
>> +case 0x1:
>> +s->Ccap15_b14_15 = HTJ2K_HTDECLARED;
>> +break;
>> +case 0x0:
>> +s->Ccap15_b14_15 = HTJ2K_HTONLY;
>> +break;
>> +default:
>> +av_log(s->avctx, AV_LOG_ERROR, "Unknown CCap value.\n");
>> +return AVERROR(EINVAL);
>> +break;
>> +}
>> +// Bit 13
>> +if ((Ccap_15 >> 13) & 1) {
>> +av_log(s->avctx, AV_LOG_ERROR, "MULTIHT set is not 
>> supported.\n");
>> +return AVERROR_PATCHWELCOME;
>> +}
>> +// Bit 12
>> +s->Ccap15_b12 = (Ccap_15 >> 12) & 1;
>> +// Bit 11
>

[FFmpeg-devel] [PATCH 2/2] lavc/h264dsp: R-V V high-depth add_pixels8

2024-07-13 Thread Rémi Denis-Courmont
---
 libavcodec/riscv/h264addpx_rvv.S | 22 ++
 libavcodec/riscv/h264dsp_init.c  |  2 ++
 2 files changed, 24 insertions(+)

diff --git a/libavcodec/riscv/h264addpx_rvv.S b/libavcodec/riscv/h264addpx_rvv.S
index fd36bd4896..3d307b2cb8 100644
--- a/libavcodec/riscv/h264addpx_rvv.S
+++ b/libavcodec/riscv/h264addpx_rvv.S
@@ -87,3 +87,25 @@ func ff_h264_add_pixels8_8_rvv, zve64x
 vsse64.vv8, (a0), a2
 ret
 endfunc
+
+func ff_h264_add_pixels8_16_rvv, zve32x
+li  t0, 8
+vsetivlizero, 8, e16, m1, ta, ma
+1:
+vle32.v v16, (a1)
+addit0, t0, -1
+vle16.v v8, (a0)
+addia1, a1, 8 * 4
+vncvt.x.x.w v24, v16
+.equoffset, 0
+.rept   256 / __riscv_xlen
+sx  zero, offset(a1)
+.equoffset, offset + (__riscv_xlen / 8)
+.endr
+vadd.vv v8, v8, v24
+vse16.v v8, (a0)
+add a0, a0, a2
+bnezt0, 1b
+
+ret
+endfunc
diff --git a/libavcodec/riscv/h264dsp_init.c b/libavcodec/riscv/h264dsp_init.c
index a6d06b3ac4..ea89314952 100644
--- a/libavcodec/riscv/h264dsp_init.c
+++ b/libavcodec/riscv/h264dsp_init.c
@@ -63,6 +63,7 @@ void ff_h264_idct8_add_14_rvv(uint8_t *dst, int16_t *block, 
int stride);
 
 void ff_h264_add_pixels8_8_rvv(uint8_t *dst, int16_t *block, int stride);
 void ff_h264_add_pixels4_8_rvv(uint8_t *dst, int16_t *block, int stride);
+void ff_h264_add_pixels8_16_rvv(uint8_t *dst, int16_t *block, int stride);
 void ff_h264_add_pixels4_16_rvv(uint8_t *dst, int16_t *block, int stride);
 
 extern int ff_startcode_find_candidate_rvb(const uint8_t *, int);
@@ -126,6 +127,7 @@ av_cold void ff_h264dsp_init_riscv(H264DSPContext *dsp, 
const int bit_depth,
 dsp->h264_idct8_add = ff_h264_idct8_add_14_rvv;
 }
 if (bit_depth > 8 && zvl128b) {
+dsp->h264_add_pixels8_clear = ff_h264_add_pixels8_16_rvv;
 if (flags & AV_CPU_FLAG_RVV_I64)
 dsp->h264_add_pixels4_clear = ff_h264_add_pixels4_16_rvv;
 }
-- 
2.45.2

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

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


[FFmpeg-devel] [PATCH 1/2] lavc/h264dsp: R-V V add_pixels4 and 8-bit add_pixels8

2024-07-13 Thread Rémi Denis-Courmont
---
 libavcodec/riscv/Makefile|  3 +-
 libavcodec/riscv/h264addpx_rvv.S | 89 
 libavcodec/riscv/h264dsp_init.c  | 11 
 3 files changed, 102 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/riscv/h264addpx_rvv.S

diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile
index 92e1544e76..0bbdd38116 100644
--- a/libavcodec/riscv/Makefile
+++ b/libavcodec/riscv/Makefile
@@ -31,7 +31,8 @@ RVV-OBJS-$(CONFIG_H263DSP) += riscv/h263dsp_rvv.o
 OBJS-$(CONFIG_H264CHROMA) += riscv/h264_chroma_init_riscv.o
 RVV-OBJS-$(CONFIG_H264CHROMA) += riscv/h264_mc_chroma.o
 OBJS-$(CONFIG_H264DSP) += riscv/h264dsp_init.o
-RVV-OBJS-$(CONFIG_H264DSP) += riscv/h264dsp_rvv.o riscv/h264idct_rvv.o
+RVV-OBJS-$(CONFIG_H264DSP) += riscv/h264addpx_rvv.o riscv/h264dsp_rvv.o \
+  riscv/h264idct_rvv.o
 OBJS-$(CONFIG_HUFFYUV_DECODER) += riscv/huffyuvdsp_init.o
 RVV-OBJS-$(CONFIG_HUFFYUV_DECODER) += riscv/huffyuvdsp_rvv.o
 OBJS-$(CONFIG_IDCTDSP) += riscv/idctdsp_init.o
diff --git a/libavcodec/riscv/h264addpx_rvv.S b/libavcodec/riscv/h264addpx_rvv.S
new file mode 100644
index 00..fd36bd4896
--- /dev/null
+++ b/libavcodec/riscv/h264addpx_rvv.S
@@ -0,0 +1,89 @@
+/*
+ * 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"
+
+.macro  sx rd, addr
+#if (__riscv_xlen == 32)
+sw  \rd, \addr
+#elif (__riscv_xlen == 64)
+sd  \rd, \addr
+#else
+sq  \rd, \addr
+#endif
+.endm
+
+func ff_h264_add_pixels4_8_rvv, zve32x
+vsetivlizero, 4, e8, mf4, ta, ma
+vlse32.vv8, (a0), a2
+vsetivlizero, 4 * 4, e8, m1, ta, ma
+vle16.v v16, (a1)
+.equoffset, 0
+.rept   256 / __riscv_xlen
+sx  zero, offset(a1)
+.equoffset, offset + (__riscv_xlen / 8)
+.endr
+vncvt.x.x.w v24, v16
+vadd.vv v8, v8, v24
+vsetivlizero, 4, e8, mf4, ta, ma
+vsse32.vv8, (a0), a2
+ret
+endfunc
+
+func ff_h264_add_pixels4_16_rvv, zve64x
+vsetivlizero, 4, e16, mf2, ta, ma
+vlse64.vv8, (a0), a2
+vsetivlizero, 4 * 4, e16, m2, ta, ma
+vle32.v v16, (a1)
+.equoffset, 0
+.rept   512 / __riscv_xlen
+sx  zero, offset(a1)
+.equoffset, offset + (__riscv_xlen / 8)
+.endr
+vncvt.x.x.w v24, v16
+vadd.vv v8, v8, v24
+vsetivlizero, 4, e16, mf2, ta, ma
+vsse64.vv8, (a0), a2
+ret
+endfunc
+
+func ff_h264_add_pixels8_8_rvv, zve64x
+li  t0, 8 * 8
+vsetivlizero, 8, e8, mf2, ta, ma
+vlse64.vv8, (a0), a2
+vsetvli zero, t0, e8, m4, ta, ma
+vle16.v v16, (a1)
+.equoffset, 0
+.rept   1024 / __riscv_xlen
+sx  zero, offset(a1)
+.equoffset, offset + (__riscv_xlen / 8)
+.endr
+vncvt.x.x.w v24, v16
+vadd.vv v8, v8, v24
+vsetivlizero, 8, e8, mf2, ta, ma
+vsse64.vv8, (a0), a2
+ret
+endfunc
diff --git a/libavcodec/riscv/h264dsp_init.c b/libavcodec/riscv/h264dsp_init.c
index 825f34443b..a6d06b3ac4 100644
--- a/libavcodec/riscv/h264dsp_init.c
+++ b/libavcodec/riscv/h264dsp_init.c
@@ -61,6 +61,10 @@ void ff_h264_idct8_add_12_rvv(uint8_t *dst, int16_t *block, 
int stride);
 void ff_h264_idct_add_14_rvv(uint8_t *dst, int16_t *block, int stride);
 void ff_h264_idct8_add_14_rvv(uint8_t *dst, int16_t *block, int stri

[FFmpeg-devel] [PATCH] libavformat/tls_mbedtls: Changes the return code handling of mbedtls_x509_crt_parse_file

2024-07-13 Thread Mohit Gupta

mbedtls_x509_crt_parse_file returns an error with negative numbers, and
positive numbers indicate the number of failed certificates to load from
certificate specific issues, such as critical extensions.

This would fix ticket #11079.

Signed-off-by: Mohit Gupta 
---
 libavformat/tls_mbedtls.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavformat/tls_mbedtls.c b/libavformat/tls_mbedtls.c
index 567b95b..97094e3 100644
--- a/libavformat/tls_mbedtls.c
+++ b/libavformat/tls_mbedtls.c
@@ -223,9 +223,11 @@ static int tls_open(URLContext *h, const char *uri, 
int flags, AVDictionary **op

  // load trusted CA
 if (shr->ca_file) {
-if ((ret = mbedtls_x509_crt_parse_file(&tls_ctx->ca_cert, 
shr->ca_file)) != 0) {
+if ((ret = mbedtls_x509_crt_parse_file(&tls_ctx->ca_cert, 
shr->ca_file)) < 0) {
 av_log(h, AV_LOG_ERROR, "mbedtls_x509_crt_parse_file for 
CA cert returned %d\n", ret);

 goto fail;
+} else if (ret > 0) {
+av_log(h, AV_LOG_DEBUG, "mbedtls_x509_crt_parse_file 
skipped %d certificate(s)\n", ret);

 }
 }
 -- 2.45.2



OpenPGP_signature.asc
Description: OpenPGP digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH] fate/lavf-container: add a test for L-HEVC remuxing

2024-07-13 Thread Anton Khirnov
Quoting James Almer (2024-07-12 14:22:11)
> Signed-off-by: James Almer 
> ---
>  tests/fate-run.sh   |  4 ++--
>  tests/fate/lavf-container.mak   | 28 +++-
>  tests/ref/lavf-fate/mv_hevc.mp4 |  3 +++
>  3 files changed, 20 insertions(+), 15 deletions(-)
>  create mode 100644 tests/ref/lavf-fate/mv_hevc.mp4
> 
> diff --git a/tests/fate-run.sh b/tests/fate-run.sh
> index 6ae0320c60..35f8da6be0 100755
> --- a/tests/fate-run.sh
> +++ b/tests/fate-run.sh
> @@ -401,8 +401,8 @@ lavf_container_fate()
>  cleanfiles="$cleanfiles $file"
>  input="${target_samples}/$1"
>  do_avconv $file -auto_conversion_filters $DEC_OPTS $2 -i "$input" \
> -  "$ENC_OPTS -metadata title=lavftest" -vcodec copy -acodec copy 
> || return
> -do_avconv_crc $file -auto_conversion_filters $DEC_OPTS -i 
> $target_path/$file $3
> +  $3 "$ENC_OPTS -metadata title=lavftest" -vcodec copy -acodec 
> copy || return
> +do_avconv_crc $file -auto_conversion_filters $DEC_OPTS -i 
> $target_path/$file $4

Can you give names to arguments? This is extra obscure.

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

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


Re: [FFmpeg-devel] [PATCH 1/2] avcodec/bsf/showinfo: print packet side data and flags

2024-07-13 Thread Anton Khirnov
Quoting James Almer (2024-07-12 02:33:06)
> Same as the framecrc muxer.

IOW obfuscated and user-hostile.

Please don't.

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

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


Re: [FFmpeg-devel] [PATCH 2/2] avcodec/bsf/showinfo: print packet data checksum

2024-07-13 Thread Anton Khirnov
Quoting James Almer (2024-07-12 02:33:07)
> Signed-off-by: James Almer 
> ---
>  libavcodec/bsf/showinfo.c | 6 +-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/bsf/showinfo.c b/libavcodec/bsf/showinfo.c
> index 0899263545..57da3fc73c 100644
> --- a/libavcodec/bsf/showinfo.c
> +++ b/libavcodec/bsf/showinfo.c
> @@ -23,6 +23,7 @@
>  #include "bsf.h"
>  #include "bsf_internal.h"
>  
> +#include "libavutil/adler32.h"
>  #include "libavutil/internal.h"
>  #include "libavutil/log.h"
>  #include "libavutil/timestamp.h"
> @@ -34,22 +35,25 @@ typedef struct ShowinfoContext {
>  static int showinfo_filter(AVBSFContext *ctx, AVPacket *pkt)
>  {
>  ShowinfoContext *priv = ctx->priv_data;
> +uint32_t crc;
>  int ret;
>  
>  ret = ff_bsf_get_packet_ref(ctx, pkt);
>  if (ret < 0)
>  return ret;
>  
> +crc = av_adler32_update(0, pkt->data, pkt->size);
>  av_log(ctx, AV_LOG_INFO,
> "n:%7"PRIu64" "
> "size:%7d "
> "pts:%s pt:%s "
> "dts:%s dt:%s "
> "ds:%"PRId64" d:%s "
> +   "0x%08"PRIx32,

could you prefix it with checksum: or something, so it's clear what it
means?

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

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


Re: [FFmpeg-devel] [PATCH 1/2] avcodec/bsf/showinfo: print packet side data and flags

2024-07-13 Thread James Almer

On 7/13/2024 10:46 AM, Anton Khirnov wrote:

Quoting James Almer (2024-07-12 02:33:06)

Same as the framecrc muxer.


IOW obfuscated and user-hostile.

Please don't.


You mean to not implement this in any form, or try to make it more user 
friendly? I could remove the flags (which is admittedly obfuscated), and 
only leave the crc which is useful to see in the middle of a bitstream 
filter list.

___
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] avcodec/bsf/showinfo: print packet side data and flags

2024-07-13 Thread Anton Khirnov
Quoting James Almer (2024-07-13 15:49:48)
> On 7/13/2024 10:46 AM, Anton Khirnov wrote:
> > Quoting James Almer (2024-07-12 02:33:06)
> >> Same as the framecrc muxer.
> > 
> > IOW obfuscated and user-hostile.
> > 
> > Please don't.
> 
> You mean to not implement this in any form, or try to make it more user 
> friendly?

The latter, if you want to spend effort on it. It is potentially useful
information, but in this form it's incomprehensible without reading the
code.

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

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


[FFmpeg-devel] [PATCH v2] avcodec/bsf/showinfo: print packet data checksum

2024-07-13 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/bsf/showinfo.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavcodec/bsf/showinfo.c b/libavcodec/bsf/showinfo.c
index 4e31e0b5cb..715b160b60 100644
--- a/libavcodec/bsf/showinfo.c
+++ b/libavcodec/bsf/showinfo.c
@@ -23,6 +23,7 @@
 #include "bsf.h"
 #include "bsf_internal.h"
 
+#include "libavutil/adler32.h"
 #include "libavutil/log.h"
 #include "libavutil/timestamp.h"
 
@@ -33,23 +34,26 @@ typedef struct ShowinfoContext {
 static int showinfo_filter(AVBSFContext *ctx, AVPacket *pkt)
 {
 ShowinfoContext *priv = ctx->priv_data;
+uint32_t crc;
 int ret;
 
 ret = ff_bsf_get_packet_ref(ctx, pkt);
 if (ret < 0)
 return ret;
 
+crc = av_adler32_update(0, pkt->data, pkt->size);
 av_log(ctx, AV_LOG_INFO,
"n:%7"PRIu64" "
"size:%7d "
"pts:%s pt:%s "
"dts:%s dt:%s "
"ds:%"PRId64" d:%s "
+   "adler32:0x%08"PRIx32
"\n",
priv->nb_packets, pkt->size,
av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &ctx->time_base_in),
av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &ctx->time_base_in),
-   pkt->duration, av_ts2timestr(pkt->duration, &ctx->time_base_in));
+   pkt->duration, av_ts2timestr(pkt->duration, &ctx->time_base_in), 
crc);
 
 priv->nb_packets++;
 
-- 
2.45.2

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

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


[FFmpeg-devel] [PATCH] mailmap: add entry for myself

2024-07-13 Thread Tong Wu
Signed-off-by: Tong Wu 
---
 .mailmap | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/.mailmap b/.mailmap
index 53cb5eac26..fe019b88c7 100644
--- a/.mailmap
+++ b/.mailmap
@@ -24,3 +24,5 @@ rcombs  
  
  
 Cosmin Stejerean  Cosmin Stejerean via ffmpeg-devel 

+ 
+ 
-- 
2.45.1.windows.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 v2] avcodec/bsf/showinfo: print packet data checksum

2024-07-13 Thread Anton Khirnov
Quoting James Almer (2024-07-13 16:05:35)
> Signed-off-by: James Almer 
> ---
>  libavcodec/bsf/showinfo.c | 6 +-
>  1 file changed, 5 insertions(+), 1 deletion(-)

LGTM

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

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


Re: [FFmpeg-devel] [PATCH 1/3] avutil/avassert: Add av_assert_unreachable()

2024-07-13 Thread epirat07
On 13 Jul 2024, at 2:47, Andreas Rheinhardt wrote:

> Marvin Scholz:
>> ---
>>  libavutil/avassert.h | 12 
>>  1 file changed, 12 insertions(+)
>>
>> diff --git a/libavutil/avassert.h b/libavutil/avassert.h
>> index 1895fb7551..cdab912fe4 100644
>> --- a/libavutil/avassert.h
>> +++ b/libavutil/avassert.h
>> @@ -75,4 +75,16 @@
>>   */
>>  void av_assert0_fpu(void);
>>
>> +/**
>> + * Assert this can not be reached
>> + */
>> +#if AV_HAS_BUILTIN(__builtin_unreachable)
>> +#define av_assert_unreachable() do {   \
>> +av_assert2(0);  \
>> +__builtin_unreachable();\
>> +} while (0)
>> +#else
>> +#define av_assert_unreachable() av_assert2(0)
>> +#endif
>> +
>>  #endif /* AVUTIL_AVASSERT_H */
>>
>> base-commit: 85706f5136cf7c88f95843b2634dd3f7d7d2cb6d
>
> You are not the first one with this idea:
> https://ffmpeg.org/pipermail/ffmpeg-devel/2024-May/328116.html
> But Michael Niedermayer thinks that adding a new macro instead of
> directly reusing av_assert is more complicated.
>
Oh I did not notice that one, thanks…

I definitely think an av_assert_unreachable() is clearer than
av_assert0(!"reached") too, obviously, else I would not propose it.

(Somewhat proven by these two cases fixed by the patch where we use
av_assert1/2(0) variants which then result in the compiler not knowing
these are unreachable cases when the assert is not enabled.)

If this approach is rejected, I can submit a version that uses
av_assert0(!"reached“).

> - 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 mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 10/11] avfilter/yadif_common: remove unused variable

2024-07-13 Thread epirat07



On 13 Jul 2024, at 2:50, Andreas Rheinhardt wrote:

> Marvin Scholz:
>> ---
>>  libavfilter/vf_yadif_videotoolbox.m | 1 -
>>  1 file changed, 1 deletion(-)
>>
>> diff --git a/libavfilter/vf_yadif_videotoolbox.m 
>> b/libavfilter/vf_yadif_videotoolbox.m
>> index c47d3edfb8..eb7026395e 100644
>> --- a/libavfilter/vf_yadif_videotoolbox.m
>> +++ b/libavfilter/vf_yadif_videotoolbox.m
>> @@ -172,7 +172,6 @@ static void filter(AVFilterContext *ctx, AVFrame *dst,
>>  static av_cold void do_uninit(AVFilterContext *ctx) 
>> API_AVAILABLE(macos(10.11), ios(8.0))
>>  {
>>  YADIFVTContext *s = ctx->priv;
>> -YADIFContext *y = &s->yadif;
>>
>>  ff_yadif_uninit(ctx);
>>
>
> This is not yadif_common.

Thanks, will be fixed in the next iteration.

>
> - 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 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/4] avcodec/cbs_h265: fix range of sps_max_sub_layers_minus1

2024-07-13 Thread James Almer
The VPS referenced by the SPS must always be present as the max value for
sps_max_sub_layers_minus1 is vps_max_sub_layers_minus1. This replaces a buggy
custom range check for the aforementioned field.
Also, add the missing conformance check for sps_temporal_id_nesting_flag while
at it.

Signed-off-by: James Almer 
---
 libavcodec/cbs_h265_syntax_template.c | 37 +++
 1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/libavcodec/cbs_h265_syntax_template.c 
b/libavcodec/cbs_h265_syntax_template.c
index 86ca00a0c9..c6db439b3b 100644
--- a/libavcodec/cbs_h265_syntax_template.c
+++ b/libavcodec/cbs_h265_syntax_template.c
@@ -788,25 +788,28 @@ static int FUNC(sps)(CodedBitstreamContext *ctx, 
RWContext *rw,
 
 ub(4, sps_video_parameter_set_id);
 h265->active_vps = vps = h265->vps[current->sps_video_parameter_set_id];
+if (!vps) {
+av_log(ctx->log_ctx, AV_LOG_ERROR, "VPS id %d not available.\n",
+   current->sps_video_parameter_set_id);
+return AVERROR_INVALIDDATA;
+}
 
-u(3, sps_max_sub_layers_minus1, 0, HEVC_MAX_SUB_LAYERS - 1);
+u(3, sps_max_sub_layers_minus1, 0, vps->vps_max_sub_layers_minus1);
 flag(sps_temporal_id_nesting_flag);
-if (vps) {
-if (vps->vps_max_sub_layers_minus1 > 
current->sps_max_sub_layers_minus1) {
-av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid stream: "
-   "sps_max_sub_layers_minus1 (%d) must be less than or equal 
to "
-   "vps_max_sub_layers_minus1 (%d).\n",
-   vps->vps_max_sub_layers_minus1,
-   current->sps_max_sub_layers_minus1);
-return AVERROR_INVALIDDATA;
-}
-if (vps->vps_temporal_id_nesting_flag &&
-!current->sps_temporal_id_nesting_flag) {
-av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid stream: "
-   "sps_temporal_id_nesting_flag must be 1 if "
-   "vps_temporal_id_nesting_flag is 1.\n");
-return AVERROR_INVALIDDATA;
-}
+
+if (vps->vps_temporal_id_nesting_flag &&
+!current->sps_temporal_id_nesting_flag) {
+av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid stream: "
+   "sps_temporal_id_nesting_flag must be 1 if "
+   "vps_temporal_id_nesting_flag is 1.\n");
+return AVERROR_INVALIDDATA;
+}
+if (current->sps_max_sub_layers_minus1 == 0 &&
+current->sps_temporal_id_nesting_flag != 1) {
+av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid stream: "
+   "sps_temporal_id_nesting_flag must be 1 if "
+   "sps_max_sub_layers_minus1 is 0.\n");
+return AVERROR_INVALIDDATA;
 }
 
 CHECK(FUNC(profile_tier_level)(ctx, rw, ¤t->profile_tier_level,
-- 
2.45.2

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

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


[FFmpeg-devel] [PATCH 2/4] avcodec/cbs_h265: add partial support for Multilayer extension fields in parameter set NALUs

2024-07-13 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/cbs_h2645.c|   3 +-
 libavcodec/cbs_h265.h |  44 ++
 libavcodec/cbs_h265_syntax_template.c | 113 +-
 libavcodec/hevc/ps.h  |   4 +-
 4 files changed, 159 insertions(+), 5 deletions(-)

diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index 5ec781ddab..828e56b8c0 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -499,7 +499,8 @@ static int 
cbs_h2645_fragment_add_nals(CodedBitstreamContext *ctx,
 size_t size = nal->size;
 enum AVCodecID codec_id = ctx->codec->codec_id;
 
-if (codec_id != AV_CODEC_ID_VVC && nal->nuh_layer_id > 0)
+if (codec_id == AV_CODEC_ID_HEVC && nal->nuh_layer_id > 0 &&
+(nal->type < HEVC_NAL_VPS || nal->type > HEVC_NAL_PPS))
 continue;
 
 // Remove trailing zeroes.
diff --git a/libavcodec/cbs_h265.h b/libavcodec/cbs_h265.h
index 91a5a55317..afb942ced5 100644
--- a/libavcodec/cbs_h265.h
+++ b/libavcodec/cbs_h265.h
@@ -248,12 +248,16 @@ typedef struct H265RawSPS {
 uint8_t sps_video_parameter_set_id;
 
 uint8_t sps_max_sub_layers_minus1;
+uint8_t sps_ext_or_max_sub_layers_minus1;
 uint8_t sps_temporal_id_nesting_flag;
 
 H265RawProfileTierLevel profile_tier_level;
 
 uint8_t sps_seq_parameter_set_id;
 
+uint8_t update_rep_format_flag;
+uint8_t sps_rep_format_idx;
+
 uint8_t chroma_format_idc;
 uint8_t separate_colour_plane_flag;
 
@@ -284,6 +288,8 @@ typedef struct H265RawSPS {
 uint8_t max_transform_hierarchy_depth_intra;
 
 uint8_t scaling_list_enabled_flag;
+uint8_t sps_infer_scaling_list_flag;
+uint8_t sps_scaling_list_ref_layer_id;
 uint8_t sps_scaling_list_data_present_flag;
 H265RawScalingList scaling_list;
 
@@ -342,6 +348,9 @@ typedef struct H265RawSPS {
 
 uint8_t motion_vector_resolution_control_idc;
 uint8_t intra_boundary_filtering_disable_flag;
+
+// Multilayer extension.
+uint8_t inter_view_mv_vert_constraint_flag;
 } H265RawSPS;
 
 typedef struct H265RawPPS {
@@ -433,6 +442,41 @@ typedef struct H265RawPPS {
 uint8_t luma_bit_depth_entry_minus8;
 uint8_t chroma_bit_depth_entry_minus8;
 uint16_t pps_palette_predictor_initializers[3][128];
+
+// Multilayer extension.
+uint8_t poc_reset_info_present_flag;
+uint8_t pps_infer_scaling_list_flag;
+uint8_t pps_scaling_list_ref_layer_id;
+uint8_t num_ref_loc_offsets;
+uint8_t ref_loc_offset_layer_id[64];
+uint8_t scaled_ref_layer_offset_present_flag[64];
+int16_t scaled_ref_layer_left_offset[64];
+int16_t scaled_ref_layer_top_offset[64];
+int16_t scaled_ref_layer_right_offset[64];
+int16_t scaled_ref_layer_bottom_offset[64];
+uint8_t ref_region_offset_present_flag[64];
+int16_t ref_region_left_offset[64];
+int16_t ref_region_top_offset[64];
+int16_t ref_region_right_offset[64];
+int16_t ref_region_bottom_offset[64];
+uint8_t resample_phase_set_present_flag[64];
+uint8_t phase_hor_luma[64];
+uint8_t phase_ver_luma[64];
+uint8_t phase_hor_chroma_plus8[64];
+uint8_t phase_ver_chroma_plus8[64];
+uint8_t colour_mapping_enabled_flag;
+uint8_t num_cm_ref_layers;
+uint8_t cm_ref_layer_id[62];
+uint8_t cm_octant_depth;
+uint8_t cm_y_part_num_log2;
+uint8_t luma_bit_depth_cm_input;
+uint8_t chroma_bit_depth_cm_input;
+uint8_t luma_bit_depth_cm_output;
+uint8_t chroma_bit_depth_cm_output;
+uint8_t cm_res_quant_bits;
+uint8_t cm_delta_flc_bits;
+int8_t cm_adapt_threshold_u_delta;
+int8_t cm_adapt_threshold_v_delta;
 } H265RawPPS;
 
 typedef struct H265RawAUD {
diff --git a/libavcodec/cbs_h265_syntax_template.c 
b/libavcodec/cbs_h265_syntax_template.c
index c6db439b3b..2f8ee0db10 100644
--- a/libavcodec/cbs_h265_syntax_template.c
+++ b/libavcodec/cbs_h265_syntax_template.c
@@ -747,6 +747,16 @@ static int FUNC(sps_scc_extension)(CodedBitstreamContext 
*ctx, RWContext *rw,
 return 0;
 }
 
+static int FUNC(sps_multilayer_extension)(CodedBitstreamContext *ctx, 
RWContext *rw,
+  H265RawSPS *current)
+{
+int err;
+
+flag(inter_view_mv_vert_constraint_flag);
+
+return 0;
+}
+
 static int FUNC(vui_parameters_default)(CodedBitstreamContext *ctx,
 RWContext *rw, H265RawVUI *current,
 H265RawSPS *sps)
@@ -781,6 +791,7 @@ static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext 
*rw,
 int err, i;
 unsigned int min_cb_log2_size_y, ctb_log2_size_y,
  min_cb_size_y,   min_tb_log2_size_y;
+unsigned int multi_layer_ext_sps_flag;
 
 HEADER("Sequence Parameter Set");
 
@@ -794,7 +805,17 @@ static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext 
*rw,
 return AVERROR_INVALIDDATA;
 }
 
+if (current->nal_unit_header.nuh_layer_id == 0)
 u(3

[FFmpeg-devel] [PATCH 3/4] avcodec/cbs_h265: reindent after the previous commit

2024-07-13 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/cbs_h265_syntax_template.c | 124 +-
 1 file changed, 62 insertions(+), 62 deletions(-)

diff --git a/libavcodec/cbs_h265_syntax_template.c 
b/libavcodec/cbs_h265_syntax_template.c
index 2f8ee0db10..1826950e8e 100644
--- a/libavcodec/cbs_h265_syntax_template.c
+++ b/libavcodec/cbs_h265_syntax_template.c
@@ -806,7 +806,7 @@ static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext 
*rw,
 }
 
 if (current->nal_unit_header.nuh_layer_id == 0)
-u(3, sps_max_sub_layers_minus1, 0, vps->vps_max_sub_layers_minus1);
+u(3, sps_max_sub_layers_minus1, 0, vps->vps_max_sub_layers_minus1);
 else {
 u(3, sps_ext_or_max_sub_layers_minus1, 0, HEVC_MAX_SUB_LAYERS);
 infer(sps_max_sub_layers_minus1, 
current->sps_ext_or_max_sub_layers_minus1 == 7
@@ -816,25 +816,25 @@ static int FUNC(sps)(CodedBitstreamContext *ctx, 
RWContext *rw,
 multi_layer_ext_sps_flag = current->nal_unit_header.nuh_layer_id &&
current->sps_ext_or_max_sub_layers_minus1 == 7;
 if (!multi_layer_ext_sps_flag) {
-flag(sps_temporal_id_nesting_flag);
+flag(sps_temporal_id_nesting_flag);
 
-if (vps->vps_temporal_id_nesting_flag &&
-!current->sps_temporal_id_nesting_flag) {
-av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid stream: "
-   "sps_temporal_id_nesting_flag must be 1 if "
-   "vps_temporal_id_nesting_flag is 1.\n");
-return AVERROR_INVALIDDATA;
-}
-if (current->sps_max_sub_layers_minus1 == 0 &&
-current->sps_temporal_id_nesting_flag != 1) {
-av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid stream: "
-   "sps_temporal_id_nesting_flag must be 1 if "
-   "sps_max_sub_layers_minus1 is 0.\n");
-return AVERROR_INVALIDDATA;
-}
+if (vps->vps_temporal_id_nesting_flag &&
+!current->sps_temporal_id_nesting_flag) {
+av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid stream: "
+   "sps_temporal_id_nesting_flag must be 1 if "
+   "vps_temporal_id_nesting_flag is 1.\n");
+return AVERROR_INVALIDDATA;
+}
+if (current->sps_max_sub_layers_minus1 == 0 &&
+current->sps_temporal_id_nesting_flag != 1) {
+av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid stream: "
+   "sps_temporal_id_nesting_flag must be 1 if "
+   "sps_max_sub_layers_minus1 is 0.\n");
+return AVERROR_INVALIDDATA;
+}
 
-CHECK(FUNC(profile_tier_level)(ctx, rw, ¤t->profile_tier_level,
-   1, current->sps_max_sub_layers_minus1));
+CHECK(FUNC(profile_tier_level)(ctx, rw, ¤t->profile_tier_level,
+   1, current->sps_max_sub_layers_minus1));
 } else {
 if (current->sps_max_sub_layers_minus1 > 0)
 infer(sps_temporal_id_nesting_flag, 
vps->vps_temporal_id_nesting_flag);
@@ -849,56 +849,56 @@ static int FUNC(sps)(CodedBitstreamContext *ctx, 
RWContext *rw,
 if (current->update_rep_format_flag)
 ub(8, sps_rep_format_idx);
 } else {
-ue(chroma_format_idc, 0, 3);
-if (current->chroma_format_idc == 3)
-flag(separate_colour_plane_flag);
-else
-infer(separate_colour_plane_flag, 0);
+ue(chroma_format_idc, 0, 3);
+if (current->chroma_format_idc == 3)
+flag(separate_colour_plane_flag);
+else
+infer(separate_colour_plane_flag, 0);
 
-ue(pic_width_in_luma_samples,  1, HEVC_MAX_WIDTH);
-ue(pic_height_in_luma_samples, 1, HEVC_MAX_HEIGHT);
+ue(pic_width_in_luma_samples,  1, HEVC_MAX_WIDTH);
+ue(pic_height_in_luma_samples, 1, HEVC_MAX_HEIGHT);
 
-flag(conformance_window_flag);
-if (current->conformance_window_flag) {
-ue(conf_win_left_offset,   0, current->pic_width_in_luma_samples);
-ue(conf_win_right_offset,  0, current->pic_width_in_luma_samples);
-ue(conf_win_top_offset,0, current->pic_height_in_luma_samples);
-ue(conf_win_bottom_offset, 0, current->pic_height_in_luma_samples);
-} else {
-infer(conf_win_left_offset,   0);
-infer(conf_win_right_offset,  0);
-infer(conf_win_top_offset,0);
-infer(conf_win_bottom_offset, 0);
-}
+flag(conformance_window_flag);
+if (current->conformance_window_flag) {
+ue(conf_win_left_offset,   0, current->pic_width_in_luma_samples);
+ue(conf_win_right_offset,  0, current->pic_width_in_luma_samples);
+ue(conf_win_top_offset,0, current->pic_height_in_luma_samples);
+ue(conf_win_bottom_offset, 0, current->pic_height_in_luma_samples);
+} else {
+infer(conf_win_left_offset,   0);
+infer(conf_win_right_offset,  0);
+infer(conf_win_top_offset,0);
+infer(conf_win_b

[FFmpeg-devel] [PATCH 4/4] avcodec/cbs_h265: add support for 3D Reference Displays Information SEI

2024-07-13 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/cbs_h2645.c|  6 
 libavcodec/cbs_h265.h | 16 ++
 libavcodec/cbs_h265_syntax_template.c | 42 +++
 3 files changed, 64 insertions(+)

diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index 828e56b8c0..d73d77a985 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -2275,6 +2275,12 @@ static const SEIMessageTypeDescriptor 
cbs_sei_h265_types[] = {
 sizeof(H265RawSEIAlphaChannelInfo),
 SEI_MESSAGE_RW(h265, sei_alpha_channel_info),
 },
+{
+SEI_TYPE_THREE_DIMENSIONAL_REFERENCE_DISPLAYS_INFO,
+1, 0,
+sizeof(H265RawSEI3DReferenceDisplaysInfo),
+SEI_MESSAGE_RW(h265, sei_3d_reference_displays_info),
+},
 SEI_MESSAGE_TYPE_END
 };
 
diff --git a/libavcodec/cbs_h265.h b/libavcodec/cbs_h265.h
index afb942ced5..52631f9bfb 100644
--- a/libavcodec/cbs_h265.h
+++ b/libavcodec/cbs_h265.h
@@ -715,6 +715,22 @@ typedef struct H265RawSEIAlphaChannelInfo {
 uint8_t  alpha_channel_clip_type_flag;
 } H265RawSEIAlphaChannelInfo;
 
+typedef struct H265RawSEI3DReferenceDisplaysInfo {
+uint8_t prec_ref_display_width;
+uint8_t ref_viewing_distance_flag;
+uint8_t prec_ref_viewing_dist;
+uint8_t num_ref_displays_minus1;
+uint8_t left_view_id[31];
+uint8_t right_view_id[31];
+uint8_t exponent_ref_display_width[31];
+uint8_t mantissa_ref_display_width[31];
+uint8_t exponent_ref_viewing_distance[31];
+uint8_t mantissa_ref_viewing_distance[31];
+uint8_t additional_shift_present_flag[31];
+uint16_t num_sample_shift_plus512[31];
+uint8_t three_dimensional_reference_displays_extension_flag;
+} H265RawSEI3DReferenceDisplaysInfo;
+
 typedef struct H265RawSEI {
 H265RawNALUnitHeader nal_unit_header;
 SEIRawMessageListmessage_list;
diff --git a/libavcodec/cbs_h265_syntax_template.c 
b/libavcodec/cbs_h265_syntax_template.c
index 1826950e8e..ee01b5e0d0 100644
--- a/libavcodec/cbs_h265_syntax_template.c
+++ b/libavcodec/cbs_h265_syntax_template.c
@@ -2189,6 +2189,48 @@ SEI_FUNC(sei_alpha_channel_info, (CodedBitstreamContext 
*ctx, RWContext *rw,
 return 0;
 }
 
+SEI_FUNC(sei_3d_reference_displays_info, (CodedBitstreamContext *ctx, 
RWContext *rw,
+  H265RawSEI3DReferenceDisplaysInfo 
*current,
+  SEIMessageState *sei))
+{
+int length;
+int err, i;
+
+HEADER("Three Dimensional Reference Displays Information");
+
+ue(prec_ref_display_width, 0, 31);
+flag(ref_viewing_distance_flag);
+if (current->ref_viewing_distance_flag)
+ue(prec_ref_viewing_dist, 0, 31);
+ue(num_ref_displays_minus1, 0, 31);
+for (i = 0; i <= current->num_ref_displays_minus1; i++) {
+ues(left_view_id[i], 0, UINT8_MAX, 1, i);
+ues(right_view_id[i], 0, UINT8_MAX, 1, i);
+us(6, exponent_ref_display_width[i], 0, 62, 1, i);
+if (!current->exponent_ref_display_width[i])
+length = FFMAX(0, (int)current->prec_ref_display_width - 30);
+else
+length = FFMAX(0, (int)current->exponent_ref_display_width[i] +
+  (int)current->prec_ref_display_width - 31);
+ubs(length, mantissa_ref_display_width[i], 1, i);
+if (current->ref_viewing_distance_flag) {
+us(6, exponent_ref_viewing_distance[i], 0, 62, 1, i);
+if (!current->exponent_ref_viewing_distance[i])
+length = FFMAX(0, (int)current->prec_ref_viewing_dist - 30);
+else
+length = FFMAX(0, 
(int)current->exponent_ref_viewing_distance[i] +
+  (int)current->prec_ref_viewing_dist - 31);
+ubs(length, mantissa_ref_viewing_distance[i], 1, i);
+}
+flags(additional_shift_present_flag[i], 1, i);
+if (current->additional_shift_present_flag[i])
+us(10, num_sample_shift_plus512[i], 0, 1023, 1, i);
+}
+flag(three_dimensional_reference_displays_extension_flag);
+
+return 0;
+}
+
 static int FUNC(sei)(CodedBitstreamContext *ctx, RWContext *rw,
  H265RawSEI *current, int prefix)
 {
-- 
2.45.2

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

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


Re: [FFmpeg-devel] [PATCH v4] avformat/dvdvideodec: Fix incorrect padding cell trim logic

2024-07-13 Thread Stefano Sabatini
On Fri, Jul 12, 2024 at 5:31 AM Marth64  wrote:
>
> Ping to apply on this set of 3, so I can send seeking and additional
> cleanup set (as a collection). Thank you!

Applied patches:
eb07a59 avformat/dvdvideodec: Don't add chapter markers for empty/dummy PTTs
f37f86a avformat/dvdvideodec: Remove redundant ret initializations
f1abb75 avformat/dvdvideodec: Fix incorrect padding cell trim logic

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


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

2024-07-13 Thread Michael Niedermayer
This is not a bugfix in code but coverity only, it does look a little nicer 
though

Fixes: CID732224

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer 
---
 libavformat/lmlm4.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/lmlm4.c b/libavformat/lmlm4.c
index 209b544ccd8..c8355e7a8d6 100644
--- a/libavformat/lmlm4.c
+++ b/libavformat/lmlm4.c
@@ -91,7 +91,6 @@ static int lmlm4_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 frame_type  = avio_rb16(pb);
 packet_size = avio_rb32(pb);
 padding = -packet_size & 511;
-frame_size  = packet_size - 8;
 
 if (frame_type > LMLM4_MPEG1L2 || frame_type == LMLM4_INVALID) {
 av_log(s, AV_LOG_ERROR, "invalid or unsupported frame_type\n");
@@ -102,6 +101,7 @@ static int lmlm4_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 return AVERROR(EIO);
 }
 
+frame_size  = packet_size - 8;
 if ((ret = av_get_packet(pb, pkt, frame_size)) <= 0)
 return AVERROR(EIO);
 
-- 
2.45.2

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

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


[FFmpeg-devel] [PATCH 2/3] avformat/lmlm4: Eliminate some AVERROR(EIO)

2024-07-13 Thread Michael Niedermayer
Found by code review related to CID732224 Overflowed constant

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer 
---
 libavformat/lmlm4.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavformat/lmlm4.c b/libavformat/lmlm4.c
index c8355e7a8d6..cec2f7ca051 100644
--- a/libavformat/lmlm4.c
+++ b/libavformat/lmlm4.c
@@ -94,16 +94,16 @@ static int lmlm4_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 
 if (frame_type > LMLM4_MPEG1L2 || frame_type == LMLM4_INVALID) {
 av_log(s, AV_LOG_ERROR, "invalid or unsupported frame_type\n");
-return AVERROR(EIO);
+return AVERROR_INVALIDDATA;
 }
 if (packet_size > LMLM4_MAX_PACKET_SIZE || packet_size<=8) {
 av_log(s, AV_LOG_ERROR, "packet size %d is invalid\n", packet_size);
-return AVERROR(EIO);
+return AVERROR_INVALIDDATA;
 }
 
 frame_size  = packet_size - 8;
 if ((ret = av_get_packet(pb, pkt, frame_size)) <= 0)
-return AVERROR(EIO);
+return ret < 0 ? ret : AVERROR(EIO);
 
 avio_skip(pb, padding);
 
-- 
2.45.2

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

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


[FFmpeg-devel] [PATCH 3/3] avfilter/vf_xfade_opencl: Check ff_inlink_consume_frame() for failure

2024-07-13 Thread Michael Niedermayer
Fixes: CID1458127 Unchecked return value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer 
---
 libavfilter/vf_xfade_opencl.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vf_xfade_opencl.c b/libavfilter/vf_xfade_opencl.c
index 2368c046b4d..8582230924a 100644
--- a/libavfilter/vf_xfade_opencl.c
+++ b/libavfilter/vf_xfade_opencl.c
@@ -293,7 +293,9 @@ static int xfade_opencl_activate(AVFilterContext *avctx)
 if (ctx->first_pts + ctx->offset_pts > ctx->xf[0]->pts) {
 ctx->xf[0] = NULL;
 ctx->need_second = 0;
-ff_inlink_consume_frame(avctx->inputs[0], &in);
+ret = ff_inlink_consume_frame(avctx->inputs[0], &in);
+if (ret < 0)
+return ret;
 return ff_filter_frame(outlink, in);
 }
 
@@ -302,8 +304,14 @@ static int xfade_opencl_activate(AVFilterContext *avctx)
 }
 
 if (ctx->xf[0] && ff_inlink_queued_frames(avctx->inputs[1]) > 0) {
-ff_inlink_consume_frame(avctx->inputs[0], &ctx->xf[0]);
-ff_inlink_consume_frame(avctx->inputs[1], &ctx->xf[1]);
+ret = ff_inlink_consume_frame(avctx->inputs[0], &ctx->xf[0]);
+if (ret < 0)
+return ret;
+ret = ff_inlink_consume_frame(avctx->inputs[1], &ctx->xf[1]);
+if (ret < 0) {
+av_frame_free(&ctx->xf[0]);
+return ret;
+}
 
 ctx->last_pts = ctx->xf[1]->pts;
 ctx->pts = ctx->xf[0]->pts;
-- 
2.45.2

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

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


Re: [FFmpeg-devel] [PATCH v4] avformat/dvdvideodec: Fix incorrect padding cell trim logic

2024-07-13 Thread Marth64
Thank you!
___
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/h264dsp: test TX bypass

2024-07-13 Thread Rémi Denis-Courmont
---
 tests/checkasm/h264dsp.c | 37 +++--
 1 file changed, 23 insertions(+), 14 deletions(-)

diff --git a/tests/checkasm/h264dsp.c b/tests/checkasm/h264dsp.c
index 67b8dce53c..1df76d72d2 100644
--- a/tests/checkasm/h264dsp.c
+++ b/tests/checkasm/h264dsp.c
@@ -188,23 +188,32 @@ static void check_idct(void)
 for (i = 0; i < FF_ARRAY_ELEMS(depths); i++) {
 bit_depth = depths[i];
 ff_h264dsp_init(&h, bit_depth, 1);
-for (sz = 4; sz <= 8; sz += 4) {
-randomize_buffers(i);
 
-if (sz == 4)
-dct4x4(coef, bit_depth);
-else
-dct8x8(coef, bit_depth);
-
-for (dc = 0; dc <= 1; dc++) {
+for (dc = 0; dc <= 2; dc++) {
+for (sz = 4; sz <= 8; sz += 4) {
 void (*idct)(uint8_t *, int16_t *, int) = NULL;
-switch ((sz << 1) | dc) {
-case (4 << 1) | 0: idct = h.h264_idct_add; break;
-case (4 << 1) | 1: idct = h.h264_idct_dc_add; break;
-case (8 << 1) | 0: idct = h.h264_idct8_add; break;
-case (8 << 1) | 1: idct = h.h264_idct8_dc_add; break;
+const char fmts[3][24] = {
+"h264_idct%d_add_%dbpp", "h264_idct%d_dc_add_%dbpp",
+"h264_add_pixels%d_%dbpp",
+};
+
+randomize_buffers(i);
+
+if (sz == 4)
+dct4x4(coef, bit_depth);
+else
+dct8x8(coef, bit_depth);
+
+switch ((sz << 2) | dc) {
+case (4 << 2) | 0: idct = h.h264_idct_add; break;
+case (4 << 2) | 1: idct = h.h264_idct_dc_add; break;
+case (4 << 2) | 2: idct = h.h264_add_pixels4_clear; break;
+case (8 << 2) | 0: idct = h.h264_idct8_add; break;
+case (8 << 2) | 1: idct = h.h264_idct8_dc_add; break;
+case (8 << 2) | 2: idct = h.h264_add_pixels8_clear; break;
 }
-if (check_func(idct, "h264_idct%d_add%s_%dbpp", sz, dc ? "_dc" 
: "", bit_depth)) {
+
+if (check_func(idct, fmts[dc], sz, bit_depth)) {
 for (align = 0; align < 16; align += sz * SIZEOF_PIXEL) {
 uint8_t *dst1 = dst1_base + align;
 if (dc) {
-- 
2.45.2

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

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


Re: [FFmpeg-devel] [PATCH 1/2] lavc/h264dsp: R-V V add_pixels4 and 8-bit add_pixels8

2024-07-13 Thread Rémi Denis-Courmont
T-Head C908 (cycles):
h264_add_pixels4_8bpp_c:93.5
h264_add_pixels4_8bpp_rvv_i32:  39.5
h264_add_pixels4_9bpp_c:87.5
h264_add_pixels4_9bpp_rvv_i64:  50.5
h264_add_pixels4_10bpp_c:   87.5
h264_add_pixels4_10bpp_rvv_i64: 50.5
h264_add_pixels4_12bpp_c:   87.5
h264_add_pixels4_12bpp_rvv_i64: 50.5
h264_add_pixels4_14bpp_c:   87.5
h264_add_pixels4_14bpp_rvv_i64: 50.5
h264_add_pixels8_8bpp_c:   265.2
h264_add_pixels8_8bpp_rvv_i64:  84.5

-- 
雷米‧德尼-库尔蒙
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".


Re: [FFmpeg-devel] [PATCH 2/2] lavc/h264dsp: R-V V high-depth add_pixels8

2024-07-13 Thread Rémi Denis-Courmont
T-Head C908 (cycles);
h264_add_pixels8_9bpp_c:270.5
h264_add_pixels8_9bpp_rvv_i32:  164.2
h264_add_pixels8_10bpp_c:   270.5
h264_add_pixels8_10bpp_rvv_i32: 164.2
h264_add_pixels8_12bpp_c:   270.5
h264_add_pixels8_12bpp_rvv_i32: 164.2
h264_add_pixels8_14bpp_c:   270.5
h264_add_pixels8_14bpp_rvv_i32: 164.2

-- 
雷米‧德尼-库尔蒙
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] checkasm/h264: test weight and biweight

2024-07-13 Thread Rémi Denis-Courmont
---
 tests/checkasm/h264dsp.c | 79 +++-
 1 file changed, 78 insertions(+), 1 deletion(-)

diff --git a/tests/checkasm/h264dsp.c b/tests/checkasm/h264dsp.c
index d1228ed985..39397f77e1 100644
--- a/tests/checkasm/h264dsp.c
+++ b/tests/checkasm/h264dsp.c
@@ -29,6 +29,81 @@
 
 static const uint32_t pixel_mask[5] = { 0x, 0x01ff01ff, 0x03ff03ff, 
0x0fff0fff, 0x3fff3fff };
 static const uint32_t pixel_mask_lf[3] = { 0xff0fff0f, 0x01ff000f, 0x03ff000f 
};
+static const int depths[5] = { 8, 9, 10, 12, 14 };
+
+static void check_weight(void)
+{
+#define HEIGHT 128
+for (int d = 0; d < FF_ARRAY_ELEMS(depths); d++) {
+const int bit_depth = depths[d];
+const int offset = rnd() & 0;
+const int log_denom = rnd() & 7;
+const int wa = rnd() & ((1 << log_denom) - 1);
+const int wb = rnd() & ((1 << log_denom) - 1);
+uint16_t ref[HEIGHT * 128 * 2], src[HEIGHT * 128 * 2];
+uint16_t out0[HEIGHT * 128 * 2], out1[HEIGHT * 128 * 2];
+uint8_t *const pref = (void *)ref;
+uint8_t *const psrc = (void *)src;
+uint8_t *const pout0 = (void *)out0;
+uint8_t *const pout1 = (void *)out1;
+H264DSPContext h;
+
+ff_h264dsp_init(&h, bit_depth, 1);
+
+for (size_t i = 0; i < FF_ARRAY_ELEMS(ref); i++)
+if (bit_depth == 8) {
+pref[i] = rnd();
+psrc[i] = rnd();
+} else {
+ref[i] = rnd() & (0x >> (16 - d));
+src[i] = rnd() & (0x >> (16 - d));
+}
+
+for (int w = 0; w < 4; w++) {
+declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *block,
+  ptrdiff_t stride, int height, int log2_denom,
+  int weight, int offset);
+
+if (check_func(h.weight_h264_pixels_tab[w], "h264_weight%d_%d",
+   16 >> w, bit_depth)) {
+memcpy(out0, ref, sizeof (out0));
+memcpy(out1, ref, sizeof (out1));
+
+call_ref(pout0, 32 >> w, HEIGHT, log_denom, wa, offset);
+call_new(pout1, 32 >> w, HEIGHT, log_denom, wa, offset);
+
+if (memcmp(out0, out1, sizeof (ref)))
+fail();
+
+bench_new(pout1, 32 >> w, HEIGHT, log_denom, wa, offset);
+}
+}
+
+for (int w = 0; w < 4; w++) {
+declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst,
+  const uint8_t *src, ptrdiff_t stride, int height,
+  int log2_denom, int wd, int ws, int offset);
+
+if (check_func(h.biweight_h264_pixels_tab[w], "h264_biweight%d_%d",
+   16 >> w, bit_depth)) {
+memcpy(out0, ref, sizeof (out0));
+memcpy(out1, ref, sizeof (out1));
+
+call_ref(pout0, psrc, 32 >> w, HEIGHT, log_denom, wa, wb,
+ offset);
+call_new(pout1, psrc, 32 >> w, HEIGHT, log_denom, wa, wb,
+ offset);
+
+if (memcmp(out0, out1, sizeof (ref)))
+fail();
+
+bench_new(pout1, psrc, 32 >> w, HEIGHT, log_denom, wa, wb,
+  offset);
+}
+}
+}
+#undef HEIGHT
+}
 
 #define SIZEOF_PIXEL ((bit_depth + 7) / 8)
 #define SIZEOF_COEF  (2 * ((bit_depth + 7) / 8))
@@ -173,7 +248,6 @@ static void dct8x8(int16_t *coef, int bit_depth)
 
 static void check_idct(void)
 {
-static const int depths[5] = { 8, 9, 10, 12, 14 };
 LOCAL_ALIGNED_16(uint8_t, src,  [8 * 8 * 2]);
 LOCAL_ALIGNED_16(uint8_t, dst,  [8 * 8 * 2]);
 LOCAL_ALIGNED_16(uint8_t, dst0, [8 * 8 * 2]);
@@ -451,6 +525,9 @@ static void check_loop_filter_intra(void)
 
 void checkasm_check_h264dsp(void)
 {
+check_weight();
+report("weight");
+
 check_idct();
 check_idct_multiple();
 report("idct");
-- 
2.45.2

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

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


Re: [FFmpeg-devel] [OSS-Fuzz] Have you considered enabling memory sanitizer?

2024-07-13 Thread Kacper Michajlow
On Thu, 27 Jun 2024 at 02:50, Kacper Michajlow  wrote:
>
> On Thu, 27 Jun 2024 at 00:45, Michael Niedermayer
>  wrote:
> >
> > On Wed, Jun 26, 2024 at 09:07:42PM +0200, Kacper Michajlow wrote:
> > > Hi,
> > >
> > > Like in the topic. I think it would be useful to enable MSAN on
> > > OSS-Fuzz. We get some tiny issues and it would be probably good to
> > > have them tracked upstream. All infra is here, so enabling it is as
> > > simple as adding it to the project.yaml. Except libbz2.so and libz.so
> > > would have to be built inline instead, looking at the build.sh, they
> > > are prebuilt. The rest should just work (TM), but needs to be tested.
> > > You can set an "experimental' flag to have it not create issues on
> > > monorail, initially.
> >
> > I assumed ossfuzz would enable all sanitizers by default
>
> They do not do that by default, because MSAN requires all dependencies
> to be instrumented too. See
> https://google.github.io/oss-fuzz/getting-started/new-project-guide/#sanitizers
>
> Looking at build.sh for ffmpeg, it should be fine to enable it.
> Obviously I have not tested everything, but I was running some tests
> locally with MSAN and also tested it with mpv oss-fuzz builds where we
> build ffmpeg too with MSAN.
>
> - Kacper

I've sent a PR to enable MSAN and a few other build improvements.
Please take a look https://github.com/google/oss-fuzz/pull/12211

Also, would it be ok to add myself to auto_ccs for ffmpeg? Mostly to
monitor what issues are reported upstream, as we get some reports in
mpv fuzzing and I never know if I should report it upstream (ffmpeg)
or it is already found by first-party fuzzing and I shouldn't make
more noise.

- Kacper
___
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] avcodec/aacenc: Correct option description for aac_coder fast

2024-07-13 Thread Marth64
The description advertises fast as "Default fast search", but
this has not been the default for a long time (current default
is twoloop).

Signed-off-by: Marth64 
---
 libavcodec/aacenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
index 163598e938..88037c7f87 100644
--- a/libavcodec/aacenc.c
+++ b/libavcodec/aacenc.c
@@ -1392,7 +1392,7 @@ static const AVOption aacenc_options[] = {
 {"aac_coder", "Coding algorithm", offsetof(AACEncContext, options.coder), 
AV_OPT_TYPE_INT, {.i64 = AAC_CODER_TWOLOOP}, 0, AAC_CODER_NB-1, AACENC_FLAGS, 
.unit = "coder"},
 {"anmr", "ANMR method",   0, AV_OPT_TYPE_CONST, {.i64 
= AAC_CODER_ANMR},INT_MIN, INT_MAX, AACENC_FLAGS, .unit = "coder"},
 {"twoloop",  "Two loop searching method", 0, AV_OPT_TYPE_CONST, {.i64 
= AAC_CODER_TWOLOOP}, INT_MIN, INT_MAX, AACENC_FLAGS, .unit = "coder"},
-{"fast", "Default fast search",   0, AV_OPT_TYPE_CONST, {.i64 
= AAC_CODER_FAST},INT_MIN, INT_MAX, AACENC_FLAGS, .unit = "coder"},
+{"fast", "Fast search",   0, AV_OPT_TYPE_CONST, {.i64 
= AAC_CODER_FAST},INT_MIN, INT_MAX, AACENC_FLAGS, .unit = "coder"},
 {"aac_ms", "Force M/S stereo coding", offsetof(AACEncContext, 
options.mid_side), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, AACENC_FLAGS},
 {"aac_is", "Intensity stereo coding", offsetof(AACEncContext, 
options.intensity_stereo), AV_OPT_TYPE_BOOL, {.i64 = 1}, -1, 1, AACENC_FLAGS},
 {"aac_pns", "Perceptual noise substitution", offsetof(AACEncContext, 
options.pns), AV_OPT_TYPE_BOOL, {.i64 = 1}, -1, 1, AACENC_FLAGS},
-- 
2.34.1

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

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