Bug 1628690 [Wayland][VA-API] Respect disabled HW decoding to allow fallback to SW decoding, r=jya
authorMartin Stransky <stransky@redhat.com>
Thu, 16 Apr 2020 13:49:37 +0000
changeset 524391 f4379cab74da22ace753deeda675ee8886522002
parent 524390 7d9103e6c1df0fcf3233a5b598c8a10ddcd420bd
child 524392 1aa79304d2f44331c2f41476ff4aa75140ab9651
push id37321
push userdluca@mozilla.com
push dateFri, 17 Apr 2020 09:38:52 +0000
treeherdermozilla-central@24537fed53e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1628690
milestone77.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1628690 [Wayland][VA-API] Respect disabled HW decoding to allow fallback to SW decoding, r=jya Differential Revision: https://phabricator.services.mozilla.com/D71158
dom/media/platforms/ffmpeg/FFmpegDecoderModule.h
dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
dom/media/platforms/ffmpeg/FFmpegVideoDecoder.h
--- a/dom/media/platforms/ffmpeg/FFmpegDecoderModule.h
+++ b/dom/media/platforms/ffmpeg/FFmpegDecoderModule.h
@@ -44,17 +44,19 @@ class FFmpegDecoderModule : public Platf
       // We refuse to create a decoder with low latency enabled if it's VP8 or
       // VP9 unless specifically allowed: this will fallback to libvpx later.
       // We do allow it for h264.
       return nullptr;
     }
     RefPtr<MediaDataDecoder> decoder = new FFmpegVideoDecoder<V>(
         mLib, aParams.mTaskQueue, aParams.VideoConfig(),
         aParams.mKnowsCompositor, aParams.mImageContainer,
-        aParams.mOptions.contains(CreateDecoderParams::Option::LowLatency));
+        aParams.mOptions.contains(CreateDecoderParams::Option::LowLatency),
+        aParams.mOptions.contains(
+            CreateDecoderParams::Option::HardwareDecoderNotAllowed));
     return decoder.forget();
   }
 
   already_AddRefed<MediaDataDecoder> CreateAudioDecoder(
       const CreateDecoderParams& aParams) override {
     RefPtr<MediaDataDecoder> decoder = new FFmpegAudioDecoder<V>(
         mLib, aParams.mTaskQueue, aParams.AudioConfig());
     return decoder.forget();
--- a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
+++ b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
@@ -265,38 +265,41 @@ void FFmpegVideoDecoder<LIBAV_VER>::PtsC
   mNumFaultyDts = 0;
   mLastPts = INT64_MIN;
   mLastDts = INT64_MIN;
 }
 
 FFmpegVideoDecoder<LIBAV_VER>::FFmpegVideoDecoder(
     FFmpegLibWrapper* aLib, TaskQueue* aTaskQueue, const VideoInfo& aConfig,
     KnowsCompositor* aAllocator, ImageContainer* aImageContainer,
-    bool aLowLatency)
+    bool aLowLatency, bool aDisableHardwareDecoding)
     : FFmpegDataDecoder(aLib, aTaskQueue, GetCodecId(aConfig.mMimeType)),
 #ifdef MOZ_WAYLAND_USE_VAAPI
       mVAAPIDeviceContext(nullptr),
+      mDisableHardwareDecoding(aDisableHardwareDecoding),
 #endif
       mImageAllocator(aAllocator),
       mImageContainer(aImageContainer),
       mInfo(aConfig),
       mLowLatency(aLowLatency) {
   // Use a new MediaByteBuffer as the object will be modified during
   // initialization.
   mExtraData = new MediaByteBuffer;
   mExtraData->AppendElements(*aConfig.mExtraData);
 }
 
 RefPtr<MediaDataDecoder::InitPromise> FFmpegVideoDecoder<LIBAV_VER>::Init() {
   MediaResult rv;
 
 #ifdef MOZ_WAYLAND_USE_VAAPI
-  rv = InitVAAPIDecoder();
-  if (NS_SUCCEEDED(rv)) {
-    return InitPromise::CreateAndResolve(TrackInfo::kVideoTrack, __func__);
+  if (!mDisableHardwareDecoding) {
+    rv = InitVAAPIDecoder();
+    if (NS_SUCCEEDED(rv)) {
+      return InitPromise::CreateAndResolve(TrackInfo::kVideoTrack, __func__);
+    }
   }
 #endif
 
   rv = InitDecoder();
   if (NS_SUCCEEDED(rv)) {
     return InitPromise::CreateAndResolve(TrackInfo::kVideoTrack, __func__);
   }
 
--- a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.h
+++ b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.h
@@ -43,17 +43,18 @@ class FFmpegVideoDecoder<LIBAV_VER>
   typedef mozilla::layers::Image Image;
   typedef mozilla::layers::ImageContainer ImageContainer;
   typedef mozilla::layers::KnowsCompositor KnowsCompositor;
   typedef SimpleMap<int64_t> DurationMap;
 
  public:
   FFmpegVideoDecoder(FFmpegLibWrapper* aLib, TaskQueue* aTaskQueue,
                      const VideoInfo& aConfig, KnowsCompositor* aAllocator,
-                     ImageContainer* aImageContainer, bool aLowLatency);
+                     ImageContainer* aImageContainer, bool aLowLatency,
+                     bool aDisableHardwareDecoding);
 
   RefPtr<InitPromise> Init() override;
   void InitCodecContext() override;
   nsCString GetDescriptionName() const override {
 #ifdef USING_MOZFFVPX
     return NS_LITERAL_CSTRING("ffvpx video decoder");
 #else
     return NS_LITERAL_CSTRING("ffmpeg video decoder");
@@ -104,16 +105,17 @@ class FFmpegVideoDecoder<LIBAV_VER>
    * non-hardware accelerated image format that FFmpeg's H264 decoder is
    * capable of outputting.
    */
   int AllocateYUV420PVideoBuffer(AVCodecContext* aCodecContext,
                                  AVFrame* aFrame);
 
 #ifdef MOZ_WAYLAND_USE_VAAPI
   AVBufferRef* mVAAPIDeviceContext;
+  const bool mDisableHardwareDecoding;
 #endif
   RefPtr<KnowsCompositor> mImageAllocator;
   RefPtr<ImageContainer> mImageContainer;
   VideoInfo mInfo;
 
   class PtsCorrectionContext {
    public:
     PtsCorrectionContext();