зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1033137 - Remove extra frame reordering in libav; r=edwin
This commit is contained in:
Родитель
4b1142651a
Коммит
441cb860ec
|
@ -86,16 +86,7 @@ FFmpegH264Decoder<LIBAV_VER>::DecodeFrame(mp4_demuxer::MP4Sample* aSample)
|
|||
aSample->is_sync_point, -1,
|
||||
gfx::IntRect(0, 0, mCodecContext.width, mCodecContext.height));
|
||||
|
||||
// Insert the frame into the heap for reordering.
|
||||
mDelayedFrames.Push(data.forget());
|
||||
|
||||
// Reorder video frames from decode order to presentation order. The minimum
|
||||
// size of the heap comes from one P frame + |max_b_frames| B frames, which
|
||||
// is the maximum number of frames in a row which will be out-of-order.
|
||||
if (mDelayedFrames.Length() > (uint32_t)mCodecContext.max_b_frames + 1) {
|
||||
VideoData* d = mDelayedFrames.Pop();
|
||||
mCallback->Output(d);
|
||||
}
|
||||
mCallback->Output(data.forget());
|
||||
}
|
||||
|
||||
if (mTaskQueue->IsEmpty()) {
|
||||
|
@ -219,14 +210,6 @@ FFmpegH264Decoder<LIBAV_VER>::Input(mp4_demuxer::MP4Sample* aSample)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
FFmpegH264Decoder<LIBAV_VER>::OutputDelayedFrames()
|
||||
{
|
||||
while (!mDelayedFrames.IsEmpty()) {
|
||||
mCallback->Output(mDelayedFrames.Pop());
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
FFmpegH264Decoder<LIBAV_VER>::Drain()
|
||||
{
|
||||
|
@ -241,9 +224,6 @@ FFmpegH264Decoder<LIBAV_VER>::Drain()
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
mTaskQueue->Dispatch(NS_NewRunnableMethod(
|
||||
this, &FFmpegH264Decoder<LIBAV_VER>::OutputDelayedFrames));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -252,14 +232,12 @@ FFmpegH264Decoder<LIBAV_VER>::Flush()
|
|||
{
|
||||
nsresult rv = FFmpegDataDecoder::Flush();
|
||||
// Even if the above fails we may as well clear our frame queue.
|
||||
mDelayedFrames.Clear();
|
||||
return rv;
|
||||
}
|
||||
|
||||
FFmpegH264Decoder<LIBAV_VER>::~FFmpegH264Decoder()
|
||||
{
|
||||
MOZ_COUNT_DTOR(FFmpegH264Decoder);
|
||||
MOZ_ASSERT(mDelayedFrames.IsEmpty());
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
#ifndef __FFmpegH264Decoder_h__
|
||||
#define __FFmpegH264Decoder_h__
|
||||
|
||||
#include "nsTPriorityQueue.h"
|
||||
|
||||
#include "FFmpegDataDecoder.h"
|
||||
|
||||
namespace mozilla
|
||||
|
@ -67,21 +65,6 @@ private:
|
|||
* refcounting.
|
||||
*/
|
||||
nsRefPtr<Image> mCurrentImage;
|
||||
|
||||
struct VideoDataComparator
|
||||
{
|
||||
bool LessThan(VideoData* const& a, VideoData* const& b) const
|
||||
{
|
||||
return a->mTime < b->mTime;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* FFmpeg returns frames in DTS order, so we need to keep a heap of the
|
||||
* previous MAX_B_FRAMES + 1 frames (all B frames in a GOP + one P frame)
|
||||
* ordered by PTS to make sure we present video frames in the intended order.
|
||||
*/
|
||||
nsTPriorityQueue<VideoData*, VideoDataComparator> mDelayedFrames;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
Загрузка…
Ссылка в новой задаче