fix for h264 with b-frame pyramid stuff

Originally committed to SVN as r2161.
This commit is contained in:
Fredrik Mellbin 2008-03-30 15:39:02 +00:00
parent aaa6d081d3
commit 0e01a74fb5
3 changed files with 24 additions and 7 deletions

View file

@ -357,19 +357,26 @@ int FFMatroskaSource::DecodeNextFrame(AVFrame *AFrame, int64_t *AFirstStartTime,
unsigned int Track, FrameFlags, FrameSize;
while (mkv_ReadFrame(MF, 0, &Track, &StartTime, &EndTime, &FilePos, &FrameSize, &FrameFlags) == 0) {
FrameSize = ReadFrame(FilePos, FrameSize, VideoCS, Env);
if (*AFirstStartTime < 0)
*AFirstStartTime = StartTime;
FrameSize = ReadFrame(FilePos, FrameSize, VideoCS, Env);
Ret = avcodec_decode_video(VideoCodecContext, AFrame, &FrameFinished, Buffer, FrameSize);
if (Ret < 0)
goto Error;
if (FrameFinished)
goto Done;
}
// Flush the last frame
if (CurrentFrame == VI.num_frames - 1 && VideoCodecContext->has_b_frames)
// Flush the last frames
if (VideoCodecContext->has_b_frames)
Ret = avcodec_decode_video(VideoCodecContext, AFrame, &FrameFinished, NULL, 0);
if (!FrameFinished || Ret < 0)
goto Error;
Error:
Done:
return Ret;
}

View file

@ -237,10 +237,13 @@ int FFmpegSource::DecodeNextFrame(AVFrame *AFrame, int64_t *AStartTime) {
while (av_read_frame(FormatContext, &Packet) >= 0) {
if (Packet.stream_index == VideoTrack) {
Ret = avcodec_decode_video(VideoCodecContext, AFrame, &FrameFinished, Packet.data, Packet.size);
if (*AStartTime < 0)
*AStartTime = Packet.dts;
Ret = avcodec_decode_video(VideoCodecContext, AFrame, &FrameFinished, Packet.data, Packet.size);
if (Ret < 0)
goto Error;
}
av_free_packet(&Packet);
@ -249,10 +252,15 @@ int FFmpegSource::DecodeNextFrame(AVFrame *AFrame, int64_t *AStartTime) {
goto Done;
}
// Flush the last frame
if (CurrentFrame == VI.num_frames - 1 && VideoCodecContext->has_b_frames)
// Flush the last frames
if (VideoCodecContext->has_b_frames)
Ret = avcodec_decode_video(VideoCodecContext, AFrame, &FrameFinished, NULL, 0);
if (!FrameFinished || Ret < 0)
goto Error;
// Ignore errors for now
Error:
Done:
return Ret;
}

View file

@ -166,6 +166,8 @@ Note that --enable-w32threads is required for multithreaded decoding to work.
<h2>Changes</h2>
<ul>
<li>1.17<ul>
<li>Changed error handling slightly in video decoding (most errors are still ignored)</li>
<li>Fixed a bug where the last frame(s) wouldn't be returned properly in h264 with b-frames+pyramid</li>
<li>Updated FFmpeg to rev X</li>
</ul></li>