/src/mozilla-central/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.h
Line | Count | Source (jump to first uncovered line) |
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>; |
24 | | DDLoggedTypeNameAndBase(FFmpegVideoDecoder<LIBAV_VER>, |
25 | | FFmpegDataDecoder<LIBAV_VER>); |
26 | | |
27 | | template<> |
28 | | class FFmpegVideoDecoder<LIBAV_VER> |
29 | | : public FFmpegDataDecoder<LIBAV_VER> |
30 | | , public DecoderDoctorLifeLogger<FFmpegVideoDecoder<LIBAV_VER>> |
31 | | { |
32 | | typedef mozilla::layers::Image Image; |
33 | | typedef mozilla::layers::ImageContainer ImageContainer; |
34 | | typedef mozilla::layers::KnowsCompositor KnowsCompositor; |
35 | | typedef SimpleMap<int64_t> DurationMap; |
36 | | |
37 | | public: |
38 | | FFmpegVideoDecoder(FFmpegLibWrapper* aLib, TaskQueue* aTaskQueue, |
39 | | const VideoInfo& aConfig, |
40 | | KnowsCompositor* aAllocator, |
41 | | ImageContainer* aImageContainer, |
42 | | bool aLowLatency); |
43 | | |
44 | | RefPtr<InitPromise> Init() override; |
45 | | void InitCodecContext() override; |
46 | | nsCString GetDescriptionName() const override |
47 | 0 | { |
48 | | #ifdef USING_MOZFFVPX |
49 | 0 | return NS_LITERAL_CSTRING("ffvpx video decoder"); |
50 | | #else |
51 | 0 | return NS_LITERAL_CSTRING("ffmpeg video decoder"); |
52 | | #endif |
53 | | } Unexecuted instantiation: mozilla::FFmpegVideoDecoder<46465650>::GetDescriptionName() const Unexecuted instantiation: mozilla::FFmpegVideoDecoder<53>::GetDescriptionName() const Unexecuted instantiation: mozilla::FFmpegVideoDecoder<54>::GetDescriptionName() const Unexecuted instantiation: mozilla::FFmpegVideoDecoder<55>::GetDescriptionName() const Unexecuted instantiation: mozilla::FFmpegVideoDecoder<57>::GetDescriptionName() const Unexecuted instantiation: mozilla::FFmpegVideoDecoder<58>::GetDescriptionName() const |
54 | | ConversionRequired NeedsConversion() const override |
55 | 0 | { |
56 | 0 | return ConversionRequired::kNeedAVCC; |
57 | 0 | } Unexecuted instantiation: mozilla::FFmpegVideoDecoder<46465650>::NeedsConversion() const Unexecuted instantiation: mozilla::FFmpegVideoDecoder<53>::NeedsConversion() const Unexecuted instantiation: mozilla::FFmpegVideoDecoder<54>::NeedsConversion() const Unexecuted instantiation: mozilla::FFmpegVideoDecoder<55>::NeedsConversion() const Unexecuted instantiation: mozilla::FFmpegVideoDecoder<57>::NeedsConversion() const Unexecuted instantiation: mozilla::FFmpegVideoDecoder<58>::NeedsConversion() const |
58 | | |
59 | | static AVCodecID GetCodecId(const nsACString& aMimeType); |
60 | | |
61 | | private: |
62 | | RefPtr<FlushPromise> ProcessFlush() override; |
63 | | MediaResult DoDecode(MediaRawData* aSample, |
64 | | uint8_t* aData, |
65 | | int aSize, |
66 | | bool* aGotFrame, |
67 | | DecodedData& aResults) override; |
68 | | void OutputDelayedFrames(); |
69 | | bool NeedParser() const override |
70 | 0 | { |
71 | 0 | return |
72 | | #if LIBAVCODEC_VERSION_MAJOR >= 55 |
73 | 0 | mCodecID == AV_CODEC_ID_VP9 || |
74 | | #endif |
75 | 0 | mCodecID == AV_CODEC_ID_VP8; |
76 | 0 | } Unexecuted instantiation: mozilla::FFmpegVideoDecoder<46465650>::NeedParser() const Unexecuted instantiation: mozilla::FFmpegVideoDecoder<53>::NeedParser() const Unexecuted instantiation: mozilla::FFmpegVideoDecoder<54>::NeedParser() const Unexecuted instantiation: mozilla::FFmpegVideoDecoder<55>::NeedParser() const Unexecuted instantiation: mozilla::FFmpegVideoDecoder<57>::NeedParser() const Unexecuted instantiation: mozilla::FFmpegVideoDecoder<58>::NeedParser() const |
77 | | |
78 | | /** |
79 | | * This method allocates a buffer for FFmpeg's decoder, wrapped in an Image. |
80 | | * Currently it only supports Planar YUV420, which appears to be the only |
81 | | * non-hardware accelerated image format that FFmpeg's H264 decoder is |
82 | | * capable of outputting. |
83 | | */ |
84 | | int AllocateYUV420PVideoBuffer(AVCodecContext* aCodecContext, |
85 | | AVFrame* aFrame); |
86 | | |
87 | | RefPtr<KnowsCompositor> mImageAllocator; |
88 | | RefPtr<ImageContainer> mImageContainer; |
89 | | VideoInfo mInfo; |
90 | | |
91 | | class PtsCorrectionContext |
92 | | { |
93 | | public: |
94 | | PtsCorrectionContext(); |
95 | | int64_t GuessCorrectPts(int64_t aPts, int64_t aDts); |
96 | | void Reset(); |
97 | 0 | int64_t LastDts() const { return mLastDts; } Unexecuted instantiation: mozilla::FFmpegVideoDecoder<46465650>::PtsCorrectionContext::LastDts() const Unexecuted instantiation: mozilla::FFmpegVideoDecoder<53>::PtsCorrectionContext::LastDts() const Unexecuted instantiation: mozilla::FFmpegVideoDecoder<54>::PtsCorrectionContext::LastDts() const Unexecuted instantiation: mozilla::FFmpegVideoDecoder<55>::PtsCorrectionContext::LastDts() const Unexecuted instantiation: mozilla::FFmpegVideoDecoder<57>::PtsCorrectionContext::LastDts() const Unexecuted instantiation: mozilla::FFmpegVideoDecoder<58>::PtsCorrectionContext::LastDts() const |
98 | | |
99 | | private: |
100 | | int64_t mNumFaultyPts; /// Number of incorrect PTS values so far |
101 | | int64_t mNumFaultyDts; /// Number of incorrect DTS values so far |
102 | | int64_t mLastPts; /// PTS of the last frame |
103 | | int64_t mLastDts; /// DTS of the last frame |
104 | | }; |
105 | | |
106 | | PtsCorrectionContext mPtsContext; |
107 | | |
108 | | DurationMap mDurationMap; |
109 | | const bool mLowLatency; |
110 | | }; |
111 | | |
112 | | } // namespace mozilla |
113 | | |
114 | | #endif // __FFmpegVideoDecoder_h__ |