2011-08-26 19:38:09 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
*/
|
|
|
|
|
2012-01-04 09:09:32 +01:00
|
|
|
#ifndef WEBRTC_TESTSUPPORT_METRICS_VIDEO_METRICS_H_
|
|
|
|
#define WEBRTC_TESTSUPPORT_METRICS_VIDEO_METRICS_H_
|
2011-08-26 19:38:09 +02:00
|
|
|
|
2011-09-12 15:45:39 +02:00
|
|
|
#include <limits>
|
|
|
|
#include <vector>
|
|
|
|
|
2012-01-04 09:09:32 +01:00
|
|
|
namespace webrtc {
|
|
|
|
namespace test {
|
2011-09-12 15:45:39 +02:00
|
|
|
|
|
|
|
// Contains video quality metrics result for a single frame.
|
|
|
|
struct FrameResult {
|
2012-01-04 09:09:32 +01:00
|
|
|
int frame_number;
|
2011-09-12 15:45:39 +02:00
|
|
|
double value;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Result from a PSNR/SSIM calculation operation.
|
|
|
|
// The frames in this data structure are 0-indexed.
|
|
|
|
struct QualityMetricsResult {
|
|
|
|
QualityMetricsResult() :
|
|
|
|
average(0.0),
|
|
|
|
min(std::numeric_limits<double>::max()),
|
|
|
|
max(std::numeric_limits<double>::min()),
|
|
|
|
min_frame_number(-1),
|
|
|
|
max_frame_number(-1)
|
|
|
|
{};
|
|
|
|
double average;
|
|
|
|
double min;
|
|
|
|
double max;
|
2012-01-04 09:09:32 +01:00
|
|
|
int min_frame_number;
|
|
|
|
int max_frame_number;
|
2011-09-12 15:45:39 +02:00
|
|
|
std::vector<FrameResult> frames;
|
|
|
|
};
|
2011-08-26 19:38:09 +02:00
|
|
|
|
2012-01-04 09:09:32 +01:00
|
|
|
// Calculates PSNR and SSIM values for the reference and test video files
|
|
|
|
// (must be in I420 format). All calculated values are filled into the
|
|
|
|
// QualityMetricsResult stucts.
|
|
|
|
// PSNR values have the unit decibel (dB) where a high value means the test file
|
|
|
|
// is similar to the reference file. The higher value, the more similar.
|
|
|
|
// For more info about PSNR, see http://en.wikipedia.org/wiki/PSNR
|
|
|
|
// SSIM values range between -1.0 and 1.0, where 1.0 means the files are
|
|
|
|
// identical. For more info about SSIM, see http://en.wikipedia.org/wiki/SSIM
|
|
|
|
// This function only compares video frames up to the point when the shortest
|
|
|
|
// video ends.
|
|
|
|
// Return value:
|
|
|
|
// 0 if successful, negative on errors:
|
|
|
|
// -1 if the source file cannot be opened
|
|
|
|
// -2 if the test file cannot be opened
|
|
|
|
// -3 if any of the files are empty
|
|
|
|
// -4 if any arguments are invalid.
|
|
|
|
int I420MetricsFromFiles(const char* ref_filename,
|
|
|
|
const char* test_filename,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
QualityMetricsResult* psnr_result,
|
|
|
|
QualityMetricsResult* ssim_result);
|
2011-11-11 10:01:03 +01:00
|
|
|
|
2012-01-04 09:09:32 +01:00
|
|
|
// Calculates PSNR values for the reference and test video files (must be in
|
|
|
|
// I420 format). All calculated values are filled into the QualityMetricsResult
|
|
|
|
// struct.
|
|
|
|
// PSNR values have the unit decibel (dB) where a high value means the test file
|
|
|
|
// is similar to the reference file. The higher value, the more similar.
|
|
|
|
// This function only compares video frames up to the point when the shortest
|
|
|
|
// video ends.
|
|
|
|
// For more info about PSNR, see http://en.wikipedia.org/wiki/PSNR
|
2011-12-05 14:03:38 +01:00
|
|
|
//
|
2012-01-04 09:09:32 +01:00
|
|
|
// Return value:
|
|
|
|
// 0 if successful, negative on errors:
|
2011-12-05 14:03:38 +01:00
|
|
|
// -1 if the source file cannot be opened
|
|
|
|
// -2 if the test file cannot be opened
|
|
|
|
// -3 if any of the files are empty
|
2012-01-04 09:09:32 +01:00
|
|
|
// -4 if any arguments are invalid.
|
|
|
|
int I420PSNRFromFiles(const char* ref_filename,
|
|
|
|
const char* test_filename,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
QualityMetricsResult* result);
|
2011-11-11 10:01:03 +01:00
|
|
|
|
2012-01-04 09:09:32 +01:00
|
|
|
// Calculates SSIM values for the reference and test video files (must be in
|
|
|
|
// I420 format). All calculated values are filled into the QualityMetricsResult
|
|
|
|
// struct.
|
|
|
|
// SSIM values range between -1.0 and 1.0, where 1.0 means the files are
|
|
|
|
// identical.
|
|
|
|
// This function only compares video frames up to the point when the shortest
|
|
|
|
// video ends.
|
|
|
|
// For more info about SSIM, see http://en.wikipedia.org/wiki/SSIM
|
2011-12-05 14:03:38 +01:00
|
|
|
//
|
2012-01-04 09:09:32 +01:00
|
|
|
// Return value:
|
|
|
|
// 0 if successful, negative on errors:
|
2011-12-05 14:03:38 +01:00
|
|
|
// -1 if the source file cannot be opened
|
|
|
|
// -2 if the test file cannot be opened
|
|
|
|
// -3 if any of the files are empty
|
2012-01-04 09:09:32 +01:00
|
|
|
// -4 if any arguments are invalid.
|
|
|
|
int I420SSIMFromFiles(const char* ref_filename,
|
|
|
|
const char* test_filename,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
QualityMetricsResult* result);
|
2011-10-04 00:54:43 +02:00
|
|
|
|
2012-01-04 09:09:32 +01:00
|
|
|
} // namespace test
|
|
|
|
} // namespace webrtc
|
2011-08-26 19:38:09 +02:00
|
|
|
|
2012-01-04 09:09:32 +01:00
|
|
|
#endif // WEBRTC_TESTSUPPORT_METRICS_VIDEO_METRICS_H_
|