PageRenderTime 24ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/Avc/avcdec_api.h

http://github.com/mbebenita/Broadway
C Header | 200 lines | 46 code | 24 blank | 130 comment | 0 complexity | 22b429c77dbe9d06168b89c5a7b174b0 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 application function interfaces to the AVC decoder library
  20. and necessary type defitionitions and enumerations.
  21. @publishedAll
  22. */
  23. #ifndef _AVCDEC_API_H_
  24. #define _AVCDEC_API_H_
  25. #include "avcapi_common.h"
  26. /**
  27. This enumeration is used for the status returned from the library interface.
  28. */
  29. typedef enum
  30. {
  31. /**
  32. The followings are fail with details. Their values are negative.
  33. */
  34. AVCDEC_NO_DATA = -4,
  35. AVCDEC_PACKET_LOSS = -3,
  36. /**
  37. Fail information
  38. */
  39. AVCDEC_NO_BUFFER = -2, /* no output picture buffer available */
  40. AVCDEC_MEMORY_FAIL = -1, /* memory allocation failed */
  41. AVCDEC_FAIL = 0,
  42. /**
  43. Generic success value
  44. */
  45. AVCDEC_SUCCESS = 1,
  46. AVCDEC_PICTURE_OUTPUT_READY = 2,
  47. AVCDEC_PICTURE_READY = 3,
  48. /**
  49. The followings are success with warnings. Their values are positive integers.
  50. */
  51. AVCDEC_NO_NEXT_SC = 4,
  52. AVCDEC_REDUNDANT_FRAME = 5,
  53. AVCDEC_CONCEALED_FRAME = 6 /* detect and conceal the error */
  54. } AVCDec_Status;
  55. /**
  56. This structure contains sequence parameters information.
  57. */
  58. typedef struct tagAVCDecSPSInfo
  59. {
  60. int FrameWidth;
  61. int FrameHeight;
  62. uint frame_only_flag;
  63. int frame_crop_left;
  64. int frame_crop_right;
  65. int frame_crop_top;
  66. int frame_crop_bottom;
  67. } AVCDecSPSInfo;
  68. #ifdef __cplusplus
  69. extern "C"
  70. {
  71. #endif
  72. /** THE FOLLOWINGS ARE APIS */
  73. /**
  74. This function parses one NAL unit from byte stream format input according to Annex B.
  75. \param "bitstream" "Pointer to the bitstream buffer."
  76. \param "nal_unit" "Point to pointer and the location of the start of the first NAL unit
  77. found in bitstream."
  78. \param "size" "As input, the pointer to the size of bitstream in bytes. As output,
  79. the value is changed to be the size of the found NAL unit."
  80. \return "AVCDEC_SUCCESS if success, AVCDEC_FAIL if no first start code is found, AVCDEC_NO_NEX_SC if
  81. the first start code is found, but the second start code is missing (potential partial NAL)."
  82. */
  83. OSCL_IMPORT_REF AVCDec_Status PVAVCAnnexBGetNALUnit(uint8 *bitstream, uint8 **nal_unit, int *size);
  84. /**
  85. This function sniffs the nal_unit_type such that users can call corresponding APIs.
  86. \param "bitstream" "Pointer to the beginning of a NAL unit (start with forbidden_zero_bit, etc.)."
  87. \param "size" "size of the bitstream (NumBytesInNALunit + 1)."
  88. \param "nal_unit_type" "Pointer to the return value of nal unit type."
  89. \return "AVCDEC_SUCCESS if success, AVCDEC_FAIL otherwise."
  90. */
  91. OSCL_IMPORT_REF AVCDec_Status PVAVCDecGetNALType(uint8 *bitstream, int size, int *nal_type, int *nal_ref_idc);
  92. /**
  93. This function decodes the sequence parameters set, initializes related parameters and
  94. allocates memory (reference frames list), must also be compliant with Annex A.
  95. It is equivalent to decode VOL header of MPEG4.
  96. \param "avcHandle" "Handle to the AVC decoder library object."
  97. \param "nal_unit" "Pointer to the buffer containing single NAL unit.
  98. The content will change due to EBSP-to-RBSP conversion."
  99. \param "nal_size" "size of the bitstream NumBytesInNALunit."
  100. \return "AVCDEC_SUCCESS if success,
  101. AVCDEC_FAIL if profile and level is not supported,
  102. AVCDEC_MEMORY_FAIL if memory allocations return null."
  103. */
  104. OSCL_IMPORT_REF AVCDec_Status PVAVCDecSeqParamSet(AVCHandle *avcHandle, uint8 *nal_unit, int nal_size);
  105. /**
  106. This function returns sequence parameters such as dimension and field flag of the most recently
  107. decoded SPS. More can be added later or grouped together into a structure. This API can be called
  108. after PVAVCInitSequence. If no sequence parameter has been decoded yet, it will return AVCDEC_FAIL.
  109. \param "avcHandle" "Handle to the AVC decoder library object."
  110. \param "seqInfo" "Pointer to the AVCDecSeqParamInfo structure."
  111. \return "AVCDEC_SUCCESS if success and AVCDEC_FAIL if fail."
  112. \note "This API can be combined with PVAVCInitSequence if wanted to be consistent with m4vdec lib."
  113. */
  114. OSCL_IMPORT_REF AVCDec_Status PVAVCDecGetSeqInfo(AVCHandle *avcHandle, AVCDecSPSInfo *seqInfo);
  115. /**
  116. This function decodes the picture parameters set and initializes related parameters. Note thate
  117. the PPS may not be present for every picture.
  118. \param "avcHandle" "Handle to the AVC decoder library object."
  119. \param "nal_unit" "Pointer to the buffer containing single NAL unit.
  120. The content will change due to EBSP-to-RBSP conversion."
  121. \param "nal_size" "size of the bitstream NumBytesInNALunit."
  122. \return "AVCDEC_SUCCESS if success, AVCDEC_FAIL if profile and level is not supported."
  123. */
  124. OSCL_IMPORT_REF AVCDec_Status PVAVCDecPicParamSet(AVCHandle *avcHandle, uint8 *nal_unit, int nal_size);
  125. /**
  126. This function decodes one NAL unit of bitstream. The type of nal unit is one of the
  127. followings, 1, 5. (for now, no data partitioning, type 2,3,4).
  128. \param "avcHandle" "Handle to the AVC decoder library object."
  129. \param "nal_unit" "Pointer to the buffer containing a single or partial NAL unit.
  130. The content will change due to EBSP-to-RBSP conversion."
  131. \param "buf_size" "Size of the buffer (less than or equal nal_size)."
  132. \param "nal_size" "size of the current NAL unit NumBytesInNALunit."
  133. \return "AVCDEC_PICTURE_READY for success and an output is ready,
  134. AVCDEC_SUCCESS for success but no output is ready,
  135. AVCDEC_PACKET_LOSS is GetData returns AVCDEC_PACKET_LOSS,
  136. AVCDEC_FAIL if syntax error is detected,
  137. AVCDEC_MEMORY_FAIL if memory is corrupted.
  138. AVCDEC_NO_PICTURE if no frame memory to write to (users need to get output and/or return picture).
  139. AVCDEC_REDUNDANT_PICTURE if error has been detected in the primary picture and redundant picture is available,
  140. AVCDEC_CONCEALED_PICTURE if error has been detected and decoder has concealed it."
  141. */
  142. OSCL_IMPORT_REF AVCDec_Status PVAVCDecSEI(AVCHandle *avcHandle, uint8 *nal_unit, int nal_size);
  143. OSCL_IMPORT_REF AVCDec_Status PVAVCDecodeSlice(AVCHandle *avcHandle, uint8 *buffer, int buf_size);
  144. /**
  145. Check the availability of the decoded picture in decoding order (frame_num).
  146. The AVCFrameIO also provide displaying order information such that the application
  147. can re-order the frame for display. A picture can be retrieved only once.
  148. \param "avcHandle" "Handle to the AVC decoder library object."
  149. \param "output" "Pointer to the AVCOutput structure. Note that decoder library will
  150. not re-used the pixel memory in this structure until it has been returned
  151. thru PVAVCReleaseOutput API."
  152. \return "AVCDEC_SUCCESS for success, AVCDEC_FAIL if no picture is available to be displayed,
  153. AVCDEC_PICTURE_READY if there is another picture to be displayed."
  154. */
  155. OSCL_IMPORT_REF AVCDec_Status PVAVCDecGetOutput(AVCHandle *avcHandle, int *indx, int *release_flag, AVCFrameIO *output);
  156. /**
  157. This function resets the decoder and expects to see the next IDR slice.
  158. \param "avcHandle" "Handle to the AVC decoder library object."
  159. */
  160. OSCL_IMPORT_REF void PVAVCDecReset(AVCHandle *avcHandle);
  161. /**
  162. This function performs clean up operation including memory deallocation.
  163. \param "avcHandle" "Handle to the AVC decoder library object."
  164. */
  165. OSCL_IMPORT_REF void PVAVCCleanUpDecoder(AVCHandle *avcHandle);
  166. //AVCDec_Status EBSPtoRBSP(uint8 *nal_unit,int *size);
  167. /** CALLBACK FUNCTION TO BE IMPLEMENTED BY APPLICATION */
  168. /** In AVCHandle structure, userData is a pointer to an object with the following
  169. member functions.
  170. */
  171. AVCDec_Status CBAVCDec_GetData(uint32 *userData, unsigned char **buffer, unsigned int *size);
  172. #ifdef __cplusplus
  173. }
  174. #endif
  175. #endif /* _AVCDEC_API_H_ */