OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 * | 9 * |
10 */ | 10 */ |
11 | 11 |
12 #ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_VP9_IMPL_H_ | 12 #ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_VP9_IMPL_H_ |
13 #define WEBRTC_MODULES_VIDEO_CODING_CODECS_VP9_IMPL_H_ | 13 #define WEBRTC_MODULES_VIDEO_CODING_CODECS_VP9_IMPL_H_ |
14 | 14 |
15 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h" | 15 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h" |
16 #include "webrtc/modules/video_coding/codecs/vp9/vp9_frame_buffer_pool.h" | 16 #include "webrtc/modules/video_coding/codecs/vp9/vp9_frame_buffer_pool.h" |
17 | 17 |
| 18 #include "vpx/svc_context.h" |
18 #include "vpx/vpx_decoder.h" | 19 #include "vpx/vpx_decoder.h" |
19 #include "vpx/vpx_encoder.h" | 20 #include "vpx/vpx_encoder.h" |
20 | 21 |
21 namespace webrtc { | 22 namespace webrtc { |
22 | 23 |
23 class VP9EncoderImpl : public VP9Encoder { | 24 class VP9EncoderImpl : public VP9Encoder { |
24 public: | 25 public: |
25 VP9EncoderImpl(); | 26 VP9EncoderImpl(); |
26 | 27 |
27 virtual ~VP9EncoderImpl(); | 28 virtual ~VP9EncoderImpl(); |
(...skipping 20 matching lines...) Expand all Loading... |
48 // Determine number of encoder threads to use. | 49 // Determine number of encoder threads to use. |
49 int NumberOfThreads(int width, int height, int number_of_cores); | 50 int NumberOfThreads(int width, int height, int number_of_cores); |
50 | 51 |
51 // Call encoder initialize function and set control settings. | 52 // Call encoder initialize function and set control settings. |
52 int InitAndSetControlSettings(const VideoCodec* inst); | 53 int InitAndSetControlSettings(const VideoCodec* inst); |
53 | 54 |
54 void PopulateCodecSpecific(CodecSpecificInfo* codec_specific, | 55 void PopulateCodecSpecific(CodecSpecificInfo* codec_specific, |
55 const vpx_codec_cx_pkt& pkt, | 56 const vpx_codec_cx_pkt& pkt, |
56 uint32_t timestamp); | 57 uint32_t timestamp); |
57 | 58 |
58 int GetEncodedPartitions(const VideoFrame& input_image); | 59 bool SetSvcRates(); |
| 60 |
| 61 virtual int GetEncodedLayerFrame(const vpx_codec_cx_pkt* pkt); |
| 62 |
| 63 // Callback function for outputting packets per spatial layer. |
| 64 static void EncoderOutputCodedPacketCallback(vpx_codec_cx_pkt* pkt, |
| 65 void* user_data); |
59 | 66 |
60 // Determine maximum target for Intra frames | 67 // Determine maximum target for Intra frames |
61 // | 68 // |
62 // Input: | 69 // Input: |
63 // - optimal_buffer_size : Optimal buffer size | 70 // - optimal_buffer_size : Optimal buffer size |
64 // Return Value : Max target size for Intra frames represented as | 71 // Return Value : Max target size for Intra frames represented as |
65 // percentage of the per frame bandwidth | 72 // percentage of the per frame bandwidth |
66 uint32_t MaxIntraTarget(uint32_t optimal_buffer_size); | 73 uint32_t MaxIntraTarget(uint32_t optimal_buffer_size); |
67 | 74 |
68 EncodedImage encoded_image_; | 75 EncodedImage encoded_image_; |
69 EncodedImageCallback* encoded_complete_callback_; | 76 EncodedImageCallback* encoded_complete_callback_; |
70 VideoCodec codec_; | 77 VideoCodec codec_; |
71 bool inited_; | 78 bool inited_; |
72 int64_t timestamp_; | 79 int64_t timestamp_; |
73 uint16_t picture_id_; | 80 uint16_t picture_id_; |
74 int cpu_speed_; | 81 int cpu_speed_; |
75 uint32_t rc_max_intra_target_; | 82 uint32_t rc_max_intra_target_; |
76 vpx_codec_ctx_t* encoder_; | 83 vpx_codec_ctx_t* encoder_; |
77 vpx_codec_enc_cfg_t* config_; | 84 vpx_codec_enc_cfg_t* config_; |
78 vpx_image_t* raw_; | 85 vpx_image_t* raw_; |
| 86 SvcInternal_t svc_internal_; |
| 87 const VideoFrame* input_image_; |
| 88 GofInfoVP9 gof_; // Contains each frame's temporal information for |
| 89 // non-flexible mode. |
| 90 uint8_t tl0_pic_idx_; // Only used in non-flexible mode. |
| 91 size_t gof_idx_; // Only used in non-flexible mode. |
| 92 uint8_t num_temporal_layers_; |
| 93 uint8_t num_spatial_layers_; |
79 }; | 94 }; |
80 | 95 |
81 | 96 |
82 class VP9DecoderImpl : public VP9Decoder { | 97 class VP9DecoderImpl : public VP9Decoder { |
83 public: | 98 public: |
84 VP9DecoderImpl(); | 99 VP9DecoderImpl(); |
85 | 100 |
86 virtual ~VP9DecoderImpl(); | 101 virtual ~VP9DecoderImpl(); |
87 | 102 |
88 int InitDecode(const VideoCodec* inst, int number_of_cores) override; | 103 int InitDecode(const VideoCodec* inst, int number_of_cores) override; |
(...skipping 17 matching lines...) Expand all Loading... |
106 Vp9FrameBufferPool frame_buffer_pool_; | 121 Vp9FrameBufferPool frame_buffer_pool_; |
107 DecodedImageCallback* decode_complete_callback_; | 122 DecodedImageCallback* decode_complete_callback_; |
108 bool inited_; | 123 bool inited_; |
109 vpx_codec_ctx_t* decoder_; | 124 vpx_codec_ctx_t* decoder_; |
110 VideoCodec codec_; | 125 VideoCodec codec_; |
111 bool key_frame_required_; | 126 bool key_frame_required_; |
112 }; | 127 }; |
113 } // namespace webrtc | 128 } // namespace webrtc |
114 | 129 |
115 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP9_IMPL_H_ | 130 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP9_IMPL_H_ |
OLD | NEW |