1*77c1e3ccSAndroid Build Coastguard Worker /* 2*77c1e3ccSAndroid Build Coastguard Worker * Copyright (c) 2022, Alliance for Open Media. All rights reserved. 3*77c1e3ccSAndroid Build Coastguard Worker * 4*77c1e3ccSAndroid Build Coastguard Worker * This source code is subject to the terms of the BSD 2 Clause License and 5*77c1e3ccSAndroid Build Coastguard Worker * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License 6*77c1e3ccSAndroid Build Coastguard Worker * was not distributed with this source code in the LICENSE file, you can 7*77c1e3ccSAndroid Build Coastguard Worker * obtain it at www.aomedia.org/license/software. If the Alliance for Open 8*77c1e3ccSAndroid Build Coastguard Worker * Media Patent License 1.0 was not distributed with this source code in the 9*77c1e3ccSAndroid Build Coastguard Worker * PATENTS file, you can obtain it at www.aomedia.org/license/patent. 10*77c1e3ccSAndroid Build Coastguard Worker */ 11*77c1e3ccSAndroid Build Coastguard Worker 12*77c1e3ccSAndroid Build Coastguard Worker #ifndef AOM_AV1_ENCODER_MCOMP_STRUCTS_H_ 13*77c1e3ccSAndroid Build Coastguard Worker #define AOM_AV1_ENCODER_MCOMP_STRUCTS_H_ 14*77c1e3ccSAndroid Build Coastguard Worker 15*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/mv.h" 16*77c1e3ccSAndroid Build Coastguard Worker 17*77c1e3ccSAndroid Build Coastguard Worker // The maximum number of steps in a step search given the largest 18*77c1e3ccSAndroid Build Coastguard Worker // allowed initial step 19*77c1e3ccSAndroid Build Coastguard Worker #define MAX_MVSEARCH_STEPS 11 20*77c1e3ccSAndroid Build Coastguard Worker // Max full pel mv specified in the unit of full pixel 21*77c1e3ccSAndroid Build Coastguard Worker // Enable the use of motion vector in range [-1023, 1023]. 22*77c1e3ccSAndroid Build Coastguard Worker #define MAX_FULL_PEL_VAL ((1 << (MAX_MVSEARCH_STEPS - 1)) - 1) 23*77c1e3ccSAndroid Build Coastguard Worker // Maximum size of the first step in full pel units 24*77c1e3ccSAndroid Build Coastguard Worker #define MAX_FIRST_STEP (1 << (MAX_MVSEARCH_STEPS - 1)) 25*77c1e3ccSAndroid Build Coastguard Worker // Maximum number of neighbors to scan per iteration during 26*77c1e3ccSAndroid Build Coastguard Worker // WARPED_CAUSAL refinement 27*77c1e3ccSAndroid Build Coastguard Worker // Note: The elements of warp_search_config.neighbor_mask must be at least 28*77c1e3ccSAndroid Build Coastguard Worker // MAX_WARP_SEARCH_NEIGHBORS many bits wide. So the type may need to be 29*77c1e3ccSAndroid Build Coastguard Worker // widened if this value is increased. 30*77c1e3ccSAndroid Build Coastguard Worker #define MAX_WARP_SEARCH_NEIGHBORS 8 31*77c1e3ccSAndroid Build Coastguard Worker 32*77c1e3ccSAndroid Build Coastguard Worker #define SEARCH_RANGE_8P 3 33*77c1e3ccSAndroid Build Coastguard Worker #define SEARCH_GRID_STRIDE_8P (2 * SEARCH_RANGE_8P + 1) 34*77c1e3ccSAndroid Build Coastguard Worker #define SEARCH_GRID_CENTER_8P \ 35*77c1e3ccSAndroid Build Coastguard Worker (SEARCH_RANGE_8P * SEARCH_GRID_STRIDE_8P + SEARCH_RANGE_8P) 36*77c1e3ccSAndroid Build Coastguard Worker 37*77c1e3ccSAndroid Build Coastguard Worker typedef struct { 38*77c1e3ccSAndroid Build Coastguard Worker FULLPEL_MV coord; 39*77c1e3ccSAndroid Build Coastguard Worker int coord_offset; 40*77c1e3ccSAndroid Build Coastguard Worker } search_neighbors; 41*77c1e3ccSAndroid Build Coastguard Worker // motion search site 42*77c1e3ccSAndroid Build Coastguard Worker typedef struct search_site { 43*77c1e3ccSAndroid Build Coastguard Worker FULLPEL_MV mv; 44*77c1e3ccSAndroid Build Coastguard Worker int offset; 45*77c1e3ccSAndroid Build Coastguard Worker } search_site; 46*77c1e3ccSAndroid Build Coastguard Worker 47*77c1e3ccSAndroid Build Coastguard Worker typedef struct search_site_config { 48*77c1e3ccSAndroid Build Coastguard Worker search_site site[MAX_MVSEARCH_STEPS * 2][16 + 1]; 49*77c1e3ccSAndroid Build Coastguard Worker // Number of search steps. 50*77c1e3ccSAndroid Build Coastguard Worker int num_search_steps; 51*77c1e3ccSAndroid Build Coastguard Worker int searches_per_step[MAX_MVSEARCH_STEPS * 2]; 52*77c1e3ccSAndroid Build Coastguard Worker int radius[MAX_MVSEARCH_STEPS * 2]; 53*77c1e3ccSAndroid Build Coastguard Worker int stride; 54*77c1e3ccSAndroid Build Coastguard Worker } search_site_config; 55*77c1e3ccSAndroid Build Coastguard Worker 56*77c1e3ccSAndroid Build Coastguard Worker enum { 57*77c1e3ccSAndroid Build Coastguard Worker // Search 8-points in the radius grid around center, up to 11 search stages. 58*77c1e3ccSAndroid Build Coastguard Worker DIAMOND = 0, 59*77c1e3ccSAndroid Build Coastguard Worker // Search 12-points in the radius/tan_radius grid around center, 60*77c1e3ccSAndroid Build Coastguard Worker // up to 15 search stages. 61*77c1e3ccSAndroid Build Coastguard Worker NSTEP = 1, 62*77c1e3ccSAndroid Build Coastguard Worker // Search 8-points in the radius grid around center, up to 16 search stages. 63*77c1e3ccSAndroid Build Coastguard Worker NSTEP_8PT = 2, 64*77c1e3ccSAndroid Build Coastguard Worker // Search 8-points in the radius grid around center, upto 11 search stages 65*77c1e3ccSAndroid Build Coastguard Worker // with clamping of search radius. 66*77c1e3ccSAndroid Build Coastguard Worker CLAMPED_DIAMOND = 3, 67*77c1e3ccSAndroid Build Coastguard Worker // Search maximum 8-points in the radius grid around center, 68*77c1e3ccSAndroid Build Coastguard Worker // up to 11 search stages. First stage consists of 8 search points 69*77c1e3ccSAndroid Build Coastguard Worker // and the rest with 6 search points each in hex shape. 70*77c1e3ccSAndroid Build Coastguard Worker HEX = 4, 71*77c1e3ccSAndroid Build Coastguard Worker // Search maximum 8-points in the radius grid around center, 72*77c1e3ccSAndroid Build Coastguard Worker // up to 11 search stages. First stage consists of 4 search 73*77c1e3ccSAndroid Build Coastguard Worker // points and the rest with 8 search points each. 74*77c1e3ccSAndroid Build Coastguard Worker BIGDIA = 5, 75*77c1e3ccSAndroid Build Coastguard Worker // Search 8-points in the square grid around center, up to 11 search stages. 76*77c1e3ccSAndroid Build Coastguard Worker SQUARE = 6, 77*77c1e3ccSAndroid Build Coastguard Worker // HEX search with up to 2 stages. 78*77c1e3ccSAndroid Build Coastguard Worker FAST_HEX = 7, 79*77c1e3ccSAndroid Build Coastguard Worker // BIGDIA search with up to 2 stages. 80*77c1e3ccSAndroid Build Coastguard Worker FAST_DIAMOND = 8, 81*77c1e3ccSAndroid Build Coastguard Worker // BIGDIA search with up to 3 stages. 82*77c1e3ccSAndroid Build Coastguard Worker FAST_BIGDIA = 9, 83*77c1e3ccSAndroid Build Coastguard Worker // BIGDIA search with up to 1 stage. 84*77c1e3ccSAndroid Build Coastguard Worker VFAST_DIAMOND = 10, 85*77c1e3ccSAndroid Build Coastguard Worker // Total number of search methods. 86*77c1e3ccSAndroid Build Coastguard Worker NUM_SEARCH_METHODS, 87*77c1e3ccSAndroid Build Coastguard Worker // Number of distinct search methods. 88*77c1e3ccSAndroid Build Coastguard Worker NUM_DISTINCT_SEARCH_METHODS = SQUARE + 1, 89*77c1e3ccSAndroid Build Coastguard Worker } UENUM1BYTE(SEARCH_METHODS); 90*77c1e3ccSAndroid Build Coastguard Worker 91*77c1e3ccSAndroid Build Coastguard Worker typedef struct warp_search_config { 92*77c1e3ccSAndroid Build Coastguard Worker int num_neighbors; 93*77c1e3ccSAndroid Build Coastguard Worker MV neighbors[MAX_WARP_SEARCH_NEIGHBORS]; 94*77c1e3ccSAndroid Build Coastguard Worker // Bitmask which is used to prune the search neighbors at one iteration 95*77c1e3ccSAndroid Build Coastguard Worker // based on which direction we chose in the previous iteration. 96*77c1e3ccSAndroid Build Coastguard Worker // See comments in av1_refine_warped_mv for details. 97*77c1e3ccSAndroid Build Coastguard Worker uint8_t neighbor_mask[MAX_WARP_SEARCH_NEIGHBORS]; 98*77c1e3ccSAndroid Build Coastguard Worker } warp_search_config; 99*77c1e3ccSAndroid Build Coastguard Worker 100*77c1e3ccSAndroid Build Coastguard Worker // Methods for refining WARPED_CAUSAL motion vectors 101*77c1e3ccSAndroid Build Coastguard Worker enum { 102*77c1e3ccSAndroid Build Coastguard Worker // Search 4 adjacent points in a diamond shape at each iteration 103*77c1e3ccSAndroid Build Coastguard Worker WARP_SEARCH_DIAMOND, 104*77c1e3ccSAndroid Build Coastguard Worker // Search 8 adjacent points in a square at each iteration 105*77c1e3ccSAndroid Build Coastguard Worker WARP_SEARCH_SQUARE, 106*77c1e3ccSAndroid Build Coastguard Worker WARP_SEARCH_METHODS 107*77c1e3ccSAndroid Build Coastguard Worker } UENUM1BYTE(WARP_SEARCH_METHOD); 108*77c1e3ccSAndroid Build Coastguard Worker 109*77c1e3ccSAndroid Build Coastguard Worker #endif // AOM_AV1_ENCODER_MCOMP_STRUCTS_H_ 110