OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 #ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_H_ | 11 #ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_H_ |
12 #define WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_H_ | 12 #define WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_H_ |
13 | 13 |
14 #include <memory> | 14 #include <memory> |
15 #include <string> | 15 #include <string> |
16 #include <vector> | 16 #include <vector> |
17 | 17 |
18 #include "webrtc/api/video/video_frame.h" | 18 #include "webrtc/api/video/video_frame.h" |
19 #include "webrtc/base/buffer.h" | 19 #include "webrtc/base/buffer.h" |
20 #include "webrtc/base/checks.h" | 20 #include "webrtc/base/checks.h" |
21 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" | 21 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" |
22 #include "webrtc/modules/video_coding/include/video_codec_interface.h" | 22 #include "webrtc/modules/video_coding/include/video_codec_interface.h" |
23 #include "webrtc/modules/video_coding/codecs/test/packet_manipulator.h" | 23 #include "webrtc/modules/video_coding/codecs/test/packet_manipulator.h" |
24 #include "webrtc/modules/video_coding/codecs/test/stats.h" | 24 #include "webrtc/modules/video_coding/codecs/test/stats.h" |
25 #include "webrtc/modules/video_coding/utility/ivf_file_writer.h" | 25 #include "webrtc/modules/video_coding/utility/ivf_file_writer.h" |
| 26 #include "webrtc/modules/video_coding/utility/vp8_header_parser.h" |
| 27 #include "webrtc/modules/video_coding/utility/vp9_uncompressed_header_parser.h" |
26 #include "webrtc/test/testsupport/frame_reader.h" | 28 #include "webrtc/test/testsupport/frame_reader.h" |
27 #include "webrtc/test/testsupport/frame_writer.h" | 29 #include "webrtc/test/testsupport/frame_writer.h" |
28 | 30 |
29 namespace webrtc { | 31 namespace webrtc { |
30 | 32 |
31 class VideoBitrateAllocator; | 33 class VideoBitrateAllocator; |
32 | 34 |
33 namespace test { | 35 namespace test { |
34 | 36 |
35 // Defines which frame types shall be excluded from packet loss and when. | 37 // Defines which frame types shall be excluded from packet loss and when. |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 // Updates the encoder with the target bit rate and the frame rate. | 148 // Updates the encoder with the target bit rate and the frame rate. |
147 virtual void SetRates(int bit_rate, int frame_rate) = 0; | 149 virtual void SetRates(int bit_rate, int frame_rate) = 0; |
148 | 150 |
149 // Return the size of the encoded frame in bytes. Dropped frames by the | 151 // Return the size of the encoded frame in bytes. Dropped frames by the |
150 // encoder are regarded as zero size. | 152 // encoder are regarded as zero size. |
151 virtual size_t EncodedFrameSize(int frame_number) = 0; | 153 virtual size_t EncodedFrameSize(int frame_number) = 0; |
152 | 154 |
153 // Return the encoded frame type (key or delta). | 155 // Return the encoded frame type (key or delta). |
154 virtual FrameType EncodedFrameType(int frame_number) = 0; | 156 virtual FrameType EncodedFrameType(int frame_number) = 0; |
155 | 157 |
| 158 // Return the qp used by encoder. |
| 159 virtual int GetQpFromEncoder(int frame_number) = 0; |
| 160 |
| 161 // Return the qp from the qp parser. |
| 162 virtual int GetQpFromBitstream(int frame_number) = 0; |
| 163 |
156 // Return the number of dropped frames. | 164 // Return the number of dropped frames. |
157 virtual int NumberDroppedFrames() = 0; | 165 virtual int NumberDroppedFrames() = 0; |
158 | 166 |
159 // Return the number of spatial resizes. | 167 // Return the number of spatial resizes. |
160 virtual int NumberSpatialResizes() = 0; | 168 virtual int NumberSpatialResizes() = 0; |
161 }; | 169 }; |
162 | 170 |
163 class VideoProcessorImpl : public VideoProcessor { | 171 class VideoProcessorImpl : public VideoProcessor { |
164 public: | 172 public: |
165 VideoProcessorImpl(webrtc::VideoEncoder* encoder, | 173 VideoProcessorImpl(webrtc::VideoEncoder* encoder, |
(...skipping 16 matching lines...) Expand all Loading... |
182 // not directly used for statistics -- for that, test::FrameStatistic is used. | 190 // not directly used for statistics -- for that, test::FrameStatistic is used. |
183 struct FrameInfo { | 191 struct FrameInfo { |
184 FrameInfo() | 192 FrameInfo() |
185 : timestamp(0), | 193 : timestamp(0), |
186 encode_start_ns(0), | 194 encode_start_ns(0), |
187 decode_start_ns(0), | 195 decode_start_ns(0), |
188 encoded_frame_size(0), | 196 encoded_frame_size(0), |
189 encoded_frame_type(kVideoFrameDelta), | 197 encoded_frame_type(kVideoFrameDelta), |
190 decoded_width(0), | 198 decoded_width(0), |
191 decoded_height(0), | 199 decoded_height(0), |
192 manipulated_length(0) {} | 200 manipulated_length(0), |
| 201 qp_encoder(0), |
| 202 qp_bitstream(0) {} |
193 | 203 |
194 uint32_t timestamp; | 204 uint32_t timestamp; |
195 int64_t encode_start_ns; | 205 int64_t encode_start_ns; |
196 int64_t decode_start_ns; | 206 int64_t decode_start_ns; |
197 size_t encoded_frame_size; | 207 size_t encoded_frame_size; |
198 FrameType encoded_frame_type; | 208 FrameType encoded_frame_type; |
199 int decoded_width; | 209 int decoded_width; |
200 int decoded_height; | 210 int decoded_height; |
201 size_t manipulated_length; | 211 size_t manipulated_length; |
| 212 int qp_encoder; |
| 213 int qp_bitstream; |
202 }; | 214 }; |
203 | 215 |
204 // Callback class required to implement according to the VideoEncoder API. | 216 // Callback class required to implement according to the VideoEncoder API. |
205 class VideoProcessorEncodeCompleteCallback | 217 class VideoProcessorEncodeCompleteCallback |
206 : public webrtc::EncodedImageCallback { | 218 : public webrtc::EncodedImageCallback { |
207 public: | 219 public: |
208 explicit VideoProcessorEncodeCompleteCallback(VideoProcessorImpl* vp) | 220 explicit VideoProcessorEncodeCompleteCallback(VideoProcessorImpl* vp) |
209 : video_processor_(vp) {} | 221 : video_processor_(vp) {} |
210 Result OnEncodedImage( | 222 Result OnEncodedImage( |
211 const webrtc::EncodedImage& encoded_image, | 223 const webrtc::EncodedImage& encoded_image, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 | 270 |
259 // Updates the encoder with the target bit rate and the frame rate. | 271 // Updates the encoder with the target bit rate and the frame rate. |
260 void SetRates(int bit_rate, int frame_rate) override; | 272 void SetRates(int bit_rate, int frame_rate) override; |
261 | 273 |
262 // Return the size of the encoded frame in bytes. | 274 // Return the size of the encoded frame in bytes. |
263 size_t EncodedFrameSize(int frame_number) override; | 275 size_t EncodedFrameSize(int frame_number) override; |
264 | 276 |
265 // Return the encoded frame type (key or delta). | 277 // Return the encoded frame type (key or delta). |
266 FrameType EncodedFrameType(int frame_number) override; | 278 FrameType EncodedFrameType(int frame_number) override; |
267 | 279 |
| 280 // Return the qp used by encoder. |
| 281 int GetQpFromEncoder(int frame_number) override; |
| 282 |
| 283 // Return the qp from the qp parser. |
| 284 int GetQpFromBitstream(int frame_number) override; |
| 285 |
268 // Return the number of dropped frames. | 286 // Return the number of dropped frames. |
269 int NumberDroppedFrames() override; | 287 int NumberDroppedFrames() override; |
270 | 288 |
271 // Return the number of spatial resizes. | 289 // Return the number of spatial resizes. |
272 int NumberSpatialResizes() override; | 290 int NumberSpatialResizes() override; |
273 | 291 |
274 webrtc::VideoEncoder* const encoder_; | 292 webrtc::VideoEncoder* const encoder_; |
275 webrtc::VideoDecoder* const decoder_; | 293 webrtc::VideoDecoder* const decoder_; |
276 const std::unique_ptr<VideoBitrateAllocator> bitrate_allocator_; | 294 const std::unique_ptr<VideoBitrateAllocator> bitrate_allocator_; |
277 | 295 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 // Statistics. | 338 // Statistics. |
321 Stats* stats_; | 339 Stats* stats_; |
322 int num_dropped_frames_; | 340 int num_dropped_frames_; |
323 int num_spatial_resizes_; | 341 int num_spatial_resizes_; |
324 }; | 342 }; |
325 | 343 |
326 } // namespace test | 344 } // namespace test |
327 } // namespace webrtc | 345 } // namespace webrtc |
328 | 346 |
329 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_H_ | 347 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_H_ |
OLD | NEW |