The branch, master has been updated
via b1f2eea1cd72f6ba01d2a3303462b9717a0d043a (commit)
via 3ba570de8b666f5ae274b99d33cf4d4628cc385b (commit)
via adfec0f52e689e9ff47863e7f36297a33d03dd3d (commit)
via 214b52df4341c610e0159618c08d96e823f26de8 (commit)
via ece623b1b32f619116088b0ad203146544423788 (commit)
via 6a53a4e3417e80b6a5e575788f7ce0e6a6a2cff1 (commit)
via 94948bd6b95f2a39daa23477f06c12a828c1e562 (commit)
from cd4b01707dd8275fb6f77e9a4d5ddd6fb02eaeef (commit)
- Log -----------------------------------------------------------------
commit b1f2eea1cd72f6ba01d2a3303462b9717a0d043a
Author: Andreas Rheinhardt <[email protected]>
AuthorDate: Mon Oct 13 18:55:15 2025 +0200
Commit: Andreas Rheinhardt <[email protected]>
CommitDate: Thu Oct 16 19:10:51 2025 +0200
avfilter/vf_noise: Deduplicate option flags
Signed-off-by: Andreas Rheinhardt <[email protected]>
diff --git a/libavfilter/vf_noise.c b/libavfilter/vf_noise.c
index 74d63fe61b..ae4a08ca50 100644
--- a/libavfilter/vf_noise.c
+++ b/libavfilter/vf_noise.c
@@ -46,12 +46,8 @@ typedef struct ThreadData {
{#name"_seed", "set component #"#x" noise seed", OFFSET(param.seed),
AV_OPT_TYPE_INT, {.i64=-1}, -1, INT_MAX, FLAGS}, \
{#name"_strength", "set component #"#x" strength", OFFSET(param.strength),
AV_OPT_TYPE_INT, {.i64=0}, 0, 100, FLAGS}, \
{#name"s", "set component #"#x" strength", OFFSET(param.strength),
AV_OPT_TYPE_INT, {.i64=0}, 0, 100, FLAGS}, \
- {#name"_flags", "set component #"#x" flags", OFFSET(param.flags),
AV_OPT_TYPE_FLAGS, {.i64=0}, 0, 31, FLAGS, .unit = #name"_flags"}, \
- {#name"f", "set component #"#x" flags", OFFSET(param.flags),
AV_OPT_TYPE_FLAGS, {.i64=0}, 0, 31, FLAGS, .unit = #name"_flags"}, \
- {"a", "averaged noise", 0, AV_OPT_TYPE_CONST, {.i64=NOISE_AVERAGED}, 0, 0,
FLAGS, .unit = #name"_flags"}, \
- {"p", "(semi)regular pattern", 0, AV_OPT_TYPE_CONST, {.i64=NOISE_PATTERN},
0, 0, FLAGS, .unit = #name"_flags"}, \
- {"t", "temporal noise", 0, AV_OPT_TYPE_CONST, {.i64=NOISE_TEMPORAL}, 0, 0,
FLAGS, .unit = #name"_flags"}, \
- {"u", "uniform noise", 0, AV_OPT_TYPE_CONST, {.i64=NOISE_UNIFORM}, 0, 0,
FLAGS, .unit = #name"_flags"},
+ {#name"_flags", "set component #"#x" flags", OFFSET(param.flags),
AV_OPT_TYPE_FLAGS, {.i64=0}, 0, 31, FLAGS, .unit = "flags"}, \
+ {#name"f", "set component #"#x" flags", OFFSET(param.flags),
AV_OPT_TYPE_FLAGS, {.i64=0}, 0, 31, FLAGS, .unit = "flags"}, \
static const AVOption noise_options[] = {
NOISE_PARAMS(all, 0, all)
@@ -59,6 +55,10 @@ static const AVOption noise_options[] = {
NOISE_PARAMS(c1, 1, param[1])
NOISE_PARAMS(c2, 2, param[2])
NOISE_PARAMS(c3, 3, param[3])
+ {"a", "averaged noise", 0, AV_OPT_TYPE_CONST, {.i64=NOISE_AVERAGED}, 0, 0,
FLAGS, .unit = "flags"},
+ {"p", "(semi)regular pattern", 0, AV_OPT_TYPE_CONST, {.i64=NOISE_PATTERN},
0, 0, FLAGS, .unit = "flags"},
+ {"t", "temporal noise", 0, AV_OPT_TYPE_CONST, {.i64=NOISE_TEMPORAL}, 0, 0,
FLAGS, .unit = "flags"},
+ {"u", "uniform noise", 0, AV_OPT_TYPE_CONST, {.i64=NOISE_UNIFORM}, 0, 0,
FLAGS, .unit = "flags"},
{NULL}
};
commit 3ba570de8b666f5ae274b99d33cf4d4628cc385b
Author: Andreas Rheinhardt <[email protected]>
AuthorDate: Mon Oct 13 15:35:35 2025 +0200
Commit: Andreas Rheinhardt <[email protected]>
CommitDate: Thu Oct 16 19:09:45 2025 +0200
avfilter/x86/vf_noise: Port line_noise funcs to SSE2
This avoids having to fix up ABI violations via emms_c and
also leads to a 73% speedup for the line noise average version
here.
Signed-off-by: Andreas Rheinhardt <[email protected]>
diff --git a/libavfilter/vf_noise.c b/libavfilter/vf_noise.c
index 43e7ad6c45..74d63fe61b 100644
--- a/libavfilter/vf_noise.c
+++ b/libavfilter/vf_noise.c
@@ -24,7 +24,6 @@
* noise generator
*/
-#include "libavutil/emms.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/imgutils.h"
@@ -280,7 +279,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame
*inpicref)
ff_filter_execute(ctx, filter_slice, &td, NULL,
n->slice_threading_impossible ? 1 :
FFMIN(n->height[0], ff_filter_get_nb_threads(ctx)));
- emms_c();
if (inpicref != out)
av_frame_free(&inpicref);
diff --git a/libavfilter/x86/vf_noise.c b/libavfilter/x86/vf_noise.c
index 2a7646728f..95f97b3b06 100644
--- a/libavfilter/x86/vf_noise.c
+++ b/libavfilter/x86/vf_noise.c
@@ -26,78 +26,81 @@
#if HAVE_INLINE_ASM
#if HAVE_6REGS
-static void line_noise_avg_mmx(uint8_t *dst, const uint8_t *src,
- int len, const int8_t * const *shift)
+static void line_noise_avg_sse2(uint8_t *dst, const uint8_t *src,
+ int len, const int8_t * const *shift)
{
- x86_reg mmx_len = len & (~7);
+ x86_reg xmm_len = len & (~15);
__asm__ volatile(
- "mov %5, %%"FF_REG_a" \n\t"
- "pxor %%mm4, %%mm4 \n\t"
- ".p2align 4 \n\t"
- "1: \n\t"
- "movq (%1, %%"FF_REG_a"), %%mm1 \n\t"
- "movq (%0, %%"FF_REG_a"), %%mm0 \n\t"
- "paddb (%2, %%"FF_REG_a"), %%mm1\n\t"
- "paddb (%3, %%"FF_REG_a"), %%mm1\n\t"
- "movq %%mm4, %%mm5 \n\t"
- "pcmpgtb %%mm0, %%mm5 \n\t"
- "movq %%mm0, %%mm6 \n\t"
- "movq %%mm0, %%mm2 \n\t"
- "punpcklbw %%mm5, %%mm0 \n\t"
- "punpckhbw %%mm5, %%mm2 \n\t"
- "movq %%mm4, %%mm5 \n\t"
- "pcmpgtb %%mm1, %%mm5 \n\t"
- "movq %%mm1, %%mm3 \n\t"
- "punpcklbw %%mm5, %%mm1 \n\t"
- "punpckhbw %%mm5, %%mm3 \n\t"
- "pmullw %%mm0, %%mm1 \n\t"
- "pmullw %%mm2, %%mm3 \n\t"
- "psraw $7, %%mm1 \n\t"
- "psraw $7, %%mm3 \n\t"
- "packsswb %%mm3, %%mm1 \n\t"
- "paddb %%mm6, %%mm1 \n\t"
- "movq %%mm1, (%4, %%"FF_REG_a") \n\t"
- "add $8, %%"FF_REG_a" \n\t"
+ "mov %5, %%"FF_REG_a" \n\t"
+ "pxor %%xmm4, %%xmm4 \n\t"
+ ".p2align 4 \n\t"
+ "1: \n\t"
+ "movdqu (%1, %%"FF_REG_a"), %%xmm1 \n\t"
+ "movdqu (%2, %%"FF_REG_a"), %%xmm2 \n\t"
+ "movdqu (%3, %%"FF_REG_a"), %%xmm3 \n\t"
+ "movdqa (%0, %%"FF_REG_a"), %%xmm0 \n\t"
+ "paddb %%xmm2, %%xmm1 \n\t"
+ "paddb %%xmm3, %%xmm1 \n\t"
+ "movdqa %%xmm4, %%xmm5 \n\t"
+ "pcmpgtb %%xmm0, %%xmm5 \n\t"
+ "movdqa %%xmm0, %%xmm6 \n\t"
+ "movdqa %%xmm0, %%xmm2 \n\t"
+ "punpcklbw %%xmm5, %%xmm0 \n\t"
+ "punpckhbw %%xmm5, %%xmm2 \n\t"
+ "movdqa %%xmm4, %%xmm5 \n\t"
+ "pcmpgtb %%xmm1, %%xmm5 \n\t"
+ "movdqa %%xmm1, %%xmm3 \n\t"
+ "punpcklbw %%xmm5, %%xmm1 \n\t"
+ "punpckhbw %%xmm5, %%xmm3 \n\t"
+ "pmullw %%xmm0, %%xmm1 \n\t"
+ "pmullw %%xmm2, %%xmm3 \n\t"
+ "psraw $7, %%xmm1 \n\t"
+ "psraw $7, %%xmm3 \n\t"
+ "packsswb %%xmm3, %%xmm1 \n\t"
+ "paddb %%xmm6, %%xmm1 \n\t"
+ "movdqa %%xmm1, (%4, %%"FF_REG_a") \n\t"
+ "add $16, %%"FF_REG_a" \n\t"
" js 1b \n\t"
- :: "r" (src+mmx_len), "r" (shift[0]+mmx_len), "r"
(shift[1]+mmx_len), "r" (shift[2]+mmx_len),
- "r" (dst+mmx_len), "g" (-mmx_len)
- : "%"FF_REG_a
+ :: "r" (src+xmm_len), "r" (shift[0]+xmm_len), "r"
(shift[1]+xmm_len), "r" (shift[2]+xmm_len),
+ "r" (dst+xmm_len), "g" (-xmm_len)
+ : XMM_CLOBBERS("%xmm0", "%xmm1", "%xmm2", "%xmm3",
+ "%xmm4", "%xmm5", "%xmm6",) "%"FF_REG_a
);
- if (mmx_len != len){
- const int8_t *shift2[3] = { shift[0]+mmx_len, shift[1]+mmx_len,
shift[2]+mmx_len };
- ff_line_noise_avg_c(dst+mmx_len, src+mmx_len, len-mmx_len, shift2);
+ if (xmm_len != len){
+ const int8_t *shift2[3] = { shift[0]+xmm_len, shift[1]+xmm_len,
shift[2]+xmm_len };
+ ff_line_noise_avg_c(dst + xmm_len, src + xmm_len, len - xmm_len,
shift2);
}
}
#endif /* HAVE_6REGS */
-static void line_noise_mmxext(uint8_t *dst, const uint8_t *src,
- const int8_t *noise, int len, int shift)
+static void line_noise_sse2(uint8_t *dst, const uint8_t *src,
+ const int8_t *noise, int len, int shift)
{
- x86_reg mmx_len = len & (~7);
+ x86_reg xmm_len = len & (~15);
noise += shift;
__asm__ volatile(
- "mov %3, %%"FF_REG_a" \n\t"
- "pcmpeqb %%mm7, %%mm7 \n\t"
- "psllw $15, %%mm7 \n\t"
- "packsswb %%mm7, %%mm7 \n\t"
- ".p2align 4 \n\t"
- "1: \n\t"
- "movq (%0, %%"FF_REG_a"), %%mm0 \n\t"
- "movq (%1, %%"FF_REG_a"), %%mm1 \n\t"
- "pxor %%mm7, %%mm0 \n\t"
- "paddsb %%mm1, %%mm0 \n\t"
- "pxor %%mm7, %%mm0 \n\t"
- "movntq %%mm0, (%2, %%"FF_REG_a") \n\t"
- "add $8, %%"FF_REG_a" \n\t"
- " js 1b \n\t"
- :: "r" (src+mmx_len), "r" (noise+mmx_len), "r" (dst+mmx_len), "g"
(-mmx_len)
- : "%"FF_REG_a
+ "mov %3, %%"FF_REG_a" \n\t"
+ "pcmpeqb %%xmm2, %%xmm2 \n\t"
+ "psllw $15, %%xmm2 \n\t"
+ "packsswb %%xmm2, %%xmm2 \n\t"
+ ".p2align 4 \n\t"
+ "1: \n\t"
+ "movdqa (%0, %%"FF_REG_a"), %%xmm0 \n\t"
+ "movdqu (%1, %%"FF_REG_a"), %%xmm1 \n\t"
+ "pxor %%xmm2, %%xmm0 \n\t"
+ "paddsb %%xmm1, %%xmm0 \n\t"
+ "pxor %%xmm2, %%xmm0 \n\t"
+ "movntdq %%xmm0, (%2, %%"FF_REG_a") \n\t"
+ "add $16, %%"FF_REG_a" \n\t"
+ " js 1b \n\t"
+ :: "r" (src+xmm_len), "r" (noise+xmm_len), "r" (dst+xmm_len), "g"
(-xmm_len)
+ : XMM_CLOBBERS("%xmm0", "%xmm1", "%xmm2",) "%"FF_REG_a
);
- if (mmx_len != len)
- ff_line_noise_c(dst+mmx_len, src+mmx_len, noise+mmx_len, len-mmx_len,
0);
+ if (xmm_len != len)
+ ff_line_noise_c(dst+xmm_len, src + xmm_len, noise + xmm_len, len -
xmm_len, 0);
}
#endif /* HAVE_INLINE_ASM */
@@ -106,13 +109,11 @@ av_cold void ff_noise_init_x86(NoiseContext *n)
#if HAVE_INLINE_ASM
int cpu_flags = av_get_cpu_flags();
- if (INLINE_MMX(cpu_flags)) {
+ if (INLINE_SSE2(cpu_flags)) {
#if HAVE_6REGS
- n->line_noise_avg = line_noise_avg_mmx;
+ n->line_noise_avg = line_noise_avg_sse2;
#endif
- }
- if (INLINE_MMXEXT(cpu_flags)) {
- n->line_noise = line_noise_mmxext;
+ n->line_noise = line_noise_sse2;
}
#endif
}
commit adfec0f52e689e9ff47863e7f36297a33d03dd3d
Author: Andreas Rheinhardt <[email protected]>
AuthorDate: Mon Oct 13 13:16:22 2025 +0200
Commit: Andreas Rheinhardt <[email protected]>
CommitDate: Thu Oct 16 18:41:19 2025 +0200
avfilter/x86/vf_noise: Make line_noise_avg_mmx() match C function
Signed-off-by: Andreas Rheinhardt <[email protected]>
diff --git a/libavfilter/x86/vf_noise.c b/libavfilter/x86/vf_noise.c
index 43387c9908..2a7646728f 100644
--- a/libavfilter/x86/vf_noise.c
+++ b/libavfilter/x86/vf_noise.c
@@ -33,27 +33,30 @@ static void line_noise_avg_mmx(uint8_t *dst, const uint8_t
*src,
__asm__ volatile(
"mov %5, %%"FF_REG_a" \n\t"
+ "pxor %%mm4, %%mm4 \n\t"
".p2align 4 \n\t"
"1: \n\t"
"movq (%1, %%"FF_REG_a"), %%mm1 \n\t"
"movq (%0, %%"FF_REG_a"), %%mm0 \n\t"
"paddb (%2, %%"FF_REG_a"), %%mm1\n\t"
"paddb (%3, %%"FF_REG_a"), %%mm1\n\t"
+ "movq %%mm4, %%mm5 \n\t"
+ "pcmpgtb %%mm0, %%mm5 \n\t"
+ "movq %%mm0, %%mm6 \n\t"
"movq %%mm0, %%mm2 \n\t"
+ "punpcklbw %%mm5, %%mm0 \n\t"
+ "punpckhbw %%mm5, %%mm2 \n\t"
+ "movq %%mm4, %%mm5 \n\t"
+ "pcmpgtb %%mm1, %%mm5 \n\t"
"movq %%mm1, %%mm3 \n\t"
- "punpcklbw %%mm0, %%mm0 \n\t"
- "punpckhbw %%mm2, %%mm2 \n\t"
- "punpcklbw %%mm1, %%mm1 \n\t"
- "punpckhbw %%mm3, %%mm3 \n\t"
- "pmulhw %%mm0, %%mm1 \n\t"
- "pmulhw %%mm2, %%mm3 \n\t"
- "paddw %%mm1, %%mm1 \n\t"
- "paddw %%mm3, %%mm3 \n\t"
- "paddw %%mm0, %%mm1 \n\t"
- "paddw %%mm2, %%mm3 \n\t"
- "psrlw $8, %%mm1 \n\t"
- "psrlw $8, %%mm3 \n\t"
- "packuswb %%mm3, %%mm1 \n\t"
+ "punpcklbw %%mm5, %%mm1 \n\t"
+ "punpckhbw %%mm5, %%mm3 \n\t"
+ "pmullw %%mm0, %%mm1 \n\t"
+ "pmullw %%mm2, %%mm3 \n\t"
+ "psraw $7, %%mm1 \n\t"
+ "psraw $7, %%mm3 \n\t"
+ "packsswb %%mm3, %%mm1 \n\t"
+ "paddb %%mm6, %%mm1 \n\t"
"movq %%mm1, (%4, %%"FF_REG_a") \n\t"
"add $8, %%"FF_REG_a" \n\t"
" js 1b \n\t"
commit 214b52df4341c610e0159618c08d96e823f26de8
Author: Andreas Rheinhardt <[email protected]>
AuthorDate: Mon Oct 13 12:20:32 2025 +0200
Commit: Andreas Rheinhardt <[email protected]>
CommitDate: Thu Oct 16 18:41:19 2025 +0200
avfilter/vf_noise: Avoid cast
Signed-off-by: Andreas Rheinhardt <[email protected]>
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 + shift;
} else {
n->line_noise(dst + x, src + x, noise, w, shift);
diff --git a/libavfilter/vf_noise.h b/libavfilter/vf_noise.h
index 62d7bee02c..081a0bbf77 100644
--- a/libavfilter/vf_noise.h
+++ b/libavfilter/vf_noise.h
@@ -40,7 +40,7 @@ typedef struct FilterParams {
AVLFG lfg;
int seed;
int8_t *noise;
- int8_t *prev_shift[MAX_RES][3];
+ const int8_t *prev_shift[MAX_RES][3];
int rand_shift[MAX_RES];
int rand_shift_init;
} FilterParams;
commit ece623b1b32f619116088b0ad203146544423788
Author: Andreas Rheinhardt <[email protected]>
AuthorDate: Mon Oct 13 10:26:06 2025 +0200
Commit: Andreas Rheinhardt <[email protected]>
CommitDate: Thu Oct 16 18:41:19 2025 +0200
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 <[email protected]>
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;
commit 6a53a4e3417e80b6a5e575788f7ce0e6a6a2cff1
Author: Andreas Rheinhardt <[email protected]>
AuthorDate: Mon Oct 13 09:43:38 2025 +0200
Commit: Andreas Rheinhardt <[email protected]>
CommitDate: Thu Oct 16 18:41:18 2025 +0200
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 <[email protected]>
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);
}
commit 94948bd6b95f2a39daa23477f06c12a828c1e562
Author: Andreas Rheinhardt <[email protected]>
AuthorDate: Mon Oct 13 06:20:07 2025 +0200
Commit: Andreas Rheinhardt <[email protected]>
CommitDate: Thu Oct 16 18:41:18 2025 +0200
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 <[email protected]>
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);
-----------------------------------------------------------------------
Summary of changes:
libavfilter/vf_noise.c | 23 +++++----
libavfilter/vf_noise.h | 8 ++-
libavfilter/x86/vf_noise.c | 122 +++++++++++++++++++++++----------------------
3 files changed, 81 insertions(+), 72 deletions(-)
hooks/post-receive
--
_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]