2014-07-21 21:57:16 +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.
|
|
|
|
*/
|
2014-12-19 22:21:52 +03:00
|
|
|
#include <string>
|
2014-07-21 21:57:16 +04:00
|
|
|
#include "third_party/googletest/src/include/gtest/gtest.h"
|
2016-08-31 00:01:10 +03:00
|
|
|
#include "./aom_config.h"
|
|
|
|
#include "./aom_version.h"
|
2014-07-21 21:57:16 +04:00
|
|
|
#include "test/codec_factory.h"
|
|
|
|
#include "test/encode_test_driver.h"
|
|
|
|
#include "test/i420_video_source.h"
|
|
|
|
#include "test/util.h"
|
|
|
|
#include "test/y4m_video_source.h"
|
2016-08-31 00:01:10 +03:00
|
|
|
#include "aom_ports/aom_timer.h"
|
2014-07-21 21:57:16 +04:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
const int kMaxPsnr = 100;
|
|
|
|
const double kUsecsInSec = 1000000.0;
|
|
|
|
|
|
|
|
struct EncodePerfTestVideo {
|
|
|
|
EncodePerfTestVideo(const char *name_, uint32_t width_, uint32_t height_,
|
|
|
|
uint32_t bitrate_, int frames_)
|
2016-08-12 03:46:05 +03:00
|
|
|
: name(name_), width(width_), height(height_), bitrate(bitrate_),
|
2014-07-21 21:57:16 +04:00
|
|
|
frames(frames_) {}
|
|
|
|
const char *name;
|
|
|
|
uint32_t width;
|
|
|
|
uint32_t height;
|
|
|
|
uint32_t bitrate;
|
|
|
|
int frames;
|
|
|
|
};
|
|
|
|
|
2016-08-31 00:01:10 +03:00
|
|
|
const EncodePerfTestVideo kAV1EncodePerfTestVectors[] = {
|
2014-07-21 21:57:16 +04:00
|
|
|
EncodePerfTestVideo("desktop_640_360_30.yuv", 640, 360, 200, 2484),
|
|
|
|
EncodePerfTestVideo("kirland_640_480_30.yuv", 640, 480, 200, 300),
|
|
|
|
EncodePerfTestVideo("macmarcomoving_640_480_30.yuv", 640, 480, 200, 987),
|
|
|
|
EncodePerfTestVideo("macmarcostationary_640_480_30.yuv", 640, 480, 200, 718),
|
|
|
|
EncodePerfTestVideo("niklas_640_480_30.yuv", 640, 480, 200, 471),
|
|
|
|
EncodePerfTestVideo("tacomanarrows_640_480_30.yuv", 640, 480, 200, 300),
|
2016-08-12 03:46:05 +03:00
|
|
|
EncodePerfTestVideo("tacomasmallcameramovement_640_480_30.yuv", 640, 480, 200,
|
|
|
|
300),
|
2014-07-21 21:57:16 +04:00
|
|
|
EncodePerfTestVideo("thaloundeskmtg_640_480_30.yuv", 640, 480, 200, 300),
|
|
|
|
EncodePerfTestVideo("niklas_1280_720_30.yuv", 1280, 720, 600, 470),
|
|
|
|
};
|
|
|
|
|
2014-12-19 02:19:21 +03:00
|
|
|
const int kEncodePerfTestSpeeds[] = { 5, 6, 7, 8 };
|
2014-12-19 22:21:52 +03:00
|
|
|
const int kEncodePerfTestThreads[] = { 1, 2, 4 };
|
2014-07-21 21:57:16 +04:00
|
|
|
|
|
|
|
#define NELEMENTS(x) (sizeof((x)) / sizeof((x)[0]))
|
|
|
|
|
2016-08-31 00:01:10 +03:00
|
|
|
class AV1EncodePerfTest
|
2016-08-23 02:08:15 +03:00
|
|
|
: public ::libaom_test::EncoderTest,
|
|
|
|
public ::libaom_test::CodecTestWithParam<libaom_test::TestMode> {
|
2014-07-21 21:57:16 +04:00
|
|
|
protected:
|
2016-08-31 00:01:10 +03:00
|
|
|
AV1EncodePerfTest()
|
2016-08-12 03:46:05 +03:00
|
|
|
: EncoderTest(GET_PARAM(0)), min_psnr_(kMaxPsnr), nframes_(0),
|
|
|
|
encoding_mode_(GET_PARAM(1)), speed_(0), threads_(1) {}
|
2014-07-21 21:57:16 +04:00
|
|
|
|
2016-08-31 00:01:10 +03:00
|
|
|
virtual ~AV1EncodePerfTest() {}
|
2014-07-21 21:57:16 +04:00
|
|
|
|
|
|
|
virtual void SetUp() {
|
|
|
|
InitializeConfig();
|
|
|
|
SetMode(encoding_mode_);
|
|
|
|
|
|
|
|
cfg_.g_lag_in_frames = 0;
|
|
|
|
cfg_.rc_min_quantizer = 2;
|
|
|
|
cfg_.rc_max_quantizer = 56;
|
|
|
|
cfg_.rc_dropframe_thresh = 0;
|
|
|
|
cfg_.rc_undershoot_pct = 50;
|
|
|
|
cfg_.rc_overshoot_pct = 50;
|
|
|
|
cfg_.rc_buf_sz = 1000;
|
|
|
|
cfg_.rc_buf_initial_sz = 500;
|
|
|
|
cfg_.rc_buf_optimal_sz = 600;
|
|
|
|
cfg_.rc_resize_allowed = 0;
|
2016-08-31 00:01:10 +03:00
|
|
|
cfg_.rc_end_usage = AOM_CBR;
|
2014-12-19 22:21:52 +03:00
|
|
|
cfg_.g_error_resilient = 1;
|
|
|
|
cfg_.g_threads = threads_;
|
2014-07-21 21:57:16 +04:00
|
|
|
}
|
|
|
|
|
2016-08-23 02:08:15 +03:00
|
|
|
virtual void PreEncodeFrameHook(::libaom_test::VideoSource *video,
|
|
|
|
::libaom_test::Encoder *encoder) {
|
2014-12-19 22:21:52 +03:00
|
|
|
if (video->frame() == 0) {
|
|
|
|
const int log2_tile_columns = 3;
|
2016-08-31 00:01:10 +03:00
|
|
|
encoder->Control(AOME_SET_CPUUSED, speed_);
|
|
|
|
encoder->Control(AV1E_SET_TILE_COLUMNS, log2_tile_columns);
|
|
|
|
encoder->Control(AV1E_SET_FRAME_PARALLEL_DECODING, 1);
|
|
|
|
encoder->Control(AOME_SET_ENABLEAUTOALTREF, 0);
|
2014-07-21 21:57:16 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void BeginPassHook(unsigned int /*pass*/) {
|
|
|
|
min_psnr_ = kMaxPsnr;
|
|
|
|
nframes_ = 0;
|
|
|
|
}
|
|
|
|
|
2016-08-31 00:01:10 +03:00
|
|
|
virtual void PSNRPktHook(const aom_codec_cx_pkt_t *pkt) {
|
2014-07-21 21:57:16 +04:00
|
|
|
if (pkt->data.psnr.psnr[0] < min_psnr_) {
|
2016-08-12 03:46:05 +03:00
|
|
|
min_psnr_ = pkt->data.psnr.psnr[0];
|
2014-07-21 21:57:16 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// for performance reasons don't decode
|
|
|
|
virtual bool DoDecode() { return 0; }
|
|
|
|
|
2016-08-12 03:46:05 +03:00
|
|
|
double min_psnr() const { return min_psnr_; }
|
2014-07-21 21:57:16 +04:00
|
|
|
|
2016-08-12 03:46:05 +03:00
|
|
|
void set_speed(unsigned int speed) { speed_ = speed; }
|
2014-07-21 21:57:16 +04:00
|
|
|
|
2016-08-12 03:46:05 +03:00
|
|
|
void set_threads(unsigned int threads) { threads_ = threads; }
|
2014-12-19 22:21:52 +03:00
|
|
|
|
2014-07-21 21:57:16 +04:00
|
|
|
private:
|
|
|
|
double min_psnr_;
|
|
|
|
unsigned int nframes_;
|
2016-08-23 02:08:15 +03:00
|
|
|
libaom_test::TestMode encoding_mode_;
|
2014-07-21 21:57:16 +04:00
|
|
|
unsigned speed_;
|
2014-12-19 22:21:52 +03:00
|
|
|
unsigned int threads_;
|
2014-07-21 21:57:16 +04:00
|
|
|
};
|
|
|
|
|
2016-08-31 00:01:10 +03:00
|
|
|
TEST_P(AV1EncodePerfTest, PerfTest) {
|
|
|
|
for (size_t i = 0; i < NELEMENTS(kAV1EncodePerfTestVectors); ++i) {
|
2014-07-21 21:57:16 +04:00
|
|
|
for (size_t j = 0; j < NELEMENTS(kEncodePerfTestSpeeds); ++j) {
|
2014-12-19 22:21:52 +03:00
|
|
|
for (size_t k = 0; k < NELEMENTS(kEncodePerfTestThreads); ++k) {
|
2016-08-31 00:01:10 +03:00
|
|
|
if (kAV1EncodePerfTestVectors[i].width < 512 &&
|
2014-12-19 22:21:52 +03:00
|
|
|
kEncodePerfTestThreads[k] > 1)
|
|
|
|
continue;
|
2016-08-31 00:01:10 +03:00
|
|
|
else if (kAV1EncodePerfTestVectors[i].width < 1024 &&
|
2014-12-19 22:21:52 +03:00
|
|
|
kEncodePerfTestThreads[k] > 2)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
set_threads(kEncodePerfTestThreads[k]);
|
|
|
|
SetUp();
|
|
|
|
|
2016-08-31 00:01:10 +03:00
|
|
|
const aom_rational timebase = { 33333333, 1000000000 };
|
2014-12-19 22:21:52 +03:00
|
|
|
cfg_.g_timebase = timebase;
|
2016-08-31 00:01:10 +03:00
|
|
|
cfg_.rc_target_bitrate = kAV1EncodePerfTestVectors[i].bitrate;
|
2014-12-19 22:21:52 +03:00
|
|
|
|
2016-08-31 00:01:10 +03:00
|
|
|
init_flags_ = AOM_CODEC_USE_PSNR;
|
2014-12-19 22:21:52 +03:00
|
|
|
|
2016-08-31 00:01:10 +03:00
|
|
|
const unsigned frames = kAV1EncodePerfTestVectors[i].frames;
|
|
|
|
const char *video_name = kAV1EncodePerfTestVectors[i].name;
|
2016-08-23 02:08:15 +03:00
|
|
|
libaom_test::I420VideoSource video(
|
2016-08-31 00:01:10 +03:00
|
|
|
video_name, kAV1EncodePerfTestVectors[i].width,
|
|
|
|
kAV1EncodePerfTestVectors[i].height, timebase.den, timebase.num, 0,
|
|
|
|
kAV1EncodePerfTestVectors[i].frames);
|
2014-12-19 22:21:52 +03:00
|
|
|
set_speed(kEncodePerfTestSpeeds[j]);
|
|
|
|
|
2016-08-31 00:01:10 +03:00
|
|
|
aom_usec_timer t;
|
|
|
|
aom_usec_timer_start(&t);
|
2014-12-19 22:21:52 +03:00
|
|
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
|
|
|
|
|
2016-08-31 00:01:10 +03:00
|
|
|
aom_usec_timer_mark(&t);
|
|
|
|
const double elapsed_secs = aom_usec_timer_elapsed(&t) / kUsecsInSec;
|
2014-12-19 22:21:52 +03:00
|
|
|
const double fps = frames / elapsed_secs;
|
|
|
|
const double minimum_psnr = min_psnr();
|
|
|
|
std::string display_name(video_name);
|
|
|
|
if (kEncodePerfTestThreads[k] > 1) {
|
|
|
|
char thread_count[32];
|
|
|
|
snprintf(thread_count, sizeof(thread_count), "_t-%d",
|
|
|
|
kEncodePerfTestThreads[k]);
|
|
|
|
display_name += thread_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("{\n");
|
|
|
|
printf("\t\"type\" : \"encode_perf_test\",\n");
|
|
|
|
printf("\t\"version\" : \"%s\",\n", VERSION_STRING_NOSP);
|
|
|
|
printf("\t\"videoName\" : \"%s\",\n", display_name.c_str());
|
|
|
|
printf("\t\"encodeTimeSecs\" : %f,\n", elapsed_secs);
|
|
|
|
printf("\t\"totalFrames\" : %u,\n", frames);
|
|
|
|
printf("\t\"framesPerSecond\" : %f,\n", fps);
|
|
|
|
printf("\t\"minPsnr\" : %f,\n", minimum_psnr);
|
2015-01-06 22:06:33 +03:00
|
|
|
printf("\t\"speed\" : %d,\n", kEncodePerfTestSpeeds[j]);
|
2014-12-19 22:21:52 +03:00
|
|
|
printf("\t\"threads\" : %d\n", kEncodePerfTestThreads[k]);
|
|
|
|
printf("}\n");
|
|
|
|
}
|
2014-07-21 21:57:16 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-31 00:01:10 +03:00
|
|
|
AV1_INSTANTIATE_TEST_CASE(AV1EncodePerfTest,
|
|
|
|
::testing::Values(::libaom_test::kRealTime));
|
2014-07-21 21:57:16 +04:00
|
|
|
} // namespace
|