From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 796B34C478 for ; Mon, 13 Oct 2025 16:57:21 +0000 (UTC) Authentication-Results: ffbox; dkim=fail (body hash mismatch (got b'+7BCGwvVwXjL0QZErDdyFMET+WIuzoypgxCh/BZJj54=', expected b'vs50GwdUTSeVIL88VFOtkbGD6iZV+nBqEtvyRkbOXxU=')) header.d=ffmpeg.org header.i=@ffmpeg.org header.a=rsa-sha256 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1760374625; h=mime-version : to : date : message-id : reply-to : subject : list-id : list-archive : list-archive : list-help : list-owner : list-post : list-subscribe : list-unsubscribe : from : cc : content-type : content-transfer-encoding : from; bh=+7BCGwvVwXjL0QZErDdyFMET+WIuzoypgxCh/BZJj54=; b=qDJgCT506Z1MOPXQl5Y2pD4K1zn30uqpv88L0zjY80JxrM/btlg3E6gYngiV3eGrHkJig CaedZP7lGnwYvx++yBNtb8c+V/5/yN+VO81pclsS1XUUcUKnreMAjogE1Rt2RR8+WpZoXhd j75yidohmkqsdlGuxMmUg5lztFT6zFmvMYk+BGRcLJBsDacL0AtgUrbK93FYH0do5TQ1JMk MfTLdnq0FCRisZm2L0pdH/doFkgesFYJN0Xiy/MaAA7hHRj1TABnRAQLbECPelt7fB1d0kQ sE1SgJ+SfA+/jh7c67FnxYdMH5Wl8aqWo1LUSkqLNFqNWGtXbaPcajig+fXw== Received: from [172.19.0.4] (unknown [172.19.0.4]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id EEE3368F21D; Mon, 13 Oct 2025 19:57:05 +0300 (EEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=ffmpeg.org; s=arc; t=1760374623; b=AVkxLIcll0+sqPvq9PxjehR+qxltXI0C/6362GEq/RqdpZihq++QZ1sHpYP2t8esLlwHG Q33Ix1JNATj95wpVtERnQEfEeP7X2O7XeqxdEQ4W+1ASb2NoTKm7kHYM1tGUCAmwTO4BX3X yba8xP3LRUSD2PmpLlDwANcCS+I25hxhXBDLVObt8SCVaJgsl7zeacZU86diXqed8HubP19 Nl3HNjfbMfJGuI7zal1O3jtAEoVDHdVRs/rH5YvR2ytddYvuzvcY3smmh/DWI/7E06hzROa RCng5+1pjbiko9/y8AH9JLfZrW0RxF8fG1nPEqxVWjgefHYOZZSoiHx+MSXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=ffmpeg.org; s=arc; t=1760374623; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=YAIPMiNm5cktEo4OJmmcYke0a9xCrPGBDQnnLpQlDUc=; b=as/DlL6ObTL4Ps1KLmnrTLNmr7FbWwDzUN07QqII/N5r1OTrFuZgHQ9yEWPBk4jZDyGbL accYf9TnYcgkRQYPBRLP+Ff5LfpQxemXitTLs6HzZo+G2Z+slb/c5b+r204W46icgzzP4t2 iLUJifMadIcsFoy7P0XoyQVGk0xBMhhRC6QZoI0BfmtG0KVOhCzny1ilol7FNiaiYrPCdUo 3pBMOgCCfVVWQuLf5qpjmDQKrt2MX36bCHqeg7Sl8fvKMTXVeiiNnc6nYq7GXuauKtaZP1h r6rE69FlrMMN4QQ/25gvcsREoJk6RkLzOlHJRsa/lPUMmRffD3T3GpSL1V7w== ARC-Authentication-Results: i=1; ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none; dmarc=pass header.from=ffmpeg.org policy.dmarc=quarantine Authentication-Results: ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none (Message is not ARC signed); dmarc=pass (Used From Domain Record) header.from=ffmpeg.org policy.dmarc=quarantine DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1760374617; h=content-type : mime-version : content-transfer-encoding : from : to : reply-to : subject : date : from; bh=vs50GwdUTSeVIL88VFOtkbGD6iZV+nBqEtvyRkbOXxU=; b=s3I03RRZ4nnwdVAnSa1fV4fQChw3CGrv4Jv5Tv70NGiIQ+QfImamnFUM+31bUHHeu/rSc vUid4Apqj5JMIhVQIsTyfy6DotYSZttNxprLSep/YUugcet++8AA8MiKT5kJbzzoOxEK3Hu eda20vC4nXEPoABZBujIcWljb+s4PMuX9t6bL1+mMaQCXdjF356om6209AiOkNwzxC4rUVH 5y82e+RXjlyFcg3e+9xShmiBnKUqJQTkieFHQDxTsdECM1nOQjCrYqV602mqfmFDASzY2xJ 6tv+Ui1o2xesOdVRERDq4REfvOT7lXR3OwrevRLaoe8X5wUZNujrCLADGvgA== Received: from be50bb5a3685 (code.ffmpeg.org [188.245.149.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 2AA8B68EA68 for ; Mon, 13 Oct 2025 19:56:57 +0300 (EEST) MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Date: Mon, 13 Oct 2025 16:56:56 -0000 Message-ID: <176037461733.25.7482280556874605784@bf907ddaa564> Message-ID-Hash: 42LKS354PDPW7UQCCKJEW7ZLGFVRIWJF X-Message-ID-Hash: 42LKS354PDPW7UQCCKJEW7ZLGFVRIWJF X-MailFrom: code@ffmpeg.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-ffmpeg-devel.ffmpeg.org-0; header-match-ffmpeg-devel.ffmpeg.org-1; header-match-ffmpeg-devel.ffmpeg.org-2; header-match-ffmpeg-devel.ffmpeg.org-3; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list Reply-To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PATCH] vf_noise (PR #20699) List-Id: FFmpeg development discussions and patches Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: mkver via ffmpeg-devel Cc: mkver Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Archived-At: List-Archive: List-Post: 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 + 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; -- 2.49.1 >>From abab9a2ff60808a2239fbd9a0848a7117788cc79 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 13 Oct 2025 13:16:22 +0200 Subject: [PATCH 5/7] avfilter/x86/vf_noise: Make line_noise_avg_mmx() match C function Signed-off-by: Andreas Rheinhardt --- libavfilter/x86/vf_noise.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) 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" -- 2.49.1 >>From 35788171b0cdc60100f537efcf8ebe7013c80aea Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 13 Oct 2025 15:35:35 +0200 Subject: [PATCH 6/7] 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 --- libavfilter/vf_noise.c | 2 - libavfilter/x86/vf_noise.c | 120 ++++++++++++++++++------------------- 2 files changed, 60 insertions(+), 62 deletions(-) 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..e3df0f553b 100644 --- a/libavfilter/x86/vf_noise.c +++ b/libavfilter/x86/vf_noise.c @@ -26,78 +26,80 @@ #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) + :: "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) : "%"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) + "mov %3, %%"FF_REG_a" \n\t" + "pcmpeqb %%xmm7, %%xmm7 \n\t" + "psllw $15, %%xmm7 \n\t" + "packsswb %%xmm7, %%xmm7 \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 %%xmm7, %%xmm0 \n\t" + "paddsb %%xmm1, %%xmm0 \n\t" + "pxor %%xmm7, %%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) : "%"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 +108,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 } -- 2.49.1 >>From 66fd0d4dc7d9ff7797307523fb0e4cc403288800 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 13 Oct 2025 18:55:15 +0200 Subject: [PATCH 7/7] avfilter/vf_noise: Deduplicate option flags Signed-off-by: Andreas Rheinhardt --- libavfilter/vf_noise.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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} }; -- 2.49.1 _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org