//static public IEnumerable<byte[]> DecodeStream(Stream s, FourCC fourcc = FourCC.NV12, AccelerationLevel acceleration = AccelerationLevel.BestAvailableAccelerationUseGPUorCPU) //{ // return null; //} /// <summary> /// Construct the decoder. /// </summary> /// <param name="stream">Stream be read from</param> /// <param name="codecId">What format the bitstream is in: AVC, HEVC, MJPEG, ...</param> /// <param name="impl">implementation to use</param> /// <param name="outIOPattern">memory type for decoding</param> public StreamDecoder(Stream stream, CodecId codecId, mfxIMPL impl = mfxIMPL.MFX_IMPL_AUTO, IOPattern outIOPattern = IOPattern.MFX_IOPATTERN_OUT_SYSTEM_MEMORY) { long oldposition = stream.Position; var buf = new byte[65536]; //avail after init int n = stream.Read(buf, 0, buf.Length); if (n < buf.Length) { Array.Resize(ref buf, n); } stream.Position = oldposition; this.decoderParameters = QuickSyncStatic.DecodeHeader(buf, codecId, impl); this.decoderParameters.IOPattern = outIOPattern; lowLevelDecoder = new LowLevelDecoder(decoderParameters, null, impl); Init(stream); }
/// <summary>Reads the file header information.</summary> /// <param name="codecId">The codec identifier.</param> /// <param name="impl">The implementation.</param> /// <param name="infs">The infs.</param> /// <param name="outIOPattern">The out io pattern.</param> /// <returns></returns> public static unsafe mfxVideoParam ReadFileHeaderInfo(CodecId codecId, mfxIMPL impl, Stream infs, IOPattern outIOPattern) { long oldposition = infs.Position; var buf = new byte[65536]; //avail after init int n = infs.Read(buf, 0, buf.Length); if (n < buf.Length) { Array.Resize(ref buf, n); } infs.Position = oldposition; var decoderParameters = QuickSyncStatic.DecodeHeader(buf, codecId, impl); decoderParameters.IOPattern = outIOPattern; return(decoderParameters); }