av1_convolve_ x,y _avx2() -- use 256 bit load/store
[aom.git] / test / encode_perf_test.cc
blob5a37b480b471455900ed7aaa76184bbdb099f3ea
1 /*
2 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
4 * This source code is subject to the terms of the BSD 2 Clause License and
5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 * was not distributed with this source code in the LICENSE file, you can
7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 * Media Patent License 1.0 was not distributed with this source code in the
9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
12 #include <string>
13 #include "third_party/googletest/src/googletest/include/gtest/gtest.h"
14 #include "./aom_config.h"
15 #include "./aom_version.h"
16 #include "test/codec_factory.h"
17 #include "test/encode_test_driver.h"
18 #include "test/i420_video_source.h"
19 #include "test/util.h"
20 #include "test/y4m_video_source.h"
21 #include "aom_ports/aom_timer.h"
23 namespace {
25 const int kMaxPsnr = 100;
26 const double kUsecsInSec = 1000000.0;
28 struct EncodePerfTestVideo {
29 EncodePerfTestVideo(const char *name_, uint32_t width_, uint32_t height_,
30 uint32_t bitrate_, int frames_)
31 : name(name_), width(width_), height(height_), bitrate(bitrate_),
32 frames(frames_) {}
33 const char *name;
34 uint32_t width;
35 uint32_t height;
36 uint32_t bitrate;
37 int frames;
40 const EncodePerfTestVideo kAV1EncodePerfTestVectors[] = {
41 EncodePerfTestVideo("desktop_640_360_30.yuv", 640, 360, 200, 2484),
42 EncodePerfTestVideo("kirland_640_480_30.yuv", 640, 480, 200, 300),
43 EncodePerfTestVideo("macmarcomoving_640_480_30.yuv", 640, 480, 200, 987),
44 EncodePerfTestVideo("macmarcostationary_640_480_30.yuv", 640, 480, 200, 718),
45 EncodePerfTestVideo("niklas_640_480_30.yuv", 640, 480, 200, 471),
46 EncodePerfTestVideo("tacomanarrows_640_480_30.yuv", 640, 480, 200, 300),
47 EncodePerfTestVideo("tacomasmallcameramovement_640_480_30.yuv", 640, 480, 200,
48 300),
49 EncodePerfTestVideo("thaloundeskmtg_640_480_30.yuv", 640, 480, 200, 300),
50 EncodePerfTestVideo("niklas_1280_720_30.yuv", 1280, 720, 600, 470),
53 const int kEncodePerfTestSpeeds[] = { 5, 6, 7, 8 };
54 const int kEncodePerfTestThreads[] = { 1, 2, 4 };
56 class AV1EncodePerfTest
57 : public ::libaom_test::CodecTestWithParam<libaom_test::TestMode>,
58 public ::libaom_test::EncoderTest {
59 protected:
60 AV1EncodePerfTest()
61 : EncoderTest(GET_PARAM(0)), min_psnr_(kMaxPsnr), nframes_(0),
62 encoding_mode_(GET_PARAM(1)), speed_(0), threads_(1) {}
64 virtual ~AV1EncodePerfTest() {}
66 virtual void SetUp() {
67 InitializeConfig();
68 SetMode(encoding_mode_);
70 cfg_.g_lag_in_frames = 0;
71 cfg_.rc_min_quantizer = 2;
72 cfg_.rc_max_quantizer = 56;
73 cfg_.rc_dropframe_thresh = 0;
74 cfg_.rc_undershoot_pct = 50;
75 cfg_.rc_overshoot_pct = 50;
76 cfg_.rc_buf_sz = 1000;
77 cfg_.rc_buf_initial_sz = 500;
78 cfg_.rc_buf_optimal_sz = 600;
79 cfg_.rc_end_usage = AOM_CBR;
80 cfg_.g_error_resilient = 1;
81 cfg_.g_threads = threads_;
84 virtual void PreEncodeFrameHook(::libaom_test::VideoSource *video,
85 ::libaom_test::Encoder *encoder) {
86 if (video->frame() == 0) {
87 const int log2_tile_columns = 3;
88 encoder->Control(AOME_SET_CPUUSED, speed_);
89 encoder->Control(AV1E_SET_TILE_COLUMNS, log2_tile_columns);
90 encoder->Control(AV1E_SET_FRAME_PARALLEL_DECODING, 1);
91 encoder->Control(AOME_SET_ENABLEAUTOALTREF, 0);
95 virtual void BeginPassHook(unsigned int /*pass*/) {
96 min_psnr_ = kMaxPsnr;
97 nframes_ = 0;
100 virtual void PSNRPktHook(const aom_codec_cx_pkt_t *pkt) {
101 if (pkt->data.psnr.psnr[0] < min_psnr_) {
102 min_psnr_ = pkt->data.psnr.psnr[0];
106 // for performance reasons don't decode
107 virtual bool DoDecode() { return 0; }
109 double min_psnr() const { return min_psnr_; }
111 void set_speed(unsigned int speed) { speed_ = speed; }
113 void set_threads(unsigned int threads) { threads_ = threads; }
115 private:
116 double min_psnr_;
117 unsigned int nframes_;
118 libaom_test::TestMode encoding_mode_;
119 unsigned speed_;
120 unsigned int threads_;
123 TEST_P(AV1EncodePerfTest, PerfTest) {
124 for (size_t i = 0; i < NELEMENTS(kAV1EncodePerfTestVectors); ++i) {
125 for (size_t j = 0; j < NELEMENTS(kEncodePerfTestSpeeds); ++j) {
126 for (size_t k = 0; k < NELEMENTS(kEncodePerfTestThreads); ++k) {
127 if (kAV1EncodePerfTestVectors[i].width < 512 &&
128 kEncodePerfTestThreads[k] > 1)
129 continue;
130 else if (kAV1EncodePerfTestVectors[i].width < 1024 &&
131 kEncodePerfTestThreads[k] > 2)
132 continue;
134 set_threads(kEncodePerfTestThreads[k]);
135 SetUp();
137 const aom_rational timebase = { 33333333, 1000000000 };
138 cfg_.g_timebase = timebase;
139 cfg_.rc_target_bitrate = kAV1EncodePerfTestVectors[i].bitrate;
141 init_flags_ = AOM_CODEC_USE_PSNR;
143 const unsigned frames = kAV1EncodePerfTestVectors[i].frames;
144 const char *video_name = kAV1EncodePerfTestVectors[i].name;
145 libaom_test::I420VideoSource video(
146 video_name, kAV1EncodePerfTestVectors[i].width,
147 kAV1EncodePerfTestVectors[i].height, timebase.den, timebase.num, 0,
148 kAV1EncodePerfTestVectors[i].frames);
149 set_speed(kEncodePerfTestSpeeds[j]);
151 aom_usec_timer t;
152 aom_usec_timer_start(&t);
154 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
156 aom_usec_timer_mark(&t);
157 const double elapsed_secs = aom_usec_timer_elapsed(&t) / kUsecsInSec;
158 const double fps = frames / elapsed_secs;
159 const double minimum_psnr = min_psnr();
160 std::string display_name(video_name);
161 if (kEncodePerfTestThreads[k] > 1) {
162 char thread_count[32];
163 snprintf(thread_count, sizeof(thread_count), "_t-%d",
164 kEncodePerfTestThreads[k]);
165 display_name += thread_count;
168 printf("{\n");
169 printf("\t\"type\" : \"encode_perf_test\",\n");
170 printf("\t\"version\" : \"%s\",\n", VERSION_STRING_NOSP);
171 printf("\t\"videoName\" : \"%s\",\n", display_name.c_str());
172 printf("\t\"encodeTimeSecs\" : %f,\n", elapsed_secs);
173 printf("\t\"totalFrames\" : %u,\n", frames);
174 printf("\t\"framesPerSecond\" : %f,\n", fps);
175 printf("\t\"minPsnr\" : %f,\n", minimum_psnr);
176 printf("\t\"speed\" : %d,\n", kEncodePerfTestSpeeds[j]);
177 printf("\t\"threads\" : %d\n", kEncodePerfTestThreads[k]);
178 printf("}\n");
184 AV1_INSTANTIATE_TEST_CASE(AV1EncodePerfTest,
185 ::testing::Values(::libaom_test::kRealTime));
186 } // namespace