xref: /aosp_15_r20/external/libaom/av1/common/common.h (revision 77c1e3ccc04c968bd2bc212e87364f250e820521)
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_COMMON_COMMON_H_
13 #define AOM_AV1_COMMON_COMMON_H_
14 
15 /* Interface header for common constant data structures and lookup tables */
16 
17 #include <assert.h>
18 
19 #include "aom_dsp/aom_dsp_common.h"
20 #include "aom_mem/aom_mem.h"
21 #include "aom/aom_integer.h"
22 #include "aom_ports/bitops.h"
23 #include "config/aom_config.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 // Only need this for fixed-size arrays, for structs just assign.
30 #define av1_copy(dest, src)              \
31   do {                                   \
32     assert(sizeof(dest) == sizeof(src)); \
33     memcpy(dest, src, sizeof(src));      \
34   } while (0)
35 
36 // Use this for variably-sized arrays.
37 #define av1_copy_array(dest, src, n)           \
38   do {                                         \
39     assert(sizeof(*(dest)) == sizeof(*(src))); \
40     memcpy(dest, src, n * sizeof(*(src)));     \
41   } while (0)
42 
43 #define av1_zero(dest) memset(&(dest), 0, sizeof(dest))
44 #define av1_zero_array(dest, n) memset(dest, 0, n * sizeof(*(dest)))
45 
get_unsigned_bits(unsigned int num_values)46 static inline int get_unsigned_bits(unsigned int num_values) {
47   return num_values > 0 ? get_msb(num_values) + 1 : 0;
48 }
49 
50 #define CHECK_MEM_ERROR(cm, lval, expr) \
51   AOM_CHECK_MEM_ERROR((cm)->error, lval, expr)
52 
53 #define AOM_FRAME_MARKER 0x2
54 
55 #define AV1_MIN_TILE_SIZE_BYTES 1
56 
57 #ifdef __cplusplus
58 }  // extern "C"
59 #endif
60 
61 #endif  // AOM_AV1_COMMON_COMMON_H_
62