xref: /aosp_15_r20/external/webrtc/modules/video_coding/codecs/vp9/libvpx_vp9_decoder.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright (c) 2020 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  *
10  */
11 
12 #ifndef MODULES_VIDEO_CODING_CODECS_VP9_LIBVPX_VP9_DECODER_H_
13 #define MODULES_VIDEO_CODING_CODECS_VP9_LIBVPX_VP9_DECODER_H_
14 
15 #ifdef RTC_ENABLE_VP9
16 
17 #include "api/video_codecs/video_decoder.h"
18 #include "modules/video_coding/codecs/vp9/include/vp9.h"
19 #include "modules/video_coding/codecs/vp9/vp9_frame_buffer_pool.h"
20 #include "vpx/vp8cx.h"
21 
22 namespace webrtc {
23 
24 class LibvpxVp9Decoder : public VP9Decoder {
25  public:
26   LibvpxVp9Decoder();
27   virtual ~LibvpxVp9Decoder();
28 
29   bool Configure(const Settings& settings) override;
30 
31   int Decode(const EncodedImage& input_image,
32              bool missing_frames,
33              int64_t /*render_time_ms*/) override;
34 
35   int RegisterDecodeCompleteCallback(DecodedImageCallback* callback) override;
36 
37   int Release() override;
38 
39   DecoderInfo GetDecoderInfo() const override;
40   const char* ImplementationName() const override;
41 
42  private:
43   int ReturnFrame(const vpx_image_t* img,
44                   uint32_t timestamp,
45                   int qp,
46                   const webrtc::ColorSpace* explicit_color_space);
47 
48   // Memory pool used to share buffers between libvpx and webrtc.
49   Vp9FrameBufferPool libvpx_buffer_pool_;
50   DecodedImageCallback* decode_complete_callback_;
51   bool inited_;
52   vpx_codec_ctx_t* decoder_;
53   bool key_frame_required_;
54   Settings current_settings_;
55 };
56 }  // namespace webrtc
57 
58 #endif  // RTC_ENABLE_VP9
59 
60 #endif  // MODULES_VIDEO_CODING_CODECS_VP9_LIBVPX_VP9_DECODER_H_
61