/// <summary> /// <see cref="av_parser_parse2(FFmpeg.AutoGen.AVCodecParserContext*, FFmpeg.AutoGen.AVCodecContext*, byte**, int*, byte*, int, long, long, long)"/> /// </summary> public int Parse(CodecContext codecContext, DataPointer data, out DataPointer result, long pts = NoPts, long dts = NoPts, long pos = 0) { byte *outBuffer; int outBufferSize; int offset = av_parser_parse2(this, codecContext, &outBuffer, &outBufferSize, (byte *)data.Pointer, data.Length, pts, dts, pos).ThrowIfError(); result = new DataPointer(outBuffer, outBufferSize); return(offset); }
public IEnumerable <DataPointer> Parse(CodecContext codecContext, Stream sourceStream, int bufferSize = 4096, long pts = NoPts, long dts = NoPts, long pos = 0) { IntPtr buffer = AllocZero(bufferSize + AV_INPUT_BUFFER_PADDING_SIZE); try { while (true) { int thisBufferLength = sourceStream.Read(ToSpan(buffer, bufferSize)); if (thisBufferLength == 0) { break; } DataPointer thisBuffer = new DataPointer(buffer, thisBufferLength); while (thisBuffer.Length > 0) { int offset = Parse(codecContext, thisBuffer, out DataPointer dataPointer, pts, dts, pos); if (dataPointer.Length > 0) { yield return(dataPointer); } thisBuffer = thisBuffer[offset..];
/// <summary> /// <see cref="avcodec_parameters_from_context(AVCodecParameters*, AVCodecContext*)"/> /// </summary> public void CopyFrom(CodecContext ctx) { avcodec_parameters_from_context(this, ctx).ThrowIfError(); }