PageRenderTime 143ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/Avc/avcdec_bitstream.h

http://github.com/mbebenita/Broadway
C Header | 125 lines | 25 code | 18 blank | 82 comment | 0 complexity | 988f4d07197f0112b510d305c3c9121a MD5 | raw file
Possible License(s): BSD-3-Clause
  1. /* ------------------------------------------------------------------
  2. * Copyright (C) 1998-2009 PacketVideo
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  13. * express or implied.
  14. * See the License for the specific language governing permissions
  15. * and limitations under the License.
  16. * -------------------------------------------------------------------
  17. */
  18. /**
  19. This file contains bitstream related functions.
  20. @publishedAll
  21. */
  22. #ifndef _AVCDEC_BITSTREAM_H_
  23. #define _AVCDEC_BITSTREAM_H_
  24. #include "avcdec_lib.h"
  25. #define WORD_SIZE 32 /* this can vary, default to 32 bit for now */
  26. #ifndef __cplusplus
  27. #define AVC_GETDATA(x,y) userData->AVC_GetData(x,y)
  28. #endif
  29. #ifdef __cplusplus
  30. extern "C"
  31. {
  32. #endif
  33. #define BitstreamFlushBits(A,B) {(A)->bitcnt += (B); (A)->incnt -= (B); (A)->curr_word <<= (B);}
  34. AVCDec_Status AVC_BitstreamFillCache(AVCDecBitstream *stream);
  35. /**
  36. This function populates bitstream structure.
  37. \param "stream" "Pointer to bitstream structure."
  38. \param "buffer" "Pointer to the bitstream buffer."
  39. \param "size" "Size of the buffer."
  40. \param "nal_size" "Size of the NAL unit."
  41. \param "resetall" "Flag for reset everything."
  42. \return "AVCDEC_SUCCESS for success and AVCDEC_FAIL for fail."
  43. */
  44. AVCDec_Status BitstreamInit(AVCDecBitstream *stream, uint8 *buffer, int size);
  45. /**
  46. This function reads next aligned word and remove the emulation prevention code
  47. if necessary.
  48. \param "stream" "Pointer to bitstream structure."
  49. \return "Next word."
  50. */
  51. uint BitstreamNextWord(AVCDecBitstream *stream);
  52. /**
  53. This function reads nBits bits from the current position and advance the pointer.
  54. \param "stream" "Pointer to bitstream structure."
  55. \param "nBits" "Number of bits to be read."
  56. \param "code" "Point to the read value."
  57. \return "AVCDEC_SUCCESS if successed, AVCDEC_FAIL if number of bits
  58. is greater than the word-size, AVCDEC_PACKET_LOSS or
  59. AVCDEC_NO_DATA if callback to get data fails."
  60. */
  61. AVCDec_Status BitstreamReadBits(AVCDecBitstream *stream, int nBits, uint *code);
  62. /**
  63. This function shows nBits bits from the current position without advancing the pointer.
  64. \param "stream" "Pointer to bitstream structure."
  65. \param "nBits" "Number of bits to be read."
  66. \param "code" "Point to the read value."
  67. \return "AVCDEC_SUCCESS if successed, AVCDEC_FAIL if number of bits
  68. is greater than the word-size, AVCDEC_NO_DATA if it needs
  69. to callback to get data."
  70. */
  71. AVCDec_Status BitstreamShowBits(AVCDecBitstream *stream, int nBits, uint *code);
  72. /**
  73. This function flushes nBits bits from the current position.
  74. \param "stream" "Pointer to bitstream structure."
  75. \param "nBits" "Number of bits to be read."
  76. \return "AVCDEC_SUCCESS if successed, AVCDEC_FAIL if number of bits
  77. is greater than the word-size It will not call back to get
  78. more data. Users should call BitstreamShowBits to determine
  79. how much they want to flush."
  80. */
  81. /**
  82. This function read 1 bit from the current position and advance the pointer.
  83. \param "stream" "Pointer to bitstream structure."
  84. \param "nBits" "Number of bits to be read."
  85. \param "code" "Point to the read value."
  86. \return "AVCDEC_SUCCESS if successed, AVCDEC_FAIL if number of bits
  87. is greater than the word-size, AVCDEC_PACKET_LOSS or
  88. AVCDEC_NO_DATA if callback to get data fails."
  89. */
  90. AVCDec_Status BitstreamRead1Bit(AVCDecBitstream *stream, uint *code);
  91. /**
  92. This function checks whether the current bit position is byte-aligned or not.
  93. \param "stream" "Pointer to the bitstream structure."
  94. \return "TRUE if byte-aligned, FALSE otherwise."
  95. */
  96. bool byte_aligned(AVCDecBitstream *stream);
  97. AVCDec_Status BitstreamByteAlign(AVCDecBitstream *stream);
  98. /**
  99. This function checks whether there are more RBSP data before the trailing bits.
  100. \param "stream" "Pointer to the bitstream structure."
  101. \return "TRUE if yes, FALSE otherwise."
  102. */
  103. bool more_rbsp_data(AVCDecBitstream *stream);
  104. #ifdef __cplusplus
  105. }
  106. #endif /* __cplusplus */
  107. #endif /* _AVCDEC_BITSTREAM_H_ */