[FFmpeg-devel] [PATCH] avformat/tls_openssl: Don't call functions inside FFMIN (PR #20576)
PR #20576 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20576
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20576.patch
It may call the function multiple times.
>From 5f80608feca66b611cf863b6f46357b32fd8709c Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Mon, 22 Sep 2025 15:34:30 +0200
Subject: [PATCH] avformat/tls_openssl: Don't call functions inside FFMIN
It may call the function multiple times.
Signed-off-by: Andreas Rheinhardt
---
libavformat/tls_openssl.c | 6 --
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/libavformat/tls_openssl.c b/libavformat/tls_openssl.c
index edfd657a3f..86b4d21799 100644
--- a/libavformat/tls_openssl.c
+++ b/libavformat/tls_openssl.c
@@ -939,8 +939,10 @@ static int tls_write(URLContext *h, const uint8_t *buf,
int size)
uc->flags &= ~AVIO_FLAG_NONBLOCK;
uc->flags |= h->flags & AVIO_FLAG_NONBLOCK;
-if (s->is_dtls)
-size = FFMIN(size, DTLS_get_data_mtu(c->ssl));
+if (s->is_dtls) {
+const size_t mtu_size = DTLS_get_data_mtu(c->ssl);
+size = FFMIN(size, mtu_size);
+}
ret = SSL_write(c->ssl, buf, size);
if (ret > 0)
--
2.49.1
___
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] configure: Add missing dependencies for AHX decoder (PR #20581)
PR #20581 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20581
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20581.patch
>From 1fc2742ae595ae175eafca502b976bd8bfd19876 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Tue, 23 Sep 2025 05:40:39 +0200
Subject: [PATCH 1/2] configure: Add missing dependencies for AHX decoder
Signed-off-by: Andreas Rheinhardt
---
configure | 1 +
1 file changed, 1 insertion(+)
diff --git a/configure b/configure
index a7bb518d70..e5764a17a3 100755
--- a/configure
+++ b/configure
@@ -2979,6 +2979,7 @@ adpcm_n64_decoder_deps="lgpl_gpl"
adpcm_psxc_decoder_deps="lgpl_gpl"
agm_decoder_select="idctdsp"
ahx_decoder_deps="lgpl_gpl"
+ahx_decoder_select="mpegaudio ahx_to_mp2_bsf"
aic_decoder_select="golomb idctdsp"
alac_encoder_select="lpc"
als_decoder_select="bswapdsp mpeg4audio"
--
2.49.1
>From 100f869f245e0d675a106a7affbd0ecdef3c70b4 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Tue, 23 Sep 2025 05:42:59 +0200
Subject: [PATCH 2/2] avcodec/mpegaudiodec_float: Don't set AVCodec.sample_fmts
directly
It is deprecated and doing so gives warnings from Clang.
Use CODEC_SAMPLEFMTS instead.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/mpegaudiodec_float.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/libavcodec/mpegaudiodec_float.c b/libavcodec/mpegaudiodec_float.c
index 232e2fa201..e713e9e251 100644
--- a/libavcodec/mpegaudiodec_float.c
+++ b/libavcodec/mpegaudiodec_float.c
@@ -115,9 +115,7 @@ const FFCodec ff_ahx_decoder = {
.p.capabilities = AV_CODEC_CAP_CHANNEL_CONF |
AV_CODEC_CAP_DR1,
.flush = flush,
-.p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
- AV_SAMPLE_FMT_FLT,
- AV_SAMPLE_FMT_NONE },
+CODEC_SAMPLEFMTS(AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_FLT),
.bsfs = "ahx_to_mp2",
};
#endif
--
2.49.1
___
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] avformat/mccenc: Various stuff (PR #20556)
PR #20556 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20556
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20556.patch
Also a bit mccdec.
>From 8e4cbb053bd2dd9c345701e940e5ff4ec2eca766 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Fri, 19 Sep 2025 19:42:24 +0200
Subject: [PATCH 01/11] avformat/mccenc: Remove redundant check
This has already been checked in init.
Signed-off-by: Andreas Rheinhardt
---
libavformat/mccenc.c | 4
1 file changed, 4 deletions(-)
diff --git a/libavformat/mccenc.c b/libavformat/mccenc.c
index 298bc6dd1a..f978c420a3 100644
--- a/libavformat/mccenc.c
+++ b/libavformat/mccenc.c
@@ -158,10 +158,6 @@ static AVRational valid_time_code_rates[] = {
static int mcc_write_header(AVFormatContext *avf)
{
MCCContext *mcc = avf->priv_data;
-if (avf->nb_streams != 1) {
-av_log(avf, AV_LOG_ERROR, "mcc muxer supports at most one stream\n");
-return AVERROR(EINVAL);
-}
avpriv_set_pts_info(avf->streams[0], 64, mcc->timecode.rate.den,
mcc->timecode.rate.num);
const char *mcc_header = mcc_header_v1;
switch ((MCCVersion)mcc->mcc_version) {
--
2.49.1
>From ad7261e64b7bfa201c89c8ac841b0e4b8101bd95 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Fri, 19 Sep 2025 18:49:42 +0200
Subject: [PATCH 02/11] avformat/mccenc: Fix assert check
Signed-off-by: Andreas Rheinhardt
---
libavformat/mccenc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavformat/mccenc.c b/libavformat/mccenc.c
index f978c420a3..02541caeb3 100644
--- a/libavformat/mccenc.c
+++ b/libavformat/mccenc.c
@@ -208,7 +208,7 @@ static int mcc_write_header(AVFormatContext *avf)
"December",
};
// assert that values are sane so we don't index out of bounds
-av_assert0(tm.tm_mon >= 0 && tm.tm_mon <= FF_ARRAY_ELEMS(months));
+av_assert0(tm.tm_mon >= 0 && tm.tm_mon < FF_ARRAY_ELEMS(months));
const char *month = months[tm.tm_mon];
static const char *const weekdays[7] = {
--
2.49.1
>From f778c205222909aac0f3f70bb439076272adb0ee Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Fri, 19 Sep 2025 19:16:06 +0200
Subject: [PATCH 03/11] avformat/mccenc: Remove redundant setting of time base
It has already been done in init.
Signed-off-by: Andreas Rheinhardt
---
libavformat/mccenc.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/libavformat/mccenc.c b/libavformat/mccenc.c
index 02541caeb3..bdc8425408 100644
--- a/libavformat/mccenc.c
+++ b/libavformat/mccenc.c
@@ -158,7 +158,6 @@ static AVRational valid_time_code_rates[] = {
static int mcc_write_header(AVFormatContext *avf)
{
MCCContext *mcc = avf->priv_data;
-avpriv_set_pts_info(avf->streams[0], 64, mcc->timecode.rate.den,
mcc->timecode.rate.num);
const char *mcc_header = mcc_header_v1;
switch ((MCCVersion)mcc->mcc_version) {
case MCC_VERSION_1:
--
2.49.1
>From 0b30d2bd8a6e4f53d5dc8286ef63b4931dceb196 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Fri, 19 Sep 2025 19:16:44 +0200
Subject: [PATCH 04/11] avformat/mccenc: Constify read-only data
Signed-off-by: Andreas Rheinhardt
---
libavformat/mccenc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavformat/mccenc.c b/libavformat/mccenc.c
index bdc8425408..c46fa033cc 100644
--- a/libavformat/mccenc.c
+++ b/libavformat/mccenc.c
@@ -145,7 +145,7 @@ static const char mcc_header_v2[] = //
*/
static const char mcc_ffmpeg_uuid[] = "0087C4F6-A6B4-5469-8C8E-BBF44950401D";
-static AVRational valid_time_code_rates[] = {
+static const AVRational valid_time_code_rates[] = {
{ .num = 24,.den = 1},
{ .num = 25,.den = 1},
{ .num = 3, .den = 1001 },
--
2.49.1
>From eacf11da84a2dd77d945cf98e9338f955bcc9d40 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Fri, 19 Sep 2025 19:53:33 +0200
Subject: [PATCH 05/11] avformat/mccenc: Deduplicate strings
Signed-off-by: Andreas Rheinhardt
---
libavformat/mccenc.c | 122 +++
1 file changed, 41 insertions(+), 81 deletions(-)
diff --git a/libavformat/mccenc.c b/libavformat/mccenc.c
index c46fa033cc..1baa007d66 100644
--- a/libavformat/mccenc.c
+++ b/libavformat/mccenc.c
@@ -58,83 +58,47 @@ typedef enum MCCVersion
MCC_VERSION_MAX = MCC_VERSION_2,
} MCCVersion;
-static const char mcc_header_v1[] = //
-"File Format=MacCaption_MCC V1.0\n"
-"\n"
+#define MCC_HEADER
\
+"File Format=MacCaption_MCC V%c.0\n"
\
+"\n"
\
+
"///\n"
\
+"// Computer Prompting and Captioning Company\n"
\
+
[FFmpeg-devel] [PATCH] Don't link all of libavfilter in checkasm (PR #20529)
PR #20529 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20529
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20529.patch
>From 10ff1b2875904afbf8059e271fa664d90c5c30f3 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Mon, 15 Sep 2025 18:45:24 +0200
Subject: [PATCH 1/3] avfilter/vf_colordetect: Rename header to
vf_colordetectdsp.h
It is more in line with our naming conventions.
Signed-off-by: Andreas Rheinhardt
---
libavfilter/aarch64/vf_colordetect_init.c | 2 +-
libavfilter/vf_colordetect.c | 2 +-
libavfilter/{vf_colordetect.h => vf_colordetectdsp.h} | 6 +++---
libavfilter/x86/vf_colordetect_init.c | 2 +-
tests/checkasm/vf_colordetect.c | 2 +-
5 files changed, 7 insertions(+), 7 deletions(-)
rename libavfilter/{vf_colordetect.h => vf_colordetectdsp.h} (98%)
diff --git a/libavfilter/aarch64/vf_colordetect_init.c
b/libavfilter/aarch64/vf_colordetect_init.c
index 4db6b90542..2fd23513e3 100644
--- a/libavfilter/aarch64/vf_colordetect_init.c
+++ b/libavfilter/aarch64/vf_colordetect_init.c
@@ -19,7 +19,7 @@
*/
#include "libavutil/aarch64/cpu.h"
-#include "libavfilter/vf_colordetect.h"
+#include "libavfilter/vf_colordetectdsp.h"
int ff_detect_alpha_full_neon(const uint8_t *color, ptrdiff_t color_stride,
const uint8_t *alpha, ptrdiff_t alpha_stride,
diff --git a/libavfilter/vf_colordetect.c b/libavfilter/vf_colordetect.c
index ef7fb25130..7abe6659a3 100644
--- a/libavfilter/vf_colordetect.c
+++ b/libavfilter/vf_colordetect.c
@@ -37,7 +37,7 @@
#include "formats.h"
#include "video.h"
-#include "vf_colordetect.h"
+#include "vf_colordetectdsp.h"
enum ColorDetectMode {
COLOR_DETECT_COLOR_RANGE = 1 << 0,
diff --git a/libavfilter/vf_colordetect.h b/libavfilter/vf_colordetectdsp.h
similarity index 98%
rename from libavfilter/vf_colordetect.h
rename to libavfilter/vf_colordetectdsp.h
index aa974bb1fd..2ce3d061a3 100644
--- a/libavfilter/vf_colordetect.h
+++ b/libavfilter/vf_colordetectdsp.h
@@ -16,8 +16,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef AVFILTER_COLORDETECT_H
-#define AVFILTER_COLORDETECT_H
+#ifndef AVFILTER_COLORDETECTDSP_H
+#define AVFILTER_COLORDETECTDSP_H
#include
#include
@@ -195,4 +195,4 @@ ff_detect_alpha16_limited_c(const uint8_t *color, ptrdiff_t
color_stride,
return transparent ? FF_ALPHA_TRANSPARENT : 0;
}
-#endif /* AVFILTER_COLORDETECT_H */
+#endif /* AVFILTER_COLORDETECTDSP_H */
diff --git a/libavfilter/x86/vf_colordetect_init.c
b/libavfilter/x86/vf_colordetect_init.c
index 72fa021bf2..7257b5c4f5 100644
--- a/libavfilter/x86/vf_colordetect_init.c
+++ b/libavfilter/x86/vf_colordetect_init.c
@@ -20,7 +20,7 @@
#include "libavutil/attributes.h"
#include "libavutil/x86/cpu.h"
-#include "libavfilter/vf_colordetect.h"
+#include "libavfilter/vf_colordetectdsp.h"
#define DETECT_RANGE_FUNC(FUNC_NAME, ASM_FUNC_NAME, C_FUNC_NAME, SHIFT,
MMSIZE) \
int ASM_FUNC_NAME(const uint8_t *src, ptrdiff_t stride,
\
diff --git a/tests/checkasm/vf_colordetect.c b/tests/checkasm/vf_colordetect.c
index 18472e9b66..471f77fcc7 100644
--- a/tests/checkasm/vf_colordetect.c
+++ b/tests/checkasm/vf_colordetect.c
@@ -19,7 +19,7 @@
#include
#include "checkasm.h"
-#include "libavfilter/vf_colordetect.h"
+#include "libavfilter/vf_colordetectdsp.h"
#include "libavutil/mem_internal.h"
#define WIDTH 540
--
2.49.1
>From 9dc8797420e8161a53dac0813d64cacbf9f2dc95 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Mon, 15 Sep 2025 19:14:39 +0200
Subject: [PATCH 2/3] avfilter/vf_colordetect: Avoid sequentially consistent
atomics
Signed-off-by: Andreas Rheinhardt
---
libavfilter/vf_colordetect.c | 27 +--
1 file changed, 17 insertions(+), 10 deletions(-)
diff --git a/libavfilter/vf_colordetect.c b/libavfilter/vf_colordetect.c
index 7abe6659a3..ee4288c839 100644
--- a/libavfilter/vf_colordetect.c
+++ b/libavfilter/vf_colordetect.c
@@ -138,7 +138,8 @@ static int detect_range(AVFilterContext *ctx, void *arg,
if (s->dsp.detect_range(in->data[0] + y_start * stride, stride,
in->width, h_slice, s->mpeg_min, s->mpeg_max))
-atomic_store(&s->detected_range, AVCOL_RANGE_JPEG);
+atomic_store_explicit(&s->detected_range, AVCOL_RANGE_JPEG,
+ memory_order_relaxed);
return 0;
}
@@ -194,11 +195,13 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
ColorDetectContext *s = ctx->priv;
const int nb_threads = FFMIN(inlink->h, s->nb_threads);
-if (s->mode & COLOR_DETECT_COLOR_RANGE && s->detected_range ==
AVCOL_RANGE_UNSPECIFIED)
+enum AVColorRange detected_range =
atomic_load_explicit(&s->detected_range, memory_order_relaxed);
+if (s->mode & COLOR_DETECT_COLOR_RANGE && detected_range ==
AVCOL_RANGE_UNSPECIFIED)
[FFmpeg-devel] [PATCH] avcodec/decode: Inline EXIF Orientation tag value (PR #20530)
PR #20530 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20530
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20530.patch
>From 2438cd28d45abb2d100f6b672f0e558e807a6714 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Mon, 15 Sep 2025 20:10:05 +0200
Subject: [PATCH] avcodec/decode: Inline EXIF Orientation tag value
Signed-off-by: Andreas Rheinhardt
---
libavcodec/decode.c| 3 ++-
libavcodec/exif.c | 5 ++---
libavcodec/exif_internal.h | 2 ++
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index ae86e270df..3d9b91a228 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -48,6 +48,7 @@
#include "codec_internal.h"
#include "decode.h"
#include "exif.h"
+#include "exif_internal.h"
#include "hwaccel_internal.h"
#include "hwconfig.h"
#include "internal.h"
@@ -2360,7 +2361,7 @@ static int exif_attach_ifd(AVCodecContext *avctx, AVFrame
*frame, const AVExifMe
for (size_t i = 0; i < ifd->count; i++) {
const AVExifEntry *entry = &ifd->entries[i];
-if (entry->id == av_exif_get_tag_id("Orientation") &&
+if (entry->id == EXIF_ORIENTATION_TAG &&
entry->count > 0 && entry->type == AV_TIFF_SHORT) {
orient = entry;
break;
diff --git a/libavcodec/exif.c b/libavcodec/exif.c
index f9ad3e1bdb..5c9a84420d 100644
--- a/libavcodec/exif.c
+++ b/libavcodec/exif.c
@@ -47,7 +47,6 @@
#define EXIF_TAG_NAME_LENGTH 32
#define MAKERNOTE_TAG 0x927c
-#define ORIENTATION_TAG0x112
#define EXIFIFD_TAG0x8769
#define IMAGE_WIDTH_TAG0x100
#define IMAGE_LENGTH_TAG 0x101
@@ -1250,7 +1249,7 @@ int ff_exif_sanitize_ifd(void *logctx, const AVFrame
*frame, AVExifMetadata *ifd
for (size_t i = 0; i < ifd->count; i++) {
AVExifEntry *entry = &ifd->entries[i];
-if (entry->id == ORIENTATION_TAG && entry->count > 0 && entry->type ==
AV_TIFF_SHORT) {
+if (entry->id == EXIF_ORIENTATION_TAG && entry->count > 0 &&
entry->type == AV_TIFF_SHORT) {
or = entry;
continue;
}
@@ -1300,7 +1299,7 @@ int ff_exif_sanitize_ifd(void *logctx, const AVFrame
*frame, AVExifMetadata *ifd
}
if (!or && orientation != 1) {
rewrite = 1;
-ret = av_exif_set_entry(logctx, ifd, ORIENTATION_TAG, AV_TIFF_SHORT,
1, NULL, 0, &orientation);
+ret = av_exif_set_entry(logctx, ifd, EXIF_ORIENTATION_TAG,
AV_TIFF_SHORT, 1, NULL, 0, &orientation);
if (ret < 0)
goto end;
}
diff --git a/libavcodec/exif_internal.h b/libavcodec/exif_internal.h
index c0d2b3ef62..6c3ae3becb 100644
--- a/libavcodec/exif_internal.h
+++ b/libavcodec/exif_internal.h
@@ -36,6 +36,8 @@
#include "exif.h"
#include "version_major.h"
+#define EXIF_ORIENTATION_TAG0x112
+
#if LIBAVCODEC_VERSION_MAJOR < 63
/* Used by the AVI demuxer */
int avpriv_exif_decode_ifd(void *logctx, const uint8_t *buf, int size,
--
2.49.1
___
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] avcodec/h274: Make H274FilmGrainDatabase a shared object (PR #20549)
PR #20549 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20549
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20549.patch
Right now, the private contexts of every decoder supporting
H.274 film grain synthesis (namely H.264, HEVC and VVC)
contain a H274FilmGrainDatabase; said structure is very large
700442B before this commit) and takes up the overwhelming
majority of said contexts: Removing it reduces sizeof(H264Context)
by 92.88%, sizeof(HEVCContext) by 97.78% and sizeof(VVCContext)
by 99.86%. This is especially important for H.264 and HEVC
when using frame-threading.
The content of said film grain database does not depend on
any input parameter; it is shareable between all its users and
could be hardcoded in the binary (but isn't, because it is so huge).
This commit adds a database with static storage duration to h274.c
and uses it instead of the elements in the private contexts above.
It is still lazily initialized as-needed; a mutex is used
for the necessary synchronization. An alternative would be to use
an AV_ONCE to initialize the whole database either in the decoders'
init function (which would be wasteful given that most videos
don't use film grain synthesis) or in ff_h274_apply_film_grain().
>From 8569976d747f422c4ce88a0248525b60259541de Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Thu, 18 Sep 2025 17:57:16 +0200
Subject: [PATCH] avcodec/h274: Make H274FilmGrainDatabase a shared object
Right now, the private contexts of every decoder supporting
H.274 film grain synthesis (namely H.264, HEVC and VVC)
contain a H274FilmGrainDatabase; said structure is very large
700442B before this commit) and takes up the overwhelming
majority of said contexts: Removing it reduces sizeof(H264Context)
by 92.88%, sizeof(HEVCContext) by 97.78% and sizeof(VVCContext)
by 99.86%. This is especially important for H.264 and HEVC
when using frame-threading.
The content of said film grain database does not depend on
any input parameter; it is shareable between all its users and
could be hardcoded in the binary (but isn't, because it is so huge).
This commit adds a database with static storage duration to h274.c
and uses it instead of the elements in the private contexts above.
It is still lazily initialized as-needed; a mutex is used
for the necessary synchronization. An alternative would be to use
an AV_ONCE to initialize the whole database either in the decoders'
init function (which would be wasteful given that most videos
don't use film grain synthesis) or in ff_h274_apply_film_grain().
Signed-off-by: Andreas Rheinhardt
---
libavcodec/h264_picture.c | 4 ++--
libavcodec/h264dec.h | 3 ---
libavcodec/h274.c | 42 ++-
libavcodec/h274.h | 11 --
libavcodec/hevc/hevcdec.c | 4 ++--
libavcodec/hevc/hevcdec.h | 3 ---
libavcodec/vvc/dec.c | 3 +--
libavcodec/vvc/dec.h | 1 -
8 files changed, 38 insertions(+), 33 deletions(-)
diff --git a/libavcodec/h264_picture.c b/libavcodec/h264_picture.c
index f5d2b31cd6..aa3d2629c8 100644
--- a/libavcodec/h264_picture.c
+++ b/libavcodec/h264_picture.c
@@ -30,10 +30,10 @@
#include "error_resilience.h"
#include "avcodec.h"
#include "h264dec.h"
+#include "h274.h"
#include "hwaccel_internal.h"
#include "mpegutils.h"
#include "libavutil/refstruct.h"
-#include "thread.h"
#include "threadframe.h"
void ff_h264_unref_picture(H264Picture *pic)
@@ -213,7 +213,7 @@ int ff_h264_field_end(H264Context *h, H264SliceContext *sl,
int in_setup)
err = AVERROR_INVALIDDATA;
if (sd) // a decoding error may have happened before the side data
could be allocated
-err = ff_h274_apply_film_grain(cur->f_grain, cur->f, &h->h274db,
+err = ff_h274_apply_film_grain(cur->f_grain, cur->f,
(AVFilmGrainParams *) sd->data);
if (err < 0) {
av_log(h->avctx, AV_LOG_WARNING, "Failed synthesizing film "
diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h
index 1df99015cc..74fd09dfaa 100644
--- a/libavcodec/h264dec.h
+++ b/libavcodec/h264dec.h
@@ -28,7 +28,6 @@
#ifndef AVCODEC_H264DEC_H
#define AVCODEC_H264DEC_H
-#include "libavutil/buffer.h"
#include "libavutil/mem_internal.h"
#include "cabac.h"
@@ -41,7 +40,6 @@
#include "h264dsp.h"
#include "h264pred.h"
#include "h264qpel.h"
-#include "h274.h"
#include "mpegutils.h"
#include "threadframe.h"
#include "videodsp.h"
@@ -344,7 +342,6 @@ typedef struct H264Context {
H264DSPContext h264dsp;
H264ChromaContext h264chroma;
H264QpelContext h264qpel;
-H274FilmGrainDatabase h274db;
H264Picture DPB[H264_MAX_PICTURE_COUNT];
H264Picture *cur_pic_ptr;
diff --git a/libavcodec/h274.c b/libavcodec/h274.c
index 332d0c2c52..81bbea7bfa 100644
--- a/libavcodec/h274.c
+++ b/libavcodec/h274.c
@@ -25,6 +25,8 @@
* @author Niklas Haas
*/
+#include
+
#include "libavutil/avassert.h"
#include "libavutil
[FFmpeg-devel] [PATCH] Revert "avformat/tls_openssl: add av_assert0() for tls_shared" (PR #20548)
PR #20548 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20548
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20548.patch
This reverts commits fd55c4b5f72a157fbb128d0ef203e9922b53552b
(for tls_openssl.c) and c74181a04b5f4e650eae662231e56518daef64d4
(for tls_gnutls.c).
It is impossible for a pointer to a member of a structure
to be NULL: If the containing structure exists, the member
exists and can't have a NULL address; if the containing
structure does not exist, then getting a pointer to the
substructure via &c->tls_shared would already be undefined
behavior (and if c were NULL, then the (UB) pointer arithmetic
performed under the hood to access the member would most likely
yield a pointer pointing to the address offsetof(TLSContext,tls_shared)
which would pass the asserts).
Signed-off-by: Andreas Rheinhardt
>From fa8309d3de658e8a51ee208edb5ecefe29ad561f Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Thu, 18 Sep 2025 14:58:55 +0200
Subject: [PATCH] Revert "avformat/tls_openssl: add av_assert0() for
tls_shared"
This reverts commits fd55c4b5f72a157fbb128d0ef203e9922b53552b
(for tls_openssl.c) and c74181a04b5f4e650eae662231e56518daef64d4
(for tls_gnutls.c).
It is impossible for a pointer to a member of a structure
to be NULL: If the containing structure exists, the member
exists and can't have a NULL address; if the containing
structure does not exist, then getting a pointer to the
substructure via &c->tls_shared would already be undefined
behavior (and if c were NULL, then the (UB) pointer arithmetic
performed under the hood to access the member would most likely
yield a pointer pointing to the address offsetof(TLSContext,tls_shared)
which would pass the asserts).
Signed-off-by: Andreas Rheinhardt
---
libavformat/tls_gnutls.c | 3 ---
libavformat/tls_openssl.c | 3 ---
2 files changed, 6 deletions(-)
diff --git a/libavformat/tls_gnutls.c b/libavformat/tls_gnutls.c
index 53306872a0..272603f1dd 100644
--- a/libavformat/tls_gnutls.c
+++ b/libavformat/tls_gnutls.c
@@ -30,7 +30,6 @@
#include "os_support.h"
#include "url.h"
#include "tls.h"
-#include "libavutil/avassert.h"
#include "libavutil/opt.h"
#include "libavutil/thread.h"
@@ -157,7 +156,6 @@ static int tls_open(URLContext *h, const char *uri, int
flags, AVDictionary **op
TLSShared *s = &c->tls_shared;
uint16_t gnutls_flags = 0;
int ret;
-av_assert0(s);
ff_gnutls_init();
@@ -263,7 +261,6 @@ static int dtls_open(URLContext *h, const char *uri, int
flags, AVDictionary **o
{
TLSContext *c = h->priv_data;
TLSShared *s = &c->tls_shared;
-av_assert0(s);
s->is_dtls = 1;
return tls_open(h, uri, flags, options);
}
diff --git a/libavformat/tls_openssl.c b/libavformat/tls_openssl.c
index db7147e491..7068497325 100644
--- a/libavformat/tls_openssl.c
+++ b/libavformat/tls_openssl.c
@@ -20,7 +20,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "libavutil/avassert.h"
#include "libavutil/mem.h"
#include "network.h"
#include "os_support.h"
@@ -747,7 +746,6 @@ static int dtls_start(URLContext *h, const char *url, int
flags, AVDictionary **
TLSContext *c = h->priv_data;
TLSShared *s = &c->tls_shared;
int ret = 0;
-av_assert0(s);
s->is_dtls = 1;
c->ctx = SSL_CTX_new(s->listen ? DTLS_server_method() :
DTLS_client_method());
@@ -848,7 +846,6 @@ static int tls_open(URLContext *h, const char *uri, int
flags, AVDictionary **op
TLSShared *s = &c->tls_shared;
int ret;
-av_assert0(s);
if ((ret = ff_tls_open_underlying(s, h, uri, options)) < 0)
goto fail;
--
2.49.1
___
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] Avoid using MMX in me_cmp (PR #20705)
PR #20705 opened by mkver URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20705 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20705.patch One could probably replace the hadamard mmxext functions by SSE2 ones if one just used an unaligned load/store in case one does not have an aligned stack. >From 7d72001ccf1e35ccac9ea0c632f517c61490a254 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 13 Oct 2025 21:20:40 +0200 Subject: [PATCH 1/3] avcodec/x86/me_cmp: Add SSE2 sad 8,16 xy2 functions The new functions are faster than the existing exact functions, yet get beaten by the nonexact functions (they can avoid unpacking to words and back). The exact (slow) MMX functions have therefore been removed, which was actually beneficial size-wise (416B of new functions, 619B of functions removed). pix_abs_0_3_c: 216.8 ( 1.00x) pix_abs_0_3_mmx:71.8 ( 3.02x) pix_abs_0_3_mmxext (approximative): 17.6 (12.34x) pix_abs_0_3_sse2: 23.5 ( 9.23x) pix_abs_0_3_sse2 (approximative):9.9 (21.94x) pix_abs_1_3_c: 98.4 ( 1.00x) pix_abs_1_3_mmx:36.9 ( 2.66x) pix_abs_1_3_mmxext (approximative): 9.2 (10.73x) pix_abs_1_3_sse2: 14.8 ( 6.63x) Signed-off-by: Andreas Rheinhardt --- libavcodec/x86/me_cmp.asm| 99 ++- libavcodec/x86/me_cmp_init.c | 128 +++ 2 files changed, 106 insertions(+), 121 deletions(-) diff --git a/libavcodec/x86/me_cmp.asm b/libavcodec/x86/me_cmp.asm index a494cdeb64..ee83556d14 100644 --- a/libavcodec/x86/me_cmp.asm +++ b/libavcodec/x86/me_cmp.asm @@ -23,10 +23,9 @@ %include "libavutil/x86/x86util.asm" -SECTION_RODATA - cextern pb_1 cextern pb_80 +cextern pw_2 SECTION .text @@ -667,6 +666,102 @@ SAD_Y2 16 INIT_XMM sse2 SAD_Y2 16 +;-- +;int ff_sad_xy2_(MPVEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t stride, int h); +;-- + +;%1 = 8/16, %2 = aligned mov, %3 = unaligned mov +%macro SAD_XY2 3 +cglobal sad%1_xy2, 5, 5, mmsize == 16 ? 8 + ARCH_X86_64 : 7, v, pix1, pix2, stride, h +mov%3 m2, [pix2q] +mov%3 m3, [pix2q+1] +%if %1 == mmsize +%if ARCH_X86_64 +mova m8, [pw_2] +%define PW_2 m8 +%else +%define PW_2 [pw_2] +%endif +%else ; %1 != mmsize +mova m6, [pw_2] +%define PW_2 m6 +%endif +pxor m1, m1 +addpix2q, strideq +%if %1 != mmsize/2 +mova m6, m2 +mova m7, m3 +punpckhbw m6, m1 +punpckhbw m7, m1 +paddw m6, m7 +%endif +punpcklbw m2, m1 +punpcklbw m3, m1 +paddw m2, m3 +mova m0, m1 + +.loop: +mov%3 m3, [pix2q] +mov%3 m4, [pix2q+1] +%if %1 != mmsize/2 +mova m5, m3 +mova m7, m4 +punpckhbw m5, m1 +punpckhbw m7, m1 +paddw m7, m5 +paddw m7, PW_2 +paddw m6, m7 +psraw m6, 2 +%endif +mov%2 m5, [pix1q] +punpcklbw m3, m1 +punpcklbw m4, m1 +paddw m3, m4 +paddw m3, PW_2 +paddw m2, m3 +psraw m2, 2 +packuswb m2, m6 +psadbwm2, m5 +paddw m0, m2 + +mov%3 m2, [pix2q+strideq] +mov%3 m4, [pix2q+strideq+1] +%if %1 != mmsize/2 +mova m5, m2 +mova m6, m4 +punpckhbw m5, m1 +punpckhbw m6, m1 +paddw m6, m5 +paddw m7, m6 +psraw m7, 2 +%endif +mov%2 m5, [pix1q+strideq] +punpcklbw m2, m1 +punpcklbw m4, m1 +paddw m2, m4 +paddw m3, m2 +psraw m3, 2 +packuswb m3, m7 +psadbwm3, m5 +paddw m0, m3 + +sub hd, 2 +leapix1q, [pix1q+2*strideq] +leapix2q, [pix2q+2*strideq] +jnz.loop + +%if %1 == 16 +movhlps m1, m0 +paddw m0, m1 +%endif +movd eax, m0 +RET +%endmacro + +INIT_XMM sse2 +SAD_XY2 8, h, h +SAD_XY2 16, a, u + ;--- ;int ff_sad_approx_xy2_(MPVEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t stride, int h); ;--- diff --git a/libavcodec/x86/me_cmp_init.c b/libavcodec/x86/me_cmp_init.c index 45425f7109..a3897e2a0b 100644 --- a/libavcodec/x86/me_cmp_init.c +++ b/libavcodec/x86/me_cmp_init.c @@ -24,8 +24,6 @@ #include "libavutil/attributes.h" #include "libavutil/cpu.h" -#include "libavutil/mem_internal.h" -#include "libavutil/x86/asm.h" #include "libavutil/x86/cpu.h" #include "libavcodec/me_cmp.h" #include "libavcodec/mpegvide
[FFmpeg-devel] [PATCH] Nuke a few MMX functions, HpelDSP patches (PR #20582)
PR #20582 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20582
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20582.patch
>From 45f89dbd435e83ed76acc410b14a44dce1a72f95 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Sun, 21 Sep 2025 22:51:18 +0200
Subject: [PATCH 01/20] avcodec/hpeldsp: Fix documentation
This commit fixes two issues in the documentation:
a) The documentation for {put,avg}_pixels_tab only mentions
widths 16 and 8, although it explicitly mentions that there
are four horizontal blocksizes. This part of the patch
basically reverts e5771f4f37b67951485205e110f4da5e7e32ea74.
b) The restrictions on height don't match the reality. While
most users abide by it, some do not:
i) vp56.c copies a 16x12 block.
ii) indeo3 can copy an arbitrary multiple of four lines
for block widths 4, 8 and 16.
iii) SVQ3 can use block sizes luma block sizes 16x16, 8x16,
16x8, 8x8, 4x8, 8x4 and 4x4 and the corresponding
8x8, 4x8, 8x4, 4x4, 2x4, 4x2 and 2x2 chroma block sizes.
This implies that for widths 2 and 4 height can be two
and is guaranteed to be at least even. For all other widths,
height can be a multiple of four.
Furthermore, a comment for the SVQ3 blocksizes has been added.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/hpeldsp.h | 21 +++--
libavcodec/svq3.c| 1 +
2 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/libavcodec/hpeldsp.h b/libavcodec/hpeldsp.h
index 41a46f0760..1f6a165bf6 100644
--- a/libavcodec/hpeldsp.h
+++ b/libavcodec/hpeldsp.h
@@ -31,11 +31,12 @@
#include
#include
-/* add and put pixel (decoding) */
-// blocksizes for hpel_pixels_func are 8x4,8x8 16x8 16x16
-// h for hpel_pixels_func is limited to {width/2, width} but never larger
-// than 16 and never smaller than 4
-typedef void (*op_pixels_func)(uint8_t *block /*align width (8 or 16)*/,
+/**
+ * Average and put pixel
+ * Widths can be 16, 8, 4 or 2. For for widths 2 and 4, h is always a positive
+ * multiple of 2; otherwise, it is a positive multiple of 4.
+ */
+typedef void (*op_pixels_func)(uint8_t *block /* align width */,
const uint8_t *pixels /*align 1*/,
ptrdiff_t line_size, int h);
@@ -46,8 +47,8 @@ typedef struct HpelDSPContext {
/**
* Halfpel motion compensation with rounding (a+b+1)>>1.
* this is an array[4][4] of motion compensation functions for 4
- * horizontal blocksizes (8,16) and the 4 halfpel positions
- * *pixels_tab[ 0->16xH 1->8xH ][ xhalfpel + 2*yhalfpel ]
+ * horizontal blocksizes (2,4,8,16) and the 4 halfpel positions
+ * *pixels_tab[ 0->16xH 1->8xH 2->4xH 3->2xH ][ xhalfpel + 2*yhalfpel ]
* @param block destination where the result is stored
* @param pixels source
* @param line_size number of bytes in a horizontal line of block
@@ -58,8 +59,8 @@ typedef struct HpelDSPContext {
/**
* Halfpel motion compensation with rounding (a+b+1)>>1.
* This is an array[4][4] of motion compensation functions for 4
- * horizontal blocksizes (8,16) and the 4 halfpel positions
- * *pixels_tab[ 0->16xH 1->8xH ][ xhalfpel + 2*yhalfpel ]
+ * horizontal blocksizes (2,4,8,16) and the 4 halfpel positions
+ * *pixels_tab[ 0->16xH 1->8xH 2->4xH 3->2xH ][ xhalfpel + 2*yhalfpel ]
* @param block destination into which the result is averaged (a+b+1)>>1
* @param pixels source
* @param line_size number of bytes in a horizontal line of block
@@ -85,7 +86,7 @@ typedef struct HpelDSPContext {
* Halfpel motion compensation with no rounding (a+b)>>1.
* this is an array[4] of motion compensation functions for 1
* horizontal blocksize (16) and the 4 halfpel positions
- * *pixels_tab[0][ xhalfpel + 2*yhalfpel ]
+ * *pixels_tab[ xhalfpel + 2*yhalfpel ]
* @param block destination into which the result is averaged (a+b)>>1
* @param pixels source
* @param line_size number of bytes in a horizontal line of block
diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c
index 4c4f3018c5..dfcfce77d3 100644
--- a/libavcodec/svq3.c
+++ b/libavcodec/svq3.c
@@ -504,6 +504,7 @@ static inline int svq3_mc_dir(SVQ3Context *s, int size, int
mode,
int dir, int avg)
{
int i, j, k, mx, my, dx, dy, x, y;
+// 0->16x16,1->8x16,2->16x8,3->8x8,4->4x8,5->8x4,6->4x4
const int part_width= ((size & 5) == 4) ? 4 : 16 >> (size & 1);
const int part_height = 16 >> ((unsigned)(size + 1) / 3);
const int extra_width = (mode == PREDICT_MODE) ? -16 * 6 : 0;
--
2.49.1
>From b9b6c00e625b31e5fe34963d8b3d14ef89086cf8 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Tue, 23 Sep 2025 05:34:37 +0200
Subject: [PATCH 02/20] avcodec/hpel_template: Fix unintentional usage of
unsigned offsets
The value of sizeof() is of type size_t which means that
an expression like
src1[i * src_stride1 + 4 * (int)sizeof(pixel)]
will use a very large offset
[FFmpeg-devel] [PATCH] avfilter/vf_colorspace: Make array smaller (PR #20575)
PR #20575 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20575
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20575.patch
>From 5cb58a94a6fc59d96fafbffb10b4a191409e7223 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Mon, 22 Sep 2025 14:40:24 +0200
Subject: [PATCH 1/2] avfilter/vf_colorspace: Make array smaller
Also makes it more independent of AVCOL_TRC_NB.
Signed-off-by: Andreas Rheinhardt
---
libavfilter/vf_colorspace.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavfilter/vf_colorspace.c b/libavfilter/vf_colorspace.c
index f919350d65..52e84abbe1 100644
--- a/libavfilter/vf_colorspace.c
+++ b/libavfilter/vf_colorspace.c
@@ -171,7 +171,7 @@ typedef struct ColorSpaceContext {
// FIXME I'm pretty sure gamma22/28 also have a linear toe slope, but I can't
// find any actual tables that document their real values...
// See http://www.13thmonkey.org/~boris/gammacorrection/ first graph why it
matters
-static const struct TransferCharacteristics
transfer_characteristics[AVCOL_TRC_NB] = {
+static const struct TransferCharacteristics transfer_characteristics[] = {
[AVCOL_TRC_BT709] = { 1.099, 0.018, 0.45, 4.5 },
[AVCOL_TRC_GAMMA22] = { 1.0,0.0,1.0 / 2.2, 0.0 },
[AVCOL_TRC_GAMMA28] = { 1.0,0.0,1.0 / 2.8, 0.0 },
@@ -189,7 +189,7 @@ static const struct TransferCharacteristics *
{
const struct TransferCharacteristics *coeffs;
-if (trc >= AVCOL_TRC_NB)
+if ((unsigned)trc >= FF_ARRAY_ELEMS(transfer_characteristics))
return NULL;
coeffs = &transfer_characteristics[trc];
if (!coeffs->alpha)
--
2.49.1
>From 18e2c4a7b07cb50ed003555ee6eb119b9c79465b Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Mon, 22 Sep 2025 15:00:32 +0200
Subject: [PATCH 2/2] avfilter/vf_tonemap_opencl: Make array smaller
Also makes the code more independent of AVCOL_TRC_NB.
Signed-off-by: Andreas Rheinhardt
---
libavfilter/vf_tonemap_opencl.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavfilter/vf_tonemap_opencl.c b/libavfilter/vf_tonemap_opencl.c
index 26fc02923c..2c1b0a007d 100644
--- a/libavfilter/vf_tonemap_opencl.c
+++ b/libavfilter/vf_tonemap_opencl.c
@@ -70,12 +70,12 @@ typedef struct TonemapOpenCLContext {
cl_memutil_mem;
} TonemapOpenCLContext;
-static const char *const linearize_funcs[AVCOL_TRC_NB] = {
+static const char *const linearize_funcs[] = {
[AVCOL_TRC_SMPTE2084] = "eotf_st2084",
[AVCOL_TRC_ARIB_STD_B67] = "inverse_oetf_hlg",
};
-static const char *const delinearize_funcs[AVCOL_TRC_NB] = {
+static const char *const delinearize_funcs[] = {
[AVCOL_TRC_BT709] = "inverse_eotf_bt1886",
[AVCOL_TRC_BT2020_10] = "inverse_eotf_bt1886",
};
--
2.49.1
___
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] avcodec/Makefile: Remove h263 decoder->mpeg4videodec.o dependency (PR #20665)
PR #20665 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20665
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20665.patch
>From 1f02b0baca4e92ed3e432c476b16b9d8e140be88 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Wed, 8 Oct 2025 03:45:20 +0200
Subject: [PATCH 1/2] avcodec/h263dec: Avoid redundant branch
Only the MPEG-4 decoder can have partitioned frames here.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/h263dec.c | 10 +++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 3821472e91..bacd258d53 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -215,12 +215,15 @@ static int decode_slice(H263DecContext *const h)
return ret;
}
+#if CONFIG_MPEG4_DECODER
if (h->partitioned_frame) {
const int qscale = h->c.qscale;
-if (CONFIG_MPEG4_DECODER && h->c.codec_id == AV_CODEC_ID_MPEG4)
-if ((ret = ff_mpeg4_decode_partitions(h)) < 0)
-return ret;
+av_assert1(h->c.codec_id == AV_CODEC_ID_MPEG4);
+
+ret = ff_mpeg4_decode_partitions(h);
+if (ret < 0)
+return ret;
/* restore variables which were modified */
h->c.first_slice_line = 1;
@@ -228,6 +231,7 @@ static int decode_slice(H263DecContext *const h)
h->c.mb_y = h->c.resync_mb_y;
ff_set_qscale(&h->c, qscale);
}
+#endif
for (; h->c.mb_y < h->c.mb_height; h->c.mb_y++) {
/* per-row end of slice checks */
--
2.49.1
>From e9a2898e0b628f029fb83ca8fffd44d5d4e32bf5 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Wed, 8 Oct 2025 04:56:04 +0200
Subject: [PATCH 2/2] avcodec/Makefile: Remove h263 decoder->mpeg4videodec.o
dependency
Also prefer using #if CONFIG_MPEG4_DECODER checks in order not
to rely on DCE.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/Makefile | 5 +++--
libavcodec/h263dec.c| 10 --
libavcodec/ituh263dec.c | 8 ++--
3 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index d55e899c14..791fd5d5a4 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -158,7 +158,7 @@ OBJS-$(CONFIG_MPEGVIDEOENC)+= mpegvideo_enc.o
mpeg12data.o \
motion_est.o ratecontrol.o
OBJS-$(CONFIG_MPEGVIDEOENCDSP) += mpegvideoencdsp.o
OBJS-$(CONFIG_MSMPEG4DEC) += msmpeg4dec.o msmpeg4.o msmpeg4data.o
\
- msmpeg4_vc1_data.o
+ msmpeg4_vc1_data.o mpeg4videodec.o
OBJS-$(CONFIG_MSMPEG4ENC) += msmpeg4enc.o msmpeg4.o msmpeg4data.o
\
msmpeg4_vc1_data.o
OBJS-$(CONFIG_MSS34DSP)+= mss34dsp.o jpegquanttables.o
@@ -576,7 +576,8 @@ OBJS-$(CONFIG_MPEG2_CUVID_DECODER) += cuviddec.o
OBJS-$(CONFIG_MPEG2_MEDIACODEC_DECODER) += mediacodecdec.o
OBJS-$(CONFIG_MPEG2_VAAPI_ENCODER) += vaapi_encode_mpeg2.o
OBJS-$(CONFIG_MPEG2_V4L2M2M_DECODER) += v4l2_m2m_dec.o
-OBJS-$(CONFIG_MPEG4_DECODER) += mpeg4videodsp.o xvididct.o
+OBJS-$(CONFIG_MPEG4_DECODER) += mpeg4videodec.o mpeg4videodsp.o \
+ xvididct.o
OBJS-$(CONFIG_MPEG4_ENCODER) += mpeg4videoenc.o
OBJS-$(CONFIG_MPEG4_CUVID_DECODER) += cuviddec.o
OBJS-$(CONFIG_MPEG4_MEDIACODEC_DECODER) += mediacodecdec.o
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index bacd258d53..697fe7e572 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -201,10 +201,12 @@ static int decode_slice(H263DecContext *const h)
ff_set_qscale(&h->c, h->c.qscale);
+#if CONFIG_MPEG4_DECODER
if (h->c.studio_profile) {
if ((ret = ff_mpeg4_decode_studio_slice_header(h)) < 0)
return ret;
}
+#endif
if (h->c.avctx->hwaccel) {
const uint8_t *start = h->gb.buffer + get_bits_count(&h->gb) / 8;
@@ -500,13 +502,15 @@ int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame
*pict,
avctx->has_b_frames = !h->c.low_delay;
-if (CONFIG_MPEG4_DECODER && avctx->codec_id == AV_CODEC_ID_MPEG4) {
+#if CONFIG_MPEG4_DECODER
+if (avctx->codec_id == AV_CODEC_ID_MPEG4) {
if (h->c.pict_type != AV_PICTURE_TYPE_B && h->c.mb_num/2 >
get_bits_left(&h->gb))
return AVERROR_INVALIDDATA;
ff_mpeg4_workaround_bugs(avctx);
if (h->c.studio_profile != (h->c.idsp.idct == NULL))
ff_mpv_idct_init(s);
}
+#endif
/* After H.263 & MPEG-4 header decode we have the height, width,
* and other parameters. So then we could init the picture. */
@@ -615,8 +619,10 @@ frame_end:
ff_mpv_frame_end(s);
-if (CONFIG_MPEG4_DECODER && avctx->codec_id == AV_CODEC_ID_MPEG4)
+#if CONFIG_MPEG4_DECODER
+if (avctx->codec_id == AV_CODEC_ID_MPEG4)
ff_mpeg4_frame_end
[FFmpeg-devel] [PATCH] avcodec/tiff_common: Remove unused ff_tadd_*_metadata() funcs (PR #20592)
PR #20592 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20592
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20592.patch
Unused since ad77345a5d14862f4701e5ad422b03b14934a5b9.
>From 6bd29f31912942e10c4d03ce180ea34baaaef08f Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Wed, 24 Sep 2025 05:01:04 +0200
Subject: [PATCH] avcodec/tiff_common: Remove unused ff_tadd_*_metadata() funcs
Unused since ad77345a5d14862f4701e5ad422b03b14934a5b9.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/tiff_common.c | 67
libavcodec/tiff_common.h | 18 ---
2 files changed, 85 deletions(-)
diff --git a/libavcodec/tiff_common.c b/libavcodec/tiff_common.c
index ee8061944b..265f843031 100644
--- a/libavcodec/tiff_common.c
+++ b/libavcodec/tiff_common.c
@@ -97,51 +97,6 @@ static int bprint_to_avdict(AVBPrint *bp, const char *name,
return av_dict_set(metadata, name, ap, AV_DICT_DONT_STRDUP_VAL);
}
-int ff_tadd_rational_metadata(int count, const char *name, const char *sep,
- GetByteContext *gb, int le, AVDictionary
**metadata)
-{
-AVBPrint bp;
-int32_t nom, denom;
-int i;
-
-if (count >= INT_MAX / sizeof(int64_t) || count <= 0)
-return AVERROR_INVALIDDATA;
-if (bytestream2_get_bytes_left(gb) < count * sizeof(int64_t))
-return AVERROR_INVALIDDATA;
-
-av_bprint_init(&bp, 10 * count, AV_BPRINT_SIZE_UNLIMITED);
-
-for (i = 0; i < count; i++) {
-nom = ff_tget_long(gb, le);
-denom = ff_tget_long(gb, le);
-av_bprintf(&bp, "%s%7"PRId32":%-7"PRId32, auto_sep(count, sep, i, 4),
nom, denom);
-}
-
-return bprint_to_avdict(&bp, name, metadata);
-}
-
-
-int ff_tadd_long_metadata(int count, const char *name, const char *sep,
- GetByteContext *gb, int le, AVDictionary **metadata)
-{
-AVBPrint bp;
-int i;
-
-if (count >= INT_MAX / sizeof(int32_t) || count <= 0)
-return AVERROR_INVALIDDATA;
-if (bytestream2_get_bytes_left(gb) < count * sizeof(int32_t))
-return AVERROR_INVALIDDATA;
-
-av_bprint_init(&bp, 10 * count, AV_BPRINT_SIZE_UNLIMITED);
-
-for (i = 0; i < count; i++) {
-av_bprintf(&bp, "%s%7i", auto_sep(count, sep, i, 8), ff_tget_long(gb,
le));
-}
-
-return bprint_to_avdict(&bp, name, metadata);
-}
-
-
int ff_tadd_doubles_metadata(int count, const char *name, const char *sep,
GetByteContext *gb, int le, AVDictionary
**metadata)
{
@@ -184,28 +139,6 @@ int ff_tadd_shorts_metadata(int count, const char *name,
const char *sep,
return bprint_to_avdict(&bp, name, metadata);
}
-
-int ff_tadd_bytes_metadata(int count, const char *name, const char *sep,
- GetByteContext *gb, int le, int is_signed,
AVDictionary **metadata)
-{
-AVBPrint bp;
-int i;
-
-if (count >= INT_MAX / sizeof(int8_t) || count < 0)
-return AVERROR_INVALIDDATA;
-if (bytestream2_get_bytes_left(gb) < count * sizeof(int8_t))
-return AVERROR_INVALIDDATA;
-
-av_bprint_init(&bp, 10 * count, AV_BPRINT_SIZE_UNLIMITED);
-
-for (i = 0; i < count; i++) {
-int v = is_signed ? (int8_t)bytestream2_get_byte(gb) :
bytestream2_get_byte(gb);
-av_bprintf(&bp, "%s%3i", auto_sep(count, sep, i, 16), v);
-}
-
-return bprint_to_avdict(&bp, name, metadata);
-}
-
int ff_tadd_string_metadata(int count, const char *name,
GetByteContext *gb, int le, AVDictionary
**metadata)
{
diff --git a/libavcodec/tiff_common.h b/libavcodec/tiff_common.h
index 11f2e739a4..67f23bd4fa 100644
--- a/libavcodec/tiff_common.h
+++ b/libavcodec/tiff_common.h
@@ -62,18 +62,6 @@ double ff_tget_double(GetByteContext *gb, int le);
/** Reads a byte from the bytestream using given endianness. */
unsigned ff_tget(GetByteContext *gb, int type, int le);
-/** Adds count rationals converted to a string
- * into the metadata dictionary.
- */
-int ff_tadd_rational_metadata(int count, const char *name, const char *sep,
- GetByteContext *gb, int le, AVDictionary
**metadata);
-
-/** Adds count longs converted to a string
- * into the metadata dictionary.
- */
-int ff_tadd_long_metadata(int count, const char *name, const char *sep,
- GetByteContext *gb, int le, AVDictionary **metadata);
-
/** Adds count doubles converted to a string
* into the metadata dictionary.
*/
@@ -86,12 +74,6 @@ int ff_tadd_doubles_metadata(int count, const char *name,
const char *sep,
int ff_tadd_shorts_metadata(int count, const char *name, const char *sep,
GetByteContext *gb, int le, int is_signed,
AVDictionary **metadata);
-/** Adds count bytes converted to a string
- * into the metadata dictionary.
- */
-int ff_tadd_bytes_metadata(int count, const char *name, const char *sep,
- GetByteContext *gb, in
[FFmpeg-devel] [PATCH] vf_noise (PR #20699)
PR #20699 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20699
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20699.patch
>From f868a52fd1642daf745e15b4684c9e5631db68a3 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Mon, 13 Oct 2025 06:20:07 +0200
Subject: [PATCH 1/7] avfilter/vf_noise: Make private context smaller
"all" only exists to set options; it does not need the big arrays
contained in FilterParams.
Signed-off-by: Andreas Rheinhardt
---
libavfilter/vf_noise.h | 5 -
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/libavfilter/vf_noise.h b/libavfilter/vf_noise.h
index 92998e54c9..25876baab5 100644
--- a/libavfilter/vf_noise.h
+++ b/libavfilter/vf_noise.h
@@ -50,7 +50,10 @@ typedef struct NoiseContext {
int nb_planes;
int bytewidth[4];
int height[4];
-FilterParams all;
+struct {
+int seed, strength;
+unsigned flags;
+} all;
FilterParams param[4];
void (*line_noise)(uint8_t *dst, const uint8_t *src, const int8_t *noise,
int len, int shift);
void (*line_noise_avg)(uint8_t *dst, const uint8_t *src, int len, const
int8_t * const *shift);
--
2.49.1
>From 8b2900b61fdc4da6bcd6bf7a2d162f97ac63d9fe Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Mon, 13 Oct 2025 09:43:38 +0200
Subject: [PATCH 2/7] avfilter/vf_noise: Don't write beyond end-of-array
This is not only UB, but also leads to races and nondeterministic
output, because the write one last the end of the buffer actually
conflicts with accesses by the thread that actually owns it.
Signed-off-by: Andreas Rheinhardt
---
libavfilter/vf_noise.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavfilter/vf_noise.c b/libavfilter/vf_noise.c
index a6613f663e..69ea528788 100644
--- a/libavfilter/vf_noise.c
+++ b/libavfilter/vf_noise.c
@@ -214,7 +214,7 @@ static void noise(uint8_t *dst, const uint8_t *src,
if (flags & NOISE_AVERAGED) {
n->line_noise_avg(dst + x, src + x, w, (const
int8_t**)p->prev_shift[ix]);
-p->prev_shift[ix][shift & 3] = noise + shift;
+p->prev_shift[ix][shift % 3] = noise + shift;
} else {
n->line_noise(dst + x, src + x, noise, w, shift);
}
--
2.49.1
>From 2f4fc55e77034ace360961ad86f0e1030f039a17 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Mon, 13 Oct 2025 10:26:06 +0200
Subject: [PATCH 3/7] avfilter/vf_noise: Fix race with very tall images
When using averaged noise with height > MAX_RES (i.e. 4096),
multiple threads would access the same prev_shift slot,
leading to races. Fix this by disabling slice threading
in such scenarios.
Signed-off-by: Andreas Rheinhardt
---
libavfilter/vf_noise.c | 5 -
libavfilter/vf_noise.h | 1 +
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/libavfilter/vf_noise.c b/libavfilter/vf_noise.c
index 69ea528788..5b88b76e05 100644
--- a/libavfilter/vf_noise.c
+++ b/libavfilter/vf_noise.c
@@ -271,12 +271,15 @@ static int filter_frame(AVFilterLink *inlink, AVFrame
*inpicref)
fp->rand_shift[i] = av_lfg_get(&fp->lfg) & (MAX_SHIFT - 1);
}
fp->rand_shift_init = 1;
+if (fp->flags & NOISE_AVERAGED && outlink->h > MAX_RES)
+n->slice_threading_impossible = 1;
}
}
td.in = inpicref; td.out = out;
ff_filter_execute(ctx, filter_slice, &td, NULL,
- FFMIN(n->height[0], ff_filter_get_nb_threads(ctx)));
+ n->slice_threading_impossible ? 1 :
+ FFMIN(n->height[0], ff_filter_get_nb_threads(ctx)));
emms_c();
if (inpicref != out)
diff --git a/libavfilter/vf_noise.h b/libavfilter/vf_noise.h
index 25876baab5..62d7bee02c 100644
--- a/libavfilter/vf_noise.h
+++ b/libavfilter/vf_noise.h
@@ -50,6 +50,7 @@ typedef struct NoiseContext {
int nb_planes;
int bytewidth[4];
int height[4];
+int slice_threading_impossible;
struct {
int seed, strength;
unsigned flags;
--
2.49.1
>From d9828d1ded3ca490ad9a183938b04904ffda9c95 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Mon, 13 Oct 2025 12:20:32 +0200
Subject: [PATCH 4/7] avfilter/vf_noise: Avoid cast
Signed-off-by: Andreas Rheinhardt
---
libavfilter/vf_noise.c | 2 +-
libavfilter/vf_noise.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavfilter/vf_noise.c b/libavfilter/vf_noise.c
index 5b88b76e05..43e7ad6c45 100644
--- a/libavfilter/vf_noise.c
+++ b/libavfilter/vf_noise.c
@@ -213,7 +213,7 @@ static void noise(uint8_t *dst, const uint8_t *src,
int shift = p->rand_shift[ix];
if (flags & NOISE_AVERAGED) {
-n->line_noise_avg(dst + x, src + x, w, (const
int8_t**)p->prev_shift[ix]);
+n->line_noise_avg(dst + x, src + x, w, p->prev_shift[ix]);
p->prev_shift[ix][shift % 3] = noise + shi
[FFmpeg-devel] [PATCH] avcodec/x86/hpeldsp_init: Remove check for inline mmx (PR #20691)
PR #20691 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20691
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20691.patch
Forgotten in 4c55724da86ddc5ef10966f287a3d50fe1a1cbbe.
>From f9cec45319be66e29c723c4a1dd0afd2a6d81145 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Sun, 12 Oct 2025 05:14:24 +0200
Subject: [PATCH] avcodec/x86/hpeldsp_init: Remove check for inline mmx
Forgotten in 4c55724da86ddc5ef10966f287a3d50fe1a1cbbe.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/x86/hpeldsp_init.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavcodec/x86/hpeldsp_init.c b/libavcodec/x86/hpeldsp_init.c
index f4b123ce03..1640ff83b6 100644
--- a/libavcodec/x86/hpeldsp_init.c
+++ b/libavcodec/x86/hpeldsp_init.c
@@ -143,7 +143,7 @@ av_cold void ff_hpeldsp_init_x86(HpelDSPContext *c, int
flags)
{
int cpu_flags = av_get_cpu_flags();
-if (INLINE_MMX(cpu_flags))
+if (EXTERNAL_MMX(cpu_flags))
hpeldsp_init_mmx(c, flags);
if (EXTERNAL_MMXEXT(cpu_flags))
--
2.49.1
___
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] avcodec/x86/h264_qpel: Don't instantiate unused functions (PR #20687)
PR #20687 opened by mkver URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20687 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20687.patch The v_lowpass wrappers (which are instantiated by this macro) are only used in the put (and not the avg) form for SSSE3 (the avg form is only used for mc02, which doesn't exist for SSSE3). Clang warns about the unused functions. >From d96f8d32adfd4ea08c276cd2b6f10e7a3caf06fc Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Fri, 10 Oct 2025 16:21:25 +0200 Subject: [PATCH] avcodec/x86/h264_qpel: Don't instantiate unused functions The v_lowpass wrappers (which are instantiated by this macro) are only used in the put (and not the avg) form for SSSE3 (the avg form is only used for mc02, which doesn't exist for SSSE3). Clang warns about the unused functions. Signed-off-by: Andreas Rheinhardt --- libavcodec/x86/h264_qpel.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavcodec/x86/h264_qpel.c b/libavcodec/x86/h264_qpel.c index c8f6726508..5d1445a8bb 100644 --- a/libavcodec/x86/h264_qpel.c +++ b/libavcodec/x86/h264_qpel.c @@ -293,7 +293,6 @@ QPEL_H264_HV_XMM(avg_, sse2) QPEL_H264_H_XMM(put_, ssse3) QPEL_H264_H_XMM(avg_, ssse3) QPEL_H264_V_XMM(put_, ssse3, sse2) -QPEL_H264_V_XMM(avg_, ssse3, sse2) QPEL_H264_HV_XMM(put_, ssse3) QPEL_H264_HV_XMM(avg_, ssse3) -- 2.49.1 ___ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] ohdec error handling (PR #20587)
PR #20587 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20587
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20587.patch
While looking at ohdec.c for other stuff, I noticed that the error handling
seems suspicious in several error paths:
1. When the dec_ref buffer can't be created, oh_decode_release() would never be
called. (Fixed in the first patch.)
2. oh_decode_close() always calls OH_VideoDecoder_Stop() if s->dec is set, but
what happens if an error happens in between its creation and
OH_VideoDecoder_Start()? Is it really safe to call?
3. What actually happens if the OH_VideoDecoder_Start() call in
oh_decode_flush() fails?
4. If oh_decode_output_frame() fails, what happens with output->buffer? It
seems to leak.
5. It also does not check mutex/condition variables initialization.
This patchset is entirely untested; I don't even know whether it compiles.
>From 556ce80ff21c0a459d163721e066990583af6e31 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Tue, 23 Sep 2025 15:03:40 +0200
Subject: [PATCH 1/3] avcodec/ohdec: Release decoder on allocation failure
Normally, the OH_AVCodec is wrapped inside an AVBuffer
to be freed in its free callback; yet when creating
the AVBuffer fails, the decoder is never destroyed.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/ohdec.c | 5 -
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/libavcodec/ohdec.c b/libavcodec/ohdec.c
index cf1177afcd..08b03a7e7b 100644
--- a/libavcodec/ohdec.c
+++ b/libavcodec/ohdec.c
@@ -124,8 +124,11 @@ static int oh_decode_create(OHCodecDecContext *s,
AVCodecContext *avctx)
s->dec_ref = av_buffer_create((uint8_t *)s->dec, 0, oh_decode_release,
NULL, 0);
-if (!s->dec_ref)
+if (!s->dec_ref) {
+oh_decode_release(NULL, (uint8_t*)s->dec);
+s->dec = NULL;
return AVERROR(ENOMEM);
+}
return 0;
}
--
2.49.1
>From bd3f5c4e7f0afbb81c68f3d79423e0d41c8581d2 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Tue, 23 Sep 2025 15:52:09 +0200
Subject: [PATCH 2/3] avcodec/ohdec: Switch to RefStruct API for internal
refcounting
It avoids allocations and corresponding error conditions.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/ohdec.c | 36 ++--
1 file changed, 14 insertions(+), 22 deletions(-)
diff --git a/libavcodec/ohdec.c b/libavcodec/ohdec.c
index 08b03a7e7b..86f3c84279 100644
--- a/libavcodec/ohdec.c
+++ b/libavcodec/ohdec.c
@@ -29,6 +29,7 @@
#include "libavutil/imgutils.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
+#include "libavutil/refstruct.h"
#include "libavutil/thread.h"
#include "avcodec.h"
@@ -40,11 +41,11 @@
typedef struct OHCodecDecContext {
AVClass *avclass;
OH_AVCodec *dec;
-/* A reference count to dec. Each hardware frame has a reference count to
+/* A RefStruct reference backing dec. Each hardware frame has a reference
count to
* dec. dec will be destroyed only after oh_decode_close and all hardware
* frames have been released.
*/
-AVBufferRef *dec_ref;
+OH_AVCodec **dec_ref;
AVMutex input_mutex;
AVCond input_cond;
@@ -74,13 +75,13 @@ typedef struct OHCodecDecContext {
typedef struct OHCodecBuffer {
uint32_t index;
OH_AVBuffer *buffer;
-AVBufferRef *dec_ref;
+OH_AVCodec **dec_ref; ///< RefStruct reference
} OHCodecBuffer;
-static void oh_decode_release(void *opaque, uint8_t *data)
+static void oh_decode_release(AVRefStructOpaque unused, void *obj)
{
-OH_AVCodec *dec = (OH_AVCodec *)data;
-OH_AVErrCode err = OH_VideoDecoder_Destroy(dec);
+OH_AVCodec **decp = obj;
+OH_AVErrCode err = OH_VideoDecoder_Destroy(*decp);
if (err == AV_ERR_OK)
av_log(NULL, AV_LOG_DEBUG, "Destroy decoder success\n");
else
@@ -122,13 +123,13 @@ static int oh_decode_create(OHCodecDecContext *s,
AVCodecContext *avctx)
}
av_log(avctx, AV_LOG_DEBUG, "Create decoder %s success\n", name);
-s->dec_ref = av_buffer_create((uint8_t *)s->dec, 0, oh_decode_release,
- NULL, 0);
+s->dec_ref = av_refstruct_alloc_ext(sizeof(*s->dec_ref), 0, NULL,
oh_decode_release);
if (!s->dec_ref) {
-oh_decode_release(NULL, (uint8_t*)s->dec);
+oh_decode_release((AVRefStructOpaque){.nc = NULL }, &s->dec);
s->dec = NULL;
return AVERROR(ENOMEM);
}
+*s->dec_ref = s->dec;
return 0;
}
@@ -408,7 +409,7 @@ static av_cold int oh_decode_close(AVCodecContext *avctx)
av_log(avctx, AV_LOG_ERROR, "Stop decoder failed, %d, %s\n",
err, av_err2str(ff_oh_err_to_ff_err(err)));
s->dec = NULL;
-av_buffer_unref(&s->dec_ref);
+av_refstruct_unref(&s->dec_ref);
}
av_packet_unref(&s->pkt);
@@ -431,13 +432,8 @@ static void oh_buffer_release(void *opaque, uint8_t *data)
OHCodecBuffer *buffer = opaque;
-
[FFmpeg-devel] [PATCH] lavc/x86: Deduplicate constants (PR #20590)
PR #20590 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20590
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20590.patch
>From 5328f198c2c21d9f2fc7bc0c2a560143134c3dca Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Wed, 24 Sep 2025 00:45:24 +0200
Subject: [PATCH 1/7] avcodec/x86/vorbisdsp: Reuse constant
Signed-off-by: Andreas Rheinhardt
---
libavcodec/x86/vorbisdsp.asm | 6 ++
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/libavcodec/x86/vorbisdsp.asm b/libavcodec/x86/vorbisdsp.asm
index 9afe2eb352..5fa8b5f866 100644
--- a/libavcodec/x86/vorbisdsp.asm
+++ b/libavcodec/x86/vorbisdsp.asm
@@ -21,15 +21,13 @@
%include "libavutil/x86/x86util.asm"
-SECTION_RODATA
-
-pdw_8000: times 4 dd 0x8000
+cextern ps_neg
SECTION .text
INIT_XMM sse
cglobal vorbis_inverse_coupling, 3, 3, 6, mag, ang, block_size
-mova m5, [pdw_8000]
+mova m5, [ps_neg]
shl block_sized, 2
addmagq, block_sizeq
addangq, block_sizeq
--
2.49.1
>From fda587ca778a525deffb42df639029f578b17886 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Wed, 24 Sep 2025 01:42:19 +0200
Subject: [PATCH 2/7] avcodec/x86/cfhd{,enc}dsp: Deduplicate constants
Signed-off-by: Andreas Rheinhardt
---
libavcodec/x86/cfhddsp.asm| 47 ++-
libavcodec/x86/cfhdencdsp.asm | 12 -
libavcodec/x86/constants.c| 3 +++
libavcodec/x86/constants.h| 3 +++
4 files changed, 36 insertions(+), 29 deletions(-)
diff --git a/libavcodec/x86/cfhddsp.asm b/libavcodec/x86/cfhddsp.asm
index 87c2df634a..aa27902f9b 100644
--- a/libavcodec/x86/cfhddsp.asm
+++ b/libavcodec/x86/cfhddsp.asm
@@ -23,15 +23,16 @@
SECTION_RODATA
-factor_p1_n1: dw 1, -1, 1, -1, 1, -1, 1, -1,
-factor_n1_p1: dw -1, 1, -1, 1, -1, 1, -1, 1,
+cextern pw_p1_m1
+cextern pw_m1_p1
factor_p11_n4: dw 11, -4, 11, -4, 11, -4, 11, -4,
factor_p5_p4: dw 5, 4, 5, 4, 5, 4, 5, 4,
-pd_4: times 4 dd 4
-pw_1: times 8 dw 1
-pw_0: times 8 dw 0
-pw_1023: times 8 dw 1023
-pw_4095: times 8 dw 4095
+cextern pd_4
+cextern pw_1
+cextern pb_0
+%define pw_0 pb_0
+cextern pw_1023
+cextern pw_4095
SECTION .text
@@ -79,8 +80,8 @@ cglobal cfhd_horiz_filter, 7, 7, 8, output, x, low, y, high,
temp, width, height
%endif
%if ARCH_X86_64
-mova m8, [factor_p1_n1]
-mova m9, [factor_n1_p1]
+mova m8, [pw_p1_m1]
+mova m9, [pw_m1_p1]
mova m10, [pw_1]
mova m11, [pd_4]
%endif
@@ -158,10 +159,10 @@ cglobal cfhd_horiz_filter, 7, 7, 8, output, x, low, y,
high, temp, width, height
paddd m6, m11
paddd m7, m11
%else
-pmaddwdm4, [factor_p1_n1]
-pmaddwdm5, [factor_p1_n1]
-pmaddwdm6, [factor_n1_p1]
-pmaddwdm7, [factor_n1_p1]
+pmaddwdm4, [pw_p1_m1]
+pmaddwdm5, [pw_p1_m1]
+pmaddwdm6, [pw_m1_p1]
+pmaddwdm7, [pw_m1_p1]
paddd m4, [pd_4]
paddd m5, [pd_4]
@@ -192,8 +193,8 @@ cglobal cfhd_horiz_filter, 7, 7, 8, output, x, low, y,
high, temp, width, height
%else
pmaddwdm2, [pw_1]
pmaddwdm0, [pw_1]
-pmaddwdm1, [factor_p1_n1]
-pmaddwdm3, [factor_p1_n1]
+pmaddwdm1, [pw_p1_m1]
+pmaddwdm3, [pw_p1_m1]
%endif
paddd m2, m4
@@ -312,8 +313,8 @@ cglobal cfhd_vert_filter, 8, 11, 14, output, ostride, low,
lwidth, high, hwidth,
dec heightd
-mova m8, [factor_p1_n1]
-mova m9, [factor_n1_p1]
+mova m8, [pw_p1_m1]
+mova m9, [pw_m1_p1]
mova m10, [pw_1]
mova m11, [pd_4]
mova m12, [factor_p11_n4]
@@ -485,10 +486,10 @@ cglobal cfhd_vert_filter, 7, 7, 8, output, x, low, y,
high, pos, width, height
paddd m6, m11
paddd m7, m11
%else
-pmaddwdm4, [factor_p1_n1]
-pmaddwdm5, [factor_p1_n1]
-pmaddwdm6, [factor_n1_p1]
-pmaddwdm7, [factor_n1_p1]
+pmaddwdm4, [pw_p1_m1]
+pmaddwdm5, [pw_p1_m1]
+pmaddwdm6, [pw_m1_p1]
+pmaddwdm7, [pw_m1_p1]
paddd m4, [pd_4]
paddd m5, [pd_4]
@@ -524,8 +525,8 @@ cglobal cfhd_vert_filter, 7, 7, 8, output, x, low, y, high,
pos, width, height
%else
pmaddwdm0, [pw_1]
pmaddwdm2, [pw_1]
-pmaddwdm1, [factor_p1_n1]
-pmaddwdm3, [factor_p1_n1]
+pmaddwdm1, [pw_p1_m1]
+pmaddwdm3, [pw_p1_m1]
%endif
paddd m0, m4
diff --git a/libavcodec/x86/cfhdencdsp.asm b/libavcodec/x86/cfhdencdsp.asm
index 4aaeb56972..7654f59643 100644
--- a/libavcodec/x86/cfhdencdsp.asm
+++ b/libavcodec/x86/cfhdencdsp.asm
@@ -23,13 +23,13 @@
SECTION_RODATA
-pw_p1_n1: dw 1, -1, 1, -1, 1, -1, 1, -1
-pw_n1_p1: dw -1, 1, -1, 1, -1, 1, -1, 1
+cextern pw_p1_m1
+cextern pw_m1_p1
pw_p5_n11: dw 5, -11, 5,
[FFmpeg-devel] [PATCH] avcodec/x86/apv_dsp: Don't export arrays unnecessarily (PR #20588)
PR #20588 opened by mkver URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20588 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20588.patch The const here is unnecessary, because everything inside SECTION_RODATA is automatically const and using it exports these objects from the object file because const is a macro in x86inc.asm. >From 4d79b5a9f4ec821161f4f5e0a0f8090d6e33820a Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 24 Sep 2025 00:10:08 +0200 Subject: [PATCH] avcodec/x86/apv_dsp: Don't export arrays unnecessarily The const here is unnecessary, because everything inside SECTION_RODATA is automatically const and using it exports these objects from the object file because const is a macro in x86inc.asm. Signed-off-by: Andreas Rheinhardt --- libavcodec/x86/apv_dsp.asm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/x86/apv_dsp.asm b/libavcodec/x86/apv_dsp.asm index 60e0f03e16..e2f30fff13 100644 --- a/libavcodec/x86/apv_dsp.asm +++ b/libavcodec/x86/apv_dsp.asm @@ -23,7 +23,7 @@ SECTION_RODATA 32 ; Full matrix for row transform. -const tmatrix_row +tmatrix_row: dw 64, 89, 84, 75, 64, 50, 35, 18 dw 64, -18, -84, 50, 64, -75, -35, 89 dw 64, 75, 35, -18, -64, -89, -84, -50 @@ -34,10 +34,10 @@ const tmatrix_row dw 64, -89, 84, -75, 64, -50, 35, -18 ; Constant pairs for broadcast in column transform. -const tmatrix_col_even +tmatrix_col_even: dw 64, 64, 64, -64 dw 84, 35, 35, -84 -const tmatrix_col_odd +tmatrix_col_odd: dw 89, 75, 50, 18 dw 75, -18, -89, -50 dw 50, -89, 18, 75 -- 2.49.1 ___ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] avcodec/bsf/ahx_to_mp2: Don't output uninitialized data (PR #20591)
PR #20591 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20591
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20591.patch
>From 0cdb58004bee28b183894a0cb91f12d247e5a835 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Wed, 24 Sep 2025 04:34:47 +0200
Subject: [PATCH] avcodec/bsf/ahx_to_mp2: Don't output uninitialized data
Signed-off-by: Andreas Rheinhardt
---
libavcodec/bsf/ahx_to_mp2.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/libavcodec/bsf/ahx_to_mp2.c b/libavcodec/bsf/ahx_to_mp2.c
index eae71fe5ee..8e30c5b1db 100644
--- a/libavcodec/bsf/ahx_to_mp2.c
+++ b/libavcodec/bsf/ahx_to_mp2.c
@@ -44,11 +44,13 @@ static int filter(AVBSFContext *ctx, AVPacket *pkt)
return ret;
if (pkt->size < 1044) {
+int original_size = pkt->size;
ret = av_grow_packet(pkt, 1044-pkt->size);
if (ret < 0) {
av_packet_unref(pkt);
return ret;
}
+memset(pkt->data + original_size, 0, 1044 - original_size);
}
return 0;
--
2.49.1
___
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] swscale/ppc/swscale_ppc_template: Fix av_unused placement (PR #20618)
PR #20618 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20618
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20618.patch
Forgotten in d6cb0d2c2bb8469f17d59dd82c8221b98e169d1a.
>From af8474d800cd3a55fbcd763766102f2c8d5042c2 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Fri, 26 Sep 2025 22:16:40 +0200
Subject: [PATCH] swscale/ppc/swscale_ppc_template: Fix av_unused placement
Forgotten in d6cb0d2c2bb8469f17d59dd82c8221b98e169d1a.
Signed-off-by: Andreas Rheinhardt
---
libswscale/ppc/swscale_ppc_template.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libswscale/ppc/swscale_ppc_template.c
b/libswscale/ppc/swscale_ppc_template.c
index 7e502d5069..1e0c095285 100644
--- a/libswscale/ppc/swscale_ppc_template.c
+++ b/libswscale/ppc/swscale_ppc_template.c
@@ -125,8 +125,8 @@ static void FUNC(hScale_real)(SwsInternal *c, int16_t *dst,
int dstW,
case 8:
for (register int i = 0; i < dstW; i++) {
register int srcPos = filterPos[i];
-vector unsigned char src_vF, av_unused src_v0, av_unused src_v1;
-vector unsigned char av_unused permS;
+vector unsigned char src_vF;
+av_unused vector unsigned char src_v0, src_v1, permS;
vector signed short src_v, filter_v;
vector signed int val_v, val_s;
FIRST_LOAD(src_v0, srcPos, src, permS);
--
2.49.1
___
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] Various libmpeghdec patches (PR #20602)
PR #20602 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20602
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20602.patch
There is another issue not fixed in this PR: The decoder treats
avctx->sample_rate as time base of avpkt->pts, although it is
AVCodecContext.pkt_timebase. That is probably the reason for the sample_rate
check.
>From a4b870ecb2c422faa8bb9fb5876b3a83f5ec4918 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Wed, 24 Sep 2025 12:07:28 +0200
Subject: [PATCH 1/8] avcodec/libmpeghdec: Remove redundant manual close calls
This decoder has the INIT_CLEANUP flag set.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/libmpeghdec.c | 6 +-
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/libavcodec/libmpeghdec.c b/libavcodec/libmpeghdec.c
index e293ec3396..ae85924625 100644
--- a/libavcodec/libmpeghdec.c
+++ b/libavcodec/libmpeghdec.c
@@ -171,16 +171,13 @@ static av_cold int mpegh3dadec_init(AVCodecContext *avctx)
s->decoder_buffer_size = MAX_OUTBUF_SIZE;
s->decoder_buffer = av_malloc(s->decoder_buffer_size);
-if (!s->decoder_buffer) {
-mpegh3dadec_close(avctx);
+if (!s->decoder_buffer)
return AVERROR(ENOMEM);
-}
// initialize the decoder
s->decoder = mpeghdecoder_init(cicp);
if (s->decoder == NULL) {
av_log(avctx, AV_LOG_ERROR, "MPEG-H decoder library init failed.\n");
-mpegh3dadec_close(avctx);
return AVERROR_EXTERNAL;
}
@@ -188,7 +185,6 @@ static av_cold int mpegh3dadec_init(AVCodecContext *avctx)
if (mpeghdecoder_setMhaConfig(s->decoder, avctx->extradata,
avctx->extradata_size)) {
av_log(avctx, AV_LOG_ERROR, "Unable to set MHA configuration\n");
-mpegh3dadec_close(avctx);
return AVERROR_INVALIDDATA;
}
}
--
2.49.1
>From b7ef96c52a8534cd2c00ab4d560cf0aca39bc1d7 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Wed, 24 Sep 2025 12:09:39 +0200
Subject: [PATCH 2/8] avcodec/libmpeghdec: Remove private class
This decoder doesn't have any options.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/libmpeghdec.c | 10 --
1 file changed, 10 deletions(-)
diff --git a/libavcodec/libmpeghdec.c b/libavcodec/libmpeghdec.c
index ae85924625..2d6798e49e 100644
--- a/libavcodec/libmpeghdec.c
+++ b/libavcodec/libmpeghdec.c
@@ -35,7 +35,6 @@
#include "libavutil/channel_layout.h"
#include "libavutil/frame.h"
#include "libavutil/mem.h"
-#include "libavutil/opt.h"
#include "codec_internal.h"
#include "decode.h"
@@ -45,7 +44,6 @@
#define MAX_OUTBUF_SIZE (sizeof(int32_t) * 24 * 3072 * (MAX_LOST_FRAMES + 1))
typedef struct MPEGH3DADecContext {
-AVClass *av_class;
// pointer to the decoder
HANDLE_MPEGH_DECODER_CONTEXT decoder;
@@ -54,13 +52,6 @@ typedef struct MPEGH3DADecContext {
int decoder_buffer_size;
} MPEGH3DADecContext;
-// private class definition for ffmpeg
-static const AVClass mpegh3da_class = {
-.class_name = "MPEG-H 3D Audio Decoder",
-.item_name = av_default_item_name,
-.version = LIBAVUTIL_VERSION_INT,
-};
-
static av_cold int mpegh3dadec_close(AVCodecContext *avctx)
{
MPEGH3DADecContext *s = avctx->priv_data;
@@ -268,7 +259,6 @@ static av_cold void mpegh3dadec_flush(AVCodecContext *avctx)
const FFCodec ff_libmpeghdec_decoder = {
.p.name = "libmpeghdec",
CODEC_LONG_NAME("libmpeghdec (MPEG-H 3D Audio)"),
-.p.priv_class = &mpegh3da_class,
.p.type = AVMEDIA_TYPE_AUDIO,
.p.id = AV_CODEC_ID_MPEGH_3D_AUDIO,
.p.capabilities =
--
2.49.1
>From 63a1d668db8922a12b8093115512348836e139d5 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Wed, 24 Sep 2025 12:10:32 +0200
Subject: [PATCH 3/8] avcodec/libmpeghdec: Don't set AVCodec.sample_fmts
It is mostly pointless for decoders (only useful for those
codecs for which a floating-point and a fixed-point decoder
exists).
Signed-off-by: Andreas Rheinhardt
---
libavcodec/libmpeghdec.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/libavcodec/libmpeghdec.c b/libavcodec/libmpeghdec.c
index 2d6798e49e..e3cb219838 100644
--- a/libavcodec/libmpeghdec.c
+++ b/libavcodec/libmpeghdec.c
@@ -268,7 +268,6 @@ const FFCodec ff_libmpeghdec_decoder = {
FF_CODEC_DECODE_CB(mpegh3dadec_decode_frame),
.close = mpegh3dadec_close,
.flush = mpegh3dadec_flush,
-CODEC_SAMPLEFMTS(AV_SAMPLE_FMT_S32),
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
.p.wrapper_name = "libmpeghdec",
};
--
2.49.1
>From 2a6618920c40420b0604fe41546ff88fab4e2473 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Wed, 24 Sep 2025 12:13:16 +0200
Subject: [PATCH 4/8] avcodec/libmpeghdec: Inline constant
Signed-off-by: Andreas Rheinhardt
---
libavcodec/libmpeghdec.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavcodec/libmpeghdec.c b/libavcodec/libmpeghdec.c
index e3cb219838..5233b36bc3 100644
--- a/libav
[FFmpeg-devel] [PATCH] avcodec/mpegaudiodec_template: Don't modify AVCodecContext.priv_data (PR #20431)
PR #20431 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20431
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20431.patch
>From fcfe42e86c7c3027b80f60dd0a43a99ebedbdccb Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Thu, 4 Sep 2025 12:00:24 +0200
Subject: [PATCH 1/4] avcodec/mpegaudiodec_template: Don't modify
AVCodecContext.priv_data
Signed-off-by: Andreas Rheinhardt
---
libavcodec/mpegaudiodec_template.c | 16 +++-
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/libavcodec/mpegaudiodec_template.c
b/libavcodec/mpegaudiodec_template.c
index d7c5210eb8..5c38f4e9d7 100644
--- a/libavcodec/mpegaudiodec_template.c
+++ b/libavcodec/mpegaudiodec_template.c
@@ -280,10 +280,9 @@ static av_cold void decode_init_static(void)
ff_mpegaudiodec_common_init_static();
}
-static av_cold int decode_init(AVCodecContext * avctx)
+static av_cold int decode_ctx_init(AVCodecContext *avctx, MPADecodeContext *s)
{
static AVOnce init_static_once = AV_ONCE_INIT;
-MPADecodeContext *s = avctx->priv_data;
s->avctx = avctx;
@@ -315,6 +314,11 @@ static av_cold int decode_init(AVCodecContext * avctx)
return 0;
}
+static av_cold int decode_init(AVCodecContext *avctx)
+{
+return decode_ctx_init(avctx, avctx->priv_data);
+}
+
#define C3 FIXHR(0.86602540378443864676/2)
#define C4 FIXHR(0.70710678118654752439/2) //0.5 / cos(pi*(9)/36)
#define C5 FIXHR(0.51763809020504152469/2) //0.5 / cos(pi*(5)/36)
@@ -1771,19 +1775,13 @@ static av_cold int decode_init_mp3on4(AVCodecContext *
avctx)
s->syncword = 0xfff0;
/* Init the first mp3 decoder in standard way, so that all tables get built
- * We replace avctx->priv_data with the context of the first decoder so
that
- * decode_init() does not have to be changed.
* Other decoders will be initialized here copying data from the first
context
*/
// Allocate zeroed memory for the first decoder context
s->mp3decctx[0] = av_mallocz(sizeof(MPADecodeContext));
if (!s->mp3decctx[0])
return AVERROR(ENOMEM);
-// Put decoder context in place to make init_decode() happy
-avctx->priv_data = s->mp3decctx[0];
-ret = decode_init(avctx);
-// Restore mp3on4 context pointer
-avctx->priv_data = s;
+ret = decode_ctx_init(avctx, s->mp3decctx[0]);
if (ret < 0)
return ret;
s->mp3decctx[0]->adu_mode = 1; // Set adu mode
--
2.49.1
>From fb818736d4a9ef8eafd85c97c0f2ff2c31ff6703 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Thu, 4 Sep 2025 12:07:06 +0200
Subject: [PATCH 2/4] avcodec/mpegaudiodec_template: Allocate sub-contexts
jointly
Signed-off-by: Andreas Rheinhardt
---
libavcodec/mpegaudiodec_template.c | 12
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/libavcodec/mpegaudiodec_template.c
b/libavcodec/mpegaudiodec_template.c
index 5c38f4e9d7..42e995643b 100644
--- a/libavcodec/mpegaudiodec_template.c
+++ b/libavcodec/mpegaudiodec_template.c
@@ -1738,10 +1738,8 @@ static const int16_t chan_layout[8] = {
static av_cold int decode_close_mp3on4(AVCodecContext * avctx)
{
MP3On4DecodeContext *s = avctx->priv_data;
-int i;
-for (i = 0; i < s->frames; i++)
-av_freep(&s->mp3decctx[i]);
+av_freep(&s->mp3decctx[0]);
return 0;
}
@@ -1777,8 +1775,8 @@ static av_cold int decode_init_mp3on4(AVCodecContext *
avctx)
/* Init the first mp3 decoder in standard way, so that all tables get built
* Other decoders will be initialized here copying data from the first
context
*/
-// Allocate zeroed memory for the first decoder context
-s->mp3decctx[0] = av_mallocz(sizeof(MPADecodeContext));
+// Allocate zeroed memory for the decoder contexts
+s->mp3decctx[0] = av_calloc(s->frames, sizeof(*s->mp3decctx[0]));
if (!s->mp3decctx[0])
return AVERROR(ENOMEM);
ret = decode_ctx_init(avctx, s->mp3decctx[0]);
@@ -1790,9 +1788,7 @@ static av_cold int decode_init_mp3on4(AVCodecContext *
avctx)
* Each frame is 1 or 2 channels - up to 5 frames allowed
*/
for (i = 1; i < s->frames; i++) {
-s->mp3decctx[i] = av_mallocz(sizeof(MPADecodeContext));
-if (!s->mp3decctx[i])
-return AVERROR(ENOMEM);
+s->mp3decctx[i] = s->mp3decctx[0] + i;
s->mp3decctx[i]->adu_mode = 1;
s->mp3decctx[i]->avctx = avctx;
s->mp3decctx[i]->mpadsp = s->mp3decctx[0]->mpadsp;
--
2.49.1
>From 3e1a4eb308100f30b7b141ec5390f1ff7121ef77 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Thu, 4 Sep 2025 12:25:48 +0200
Subject: [PATCH 3/4] avcodec/mpegaudiodec_template: Mark flush functions as
av_cold
Signed-off-by: Andreas Rheinhardt
---
libavcodec/mpegaudiodec_template.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libavcodec/mpegaudiodec_template.c
b/libavcodec/mpegaudiodec_template.c
index 42e995643b..3ca9adb8ab 100644
--- a/libavco
[FFmpeg-devel] [PATCH] avfilter/Makefile: Add dependencies for premultiply_dynamic filter (PR #20441)
PR #20441 opened by mkver URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20441 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20441.patch >From fff53d51fb7f4ce5519fae5253d14cc882721e91 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Thu, 4 Sep 2025 21:39:23 +0200 Subject: [PATCH] avfilter/Makefile: Add dependencies for premultiply_dynamic filter Signed-off-by: Andreas Rheinhardt --- libavfilter/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 07fb4c3d6c..bd3f6da27d 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -437,6 +437,7 @@ OBJS-$(CONFIG_PIXDESCTEST_FILTER)+= vf_pixdesctest.o OBJS-$(CONFIG_PIXELIZE_FILTER) += vf_pixelize.o OBJS-$(CONFIG_PIXSCOPE_FILTER) += vf_datascope.o OBJS-$(CONFIG_PP7_FILTER)+= vf_pp7.o qp_table.o +OBJS-$(CONFIG_PREMULTIPLY_DYNAMIC_FILTER)+= vf_premultiply.o framesync.o OBJS-$(CONFIG_PREMULTIPLY_FILTER)+= vf_premultiply.o framesync.o OBJS-$(CONFIG_PREWITT_FILTER)+= vf_convolution.o OBJS-$(CONFIG_PREWITT_OPENCL_FILTER) += vf_convolution_opencl.o opencl.o \ -- 2.49.1 ___ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] avformat/mov: Remove unused variable (PR #20434)
PR #20434 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20434
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20434.patch
>From 550d5ebed171cf478e97c26add8512e899a87fa0 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Thu, 4 Sep 2025 14:28:42 +0200
Subject: [PATCH] avformat/mov: Remove unused variable
Signed-off-by: Andreas Rheinhardt
---
libavformat/mov.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 81753d04e9..216c6a5442 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -10318,7 +10318,6 @@ static int mov_parse_exif_item(AVFormatContext *s,
MOVContext *c = s->priv_data;
AVPacketSideData *sd;
AVExifMetadata ifd = { 0 };
-AVExifEntry *entry = NULL;
AVBufferRef *buf;
int64_t offset = 0, pos = avio_tell(s->pb);
unsigned orientation_id = av_exif_get_tag_id("Orientation");
--
2.49.1
___
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] avcodec/cbrt_tablegen: Avoid static array used only once (PR #20404)
PR #20404 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20404
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20404.patch
Also fix building with hardcoded tables, which has been broken by #20344.
From a3e22d2c394202cef52bee077d22132796cba95c Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Wed, 3 Sep 2025 01:48:55 +0200
Subject: [PATCH 1/5] avcodec/pcm_tablegen: Fix CONFIG_HARDCODED_TABLES
Broken in ae448e00afb43d7f72dfa9c82a4c45994e4fea6a.
Notice that config_components.h is safe to include,
as it is valid for both the host and the target
(in contrast to config.h).
Signed-off-by: Andreas Rheinhardt
---
libavcodec/pcm_tablegen.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/libavcodec/pcm_tablegen.h b/libavcodec/pcm_tablegen.h
index 590ba59814..60ef9656d5 100644
--- a/libavcodec/pcm_tablegen.h
+++ b/libavcodec/pcm_tablegen.h
@@ -24,6 +24,7 @@
#define AVCODEC_PCM_TABLEGEN_H
#include
+#include "config_components.h"
#include "libavutil/attributes.h"
/* from g711.c by SUN microsystems (unrestricted use) */
--
2.49.1
From 74f7c26beba8889d6427ffe83e3afc84803bc71d Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Tue, 2 Sep 2025 17:19:04 +0200
Subject: [PATCH 2/5] avcodec/cbrt_tablegen: Remove always-false branch
Each ff_cbrt_tableinit*() is called at most once, making this
check always-false.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/cbrt_tablegen.h | 2 --
1 file changed, 2 deletions(-)
diff --git a/libavcodec/cbrt_tablegen.h b/libavcodec/cbrt_tablegen.h
index 9af18d8ab5..fae5d547aa 100644
--- a/libavcodec/cbrt_tablegen.h
+++ b/libavcodec/cbrt_tablegen.h
@@ -40,7 +40,6 @@ uint32_t AAC_RENAME(ff_cbrt_tab)[1 << 13];
av_cold void AAC_RENAME(ff_cbrt_tableinit)(void)
{
static double cbrt_tab_dbl[1 << 13];
-if (!AAC_RENAME(ff_cbrt_tab)[(1<<13) - 1]) {
int i, j, k;
double cbrt_val;
@@ -67,7 +66,6 @@ av_cold void AAC_RENAME(ff_cbrt_tableinit)(void)
for (i = 0; i < 1<<13; i++)
AAC_RENAME(ff_cbrt_tab)[i] = CBRT(cbrt_tab_dbl[i]);
-}
}
#endif /* AVCODEC_CBRT_TABLEGEN_H */
--
2.49.1
From 88c3d9c9179826d23369b9b1699e6ffc4e18c3aa Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Tue, 2 Sep 2025 20:47:21 +0200
Subject: [PATCH 3/5] avcodec/cbrt_tablegen: Reduce size of LUT only used once
ff_cbrt_tableinit{,_fixed}() uses a LUT of doubles of the same size
as the actual LUT to be initialized (8192 elems). Said LUT is only
used to initialize another LUT, but because it is static, the dirty
memory (64KiB) is not released. It is also too large to be put on
the stack.
This commit mitigates this: We only use a LUT for the powers of
odd values, thereby halving its size. The generated LUT stays unchanged.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/cbrt_tablegen.h | 58 --
1 file changed, 37 insertions(+), 21 deletions(-)
diff --git a/libavcodec/cbrt_tablegen.h b/libavcodec/cbrt_tablegen.h
index fae5d547aa..53ff79f570 100644
--- a/libavcodec/cbrt_tablegen.h
+++ b/libavcodec/cbrt_tablegen.h
@@ -35,37 +35,53 @@
#define CBRT(x) av_float2int((float)(x))
#endif
-uint32_t AAC_RENAME(ff_cbrt_tab)[1 << 13];
+#define LUT_SIZE (1 << 13)
+#define TMP_LUT_SIZE (LUT_SIZE/2)
+
+uint32_t AAC_RENAME(ff_cbrt_tab)[LUT_SIZE];
av_cold void AAC_RENAME(ff_cbrt_tableinit)(void)
{
-static double cbrt_tab_dbl[1 << 13];
-int i, j, k;
-double cbrt_val;
+// LUT of k^{4/3} for odd k; element idx corresponds to 2 * idx + 1.
+static double cbrt_tab_dbl[TMP_LUT_SIZE];
-for (i = 1; i < 1<<13; i++)
-cbrt_tab_dbl[i] = 1;
+for (int idx = 0; idx < TMP_LUT_SIZE; ++idx)
+cbrt_tab_dbl[idx] = 1;
-/* have to take care of non-squarefree numbers */
-for (i = 2; i < 90; i++) {
-if (cbrt_tab_dbl[i] == 1) {
-cbrt_val = i * cbrt(i);
-for (k = i; k < 1<<13; k *= i)
-for (j = k; j < 1<<13; j += k)
-cbrt_tab_dbl[j] *= cbrt_val;
+/* have to take care of non-squarefree numbers; notice that sqrt(LUT_SIZE)
= 90;
+ * idx == 44 corresponds to 89. */
+for (int idx = 1; idx < 45; ++idx) {
+if (cbrt_tab_dbl[idx] == 1) {
+int i = 2 * idx + 1;
+double cbrt_val = i * cbrt(i);
+for (int k = i; k < LUT_SIZE; k *= i) {
+// We only have to handle k, 3 * k, 5 * k,...,
+// because only these are odd. The corresponding indices are
+// k >> 1, (k >> 1) + k, (k >> 1) + 2 * k,...
+for (int idx2 = k >> 1; idx2 < TMP_LUT_SIZE; idx2 += k)
+cbrt_tab_dbl[idx2] *= cbrt_val;
}
}
+}
-for (i = 91; i <= 8191; i+= 2) {
-if (cbrt_tab_dbl[i] == 1) {
-cbrt_val = i * cbrt(i);
-for (j = i; j < 1<<13; j += i)
-cbrt_tab
[FFmpeg-devel] [PATCH] avformat/avformat: Make AVFMT_FLAG_ID3V2_AUTO private (PR #20419)
PR #20419 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20419
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20419.patch
It has been pushed just now (without version bump and APIchanges entry...), so
it can be made private without deprecation.
>From f5cc1af53ab04c3ccf8786983c7b5ab69398b742 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Wed, 3 Sep 2025 20:38:48 +0200
Subject: [PATCH 1/3] avformat/avformat: Make AVFMT_FLAG_ID3V2_AUTO private
This flag governs whether avformat_open_input() reads
ID3v2 tags generically; some demuxers without this flag
read these tags themselves in a non-generic way,
e.g. oma. This makes this flag an implementation detail
that should not be exposed to the user, i.e. an internal flag.
Given that 9d037c54f209958d47ac376d2a9561608f98dfae
did not bump version and added no APIchanges entry
I deemded it inappropriate to bump version or add
an APIchanges entry for the removal of AVFMT_FLAG_ID3V2_AUTO.
Signed-off-by: Andreas Rheinhardt
---
libavformat/aacdec.c | 3 ++-
libavformat/avformat.h | 1 -
libavformat/demux.c| 2 +-
libavformat/demux.h| 5 +
libavformat/mp3dec.c | 3 ++-
libavformat/tta.c | 2 +-
libavformat/wavdec.c | 3 ++-
7 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c
index 21d63ce189..38ac9dcbe7 100644
--- a/libavformat/aacdec.c
+++ b/libavformat/aacdec.c
@@ -208,9 +208,10 @@ retry:
const FFInputFormat ff_aac_demuxer = {
.p.name = "aac",
.p.long_name = NULL_IF_CONFIG_SMALL("raw ADTS AAC (Advanced Audio
Coding)"),
-.p.flags = AVFMT_GENERIC_INDEX | AVFMT_FLAG_ID3V2_AUTO,
+.p.flags = AVFMT_GENERIC_INDEX,
.p.extensions = "aac",
.p.mime_type = "audio/aac,audio/aacp,audio/x-aac",
+.flags_internal = FF_INFMT_FLAG_ID3V2_AUTO,
.read_probe = adts_aac_probe,
.read_header = adts_aac_read_header,
.read_packet = adts_aac_read_packet,
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 75c8a4703b..be6e532387 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1435,7 +1435,6 @@ typedef struct AVFormatContext {
#define AVFMT_FLAG_SORT_DTS0x1 ///< try to interleave outputted
packets by dts (using this flag can slow demuxing down)
#define AVFMT_FLAG_FAST_SEEK 0x8 ///< Enable fast, but inaccurate seeks
for some formats
#define AVFMT_FLAG_AUTO_BSF 0x20 ///< Add bitstream filters as requested
by the muxer
-#define AVFMT_FLAG_ID3V2_AUTO 0x40 ///< Automatically parse ID3v2 metadata
/**
* Maximum number of bytes read from input in order to determine stream
diff --git a/libavformat/demux.c b/libavformat/demux.c
index dfc146d9c4..14776bc02f 100644
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -215,7 +215,7 @@ static int update_stream_avctx(AVFormatContext *s)
}
static av_always_inline int is_id3v2_format(const AVInputFormat *fmt) {
-return fmt->flags & AVFMT_FLAG_ID3V2_AUTO;
+return ffifmt(fmt)->flags_internal & FF_INFMT_FLAG_ID3V2_AUTO;
}
int avformat_open_input(AVFormatContext **ps, const char *filename,
diff --git a/libavformat/demux.h b/libavformat/demux.h
index 7c22c870e2..ab1c001c9f 100644
--- a/libavformat/demux.h
+++ b/libavformat/demux.h
@@ -39,6 +39,11 @@ struct AVDeviceInfoList;
*/
#define FF_INFMT_FLAG_PREFER_CODEC_FRAMERATE (1 << 1)
+/**
+ * Automatically parse ID3v2 metadata
+ */
+#define FF_INFMT_FLAG_ID3V2_AUTO (1 << 2)
+
typedef struct FFInputFormat {
/**
* The public AVInputFormat. See avformat.h for it.
diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
index 9cfc711493..5b153c7c9e 100644
--- a/libavformat/mp3dec.c
+++ b/libavformat/mp3dec.c
@@ -618,10 +618,11 @@ static const AVClass demuxer_class = {
const FFInputFormat ff_mp3_demuxer = {
.p.name = "mp3",
.p.long_name= NULL_IF_CONFIG_SMALL("MP2/3 (MPEG audio layer 2/3)"),
-.p.flags= AVFMT_GENERIC_INDEX | AVFMT_FLAG_ID3V2_AUTO,
+.p.flags= AVFMT_GENERIC_INDEX,
.p.extensions = "mp2,mp3,m2a,mpa", /* XXX: use probe */
.p.priv_class = &demuxer_class,
.p.mime_type= "audio/mpeg",
+.flags_internal = FF_INFMT_FLAG_ID3V2_AUTO,
.read_probe = mp3_read_probe,
.read_header= mp3_read_header,
.read_packet= mp3_read_packet,
diff --git a/libavformat/tta.c b/libavformat/tta.c
index 26335202c7..70642324af 100644
--- a/libavformat/tta.c
+++ b/libavformat/tta.c
@@ -191,9 +191,9 @@ static int tta_read_seek(AVFormatContext *s, int
stream_index, int64_t timestamp
const FFInputFormat ff_tta_demuxer = {
.p.name = "tta",
.p.long_name= NULL_IF_CONFIG_SMALL("TTA (True Audio)"),
-.p.flags= AVFMT_FLAG_ID3V2_AUTO,
.p.extensions = "tta",
.priv_data_size = sizeof(TTAContext),
+.flags_internal = FF_INFMT_FLAG_ID3V2_AUTO,
.read_probe = tta_pr
[FFmpeg-devel] [PATCH] avcodec/pcm_tablegen: Fix hardcoded-tables if alaw,mulaw,vidc codecs disabled (PR #20436)
PR #20436 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20436
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20436.patch
Given that the various tableinit functions are no longer compiled
unconditionally, one gets a compilation failure in pcm_tablegen.c (which
creates the tables to be hardcoded) when both the encoder as well as the
decoder are disabled for any one of {alaw,mulaw,vidc}. This commit fixes this
scenario. It is intended to be applied after #20394 (otherwise, it would cause
a regression when only the encoder is disabled with the decoder enabled).
>From 4aabe5c9169d1242c4a2ba64e9943ab19cf4721f Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Thu, 4 Sep 2025 14:56:13 +0200
Subject: [PATCH] avcodec/pcm_tablegen: Fix hardcoded-tables if alaw,mulaw,vidc
codecs disabled
Since ae448e00afb43d7f72dfa9c82a4c45994e4fea6a the various
tableinit functions are not compiled unconditionally any more,
so that pcm_tablegen.c (which creates the hardcoded tables)
needs to be updated.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/pcm_tablegen.c | 14 ++
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/libavcodec/pcm_tablegen.c b/libavcodec/pcm_tablegen.c
index 473a47f6d9..cff713606b 100644
--- a/libavcodec/pcm_tablegen.c
+++ b/libavcodec/pcm_tablegen.c
@@ -21,21 +21,27 @@
*/
#include
+#include "config_components.h"
#define CONFIG_HARDCODED_TABLES 0
#include "pcm_tablegen.h"
#include "tableprint.h"
int main(void)
{
-pcm_alaw_tableinit();
-pcm_ulaw_tableinit();
-pcm_vidc_tableinit();
-
write_fileheader();
+#if CONFIG_PCM_ALAW_ENCODER
+pcm_alaw_tableinit();
WRITE_ARRAY("static const", uint8_t, linear_to_alaw);
+#endif
+#if CONFIG_PCM_MULAW_ENCODER
+pcm_ulaw_tableinit();
WRITE_ARRAY("static const", uint8_t, linear_to_ulaw);
+#endif
+#if CONFIG_PCM_VIDC_ENCODER
+pcm_vidc_tableinit();
WRITE_ARRAY("static const", uint8_t, linear_to_vidc);
+#endif
return 0;
}
--
2.49.1
___
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] swscale/ops: Fix linking with x86 assembly disabled (PR #20432)
PR #20432 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20432
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20432.patch
Also use "" instead of <> to include our own headers.
>From fec72a6ead263021148530ec6a97de0c0e56cb0f Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Thu, 4 Sep 2025 14:01:20 +0200
Subject: [PATCH 1/2] swscale/ops: Fix linking with x86 assembly disabled
Signed-off-by: Andreas Rheinhardt
---
libswscale/ops.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libswscale/ops.c b/libswscale/ops.c
index e8c05587e1..21aeb16931 100644
--- a/libswscale/ops.c
+++ b/libswscale/ops.c
@@ -33,7 +33,7 @@ extern const SwsOpBackend backend_x86;
const SwsOpBackend * const ff_sws_op_backends[] = {
&backend_murder,
-#if ARCH_X86_64
+#if ARCH_X86_64 && HAVE_X86ASM
&backend_x86,
#endif
&backend_c,
--
2.49.1
>From c6dc5d299e1b4f2730691910b1b9cfaa0092166b Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Thu, 4 Sep 2025 14:16:45 +0200
Subject: [PATCH 2/2] all: Use "" instead of <> to include internal headers
Signed-off-by: Andreas Rheinhardt
---
fftools/textformat/tf_mermaid.c | 7 +++
libavfilter/vf_colordetect.h| 5 ++---
libavfilter/vf_deshake_opencl.c | 2 +-
libswscale/ops_optimizer.c | 2 +-
libswscale/x86/ops.c| 4 ++--
5 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/fftools/textformat/tf_mermaid.c b/fftools/textformat/tf_mermaid.c
index 6af58d58c2..ef730d570b 100644
--- a/fftools/textformat/tf_mermaid.c
+++ b/fftools/textformat/tf_mermaid.c
@@ -27,10 +27,9 @@
#include "avtextformat.h"
#include "tf_internal.h"
#include "tf_mermaid.h"
-#include
-#include
-#include
-#include
+#include "libavutil/bprint.h"
+#include "libavutil/mem.h"
+#include "libavutil/opt.h"
static const char *init_directive = ""
diff --git a/libavfilter/vf_colordetect.h b/libavfilter/vf_colordetect.h
index 95f30a6ac2..aa974bb1fd 100644
--- a/libavfilter/vf_colordetect.h
+++ b/libavfilter/vf_colordetect.h
@@ -22,9 +22,8 @@
#include
#include
-#include
-#include
-#include
+#include "libavutil/avassert.h"
+#include "libavutil/pixfmt.h"
enum FFAlphaDetect {
FF_ALPHA_NONE = -1,
diff --git a/libavfilter/vf_deshake_opencl.c b/libavfilter/vf_deshake_opencl.c
index dc3df0e989..1dc5486613 100644
--- a/libavfilter/vf_deshake_opencl.c
+++ b/libavfilter/vf_deshake_opencl.c
@@ -46,7 +46,7 @@
*/
#include
-#include
+#include "libavutil/lfg.h"
#include "libavutil/opt.h"
#include "libavutil/mem.h"
#include "libavutil/fifo.h"
diff --git a/libswscale/ops_optimizer.c b/libswscale/ops_optimizer.c
index c28c2c36bb..b13e7ebdc1 100644
--- a/libswscale/ops_optimizer.c
+++ b/libswscale/ops_optimizer.c
@@ -19,7 +19,7 @@
*/
#include "libavutil/avassert.h"
-#include
+#include "libavutil/bswap.h"
#include "libavutil/rational.h"
#include "ops.h"
diff --git a/libswscale/x86/ops.c b/libswscale/x86/ops.c
index 8704f77227..3b5a060f64 100644
--- a/libswscale/x86/ops.c
+++ b/libswscale/x86/ops.c
@@ -20,8 +20,8 @@
#include
-#include
-#include
+#include "libavutil/avassert.h"
+#include "libavutil/mem.h"
#include "../ops_chain.h"
--
2.49.1
___
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] tests/checkasm/sw_ops: Avoid 1 << 32 (PR #20515)
PR #20515 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20515
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20515.patch
It is UB.
>From bc545bae3be34e71980f93259dfca1b8bb28bd92 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Sat, 13 Sep 2025 21:27:27 +0200
Subject: [PATCH] tests/checkasm/sw_ops: Avoid 1 << 32
It is UB.
Signed-off-by: Andreas Rheinhardt
---
tests/checkasm/sw_ops.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/checkasm/sw_ops.c b/tests/checkasm/sw_ops.c
index 57fd501fa1..20b697bf25 100644
--- a/tests/checkasm/sw_ops.c
+++ b/tests/checkasm/sw_ops.c
@@ -426,7 +426,7 @@ static void check_pack_unpack(void)
.pack = pack,
});
-CHECK_RANGE(FMT("unpack_%s", pat), (1 << total) - 1, 1, num, type,
type, {
+CHECK_RANGE(FMT("unpack_%s", pat), UINT32_MAX >> (32 - total), 1, num,
type, type, {
.op = SWS_OP_UNPACK,
.type = type,
.pack = pack,
--
2.49.1
___
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] swresample/swresample_internal: Use union for float, int matrix (PR #20505)
PR #20505 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20505
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20505.patch
>From 92b22e11ad75397137aa4bdcab6a3bf1e680a258 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Fri, 12 Sep 2025 17:53:27 +0200
Subject: [PATCH 1/4] swresample/swresample_internal: Use union for float, int
matrix
Saves 16KiB from SwrContext.
(FATE would also pass if one made the double matrix part of
the union, too, but I don't know whether this is truely correct,
because swri_rematrix() accesses the double matrix (to check whether
it is equal to 1.0) even when one of the other matrices is in use.)
Signed-off-by: Andreas Rheinhardt
---
libswresample/rematrix.c| 35 ++---
libswresample/swresample_internal.h | 8 +--
2 files changed, 23 insertions(+), 20 deletions(-)
diff --git a/libswresample/rematrix.c b/libswresample/rematrix.c
index f55b85a52d..c88b22d8fb 100644
--- a/libswresample/rematrix.c
+++ b/libswresample/rematrix.c
@@ -69,13 +69,12 @@ int swr_set_matrix(struct SwrContext *s, const double
*matrix, int stride)
if (!s || s->in_convert) // s needs to be allocated but not initialized
return AVERROR(EINVAL);
memset(s->matrix, 0, sizeof(s->matrix));
-memset(s->matrix_flt, 0, sizeof(s->matrix_flt));
nb_in = s->user_in_chlayout.nb_channels;
nb_out = s->user_out_chlayout.nb_channels;
for (out = 0; out < nb_out; out++) {
for (in = 0; in < nb_in; in++)
-s->matrix_flt[out][in] = s->matrix[out][in] = matrix[in];
+s->matrix[out][in] = matrix[in];
matrix += stride;
}
s->rematrix_custom = 1;
@@ -436,7 +435,6 @@ fail:
av_cold static int auto_matrix(SwrContext *s)
{
double maxval;
-int ret;
if (s->rematrix_maxval > 0) {
maxval = s->rematrix_maxval;
@@ -447,19 +445,10 @@ av_cold static int auto_matrix(SwrContext *s)
maxval = INT_MAX;
memset(s->matrix, 0, sizeof(s->matrix));
-ret = swr_build_matrix2(&s->in_ch_layout, &s->out_ch_layout,
- s->clev, s->slev, s->lfe_mix_level,
- maxval, s->rematrix_volume, (double*)s->matrix,
- s->matrix[1] - s->matrix[0], s->matrix_encoding, s);
-
-if (ret >= 0 && s->int_sample_fmt == AV_SAMPLE_FMT_FLTP) {
-int i, j;
-for (i = 0; i < FF_ARRAY_ELEMS(s->matrix[0]); i++)
-for (j = 0; j < FF_ARRAY_ELEMS(s->matrix[0]); j++)
-s->matrix_flt[i][j] = s->matrix[i][j];
-}
-
-return ret;
+return swr_build_matrix2(&s->in_ch_layout, &s->out_ch_layout,
+ s->clev, s->slev, s->lfe_mix_level,
+ maxval, s->rematrix_volume, (double*)s->matrix,
+ s->matrix[1] - s->matrix[0], s->matrix_encoding,
s);
}
av_cold int swri_rematrix_init(SwrContext *s){
@@ -554,9 +543,19 @@ av_cold int swri_rematrix_init(SwrContext *s){
for (i = 0; i < SWR_CH_MAX; i++) {
int ch_in=0;
for (j = 0; j < SWR_CH_MAX; j++) {
-s->matrix32[i][j]= lrintf(s->matrix[i][j] * 32768);
-if(s->matrix[i][j])
+const double coeff = s->matrix[i][j];
+if (coeff)
s->matrix_ch[i][++ch_in]= j;
+switch (s->int_sample_fmt) {
+case AV_SAMPLE_FMT_FLTP:
+s->matrix_flt[i][j] = coeff;
+break;
+case AV_SAMPLE_FMT_DBLP:
+break;
+default:
+s->matrix32[i][j] = lrintf(coeff * 32768);
+break;
+}
}
s->matrix_ch[i][0]= ch_in;
}
diff --git a/libswresample/swresample_internal.h
b/libswresample/swresample_internal.h
index 21c9e33fa1..c2b5e18a2c 100644
--- a/libswresample/swresample_internal.h
+++ b/libswresample/swresample_internal.h
@@ -167,12 +167,16 @@ struct SwrContext {
struct Resampler const *resampler; ///< resampler virtual
function table
double matrix[SWR_CH_MAX][SWR_CH_MAX]; ///< floating point
rematrixing coefficients
-float matrix_flt[SWR_CH_MAX][SWR_CH_MAX]; ///< single precision
floating point rematrixing coefficients
+union {
+float matrix_flt[SWR_CH_MAX][SWR_CH_MAX]; ///< single precision
floating point rematrixing coefficients
+///< valid iff
int_sample_fmt is AV_SAMPLE_FMT_FLTP
+int32_t matrix32[SWR_CH_MAX][SWR_CH_MAX]; ///< 17.15 fixed point
rematrixing coefficients
+///< valid iff
int_sample_fmt is != AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_DBLP
+};
uint8_t *native_matrix;
uint8_t *native_one;
uint8_t *native_simd_one;
uint8_t *native_simd_matrix;
-int32_t matrix32[SWR_CH_MAX][SWR_CH_MAX]; ///< 17.15 fixed point
rematrixing coefficients
[FFmpeg-devel] [PATCH] avcodec/bsf/noise: Avoid allocation for string (PR #20506)
PR #20506 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20506
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20506.patch
>From 77afa9f560fb883d543184911192acf918ea9b9c Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Fri, 12 Sep 2025 19:34:39 +0200
Subject: [PATCH] avcodec/bsf/noise: Avoid allocation for string
Signed-off-by: Andreas Rheinhardt
---
libavcodec/bsf/noise.c | 17 +++--
1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/libavcodec/bsf/noise.c b/libavcodec/bsf/noise.c
index a622855717..3462b30f82 100644
--- a/libavcodec/bsf/noise.c
+++ b/libavcodec/bsf/noise.c
@@ -18,13 +18,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include
+#include
#include "bsf.h"
#include "bsf_internal.h"
#include "libavutil/log.h"
-#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/eval.h"
@@ -79,24 +78,22 @@ typedef struct NoiseContext {
static int noise_init(AVBSFContext *ctx)
{
NoiseContext *s = ctx->priv_data;
+const char *amount_str = s->amount_str;
int ret;
-if (!s->amount_str) {
-s->amount_str = (!s->drop_str && !s->dropamount) ? av_strdup("-1") :
av_strdup("0");
-if (!s->amount_str)
-return AVERROR(ENOMEM);
-}
+if (!amount_str)
+amount_str = (!s->drop_str && !s->dropamount) ? "-1" : "0";
if (ctx->par_in->codec_id == AV_CODEC_ID_WRAPPED_AVFRAME &&
-strcmp(s->amount_str, "0")) {
+strcmp(amount_str, "0")) {
av_log(ctx, AV_LOG_ERROR, "Wrapped AVFrame noising is unsupported\n");
return AVERROR_PATCHWELCOME;
}
-ret = av_expr_parse(&s->amount_pexpr, s->amount_str,
+ret = av_expr_parse(&s->amount_pexpr, amount_str,
var_names, NULL, NULL, NULL, NULL, 0, ctx);
if (ret < 0) {
-av_log(ctx, AV_LOG_ERROR, "Error in parsing expr for amount: %s\n",
s->amount_str);
+av_log(ctx, AV_LOG_ERROR, "Error in parsing expr for amount: %s\n",
amount_str);
return ret;
}
--
2.49.1
___
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] swscale/x86/ops: Fix leak (PR #20507)
PR #20507 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20507
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20507.patch
>From 0c93050b46a431475f0af2e3cac7c400d16afc70 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Fri, 12 Sep 2025 20:47:57 +0200
Subject: [PATCH 1/2] swscale/ops_chain: Free correct pointer on error
Signed-off-by: Andreas Rheinhardt
---
libswscale/ops_chain.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libswscale/ops_chain.c b/libswscale/ops_chain.c
index 80162507b0..ef768b4904 100644
--- a/libswscale/ops_chain.c
+++ b/libswscale/ops_chain.c
@@ -234,7 +234,7 @@ int ff_sws_op_compile_tables(const SwsOpTable *const
tables[], int num_tables,
ret = ff_sws_op_chain_append(chain, best->func, best->free, &priv);
if (ret < 0) {
if (best->free)
-best->free(&priv);
+best->free(priv.ptr);
return ret;
}
--
2.49.1
>From 18555df87e7838b88bc9c583b79fee2d8cb8 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Fri, 12 Sep 2025 20:55:24 +0200
Subject: [PATCH 2/2] swscale/x86/ops: Fix leak
Signed-off-by: Andreas Rheinhardt
---
libswscale/x86/ops.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libswscale/x86/ops.c b/libswscale/x86/ops.c
index 3b5a060f64..82a6d233b9 100644
--- a/libswscale/x86/ops.c
+++ b/libswscale/x86/ops.c
@@ -206,7 +206,7 @@ static int setup_dither(const SwsOp *op, SwsOpPriv *out)
DECL_COMMON_PATTERNS(F32, dither##SIZE##EXT,
\
.op= SWS_OP_DITHER,
\
.setup = setup_dither,
\
-.free = SIZE > 2 ? av_free : NULL,
\
+.free = (1 << SIZE) > 2 ? av_free : NULL,
\
.dither_size = SIZE,
\
);
--
2.49.1
___
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] avcodec: Add av_cold to flush,init,close functions missing it (PR #20509)
PR #20509 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20509
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20509.patch
>From 343b38b29fe048358237807660224d8074b664df Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Fri, 5 Sep 2025 01:09:49 +0200
Subject: [PATCH 1/2] avcodec: Add av_cold to flush,init,close functions
missing it
Signed-off-by: Andreas Rheinhardt
---
libavcodec/acelp_filters.c | 2 +-
libavcodec/acelp_vectors.c | 2 +-
libavcodec/adpcm.c | 4 +++-
libavcodec/adxdec.c| 3 ++-
libavcodec/agm.c | 3 ++-
libavcodec/apedec.c| 3 ++-
libavcodec/apv_decode.c| 3 ++-
libavcodec/arbc.c | 3 ++-
libavcodec/argo.c | 3 ++-
libavcodec/ass.c | 2 +-
libavcodec/ass_split.c | 4 ++--
libavcodec/atrac9dec.c | 2 +-
libavcodec/audio_frame_queue.c | 2 +-
libavcodec/av1_parser.c| 3 ++-
libavcodec/av1dec.c| 3 ++-
libavcodec/avdct.c | 7 ---
libavcodec/bink.c | 2 +-
libavcodec/binkaudio.c | 3 ++-
libavcodec/cavsdec.c | 3 ++-
libavcodec/cbs_av1.c | 5 +++--
libavcodec/cbs_bsf.c | 6 --
libavcodec/cbs_h2645.c | 12 ++--
libavcodec/cbs_vp9.c | 2 +-
libavcodec/ccaption_dec.c | 3 ++-
libavcodec/cdgraphics.c| 4 +++-
libavcodec/cdtoons.c | 2 +-
libavcodec/celp_filters.c | 3 ++-
libavcodec/cngdec.c| 2 +-
libavcodec/dirac_parser.c | 5 +++--
libavcodec/dovi_rpu.c | 3 ++-
libavcodec/dpcm.c | 4 +++-
libavcodec/dvdsubdec.c | 2 +-
libavcodec/evc_parser.c| 4 +++-
libavcodec/executor.c | 6 +++---
libavcodec/ffv1_parser.c | 4 +++-
libavcodec/flac_parser.c | 2 +-
libavcodec/ftr.c | 4 +++-
libavcodec/gif.c | 3 ++-
libavcodec/gsmdec.c| 3 ++-
libavcodec/h264_parser.c | 3 ++-
libavcodec/h264dec.c | 3 ++-
libavcodec/hevc/hevcdec.c | 2 +-
libavcodec/imm4.c | 3 ++-
libavcodec/imm5.c | 3 ++-
libavcodec/imx.c | 5 +++--
libavcodec/j2kenc.c| 3 ++-
libavcodec/lossless_videodsp.c | 3 ++-
libavcodec/midivid.c | 3 ++-
libavcodec/mjpegdec.c | 7 +++
libavcodec/mlpdec.c| 3 ++-
libavcodec/mobiclip.c | 3 ++-
libavcodec/movtextenc.c| 3 ++-
libavcodec/mpc7.c | 3 ++-
libavcodec/mpegvideo_parser.c | 2 +-
libavcodec/msrle.c | 3 ++-
libavcodec/msrleenc.c | 4 +++-
libavcodec/mv30.c | 3 ++-
libavcodec/osq.c | 3 ++-
libavcodec/parser.c| 7 ---
libavcodec/pdvdec.c| 4 +++-
libavcodec/qpeg.c | 5 -
libavcodec/qtrle.c | 4 +++-
libavcodec/ralf.c | 2 +-
libavcodec/rtjpeg.c| 4 +++-
libavcodec/rv60dec.c | 4 +++-
libavcodec/samidec.c | 3 ++-
libavcodec/srtenc.c| 2 +-
libavcodec/svq1dec.c | 3 ++-
libavcodec/textdec.c | 3 ++-
libavcodec/v4l2_m2m.c | 6 +++---
libavcodec/vc1dec.c| 2 +-
libavcodec/vorbis_parser.c | 2 +-
libavcodec/vp3.c | 3 ++-
libavcodec/vp9.c | 3 ++-
libavcodec/vvc/thread.c| 4 ++--
libavcodec/wavpack.c | 2 +-
libavcodec/webvttenc.c | 2 +-
libavcodec/wmalosslessdec.c| 2 +-
libavcodec/wmaprodec.c | 7 ---
libavcodec/xbm_parser.c| 7 +--
libavcodec/zerocodec.c | 3 ++-
81 files changed, 176 insertions(+), 106 deletions(-)
diff --git a/libavcodec/acelp_filters.c b/libavcodec/acelp_filters.c
index db4908f31c..99e8994851 100644
--- a/libavcodec/acelp_filters.c
+++ b/libavcodec/acelp_filters.c
@@ -147,7 +147,7 @@ void ff_tilt_compensation(float *mem, float tilt, float
*samples, int size)
*mem = new_tilt_mem;
}
-void ff_acelp_filter_init(ACELPFContext *c)
+av_cold void ff_acelp_filter_init(ACELPFContext *c)
{
c->acelp_interpolatef = ff_acelp_interpolatef;
c->acelp_apply_order_2_transfer_function =
ff_acelp_apply_order_2_transfer_function;
diff --git a/libavcodec/acelp_vectors.c b/libavcodec/acelp_vectors.c
index f47da40008..99d573bda2 100644
--- a/libavcodec/acelp_vectors.c
+++ b/libavcodec/acelp_vectors.c
@@ -255,7 +255,7 @@ void ff_clear_fixed_vector(float *out, const AMRFixed *in,
int size)
}
}
-void ff_acelp_vectors_init(ACELPVContext *c)
+av_cold void ff_acelp_vectors_init(ACELPVContext *c)
{
c->weighted_vector_sumf = ff_weighted_vector_sumf;
diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
index 4c15be6207..26323507e3 100644
--- a/libavcodec/adpcm.c
+++ b/libavcodec/adpcm.c
@@ -46,6 +46,8 @@
#include "code
[FFmpeg-devel] [PATCH] avcodec/vvc/data: Mark tables as hidden (PR #20510)
PR #20510 opened by mkver URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20510 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20510.patch This allows compilers to optimize accesses like ff_vvc_diag_scan_x[2][2][x] by baking the offset derived from [2][2] into the relocation (so that it is performed at link-time). Signed-off-by: Andreas Rheinhardt >From 6aea9faf166f8e793361d3997e4475c02abac52a Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sat, 13 Sep 2025 05:00:32 +0200 Subject: [PATCH] avcodec/vvc/data: Mark tables as hidden This allows compilers to optimize accesses like ff_vvc_diag_scan_x[2][2][x] by baking the offset derived from [2][2] into the relocation (so that it is performed at link-time). Signed-off-by: Andreas Rheinhardt --- libavcodec/vvc/data.h | 4 1 file changed, 4 insertions(+) diff --git a/libavcodec/vvc/data.h b/libavcodec/vvc/data.h index a0512e626b..a28150484d 100644 --- a/libavcodec/vvc/data.h +++ b/libavcodec/vvc/data.h @@ -23,6 +23,9 @@ #include +#include "libavutil/attributes_internal.h" + +FF_VISIBILITY_PUSH_HIDDEN extern const uint8_t ff_vvc_diag_scan_x[5][5][16 * 16]; extern const uint8_t ff_vvc_diag_scan_y[5][5][16 * 16]; @@ -80,5 +83,6 @@ extern const uint8_t ff_vvc_alf_class_to_filt_map[16][25]; extern const uint8_t ff_vvc_alf_aps_class_to_filt_map[25]; const uint8_t* ff_vvc_get_mip_matrix(const int size_id, const int mode_idx); +FF_VISIBILITY_POP_HIDDEN #endif /* AVCODEC_VVC_DATA_H */ -- 2.49.1 ___ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] swresample/resample, soxr_resample: Use designated initializers (PR #20508)
PR #20508 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20508
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20508.patch
>From 1c050139a9ae49bd147039975d6d7a67ee70ee66 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Fri, 12 Sep 2025 22:22:22 +0200
Subject: [PATCH] swresample/resample, soxr_resample: Use designated
initializers
Signed-off-by: Andreas Rheinhardt
---
libswresample/resample.c | 18 +-
libswresample/soxr_resample.c | 11 ---
2 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/libswresample/resample.c b/libswresample/resample.c
index 2b8571bbd6..16d48e93da 100644
--- a/libswresample/resample.c
+++ b/libswresample/resample.c
@@ -501,13 +501,13 @@ static int invert_initial_buffer(ResampleContext *c,
AudioData *dst, const Audio
return FFMAX(res, 0);
}
-struct Resampler const swri_resampler={
- resample_init,
- resample_free,
- multiple_resample,
- resample_flush,
- set_compensation,
- get_delay,
- invert_initial_buffer,
- get_out_samples,
+const struct Resampler swri_resampler = {
+.init = resample_init,
+.free = resample_free,
+.multiple_resample = multiple_resample,
+.flush = resample_flush,
+.set_compensation = set_compensation,
+.get_delay = get_delay,
+.invert_initial_buffer = invert_initial_buffer,
+.get_out_samples = get_out_samples,
};
diff --git a/libswresample/soxr_resample.c b/libswresample/soxr_resample.c
index 00d79878ca..cc5b4db5d4 100644
--- a/libswresample/soxr_resample.c
+++ b/libswresample/soxr_resample.c
@@ -123,7 +123,12 @@ static int64_t get_out_samples(struct SwrContext *s, int
in_samples){
return (int64_t)(out_samples + delayed_samples + 1 + .5);
}
-struct Resampler const swri_soxr_resampler={
-create, destroy, process, flush, NULL /* set_compensation */, get_delay,
-invert_initial_buffer, get_out_samples
+const struct Resampler swri_soxr_resampler = {
+.init = create,
+.free = destroy,
+.multiple_resample = process,
+.flush = flush,
+.get_delay = get_delay,
+.invert_initial_buffer = invert_initial_buffer,
+.get_out_samples = get_out_samples,
};
--
2.49.1
___
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] avcodec/rkmppdec: Close decoder generically on init failure (PR #20512)
PR #20512 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20512
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20512.patch
>From 6f07c9da0dd143e24e50f7cfb2030d7e885e5f71 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Sat, 13 Sep 2025 11:59:01 +0200
Subject: [PATCH] avcodec/rkmppdec: Close decoder generically on init failure
Signed-off-by: Andreas Rheinhardt
---
libavcodec/rkmppdec.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/libavcodec/rkmppdec.c b/libavcodec/rkmppdec.c
index dad0e4c25f..a5ed0fc9b7 100644
--- a/libavcodec/rkmppdec.c
+++ b/libavcodec/rkmppdec.c
@@ -257,7 +257,6 @@ static av_cold int rkmpp_init_decoder(AVCodecContext *avctx)
fail:
av_log(avctx, AV_LOG_ERROR, "Failed to initialize RKMPP decoder.\n");
-rkmpp_close_decoder(avctx);
return ret;
}
@@ -563,7 +562,7 @@ static const AVCodecHWConfigInternal *const
rkmpp_hw_configs[] = {
.hw_configs = rkmpp_hw_configs, \
.bsfs = BSFS, \
.p.wrapper_name = "rkmpp", \
-.caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE, \
+.caps_internal = FF_CODEC_CAP_INIT_CLEANUP |
FF_CODEC_CAP_NOT_INIT_THREADSAFE, \
};
RKMPP_DEC(h264, AV_CODEC_ID_H264, "h264_mp4toannexb")
--
2.49.1
___
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] avformat/aviobuf: Don't pretend to support avio_context_free(NULL) (PR #20416)
PR #20416 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20416
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20416.patch
It makes no sense to ever call it that way given that
avio_context_free() accepts a pointer to a pointer to an AVIOContext.
Other double-pointer-free functions like av_freep() also do it
that way (and therefore avio_context_free(NULL) still crashes
even with 870cfed2317e311a71bc14773332486a162f059c).
Signed-off-by: Andreas Rheinhardt
>From cd21fa41c70bdc03660e0566649e9cf2bd7441b7 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Wed, 3 Sep 2025 15:51:51 +0200
Subject: [PATCH] avformat/aviobuf: Don't pretend to support
avio_context_free(NULL)
It makes no sense to ever call it that way given that
avio_context_free() accepts a pointer to a pointer to an AVIOContext.
Other double-pointer-free functions like av_freep() also do it
that way (and therefore avio_context_free(NULL) still crashes
even with 870cfed2317e311a71bc14773332486a162f059c).
Signed-off-by: Andreas Rheinhardt
---
libavformat/aviobuf.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 2e65f50006..6a6ec36e28 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -125,8 +125,8 @@ AVIOContext *avio_alloc_context(
void avio_context_free(AVIOContext **ps)
{
-if (ps && *ps) {
-AVIOContext *s = *ps;
+AVIOContext *s = *ps;
+if (s) {
av_freep(&s->protocol_whitelist);
av_freep(&s->protocol_blacklist);
}
--
2.49.1
___
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] avcodec/mjpegdec: Avoid mixing return value and error code, avoid branch (PR #20497)
PR #20497 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20497
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20497.patch
>From 2fdfade62c03c2b2d6eefc4b52bef1d8a4ffcd38 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Thu, 11 Sep 2025 22:04:53 +0200
Subject: [PATCH 1/6] avcodec/mjpegdec: Remove pointless information from
logmessage
There is no reason to add the address of an element of
MJpegDecodeContext (which makes logmessage nonreproducible).
Also avoid always printing a zero.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/mjpegdec.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 3dde759fea..bb5540c8bb 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -822,8 +822,7 @@ static inline int mjpeg_decode_dc(MJpegDecodeContext *s,
int dc_index)
code = get_vlc2(&s->gb, s->vlcs[0][dc_index].table, 9, 2);
if (code < 0 || code > 16) {
av_log(s->avctx, AV_LOG_WARNING,
- "mjpeg_decode_dc: bad vlc: %d:%d (%p)\n",
- 0, dc_index, &s->vlcs[0][dc_index]);
+ "mjpeg_decode_dc: bad vlc: %d\n", dc_index);
return 0xf;
}
--
2.49.1
>From 7d74683d37069770fb619a6d1989b439eff52687 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Thu, 11 Sep 2025 22:33:32 +0200
Subject: [PATCH 2/6] avcodec/mjpegdec: Avoid superfluous secondary error
message
Up until now, a DC error in decode_block() or decode_dc_progressive()
would lead to a warning from mjpeg_decode_dc() and a (less verbose)
error from the caller. Upgrade the former to an error status (all
callers treat is an error) and remove the latter.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/mjpegdec.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index bb5540c8bb..711ea1c140 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -821,7 +821,7 @@ static inline int mjpeg_decode_dc(MJpegDecodeContext *s,
int dc_index)
int code;
code = get_vlc2(&s->gb, s->vlcs[0][dc_index].table, 9, 2);
if (code < 0 || code > 16) {
-av_log(s->avctx, AV_LOG_WARNING,
+av_log(s->avctx, AV_LOG_ERROR,
"mjpeg_decode_dc: bad vlc: %d\n", dc_index);
return 0xf;
}
@@ -841,7 +841,6 @@ static int decode_block(MJpegDecodeContext *s, int16_t
*block, int component,
/* DC coef */
val = mjpeg_decode_dc(s, dc_index);
if (val == 0xf) {
-av_log(s->avctx, AV_LOG_ERROR, "error dc\n");
return AVERROR_INVALIDDATA;
}
val = val * (unsigned)quant_matrix[0] + s->last_dc[component];
@@ -889,7 +888,6 @@ static int decode_dc_progressive(MJpegDecodeContext *s,
int16_t *block,
s->bdsp.clear_block(block);
val = mjpeg_decode_dc(s, dc_index);
if (val == 0xf) {
-av_log(s->avctx, AV_LOG_ERROR, "error dc\n");
return AVERROR_INVALIDDATA;
}
val = (val * (quant_matrix[0] << Al)) + s->last_dc[component];
--
2.49.1
>From d814b5b0e97165c9dfc882bb4d36a7d4431e61ca Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Fri, 12 Sep 2025 00:13:52 +0200
Subject: [PATCH 3/6] avcodec/mjpegdec: Avoid mixing return value and error
code, avoid branch
mjpeg_decode_dc() currently has a special return value (0xf)
for the case of invalid data; this value does not overlap with
the ordinary return values, yet the compiler can't prove this
(at least on x86 where an asm version of NEG_USR32 is used
inside get_xbits()), so the non-error return value has to be checked
for being the special value even if mjpeg_decode_dc() is inlined.
This commit avoids this by separating error code and ordinary return
value. It also means that the ljpeg functions return the proper
error code and not -1 in case of invalid data.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/mjpegdec.c | 48 ++-
1 file changed, 25 insertions(+), 23 deletions(-)
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 711ea1c140..82b82ff44d 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -816,20 +816,18 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
return 0;
}
-static inline int mjpeg_decode_dc(MJpegDecodeContext *s, int dc_index)
+static inline int mjpeg_decode_dc(MJpegDecodeContext *s, int dc_index, int
*val)
{
int code;
code = get_vlc2(&s->gb, s->vlcs[0][dc_index].table, 9, 2);
if (code < 0 || code > 16) {
av_log(s->avctx, AV_LOG_ERROR,
"mjpeg_decode_dc: bad vlc: %d\n", dc_index);
-return 0xf;
+return AVERROR_INVALIDDATA;
}
-if (code)
-return get_xbits(&s->gb, code);
-else
-return 0;
+*val = code ? get_xbits(&s->gb, code) : 0;
+return 0;
}
/* decode block and dequantize */
@@ -839,10 +837,10 @@ static int decode_block(MJpegDecodeContext *s, i
[FFmpeg-devel] [PATCH] avcodec/Makefile: Add adpcm_vima->adpcm.o dependency (PR #20498)
PR #20498 opened by mkver URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20498 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20498.patch Forgotten in 9141fe9653dc078d81bff8308ffdd2aaaf35495c. Signed-off-by: Andreas Rheinhardt >From 4c9071d0f1cec2b5c9451919701c7780a14c0eb8 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Fri, 12 Sep 2025 04:40:46 +0200 Subject: [PATCH] avcodec/Makefile: Add adpcm_vima->adpcm.o dependency Forgotten in 9141fe9653dc078d81bff8308ffdd2aaaf35495c. Signed-off-by: Andreas Rheinhardt --- libavcodec/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index ac143f4103..a321cda3a5 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1012,7 +1012,7 @@ OBJS-$(CONFIG_ADPCM_SWF_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_SWF_ENCODER) += adpcmenc.o adpcm_data.o OBJS-$(CONFIG_ADPCM_THP_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_THP_LE_DECODER) += adpcm.o adpcm_data.o -OBJS-$(CONFIG_ADPCM_VIMA_DECODER) += vima.o adpcm_data.o +OBJS-$(CONFIG_ADPCM_VIMA_DECODER) += vima.o adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_XA_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_XMD_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_YAMAHA_DECODER) += adpcm.o adpcm_data.o -- 2.49.1 ___ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] vf_blend (PR #20634)
PR #20634 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20634
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20634.patch
>From f2717889b4bff014ad8d00a98dc94761ed56c325 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Wed, 1 Oct 2025 07:56:49 +0200
Subject: [PATCH 1/2] avfilter/blend_modes: Use stride in bytes
The blend functions currently convert strides from bytes to elements
of the type by using the stride /= sizeof(pixel) idiom. Yet this has
several drawbacks:
1. It invokes undefined behavior that happens to work when stride is
negative: size_t is typically the unsigned type of ptrdiff_t and
therefore the division will be performed as size_t, i.e. use logical
right shifts, making stride very big when sizeof(pixel) is > 1. This
works, because pointer to pixel for accesses entails an implicit
factor of sizeof(pixel) so that everything is correct modulo SIZE_MAX.
Yet this is UB and UBSan complains about it.
2. It makes the compiler emit actual shifts/ands to discard the low bits
shifted away.
3. There may be systems where alignof(uint16_t) or alignof(float) is
strictly smaller than their sizeof, so that the stride (in bytes) is
not guaranteed to be multiple of these sizeofs. In this case, dividing
by sizeof(pixel) is simply wrong.
Signed-off-by: Andreas Rheinhardt
---
libavfilter/blend_modes.c | 16 ++--
libavfilter/vf_blend_init.h | 16 ++--
2 files changed, 12 insertions(+), 20 deletions(-)
diff --git a/libavfilter/blend_modes.c b/libavfilter/blend_modes.c
index 9b1e78b146..35e365996c 100644
--- a/libavfilter/blend_modes.c
+++ b/libavfilter/blend_modes.c
@@ -92,22 +92,18 @@ static void fn0(NAME)(const uint8_t *_top, ptrdiff_t
top_linesize, \
ptrdiff_t width, ptrdiff_t height, \
FilterParams *param, SliceParams *sliceparam)\
{
\
-const PIXEL *top = (const PIXEL *)_top;
\
-const PIXEL *bottom = (const PIXEL *)_bottom;
\
-PIXEL *dst = (PIXEL *)_dst;
\
const float opacity = param->opacity;
\
\
-dst_linesize /= sizeof(PIXEL);
\
-top_linesize /= sizeof(PIXEL);
\
-bottom_linesize /= sizeof(PIXEL);
\
-
\
for (int i = 0; i < height; i++) {
\
+const PIXEL *top = (const PIXEL *)_top;
\
+const PIXEL *bottom = (const PIXEL *)_bottom;
\
+PIXEL *dst = (PIXEL *)_dst;
\
for (int j = 0; j < width; j++) {
\
dst[j] = top[j] + ((EXPR)-top[j]) * opacity;
\
}
\
-dst += dst_linesize;
\
-top += top_linesize;
\
-bottom += bottom_linesize;
\
+_dst+= dst_linesize;
\
+_top+= top_linesize;
\
+_bottom += bottom_linesize;
\
}
\
}
diff --git a/libavfilter/vf_blend_init.h b/libavfilter/vf_blend_init.h
index 98d440fe67..7f66796e3e 100644
--- a/libavfilter/vf_blend_init.h
+++ b/libavfilter/vf_blend_init.h
@@ -82,22 +82,18 @@ static void blend_normal_##name(const uint8_t *_top,
ptrdiff_t top_linesize,
ptrdiff_t width, ptrdiff_t height,
\
FilterParams *param, SliceParams *sliceparam)
\
{
\
-const type *top = (const type*)_top;
\
-const type *bottom = (const type*)_bottom;
\
-type *dst = (type*)_dst;
\
const float opacity = param->opacity;
\
\
-dst_linesize /= sizeof(type);
[FFmpeg-devel] [PATCH] avcodec/x86/fpel: Port ff_put_pixels8_mmx() to SSE2 (PR #20706)
PR #20706 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20706
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20706.patch
This has the advantage of not violating the ABI by using
MMX registers without issuing emms; it e.g. allows
to remove an emms_c from bink.c.
This commit uses GP registers on Unix64 (there are not
enough volatile registers to do likewise on Win64) which
reduces codesize and is faster on some CPUs.
>From dee82cd1a40c7ce05bfdc9a35ab2dcd453b60f26 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Tue, 14 Oct 2025 15:06:13 +0200
Subject: [PATCH] avcodec/x86/fpel: Port ff_put_pixels8_mmx() to SSE2
This has the advantage of not violating the ABI by using
MMX registers without issuing emms; it e.g. allows
to remove an emms_c from bink.c.
This commit uses GP registers on Unix64 (there are not
enough volatile registers to do likewise on Win64) which
reduces codesize and is faster on some CPUs.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/bink.c | 2 --
libavcodec/x86/cavsdsp.c | 11 +--
libavcodec/x86/fpel.asm | 22 --
libavcodec/x86/fpel.h | 8
libavcodec/x86/hpeldsp_init.c | 14 +++---
libavcodec/x86/qpeldsp_init.c | 4 ++--
libavcodec/x86/vc1dsp_init.c | 4 ++--
7 files changed, 28 insertions(+), 37 deletions(-)
diff --git a/libavcodec/bink.c b/libavcodec/bink.c
index ef8e974589..e5300be000 100644
--- a/libavcodec/bink.c
+++ b/libavcodec/bink.c
@@ -21,7 +21,6 @@
*/
#include "libavutil/attributes.h"
-#include "libavutil/emms.h"
#include "libavutil/imgutils.h"
#include "libavutil/mem.h"
#include "libavutil/mem_internal.h"
@@ -1297,7 +1296,6 @@ static int decode_frame(AVCodecContext *avctx, AVFrame
*frame,
if (get_bits_count(&gb) >= bits_count)
break;
}
-emms_c();
if (c->version > 'b') {
if ((ret = av_frame_replace(c->last, frame)) < 0)
diff --git a/libavcodec/x86/cavsdsp.c b/libavcodec/x86/cavsdsp.c
index d14b472d54..e333bbee49 100644
--- a/libavcodec/x86/cavsdsp.c
+++ b/libavcodec/x86/cavsdsp.c
@@ -46,13 +46,6 @@ static void cavs_idct8_add_sse2(uint8_t *dst, int16_t
*block, ptrdiff_t stride)
#endif /* HAVE_SSE2_EXTERNAL */
-static av_cold void cavsdsp_init_mmx(CAVSDSPContext *c)
-{
-#if HAVE_MMX_EXTERNAL
-c->put_cavs_qpel_pixels_tab[1][0] = ff_put_pixels8x8_mmx;
-#endif /* HAVE_MMX_EXTERNAL */
-}
-
#if HAVE_SSE2_EXTERNAL
#define DEF_QPEL(OPNAME) \
void ff_ ## OPNAME ## _cavs_qpel8_mc20_sse2(uint8_t *dst, const uint8_t
*src, ptrdiff_t stride); \
@@ -98,9 +91,6 @@ av_cold void ff_cavsdsp_init_x86(CAVSDSPContext *c)
{
av_unused int cpu_flags = av_get_cpu_flags();
-if (X86_MMX(cpu_flags))
-cavsdsp_init_mmx(c);
-
#if HAVE_MMX_EXTERNAL
if (EXTERNAL_MMXEXT(cpu_flags)) {
c->avg_cavs_qpel_pixels_tab[1][0] = ff_avg_pixels8x8_mmxext;
@@ -113,6 +103,7 @@ av_cold void ff_cavsdsp_init_x86(CAVSDSPContext *c)
c->put_cavs_qpel_pixels_tab[0][ 4] = put_cavs_qpel16_mc01_sse2;
c->put_cavs_qpel_pixels_tab[0][ 8] = put_cavs_qpel16_mc02_sse2;
c->put_cavs_qpel_pixels_tab[0][12] = put_cavs_qpel16_mc03_sse2;
+c->put_cavs_qpel_pixels_tab[1][ 0] = ff_put_pixels8x8_sse2;
c->put_cavs_qpel_pixels_tab[1][ 2] = ff_put_cavs_qpel8_mc20_sse2;
c->put_cavs_qpel_pixels_tab[1][ 4] = put_cavs_qpel8_mc01_sse2;
c->put_cavs_qpel_pixels_tab[1][ 8] = ff_put_cavs_qpel8_mc02_sse2;
diff --git a/libavcodec/x86/fpel.asm b/libavcodec/x86/fpel.asm
index 68a05310f2..e4becca5fb 100644
--- a/libavcodec/x86/fpel.asm
+++ b/libavcodec/x86/fpel.asm
@@ -27,7 +27,7 @@ SECTION .text
; void ff_put/avg_pixels(uint8_t *block, const uint8_t *pixels,
;ptrdiff_t line_size, int h)
-%macro OP_PIXELS 2
+%macro OP_PIXELS 2-3 0
%if %2 == mmsize/2
%define LOAD movh
%define SAVE movh
@@ -35,14 +35,25 @@ SECTION .text
%define LOAD movu
%define SAVE mova
%endif
-cglobal %1_pixels%2x%2, 3,5,4
+cglobal %1_pixels%2x%2, 3,5+4*%3,%3 ? 4 : 0
mov r3d, %2
jmp %1_pixels%2_after_prologue
-cglobal %1_pixels%2, 4,5,4
+cglobal %1_pixels%2, 4,5+4*%3,%3 ? 4 : 0
%1_pixels%2_after_prologue:
lea r4, [r2*3]
.loop:
+%if %3
+; Use GPRs on UNIX64 for put8, but not on Win64 due to a lack of volatile GPRs
+mov r5q, [r1]
+mov r6q, [r1+r2]
+mov r7q, [r1+r2*2]
+mov r8q, [r1+r4]
+mov[r0], r5q
+mov [r0+r2], r6q
+mov [r0+r2*2], r7q
+mov [r0+r4], r8q
+%else
LOAD m0, [r1]
LOAD m1, [r1+r2]
LOAD m2, [r1+r2*2]
@@ -57,6 +68,7 @@ cglobal %1_pixels%2, 4,5,4
SAVE[r0+r2], m1
SAVE [r0+r2*2], m2
SAVE[r0+r4], m3
+%endif
sub r3d, 4
lea r1, [r1+r2*4]
lea r0, [r0+r2*4]
@@ -64,12 +76,10 @@ cglobal %1_pixels%2, 4,5,4
RET
%endmacro
-INIT_MMX mmx
-OP_PIXELS
[FFmpeg-devel] [PATCH] h264qpel (PR #20645)
PR #20645 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20645
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20645.patch
>From 549383606f01ac1cf481c0b69b923ed44fcb99d4 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Sat, 4 Oct 2025 07:29:35 +0200
Subject: [PATCH 1/8] avcodec/x86/h264_qpel_8bit: Improve register allocation
None of the other registers need to be preserved at this time,
so six XMM registers are always enough. Forgotten in
fa9ea5113b48904daef9df6a282bd9c04c32258d.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/x86/h264_qpel_8bit.asm | 6 +-
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/libavcodec/x86/h264_qpel_8bit.asm
b/libavcodec/x86/h264_qpel_8bit.asm
index ede4f382e1..bbf591664a 100644
--- a/libavcodec/x86/h264_qpel_8bit.asm
+++ b/libavcodec/x86/h264_qpel_8bit.asm
@@ -634,11 +634,7 @@ QPEL8OR16_HV2_LOWPASS_OP put
QPEL8OR16_HV2_LOWPASS_OP avg
%macro QPEL8OR16_HV2_LOWPASS_OP_XMM 1
-%ifidn %1, avg
-cglobal %1_h264_qpel8_hv2_lowpass, 3,4,7 ; dst, tmp, dstStride
-%else
cglobal %1_h264_qpel8_hv2_lowpass, 3,4,6 ; dst, tmp, dstStride
-%endif
mov r3d, 8
.loop:
mova m1, [r1+16]
@@ -663,7 +659,7 @@ cglobal %1_h264_qpel8_hv2_lowpass, 3,4,6 ; dst, tmp,
dstStride
paddw m0, m2
psraw m0, 6
packuswb m0, m0
-op_%1hm0, [r0], m6
+op_%1hm0, [r0], m5
add r1, 48
add r0, r2
dec r3d
--
2.49.1
>From 48460a769cf736dac6237bd4116eafb1cce51d2a Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Sat, 4 Oct 2025 08:43:21 +0200
Subject: [PATCH 2/8] avcodec/h264qpel: Move Snow-only code to snow.c
Blocksize 2 is Snow-only, so move all the code pertaining
to it to snow.c. Also make the put array in H264QpelContext
smaller -- it only needs three sets of 16 function pointers.
This continues 6eb8bc42176f73c1d7c2e9f4bc1ab988f7149de5
and b0c91c2fba82f98dfe7a70f2591ec7a2126820c0.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/h264qpel.c | 60 ---
libavcodec/h264qpel.h | 2 +-
libavcodec/h264qpel_template.c | 94 ++---
libavcodec/pel_template.c | 2 +-
libavcodec/snow.c | 104 ++---
libavcodec/snow.h | 6 +-
tests/checkasm/h264qpel.c | 2 +-
7 files changed, 152 insertions(+), 118 deletions(-)
diff --git a/libavcodec/h264qpel.c b/libavcodec/h264qpel.c
index be80203c4b..0bc715c638 100644
--- a/libavcodec/h264qpel.c
+++ b/libavcodec/h264qpel.c
@@ -26,65 +26,6 @@
#define pixeltmp int16_t
#define BIT_DEPTH 8
#include "h264qpel_template.c"
-
-static void put_h264_qpel2_h_lowpass_8(uint8_t *dst, const uint8_t *restrict
src, int dstStride, int srcStride)
-{
-const int h = 2;
-for (int i = 0; i < h; ++i) {
-dst[0] = av_clip_uint8(((src[0]+src[1])*20 - (src[-1]+src[2])*5 +
(src[-2]+src[3]) + 16) >> 5);
-dst[1] = av_clip_uint8(((src[1]+src[2])*20 - (src[0 ]+src[3])*5 +
(src[-1]+src[4]) + 16) >> 5);
-dst += dstStride;
-src += srcStride;
-}
-}
-
-static void put_h264_qpel2_v_lowpass_8(uint8_t *dst, const uint8_t *restrict
src, int dstStride, int srcStride)
-{
-const int w = 2;
-for (int i = 0; i < w; ++i) {
-const int srcB = src[-2*srcStride];
-const int srcA = src[-1*srcStride];
-const int src0 = src[0 *srcStride];
-const int src1 = src[1 *srcStride];
-const int src2 = src[2 *srcStride];
-const int src3 = src[3 *srcStride];
-const int src4 = src[4 *srcStride];
-dst[0*dstStride] = av_clip_uint8(((src0+src1)*20 - (srcA+src2)*5 +
(srcB+src3) + 16) >> 5);
-dst[1*dstStride] = av_clip_uint8(((src1+src2)*20 - (src0+src3)*5 +
(srcA+src4) + 16) >> 5);
-dst++;
-src++;
-}
-}
-
-static void put_h264_qpel2_hv_lowpass_8(uint8_t *dst, pixeltmp *tmp, const
uint8_t *restrict src, int dstStride, int tmpStride, int srcStride)
-{
-const int h = 2;
-const int w = 2;
-src -= 2*srcStride;
-for (int i = 0; i < h + 5; ++i) {
-tmp[0] = (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]);
-tmp[1] = (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]);
-tmp += tmpStride;
-src += srcStride;
-}
-tmp -= tmpStride*(h+5-2);
-for (int i = 0; i < w; ++i) {
-const int tmpB = tmp[-2*tmpStride];
-const int tmpA = tmp[-1*tmpStride];
-const int tmp0 = tmp[0 *tmpStride];
-const int tmp1 = tmp[1 *tmpStride];
-const int tmp2 = tmp[2 *tmpStride];
-const int tmp3 = tmp[3 *tmpStride];
-const int tmp4 = tmp[4 *tmpStride];
-dst[0*dstStride] = av_clip_uint8(((tmp0+tmp1)*20 - (tmpA+tmp2)*5 +
(tmpB+tmp3) + 512) >> 10);
-dst[1*dstStride] = av_clip_uint8(((tmp1+tmp2)*20 - (tmp0+tmp3)*5 +
(tmpA+tmp4) + 512) >> 10);
-dst++;
-tmp++;
-}
-}
[FFmpeg-devel] [PATCH] avcodec/mjpegdec: Remove unnecessary reload (PR #20664)
PR #20664 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20664
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20664.patch
(In a lot of instances, the reloads inside GET_VLC are unnecessary. I will look
into removing them soon.)
>From 67edb1a5c31384de7bf3c160da8132fa933e92e9 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Wed, 8 Oct 2025 03:12:19 +0200
Subject: [PATCH] avcodec/mjpegdec: Remove unnecessary reload
Signed-off-by: Andreas Rheinhardt
---
libavcodec/mjpegdec.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 69bc003490..86dd50ce0c 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -853,10 +853,10 @@ static int decode_block(MJpegDecodeContext *s, int16_t
*block, int component,
i += ((unsigned)code) >> 4;
code &= 0xf;
+// GET_VLC updates the cache if parsing doesn't finish in the first
stage.
+// So we always have at least MIN_CACHE_BITS - 9 > 15 bits left here
+// and don't need to refill the cache.
if (code) {
-if (code > MIN_CACHE_BITS - 16)
-UPDATE_CACHE(re, &s->gb);
-
{
int cache = GET_CACHE(re, &s->gb);
int sign = (~cache) >> 31;
--
2.49.1
___
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] avcodec/x86/h263_loopfilter: Port loop filter to SSE2 (PR #20636)
PR #20636 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20636
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20636.patch
>From 0c2f259863bea7908422a5ae43ec380fce1f8135 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Wed, 1 Oct 2025 13:42:09 +0200
Subject: [PATCH 1/2] tests/checkasm/llviddsp: Use the same width for each
cpuflag
Otherwise the benchmark numbers would be incomparable nonsense.
Signed-off-by: Andreas Rheinhardt
---
tests/checkasm/llviddsp.c | 6 +-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/tests/checkasm/llviddsp.c b/tests/checkasm/llviddsp.c
index 9f8de65df4..0552e98106 100644
--- a/tests/checkasm/llviddsp.c
+++ b/tests/checkasm/llviddsp.c
@@ -195,9 +195,13 @@ static void check_add_gradient_pred(LLVidDSPContext *c,
int w) {
void checkasm_check_llviddsp(void)
{
LLVidDSPContext c;
-int width = 16 * av_clip(rnd(), 16, 128);
+static int saved_width = 0;
+int width = saved_width;
int accRnd = rnd() & 0xFF;
+if (!width)
+saved_width = width = 16 * av_clip(rnd(), 16, 128);
+
ff_llviddsp_init(&c);
check_add_bytes(&c, width);
--
2.49.1
>From 412776390c42ed6088752a314ec515792239055d Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Wed, 1 Oct 2025 10:46:39 +0200
Subject: [PATCH 2/2] avcodec/x86/h263_loopfilter: Port loop filter to SSE2
Old benchmarks:
h263dsp.h_loop_filter_c:41.2 ( 1.00x)
h263dsp.h_loop_filter_mmx: 39.5 ( 1.04x)
h263dsp.v_loop_filter_c:43.5 ( 1.00x)
h263dsp.v_loop_filter_mmx: 16.9 ( 2.57x)
New benchmarks:
h263dsp.h_loop_filter_c:41.6 ( 1.00x)
h263dsp.h_loop_filter_sse2: 28.2 ( 1.48x)
h263dsp.v_loop_filter_c:42.4 ( 1.00x)
h263dsp.v_loop_filter_sse2: 15.1 ( 2.81x)
Signed-off-by: Andreas Rheinhardt
---
libavcodec/x86/constants.c | 2 +-
libavcodec/x86/constants.h | 2 +-
libavcodec/x86/h263_loopfilter.asm | 167 -
libavcodec/x86/h263dsp_init.c | 10 +-
tests/checkasm/h263dsp.c | 2 +-
5 files changed, 78 insertions(+), 105 deletions(-)
diff --git a/libavcodec/x86/constants.c b/libavcodec/x86/constants.c
index c5f3c6428e..1e2f5990e4 100644
--- a/libavcodec/x86/constants.c
+++ b/libavcodec/x86/constants.c
@@ -75,7 +75,7 @@ DECLARE_ALIGNED(32, const ymm_reg, ff_pb_80) = {
0x8080808080808080ULL, 0x808
0x8080808080808080ULL,
0x8080808080808080ULL };
DECLARE_ALIGNED(32, const ymm_reg, ff_pb_FE) = { 0xFEFEFEFEFEFEFEFEULL,
0xFEFEFEFEFEFEFEFEULL,
0xFEFEFEFEFEFEFEFEULL,
0xFEFEFEFEFEFEFEFEULL };
-DECLARE_ALIGNED(8, const uint64_t, ff_pb_FC) = 0xFCFCFCFCFCFCFCFCULL;
+DECLARE_ALIGNED(16, const xmm_reg, ff_pb_FC) = { 0xFCFCFCFCFCFCFCFCULL,
0xFCFCFCFCFCFCFCFCULL };
DECLARE_ALIGNED(16, const xmm_reg, ff_ps_neg) = { 0x80008000ULL,
0x80008000ULL };
diff --git a/libavcodec/x86/constants.h b/libavcodec/x86/constants.h
index 4a55adb5b3..7d0bd975b9 100644
--- a/libavcodec/x86/constants.h
+++ b/libavcodec/x86/constants.h
@@ -56,8 +56,8 @@ extern const ymm_reg ff_pb_1;
extern const ymm_reg ff_pb_2;
extern const ymm_reg ff_pb_3;
extern const ymm_reg ff_pb_80;
+extern const xmm_reg ff_pb_FC;
extern const ymm_reg ff_pb_FE;
-extern const uint64_t ff_pb_FC;
extern const xmm_reg ff_ps_neg;
diff --git a/libavcodec/x86/h263_loopfilter.asm
b/libavcodec/x86/h263_loopfilter.asm
index 77c8cf154d..ebe76f01af 100644
--- a/libavcodec/x86/h263_loopfilter.asm
+++ b/libavcodec/x86/h263_loopfilter.asm
@@ -1,5 +1,5 @@
;**
-;* MMX-optimized H.263 loop filter
+;* SSE2-optimized H.263 loop filter
;* Copyright (c) 2003-2013 Michael Niedermayer
;* Copyright (c) 2013 Daniel Kang
;*
@@ -22,7 +22,6 @@
%include "libavutil/x86/x86util.asm"
-SECTION_RODATA
cextern pb_FC
cextern h263_loop_filter_strength
@@ -30,60 +29,45 @@ SECTION .text
%macro H263_LOOP_FILTER 5
pxor m7, m7
-mova m0, [%1]
-mova m1, [%1]
-mova m2, [%4]
-mova m3, [%4]
+movq m0, [%1]
+movq m6, [%4]
+mova m5, m0
punpcklbwm0, m7
-punpckhbwm1, m7
+punpcklbwm6, m7
+psubwm0, m6
+movq m2, [%2]
+movq m1, [%3]
+mova m3, m2
+mova m4, m1
punpcklbwm2, m7
-punpckhbwm3, m7
-psubwm0, m2
-psubwm1, m3
-mova m2, [%2]
-mova m3, [%2]
-mova m4, [%3]
-mova m5, [%3]
-punpcklbwm2, m7
-punpckhbwm3, m7
-punpcklbwm4, m7
-punp
[FFmpeg-devel] [PATCH] avcodec/pngenc: Mark unreachable default switch cases as such (PR #20641)
PR #20641 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20641
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20641.patch
>From 2eb23623c006631e4201e57360a70f2d30a72da9 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Thu, 2 Oct 2025 21:07:48 +0200
Subject: [PATCH] avcodec/pngenc: Mark unreachable default switch cases as such
Signed-off-by: Andreas Rheinhardt
---
libavcodec/pngenc.c | 7 ++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c
index 5baad9aad5..8e4f42125e 100644
--- a/libavcodec/pngenc.c
+++ b/libavcodec/pngenc.c
@@ -195,6 +195,8 @@ static void png_filter_row(PNGEncContext *c, uint8_t *dst,
int filter_type,
dst[i] = src[i] - top[i];
sub_png_paeth_prediction(dst + i, src + i, top + i, size - i, bpp);
break;
+default:
+av_unreachable("PNG_FILTER_VALUE_MIXED can't happen here and all
others are covered");
}
}
@@ -816,6 +818,9 @@ static int apng_do_inverse_blend(AVFrame *output, const
AVFrame *input,
palette[*background] >> 24 == 0)
break;
return -1;
+
+default:
+av_unreachable("Pixfmt has been checked before");
}
memmove(output_data, foreground, bpp);
@@ -1193,7 +1198,7 @@ static av_cold int png_enc_init(AVCodecContext *avctx)
s->color_type = PNG_COLOR_TYPE_PALETTE;
break;
default:
-return -1;
+av_unreachable("Already checked via CODEC_PIXFMTS");
}
s->bits_per_pixel = ff_png_get_nb_channels(s->color_type) * s->bit_depth;
--
2.49.1
___
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] avfilter/x86/vf_{pullup,spp}: Port functions to SSE2, SSSE3 (PR #20696)
PR #20696 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20696
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20696.patch
From 1b3235d4163e0bf31d017c2df12d3198387f4798 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Sun, 12 Oct 2025 17:19:26 +0200
Subject: [PATCH 1/2] avfilter/x86/vf_spp: Port store_slice to SSE2
This allows to remove an emms_c from the filter. It also gives
25% speedup here (when timing the calls to store_slice using
START/STOP_TIMER).
Signed-off-by: Andreas Rheinhardt
---
libavfilter/vf_spp.c | 2 --
libavfilter/x86/vf_spp.c | 49
2 files changed, 24 insertions(+), 27 deletions(-)
diff --git a/libavfilter/vf_spp.c b/libavfilter/vf_spp.c
index 5c5b98f8db..20c9fd4340 100644
--- a/libavfilter/vf_spp.c
+++ b/libavfilter/vf_spp.c
@@ -31,7 +31,6 @@
* ported by Clément Bœsch for FFmpeg.
*/
-#include "libavutil/emms.h"
#include "libavutil/imgutils.h"
#include "libavutil/mem.h"
#include "libavutil/mem_internal.h"
@@ -425,7 +424,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
filter(s, out->data[1], in->data[1], out->linesize[1],
in->linesize[1], cw,ch,qp_table, qp_stride, 0, depth);
filter(s, out->data[2], in->data[2], out->linesize[2],
in->linesize[2], cw,ch,qp_table, qp_stride, 0, depth);
}
-emms_c();
}
}
diff --git a/libavfilter/x86/vf_spp.c b/libavfilter/x86/vf_spp.c
index f8e5727bfc..48c3d25d7c 100644
--- a/libavfilter/x86/vf_spp.c
+++ b/libavfilter/x86/vf_spp.c
@@ -18,16 +18,20 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#include
+#include "config.h"
#include "libavutil/attributes.h"
#include "libavutil/cpu.h"
+#include "libavutil/x86/asm.h"
+#include "libavutil/x86/cpu.h"
#include "libavfilter/vf_spp.h"
-#if HAVE_MMX_INLINE
-static void store_slice_mmx(uint8_t *dst, const int16_t *src,
-int dst_stride, int src_stride,
-int width, int height, int log2_scale,
-const uint8_t dither[8][8])
+#if HAVE_SSE2_INLINE
+static void store_slice_sse2(uint8_t *dst, const int16_t *src,
+ int dst_stride, int src_stride,
+ int width, int height, int log2_scale,
+ const uint8_t dither[8][8])
{
int y;
@@ -35,30 +39,25 @@ static void store_slice_mmx(uint8_t *dst, const int16_t
*src,
uint8_t *dst1 = dst;
const int16_t *src1 = src;
__asm__ volatile(
-"movq (%3), %%mm3 \n"
-"movq (%3), %%mm4 \n"
-"movd %4, %%mm2 \n"
-"pxor %%mm0, %%mm0 \n"
-"punpcklbw %%mm0, %%mm3 \n"
-"punpckhbw %%mm0, %%mm4 \n"
-"psraw %%mm2, %%mm3 \n"
-"psraw %%mm2, %%mm4 \n"
-"movd %5, %%mm2 \n"
+"movq (%3), %%xmm1 \n"
+"movd %4, %%xmm2 \n"
+"pxor %%xmm0, %%xmm0 \n"
+"punpcklbw %%xmm0, %%xmm1 \n"
+"psraw %%xmm2, %%xmm1 \n"
+"movd %5, %%xmm2 \n"
"1: \n"
-"movq (%0), %%mm0 \n"
-"movq 8(%0), %%mm1 \n"
-"paddw %%mm3, %%mm0 \n"
-"paddw %%mm4, %%mm1 \n"
-"psraw %%mm2, %%mm0 \n"
-"psraw %%mm2, %%mm1 \n"
-"packuswb %%mm1, %%mm0 \n"
-"movq %%mm0, (%1) \n"
+"movdqa (%0), %%xmm0 \n"
+"paddw %%xmm1, %%xmm0 \n"
+"psraw %%xmm2, %%xmm0 \n"
+"packuswb %%xmm0, %%xmm0 \n"
+"movq %%xmm0, (%1)\n"
"add $16, %0\n"
"add $8, %1 \n"
"cmp %2, %1 \n"
" jb 1b \n"
: "+r" (src1), "+r"(dst1)
: "r"(dst + width), "r"(dither[y]), "g"(log2_scale), "g"(MAX_LEVEL
- log2_scale)
+XMM_CLOBBERS_ONLY("%xmm0", "%xmm1", "%xmm2")
);
src += src_stride;
dst += dst_stride;
@@ -69,11 +68,11 @@ static void store_slice_mmx(uint8_t *dst, const int16_t
*src,
av_cold void ff_spp_init_x86(SPPContext *s)
{
-#if HAVE_MMX_INLINE
+#if HAVE_SSE2_INLINE
int cpu_flags = av_get_cpu_flags();
-if (cpu_flags & AV_CPU_FLAG_MMX) {
-s->store_slice = store_slice_mmx;
+if (INLINE_SSE2(cpu_flags)) {
+s->store_slice = store_slice_sse2;
}
#endif
}
--
2.49.1
From d9571bb9b2e49042a7d2fb0bd18c390b6dc63f57 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Sun, 12 Oct 2025 19:28:35 +0200
Subject: [PATCH 2/2] avfilter/x86/vf_pullup: Port pullup fun
[FFmpeg-devel] [PATCH] Port cavs qpeldsp from MMX to SSE2 (PR #20648)
PR #20648 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20648
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20648.patch
Also uncovered a bug in the MMX version that has gone unnoticed since it was
added in 2006. Apparently no one uses cavs.
>From 099834932c49192a9441b51e485aaa355514c520 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Sun, 5 Oct 2025 08:16:01 +0200
Subject: [PATCH 1/7] avcodec/cavs: Remove unused parameter
Signed-off-by: Andreas Rheinhardt
---
libavcodec/cavs.c | 18 +-
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/libavcodec/cavs.c b/libavcodec/cavs.c
index 172cc5cc7a..4db6892452 100644
--- a/libavcodec/cavs.c
+++ b/libavcodec/cavs.c
@@ -387,7 +387,7 @@ void ff_cavs_modify_mb_i(AVSContext *h, int *pred_mode_uv)
/
static inline void mc_dir_part(AVSContext *h, AVFrame *pic, int chroma_height,
- int delta, int list, uint8_t *dest_y,
+ int list, uint8_t *dest_y,
uint8_t *dest_cb, uint8_t *dest_cr,
int src_x_offset, int src_y_offset,
qpel_mc_func *qpix_op,
@@ -452,7 +452,7 @@ static inline void mc_dir_part(AVSContext *h, AVFrame *pic,
int chroma_height,
chroma_op(dest_cr, src_cr, h->c_stride, chroma_height, mx & 7, my & 7);
}
-static inline void mc_part_std(AVSContext *h, int chroma_height, int delta,
+static inline void mc_part_std(AVSContext *h, int chroma_height,
uint8_t *dest_y,
uint8_t *dest_cb,
uint8_t *dest_cr,
@@ -474,7 +474,7 @@ static inline void mc_part_std(AVSContext *h, int
chroma_height, int delta,
if (mv->ref >= 0) {
AVFrame *ref = h->DPB[mv->ref].f;
-mc_dir_part(h, ref, chroma_height, delta, 0,
+mc_dir_part(h, ref, chroma_height, 0,
dest_y, dest_cb, dest_cr, x_offset, y_offset,
qpix_op, chroma_op, mv);
@@ -484,7 +484,7 @@ static inline void mc_part_std(AVSContext *h, int
chroma_height, int delta,
if ((mv + MV_BWD_OFFS)->ref >= 0) {
AVFrame *ref = h->DPB[0].f;
-mc_dir_part(h, ref, chroma_height, delta, 1,
+mc_dir_part(h, ref, chroma_height, 1,
dest_y, dest_cb, dest_cr, x_offset, y_offset,
qpix_op, chroma_op, mv + MV_BWD_OFFS);
}
@@ -493,32 +493,32 @@ static inline void mc_part_std(AVSContext *h, int
chroma_height, int delta,
void ff_cavs_inter(AVSContext *h, enum cavs_mb mb_type)
{
if (ff_cavs_partition_flags[mb_type] == 0) { // 16x16
-mc_part_std(h, 8, 0, h->cy, h->cu, h->cv, 0, 0,
+mc_part_std(h, 8, h->cy, h->cu, h->cv, 0, 0,
h->cdsp.put_cavs_qpel_pixels_tab[0],
h->h264chroma.put_h264_chroma_pixels_tab[0],
h->cdsp.avg_cavs_qpel_pixels_tab[0],
h->h264chroma.avg_h264_chroma_pixels_tab[0],
&h->mv[MV_FWD_X0]);
} else {
-mc_part_std(h, 4, 0, h->cy, h->cu, h->cv, 0, 0,
+mc_part_std(h, 4, h->cy, h->cu, h->cv, 0, 0,
h->cdsp.put_cavs_qpel_pixels_tab[1],
h->h264chroma.put_h264_chroma_pixels_tab[1],
h->cdsp.avg_cavs_qpel_pixels_tab[1],
h->h264chroma.avg_h264_chroma_pixels_tab[1],
&h->mv[MV_FWD_X0]);
-mc_part_std(h, 4, 0, h->cy, h->cu, h->cv, 4, 0,
+mc_part_std(h, 4, h->cy, h->cu, h->cv, 4, 0,
h->cdsp.put_cavs_qpel_pixels_tab[1],
h->h264chroma.put_h264_chroma_pixels_tab[1],
h->cdsp.avg_cavs_qpel_pixels_tab[1],
h->h264chroma.avg_h264_chroma_pixels_tab[1],
&h->mv[MV_FWD_X1]);
-mc_part_std(h, 4, 0, h->cy, h->cu, h->cv, 0, 4,
+mc_part_std(h, 4, h->cy, h->cu, h->cv, 0, 4,
h->cdsp.put_cavs_qpel_pixels_tab[1],
h->h264chroma.put_h264_chroma_pixels_tab[1],
h->cdsp.avg_cavs_qpel_pixels_tab[1],
h->h264chroma.avg_h264_chroma_pixels_tab[1],
&h->mv[MV_FWD_X2]);
-mc_part_std(h, 4, 0, h->cy, h->cu, h->cv, 4, 4,
+mc_part_std(h, 4, h->cy, h->cu, h->cv, 4, 4,
h->cdsp.put_cavs_qpel_pixels_tab[1],
h->h264chroma.put_h264_chroma_pixels_tab[1],
h->cdsp.avg_cavs_qpel_pixels_tab[1],
--
2.49.1
>From 53c9a63f9998301a69b7b446950f9cb897c95b78 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Sun, 5 Oct 2025 12:35:17 +0200
Subject: [PATCH 2/7] avcodec/x86/cavsdsp: Fix vertical qpel motion
compensation
The prediction involves terms of the form
(-1 * s0 - 2 * s1 + 96 * s2 + 42 * s3
[FFmpeg-devel] [PATCH] avcodec/liblc3enc: Avoid allocating buffer to send a zero frame (PR #20633)
PR #20633 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20633
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20633.patch
liblc3 supports arbitrary strides, so one can simply use a stride
of zero to make it read the same zero value again and again.
>From 3bf38a3570673776249787228325a8c15bc020c6 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Tue, 30 Sep 2025 18:53:08 +0200
Subject: [PATCH] avcodec/liblc3enc: Avoid allocating buffer to send a zero
frame
liblc3 supports arbitrary strides, so one can simply use a stride
of zero to make it read the same zero value again and again.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/liblc3enc.c | 12 +++-
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/libavcodec/liblc3enc.c b/libavcodec/liblc3enc.c
index 66007a90f3..72c117b993 100644
--- a/libavcodec/liblc3enc.c
+++ b/libavcodec/liblc3enc.c
@@ -137,7 +137,6 @@ static int liblc3_encode(AVCodecContext *avctx, AVPacket
*pkt,
LibLC3EncContext *liblc3 = avctx->priv_data;
int block_bytes = liblc3->block_bytes;
int channels = avctx->ch_layout.nb_channels;
-void *zero_frame = NULL;
uint8_t *data_ptr;
int ret;
@@ -152,25 +151,20 @@ static int liblc3_encode(AVCodecContext *avctx, AVPacket
*pkt,
return 0;
liblc3->remaining_samples = 0;
-zero_frame = av_mallocz(avctx->frame_size * sizeof(float));
-if (!zero_frame)
-return AVERROR(ENOMEM);
}
data_ptr = pkt->data;
for (int ch = 0; ch < channels; ch++) {
-const float *pcm = zero_frame ? zero_frame : frame->data[ch];
+const float *pcm = frame ? (const float*)frame->data[ch] : (const
float[]){ 0 };
+int stride = !!frame; // use a stride of zero to send a zero frame
int nbytes = block_bytes / channels + (ch < block_bytes % channels);
lc3_encode(liblc3->encoder[ch],
- LC3_PCM_FORMAT_FLOAT, pcm, 1, nbytes, data_ptr);
+ LC3_PCM_FORMAT_FLOAT, pcm, stride, nbytes, data_ptr);
data_ptr += nbytes;
}
-if (zero_frame)
-av_free(zero_frame);
-
*got_packet_ptr = 1;
return 0;
--
2.49.1
___
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] avcodec/x86/qpeldsp_init: Fix compilation without external assembly (PR #20616)
PR #20616 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20616
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20616.patch
Will apply this soon.
>From 096958b6a0851477a26c8ba08cb9696e68088822 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Fri, 26 Sep 2025 16:17:45 +0200
Subject: [PATCH] avcodec/x86/qpeldsp_init: Fix compilation without external
assembly
Broken in 2cf9e733c6a00423a0967f23341d9f09e3c8.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/x86/qpeldsp_init.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/libavcodec/x86/qpeldsp_init.c b/libavcodec/x86/qpeldsp_init.c
index 097cda0106..2448adde88 100644
--- a/libavcodec/x86/qpeldsp_init.c
+++ b/libavcodec/x86/qpeldsp_init.c
@@ -537,9 +537,11 @@ av_cold void ff_qpeldsp_init_x86(QpelDSPContext *c)
SET_QPEL_FUNCS(put_no_rnd_qpel, 1, 8, mmxext, );
#endif /* HAVE_MMXEXT_EXTERNAL */
}
+#if HAVE_SSE2_EXTERNAL
if (EXTERNAL_SSE2(cpu_flags)) {
c->put_no_rnd_qpel_pixels_tab[0][0] =
c->put_qpel_pixels_tab[0][0] = put_qpel16_mc00_sse2;
c->avg_qpel_pixels_tab[0][0] = avg_qpel16_mc00_sse2;
}
+#endif
}
--
2.49.1
___
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] Port VP3 loopfilters to SSE2 (PR #20686)
PR #20686 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20686
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20686.patch
Also make them bitexact (they currently are not for extreme edge cases that
don't happen in practice).
>From 98f43a540c2957624cca4024f4661b0a87906597 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Fri, 10 Oct 2025 14:58:58 +0200
Subject: [PATCH 1/4] tests/checkasm: Add VP3 loop filter test
Signed-off-by: Andreas Rheinhardt
---
tests/checkasm/Makefile | 1 +
tests/checkasm/checkasm.c | 3 +
tests/checkasm/checkasm.h | 1 +
tests/checkasm/vp3dsp.c | 117 ++
tests/fate/checkasm.mak | 1 +
5 files changed, 123 insertions(+)
create mode 100644 tests/checkasm/vp3dsp.c
diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
index 7a9566eb8a..e47070d90f 100644
--- a/tests/checkasm/Makefile
+++ b/tests/checkasm/Makefile
@@ -22,6 +22,7 @@ AVCODECOBJS-$(CONFIG_ME_CMP)+= motion.o
AVCODECOBJS-$(CONFIG_MPEGVIDEOENCDSP) += mpegvideoencdsp.o
AVCODECOBJS-$(CONFIG_QPELDSP) += qpeldsp.o
AVCODECOBJS-$(CONFIG_VC1DSP)+= vc1dsp.o
+AVCODECOBJS-$(CONFIG_VP3DSP)+= vp3dsp.o
AVCODECOBJS-$(CONFIG_VP8DSP)+= vp8dsp.o
AVCODECOBJS-$(CONFIG_VIDEODSP) += videodsp.o
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index 83aa26624d..4469e043f5 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -251,6 +251,9 @@ static const struct {
#if CONFIG_VC1DSP
{ "vc1dsp", checkasm_check_vc1dsp },
#endif
+#if CONFIG_VP3DSP
+{ "vp3dsp", checkasm_check_vp3dsp },
+#endif
#if CONFIG_VP8DSP
{ "vp8dsp", checkasm_check_vp8dsp },
#endif
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index bd7a896447..e1ccd4011b 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -152,6 +152,7 @@ void checkasm_check_vf_gblur(void);
void checkasm_check_vf_hflip(void);
void checkasm_check_vf_threshold(void);
void checkasm_check_vf_sobel(void);
+void checkasm_check_vp3dsp(void);
void checkasm_check_vp8dsp(void);
void checkasm_check_vp9dsp(void);
void checkasm_check_videodsp(void);
diff --git a/tests/checkasm/vp3dsp.c b/tests/checkasm/vp3dsp.c
new file mode 100644
index 00..03466e7425
--- /dev/null
+++ b/tests/checkasm/vp3dsp.c
@@ -0,0 +1,117 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include
+#include
+
+#include "checkasm.h"
+#include "libavutil/intreadwrite.h"
+#include "libavutil/macros.h"
+#include "libavutil/mem_internal.h"
+#include "libavcodec/avcodec.h"
+#include "libavcodec/vp3dsp.h"
+
+enum {
+MAX_STRIDE = 64,
+MIN_STRIDE = 8,
+/// Horizontal tests operate on 4x8 blocks
+HORIZONTAL_BUF_SIZE = ((8 /* lines */ - 1) * MAX_STRIDE + 4 /* width */ +
7 /* misalignment */),
+/// Vertical tests operate on 8x4 blocks
+VERTICAL_BUF_SIZE = ((4 /* lines */ - 1) * MAX_STRIDE + 8 /* width */ +
7 /* misalignment */),
+};
+
+#define randomize_buffers(buf0, buf1, size)\
+do { \
+static_assert(sizeof(buf0[0]) == 1 && sizeof(buf1[0]) == 1, \
+ "Pointer arithmetic needs to be adapted"); \
+for (size_t k = 0; k < (size & ~3); k += 4) { \
+uint32_t r = rnd();\
+AV_WN32A(buf0 + k, r); \
+AV_WN32A(buf1 + k, r); \
+} \
+for (size_t k = size & ~3; k < size; ++k) \
+buf0[k] = buf1[k] = rnd(); \
+} while (0)
+
+
+static void vp3_check_loop_filter(void)
+{
+DECLARE_ALIGNED(8, uint8_t, hor_buf0)[HORIZONTAL_BUF_SIZE];
+DECLARE_ALIGNED(8, uint8_t, hor_buf1)[HORIZONTAL_BUF_SIZE];
+DECLARE_ALIGNED(8, uint8_t, ver_buf0)[VERTICAL_BUF_SIZE];
+DECLARE_ALIGNED(8, uint8_t, ver_buf1)[VERTICAL_BUF_SIZE];
+DECLARE_ALIGNED(8, int, bounding_values_array)[256 + 2];
+int *const bounding_values = bounding_values_array + 127;
+VP3DSPContext vp3dsp;
+static const str
[FFmpeg-devel] [PATCH] avcodec/x86/mpegvideoencdsp_init: Use xmm registers in SSSE3 functions (PR #20692)
PR #20692 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20692
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20692.patch
>From eb12812e4c6a0a9dd781ff1f721e512e7702f3f1 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Sun, 12 Oct 2025 07:18:24 +0200
Subject: [PATCH 1/3] tests/checkasm/mpegvideoencdsp: Add test for add_8x8basis
Signed-off-by: Andreas Rheinhardt
---
tests/checkasm/mpegvideoencdsp.c | 40
1 file changed, 35 insertions(+), 5 deletions(-)
diff --git a/tests/checkasm/mpegvideoencdsp.c b/tests/checkasm/mpegvideoencdsp.c
index 24791d113d..281195cd5f 100644
--- a/tests/checkasm/mpegvideoencdsp.c
+++ b/tests/checkasm/mpegvideoencdsp.c
@@ -16,20 +16,48 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/common.h"
#include "libavutil/intreadwrite.h"
-#include "libavutil/mem.h"
#include "libavutil/mem_internal.h"
+#include "libavcodec/mathops.h"
#include "libavcodec/mpegvideoencdsp.h"
#include "checkasm.h"
-#define randomize_buffers(buf, size) \
-do { \
-for (int j = 0; j < size; j += 4) \
-AV_WN32(buf + j, rnd()); \
+#define randomize_buffers(buf, size)\
+do {\
+for (int j = 0; j < size; j += 4) \
+AV_WN32((char*)buf + j, rnd()); \
} while (0)
+#define randomize_buffer_clipped(buf, min, max) \
+do { \
+for (size_t j = 0; j < FF_ARRAY_ELEMS(buf); ++j) \
+buf[j] = rnd() % (max - min + 1) + min; \
+} while (0)
+
+static void check_add_8x8basis(MpegvideoEncDSPContext *c)
+{
+declare_func_emms(AV_CPU_FLAG_SSSE3, void, int16_t rem[64], const int16_t
basis[64], int scale);
+if (check_func(c->add_8x8basis, "add_8x8basis")) {
+// FIXME: What are the actual ranges for these values?
+int scale = sign_extend(rnd(), 12);
+int16_t rem1[64];
+int16_t rem2[64];
+int16_t basis[64];
+
+randomize_buffer_clipped(basis, -15760, 15760);
+randomize_buffers(rem1, sizeof(rem1));
+memcpy(rem2, rem1, sizeof(rem2));
+call_ref(rem1, basis, scale);
+call_new(rem2, basis, scale);
+if (memcmp(rem1, rem2, sizeof(rem1)))
+fail();
+bench_new(rem1, basis, scale);
+}
+}
+
static void check_pix_sum(MpegvideoEncDSPContext *c)
{
LOCAL_ALIGNED_16(uint8_t, src, [16 * 16]);
@@ -144,4 +172,6 @@ void checkasm_check_mpegvideoencdsp(void)
report("pix_norm1");
check_draw_edges(&c);
report("draw_edges");
+check_add_8x8basis(&c);
+report("add_8x8basis");
}
--
2.49.1
>From 77e38557e5d27c2cc698d1c07b0e6311a89cf113 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Sun, 12 Oct 2025 07:29:04 +0200
Subject: [PATCH 2/3] avcodec/x86/mpegvideoencdsp_init: Don't use slow path
unnecessarily
The only requirement of this code (and essentially the pmulhrsw
instruction) is that the scaled scale fits into an int16_t.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/x86/mpegvideoencdsp_init.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavcodec/x86/mpegvideoencdsp_init.c
b/libavcodec/x86/mpegvideoencdsp_init.c
index 78c2ef87b8..dc8fcd8833 100644
--- a/libavcodec/x86/mpegvideoencdsp_init.c
+++ b/libavcodec/x86/mpegvideoencdsp_init.c
@@ -90,7 +90,7 @@ static void add_8x8basis_ssse3(int16_t rem[64], const int16_t
basis[64], int sca
{
x86_reg i=0;
-if (FFABS(scale) < MAX_ABS) {
+if (FFABS(scale) < 1024) {
scale <<= 16 + SCALE_OFFSET - BASIS_SHIFT + RECON_SHIFT;
__asm__ volatile(
"movd %3, %%mm5\n\t"
--
2.49.1
>From 803493e80ce2a887f1e1b67e51f15f8b548dbe0b Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Sun, 12 Oct 2025 08:04:11 +0200
Subject: [PATCH 3/3] avcodec/x86/mpegvideoencdsp_init: Use xmm registers in
SSSE3 functions
Improves performance and no longer breaks the ABI (by forgetting
to call emms).
Old benchmarks:
add_8x8basis_c: 43.6 ( 1.00x)
add_8x8basis_ssse3: 12.3 ( 3.55x)
New benchmarks:
add_8x8basis_c: 43.0 ( 1.00x)
add_8x8basis_ssse3: 6.3 ( 6.79x)
Notice that the output of try_8x8basis_ssse3 changes a bit:
Before this commit, it computes certain values and adds the values
for i,i+1,i+4 and i+5 before right shifting them; now it adds
the values for i,i+1,i+8,i+9. The second pair in these lists
could be avoided (by shifting xmm0 and xmm1 before adding both together
instead of only shifting xmm0 after adding them), but the former
i,i+1 is inherent in using pmaddwd. This is the reason that this
function is not bitexact.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/mpegvi
[FFmpeg-devel] [PATCH] hpeldsp (PR #20668)
PR #20668 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20668
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20668.patch
>From 09c0c45423ddbfe6925a7b1aed004a2f35d92e9e Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Fri, 3 Oct 2025 04:14:59 +0200
Subject: [PATCH 1/3] avcodec/x86/hpeldsp: Add SSE2 of {avg,put} no_rnd xy2
with blocksize 16
Also remove the now superseded MMX versions (the new functions have the
exact same codesize as the removed ones).
Old benchmarks:
avg_no_rnd_pixels_tab[0][3]_c: 233.7 ( 1.00x)
avg_no_rnd_pixels_tab[0][3]_mmx: 121.5 ( 1.92x)
put_no_rnd_pixels_tab[0][3]_c: 171.4 ( 1.00x)
put_no_rnd_pixels_tab[0][3]_mmx:82.6 ( 2.08x)
New benchmarks:
avg_no_rnd_pixels_tab[0][3]_c: 233.3 ( 1.00x)
avg_no_rnd_pixels_tab[0][3]_sse2: 45.0 ( 5.18x)
put_no_rnd_pixels_tab[0][3]_c: 172.1 ( 1.00x)
put_no_rnd_pixels_tab[0][3]_sse2: 40.9 ( 4.21x)
Signed-off-by: Andreas Rheinhardt
---
libavcodec/x86/hpeldsp.asm| 13 +++--
libavcodec/x86/hpeldsp_init.c | 89 +++
2 files changed, 14 insertions(+), 88 deletions(-)
diff --git a/libavcodec/x86/hpeldsp.asm b/libavcodec/x86/hpeldsp.asm
index e9f988f7b5..4c19da3e2a 100644
--- a/libavcodec/x86/hpeldsp.asm
+++ b/libavcodec/x86/hpeldsp.asm
@@ -29,6 +29,7 @@
SECTION_RODATA
cextern pb_1
+cextern pw_1
cextern pw_2
pb_interleave16: db 0, 8, 1, 9, 2, 10, 3, 11, 4, 12, 5, 13, 6, 14, 7, 15
pb_interleave8: db 0, 4, 1, 5, 2, 6, 3, 7
@@ -407,10 +408,10 @@ AVG_PIXELS8_Y2
; void ff_avg_pixels16_xy2(uint8_t *block, const uint8_t *pixels, ptrdiff_t
line_size, int h)
-%macro SET_PIXELS_XY2 1
-cglobal %1_pixels16_xy2, 4,5,8
+%macro SET_PIXELS_XY2 2-3
+cglobal %1%3_pixels16_xy2, 4,5,8
pxorm7, m7
-movam6, [pw_2]
+movam6, [%2]
movum0, [r1]
movum4, [r1+1]
movam1, m0
@@ -481,8 +482,10 @@ cglobal %1_pixels16_xy2, 4,5,8
%endmacro
INIT_XMM sse2
-SET_PIXELS_XY2 put
-SET_PIXELS_XY2 avg
+SET_PIXELS_XY2 put, pw_2
+SET_PIXELS_XY2 avg, pw_2
+SET_PIXELS_XY2 put, pw_1, _no_rnd
+SET_PIXELS_XY2 avg, pw_1, _no_rnd
%macro SSSE3_PIXELS_XY2 1-2
%if %0 == 2 ; sse2
diff --git a/libavcodec/x86/hpeldsp_init.c b/libavcodec/x86/hpeldsp_init.c
index cb47cb7752..44e44f0975 100644
--- a/libavcodec/x86/hpeldsp_init.c
+++ b/libavcodec/x86/hpeldsp_init.c
@@ -30,7 +30,6 @@
#include "libavutil/x86/cpu.h"
#include "libavcodec/avcodec.h"
#include "libavcodec/hpeldsp.h"
-#include "libavcodec/pixels.h"
#include "fpel.h"
#include "hpeldsp.h"
#include "inline_asm.h"
@@ -65,6 +64,10 @@ void ff_put_no_rnd_pixels16_y2_sse2(uint8_t *block, const
uint8_t *pixels,
ptrdiff_t line_size, int h);
void ff_avg_no_rnd_pixels16_y2_sse2(uint8_t *block, const uint8_t *pixels,
ptrdiff_t line_size, int h);
+void ff_put_no_rnd_pixels16_xy2_sse2(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+void ff_avg_no_rnd_pixels16_xy2_sse2(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
void ff_avg_pixels8_x2_mmxext(uint8_t *block, const uint8_t *pixels,
ptrdiff_t line_size, int h);
void ff_avg_pixels8_y2_mmxext(uint8_t *block, const uint8_t *pixels,
@@ -143,94 +146,12 @@ static void put_no_rnd_pixels8_xy2_mmx(uint8_t *block,
const uint8_t *pixels,
:FF_REG_a, "memory");
}
-// this routine is 'slightly' suboptimal but mostly unused
-static void avg_no_rnd_pixels8_xy2_mmx(uint8_t *block, const uint8_t *pixels,
- ptrdiff_t line_size, int h)
-{
-MOVQ_ZERO(mm7);
-MOVQ_WONE(mm6); // =2 for rnd and =1 for no_rnd version
-__asm__ volatile(
-"movq (%1), %%mm0 \n\t"
-"movq 1(%1), %%mm4\n\t"
-"movq %%mm0, %%mm1\n\t"
-"movq %%mm4, %%mm5\n\t"
-"punpcklbw %%mm7, %%mm0 \n\t"
-"punpcklbw %%mm7, %%mm4 \n\t"
-"punpckhbw %%mm7, %%mm1 \n\t"
-"punpckhbw %%mm7, %%mm5 \n\t"
-"paddusw %%mm0, %%mm4 \n\t"
-"paddusw %%mm1, %%mm5 \n\t"
-"xor%%"FF_REG_a", %%"FF_REG_a" \n\t"
-"add%3, %1 \n\t"
-".p2align 3 \n\t"
-"1: \n\t"
-"movq (%1, %%"FF_REG_a"), %%mm0 \n\t"
-"movq 1(%1, %%"FF_REG_a"), %%mm2 \n\t"
-"movq %%mm0, %%mm1\n\t"
-"movq %%mm2, %%mm3\n\t"
-"punpcklbw %%mm7, %%mm0 \n\t"
-"punpcklbw %%mm7, %%mm2 \n\t"
-"punpckhbw %%mm7, %%mm1 \
[FFmpeg-devel] [PATCH] Stop using MMX in IDCTDSP (PR #20838)
PR #20838 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20838
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20838.patch
>From 549f85f6c3f32f90429bed8362e8817268fad862 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Tue, 4 Nov 2025 13:56:01 +0100
Subject: [PATCH 1/7] avcodec/x86/idctdsp_init: Fix IDCT permutation for 32bit
without SSE2
bfb28b5ce89f3e950214b67ea95b45e3355c2caf removed the MMX idct_put
and idct_add functions, because they were overridden by SSE2 versions
(which use SSE2 only for the put/add part, not the actual IDCT).
This meant that for MMX, the idct functions are not set in unison,
so that the permutation which is meant to apply to all three
is incorrect on 32bit systems if SSE2 is unavailable/disabled.
Fix this by setting the MMX version only if SSE2 is enabled.
(No one complained, so apparently no one uses a new FFmpeg
with non-SSE2 capable systems.)
Signed-off-by: Andreas Rheinhardt
---
libavcodec/x86/idctdsp_init.c | 13 +
1 file changed, 1 insertion(+), 12 deletions(-)
diff --git a/libavcodec/x86/idctdsp_init.c b/libavcodec/x86/idctdsp_init.c
index 2d165b975b..281d143ade 100644
--- a/libavcodec/x86/idctdsp_init.c
+++ b/libavcodec/x86/idctdsp_init.c
@@ -65,18 +65,6 @@ 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 (!high_bit_depth &&
-avctx->lowres == 0 &&
-(avctx->idct_algo == FF_IDCT_AUTO ||
-avctx->idct_algo == FF_IDCT_SIMPLEAUTO ||
-avctx->idct_algo == FF_IDCT_SIMPLEMMX)) {
-c->idct = ff_simple_idct_mmx;
-}
-}
-#endif
-
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;
@@ -88,6 +76,7 @@ av_cold void ff_idctdsp_init_x86(IDCTDSPContext *c,
AVCodecContext *avctx,
(avctx->idct_algo == FF_IDCT_AUTO ||
avctx->idct_algo == FF_IDCT_SIMPLEAUTO ||
avctx->idct_algo == FF_IDCT_SIMPLEMMX)) {
+c->idct = ff_simple_idct_mmx;
c->idct_put = ff_simple_idct_put_sse2;
c->idct_add = ff_simple_idct_add_sse2;
c->perm_type = FF_IDCT_PERM_SIMPLE;
--
2.49.1
>From d4013319afd63deb83cc1dbf2816382854085379 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Tue, 4 Nov 2025 17:53:30 +0100
Subject: [PATCH 2/7] avcodec/tests/x86/dct: Test 32bit simple idct
The test has been removed in bfb28b5ce89f3e950214b67ea95b45e3355c2caf
when MMX idctdsp functions overridden by SSE2 were removed;
ff_simple_idct_mmx() has been completely disabled in this patch
for x64 and so the test should have been disabled on x64 instead
of removing it.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/tests/x86/dct.c | 4
1 file changed, 4 insertions(+)
diff --git a/libavcodec/tests/x86/dct.c b/libavcodec/tests/x86/dct.c
index 7800abc7f7..e864de6904 100644
--- a/libavcodec/tests/x86/dct.c
+++ b/libavcodec/tests/x86/dct.c
@@ -88,6 +88,10 @@ static const struct algo idct_tab_arch[] = {
{ "SIMPLE10-AVX", ff_simple_idct10_avx, FF_IDCT_PERM_TRANSPOSE,
AV_CPU_FLAG_AVX},
{ "SIMPLE12-AVX", ff_simple_idct12_avx, FF_IDCT_PERM_TRANSPOSE,
AV_CPU_FLAG_AVX, 1 },
#endif
+#else
+#if HAVE_SSE2_EXTERNAL
+{ "SIMPLE-SSE2", ff_simple_idct_mmx, FF_IDCT_PERM_SIMPLE,
AV_CPU_FLAG_SSE2},
+#endif
#endif
#endif
{ 0 }
--
2.49.1
>From d30025d2857dc3cdcc9eb4c09ed85794473ac3a1 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Wed, 5 Nov 2025 02:59:59 +0100
Subject: [PATCH 3/7] avcodec/x86/xvididct: Don't use MMX registers in SSE2
function
It is higly surprising and would necessitate emms in order to be ABI
compliant; but it is better just not to use them in the first place.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/x86/xvididct.asm | 76 -
1 file changed, 42 insertions(+), 34 deletions(-)
diff --git a/libavcodec/x86/xvididct.asm b/libavcodec/x86/xvididct.asm
index 4197551cdf..0daa2edd42 100644
--- a/libavcodec/x86/xvididct.asm
+++ b/libavcodec/x86/xvididct.asm
@@ -101,8 +101,6 @@ walkenIdctRounders: times 4 dd 65536
times 4 dd 512
times 2 dd 0
-pb_127: times 8 db 127
-
SECTION .text
; Temporary storage before the column pass
@@ -167,36 +165,47 @@ SECTION .text
%define TAN1 xmm2
%endif
-%macro JZ 2
-test %1, %1
+%macro JZ 3
+test%1%3, %1%3
jz .%2
%endmacro
-%macro JNZ 2
-test %1, %1
+%macro JNZ 3
+test%1%3, %1%3
jnz .%2
%endmacro
%macro TEST_ONE_ROW 4 ; src, reg, clear, arg
%3%4
-movq mm1, [%1]
-por mm1, [%1 + 8]
-paddusb mm1, mm0
-pmovmskb %2, mm1
+mova m1, [%1]
[FFmpeg-devel] [PATCH] avcodec/get_bits: Avoid unused variable (PR #20843)
PR #20843 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20843
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20843.patch
Fixes lots of warnings from MSVC (which does not support av_unused).
>From 338c2c6d4ad206e2da061e7baf7c30f005f0f380 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Wed, 5 Nov 2025 14:36:31 +0100
Subject: [PATCH] avcodec/get_bits: Avoid unused variable
Fixes lots of warnings from MSVC (which does not support av_unused).
Signed-off-by: Andreas Rheinhardt
---
libavcodec/get_bits.h | 15 ++-
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/libavcodec/get_bits.h b/libavcodec/get_bits.h
index 85c87c65b1..a0c0f51276 100644
--- a/libavcodec/get_bits.h
+++ b/libavcodec/get_bits.h
@@ -166,18 +166,22 @@ static inline unsigned int show_bits(GetBitContext *s,
int n);
#define MIN_CACHE_BITS 25
+#define OPEN_READER_NOSIZE_NOCACHE(name, gb)\
+unsigned int name ## _index = (gb)->index
+
#define OPEN_READER_NOSIZE(name, gb)\
-unsigned int name ## _index = (gb)->index; \
-av_unused unsigned int name ## _cache
+OPEN_READER_NOSIZE_NOCACHE(name, gb); \
+unsigned int name ## _cache
#if UNCHECKED_BITSTREAM_READER
#define OPEN_READER(name, gb) OPEN_READER_NOSIZE(name, gb)
-
+#define OPEN_READER_SIZE(name, gb) ((void)0)
#define BITS_AVAILABLE(name, gb) 1
#else
+#define OPEN_READER_SIZE(name, gb) unsigned int name ## _size_plus8 =
(gb)->size_in_bits_plus8
#define OPEN_READER(name, gb) \
OPEN_READER_NOSIZE(name, gb); \
-unsigned int name ## _size_plus8 = (gb)->size_in_bits_plus8
+OPEN_READER_SIZE(name, gb)
#define BITS_AVAILABLE(name, gb) name ## _index < name ## _size_plus8
#endif
@@ -378,7 +382,8 @@ static inline unsigned int show_bits(GetBitContext *s, int
n)
static inline void skip_bits(GetBitContext *s, int n)
{
-OPEN_READER(re, s);
+OPEN_READER_NOSIZE_NOCACHE(re, s);
+OPEN_READER_SIZE(re, s);
LAST_SKIP_BITS(re, s, n);
CLOSE_READER(re, s);
}
--
2.49.1
___
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] avcodec/x86/h264_chromamc: Use xmm regs in chroma_mc4 SSSE3 functions (PR #20842)
PR #20842 opened by mkver URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20842 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20842.patch Doubling the register size allowed to avoid two pmaddubsw. It is also ABI compliant (the old version lacked an emms) and the average versions no longer rely on padding (the old versions used pavgb with a memory operand reading eight bytes, although only four are needed). Old benchmarks (the latter four refer to RV40): avg_h264_chroma_mc4_8_c: 145.7 ( 1.00x) avg_h264_chroma_mc4_8_ssse3:32.3 ( 4.51x) put_h264_chroma_mc4_8_c: 136.1 ( 1.00x) put_h264_chroma_mc4_8_ssse3:29.0 ( 4.70x) avg_chroma_mc4_c: 162.1 ( 1.00x) avg_chroma_mc4_ssse3: 31.1 ( 5.22x) put_chroma_mc4_c: 137.5 ( 1.00x) put_chroma_mc4_ssse3: 28.6 ( 4.81x) New benchmarks: avg_h264_chroma_mc4_8_c: 146.7 ( 1.00x) avg_h264_chroma_mc4_8_ssse3:26.5 ( 5.53x) put_h264_chroma_mc4_8_c: 136.8 ( 1.00x) put_h264_chroma_mc4_8_ssse3:22.5 ( 6.09x) avg_chroma_mc4_c: 165.5 ( 1.00x) avg_chroma_mc4_ssse3: 27.2 ( 6.08x) put_chroma_mc4_c: 138.1 ( 1.00x) put_chroma_mc4_ssse3: 23.2 ( 5.96x) >From 16296019a93e612ba4d07495e9bc85c49dbc1aaf Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 5 Nov 2025 12:46:50 +0100 Subject: [PATCH] avcodec/x86/h264_chromamc: Use xmm regs in chroma_mc4 SSSE3 functions Doubling the register size allowed to avoid two pmaddubsw. It is also ABI compliant (the old version lacked an emms) and the average versions no longer rely on padding (the old versions used pavgb with a memory operand reading eight bytes, although only four are needed). Old benchmarks (the latter four refer to RV40): avg_h264_chroma_mc4_8_c: 145.7 ( 1.00x) avg_h264_chroma_mc4_8_ssse3:32.3 ( 4.51x) put_h264_chroma_mc4_8_c: 136.1 ( 1.00x) put_h264_chroma_mc4_8_ssse3:29.0 ( 4.70x) avg_chroma_mc4_c: 162.1 ( 1.00x) avg_chroma_mc4_ssse3: 31.1 ( 5.22x) put_chroma_mc4_c: 137.5 ( 1.00x) put_chroma_mc4_ssse3: 28.6 ( 4.81x) New benchmarks: avg_h264_chroma_mc4_8_c: 146.7 ( 1.00x) avg_h264_chroma_mc4_8_ssse3:26.5 ( 5.53x) put_h264_chroma_mc4_8_c: 136.8 ( 1.00x) put_h264_chroma_mc4_8_ssse3:22.5 ( 6.09x) avg_chroma_mc4_c: 165.5 ( 1.00x) avg_chroma_mc4_ssse3: 27.2 ( 6.08x) put_chroma_mc4_c: 138.1 ( 1.00x) put_chroma_mc4_ssse3: 23.2 ( 5.96x) Signed-off-by: Andreas Rheinhardt --- libavcodec/x86/h264_chromamc.asm | 89 +--- 1 file changed, 46 insertions(+), 43 deletions(-) diff --git a/libavcodec/x86/h264_chromamc.asm b/libavcodec/x86/h264_chromamc.asm index 6a65d5cabd..7c896db179 100644 --- a/libavcodec/x86/h264_chromamc.asm +++ b/libavcodec/x86/h264_chromamc.asm @@ -276,51 +276,57 @@ cglobal %1_%2_chroma_mc8%3, 6, 7+UNIX64, 8 %endmacro %macro chroma_mc4_ssse3_func 2 -cglobal %1_%2_chroma_mc4, 6, 7+UNIX64, 0 -movq m5, [pw_32] +cglobal %1_%2_chroma_mc4, 6, 7+UNIX64, 8 +mova m5, [pw_32] ..@%1_%2_chroma_mc4_after_init_ %+ cpuname: -mov r6, r4 +mov r6d, r4d shl r4d, 8 -sub r4d, r6d -mov r6, 8 -add r4d, 8 ; x*288+8 -sub r6d, r5d -imul r6d, r4d ; (8-y)*(x*255+8) = (8-y)*x<<8 | (8-y)*(8-x) -imul r4d, r5d ;y *(x*255+8) =y *x<<8 |y *(8-x) +movd m0, [r1] +sub r6d, 8 +sub r4d, r6d ; x << 8 | (8-x) +mov r6d, r5d +shl r5d, 16 +movd m1, [r1+1] +sub r6d, 8 +sub r5d, r6d ; y << 16 | (8-y) +imul r4d, r5d ; xy << 24 | (8-x)y << 16 | x(8-y) << 8 | (8-x)(8-y) +add r1, r2 -movd m7, r6d -movd m6, r4d -movd m0, [r1 ] -pshufwm7, m7, 0 -punpcklbw m0, [r1+1] -pshufwm6, m6, 0 +movd m6, r4d ; ABCD +punpcklwd m6, m6 ; ABABCDCD +pshufdm7, m6, 0x55; CDCDCD
[FFmpeg-devel] [PATCH] avcodec/packet: Move ff_side_data_set_encoder_stats() to encode.c (PR #20844)
PR #20844 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20844
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20844.patch
>From f484ee7b5a72b46abb2636ac6c40c6aa16ce0c1a Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Wed, 5 Nov 2025 14:53:12 +0100
Subject: [PATCH 1/4] avcodec/libaomenc: Avoid av_unused
pict_type is always used since 5e0eac3d4566839598f6d6fe5d0023d6713a;
ctx in set_pix_fmt() seems to have been always unused.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/libaomenc.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index e9b15fd7bd..82d5513e3d 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -484,7 +484,6 @@ static int set_pix_fmt(AVCodecContext *avctx,
aom_codec_caps_t codec_caps,
struct aom_codec_enc_cfg *enccfg, aom_codec_flags_t
*flags,
aom_img_fmt_t *img_fmt)
{
-av_unused AOMContext *ctx = avctx->priv_data;
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
enccfg->g_bit_depth = enccfg->g_input_bit_depth = desc->comp[0].depth;
switch (avctx->pix_fmt) {
@@ -1090,7 +1089,7 @@ static int storeframe(AVCodecContext *avctx, struct
FrameListData *cx_frame,
AVPacket *pkt)
{
AOMContext *ctx = avctx->priv_data;
-av_unused int pict_type;
+enum AVPictureType pict_type;
int ret = ff_get_encode_buffer(avctx, pkt, cx_frame->sz, 0);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR,
--
2.49.1
>From 03cadd9fc8cc4175c56cfee2011c71fea68a2c31 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Wed, 5 Nov 2025 15:07:25 +0100
Subject: [PATCH 2/4] avcodec/libx265: Remove stray
FF_ENABLE_DEPRECATION_WARNINGS
Forgotten in 7d07723db5c18bb762f8eeb2a844a677986b8dcc.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/libx265.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index d897707dd7..4816085cf8 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -293,7 +293,6 @@ static av_cold int libx265_encode_init(AVCodecContext
*avctx)
} else {
ctx->params->fpsNum = avctx->time_base.den;
ctx->params->fpsDenom= avctx->time_base.num;
-FF_ENABLE_DEPRECATION_WARNINGS
}
ctx->params->sourceWidth = avctx->width;
ctx->params->sourceHeight= avctx->height;
--
2.49.1
>From 8370502db1903c876fcde3ac230bd8ed51d84a19 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Wed, 5 Nov 2025 15:29:48 +0100
Subject: [PATCH 3/4] avcodec/packet: Move ff_side_data_set_encoder_stats() to
encode.c
And rename it to ff_encode_add_stats_side_data() and move its
declaration to encode.h. Also constify the error pointee.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/dnxhdenc.c| 3 +--
libavcodec/encode.c | 26 ++
libavcodec/encode.h | 3 +++
libavcodec/libaomenc.c | 6 ++
libavcodec/libkvazaar.c | 4 +---
libavcodec/liboapvenc.c | 3 +--
libavcodec/libsvtav1.c | 3 +--
libavcodec/libvpxenc.c | 5 ++---
libavcodec/libx264.c | 4 ++--
libavcodec/libx265.c | 3 +--
libavcodec/libxavs.c | 4 +---
libavcodec/libxeve.c | 7 +--
libavcodec/libxvid.c | 3 +--
libavcodec/mpegvideo_enc.c | 9 -
libavcodec/nvenc.c | 3 +--
libavcodec/packet.c | 26 --
libavcodec/packet_internal.h | 2 --
libavcodec/qsvenc.c | 4 +---
libavcodec/snowenc.c | 9 -
libavcodec/svq1enc.c | 3 +--
20 files changed, 54 insertions(+), 76 deletions(-)
diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c
index 7a5978c137..edb58ba25f 100644
--- a/libavcodec/dnxhdenc.c
+++ b/libavcodec/dnxhdenc.c
@@ -38,7 +38,6 @@
#include "mpegvideo.h"
#include "mpegvideoenc.h"
#include "pixblockdsp.h"
-#include "packet_internal.h"
#include "profiles.h"
#include "dnxhdenc.h"
@@ -1300,7 +1299,7 @@ encode_coding_unit:
goto encode_coding_unit;
}
-ff_side_data_set_encoder_stats(pkt, ctx->qscale * FF_QP2LAMBDA, NULL, 0,
AV_PICTURE_TYPE_I);
+ff_encode_add_stats_side_data(pkt, ctx->qscale * FF_QP2LAMBDA, NULL, 0,
AV_PICTURE_TYPE_I);
*got_packet = 1;
return 0;
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 1eca5e38c1..d8f2cc52b0 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -23,6 +23,7 @@
#include "libavutil/emms.h"
#include "libavutil/frame.h"
#include "libavutil/internal.h"
+#include "libavutil/intreadwrite.h"
#include "libavutil/mem.h"
#include "libavutil/pixdesc.h"
#include "libavutil/samplefmt.h"
@@ -914,6 +915,31 @@ AVCPBProperties
*ff_encode_add_cpb_side_data(AVCodecContext *avctx)
return props;
}
+int ff_encode_add_stats_side_data(AVPacket *pkt, int quality, const int64_t
error[],
[FFmpeg-devel] [PATCH] avcodec/x86/hevc/add_res: Remove AVX add_residual functions (PR #20789)
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
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
---
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_(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
decr4d
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
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
---
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]
-paddswm0, m2
-paddswm1, m3
+paddswm0, [r1]
+paddswm1, [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]
-paddswm2, m6
-paddswm3, m7
+paddswm2, [r1+32]
+paddswm3, [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
paddswm1, m5
paddswm2, m6
+%else
+paddswm1, [r1+%1]
+paddswm2, [r1+%1+16]
+%endif
m
[FFmpeg-devel] [PATCH] avcodec/x86/hpeldsp: Don't use saturated addition when unnecessary (PR #20791)
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 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 --- 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 -pmulhrswm2, [pw_8192] +pmulhrswm2, m3 %endif %ifidn %1, avg movhm1, [r0+r4] @@ -450,7 +450,7 @@ cglobal %1%3_pixels8_xy2, 4,5,5 psrlw m0, 2 %else paddusw m0, m2 -pmulhrswm0, [pw_8192] +pmulhrswm0, m3 %endif %ifidn %1, avg movhm1, [r0+r4] -- 2.49.1 >From a84ea10f93fbb66530eaa5ebb6f0275203d18356 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt 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 --- 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 pmulhrswm2, 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 pmulhrswm0, 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 movum3, [r1+r4+1] pmaddubsw m2, m5 pmaddubsw m3, m5 -paddusw m0, m2 -paddusw m1, m3 +paddw m0, m2 +paddw m1, m3 pmulhrswm0, [pw_8192] pmulhrswm1, [pw_8192] %ifidn %1, avg @@ -587,8 +587,8 @@ cglobal %1_pixels16_xy2, 4,5,%2 movum1, [r1+r4+1] pmaddubsw m0, m5 pmaddubsw m1, m5 -paddusw m2, m0 -paddusw m3, m1 +paddw m2, m0 +paddw m3, m1 pmulhrswm2, [pw_8192] pmulhrswm3, [pw_8192] %ifidn %1, avg -- 2.49.1 >From 88f4641db2d488308f04b70cba9f285d30da6eb5 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt 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 --- 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
[FFmpeg-devel] [PATCH] avcodec/rv34dsp: Reduce size of qpel functions arrays (PR #20792)
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
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
---
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
___
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] .gitignore: Add config_components.asm (PR #20816)
PR #20816 opened by mkver URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20816 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20816.patch Forgotten in c607aae2b95b05bdc7066e3572737cb00a596e9f. >From 6b8aa6d21ad3f1890f82ac99a74de28f63c78e95 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 2 Nov 2025 08:46:48 +0100 Subject: [PATCH] .gitignore: Add config_components.asm Forgotten in c607aae2b95b05bdc7066e3572737cb00a596e9f. Signed-off-by: Andreas Rheinhardt --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 4aa49c52c7..d789b5804c 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,7 @@ /ffprobe /config.asm /config.h +/config_components.asm /config_components.h /coverage.info /lcov/ -- 2.49.1 ___ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] avcodec/x86/vp3dsp: Remove remnants of MMX (PR #20817)
PR #20817 opened by mkver URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20817 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20817.patch Forgotten in eefec0663406d7c2749a280f5244caaacb069c60. >From 9fdb3a6d87d1bb37e50981a12840d75fcbbada55 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 2 Nov 2025 10:37:22 +0100 Subject: [PATCH] avcodec/x86/vp3dsp: Remove remnants of MMX Forgotten in eefec0663406d7c2749a280f5244caaacb069c60. Signed-off-by: Andreas Rheinhardt --- libavcodec/x86/vp3dsp.asm | 32 1 file changed, 32 deletions(-) diff --git a/libavcodec/x86/vp3dsp.asm b/libavcodec/x86/vp3dsp.asm index f2fc1efd32..3fa6584c9d 100644 --- a/libavcodec/x86/vp3dsp.asm +++ b/libavcodec/x86/vp3dsp.asm @@ -520,7 +520,6 @@ cglobal put_vp_no_rnd_pixels8_l2, 5, 6, 0, dst, src1, src2, stride, h, stride3 %endmacro %macro VP3_IDCT 1 -%if mmsize == 16 %define I(x) [%1+16*x] %define O(x) [%1+16*x] %define C(x) [vp3_idct_data+16*(x-1)] @@ -538,37 +537,6 @@ cglobal put_vp_no_rnd_pixels8_l2, 5, 6, 0, dst, src1, src2, stride, h, stride3 %define ADD(x) paddsw x, [pw_8] VP3_1D_IDCT_SSE2 PUT_BLOCK 0, 1, 2, 3, 4, 5, 6, 7 -%else ; mmsize == 8 -; eax = quantized input -; ebx = dequantizer matrix -; ecx = IDCT constants -; M(I) = ecx + MaskOffset(0) + I * 8 -; C(I) = ecx + CosineOffset(32) + (I-1) * 8 -; edx = output -; r0..r7 = mm0..mm7 -%define OC_8 [pw_8] -%define C(x) [vp3_idct_data+16*(x-1)] - -; at this point, function has completed dequantization + dezigzag + -; partial transposition; now do the idct itself -%define I(x) [%1+16*x] -%define J(x) [%1+16*x] -RowIDCT -Transpose - -%define I(x) [%1+16*x+8] -%define J(x) [%1+16*x+8] -RowIDCT -Transpose - -%define I(x) [%1+16* x] -%define J(x) [%1+16*(x-4)+8] -ColumnIDCT - -%define I(x) [%1+16* x +64] -%define J(x) [%1+16*(x-4)+72] -ColumnIDCT -%endif ; mmsize == 16/8 %endmacro %macro vp3_idct_funcs 0 -- 2.49.1 ___ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] avcodec: Avoid relocations for color ranges (PR #20828)
PR #20828 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20828
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20828.patch
Also add a few more tests to the lavc/tests/avcodec.c.
>From c35dff046e1f7dbcb8f356eba7d39fdfdda29e44 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Mon, 3 Nov 2025 00:17:18 +0100
Subject: [PATCH 1/8] avcodec/avcodec: Remove always-true branches
avcodec_get_supported_config() always sets a dummy for
the pointer to the number of entries in case it is not set.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/avcodec.c | 8 ++--
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index db24b4ed52..78453e2467 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -723,14 +723,12 @@ int attribute_align_arg
avcodec_receive_frame(AVCodecContext *avctx, AVFrame *fr
if (codec->type != (allowed_type)) \
return AVERROR(EINVAL); \
*out_configs = (field); \
-if (out_num_configs) { \
for (int i = 0;; i++) { \
if (!(field) || !memcmp(&(field)[i], &end, sizeof(end))) { \
*out_num_configs = i; \
break; \
} \
} \
-} \
return 0; \
} while (0)
@@ -779,14 +777,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
if (codec->type != AVMEDIA_TYPE_VIDEO)
return AVERROR(EINVAL);
*out_configs = color_range_table[ffcodec(codec)->color_ranges];
-if (out_num_configs)
-*out_num_configs = av_popcount(ffcodec(codec)->color_ranges);
+*out_num_configs = av_popcount(ffcodec(codec)->color_ranges);
return 0;
case AV_CODEC_CONFIG_COLOR_SPACE:
*out_configs = NULL;
-if (out_num_configs)
-*out_num_configs = 0;
+*out_num_configs = 0;
return 0;
case AV_CODEC_CONFIG_ALPHA_MODE:
--
2.49.1
>From 7bac71e2d3ef3b9645753fd553aea1f5451c0531 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Mon, 3 Nov 2025 07:41:40 +0100
Subject: [PATCH 2/8] avcodec/avcodec: Avoid relocations for color ranges
Signed-off-by: Andreas Rheinhardt
---
libavcodec/avcodec.c | 29 +
1 file changed, 13 insertions(+), 16 deletions(-)
diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index 78453e2467..00f5447b52 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -732,22 +732,15 @@ int attribute_align_arg
avcodec_receive_frame(AVCodecContext *avctx, AVFrame *fr
return 0; \
} while (0)
-static const enum AVColorRange color_range_jpeg[] = {
-AVCOL_RANGE_JPEG, AVCOL_RANGE_UNSPECIFIED
+static const enum AVColorRange color_range_tab[] = {
+AVCOL_RANGE_MPEG, AVCOL_RANGE_JPEG, AVCOL_RANGE_UNSPECIFIED,
+AVCOL_RANGE_MPEG, AVCOL_RANGE_UNSPECIFIED,
};
-static const enum AVColorRange color_range_mpeg[] = {
-AVCOL_RANGE_MPEG, AVCOL_RANGE_UNSPECIFIED
-};
-
-static const enum AVColorRange color_range_all[] = {
-AVCOL_RANGE_MPEG, AVCOL_RANGE_JPEG, AVCOL_RANGE_UNSPECIFIED
-};
-
-static const enum AVColorRange *color_range_table[] = {
-[AVCOL_RANGE_MPEG] = color_range_mpeg,
-[AVCOL_RANGE_JPEG] = color_range_jpeg,
-[AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG] = color_range_all,
+static const uint8_t color_range_offsets[] = {
+[AVCOL_RANGE_MPEG] = 3,
+[AVCOL_RANGE_JPEG] = 1,
+[AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG] = 0,
};
int ff_default_get_supported_config(const AVCodecContext *avctx,
@@ -776,8 +769,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
case AV_CODEC_CONFIG_COLOR_RANGE:
if (codec->type != AVMEDIA_TYPE_VIDEO)
return AVERROR(EINVAL);
-*out_configs = color_range_table[ffcodec(codec)->color_ranges];
-*out_num_configs = av_popcount(ffcodec(codec)->color_ranges);
+unsigned color_ranges = codec2->color_ranges;
+if (color_ranges)
+*out_configs = color_range_tab + color_range_offsets[color_ranges];
+else
+*out_configs = NULL;
+*out_num_configs = av_popcount(color_ranges);
return 0;
case AV_CODEC_CONFIG_COLOR_SPACE:
--
2.49.1
>From 05352edf16132235428d32c32dcbff8a2b4d1b53 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Mon, 3 Nov 2025 08:22:59 +0100
Subject: [PATCH 3/8] avcodec/codec_internal: U
[FFmpeg-devel] [PATCH] Optimize lcevc away if disabled (PR #20818)
PR #20818 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20818
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20818.patch
>From abf819cff61d779f131fa7c23232952b46496928 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Sun, 2 Nov 2025 15:03:33 +0100
Subject: [PATCH 1/5] avcodec/pthread_frame: Call ff_decode_internal_sync()
only during init
It is not necessary to do it more than once, as none of the fields
set change after init.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/pthread_frame.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index abf0d5a199..0b56af916d 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -401,7 +401,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
dst->hwaccel_flags = src->hwaccel_flags;
av_refstruct_replace(&dst->internal->pool, src->internal->pool);
-ff_decode_internal_sync(dst, src);
}
if (for_user) {
--
2.49.1
>From 182b9c7a4a7117371d51caa917f26162db53cc56 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Sun, 2 Nov 2025 15:29:59 +0100
Subject: [PATCH 2/5] avcodec/decode: Don't allocate LCEVC context for
non-video
Signed-off-by: Andreas Rheinhardt
---
libavcodec/decode.c | 8 +---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index d8e523f327..df4e1b38c7 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -2080,9 +2080,11 @@ int ff_decode_preinit(AVCodecContext *avctx)
return ret;
if (!(avctx->export_side_data & AV_CODEC_EXPORT_DATA_ENHANCEMENTS)) {
-ret = ff_lcevc_alloc(&dc->lcevc);
-if (ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE))
-return ret;
+if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
+ret = ff_lcevc_alloc(&dc->lcevc);
+if (ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE))
+return ret;
+}
}
return 0;
--
2.49.1
>From 2786e5a9ad32920fccee9352161e81c8e733563b Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Sun, 2 Nov 2025 16:00:06 +0100
Subject: [PATCH 3/5] avcodec/decode: Put lcevc fields into structure of their
own
Makes it easier to see that width and height in DecodeContext is
actually a lcevc field.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/decode.c | 34 ++
1 file changed, 18 insertions(+), 16 deletions(-)
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index df4e1b38c7..b7859d3e25 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -94,10 +94,12 @@ typedef struct DecodeContext {
*/
uint64_t side_data_pref_mask;
-FFLCEVCContext *lcevc;
-int lcevc_frame;
-int width;
-int height;
+struct {
+FFLCEVCContext *ctx;
+int frame;
+int width;
+int height;
+} lcevc;
} DecodeContext;
static DecodeContext *decode_ctx(AVCodecInternal *avci)
@@ -1661,12 +1663,12 @@ static void update_frame_props(AVCodecContext *avctx,
AVFrame *frame)
AVCodecInternal*avci = avctx->internal;
DecodeContext*dc = decode_ctx(avci);
-dc->lcevc_frame = dc->lcevc && avctx->codec_type == AVMEDIA_TYPE_VIDEO &&
+dc->lcevc.frame = dc->lcevc.ctx && avctx->codec_type == AVMEDIA_TYPE_VIDEO
&&
av_frame_get_side_data(frame, AV_FRAME_DATA_LCEVC);
-if (dc->lcevc_frame) {
-dc->width = frame->width;
-dc->height= frame->height;
+if (dc->lcevc.frame) {
+dc->lcevc.width = frame->width;
+dc->lcevc.height = frame->height;
frame->width = frame->width * 2 /
FFMAX(frame->sample_aspect_ratio.den, 1);
frame->height = frame->height * 2 /
FFMAX(frame->sample_aspect_ratio.num, 1);
}
@@ -1677,7 +1679,7 @@ static int attach_post_process_data(AVCodecContext
*avctx, AVFrame *frame)
AVCodecInternal*avci = avctx->internal;
DecodeContext*dc = decode_ctx(avci);
-if (dc->lcevc_frame) {
+if (dc->lcevc.frame) {
FrameDecodeData *fdd = frame->private_ref;
FFLCEVCFrame *frame_ctx;
int ret;
@@ -1692,13 +1694,13 @@ static int attach_post_process_data(AVCodecContext
*avctx, AVFrame *frame)
return AVERROR(ENOMEM);
}
-frame_ctx->lcevc = av_refstruct_ref(dc->lcevc);
+frame_ctx->lcevc = av_refstruct_ref(dc->lcevc.ctx);
frame_ctx->frame->width = frame->width;
frame_ctx->frame->height = frame->height;
frame_ctx->frame->format = frame->format;
-frame->width = dc->width;
-frame->height = dc->height;
+frame->width = dc->lcevc.width;
+frame->height = dc->lcevc.height;
ret = avctx->get_buffer2(avctx, frame_ctx->frame, 0);
if (ret < 0) {
@@ -1712,7 +1714,7 @@ static int attach_post_process_data(AVCodecContext
*avctx, AVFrame *frame)
fd
[FFmpeg-devel] [PATCH] avcodec/x86/Makefile: Don't use MMX-OBJS for fdct.o (PR #20833)
PR #20833 opened by mkver URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20833 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20833.patch >From 71e4d804ac5c2569f4359ed95288d3601d2b1a72 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 4 Nov 2025 05:49:51 +0100 Subject: [PATCH 1/2] avcodec/x86/Makefile: Don't use MMX-OBJS for fdct.o MMX has been removed in d402ec6be99dc82e263bad883e7c1c3d957343db. Signed-off-by: Andreas Rheinhardt --- libavcodec/x86/Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile index ed60fa340f..1c1e14b4b8 100644 --- a/libavcodec/x86/Makefile +++ b/libavcodec/x86/Makefile @@ -7,7 +7,7 @@ OBJS-$(CONFIG_BLOCKDSP)+= x86/blockdsp_init.o OBJS-$(CONFIG_BSWAPDSP)+= x86/bswapdsp_init.o OBJS-$(CONFIG_DIRAC_DECODER) += x86/diracdsp_init.o \ x86/dirac_dwt_init.o -OBJS-$(CONFIG_FDCTDSP) += x86/fdctdsp_init.o +OBJS-$(CONFIG_FDCTDSP) += x86/fdctdsp_init.o x86/fdct.o OBJS-$(CONFIG_FMTCONVERT) += x86/fmtconvert_init.o OBJS-$(CONFIG_H263DSP) += x86/h263dsp_init.o OBJS-$(CONFIG_H264CHROMA) += x86/h264chroma_init.o @@ -83,7 +83,6 @@ OBJS-$(CONFIG_WEBP_DECODER)+= x86/vp8dsp_init.o # GCC inline assembly optimizations # subsystems -MMX-OBJS-$(CONFIG_FDCTDSP) += x86/fdct.o MMX-OBJS-$(CONFIG_VC1DSP) += x86/vc1dsp_mmx.o # decoders/encoders -- 2.49.1 >From 65324ac2650c7a1ab9390aa187fc5b0ae3923b7c Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 4 Nov 2025 06:19:51 +0100 Subject: [PATCH 2/2] avcodec/x86/fdct: Remove obsolete comment Signed-off-by: Andreas Rheinhardt --- libavcodec/x86/fdct.c | 4 1 file changed, 4 deletions(-) diff --git a/libavcodec/x86/fdct.c b/libavcodec/x86/fdct.c index f4677ff4be..065af56a4a 100644 --- a/libavcodec/x86/fdct.c +++ b/libavcodec/x86/fdct.c @@ -44,10 +44,6 @@ // constants for the forward DCT // - // -// Be sure to check that your compiler is aligning all constants to QWORD -// (8-byte) memory boundaries! Otherwise the unaligned memory access will -// severely stall MMX execution. -// // #define BITS_FRW_ACC 3 //; 2 or 3 for accuracy -- 2.49.1 ___ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] avcodec/proresdec: Remove unused hwaccel_last_picture_private (PR #20753)
PR #20753 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20753
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20753.patch
ProRes is an intra-only codec.
Copied from FFV1?
>From d01608e0222a04b5743446f200284d486524b355 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Sat, 25 Oct 2025 22:27:36 +0200
Subject: [PATCH] avcodec/proresdec: Remove unused hwaccel_last_picture_private
ProRes is an intra-only codec.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/proresdec.c | 6 ++
libavcodec/proresdec.h | 2 +-
2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/libavcodec/proresdec.c b/libavcodec/proresdec.c
index 814074f9d7..40c15a0c85 100644
--- a/libavcodec/proresdec.c
+++ b/libavcodec/proresdec.c
@@ -788,8 +788,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame
*frame,
if ((ret = ff_thread_get_buffer(avctx, frame, 0)) < 0)
return ret;
-av_refstruct_unref(&ctx->hwaccel_last_picture_private);
-FFSWAP(void *, ctx->hwaccel_picture_private,
ctx->hwaccel_last_picture_private);
+av_refstruct_unref(&ctx->hwaccel_picture_private);
if ((ret = ff_hwaccel_frame_priv_alloc(avctx,
&ctx->hwaccel_picture_private)) < 0)
return ret;
@@ -832,7 +831,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame
*frame,
goto decode_picture;
}
-av_refstruct_unref(&ctx->hwaccel_last_picture_private);
+av_refstruct_unref(&ctx->hwaccel_picture_private);
*got_frame = 1;
@@ -845,7 +844,6 @@ static av_cold int decode_close(AVCodecContext *avctx)
av_freep(&ctx->slices);
av_refstruct_unref(&ctx->hwaccel_picture_private);
-av_refstruct_unref(&ctx->hwaccel_last_picture_private);
return 0;
}
diff --git a/libavcodec/proresdec.h b/libavcodec/proresdec.h
index d33eab149b..965fc85b7a 100644
--- a/libavcodec/proresdec.h
+++ b/libavcodec/proresdec.h
@@ -44,7 +44,7 @@ typedef struct {
BlockDSPContext bdsp;
ProresDSPContext prodsp;
AVFrame *frame;
-void *hwaccel_picture_private, *hwaccel_last_picture_private;
+void *hwaccel_picture_private;
int frame_type; ///< 0 = progressive, 1 = tff, 2 = bff
uint8_t qmat_luma[64];
uint8_t qmat_chroma[64];
--
2.49.1
___
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] avcodec/vc1dec: Don't initialize write-only intra_scantable, deduplicate cleanup code (PR #20786)
PR #20786 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20786
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20786.patch
>From 798a62cbb30586d704d9365cbf87b04cd64b Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Wed, 29 Oct 2025 15:47:47 +0100
Subject: [PATCH 1/2] avcodec/vc1dec: Don't initialize write-only
intra_scantable
VC-1 does not use it.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/vc1dec.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 55225baec9..35d8c68f45 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -468,9 +468,6 @@ av_cold int ff_vc1_decode_init(AVCodecContext *avctx)
if (ret < 0)
return ret;
-ff_permute_scantable(s->intra_scantable.permutated, ff_wmv1_scantable[1],
- s->idsp.idct_permutation);
-
ret = vc1_decode_init_alloc_tables(v);
if (ret < 0) {
vc1_decode_reset(avctx);
--
2.49.1
>From 3e8af4515c36caf744328f25c60376f9aebbae53 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Wed, 29 Oct 2025 15:59:17 +0100
Subject: [PATCH 2/2] avcodec/vc1dec: Deduplicate cleanup code
Signed-off-by: Andreas Rheinhardt
---
libavcodec/vc1dec.c | 7 +--
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 35d8c68f45..1925384ba5 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -1366,12 +1366,7 @@ image:
}
end:
-av_free(buf2);
-for (i = 0; i < n_slices; i++)
-av_free(slices[i].buf);
-av_free(slices);
-return buf_size;
-
+ret = buf_size;
err:
av_free(buf2);
for (i = 0; i < n_slices; i++)
--
2.49.1
___
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] avcodec/x86/qpel: Add specializations for put_l2 functions (PR #20785)
PR #20785 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20785
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20785.patch
>From 995bc3690264ac6711d8364156fbfcf5b40766e1 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Thu, 9 Oct 2025 03:57:33 +0200
Subject: [PATCH 1/3] avcodec/x86/{h264_qpel,qpeldsp_init}: Move shared decls
into header
Signed-off-by: Andreas Rheinhardt
---
libavcodec/x86/h264_qpel.c| 9 +
libavcodec/x86/qpel.h | 38 +++
libavcodec/x86/qpeldsp_init.c | 14 +
3 files changed, 40 insertions(+), 21 deletions(-)
create mode 100644 libavcodec/x86/qpel.h
diff --git a/libavcodec/x86/h264_qpel.c b/libavcodec/x86/h264_qpel.c
index 5d1445a8bb..30851e266e 100644
--- a/libavcodec/x86/h264_qpel.c
+++ b/libavcodec/x86/h264_qpel.c
@@ -28,6 +28,7 @@
#include "libavutil/x86/cpu.h"
#include "libavcodec/h264qpel.h"
#include "fpel.h"
+#include "qpel.h"
#if HAVE_X86ASM
void ff_avg_pixels4_mmxext(uint8_t *dst, const uint8_t *src, ptrdiff_t stride);
@@ -35,14 +36,6 @@ void ff_put_pixels4_l2_mmxext(uint8_t *dst, const uint8_t
*src1, const uint8_t *
ptrdiff_t stride);
void ff_avg_pixels4_l2_mmxext(uint8_t *dst, const uint8_t *src1, const uint8_t
*src2,
ptrdiff_t stride);
-void ff_put_pixels8_l2_mmxext(uint8_t *dst, const uint8_t *src1, const uint8_t
*src2,
- ptrdiff_t dstStride, ptrdiff_t src1Stride, int
h);
-void ff_avg_pixels8_l2_mmxext(uint8_t *dst, const uint8_t *src1, const uint8_t
*src2,
- ptrdiff_t dstStride, ptrdiff_t src1Stride);
-void ff_put_pixels16_l2_mmxext(uint8_t *dst, const uint8_t *src1, const
uint8_t *src2,
- ptrdiff_t dstStride, ptrdiff_t src1Stride, int
h);
-void ff_avg_pixels16_l2_mmxext(uint8_t *dst, const uint8_t *src1, const
uint8_t *src2,
- ptrdiff_t dstStride, ptrdiff_t src1Stride);
#define ff_put_pixels4_l2_mmxext(dst, src1, src2, dststride, src1stride, h) \
ff_put_pixels4_l2_mmxext((dst), (src1), (src2), (dststride))
#define ff_avg_pixels4_l2_mmxext(dst, src1, src2, dststride, src1stride, h) \
diff --git a/libavcodec/x86/qpel.h b/libavcodec/x86/qpel.h
new file mode 100644
index 00..b30d5e23dc
--- /dev/null
+++ b/libavcodec/x86/qpel.h
@@ -0,0 +1,38 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_X86_QPEL_H
+#define AVCODEC_X86_QPEL_H
+
+#include
+#include
+
+void ff_put_pixels8_l2_mmxext(uint8_t *dst,
+ const uint8_t *src1, const uint8_t *src2,
+ ptrdiff_t dstStride, ptrdiff_t src1Stride, int
h);
+void ff_avg_pixels8_l2_mmxext(uint8_t *dst,
+ const uint8_t *src1, const uint8_t *src2,
+ ptrdiff_t dstStride, ptrdiff_t src1Stride);
+void ff_put_pixels16_l2_mmxext(uint8_t *dst,
+ const uint8_t *src1, const uint8_t *src2,
+ ptrdiff_t dstStride, ptrdiff_t src1Stride, int
h);
+void ff_avg_pixels16_l2_mmxext(uint8_t *dst,
+ const uint8_t *src1, const uint8_t *src2,
+ ptrdiff_t dstStride, ptrdiff_t src1Stride);
+
+#endif /* AVCODEC_X86_QPEL_H */
diff --git a/libavcodec/x86/qpeldsp_init.c b/libavcodec/x86/qpeldsp_init.c
index a1d1eb80b3..f88c804a48 100644
--- a/libavcodec/x86/qpeldsp_init.c
+++ b/libavcodec/x86/qpeldsp_init.c
@@ -27,25 +27,13 @@
#include "libavutil/attributes.h"
#include "libavutil/cpu.h"
#include "libavutil/x86/cpu.h"
-#include "libavcodec/pixels.h"
#include "libavcodec/qpeldsp.h"
#include "fpel.h"
+#include "qpel.h"
-void ff_put_pixels8_l2_mmxext(uint8_t *dst,
- const uint8_t *src1, const uint8_t *src2,
- ptrdiff_t dstStride, ptrdiff_t src1Stride, int
h);
void ff_put_no_rnd_pixels8_l2_mmxext(uint8_t *dst,
const uint8_t *src1, const uint8_t *src2,
ptrdiff_t dstStride, ptrdiff_t
src1Stride, int h);
-void ff_avg_pixels8_l2_mmxext(uint8_t *dst,
-
[FFmpeg-devel] [PATCH] Fix build failure, deprecation warnings due to parser changes (PR #20814)
PR #20814 opened by mkver URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20814 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20814.patch I intend to apply this soon. >From 25968dbb056a1066296a005e2d24545c28a4fa8c Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sat, 1 Nov 2025 18:41:27 +0100 Subject: [PATCH 1/2] avcodec/parser_internal: Rename PASSTHROUGH macro to avoid name conflict wingdi.h defines its own PASSTHROUGH and it is included implicitly by the VC-1 parser (which is mpegvideo-based and therefore includes a lot of stuff). Signed-off-by: Andreas Rheinhardt --- libavcodec/parser_internal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/parser_internal.h b/libavcodec/parser_internal.h index e366b5576a..fa9af971c1 100644 --- a/libavcodec/parser_internal.h +++ b/libavcodec/parser_internal.h @@ -67,9 +67,9 @@ static inline const FFCodecParser *ffcodecparser(const AVCodecParser *parser) #define CHECK_FOR_TOO_MANY_IDS(...) AV_JOIN(EIGTH_ARG(__VA_ARGS__, NO, NO, NO, NO, NO, NO, NO, NO), _FAIL) // For compatibility with MSVC's old, spec-incompliant preprocessor. -#define PASSTHROUGH(...) __VA_ARGS__ +#define FF_MSVC_EXPAND(...) __VA_ARGS__ #define FIRST_SEVEN2(a,b,c,d,e,f,g,...) a,b,c,d,e,f,g -#define FIRST_SEVEN(...) PASSTHROUGH(FIRST_SEVEN2(__VA_ARGS__)) +#define FIRST_SEVEN(...) FF_MSVC_EXPAND(FIRST_SEVEN2(__VA_ARGS__)) #define TIMES_SEVEN(a) a,a,a,a,a,a,a #if FF_API_PARSER_PRIVATE -- 2.49.1 >From fa959bb135bf95edc0f4bcc7ab8c327532f64694 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sat, 1 Nov 2025 18:48:17 +0100 Subject: [PATCH 2/2] avcodec/parsers: Silence deprecation warnings Slipped through because Clang (in contrast to GCC) does not warn about this. Signed-off-by: Andreas Rheinhardt --- libavcodec/parsers.c | 4 1 file changed, 4 insertions(+) diff --git a/libavcodec/parsers.c b/libavcodec/parsers.c index c3460a3b86..cae1f7213e 100644 --- a/libavcodec/parsers.c +++ b/libavcodec/parsers.c @@ -22,8 +22,11 @@ #include "parser_internal.h" #if FF_API_PARSER_PRIVATE +#include "libavutil/internal.h" #include #include + +FF_DISABLE_DEPRECATION_WARNINGS #define CHECK_OFFSET(field, public_prefix) static_assert(offsetof(FFCodecParser, field) == offsetof(FFCodecParser, p.public_prefix ## field), "Wrong offsets") CHECK_OFFSET(codec_ids,); CHECK_OFFSET(priv_data_size,); @@ -31,6 +34,7 @@ CHECK_OFFSET(init, parser_); CHECK_OFFSET(parse, parser_); CHECK_OFFSET(close, parser_); CHECK_OFFSET(split,); +FF_ENABLE_DEPRECATION_WARNINGS #endif extern const FFCodecParser ff_aac_parser; -- 2.49.1 ___ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] h264chroma (PR #20813)
PR #20813 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20813
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20813.patch
>From f3d54991d9243bd5065d22c4424628ff8972f1c4 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Thu, 30 Oct 2025 15:40:02 +0100
Subject: [PATCH 1/4] avcodec/h264chroma: Move mc1 function to mpegvideo_dec.c
It is only used by mpegvideo decoders (for lowres). It is also only used
for bitdepth == 8, so don't build the bitdepth == 16 function at all any
more.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/h264chroma.c | 2 --
libavcodec/h264chroma_template.c | 34 --
libavcodec/mpegvideo_dec.c | 41
tests/checkasm/h264chroma.c | 2 +-
4 files changed, 42 insertions(+), 37 deletions(-)
diff --git a/libavcodec/h264chroma.c b/libavcodec/h264chroma.c
index 1eeab7bc40..5000c89aa7 100644
--- a/libavcodec/h264chroma.c
+++ b/libavcodec/h264chroma.c
@@ -32,11 +32,9 @@
c->put_h264_chroma_pixels_tab[0] = put_h264_chroma_mc8_ ## depth ## _c; \
c->put_h264_chroma_pixels_tab[1] = put_h264_chroma_mc4_ ## depth ## _c; \
c->put_h264_chroma_pixels_tab[2] = put_h264_chroma_mc2_ ## depth ## _c; \
-c->put_h264_chroma_pixels_tab[3] = put_h264_chroma_mc1_ ## depth ## _c; \
c->avg_h264_chroma_pixels_tab[0] = avg_h264_chroma_mc8_ ## depth ## _c; \
c->avg_h264_chroma_pixels_tab[1] = avg_h264_chroma_mc4_ ## depth ## _c; \
c->avg_h264_chroma_pixels_tab[2] = avg_h264_chroma_mc2_ ## depth ## _c; \
-c->avg_h264_chroma_pixels_tab[3] = avg_h264_chroma_mc1_ ## depth ## _c; \
av_cold void ff_h264chroma_init(H264ChromaContext *c, int bit_depth)
{
diff --git a/libavcodec/h264chroma_template.c b/libavcodec/h264chroma_template.c
index b9d24f5a0c..b58be192cd 100644
--- a/libavcodec/h264chroma_template.c
+++ b/libavcodec/h264chroma_template.c
@@ -26,40 +26,6 @@
#include "bit_depth_template.c"
#define H264_CHROMA_MC(OPNAME, OP)\
-static void FUNCC(OPNAME ## h264_chroma_mc1)(uint8_t *_dst /*align 8*/, const
uint8_t *_src /*align 1*/, ptrdiff_t stride, int h, int x, int y){\
-pixel *dst = (pixel*)_dst;\
-const pixel *src = (const pixel*)_src;\
-const int A=(8-x)*(8-y);\
-const int B=( x)*(8-y);\
-const int C=(8-x)*( y);\
-const int D=( x)*( y);\
-int i;\
-stride >>= sizeof(pixel)-1;\
-\
-av_assert2(x<8 && y<8 && x>=0 && y>=0);\
-\
-if(D){\
-for(i=0; i= 0 && y >= 0);\
+\
+if (D) {\
+for (int i = 0; i < h; ++i) {\
+OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] +
D*src[stride+1]));\
+dst += stride;\
+src += stride;\
+}\
+} else if (B + C) {\
+const int E= B + C;\
+const int step = C ? stride : 1;\
+for (int i = 0; i < h; ++i) {\
+OP(dst[0], (A*src[0] + E*src[step+0]));\
+dst += stride;\
+src += stride;\
+}\
+} else {\
+for (int i = 0; i < h; ++i) {\
+OP(dst[0], (A*src[0]));\
+dst += stride;\
+src += stride;\
+}\
+}\
+}\
+
+#define op_avg(a, b) a = (((a)+(((b) + 32)>>6)+1)>>1)
+#define op_put(a, b) a = (((b) + 32)>>6)
+
+H264_CHROMA_MC(put_, op_put)
+H264_CHROMA_MC(avg_, op_avg)
+
av_cold int ff_mpv_decode_init(MpegEncContext *s, AVCodecContext *avctx)
{
enum ThreadingStatus thread_status;
@@ -62,6 +101,8 @@ av_cold int ff_mpv_decode_init(MpegEncContext *s,
AVCodecContext *avctx)
ff_mpv_idct_init(s);
ff_h264chroma_init(&s->h264chroma, 8); //for lowres
+s->h264chroma.avg_h264_chroma_pixels_tab[3] = avg_h264_chroma_mc1;
+s->h264chroma.put_h264_chroma_pixels_tab[3] = put_h264_chroma_mc1;
if (s->picture_pool) // VC-1 can call this multiple times
return 0;
diff --git a/tests/checkasm/h264chroma.c b/tests/checkasm/h264chroma.c
index 9579fceab7..52aa220152 100644
--- a/tests/checkasm/h264chroma.c
+++ b/tests/checkasm/h264chroma.c
@@ -51,7 +51,7 @@ static void check_chroma_mc(void)
for (int bit_depth = 8; bit_depth <= 10; bit_depth++) {
ff_h264chroma_init(&h, bit_depth);
randomize_buffers(bit_depth);
-for (int size = 0; size < 4; size++) {
+for (int size = 0; size < 3; size++) {
#define CHECK_CHROMA_MC(name)
\
do {
\
--
2.49.1
>From 392026641d525d8df0b5fff01102de98d9e4097b Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Sat, 1 Nov 2025 11:27:22 +0100
Subject: [PATCH 2/4] configure: Add config_components.asm
This is in preparation for the next commit.
Signed-off-by: Andreas Rheinhardt
---
configure | 7 +--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/configure b/configure
index 3b132d07c9..17f72b735e 100755
--- a/configure
+++ b/conf
[FFmpeg-devel] [PATCH] avcodec/fflcms2: Don't access inexistent array elements (PR #20780)
PR #20780 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20780
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20780.patch
This would happen if one of the extended transfer characteristics is in
use (currently only AVCOL_TRC_V_LOG).
This issue has actually been pointed out in the review.
>From 0941646182ba59daa452885f508b87bef2090e46 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Tue, 28 Oct 2025 21:40:50 +0100
Subject: [PATCH] avcodec/fflcms2: Don't access inexistent array elements
This would happen if one of the extended transfer characteristics is in
use (currently only AVCOL_TRC_V_LOG).
Signed-off-by: Andreas Rheinhardt
---
libavcodec/fflcms2.c | 5 +
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/libavcodec/fflcms2.c b/libavcodec/fflcms2.c
index c7b944a02f..3c7f3dc07f 100644
--- a/libavcodec/fflcms2.c
+++ b/libavcodec/fflcms2.c
@@ -50,10 +50,7 @@ void ff_icc_context_uninit(FFIccContext *s)
static int get_curve(FFIccContext *s, enum AVColorTransferCharacteristic trc,
cmsToneCurve **out_curve)
{
-if ((trc >= AVCOL_TRC_NB && trc < AVCOL_TRC_EXT_BASE) || trc >=
AVCOL_TRC_EXT_NB)
-return AVERROR_INVALIDDATA;
-
-if (s->curves[trc])
+if ((unsigned)trc < AVCOL_TRC_NB && s->curves[trc])
goto done;
switch (trc) {
--
2.49.1
___
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] avcodec/x86/me_cmp: Avoid MMX in (n)sse (PR #20822)
PR #20822 opened by mkver URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20822 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20822.patch >From 8c9f4f695859f018109294b6712b9f97eb777ed6 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 2 Nov 2025 17:43:10 +0100 Subject: [PATCH 1/5] avcodec/x86/me_cmp: Avoid unnecessary instruction Signed-off-by: Andreas Rheinhardt --- libavcodec/x86/me_cmp.asm | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libavcodec/x86/me_cmp.asm b/libavcodec/x86/me_cmp.asm index 7825c8ef71..cf4ee941f7 100644 --- a/libavcodec/x86/me_cmp.asm +++ b/libavcodec/x86/me_cmp.asm @@ -282,9 +282,6 @@ HADAMARD8_DIFF 9 %macro SUM_SQUARED_ERRORS 1 cglobal sse%1, 5,5,8, v, pix1, pix2, lsize, h -%if %1 == mmsize -shr hd, 1 -%endif pxor m0, m0 ; mm0 = 0 pxor m7, m7 ; mm7 holds the sum @@ -334,11 +331,12 @@ cglobal sse%1, 5,5,8, v, pix1, pix2, lsize, h %if %1 == mmsize leapix1q, [pix1q + 2*lsizeq] leapix2q, [pix2q + 2*lsizeq] +sub hd, 2 %else addpix1q, lsizeq addpix2q, lsizeq -%endif dec hd +%endif jnz .next2lines HADDD m7, m1 -- 2.49.1 >From 205a0e1a49d168fd07c55d152b6fc5fc0706aeb8 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 2 Nov 2025 17:50:15 +0100 Subject: [PATCH 2/5] avcodec/x86/me_cmp: Rename registers This will avoid using xmm registers that are volatile for Win64 in the next commit. Signed-off-by: Andreas Rheinhardt --- libavcodec/x86/me_cmp.asm | 18 +- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libavcodec/x86/me_cmp.asm b/libavcodec/x86/me_cmp.asm index cf4ee941f7..03db905346 100644 --- a/libavcodec/x86/me_cmp.asm +++ b/libavcodec/x86/me_cmp.asm @@ -283,7 +283,7 @@ HADAMARD8_DIFF 9 %macro SUM_SQUARED_ERRORS 1 cglobal sse%1, 5,5,8, v, pix1, pix2, lsize, h pxor m0, m0 ; mm0 = 0 -pxor m7, m7 ; mm7 holds the sum +pxor m5, m5 ; m5 holds the sum .next2lines: ; FIXME why are these unaligned movs? pix1[] is aligned movu m1, [pix1q]; m1 = pix1[0][0-15], [0-7] for mmx @@ -299,12 +299,12 @@ cglobal sse%1, 5,5,8, v, pix1, pix2, lsize, h ; todo: mm1-mm2, mm3-mm4 ; algo: subtract mm1 from mm2 with saturation and vice versa ; OR the result to get the absolute difference -mova m5, m1 -mova m6, m3 +mova m6, m1 +mova m7, m3 psubusb m1, m2 psubusb m3, m4 -psubusb m2, m5 -psubusb m4, m6 +psubusb m2, m6 +psubusb m4, m7 por m2, m1 por m4, m3 @@ -325,8 +325,8 @@ cglobal sse%1, 5,5,8, v, pix1, pix2, lsize, h paddd m1, m2 paddd m3, m4 -paddd m7, m1 -paddd m7, m3 +paddd m5, m1 +paddd m5, m3 %if %1 == mmsize leapix1q, [pix1q + 2*lsizeq] @@ -339,8 +339,8 @@ cglobal sse%1, 5,5,8, v, pix1, pix2, lsize, h %endif jnz .next2lines -HADDD m7, m1 -movd eax, m7 ; return value +HADDD m5, m1 +movd eax, m5 ; return value RET %endmacro -- 2.49.1 >From d2e5fe5863476a420ae97c07e37e4003d6af3d61 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 2 Nov 2025 18:02:27 +0100 Subject: [PATCH 3/5] avcodec/x86/me_cmp: Add ff_sse8_sse2() Benchmarks: sse_1_c:51.9 ( 1.00x) sse_1_mmx: 16.5 ( 3.15x) sse_1_sse2: 9.7 ( 5.36x) Signed-off-by: Andreas Rheinhardt --- libavcodec/x86/me_cmp.asm| 20 ++-- libavcodec/x86/me_cmp_init.c | 3 +++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/libavcodec/x86/me_cmp.asm b/libavcodec/x86/me_cmp.asm index 03db905346..57a09a2b75 100644 --- a/libavcodec/x86/me_cmp.asm +++ b/libavcodec/x86/me_cmp.asm @@ -281,11 +281,25 @@ HADAMARD8_DIFF 9 ; ptrdiff_t line_size, int h) %macro SUM_SQUARED_ERRORS 1 -cglobal sse%1, 5,5,8, v, pix1, pix2, lsize, h +cglobal sse%1, 5,5,%1 < mmsize ? 6 : 8, v, pix1, pix2, lsize, h pxor m0, m0 ; mm0 = 0 pxor m5, m5 ; m5 holds the sum .next2lines: ; FIXME why are these unaligned movs? pix1[] is aligned +%if %1 < mmsize +movh m1, [pix1q] +movh m2, [pix2q] +movh m3, [pix1q+lsizeq] +movh m4, [pix2q+lsizeq] +punpcklbw m1, m0 +punpcklbw m2, m0 +punpcklbw m3, m0 +punpcklbw m4, m0 +psubw m1, m2 +psubw m3, m4 +pmaddwd m1, m1 +pmaddwd m3, m3 +%else movu m1, [pix1q]; m1 = pix1[0][0-15], [0-7] for mmx movu m2, [pix2q]; m2 = pix2[0][0-15], [0-7] for mmx %if %1 == mmsize @@ -325,10 +339,11 @@ cglobal sse%1, 5,5,8, v, pix1, pix2, lsize, h paddd m1, m2 paddd m3, m4 +%endif paddd m5,
[FFmpeg-devel] [PATCH] avcodec/x86/mpegvideoencdsp_init: Fix left shift of negative number (PR #20733)
PR #20733 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20733
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20733.patch
Uncovered by UBSan when running the mpegvideoencdsp checkasm
test.
Will apply this tonight unless there are objections.
>From 05b8608c76e76b7d8b4ce5e86e0940244fbb737e Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Tue, 21 Oct 2025 12:11:55 +0200
Subject: [PATCH] avcodec/x86/mpegvideoencdsp_init: Fix left shift of negative
number
Uncovered by UBSan when running the mpegvideoencdsp checkasm
test.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/x86/mpegvideoencdsp_init.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavcodec/x86/mpegvideoencdsp_init.c
b/libavcodec/x86/mpegvideoencdsp_init.c
index 3cd16fefbf..bf5b722016 100644
--- a/libavcodec/x86/mpegvideoencdsp_init.c
+++ b/libavcodec/x86/mpegvideoencdsp_init.c
@@ -42,7 +42,7 @@ static int try_8x8basis_ssse3(const int16_t rem[64], const
int16_t weight[64], c
x86_reg i=0;
av_assert2(FFABS(scale) < MAX_ABS);
-scale <<= 16 + SCALE_OFFSET - BASIS_SHIFT + RECON_SHIFT;
+scale *= 1 << (16 + SCALE_OFFSET - BASIS_SHIFT + RECON_SHIFT);
__asm__ volatile(
"pxor%%xmm2, %%xmm2 \n\t"
@@ -87,7 +87,7 @@ static void add_8x8basis_ssse3(int16_t rem[64], const int16_t
basis[64], int sca
x86_reg i=0;
if (FFABS(scale) < 1024) {
-scale <<= 16 + SCALE_OFFSET - BASIS_SHIFT + RECON_SHIFT;
+scale *= 1 << (16 + SCALE_OFFSET - BASIS_SHIFT + RECON_SHIFT);
__asm__ volatile(
"movd%3, %%xmm2 \n\t"
"punpcklwd %%xmm2, %%xmm2 \n\t"
--
2.49.1
___
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] Remove some 3dnow remnants (PR #20748)
PR #20748 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20748
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20748.patch
>From 9a9edd8024bb57fcda318ba5e3f73f8a85611466 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Sat, 25 Oct 2025 07:04:39 +0200
Subject: [PATCH 1/2] configure: Remove 3dnow
The last 3dnow functions have been removed in commit
5ef613bcb0508f16bd5b190168183326391de9b0. So remove 3dnow
from configure; the only thing kept is that --disable-amd3dnow
is still accepted, but no longer advertised by --help.
Signed-off-by: Andreas Rheinhardt
---
configure | 6 --
1 file changed, 6 deletions(-)
diff --git a/configure b/configure
index 9052f18bb9..0667083a3e 100755
--- a/configure
+++ b/configure
@@ -452,8 +452,6 @@ Optimization options (experts only):
--disable-altivecdisable AltiVec optimizations
--disable-vsxdisable VSX optimizations
--disable-power8 disable POWER8 optimizations
- --disable-amd3dnow disable 3DNow! optimizations
- --disable-amd3dnowextdisable 3DNow! extended optimizations
--disable-mmxdisable MMX optimizations
--disable-mmxext disable MMXEXT optimizations
--disable-ssedisable SSE optimizations
@@ -2861,8 +2859,6 @@ simd128_deps="wasm"
x86_64_select="i686"
x86_64_suggest="fast_cmov"
-amd3dnow_deps="mmx"
-amd3dnowext_deps="amd3dnow"
i686_deps="x86"
mmx_deps="x86"
mmxext_deps="mmx"
@@ -8177,8 +8173,6 @@ if enabled x86; then
echo "x86 assembler ${x86asmexe}"
echo "MMX enabled ${mmx-no}"
echo "MMXEXT enabled${mmxext-no}"
-echo "3DNow! enabled${amd3dnow-no}"
-echo "3DNow! extended enabled ${amd3dnowext-no}"
echo "SSE enabled ${sse-no}"
echo "SSSE3 enabled ${ssse3-no}"
echo "AESNI enabled ${aesni-no}"
--
2.49.1
>From 7b5b29910ad39e8666f41ccc64cfb4064f4e08f6 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Sat, 25 Oct 2025 07:27:11 +0200
Subject: [PATCH 2/2] avutil/x86/cpu: Remove 3dnow flags, macros
Unused since 5ef613bcb0508f16bd5b190168183326391de9b0.
Signed-off-by: Andreas Rheinhardt
---
libavutil/x86/cpu.h | 9 -
1 file changed, 9 deletions(-)
diff --git a/libavutil/x86/cpu.h b/libavutil/x86/cpu.h
index 40a1eef0ab..00e82255b1 100644
--- a/libavutil/x86/cpu.h
+++ b/libavutil/x86/cpu.h
@@ -22,11 +22,6 @@
#include "libavutil/cpu.h"
#include "libavutil/cpu_internal.h"
-#define AV_CPU_FLAG_AMD3DNOWAV_CPU_FLAG_3DNOW
-#define AV_CPU_FLAG_AMD3DNOWEXT AV_CPU_FLAG_3DNOWEXT
-
-#define X86_AMD3DNOW(flags) CPUEXT(flags, AMD3DNOW)
-#define X86_AMD3DNOWEXT(flags) CPUEXT(flags, AMD3DNOWEXT)
#define X86_MMX(flags) CPUEXT(flags, MMX)
#define X86_MMXEXT(flags) CPUEXT(flags, MMXEXT)
#define X86_SSE(flags) CPUEXT(flags, SSE)
@@ -51,8 +46,6 @@
#define X86_AESNI(flags)CPUEXT(flags, AESNI)
#define X86_AVX512(flags) CPUEXT(flags, AVX512)
-#define EXTERNAL_AMD3DNOW(flags)CPUEXT_SUFFIX(flags, _EXTERNAL, AMD3DNOW)
-#define EXTERNAL_AMD3DNOWEXT(flags) CPUEXT_SUFFIX(flags, _EXTERNAL,
AMD3DNOWEXT)
#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)
@@ -82,8 +75,6 @@
#define EXTERNAL_AVX512(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, AVX512)
#define EXTERNAL_AVX512ICL(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, AVX512ICL)
-#define INLINE_AMD3DNOW(flags) CPUEXT_SUFFIX(flags, _INLINE, AMD3DNOW)
-#define INLINE_AMD3DNOWEXT(flags) CPUEXT_SUFFIX(flags, _INLINE, AMD3DNOWEXT)
#define INLINE_MMX(flags) CPUEXT_SUFFIX(flags, _INLINE, MMX)
#define INLINE_MMXEXT(flags)CPUEXT_SUFFIX(flags, _INLINE, MMXEXT)
#define INLINE_SSE(flags) CPUEXT_SUFFIX(flags, _INLINE, SSE)
--
2.49.1
___
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] avcodec/x86/hevc/idct: Port ff_hevc_idct_4x4_dc_{8,10,12}_mmxext to SSE2 (PR #20788)
PR #20788 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20788
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20788.patch
Practically no change in benchmarks (and in codesize).
hevc_idct_4x4_dc_8_c:7.8 ( 1.00x)
hevc_idct_4x4_dc_8_mmxext: 6.9 ( 1.14x)
hevc_idct_4x4_dc_8_sse2: 6.8 ( 1.15x)
hevc_idct_4x4_dc_10_c: 7.9 ( 1.00x)
hevc_idct_4x4_dc_10_mmxext: 6.9 ( 1.16x)
hevc_idct_4x4_dc_10_sse2:6.8 ( 1.16x)
hevc_idct_4x4_dc_12_c: 7.8 ( 1.00x)
hevc_idct_4x4_dc_12_mmxext: 7.0 ( 1.13x)
hevc_idct_4x4_dc_12_sse2:6.8 ( 1.15x)
>From e81edabc4d6dfb825e6432da48a0a827b69e6ade Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Thu, 30 Oct 2025 00:07:42 +0100
Subject: [PATCH] avcodec/x86/hevc/idct: Port
ff_hevc_idct_4x4_dc_{8,10,12}_mmxext to SSE2
Practically no change in benchmarks (and in codesize).
hevc_idct_4x4_dc_8_c:7.8 ( 1.00x)
hevc_idct_4x4_dc_8_mmxext: 6.9 ( 1.14x)
hevc_idct_4x4_dc_8_sse2: 6.8 ( 1.15x)
hevc_idct_4x4_dc_10_c: 7.9 ( 1.00x)
hevc_idct_4x4_dc_10_mmxext: 6.9 ( 1.16x)
hevc_idct_4x4_dc_10_sse2:6.8 ( 1.16x)
hevc_idct_4x4_dc_12_c: 7.8 ( 1.00x)
hevc_idct_4x4_dc_12_mmxext: 7.0 ( 1.13x)
hevc_idct_4x4_dc_12_sse2:6.8 ( 1.15x)
Signed-off-by: Andreas Rheinhardt
---
libavcodec/x86/hevc/dsp_init.c | 11 ---
libavcodec/x86/hevc/idct.asm | 19 ++-
tests/checkasm/hevc_idct.c | 2 +-
3 files changed, 11 insertions(+), 21 deletions(-)
diff --git a/libavcodec/x86/hevc/dsp_init.c b/libavcodec/x86/hevc/dsp_init.c
index ba921e7299..6966340c42 100644
--- a/libavcodec/x86/hevc/dsp_init.c
+++ b/libavcodec/x86/hevc/dsp_init.c
@@ -65,7 +65,7 @@ void ff_hevc_idct_ ## W ## _dc_8_ ## opt(int16_t *coeffs); \
void ff_hevc_idct_ ## W ## _dc_10_ ## opt(int16_t *coeffs); \
void ff_hevc_idct_ ## W ## _dc_12_ ## opt(int16_t *coeffs)
-IDCT_DC_FUNCS(4x4, mmxext);
+IDCT_DC_FUNCS(4x4, sse2);
IDCT_DC_FUNCS(8x8, sse2);
IDCT_DC_FUNCS(16x16, sse2);
IDCT_DC_FUNCS(32x32, sse2);
@@ -816,8 +816,6 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int
bit_depth)
if (bit_depth == 8) {
if (EXTERNAL_MMXEXT(cpu_flags)) {
-c->idct_dc[0] = ff_hevc_idct_4x4_dc_8_mmxext;
-
c->add_residual[0] = ff_hevc_add_residual_4_8_mmxext;
}
if (EXTERNAL_SSE2(cpu_flags)) {
@@ -832,6 +830,7 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int
bit_depth)
}
SAO_BAND_INIT(8, sse2);
+c->idct_dc[0] = ff_hevc_idct_4x4_dc_8_sse2;
c->idct_dc[1] = ff_hevc_idct_8x8_dc_8_sse2;
c->idct_dc[2] = ff_hevc_idct_16x16_dc_8_sse2;
c->idct_dc[3] = ff_hevc_idct_32x32_dc_8_sse2;
@@ -998,7 +997,6 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int
bit_depth)
} else if (bit_depth == 10) {
if (EXTERNAL_MMXEXT(cpu_flags)) {
c->add_residual[0] = ff_hevc_add_residual_4_10_mmxext;
-c->idct_dc[0] = ff_hevc_idct_4x4_dc_10_mmxext;
}
if (EXTERNAL_SSE2(cpu_flags)) {
c->hevc_v_loop_filter_chroma =
ff_hevc_v_loop_filter_chroma_10_sse2;
@@ -1013,6 +1011,7 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int
bit_depth)
SAO_BAND_INIT(10, sse2);
SAO_EDGE_INIT(10, sse2);
+c->idct_dc[0] = ff_hevc_idct_4x4_dc_10_sse2;
c->idct_dc[1] = ff_hevc_idct_8x8_dc_10_sse2;
c->idct_dc[2] = ff_hevc_idct_16x16_dc_10_sse2;
c->idct_dc[3] = ff_hevc_idct_32x32_dc_10_sse2;
@@ -1218,9 +1217,6 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int
bit_depth)
}
#endif /* HAVE_AVX2_EXTERNAL */
} else if (bit_depth == 12) {
-if (EXTERNAL_MMXEXT(cpu_flags)) {
-c->idct_dc[0] = ff_hevc_idct_4x4_dc_12_mmxext;
-}
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;
@@ -1231,6 +1227,7 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int
bit_depth)
SAO_BAND_INIT(12, sse2);
SAO_EDGE_INIT(12, sse2);
+c->idct_dc[0] = ff_hevc_idct_4x4_dc_12_sse2;
c->idct_dc[1] = ff_hevc_idct_8x8_dc_12_sse2;
c->idct_dc[2] = ff_hevc_idct_16x16_dc_12_sse2;
c->idct_dc[3] = ff_hevc_idct_32x32_dc_12_sse2;
diff --git a/libavcodec/x86/hevc/idc
[FFmpeg-devel] [PATCH] WIP, RFC: Avoid reliance on DCE (PR #20793)
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
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
---
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
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
---
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, S
[FFmpeg-devel] [PATCH] avcodec/h264idct_template: Deduplicate h264_{luma,chroma}_dc_dequant_idct (PR #20874)
PR #20874 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20874
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20874.patch
>From 0b211afaedb40de46b1fd871496b16ba0da3f6c1 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Sun, 9 Nov 2025 14:30:00 +0100
Subject: [PATCH 1/2] avcodec/bit_depth_template: Add PIXELSIZE
Sometimes functions for bit depth 9..16 are the same (because they
actually only depend on the underlying pixel type). The macros added
here allow to support this usecase.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/bit_depth_template.c | 4
1 file changed, 4 insertions(+)
diff --git a/libavcodec/bit_depth_template.c b/libavcodec/bit_depth_template.c
index ca5037148a..6a80cdaf32 100644
--- a/libavcodec/bit_depth_template.c
+++ b/libavcodec/bit_depth_template.c
@@ -43,11 +43,13 @@
# undef FUNCC
# undef av_clip_pixel
# undef PIXEL_SPLAT_X4
+# undef PIXELSIZE
#else
# define AVCODEC_BIT_DEPTH_TEMPLATE_C
#endif
#if BIT_DEPTH > 8
+# define PIXELSIZE 16
# define pixel uint16_t
# define pixel2 uint32_t
# define pixel4 uint64_t
@@ -76,6 +78,7 @@
# define av_clip_pixel(a) av_clip_uintp2(a, BIT_DEPTH)
# define CLIP(a) av_clip_uintp2(a, BIT_DEPTH)
#else
+# define PIXELSIZE 8
# define pixel uint8_t
# define pixel2 uint16_t
# define pixel4 uint32_t
@@ -100,6 +103,7 @@
#define FUNC2(a, b, c) FUNC3(a, b, c)
#define FUNC(a) FUNC2(a, BIT_DEPTH,)
#define FUNCC(a) FUNC2(a, BIT_DEPTH, _c)
+#define FUNCC2(a) FUNC2(a, PIXELSIZE, _c)
#define FUNC4(a, b, c) a ## _int ## b ## _ ## c ## bit
#define FUNC5(a, b, c) FUNC4(a, b, c)
#define FUNC6(a) FUNC5(a, IN_IDCT_DEPTH, BIT_DEPTH)
--
2.49.1
>From 5d99c5529ecade161610af37f9e4a9daa5aba2d5 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Sun, 9 Nov 2025 14:41:16 +0100
Subject: [PATCH 2/2] avcodec/h264idct_template: Deduplicate
h264_{luma,chroma}_dc_dequant_idct
All the high bit depth functions of these types are identical.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/h264dsp.c | 16
libavcodec/h264idct.h | 11 ---
libavcodec/h264idct_template.c | 11 ---
3 files changed, 24 insertions(+), 14 deletions(-)
diff --git a/libavcodec/h264dsp.c b/libavcodec/h264dsp.c
index 1ba936be1c..8a6a3f5325 100644
--- a/libavcodec/h264dsp.c
+++ b/libavcodec/h264dsp.c
@@ -69,14 +69,19 @@ av_cold void ff_h264dsp_init(H264DSPContext *c, const int
bit_depth,
#undef FUNC
#define FUNC(a, depth) a ## _ ## depth ## _c
-#define ADDPX_DSP(depth) \
+#define SET_PIXSIZE_FUNCS(depth) \
+c->h264_luma_dc_dequant_idct= FUNC(ff_h264_luma_dc_dequant_idct, depth);\
+if (chroma_format_idc <= 1)\
+c->h264_chroma_dc_dequant_idct= FUNC(ff_h264_chroma_dc_dequant_idct,
depth);\
+else\
+c->h264_chroma_dc_dequant_idct=
FUNC(ff_h264_chroma422_dc_dequant_idct, depth);\
c->h264_add_pixels4_clear = FUNC(ff_h264_add_pixels4, depth);\
c->h264_add_pixels8_clear = FUNC(ff_h264_add_pixels8, depth)
if (bit_depth > 8 && bit_depth <= 16) {
-ADDPX_DSP(16);
+SET_PIXSIZE_FUNCS(16);
} else {
-ADDPX_DSP(8);
+SET_PIXSIZE_FUNCS(8);
}
#define H264_DSP(depth) \
@@ -91,11 +96,6 @@ av_cold void ff_h264dsp_init(H264DSPContext *c, const int
bit_depth,
else\
c->h264_idct_add8 = FUNC(ff_h264_idct_add8_422, depth);\
c->h264_idct_add16intra= FUNC(ff_h264_idct_add16intra, depth);\
-c->h264_luma_dc_dequant_idct= FUNC(ff_h264_luma_dc_dequant_idct, depth);\
-if (chroma_format_idc <= 1)\
-c->h264_chroma_dc_dequant_idct= FUNC(ff_h264_chroma_dc_dequant_idct,
depth);\
-else\
-c->h264_chroma_dc_dequant_idct=
FUNC(ff_h264_chroma422_dc_dequant_idct, depth);\
\
c->weight_h264_pixels_tab[0]= FUNC(weight_h264_pixels16, depth);\
c->weight_h264_pixels_tab[1]= FUNC(weight_h264_pixels8, depth);\
diff --git a/libavcodec/h264idct.h b/libavcodec/h264idct.h
index 6f18df9e5f..42e93ed17a 100644
--- a/libavcodec/h264idct.h
+++ b/libavcodec/h264idct.h
@@ -31,9 +31,6 @@ void ff_h264_idct_add16intra_ ## depth ## _c(uint8_t *dst,
const int *blockoffse
void ff_h264_idct8_add4_ ## depth ## _c(uint8_t *dst, const int *blockoffset,
int16_t *block, int stride, const uint8_t nnzc[5 * 8]);\
void ff_h264_idct_add8_422_ ## depth ## _c(uint8_t **dest, const int
*blockoffset, int16_t *block, int stride, const uint8_t nnzc[15 * 8]);\
void ff_h264_idct_add8_ ## depth ## _c(uint8_t **dest, const int *blockoffset,
int16_t *block, int stride, const uint8_t nnzc[15 * 8]);\
-void ff_h264_luma_dc_dequant_idct_ ## depth ## _c(int16_t *output, int16_t
*input, int qmul);\
-void ff_h264_chroma422_dc_dequant_idct_ ## depth ## _c(int16_t *block, int
qmul);\
-void ff_h264_chroma_dc_dequant_idct_ ## depth ## _c(int16_t *block, int qmul);
H264_IDCT( 8)
H264_IDCT( 9)
@@ -41,4 +38,12 @@ H264_IDCT(10)
H264_IDCT(12)
H264_IDCT(14)
+#define H264_IDCT2(pi
[FFmpeg-devel] [PATCH] configure: Add mxpeg->hpeldsp dependency (PR #20741)
PR #20741 opened by mkver URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20741 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20741.patch Forgotten in 124c856d389af4ca1f6ac914271a892762df269d. >From 0b81f8624e0b23c3edaab2889a5640feb4c13c1d Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Thu, 23 Oct 2025 15:17:47 +0200 Subject: [PATCH] configure: Add mxpeg->hpeldsp dependency Forgotten in 124c856d389af4ca1f6ac914271a892762df269d. Signed-off-by: Andreas Rheinhardt --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 39e69d217d..9052f18bb9 100755 --- a/configure +++ b/configure @@ -3126,7 +3126,7 @@ mts2_decoder_select="jpegtables mss34dsp" mv30_decoder_select="aandcttables blockdsp" mvha_decoder_select="inflate_wrapper llviddsp" mwsc_decoder_select="inflate_wrapper" -mxpeg_decoder_select="mjpeg_decoder" +mxpeg_decoder_select="hpeldsp mjpeg_decoder" nellymoser_decoder_select="sinewin" nellymoser_encoder_select="audio_frame_queue sinewin" notchlc_decoder_select="lzf" -- 2.49.1 ___ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] avutil/timecode: Fix -Wformat-truncation warning (PR #20860)
PR #20860 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20860
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20860.patch
Using unsigned for fps more natural since the corresponding AVTimecode field
is unsigned and fixes a -Wformat-truncation warning from GCC 16:
in case fps were negative, the hours, minutes and seconds would
be negative, leading to an additional '-' which is not accounted for in
AV_TIMECODE_STR_SIZE.
Replaces #20859.
>From 6593f517fbfc3b8fef8f61ff0af2e4baed5fafc9 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Sat, 8 Nov 2025 00:52:03 +0100
Subject: [PATCH] avutil/timecode: Fix -Wformat-truncation warning
Using unsigned for fps more natural since the corresponding AVTimecode field
is unsigned and fixes a -Wformat-truncation warning from GCC 16:
in case fps were negative, the hours, minutes and seconds would
be negative, leading to an additional '-' which is not accounted for in
AV_TIMECODE_STR_SIZE.
Signed-off-by: Andreas Rheinhardt
---
libavutil/timecode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavutil/timecode.c b/libavutil/timecode.c
index bca16b6ac2..b5352a3961 100644
--- a/libavutil/timecode.c
+++ b/libavutil/timecode.c
@@ -103,7 +103,7 @@ uint32_t av_timecode_get_smpte(AVRational rate, int drop,
int hh, int mm, int ss
char *av_timecode_make_string(const AVTimecode *tc, char *buf, int
framenum_arg)
{
-int fps = tc->fps;
+unsigned fps = tc->fps;
int drop = tc->flags & AV_TIMECODE_FLAG_DROPFRAME;
int hh, mm, ss, ff, ff_len, neg = 0;
int64_t framenum = framenum_arg;
--
2.49.1
___
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] Avoid av_unused (PR #20866)
PR #20866 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20866
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20866.patch
>From 41631b48d2392f83130c734b26f7c9fdb8415f5a Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Sat, 8 Nov 2025 17:02:13 +0100
Subject: [PATCH 1/2] swresample/swresample: Avoid av_unused
Possible now that -Wdeclaration-after-statement is no longer used.
Signed-off-by: Andreas Rheinhardt
---
libswresample/swresample.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/libswresample/swresample.c b/libswresample/swresample.c
index 40485a019c..e7ce4a10aa 100644
--- a/libswresample/swresample.c
+++ b/libswresample/swresample.c
@@ -720,14 +720,13 @@ int attribute_align_arg swr_convert(struct SwrContext *s,
{
AudioData * in= &s->in;
AudioData *out= &s->out;
-av_unused int max_output;
if (!swr_is_initialized(s)) {
av_log(s, AV_LOG_ERROR, "Context has not been initialized\n");
return AVERROR(EINVAL);
}
#if defined(ASSERT_LEVEL) && ASSERT_LEVEL >1
-max_output = swr_get_out_samples(s, in_count);
+int max_output = swr_get_out_samples(s, in_count);
#endif
while(s->drop_output > 0){
--
2.49.1
>From 6e02e7f5fea48b945ef7abece00d610350b6d079 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Sat, 8 Nov 2025 17:15:57 +0100
Subject: [PATCH 2/2] avformat/mp3enc: Avoid av_unused
Possible now that -Wdeclaration-after-statement is no more.
Signed-off-by: Andreas Rheinhardt
---
libavformat/mp3enc.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
index 0ebd480d3f..724c7269dc 100644
--- a/libavformat/mp3enc.c
+++ b/libavformat/mp3enc.c
@@ -322,7 +322,6 @@ static int mp3_write_audio_packet(AVFormatContext *s,
AVPacket *pkt)
if (pkt->data && pkt->size >= 4) {
MPADecodeHeader mpah;
int ret;
-av_unused int base;
uint32_t h;
h = AV_RB32(pkt->data);
@@ -339,7 +338,7 @@ static int mp3_write_audio_packet(AVFormatContext *s,
AVPacket *pkt)
#ifdef FILTER_VBR_HEADERS
/* filter out XING and INFO headers. */
-base = 4 + xing_offtbl[mpah.lsf == 1][mpah.nb_channels == 1];
+int base = 4 + xing_offtbl[mpah.lsf == 1][mpah.nb_channels == 1];
if (base + 4 <= pkt->size) {
uint32_t v = AV_RB32(pkt->data + base);
--
2.49.1
___
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] avutil/cpu: Deprecate AV_CPU_FLAG_FORCE (PR #20911)
PR #20911 opened by mkver URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20911 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20911.patch This flag does nothing since the deactivation of the dsp_mask field of AVCodecContext in commits 9ae6ba288368be42dbd77613e07255d38bbba40e and 9ae6ba288368be42dbd77613e07255d38bbba40e (it has been superseded with better ways to override the CPU flags). So deprecate it. (Missing version bump in this patch.) >From 7b3aab3ba620eb7a470509b3dc7ccf61c813cd79 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Thu, 13 Nov 2025 14:16:30 +0100 Subject: [PATCH] avutil/cpu: Deprecate AV_CPU_FLAG_FORCE This flag does nothing since the deactivation of the dsp_mask field of AVCodecContext in commits 9ae6ba288368be42dbd77613e07255d38bbba40e and 9ae6ba288368be42dbd77613e07255d38bbba40e (it has been superseded with better ways to override the CPU flags). So deprecate it. Signed-off-by: Andreas Rheinhardt --- doc/APIchanges | 3 +++ libavutil/cpu.h | 4 +++- libavutil/version.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index 9d128ae77b..fafda4d063 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2025-03-28 API changes, most recent first: +2025-11-13 - xx - lavu 60.yy.100 - cpu.h + Deprecate AV_CPU_FLAG_FORCE without replacement. + 2025-11-01 - xx - lavc 62.19.100 - avcodec.h Schedule AVCodecParser and av_parser_init() to use enum AVCodecID for codec ids on the next major version bump. diff --git a/libavutil/cpu.h b/libavutil/cpu.h index 5ef5da58eb..a06fc08e56 100644 --- a/libavutil/cpu.h +++ b/libavutil/cpu.h @@ -24,7 +24,9 @@ #include #include "version.h" -#define AV_CPU_FLAG_FORCE0x8000 /* force usage of selected flags (OR) */ +#if FF_API_CPU_FLAG_FORCE +#define AV_CPU_FLAG_FORCE0x8000 /* @deprecated, should not be used */ +#endif /* lower 16 bits - CPU features */ #define AV_CPU_FLAG_MMX 0x0001 ///< standard MMX diff --git a/libavutil/version.h b/libavutil/version.h index b16b88bfca..4879f1e0c4 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -110,6 +110,7 @@ #define FF_API_VULKAN_FIXED_QUEUES (LIBAVUTIL_VERSION_MAJOR < 61) #define FF_API_OPT_INT_LIST (LIBAVUTIL_VERSION_MAJOR < 61) #define FF_API_OPT_PTR (LIBAVUTIL_VERSION_MAJOR < 61) +#define FF_API_CPU_FLAG_FORCE (LIBAVUTIL_VERSION_MAJOR < 61) /** * @} -- 2.49.1 ___ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] avfilter/vf_fspp: Add checkasm, port to SSE2, fix big-endian (PR #20909)
PR #20909 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20909
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20909.patch
>From 92fe3d96e6f9a3b169a3edcdb48ecdc543ba862e Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Sun, 9 Nov 2025 17:06:46 +0100
Subject: [PATCH 01/23] avfilter/vf_fspp: Add DSPCtx, move DSP functions to
file of their own
This is in preparation for adding checkasm tests; without it,
checkasm would pull all of libavfilter in.
Signed-off-by: Andreas Rheinhardt
---
libavfilter/Makefile| 2 +-
libavfilter/vf_fspp.c | 399 +++-
libavfilter/vf_fsppdsp.c| 369 ++
libavfilter/{vf_fspp.h => vf_fsppdsp.h} | 85 +++--
libavfilter/x86/vf_fspp_init.c | 4 +-
5 files changed, 455 insertions(+), 404 deletions(-)
create mode 100644 libavfilter/vf_fsppdsp.c
rename libavfilter/{vf_fspp.h => vf_fsppdsp.h} (52%)
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 69d74183b2..d56a458e45 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -329,7 +329,7 @@ OBJS-$(CONFIG_FRAMESTEP_FILTER) +=
vf_framestep.o
OBJS-$(CONFIG_FREEZEDETECT_FILTER) += vf_freezedetect.o
OBJS-$(CONFIG_FREEZEFRAMES_FILTER) += vf_freezeframes.o
OBJS-$(CONFIG_FREI0R_FILTER) += vf_frei0r.o
-OBJS-$(CONFIG_FSPP_FILTER) += vf_fspp.o qp_table.o
+OBJS-$(CONFIG_FSPP_FILTER) += vf_fspp.o vf_fsppdsp.o
qp_table.o
OBJS-$(CONFIG_FSYNC_FILTER) += vf_fsync.o
OBJS-$(CONFIG_GBLUR_FILTER) += vf_gblur.o
OBJS-$(CONFIG_GBLUR_VULKAN_FILTER) += vf_gblur_vulkan.o vulkan.o
vulkan_filter.o
diff --git a/libavfilter/vf_fspp.c b/libavfilter/vf_fspp.c
index 6b4a715367..9371c63e77 100644
--- a/libavfilter/vf_fspp.c
+++ b/libavfilter/vf_fspp.c
@@ -41,12 +41,40 @@
#include "libavutil/mem_internal.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
+#include "libavutil/video_enc_params.h"
+#include "avfilter.h"
#include "filters.h"
#include "qp_table.h"
-#include "vf_fspp.h"
+#include "vf_fsppdsp.h"
#include "video.h"
+#define BLOCKSZ 12
+#define MAX_LEVEL 5
+
+typedef struct FSPPContext {
+const struct AVClass *class;
+uint64_t threshold_mtx_noq[8 * 2];
+uint64_t threshold_mtx[8 * 2];//used in both C & MMX (& later
SSE2) versions
+
+int log2_count;
+int strength;
+int hsub;
+int vsub;
+int temp_stride;
+int qp;
+enum AVVideoEncParamsType qscale_type;
+int prev_q;
+uint8_t *src;
+int16_t *temp;
+int8_t *non_b_qp_table;
+int non_b_qp_stride;
+int use_bframe_qp;
+
+FSPPDSPContext dsp;
+} FSPPContext;
+
+
#define OFFSET(x) offsetof(FSPPContext, x)
#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
static const AVOption fspp_options[] = {
@@ -59,17 +87,6 @@ static const AVOption fspp_options[] = {
AVFILTER_DEFINE_CLASS(fspp);
-DECLARE_ALIGNED(32, static const uint8_t, dither)[8][8] = {
-{ 0, 48, 12, 60, 3, 51, 15, 63, },
-{ 32, 16, 44, 28, 35, 19, 47, 31, },
-{ 8, 56, 4, 52, 11, 59, 7, 55, },
-{ 40, 24, 36, 20, 43, 27, 39, 23, },
-{ 2, 50, 14, 62, 1, 49, 13, 61, },
-{ 34, 18, 46, 30, 33, 17, 45, 29, },
-{ 10, 58, 6, 54, 9, 57, 5, 53, },
-{ 42, 26, 38, 22, 41, 25, 37, 21, },
-};
-
static const short custom_threshold[64] = {
// values (296) can't be too high
// -it causes too big quant dependence
@@ -84,73 +101,6 @@ static const short custom_threshold[64] = {
20, 27, 26, 23, 20, 15, 11, 5
};
-//This func reads from 1 slice, 1 and clears 0 & 1
-static void store_slice_c(uint8_t *dst, int16_t *src,
- ptrdiff_t dst_stride, ptrdiff_t src_stride,
- ptrdiff_t width, ptrdiff_t height, ptrdiff_t
log2_scale)
-{
-int y, x;
-#define STORE(pos)
\
-temp = (src[x + pos] + (d[pos] >> log2_scale)) >> (6 - log2_scale);
\
-src[x + pos] = src[x + pos - 8 * src_stride] = 0;
\
-if (temp & 0x100) temp = ~(temp >> 31);
\
-dst[x + pos] = temp;
-
-for (y = 0; y < height; y++) {
-const uint8_t *d = dither[y];
-for (x = 0; x < width; x += 8) {
-int temp;
-STORE(0);
-STORE(1);
-STORE(2);
-STORE(3);
-STORE(4);
-STORE(5);
-STORE(6);
-STORE(7);
-}
-src += src_stride;
-dst += dst_stride;
-}
-}
-
-//This func reads from 2 slices, 0 & 2 and clears 2-nd
-static void store_slice2_c(uint8_t *dst, int16_t *src,
- ptrdiff_t dst_stride, ptrdiff_t src_stride,
- ptrdiff_t widt
[FFmpeg-devel] [PATCH] avcodec/prores_raw: Reuse permutation (PR #20918)
PR #20918 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20918
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20918.patch
The ProresDSPContext already contains the idct_permutation.
Seems like the raw code has been branched of before February (before
deee2fb52d4ae0fe2a0cf1698a200ab02e3a9741).
>From 9ef362489266e92c8d14bca2f0b9c9b40737bf30 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Fri, 14 Nov 2025 12:31:11 +0100
Subject: [PATCH] avcodec/prores_raw: Reuse permutation
The ProresDSPContext already contains the idct_permutation.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/prores_raw.c | 6 +-
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/libavcodec/prores_raw.c b/libavcodec/prores_raw.c
index 65e0576619..9bc76da698 100644
--- a/libavcodec/prores_raw.c
+++ b/libavcodec/prores_raw.c
@@ -43,7 +43,6 @@
static av_cold int decode_init(AVCodecContext *avctx)
{
ProResRAWContext *s = avctx->priv_data;
-uint8_t idct_permutation[64];
avctx->bits_per_raw_sample = 12;
avctx->color_primaries = AVCOL_PRI_UNSPECIFIED;
@@ -55,10 +54,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
ff_blockdsp_init(&s->bdsp);
ff_proresdsp_init(&s->prodsp, avctx->bits_per_raw_sample);
-ff_init_scantable_permutation(idct_permutation,
- s->prodsp.idct_permutation_type);
-
-ff_permute_scantable(s->scan, ff_prores_interlaced_scan, idct_permutation);
+ff_permute_scantable(s->scan, ff_prores_interlaced_scan,
s->prodsp.idct_permutation);
return 0;
}
--
2.49.1
___
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] Revert "avutil/hwcontext_amf: Simplified blocking before frame submission" (PR #20912)
PR #20912 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20912
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20912.patch
This reverts commit 62184be5486ec06d6976c20931b30738c8e83fd8.
It includes a private header (lavu/mutex.h) in a public header
(hwcontext_amf.h).
>From 446aeebee3575ff4a605ac0d94f62094a5afef3f Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Thu, 13 Nov 2025 15:56:16 +0100
Subject: [PATCH] Revert "avutil/hwcontext_amf: Simplified blocking before
frame submission"
This reverts commit 62184be5486ec06d6976c20931b30738c8e83fd8.
It includes a private header (lavu/mutex.h) in a public header
(hwcontext_amf.h).
Signed-off-by: Andreas Rheinhardt
---
libavcodec/amfenc.c | 93 ---
libavutil/hwcontext_amf.c | 6 +--
libavutil/hwcontext_amf.h | 2 -
3 files changed, 90 insertions(+), 11 deletions(-)
diff --git a/libavcodec/amfenc.c b/libavcodec/amfenc.c
index 2174c5bdb2..f363192000 100644
--- a/libavcodec/amfenc.c
+++ b/libavcodec/amfenc.c
@@ -381,6 +381,89 @@ static AMF_RESULT amf_set_property_buffer(AMFSurface
*object, const wchar_t *nam
return res;
}
+static AMF_RESULT amf_lock_context(AVCodecContext *avctx)
+{
+AMFEncoderContext *ctx = avctx->priv_data;
+AVHWDeviceContext *hw_device_ctx =
(AVHWDeviceContext*)ctx->device_ctx_ref->data;
+AVAMFDeviceContext*amf_device_ctx = (AVAMFDeviceContext
*)hw_device_ctx->hwctx;
+AMF_RESULT res;
+
+switch(amf_device_ctx->memory_type) {
+case AMF_MEMORY_DX11:
+res =
amf_device_ctx->context->pVtbl->LockDX11(amf_device_ctx->context);
+AMF_RETURN_IF_FALSE(ctx, res == AMF_OK, AVERROR(ENOMEM), "LockDX11()
failed with error %d\n", res);
+break;
+case AMF_MEMORY_DX12:
+{
+AMFContext2 *context2 = NULL;
+AMFGuid guid = IID_AMFContext2();
+res =
amf_device_ctx->context->pVtbl->QueryInterface(amf_device_ctx->context, &guid,
(void**)&context2);
+AMF_RETURN_IF_FALSE(ctx, res == AMF_OK, AVERROR_UNKNOWN,
"QueryInterface for AMFContext2 failed with error %d\n", res);
+res = context2->pVtbl->LockDX12(context2);
+AMF_RETURN_IF_FALSE(ctx, res == AMF_OK, AVERROR(ENOMEM), "LockDX12()
failed with error %d\n", res);
+context2->pVtbl->Release(context2);
+}
+break;
+case AMF_MEMORY_DX9:
+res = amf_device_ctx->context->pVtbl->LockDX9(amf_device_ctx->context);
+AMF_RETURN_IF_FALSE(ctx, res == AMF_OK, AVERROR(ENOMEM), "LockDX9()
failed with error %d\n", res);
+
+case AMF_MEMORY_VULKAN:
+{
+AMFContext2 *context2 = NULL;
+AMFGuid guid = IID_AMFContext2();
+res =
amf_device_ctx->context->pVtbl->QueryInterface(amf_device_ctx->context, &guid,
(void**)&context2);
+AMF_RETURN_IF_FALSE(ctx, res == AMF_OK, AVERROR_UNKNOWN,
"QueryInterface for AMFContext2 failed with error %d\n", res);
+res = context2->pVtbl->LockVulkan(context2);
+AMF_RETURN_IF_FALSE(ctx, res == AMF_OK, AVERROR(ENOMEM), "LockVulkan()
failed with error %d\n", res);
+context2->pVtbl->Release(context2);
+}
+break;
+}
+return AMF_OK;
+}
+static AMF_RESULT amf_unlock_context(AVCodecContext *avctx)
+{
+AMFEncoderContext *ctx = avctx->priv_data;
+AVHWDeviceContext *hw_device_ctx =
(AVHWDeviceContext*)ctx->device_ctx_ref->data;
+AVAMFDeviceContext*amf_device_ctx = (AVAMFDeviceContext
*)hw_device_ctx->hwctx;
+AMF_RESULT res;
+
+switch(amf_device_ctx->memory_type) {
+case AMF_MEMORY_DX11:
+res =
amf_device_ctx->context->pVtbl->UnlockDX11(amf_device_ctx->context);
+AMF_RETURN_IF_FALSE(ctx, res == AMF_OK, AVERROR(ENOMEM), "LockDX11()
failed with error %d\n", res);
+break;
+case AMF_MEMORY_DX12:
+{
+AMFContext2 *context2 = NULL;
+AMFGuid guid = IID_AMFContext2();
+res =
amf_device_ctx->context->pVtbl->QueryInterface(amf_device_ctx->context, &guid,
(void**)&context2);
+AMF_RETURN_IF_FALSE(ctx, res == AMF_OK, AVERROR_UNKNOWN,
"QueryInterface for AMFContext2 failed with error %d\n", res);
+res = context2->pVtbl->UnlockDX12(context2);
+AMF_RETURN_IF_FALSE(ctx, res == AMF_OK, AVERROR(ENOMEM), "LockDX12()
failed with error %d\n", res);
+context2->pVtbl->Release(context2);
+}
+break;
+case AMF_MEMORY_DX9:
+res =
amf_device_ctx->context->pVtbl->UnlockDX9(amf_device_ctx->context);
+AMF_RETURN_IF_FALSE(ctx, res == AMF_OK, AVERROR(ENOMEM), "LockDX9()
failed with error %d\n", res);
+
+case AMF_MEMORY_VULKAN:
+{
+AMFContext2 *context2 = NULL;
+AMFGuid guid = IID_AMFContext2();
+res =
amf_device_ctx->context->pVtbl->QueryInterface(amf_device_ctx->context, &guid,
(void**)&context2);
+AMF_RETURN_IF_FALSE(ctx, res == AMF_OK, AVERROR_UNKNOWN,
"QueryInterface for AMFContext2 failed
[FFmpeg-devel] [PATCH] configure: Only test for SSE2 intrinsics on x86 (PR #20934)
PR #20934 opened by mkver URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20934 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20934.patch >From 76eef407bf5fa62e129352d2c460b57e6a5fc759 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 17 Nov 2025 00:05:16 +0100 Subject: [PATCH] configure: Only test for SSE2 intrinsics on x86 Signed-off-by: Andreas Rheinhardt --- configure | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 659b428cfc..441bdc9373 100755 --- a/configure +++ b/configure @@ -6675,13 +6675,14 @@ EOF ;; esac +check_cc intrinsics_sse2 emmintrin.h "__m128i test = _mm_setzero_si128()" + elif enabled loongarch; then enabled lsx && check_inline_asm lsx '"vadd.b $vr0, $vr1, $vr2"' '-mlsx' && append LSXFLAGS '-mlsx' enabled lasx && check_inline_asm lasx '"xvadd.b $xr0, $xr1, $xr2"' '-mlasx' && append LASXFLAGS '-mlasx' fi check_cc intrinsics_neon arm_neon.h "int16x8_t test = vdupq_n_s16(0)" -check_cc intrinsics_sse2 emmintrin.h "__m128i test = _mm_setzero_si128()" check_ldflags -Wl,--as-needed check_ldflags -Wl,-z,noexecstack -- 2.49.1 ___ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] avcodec/x86/mpegvideoenc cleanup (PR #20932)
PR #20932 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20932
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20932.patch
>From a7102ce7ed9e6c0a8c61a92eb8e66b4260057adb Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Sat, 15 Nov 2025 16:18:16 +0100
Subject: [PATCH 1/9] avcodec/x86/mpegvideoenc: Remove check for MMX
Signed-off-by: Andreas Rheinhardt
---
libavcodec/x86/mpegvideoenc.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/libavcodec/x86/mpegvideoenc.c b/libavcodec/x86/mpegvideoenc.c
index eac9947590..bb1d2cc319 100644
--- a/libavcodec/x86/mpegvideoenc.c
+++ b/libavcodec/x86/mpegvideoenc.c
@@ -123,16 +123,14 @@ av_cold void ff_dct_encode_init_x86(MPVEncContext *const
s)
const int dct_algo = s->c.avctx->dct_algo;
if (dct_algo == FF_DCT_AUTO || dct_algo == FF_DCT_MMX) {
-#if HAVE_MMX_INLINE
-int cpu_flags = av_get_cpu_flags();
#if HAVE_SSE2_INLINE
+int cpu_flags = av_get_cpu_flags();
if (INLINE_SSE2(cpu_flags)) {
#if HAVE_6REGS
s->dct_quantize = dct_quantize_sse2;
#endif
s->denoise_dct = denoise_dct_sse2;
}
-#endif
#if HAVE_6REGS && HAVE_SSSE3_INLINE
if (INLINE_SSSE3(cpu_flags))
s->dct_quantize = dct_quantize_ssse3;
--
2.49.1
>From feecc0585a8b83eb0d0897c8a842e82f080d6f26 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Sat, 15 Nov 2025 16:46:18 +0100
Subject: [PATCH 2/9] avcodec/x86/mpegvideoenc: Reduce number of registers used
Avoids a push+pop on x64 Windows.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/x86/mpegvideoenc.c | 18 +-
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/libavcodec/x86/mpegvideoenc.c b/libavcodec/x86/mpegvideoenc.c
index bb1d2cc319..2ca05f69ea 100644
--- a/libavcodec/x86/mpegvideoenc.c
+++ b/libavcodec/x86/mpegvideoenc.c
@@ -68,7 +68,7 @@ static void denoise_dct_sse2(MPVEncContext *const s, int16_t
block[])
s->dct_count[intra]++;
__asm__ volatile(
-"pxor %%xmm7, %%xmm7\n\t"
+"pxor %%xmm6, %%xmm6\n\t"
"1: \n\t"
"pxor %%xmm0, %%xmm0\n\t"
"pxor %%xmm1, %%xmm1\n\t"
@@ -90,18 +90,18 @@ static void denoise_dct_sse2(MPVEncContext *const s,
int16_t block[])
"psubw %%xmm1, %%xmm3 \n\t"
"movdqa %%xmm2, (%0)\n\t"
"movdqa %%xmm3, 16(%0) \n\t"
-"movdqa %%xmm4, %%xmm6 \n\t"
+"movdqa %%xmm4, %%xmm2 \n\t"
"movdqa %%xmm5, %%xmm0 \n\t"
-"punpcklwd %%xmm7, %%xmm4 \n\t"
-"punpckhwd %%xmm7, %%xmm6 \n\t"
-"punpcklwd %%xmm7, %%xmm5 \n\t"
-"punpckhwd %%xmm7, %%xmm0 \n\t"
+"punpcklwd %%xmm6, %%xmm4 \n\t"
+"punpckhwd %%xmm6, %%xmm2 \n\t"
+"punpcklwd %%xmm6, %%xmm5 \n\t"
+"punpckhwd %%xmm6, %%xmm0 \n\t"
"paddd (%1), %%xmm4 \n\t"
-"paddd 16(%1), %%xmm6 \n\t"
+"paddd 16(%1), %%xmm2 \n\t"
"paddd 32(%1), %%xmm5 \n\t"
"paddd 48(%1), %%xmm0 \n\t"
"movdqa %%xmm4, (%1)\n\t"
-"movdqa %%xmm6, 16(%1) \n\t"
+"movdqa %%xmm2, 16(%1) \n\t"
"movdqa %%xmm5, 32(%1) \n\t"
"movdqa %%xmm0, 48(%1) \n\t"
"add $32, %0\n\t"
@@ -112,7 +112,7 @@ static void denoise_dct_sse2(MPVEncContext *const s,
int16_t block[])
: "+r" (block), "+r" (sum), "+r" (offset)
: "r"(block+64)
XMM_CLOBBERS_ONLY("%xmm0", "%xmm1", "%xmm2", "%xmm3",
-"%xmm4", "%xmm5", "%xmm6", "%xmm7")
+"%xmm4", "%xmm5", "%xmm6")
);
}
#endif /* HAVE_SSE2_INLINE */
--
2.49.1
>From 89a1bacded6e635f4773d2ae8b72cbd4f9a12338 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Sat, 15 Nov 2025 17:32:29 +0100
Subject: [PATCH 3/9] avcodec/x86/mpegvideoenc: Port denoise_dct_sse2 to
external assembly
Signed-off-by: Andreas Rheinhardt
---
libavcodec/x86/mpegvideoenc.c | 59 --
libavcodec/x86/mpegvideoencdsp.asm | 46 +++
2 files changed, 54 insertions(+), 51 deletions(-)
diff --git a/libavcodec/x86/mpegvideoenc.c b/libavcodec/x86/mpegvideoenc.c
index 2ca05f69ea..e5665ac781 100644
--- a/libavcodec/x86/mpegvideoenc.c
+++ b/libavcodec/x86/mpegvideoenc.c
@@ -57,8 +57,10 @@ DECLARE_ALIGNED(16, static const uint16_t,
inv_zigzag_direct16)[64] = {
#endif /* HAVE_6REGS */
-#if HAVE_INLINE_ASM
-#if HAVE_SSE2_INLINE
+#if HAVE_SS
[FFmpeg-devel] [PATCH] avcodec/mpeg12: Inline ff_mpeg1_clean_buffers() into its callers (PR #20942)
PR #20942 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20942
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20942.patch
>From fd5fbb41ccaf846a3dc1742ba65dfe6714a543aa Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Mon, 17 Nov 2025 15:35:38 +0100
Subject: [PATCH 1/3] avcodec/mpeg12: Inline ff_mpeg1_clean_buffers() into its
callers
This function is extremely small, so inlining it is appropriate (and
actually beneficial size-wise here). It furthermore allows to remove
the mpeg12codecs.h header and the mpeg12-encoders->mpeg12.o dependency.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/Makefile| 4 ++--
libavcodec/mpeg12.c| 10 --
libavcodec/mpeg12codecs.h | 29 -
libavcodec/mpeg12dec.c | 7 +--
libavcodec/mpeg12enc.h | 8
libavcodec/mpegvideo_enc.c | 3 +--
6 files changed, 16 insertions(+), 45 deletions(-)
delete mode 100644 libavcodec/mpeg12codecs.h
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 49c284ef9e..3e6f000868 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -566,14 +566,14 @@ OBJS-$(CONFIG_MPC7_DECODER)+= mpc7.o mpc.o
OBJS-$(CONFIG_MPC8_DECODER)+= mpc8.o mpc.o
OBJS-$(CONFIG_MPEGVIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o
OBJS-$(CONFIG_MPEG1VIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o
-OBJS-$(CONFIG_MPEG1VIDEO_ENCODER) += mpeg12enc.o mpeg12.o
+OBJS-$(CONFIG_MPEG1VIDEO_ENCODER) += mpeg12enc.o
OBJS-$(CONFIG_MPEG1_CUVID_DECODER) += cuviddec.o
OBJS-$(CONFIG_MPEG1_V4L2M2M_DECODER) += v4l2_m2m_dec.o
OBJS-$(CONFIG_MPEG2_MMAL_DECODER) += mmaldec.o
OBJS-$(CONFIG_MPEG2_QSV_DECODER) += qsvdec.o
OBJS-$(CONFIG_MPEG2_QSV_ENCODER) += qsvenc_mpeg2.o
OBJS-$(CONFIG_MPEG2VIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o
-OBJS-$(CONFIG_MPEG2VIDEO_ENCODER) += mpeg12enc.o mpeg12.o
+OBJS-$(CONFIG_MPEG2VIDEO_ENCODER) += mpeg12enc.o
OBJS-$(CONFIG_MPEG2_CUVID_DECODER) += cuviddec.o
OBJS-$(CONFIG_MPEG2_MEDIACODEC_DECODER) += mediacodecdec.o
OBJS-$(CONFIG_MPEG2_VAAPI_ENCODER) += vaapi_encode_mpeg2.o
diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c
index 62a77b6806..61723f3a29 100644
--- a/libavcodec/mpeg12.c
+++ b/libavcodec/mpeg12.c
@@ -30,8 +30,6 @@
#include "libavutil/attributes.h"
#include "libavutil/thread.h"
-#include "mpegvideo.h"
-#include "mpeg12codecs.h"
#include "mpeg12data.h"
#include "mpeg12dec.h"
#include "mpegutils.h"
@@ -122,14 +120,6 @@ av_cold void ff_init_2d_vlc_rl(const uint16_t
table_vlc[][2], RL_VLC_ELEM rl_vlc
}
}
-void ff_mpeg1_clean_buffers(MpegEncContext *s)
-{
-s->last_dc[0] = 1 << (7 + s->intra_dc_precision);
-s->last_dc[1] = s->last_dc[0];
-s->last_dc[2] = s->last_dc[0];
-memset(s->last_mv, 0, sizeof(s->last_mv));
-}
-
/**/
/* decoding */
diff --git a/libavcodec/mpeg12codecs.h b/libavcodec/mpeg12codecs.h
deleted file mode 100644
index f8cf5503e2..00
--- a/libavcodec/mpeg12codecs.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * MPEG-1/2 codecs common code
- * Copyright (c) 2007 Aurelien Jacobs
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVCODEC_MPEG12CODECS_H
-#define AVCODEC_MPEG12CODECS_H
-
-#include "mpegvideo.h"
-
-void ff_mpeg1_clean_buffers(MpegEncContext *s);
-
-#endif /* AVCODEC_MPEG12CODECS_H */
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 3ea8d02e1b..58ff925bfd 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -50,7 +50,6 @@
#include "idctdsp.h"
#include "mpeg_er.h"
#include "mpeg12.h"
-#include "mpeg12codecs.h"
#include "mpeg12data.h"
#include "mpeg12dec.h"
#include "mpegutils.h"
@@ -1375,7 +1374,6 @@ static int mpeg_decode_slice(Mpeg12SliceContext *const s,
int mb_y,
if (s->c.codec_id != AV_CODEC_ID_MPEG1VIDEO && s->c.mb_height > 2800/16)
skip_bits(&s->gb, 3);
-ff_mpeg1_clean_buffers(&s->c);
s->c.interlaced_dct = 0;
s->c.qscale = mpeg_get_qscale(&s->gb, s->c.q_scale_type);
@@ -1455,6 +1453,11 @@ static int mpeg_decode_slice(Mpeg12SliceContext *const
s, int mb_y,
}
}
+s->c.last_dc[0] = 128 << s->c.intra_dc_p
[FFmpeg-devel] [PATCH] avformat/oggenc: Schedule pagesize option for removal (PR #20992)
PR #20992 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20992
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20992.patch
Deprecated in 59220d559b5077c15fa6434e42df95f3b92f0199.
(Alternatively we could keep it and no longer claim that it is deprecated.)
>From 52880470ca7860cb32a2915be4583d7091f8a45b Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Fri, 21 Nov 2025 15:52:46 +0100
Subject: [PATCH] avformat/oggenc: Schedule pagesize option for removal
Deprecated in 59220d559b5077c15fa6434e42df95f3b92f0199.
Signed-off-by: Andreas Rheinhardt
---
libavformat/oggenc.c | 17 +++--
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c
index e1bb7dd972..9a548a8d29 100644
--- a/libavformat/oggenc.c
+++ b/libavformat/oggenc.c
@@ -76,7 +76,9 @@ typedef struct OGGPageList {
typedef struct OGGContext {
const AVClass *class;
OGGPageList *page_list;
+#if LIBAVFORMAT_VERSION_MAJOR < 63
int pref_size; ///< preferred page size (0 => fill all segments)
+#endif
int64_t pref_duration; ///< preferred page duration (0 => fill all
segments)
int serial_offset;
} OGGContext;
@@ -87,10 +89,12 @@ typedef struct OGGContext {
static const AVOption options[] = {
{ "serial_offset", "serial number offset",
OFFSET(serial_offset), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX,
PARAM },
+#if LIBAVFORMAT_VERSION_MAJOR < 63
{ "oggpagesize", "Set preferred Ogg page size.",
- OFFSET(pref_size), AV_OPT_TYPE_INT, {.i64 = 0}, 0, MAX_PAGE_SIZE, PARAM},
-{ "pagesize", "preferred page size in bytes (deprecated)",
-OFFSET(pref_size), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, MAX_PAGE_SIZE,
PARAM },
+ OFFSET(pref_size), AV_OPT_TYPE_INT, {.i64 = 0}, 0, MAX_PAGE_SIZE, PARAM
| AV_OPT_FLAG_DEPRECATED },
+{ "pagesize", "preferred page size in bytes",
+OFFSET(pref_size), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, MAX_PAGE_SIZE,
PARAM | AV_OPT_FLAG_DEPRECATED },
+#endif
{ "page_duration", "preferred page duration, in microseconds",
OFFSET(pref_duration), AV_OPT_TYPE_INT64, { .i64 = 100 }, 0,
INT64_MAX, PARAM },
{ NULL },
@@ -262,8 +266,12 @@ static int ogg_buffer_data(AVFormatContext *s, AVStream
*st,
if (page->segments_count == 255) {
ogg_buffer_page(s, oggstream);
} else if (!header) {
+#if LIBAVFORMAT_VERSION_MAJOR < 63
if ((ogg->pref_size > 0 && page->size >= ogg->pref_size)
||
(ogg->pref_duration > 0 && next - start >=
ogg->pref_duration)) {
+#else
+if (ogg->pref_duration > 0 && next - start >=
ogg->pref_duration) {
+#endif
ogg_buffer_page(s, oggstream);
}
}
@@ -477,9 +485,6 @@ static int ogg_init(AVFormatContext *s)
OGGStreamContext *oggstream = NULL;
int i, j;
-if (ogg->pref_size)
-av_log(s, AV_LOG_WARNING, "The pagesize option is deprecated\n");
-
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
unsigned serial_num = i + ogg->serial_offset;
--
2.49.1
___
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
[FFmpeg-devel] [PATCH] avutil/error: Avoid relocations and unused information (PR #20991)
PR #20991 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20991
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20991.patch
>From fccdc3f5dea922fbc3100814dce721acef82bfbb Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt
Date: Fri, 21 Nov 2025 13:58:22 +0100
Subject: [PATCH 1/3] av{codec,util}/tests: Remove pointless undefs
Before commit e96d90eed66a198566c409958432d282e1b03869 lavu/internal.h
contained redefined various discouraged/forbidden functions to induce
compilation failures upon use, like e.g.
#define malloc please_use_av_malloc
In order to use these functions, some files had to undefine these
macros. This commit removes the remaining pointless undefs.
Signed-off-by: Andreas Rheinhardt
---
libavcodec/jacosubdec.c | 2 --
libavcodec/tests/motion.c| 2 --
libavcodec/tests/snowenc.c | 4
libavfilter/tests/formats.c | 2 --
libavformat/sbgdec.c | 1 -
libavutil/file_open.c| 1 -
libavutil/tests/bprint.c | 2 --
libavutil/tests/error.c | 2 --
libavutil/tests/file.c | 2 --
libavutil/tests/imgutils.c | 1 -
libavutil/tests/pca.c| 1 -
libavutil/tests/random_seed.c| 1 -
libswresample/tests/swresample.c | 2 --
tools/fourcc2pixfmt.c| 3 ---
14 files changed, 26 deletions(-)
diff --git a/libavcodec/jacosubdec.c b/libavcodec/jacosubdec.c
index 08349a9ec8..fd90dcc4b6 100644
--- a/libavcodec/jacosubdec.c
+++ b/libavcodec/jacosubdec.c
@@ -32,8 +32,6 @@
#include "libavutil/bprint.h"
#include "libavutil/time_internal.h"
-#undef time
-
static int insert_text(AVBPrint *dst, const char *in, const char *arg)
{
av_bprintf(dst, "%s", arg);
diff --git a/libavcodec/tests/motion.c b/libavcodec/tests/motion.c
index 719fba537d..ad2d65ec78 100644
--- a/libavcodec/tests/motion.c
+++ b/libavcodec/tests/motion.c
@@ -36,8 +36,6 @@
#include "libavutil/mem.h"
#include "libavutil/time.h"
-#undef printf
-
#define WIDTH 64
#define HEIGHT 64
diff --git a/libavcodec/tests/snowenc.c b/libavcodec/tests/snowenc.c
index 311374e5d4..35feedba06 100644
--- a/libavcodec/tests/snowenc.c
+++ b/libavcodec/tests/snowenc.c
@@ -20,10 +20,6 @@
#include "libavcodec/snowenc.c"
-#undef malloc
-#undef free
-#undef printf
-
#include "libavutil/lfg.h"
#include "libavutil/mathematics.h"
#include "libavutil/mem.h"
diff --git a/libavfilter/tests/formats.c b/libavfilter/tests/formats.c
index 5cc3ca3371..3fdad7427e 100644
--- a/libavfilter/tests/formats.c
+++ b/libavfilter/tests/formats.c
@@ -22,8 +22,6 @@
#include "libavfilter/audio.h"
#include "libavfilter/formats.c"
-#undef printf
-
const int64_t avfilter_all_channel_layouts[] = {
AV_CH_FRONT_CENTER,
AV_CH_FRONT_CENTER|AV_CH_LOW_FREQUENCY,
diff --git a/libavformat/sbgdec.c b/libavformat/sbgdec.c
index 4afb51b844..0e3d860d9f 100644
--- a/libavformat/sbgdec.c
+++ b/libavformat/sbgdec.c
@@ -905,7 +905,6 @@ static int expand_timestamps(void *log, struct sbg_script
*s)
av_log(log, AV_LOG_WARNING,
"Scripts with mixed absolute and relative timestamps can give "
"unexpected results (pause, seeking, time zone change).\n");
-#undef time
time(&now0);
tm = localtime_r(&now0, &tmpbuf);
now = tm ? tm->tm_hour * 3600 + tm->tm_min * 60 + tm->tm_sec :
diff --git a/libavutil/file_open.c b/libavutil/file_open.c
index 4692035d55..121a562fcb 100644
--- a/libavutil/file_open.c
+++ b/libavutil/file_open.c
@@ -120,7 +120,6 @@ int avpriv_tempfile(const char *prefix, char **filename,
int log_offset, void *l
if(!ptr)
ptr= tempnam(".", prefix);
*filename = av_strdup(ptr);
-#undef free
free(ptr);
#else
return AVERROR(ENOSYS);
diff --git a/libavutil/tests/bprint.c b/libavutil/tests/bprint.c
index d7f9abf23e..9a87283302 100644
--- a/libavutil/tests/bprint.c
+++ b/libavutil/tests/bprint.c
@@ -21,8 +21,6 @@
#include "libavutil/avassert.h"
#include "libavutil/bprint.c"
-#undef printf
-
static void bprint_pascal(AVBPrint *b, unsigned size)
{
unsigned i, j;
diff --git a/libavutil/tests/error.c b/libavutil/tests/error.c
index 16efc8ac45..b7b253b7b5 100644
--- a/libavutil/tests/error.c
+++ b/libavutil/tests/error.c
@@ -18,8 +18,6 @@
#include "libavutil/error.c"
-#undef printf
-
int main(void)
{
int i;
diff --git a/libavutil/tests/file.c b/libavutil/tests/file.c
index 3608bcccbe..0b151de9a1 100644
--- a/libavutil/tests/file.c
+++ b/libavutil/tests/file.c
@@ -18,8 +18,6 @@
#include "libavutil/file.c"
-#undef printf
-
int main(void)
{
uint8_t *buf;
diff --git a/libavutil/tests/imgutils.c b/libavutil/tests/imgutils.c
index 6a5097bc35..cd363145ad 100644
--- a/libavutil/tests/imgutils.c
+++ b/libavutil/tests/imgutils.c
@@ -20,7 +20,6 @@
#include "libavutil/crc.h"
#include "libavutil/mem.h"
-#undef printf
static int check_image_fill(enum AVPixelFormat pix_fmt, int w, int h) {
uint8_t *data[4];
size_t sizes[4];
di
