зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1139779: Part2. Use display dimension from SPS NAL. r=rillian
This commit is contained in:
Родитель
60fd94d4f2
Коммит
85f78b847d
|
@ -20,6 +20,7 @@
|
|||
#include "nsThreadUtils.h"
|
||||
#include "prlog.h"
|
||||
#include "VideoUtils.h"
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
PRLogModuleInfo* GetAppleMediaLog();
|
||||
|
@ -35,8 +36,7 @@ AppleVDADecoder::AppleVDADecoder(const mp4_demuxer::VideoDecoderConfig& aConfig,
|
|||
FlushableMediaTaskQueue* aVideoTaskQueue,
|
||||
MediaDataDecoderCallback* aCallback,
|
||||
layers::ImageContainer* aImageContainer)
|
||||
: mConfig(aConfig)
|
||||
, mTaskQueue(aVideoTaskQueue)
|
||||
: mTaskQueue(aVideoTaskQueue)
|
||||
, mCallback(aCallback)
|
||||
, mImageContainer(aImageContainer)
|
||||
, mDecoder(nullptr)
|
||||
|
@ -46,26 +46,32 @@ AppleVDADecoder::AppleVDADecoder(const mp4_demuxer::VideoDecoderConfig& aConfig,
|
|||
// TODO: Verify aConfig.mime_type.
|
||||
|
||||
// Retrieve video dimensions from H264 SPS NAL.
|
||||
mPictureWidth = mConfig.image_width;
|
||||
mPictureHeight = mConfig.image_height;
|
||||
mPictureWidth = aConfig.image_width;
|
||||
mPictureHeight = aConfig.image_height;
|
||||
mDisplayWidth = aConfig.display_width;
|
||||
mDisplayHeight = aConfig.display_height;
|
||||
mExtraData = aConfig.extra_data;
|
||||
mMaxRefFrames = 4;
|
||||
mp4_demuxer::SPSData spsdata;
|
||||
if (mp4_demuxer::H264::DecodeSPSFromExtraData(mConfig.extra_data, spsdata) &&
|
||||
if (mp4_demuxer::H264::DecodeSPSFromExtraData(mExtraData, spsdata) &&
|
||||
spsdata.pic_width && spsdata.pic_height) {
|
||||
mPictureWidth = spsdata.pic_width;
|
||||
mPictureHeight = spsdata.pic_height;
|
||||
mDisplayWidth = spsdata.display_width;
|
||||
mDisplayHeight = spsdata.display_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;
|
||||
std::min(std::max(mMaxRefFrames, spsdata.max_num_ref_frames + 1), 16u);
|
||||
}
|
||||
|
||||
LOG("Creating AppleVDADecoder for %dx%d h.264 video",
|
||||
LOG("Creating AppleVDADecoder for %dx%d (%dx%d) h.264 video",
|
||||
mPictureWidth,
|
||||
mPictureHeight
|
||||
mPictureHeight,
|
||||
mDisplayWidth,
|
||||
mDisplayHeight
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -257,12 +263,12 @@ AppleVDADecoder::OutputFrame(CVPixelBufferRef aImage,
|
|||
nsRefPtr<MacIOSurface> macSurface = new MacIOSurface(surface);
|
||||
// Bounds.
|
||||
VideoInfo info;
|
||||
info.mDisplay = nsIntSize(mConfig.display_width, mConfig.display_height);
|
||||
info.mDisplay = nsIntSize(mDisplayWidth, mDisplayHeight);
|
||||
info.mHasVideo = true;
|
||||
gfx::IntRect visible = gfx::IntRect(0,
|
||||
0,
|
||||
mConfig.display_width,
|
||||
mConfig.display_height);
|
||||
mPictureWidth,
|
||||
mPictureHeight);
|
||||
|
||||
nsRefPtr<layers::Image> image =
|
||||
mImageContainer->CreateImage(ImageFormat::MAC_IOSURFACE);
|
||||
|
@ -410,8 +416,8 @@ AppleVDADecoder::InitializeSession()
|
|||
CFDictionaryRef
|
||||
AppleVDADecoder::CreateDecoderSpecification()
|
||||
{
|
||||
const uint8_t* extradata = mConfig.extra_data->Elements();
|
||||
int extrasize = mConfig.extra_data->Length();
|
||||
const uint8_t* extradata = mExtraData->Elements();
|
||||
int extrasize = mExtraData->Length();
|
||||
|
||||
OSType format = 'avc1';
|
||||
AutoCFRelease<CFNumberRef> avc_width =
|
||||
|
|
|
@ -89,13 +89,15 @@ public:
|
|||
void ClearReorderedFrames();
|
||||
CFDictionaryRef CreateOutputConfiguration();
|
||||
|
||||
const mp4_demuxer::VideoDecoderConfig& mConfig;
|
||||
nsRefPtr<mp4_demuxer::ByteBuffer> mExtraData;
|
||||
nsRefPtr<FlushableMediaTaskQueue> mTaskQueue;
|
||||
MediaDataDecoderCallback* mCallback;
|
||||
nsRefPtr<layers::ImageContainer> mImageContainer;
|
||||
ReorderQueue mReorderQueue;
|
||||
uint32_t mPictureWidth;
|
||||
uint32_t mPictureHeight;
|
||||
uint32_t mDisplayWidth;
|
||||
uint32_t mDisplayHeight;
|
||||
uint32_t mMaxRefFrames;
|
||||
|
||||
private:
|
||||
|
|
|
@ -46,8 +46,8 @@ AppleVTDecoder::AppleVTDecoder(const mp4_demuxer::VideoDecoderConfig& aConfig,
|
|||
MOZ_COUNT_CTOR(AppleVTDecoder);
|
||||
// TODO: Verify aConfig.mime_type.
|
||||
LOG("Creating AppleVTDecoder for %dx%d h.264 video",
|
||||
mConfig.image_width,
|
||||
mConfig.image_height
|
||||
mDisplayWidth,
|
||||
mDisplayHeight
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -262,7 +262,7 @@ AppleVTDecoder::InitializeSession()
|
|||
|
||||
#ifdef LOG_MEDIA_SHA1
|
||||
SHA1Sum avc_hash;
|
||||
avc_hash.update(mConfig.extra_data->Elements(), mConfig.extra_data->Length());
|
||||
avc_hash.update(mExtraData->Elements(),mExtraData->Length());
|
||||
uint8_t digest_buf[SHA1Sum::kHashSize];
|
||||
avc_hash.finish(digest_buf);
|
||||
nsAutoCString avc_digest;
|
||||
|
@ -270,7 +270,7 @@ AppleVTDecoder::InitializeSession()
|
|||
avc_digest.AppendPrintf("%02x", digest_buf[i]);
|
||||
}
|
||||
LOG("AVCDecoderConfig %ld bytes sha1 %s",
|
||||
mConfig.extra_data->Length(), avc_digest.get());
|
||||
mExtraData->Length(), avc_digest.get());
|
||||
#endif // LOG_MEDIA_SHA1
|
||||
|
||||
AutoCFRelease<CFDictionaryRef> extensions = CreateDecoderExtensions();
|
||||
|
@ -329,8 +329,8 @@ AppleVTDecoder::CreateDecoderExtensions()
|
|||
{
|
||||
AutoCFRelease<CFDataRef> avc_data =
|
||||
CFDataCreate(kCFAllocatorDefault,
|
||||
mConfig.extra_data->Elements(),
|
||||
mConfig.extra_data->Length());
|
||||
mExtraData->Elements(),
|
||||
mExtraData->Length());
|
||||
|
||||
const void* atomsKey[] = { CFSTR("avcC") };
|
||||
const void* atomsValue[] = { avc_data };
|
||||
|
|
Загрузка…
Ссылка в новой задаче