aboutsummaryrefslogtreecommitdiffstats
path: root/libswscale/rgb2rgb_template.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-02-23 02:33:21 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-02-23 04:31:55 +0100
commite99f1a8cc8b90926209b7390ae3f50d519c0e63f (patch)
treeb50f42ffe92fdb5fb2bc1efeaf9625d208e9c6ca /libswscale/rgb2rgb_template.c
parent094673ff1b1a0f83584f3aeea76a3e9c9e3129bf (diff)
parent562ebc30775db243941db3c96396e7bf8a0e0a44 (diff)
downloadffmpeg-e99f1a8cc8b90926209b7390ae3f50d519c0e63f.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: dxva2: don't check for DXVA_PictureParameters->wDecodedPictureIndex img2: split muxer and demuxer into separate files rm: prevent infinite loops for index parsing. aac: fix infinite loop on end-of-frame with sequence of 1-bits. mov: Add more HDV and XDCAM FourCCs. lavf: don't set AVCodecContext.has_b_frames in compute_pkt_fields(). rmdec: when using INT4 deinterleaving, error out if sub_packet_h <= 1. cdxl: correctly synchronize video timestamps to audio mlpdec_parser: fix a few channel layouts. Add channel names to channel_names[] array for channels added in b2890f5 movenc: Buffer the mdat for the initial moov fragment, too flvdec: Ignore the index if the ignidx flag is set flvdec: Fix indentation movdec: Don't parse all fragments if ignidx is set movdec: Restart parsing root-level atoms at the right spot prores: use natural integer type for the codebook index mov: Add support for MPEG2 HDV 720p24 (hdv4) swscale: K&R formatting cosmetics (part I) swscale: variable declaration and placement cosmetics Conflicts: configure libavcodec/aacdec.c libavcodec/mlp_parser.c libavformat/flvdec.c libavformat/img2.c libavformat/isom.h libavformat/mov.c libavformat/movenc.c libswscale/rgb2rgb.c libswscale/rgb2rgb_template.c libswscale/yuv2rgb.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libswscale/rgb2rgb_template.c')
-rw-r--r--libswscale/rgb2rgb_template.c768
1 files changed, 387 insertions, 381 deletions
diff --git a/libswscale/rgb2rgb_template.c b/libswscale/rgb2rgb_template.c
index 6363bc19aa..c05cdc8549 100644
--- a/libswscale/rgb2rgb_template.c
+++ b/libswscale/rgb2rgb_template.c
@@ -26,254 +26,264 @@
#include <stddef.h>
-static inline void rgb24tobgr32_c(const uint8_t *src, uint8_t *dst, int src_size)
+static inline void rgb24tobgr32_c(const uint8_t *src, uint8_t *dst,
+ int src_size)
{
- uint8_t *dest = dst;
- const uint8_t *s = src;
- const uint8_t *end;
- end = s + src_size;
+ uint8_t *dest = dst;
+ const uint8_t *s = src;
+ const uint8_t *end = s + src_size;
while (s < end) {
#if HAVE_BIGENDIAN
- /* RGB24 (= R,G,B) -> RGB32 (= A,B,G,R) */
- *dest++ = 255;
- *dest++ = s[2];
- *dest++ = s[1];
- *dest++ = s[0];
- s+=3;
+ /* RGB24 (= R, G, B) -> RGB32 (= A, B, G, R) */
+ *dest++ = 255;
+ *dest++ = s[2];
+ *dest++ = s[1];
+ *dest++ = s[0];
+ s += 3;
#else
- *dest++ = *s++;
- *dest++ = *s++;
- *dest++ = *s++;
- *dest++ = 255;
+ *dest++ = *s++;
+ *dest++ = *s++;
+ *dest++ = *s++;
+ *dest++ = 255;
#endif
}
}
-static inline void rgb32tobgr24_c(const uint8_t *src, uint8_t *dst, int src_size)
+static inline void rgb32tobgr24_c(const uint8_t *src, uint8_t *dst,
+ int src_size)
{
- uint8_t *dest = dst;
- const uint8_t *s = src;
- const uint8_t *end;
-
- end = s + src_size;
+ uint8_t *dest = dst;
+ const uint8_t *s = src;
+ const uint8_t *end = s + src_size;
while (s < end) {
#if HAVE_BIGENDIAN
- /* RGB32 (= A,B,G,R) -> RGB24 (= R,G,B) */
+ /* RGB32 (= A, B, G, R) -> RGB24 (= R, G, B) */
s++;
- dest[2] = *s++;
- dest[1] = *s++;
- dest[0] = *s++;
- dest += 3;
+ dest[2] = *s++;
+ dest[1] = *s++;
+ dest[0] = *s++;
+ dest += 3;
#else
- *dest++ = *s++;
- *dest++ = *s++;
- *dest++ = *s++;
+ *dest++ = *s++;
+ *dest++ = *s++;
+ *dest++ = *s++;
s++;
#endif
}
}
/*
- original by Strepto/Astral
- ported to gcc & bugfixed: A'rpi
- MMX2, 3DNOW optimization by Nick Kurshev
- 32-bit C version, and and&add trick by Michael Niedermayer
-*/
+ * original by Strepto/Astral
+ * ported to gcc & bugfixed: A'rpi
+ * MMX2, 3DNOW optimization by Nick Kurshev
+ * 32-bit C version, and and&add trick by Michael Niedermayer
+ */
static inline void rgb15to16_c(const uint8_t *src, uint8_t *dst, int src_size)
{
- register const uint8_t* s=src;
- register uint8_t* d=dst;
- register const uint8_t *end;
- const uint8_t *mm_end;
- end = s + src_size;
- mm_end = end - 3;
+ register uint8_t *d = dst;
+ register const uint8_t *s = src;
+ register const uint8_t *end = s + src_size;
+ const uint8_t *mm_end = end - 3;
+
while (s < mm_end) {
- register unsigned x= *((const uint32_t *)s);
- *((uint32_t *)d) = (x&0x7FFF7FFF) + (x&0x7FE07FE0);
- d+=4;
- s+=4;
+ register unsigned x = *((const uint32_t *)s);
+ *((uint32_t *)d) = (x & 0x7FFF7FFF) + (x & 0x7FE07FE0);
+ d += 4;
+ s += 4;
}
if (s < end) {
- register unsigned short x= *((const uint16_t *)s);
- *((uint16_t *)d) = (x&0x7FFF) + (x&0x7FE0);
+ register unsigned short x = *((const uint16_t *)s);
+ *((uint16_t *)d) = (x & 0x7FFF) + (x & 0x7FE0);
}
}
static inline void rgb16to15_c(const uint8_t *src, uint8_t *dst, int src_size)
{
- register const uint8_t* s=src;
- register uint8_t* d=dst;
- register const uint8_t *end;
- const uint8_t *mm_end;
- end = s + src_size;
+ register uint8_t *d = dst;
+ register const uint8_t *s = src;
+ register const uint8_t *end = s + src_size;
+ const uint8_t *mm_end = end - 3;
- mm_end = end - 3;
while (s < mm_end) {
- register uint32_t x= *((const uint32_t*)s);
- *((uint32_t *)d) = ((x>>1)&0x7FE07FE0) | (x&0x001F001F);
- s+=4;
- d+=4;
+ register uint32_t x = *((const uint32_t *)s);
+ *((uint32_t *)d) = ((x >> 1) & 0x7FE07FE0) | (x & 0x001F001F);
+ s += 4;
+ d += 4;
}
if (s < end) {
- register uint16_t x= *((const uint16_t*)s);
- *((uint16_t *)d) = ((x>>1)&0x7FE0) | (x&0x001F);
+ register uint16_t x = *((const uint16_t *)s);
+ *((uint16_t *)d) = ((x >> 1) & 0x7FE0) | (x & 0x001F);
}
}
static inline void rgb32to16_c(const uint8_t *src, uint8_t *dst, int src_size)
{
- const uint8_t *s = src;
- const uint8_t *end;
- uint16_t *d = (uint16_t *)dst;
- end = s + src_size;
+ uint16_t *d = (uint16_t *)dst;
+ const uint8_t *s = src;
+ const uint8_t *end = s + src_size;
while (s < end) {
- register int rgb = *(const uint32_t*)s; s += 4;
- *d++ = ((rgb&0xFF)>>3) + ((rgb&0xFC00)>>5) + ((rgb&0xF80000)>>8);
+ register int rgb = *(const uint32_t *)s;
+ s += 4;
+ *d++ = ((rgb & 0xFF) >> 3) +
+ ((rgb & 0xFC00) >> 5) +
+ ((rgb & 0xF80000) >> 8);
}
}
-static inline void rgb32tobgr16_c(const uint8_t *src, uint8_t *dst, int src_size)
+static inline void rgb32tobgr16_c(const uint8_t *src, uint8_t *dst,
+ int src_size)
{
- const uint8_t *s = src;
- const uint8_t *end;
- uint16_t *d = (uint16_t *)dst;
- end = s + src_size;
+ uint16_t *d = (uint16_t *)dst;
+ const uint8_t *s = src;
+ const uint8_t *end = s + src_size;
+
while (s < end) {
- register int rgb = *(const uint32_t*)s; s += 4;
- *d++ = ((rgb&0xF8)<<8) + ((rgb&0xFC00)>>5) + ((rgb&0xF80000)>>19);
+ register int rgb = *(const uint32_t *)s;
+ s += 4;
+ *d++ = ((rgb & 0xF8) << 8) +
+ ((rgb & 0xFC00) >> 5) +
+ ((rgb & 0xF80000) >> 19);
}
}
static inline void rgb32to15_c(const uint8_t *src, uint8_t *dst, int src_size)
{
- const uint8_t *s = src;
- const uint8_t *end;
- uint16_t *d = (uint16_t *)dst;
- end = s + src_size;
+ uint16_t *d = (uint16_t *)dst;
+ const uint8_t *s = src;
+ const uint8_t *end = s + src_size;
+
while (s < end) {
- register int rgb = *(const uint32_t*)s; s += 4;
- *d++ = ((rgb&0xFF)>>3) + ((rgb&0xF800)>>6) + ((rgb&0xF80000)>>9);
+ register int rgb = *(const uint32_t *)s;
+ s += 4;
+ *d++ = ((rgb & 0xFF) >> 3) +
+ ((rgb & 0xF800) >> 6) +
+ ((rgb & 0xF80000) >> 9);
}
}
-static inline void rgb32tobgr15_c(const uint8_t *src, uint8_t *dst, int src_size)
+static inline void rgb32tobgr15_c(const uint8_t *src, uint8_t *dst,
+ int src_size)
{
- const uint8_t *s = src;
- const uint8_t *end;
- uint16_t *d = (uint16_t *)dst;
- end = s + src_size;
+ uint16_t *d = (uint16_t *)dst;
+ const uint8_t *s = src;
+ const uint8_t *end = s + src_size;
+
while (s < end) {
- register int rgb = *(const uint32_t*)s; s += 4;
- *d++ = ((rgb&0xF8)<<7) + ((rgb&0xF800)>>6) + ((rgb&0xF80000)>>19);
+ register int rgb = *(const uint32_t *)s;
+ s += 4;
+ *d++ = ((rgb & 0xF8) << 7) +
+ ((rgb & 0xF800) >> 6) +
+ ((rgb & 0xF80000) >> 19);
}
}
-static inline void rgb24tobgr16_c(const uint8_t *src, uint8_t *dst, int src_size)
+static inline void rgb24tobgr16_c(const uint8_t *src, uint8_t *dst,
+ int src_size)
{
- const uint8_t *s = src;
- const uint8_t *end;
- uint16_t *d = (uint16_t *)dst;
- end = s + src_size;
+ uint16_t *d = (uint16_t *)dst;
+ const uint8_t *s = src;
+ const uint8_t *end = s + src_size;
+
while (s < end) {
const int b = *s++;
const int g = *s++;
const int r = *s++;
- *d++ = (b>>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8);
+ *d++ = (b >> 3) | ((g & 0xFC) << 3) | ((r & 0xF8) << 8);
}
}
static inline void rgb24to16_c(const uint8_t *src, uint8_t *dst, int src_size)
{
- const uint8_t *s = src;
- const uint8_t *end;
- uint16_t *d = (uint16_t *)dst;
- end = s + src_size;
+ uint16_t *d = (uint16_t *)dst;
+ const uint8_t *s = src;
+ const uint8_t *end = s + src_size;
+
while (s < end) {
const int r = *s++;
const int g = *s++;
const int b = *s++;
- *d++ = (b>>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8);
+ *d++ = (b >> 3) | ((g & 0xFC) << 3) | ((r & 0xF8) << 8);
}
}
-static inline void rgb24tobgr15_c(const uint8_t *src, uint8_t *dst, int src_size)
+static inline void rgb24tobgr15_c(const uint8_t *src, uint8_t *dst,
+ int src_size)
{
- const uint8_t *s = src;
- const uint8_t *end;
- uint16_t *d = (uint16_t *)dst;
- end = s + src_size;
+ uint16_t *d = (uint16_t *)dst;
+ const uint8_t *s = src;
+ const uint8_t *end = s + src_size;
+
while (s < end) {
const int b = *s++;
const int g = *s++;
const int r = *s++;
- *d++ = (b>>3) | ((g&0xF8)<<2) | ((r&0xF8)<<7);
+ *d++ = (b >> 3) | ((g & 0xF8) << 2) | ((r & 0xF8) << 7);
}
}
static inline void rgb24to15_c(const uint8_t *src, uint8_t *dst, int src_size)
{
- const uint8_t *s = src;
- const uint8_t *end;
- uint16_t *d = (uint16_t *)dst;
- end = s + src_size;
+ uint16_t *d = (uint16_t *)dst;
+ const uint8_t *s = src;
+ const uint8_t *end = s + src_size;
+
while (s < end) {
const int r = *s++;
const int g = *s++;
const int b = *s++;
- *d++ = (b>>3) | ((g&0xF8)<<2) | ((r&0xF8)<<7);
+ *d++ = (b >> 3) | ((g & 0xF8) << 2) | ((r & 0xF8) << 7);
}
}
-static inline void rgb15tobgr24_c(const uint8_t *src, uint8_t *dst, int src_size)
+static inline void rgb15tobgr24_c(const uint8_t *src, uint8_t *dst,
+ int src_size)
{
- const uint16_t *end;
- uint8_t *d = dst;
- const uint16_t *s = (const uint16_t*)src;
- end = s + src_size/2;
+ uint8_t *d = dst;
+ const uint16_t *s = (const uint16_t *)src;
+ const uint16_t *end = s + src_size / 2;
+
while (s < end) {
- register uint16_t bgr;
- bgr = *s++;
- *d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2);
- *d++ = ((bgr&0x3E0)>>2) | ((bgr&0x3E0)>>7);
+ register uint16_t bgr = *s++;
+ *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2);
+ *d++ = ((bgr&0x03E0)>>2) | ((bgr&0x03E0)>> 7);
*d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12);
}
}
-static inline void rgb16tobgr24_c(const uint8_t *src, uint8_t *dst, int src_size)
+static inline void rgb16tobgr24_c(const uint8_t *src, uint8_t *dst,
+ int src_size)
{
- const uint16_t *end;
- uint8_t *d = (uint8_t *)dst;
- const uint16_t *s = (const uint16_t *)src;
- end = s + src_size/2;
+ uint8_t *d = (uint8_t *)dst;
+ const uint16_t *s = (const uint16_t *)src;
+ const uint16_t *end = s + src_size / 2;
+
while (s < end) {
- register uint16_t bgr;
- bgr = *s++;
- *d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2);
- *d++ = ((bgr&0x7E0)>>3) | ((bgr&0x7E0)>>9);
+ register uint16_t bgr = *s++;
+ *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2);
+ *d++ = ((bgr&0x07E0)>>3) | ((bgr&0x07E0)>> 9);
*d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13);
}
}
static inline void rgb15to32_c(const uint8_t *src, uint8_t *dst, int src_size)
{
- const uint16_t *end;
- uint8_t *d = dst;
- const uint16_t *s = (const uint16_t *)src;
- end = s + src_size/2;
+ uint8_t *d = dst;
+ const uint16_t *s = (const uint16_t *)src;
+ const uint16_t *end = s + src_size / 2;
+
while (s < end) {
- register uint16_t bgr;
- bgr = *s++;
+ register uint16_t bgr = *s++;
#if HAVE_BIGENDIAN
*d++ = 255;
*d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12);
- *d++ = ((bgr&0x3E0)>>2) | ((bgr&0x3E0)>>7);
- *d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2);
+ *d++ = ((bgr&0x03E0)>>2) | ((bgr&0x03E0)>> 7);
+ *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2);
#else
- *d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2);
- *d++ = ((bgr&0x3E0)>>2) | ((bgr&0x3E0)>>7);
+ *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2);
+ *d++ = ((bgr&0x03E0)>>2) | ((bgr&0x03E0)>> 7);
*d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12);
*d++ = 255;
#endif
@@ -282,48 +292,49 @@ static inline void rgb15to32_c(const uint8_t *src, uint8_t *dst, int src_size)
static inline void rgb16to32_c(const uint8_t *src, uint8_t *dst, int src_size)
{
- const uint16_t *end;
- uint8_t *d = dst;
- const uint16_t *s = (const uint16_t*)src;
- end = s + src_size/2;
+ uint8_t *d = dst;
+ const uint16_t *s = (const uint16_t *)src;
+ const uint16_t *end = s + src_size / 2;
+
while (s < end) {
- register uint16_t bgr;
- bgr = *s++;
+ register uint16_t bgr = *s++;
#if HAVE_BIGENDIAN
*d++ = 255;
*d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13);
- *d++ = ((bgr&0x7E0)>>3) | ((bgr&0x7E0)>>9);
- *d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2);
+ *d++ = ((bgr&0x07E0)>>3) | ((bgr&0x07E0)>> 9);
+ *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2);
#else
- *d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2);
- *d++ = ((bgr&0x7E0)>>3) | ((bgr&0x7E0)>>9);
+ *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2);
+ *d++ = ((bgr&0x07E0)>>3) | ((bgr&0x07E0)>> 9);
*d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13);
*d++ = 255;
#endif
}
}
-static inline void shuffle_bytes_2103_c(const uint8_t *src, uint8_t *dst, int src_size)
+static inline void shuffle_bytes_2103_c(const uint8_t *src, uint8_t *dst,
+ int src_size)
{
- int idx = 15 - src_size;
- const uint8_t *s = src-idx;
- uint8_t *d = dst-idx;
- for (; idx<15; idx+=4) {
- register int v = *(const uint32_t *)&s[idx], g = v & 0xff00ff00;
- v &= 0xff00ff;
- *(uint32_t *)&d[idx] = (v>>16) + g + (v<<16);
+ int idx = 15 - src_size;
+ const uint8_t *s = src - idx;
+ uint8_t *d = dst - idx;
+
+ for (; idx < 15; idx += 4) {
+ register int v = *(const uint32_t *)&s[idx], g = v & 0xff00ff00;
+ v &= 0xff00ff;
+ *(uint32_t *)&d[idx] = (v >> 16) + g + (v << 16);
}
}
static inline void rgb24tobgr24_c(const uint8_t *src, uint8_t *dst, int src_size)
{
unsigned i;
- for (i=0; i<src_size; i+=3) {
- register uint8_t x;
- x = src[i + 2];
- dst[i + 1] = src[i + 1];
- dst[i + 2] = src[i + 0];
- dst[i + 0] = x;
+
+ for (i = 0; i < src_size; i += 3) {
+ register uint8_t x = src[i + 2];
+ dst[i + 1] = src[i + 1];
+ dst[i + 2] = src[i + 0];
+ dst[i + 0] = x;
}
}
@@ -333,42 +344,42 @@ static inline void yuvPlanartoyuy2_c(const uint8_t *ysrc, const uint8_t *usrc,
int lumStride, int chromStride,
int dstStride, int vertLumPerChroma)
{
- int y;
+ int y, i;
const int chromWidth = width >> 1;
- for (y=0; y<height; y++) {
+
+ for (y = 0; y < height; y++) {
#if HAVE_FAST_64BIT
- int i;
- uint64_t *ldst = (uint64_t *) dst;
+ uint64_t *ldst = (uint64_t *)dst;
const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;
for (i = 0; i < chromWidth; i += 2) {
- uint64_t k, l;
- k = yc[0] + (uc[0] << 8) +
- (yc[1] << 16) + (vc[0] << 24);
- l = yc[2] + (uc[1] << 8) +
- (yc[3] << 16) + (vc[1] << 24);
+ uint64_t k = yc[0] + (uc[0] << 8) +
+ (yc[1] << 16) + (vc[0] << 24);
+ uint64_t l = yc[2] + (uc[1] << 8) +
+ (yc[3] << 16) + (vc[1] << 24);
*ldst++ = k + (l << 32);
- yc += 4;
- uc += 2;
- vc += 2;
+ yc += 4;
+ uc += 2;
+ vc += 2;
}
#else
- int i, *idst = (int32_t *) dst;
+ int *idst = (int32_t *)dst;
const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;
+
for (i = 0; i < chromWidth; i++) {
#if HAVE_BIGENDIAN
- *idst++ = (yc[0] << 24)+ (uc[0] << 16) +
- (yc[1] << 8) + (vc[0] << 0);
+ *idst++ = (yc[0] << 24) + (uc[0] << 16) +
+ (yc[1] << 8) + (vc[0] << 0);
#else
*idst++ = yc[0] + (uc[0] << 8) +
- (yc[1] << 16) + (vc[0] << 24);
+ (yc[1] << 16) + (vc[0] << 24);
#endif
yc += 2;
uc++;
vc++;
}
#endif
- if ((y&(vertLumPerChroma-1)) == vertLumPerChroma-1) {
+ if ((y & (vertLumPerChroma - 1)) == vertLumPerChroma - 1) {
usrc += chromStride;
vsrc += chromStride;
}
@@ -383,9 +394,8 @@ static inline void yuvPlanartoyuy2_c(const uint8_t *ysrc, const uint8_t *usrc,
*/
static inline void yv12toyuy2_c(const uint8_t *ysrc, const uint8_t *usrc,
const uint8_t *vsrc, uint8_t *dst,
- int width, int height,
- int lumStride, int chromStride,
- int dstStride)
+ int width, int height, int lumStride,
+ int chromStride, int dstStride)
{
//FIXME interpolate chroma
yuvPlanartoyuy2_c(ysrc, usrc, vsrc, dst, width, height, lumStride,
@@ -398,47 +408,47 @@ static inline void yuvPlanartouyvy_c(const uint8_t *ysrc, const uint8_t *usrc,
int lumStride, int chromStride,
int dstStride, int vertLumPerChroma)
{
- int y;
+ int y, i;
const int chromWidth = width >> 1;
- for (y=0; y<height; y++) {
+
+ for (y = 0; y < height; y++) {
#if HAVE_FAST_64BIT
- int i;
- uint64_t *ldst = (uint64_t *) dst;
+ uint64_t *ldst = (uint64_t *)dst;
const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;
for (i = 0; i < chromWidth; i += 2) {
- uint64_t k, l;
- k = uc[0] + (yc[0] << 8) +
- (vc[0] << 16) + (yc[1] << 24);
- l = uc[1] + (yc[2] << 8) +
- (vc[1] << 16) + (yc[3] << 24);
+ uint64_t k = uc[0] + (yc[0] << 8) +
+ (vc[0] << 16) + (yc[1] << 24);
+ uint64_t l = uc[1] + (yc[2] << 8) +
+ (vc[1] << 16) + (yc[3] << 24);
*ldst++ = k + (l << 32);
- yc += 4;
- uc += 2;
- vc += 2;
+ yc += 4;
+ uc += 2;
+ vc += 2;
}
#else
- int i, *idst = (int32_t *) dst;
+ int *idst = (int32_t *)dst;
const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;
+
for (i = 0; i < chromWidth; i++) {
#if HAVE_BIGENDIAN
- *idst++ = (uc[0] << 24)+ (yc[0] << 16) +
- (vc[0] << 8) + (yc[1] << 0);
+ *idst++ = (uc[0] << 24) + (yc[0] << 16) +
+ (vc[0] << 8) + (yc[1] << 0);
#else
*idst++ = uc[0] + (yc[0] << 8) +
- (vc[0] << 16) + (yc[1] << 24);
+ (vc[0] << 16) + (yc[1] << 24);
#endif
yc += 2;
uc++;
vc++;
}
#endif
- if ((y&(vertLumPerChroma-1)) == vertLumPerChroma-1) {
+ if ((y & (vertLumPerChroma - 1)) == vertLumPerChroma - 1) {
usrc += chromStride;
vsrc += chromStride;
}
ysrc += lumStride;
- dst += dstStride;
+ dst += dstStride;
}
}
@@ -448,9 +458,8 @@ static inline void yuvPlanartouyvy_c(const uint8_t *ysrc, const uint8_t *usrc,
*/
static inline void yv12touyvy_c(const uint8_t *ysrc, const uint8_t *usrc,
const uint8_t *vsrc, uint8_t *dst,
- int width, int height,
- int lumStride, int chromStride,
- int dstStride)
+ int width, int height, int lumStride,
+ int chromStride, int dstStride)
{
//FIXME interpolate chroma
yuvPlanartouyvy_c(ysrc, usrc, vsrc, dst, width, height, lumStride,
@@ -462,9 +471,8 @@ static inline void yv12touyvy_c(const uint8_t *ysrc, const uint8_t *usrc,
*/
static inline void yuv422ptouyvy_c(const uint8_t *ysrc, const uint8_t *usrc,
const uint8_t *vsrc, uint8_t *dst,
- int width, int height,
- int lumStride, int chromStride,
- int dstStride)
+ int width, int height, int lumStride,
+ int chromStride, int dstStride)
{
yuvPlanartouyvy_c(ysrc, usrc, vsrc, dst, width, height, lumStride,
chromStride, dstStride, 1);
@@ -475,9 +483,8 @@ static inline void yuv422ptouyvy_c(const uint8_t *ysrc, const uint8_t *usrc,
*/
static inline void yuv422ptoyuy2_c(const uint8_t *ysrc, const uint8_t *usrc,
const uint8_t *vsrc, uint8_t *dst,
- int width, int height,
- int lumStride, int chromStride,
- int dstStride)
+ int width, int height, int lumStride,
+ int chromStride, int dstStride)
{
yuvPlanartoyuy2_c(ysrc, usrc, vsrc, dst, width, height, lumStride,
chromStride, dstStride, 1);
@@ -489,26 +496,26 @@ static inline void yuv422ptoyuy2_c(const uint8_t *ysrc, const uint8_t *usrc,
*/
static inline void yuy2toyv12_c(const uint8_t *src, uint8_t *ydst,
uint8_t *udst, uint8_t *vdst,
- int width, int height,
- int lumStride, int chromStride,
- int srcStride)
+ int width, int height, int lumStride,
+ int chromStride, int srcStride)
{
int y;
const int chromWidth = width >> 1;
- for (y=0; y<height; y+=2) {
+
+ for (y = 0; y < height; y += 2) {
int i;
- for (i=0; i<chromWidth; i++) {
- ydst[2*i+0] = src[4*i+0];
- udst[i] = src[4*i+1];
- ydst[2*i+1] = src[4*i+2];
- vdst[i] = src[4*i+3];
+ for (i = 0; i < chromWidth; i++) {
+ ydst[2 * i + 0] = src[4 * i + 0];
+ udst[i] = src[4 * i + 1];
+ ydst[2 * i + 1] = src[4 * i + 2];
+ vdst[i] = src[4 * i + 3];
}
ydst += lumStride;
src += srcStride;
- for (i=0; i<chromWidth; i++) {
- ydst[2*i+0] = src[4*i+0];
- ydst[2*i+1] = src[4*i+2];
+ for (i = 0; i < chromWidth; i++) {
+ ydst[2 * i + 0] = src[4 * i + 0];
+ ydst[2 * i + 1] = src[4 * i + 2];
}
udst += chromStride;
vdst += chromStride;
@@ -520,46 +527,46 @@ static inline void yuy2toyv12_c(const uint8_t *src, uint8_t *ydst,
static inline void planar2x_c(const uint8_t *src, uint8_t *dst, int srcWidth,
int srcHeight, int srcStride, int dstStride)
{
- int x,y;
+ int x, y;
- dst[0]= src[0];
+ dst[0] = src[0];
// first line
- for (x=0; x<srcWidth-1; x++) {
- dst[2*x+1]= (3*src[x] + src[x+1])>>2;
- dst[2*x+2]= ( src[x] + 3*src[x+1])>>2;
+ for (x = 0; x < srcWidth - 1; x++) {
+ dst[2 * x + 1] = (3 * src[x] + src[x + 1]) >> 2;
+ dst[2 * x + 2] = (src[x] + 3 * src[x + 1]) >> 2;
}
- dst[2*srcWidth-1]= src[srcWidth-1];
+ dst[2 * srcWidth - 1] = src[srcWidth - 1];
- dst+= dstStride;
+ dst += dstStride;
- for (y=1; y<srcHeight; y++) {
+ for (y = 1; y < srcHeight; y++) {
const int mmxSize = 1;
- dst[0 ]= (3*src[0] + src[srcStride])>>2;
- dst[dstStride]= ( src[0] + 3*src[srcStride])>>2;
+ dst[0] = (src[0] * 3 + src[srcStride]) >> 2;
+ dst[dstStride] = (src[0] + 3 * src[srcStride]) >> 2;
- for (x=mmxSize-1; x<srcWidth-1; x++) {
- dst[2*x +1]= (3*src[x+0] + src[x+srcStride+1])>>2;
- dst[2*x+dstStride+2]= ( src[x+0] + 3*src[x+srcStride+1])>>2;
- dst[2*x+dstStride+1]= ( src[x+1] + 3*src[x+srcStride ])>>2;
- dst[2*x +2]= (3*src[x+1] + src[x+srcStride ])>>2;
+ for (x = mmxSize - 1; x < srcWidth - 1; x++) {
+ dst[2 * x + 1] = (src[x + 0] * 3 + src[x + srcStride + 1]) >> 2;
+ dst[2 * x + dstStride + 2] = (src[x + 0] + 3 * src[x + srcStride + 1]) >> 2;
+ dst[2 * x + dstStride + 1] = (src[x + 1] + 3 * src[x + srcStride]) >> 2;
+ dst[2 * x + 2] = (src[x + 1] * 3 + src[x + srcStride]) >> 2;
}
- dst[srcWidth*2 -1 ]= (3*src[srcWidth-1] + src[srcWidth-1 + srcStride])>>2;
- dst[srcWidth*2 -1 + dstStride]= ( src[srcWidth-1] + 3*src[srcWidth-1 + srcStride])>>2;
+ dst[srcWidth * 2 - 1] = (src[srcWidth - 1] * 3 + src[srcWidth - 1 + srcStride]) >> 2;
+ dst[srcWidth * 2 - 1 + dstStride] = (src[srcWidth - 1] + 3 * src[srcWidth - 1 + srcStride]) >> 2;
- dst+=dstStride*2;
- src+=srcStride;
+ dst += dstStride * 2;
+ src += srcStride;
}
// last line
- dst[0]= src[0];
+ dst[0] = src[0];
- for (x=0; x<srcWidth-1; x++) {
- dst[2*x+1]= (3*src[x] + src[x+1])>>2;
- dst[2*x+2]= ( src[x] + 3*src[x+1])>>2;
+ for (x = 0; x < srcWidth - 1; x++) {
+ dst[2 * x + 1] = (src[x] * 3 + src[x + 1]) >> 2;
+ dst[2 * x + 2] = (src[x] + 3 * src[x + 1]) >> 2;
}
- dst[2*srcWidth-1]= src[srcWidth-1];
+ dst[2 * srcWidth - 1] = src[srcWidth - 1];
}
/**
@@ -570,26 +577,26 @@ static inline void planar2x_c(const uint8_t *src, uint8_t *dst, int srcWidth,
*/
static inline void uyvytoyv12_c(const uint8_t *src, uint8_t *ydst,
uint8_t *udst, uint8_t *vdst,
- int width, int height,
- int lumStride, int chromStride,
- int srcStride)
+ int width, int height, int lumStride,
+ int chromStride, int srcStride)
{
int y;
const int chromWidth = width >> 1;
- for (y=0; y<height; y+=2) {
+
+ for (y = 0; y < height; y += 2) {
int i;
- for (i=0; i<chromWidth; i++) {
- udst[i] = src[4*i+0];
- ydst[2*i+0] = src[4*i+1];
- vdst[i] = src[4*i+2];
- ydst[2*i+1] = src[4*i+3];
+ for (i = 0; i < chromWidth; i++) {
+ udst[i] = src[4 * i + 0];
+ ydst[2 * i + 0] = src[4 * i + 1];
+ vdst[i] = src[4 * i + 2];
+ ydst[2 * i + 1] = src[4 * i + 3];
}
ydst += lumStride;
src += srcStride;
- for (i=0; i<chromWidth; i++) {
- ydst[2*i+0] = src[4*i+1];
- ydst[2*i+1] = src[4*i+3];
+ for (i = 0; i < chromWidth; i++) {
+ ydst[2 * i + 0] = src[4 * i + 1];
+ ydst[2 * i + 1] = src[4 * i + 3];
}
udst += chromStride;
vdst += chromStride;
@@ -611,50 +618,50 @@ void rgb24toyv12_c(const uint8_t *src, uint8_t *ydst, uint8_t *udst,
{
int y;
const int chromWidth = width >> 1;
- y=0;
- for (; y<height; y+=2) {
+
+ for (y = 0; y < height; y += 2) {
int i;
- for (i=0; i<chromWidth; i++) {
- unsigned int b = src[6*i+0];
- unsigned int g = src[6*i+1];
- unsigned int r = src[6*i+2];
+ for (i = 0; i < chromWidth; i++) {
+ unsigned int b = src[6 * i + 0];
+ unsigned int g = src[6 * i + 1];
+ unsigned int r = src[6 * i + 2];
- unsigned int Y = ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16;
- unsigned int V = ((RV*r + GV*g + BV*b)>>RGB2YUV_SHIFT) + 128;
- unsigned int U = ((RU*r + GU*g + BU*b)>>RGB2YUV_SHIFT) + 128;
+ unsigned int Y = ((RY * r + GY * g + BY * b) >> RGB2YUV_SHIFT) + 16;
+ unsigned int V = ((RV * r + GV * g + BV * b) >> RGB2YUV_SHIFT) + 128;
+ unsigned int U = ((RU * r + GU * g + BU * b) >> RGB2YUV_SHIFT) + 128;
udst[i] = U;
vdst[i] = V;
- ydst[2*i] = Y;
+ ydst[2 * i] = Y;
- b = src[6*i+3];
- g = src[6*i+4];
- r = src[6*i+5];
+ b = src[6 * i + 3];
+ g = src[6 * i + 4];
+ r = src[6 * i + 5];
- Y = ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16;
- ydst[2*i+1] = Y;
+ Y = ((RY * r + GY * g + BY * b) >> RGB2YUV_SHIFT) + 16;
+ ydst[2 * i + 1] = Y;
}
ydst += lumStride;
src += srcStride;
- if(y+1 == height)
+ if (y+1 == height)
break;
- for (i=0; i<chromWidth; i++) {
- unsigned int b = src[6*i+0];
- unsigned int g = src[6*i+1];
- unsigned int r = src[6*i+2];
+ for (i = 0; i < chromWidth; i++) {
+ unsigned int b = src[6 * i + 0];
+ unsigned int g = src[6 * i + 1];
+ unsigned int r = src[6 * i + 2];
- unsigned int Y = ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16;
+ unsigned int Y = ((RY * r + GY * g + BY * b) >> RGB2YUV_SHIFT) + 16;
- ydst[2*i] = Y;
+ ydst[2 * i] = Y;
- b = src[6*i+3];
- g = src[6*i+4];
- r = src[6*i+5];
+ b = src[6 * i + 3];
+ g = src[6 * i + 4];
+ r = src[6 * i + 5];
- Y = ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16;
- ydst[2*i+1] = Y;
+ Y = ((RY * r + GY * g + BY * b) >> RGB2YUV_SHIFT) + 16;
+ ydst[2 * i + 1] = Y;
}
udst += chromStride;
vdst += chromStride;
@@ -664,17 +671,16 @@ void rgb24toyv12_c(const uint8_t *src, uint8_t *ydst, uint8_t *udst,
}
static void interleaveBytes_c(const uint8_t *src1, const uint8_t *src2,
- uint8_t *dest, int width,
- int height, int src1Stride,
- int src2Stride, int dstStride)
+ uint8_t *dest, int width, int height,
+ int src1Stride, int src2Stride, int dstStride)
{
int h;
- for (h=0; h < height; h++) {
+ for (h = 0; h < height; h++) {
int w;
- for (w=0; w < width; w++) {
- dest[2*w+0] = src1[w];
- dest[2*w+1] = src2[w];
+ for (w = 0; w < width; w++) {
+ dest[2 * w + 0] = src1[w];
+ dest[2 * w + 1] = src2[w];
}
dest += dstStride;
src1 += src1Stride;
@@ -688,20 +694,21 @@ static inline void vu9_to_vu12_c(const uint8_t *src1, const uint8_t *src2,
int srcStride1, int srcStride2,
int dstStride1, int dstStride2)
{
- int y;
- int x,w,h;
- w=width/2; h=height/2;
- for (y=0;y<h;y++) {
- const uint8_t* s1=src1+srcStride1*(y>>1);
- uint8_t* d=dst1+dstStride1*y;
- x=0;
- for (;x<w;x++) d[2*x]=d[2*x+1]=s1[x];
+ int x, y;
+ int w = width / 2;
+ int h = height / 2;
+
+ for (y = 0; y < h; y++) {
+ const uint8_t *s1 = src1 + srcStride1 * (y >> 1);
+ uint8_t *d = dst1 + dstStride1 * y;
+ for (x = 0; x < w; x++)
+ d[2 * x] = d[2 * x + 1] = s1[x];
}
- for (y=0;y<h;y++) {
- const uint8_t* s2=src2+srcStride2*(y>>1);
- uint8_t* d=dst2+dstStride2*y;
- x=0;
- for (;x<w;x++) d[2*x]=d[2*x+1]=s2[x];
+ for (y = 0; y < h; y++) {
+ const uint8_t *s2 = src2 + srcStride2 * (y >> 1);
+ uint8_t *d = dst2 + dstStride2 * y;
+ for (x = 0; x < w; x++)
+ d[2 * x] = d[2 * x + 1] = s2[x];
}
}
@@ -711,37 +718,36 @@ static inline void yvu9_to_yuy2_c(const uint8_t *src1, const uint8_t *src2,
int srcStride1, int srcStride2,
int srcStride3, int dstStride)
{
- int x;
- int y,w,h;
- w=width/2; h=height;
- for (y=0;y<h;y++) {
- const uint8_t* yp=src1+srcStride1*y;
- const uint8_t* up=src2+srcStride2*(y>>2);
- const uint8_t* vp=src3+srcStride3*(y>>2);
- uint8_t* d=dst+dstStride*y;
- x=0;
- for (; x<w; x++) {
- const int x2 = x<<2;
- d[8*x+0] = yp[x2];
- d[8*x+1] = up[x];
- d[8*x+2] = yp[x2+1];
- d[8*x+3] = vp[x];
- d[8*x+4] = yp[x2+2];
- d[8*x+5] = up[x];
- d[8*x+6] = yp[x2+3];
- d[8*x+7] = vp[x];
+ int x, y;
+ int w = width / 2;
+ int h = height;
+
+ for (y = 0; y < h; y++) {
+ const uint8_t *yp = src1 + srcStride1 * y;
+ const uint8_t *up = src2 + srcStride2 * (y >> 2);
+ const uint8_t *vp = src3 + srcStride3 * (y >> 2);
+ uint8_t *d = dst + dstStride * y;
+ for (x = 0; x < w; x++) {
+ const int x2 = x << 2;
+ d[8 * x + 0] = yp[x2];
+ d[8 * x + 1] = up[x];
+ d[8 * x + 2] = yp[x2 + 1];
+ d[8 * x + 3] = vp[x];
+ d[8 * x + 4] = yp[x2 + 2];
+ d[8 * x + 5] = up[x];
+ d[8 * x + 6] = yp[x2 + 3];
+ d[8 * x + 7] = vp[x];
}
}
}
static void extract_even_c(const uint8_t *src, uint8_t *dst, int count)
{
- dst += count;
- src += 2*count;
- count= - count;
-
- while(count<0) {
- dst[count]= src[2*count];
+ dst += count;
+ src += count * 2;
+ count = -count;
+ while (count < 0) {
+ dst[count] = src[2 * count];
count++;
}
}
@@ -749,13 +755,13 @@ static void extract_even_c(const uint8_t *src, uint8_t *dst, int count)
static void extract_even2_c(const uint8_t *src, uint8_t *dst0, uint8_t *dst1,
int count)
{
- dst0+= count;
- dst1+= count;
- src += 4*count;
- count= - count;
- while(count<0) {
- dst0[count]= src[4*count+0];
- dst1[count]= src[4*count+2];
+ dst0 += count;
+ dst1 += count;
+ src += count * 4;
+ count = -count;
+ while (count < 0) {
+ dst0[count] = src[4 * count + 0];
+ dst1[count] = src[4 * count + 2];
count++;
}
}
@@ -763,14 +769,14 @@ static void extract_even2_c(const uint8_t *src, uint8_t *dst0, uint8_t *dst1,
static void extract_even2avg_c(const uint8_t *src0, const uint8_t *src1,
uint8_t *dst0, uint8_t *dst1, int count)
{
- dst0 += count;
- dst1 += count;
- src0 += 4*count;
- src1 += 4*count;
- count= - count;
- while(count<0) {
- dst0[count]= (src0[4*count+0]+src1[4*count+0])>>1;
- dst1[count]= (src0[4*count+2]+src1[4*count+2])>>1;
+ dst0 += count;
+ dst1 += count;
+ src0 += count * 4;
+ src1 += count * 4;
+ count = -count;
+ while (count < 0) {
+ dst0[count] = (src0[4 * count + 0] + src1[4 * count + 0]) >> 1;
+ dst1[count] = (src0[4 * count + 2] + src1[4 * count + 2]) >> 1;
count++;
}
}
@@ -778,14 +784,14 @@ static void extract_even2avg_c(const uint8_t *src0, const uint8_t *src1,
static void extract_odd2_c(const uint8_t *src, uint8_t *dst0, uint8_t *dst1,
int count)
{
- dst0+= count;
- dst1+= count;
- src += 4*count;
- count= - count;
+ dst0 += count;
+ dst1 += count;
+ src += count * 4;
+ count = -count;
src++;
- while(count<0) {
- dst0[count]= src[4*count+0];
- dst1[count]= src[4*count+2];
+ while (count < 0) {
+ dst0[count] = src[4 * count + 0];
+ dst1[count] = src[4 * count + 2];
count++;
}
}
@@ -793,16 +799,16 @@ static void extract_odd2_c(const uint8_t *src, uint8_t *dst0, uint8_t *dst1,
static void extract_odd2avg_c(const uint8_t *src0, const uint8_t *src1,
uint8_t *dst0, uint8_t *dst1, int count)
{
- dst0 += count;
- dst1 += count;
- src0 += 4*count;
- src1 += 4*count;
- count= - count;
+ dst0 += count;
+ dst1 += count;
+ src0 += count * 4;
+ src1 += count * 4;
+ count = -count;
src0++;
src1++;
- while(count<0) {
- dst0[count]= (src0[4*count+0]+src1[4*count+0])>>1;
- dst1[count]= (src0[4*count+2]+src1[4*count+2])>>1;
+ while (count < 0) {
+ dst0[count] = (src0[4 * count + 0] + src1[4 * count + 0]) >> 1;
+ dst1[count] = (src0[4 * count + 2] + src1[4 * count + 2]) >> 1;
count++;
}
}
@@ -812,18 +818,18 @@ static void yuyvtoyuv420_c(uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
int lumStride, int chromStride, int srcStride)
{
int y;
- const int chromWidth= -((-width)>>1);
+ const int chromWidth = -((-width) >> 1);
- for (y=0; y<height; y++) {
+ for (y = 0; y < height; y++) {
extract_even_c(src, ydst, width);
- if(y&1) {
+ if (y & 1) {
extract_odd2avg_c(src - srcStride, src, udst, vdst, chromWidth);
- udst+= chromStride;
- vdst+= chromStride;
+ udst += chromStride;
+ vdst += chromStride;
}
- src += srcStride;
- ydst+= lumStride;
+ src += srcStride;
+ ydst += lumStride;
}
}
@@ -832,16 +838,16 @@ static void yuyvtoyuv422_c(uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
int lumStride, int chromStride, int srcStride)
{
int y;
- const int chromWidth= -((-width)>>1);
+ const int chromWidth = -((-width) >> 1);
- for (y=0; y<height; y++) {
+ for (y = 0; y < height; y++) {
extract_even_c(src, ydst, width);
extract_odd2_c(src, udst, vdst, chromWidth);
- src += srcStride;
- ydst+= lumStride;
- udst+= chromStride;
- vdst+= chromStride;
+ src += srcStride;
+ ydst += lumStride;
+ udst += chromStride;
+ vdst += chromStride;
}
}
@@ -850,18 +856,18 @@ static void uyvytoyuv420_c(uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
int lumStride, int chromStride, int srcStride)
{
int y;
- const int chromWidth= -((-width)>>1);
+ const int chromWidth = -((-width) >> 1);
- for (y=0; y<height; y++) {
+ for (y = 0; y < height; y++) {
extract_even_c(src + 1, ydst, width);
- if(y&1) {
+ if (y & 1) {
extract_even2avg_c(src - srcStride, src, udst, vdst, chromWidth);
- udst+= chromStride;
- vdst+= chromStride;
+ udst += chromStride;
+ vdst += chromStride;
}
- src += srcStride;
- ydst+= lumStride;
+ src += srcStride;
+ ydst += lumStride;
}
}
@@ -870,16 +876,16 @@ static void uyvytoyuv422_c(uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
int lumStride, int chromStride, int srcStride)
{
int y;
- const int chromWidth= -((-width)>>1);
+ const int chromWidth = -((-width) >> 1);
- for (y=0; y<height; y++) {
+ for (y = 0; y < height; y++) {
extract_even_c(src + 1, ydst, width);
extract_even2_c(src, udst, vdst, chromWidth);
- src += srcStride;
- ydst+= lumStride;
- udst+= chromStride;
- vdst+= chromStride;
+ src += srcStride;
+ ydst += lumStride;
+ udst += chromStride;
+ vdst += chromStride;
}
}