Bug 1496529 - P3. Make the Apple H264 decoder provide 0 latency option. r=bryce
authorJean-Yves Avenard <jyavenard@mozilla.com>
Tue, 09 Oct 2018 16:59:05 +0000
changeset 488764 19cdb829699f0bcaa047c7a29bb9d6b494f4e412
parent 488763 f2b367bc188af94df47032d10cab669d0dc0c474
child 488765 b76ae0d758d9ae80d762c901c0faa321ddba57f1
push id246
push userfmarier@mozilla.com
push dateSat, 13 Oct 2018 00:15:40 +0000
reviewersbryce
bugs1496529
milestone64.0a1
Bug 1496529 - P3. Make the Apple H264 decoder provide 0 latency option. r=bryce When used with the LowLatency option, we guarantee that the stream will contain no B-frame, as such we can reduce the re-ordering queue to zero. The apple VT decoder already returns frames in decode order making this change trivial. Depends on D7861 Differential Revision: https://phabricator.services.mozilla.com/D7862
dom/media/platforms/apple/AppleDecoderModule.cpp
dom/media/platforms/apple/AppleVTDecoder.cpp
dom/media/platforms/apple/AppleVTDecoder.h
--- a/dom/media/platforms/apple/AppleDecoderModule.cpp
+++ b/dom/media/platforms/apple/AppleDecoderModule.cpp
@@ -64,17 +64,18 @@ AppleDecoderModule::Startup()
 }
 
 already_AddRefed<MediaDataDecoder>
 AppleDecoderModule::CreateVideoDecoder(const CreateDecoderParams& aParams)
 {
   RefPtr<MediaDataDecoder> decoder =
     new AppleVTDecoder(aParams.VideoConfig(),
                        aParams.mTaskQueue,
-                       aParams.mImageContainer);
+                       aParams.mImageContainer,
+                       aParams.mOptions);
   return decoder.forget();
 }
 
 already_AddRefed<MediaDataDecoder>
 AppleDecoderModule::CreateAudioDecoder(const CreateDecoderParams& aParams)
 {
   RefPtr<MediaDataDecoder> decoder =
     new AppleATDecoder(aParams.AudioConfig(), aParams.mTaskQueue);
--- a/dom/media/platforms/apple/AppleVTDecoder.cpp
+++ b/dom/media/platforms/apple/AppleVTDecoder.cpp
@@ -23,39 +23,43 @@
 #define LOG(...) DDMOZ_LOG(sPDMLog, mozilla::LogLevel::Debug, __VA_ARGS__)
 #define LOGEX(_this, ...)                                                      \
   DDMOZ_LOGEX(_this, sPDMLog, mozilla::LogLevel::Debug, __VA_ARGS__)
 
 namespace mozilla {
 
 AppleVTDecoder::AppleVTDecoder(const VideoInfo& aConfig,
                                TaskQueue* aTaskQueue,
-                               layers::ImageContainer* aImageContainer)
+                               layers::ImageContainer* aImageContainer,
+                               CreateDecoderParams::OptionSet aOptions)
   : mExtraData(aConfig.mExtraData)
   , mPictureWidth(aConfig.mImage.width)
   , mPictureHeight(aConfig.mImage.height)
   , mDisplayWidth(aConfig.mDisplay.width)
   , mDisplayHeight(aConfig.mDisplay.height)
   , mTaskQueue(aTaskQueue)
-  , mMaxRefFrames(H264::ComputeMaxRefFrames(aConfig.mExtraData))
+  , mMaxRefFrames(aOptions.contains(CreateDecoderParams::Option::LowLatency)
+                    ? 0
+                    : H264::ComputeMaxRefFrames(aConfig.mExtraData))
   , mImageContainer(aImageContainer)
 #ifdef MOZ_WIDGET_UIKIT
   , mUseSoftwareImages(true)
 #else
   , mUseSoftwareImages(false)
 #endif
   , mIsFlushing(false)
   , mMonitor("AppleVTDecoder")
   , mFormat(nullptr)
   , mSession(nullptr)
   , mIsHardwareAccelerated(false)
 {
   MOZ_COUNT_CTOR(AppleVTDecoder);
   // TODO: Verify aConfig.mime_type.
-  LOG("Creating AppleVTDecoder for %dx%d h.264 video", mDisplayWidth,
+  LOG("Creating AppleVTDecoder for %dx%d h.264 video",
+      mDisplayWidth,
       mDisplayHeight);
 
   // To ensure our PromiseHolder is only ever accessed with the monitor held.
   mPromise.SetMonitor(&mMonitor);
 }
 
 AppleVTDecoder::~AppleVTDecoder()
 {
--- a/dom/media/platforms/apple/AppleVTDecoder.h
+++ b/dom/media/platforms/apple/AppleVTDecoder.h
@@ -21,17 +21,18 @@ DDLoggedTypeDeclNameAndBase(AppleVTDecod
 
 class AppleVTDecoder
   : public MediaDataDecoder
   , public DecoderDoctorLifeLogger<AppleVTDecoder>
 {
 public:
   AppleVTDecoder(const VideoInfo& aConfig,
                  TaskQueue* aTaskQueue,
-                 layers::ImageContainer* aImageContainer);
+                 layers::ImageContainer* aImageContainer,
+                 CreateDecoderParams::OptionSet aOptions);
 
   class AppleFrameRef {
   public:
     media::TimeUnit decode_timestamp;
     media::TimeUnit composition_timestamp;
     media::TimeUnit duration;
     int64_t byte_offset;
     bool is_sync_point;