#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include <math.h>
#include <algorithm>
#include <utility>
#include "base/logging.h"
#include "media/base/video_frame.h"
#include "media/base/video_types.h"
#include "media/gpu/test/video_frame_helpers.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/libyuv/include/libyuv/compare.h"
#include "ui/gfx/geometry/point.h"
#define ASSERT_TRUE_OR_RETURN(predicate, return_value) …
namespace media {
namespace test {
namespace {
enum SimilarityMetrics { … };
double SSIM16BitPlane8x8(const uint8_t* src_a,
int stride_a,
const uint8_t* src_b,
int stride_b) { … }
double Calc16bitPlaneSSIM(const uint8_t* src_a,
int stride_a,
const uint8_t* src_b,
int stride_b,
int width,
int height) { … }
double ComputeYUV420P10SSIM(const uint8_t* src_y_a,
int stride_y_a,
const uint8_t* src_u_a,
int stride_u_a,
const uint8_t* src_v_a,
int stride_v_a,
const uint8_t* src_y_b,
int stride_y_b,
const uint8_t* src_u_b,
int stride_u_b,
const uint8_t* src_v_b,
int stride_v_b,
int width,
int height) { … }
double ComputeSimilarity(const VideoFrame* frame1,
const VideoFrame* frame2,
SimilarityMetrics mode) { … }
constexpr int kJointDistributionBitDepth = …;
constexpr int kJointDistributionDim = …;
DistributionTable;
bool ComputeLogJointDistribution(const VideoFrame& frame,
DistributionTable& log_joint_distribution) { … }
double ComputeLogProbability(const VideoFrame& frame,
DistributionTable& log_joint_distribution) { … }
constexpr double kMaxPsnr = …;
}
size_t CompareFramesWithErrorDiff(const VideoFrame& frame1,
const VideoFrame& frame2,
uint8_t tolerance) { … }
double ComputePSNR(const VideoFrame& frame1, const VideoFrame& frame2) { … }
double ComputeSSIM(const VideoFrame& frame1, const VideoFrame& frame2) { … }
double ComputeLogLikelihoodRatio(scoped_refptr<const VideoFrame> golden_frame,
scoped_refptr<const VideoFrame> test_frame) { … }
double ComputeAR30PSNR(const uint32_t* frame1_data,
size_t frame1_stride,
const uint32_t* frame2_data,
size_t frame2_stride,
size_t width,
size_t height) { … }
}
}