2014-10-16 03:40:12 +04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2014 The WebM 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.
|
|
|
|
*/
|
|
|
|
|
2015-07-30 00:51:36 +03:00
|
|
|
#include "third_party/googletest/src/include/gtest/gtest.h"
|
|
|
|
|
2014-10-16 03:40:12 +04:00
|
|
|
#include "test/codec_factory.h"
|
|
|
|
#include "test/encode_test_driver.h"
|
2015-07-30 00:51:36 +03:00
|
|
|
#include "test/util.h"
|
2014-10-16 03:40:12 +04:00
|
|
|
#include "test/y4m_video_source.h"
|
|
|
|
#include "test/yuv_video_source.h"
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2016-01-27 23:42:45 +03:00
|
|
|
const unsigned int kWidth = 160;
|
2014-10-16 03:40:12 +04:00
|
|
|
const unsigned int kHeight = 90;
|
|
|
|
const unsigned int kFramerate = 50;
|
|
|
|
const unsigned int kFrames = 10;
|
|
|
|
const int kBitrate = 500;
|
2014-12-15 22:58:43 +03:00
|
|
|
// List of psnr thresholds for speed settings 0-7 and 5 encoding modes
|
|
|
|
const double kPsnrThreshold[][5] = {
|
2016-01-27 23:42:45 +03:00
|
|
|
{ 36.0, 37.0, 37.0, 37.0, 37.0 }, { 35.0, 36.0, 36.0, 36.0, 36.0 },
|
|
|
|
{ 34.0, 35.0, 35.0, 35.0, 35.0 }, { 33.0, 34.0, 34.0, 34.0, 34.0 },
|
|
|
|
{ 32.0, 33.0, 33.0, 33.0, 33.0 }, { 31.0, 32.0, 32.0, 32.0, 32.0 },
|
|
|
|
{ 30.0, 31.0, 31.0, 31.0, 31.0 }, { 29.0, 30.0, 30.0, 30.0, 30.0 },
|
2014-12-15 22:58:43 +03:00
|
|
|
};
|
2014-10-16 03:40:12 +04:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
const char *filename;
|
|
|
|
unsigned int input_bit_depth;
|
|
|
|
vpx_img_fmt fmt;
|
|
|
|
vpx_bit_depth_t bit_depth;
|
|
|
|
unsigned int profile;
|
|
|
|
} TestVideoParam;
|
|
|
|
|
2014-12-15 22:58:43 +03:00
|
|
|
const TestVideoParam kTestVectors[] = {
|
2016-01-27 23:42:45 +03:00
|
|
|
{ "park_joy_90p_8_420.y4m", 8, VPX_IMG_FMT_I420, VPX_BITS_8, 0 },
|
|
|
|
{ "park_joy_90p_8_422.y4m", 8, VPX_IMG_FMT_I422, VPX_BITS_8, 1 },
|
|
|
|
{ "park_joy_90p_8_444.y4m", 8, VPX_IMG_FMT_I444, VPX_BITS_8, 1 },
|
|
|
|
{ "park_joy_90p_8_440.yuv", 8, VPX_IMG_FMT_I440, VPX_BITS_8, 1 },
|
2016-01-21 03:13:04 +03:00
|
|
|
#if CONFIG_VPX_HIGHBITDEPTH
|
2016-01-27 23:42:45 +03:00
|
|
|
{ "park_joy_90p_10_420.y4m", 10, VPX_IMG_FMT_I42016, VPX_BITS_10, 2 },
|
|
|
|
{ "park_joy_90p_10_422.y4m", 10, VPX_IMG_FMT_I42216, VPX_BITS_10, 3 },
|
|
|
|
{ "park_joy_90p_10_444.y4m", 10, VPX_IMG_FMT_I44416, VPX_BITS_10, 3 },
|
|
|
|
{ "park_joy_90p_10_440.yuv", 10, VPX_IMG_FMT_I44016, VPX_BITS_10, 3 },
|
|
|
|
{ "park_joy_90p_12_420.y4m", 12, VPX_IMG_FMT_I42016, VPX_BITS_12, 2 },
|
|
|
|
{ "park_joy_90p_12_422.y4m", 12, VPX_IMG_FMT_I42216, VPX_BITS_12, 3 },
|
|
|
|
{ "park_joy_90p_12_444.y4m", 12, VPX_IMG_FMT_I44416, VPX_BITS_12, 3 },
|
|
|
|
{ "park_joy_90p_12_440.yuv", 12, VPX_IMG_FMT_I44016, VPX_BITS_12, 3 },
|
2016-01-21 03:13:04 +03:00
|
|
|
#endif // CONFIG_VPX_HIGHBITDEPTH
|
2014-10-16 03:40:12 +04:00
|
|
|
};
|
|
|
|
|
2014-12-15 22:58:43 +03:00
|
|
|
// Encoding modes tested
|
|
|
|
const libvpx_test::TestMode kEncodingModeVectors[] = {
|
2016-01-27 23:42:45 +03:00
|
|
|
::libvpx_test::kTwoPassGood, ::libvpx_test::kOnePassGood,
|
2014-12-15 22:58:43 +03:00
|
|
|
::libvpx_test::kRealTime,
|
|
|
|
};
|
|
|
|
|
|
|
|
// Speed settings tested
|
2016-01-27 23:42:45 +03:00
|
|
|
const int kCpuUsedVectors[] = { 1, 2, 3, 5, 6 };
|
2014-12-15 22:58:43 +03:00
|
|
|
|
2014-10-16 03:40:12 +04:00
|
|
|
int is_extension_y4m(const char *filename) {
|
|
|
|
const char *dot = strrchr(filename, '.');
|
|
|
|
if (!dot || dot == filename)
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return !strcmp(dot, ".y4m");
|
|
|
|
}
|
|
|
|
|
|
|
|
class EndToEndTestLarge
|
|
|
|
: public ::libvpx_test::EncoderTest,
|
2016-01-27 23:42:45 +03:00
|
|
|
public ::libvpx_test::CodecTestWith3Params<libvpx_test::TestMode,
|
2014-12-15 22:58:43 +03:00
|
|
|
TestVideoParam, int> {
|
2014-10-16 03:40:12 +04:00
|
|
|
protected:
|
|
|
|
EndToEndTestLarge()
|
2016-01-27 23:42:45 +03:00
|
|
|
: EncoderTest(GET_PARAM(0)), test_video_param_(GET_PARAM(2)),
|
|
|
|
cpu_used_(GET_PARAM(3)), psnr_(0.0), nframes_(0),
|
|
|
|
encoding_mode_(GET_PARAM(1)) {}
|
2014-10-16 03:40:12 +04:00
|
|
|
|
|
|
|
virtual ~EndToEndTestLarge() {}
|
|
|
|
|
|
|
|
virtual void SetUp() {
|
|
|
|
InitializeConfig();
|
|
|
|
SetMode(encoding_mode_);
|
|
|
|
if (encoding_mode_ != ::libvpx_test::kRealTime) {
|
|
|
|
cfg_.g_lag_in_frames = 5;
|
|
|
|
cfg_.rc_end_usage = VPX_VBR;
|
|
|
|
} else {
|
|
|
|
cfg_.g_lag_in_frames = 0;
|
|
|
|
cfg_.rc_end_usage = VPX_CBR;
|
2014-12-15 22:58:43 +03:00
|
|
|
cfg_.rc_buf_sz = 1000;
|
|
|
|
cfg_.rc_buf_initial_sz = 500;
|
|
|
|
cfg_.rc_buf_optimal_sz = 600;
|
2014-10-16 03:40:12 +04:00
|
|
|
}
|
2014-12-07 22:28:51 +03:00
|
|
|
dec_cfg_.threads = 4;
|
2014-10-16 03:40:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void BeginPassHook(unsigned int) {
|
|
|
|
psnr_ = 0.0;
|
|
|
|
nframes_ = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void PSNRPktHook(const vpx_codec_cx_pkt_t *pkt) {
|
|
|
|
psnr_ += pkt->data.psnr.psnr[0];
|
|
|
|
nframes_++;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video,
|
|
|
|
::libvpx_test::Encoder *encoder) {
|
|
|
|
if (video->frame() == 1) {
|
2014-12-07 22:28:51 +03:00
|
|
|
encoder->Control(VP9E_SET_FRAME_PARALLEL_DECODING, 1);
|
|
|
|
encoder->Control(VP9E_SET_TILE_COLUMNS, 4);
|
2014-12-15 22:58:43 +03:00
|
|
|
encoder->Control(VP8E_SET_CPUUSED, cpu_used_);
|
2014-10-16 03:40:12 +04:00
|
|
|
if (encoding_mode_ != ::libvpx_test::kRealTime) {
|
|
|
|
encoder->Control(VP8E_SET_ENABLEAUTOALTREF, 1);
|
|
|
|
encoder->Control(VP8E_SET_ARNR_MAXFRAMES, 7);
|
|
|
|
encoder->Control(VP8E_SET_ARNR_STRENGTH, 5);
|
|
|
|
encoder->Control(VP8E_SET_ARNR_TYPE, 3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
double GetAveragePsnr() const {
|
2016-01-27 23:42:45 +03:00
|
|
|
if (nframes_) return psnr_ / nframes_;
|
2014-10-16 03:40:12 +04:00
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
|
2014-12-15 22:58:43 +03:00
|
|
|
double GetPsnrThreshold() {
|
|
|
|
return kPsnrThreshold[cpu_used_][encoding_mode_];
|
|
|
|
}
|
|
|
|
|
2014-10-16 03:40:12 +04:00
|
|
|
TestVideoParam test_video_param_;
|
2014-12-15 22:58:43 +03:00
|
|
|
int cpu_used_;
|
2014-10-16 03:40:12 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
double psnr_;
|
|
|
|
unsigned int nframes_;
|
|
|
|
libvpx_test::TestMode encoding_mode_;
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_P(EndToEndTestLarge, EndtoEndPSNRTest) {
|
|
|
|
cfg_.rc_target_bitrate = kBitrate;
|
|
|
|
cfg_.g_error_resilient = 0;
|
|
|
|
cfg_.g_profile = test_video_param_.profile;
|
|
|
|
cfg_.g_input_bit_depth = test_video_param_.input_bit_depth;
|
|
|
|
cfg_.g_bit_depth = test_video_param_.bit_depth;
|
|
|
|
init_flags_ = VPX_CODEC_USE_PSNR;
|
2016-01-27 23:42:45 +03:00
|
|
|
if (cfg_.g_bit_depth > 8) init_flags_ |= VPX_CODEC_USE_HIGHBITDEPTH;
|
2014-10-16 03:40:12 +04:00
|
|
|
|
|
|
|
libvpx_test::VideoSource *video;
|
|
|
|
if (is_extension_y4m(test_video_param_.filename)) {
|
2016-01-27 23:42:45 +03:00
|
|
|
video =
|
|
|
|
new libvpx_test::Y4mVideoSource(test_video_param_.filename, 0, kFrames);
|
2014-10-16 03:40:12 +04:00
|
|
|
} else {
|
|
|
|
video = new libvpx_test::YUVVideoSource(test_video_param_.filename,
|
2016-01-27 23:42:45 +03:00
|
|
|
test_video_param_.fmt, kWidth,
|
|
|
|
kHeight, kFramerate, 1, 0, kFrames);
|
2014-10-16 03:40:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(RunLoop(video));
|
|
|
|
const double psnr = GetAveragePsnr();
|
2014-12-15 22:58:43 +03:00
|
|
|
EXPECT_GT(psnr, GetPsnrThreshold());
|
2016-01-27 23:42:45 +03:00
|
|
|
delete (video);
|
2014-10-16 03:40:12 +04:00
|
|
|
}
|
|
|
|
|
2016-01-21 03:13:04 +03:00
|
|
|
#if CONFIG_VPX_HIGHBITDEPTH
|
2016-01-27 23:42:45 +03:00
|
|
|
#if CONFIG_VP10_ENCODER
|
2015-09-19 19:14:18 +03:00
|
|
|
// TODO(angiebird): many fail in high bitdepth mode.
|
|
|
|
INSTANTIATE_TEST_CASE_P(
|
|
|
|
DISABLED_VP10, EndToEndTestLarge,
|
|
|
|
::testing::Combine(
|
|
|
|
::testing::Values(static_cast<const libvpx_test::CodecFactory *>(
|
|
|
|
&libvpx_test::kVP10)),
|
|
|
|
::testing::ValuesIn(kEncodingModeVectors),
|
|
|
|
::testing::ValuesIn(kTestVectors),
|
|
|
|
::testing::ValuesIn(kCpuUsedVectors)));
|
2016-01-27 23:42:45 +03:00
|
|
|
#endif // CONFIG_VP10_ENCODER
|
2015-09-19 19:14:18 +03:00
|
|
|
#else
|
2016-01-27 23:42:45 +03:00
|
|
|
VP10_INSTANTIATE_TEST_CASE(EndToEndTestLarge,
|
|
|
|
::testing::ValuesIn(kEncodingModeVectors),
|
|
|
|
::testing::ValuesIn(kTestVectors),
|
|
|
|
::testing::ValuesIn(kCpuUsedVectors));
|
2016-01-21 03:13:04 +03:00
|
|
|
#endif // CONFIG_VPX_HIGHBITDEPTH
|
2014-10-16 03:40:12 +04:00
|
|
|
} // namespace
|