blob: d25a1cfc57ab538f9ea1fe7073efb1e63b117591 [file] [log] [blame]
mikhal@webrtc.org552f1732011-08-26 17:38:09 +00001/*
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.orgf0a84642011-09-12 13:45:39 +000015#include "typedefs.h"
16#include <limits>
17#include <vector>
18
19
20// Contains video quality metrics result for a single frame.
21struct 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.
28struct 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.org552f1732011-08-26 17:38:09 +000043
44// PSNR & SSIM calculations
phoglund@webrtc.org1144ba22011-11-11 09:01:03 +000045
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.org552f1732011-08-26 17:38:09 +000050WebRtc_Word32
51PsnrFromFiles(const WebRtc_Word8 *refFileName,
52 const WebRtc_Word8 *testFileName, WebRtc_Word32 width,
kjellander@webrtc.orgf0a84642011-09-12 13:45:39 +000053 WebRtc_Word32 height, QualityMetricsResult *result);
mikhal@webrtc.org552f1732011-08-26 17:38:09 +000054
phoglund@webrtc.org1144ba22011-11-11 09:01:03 +000055
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.org552f1732011-08-26 17:38:09 +000059WebRtc_Word32
60SsimFromFiles(const WebRtc_Word8 *refFileName,
61 const WebRtc_Word8 *testFileName, WebRtc_Word32 width,
kjellander@webrtc.orgf0a84642011-09-12 13:45:39 +000062 WebRtc_Word32 height, QualityMetricsResult *result);
mikhal@webrtc.org552f1732011-08-26 17:38:09 +000063
mikhal@webrtc.orge06be4f2011-10-03 22:54:43 +000064double
65SsimFrame(WebRtc_UWord8 *img1, WebRtc_UWord8 *img2, WebRtc_Word32 stride_img1,
66 WebRtc_Word32 stride_img2, WebRtc_Word32 width, WebRtc_Word32 height);
67
mikhal@webrtc.org552f1732011-08-26 17:38:09 +000068
69#endif // WEBRTC_MODULES_VIDEO_CODING_TEST_VIDEO_METRICS_H_