OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef VP9_COMMON_VP9_COMMON_H_ | 11 #ifndef VP9_COMMON_VP9_COMMON_H_ |
12 #define VP9_COMMON_VP9_COMMON_H_ | 12 #define VP9_COMMON_VP9_COMMON_H_ |
13 | 13 |
14 /* Interface header for common constant data structures and lookup tables */ | 14 /* Interface header for common constant data structures and lookup tables */ |
15 | 15 |
16 #include <assert.h> | 16 #include <assert.h> |
17 | 17 |
18 #include "./vpx_config.h" | 18 #include "./vpx_config.h" |
19 #include "vpx_mem/vpx_mem.h" | 19 #include "vpx_mem/vpx_mem.h" |
20 #include "vpx/vpx_integer.h" | 20 #include "vpx/vpx_integer.h" |
21 #include "vp9/common/vp9_systemdependent.h" | 21 #include "vp9/common/vp9_systemdependent.h" |
22 | 22 |
23 #ifdef __cplusplus | 23 #ifdef __cplusplus |
24 extern "C" { | 24 extern "C" { |
25 #endif | 25 #endif |
26 | 26 |
27 #define MIN(x, y) (((x) < (y)) ? (x) : (y)) | 27 #define MIN(x, y) (((x) < (y)) ? (x) : (y)) |
28 #define MAX(x, y) (((x) > (y)) ? (x) : (y)) | 28 #define MAX(x, y) (((x) > (y)) ? (x) : (y)) |
29 | 29 |
30 #define ROUND_POWER_OF_TWO(value, n) \ | |
31 (((value) + (1 << ((n) - 1))) >> (n)) | |
32 | |
33 #define ALIGN_POWER_OF_TWO(value, n) \ | |
34 (((value) + ((1 << (n)) - 1)) & ~((1 << (n)) - 1)) | |
35 | |
36 // Only need this for fixed-size arrays, for structs just assign. | 30 // Only need this for fixed-size arrays, for structs just assign. |
37 #define vp9_copy(dest, src) { \ | 31 #define vp9_copy(dest, src) { \ |
38 assert(sizeof(dest) == sizeof(src)); \ | 32 assert(sizeof(dest) == sizeof(src)); \ |
39 memcpy(dest, src, sizeof(src)); \ | 33 memcpy(dest, src, sizeof(src)); \ |
40 } | 34 } |
41 | 35 |
42 // Use this for variably-sized arrays. | 36 // Use this for variably-sized arrays. |
43 #define vp9_copy_array(dest, src, n) { \ | 37 #define vp9_copy_array(dest, src, n) { \ |
44 assert(sizeof(*dest) == sizeof(*src)); \ | 38 assert(sizeof(*dest) == sizeof(*src)); \ |
45 memcpy(dest, src, n * sizeof(*src)); \ | 39 memcpy(dest, src, n * sizeof(*src)); \ |
(...skipping 30 matching lines...) Expand all Loading... |
76 return (uint16_t)clamp(val, 0, 4095); | 70 return (uint16_t)clamp(val, 0, 4095); |
77 } | 71 } |
78 } | 72 } |
79 | 73 |
80 // Note: | 74 // Note: |
81 // tran_low_t is the datatype used for final transform coefficients. | 75 // tran_low_t is the datatype used for final transform coefficients. |
82 // tran_high_t is the datatype used for intermediate transform stages. | 76 // tran_high_t is the datatype used for intermediate transform stages. |
83 typedef int64_t tran_high_t; | 77 typedef int64_t tran_high_t; |
84 typedef int32_t tran_low_t; | 78 typedef int32_t tran_low_t; |
85 | 79 |
86 #define CONVERT_TO_SHORTPTR(x) ((uint16_t*)(((uintptr_t)x) << 1)) | |
87 #define CONVERT_TO_BYTEPTR(x) ((uint8_t*)(((uintptr_t)x) >> 1 )) | |
88 | |
89 #else | 80 #else |
90 | 81 |
91 // Note: | 82 // Note: |
92 // tran_low_t is the datatype used for final transform coefficients. | 83 // tran_low_t is the datatype used for final transform coefficients. |
93 // tran_high_t is the datatype used for intermediate transform stages. | 84 // tran_high_t is the datatype used for intermediate transform stages. |
94 typedef int32_t tran_high_t; | 85 typedef int32_t tran_high_t; |
95 typedef int16_t tran_low_t; | 86 typedef int16_t tran_low_t; |
96 #endif // CONFIG_VP9_HIGHBITDEPTH | 87 #endif // CONFIG_VP9_HIGHBITDEPTH |
97 | 88 |
98 #if CONFIG_DEBUG | 89 #if CONFIG_DEBUG |
(...skipping 18 matching lines...) Expand all Loading... |
117 #define VP9_SYNC_CODE_2 0x42 | 108 #define VP9_SYNC_CODE_2 0x42 |
118 | 109 |
119 #define VP9_FRAME_MARKER 0x2 | 110 #define VP9_FRAME_MARKER 0x2 |
120 | 111 |
121 | 112 |
122 #ifdef __cplusplus | 113 #ifdef __cplusplus |
123 } // extern "C" | 114 } // extern "C" |
124 #endif | 115 #endif |
125 | 116 |
126 #endif // VP9_COMMON_VP9_COMMON_H_ | 117 #endif // VP9_COMMON_VP9_COMMON_H_ |
OLD | NEW |