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 | |
Tom Finegan | 60e653d | 2018-05-22 11:34:58 -0700 | [diff] [blame] | 14 | #include "config/aom_config.h" |
| 15 | |
Hui Su | bce84eb | 2018-04-18 12:00:19 -0700 | [diff] [blame] | 16 | #include "av1/common/blockd.h" |
Alex Converse | 2874430 | 2017-04-13 14:46:22 -0700 | [diff] [blame] | 17 | #include "av1/common/enums.h" |
| 18 | #include "av1/common/mv.h" |
| 19 | #include "av1/common/mvref_common.h" |
Hui Su | bce84eb | 2018-04-18 12:00:19 -0700 | [diff] [blame] | 20 | #include "av1/common/onyxc_int.h" |
Alex Converse | 2874430 | 2017-04-13 14:46:22 -0700 | [diff] [blame] | 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[] = { |
Alex Converse | 2874430 | 2017-04-13 14:46:22 -0700 | [diff] [blame] | 35 | { { 0, 0 }, 0, 0, BLOCK_128X128, false }, |
Alex Converse | 2874430 | 2017-04-13 14:46:22 -0700 | [diff] [blame] | 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, |
Hui Su | b488f91 | 2018-01-11 12:12:16 -0800 | [diff] [blame] | 50 | false }, |
Alex Converse | 2874430 | 2017-04-13 14:46:22 -0700 | [diff] [blame] | 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, |
Hui Su | b488f91 | 2018-01-11 12:12:16 -0800 | [diff] [blame] | 115 | false }, |
Alex Converse | 2874430 | 2017-04-13 14:46:22 -0700 | [diff] [blame] | 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, |
Hui Su | b488f91 | 2018-01-11 12:12:16 -0800 | [diff] [blame] | 130 | false }, |
Alex Converse | 2874430 | 2017-04-13 14:46:22 -0700 | [diff] [blame] | 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, |
Hui Su | b488f91 | 2018-01-11 12:12:16 -0800 | [diff] [blame] | 136 | false }, |
Alex Converse | 2874430 | 2017-04-13 14:46:22 -0700 | [diff] [blame] | 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 | }; |
Hui Su | bce84eb | 2018-04-18 12:00:19 -0700 | [diff] [blame] | 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 | AV1_COMMON cm; |
| 157 | memset(&cm, 0, sizeof(cm)); |
| 158 | |
Alex Converse | 2874430 | 2017-04-13 14:46:22 -0700 | [diff] [blame] | 159 | 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] | 160 | EXPECT_EQ(static_cast<int>(kDvCases[i].valid), |
Hui Su | bce84eb | 2018-04-18 12:00:19 -0700 | [diff] [blame] | 161 | av1_is_dv_valid(kDvCases[i].dv, &cm, &xd, |
| 162 | xd.tile.mi_row_start + kDvCases[i].mi_row_offset, |
| 163 | xd.tile.mi_col_start + kDvCases[i].mi_col_offset, |
Hui Su | 64463e7 | 2017-11-06 12:36:00 -0800 | [diff] [blame] | 164 | kDvCases[i].bsize, MAX_MIB_SIZE_LOG2)) |
Alex Converse | 2874430 | 2017-04-13 14:46:22 -0700 | [diff] [blame] | 165 | << "DvCases[" << i << "]"; |
| 166 | } |
| 167 | } |
| 168 | } // namespace |