Esempio n. 1
0
        private CuCallbackResult SequenceCallback(
            IntPtr data, ref CuVideoFormat format)
        {
            using var _ = _context.Push();

            PrintInformation("CuVideoFormat", new Dictionary <string, object>
            {
                ["Codec"]       = format.Codec,
                ["Bitrate"]     = format.Bitrate,
                ["CodedWidth"]  = format.CodedWidth,
                ["CodedHeight"] = format.CodedHeight,
                ["Framerate"]   = format.FrameRateNumerator / format.FrameRateDenominator,
            });

            if (!format.IsSupportedByDecoder(out var error, out var caps))
            {
                Console.Error.WriteLine(error);
                Environment.Exit(-1);
                return(CuCallbackResult.Failure);
            }

            PrintInformation("CuVideoDecodeCaps", new Dictionary <string, object>
            {
                ["MaxWidth"]  = caps.MaxWidth,
                ["MaxHeight"] = caps.MaxHeight,
            });

            if (!_decoder.IsEmpty)
            {
                _decoder.Reconfigure(ref format);
                return(CuCallbackResult.Success);
            }

            _info = new CuVideoDecodeCreateInfo
            {
                CodecType       = format.Codec,
                ChromaFormat    = format.ChromaFormat,
                OutputFormat    = format.GetSurfaceFormat(),
                BitDepthMinus8  = format.BitDepthLumaMinus8,
                DeinterlaceMode = format.ProgressiveSequence
                    ? CuVideoDeinterlaceMode.Weave
                    : CuVideoDeinterlaceMode.Adaptive,
                NumOutputSurfaces = 2,
                CreationFlags     = CuVideoCreateFlags.PreferCUVID,
                NumDecodeSurfaces = format.MinNumDecodeSurfaces,
                VideoLock         = _contextLock,
                Width             = format.CodedWidth,
                Height            = format.CodedHeight,
                MaxWidth          = format.CodedWidth,
                MaxHeight         = format.CodedHeight,
                TargetWidth       = format.CodedWidth,
                TargetHeight      = format.CodedHeight
            };

            _decoder = CuVideoDecoder.Create(ref _info);

            return((CuCallbackResult)format.MinNumDecodeSurfaces);
        }
Esempio n. 2
0
 public FrameInformation(
     BufferStorage buffer,
     int pitch,
     CuVideoDecodeCreateInfo info,
     YuvInformation yuvInfo)
 {
     Buffer  = buffer;
     Pitch   = pitch;
     Info    = info;
     YuvInfo = yuvInfo;
 }
Esempio n. 3
0
 /// <inheritdoc cref="CreateDecoder(out CuVideoDecoder, ref CuVideoDecodeCreateInfo)"/>
 public static CuVideoDecoder Create(ref CuVideoDecodeCreateInfo pdci)
 {
     var result = CreateDecoder(out var decoder, ref pdci);
     CheckResult(result);
     return decoder;
 }
Esempio n. 4
0
 public static extern CuResult CreateDecoder(out CuVideoDecoder decoder, ref CuVideoDecodeCreateInfo pdci);