neaacdec.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. /*
  2. ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
  3. ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
  4. **
  5. ** This program is free software; you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation; either version 2 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program; if not, write to the Free Software
  17. ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. **
  19. ** Any non-GPL usage of this software or parts of this software is strictly
  20. ** forbidden.
  21. **
  22. ** The "appropriate copyright message" mentioned in section 2c of the GPLv2
  23. ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
  24. **
  25. ** Commercial non-GPL licensing of this software is possible.
  26. ** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
  27. **
  28. ** $Id: neaacdec.h,v 1.13 2009/01/26 23:51:15 menno Exp $
  29. **/
  30. #ifndef __NEAACDEC_H__
  31. #define __NEAACDEC_H__
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif /* __cplusplus */
  35. #if 1
  36. /* MACROS FOR BACKWARDS COMPATIBILITY */
  37. /* structs */
  38. #define faacDecHandle NeAACDecHandle
  39. #define faacDecConfiguration NeAACDecConfiguration
  40. #define faacDecConfigurationPtr NeAACDecConfigurationPtr
  41. #define faacDecFrameInfo NeAACDecFrameInfo
  42. /* functions */
  43. #define faacDecGetErrorMessage NeAACDecGetErrorMessage
  44. #define faacDecSetConfiguration NeAACDecSetConfiguration
  45. #define faacDecGetCurrentConfiguration NeAACDecGetCurrentConfiguration
  46. #define faacDecInit NeAACDecInit
  47. #define faacDecInit2 NeAACDecInit2
  48. #define faacDecInitDRM NeAACDecInitDRM
  49. #define faacDecPostSeekReset NeAACDecPostSeekReset
  50. #define faacDecOpen NeAACDecOpen
  51. #define faacDecClose NeAACDecClose
  52. #define faacDecDecode NeAACDecDecode
  53. #define AudioSpecificConfig NeAACDecAudioSpecificConfig
  54. #endif
  55. #ifdef _WIN32
  56. #pragma pack(push, 8)
  57. #ifndef NEAACDECAPI
  58. #define NEAACDECAPI __cdecl
  59. #endif
  60. #else
  61. #ifndef NEAACDECAPI
  62. #define NEAACDECAPI
  63. #endif
  64. #endif
  65. #define FAAD2_VERSION "2.7"
  66. /* object types for AAC */
  67. #define MAIN 1
  68. #define LC 2
  69. #define SSR 3
  70. #define LTP 4
  71. #define HE_AAC 5
  72. #define ER_LC 17
  73. #define ER_LTP 19
  74. #define LD 23
  75. #define DRM_ER_LC 27 /* special object type for DRM */
  76. /* header types */
  77. #define RAW 0
  78. #define ADIF 1
  79. #define ADTS 2
  80. #define LATM 3
  81. /* SBR signalling */
  82. #define NO_SBR 0
  83. #define SBR_UPSAMPLED 1
  84. #define SBR_DOWNSAMPLED 2
  85. #define NO_SBR_UPSAMPLED 3
  86. /* library output formats */
  87. #define FAAD_FMT_16BIT 1
  88. #define FAAD_FMT_24BIT 2
  89. #define FAAD_FMT_32BIT 3
  90. #define FAAD_FMT_FLOAT 4
  91. #define FAAD_FMT_FIXED FAAD_FMT_FLOAT
  92. #define FAAD_FMT_DOUBLE 5
  93. /* Capabilities */
  94. #define LC_DEC_CAP (1<<0) /* Can decode LC */
  95. #define MAIN_DEC_CAP (1<<1) /* Can decode MAIN */
  96. #define LTP_DEC_CAP (1<<2) /* Can decode LTP */
  97. #define LD_DEC_CAP (1<<3) /* Can decode LD */
  98. #define ERROR_RESILIENCE_CAP (1<<4) /* Can decode ER */
  99. #define FIXED_POINT_CAP (1<<5) /* Fixed point */
  100. /* Channel definitions */
  101. #define FRONT_CHANNEL_CENTER (1)
  102. #define FRONT_CHANNEL_LEFT (2)
  103. #define FRONT_CHANNEL_RIGHT (3)
  104. #define SIDE_CHANNEL_LEFT (4)
  105. #define SIDE_CHANNEL_RIGHT (5)
  106. #define BACK_CHANNEL_LEFT (6)
  107. #define BACK_CHANNEL_RIGHT (7)
  108. #define BACK_CHANNEL_CENTER (8)
  109. #define LFE_CHANNEL (9)
  110. #define UNKNOWN_CHANNEL (0)
  111. /* DRM channel definitions */
  112. #define DRMCH_MONO 1
  113. #define DRMCH_STEREO 2
  114. #define DRMCH_SBR_MONO 3
  115. #define DRMCH_SBR_STEREO 4
  116. #define DRMCH_SBR_PS_STEREO 5
  117. /* A decode call can eat up to FAAD_MIN_STREAMSIZE bytes per decoded channel,
  118. so at least so much bytes per channel should be available in this stream */
  119. #define FAAD_MIN_STREAMSIZE 768 /* 6144 bits/channel */
  120. typedef void *NeAACDecHandle;
  121. typedef struct mp4AudioSpecificConfig
  122. {
  123. /* Audio Specific Info */
  124. unsigned char objectTypeIndex;
  125. unsigned char samplingFrequencyIndex;
  126. unsigned long samplingFrequency;
  127. unsigned char channelsConfiguration;
  128. /* GA Specific Info */
  129. unsigned char frameLengthFlag;
  130. unsigned char dependsOnCoreCoder;
  131. unsigned short coreCoderDelay;
  132. unsigned char extensionFlag;
  133. unsigned char aacSectionDataResilienceFlag;
  134. unsigned char aacScalefactorDataResilienceFlag;
  135. unsigned char aacSpectralDataResilienceFlag;
  136. unsigned char epConfig;
  137. char sbr_present_flag;
  138. char forceUpSampling;
  139. char downSampledSBR;
  140. } mp4AudioSpecificConfig;
  141. typedef struct NeAACDecConfiguration
  142. {
  143. unsigned char defObjectType;
  144. unsigned long defSampleRate;
  145. unsigned char outputFormat;
  146. unsigned char downMatrix;
  147. unsigned char useOldADTSFormat;
  148. unsigned char dontUpSampleImplicitSBR;
  149. } NeAACDecConfiguration, *NeAACDecConfigurationPtr;
  150. typedef struct NeAACDecFrameInfo
  151. {
  152. unsigned long bytesconsumed;
  153. unsigned long samples;
  154. unsigned char channels;
  155. unsigned char error;
  156. unsigned long samplerate;
  157. /* SBR: 0: off, 1: on; upsample, 2: on; downsampled, 3: off; upsampled */
  158. unsigned char sbr;
  159. /* MPEG-4 ObjectType */
  160. unsigned char object_type;
  161. /* AAC header type; MP4 will be signalled as RAW also */
  162. unsigned char header_type;
  163. /* multichannel configuration */
  164. unsigned char num_front_channels;
  165. unsigned char num_side_channels;
  166. unsigned char num_back_channels;
  167. unsigned char num_lfe_channels;
  168. unsigned char channel_position[64];
  169. /* PS: 0: off, 1: on */
  170. unsigned char ps;
  171. } NeAACDecFrameInfo;
  172. char* NEAACDECAPI NeAACDecGetErrorMessage(unsigned char errcode);
  173. unsigned long NEAACDECAPI NeAACDecGetCapabilities(void);
  174. NeAACDecHandle NEAACDECAPI NeAACDecOpen(void);
  175. NeAACDecConfigurationPtr NEAACDECAPI NeAACDecGetCurrentConfiguration(NeAACDecHandle hDecoder);
  176. unsigned char NEAACDECAPI NeAACDecSetConfiguration(NeAACDecHandle hDecoder,
  177. NeAACDecConfigurationPtr config);
  178. /* Init the library based on info from the AAC file (ADTS/ADIF) */
  179. long NEAACDECAPI NeAACDecInit(NeAACDecHandle hDecoder,
  180. unsigned char *buffer,
  181. unsigned long buffer_size,
  182. unsigned long *samplerate,
  183. unsigned char *channels);
  184. /* Init the library using a DecoderSpecificInfo */
  185. char NEAACDECAPI NeAACDecInit2(NeAACDecHandle hDecoder,
  186. unsigned char *pBuffer,
  187. unsigned long SizeOfDecoderSpecificInfo,
  188. unsigned long *samplerate,
  189. unsigned char *channels);
  190. /* Init the library for DRM */
  191. char NEAACDECAPI NeAACDecInitDRM(NeAACDecHandle *hDecoder, unsigned long samplerate,
  192. unsigned char channels);
  193. void NEAACDECAPI NeAACDecPostSeekReset(NeAACDecHandle hDecoder, long frame);
  194. void NEAACDECAPI NeAACDecClose(NeAACDecHandle hDecoder);
  195. void* NEAACDECAPI NeAACDecDecode(NeAACDecHandle hDecoder,
  196. NeAACDecFrameInfo *hInfo,
  197. unsigned char *buffer,
  198. unsigned long buffer_size);
  199. void* NEAACDECAPI NeAACDecDecode2(NeAACDecHandle hDecoder,
  200. NeAACDecFrameInfo *hInfo,
  201. unsigned char *buffer,
  202. unsigned long buffer_size,
  203. void **sample_buffer,
  204. unsigned long sample_buffer_size);
  205. char NEAACDECAPI NeAACDecAudioSpecificConfig(unsigned char *pBuffer,
  206. unsigned long buffer_size,
  207. mp4AudioSpecificConfig *mp4ASC);
  208. #ifdef _WIN32
  209. #pragma pack(pop)
  210. #endif
  211. #ifdef __cplusplus
  212. }
  213. #endif /* __cplusplus */
  214. #endif