common.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 VPX_VP8_COMMON_COMMON_H_
  11. #define VPX_VP8_COMMON_COMMON_H_
  12. #include <assert.h>
  13. /* Interface header for common constant data structures and lookup tables */
  14. #include "vpx_mem/vpx_mem.h"
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. /* Only need this for fixed-size arrays, for structs just assign. */
  19. #define vp8_copy(Dest, Src) \
  20. { \
  21. assert(sizeof(Dest) == sizeof(Src)); \
  22. memcpy(Dest, Src, sizeof(Src)); \
  23. }
  24. /* Use this for variably-sized arrays. */
  25. #define vp8_copy_array(Dest, Src, N) \
  26. { \
  27. assert(sizeof(*(Dest)) == sizeof(*(Src))); \
  28. memcpy(Dest, Src, (N) * sizeof(*(Src))); \
  29. }
  30. #define vp8_zero(Dest) memset(&(Dest), 0, sizeof(Dest));
  31. #define vp8_zero_array(Dest, N) memset(Dest, 0, (N) * sizeof(*(Dest)));
  32. #ifdef __cplusplus
  33. } // extern "C"
  34. #endif
  35. #endif // VPX_VP8_COMMON_COMMON_H_