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

Side by Side Diff: webrtc/tools/frame_analyzer/video_quality_analysis.cc

Issue 1362503003: Use suffixed {uint,int}{8,16,32,64}_t types. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: google::int32 Created 5 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 if (chars_read != 1 || feof(stats_file)) { 80 if (chars_read != 1 || feof(stats_file)) {
81 return false; 81 return false;
82 } 82 }
83 line[chars] = buf; 83 line[chars] = buf;
84 ++chars; 84 ++chars;
85 } 85 }
86 line[chars-1] = '\0'; // Strip the trailing \n and put end of string. 86 line[chars-1] = '\0'; // Strip the trailing \n and put end of string.
87 return true; 87 return true;
88 } 88 }
89 89
90 bool ExtractFrameFromYuvFile(const char* i420_file_name, int width, int height, 90 bool ExtractFrameFromYuvFile(const char* i420_file_name,
91 int frame_number, uint8* result_frame) { 91 int width,
92 int height,
93 int frame_number,
94 uint8_t* result_frame) {
92 int frame_size = GetI420FrameSize(width, height); 95 int frame_size = GetI420FrameSize(width, height);
93 int offset = frame_number * frame_size; // Calculate offset for the frame. 96 int offset = frame_number * frame_size; // Calculate offset for the frame.
94 bool errors = false; 97 bool errors = false;
95 98
96 FILE* input_file = fopen(i420_file_name, "rb"); 99 FILE* input_file = fopen(i420_file_name, "rb");
97 if (input_file == NULL) { 100 if (input_file == NULL) {
98 fprintf(stderr, "Couldn't open input file for reading: %s\n", 101 fprintf(stderr, "Couldn't open input file for reading: %s\n",
99 i420_file_name); 102 i420_file_name);
100 return false; 103 return false;
101 } 104 }
102 105
103 // Change stream pointer to new offset. 106 // Change stream pointer to new offset.
104 fseek(input_file, offset, SEEK_SET); 107 fseek(input_file, offset, SEEK_SET);
105 108
106 size_t bytes_read = fread(result_frame, 1, frame_size, input_file); 109 size_t bytes_read = fread(result_frame, 1, frame_size, input_file);
107 if (bytes_read != static_cast<size_t>(frame_size) && 110 if (bytes_read != static_cast<size_t>(frame_size) &&
108 ferror(input_file)) { 111 ferror(input_file)) {
109 fprintf(stdout, "Error while reading frame no %d from file %s\n", 112 fprintf(stdout, "Error while reading frame no %d from file %s\n",
110 frame_number, i420_file_name); 113 frame_number, i420_file_name);
111 errors = true; 114 errors = true;
112 } 115 }
113 fclose(input_file); 116 fclose(input_file);
114 return !errors; 117 return !errors;
115 } 118 }
116 119
117 bool ExtractFrameFromY4mFile(const char* y4m_file_name, int width, int height, 120 bool ExtractFrameFromY4mFile(const char* y4m_file_name,
118 int frame_number, uint8* result_frame) { 121 int width,
122 int height,
123 int frame_number,
124 uint8_t* result_frame) {
119 int frame_size = GetI420FrameSize(width, height); 125 int frame_size = GetI420FrameSize(width, height);
120 int frame_offset = frame_number * frame_size; 126 int frame_offset = frame_number * frame_size;
121 bool errors = false; 127 bool errors = false;
122 128
123 FILE* input_file = fopen(y4m_file_name, "rb"); 129 FILE* input_file = fopen(y4m_file_name, "rb");
124 if (input_file == NULL) { 130 if (input_file == NULL) {
125 fprintf(stderr, "Couldn't open input file for reading: %s\n", 131 fprintf(stderr, "Couldn't open input file for reading: %s\n",
126 y4m_file_name); 132 y4m_file_name);
127 return false; 133 return false;
128 } 134 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 fprintf(stdout, "Error while reading frame no %d from file %s\n", 166 fprintf(stdout, "Error while reading frame no %d from file %s\n",
161 frame_number, y4m_file_name); 167 frame_number, y4m_file_name);
162 errors = true; 168 errors = true;
163 } 169 }
164 170
165 fclose(input_file); 171 fclose(input_file);
166 return !errors; 172 return !errors;
167 } 173 }
168 174
169 double CalculateMetrics(VideoAnalysisMetricsType video_metrics_type, 175 double CalculateMetrics(VideoAnalysisMetricsType video_metrics_type,
170 const uint8* ref_frame, const uint8* test_frame, 176 const uint8_t* ref_frame,
171 int width, int height) { 177 const uint8_t* test_frame,
178 int width,
179 int height) {
172 if (!ref_frame || !test_frame) 180 if (!ref_frame || !test_frame)
173 return -1; 181 return -1;
174 else if (height < 0 || width < 0) 182 else if (height < 0 || width < 0)
175 return -1; 183 return -1;
176 int half_width = (width + 1) >> 1; 184 int half_width = (width + 1) >> 1;
177 int half_height = (height + 1) >> 1; 185 int half_height = (height + 1) >> 1;
178 const uint8* src_y_a = ref_frame; 186 const uint8_t* src_y_a = ref_frame;
179 const uint8* src_u_a = src_y_a + width * height; 187 const uint8_t* src_u_a = src_y_a + width * height;
180 const uint8* src_v_a = src_u_a + half_width * half_height; 188 const uint8_t* src_v_a = src_u_a + half_width * half_height;
181 const uint8* src_y_b = test_frame; 189 const uint8_t* src_y_b = test_frame;
182 const uint8* src_u_b = src_y_b + width * height; 190 const uint8_t* src_u_b = src_y_b + width * height;
183 const uint8* src_v_b = src_u_b + half_width * half_height; 191 const uint8_t* src_v_b = src_u_b + half_width * half_height;
184 192
185 int stride_y = width; 193 int stride_y = width;
186 int stride_uv = half_width; 194 int stride_uv = half_width;
187 195
188 double result = 0.0; 196 double result = 0.0;
189 197
190 switch (video_metrics_type) { 198 switch (video_metrics_type) {
191 case kPSNR: 199 case kPSNR:
192 // In the following: stride is determined by width. 200 // In the following: stride is determined by width.
193 result = libyuv::I420Psnr(src_y_a, width, src_u_a, half_width, 201 result = libyuv::I420Psnr(src_y_a, width, src_u_a, half_width,
(...skipping 26 matching lines...) Expand all
220 y4m_mode = true; 228 y4m_mode = true;
221 } 229 }
222 230
223 int size = GetI420FrameSize(width, height); 231 int size = GetI420FrameSize(width, height);
224 FILE* stats_file = fopen(stats_file_name, "r"); 232 FILE* stats_file = fopen(stats_file_name, "r");
225 233
226 // String buffer for the lines in the stats file. 234 // String buffer for the lines in the stats file.
227 char line[STATS_LINE_LENGTH]; 235 char line[STATS_LINE_LENGTH];
228 236
229 // Allocate buffers for test and reference frames. 237 // Allocate buffers for test and reference frames.
230 uint8* test_frame = new uint8[size]; 238 uint8_t* test_frame = new uint8_t[size];
231 uint8* reference_frame = new uint8[size]; 239 uint8_t* reference_frame = new uint8_t[size];
232 int previous_frame_number = -1; 240 int previous_frame_number = -1;
233 241
234 // While there are entries in the stats file. 242 // While there are entries in the stats file.
235 while (GetNextStatsLine(stats_file, line)) { 243 while (GetNextStatsLine(stats_file, line)) {
236 int extracted_test_frame = ExtractFrameSequenceNumber(line); 244 int extracted_test_frame = ExtractFrameSequenceNumber(line);
237 int decoded_frame_number = ExtractDecodedFrameNumber(line); 245 int decoded_frame_number = ExtractDecodedFrameNumber(line);
238 246
239 // If there was problem decoding the barcode in this frame or the frame has 247 // If there was problem decoding the barcode in this frame or the frame has
240 // been duplicated, continue. 248 // been duplicated, continue.
241 if (IsThereBarcodeError(line) || 249 if (IsThereBarcodeError(line) ||
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 for (iter = results->frames.begin(); iter != results->frames.end() - 1; 363 for (iter = results->frames.begin(); iter != results->frames.end() - 1;
356 ++iter) { 364 ++iter) {
357 fprintf(output, "%f,", iter->ssim_value); 365 fprintf(output, "%f,", iter->ssim_value);
358 } 366 }
359 fprintf(output, "%f] score\n", iter->ssim_value); 367 fprintf(output, "%f] score\n", iter->ssim_value);
360 } 368 }
361 } 369 }
362 370
363 } // namespace test 371 } // namespace test
364 } // namespace webrtc 372 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698