BladeMP3EncDLL.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. /*
  2. * Blade Type of DLL Interface for Lame encoder
  3. *
  4. * Copyright (c) 1999-2002 A.L. Faber
  5. * Based on bladedll.h version 1.0 written by Jukka Poikolainen
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Library General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Library General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Library General Public
  18. * License along with this library; if not, write to the
  19. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  20. * Boston, MA 02111-1307, USA.
  21. */
  22. #ifndef ___BLADEDLL_H_INCLUDED___
  23. #define ___BLADEDLL_H_INCLUDED___
  24. #ifdef __GNUC__
  25. #define ATTRIBUTE_PACKED __attribute__((packed))
  26. #else
  27. #define ATTRIBUTE_PACKED
  28. #pragma pack(push)
  29. #pragma pack(1)
  30. #endif
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. /* encoding formats */
  35. #define BE_CONFIG_MP3 0
  36. #define BE_CONFIG_LAME 256
  37. /* type definitions */
  38. typedef void* HBE_STREAM;
  39. typedef HBE_STREAM *PHBE_STREAM;
  40. typedef unsigned long BE_ERR;
  41. /* error codes */
  42. #define BE_ERR_SUCCESSFUL 0x00000000
  43. #define BE_ERR_INVALID_FORMAT 0x00000001
  44. #define BE_ERR_INVALID_FORMAT_PARAMETERS 0x00000002
  45. #define BE_ERR_NO_MORE_HANDLES 0x00000003
  46. #define BE_ERR_INVALID_HANDLE 0x00000004
  47. #define BE_ERR_BUFFER_TOO_SMALL 0x00000005
  48. /* other constants */
  49. #define BE_MAX_HOMEPAGE 128
  50. /* format specific variables */
  51. #define BE_MP3_MODE_STEREO 0
  52. #define BE_MP3_MODE_JSTEREO 1
  53. #define BE_MP3_MODE_DUALCHANNEL 2
  54. #define BE_MP3_MODE_MONO 3
  55. #define MPEG1 1
  56. #define MPEG2 0
  57. #ifdef _BLADEDLL
  58. #undef FLOAT
  59. #include <Windows.h>
  60. #endif
  61. #define CURRENT_STRUCT_VERSION 1
  62. #define CURRENT_STRUCT_SIZE sizeof(BE_CONFIG) // is currently 331 bytes
  63. typedef enum
  64. {
  65. VBR_METHOD_NONE = -1,
  66. VBR_METHOD_DEFAULT = 0,
  67. VBR_METHOD_OLD = 1,
  68. VBR_METHOD_NEW = 2,
  69. VBR_METHOD_MTRH = 3,
  70. VBR_METHOD_ABR = 4
  71. } VBRMETHOD;
  72. typedef enum
  73. {
  74. LQP_NOPRESET =-1,
  75. // QUALITY PRESETS
  76. LQP_NORMAL_QUALITY = 0,
  77. LQP_LOW_QUALITY = 1,
  78. LQP_HIGH_QUALITY = 2,
  79. LQP_VOICE_QUALITY = 3,
  80. LQP_R3MIX = 4,
  81. LQP_VERYHIGH_QUALITY = 5,
  82. LQP_STANDARD = 6,
  83. LQP_FAST_STANDARD = 7,
  84. LQP_EXTREME = 8,
  85. LQP_FAST_EXTREME = 9,
  86. LQP_INSANE = 10,
  87. LQP_ABR = 11,
  88. LQP_CBR = 12,
  89. LQP_MEDIUM = 13,
  90. LQP_FAST_MEDIUM = 14,
  91. // NEW PRESET VALUES
  92. LQP_PHONE =1000,
  93. LQP_SW =2000,
  94. LQP_AM =3000,
  95. LQP_FM =4000,
  96. LQP_VOICE =5000,
  97. LQP_RADIO =6000,
  98. LQP_TAPE =7000,
  99. LQP_HIFI =8000,
  100. LQP_CD =9000,
  101. LQP_STUDIO =10000
  102. } LAME_QUALITY_PRESET;
  103. typedef struct {
  104. DWORD dwConfig; // BE_CONFIG_XXXXX
  105. // Currently only BE_CONFIG_MP3 is supported
  106. union {
  107. struct {
  108. DWORD dwSampleRate; // 48000, 44100 and 32000 allowed
  109. BYTE byMode; // BE_MP3_MODE_STEREO, BE_MP3_MODE_DUALCHANNEL, BE_MP3_MODE_MONO
  110. WORD wBitrate; // 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256 and 320 allowed
  111. BOOL bPrivate;
  112. BOOL bCRC;
  113. BOOL bCopyright;
  114. BOOL bOriginal;
  115. } mp3; // BE_CONFIG_MP3
  116. struct
  117. {
  118. // STRUCTURE INFORMATION
  119. DWORD dwStructVersion;
  120. DWORD dwStructSize;
  121. // BASIC ENCODER SETTINGS
  122. DWORD dwSampleRate; // SAMPLERATE OF INPUT FILE
  123. DWORD dwReSampleRate; // DOWNSAMPLERATE, 0=ENCODER DECIDES
  124. LONG nMode; // BE_MP3_MODE_STEREO, BE_MP3_MODE_DUALCHANNEL, BE_MP3_MODE_MONO
  125. DWORD dwBitrate; // CBR bitrate, VBR min bitrate
  126. DWORD dwMaxBitrate; // CBR ignored, VBR Max bitrate
  127. LONG nPreset; // Quality preset, use one of the settings of the LAME_QUALITY_PRESET enum
  128. DWORD dwMpegVersion; // FUTURE USE, MPEG-1 OR MPEG-2
  129. DWORD dwPsyModel; // FUTURE USE, SET TO 0
  130. DWORD dwEmphasis; // FUTURE USE, SET TO 0
  131. // BIT STREAM SETTINGS
  132. BOOL bPrivate; // Set Private Bit (TRUE/FALSE)
  133. BOOL bCRC; // Insert CRC (TRUE/FALSE)
  134. BOOL bCopyright; // Set Copyright Bit (TRUE/FALSE)
  135. BOOL bOriginal; // Set Original Bit (TRUE/FALSE)
  136. // VBR STUFF
  137. BOOL bWriteVBRHeader; // WRITE XING VBR HEADER (TRUE/FALSE)
  138. BOOL bEnableVBR; // USE VBR ENCODING (TRUE/FALSE)
  139. INT nVBRQuality; // VBR QUALITY 0..9
  140. DWORD dwVbrAbr_bps; // Use ABR in stead of nVBRQuality
  141. VBRMETHOD nVbrMethod;
  142. BOOL bNoRes; // Disable Bit resorvoir (TRUE/FALSE)
  143. // MISC SETTINGS
  144. BOOL bStrictIso; // Use strict ISO encoding rules (TRUE/FALSE)
  145. WORD nQuality; // Quality Setting, HIGH BYTE should be NOT LOW byte, otherwhise quality=5
  146. // FUTURE USE, SET TO 0, align strucutre to 331 bytes
  147. BYTE btReserved[255-4*sizeof(DWORD) - sizeof( WORD )];
  148. } LHV1; // LAME header version 1
  149. struct {
  150. DWORD dwSampleRate;
  151. BYTE byMode;
  152. WORD wBitrate;
  153. BYTE byEncodingMethod;
  154. } aac;
  155. } format;
  156. } BE_CONFIG, *PBE_CONFIG ATTRIBUTE_PACKED;
  157. typedef struct {
  158. // BladeEnc DLL Version number
  159. BYTE byDLLMajorVersion;
  160. BYTE byDLLMinorVersion;
  161. // BladeEnc Engine Version Number
  162. BYTE byMajorVersion;
  163. BYTE byMinorVersion;
  164. // DLL Release date
  165. BYTE byDay;
  166. BYTE byMonth;
  167. WORD wYear;
  168. // BladeEnc Homepage URL
  169. CHAR zHomepage[BE_MAX_HOMEPAGE + 1];
  170. BYTE byAlphaLevel;
  171. BYTE byBetaLevel;
  172. BYTE byMMXEnabled;
  173. BYTE btReserved[125];
  174. } BE_VERSION, *PBE_VERSION ATTRIBUTE_PACKED;
  175. #ifndef _BLADEDLL
  176. typedef BE_ERR (*BEINITSTREAM) (PBE_CONFIG, PDWORD, PDWORD, PHBE_STREAM);
  177. typedef BE_ERR (*BEENCODECHUNK) (HBE_STREAM, DWORD, PSHORT, PBYTE, PDWORD);
  178. // added for floating point audio -- DSPguru, jd
  179. typedef BE_ERR (*BEENCODECHUNKFLOATS16NI) (HBE_STREAM, DWORD, PFLOAT, PFLOAT, PBYTE, PDWORD);
  180. typedef BE_ERR (*BEDEINITSTREAM) (HBE_STREAM, PBYTE, PDWORD);
  181. typedef BE_ERR (*BECLOSESTREAM) (HBE_STREAM);
  182. typedef VOID (*BEVERSION) (PBE_VERSION);
  183. typedef BE_ERR (*BEWRITEVBRHEADER) (LPCSTR);
  184. typedef BE_ERR (*BEWRITEINFOTAG) (HBE_STREAM, LPCSTR );
  185. #define TEXT_BEINITSTREAM "beInitStream"
  186. #define TEXT_BEENCODECHUNK "beEncodeChunk"
  187. #define TEXT_BEENCODECHUNKFLOATS16NI "beEncodeChunkFloatS16NI"
  188. #define TEXT_BEDEINITSTREAM "beDeinitStream"
  189. #define TEXT_BECLOSESTREAM "beCloseStream"
  190. #define TEXT_BEVERSION "beVersion"
  191. #define TEXT_BEWRITEVBRHEADER "beWriteVBRHeader"
  192. #define TEXT_BEFLUSHNOGAP "beFlushNoGap"
  193. #define TEXT_BEWRITEINFOTAG "beWriteInfoTag"
  194. #else
  195. __declspec(dllexport) BE_ERR beInitStream(PBE_CONFIG pbeConfig, PDWORD dwSamples, PDWORD dwBufferSize, PHBE_STREAM phbeStream);
  196. __declspec(dllexport) BE_ERR beEncodeChunk(HBE_STREAM hbeStream, DWORD nSamples, PSHORT pSamples, PBYTE pOutput, PDWORD pdwOutput);
  197. // added for floating point audio -- DSPguru, jd
  198. __declspec(dllexport) BE_ERR beEncodeChunkFloatS16NI(HBE_STREAM hbeStream, DWORD nSamples, PFLOAT buffer_l, PFLOAT buffer_r, PBYTE pOutput, PDWORD pdwOutput);
  199. __declspec(dllexport) BE_ERR beDeinitStream(HBE_STREAM hbeStream, PBYTE pOutput, PDWORD pdwOutput);
  200. __declspec(dllexport) BE_ERR beCloseStream(HBE_STREAM hbeStream);
  201. __declspec(dllexport) VOID beVersion(PBE_VERSION pbeVersion);
  202. __declspec(dllexport) BE_ERR beWriteVBRHeader(LPCSTR lpszFileName);
  203. __declspec(dllexport) BE_ERR beFlushNoGap(HBE_STREAM hbeStream, PBYTE pOutput, PDWORD pdwOutput);
  204. __declspec(dllexport) BE_ERR beWriteInfoTag( HBE_STREAM hbeStream, LPCSTR lpszFileName );
  205. #endif
  206. #ifdef __cplusplus
  207. }
  208. #endif
  209. #ifndef __GNUC__
  210. #pragma pack(pop)
  211. #endif
  212. #endif