ffmpeg-devel
Threads by month
- ----- 2026 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
October 2025
- 50 participants
- 205 discussions
PR #20645 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20645
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20645.patch
From 549383606f01ac1cf481c0b69b923ed44fcb99d4 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Sat, 4 Oct 2025 07:29:35 +0200
Subject: [PATCH 1/8] avcodec/x86/h264_qpel_8bit: Improve register allocation
None of the other registers need to be preserved at this time,
so six XMM registers are always enough. Forgotten in
fa9ea5113b48904daef9df6a282bd9c04c32258d.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/h264_qpel_8bit.asm | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/libavcodec/x86/h264_qpel_8bit.asm b/libavcodec/x86/h264_qpel_8bit.asm
index ede4f382e1..bbf591664a 100644
--- a/libavcodec/x86/h264_qpel_8bit.asm
+++ b/libavcodec/x86/h264_qpel_8bit.asm
@@ -634,11 +634,7 @@ QPEL8OR16_HV2_LOWPASS_OP put
QPEL8OR16_HV2_LOWPASS_OP avg
%macro QPEL8OR16_HV2_LOWPASS_OP_XMM 1
-%ifidn %1, avg
-cglobal %1_h264_qpel8_hv2_lowpass, 3,4,7 ; dst, tmp, dstStride
-%else
cglobal %1_h264_qpel8_hv2_lowpass, 3,4,6 ; dst, tmp, dstStride
-%endif
mov r3d, 8
.loop:
mova m1, [r1+16]
@@ -663,7 +659,7 @@ cglobal %1_h264_qpel8_hv2_lowpass, 3,4,6 ; dst, tmp, dstStride
paddw m0, m2
psraw m0, 6
packuswb m0, m0
- op_%1h m0, [r0], m6
+ op_%1h m0, [r0], m5
add r1, 48
add r0, r2
dec r3d
--
2.49.1
From 48460a769cf736dac6237bd4116eafb1cce51d2a Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Sat, 4 Oct 2025 08:43:21 +0200
Subject: [PATCH 2/8] avcodec/h264qpel: Move Snow-only code to snow.c
Blocksize 2 is Snow-only, so move all the code pertaining
to it to snow.c. Also make the put array in H264QpelContext
smaller -- it only needs three sets of 16 function pointers.
This continues 6eb8bc42176f73c1d7c2e9f4bc1ab988f7149de5
and b0c91c2fba82f98dfe7a70f2591ec7a2126820c0.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/h264qpel.c | 60 -------------------
libavcodec/h264qpel.h | 2 +-
libavcodec/h264qpel_template.c | 94 ++++++++++++++---------------
libavcodec/pel_template.c | 2 +-
libavcodec/snow.c | 104 ++++++++++++++++++++++++++++++---
libavcodec/snow.h | 6 +-
tests/checkasm/h264qpel.c | 2 +-
7 files changed, 152 insertions(+), 118 deletions(-)
diff --git a/libavcodec/h264qpel.c b/libavcodec/h264qpel.c
index be80203c4b..0bc715c638 100644
--- a/libavcodec/h264qpel.c
+++ b/libavcodec/h264qpel.c
@@ -26,65 +26,6 @@
#define pixeltmp int16_t
#define BIT_DEPTH 8
#include "h264qpel_template.c"
-
-static void put_h264_qpel2_h_lowpass_8(uint8_t *dst, const uint8_t *restrict src, int dstStride, int srcStride)
-{
- const int h = 2;
- for (int i = 0; i < h; ++i) {
- dst[0] = av_clip_uint8(((src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]) + 16) >> 5);
- dst[1] = av_clip_uint8(((src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]) + 16) >> 5);
- dst += dstStride;
- src += srcStride;
- }
-}
-
-static void put_h264_qpel2_v_lowpass_8(uint8_t *dst, const uint8_t *restrict src, int dstStride, int srcStride)
-{
- const int w = 2;
- for (int i = 0; i < w; ++i) {
- const int srcB = src[-2*srcStride];
- const int srcA = src[-1*srcStride];
- const int src0 = src[0 *srcStride];
- const int src1 = src[1 *srcStride];
- const int src2 = src[2 *srcStride];
- const int src3 = src[3 *srcStride];
- const int src4 = src[4 *srcStride];
- dst[0*dstStride] = av_clip_uint8(((src0+src1)*20 - (srcA+src2)*5 + (srcB+src3) + 16) >> 5);
- dst[1*dstStride] = av_clip_uint8(((src1+src2)*20 - (src0+src3)*5 + (srcA+src4) + 16) >> 5);
- dst++;
- src++;
- }
-}
-
-static void put_h264_qpel2_hv_lowpass_8(uint8_t *dst, pixeltmp *tmp, const uint8_t *restrict src, int dstStride, int tmpStride, int srcStride)
-{
- const int h = 2;
- const int w = 2;
- src -= 2*srcStride;
- for (int i = 0; i < h + 5; ++i) {
- tmp[0] = (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]);
- tmp[1] = (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]);
- tmp += tmpStride;
- src += srcStride;
- }
- tmp -= tmpStride*(h+5-2);
- for (int i = 0; i < w; ++i) {
- const int tmpB = tmp[-2*tmpStride];
- const int tmpA = tmp[-1*tmpStride];
- const int tmp0 = tmp[0 *tmpStride];
- const int tmp1 = tmp[1 *tmpStride];
- const int tmp2 = tmp[2 *tmpStride];
- const int tmp3 = tmp[3 *tmpStride];
- const int tmp4 = tmp[4 *tmpStride];
- dst[0*dstStride] = av_clip_uint8(((tmp0+tmp1)*20 - (tmpA+tmp2)*5 + (tmpB+tmp3) + 512) >> 10);
- dst[1*dstStride] = av_clip_uint8(((tmp1+tmp2)*20 - (tmp0+tmp3)*5 + (tmpA+tmp4) + 512) >> 10);
- dst++;
- tmp++;
- }
-}
-
-H264_MC(put_, 2)
-
#undef BIT_DEPTH
#define BIT_DEPTH 9
@@ -140,7 +81,6 @@ av_cold void ff_h264qpel_init(H264QpelContext *c, int bit_depth)
switch (bit_depth) {
default:
SET_QPEL(8);
- dspfunc2(put_h264_qpel, 3, 2, 8); // only used by Snow
break;
case 9:
SET_QPEL(9);
diff --git a/libavcodec/h264qpel.h b/libavcodec/h264qpel.h
index 6ae5ba1724..f198a9483c 100644
--- a/libavcodec/h264qpel.h
+++ b/libavcodec/h264qpel.h
@@ -25,7 +25,7 @@
#include "qpeldsp.h"
typedef struct H264QpelContext {
- qpel_mc_func put_h264_qpel_pixels_tab[4][16];
+ qpel_mc_func put_h264_qpel_pixels_tab[3][16];
qpel_mc_func avg_h264_qpel_pixels_tab[3][16];
} H264QpelContext;
diff --git a/libavcodec/h264qpel_template.c b/libavcodec/h264qpel_template.c
index a55b45e824..875ac86d15 100644
--- a/libavcodec/h264qpel_template.c
+++ b/libavcodec/h264qpel_template.c
@@ -304,134 +304,134 @@ static void FUNC(OPNAME ## h264_qpel16_hv_lowpass)(uint8_t *dst, pixeltmp *tmp,
FUNC(OPNAME ## h264_qpel8_hv_lowpass)(dst+8*sizeof(pixel), tmp+8, src+8*sizeof(pixel), dstStride, tmpStride, srcStride);\
}\
-#define H264_MC(OPNAME, SIZE) \
-static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc00)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\
+#define H264_MC(OPNAME, NAME, SIZE) \
+static void FUNCC(OPNAME ## NAME ## _qpel ## SIZE ## _mc00)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\
{\
FUNCC(OPNAME ## pixels ## SIZE)(dst, src, stride, SIZE);\
}\
\
-static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc10)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\
+static void FUNCC(OPNAME ## NAME ## _qpel ## SIZE ## _mc10)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\
{\
uint8_t half[SIZE*SIZE*sizeof(pixel)];\
- FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(half, src, SIZE*sizeof(pixel), stride);\
+ FUNC(put_ ## NAME ## _qpel ## SIZE ## _h_lowpass)(half, src, SIZE*sizeof(pixel), stride);\
FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, src, half, stride, stride, SIZE*sizeof(pixel), SIZE);\
}\
\
-static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc20)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\
+static void FUNCC(OPNAME ## NAME ## _qpel ## SIZE ## _mc20)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\
{\
- FUNC(OPNAME ## h264_qpel ## SIZE ## _h_lowpass)(dst, src, stride, stride);\
+ FUNC(OPNAME ## NAME ## _qpel ## SIZE ## _h_lowpass)(dst, src, stride, stride);\
}\
\
-static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc30)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\
+static void FUNCC(OPNAME ## NAME ## _qpel ## SIZE ## _mc30)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\
{\
uint8_t half[SIZE*SIZE*sizeof(pixel)];\
- FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(half, src, SIZE*sizeof(pixel), stride);\
+ FUNC(put_ ## NAME ## _qpel ## SIZE ## _h_lowpass)(half, src, SIZE*sizeof(pixel), stride);\
FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, src+sizeof(pixel), half, stride, stride, SIZE*sizeof(pixel), SIZE);\
}\
\
-static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc01)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\
+static void FUNCC(OPNAME ## NAME ## _qpel ## SIZE ## _mc01)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\
{\
uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
uint8_t half[SIZE*SIZE*sizeof(pixel)];\
FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
- FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(half, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
+ FUNC(put_ ## NAME ## _qpel ## SIZE ## _v_lowpass)(half, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, full_mid, half, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
}\
\
-static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc02)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\
+static void FUNCC(OPNAME ## NAME ## _qpel ## SIZE ## _mc02)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\
{\
uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
- FUNC(OPNAME ## h264_qpel ## SIZE ## _v_lowpass)(dst, full_mid, stride, SIZE*sizeof(pixel));\
+ FUNC(OPNAME ## NAME ## _qpel ## SIZE ## _v_lowpass)(dst, full_mid, stride, SIZE*sizeof(pixel));\
}\
\
-static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc03)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\
+static void FUNCC(OPNAME ## NAME ## _qpel ## SIZE ## _mc03)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\
{\
uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
uint8_t half[SIZE*SIZE*sizeof(pixel)];\
FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
- FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(half, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
+ FUNC(put_ ## NAME ## _qpel ## SIZE ## _v_lowpass)(half, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, full_mid+SIZE*sizeof(pixel), half, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
}\
\
-static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc11)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\
+static void FUNCC(OPNAME ## NAME ## _qpel ## SIZE ## _mc11)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\
{\
uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
- FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src, SIZE*sizeof(pixel), stride);\
+ FUNC(put_ ## NAME ## _qpel ## SIZE ## _h_lowpass)(halfH, src, SIZE*sizeof(pixel), stride);\
FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
- FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
+ FUNC(put_ ## NAME ## _qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
}\
\
-static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc31)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\
+static void FUNCC(OPNAME ## NAME ## _qpel ## SIZE ## _mc31)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\
{\
uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
- FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src, SIZE*sizeof(pixel), stride);\
+ FUNC(put_ ## NAME ## _qpel ## SIZE ## _h_lowpass)(halfH, src, SIZE*sizeof(pixel), stride);\
FUNC(copy_block ## SIZE )(full, src - stride*2 + sizeof(pixel), SIZE*sizeof(pixel), stride, SIZE + 5);\
- FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
+ FUNC(put_ ## NAME ## _qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
}\
\
-static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc13)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\
+static void FUNCC(OPNAME ## NAME ## _qpel ## SIZE ## _mc13)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\
{\
uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
- FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src + stride, SIZE*sizeof(pixel), stride);\
+ FUNC(put_ ## NAME ## _qpel ## SIZE ## _h_lowpass)(halfH, src + stride, SIZE*sizeof(pixel), stride);\
FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
- FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
+ FUNC(put_ ## NAME ## _qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
}\
\
-static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc33)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\
+static void FUNCC(OPNAME ## NAME ## _qpel ## SIZE ## _mc33)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\
{\
uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
- FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src + stride, SIZE*sizeof(pixel), stride);\
+ FUNC(put_ ## NAME ## _qpel ## SIZE ## _h_lowpass)(halfH, src + stride, SIZE*sizeof(pixel), stride);\
FUNC(copy_block ## SIZE )(full, src - stride*2 + sizeof(pixel), SIZE*sizeof(pixel), stride, SIZE + 5);\
- FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
+ FUNC(put_ ## NAME ## _qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
}\
\
-static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc22)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\
+static void FUNCC(OPNAME ## NAME ## _qpel ## SIZE ## _mc22)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\
{\
pixeltmp tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
- FUNC(OPNAME ## h264_qpel ## SIZE ## _hv_lowpass)(dst, tmp, src, stride, SIZE*sizeof(pixel), stride);\
+ FUNC(OPNAME ## NAME ## _qpel ## SIZE ## _hv_lowpass)(dst, tmp, src, stride, SIZE*sizeof(pixel), stride);\
}\
\
-static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc21)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\
+static void FUNCC(OPNAME ## NAME ## _qpel ## SIZE ## _mc21)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\
{\
pixeltmp tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
uint8_t halfHV[SIZE*SIZE*sizeof(pixel)];\
- FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src, SIZE*sizeof(pixel), stride);\
- FUNC(put_h264_qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
+ FUNC(put_ ## NAME ## _qpel ## SIZE ## _h_lowpass)(halfH, src, SIZE*sizeof(pixel), stride);\
+ FUNC(put_ ## NAME ## _qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfHV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
}\
\
-static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc23)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\
+static void FUNCC(OPNAME ## NAME ## _qpel ## SIZE ## _mc23)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\
{\
pixeltmp tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
uint8_t halfHV[SIZE*SIZE*sizeof(pixel)];\
- FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src + stride, SIZE*sizeof(pixel), stride);\
- FUNC(put_h264_qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
+ FUNC(put_ ## NAME ## _qpel ## SIZE ## _h_lowpass)(halfH, src + stride, SIZE*sizeof(pixel), stride);\
+ FUNC(put_ ## NAME ## _qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfHV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
}\
\
-static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc12)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\
+static void FUNCC(OPNAME ## NAME ## _qpel ## SIZE ## _mc12)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\
{\
uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
@@ -439,12 +439,12 @@ static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc12)(uint8_t *dst, const uint
uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
uint8_t halfHV[SIZE*SIZE*sizeof(pixel)];\
FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
- FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
- FUNC(put_h264_qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
+ FUNC(put_ ## NAME ## _qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
+ FUNC(put_ ## NAME ## _qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfV, halfHV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
}\
\
-static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc32)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\
+static void FUNCC(OPNAME ## NAME ## _qpel ## SIZE ## _mc32)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\
{\
uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
@@ -452,8 +452,8 @@ static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc32)(uint8_t *dst, const uint
uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
uint8_t halfHV[SIZE*SIZE*sizeof(pixel)];\
FUNC(copy_block ## SIZE )(full, src - stride*2 + sizeof(pixel), SIZE*sizeof(pixel), stride, SIZE + 5);\
- FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
- FUNC(put_h264_qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
+ FUNC(put_ ## NAME ## _qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
+ FUNC(put_ ## NAME ## _qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfV, halfHV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
}\
@@ -463,14 +463,16 @@ static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc32)(uint8_t *dst, const uint
#define op2_avg(a, b) a = (((a)+CLIP(((b) + 512)>>10)+1)>>1)
#define op2_put(a, b) a = CLIP(((b) + 512)>>10)
+#ifndef SNOW
H264_LOWPASS(put_ , op_put, op2_put)
H264_LOWPASS(avg_ , op_avg, op2_avg)
-H264_MC(put_, 4)
-H264_MC(put_, 8)
-H264_MC(put_, 16)
-H264_MC(avg_, 4)
-H264_MC(avg_, 8)
-H264_MC(avg_, 16)
+H264_MC(put_, h264, 4)
+H264_MC(put_, h264, 8)
+H264_MC(put_, h264, 16)
+H264_MC(avg_, h264, 4)
+H264_MC(avg_, h264, 8)
+H264_MC(avg_, h264, 16)
+#endif
#undef op_avg
#undef op_put
diff --git a/libavcodec/pel_template.c b/libavcodec/pel_template.c
index 6da7a56b2d..7de3db72f1 100644
--- a/libavcodec/pel_template.c
+++ b/libavcodec/pel_template.c
@@ -66,7 +66,7 @@ static inline void FUNCC(OPNAME ## _pixels8)(uint8_t *block, \
block += line_size; \
} \
} \
- \
+av_unused \
CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16), \
FUNCC(OPNAME ## _pixels8), \
8 * sizeof(pixel))
diff --git a/libavcodec/snow.c b/libavcodec/snow.c
index e0ce83eb9c..006d84d8ce 100644
--- a/libavcodec/snow.c
+++ b/libavcodec/snow.c
@@ -18,6 +18,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <assert.h>
+
#include "libavutil/log.h"
#include "libavutil/mem.h"
#include "libavutil/thread.h"
@@ -26,6 +28,91 @@
#include "snow.h"
#include "snowdata.h"
+#define pixeltmp int16_t
+#define BIT_DEPTH 8
+#define SNOW
+#include "h264qpel_template.c"
+
+static void put_snow_qpel2_h_lowpass_8(uint8_t *dst, const uint8_t *restrict src, int dstStride, int srcStride)
+{
+ const int h = 2;
+ for (int i = 0; i < h; ++i) {
+ dst[0] = av_clip_uint8(((src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]) + 16) >> 5);
+ dst[1] = av_clip_uint8(((src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]) + 16) >> 5);
+ dst += dstStride;
+ src += srcStride;
+ }
+}
+
+static void put_snow_qpel2_v_lowpass_8(uint8_t *dst, const uint8_t *restrict src, int dstStride, int srcStride)
+{
+ const int w = 2;
+ for (int i = 0; i < w; ++i) {
+ const int srcB = src[-2*srcStride];
+ const int srcA = src[-1*srcStride];
+ const int src0 = src[0 *srcStride];
+ const int src1 = src[1 *srcStride];
+ const int src2 = src[2 *srcStride];
+ const int src3 = src[3 *srcStride];
+ const int src4 = src[4 *srcStride];
+ dst[0*dstStride] = av_clip_uint8(((src0+src1)*20 - (srcA+src2)*5 + (srcB+src3) + 16) >> 5);
+ dst[1*dstStride] = av_clip_uint8(((src1+src2)*20 - (src0+src3)*5 + (srcA+src4) + 16) >> 5);
+ dst++;
+ src++;
+ }
+}
+
+static void put_snow_qpel2_hv_lowpass_8(uint8_t *dst, pixeltmp *tmp, const uint8_t *restrict src, int dstStride, int tmpStride, int srcStride)
+{
+ const int h = 2;
+ const int w = 2;
+ src -= 2*srcStride;
+ for (int i = 0; i < h + 5; ++i) {
+ tmp[0] = (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]);
+ tmp[1] = (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]);
+ tmp += tmpStride;
+ src += srcStride;
+ }
+ tmp -= tmpStride*(h+5-2);
+ for (int i = 0; i < w; ++i) {
+ const int tmpB = tmp[-2*tmpStride];
+ const int tmpA = tmp[-1*tmpStride];
+ const int tmp0 = tmp[0 *tmpStride];
+ const int tmp1 = tmp[1 *tmpStride];
+ const int tmp2 = tmp[2 *tmpStride];
+ const int tmp3 = tmp[3 *tmpStride];
+ const int tmp4 = tmp[4 *tmpStride];
+ dst[0*dstStride] = av_clip_uint8(((tmp0+tmp1)*20 - (tmpA+tmp2)*5 + (tmpB+tmp3) + 512) >> 10);
+ dst[1*dstStride] = av_clip_uint8(((tmp1+tmp2)*20 - (tmp0+tmp3)*5 + (tmpA+tmp4) + 512) >> 10);
+ dst++;
+ tmp++;
+ }
+}
+
+H264_MC(put_, snow, 2)
+
+static av_cold void init_qpel(SnowContext *const s)
+{
+ static_assert(offsetof(H264QpelContext, put_h264_qpel_pixels_tab) == 0,
+ "put_h264_qpel_pixels_tab not at start of H264QpelContext");
+ ff_h264qpel_init(&s->h264qpel, 8);
+ s->put_snow_qpel_pixels_tab[3][0] = put_snow_qpel2_mc00_8_c;
+ s->put_snow_qpel_pixels_tab[3][1] = put_snow_qpel2_mc10_8_c;
+ s->put_snow_qpel_pixels_tab[3][2] = put_snow_qpel2_mc20_8_c;
+ s->put_snow_qpel_pixels_tab[3][3] = put_snow_qpel2_mc30_8_c;
+ s->put_snow_qpel_pixels_tab[3][4] = put_snow_qpel2_mc01_8_c;
+ s->put_snow_qpel_pixels_tab[3][5] = put_snow_qpel2_mc11_8_c;
+ s->put_snow_qpel_pixels_tab[3][6] = put_snow_qpel2_mc21_8_c;
+ s->put_snow_qpel_pixels_tab[3][7] = put_snow_qpel2_mc31_8_c;
+ s->put_snow_qpel_pixels_tab[3][8] = put_snow_qpel2_mc02_8_c;
+ s->put_snow_qpel_pixels_tab[3][9] = put_snow_qpel2_mc12_8_c;
+ s->put_snow_qpel_pixels_tab[3][10] = put_snow_qpel2_mc22_8_c;
+ s->put_snow_qpel_pixels_tab[3][11] = put_snow_qpel2_mc32_8_c;
+ s->put_snow_qpel_pixels_tab[3][12] = put_snow_qpel2_mc03_8_c;
+ s->put_snow_qpel_pixels_tab[3][13] = put_snow_qpel2_mc13_8_c;
+ s->put_snow_qpel_pixels_tab[3][14] = put_snow_qpel2_mc23_8_c;
+ s->put_snow_qpel_pixels_tab[3][15] = put_snow_qpel2_mc33_8_c;
+}
void ff_snow_inner_add_yblock(const uint8_t *obmc, const int obmc_stride, uint8_t * * block, int b_w, int b_h,
int src_x, int src_y, int src_stride, slice_buffer * sb, int add, uint8_t * dst8){
@@ -354,18 +441,18 @@ void ff_snow_pred_block(SnowContext *s, uint8_t *dst, uint8_t *tmp, ptrdiff_t st
else if(b_w==32){
int y;
for(y=0; y<b_h; y+=16){
- s->h264qpel.put_h264_qpel_pixels_tab[0][dy+(dx>>2)](dst + y*stride, src + 3 + (y+3)*stride,stride);
- s->h264qpel.put_h264_qpel_pixels_tab[0][dy+(dx>>2)](dst + 16 + y*stride, src + 19 + (y+3)*stride,stride);
+ s->put_snow_qpel_pixels_tab[0][dy+(dx>>2)](dst + y*stride, src + 3 + (y+3)*stride,stride);
+ s->put_snow_qpel_pixels_tab[0][dy+(dx>>2)](dst + 16 + y*stride, src + 19 + (y+3)*stride,stride);
}
}else if(b_w==b_h)
- s->h264qpel.put_h264_qpel_pixels_tab[tab_index ][dy+(dx>>2)](dst,src + 3 + 3*stride,stride);
+ s->put_snow_qpel_pixels_tab[tab_index ][dy+(dx>>2)](dst,src + 3 + 3*stride,stride);
else if(b_w==2*b_h){
- s->h264qpel.put_h264_qpel_pixels_tab[tab_index+1][dy+(dx>>2)](dst ,src + 3 + 3*stride,stride);
- s->h264qpel.put_h264_qpel_pixels_tab[tab_index+1][dy+(dx>>2)](dst+b_h,src + 3 + b_h + 3*stride,stride);
+ s->put_snow_qpel_pixels_tab[tab_index+1][dy+(dx>>2)](dst ,src + 3 + 3*stride,stride);
+ s->put_snow_qpel_pixels_tab[tab_index+1][dy+(dx>>2)](dst+b_h,src + 3 + b_h + 3*stride,stride);
}else{
av_assert2(2*b_w==b_h);
- s->h264qpel.put_h264_qpel_pixels_tab[tab_index ][dy+(dx>>2)](dst ,src + 3 + 3*stride ,stride);
- s->h264qpel.put_h264_qpel_pixels_tab[tab_index ][dy+(dx>>2)](dst+b_w*stride,src + 3 + 3*stride+b_w*stride,stride);
+ s->put_snow_qpel_pixels_tab[tab_index ][dy+(dx>>2)](dst ,src + 3 + 3*stride ,stride);
+ s->put_snow_qpel_pixels_tab[tab_index ][dy+(dx>>2)](dst+b_w*stride,src + 3 + 3*stride+b_w*stride,stride);
}
}
}
@@ -404,7 +491,8 @@ av_cold int ff_snow_common_init(AVCodecContext *avctx){
ff_videodsp_init(&s->vdsp, 8);
ff_dwt_init(&s->dwt);
- ff_h264qpel_init(&s->h264qpel, 8);
+
+ init_qpel(s);
#define mcfh(dx,dy)\
s->hdsp.put_pixels_tab [0][dy/4+dx/8]=\
diff --git a/libavcodec/snow.h b/libavcodec/snow.h
index 9b19e70bd5..83dc6c1256 100644
--- a/libavcodec/snow.h
+++ b/libavcodec/snow.h
@@ -116,7 +116,11 @@ typedef struct SnowContext{
RangeCoder c;
HpelDSPContext hdsp;
VideoDSPContext vdsp;
- H264QpelContext h264qpel;
+ union {
+ /// everything except size 2 are from H.264
+ qpel_mc_func put_snow_qpel_pixels_tab[4][16];
+ H264QpelContext h264qpel;
+ };
SnowDWTContext dwt;
AVFrame *input_picture; ///< new_picture with the internal linesizes
AVFrame *current_picture;
diff --git a/tests/checkasm/h264qpel.c b/tests/checkasm/h264qpel.c
index 7387c2510a..6f4a021faf 100644
--- a/tests/checkasm/h264qpel.c
+++ b/tests/checkasm/h264qpel.c
@@ -64,7 +64,7 @@ void checkasm_check_h264qpel(void)
for (bit_depth = 8; bit_depth <= 10; bit_depth++) {
ff_h264qpel_init(&h, bit_depth);
- for (i = 0; i < (op || bit_depth != 8 ? 3 : 4); i++) {
+ for (i = 0; i < 3; i++) {
int size = 16 >> i;
for (j = 0; j < 16; j++)
if (check_func(tab[i][j], "%s_h264_qpel_%d_mc%d%d_%d", op_name, size, j & 3, j >> 2, bit_depth)) {
--
2.49.1
From 61a5e967e9a90e8ab6a78231536735827a6939b1 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Sat, 4 Oct 2025 09:19:23 +0200
Subject: [PATCH 3/8] avcodec/x86/h264_qpel_8bit: Don't duplicate
qpel4_hv_lowpass_v_mmxext
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/h264_qpel.c | 5 +++--
libavcodec/x86/h264_qpel_8bit.asm | 5 +++--
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/libavcodec/x86/h264_qpel.c b/libavcodec/x86/h264_qpel.c
index 636be54530..45e0878e57 100644
--- a/libavcodec/x86/h264_qpel.c
+++ b/libavcodec/x86/h264_qpel.c
@@ -63,7 +63,6 @@ void ff_ ## OPNAME ## _h264_qpel16_h_lowpass_l2_sse2(uint8_t *dst, const uint8_t
void ff_ ## OPNAME ## _h264_qpel8_h_lowpass_l2_ssse3(uint8_t *dst, const uint8_t *src, const uint8_t *src2, ptrdiff_t dstStride, ptrdiff_t src2Stride);\
void ff_ ## OPNAME ## _h264_qpel4_v_lowpass_mmxext(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride);\
void ff_ ## OPNAME ## _h264_qpel8or16_v_lowpass_sse2(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride, int h);\
-void ff_ ## OPNAME ## _h264_qpel4_hv_lowpass_v_mmxext(const uint8_t *src, int16_t *tmp, ptrdiff_t srcStride);\
void ff_ ## OPNAME ## _h264_qpel4_hv_lowpass_h_mmxext(int16_t *tmp, uint8_t *dst, ptrdiff_t dstStride);\
void ff_ ## OPNAME ## _h264_qpel8or16_hv1_lowpass_op_sse2(const uint8_t *src, int16_t *tmp, ptrdiff_t srcStride, int size);\
void ff_ ## OPNAME ## _h264_qpel8or16_hv2_lowpass_op_mmxext(uint8_t *dst, int16_t *tmp, ptrdiff_t dstStride, int h);\
@@ -73,6 +72,8 @@ void ff_ ## OPNAME ## _pixels4_l2_shift5_mmxext(uint8_t *dst, const int16_t *src
void ff_ ## OPNAME ## _pixels8_l2_shift5_sse2(uint8_t *dst, const int16_t *src16, const uint8_t *src8, ptrdiff_t dstStride);\
void ff_ ## OPNAME ## _pixels16_l2_shift5_sse2(uint8_t *dst, const int16_t *src16, const uint8_t *src8, ptrdiff_t dstStride);\
+void ff_put_h264_qpel4_hv_lowpass_v_mmxext(const uint8_t *src, int16_t *tmp, ptrdiff_t srcStride);
+
DEF_QPEL(avg)
DEF_QPEL(put)
@@ -82,7 +83,7 @@ static av_always_inline void OPNAME ## h264_qpel4_hv_lowpass_ ## MMX(uint8_t *ds
int w=3;\
src -= 2*srcStride+2;\
while(w--){\
- ff_ ## OPNAME ## h264_qpel4_hv_lowpass_v_mmxext(src, tmp, srcStride);\
+ ff_put_h264_qpel4_hv_lowpass_v_mmxext(src, tmp, srcStride);\
tmp += 4;\
src += 4;\
}\
diff --git a/libavcodec/x86/h264_qpel_8bit.asm b/libavcodec/x86/h264_qpel_8bit.asm
index bbf591664a..a610a831db 100644
--- a/libavcodec/x86/h264_qpel_8bit.asm
+++ b/libavcodec/x86/h264_qpel_8bit.asm
@@ -502,8 +502,8 @@ QPEL8OR16_V_LOWPASS_OP avg
SWAP 0, 1, 2, 3, 4, 5
%endmacro
-%macro QPEL4_HV1_LOWPASS_OP 1
-cglobal %1_h264_qpel4_hv_lowpass_v, 3,3 ; src, tmp, srcStride
+INIT_MMX mmxext
+cglobal put_h264_qpel4_hv_lowpass_v, 3,3 ; src, tmp, srcStride
pxor m7, m7
movh m0, [r0]
movh m1, [r0+r2]
@@ -524,6 +524,7 @@ cglobal %1_h264_qpel4_hv_lowpass_v, 3,3 ; src, tmp, srcStride
FILT_HV 3*24
RET
+%macro QPEL4_HV1_LOWPASS_OP 1
cglobal %1_h264_qpel4_hv_lowpass_h, 3,4 ; tmp, dst, dstStride
mov r3d, 4
.loop:
--
2.49.1
From 83a0d0ace9846bba82878c8993088d21f457a168 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Sat, 4 Oct 2025 10:15:09 +0200
Subject: [PATCH 4/8] avcodec/h264_qpel: Move loop into
qpel4_hv_lowpass_v_mmxext()
Every caller calls it three times in a loop, with slightly
modified arguments. So it makes sense to move the loop
into the callee.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/h264_qpel.c | 8 +-------
libavcodec/x86/h264_qpel_8bit.asm | 10 +++++++++-
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/libavcodec/x86/h264_qpel.c b/libavcodec/x86/h264_qpel.c
index 45e0878e57..af031fe2e9 100644
--- a/libavcodec/x86/h264_qpel.c
+++ b/libavcodec/x86/h264_qpel.c
@@ -80,14 +80,8 @@ DEF_QPEL(put)
#define QPEL_H264(OPNAME, OP, MMX)\
static av_always_inline void OPNAME ## h264_qpel4_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride)\
{\
- int w=3;\
src -= 2*srcStride+2;\
- while(w--){\
- ff_put_h264_qpel4_hv_lowpass_v_mmxext(src, tmp, srcStride);\
- tmp += 4;\
- src += 4;\
- }\
- tmp -= 3*4;\
+ ff_put_h264_qpel4_hv_lowpass_v_mmxext(src, tmp, srcStride);\
ff_ ## OPNAME ## h264_qpel4_hv_lowpass_h_mmxext(tmp, dst, dstStride);\
}\
\
diff --git a/libavcodec/x86/h264_qpel_8bit.asm b/libavcodec/x86/h264_qpel_8bit.asm
index a610a831db..64c91ba63a 100644
--- a/libavcodec/x86/h264_qpel_8bit.asm
+++ b/libavcodec/x86/h264_qpel_8bit.asm
@@ -503,8 +503,11 @@ QPEL8OR16_V_LOWPASS_OP avg
%endmacro
INIT_MMX mmxext
-cglobal put_h264_qpel4_hv_lowpass_v, 3,3 ; src, tmp, srcStride
+cglobal put_h264_qpel4_hv_lowpass_v, 3,5 ; src, tmp, srcStride
+ mov r4d, 3
+ mov r3, r0
pxor m7, m7
+.loop:
movh m0, [r0]
movh m1, [r0+r2]
lea r0, [r0+2*r2]
@@ -522,6 +525,11 @@ cglobal put_h264_qpel4_hv_lowpass_v, 3,3 ; src, tmp, srcStride
FILT_HV 1*24
FILT_HV 2*24
FILT_HV 3*24
+ add r3, 4
+ add r1, 8
+ mov r0, r3
+ dec r4d
+ jnz .loop
RET
%macro QPEL4_HV1_LOWPASS_OP 1
--
2.49.1
From 0c81a90999459b12f31cc7e0463c2a5769cbf047 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Sat, 4 Oct 2025 10:21:38 +0200
Subject: [PATCH 5/8] avcodec/x86/h264_qpel_8bit: Avoid doing unnecessary work
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/h264_qpel_8bit.asm | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/libavcodec/x86/h264_qpel_8bit.asm b/libavcodec/x86/h264_qpel_8bit.asm
index 64c91ba63a..c66a9bda40 100644
--- a/libavcodec/x86/h264_qpel_8bit.asm
+++ b/libavcodec/x86/h264_qpel_8bit.asm
@@ -387,8 +387,12 @@ QPEL8_H_LOWPASS_L2_OP_XMM avg
; All functions that call this are required to have function arguments of
; dst, src, dstStride, srcStride
-%macro FILT_V 1
+%macro FILT_V 1-2
+%ifnidn %2, last
mova m6, m2
+%else
+ SWAP 6, 2
+%endif
movh m5, [r1]
paddw m6, m3
psllw m6, 2
@@ -403,7 +407,9 @@ QPEL8_H_LOWPASS_L2_OP_XMM avg
psraw m6, 5
packuswb m6, m6
op_%1h m6, [r0], m0 ; 1
+%ifnidn %2, last
add r0, r2
+%endif
SWAP 0, 1, 2, 3, 4, 5
%endmacro
@@ -428,7 +434,7 @@ cglobal %1_h264_qpel4_v_lowpass, 4,4 ; dst, src, dstStride, srcStride
FILT_V %1
FILT_V %1
FILT_V %1
- FILT_V %1
+ FILT_V %1, last
RET
%endmacro
@@ -473,7 +479,7 @@ cglobal %1_h264_qpel8or16_v_lowpass, 5,5,8 ; dst, src, dstStride, srcStride, h
FILT_V %1
FILT_V %1
FILT_V %1
- FILT_V %1
+ FILT_V %1, last
.end:
RET
%endmacro
@@ -485,8 +491,12 @@ QPEL8OR16_V_LOWPASS_OP avg
; All functions that use this are required to have args:
; src, tmp, srcSize
-%macro FILT_HV 1 ; offset
+%macro FILT_HV 1-2 ; offset, last
+%ifnidn %2, last
mova m6, m2
+%else
+ SWAP 2, 6
+%endif
movh m5, [r0]
paddw m6, m3
psllw m6, 2
@@ -496,7 +506,9 @@ QPEL8OR16_V_LOWPASS_OP avg
punpcklbw m5, m7
pmullw m6, [pw_5]
paddw m0, m5
+%ifnidn %2, last
add r0, r2
+%endif
paddw m6, m0
mova [r1+%1], m6
SWAP 0, 1, 2, 3, 4, 5
@@ -524,7 +536,7 @@ cglobal put_h264_qpel4_hv_lowpass_v, 3,5 ; src, tmp, srcStride
FILT_HV 0*24
FILT_HV 1*24
FILT_HV 2*24
- FILT_HV 3*24
+ FILT_HV 3*24, last
add r3, 4
add r1, 8
mov r0, r3
@@ -595,7 +607,7 @@ cglobal put_h264_qpel8or16_hv1_lowpass_op, 4,4,8 ; src, tmp, srcStride, size
FILT_HV 12*48
FILT_HV 13*48
FILT_HV 14*48
- FILT_HV 15*48
+ FILT_HV 15*48, last
.end:
RET
--
2.49.1
From 3ad8a75f9b5acd47f644ecf199cd33d324d9cf2b Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Sat, 4 Oct 2025 12:38:32 +0200
Subject: [PATCH 6/8] avcodec/x86/h264_qpel: Port
qpel8or16_hv2_lowpass_op_mmxext to SSE2
This means that only blocksize 4 still uses mmx(ext).
Old benchmarks:
avg_h264_qpel_8_mc12_8_c: 428.4 ( 1.00x)
avg_h264_qpel_8_mc12_8_sse2: 74.3 ( 5.77x)
avg_h264_qpel_8_mc12_8_ssse3: 69.3 ( 6.18x)
avg_h264_qpel_8_mc21_8_c: 401.4 ( 1.00x)
avg_h264_qpel_8_mc21_8_sse2: 97.8 ( 4.10x)
avg_h264_qpel_8_mc21_8_ssse3: 93.7 ( 4.28x)
avg_h264_qpel_8_mc22_8_c: 281.8 ( 1.00x)
avg_h264_qpel_8_mc22_8_sse2: 66.7 ( 4.23x)
avg_h264_qpel_8_mc22_8_ssse3: 62.6 ( 4.50x)
avg_h264_qpel_8_mc23_8_c: 397.2 ( 1.00x)
avg_h264_qpel_8_mc23_8_sse2: 97.9 ( 4.06x)
avg_h264_qpel_8_mc23_8_ssse3: 93.7 ( 4.24x)
avg_h264_qpel_8_mc32_8_c: 432.4 ( 1.00x)
avg_h264_qpel_8_mc32_8_sse2: 73.9 ( 5.85x)
avg_h264_qpel_8_mc32_8_ssse3: 69.5 ( 6.22x)
avg_h264_qpel_16_mc12_8_c: 1756.4 ( 1.00x)
avg_h264_qpel_16_mc12_8_sse2: 240.0 ( 7.32x)
avg_h264_qpel_16_mc12_8_ssse3: 204.5 ( 8.59x)
avg_h264_qpel_16_mc21_8_c: 1635.3 ( 1.00x)
avg_h264_qpel_16_mc21_8_sse2: 321.2 ( 5.09x)
avg_h264_qpel_16_mc21_8_ssse3: 288.5 ( 5.67x)
avg_h264_qpel_16_mc22_8_c: 1130.8 ( 1.00x)
avg_h264_qpel_16_mc22_8_sse2: 219.4 ( 5.15x)
avg_h264_qpel_16_mc22_8_ssse3: 182.2 ( 6.21x)
avg_h264_qpel_16_mc23_8_c: 1622.5 ( 1.00x)
avg_h264_qpel_16_mc23_8_sse2: 321.3 ( 5.05x)
avg_h264_qpel_16_mc23_8_ssse3: 289.5 ( 5.60x)
avg_h264_qpel_16_mc32_8_c: 1762.5 ( 1.00x)
avg_h264_qpel_16_mc32_8_sse2: 236.1 ( 7.46x)
avg_h264_qpel_16_mc32_8_ssse3: 205.2 ( 8.59x)
put_h264_qpel_8_mc12_8_c: 427.2 ( 1.00x)
put_h264_qpel_8_mc12_8_sse2: 72.1 ( 5.93x)
put_h264_qpel_8_mc12_8_ssse3: 67.0 ( 6.38x)
put_h264_qpel_8_mc21_8_c: 402.9 ( 1.00x)
put_h264_qpel_8_mc21_8_sse2: 95.9 ( 4.20x)
put_h264_qpel_8_mc21_8_ssse3: 91.9 ( 4.38x)
put_h264_qpel_8_mc22_8_c: 235.0 ( 1.00x)
put_h264_qpel_8_mc22_8_sse2: 64.6 ( 3.64x)
put_h264_qpel_8_mc22_8_ssse3: 60.0 ( 3.92x)
put_h264_qpel_8_mc23_8_c: 403.6 ( 1.00x)
put_h264_qpel_8_mc23_8_sse2: 95.9 ( 4.21x)
put_h264_qpel_8_mc23_8_ssse3: 91.7 ( 4.40x)
put_h264_qpel_8_mc32_8_c: 430.7 ( 1.00x)
put_h264_qpel_8_mc32_8_sse2: 72.1 ( 5.97x)
put_h264_qpel_8_mc32_8_ssse3: 67.0 ( 6.43x)
put_h264_qpel_16_mc12_8_c: 1724.2 ( 1.00x)
put_h264_qpel_16_mc12_8_sse2: 230.7 ( 7.47x)
put_h264_qpel_16_mc12_8_ssse3: 199.8 ( 8.63x)
put_h264_qpel_16_mc21_8_c: 1613.3 ( 1.00x)
put_h264_qpel_16_mc21_8_sse2: 327.5 ( 4.93x)
put_h264_qpel_16_mc21_8_ssse3: 297.2 ( 5.43x)
put_h264_qpel_16_mc22_8_c: 959.2 ( 1.00x)
put_h264_qpel_16_mc22_8_sse2: 211.9 ( 4.53x)
put_h264_qpel_16_mc22_8_ssse3: 186.1 ( 5.15x)
put_h264_qpel_16_mc23_8_c: 1619.0 ( 1.00x)
put_h264_qpel_16_mc23_8_sse2: 319.7 ( 5.06x)
put_h264_qpel_16_mc23_8_ssse3: 299.2 ( 5.41x)
put_h264_qpel_16_mc32_8_c: 1741.7 ( 1.00x)
put_h264_qpel_16_mc32_8_sse2: 230.9 ( 7.54x)
put_h264_qpel_16_mc32_8_ssse3: 199.4 ( 8.74x)
New benchmarks:
avg_h264_qpel_8_mc12_8_c: 427.2 ( 1.00x)
avg_h264_qpel_8_mc12_8_sse2: 63.9 ( 6.69x)
avg_h264_qpel_8_mc12_8_ssse3: 69.2 ( 6.18x)
avg_h264_qpel_8_mc21_8_c: 399.2 ( 1.00x)
avg_h264_qpel_8_mc21_8_sse2: 87.7 ( 4.55x)
avg_h264_qpel_8_mc21_8_ssse3: 93.9 ( 4.25x)
avg_h264_qpel_8_mc22_8_c: 285.7 ( 1.00x)
avg_h264_qpel_8_mc22_8_sse2: 56.4 ( 5.07x)
avg_h264_qpel_8_mc22_8_ssse3: 62.6 ( 4.56x)
avg_h264_qpel_8_mc23_8_c: 398.6 ( 1.00x)
avg_h264_qpel_8_mc23_8_sse2: 87.6 ( 4.55x)
avg_h264_qpel_8_mc23_8_ssse3: 93.8 ( 4.25x)
avg_h264_qpel_8_mc32_8_c: 425.8 ( 1.00x)
avg_h264_qpel_8_mc32_8_sse2: 63.8 ( 6.67x)
avg_h264_qpel_8_mc32_8_ssse3: 69.0 ( 6.17x)
avg_h264_qpel_16_mc12_8_c: 1748.2 ( 1.00x)
avg_h264_qpel_16_mc12_8_sse2: 198.5 ( 8.81x)
avg_h264_qpel_16_mc12_8_ssse3: 203.2 ( 8.60x)
avg_h264_qpel_16_mc21_8_c: 1638.1 ( 1.00x)
avg_h264_qpel_16_mc21_8_sse2: 277.4 ( 5.91x)
avg_h264_qpel_16_mc21_8_ssse3: 291.1 ( 5.63x)
avg_h264_qpel_16_mc22_8_c: 1140.7 ( 1.00x)
avg_h264_qpel_16_mc22_8_sse2: 180.3 ( 6.33x)
avg_h264_qpel_16_mc22_8_ssse3: 181.9 ( 6.27x)
avg_h264_qpel_16_mc23_8_c: 1629.9 ( 1.00x)
avg_h264_qpel_16_mc23_8_sse2: 278.0 ( 5.86x)
avg_h264_qpel_16_mc23_8_ssse3: 291.0 ( 5.60x)
avg_h264_qpel_16_mc32_8_c: 1752.1 ( 1.00x)
avg_h264_qpel_16_mc32_8_sse2: 193.7 ( 9.05x)
avg_h264_qpel_16_mc32_8_ssse3: 203.4 ( 8.61x)
put_h264_qpel_8_mc12_8_c: 421.8 ( 1.00x)
put_h264_qpel_8_mc12_8_sse2: 61.7 ( 6.83x)
put_h264_qpel_8_mc12_8_ssse3: 67.2 ( 6.28x)
put_h264_qpel_8_mc21_8_c: 396.8 ( 1.00x)
put_h264_qpel_8_mc21_8_sse2: 85.4 ( 4.65x)
put_h264_qpel_8_mc21_8_ssse3: 91.6 ( 4.33x)
put_h264_qpel_8_mc22_8_c: 234.1 ( 1.00x)
put_h264_qpel_8_mc22_8_sse2: 54.4 ( 4.30x)
put_h264_qpel_8_mc22_8_ssse3: 60.2 ( 3.89x)
put_h264_qpel_8_mc23_8_c: 399.2 ( 1.00x)
put_h264_qpel_8_mc23_8_sse2: 85.5 ( 4.67x)
put_h264_qpel_8_mc23_8_ssse3: 91.8 ( 4.35x)
put_h264_qpel_8_mc32_8_c: 422.2 ( 1.00x)
put_h264_qpel_8_mc32_8_sse2: 61.8 ( 6.83x)
put_h264_qpel_8_mc32_8_ssse3: 67.0 ( 6.30x)
put_h264_qpel_16_mc12_8_c: 1720.3 ( 1.00x)
put_h264_qpel_16_mc12_8_sse2: 189.9 ( 9.06x)
put_h264_qpel_16_mc12_8_ssse3: 199.9 ( 8.61x)
put_h264_qpel_16_mc21_8_c: 1624.5 ( 1.00x)
put_h264_qpel_16_mc21_8_sse2: 285.4 ( 5.69x)
put_h264_qpel_16_mc21_8_ssse3: 296.4 ( 5.48x)
put_h264_qpel_16_mc22_8_c: 963.9 ( 1.00x)
put_h264_qpel_16_mc22_8_sse2: 170.1 ( 5.67x)
put_h264_qpel_16_mc22_8_ssse3: 186.4 ( 5.17x)
put_h264_qpel_16_mc23_8_c: 1613.5 ( 1.00x)
put_h264_qpel_16_mc23_8_sse2: 274.6 ( 5.88x)
put_h264_qpel_16_mc23_8_ssse3: 300.4 ( 5.37x)
put_h264_qpel_16_mc32_8_c: 1735.9 ( 1.00x)
put_h264_qpel_16_mc32_8_sse2: 189.6 ( 9.15x)
put_h264_qpel_16_mc32_8_ssse3: 199.5 ( 8.70x)
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/h264_qpel.c | 4 ++--
libavcodec/x86/h264_qpel_8bit.asm | 34 +++++++++++--------------------
2 files changed, 14 insertions(+), 24 deletions(-)
diff --git a/libavcodec/x86/h264_qpel.c b/libavcodec/x86/h264_qpel.c
index af031fe2e9..f4082e2242 100644
--- a/libavcodec/x86/h264_qpel.c
+++ b/libavcodec/x86/h264_qpel.c
@@ -65,7 +65,7 @@ void ff_ ## OPNAME ## _h264_qpel4_v_lowpass_mmxext(uint8_t *dst, const uint8_t *
void ff_ ## OPNAME ## _h264_qpel8or16_v_lowpass_sse2(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride, int h);\
void ff_ ## OPNAME ## _h264_qpel4_hv_lowpass_h_mmxext(int16_t *tmp, uint8_t *dst, ptrdiff_t dstStride);\
void ff_ ## OPNAME ## _h264_qpel8or16_hv1_lowpass_op_sse2(const uint8_t *src, int16_t *tmp, ptrdiff_t srcStride, int size);\
-void ff_ ## OPNAME ## _h264_qpel8or16_hv2_lowpass_op_mmxext(uint8_t *dst, int16_t *tmp, ptrdiff_t dstStride, int h);\
+void ff_ ## OPNAME ## _h264_qpel8or16_hv2_lowpass_op_sse2(uint8_t *dst, int16_t *tmp, ptrdiff_t dstStride, int h);\
void ff_ ## OPNAME ## _h264_qpel8_hv2_lowpass_ssse3(uint8_t *dst, int16_t *tmp, ptrdiff_t dstStride);\
void ff_ ## OPNAME ## _h264_qpel16_hv2_lowpass_ssse3(uint8_t *dst, int16_t *tmp, ptrdiff_t dstStride);\
void ff_ ## OPNAME ## _pixels4_l2_shift5_mmxext(uint8_t *dst, const int16_t *src16, const uint8_t *src8, ptrdiff_t dstStride);\
@@ -89,7 +89,7 @@ static av_always_inline void ff_ ## OPNAME ## h264_qpel8or16_hv2_lowpass_ ## MMX
{\
int w = size>>4;\
do{\
- ff_ ## OPNAME ## h264_qpel8or16_hv2_lowpass_op_mmxext(dst, tmp, dstStride, size);\
+ ff_ ## OPNAME ## h264_qpel8or16_hv2_lowpass_op_sse2(dst, tmp, dstStride, size);\
tmp += 8;\
dst += 8;\
}while(w--);\
diff --git a/libavcodec/x86/h264_qpel_8bit.asm b/libavcodec/x86/h264_qpel_8bit.asm
index c66a9bda40..39a387b4bb 100644
--- a/libavcodec/x86/h264_qpel_8bit.asm
+++ b/libavcodec/x86/h264_qpel_8bit.asm
@@ -613,36 +613,26 @@ cglobal put_h264_qpel8or16_hv1_lowpass_op, 4,4,8 ; src, tmp, srcStride, size
%macro QPEL8OR16_HV2_LOWPASS_OP 1
-cglobal %1_h264_qpel8or16_hv2_lowpass_op, 4,4 ; dst, tmp, dstStride, h
+cglobal %1_h264_qpel8or16_hv2_lowpass_op, 4,4,6 ; dst, tmp, dstStride, h
.loop:
mova m0, [r1]
- mova m3, [r1+8]
- mova m1, [r1+2]
- mova m4, [r1+10]
- paddw m0, m4
- paddw m1, m3
- paddw m3, [r1+18]
- paddw m4, [r1+16]
- mova m2, [r1+4]
- mova m5, [r1+12]
- paddw m2, [r1+6]
- paddw m5, [r1+14]
+ movu m1, [r1+2]
+ movu m3, [r1+10]
+ movu m4, [r1+8]
+ movu m2, [r1+4]
+ movu m5, [r1+6]
+ paddw m0, m3
+ paddw m1, m4
psubw m0, m1
- psubw m3, m4
psraw m0, 2
- psraw m3, 2
+ paddw m2, m5
psubw m0, m1
- psubw m3, m4
paddsw m0, m2
- paddsw m3, m5
psraw m0, 2
- psraw m3, 2
paddw m0, m2
- paddw m3, m5
psraw m0, 6
- psraw m3, 6
- packuswb m0, m3
- op_%1 m0, [r0], m7
+ packuswb m0, m0
+ op_%1h m0, [r0], m5
add r1, 48
add r0, r2
dec r3d
@@ -650,7 +640,7 @@ cglobal %1_h264_qpel8or16_hv2_lowpass_op, 4,4 ; dst, tmp, dstStride, h
RET
%endmacro
-INIT_MMX mmxext
+INIT_XMM sse2
QPEL8OR16_HV2_LOWPASS_OP put
QPEL8OR16_HV2_LOWPASS_OP avg
--
2.49.1
From 65beb628def380385dc0c8af4b09c8ade2f2ac9f Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Sat, 4 Oct 2025 15:07:18 +0200
Subject: [PATCH 7/8] avcodec/x86/h264_qpel: Split hv2_lowpass_sse2 into size
8,16 funcs
This is beneficial size-wise: 384B of new asm functions are more
than outweighted by 416B savings from simpler calls here (for size 16,
the size 8 function had been called twice).
It also makes the code more readable, as it allowed to remove
several wrappers in h264_qpel.c.
It is also beneficial performance-wise. Old benchmarks:
avg_h264_qpel_16_mc12_8_c: 1757.7 ( 1.00x)
avg_h264_qpel_16_mc12_8_sse2: 197.7 ( 8.89x)
avg_h264_qpel_16_mc12_8_ssse3: 204.6 ( 8.59x)
avg_h264_qpel_16_mc21_8_c: 1631.6 ( 1.00x)
avg_h264_qpel_16_mc21_8_sse2: 276.4 ( 5.90x)
avg_h264_qpel_16_mc21_8_ssse3: 290.7 ( 5.61x)
avg_h264_qpel_16_mc22_8_c: 1122.7 ( 1.00x)
avg_h264_qpel_16_mc22_8_sse2: 179.5 ( 6.25x)
avg_h264_qpel_16_mc22_8_ssse3: 181.8 ( 6.17x)
avg_h264_qpel_16_mc23_8_c: 1626.7 ( 1.00x)
avg_h264_qpel_16_mc23_8_sse2: 276.8 ( 5.88x)
avg_h264_qpel_16_mc23_8_ssse3: 290.9 ( 5.59x)
avg_h264_qpel_16_mc32_8_c: 1754.1 ( 1.00x)
avg_h264_qpel_16_mc32_8_sse2: 193.8 ( 9.05x)
avg_h264_qpel_16_mc32_8_ssse3: 203.6 ( 8.62x)
put_h264_qpel_16_mc12_8_c: 1733.6 ( 1.00x)
put_h264_qpel_16_mc12_8_sse2: 189.6 ( 9.14x)
put_h264_qpel_16_mc12_8_ssse3: 199.6 ( 8.69x)
put_h264_qpel_16_mc21_8_c: 1616.0 ( 1.00x)
put_h264_qpel_16_mc21_8_sse2: 284.3 ( 5.69x)
put_h264_qpel_16_mc21_8_ssse3: 296.5 ( 5.45x)
put_h264_qpel_16_mc22_8_c: 963.7 ( 1.00x)
put_h264_qpel_16_mc22_8_sse2: 169.9 ( 5.67x)
put_h264_qpel_16_mc22_8_ssse3: 186.1 ( 5.18x)
put_h264_qpel_16_mc23_8_c: 1607.2 ( 1.00x)
put_h264_qpel_16_mc23_8_sse2: 275.0 ( 5.84x)
put_h264_qpel_16_mc23_8_ssse3: 297.8 ( 5.40x)
put_h264_qpel_16_mc32_8_c: 1734.7 ( 1.00x)
put_h264_qpel_16_mc32_8_sse2: 189.4 ( 9.16x)
put_h264_qpel_16_mc32_8_ssse3: 199.4 ( 8.70x)
New benchmarks:
avg_h264_qpel_16_mc12_8_c: 1743.7 ( 1.00x)
avg_h264_qpel_16_mc12_8_sse2: 189.7 ( 9.19x)
avg_h264_qpel_16_mc12_8_ssse3: 204.4 ( 8.53x)
avg_h264_qpel_16_mc21_8_c: 1637.7 ( 1.00x)
avg_h264_qpel_16_mc21_8_sse2: 267.7 ( 6.12x)
avg_h264_qpel_16_mc21_8_ssse3: 291.5 ( 5.62x)
avg_h264_qpel_16_mc22_8_c: 1150.3 ( 1.00x)
avg_h264_qpel_16_mc22_8_sse2: 164.6 ( 6.99x)
avg_h264_qpel_16_mc22_8_ssse3: 182.1 ( 6.32x)
avg_h264_qpel_16_mc23_8_c: 1635.3 ( 1.00x)
avg_h264_qpel_16_mc23_8_sse2: 268.5 ( 6.09x)
avg_h264_qpel_16_mc23_8_ssse3: 298.5 ( 5.48x)
avg_h264_qpel_16_mc32_8_c: 1740.6 ( 1.00x)
avg_h264_qpel_16_mc32_8_sse2: 182.6 ( 9.53x)
avg_h264_qpel_16_mc32_8_ssse3: 201.9 ( 8.62x)
put_h264_qpel_16_mc12_8_c: 1727.4 ( 1.00x)
put_h264_qpel_16_mc12_8_sse2: 188.1 ( 9.18x)
put_h264_qpel_16_mc12_8_ssse3: 199.6 ( 8.65x)
put_h264_qpel_16_mc21_8_c: 1623.5 ( 1.00x)
put_h264_qpel_16_mc21_8_sse2: 265.9 ( 6.11x)
put_h264_qpel_16_mc21_8_ssse3: 299.4 ( 5.42x)
put_h264_qpel_16_mc22_8_c: 954.0 ( 1.00x)
put_h264_qpel_16_mc22_8_sse2: 161.8 ( 5.89x)
put_h264_qpel_16_mc22_8_ssse3: 180.4 ( 5.29x)
put_h264_qpel_16_mc23_8_c: 1611.2 ( 1.00x)
put_h264_qpel_16_mc23_8_sse2: 265.8 ( 6.06x)
put_h264_qpel_16_mc23_8_ssse3: 300.3 ( 5.37x)
put_h264_qpel_16_mc32_8_c: 1734.5 ( 1.00x)
put_h264_qpel_16_mc32_8_sse2: 180.0 ( 9.63x)
put_h264_qpel_16_mc32_8_ssse3: 199.7 ( 8.69x)
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/h264_qpel.c | 39 +++-----------------
libavcodec/x86/h264_qpel_8bit.asm | 61 ++++++++++++++++++++-----------
2 files changed, 45 insertions(+), 55 deletions(-)
diff --git a/libavcodec/x86/h264_qpel.c b/libavcodec/x86/h264_qpel.c
index f4082e2242..9b22c74286 100644
--- a/libavcodec/x86/h264_qpel.c
+++ b/libavcodec/x86/h264_qpel.c
@@ -65,7 +65,8 @@ void ff_ ## OPNAME ## _h264_qpel4_v_lowpass_mmxext(uint8_t *dst, const uint8_t *
void ff_ ## OPNAME ## _h264_qpel8or16_v_lowpass_sse2(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride, int h);\
void ff_ ## OPNAME ## _h264_qpel4_hv_lowpass_h_mmxext(int16_t *tmp, uint8_t *dst, ptrdiff_t dstStride);\
void ff_ ## OPNAME ## _h264_qpel8or16_hv1_lowpass_op_sse2(const uint8_t *src, int16_t *tmp, ptrdiff_t srcStride, int size);\
-void ff_ ## OPNAME ## _h264_qpel8or16_hv2_lowpass_op_sse2(uint8_t *dst, int16_t *tmp, ptrdiff_t dstStride, int h);\
+void ff_ ## OPNAME ## _h264_qpel8_hv2_lowpass_sse2(uint8_t *dst, int16_t *tmp, ptrdiff_t dstStride);\
+void ff_ ## OPNAME ## _h264_qpel16_hv2_lowpass_sse2(uint8_t *dst, int16_t *tmp, ptrdiff_t dstStride);\
void ff_ ## OPNAME ## _h264_qpel8_hv2_lowpass_ssse3(uint8_t *dst, int16_t *tmp, ptrdiff_t dstStride);\
void ff_ ## OPNAME ## _h264_qpel16_hv2_lowpass_ssse3(uint8_t *dst, int16_t *tmp, ptrdiff_t dstStride);\
void ff_ ## OPNAME ## _pixels4_l2_shift5_mmxext(uint8_t *dst, const int16_t *src16, const uint8_t *src8, ptrdiff_t dstStride);\
@@ -84,16 +85,6 @@ static av_always_inline void OPNAME ## h264_qpel4_hv_lowpass_ ## MMX(uint8_t *ds
ff_put_h264_qpel4_hv_lowpass_v_mmxext(src, tmp, srcStride);\
ff_ ## OPNAME ## h264_qpel4_hv_lowpass_h_mmxext(tmp, dst, dstStride);\
}\
-\
-static av_always_inline void ff_ ## OPNAME ## h264_qpel8or16_hv2_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, ptrdiff_t dstStride, int size)\
-{\
- int w = size>>4;\
- do{\
- ff_ ## OPNAME ## h264_qpel8or16_hv2_lowpass_op_sse2(dst, tmp, dstStride, size);\
- tmp += 8;\
- dst += 8;\
- }while(w--);\
-}\
#define QPEL_H264_H16(OPNAME, EXT) \
static av_always_inline void ff_ ## OPNAME ## h264_qpel16_h_lowpass_l2_ ## EXT(uint8_t *dst, const uint8_t *src, const uint8_t *src2, ptrdiff_t dstStride, ptrdiff_t src2Stride)\
@@ -156,40 +147,22 @@ static av_always_inline void put_h264_qpel8or16_hv1_lowpass_sse2(int16_t *tmp,
}
#define QPEL_H264_HV_XMM(OPNAME, OP, MMX)\
-static av_always_inline void OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride, int size)\
-{\
- put_h264_qpel8or16_hv1_lowpass_sse2(tmp, src, srcStride, size);\
- ff_ ## OPNAME ## h264_qpel8or16_hv2_lowpass_ ## MMX(dst, tmp, dstStride, size);\
-}\
static av_always_inline void OPNAME ## h264_qpel8_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride)\
{\
- OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(dst, tmp, src, dstStride, srcStride, 8);\
+ put_h264_qpel8or16_hv1_lowpass_sse2(tmp, src, srcStride, 8);\
+ ff_ ## OPNAME ## h264_qpel8_hv2_lowpass_ ## MMX(dst, tmp, dstStride);\
}\
static av_always_inline void OPNAME ## h264_qpel16_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride)\
{\
- OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(dst, tmp, src, dstStride, srcStride, 16);\
+ put_h264_qpel8or16_hv1_lowpass_sse2(tmp, src, srcStride, 16);\
+ ff_ ## OPNAME ## h264_qpel16_hv2_lowpass_ ## MMX(dst, tmp, dstStride);\
}\
-#define SSSE3_HV2_LOWPASS_WRAPPER(OPNAME) \
-static av_always_inline void \
-ff_ ## OPNAME ## _h264_qpel8or16_hv2_lowpass_ssse3(uint8_t *dst, int16_t *tmp, ptrdiff_t dstStride, int size) \
-{\
- if (size == 8)\
- ff_ ## OPNAME ## _h264_qpel8_hv2_lowpass_ssse3(dst, tmp, dstStride);\
- else\
- ff_ ## OPNAME ## _h264_qpel16_hv2_lowpass_ssse3(dst, tmp, dstStride);\
-}
-SSSE3_HV2_LOWPASS_WRAPPER(avg)
-SSSE3_HV2_LOWPASS_WRAPPER(put)
-
#define ff_put_h264_qpel8_v_lowpass_ssse3 ff_put_h264_qpel8_v_lowpass_sse2
#define ff_avg_h264_qpel8_v_lowpass_ssse3 ff_avg_h264_qpel8_v_lowpass_sse2
#define ff_put_h264_qpel16_v_lowpass_ssse3 ff_put_h264_qpel16_v_lowpass_sse2
#define ff_avg_h264_qpel16_v_lowpass_ssse3 ff_avg_h264_qpel16_v_lowpass_sse2
-#define ff_put_h264_qpel8or16_hv2_lowpass_sse2 ff_put_h264_qpel8or16_hv2_lowpass_mmxext
-#define ff_avg_h264_qpel8or16_hv2_lowpass_sse2 ff_avg_h264_qpel8or16_hv2_lowpass_mmxext
-
#define ff_put_pixels4_l2_shift5_sse2 ff_put_pixels4_l2_shift5_mmxext
#define ff_avg_pixels4_l2_shift5_sse2 ff_avg_pixels4_l2_shift5_mmxext
diff --git a/libavcodec/x86/h264_qpel_8bit.asm b/libavcodec/x86/h264_qpel_8bit.asm
index 39a387b4bb..6e082819ac 100644
--- a/libavcodec/x86/h264_qpel_8bit.asm
+++ b/libavcodec/x86/h264_qpel_8bit.asm
@@ -611,28 +611,45 @@ cglobal put_h264_qpel8or16_hv1_lowpass_op, 4,4,8 ; src, tmp, srcStride, size
.end:
RET
-
-%macro QPEL8OR16_HV2_LOWPASS_OP 1
-cglobal %1_h264_qpel8or16_hv2_lowpass_op, 4,4,6 ; dst, tmp, dstStride, h
-.loop:
- mova m0, [r1]
- movu m1, [r1+2]
- movu m3, [r1+10]
- movu m4, [r1+8]
- movu m2, [r1+4]
- movu m5, [r1+6]
- paddw m0, m3
+%macro HV2_LOWPASS 2
+ mova %1, [r1+%2]
+ movu m1, [r1+2+%2]
+ movu m3, [r1+10+%2]
+ movu m4, [r1+8+%2]
+ movu m2, [r1+4+%2]
+ paddw %1, m3
+ movu m3, [r1+6+%2]
paddw m1, m4
- psubw m0, m1
- psraw m0, 2
- paddw m2, m5
- psubw m0, m1
- paddsw m0, m2
- psraw m0, 2
- paddw m0, m2
- psraw m0, 6
+ psubw %1, m1
+ psraw %1, 2
+ paddw m2, m3
+ psubw %1, m1
+ paddsw %1, m2
+ psraw %1, 2
+ paddw %1, m2
+ psraw %1, 6
+%endmacro
+
+%macro QPEL8AND16_HV2_LOWPASS_OP 1
+cglobal %1_h264_qpel8_hv2_lowpass, 3,4,6 ; dst, tmp, dstStride
+ mov r3d, 8
+.loop:
+ HV2_LOWPASS m0, 0
packuswb m0, m0
- op_%1h m0, [r0], m5
+ op_%1h m0, [r0], m3
+ add r1, 48
+ add r0, r2
+ dec r3d
+ jne .loop
+ RET
+
+cglobal %1_h264_qpel16_hv2_lowpass, 3,4,6 ; dst, tmp, dstStride
+ mov r3d, 16
+.loop:
+ HV2_LOWPASS m0, 0
+ HV2_LOWPASS m5, 16
+ packuswb m0, m5
+ op_%1 m0, [r0], m3
add r1, 48
add r0, r2
dec r3d
@@ -641,8 +658,8 @@ cglobal %1_h264_qpel8or16_hv2_lowpass_op, 4,4,6 ; dst, tmp, dstStride, h
%endmacro
INIT_XMM sse2
-QPEL8OR16_HV2_LOWPASS_OP put
-QPEL8OR16_HV2_LOWPASS_OP avg
+QPEL8AND16_HV2_LOWPASS_OP put
+QPEL8AND16_HV2_LOWPASS_OP avg
%macro QPEL8OR16_HV2_LOWPASS_OP_XMM 1
cglobal %1_h264_qpel8_hv2_lowpass, 3,4,6 ; dst, tmp, dstStride
--
2.49.1
From fcf92b4db9feeb2b626d171317d2609a7d7402b4 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Sat, 4 Oct 2025 15:45:36 +0200
Subject: [PATCH 8/8] avcodec/x86/h264_qpel: Simplify macros
1. Remove the OP parameter from the QPEL_H264* macros. These are
a remnant of inline assembly and were forgotten in
610e00b3594bf0f2a75713f20e9c4edf0d03a818.
2. Pass the instruction set extension for the shift5 function
explicitly in the macro instead of using magic #defines.
3. Likewise, avoid magic #defines for (8|16)_v_lowpass_ssse3.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/h264_qpel.c | 98 ++++++++++++++++++--------------------
1 file changed, 46 insertions(+), 52 deletions(-)
diff --git a/libavcodec/x86/h264_qpel.c b/libavcodec/x86/h264_qpel.c
index 9b22c74286..f7596329e2 100644
--- a/libavcodec/x86/h264_qpel.c
+++ b/libavcodec/x86/h264_qpel.c
@@ -78,7 +78,7 @@ void ff_put_h264_qpel4_hv_lowpass_v_mmxext(const uint8_t *src, int16_t *tmp, ptr
DEF_QPEL(avg)
DEF_QPEL(put)
-#define QPEL_H264(OPNAME, OP, MMX)\
+#define QPEL_H264(OPNAME, MMX)\
static av_always_inline void OPNAME ## h264_qpel4_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride)\
{\
src -= 2*srcStride+2;\
@@ -100,17 +100,17 @@ static av_always_inline void ff_ ## OPNAME ## h264_qpel16_h_lowpass_l2_ ## EXT(u
#if ARCH_X86_64
-#define QPEL_H264_H16_XMM(OPNAME, OP, MMX)\
+#define QPEL_H264_H16_XMM(OPNAME, MMX)\
void ff_avg_h264_qpel16_h_lowpass_l2_ssse3(uint8_t *dst, const uint8_t *src, const uint8_t *src2, ptrdiff_t dstStride, ptrdiff_t src2Stride);
void ff_put_h264_qpel16_h_lowpass_l2_ssse3(uint8_t *dst, const uint8_t *src, const uint8_t *src2, ptrdiff_t dstStride, ptrdiff_t src2Stride);
#else // ARCH_X86_64
-#define QPEL_H264_H16_XMM(OPNAME, OP, EXT) QPEL_H264_H16(OPNAME, EXT)
+#define QPEL_H264_H16_XMM(OPNAME, EXT) QPEL_H264_H16(OPNAME, EXT)
#endif // ARCH_X86_64
-#define QPEL_H264_H_XMM(OPNAME, OP, MMX)\
-QPEL_H264_H16_XMM(OPNAME, OP, MMX)\
+#define QPEL_H264_H_XMM(OPNAME, MMX)\
+QPEL_H264_H16_XMM(OPNAME, MMX)\
static av_always_inline void ff_ ## OPNAME ## h264_qpel16_h_lowpass_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride)\
{\
ff_ ## OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst , src , dstStride, srcStride);\
@@ -121,15 +121,15 @@ static av_always_inline void ff_ ## OPNAME ## h264_qpel16_h_lowpass_ ## MMX(uint
ff_ ## OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride);\
}\
-#define QPEL_H264_V_XMM(OPNAME, OP, MMX)\
-static av_always_inline void ff_ ## OPNAME ## h264_qpel8_v_lowpass_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride)\
+#define QPEL_H264_V_XMM(OPNAME, XMM, XMM2)\
+static av_always_inline void ff_ ## OPNAME ## h264_qpel8_v_lowpass_ ## XMM(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride)\
{\
- ff_ ## OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst , src , dstStride, srcStride, 8);\
+ ff_ ## OPNAME ## h264_qpel8or16_v_lowpass_ ## XMM2(dst , src , dstStride, srcStride, 8);\
}\
-static av_always_inline void ff_ ## OPNAME ## h264_qpel16_v_lowpass_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride)\
+static av_always_inline void ff_ ## OPNAME ## h264_qpel16_v_lowpass_ ## XMM(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride)\
{\
- ff_ ## OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst , src , dstStride, srcStride, 16);\
- ff_ ## OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride, 16);\
+ ff_ ## OPNAME ## h264_qpel8or16_v_lowpass_ ## XMM2(dst , src , dstStride, srcStride, 16);\
+ ff_ ## OPNAME ## h264_qpel8or16_v_lowpass_ ## XMM2(dst+8, src+8, dstStride, srcStride, 16);\
}
static av_always_inline void put_h264_qpel8or16_hv1_lowpass_sse2(int16_t *tmp,
@@ -146,7 +146,7 @@ static av_always_inline void put_h264_qpel8or16_hv1_lowpass_sse2(int16_t *tmp,
}
}
-#define QPEL_H264_HV_XMM(OPNAME, OP, MMX)\
+#define QPEL_H264_HV_XMM(OPNAME, MMX)\
static av_always_inline void OPNAME ## h264_qpel8_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride)\
{\
put_h264_qpel8or16_hv1_lowpass_sse2(tmp, src, srcStride, 8);\
@@ -158,18 +158,10 @@ static av_always_inline void OPNAME ## h264_qpel16_hv_lowpass_ ## MMX(uint8_t *d
ff_ ## OPNAME ## h264_qpel16_hv2_lowpass_ ## MMX(dst, tmp, dstStride);\
}\
-#define ff_put_h264_qpel8_v_lowpass_ssse3 ff_put_h264_qpel8_v_lowpass_sse2
-#define ff_avg_h264_qpel8_v_lowpass_ssse3 ff_avg_h264_qpel8_v_lowpass_sse2
-#define ff_put_h264_qpel16_v_lowpass_ssse3 ff_put_h264_qpel16_v_lowpass_sse2
-#define ff_avg_h264_qpel16_v_lowpass_ssse3 ff_avg_h264_qpel16_v_lowpass_sse2
-
-#define ff_put_pixels4_l2_shift5_sse2 ff_put_pixels4_l2_shift5_mmxext
-#define ff_avg_pixels4_l2_shift5_sse2 ff_avg_pixels4_l2_shift5_mmxext
-
-#define H264_MC_V_H_HV(OPNAME, SIZE, MMX, ALIGN) \
-H264_MC_V(OPNAME, SIZE, MMX, ALIGN)\
-H264_MC_H(OPNAME, SIZE, MMX, ALIGN)\
-H264_MC_HV(OPNAME, SIZE, MMX, ALIGN)\
+#define H264_MC_V_H_HV(OPNAME, SIZE, MMX, ALIGN, SHIFT5_EXT) \
+H264_MC_V(OPNAME, SIZE, MMX, ALIGN, SHIFT5_EXT)\
+H264_MC_H(OPNAME, SIZE, MMX, ALIGN, SHIFT5_EXT)\
+H264_MC_HV(OPNAME, SIZE, MMX, ALIGN, SHIFT5_EXT)\
static void put_h264_qpel16_mc00_sse2 (uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
@@ -188,7 +180,7 @@ static void avg_h264_qpel8_mc00_mmxext(uint8_t *dst, const uint8_t *src,
ff_avg_pixels8_mmxext(dst, src, stride, 8);
}
-#define H264_MC_H(OPNAME, SIZE, MMX, ALIGN) \
+#define H264_MC_H(OPNAME, SIZE, MMX, ALIGN, UNUSED) \
static void OPNAME ## h264_qpel ## SIZE ## _mc10_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
{\
ff_ ## OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, src, stride, stride);\
@@ -204,7 +196,7 @@ static void OPNAME ## h264_qpel ## SIZE ## _mc30_ ## MMX(uint8_t *dst, const uin
ff_ ## OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, src+1, stride, stride);\
}\
-#define H264_MC_V(OPNAME, SIZE, MMX, ALIGN) \
+#define H264_MC_V(OPNAME, SIZE, MMX, ALIGN, UNUSED) \
static void OPNAME ## h264_qpel ## SIZE ## _mc01_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
{\
LOCAL_ALIGNED(ALIGN, uint8_t, temp, [SIZE*SIZE]);\
@@ -224,7 +216,7 @@ static void OPNAME ## h264_qpel ## SIZE ## _mc03_ ## MMX(uint8_t *dst, const uin
ff_ ## OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, src+stride, temp, stride, stride, SIZE);\
}\
-#define H264_MC_HV(OPNAME, SIZE, MMX, ALIGN) \
+#define H264_MC_HV(OPNAME, SIZE, MMX, ALIGN, SHIFT5_EXT) \
static void OPNAME ## h264_qpel ## SIZE ## _mc11_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
{\
LOCAL_ALIGNED(ALIGN, uint8_t, temp, [SIZE*SIZE]);\
@@ -286,7 +278,7 @@ static void OPNAME ## h264_qpel ## SIZE ## _mc12_ ## MMX(uint8_t *dst, const uin
int16_t * const halfV= (int16_t*)(temp + SIZE*SIZE);\
av_assert2(((uintptr_t)temp & 7) == 0);\
put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, halfV, src, SIZE, stride);\
- ff_ ## OPNAME ## pixels ## SIZE ## _l2_shift5_sse2(dst, halfV+2, halfHV, stride);\
+ ff_ ## OPNAME ## pixels ## SIZE ## _l2_shift5_ ## SHIFT5_EXT(dst, halfV+2, halfHV, stride);\
}\
\
static void OPNAME ## h264_qpel ## SIZE ## _mc32_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
@@ -296,35 +288,37 @@ static void OPNAME ## h264_qpel ## SIZE ## _mc32_ ## MMX(uint8_t *dst, const uin
int16_t * const halfV= (int16_t*)(temp + SIZE*SIZE);\
av_assert2(((uintptr_t)temp & 7) == 0);\
put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, halfV, src, SIZE, stride);\
- ff_ ## OPNAME ## pixels ## SIZE ## _l2_shift5_sse2(dst, halfV+3, halfHV, stride);\
+ ff_ ## OPNAME ## pixels ## SIZE ## _l2_shift5_ ## SHIFT5_EXT(dst, halfV+3, halfHV, stride);\
}\
-#define H264_MC(QPEL, SIZE, MMX, ALIGN)\
-QPEL(put_, SIZE, MMX, ALIGN) \
-QPEL(avg_, SIZE, MMX, ALIGN) \
+#define H264_MC(QPEL, SIZE, MMX, ALIGN, SHIFT5_EXT)\
+QPEL(put_, SIZE, MMX, ALIGN, SHIFT5_EXT) \
+QPEL(avg_, SIZE, MMX, ALIGN, SHIFT5_EXT) \
-#define H264_MC_816(QPEL, XMM)\
-QPEL(put_, 8, XMM, 16)\
-QPEL(put_, 16,XMM, 16)\
-QPEL(avg_, 8, XMM, 16)\
-QPEL(avg_, 16,XMM, 16)\
+#define H264_MC_816(QPEL, XMM, SHIFT5_EXT)\
+QPEL(put_, 8, XMM, 16, SHIFT5_EXT)\
+QPEL(put_, 16,XMM, 16, SHIFT5_EXT)\
+QPEL(avg_, 8, XMM, 16, SHIFT5_EXT)\
+QPEL(avg_, 16,XMM, 16, SHIFT5_EXT)\
-QPEL_H264(put_, PUT_OP, mmxext)
-QPEL_H264(avg_, AVG_MMXEXT_OP, mmxext)
-QPEL_H264_V_XMM(put_, PUT_OP, sse2)
-QPEL_H264_V_XMM(avg_,AVG_MMXEXT_OP, sse2)
-QPEL_H264_HV_XMM(put_, PUT_OP, sse2)
-QPEL_H264_HV_XMM(avg_,AVG_MMXEXT_OP, sse2)
-QPEL_H264_H_XMM(put_, PUT_OP, ssse3)
-QPEL_H264_H_XMM(avg_,AVG_MMXEXT_OP, ssse3)
-QPEL_H264_HV_XMM(put_, PUT_OP, ssse3)
-QPEL_H264_HV_XMM(avg_,AVG_MMXEXT_OP, ssse3)
+QPEL_H264(put_, mmxext)
+QPEL_H264(avg_, mmxext)
+QPEL_H264_V_XMM(put_, sse2, sse2)
+QPEL_H264_V_XMM(avg_, sse2, sse2)
+QPEL_H264_HV_XMM(put_, sse2)
+QPEL_H264_HV_XMM(avg_, sse2)
+QPEL_H264_H_XMM(put_, ssse3)
+QPEL_H264_H_XMM(avg_, ssse3)
+QPEL_H264_V_XMM(put_, ssse3, sse2)
+QPEL_H264_V_XMM(avg_, ssse3, sse2)
+QPEL_H264_HV_XMM(put_, ssse3)
+QPEL_H264_HV_XMM(avg_, ssse3)
-H264_MC(H264_MC_V_H_HV, 4, mmxext, 8)
-H264_MC_816(H264_MC_V, sse2)
-H264_MC_816(H264_MC_HV, sse2)
-H264_MC_816(H264_MC_H, ssse3)
-H264_MC_816(H264_MC_HV, ssse3)
+H264_MC(H264_MC_V_H_HV, 4, mmxext, 8, mmxext)
+H264_MC_816(H264_MC_V, sse2, sse2)
+H264_MC_816(H264_MC_HV, sse2, sse2)
+H264_MC_816(H264_MC_H, ssse3, sse2)
+H264_MC_816(H264_MC_HV, ssse3, sse2)
//10bit
--
2.49.1
1
0
PR #20644 opened by Y0SH1M4S73R
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20644
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20644.patch
See commit messages for details.
From e4590f078e26dcee8ff8ff3c48fd0d50a9f231fa Mon Sep 17 00:00:00 2001
From: Y0SH1M4S73R <Y0SH1M4S73R(a)github.com>
Date: Sat, 4 Oct 2025 01:10:54 -0400
Subject: [PATCH 1/2] avfilter/flite: add .flitevox file support
libflite allows users to load voices from .flitevox files. The flite filter can now load a voice from such a file using the voicefile option.
The global initialization logic for the flite filter has been updated to register language and lexicon initialization functions for the "eng" and "useng" language strings. This is necessary to allow .flitevox files to be loaded correctly.
Due to the relatively large size of loaded voices (~15 MB), I have chosen to cache them in `voice_entry` structs contained in a static array. However, this implementation does not account for the possibility of the voice file at a specified path being changed before a voice previously loaded from that file is no longer in use. As such, changes to this implementation, and whether loaded voices should even be cached in the first place, should be discussed.
---
libavfilter/asrc_flite.c | 141 +++++++++++++++++++++++++++++++++++++--
1 file changed, 136 insertions(+), 5 deletions(-)
diff --git a/libavfilter/asrc_flite.c b/libavfilter/asrc_flite.c
index 33576beade..6f7ef467cd 100644
--- a/libavfilter/asrc_flite.c
+++ b/libavfilter/asrc_flite.c
@@ -31,6 +31,7 @@
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/thread.h"
+#include "libavutil/tree.h"
#include "avfilter.h"
#include "filters.h"
#include "audio.h"
@@ -39,6 +40,7 @@
typedef struct FliteContext {
const AVClass *class;
char *voice_str;
+ char *voice_file;
char *textfile;
char *text;
char *text_p;
@@ -65,6 +67,7 @@ static const AVOption flite_options[] = {
{ "textfile", "set filename of the text to speak", OFFSET(textfile), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
{ "v", "set voice", OFFSET(voice_str), AV_OPT_TYPE_STRING, {.str="kal"}, 0, 0, FLAGS },
{ "voice", "set voice", OFFSET(voice_str), AV_OPT_TYPE_STRING, {.str="kal"}, 0, 0, FLAGS },
+ { "voicefile", "set flitevox voice file", OFFSET(voice_file), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS},
{ NULL }
};
@@ -74,7 +77,7 @@ static AVMutex flite_mutex = AV_MUTEX_INITIALIZER;
static int flite_inited = 0;
-/* declare functions for all the supported voices */
+/* declare functions for all the built-in voices */
#define DECLARE_REGISTER_VOICE_FN(name) \
cst_voice *register_cmu_us_## name(const char *); \
void unregister_cmu_us_## name(cst_voice *)
@@ -84,8 +87,12 @@ DECLARE_REGISTER_VOICE_FN(kal16);
DECLARE_REGISTER_VOICE_FN(rms);
DECLARE_REGISTER_VOICE_FN(slt);
+void usenglish_init(cst_voice *);
+cst_lexicon *cmulex_init(void);
+
struct voice_entry {
const char *name;
+ char *voice_file;
cst_voice * (*register_fn)(const char *);
void (*unregister_fn)(cst_voice *);
cst_voice *voice;
@@ -145,6 +152,106 @@ static int select_voice(struct voice_entry **entry_ret, const char *voice_name,
return AVERROR(EINVAL);
}
+static int loaded_voice_entry_count = 0;
+static int loaded_voice_entry_capacity = 0;
+static struct voice_entry **loaded_voice_entries = NULL;
+
+static int add_loaded_entry(struct voice_entry *entry) {
+ if (loaded_voice_entry_count == loaded_voice_entry_capacity) {
+ if(av_dynarray_add_nofree(&loaded_voice_entries, &loaded_voice_entry_capacity, entry) < 0)
+ return AVERROR(ENOMEM);
+ loaded_voice_entry_count++;
+ } else {
+ for (int i = 0; i < loaded_voice_entry_capacity; i++) {
+ if(!loaded_voice_entries[i]) {
+ loaded_voice_entries[i] = entry;
+ loaded_voice_entry_count++;
+ break;
+ }
+ }
+ }
+ return 0;
+}
+
+static struct voice_entry *get_loaded_entry(void *key, int (predicate)(const void *key, const struct voice_entry *entry)) {
+ for (int i = 0; i < loaded_voice_entry_capacity; i++) {
+ struct voice_entry *entry = loaded_voice_entries[i];
+ if (entry && predicate(key, entry))
+ return entry;
+ }
+ return NULL;
+}
+
+static int path_predicate(const void *key, const struct voice_entry *entry) {
+ return !strcmp((const char *)key, entry->voice_file);
+}
+
+static int voice_predicate(const void *key, const struct voice_entry *entry) {
+ return (const cst_voice *)key == entry->voice;
+}
+
+static void remove_loaded_entry(const struct voice_entry *removing_entry) {
+ for (int i = 0; i < loaded_voice_entry_capacity; i++) {
+ const struct voice_entry *entry = loaded_voice_entries[i];
+ if (entry == removing_entry) {
+ loaded_voice_entries[i] = NULL;
+ loaded_voice_entry_count--;
+ }
+ }
+}
+
+static void unregister_loaded_voice(cst_voice *voice) {
+ struct voice_entry *entry = get_loaded_entry(voice, voice_predicate);
+ if (!entry) {
+ av_log(NULL, AV_LOG_ERROR, "unregister_loaded_voice failed: no voice entry\n");
+ return;
+ }
+ if (entry->voice != voice) {
+ av_log(NULL, AV_LOG_ERROR, "unregister_loaded_voice failed: voice mismatch\n");
+ return;
+ }
+ remove_loaded_entry(entry);
+ delete_voice(entry->voice);
+ av_free((char *)entry->name);
+ av_free(entry->voice_file);
+ av_free(entry);
+ return;
+}
+
+static int load_voice(struct voice_entry **entry_ret, char *voice_path, void *log_ctx) {
+ pthread_mutex_lock(&flite_mutex);
+ struct voice_entry *entry = get_loaded_entry(voice_path, path_predicate);
+ if (!entry) {
+ cst_voice *voice;
+ if (!(voice = flite_voice_load(voice_path))) {
+ pthread_mutex_unlock(&flite_mutex);
+ av_log(log_ctx, AV_LOG_ERROR, "the voice file '%s' can not be read\n", voice_path);
+ return AVERROR_EXTERNAL;
+ }
+
+ entry = av_mallocz(sizeof(struct voice_entry));
+ entry->name = av_strdup(voice->name);
+ entry->voice_file = av_strdup(voice_path);
+ entry->unregister_fn = unregister_loaded_voice;
+ entry->voice = voice;
+
+ int ret;
+ if ((ret = add_loaded_entry(entry)) < 0) {
+ pthread_mutex_unlock(&flite_mutex);
+ delete_voice(voice);
+ av_free((char *)entry->name);
+ av_free(entry->voice_file);
+ av_free(entry);
+ return ret;
+ }
+ }
+ entry->usage_count++;
+ pthread_mutex_unlock(&flite_mutex);
+ *entry_ret = entry;
+ return 0;
+
+}
+
static int audio_stream_chunk_by_word(const cst_wave *wave, int start, int size,
int last, cst_audio_streaming_info *asi)
{
@@ -164,6 +271,17 @@ static int audio_stream_chunk_by_word(const cst_wave *wave, int start, int size,
return CST_AUDIO_STREAM_CONT;
}
+static int perform_flite_initializations(void) {
+ int ret = 0;
+ if ((ret = flite_init()) < 0)
+ return ret;
+ if ((ret = flite_add_lang("eng", usenglish_init, cmulex_init)) < 0)
+ return ret;
+ if ((ret = flite_add_lang("usenglish", usenglish_init, cmulex_init)) < 0)
+ return ret;
+ return 0;
+}
+
static av_cold int init(AVFilterContext *ctx)
{
FliteContext *flite = ctx->priv;
@@ -177,7 +295,7 @@ static av_cold int init(AVFilterContext *ctx)
pthread_mutex_lock(&flite_mutex);
if (!flite_inited) {
- if ((ret = flite_init()) >= 0)
+ if ((ret = perform_flite_initializations()) >= 0)
flite_inited = 1;
}
pthread_mutex_unlock(&flite_mutex);
@@ -186,8 +304,14 @@ static av_cold int init(AVFilterContext *ctx)
return AVERROR_EXTERNAL;
}
- if ((ret = select_voice(&flite->voice_entry, flite->voice_str, ctx)) < 0)
- return ret;
+ if (flite->voice_file) {
+ if ((ret = load_voice(&flite->voice_entry, flite->voice_file, ctx)) < 0)
+ return ret;
+ } else {
+ if ((ret = select_voice(&flite->voice_entry, flite->voice_str, ctx)) < 0)
+ return ret;
+ }
+
flite->voice = flite->voice_entry->voice;
if (flite->textfile && flite->text) {
@@ -297,8 +421,15 @@ static int config_props(AVFilterLink *outlink)
outlink->sample_rate = flite->sample_rate;
outlink->time_base = (AVRational){1, flite->sample_rate};
+ const char *voice_name;
+ if (flite->voice_file) {
+ voice_name = av_asprintf("%s (%s)", flite->voice->name, flite->voice_file);
+ } else {
+ voice_name = flite->voice_str;
+ }
+
av_log(ctx, AV_LOG_VERBOSE, "voice:%s fmt:%s sample_rate:%d\n",
- flite->voice_str,
+ voice_name,
av_get_sample_fmt_name(outlink->format), outlink->sample_rate);
return 0;
--
2.49.1
From 7d7a83f78e78928f7c561dee06ace8ab7ee68f50 Mon Sep 17 00:00:00 2001
From: Y0SH1M4S73R <Y0SH1M4S73R(a)github.com>
Date: Sat, 4 Oct 2025 02:52:34 -0400
Subject: [PATCH 2/2] avfilter/ffmpeg: corrects formatting mistakes
---
libavfilter/asrc_flite.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libavfilter/asrc_flite.c b/libavfilter/asrc_flite.c
index 6f7ef467cd..90936b9028 100644
--- a/libavfilter/asrc_flite.c
+++ b/libavfilter/asrc_flite.c
@@ -67,7 +67,7 @@ static const AVOption flite_options[] = {
{ "textfile", "set filename of the text to speak", OFFSET(textfile), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
{ "v", "set voice", OFFSET(voice_str), AV_OPT_TYPE_STRING, {.str="kal"}, 0, 0, FLAGS },
{ "voice", "set voice", OFFSET(voice_str), AV_OPT_TYPE_STRING, {.str="kal"}, 0, 0, FLAGS },
- { "voicefile", "set flitevox voice file", OFFSET(voice_file), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS},
+ { "voicefile", "set flitevox voice file", OFFSET(voice_file), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
{ NULL }
};
@@ -158,12 +158,12 @@ static struct voice_entry **loaded_voice_entries = NULL;
static int add_loaded_entry(struct voice_entry *entry) {
if (loaded_voice_entry_count == loaded_voice_entry_capacity) {
- if(av_dynarray_add_nofree(&loaded_voice_entries, &loaded_voice_entry_capacity, entry) < 0)
+ if (av_dynarray_add_nofree(&loaded_voice_entries, &loaded_voice_entry_capacity, entry) < 0)
return AVERROR(ENOMEM);
loaded_voice_entry_count++;
} else {
for (int i = 0; i < loaded_voice_entry_capacity; i++) {
- if(!loaded_voice_entries[i]) {
+ if (!loaded_voice_entries[i]) {
loaded_voice_entries[i] = entry;
loaded_voice_entry_count++;
break;
--
2.49.1
1
0
[PATCH] avutil/attributes: don't force format checking to __gnu_printf__ on mingw build (PR #20643)
by Kacper Michajłow 04 Oct '25
by Kacper Michajłow 04 Oct '25
04 Oct '25
PR #20643 opened by Kacper Michajłow (kasper93)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20643
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20643.patch
Use __MINGW_{PRINTF,SCANF}_FORMAT which matches the format check for
implementation that is actually used.
From e6d5af7078a1a887abd69a5fd28d47baa82238f0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= <kasper93(a)gmail.com>
Date: Sat, 4 Oct 2025 08:49:21 +0200
Subject: [PATCH] avutil/attributes: don't force format checking to
__gnu_printf__ on mingw build
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Use __MINGW_{PRINTF,SCANF}_FORMAT which matches the format check for
implementation that is actually used.
Signed-off-by: Kacper Michajłow <kasper93(a)gmail.com>
---
configure | 4 ----
libavutil/attributes.h | 24 ++++++++++++++++++++++--
2 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/configure b/configure
index 3de3b150ef..7828381b5d 100755
--- a/configure
+++ b/configure
@@ -6225,8 +6225,6 @@ probe_libc(){
if ! test_${pfx}cpp_condition crtdefs.h "defined(_UCRT)"; then
add_${pfx}cppflags -D__USE_MINGW_ANSI_STDIO=1
fi
- eval test \$${pfx_no_}cc_type = "gcc" &&
- add_${pfx}cppflags -D__printf__=__gnu_printf__
test_${pfx}cpp_condition windows.h "!defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600" &&
add_${pfx}cppflags -D_WIN32_WINNT=0x0600
add_${pfx}cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
@@ -6244,8 +6242,6 @@ probe_libc(){
add_${pfx}cppflags -D__MSVCRT_VERSION__=0x0700
test_${pfx}cpp_condition windows.h "!defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600" &&
add_${pfx}cppflags -D_WIN32_WINNT=0x0600
- eval test \$${pfx_no_}cc_type = "gcc" &&
- add_${pfx}cppflags -D__printf__=__gnu_printf__
add_${pfx}cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
elif test_${pfx}cpp_condition crtversion.h "defined _VC_CRT_MAJOR_VERSION"; then
eval ${pfx}libc_type=msvcrt
diff --git a/libavutil/attributes.h b/libavutil/attributes.h
index 772e327fa4..4f05ce7f40 100644
--- a/libavutil/attributes.h
+++ b/libavutil/attributes.h
@@ -172,11 +172,31 @@
#if defined(__GNUC__) || defined(__clang__)
# define av_builtin_constant_p __builtin_constant_p
-# define av_printf_format(fmtpos, attrpos) __attribute__((__format__(__printf__, fmtpos, attrpos)))
-# define av_scanf_format(fmtpos, attrpos) __attribute__((__format__(__scanf__, fmtpos, attrpos)))
#else
# define av_builtin_constant_p(x) 0
+#endif
+
+#ifdef __MINGW_PRINTF_FORMAT
+# define AV_PRINTF_FMT __MINGW_PRINTF_FORMAT
+#elif defined(__has_attribute) && __has_attribute(format)
+# define AV_PRINTF_FMT __printf__
+#endif
+
+#ifdef __MINGW_SCANF_FORMAT
+# define AV_SCANF_FMT __MINGW_SCANF_FORMAT
+#elif defined(__has_attribute) && __has_attribute(format)
+# define AV_SCANF_FMT __scanf__
+#endif
+
+#ifdef AV_PRINTF_FMT
+# define av_printf_format(fmtpos, attrpos) __attribute__((format(AV_PRINTF_FMT, fmtpos, attrpos)))
+#else
# define av_printf_format(fmtpos, attrpos)
+#endif
+
+#ifdef AV_SCANF_FMT
+# define av_scanf_format(fmtpos, attrpos) __attribute__((format(AV_SCANF_FMT, fmtpos, attrpos)))
+#else
# define av_scanf_format(fmtpos, attrpos)
#endif
--
2.49.1
1
0
[PATCH] configure: add intial Windows platform install files for debug with .pdb symbols
by Roger Johnson 04 Oct '25
by Roger Johnson 04 Oct '25
04 Oct '25
configure: add intial Windows platform install files for debug with .pdb
symbols
adding symbols installation to Mingw32/64 & Windows x86/x64 windows
targets with variable added to config.mak and additional install step
for this in library.mak, resulting in shared library symbol files being
installed for easy consumption in debug installs.
Signed-off-by: Roger Johnson <roger(a)oneibus.com>
---
configure | 3 +++
ffbuild/library.mak | 9 ++++++++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/configure b/configure
index 399b1ce128..6a5b2793e3 100755
--- a/configure
+++ b/configure
@@ -6040,6 +6040,7 @@ case $target_os in
SLIB_INSTALL_LINKS=
SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
SLIB_INSTALL_EXTRA_LIB='lib$(SLIBNAME:$(SLIBSUF)=.dll.a)
$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
+ SLIB_INSTALL_EXTRA_SYM='$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.pdb)'
SLIB_CREATE_DEF_CMD='EXTERN_PREFIX="$(EXTERN_PREFIX)"
AR="$(AR_CMD)" NM="$(NM_CMD)" $(SRC_PATH)/compat/windows/makedef
$(SUBDIR)lib$(NAME).ver $(OBJS) > $$(@:$(SLIBSUF)=.def)'
SHFLAGS='-shared
-Wl,--out-implib,$(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a)
-Wl,--disable-auto-image-base $$(@:$(SLIBSUF)=.def)'
enabled x86_64 && objformat="win64" || objformat="win32"
@@ -6083,6 +6084,7 @@ case $target_os in
SLIB_INSTALL_LINKS=
SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
SLIB_INSTALL_EXTRA_LIB='$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
+ SLIB_INSTALL_EXTRA_SYM='$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.pdb)'
if test $ld_type = "clang"; then
SHFLAGS='-Wl,-dll -Wl,-def:$$(@:$(SLIBSUF)=.def)
-Wl,-implib:$(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib)'
else
@@ -8460,6 +8462,7 @@ SLIB_INSTALL_NAME=${SLIB_INSTALL_NAME}
SLIB_INSTALL_LINKS=${SLIB_INSTALL_LINKS}
SLIB_INSTALL_EXTRA_LIB=${SLIB_INSTALL_EXTRA_LIB}
SLIB_INSTALL_EXTRA_SHLIB=${SLIB_INSTALL_EXTRA_SHLIB}
+SLIB_INSTALL_EXTRA_SYM=${SLIB_INSTALL_EXTRA_SYM}
VERSION_SCRIPT_POSTPROCESS_CMD=${VERSION_SCRIPT_POSTPROCESS_CMD}
SAMPLES:=${samples:-\$(FATE_SAMPLES)}
NOREDZONE_FLAGS=$noredzone_flags
diff --git a/ffbuild/library.mak b/ffbuild/library.mak
index 91daa9c25f..211793fedb 100644
--- a/ffbuild/library.mak
+++ b/ffbuild/library.mak
@@ -17,6 +17,8 @@ all-$(CONFIG_SHARED): $(SUBDIR)$(SLIBNAME)
$(SUBDIR)lib$(FULLNAME).pc
LIBOBJS := $(OBJS) $(SHLIBOBJS) $(STLIBOBJS) $(SUBDIR)%.h.o $(TESTOBJS)
$(LIBOBJS) $(LIBOBJS:.o=.s) $(LIBOBJS:.o=.i): CPPFLAGS +=
-DHAVE_AV_CONFIG_H
+ISDEBUG := $(if $(findstring
--enable-debug,$(FFMPEG_CONFIGURATION)),yes,)
+
ifdef CONFIG_SHARED
# In case both shared libs and static libs are enabled, it can happen
# that a user might want to link e.g. libavformat statically, but
@@ -47,7 +49,7 @@ endif
install-headers: install-lib$(NAME)-headers install-lib$(NAME)-pkgconfig
install-libs-$(CONFIG_STATIC): install-lib$(NAME)-static
-install-libs-$(CONFIG_SHARED): install-lib$(NAME)-shared
+install-libs-$(CONFIG_SHARED): install-lib$(NAME)-shared
install-lib$(NAME)-symbols
define RULES
$(TOOLS): THISLIB = $(FULLNAME:%=$(LD_LIB))
@@ -102,6 +104,10 @@ install-lib$(NAME)-shared: $(SUBDIR)$(SLIBNAME)
$(if $(SLIB_INSTALL_EXTRA_LIB),$(Q)mkdir -p "$(LIBDIR)")
$(if $(SLIB_INSTALL_EXTRA_LIB),$$(INSTALL) -m 644
$(SLIB_INSTALL_EXTRA_LIB:%=$(SUBDIR)%) "$(LIBDIR)")
+install-lib$(NAME)-symbols: $(SUBDIR)$(SLIB_INSTALL_EXTRA_SYM)
+ $(Q)mkdir -p "$(SHLIBDIR)"
+ $(if $(ISDEBUG),$(if $(SLIB_INSTALL_EXTRA_SYM),$$(INSTALL) -m 644
$(SLIB_INSTALL_EXTRA_SYM:%=$(SUBDIR)%) "$(SHLIBDIR)"))
+
install-lib$(NAME)-static: $(SUBDIR)$(LIBNAME)
$(Q)mkdir -p "$(LIBDIR)"
$$(INSTALL) -m 644 $$< "$(LIBDIR)"
@@ -119,6 +125,7 @@ uninstall-libs::
-$(RM) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR)" \
"$(SHLIBDIR)/$(SLIBNAME)" \
"$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
+ -$(RM) $(SLIB_INSTALL_EXTRA_SYM:%="$(SHLIBDIR)/%")
-$(RM) $(SLIB_INSTALL_EXTRA_SHLIB:%="$(SHLIBDIR)/%")
-$(RM) $(SLIB_INSTALL_EXTRA_LIB:%="$(LIBDIR)/%")
-$(RM) "$(LIBDIR)/$(LIBNAME)"
--
2.51.0.windows.1
1
0
[PATCH] configure: add intial Windows platform install files for debug with .pdb symbols
by Roger Johnson 03 Oct '25
by Roger Johnson 03 Oct '25
03 Oct '25
configure: add intial Windows platform install files for debug with .pdb
symbols
adding symbols installation to Mingw32/64 & Windows x86/x64 windows targets
with variable added to config.mak and additional install step for this
in library.mak,
resulting in shared library symbol files being installed for easy
consumption
in debug installs.
Signed-off-by: Roger Johnson <roger(a)oneibus.com>
---
configure | 3 +++
ffbuild/library.mak | 9 ++++++++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/configure b/configure
index 399b1ce128..d60a3842f9 100755
--- a/configure
+++ b/configure
@@ -6040,6 +6040,7 @@ case $target_os in
SLIB_INSTALL_LINKS=
SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
SLIB_INSTALL_EXTRA_LIB='lib$(SLIBNAME:$(SLIBSUF)=.dll.a)
$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
+ SLIB_INSTALL_EXTRA_SYM='$(SLIBNAME:$(SLIBSUF)=.pdb)'
SLIB_CREATE_DEF_CMD='EXTERN_PREFIX="$(EXTERN_PREFIX)"
AR="$(AR_CMD)" NM="$(NM_CMD)" $(SRC_PATH)/compat/windows/makedef
$(SUBDIR)lib$(NAME).ver $(OBJS) > $$(@:$(SLIBSUF)=.def)'
SHFLAGS='-shared
-Wl,--out-implib,$(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a)
-Wl,--disable-auto-image-base $$(@:$(SLIBSUF)=.def)'
enabled x86_64 && objformat="win64" || objformat="win32"
@@ -6083,6 +6084,7 @@ case $target_os in
SLIB_INSTALL_LINKS=
SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
SLIB_INSTALL_EXTRA_LIB='$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
+ SLIB_INSTALL_EXTRA_SYM='$(SLIBNAME:$(SLIBSUF)=.pdb)'
if test $ld_type = "clang"; then
SHFLAGS='-Wl,-dll -Wl,-def:$$(@:$(SLIBSUF)=.def)
-Wl,-implib:$(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib)'
else
@@ -8460,6 +8462,7 @@ SLIB_INSTALL_NAME=${SLIB_INSTALL_NAME}
SLIB_INSTALL_LINKS=${SLIB_INSTALL_LINKS}
SLIB_INSTALL_EXTRA_LIB=${SLIB_INSTALL_EXTRA_LIB}
SLIB_INSTALL_EXTRA_SHLIB=${SLIB_INSTALL_EXTRA_SHLIB}
+SLIB_INSTALL_EXTRA_SYM=${SLIB_INSTALL_EXTRA_SYM}
VERSION_SCRIPT_POSTPROCESS_CMD=${VERSION_SCRIPT_POSTPROCESS_CMD}
SAMPLES:=${samples:-\$(FATE_SAMPLES)}
NOREDZONE_FLAGS=$noredzone_flags
diff --git a/ffbuild/library.mak b/ffbuild/library.mak
index 91daa9c25f..cf54615253 100644
--- a/ffbuild/library.mak
+++ b/ffbuild/library.mak
@@ -17,6 +17,8 @@ all-$(CONFIG_SHARED): $(SUBDIR)$(SLIBNAME)
$(SUBDIR)lib$(FULLNAME).pc
LIBOBJS := $(OBJS) $(SHLIBOBJS) $(STLIBOBJS) $(SUBDIR)%.h.o $(TESTOBJS)
$(LIBOBJS) $(LIBOBJS:.o=.s) $(LIBOBJS:.o=.i): CPPFLAGS +=
-DHAVE_AV_CONFIG_H
+ISDEBUG := $(if $(findstring
--enable-debug,$(FFMPEG_CONFIGURATION)),yes,)
+
ifdef CONFIG_SHARED
# In case both shared libs and static libs are enabled, it can happen
# that a user might want to link e.g. libavformat statically, but
@@ -47,7 +49,7 @@ endif
install-headers: install-lib$(NAME)-headers install-lib$(NAME)-pkgconfig
install-libs-$(CONFIG_STATIC): install-lib$(NAME)-static
-install-libs-$(CONFIG_SHARED): install-lib$(NAME)-shared
+install-libs-$(CONFIG_SHARED): install-lib$(NAME)-shared
install-lib$(NAME)-symbols
define RULES
$(TOOLS): THISLIB = $(FULLNAME:%=$(LD_LIB))
@@ -102,6 +104,10 @@ install-lib$(NAME)-shared: $(SUBDIR)$(SLIBNAME)
$(if $(SLIB_INSTALL_EXTRA_LIB),$(Q)mkdir -p "$(LIBDIR)")
$(if $(SLIB_INSTALL_EXTRA_LIB),$$(INSTALL) -m 644
$(SLIB_INSTALL_EXTRA_LIB:%=$(SUBDIR)%) "$(LIBDIR)")
+install-lib$(NAME)-symbols: $(SUBDIR)$(SLIBNAME)
+ $(Q)mkdir -p "$(SHLIBDIR)"
+ $(if $(ISDEBUG),$(if $(SLIB_INSTALL_EXTRA_SYM),$$(INSTALL) -m 644 $$<
"$(SHLIBDIR)/$(SLIB_INSTALL_EXTRA_SYM)"))
+
install-lib$(NAME)-static: $(SUBDIR)$(LIBNAME)
$(Q)mkdir -p "$(LIBDIR)"
$$(INSTALL) -m 644 $$< "$(LIBDIR)"
@@ -119,6 +125,7 @@ uninstall-libs::
-$(RM) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR)" \
"$(SHLIBDIR)/$(SLIBNAME)" \
"$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
+ -$(RM) $(SLIB_INSTALL_EXTRA_SYM:%="$(SHLIBDIR)/%")
-$(RM) $(SLIB_INSTALL_EXTRA_SHLIB:%="$(SHLIBDIR)/%")
-$(RM) $(SLIB_INSTALL_EXTRA_LIB:%="$(LIBDIR)/%")
-$(RM) "$(LIBDIR)/$(LIBNAME)"
--
2.51.0.windows.1
1
0
[PATCH] Allow the user to limit metadata length and bext coding history (PR #20642)
by michaelni 03 Oct '25
by michaelni 03 Oct '25
03 Oct '25
PR #20642 opened by michaelni
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20642
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20642.patch
From 42e879d0a91dcb4ee5d21329b58ef93014ea3cb3 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <michael(a)niedermayer.cc>
Date: Fri, 3 Oct 2025 00:12:32 +0200
Subject: [PATCH 1/2] avformat: Add max_metadata_length to limit the maximum
length of metadata entries
Signed-off-by: Michael Niedermayer <michael(a)niedermayer.cc>
---
doc/APIchanges | 3 +++
libavformat/avformat.h | 8 ++++++++
libavformat/options_table.h | 1 +
libavformat/version.h | 2 +-
4 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/doc/APIchanges b/doc/APIchanges
index 6e7f5d2037..01faaa4dff 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2025-03-28
API changes, most recent first:
+2025-10-xx - xxxxxxxxxx - lavf 62.7.100 - avformat.h
+ Add max_metadata_length
+
2025-08-xx - xxxxxxxxxx - lavf 62.6.100 - oggparsevorbis.h oggparseopus.h oggparseflac.h
Drop header packets from secondary chained ogg/{flac, opus, vorbis} streams
from demuxer output.
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index a7446546e5..2ce09f31fa 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1884,6 +1884,14 @@ typedef struct AVFormatContext {
* @see skip_estimate_duration_from_pts
*/
int64_t duration_probesize;
+
+ /**
+ * The maximum length of metadata fields.
+ * This gives demuxers a guideline of what is "too large"
+ * - encoding: unused
+ * - decoding: set by user
+ */
+ int max_metadata_length;
} AVFormatContext;
/**
diff --git a/libavformat/options_table.h b/libavformat/options_table.h
index 5047b5ce50..1d458c1200 100644
--- a/libavformat/options_table.h
+++ b/libavformat/options_table.h
@@ -106,6 +106,7 @@ static const AVOption avformat_options[] = {
{"skip_estimate_duration_from_pts", "skip duration calculation in estimate_timings_from_pts", OFFSET(skip_estimate_duration_from_pts), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, D},
{"max_probe_packets", "Maximum number of packets to probe a codec", OFFSET(max_probe_packets), AV_OPT_TYPE_INT, { .i64 = 2500 }, 0, INT_MAX, D },
{"duration_probesize", "Maximum number of bytes to probe the durations of the streams in estimate_timings_from_pts", OFFSET(duration_probesize), AV_OPT_TYPE_INT64, {.i64 = 0 }, 0, (double)INT64_MAX, D},
+{"max_metadata_length", "Maximum length of metadata fields", OFFSET(max_metadata_length), AV_OPT_TYPE_INT, { .i64 = INT_MAX }, 0, INT_MAX, D },
{NULL},
};
diff --git a/libavformat/version.h b/libavformat/version.h
index 4bde82abb4..70c554c19c 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -31,7 +31,7 @@
#include "version_major.h"
-#define LIBAVFORMAT_VERSION_MINOR 6
+#define LIBAVFORMAT_VERSION_MINOR 7
#define LIBAVFORMAT_VERSION_MICRO 100
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
--
2.49.1
From dad6cf719230e6d6c486880d621204d885ef055f Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <michael(a)niedermayer.cc>
Date: Fri, 3 Oct 2025 00:14:46 +0200
Subject: [PATCH 2/2] avformat/wavdec: Limit the BEXT coding history size to
the max metadata length
The specification has no limit on its size.
This can cause allocation of physical memory
twice the size of the input file.
giving the user a way to limit this makes sense.
Even though there are other ways to cause more memory
to be allocated.
Reported-by: Albin V, AWS Security
Signed-off-by: Michael Niedermayer <michael(a)niedermayer.cc>
---
libavformat/wavdec.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
index 7d701c517a..4ee9658be6 100644
--- a/libavformat/wavdec.c
+++ b/libavformat/wavdec.c
@@ -32,6 +32,7 @@
#include "libavutil/dict.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/log.h"
+#include "libavutil/macros.h"
#include "libavutil/mathematics.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
@@ -322,15 +323,20 @@ static int wav_parse_bext_tag(AVFormatContext *s, int64_t size)
/* CodingHistory present */
size -= 602;
- if (!(coding_history = av_malloc(size + 1)))
+ int read_len = FFMIN3(size, s->max_metadata_length, INT_MAX - 1);
+
+ if (!(coding_history = av_malloc(read_len + 1)))
return AVERROR(ENOMEM);
- if ((ret = ffio_read_size(s->pb, coding_history, size)) < 0) {
+ if ((ret = ffio_read_size(s->pb, coding_history, read_len)) < 0) {
av_free(coding_history);
return ret;
}
- coding_history[size] = 0;
+ if (read_len < size)
+ avio_skip(s->pb, size - read_len);
+
+ coding_history[read_len] = 0;
if ((ret = av_dict_set(&s->metadata, "coding_history", coding_history,
AV_DICT_DONT_STRDUP_VAL)) < 0)
return ret;
--
2.49.1
1
0
[PATCH] avcodec/pngenc: Mark unreachable default switch cases as such (PR #20641)
by mkver 02 Oct '25
by mkver 02 Oct '25
02 Oct '25
PR #20641 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20641
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20641.patch
From 2eb23623c006631e4201e57360a70f2d30a72da9 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Thu, 2 Oct 2025 21:07:48 +0200
Subject: [PATCH] avcodec/pngenc: Mark unreachable default switch cases as such
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/pngenc.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c
index 5baad9aad5..8e4f42125e 100644
--- a/libavcodec/pngenc.c
+++ b/libavcodec/pngenc.c
@@ -195,6 +195,8 @@ static void png_filter_row(PNGEncContext *c, uint8_t *dst, int filter_type,
dst[i] = src[i] - top[i];
sub_png_paeth_prediction(dst + i, src + i, top + i, size - i, bpp);
break;
+ default:
+ av_unreachable("PNG_FILTER_VALUE_MIXED can't happen here and all others are covered");
}
}
@@ -816,6 +818,9 @@ static int apng_do_inverse_blend(AVFrame *output, const AVFrame *input,
palette[*background] >> 24 == 0)
break;
return -1;
+
+ default:
+ av_unreachable("Pixfmt has been checked before");
}
memmove(output_data, foreground, bpp);
@@ -1193,7 +1198,7 @@ static av_cold int png_enc_init(AVCodecContext *avctx)
s->color_type = PNG_COLOR_TYPE_PALETTE;
break;
default:
- return -1;
+ av_unreachable("Already checked via CODEC_PIXFMTS");
}
s->bits_per_pixel = ff_png_get_nb_channels(s->color_type) * s->bit_depth;
--
2.49.1
1
0
PR #20640 opened by toots
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20640
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20640.patch
From 3a9233d70c02a336a59d85bae753eadc09d86a53 Mon Sep 17 00:00:00 2001
From: Romain Beauxis <romain.beauxis(a)gmail.com>
Date: Wed, 1 Oct 2025 18:01:13 -0500
Subject: [PATCH] Cleanup packet-level BOS/EOS logic.
---
libavformat/oggdec.c | 6 ++--
libavformat/oggdec.h | 4 +--
libavformat/oggparsecelt.c | 2 +-
libavformat/oggparsedirac.c | 4 +--
libavformat/oggparseflac.c | 6 ++--
libavformat/oggparseogm.c | 6 ++--
libavformat/oggparseopus.c | 36 +++------------------
libavformat/oggparseskeleton.c | 4 +--
libavformat/oggparsespeex.c | 6 ++--
libavformat/oggparsetheora.c | 6 ++--
libavformat/oggparsevorbis.c | 58 ++--------------------------------
libavformat/oggparsevp8.c | 6 ++--
12 files changed, 33 insertions(+), 111 deletions(-)
diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index 9f3a92a5ea..2bd2ec1b65 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -567,7 +567,8 @@ static int ogg_packet(AVFormatContext *s, int *sid, int *dstart, int *dsize,
os->incomplete = 0;
if (os->header) {
- if ((ret = os->codec->header(s, idx)) < 0) {
+ int is_first = os->flags & OGG_FLAG_BOS && !os->nb_header;
+ if ((ret = os->codec->header(s, idx, is_first)) < 0) {
av_log(s, AV_LOG_ERROR, "Header processing failed: %s\n", av_err2str(ret));
return ret;
}
@@ -605,7 +606,8 @@ static int ogg_packet(AVFormatContext *s, int *sid, int *dstart, int *dsize,
ret = 0;
if (os->codec && os->codec->packet) {
- if ((ret = os->codec->packet(s, idx)) < 0) {
+ int is_last_packet = os->flags & OGG_FLAG_EOS && os->page_end;
+ if ((ret = os->codec->packet(s, idx, is_last_packet)) < 0) {
av_log(s, AV_LOG_ERROR, "Packet processing failed: %s\n", av_err2str(ret));
return ret;
}
diff --git a/libavformat/oggdec.h b/libavformat/oggdec.h
index b051b651e3..76d1c0f0eb 100644
--- a/libavformat/oggdec.h
+++ b/libavformat/oggdec.h
@@ -37,7 +37,7 @@ struct ogg_codec {
* 0 if the packet was not a header (was a data packet)
* -1 if an error occurred or for unsupported stream
*/
- int (*header)(AVFormatContext *, int);
+ int (*header)(AVFormatContext *, int, int);
/**
* Attempt to process a packet as a data packet
* @return < 0 (AVERROR) code or -1 on error
@@ -45,7 +45,7 @@ struct ogg_codec {
* == 1 if the packet was a header from a chained bitstream.
* This will cause the packet to be skipped in calling code (ogg_packet()
*/
- int (*packet)(AVFormatContext *, int);
+ int (*packet)(AVFormatContext *, int, int);
/**
* Translate a granule into a timestamp.
* Will set dts if non-null and known.
diff --git a/libavformat/oggparsecelt.c b/libavformat/oggparsecelt.c
index 626e1ab27d..683e075bf7 100644
--- a/libavformat/oggparsecelt.c
+++ b/libavformat/oggparsecelt.c
@@ -31,7 +31,7 @@ struct oggcelt_private {
int extra_headers_left;
};
-static int celt_header(AVFormatContext *s, int idx)
+static int celt_header(AVFormatContext *s, int idx, int is_first)
{
struct ogg *ogg = s->priv_data;
struct ogg_stream *os = ogg->streams + idx;
diff --git a/libavformat/oggparsedirac.c b/libavformat/oggparsedirac.c
index c5bd43a757..62ded6e592 100644
--- a/libavformat/oggparsedirac.c
+++ b/libavformat/oggparsedirac.c
@@ -26,7 +26,7 @@
#include "internal.h"
#include "oggdec.h"
-static int dirac_header(AVFormatContext *s, int idx)
+static int dirac_header(AVFormatContext *s, int idx, int is_first)
{
struct ogg *ogg = s->priv_data;
struct ogg_stream *os = ogg->streams + idx;
@@ -84,7 +84,7 @@ static uint64_t dirac_gptopts(AVFormatContext *s, int idx, uint64_t granule,
return pts;
}
-static int old_dirac_header(AVFormatContext *s, int idx)
+static int old_dirac_header(AVFormatContext *s, int idx, int is_first)
{
struct ogg *ogg = s->priv_data;
struct ogg_stream *os = ogg->streams + idx;
diff --git a/libavformat/oggparseflac.c b/libavformat/oggparseflac.c
index e81e4021a1..ec68ebb6b8 100644
--- a/libavformat/oggparseflac.c
+++ b/libavformat/oggparseflac.c
@@ -31,7 +31,7 @@
#define OGG_FLAC_MAGIC_SIZE sizeof(OGG_FLAC_MAGIC)-1
static int
-flac_header (AVFormatContext * s, int idx)
+flac_header (AVFormatContext * s, int idx, int is_first)
{
struct ogg *ogg = s->priv_data;
struct ogg_stream *os = ogg->streams + idx;
@@ -81,7 +81,7 @@ flac_header (AVFormatContext * s, int idx)
}
static int
-flac_packet (AVFormatContext * s, int idx)
+flac_packet (AVFormatContext * s, int idx, int is_last)
{
struct ogg *ogg = s->priv_data;
struct ogg_stream *os = ogg->streams + idx;
@@ -109,7 +109,7 @@ flac_packet (AVFormatContext * s, int idx)
}
static int
-old_flac_header (AVFormatContext * s, int idx)
+old_flac_header (AVFormatContext * s, int idx, int is_first)
{
struct ogg *ogg = s->priv_data;
AVStream *st = s->streams[idx];
diff --git a/libavformat/oggparseogm.c b/libavformat/oggparseogm.c
index 1e794745ab..f66db82301 100644
--- a/libavformat/oggparseogm.c
+++ b/libavformat/oggparseogm.c
@@ -34,7 +34,7 @@
#include "riff.h"
static int
-ogm_header(AVFormatContext *s, int idx)
+ogm_header(AVFormatContext *s, int idx, int is_first)
{
struct ogg *ogg = s->priv_data;
struct ogg_stream *os = ogg->streams + idx;
@@ -128,7 +128,7 @@ ogm_header(AVFormatContext *s, int idx)
}
static int
-ogm_dshow_header(AVFormatContext *s, int idx)
+ogm_dshow_header(AVFormatContext *s, int idx, int is_first)
{
struct ogg *ogg = s->priv_data;
struct ogg_stream *os = ogg->streams + idx;
@@ -169,7 +169,7 @@ ogm_dshow_header(AVFormatContext *s, int idx)
}
static int
-ogm_packet(AVFormatContext *s, int idx)
+ogm_packet(AVFormatContext *s, int idx, int is_last)
{
struct ogg *ogg = s->priv_data;
struct ogg_stream *os = ogg->streams + idx;
diff --git a/libavformat/oggparseopus.c b/libavformat/oggparseopus.c
index ae4ff22c53..af1f3e4ba6 100644
--- a/libavformat/oggparseopus.c
+++ b/libavformat/oggparseopus.c
@@ -81,7 +81,7 @@ static int parse_opus_header(AVFormatContext *avf, AVStream *st, struct ogg_stre
return 1;
}
-static int opus_header(AVFormatContext *avf, int idx)
+static int opus_header(AVFormatContext *avf, int idx, int is_first)
{
struct ogg *ogg = avf->priv_data;
struct ogg_stream *os = &ogg->streams[idx];
@@ -95,7 +95,7 @@ static int opus_header(AVFormatContext *avf, int idx)
return AVERROR(ENOMEM);
}
- if (os->flags & OGG_FLAG_BOS)
+ if (is_first)
return parse_opus_header(avf, st, os, priv, packet, os->psize);
if (priv->need_comments) {
@@ -129,7 +129,7 @@ static int opus_duration(uint8_t *src, int size)
return frame_size * nb_frames;
}
-static int opus_packet(AVFormatContext *avf, int idx)
+static int opus_packet(AVFormatContext *avf, int idx, int is_last)
{
struct ogg *ogg = avf->priv_data;
struct ogg_stream *os = &ogg->streams[idx];
@@ -163,34 +163,6 @@ static int opus_packet(AVFormatContext *avf, int idx)
return 1;
}
- if ((!os->lastpts || os->lastpts == AV_NOPTS_VALUE) && !(os->flags & OGG_FLAG_EOS)) {
- int seg, d;
- int duration;
- uint8_t *last_pkt = os->buf + os->pstart;
- uint8_t *next_pkt = last_pkt;
-
- duration = 0;
- seg = os->segp;
- d = opus_duration(last_pkt, os->psize);
- if (d < 0) {
- os->pflags |= AV_PKT_FLAG_CORRUPT;
- return 0;
- }
- duration += d;
- last_pkt = next_pkt = next_pkt + os->psize;
- for (; seg < os->nsegs; seg++) {
- next_pkt += os->segments[seg];
- if (os->segments[seg] < 255 && next_pkt != last_pkt) {
- int d = opus_duration(last_pkt, next_pkt - last_pkt);
- if (d > 0)
- duration += d;
- last_pkt = next_pkt;
- }
- }
- os->lastpts =
- os->lastdts = os->granule - duration;
- }
-
if ((ret = opus_duration(packet, os->psize)) < 0)
return ret;
@@ -202,7 +174,7 @@ static int opus_packet(AVFormatContext *avf, int idx)
}
priv->cur_dts += os->pduration;
- if ((os->flags & OGG_FLAG_EOS)) {
+ if (is_last) {
int64_t skip = priv->cur_dts - os->granule + priv->pre_skip;
skip = FFMIN(skip, os->pduration);
if (skip > 0) {
diff --git a/libavformat/oggparseskeleton.c b/libavformat/oggparseskeleton.c
index 2016b16c95..1c54285aaa 100644
--- a/libavformat/oggparseskeleton.c
+++ b/libavformat/oggparseskeleton.c
@@ -23,7 +23,7 @@
#include "internal.h"
#include "oggdec.h"
-static int skeleton_header(AVFormatContext *s, int idx)
+static int skeleton_header(AVFormatContext *s, int idx, int flags)
{
struct ogg *ogg = s->priv_data;
struct ogg_stream *os = ogg->streams + idx;
@@ -36,7 +36,7 @@ static int skeleton_header(AVFormatContext *s, int idx)
st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
- if ((os->flags & OGG_FLAG_EOS) && os->psize == 0)
+ if ((flags & OGG_FLAG_EOS) && os->psize == 0)
return 1;
if (os->psize < 8)
diff --git a/libavformat/oggparsespeex.c b/libavformat/oggparsespeex.c
index 0a4b32de15..d3eed6e728 100644
--- a/libavformat/oggparsespeex.c
+++ b/libavformat/oggparsespeex.c
@@ -36,7 +36,7 @@ struct speex_params {
int seq;
};
-static int speex_header(AVFormatContext *s, int idx) {
+static int speex_header(AVFormatContext *s, int idx, int flags) {
struct ogg *ogg = s->priv_data;
struct ogg_stream *os = ogg->streams + idx;
struct speex_params *spxp = os->private;
@@ -111,14 +111,14 @@ static int ogg_page_packets(struct ogg_stream *os)
return packets;
}
-static int speex_packet(AVFormatContext *s, int idx)
+static int speex_packet(AVFormatContext *s, int idx, int flags)
{
struct ogg *ogg = s->priv_data;
struct ogg_stream *os = ogg->streams + idx;
struct speex_params *spxp = os->private;
int packet_size = spxp->packet_size;
- if (os->flags & OGG_FLAG_EOS && os->lastpts != AV_NOPTS_VALUE &&
+ if (flags & OGG_FLAG_EOS && os->lastpts != AV_NOPTS_VALUE &&
os->granule > 0) {
/* first packet of final page. we have to calculate the final packet
duration here because it is the only place we know the next-to-last
diff --git a/libavformat/oggparsetheora.c b/libavformat/oggparsetheora.c
index 6cdd962759..43f5ef9fb3 100644
--- a/libavformat/oggparsetheora.c
+++ b/libavformat/oggparsetheora.c
@@ -35,7 +35,7 @@ typedef struct TheoraParams {
unsigned version;
} TheoraParams;
-static int theora_header(AVFormatContext *s, int idx)
+static int theora_header(AVFormatContext *s, int idx, int flags)
{
struct ogg *ogg = s->priv_data;
struct ogg_stream *os = ogg->streams + idx;
@@ -168,7 +168,7 @@ static uint64_t theora_gptopts(AVFormatContext *ctx, int idx, uint64_t gp,
return iframe + pframe;
}
-static int theora_packet(AVFormatContext *s, int idx)
+static int theora_packet(AVFormatContext *s, int idx, int flags)
{
struct ogg *ogg = s->priv_data;
struct ogg_stream *os = ogg->streams + idx;
@@ -179,7 +179,7 @@ static int theora_packet(AVFormatContext *s, int idx)
the total duration to the page granule to find the encoder delay and
set the first timestamp */
- if ((!os->lastpts || os->lastpts == AV_NOPTS_VALUE) && !(os->flags & OGG_FLAG_EOS)) {
+ if ((!os->lastpts || os->lastpts == AV_NOPTS_VALUE) && !(flags & OGG_FLAG_EOS)) {
int seg;
int64_t pts;
diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c
index 7c4f7624f8..58b9f98669 100644
--- a/libavformat/oggparsevorbis.c
+++ b/libavformat/oggparsevorbis.c
@@ -368,7 +368,7 @@ static int vorbis_update_metadata(AVFormatContext *s, int idx)
os->psize - 8);
}
-static int vorbis_header(AVFormatContext *s, int idx)
+static int vorbis_header(AVFormatContext *s, int idx, int is_first)
{
struct ogg *ogg = s->priv_data;
AVStream *st = s->streams[idx];
@@ -447,7 +447,7 @@ static int vorbis_header(AVFormatContext *s, int idx)
return 1;
}
-static int vorbis_packet(AVFormatContext *s, int idx)
+static int vorbis_packet(AVFormatContext *s, int idx, int is_last)
{
struct ogg *ogg = s->priv_data;
struct ogg_stream *os = ogg->streams + idx;
@@ -460,58 +460,6 @@ static int vorbis_packet(AVFormatContext *s, int idx)
if (!priv->vp)
return AVERROR_INVALIDDATA;
- /* first packet handling
- * here we parse the duration of each packet in the first page and compare
- * the total duration to the page granule to find the encoder delay and
- * set the first timestamp */
- if ((!os->lastpts || os->lastpts == AV_NOPTS_VALUE) && !(os->flags & OGG_FLAG_EOS) && (int64_t)os->granule>=0) {
- int seg, d;
- uint8_t *last_pkt = os->buf + os->pstart;
- uint8_t *next_pkt = last_pkt;
-
- av_vorbis_parse_reset(priv->vp);
- duration = 0;
- seg = os->segp;
- d = av_vorbis_parse_frame_flags(priv->vp, last_pkt, 1, &flags);
- if (d < 0) {
- os->pflags |= AV_PKT_FLAG_CORRUPT;
- return 0;
- } else if (flags & VORBIS_FLAG_COMMENT) {
- vorbis_update_metadata(s, idx);
- flags = 0;
- }
- duration += d;
- last_pkt = next_pkt = next_pkt + os->psize;
- for (; seg < os->nsegs; seg++) {
- if (os->segments[seg] < 255) {
- int d = av_vorbis_parse_frame_flags(priv->vp, last_pkt, 1, &flags);
- if (d < 0) {
- duration = os->granule;
- break;
- } else if (flags & VORBIS_FLAG_COMMENT) {
- vorbis_update_metadata(s, idx);
- flags = 0;
- }
- duration += d;
- last_pkt = next_pkt + os->segments[seg];
- }
- next_pkt += os->segments[seg];
- }
- os->lastpts =
- os->lastdts = os->granule - duration;
-
- if (!os->granule && duration) //hack to deal with broken files (Ticket3710)
- os->lastpts = os->lastdts = AV_NOPTS_VALUE;
-
- if (s->streams[idx]->start_time == AV_NOPTS_VALUE) {
- s->streams[idx]->start_time = FFMAX(os->lastpts, 0);
- if (s->streams[idx]->duration != AV_NOPTS_VALUE)
- s->streams[idx]->duration -= s->streams[idx]->start_time;
- }
- priv->final_pts = AV_NOPTS_VALUE;
- av_vorbis_parse_reset(priv->vp);
- }
-
/* parse packet duration */
if (os->psize > 0) {
duration = av_vorbis_parse_frame_flags(priv->vp, os->buf + os->pstart, 1, &flags);
@@ -569,7 +517,7 @@ static int vorbis_packet(AVFormatContext *s, int idx)
* here we save the pts of the first packet in the final page, sum up all
* packet durations in the final page except for the last one, and compare
* to the page granule to find the duration of the final packet */
- if (os->flags & OGG_FLAG_EOS) {
+ if (is_last) {
if (os->lastpts != AV_NOPTS_VALUE) {
priv->final_pts = os->lastpts;
priv->final_duration = 0;
diff --git a/libavformat/oggparsevp8.c b/libavformat/oggparsevp8.c
index 676b3a0f8e..679ef64d76 100644
--- a/libavformat/oggparsevp8.c
+++ b/libavformat/oggparsevp8.c
@@ -27,7 +27,7 @@
#define VP8_HEADER_SIZE 26
-static int vp8_header(AVFormatContext *s, int idx)
+static int vp8_header(AVFormatContext *s, int idx, int flags)
{
struct ogg *ogg = s->priv_data;
struct ogg_stream *os = ogg->streams + idx;
@@ -98,14 +98,14 @@ static uint64_t vp8_gptopts(AVFormatContext *s, int idx,
return pts;
}
-static int vp8_packet(AVFormatContext *s, int idx)
+static int vp8_packet(AVFormatContext *s, int idx, int flags)
{
struct ogg *ogg = s->priv_data;
struct ogg_stream *os = ogg->streams + idx;
uint8_t *p = os->buf + os->pstart;
if ((!os->lastpts || os->lastpts == AV_NOPTS_VALUE) &&
- !(os->flags & OGG_FLAG_EOS)) {
+ !(flags & OGG_FLAG_EOS)) {
int seg;
int duration;
uint8_t *last_pkt = p;
--
2.49.1
1
0
[PATCH] avformat/tls_openssl: do not cleanup tls after a successful dtls_start() (PR #20639)
by Marton Balint 01 Oct '25
by Marton Balint 01 Oct '25
01 Oct '25
PR #20639 opened by Marton Balint (cus)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20639
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20639.patch
Regression since 8e11e2cdb82299e7f0b6d8884bf2bc65c1c3f5e8.
Signed-off-by: Marton Balint <cus(a)passwd.hu>
From be9a80afe1ff01c5eb36b8390ed6153c2a7b2543 Mon Sep 17 00:00:00 2001
From: Marton Balint <cus(a)passwd.hu>
Date: Thu, 2 Oct 2025 00:27:29 +0200
Subject: [PATCH] avformat/tls_openssl: do not cleanup tls after a successful
dtls_start()
Regression since 8e11e2cdb82299e7f0b6d8884bf2bc65c1c3f5e8.
Signed-off-by: Marton Balint <cus(a)passwd.hu>
---
libavformat/tls_openssl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavformat/tls_openssl.c b/libavformat/tls_openssl.c
index c2adaa38d1..c7d6ff6cf4 100644
--- a/libavformat/tls_openssl.c
+++ b/libavformat/tls_openssl.c
@@ -834,7 +834,7 @@ static int dtls_start(URLContext *h, const char *url, int flags, AVDictionary **
av_log(c, AV_LOG_VERBOSE, "Setup ok, MTU=%d\n", c->tls_shared.mtu);
- ret = 0;
+ return 0;
fail:
tls_close(h);
return ret;
--
2.49.1
1
0
01 Oct '25
PR #20638 opened by Niklas Haas (haasn)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20638
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20638.patch
Avoids the following Coverity warning:
> CID 1666425: Concurrent data access violations (MISSING_LOCK)
> Accessing "fg->best_input" without holding lock "Scheduler.schedule_lock".
> Elsewhere, "SchFilterGraph.best_input" is written to with
> "Scheduler.schedule_lock" held 2 out of 2 times (2 of these accesses
> strongly imply that it is necessary).
I'm pretty sure this is a false positive, as `fg->best_input` is only ever
written by the filter thread - so there's zero risk of concurrent write with
this read. However, coverity seems to not be aware of this fact. To be honest,
I'm not sure why it didn't trigger before, but possibly because the only
other writing location before was in the same function, so maybe it was
smart enough to understand that it can't race with itself.
A mutex is nowehere near expensive enough that this once-per-frame extra
lock/unlock is going to be in any way measurable.
From 8248d22720e36edf1fc04269e047c5218526f14d Mon Sep 17 00:00:00 2001
From: Niklas Haas <git(a)haasn.dev>
Date: Wed, 1 Oct 2025 18:15:48 +0200
Subject: [PATCH] fftools: silence coverity race condition warning
Avoids the following Coverity warning:
> CID 1666425: Concurrent data access violations (MISSING_LOCK)
> Accessing "fg->best_input" without holding lock "Scheduler.schedule_lock".
> Elsewhere, "SchFilterGraph.best_input" is written to with
> "Scheduler.schedule_lock" held 2 out of 2 times (2 of these accesses
> strongly imply that it is necessary).
I'm pretty sure this is a false positive, as `fg->best_input` is only ever
written by the filter thread - so there's zero risk of concurrent write with
this read. However, coverity seems to not be aware of this fact. To be honest,
I'm not sure why it didn't trigger before, but possibly because the only
other writing location before was in the same function, so maybe it was
smart enough to understand that it can't race with itself.
A mutex is nowehere near expensive enough that this once-per-frame extra
lock/unlock is going to be in any way measurable.
---
fftools/ffmpeg_sched.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/fftools/ffmpeg_sched.c b/fftools/ffmpeg_sched.c
index d08f4a061d..5c52779588 100644
--- a/fftools/ffmpeg_sched.c
+++ b/fftools/ffmpeg_sched.c
@@ -2445,19 +2445,16 @@ int sch_filter_receive(Scheduler *sch, unsigned fg_idx,
av_assert0(*in_idx <= fg->nb_inputs);
- // update scheduling to account for desired input stream, if it changed
- //
- // this check needs no locking because only the filtering thread
- // updates this value
- if (*in_idx != fg->best_input) {
- pthread_mutex_lock(&sch->schedule_lock);
+ pthread_mutex_lock(&sch->schedule_lock);
+ // update scheduling to account for desired input stream, if it changed
+ if (*in_idx != fg->best_input) {
fg->best_input = *in_idx;
schedule_update_locked(sch);
-
- pthread_mutex_unlock(&sch->schedule_lock);
}
+ pthread_mutex_unlock(&sch->schedule_lock);
+
if (*in_idx == fg->nb_inputs) {
int terminate = waiter_wait(sch, &fg->waiter);
return terminate ? AVERROR_EOF : AVERROR(EAGAIN);
--
2.49.1
1
0