[FFmpeg-devel] Extend/optimize RGB to RGB conversions funcs into rgb2rgb.c
Loren Merritt
lorenm at u.washington.edu
Mon Sep 10 01:31:27 CEST 2012
On Mon, 10 Sep 2012, yann.lepetitcorps at free.fr wrote:
> Selon Reimar Döffinger <Reimar.Doeffinger at gmx.de>:
>
>> Though one thing I wonder is why exactly that is faster, and why your
>> compiler can't figure out how to optimize it on its own.
>> There is also a bit the issue that compared to NEON-optimizing the code
>> this is rather a very minor optimization.
>
> I think that is a little more speed because of this :
>
> - dst[3 * i + 0] = src[4 * i + 2];
> - dst[3 * i + 1] = src[4 * i + 1];
> - dst[3 * i + 2] = src[4 * i + 0];
>
> + dst[0] = psrc[2];
> + dst[1] = psrc[1];
> + dst[2] = psrc[0];
>
> => the copy is make with a "direct" adressing, cf. without multiplications or
> additions into the [] array adressing
> (can the compilator handle automaticaly the * 3 multiplication for free ?)
It's not that a *3 is free, but rather that the addressing mode of the
generated instructions doesn't have to be the same as the one in the
source code. GCC is normally capable of switching from index variables to
pointer incrementing or vice versa, though it doesn't always choose
optimally when to do so.
--Loren Merritt
More information about the ffmpeg-devel
mailing list