[FFmpeg-cvslog] swsscale/swscale_unscaled: add GBRAP16
Paul B Mahol
git at videolan.org
Wed Oct 16 20:50:11 CEST 2013
ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Mon Oct 14 17:42:41 2013 +0000| [37d6b2b4e6f858a984b6af19410dc60294c98e99] | committer: Michael Niedermayer
swsscale/swscale_unscaled: add GBRAP16
Signed-off-by: Paul B Mahol <onemda at gmail.com>
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=37d6b2b4e6f858a984b6af19410dc60294c98e99
---
libswscale/swscale_unscaled.c | 46 +++++++++++++++++++++++++++++++++++------
1 file changed, 40 insertions(+), 6 deletions(-)
diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c
index 820073c..83086f7 100644
--- a/libswscale/swscale_unscaled.c
+++ b/libswscale/swscale_unscaled.c
@@ -394,6 +394,7 @@ static void gbr16ptopacked16(const uint16_t *src[], int srcStride[],
int alpha, int swap, int bpp, int width)
{
int x, h, i;
+ int src_alpha = src[3] != NULL;
int scale_high = 16 - bpp, scale_low = (bpp - 8) * 2;
for (h = 0; h < srcSliceH; h++) {
uint16_t *dest = (uint16_t *)(dst + dstStride * h);
@@ -401,7 +402,7 @@ static void gbr16ptopacked16(const uint16_t *src[], int srcStride[],
switch(swap) {
case 3:
- if (alpha) {
+ 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);
@@ -411,6 +412,17 @@ static void gbr16ptopacked16(const uint16_t *src[], int srcStride[],
*dest++ = av_bswap16(component << scale_high | component >> scale_low);
*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 {
for (x = 0; x < width; x++) {
component = av_bswap16(src[0][x]);
@@ -423,13 +435,20 @@ static void gbr16ptopacked16(const uint16_t *src[], int srcStride[],
}
break;
case 2:
- if (alpha) {
+ 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++ = 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 {
for (x = 0; x < width; x++) {
*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;
case 1:
- if (alpha) {
+ 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++ = 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 {
for (x = 0; x < width; x++) {
*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;
default:
- if (alpha) {
+ 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++ = 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 {
for (x = 0; x < width; x++) {
*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;
}
}
@@ -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_GBRP10LE || srcFormat == AV_PIX_FMT_GBRP10BE ||
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_BGR48LE || dstFormat == AV_PIX_FMT_BGR48BE ||
dstFormat == AV_PIX_FMT_RGBA64LE || dstFormat == AV_PIX_FMT_RGBA64BE ||
More information about the ffmpeg-cvslog
mailing list