| 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 | 22 |
| 22 #ifdef __cplusplus | 23 #ifdef __cplusplus |
| 23 extern "C" { | 24 extern "C" { |
| 24 #endif | 25 #endif |
| 25 | 26 |
| 26 #define MIN(x, y) (((x) < (y)) ? (x) : (y)) | 27 #define MIN(x, y) (((x) < (y)) ? (x) : (y)) |
| 27 #define MAX(x, y) (((x) > (y)) ? (x) : (y)) | 28 #define MAX(x, y) (((x) > (y)) ? (x) : (y)) |
| 28 | 29 |
| 29 #define ROUND_POWER_OF_TWO(value, n) \ | 30 #define ROUND_POWER_OF_TWO(value, n) \ |
| 30 (((value) + (1 << ((n) - 1))) >> (n)) | 31 (((value) + (1 << ((n) - 1))) >> (n)) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 52 } | 53 } |
| 53 | 54 |
| 54 static INLINE int clamp(int value, int low, int high) { | 55 static INLINE int clamp(int value, int low, int high) { |
| 55 return value < low ? low : (value > high ? high : value); | 56 return value < low ? low : (value > high ? high : value); |
| 56 } | 57 } |
| 57 | 58 |
| 58 static INLINE double fclamp(double value, double low, double high) { | 59 static INLINE double fclamp(double value, double low, double high) { |
| 59 return value < low ? low : (value > high ? high : value); | 60 return value < low ? low : (value > high ? high : value); |
| 60 } | 61 } |
| 61 | 62 |
| 62 static int get_unsigned_bits(unsigned int num_values) { | 63 static INLINE int get_unsigned_bits(unsigned int num_values) { |
| 63 int cat = 0; | 64 return num_values > 0 ? get_msb(num_values) + 1 : 0; |
| 64 if (num_values <= 1) | |
| 65 return 0; | |
| 66 num_values--; | |
| 67 while (num_values > 0) { | |
| 68 cat++; | |
| 69 num_values >>= 1; | |
| 70 } | |
| 71 return cat; | |
| 72 } | 65 } |
| 73 | 66 |
| 74 #if CONFIG_DEBUG | 67 #if CONFIG_DEBUG |
| 75 #define CHECK_MEM_ERROR(cm, lval, expr) do { \ | 68 #define CHECK_MEM_ERROR(cm, lval, expr) do { \ |
| 76 lval = (expr); \ | 69 lval = (expr); \ |
| 77 if (!lval) \ | 70 if (!lval) \ |
| 78 vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, \ | 71 vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, \ |
| 79 "Failed to allocate "#lval" at %s:%d", \ | 72 "Failed to allocate "#lval" at %s:%d", \ |
| 80 __FILE__, __LINE__); \ | 73 __FILE__, __LINE__); \ |
| 81 } while (0) | 74 } while (0) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 93 #define VP9_SYNC_CODE_2 0x42 | 86 #define VP9_SYNC_CODE_2 0x42 |
| 94 | 87 |
| 95 #define VP9_FRAME_MARKER 0x2 | 88 #define VP9_FRAME_MARKER 0x2 |
| 96 | 89 |
| 97 | 90 |
| 98 #ifdef __cplusplus | 91 #ifdef __cplusplus |
| 99 } // extern "C" | 92 } // extern "C" |
| 100 #endif | 93 #endif |
| 101 | 94 |
| 102 #endif // VP9_COMMON_VP9_COMMON_H_ | 95 #endif // VP9_COMMON_VP9_COMMON_H_ |
| OLD | NEW |