[FFmpeg-devel] [RFC] RGB32 / BGR32 ethernal bug

Michael Niedermayer michaelni
Tue Feb 2 21:37:31 CET 2010


On Sun, Jan 31, 2010 at 01:22:53PM +0100, Stefano Sabatini wrote:
> On date Sunday 2010-01-31 02:06:12 +0100, Michael Niedermayer encoded:
> > On Sun, Jan 31, 2010 at 01:48:23AM +0100, Stefano Sabatini wrote:
> > > On date Tuesday 2010-01-26 09:17:12 +0100, Michael Niedermayer encoded:
> [...]
> > > > you write byte shuffling code, id suggest to call it accordingly
> > > > theres nothing rgb specific on this, it could be usefull to do packed yuv
> > > > shuffling as well.
> > > > 
> > > > like maybe:
> > > > byte_shuffle_0123_to_0321
> > > > but before you convert your code to this, what is the speed gain from
> > > > a/b/c/d being constants instead of just passed into the function?
> > > > there should be enough registers for this in theory
> > > > also
> > > > dst+=4; src+=4
> > > > for(dst<dstend
> > > > would reduce the register need
> > > 
> > > Patch+diff of the regression test attached, maybe rgb2rgb.{h,c} is not
> > > the right place for the shuffle functions and you can suggest a better
> > > place.
> > 
> > it can be moved later
> > 
> > 
> > > 
> > > I have yet to try/benchmark with a generic shuffle_byte_4() function.
> > 
> > then ill wait with a review
> 
> Attached patches with the two different approaches, code with ad-hoc
> custom shuffle functions and with the generic shuffle function
> shuffle_bytes_abcd, first solution looks simpler and faster, but I may
> miss something.
> 
> Regards. 
> -- 
> FFmpeg = Fostering Fostering Miracolous Purposeless Eager Geisha

>  rgb2rgb.c |   25 +++++++++++++++++++++++++
>  rgb2rgb.h |    6 ++++++
>  swscale.c |   43 ++++++++++++++++++++++++++++++++++++-------
>  3 files changed, 67 insertions(+), 7 deletions(-)
> 175a71db692d965f98bce9a98c7df61277ee653c  lsws-fix-rgba32-scaling.patch
> Index: ffmpeg/libswscale/rgb2rgb.c
> ===================================================================
> --- ffmpeg.orig/libswscale/rgb2rgb.c	2010-01-31 01:50:52.000000000 +0100
> +++ ffmpeg/libswscale/rgb2rgb.c	2010-01-31 11:43:22.000000000 +0100
> @@ -442,3 +442,28 @@
>          dst[i] = ((b<<1)&0x07) | ((g&0x07)<<3) | ((r&0x03)<<6);
>      }
>  }
> +
> +void shuffle_bytes_0123(const uint8_t *src, uint8_t *dst, long src_size)
> +{
> +    memcpy(dst, src, src_size);
> +}
> +
> +#define DEFINE_SHUFFLE_BYTES(a, b, c, d)                                \
> +void shuffle_bytes_##a##b##c##d(const uint8_t *src, uint8_t *dst, long src_size) \
> +{                                                                       \
> +    long i;                                                             \
> +                                                                        \
> +    for (i = 0; i < src_size; i+=4) {                                   \
> +        dst[i + 0] = src[i + a];                                        \
> +        dst[i + 1] = src[i + b];                                        \
> +        dst[i + 2] = src[i + c];                                        \
> +        dst[i + 3] = src[i + d];                                        \
> +    }                                                                   \
> +}
> +
> +DEFINE_SHUFFLE_BYTES(0, 3, 2, 1);
> +DEFINE_SHUFFLE_BYTES(1, 2, 3, 0);
> +DEFINE_SHUFFLE_BYTES(2, 1, 0, 3);
> +DEFINE_SHUFFLE_BYTES(3, 0, 1, 2);
> +DEFINE_SHUFFLE_BYTES(3, 2, 1, 0);
> +
> Index: ffmpeg/libswscale/rgb2rgb.h
> ===================================================================
> --- ffmpeg.orig/libswscale/rgb2rgb.h	2010-01-31 01:50:52.000000000 +0100
> +++ ffmpeg/libswscale/rgb2rgb.h	2010-01-31 11:43:22.000000000 +0100
> @@ -60,6 +60,12 @@
>  void rgb15tobgr15(const uint8_t *src, uint8_t *dst, long src_size);
>  void bgr8torgb8  (const uint8_t *src, uint8_t *dst, long src_size);
>  
> +void shuffle_bytes_0123(const uint8_t *src, uint8_t *dst, long src_size);
> +void shuffle_bytes_0321(const uint8_t *src, uint8_t *dst, long src_size);
> +void shuffle_bytes_1230(const uint8_t *src, uint8_t *dst, long src_size);
> +void shuffle_bytes_2103(const uint8_t *src, uint8_t *dst, long src_size);
> +void shuffle_bytes_3012(const uint8_t *src, uint8_t *dst, long src_size);
> +void shuffle_bytes_3210(const uint8_t *src, uint8_t *dst, long src_size);
>  
>  void palette8topacked32(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette);
>  void palette8topacked24(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette);

> Index: ffmpeg/libswscale/swscale.c
> ===================================================================
> --- ffmpeg.orig/libswscale/swscale.c	2010-01-31 01:50:52.000000000 +0100
> +++ ffmpeg/libswscale/swscale.c	2010-01-31 13:18:22.000000000 +0100
> @@ -66,6 +66,7 @@
>  #include "libavutil/intreadwrite.h"
>  #include "libavutil/x86_cpu.h"
>  #include "libavutil/avutil.h"
> +#include "libavutil/timer.h"
>  #include "libavutil/bswap.h"
>  #include "libavutil/pixdesc.h"
>  

ehm

also the memcpy case should be redundant

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Avoid a single point of failure, be that a person or equipment.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100202/b96624ee/attachment.pgp>



More information about the ffmpeg-devel mailing list