changed rgba32_to routines to support both alpha and non-alpha formats

Originally committed as revision 7066 to svn://svn.ffmpeg.org/ffmpeg/trunk
pull/126/head
Alex Beregszaszi 19 years ago
parent d8b45f7961
commit 8e96866a52
  1. 26
      libavcodec/imgconvert_template.h

@ -410,7 +410,8 @@ static void glue(pal8_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
} }
} }
#if !defined(FMT_RGBA32) && defined(RGBA_OUT) // RGB24 has optimised routines
#if !defined(FMT_RGBA32) && !defined(FMT_RGB24)
/* alpha support */ /* alpha support */
static void glue(rgba32_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src, static void glue(rgba32_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
@ -419,7 +420,10 @@ static void glue(rgba32_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
const uint8_t *s; const uint8_t *s;
uint8_t *d; uint8_t *d;
int src_wrap, dst_wrap, j, y; int src_wrap, dst_wrap, j, y;
unsigned int v, r, g, b, a; unsigned int v, r, g, b;
#ifdef RGBA_OUT
unsigned int a;
#endif
s = src->data[0]; s = src->data[0];
src_wrap = src->linesize[0] - width * 4; src_wrap = src->linesize[0] - width * 4;
@ -430,11 +434,15 @@ static void glue(rgba32_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
for(y=0;y<height;y++) { for(y=0;y<height;y++) {
for(j = 0;j < width; j++) { for(j = 0;j < width; j++) {
v = ((const uint32_t *)(s))[0]; v = ((const uint32_t *)(s))[0];
a = (v >> 24) & 0xff;
r = (v >> 16) & 0xff; r = (v >> 16) & 0xff;
g = (v >> 8) & 0xff; g = (v >> 8) & 0xff;
b = v & 0xff; b = v & 0xff;
#ifdef RGBA_OUT
a = (v >> 24) & 0xff;
RGBA_OUT(d, r, g, b, a); RGBA_OUT(d, r, g, b, a);
#else
RGB_OUT(d, r, g, b);
#endif
s += 4; s += 4;
d += BPP; d += BPP;
} }
@ -449,7 +457,10 @@ static void glue(RGB_NAME, _to_rgba32)(AVPicture *dst, const AVPicture *src,
const uint8_t *s; const uint8_t *s;
uint8_t *d; uint8_t *d;
int src_wrap, dst_wrap, j, y; int src_wrap, dst_wrap, j, y;
unsigned int r, g, b, a; unsigned int r, g, b;
#ifdef RGBA_IN
unsigned int a;
#endif
s = src->data[0]; s = src->data[0];
src_wrap = src->linesize[0] - width * BPP; src_wrap = src->linesize[0] - width * BPP;
@ -459,8 +470,13 @@ static void glue(RGB_NAME, _to_rgba32)(AVPicture *dst, const AVPicture *src,
for(y=0;y<height;y++) { for(y=0;y<height;y++) {
for(j = 0;j < width; j++) { for(j = 0;j < width; j++) {
#ifdef RGBA_IN
RGBA_IN(r, g, b, a, s); RGBA_IN(r, g, b, a, s);
((uint32_t *)(d))[0] = (a << 24) | (r << 16) | (g << 8) | b; ((uint32_t *)(d))[0] = (a << 24) | (r << 16) | (g << 8) | b;
#else
RGB_IN(r, g, b, s);
((uint32_t *)(d))[0] = (0xff << 24) | (r << 16) | (g << 8) | b;
#endif
d += 4; d += 4;
s += BPP; s += BPP;
} }
@ -469,7 +485,7 @@ static void glue(RGB_NAME, _to_rgba32)(AVPicture *dst, const AVPicture *src,
} }
} }
#endif /* !defined(FMT_RGBA32) && defined(RGBA_IN) */ #endif /* !defined(FMT_RGBA32) */
#ifndef FMT_RGB24 #ifndef FMT_RGB24

Loading…
Cancel
Save