Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Niklas Haas <ffmpeg@haasn.xyz>
To: ffmpeg-devel@ffmpeg.org
Cc: Niklas Haas <git@haasn.dev>
Subject: [FFmpeg-devel] [PATCH 1/4] avfilter/scene_sad: pass true depth to ff_scene_sad_get_fn()
Date: Sat, 12 Jul 2025 11:22:40 +0200
Message-ID: <20250712092243.29138-1-ffmpeg@haasn.xyz> (raw)

From: Niklas Haas <git@haasn.dev>

I need to be able to distinguish between 10/12/14 and 16 bit depths, for
overflow reasons.
---
 libavfilter/f_select.c           | 2 +-
 libavfilter/scene_sad.c          | 5 ++---
 libavfilter/vf_framerate.c       | 2 +-
 libavfilter/vf_freezedetect.c    | 2 +-
 libavfilter/vf_identity.c        | 2 +-
 libavfilter/vf_minterpolate.c    | 2 +-
 libavfilter/vf_scdet.c           | 2 +-
 libavfilter/x86/scene_sad_init.c | 2 +-
 8 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/libavfilter/f_select.c b/libavfilter/f_select.c
index a5609ec178..46208a7b76 100644
--- a/libavfilter/f_select.c
+++ b/libavfilter/f_select.c
@@ -272,7 +272,7 @@ static int config_input(AVFilterLink *inlink)
         inlink->type == AVMEDIA_TYPE_AUDIO ? inlink->sample_rate : NAN;
 
     if (CONFIG_SELECT_FILTER && select->do_scene_detect) {
-        select->sad = ff_scene_sad_get_fn(select->bitdepth == 8 ? 8 : 16);
+        select->sad = ff_scene_sad_get_fn(select->bitdepth);
         if (!select->sad)
             return AVERROR(EINVAL);
     }
diff --git a/libavfilter/scene_sad.c b/libavfilter/scene_sad.c
index caf911eb5d..05dd97e055 100644
--- a/libavfilter/scene_sad.c
+++ b/libavfilter/scene_sad.c
@@ -63,11 +63,10 @@ ff_scene_sad_fn ff_scene_sad_get_fn(int depth)
     sad = ff_scene_sad_get_fn_x86(depth);
 #endif
     if (!sad) {
-        if (depth == 8)
+        if (depth <= 8)
             sad = ff_scene_sad_c;
-        if (depth == 16)
+        else if (depth <= 16)
             sad = ff_scene_sad16_c;
     }
     return sad;
 }
-
diff --git a/libavfilter/vf_framerate.c b/libavfilter/vf_framerate.c
index 9976db8d93..a6598f97bb 100644
--- a/libavfilter/vf_framerate.c
+++ b/libavfilter/vf_framerate.c
@@ -282,7 +282,7 @@ static int config_input(AVFilterLink *inlink)
 
     s->bitdepth = pix_desc->comp[0].depth;
 
-    s->sad = ff_scene_sad_get_fn(s->bitdepth == 8 ? 8 : 16);
+    s->sad = ff_scene_sad_get_fn(s->bitdepth);
     if (!s->sad)
         return AVERROR(EINVAL);
 
diff --git a/libavfilter/vf_freezedetect.c b/libavfilter/vf_freezedetect.c
index ce67eed3ae..465a2e640b 100644
--- a/libavfilter/vf_freezedetect.c
+++ b/libavfilter/vf_freezedetect.c
@@ -103,7 +103,7 @@ static int config_input(AVFilterLink *inlink)
         s->height[plane] = inlink->h >> ((plane == 1 || plane == 2) ? pix_desc->log2_chroma_h : 0);
     }
 
-    s->sad = ff_scene_sad_get_fn(s->bitdepth == 8 ? 8 : 16);
+    s->sad = ff_scene_sad_get_fn(s->bitdepth);
     if (!s->sad)
         return AVERROR(EINVAL);
 
diff --git a/libavfilter/vf_identity.c b/libavfilter/vf_identity.c
index fc44bfaea0..6a94a92355 100644
--- a/libavfilter/vf_identity.c
+++ b/libavfilter/vf_identity.c
@@ -304,7 +304,7 @@ static int config_input_ref(AVFilterLink *inlink)
     s->filter_slice = !s->is_msad ? compute_images_identity : compute_images_msad;
     s->filter_line = desc->comp[0].depth > 8 ? identity_line_16bit : identity_line_8bit;
 
-    s->sad = ff_scene_sad_get_fn(desc->comp[0].depth <= 8 ? 8 : 16);
+    s->sad = ff_scene_sad_get_fn(desc->comp[0].depth);
     if (!s->sad)
         return AVERROR(EINVAL);
 
diff --git a/libavfilter/vf_minterpolate.c b/libavfilter/vf_minterpolate.c
index 93d331f2ff..d034783bc5 100644
--- a/libavfilter/vf_minterpolate.c
+++ b/libavfilter/vf_minterpolate.c
@@ -387,7 +387,7 @@ static int config_input(AVFilterLink *inlink)
     }
 
     if (mi_ctx->scd_method == SCD_METHOD_FDIFF) {
-        mi_ctx->sad = ff_scene_sad_get_fn(mi_ctx->bitdepth == 8 ? 8 : 16);
+        mi_ctx->sad = ff_scene_sad_get_fn(mi_ctx->bitdepth);
         if (!mi_ctx->sad)
             return AVERROR(EINVAL);
     }
diff --git a/libavfilter/vf_scdet.c b/libavfilter/vf_scdet.c
index 1568a0a496..8aa2f0a73b 100644
--- a/libavfilter/vf_scdet.c
+++ b/libavfilter/vf_scdet.c
@@ -91,7 +91,7 @@ static int config_input(AVFilterLink *inlink)
         s->height[plane] = inlink->h >> ((plane == 1 || plane == 2) ? desc->log2_chroma_h : 0);
     }
 
-    s->sad = ff_scene_sad_get_fn(s->bitdepth == 8 ? 8 : 16);
+    s->sad = ff_scene_sad_get_fn(s->bitdepth);
     if (!s->sad)
         return AVERROR(EINVAL);
 
diff --git a/libavfilter/x86/scene_sad_init.c b/libavfilter/x86/scene_sad_init.c
index 2c3729ceee..4a4c40195f 100644
--- a/libavfilter/x86/scene_sad_init.c
+++ b/libavfilter/x86/scene_sad_init.c
@@ -47,7 +47,7 @@ ff_scene_sad_fn ff_scene_sad_get_fn_x86(int depth)
 {
 #if HAVE_X86ASM
     int cpu_flags = av_get_cpu_flags();
-    if (depth == 8) {
+    if (depth <= 8) {
 #if HAVE_AVX2_EXTERNAL
         if (EXTERNAL_AVX2_FAST(cpu_flags))
             return scene_sad_avx2;
-- 
2.49.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

             reply	other threads:[~2025-07-12  9:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-12  9:22 Niklas Haas [this message]
2025-07-12  9:22 ` [FFmpeg-devel] [PATCH 2/4] tests/checkasm: add scene_sad checkasm test Niklas Haas
2025-07-12  9:22 ` [FFmpeg-devel] [PATCH 3/4] avfilter/x86/scene_sad: add AVX512 implementation Niklas Haas
2025-07-12  9:22 ` [FFmpeg-devel] [PATCH 4/4] avfilter/x86/scene_sad: add high bit depth AVX2/AVX512 version Niklas Haas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250712092243.29138-1-ffmpeg@haasn.xyz \
    --to=ffmpeg@haasn.xyz \
    --cc=ffmpeg-devel@ffmpeg.org \
    --cc=git@haasn.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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