From e4033d89f1727d7079545bcb8e5380880e87e2bf Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Fri, 25 Jan 2013 23:05:48 +0100 Subject: sws: GBRP9, GBRP10 GBRP12 GBRP14 output support Signed-off-by: Michael Niedermayer --- libswscale/output.c | 30 +++++++++++++++++++++++++++--- libswscale/utils.c | 20 ++++++++++---------- 2 files changed, 37 insertions(+), 13 deletions(-) (limited to 'libswscale') diff --git a/libswscale/output.c b/libswscale/output.c index 30217c7b63..e49cb73f15 100644 --- a/libswscale/output.c +++ b/libswscale/output.c @@ -1380,8 +1380,11 @@ yuv2gbrp_full_X_c(SwsContext *c, const int16_t *lumFilter, 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 = 0; + uint16_t **dest16 = (uint16_t**)dest; + int SH = 22 + 7 - desc->comp[0].depth_minus1; for (i = 0; i < dstW; i++) { int j; @@ -1421,9 +1424,22 @@ yuv2gbrp_full_X_c(SwsContext *c, const int16_t *lumFilter, B = av_clip_uintp2(B, 30); } - dest[0][i] = G >> 22; - dest[1][i] = B >> 22; - dest[2][i] = R >> 22; + if (SH != 22) { + dest16[0][i] = G >> SH; + dest16[1][i] = B >> SH; + dest16[2][i] = R >> SH; + } else { + dest[0][i] = G >> 22; + dest[1][i] = B >> 22; + dest[2][i] = R >> 22; + } + } + if (SH != 22 && (!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]); + } } } @@ -1541,6 +1557,14 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, *yuv2packedX = yuv2rgb8_full_X_c; break; case AV_PIX_FMT_GBRP: + case AV_PIX_FMT_GBRP9BE: + case AV_PIX_FMT_GBRP9LE: + case AV_PIX_FMT_GBRP10BE: + case AV_PIX_FMT_GBRP10LE: + case AV_PIX_FMT_GBRP12BE: + case AV_PIX_FMT_GBRP12LE: + case AV_PIX_FMT_GBRP14BE: + case AV_PIX_FMT_GBRP14LE: *yuv2anyX = yuv2gbrp_full_X_c; break; } diff --git a/libswscale/utils.c b/libswscale/utils.c index 9e2dfc0bb0..4bb11448ab 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -186,14 +186,14 @@ static const FormatEntry format_entries[AV_PIX_FMT_NB] = { [AV_PIX_FMT_YUV444P14BE] = { 1, 1 }, [AV_PIX_FMT_YUV444P14LE] = { 1, 1 }, [AV_PIX_FMT_GBRP] = { 1, 1 }, - [AV_PIX_FMT_GBRP9LE] = { 1, 0 }, - [AV_PIX_FMT_GBRP9BE] = { 1, 0 }, - [AV_PIX_FMT_GBRP10LE] = { 1, 0 }, - [AV_PIX_FMT_GBRP10BE] = { 1, 0 }, - [AV_PIX_FMT_GBRP12LE] = { 1, 0 }, - [AV_PIX_FMT_GBRP12BE] = { 1, 0 }, - [AV_PIX_FMT_GBRP14LE] = { 1, 0 }, - [AV_PIX_FMT_GBRP14BE] = { 1, 0 }, + [AV_PIX_FMT_GBRP9LE] = { 1, 1 }, + [AV_PIX_FMT_GBRP9BE] = { 1, 1 }, + [AV_PIX_FMT_GBRP10LE] = { 1, 1 }, + [AV_PIX_FMT_GBRP10BE] = { 1, 1 }, + [AV_PIX_FMT_GBRP12LE] = { 1, 1 }, + [AV_PIX_FMT_GBRP12BE] = { 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 }, }; @@ -1019,7 +1019,7 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, c->flags = flags; } } - if(dstFormat == AV_PIX_FMT_GBRP) { + if (isPlanarRGB(dstFormat)) { if (!(flags & SWS_FULL_CHR_H_INT)) { av_log(c, AV_LOG_DEBUG, "%s output is not supported with half chroma resolution, switching to full\n", @@ -1033,7 +1033,7 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, * chroma interpolation */ if (flags & SWS_FULL_CHR_H_INT && isAnyRGB(dstFormat) && - dstFormat != AV_PIX_FMT_GBRP && + !isPlanarRGB(dstFormat) && dstFormat != AV_PIX_FMT_RGBA && dstFormat != AV_PIX_FMT_ARGB && dstFormat != AV_PIX_FMT_BGRA && -- cgit v1.2.3