From 522ce9578699c78782e6e6d8fc25808c48577b39 Mon Sep 17 00:00:00 2001 From: Vitor Sessak Date: Thu, 23 Oct 2008 19:13:11 +0000 Subject: [PATCH] Fix broken palette8to*. Originally committed as revision 27817 to svn://svn.mplayerhq.hu/mplayer/trunk/libswscale --- libswscale/rgb2rgb.c | 71 ++++---------------------------------------- libswscale/rgb2rgb.h | 6 ++-- libswscale/swscale.c | 41 +++++++++++++++++++++---- 3 files changed, 43 insertions(+), 75 deletions(-) diff --git a/libswscale/rgb2rgb.c b/libswscale/rgb2rgb.c index 13388ac85a..b55141264a 100644 --- a/libswscale/rgb2rgb.c +++ b/libswscale/rgb2rgb.c @@ -213,84 +213,23 @@ void sws_rgb2rgb_init(int flags){ } /** - * Palette is assumed to contain BGR32. + * Convert the palette to the same packet 32-bit format as the palette */ -void palette8torgb32(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette) +void palette8topacked32(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette) { long i; -/* for (i=0; i dst format: ABC */ -void palette8torgb24(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) { long i; -/* - Writes 1 byte too much and might cause alignment issues on some architectures? - for (i=0; i %s converter\n", sws_format_name(srcFormat), sws_format_name(dstFormat)); break; } @@ -2343,8 +2345,10 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, int d if ((usePal(srcFormat) && ( dstFormat == PIX_FMT_RGB32 || + dstFormat == PIX_FMT_RGB32_1 || dstFormat == PIX_FMT_RGB24 || dstFormat == PIX_FMT_BGR32 || + dstFormat == PIX_FMT_BGR32_1 || dstFormat == PIX_FMT_BGR24))) c->swScale= pal2rgbWrapper; @@ -2739,7 +2743,34 @@ int sws_scale(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, u= av_clip_uint8((RU*r + GU*g + BU*b + (257<<(RGB2YUV_SHIFT-1)))>>RGB2YUV_SHIFT); v= av_clip_uint8((RV*r + GV*g + BV*b + (257<<(RGB2YUV_SHIFT-1)))>>RGB2YUV_SHIFT); c->pal_yuv[i]= y + (u<<8) + (v<<16); - c->pal_rgb[i]= b + (g<<8) + (r<<16); + + + switch(c->dstFormat) { + case PIX_FMT_BGR32: +#ifndef WORDS_BIGENDIAN + case PIX_FMT_RGB24: +#endif + c->pal_rgb[i]= r + (g<<8) + (b<<16); + break; + case PIX_FMT_BGR32_1: +#ifdef WORDS_BIGENDIAN + case PIX_FMT_BGR24: +#endif + c->pal_rgb[i]= (r + (g<<8) + (b<<16)) << 8; + break; + case PIX_FMT_RGB32_1: +#ifdef WORDS_BIGENDIAN + case PIX_FMT_RGB24: +#endif + c->pal_rgb[i]= (b + (g<<8) + (r<<16)) << 8; + break; + case PIX_FMT_RGB32: +#ifndef WORDS_BIGENDIAN + case PIX_FMT_BGR24: +#endif + default: + c->pal_rgb[i]= b + (g<<8) + (r<<16); + } } }