pvmp3decoder_api.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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. ------------------------------------------------------------------------------
  20. PacketVideo Corp.
  21. MP3 Decoder Library
  22. Filename: pvmp3decoder_api.h
  23. Date: 09/21/2007
  24. ------------------------------------------------------------------------------
  25. REVISION HISTORY
  26. Description:
  27. ------------------------------------------------------------------------------
  28. INCLUDE DESCRIPTION
  29. This include file defines the structure tPVMP3DecoderExternal
  30. ------------------------------------------------------------------------------
  31. */
  32. /*----------------------------------------------------------------------------
  33. ; CONTINUE ONLY IF NOT ALREADY DEFINED
  34. ----------------------------------------------------------------------------*/
  35. #ifndef PVMP3DECODER_API_H
  36. #define PVMP3DECODER_API_H
  37. /*----------------------------------------------------------------------------
  38. ; INCLUDES
  39. ----------------------------------------------------------------------------*/
  40. #include "pvmp3_audio_type_defs.h"
  41. #include "pvmp3_dec_defs.h"
  42. /*----------------------------------------------------------------------------
  43. ; MACROS
  44. ; Define module specific macros here
  45. ----------------------------------------------------------------------------*/
  46. #ifdef __cplusplus
  47. extern "C"
  48. {
  49. #endif
  50. /*----------------------------------------------------------------------------
  51. ; DEFINES
  52. ; Include all pre-processor statements here.
  53. ----------------------------------------------------------------------------*/
  54. /*----------------------------------------------------------------------------
  55. ; EXTERNAL VARIABLES REFERENCES
  56. ; Declare variables used in this module but defined elsewhere
  57. ----------------------------------------------------------------------------*/
  58. /*----------------------------------------------------------------------------
  59. ; SIMPLE TYPEDEF'S
  60. ----------------------------------------------------------------------------*/
  61. /*----------------------------------------------------------------------------
  62. ; ENUMERATED TYPEDEF'S
  63. ----------------------------------------------------------------------------*/
  64. typedef enum
  65. {
  66. flat = 0,
  67. bass_boost = 1,
  68. rock = 2,
  69. pop = 3,
  70. jazz = 4,
  71. classical = 5,
  72. talk = 6,
  73. flat_ = 7
  74. } e_equalization;
  75. typedef enum ERROR_CODE
  76. {
  77. NO_DECODING_ERROR = 0,
  78. UNSUPPORTED_LAYER = 1,
  79. UNSUPPORTED_FREE_BITRATE = 2,
  80. FILE_OPEN_ERROR = 3, /* error opening file */
  81. CHANNEL_CONFIG_ERROR = 4, /* error in channel configuration */
  82. SYNTHESIS_WINDOW_ERROR = 5, /* error in synthesis window table */
  83. READ_FILE_ERROR = 6, /* error reading input file */
  84. SIDE_INFO_ERROR = 7, /* error in side info */
  85. HUFFMAN_TABLE_ERROR = 8, /* error in Huffman table */
  86. COMMAND_LINE_ERROR = 9, /* error in command line */
  87. MEMORY_ALLOCATION_ERROR = 10, /* error allocating memory */
  88. NO_ENOUGH_MAIN_DATA_ERROR = 11,
  89. SYNCH_LOST_ERROR = 12,
  90. OUTPUT_BUFFER_TOO_SMALL = 13 /* output buffer can't hold output */
  91. } ERROR_CODE;
  92. /*----------------------------------------------------------------------------
  93. ; STRUCTURES TYPEDEF'S
  94. ----------------------------------------------------------------------------*/
  95. typedef struct
  96. #ifdef __cplusplus
  97. tPVMP3DecoderExternal
  98. #endif
  99. {
  100. /*
  101. * INPUT:
  102. * Pointer to the input buffer that contains the encoded bistream data.
  103. * The data is filled in such that the first bit transmitted is
  104. * the most-significant bit (MSB) of the first array element.
  105. * The buffer is accessed in a linear fashion for speed, and the number of
  106. * bytes consumed varies frame to frame.
  107. * The calling environment can change what is pointed to between calls to
  108. * the decode function, library, as long as the inputBufferCurrentLength,
  109. * and inputBufferUsedLength are updated too. Also, any remaining bits in
  110. * the old buffer must be put at the beginning of the new buffer.
  111. */
  112. uint8 *pInputBuffer;
  113. /*
  114. * INPUT:
  115. * Number of valid bytes in the input buffer, set by the calling
  116. * function. After decoding the bitstream the library checks to
  117. * see if it when past this value; it would be to prohibitive to
  118. * check after every read operation. This value is not modified by
  119. * the MP3 library.
  120. */
  121. int32 inputBufferCurrentLength;
  122. /*
  123. * INPUT/OUTPUT:
  124. * Number of elements used by the library, initially set to zero by
  125. * the function pvmp3_resetDecoder(), and modified by each
  126. * call to pvmp3_framedecoder().
  127. */
  128. int32 inputBufferUsedLength;
  129. /*
  130. * OUTPUT:
  131. * holds the predicted frame size. It used on the test console, for parsing
  132. * purposes.
  133. */
  134. uint32 CurrentFrameLength;
  135. /*
  136. * INPUT:
  137. * This variable holds the type of equalization used
  138. *
  139. *
  140. */
  141. e_equalization equalizerType;
  142. /*
  143. * INPUT:
  144. * The actual size of the buffer.
  145. * This variable is not used by the library, but is used by the
  146. * console test application. This parameter could be deleted
  147. * if this value was passed into these function.
  148. */
  149. int32 inputBufferMaxLength;
  150. /*
  151. * OUTPUT:
  152. * The number of channels decoded from the bitstream.
  153. */
  154. int16 num_channels;
  155. /*
  156. * OUTPUT:
  157. * The number of channels decoded from the bitstream.
  158. */
  159. int16 version;
  160. /*
  161. * OUTPUT:
  162. * The sampling rate decoded from the bitstream, in units of
  163. * samples/second.
  164. */
  165. int32 samplingRate;
  166. /*
  167. * OUTPUT:
  168. * This value is the bitrate in units of bits/second. IT
  169. * is calculated using the number of bits consumed for the current frame,
  170. * and then multiplying by the sampling_rate, divided by points in a frame.
  171. * This value can changes frame to frame.
  172. */
  173. int32 bitRate;
  174. /*
  175. * INPUT/OUTPUT:
  176. * In: Inform decoder how much more room is available in the output buffer in int16 samples
  177. * Out: Size of the output frame in 16-bit words, This value depends on the mp3 version
  178. */
  179. int32 outputFrameSize;
  180. /*
  181. * INPUT:
  182. * Flag to enable/disable crc error checking
  183. */
  184. int32 crcEnabled;
  185. /*
  186. * OUTPUT:
  187. * This value is used to accumulate bit processed and compute an estimate of the
  188. * bitrate. For debugging purposes only, as it will overflow for very long clips
  189. */
  190. uint32 totalNumberOfBitsUsed;
  191. /*
  192. * INPUT: (but what is pointed to is an output)
  193. * Pointer to the output buffer to hold the 16-bit PCM audio samples.
  194. * If the output is stereo, both left and right channels will be stored
  195. * in this one buffer.
  196. */
  197. int16 *pOutputBuffer;
  198. } tPVMP3DecoderExternal;
  199. uint32 pvmp3_decoderMemRequirements(void);
  200. void pvmp3_InitDecoder(tPVMP3DecoderExternal *pExt,
  201. void *pMem);
  202. void pvmp3_resetDecoder(void *pMem);
  203. ERROR_CODE pvmp3_framedecoder(tPVMP3DecoderExternal *pExt,
  204. void *pMem);
  205. #ifdef __cplusplus
  206. }
  207. #endif
  208. /*----------------------------------------------------------------------------
  209. ; END
  210. ----------------------------------------------------------------------------*/
  211. #endif