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