| OLD | NEW |
| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 return -1; | 46 return -1; |
| 47 } | 47 } |
| 48 std::string frame = line.substr(0, space_position); | 48 std::string frame = line.substr(0, space_position); |
| 49 | 49 |
| 50 size_t underscore_position = frame.find('_'); | 50 size_t underscore_position = frame.find('_'); |
| 51 if (underscore_position == std::string::npos) { | 51 if (underscore_position == std::string::npos) { |
| 52 return -1; | 52 return -1; |
| 53 } | 53 } |
| 54 std::string frame_number = frame.substr(underscore_position + 1); | 54 std::string frame_number = frame.substr(underscore_position + 1); |
| 55 | 55 |
| 56 return strtol(frame_number.c_str(), NULL, 10); | 56 return strtol(frame_number.c_str(), nullptr, 10); |
| 57 } | 57 } |
| 58 | 58 |
| 59 int ExtractDecodedFrameNumber(std::string line) { | 59 int ExtractDecodedFrameNumber(std::string line) { |
| 60 size_t space_position = line.find(' '); | 60 size_t space_position = line.find(' '); |
| 61 if (space_position == std::string::npos) { | 61 if (space_position == std::string::npos) { |
| 62 return -1; | 62 return -1; |
| 63 } | 63 } |
| 64 std::string decoded_number = line.substr(space_position + 1); | 64 std::string decoded_number = line.substr(space_position + 1); |
| 65 | 65 |
| 66 return strtol(decoded_number.c_str(), NULL, 10); | 66 return strtol(decoded_number.c_str(), nullptr, 10); |
| 67 } | 67 } |
| 68 | 68 |
| 69 bool IsThereBarcodeError(std::string line) { | 69 bool IsThereBarcodeError(std::string line) { |
| 70 size_t barcode_error_position = line.find("Barcode error"); | 70 size_t barcode_error_position = line.find("Barcode error"); |
| 71 if (barcode_error_position != std::string::npos) { | 71 if (barcode_error_position != std::string::npos) { |
| 72 return true; | 72 return true; |
| 73 } | 73 } |
| 74 return false; | 74 return false; |
| 75 } | 75 } |
| 76 | 76 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 93 bool ExtractFrameFromYuvFile(const char* i420_file_name, | 93 bool ExtractFrameFromYuvFile(const char* i420_file_name, |
| 94 int width, | 94 int width, |
| 95 int height, | 95 int height, |
| 96 int frame_number, | 96 int frame_number, |
| 97 uint8_t* result_frame) { | 97 uint8_t* result_frame) { |
| 98 int frame_size = GetI420FrameSize(width, height); | 98 int frame_size = GetI420FrameSize(width, height); |
| 99 int offset = frame_number * frame_size; // Calculate offset for the frame. | 99 int offset = frame_number * frame_size; // Calculate offset for the frame. |
| 100 bool errors = false; | 100 bool errors = false; |
| 101 | 101 |
| 102 FILE* input_file = fopen(i420_file_name, "rb"); | 102 FILE* input_file = fopen(i420_file_name, "rb"); |
| 103 if (input_file == NULL) { | 103 if (input_file == nullptr) { |
| 104 fprintf(stderr, "Couldn't open input file for reading: %s\n", | 104 fprintf(stderr, "Couldn't open input file for reading: %s\n", |
| 105 i420_file_name); | 105 i420_file_name); |
| 106 return false; | 106 return false; |
| 107 } | 107 } |
| 108 | 108 |
| 109 // Change stream pointer to new offset. | 109 // Change stream pointer to new offset. |
| 110 fseek(input_file, offset, SEEK_SET); | 110 fseek(input_file, offset, SEEK_SET); |
| 111 | 111 |
| 112 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); |
| 113 if (bytes_read != static_cast<size_t>(frame_size) && | 113 if (bytes_read != static_cast<size_t>(frame_size) && |
| 114 ferror(input_file)) { | 114 ferror(input_file)) { |
| 115 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", |
| 116 frame_number, i420_file_name); | 116 frame_number, i420_file_name); |
| 117 errors = true; | 117 errors = true; |
| 118 } | 118 } |
| 119 fclose(input_file); | 119 fclose(input_file); |
| 120 return !errors; | 120 return !errors; |
| 121 } | 121 } |
| 122 | 122 |
| 123 bool ExtractFrameFromY4mFile(const char* y4m_file_name, | 123 bool ExtractFrameFromY4mFile(const char* y4m_file_name, |
| 124 int width, | 124 int width, |
| 125 int height, | 125 int height, |
| 126 int frame_number, | 126 int frame_number, |
| 127 uint8_t* result_frame) { | 127 uint8_t* result_frame) { |
| 128 int frame_size = GetI420FrameSize(width, height); | 128 int frame_size = GetI420FrameSize(width, height); |
| 129 int inital_offset = frame_number * (frame_size + Y4M_FRAME_HEADER_SIZE); | 129 int inital_offset = frame_number * (frame_size + Y4M_FRAME_HEADER_SIZE); |
| 130 int frame_offset = 0; | 130 int frame_offset = 0; |
| 131 | 131 |
| 132 FILE* input_file = fopen(y4m_file_name, "rb"); | 132 FILE* input_file = fopen(y4m_file_name, "rb"); |
| 133 if (input_file == NULL) { | 133 if (input_file == nullptr) { |
| 134 fprintf(stderr, "Couldn't open input file for reading: %s\n", | 134 fprintf(stderr, "Couldn't open input file for reading: %s\n", |
| 135 y4m_file_name); | 135 y4m_file_name); |
| 136 return false; | 136 return false; |
| 137 } | 137 } |
| 138 | 138 |
| 139 // YUV4MPEG2, a.k.a. Y4M File format has a file header and a frame header. The | 139 // YUV4MPEG2, a.k.a. Y4M File format has a file header and a frame header. The |
| 140 // file header has the aspect: "YUV4MPEG2 C420 W640 H360 Ip F30:1 A1:1". | 140 // file header has the aspect: "YUV4MPEG2 C420 W640 H360 Ip F30:1 A1:1". |
| 141 char frame_header[Y4M_FILE_HEADER_MAX_SIZE]; | 141 char frame_header[Y4M_FILE_HEADER_MAX_SIZE]; |
| 142 size_t bytes_read = | 142 size_t bytes_read = |
| 143 fread(frame_header, 1, Y4M_FILE_HEADER_MAX_SIZE - 1, input_file); | 143 fread(frame_header, 1, Y4M_FILE_HEADER_MAX_SIZE - 1, input_file); |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 return frame_cnt; | 350 return frame_cnt; |
| 351 } | 351 } |
| 352 } // namespace | 352 } // namespace |
| 353 | 353 |
| 354 void PrintMaxRepeatedAndSkippedFrames(FILE* output, | 354 void PrintMaxRepeatedAndSkippedFrames(FILE* output, |
| 355 const std::string& label, | 355 const std::string& label, |
| 356 const std::string& stats_file_ref_name, | 356 const std::string& stats_file_ref_name, |
| 357 const std::string& stats_file_test_name) { | 357 const std::string& stats_file_test_name) { |
| 358 FILE* stats_file_ref = fopen(stats_file_ref_name.c_str(), "r"); | 358 FILE* stats_file_ref = fopen(stats_file_ref_name.c_str(), "r"); |
| 359 FILE* stats_file_test = fopen(stats_file_test_name.c_str(), "r"); | 359 FILE* stats_file_test = fopen(stats_file_test_name.c_str(), "r"); |
| 360 if (stats_file_ref == NULL) { | 360 if (stats_file_ref == nullptr) { |
| 361 fprintf(stderr, "Couldn't open reference stats file for reading: %s\n", | 361 fprintf(stderr, "Couldn't open reference stats file for reading: %s\n", |
| 362 stats_file_ref_name.c_str()); | 362 stats_file_ref_name.c_str()); |
| 363 return; | 363 return; |
| 364 } | 364 } |
| 365 if (stats_file_test == NULL) { | 365 if (stats_file_test == nullptr) { |
| 366 fprintf(stderr, "Couldn't open test stats file for reading: %s\n", | 366 fprintf(stderr, "Couldn't open test stats file for reading: %s\n", |
| 367 stats_file_test_name.c_str()); | 367 stats_file_test_name.c_str()); |
| 368 fclose(stats_file_ref); | 368 fclose(stats_file_ref); |
| 369 return; | 369 return; |
| 370 } | 370 } |
| 371 | 371 |
| 372 int max_repeated_frames = 1; | 372 int max_repeated_frames = 1; |
| 373 int max_skipped_frames = 1; | 373 int max_skipped_frames = 1; |
| 374 | 374 |
| 375 std::vector<std::pair<int, int> > frame_cnt_ref = | 375 std::vector<std::pair<int, int> > frame_cnt_ref = |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 for (iter = results->frames.begin(); iter != results->frames.end() - 1; | 455 for (iter = results->frames.begin(); iter != results->frames.end() - 1; |
| 456 ++iter) { | 456 ++iter) { |
| 457 fprintf(output, "%f,", iter->ssim_value); | 457 fprintf(output, "%f,", iter->ssim_value); |
| 458 } | 458 } |
| 459 fprintf(output, "%f] score\n", iter->ssim_value); | 459 fprintf(output, "%f] score\n", iter->ssim_value); |
| 460 } | 460 } |
| 461 } | 461 } |
| 462 | 462 |
| 463 } // namespace test | 463 } // namespace test |
| 464 } // namespace webrtc | 464 } // namespace webrtc |
| OLD | NEW |