1 /* 2 * Copyright (c) 2016, 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 #ifndef AOM_AV1_ENCODER_HASH_MOTION_H_ 13 #define AOM_AV1_ENCODER_HASH_MOTION_H_ 14 15 #include "config/aom_config.h" 16 17 #include "aom/aom_integer.h" 18 #include "aom_scale/yv12config.h" 19 #include "third_party/vector/vector.h" 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 // store a block's hash info. 25 // x and y are the position from the top left of the picture 26 // hash_value2 is used to store the second hash value 27 typedef struct _block_hash { 28 int16_t x; 29 int16_t y; 30 uint32_t hash_value2; 31 } block_hash; 32 33 typedef struct _hash_table { 34 Vector **p_lookup_table; 35 } hash_table; 36 37 void av1_hash_table_init(hash_table *p_hash_table, struct macroblock *x); 38 void av1_hash_table_destroy(hash_table *p_hash_table); 39 void av1_hash_table_create(hash_table *p_hash_table); 40 int32_t av1_hash_table_count(const hash_table *p_hash_table, 41 uint32_t hash_value); 42 Iterator av1_hash_get_first_iterator(hash_table *p_hash_table, 43 uint32_t hash_value); 44 int32_t av1_has_exact_match(hash_table *p_hash_table, uint32_t hash_value1, 45 uint32_t hash_value2); 46 void av1_generate_block_2x2_hash_value(const YV12_BUFFER_CONFIG *picture, 47 uint32_t *pic_block_hash[2], 48 int8_t *pic_block_same_info[3], 49 struct macroblock *x); 50 void av1_generate_block_hash_value(const YV12_BUFFER_CONFIG *picture, 51 int block_size, 52 uint32_t *src_pic_block_hash[2], 53 uint32_t *dst_pic_block_hash[2], 54 int8_t *src_pic_block_same_info[3], 55 int8_t *dst_pic_block_same_info[3], 56 struct macroblock *x); 57 void av1_add_to_hash_map_by_row_with_precal_data(hash_table *p_hash_table, 58 uint32_t *pic_hash[2], 59 int8_t *pic_is_same, 60 int pic_width, int pic_height, 61 int block_size); 62 63 // check whether the block starts from (x_start, y_start) with the size of 64 // block_size x block_size has the same color in all rows 65 int av1_hash_is_horizontal_perfect(const YV12_BUFFER_CONFIG *picture, 66 int block_size, int x_start, int y_start); 67 // check whether the block starts from (x_start, y_start) with the size of 68 // block_size x block_size has the same color in all columns 69 int av1_hash_is_vertical_perfect(const YV12_BUFFER_CONFIG *picture, 70 int block_size, int x_start, int y_start); 71 void av1_get_block_hash_value(uint8_t *y_src, int stride, int block_size, 72 uint32_t *hash_value1, uint32_t *hash_value2, 73 int use_highbitdepth, struct macroblock *x); 74 75 #ifdef __cplusplus 76 } // extern "C" 77 #endif 78 79 #endif // AOM_AV1_ENCODER_HASH_MOTION_H_ 80