tor-browser

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

intrabc_test.cc (5551B)


      1 /*
      2 * Copyright (c) 2017, 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 
     14 #include "config/aom_config.h"
     15 
     16 #include "av1/common/av1_common_int.h"
     17 #include "av1/common/blockd.h"
     18 #include "av1/common/enums.h"
     19 #include "av1/common/mv.h"
     20 #include "av1/common/mvref_common.h"
     21 #include "av1/common/tile_common.h"
     22 
     23 namespace {
     24 TEST(IntrabcTest, DvValidation) {
     25  struct DvTestCase {
     26    MV dv;
     27    int mi_row_offset;
     28    int mi_col_offset;
     29    BLOCK_SIZE bsize;
     30    bool valid;
     31  };
     32  const int kSubPelScale = 8;
     33  const int kTileMaxMibWidth = 8;
     34  const DvTestCase kDvCases[] = {
     35    { { 0, 0 }, 0, 0, BLOCK_128X128, false },
     36    { { 0, 0 }, 0, 0, BLOCK_64X64, false },
     37    { { 0, 0 }, 0, 0, BLOCK_32X32, false },
     38    { { 0, 0 }, 0, 0, BLOCK_16X16, false },
     39    { { 0, 0 }, 0, 0, BLOCK_8X8, false },
     40    { { 0, 0 }, 0, 0, BLOCK_4X4, false },
     41    { { -MAX_SB_SIZE * kSubPelScale, -MAX_SB_SIZE * kSubPelScale },
     42      MAX_SB_SIZE / MI_SIZE,
     43      MAX_SB_SIZE / MI_SIZE,
     44      BLOCK_16X16,
     45      true },
     46    { { 0, -MAX_SB_SIZE * kSubPelScale },
     47      MAX_SB_SIZE / MI_SIZE,
     48      MAX_SB_SIZE / MI_SIZE,
     49      BLOCK_16X16,
     50      false },
     51    { { -MAX_SB_SIZE * kSubPelScale, 0 },
     52      MAX_SB_SIZE / MI_SIZE,
     53      MAX_SB_SIZE / MI_SIZE,
     54      BLOCK_16X16,
     55      true },
     56    { { MAX_SB_SIZE * kSubPelScale, 0 },
     57      MAX_SB_SIZE / MI_SIZE,
     58      MAX_SB_SIZE / MI_SIZE,
     59      BLOCK_16X16,
     60      false },
     61    { { 0, MAX_SB_SIZE * kSubPelScale },
     62      MAX_SB_SIZE / MI_SIZE,
     63      MAX_SB_SIZE / MI_SIZE,
     64      BLOCK_16X16,
     65      false },
     66    { { -32 * kSubPelScale, -32 * kSubPelScale },
     67      MAX_SB_SIZE / MI_SIZE,
     68      MAX_SB_SIZE / MI_SIZE,
     69      BLOCK_32X32,
     70      true },
     71    { { -32 * kSubPelScale, -32 * kSubPelScale },
     72      32 / MI_SIZE,
     73      32 / MI_SIZE,
     74      BLOCK_32X32,
     75      false },
     76    { { -32 * kSubPelScale - kSubPelScale / 2, -32 * kSubPelScale },
     77      MAX_SB_SIZE / MI_SIZE,
     78      MAX_SB_SIZE / MI_SIZE,
     79      BLOCK_32X32,
     80      false },
     81    { { -33 * kSubPelScale, -32 * kSubPelScale },
     82      MAX_SB_SIZE / MI_SIZE,
     83      MAX_SB_SIZE / MI_SIZE,
     84      BLOCK_32X32,
     85      true },
     86    { { -32 * kSubPelScale, -32 * kSubPelScale - kSubPelScale / 2 },
     87      MAX_SB_SIZE / MI_SIZE,
     88      MAX_SB_SIZE / MI_SIZE,
     89      BLOCK_32X32,
     90      false },
     91    { { -32 * kSubPelScale, -33 * kSubPelScale },
     92      MAX_SB_SIZE / MI_SIZE,
     93      MAX_SB_SIZE / MI_SIZE,
     94      BLOCK_32X32,
     95      true },
     96    { { -MAX_SB_SIZE * kSubPelScale, -MAX_SB_SIZE * kSubPelScale },
     97      MAX_SB_SIZE / MI_SIZE,
     98      MAX_SB_SIZE / MI_SIZE,
     99      BLOCK_LARGEST,
    100      true },
    101    { { -(MAX_SB_SIZE + 1) * kSubPelScale, -MAX_SB_SIZE * kSubPelScale },
    102      MAX_SB_SIZE / MI_SIZE,
    103      MAX_SB_SIZE / MI_SIZE,
    104      BLOCK_LARGEST,
    105      false },
    106    { { -MAX_SB_SIZE * kSubPelScale, -(MAX_SB_SIZE + 1) * kSubPelScale },
    107      MAX_SB_SIZE / MI_SIZE,
    108      MAX_SB_SIZE / MI_SIZE,
    109      BLOCK_LARGEST,
    110      false },
    111    { { -(MAX_SB_SIZE - 1) * kSubPelScale, -MAX_SB_SIZE * kSubPelScale },
    112      MAX_SB_SIZE / MI_SIZE,
    113      MAX_SB_SIZE / MI_SIZE,
    114      BLOCK_LARGEST,
    115      false },
    116    { { -MAX_SB_SIZE * kSubPelScale, -(MAX_SB_SIZE - 1) * kSubPelScale },
    117      MAX_SB_SIZE / MI_SIZE,
    118      MAX_SB_SIZE / MI_SIZE,
    119      BLOCK_LARGEST,
    120      true },
    121    { { -(MAX_SB_SIZE - 1) * kSubPelScale, -(MAX_SB_SIZE - 1) * kSubPelScale },
    122      MAX_SB_SIZE / MI_SIZE,
    123      MAX_SB_SIZE / MI_SIZE,
    124      BLOCK_LARGEST,
    125      false },
    126    { { -MAX_SB_SIZE * kSubPelScale, MAX_SB_SIZE * kSubPelScale },
    127      MAX_SB_SIZE / MI_SIZE,
    128      MAX_SB_SIZE / MI_SIZE,
    129      BLOCK_LARGEST,
    130      false },
    131    { { -MAX_SB_SIZE * kSubPelScale,
    132        (kTileMaxMibWidth - 2) * MAX_SB_SIZE * kSubPelScale },
    133      MAX_SB_SIZE / MI_SIZE,
    134      MAX_SB_SIZE / MI_SIZE,
    135      BLOCK_LARGEST,
    136      false },
    137    { { -MAX_SB_SIZE * kSubPelScale,
    138        ((kTileMaxMibWidth - 2) * MAX_SB_SIZE + 1) * kSubPelScale },
    139      MAX_SB_SIZE / MI_SIZE,
    140      MAX_SB_SIZE / MI_SIZE,
    141      BLOCK_LARGEST,
    142      false },
    143  };
    144 
    145  MACROBLOCKD xd;
    146  memset(&xd, 0, sizeof(xd));
    147  xd.tile.mi_row_start = 8 * MAX_MIB_SIZE;
    148  xd.tile.mi_row_end = 16 * MAX_MIB_SIZE;
    149  xd.tile.mi_col_start = 24 * MAX_MIB_SIZE;
    150  xd.tile.mi_col_end = xd.tile.mi_col_start + kTileMaxMibWidth * MAX_MIB_SIZE;
    151  xd.plane[1].subsampling_x = 1;
    152  xd.plane[1].subsampling_y = 1;
    153  xd.plane[2].subsampling_x = 1;
    154  xd.plane[2].subsampling_y = 1;
    155 
    156  SequenceHeader seq_params = {};
    157  AV1_COMMON cm;
    158  memset(&cm, 0, sizeof(cm));
    159  cm.seq_params = &seq_params;
    160 
    161  for (const DvTestCase &dv_case : kDvCases) {
    162    const int mi_row = xd.tile.mi_row_start + dv_case.mi_row_offset;
    163    const int mi_col = xd.tile.mi_col_start + dv_case.mi_col_offset;
    164    xd.is_chroma_ref = is_chroma_reference(mi_row, mi_col, dv_case.bsize,
    165                                           xd.plane[1].subsampling_x,
    166                                           xd.plane[1].subsampling_y);
    167    EXPECT_EQ(static_cast<int>(dv_case.valid),
    168              av1_is_dv_valid(dv_case.dv, &cm, &xd, mi_row, mi_col,
    169                              dv_case.bsize, MAX_MIB_SIZE_LOG2));
    170  }
    171 }
    172 }  // namespace