Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(356)

Side by Side Diff: webrtc/modules/video_coding/codecs/test/videoprocessor.h

Issue 2711133002: Step #1: Support pipelining codecs in VideoProcessor. (Closed)
Patch Set: Rebase. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 // These (optional) file writers are used for persistently storing the output 294 // These (optional) file writers are used for persistently storing the output
269 // of the coding pipeline at different stages: pre encode (source), post 295 // of the coding pipeline at different stages: pre encode (source), post
270 // encode (encoded), and post decode (decoded). The purpose is to give the 296 // encode (encoded), and post decode (decoded). The purpose is to give the
271 // experimenter an option to subjectively evaluate the quality of the 297 // experimenter an option to subjectively evaluate the quality of the
272 // encoding, given the test settings. Each frame writer is enabled by being 298 // encoding, given the test settings. Each frame writer is enabled by being
273 // non-null. 299 // non-null.
274 FrameWriter* const source_frame_writer_; 300 FrameWriter* const source_frame_writer_;
275 IvfFileWriter* const encoded_frame_writer_; 301 IvfFileWriter* const encoded_frame_writer_;
276 FrameWriter* const decoded_frame_writer_; 302 FrameWriter* const decoded_frame_writer_;
277 303
278 // Keep track of the last successful frame, since we need to write that 304 bool initialized_;
279 // when decoding fails. 305
280 std::unique_ptr<uint8_t[]> last_successful_frame_buffer_; 306 // Frame metadata for all frames that have been added through a call to
281 // To keep track of if we have excluded the first key frame from packet loss. 307 // ProcessFrames(). We need to store this metadata over the course of the
308 // test run, to support pipelining HW codecs.
309 std::vector<FrameInfo> frame_infos_;
310 int last_encoded_frame_num_;
311 int last_decoded_frame_num_;
312
313 // Keep track of if we have excluded the first key frame from packet loss.
282 bool first_key_frame_has_been_excluded_; 314 bool first_key_frame_has_been_excluded_;
283 // To tell the decoder previous frame have been dropped due to packet loss. 315
284 bool last_frame_missing_; 316 // Keep track of the last successfully decoded frame, since we write that
285 // If Init() has executed successfully. 317 // frame to disk when decoding fails.
286 bool initialized_; 318 rtc::Buffer last_decoded_frame_buffer_;
287 size_t encoded_frame_size_;
288 FrameType encoded_frame_type_;
289 int prev_time_stamp_;
290 int last_encoder_frame_width_;
291 int last_encoder_frame_height_;
292 319
293 // Statistics. 320 // Statistics.
294 Stats* stats_; 321 Stats* stats_;
295 int num_dropped_frames_; 322 int num_dropped_frames_;
296 int num_spatial_resizes_; 323 int num_spatial_resizes_;
297 double bit_rate_factor_; // Multiply frame length with this to get bit rate. 324 double bit_rate_factor_; // Multiply frame length with this to get bit rate.
298 int64_t encode_start_ns_;
299 int64_t decode_start_ns_;
300 }; 325 };
301 326
302 } // namespace test 327 } // namespace test
303 } // namespace webrtc 328 } // namespace webrtc
304 329
305 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_H_ 330 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698