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 A36914A9B7 for ; Fri, 18 Jul 2025 12:46:58 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 9965D68CF02; Fri, 18 Jul 2025 15:46:56 +0300 (EEST) Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 85C7968CD6B for ; Fri, 18 Jul 2025 15:46:53 +0300 (EEST) Received: from haasn.dev (unknown [10.30.1.1]) by haasn.dev (Postfix) with UTF8SMTP id 22EB540E94 for ; Fri, 18 Jul 2025 14:46:53 +0200 (CEST) Date: Fri, 18 Jul 2025 14:46:53 +0200 Message-ID: <20250718144653.GC312574@haasn.xyz> From: Niklas Haas To: FFmpeg development discussions and patches In-Reply-To: References: <20250718095716.68346-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Content-Disposition: inline Subject: Re: [FFmpeg-devel] [PATCH v3 1/3] avfilter/vf_colordetect: add new color range detection filter 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: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Fri, 18 Jul 2025 14:38:04 +0200 Kacper Michajlow wrote: > > +static inline int ff_detect_range_c(const uint8_t *data, ptrdiff_t stride, > > + ptrdiff_t width, ptrdiff_t height, > > + int mpeg_min, int mpeg_max) > > +{ > > + while (height--) { > > + for (int x = 0; x < width; x++) { > > + const uint8_t val = data[x]; > > + if (val < mpeg_min || val > mpeg_max) > > + return 1; > > + } > > + data += stride; > > + } > > + > > + return 0; > > +} > > You could process width as a whole to allow better vectorization. > Assuming you don't process 10000x1 images, it will be faster on average. That's what I had in v1 of my patch, but it is significantly (50%) slower on GCC, which prefers the version I have written above. There is the not insignificant point that this C routine is also being used to handle remaining elements that don't fit into a multiple of the SIMD kernel, for which the scalar code is actually preferred. _______________________________________________ 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".