зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1111319: Reorder video frames with respect to decoding sliding window. r=rillian
This commit is contained in:
Родитель
a52d454032
Коммит
a3c28798a1
|
@ -48,11 +48,19 @@ AppleVDADecoder::AppleVDADecoder(const mp4_demuxer::VideoDecoderConfig& aConfig,
|
|||
// Retrieve video dimensions from H264 SPS NAL.
|
||||
mPictureWidth = mConfig.image_width;
|
||||
mPictureHeight = mConfig.image_height;
|
||||
mMaxRefFrames = 4;
|
||||
mp4_demuxer::SPSData spsdata;
|
||||
if (mp4_demuxer::H264::DecodeSPSFromExtraData(mConfig.extra_data, spsdata) &&
|
||||
spsdata.pic_width && spsdata.pic_height) {
|
||||
mPictureWidth = spsdata.pic_width;
|
||||
mPictureHeight = spsdata.pic_height;
|
||||
// max_num_ref_frames determines the size of the sliding window
|
||||
// we need to queue that many frames in order to guarantee proper
|
||||
// pts frames ordering. Use a minimum of 4 to ensure proper playback of
|
||||
// non compliant videos.
|
||||
mMaxRefFrames =
|
||||
(spsdata.max_num_ref_frames + 1) > mMaxRefFrames ?
|
||||
spsdata.max_num_ref_frames + 1 : mMaxRefFrames;
|
||||
}
|
||||
|
||||
LOG("Creating AppleVDADecoder for %dx%d h.264 video",
|
||||
|
@ -282,17 +290,9 @@ AppleVDADecoder::OutputFrame(CVPixelBufferRef aImage,
|
|||
// in composition order.
|
||||
mReorderQueue.Push(data);
|
||||
// Assume a frame with a PTS <= current DTS is ready.
|
||||
while (mReorderQueue.Length() > 0) {
|
||||
while (mReorderQueue.Length() > mMaxRefFrames) {
|
||||
nsRefPtr<VideoData> readyData = mReorderQueue.Pop();
|
||||
if (readyData->mTime <= aFrameRef->decode_timestamp) {
|
||||
LOG("returning queued frame with pts %lld", readyData->mTime);
|
||||
mCallback->Output(readyData);
|
||||
} else {
|
||||
LOG("requeued frame with pts %lld > %lld",
|
||||
readyData->mTime, aFrameRef->decode_timestamp);
|
||||
mReorderQueue.Push(readyData);
|
||||
break;
|
||||
}
|
||||
}
|
||||
LOG("%llu decoded frames queued",
|
||||
static_cast<unsigned long long>(mReorderQueue.Length()));
|
||||
|
|
|
@ -92,6 +92,7 @@ public:
|
|||
ReorderQueue mReorderQueue;
|
||||
uint32_t mPictureWidth;
|
||||
uint32_t mPictureHeight;
|
||||
uint32_t mMaxRefFrames;
|
||||
|
||||
private:
|
||||
VDADecoder mDecoder;
|
||||
|
|
Загрузка…
Ссылка в новой задаче