scalability_test.cc (3024B)
1 /* 2 * Copyright (c) 2018, 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 "gtest/gtest.h" 13 #include "test/codec_factory.h" 14 #include "test/encode_test_driver.h" 15 #include "test/i420_video_source.h" 16 #include "test/util.h" 17 18 namespace { 19 20 const int kCpuUsed = 8; 21 const int kBaseLayerQp = 55; 22 const int kEnhancementLayerQp = 20; 23 24 class ScalabilityTest 25 : public ::libaom_test::CodecTestWithParam<libaom_test::TestMode>, 26 public ::libaom_test::EncoderTest { 27 protected: 28 ScalabilityTest() : EncoderTest(GET_PARAM(0)) {} 29 ~ScalabilityTest() override = default; 30 31 void SetUp() override { 32 InitializeConfig(GET_PARAM(1)); 33 num_spatial_layers_ = 2; 34 } 35 36 void PreEncodeFrameHook(::libaom_test::VideoSource *video, 37 ::libaom_test::Encoder *encoder) override { 38 if (video->frame() == 0) { 39 encoder->Control(AOME_SET_CPUUSED, kCpuUsed); 40 encoder->Control(AOME_SET_NUMBER_SPATIAL_LAYERS, num_spatial_layers_); 41 } 42 if (video->frame() % num_spatial_layers_) { 43 frame_flags_ = AOM_EFLAG_NO_REF_LAST2 | AOM_EFLAG_NO_REF_LAST3 | 44 AOM_EFLAG_NO_REF_GF | AOM_EFLAG_NO_REF_ARF | 45 AOM_EFLAG_NO_REF_BWD | AOM_EFLAG_NO_REF_ARF2 | 46 AOM_EFLAG_NO_UPD_LAST | AOM_EFLAG_NO_UPD_GF | 47 AOM_EFLAG_NO_UPD_ARF | AOM_EFLAG_NO_UPD_ENTROPY; 48 encoder->Control(AOME_SET_SPATIAL_LAYER_ID, 1); 49 encoder->Control(AOME_SET_CQ_LEVEL, kEnhancementLayerQp); 50 } else { 51 frame_flags_ = AOM_EFLAG_NO_REF_LAST2 | AOM_EFLAG_NO_REF_LAST3 | 52 AOM_EFLAG_NO_REF_GF | AOM_EFLAG_NO_REF_ARF | 53 AOM_EFLAG_NO_REF_BWD | AOM_EFLAG_NO_REF_ARF2 | 54 AOM_EFLAG_NO_UPD_GF | AOM_EFLAG_NO_UPD_ARF | 55 AOM_EFLAG_NO_UPD_ENTROPY; 56 encoder->Control(AOME_SET_SPATIAL_LAYER_ID, 0); 57 encoder->Control(AOME_SET_CQ_LEVEL, kBaseLayerQp); 58 } 59 } 60 61 void DoTest(int num_spatial_layers) { 62 num_spatial_layers_ = num_spatial_layers; 63 cfg_.rc_end_usage = AOM_Q; 64 cfg_.g_lag_in_frames = 0; 65 66 ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 67 288, 30, 1, 0, 18); 68 ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); 69 } 70 71 int num_spatial_layers_; 72 }; 73 74 TEST_P(ScalabilityTest, TestNoMismatch2SpatialLayers) { DoTest(2); } 75 76 TEST_P(ScalabilityTest, TestNoMismatch3SpatialLayers) { DoTest(3); } 77 78 AV1_INSTANTIATE_TEST_SUITE(ScalabilityTest, 79 ::testing::Values(::libaom_test::kRealTime)); 80 81 } // namespace