1 /*
2 * Copyright (c) 2023, Alliance for Open Media. All rights reserved.
3 *
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.
10 */
11
12 #include "test/codec_factory.h"
13 #include "test/encode_test_driver.h"
14 #include "test/i420_video_source.h"
15 #include "test/util.h"
16
17 namespace {
18
19 // Params: test mode, threads.
20 class DropFrameEncodeTestLarge
21 : public ::libaom_test::CodecTestWith2Params<libaom_test::TestMode,
22 unsigned int>,
23 public ::libaom_test::EncoderTest {
24 protected:
DropFrameEncodeTestLarge()25 DropFrameEncodeTestLarge()
26 : EncoderTest(GET_PARAM(0)), frame_number_(0), threads_(GET_PARAM(2)) {}
27
SetUp()28 void SetUp() override { InitializeConfig(GET_PARAM(1)); }
29
PreEncodeFrameHook(::libaom_test::VideoSource * video,::libaom_test::Encoder * encoder)30 void PreEncodeFrameHook(::libaom_test::VideoSource *video,
31 ::libaom_test::Encoder *encoder) override {
32 frame_number_ = video->frame();
33 if (frame_number_ == 0) {
34 encoder->Control(AOME_SET_CPUUSED, 1);
35 }
36 }
37
38 unsigned int frame_number_;
39 unsigned int threads_;
40 };
41
42 // Test to reproduce the assertion failure related to buf->display_idx in
43 // init_gop_frames_for_tpl() and segmentation fault reported in aomedia:3372
44 // while encoding with --drop-frame=1.
TEST_P(DropFrameEncodeTestLarge,TestNoMisMatch)45 TEST_P(DropFrameEncodeTestLarge, TestNoMisMatch) {
46 cfg_.rc_end_usage = AOM_CBR;
47 cfg_.rc_buf_sz = 1;
48 cfg_.g_pass = AOM_RC_ONE_PASS;
49 cfg_.rc_dropframe_thresh = 1;
50 cfg_.g_threads = threads_;
51
52 ::libaom_test::I420VideoSource video("desktopqvga2.320_240.yuv", 320, 240, 30,
53 1, 0, 100);
54
55 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
56 }
57
58 AV1_INSTANTIATE_TEST_SUITE(DropFrameEncodeTestLarge,
59 ::testing::Values(::libaom_test::kOnePassGood),
60 ::testing::Values(1, 4));
61
62 } // namespace
63