summaryrefslogtreecommitdiff
path: root/libswscale
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2016-11-30 22:45:08 +0100
committerPaul B Mahol <onemda@gmail.com>2016-12-01 21:37:25 +0100
commit6427c9ffee347306d0b00ef94d8cac70babc530c (patch)
tree15c652ec2e625166b1ee36733026805604490b81 /libswscale
parentfbdf8f176e0fbf48132e45445f538d74c74107a4 (diff)
swscale: add gbr(a)p16 output support
Diffstat (limited to 'libswscale')
-rw-r--r--libswscale/output.c83
-rw-r--r--libswscale/utils.c8
2 files changed, 85 insertions, 6 deletions
diff --git a/libswscale/output.c b/libswscale/output.c
index b0d33b18ec..9774e9f327 100644
--- a/libswscale/output.c
+++ b/libswscale/output.c
@@ -2022,6 +2022,81 @@ yuv2gbrp_full_X_c(SwsContext *c, const int16_t *lumFilter,
}
static void
+yuv2gbrp16_full_X_c(SwsContext *c, const int16_t *lumFilter,
+ const int16_t **lumSrcx, int lumFilterSize,
+ const int16_t *chrFilter, const int16_t **chrUSrcx,
+ const int16_t **chrVSrcx, int chrFilterSize,
+ const int16_t **alpSrc, uint8_t **dest,
+ int dstW, int y)
+{
+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->dstFormat);
+ int i;
+ int hasAlpha = (desc->flags & AV_PIX_FMT_FLAG_ALPHA) && alpSrc;
+ uint16_t **dest16 = (uint16_t**)dest;
+ const int32_t **lumSrc = (const int32_t**)lumSrcx;
+ const int32_t **chrUSrc = (const int32_t**)chrUSrcx;
+ const int32_t **chrVSrc = (const int32_t**)chrVSrcx;
+ int A = 0; // init to silence warning
+
+ for (i = 0; i < dstW; i++) {
+ int j;
+ int Y = -0x40000000;
+ int U = -(128 << 23);
+ int V = -(128 << 23);
+ int R, G, B;
+
+ for (j = 0; j < lumFilterSize; j++)
+ Y += lumSrc[j][i] * (unsigned)lumFilter[j];
+
+ for (j = 0; j < chrFilterSize; j++) {
+ U += chrUSrc[j][i] * (unsigned)chrFilter[j];
+ V += chrVSrc[j][i] * (unsigned)chrFilter[j];
+ }
+
+ Y >>= 14;
+ Y += 0x10000;
+ U >>= 14;
+ V >>= 14;
+
+ if (hasAlpha) {
+ A = 1 << 18;
+
+ for (j = 0; j < lumFilterSize; j++)
+ A += alpSrc[j][i] * lumFilter[j];
+
+ if (A & 0xF8000000)
+ A = av_clip_uintp2(A, 27);
+ }
+
+ Y -= c->yuv2rgb_y_offset;
+ Y *= c->yuv2rgb_y_coeff;
+ Y += 1 << 13;
+ R = V * c->yuv2rgb_v2r_coeff;
+ G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
+ B = U * c->yuv2rgb_u2b_coeff;
+
+ R = av_clip_uintp2(Y + R, 30);
+ G = av_clip_uintp2(Y + G, 30);
+ B = av_clip_uintp2(Y + B, 30);
+
+ dest16[0][i] = G >> 14;
+ dest16[1][i] = B >> 14;
+ dest16[2][i] = R >> 14;
+ if (hasAlpha)
+ dest16[3][i] = A >> 11;
+ }
+ if ((!isBE(c->dstFormat)) != (!HAVE_BIGENDIAN)) {
+ for (i = 0; i < dstW; i++) {
+ dest16[0][i] = av_bswap16(dest16[0][i]);
+ dest16[1][i] = av_bswap16(dest16[1][i]);
+ dest16[2][i] = av_bswap16(dest16[2][i]);
+ if (hasAlpha)
+ dest16[3][i] = av_bswap16(dest16[3][i]);
+ }
+ }
+}
+
+static void
yuv2ya8_1_c(SwsContext *c, const int16_t *buf0,
const int16_t *ubuf[2], const int16_t *vbuf[2],
const int16_t *abuf0, uint8_t *dest, int dstW,
@@ -2402,8 +2477,6 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c,
case AV_PIX_FMT_GBRP12LE:
case AV_PIX_FMT_GBRP14BE:
case AV_PIX_FMT_GBRP14LE:
- case AV_PIX_FMT_GBRP16BE:
- case AV_PIX_FMT_GBRP16LE:
case AV_PIX_FMT_GBRAP:
case AV_PIX_FMT_GBRAP10BE:
case AV_PIX_FMT_GBRAP10LE:
@@ -2411,6 +2484,12 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c,
case AV_PIX_FMT_GBRAP12LE:
*yuv2anyX = yuv2gbrp_full_X_c;
break;
+ case AV_PIX_FMT_GBRP16BE:
+ case AV_PIX_FMT_GBRP16LE:
+ case AV_PIX_FMT_GBRAP16BE:
+ case AV_PIX_FMT_GBRAP16LE:
+ *yuv2anyX = yuv2gbrp16_full_X_c;
+ break;
}
if (!*yuv2packedX && !*yuv2anyX)
goto YUV_PACKED;
diff --git a/libswscale/utils.c b/libswscale/utils.c
index 15cc56d5a4..60a8e55ba5 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -230,11 +230,11 @@ static const FormatEntry format_entries[AV_PIX_FMT_NB] = {
[AV_PIX_FMT_GBRAP12BE] = { 1, 1 },
[AV_PIX_FMT_GBRP14LE] = { 1, 1 },
[AV_PIX_FMT_GBRP14BE] = { 1, 1 },
- [AV_PIX_FMT_GBRP16LE] = { 1, 0 },
- [AV_PIX_FMT_GBRP16BE] = { 1, 0 },
+ [AV_PIX_FMT_GBRP16LE] = { 1, 1 },
+ [AV_PIX_FMT_GBRP16BE] = { 1, 1 },
[AV_PIX_FMT_GBRAP] = { 1, 1 },
- [AV_PIX_FMT_GBRAP16LE] = { 1, 0 },
- [AV_PIX_FMT_GBRAP16BE] = { 1, 0 },
+ [AV_PIX_FMT_GBRAP16LE] = { 1, 1 },
+ [AV_PIX_FMT_GBRAP16BE] = { 1, 1 },
[AV_PIX_FMT_BAYER_BGGR8] = { 1, 0 },
[AV_PIX_FMT_BAYER_RGGB8] = { 1, 0 },
[AV_PIX_FMT_BAYER_GBRG8] = { 1, 0 },