diff options
author | Fabrice Bellard <fabrice@bellard.org> | 2003-04-19 16:21:25 +0000 |
---|---|---|
committer | Fabrice Bellard <fabrice@bellard.org> | 2003-04-19 16:21:25 +0000 |
commit | 6d93f19449dd0c05e36efd3668529e12347bb47c (patch) | |
tree | 919235423c5e113a32e13f32e7cd8cf657485203 | |
parent | 5ae2c73e4d5ab813bf826c166bb0b287bc189e92 (diff) | |
download | ffmpeg-6d93f19449dd0c05e36efd3668529e12347bb47c.tar.gz |
rgba32 convert
Originally committed as revision 1794 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavcodec/imgconvert.c | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c index ca1aec6adb..8cdebf9407 100644 --- a/libavcodec/imgconvert.c +++ b/libavcodec/imgconvert.c @@ -119,7 +119,7 @@ static PixFmtInfo pix_fmt_info[PIX_FMT_NB] = { /* paletted formats */ [PIX_FMT_PAL8] = { .name = "pal8", - .nb_components = 1, .is_packed = 1, .is_paletted = 1, + .nb_components = 1, .is_packed = 1, .is_alpha = 1, .is_paletted = 1, }, }; @@ -989,7 +989,6 @@ static void gray_to_mono(AVPicture *dst, AVPicture *src, d = dst->data[0]; dst_wrap = dst->linesize[0] - ((width + 7) >> 3); - printf("%d %d\n", width, height); for(y=0;y<height;y++) { n = width; @@ -1085,6 +1084,34 @@ static void rgb24_to_pal8(AVPicture *dst, AVPicture *src, pal[i++] = 0; } +static void rgba32_to_rgb24(AVPicture *dst, AVPicture *src, + int width, int height) +{ + const uint8_t *s; + uint8_t *d; + int src_wrap, dst_wrap, j, y; + unsigned int v; + + s = src->data[0]; + src_wrap = src->linesize[0] - width * 4; + + d = dst->data[0]; + dst_wrap = dst->linesize[0] - width * 3; + + for(y=0;y<height;y++) { + for(j = 0;j < width; j++) { + v = *(uint32_t *)s; + s += 4; + d[0] = v >> 16; + d[1] = v >> 8; + d[2] = v; + d += 3; + } + s += src_wrap; + d += dst_wrap; + } +} + typedef struct ConvertEntry { void (*convert)(AVPicture *dst, AVPicture *src, int width, int height); } ConvertEntry; @@ -1158,6 +1185,9 @@ static ConvertEntry convert_table[PIX_FMT_NB][PIX_FMT_NB] = { [PIX_FMT_GRAY8] = { .convert = rgba32_to_gray }, + [PIX_FMT_RGB24] = { + .convert = rgba32_to_rgb24 + }, }, [PIX_FMT_BGR24] = { [PIX_FMT_YUV420P] = { |