2014-12-16 20:10:20 +01: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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include "third_party/googletest/src/include/gtest/gtest.h"
|
|
|
|
#include "test/codec_factory.h"
|
|
|
|
#include "test/encode_test_driver.h"
|
|
|
|
#include "test/md5_helper.h"
|
2015-02-26 04:09:59 +01:00
|
|
|
#include "test/util.h"
|
|
|
|
#include "test/y4m_video_source.h"
|
2017-01-20 18:15:15 +01:00
|
|
|
#include "vp9/encoder/vp9_firstpass.h"
|
2014-12-16 20:10:20 +01:00
|
|
|
|
|
|
|
namespace {
|
2017-01-20 18:15:15 +01:00
|
|
|
// FIRSTPASS_STATS struct:
|
|
|
|
// {
|
2016-12-12 15:05:19 +01:00
|
|
|
// 25 double members;
|
2017-01-20 18:15:15 +01:00
|
|
|
// 1 int64_t member;
|
|
|
|
// }
|
|
|
|
// Whenever FIRSTPASS_STATS struct is modified, the following constants need to
|
|
|
|
// be revisited.
|
2016-12-12 15:05:19 +01:00
|
|
|
const int kDbl = 25;
|
2017-01-20 18:15:15 +01:00
|
|
|
const int kInt = 1;
|
|
|
|
const size_t kFirstPassStatsSz = kDbl * sizeof(double) + kInt * sizeof(int64_t);
|
|
|
|
|
|
|
|
class VPxFirstPassEncoderThreadTest
|
|
|
|
: public ::libvpx_test::EncoderTest,
|
|
|
|
public ::libvpx_test::CodecTestWith2Params<libvpx_test::TestMode, int> {
|
|
|
|
protected:
|
|
|
|
VPxFirstPassEncoderThreadTest()
|
|
|
|
: EncoderTest(GET_PARAM(0)), encoder_initialized_(false), tiles_(0),
|
|
|
|
encoding_mode_(GET_PARAM(1)), set_cpu_used_(GET_PARAM(2)) {
|
|
|
|
init_flags_ = VPX_CODEC_USE_PSNR;
|
|
|
|
|
2017-02-24 20:40:22 +01:00
|
|
|
row_mt_mode_ = 1;
|
2017-02-03 17:29:21 +01:00
|
|
|
first_pass_only_ = true;
|
2017-01-20 18:15:15 +01:00
|
|
|
firstpass_stats_.buf = NULL;
|
|
|
|
firstpass_stats_.sz = 0;
|
|
|
|
}
|
|
|
|
virtual ~VPxFirstPassEncoderThreadTest() { free(firstpass_stats_.buf); }
|
|
|
|
|
|
|
|
virtual void SetUp() {
|
|
|
|
InitializeConfig();
|
|
|
|
SetMode(encoding_mode_);
|
|
|
|
|
|
|
|
cfg_.rc_end_usage = VPX_VBR;
|
|
|
|
cfg_.rc_2pass_vbr_minsection_pct = 5;
|
|
|
|
cfg_.rc_2pass_vbr_maxsection_pct = 2000;
|
|
|
|
cfg_.rc_max_quantizer = 56;
|
|
|
|
cfg_.rc_min_quantizer = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void BeginPassHook(unsigned int /*pass*/) {
|
|
|
|
encoder_initialized_ = false;
|
|
|
|
abort_ = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void EndPassHook() {
|
|
|
|
// For first pass stats test, only run first pass encoder.
|
|
|
|
if (first_pass_only_ && cfg_.g_pass == VPX_RC_FIRST_PASS)
|
|
|
|
abort_ |= first_pass_only_;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void PreEncodeFrameHook(::libvpx_test::VideoSource * /*video*/,
|
|
|
|
::libvpx_test::Encoder *encoder) {
|
|
|
|
if (!encoder_initialized_) {
|
|
|
|
// Encode in 2-pass mode.
|
|
|
|
encoder->Control(VP9E_SET_TILE_COLUMNS, tiles_);
|
|
|
|
encoder->Control(VP8E_SET_CPUUSED, set_cpu_used_);
|
|
|
|
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);
|
|
|
|
encoder->Control(VP9E_SET_FRAME_PARALLEL_DECODING, 0);
|
|
|
|
|
2016-12-27 14:15:43 +01:00
|
|
|
if (encoding_mode_ == ::libvpx_test::kTwoPassGood)
|
2017-02-24 20:40:22 +01:00
|
|
|
encoder->Control(VP9E_SET_ROW_MT, row_mt_mode_);
|
2017-01-20 18:15:15 +01:00
|
|
|
|
|
|
|
encoder_initialized_ = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void StatsPktHook(const vpx_codec_cx_pkt_t *pkt) {
|
|
|
|
const uint8_t *const pkt_buf =
|
|
|
|
reinterpret_cast<uint8_t *>(pkt->data.twopass_stats.buf);
|
|
|
|
const size_t pkt_size = pkt->data.twopass_stats.sz;
|
|
|
|
|
|
|
|
// First pass stats size equals sizeof(FIRSTPASS_STATS)
|
|
|
|
EXPECT_EQ(pkt_size, kFirstPassStatsSz)
|
|
|
|
<< "Error: First pass stats size doesn't equal kFirstPassStatsSz";
|
|
|
|
|
|
|
|
firstpass_stats_.buf =
|
|
|
|
realloc(firstpass_stats_.buf, firstpass_stats_.sz + pkt_size);
|
|
|
|
memcpy((uint8_t *)firstpass_stats_.buf + firstpass_stats_.sz, pkt_buf,
|
|
|
|
pkt_size);
|
|
|
|
firstpass_stats_.sz += pkt_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool encoder_initialized_;
|
|
|
|
int tiles_;
|
|
|
|
::libvpx_test::TestMode encoding_mode_;
|
|
|
|
int set_cpu_used_;
|
2017-02-24 20:40:22 +01:00
|
|
|
int row_mt_mode_;
|
2017-02-03 17:29:21 +01:00
|
|
|
bool first_pass_only_;
|
2017-01-20 18:15:15 +01:00
|
|
|
vpx_fixed_buf_t firstpass_stats_;
|
|
|
|
};
|
|
|
|
|
2017-04-24 21:06:49 +02:00
|
|
|
static void compare_fp_stats(vpx_fixed_buf_t *fp_stats, double factor) {
|
2017-01-20 18:15:15 +01:00
|
|
|
// fp_stats consists of 2 set of first pass encoding stats. These 2 set of
|
|
|
|
// stats are compared to check if the stats match or at least are very close.
|
|
|
|
FIRSTPASS_STATS *stats1 = reinterpret_cast<FIRSTPASS_STATS *>(fp_stats->buf);
|
|
|
|
int nframes_ = (int)(fp_stats->sz / sizeof(FIRSTPASS_STATS));
|
|
|
|
FIRSTPASS_STATS *stats2 = stats1 + nframes_ / 2;
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
// The total stats are also output and included in the first pass stats. Here
|
|
|
|
// ignore that in the comparison.
|
|
|
|
for (i = 0; i < (nframes_ / 2 - 1); ++i) {
|
|
|
|
const double *frame_stats1 = reinterpret_cast<double *>(stats1);
|
|
|
|
const double *frame_stats2 = reinterpret_cast<double *>(stats2);
|
|
|
|
|
|
|
|
for (j = 0; j < kDbl; ++j) {
|
2017-10-06 00:02:51 +02:00
|
|
|
ASSERT_LE(fabs(*frame_stats1 - *frame_stats2),
|
|
|
|
fabs(*frame_stats1) / factor)
|
|
|
|
<< "First failure @ frame #" << i << " stat #" << j << " ("
|
|
|
|
<< *frame_stats1 << " vs. " << *frame_stats2 << ")";
|
2017-01-20 18:15:15 +01:00
|
|
|
frame_stats1++;
|
|
|
|
frame_stats2++;
|
|
|
|
}
|
|
|
|
|
|
|
|
stats1++;
|
|
|
|
stats2++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reset firstpass_stats_ to 0.
|
|
|
|
memset((uint8_t *)fp_stats->buf, 0, fp_stats->sz);
|
|
|
|
fp_stats->sz = 0;
|
|
|
|
}
|
|
|
|
|
2017-02-16 14:37:41 +01:00
|
|
|
static void compare_fp_stats_md5(vpx_fixed_buf_t *fp_stats) {
|
|
|
|
// fp_stats consists of 2 set of first pass encoding stats. These 2 set of
|
|
|
|
// stats are compared to check if the stats match.
|
|
|
|
uint8_t *stats1 = reinterpret_cast<uint8_t *>(fp_stats->buf);
|
|
|
|
uint8_t *stats2 = stats1 + fp_stats->sz / 2;
|
2017-02-24 20:40:22 +01:00
|
|
|
::libvpx_test::MD5 md5_row_mt_0, md5_row_mt_1;
|
2017-02-16 14:37:41 +01:00
|
|
|
|
2017-02-24 20:40:22 +01:00
|
|
|
md5_row_mt_0.Add(stats1, fp_stats->sz / 2);
|
|
|
|
const char *md5_row_mt_0_str = md5_row_mt_0.Get();
|
2017-02-16 14:37:41 +01:00
|
|
|
|
2017-02-24 20:40:22 +01:00
|
|
|
md5_row_mt_1.Add(stats2, fp_stats->sz / 2);
|
|
|
|
const char *md5_row_mt_1_str = md5_row_mt_1.Get();
|
2017-02-16 14:37:41 +01:00
|
|
|
|
|
|
|
// Check md5 match.
|
2017-02-24 20:40:22 +01:00
|
|
|
ASSERT_STREQ(md5_row_mt_0_str, md5_row_mt_1_str)
|
2017-02-16 14:37:41 +01:00
|
|
|
<< "MD5 checksums don't match";
|
|
|
|
|
|
|
|
// Reset firstpass_stats_ to 0.
|
|
|
|
memset((uint8_t *)fp_stats->buf, 0, fp_stats->sz);
|
|
|
|
fp_stats->sz = 0;
|
|
|
|
}
|
|
|
|
|
2017-01-20 18:15:15 +01:00
|
|
|
TEST_P(VPxFirstPassEncoderThreadTest, FirstPassStatsTest) {
|
2016-12-27 14:15:43 +01:00
|
|
|
::libvpx_test::Y4mVideoSource video("niklas_1280_720_30.y4m", 0, 60);
|
2017-01-20 18:15:15 +01:00
|
|
|
|
2017-02-03 17:29:21 +01:00
|
|
|
first_pass_only_ = true;
|
2017-01-20 18:15:15 +01:00
|
|
|
cfg_.rc_target_bitrate = 1000;
|
|
|
|
|
2017-04-24 21:06:49 +02:00
|
|
|
// Test row_mt_mode: 0 vs 1 at single thread case(threads = 1, tiles_ = 0)
|
2017-01-20 18:15:15 +01:00
|
|
|
tiles_ = 0;
|
|
|
|
cfg_.g_threads = 1;
|
|
|
|
|
2017-02-24 20:40:22 +01:00
|
|
|
row_mt_mode_ = 0;
|
2017-01-20 18:15:15 +01:00
|
|
|
init_flags_ = VPX_CODEC_USE_PSNR;
|
|
|
|
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
|
|
|
|
|
2017-02-24 20:40:22 +01:00
|
|
|
row_mt_mode_ = 1;
|
2017-01-20 18:15:15 +01:00
|
|
|
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
|
|
|
|
|
2017-04-24 21:06:49 +02:00
|
|
|
// Compare to check if using or not using row-mt generates close stats.
|
2017-10-06 00:02:51 +02:00
|
|
|
ASSERT_NO_FATAL_FAILURE(compare_fp_stats(&firstpass_stats_, 1000.0));
|
2017-01-20 18:15:15 +01:00
|
|
|
|
2017-04-24 21:06:49 +02:00
|
|
|
// Test single thread vs multiple threads
|
2017-02-24 20:40:22 +01:00
|
|
|
row_mt_mode_ = 1;
|
2017-04-24 21:06:49 +02:00
|
|
|
tiles_ = 0;
|
2017-01-20 18:15:15 +01:00
|
|
|
|
|
|
|
cfg_.g_threads = 1;
|
|
|
|
init_flags_ = VPX_CODEC_USE_PSNR;
|
|
|
|
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
|
|
|
|
|
|
|
|
cfg_.g_threads = 4;
|
|
|
|
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
|
|
|
|
|
2017-04-24 21:06:49 +02:00
|
|
|
// Compare to check if single-thread and multi-thread stats are close enough.
|
2017-10-06 00:02:51 +02:00
|
|
|
ASSERT_NO_FATAL_FAILURE(compare_fp_stats(&firstpass_stats_, 1000.0));
|
2017-02-16 14:37:41 +01:00
|
|
|
|
2017-04-24 21:06:49 +02:00
|
|
|
// Bit exact test in row_mt mode.
|
|
|
|
// When row_mt_mode_=1 and using >1 threads, the encoder generates bit exact
|
|
|
|
// result.
|
|
|
|
row_mt_mode_ = 1;
|
2017-02-16 14:37:41 +01:00
|
|
|
tiles_ = 2;
|
|
|
|
|
2017-04-24 21:06:49 +02:00
|
|
|
cfg_.g_threads = 2;
|
2017-02-16 14:37:41 +01:00
|
|
|
init_flags_ = VPX_CODEC_USE_PSNR;
|
|
|
|
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
|
|
|
|
|
2017-04-24 21:06:49 +02:00
|
|
|
cfg_.g_threads = 8;
|
2017-02-16 14:37:41 +01:00
|
|
|
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
|
|
|
|
|
2017-02-24 20:40:22 +01:00
|
|
|
// Compare to check if stats match with row-mt=0/1.
|
2017-02-16 14:37:41 +01:00
|
|
|
compare_fp_stats_md5(&firstpass_stats_);
|
2017-01-20 18:15:15 +01:00
|
|
|
}
|
|
|
|
|
2015-08-19 23:13:18 +02:00
|
|
|
class VPxEncoderThreadTest
|
2014-12-16 20:10:20 +01:00
|
|
|
: public ::libvpx_test::EncoderTest,
|
2016-10-19 20:07:41 +02:00
|
|
|
public ::libvpx_test::CodecTestWith4Params<libvpx_test::TestMode, int,
|
|
|
|
int, int> {
|
2014-12-16 20:10:20 +01:00
|
|
|
protected:
|
2015-08-19 23:13:18 +02:00
|
|
|
VPxEncoderThreadTest()
|
2016-10-19 20:07:41 +02:00
|
|
|
: EncoderTest(GET_PARAM(0)), encoder_initialized_(false),
|
|
|
|
tiles_(GET_PARAM(3)), threads_(GET_PARAM(4)),
|
2016-07-26 07:50:48 +02:00
|
|
|
encoding_mode_(GET_PARAM(1)), set_cpu_used_(GET_PARAM(2)) {
|
2014-12-16 20:10:20 +01:00
|
|
|
init_flags_ = VPX_CODEC_USE_PSNR;
|
|
|
|
md5_.clear();
|
2017-02-24 20:40:22 +01:00
|
|
|
row_mt_mode_ = 1;
|
2017-02-22 21:24:16 +01:00
|
|
|
psnr_ = 0.0;
|
|
|
|
nframes_ = 0;
|
2014-12-16 20:10:20 +01:00
|
|
|
}
|
2016-04-28 22:09:08 +02:00
|
|
|
virtual ~VPxEncoderThreadTest() {}
|
2014-12-16 20:10:20 +01:00
|
|
|
|
|
|
|
virtual void SetUp() {
|
|
|
|
InitializeConfig();
|
|
|
|
SetMode(encoding_mode_);
|
|
|
|
|
|
|
|
if (encoding_mode_ != ::libvpx_test::kRealTime) {
|
|
|
|
cfg_.rc_end_usage = VPX_VBR;
|
|
|
|
cfg_.rc_2pass_vbr_minsection_pct = 5;
|
2016-03-15 17:28:16 +01:00
|
|
|
cfg_.rc_2pass_vbr_maxsection_pct = 2000;
|
2014-12-16 20:10:20 +01:00
|
|
|
} else {
|
|
|
|
cfg_.g_lag_in_frames = 0;
|
|
|
|
cfg_.rc_end_usage = VPX_CBR;
|
|
|
|
cfg_.g_error_resilient = 1;
|
|
|
|
}
|
|
|
|
cfg_.rc_max_quantizer = 56;
|
|
|
|
cfg_.rc_min_quantizer = 0;
|
|
|
|
}
|
|
|
|
|
2015-03-05 20:47:21 +01:00
|
|
|
virtual void BeginPassHook(unsigned int /*pass*/) {
|
|
|
|
encoder_initialized_ = false;
|
2017-02-22 21:24:16 +01:00
|
|
|
psnr_ = 0.0;
|
|
|
|
nframes_ = 0;
|
2015-03-05 20:47:21 +01:00
|
|
|
}
|
|
|
|
|
2016-02-12 03:27:00 +01:00
|
|
|
virtual void PreEncodeFrameHook(::libvpx_test::VideoSource * /*video*/,
|
2014-12-16 20:10:20 +01:00
|
|
|
::libvpx_test::Encoder *encoder) {
|
2015-03-05 20:47:21 +01:00
|
|
|
if (!encoder_initialized_) {
|
2014-12-16 20:10:20 +01:00
|
|
|
// Encode 4 column tiles.
|
|
|
|
encoder->Control(VP9E_SET_TILE_COLUMNS, tiles_);
|
|
|
|
encoder->Control(VP8E_SET_CPUUSED, set_cpu_used_);
|
|
|
|
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);
|
2016-10-25 19:47:21 +02:00
|
|
|
encoder->Control(VP9E_SET_FRAME_PARALLEL_DECODING, 0);
|
2014-12-16 20:10:20 +01:00
|
|
|
} else {
|
|
|
|
encoder->Control(VP8E_SET_ENABLEAUTOALTREF, 0);
|
2015-03-06 19:47:09 +01:00
|
|
|
encoder->Control(VP9E_SET_AQ_MODE, 3);
|
2014-12-16 20:10:20 +01:00
|
|
|
}
|
2017-02-13 20:36:02 +01:00
|
|
|
encoder->Control(VP9E_SET_ROW_MT, row_mt_mode_);
|
2017-04-24 21:06:49 +02:00
|
|
|
|
2015-03-05 20:47:21 +01:00
|
|
|
encoder_initialized_ = true;
|
2014-12-16 20:10:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-22 21:24:16 +01:00
|
|
|
virtual void PSNRPktHook(const vpx_codec_cx_pkt_t *pkt) {
|
|
|
|
psnr_ += pkt->data.psnr.psnr[0];
|
|
|
|
nframes_++;
|
|
|
|
}
|
|
|
|
|
2016-04-28 22:09:08 +02:00
|
|
|
virtual void DecompressedFrameHook(const vpx_image_t &img,
|
|
|
|
vpx_codec_pts_t /*pts*/) {
|
|
|
|
::libvpx_test::MD5 md5_res;
|
|
|
|
md5_res.Add(&img);
|
|
|
|
md5_.push_back(md5_res.Get());
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool HandleDecodeResult(const vpx_codec_err_t res,
|
2016-07-26 07:50:48 +02:00
|
|
|
const libvpx_test::VideoSource & /*video*/,
|
2016-04-28 22:09:08 +02:00
|
|
|
libvpx_test::Decoder * /*decoder*/) {
|
2014-12-16 20:10:20 +01:00
|
|
|
if (res != VPX_CODEC_OK) {
|
2016-04-28 22:09:08 +02:00
|
|
|
EXPECT_EQ(VPX_CODEC_OK, res);
|
|
|
|
return false;
|
2014-12-16 20:10:20 +01:00
|
|
|
}
|
|
|
|
|
2016-04-28 22:09:08 +02:00
|
|
|
return true;
|
2014-12-16 20:10:20 +01:00
|
|
|
}
|
|
|
|
|
2017-02-22 21:24:16 +01:00
|
|
|
double GetAveragePsnr() const { return nframes_ ? (psnr_ / nframes_) : 0.0; }
|
|
|
|
|
2015-03-05 20:47:21 +01:00
|
|
|
bool encoder_initialized_;
|
2014-12-16 20:10:20 +01:00
|
|
|
int tiles_;
|
2016-10-19 20:07:41 +02:00
|
|
|
int threads_;
|
2014-12-16 20:10:20 +01:00
|
|
|
::libvpx_test::TestMode encoding_mode_;
|
|
|
|
int set_cpu_used_;
|
2017-02-24 20:40:22 +01:00
|
|
|
int row_mt_mode_;
|
2017-02-22 21:24:16 +01:00
|
|
|
double psnr_;
|
|
|
|
unsigned int nframes_;
|
2014-12-16 20:10:20 +01:00
|
|
|
std::vector<std::string> md5_;
|
|
|
|
};
|
|
|
|
|
2015-08-19 23:13:18 +02:00
|
|
|
TEST_P(VPxEncoderThreadTest, EncoderResultTest) {
|
2015-02-26 04:09:59 +01:00
|
|
|
::libvpx_test::Y4mVideoSource video("niklas_1280_720_30.y4m", 15, 20);
|
2014-12-16 20:10:20 +01:00
|
|
|
cfg_.rc_target_bitrate = 1000;
|
2017-02-22 21:24:16 +01:00
|
|
|
|
2017-02-27 19:50:02 +01:00
|
|
|
// Part 1: Bit exact test for row_mt_mode_ = 0.
|
2017-03-01 00:13:11 +01:00
|
|
|
// This part keeps original unit tests done before row-mt code is checked in.
|
2017-02-24 20:40:22 +01:00
|
|
|
row_mt_mode_ = 0;
|
2014-12-16 20:10:20 +01:00
|
|
|
|
|
|
|
// Encode using single thread.
|
|
|
|
cfg_.g_threads = 1;
|
|
|
|
init_flags_ = VPX_CODEC_USE_PSNR;
|
|
|
|
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
|
2017-02-22 21:24:16 +01:00
|
|
|
const std::vector<std::string> single_thr_md5 = md5_;
|
2014-12-16 20:10:20 +01:00
|
|
|
md5_.clear();
|
|
|
|
|
|
|
|
// Encode using multiple threads.
|
2016-10-19 20:07:41 +02:00
|
|
|
cfg_.g_threads = threads_;
|
2014-12-16 20:10:20 +01:00
|
|
|
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
|
2017-02-22 21:24:16 +01:00
|
|
|
const std::vector<std::string> multi_thr_md5 = md5_;
|
2014-12-16 20:10:20 +01:00
|
|
|
md5_.clear();
|
|
|
|
|
|
|
|
// Compare to check if two vectors are equal.
|
|
|
|
ASSERT_EQ(single_thr_md5, multi_thr_md5);
|
2017-02-16 14:37:41 +01:00
|
|
|
|
2017-02-27 19:50:02 +01:00
|
|
|
// Part 2: row_mt_mode_ = 0 vs row_mt_mode_ = 1 single thread bit exact test.
|
2017-02-24 20:40:22 +01:00
|
|
|
row_mt_mode_ = 1;
|
2017-02-22 21:24:16 +01:00
|
|
|
|
|
|
|
// Encode using single thread
|
|
|
|
cfg_.g_threads = 1;
|
|
|
|
init_flags_ = VPX_CODEC_USE_PSNR;
|
|
|
|
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
|
2017-02-27 19:50:02 +01:00
|
|
|
std::vector<std::string> row_mt_single_thr_md5 = md5_;
|
2017-02-22 21:24:16 +01:00
|
|
|
md5_.clear();
|
|
|
|
|
2017-02-27 19:50:02 +01:00
|
|
|
ASSERT_EQ(single_thr_md5, row_mt_single_thr_md5);
|
2017-02-22 21:24:16 +01:00
|
|
|
|
2017-03-01 00:13:11 +01:00
|
|
|
// Part 3: Bit exact test with row-mt on
|
2017-04-24 21:06:49 +02:00
|
|
|
// When row_mt_mode_=1 and using >1 threads, the encoder generates bit exact
|
|
|
|
// result.
|
2017-02-24 20:40:22 +01:00
|
|
|
row_mt_mode_ = 1;
|
2017-02-27 19:50:02 +01:00
|
|
|
row_mt_single_thr_md5.clear();
|
2017-02-22 21:24:16 +01:00
|
|
|
|
2017-04-24 21:06:49 +02:00
|
|
|
// Encode using 2 threads.
|
|
|
|
cfg_.g_threads = 2;
|
2017-02-16 14:37:41 +01:00
|
|
|
init_flags_ = VPX_CODEC_USE_PSNR;
|
|
|
|
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
|
2017-02-27 19:50:02 +01:00
|
|
|
row_mt_single_thr_md5 = md5_;
|
2017-02-22 21:24:16 +01:00
|
|
|
md5_.clear();
|
|
|
|
|
|
|
|
// Encode using multiple threads.
|
|
|
|
cfg_.g_threads = threads_;
|
|
|
|
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
|
2017-02-27 19:50:02 +01:00
|
|
|
const std::vector<std::string> row_mt_multi_thr_md5 = md5_;
|
2017-02-16 14:37:41 +01:00
|
|
|
md5_.clear();
|
|
|
|
|
|
|
|
// Compare to check if two vectors are equal.
|
2017-02-27 19:50:02 +01:00
|
|
|
ASSERT_EQ(row_mt_single_thr_md5, row_mt_multi_thr_md5);
|
2017-02-22 21:24:16 +01:00
|
|
|
|
|
|
|
// Part 4: PSNR test with bit_match_mode_ = 0
|
2017-02-24 20:40:22 +01:00
|
|
|
row_mt_mode_ = 1;
|
2017-02-22 21:24:16 +01:00
|
|
|
|
|
|
|
// Encode using single thread.
|
|
|
|
cfg_.g_threads = 1;
|
|
|
|
init_flags_ = VPX_CODEC_USE_PSNR;
|
|
|
|
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
|
|
|
|
const double single_thr_psnr = GetAveragePsnr();
|
|
|
|
|
|
|
|
// Encode using multiple threads.
|
|
|
|
cfg_.g_threads = threads_;
|
|
|
|
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
|
|
|
|
const double multi_thr_psnr = GetAveragePsnr();
|
|
|
|
|
|
|
|
EXPECT_NEAR(single_thr_psnr, multi_thr_psnr, 0.1);
|
2014-12-16 20:10:20 +01:00
|
|
|
}
|
|
|
|
|
2017-01-20 18:15:15 +01:00
|
|
|
INSTANTIATE_TEST_CASE_P(
|
|
|
|
VP9, VPxFirstPassEncoderThreadTest,
|
|
|
|
::testing::Combine(
|
|
|
|
::testing::Values(
|
|
|
|
static_cast<const libvpx_test::CodecFactory *>(&libvpx_test::kVP9)),
|
|
|
|
::testing::Values(::libvpx_test::kTwoPassGood),
|
|
|
|
::testing::Range(0, 4))); // cpu_used
|
|
|
|
|
2016-11-22 16:31:04 +01:00
|
|
|
// Split this into two instantiations so that we can distinguish
|
|
|
|
// between very slow runs ( ie cpu_speed 0 ) vs ones that can be
|
|
|
|
// run nightly by adding Large to the title.
|
|
|
|
INSTANTIATE_TEST_CASE_P(
|
|
|
|
VP9, VPxEncoderThreadTest,
|
|
|
|
::testing::Combine(
|
|
|
|
::testing::Values(
|
|
|
|
static_cast<const libvpx_test::CodecFactory *>(&libvpx_test::kVP9)),
|
|
|
|
::testing::Values(::libvpx_test::kTwoPassGood,
|
|
|
|
::libvpx_test::kOnePassGood,
|
|
|
|
::libvpx_test::kRealTime),
|
2017-03-07 22:58:11 +01:00
|
|
|
::testing::Range(3, 9), // cpu_used
|
2016-11-22 16:31:04 +01:00
|
|
|
::testing::Range(0, 3), // tile_columns
|
|
|
|
::testing::Range(2, 5))); // threads
|
|
|
|
|
|
|
|
INSTANTIATE_TEST_CASE_P(
|
|
|
|
VP9Large, VPxEncoderThreadTest,
|
|
|
|
::testing::Combine(
|
|
|
|
::testing::Values(
|
|
|
|
static_cast<const libvpx_test::CodecFactory *>(&libvpx_test::kVP9)),
|
|
|
|
::testing::Values(::libvpx_test::kTwoPassGood,
|
|
|
|
::libvpx_test::kOnePassGood,
|
|
|
|
::libvpx_test::kRealTime),
|
2017-03-07 22:58:11 +01:00
|
|
|
::testing::Range(0, 3), // cpu_used
|
2016-11-22 16:31:04 +01:00
|
|
|
::testing::Range(0, 3), // tile_columns
|
|
|
|
::testing::Range(2, 5))); // threads
|
|
|
|
|
2014-12-16 20:10:20 +01:00
|
|
|
} // namespace
|