hash_motion.h (3751B)
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 <stdbool.h> 16 17 #include "aom/aom_integer.h" 18 #include "aom_scale/yv12config.h" 19 #include "av1/encoder/hash.h" 20 #include "third_party/vector/vector.h" 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 // Block size used for force_integer_mv decisions 26 #define FORCE_INT_MV_DECISION_BLOCK_SIZE 8 27 28 // store a block's hash info. 29 // x and y are the position from the top left of the picture 30 // hash_value2 is used to store the second hash value 31 typedef struct _block_hash { 32 int16_t x; 33 int16_t y; 34 uint32_t hash_value2; 35 } block_hash; 36 37 typedef struct _hash_table { 38 // a dynamically allocated array of kMaxAddr elements 39 Vector **p_lookup_table; 40 } hash_table; 41 42 struct intrabc_hash_info; 43 44 typedef struct intrabc_hash_info { 45 // buffer for hash value calculation of a block 46 // used only in av1_get_block_hash_value() 47 // [two buffers used ping-pong] 48 // buffers are AOM_BUFFER_SIZE_FOR_BLOCK_HASH elements long 49 uint32_t *hash_value_buffer[2]; 50 hash_table intrabc_hash_table; 51 52 CRC32C crc_calculator; 53 int crc_initialized; 54 } IntraBCHashInfo; 55 56 void av1_hash_table_init(IntraBCHashInfo *intra_bc_hash_info); 57 void av1_hash_table_destroy(hash_table *p_hash_table); 58 bool av1_hash_table_create(hash_table *p_hash_table); 59 int32_t av1_hash_table_count(const hash_table *p_hash_table, 60 uint32_t hash_value); 61 Iterator av1_hash_get_first_iterator(hash_table *p_hash_table, 62 uint32_t hash_value); 63 void av1_generate_block_2x2_hash_value(const YV12_BUFFER_CONFIG *picture, 64 uint32_t *pic_block_hash); 65 void av1_generate_block_hash_value(IntraBCHashInfo *intra_bc_hash_info, 66 const YV12_BUFFER_CONFIG *picture, 67 int block_size, 68 const uint32_t *src_pic_block_hash, 69 uint32_t *dst_pic_block_hash); 70 bool av1_add_to_hash_map_by_row_with_precal_data(hash_table *p_hash_table, 71 const uint32_t *pic_hash, 72 int pic_width, int pic_height, 73 int block_size); 74 75 // check whether the block starts from (x_start, y_start) with the size of 76 // block_size x block_size has the same color in all rows 77 int av1_hash_is_horizontal_perfect(const YV12_BUFFER_CONFIG *picture, 78 int block_size, int x_start, int y_start); 79 // check whether the block starts from (x_start, y_start) with the size of 80 // block_size x block_size has the same color in all columns 81 int av1_hash_is_vertical_perfect(const YV12_BUFFER_CONFIG *picture, 82 int block_size, int x_start, int y_start); 83 84 void av1_get_block_hash_value(IntraBCHashInfo *intra_bc_hash_info, 85 const uint8_t *y_src, int stride, int block_size, 86 uint32_t *hash_value1, uint32_t *hash_value2, 87 int use_highbitdepth); 88 89 #ifdef __cplusplus 90 } // extern "C" 91 #endif 92 93 #endif // AOM_AV1_ENCODER_HASH_MOTION_H_