aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2013-05-06 15:13:53 +0000
committerPaul B Mahol <onemda@gmail.com>2013-05-08 12:48:05 +0000
commit5c057433ccd32f37ddc828d3f82c5b1ad7d3e3db (patch)
tree8edcb9970d79eda2e8c7da1c1f9d557a9999ea7c
parent8d9537228f034037e710146291a933f0f4f554be (diff)
downloadffmpeg-5c057433ccd32f37ddc828d3f82c5b1ad7d3e3db.tar.gz
libswscale: GBRAP input & output and GBRAP16 input support
Signed-off-by: Paul B Mahol <onemda@gmail.com>
-rw-r--r--libavcodec/utils.c1
-rw-r--r--libswscale/input.c18
-rw-r--r--libswscale/output.c9
-rw-r--r--libswscale/swscale.c3
-rw-r--r--libswscale/swscale_internal.h3
-rw-r--r--libswscale/swscale_unscaled.c21
-rw-r--r--libswscale/utils.c6
-rw-r--r--tests/ref/fate/filter-pixdesc1
-rw-r--r--tests/ref/fate/filter-pixfmts-copy1
-rw-r--r--tests/ref/fate/filter-pixfmts-field1
-rw-r--r--tests/ref/fate/filter-pixfmts-hflip1
-rw-r--r--tests/ref/fate/filter-pixfmts-il1
-rw-r--r--tests/ref/fate/filter-pixfmts-null1
-rw-r--r--tests/ref/fate/filter-pixfmts-pad1
-rw-r--r--tests/ref/fate/filter-pixfmts-scale1
-rw-r--r--tests/ref/fate/filter-pixfmts-vflip1
16 files changed, 64 insertions, 6 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 311bca69b0..5899eb831a 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -203,6 +203,7 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
case AV_PIX_FMT_YUV422P:
case AV_PIX_FMT_YUV440P:
case AV_PIX_FMT_YUV444P:
+ case AV_PIX_FMT_GBRAP:
case AV_PIX_FMT_GBRP:
case AV_PIX_FMT_GRAY8:
case AV_PIX_FMT_GRAY16BE:
diff --git a/libswscale/input.c b/libswscale/input.c
index 21dfeca573..35caa322ee 100644
--- a/libswscale/input.c
+++ b/libswscale/input.c
@@ -720,6 +720,14 @@ static void planar_rgb_to_y(uint8_t *_dst, const uint8_t *src[4], int width, int
}
}
+static void planar_rgb_to_a(uint8_t *_dst, const uint8_t *src[4], int width, int32_t *unused)
+{
+ uint16_t *dst = (uint16_t *)_dst;
+ int i;
+ for (i = 0; i < width; i++)
+ dst[i] = src[3][i] << 6;
+}
+
static void planar_rgb_to_uv(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *src[4], int width, int32_t *rgb2yuv)
{
uint16_t *dstU = (uint16_t *)_dstU;
@@ -835,6 +843,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;
@@ -850,9 +859,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;
@@ -955,7 +966,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:
@@ -1084,6 +1096,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;
@@ -1099,9 +1112,12 @@ 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:
+ c->readAlpPlanar = planar_rgb_to_a;
case AV_PIX_FMT_GBRP:
c->readLumPlanar = planar_rgb_to_y;
break;
diff --git a/libswscale/output.c b/libswscale/output.c
index da760d2599..9669b4572b 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 c34c56ca62..827837eec7 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -256,6 +256,9 @@ static av_always_inline void hyscale(SwsContext *c, int16_t *dst, int dstWidth,
} else if (c->readLumPlanar && !isAlpha) {
c->readLumPlanar(formatConvBuffer, src_in, srcW, c->input_rgb2yuv_table);
src = formatConvBuffer;
+ } else if (c->readAlpPlanar && isAlpha) {
+ c->readAlpPlanar(formatConvBuffer, src_in, srcW, NULL);
+ src = formatConvBuffer;
}
if (!c->hyscale_fast) {
diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index c4ea26f694..5e3cc62e3a 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -504,12 +504,13 @@ typedef struct SwsContext {
/**
* Functions to read planar input, such as planar RGB, and convert
- * internally to Y/UV.
+ * internally to Y/UV/A.
*/
/** @{ */
void (*readLumPlanar)(uint8_t *dst, const uint8_t *src[4], int width, int32_t *rgb2yuv);
void (*readChrPlanar)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src[4],
int width, int32_t *rgb2yuv);
+ void (*readAlpPlanar)(uint8_t *dst, const uint8_t *src[4], int width, int32_t *rgb2yuv);
/** @} */
/**
diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c
index 8c24e560ee..d42bb08810 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 b0a0f19110..5f4dabfad7 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 f8473c132b..1387f4f96b 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 4d4088fe32..342840898b 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 eef2eba12d..dec6cb335d 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 a6f5d83826..c9f942bea6 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 29e4235000..e09b2aad10 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 4d4088fe32..342840898b 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 192ff6a430..f8f8dd42cc 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 375ad7cc11..30d9eb97e4 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 76ddf2bedea40c8743f4117b786d4773
gbrp 7b83ae32c1f76bd634e50f4797a74e92
gbrp10be 77dae432c42fad019c286753b0e4b0a8
gbrp10le 7d3e7341423b1206e8a6a3a02b48b5d7
diff --git a/tests/ref/fate/filter-pixfmts-vflip b/tests/ref/fate/filter-pixfmts-vflip
index c6a6c0642c..67961834b6 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