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 | |
| 11 | |
| 12 | #ifndef WEBRTC_MODULES_VIDEO_CODING_TEST_VIDEO_METRICS_H_ |
| 13 | #define WEBRTC_MODULES_VIDEO_CODING_TEST_VIDEO_METRICS_H_ |
| 14 | |
kjellander@webrtc.org | f0a8464 | 2011-09-12 13:45:39 +0000 | [diff] [blame] | 15 | #include "typedefs.h" |
| 16 | #include <limits> |
| 17 | #include <vector> |
| 18 | |
| 19 | |
| 20 | // Contains video quality metrics result for a single frame. |
| 21 | struct FrameResult { |
| 22 | WebRtc_Word32 frame_number; |
| 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; |
| 39 | WebRtc_Word32 min_frame_number; |
| 40 | WebRtc_Word32 max_frame_number; |
| 41 | std::vector<FrameResult> frames; |
| 42 | }; |
mikhal@webrtc.org | 552f173 | 2011-08-26 17:38:09 +0000 | [diff] [blame] | 43 | |
| 44 | // PSNR & SSIM calculations |
phoglund@webrtc.org | 1144ba2 | 2011-11-11 09:01:03 +0000 | [diff] [blame] | 45 | |
| 46 | // PSNR values are filled into the QualityMetricsResult struct. |
| 47 | // If the result is std::numerical_limits<double>::max() the videos were |
| 48 | // equal. Otherwise, PSNR values are in decibel (higher is better). This |
| 49 | // algorithm only compares up to the point when the shortest video ends. |
mikhal@webrtc.org | 552f173 | 2011-08-26 17:38:09 +0000 | [diff] [blame] | 50 | WebRtc_Word32 |
| 51 | PsnrFromFiles(const WebRtc_Word8 *refFileName, |
| 52 | const WebRtc_Word8 *testFileName, WebRtc_Word32 width, |
kjellander@webrtc.org | f0a8464 | 2011-09-12 13:45:39 +0000 | [diff] [blame] | 53 | WebRtc_Word32 height, QualityMetricsResult *result); |
mikhal@webrtc.org | 552f173 | 2011-08-26 17:38:09 +0000 | [diff] [blame] | 54 | |
phoglund@webrtc.org | 1144ba2 | 2011-11-11 09:01:03 +0000 | [diff] [blame] | 55 | |
| 56 | // SSIM values are filled into the QualityMetricsResult struct. |
| 57 | // Values range between -1 and 1, where 1 means the files were identical. This |
| 58 | // algorithm only compares up to the point when the shortest video ends. |
mikhal@webrtc.org | 552f173 | 2011-08-26 17:38:09 +0000 | [diff] [blame] | 59 | WebRtc_Word32 |
| 60 | SsimFromFiles(const WebRtc_Word8 *refFileName, |
| 61 | const WebRtc_Word8 *testFileName, WebRtc_Word32 width, |
kjellander@webrtc.org | f0a8464 | 2011-09-12 13:45:39 +0000 | [diff] [blame] | 62 | WebRtc_Word32 height, QualityMetricsResult *result); |
mikhal@webrtc.org | 552f173 | 2011-08-26 17:38:09 +0000 | [diff] [blame] | 63 | |
mikhal@webrtc.org | e06be4f | 2011-10-03 22:54:43 +0000 | [diff] [blame] | 64 | double |
| 65 | SsimFrame(WebRtc_UWord8 *img1, WebRtc_UWord8 *img2, WebRtc_Word32 stride_img1, |
| 66 | WebRtc_Word32 stride_img2, WebRtc_Word32 width, WebRtc_Word32 height); |
| 67 | |
mikhal@webrtc.org | 552f173 | 2011-08-26 17:38:09 +0000 | [diff] [blame] | 68 | |
| 69 | #endif // WEBRTC_MODULES_VIDEO_CODING_TEST_VIDEO_METRICS_H_ |