[libav-devel] [PATCH 1/5] sws: GBRP9, GBRP10 GBRP12 GBRP14 output support

2013-01-27 Thread Derek Buitenhuis
From: Michael Niedermayer michae...@gmx.at

Signed-off-by: Michael Niedermayer michae...@gmx.at
Signed-off-by: Derek Buitenhuis derek.buitenh...@gmail.com
---
 libswscale/output.c   |   28 +---
 libswscale/utils.c|   16 
 tests/ref/lavfi/pixdesc   |6 ++
 tests/ref/lavfi/pixfmts_copy  |6 ++
 tests/ref/lavfi/pixfmts_null  |6 ++
 tests/ref/lavfi/pixfmts_scale |6 ++
 tests/ref/lavfi/pixfmts_vflip |6 ++
 7 files changed, 63 insertions(+), 11 deletions(-)

diff --git a/libswscale/output.c b/libswscale/output.c
index 4ea2e48..ba7b580 100644
--- a/libswscale/output.c
+++ b/libswscale/output.c
@@ -1269,8 +1269,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;
@@ -1316,9 +1319,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]);
+}
 }
 }
 
@@ -1417,6 +1433,12 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c,
 *yuv2packedX = yuv2bgr24_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_GBRP16BE:
+case AV_PIX_FMT_GBRP16LE:
 *yuv2anyX = yuv2gbrp_full_X_c;
 break;
 }
diff --git a/libswscale/utils.c b/libswscale/utils.c
index a65922b..b0a4d04 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -164,12 +164,12 @@ static const FormatEntry format_entries[AV_PIX_FMT_NB] = {
 [AV_PIX_FMT_YUV444P10BE] = { 1, 1 },
 [AV_PIX_FMT_YUV444P10LE] = { 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_GBRP16LE]= { 1, 0 },
-[AV_PIX_FMT_GBRP16BE]= { 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_GBRP16LE]= { 1, 1 },
+[AV_PIX_FMT_GBRP16BE]= { 1, 1 },
 };
 
 int sws_isSupportedInput(enum AVPixelFormat pix_fmt)
@@ -938,7 +938,7 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter 
*srcFilter,
 getSubSampleFactors(c-chrSrcHSubSample, c-chrSrcVSubSample, srcFormat);
 getSubSampleFactors(c-chrDstHSubSample, c-chrDstVSubSample, dstFormat);
 
-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,
@@ -952,7 +952,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  
diff --git a/tests/ref/lavfi/pixdesc b/tests/ref/lavfi/pixdesc
index eaf0b78..683db66 100644
--- a/tests/ref/lavfi/pixdesc
+++ b/tests/ref/lavfi/pixdesc
@@ -13,6 +13,12 @@ bgr565le1dfdd03995c287e3c754b164bf26a355
 bgr824bd566170343d06fec6fccfff5abc54
 bgra76a18a5151242fa137133f604cd624d2
 gbrp76204621e200a3cc633012f6720c7005
+gbrp10be2ca4a4a589a7dc461ff186913c7a69e5
+gbrp10le46176f1fcc6e67f9862115fe373f73d3
+gbrp16beb577122bb4fc34274b9fc2d1c6b934d0
+gbrp16le7a8fc641745c4f363348522a687d2a08
+gbrp9be 981c2c1b0ef1791824b4c7518331bc2e
+gbrp9le 25fb915ed11d07d631e0e7b78d54bebf
 graydb08f7f0751900347e6b8649e4164d21
 gray16be7becf34ae825a3df3969bf4c6bfeb5e2
 gray16le

Re: [libav-devel] [PATCH 1/5] sws: GBRP9, GBRP10 GBRP12 GBRP14 output support

2013-01-27 Thread Ronald S. Bultje
Hi,

On Sun, Jan 27, 2013 at 1:25 PM, Derek Buitenhuis
derek.buitenh...@gmail.com wrote:
 From: Michael Niedermayer michae...@gmx.at

 Signed-off-by: Michael Niedermayer michae...@gmx.at
 Signed-off-by: Derek Buitenhuis derek.buitenh...@gmail.com
 ---
  libswscale/output.c   |   28 +---
  libswscale/utils.c|   16 
  tests/ref/lavfi/pixdesc   |6 ++
  tests/ref/lavfi/pixfmts_copy  |6 ++
  tests/ref/lavfi/pixfmts_null  |6 ++
  tests/ref/lavfi/pixfmts_scale |6 ++
  tests/ref/lavfi/pixfmts_vflip |6 ++
  7 files changed, 63 insertions(+), 11 deletions(-)

OK if you fix title (no 14/12 bit bgrp here).

Ronald
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 1/5] sws: GBRP9, GBRP10 GBRP12 GBRP14 output support

2013-01-27 Thread Derek Buitenhuis
On 2013-01-27 4:25 PM, Derek Buitenhuis wrote:
 From: Michael Niedermayer michae...@gmx.at
 
 Signed-off-by: Michael Niedermayer michae...@gmx.at
 Signed-off-by: Derek Buitenhuis derek.buitenh...@gmail.com
 ---
  libswscale/output.c   |   28 +---
  libswscale/utils.c|   16 
  tests/ref/lavfi/pixdesc   |6 ++
  tests/ref/lavfi/pixfmts_copy  |6 ++
  tests/ref/lavfi/pixfmts_null  |6 ++
  tests/ref/lavfi/pixfmts_scale |6 ++
  tests/ref/lavfi/pixfmts_vflip |6 ++
  7 files changed, 63 insertions(+), 11 deletions(-)

Message amended locally to reflect what it actually does (GBRP16).

- Derek
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel