[vlc-commits] nvdec: move cuda format to chroma mapping

Quentin Chateau git at videolan.org
Mon Apr 6 09:37:43 CEST 2020


vlc | branch: master | Quentin Chateau <quentin.chateau at deepskycorp.com> | Fri Apr  3 17:34:37 2020 +0200| [d50d91cc8d8e8ac59e52d4aae8f41cbc1fc8e00d] | committer: Steve Lhomme

nvdec: move cuda format to chroma mapping

Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d50d91cc8d8e8ac59e52d4aae8f41cbc1fc8e00d
---

 modules/hw/nvdec/nvdec.c | 36 +++++++++++++++++++-----------------
 1 file changed, 19 insertions(+), 17 deletions(-)

diff --git a/modules/hw/nvdec/nvdec.c b/modules/hw/nvdec/nvdec.c
index 08312cce54..893cd8381a 100644
--- a/modules/hw/nvdec/nvdec.c
+++ b/modules/hw/nvdec/nvdec.c
@@ -282,6 +282,24 @@ static vlc_fourcc_t MapSurfaceChroma(cudaVideoChromaFormat chroma, unsigned bitD
     }
 }
 
+static vlc_fourcc_t MapSurfaceOpaqueChroma(cudaVideoChromaFormat chroma, unsigned bitDepth)
+{
+    switch (chroma) {
+        case cudaVideoChromaFormat_420:
+            if (bitDepth <= 8)
+                return VLC_CODEC_NVDEC_OPAQUE;
+            if (bitDepth <= 10)
+                return VLC_CODEC_NVDEC_OPAQUE_10B;
+            return VLC_CODEC_NVDEC_OPAQUE_16B;
+        case cudaVideoChromaFormat_444:
+            if (bitDepth <= 8)
+                return VLC_CODEC_NVDEC_OPAQUE_444;
+            return VLC_CODEC_NVDEC_OPAQUE_444_16B;
+        default:
+            return 0;
+    }
+}
+
 static cudaVideoSurfaceFormat MapSurfaceFmt(int i_vlc_fourcc)
 {
     switch (i_vlc_fourcc) {
@@ -1022,23 +1040,7 @@ static int OpenDecoder(vlc_object_t *p_this)
 
     vlc_fourcc_t output_chromas[3];
     size_t chroma_idx = 0;
-    if (cudaChroma == cudaVideoChromaFormat_420)
-    {
-        if (i_depth_luma >= 16)
-            output_chromas[chroma_idx++] = VLC_CODEC_NVDEC_OPAQUE_16B;
-        else if (i_depth_luma > 8)
-            output_chromas[chroma_idx++] = VLC_CODEC_NVDEC_OPAQUE_10B;
-        else
-            output_chromas[chroma_idx++] = VLC_CODEC_NVDEC_OPAQUE;
-    }
-    else if (cudaChroma == cudaVideoChromaFormat_444)
-    {
-        if (i_depth_luma > 8)
-            output_chromas[chroma_idx++] = VLC_CODEC_NVDEC_OPAQUE_444_16B;
-        else
-            output_chromas[chroma_idx++] = VLC_CODEC_NVDEC_OPAQUE_444;
-    }
-
+    output_chromas[chroma_idx++] = MapSurfaceOpaqueChroma(cudaChroma, i_depth_luma);
     output_chromas[chroma_idx++] = MapSurfaceChroma(cudaChroma, i_depth_luma);
     output_chromas[chroma_idx++] = 0;
 



More information about the vlc-commits mailing list