BladeMP3EncDLL.h 8.1 KB

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