[FFmpeg-devel] [PATCH] libswscale: GBRAP input & output and GBRAP16 input support
Michael Niedermayer
michaelni at gmx.at
Tue May 7 17:27:04 CEST 2013
On Tue, May 07, 2013 at 03:06:31PM +0000, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol <onemda at gmail.com>
> ---
> libavcodec/utils.c | 1 +
> libswscale/input.c | 18 +++++++++++++++++-
> libswscale/output.c | 9 ++++++++-
> libswscale/swscale.c | 3 +++
> libswscale/swscale_internal.h | 3 ++-
> 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 +
> 16 files changed, 64 insertions(+), 6 deletions(-)
>
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index f4aeb19..900fe43 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 21dfeca..f222d80 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)
> +{
> + 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 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..fc39456 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);
> + src = formatConvBuffer;
> }
>
> if (!c->hyscale_fast) {
> diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
> index c4ea26f..febc2f7 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);
maybe the prototype could be kept matching with readLumPlanar()
(it can be quite annoying to chnage it later when some asm uses it too)
and i dont know if we wont ever need some data table
patch LGTM
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Freedom in capitalist society always remains about the same as it was in
ancient Greek republics: Freedom for slave owners. -- Vladimir Lenin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130507/c4f24286/attachment.asc>
More information about the ffmpeg-devel
mailing list