/src/mozilla-central/dom/media/platforms/agnostic/AOMDecoder.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 | | #if !defined(AOMDecoder_h_) |
7 | | #define AOMDecoder_h_ |
8 | | |
9 | | #include "PlatformDecoderModule.h" |
10 | | #include "mozilla/Span.h" |
11 | | |
12 | | #include <stdint.h> |
13 | | #include "aom/aom_decoder.h" |
14 | | |
15 | | namespace mozilla { |
16 | | |
17 | | DDLoggedTypeDeclNameAndBase(AOMDecoder, MediaDataDecoder); |
18 | | |
19 | | class AOMDecoder |
20 | | : public MediaDataDecoder |
21 | | , public DecoderDoctorLifeLogger<AOMDecoder> |
22 | | { |
23 | | public: |
24 | | explicit AOMDecoder(const CreateDecoderParams& aParams); |
25 | | |
26 | | RefPtr<InitPromise> Init() override; |
27 | | RefPtr<DecodePromise> Decode(MediaRawData* aSample) override; |
28 | | RefPtr<DecodePromise> Drain() override; |
29 | | RefPtr<FlushPromise> Flush() override; |
30 | | RefPtr<ShutdownPromise> Shutdown() override; |
31 | | nsCString GetDescriptionName() const override |
32 | 0 | { |
33 | 0 | return NS_LITERAL_CSTRING("av1 libaom video decoder"); |
34 | 0 | } |
35 | | |
36 | | // Return true if aMimeType is a one of the strings used |
37 | | // by our demuxers to identify AV1 streams. |
38 | | static bool IsAV1(const nsACString& aMimeType); |
39 | | |
40 | | // Return true if a sample is a keyframe. |
41 | | static bool IsKeyframe(Span<const uint8_t> aBuffer); |
42 | | |
43 | | // Return the frame dimensions for a sample. |
44 | | static gfx::IntSize GetFrameSize(Span<const uint8_t> aBuffer); |
45 | | |
46 | | private: |
47 | | ~AOMDecoder(); |
48 | | RefPtr<DecodePromise> ProcessDecode(MediaRawData* aSample); |
49 | | |
50 | | const RefPtr<layers::ImageContainer> mImageContainer; |
51 | | const RefPtr<TaskQueue> mTaskQueue; |
52 | | |
53 | | // AOM decoder state |
54 | | aom_codec_ctx_t mCodec; |
55 | | |
56 | | const VideoInfo& mInfo; |
57 | | }; |
58 | | |
59 | | } // namespace mozilla |
60 | | |
61 | | #endif // AOMDecoder_h_ |