public bool InitCuda() { bool Success = m_cuda != IntPtr.Zero; if (!Success) { if ((m_cuda = CudaTools.Cuda_Create64()) != IntPtr.Zero) { if (CudaTools.Cuda_GetContext64(m_cuda, out m_cudaContext) == true) { Success = true; } } } return(Success); }
public bool Init(CudaTools.CODEC codec = CudaTools.CODEC.H264, CudaTools.DECODER_MODE decoderMode = CudaTools.DECODER_MODE.CPU_ARGB, int skipCount = 1) { bool retVal = false; CloseDecoder(); if ((m_cuda = CudaTools.Cuda_Create64()) != IntPtr.Zero) { ulong t; ulong f; CudaTools.Cuda_GetDeviceMemory64(m_cuda, out t, out f); if (CudaTools.Cuda_GetContext64(m_cuda, out m_cudaContext) == true) { if ((m_videoDecoder = CudaTools.VideoDecoder_Create64(m_cudaContext)) != IntPtr.Zero) { IntPtr semaphoreInput; IntPtr semaphoreOutput; IntPtr eventStopped; CudaTools.VideoDecoder_GetWindowsHandles64(m_videoDecoder, out semaphoreInput, out semaphoreOutput, out eventStopped); m_InputQueueSemaphore = new Semaphore(0, int.MaxValue); m_InputQueueSemaphore.SafeWaitHandle = new SafeWaitHandle(semaphoreInput, false); m_OutputQueueSemaphore = new Semaphore(0, int.MaxValue); m_OutputQueueSemaphore.SafeWaitHandle = new SafeWaitHandle(semaphoreOutput, false); if (CudaTools.VideoDecoder_Init64(m_videoDecoder)) { CudaTools.VideoDecoder_ConfigureDecoder64(m_videoDecoder, (int)m_width, (int)m_height, (int)decoderMode, (int)codec); CudaTools.VideoDecoder_SetSkipCount(m_videoDecoder, skipCount); CudaTools.VideoDecoder_Start64(m_videoDecoder); retVal = true; } } } } return(retVal); }