tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

active_map_test.cc (3797B)


      1 /*
      2 * Copyright (c) 2016, 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 <climits>
     13 #include <vector>
     14 #include "gtest/gtest.h"
     15 #include "test/codec_factory.h"
     16 #include "test/encode_test_driver.h"
     17 #include "test/i420_video_source.h"
     18 #include "test/util.h"
     19 
     20 namespace {
     21 
     22 // Params: test mode, speed, aq_mode and screen_content mode.
     23 class ActiveMapTest
     24    : public ::libaom_test::CodecTestWith4Params<libaom_test::TestMode, int,
     25                                                 int, int>,
     26      public ::libaom_test::EncoderTest {
     27 protected:
     28  static const int kWidth = 208;
     29  static const int kHeight = 144;
     30 
     31  ActiveMapTest() : EncoderTest(GET_PARAM(0)) {}
     32  ~ActiveMapTest() override = default;
     33 
     34  void SetUp() override {
     35    InitializeConfig(GET_PARAM(1));
     36    cpu_used_ = GET_PARAM(2);
     37    aq_mode_ = GET_PARAM(3);
     38    screen_mode_ = GET_PARAM(4);
     39  }
     40 
     41  void PreEncodeFrameHook(::libaom_test::VideoSource *video,
     42                          ::libaom_test::Encoder *encoder) override {
     43    if (video->frame() == 0) {
     44      encoder->Control(AOME_SET_CPUUSED, cpu_used_);
     45      encoder->Control(AV1E_SET_ALLOW_WARPED_MOTION, 0);
     46      encoder->Control(AV1E_SET_ENABLE_GLOBAL_MOTION, 0);
     47      encoder->Control(AV1E_SET_ENABLE_OBMC, 0);
     48      encoder->Control(AV1E_SET_AQ_MODE, aq_mode_);
     49      encoder->Control(AV1E_SET_TUNE_CONTENT, screen_mode_);
     50      if (screen_mode_) encoder->Control(AV1E_SET_ENABLE_PALETTE, 1);
     51    } else if (video->frame() == 3) {
     52      aom_active_map_t map = aom_active_map_t();
     53      /* clang-format off */
     54      uint8_t active_map[9 * 13] = {
     55        1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0,
     56        1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0,
     57        1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0,
     58        1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0,
     59        0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1,
     60        0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1,
     61        0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1,
     62        0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1,
     63        1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0,
     64      };
     65      /* clang-format on */
     66      map.cols = (kWidth + 15) / 16;
     67      map.rows = (kHeight + 15) / 16;
     68      ASSERT_EQ(map.cols, 13u);
     69      ASSERT_EQ(map.rows, 9u);
     70      map.active_map = active_map;
     71      encoder->Control(AOME_SET_ACTIVEMAP, &map);
     72    } else if (video->frame() == 15) {
     73      aom_active_map_t map = aom_active_map_t();
     74      map.cols = (kWidth + 15) / 16;
     75      map.rows = (kHeight + 15) / 16;
     76      map.active_map = nullptr;
     77      encoder->Control(AOME_SET_ACTIVEMAP, &map);
     78    }
     79  }
     80 
     81  void DoTest() {
     82    // Validate that this non multiple of 64 wide clip encodes
     83    cfg_.g_lag_in_frames = 0;
     84    cfg_.rc_target_bitrate = 400;
     85    cfg_.rc_resize_mode = 0;
     86    cfg_.g_pass = AOM_RC_ONE_PASS;
     87    cfg_.rc_end_usage = AOM_CBR;
     88    cfg_.kf_max_dist = 90000;
     89    ::libaom_test::I420VideoSource video("hantro_odd.yuv", kWidth, kHeight, 100,
     90                                         1, 0, 100);
     91 
     92    ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
     93  }
     94 
     95  int cpu_used_;
     96  int aq_mode_;
     97  int screen_mode_;
     98 };
     99 
    100 TEST_P(ActiveMapTest, Test) { DoTest(); }
    101 
    102 AV1_INSTANTIATE_TEST_SUITE(ActiveMapTest,
    103                           ::testing::Values(::libaom_test::kRealTime),
    104                           ::testing::Range(5, 12), ::testing::Values(0, 3),
    105                           ::testing::Values(0, 1));
    106 
    107 }  // namespace