mikhal@webrtc.org | 552f173 | 2011-08-26 17:38:09 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
kjellander@webrtc.org | cc33737 | 2012-01-04 08:09:32 +0000 | [diff] [blame^] | 11 | #ifndef WEBRTC_TESTSUPPORT_METRICS_VIDEO_METRICS_H_ |
| 12 | #define WEBRTC_TESTSUPPORT_METRICS_VIDEO_METRICS_H_ |
mikhal@webrtc.org | 552f173 | 2011-08-26 17:38:09 +0000 | [diff] [blame] | 13 | |
kjellander@webrtc.org | f0a8464 | 2011-09-12 13:45:39 +0000 | [diff] [blame] | 14 | #include <limits> |
| 15 | #include <vector> |
| 16 | |
kjellander@webrtc.org | cc33737 | 2012-01-04 08:09:32 +0000 | [diff] [blame^] | 17 | namespace webrtc { |
| 18 | namespace test { |
kjellander@webrtc.org | f0a8464 | 2011-09-12 13:45:39 +0000 | [diff] [blame] | 19 | |
| 20 | // Contains video quality metrics result for a single frame. |
| 21 | struct FrameResult { |
kjellander@webrtc.org | cc33737 | 2012-01-04 08:09:32 +0000 | [diff] [blame^] | 22 | int frame_number; |
kjellander@webrtc.org | f0a8464 | 2011-09-12 13:45:39 +0000 | [diff] [blame] | 23 | double value; |
| 24 | }; |
| 25 | |
| 26 | // Result from a PSNR/SSIM calculation operation. |
| 27 | // The frames in this data structure are 0-indexed. |
| 28 | struct QualityMetricsResult { |
| 29 | QualityMetricsResult() : |
| 30 | average(0.0), |
| 31 | min(std::numeric_limits<double>::max()), |
| 32 | max(std::numeric_limits<double>::min()), |
| 33 | min_frame_number(-1), |
| 34 | max_frame_number(-1) |
| 35 | {}; |
| 36 | double average; |
| 37 | double min; |
| 38 | double max; |
kjellander@webrtc.org | cc33737 | 2012-01-04 08:09:32 +0000 | [diff] [blame^] | 39 | int min_frame_number; |
| 40 | int max_frame_number; |
kjellander@webrtc.org | f0a8464 | 2011-09-12 13:45:39 +0000 | [diff] [blame] | 41 | std::vector<FrameResult> frames; |
| 42 | }; |
mikhal@webrtc.org | 552f173 | 2011-08-26 17:38:09 +0000 | [diff] [blame] | 43 | |
kjellander@webrtc.org | cc33737 | 2012-01-04 08:09:32 +0000 | [diff] [blame^] | 44 | // Calculates PSNR and SSIM values for the reference and test video files |
| 45 | // (must be in I420 format). All calculated values are filled into the |
| 46 | // QualityMetricsResult stucts. |
| 47 | // PSNR values have the unit decibel (dB) where a high value means the test file |
| 48 | // is similar to the reference file. The higher value, the more similar. |
| 49 | // For more info about PSNR, see http://en.wikipedia.org/wiki/PSNR |
| 50 | // SSIM values range between -1.0 and 1.0, where 1.0 means the files are |
| 51 | // identical. For more info about SSIM, see http://en.wikipedia.org/wiki/SSIM |
| 52 | // This function only compares video frames up to the point when the shortest |
| 53 | // video ends. |
| 54 | // Return value: |
| 55 | // 0 if successful, negative on errors: |
kjellander@webrtc.org | 82d91ae | 2011-12-05 13:03:38 +0000 | [diff] [blame] | 56 | // -1 if the source file cannot be opened |
| 57 | // -2 if the test file cannot be opened |
| 58 | // -3 if any of the files are empty |
kjellander@webrtc.org | cc33737 | 2012-01-04 08:09:32 +0000 | [diff] [blame^] | 59 | // -4 if any arguments are invalid. |
| 60 | int I420MetricsFromFiles(const char* ref_filename, |
| 61 | const char* test_filename, |
| 62 | int width, |
| 63 | int height, |
| 64 | QualityMetricsResult* psnr_result, |
| 65 | QualityMetricsResult* ssim_result); |
phoglund@webrtc.org | 1144ba2 | 2011-11-11 09:01:03 +0000 | [diff] [blame] | 66 | |
kjellander@webrtc.org | cc33737 | 2012-01-04 08:09:32 +0000 | [diff] [blame^] | 67 | // Calculates PSNR values for the reference and test video files (must be in |
| 68 | // I420 format). All calculated values are filled into the QualityMetricsResult |
| 69 | // struct. |
| 70 | // PSNR values have the unit decibel (dB) where a high value means the test file |
| 71 | // is similar to the reference file. The higher value, the more similar. |
| 72 | // This function only compares video frames up to the point when the shortest |
| 73 | // video ends. |
| 74 | // For more info about PSNR, see http://en.wikipedia.org/wiki/PSNR |
kjellander@webrtc.org | 82d91ae | 2011-12-05 13:03:38 +0000 | [diff] [blame] | 75 | // |
kjellander@webrtc.org | cc33737 | 2012-01-04 08:09:32 +0000 | [diff] [blame^] | 76 | // Return value: |
| 77 | // 0 if successful, negative on errors: |
kjellander@webrtc.org | 82d91ae | 2011-12-05 13:03:38 +0000 | [diff] [blame] | 78 | // -1 if the source file cannot be opened |
| 79 | // -2 if the test file cannot be opened |
| 80 | // -3 if any of the files are empty |
kjellander@webrtc.org | cc33737 | 2012-01-04 08:09:32 +0000 | [diff] [blame^] | 81 | // -4 if any arguments are invalid. |
| 82 | int I420PSNRFromFiles(const char* ref_filename, |
| 83 | const char* test_filename, |
| 84 | int width, |
| 85 | int height, |
| 86 | QualityMetricsResult* result); |
mikhal@webrtc.org | 552f173 | 2011-08-26 17:38:09 +0000 | [diff] [blame] | 87 | |
kjellander@webrtc.org | cc33737 | 2012-01-04 08:09:32 +0000 | [diff] [blame^] | 88 | // Calculates SSIM values for the reference and test video files (must be in |
| 89 | // I420 format). All calculated values are filled into the QualityMetricsResult |
| 90 | // struct. |
| 91 | // SSIM values range between -1.0 and 1.0, where 1.0 means the files are |
| 92 | // identical. |
| 93 | // This function only compares video frames up to the point when the shortest |
| 94 | // video ends. |
| 95 | // For more info about SSIM, see http://en.wikipedia.org/wiki/SSIM |
| 96 | // |
| 97 | // Return value: |
| 98 | // 0 if successful, negative on errors: |
| 99 | // -1 if the source file cannot be opened |
| 100 | // -2 if the test file cannot be opened |
| 101 | // -3 if any of the files are empty |
| 102 | // -4 if any arguments are invalid. |
| 103 | int I420SSIMFromFiles(const char* ref_filename, |
| 104 | const char* test_filename, |
| 105 | int width, |
| 106 | int height, |
| 107 | QualityMetricsResult* result); |
mikhal@webrtc.org | 552f173 | 2011-08-26 17:38:09 +0000 | [diff] [blame] | 108 | |
kjellander@webrtc.org | cc33737 | 2012-01-04 08:09:32 +0000 | [diff] [blame^] | 109 | } // namespace test |
| 110 | } // namespace webrtc |
| 111 | |
| 112 | #endif // WEBRTC_TESTSUPPORT_METRICS_VIDEO_METRICS_H_ |