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

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

Powered by Google App Engine
This is Rietveld 408576698