vc1hwd_util.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*------------------------------------------------------------------------------
  2. -- --
  3. -- This software is confidential and proprietary and may be used --
  4. -- only as expressly authorized by a licensing agreement from --
  5. -- --
  6. -- Hantro Products Oy. --
  7. -- --
  8. -- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
  9. -- ALL RIGHTS RESERVED --
  10. -- --
  11. -- The entire notice above must be reproduced --
  12. -- on all copies and should not be removed. --
  13. -- --
  14. --------------------------------------------------------------------------------
  15. --
  16. -- Description : Utility macros and functions
  17. --
  18. --------------------------------------------------------------------------------
  19. --
  20. -- Version control information, please leave untouched.
  21. --
  22. -- $RCSfile: vc1hwd_util.h,v $
  23. -- $Revision: 1.2 $
  24. -- $Date: 2007/11/19 13:00:43 $
  25. --
  26. ------------------------------------------------------------------------------*/
  27. #ifndef VC1HWD_UTIL_H
  28. #define VC1HWD_UTIL_H
  29. /*------------------------------------------------------------------------------
  30. Include headers
  31. ------------------------------------------------------------------------------*/
  32. #include "basetype.h"
  33. #ifdef _ASSERT_USED
  34. #include <assert.h>
  35. #endif
  36. #if defined(_DEBUG_PRINT) || defined(_ERROR_PRINT)
  37. #include <stdio.h>
  38. #endif
  39. /*------------------------------------------------------------------------------
  40. Module defines
  41. ------------------------------------------------------------------------------*/
  42. #define HANTRO_OK 0
  43. #define HANTRO_NOK 1
  44. #define HANTRO_TRUE 1
  45. #define HANTRO_FALSE 0
  46. #ifndef NULL
  47. #define NULL 0
  48. #endif
  49. /* value to be returned by GetBits if stream buffer is empty */
  50. #define END_OF_STREAM 0xFFFFFFFFU
  51. /* macro for assertion, used only if compiler flag _ASSERT_USED is defined */
  52. #ifdef _ASSERT_USED
  53. #define ASSERT(expr) assert(expr)
  54. #else
  55. #define ASSERT(expr)
  56. #endif
  57. /* macro for debug printing, used only if compiler flag _DEBUG_PRINT is
  58. * defined */
  59. #ifdef _DEBUG_PRINT
  60. #define DPRINT(args) printf args ; fflush(stdout)
  61. #else
  62. #define DPRINT(args)
  63. #endif
  64. /* macro for error printing, used only if compiler flag _ERROR_PRINT is
  65. * defined */
  66. #ifdef _ERROR_PRINT
  67. #define EPRINT(msg) fprintf(stderr,"ERROR: %s\n",msg)
  68. #else
  69. #define EPRINT(msg)
  70. #endif
  71. /* macro to get smaller of two values */
  72. #define MIN(a, b) (((a) < (b)) ? (a) : (b))
  73. /* macro to get greater of two values */
  74. #define MAX(a, b) (((a) > (b)) ? (a) : (b))
  75. /* macro to get absolute value */
  76. #define ABS(a) (((a) < 0) ? -(a) : (a))
  77. /* macro to clip a value z, so that x <= z =< y */
  78. #define CLIP3(x,y,z) (((z) < (x)) ? (x) : (((z) > (y)) ? (y) : (z)))
  79. /* macro to clip a value z, so that 0 <= z =< 255 */
  80. #define CLIP1(z) (((z) < 0) ? 0 : (((z) > 255) ? 255 : (z)))
  81. /*------------------------------------------------------------------------------
  82. Data types
  83. ------------------------------------------------------------------------------*/
  84. /*------------------------------------------------------------------------------
  85. Function prototypes
  86. ------------------------------------------------------------------------------*/
  87. #endif /* #ifndef VC1HWD_UTIL_H */