Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        public bool InitDecoder(CudaTools.DECODER_MODE modeDecoder, int outputWidth, int outputHeight, CudaTools.CODEC codec = CudaTools.CODEC.H264)
        {
            bool Success = InitCuda();

            if (Success)
            {
                FreeDecoder();
                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 (Success = CudaTools.VideoDecoder_Init64(m_videoDecoder))
                    {
                        CudaTools.VideoDecoder_ConfigureDecoder64(m_videoDecoder, outputWidth, outputHeight, (int)modeDecoder, (int)codec);
                        Success = true;
                    }
                }
            }
            return(Success);
        }