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 |
11 #include "webrtc/test/testsupport/metrics/video_metrics.h" | 11 #include "webrtc/test/testsupport/metrics/video_metrics.h" |
12 | 12 |
13 #include <assert.h> | 13 #include <assert.h> |
14 #include <stdio.h> | 14 #include <stdio.h> |
15 | 15 |
16 #include <algorithm> // min_element, max_element | 16 #include <algorithm> // min_element, max_element |
| 17 #include <memory> |
17 | 18 |
18 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" | 19 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" |
19 #include "webrtc/video_frame.h" | 20 #include "webrtc/video_frame.h" |
20 | 21 |
21 namespace webrtc { | 22 namespace webrtc { |
22 namespace test { | 23 namespace test { |
23 | 24 |
24 // Copy here so our callers won't need to include libyuv for this constant. | 25 // Copy here so our callers won't need to include libyuv for this constant. |
25 double kMetricsPerfectPSNR = kPerfectPSNR; | 26 double kMetricsPerfectPSNR = kPerfectPSNR; |
26 | 27 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 fprintf(stderr, "Cannot open file %s\n", test_filename); | 105 fprintf(stderr, "Cannot open file %s\n", test_filename); |
105 fclose(ref_fp); | 106 fclose(ref_fp); |
106 return -2; | 107 return -2; |
107 } | 108 } |
108 int frame_number = 0; | 109 int frame_number = 0; |
109 | 110 |
110 // Read reference and test frames. | 111 // Read reference and test frames. |
111 const size_t frame_length = 3 * width * height >> 1; | 112 const size_t frame_length = 3 * width * height >> 1; |
112 VideoFrame ref_frame; | 113 VideoFrame ref_frame; |
113 VideoFrame test_frame; | 114 VideoFrame test_frame; |
114 rtc::scoped_ptr<uint8_t[]> ref_buffer(new uint8_t[frame_length]); | 115 std::unique_ptr<uint8_t[]> ref_buffer(new uint8_t[frame_length]); |
115 rtc::scoped_ptr<uint8_t[]> test_buffer(new uint8_t[frame_length]); | 116 std::unique_ptr<uint8_t[]> test_buffer(new uint8_t[frame_length]); |
116 | 117 |
117 // Set decoded image parameters. | 118 // Set decoded image parameters. |
118 int half_width = (width + 1) / 2; | 119 int half_width = (width + 1) / 2; |
119 ref_frame.CreateEmptyFrame(width, height, width, half_width, half_width); | 120 ref_frame.CreateEmptyFrame(width, height, width, half_width, half_width); |
120 test_frame.CreateEmptyFrame(width, height, width, half_width, half_width); | 121 test_frame.CreateEmptyFrame(width, height, width, half_width, half_width); |
121 | 122 |
122 size_t ref_bytes = fread(ref_buffer.get(), 1, frame_length, ref_fp); | 123 size_t ref_bytes = fread(ref_buffer.get(), 1, frame_length, ref_fp); |
123 size_t test_bytes = fread(test_buffer.get(), 1, frame_length, test_fp); | 124 size_t test_bytes = fread(test_buffer.get(), 1, frame_length, test_fp); |
124 while (ref_bytes == frame_length && test_bytes == frame_length) { | 125 while (ref_bytes == frame_length && test_bytes == frame_length) { |
125 // Converting from buffer to plane representation. | 126 // Converting from buffer to plane representation. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 int width, | 190 int width, |
190 int height, | 191 int height, |
191 QualityMetricsResult* result) { | 192 QualityMetricsResult* result) { |
192 assert(result != NULL); | 193 assert(result != NULL); |
193 return CalculateMetrics(kSSIM, ref_filename, test_filename, width, height, | 194 return CalculateMetrics(kSSIM, ref_filename, test_filename, width, height, |
194 NULL, result); | 195 NULL, result); |
195 } | 196 } |
196 | 197 |
197 } // namespace test | 198 } // namespace test |
198 } // namespace webrtc | 199 } // namespace webrtc |
OLD | NEW |