1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

swscale: 9,10 bits pixel format output support

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Baptiste Coudurier 2011-05-08 14:20:57 +02:00 committed by Michael Niedermayer
parent 299cbe2c9b
commit b9e608492a
9 changed files with 135 additions and 29 deletions

View File

@ -401,23 +401,76 @@ static av_always_inline void yuv2yuvX16inC_template(const int16_t *lumFilter, co
}
}
static av_always_inline void yuv2yuvXNinC_template(const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize,
const int16_t *chrFilter, const int16_t **chrSrc, int chrFilterSize,
const int16_t **alpSrc, uint16_t *dest, uint16_t *uDest, uint16_t *vDest, uint16_t *aDest,
int dstW, int chrDstW, int big_endian, int depth)
{
//FIXME Optimize (just quickly written not optimized..)
int i;
for (i = 0; i < dstW; i++) {
int val = 1 << (26-depth);
int j;
for (j = 0; j < lumFilterSize; j++)
val += lumSrc[j][i] * lumFilter[j];
if (big_endian) {
AV_WB16(&dest[i], av_clip(val >> (27-depth), 0, (1<<depth)-1));
} else {
AV_WL16(&dest[i], av_clip(val >> (27-depth), 0, (1<<depth)-1));
}
}
if (uDest) {
for (i = 0; i < chrDstW; i++) {
int u = 1 << (26-depth);
int v = 1 << (26-depth);
int j;
for (j = 0; j < chrFilterSize; j++) {
u += chrSrc[j][i ] * chrFilter[j];
v += chrSrc[j][i + VOFW] * chrFilter[j];
}
if (big_endian) {
AV_WB16(&uDest[i], av_clip(u >> (27-depth), 0, (1<<depth)-1));
AV_WB16(&vDest[i], av_clip(v >> (27-depth), 0, (1<<depth)-1));
} else {
AV_WL16(&uDest[i], av_clip(u >> (27-depth), 0, (1<<depth)-1));
AV_WL16(&vDest[i], av_clip(v >> (27-depth), 0, (1<<depth)-1));
}
}
}
}
static inline void yuv2yuvX16inC(const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize,
const int16_t *chrFilter, const int16_t **chrSrc, int chrFilterSize,
const int16_t **alpSrc, uint16_t *dest, uint16_t *uDest, uint16_t *vDest, uint16_t *aDest, int dstW, int chrDstW,
enum PixelFormat dstFormat)
{
if (isBE(dstFormat)) {
yuv2yuvX16inC_template(lumFilter, lumSrc, lumFilterSize,
chrFilter, chrSrc, chrFilterSize,
alpSrc,
dest, uDest, vDest, aDest,
dstW, chrDstW, 1);
if (isNBPS(dstFormat)) {
const int depth = av_pix_fmt_descriptors[dstFormat].comp[0].depth_minus1+1;
yuv2yuvXNinC_template(lumFilter, lumSrc, lumFilterSize,
chrFilter, chrSrc, chrFilterSize,
alpSrc,
dest, uDest, vDest, aDest,
dstW, chrDstW, isBE(dstFormat), depth);
} else {
yuv2yuvX16inC_template(lumFilter, lumSrc, lumFilterSize,
chrFilter, chrSrc, chrFilterSize,
alpSrc,
dest, uDest, vDest, aDest,
dstW, chrDstW, 0);
if (isBE(dstFormat)) {
yuv2yuvX16inC_template(lumFilter, lumSrc, lumFilterSize,
chrFilter, chrSrc, chrFilterSize,
alpSrc,
dest, uDest, vDest, aDest,
dstW, chrDstW, 1);
} else {
yuv2yuvX16inC_template(lumFilter, lumSrc, lumFilterSize,
chrFilter, chrSrc, chrFilterSize,
alpSrc,
dest, uDest, vDest, aDest,
dstW, chrDstW, 0);
}
}
}
@ -1823,34 +1876,62 @@ static int planarCopyWrapper(SwsContext *c, const uint8_t* src[], int srcStride[
length*=2;
fillPlane(dst[plane], dstStride[plane], length, height, y, (plane==3) ? 255 : 128);
} else {
if(isNBPS(c->srcFormat)) {
const int depth = av_pix_fmt_descriptors[c->srcFormat].comp[plane].depth_minus1+1;
if(isNBPS(c->srcFormat) || isNBPS(c->dstFormat)) {
const int src_depth = av_pix_fmt_descriptors[c->srcFormat].comp[plane].depth_minus1+1;
const int dst_depth = av_pix_fmt_descriptors[c->dstFormat].comp[plane].depth_minus1+1;
uint16_t *srcPtr2 = (uint16_t*)srcPtr;
uint16_t *dstPtr2 = (uint16_t*)dstPtr;
if (is16BPS(c->dstFormat)) {
uint16_t *dstPtr2 = (uint16_t*)dstPtr;
if (dst_depth == 8) {
for (i = 0; i < height; i++) {
uint8_t *dither= dithers[src_depth-9][i&7];
for (j = 0; j < length-7; j+=8){
dstPtr[j+0] = (srcPtr2[j+0] + dither[0])>>(src_depth-8);
dstPtr[j+1] = (srcPtr2[j+1] + dither[1])>>(src_depth-8);
dstPtr[j+2] = (srcPtr2[j+2] + dither[2])>>(src_depth-8);
dstPtr[j+3] = (srcPtr2[j+3] + dither[3])>>(src_depth-8);
dstPtr[j+4] = (srcPtr2[j+4] + dither[4])>>(src_depth-8);
dstPtr[j+5] = (srcPtr2[j+5] + dither[5])>>(src_depth-8);
dstPtr[j+6] = (srcPtr2[j+6] + dither[6])>>(src_depth-8);
dstPtr[j+7] = (srcPtr2[j+7] + dither[7])>>(src_depth-8);
}
for (; j < length; j++)
dstPtr[j] = (srcPtr2[j] + dither[j&7])>>(src_depth-8);
dstPtr += dstStride[plane];
srcPtr2 += srcStride[plane]/2;
}
} else if (src_depth == 8) {
for (i = 0; i < height; i++) {
for (j = 0; j < length; j++)
dstPtr2[j] = (srcPtr2[j]<<(16-depth)) | (srcPtr2[j]>>(2*depth-16));
dstPtr2[j] = (srcPtr[j]<<(dst_depth-8)) |
(srcPtr[j]>>(2*8-dst_depth));
dstPtr2 += dstStride[plane]/2;
srcPtr += srcStride[plane];
}
} else if (src_depth < dst_depth) {
for (i = 0; i < height; i++) {
for (j = 0; j < length; j++)
dstPtr2[j] = (srcPtr2[j]<<(dst_depth-src_depth)) |
(srcPtr2[j]>>(2*src_depth-dst_depth));
dstPtr2 += dstStride[plane]/2;
srcPtr2 += srcStride[plane]/2;
}
} else {
for (i = 0; i < height; i++) {
uint8_t *dither= dithers[depth-9][i&7];
uint8_t *dither= dithers[src_depth-9][i&7];
for (j = 0; j < length-7; j+=8){
dstPtr[j+0] = (srcPtr2[j+0] + dither[0])>>(depth-8);
dstPtr[j+1] = (srcPtr2[j+1] + dither[1])>>(depth-8);
dstPtr[j+2] = (srcPtr2[j+2] + dither[2])>>(depth-8);
dstPtr[j+3] = (srcPtr2[j+3] + dither[3])>>(depth-8);
dstPtr[j+4] = (srcPtr2[j+4] + dither[4])>>(depth-8);
dstPtr[j+5] = (srcPtr2[j+5] + dither[5])>>(depth-8);
dstPtr[j+6] = (srcPtr2[j+6] + dither[6])>>(depth-8);
dstPtr[j+7] = (srcPtr2[j+7] + dither[7])>>(depth-8);
dstPtr2[j+0] = (srcPtr2[j+0] + dither[0])>>(src_depth-dst_depth);
dstPtr2[j+1] = (srcPtr2[j+1] + dither[1])>>(src_depth-dst_depth);
dstPtr2[j+2] = (srcPtr2[j+2] + dither[2])>>(src_depth-dst_depth);
dstPtr2[j+3] = (srcPtr2[j+3] + dither[3])>>(src_depth-dst_depth);
dstPtr2[j+4] = (srcPtr2[j+4] + dither[4])>>(src_depth-dst_depth);
dstPtr2[j+5] = (srcPtr2[j+5] + dither[5])>>(src_depth-dst_depth);
dstPtr2[j+6] = (srcPtr2[j+6] + dither[6])>>(src_depth-dst_depth);
dstPtr2[j+7] = (srcPtr2[j+7] + dither[7])>>(src_depth-dst_depth);
}
for (; j < length; j++)
dstPtr[j] = (srcPtr2[j] + dither[j&7])>>(depth-8);
dstPtr += dstStride[plane];
dstPtr2[j] = (srcPtr2[j] + dither[j&7])>>(src_depth-dst_depth);
dstPtr2 += dstStride[plane];
srcPtr2 += srcStride[plane]/2;
}
}

View File

@ -359,6 +359,8 @@ const char *sws_format_name(enum PixelFormat format);
|| (x)==PIX_FMT_YUV420P9BE \
|| (x)==PIX_FMT_YUV420P10LE \
|| (x)==PIX_FMT_YUV420P10BE \
|| (x)==PIX_FMT_YUV422P10LE \
|| (x)==PIX_FMT_YUV422P10BE \
)
#define isBE(x) ((x)&1)
#define isPlanar8YUV(x) ( \
@ -377,11 +379,13 @@ const char *sws_format_name(enum PixelFormat format);
|| (x)==PIX_FMT_YUV420P9LE \
|| (x)==PIX_FMT_YUV420P10LE \
|| (x)==PIX_FMT_YUV420P16LE \
|| (x)==PIX_FMT_YUV422P10LE \
|| (x)==PIX_FMT_YUV422P16LE \
|| (x)==PIX_FMT_YUV444P16LE \
|| (x)==PIX_FMT_YUV420P9BE \
|| (x)==PIX_FMT_YUV420P10BE \
|| (x)==PIX_FMT_YUV420P16BE \
|| (x)==PIX_FMT_YUV422P10BE \
|| (x)==PIX_FMT_YUV422P16BE \
|| (x)==PIX_FMT_YUV444P16BE \
)

View File

@ -2817,7 +2817,7 @@ static int RENAME(swScale)(SwsContext *c, const uint8_t* src[], int srcStride[],
} else if (isPlanarYUV(dstFormat) || dstFormat==PIX_FMT_GRAY8) { //YV12 like
const int chrSkipMask= (1<<c->chrDstVSubSample)-1;
if ((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi
if (is16BPS(dstFormat)) {
if (is16BPS(dstFormat) || isNBPS(dstFormat)) {
yuv2yuvX16inC(
vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize,
vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
@ -2894,7 +2894,7 @@ static int RENAME(swScale)(SwsContext *c, const uint8_t* src[], int srcStride[],
} else if (isPlanarYUV(dstFormat) || dstFormat==PIX_FMT_GRAY8) { //YV12
const int chrSkipMask= (1<<c->chrDstVSubSample)-1;
if ((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi
if (is16BPS(dstFormat)) {
if (is16BPS(dstFormat) || isNBPS(dstFormat)) {
yuv2yuvX16inC(
vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize,
vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
@ -2979,6 +2979,7 @@ static void RENAME(sws_init_swScale)(SwsContext *c)
case PIX_FMT_BGR4_BYTE:
case PIX_FMT_RGB4_BYTE: c->chrToYV12 = palToUV; break;
case PIX_FMT_YUV420P9 : c->chrToYV12 = (void*)RENAME(yuv9ToUV ); break;
case PIX_FMT_YUV422P10:
case PIX_FMT_YUV420P10: c->chrToYV12 = (void*)RENAME(yuv10ToUV); break;
case PIX_FMT_YUV420P16BE:
case PIX_FMT_YUV422P16BE:
@ -3027,6 +3028,7 @@ static void RENAME(sws_init_swScale)(SwsContext *c)
c->alpToYV12 = NULL;
switch (srcFormat) {
case PIX_FMT_YUV420P9 : c->lumToYV12 = (void*)RENAME(yuv9ToY ); break;
case PIX_FMT_YUV422P10:
case PIX_FMT_YUV420P10: c->lumToYV12 = (void*)RENAME(yuv10ToY); break;
case PIX_FMT_YUYV422 :
case PIX_FMT_YUV420P16BE:

View File

@ -115,6 +115,7 @@ const char *swscale_license(void)
|| (x)==PIX_FMT_YUV444P16BE \
|| (x)==PIX_FMT_YUV420P9 \
|| (x)==PIX_FMT_YUV420P10 \
|| (x)==PIX_FMT_YUV422P10 \
)
int sws_isSupportedInput(enum PixelFormat pix_fmt)
@ -142,6 +143,9 @@ int sws_isSupportedInput(enum PixelFormat pix_fmt)
|| (x)==PIX_FMT_GRAY8 \
|| (x)==PIX_FMT_YUV410P \
|| (x)==PIX_FMT_YUV440P \
|| (x)==PIX_FMT_YUV420P9 \
|| (x)==PIX_FMT_YUV420P10 \
|| (x)==PIX_FMT_YUV422P10 \
|| (x)==PIX_FMT_YUV420P16LE \
|| (x)==PIX_FMT_YUV422P16LE \
|| (x)==PIX_FMT_YUV444P16LE \

View File

@ -27,9 +27,12 @@ uyvy422 adcf64516a19fce44df77082bdb16291
yuv410p 2d9225153c83ee1132397d619d94d1b3
yuv411p 8b298af3e43348ca1b11eb8a3252ac6c
yuv420p eba2f135a08829387e2f698ff72a2939
yuv420p10le 4228ee628c6deec123a13b9784516cc7
yuv420p16be 16c009a235cd52b74791a895423152a3
yuv420p16le 2d59c4f1d0314a5a957a7cfc4b6fabcc
yuv420p9le 16543fda8f87d94a6cf857d2e8d4461a
yuv422p c9bba4529821d796a6ab09f6a5fd355a
yuv422p10le d0607c260a45c973e6639f4e449730ad
yuv422p16be 5499502e1c29534a158a1fe60e889f60
yuv422p16le e3d61fde6978591596bc36b914386623
yuv440p 5a064afe2b453bb52cdb3f176b1aa1cf

View File

@ -27,9 +27,12 @@ uyvy422 adcf64516a19fce44df77082bdb16291
yuv410p 2d9225153c83ee1132397d619d94d1b3
yuv411p 8b298af3e43348ca1b11eb8a3252ac6c
yuv420p eba2f135a08829387e2f698ff72a2939
yuv420p10le 4228ee628c6deec123a13b9784516cc7
yuv420p16be 16c009a235cd52b74791a895423152a3
yuv420p16le 2d59c4f1d0314a5a957a7cfc4b6fabcc
yuv420p9le 16543fda8f87d94a6cf857d2e8d4461a
yuv422p c9bba4529821d796a6ab09f6a5fd355a
yuv422p10le d0607c260a45c973e6639f4e449730ad
yuv422p16be 5499502e1c29534a158a1fe60e889f60
yuv422p16le e3d61fde6978591596bc36b914386623
yuv440p 5a064afe2b453bb52cdb3f176b1aa1cf

View File

@ -27,9 +27,12 @@ uyvy422 adcf64516a19fce44df77082bdb16291
yuv410p 2d9225153c83ee1132397d619d94d1b3
yuv411p 8b298af3e43348ca1b11eb8a3252ac6c
yuv420p eba2f135a08829387e2f698ff72a2939
yuv420p10le 4228ee628c6deec123a13b9784516cc7
yuv420p16be 16c009a235cd52b74791a895423152a3
yuv420p16le 2d59c4f1d0314a5a957a7cfc4b6fabcc
yuv420p9le 16543fda8f87d94a6cf857d2e8d4461a
yuv422p c9bba4529821d796a6ab09f6a5fd355a
yuv422p10le d0607c260a45c973e6639f4e449730ad
yuv422p16be 5499502e1c29534a158a1fe60e889f60
yuv422p16le e3d61fde6978591596bc36b914386623
yuv440p 5a064afe2b453bb52cdb3f176b1aa1cf

View File

@ -27,9 +27,12 @@ uyvy422 314bd486277111a95d9369b944fa0400
yuv410p 7df8f6d69b56a8dcb6c7ee908e5018b5
yuv411p 1143e7c5cc28fe0922b051b17733bc4c
yuv420p fdad2d8df8985e3d17e73c71f713cb14
yuv420p10le d510ddbabefd03ef39ec943fcb51b709
yuv420p16be 29a0265764530070f5cd3251cc01f66a
yuv420p16le 6f3a265b084a78baec229238d9f7945f
yuv420p9le c136dce5913a722eee44ab72cff664b2
yuv422p 918e37701ee7377d16a8a6c119c56a40
yuv422p10le aeb0ef08a883f43429ca9d886d8fc095
yuv422p16be ef3e865fc1d0c68977c735323c50af6e
yuv422p16le 428a9b96214c09cb5a983ce36d6961ff
yuv440p 461503fdb9b90451020aa3b25ddf041c

View File

@ -27,9 +27,12 @@ uyvy422 ffbd36720c77398d9a0d03ce2625928f
yuv410p 7bfb39d7afb49d6a6173e6b23ae321eb
yuv411p 4a90048cc3a65fac150e53289700efe1
yuv420p 2e6d6062e8cad37fb3ab2c433b55f382
yuv420p10le 4b5249208602b941332945c926f80ae9
yuv420p16be 539076782902664a8acf381bf4f713e8
yuv420p16le 0f609e588e5a258644ef85170d70e030
yuv420p9le 7e606310d3f5ff12badf911e8f333471
yuv422p d7f5cb44d9b0210d66d6a8762640ab34
yuv422p10le 11b57f2bd9661024153f3973b9090cdb
yuv422p16be 9bd8f8c961822b586fa4cf992be54acc
yuv422p16le 9c4a1239605c7952b736ac3130163f14
yuv440p 876385e96165acf51271b20e5d85a416