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_H_
13 #define AOM_AV1_ENCODER_HASH_H_
14 
15 #include "config/aom_config.h"
16 
17 #include "aom/aom_integer.h"
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 typedef struct _crc_calculator {
24   uint32_t remainder;
25   uint32_t trunc_poly;
26   uint32_t bits;
27   uint32_t table[256];
28   uint32_t final_result_mask;
29 } CRC_CALCULATOR;
30 
31 // Initialize the crc calculator. It must be executed at least once before
32 // calling av1_get_crc_value().
33 void av1_crc_calculator_init(CRC_CALCULATOR *p_crc_calculator, uint32_t bits,
34                              uint32_t truncPoly);
35 uint32_t av1_get_crc_value(void *crc_calculator, uint8_t *p, int length);
36 
37 // CRC32C: POLY = 0x82f63b78;
38 typedef struct _CRC32C {
39   /* Table for a quadword-at-a-time software crc. */
40   uint32_t table[8][256];
41 } CRC32C;
42 
43 // init table for software version crc32c
44 void av1_crc32c_calculator_init(CRC32C *p_crc32c);
45 
46 #define AOM_BUFFER_SIZE_FOR_BLOCK_HASH (4096)
47 
48 #ifdef __cplusplus
49 }  // extern "C"
50 #endif
51 
52 #endif  // AOM_AV1_ENCODER_HASH_H_
53