vp9_common.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
  3. *
  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
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #ifndef VP9_COMMON_VP9_COMMON_H_
  11. #define VP9_COMMON_VP9_COMMON_H_
  12. /* Interface header for common constant data structures and lookup tables */
  13. #include <assert.h>
  14. #include "./vpx_config.h"
  15. #include "vpx_dsp/vpx_dsp_common.h"
  16. #include "vpx_mem/vpx_mem.h"
  17. #include "vpx/vpx_integer.h"
  18. #include "vpx_ports/bitops.h"
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. // Only need this for fixed-size arrays, for structs just assign.
  23. #define vp9_copy(dest, src) { \
  24. assert(sizeof(dest) == sizeof(src)); \
  25. memcpy(dest, src, sizeof(src)); \
  26. }
  27. // Use this for variably-sized arrays.
  28. #define vp9_copy_array(dest, src, n) { \
  29. assert(sizeof(*dest) == sizeof(*src)); \
  30. memcpy(dest, src, n * sizeof(*src)); \
  31. }
  32. #define vp9_zero(dest) memset(&(dest), 0, sizeof(dest))
  33. #define vp9_zero_array(dest, n) memset(dest, 0, n * sizeof(*dest))
  34. static INLINE int get_unsigned_bits(unsigned int num_values) {
  35. return num_values > 0 ? get_msb(num_values) + 1 : 0;
  36. }
  37. #if CONFIG_DEBUG
  38. #define CHECK_MEM_ERROR(cm, lval, expr) do { \
  39. lval = (expr); \
  40. if (!lval) \
  41. vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, \
  42. "Failed to allocate "#lval" at %s:%d", \
  43. __FILE__, __LINE__); \
  44. } while (0)
  45. #else
  46. #define CHECK_MEM_ERROR(cm, lval, expr) do { \
  47. lval = (expr); \
  48. if (!lval) \
  49. vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, \
  50. "Failed to allocate "#lval); \
  51. } while (0)
  52. #endif
  53. #define VP9_SYNC_CODE_0 0x49
  54. #define VP9_SYNC_CODE_1 0x83
  55. #define VP9_SYNC_CODE_2 0x42
  56. #define VP9_FRAME_MARKER 0x2
  57. #ifdef __cplusplus
  58. } // extern "C"
  59. #endif
  60. #endif // VP9_COMMON_VP9_COMMON_H_