xref: /aosp_15_r20/external/libaom/test/dropframe_encode_test.cc (revision 77c1e3ccc04c968bd2bc212e87364f250e820521)
1*77c1e3ccSAndroid Build Coastguard Worker /*
2*77c1e3ccSAndroid Build Coastguard Worker  * Copyright (c) 2023, Alliance for Open Media. All rights reserved.
3*77c1e3ccSAndroid Build Coastguard Worker  *
4*77c1e3ccSAndroid Build Coastguard Worker  * This source code is subject to the terms of the BSD 2 Clause License and
5*77c1e3ccSAndroid Build Coastguard Worker  * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6*77c1e3ccSAndroid Build Coastguard Worker  * was not distributed with this source code in the LICENSE file, you can
7*77c1e3ccSAndroid Build Coastguard Worker  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8*77c1e3ccSAndroid Build Coastguard Worker  * Media Patent License 1.0 was not distributed with this source code in the
9*77c1e3ccSAndroid Build Coastguard Worker  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10*77c1e3ccSAndroid Build Coastguard Worker  */
11*77c1e3ccSAndroid Build Coastguard Worker 
12*77c1e3ccSAndroid Build Coastguard Worker #include "test/codec_factory.h"
13*77c1e3ccSAndroid Build Coastguard Worker #include "test/encode_test_driver.h"
14*77c1e3ccSAndroid Build Coastguard Worker #include "test/i420_video_source.h"
15*77c1e3ccSAndroid Build Coastguard Worker #include "test/util.h"
16*77c1e3ccSAndroid Build Coastguard Worker 
17*77c1e3ccSAndroid Build Coastguard Worker namespace {
18*77c1e3ccSAndroid Build Coastguard Worker 
19*77c1e3ccSAndroid Build Coastguard Worker // Params: test mode, threads.
20*77c1e3ccSAndroid Build Coastguard Worker class DropFrameEncodeTestLarge
21*77c1e3ccSAndroid Build Coastguard Worker     : public ::libaom_test::CodecTestWith2Params<libaom_test::TestMode,
22*77c1e3ccSAndroid Build Coastguard Worker                                                  unsigned int>,
23*77c1e3ccSAndroid Build Coastguard Worker       public ::libaom_test::EncoderTest {
24*77c1e3ccSAndroid Build Coastguard Worker  protected:
DropFrameEncodeTestLarge()25*77c1e3ccSAndroid Build Coastguard Worker   DropFrameEncodeTestLarge()
26*77c1e3ccSAndroid Build Coastguard Worker       : EncoderTest(GET_PARAM(0)), frame_number_(0), threads_(GET_PARAM(2)) {}
27*77c1e3ccSAndroid Build Coastguard Worker 
SetUp()28*77c1e3ccSAndroid Build Coastguard Worker   void SetUp() override { InitializeConfig(GET_PARAM(1)); }
29*77c1e3ccSAndroid Build Coastguard Worker 
PreEncodeFrameHook(::libaom_test::VideoSource * video,::libaom_test::Encoder * encoder)30*77c1e3ccSAndroid Build Coastguard Worker   void PreEncodeFrameHook(::libaom_test::VideoSource *video,
31*77c1e3ccSAndroid Build Coastguard Worker                           ::libaom_test::Encoder *encoder) override {
32*77c1e3ccSAndroid Build Coastguard Worker     frame_number_ = video->frame();
33*77c1e3ccSAndroid Build Coastguard Worker     if (frame_number_ == 0) {
34*77c1e3ccSAndroid Build Coastguard Worker       encoder->Control(AOME_SET_CPUUSED, 1);
35*77c1e3ccSAndroid Build Coastguard Worker     }
36*77c1e3ccSAndroid Build Coastguard Worker   }
37*77c1e3ccSAndroid Build Coastguard Worker 
38*77c1e3ccSAndroid Build Coastguard Worker   unsigned int frame_number_;
39*77c1e3ccSAndroid Build Coastguard Worker   unsigned int threads_;
40*77c1e3ccSAndroid Build Coastguard Worker };
41*77c1e3ccSAndroid Build Coastguard Worker 
42*77c1e3ccSAndroid Build Coastguard Worker // Test to reproduce the assertion failure related to buf->display_idx in
43*77c1e3ccSAndroid Build Coastguard Worker // init_gop_frames_for_tpl() and segmentation fault reported in aomedia:3372
44*77c1e3ccSAndroid Build Coastguard Worker // while encoding with --drop-frame=1.
TEST_P(DropFrameEncodeTestLarge,TestNoMisMatch)45*77c1e3ccSAndroid Build Coastguard Worker TEST_P(DropFrameEncodeTestLarge, TestNoMisMatch) {
46*77c1e3ccSAndroid Build Coastguard Worker   cfg_.rc_end_usage = AOM_CBR;
47*77c1e3ccSAndroid Build Coastguard Worker   cfg_.rc_buf_sz = 1;
48*77c1e3ccSAndroid Build Coastguard Worker   cfg_.g_pass = AOM_RC_ONE_PASS;
49*77c1e3ccSAndroid Build Coastguard Worker   cfg_.rc_dropframe_thresh = 1;
50*77c1e3ccSAndroid Build Coastguard Worker   cfg_.g_threads = threads_;
51*77c1e3ccSAndroid Build Coastguard Worker 
52*77c1e3ccSAndroid Build Coastguard Worker   ::libaom_test::I420VideoSource video("desktopqvga2.320_240.yuv", 320, 240, 30,
53*77c1e3ccSAndroid Build Coastguard Worker                                        1, 0, 100);
54*77c1e3ccSAndroid Build Coastguard Worker 
55*77c1e3ccSAndroid Build Coastguard Worker   ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
56*77c1e3ccSAndroid Build Coastguard Worker }
57*77c1e3ccSAndroid Build Coastguard Worker 
58*77c1e3ccSAndroid Build Coastguard Worker AV1_INSTANTIATE_TEST_SUITE(DropFrameEncodeTestLarge,
59*77c1e3ccSAndroid Build Coastguard Worker                            ::testing::Values(::libaom_test::kOnePassGood),
60*77c1e3ccSAndroid Build Coastguard Worker                            ::testing::Values(1, 4));
61*77c1e3ccSAndroid Build Coastguard Worker 
62*77c1e3ccSAndroid Build Coastguard Worker }  // namespace
63