Bug 1098680 - Use the image size rather than the display size when initializing the apple h264 decoders. r=ajones
authorMatt Woodrow <mwoodrow@mozilla.com>
Fri, 14 Nov 2014 17:15:42 +1300
changeset 231918 ee84af2b3f2dcf98629ba774af7b57c8c7c13b90
parent 231917 98e5853c10436b071c96ede66ca73a6d43d4cc97
child 231919 cc92e864c67953497eabfed90fa74130eea2a9c0
push id7326
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:58:42 +0000
treeherdermozilla-aurora@d3a3b2a0f2f8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersajones
bugs1098680
milestone36.0a1
Bug 1098680 - Use the image size rather than the display size when initializing the apple h264 decoders. r=ajones
dom/media/fmp4/apple/AppleVDADecoder.cpp
dom/media/fmp4/apple/AppleVTDecoder.cpp
media/libstagefright/binding/DecoderData.cpp
media/libstagefright/binding/include/mp4_demuxer/DecoderData.h
--- 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();
 };