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[] = { |
Alex Converse | 2874430 | 2017-04-13 14:46:22 -0700 | [diff] [blame] | 32 | { { 0, 0 }, 0, 0, BLOCK_128X128, false }, |
Alex Converse | 2874430 | 2017-04-13 14:46:22 -0700 | [diff] [blame] | 33 | { { 0, 0 }, 0, 0, BLOCK_64X64, false }, |
| 34 | { { 0, 0 }, 0, 0, BLOCK_32X32, false }, |
| 35 | { { 0, 0 }, 0, 0, BLOCK_16X16, false }, |
| 36 | { { 0, 0 }, 0, 0, BLOCK_8X8, false }, |
| 37 | { { 0, 0 }, 0, 0, BLOCK_4X4, false }, |
| 38 | { { -MAX_SB_SIZE * kSubPelScale, -MAX_SB_SIZE * kSubPelScale }, |
| 39 | MAX_SB_SIZE / MI_SIZE, |
| 40 | MAX_SB_SIZE / MI_SIZE, |
| 41 | BLOCK_16X16, |
| 42 | true }, |
| 43 | { { 0, -MAX_SB_SIZE * kSubPelScale }, |
| 44 | MAX_SB_SIZE / MI_SIZE, |
| 45 | MAX_SB_SIZE / MI_SIZE, |
| 46 | BLOCK_16X16, |
Hui Su | b488f91 | 2018-01-11 12:12:16 -0800 | [diff] [blame] | 47 | false }, |
Alex Converse | 2874430 | 2017-04-13 14:46:22 -0700 | [diff] [blame] | 48 | { { -MAX_SB_SIZE * kSubPelScale, 0 }, |
| 49 | MAX_SB_SIZE / MI_SIZE, |
| 50 | MAX_SB_SIZE / MI_SIZE, |
| 51 | BLOCK_16X16, |
| 52 | true }, |
| 53 | { { MAX_SB_SIZE * kSubPelScale, 0 }, |
| 54 | MAX_SB_SIZE / MI_SIZE, |
| 55 | MAX_SB_SIZE / MI_SIZE, |
| 56 | BLOCK_16X16, |
| 57 | false }, |
| 58 | { { 0, MAX_SB_SIZE * kSubPelScale }, |
| 59 | MAX_SB_SIZE / MI_SIZE, |
| 60 | MAX_SB_SIZE / MI_SIZE, |
| 61 | BLOCK_16X16, |
| 62 | false }, |
| 63 | { { -32 * kSubPelScale, -32 * kSubPelScale }, |
| 64 | MAX_SB_SIZE / MI_SIZE, |
| 65 | MAX_SB_SIZE / MI_SIZE, |
| 66 | BLOCK_32X32, |
| 67 | true }, |
| 68 | { { -32 * kSubPelScale, -32 * kSubPelScale }, |
| 69 | 32 / MI_SIZE, |
| 70 | 32 / MI_SIZE, |
| 71 | BLOCK_32X32, |
| 72 | false }, |
| 73 | { { -32 * kSubPelScale - kSubPelScale / 2, -32 * kSubPelScale }, |
| 74 | MAX_SB_SIZE / MI_SIZE, |
| 75 | MAX_SB_SIZE / MI_SIZE, |
| 76 | BLOCK_32X32, |
| 77 | false }, |
| 78 | { { -33 * kSubPelScale, -32 * kSubPelScale }, |
| 79 | MAX_SB_SIZE / MI_SIZE, |
| 80 | MAX_SB_SIZE / MI_SIZE, |
| 81 | BLOCK_32X32, |
| 82 | true }, |
| 83 | { { -32 * kSubPelScale, -32 * kSubPelScale - kSubPelScale / 2 }, |
| 84 | MAX_SB_SIZE / MI_SIZE, |
| 85 | MAX_SB_SIZE / MI_SIZE, |
| 86 | BLOCK_32X32, |
| 87 | false }, |
| 88 | { { -32 * kSubPelScale, -33 * kSubPelScale }, |
| 89 | MAX_SB_SIZE / MI_SIZE, |
| 90 | MAX_SB_SIZE / MI_SIZE, |
| 91 | BLOCK_32X32, |
| 92 | true }, |
| 93 | { { -MAX_SB_SIZE * kSubPelScale, -MAX_SB_SIZE * kSubPelScale }, |
| 94 | MAX_SB_SIZE / MI_SIZE, |
| 95 | MAX_SB_SIZE / MI_SIZE, |
| 96 | BLOCK_LARGEST, |
| 97 | true }, |
| 98 | { { -(MAX_SB_SIZE + 1) * kSubPelScale, -MAX_SB_SIZE * kSubPelScale }, |
| 99 | MAX_SB_SIZE / MI_SIZE, |
| 100 | MAX_SB_SIZE / MI_SIZE, |
| 101 | BLOCK_LARGEST, |
| 102 | false }, |
| 103 | { { -MAX_SB_SIZE * kSubPelScale, -(MAX_SB_SIZE + 1) * kSubPelScale }, |
| 104 | MAX_SB_SIZE / MI_SIZE, |
| 105 | MAX_SB_SIZE / MI_SIZE, |
| 106 | BLOCK_LARGEST, |
| 107 | false }, |
| 108 | { { -(MAX_SB_SIZE - 1) * kSubPelScale, -MAX_SB_SIZE * kSubPelScale }, |
| 109 | MAX_SB_SIZE / MI_SIZE, |
| 110 | MAX_SB_SIZE / MI_SIZE, |
| 111 | BLOCK_LARGEST, |
Hui Su | b488f91 | 2018-01-11 12:12:16 -0800 | [diff] [blame] | 112 | false }, |
Alex Converse | 2874430 | 2017-04-13 14:46:22 -0700 | [diff] [blame] | 113 | { { -MAX_SB_SIZE * kSubPelScale, -(MAX_SB_SIZE - 1) * kSubPelScale }, |
| 114 | MAX_SB_SIZE / MI_SIZE, |
| 115 | MAX_SB_SIZE / MI_SIZE, |
| 116 | BLOCK_LARGEST, |
| 117 | true }, |
| 118 | { { -(MAX_SB_SIZE - 1) * kSubPelScale, -(MAX_SB_SIZE - 1) * kSubPelScale }, |
| 119 | MAX_SB_SIZE / MI_SIZE, |
| 120 | MAX_SB_SIZE / MI_SIZE, |
| 121 | BLOCK_LARGEST, |
| 122 | false }, |
| 123 | { { -MAX_SB_SIZE * kSubPelScale, MAX_SB_SIZE * kSubPelScale }, |
| 124 | MAX_SB_SIZE / MI_SIZE, |
| 125 | MAX_SB_SIZE / MI_SIZE, |
| 126 | BLOCK_LARGEST, |
Hui Su | b488f91 | 2018-01-11 12:12:16 -0800 | [diff] [blame] | 127 | false }, |
Alex Converse | 2874430 | 2017-04-13 14:46:22 -0700 | [diff] [blame] | 128 | { { -MAX_SB_SIZE * kSubPelScale, |
| 129 | (kTileMaxMibWidth - 2) * MAX_SB_SIZE * kSubPelScale }, |
| 130 | MAX_SB_SIZE / MI_SIZE, |
| 131 | MAX_SB_SIZE / MI_SIZE, |
| 132 | BLOCK_LARGEST, |
Hui Su | b488f91 | 2018-01-11 12:12:16 -0800 | [diff] [blame] | 133 | false }, |
Alex Converse | 2874430 | 2017-04-13 14:46:22 -0700 | [diff] [blame] | 134 | { { -MAX_SB_SIZE * kSubPelScale, |
| 135 | ((kTileMaxMibWidth - 2) * MAX_SB_SIZE + 1) * kSubPelScale }, |
| 136 | MAX_SB_SIZE / MI_SIZE, |
| 137 | MAX_SB_SIZE / MI_SIZE, |
| 138 | BLOCK_LARGEST, |
| 139 | false }, |
| 140 | }; |
| 141 | TileInfo tile; |
| 142 | tile.mi_row_start = 8 * MAX_MIB_SIZE; |
| 143 | tile.mi_row_end = 16 * MAX_MIB_SIZE; |
| 144 | tile.mi_col_start = 24 * MAX_MIB_SIZE; |
| 145 | tile.mi_col_end = tile.mi_col_start + kTileMaxMibWidth * MAX_MIB_SIZE; |
| 146 | for (int i = 0; i < static_cast<int>(GTEST_ARRAY_SIZE_(kDvCases)); ++i) { |
Tom Finegan | f19a91c | 2018-01-31 11:30:17 -0800 | [diff] [blame] | 147 | EXPECT_EQ(static_cast<int>(kDvCases[i].valid), |
Hui Su | 64463e7 | 2017-11-06 12:36:00 -0800 | [diff] [blame] | 148 | av1_is_dv_valid(kDvCases[i].dv, &tile, |
| 149 | tile.mi_row_start + kDvCases[i].mi_row_offset, |
| 150 | tile.mi_col_start + kDvCases[i].mi_col_offset, |
| 151 | kDvCases[i].bsize, MAX_MIB_SIZE_LOG2)) |
Alex Converse | 2874430 | 2017-04-13 14:46:22 -0700 | [diff] [blame] | 152 | << "DvCases[" << i << "]"; |
| 153 | } |
| 154 | } |
| 155 | } // namespace |