* [FFmpeg-devel] [PATCH] Don't link all of libavfilter in checkasm (PR #20529)
@ 2025-09-15 17:52 mkver via ffmpeg-devel
0 siblings, 0 replies; only message in thread
From: mkver via ffmpeg-devel @ 2025-09-15 17:52 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: mkver
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 <andreas.rheinhardt@outlook.com>
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 <andreas.rheinhardt@outlook.com>
---
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 <stddef.h>
#include <stdint.h>
@@ -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 <string.h>
#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 <andreas.rheinhardt@outlook.com>
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 <andreas.rheinhardt@outlook.com>
---
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)
ff_filter_execute(ctx, detect_range, in, NULL, nb_threads);
- if (s->mode & COLOR_DETECT_ALPHA_MODE && s->detected_alpha != FF_ALPHA_NONE &&
- s->detected_alpha != FF_ALPHA_STRAIGHT)
+ enum FFAlphaDetect detected_alpha = atomic_load_explicit(&s->detected_alpha, memory_order_relaxed);
+ if (s->mode & COLOR_DETECT_ALPHA_MODE && detected_alpha != FF_ALPHA_NONE &&
+ detected_alpha != FF_ALPHA_STRAIGHT)
ff_filter_execute(ctx, detect_alpha, in, NULL, nb_threads);
return ff_filter_frame(inlink->dst->outputs[0], in);
@@ -212,17 +215,21 @@ static av_cold void uninit(AVFilterContext *ctx)
av_log(ctx, AV_LOG_INFO, "Detected color properties:\n");
if (s->mode & COLOR_DETECT_COLOR_RANGE) {
+ enum AVColorRange detected_range = atomic_load_explicit(&s->detected_range,
+ memory_order_relaxed);
av_log(ctx, AV_LOG_INFO, " Color range: %s\n",
- s->detected_range == AVCOL_RANGE_JPEG ? "JPEG / full range"
- : "undetermined");
+ detected_range == AVCOL_RANGE_JPEG ? "JPEG / full range"
+ : "undetermined");
}
if (s->mode & COLOR_DETECT_ALPHA_MODE) {
+ enum FFAlphaDetect detected_alpha = atomic_load_explicit(&s->detected_alpha,
+ memory_order_relaxed);
av_log(ctx, AV_LOG_INFO, " Alpha mode: %s\n",
- s->detected_alpha == FF_ALPHA_NONE ? "none" :
- s->detected_alpha == FF_ALPHA_STRAIGHT ? "straight" :
- s->detected_alpha == FF_ALPHA_TRANSPARENT ? "undetermined"
- : "opaque");
+ detected_alpha == FF_ALPHA_NONE ? "none" :
+ detected_alpha == FF_ALPHA_STRAIGHT ? "straight" :
+ detected_alpha == FF_ALPHA_TRANSPARENT ? "undetermined"
+ : "opaque");
}
}
--
2.49.1
>From 0349b549a2f22c5fd591a02b0a9f2bd85ff13d4e Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Mon, 15 Sep 2025 19:33:41 +0200
Subject: [PATCH 3/3] avfilter/vf_colordetect: Move ff_color_detect_dsp_init()
out of .c file
Otherwise checkasm pulls in vf_colordetect.o and then all of
libavfilter.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavfilter/vf_colordetect.c | 17 -----------------
libavfilter/vf_colordetectdsp.h | 24 +++++++++++++++++++++---
2 files changed, 21 insertions(+), 20 deletions(-)
diff --git a/libavfilter/vf_colordetect.c b/libavfilter/vf_colordetect.c
index ee4288c839..14b75b72ce 100644
--- a/libavfilter/vf_colordetect.c
+++ b/libavfilter/vf_colordetect.c
@@ -233,23 +233,6 @@ static av_cold void uninit(AVFilterContext *ctx)
}
}
-av_cold void ff_color_detect_dsp_init(FFColorDetectDSPContext *dsp, int depth,
- enum AVColorRange color_range)
-{
- dsp->detect_range = depth > 8 ? ff_detect_range16_c : ff_detect_range_c;
- if (color_range == AVCOL_RANGE_JPEG) {
- dsp->detect_alpha = depth > 8 ? ff_detect_alpha16_full_c : ff_detect_alpha_full_c;
- } else {
- dsp->detect_alpha = depth > 8 ? ff_detect_alpha16_limited_c : ff_detect_alpha_limited_c;
- }
-
-#if ARCH_AARCH64
- ff_color_detect_dsp_init_aarch64(dsp, depth, color_range);
-#elif ARCH_X86
- ff_color_detect_dsp_init_x86(dsp, depth, color_range);
-#endif
-}
-
static const AVFilterPad colordetect_inputs[] = {
{
.name = "default",
diff --git a/libavfilter/vf_colordetectdsp.h b/libavfilter/vf_colordetectdsp.h
index 2ce3d061a3..7a57e7aa73 100644
--- a/libavfilter/vf_colordetectdsp.h
+++ b/libavfilter/vf_colordetectdsp.h
@@ -22,6 +22,9 @@
#include <stddef.h>
#include <stdint.h>
+#include "config.h"
+
+#include "libavutil/attributes.h"
#include "libavutil/avassert.h"
#include "libavutil/pixfmt.h"
@@ -46,9 +49,6 @@ typedef struct FFColorDetectDSPContext {
int alpha_max, int mpeg_range, int offset);
} FFColorDetectDSPContext;
-void ff_color_detect_dsp_init(FFColorDetectDSPContext *dsp, int depth,
- enum AVColorRange color_range);
-
void ff_color_detect_dsp_init_aarch64(FFColorDetectDSPContext *dsp, int depth,
enum AVColorRange color_range);
void ff_color_detect_dsp_init_x86(FFColorDetectDSPContext *dsp, int depth,
@@ -195,4 +195,22 @@ ff_detect_alpha16_limited_c(const uint8_t *color, ptrdiff_t color_stride,
return transparent ? FF_ALPHA_TRANSPARENT : 0;
}
+static av_cold inline void
+ff_color_detect_dsp_init(FFColorDetectDSPContext *dsp, int depth,
+ enum AVColorRange color_range)
+{
+ dsp->detect_range = depth > 8 ? ff_detect_range16_c : ff_detect_range_c;
+ if (color_range == AVCOL_RANGE_JPEG) {
+ dsp->detect_alpha = depth > 8 ? ff_detect_alpha16_full_c : ff_detect_alpha_full_c;
+ } else {
+ dsp->detect_alpha = depth > 8 ? ff_detect_alpha16_limited_c : ff_detect_alpha_limited_c;
+ }
+
+#if ARCH_AARCH64
+ ff_color_detect_dsp_init_aarch64(dsp, depth, color_range);
+#elif ARCH_X86
+ ff_color_detect_dsp_init_x86(dsp, depth, color_range);
+#endif
+}
+
#endif /* AVFILTER_COLORDETECTDSP_H */
--
2.49.1
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-09-15 17:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-15 17:52 [FFmpeg-devel] [PATCH] Don't link all of libavfilter in checkasm (PR #20529) mkver via ffmpeg-devel
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git