PageRenderTime 353ms CodeModel.GetById 68ms RepoModel.GetById 8ms app.codeStats 0ms

/Show/avc/avcdec_api.h

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