tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

libvpx_vp8_decoder.h (2787B)


      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 <cstdint>
     15 #include <memory>
     16 #include <optional>
     17 
     18 #include "api/environment/environment.h"
     19 #include "api/video/color_space.h"
     20 #include "api/video/encoded_image.h"
     21 #include "api/video_codecs/video_decoder.h"
     22 #include "common_video/include/video_frame_buffer_pool.h"
     23 #include "third_party/libvpx/source/libvpx/vpx/vpx_decoder.h"
     24 #include "third_party/libvpx/source/libvpx/vpx/vpx_image.h"
     25 
     26 namespace webrtc {
     27 
     28 class LibvpxVp8Decoder : public VideoDecoder {
     29 public:
     30  explicit LibvpxVp8Decoder(const Environment& env);
     31  ~LibvpxVp8Decoder() override;
     32 
     33  bool Configure(const Settings& settings) override;
     34  int Decode(const EncodedImage& input_image,
     35             int64_t /*render_time_ms*/) override;
     36 
     37  // TODO(bugs.webrtc.org/15444): Remove once all subclasses have been migrated
     38  // to expecting calls Decode without a missing_frames param.
     39  int Decode(const EncodedImage& input_image,
     40             bool missing_frames,
     41             int64_t /*render_time_ms*/) override;
     42 
     43  int RegisterDecodeCompleteCallback(DecodedImageCallback* callback) override;
     44  int Release() override;
     45 
     46  DecoderInfo GetDecoderInfo() const override;
     47  const char* ImplementationName() const override;
     48 
     49  struct DeblockParams {
     50    DeblockParams() : max_level(6), degrade_qp(1), min_qp(0) {}
     51    DeblockParams(int max_level, int degrade_qp, int min_qp)
     52        : max_level(max_level), degrade_qp(degrade_qp), min_qp(min_qp) {}
     53    int max_level;   // Deblocking strength: [0, 16].
     54    int degrade_qp;  // If QP value is below, start lowering `max_level`.
     55    int min_qp;      // If QP value is below, turn off deblocking.
     56  };
     57 
     58 private:
     59  class QpSmoother;
     60 
     61  int ReturnFrame(const vpx_image_t* img,
     62                  uint32_t timeStamp,
     63                  int qp,
     64                  const ColorSpace* explicit_color_space);
     65  const bool use_postproc_;
     66 
     67  VideoFrameBufferPool buffer_pool_;
     68  DecodedImageCallback* decode_complete_callback_;
     69  bool inited_;
     70  vpx_codec_ctx_t* decoder_;
     71  int last_frame_width_;
     72  int last_frame_height_;
     73  bool key_frame_required_;
     74  const std::optional<DeblockParams> deblock_params_;
     75  const std::unique_ptr<QpSmoother> qp_smoother_;
     76 };
     77 
     78 }  // namespace webrtc
     79 
     80 #endif  // MODULES_VIDEO_CODING_CODECS_VP8_LIBVPX_VP8_DECODER_H_