H264PutBits.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 : Bit stream handling
  17. --
  18. ------------------------------------------------------------------------------*/
  19. #ifndef __H264_PUT_BITS_H__
  20. #define __H264_PUT_BITS_H__
  21. /*------------------------------------------------------------------------------
  22. 1. Include headers
  23. ------------------------------------------------------------------------------*/
  24. #include "basetype.h"
  25. #include "enccommon.h"
  26. /*------------------------------------------------------------------------------
  27. 2. External compiler flags
  28. --------------------------------------------------------------------------------
  29. --------------------------------------------------------------------------------
  30. 3. Module defines
  31. ------------------------------------------------------------------------------*/
  32. #if 1
  33. #define H264NalBits(stream, val, num) H264PutNalBits(stream, val, num)
  34. #else
  35. #define H264NalBits(stream, val, num) \
  36. if (stream->bufferedBits + num < 8) { \
  37. i32 bits = stream->bufferedBits + (num); \
  38. stream->bufferedBits += (num); \
  39. stream->byteBuffer = stream->byteBuffer | ((u32)(val) << (32-bits)); \
  40. } else { \
  41. H264PutNalBits(stream, val, num); \
  42. }
  43. #endif
  44. /*------------------------------------------------------------------------------
  45. 4. Function prototypes
  46. ------------------------------------------------------------------------------*/
  47. bool_e H264SetBuffer(stream_s * buffer, u8 * stream, i32 size);
  48. void H264PutBits(stream_s *, i32, i32);
  49. void H264PutNalBits(stream_s *, i32, i32);
  50. void H264ExpGolombUnsigned(stream_s * stream, u32 val);
  51. void H264ExpGolombSigned(stream_s * stream, i32 val);
  52. void H264RbspTrailingBits(stream_s * stream);
  53. void H264Comment(char *comment);
  54. #endif