You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.2KB

  1. /*
  2. * This file is part of FFmpeg.
  3. *
  4. * FFmpeg is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * FFmpeg is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with FFmpeg; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. /**
  19. * @file
  20. * @ingroup lavu
  21. * Utility Preprocessor macros
  22. */
  23. #ifndef AVUTIL_MACROS_H
  24. #define AVUTIL_MACROS_H
  25. #include "libavutil/avconfig.h"
  26. #if AV_HAVE_BIGENDIAN
  27. # define AV_NE(be, le) (be)
  28. #else
  29. # define AV_NE(be, le) (le)
  30. #endif
  31. /**
  32. * Comparator.
  33. * For two numerical expressions x and y, gives 1 if x > y, -1 if x < y, and 0
  34. * if x == y. This is useful for instance in a qsort comparator callback.
  35. * Furthermore, compilers are able to optimize this to branchless code, and
  36. * there is no risk of overflow with signed types.
  37. * As with many macros, this evaluates its argument multiple times, it thus
  38. * must not have a side-effect.
  39. */
  40. #define FFDIFFSIGN(x,y) (((x)>(y)) - ((x)<(y)))
  41. #define FFMAX(a,b) ((a) > (b) ? (a) : (b))
  42. #define FFMAX3(a,b,c) FFMAX(FFMAX(a,b),c)
  43. #define FFMIN(a,b) ((a) > (b) ? (b) : (a))
  44. #define FFMIN3(a,b,c) FFMIN(FFMIN(a,b),c)
  45. #define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0)
  46. #define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0]))
  47. #define MKTAG(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((unsigned)(d) << 24))
  48. #define MKBETAG(a,b,c,d) ((d) | ((c) << 8) | ((b) << 16) | ((unsigned)(a) << 24))
  49. /**
  50. * @addtogroup preproc_misc Preprocessor String Macros
  51. *
  52. * String manipulation macros
  53. *
  54. * @{
  55. */
  56. #define AV_STRINGIFY(s) AV_TOSTRING(s)
  57. #define AV_TOSTRING(s) #s
  58. #define AV_GLUE(a, b) a ## b
  59. #define AV_JOIN(a, b) AV_GLUE(a, b)
  60. /**
  61. * @}
  62. */
  63. #define AV_PRAGMA(s) _Pragma(#s)
  64. #define FFALIGN(x, a) (((x)+(a)-1)&~((a)-1))
  65. #endif /* AVUTIL_MACROS_H */