RogerZhou | cc5d35d | 2017-08-07 22:20:15 -0700 | [diff] [blame] | 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 | |
James Zern | e1cbb13 | 2018-08-22 14:10:36 -0700 | [diff] [blame] | 12 | #ifndef AOM_AV1_ENCODER_HASH_MOTION_H_ |
| 13 | #define AOM_AV1_ENCODER_HASH_MOTION_H_ |
RogerZhou | cc5d35d | 2017-08-07 22:20:15 -0700 | [diff] [blame] | 14 | |
James Zern | a4f38ae | 2022-04-28 13:11:27 -0700 | [diff] [blame] | 15 | #include <stdbool.h> |
| 16 | |
Tom Finegan | 60e653d | 2018-05-22 11:34:58 -0700 | [diff] [blame] | 17 | #include "config/aom_config.h" |
| 18 | |
RogerZhou | cc5d35d | 2017-08-07 22:20:15 -0700 | [diff] [blame] | 19 | #include "aom/aom_integer.h" |
| 20 | #include "aom_scale/yv12config.h" |
chiyotsai | 82f36c9 | 2020-04-09 16:18:02 -0700 | [diff] [blame] | 21 | #include "av1/encoder/hash.h" |
RogerZhou | cc5d35d | 2017-08-07 22:20:15 -0700 | [diff] [blame] | 22 | #include "third_party/vector/vector.h" |
| 23 | #ifdef __cplusplus |
| 24 | extern "C" { |
| 25 | #endif |
| 26 | |
Ranjit Kumar Tulabandu | 9f26c99 | 2019-10-24 12:24:52 +0530 | [diff] [blame] | 27 | // Block size used for force_integer_mv decisions |
| 28 | #define FORCE_INT_MV_DECISION_BLOCK_SIZE 8 |
| 29 | |
RogerZhou | cc5d35d | 2017-08-07 22:20:15 -0700 | [diff] [blame] | 30 | // store a block's hash info. |
| 31 | // x and y are the position from the top left of the picture |
| 32 | // hash_value2 is used to store the second hash value |
| 33 | typedef struct _block_hash { |
| 34 | int16_t x; |
| 35 | int16_t y; |
| 36 | uint32_t hash_value2; |
| 37 | } block_hash; |
| 38 | |
Johann | b0ef6ff | 2018-02-08 14:32:21 -0800 | [diff] [blame] | 39 | typedef struct _hash_table { |
| 40 | Vector **p_lookup_table; |
| 41 | } hash_table; |
RogerZhou | cc5d35d | 2017-08-07 22:20:15 -0700 | [diff] [blame] | 42 | |
chiyotsai | 82f36c9 | 2020-04-09 16:18:02 -0700 | [diff] [blame] | 43 | struct intrabc_hash_info; |
| 44 | |
| 45 | typedef struct intrabc_hash_info { |
| 46 | // buffer for hash value calculation of a block |
| 47 | // used only in av1_get_block_hash_value() |
| 48 | // [first hash/second hash] |
| 49 | // [two buffers used ping-pong] |
| 50 | uint32_t *hash_value_buffer[2][2]; |
| 51 | hash_table intrabc_hash_table; |
| 52 | |
| 53 | CRC_CALCULATOR crc_calculator1; |
| 54 | CRC_CALCULATOR crc_calculator2; |
| 55 | int g_crc_initialized; |
| 56 | } IntraBCHashInfo; |
| 57 | |
| 58 | void av1_hash_table_init(IntraBCHashInfo *intra_bc_hash_info); |
chiyotsai | fc1404d | 2019-08-08 12:09:12 -0700 | [diff] [blame] | 59 | void av1_hash_table_clear_all(hash_table *p_hash_table); |
RogerZhou | cc5d35d | 2017-08-07 22:20:15 -0700 | [diff] [blame] | 60 | void av1_hash_table_destroy(hash_table *p_hash_table); |
James Zern | a4f38ae | 2022-04-28 13:11:27 -0700 | [diff] [blame] | 61 | bool av1_hash_table_create(hash_table *p_hash_table); |
David Turner | a21966b | 2018-12-05 14:48:49 +0000 | [diff] [blame] | 62 | int32_t av1_hash_table_count(const hash_table *p_hash_table, |
| 63 | uint32_t hash_value); |
RogerZhou | cc5d35d | 2017-08-07 22:20:15 -0700 | [diff] [blame] | 64 | Iterator av1_hash_get_first_iterator(hash_table *p_hash_table, |
| 65 | uint32_t hash_value); |
| 66 | int32_t av1_has_exact_match(hash_table *p_hash_table, uint32_t hash_value1, |
| 67 | uint32_t hash_value2); |
chiyotsai | 82f36c9 | 2020-04-09 16:18:02 -0700 | [diff] [blame] | 68 | void av1_generate_block_2x2_hash_value(IntraBCHashInfo *intra_bc_hash_info, |
| 69 | const YV12_BUFFER_CONFIG *picture, |
RogerZhou | cc5d35d | 2017-08-07 22:20:15 -0700 | [diff] [blame] | 70 | uint32_t *pic_block_hash[2], |
chiyotsai | 82f36c9 | 2020-04-09 16:18:02 -0700 | [diff] [blame] | 71 | int8_t *pic_block_same_info[3]); |
| 72 | void av1_generate_block_hash_value(IntraBCHashInfo *intra_bc_hash_info, |
| 73 | const YV12_BUFFER_CONFIG *picture, |
RogerZhou | cc5d35d | 2017-08-07 22:20:15 -0700 | [diff] [blame] | 74 | int block_size, |
| 75 | uint32_t *src_pic_block_hash[2], |
| 76 | uint32_t *dst_pic_block_hash[2], |
| 77 | int8_t *src_pic_block_same_info[3], |
chiyotsai | 82f36c9 | 2020-04-09 16:18:02 -0700 | [diff] [blame] | 78 | int8_t *dst_pic_block_same_info[3]); |
James Zern | a4f38ae | 2022-04-28 13:11:27 -0700 | [diff] [blame] | 79 | bool av1_add_to_hash_map_by_row_with_precal_data(hash_table *p_hash_table, |
RogerZhou | cc5d35d | 2017-08-07 22:20:15 -0700 | [diff] [blame] | 80 | uint32_t *pic_hash[2], |
| 81 | int8_t *pic_is_same, |
| 82 | int pic_width, int pic_height, |
| 83 | int block_size); |
| 84 | |
| 85 | // check whether the block starts from (x_start, y_start) with the size of |
| 86 | // block_size x block_size has the same color in all rows |
| 87 | int av1_hash_is_horizontal_perfect(const YV12_BUFFER_CONFIG *picture, |
| 88 | int block_size, int x_start, int y_start); |
| 89 | // check whether the block starts from (x_start, y_start) with the size of |
| 90 | // block_size x block_size has the same color in all columns |
| 91 | int av1_hash_is_vertical_perfect(const YV12_BUFFER_CONFIG *picture, |
| 92 | int block_size, int x_start, int y_start); |
chiyotsai | 82f36c9 | 2020-04-09 16:18:02 -0700 | [diff] [blame] | 93 | |
| 94 | void av1_get_block_hash_value(IntraBCHashInfo *intrabc_hash_info, |
| 95 | const uint8_t *y_src, int stride, int block_size, |
Debargha Mukherjee | 1c58301 | 2018-02-28 22:16:16 -0800 | [diff] [blame] | 96 | uint32_t *hash_value1, uint32_t *hash_value2, |
chiyotsai | 82f36c9 | 2020-04-09 16:18:02 -0700 | [diff] [blame] | 97 | int use_highbitdepth); |
RogerZhou | cc5d35d | 2017-08-07 22:20:15 -0700 | [diff] [blame] | 98 | |
| 99 | #ifdef __cplusplus |
| 100 | } // extern "C" |
| 101 | #endif |
| 102 | |
James Zern | e1cbb13 | 2018-08-22 14:10:36 -0700 | [diff] [blame] | 103 | #endif // AOM_AV1_ENCODER_HASH_MOTION_H_ |