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

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

Issue 2997283002: VideoProcessorIntegrationTest: make it runnable on a task queue. (Closed)
Patch Set: Rebase. Created 3 years, 3 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 <map>
14 #include <memory> 15 #include <memory>
15 #include <string> 16 #include <string>
16 #include <vector> 17 #include <vector>
17 18
18 #include "webrtc/api/video/video_frame.h" 19 #include "webrtc/api/video/video_frame.h"
19 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" 20 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
20 #include "webrtc/modules/video_coding/codecs/test/packet_manipulator.h" 21 #include "webrtc/modules/video_coding/codecs/test/packet_manipulator.h"
21 #include "webrtc/modules/video_coding/codecs/test/stats.h" 22 #include "webrtc/modules/video_coding/codecs/test/stats.h"
22 #include "webrtc/modules/video_coding/include/video_codec_interface.h" 23 #include "webrtc/modules/video_coding/include/video_codec_interface.h"
23 #include "webrtc/modules/video_coding/utility/ivf_file_writer.h" 24 #include "webrtc/modules/video_coding/utility/ivf_file_writer.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 // Tears down callbacks and releases the encoder and decoder. 153 // Tears down callbacks and releases the encoder and decoder.
153 void Release(); 154 void Release();
154 155
155 // Processes a single frame. The frames must be processed in order, and the 156 // Processes a single frame. The frames must be processed in order, and the
156 // VideoProcessor must be initialized first. 157 // VideoProcessor must be initialized first.
157 void ProcessFrame(int frame_number); 158 void ProcessFrame(int frame_number);
158 159
159 // Updates the encoder with target rates. Must be called at least once. 160 // Updates the encoder with target rates. Must be called at least once.
160 void SetRates(int bitrate_kbps, int framerate_fps); 161 void SetRates(int bitrate_kbps, int framerate_fps);
161 162
162
163 // TODO(brandtr): Get rid of these functions by moving the corresponding QP 163 // TODO(brandtr): Get rid of these functions by moving the corresponding QP
164 // fields to the Stats object. 164 // fields to the Stats object.
165 int GetQpFromEncoder(int frame_number) const; 165 int GetQpFromEncoder(int frame_number) const;
166 int GetQpFromBitstream(int frame_number) const; 166 int GetQpFromBitstream(int frame_number) const;
167 167
168 // Returns the number of dropped frames.
169 std::vector<int> NumberDroppedFramesPerRateUpdate() const;
168 170
169 // Return the number of dropped frames. 171 // Returns the number of spatial resizes.
170 int NumberDroppedFrames(); 172 std::vector<int> NumberSpatialResizesPerRateUpdate() const;
171 173
172 // Return the number of spatial resizes. 174 int LastDecodedFrameNumber() const;
173 int NumberSpatialResizes();
174 175
175 private: 176 private:
176 // Container that holds per-frame information that needs to be stored between 177 // Container that holds per-frame information that needs to be stored between
177 // calls to Encode and Decode, as well as the corresponding callbacks. It is 178 // calls to Encode and Decode, as well as the corresponding callbacks. It is
178 // not directly used for statistics -- for that, test::FrameStatistic is used. 179 // not directly used for statistics -- for that, test::FrameStatistic is used.
179 // TODO(brandtr): Get rid of this struct and use the Stats class instead. 180 // TODO(brandtr): Get rid of this struct and use the Stats class instead.
180 struct FrameInfo { 181 struct FrameInfo {
181 int64_t encode_start_ns = 0; 182 int64_t encode_start_ns = 0;
182 int64_t decode_start_ns = 0; 183 int64_t decode_start_ns = 0;
183 int qp_encoder = 0; 184 int qp_encoder = 0;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 rtc::TaskQueue* const task_queue_; 278 rtc::TaskQueue* const task_queue_;
278 }; 279 };
279 280
280 // Invoked by the callback adapter when a frame has completed encoding. 281 // Invoked by the callback adapter when a frame has completed encoding.
281 void FrameEncoded(webrtc::VideoCodecType codec, 282 void FrameEncoded(webrtc::VideoCodecType codec,
282 const webrtc::EncodedImage& encodedImage); 283 const webrtc::EncodedImage& encodedImage);
283 284
284 // Invoked by the callback adapter when a frame has completed decoding. 285 // Invoked by the callback adapter when a frame has completed decoding.
285 void FrameDecoded(const webrtc::VideoFrame& image); 286 void FrameDecoded(const webrtc::VideoFrame& image);
286 287
287 // Use the frame number as the basis for timestamp to identify frames. Let the
288 // first timestamp be non-zero, to not make the IvfFileWriter believe that we
289 // want to use capture timestamps in the IVF files.
290 uint32_t FrameNumberToTimestamp(int frame_number) const;
291 int TimestampToFrameNumber(uint32_t timestamp) const;
292
293 bool initialized_ GUARDED_BY(sequence_checker_); 288 bool initialized_ GUARDED_BY(sequence_checker_);
294
295 TestConfig config_ GUARDED_BY(sequence_checker_); 289 TestConfig config_ GUARDED_BY(sequence_checker_);
296 290
297 webrtc::VideoEncoder* const encoder_; 291 webrtc::VideoEncoder* const encoder_;
298 webrtc::VideoDecoder* const decoder_; 292 webrtc::VideoDecoder* const decoder_;
299 const std::unique_ptr<VideoBitrateAllocator> bitrate_allocator_; 293 const std::unique_ptr<VideoBitrateAllocator> bitrate_allocator_;
300 294
301 // Adapters for the codec callbacks. 295 // Adapters for the codec callbacks.
302 VideoProcessorEncodeCompleteCallback encode_callback_; 296 VideoProcessorEncodeCompleteCallback encode_callback_;
303 VideoProcessorDecodeCompleteCallback decode_callback_; 297 VideoProcessorDecodeCompleteCallback decode_callback_;
304 298
(...skipping 12 matching lines...) Expand all
317 IvfFileWriter* const encoded_frame_writer_; 311 IvfFileWriter* const encoded_frame_writer_;
318 FrameWriter* const decoded_frame_writer_; 312 FrameWriter* const decoded_frame_writer_;
319 313
320 // Frame metadata for all frames that have been added through a call to 314 // Frame metadata for all frames that have been added through a call to
321 // ProcessFrames(). We need to store this metadata over the course of the 315 // ProcessFrames(). We need to store this metadata over the course of the
322 // test run, to support pipelining HW codecs. 316 // test run, to support pipelining HW codecs.
323 std::vector<FrameInfo> frame_infos_ GUARDED_BY(sequence_checker_); 317 std::vector<FrameInfo> frame_infos_ GUARDED_BY(sequence_checker_);
324 int last_encoded_frame_num_ GUARDED_BY(sequence_checker_); 318 int last_encoded_frame_num_ GUARDED_BY(sequence_checker_);
325 int last_decoded_frame_num_ GUARDED_BY(sequence_checker_); 319 int last_decoded_frame_num_ GUARDED_BY(sequence_checker_);
326 320
321 // Store an RTP timestamp -> frame number map, since the timestamps are
322 // based off of the frame rate, which can change mid-test.
323 std::map<uint32_t, int> rtp_timestamp_to_frame_num_
324 GUARDED_BY(sequence_checker_);
325
327 // Keep track of if we have excluded the first key frame from packet loss. 326 // Keep track of if we have excluded the first key frame from packet loss.
328 bool first_key_frame_has_been_excluded_ GUARDED_BY(sequence_checker_); 327 bool first_key_frame_has_been_excluded_ GUARDED_BY(sequence_checker_);
329 328
330 // Keep track of the last successfully decoded frame, since we write that 329 // Keep track of the last successfully decoded frame, since we write that
331 // frame to disk when decoding fails. 330 // frame to disk when decoding fails.
332 rtc::Buffer last_decoded_frame_buffer_ GUARDED_BY(sequence_checker_); 331 rtc::Buffer last_decoded_frame_buffer_ GUARDED_BY(sequence_checker_);
333 332
334 // Statistics. 333 // Statistics.
335 Stats* stats_; 334 Stats* stats_;
336 int num_dropped_frames_ GUARDED_BY(sequence_checker_); 335 std::vector<int> num_dropped_frames_ GUARDED_BY(sequence_checker_);
337 int num_spatial_resizes_ GUARDED_BY(sequence_checker_); 336 std::vector<int> num_spatial_resizes_ GUARDED_BY(sequence_checker_);
337 int rate_update_index_ GUARDED_BY(sequence_checker_);
338 338
339 rtc::SequencedTaskChecker sequence_checker_; 339 rtc::SequencedTaskChecker sequence_checker_;
340 340
341 RTC_DISALLOW_COPY_AND_ASSIGN(VideoProcessor); 341 RTC_DISALLOW_COPY_AND_ASSIGN(VideoProcessor);
342 }; 342 };
343 343
344 } // namespace test 344 } // namespace test
345 } // namespace webrtc 345 } // namespace webrtc
346 346
347 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_H_ 347 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698