[vlc-commits] nvdec: get the decoder device earlier

Steve Lhomme git at videolan.org
Tue Mar 17 11:32:15 CET 2020


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Mar 16 15:33:03 2020 +0100| [87c40237d939890cdf85227488d20a78c6be101e] | committer: Steve Lhomme

nvdec: get the decoder device earlier

If the decoder device doesn't match we shouldn't be using this decoder anyway.

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

 modules/hw/nvdec/nvdec.c | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/modules/hw/nvdec/nvdec.c b/modules/hw/nvdec/nvdec.c
index 162330788f..d5246bf4bd 100644
--- a/modules/hw/nvdec/nvdec.c
+++ b/modules/hw/nvdec/nvdec.c
@@ -758,17 +758,33 @@ static int OpenDecoder(vlc_object_t *p_this)
             return VLC_EGENERIC;
     }
 
+    vlc_decoder_device *dec_device = decoder_GetDecoderDevice( p_dec );
+    if (dec_device == NULL)
+        return VLC_ENOOBJ;
+    if (dec_device->type != VLC_DECODER_DEVICE_NVDEC)
+    {
+        vlc_decoder_device_Release(dec_device);
+        return VLC_ENOOBJ;
+    }
+    p_sys->vctx_out = vlc_video_context_Create( dec_device, VLC_VIDEO_CONTEXT_NVDEC, 0, NULL );
+    vlc_decoder_device_Release(dec_device);
+    if (unlikely(p_sys->vctx_out == NULL))
+    {
+        msg_Err(p_dec, "failed to create a video context");
+        return VLC_ENOOBJ;
+    }
+
     result = cuvid_load_functions(&p_sys->cuvidFunctions, p_dec);
     if (result != VLC_SUCCESS) {
         if (p_sys->b_is_hxxx)
             hxxx_helper_clean(&p_sys->hh);
-        return VLC_EGENERIC;
+        goto error;
     }
     result = cuda_load_functions(&p_sys->cudaFunctions, p_dec);
     if (result != VLC_SUCCESS) {
         if (p_sys->b_is_hxxx)
             hxxx_helper_clean(&p_sys->hh);
-        return VLC_EGENERIC;
+        goto error;
     }
 
     result = CALL_CUDA_DEC(cuInit, 0);
@@ -918,20 +934,6 @@ static int OpenDecoder(vlc_object_t *p_this)
         goto error;
     }
 
-    vlc_decoder_device *dec_device = decoder_GetDecoderDevice( p_dec );
-    if (dec_device == NULL)
-        goto error;
-    if (dec_device->type == VLC_DECODER_DEVICE_NVDEC)
-    {
-        p_sys->vctx_out = vlc_video_context_Create( dec_device, VLC_VIDEO_CONTEXT_NVDEC, 0, NULL );
-    }
-    vlc_decoder_device_Release(dec_device);
-    if (unlikely(p_sys->vctx_out == NULL))
-    {
-        msg_Err(p_dec, "failed to create a video context");
-        goto error;
-    }
-
     vlc_fourcc_t output_chromas[3];
     size_t chroma_idx = 0;
     if (cudaChroma == cudaVideoChromaFormat_420)



More information about the vlc-commits mailing list