]> git.sesse.net Git - ffmpeg/commitdiff
swscale: support AV_PIX_FMT_YA16 as input
authorVittorio Giovara <vittorio.giovara@gmail.com>
Sun, 20 Jul 2014 05:05:35 +0000 (01:05 -0400)
committerVittorio Giovara <vittorio.giovara@gmail.com>
Mon, 4 Aug 2014 11:56:05 +0000 (12:56 +0100)
Based on a long debug session with Kostya.

libswscale/input.c
libswscale/swscale-test.c
libswscale/swscale_internal.h
libswscale/swscale_unscaled.c
libswscale/utils.c

index 1ffdfe534b2c6c50322be9cc2e301587c8192a67..f583b3f214dcd718463625f7b816208a51c9cb52 100644 (file)
@@ -419,6 +419,38 @@ static void bswap16UV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *_src1,
     }
 }
 
+static void read_ya16le_gray_c(uint8_t *dst, const uint8_t *src, int width,
+                               uint32_t *unused)
+{
+    int i;
+    for (i = 0; i < width; i++)
+        AV_WN16(dst + i * 2, AV_RL16(src + i * 4));
+}
+
+static void read_ya16le_alpha_c(uint8_t *dst, const uint8_t *src, int width,
+                                uint32_t *unused)
+{
+    int i;
+    for (i = 0; i < width; i++)
+        AV_WN16(dst + i * 2, AV_RL16(src + i * 4 + 2));
+}
+
+static void read_ya16be_gray_c(uint8_t *dst, const uint8_t *src, int width,
+                               uint32_t *unused)
+{
+    int i;
+    for (i = 0; i < width; i++)
+        AV_WN16(dst + i * 2, AV_RB16(src + i * 4));
+}
+
+static void read_ya16be_alpha_c(uint8_t *dst, const uint8_t *src, int width,
+                                uint32_t *unused)
+{
+    int i;
+    for (i = 0; i < width; i++)
+        AV_WN16(dst + i * 2, AV_RB16(src + i * 4 + 2));
+}
+
 /* This is almost identical to the previous, end exists only because
  * yuy2ToY/UV)(dst, src + 1, ...) would have 100% unaligned accesses. */
 static void uyvyToY_c(uint8_t *dst, const uint8_t *src, int width,
@@ -987,6 +1019,14 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
         c->alpToYV12 = bswap16Y_c;
         break;
 #endif
+    case AV_PIX_FMT_YA16LE:
+        c->lumToYV12 = read_ya16le_gray_c;
+        c->alpToYV12 = read_ya16le_alpha_c;
+        break;
+    case AV_PIX_FMT_YA16BE:
+        c->lumToYV12 = read_ya16be_gray_c;
+        c->alpToYV12 = read_ya16be_alpha_c;
+        break;
     case AV_PIX_FMT_YUYV422:
     case AV_PIX_FMT_YVYU422:
     case AV_PIX_FMT_YA8:
index 7cf2dc06af6f9a345b4d1a663d3a074870c99e1f..8063519be15f45bfd3684abe57db82427057fca7 100644 (file)
@@ -39,7 +39,9 @@
     ((x) == AV_PIX_FMT_GRAY8       ||     \
      (x) == AV_PIX_FMT_YA8         ||     \
      (x) == AV_PIX_FMT_GRAY16BE    ||     \
-     (x) == AV_PIX_FMT_GRAY16LE)
+     (x) == AV_PIX_FMT_GRAY16LE    ||     \
+     (x) == AV_PIX_FMT_YA16BE      ||     \
+     (x) == AV_PIX_FMT_YA16LE)
 #define hasChroma(x)                   \
     (!(isGray(x)                ||     \
        (x) == AV_PIX_FMT_MONOBLACK ||     \
index 4aef9617dd30a96bad44d55248711bfec960682e..a0daa071e96bff6cf9bc9dd1d96046f9b36899a8 100644 (file)
@@ -608,7 +608,9 @@ static av_always_inline int isRGB(enum AVPixelFormat pix_fmt)
     ((x) == AV_PIX_FMT_GRAY8       ||  \
      (x) == AV_PIX_FMT_YA8         ||  \
      (x) == AV_PIX_FMT_GRAY16BE    ||  \
-     (x) == AV_PIX_FMT_GRAY16LE)
+     (x) == AV_PIX_FMT_GRAY16LE    ||  \
+     (x) == AV_PIX_FMT_YA16BE      ||  \
+     (x) == AV_PIX_FMT_YA16LE)
 #endif
 
 #define isRGBinInt(x)                  \
index 21762a72ae34c84c2a117557dc46fabde6bb7654..ffc813e1ec0fbcd5d27bf924063aa5e0bd78c63a 100644 (file)
@@ -1053,6 +1053,7 @@ void ff_get_unscaled_swscale(SwsContext *c)
         IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGR565) ||
         IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGRA64) ||
         IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GRAY16) ||
+        IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YA16)   ||
         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_RGB555) ||
index ae121f85298863e6bd0dae02b65d947bf46f3d6b..3a8531d0f0ac2dbeeecdaf42a0c3860398612cb9 100644 (file)
@@ -155,6 +155,8 @@ static const FormatEntry format_entries[AV_PIX_FMT_NB] = {
     [AV_PIX_FMT_BGR444LE]    = { 1, 1 },
     [AV_PIX_FMT_BGR444BE]    = { 1, 1 },
     [AV_PIX_FMT_YA8]         = { 1, 0 },
+    [AV_PIX_FMT_YA16BE]      = { 1, 0 },
+    [AV_PIX_FMT_YA16LE]      = { 1, 0 },
     [AV_PIX_FMT_BGR48BE]     = { 1, 1 },
     [AV_PIX_FMT_BGR48LE]     = { 1, 1 },
     [AV_PIX_FMT_BGRA64BE]    = { 0, 0, 1 },