Correctly support pal8 with alpha in libswscale, fix png pal8 with alpha.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Baptiste Coudurier 2011-04-27 21:52:09 +02:00 committed by Michael Niedermayer
parent dbfdb288c1
commit 624a7e005c
3 changed files with 13 additions and 0 deletions

View File

@ -1158,6 +1158,16 @@ BGR2UV(uint16_t, bgr15ToUV, 0, 0, 0, 0, 0x001F, 0x03E0, 0x7C00, RU<<10, GU<<
BGR2UV(uint16_t, rgb16ToUV, 0, 0, 0, 0, 0xF800, 0x07E0, 0x001F, RU , GU<<5, BU<<11, RV , GV<<5, BV<<11, RGB2YUV_SHIFT+8)
BGR2UV(uint16_t, rgb15ToUV, 0, 0, 0, 0, 0x7C00, 0x03E0, 0x001F, RU , GU<<5, BU<<10, RV , GV<<5, BV<<10, RGB2YUV_SHIFT+7)
static inline void palToA(uint8_t *dst, const uint8_t *src, long width, uint32_t *pal)
{
int i;
for (i=0; i<width; i++) {
int d= src[i];
dst[i]= pal[d] >> 24;
}
}
static inline void palToY(uint8_t *dst, const uint8_t *src, long width, uint32_t *pal)
{
int i;
@ -2002,6 +2012,7 @@ int sws_scale(SwsContext *c, const uint8_t* const src[], const int srcStride[],
int p, r, g, b, y, u, v, a = 0xff;
if(c->srcFormat == PIX_FMT_PAL8) {
p=((const uint32_t*)(src[1]))[i];
a= (p>>24)&0xFF;
r= (p>>16)&0xFF;
g= (p>> 8)&0xFF;
b= p &0xFF;

View File

@ -459,6 +459,7 @@ const char *sws_format_name(enum PixelFormat format);
|| (x)==PIX_FMT_BGR32_1 \
|| (x)==PIX_FMT_RGB32 \
|| (x)==PIX_FMT_RGB32_1 \
|| (x)==PIX_FMT_PAL8 \
|| (x)==PIX_FMT_GRAY8A \
|| (x)==PIX_FMT_YUVA420P \
)

View File

@ -3068,6 +3068,7 @@ static void RENAME(sws_init_swScale)(SwsContext *c)
case PIX_FMT_BGR32 :
case PIX_FMT_BGR32_1: c->alpToYV12 = abgrToA; break;
case PIX_FMT_GRAY8A : c->alpToYV12 = RENAME(yuy2ToY); break;
case PIX_FMT_PAL8 : c->alpToYV12 = palToA; break;
}
}