[FFmpeg-devel] [PATCH v2 2/2] avcodec/hevc_parser: fix missing zero_byte at frame beginning

2023-12-26 Thread Zhao Zhili
From: Zhao Zhili 

The start code is matched against 0x01, zero_byte was treated
as last byte of last frame rather than the beginning of next frame.
---
 libavcodec/hevc_parser.c | 4 
 tests/fate/hevc.mak  | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavcodec/hevc_parser.c b/libavcodec/hevc_parser.c
index 87270cffb4..99a4272fad 100644
--- a/libavcodec/hevc_parser.c
+++ b/libavcodec/hevc_parser.c
@@ -278,6 +278,8 @@ static int hevc_find_frame_end(AVCodecParserContext *s, 
const uint8_t *buf,
 (nut >= 41 && nut <= 44) || (nut >= 48 && nut <= 55)) {
 if (pc->frame_start_found) {
 pc->frame_start_found = 0;
+if (!((pc->state64 >> 6 * 8) & 0xFF))
+return i - 6;
 return i - 5;
 }
 } else if (nut <= HEVC_NAL_RASL_R ||
@@ -288,6 +290,8 @@ static int hevc_find_frame_end(AVCodecParserContext *s, 
const uint8_t *buf,
 pc->frame_start_found = 1;
 } else { // First slice of next frame found
 pc->frame_start_found = 0;
+if (!((pc->state64 >> 6 * 8) & 0xFF))
+return i - 6;
 return i - 5;
 }
 }
diff --git a/tests/fate/hevc.mak b/tests/fate/hevc.mak
index b3c6792140..4889ee8237 100644
--- a/tests/fate/hevc.mak
+++ b/tests/fate/hevc.mak
@@ -222,7 +222,7 @@ FATE_HEVC-$(call ALLYES, HEVC_DEMUXER MOV_DEMUXER 
HEVC_PARSER HEVC_MP4TOANNEXB_B
 fate-hevc-bsf-mp4toannexb: tests/data/hevc-mp4.mov
 fate-hevc-bsf-mp4toannexb: CMD = md5 -i $(TARGET_PATH)/tests/data/hevc-mp4.mov 
-c:v copy -fflags +bitexact -f hevc
 fate-hevc-bsf-mp4toannexb: CMP = oneline
-fate-hevc-bsf-mp4toannexb: REF = 1873662a3af1848c37e4eb25722c8df9
+fate-hevc-bsf-mp4toannexb: REF = 73019329ed7f81c24f9af67c34c640c0
 
 fate-hevc-skiploopfilter: CMD = framemd5 -skip_loop_filter nokey -i 
$(TARGET_SAMPLES)/hevc-conformance/SAO_D_Samsung_5.bit -sws_flags bitexact
 FATE_HEVC-$(call FRAMEMD5, HEVC, HEVC, HEVC_PARSER) += fate-hevc-skiploopfilter
-- 
2.25.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 5/5] avcodec/dxva2(h264|mpeg2|vc1): use av_assert0 instead of assert

2023-12-26 Thread Xiang, Haihao
On Ma, 2023-12-25 at 22:18 +0800, Tong Wu wrote:
> Signed-off-by: Tong Wu 
> ---
>  libavcodec/dxva2.c   |  6 +++---
>  libavcodec/dxva2_h264.c  | 16 
>  libavcodec/dxva2_mpeg2.c |  2 +-
>  libavcodec/dxva2_vc1.c   |  2 +-
>  4 files changed, 13 insertions(+), 13 deletions(-)
> 
> diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c
> index 7160a0008b..c60393a60b 100644
> --- a/libavcodec/dxva2.c
> +++ b/libavcodec/dxva2.c
> @@ -20,10 +20,10 @@
>   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
> USA
>   */
>  
> -#include 
>  #include 
>  #include 
>  
> +#include "libavutil/avassert.h"
>  #include "libavutil/common.h"
>  #include "libavutil/log.h"
>  #include "libavutil/time.h"
> @@ -795,7 +795,7 @@ unsigned ff_dxva2_get_surface_index(const AVCodecContext
> *avctx,
>  }
>  #endif
>  
> -    assert(0);
> +    av_assert0(0);

The assertion in ff_d3d12va_get_surface_index() was removed in patch 4/5, could
you remove this assertion too ? 

Thanks
Haihao

>  return 0;
>  }
>  
> @@ -1012,7 +1012,7 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx,
> AVFrame *frame,
>  
>  /* TODO Film Grain when possible */
>  
> -    assert(buffer_count == 1 + (qm_size > 0) + 2);
> +    av_assert0(buffer_count == 1 + (qm_size > 0) + 2);
>  
>  #if CONFIG_D3D11VA
>  if (ff_dxva2_is_d3d11(avctx))
> diff --git a/libavcodec/dxva2_h264.c b/libavcodec/dxva2_h264.c
> index e0ec4878a7..0fe4152625 100644
> --- a/libavcodec/dxva2_h264.c
> +++ b/libavcodec/dxva2_h264.c
> @@ -44,7 +44,7 @@ struct dxva2_picture_context {
>  static void fill_picture_entry(DXVA_PicEntry_H264 *pic,
>     unsigned index, unsigned flag)
>  {
> -    assert((index&0x7f) == index && (flag&0x01) == flag);
> +    av_assert0((index&0x7f) == index && (flag&0x01) == flag);
>  pic->bPicEntry = index | (flag << 7);
>  }
>  
> @@ -194,8 +194,8 @@ void ff_dxva2_h264_fill_scaling_lists(const AVCodecContext
> *avctx, AVDXVAContext
>  
>  static int is_slice_short(const AVCodecContext *avctx, AVDXVAContext *ctx)
>  {
> -    assert(DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx) == 1 ||
> -   DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx) == 2);
> +    av_assert0(DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx) == 1 ||
> +   DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx) == 2);
>  return DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx) == 2;
>  }
>  
> @@ -348,10 +348,10 @@ static int
> commit_bitstream_and_slice_buffer(AVCodecContext *avctx,
>  static const unsigned start_code_size = sizeof(start_code);
>  unsigned position, size;
>  
> -    assert(offsetof(DXVA_Slice_H264_Short, BSNALunitDataLocation) ==
> -   offsetof(DXVA_Slice_H264_Long,  BSNALunitDataLocation));
> -    assert(offsetof(DXVA_Slice_H264_Short, SliceBytesInBuffer) ==
> -   offsetof(DXVA_Slice_H264_Long,  SliceBytesInBuffer));
> +    av_assert0(offsetof(DXVA_Slice_H264_Short, BSNALunitDataLocation) ==
> +   offsetof(DXVA_Slice_H264_Long,  BSNALunitDataLocation));
> +    av_assert0(offsetof(DXVA_Slice_H264_Short, SliceBytesInBuffer) ==
> +   offsetof(DXVA_Slice_H264_Long,  SliceBytesInBuffer));
>  
>  if (is_slice_short(avctx, ctx))
>  slice = &ctx_pic->slice_short[i];
> @@ -453,7 +453,7 @@ static int dxva2_h264_start_frame(AVCodecContext *avctx,
>  
>  if (!DXVA_CONTEXT_VALID(avctx, ctx))
>  return -1;
> -    assert(ctx_pic);
> +    av_assert0(ctx_pic);
>  
>  /* Fill up DXVA_PicParams_H264 */
>  ff_dxva2_h264_fill_picture_parameters(avctx, ctx, &ctx_pic->pp);
> diff --git a/libavcodec/dxva2_mpeg2.c b/libavcodec/dxva2_mpeg2.c
> index 4c9ed1d761..d31a8bb872 100644
> --- a/libavcodec/dxva2_mpeg2.c
> +++ b/libavcodec/dxva2_mpeg2.c
> @@ -264,7 +264,7 @@ static int dxva2_mpeg2_start_frame(AVCodecContext *avctx,
>  
>  if (!DXVA_CONTEXT_VALID(avctx, ctx))
>  return -1;
> -    assert(ctx_pic);
> +    av_assert0(ctx_pic);
>  
>  ff_dxva2_mpeg2_fill_picture_parameters(avctx, ctx, &ctx_pic->pp);
>  ff_dxva2_mpeg2_fill_quantization_matrices(avctx, ctx, &ctx_pic->qm);
> diff --git a/libavcodec/dxva2_vc1.c b/libavcodec/dxva2_vc1.c
> index 2b1b3f97ea..f7513b2b15 100644
> --- a/libavcodec/dxva2_vc1.c
> +++ b/libavcodec/dxva2_vc1.c
> @@ -321,7 +321,7 @@ static int dxva2_vc1_start_frame(AVCodecContext *avctx,
>  
>  if (!DXVA_CONTEXT_VALID(avctx, ctx))
>  return -1;
> -    assert(ctx_pic);
> +    av_assert0(ctx_pic);
>  
>  ff_dxva2_vc1_fill_picture_parameters(avctx, ctx, &ctx_pic->pp);
>  

___
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/5] avcodec/d3d12va_decode: remove assertion from get_surface_index

2023-12-26 Thread Xiang, Haihao
On Ma, 2023-12-25 at 22:18 +0800, Tong Wu wrote:
> Return zero for failed case and avoid aborting the program.
> 
> Signed-off-by: Tong Wu 
> ---
>  libavcodec/d3d12va_decode.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/libavcodec/d3d12va_decode.c b/libavcodec/d3d12va_decode.c
> index 50d5b8d601..20dc485284 100644
> --- a/libavcodec/d3d12va_decode.c
> +++ b/libavcodec/d3d12va_decode.c
> @@ -20,7 +20,6 @@
>   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
> USA
>   */
>  
> -#include 
>  #include 
>  #include 
>  
> @@ -80,7 +79,6 @@ unsigned ff_d3d12va_get_surface_index(const AVCodecContext
> *avctx,
>  }
>  
>  fail:
> -    assert(0);

Something is wrong if arriving here, could you add a warning message ? 

Thanks
Haihao


>  return 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 v1 1/2] avcodec/av1dec: Move message of OBU info back to the beginning

2023-12-26 Thread Xiang, Haihao
On Di, 2023-12-26 at 11:31 +0800, fei.w.wang-at-intel@ffmpeg.org wrote:
> From: Fei Wang 
> 
> So that can show OBU info even it doesn't have decomposed content.
> 
> Signed-off-by: Fei Wang 
> ---
>  libavcodec/av1dec.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
> index da05a0f039..e8041c1f58 100644
> --- a/libavcodec/av1dec.c
> +++ b/libavcodec/av1dec.c
> @@ -1200,11 +1200,12 @@ static int av1_receive_frame_internal(AVCodecContext
> *avctx, AVFrame *frame)
>  AV1RawOBU *obu = unit->content;
>  const AV1RawOBUHeader *header;
>  
> +    av_log(avctx, AV_LOG_DEBUG, "Obu idx:%d, obu type:%d.\n", i, unit-
> >type);

Could you add message to indicate the content of this unit is available or not ?

Thanks
Haihao

> +
>  if (!obu)
>  continue;
>  
>  header = &obu->header;
> -    av_log(avctx, AV_LOG_DEBUG, "Obu idx:%d, obu type:%d.\n", i, unit-
> >type);
>  
>  switch (unit->type) {
>  case AV1_OBU_SEQUENCE_HEADER:

___
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 6/7] avcodec/hevc: Add asm opt for the following functions

2023-12-26 Thread jinbo
tests/checkasm/checkasm:   C   LSX LASX
put_hevc_qpel_uni_h4_8_c:  5.7 1.2
put_hevc_qpel_uni_h6_8_c:  12.22.7
put_hevc_qpel_uni_h8_8_c:  21.53.2
put_hevc_qpel_uni_h12_8_c: 47.29.2 7.2
put_hevc_qpel_uni_h16_8_c: 87.011.79.0
put_hevc_qpel_uni_h24_8_c: 188.2   27.521.0
put_hevc_qpel_uni_h32_8_c: 335.2   46.728.5
put_hevc_qpel_uni_h48_8_c: 772.5   104.5   65.2
put_hevc_qpel_uni_h64_8_c: 1383.2  142.2   109.0

put_hevc_epel_uni_w_v4_8_c:5.0 1.5
put_hevc_epel_uni_w_v6_8_c:10.73.5 2.5
put_hevc_epel_uni_w_v8_8_c:18.23.7 3.0
put_hevc_epel_uni_w_v12_8_c:   40.210.77.5
put_hevc_epel_uni_w_v16_8_c:   70.213.09.2
put_hevc_epel_uni_w_v24_8_c:   158.2   30.222.5
put_hevc_epel_uni_w_v32_8_c:   281.0   52.036.5
put_hevc_epel_uni_w_v48_8_c:   631.7   116.7   82.7
put_hevc_epel_uni_w_v64_8_c:   1108.2  207.5   142.2

put_hevc_epel_uni_w_h4_8_c:4.7 1.2
put_hevc_epel_uni_w_h6_8_c:9.7 3.5 2.7
put_hevc_epel_uni_w_h8_8_c:17.24.2 3.5
put_hevc_epel_uni_w_h12_8_c:   38.011.57.2
put_hevc_epel_uni_w_h16_8_c:   69.214.59.2
put_hevc_epel_uni_w_h24_8_c:   152.0   34.722.5
put_hevc_epel_uni_w_h32_8_c:   271.0   58.040.0
put_hevc_epel_uni_w_h48_8_c:   597.5   136.7   95.0
put_hevc_epel_uni_w_h64_8_c:   1074.0  252.2   168.0

put_hevc_epel_bi_h4_8_c:   4.5 0.7
put_hevc_epel_bi_h6_8_c:   9.0 1.5
put_hevc_epel_bi_h8_8_c:   15.21.7
put_hevc_epel_bi_h12_8_c:  33.54.2 3.7
put_hevc_epel_bi_h16_8_c:  59.75.2 4.7
put_hevc_epel_bi_h24_8_c:  132.2   11.0
put_hevc_epel_bi_h32_8_c:  232.7   20.213.2
put_hevc_epel_bi_h48_8_c:  521.7   45.231.2
put_hevc_epel_bi_h64_8_c:  949.0   71.551.0

After this patch, the peformance of decoding H265 4K 30FPS
30Mbps on 3A6000 with 8 threads improves 1fps(55fps-->56fsp).

Change-Id: I8cc1e41daa63ca478039bc55d1ee8934a7423f51
---
 libavcodec/loongarch/hevc_mc.S| 1991 -
 libavcodec/loongarch/hevcdsp_init_loongarch.c |   66 +
 libavcodec/loongarch/hevcdsp_lasx.h   |   54 +
 libavcodec/loongarch/hevcdsp_lsx.h|   36 +-
 4 files changed, 2144 insertions(+), 3 deletions(-)

diff --git a/libavcodec/loongarch/hevc_mc.S b/libavcodec/loongarch/hevc_mc.S
index 0b0647546b..a0e5938fbd 100644
--- a/libavcodec/loongarch/hevc_mc.S
+++ b/libavcodec/loongarch/hevc_mc.S
@@ -1784,8 +1784,12 @@ function ff_hevc_put_hevc_qpel_uni_w_h64_8_lasx
 endfunc
 
 const shufb
-.byte 0,1,2,3, 1,2,3,4 ,2,3,4,5, 3,4,5,6
-.byte 4,5,6,7, 5,6,7,8 ,6,7,8,9, 7,8,9,10
+.byte 0,1,2,3, 1,2,3,4 ,2,3,4,5, 3,4,5,6  //mask for epel_uni_w(128-bit)
+.byte 4,5,6,7, 5,6,7,8 ,6,7,8,9, 7,8,9,10 //mask for epel_uni_w(256-bit)
+.byte 0,1,2,3, 4,5,6,7 ,1,2,3,4, 5,6,7,8  //mask for qpel_uni_h4
+.byte 0,1,1,2, 2,3,3,4 ,4,5,5,6, 6,7,7,8  //mask for qpel_uni_h/v6/8...
+.byte 0,1,2,3, 1,2,3,4 ,2,3,4,5, 3,4,5,6, 4,5,6,7, 5,6,7,8, 6,7,8,9, 
7,8,9,10 //epel_uni_w_h16/24/32/48/64
+.byte 0,1,1,2, 2,3,3,4 ,4,5,5,6, 6,7,7,8, 0,1,1,2, 2,3,3,4 ,4,5,5,6, 
6,7,7,8  //mask for bi_epel_h16/24/32/48/64
 endconst
 
 .macro PUT_HEVC_EPEL_UNI_W_HV4_LSX w
@@ -2584,3 +2588,1986 @@ function ff_hevc_put_hevc_epel_uni_w_hv64_8_lasx
 addi.d t5, t5,  -1
 bnez   t5, .LOOP_HV64_LASX
 endfunc
+
+/*
+ * void FUNC(put_hevc_qpel_uni_h)(uint8_t *_dst, ptrdiff_t _dststride,
+ *const uint8_t *_src, ptrdiff_t _srcstride,
+ *int height, intptr_t mx, intptr_t my,
+ *int width)
+ */
+function ff_hevc_put_hevc_uni_qpel_h4_8_lsx
+addi.d t0, a5,  -1
+slli.w t0, t0,  4
+la.local   t1, ff_hevc_qpel_filters
+vldx   vr5,t1,  t0 //filter
+addi.d a2, a2,  -3 //src -= 3
+addi.w t1, zero,32
+vreplgr2vr.h   vr1,t1
+la.local   t1, shufb
+vldvr2,t1,  32 //mask0 0 1
+vaddi.bu   vr3,vr2, 2  //mask1 2 3
+.LOOP_UNI_H4:
+vldvr18,   a2,  0
+vldx   vr19,   a2,  a3
+alsl.d a2, a3,  a2,   1
+vshuf.bvr6,vr18,vr18,   vr2
+vshuf.bvr7,vr18,vr18,   vr3
+vshuf.bvr8,vr19,vr19,   vr2
+vshuf.bvr9,vr19,vr19,   vr3
+vdp2.h.bu.bvr10,   vr6, vr5
+vdp2.h.bu.bvr11,   vr7, vr5
+vdp2.h.bu.bvr12,   vr8, vr5
+vdp2.h.bu.bvr13,   vr9, vr5
+vhaddw.d.h vr10
+vhaddw.d.h vr11
+vhaddw.d.h vr12
+vhaddw.d.h vr13
+vpickev.w  vr10,   vr11,vr10
+vpi

[FFmpeg-devel] [PATCH v2 7/7] avcodec/hevc: Add ff_hevc_idct_32x32_lasx asm opt

2023-12-26 Thread jinbo
From: yuanhecai 

tests/checkasm/checkasm:

  C  LSX   LASX
hevc_idct_32x32_8_c:  1243.0 211.7 101.7

Speedup of decoding H265 4K 30FPS 30Mbps on
3A6000 with 8 threads is 1fps(56fps-->57fps).
---
 libavcodec/loongarch/Makefile |   3 +-
 libavcodec/loongarch/hevc_idct.S  | 863 ++
 libavcodec/loongarch/hevc_idct_lsx.c  |  10 +-
 libavcodec/loongarch/hevcdsp_init_loongarch.c |   2 +
 libavcodec/loongarch/hevcdsp_lasx.h   |   2 +
 5 files changed, 874 insertions(+), 6 deletions(-)
 create mode 100644 libavcodec/loongarch/hevc_idct.S

diff --git a/libavcodec/loongarch/Makefile b/libavcodec/loongarch/Makefile
index ad98cd4054..07da2964e4 100644
--- a/libavcodec/loongarch/Makefile
+++ b/libavcodec/loongarch/Makefile
@@ -29,7 +29,8 @@ LSX-OBJS-$(CONFIG_HEVC_DECODER)   += 
loongarch/hevcdsp_lsx.o \
  loongarch/hevc_mc_uni_lsx.o \
  loongarch/hevc_mc_uniw_lsx.o \
  loongarch/hevc_add_res.o \
- loongarch/hevc_mc.o
+ loongarch/hevc_mc.o \
+ loongarch/hevc_idct.o
 LSX-OBJS-$(CONFIG_H264DSP)+= loongarch/h264idct.o \
  loongarch/h264idct_loongarch.o \
  loongarch/h264dsp.o
diff --git a/libavcodec/loongarch/hevc_idct.S b/libavcodec/loongarch/hevc_idct.S
new file mode 100644
index 00..5593e5fd73
--- /dev/null
+++ b/libavcodec/loongarch/hevc_idct.S
@@ -0,0 +1,863 @@
+/*
+ * Copyright (c) 2023 Loongson Technology Corporation Limited
+ * Contributed by Hecai Yuan 
+ *
+ * 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 "loongson_asm.S"
+
+.macro fr_store
+addi.dsp,   sp,   -64
+fst.d f24,  sp,   0
+fst.d f25,  sp,   8
+fst.d f26,  sp,   16
+fst.d f27,  sp,   24
+fst.d f28,  sp,   32
+fst.d f29,  sp,   40
+fst.d f30,  sp,   48
+fst.d f31,  sp,   56
+.endm
+
+.macro fr_recover
+fld.d f24,  sp,   0
+fld.d f25,  sp,   8
+fld.d f26,  sp,   16
+fld.d f27,  sp,   24
+fld.d f28,  sp,   32
+fld.d f29,  sp,   40
+fld.d f30,  sp,   48
+fld.d f31,  sp,   56
+addi.dsp,   sp,   64
+.endm
+
+.macro malloc_space number
+li.w  t0,   \number
+sub.d sp,   sp,   t0
+fr_store
+.endm
+
+.macro free_space number
+fr_recover
+li.w  t0,   \number
+add.d sp,   sp,   t0
+.endm
+
+.extern gt32x32_cnst1
+
+.extern gt32x32_cnst2
+
+.extern gt8x8_cnst
+
+.extern gt32x32_cnst0
+
+.macro idct_16x32_step1_lasx
+xvldrepl.wxr20, t1,   0
+xvldrepl.wxr21, t1,   4
+xvldrepl.wxr22, t1,   8
+xvldrepl.wxr23, t1,   12
+
+xvmulwev.w.h  xr16, xr8,  xr20
+xvmaddwod.w.h xr16, xr8,  xr20
+xvmulwev.w.h  xr17, xr9,  xr20
+xvmaddwod.w.h xr17, xr9,  xr20
+
+xvmaddwev.w.h xr16, xr10, xr21
+xvmaddwod.w.h xr16, xr10, xr21
+xvmaddwev.w.h xr17, xr11, xr21
+xvmaddwod.w.h xr17, xr11, xr21
+
+xvmaddwev.w.h xr16, xr12, xr22
+xvmaddwod.w.h xr16, xr12, xr22
+xvmaddwev.w.h xr17, xr13, xr22
+xvmaddwod.w.h xr17, xr13, xr22
+
+xvmaddwev.w.h xr16, xr14, xr23
+xvmaddwod.w.h xr16, xr14, xr23
+xvmaddwev.w.h xr17, xr15, xr23
+xvmaddwod.w.h xr17, xr15, xr23
+
+xvld  xr0,  t2,   0
+xvld  xr1,  t2,   32
+
+xvadd.w   xr18, xr0,  xr16
+xvadd.w   xr19, xr1,  xr17
+xvsub.w   xr0,  xr0,  xr16
+xvsub.w   xr1,  xr1,  xr17
+
+xvst  xr18, t2, 

[FFmpeg-devel] [PATCH v2 5/7] avcodec/hevc: Add epel_uni_w_hv4/6/8/12/16/24/32/48/64 asm opt

2023-12-26 Thread jinbo
tests/checkasm/checkasm:   C   LSX LASX
put_hevc_epel_uni_w_hv4_8_c:   9.5 2.2
put_hevc_epel_uni_w_hv6_8_c:   18.55.0 3.7
put_hevc_epel_uni_w_hv8_8_c:   30.76.0 4.5
put_hevc_epel_uni_w_hv12_8_c:  63.714.010.7
put_hevc_epel_uni_w_hv16_8_c:  107.5   22.717.0
put_hevc_epel_uni_w_hv24_8_c:  236.7   50.231.7
put_hevc_epel_uni_w_hv32_8_c:  414.5   88.053.0
put_hevc_epel_uni_w_hv48_8_c:  917.5   197.7   118.5
put_hevc_epel_uni_w_hv64_8_c:  1617.0  349.5   203.0

After this patch, the peformance of decoding H265 4K 30FPS 30Mbps
on 3A6000 with 8 threads improves 3fps (52fps-->55fsp).

Change-Id: If067e394cec4685c62193e7adb829ac93ba4804d
---
 libavcodec/loongarch/hevc_mc.S| 821 ++
 libavcodec/loongarch/hevcdsp_init_loongarch.c |  19 +
 libavcodec/loongarch/hevcdsp_lasx.h   |   9 +
 libavcodec/loongarch/hevcdsp_lsx.h|  10 +
 4 files changed, 859 insertions(+)

diff --git a/libavcodec/loongarch/hevc_mc.S b/libavcodec/loongarch/hevc_mc.S
index 2ee338fb8e..0b0647546b 100644
--- a/libavcodec/loongarch/hevc_mc.S
+++ b/libavcodec/loongarch/hevc_mc.S
@@ -22,6 +22,7 @@
 #include "loongson_asm.S"
 
 .extern ff_hevc_qpel_filters
+.extern ff_hevc_epel_filters
 
 .macro LOAD_VAR bit
 addi.w t1, a5,  6  //shift
@@ -206,6 +207,12 @@
 .endif
 .endm
 
+/*
+ * void FUNC(put_hevc_pel_uni_w_pixels)(uint8_t *_dst, ptrdiff_t _dststride,
+ *  const uint8_t *_src, ptrdiff_t 
_srcstride,
+ *  int height, int denom, int wx, int ox,
+ *  intptr_t mx, intptr_t my, int width)
+ */
 function ff_hevc_put_hevc_pel_uni_w_pixels4_8_lsx
 LOAD_VAR 128
 srli.w t0, a4,  1
@@ -482,6 +489,12 @@ endfunc
 xvhaddw.d.w  \in0,  \in0,  \in0
 .endm
 
+/*
+ * void FUNC(put_hevc_qpel_uni_w_v)(uint8_t *_dst,  ptrdiff_t _dststride,
+ *  const uint8_t *_src, ptrdiff_t _srcstride,
+ *  int height, int denom, int wx, int ox,
+ *  intptr_t mx, intptr_t my, int width)
+ */
 function ff_hevc_put_hevc_qpel_uni_w_v4_8_lsx
 LOAD_VAR 128
 ld.d   t0, sp,  8  //my
@@ -1253,6 +1266,12 @@ endfunc
 xvssrani.bu.h  \out0,  xr11,0
 .endm
 
+/*
+ * void FUNC(put_hevc_qpel_uni_w_h)(uint8_t *_dst,  ptrdiff_t _dststride,
+ *  const uint8_t *_src, ptrdiff_t _srcstride,
+ *  int height, int denom, int wx, int ox,
+ *  intptr_t mx, intptr_t my, int width)
+ */
 function ff_hevc_put_hevc_qpel_uni_w_h4_8_lsx
 LOAD_VAR 128
 ld.d   t0, sp,  0  //mx
@@ -1763,3 +1782,805 @@ function ff_hevc_put_hevc_qpel_uni_w_h64_8_lasx
 addi.d a4, a4,  -1
 bnez   a4, .LOOP_H64_LASX
 endfunc
+
+const shufb
+.byte 0,1,2,3, 1,2,3,4 ,2,3,4,5, 3,4,5,6
+.byte 4,5,6,7, 5,6,7,8 ,6,7,8,9, 7,8,9,10
+endconst
+
+.macro PUT_HEVC_EPEL_UNI_W_HV4_LSX w
+fld.d  f7, a2,  0  // start to load src
+fldx.d f8, a2,  a3
+alsl.d a2, a3,  a2,1
+fld.d  f9, a2,  0
+vshuf.bvr7,vr7, vr7,   vr0 // 0123 1234 2345 3456
+vshuf.bvr8,vr8, vr8,   vr0
+vshuf.bvr9,vr9, vr9,   vr0
+vdp2.h.bu.bvr10,   vr7, vr5  // EPEL_FILTER(src, 1)
+vdp2.h.bu.bvr11,   vr8, vr5
+vdp2.h.bu.bvr12,   vr9, vr5
+vhaddw.w.h vr10,   vr10,vr10 // tmp[0/1/2/3]
+vhaddw.w.h vr11,   vr11,vr11 // vr10,vr11,vr12 corresponding to 
EPEL_EXTRA
+vhaddw.w.h vr12,   vr12,vr12
+.LOOP_HV4_\w:
+add.d  a2, a2,  a3
+fld.d  f14,a2,  0// height loop begin
+vshuf.bvr14,   vr14,vr14,  vr0
+vdp2.h.bu.bvr13,   vr14,vr5
+vhaddw.w.h vr13,   vr13,vr13
+vmul.w vr14,   vr10,vr16 // EPEL_FILTER(tmp, MAX_PB_SIZE)
+vmadd.wvr14,   vr11,vr17
+vmadd.wvr14,   vr12,vr18
+vmadd.wvr14,   vr13,vr19
+vaddi.wu   vr10,   vr11,0//back up previous value
+vaddi.wu   vr11,   vr12,0
+vaddi.wu   vr12,   vr13,0
+vsrai.wvr14,   vr14,6// >> 6
+vmul.w vr14,   vr14,vr1  // * wx
+vadd.w vr14,   vr14,vr2  // + offset
+vsra.w vr14,   vr14,vr3  // >> shift
+vadd.w vr14,   vr14,vr4  // + ox
+vssrani.h.wvr14,   vr14,0
+vssrani.bu.h   vr14,   vr14,0// clip
+fst.s  f14,a0,  0
+add.d  a0, a0,  a1
+addi.d a4, a4,  -1
+bnez   a4, .LOOP_HV4_\w
+.endm
+
+/*
+ * void FUNC(put_hevc_e

[FFmpeg-devel] [PATCH v2 4/7] avcodec/hevc: Add qpel_uni_w_v|h4/6/8/12/16/24/32/48/64 asm opt

2023-12-26 Thread jinbo
tests/checkasm/checkasm:   C   LSX LASX
put_hevc_qpel_uni_w_h4_8_c:6.5 1.7 1.2
put_hevc_qpel_uni_w_h6_8_c:14.54.5 3.7
put_hevc_qpel_uni_w_h8_8_c:24.55.7 4.5
put_hevc_qpel_uni_w_h12_8_c:   54.717.512.0
put_hevc_qpel_uni_w_h16_8_c:   96.522.713.2
put_hevc_qpel_uni_w_h24_8_c:   216.0   51.233.2
put_hevc_qpel_uni_w_h32_8_c:   385.7   87.053.2
put_hevc_qpel_uni_w_h48_8_c:   860.5   192.0   113.2
put_hevc_qpel_uni_w_h64_8_c:   1531.0  334.2   200.0

put_hevc_qpel_uni_w_v4_8_c:8.0 1.7
put_hevc_qpel_uni_w_v6_8_c:17.24.5
put_hevc_qpel_uni_w_v8_8_c:29.56.0 5.2
put_hevc_qpel_uni_w_v12_8_c:   65.216.011.7
put_hevc_qpel_uni_w_v16_8_c:   116.5   20.514.0
put_hevc_qpel_uni_w_v24_8_c:   259.2   48.537.2
put_hevc_qpel_uni_w_v32_8_c:   459.5   80.556.0
put_hevc_qpel_uni_w_v48_8_c:   1028.5  180.2   126.5
put_hevc_qpel_uni_w_v64_8_c:   1831.2  319.2   224.2

Speedup of decoding H265 4K 30FPS 30Mbps on
3A6000 with 8 threads is 4fps(48fps-->52fps).

Change-Id: I1178848541d90083869225ba98a02e6aa8bb8c5a
---
 libavcodec/loongarch/hevc_mc.S| 1294 +
 libavcodec/loongarch/hevcdsp_init_loongarch.c |   38 +
 libavcodec/loongarch/hevcdsp_lasx.h   |   18 +
 libavcodec/loongarch/hevcdsp_lsx.h|   20 +
 4 files changed, 1370 insertions(+)

diff --git a/libavcodec/loongarch/hevc_mc.S b/libavcodec/loongarch/hevc_mc.S
index c5d553effe..2ee338fb8e 100644
--- a/libavcodec/loongarch/hevc_mc.S
+++ b/libavcodec/loongarch/hevc_mc.S
@@ -21,6 +21,8 @@
 
 #include "loongson_asm.S"
 
+.extern ff_hevc_qpel_filters
+
 .macro LOAD_VAR bit
 addi.w t1, a5,  6  //shift
 addi.w t3, zero,1  //one
@@ -469,3 +471,1295 @@ function ff_hevc_put_hevc_pel_uni_w_pixels64_8_lasx
 addi.w a4, a4,  -1
 bnez   a4, .LOOP_PIXELS64_LASX
 endfunc
+
+.macro  vhaddw.d.h  in0
+vhaddw.w.h  \in0,  \in0,  \in0
+vhaddw.d.w  \in0,  \in0,  \in0
+.endm
+
+.macro  xvhaddw.d.h  in0
+xvhaddw.w.h  \in0,  \in0,  \in0
+xvhaddw.d.w  \in0,  \in0,  \in0
+.endm
+
+function ff_hevc_put_hevc_qpel_uni_w_v4_8_lsx
+LOAD_VAR 128
+ld.d   t0, sp,  8  //my
+addi.d t0, t0,  -1
+slli.w t0, t0,  4
+la.local   t1, ff_hevc_qpel_filters
+vldx   vr5,t1,  t0  //filter
+slli.d t0, a3,  1  //stride * 2
+add.d  t1, t0,  a3 //stride * 3
+add.d  t2, t1,  a3 //stride * 4
+sub.d  a2, a2,  t1 //src -= stride*3
+fld.s  f6, a2,  0  //0
+fldx.s f7, a2,  a3 //1
+fldx.s f8, a2,  t0 //2
+add.d  a2, a2,  t1
+fld.s  f9, a2,  0  //3
+fldx.s f10,a2,  a3 //4
+fldx.s f11,a2,  t0 //5
+fldx.s f12,a2,  t1 //6
+add.d  a2, a2,  t2
+vilvl.bvr6,vr7, vr6
+vilvl.bvr7,vr9, vr8
+vilvl.bvr8,vr11,vr10
+vilvl.bvr9,vr13,vr12
+vilvl.hvr6,vr7, vr6
+vilvl.hvr7,vr9, vr8
+vilvl.wvr8,vr7, vr6
+vilvh.wvr9,vr7, vr6
+.LOOP_V4:
+fld.s  f13,a2,  0  //7
+fldx.s f14,a2,  a3 //8 next loop
+add.d  a2, a2,  t0
+vextrins.b vr8,vr13,0x70
+vextrins.b vr8,vr13,0xf1
+vextrins.b vr9,vr13,0x72
+vextrins.b vr9,vr13,0xf3
+vbsrl.vvr10,   vr8, 1
+vbsrl.vvr11,   vr9, 1
+vextrins.b vr10,   vr14,0x70
+vextrins.b vr10,   vr14,0xf1
+vextrins.b vr11,   vr14,0x72
+vextrins.b vr11,   vr14,0xf3
+vdp2.h.bu.bvr6,vr8, vr5 //QPEL_FILTER(src, stride)
+vdp2.h.bu.bvr7,vr9, vr5
+vdp2.h.bu.bvr12,   vr10,vr5
+vdp2.h.bu.bvr13,   vr11,vr5
+vbsrl.vvr8,vr10,1
+vbsrl.vvr9,vr11,1
+vhaddw.d.h vr6
+vhaddw.d.h vr7
+vhaddw.d.h vr12
+vhaddw.d.h vr13
+vpickev.w  vr6,vr7, vr6
+vpickev.w  vr12,   vr13,vr12
+vmulwev.w.hvr6,vr6, vr1 //QPEL_FILTER(src, stride) * wx
+vmulwev.w.hvr12,   vr12,vr1
+vadd.w vr6,vr6, vr2
+vsra.w vr6,vr6, vr3
+vadd.w vr6,vr6, vr4
+vadd.w vr12,   vr12,vr2
+vsra.w vr12,   vr12,vr3
+vadd.w vr12,   vr12,vr4
+vssrani.h.wvr12,   vr6, 0
+vssrani.bu.h   vr12,   vr12,0
+fst.s  f12,a0,  0
+add.d  a0, a0,  a1

[FFmpeg-devel] [PATCH v2 2/7] avcodec/hevc: Add add_residual_4/8/16/32 asm opt

2023-12-26 Thread jinbo
After this patch, the peformance of decoding H265 4K 30FPS 30Mbps
on 3A6000 with 8 threads improves 2fps (45fps-->47fsp).
---
 libavcodec/loongarch/Makefile |   3 +-
 libavcodec/loongarch/hevc_add_res.S   | 162 ++
 libavcodec/loongarch/hevcdsp_init_loongarch.c |   5 +
 libavcodec/loongarch/hevcdsp_lsx.h|   5 +
 4 files changed, 174 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/loongarch/hevc_add_res.S

diff --git a/libavcodec/loongarch/Makefile b/libavcodec/loongarch/Makefile
index 06cfab5c20..07ea97f803 100644
--- a/libavcodec/loongarch/Makefile
+++ b/libavcodec/loongarch/Makefile
@@ -27,7 +27,8 @@ LSX-OBJS-$(CONFIG_HEVC_DECODER)   += 
loongarch/hevcdsp_lsx.o \
  loongarch/hevc_lpf_sao_lsx.o \
  loongarch/hevc_mc_bi_lsx.o \
  loongarch/hevc_mc_uni_lsx.o \
- loongarch/hevc_mc_uniw_lsx.o
+ loongarch/hevc_mc_uniw_lsx.o \
+ loongarch/hevc_add_res.o
 LSX-OBJS-$(CONFIG_H264DSP)+= loongarch/h264idct.o \
  loongarch/h264idct_loongarch.o \
  loongarch/h264dsp.o
diff --git a/libavcodec/loongarch/hevc_add_res.S 
b/libavcodec/loongarch/hevc_add_res.S
new file mode 100644
index 00..dd2d820af8
--- /dev/null
+++ b/libavcodec/loongarch/hevc_add_res.S
@@ -0,0 +1,162 @@
+/*
+ * Loongson LSX optimized add_residual functions for HEVC decoding
+ *
+ * Copyright (c) 2023 Loongson Technology Corporation Limited
+ * Contributed by jinbo 
+ *
+ * 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 "loongson_asm.S"
+
+/*
+ * void ff_hevc_add_residual4x4_lsx(uint8_t *dst, const int16_t *res, 
ptrdiff_t stride)
+ */
+.macro ADD_RES_LSX_4x4_8
+vldrepl.w  vr0,a0, 0
+add.d  t0, a0, a2
+vldrepl.w  vr1,t0, 0
+vldvr2,a1, 0
+
+vilvl.wvr1,vr1,vr0
+vsllwil.hu.bu  vr1,vr1,0
+vadd.h vr1,vr1,vr2
+vssrani.bu.h   vr1,vr1,0
+
+vstelm.w   vr1,a0, 0,0
+vstelm.w   vr1,t0, 0,1
+.endm
+
+function ff_hevc_add_residual4x4_8_lsx
+ADD_RES_LSX_4x4_8
+alsl.d a0, a2, a0,   1
+addi.d a1, a1, 16
+ADD_RES_LSX_4x4_8
+endfunc
+
+/*
+ * void ff_hevc_add_residual8x8_8_lsx(uint8_t *dst, const int16_t *res, 
ptrdiff_t stride)
+ */
+.macro ADD_RES_LSX_8x8_8
+vldrepl.d  vr0,a0, 0
+add.d  t0, a0, a2
+vldrepl.d  vr1,t0, 0
+add.d  t1, t0, a2
+vldrepl.d  vr2,t1, 0
+add.d  t2, t1, a2
+vldrepl.d  vr3,t2, 0
+
+vldvr4,a1, 0
+addi.d t3, zero,   16
+vldx   vr5,a1, t3
+addi.d t4, a1, 32
+vldvr6,t4, 0
+vldx   vr7,t4, t3
+
+vsllwil.hu.bu  vr0,vr0,0
+vsllwil.hu.bu  vr1,vr1,0
+vsllwil.hu.bu  vr2,vr2,0
+vsllwil.hu.bu  vr3,vr3,0
+vadd.h vr0,vr0,vr4
+vadd.h vr1,vr1,vr5
+vadd.h vr2,vr2,vr6
+vadd.h vr3,vr3,vr7
+vssrani.bu.h   vr1,vr0,0
+vssrani.bu.h   vr3,vr2,0
+
+vstelm.d   vr1,a0, 0, 0
+vstelm.d   vr1,t0, 0, 1
+vstelm.d   vr3,t1, 0, 0
+vstelm.d   vr3,t2, 0, 1
+.endm
+
+function ff_hevc_add_residual8x8_8_lsx
+ADD_RES_LSX_8x8_8
+alsl.d a0, a2, a0,2
+addi.d a1, a1, 64
+ADD_RES_LSX_8x8_8
+endfunc
+
+/*
+ * void ff_hevc_add_residual16x16_8_lsx(uint8_t *dst, const int16_t *res, 
ptrdiff_t stride)
+ */
+function ff_hevc_add_residual16x16_8_lsx
+.rept 8
+vldvr0,a0, 0
+vldx   vr2,a0, a2
+
+vldvr4,a1, 0
+addi.d t0, zero,   16
+vldx   vr5,

[FFmpeg-devel] [PATCH v2 3/7] avcodec/hevc: Add pel_uni_w_pixels4/6/8/12/16/24/32/48/64 asm opt

2023-12-26 Thread jinbo
tests/checkasm/checkasm:   C   LSX LASX
put_hevc_pel_uni_w_pixels4_8_c:2.7 1.0
put_hevc_pel_uni_w_pixels6_8_c:6.2 2.0 1.5
put_hevc_pel_uni_w_pixels8_8_c:10.72.5 1.7
put_hevc_pel_uni_w_pixels12_8_c:   23.05.5 5.0
put_hevc_pel_uni_w_pixels16_8_c:   41.08.2 5.0
put_hevc_pel_uni_w_pixels24_8_c:   91.019.713.2
put_hevc_pel_uni_w_pixels32_8_c:   161.7   32.516.2
put_hevc_pel_uni_w_pixels48_8_c:   354.5   73.743.0
put_hevc_pel_uni_w_pixels64_8_c:   641.5   130.0   64.2

Speedup of decoding H265 4K 30FPS 30Mbps on 3A6000 with
8 threads is 1fps(47fps-->48fps).
---
 libavcodec/loongarch/Makefile |   3 +-
 libavcodec/loongarch/hevc_mc.S| 471 ++
 libavcodec/loongarch/hevcdsp_init_loongarch.c |  43 ++
 libavcodec/loongarch/hevcdsp_lasx.h   |  53 ++
 libavcodec/loongarch/hevcdsp_lsx.h|  27 +
 5 files changed, 596 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/loongarch/hevc_mc.S
 create mode 100644 libavcodec/loongarch/hevcdsp_lasx.h

diff --git a/libavcodec/loongarch/Makefile b/libavcodec/loongarch/Makefile
index 07ea97f803..ad98cd4054 100644
--- a/libavcodec/loongarch/Makefile
+++ b/libavcodec/loongarch/Makefile
@@ -28,7 +28,8 @@ LSX-OBJS-$(CONFIG_HEVC_DECODER)   += 
loongarch/hevcdsp_lsx.o \
  loongarch/hevc_mc_bi_lsx.o \
  loongarch/hevc_mc_uni_lsx.o \
  loongarch/hevc_mc_uniw_lsx.o \
- loongarch/hevc_add_res.o
+ loongarch/hevc_add_res.o \
+ loongarch/hevc_mc.o
 LSX-OBJS-$(CONFIG_H264DSP)+= loongarch/h264idct.o \
  loongarch/h264idct_loongarch.o \
  loongarch/h264dsp.o
diff --git a/libavcodec/loongarch/hevc_mc.S b/libavcodec/loongarch/hevc_mc.S
new file mode 100644
index 00..c5d553effe
--- /dev/null
+++ b/libavcodec/loongarch/hevc_mc.S
@@ -0,0 +1,471 @@
+/*
+ * Copyright (c) 2023 Loongson Technology Corporation Limited
+ * Contributed by jinbo 
+ *
+ * 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 "loongson_asm.S"
+
+.macro LOAD_VAR bit
+addi.w t1, a5,  6  //shift
+addi.w t3, zero,1  //one
+sub.w  t4, t1,  t3
+sll.w  t3, t3,  t4 //offset
+.if \bit == 128
+vreplgr2vr.w   vr1,a6  //wx
+vreplgr2vr.w   vr2,t3  //offset
+vreplgr2vr.w   vr3,t1  //shift
+vreplgr2vr.w   vr4,a7  //ox
+.else
+xvreplgr2vr.w  xr1,a6
+xvreplgr2vr.w  xr2,t3
+xvreplgr2vr.w  xr3,t1
+xvreplgr2vr.w  xr4,a7
+.endif
+.endm
+
+.macro HEVC_PEL_UNI_W_PIXELS8_LSX src0, dst0, w
+vldrepl.d  vr0,\src0,   0
+vsllwil.hu.bu  vr0,vr0, 0
+vexth.wu.huvr5,vr0
+vsllwil.wu.hu  vr0,vr0, 0
+vslli.wvr0,vr0, 6
+vslli.wvr5,vr5, 6
+vmul.w vr0,vr0, vr1
+vmul.w vr5,vr5, vr1
+vadd.w vr0,vr0, vr2
+vadd.w vr5,vr5, vr2
+vsra.w vr0,vr0, vr3
+vsra.w vr5,vr5, vr3
+vadd.w vr0,vr0, vr4
+vadd.w vr5,vr5, vr4
+vssrani.h.wvr5,vr0, 0
+vssrani.bu.h   vr5,vr5, 0
+.if \w == 6
+fst.s  f5, \dst0,   0
+vstelm.h   vr5,\dst0,   4, 2
+.else
+fst.d  f5, \dst0,   0
+.endif
+.endm
+
+.macro HEVC_PEL_UNI_W_PIXELS8x2_LASX src0, dst0, w
+vldrepl.d  vr0,\src0,   0
+add.d  t2, \src0,   a3
+vldrepl.d  vr5,t2,  0
+xvpermi.q  xr0,xr5, 0x02
+xvsllwil.hu.bu xr0,xr0, 0
+xvexth.wu.hu   xr5,xr0
+xvsllwil.wu.hu xr0,xr0, 0
+xvslli.w   xr0,xr0, 6
+xvslli.w   xr5,xr5, 6
+xvmul.wxr0,xr0, xr1
+xvmul.wxr5,xr5, xr1
+xvadd.wxr0,xr0, 

[FFmpeg-devel] [PATCH v2] [loongarch] Add hevc 128-bit & 256-bit asm optimizatons

2023-12-26 Thread jinbo
v2: Add patch 7/7.

[PATCH v2 1/7] avcodec/hevc: Add init for sao_edge_filter
[PATCH v2 2/7] avcodec/hevc: Add add_residual_4/8/16/32 asm opt
[PATCH v2 3/7] avcodec/hevc: Add pel_uni_w_pixels4/6/8/12/16/24/32/48/64 asm opt
[PATCH v2 4/7] avcodec/hevc: Add qpel_uni_w_v|h4/6/8/12/16/24/32/48/64 asm opt
[PATCH v2 5/7] avcodec/hevc: Add epel_uni_w_hv4/6/8/12/16/24/32/48/64 asm opt
[PATCH v2 6/7] avcodec/hevc: Add qpel_uni_h,epel_uni_w_h|v,epel_bi_h asm opt
[PATCH v2 7/7] avcodec/hevc: Add ff_hevc_idct_32x32_lasx asm opt

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

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


[FFmpeg-devel] [PATCH v2 1/7] avcodec/hevc: Add init for sao_edge_filter

2023-12-26 Thread jinbo
Forgot to init c->sao_edge_filter[idx] when idx=0/1/2/3.
After this patch, the speedup of decoding H265 4K 30FPS
30Mbps on 3A6000 is about 7% (42fps==>45fps).

Change-Id: I521999b397fa72b931a23c165cf45f276440cdfb
---
 libavcodec/loongarch/hevcdsp_init_loongarch.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/loongarch/hevcdsp_init_loongarch.c 
b/libavcodec/loongarch/hevcdsp_init_loongarch.c
index 22739c6f5b..5a96f3a4c9 100644
--- a/libavcodec/loongarch/hevcdsp_init_loongarch.c
+++ b/libavcodec/loongarch/hevcdsp_init_loongarch.c
@@ -167,6 +167,10 @@ void ff_hevc_dsp_init_loongarch(HEVCDSPContext *c, const 
int bit_depth)
 c->put_hevc_qpel_uni_w[8][1][1] = 
ff_hevc_put_hevc_uni_w_qpel_hv48_8_lsx;
 c->put_hevc_qpel_uni_w[9][1][1] = 
ff_hevc_put_hevc_uni_w_qpel_hv64_8_lsx;
 
+c->sao_edge_filter[0] = ff_hevc_sao_edge_filter_8_lsx;
+c->sao_edge_filter[1] = ff_hevc_sao_edge_filter_8_lsx;
+c->sao_edge_filter[2] = ff_hevc_sao_edge_filter_8_lsx;
+c->sao_edge_filter[3] = ff_hevc_sao_edge_filter_8_lsx;
 c->sao_edge_filter[4] = ff_hevc_sao_edge_filter_8_lsx;
 
 c->hevc_h_loop_filter_luma = ff_hevc_loop_filter_luma_h_8_lsx;
-- 
2.20.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/2] avcodec/hevc_parser: fix missing zero_byte at frame beginning

2023-12-26 Thread Zhao Zhili
From: Zhao Zhili 

The start code is matched against 0x01, zero_byte was treated
as last byte of last frame rather than the beginning of next frame.
---
 libavcodec/hevc_parser.c | 4 
 tests/fate/hevc.mak  | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavcodec/hevc_parser.c b/libavcodec/hevc_parser.c
index 87270cffb4..32828c5014 100644
--- a/libavcodec/hevc_parser.c
+++ b/libavcodec/hevc_parser.c
@@ -278,6 +278,8 @@ static int hevc_find_frame_end(AVCodecParserContext *s, 
const uint8_t *buf,
 (nut >= 41 && nut <= 44) || (nut >= 48 && nut <= 55)) {
 if (pc->frame_start_found) {
 pc->frame_start_found = 0;
+if (!buf[i - 6])
+return i - 6;
 return i - 5;
 }
 } else if (nut <= HEVC_NAL_RASL_R ||
@@ -288,6 +290,8 @@ static int hevc_find_frame_end(AVCodecParserContext *s, 
const uint8_t *buf,
 pc->frame_start_found = 1;
 } else { // First slice of next frame found
 pc->frame_start_found = 0;
+if (!buf[i - 6])
+return i - 6;
 return i - 5;
 }
 }
diff --git a/tests/fate/hevc.mak b/tests/fate/hevc.mak
index b3c6792140..4889ee8237 100644
--- a/tests/fate/hevc.mak
+++ b/tests/fate/hevc.mak
@@ -222,7 +222,7 @@ FATE_HEVC-$(call ALLYES, HEVC_DEMUXER MOV_DEMUXER 
HEVC_PARSER HEVC_MP4TOANNEXB_B
 fate-hevc-bsf-mp4toannexb: tests/data/hevc-mp4.mov
 fate-hevc-bsf-mp4toannexb: CMD = md5 -i $(TARGET_PATH)/tests/data/hevc-mp4.mov 
-c:v copy -fflags +bitexact -f hevc
 fate-hevc-bsf-mp4toannexb: CMP = oneline
-fate-hevc-bsf-mp4toannexb: REF = 1873662a3af1848c37e4eb25722c8df9
+fate-hevc-bsf-mp4toannexb: REF = 73019329ed7f81c24f9af67c34c640c0
 
 fate-hevc-skiploopfilter: CMD = framemd5 -skip_loop_filter nokey -i 
$(TARGET_SAMPLES)/hevc-conformance/SAO_D_Samsung_5.bit -sws_flags bitexact
 FATE_HEVC-$(call FRAMEMD5, HEVC, HEVC, HEVC_PARSER) += fate-hevc-skiploopfilter
-- 
2.25.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 1/2] avcodec/hevc_mp4toannexb_bsf: use HEVCNALUnitType instead of integer literal

2023-12-26 Thread Zhao Zhili
From: Zhao Zhili 

---
 libavcodec/hevc_mp4toannexb_bsf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/hevc_mp4toannexb_bsf.c 
b/libavcodec/hevc_mp4toannexb_bsf.c
index f9a025a36b..d91229a895 100644
--- a/libavcodec/hevc_mp4toannexb_bsf.c
+++ b/libavcodec/hevc_mp4toannexb_bsf.c
@@ -157,7 +157,8 @@ static int hevc_mp4toannexb_filter(AVBSFContext *ctx, 
AVPacket *out)
 nalu_type = (bytestream2_peek_byte(&gb) >> 1) & 0x3f;
 
 /* prepend extradata to IRAP frames */
-is_irap   = nalu_type >= 16 && nalu_type <= 23;
+is_irap = nalu_type >= HEVC_NAL_BLA_W_LP &&
+  nalu_type <= HEVC_NAL_RSV_IRAP_VCL23;
 add_extradata = is_irap && !got_irap;
 extra_size= add_extradata * ctx->par_out->extradata_size;
 got_irap |= is_irap;
-- 
2.25.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/2] libavfilter/vf_dnn_detect: Add two outputs ssd support

2023-12-26 Thread wenbin . chen-at-intel . com
From: Wenbin Chen 

For this kind of model, we can directly use its output as final result
just like ssd model. The difference is that it splits output into two
tensors. [x_min, y_min, x_max, y_max, confidence] and [lable_id].

Model example refer to: 
https://github.com/openvinotoolkit/open_model_zoo/tree/master/models/intel/person-detection-0106

Signed-off-by: Wenbin Chen 
---
 libavfilter/vf_dnn_detect.c | 64 +
 1 file changed, 50 insertions(+), 14 deletions(-)

diff --git a/libavfilter/vf_dnn_detect.c b/libavfilter/vf_dnn_detect.c
index 88865c8a8e..249cbba0f7 100644
--- a/libavfilter/vf_dnn_detect.c
+++ b/libavfilter/vf_dnn_detect.c
@@ -359,24 +359,48 @@ static int dnn_detect_post_proc_yolov3(AVFrame *frame, 
DNNData *output,
 return 0;
 }
 
-static int dnn_detect_post_proc_ssd(AVFrame *frame, DNNData *output, 
AVFilterContext *filter_ctx)
+static int dnn_detect_post_proc_ssd(AVFrame *frame, DNNData *output, int 
nb_outputs,
+AVFilterContext *filter_ctx)
 {
 DnnDetectContext *ctx = filter_ctx->priv;
 float conf_threshold = ctx->confidence;
-int proposal_count = output->height;
-int detect_size = output->width;
-float *detections = output->data;
+int proposal_count = 0;
+int detect_size = 0;
+float *detections = NULL, *labels = NULL;
 int nb_bboxes = 0;
 AVDetectionBBoxHeader *header;
 AVDetectionBBox *bbox;
-
-if (output->width != 7) {
+int scale_w = ctx->scale_width;
+int scale_h = ctx->scale_height;
+
+if (nb_outputs == 1 && output->width == 7) {
+proposal_count = output->height;
+detect_size = output->width;
+detections = output->data;
+} else if (nb_outputs == 2 && output[0].width == 5) {
+proposal_count = output[0].height;
+detect_size = output[0].width;
+detections = output[0].data;
+labels = output[1].data;
+} else if (nb_outputs == 2 && output[1].width == 5) {
+proposal_count = output[1].height;
+detect_size = output[1].width;
+detections = output[1].data;
+labels = output[0].data;
+} else {
 av_log(filter_ctx, AV_LOG_ERROR, "Model output shape doesn't match ssd 
requirement.\n");
 return AVERROR(EINVAL);
 }
 
+if (proposal_count == 0)
+return 0;
+
 for (int i = 0; i < proposal_count; ++i) {
-float conf = detections[i * detect_size + 2];
+float conf;
+if (nb_outputs == 1)
+conf = detections[i * detect_size + 2];
+else
+conf = detections[i * detect_size + 4];
 if (conf < conf_threshold) {
 continue;
 }
@@ -398,12 +422,24 @@ static int dnn_detect_post_proc_ssd(AVFrame *frame, 
DNNData *output, AVFilterCon
 
 for (int i = 0; i < proposal_count; ++i) {
 int av_unused image_id = (int)detections[i * detect_size + 0];
-int label_id = (int)detections[i * detect_size + 1];
-float conf   =  detections[i * detect_size + 2];
-float x0 =  detections[i * detect_size + 3];
-float y0 =  detections[i * detect_size + 4];
-float x1 =  detections[i * detect_size + 5];
-float y1 =  detections[i * detect_size + 6];
+int label_id;
+float conf, x0, y0, x1, y1;
+
+if (nb_outputs == 1) {
+label_id = (int)detections[i * detect_size + 1];
+conf = detections[i * detect_size + 2];
+x0   = detections[i * detect_size + 3];
+y0   = detections[i * detect_size + 4];
+x1   = detections[i * detect_size + 5];
+y1   = detections[i * detect_size + 6];
+} else {
+label_id = (int)labels[i];
+x0 =  detections[i * detect_size] / scale_w;
+y0 =  detections[i * detect_size + 1] / scale_h;
+x1 =  detections[i * detect_size + 2] / scale_w;
+y1 =  detections[i * detect_size + 3] / scale_h;
+conf   =  detections[i * detect_size + 4];
+}
 
 if (conf < conf_threshold) {
 continue;
@@ -447,7 +483,7 @@ static int dnn_detect_post_proc_ov(AVFrame *frame, DNNData 
*output, int nb_outpu
 
 switch (ctx->model_type) {
 case DDMT_SSD:
-ret = dnn_detect_post_proc_ssd(frame, output, filter_ctx);
+ret = dnn_detect_post_proc_ssd(frame, output, nb_outputs, filter_ctx);
 if (ret < 0)
 return ret;
 break;
-- 
2.34.1

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

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


[FFmpeg-devel] [PATCH 1/2] libavfilter/dnn_backend_openvino: Add dynamic output support

2023-12-26 Thread wenbin . chen-at-intel . com
From: Wenbin Chen 

Add dynamic outputs support. Some models don't have fixed output size.
Its size changes according to result. Now openvino can run these kinds of
models.

Signed-off-by: Wenbin Chen 
---
 libavfilter/dnn/dnn_backend_openvino.c | 134 +++--
 1 file changed, 59 insertions(+), 75 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_openvino.c 
b/libavfilter/dnn/dnn_backend_openvino.c
index 671a995c70..e207d44584 100644
--- a/libavfilter/dnn/dnn_backend_openvino.c
+++ b/libavfilter/dnn/dnn_backend_openvino.c
@@ -219,31 +219,26 @@ static int fill_model_input_ov(OVModel *ov_model, 
OVRequestItem *request)
 task = lltask->task;
 
 #if HAVE_OPENVINO2
-if (!ov_model_is_dynamic(ov_model->ov_model)) {
-if (ov_model->input_port) {
-ov_output_const_port_free(ov_model->input_port);
-ov_model->input_port = NULL;
-}
-status = ov_model_const_input_by_name(ov_model->ov_model, 
task->input_name, &ov_model->input_port);
-if (status != OK) {
-av_log(ctx, AV_LOG_ERROR, "Failed to get input port shape.\n");
-return ov2_map_error(status, NULL);
-}
-status = ov_const_port_get_shape(ov_model->input_port, &input_shape);
-if (status != OK) {
-av_log(ctx, AV_LOG_ERROR, "Failed to get input port shape.\n");
-return ov2_map_error(status, NULL);
-}
-dims = input_shape.dims;
-status = ov_port_get_element_type(ov_model->input_port, &precision);
-if (status != OK) {
-av_log(ctx, AV_LOG_ERROR, "Failed to get input port data type.\n");
-ov_shape_free(&input_shape);
-return ov2_map_error(status, NULL);
-}
-} else {
-avpriv_report_missing_feature(ctx, "Do not support dynamic model.");
-return AVERROR(ENOSYS);
+if (ov_model->input_port) {
+ov_output_const_port_free(ov_model->input_port);
+ov_model->input_port = NULL;
+}
+status = ov_model_const_input_by_name(ov_model->ov_model, 
task->input_name, &ov_model->input_port);
+if (status != OK) {
+av_log(ctx, AV_LOG_ERROR, "Failed to get input port shape.\n");
+return ov2_map_error(status, NULL);
+}
+status = ov_const_port_get_shape(ov_model->input_port, &input_shape);
+if (status != OK) {
+av_log(ctx, AV_LOG_ERROR, "Failed to get input port shape.\n");
+return ov2_map_error(status, NULL);
+}
+dims = input_shape.dims;
+status = ov_port_get_element_type(ov_model->input_port, &precision);
+if (status != OK) {
+av_log(ctx, AV_LOG_ERROR, "Failed to get input port data type.\n");
+ov_shape_free(&input_shape);
+return ov2_map_error(status, NULL);
 }
 input.height = dims[1];
 input.width = dims[2];
@@ -1049,30 +1044,22 @@ static int get_input_ov(void *model, DNNData *input, 
const char *input_name)
 ov_element_type_e precision;
 int64_t* dims;
 ov_status_e status;
-if (!ov_model_is_dynamic(ov_model->ov_model)) {
-status = ov_model_const_input_by_name(ov_model->ov_model, input_name, 
&ov_model->input_port);
-if (status != OK) {
-av_log(ctx, AV_LOG_ERROR, "Failed to get input port shape.\n");
-return ov2_map_error(status, NULL);
-}
-
-status = ov_const_port_get_shape(ov_model->input_port, &input_shape);
-if (status != OK) {
-av_log(ctx, AV_LOG_ERROR, "Failed to get input port shape.\n");
-return ov2_map_error(status, NULL);
-}
-dims = input_shape.dims;
-
-status = ov_port_get_element_type(ov_model->input_port, &precision);
-if (status != OK) {
-av_log(ctx, AV_LOG_ERROR, "Failed to get input port data type.\n");
-return ov2_map_error(status, NULL);
-}
-} else {
-avpriv_report_missing_feature(ctx, "Do not support dynamic model 
now.");
-return AVERROR(ENOSYS);
+status = ov_model_const_input_by_name(ov_model->ov_model, input_name, 
&ov_model->input_port);
+if (status != OK) {
+av_log(ctx, AV_LOG_ERROR, "Failed to get input port shape.\n");
+return ov2_map_error(status, NULL);
 }
-
+status = ov_port_get_element_type(ov_model->input_port, &precision);
+if (status != OK) {
+av_log(ctx, AV_LOG_ERROR, "Failed to get input port data type.\n");
+return ov2_map_error(status, NULL);
+}
+status = ov_const_port_get_shape(ov_model->input_port, &input_shape);
+if (status != OK) {
+av_log(ctx, AV_LOG_ERROR, "Failed to get input port shape.\n");
+return ov2_map_error(status, NULL);
+}
+dims = input_shape.dims;
 if (dims[1] <= 3) { // NCHW
 input->channels = dims[1];
 input->height   = input_resizable ? -1 : dims[2];
@@ -1083,7 +1070,7 @@ static int get_input_ov(void *model, DNNData *input, 
const char *input_name)
 input->channels = dims

Re: [FFmpeg-devel] [PATCH v2] configure: Enable section_data_rel_ro for FreeBSD and NetBSD aarch64 / arm

2023-12-26 Thread Brad Smith
On December 26, 2023 7:35:09 a.m. Michael Niedermayer 
 wrote:



On Mon, Dec 25, 2023 at 09:04:54PM -0500, Brad Smith wrote:

On 2023-12-24 9:08 p.m., Michael Niedermayer wrote:

On Sun, Dec 24, 2023 at 02:33:31PM -0500, Brad Smith wrote:

configure: Enable section_data_rel_ro for FreeBSD and NetBSD aarch64 / arm

Fixes the build. It's a requirement when utilizing PIE.

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

will apply

thx


Thanks. Can you please back port this to 6.1, 6.0, 5.1, 5.0 and 4.4?


it will be in the next releases from these branches

thx


Thanks.


Sent with Aqua Mail for Android
___
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/d3d12va_decode: don't change the resource state if the referenced frame is the same as the current frame

2023-12-26 Thread Wu, Tong1
>From: ffmpeg-devel  On Behalf Of Wu
>Jianhua
>Sent: Tuesday, December 26, 2023 9:21 PM
>To: FFmpeg development discussions and patches de...@ffmpeg.org>
>Subject: [FFmpeg-devel] [PATCH] avcodec/d3d12va_decode: don't change the
>resource state if the referenced frame is the same as the current frame
>
>avcodec/d3d12va_decode: don't change the resource state if the referenced
>frame is the same as the current frame
>
> This commit removes the follow warning and error:
>
>D3D12 WARNING: ID3D12CommandList::ResourceBarrier: Called on the
>same subresource(s) of
>Resource(0x02236E0E00D0:'Unnamed ID3D12Resource Object') in
>separate Barrier Descs
>which is inefficient and likely unintentional. Desc[0] and Desc[1] on
>(subresource :
>4294967295). [RESOURCE_MANIPULATION WARNING #1008:
>RESOURCE_BARRIER_DUPLICATE_SUBRESOURCE_TRANSITIONS]
>
>D3D12 ERROR: ID3D12CommandList::ResourceBarrier: Before state (0x0:
>D3D12_RESOURCE_STATE_[COMMON|PRESENT])
>of resource (0x02236E0E00D0:'Unnamed ID3D12Resource Object')
>(subresource: 0) specified
>by transition barrier does not match with the state (0x2:
>D3D12_RESOURCE_STATE_VIDEO_DECODE_WRITE)
>specified in the previous call to ResourceBarrier [RESOURCE_MANIPULATION
>ERROR #527:
>RESOURCE_BARRIER_BEFORE_AFTER_MISMATCH]
>
>Patch attached

Could you please split the function declaration(header) into 2 lines since it's 
a little bit long?

Thx,
Tong

___
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] lavfi: add quirc filter

2023-12-26 Thread James Almer

On 12/26/2023 10:25 PM, Stefano Sabatini wrote:

On date Tuesday 2023-12-26 17:20:33 +0100, Stefano Sabatini wrote:

---
  Changelog|   1 +
  configure|   4 +
  doc/filters.texi |  35 
  libavfilter/Makefile |   1 +
  libavfilter/allfilters.c |   1 +
  libavfilter/vf_quirc.c   | 183 +++
  6 files changed, 225 insertions(+)
  create mode 100644 libavfilter/vf_quirc.c


V2 with a few fixes and all corners put in the metadata (e.g. in case
the QR code is rotated).


Looking at the library, the license is very permissive and the code 
hasn't been touched in many years. It is also pretty small, so why not 
just add it as a native filter instead of requiring an external 
dependency for what seems to be a relatively simple process?

___
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] lavfi: add quirc filter

2023-12-26 Thread Stefano Sabatini
On date Tuesday 2023-12-26 17:20:33 +0100, Stefano Sabatini wrote:
> ---
>  Changelog|   1 +
>  configure|   4 +
>  doc/filters.texi |  35 
>  libavfilter/Makefile |   1 +
>  libavfilter/allfilters.c |   1 +
>  libavfilter/vf_quirc.c   | 183 +++
>  6 files changed, 225 insertions(+)
>  create mode 100644 libavfilter/vf_quirc.c

V2 with a few fixes and all corners put in the metadata (e.g. in case
the QR code is rotated).
>From ef373b4adcaa7125310f5fa290f67ec3ba849fc9 Mon Sep 17 00:00:00 2001
From: Stefano Sabatini 
Date: Tue, 26 Dec 2023 16:19:10 +0100
Subject: [PATCH] lavfi: add quirc filter

---
 Changelog|   1 +
 configure|   4 +
 doc/filters.texi |  32 
 libavfilter/Makefile |   1 +
 libavfilter/allfilters.c |   1 +
 libavfilter/vf_quirc.c   | 172 +++
 6 files changed, 211 insertions(+)
 create mode 100644 libavfilter/vf_quirc.c

diff --git a/Changelog b/Changelog
index b483bb9c69..424bfc11af 100644
--- a/Changelog
+++ b/Changelog
@@ -14,6 +14,7 @@ version :
 - D3D12VA hardware accelerated H264, HEVC, VP9, AV1, MPEG-2 and VC1 decoding
 - tiltandshift filter
 - qrencode filter and qrencodesrc source
+- quirc filter
 
 version 6.1:
 - libaribcaption decoder
diff --git a/configure b/configure
index 0b2f4e9792..419ff76bc1 100755
--- a/configure
+++ b/configure
@@ -257,6 +257,7 @@ External library support:
   --enable-libplacebo  enable libplacebo library [no]
   --enable-libpulseenable Pulseaudio input via libpulse [no]
   --enable-libqrencode enable QR encode generation via libqrencode [no]
+  --enable-libquircenable QR decoding via libquirc [no]
   --enable-librabbitmq enable RabbitMQ library [no]
   --enable-librav1eenable AV1 encoding via rav1e [no]
   --enable-librist enable RIST via librist [no]
@@ -1883,6 +1884,7 @@ EXTERNAL_LIBRARY_LIST="
 libplacebo
 libpulse
 libqrencode
+libquirc
 librabbitmq
 librav1e
 librist
@@ -3793,6 +3795,7 @@ ocv_filter_deps="libopencv"
 openclsrc_filter_deps="opencl"
 qrencode_filter_deps="libqrencode"
 qrencodesrc_filter_deps="libqrencode"
+quirc_filter_deps="libquirc"
 overlay_opencl_filter_deps="opencl"
 overlay_qsv_filter_deps="libmfx"
 overlay_qsv_filter_select="qsvvpp"
@@ -6845,6 +6848,7 @@ enabled libopus   && {
 enabled libplacebo&& require_pkg_config libplacebo "libplacebo >= 4.192.0" libplacebo/vulkan.h pl_vulkan_create
 enabled libpulse  && require_pkg_config libpulse libpulse pulse/pulseaudio.h pa_context_new
 enabled libqrencode   && require_pkg_config libqrencode libqrencode qrencode.h QRcode_encodeString
+enabled libquirc  && require libquirc quirc.h quirc_decode -lquirc
 enabled librabbitmq   && require_pkg_config librabbitmq "librabbitmq >= 0.7.1" amqp.h amqp_new_connection
 enabled librav1e  && require_pkg_config librav1e "rav1e >= 0.5.0" rav1e.h rav1e_context_new
 enabled librist   && require_pkg_config librist "librist >= 0.2.7" librist/librist.h rist_receiver_create
diff --git a/doc/filters.texi b/doc/filters.texi
index 4a31ea367a..4691b78a2e 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -20384,6 +20384,38 @@ qrencode=text=%@{pts@}
 
 @end itemize
 
+@section quirc
+
+Identify and decode a QR code using the libquirc library (see
+@url{https://github.com/dlbeer/quirc/}), and print the identified QR codes
+positions and payload as metadata.
+
+To enable the compilation of this filter, you need to configure FFmpeg with with
+@code{--enable-libquirc}.
+
+For each found QR code in the input video, some metadata entries are added with
+the prefix @var{lavfi.quirc.N}, where @var{N} is the index, starting from 0,
+associated to the QR code.
+
+A description of each metadata value follows:
+
+@table @option
+@item lavfi.quirc.count
+the number of found QR codes, it is not set in case none was found
+
+@item lavfi.quirc.N.corner.M.x
+@item lavfi.quirc.N.coreer.M.y
+the x/y positions of the four corners of the square containing the QR code,
+where @var{M} is the index of the corner starting from 0
+
+@item lavfi.quirc.N.X
+@item lavfi.quirc.N.Y
+the bottom-right position of the @var{N} QR code
+
+@item lavfi.quirc.N.payload
+the payload of the QR code
+@end table
+
 @section random
 
 Flush video frames from internal cache of frames into a random order.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 31371ceb1a..f65fb9a5a7 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -437,6 +437,7 @@ OBJS-$(CONFIG_PSEUDOCOLOR_FILTER)+= vf_pseudocolor.o
 OBJS-$(CONFIG_PSNR_FILTER)   += vf_psnr.o framesync.o
 OBJS-$(CONFIG_PULLUP_FILTER) += vf_pullup.o
 OBJS-$(CONFIG_QP_FILTER) += vf_qp.o
+OBJS-$(CONFIG_QUIRC_FILTER)  += vf_quirc.o
 OBJS-$(CONFIG_RANDOM_FILTER

Re: [FFmpeg-devel] [PATCH] lavfi: add quirc filter

2023-12-26 Thread Stefano Sabatini
On date Tuesday 2023-12-26 20:08:10 +0100, Andreas Rheinhardt wrote:
> Stefano Sabatini:
[...]
> > +static int query_formats(AVFilterContext *ctx)
> > +{
> > +static const enum AVPixelFormat pix_fmts[] = {AV_PIX_FMT_GRAY8, 
> > AV_PIX_FMT_NONE};
> > +return ff_set_common_formats_from_list(ctx, pix_fmts);
> > +}
> 
> FILTER_QUERY_FUNC is inappropriate for this.

What should I use 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".


Re: [FFmpeg-devel] [PATCH] lavfi: add quirc filter

2023-12-26 Thread Stefano Sabatini
On date Tuesday 2023-12-26 16:21:55 -0300, James Almer wrote:
> On 12/26/2023 1:20 PM, Stefano Sabatini wrote:
> > +static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
> > +{
> > +AVFilterContext *ctx = inlink->dst;
> > +AVFilterLink *outlink = ctx->outputs[0];
> > +QuircContext *quirc = ctx->priv;
> > +int codes_count;
> > +int i, w, h;
> > +uint8_t *image, *imagep, *srcp;
> > +
> > +image = quirc_begin(quirc->quirc, &w, &h);
> 

> Can't this fail?

> Or does the allocation take place in the quirc_resize()
> call?

correct

> > +
> > +/* copy input image to quirc buffer */
> > +imagep = image;
> > +srcp = frame->data[0];
> > +for (i = 0; i < inlink->h; i++) {
> > +memcpy(imagep, srcp, w);
> 

> Can w differ from inlink->w?

No, given that the resize is done in config_inputs.


> > +imagep += w;
> > +srcp += frame->linesize[0];
> > +}
> 
> Maybe instead do
> 

> av_image_copy_plane(image, w, frame->data[0], frame->linesize[0],
> w, inlink->h);

good catch, thanks for the feedback
___
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] Mailinglist conduct [was: Re: [PATCH] lavc: remove the QOA decoder]

2023-12-26 Thread James Almer


On 12/26/2023 7:40 PM, Paul B Mahol wrote:

On Tue, Dec 26, 2023 at 11:20 PM Ronald S. Bultje 
wrote:


Paul,

On Thu, Dec 21, 2023 at 3:05 PM Paul B Mahol  wrote:


Say what serious feature you contributed ? - Nothing.



the CC requests that you please refrain from attacking fellow FFmpeg
contributors ("what serious feature [have] you contributed? - Nothing") on
the mailinglist.



I object here to your dictatorship trolling.

Your are selectively picking what to comment and censor.


What did the phrase Ronald quoted add to the conversation? Do you 
consider that being civil? Because pretty much no one does.
Why can't people discuss and exchange opinions without talking shit to 
each other?


This ML has a very bad reputation because things like that are rampant, 
so it has to stop. How will anyone want to contribute if the threat of 
being shit talked for no reason is always looming?

___
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] Mailinglist conduct [was: Re: [PATCH] lavc: remove the QOA decoder]

2023-12-26 Thread Paul B Mahol
On Tue, Dec 26, 2023 at 11:20 PM Ronald S. Bultje 
wrote:

> Paul,
>
> On Thu, Dec 21, 2023 at 3:05 PM Paul B Mahol  wrote:
>
> > Say what serious feature you contributed ? - Nothing.
> >
>
> the CC requests that you please refrain from attacking fellow FFmpeg
> contributors ("what serious feature [have] you contributed? - Nothing") on
> the mailinglist.
>

I object here to your dictatorship trolling.

Your are selectively picking what to comment and censor.

Your cowboy show is over!


>
> Signed unanimously,
> the CC illuminati (Anton, James, Jean-Baptiste, Michael, 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 mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 3/6] Add CRYO APC muxer

2023-12-26 Thread Michael Niedermayer
Hi

On Tue, Dec 26, 2023 at 04:52:47PM +0100, Tomas Härdin wrote:
> 

[...]
> +
> +static int apc_write_header(AVFormatContext *s)
> +{
> +AVIOContext *pb = s->pb;
> +AVCodecParameters *par;
> +AVStream *st;
> +
> +if (s->nb_streams != 1) {
> +av_log(s, AV_LOG_ERROR, "Must have exactly one stream\n");
> +return AVERROR(EINVAL);
> +}
> +
> +st = s->streams[0];
> +par = st->codecpar;
> +
> +if (par->ch_layout.nb_channels <= 0 || par->ch_layout.nb_channels > 2) {
> +av_log(s, AV_LOG_ERROR, "Must be mono or stereo\n");
> +return AVERROR(EINVAL);
> +}
> +
> +if (par->extradata_size != 0 && par->extradata_size != 8) {
> +av_log(s, AV_LOG_ERROR,
> +"Must have exactly 0 or 8 bytes of extradata, got %i\n",
> +par->extradata_size);
> +return AVERROR(EINVAL);
> +}
> +
> +ffio_wfourcc(pb, "CRYO");
> +ffio_wfourcc(pb, "_APC");
> +ffio_wfourcc(pb, "1.20");

> +avio_wl32(pb, 0); // number or samples

please add to the comment "updated in apc_write_trailer()"


> +avio_wl32(pb, par->sample_rate);
> +
> +// write extradata if we have it (remuxing)
> +// else write dummy values and wait for AV_PKT_DATA_NEW_EXTRADATA 
> (encoding)
> +if (par->extradata_size) {
> +avio_write(pb, par->extradata, par->extradata_size);
> +} else {
> +avio_wl64(pb, 0);
> +}
> +
> +avio_wl32(pb, par->ch_layout.nb_channels - 1);
> +avpriv_set_pts_info(st, 64, 1, par->sample_rate);
> +return 0;
> +}
> +

> +static int apc_write_packet(AVFormatContext *s, AVPacket *pkt)
> +{
> +size_t extradata_size = 0;

> +const uint8_t *extradata = av_packet_get_side_data(
> +pkt, AV_PKT_DATA_NEW_EXTRADATA, &extradata_size);
> +
> +if (extradata_size == 8) {
> +// we got predictors from encoder
> +// try to seek back end write them
> +int64_t pos = avio_tell(s->pb), err;
> +if ((err = avio_seek(s->pb, 20, SEEK_SET)) >= 0) {
> +avio_write(s->pb, extradata, extradata_size);
> +avio_seek(s->pb, pos, SEEK_SET);
> +} else {
> +av_log(s, AV_LOG_ERROR, "Got predictors from encoder but 
> couldn't seek back to write them\n");
> +// fail since we should always be able to do this within the 
> avio cache
> +// unless the encoder gave us predictors way too late for some 
> reason
> +return err;
> +}
> +}

I think the encoder should buffer data or use 2 passes
if it needs future data. seeking back in the muxer is a bit odd.

if it becomes available always in teh first packet then maybe the
whole header could be written in the first packet

I would suggest, you add APC support to nut.
Thats a good test to ensure the packet and extradata is set at the right time
for a generic muxer



> +
> +avio_write(s->pb, pkt->data, pkt->size);
> +return 0;
> +}
> +
> +static int apc_write_trailer(AVFormatContext *s)
> +{
> +int64_t file_size = avio_tell(s->pb);
> +
> +// write length, if we're able to seek back
> +if (avio_seek(s->pb, 12, SEEK_SET) >= 0) {

> +if (file_size - APC_HEADER_SIZE >
> +UINT32_MAX * s->streams[0]->codecpar->ch_layout.nb_channels 
> / 2) {
> +av_log(s, AV_LOG_ERROR, "File too large\n");
> +return AVERROR(EINVAL);
> +}
> +
> +avio_wl32(s->pb, (file_size - APC_HEADER_SIZE) *
> +2 / 
> s->streams[0]->codecpar->ch_layout.nb_channels);

I think something like this is slightly cleaner:


int64_t number_of_samples = (file_size - APC_HEADER_SIZE) *
2 / s->streams[0]->codecpar->ch_layout.nb_channels;

if (number_of_samples > UINT32_MAX)
...
[...]

thx

--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Avoid a single point of failure, be that a person or equipment.


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 2/2] avcodec/proresenc: fix alpha plane encoding bitstream

2023-12-26 Thread Clément Bœsch
These functions encode a slice of alpha (1 to 8 macroblocks) which are
expected to be encoded as a repeated sequence of "[diff][run-1]", where
diff is the running difference of the alpha value and run is how many
times that value is expected to be duplicated (within the limit of a
grand total of 2048 unpacked samples, corresponding to a slice of 8 MB).

Even when run==0 (the run variable semantic is actually "run minus 1"),
there is always a diff previously encoded that needs a counter of at
least 1. This means we need to call put_alpha_run() unconditionally at
the end of the bitstream to account for the last running diff.

This commit fixes glitchy playbacks on QuickTime with M2 and M3 hardware
(but not M1 for some mysterious reason) with files generated with
commands such as:

  ffmpeg -f lavfi -i testsrc2=d=5:s=912x320,chromakey -c:v prores_aw -profile:v 
4-y aw.mov
  ffmpeg -f lavfi -i testsrc2=d=5:s=912x320,chromakey -c:v prores_ks -profile:v 
 -y ks.mov

The glitch expresses itself deterministically as blinking black
rectangles on random frames (for example on frame 21, 54, 71, 79, ...).

Even with the proresdec from FFmpeg, overreads actually happens while
reading the run-minus-1 value (around val = get_bits(gb, 4) in
unpack_alpha()). This doesn't seem to cause any particular issue because
it simply overreads into the next slice, and because the decoder is
resilient, but it's still a problem.

Fixes ticket #10255.
---
 libavcodec/proresenc_anatoliy.c | 3 +--
 libavcodec/proresenc_kostya.c   | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index 16741afd68..9b9ffa03be 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -486,8 +486,7 @@ static av_always_inline int 
encode_alpha_slice_data(AVCodecContext *avctx, int8_
 run++;
 }
 } while (idx < num_coeffs);
-if (run)
-put_alpha_run(&pb, run);
+put_alpha_run(&pb, run);
 flush_put_bits(&pb);
 *a_data_size = put_bytes_output(&pb);
 
diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
index e904632f8e..8d45e42d1a 100644
--- a/libavcodec/proresenc_kostya.c
+++ b/libavcodec/proresenc_kostya.c
@@ -562,8 +562,7 @@ static void encode_alpha_plane(ProresContext *ctx, 
PutBitContext *pb,
 run++;
 }
 } while (idx < num_coeffs);
-if (run)
-put_alpha_run(pb, run);
+put_alpha_run(pb, run);
 }
 
 static int encode_slice(AVCodecContext *avctx, const AVFrame *pic,
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH 1/2] avcodec/proresenc: make transparency honored in mov/QT

2023-12-26 Thread Clément Bœsch
In the mov muxer (in mov_write_video_tag()), bits_per_coded_sample will
be written under certain conditions and is required to be 32 for the
transparency to be honored in QuickTime.

prores_kostya already has this setting but prores_anatoliy and
prores_videotoolbox didn't.
---
 libavcodec/proresenc_anatoliy.c | 3 +++
 libavcodec/videotoolboxenc.c| 2 ++
 2 files changed, 5 insertions(+)

diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index a1cb46aa59..16741afd68 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -930,6 +930,9 @@ static av_cold int prores_encode_init(AVCodecContext *avctx)
 }
 }
 
+if (ctx->need_alpha)
+avctx->bits_per_coded_sample = 32;
+
 ff_fdctdsp_init(&ctx->fdsp, avctx);
 
 avctx->codec_tag = AV_RL32((const uint8_t*)profiles[avctx->profile].name);
diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index 15e0e1fe29..644fd60b00 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -521,6 +521,8 @@ static CMVideoCodecType get_cm_codec_type(AVCodecContext 
*avctx,
 }
 return kCMVideoCodecType_HEVC;
 case AV_CODEC_ID_PRORES:
+if (desc && (desc->flags & AV_PIX_FMT_FLAG_ALPHA))
+avctx->bits_per_coded_sample = 32;
 switch (profile) {
 case AV_PROFILE_PRORES_PROXY:
 return MKBETAG('a','p','c','o'); // 
kCMVideoCodecType_AppleProRes422Proxy
-- 
2.43.0

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

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


[FFmpeg-devel] Mailinglist conduct [was: Re: [PATCH] lavc: remove the QOA decoder]

2023-12-26 Thread Ronald S. Bultje
Paul,

On Thu, Dec 21, 2023 at 3:05 PM Paul B Mahol  wrote:

> Say what serious feature you contributed ? - Nothing.
>

the CC requests that you please refrain from attacking fellow FFmpeg
contributors ("what serious feature [have] you contributed? - Nothing") on
the mailinglist.

Signed unanimously,
the CC illuminati (Anton, James, Jean-Baptiste, Michael, 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] lavfi: add quirc filter

2023-12-26 Thread James Almer

On 12/26/2023 1:20 PM, Stefano Sabatini wrote:

+static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
+{
+AVFilterContext *ctx = inlink->dst;
+AVFilterLink *outlink = ctx->outputs[0];
+QuircContext *quirc = ctx->priv;
+int codes_count;
+int i, w, h;
+uint8_t *image, *imagep, *srcp;
+
+image = quirc_begin(quirc->quirc, &w, &h);


Can't this fail? Or does the allocation take place in the quirc_resize() 
call?



+
+/* copy input image to quirc buffer */
+imagep = image;
+srcp = frame->data[0];
+for (i = 0; i < inlink->h; i++) {
+memcpy(imagep, srcp, w);


Can w differ from inlink->w?


+imagep += w;
+srcp += frame->linesize[0];
+}


Maybe instead do

av_image_copy_plane(image, w, frame->data[0], frame->linesize[0],
w, inlink->h);
___
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] avcodec/osq: Implement flush()

2023-12-26 Thread Andreas Rheinhardt
Michael Niedermayer:
> Fixes: out of array access
> Fixes: 
> 62164/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_OSQ_fuzzer-6227491892887552
> Fixes: 
> 62164/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_OSQ_fuzzer-6268561729126400
> Fixes: 
> 62164/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_OSQ_fuzzer-6414805046788096
> Fixes: 
> 62164/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_OSQ_fuzzer-6538151088488448
> Fixes: 
> 62164/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_OSQ_fuzzer-6608131540779008
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/osq.c | 10 ++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/libavcodec/osq.c b/libavcodec/osq.c
> index 435f3ea7f69..abe15c97f18 100644
> --- a/libavcodec/osq.c
> +++ b/libavcodec/osq.c
> @@ -61,6 +61,15 @@ typedef struct OSQContext {
>  int pkt_offset;
>  } OSQContext;
>  
> +static void osq_flush(AVCodecContext *avctx)
> +{
> +OSQContext *s = avctx->priv_data;
> +
> +s->bitstream_size = 0;
> +s->pkt_offset = 0;
> +av_packet_unref(s->pkt);

s->pkt is the same as avctx->internal->in_pkt which is unreferenced
generically upon flush. So this is unnecessary.

> +}
> +
>  static av_cold int osq_close(AVCodecContext *avctx)
>  {
>  OSQContext *s = avctx->priv_data;
> @@ -478,4 +487,5 @@ const FFCodec ff_osq_decoder = {
>  AV_SAMPLE_FMT_S16P,
>  AV_SAMPLE_FMT_S32P,
>  AV_SAMPLE_FMT_NONE },
> +.flush= osq_flush,
>  };

___
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] lavfi: add quirc filter

2023-12-26 Thread Andreas Rheinhardt
Stefano Sabatini:
> ---
>  Changelog|   1 +
>  configure|   4 +
>  doc/filters.texi |  35 
>  libavfilter/Makefile |   1 +
>  libavfilter/allfilters.c |   1 +
>  libavfilter/vf_quirc.c   | 183 +++
>  6 files changed, 225 insertions(+)
>  create mode 100644 libavfilter/vf_quirc.c
> 
> diff --git a/Changelog b/Changelog
> index b483bb9c69..424bfc11af 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -14,6 +14,7 @@ version :
>  - D3D12VA hardware accelerated H264, HEVC, VP9, AV1, MPEG-2 and VC1 decoding
>  - tiltandshift filter
>  - qrencode filter and qrencodesrc source
> +- quirc filter
>  
>  version 6.1:
>  - libaribcaption decoder
> diff --git a/configure b/configure
> index 0b2f4e9792..419ff76bc1 100755
> --- a/configure
> +++ b/configure
> @@ -257,6 +257,7 @@ External library support:
>--enable-libplacebo  enable libplacebo library [no]
>--enable-libpulseenable Pulseaudio input via libpulse [no]
>--enable-libqrencode enable QR encode generation via libqrencode [no]
> +  --enable-libquircenable QR decoding via libquirc [no]
>--enable-librabbitmq enable RabbitMQ library [no]
>--enable-librav1eenable AV1 encoding via rav1e [no]
>--enable-librist enable RIST via librist [no]
> @@ -1883,6 +1884,7 @@ EXTERNAL_LIBRARY_LIST="
>  libplacebo
>  libpulse
>  libqrencode
> +libquirc
>  librabbitmq
>  librav1e
>  librist
> @@ -3793,6 +3795,7 @@ ocv_filter_deps="libopencv"
>  openclsrc_filter_deps="opencl"
>  qrencode_filter_deps="libqrencode"
>  qrencodesrc_filter_deps="libqrencode"
> +quirc_filter_deps="libquirc"
>  overlay_opencl_filter_deps="opencl"
>  overlay_qsv_filter_deps="libmfx"
>  overlay_qsv_filter_select="qsvvpp"
> @@ -6845,6 +6848,7 @@ enabled libopus   && {
>  enabled libplacebo&& require_pkg_config libplacebo "libplacebo >= 
> 4.192.0" libplacebo/vulkan.h pl_vulkan_create
>  enabled libpulse  && require_pkg_config libpulse libpulse 
> pulse/pulseaudio.h pa_context_new
>  enabled libqrencode   && require_pkg_config libqrencode libqrencode 
> qrencode.h QRcode_encodeString
> +enabled libquirc  && require libquirc quirc.h quirc_decode -lquirc
>  enabled librabbitmq   && require_pkg_config librabbitmq "librabbitmq >= 
> 0.7.1" amqp.h amqp_new_connection
>  enabled librav1e  && require_pkg_config librav1e "rav1e >= 0.5.0" 
> rav1e.h rav1e_context_new
>  enabled librist   && require_pkg_config librist "librist >= 0.2.7" 
> librist/librist.h rist_receiver_create
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 04898ede31..5fbe381d74 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -20368,6 +20368,41 @@ qrencode=text=%@{pts@}
>  
>  @end itemize
>  
> +@section quirc
> +
> +Identify and decode a QR code using the libquirc library (see
> +@url{https://github.com/dlbeer/quirc/}), and print the identified QR codes
> +positions and payload as metadata.
> +
> +To enable the compilation of this filter, you need to configure FFmpeg with 
> with
> +@code{--enable-libquirc}.
> +
> +For each found QR code in the input video, some metadata entries are added 
> with
> +the prefix @var{lavfi.quirc.N}, where @var{N} is the index, starting from 0,
> +associated to the QR code.
> +
> +A description of each metadata value follows:
> +
> +@table @option
> +@item lavfi.quirc.count
> +the number of found QR codes, it is not set in case none was found
> +
> +@item lavfi.quirc.N.x
> +@item lavfi.quirc.N.y
> +the top-left position of the @var{N} QR code
> +
> +@item lavfi.quirc.N.X
> +@item lavfi.quirc.N.Y
> +the bottom-right position of the @var{N} QR code
> +
> +@item lavfi.quirc.N.w
> +@item lavfi.quirc.N.h
> +the size of the @var{N} QR code
> +
> +@item lavfi.quirc.N.payload
> +the payload of the QR code
> +@end table
> +
>  @section random
>  
>  Flush video frames from internal cache of frames into a random order.
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index 31371ceb1a..f65fb9a5a7 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -437,6 +437,7 @@ OBJS-$(CONFIG_PSEUDOCOLOR_FILTER)+= 
> vf_pseudocolor.o
>  OBJS-$(CONFIG_PSNR_FILTER)   += vf_psnr.o framesync.o
>  OBJS-$(CONFIG_PULLUP_FILTER) += vf_pullup.o
>  OBJS-$(CONFIG_QP_FILTER) += vf_qp.o
> +OBJS-$(CONFIG_QUIRC_FILTER)  += vf_quirc.o
>  OBJS-$(CONFIG_RANDOM_FILTER) += vf_random.o
>  OBJS-$(CONFIG_READEIA608_FILTER) += vf_readeia608.o
>  OBJS-$(CONFIG_READVITC_FILTER)   += vf_readvitc.o
> diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
> index 20feb37967..b8570dbab2 100644
> --- a/libavfilter/allfilters.c
> +++ b/libavfilter/allfilters.c
> @@ -412,6 +412,7 @@ extern const AVFilter ff_vf_psnr;
>  extern const AVFilter ff_vf_pullup;
>  extern c

Re: [FFmpeg-devel] [PATCH v2] avcodec/jpegxl_parser: check ANS cluster alphabet size vs bundle size

2023-12-26 Thread Michael Niedermayer
On Tue, Dec 26, 2023 at 08:23:35AM -0600, Leo Izen wrote:
> On 12/25/23 15:09, Michael Niedermayer wrote:
> > On Mon, Dec 25, 2023 at 12:04:17PM -0500, Leo Izen wrote:
> > > The specification doesn't mention that clusters cannot have alphabet
> > > sizes greater than 1 << bundle->log_alphabet_size, but the reference
> > > implementation rejects these entropy streams as invalid, so we should
> > > too. Refusing to do so can overflow a stack variable on line 556 that
> > > should be large enough otherwise.
> > > 
> > > Fixes #10738.
> > > 
> > > Found-by: Zeng Yunxiang and Li Zeyuan
> > > Signed-off-by: Leo Izen 
> > > ---
> > >   libavcodec/jpegxl_parser.c | 28 +++-
> > >   1 file changed, 19 insertions(+), 9 deletions(-)
> > > 
> > > diff --git a/libavcodec/jpegxl_parser.c b/libavcodec/jpegxl_parser.c
> > > index 006eb6b295..f026fda9ac 100644
> > > --- a/libavcodec/jpegxl_parser.c
> > > +++ b/libavcodec/jpegxl_parser.c
> > > @@ -64,26 +64,26 @@ typedef struct JXLSymbolDistribution {
> > >   int log_bucket_size;
> > >   /* this is the actual size of the alphabet */
> > >   int alphabet_size;
> > > -/* ceil(log(alphabet_size)) */
> > > -int log_alphabet_size;
> > >   /* for prefix code distributions */
> > >   VLC vlc;
> > >   /* in case bits == 0 */
> > >   uint32_t default_symbol;
> > > +/* ceil(log(alphabet_size)) */
> > > +int log_alphabet_size;
> > 
> > that seems unneeded
> > 
> 
> dist->log_alphaebet_size is only used for prefix code distributions so I
> moved it for clarity. I can also remove this change from this commit if you
> think it's off-topic.

it belongs in a seperate patch

also the 258 -> 256 should be a seperate patch IMHO
Its not part of fixing the ticket


> 
> In either case, is the commit okay, apart from this one change? If so I'm
> going to merge it (after I remove this one change from the diff).

yes

thx

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

Old school: Use the lowest level language in which you can solve the problem
conveniently.
New school: Use the highest level language in which the latest supercomputer
can solve the problem without the user falling asleep waiting.


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/3] avcodec/osq: avoid several signed integer overflows

2023-12-26 Thread James Almer

On 12/26/2023 1:37 PM, Michael Niedermayer wrote:

Fixes: signed integer overflow: 178459578 + 2009763270 cannot be represented in 
type 'int'
Fixes: 
62285/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_OSQ_fuzzer-5013423686287360

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
  libavcodec/osq.c | 24 
  1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/libavcodec/osq.c b/libavcodec/osq.c
index abe15c97f18..f2771c46eb5 100644
--- a/libavcodec/osq.c
+++ b/libavcodec/osq.c
@@ -222,8 +222,8 @@ static int osq_channel_parameters(AVCodecContext *avctx, 
int ch)
  #define C (-3)
  #define D (-4)
  #define E (-5)
-#define P2 ((dst[A] + dst[A]) - dst[B])
-#define P3 ((dst[A] - dst[B]) * 3 + dst[C])
+#define P2 (((unsigned)dst[A] + dst[A]) - dst[B])
+#define P3 (((unsigned)dst[A] - dst[B]) * 3 + dst[C])
  
  static int do_decode(AVCodecContext *avctx, AVFrame *frame, int decorrelate, int downsample)

  {
@@ -273,10 +273,10 @@ static int do_decode(AVCodecContext *avctx, AVFrame 
*frame, int decorrelate, int
  case 0:
  break;
  case 1:
-dst[n] += dst[A];
+dst[n] += (unsigned)dst[A];
  break;
  case 2:
-dst[n] += dst[A] + p;
+dst[n] += (unsigned)dst[A] + p;
  break;
  case 3:
  dst[n] += P2;
@@ -291,28 +291,28 @@ static int do_decode(AVCodecContext *avctx, AVFrame 
*frame, int decorrelate, int
  dst[n] += P3 + p;
  break;
  case 7:
-dst[n] += (P2 + P3) / 2 + p;
+dst[n] += (int)(P2 + P3) / 2 + (unsigned)p;


Would 2U work for this? It's shorted and more readable that casts 
everywhere. Same for most cases below.



  break;
  case 8:
-dst[n] += (P2 + P3) / 2;
+dst[n] += (int)(P2 + P3) / 2;
  break;
  case 9:
-dst[n] += (P2 * 2 + P3) / 3 + p;
+dst[n] += (int)(P2 * 2 + P3) / 3 + (unsigned)p;
  break;
  case 10:
-dst[n] += (P2 + P3 * 2) / 3 + p;
+dst[n] += (int)(P2 + P3 * 2) / 3 + (unsigned)p;
  break;
  case 11:
-dst[n] += (dst[A] + dst[B]) / 2;
+dst[n] += (int)((unsigned)dst[A] + dst[B]) / 2;
  break;
  case 12:
-dst[n] += dst[B];
+dst[n] += (unsigned)dst[B];
  break;
  case 13:
-dst[n] += (dst[D] + dst[B]) / 2;
+dst[n] += (int)(unsigned)(dst[D] + dst[B]) / 2;
  break;
  case 14:
-dst[n] += (P2 + dst[A]) / 2 + p;
+dst[n] += (int)((unsigned)P2 + dst[A]) / 2 + (unsigned)p;
  break;
  default:
  return AVERROR_INVALIDDATA;

___
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] avformat/concatdec: clip outpoint - inpoint overflow in get_best_effort_duration()

2023-12-26 Thread Michael Niedermayer
An alternative would be to limit all time/duration fields to below 64bit

Fixes: signed integer overflow: -9300 - 922337203683900 cannot be 
represented in type 'long long'
Fixes: 
64546/clusterfuzz-testcase-minimized-ffmpeg_dem_CONCAT_fuzzer-5110813828186112

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavformat/concatdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
index 5a7a063ef7d..3da2ac9e705 100644
--- a/libavformat/concatdec.c
+++ b/libavformat/concatdec.c
@@ -323,7 +323,7 @@ static int64_t get_best_effort_duration(ConcatFile *file, 
AVFormatContext *avf)
 if (file->user_duration != AV_NOPTS_VALUE)
 return file->user_duration;
 if (file->outpoint != AV_NOPTS_VALUE)
-return file->outpoint - file->file_inpoint;
+return av_sat_sub64(file->outpoint, file->file_inpoint);
 if (avf->duration > 0)
 return avf->duration - (file->file_inpoint - file->file_start_time);
 if (file->next_dts != AV_NOPTS_VALUE)
-- 
2.17.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/3] avcodec/osq: avoid several signed integer overflows

2023-12-26 Thread Michael Niedermayer
Fixes: signed integer overflow: 178459578 + 2009763270 cannot be represented in 
type 'int'
Fixes: 
62285/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_OSQ_fuzzer-5013423686287360

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/osq.c | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/libavcodec/osq.c b/libavcodec/osq.c
index abe15c97f18..f2771c46eb5 100644
--- a/libavcodec/osq.c
+++ b/libavcodec/osq.c
@@ -222,8 +222,8 @@ static int osq_channel_parameters(AVCodecContext *avctx, 
int ch)
 #define C (-3)
 #define D (-4)
 #define E (-5)
-#define P2 ((dst[A] + dst[A]) - dst[B])
-#define P3 ((dst[A] - dst[B]) * 3 + dst[C])
+#define P2 (((unsigned)dst[A] + dst[A]) - dst[B])
+#define P3 (((unsigned)dst[A] - dst[B]) * 3 + dst[C])
 
 static int do_decode(AVCodecContext *avctx, AVFrame *frame, int decorrelate, 
int downsample)
 {
@@ -273,10 +273,10 @@ static int do_decode(AVCodecContext *avctx, AVFrame 
*frame, int decorrelate, int
 case 0:
 break;
 case 1:
-dst[n] += dst[A];
+dst[n] += (unsigned)dst[A];
 break;
 case 2:
-dst[n] += dst[A] + p;
+dst[n] += (unsigned)dst[A] + p;
 break;
 case 3:
 dst[n] += P2;
@@ -291,28 +291,28 @@ static int do_decode(AVCodecContext *avctx, AVFrame 
*frame, int decorrelate, int
 dst[n] += P3 + p;
 break;
 case 7:
-dst[n] += (P2 + P3) / 2 + p;
+dst[n] += (int)(P2 + P3) / 2 + (unsigned)p;
 break;
 case 8:
-dst[n] += (P2 + P3) / 2;
+dst[n] += (int)(P2 + P3) / 2;
 break;
 case 9:
-dst[n] += (P2 * 2 + P3) / 3 + p;
+dst[n] += (int)(P2 * 2 + P3) / 3 + (unsigned)p;
 break;
 case 10:
-dst[n] += (P2 + P3 * 2) / 3 + p;
+dst[n] += (int)(P2 + P3 * 2) / 3 + (unsigned)p;
 break;
 case 11:
-dst[n] += (dst[A] + dst[B]) / 2;
+dst[n] += (int)((unsigned)dst[A] + dst[B]) / 2;
 break;
 case 12:
-dst[n] += dst[B];
+dst[n] += (unsigned)dst[B];
 break;
 case 13:
-dst[n] += (dst[D] + dst[B]) / 2;
+dst[n] += (int)(unsigned)(dst[D] + dst[B]) / 2;
 break;
 case 14:
-dst[n] += (P2 + dst[A]) / 2 + p;
+dst[n] += (int)((unsigned)P2 + dst[A]) / 2 + (unsigned)p;
 break;
 default:
 return AVERROR_INVALIDDATA;
-- 
2.17.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 1/3] avcodec/osq: Implement flush()

2023-12-26 Thread Michael Niedermayer
Fixes: out of array access
Fixes: 
62164/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_OSQ_fuzzer-6227491892887552
Fixes: 
62164/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_OSQ_fuzzer-6268561729126400
Fixes: 
62164/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_OSQ_fuzzer-6414805046788096
Fixes: 
62164/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_OSQ_fuzzer-6538151088488448
Fixes: 
62164/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_OSQ_fuzzer-6608131540779008

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/osq.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/libavcodec/osq.c b/libavcodec/osq.c
index 435f3ea7f69..abe15c97f18 100644
--- a/libavcodec/osq.c
+++ b/libavcodec/osq.c
@@ -61,6 +61,15 @@ typedef struct OSQContext {
 int pkt_offset;
 } OSQContext;
 
+static void osq_flush(AVCodecContext *avctx)
+{
+OSQContext *s = avctx->priv_data;
+
+s->bitstream_size = 0;
+s->pkt_offset = 0;
+av_packet_unref(s->pkt);
+}
+
 static av_cold int osq_close(AVCodecContext *avctx)
 {
 OSQContext *s = avctx->priv_data;
@@ -478,4 +487,5 @@ const FFCodec ff_osq_decoder = {
 AV_SAMPLE_FMT_S16P,
 AV_SAMPLE_FMT_S32P,
 AV_SAMPLE_FMT_NONE },
+.flush= osq_flush,
 };
-- 
2.17.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] lavfi: add quirc filter

2023-12-26 Thread Stefano Sabatini
---
 Changelog|   1 +
 configure|   4 +
 doc/filters.texi |  35 
 libavfilter/Makefile |   1 +
 libavfilter/allfilters.c |   1 +
 libavfilter/vf_quirc.c   | 183 +++
 6 files changed, 225 insertions(+)
 create mode 100644 libavfilter/vf_quirc.c

diff --git a/Changelog b/Changelog
index b483bb9c69..424bfc11af 100644
--- a/Changelog
+++ b/Changelog
@@ -14,6 +14,7 @@ version :
 - D3D12VA hardware accelerated H264, HEVC, VP9, AV1, MPEG-2 and VC1 decoding
 - tiltandshift filter
 - qrencode filter and qrencodesrc source
+- quirc filter
 
 version 6.1:
 - libaribcaption decoder
diff --git a/configure b/configure
index 0b2f4e9792..419ff76bc1 100755
--- a/configure
+++ b/configure
@@ -257,6 +257,7 @@ External library support:
   --enable-libplacebo  enable libplacebo library [no]
   --enable-libpulseenable Pulseaudio input via libpulse [no]
   --enable-libqrencode enable QR encode generation via libqrencode [no]
+  --enable-libquircenable QR decoding via libquirc [no]
   --enable-librabbitmq enable RabbitMQ library [no]
   --enable-librav1eenable AV1 encoding via rav1e [no]
   --enable-librist enable RIST via librist [no]
@@ -1883,6 +1884,7 @@ EXTERNAL_LIBRARY_LIST="
 libplacebo
 libpulse
 libqrencode
+libquirc
 librabbitmq
 librav1e
 librist
@@ -3793,6 +3795,7 @@ ocv_filter_deps="libopencv"
 openclsrc_filter_deps="opencl"
 qrencode_filter_deps="libqrencode"
 qrencodesrc_filter_deps="libqrencode"
+quirc_filter_deps="libquirc"
 overlay_opencl_filter_deps="opencl"
 overlay_qsv_filter_deps="libmfx"
 overlay_qsv_filter_select="qsvvpp"
@@ -6845,6 +6848,7 @@ enabled libopus   && {
 enabled libplacebo&& require_pkg_config libplacebo "libplacebo >= 
4.192.0" libplacebo/vulkan.h pl_vulkan_create
 enabled libpulse  && require_pkg_config libpulse libpulse 
pulse/pulseaudio.h pa_context_new
 enabled libqrencode   && require_pkg_config libqrencode libqrencode 
qrencode.h QRcode_encodeString
+enabled libquirc  && require libquirc quirc.h quirc_decode -lquirc
 enabled librabbitmq   && require_pkg_config librabbitmq "librabbitmq >= 
0.7.1" amqp.h amqp_new_connection
 enabled librav1e  && require_pkg_config librav1e "rav1e >= 0.5.0" 
rav1e.h rav1e_context_new
 enabled librist   && require_pkg_config librist "librist >= 0.2.7" 
librist/librist.h rist_receiver_create
diff --git a/doc/filters.texi b/doc/filters.texi
index 04898ede31..5fbe381d74 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -20368,6 +20368,41 @@ qrencode=text=%@{pts@}
 
 @end itemize
 
+@section quirc
+
+Identify and decode a QR code using the libquirc library (see
+@url{https://github.com/dlbeer/quirc/}), and print the identified QR codes
+positions and payload as metadata.
+
+To enable the compilation of this filter, you need to configure FFmpeg with 
with
+@code{--enable-libquirc}.
+
+For each found QR code in the input video, some metadata entries are added with
+the prefix @var{lavfi.quirc.N}, where @var{N} is the index, starting from 0,
+associated to the QR code.
+
+A description of each metadata value follows:
+
+@table @option
+@item lavfi.quirc.count
+the number of found QR codes, it is not set in case none was found
+
+@item lavfi.quirc.N.x
+@item lavfi.quirc.N.y
+the top-left position of the @var{N} QR code
+
+@item lavfi.quirc.N.X
+@item lavfi.quirc.N.Y
+the bottom-right position of the @var{N} QR code
+
+@item lavfi.quirc.N.w
+@item lavfi.quirc.N.h
+the size of the @var{N} QR code
+
+@item lavfi.quirc.N.payload
+the payload of the QR code
+@end table
+
 @section random
 
 Flush video frames from internal cache of frames into a random order.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 31371ceb1a..f65fb9a5a7 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -437,6 +437,7 @@ OBJS-$(CONFIG_PSEUDOCOLOR_FILTER)+= 
vf_pseudocolor.o
 OBJS-$(CONFIG_PSNR_FILTER)   += vf_psnr.o framesync.o
 OBJS-$(CONFIG_PULLUP_FILTER) += vf_pullup.o
 OBJS-$(CONFIG_QP_FILTER) += vf_qp.o
+OBJS-$(CONFIG_QUIRC_FILTER)  += vf_quirc.o
 OBJS-$(CONFIG_RANDOM_FILTER) += vf_random.o
 OBJS-$(CONFIG_READEIA608_FILTER) += vf_readeia608.o
 OBJS-$(CONFIG_READVITC_FILTER)   += vf_readvitc.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 20feb37967..b8570dbab2 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -412,6 +412,7 @@ extern const AVFilter ff_vf_psnr;
 extern const AVFilter ff_vf_pullup;
 extern const AVFilter ff_vf_qp;
 extern const AVFilter ff_vf_qrencode;
+extern const AVFilter ff_vf_quirc;
 extern const AVFilter ff_vf_random;
 extern const AVFilter ff_vf_readeia608;
 extern const AVFilter ff_vf_readvitc;
diff --git a/libavfilter/vf_quirc.c b/libavfilter/vf_quirc.c
new fi

[FFmpeg-devel] [PATCH 6/6] Add myself as APC maintainer

2023-12-26 Thread Tomas Härdin

From 616ab30780e72beb3f07ef0cb2f26ac1c8181524 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= 
Date: Tue, 26 Dec 2023 16:45:33 +0100
Subject: [PATCH 6/6] Add myself as APC maintainer

---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 3430e1722b..da111e72fb 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -391,6 +391,7 @@ Muxers/Demuxers:
   aiffenc.c Baptiste Coudurier, Matthieu Bouron
   alp.c Zane van Iperen
   amvenc.c  Zane van Iperen
+  apc*  Tomas Härdin
   apm.c Zane van Iperen
   apngdec.c Benoit Fouet
   argo_asf.cZane van Iperen
-- 
2.39.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 5/6] Add ADPCM IMA CRYO APC encoder

2023-12-26 Thread Tomas Härdin
Hopefully I got the testing right
From 047ba1051d5e03b2a54d2aad514dd4501750bc71 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= 
Date: Tue, 26 Dec 2023 14:32:20 +0100
Subject: [PATCH 5/6] Add ADPCM IMA CRYO APC encoder

No trellis quantization yet
---
 Changelog  |  1 +
 doc/general_contents.texi  |  2 +-
 libavcodec/adpcmenc.c  | 33 +
 libavcodec/allcodecs.c |  1 +
 libavcodec/version.h   |  2 +-
 tests/fate/acodec.mak  |  2 ++
 tests/ref/acodec/adpcm-ima_apc |  4 
 7 files changed, 43 insertions(+), 2 deletions(-)
 create mode 100644 tests/ref/acodec/adpcm-ima_apc

diff --git a/Changelog b/Changelog
index 344bf4d1cf..38ad342e09 100644
--- a/Changelog
+++ b/Changelog
@@ -4,6 +4,7 @@ releases are sorted from youngest to oldest.
 version :
 - LEAD MCMP decoder
 - CRYO APC muxer
+- ADPCM IMA APC encoder
 
 version 6.1:
 - libaribcaption decoder
diff --git a/doc/general_contents.texi b/doc/general_contents.texi
index a43736e3a8..f02ea89b54 100644
--- a/doc/general_contents.texi
+++ b/doc/general_contents.texi
@@ -1169,7 +1169,7 @@ following image formats are supported:
 @item ADPCM IMA Acorn Replay @tab @tab  X
 @item ADPCM IMA AMV  @tab  X  @tab  X
 @tab Used in AMV files
-@item ADPCM IMA APC  @tab @tab  X
+@item ADPCM IMA APC  @tab  X  @tab  X
 @tab Codec used in games by Cryo Interactive
 @item ADPCM IMA Cunning Developments  @tab @tab  X
 @item ADPCM IMA Electronic Arts EACS  @tab @tab  X
diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c
index 63afffc58f..47dbec41fa 100644
--- a/libavcodec/adpcmenc.c
+++ b/libavcodec/adpcmenc.c
@@ -74,6 +74,7 @@ typedef struct ADPCMEncodeContext {
 TrellisNode *node_buf;
 TrellisNode **nodep_buf;
 uint8_t *trellis_hash;
+int extradata_updated;
 } ADPCMEncodeContext;
 
 #define FREEZE_INTERVAL 128
@@ -157,6 +158,15 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx)
 bytestream_put_le16(&extradata, ff_adpcm_AdaptCoeff2[i] * 4);
 }
 ) /* End of CASE */
+CASE(ADPCM_IMA_APC,
+if (avctx->trellis) {
+av_log(avctx, AV_LOG_ERROR, "trellis encoding not implemented for CRYO APC\n");
+return AVERROR_PATCHWELCOME;
+}
+//extradata will be output in adpcm_encode_frame()
+avctx->frame_size  = s->block_size * 2 / channels;
+avctx->block_align = s->block_size;
+) /* End of CASE */
 CASE(ADPCM_YAMAHA,
 avctx->frame_size  = s->block_size * 2 / channels;
 avctx->block_align = s->block_size;
@@ -622,6 +632,28 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
 dst = avpkt->data;
 
 switch(avctx->codec->id) {
+CASE(ADPCM_IMA_APC,
+//initialize predictors using initial samples
+if (!c->extradata_updated) {
+uint8_t *side_data = av_packet_new_side_data(
+avpkt, AV_PKT_DATA_NEW_EXTRADATA, 8);
+
+if (!side_data) {
+return AVERROR(ENOMEM);
+}
+
+for (int ch = 0; ch < channels; ch++) {
+c->status[ch].prev_sample = samples[ch];
+bytestream_put_le32(&side_data, c->status[ch].prev_sample);
+}
+c->extradata_updated = 1;
+}
+for (int i = 0; i < frame->nb_samples*channels/2; i++) {
+uint8_t l = adpcm_ima_compress_sample(&c->status[0],  samples[2*i+0]);
+uint8_t r = adpcm_ima_compress_sample(&c->status[st], samples[2*i+1]);
+*dst++ = (l<<4) | r;
+}
+) /* End of CASE */
 CASE(ADPCM_IMA_WAV,
 int blocks = (frame->nb_samples - 1) / 8;
 
@@ -1028,6 +1060,7 @@ ADPCM_ENCODER(ADPCM_IMA_QT,  adpcm_ima_qt,  sample_fmts_p, 0,
 ADPCM_ENCODER(ADPCM_IMA_SSI, adpcm_ima_ssi, sample_fmts,   AV_CODEC_CAP_SMALL_LAST_FRAME, "ADPCM IMA Simon & Schuster Interactive")
 ADPCM_ENCODER(ADPCM_IMA_WAV, adpcm_ima_wav, sample_fmts_p, 0, "ADPCM IMA WAV")
 ADPCM_ENCODER(ADPCM_IMA_WS,  adpcm_ima_ws,  sample_fmts,   AV_CODEC_CAP_SMALL_LAST_FRAME, "ADPCM IMA Westwood")
+ADPCM_ENCODER(ADPCM_IMA_APC, adpcm_ima_apc, sample_fmts,   0, "ADPCM IMA CRYO APC")
 ADPCM_ENCODER(ADPCM_MS,  adpcm_ms,  sample_fmts,   0, "ADPCM Microsoft")
 ADPCM_ENCODER(ADPCM_SWF, adpcm_swf, sample_fmts,   0, "ADPCM Shockwave Flash")
 ADPCM_ENCODER(ADPCM_YAMAHA,  adpcm_yamaha,  sample_fmts,   0, "ADPCM Yamaha")
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 2662adb754..33bdd72d27 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -668,6 +668,7 @@ extern const FFCodec ff_adpcm_ima_amv_encoder;
 extern const FFCodec ff_adpcm_ima_alp_decoder;
 extern const FFCodec ff_adpcm_ima_alp_encoder;
 extern const FFCodec ff

[FFmpeg-devel] [PATCH 4/6] Un-mark IMA APC as intra-only

2023-12-26 Thread Tomas Härdin

From dd84044af61931988e43bd58c202fe4e7ca7069a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= 
Date: Tue, 26 Dec 2023 16:30:35 +0100
Subject: [PATCH 4/6] Un-mark IMA APC as intra-only

Packets must be decoded in order.
There is no way to seek and get a bitexact decode.
---
 libavcodec/codec_desc.c | 2 +-
 libavformat/apc.c   | 5 +
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 432a9c9ea6..899c082c83 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -2431,7 +2431,7 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .type  = AVMEDIA_TYPE_AUDIO,
 .name  = "adpcm_ima_apc",
 .long_name = NULL_IF_CONFIG_SMALL("ADPCM IMA CRYO APC"),
-.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
+.props = AV_CODEC_PROP_LOSSY,
 },
 {
 .id= AV_CODEC_ID_ADPCM_VIMA,
diff --git a/libavformat/apc.c b/libavformat/apc.c
index 7765c53088..d1891954a8 100644
--- a/libavformat/apc.c
+++ b/libavformat/apc.c
@@ -75,8 +75,13 @@ static int apc_read_header(AVFormatContext *s)
 
 static int apc_read_packet(AVFormatContext *s, AVPacket *pkt)
 {
+int first = avio_tell(s->pb) == 32;
 if (av_get_packet(s->pb, pkt, MAX_READ_SIZE) <= 0)
 return AVERROR(EIO);
+// each IMA APC packet depends on the one before for bitexact decode
+// extradata is used to initialize the decoder
+if (first)
+pkt->flags |= AV_PKT_FLAG_KEY;
 pkt->stream_index = 0;
 return 0;
 }
-- 
2.39.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/6] Add CRYO APC muxer

2023-12-26 Thread Tomas Härdin

From 14f3dd40a49ebf5ea020465732511e9d79a2e14a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= 
Date: Tue, 26 Dec 2023 14:32:10 +0100
Subject: [PATCH 3/6] Add CRYO APC muxer

---
 Changelog |   1 +
 doc/general_contents.texi |   2 +-
 libavformat/Makefile  |   1 +
 libavformat/allformats.c  |   1 +
 libavformat/apcenc.c  | 125 ++
 libavformat/version.h |   2 +-
 6 files changed, 130 insertions(+), 2 deletions(-)
 create mode 100644 libavformat/apcenc.c

diff --git a/Changelog b/Changelog
index ca38546262..344bf4d1cf 100644
--- a/Changelog
+++ b/Changelog
@@ -3,6 +3,7 @@ releases are sorted from youngest to oldest.
 
 version :
 - LEAD MCMP decoder
+- CRYO APC muxer
 
 version 6.1:
 - libaribcaption decoder
diff --git a/doc/general_contents.texi b/doc/general_contents.texi
index 3328753acb..a43736e3a8 100644
--- a/doc/general_contents.texi
+++ b/doc/general_contents.texi
@@ -448,7 +448,7 @@ library:
 @item CRC testing format@tab X @tab
 @item Creative Voice@tab X @tab X
 @tab Created for the Sound Blaster Pro.
-@item CRYO APC  @tab   @tab X
+@item CRYO APC  @tab X @tab X
 @tab Audio format used in some games by CRYO Interactive Entertainment.
 @item D-Cinema audio@tab X @tab X
 @item Deluxe Paint Animation@tab   @tab X
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 329055ccfd..d88a65d713 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -105,6 +105,7 @@ OBJS-$(CONFIG_AMV_MUXER) += amvenc.o
 OBJS-$(CONFIG_ANM_DEMUXER)   += anm.o
 OBJS-$(CONFIG_APAC_DEMUXER)  += apac.o rawdec.o
 OBJS-$(CONFIG_APC_DEMUXER)   += apc.o
+OBJS-$(CONFIG_APC_MUXER) += apcenc.o
 OBJS-$(CONFIG_APE_DEMUXER)   += ape.o apetag.o img2.o
 OBJS-$(CONFIG_APM_DEMUXER)   += apm.o
 OBJS-$(CONFIG_APM_MUXER) += apm.o rawenc.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index d4b505a5a3..ab74c2028f 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -60,6 +60,7 @@ extern const FFOutputFormat ff_amv_muxer;
 extern const AVInputFormat  ff_anm_demuxer;
 extern const AVInputFormat  ff_apac_demuxer;
 extern const AVInputFormat  ff_apc_demuxer;
+extern const FFOutputFormat ff_apc_muxer;
 extern const AVInputFormat  ff_ape_demuxer;
 extern const AVInputFormat  ff_apm_demuxer;
 extern const FFOutputFormat ff_apm_muxer;
diff --git a/libavformat/apcenc.c b/libavformat/apcenc.c
new file mode 100644
index 00..ba024ead50
--- /dev/null
+++ b/libavformat/apcenc.c
@@ -0,0 +1,125 @@
+/*
+ * CRYO APC audio format muxer
+ * Copyright (c) 2023 Tomas Härdin 
+ *
+ * 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 "avio_internal.h"
+#include "internal.h"
+#include "mux.h"
+
+#define APC_HEADER_SIZE (8*4)
+
+static int apc_write_header(AVFormatContext *s)
+{
+AVIOContext *pb = s->pb;
+AVCodecParameters *par;
+AVStream *st;
+
+if (s->nb_streams != 1) {
+av_log(s, AV_LOG_ERROR, "Must have exactly one stream\n");
+return AVERROR(EINVAL);
+}
+
+st = s->streams[0];
+par = st->codecpar;
+
+if (par->ch_layout.nb_channels <= 0 || par->ch_layout.nb_channels > 2) {
+av_log(s, AV_LOG_ERROR, "Must be mono or stereo\n");
+return AVERROR(EINVAL);
+}
+
+if (par->extradata_size != 0 && par->extradata_size != 8) {
+av_log(s, AV_LOG_ERROR,
+"Must have exactly 0 or 8 bytes of extradata, got %i\n",
+par->extradata_size);
+return AVERROR(EINVAL);
+}
+
+ffio_wfourcc(pb, "CRYO");
+ffio_wfourcc(pb, "_APC");
+ffio_wfourcc(pb, "1.20");
+avio_wl32(pb, 0); // number or samples
+avio_wl32(pb, par->sample_rate);
+
+// write extradata if we have it (remuxing)
+// else write dummy values and wait for AV_PKT_DATA_NEW_EXTRADATA (encoding)
+if (par->extradata_size) {
+avio_write(pb, par->extradata, par->extradata_size);
+} else {
+avio_wl64(pb, 0);
+}
+
+avio_wl32(pb, par->ch_layout.nb_channels - 1);
+avpriv_set_pts_info(st, 64, 1, par->sample_rate);
+return 0;
+}
+

[FFmpeg-devel] [PATCH 2/6] apc: Read duration from file

2023-12-26 Thread Tomas Härdin

From b3756e6258d18139fb2b67e3d9bc795bafd1b065 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= 
Date: Tue, 26 Dec 2023 14:31:59 +0100
Subject: [PATCH 2/6] apc: Read duration from file

---
 libavformat/apc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavformat/apc.c b/libavformat/apc.c
index b8b18c966c..7765c53088 100644
--- a/libavformat/apc.c
+++ b/libavformat/apc.c
@@ -24,6 +24,7 @@
 #include "libavutil/channel_layout.h"
 #include "avformat.h"
 #include "demux.h"
+#include "internal.h"
 
 static int apc_probe(const AVProbeData *p)
 {
@@ -51,8 +52,9 @@ static int apc_read_header(AVFormatContext *s)
 st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
 st->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_APC;
 
-avio_rl32(pb); /* number of samples */
+st->duration = avio_rl32(pb); /* number of samples */
 st->codecpar->sample_rate = avio_rl32(pb);
+avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
 
 /* initial predictor values for adpcm decoder */
 if ((ret = ff_get_extradata(s, st->codecpar, pb, 2 * 4)) < 0)
-- 
2.39.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/6] doc/general_contents.texi: Add missing ADPCM IMA APC entry

2023-12-26 Thread Tomas Härdin
Rebased and addressed some comments from last time. Also discovered
some issues like the IMA APC codec not being listed. This is for the
Cryo game modding community.

/Tomas
From 490754ea1580d4d02bba83150ca09ca8f960c6fd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= 
Date: Tue, 26 Dec 2023 15:03:51 +0100
Subject: [PATCH 1/6] doc/general_contents.texi: Add missing ADPCM IMA APC
 entry

---
 doc/general_contents.texi | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/doc/general_contents.texi b/doc/general_contents.texi
index 62ca4f7cb6..3328753acb 100644
--- a/doc/general_contents.texi
+++ b/doc/general_contents.texi
@@ -1169,6 +1169,8 @@ following image formats are supported:
 @item ADPCM IMA Acorn Replay @tab @tab  X
 @item ADPCM IMA AMV  @tab  X  @tab  X
 @tab Used in AMV files
+@item ADPCM IMA APC  @tab @tab  X
+@tab Codec used in games by Cryo Interactive
 @item ADPCM IMA Cunning Developments  @tab @tab  X
 @item ADPCM IMA Electronic Arts EACS  @tab @tab  X
 @item ADPCM IMA Electronic Arts SEAD  @tab @tab  X
-- 
2.39.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 v2] avcodec/jpegxl_parser: check ANS cluster alphabet size vs bundle size

2023-12-26 Thread Leo Izen

On 12/25/23 15:09, Michael Niedermayer wrote:

On Mon, Dec 25, 2023 at 12:04:17PM -0500, Leo Izen wrote:

The specification doesn't mention that clusters cannot have alphabet
sizes greater than 1 << bundle->log_alphabet_size, but the reference
implementation rejects these entropy streams as invalid, so we should
too. Refusing to do so can overflow a stack variable on line 556 that
should be large enough otherwise.

Fixes #10738.

Found-by: Zeng Yunxiang and Li Zeyuan
Signed-off-by: Leo Izen 
---
  libavcodec/jpegxl_parser.c | 28 +++-
  1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/libavcodec/jpegxl_parser.c b/libavcodec/jpegxl_parser.c
index 006eb6b295..f026fda9ac 100644
--- a/libavcodec/jpegxl_parser.c
+++ b/libavcodec/jpegxl_parser.c
@@ -64,26 +64,26 @@ typedef struct JXLSymbolDistribution {
  int log_bucket_size;
  /* this is the actual size of the alphabet */
  int alphabet_size;
-/* ceil(log(alphabet_size)) */
-int log_alphabet_size;
  
  /* for prefix code distributions */

  VLC vlc;
  /* in case bits == 0 */
  uint32_t default_symbol;
+/* ceil(log(alphabet_size)) */
+int log_alphabet_size;
  


that seems unneeded



dist->log_alphaebet_size is only used for prefix code distributions so I 
moved it for clarity. I can also remove this change from this commit if 
you think it's off-topic.


In either case, is the commit okay, apart from this one change? If so 
I'm going to merge it (after I remove this one change from the diff).


- Leo Izen (Traneptora)

___
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] Mailinglist conduct [was: Re: [PATCH] lavc: remove the QOA decoder]

2023-12-26 Thread Ronald S. Bultje
Hi Nicolas,

On Thu, Dec 21, 2023 at 3:31 PM Nicolas George  wrote:

> Paul B Mahol (12023-12-21):
> > Say what serious feature you contributed ? - Nothing.
>
> I did not want to say it, but since it is now in the open: Not nothing:
> negative. His naysaying discouraged me from working further on the
> built-in documentation system.
>

The CC deems some of your statements in this thread (here: "Not nothing:
negative", and later on: "Then you need to find a different project.") to
be personal attacks, in violation of our code of conduct. The CC requests
that you stop such behaviour at once and refrain from it in the future.
Remember that the CC has the option to take away mailinglist privileges.

Unanimously signed,
The CC illuminati (Anton, James, Jean-Baptiste, Michael, 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] avcodec/d3d12va_decode: don't change the resource state if the referenced frame is the same as the current frame

2023-12-26 Thread Wu Jianhua
avcodec/d3d12va_decode: don't change the resource state if the referenced frame 
is the same as the current frame

 This commit removes the follow warning and error:

D3D12 WARNING: ID3D12CommandList::ResourceBarrier: Called on the same 
subresource(s) of
Resource(0x02236E0E00D0:'Unnamed ID3D12Resource Object') in separate 
Barrier Descs
which is inefficient and likely unintentional. Desc[0] and Desc[1] on 
(subresource :
4294967295). [RESOURCE_MANIPULATION WARNING #1008: 
RESOURCE_BARRIER_DUPLICATE_SUBRESOURCE_TRANSITIONS]

D3D12 ERROR: ID3D12CommandList::ResourceBarrier: Before state (0x0: 
D3D12_RESOURCE_STATE_[COMMON|PRESENT])
of resource (0x02236E0E00D0:'Unnamed ID3D12Resource Object') 
(subresource: 0) specified
by transition barrier does not match with the state (0x2: 
D3D12_RESOURCE_STATE_VIDEO_DECODE_WRITE)
specified in the previous call to ResourceBarrier [RESOURCE_MANIPULATION 
ERROR #527:
RESOURCE_BARRIER_BEFORE_AFTER_MISMATCH]

Patch attached


0001-avcodec-d3d12va_decode-don-t-change-the-resource-sta.patch
Description: 0001-avcodec-d3d12va_decode-don-t-change-the-resource-sta.patch
___
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: remove the QOA decoder

2023-12-26 Thread Michael Niedermayer
On Mon, Dec 25, 2023 at 11:22:40AM -0600, Leo Izen wrote:
> On 12/21/23 21:32, Michael Niedermayer wrote:
> > 
> > Can you think of a way to add some lines of code to this that makes it more 
> > maintainable ?
> > 
> > if yes, then i think you proofed that adding code can reduce maintaince 
> > burden
> > 
> > thx
> > 
> 
> This is clearly not the point here. The point is that an in-house module has
> to be maintained, and removing that module removes the maintenance burden.
> An international obfuscated C contest entry isn't really on-topic.

You snipped the whole discussion this was a reply to and argue in a different
context. The claim was:

> > > [...] , but every line of code
> > > carries with it a non-zero maintenance burden

And the text you replied to was part of sketching a proof that the
claim was false.

If you make a different claim, yes, you need a different proof.

So what is the new claim ?
"The point is that an in-house module has
 to be maintained, and removing that module removes the maintenance burden."

This is true, IF you ignore that "removing that module" has lead to loss of
developers, should lead to loss of users and also a higher burden on the
end user, who then may have to compile various external dependancies
and maintain these with security updates. OR maybe the end user would
have to choose between 2 forks depending in what feature she wants.

If one, for sake of argument would say the removial of any module would
be good, then the optimum is 0 modules.
Thats clearly not optimal so that would be abusrd

So we know removial cannot always be optimal. That also means it must be
a good thing sometimes to have what you call additional "maintenance burden"

thx

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

it is not once nor twice but times without number that the same ideas make
their appearance in the world. -- Aristotle


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

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


Re: [FFmpeg-devel] [PATCH v2] configure: Enable section_data_rel_ro for FreeBSD and NetBSD aarch64 / arm

2023-12-26 Thread Michael Niedermayer
On Mon, Dec 25, 2023 at 09:04:54PM -0500, Brad Smith wrote:
> On 2023-12-24 9:08 p.m., Michael Niedermayer wrote:
> > On Sun, Dec 24, 2023 at 02:33:31PM -0500, Brad Smith wrote:
> > > configure: Enable section_data_rel_ro for FreeBSD and NetBSD aarch64 / arm
> > > 
> > > Fixes the build. It's a requirement when utilizing PIE.
> > > 
> > > Signed-off-by: Brad Smith 
> > > ---
> > >   configure | 2 ++
> > >   1 file changed, 2 insertions(+)
> > will apply
> > 
> > thx
> 
> Thanks. Can you please back port this to 6.1, 6.0, 5.1, 5.0 and 4.4?

it will be in the next releases from these branches

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

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


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

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