• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "third_party/googletest/src/googletest/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:
ScalabilityTest()28   ScalabilityTest() : EncoderTest(GET_PARAM(0)) {}
~ScalabilityTest()29   virtual ~ScalabilityTest() {}
30 
SetUp()31   virtual void SetUp() {
32     InitializeConfig(GET_PARAM(1));
33     num_spatial_layers_ = 2;
34   }
35 
PreEncodeFrameHook(::libaom_test::VideoSource * video,::libaom_test::Encoder * encoder)36   virtual void PreEncodeFrameHook(::libaom_test::VideoSource *video,
37                                   ::libaom_test::Encoder *encoder) {
38     if (video->frame() == 0) {
39       encoder->Control(AOME_SET_CPUUSED, kCpuUsed);
40       encoder->Control(AOME_SET_NUMBER_SPATIAL_LAYERS, num_spatial_layers_);
41     } else if (video->frame() % num_spatial_layers_) {
42       frame_flags_ = AOM_EFLAG_NO_REF_LAST2 | AOM_EFLAG_NO_REF_LAST3 |
43                      AOM_EFLAG_NO_REF_GF | AOM_EFLAG_NO_REF_ARF |
44                      AOM_EFLAG_NO_REF_BWD | AOM_EFLAG_NO_REF_ARF2 |
45                      AOM_EFLAG_NO_UPD_LAST | AOM_EFLAG_NO_UPD_GF |
46                      AOM_EFLAG_NO_UPD_ARF | AOM_EFLAG_NO_UPD_ENTROPY;
47       encoder->Control(AOME_SET_SPATIAL_LAYER_ID, 1);
48       encoder->Control(AOME_SET_CQ_LEVEL, kEnhancementLayerQp);
49     } else {
50       frame_flags_ = AOM_EFLAG_NO_REF_LAST2 | AOM_EFLAG_NO_REF_LAST3 |
51                      AOM_EFLAG_NO_REF_GF | AOM_EFLAG_NO_REF_ARF |
52                      AOM_EFLAG_NO_REF_BWD | AOM_EFLAG_NO_REF_ARF2 |
53                      AOM_EFLAG_NO_UPD_GF | AOM_EFLAG_NO_UPD_ARF |
54                      AOM_EFLAG_NO_UPD_ENTROPY;
55       encoder->Control(AOME_SET_SPATIAL_LAYER_ID, 0);
56       encoder->Control(AOME_SET_CQ_LEVEL, kBaseLayerQp);
57     }
58   }
59 
DoTest(int num_spatial_layers)60   void DoTest(int num_spatial_layers) {
61     num_spatial_layers_ = num_spatial_layers;
62     cfg_.rc_end_usage = AOM_Q;
63     cfg_.g_lag_in_frames = 0;
64 
65     ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352,
66                                          288, 30, 1, 0, 18);
67     ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
68   }
69 
70   int num_spatial_layers_;
71 };
72 
TEST_P(ScalabilityTest,TestNoMismatch2SpatialLayers)73 TEST_P(ScalabilityTest, TestNoMismatch2SpatialLayers) { DoTest(2); }
74 
TEST_P(ScalabilityTest,TestNoMismatch3SpatialLayers)75 TEST_P(ScalabilityTest, TestNoMismatch3SpatialLayers) { DoTest(3); }
76 
77 AV1_INSTANTIATE_TEST_SUITE(ScalabilityTest,
78                            ::testing::Values(::libaom_test::kRealTime));
79 
80 }  // namespace
81