[FFmpeg-cvslog] r32394 - in trunk/libswscale: swscale.c swscale_internal.h swscale_template.c utils.c
bcoudurier
subversion
Tue Sep 28 00:24:03 CEST 2010
Author: bcoudurier
Date: Tue Sep 28 00:24:03 2010
New Revision: 32394
Log:
Y400A (gray alpha) input support in libswscale
Modified:
trunk/libswscale/swscale.c
trunk/libswscale/swscale_internal.h
trunk/libswscale/swscale_template.c
trunk/libswscale/utils.c
Modified: trunk/libswscale/swscale.c
==============================================================================
--- trunk/libswscale/swscale.c Mon Sep 27 22:10:53 2010 (r32393)
+++ trunk/libswscale/swscale.c Tue Sep 28 00:24:03 2010 (r32394)
@@ -82,6 +82,7 @@ untested special converters
(x)==PIX_FMT_PAL8 \
|| (x)==PIX_FMT_YUYV422 \
|| (x)==PIX_FMT_UYVY422 \
+ || (x)==PIX_FMT_Y400A \
|| isAnyRGB(x) \
)
@@ -1435,6 +1436,34 @@ static int uyvyToYuv422Wrapper(SwsContex
return srcSliceH;
}
+static void gray8aToPacked32(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette)
+{
+ long i;
+ for (i=0; i<num_pixels; i++)
+ ((uint32_t *) dst)[i] = ((const uint32_t *)palette)[src[i<<1]] | (src[(i<<1)+1] << 24);
+}
+
+static void gray8aToPacked32_1(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette)
+{
+ long i;
+
+ for (i=0; i<num_pixels; i++)
+ ((uint32_t *) dst)[i] = ((const uint32_t *)palette)[src[i<<1]] | src[(i<<1)+1];
+}
+
+static void gray8aToPacked24(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette)
+{
+ long i;
+
+ for (i=0; i<num_pixels; i++) {
+ //FIXME slow?
+ dst[0]= palette[src[i<<1]*4+0];
+ dst[1]= palette[src[i<<1]*4+1];
+ dst[2]= palette[src[i<<1]*4+2];
+ dst+= 3;
+ }
+}
+
static int palToRgbWrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[])
{
@@ -1446,7 +1475,16 @@ static int palToRgbWrapper(SwsContext *c
uint8_t *dstPtr= dst[0] + dstStride[0]*srcSliceY;
const uint8_t *srcPtr= src[0];
- if (usePal(srcFormat)) {
+ if (srcFormat == PIX_FMT_Y400A) {
+ switch (dstFormat) {
+ case PIX_FMT_RGB32 : conv = gray8aToPacked32; break;
+ case PIX_FMT_BGR32 : conv = gray8aToPacked32; break;
+ case PIX_FMT_BGR32_1: conv = gray8aToPacked32_1; break;
+ case PIX_FMT_RGB32_1: conv = gray8aToPacked32_1; break;
+ case PIX_FMT_RGB24 : conv = gray8aToPacked24; break;
+ case PIX_FMT_BGR24 : conv = gray8aToPacked24; break;
+ }
+ } else if (usePal(srcFormat)) {
switch (dstFormat) {
case PIX_FMT_RGB32 : conv = sws_convertPalette8ToPacked32; break;
case PIX_FMT_BGR32 : conv = sws_convertPalette8ToPacked32; break;
@@ -1903,7 +1941,7 @@ int sws_scale(SwsContext *c, const uint8
r= (i>>3 )*255;
g= ((i>>1)&3)*85;
b= (i&1 )*255;
- } else if(c->srcFormat == PIX_FMT_GRAY8) {
+ } else if(c->srcFormat == PIX_FMT_GRAY8 || PIX_FMT_Y400A) {
r = g = b = i;
} else {
assert(c->srcFormat == PIX_FMT_BGR4_BYTE);
Modified: trunk/libswscale/swscale_internal.h
==============================================================================
--- trunk/libswscale/swscale_internal.h Mon Sep 27 22:10:53 2010 (r32393)
+++ trunk/libswscale/swscale_internal.h Tue Sep 28 00:24:03 2010 (r32394)
@@ -378,6 +378,7 @@ const char *sws_format_name(enum PixelFo
)
#define isGray(x) ( \
(x)==PIX_FMT_GRAY8 \
+ || (x)==PIX_FMT_Y400A \
|| (x)==PIX_FMT_GRAY16BE \
|| (x)==PIX_FMT_GRAY16LE \
)
@@ -440,9 +441,10 @@ const char *sws_format_name(enum PixelFo
|| (x)==PIX_FMT_BGR32_1 \
|| (x)==PIX_FMT_RGB32 \
|| (x)==PIX_FMT_RGB32_1 \
+ || (x)==PIX_FMT_Y400A \
|| (x)==PIX_FMT_YUVA420P \
)
-#define usePal(x) (av_pix_fmt_descriptors[x].flags & PIX_FMT_PAL)
+#define usePal(x) ((av_pix_fmt_descriptors[x].flags & PIX_FMT_PAL) || (x) == PIX_FMT_Y400A)
extern const uint64_t ff_dither4[2];
extern const uint64_t ff_dither8[2];
Modified: trunk/libswscale/swscale_template.c
==============================================================================
--- trunk/libswscale/swscale_template.c Mon Sep 27 22:10:53 2010 (r32393)
+++ trunk/libswscale/swscale_template.c Tue Sep 28 00:24:03 2010 (r32394)
@@ -3001,6 +3001,7 @@ static void RENAME(sws_init_swScale)(Sws
case PIX_FMT_YUV420P16BE:
case PIX_FMT_YUV422P16BE:
case PIX_FMT_YUV444P16BE:
+ case PIX_FMT_Y400A :
case PIX_FMT_GRAY16BE : c->lumToYV12 = RENAME(yuy2ToY); break;
case PIX_FMT_UYVY422 :
case PIX_FMT_YUV420P16LE:
@@ -3033,10 +3034,14 @@ static void RENAME(sws_init_swScale)(Sws
case PIX_FMT_RGB32_1:
case PIX_FMT_BGR32 :
case PIX_FMT_BGR32_1: c->alpToYV12 = abgrToA; break;
+ case PIX_FMT_Y400A : c->alpToYV12 = RENAME(yuy2ToY); break;
}
}
switch (srcFormat) {
+ case PIX_FMT_Y400A :
+ c->alpSrcOffset = 1;
+ break;
case PIX_FMT_RGB32 :
case PIX_FMT_BGR32 :
c->alpSrcOffset = 3;
Modified: trunk/libswscale/utils.c
==============================================================================
--- trunk/libswscale/utils.c Mon Sep 27 22:10:53 2010 (r32393)
+++ trunk/libswscale/utils.c Tue Sep 28 00:24:03 2010 (r32394)
@@ -81,6 +81,7 @@ const char *swscale_license(void)
|| (x)==PIX_FMT_RGB565 \
|| (x)==PIX_FMT_RGB555 \
|| (x)==PIX_FMT_GRAY8 \
+ || (x)==PIX_FMT_Y400A \
|| (x)==PIX_FMT_YUV410P \
|| (x)==PIX_FMT_YUV440P \
|| (x)==PIX_FMT_NV12 \
More information about the ffmpeg-cvslog
mailing list