diff options
author | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2010-09-27 22:24:03 +0000 |
---|---|---|
committer | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2010-09-27 22:24:03 +0000 |
commit | df0743e01e9fb88b9eb67815bacc2fe89e313eff (patch) | |
tree | 2270a4c4a0bb1b7d3140ed776cf692110f04f6a7 | |
parent | 59cb40b92194c272c4d097c702a46f90edb94958 (diff) | |
download | ffmpeg-df0743e01e9fb88b9eb67815bacc2fe89e313eff.tar.gz |
Y400A (gray alpha) input support in libswscale
Originally committed as revision 32394 to svn://svn.mplayerhq.hu/mplayer/trunk/libswscale
-rw-r--r-- | libswscale/swscale.c | 42 | ||||
-rw-r--r-- | libswscale/swscale_internal.h | 4 | ||||
-rw-r--r-- | libswscale/swscale_template.c | 5 | ||||
-rw-r--r-- | libswscale/utils.c | 1 |
4 files changed, 49 insertions, 3 deletions
diff --git a/libswscale/swscale.c b/libswscale/swscale.c index fbfc006a98..aa400f6094 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -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(SwsContext *c, const uint8_t* src[], int srcStrid 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, const uint8_t* src[], int srcStride[], 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_t* const src[], const int srcStride[], 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); diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index d5df2988f3..19dff8f37b 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -378,6 +378,7 @@ const char *sws_format_name(enum PixelFormat format); ) #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 PixelFormat format); || (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]; diff --git a/libswscale/swscale_template.c b/libswscale/swscale_template.c index 42c4a8ba5f..34868ac5cc 100644 --- a/libswscale/swscale_template.c +++ b/libswscale/swscale_template.c @@ -3001,6 +3001,7 @@ static void RENAME(sws_init_swScale)(SwsContext *c) 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)(SwsContext *c) 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; diff --git a/libswscale/utils.c b/libswscale/utils.c index b52a7937b0..c817a4d997 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -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 \ |