swsscale/swscale_unscaled: add GBRAP16

Signed-off-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Paul B Mahol 2013-10-14 17:42:41 +00:00 committed by Michael Niedermayer
parent 9ec9d46365
commit 37d6b2b4e6
1 changed files with 40 additions and 6 deletions

View File

@ -394,6 +394,7 @@ static void gbr16ptopacked16(const uint16_t *src[], int srcStride[],
int alpha, int swap, int bpp, int width) int alpha, int swap, int bpp, int width)
{ {
int x, h, i; int x, h, i;
int src_alpha = src[3] != NULL;
int scale_high = 16 - bpp, scale_low = (bpp - 8) * 2; int scale_high = 16 - bpp, scale_low = (bpp - 8) * 2;
for (h = 0; h < srcSliceH; h++) { for (h = 0; h < srcSliceH; h++) {
uint16_t *dest = (uint16_t *)(dst + dstStride * h); uint16_t *dest = (uint16_t *)(dst + dstStride * h);
@ -401,7 +402,7 @@ static void gbr16ptopacked16(const uint16_t *src[], int srcStride[],
switch(swap) { switch(swap) {
case 3: case 3:
if (alpha) { if (alpha && !src_alpha) {
for (x = 0; x < width; x++) { for (x = 0; x < width; x++) {
component = av_bswap16(src[0][x]); component = av_bswap16(src[0][x]);
*dest++ = av_bswap16(component << scale_high | component >> scale_low); *dest++ = av_bswap16(component << scale_high | component >> scale_low);
@ -411,6 +412,17 @@ static void gbr16ptopacked16(const uint16_t *src[], int srcStride[],
*dest++ = av_bswap16(component << scale_high | component >> scale_low); *dest++ = av_bswap16(component << scale_high | component >> scale_low);
*dest++ = 0xffff; *dest++ = 0xffff;
} }
} else if (alpha && src_alpha) {
for (x = 0; x < width; x++) {
component = av_bswap16(src[0][x]);
*dest++ = av_bswap16(component << scale_high | component >> scale_low);
component = av_bswap16(src[1][x]);
*dest++ = av_bswap16(component << scale_high | component >> scale_low);
component = av_bswap16(src[2][x]);
*dest++ = av_bswap16(component << scale_high | component >> scale_low);
component = av_bswap16(src[3][x]);
*dest++ = av_bswap16(component << scale_high | component >> scale_low);
}
} else { } else {
for (x = 0; x < width; x++) { for (x = 0; x < width; x++) {
component = av_bswap16(src[0][x]); component = av_bswap16(src[0][x]);
@ -423,13 +435,20 @@ static void gbr16ptopacked16(const uint16_t *src[], int srcStride[],
} }
break; break;
case 2: case 2:
if (alpha) { if (alpha && !src_alpha) {
for (x = 0; x < width; x++) { for (x = 0; x < width; x++) {
*dest++ = av_bswap16(src[0][x] << scale_high | src[0][x] >> scale_low); *dest++ = av_bswap16(src[0][x] << scale_high | src[0][x] >> scale_low);
*dest++ = av_bswap16(src[1][x] << scale_high | src[1][x] >> scale_low); *dest++ = av_bswap16(src[1][x] << scale_high | src[1][x] >> scale_low);
*dest++ = av_bswap16(src[2][x] << scale_high | src[2][x] >> scale_low); *dest++ = av_bswap16(src[2][x] << scale_high | src[2][x] >> scale_low);
*dest++ = 0xffff; *dest++ = 0xffff;
} }
} else if (alpha && src_alpha) {
for (x = 0; x < width; x++) {
*dest++ = av_bswap16(src[0][x] << scale_high | src[0][x] >> scale_low);
*dest++ = av_bswap16(src[1][x] << scale_high | src[1][x] >> scale_low);
*dest++ = av_bswap16(src[2][x] << scale_high | src[2][x] >> scale_low);
*dest++ = av_bswap16(src[3][x] << scale_high | src[3][x] >> scale_low);
}
} else { } else {
for (x = 0; x < width; x++) { for (x = 0; x < width; x++) {
*dest++ = av_bswap16(src[0][x] << scale_high | src[0][x] >> scale_low); *dest++ = av_bswap16(src[0][x] << scale_high | src[0][x] >> scale_low);
@ -439,13 +458,20 @@ static void gbr16ptopacked16(const uint16_t *src[], int srcStride[],
} }
break; break;
case 1: case 1:
if (alpha) { if (alpha && !src_alpha) {
for (x = 0; x < width; x++) { for (x = 0; x < width; x++) {
*dest++ = av_bswap16(src[0][x]) << scale_high | av_bswap16(src[0][x]) >> scale_low; *dest++ = av_bswap16(src[0][x]) << scale_high | av_bswap16(src[0][x]) >> scale_low;
*dest++ = av_bswap16(src[1][x]) << scale_high | av_bswap16(src[1][x]) >> scale_low; *dest++ = av_bswap16(src[1][x]) << scale_high | av_bswap16(src[1][x]) >> scale_low;
*dest++ = av_bswap16(src[2][x]) << scale_high | av_bswap16(src[2][x]) >> scale_low; *dest++ = av_bswap16(src[2][x]) << scale_high | av_bswap16(src[2][x]) >> scale_low;
*dest++ = 0xffff; *dest++ = 0xffff;
} }
} else if (alpha && src_alpha) {
for (x = 0; x < width; x++) {
*dest++ = av_bswap16(src[0][x]) << scale_high | av_bswap16(src[0][x]) >> scale_low;
*dest++ = av_bswap16(src[1][x]) << scale_high | av_bswap16(src[1][x]) >> scale_low;
*dest++ = av_bswap16(src[2][x]) << scale_high | av_bswap16(src[2][x]) >> scale_low;
*dest++ = av_bswap16(src[3][x]) << scale_high | av_bswap16(src[3][x]) >> scale_low;
}
} else { } else {
for (x = 0; x < width; x++) { for (x = 0; x < width; x++) {
*dest++ = av_bswap16(src[0][x]) << scale_high | av_bswap16(src[0][x]) >> scale_low; *dest++ = av_bswap16(src[0][x]) << scale_high | av_bswap16(src[0][x]) >> scale_low;
@ -455,13 +481,20 @@ static void gbr16ptopacked16(const uint16_t *src[], int srcStride[],
} }
break; break;
default: default:
if (alpha) { if (alpha && !src_alpha) {
for (x = 0; x < width; x++) { for (x = 0; x < width; x++) {
*dest++ = src[0][x] << scale_high | src[0][x] >> scale_low; *dest++ = src[0][x] << scale_high | src[0][x] >> scale_low;
*dest++ = src[1][x] << scale_high | src[1][x] >> scale_low; *dest++ = src[1][x] << scale_high | src[1][x] >> scale_low;
*dest++ = src[2][x] << scale_high | src[2][x] >> scale_low; *dest++ = src[2][x] << scale_high | src[2][x] >> scale_low;
*dest++ = 0xffff; *dest++ = 0xffff;
} }
} else if (alpha && src_alpha) {
for (x = 0; x < width; x++) {
*dest++ = src[0][x] << scale_high | src[0][x] >> scale_low;
*dest++ = src[1][x] << scale_high | src[1][x] >> scale_low;
*dest++ = src[2][x] << scale_high | src[2][x] >> scale_low;
*dest++ = src[3][x] << scale_high | src[3][x] >> scale_low;
}
} else { } else {
for (x = 0; x < width; x++) { for (x = 0; x < width; x++) {
*dest++ = src[0][x] << scale_high | src[0][x] >> scale_low; *dest++ = src[0][x] << scale_high | src[0][x] >> scale_low;
@ -470,7 +503,7 @@ static void gbr16ptopacked16(const uint16_t *src[], int srcStride[],
} }
} }
} }
for (i = 0; i < 3; i++) for (i = 0; i < 3 + src_alpha; i++)
src[i] += srcStride[i] >> 1; src[i] += srcStride[i] >> 1;
} }
} }
@ -1225,7 +1258,8 @@ void ff_get_unscaled_swscale(SwsContext *c)
srcFormat == AV_PIX_FMT_GBRP16LE || srcFormat == AV_PIX_FMT_GBRP16BE || srcFormat == AV_PIX_FMT_GBRP16LE || srcFormat == AV_PIX_FMT_GBRP16BE ||
srcFormat == AV_PIX_FMT_GBRP10LE || srcFormat == AV_PIX_FMT_GBRP10BE || srcFormat == AV_PIX_FMT_GBRP10LE || srcFormat == AV_PIX_FMT_GBRP10BE ||
srcFormat == AV_PIX_FMT_GBRP12LE || srcFormat == AV_PIX_FMT_GBRP12BE || srcFormat == AV_PIX_FMT_GBRP12LE || srcFormat == AV_PIX_FMT_GBRP12BE ||
srcFormat == AV_PIX_FMT_GBRP14LE || srcFormat == AV_PIX_FMT_GBRP14BE) && srcFormat == AV_PIX_FMT_GBRP14LE || srcFormat == AV_PIX_FMT_GBRP14BE ||
srcFormat == AV_PIX_FMT_GBRAP16LE || srcFormat == AV_PIX_FMT_GBRAP16BE) &&
(dstFormat == AV_PIX_FMT_RGB48LE || dstFormat == AV_PIX_FMT_RGB48BE || (dstFormat == AV_PIX_FMT_RGB48LE || dstFormat == AV_PIX_FMT_RGB48BE ||
dstFormat == AV_PIX_FMT_BGR48LE || dstFormat == AV_PIX_FMT_BGR48BE || dstFormat == AV_PIX_FMT_BGR48LE || dstFormat == AV_PIX_FMT_BGR48BE ||
dstFormat == AV_PIX_FMT_RGBA64LE || dstFormat == AV_PIX_FMT_RGBA64BE || dstFormat == AV_PIX_FMT_RGBA64LE || dstFormat == AV_PIX_FMT_RGBA64BE ||