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 2D0614AF4D for ; Thu, 21 Aug 2025 03:54:17 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 9EA5968D667; Thu, 21 Aug 2025 06:54:12 +0300 (EEST) Received: from c1ad6a1ecdc3 (code.ffmpeg.org [188.245.149.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 5D5CE68D678 for ; Thu, 21 Aug 2025 06:54:10 +0300 (EEST) MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] =?utf-8?q?=5BPATCH=5D_avfilter/vf=5Fcolordetect?= =?utf-8?q?=3A_Reorder_to_avoid_null_pointer_check_=28PR_=2320299=29?= X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Zhao Zhili via ffmpeg-devel Reply-To: FFmpeg development discussions and patches Cc: Zhao Zhili Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Message-Id: <20250821035412.9EA5968D667@ffbox0-bg.ffmpeg.org> Date: Thu, 21 Aug 2025 06:54:12 +0300 (EEST) Archived-At: List-Archive: List-Post: 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 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".