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); }
public bool Init(CudaTools.DECODER_MODE modeDecoder, CudaTools.ENCODER_MODE modeEncoder, CudaTools.VIDEOSINK_MODE modeSink, int outputWidth, int outputHeight, int bitRate, int frameRate, int gopLength, int invalidateRefFramesEnableFlag = 0, int intraRefreshEnableFlag = 1, int intraRefreshPeriod = 5, int intraRefreshDuration = 5) { bool success = false; if (success = InitDecoder(modeDecoder, outputWidth, outputHeight)) { if (success = InitEncoder(modeEncoder, modeSink, bitRate, frameRate, gopLength, invalidateRefFramesEnableFlag, intraRefreshEnableFlag, intraRefreshPeriod, intraRefreshDuration)) { if (success) { IntPtr semaphoreOutput; IntPtr eventStopped; CudaTools.VideoEncoder_GetWindowsHandles64(m_videoEncoder, out eventStopped, out semaphoreOutput); m_OutputQueueEncoderSemaphore = new Semaphore(0, int.MaxValue); m_OutputQueueEncoderSemaphore.SafeWaitHandle = new SafeWaitHandle(semaphoreOutput, false); } } } 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); }