tor-browser

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

decode_scalability_test.cc (3890B)


      1 /*
      2 * Copyright (c) 2021, 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 <ostream>
     13 
     14 #include "gtest/gtest.h"
     15 #include "test/codec_factory.h"
     16 #include "test/decode_test_driver.h"
     17 #include "test/ivf_video_source.h"
     18 #include "test/util.h"
     19 #include "test/video_source.h"
     20 
     21 namespace {
     22 
     23 struct ObuExtensionHeader {
     24  int temporal_id;
     25  int spatial_id;
     26 };
     27 
     28 struct DecodeParam {
     29  const char *filename;
     30  const ObuExtensionHeader *headers;
     31  size_t num_headers;
     32 };
     33 
     34 std::ostream &operator<<(std::ostream &os, const DecodeParam &dp) {
     35  return os << "file: " << dp.filename;
     36 }
     37 
     38 class DecodeScalabilityTest
     39    : public ::libaom_test::DecoderTest,
     40      public ::libaom_test::CodecTestWithParam<DecodeParam> {
     41 protected:
     42  DecodeScalabilityTest()
     43      : DecoderTest(GET_PARAM(0)), headers_(GET_PARAM(1).headers),
     44        num_headers_(GET_PARAM(1).num_headers) {}
     45 
     46  ~DecodeScalabilityTest() override = default;
     47 
     48  void PreDecodeFrameHook(const libaom_test::CompressedVideoSource &video,
     49                          libaom_test::Decoder *decoder) override {
     50    if (video.frame_number() == 0)
     51      decoder->Control(AV1D_SET_OUTPUT_ALL_LAYERS, 1);
     52  }
     53 
     54  void DecompressedFrameHook(const aom_image_t &img,
     55                             const unsigned int /*frame_number*/) override {
     56    const ObuExtensionHeader &header = headers_[header_index_];
     57    EXPECT_EQ(img.temporal_id, header.temporal_id);
     58    EXPECT_EQ(img.spatial_id, header.spatial_id);
     59    header_index_ = (header_index_ + 1) % num_headers_;
     60  }
     61 
     62  void RunTest() {
     63    const DecodeParam input = GET_PARAM(1);
     64    aom_codec_dec_cfg_t cfg = { 1, 0, 0, !FORCE_HIGHBITDEPTH_DECODING };
     65    libaom_test::IVFVideoSource decode_video(input.filename);
     66    decode_video.Init();
     67 
     68    ASSERT_NO_FATAL_FAILURE(RunLoop(&decode_video, cfg));
     69  }
     70 
     71 private:
     72  const ObuExtensionHeader *const headers_;
     73  const size_t num_headers_;
     74  size_t header_index_ = 0;
     75 };
     76 
     77 TEST_P(DecodeScalabilityTest, ObuExtensionHeader) { RunTest(); }
     78 
     79 // For all test files, we have:
     80 //   operatingPoint = 0
     81 //   OperatingPointIdc = operating_point_idc[ 0 ]
     82 
     83 // av1-1-b8-01-size-16x16.ivf:
     84 //   operating_points_cnt_minus_1 = 0
     85 //   operating_point_idc[ 0 ] = 0x0
     86 const ObuExtensionHeader kSize16x16Headers[1] = { { 0, 0 } };
     87 
     88 // av1-1-b8-22-svc-L1T2.ivf:
     89 //   operating_points_cnt_minus_1 = 1
     90 //   operating_point_idc[ 0 ] = 0x103
     91 //   operating_point_idc[ 1 ] = 0x101
     92 const ObuExtensionHeader kL1T2Headers[2] = { { 0, 0 }, { 1, 0 } };
     93 
     94 // av1-1-b8-22-svc-L2T1.ivf:
     95 //   operating_points_cnt_minus_1 = 1
     96 //   operating_point_idc[ 0 ] = 0x301
     97 //   operating_point_idc[ 1 ] = 0x101
     98 const ObuExtensionHeader kL2T1Headers[2] = { { 0, 0 }, { 0, 1 } };
     99 
    100 // av1-1-b8-22-svc-L2T2.ivf:
    101 //   operating_points_cnt_minus_1 = 3
    102 //   operating_point_idc[ 0 ] = 0x303
    103 //   operating_point_idc[ 1 ] = 0x301
    104 //   operating_point_idc[ 2 ] = 0x103
    105 //   operating_point_idc[ 3 ] = 0x101
    106 const ObuExtensionHeader kL2T2Headers[4] = {
    107  { 0, 0 }, { 0, 1 }, { 1, 0 }, { 1, 1 }
    108 };
    109 
    110 const DecodeParam kAV1DecodeScalabilityTests[] = {
    111  // { filename, headers, num_headers }
    112  { "av1-1-b8-01-size-16x16.ivf", kSize16x16Headers, 1 },
    113  { "av1-1-b8-22-svc-L1T2.ivf", kL1T2Headers, 2 },
    114  { "av1-1-b8-22-svc-L2T1.ivf", kL2T1Headers, 2 },
    115  { "av1-1-b8-22-svc-L2T2.ivf", kL2T2Headers, 4 },
    116 };
    117 
    118 AV1_INSTANTIATE_TEST_SUITE(DecodeScalabilityTest,
    119                           ::testing::ValuesIn(kAV1DecodeScalabilityTests));
    120 
    121 }  // namespace