Merge "remove mmx variance functions"
[aom.git] / test / vp9_ethread_test.cc
blobf0b8cef579d01cb102b830949f6af7d95d4e83c4
1 /*
2 * Copyright (c) 2014 The WebM project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
11 #include <string>
12 #include <vector>
13 #include "third_party/googletest/src/include/gtest/gtest.h"
14 #include "test/codec_factory.h"
15 #include "test/encode_test_driver.h"
16 #include "test/md5_helper.h"
17 #include "test/util.h"
18 #include "test/y4m_video_source.h"
20 namespace {
21 class VPxEncoderThreadTest
22 : public ::libvpx_test::EncoderTest,
23 public ::libvpx_test::CodecTestWith2Params<libvpx_test::TestMode, int> {
24 protected:
25 VPxEncoderThreadTest()
26 : EncoderTest(GET_PARAM(0)),
27 encoder_initialized_(false),
28 tiles_(2),
29 encoding_mode_(GET_PARAM(1)),
30 set_cpu_used_(GET_PARAM(2)) {
31 init_flags_ = VPX_CODEC_USE_PSNR;
32 md5_.clear();
34 virtual ~VPxEncoderThreadTest() {}
36 virtual void SetUp() {
37 InitializeConfig();
38 SetMode(encoding_mode_);
40 if (encoding_mode_ != ::libvpx_test::kRealTime) {
41 cfg_.g_lag_in_frames = 3;
42 cfg_.rc_end_usage = VPX_VBR;
43 cfg_.rc_2pass_vbr_minsection_pct = 5;
44 cfg_.rc_2pass_vbr_maxsection_pct = 2000;
45 } else {
46 cfg_.g_lag_in_frames = 0;
47 cfg_.rc_end_usage = VPX_CBR;
48 cfg_.g_error_resilient = 1;
50 cfg_.rc_max_quantizer = 56;
51 cfg_.rc_min_quantizer = 0;
54 virtual void BeginPassHook(unsigned int /*pass*/) {
55 encoder_initialized_ = false;
58 virtual void PreEncodeFrameHook(::libvpx_test::VideoSource * /*video*/,
59 ::libvpx_test::Encoder *encoder) {
60 if (!encoder_initialized_) {
61 // Encode 4 column tiles.
62 encoder->Control(VP9E_SET_TILE_COLUMNS, tiles_);
63 encoder->Control(VP8E_SET_CPUUSED, set_cpu_used_);
64 if (encoding_mode_ != ::libvpx_test::kRealTime) {
65 encoder->Control(VP8E_SET_ENABLEAUTOALTREF, 1);
66 encoder->Control(VP8E_SET_ARNR_MAXFRAMES, 7);
67 encoder->Control(VP8E_SET_ARNR_STRENGTH, 5);
68 encoder->Control(VP8E_SET_ARNR_TYPE, 3);
69 } else {
70 encoder->Control(VP8E_SET_ENABLEAUTOALTREF, 0);
71 encoder->Control(VP9E_SET_AQ_MODE, 3);
73 encoder_initialized_ = true;
77 virtual void DecompressedFrameHook(const vpx_image_t &img,
78 vpx_codec_pts_t /*pts*/) {
79 ::libvpx_test::MD5 md5_res;
80 md5_res.Add(&img);
81 md5_.push_back(md5_res.Get());
84 virtual bool HandleDecodeResult(const vpx_codec_err_t res,
85 const libvpx_test::VideoSource& /*video*/,
86 libvpx_test::Decoder * /*decoder*/) {
87 if (res != VPX_CODEC_OK) {
88 EXPECT_EQ(VPX_CODEC_OK, res);
89 return false;
92 return true;
95 bool encoder_initialized_;
96 int tiles_;
97 ::libvpx_test::TestMode encoding_mode_;
98 int set_cpu_used_;
99 std::vector<std::string> md5_;
102 TEST_P(VPxEncoderThreadTest, EncoderResultTest) {
103 std::vector<std::string> single_thr_md5, multi_thr_md5;
105 ::libvpx_test::Y4mVideoSource video("niklas_1280_720_30.y4m", 15, 20);
107 cfg_.rc_target_bitrate = 1000;
109 // Encode using single thread.
110 cfg_.g_threads = 1;
111 init_flags_ = VPX_CODEC_USE_PSNR;
112 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
113 single_thr_md5 = md5_;
114 md5_.clear();
116 // Encode using multiple threads.
117 cfg_.g_threads = 4;
118 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
119 multi_thr_md5 = md5_;
120 md5_.clear();
122 // Compare to check if two vectors are equal.
123 ASSERT_EQ(single_thr_md5, multi_thr_md5);
126 VP9_INSTANTIATE_TEST_CASE(
127 VPxEncoderThreadTest,
128 ::testing::Values(::libvpx_test::kTwoPassGood, ::libvpx_test::kOnePassGood,
129 ::libvpx_test::kRealTime),
130 ::testing::Range(1, 9));
132 VP10_INSTANTIATE_TEST_CASE(
133 VPxEncoderThreadTest,
134 ::testing::Values(::libvpx_test::kTwoPassGood, ::libvpx_test::kOnePassGood),
135 ::testing::Range(1, 3));
136 } // namespace