Mercurial > mplayer.hg
changeset 32308:ecb8e52d4add
Y400A (gray alpha) input support in libswscale
author | bcoudurier |
---|---|
date | Mon, 27 Sep 2010 22:24:03 +0000 |
parents | 7ba2369d71f7 |
children | f0247fec1cd7 |
files | libswscale/swscale.c libswscale/swscale_internal.h libswscale/swscale_template.c libswscale/utils.c |
diffstat | 4 files changed, 49 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/libswscale/swscale.c Mon Sep 27 20:10:53 2010 +0000 +++ b/libswscale/swscale.c Mon Sep 27 22:24:03 2010 +0000 @@ -82,6 +82,7 @@ (x)==PIX_FMT_PAL8 \ || (x)==PIX_FMT_YUYV422 \ || (x)==PIX_FMT_UYVY422 \ + || (x)==PIX_FMT_Y400A \ || isAnyRGB(x) \ ) @@ -1435,6 +1436,34 @@ 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 @@ 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 @@ 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);
--- a/libswscale/swscale_internal.h Mon Sep 27 20:10:53 2010 +0000 +++ b/libswscale/swscale_internal.h Mon Sep 27 22:24:03 2010 +0000 @@ -378,6 +378,7 @@ ) #define isGray(x) ( \ (x)==PIX_FMT_GRAY8 \ + || (x)==PIX_FMT_Y400A \ || (x)==PIX_FMT_GRAY16BE \ || (x)==PIX_FMT_GRAY16LE \ ) @@ -440,9 +441,10 @@ || (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];
--- a/libswscale/swscale_template.c Mon Sep 27 20:10:53 2010 +0000 +++ b/libswscale/swscale_template.c Mon Sep 27 22:24:03 2010 +0000 @@ -3001,6 +3001,7 @@ 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 @@ 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;
--- a/libswscale/utils.c Mon Sep 27 20:10:53 2010 +0000 +++ b/libswscale/utils.c Mon Sep 27 22:24:03 2010 +0000 @@ -81,6 +81,7 @@ || (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 \