LCOV - code coverage report
Current view: top level - dom/media/platforms/ffmpeg - FFmpegVideoDecoder.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 5 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 10 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim:set ts=2 sw=2 sts=2 et cindent: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #ifndef __FFmpegVideoDecoder_h__
       8             : #define __FFmpegVideoDecoder_h__
       9             : 
      10             : #include "FFmpegLibWrapper.h"
      11             : #include "FFmpegDataDecoder.h"
      12             : #include "SimpleMap.h"
      13             : 
      14             : namespace mozilla
      15             : {
      16             : 
      17             : template <int V>
      18             : class FFmpegVideoDecoder : public FFmpegDataDecoder<V>
      19             : {
      20             : };
      21             : 
      22             : template <>
      23             : class FFmpegVideoDecoder<LIBAV_VER> : public FFmpegDataDecoder<LIBAV_VER>
      24             : {
      25             :   typedef mozilla::layers::Image Image;
      26             :   typedef mozilla::layers::ImageContainer ImageContainer;
      27             :   typedef mozilla::layers::KnowsCompositor KnowsCompositor;
      28             :   typedef SimpleMap<int64_t> DurationMap;
      29             : 
      30             : public:
      31             :   FFmpegVideoDecoder(FFmpegLibWrapper* aLib, TaskQueue* aTaskQueue,
      32             :                      const VideoInfo& aConfig,
      33             :                      KnowsCompositor* aAllocator,
      34             :                      ImageContainer* aImageContainer,
      35             :                      bool aLowLatency);
      36             :   virtual ~FFmpegVideoDecoder();
      37             : 
      38             :   RefPtr<InitPromise> Init() override;
      39             :   void InitCodecContext() override;
      40           0 :   const char* GetDescriptionName() const override
      41             :   {
      42             : #ifdef USING_MOZFFVPX
      43           0 :     return "ffvpx video decoder";
      44             : #else
      45           0 :     return "ffmpeg video decoder";
      46             : #endif
      47             :   }
      48           0 :   ConversionRequired NeedsConversion() const override
      49             :   {
      50           0 :     return ConversionRequired::kNeedAVCC;
      51             :   }
      52             : 
      53             :   static AVCodecID GetCodecId(const nsACString& aMimeType);
      54             : 
      55             : private:
      56             :   RefPtr<DecodePromise> ProcessDecode(MediaRawData* aSample) override;
      57             :   RefPtr<DecodePromise> ProcessDrain() override;
      58             :   RefPtr<FlushPromise> ProcessFlush() override;
      59             :   MediaResult DoDecode(MediaRawData* aSample, bool* aGotFrame,
      60             :                        DecodedData& aResults);
      61             :   MediaResult DoDecode(MediaRawData* aSample, uint8_t* aData, int aSize,
      62             :                        bool* aGotFrame, DecodedData& aResults);
      63             :   void OutputDelayedFrames();
      64             : 
      65             :   /**
      66             :    * This method allocates a buffer for FFmpeg's decoder, wrapped in an Image.
      67             :    * Currently it only supports Planar YUV420, which appears to be the only
      68             :    * non-hardware accelerated image format that FFmpeg's H264 decoder is
      69             :    * capable of outputting.
      70             :    */
      71             :   int AllocateYUV420PVideoBuffer(AVCodecContext* aCodecContext,
      72             :                                  AVFrame* aFrame);
      73             : 
      74             :   RefPtr<KnowsCompositor> mImageAllocator;
      75             :   RefPtr<ImageContainer> mImageContainer;
      76             :   VideoInfo mInfo;
      77             : 
      78             :   // Parser used for VP8 and VP9 decoding.
      79             :   AVCodecParserContext* mCodecParser;
      80             : 
      81             :   class PtsCorrectionContext
      82             :   {
      83             :   public:
      84             :     PtsCorrectionContext();
      85             :     int64_t GuessCorrectPts(int64_t aPts, int64_t aDts);
      86             :     void Reset();
      87             :     int64_t LastDts() const { return mLastDts; }
      88             : 
      89             :   private:
      90             :     int64_t mNumFaultyPts; /// Number of incorrect PTS values so far
      91             :     int64_t mNumFaultyDts; /// Number of incorrect DTS values so far
      92             :     int64_t mLastPts;      /// PTS of the last frame
      93             :     int64_t mLastDts;      /// DTS of the last frame
      94             :   };
      95             : 
      96             :   PtsCorrectionContext mPtsContext;
      97             :   int64_t mLastInputDts;
      98             : 
      99             :   DurationMap mDurationMap;
     100             :   const bool mLowLatency;
     101             : };
     102             : 
     103             : } // namespace mozilla
     104             : 
     105             : #endif // __FFmpegVideoDecoder_h__

Generated by: LCOV version 1.13