2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
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.
12 #ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_VP9_IMPL_H_
13 #define WEBRTC_MODULES_VIDEO_CODING_CODECS_VP9_IMPL_H_
15 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h"
17 // VPX forward declaration
18 typedef struct vpx_codec_ctx vpx_codec_ctx_t;
19 typedef struct vpx_codec_ctx vpx_dec_ctx_t;
20 typedef struct vpx_codec_enc_cfg vpx_codec_enc_cfg_t;
21 typedef struct vpx_image vpx_image_t;
22 typedef struct vpx_ref_frame vpx_ref_frame_t;
23 struct vpx_codec_cx_pkt;
27 class VP9EncoderImpl : public VP9Encoder {
31 virtual ~VP9EncoderImpl();
33 virtual int Release() OVERRIDE;
35 virtual int InitEncode(const VideoCodec* codec_settings,
37 uint32_t max_payload_size) OVERRIDE;
39 virtual int Encode(const I420VideoFrame& input_image,
40 const CodecSpecificInfo* codec_specific_info,
41 const std::vector<VideoFrameType>* frame_types) OVERRIDE;
43 virtual int RegisterEncodeCompleteCallback(EncodedImageCallback* callback)
46 virtual int SetChannelParameters(uint32_t packet_loss, int rtt) OVERRIDE;
48 virtual int SetRates(uint32_t new_bitrate_kbit, uint32_t frame_rate) OVERRIDE;
51 // Call encoder initialize function and set control settings.
52 int InitAndSetControlSettings(const VideoCodec* inst);
54 void PopulateCodecSpecific(CodecSpecificInfo* codec_specific,
55 const vpx_codec_cx_pkt& pkt,
58 int GetEncodedPartitions(const I420VideoFrame& input_image);
60 // Determine maximum target for Intra frames
63 // - optimal_buffer_size : Optimal buffer size
64 // Return Value : Max target size for Intra frames represented as
65 // percentage of the per frame bandwidth
66 uint32_t MaxIntraTarget(uint32_t optimal_buffer_size);
68 EncodedImage encoded_image_;
69 EncodedImageCallback* encoded_complete_callback_;
75 uint32_t rc_max_intra_target_;
76 vpx_codec_ctx_t* encoder_;
77 vpx_codec_enc_cfg_t* config_;
82 class VP9DecoderImpl : public VP9Decoder {
86 virtual ~VP9DecoderImpl();
88 virtual int InitDecode(const VideoCodec* inst, int number_of_cores) OVERRIDE;
90 virtual int Decode(const EncodedImage& input_image,
92 const RTPFragmentationHeader* fragmentation,
93 const CodecSpecificInfo* codec_specific_info,
94 int64_t /*render_time_ms*/) OVERRIDE;
96 virtual int RegisterDecodeCompleteCallback(DecodedImageCallback* callback)
99 virtual int Release() OVERRIDE;
101 virtual int Reset() OVERRIDE;
104 int ReturnFrame(const vpx_image_t* img, uint32_t timeStamp);
106 I420VideoFrame decoded_image_;
107 DecodedImageCallback* decode_complete_callback_;
109 vpx_dec_ctx_t* decoder_;
111 bool key_frame_required_;
113 } // namespace webrtc
115 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP9_IMPL_H_