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