h264hwd_util.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. -- Abstract : Utility macros and functions
  17. --
  18. --------------------------------------------------------------------------------
  19. --
  20. -- Version control information, please leave untouched.
  21. --
  22. -- $RCSfile: h264hwd_util.h,v $
  23. -- $Date: 2008/09/03 05:56:16 $
  24. -- $Revision: 1.2 $
  25. --
  26. ------------------------------------------------------------------------------*/
  27. #ifndef H264BSDDEC_UTIL_H
  28. #define H264BSDDEC_UTIL_H
  29. /*------------------------------------------------------------------------------
  30. 1. Include headers
  31. ------------------------------------------------------------------------------*/
  32. #include "basetype.h"
  33. #include "dwl.h"
  34. #include "h264hwd_stream.h"
  35. #include "h264hwd_debug.h"
  36. /*------------------------------------------------------------------------------
  37. 2. Module defines
  38. ------------------------------------------------------------------------------*/
  39. #define HANTRO_OK 0
  40. #define HANTRO_NOK 1
  41. #define HANTRO_FALSE (0U)
  42. #define HANTRO_TRUE (1U)
  43. #define MEMORY_ALLOCATION_ERROR 0xFFFF
  44. #define PARAM_SET_ERROR 0xFFF0
  45. /* value to be returned by GetBits if stream buffer is empty */
  46. #define END_OF_STREAM 0xFFFFFFFFU
  47. #define EMPTY_RESIDUAL_INDICATOR 0xFFFFFF
  48. /* macro to mark a residual block empty, i.e. contain zero coefficients */
  49. #define MARK_RESIDUAL_EMPTY(residual) ((residual)[0] = EMPTY_RESIDUAL_INDICATOR)
  50. /* macro to check if residual block is empty */
  51. #define IS_RESIDUAL_EMPTY(residual) ((residual)[0] == EMPTY_RESIDUAL_INDICATOR)
  52. /* macro to get smaller of two values */
  53. #define MIN(a, b) (((a) < (b)) ? (a) : (b))
  54. /* macro to get greater of two values */
  55. #define MAX(a, b) (((a) > (b)) ? (a) : (b))
  56. /* macro to get absolute value */
  57. #define ABS(a) (((a) < 0) ? -(a) : (a))
  58. /* macro to clip a value z, so that x <= z =< y */
  59. #define CLIP3(x,y,z) (((z) < (x)) ? (x) : (((z) > (y)) ? (y) : (z)))
  60. /* macro to clip a value z, so that 0 <= z =< 255 */
  61. #define CLIP1(z) (((z) < 0) ? 0 : (((z) > 255) ? 255 : (z)))
  62. /* macro to allocate memory */
  63. #define ALLOCATE(ptr, count, type) \
  64. { \
  65. ptr = DWLmalloc((count) * sizeof(type)); \
  66. }
  67. /* macro to free allocated memory */
  68. #define FREE(ptr) \
  69. { \
  70. if(ptr != NULL) {DWLfree(ptr); ptr = NULL;}\
  71. }
  72. extern const u32 h264bsdQpC[52];
  73. /*------------------------------------------------------------------------------
  74. 3. Data types
  75. ------------------------------------------------------------------------------*/
  76. typedef enum
  77. {
  78. TOPFIELD = 0,
  79. BOTFIELD = 1,
  80. FRAME = 2
  81. } picStruct_e;
  82. /*------------------------------------------------------------------------------
  83. 4. Function prototypes
  84. ------------------------------------------------------------------------------*/
  85. u32 h264bsdCountLeadingZeros(u32 value, u32 length);
  86. u32 h264bsdRbspTrailingBits(strmData_t * strmData);
  87. u32 h264bsdMoreRbspData(strmData_t * strmData);
  88. u32 h264bsdNextMbAddress(u32 * pSliceGroupMap, u32 picSizeInMbs,
  89. u32 currMbAddr);
  90. u32 h264CheckCabacZeroWords( strmData_t *strmData );
  91. #endif /* #ifdef H264BSDDEC_UTIL_H */