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