• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2018 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 #ifndef MODULES_VIDEO_CODING_CODECS_VP8_LIBVPX_VP8_DECODER_H_
12 #define MODULES_VIDEO_CODING_CODECS_VP8_LIBVPX_VP8_DECODER_H_
13 
14 #include <memory>
15 
16 #include "absl/types/optional.h"
17 #include "api/video/encoded_image.h"
18 #include "api/video_codecs/video_decoder.h"
19 #include "common_video/include/i420_buffer_pool.h"
20 #include "modules/video_coding/codecs/vp8/include/vp8.h"
21 #include "modules/video_coding/include/video_codec_interface.h"
22 #include "vpx/vp8dx.h"
23 #include "vpx/vpx_decoder.h"
24 
25 namespace webrtc {
26 
27 class LibvpxVp8Decoder : public VideoDecoder {
28  public:
29   LibvpxVp8Decoder();
30   ~LibvpxVp8Decoder() override;
31 
32   int InitDecode(const VideoCodec* inst, int number_of_cores) override;
33 
34   int Decode(const EncodedImage& input_image,
35              bool missing_frames,
36              int64_t /*render_time_ms*/) override;
37 
38   int RegisterDecodeCompleteCallback(DecodedImageCallback* callback) override;
39   int Release() override;
40 
41   const char* ImplementationName() const override;
42 
43   struct DeblockParams {
44     int max_level = 6;   // Deblocking strength: [0, 16].
45     int degrade_qp = 1;  // If QP value is below, start lowering |max_level|.
46     int min_qp = 0;      // If QP value is below, turn off deblocking.
47   };
48 
49  private:
50   class QpSmoother;
51   int ReturnFrame(const vpx_image_t* img,
52                   uint32_t timeStamp,
53                   int qp,
54                   const webrtc::ColorSpace* explicit_color_space);
55   const bool use_postproc_;
56 
57   I420BufferPool buffer_pool_;
58   DecodedImageCallback* decode_complete_callback_;
59   bool inited_;
60   vpx_codec_ctx_t* decoder_;
61   int propagation_cnt_;
62   int last_frame_width_;
63   int last_frame_height_;
64   bool key_frame_required_;
65   const absl::optional<DeblockParams> deblock_params_;
66   const std::unique_ptr<QpSmoother> qp_smoother_;
67 };
68 
69 }  // namespace webrtc
70 
71 #endif  // MODULES_VIDEO_CODING_CODECS_VP8_LIBVPX_VP8_DECODER_H_
72