summaryrefslogtreecommitdiff
path: root/libswscale
diff options
context:
space:
mode:
authorBaptiste Coudurier <baptiste.coudurier@gmail.com>2011-04-27 21:52:09 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-04-27 21:52:09 +0200
commit624a7e005cc65b1e86531aa1ecfa7bea14e8bc7d (patch)
treef423d385b04e2292718af4e11f025ec26f18d5b4 /libswscale
parentdbfdb288c1921eeb9fef5bca20eee33da7fcdd71 (diff)
Correctly support pal8 with alpha in libswscale, fix png pal8 with alpha.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libswscale')
-rw-r--r--libswscale/swscale.c11
-rw-r--r--libswscale/swscale_internal.h1
-rw-r--r--libswscale/swscale_template.c1
3 files changed, 13 insertions, 0 deletions
diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index 54515c8206..b72ed79ae9 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -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;
diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index 6eac7e97db..de7859e3c0 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -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 \
)
diff --git a/libswscale/swscale_template.c b/libswscale/swscale_template.c
index c269281a14..864bafc85c 100644
--- a/libswscale/swscale_template.c
+++ b/libswscale/swscale_template.c
@@ -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;
}
}