[FFmpeg-devel] [PATCH 1/2] libswscale: GBRAP input & output and GBRAP16 input support
Paul B Mahol
onemda at gmail.com
Tue May 7 11:39:10 CEST 2013
Signed-off-by: Paul B Mahol <onemda at gmail.com>
---
libswscale/input.c | 9 ++++++++-
libswscale/output.c | 9 ++++++++-
libswscale/swscale.c | 2 +-
libswscale/swscale_unscaled.c | 21 +++++++++++++++++++++
libswscale/utils.c | 6 +++---
tests/ref/fate/filter-pixdesc | 1 +
tests/ref/fate/filter-pixfmts-copy | 1 +
tests/ref/fate/filter-pixfmts-field | 1 +
tests/ref/fate/filter-pixfmts-hflip | 1 +
tests/ref/fate/filter-pixfmts-il | 1 +
tests/ref/fate/filter-pixfmts-null | 1 +
tests/ref/fate/filter-pixfmts-pad | 1 +
tests/ref/fate/filter-pixfmts-scale | 1 +
tests/ref/fate/filter-pixfmts-vflip | 1 +
14 files changed, 50 insertions(+), 6 deletions(-)
diff --git a/libswscale/input.c b/libswscale/input.c
index 5259603..608edd5 100644
--- a/libswscale/input.c
+++ b/libswscale/input.c
@@ -923,6 +923,7 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
case AV_PIX_FMT_GBRP14LE:
c->readChrPlanar = planar_rgb14le_to_uv;
break;
+ case AV_PIX_FMT_GBRAP16LE:
case AV_PIX_FMT_GBRP16LE:
c->readChrPlanar = planar_rgb16le_to_uv;
break;
@@ -938,9 +939,11 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
case AV_PIX_FMT_GBRP14BE:
c->readChrPlanar = planar_rgb14be_to_uv;
break;
+ case AV_PIX_FMT_GBRAP16BE:
case AV_PIX_FMT_GBRP16BE:
c->readChrPlanar = planar_rgb16be_to_uv;
break;
+ case AV_PIX_FMT_GBRAP:
case AV_PIX_FMT_GBRP:
c->readChrPlanar = planar_rgb_to_uv;
break;
@@ -1043,7 +1046,8 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
case AV_PIX_FMT_BGR555BE:
c->chrToYV12 = bgr15beToUV_half_c;
break;
- case AV_PIX_FMT_GBR24P :
+ case AV_PIX_FMT_GBRAP:
+ case AV_PIX_FMT_GBRP:
c->chrToYV12 = gbr24pToUV_half_c;
break;
case AV_PIX_FMT_BGR444LE:
@@ -1172,6 +1176,7 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
case AV_PIX_FMT_GBRP14LE:
c->readLumPlanar = planar_rgb14le_to_y;
break;
+ case AV_PIX_FMT_GBRAP16LE:
case AV_PIX_FMT_GBRP16LE:
c->readLumPlanar = planar_rgb16le_to_y;
break;
@@ -1187,9 +1192,11 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
case AV_PIX_FMT_GBRP14BE:
c->readLumPlanar = planar_rgb14be_to_y;
break;
+ case AV_PIX_FMT_GBRAP16BE:
case AV_PIX_FMT_GBRP16BE:
c->readLumPlanar = planar_rgb16be_to_y;
break;
+ case AV_PIX_FMT_GBRAP:
case AV_PIX_FMT_GBRP:
c->readLumPlanar = planar_rgb_to_y;
break;
diff --git a/libswscale/output.c b/libswscale/output.c
index da760d2..9669b45 100644
--- a/libswscale/output.c
+++ b/libswscale/output.c
@@ -1495,7 +1495,7 @@ yuv2gbrp_full_X_c(SwsContext *c, const int16_t *lumFilter,
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->dstFormat);
int i;
- int hasAlpha = 0;
+ int hasAlpha = (desc->flags & PIX_FMT_ALPHA) && alpSrc;
uint16_t **dest16 = (uint16_t**)dest;
int SH = 22 + 7 - desc->comp[0].depth_minus1;
@@ -1547,10 +1547,14 @@ yuv2gbrp_full_X_c(SwsContext *c, const int16_t *lumFilter,
dest16[0][i] = G >> SH;
dest16[1][i] = B >> SH;
dest16[2][i] = R >> SH;
+ if (hasAlpha)
+ dest16[3][i] = A;
} else {
dest[0][i] = G >> 22;
dest[1][i] = B >> 22;
dest[2][i] = R >> 22;
+ if (hasAlpha)
+ dest[3][i] = A;
}
}
if (SH != 22 && (!isBE(c->dstFormat)) != (!HAVE_BIGENDIAN)) {
@@ -1558,6 +1562,8 @@ yuv2gbrp_full_X_c(SwsContext *c, const int16_t *lumFilter,
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]);
}
}
}
@@ -1722,6 +1728,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c,
case AV_PIX_FMT_GBRP14LE:
case AV_PIX_FMT_GBRP16BE:
case AV_PIX_FMT_GBRP16LE:
+ case AV_PIX_FMT_GBRAP:
*yuv2anyX = yuv2gbrp_full_X_c;
break;
}
diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index c34c56c..74aba82 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -668,7 +668,7 @@ static int swScale(SwsContext *c, const uint8_t *src[],
lumSrcPtr, vLumFilterSize,
vChrFilter + dstY * vChrFilterSize,
chrUSrcPtr, chrVSrcPtr, vChrFilterSize,
- alpSrcPtr, dest, dstW, dstY);
+ alpPixBuf ? alpSrcPtr : NULL, dest, dstW, dstY);
}
}
}
diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c
index 8c24e56..d42bb08 100644
--- a/libswscale/swscale_unscaled.c
+++ b/libswscale/swscale_unscaled.c
@@ -492,6 +492,22 @@ static int planarRgbToRgbWrapper(SwsContext *c, const uint8_t *src[],
return srcSliceH;
}
+static int planarRgbToplanarRgbWrapper(SwsContext *c, const uint8_t *src[],
+ int srcStride[], int srcSliceY, int srcSliceH,
+ uint8_t *dst[], int dstStride[])
+{
+ copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->srcW,
+ dst[0], dstStride[0]);
+ copyPlane(src[1], srcStride[1], srcSliceY, srcSliceH, c->srcW,
+ dst[1], dstStride[1]);
+ copyPlane(src[2], srcStride[2], srcSliceY, srcSliceH, c->srcW,
+ dst[2], dstStride[2]);
+ if (dst[3])
+ fillPlane(dst[3], dstStride[3], c->srcW, srcSliceH, srcSliceY, 255);
+
+ return srcSliceH;
+}
+
static void packedtogbr24p(const uint8_t *src, int srcStride,
uint8_t *dst[], int dstStride[], int srcSliceH,
int alpha_first, int inc_size, int width)
@@ -1039,6 +1055,10 @@ void ff_get_unscaled_swscale(SwsContext *c)
&& (!needsDither || (c->flags&(SWS_FAST_BILINEAR|SWS_POINT))))
c->swScale= rgbToRgbWrapper;
+ if ((srcFormat == AV_PIX_FMT_GBRP && dstFormat == AV_PIX_FMT_GBRAP) ||
+ (srcFormat == AV_PIX_FMT_GBRAP && dstFormat == AV_PIX_FMT_GBRP))
+ c->swScale = planarRgbToplanarRgbWrapper;
+
#define isByteRGB(f) ( \
f == AV_PIX_FMT_RGB32 || \
f == AV_PIX_FMT_RGB32_1 || \
@@ -1066,6 +1086,7 @@ void ff_get_unscaled_swscale(SwsContext *c)
IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRP12) ||
IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRP14) ||
IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRP16) ||
+ IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRAP16) ||
IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_RGB444) ||
IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_RGB48) ||
IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_RGBA64) ||
diff --git a/libswscale/utils.c b/libswscale/utils.c
index b0a0f19..5f4dabf 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -200,9 +200,9 @@ static const FormatEntry format_entries[AV_PIX_FMT_NB] = {
[AV_PIX_FMT_GBRP16BE] = { 1, 0 },
[AV_PIX_FMT_XYZ12BE] = { 1, 0, 1 },
[AV_PIX_FMT_XYZ12LE] = { 1, 0, 1 },
- [AV_PIX_FMT_GBRAP] = { 0, 0 },
- [AV_PIX_FMT_GBRAP16LE] = { 0, 0 },
- [AV_PIX_FMT_GBRAP16BE] = { 0, 0 },
+ [AV_PIX_FMT_GBRAP] = { 1, 1 },
+ [AV_PIX_FMT_GBRAP16LE] = { 1, 0 },
+ [AV_PIX_FMT_GBRAP16BE] = { 1, 0 },
};
int sws_isSupportedInput(enum AVPixelFormat pix_fmt)
diff --git a/tests/ref/fate/filter-pixdesc b/tests/ref/fate/filter-pixdesc
index f8473c1..1387f4f 100644
--- a/tests/ref/fate/filter-pixdesc
+++ b/tests/ref/fate/filter-pixdesc
@@ -15,6 +15,7 @@ bgr565be 13a36d6502be88fc0c2aec05b8d2d501
bgr565le ed027571692aecd522aa65a90cc7e09b
bgr8 71ef789609c746c2e7e4be9dec29062c
bgra 0364b074268682ea46168742a8239f7d
+gbrap 412a2449fdfaeb5ebdf5e4196cc7391a
gbrp 89d6e4b116e3bd542fa09a19a977ad16
gbrp10be 5dc62e2d01fa7c19a57abe48246f2232
gbrp10le 0cac205a304b59811ce30fcad49b3527
diff --git a/tests/ref/fate/filter-pixfmts-copy b/tests/ref/fate/filter-pixfmts-copy
index 4d4088f..3428408 100644
--- a/tests/ref/fate/filter-pixfmts-copy
+++ b/tests/ref/fate/filter-pixfmts-copy
@@ -15,6 +15,7 @@ bgr565be 13a36d6502be88fc0c2aec05b8d2d501
bgr565le ed027571692aecd522aa65a90cc7e09b
bgr8 71ef789609c746c2e7e4be9dec29062c
bgra 0364b074268682ea46168742a8239f7d
+gbrap 412a2449fdfaeb5ebdf5e4196cc7391a
gbrp 89d6e4b116e3bd542fa09a19a977ad16
gbrp10be 5dc62e2d01fa7c19a57abe48246f2232
gbrp10le 0cac205a304b59811ce30fcad49b3527
diff --git a/tests/ref/fate/filter-pixfmts-field b/tests/ref/fate/filter-pixfmts-field
index eef2eba..dec6cb3 100644
--- a/tests/ref/fate/filter-pixfmts-field
+++ b/tests/ref/fate/filter-pixfmts-field
@@ -15,6 +15,7 @@ bgr565be bf955b9a035af0e613cf1de249f55f9d
bgr565le 6dd85cd5e19266c53a54cbcf06d396a7
bgr8 9669f6974f0fc1c0afa1c7d4df093c0b
bgra f7cabae31dd7465dab2203f45db646f8
+gbrap fdb15f25cd6db3d19a7df727e0f4de3a
gbrp 55eab469e3e02ccc5a358565d9b1eaa7
gbrp10be 38753e9ac21e13d76d1a83bd7272c026
gbrp10le a65ff11ee79ae698550218549288e6cc
diff --git a/tests/ref/fate/filter-pixfmts-hflip b/tests/ref/fate/filter-pixfmts-hflip
index a6f5d83..c9f942b 100644
--- a/tests/ref/fate/filter-pixfmts-hflip
+++ b/tests/ref/fate/filter-pixfmts-hflip
@@ -15,6 +15,7 @@ bgr565be 3b464a00c619410eac7bdea9c96faf60
bgr565le 4b4c708d4ad222f41734dce68e9d48b6
bgr8 ad1db7a17cdfab2ede6f22c2415a3fbf
bgra 85fa06ad9fd156c3179a647a2e741b60
+gbrap 5fbf0a36ee9486161a862a4b2d6f8242
gbrp 95fde5b6a767cf8d2679a4a6d18fdbe7
gbrp10be 5ddc834dbf2198f6b1af36c66b185e2c
gbrp10le 04814cbb805b66e8e085c7db4a548deb
diff --git a/tests/ref/fate/filter-pixfmts-il b/tests/ref/fate/filter-pixfmts-il
index 29e4235..e09b2aa 100644
--- a/tests/ref/fate/filter-pixfmts-il
+++ b/tests/ref/fate/filter-pixfmts-il
@@ -15,6 +15,7 @@ bgr565be 5ff7a76d9f58800e38f21a84d88c7129
bgr565le 485b2b6f589a936d6fb12d0033809dca
bgr8 d7fae34b87a67556c273585d9140ff96
bgra 7b4abc57f0ee99a0226e9bfd5d25cf9e
+gbrap 583131faa19f062f6523321da52066de
gbrp b85cfeb0e34559ffb4b2e4f1209a3712
gbrp10be 5487219fee31607d6b19aa0d302fb42f
gbrp10le 7975e53a9e03a8acfa877334ae5e9d1d
diff --git a/tests/ref/fate/filter-pixfmts-null b/tests/ref/fate/filter-pixfmts-null
index 4d4088f..3428408 100644
--- a/tests/ref/fate/filter-pixfmts-null
+++ b/tests/ref/fate/filter-pixfmts-null
@@ -15,6 +15,7 @@ bgr565be 13a36d6502be88fc0c2aec05b8d2d501
bgr565le ed027571692aecd522aa65a90cc7e09b
bgr8 71ef789609c746c2e7e4be9dec29062c
bgra 0364b074268682ea46168742a8239f7d
+gbrap 412a2449fdfaeb5ebdf5e4196cc7391a
gbrp 89d6e4b116e3bd542fa09a19a977ad16
gbrp10be 5dc62e2d01fa7c19a57abe48246f2232
gbrp10le 0cac205a304b59811ce30fcad49b3527
diff --git a/tests/ref/fate/filter-pixfmts-pad b/tests/ref/fate/filter-pixfmts-pad
index 192ff6a..f8f8dd4 100644
--- a/tests/ref/fate/filter-pixfmts-pad
+++ b/tests/ref/fate/filter-pixfmts-pad
@@ -5,6 +5,7 @@ argb e5fbb7bb282a80897b8f730627f68876
bgr0 c55368036cccbb0af471d6bd82abe02a
bgr24 67f9fd70dc6d9896b7122976b33932b4
bgra c8dd017b5a3b55e8b9d0ac1cdcf327bd
+gbrap 23e8ef832c4aef52c6183f429ac86b32
gbrp 74f83deee9866bbdce3f91fa2aeddaaa
gray b1abadae3718522aa57a7972da8cbe17
rgb0 b1977b45634c4db58a183a07feb2acff
diff --git a/tests/ref/fate/filter-pixfmts-scale b/tests/ref/fate/filter-pixfmts-scale
index 375ad7c..a57847c 100644
--- a/tests/ref/fate/filter-pixfmts-scale
+++ b/tests/ref/fate/filter-pixfmts-scale
@@ -15,6 +15,7 @@ bgr565be fca6f07daf23d9dd84381dd4c9afd959
bgr565le f524e9f16bdd68b247dbcb621e543fc0
bgr8 68a3a395043dc57335ad1f8e891229c5
bgra 3eaf5489b8aa13a3388aad3751b597bf
+gbrap fb463f07681f099871db2309dd438123
gbrp 7b83ae32c1f76bd634e50f4797a74e92
gbrp10be 77dae432c42fad019c286753b0e4b0a8
gbrp10le 7d3e7341423b1206e8a6a3a02b48b5d7
diff --git a/tests/ref/fate/filter-pixfmts-vflip b/tests/ref/fate/filter-pixfmts-vflip
index c6a6c06..6796183 100644
--- a/tests/ref/fate/filter-pixfmts-vflip
+++ b/tests/ref/fate/filter-pixfmts-vflip
@@ -15,6 +15,7 @@ bgr565be 7100c2ddfee42e7efafec1ccefecf7c6
bgr565le 9fab295d966386d4ef99d5b43066da47
bgr8 275ce12eeb05de67a6915f67cbb43ce5
bgra d29c35871248c476c366e678db580982
+gbrap 29844a8e4334493fdd2d499bcb532535
gbrp 7852e9bbe52cfad9bab8081a5c7a5a31
gbrp10be f591c6c98396baf3242837827081f2f7
gbrp10le c5edb9bb566edbc8c478595ac6ab070f
--
1.7.11.2
More information about the ffmpeg-devel
mailing list