Bug 1098680 - Use the image size rather than the display size when initializing the apple h264 decoders. r=ajones
--- a/dom/media/fmp4/apple/AppleVDADecoder.cpp
+++ b/dom/media/fmp4/apple/AppleVDADecoder.cpp
@@ -39,18 +39,18 @@ AppleVDADecoder::AppleVDADecoder(const m
, mCallback(aCallback)
, mImageContainer(aImageContainer)
, mDecoder(nullptr)
, mIs106(!nsCocoaFeatures::OnLionOrLater())
{
MOZ_COUNT_CTOR(AppleVDADecoder);
// TODO: Verify aConfig.mime_type.
LOG("Creating AppleVDADecoder for %dx%d h.264 video",
- mConfig.display_width,
- mConfig.display_height
+ mConfig.image_width,
+ mConfig.image_height
);
}
AppleVDADecoder::~AppleVDADecoder()
{
MOZ_COUNT_DTOR(AppleVDADecoder);
}
@@ -232,17 +232,17 @@ AppleVDADecoder::OutputFrame(CVPixelBuff
aFrameRef->composition_timestamp,
aFrameRef->duration,
aFrameRef->is_sync_point ? " keyframe" : ""
);
nsRefPtr<MacIOSurface> macSurface = new MacIOSurface(surface);
// Bounds.
VideoInfo info;
- info.mDisplay = nsIntSize(macSurface->GetWidth(), macSurface->GetHeight());
+ info.mDisplay = nsIntSize(mConfig.display_width, mConfig.display_height);
info.mHasVideo = true;
gfx::IntRect visible = gfx::IntRect(0,
0,
mConfig.display_width,
mConfig.display_height);
nsRefPtr<layers::Image> image =
mImageContainer->CreateImage(ImageFormat::MAC_IOSURFACE);
@@ -406,21 +406,21 @@ AppleVDADecoder::CreateDecoderSpecificat
{
const uint8_t* extradata = mConfig.extra_data.begin();
int extrasize = mConfig.extra_data.length();
OSType format = 'avc1';
AutoCFRelease<CFNumberRef> avc_width =
CFNumberCreate(kCFAllocatorDefault,
kCFNumberSInt32Type,
- &mConfig.display_width);
+ &mConfig.image_width);
AutoCFRelease<CFNumberRef> avc_height =
CFNumberCreate(kCFAllocatorDefault,
kCFNumberSInt32Type,
- &mConfig.display_height);
+ &mConfig.image_height);
AutoCFRelease<CFNumberRef> avc_format =
CFNumberCreate(kCFAllocatorDefault,
kCFNumberSInt32Type,
&format);
AutoCFRelease<CFDataRef> avc_data =
CFDataCreate(kCFAllocatorDefault,
extradata,
extrasize);
--- a/dom/media/fmp4/apple/AppleVTDecoder.cpp
+++ b/dom/media/fmp4/apple/AppleVTDecoder.cpp
@@ -39,18 +39,18 @@ AppleVTDecoder::AppleVTDecoder(const mp4
layers::ImageContainer* aImageContainer)
: AppleVDADecoder(aConfig, aVideoTaskQueue, aCallback, aImageContainer)
, mFormat(nullptr)
, mSession(nullptr)
{
MOZ_COUNT_CTOR(AppleVTDecoder);
// TODO: Verify aConfig.mime_type.
LOG("Creating AppleVTDecoder for %dx%d h.264 video",
- mConfig.display_width,
- mConfig.display_height
+ mConfig.image_width,
+ mConfig.image_height
);
}
AppleVTDecoder::~AppleVTDecoder()
{
MOZ_COUNT_DTOR(AppleVTDecoder);
}
@@ -270,18 +270,18 @@ AppleVTDecoder::InitializeSession()
LOG("AVCDecoderConfig %ld bytes sha1 %s",
mConfig.extra_data.length(), avc_digest.get());
#endif // LOG_MEDIA_SHA1
AutoCFRelease<CFDictionaryRef> extensions = CreateDecoderExtensions();
rv = CMVideoFormatDescriptionCreate(kCFAllocatorDefault,
kCMVideoCodecType_H264,
- mConfig.display_width,
- mConfig.display_height,
+ mConfig.image_width,
+ mConfig.image_height,
extensions,
&mFormat);
if (rv != noErr) {
NS_ERROR("Couldn't create format description!");
return NS_ERROR_FAILURE;
}
// Contruct video decoder selection spec.
--- a/media/libstagefright/binding/DecoderData.cpp
+++ b/media/libstagefright/binding/DecoderData.cpp
@@ -164,16 +164,18 @@ AudioDecoderConfig::IsValid()
}
void
VideoDecoderConfig::Update(sp<MetaData>& aMetaData, const char* aMimeType)
{
TrackConfig::Update(aMetaData, aMimeType);
display_width = FindInt32(aMetaData, kKeyDisplayWidth);
display_height = FindInt32(aMetaData, kKeyDisplayHeight);
+ image_width = FindInt32(aMetaData, kKeyWidth);
+ image_height = FindInt32(aMetaData, kKeyHeight);
if (FindData(aMetaData, kKeyAVCC, &extra_data) && extra_data.length() >= 7) {
// Set size of the NAL length to 4. The demuxer formats its output with
// this NAL length size.
extra_data[4] |= 3;
annex_b = AnnexB::ConvertExtraDataToAnnexB(extra_data);
}
}
--- a/media/libstagefright/binding/include/mp4_demuxer/DecoderData.h
+++ b/media/libstagefright/binding/include/mp4_demuxer/DecoderData.h
@@ -111,16 +111,19 @@ private:
class VideoDecoderConfig : public TrackConfig
{
public:
VideoDecoderConfig() : display_width(0), display_height(0) {}
int32_t display_width;
int32_t display_height;
+ int32_t image_width;
+ int32_t image_height;
+
mozilla::Vector<uint8_t> extra_data; // Unparsed AVCDecoderConfig payload.
mozilla::Vector<uint8_t> annex_b; // Parsed version for sample prepend.
void Update(stagefright::sp<stagefright::MetaData>& aMetaData,
const char* aMimeType);
bool IsValid();
};