mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
Y400A (gray alpha) input support in libswscale
Originally committed as revision 32394 to svn://svn.mplayerhq.hu/mplayer/trunk/libswscale
This commit is contained in:
parent
59cb40b921
commit
df0743e01e
@ -82,6 +82,7 @@ untested special converters
|
|||||||
(x)==PIX_FMT_PAL8 \
|
(x)==PIX_FMT_PAL8 \
|
||||||
|| (x)==PIX_FMT_YUYV422 \
|
|| (x)==PIX_FMT_YUYV422 \
|
||||||
|| (x)==PIX_FMT_UYVY422 \
|
|| (x)==PIX_FMT_UYVY422 \
|
||||||
|
|| (x)==PIX_FMT_Y400A \
|
||||||
|| isAnyRGB(x) \
|
|| isAnyRGB(x) \
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -1435,6 +1436,34 @@ static int uyvyToYuv422Wrapper(SwsContext *c, const uint8_t* src[], int srcStrid
|
|||||||
return srcSliceH;
|
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,
|
static int palToRgbWrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
|
||||||
int srcSliceH, uint8_t* dst[], int dstStride[])
|
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;
|
uint8_t *dstPtr= dst[0] + dstStride[0]*srcSliceY;
|
||||||
const uint8_t *srcPtr= src[0];
|
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) {
|
switch (dstFormat) {
|
||||||
case PIX_FMT_RGB32 : conv = sws_convertPalette8ToPacked32; break;
|
case PIX_FMT_RGB32 : conv = sws_convertPalette8ToPacked32; break;
|
||||||
case PIX_FMT_BGR32 : 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;
|
r= (i>>3 )*255;
|
||||||
g= ((i>>1)&3)*85;
|
g= ((i>>1)&3)*85;
|
||||||
b= (i&1 )*255;
|
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;
|
r = g = b = i;
|
||||||
} else {
|
} else {
|
||||||
assert(c->srcFormat == PIX_FMT_BGR4_BYTE);
|
assert(c->srcFormat == PIX_FMT_BGR4_BYTE);
|
||||||
|
@ -378,6 +378,7 @@ const char *sws_format_name(enum PixelFormat format);
|
|||||||
)
|
)
|
||||||
#define isGray(x) ( \
|
#define isGray(x) ( \
|
||||||
(x)==PIX_FMT_GRAY8 \
|
(x)==PIX_FMT_GRAY8 \
|
||||||
|
|| (x)==PIX_FMT_Y400A \
|
||||||
|| (x)==PIX_FMT_GRAY16BE \
|
|| (x)==PIX_FMT_GRAY16BE \
|
||||||
|| (x)==PIX_FMT_GRAY16LE \
|
|| (x)==PIX_FMT_GRAY16LE \
|
||||||
)
|
)
|
||||||
@ -440,9 +441,10 @@ const char *sws_format_name(enum PixelFormat format);
|
|||||||
|| (x)==PIX_FMT_BGR32_1 \
|
|| (x)==PIX_FMT_BGR32_1 \
|
||||||
|| (x)==PIX_FMT_RGB32 \
|
|| (x)==PIX_FMT_RGB32 \
|
||||||
|| (x)==PIX_FMT_RGB32_1 \
|
|| (x)==PIX_FMT_RGB32_1 \
|
||||||
|
|| (x)==PIX_FMT_Y400A \
|
||||||
|| (x)==PIX_FMT_YUVA420P \
|
|| (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_dither4[2];
|
||||||
extern const uint64_t ff_dither8[2];
|
extern const uint64_t ff_dither8[2];
|
||||||
|
@ -3001,6 +3001,7 @@ static void RENAME(sws_init_swScale)(SwsContext *c)
|
|||||||
case PIX_FMT_YUV420P16BE:
|
case PIX_FMT_YUV420P16BE:
|
||||||
case PIX_FMT_YUV422P16BE:
|
case PIX_FMT_YUV422P16BE:
|
||||||
case PIX_FMT_YUV444P16BE:
|
case PIX_FMT_YUV444P16BE:
|
||||||
|
case PIX_FMT_Y400A :
|
||||||
case PIX_FMT_GRAY16BE : c->lumToYV12 = RENAME(yuy2ToY); break;
|
case PIX_FMT_GRAY16BE : c->lumToYV12 = RENAME(yuy2ToY); break;
|
||||||
case PIX_FMT_UYVY422 :
|
case PIX_FMT_UYVY422 :
|
||||||
case PIX_FMT_YUV420P16LE:
|
case PIX_FMT_YUV420P16LE:
|
||||||
@ -3033,10 +3034,14 @@ static void RENAME(sws_init_swScale)(SwsContext *c)
|
|||||||
case PIX_FMT_RGB32_1:
|
case PIX_FMT_RGB32_1:
|
||||||
case PIX_FMT_BGR32 :
|
case PIX_FMT_BGR32 :
|
||||||
case PIX_FMT_BGR32_1: c->alpToYV12 = abgrToA; break;
|
case PIX_FMT_BGR32_1: c->alpToYV12 = abgrToA; break;
|
||||||
|
case PIX_FMT_Y400A : c->alpToYV12 = RENAME(yuy2ToY); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (srcFormat) {
|
switch (srcFormat) {
|
||||||
|
case PIX_FMT_Y400A :
|
||||||
|
c->alpSrcOffset = 1;
|
||||||
|
break;
|
||||||
case PIX_FMT_RGB32 :
|
case PIX_FMT_RGB32 :
|
||||||
case PIX_FMT_BGR32 :
|
case PIX_FMT_BGR32 :
|
||||||
c->alpSrcOffset = 3;
|
c->alpSrcOffset = 3;
|
||||||
|
@ -81,6 +81,7 @@ const char *swscale_license(void)
|
|||||||
|| (x)==PIX_FMT_RGB565 \
|
|| (x)==PIX_FMT_RGB565 \
|
||||||
|| (x)==PIX_FMT_RGB555 \
|
|| (x)==PIX_FMT_RGB555 \
|
||||||
|| (x)==PIX_FMT_GRAY8 \
|
|| (x)==PIX_FMT_GRAY8 \
|
||||||
|
|| (x)==PIX_FMT_Y400A \
|
||||||
|| (x)==PIX_FMT_YUV410P \
|
|| (x)==PIX_FMT_YUV410P \
|
||||||
|| (x)==PIX_FMT_YUV440P \
|
|| (x)==PIX_FMT_YUV440P \
|
||||||
|| (x)==PIX_FMT_NV12 \
|
|| (x)==PIX_FMT_NV12 \
|
||||||
|
Loading…
Reference in New Issue
Block a user