Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Zhao Zhili via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: Zhao Zhili <code@ffmpeg.org>
Subject: [FFmpeg-devel] [PATCH] avfilter/vf_colordetect: Reorder to avoid null pointer check (PR #20299)
Date: Thu, 21 Aug 2025 06:54:12 +0300 (EEST)
Message-ID: <20250821035412.9EA5968D667@ffbox0-bg.ffmpeg.org> (raw)

PR #20299 opened by Zhao Zhili (quink)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20299
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20299.patch

Follow the general practice to assign the C implementation to DSP,
then the SIMD-optimized version.


From 2796ce20d9a91193dbdca9aa980accfb9f2794b0 Mon Sep 17 00:00:00 2001
From: Zhao Zhili <zhilizhao@tencent.com>
Date: Thu, 21 Aug 2025 11:01:35 +0800
Subject: [PATCH] avfilter/vf_colordetect: Reorder to avoid null pointer check

Follow the general practice to assign the C implementation to DSP,
then the SIMD-optimized version.
---
 libavfilter/vf_colordetect.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/libavfilter/vf_colordetect.c b/libavfilter/vf_colordetect.c
index a7fc98e2f1..88374ac3e2 100644
--- a/libavfilter/vf_colordetect.c
+++ b/libavfilter/vf_colordetect.c
@@ -229,19 +229,16 @@ 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_X86
     ff_color_detect_dsp_init_x86(dsp, depth, color_range);
 #endif
-
-    if (!dsp->detect_range)
-        dsp->detect_range = depth > 8 ? ff_detect_range16_c : ff_detect_range_c;
-    if (!dsp->detect_alpha) {
-        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;
-        }
-    }
 }
 
 static const AVFilterPad colordetect_inputs[] = {
-- 
2.49.1

_______________________________________________
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-08-21  3:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20250821035412.9EA5968D667@ffbox0-bg.ffmpeg.org \
    --to=ffmpeg-devel@ffmpeg.org \
    --cc=code@ffmpeg.org \
    /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