Example #1
0
        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);
        }
Example #2
0
        public bool InitEncoder(CudaTools.ENCODER_MODE modeEncoder, CudaTools.VIDEOSINK_MODE modeSink, int bitRate, int frameRate, int gopLength,
                                int invalidateRefFramesEnableFlag,
                                int intraRefreshEnableFlag,
                                int intraRefreshPeriod,
                                int intraRefreshDuration)
        {
            bool Success = false;

            FreeEncoder();
            if ((m_videoEncoder = CudaTools.VideoEncoder_Create64(m_videoDecoder)) != IntPtr.Zero)
            {
                CudaTools.VideoEncoder_ConfigureEncoder64(m_videoEncoder, bitRate, (int)frameRate, (int)modeEncoder, (int)modeSink, (int)gopLength, (int)invalidateRefFramesEnableFlag,
                                                          (int)intraRefreshEnableFlag, (int)intraRefreshPeriod, (int)intraRefreshDuration);
                Success = true;
            }
            return(Success);
        }