ffmpeg-devel
Threads by month
- ----- 2026 -----
- 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 #20797 opened by desmondliu
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20797
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20797.patch
Last parameter to recvfrom() is not initialized, causing
recvfrom() to randomly return EINVAL. Issue was introduced in
af04a27893.
From 4348bde2d2c58a2409c277f487541be00a5f61f6 Mon Sep 17 00:00:00 2001
From: Desmond Liu <desmond.liu(a)netint.ca>
Date: Thu, 30 Oct 2025 17:22:12 -0700
Subject: [PATCH] libavformat/udp: Fix call to recvfrom(2)
Last parameter to recvfrom() is not initialized, causing
recvfrom() to randomly return EINVAL. Issue was introduced in
af04a27893.
---
libavformat/udp.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/libavformat/udp.c b/libavformat/udp.c
index 87a9d5d431..61e80c86c5 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -543,6 +543,7 @@ static void *circular_buffer_task_rx( void *_URLContext)
}
while(1) {
UDPQueuedPacketHeader pkt_header;
+ pkt_header.addr_len = sizeof(pkt_header.addr);
pthread_mutex_unlock(&s->mutex);
/* Blocking operations are always cancellation points;
--
2.49.1
1
0
[PATCH] avformat/rtmpproto: consider command line argument lengths (PR #20796)
by michaelni 30 Oct '25
by michaelni 30 Oct '25
30 Oct '25
PR #20796 opened by michaelni
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20796
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20796.patch
From 844511d76807d4ad2b248540b20f534bc640540c Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <michael(a)niedermayer.cc>
Date: Thu, 30 Oct 2025 23:05:57 +0100
Subject: [PATCH 1/2] avformat/rtmpproto_ Check tcurl and flashver length
Fixes: out of array accesses
Signed-off-by: Michael Niedermayer <michael(a)niedermayer.cc>
---
libavformat/rtmpproto.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index 4f866eb76c..5de3bebc62 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -2859,6 +2859,12 @@ reconnect:
"FMLE/3.0 (compatible; %s)", LIBAVFORMAT_IDENT);
}
}
+ if ( strlen(rt->flashver) > FLASHVER_MAX_LENGTH
+ || strlen(rt->tcurl ) > TCURL_MAX_LENGTH
+ ) {
+ ret = AVERROR(EINVAL);
+ goto fail;
+ }
rt->receive_report_size = 1048576;
rt->bytes_read = 0;
--
2.49.1
From 708ab1bc8ee6e6c28005b3bc219bc7fc0b693b16 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <michael(a)niedermayer.cc>
Date: Thu, 30 Oct 2025 23:20:41 +0100
Subject: [PATCH 2/2] avformat/rtmpproto: consider command line argument
lengths
Fixes: out of array access
Fixes: zeropath/rtmp-2025-10
Found-by: Joshua Rogers <joshua(a)joshua.hu>
Signed-off-by: Michael Niedermayer <michael(a)niedermayer.cc>
---
libavformat/rtmpproto.c | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index 5de3bebc62..b029c57621 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -163,6 +163,13 @@ static int handle_chunk_size(URLContext *s, RTMPPacket *pkt);
static int handle_window_ack_size(URLContext *s, RTMPPacket *pkt);
static int handle_set_peer_bw(URLContext *s, RTMPPacket *pkt);
+static size_t zstrlen(const char *c)
+{
+ if(c)
+ return strlen(c);
+ return 0;
+}
+
static int add_tracked_method(RTMPContext *rt, const char *name, int id)
{
int err;
@@ -327,7 +334,16 @@ static int gen_connect(URLContext *s, RTMPContext *rt)
int ret;
if ((ret = ff_rtmp_packet_create(&pkt, RTMP_SYSTEM_CHANNEL, RTMP_PT_INVOKE,
- 0, 4096 + APP_MAX_LENGTH)) < 0)
+ 0, 4096 + APP_MAX_LENGTH
+ + strlen(rt->auth_params) + strlen(rt->flashver)
+ + zstrlen(rt->enhanced_codecs)/5*7
+ + zstrlen(rt->swfurl)
+ + zstrlen(rt->swfverify)
+ + zstrlen(rt->tcurl)
+ + zstrlen(rt->auth_params)
+ + zstrlen(rt->pageurl)
+ + zstrlen(rt->conn)*3
+ )) < 0)
return ret;
p = pkt.data;
@@ -1926,7 +1942,9 @@ static int write_status(URLContext *s, RTMPPacket *pkt,
if ((ret = ff_rtmp_packet_create(&spkt, RTMP_SYSTEM_CHANNEL,
RTMP_PT_INVOKE, 0,
- RTMP_PKTDATA_DEFAULT_SIZE)) < 0) {
+ RTMP_PKTDATA_DEFAULT_SIZE
+ + strlen(status) + strlen(description)
+ + zstrlen(details))) < 0) {
av_log(s, AV_LOG_ERROR, "Unable to create response packet\n");
return ret;
}
--
2.49.1
1
0
PR #20795 opened by Manuel Lauss (mlauss2)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20795
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20795.patch
This is another post-processing codec: it sums the r/g/b componentes
of the 4 surrounding pixels, and uses the 15bit-rgb value as an index into
a second table to find a matching pixel.
It is only used in the first 10-20 frames of the Rebel Assault 2 LxxRETRY.SAN files
to slightly blur the outline of the "opening aperture" effect.
Signed-off-by: Manuel Lauss <manuel.lauss(a)gmail.com>
From 137913ee994bf18fd3444b76893237474ec93ef4 Mon Sep 17 00:00:00 2001
From: Manuel Lauss <manuel.lauss(a)gmail.com>
Date: Thu, 30 Oct 2025 16:01:10 +0100
Subject: [PATCH] avcodec/sanm: implement codec45
This is another post-processing codec: it sums the r/g/b componentes
of the 4 surrounding pixels, and uses the 15bit-rgb value as an index into
a second table to find a matching pixel.
It is only used in 10-20 frames of the Rebel Assault 2 LxxRETRY.SAN files
to slightly blur the outline of the "opening aperture" effect.
Signed-off-by: Manuel Lauss <manuel.lauss(a)gmail.com>
---
libavcodec/sanm.c | 77 +++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 75 insertions(+), 2 deletions(-)
diff --git a/libavcodec/sanm.c b/libavcodec/sanm.c
index 742fc1d477..1d04edc672 100644
--- a/libavcodec/sanm.c
+++ b/libavcodec/sanm.c
@@ -297,6 +297,8 @@ typedef struct SANMVideoContext {
uint8_t c4tbl[2][256][16];
uint16_t c4param;
uint8_t c47cb[4];
+ uint8_t c45tbl1[0x300];
+ uint8_t c45tbl2[0x8000];
} SANMVideoContext;
enum GlyphEdge {
@@ -1946,6 +1948,71 @@ static int old_codec48(SANMVideoContext *ctx, GetByteContext *gb, int top, int l
return 0;
}
+static void old_codec45(SANMVideoContext *ctx, GetByteContext *gb, int top, int left, int flag)
+{
+ int t1, t2, i;
+ int16_t x, y;
+
+ if (bytestream2_get_bytes_left(gb) < 6)
+ return;
+
+ bytestream2_skip(gb, 2);
+ t1 = bytestream2_get_le16u(gb);
+ t2 = bytestream2_get_byteu(gb);
+ bytestream2_skip(gb, 1);
+ if (t2 != 1)
+ return;
+ if (t1 == 0) {
+ if (bytestream2_get_bytes_left(gb) < 0x300)
+ return;
+ bytestream2_get_bufferu(gb, ctx->c45tbl1, 0x300);
+ i = 0;
+ while ((bytestream2_get_bytes_left(gb) > 1) && (i < 0x8000)) {
+ uint8_t len = bytestream2_get_byteu(gb);
+ uint8_t val = bytestream2_get_byteu(gb);
+ if ((i + len) > 0x8000)
+ len = 0x8000 - i;
+ memset(ctx->c45tbl2 + i, val, len);
+ i += len;
+ }
+ }
+
+ if (flag)
+ return;
+
+ x = left;
+ y = top;
+ while (bytestream2_get_bytes_left(gb) > 3) {
+ int16_t xd = bytestream2_get_le16u(gb);
+ int8_t yd = bytestream2_get_byteu(gb);
+ x += xd;
+ y += yd;
+ int len = bytestream2_get_byteu(gb);
+ while (len >= 0) {
+ if ((x > 0) && (y > 0) && (x < ctx->width - 1)) {
+ if (y >= ctx->height)
+ return;
+
+ uint8_t *dst = (uint8_t *)ctx->fbuf + x + y * ctx->pitch;
+ unsigned int c1 = *(dst - 1) * 3;
+ unsigned int c2 = *(dst + 1) * 3;
+ unsigned int r = ctx->c45tbl1[c1 + 0] + ctx->c45tbl1[c2 + 0];
+ unsigned int g = ctx->c45tbl1[c1 + 1] + ctx->c45tbl1[c2 + 1];
+ unsigned int b = ctx->c45tbl1[c1 + 2] + ctx->c45tbl1[c2 + 2];
+ c1 = *(dst - ctx->pitch) * 3;
+ c2 = *(dst + ctx->pitch) * 3;
+ r += ctx->c45tbl1[c1 + 0] + ctx->c45tbl1[c2 + 0];
+ g += ctx->c45tbl1[c1 + 1] + ctx->c45tbl1[c2 + 1];
+ b += ctx->c45tbl1[c1 + 2] + ctx->c45tbl1[c2 + 2];
+ *dst = ctx->c45tbl2[((r << 5) & 0x7c00) | (g & 0x3e0) | (b >> 5)];
+ }
+ x++;
+ len--;
+ }
+ x--;
+ }
+}
+
static int process_frame_obj(SANMVideoContext *ctx, GetByteContext *gb,
int xoff, int yoff)
{
@@ -1964,6 +2031,12 @@ static int process_frame_obj(SANMVideoContext *ctx, GetByteContext *gb,
parm2 = bytestream2_get_le16u(gb);
if (w < 1 || h < 1 || w > 640 || h > 480 || left > 640 || top > 480 || left + w <= 0 || top + h <= 0) {
+ /* codec45 frames with data for the 2 tables have nonsensical dimensions */
+ if (codec == 45) {
+ old_codec45(ctx, gb, 0, 0, 1);
+ return 0;
+ }
+
av_log(ctx->avctx, AV_LOG_WARNING,
"ignoring invalid fobj dimensions: c%d %d %d @ %d %d\n",
codec, w, h, left, top);
@@ -1980,7 +2053,7 @@ static int process_frame_obj(SANMVideoContext *ctx, GetByteContext *gb,
if ((w == 640) && (h == 272) && (top == 60) && (codec == 47))
left = top = 0;
- if (!ctx->have_dimensions) {
+ if (!ctx->have_dimensions && (codec != 45)) {
int xres, yres;
if (ctx->subversion < 2) {
/* Rebel Assault 1: 384x242 internal size */
@@ -2073,7 +2146,7 @@ static int process_frame_obj(SANMVideoContext *ctx, GetByteContext *gb,
case 37:
return old_codec37(ctx, gb, top, left, w, h); break;
case 45:
- return 0;
+ old_codec45(ctx, gb, top, left, 0); break;
case 47:
return old_codec47(ctx, gb, top, left, w, h); break;
case 48:
--
2.49.1
1
0
This was broken by dc7bd7c5a5 because it was depending on the behaviour
of all frames setting key_frame by default, although that was also wrong
because it didn't unset the flag for duplicate/repeated frames.
Signed-off-by: Jeremy James <jeremy.james(a)gmail.com>
---
libavcodec/qtrle.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/libavcodec/qtrle.c b/libavcodec/qtrle.c
index 1c2fbc357e..c8bee8ce44 100644
--- a/libavcodec/qtrle.c
+++ b/libavcodec/qtrle.c
@@ -557,6 +557,10 @@ done:
if ((ret = av_frame_ref(rframe, s->frame)) < 0)
return ret;
+
+ rframe->pict_type = !duplicate ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
+ rframe->flags = AV_FRAME_FLAG_KEY * !duplicate;
+
*got_frame = 1;
/* always report that the buffer was completely consumed */
--
2.43.0
1
0
[PATCH] All: Removed reliance on compiler performing dead code elimination, changed various macro constant checks from if() to #if (PR #20794)
by death 30 Oct '25
by death 30 Oct '25
30 Oct '25
PR #20794 opened by death
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20794
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20794.patch
https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/20763
No-dead-code-elimination patch, try 2
Verified on various MSVC configurations: x86_32, x86_64, ARM64.
Most changes deal with x86 code checking for ARCH_X86_64 and failing to link on x86_32.
From 4d5a97dd54fa9e69d095205bb5a9a3b699c13850 Mon Sep 17 00:00:00 2001
From: Piotr Pawlowski <p(a)perkele.cc>
Date: Thu, 30 Oct 2025 14:41:40 +0100
Subject: [PATCH] All: Removed reliance on compiler performing dead code
elimination, changed various macro constant checks from if() to #if
---
libavcodec/avcodec.c | 5 +-
libavcodec/encode.c | 17 +++---
libavcodec/x86/flacdsp_init.c | 16 ++++--
libavcodec/x86/hevc/dsp_init.c | 84 +++++++++++++++-------------
libavcodec/x86/idctdsp_init.c | 9 ++-
libavcodec/x86/mlpdsp_init.c | 6 +-
libavcodec/x86/v210-init.c | 24 +++++---
libavcodec/x86/v210enc_init.c | 3 +-
libavfilter/x86/colorspacedsp_init.c | 4 +-
libavfilter/x86/f_ebur128_init.c | 4 +-
libavfilter/x86/vf_atadenoise_init.c | 6 +-
libavfilter/x86/vf_bwdif_init.c | 12 ++--
libavfilter/x86/vf_nlmeans_init.c | 4 +-
libavfilter/x86/vf_ssim_init.c | 4 +-
libavfilter/x86/vf_w3fdif_init.c | 4 +-
15 files changed, 125 insertions(+), 77 deletions(-)
diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index 0355b7c338..6ef506a4fc 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -438,10 +438,11 @@ av_cold void ff_codec_close(AVCodecContext *avctx)
if (avcodec_is_open(avctx)) {
AVCodecInternal *avci = avctx->internal;
- if (CONFIG_FRAME_THREAD_ENCODER &&
- avci->frame_thread_encoder && avctx->thread_count > 1) {
+#if CONFIG_FRAME_THREAD_ENCODER
+ if (avci->frame_thread_encoder && avctx->thread_count > 1) {
ff_frame_thread_encoder_free(avctx);
}
+#endif
if (HAVE_THREADS && avci->thread_ctx)
ff_thread_free(avctx);
if (avci->needs_close && ffcodec(avctx->codec)->close)
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 1eca5e38c1..728b5a8c0b 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -316,12 +316,13 @@ static int encode_simple_internal(AVCodecContext *avctx, AVPacket *avpkt)
av_assert0(codec->cb_type == FF_CODEC_CB_TYPE_ENCODE);
- if (CONFIG_FRAME_THREAD_ENCODER && avci->frame_thread_encoder)
+#if CONFIG_FRAME_THREAD_ENCODER
+ if (avci->frame_thread_encoder)
/* This will unref frame. */
ret = ff_thread_video_encode_frame(avctx, avpkt, frame, &got_packet);
- else {
+ else
+#endif
ret = ff_encode_encode_cb(avctx, avpkt, frame, &got_packet);
- }
if (avci->draining && !got_packet)
avci->draining_done = 1;
@@ -824,11 +825,11 @@ int ff_encode_preinit(AVCodecContext *avctx)
memcpy(sd_packet->data, sd_frame->data, sd_frame->size);
}
- if (CONFIG_FRAME_THREAD_ENCODER) {
- ret = ff_frame_thread_encoder_init(avctx);
- if (ret < 0)
- return ret;
- }
+#if CONFIG_FRAME_THREAD_ENCODER
+ ret = ff_frame_thread_encoder_init(avctx);
+ if (ret < 0)
+ return ret;
+#endif
return 0;
}
diff --git a/libavcodec/x86/flacdsp_init.c b/libavcodec/x86/flacdsp_init.c
index fa993d3466..386955ba67 100644
--- a/libavcodec/x86/flacdsp_init.c
+++ b/libavcodec/x86/flacdsp_init.c
@@ -85,8 +85,10 @@ av_cold void ff_flacdsp_init_x86(FLACDSPContext *c, enum AVSampleFormat fmt, int
c->decorrelate[0] = ff_flac_decorrelate_indep4_16_ssse3;
else if (channels == 6)
c->decorrelate[0] = ff_flac_decorrelate_indep6_16_ssse3;
- else if (ARCH_X86_64 && channels == 8)
+#if ARCH_X86_64
+ else if (channels == 8)
c->decorrelate[0] = ff_flac_decorrelate_indep8_16_ssse3;
+#endif
} else if (fmt == AV_SAMPLE_FMT_S32) {
if (channels == 2)
c->decorrelate[0] = ff_flac_decorrelate_indep2_32_ssse3;
@@ -94,8 +96,10 @@ av_cold void ff_flacdsp_init_x86(FLACDSPContext *c, enum AVSampleFormat fmt, int
c->decorrelate[0] = ff_flac_decorrelate_indep4_32_ssse3;
else if (channels == 6)
c->decorrelate[0] = ff_flac_decorrelate_indep6_32_ssse3;
- else if (ARCH_X86_64 && channels == 8)
+#if ARCH_X86_64
+ else if (channels == 8)
c->decorrelate[0] = ff_flac_decorrelate_indep8_32_ssse3;
+#endif
}
}
if (EXTERNAL_SSE4(cpu_flags)) {
@@ -105,15 +109,19 @@ av_cold void ff_flacdsp_init_x86(FLACDSPContext *c, enum AVSampleFormat fmt, int
}
if (EXTERNAL_AVX(cpu_flags)) {
if (fmt == AV_SAMPLE_FMT_S16) {
- if (ARCH_X86_64 && channels == 8)
+#if ARCH_X86_64
+ if (channels == 8)
c->decorrelate[0] = ff_flac_decorrelate_indep8_16_avx;
+#endif
} else if (fmt == AV_SAMPLE_FMT_S32) {
if (channels == 4)
c->decorrelate[0] = ff_flac_decorrelate_indep4_32_avx;
else if (channels == 6)
c->decorrelate[0] = ff_flac_decorrelate_indep6_32_avx;
- else if (ARCH_X86_64 && channels == 8)
+#if ARCH_X86_64
+ else if (channels == 8)
c->decorrelate[0] = ff_flac_decorrelate_indep8_32_avx;
+#endif
}
}
if (EXTERNAL_XOP(cpu_flags)) {
diff --git a/libavcodec/x86/hevc/dsp_init.c b/libavcodec/x86/hevc/dsp_init.c
index 6966340c42..3d568016e7 100644
--- a/libavcodec/x86/hevc/dsp_init.c
+++ b/libavcodec/x86/hevc/dsp_init.c
@@ -821,13 +821,13 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth)
if (EXTERNAL_SSE2(cpu_flags)) {
c->hevc_v_loop_filter_chroma = ff_hevc_v_loop_filter_chroma_8_sse2;
c->hevc_h_loop_filter_chroma = ff_hevc_h_loop_filter_chroma_8_sse2;
- if (ARCH_X86_64) {
- c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_8_sse2;
- c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_8_sse2;
+#if ARCH_X86_64
+ c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_8_sse2;
+ c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_8_sse2;
- c->idct[2] = ff_hevc_idct_16x16_8_sse2;
- c->idct[3] = ff_hevc_idct_32x32_8_sse2;
- }
+ c->idct[2] = ff_hevc_idct_16x16_8_sse2;
+ c->idct[3] = ff_hevc_idct_32x32_8_sse2;
+#endif
SAO_BAND_INIT(8, sse2);
c->idct_dc[0] = ff_hevc_idct_4x4_dc_8_sse2;
@@ -843,10 +843,10 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth)
c->add_residual[3] = ff_hevc_add_residual_32_8_sse2;
}
if (EXTERNAL_SSSE3(cpu_flags)) {
- if(ARCH_X86_64) {
- c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_8_ssse3;
- c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_8_ssse3;
- }
+#if ARCH_X86_64
+ c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_8_ssse3;
+ c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_8_ssse3;
+#endif
SAO_EDGE_INIT(8, ssse3);
}
#if HAVE_SSE4_EXTERNAL && ARCH_X86_64
@@ -866,13 +866,13 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth)
if (EXTERNAL_AVX(cpu_flags)) {
c->hevc_v_loop_filter_chroma = ff_hevc_v_loop_filter_chroma_8_avx;
c->hevc_h_loop_filter_chroma = ff_hevc_h_loop_filter_chroma_8_avx;
- if (ARCH_X86_64) {
- c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_8_avx;
- c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_8_avx;
+#if ARCH_X86_64
+ c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_8_avx;
+ c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_8_avx;
- c->idct[2] = ff_hevc_idct_16x16_8_avx;
- c->idct[3] = ff_hevc_idct_32x32_8_avx;
- }
+ c->idct[2] = ff_hevc_idct_16x16_8_avx;
+ c->idct[3] = ff_hevc_idct_32x32_8_avx;
+#endif
SAO_BAND_INIT(8, avx);
c->idct[0] = ff_hevc_idct_4x4_8_avx;
@@ -986,7 +986,8 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth)
c->add_residual[3] = ff_hevc_add_residual_32_8_avx2;
}
#endif /* HAVE_AVX2_EXTERNAL */
- if (EXTERNAL_AVX512ICL(cpu_flags) && ARCH_X86_64) {
+#if ARCH_X86_64
+ if (EXTERNAL_AVX512ICL(cpu_flags)) {
c->put_hevc_qpel[1][0][1] = ff_hevc_put_qpel_h4_8_avx512icl;
c->put_hevc_qpel[3][0][1] = ff_hevc_put_qpel_h8_8_avx512icl;
c->put_hevc_qpel[5][0][1] = ff_hevc_put_qpel_h16_8_avx512icl;
@@ -994,6 +995,7 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth)
c->put_hevc_qpel[9][0][1] = ff_hevc_put_qpel_h64_8_avx512icl;
c->put_hevc_qpel[3][1][1] = ff_hevc_put_qpel_hv8_8_avx512icl;
}
+#endif
} else if (bit_depth == 10) {
if (EXTERNAL_MMXEXT(cpu_flags)) {
c->add_residual[0] = ff_hevc_add_residual_4_10_mmxext;
@@ -1001,13 +1003,13 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth)
if (EXTERNAL_SSE2(cpu_flags)) {
c->hevc_v_loop_filter_chroma = ff_hevc_v_loop_filter_chroma_10_sse2;
c->hevc_h_loop_filter_chroma = ff_hevc_h_loop_filter_chroma_10_sse2;
- if (ARCH_X86_64) {
- c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_10_sse2;
- c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_10_sse2;
+#if ARCH_X86_64
+ c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_10_sse2;
+ c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_10_sse2;
- c->idct[2] = ff_hevc_idct_16x16_10_sse2;
- c->idct[3] = ff_hevc_idct_32x32_10_sse2;
- }
+ c->idct[2] = ff_hevc_idct_16x16_10_sse2;
+ c->idct[3] = ff_hevc_idct_32x32_10_sse2;
+#endif
SAO_BAND_INIT(10, sse2);
SAO_EDGE_INIT(10, sse2);
@@ -1023,10 +1025,12 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth)
c->add_residual[2] = ff_hevc_add_residual_16_10_sse2;
c->add_residual[3] = ff_hevc_add_residual_32_10_sse2;
}
- if (EXTERNAL_SSSE3(cpu_flags) && ARCH_X86_64) {
+#if ARCH_X86_64
+ if (EXTERNAL_SSSE3(cpu_flags)) {
c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_10_ssse3;
c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_10_ssse3;
}
+#endif
#if HAVE_SSE4_EXTERNAL && ARCH_X86_64
if (EXTERNAL_SSE4(cpu_flags)) {
EPEL_LINKS(c->put_hevc_epel, 0, 0, pel_pixels, 10, sse4);
@@ -1043,13 +1047,13 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth)
if (EXTERNAL_AVX(cpu_flags)) {
c->hevc_v_loop_filter_chroma = ff_hevc_v_loop_filter_chroma_10_avx;
c->hevc_h_loop_filter_chroma = ff_hevc_h_loop_filter_chroma_10_avx;
- if (ARCH_X86_64) {
- c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_10_avx;
- c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_10_avx;
+#if ARCH_X86_64
+ c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_10_avx;
+ c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_10_avx;
- c->idct[2] = ff_hevc_idct_16x16_10_avx;
- c->idct[3] = ff_hevc_idct_32x32_10_avx;
- }
+ c->idct[2] = ff_hevc_idct_16x16_10_avx;
+ c->idct[3] = ff_hevc_idct_32x32_10_avx;
+#endif
c->idct[0] = ff_hevc_idct_4x4_10_avx;
c->idct[1] = ff_hevc_idct_8x8_10_avx;
@@ -1220,10 +1224,10 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth)
if (EXTERNAL_SSE2(cpu_flags)) {
c->hevc_v_loop_filter_chroma = ff_hevc_v_loop_filter_chroma_12_sse2;
c->hevc_h_loop_filter_chroma = ff_hevc_h_loop_filter_chroma_12_sse2;
- if (ARCH_X86_64) {
- c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_12_sse2;
- c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_12_sse2;
- }
+#if ARCH_X86_64
+ c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_12_sse2;
+ c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_12_sse2;
+#endif
SAO_BAND_INIT(12, sse2);
SAO_EDGE_INIT(12, sse2);
@@ -1232,10 +1236,12 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth)
c->idct_dc[2] = ff_hevc_idct_16x16_dc_12_sse2;
c->idct_dc[3] = ff_hevc_idct_32x32_dc_12_sse2;
}
- if (EXTERNAL_SSSE3(cpu_flags) && ARCH_X86_64) {
+#if ARCH_X86_64
+ if (EXTERNAL_SSSE3(cpu_flags)) {
c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_12_ssse3;
c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_12_ssse3;
}
+#endif
#if HAVE_SSE4_EXTERNAL && ARCH_X86_64
if (EXTERNAL_SSE4(cpu_flags)) {
EPEL_LINKS(c->put_hevc_epel, 0, 0, pel_pixels, 12, sse4);
@@ -1252,10 +1258,10 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth)
if (EXTERNAL_AVX(cpu_flags)) {
c->hevc_v_loop_filter_chroma = ff_hevc_v_loop_filter_chroma_12_avx;
c->hevc_h_loop_filter_chroma = ff_hevc_h_loop_filter_chroma_12_avx;
- if (ARCH_X86_64) {
- c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_12_avx;
- c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_12_avx;
- }
+#if ARCH_X86_64
+ c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_12_avx;
+ c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_12_avx;
+#endif
SAO_BAND_INIT(12, avx);
}
if (EXTERNAL_AVX2(cpu_flags)) {
diff --git a/libavcodec/x86/idctdsp_init.c b/libavcodec/x86/idctdsp_init.c
index 2d165b975b..d58056ef29 100644
--- a/libavcodec/x86/idctdsp_init.c
+++ b/libavcodec/x86/idctdsp_init.c
@@ -94,8 +94,8 @@ av_cold void ff_idctdsp_init_x86(IDCTDSPContext *c, AVCodecContext *avctx,
}
#endif
- if (ARCH_X86_64 &&
- !high_bit_depth &&
+#if ARCH_X86_64
+ if (!high_bit_depth &&
avctx->lowres == 0 &&
(avctx->idct_algo == FF_IDCT_AUTO ||
avctx->idct_algo == FF_IDCT_SIMPLEAUTO ||
@@ -106,9 +106,11 @@ av_cold void ff_idctdsp_init_x86(IDCTDSPContext *c, AVCodecContext *avctx,
c->idct_add = ff_simple_idct8_add_sse2;
c->perm_type = FF_IDCT_PERM_TRANSPOSE;
}
+#endif
}
- if (ARCH_X86_64 && avctx->lowres == 0) {
+#if ARCH_X86_64
+ if (avctx->lowres == 0) {
if (EXTERNAL_AVX(cpu_flags) &&
!high_bit_depth &&
(avctx->idct_algo == FF_IDCT_AUTO ||
@@ -158,4 +160,5 @@ av_cold void ff_idctdsp_init_x86(IDCTDSPContext *c, AVCodecContext *avctx,
}
}
}
+#endif
}
diff --git a/libavcodec/x86/mlpdsp_init.c b/libavcodec/x86/mlpdsp_init.c
index 950f996832..21a0e38143 100644
--- a/libavcodec/x86/mlpdsp_init.c
+++ b/libavcodec/x86/mlpdsp_init.c
@@ -200,8 +200,10 @@ av_cold void ff_mlpdsp_init_x86(MLPDSPContext *c)
if (INLINE_MMX(cpu_flags))
c->mlp_filter_channel = mlp_filter_channel_x86;
#endif
- if (ARCH_X86_64 && EXTERNAL_SSE4(cpu_flags))
+#if ARCH_X86_64
+ if (EXTERNAL_SSE4(cpu_flags))
c->mlp_rematrix_channel = ff_mlp_rematrix_channel_sse4;
- if (ARCH_X86_64 && EXTERNAL_AVX2_FAST(cpu_flags) && cpu_flags & AV_CPU_FLAG_BMI2)
+ if (EXTERNAL_AVX2_FAST(cpu_flags) && cpu_flags & AV_CPU_FLAG_BMI2)
c->mlp_rematrix_channel = ff_mlp_rematrix_channel_avx2_bmi2;
+#endif // ARCH_X86_64
}
diff --git a/libavcodec/x86/v210-init.c b/libavcodec/x86/v210-init.c
index 8b3677b8aa..895cc8f329 100644
--- a/libavcodec/x86/v210-init.c
+++ b/libavcodec/x86/v210-init.c
@@ -38,28 +38,38 @@ av_cold void ff_v210_x86_init(V210DecContext *s)
if (s->aligned_input) {
if (cpu_flags & AV_CPU_FLAG_SSSE3)
s->unpack_frame = ff_v210_planar_unpack_aligned_ssse3;
-
- if (HAVE_AVX_EXTERNAL && cpu_flags & AV_CPU_FLAG_AVX)
+#if HAVE_AVX_EXTERNAL
+ if (cpu_flags & AV_CPU_FLAG_AVX)
s->unpack_frame = ff_v210_planar_unpack_aligned_avx;
+#endif
- if (HAVE_AVX2_EXTERNAL && cpu_flags & AV_CPU_FLAG_AVX2)
+#if HAVE_AVX2_EXTERNAL
+ if (cpu_flags & AV_CPU_FLAG_AVX2)
s->unpack_frame = ff_v210_planar_unpack_aligned_avx2;
+#endif
+#if HAVE_AVX512ICL_EXTERNAL
if (EXTERNAL_AVX512ICL(cpu_flags))
s->unpack_frame = ff_v210_planar_unpack_avx512icl;
+#endif
}
else {
if (cpu_flags & AV_CPU_FLAG_SSSE3)
s->unpack_frame = ff_v210_planar_unpack_unaligned_ssse3;
-
- if (HAVE_AVX_EXTERNAL && cpu_flags & AV_CPU_FLAG_AVX)
+#if HAVE_AVX_EXTERNAL
+ if (cpu_flags & AV_CPU_FLAG_AVX)
s->unpack_frame = ff_v210_planar_unpack_unaligned_avx;
+#endif
- if (HAVE_AVX2_EXTERNAL && cpu_flags & AV_CPU_FLAG_AVX2)
+#if HAVE_AVX2_EXTERNAL
+ if (cpu_flags & AV_CPU_FLAG_AVX2)
s->unpack_frame = ff_v210_planar_unpack_unaligned_avx2;
+#endif
+#if HAVE_AVX512ICL_EXTERNAL
if (EXTERNAL_AVX512ICL(cpu_flags))
s->unpack_frame = ff_v210_planar_unpack_avx512icl;
- }
#endif
+ }
+#endif // HAVE_X86ASM
}
diff --git a/libavcodec/x86/v210enc_init.c b/libavcodec/x86/v210enc_init.c
index 44f22ca7fe..8396ea7a0b 100644
--- a/libavcodec/x86/v210enc_init.c
+++ b/libavcodec/x86/v210enc_init.c
@@ -71,11 +71,12 @@ av_cold void ff_v210enc_init_x86(V210EncContext *s)
s->pack_line_10 = ff_v210_planar_pack_10_avx512;
#endif
}
-
+#if HAVE_AVX512ICL_EXTERNAL
if (EXTERNAL_AVX512ICL(cpu_flags)) {
s->sample_factor_8 = 4;
s->pack_line_8 = ff_v210_planar_pack_8_avx512icl;
s->sample_factor_10 = 4;
s->pack_line_10 = ff_v210_planar_pack_10_avx512icl;
}
+#endif
}
diff --git a/libavfilter/x86/colorspacedsp_init.c b/libavfilter/x86/colorspacedsp_init.c
index b5006ac295..429cc8bd26 100644
--- a/libavfilter/x86/colorspacedsp_init.c
+++ b/libavfilter/x86/colorspacedsp_init.c
@@ -78,9 +78,10 @@ void ff_multiply3x3_sse2(int16_t *data[3], ptrdiff_t stride, int w, int h,
void ff_colorspacedsp_x86_init(ColorSpaceDSPContext *dsp)
{
+#if ARCH_X86_64
int cpu_flags = av_get_cpu_flags();
- if (ARCH_X86_64 && EXTERNAL_SSE2(cpu_flags)) {
+ if (EXTERNAL_SSE2(cpu_flags)) {
#define assign_yuv2yuv_fns(ss) \
dsp->yuv2yuv[BPP_8 ][BPP_8 ][SS_##ss] = ff_yuv2yuv_##ss##p8to8_sse2; \
dsp->yuv2yuv[BPP_8 ][BPP_10][SS_##ss] = ff_yuv2yuv_##ss##p8to10_sse2; \
@@ -116,4 +117,5 @@ void ff_colorspacedsp_x86_init(ColorSpaceDSPContext *dsp)
dsp->multiply3x3 = ff_multiply3x3_sse2;
}
+#endif
}
diff --git a/libavfilter/x86/f_ebur128_init.c b/libavfilter/x86/f_ebur128_init.c
index 4a7109746d..ef700e8080 100644
--- a/libavfilter/x86/f_ebur128_init.c
+++ b/libavfilter/x86/f_ebur128_init.c
@@ -30,11 +30,13 @@ double ff_ebur128_find_peak_2ch_avx(double *, int, const double *, int);
av_cold void ff_ebur128_init_x86(EBUR128DSPContext *dsp, int nb_channels)
{
+#if ARCH_X86_64
int cpu_flags = av_get_cpu_flags();
- if (ARCH_X86_64 && EXTERNAL_AVX(cpu_flags)) {
+ if (EXTERNAL_AVX(cpu_flags)) {
dsp->filter_channels = ff_ebur128_filter_channels_avx;
if (nb_channels == 2)
dsp->find_peak = ff_ebur128_find_peak_2ch_avx;
}
+#endif
}
diff --git a/libavfilter/x86/vf_atadenoise_init.c b/libavfilter/x86/vf_atadenoise_init.c
index e7a653f191..3847e53250 100644
--- a/libavfilter/x86/vf_atadenoise_init.c
+++ b/libavfilter/x86/vf_atadenoise_init.c
@@ -36,15 +36,17 @@ void ff_atadenoise_filter_row8_serial_sse4(const uint8_t *src, uint8_t *dst,
av_cold void ff_atadenoise_init_x86(ATADenoiseDSPContext *dsp, int depth, int algorithm, const float *sigma)
{
+#if ARCH_X86_64
int cpu_flags = av_get_cpu_flags();
for (int p = 0; p < 4; p++) {
- if (ARCH_X86_64 && EXTERNAL_SSE4(cpu_flags) && depth <= 8 && algorithm == PARALLEL && sigma[p] == INT16_MAX) {
+ if (EXTERNAL_SSE4(cpu_flags) && depth <= 8 && algorithm == PARALLEL && sigma[p] == INT16_MAX) {
dsp->filter_row[p] = ff_atadenoise_filter_row8_sse4;
}
- if (ARCH_X86_64 && EXTERNAL_SSE4(cpu_flags) && depth <= 8 && algorithm == SERIAL && sigma[p] == INT16_MAX) {
+ if (EXTERNAL_SSE4(cpu_flags) && depth <= 8 && algorithm == SERIAL && sigma[p] == INT16_MAX) {
dsp->filter_row[p] = ff_atadenoise_filter_row8_serial_sse4;
}
}
+#endif
}
diff --git a/libavfilter/x86/vf_bwdif_init.c b/libavfilter/x86/vf_bwdif_init.c
index 76b574b2a9..51508ee771 100644
--- a/libavfilter/x86/vf_bwdif_init.c
+++ b/libavfilter/x86/vf_bwdif_init.c
@@ -67,18 +67,22 @@ av_cold void ff_bwdif_init_x86(BWDIFDSPContext *bwdif, int bit_depth)
bwdif->filter_line = ff_bwdif_filter_line_sse2;
if (EXTERNAL_SSSE3(cpu_flags))
bwdif->filter_line = ff_bwdif_filter_line_ssse3;
- if (ARCH_X86_64 && EXTERNAL_AVX2_FAST(cpu_flags))
+#if ARCH_X86_64
+ if (EXTERNAL_AVX2_FAST(cpu_flags))
bwdif->filter_line = ff_bwdif_filter_line_avx2;
- if (ARCH_X86_64 && EXTERNAL_AVX512ICL(cpu_flags))
+ if (EXTERNAL_AVX512ICL(cpu_flags))
bwdif->filter_line = ff_bwdif_filter_line_avx512icl;
+#endif
} else if (bit_depth <= 12) {
if (EXTERNAL_SSE2(cpu_flags))
bwdif->filter_line = ff_bwdif_filter_line_12bit_sse2;
if (EXTERNAL_SSSE3(cpu_flags))
bwdif->filter_line = ff_bwdif_filter_line_12bit_ssse3;
- if (ARCH_X86_64 && EXTERNAL_AVX2_FAST(cpu_flags))
+#if ARCH_X86_64
+ if (EXTERNAL_AVX2_FAST(cpu_flags))
bwdif->filter_line = ff_bwdif_filter_line_12bit_avx2;
- if (ARCH_X86_64 && EXTERNAL_AVX512ICL(cpu_flags))
+ if (EXTERNAL_AVX512ICL(cpu_flags))
bwdif->filter_line = ff_bwdif_filter_line_12bit_avx512icl;
+#endif
}
}
diff --git a/libavfilter/x86/vf_nlmeans_init.c b/libavfilter/x86/vf_nlmeans_init.c
index 37764d30ab..5d67090a98 100644
--- a/libavfilter/x86/vf_nlmeans_init.c
+++ b/libavfilter/x86/vf_nlmeans_init.c
@@ -33,8 +33,10 @@ void ff_compute_weights_line_avx2(const uint32_t *const iia,
av_cold void ff_nlmeans_init_x86(NLMeansDSPContext *dsp)
{
+#if ARCH_X86_64
int cpu_flags = av_get_cpu_flags();
- if (ARCH_X86_64 && EXTERNAL_AVX2_FAST(cpu_flags))
+ if (EXTERNAL_AVX2_FAST(cpu_flags))
dsp->compute_weights_line = ff_compute_weights_line_avx2;
+#endif
}
diff --git a/libavfilter/x86/vf_ssim_init.c b/libavfilter/x86/vf_ssim_init.c
index cbaa20ef16..6f2305430c 100644
--- a/libavfilter/x86/vf_ssim_init.c
+++ b/libavfilter/x86/vf_ssim_init.c
@@ -34,8 +34,10 @@ void ff_ssim_init_x86(SSIMDSPContext *dsp)
{
int cpu_flags = av_get_cpu_flags();
- if (ARCH_X86_64 && EXTERNAL_SSSE3(cpu_flags))
+#if ARCH_X86_64
+ if (EXTERNAL_SSSE3(cpu_flags))
dsp->ssim_4x4_line = ff_ssim_4x4_line_ssse3;
+#endif
if (EXTERNAL_SSE4(cpu_flags))
dsp->ssim_end_line = ff_ssim_end_line_sse4;
if (EXTERNAL_XOP(cpu_flags))
diff --git a/libavfilter/x86/vf_w3fdif_init.c b/libavfilter/x86/vf_w3fdif_init.c
index 16202fba76..6d677d651d 100644
--- a/libavfilter/x86/vf_w3fdif_init.c
+++ b/libavfilter/x86/vf_w3fdif_init.c
@@ -56,7 +56,9 @@ av_cold void ff_w3fdif_init_x86(W3FDIFDSPContext *dsp, int depth)
dsp->filter_scale = ff_w3fdif_scale_sse2;
}
- if (ARCH_X86_64 && EXTERNAL_SSE2(cpu_flags) && depth <= 8) {
+#if ARCH_X86_64
+ if (EXTERNAL_SSE2(cpu_flags) && depth <= 8) {
dsp->filter_complex_high = ff_w3fdif_complex_high_sse2;
}
+#endif
}
--
2.49.1
1
0
PR #20793 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20793
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20793.patch
This patchset is a proposal to get rid of our spec-incompliant reliance on dead code elimination. The key to it is a macro IF(CONFIG, cond, code) (code is actually ...) that expands to "if (cond) { code }" if CONFIG is 1 (as a preprocessor define) and "if (0 && cond) { }" if CONFIG is 0. What is your opinion on this?
From 88b95c6e7f52d4bc9e2a91e8a91c6a10ef3caab3 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Wed, 29 Oct 2025 19:19:49 +0100
Subject: [PATCH 01/34] avutil/x86/cpu: Remove {FMA3,AVX2,AVX}_SLOW macros
For both SSE2 and AVX, there are corresponding SLOW cpu flags,
so that for each of these instruction sets, there are four
potential states; in order of slowest to fastest, there are
a) both flags unset (instruction set unsupported),
b) only the slow flag set (instruction set supported, but so slow
that using it is not worthwhile)
c) slow flag and ordinary flag set
d) ordinary flag set
For AVX, the ordinary flag is never reset, so that the {FMA3,AVX2,AVX}_SLOW
macros are simply equivalent to the ordinary FMA3/AVX2/AVX macros
(except if one forced cpu flags). Therefore using them makes no sense
and unsurprisingly no one ever used them. So remove them.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavutil/x86/cpu.h | 5 -----
1 file changed, 5 deletions(-)
diff --git a/libavutil/x86/cpu.h b/libavutil/x86/cpu.h
index 00e82255b1..ff83d324a8 100644
--- a/libavutil/x86/cpu.h
+++ b/libavutil/x86/cpu.h
@@ -38,7 +38,6 @@
#define X86_SSE42(flags) CPUEXT(flags, SSE42)
#define X86_AVX(flags) CPUEXT(flags, AVX)
#define X86_AVX_FAST(flags) CPUEXT_FAST(flags, AVX)
-#define X86_AVX_SLOW(flags) CPUEXT_SLOW(flags, AVX)
#define X86_XOP(flags) CPUEXT(flags, XOP)
#define X86_FMA3(flags) CPUEXT(flags, FMA3)
#define X86_FMA4(flags) CPUEXT(flags, FMA4)
@@ -62,15 +61,12 @@
#define EXTERNAL_SSE42(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, SSE42)
#define EXTERNAL_AVX(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, AVX)
#define EXTERNAL_AVX_FAST(flags) CPUEXT_SUFFIX_FAST(flags, _EXTERNAL, AVX)
-#define EXTERNAL_AVX_SLOW(flags) CPUEXT_SUFFIX_SLOW(flags, _EXTERNAL, AVX)
#define EXTERNAL_XOP(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, XOP)
#define EXTERNAL_FMA3(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, FMA3)
#define EXTERNAL_FMA3_FAST(flags) CPUEXT_SUFFIX_FAST2(flags, _EXTERNAL, FMA3, AVX)
-#define EXTERNAL_FMA3_SLOW(flags) CPUEXT_SUFFIX_SLOW2(flags, _EXTERNAL, FMA3, AVX)
#define EXTERNAL_FMA4(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, FMA4)
#define EXTERNAL_AVX2(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, AVX2)
#define EXTERNAL_AVX2_FAST(flags) CPUEXT_SUFFIX_FAST2(flags, _EXTERNAL, AVX2, AVX)
-#define EXTERNAL_AVX2_SLOW(flags) CPUEXT_SUFFIX_SLOW2(flags, _EXTERNAL, AVX2, AVX)
#define EXTERNAL_AESNI(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, AESNI)
#define EXTERNAL_AVX512(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, AVX512)
#define EXTERNAL_AVX512ICL(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, AVX512ICL)
@@ -91,7 +87,6 @@
#define INLINE_SSE42(flags) CPUEXT_SUFFIX(flags, _INLINE, SSE42)
#define INLINE_AVX(flags) CPUEXT_SUFFIX(flags, _INLINE, AVX)
#define INLINE_AVX_FAST(flags) CPUEXT_SUFFIX_FAST(flags, _INLINE, AVX)
-#define INLINE_AVX_SLOW(flags) CPUEXT_SUFFIX_SLOW(flags, _INLINE, AVX)
#define INLINE_XOP(flags) CPUEXT_SUFFIX(flags, _INLINE, XOP)
#define INLINE_FMA3(flags) CPUEXT_SUFFIX(flags, _INLINE, FMA3)
#define INLINE_FMA4(flags) CPUEXT_SUFFIX(flags, _INLINE, FMA4)
--
2.49.1
From 7787a70221bb81fc387bbe0f83e57b2945b18c55 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Wed, 29 Oct 2025 19:59:03 +0100
Subject: [PATCH 02/34] avcodec/x86/cpu: Remove SSE2_FAST macros
Some CPUs support SSE2, but only so slow that sometimes MMX(EXT)
functions are faster. The SSE2_FAST macros exist to set some
dsp functions only if they are faster than MMX(EXT).
Yet this rationale no longer applies nowadays, because MMX(EXT)
functions are removed when overridden by SSE2 functions.
Consequently, it is no longer used since
1f9ef6a8dc6e57b360cf53dd644fde1936ad3047. So remove the SSE2_FAST
macros.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavutil/x86/cpu.h | 3 ---
1 file changed, 3 deletions(-)
diff --git a/libavutil/x86/cpu.h b/libavutil/x86/cpu.h
index ff83d324a8..087b941795 100644
--- a/libavutil/x86/cpu.h
+++ b/libavutil/x86/cpu.h
@@ -26,7 +26,6 @@
#define X86_MMXEXT(flags) CPUEXT(flags, MMXEXT)
#define X86_SSE(flags) CPUEXT(flags, SSE)
#define X86_SSE2(flags) CPUEXT(flags, SSE2)
-#define X86_SSE2_FAST(flags) CPUEXT_FAST(flags, SSE2)
#define X86_SSE2_SLOW(flags) CPUEXT_SLOW(flags, SSE2)
#define X86_SSE3(flags) CPUEXT(flags, SSE3)
#define X86_SSE3_FAST(flags) CPUEXT_FAST(flags, SSE3)
@@ -49,7 +48,6 @@
#define EXTERNAL_MMXEXT(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, MMXEXT)
#define EXTERNAL_SSE(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, SSE)
#define EXTERNAL_SSE2(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, SSE2)
-#define EXTERNAL_SSE2_FAST(flags) CPUEXT_SUFFIX_FAST(flags, _EXTERNAL, SSE2)
#define EXTERNAL_SSE2_SLOW(flags) CPUEXT_SUFFIX_SLOW(flags, _EXTERNAL, SSE2)
#define EXTERNAL_SSE3(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, SSE3)
#define EXTERNAL_SSE3_FAST(flags) CPUEXT_SUFFIX_FAST(flags, _EXTERNAL, SSE3)
@@ -75,7 +73,6 @@
#define INLINE_MMXEXT(flags) CPUEXT_SUFFIX(flags, _INLINE, MMXEXT)
#define INLINE_SSE(flags) CPUEXT_SUFFIX(flags, _INLINE, SSE)
#define INLINE_SSE2(flags) CPUEXT_SUFFIX(flags, _INLINE, SSE2)
-#define INLINE_SSE2_FAST(flags) CPUEXT_SUFFIX_FAST(flags, _INLINE, SSE2)
#define INLINE_SSE2_SLOW(flags) CPUEXT_SUFFIX_SLOW(flags, _INLINE, SSE2)
#define INLINE_SSE3(flags) CPUEXT_SUFFIX(flags, _INLINE, SSE3)
#define INLINE_SSE3_FAST(flags) CPUEXT_SUFFIX_FAST(flags, _INLINE, SSE3)
--
2.49.1
From 82db8b3bea694d4dafb73ce490be4e6991d00737 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Wed, 29 Oct 2025 19:42:13 +0100
Subject: [PATCH 03/34] avutil/cpu_internal: Remove CPUEXT_SUFFIX_SLOW2
Unused.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavutil/cpu_internal.h | 4 ----
1 file changed, 4 deletions(-)
diff --git a/libavutil/cpu_internal.h b/libavutil/cpu_internal.h
index 8dca62334a..af2a9ceac4 100644
--- a/libavutil/cpu_internal.h
+++ b/libavutil/cpu_internal.h
@@ -34,10 +34,6 @@
(HAVE_ ## cpuext ## suffix && \
((flags) & (AV_CPU_FLAG_ ## cpuext | AV_CPU_FLAG_ ## cpuext ## SLOW)))
-#define CPUEXT_SUFFIX_SLOW2(flags, suffix, cpuext, slow_cpuext) \
- (HAVE_ ## cpuext ## suffix && ((flags) & AV_CPU_FLAG_ ## cpuext) && \
- ((flags) & (AV_CPU_FLAG_ ## slow_cpuext | AV_CPU_FLAG_ ## slow_cpuext ## SLOW)))
-
#define CPUEXT_SUFFIX_FAST(flags, suffix, cpuext) CPUEXT_SUFFIX_FAST2(flags, suffix, cpuext, cpuext)
#define CPUEXT(flags, cpuext) CPUEXT_SUFFIX(flags, , cpuext)
--
2.49.1
From 8d42504ab4c20fe76a38eb8b0492149767338db8 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Wed, 29 Oct 2025 21:00:12 +0100
Subject: [PATCH 04/34] avutil/cpu_internal: Add macros to avoid relying on DCE
These macros evaluate to "if (0 && cond) {}" if the relevant configure
condition (i.e. HAVE_SSE2_EXTERNAL) is false and to "if (cond) { code }"
if it is. They can be used to easily replace avoid most reliance on DCE;
the only exceptions to it are scenarios where "code" contains
preprocessor directives (i.e. #if blocks).
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavutil/cpu_internal.h | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/libavutil/cpu_internal.h b/libavutil/cpu_internal.h
index af2a9ceac4..7da8562cbf 100644
--- a/libavutil/cpu_internal.h
+++ b/libavutil/cpu_internal.h
@@ -23,6 +23,35 @@
#include "cpu.h"
+#define IF_1(cond, ...) if (cond) { __VA_ARGS__ }
+#define IF_0(cond, ...) if (0 && cond) {}
+#define IF_2(CONFIG_BOOL, cond, ...) IF_ ## CONFIG_BOOL (cond, __VA_ARGS__)
+
+#define IF(CONFIG, cond, ...) IF_2(CONFIG, (cond), __VA_ARGS__)
+
+#define IF_HAVE(FEATURE, cond, ...) IF(HAVE_ ## FEATURE, (cond), __VA_ARGS__)
+
+#define IF_CPUEXT_SUFFIX(flags, suffix, cpuext, ...) \
+ IF_HAVE(cpuext ## suffix, (flags) & AV_CPU_FLAG_ ## cpuext, __VA_ARGS__)
+
+#define IF_CPUEXT_SUFFIX_EXT(flags, suffix, cpuext, additional_cond, ...) \
+ IF_HAVE(cpuext ## suffix, ((flags) & AV_CPU_FLAG_ ## cpuext) && (additional_cond), __VA_ARGS__)
+
+#define IF_CPUEXT_SUFFIX_FAST2(flags, suffix, cpuext, slow_cpuext, ...) \
+ IF_HAVE(cpuext ## suffix, ((flags) & AV_CPU_FLAG_ ## cpuext) && \
+ !((flags) & AV_CPU_FLAG_ ## slow_cpuext ## SLOW), __VA_ARGS__)
+
+#define IF_CPUEXT_SUFFIX_SLOW(flags, suffix, cpuext, slow_cpuext, ...) \
+ IF_HAVE(cpuext ## suffix, \
+ (flags) & (AV_CPU_FLAG_ ## cpuext | AV_CPU_FLAG_ ## cpuext ## SLOW), __VA_ARGS__)
+
+#define IF_CPUEXT_SUFFIX_FAST(flags, suffix, cpuext, ...) \
+ IF_CPUEXT_SUFFIX_FAST2(flags, suffix, cpuext, cpuext, __VA_ARGS__)
+
+#define IF_CPUEXT(flags, cpuext, ...) IF_CPUEXT_SUFFIX (flags, , cpuext, __VA_ARGS__)
+#define IF_CPUEXT_FAST(flags, cpuext, ...) IF_CPUEXT_SUFFIX_FAST(flags, , cpuext, __VA_ARGS__)
+#define IF_CPUEXT_SLOW(flags, cpuext, ...) IF_CPUEXT_SUFFIX_SLOW(flags, , cpuext, __VA_ARGS__)
+
#define CPUEXT_SUFFIX(flags, suffix, cpuext) \
(HAVE_ ## cpuext ## suffix && ((flags) & AV_CPU_FLAG_ ## cpuext))
--
2.49.1
From 881714ed8d51c26e71b11b57251e7d0edf4b8068 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Wed, 29 Oct 2025 21:22:21 +0100
Subject: [PATCH 05/34] avutil/x86/cpu: Add macros to avoid reliance on DCE
This here mimics the existing EXTERNAL_ macros;
it would also be possible to use a macro
like IF_EXTERNAL(cpuext, flags, ...).
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavutil/x86/cpu.h | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/libavutil/x86/cpu.h b/libavutil/x86/cpu.h
index 087b941795..a12ffb85ee 100644
--- a/libavutil/x86/cpu.h
+++ b/libavutil/x86/cpu.h
@@ -44,6 +44,33 @@
#define X86_AESNI(flags) CPUEXT(flags, AESNI)
#define X86_AVX512(flags) CPUEXT(flags, AVX512)
+#define IF_EXTERNAL_EXTENDED(cpuext, flags, additional_cond, ...) \
+ IF_CPUEXT_SUFFIX_EXT((flags), _EXTERNAL, cpuext, (additional_cond), __VA_ARGS__)
+#define IF_EXTERNAL_MMX(flags, ...) IF_CPUEXT_SUFFIX(flags, _EXTERNAL, MMX, __VA_ARGS__)
+#define IF_EXTERNAL_MMXEXT(flags, ...) IF_CPUEXT_SUFFIX(flags, _EXTERNAL, MMXEXT, __VA_ARGS__)
+#define IF_EXTERNAL_SSE(flags, ...) IF_CPUEXT_SUFFIX(flags, _EXTERNAL, SSE, __VA_ARGS__)
+#define IF_EXTERNAL_SSE2(flags, ...) IF_CPUEXT_SUFFIX(flags, _EXTERNAL, SSE2, __VA_ARGS__)
+#define IF_EXTERNAL_SSE2_SLOW(flags, ...) IF_CPUEXT_SUFFIX_SLOW(flags, _EXTERNAL, SSE2, __VA_ARGS__)
+#define IF_EXTERNAL_SSE3(flags, ...) IF_CPUEXT_SUFFIX(flags, _EXTERNAL, SSE3, __VA_ARGS__)
+#define IF_EXTERNAL_SSE3_FAST(flags, ...) IF_CPUEXT_SUFFIX_FAST(flags, _EXTERNAL, SSE3, __VA_ARGS__)
+#define IF_EXTERNAL_SSE3_SLOW(flags, ...) IF_CPUEXT_SUFFIX_SLOW(flags, _EXTERNAL, SSE3, __VA_ARGS__)
+#define IF_EXTERNAL_SSSE3(flags, ...) IF_CPUEXT_SUFFIX(flags, _EXTERNAL, SSSE3, __VA_ARGS__)
+#define IF_EXTERNAL_SSSE3_FAST(flags, ...) IF_CPUEXT_SUFFIX_FAST(flags, _EXTERNAL, SSSE3, __VA_ARGS__)
+#define IF_EXTERNAL_SSSE3_SLOW(flags, ...) IF_CPUEXT_SUFFIX_SLOW(flags, _EXTERNAL, SSSE3, __VA_ARGS__)
+#define IF_EXTERNAL_SSE4(flags, ...) IF_CPUEXT_SUFFIX(flags, _EXTERNAL, SSE4, __VA_ARGS__)
+#define IF_EXTERNAL_SSE42(flags, ...) IF_CPUEXT_SUFFIX(flags, _EXTERNAL, SSE42, __VA_ARGS__)
+#define IF_EXTERNAL_AVX(flags, ...) IF_CPUEXT_SUFFIX(flags, _EXTERNAL, AVX, __VA_ARGS__)
+#define IF_EXTERNAL_AVX_FAST(flags, ...) IF_CPUEXT_SUFFIX_FAST(flags, _EXTERNAL, AVX, __VA_ARGS__)
+#define IF_EXTERNAL_XOP(flags, ...) IF_CPUEXT_SUFFIX(flags, _EXTERNAL, XOP, __VA_ARGS__)
+#define IF_EXTERNAL_FMA3(flags, ...) IF_CPUEXT_SUFFIX(flags, _EXTERNAL, FMA3, __VA_ARGS__)
+#define IF_EXTERNAL_FMA3_FAST(flags, ...) IF_CPUEXT_SUFFIX_FAST2(flags, _EXTERNAL, FMA3, AVX, __VA_ARGS__)
+#define IF_EXTERNAL_FMA4(flags, ...) IF_CPUEXT_SUFFIX(flags, _EXTERNAL, FMA4, __VA_ARGS__)
+#define IF_EXTERNAL_AVX2(flags, ...) IF_CPUEXT_SUFFIX(flags, _EXTERNAL, AVX2, __VA_ARGS__)
+#define IF_EXTERNAL_AVX2_FAST(flags, ...) IF_CPUEXT_SUFFIX_FAST2(flags, _EXTERNAL, AVX2, AVX, __VA_ARGS__)
+#define IF_EXTERNAL_AESNI(flags, ...) IF_CPUEXT_SUFFIX(flags, _EXTERNAL, AESNI, __VA_ARGS__)
+#define IF_EXTERNAL_AVX512(flags, ...) IF_CPUEXT_SUFFIX(flags, _EXTERNAL, AVX512, __VA_ARGS__)
+#define IF_EXTERNAL_AVX512ICL(flags, ...) IF_CPUEXT_SUFFIX(flags, _EXTERNAL, AVX512ICL, __VA_ARGS__)
+
#define EXTERNAL_MMX(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, MMX)
#define EXTERNAL_MMXEXT(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, MMXEXT)
#define EXTERNAL_SSE(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, SSE)
--
2.49.1
From 57aec72a0c11d37dcc8a78f31c357094a4323ce0 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Wed, 29 Oct 2025 23:10:56 +0100
Subject: [PATCH 06/34] avcodec/x86/xvididct_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/xvididct_init.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavcodec/x86/xvididct_init.c b/libavcodec/x86/xvididct_init.c
index c6c87b0c90..a98b22933c 100644
--- a/libavcodec/x86/xvididct_init.c
+++ b/libavcodec/x86/xvididct_init.c
@@ -30,11 +30,11 @@ av_cold void ff_xvid_idct_init_x86(IDCTDSPContext *c)
#if HAVE_X86ASM
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->idct_put = ff_xvid_idct_put_sse2;
c->idct_add = ff_xvid_idct_add_sse2;
c->idct = ff_xvid_idct_sse2;
c->perm_type = FF_IDCT_PERM_SSE2;
- }
+ )
#endif /* HAVE_X86ASM */
}
--
2.49.1
From 4e6d89b98f79ff3990e48b7c2b232d46b354b3b5 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Thu, 30 Oct 2025 12:40:47 +0100
Subject: [PATCH 07/34] avcodec/x86/h263dsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/h263dsp_init.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavcodec/x86/h263dsp_init.c b/libavcodec/x86/h263dsp_init.c
index 3dd5d132e5..7d2fb7c710 100644
--- a/libavcodec/x86/h263dsp_init.c
+++ b/libavcodec/x86/h263dsp_init.c
@@ -32,8 +32,8 @@ av_cold void ff_h263dsp_init_x86(H263DSPContext *c)
{
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->h263_h_loop_filter = ff_h263_h_loop_filter_sse2;
c->h263_v_loop_filter = ff_h263_v_loop_filter_sse2;
- }
+ )
}
--
2.49.1
From 0a9298ab1f212430ee7ef6bd688902ff278d847d Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Thu, 30 Oct 2025 12:42:39 +0100
Subject: [PATCH 08/34] avcodec/x86/jpeg2000dsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/jpeg2000dsp_init.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/libavcodec/x86/jpeg2000dsp_init.c b/libavcodec/x86/jpeg2000dsp_init.c
index 7310a1d0e1..6cf8a55b1b 100644
--- a/libavcodec/x86/jpeg2000dsp_init.c
+++ b/libavcodec/x86/jpeg2000dsp_init.c
@@ -34,27 +34,27 @@ void ff_rct_int_avx2 (void *src0, void *src1, void *src2, int csize);
av_cold void ff_jpeg2000dsp_init_x86(Jpeg2000DSPContext *c)
{
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_SSE(cpu_flags)) {
+ IF_EXTERNAL_SSE(cpu_flags,
c->mct_decode[FF_DWT97] = ff_ict_float_sse;
- }
+ )
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->mct_decode[FF_DWT53] = ff_rct_int_sse2;
- }
+ )
- if (EXTERNAL_AVX_FAST(cpu_flags)) {
+ IF_EXTERNAL_AVX_FAST(cpu_flags,
c->mct_decode[FF_DWT97] = ff_ict_float_avx;
- }
+ )
- if (EXTERNAL_FMA4(cpu_flags)) {
+ IF_EXTERNAL_FMA4(cpu_flags,
c->mct_decode[FF_DWT97] = ff_ict_float_fma4;
- }
+ )
- if (EXTERNAL_FMA3_FAST(cpu_flags)) {
+ IF_EXTERNAL_FMA3_FAST(cpu_flags,
c->mct_decode[FF_DWT97] = ff_ict_float_fma3;
- }
+ )
- if (EXTERNAL_AVX2_FAST(cpu_flags)) {
+ IF_EXTERNAL_AVX2_FAST(cpu_flags,
c->mct_decode[FF_DWT53] = ff_rct_int_avx2;
- }
+ )
}
--
2.49.1
From f0436e4c387dd28c91c5da11e06f2b848b4079cf Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Thu, 30 Oct 2025 12:44:02 +0100
Subject: [PATCH 09/34] avcodec/x86/pixblockdsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/pixblockdsp_init.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavcodec/x86/pixblockdsp_init.c b/libavcodec/x86/pixblockdsp_init.c
index 650a0eb4f6..f37db645f7 100644
--- a/libavcodec/x86/pixblockdsp_init.c
+++ b/libavcodec/x86/pixblockdsp_init.c
@@ -32,12 +32,12 @@ av_cold void ff_pixblockdsp_init_x86(PixblockDSPContext *c,
{
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
if (!high_bit_depth) {
c->get_pixels_unaligned =
c->get_pixels = ff_get_pixels_sse2;
}
c->diff_pixels_unaligned =
c->diff_pixels = ff_diff_pixels_sse2;
- }
+ )
}
--
2.49.1
From 4a87c5bdb18d6d15e2dd4b3be3701c1c046dcbb7 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Thu, 30 Oct 2025 12:45:22 +0100
Subject: [PATCH 10/34] avcodec/x86/svq1enc_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/svq1enc_init.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/libavcodec/x86/svq1enc_init.c b/libavcodec/x86/svq1enc_init.c
index daf573beba..4bd2e7e4df 100644
--- a/libavcodec/x86/svq1enc_init.c
+++ b/libavcodec/x86/svq1enc_init.c
@@ -18,7 +18,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "config.h"
#include "libavutil/attributes.h"
#include "libavutil/cpu.h"
#include "libavutil/x86/cpu.h"
@@ -31,7 +30,7 @@ av_cold void ff_svq1enc_init_x86(SVQ1EncDSPContext *c)
{
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->ssd_int8_vs_int16 = ff_ssd_int8_vs_int16_sse2;
- }
+ )
}
--
2.49.1
From 687a1191004b29de3991e948ca84ceab004531af Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Thu, 30 Oct 2025 12:50:24 +0100
Subject: [PATCH 11/34] avcodec/x86/apv_dsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/apv_dsp_init.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavcodec/x86/apv_dsp_init.c b/libavcodec/x86/apv_dsp_init.c
index 39360a0ad2..7bd6873616 100644
--- a/libavcodec/x86/apv_dsp_init.c
+++ b/libavcodec/x86/apv_dsp_init.c
@@ -36,9 +36,9 @@ av_cold void ff_apv_dsp_init_x86_64(APVDSPContext *dsp)
{
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_AVX2_FAST(cpu_flags)) {
+ IF_EXTERNAL_AVX2_FAST(cpu_flags,
dsp->decode_transquant = ff_apv_decode_transquant_avx2;
- }
+ )
}
#endif /* ARCH_X86_64 */
--
2.49.1
From f73bf934872be2f74406f80336cf040e1653d9ae Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Thu, 30 Oct 2025 12:51:57 +0100
Subject: [PATCH 12/34] avcodec/x86/utvideodsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/utvideodsp_init.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/libavcodec/x86/utvideodsp_init.c b/libavcodec/x86/utvideodsp_init.c
index 2b436c6c5c..004549cb43 100644
--- a/libavcodec/x86/utvideodsp_init.c
+++ b/libavcodec/x86/utvideodsp_init.c
@@ -18,10 +18,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "config.h"
#include "libavutil/attributes.h"
#include "libavutil/cpu.h"
-#include "libavutil/x86/asm.h"
#include "libavutil/x86/cpu.h"
#include "libavcodec/utvideodsp.h"
@@ -43,12 +41,12 @@ av_cold void ff_utvideodsp_init_x86(UTVideoDSPContext *c)
{
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->restore_rgb_planes = ff_restore_rgb_planes_sse2;
c->restore_rgb_planes10 = ff_restore_rgb_planes10_sse2;
- }
- if (EXTERNAL_AVX2_FAST(cpu_flags)) {
+ )
+ IF_EXTERNAL_AVX2_FAST(cpu_flags,
c->restore_rgb_planes = ff_restore_rgb_planes_avx2;
c->restore_rgb_planes10 = ff_restore_rgb_planes10_avx2;
- }
+ )
}
--
2.49.1
From e1fa1e754c5ef0a16155e7273e31dfd9423774cc Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Thu, 30 Oct 2025 13:04:17 +0100
Subject: [PATCH 13/34] avcodec/x86/exrdsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/exrdsp_init.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/libavcodec/x86/exrdsp_init.c b/libavcodec/x86/exrdsp_init.c
index 63b3480d8f..77fda48295 100644
--- a/libavcodec/x86/exrdsp_init.c
+++ b/libavcodec/x86/exrdsp_init.c
@@ -36,17 +36,17 @@ av_cold void ff_exrdsp_init_x86(ExrDSPContext *dsp)
{
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
dsp->reorder_pixels = ff_reorder_pixels_sse2;
- }
- if (EXTERNAL_SSSE3(cpu_flags)) {
+ )
+ IF_EXTERNAL_SSSE3(cpu_flags,
dsp->predictor = ff_predictor_ssse3;
- }
- if (EXTERNAL_AVX(cpu_flags)) {
+ )
+ IF_EXTERNAL_AVX(cpu_flags,
dsp->predictor = ff_predictor_avx;
- }
- if (EXTERNAL_AVX2_FAST(cpu_flags)) {
+ )
+ IF_EXTERNAL_AVX2_FAST(cpu_flags,
dsp->reorder_pixels = ff_reorder_pixels_avx2;
dsp->predictor = ff_predictor_avx2;
- }
+ )
}
--
2.49.1
From 9f6b2ab299f12ab1fb98688b24bb989caf435361 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Thu, 30 Oct 2025 13:05:27 +0100
Subject: [PATCH 14/34] avcodec/x86/blockdsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/blockdsp_init.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/libavcodec/x86/blockdsp_init.c b/libavcodec/x86/blockdsp_init.c
index 37f3bb6a84..fafe4c4ef0 100644
--- a/libavcodec/x86/blockdsp_init.c
+++ b/libavcodec/x86/blockdsp_init.c
@@ -39,21 +39,21 @@ av_cold void ff_blockdsp_init_x86(BlockDSPContext *c)
#if HAVE_X86ASM
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_SSE(cpu_flags)) {
+ IF_EXTERNAL_SSE(cpu_flags,
c->clear_block = ff_clear_block_sse;
c->clear_blocks = ff_clear_blocks_sse;
- }
- if (EXTERNAL_SSE2(cpu_flags)) {
+ )
+ IF_EXTERNAL_SSE2(cpu_flags,
c->fill_block_tab[0] = ff_fill_block_tab_16_sse2;
c->fill_block_tab[1] = ff_fill_block_tab_8_sse2;
- }
- if (EXTERNAL_AVX_FAST(cpu_flags)) {
+ )
+ IF_EXTERNAL_AVX_FAST(cpu_flags,
c->clear_block = ff_clear_block_avx;
c->clear_blocks = ff_clear_blocks_avx;
- }
- if (EXTERNAL_AVX2(cpu_flags)) {
+ )
+ IF_EXTERNAL_AVX2(cpu_flags,
c->fill_block_tab[0] = ff_fill_block_tab_16_avx2;
c->fill_block_tab[1] = ff_fill_block_tab_8_avx2;
- }
+ )
#endif /* HAVE_X86ASM */
}
--
2.49.1
From 71731dee2486998402fabfe9d5e20a863ba88730 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Thu, 30 Oct 2025 13:06:27 +0100
Subject: [PATCH 15/34] avcodec/x86/sbcdsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/sbcdsp_init.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavcodec/x86/sbcdsp_init.c b/libavcodec/x86/sbcdsp_init.c
index 7416a86ac6..ec32927627 100644
--- a/libavcodec/x86/sbcdsp_init.c
+++ b/libavcodec/x86/sbcdsp_init.c
@@ -44,9 +44,9 @@ av_cold void ff_sbcdsp_init_x86(SBCDSPContext *s)
{
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_MMX(cpu_flags)) {
+ IF_EXTERNAL_MMX(cpu_flags,
s->sbc_analyze_4 = ff_sbc_analyze_4_mmx;
s->sbc_analyze_8 = ff_sbc_analyze_8_mmx;
s->sbc_calc_scalefactors = ff_sbc_calc_scalefactors_mmx;
- }
+ )
}
--
2.49.1
From f7dc78a394ecab7ea5322dfa2abea8cb99e85c36 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Thu, 30 Oct 2025 13:07:35 +0100
Subject: [PATCH 16/34] avcodec/x86/vp3dsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/vp3dsp_init.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/libavcodec/x86/vp3dsp_init.c b/libavcodec/x86/vp3dsp_init.c
index 42daf99981..ce15f67fc8 100644
--- a/libavcodec/x86/vp3dsp_init.c
+++ b/libavcodec/x86/vp3dsp_init.c
@@ -44,19 +44,19 @@ av_cold void ff_vp3dsp_init_x86(VP3DSPContext *c)
{
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_MMX(cpu_flags)) {
+ IF_EXTERNAL_MMX(cpu_flags,
c->put_no_rnd_pixels_l2 = ff_put_vp_no_rnd_pixels8_l2_mmx;
- }
+ )
- if (EXTERNAL_MMXEXT(cpu_flags)) {
+ IF_EXTERNAL_MMXEXT(cpu_flags,
c->idct_dc_add = ff_vp3_idct_dc_add_mmxext;
- }
+ )
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->idct_put = ff_vp3_idct_put_sse2;
c->idct_add = ff_vp3_idct_add_sse2;
c->v_loop_filter = c->v_loop_filter_unaligned = ff_vp3_v_loop_filter_sse2;
c->h_loop_filter = c->h_loop_filter_unaligned = ff_vp3_h_loop_filter_sse2;
- }
+ )
}
--
2.49.1
From 80b2c9bd99a7a666a40a6dfe132e652614d7ac33 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Thu, 30 Oct 2025 13:09:04 +0100
Subject: [PATCH 17/34] avcodec/x86/proresdsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/proresdsp_init.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/libavcodec/x86/proresdsp_init.c b/libavcodec/x86/proresdsp_init.c
index f7abbfa692..6c00a795eb 100644
--- a/libavcodec/x86/proresdsp_init.c
+++ b/libavcodec/x86/proresdsp_init.c
@@ -36,15 +36,15 @@ av_cold void ff_proresdsp_init_x86(ProresDSPContext *dsp, int bits_per_raw_sampl
int cpu_flags = av_get_cpu_flags();
if (bits_per_raw_sample == 10) {
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
dsp->idct_permutation_type = FF_IDCT_PERM_TRANSPOSE;
dsp->idct_put = ff_prores_idct_put_10_sse2;
- }
+ )
- if (EXTERNAL_AVX(cpu_flags)) {
+ IF_EXTERNAL_AVX(cpu_flags,
dsp->idct_permutation_type = FF_IDCT_PERM_TRANSPOSE;
dsp->idct_put = ff_prores_idct_put_10_avx;
- }
+ )
}
#endif /* ARCH_X86_64 */
}
--
2.49.1
From 64c7d972d73e5f0305f78401bf01688c58a1f53b Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Thu, 30 Oct 2025 13:09:51 +0100
Subject: [PATCH 18/34] avcodec/x86/sbrdsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/sbrdsp_init.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/libavcodec/x86/sbrdsp_init.c b/libavcodec/x86/sbrdsp_init.c
index 999f681220..ff92a838ce 100644
--- a/libavcodec/x86/sbrdsp_init.c
+++ b/libavcodec/x86/sbrdsp_init.c
@@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "config.h"
#include "libavutil/attributes.h"
#include "libavutil/cpu.h"
#include "libavutil/x86/cpu.h"
@@ -59,7 +58,7 @@ av_cold void ff_sbrdsp_init_x86(SBRDSPContext *s)
{
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_SSE(cpu_flags)) {
+ IF_EXTERNAL_SSE(cpu_flags,
s->neg_odd_64 = ff_sbr_neg_odd_64_sse;
s->sum_square = ff_sbr_sum_square_sse;
s->sum64x5 = ff_sbr_sum64x5_sse;
@@ -68,18 +67,18 @@ av_cold void ff_sbrdsp_init_x86(SBRDSPContext *s)
s->qmf_post_shuffle = ff_sbr_qmf_post_shuffle_sse;
s->qmf_deint_neg = ff_sbr_qmf_deint_neg_sse;
s->autocorrelate = ff_sbr_autocorrelate_sse;
- }
+ )
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
s->qmf_deint_bfly = ff_sbr_qmf_deint_bfly_sse2;
s->qmf_pre_shuffle = ff_sbr_qmf_pre_shuffle_sse2;
s->hf_apply_noise[0] = ff_sbr_hf_apply_noise_0_sse2;
s->hf_apply_noise[1] = ff_sbr_hf_apply_noise_1_sse2;
s->hf_apply_noise[2] = ff_sbr_hf_apply_noise_2_sse2;
s->hf_apply_noise[3] = ff_sbr_hf_apply_noise_3_sse2;
- }
+ )
- if (EXTERNAL_SSE3(cpu_flags)) {
+ IF_EXTERNAL_SSE3(cpu_flags,
s->autocorrelate = ff_sbr_autocorrelate_sse3;
- }
+ )
}
--
2.49.1
From 17e0e0e7fb6caa542c44cd9d6a8ef25e9cc011e1 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Thu, 30 Oct 2025 13:14:27 +0100
Subject: [PATCH 19/34] avcodec/x86/takdsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/takdsp_init.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/libavcodec/x86/takdsp_init.c b/libavcodec/x86/takdsp_init.c
index 9553f8442c..feb4b3a52d 100644
--- a/libavcodec/x86/takdsp_init.c
+++ b/libavcodec/x86/takdsp_init.c
@@ -37,21 +37,21 @@ av_cold void ff_takdsp_init_x86(TAKDSPContext *c)
#if HAVE_X86ASM
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->decorrelate_ls = ff_tak_decorrelate_ls_sse2;
c->decorrelate_sr = ff_tak_decorrelate_sr_sse2;
c->decorrelate_sm = ff_tak_decorrelate_sm_sse2;
- }
+ )
- if (EXTERNAL_SSE4(cpu_flags)) {
+ IF_EXTERNAL_SSE4(cpu_flags,
c->decorrelate_sf = ff_tak_decorrelate_sf_sse4;
- }
+ )
- if (EXTERNAL_AVX2_FAST(cpu_flags)) {
+ IF_EXTERNAL_AVX2_FAST(cpu_flags,
c->decorrelate_ls = ff_tak_decorrelate_ls_avx2;
c->decorrelate_sr = ff_tak_decorrelate_sr_avx2;
c->decorrelate_sm = ff_tak_decorrelate_sm_avx2;
c->decorrelate_sf = ff_tak_decorrelate_sf_avx2;
- }
+ )
#endif
}
--
2.49.1
From f80e49c9c33dcf830f8e8e5fe5ed6aa94b2c4619 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Thu, 30 Oct 2025 13:15:52 +0100
Subject: [PATCH 20/34] avcodec/x86/opusdsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/opusdsp_init.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/libavcodec/x86/opusdsp_init.c b/libavcodec/x86/opusdsp_init.c
index 83f7616a2e..ec15c77868 100644
--- a/libavcodec/x86/opusdsp_init.c
+++ b/libavcodec/x86/opusdsp_init.c
@@ -16,8 +16,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "config.h"
-
#include "libavutil/attributes.h"
#include "libavutil/x86/cpu.h"
#include "libavcodec/opus/dsp.h"
@@ -29,8 +27,8 @@ av_cold void ff_opus_dsp_init_x86(OpusDSP *ctx)
{
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_FMA3(cpu_flags)) {
+ IF_EXTERNAL_FMA3(cpu_flags,
ctx->postfilter = ff_opus_postfilter_fma3;
ctx->deemphasis = ff_opus_deemphasis_fma3;
- }
+ )
}
--
2.49.1
From e4fd0918ece61ba75364637897b878e822e17d03 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Thu, 30 Oct 2025 13:17:57 +0100
Subject: [PATCH 21/34] avcodec/x86/ac3dsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/ac3dsp_init.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/libavcodec/x86/ac3dsp_init.c b/libavcodec/x86/ac3dsp_init.c
index 353cf38f86..761f96c68e 100644
--- a/libavcodec/x86/ac3dsp_init.c
+++ b/libavcodec/x86/ac3dsp_init.c
@@ -38,20 +38,20 @@ av_cold void ff_ac3dsp_init_x86(AC3DSPContext *c)
{
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->ac3_exponent_min = ff_ac3_exponent_min_sse2;
c->float_to_fixed24 = ff_float_to_fixed24_sse2;
c->compute_mantissa_size = ff_ac3_compute_mantissa_size_sse2;
c->extract_exponents = ff_ac3_extract_exponents_sse2;
- }
+ )
- if (EXTERNAL_SSSE3(cpu_flags)) {
+ IF_EXTERNAL_SSSE3(cpu_flags,
if (!(cpu_flags & AV_CPU_FLAG_ATOM))
c->extract_exponents = ff_ac3_extract_exponents_ssse3;
- }
- if (EXTERNAL_AVX_FAST(cpu_flags)) {
+ )
+ IF_EXTERNAL_AVX_FAST(cpu_flags,
c->float_to_fixed24 = ff_float_to_fixed24_avx;
- }
+ )
}
#define DOWNMIX_FUNC_OPT(ch, opt) \
@@ -76,12 +76,12 @@ void ff_ac3dsp_set_downmix_x86(AC3DSPContext *c)
#define SET_DOWNMIX(ch, suf, SUF) \
if (ch == c->in_channels) { \
- if (EXTERNAL_ ## SUF (cpu_flags)) { \
+ IF_EXTERNAL_ ## SUF (cpu_flags, \
if (c->out_channels == 1) \
c->downmix = ff_ac3_downmix_ ## ch ## _to_1_ ## suf; \
else \
c->downmix = ff_ac3_downmix_ ## ch ## _to_2_ ## suf; \
- } \
+ ) \
}
#define SET_DOWNMIX_ALL(suf, SUF) \
--
2.49.1
From b8f77878751ed4b6a1ebcf57b0517d0eda8d947f Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Thu, 30 Oct 2025 13:18:56 +0100
Subject: [PATCH 22/34] avcodec/x86/vp6dsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/vp6dsp_init.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavcodec/x86/vp6dsp_init.c b/libavcodec/x86/vp6dsp_init.c
index 83d45ec36c..fa6e6d963c 100644
--- a/libavcodec/x86/vp6dsp_init.c
+++ b/libavcodec/x86/vp6dsp_init.c
@@ -32,7 +32,7 @@ av_cold void ff_vp6dsp_init_x86(VP56DSPContext *c)
{
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->vp6_filter_diag4 = ff_vp6_filter_diag4_sse2;
- }
+ )
}
--
2.49.1
From bf1c3c91e66844bd44a14664588f1befc09f36ac Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Thu, 30 Oct 2025 13:35:33 +0100
Subject: [PATCH 23/34] avcodec/x86/flacdsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/flacdsp_init.c | 32 ++++++++++++++++++--------------
1 file changed, 18 insertions(+), 14 deletions(-)
diff --git a/libavcodec/x86/flacdsp_init.c b/libavcodec/x86/flacdsp_init.c
index fa993d3466..a2df81a945 100644
--- a/libavcodec/x86/flacdsp_init.c
+++ b/libavcodec/x86/flacdsp_init.c
@@ -65,7 +65,7 @@ av_cold void ff_flacdsp_init_x86(FLACDSPContext *c, enum AVSampleFormat fmt, int
#if HAVE_X86ASM
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->wasted32 = ff_flac_wasted_32_sse2;
if (fmt == AV_SAMPLE_FMT_S16) {
c->decorrelate[1] = ff_flac_decorrelate_ls_16_sse2;
@@ -76,8 +76,8 @@ av_cold void ff_flacdsp_init_x86(FLACDSPContext *c, enum AVSampleFormat fmt, int
c->decorrelate[2] = ff_flac_decorrelate_rs_32_sse2;
c->decorrelate[3] = ff_flac_decorrelate_ms_32_sse2;
}
- }
- if (EXTERNAL_SSSE3(cpu_flags)) {
+ )
+ IF_EXTERNAL_SSSE3(cpu_flags,
if (fmt == AV_SAMPLE_FMT_S16) {
if (channels == 2)
c->decorrelate[0] = ff_flac_decorrelate_indep2_16_ssse3;
@@ -85,8 +85,9 @@ av_cold void ff_flacdsp_init_x86(FLACDSPContext *c, enum AVSampleFormat fmt, int
c->decorrelate[0] = ff_flac_decorrelate_indep4_16_ssse3;
else if (channels == 6)
c->decorrelate[0] = ff_flac_decorrelate_indep6_16_ssse3;
- else if (ARCH_X86_64 && channels == 8)
+ else IF(ARCH_X86_64, channels == 8,
c->decorrelate[0] = ff_flac_decorrelate_indep8_16_ssse3;
+ )
} else if (fmt == AV_SAMPLE_FMT_S32) {
if (channels == 2)
c->decorrelate[0] = ff_flac_decorrelate_indep2_32_ssse3;
@@ -94,30 +95,33 @@ av_cold void ff_flacdsp_init_x86(FLACDSPContext *c, enum AVSampleFormat fmt, int
c->decorrelate[0] = ff_flac_decorrelate_indep4_32_ssse3;
else if (channels == 6)
c->decorrelate[0] = ff_flac_decorrelate_indep6_32_ssse3;
- else if (ARCH_X86_64 && channels == 8)
+ else IF(ARCH_X86_64, channels == 8,
c->decorrelate[0] = ff_flac_decorrelate_indep8_32_ssse3;
+ )
}
- }
- if (EXTERNAL_SSE4(cpu_flags)) {
+ )
+ IF_EXTERNAL_SSE4(cpu_flags,
c->lpc16 = ff_flac_lpc_16_sse4;
c->lpc32 = ff_flac_lpc_32_sse4;
c->wasted33 = ff_flac_wasted_33_sse4;
- }
- if (EXTERNAL_AVX(cpu_flags)) {
+ )
+ IF_EXTERNAL_AVX(cpu_flags,
if (fmt == AV_SAMPLE_FMT_S16) {
- if (ARCH_X86_64 && channels == 8)
+ IF(ARCH_X86_64, channels == 8,
c->decorrelate[0] = ff_flac_decorrelate_indep8_16_avx;
+ )
} else if (fmt == AV_SAMPLE_FMT_S32) {
if (channels == 4)
c->decorrelate[0] = ff_flac_decorrelate_indep4_32_avx;
else if (channels == 6)
c->decorrelate[0] = ff_flac_decorrelate_indep6_32_avx;
- else if (ARCH_X86_64 && channels == 8)
+ else IF(ARCH_X86_64, channels == 8,
c->decorrelate[0] = ff_flac_decorrelate_indep8_32_avx;
+ )
}
- }
- if (EXTERNAL_XOP(cpu_flags)) {
+ )
+ IF_EXTERNAL_XOP(cpu_flags,
c->lpc32 = ff_flac_lpc_32_xop;
- }
+ )
#endif /* HAVE_X86ASM */
}
--
2.49.1
From f53202fe7f9dfbb6fb6cbefe43367e13f177a9a1 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Thu, 30 Oct 2025 13:38:51 +0100
Subject: [PATCH 24/34] avcodec/x86/huffyuvdsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/huffyuvdsp_init.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/libavcodec/x86/huffyuvdsp_init.c b/libavcodec/x86/huffyuvdsp_init.c
index 239d3ca313..43515735c7 100644
--- a/libavcodec/x86/huffyuvdsp_init.c
+++ b/libavcodec/x86/huffyuvdsp_init.c
@@ -18,11 +18,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "config.h"
#include "libavutil/attributes.h"
#include "libavutil/cpu.h"
#include "libavutil/pixdesc.h"
-#include "libavutil/x86/asm.h"
#include "libavutil/x86/cpu.h"
#include "libavcodec/huffyuvdsp.h"
@@ -38,16 +36,16 @@ av_cold void ff_huffyuvdsp_init_x86(HuffYUVDSPContext *c, enum AVPixelFormat pix
int cpu_flags = av_get_cpu_flags();
const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(pix_fmt);
- if (EXTERNAL_MMXEXT(cpu_flags) && pix_desc && pix_desc->comp[0].depth<16) {
+ IF_EXTERNAL_EXTENDED(MMXEXT, cpu_flags, pix_desc && pix_desc->comp[0].depth<16,
c->add_hfyu_median_pred_int16 = ff_add_hfyu_median_pred_int16_mmxext;
- }
+ )
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->add_int16 = ff_add_int16_sse2;
c->add_hfyu_left_pred_bgr32 = ff_add_hfyu_left_pred_bgr32_sse2;
- }
+ )
- if (EXTERNAL_AVX2_FAST(cpu_flags)) {
+ IF_EXTERNAL_AVX2_FAST(cpu_flags,
c->add_int16 = ff_add_int16_avx2;
- }
+ )
}
--
2.49.1
From 0c2fd3312d99c61a7e26b75b7537630c54d0b478 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Thu, 30 Oct 2025 13:41:37 +0100
Subject: [PATCH 25/34] avcodec/x86/huffyuvencdsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/huffyuvencdsp_init.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/libavcodec/x86/huffyuvencdsp_init.c b/libavcodec/x86/huffyuvencdsp_init.c
index c9c33b75b4..b64d1200dc 100644
--- a/libavcodec/x86/huffyuvencdsp_init.c
+++ b/libavcodec/x86/huffyuvencdsp_init.c
@@ -40,15 +40,15 @@ av_cold void ff_huffyuvencdsp_init_x86(HuffYUVEncDSPContext *c, enum AVPixelForm
av_unused int cpu_flags = av_get_cpu_flags();
const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(pix_fmt);
- if (EXTERNAL_MMXEXT(cpu_flags) && pix_desc && pix_desc->comp[0].depth<16) {
+ IF_EXTERNAL_EXTENDED(MMXEXT, cpu_flags, pix_desc && pix_desc->comp[0].depth<16,
c->sub_hfyu_median_pred_int16 = ff_sub_hfyu_median_pred_int16_mmxext;
- }
+ )
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->diff_int16 = ff_diff_int16_sse2;
- }
+ )
- if (EXTERNAL_AVX2_FAST(cpu_flags)) {
+ IF_EXTERNAL_AVX2_FAST(cpu_flags,
c->diff_int16 = ff_diff_int16_avx2;
- }
+ )
}
--
2.49.1
From fe24a086f315a9d49d9758985f1ae03aea695a89 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Thu, 30 Oct 2025 13:42:40 +0100
Subject: [PATCH 26/34] avcodec/x86/cfhddsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/cfhddsp_init.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/libavcodec/x86/cfhddsp_init.c b/libavcodec/x86/cfhddsp_init.c
index c5d89561ae..362dc91b3c 100644
--- a/libavcodec/x86/cfhddsp_init.c
+++ b/libavcodec/x86/cfhddsp_init.c
@@ -21,7 +21,6 @@
#include <stddef.h>
#include <stdint.h>
-#include "config.h"
#include "libavutil/attributes.h"
#include "libavutil/cpu.h"
#include "libavutil/x86/cpu.h"
@@ -42,12 +41,12 @@ av_cold void ff_cfhddsp_init_x86(CFHDDSPContext *c, int depth, int bayer)
{
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->horiz_filter = ff_cfhd_horiz_filter_sse2;
c->vert_filter = ff_cfhd_vert_filter_sse2;
if (depth == 10 && !bayer)
c->horiz_filter_clip = ff_cfhd_horiz_filter_clip10_sse2;
if (depth == 12 && !bayer)
c->horiz_filter_clip = ff_cfhd_horiz_filter_clip12_sse2;
- }
+ )
}
--
2.49.1
From f43d706de657212b61fede3d0f7ad86f073a4365 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Thu, 30 Oct 2025 13:43:20 +0100
Subject: [PATCH 27/34] avcodec/x86/cfhdencdsp_init: Avoid reliance on DCE
Also avoid an unused variable warning with 32 bit builds.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/cfhdencdsp_init.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libavcodec/x86/cfhdencdsp_init.c b/libavcodec/x86/cfhdencdsp_init.c
index 5cea39a80a..41d5ca1474 100644
--- a/libavcodec/x86/cfhdencdsp_init.c
+++ b/libavcodec/x86/cfhdencdsp_init.c
@@ -38,12 +38,12 @@ void ff_cfhdenc_vert_filter_sse2(const int16_t *input, int16_t *low, int16_t *hi
av_cold void ff_cfhdencdsp_init_x86(CFHDEncDSPContext *c)
{
+#if ARCH_X86_64
int cpu_flags = av_get_cpu_flags();
-#if ARCH_X86_64
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->horiz_filter = ff_cfhdenc_horiz_filter_sse2;
c->vert_filter = ff_cfhdenc_vert_filter_sse2;
- }
+ )
#endif
}
--
2.49.1
From c44a0b3e1308293fe0eeebdb6458a025e61c1398 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Thu, 30 Oct 2025 13:44:49 +0100
Subject: [PATCH 28/34] avcodec/x86/mpegvideoencdsp_init: Avoid reliance on DCE
Also avoid an unused variable warning with 32 bit builds.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/mpegvideoencdsp_init.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/libavcodec/x86/mpegvideoencdsp_init.c b/libavcodec/x86/mpegvideoencdsp_init.c
index bf5b722016..a6b32cd1d7 100644
--- a/libavcodec/x86/mpegvideoencdsp_init.c
+++ b/libavcodec/x86/mpegvideoencdsp_init.c
@@ -208,14 +208,14 @@ av_cold void ff_mpegvideoencdsp_init_x86(MpegvideoEncDSPContext *c,
{
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->pix_sum = ff_pix_sum16_sse2;
c->pix_norm1 = ff_pix_norm1_sse2;
- }
+ )
- if (EXTERNAL_XOP(cpu_flags)) {
+ IF_EXTERNAL_XOP(cpu_flags,
c->pix_sum = ff_pix_sum16_xop;
- }
+ )
#if HAVE_INLINE_ASM
--
2.49.1
From 1fa678e0ce49da1cc1a20dea02de9b10de3cd526 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Thu, 30 Oct 2025 13:45:49 +0100
Subject: [PATCH 29/34] avcodec/x86/lossless_videodsp_init: Avoid reliance on
DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/lossless_videodsp_init.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/libavcodec/x86/lossless_videodsp_init.c b/libavcodec/x86/lossless_videodsp_init.c
index 5690cacaad..80f87238cd 100644
--- a/libavcodec/x86/lossless_videodsp_init.c
+++ b/libavcodec/x86/lossless_videodsp_init.c
@@ -18,8 +18,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "config.h"
-#include "../lossless_videodsp.h"
+#include "libavcodec/lossless_videodsp.h"
#include "libavutil/x86/cpu.h"
void ff_add_bytes_sse2(uint8_t *dst, uint8_t *src, ptrdiff_t w);
@@ -46,25 +45,25 @@ void ff_llviddsp_init_x86(LLVidDSPContext *c)
{
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->add_bytes = ff_add_bytes_sse2;
c->add_median_pred = ff_add_median_pred_sse2;
- }
+ )
- if (EXTERNAL_SSSE3(cpu_flags)) {
+ IF_EXTERNAL_SSSE3(cpu_flags,
c->add_left_pred = ff_add_left_pred_ssse3;
c->add_left_pred_int16 = ff_add_left_pred_int16_ssse3;
c->add_gradient_pred = ff_add_gradient_pred_ssse3;
- }
+ )
- if (EXTERNAL_SSSE3_FAST(cpu_flags)) {
+ IF_EXTERNAL_SSSE3_FAST(cpu_flags,
c->add_left_pred = ff_add_left_pred_unaligned_ssse3;
c->add_left_pred_int16 = ff_add_left_pred_int16_unaligned_ssse3;
- }
+ )
- if (EXTERNAL_AVX2_FAST(cpu_flags)) {
+ IF_EXTERNAL_AVX2_FAST(cpu_flags,
c->add_bytes = ff_add_bytes_avx2;
c->add_left_pred = ff_add_left_pred_unaligned_avx2;
c->add_gradient_pred = ff_add_gradient_pred_avx2;
- }
+ )
}
--
2.49.1
From 904439625360b1cd0c2b2fc8b9a1114d8cf74d5d Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Thu, 30 Oct 2025 13:46:45 +0100
Subject: [PATCH 30/34] avcodec/x86/lossless_videoencdsp_init: Avoid reliance
on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/lossless_videoencdsp_init.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/libavcodec/x86/lossless_videoencdsp_init.c b/libavcodec/x86/lossless_videoencdsp_init.c
index 22a4014ef1..fa4b864f50 100644
--- a/libavcodec/x86/lossless_videoencdsp_init.c
+++ b/libavcodec/x86/lossless_videoencdsp_init.c
@@ -91,15 +91,15 @@ av_cold void ff_llvidencdsp_init_x86(LLVidEncDSPContext *c)
}
#endif /* HAVE_INLINE_ASM */
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->diff_bytes = ff_diff_bytes_sse2;
- }
+ )
- if (EXTERNAL_AVX(cpu_flags)) {
+ IF_EXTERNAL_AVX(cpu_flags,
c->sub_left_predict = ff_sub_left_predict_avx;
- }
+ )
- if (EXTERNAL_AVX2_FAST(cpu_flags)) {
+ IF_EXTERNAL_AVX2_FAST(cpu_flags,
c->diff_bytes = ff_diff_bytes_avx2;
- }
+ )
}
--
2.49.1
From 09bf720331e2d12ff2beeb44ef4faf3479afcf0e Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Thu, 30 Oct 2025 14:01:41 +0100
Subject: [PATCH 31/34] avcodec/x86/h264_intrapred_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/h264_intrapred_init.c | 36 ++++++++++++++--------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/libavcodec/x86/h264_intrapred_init.c b/libavcodec/x86/h264_intrapred_init.c
index aa9bc721f0..8d8ae758d3 100644
--- a/libavcodec/x86/h264_intrapred_init.c
+++ b/libavcodec/x86/h264_intrapred_init.c
@@ -163,7 +163,7 @@ av_cold void ff_h264_pred_init_x86(H264PredContext *h, int codec_id,
int cpu_flags = av_get_cpu_flags();
if (bit_depth == 8) {
- if (EXTERNAL_MMXEXT(cpu_flags)) {
+ IF_EXTERNAL_MMXEXT(cpu_flags,
if (chroma_format_idc <= 1)
h->pred8x8[HOR_PRED8x8 ] = ff_pred8x8_horizontal_8_mmxext;
h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_8_mmxext;
@@ -196,13 +196,13 @@ av_cold void ff_h264_pred_init_x86(H264PredContext *h, int codec_id,
h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_8_mmxext;
h->pred4x4 [VERT_PRED ] = ff_pred4x4_vertical_vp8_8_mmxext;
}
- }
+ )
- if (EXTERNAL_SSE(cpu_flags)) {
+ IF_EXTERNAL_SSE(cpu_flags,
h->pred16x16[VERT_PRED8x8] = ff_pred16x16_vertical_8_sse;
- }
+ )
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_8_sse2;
h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_8_sse2;
h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_8_sse2;
@@ -226,9 +226,9 @@ av_cold void ff_h264_pred_init_x86(H264PredContext *h, int codec_id,
h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_8_sse2;
}
}
- }
+ )
- if (EXTERNAL_SSSE3(cpu_flags)) {
+ IF_EXTERNAL_SSSE3(cpu_flags,
h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_8_ssse3;
h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_8_ssse3;
if (chroma_format_idc <= 1)
@@ -257,19 +257,19 @@ av_cold void ff_h264_pred_init_x86(H264PredContext *h, int codec_id,
h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_8_ssse3;
}
}
- }
+ )
- if(EXTERNAL_AVX2(cpu_flags)){
+ IF_EXTERNAL_AVX2(cpu_flags,
if (codec_id == AV_CODEC_ID_VP8) {
h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_tm_vp8_8_avx2;
}
- }
+ )
} else if (bit_depth == 10) {
- if (EXTERNAL_MMXEXT(cpu_flags)) {
+ IF_EXTERNAL_MMXEXT(cpu_flags,
h->pred4x4[DC_PRED ] = ff_pred4x4_dc_10_mmxext;
h->pred4x4[HOR_UP_PRED ] = ff_pred4x4_horizontal_up_10_mmxext;
- }
- if (EXTERNAL_SSE2(cpu_flags)) {
+ )
+ IF_EXTERNAL_SSE2(cpu_flags,
h->pred4x4[DIAG_DOWN_LEFT_PRED ] = ff_pred4x4_down_left_10_sse2;
h->pred4x4[DIAG_DOWN_RIGHT_PRED] = ff_pred4x4_down_right_10_sse2;
h->pred4x4[VERT_LEFT_PRED ] = ff_pred4x4_vertical_left_10_sse2;
@@ -300,8 +300,8 @@ av_cold void ff_h264_pred_init_x86(H264PredContext *h, int codec_id,
h->pred16x16[LEFT_DC_PRED8x8 ] = ff_pred16x16_left_dc_10_sse2;
h->pred16x16[VERT_PRED8x8 ] = ff_pred16x16_vertical_10_sse2;
h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_10_sse2;
- }
- if (EXTERNAL_SSSE3(cpu_flags)) {
+ )
+ IF_EXTERNAL_SSSE3(cpu_flags,
h->pred4x4[DIAG_DOWN_RIGHT_PRED] = ff_pred4x4_down_right_10_ssse3;
h->pred4x4[VERT_RIGHT_PRED ] = ff_pred4x4_vertical_right_10_ssse3;
h->pred4x4[HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_10_ssse3;
@@ -311,8 +311,8 @@ av_cold void ff_h264_pred_init_x86(H264PredContext *h, int codec_id,
h->pred8x8l[DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_10_ssse3;
h->pred8x8l[VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_10_ssse3;
h->pred8x8l[HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_10_ssse3;
- }
- if (EXTERNAL_AVX(cpu_flags)) {
+ )
+ IF_EXTERNAL_AVX(cpu_flags,
h->pred4x4[DIAG_DOWN_LEFT_PRED ] = ff_pred4x4_down_left_10_avx;
h->pred4x4[DIAG_DOWN_RIGHT_PRED] = ff_pred4x4_down_right_10_avx;
h->pred4x4[VERT_LEFT_PRED ] = ff_pred4x4_vertical_left_10_avx;
@@ -327,6 +327,6 @@ av_cold void ff_h264_pred_init_x86(H264PredContext *h, int codec_id,
h->pred8x8l[DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_10_avx;
h->pred8x8l[VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_10_avx;
h->pred8x8l[HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_10_avx;
- }
+ )
}
}
--
2.49.1
From 03fa11b8c149155628df686676cd2ff2d692a692 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Thu, 30 Oct 2025 14:11:59 +0100
Subject: [PATCH 32/34] avcodec/x86/idctdsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/idctdsp_init.c | 60 +++++++++++++++++------------------
1 file changed, 29 insertions(+), 31 deletions(-)
diff --git a/libavcodec/x86/idctdsp_init.c b/libavcodec/x86/idctdsp_init.c
index 2d165b975b..8e20989e5f 100644
--- a/libavcodec/x86/idctdsp_init.c
+++ b/libavcodec/x86/idctdsp_init.c
@@ -66,7 +66,7 @@ av_cold void ff_idctdsp_init_x86(IDCTDSPContext *c, AVCodecContext *avctx,
int cpu_flags = av_get_cpu_flags();
#if ARCH_X86_32
- if (EXTERNAL_MMX(cpu_flags)) {
+ IF_EXTERNAL_MMX(cpu_flags,
if (!high_bit_depth &&
avctx->lowres == 0 &&
(avctx->idct_algo == FF_IDCT_AUTO ||
@@ -74,88 +74,86 @@ av_cold void ff_idctdsp_init_x86(IDCTDSPContext *c, AVCodecContext *avctx,
avctx->idct_algo == FF_IDCT_SIMPLEMMX)) {
c->idct = ff_simple_idct_mmx;
}
- }
+ )
#endif
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_sse2;
c->put_pixels_clamped = ff_put_pixels_clamped_sse2;
c->add_pixels_clamped = ff_add_pixels_clamped_sse2;
-#if ARCH_X86_32
- if (!high_bit_depth &&
+ IF(ARCH_X86_32, !high_bit_depth &&
avctx->lowres == 0 &&
(avctx->idct_algo == FF_IDCT_AUTO ||
- avctx->idct_algo == FF_IDCT_SIMPLEAUTO ||
- avctx->idct_algo == FF_IDCT_SIMPLEMMX)) {
+ avctx->idct_algo == FF_IDCT_SIMPLEAUTO ||
+ avctx->idct_algo == FF_IDCT_SIMPLEMMX),
c->idct_put = ff_simple_idct_put_sse2;
c->idct_add = ff_simple_idct_add_sse2;
c->perm_type = FF_IDCT_PERM_SIMPLE;
- }
-#endif
-
- if (ARCH_X86_64 &&
- !high_bit_depth &&
+ )
+ IF(ARCH_X86_64, !high_bit_depth &&
avctx->lowres == 0 &&
(avctx->idct_algo == FF_IDCT_AUTO ||
- avctx->idct_algo == FF_IDCT_SIMPLEAUTO ||
- avctx->idct_algo == FF_IDCT_SIMPLEMMX ||
- avctx->idct_algo == FF_IDCT_SIMPLE)) {
+ avctx->idct_algo == FF_IDCT_SIMPLEAUTO ||
+ avctx->idct_algo == FF_IDCT_SIMPLEMMX ||
+ avctx->idct_algo == FF_IDCT_SIMPLE),
c->idct = ff_simple_idct8_sse2;
c->idct_put = ff_simple_idct8_put_sse2;
c->idct_add = ff_simple_idct8_add_sse2;
c->perm_type = FF_IDCT_PERM_TRANSPOSE;
- }
- }
+ )
+ )
- if (ARCH_X86_64 && avctx->lowres == 0) {
- if (EXTERNAL_AVX(cpu_flags) &&
+#if ARCH_X86_64
+ if (avctx->lowres == 0) {
+ IF_EXTERNAL_EXTENDED(AVX, cpu_flags,
!high_bit_depth &&
(avctx->idct_algo == FF_IDCT_AUTO ||
- avctx->idct_algo == FF_IDCT_SIMPLEAUTO ||
- avctx->idct_algo == FF_IDCT_SIMPLEMMX ||
- avctx->idct_algo == FF_IDCT_SIMPLE)) {
+ avctx->idct_algo == FF_IDCT_SIMPLEAUTO ||
+ avctx->idct_algo == FF_IDCT_SIMPLEMMX ||
+ avctx->idct_algo == FF_IDCT_SIMPLE),
c->idct = ff_simple_idct8_avx;
c->idct_put = ff_simple_idct8_put_avx;
c->idct_add = ff_simple_idct8_add_avx;
c->perm_type = FF_IDCT_PERM_TRANSPOSE;
- }
+ )
if (avctx->bits_per_raw_sample == 10 &&
avctx->codec_id != AV_CODEC_ID_MPEG4 &&
(avctx->idct_algo == FF_IDCT_AUTO ||
avctx->idct_algo == FF_IDCT_SIMPLEAUTO ||
avctx->idct_algo == FF_IDCT_SIMPLE)) {
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->idct_put = ff_simple_idct10_put_sse2;
c->idct_add = NULL;
c->idct = ff_simple_idct10_sse2;
c->perm_type = FF_IDCT_PERM_TRANSPOSE;
- }
- if (EXTERNAL_AVX(cpu_flags)) {
+ )
+ IF_EXTERNAL_AVX(cpu_flags,
c->idct_put = ff_simple_idct10_put_avx;
c->idct_add = NULL;
c->idct = ff_simple_idct10_avx;
c->perm_type = FF_IDCT_PERM_TRANSPOSE;
- }
+ )
}
if (avctx->bits_per_raw_sample == 12 &&
(avctx->idct_algo == FF_IDCT_AUTO ||
avctx->idct_algo == FF_IDCT_SIMPLEMMX)) {
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->idct_put = ff_simple_idct12_put_sse2;
c->idct_add = NULL;
c->idct = ff_simple_idct12_sse2;
c->perm_type = FF_IDCT_PERM_TRANSPOSE;
- }
- if (EXTERNAL_AVX(cpu_flags)) {
+ )
+ IF_EXTERNAL_AVX(cpu_flags,
c->idct_put = ff_simple_idct12_put_avx;
c->idct_add = NULL;
c->idct = ff_simple_idct12_avx;
c->perm_type = FF_IDCT_PERM_TRANSPOSE;
- }
+ )
}
}
+#endif
}
--
2.49.1
From b1ee6b9307d25254c67481176a27c3fb8eff59bd Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Thu, 30 Oct 2025 14:15:37 +0100
Subject: [PATCH 33/34] avcodec/x86/dcadsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/dcadsp_init.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/libavcodec/x86/dcadsp_init.c b/libavcodec/x86/dcadsp_init.c
index c01bfffaba..a2a8be120f 100644
--- a/libavcodec/x86/dcadsp_init.c
+++ b/libavcodec/x86/dcadsp_init.c
@@ -36,14 +36,17 @@ av_cold void ff_dcadsp_init_x86(DCADSPContext *s)
{
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_SSE2(cpu_flags))
+ IF_EXTERNAL_SSE2(cpu_flags,
s->lfe_fir_float[0] = ff_lfe_fir0_float_sse2;
- if (EXTERNAL_SSE3(cpu_flags))
+ )
+ IF_EXTERNAL_SSE3(cpu_flags,
s->lfe_fir_float[1] = ff_lfe_fir1_float_sse3;
- if (EXTERNAL_AVX(cpu_flags)) {
+ )
+ IF_EXTERNAL_AVX(cpu_flags,
s->lfe_fir_float[0] = ff_lfe_fir0_float_avx;
s->lfe_fir_float[1] = ff_lfe_fir1_float_avx;
- }
- if (EXTERNAL_FMA3(cpu_flags))
+ )
+ IF_EXTERNAL_FMA3(cpu_flags,
s->lfe_fir_float[0] = ff_lfe_fir0_float_fma3;
+ )
}
--
2.49.1
From acb426b2dc11960d6f77dc7286bbc0d90a615348 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Thu, 30 Oct 2025 14:17:10 +0100
Subject: [PATCH 34/34] avcodec/x86/aacpsdsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/aacpsdsp_init.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/libavcodec/x86/aacpsdsp_init.c b/libavcodec/x86/aacpsdsp_init.c
index 221fe71bc7..21485385df 100644
--- a/libavcodec/x86/aacpsdsp_init.c
+++ b/libavcodec/x86/aacpsdsp_init.c
@@ -53,22 +53,22 @@ av_cold void ff_psdsp_init_x86(PSDSPContext *s)
{
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_SSE(cpu_flags)) {
+ IF_EXTERNAL_SSE(cpu_flags,
s->add_squares = ff_ps_add_squares_sse;
s->mul_pair_single = ff_ps_mul_pair_single_sse;
s->hybrid_analysis_ileave = ff_ps_hybrid_analysis_ileave_sse;
s->hybrid_synthesis_deint = ff_ps_hybrid_synthesis_deint_sse;
s->hybrid_analysis = ff_ps_hybrid_analysis_sse;
- }
- if (EXTERNAL_SSE3(cpu_flags)) {
+ )
+ IF_EXTERNAL_SSE3(cpu_flags,
s->add_squares = ff_ps_add_squares_sse3;
s->stereo_interpolate[0] = ff_ps_stereo_interpolate_sse3;
s->stereo_interpolate[1] = ff_ps_stereo_interpolate_ipdopd_sse3;
- }
- if (EXTERNAL_SSE4(cpu_flags)) {
+ )
+ IF_EXTERNAL_SSE4(cpu_flags,
s->hybrid_synthesis_deint = ff_ps_hybrid_synthesis_deint_sse4;
- }
- if (EXTERNAL_FMA3(cpu_flags)) {
+ )
+ IF_EXTERNAL_FMA3(cpu_flags,
s->hybrid_analysis = ff_ps_hybrid_analysis_fma3;
- }
+ )
}
--
2.49.1
1
0
30 Oct '25
PR #20792 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20792
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20792.patch
Only size 16 and 8 are used (and set).
From 0242cb36a576721ee6fb9bbbf70616dacb9957b3 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Thu, 30 Oct 2025 12:17:25 +0100
Subject: [PATCH] avcodec/rv34dsp: Reduce size of qpel functions arrays
Only size 16 and 8 are used (and set).
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/rv34dsp.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavcodec/rv34dsp.h b/libavcodec/rv34dsp.h
index d59b3c2732..c9fbd95e4e 100644
--- a/libavcodec/rv34dsp.h
+++ b/libavcodec/rv34dsp.h
@@ -55,8 +55,8 @@ typedef int (*rv40_loop_filter_strength_func)(uint8_t *src, ptrdiff_t stride,
int *p1, int *q1);
typedef struct RV34DSPContext {
- qpel_mc_func put_pixels_tab[4][16];
- qpel_mc_func avg_pixels_tab[4][16];
+ qpel_mc_func put_pixels_tab[2][16];
+ qpel_mc_func avg_pixels_tab[2][16];
h264_chroma_mc_func put_chroma_pixels_tab[3];
h264_chroma_mc_func avg_chroma_pixels_tab[3];
/**
--
2.49.1
1
0
[PATCH] avcodec/x86/hpeldsp: Don't use saturated addition when unnecessary (PR #20791)
by mkver 30 Oct '25
by mkver 30 Oct '25
30 Oct '25
PR #20791 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20791
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20791.patch
From 50f2e0e7ba41e4aedf36244d63c42a1381fc0336 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Thu, 30 Oct 2025 10:27:00 +0100
Subject: [PATCH 1/3] avcodec/x86/hpeldsp: Actually use constants in registers
Forgotten in 36f92206bb90d6f0268749bd6fe6aa57974442db.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/hpeldsp.asm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavcodec/x86/hpeldsp.asm b/libavcodec/x86/hpeldsp.asm
index 2587e3c315..0974286b0d 100644
--- a/libavcodec/x86/hpeldsp.asm
+++ b/libavcodec/x86/hpeldsp.asm
@@ -428,7 +428,7 @@ cglobal %1%3_pixels8_xy2, 4,5,5
psrlw m2, 2
%else
paddusw m2, m0
- pmulhrsw m2, [pw_8192]
+ pmulhrsw m2, m3
%endif
%ifidn %1, avg
movh m1, [r0+r4]
@@ -450,7 +450,7 @@ cglobal %1%3_pixels8_xy2, 4,5,5
psrlw m0, 2
%else
paddusw m0, m2
- pmulhrsw m0, [pw_8192]
+ pmulhrsw m0, m3
%endif
%ifidn %1, avg
movh m1, [r0+r4]
--
2.49.1
From a84ea10f93fbb66530eaa5ebb6f0275203d18356 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Thu, 30 Oct 2025 10:44:41 +0100
Subject: [PATCH 2/3] avcodec/x86/hpeldsp: Don't use saturated addition when
unnecessary
The numbers here are small (sums of values unpacked from bytes).
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/hpeldsp.asm | 48 +++++++++++++++++++-------------------
1 file changed, 24 insertions(+), 24 deletions(-)
diff --git a/libavcodec/x86/hpeldsp.asm b/libavcodec/x86/hpeldsp.asm
index 0974286b0d..c92c70f5ad 100644
--- a/libavcodec/x86/hpeldsp.asm
+++ b/libavcodec/x86/hpeldsp.asm
@@ -423,11 +423,11 @@ cglobal %1%3_pixels8_xy2, 4,5,5
punpcklbw m0, m1
pmaddubsw m0, m4
%ifidn %3, _no_rnd
- paddusw m2, m3
- paddusw m2, m0
+ paddw m2, m3
+ paddw m2, m0
psrlw m2, 2
%else
- paddusw m2, m0
+ paddw m2, m0
pmulhrsw m2, m3
%endif
%ifidn %1, avg
@@ -445,11 +445,11 @@ cglobal %1%3_pixels8_xy2, 4,5,5
punpcklbw m2, m1
pmaddubsw m2, m4
%ifidn %3, _no_rnd
- paddusw m0, m3
- paddusw m0, m2
+ paddw m0, m3
+ paddw m0, m2
psrlw m0, 2
%else
- paddusw m0, m2
+ paddw m0, m2
pmulhrsw m0, m3
%endif
%ifidn %1, avg
@@ -485,8 +485,8 @@ cglobal %1%3_pixels16_xy2, 4,5,8
punpcklbw m4, m7
punpckhbw m1, m7
punpckhbw m5, m7
- paddusw m4, m0
- paddusw m5, m1
+ paddw m4, m0
+ paddw m5, m1
xor r4, r4
add r1, r2
.loop:
@@ -498,12 +498,12 @@ cglobal %1%3_pixels16_xy2, 4,5,8
punpcklbw m2, m7
punpckhbw m1, m7
punpckhbw m3, m7
- paddusw m0, m2
- paddusw m1, m3
- paddusw m4, m6
- paddusw m5, m6
- paddusw m4, m0
- paddusw m5, m1
+ paddw m0, m2
+ paddw m1, m3
+ paddw m4, m6
+ paddw m5, m6
+ paddw m4, m0
+ paddw m5, m1
psrlw m4, 2
psrlw m5, 2
%ifidn %1, avg
@@ -524,12 +524,12 @@ cglobal %1%3_pixels16_xy2, 4,5,8
punpcklbw m4, m7
punpckhbw m3, m7
punpckhbw m5, m7
- paddusw m4, m2
- paddusw m5, m3
- paddusw m0, m6
- paddusw m1, m6
- paddusw m0, m4
- paddusw m1, m5
+ paddw m4, m2
+ paddw m5, m3
+ paddw m0, m6
+ paddw m1, m6
+ paddw m0, m4
+ paddw m1, m5
psrlw m0, 2
psrlw m1, 2
%ifidn %1, avg
@@ -567,8 +567,8 @@ cglobal %1_pixels16_xy2, 4,5,%2
movu m3, [r1+r4+1]
pmaddubsw m2, m5
pmaddubsw m3, m5
- paddusw m0, m2
- paddusw m1, m3
+ paddw m0, m2
+ paddw m1, m3
pmulhrsw m0, [pw_8192]
pmulhrsw m1, [pw_8192]
%ifidn %1, avg
@@ -587,8 +587,8 @@ cglobal %1_pixels16_xy2, 4,5,%2
movu m1, [r1+r4+1]
pmaddubsw m0, m5
pmaddubsw m1, m5
- paddusw m2, m0
- paddusw m3, m1
+ paddw m2, m0
+ paddw m3, m1
pmulhrsw m2, [pw_8192]
pmulhrsw m3, [pw_8192]
%ifidn %1, avg
--
2.49.1
From 88f4641db2d488308f04b70cba9f285d30da6eb5 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Thu, 30 Oct 2025 11:07:43 +0100
Subject: [PATCH 3/3] avcodec/x86/hpeldsp: Don't use PAVGB macro
It was only needed for MMX and there are no MMX functions here any more.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/hpeldsp.asm | 84 +++++++++++++++++++-------------------
1 file changed, 42 insertions(+), 42 deletions(-)
diff --git a/libavcodec/x86/hpeldsp.asm b/libavcodec/x86/hpeldsp.asm
index c92c70f5ad..cbdf0e460d 100644
--- a/libavcodec/x86/hpeldsp.asm
+++ b/libavcodec/x86/hpeldsp.asm
@@ -54,8 +54,8 @@ cglobal put_pixels8_x2, 4,5
pavgb m0, m2
pavgb m1, m3
%else
- PAVGB m0, [r1]
- PAVGB m1, [r1+r2]
+ pavgb m0, [r1]
+ pavgb m1, [r1+r2]
%endif
mova [r0], m0
mova [r0+r2], m1
@@ -69,8 +69,8 @@ cglobal put_pixels8_x2, 4,5
pavgb m0, m2
pavgb m1, m3
%else
- PAVGB m0, [r1]
- PAVGB m1, [r1+r2]
+ pavgb m0, [r1]
+ pavgb m1, [r1+r2]
%endif
add r1, r4
mova [r0], m0
@@ -103,8 +103,8 @@ cglobal put_no_rnd_pixels8_x2, 4,5
add r1, r4
psubusb m0, m6
psubusb m2, m6
- PAVGB m0, m1
- PAVGB m2, m3
+ pavgb m0, m1
+ pavgb m2, m3
mova [r0], m0
mova [r0+r2], m2
mova m0, [r1]
@@ -115,8 +115,8 @@ cglobal put_no_rnd_pixels8_x2, 4,5
add r1, r4
psubusb m0, m6
psubusb m2, m6
- PAVGB m0, m1
- PAVGB m2, m3
+ pavgb m0, m1
+ pavgb m2, m3
mova [r0], m0
mova [r0+r2], m2
add r0, r4
@@ -143,8 +143,8 @@ cglobal %1_no_rnd_pixels8_x2_exact, 4,5
pxor m2, m4
pxor m1, m4
pxor m3, m4
- PAVGB m0, m1
- PAVGB m2, m3
+ pavgb m0, m1
+ pavgb m2, m3
pxor m0, m4
pxor m2, m4
%ifidn %1, avg
@@ -161,8 +161,8 @@ cglobal %1_no_rnd_pixels8_x2_exact, 4,5
pxor m1, m4
pxor m2, m4
pxor m3, m4
- PAVGB m0, m1
- PAVGB m2, m3
+ pavgb m0, m1
+ pavgb m2, m3
pxor m0, m4
pxor m2, m4
%ifidn %1, avg
@@ -198,16 +198,16 @@ cglobal put_pixels8_y2, 4,5
movu m1, [r1+r2]
movu m2, [r1+r4]
add r1, r4
- PAVGB m0, m1
- PAVGB m1, m2
+ pavgb m0, m1
+ pavgb m1, m2
mova [r0+r2], m0
mova [r0+r4], m1
movu m1, [r1+r2]
movu m0, [r1+r4]
add r0, r4
add r1, r4
- PAVGB m2, m1
- PAVGB m1, m0
+ pavgb m2, m1
+ pavgb m1, m0
mova [r0+r2], m2
mova [r0+r4], m1
add r0, r4
@@ -235,8 +235,8 @@ cglobal put_no_rnd_pixels8_y2, 4,5
mova m2, [r1+r4]
add r1, r4
psubusb m1, m6
- PAVGB m0, m1
- PAVGB m1, m2
+ pavgb m0, m1
+ pavgb m1, m2
mova [r0+r2], m0
mova [r0+r4], m1
mova m1, [r1+r2]
@@ -244,8 +244,8 @@ cglobal put_no_rnd_pixels8_y2, 4,5
add r0, r4
add r1, r4
psubusb m1, m6
- PAVGB m2, m1
- PAVGB m1, m0
+ pavgb m2, m1
+ pavgb m1, m0
mova [r0+r2], m2
mova [r0+r4], m1
add r0, r4
@@ -271,8 +271,8 @@ cglobal %1_no_rnd_pixels8_y2_exact, 4,5
movu m2, [r1+r2]
pxor m1, m3
pxor m2, m3
- PAVGB m0, m1
- PAVGB m1, m2
+ pavgb m0, m1
+ pavgb m1, m2
pxor m0, m3
pxor m1, m3
%ifidn %1, avg
@@ -285,8 +285,8 @@ cglobal %1_no_rnd_pixels8_y2_exact, 4,5
movu m0, [r1+r4]
pxor m1, m3
pxor m0, m3
- PAVGB m2, m1
- PAVGB m1, m0
+ pavgb m2, m1
+ pavgb m1, m0
pxor m2, m3
pxor m1, m3
%ifidn %1, avg
@@ -325,11 +325,11 @@ cglobal avg_pixels8_x2, 4,5
pavgb m0, m1
pavgb m2, m3
%else
- PAVGB m0, [r1+1], m3, m5
- PAVGB m2, [r1+r2+1], m4, m5
+ pavgb m0, [r1+1]
+ pavgb m2, [r1+r2+1]
%endif
- PAVGB m0, [r0], m3, m5
- PAVGB m2, [r0+r2], m4, m5
+ pavgb m0, [r0]
+ pavgb m2, [r0+r2]
add r1, r4
mova [r0], m0
mova [r0+r2], m2
@@ -341,13 +341,13 @@ cglobal avg_pixels8_x2, 4,5
pavgb m0, m1
pavgb m2, m3
%else
- PAVGB m0, [r1+1], m3, m5
- PAVGB m2, [r1+r2+1], m4, m5
+ pavgb m0, [r1+1]
+ pavgb m2, [r1+r2+1]
%endif
add r0, r4
add r1, r4
- PAVGB m0, [r0], m3, m5
- PAVGB m2, [r0+r2], m4, m5
+ pavgb m0, [r0]
+ pavgb m2, [r0+r2]
mova [r0], m0
mova [r0+r2], m2
add r0, r4
@@ -377,20 +377,20 @@ cglobal avg_pixels8_y2, 4,5
movu m1, [r1+r2]
movu m2, [r1+r4]
add r1, r4
- PAVGB m0, m1
- PAVGB m1, m2
- PAVGB m0, [r0+r2]
- PAVGB m1, [r0+r4]
+ pavgb m0, m1
+ pavgb m1, m2
+ pavgb m0, [r0+r2]
+ pavgb m1, [r0+r4]
mova [r0+r2], m0
mova [r0+r4], m1
movu m1, [r1+r2]
movu m0, [r1+r4]
- PAVGB m2, m1
- PAVGB m1, m0
+ pavgb m2, m1
+ pavgb m1, m0
add r0, r4
add r1, r4
- PAVGB m2, [r0+r2]
- PAVGB m1, [r0+r4]
+ pavgb m2, [r0+r2]
+ pavgb m1, [r0+r4]
mova [r0+r2], m2
mova [r0+r4], m1
add r0, r4
@@ -509,7 +509,7 @@ cglobal %1%3_pixels16_xy2, 4,5,8
%ifidn %1, avg
mova m3, [r0+r4]
packuswb m4, m5
- PAVGB m4, m3
+ pavgb m4, m3
%else
packuswb m4, m5
%endif
@@ -535,7 +535,7 @@ cglobal %1%3_pixels16_xy2, 4,5,8
%ifidn %1, avg
mova m3, [r0+r4]
packuswb m0, m1
- PAVGB m0, m3
+ pavgb m0, m3
%else
packuswb m0, m1
%endif
--
2.49.1
1
0
30 Oct '25
PR #20789 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20789
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20789.patch
From a0fa1c8e484f06cc9a9e2e3cfe53ec121fb74659 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Thu, 30 Oct 2025 08:30:40 +0100
Subject: [PATCH 1/3] avcodec/x86/hevc/add_res: Remove AVX add_residual
functions
The AVX and SSE2 functions are identical except for the VEX encodings
used since e9abef437f0a348c017d4ac8b23a122881c1dc87 and
8b8492452d53293b2ac8c842877fadf7925fc950.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/hevc/add_res.asm | 7 +------
libavcodec/x86/hevc/dsp.h | 4 ----
libavcodec/x86/hevc/dsp_init.c | 4 ----
3 files changed, 1 insertion(+), 14 deletions(-)
diff --git a/libavcodec/x86/hevc/add_res.asm b/libavcodec/x86/hevc/add_res.asm
index 3ecbd4269c..5d7115620f 100644
--- a/libavcodec/x86/hevc/add_res.asm
+++ b/libavcodec/x86/hevc/add_res.asm
@@ -117,7 +117,7 @@ cglobal hevc_add_residual_4_8, 3, 3, 6
%endmacro
-%macro TRANSFORM_ADD_8 0
+INIT_XMM sse2
; void ff_hevc_add_residual_8_8_<opt>(uint8_t *dst, const int16_t *res, ptrdiff_t stride)
cglobal hevc_add_residual_8_8, 3, 4, 8
pxor m4, m4
@@ -154,12 +154,7 @@ cglobal hevc_add_residual_32_8, 3, 5, 7
dec r4d
jg .loop
RET
-%endmacro
-INIT_XMM sse2
-TRANSFORM_ADD_8
-INIT_XMM avx
-TRANSFORM_ADD_8
%if HAVE_AVX2_EXTERNAL
INIT_YMM avx2
diff --git a/libavcodec/x86/hevc/dsp.h b/libavcodec/x86/hevc/dsp.h
index 03986b970a..0062699ce0 100644
--- a/libavcodec/x86/hevc/dsp.h
+++ b/libavcodec/x86/hevc/dsp.h
@@ -172,10 +172,6 @@ void ff_hevc_add_residual_8_8_sse2(uint8_t *dst, const int16_t *res, ptrdiff_t s
void ff_hevc_add_residual_16_8_sse2(uint8_t *dst, const int16_t *res, ptrdiff_t stride);
void ff_hevc_add_residual_32_8_sse2(uint8_t *dst, const int16_t *res, ptrdiff_t stride);
-void ff_hevc_add_residual_8_8_avx(uint8_t *dst, const int16_t *res, ptrdiff_t stride);
-void ff_hevc_add_residual_16_8_avx(uint8_t *dst, const int16_t *res, ptrdiff_t stride);
-void ff_hevc_add_residual_32_8_avx(uint8_t *dst, const int16_t *res, ptrdiff_t stride);
-
void ff_hevc_add_residual_32_8_avx2(uint8_t *dst, const int16_t *res, ptrdiff_t stride);
void ff_hevc_add_residual_4_10_mmxext(uint8_t *dst, const int16_t *res, ptrdiff_t stride);
diff --git a/libavcodec/x86/hevc/dsp_init.c b/libavcodec/x86/hevc/dsp_init.c
index 6966340c42..f1558b7e3e 100644
--- a/libavcodec/x86/hevc/dsp_init.c
+++ b/libavcodec/x86/hevc/dsp_init.c
@@ -877,10 +877,6 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth)
c->idct[0] = ff_hevc_idct_4x4_8_avx;
c->idct[1] = ff_hevc_idct_8x8_8_avx;
-
- c->add_residual[1] = ff_hevc_add_residual_8_8_avx;
- c->add_residual[2] = ff_hevc_add_residual_16_8_avx;
- c->add_residual[3] = ff_hevc_add_residual_32_8_avx;
}
if (EXTERNAL_AVX2(cpu_flags)) {
c->sao_band_filter[0] = ff_hevc_sao_band_filter_8_8_avx2;
--
2.49.1
From 17526beaf2ea13fd7e1484e8af0ae44baee6f8cb Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Thu, 30 Oct 2025 08:49:38 +0100
Subject: [PATCH 2/3] avcodec/x86/hevc/add_res: Reduce number of registers used
This makes these functions use only volatile registers (even on Win64).
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/hevc/add_res.asm | 32 +++++++++++++++++---------------
1 file changed, 17 insertions(+), 15 deletions(-)
diff --git a/libavcodec/x86/hevc/add_res.asm b/libavcodec/x86/hevc/add_res.asm
index 5d7115620f..8abfcab893 100644
--- a/libavcodec/x86/hevc/add_res.asm
+++ b/libavcodec/x86/hevc/add_res.asm
@@ -61,20 +61,16 @@ cglobal hevc_add_residual_4_8, 3, 3, 6
movq m1, [r0+r2]
punpcklbw m0, m4
punpcklbw m1, m4
- mova m2, [r1]
- mova m3, [r1+16]
- paddsw m0, m2
- paddsw m1, m3
+ paddsw m0, [r1]
+ paddsw m1, [r1+16]
packuswb m0, m1
movq m2, [r0+r2*2]
movq m3, [r0+r3]
punpcklbw m2, m4
punpcklbw m3, m4
- mova m6, [r1+32]
- mova m7, [r1+48]
- paddsw m2, m6
- paddsw m3, m7
+ paddsw m2, [r1+32]
+ paddsw m3, [r1+48]
packuswb m2, m3
movq [r0], m0
@@ -88,27 +84,33 @@ cglobal hevc_add_residual_4_8, 3, 3, 6
mova m2, m1
punpcklbw m1, m0
punpckhbw m2, m0
+%if cpuflag(avx2)
mova xm5, [r1+%1]
mova xm6, [r1+%1+16]
-%if cpuflag(avx2)
vinserti128 m5, m5, [r1+%1+32], 1
vinserti128 m6, m6, [r1+%1+48], 1
-%endif
paddsw m1, m5
paddsw m2, m6
+%else
+ paddsw m1, [r1+%1]
+ paddsw m2, [r1+%1+16]
+%endif
mova m3, [%3]
mova m4, m3
punpcklbw m3, m0
punpckhbw m4, m0
+%if cpuflag(avx2)
mova xm5, [r1+%1+mmsize*2]
mova xm6, [r1+%1+mmsize*2+16]
-%if cpuflag(avx2)
vinserti128 m5, m5, [r1+%1+96], 1
vinserti128 m6, m6, [r1+%1+112], 1
-%endif
paddsw m3, m5
paddsw m4, m6
+%else
+ paddsw m3, [r1+%1+mmsize*2]
+ paddsw m4, [r1+%1+mmsize*2+16]
+%endif
packuswb m1, m2
packuswb m3, m4
@@ -119,7 +121,7 @@ cglobal hevc_add_residual_4_8, 3, 3, 6
INIT_XMM sse2
; void ff_hevc_add_residual_8_8_<opt>(uint8_t *dst, const int16_t *res, ptrdiff_t stride)
-cglobal hevc_add_residual_8_8, 3, 4, 8
+cglobal hevc_add_residual_8_8, 3, 4, 5
pxor m4, m4
lea r3, [r2*3]
ADD_RES_SSE_8_8
@@ -129,7 +131,7 @@ cglobal hevc_add_residual_8_8, 3, 4, 8
RET
; void ff_hevc_add_residual_16_8_<opt>(uint8_t *dst, const int16_t *res, ptrdiff_t stride)
-cglobal hevc_add_residual_16_8, 3, 5, 7
+cglobal hevc_add_residual_16_8, 3, 5, 5
pxor m0, m0
lea r3, [r2*3]
mov r4d, 4
@@ -143,7 +145,7 @@ cglobal hevc_add_residual_16_8, 3, 5, 7
RET
; void ff_hevc_add_residual_32_8_<opt>(uint8_t *dst, const int16_t *res, ptrdiff_t stride)
-cglobal hevc_add_residual_32_8, 3, 5, 7
+cglobal hevc_add_residual_32_8, 3, 5, 5
pxor m0, m0
mov r4d, 16
.loop:
--
2.49.1
From 894f415b278a07c9afbe349697bde80bbdab4e11 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
Date: Thu, 30 Oct 2025 09:58:13 +0100
Subject: [PATCH 3/3] avcodec/x86/hevc/add_res: Avoid unnecessary modification
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
---
libavcodec/x86/hevc/add_res.asm | 32 ++++++++++++++------------------
1 file changed, 14 insertions(+), 18 deletions(-)
diff --git a/libavcodec/x86/hevc/add_res.asm b/libavcodec/x86/hevc/add_res.asm
index 8abfcab893..3489e04e2b 100644
--- a/libavcodec/x86/hevc/add_res.asm
+++ b/libavcodec/x86/hevc/add_res.asm
@@ -27,9 +27,9 @@ cextern pw_1023
%define max_pixels_10 pw_1023
; the add_res macros and functions were largely inspired by h264_idct.asm from the x264 project
-%macro ADD_RES_MMX_4_8 0
- mova m0, [r1]
- mova m2, [r1+8]
+%macro ADD_RES_MMX_4_8 1
+ mova m0, [r1+%1]
+ mova m2, [r1+%1+8]
movd m1, [r0]
movd m3, [r0+r2]
@@ -50,27 +50,26 @@ INIT_MMX mmxext
; void ff_hevc_add_residual_4_8_mmxext(uint8_t *dst, const int16_t *res, ptrdiff_t stride)
cglobal hevc_add_residual_4_8, 3, 3, 6
pxor m4, m4
- ADD_RES_MMX_4_8
- add r1, 16
+ ADD_RES_MMX_4_8 0
lea r0, [r0+r2*2]
- ADD_RES_MMX_4_8
+ ADD_RES_MMX_4_8 16
RET
-%macro ADD_RES_SSE_8_8 0
+%macro ADD_RES_SSE_8_8 1
movq m0, [r0]
movq m1, [r0+r2]
punpcklbw m0, m4
punpcklbw m1, m4
- paddsw m0, [r1]
- paddsw m1, [r1+16]
+ paddsw m0, [r1+%1]
+ paddsw m1, [r1+%1+16]
packuswb m0, m1
movq m2, [r0+r2*2]
movq m3, [r0+r3]
punpcklbw m2, m4
punpcklbw m3, m4
- paddsw m2, [r1+32]
- paddsw m3, [r1+48]
+ paddsw m2, [r1+%1+32]
+ paddsw m3, [r1+%1+48]
packuswb m2, m3
movq [r0], m0
@@ -124,10 +123,9 @@ INIT_XMM sse2
cglobal hevc_add_residual_8_8, 3, 4, 5
pxor m4, m4
lea r3, [r2*3]
- ADD_RES_SSE_8_8
- add r1, 64
+ ADD_RES_SSE_8_8 0
lea r0, [r0+r2*4]
- ADD_RES_SSE_8_8
+ ADD_RES_SSE_8_8 64
RET
; void ff_hevc_add_residual_16_8_<opt>(uint8_t *dst, const int16_t *res, ptrdiff_t stride)
@@ -292,9 +290,8 @@ cglobal hevc_add_residual_4_10, 3, 3, 6
pxor m2, m2
mova m3, [max_pixels_10]
ADD_RES_MMX_4_10 r0, r2, r1
- add r1, 16
lea r0, [r0+2*r2]
- ADD_RES_MMX_4_10 r0, r2, r1
+ ADD_RES_MMX_4_10 r0, r2, r1+16
RET
INIT_XMM sse2
@@ -305,8 +302,7 @@ cglobal hevc_add_residual_8_10, 3, 4, 6
ADD_RES_SSE_8_10 r0, r2, r3, r1
lea r0, [r0+r2*4]
- add r1, 64
- ADD_RES_SSE_8_10 r0, r2, r3, r1
+ ADD_RES_SSE_8_10 r0, r2, r3, r1+64
RET
cglobal hevc_add_residual_16_10, 3, 5, 6
--
2.49.1
1
0
Hello all,
It has come to the attention of the FFmpeg Community Council that the owner of the YouTube channel @t3dotgg is being "doxxed". In consideration of the timeline, this is suspected to be an act of retaliation for their recent video "FFmpeg needs to change" and/or other statements.
Many people in the community disagree with him, and some (including myself) have even been upset by the video. That is **NOT** a justification for doxxing.
Such activity is not acceptable or even tolerable in any circumstances. Period. The people involved are not welcome in FFmpeg, and I think that they are in fact not welcome in the broader open-source community. Besides, this sort of action gives us a bad name and is doing us a disservice.
The CC reserves the option to take further action under the FFmpeg CoC.
Thanks for your attention,
Br,
N.B.: This message is my personal opinion, but I doubt that anyone else in the CC will disagree.
4
9