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 | 17 |
17 #include "webrtc/api/video/video_frame.h" | 18 #include "webrtc/api/video/video_frame.h" |
| 19 #include "webrtc/base/buffer.h" |
18 #include "webrtc/base/checks.h" | 20 #include "webrtc/base/checks.h" |
19 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" | 21 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" |
20 #include "webrtc/modules/video_coding/include/video_codec_interface.h" | 22 #include "webrtc/modules/video_coding/include/video_codec_interface.h" |
21 #include "webrtc/modules/video_coding/codecs/test/packet_manipulator.h" | 23 #include "webrtc/modules/video_coding/codecs/test/packet_manipulator.h" |
22 #include "webrtc/modules/video_coding/codecs/test/stats.h" | 24 #include "webrtc/modules/video_coding/codecs/test/stats.h" |
23 #include "webrtc/modules/video_coding/utility/ivf_file_writer.h" | 25 #include "webrtc/modules/video_coding/utility/ivf_file_writer.h" |
24 #include "webrtc/test/testsupport/frame_reader.h" | 26 #include "webrtc/test/testsupport/frame_reader.h" |
25 #include "webrtc/test/testsupport/frame_writer.h" | 27 #include "webrtc/test/testsupport/frame_writer.h" |
26 | 28 |
27 namespace webrtc { | 29 namespace webrtc { |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 const TestConfig& config, | 170 const TestConfig& config, |
169 Stats* stats, | 171 Stats* stats, |
170 FrameWriter* source_frame_writer, | 172 FrameWriter* source_frame_writer, |
171 IvfFileWriter* encoded_frame_writer, | 173 IvfFileWriter* encoded_frame_writer, |
172 FrameWriter* decoded_frame_writer); | 174 FrameWriter* decoded_frame_writer); |
173 virtual ~VideoProcessorImpl(); | 175 virtual ~VideoProcessorImpl(); |
174 bool Init() override; | 176 bool Init() override; |
175 bool ProcessFrame(int frame_number) override; | 177 bool ProcessFrame(int frame_number) override; |
176 | 178 |
177 private: | 179 private: |
| 180 // Container that holds per-frame information that needs to be stored between |
| 181 // calls to Encode and Decode, as well as the corresponding callbacks. It is |
| 182 // not directly used for statistics -- for that, test::FrameStatistic is used. |
| 183 struct FrameInfo { |
| 184 FrameInfo() |
| 185 : timestamp(0), |
| 186 encode_start_ns(0), |
| 187 decode_start_ns(0), |
| 188 encoded_frame_size(0), |
| 189 encoded_frame_type(kVideoFrameDelta), |
| 190 decoded_width(0), |
| 191 decoded_height(0), |
| 192 manipulated_length(0) {} |
| 193 |
| 194 uint32_t timestamp; |
| 195 int64_t encode_start_ns; |
| 196 int64_t decode_start_ns; |
| 197 size_t encoded_frame_size; |
| 198 FrameType encoded_frame_type; |
| 199 int decoded_width; |
| 200 int decoded_height; |
| 201 size_t manipulated_length; |
| 202 }; |
| 203 |
178 // Callback class required to implement according to the VideoEncoder API. | 204 // Callback class required to implement according to the VideoEncoder API. |
179 class VideoProcessorEncodeCompleteCallback | 205 class VideoProcessorEncodeCompleteCallback |
180 : public webrtc::EncodedImageCallback { | 206 : public webrtc::EncodedImageCallback { |
181 public: | 207 public: |
182 explicit VideoProcessorEncodeCompleteCallback(VideoProcessorImpl* vp) | 208 explicit VideoProcessorEncodeCompleteCallback(VideoProcessorImpl* vp) |
183 : video_processor_(vp) {} | 209 : video_processor_(vp) {} |
184 Result OnEncodedImage( | 210 Result OnEncodedImage( |
185 const webrtc::EncodedImage& encoded_image, | 211 const webrtc::EncodedImage& encoded_image, |
186 const webrtc::CodecSpecificInfo* codec_specific_info, | 212 const webrtc::CodecSpecificInfo* codec_specific_info, |
187 const webrtc::RTPFragmentationHeader* fragmentation) override { | 213 const webrtc::RTPFragmentationHeader* fragmentation) override { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 const std::unique_ptr<EncodedImageCallback> encode_callback_; | 279 const std::unique_ptr<EncodedImageCallback> encode_callback_; |
254 const std::unique_ptr<DecodedImageCallback> decode_callback_; | 280 const std::unique_ptr<DecodedImageCallback> decode_callback_; |
255 | 281 |
256 PacketManipulator* const packet_manipulator_; | 282 PacketManipulator* const packet_manipulator_; |
257 const TestConfig& config_; | 283 const TestConfig& config_; |
258 | 284 |
259 // These (mandatory) file manipulators are used for, e.g., objective PSNR and | 285 // These (mandatory) file manipulators are used for, e.g., objective PSNR and |
260 // SSIM calculations at the end of a test run. | 286 // SSIM calculations at the end of a test run. |
261 FrameReader* const analysis_frame_reader_; | 287 FrameReader* const analysis_frame_reader_; |
262 FrameWriter* const analysis_frame_writer_; | 288 FrameWriter* const analysis_frame_writer_; |
| 289 const int num_frames_; |
263 | 290 |
264 // These (optional) file writers are used for persistently storing the output | 291 // These (optional) file writers are used for persistently storing the output |
265 // of the coding pipeline at different stages: pre encode (source), post | 292 // of the coding pipeline at different stages: pre encode (source), post |
266 // encode (encoded), and post decode (decoded). The purpose is to give the | 293 // encode (encoded), and post decode (decoded). The purpose is to give the |
267 // experimenter an option to subjectively evaluate the quality of the | 294 // experimenter an option to subjectively evaluate the quality of the |
268 // encoding, given the test settings. Each frame writer is enabled by being | 295 // encoding, given the test settings. Each frame writer is enabled by being |
269 // non-null. | 296 // non-null. |
270 FrameWriter* const source_frame_writer_; | 297 FrameWriter* const source_frame_writer_; |
271 IvfFileWriter* const encoded_frame_writer_; | 298 IvfFileWriter* const encoded_frame_writer_; |
272 FrameWriter* const decoded_frame_writer_; | 299 FrameWriter* const decoded_frame_writer_; |
273 | 300 |
274 // Keep track of the last successful frame, since we need to write that | 301 bool initialized_; |
275 // when decoding fails. | 302 |
276 std::unique_ptr<uint8_t[]> last_successful_frame_buffer_; | 303 // Frame metadata for all frames that have been added through a call to |
277 // To keep track of if we have excluded the first key frame from packet loss. | 304 // ProcessFrames(). We need to store this metadata over the course of the |
| 305 // test run, to support pipelining HW codecs. |
| 306 std::vector<FrameInfo> frame_infos_; |
| 307 int last_encoded_frame_num_; |
| 308 int last_decoded_frame_num_; |
| 309 |
| 310 // Keep track of if we have excluded the first key frame from packet loss. |
278 bool first_key_frame_has_been_excluded_; | 311 bool first_key_frame_has_been_excluded_; |
279 // To tell the decoder previous frame have been dropped due to packet loss. | 312 |
280 bool last_frame_missing_; | 313 // Keep track of the last successfully decoded frame, since we write that |
281 // If Init() has executed successfully. | 314 // frame to disk when decoding fails. |
282 bool initialized_; | 315 rtc::Buffer last_decoded_frame_buffer_; |
283 size_t encoded_frame_size_; | |
284 FrameType encoded_frame_type_; | |
285 int prev_time_stamp_; | |
286 int last_encoder_frame_width_; | |
287 int last_encoder_frame_height_; | |
288 | 316 |
289 // Statistics. | 317 // Statistics. |
290 Stats* stats_; | 318 Stats* stats_; |
291 int num_dropped_frames_; | 319 int num_dropped_frames_; |
292 int num_spatial_resizes_; | 320 int num_spatial_resizes_; |
293 double bit_rate_factor_; // Multiply frame length with this to get bit rate. | 321 double bit_rate_factor_; // Multiply frame length with this to get bit rate. |
294 int64_t encode_start_ns_; | |
295 int64_t decode_start_ns_; | |
296 }; | 322 }; |
297 | 323 |
298 } // namespace test | 324 } // namespace test |
299 } // namespace webrtc | 325 } // namespace webrtc |
300 | 326 |
301 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_H_ | 327 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_H_ |
OLD | NEW |