From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 1DC0D4C3A6 for ; Sat, 8 Mar 2025 22:53:54 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F29F768E0B3; Sun, 9 Mar 2025 00:53:50 +0200 (EET) Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BCF7168E0B3 for ; Sun, 9 Mar 2025 00:53:43 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1741474423; bh=QzOPF8FH4nKifG4e6FnRfUYhQ8mOkAnS2Bt9+hokhL4=; h=Date:From:To:Subject:References:From; b=NB9e58XUHYF6N77qAZssQRuE7zBioi3EtAMKo+PbcuSfnDDrsMHsd409WP8z5JTEc Pjaxp3WjHwyJQP1Ki2C1DQLTZZB7C/aSCsVjxS+eYuDwOMoDEbdtNBCzQFa7UWofC9 UHA3JhnHHuR3pB+Uxp4KEAUt8i24VqB4SQ1pCudo= Received: from localhost (unknown [185.35.208.89]) by haasn.dev (Postfix) with UTF8SMTPSA id 2FB6B40D6F for ; Sat, 8 Mar 2025 23:53:43 +0100 (CET) Date: Sat, 8 Mar 2025 23:53:42 +0100 Message-ID: <20250308235342.GB669161@haasn.xyz> From: Niklas Haas To: ffmpeg-devel@ffmpeg.org References: MIME-Version: 1.0 Content-Disposition: inline Subject: [FFmpeg-devel] [RFC] New swscale internal design prototype 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: Hi all, for the past two months, I have been working on a prototype for a radical redesign of the swscale internals, specifically the format handling layer. This includes, or will eventually expand to include, all format input/output and unscaled special conversion steps. I am not yet at a point where the new code can replace the scaling kernels, but for the time being, we could start usaing it for the simple unscaled cases, in theory, right away. Rather than repeating my entire design document here, I opted to collect my notes into a design document on my WIP branch: https://github.com/haasn/FFmpeg/blob/swscale3/doc/swscale-v2.txt I have spent the past week or so ironing out the last kinks and extensively benchmarking the new design at least on x86, and it is generally a roughly 1.9x improvement over the existing unscaled special converters across the board, before even adding any hand written ASM. (This speedup is *just* using the less-than-optimal compiler output from my reference C code!) In some cases we even measure ~3-4x or even ~6x speedups, especially those where swscale does not currently have hand written SIMD. Overall: cpu: 16-core AMD Ryzen Threadripper 1950X gcc 14.2.1: single thread: Overall speedup=1.887x faster, min=0.250x max=22.578x multi thread: Overall speedup=1.657x faster, min=0.190x max=87.972x (The 0.2x slowdown cases are for rgb8/gbr8 input, which requires LUT support for efficient decoding, but I wanted to focus on the core operations first before worrying about adding LUT-based optimizations to the design) I am (almost) ready to begin moving forwards with this design, merging it into swscale and using it at least for unscaled format conversions, XYZ decoding, colorspace transformations (subsuming the existing, horribly unoptimized, 3DLUT layer), gamma transformations, and so on. I wanted to post it here to gather some feedback on the approach. Where does it fall on the "madness" scale? Is the new operations and optimizer design comprehensible? Am I trying too hard to reinvent compilers? Are there any platforms where the high number of function calls per frame would be probitively expensive? What are the thoughts on the float-first approach? See also the list of limitations and improvement ideas at the bottom of my design document. Thanks for your time, Niklas _______________________________________________ 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".