diff options
author | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2010-02-03 23:46:00 +0000 |
---|---|---|
committer | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2010-02-03 23:46:00 +0000 |
commit | 82e5f86bd503db42999df3c0a90efeef8e3dda20 (patch) | |
tree | d51e529dbe637d9feb7f375081c9c719904b802d /libswscale/rgb2rgb.c | |
parent | f5968788bb3692f2fd503bb2ec1526b0369c7f92 (diff) | |
download | ffmpeg-82e5f86bd503db42999df3c0a90efeef8e3dda20.tar.gz |
Implement shuffle_bytes_abcd() functions and use them for shuffling
bytes when converting between RGB32 variants.
In particular fix the argb -> rgba and abgr -> bgra conversions.
See the thread:
Subject: [FFmpeg-devel] [RFC] RGB32 / BGR32 ethernal bug
Date: Tue, 26 Jan 2010 01:06:18 +0100
Originally committed as revision 30501 to svn://svn.mplayerhq.hu/mplayer/trunk/libswscale
Diffstat (limited to 'libswscale/rgb2rgb.c')
-rw-r--r-- | libswscale/rgb2rgb.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libswscale/rgb2rgb.c b/libswscale/rgb2rgb.c index 1dc728ab9d..5230a777ac 100644 --- a/libswscale/rgb2rgb.c +++ b/libswscale/rgb2rgb.c @@ -442,3 +442,23 @@ void bgr8torgb8(const uint8_t *src, uint8_t *dst, long src_size) dst[i] = ((b<<1)&0x07) | ((g&0x07)<<3) | ((r&0x03)<<6); } } + +#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); + |