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

Side by Side Diff: modules/video_coding/codecs/test/videoprocessor_integrationtest.h

Issue 3009423002: VideoProcessorIntegrationTest: Group member variables into two structs containing target/actual rate (Closed)
Patch Set: rebase Created 3 years, 2 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
« no previous file with comments | « no previous file | modules/video_coding/codecs/test/videoprocessor_integrationtest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2017 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 13 matching lines...) Expand all
24 #include "modules/video_coding/utility/ivf_file_writer.h" 24 #include "modules/video_coding/utility/ivf_file_writer.h"
25 #include "test/gtest.h" 25 #include "test/gtest.h"
26 #include "test/testsupport/frame_reader.h" 26 #include "test/testsupport/frame_reader.h"
27 #include "test/testsupport/frame_writer.h" 27 #include "test/testsupport/frame_writer.h"
28 #include "test/testsupport/packet_reader.h" 28 #include "test/testsupport/packet_reader.h"
29 29
30 namespace webrtc { 30 namespace webrtc {
31 namespace test { 31 namespace test {
32 32
33 // The sequence of bit rate and frame rate changes for the encoder, the frame 33 // The sequence of bit rate and frame rate changes for the encoder, the frame
34 // number where the changes are made, and the total number of frames for the 34 // number where the changes are made, and the total number of frames to process.
35 // test.
36 struct RateProfile { 35 struct RateProfile {
37 static const int kMaxNumRateUpdates = 3; 36 static const int kMaxNumRateUpdates = 3;
38 37
39 int target_bit_rate[kMaxNumRateUpdates]; 38 int target_bit_rate[kMaxNumRateUpdates];
40 int input_frame_rate[kMaxNumRateUpdates]; 39 int input_frame_rate[kMaxNumRateUpdates];
41 int frame_index_rate_update[kMaxNumRateUpdates + 1]; 40 int frame_index_rate_update[kMaxNumRateUpdates + 1];
42 int num_frames; 41 int num_frames;
43 }; 42 };
44 43
45 // Thresholds for the rate control metrics. The rate mismatch thresholds are 44 // Thresholds for the rate control metrics. The thresholds are defined for each
46 // defined as percentages. |max_time_hit_target| is defined as number of frames, 45 // rate update sequence. |max_num_frames_to_hit_target| is defined as number of
47 // after a rate update is made to the encoder, for the encoder to reach within 46 // frames, after a rate update is made to the encoder, for the encoder to reach
48 // |kPercTargetvsActualMismatch| of new target rate. The thresholds are defined 47 // |kMaxBitrateMismatchPercent| of new target rate.
49 // for each rate update sequence.
50 struct RateControlThresholds { 48 struct RateControlThresholds {
51 int max_num_dropped_frames; 49 int max_num_dropped_frames;
52 int max_key_frame_size_mismatch; 50 int max_key_framesize_mismatch_percent;
53 int max_delta_frame_size_mismatch; 51 int max_delta_framesize_mismatch_percent;
54 int max_encoding_rate_mismatch; 52 int max_bitrate_mismatch_percent;
55 int max_time_hit_target; 53 int max_num_frames_to_hit_target;
56 int num_spatial_resizes; 54 int num_spatial_resizes;
57 int num_key_frames; 55 int num_key_frames;
58 }; 56 };
59 57
60 // Thresholds for the quality metrics. 58 // Thresholds for the quality metrics.
61 struct QualityThresholds { 59 struct QualityThresholds {
62 QualityThresholds(double min_avg_psnr, 60 QualityThresholds(double min_avg_psnr,
63 double min_min_psnr, 61 double min_min_psnr,
64 double min_avg_ssim, 62 double min_avg_ssim,
65 double min_min_ssim) 63 double min_min_ssim)
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 int height); 103 int height);
106 104
107 static void SetRateProfile(RateProfile* rate_profile, 105 static void SetRateProfile(RateProfile* rate_profile,
108 int rate_update_index, 106 int rate_update_index,
109 int bitrate_kbps, 107 int bitrate_kbps,
110 int framerate_fps, 108 int framerate_fps,
111 int frame_index_rate_update); 109 int frame_index_rate_update);
112 110
113 static void AddRateControlThresholds( 111 static void AddRateControlThresholds(
114 int max_num_dropped_frames, 112 int max_num_dropped_frames,
115 int max_key_frame_size_mismatch, 113 int max_key_framesize_mismatch_percent,
116 int max_delta_frame_size_mismatch, 114 int max_delta_framesize_mismatch_percent,
117 int max_encoding_rate_mismatch, 115 int max_bitrate_mismatch_percent,
118 int max_time_hit_target, 116 int max_num_frames_to_hit_target,
119 int num_spatial_resizes, 117 int num_spatial_resizes,
120 int num_key_frames, 118 int num_key_frames,
121 std::vector<RateControlThresholds>* rc_thresholds); 119 std::vector<RateControlThresholds>* rc_thresholds);
122 120
123 void ProcessFramesAndMaybeVerify( 121 void ProcessFramesAndMaybeVerify(
124 const RateProfile& rate_profile, 122 const RateProfile& rate_profile,
125 const std::vector<RateControlThresholds>* rc_thresholds, 123 const std::vector<RateControlThresholds>* rc_thresholds,
126 const QualityThresholds* quality_thresholds, 124 const QualityThresholds* quality_thresholds,
127 const VisualizationParams* visualization_params); 125 const VisualizationParams* visualization_params);
128 126
129 // Config. 127 // Config.
130 TestConfig config_; 128 TestConfig config_;
131 129
132 private: 130 private:
133 static const int kMaxNumTemporalLayers = 3; 131 static const int kMaxNumTemporalLayers = 3;
134 132
133 struct TestResults {
134 int KeyFrameSizeMismatchPercent() const {
135 if (num_key_frames == 0) {
136 return -1;
137 }
138 return 100 * sum_key_framesize_mismatch / num_key_frames;
139 }
140 int DeltaFrameSizeMismatchPercent(int i) const {
141 return 100 * sum_delta_framesize_mismatch_layer[i] / num_frames_layer[i];
142 }
143 int BitrateMismatchPercent(float target_kbps) const {
144 return 100 * fabs(kbps - target_kbps) / target_kbps;
145 }
146 int BitrateMismatchPercent(int i, float target_kbps_layer) const {
147 return 100 * fabs(kbps_layer[i] - target_kbps_layer) / target_kbps_layer;
148 }
149 int num_frames = 0;
150 int num_frames_layer[kMaxNumTemporalLayers] = {0};
151 int num_key_frames = 0;
152 int num_frames_to_hit_target = 0;
153 float sum_framesize_kbits = 0.0f;
154 float sum_framesize_kbits_layer[kMaxNumTemporalLayers] = {0};
155 float kbps = 0.0f;
156 float kbps_layer[kMaxNumTemporalLayers] = {0};
157 float sum_key_framesize_mismatch = 0.0f;
158 float sum_delta_framesize_mismatch_layer[kMaxNumTemporalLayers] = {0};
159 };
160
161 struct TargetRates {
162 int kbps;
163 int fps;
164 float kbps_layer[kMaxNumTemporalLayers];
165 float fps_layer[kMaxNumTemporalLayers];
166 float framesize_kbits_layer[kMaxNumTemporalLayers];
167 float key_framesize_kbits_initial;
168 float key_framesize_kbits;
169 };
170
135 void CreateEncoderAndDecoder(); 171 void CreateEncoderAndDecoder();
136 void DestroyEncoderAndDecoder(); 172 void DestroyEncoderAndDecoder();
137 void SetUpAndInitObjects(rtc::TaskQueue* task_queue, 173 void SetUpAndInitObjects(rtc::TaskQueue* task_queue,
138 const int initial_bitrate_kbps, 174 const int initial_bitrate_kbps,
139 const int initial_framerate_fps, 175 const int initial_framerate_fps,
140 const VisualizationParams* visualization_params); 176 const VisualizationParams* visualization_params);
141 void ReleaseAndCloseObjects(rtc::TaskQueue* task_queue); 177 void ReleaseAndCloseObjects(rtc::TaskQueue* task_queue);
178 int TemporalLayerIndexForFrame(int frame_number) const;
179
180 // Rate control metrics.
181 void ResetRateControlMetrics(int rate_update_index,
182 const RateProfile& rate_profile);
183 void SetRatesPerTemporalLayer();
142 void UpdateRateControlMetrics(int frame_number); 184 void UpdateRateControlMetrics(int frame_number);
143 void PrintAndMaybeVerifyRateControlMetrics( 185 void PrintRateControlMetrics(
186 int rate_update_index,
187 const std::vector<int>& num_dropped_frames,
188 const std::vector<int>& num_spatial_resizes) const;
189 void VerifyRateControlMetrics(
144 int rate_update_index, 190 int rate_update_index,
145 const std::vector<RateControlThresholds>* rc_thresholds, 191 const std::vector<RateControlThresholds>* rc_thresholds,
146 const std::vector<int>& num_dropped_frames, 192 const std::vector<int>& num_dropped_frames,
147 const std::vector<int>& num_resize_actions); 193 const std::vector<int>& num_spatial_resizes) const;
148 int TemporalLayerIndexForFrame(int frame_number) const;
149 void ResetRateControlMetrics(int rate_update_index,
150 const RateProfile& rate_profile);
151 194
152 // Codecs. 195 // Codecs.
153 std::unique_ptr<VideoEncoder> encoder_; 196 std::unique_ptr<VideoEncoder> encoder_;
154 std::unique_ptr<cricket::WebRtcVideoDecoderFactory> decoder_factory_; 197 std::unique_ptr<cricket::WebRtcVideoDecoderFactory> decoder_factory_;
155 VideoDecoder* decoder_; 198 VideoDecoder* decoder_;
156 199
157 // Helper objects. 200 // Helper objects.
158 std::unique_ptr<FrameReader> analysis_frame_reader_; 201 std::unique_ptr<FrameReader> analysis_frame_reader_;
159 std::unique_ptr<FrameWriter> analysis_frame_writer_; 202 std::unique_ptr<FrameWriter> analysis_frame_writer_;
160 std::unique_ptr<IvfFileWriter> encoded_frame_writer_; 203 std::unique_ptr<IvfFileWriter> encoded_frame_writer_;
161 std::unique_ptr<FrameWriter> decoded_frame_writer_; 204 std::unique_ptr<FrameWriter> decoded_frame_writer_;
162 PacketReader packet_reader_; 205 PacketReader packet_reader_;
163 std::unique_ptr<PacketManipulator> packet_manipulator_; 206 std::unique_ptr<PacketManipulator> packet_manipulator_;
164 Stats stats_; 207 Stats stats_;
165 std::unique_ptr<VideoProcessor> processor_; 208 std::unique_ptr<VideoProcessor> processor_;
166 209
167 // Quantities defined/updated for every encoder rate update. 210 // Quantities updated for every encoded frame.
168 int num_frames_per_update_[kMaxNumTemporalLayers]; 211 TestResults actual_;
169 float sum_frame_size_mismatch_[kMaxNumTemporalLayers]; 212
170 float sum_encoded_frame_size_[kMaxNumTemporalLayers]; 213 // Rates set for every encoder rate update.
171 float encoding_bitrate_[kMaxNumTemporalLayers]; 214 TargetRates target_;
172 float per_frame_bandwidth_[kMaxNumTemporalLayers];
173 float bitrate_layer_[kMaxNumTemporalLayers];
174 float framerate_layer_[kMaxNumTemporalLayers];
175 int num_frames_total_;
176 float sum_encoded_frame_size_total_;
177 float encoding_bitrate_total_;
178 float perc_encoding_rate_mismatch_;
179 int num_frames_to_hit_target_;
180 bool encoding_rate_within_target_;
181 int bitrate_kbps_;
182 int framerate_;
183 float target_size_key_frame_initial_;
184 float target_size_key_frame_;
185 float sum_key_frame_size_mismatch_;
186 int num_key_frames_;
187 }; 215 };
188 216
189 } // namespace test 217 } // namespace test
190 } // namespace webrtc 218 } // namespace webrtc
191 219
192 #endif // MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_INTEGRATIONTEST_H_ 220 #endif // MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_INTEGRATIONTEST_H_
OLDNEW
« no previous file with comments | « no previous file | modules/video_coding/codecs/test/videoprocessor_integrationtest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698