110a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org/* 210a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org * Copyright (c) 2012 The WebM project authors. All Rights Reserved. 310a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org * 410a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org * Use of this source code is governed by a BSD-style license 510a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org * that can be found in the LICENSE file in the root of the source 610a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org * tree. An additional intellectual property rights grant can be found 710a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org * in the file PATENTS. All contributing project authors may 810a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org * be found in the AUTHORS file in the root of the source tree. 910a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org */ 1010a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org#include <climits> 1110a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org#include <vector> 1210a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org#include "third_party/googletest/src/include/gtest/gtest.h" 1310a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org#include "test/codec_factory.h" 1410a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org#include "test/encode_test_driver.h" 1510a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org#include "test/i420_video_source.h" 1610a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org#include "test/util.h" 1710a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org 1810a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.orgnamespace { 1910a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org 2010a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.orgclass BordersTest : public ::libvpx_test::EncoderTest, 2110a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org public ::libvpx_test::CodecTestWithParam<libvpx_test::TestMode> { 2210a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org protected: 2310a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org BordersTest() : EncoderTest(GET_PARAM(0)) {} 2493a74791c8e808ea76001ee07693aa2a5fdd3500johannkoenig@chromium.org virtual ~BordersTest() {} 2510a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org 2610a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org virtual void SetUp() { 2710a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org InitializeConfig(); 2810a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org SetMode(GET_PARAM(1)); 2910a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org } 3010a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org 3110a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video, 3210a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org ::libvpx_test::Encoder *encoder) { 33f9586bb54d74c97d07b09eb2512f8569c9c1c025fgalligan@chromium.org if (video->frame() == 1) { 34a9f5ee7eb0cc3f07fd346cf0c856ab3d1d1971c8fgalligan@chromium.org encoder->Control(VP8E_SET_CPUUSED, 1); 3510a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org encoder->Control(VP8E_SET_ENABLEAUTOALTREF, 1); 3610a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org encoder->Control(VP8E_SET_ARNR_MAXFRAMES, 7); 3710a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org encoder->Control(VP8E_SET_ARNR_STRENGTH, 5); 389a5fccadbf86bd614db22afaff64c794c1e16215fgalligan@chromium.org encoder->Control(VP8E_SET_ARNR_TYPE, 3); 3910a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org } 4010a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org } 4110a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org 4210a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org virtual void FramePktHook(const vpx_codec_cx_pkt_t *pkt) { 4310a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org if (pkt->data.frame.flags & VPX_FRAME_IS_KEY) { 4410a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org } 4510a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org } 4610a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org}; 4710a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org 4810a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.orgTEST_P(BordersTest, TestEncodeHighBitrate) { 4910a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org // Validate that this non multiple of 64 wide clip encodes and decodes 5010a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org // without a mismatch when passing in a very low max q. This pushes 5110a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org // the encoder to producing lots of big partitions which will likely 5210a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org // extend into the border and test the border condition. 5310a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org cfg_.g_lag_in_frames = 25; 5410a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org cfg_.rc_2pass_vbr_minsection_pct = 5; 5510a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org cfg_.rc_2pass_vbr_minsection_pct = 2000; 5610a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org cfg_.rc_target_bitrate = 2000; 5710a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org cfg_.rc_max_quantizer = 10; 5810a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org 5910a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org ::libvpx_test::I420VideoSource video("hantro_odd.yuv", 208, 144, 30, 1, 0, 6010a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org 40); 6110a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org 6210a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); 6310a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org} 6410a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.orgTEST_P(BordersTest, TestLowBitrate) { 6510a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org // Validate that this clip encodes and decodes without a mismatch 6610a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org // when passing in a very high min q. This pushes the encoder to producing 6710a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org // lots of small partitions which might will test the other condition. 6810a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org 6910a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org cfg_.g_lag_in_frames = 25; 7010a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org cfg_.rc_2pass_vbr_minsection_pct = 5; 71d851b91d14ef0bd71acdce7b90c9a8f1af1181adjohannkoenig@chromium.org cfg_.rc_2pass_vbr_maxsection_pct = 2000; 7210a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org cfg_.rc_target_bitrate = 200; 7310a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org cfg_.rc_min_quantizer = 40; 7410a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org 7510a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org ::libvpx_test::I420VideoSource video("hantro_odd.yuv", 208, 144, 30, 1, 0, 7610a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org 40); 7710a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org 7810a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); 7910a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org} 8010a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org 8110a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.orgVP9_INSTANTIATE_TEST_CASE(BordersTest, ::testing::Values( 8210a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org ::libvpx_test::kTwoPassGood)); 8310a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org} // namespace 84