[FFmpeg-cvslog] Correctly support pal8 with alpha in libswscale, fix png pal8 with alpha.
Baptiste Coudurier
git at videolan.org
Wed Apr 27 21:53:28 CEST 2011
ffmpeg | branch: master | Baptiste Coudurier <baptiste.coudurier at gmail.com> | Wed Apr 27 21:52:09 2011 +0200| [624a7e005cc65b1e86531aa1ecfa7bea14e8bc7d] | committer: Michael Niedermayer
Correctly support pal8 with alpha in libswscale, fix png pal8 with alpha.
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=624a7e005cc65b1e86531aa1ecfa7bea14e8bc7d
---
libswscale/swscale.c | 11 +++++++++++
libswscale/swscale_internal.h | 1 +
libswscale/swscale_template.c | 1 +
3 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index 54515c8..b72ed79 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 6eac7e9..de7859e 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 c269281..864bafc 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;
}
}
More information about the ffmpeg-cvslog
mailing list