diff mbox

[FFmpeg-devel] swscale: add P016 input support

Message ID 20170129211151.31424-1-philipl@overt.org
State Accepted
Commit 4c2176d45be1a7fbbcdf1f3d01b1ba2bab6f8d0f
Headers show

Commit Message

Philip Langdale Jan. 29, 2017, 9:11 p.m. UTC
Signed-off-by: Philip Langdale <philipl@overt.org>
---
 libswscale/input.c            | 32 ++++++++++++++++++++++++++++++++
 libswscale/swscale_unscaled.c |  4 +++-
 libswscale/utils.c            |  2 ++
 3 files changed, 37 insertions(+), 1 deletion(-)

Comments

Michael Niedermayer Jan. 31, 2017, 1:43 p.m. UTC | #1
On Sun, Jan 29, 2017 at 01:11:51PM -0800, Philip Langdale wrote:
> Signed-off-by: Philip Langdale <philipl@overt.org>
> ---
>  libswscale/input.c            | 32 ++++++++++++++++++++++++++++++++
>  libswscale/swscale_unscaled.c |  4 +++-
>  libswscale/utils.c            |  2 ++
>  3 files changed, 37 insertions(+), 1 deletion(-)

i assume this is tested and works
LGTM

thanks

[...]
Philip Langdale Feb. 1, 2017, 3:49 a.m. UTC | #2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tue, 31 Jan 2017 14:43:24 +0100
Michael Niedermayer <michaelni@gmx.at> wrote:

> On Sun, Jan 29, 2017 at 01:11:51PM -0800, Philip Langdale wrote:

> > Signed-off-by: Philip Langdale <philipl@overt.org>

> > ---

> >  libswscale/input.c            | 32 ++++++++++++++++++++++++++++++++

> >  libswscale/swscale_unscaled.c |  4 +++-

> >  libswscale/utils.c            |  2 ++

> >  3 files changed, 37 insertions(+), 1 deletion(-)  

> 

> i assume this is tested and works

> LGTM

> 

> thanks

> 

> [...]


Yes. Thanks.

- --phil
-----BEGIN PGP SIGNATURE-----

iEYEARECAAYFAliRWuAACgkQ+NaxlGp1aC6d5gCgp8pIgWnWRVMMTkmG87TYsl3s
nHwAmwcM/RFCshlSLfsjqtzqJTd8rDg2
=yaGC
-----END PGP SIGNATURE-----
diff mbox

Patch

diff --git a/libswscale/input.c b/libswscale/input.c
index 1f4ea18..8b5f348 100644
--- a/libswscale/input.c
+++ b/libswscale/input.c
@@ -719,6 +719,28 @@  static void p010BEToUV_c(uint8_t *dstU, uint8_t *dstV,
     }
 }
 
+static void p016LEToUV_c(uint8_t *dstU, uint8_t *dstV,
+                       const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
+                       int width, uint32_t *unused)
+{
+    int i;
+    for (i = 0; i < width; i++) {
+        AV_WN16(dstU + i * 2, AV_RL16(src1 + i * 4 + 0));
+        AV_WN16(dstV + i * 2, AV_RL16(src1 + i * 4 + 2));
+    }
+}
+
+static void p016BEToUV_c(uint8_t *dstU, uint8_t *dstV,
+                       const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
+                       int width, uint32_t *unused)
+{
+    int i;
+    for (i = 0; i < width; i++) {
+        AV_WN16(dstU + i * 2, AV_RB16(src1 + i * 4 + 0));
+        AV_WN16(dstV + i * 2, AV_RB16(src1 + i * 4 + 2));
+    }
+}
+
 #define input_pixel(pos) (isBE(origin) ? AV_RB16(pos) : AV_RL16(pos))
 
 static void bgr24ToY_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2,
@@ -1085,6 +1107,12 @@  av_cold void ff_sws_init_input_funcs(SwsContext *c)
     case AV_PIX_FMT_P010BE:
         c->chrToYV12 = p010BEToUV_c;
         break;
+    case AV_PIX_FMT_P016LE:
+        c->chrToYV12 = p016LEToUV_c;
+        break;
+    case AV_PIX_FMT_P016BE:
+        c->chrToYV12 = p016BEToUV_c;
+        break;
     }
     if (c->chrSrcHSubSample) {
         switch (srcFormat) {
@@ -1326,6 +1354,8 @@  av_cold void ff_sws_init_input_funcs(SwsContext *c)
     case AV_PIX_FMT_GRAY10LE:
     case AV_PIX_FMT_GRAY12LE:
     case AV_PIX_FMT_GRAY16LE:
+
+    case AV_PIX_FMT_P016LE:
         c->lumToYV12 = bswap16Y_c;
         break;
     case AV_PIX_FMT_YUVA444P9LE:
@@ -1362,6 +1392,8 @@  av_cold void ff_sws_init_input_funcs(SwsContext *c)
     case AV_PIX_FMT_GRAY10BE:
     case AV_PIX_FMT_GRAY12BE:
     case AV_PIX_FMT_GRAY16BE:
+
+    case AV_PIX_FMT_P016BE:
         c->lumToYV12 = bswap16Y_c;
         break;
     case AV_PIX_FMT_YUVA444P9BE:
diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c
index b2bfc40..ba3d688 100644
--- a/libswscale/swscale_unscaled.c
+++ b/libswscale/swscale_unscaled.c
@@ -1878,8 +1878,10 @@  void ff_get_unscaled_swscale(SwsContext *c)
          c->chrDstVSubSample == c->chrSrcVSubSample &&
          dstFormat != AV_PIX_FMT_NV12 && dstFormat != AV_PIX_FMT_NV21 &&
          dstFormat != AV_PIX_FMT_P010LE && dstFormat != AV_PIX_FMT_P010BE &&
+         dstFormat != AV_PIX_FMT_P016LE && dstFormat != AV_PIX_FMT_P016BE &&
          srcFormat != AV_PIX_FMT_NV12 && srcFormat != AV_PIX_FMT_NV21 &&
-         srcFormat != AV_PIX_FMT_P010LE && srcFormat != AV_PIX_FMT_P010BE))
+         srcFormat != AV_PIX_FMT_P010LE && srcFormat != AV_PIX_FMT_P010BE &&
+         srcFormat != AV_PIX_FMT_P016LE && srcFormat != AV_PIX_FMT_P016BE))
     {
         if (isPacked(c->srcFormat))
             c->swscale = packedCopyWrapper;
diff --git a/libswscale/utils.c b/libswscale/utils.c
index 60a8e55..caae63a 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -252,6 +252,8 @@  static const FormatEntry format_entries[AV_PIX_FMT_NB] = {
     [AV_PIX_FMT_AYUV64LE]    = { 1, 1},
     [AV_PIX_FMT_P010LE]      = { 1, 1 },
     [AV_PIX_FMT_P010BE]      = { 1, 1 },
+    [AV_PIX_FMT_P016LE]      = { 1, 0 },
+    [AV_PIX_FMT_P016BE]      = { 1, 0 },
 };
 
 int sws_isSupportedInput(enum AVPixelFormat pix_fmt)