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

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

Issue 3011923002: Clean up Stats class used in VideoProcessor tests. (Closed)
Patch Set: Fix VS compile. 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
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 IvfFileWriter* encoded_frame_writer, 127 IvfFileWriter* encoded_frame_writer,
128 FrameWriter* decoded_frame_writer); 128 FrameWriter* decoded_frame_writer);
129 ~VideoProcessor(); 129 ~VideoProcessor();
130 130
131 // Sets up callbacks and initializes the encoder and decoder. 131 // Sets up callbacks and initializes the encoder and decoder.
132 void Init(); 132 void Init();
133 133
134 // Tears down callbacks and releases the encoder and decoder. 134 // Tears down callbacks and releases the encoder and decoder.
135 void Release(); 135 void Release();
136 136
137 // Processes a single frame. The frames must be processed in order, and the 137 // Reads a frame from the analysis frame reader and sends it to the encoder.
138 // VideoProcessor must be initialized first. 138 // When the encode callback is received, the encoded frame is sent to the
139 void ProcessFrame(int frame_number); 139 // decoder. The decoded frame is written to disk by the analysis frame writer.
140 // Objective video quality metrics can thus be calculated after the fact.
141 void ProcessFrame();
140 142
141 // Updates the encoder with target rates. Must be called at least once. 143 // Updates the encoder with target rates. Must be called at least once.
142 void SetRates(int bitrate_kbps, int framerate_fps); 144 void SetRates(int bitrate_kbps, int framerate_fps);
143 145
144 // Returns the number of dropped frames. 146 // Returns the number of dropped frames.
145 std::vector<int> NumberDroppedFramesPerRateUpdate() const; 147 std::vector<int> NumberDroppedFramesPerRateUpdate() const;
146 148
147 // Returns the number of spatial resizes. 149 // Returns the number of spatial resizes.
148 std::vector<int> NumberSpatialResizesPerRateUpdate() const; 150 std::vector<int> NumberSpatialResizesPerRateUpdate() const;
149 151
150 private: 152 private:
151 // Container that holds per-frame information that needs to be stored between
152 // calls to Encode and Decode, as well as the corresponding callbacks. It is
153 // not directly used for statistics -- for that, test::FrameStatistic is used.
154 // TODO(brandtr): Get rid of this struct and use the Stats class instead.
155 struct FrameInfo {
156 int64_t encode_start_ns = 0;
157 int64_t decode_start_ns = 0;
158 int decoded_width = 0;
159 int decoded_height = 0;
160 size_t manipulated_length = 0;
161 };
162
163 class VideoProcessorEncodeCompleteCallback 153 class VideoProcessorEncodeCompleteCallback
164 : public webrtc::EncodedImageCallback { 154 : public webrtc::EncodedImageCallback {
165 public: 155 public:
166 explicit VideoProcessorEncodeCompleteCallback( 156 explicit VideoProcessorEncodeCompleteCallback(
167 VideoProcessor* video_processor) 157 VideoProcessor* video_processor)
168 : video_processor_(video_processor), 158 : video_processor_(video_processor),
169 task_queue_(rtc::TaskQueue::Current()) {} 159 task_queue_(rtc::TaskQueue::Current()) {}
170 160
171 Result OnEncodedImage( 161 Result OnEncodedImage(
172 const webrtc::EncodedImage& encoded_image, 162 const webrtc::EncodedImage& encoded_image,
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 FrameReader* const analysis_frame_reader_; 266 FrameReader* const analysis_frame_reader_;
277 FrameWriter* const analysis_frame_writer_; 267 FrameWriter* const analysis_frame_writer_;
278 268
279 // These (optional) file writers are used to persistently store the encoded 269 // These (optional) file writers are used to persistently store the encoded
280 // and decoded bitstreams. The purpose is to give the experimenter an option 270 // and decoded bitstreams. The purpose is to give the experimenter an option
281 // to subjectively evaluate the quality of the processing. Each frame writer 271 // to subjectively evaluate the quality of the processing. Each frame writer
282 // is enabled by being non-null. 272 // is enabled by being non-null.
283 IvfFileWriter* const encoded_frame_writer_; 273 IvfFileWriter* const encoded_frame_writer_;
284 FrameWriter* const decoded_frame_writer_; 274 FrameWriter* const decoded_frame_writer_;
285 275
286 // Frame metadata for all frames that have been added through a call to 276 // Keep track of inputed/encoded/decoded frames, so we can detect frame drops.
287 // ProcessFrames(). We need to store this metadata over the course of the 277 int last_inputed_frame_num_ GUARDED_BY(sequence_checker_);
288 // test run, to support pipelining HW codecs.
289 std::vector<FrameInfo> frame_infos_ GUARDED_BY(sequence_checker_);
290 int last_encoded_frame_num_ GUARDED_BY(sequence_checker_); 278 int last_encoded_frame_num_ GUARDED_BY(sequence_checker_);
291 int last_decoded_frame_num_ GUARDED_BY(sequence_checker_); 279 int last_decoded_frame_num_ GUARDED_BY(sequence_checker_);
292 280
293 // Store an RTP timestamp -> frame number map, since the timestamps are 281 // Store an RTP timestamp -> frame number map, since the timestamps are
294 // based off of the frame rate, which can change mid-test. 282 // based off of the frame rate, which can change mid-test.
295 std::map<uint32_t, int> rtp_timestamp_to_frame_num_ 283 std::map<uint32_t, int> rtp_timestamp_to_frame_num_
296 GUARDED_BY(sequence_checker_); 284 GUARDED_BY(sequence_checker_);
297 285
298 // Keep track of if we have excluded the first key frame from packet loss. 286 // Keep track of if we have excluded the first key frame from packet loss.
299 bool first_key_frame_has_been_excluded_ GUARDED_BY(sequence_checker_); 287 bool first_key_frame_has_been_excluded_ GUARDED_BY(sequence_checker_);
(...skipping 10 matching lines...) Expand all
310 298
311 rtc::SequencedTaskChecker sequence_checker_; 299 rtc::SequencedTaskChecker sequence_checker_;
312 300
313 RTC_DISALLOW_COPY_AND_ASSIGN(VideoProcessor); 301 RTC_DISALLOW_COPY_AND_ASSIGN(VideoProcessor);
314 }; 302 };
315 303
316 } // namespace test 304 } // namespace test
317 } // namespace webrtc 305 } // namespace webrtc
318 306
319 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_H_ 307 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_H_
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/codecs/test/stats_unittest.cc ('k') | webrtc/modules/video_coding/codecs/test/videoprocessor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698