diff mbox

[FFmpeg-devel] Add 16-bit Depth pixel format

Message ID CAHKtxpD0CJr72KtgcXvvh+QLG3aOzpqcaPuT3_VmWzG1cFW54A@mail.gmail.com
State New
Headers show

Commit Message

Pablo Rubio Fernández Nov. 19, 2018, 5:21 p.m. UTC
Hi all!
It's my first time here. I want to create a patch to add Z16 pixel format.
I have did some changes, and I want to know if I'll need change any other
file.
I attach my current patch.
Thanks in advance.

Comments

Paul B Mahol Nov. 19, 2018, 5:41 p.m. UTC | #1
On 11/19/18, Pablo Rubio Fernández <prubio@elitegrupo.com> wrote:
> Hi all!
> It's my first time here. I want to create a patch to add Z16 pixel format.
> I have did some changes, and I want to know if I'll need change any other
> file.
> I attach my current patch.
> Thanks in advance.
>

Isn't this same as gray16?
diff mbox

Patch

From 7f3e028198c510fd8cf14c087d4a223bd7e94422 Mon Sep 17 00:00:00 2001
From: prubio <prubio@elitegrupo.com>
Date: Fri, 16 Nov 2018 11:55:00 +0100
Subject: [PATCH] Add 16-bit Depth z16 pixel format

---
 libavdevice/v4l2-common.c | 3 +++
 libavutil/pixdesc.c       | 9 +++++++++
 libavutil/pixfmt.h        | 2 ++
 libswscale/input.c        | 3 +++
 libswscale/utils.c        | 2 ++
 5 files changed, 19 insertions(+)

diff --git a/libavdevice/v4l2-common.c b/libavdevice/v4l2-common.c
index 2d6bfac..337bb08 100644
--- a/libavdevice/v4l2-common.c
+++ b/libavdevice/v4l2-common.c
@@ -46,6 +46,9 @@  const struct fmt_map ff_fmt_conversion_table[] = {
 #ifdef V4L2_PIX_FMT_Y16
     { AV_PIX_FMT_GRAY16LE,AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_Y16     },
 #endif
+#ifdef V4L2_PIX_FMT_Z16
+    { AV_PIX_FMT_Z16,     AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_Z16     },
+#endif
     { AV_PIX_FMT_NV12,    AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_NV12    },
     { AV_PIX_FMT_NONE,    AV_CODEC_ID_MJPEG,    V4L2_PIX_FMT_MJPEG   },
     { AV_PIX_FMT_NONE,    AV_CODEC_ID_MJPEG,    V4L2_PIX_FMT_JPEG    },
diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index 1c36577..9ede616 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -2268,6 +2268,15 @@  static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
         .flags = AV_PIX_FMT_FLAG_FLOAT,
         .alias = "yf32le",
     },
+    [AV_PIX_FMT_Z16] = {
+        .name = "z16",
+        .nb_components = 1,
+        .log2_chroma_w = 0,
+        .log2_chroma_h = 0,
+        .comp = {
+            { 0, 2, 0, 0, 16, 1, 15, 1 },       /* Y */
+        },
+    },
 };
 #if FF_API_PLUS1_MINUS1
 FF_ENABLE_DEPRECATION_WARNINGS
diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
index 6815f8d..d8a7119 100644
--- a/libavutil/pixfmt.h
+++ b/libavutil/pixfmt.h
@@ -300,6 +300,8 @@  enum AVPixelFormat {
     AV_PIX_FMT_P016LE, ///< like NV12, with 16bpp per component, little-endian
     AV_PIX_FMT_P016BE, ///< like NV12, with 16bpp per component, big-endian
 
+    AV_PIX_FMT_Z16,  ///< 16 bit Depth (little-endian)
+
     /**
      * Hardware surfaces for Direct3D11.
      *
diff --git a/libswscale/input.c b/libswscale/input.c
index 4099c19..7178307 100644
--- a/libswscale/input.c
+++ b/libswscale/input.c
@@ -1448,6 +1448,9 @@  av_cold void ff_sws_init_input_funcs(SwsContext *c)
         c->alpToYV12 = bswap16Y_c;
         break;
 #endif
+    case AV_PIX_FMT_Z16:
+        c->lumToYV12 = bswap16Y_c;
+        break;
     case AV_PIX_FMT_YA16LE:
         c->lumToYV12 = read_ya16le_gray_c;
         break;
diff --git a/libswscale/utils.c b/libswscale/utils.c
index d5913ed..2e18e2d 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -260,6 +260,7 @@  static const FormatEntry format_entries[AV_PIX_FMT_NB] = {
     [AV_PIX_FMT_P016BE]      = { 1, 1 },
     [AV_PIX_FMT_GRAYF32LE]   = { 1, 1 },
     [AV_PIX_FMT_GRAYF32BE]   = { 1, 1 },
+    [AV_PIX_FMT_Z16]         = { 1, 1 },
 };
 
 int sws_isSupportedInput(enum AVPixelFormat pix_fmt)
@@ -1034,6 +1035,7 @@  static int handle_jpeg(enum AVPixelFormat *format)
     case AV_PIX_FMT_GRAY16BE:
     case AV_PIX_FMT_YA16BE:
     case AV_PIX_FMT_YA16LE:
+    case AV_PIX_FMT_Z16:
         return 1;
     default:
         return 0;
-- 
2.7.4