Alex Converse | 2874430 | 2017-04-13 14:46:22 -0700 | [diff] [blame] | 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 "third_party/googletest/src/googletest/include/gtest/gtest.h" |
| 13 | |
| 14 | #include "./aom_config.h" |
| 15 | #include "av1/common/enums.h" |
| 16 | #include "av1/common/mv.h" |
| 17 | #include "av1/common/mvref_common.h" |
| 18 | #include "av1/common/tile_common.h" |
| 19 | |
| 20 | namespace { |
| 21 | TEST(IntrabcTest, DvValidation) { |
| 22 | struct DvTestCase { |
| 23 | MV dv; |
| 24 | int mi_row_offset; |
| 25 | int mi_col_offset; |
| 26 | BLOCK_SIZE bsize; |
| 27 | bool valid; |
| 28 | }; |
| 29 | const int kSubPelScale = 8; |
| 30 | const int kTileMaxMibWidth = 8; |
| 31 | const DvTestCase kDvCases[] = { |
| 32 | #if CONFIG_EXT_PARTITION |
| 33 | { { 0, 0 }, 0, 0, BLOCK_128X128, false }, |
| 34 | #endif |
| 35 | { { 0, 0 }, 0, 0, BLOCK_64X64, false }, |
| 36 | { { 0, 0 }, 0, 0, BLOCK_32X32, false }, |
| 37 | { { 0, 0 }, 0, 0, BLOCK_16X16, false }, |
| 38 | { { 0, 0 }, 0, 0, BLOCK_8X8, false }, |
| 39 | { { 0, 0 }, 0, 0, BLOCK_4X4, false }, |
| 40 | { { -MAX_SB_SIZE * kSubPelScale, -MAX_SB_SIZE * kSubPelScale }, |
| 41 | MAX_SB_SIZE / MI_SIZE, |
| 42 | MAX_SB_SIZE / MI_SIZE, |
| 43 | BLOCK_16X16, |
| 44 | true }, |
| 45 | { { 0, -MAX_SB_SIZE * kSubPelScale }, |
| 46 | MAX_SB_SIZE / MI_SIZE, |
| 47 | MAX_SB_SIZE / MI_SIZE, |
| 48 | BLOCK_16X16, |
| 49 | true }, |
| 50 | { { -MAX_SB_SIZE * kSubPelScale, 0 }, |
| 51 | MAX_SB_SIZE / MI_SIZE, |
| 52 | MAX_SB_SIZE / MI_SIZE, |
| 53 | BLOCK_16X16, |
| 54 | true }, |
| 55 | { { MAX_SB_SIZE * kSubPelScale, 0 }, |
| 56 | MAX_SB_SIZE / MI_SIZE, |
| 57 | MAX_SB_SIZE / MI_SIZE, |
| 58 | BLOCK_16X16, |
| 59 | false }, |
| 60 | { { 0, MAX_SB_SIZE * kSubPelScale }, |
| 61 | MAX_SB_SIZE / MI_SIZE, |
| 62 | MAX_SB_SIZE / MI_SIZE, |
| 63 | BLOCK_16X16, |
| 64 | false }, |
| 65 | { { -32 * kSubPelScale, -32 * kSubPelScale }, |
| 66 | MAX_SB_SIZE / MI_SIZE, |
| 67 | MAX_SB_SIZE / MI_SIZE, |
| 68 | BLOCK_32X32, |
| 69 | true }, |
| 70 | { { -32 * kSubPelScale, -32 * kSubPelScale }, |
| 71 | 32 / MI_SIZE, |
| 72 | 32 / MI_SIZE, |
| 73 | BLOCK_32X32, |
| 74 | false }, |
| 75 | { { -32 * kSubPelScale - kSubPelScale / 2, -32 * kSubPelScale }, |
| 76 | MAX_SB_SIZE / MI_SIZE, |
| 77 | MAX_SB_SIZE / MI_SIZE, |
| 78 | BLOCK_32X32, |
| 79 | false }, |
| 80 | { { -33 * kSubPelScale, -32 * kSubPelScale }, |
| 81 | MAX_SB_SIZE / MI_SIZE, |
| 82 | MAX_SB_SIZE / MI_SIZE, |
| 83 | BLOCK_32X32, |
| 84 | true }, |
| 85 | { { -32 * kSubPelScale, -32 * kSubPelScale - kSubPelScale / 2 }, |
| 86 | MAX_SB_SIZE / MI_SIZE, |
| 87 | MAX_SB_SIZE / MI_SIZE, |
| 88 | BLOCK_32X32, |
| 89 | false }, |
| 90 | { { -32 * kSubPelScale, -33 * kSubPelScale }, |
| 91 | MAX_SB_SIZE / MI_SIZE, |
| 92 | MAX_SB_SIZE / MI_SIZE, |
| 93 | BLOCK_32X32, |
| 94 | true }, |
| 95 | { { -MAX_SB_SIZE * kSubPelScale, -MAX_SB_SIZE * kSubPelScale }, |
| 96 | MAX_SB_SIZE / MI_SIZE, |
| 97 | MAX_SB_SIZE / MI_SIZE, |
| 98 | BLOCK_LARGEST, |
| 99 | true }, |
| 100 | { { -(MAX_SB_SIZE + 1) * kSubPelScale, -MAX_SB_SIZE * kSubPelScale }, |
| 101 | MAX_SB_SIZE / MI_SIZE, |
| 102 | MAX_SB_SIZE / MI_SIZE, |
| 103 | BLOCK_LARGEST, |
| 104 | false }, |
| 105 | { { -MAX_SB_SIZE * kSubPelScale, -(MAX_SB_SIZE + 1) * kSubPelScale }, |
| 106 | MAX_SB_SIZE / MI_SIZE, |
| 107 | MAX_SB_SIZE / MI_SIZE, |
| 108 | BLOCK_LARGEST, |
| 109 | false }, |
| 110 | { { -(MAX_SB_SIZE - 1) * kSubPelScale, -MAX_SB_SIZE * kSubPelScale }, |
| 111 | MAX_SB_SIZE / MI_SIZE, |
| 112 | MAX_SB_SIZE / MI_SIZE, |
| 113 | BLOCK_LARGEST, |
| 114 | true }, |
| 115 | { { -MAX_SB_SIZE * kSubPelScale, -(MAX_SB_SIZE - 1) * kSubPelScale }, |
| 116 | MAX_SB_SIZE / MI_SIZE, |
| 117 | MAX_SB_SIZE / MI_SIZE, |
| 118 | BLOCK_LARGEST, |
| 119 | true }, |
| 120 | { { -(MAX_SB_SIZE - 1) * kSubPelScale, -(MAX_SB_SIZE - 1) * kSubPelScale }, |
| 121 | MAX_SB_SIZE / MI_SIZE, |
| 122 | MAX_SB_SIZE / MI_SIZE, |
| 123 | BLOCK_LARGEST, |
| 124 | false }, |
| 125 | { { -MAX_SB_SIZE * kSubPelScale, MAX_SB_SIZE * kSubPelScale }, |
| 126 | MAX_SB_SIZE / MI_SIZE, |
| 127 | MAX_SB_SIZE / MI_SIZE, |
| 128 | BLOCK_LARGEST, |
| 129 | true }, |
| 130 | { { -MAX_SB_SIZE * kSubPelScale, |
| 131 | (kTileMaxMibWidth - 2) * MAX_SB_SIZE * kSubPelScale }, |
| 132 | MAX_SB_SIZE / MI_SIZE, |
| 133 | MAX_SB_SIZE / MI_SIZE, |
| 134 | BLOCK_LARGEST, |
| 135 | true }, |
| 136 | { { -MAX_SB_SIZE * kSubPelScale, |
| 137 | ((kTileMaxMibWidth - 2) * MAX_SB_SIZE + 1) * kSubPelScale }, |
| 138 | MAX_SB_SIZE / MI_SIZE, |
| 139 | MAX_SB_SIZE / MI_SIZE, |
| 140 | BLOCK_LARGEST, |
| 141 | false }, |
| 142 | }; |
| 143 | TileInfo tile; |
| 144 | tile.mi_row_start = 8 * MAX_MIB_SIZE; |
| 145 | tile.mi_row_end = 16 * MAX_MIB_SIZE; |
| 146 | tile.mi_col_start = 24 * MAX_MIB_SIZE; |
| 147 | tile.mi_col_end = tile.mi_col_start + kTileMaxMibWidth * MAX_MIB_SIZE; |
| 148 | for (int i = 0; i < static_cast<int>(GTEST_ARRAY_SIZE_(kDvCases)); ++i) { |
| 149 | EXPECT_EQ(kDvCases[i].valid, |
| 150 | is_dv_valid(kDvCases[i].dv, &tile, |
| 151 | tile.mi_row_start + kDvCases[i].mi_row_offset, |
| 152 | tile.mi_col_start + kDvCases[i].mi_col_offset, |
| 153 | kDvCases[i].bsize)) |
| 154 | << "DvCases[" << i << "]"; |
| 155 | } |
| 156 | } |
| 157 | } // namespace |