diff options
Diffstat (limited to 'Src/Plugins/Encoder/enc_lame')
-rw-r--r-- | Src/Plugins/Encoder/enc_lame/24bit.cpp | 147 | ||||
-rw-r--r-- | Src/Plugins/Encoder/enc_lame/BladeMP3EncDLL.c | 1028 | ||||
-rw-r--r-- | Src/Plugins/Encoder/enc_lame/BladeMP3EncDLL.h | 278 | ||||
-rw-r--r-- | Src/Plugins/Encoder/enc_lame/MP3Coder.cpp | 196 | ||||
-rw-r--r-- | Src/Plugins/Encoder/enc_lame/MP3Coder.h | 62 | ||||
-rw-r--r-- | Src/Plugins/Encoder/enc_lame/enc_lame.rc | 145 | ||||
-rw-r--r-- | Src/Plugins/Encoder/enc_lame/enc_lame.sln | 30 | ||||
-rw-r--r-- | Src/Plugins/Encoder/enc_lame/enc_lame.vcxproj | 293 | ||||
-rw-r--r-- | Src/Plugins/Encoder/enc_lame/enc_lame.vcxproj.filters | 44 | ||||
-rw-r--r-- | Src/Plugins/Encoder/enc_lame/main.cpp | 503 | ||||
-rw-r--r-- | Src/Plugins/Encoder/enc_lame/resource.h | 57 | ||||
-rw-r--r-- | Src/Plugins/Encoder/enc_lame/version.rc2 | 39 |
12 files changed, 2822 insertions, 0 deletions
diff --git a/Src/Plugins/Encoder/enc_lame/24bit.cpp b/Src/Plugins/Encoder/enc_lame/24bit.cpp new file mode 100644 index 00000000..d1b83b1f --- /dev/null +++ b/Src/Plugins/Encoder/enc_lame/24bit.cpp @@ -0,0 +1,147 @@ +#include "MP3Coder.h" +#include <malloc.h> + +static const float const_1_div_128_ = 32768.0 / 128.0; /* 8 bit multiplier */ +static const double const_1_div_2147483648_ = 32768.0 / 2147483648.0; /* 32 bit multiplier */ + +static void Int8_To_Float32(float *dest, void *sourceBuffer, signed int sourceStride, unsigned int count) +{ + signed char *src = (signed char*)sourceBuffer; + + while( count-- ) + { + float samp = *src * const_1_div_128_; + *dest = samp; + + src += sourceStride; + dest ++; + } +} + +static void Int24_To_Float32(float *dest, void *sourceBuffer, signed int sourceStride, unsigned int count) +{ + unsigned char *src = (unsigned char*)sourceBuffer; + + while ( count-- ) + { + signed long temp = (((long)src[0]) << 8); + temp = temp | (((long)src[1]) << 16); + temp = temp | (((long)src[2]) << 24); + *dest = (float) ((double)temp * const_1_div_2147483648_); + src += sourceStride * 3; + dest ++; + } +} + +int AudioCoderMP3_24::Encode(int framepos, void *in, int in_avail, int *in_used, void *out, int out_avail) +{ + if (m_err) return -1; + if (!hbeStream) + { + if (beInitStream(&beConfig, &ibuf_size_spls, &obuf_size, (PHBE_STREAM) &hbeStream) != BE_ERR_SUCCESSFUL) + { + m_err++; + return -1; + } + ibuf_size = ibuf_size_spls * bytesPerSample; + + if (is_downmix) ibuf_size *= 2; + + bs = (char*)malloc(ibuf_size); + bs_size = 0; + } + + *in_used = 0; + + int needbytes = ibuf_size - bs_size; + if (needbytes > 0 && in_avail > 0) + { + if (needbytes > in_avail) + needbytes = in_avail; + memcpy(bs + bs_size, in, needbytes); + bs_size += needbytes; + *in_used = needbytes; + } + + if (!done) + { + if (bs_size < (int)ibuf_size) return 0; + } + + if (out_avail < (int)obuf_size) return 0; + + int feedBytes = min(bs_size, (int)ibuf_size); + int feedSamples = feedBytes / bytesPerSample; + bs_size -= feedBytes; + /* + if (is_downmix) + { + int x; + int l = feedBytes / 4; + short *b = (short*)bs; + for (x = 0; x < l; x ++) + { + b[x] = b[x * 2] / 2 + b[x * 2 + 1] / 2; + } + } + */ + DWORD dwo = 0; + + if (feedSamples) + { + if (mono_input) + { + float *float_l = (float *)alloca(sizeof(float) * feedSamples); + switch(bytesPerSample) + { + case 8: + Int8_To_Float32(float_l, bs, 1, feedSamples); + break; + case 24: + Int24_To_Float32(float_l, bs, 1, feedSamples); + break; + } + + + if (beEncodeChunkFloatS16NI(hbeStream, feedSamples, float_l, float_l, (unsigned char *)out, &dwo) != BE_ERR_SUCCESSFUL) + { + m_err++; + return -1; + } + } + else + { + float *float_l = (float *)alloca(sizeof(float) * feedSamples / 2); + float *float_r = (float *)alloca(sizeof(float) * feedSamples / 2); + switch(bytesPerSample) + { + case 1: // 8 bit + Int8_To_Float32(float_l, bs, 2, feedSamples / 2); + Int8_To_Float32(float_r, bs + 1, 2, feedSamples / 2); + break; + case 3: // 24 bit + Int24_To_Float32(float_l, bs, 2, feedSamples / 2); + Int24_To_Float32(float_r, bs + 3, 2, feedSamples / 2); + break; + } + + if (beEncodeChunkFloatS16NI(hbeStream, feedSamples / 2, float_l, float_r, (unsigned char *)out, &dwo) != BE_ERR_SUCCESSFUL) + { + m_err++; + return -1; + } + } + } + + if (!dwo && done == 1) + { + if (beDeinitStream(hbeStream, (unsigned char *)out, &dwo) != BE_ERR_SUCCESSFUL) + { + m_err++; + return -1; + } + done++; + } + + return dwo; +}
\ No newline at end of file diff --git a/Src/Plugins/Encoder/enc_lame/BladeMP3EncDLL.c b/Src/Plugins/Encoder/enc_lame/BladeMP3EncDLL.c new file mode 100644 index 00000000..e982cad2 --- /dev/null +++ b/Src/Plugins/Encoder/enc_lame/BladeMP3EncDLL.c @@ -0,0 +1,1028 @@ +/* +* Blade DLL Interface for LAME. +* +* Copyright (c) 1999 - 2002 A.L. Faber +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Library General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Library General Public License for more details. +* +* You should have received a copy of the GNU Library General Public +* License along with this library; if not, write to the +* Free Software Foundation, Inc., 59 Temple Place - Suite 330, +* Boston, MA 02111-1307, USA. +*/ + +#include <windows.h> +#include <Windef.h> +#include "BladeMP3EncDLL.h" +#include <assert.h> +#include <stdio.h> + +#include <lame/lame.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#define Min(A, B) ((A) < (B) ? (A) : (B)) +#define Max(A, B) ((A) > (B) ? (A) : (B)) + +#define _RELEASEDEBUG 0 + + // lame_enc DLL version number + const BYTE MAJORVERSION = 1; + const BYTE MINORVERSION = 32; + + + // Local variables + static DWORD dwSampleBufferSize = 0; + static HMODULE gs_hModule = NULL; + static BOOL gs_bLogFile = FALSE; + static lame_global_flags* gfp_save = NULL; + + // Local function prototypes + static void dump_config(lame_global_flags* gfp); + static void DebugPrintf(const char* pzFormat, ...); + static void DispErr(wchar_t const* strErr); + static void PresetOptions(lame_global_flags* gfp, LONG myPreset); + + + static void DebugPrintf(const char* pzFormat, ...) + { + char szBuffer[1024] = { '\0', }; + char szFileName[MAX_PATH + 1] = { '\0', }; + va_list ap; + + // Get the full module (DLL) file name + GetModuleFileNameA(gs_hModule, + szFileName, + sizeof(szFileName)); + + // change file name extention + szFileName[strlen(szFileName) - 3] = 't'; + szFileName[strlen(szFileName) - 2] = 'x'; + szFileName[strlen(szFileName) - 1] = 't'; + + // start at beginning of the list + va_start(ap, pzFormat); + + // copy it to the string buffer + _vsnprintf(szBuffer, sizeof(szBuffer), pzFormat, ap); + + // log it to the file? + if (gs_bLogFile) + { + FILE* fp = NULL; + + // try to open the log file + fp = fopen(szFileName, "a+"); + + // check file open result + if (fp) + { + // write string to the file + fputs(szBuffer, fp); + + // close the file + fclose(fp); + } + } + +#if defined _DEBUG || defined _RELEASEDEBUG + OutputDebugStringA(szBuffer); +#endif + + va_end(ap); + } + + + static void PresetOptions(lame_global_flags* gfp, LONG myPreset) + { + switch (myPreset) + { + /*-1*/case LQP_NOPRESET: + break; + + /*0*/case LQP_NORMAL_QUALITY: + /* lame_set_quality( gfp, 5 );*/ + break; + + /*1*/case LQP_LOW_QUALITY: + lame_set_quality(gfp, 9); + break; + + /*2*/case LQP_HIGH_QUALITY: + lame_set_quality(gfp, 2); + break; + + /*3*/case LQP_VOICE_QUALITY: // --voice flag for experimental voice mode + lame_set_mode(gfp, MONO); + lame_set_preset(gfp, 56); + break; + + /*4*/case LQP_R3MIX: // --R3MIX + lame_set_preset(gfp, R3MIX); + break; + + /*5*/case LQP_VERYHIGH_QUALITY: + lame_set_quality(gfp, 0); + break; + + /*6*/case LQP_STANDARD: // --PRESET STANDARD + lame_set_preset(gfp, STANDARD); + break; + + /*7*/case LQP_FAST_STANDARD: // --PRESET FAST STANDARD + lame_set_preset(gfp, STANDARD_FAST); + break; + + /*8*/case LQP_EXTREME: // --PRESET EXTREME + lame_set_preset(gfp, EXTREME); + break; + + /*9*/case LQP_FAST_EXTREME: // --PRESET FAST EXTREME: + lame_set_preset(gfp, EXTREME_FAST); + break; + + /*10*/case LQP_INSANE: // --PRESET INSANE + lame_set_preset(gfp, INSANE); + break; + + /*11*/case LQP_ABR: // --PRESET ABR + // handled in beInitStream + break; + + /*12*/case LQP_CBR: // --PRESET CBR + // handled in beInitStream + break; + + /*13*/case LQP_MEDIUM: // --PRESET MEDIUM + lame_set_preset(gfp, MEDIUM); + break; + + /*14*/case LQP_FAST_MEDIUM: // --PRESET FAST MEDIUM + lame_set_preset(gfp, MEDIUM_FAST); + break; + + /*1000*/case LQP_PHONE: + lame_set_mode(gfp, MONO); + lame_set_preset(gfp, 16); + break; + + /*2000*/case LQP_SW: + lame_set_mode(gfp, MONO); + lame_set_preset(gfp, 24); + break; + + /*3000*/case LQP_AM: + lame_set_mode(gfp, MONO); + lame_set_preset(gfp, 40); + break; + + /*4000*/case LQP_FM: + lame_set_preset(gfp, 112); + break; + + /*5000*/case LQP_VOICE: + lame_set_mode(gfp, MONO); + lame_set_preset(gfp, 56); + break; + + /*6000*/case LQP_RADIO: + lame_set_preset(gfp, 112); + break; + + /*7000*/case LQP_TAPE: + lame_set_preset(gfp, 112); + break; + + /*8000*/case LQP_HIFI: + lame_set_preset(gfp, 160); + break; + + /*9000*/case LQP_CD: + lame_set_preset(gfp, 192); + break; + + /*10000*/case LQP_STUDIO: + lame_set_preset(gfp, 256); + break; + + } + } + + + __declspec(dllexport) BE_ERR beInitStream(PBE_CONFIG pbeConfig, PDWORD dwSamples, PDWORD dwBufferSize, PHBE_STREAM phbeStream) + { + int actual_bitrate; + //2001-12-18 + BE_CONFIG lameConfig = { 0, }; + int nInitReturn = 0; + lame_global_flags* gfp = NULL; + + // Init the global flags structure + gfp = lame_init(); + *phbeStream = (HBE_STREAM)gfp; + + // clear out structure + memset(&lameConfig, 0x00, CURRENT_STRUCT_SIZE); + + // Check if this is a regular BLADE_ENCODER header + if (pbeConfig->dwConfig != BE_CONFIG_LAME) + { + int nCRC = pbeConfig->format.mp3.bCRC; + int nVBR = (nCRC >> 12) & 0x0F; + + // Copy parameter from old Blade structure + lameConfig.format.LHV1.dwSampleRate = pbeConfig->format.mp3.dwSampleRate; + //for low bitrates, LAME will automatically downsample for better + //sound quality. Forcing output samplerate = input samplerate is not a good idea + //unless the user specifically requests it: + //lameConfig.format.LHV1.dwReSampleRate=pbeConfig->format.mp3.dwSampleRate; + lameConfig.format.LHV1.nMode = (pbeConfig->format.mp3.byMode & 0x0F); + lameConfig.format.LHV1.dwBitrate = pbeConfig->format.mp3.wBitrate; + lameConfig.format.LHV1.bPrivate = pbeConfig->format.mp3.bPrivate; + lameConfig.format.LHV1.bOriginal = pbeConfig->format.mp3.bOriginal; + lameConfig.format.LHV1.bCRC = nCRC & 0x01; + lameConfig.format.LHV1.bCopyright = pbeConfig->format.mp3.bCopyright; + + // Fill out the unknowns + lameConfig.format.LHV1.dwStructSize = CURRENT_STRUCT_SIZE; + lameConfig.format.LHV1.dwStructVersion = CURRENT_STRUCT_VERSION; + + // Get VBR setting from fourth nibble + if (nVBR > 0) + { + lameConfig.format.LHV1.bWriteVBRHeader = TRUE; + lameConfig.format.LHV1.bEnableVBR = TRUE; + lameConfig.format.LHV1.nVBRQuality = nVBR - 1; + } + + // Get Quality from third nibble + lameConfig.format.LHV1.nPreset = ((nCRC >> 8) & 0x0F); + + } + else + { + // Copy the parameters + memcpy(&lameConfig, pbeConfig, pbeConfig->format.LHV1.dwStructSize); + } + + // --------------- Set arguments to LAME encoder ------------------------- + + // Set input sample frequency + lame_set_in_samplerate(gfp, lameConfig.format.LHV1.dwSampleRate); + + // disable INFO/VBR tag by default. + // if this tag is used, the calling program must call beWriteVBRTag() + // after encoding. But the original DLL documentation does not + // require the + // app to call beWriteVBRTag() unless they have specifically + // set LHV1.bWriteVBRHeader=TRUE. Thus the default setting should + // be disabled. + lame_set_bWriteVbrTag(gfp, 0); + + //2001-12-18 Dibrom's ABR preset stuff + + if (lameConfig.format.LHV1.nPreset == LQP_ABR) // --ALT-PRESET ABR + { + actual_bitrate = lameConfig.format.LHV1.dwVbrAbr_bps / 1000; + + // limit range + if (actual_bitrate > 320) + { + actual_bitrate = 320; + } + + if (actual_bitrate < 8) + { + actual_bitrate = 8; + } + + lame_set_preset(gfp, actual_bitrate); + } + + // end Dibrom's ABR preset 2001-12-18 ****** START OF CBR + + if (lameConfig.format.LHV1.nPreset == LQP_CBR) // --ALT-PRESET CBR + { + actual_bitrate = lameConfig.format.LHV1.dwBitrate; + lame_set_preset(gfp, actual_bitrate); + lame_set_VBR(gfp, vbr_off); + } + + // end Dibrom's CBR preset 2001-12-18 + + // The following settings only used when preset is not one of the LAME QUALITY Presets + if ((int)lameConfig.format.LHV1.nPreset < (int)LQP_STANDARD) + { + switch (lameConfig.format.LHV1.nMode) + { + case BE_MP3_MODE_STEREO: + lame_set_mode(gfp, STEREO); + lame_set_num_channels(gfp, 2); + break; + case BE_MP3_MODE_JSTEREO: + lame_set_mode(gfp, JOINT_STEREO); + //lame_set_force_ms( gfp, bForceMS ); // no check box to force this? + lame_set_num_channels(gfp, 2); + break; + case BE_MP3_MODE_MONO: + lame_set_mode(gfp, MONO); + lame_set_num_channels(gfp, 1); + break; + case BE_MP3_MODE_DUALCHANNEL: + lame_set_mode(gfp, DUAL_CHANNEL); + lame_set_num_channels(gfp, 2); + break; + default: + { + DebugPrintf("Invalid lameConfig.format.LHV1.nMode, value is %d\n", lameConfig.format.LHV1.nMode); + return BE_ERR_INVALID_FORMAT_PARAMETERS; + } + } + + if (lameConfig.format.LHV1.bEnableVBR) + { + /* set VBR quality */ + lame_set_VBR_q(gfp, lameConfig.format.LHV1.nVBRQuality); + + /* select proper VBR method */ + switch (lameConfig.format.LHV1.nVbrMethod) + { + case VBR_METHOD_NONE: + lame_set_VBR(gfp, vbr_off); + break; + + case VBR_METHOD_DEFAULT: + lame_set_VBR(gfp, vbr_default); + break; + + case VBR_METHOD_OLD: + lame_set_VBR(gfp, vbr_rh); + break; + + case VBR_METHOD_MTRH: + case VBR_METHOD_NEW: + /* + * the --vbr-mtrh commandline switch is obsolete. + * now --vbr-mtrh is known as --vbr-new + */ + lame_set_VBR(gfp, vbr_mtrh); + break; + + case VBR_METHOD_ABR: + lame_set_VBR(gfp, vbr_abr); + break; + + default: + /* unsupported VBR method */ + assert(FALSE); + } + } + else + { + /* use CBR encoding method, so turn off VBR */ + lame_set_VBR(gfp, vbr_off); + } + + /* Set bitrate. (CDex users always specify bitrate=Min bitrate when using VBR) */ + lame_set_brate(gfp, lameConfig.format.LHV1.dwBitrate); + + /* check if we have to use ABR, in order to backwards compatible, this + * condition should still be checked indepedent of the nVbrMethod method + */ + if (lameConfig.format.LHV1.dwVbrAbr_bps > 0) + { + /* set VBR method to ABR */ + lame_set_VBR(gfp, vbr_abr); + + /* calculate to kbps, round to nearest kbps */ + lame_set_VBR_mean_bitrate_kbps(gfp, (lameConfig.format.LHV1.dwVbrAbr_bps + 500) / 1000); + + /* limit range */ + if (lame_get_VBR_mean_bitrate_kbps(gfp) > 320) + { + lame_set_VBR_mean_bitrate_kbps(gfp, 320); + } + + if (lame_get_VBR_mean_bitrate_kbps(gfp) < 8) + { + lame_set_VBR_mean_bitrate_kbps(gfp, 8); + } + } + + } + + // First set all the preset options + if (LQP_NOPRESET != lameConfig.format.LHV1.nPreset) + { + PresetOptions(gfp, lameConfig.format.LHV1.nPreset); + } + + + // Set frequency resampling rate, if specified + if (lameConfig.format.LHV1.dwReSampleRate > 0) + { + lame_set_out_samplerate(gfp, lameConfig.format.LHV1.dwReSampleRate); + } + + + switch (lameConfig.format.LHV1.nMode) + { + case BE_MP3_MODE_MONO: + lame_set_mode(gfp, MONO); + lame_set_num_channels(gfp, 1); + break; + + default: + break; + } + + + // Use strict ISO encoding? + lame_set_strict_ISO(gfp, (lameConfig.format.LHV1.bStrictIso) ? 1 : 0); + + // Set copyright flag? + if (lameConfig.format.LHV1.bCopyright) + { + lame_set_copyright(gfp, 1); + } + + // Do we have to tag it as non original + if (!lameConfig.format.LHV1.bOriginal) + { + lame_set_original(gfp, 0); + } + else + { + lame_set_original(gfp, 1); + } + + // Add CRC? + if (lameConfig.format.LHV1.bCRC) + { + lame_set_error_protection(gfp, 1); + } + else + { + lame_set_error_protection(gfp, 0); + } + + // Set private bit? + if (lameConfig.format.LHV1.bPrivate) + { + lame_set_extension(gfp, 1); + } + else + { + lame_set_extension(gfp, 0); + } + + + // Set VBR min bitrate, if specified + if (lameConfig.format.LHV1.dwBitrate > 0) + { + lame_set_VBR_min_bitrate_kbps(gfp, lameConfig.format.LHV1.dwBitrate); + } + + // Set Maxbitrate, if specified + if (lameConfig.format.LHV1.dwMaxBitrate > 0) + { + lame_set_VBR_max_bitrate_kbps(gfp, lameConfig.format.LHV1.dwMaxBitrate); + } + // Set bit resovoir option + if (lameConfig.format.LHV1.bNoRes) + { + lame_set_disable_reservoir(gfp, 1); + } + + // check if the VBR tag is required + if (lameConfig.format.LHV1.bWriteVBRHeader) + { + lame_set_bWriteVbrTag(gfp, 1); + } + else + { + lame_set_bWriteVbrTag(gfp, 0); + } + + // Override Quality setting, use HIGHBYTE = NOT LOWBYTE to be backwards compatible + if ((lameConfig.format.LHV1.nQuality & 0xFF) == + ((~(lameConfig.format.LHV1.nQuality >> 8)) & 0xFF)) + { + lame_set_quality(gfp, lameConfig.format.LHV1.nQuality & 0xFF); + } + + if (0 != (nInitReturn = lame_init_params(gfp))) + { + return nInitReturn; + } + + //LAME encoding call will accept any number of samples. + if (0 == lame_get_version(gfp)) + { + // For MPEG-II, only 576 samples per frame per channel + *dwSamples = 576 * lame_get_num_channels(gfp); + } + else + { + // For MPEG-I, 1152 samples per frame per channel + *dwSamples = 1152 * lame_get_num_channels(gfp); + } + + // Set the input sample buffer size, so we know what we can expect + dwSampleBufferSize = *dwSamples; + + // Set MP3 buffer size, conservative estimate + *dwBufferSize = (DWORD)(1.25 * (*dwSamples / lame_get_num_channels(gfp)) + 7200); + + // For debugging purposes + dump_config(gfp); + + // Everything went OK, thus return SUCCESSFUL + return BE_ERR_SUCCESSFUL; + } + + + + __declspec(dllexport) BE_ERR beFlushNoGap(HBE_STREAM hbeStream, PBYTE pOutput, PDWORD pdwOutput) + { + int nOutputSamples = 0; + + lame_global_flags* gfp = (lame_global_flags*)hbeStream; + + // Init the global flags structure + nOutputSamples = lame_encode_flush_nogap(gfp, pOutput, LAME_MAXMP3BUFFER); + + if (nOutputSamples < 0) + { + *pdwOutput = 0; + return BE_ERR_BUFFER_TOO_SMALL; + } + else + { + *pdwOutput = nOutputSamples; + } + + return BE_ERR_SUCCESSFUL; + } + + __declspec(dllexport) BE_ERR beDeinitStream(HBE_STREAM hbeStream, PBYTE pOutput, PDWORD pdwOutput) + { + int nOutputSamples = 0; + + lame_global_flags* gfp = (lame_global_flags*)hbeStream; + + nOutputSamples = lame_encode_flush(gfp, pOutput, 0); + + if (nOutputSamples < 0) + { + *pdwOutput = 0; + return BE_ERR_BUFFER_TOO_SMALL; + } + else + { + *pdwOutput = nOutputSamples; + } + + return BE_ERR_SUCCESSFUL; + } + + + __declspec(dllexport) BE_ERR beCloseStream(HBE_STREAM hbeStream) + { + lame_global_flags* gfp = (lame_global_flags*)hbeStream; + + // lame will be close in VbrWriteTag function + if (!lame_get_bWriteVbrTag(gfp)) + { + // clean up of allocated memory + lame_close(gfp); + + gfp_save = NULL; + } + else + { + gfp_save = (lame_global_flags*)hbeStream; + } + + // DeInit encoder + return BE_ERR_SUCCESSFUL; + } + + + + __declspec(dllexport) VOID beVersion(PBE_VERSION pbeVersion) + { + // DLL Release date + char lpszDate[20] = { '\0', }; + char lpszTemp[5] = { '\0', }; + lame_version_t lv = { 0, }; + + + // Set DLL interface version + pbeVersion->byDLLMajorVersion = MAJORVERSION; + pbeVersion->byDLLMinorVersion = MINORVERSION; + + get_lame_version_numerical(&lv); + + // Set Engine version number (Same as Lame version) + pbeVersion->byMajorVersion = (BYTE)lv.major; + pbeVersion->byMinorVersion = (BYTE)lv.minor; + pbeVersion->byAlphaLevel = (BYTE)lv.alpha; + pbeVersion->byBetaLevel = (BYTE)lv.beta; + +#ifdef MMX_choose_table + pbeVersion->byMMXEnabled = 1; +#else + pbeVersion->byMMXEnabled = 0; +#endif + + memset(pbeVersion->btReserved, 0, sizeof(pbeVersion->btReserved)); + + // Get compilation date + strcpy(lpszDate, __DATE__); + + // Get the first three character, which is the month + strncpy(lpszTemp, lpszDate, 3); + lpszTemp[3] = '\0'; + pbeVersion->byMonth = 1; + + // Set month + if (strcmp(lpszTemp, "Jan") == 0) pbeVersion->byMonth = 1; + if (strcmp(lpszTemp, "Feb") == 0) pbeVersion->byMonth = 2; + if (strcmp(lpszTemp, "Mar") == 0) pbeVersion->byMonth = 3; + if (strcmp(lpszTemp, "Apr") == 0) pbeVersion->byMonth = 4; + if (strcmp(lpszTemp, "May") == 0) pbeVersion->byMonth = 5; + if (strcmp(lpszTemp, "Jun") == 0) pbeVersion->byMonth = 6; + if (strcmp(lpszTemp, "Jul") == 0) pbeVersion->byMonth = 7; + if (strcmp(lpszTemp, "Aug") == 0) pbeVersion->byMonth = 8; + if (strcmp(lpszTemp, "Sep") == 0) pbeVersion->byMonth = 9; + if (strcmp(lpszTemp, "Oct") == 0) pbeVersion->byMonth = 10; + if (strcmp(lpszTemp, "Nov") == 0) pbeVersion->byMonth = 11; + if (strcmp(lpszTemp, "Dec") == 0) pbeVersion->byMonth = 12; + + // Get day of month string (char [4..5]) + pbeVersion->byDay = (BYTE)atoi(lpszDate + 4); + + // Get year of compilation date (char [7..10]) + pbeVersion->wYear = (WORD)atoi(lpszDate + 7); + + memset(pbeVersion->zHomepage, 0x00, BE_MAX_HOMEPAGE); + + strcpy(pbeVersion->zHomepage, "http://www.mp3dev.org/"); + } + + __declspec(dllexport) BE_ERR beEncodeChunk(HBE_STREAM hbeStream, DWORD nSamples, + PSHORT pSamples, PBYTE pOutput, PDWORD pdwOutput) + { + // Encode it + int dwSamples; + int nOutputSamples = 0; + lame_global_flags* gfp = (lame_global_flags*)hbeStream; + + dwSamples = nSamples / lame_get_num_channels(gfp); + + // old versions of lame_enc.dll required exactly 1152 samples + // and worked even if nSamples accidently set to 2304 + // simulate this behavoir: + if (1 == lame_get_num_channels(gfp) && nSamples == 2304) + { + dwSamples /= 2; + } + + + if (1 == lame_get_num_channels(gfp)) + { + nOutputSamples = lame_encode_buffer(gfp, pSamples, pSamples, dwSamples, pOutput, 0); + } + else + { + nOutputSamples = lame_encode_buffer_interleaved(gfp, pSamples, dwSamples, pOutput, 0); + } + + + if (nOutputSamples < 0) + { + *pdwOutput = 0; + return BE_ERR_BUFFER_TOO_SMALL; + } + else + { + *pdwOutput = (DWORD)nOutputSamples; + } + + return BE_ERR_SUCCESSFUL; + } + + + // accept floating point audio samples, scaled to the range of a signed 16-bit + // integer (within +/- 32768), in non-interleaved channels -- DSPguru, jd + __declspec(dllexport) BE_ERR beEncodeChunkFloatS16NI(HBE_STREAM hbeStream, DWORD nSamples, + PFLOAT buffer_l, PFLOAT buffer_r, PBYTE pOutput, PDWORD pdwOutput) + { + int nOutputSamples; + lame_global_flags* gfp = (lame_global_flags*)hbeStream; + + nOutputSamples = lame_encode_buffer_float(gfp, buffer_l, buffer_r, nSamples, pOutput, 0); + + if (nOutputSamples >= 0) + { + *pdwOutput = (DWORD)nOutputSamples; + } + else + { + *pdwOutput = 0; + return BE_ERR_BUFFER_TOO_SMALL; + } + + return BE_ERR_SUCCESSFUL; + } + + static int + maybeSyncWord(FILE* fpStream) + { + unsigned char mp3_frame_header[4]; + size_t nbytes = fread(mp3_frame_header, 1, sizeof(mp3_frame_header), fpStream); + if (nbytes != sizeof(mp3_frame_header)) { + return -1; + } + if (mp3_frame_header[0] != 0xffu) { + return -1; /* doesn't look like a sync word */ + } + if ((mp3_frame_header[1] & 0xE0u) != 0xE0u) { + return -1; /* doesn't look like a sync word */ + } + return 0; + } + + static int + skipId3v2(FILE* fpStream, size_t lametag_frame_size) + { + size_t nbytes; + size_t id3v2TagSize = 0; + unsigned char id3v2Header[10]; + + /* seek to the beginning of the stream */ + if (fseek(fpStream, 0, SEEK_SET) != 0) { + return -2; /* not seekable, abort */ + } + /* read 10 bytes in case there's an ID3 version 2 header here */ + nbytes = fread(id3v2Header, 1, sizeof(id3v2Header), fpStream); + if (nbytes != sizeof(id3v2Header)) { + return -3; /* not readable, maybe opened Write-Only */ + } + /* does the stream begin with the ID3 version 2 file identifier? */ + if (!strncmp((char*)id3v2Header, "ID3", 3)) { + /* the tag size (minus the 10-byte header) is encoded into four + * bytes where the most significant bit is clear in each byte + */ + id3v2TagSize = (((id3v2Header[6] & 0x7f) << 21) + | ((id3v2Header[7] & 0x7f) << 14) + | ((id3v2Header[8] & 0x7f) << 7) + | (id3v2Header[9] & 0x7f)) + + sizeof id3v2Header; + } + /* Seek to the beginning of the audio stream */ + if (fseek(fpStream, id3v2TagSize, SEEK_SET) != 0) { + return -2; + } + if (maybeSyncWord(fpStream) != 0) { + return -1; + } + if (fseek(fpStream, id3v2TagSize + lametag_frame_size, SEEK_SET) != 0) { + return -2; + } + if (maybeSyncWord(fpStream) != 0) { + return -1; + } + /* OK, it seems we found our LAME-Tag/Xing frame again */ + /* Seek to the beginning of the audio stream */ + if (fseek(fpStream, id3v2TagSize, SEEK_SET) != 0) { + return -2; + } + return 0; + } + + static BE_ERR + updateLameTagFrame(lame_global_flags* gfp, FILE* fpStream) + { + size_t n = lame_get_lametag_frame(gfp, 0, 0); /* ask for bufer size */ + + if (n > 0) + { + unsigned char* buffer = 0; + size_t m = 1; + + if (0 != skipId3v2(fpStream, n)) + { + DispErr("Error updating LAME-tag frame:\n\n" + "can't locate old frame\n"); + return BE_ERR_INVALID_FORMAT_PARAMETERS; + } + + buffer = (unsigned char*)malloc(n); + + if (buffer == 0) + { + DispErr("Error updating LAME-tag frame:\n\n" + "can't allocate frame buffer\n"); + return BE_ERR_INVALID_FORMAT_PARAMETERS; + } + + /* Put it all to disk again */ + n = lame_get_lametag_frame(gfp, buffer, n); + if (n > 0) + { + m = fwrite(buffer, n, 1, fpStream); + } + free(buffer); + + if (m != 1) + { + DispErr("Error updating LAME-tag frame:\n\n" + "couldn't write frame into file\n"); + return BE_ERR_INVALID_FORMAT_PARAMETERS; + } + } + return BE_ERR_SUCCESSFUL; + } + + __declspec(dllexport) BE_ERR beWriteInfoTag(HBE_STREAM hbeStream, + LPCSTR lpszFileName) + { + FILE* fpStream = NULL; + BE_ERR beResult = BE_ERR_SUCCESSFUL; + + lame_global_flags* gfp = (lame_global_flags*)hbeStream; + + if (NULL != gfp) + { + // Do we have to write the VBR tag? + if (lame_get_bWriteVbrTag(gfp)) + { + // Try to open the file + fpStream = fopen(lpszFileName, "rb+"); + + // Check file open result + if (NULL == fpStream) + { + beResult = BE_ERR_INVALID_FORMAT_PARAMETERS; + DispErr("Error updating LAME-tag frame:\n\n" + "can't open file for reading and writing\n"); + } + else + { + beResult = updateLameTagFrame(gfp, fpStream); + + // Close the file stream + fclose(fpStream); + } + } + + // clean up of allocated memory + lame_close(gfp); + } + else + { + beResult = BE_ERR_INVALID_FORMAT_PARAMETERS; + } + + // return result + return beResult; + } + + // for backwards compatiblity + __declspec(dllexport) BE_ERR beWriteVBRHeader(LPCSTR lpszFileName) + { + return beWriteInfoTag((HBE_STREAM)gfp_save, lpszFileName); + } + + + BOOL APIENTRY DllMain(HANDLE hModule, + DWORD ul_reason_for_call, + LPVOID lpReserved) + { + (void)lpReserved; + gs_hModule = (HMODULE)hModule; + + switch (ul_reason_for_call) + { + case DLL_PROCESS_ATTACH: + // Enable debug/logging? + gs_bLogFile = GetPrivateProfileIntA("Debug", "WriteLogFile", gs_bLogFile, "lame_enc.ini"); + break; + case DLL_THREAD_ATTACH: + break; + case DLL_THREAD_DETACH: + break; + case DLL_PROCESS_DETACH: + break; + } + return TRUE; + } + + + static void dump_config(lame_global_flags* gfp) + { + DebugPrintf("\n\nLame_enc configuration options:\n"); + DebugPrintf("==========================================================\n"); + + DebugPrintf("version =%d\n", lame_get_version(gfp)); + DebugPrintf("Layer =3\n"); + DebugPrintf("mode ="); + switch (lame_get_mode(gfp)) + { + case STEREO: DebugPrintf("Stereo\n"); break; + case JOINT_STEREO: DebugPrintf("Joint-Stereo\n"); break; + case DUAL_CHANNEL: DebugPrintf("Forced Stereo\n"); break; + case MONO: DebugPrintf("Mono\n"); break; + case NOT_SET: /* FALLTROUGH */ + default: DebugPrintf("Error (unknown)\n"); break; + } + + DebugPrintf("Input sample rate =%.1f kHz\n", lame_get_in_samplerate(gfp) / 1000.0); + DebugPrintf("Output sample rate =%.1f kHz\n", lame_get_out_samplerate(gfp) / 1000.0); + + DebugPrintf("bitrate =%d kbps\n", lame_get_brate(gfp)); + DebugPrintf("Quality Setting =%d\n", lame_get_quality(gfp)); + + DebugPrintf("Low pass frequency =%d\n", lame_get_lowpassfreq(gfp)); + DebugPrintf("Low pass width =%d\n", lame_get_lowpasswidth(gfp)); + + DebugPrintf("High pass frequency =%d\n", lame_get_highpassfreq(gfp)); + DebugPrintf("High pass width =%d\n", lame_get_highpasswidth(gfp)); + + DebugPrintf("No short blocks =%d\n", lame_get_no_short_blocks(gfp)); + DebugPrintf("Force short blocks =%d\n", lame_get_force_short_blocks(gfp)); + + DebugPrintf("de-emphasis =%d\n", lame_get_emphasis(gfp)); + DebugPrintf("private flag =%d\n", lame_get_extension(gfp)); + + DebugPrintf("copyright flag =%d\n", lame_get_copyright(gfp)); + DebugPrintf("original flag =%d\n", lame_get_original(gfp)); + DebugPrintf("CRC =%s\n", lame_get_error_protection(gfp) ? "on" : "off"); + DebugPrintf("Fast mode =%s\n", (lame_get_quality(gfp)) ? "enabled" : "disabled"); + DebugPrintf("Force mid/side stereo =%s\n", (lame_get_force_ms(gfp)) ? "enabled" : "disabled"); + DebugPrintf("Disable Reservoir =%d\n", lame_get_disable_reservoir(gfp)); + DebugPrintf("Allow diff-short =%d\n", lame_get_allow_diff_short(gfp)); + DebugPrintf("Interchannel masking =%f\n", lame_get_interChRatio(gfp)); + DebugPrintf("Strict ISO Encoding =%s\n", (lame_get_strict_ISO(gfp)) ? "Yes" : "No"); + DebugPrintf("Scale =%5.2f\n", lame_get_scale(gfp)); + + DebugPrintf("VBR =%s, VBR_q =%d, VBR method =", + (lame_get_VBR(gfp) != vbr_off) ? "enabled" : "disabled", + lame_get_VBR_q(gfp)); + + switch (lame_get_VBR(gfp)) + { + case vbr_off: DebugPrintf("vbr_off\n"); break; + case vbr_mt: DebugPrintf("vbr_mt \n"); break; + case vbr_rh: DebugPrintf("vbr_rh \n"); break; + case vbr_mtrh: DebugPrintf("vbr_mtrh \n"); break; + case vbr_abr: + DebugPrintf("vbr_abr (average bitrate %d kbps)\n", lame_get_VBR_mean_bitrate_kbps(gfp)); + break; + default: + DebugPrintf("error, unknown VBR setting\n"); + break; + } + + DebugPrintf("Vbr Min bitrate =%d kbps\n", lame_get_VBR_min_bitrate_kbps(gfp)); + DebugPrintf("Vbr Max bitrate =%d kbps\n", lame_get_VBR_max_bitrate_kbps(gfp)); + + DebugPrintf("Write VBR Header =%s\n", (lame_get_bWriteVbrTag(gfp)) ? "Yes" : "No"); + DebugPrintf("VBR Hard min =%d\n", lame_get_VBR_hard_min(gfp)); + + DebugPrintf("ATH Only =%d\n", lame_get_ATHonly(gfp)); + DebugPrintf("ATH short =%d\n", lame_get_ATHshort(gfp)); + DebugPrintf("ATH no =%d\n", lame_get_noATH(gfp)); + DebugPrintf("ATH type =%d\n", lame_get_ATHtype(gfp)); + DebugPrintf("ATH lower =%f\n", lame_get_ATHlower(gfp)); + DebugPrintf("ATH aa =%d\n", lame_get_athaa_type(gfp)); + //DebugPrintf("ATH aa loudapprox =%d\n", lame_get_athaa_loudapprox( gfp ) ); + DebugPrintf("ATH aa sensitivity =%f\n", lame_get_athaa_sensitivity(gfp)); + + DebugPrintf("Experimental nspsytune =%d\n", lame_get_exp_nspsytune(gfp)); + DebugPrintf("Experimental X =%d\n", lame_get_experimentalX(gfp)); + DebugPrintf("Experimental Y =%d\n", lame_get_experimentalY(gfp)); + DebugPrintf("Experimental Z =%d\n", lame_get_experimentalZ(gfp)); + } + + + static void DispErr(wchar_t const* strErr) + { + MessageBox(NULL, strErr, L"LAME_ENC.DLL", MB_OK | MB_ICONHAND); + } + +#ifdef __cplusplus +} +#endif diff --git a/Src/Plugins/Encoder/enc_lame/BladeMP3EncDLL.h b/Src/Plugins/Encoder/enc_lame/BladeMP3EncDLL.h new file mode 100644 index 00000000..20aaff4d --- /dev/null +++ b/Src/Plugins/Encoder/enc_lame/BladeMP3EncDLL.h @@ -0,0 +1,278 @@ +/* + * Blade DLL Interface for LAME. + * + * Copyright (c) 1999 A.L. Faber + * Based on bladedll.h version 1.0 written by Jukka Poikolainen + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef ___BLADEDLL_H_INCLUDED___ +#define ___BLADEDLL_H_INCLUDED___ + +#pragma pack(push) +#pragma pack(1) + +#ifdef __cplusplus +extern "C" { +#endif + +/* encoding formats */ + +#define BE_CONFIG_MP3 0 +#define BE_CONFIG_LAME 256 + +/* type definitions */ + +typedef unsigned long HBE_STREAM; +typedef HBE_STREAM *PHBE_STREAM; +typedef unsigned long BE_ERR; + +/* error codes */ + +#define BE_ERR_SUCCESSFUL 0x00000000 +#define BE_ERR_INVALID_FORMAT 0x00000001 +#define BE_ERR_INVALID_FORMAT_PARAMETERS 0x00000002 +#define BE_ERR_NO_MORE_HANDLES 0x00000003 +#define BE_ERR_INVALID_HANDLE 0x00000004 +#define BE_ERR_BUFFER_TOO_SMALL 0x00000005 + +/* other constants */ + +#define BE_MAX_HOMEPAGE 128 + +/* format specific variables */ + +#define BE_MP3_MODE_STEREO 0 +#define BE_MP3_MODE_JSTEREO 1 +#define BE_MP3_MODE_DUALCHANNEL 2 +#define BE_MP3_MODE_MONO 3 + + + +#define MPEG1 1 +#define MPEG2 0 + +#ifdef _BLADEDLL +#undef FLOAT + #include <Windows.h> +#endif + +#define CURRENT_STRUCT_VERSION 1 +#define CURRENT_STRUCT_SIZE sizeof(BE_CONFIG) // is currently 331 bytes + +/* OBSOLETE, VALUES STILL WORK +typedef enum +{ + NORMAL_QUALITY=0, + LOW_QUALITY, + HIGH_QUALITY, + VOICE_QUALITY +} LAME_QUALTIY_PRESET; + +*/ + + +typedef enum +{ + VBR_METHOD_NONE = -1, + VBR_METHOD_DEFAULT = 0, + VBR_METHOD_OLD = 1, + VBR_METHOD_NEW = 2, + VBR_METHOD_MTRH = 3, + VBR_METHOD_ABR = 4 +} VBRMETHOD; + +typedef enum +{ + LQP_NOPRESET=-1, + + // QUALITY PRESETS + LQP_NORMAL_QUALITY = 0, + LQP_LOW_QUALITY = 1, + LQP_HIGH_QUALITY = 2, + LQP_VOICE_QUALITY = 3, + LQP_R3MIX = 4, + LQP_VERYHIGH_QUALITY = 5, + LQP_STANDARD = 6, + LQP_FAST_STANDARD = 7, + LQP_EXTREME = 8, + LQP_FAST_EXTREME = 9, + LQP_INSANE = 10, + LQP_ABR = 11, + LQP_CBR = 12, + LQP_MEDIUM = 13, + LQP_FAST_MEDIUM = 14, + + // NEW PRESET VALUES + LQP_PHONE =1000, + LQP_SW =2000, + LQP_AM =3000, + LQP_FM =4000, + LQP_VOICE =5000, + LQP_RADIO =6000, + LQP_TAPE =7000, + LQP_HIFI =8000, + LQP_CD =9000, + LQP_STUDIO =10000 + +} LAME_QUALTIY_PRESET; + + + +typedef struct { + DWORD dwConfig; // BE_CONFIG_XXXXX + // Currently only BE_CONFIG_MP3 is supported + union { + + struct { + + DWORD dwSampleRate; // 48000, 44100 and 32000 allowed. RG note: also seems to support 16000, 22050, 24000. + BYTE byMode; // BE_MP3_MODE_STEREO, BE_MP3_MODE_DUALCHANNEL, BE_MP3_MODE_MONO + WORD wBitrate; // 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256 and 320 allowed. RG note: also seems to support 8,16,24. + BOOL bPrivate; + BOOL bCRC; + BOOL bCopyright; + BOOL bOriginal; + + } mp3; // BE_CONFIG_MP3 + + struct + { + // STRUCTURE INFORMATION + DWORD dwStructVersion; + DWORD dwStructSize; + + // BASIC ENCODER SETTINGS + DWORD dwSampleRate; // SAMPLERATE OF INPUT FILE + DWORD dwReSampleRate; // DOWNSAMPLERATE, 0=ENCODER DECIDES + LONG nMode; // BE_MP3_MODE_STEREO, BE_MP3_MODE_DUALCHANNEL, BE_MP3_MODE_MONO + DWORD dwBitrate; // CBR bitrate, VBR min bitrate + DWORD dwMaxBitrate; // CBR ignored, VBR Max bitrate + LONG nPreset; // Quality preset, use one of the settings of the LAME_QUALITY_PRESET enum + DWORD dwMpegVersion; // FUTURE USE, MPEG-1 OR MPEG-2 + DWORD dwPsyModel; // FUTURE USE, SET TO 0 + DWORD dwEmphasis; // FUTURE USE, SET TO 0 + + // BIT STREAM SETTINGS + BOOL bPrivate; // Set Private Bit (TRUE/FALSE) + BOOL bCRC; // Insert CRC (TRUE/FALSE) + BOOL bCopyright; // Set Copyright Bit (TRUE/FALSE) + BOOL bOriginal; // Set Original Bit (TRUE/FALSE) + + // VBR STUFF + BOOL bWriteVBRHeader; // WRITE XING VBR HEADER (TRUE/FALSE) + BOOL bEnableVBR; // USE VBR ENCODING (TRUE/FALSE) + INT nVBRQuality; // VBR QUALITY 0..9 + DWORD dwVbrAbr_bps; // Use ABR in stead of nVBRQuality + VBRMETHOD nVbrMethod; + BOOL bNoRes; // Disable Bit resorvoir + + // MISC SETTINGS + BOOL bStrictIso; // Use strict ISO encoding rules (TRUE/FALSE) + WORD nQuality; // Quality Setting, HIGH BYTE should be NOT LOW byte, otherwhise quality=5 + + // FUTURE USE, SET TO 0, align strucutre to 331 bytes + BYTE btReserved[255-4*sizeof(DWORD) - sizeof( WORD )]; + + } LHV1; // LAME header version 1 + + struct { + + DWORD dwSampleRate; + BYTE byMode; + WORD wBitrate; + BYTE byEncodingMethod; + + } aac; + + } format; + +} BE_CONFIG, *PBE_CONFIG; + + +typedef struct { + + // BladeEnc DLL Version number + + BYTE byDLLMajorVersion; + BYTE byDLLMinorVersion; + + // BladeEnc Engine Version Number + + BYTE byMajorVersion; + BYTE byMinorVersion; + + // DLL Release date + + BYTE byDay; + BYTE byMonth; + WORD wYear; + + // BladeEnc Homepage URL + + CHAR zHomepage[BE_MAX_HOMEPAGE + 1]; + + BYTE byAlphaLevel; + BYTE byBetaLevel; + BYTE byMMXEnabled; + + BYTE btReserved[125]; + + +} BE_VERSION, *PBE_VERSION; + +#ifndef _BLADEDLL + +typedef BE_ERR (*BEINITSTREAM) (PBE_CONFIG, PDWORD, PDWORD, PHBE_STREAM); +typedef BE_ERR (*BEENCODECHUNK) (HBE_STREAM, DWORD, PSHORT, PBYTE, PDWORD); +// added for floating point audio -- DSPguru, jd +typedef BE_ERR (*BEENCODECHUNKFLOATS16NI) (HBE_STREAM, DWORD, PFLOAT, PFLOAT, PBYTE, PDWORD); +typedef BE_ERR (*BEDEINITSTREAM) (HBE_STREAM, PBYTE, PDWORD); +typedef BE_ERR (*BECLOSESTREAM) (HBE_STREAM); +typedef VOID (*BEVERSION) (PBE_VERSION); +typedef VOID (*BEWRITEVBRHEADER) (LPCSTR); + +#define TEXT_BEINITSTREAM "beInitStream" +#define TEXT_BEENCODECHUNK "beEncodeChunk" +#define TEXT_BEENCODECHUNKFLOATS16NI "beEncodeChunkFloatS16NI" +#define TEXT_BEDEINITSTREAM "beDeinitStream" +#define TEXT_BECLOSESTREAM "beCloseStream" +#define TEXT_BEVERSION "beVersion" +#define TEXT_BEWRITEVBRHEADER "beWriteVBRHeader" + +#else + +__declspec(dllexport) BE_ERR beInitStream(PBE_CONFIG pbeConfig, PDWORD dwSamples, PDWORD dwBufferSize, PHBE_STREAM phbeStream); +__declspec(dllexport) BE_ERR beEncodeChunk(HBE_STREAM hbeStream, DWORD nSamples, PSHORT pSamples, PBYTE pOutput, PDWORD pdwOutput); +// added for floating point audio -- DSPguru, jd +__declspec(dllexport) BE_ERR beEncodeChunkFloatS16NI(HBE_STREAM hbeStream, DWORD nSamples, PFLOAT buffer_l, PFLOAT buffer_r, PBYTE pOutput, PDWORD pdwOutput); +__declspec(dllexport) BE_ERR beDeinitStream(HBE_STREAM hbeStream, PBYTE pOutput, PDWORD pdwOutput); +__declspec(dllexport) BE_ERR beCloseStream(HBE_STREAM hbeStream); +__declspec(dllexport) VOID beVersion(PBE_VERSION pbeVersion); +__declspec(dllexport) BE_ERR beWriteVBRHeader(LPCSTR lpszFileName); +__declspec(dllexport) BE_ERR beFlushNoGap(HBE_STREAM hbeStream, PBYTE pOutput, PDWORD pdwOutput); +__declspec(dllexport) BE_ERR beWriteInfoTag( HBE_STREAM hbeStream, LPCSTR lpszFileName); + +#endif + +#pragma pack(pop) + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Src/Plugins/Encoder/enc_lame/MP3Coder.cpp b/Src/Plugins/Encoder/enc_lame/MP3Coder.cpp new file mode 100644 index 00000000..7bf7d605 --- /dev/null +++ b/Src/Plugins/Encoder/enc_lame/MP3Coder.cpp @@ -0,0 +1,196 @@ +#include "MP3Coder.h" + +AudioCoderMP3::~AudioCoderMP3() +{ + if (hbeStream) beCloseStream(hbeStream); hbeStream = 0; + if (bs) free(bs); bs = 0; +} + +int AudioCoderMP3::GetLastError() { return m_err; }; + +void AudioCoderMP3::setVbrFilename(char *filename) +{ + if (hbeStream) beCloseStream(hbeStream); + hbeStream = 0; + if (filename) + { + beWriteVBRHeader(filename); + } +} + +int AudioCoderMP3::Encode(int framepos, void *in, int in_avail, int *in_used, void *out, int out_avail) +{ + if (m_err) return -1; + if (!hbeStream) + { + if (beInitStream(&beConfig, &ibuf_size_spls, &obuf_size, (PHBE_STREAM) &hbeStream) != BE_ERR_SUCCESSFUL) + { + m_err++; + return -1; + } + ibuf_size = ibuf_size_spls * bytesPerSample; + + if (is_downmix) ibuf_size *= 2; + + bs = (char*)malloc(ibuf_size); + bs_size = 0; + } + + + *in_used = 0; + + int needbytes = ibuf_size - bs_size; + if (needbytes > 0 && in_avail > 0) + { + if (needbytes > in_avail) + needbytes = in_avail; + memcpy(bs + bs_size, in, needbytes); + bs_size += needbytes; + *in_used = needbytes; + } + if (!done) + { + if (bs_size < (int)ibuf_size) return 0; + + } + + if (out_avail < (int)obuf_size) return 0; + + int feedBytes = min(bs_size, (int)ibuf_size); + int feedSamples = feedBytes / bytesPerSample; + bs_size -= feedBytes; + + if (is_downmix) + { + int x; + int l = feedBytes / 4; + short *b = (short*)bs; + for (x = 0; x < l; x ++) + { + b[x] = b[x * 2] / 2 + b[x * 2 + 1] / 2; + } + feedSamples/=2; + } + DWORD dwo = 0; + + if (feedSamples) + { + if (beEncodeChunk(hbeStream, feedSamples, (short*)bs, (unsigned char*)out, &dwo) != BE_ERR_SUCCESSFUL) + { + m_err++; + return -1; + } + } + if (!dwo && done==1) + { + if (beDeinitStream(hbeStream, (unsigned char *)out, &dwo) != BE_ERR_SUCCESSFUL) + { + m_err++; + return -1; + } + done++; + } + + return dwo; +} + +void AudioCoderMP3::PrepareToFinish() +{ + done = 1; +} + +AudioCoderMP3::AudioCoderMP3(int nch, int srate, int bps, configtype *cfg) + : obuf_size(0), ibuf_size(0), ibuf_size_spls(0), done(false), bs_size(0) +{ + m_err = 0; + hbeStream = 0; + bs = 0; + is_downmix = 0; + mono_input=0; + + memset(&beConfig, 0, sizeof(beConfig)); // clear all fields + + if (srate != 32000 + && srate != 44100 + && srate != 48000 + && srate != 16000 /* MPEG 2 sample rates */ + && srate != 22050 + && srate != 24000 + && srate != 11025 /* MPEG 2.5 sample rates */ + && srate != 12000 + && srate != 8000) + { + //MessageBox(NULL, "The only valid audio sampling rates for the LAME mp3 encoder are:\r\t16000\r\t22050\r\t24000\r\t32000\r\t44100\r\t48000\r\rPlease modify the encoding profile to use one of these sampling rates, and then try again.", "Invalid sampling rate", MB_OK); + m_err++; + return ; + } + + // use the LAME config structure + beConfig.dwConfig = BE_CONFIG_LAME; + + // this are the default settings for testcase.wav + beConfig.format.LHV1.dwStructVersion = 1; + beConfig.format.LHV1.dwStructSize = sizeof(beConfig); + beConfig.format.LHV1.dwSampleRate = srate; // INPUT FREQUENCY + + beConfig.format.LHV1.nMode = cfg->stereo_mode; + if (nch < 2) + { + beConfig.format.LHV1.nMode = BE_MP3_MODE_MONO; + mono_input=1; + } + else + { + if (beConfig.format.LHV1.nMode == BE_MP3_MODE_MONO) + is_downmix = 1; + // beConfig.format.LHV1.nMode = BE_MP3_MODE_STEREO; + } + + beConfig.format.LHV1.dwBitrate = cfg->bitrate; + beConfig.format.LHV1.dwMaxBitrate = (cfg->vbr_method != -1 ? cfg->vbr_max_bitrate : cfg->bitrate); + + beConfig.format.LHV1.dwReSampleRate = 0; // DOWNSAMPLERATE, 0=ENCODER DECIDES + + if (beConfig.format.LHV1.dwMaxBitrate < 32) // less than 32, let's force mono + { + if (nch > 1) + { + beConfig.format.LHV1.nMode = BE_MP3_MODE_MONO; + is_downmix = 1; + } + } + + /*int effective_nch = (beConfig.format.LHV1.nMode == BE_MP3_MODE_MONO) ? 1 : 2; + + if (beConfig.format.LHV1.dwReSampleRate >= 32000 && + beConfig.format.LHV1.dwMaxBitrate / effective_nch <= 32) + { + beConfig.format.LHV1.dwReSampleRate /= 2; + }*/ +/* + if (beConfig.format.LHV1.dwReSampleRate < 32000) + beConfig.format.LHV1.dwMpegVersion = MPEG2; // MPEG VERSION (I or II) + else + beConfig.format.LHV1.dwMpegVersion = MPEG1; // MPEG VERSION (I or II) +*/ + + beConfig.format.LHV1.nPreset = cfg->quality; + + beConfig.format.LHV1.dwPsyModel = 0; // USE DEFAULT PSYCHOACOUSTIC MODEL + beConfig.format.LHV1.dwEmphasis = 0; // NO EMPHASIS TURNED ON + + beConfig.format.LHV1.bOriginal = 0; // SET ORIGINAL FLAG + beConfig.format.LHV1.bCRC = 0; // INSERT CRC + beConfig.format.LHV1.bCopyright = 0; // SET COPYRIGHT FLAG + beConfig.format.LHV1.bPrivate = 0; // SET PRIVATE FLAG + beConfig.format.LHV1.bNoRes = 0; + beConfig.format.LHV1.bWriteVBRHeader = 1; + + beConfig.format.LHV1.bEnableVBR = cfg->vbr_method != VBR_METHOD_NONE; + beConfig.format.LHV1.nVBRQuality = cfg->vbr; + //beConfig.format.LHV1.dwVbrAbr_bps = (cfg->vbr_method != VBR_METHOD_NONE ? 1000 * cfg->abr_bitrate : 0); + beConfig.format.LHV1.dwVbrAbr_bps = (cfg->vbr_method == VBR_METHOD_ABR ? 1000 * cfg->abr_bitrate : 0); + beConfig.format.LHV1.nVbrMethod = (VBRMETHOD)cfg->vbr_method; + + bytesPerSample = bps / 8; +}
\ No newline at end of file diff --git a/Src/Plugins/Encoder/enc_lame/MP3Coder.h b/Src/Plugins/Encoder/enc_lame/MP3Coder.h new file mode 100644 index 00000000..9a16b603 --- /dev/null +++ b/Src/Plugins/Encoder/enc_lame/MP3Coder.h @@ -0,0 +1,62 @@ +#ifndef NULLSOFT_MP3_CODER_H +#define NULLSOFT_MP3_CODER_H + +#include <windows.h> +#include "../nsv/enc_if.h" +#include "BladeMP3EncDLL.h" +#ifndef _BLADEDLL +extern BEINITSTREAM beInitStream; +extern BECLOSESTREAM beCloseStream; +extern BEENCODECHUNK beEncodeChunk; +extern BEDEINITSTREAM beDeinitStream; +extern BEWRITEVBRHEADER beWriteVBRHeader; +extern BEVERSION beVersion; +extern BEENCODECHUNKFLOATS16NI beEncodeChunkFloatS16NI; +#endif // !_BLADEDLL + + + +typedef struct +{ + int bitrate; + int vbr_max_bitrate; + int abr_bitrate; + int stereo_mode; //0=stereo,1=jstereo,2=mchannel,3=mono + int quality; //0=normal,1=low,2=high,3=voice,4=r3mix,5=vh + + int vbr; // 0=high-9=low + int vbr_method; // -1=none, 0=default, 1=old, 2=new, 3=mtrh, 4=abr + +} +configtype; +class AudioCoderMP3 : public AudioCoder +{ +public: + AudioCoderMP3(int nch, int srate, int bps, configtype *cfg); + int Encode(int framepos, void *in, int in_avail, int *in_used, void *out, int out_avail); + virtual ~AudioCoderMP3(); + int GetLastError(); + void setVbrFilename(char *filename); + void PrepareToFinish(); +protected: + int m_err; + DWORD obuf_size; + DWORD ibuf_size, ibuf_size_spls; + HBE_STREAM hbeStream; + BE_CONFIG beConfig; + int bytesPerSample; + int done; + char *bs; + int bs_size; + int is_downmix; + int mono_input; +}; + +class AudioCoderMP3_24 : public AudioCoderMP3 +{ +public: + AudioCoderMP3_24(int nch, int srate, int bps, configtype *cfg) : AudioCoderMP3(nch, srate, bps, cfg) {} +int Encode(int framepos, void *in, int in_avail, int *in_used, void *out, int out_avail); +}; + +#endif
\ No newline at end of file diff --git a/Src/Plugins/Encoder/enc_lame/enc_lame.rc b/Src/Plugins/Encoder/enc_lame/enc_lame.rc new file mode 100644 index 00000000..b6d63988 --- /dev/null +++ b/Src/Plugins/Encoder/enc_lame/enc_lame.rc @@ -0,0 +1,145 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "#include ""version.rc2""\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_MP3 DIALOGEX 0, 0, 256, 167 +STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD +FONT 8, "MS Shell Dlg", 0, 0, 0x0 +BEGIN + GROUPBOX "MP3 Encoder Options",IDC_STATIC,0,0,256,166 + LTEXT "Mode:",IDC_STATIC,4,13,21,8 + COMBOBOX IDC_VBRMETHOD,28,11,52,155,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_STEREOMODE,87,11,66,184,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "Bitrate:",IDC_BITRATE_TEXT1,6,28,80,8 + COMBOBOX IDC_BITRATE,87,25,38,98,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "kbps",IDC_BITRATE_TEXT2,129,28,16,8 + LTEXT "VBR Maximum Bitrate:",IDC_MAXBITRATE_TEXT1,6,42,77,8 + COMBOBOX IDC_MAXBITRATE,87,39,38,98,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "kbps",IDC_MAXBITRATE_TEXT2,129,42,16,8 + LTEXT "Average Bitrate:",IDC_AVGBITRATE_TEXT1,6,56,77,8 + COMBOBOX IDC_AVGBITRATE,87,53,38,98,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "kbps",IDC_AVGBITRATE_TEXT2,129,56,16,8 + LTEXT "Quality:",IDC_STATIC,7,74,24,8 + COMBOBOX IDC_QUALITY,33,72,98,110,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "VBR Q:",IDC_VBRQ_TEXT,136,74,25,8 + COMBOBOX IDC_VBRQ,161,72,40,98,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "MPEG Layer-3 audio coding technology licensed from Fraunhofer IIS and Thomson.",IDC_STATIC,5,92,148,18,NOT WS_VISIBLE + LTEXT "MPEG Layer-3 encoding technology by Mp3dev.",IDC_STATIC,5,115,154,8 + LTEXT "",IDC_LAMEVERSION,136,153,114,8,0,WS_EX_RIGHT +END + +IDD_MP3_MISSING DIALOGEX 0, 0, 256, 167 +STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD +FONT 8, "MS Shell Dlg", 0, 0, 0x0 +BEGIN + GROUPBOX "MP3 Encoder Options",-1,0,0,256,166 + LTEXT "MP3 encoding support is not available as ""lame_enc.dll"" is not present.\n\nYou will need to manually download ""lame_enc.dll"" to the Winamp\Shared folder to enable MP3 encoding support.",-1,12,14,231,34 + LTEXT "Click here for information on where you can obtain ""lame_enc.dll"".",-1,12,54,231,10 + CONTROL "here",IDC_URL1,"Button",BS_OWNERDRAW | WS_TABSTOP,27,54,15,8 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE +BEGIN + 65535 "{F1534ECA-6E64-42c2-9781-812E61154515}" +END + +STRINGTABLE +BEGIN + IDS_BITRATE "Bitrate:" + IDS_ABR_MIN_BITRATE "ABR Minimum Bitrate" + IDS_VBR_MIN_BITRATE "VBR Minimum Bitrate" + IDS_N_A "N/A" + IDS_ABR_MAX_BITRATE "ABR Maximum Bitrate" + IDS_VBR_MAX_BITRATE "VBR Maximum Bitrate" + IDS_AVERAGE_BITRATE "Average Bitrate" + IDS_STEREO "Stereo" + IDS_JOINT_STEREO "Joint Stereo" + IDS_MULTI_CHANNEL "Multi-Channel" + IDS_MONO "Mono" + IDS_NORMAL "Normal" + IDS_LOW "Low" + IDS_HIGH "High" + IDS_VOICE "Voice" + IDS_R3MIX "R3mix" +END + +STRINGTABLE +BEGIN + IDS_VERY_HIGH "Very High" + IDS_HIGH_BRACKET "(High)" + IDS_LOW_BRACKET "(Low)" + IDS_ENC_LAME_DESC "MP3 Encoder %s" + IDS_ENC_LAME_DESC_MISSING "MP3 Encoder %s [NOT LOADED]" +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// +#include "version.rc2" + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Src/Plugins/Encoder/enc_lame/enc_lame.sln b/Src/Plugins/Encoder/enc_lame/enc_lame.sln new file mode 100644 index 00000000..4af92741 --- /dev/null +++ b/Src/Plugins/Encoder/enc_lame/enc_lame.sln @@ -0,0 +1,30 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29509.3 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "enc_lame", "enc_lame.vcxproj", "{861F24D8-9B22-42FA-B056-7A86D6B4500C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {861F24D8-9B22-42FA-B056-7A86D6B4500C}.Debug|Win32.ActiveCfg = Debug|Win32 + {861F24D8-9B22-42FA-B056-7A86D6B4500C}.Debug|Win32.Build.0 = Debug|Win32 + {861F24D8-9B22-42FA-B056-7A86D6B4500C}.Debug|x64.ActiveCfg = Debug|x64 + {861F24D8-9B22-42FA-B056-7A86D6B4500C}.Debug|x64.Build.0 = Debug|x64 + {861F24D8-9B22-42FA-B056-7A86D6B4500C}.Release|Win32.ActiveCfg = Release|Win32 + {861F24D8-9B22-42FA-B056-7A86D6B4500C}.Release|Win32.Build.0 = Release|Win32 + {861F24D8-9B22-42FA-B056-7A86D6B4500C}.Release|x64.ActiveCfg = Release|x64 + {861F24D8-9B22-42FA-B056-7A86D6B4500C}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {CC41ED85-6766-472A-9C3A-5E89A14D82B6} + EndGlobalSection +EndGlobal diff --git a/Src/Plugins/Encoder/enc_lame/enc_lame.vcxproj b/Src/Plugins/Encoder/enc_lame/enc_lame.vcxproj new file mode 100644 index 00000000..6dcaa1eb --- /dev/null +++ b/Src/Plugins/Encoder/enc_lame/enc_lame.vcxproj @@ -0,0 +1,293 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|x64"> + <Configuration>Debug</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|x64"> + <Configuration>Release</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{861F24D8-9B22-42FA-B056-7A86D6B4500C}</ProjectGuid> + <RootNamespace>enc_lame</RootNamespace> + <WindowsTargetPlatformVersion>10.0.19041.0</WindowsTargetPlatformVersion> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <PlatformToolset>v142</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <PlatformToolset>v142</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <PlatformToolset>v142</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <PlatformToolset>v142</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <LinkIncremental>false</LinkIncremental> + <OutDir>$(PlatformShortName)_$(Configuration)\</OutDir> + <IntDir>$(PlatformShortName)_$(Configuration)\</IntDir> + <IncludePath>$(IncludePath)</IncludePath> + <LibraryPath>$(LibraryPath)</LibraryPath> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <LinkIncremental>false</LinkIncremental> + <OutDir>$(PlatformShortName)_$(Configuration)\</OutDir> + <IntDir>$(PlatformShortName)_$(Configuration)\</IntDir> + <IncludePath>$(IncludePath)</IncludePath> + <LibraryPath>$(LibraryPath)</LibraryPath> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <LinkIncremental>false</LinkIncremental> + <OutDir>$(PlatformShortName)_$(Configuration)\</OutDir> + <IntDir>$(PlatformShortName)_$(Configuration)\</IntDir> + <IncludePath>$(IncludePath)</IncludePath> + <LibraryPath>$(LibraryPath)</LibraryPath> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <LinkIncremental>false</LinkIncremental> + <OutDir>$(PlatformShortName)_$(Configuration)\</OutDir> + <IntDir>$(PlatformShortName)_$(Configuration)\</IntDir> + <IncludePath>$(IncludePath)</IncludePath> + <LibraryPath>$(LibraryPath)</LibraryPath> + </PropertyGroup> + <PropertyGroup Label="Vcpkg"> + <VcpkgEnableManifest>false</VcpkgEnableManifest> + </PropertyGroup> + <PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <VcpkgUseStatic>false</VcpkgUseStatic> + <VcpkgInstalledDir> + </VcpkgInstalledDir> + <VcpkgConfiguration>Debug</VcpkgConfiguration> + <VcpkgTriplet>x86-windows-static-md</VcpkgTriplet> + </PropertyGroup> + <PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <VcpkgUseStatic>false</VcpkgUseStatic> + <VcpkgInstalledDir> + </VcpkgInstalledDir> + <VcpkgTriplet>x86-windows-static-md</VcpkgTriplet> + </PropertyGroup> + <PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <VcpkgUseStatic>false</VcpkgUseStatic> + <VcpkgInstalledDir> + </VcpkgInstalledDir> + <VcpkgTriplet>x86-windows-static-md</VcpkgTriplet> + <VcpkgConfiguration>Debug</VcpkgConfiguration> + </PropertyGroup> + <PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <VcpkgUseStatic>false</VcpkgUseStatic> + <VcpkgInstalledDir> + </VcpkgInstalledDir> + <VcpkgTriplet>x86-windows-static-md</VcpkgTriplet> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <Optimization>Disabled</Optimization> + <AdditionalIncludeDirectories>..\..\..\Wasabi;..\..\..\external_dependencies\vcpkg\$(PlatformShortName)-windows-static\include\lame</AdditionalIncludeDirectories> + <PreprocessorDefinitions>_WINDOWS;_USRDLL;_BLADEDLL;NSV_CODER_MP3_EXPORTS;WINDOWS_IGNORE_PACKING_MISMATCH;WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <MinimalRebuild>false</MinimalRebuild> + <MultiProcessorCompilation>true</MultiProcessorCompilation> + <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> + <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <WarningLevel>Level3</WarningLevel> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + <StructMemberAlignment>Default</StructMemberAlignment> + <ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName> + </ClCompile> + <ResourceCompile> + <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <Culture>0x0409</Culture> + </ResourceCompile> + <Link> + <AdditionalDependencies>shlwapi.lib;libmp3lame-static.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile> + <GenerateDebugInformation>true</GenerateDebugInformation> + <ProgramDatabaseFile>$(IntDir)$(TargetName).pdb</ProgramDatabaseFile> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary> + <TargetMachine>MachineX86</TargetMachine> + <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers> + <AdditionalLibraryDirectories>..\..\..\external_dependencies\vcpkg\$(PlatformShortName)-windows-static\debug\lib\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> + </Link> + <PostBuildEvent> + <Command>xcopy /Y /D $(OutDir)$(TargetName)$(TargetExt) ..\..\..\..\Build\Winamp_$(PlatformShortName)_$(Configuration)\Plugins\ +xcopy /Y /D $(IntDir)$(TargetName).pdb ..\..\..\..\Build\Winamp_$(PlatformShortName)_$(Configuration)\Plugins\ +if exist ..\..\..\resources\libraries\lame_enc.dll xcopy /Y /D ..\..\..\resources\libraries\lame_enc.dll ..\..\..\..\Build\Winamp_$(PlatformShortName)_$(Configuration)\Plugins\</Command> + <Message>Post build event: 'xcopy /Y /D $(OutDir)$(TargetName)$(TargetExt) ..\..\..\..\Build\Winamp_$(PlatformShortName)_$(Configuration)\Plugins\ and if exist ..\..\..\resources\libraries\lame_enc.dll xcopy /Y /D ..\..\..\resources\libraries\lame_enc.dll ..\..\..\..\Build\Winamp_$(PlatformShortName)_$(Configuration)\Shared\'</Message> + </PostBuildEvent> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <ClCompile> + <Optimization>Disabled</Optimization> + <AdditionalIncludeDirectories>..\..\..\Wasabi;..\..\..\external_dependencies\vcpkg\$(PlatformShortName)-windows-static\include\lame</AdditionalIncludeDirectories> + <PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;_BLADEDLL;NSV_CODER_MP3_EXPORTS;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <MinimalRebuild>false</MinimalRebuild> + <MultiProcessorCompilation>true</MultiProcessorCompilation> + <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> + <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <WarningLevel>Level3</WarningLevel> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + <ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName> + </ClCompile> + <ResourceCompile> + <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <Culture>0x0409</Culture> + </ResourceCompile> + <Link> + <AdditionalDependencies>shlwapi.lib;..\..\..\external_dependencies\vcpkg\$(PlatformShortName)-windows-static\debug\lib\libmp3lame-static.lib</AdditionalDependencies> + <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile> + <GenerateDebugInformation>true</GenerateDebugInformation> + <ProgramDatabaseFile>$(IntDir)$(TargetName).pdb</ProgramDatabaseFile> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary> + <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers> + <AdditionalLibraryDirectories>..\..\..\external_dependencies\vcpkg\$(PlatformShortName)-windows-static\debug\lib\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> + </Link> + <PostBuildEvent> + <Command>xcopy /Y /D $(OutDir)$(TargetName)$(TargetExt) ..\..\..\..\Build\Winamp_$(PlatformShortName)_$(Configuration)\Plugins\ +xcopy /Y /D $(IntDir)$(TargetName).pdb ..\..\..\..\Build\Winamp_$(PlatformShortName)_$(Configuration)\Plugins\ +if exist ..\..\..\resources\libraries\lame_enc.dll xcopy /Y /D ..\..\..\resources\libraries\lame_enc.dll ..\..\..\..\Build\Winamp_$(PlatformShortName)_$(Configuration)\Plugins\</Command> + <Message>Post build event: 'xcopy /Y /D $(OutDir)$(TargetName)$(TargetExt) ..\..\..\..\Build\Winamp_$(PlatformShortName)_$(Configuration)\Plugins\ and if exist ..\..\..\resources\libraries\lame_enc.dll xcopy /Y /D ..\..\..\resources\libraries\lame_enc.dll ..\..\..\..\Build\Winamp_$(PlatformShortName)_$(Configuration)\Shared\'</Message> + </PostBuildEvent> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <Optimization>MinSpace</Optimization> + <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion> + <FavorSizeOrSpeed>Size</FavorSizeOrSpeed> + <AdditionalIncludeDirectories>..\..\..\Wasabi;..\..\..\external_dependencies\vcpkg\$(PlatformShortName)-windows-static\include\lame</AdditionalIncludeDirectories> + <PreprocessorDefinitions>_WINDOWS;_USRDLL;_BLADEDLL;NSV_CODER_MP3_EXPORTS;WINDOWS_IGNORE_PACKING_MISMATCH;NDEBUG;WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <StringPooling>true</StringPooling> + <MultiProcessorCompilation>true</MultiProcessorCompilation> + <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> + <BufferSecurityCheck>true</BufferSecurityCheck> + <WarningLevel>Level3</WarningLevel> + <DebugInformationFormat>None</DebugInformationFormat> + <StructMemberAlignment>Default</StructMemberAlignment> + <ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName> + </ClCompile> + <ResourceCompile> + <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <Culture>0x0409</Culture> + </ResourceCompile> + <Link> + <AdditionalDependencies>shlwapi.lib;libmp3lame-static.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile> + <GenerateDebugInformation>false</GenerateDebugInformation> + <ProgramDatabaseFile>$(IntDir)$(TargetName).pdb</ProgramDatabaseFile> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary> + <TargetMachine>MachineX86</TargetMachine> + <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers> + <AdditionalLibraryDirectories>..\..\..\external_dependencies\vcpkg\$(PlatformShortName)-windows-static\lib\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> + </Link> + <PostBuildEvent> + <Command>xcopy /Y /D $(OutDir)$(TargetName)$(TargetExt) ..\..\..\..\Build\Winamp_$(PlatformShortName)_$(Configuration)\Plugins\ +if exist ..\..\..\resources\libraries\lame_enc.dll xcopy /Y /D ..\..\..\resources\libraries\lame_enc.dll ..\..\..\..\Build\Winamp_$(PlatformShortName)_$(Configuration)\Plugins\</Command> + <Message>Post build event: 'xcopy /Y /D $(OutDir)$(TargetName)$(TargetExt) ..\..\..\..\Build\Winamp_$(PlatformShortName)_$(Configuration)\Plugins\ and if exist ..\..\..\resources\libraries\lame_enc.dll xcopy /Y /D ..\..\..\resources\libraries\lame_enc.dll ..\..\..\..\Build\Winamp_$(PlatformShortName)_$(Configuration)\Shared\'</Message> + </PostBuildEvent> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <ClCompile> + <Optimization>MinSpace</Optimization> + <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion> + <FavorSizeOrSpeed>Size</FavorSizeOrSpeed> + <AdditionalIncludeDirectories>..\..\..\Wasabi;..\..\..\external_dependencies\vcpkg\$(PlatformShortName)-windows-static\include\lame</AdditionalIncludeDirectories> + <PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;NSV_CODER_MP3_EXPORTS;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <StringPooling>true</StringPooling> + <MultiProcessorCompilation>true</MultiProcessorCompilation> + <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> + <BufferSecurityCheck>true</BufferSecurityCheck> + <WarningLevel>Level3</WarningLevel> + <DebugInformationFormat>None</DebugInformationFormat> + <ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName> + </ClCompile> + <ResourceCompile> + <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <Culture>0x0409</Culture> + </ResourceCompile> + <Link> + <AdditionalDependencies>shlwapi.lib;..\..\..\external_dependencies\vcpkg\$(PlatformShortName)-windows-static\lib\libmp3lame-static.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile> + <GenerateDebugInformation>false</GenerateDebugInformation> + <ProgramDatabaseFile>$(IntDir)$(TargetName).pdb</ProgramDatabaseFile> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary> + <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers> + <AdditionalLibraryDirectories>..\..\..\external_dependencies\vcpkg\$(PlatformShortName)-windows-static\debug\lib\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> + </Link> + <PostBuildEvent> + <Command>xcopy /Y /D $(OutDir)$(TargetName)$(TargetExt) ..\..\..\..\Build\Winamp_$(PlatformShortName)_$(Configuration)\Plugins\ +if exist ..\resources\libraries\lame_enc.dll xcopy /Y /D ..\..\..\resources\libraries\lame_enc.dll ..\..\..\..\Build\Winamp_$(PlatformShortName)_$(Configuration)\Plugins\</Command> + <Message>Post build event: 'xcopy /Y /D $(OutDir)$(TargetName)$(TargetExt) ..\..\..\..\Build\Winamp_$(PlatformShortName)_$(Configuration)\Plugins\ and if exist ..\..\..\resources\libraries\lame_enc.dll xcopy /Y /D ..\..\..\resources\libraries\lame_enc.dll ..\..\..\..\Build\Winamp_$(PlatformShortName)_$(Configuration)\Shared\'</Message> + </PostBuildEvent> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="24bit.cpp" /> + <ClCompile Include="BladeMP3EncDLL.c" /> + <ClCompile Include="main.cpp"> + <!--PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;NSV_CODER_MP3_EXPORTS</PreprocessorDefinitions> + <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;NSV_CODER_MP3_EXPORTS</PreprocessorDefinitions> + <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;NSV_CODER_MP3_EXPORTS</PreprocessorDefinitions> + <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;NSV_CODER_MP3_EXPORTS</PreprocessorDefinitions--> + </ClCompile> + <ClCompile Include="MP3Coder.cpp" /> + </ItemGroup> + <ItemGroup> + <ResourceCompile Include="enc_lame.rc" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="BladeMP3EncDLL.h" /> + <ClInclude Include="MP3Coder.h" /> + <ClInclude Include="resource.h" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\..\..\Wasabi\Wasabi.vcxproj"> + <Project>{3e0bfa8a-b86a-42e9-a33f-ec294f823f7f}</Project> + </ProjectReference> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/Src/Plugins/Encoder/enc_lame/enc_lame.vcxproj.filters b/Src/Plugins/Encoder/enc_lame/enc_lame.vcxproj.filters new file mode 100644 index 00000000..67ebcd12 --- /dev/null +++ b/Src/Plugins/Encoder/enc_lame/enc_lame.vcxproj.filters @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <ClCompile Include="24bit.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="main.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="MP3Coder.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="BladeMP3EncDLL.c"> + <Filter>Source Files</Filter> + </ClCompile> + </ItemGroup> + <ItemGroup> + <ClInclude Include="resource.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="MP3Coder.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="BladeMP3EncDLL.h"> + <Filter>Header Files</Filter> + </ClInclude> + </ItemGroup> + <ItemGroup> + <Filter Include="Header Files"> + <UniqueIdentifier>{dc9d6b9d-69d1-40a7-97c9-870cfa399631}</UniqueIdentifier> + </Filter> + <Filter Include="Ressource Files"> + <UniqueIdentifier>{3e0eac86-0886-4e85-a300-8b6cb497e2a7}</UniqueIdentifier> + </Filter> + <Filter Include="Source Files"> + <UniqueIdentifier>{bf0f4053-1c32-4453-a394-6542b1301613}</UniqueIdentifier> + </Filter> + </ItemGroup> + <ItemGroup> + <ResourceCompile Include="enc_lame.rc"> + <Filter>Ressource Files</Filter> + </ResourceCompile> + </ItemGroup> +</Project>
\ No newline at end of file diff --git a/Src/Plugins/Encoder/enc_lame/main.cpp b/Src/Plugins/Encoder/enc_lame/main.cpp new file mode 100644 index 00000000..197c3bb1 --- /dev/null +++ b/Src/Plugins/Encoder/enc_lame/main.cpp @@ -0,0 +1,503 @@ +/* +** nsv_coder_lame: main.cpp - LAME mp3 encoder plug-in +** (requires lame_enc.dll) +** +** Copyright (C) 2001-2006 Nullsoft, Inc. +** +** This software is provided 'as-is', without any express or implied warranty. +** In no event will the authors be held liable for any damages arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, including commercial +** applications, and to alter it and redistribute it freely, subject to the following restrictions: +** 1. The origin of this software must not be misrepresented; you must not claim that you wrote the +** original software. If you use this software in a product, an acknowledgment in the product +** documentation would be appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be misrepresented as +** being the original software. +** 3. This notice may not be removed or altered from any source distribution. +*/ + +#define ENC_VERSION "v1.38" + +#include <stdio.h> +#include "resource.h" +#include "BladeMP3EncDLL.h" +#include "MP3Coder.h" +#include <strsafe.h> +#include <shlwapi.h> +#include <lame/lame.h> + +// wasabi based services for localisation support +#include <api/service/waServiceFactory.h> +#include "../Agave/Language/api_language.h" +#include "../winamp/wa_ipc.h" + +HWND winampwnd = 0; +api_service *WASABI_API_SVC = 0; +api_language *WASABI_API_LNG = 0; +HINSTANCE WASABI_API_LNG_HINST = 0, WASABI_API_ORIG_HINST = 0; + +int g_valid_bitrates[] = { 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, -1 }; + +static wchar_t lamedll[MAX_PATH]=L""; +HINSTANCE g_lamedll = 0; + +//BEINITSTREAM beInitStream=0; +//BECLOSESTREAM beCloseStream=0; +//BEENCODECHUNK beEncodeChunk=0; +//BEDEINITSTREAM beDeinitStream=0; +//BEWRITEVBRHEADER beWriteVBRHeader=0; +//BEVERSION beVersion=0; +//BEENCODECHUNKFLOATS16NI beEncodeChunkFloatS16NI=0; + +static HINSTANCE GetMyInstance() +{ + MEMORY_BASIC_INFORMATION mbi = {0}; + if(VirtualQuery(GetMyInstance, &mbi, sizeof(mbi))) + return (HINSTANCE)mbi.AllocationBase; + return NULL; +} + +void GetLocalisationApiService(void) +{ + if(!WASABI_API_LNG) + { + // loader so that we can get the localisation service api for use + if(!WASABI_API_SVC) + { + WASABI_API_SVC = (api_service*)SendMessage(winampwnd, WM_WA_IPC, 0, IPC_GET_API_SERVICE); + if (WASABI_API_SVC == (api_service*)1) + { + WASABI_API_SVC = NULL; + return; + } + } + + if(!WASABI_API_LNG) + { + waServiceFactory *sf; + sf = WASABI_API_SVC->service_getServiceByGuid(languageApiGUID); + if (sf) WASABI_API_LNG = reinterpret_cast<api_language*>(sf->getInterface()); + } + + // need to have this initialised before we try to do anything with localisation features + WASABI_API_START_LANG(GetMyInstance(),EncLameLangGUID); + } +} +/* +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + return TRUE; +}*/ + +typedef struct +{ + configtype cfg; + char configfile[MAX_PATH]; +} +configwndrec; + +void BuildVersionString(wchar_t version[128]) +{ + BE_VERSION ver; + beVersion(&ver); + + if (ver.byBetaLevel) + StringCchPrintf(version, 128, L"%u.%ub%u", (unsigned int)ver.byMajorVersion, (unsigned int)ver.byMinorVersion, (unsigned int)ver.byBetaLevel); + else if (ver.byAlphaLevel) + StringCchPrintf(version, 128, L"%u.%ua%u", (unsigned int)ver.byMajorVersion, (unsigned int)ver.byMinorVersion, (unsigned int)ver.byAlphaLevel); + else + StringCchPrintf(version, 128, L"%u.%u", (unsigned int)ver.byMajorVersion, (unsigned int)ver.byMinorVersion); +} + +void readconfig(char *configfile, configtype *cfg) +{ + cfg->bitrate = 128; + cfg->vbr_max_bitrate = 320; + cfg->abr_bitrate = 128; + + cfg->stereo_mode = 1; + cfg->quality = LQP_FAST_STANDARD; + + cfg->vbr = 2; + cfg->vbr_method = VBR_METHOD_NEW; + + if (configfile) + GetPrivateProfileStructA("audio_mp3l", "conf", cfg, sizeof(configtype), configfile); +} + +void writeconfig(char* configfile, configtype *cfg) +{ + if (configfile) + WritePrivateProfileStructA("audio_mp3l", "conf", cfg, sizeof(configtype), configfile); +} + +extern "C" +{ + unsigned int __declspec(dllexport) GetAudioTypes3(int idx, char *desc) + { + //if ((g_lamedll != NULL) && (beInitStream != NULL) && (beCloseStream != NULL) && (beEncodeChunk != NULL) && (beDeinitStream != NULL) && (beWriteVBRHeader != NULL) && (beVersion != NULL)) + if (idx == 0) + { + GetLocalisationApiService(); + StringCchPrintfA(desc, 1024, WASABI_API_LNGSTRING(IDS_ENC_LAME_DESC), ENC_VERSION); + return mmioFOURCC('M', 'P', '3', 'l'); + } + return 0; + } + + AudioCoder __declspec(dllexport) *CreateAudio3(int nch, int srate, int bps, unsigned int srct, unsigned int *outt, char *configfile) + { + if (nch > 2 || srate > 48000) + return NULL; + + if (srct == mmioFOURCC('P', 'C', 'M', ' ') && *outt == mmioFOURCC('M', 'P', '3', 'l')) + { + configtype cfg; + readconfig(configfile, &cfg); + *outt = mmioFOURCC('M', 'P', '3', ' '); + AudioCoderMP3 *t=0; + if (bps != 16) + t = new AudioCoderMP3_24(nch, srate, bps, &cfg); + else + t = new AudioCoderMP3(nch, srate, bps, &cfg); + if (t->GetLastError()) + { + delete t; + return NULL; + } + return t; + } + return NULL; + } + + void __declspec(dllexport) FinishAudio3(const char *filename, AudioCoder *coder) + { + //beWriteVBRHeader(filename); + ((AudioCoderMP3*)coder)->setVbrFilename((char *)filename); //apparently this needs to be called after beCloseStream + } + + void __declspec(dllexport) PrepareToFinish(const char *filename, AudioCoder *coder) + { + ((AudioCoderMP3*)coder)->PrepareToFinish(); + } + + static void setBitrates(HWND hwndDlg, int mi, int ma) + { + int i = 0; + while (g_valid_bitrates[i] > 0) + { + if (g_valid_bitrates[i] == mi) SendDlgItemMessage(hwndDlg, IDC_BITRATE, CB_SETCURSEL, i, 0); + if (g_valid_bitrates[i] == ma) SendDlgItemMessage(hwndDlg, IDC_MAXBITRATE, CB_SETCURSEL, i, 0); + i++; + } + } + + BOOL CALLBACK DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) + { + if (uMsg == WM_USER + 666) + { + int vbr_meth = (int)SendDlgItemMessage(hwndDlg, IDC_VBRMETHOD, CB_GETCURSEL, 0, 0); + if (vbr_meth == CB_ERR) vbr_meth = 0; + vbr_meth--; + EnableWindow(GetDlgItem(hwndDlg, IDC_VBRQ), vbr_meth != -1 && vbr_meth != 4); + EnableWindow(GetDlgItem(hwndDlg, IDC_VBRQ_TEXT), vbr_meth != -1 && vbr_meth != 4); + SetDlgItemTextW(hwndDlg, IDC_BITRATE_TEXT1, WASABI_API_LNGSTRINGW((vbr_meth == -1 ? IDS_BITRATE : vbr_meth == 4 ? IDS_ABR_MIN_BITRATE : IDS_VBR_MIN_BITRATE))); + SetDlgItemTextW(hwndDlg, IDC_MAXBITRATE_TEXT1, WASABI_API_LNGSTRINGW((vbr_meth == -1 ? IDS_N_A : vbr_meth == 4 ? IDS_ABR_MAX_BITRATE : IDS_VBR_MAX_BITRATE))); + SetDlgItemTextW(hwndDlg, IDC_AVGBITRATE_TEXT1, WASABI_API_LNGSTRINGW((vbr_meth != 4 ? IDS_N_A : IDS_AVERAGE_BITRATE))); + + EnableWindow(GetDlgItem(hwndDlg, IDC_MAXBITRATE_TEXT1), vbr_meth != -1); + EnableWindow(GetDlgItem(hwndDlg, IDC_MAXBITRATE_TEXT2), vbr_meth != -1); + EnableWindow(GetDlgItem(hwndDlg, IDC_MAXBITRATE), vbr_meth != -1); + EnableWindow(GetDlgItem(hwndDlg, IDC_AVGBITRATE_TEXT1), vbr_meth == 4); + EnableWindow(GetDlgItem(hwndDlg, IDC_AVGBITRATE_TEXT2), vbr_meth == 4); + EnableWindow(GetDlgItem(hwndDlg, IDC_AVGBITRATE), vbr_meth == 4); + + int qual = (int)SendDlgItemMessage(hwndDlg, IDC_QUALITY, CB_GETCURSEL, 0, 0); + if (qual == CB_ERR) qual = 0; + switch (qual) + { + case LQP_R3MIX: + case LQP_STANDARD: + case LQP_FAST_STANDARD: + case LQP_EXTREME: + case LQP_FAST_EXTREME: + case LQP_INSANE: + case LQP_MEDIUM: + case LQP_FAST_MEDIUM: + case LQP_ABR: + case LQP_CBR: + EnableWindow(GetDlgItem(hwndDlg, IDC_STEREOMODE), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_VBRMETHOD), 0); + break; + default: + EnableWindow(GetDlgItem(hwndDlg, IDC_STEREOMODE), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_VBRMETHOD), 1); + break; + } + if (qual == 4) EnableWindow(GetDlgItem(hwndDlg, IDC_VBRQ), 0); + } + + if (uMsg == WM_USER + 667) + { + int qual = (int)SendDlgItemMessage(hwndDlg, IDC_QUALITY, CB_GETCURSEL, 0, 0); + if (qual == CB_ERR) qual = 0; + switch (qual) + { + case LQP_R3MIX: + SendDlgItemMessage(hwndDlg, IDC_VBRMETHOD, CB_SETCURSEL, 3, 0); + setBitrates(hwndDlg, 96, 224); + SendDlgItemMessage(hwndDlg, IDC_STEREOMODE, CB_SETCURSEL, 1, 0); + SendDlgItemMessage(hwndDlg, IDC_VBRQ, CB_SETCURSEL, 1, 0); + break; + case LQP_STANDARD: /* check for alt-preset standard */ + SendDlgItemMessage(hwndDlg, IDC_VBRMETHOD, CB_SETCURSEL, 2, 0); + setBitrates(hwndDlg, 32, 320); + SendDlgItemMessage(hwndDlg, IDC_STEREOMODE, CB_SETCURSEL, 1, 0); + SendDlgItemMessage(hwndDlg, IDC_VBRQ, CB_SETCURSEL, 2, 0); + break; + case LQP_FAST_STANDARD: /* check for alt-preset fast standard */ + SendDlgItemMessage(hwndDlg, IDC_VBRMETHOD, CB_SETCURSEL, 3, 0); + setBitrates(hwndDlg, 32, 320); + SendDlgItemMessage(hwndDlg, IDC_STEREOMODE, CB_SETCURSEL, 1, 0); + SendDlgItemMessage(hwndDlg, IDC_VBRQ, CB_SETCURSEL, 2, 0); + break; + case LQP_MEDIUM: /* check for alt-preset medium */ + SendDlgItemMessage(hwndDlg, IDC_VBRMETHOD, CB_SETCURSEL, 2, 0); + setBitrates(hwndDlg, 32, 320); + SendDlgItemMessage(hwndDlg, IDC_STEREOMODE, CB_SETCURSEL, 1, 0); + SendDlgItemMessage(hwndDlg, IDC_VBRQ, CB_SETCURSEL, 2, 0); + break; + case LQP_FAST_MEDIUM: /* check for alt-preset fast medium */ + SendDlgItemMessage(hwndDlg, IDC_VBRMETHOD, CB_SETCURSEL, 3, 0); + setBitrates(hwndDlg, 32, 320); + SendDlgItemMessage(hwndDlg, IDC_STEREOMODE, CB_SETCURSEL, 1, 0); + SendDlgItemMessage(hwndDlg, IDC_VBRQ, CB_SETCURSEL, 2, 0); + break; + case LQP_EXTREME: /* check for alt-preset extreme */ + SendDlgItemMessage(hwndDlg, IDC_VBRMETHOD, CB_SETCURSEL, 2, 0); + setBitrates(hwndDlg, 32, 320); + SendDlgItemMessage(hwndDlg, IDC_STEREOMODE, CB_SETCURSEL, 1, 0); + SendDlgItemMessage(hwndDlg, IDC_VBRQ, CB_SETCURSEL, 2, 0); + break; + case LQP_FAST_EXTREME: /* check for alt-preset fast extreme */ + SendDlgItemMessage(hwndDlg, IDC_VBRMETHOD, CB_SETCURSEL, 3, 0); + setBitrates(hwndDlg, 32, 320); + SendDlgItemMessage(hwndDlg, IDC_STEREOMODE, CB_SETCURSEL, 1, 0); + SendDlgItemMessage(hwndDlg, IDC_VBRQ, CB_SETCURSEL, 2, 0); + break; + case LQP_INSANE: /* check for alt-preset fast insane */ + SendDlgItemMessage(hwndDlg, IDC_VBRMETHOD, CB_SETCURSEL, 0, 0); + setBitrates(hwndDlg, 320, 320); + SendDlgItemMessage(hwndDlg, IDC_STEREOMODE, CB_SETCURSEL, 1, 0); + break; + case LQP_ABR: /* check for alt-preset fast insane */ + SendDlgItemMessage(hwndDlg, IDC_VBRMETHOD, CB_SETCURSEL, 5, 0); + setBitrates(hwndDlg, 64, 320); + SendDlgItemMessage(hwndDlg, IDC_STEREOMODE, CB_SETCURSEL, 1, 0); + SendDlgItemMessage(hwndDlg, IDC_VBRQ, CB_SETCURSEL, 2, 0); + break; + case LQP_CBR: /* check for alt-preset fast insane */ + SendDlgItemMessage(hwndDlg, IDC_VBRMETHOD, CB_SETCURSEL, 0, 0); + SendDlgItemMessage(hwndDlg, IDC_STEREOMODE, CB_SETCURSEL, 1, 0); + break; + } + SendMessage(hwndDlg, WM_USER + 666, 0, 0); + } + + if (uMsg == WM_INITDIALOG) + { +#if defined (_WIN64) + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); +#else + SetWindowLong(hwndDlg, GWL_USERDATA, lParam); +#endif + wchar_t versionText[128] = {0}; + BuildVersionString(versionText); + SetDlgItemText(hwndDlg, IDC_LAMEVERSION, versionText); + if (lParam) + { + configwndrec *wc = (configwndrec*)lParam; + + // -1=none, 0=default, 1=old, 2=new, 3=mtrh, 4=abr + SendDlgItemMessageW(hwndDlg, IDC_VBRMETHOD, CB_ADDSTRING, 0, (LPARAM)L"CBR"); + SendDlgItemMessageW(hwndDlg, IDC_VBRMETHOD, CB_ADDSTRING, 0, (LPARAM)L"VBR default"); + SendDlgItemMessageW(hwndDlg, IDC_VBRMETHOD, CB_ADDSTRING, 0, (LPARAM)L"VBR old"); + SendDlgItemMessageW(hwndDlg, IDC_VBRMETHOD, CB_ADDSTRING, 0, (LPARAM)L"VBR new"); + SendDlgItemMessageW(hwndDlg, IDC_VBRMETHOD, CB_ADDSTRING, 0, (LPARAM)L"VBR mtrh"); + SendDlgItemMessageW(hwndDlg, IDC_VBRMETHOD, CB_ADDSTRING, 0, (LPARAM)L"ABR"); + SendDlgItemMessageW(hwndDlg, IDC_VBRMETHOD, CB_SETCURSEL, wc->cfg.vbr_method + 1, 0); + + //0=stereo,1=jstereo,2=mchannel,3=mono + SendDlgItemMessageW(hwndDlg, IDC_STEREOMODE, CB_ADDSTRING, 0, (LPARAM)WASABI_API_LNGSTRINGW(IDS_STEREO)); + SendDlgItemMessageW(hwndDlg, IDC_STEREOMODE, CB_ADDSTRING, 0, (LPARAM)WASABI_API_LNGSTRINGW(IDS_JOINT_STEREO)); + SendDlgItemMessageW(hwndDlg, IDC_STEREOMODE, CB_ADDSTRING, 0, (LPARAM)WASABI_API_LNGSTRINGW(IDS_MULTI_CHANNEL)); + SendDlgItemMessageW(hwndDlg, IDC_STEREOMODE, CB_ADDSTRING, 0, (LPARAM)WASABI_API_LNGSTRINGW(IDS_MONO)); + SendDlgItemMessageW(hwndDlg, IDC_STEREOMODE, CB_SETCURSEL, wc->cfg.stereo_mode, 0); + + { + int i = 0; + while (g_valid_bitrates[i] > 0) + { + wchar_t buf[64] = {0}; + StringCchPrintf(buf, 64, L"%d", g_valid_bitrates[i]); + SendDlgItemMessage(hwndDlg, IDC_BITRATE , CB_ADDSTRING, 0, (LPARAM)buf); + SendDlgItemMessage(hwndDlg, IDC_MAXBITRATE, CB_ADDSTRING, 0, (LPARAM)buf); + SendDlgItemMessage(hwndDlg, IDC_AVGBITRATE, CB_ADDSTRING, 0, (LPARAM)buf); + SendDlgItemMessage(hwndDlg, IDC_BITRATE , CB_SETITEMDATA, i, g_valid_bitrates[i]); + SendDlgItemMessage(hwndDlg, IDC_MAXBITRATE, CB_SETITEMDATA, i, g_valid_bitrates[i]); + SendDlgItemMessage(hwndDlg, IDC_AVGBITRATE, CB_SETITEMDATA, i, g_valid_bitrates[i]); + i++; + }; + + i = 0; + while (g_valid_bitrates[i] > 0) + { + if (g_valid_bitrates[i] == wc->cfg.bitrate ) SendDlgItemMessage(hwndDlg, IDC_BITRATE , CB_SETCURSEL, i, 0); + if (g_valid_bitrates[i] == wc->cfg.abr_bitrate ) SendDlgItemMessage(hwndDlg, IDC_AVGBITRATE, CB_SETCURSEL, i, 0); + if (g_valid_bitrates[i] == wc->cfg.vbr_max_bitrate) SendDlgItemMessage(hwndDlg, IDC_MAXBITRATE, CB_SETCURSEL, i, 0); + i++; + } + } + + SendDlgItemMessageW(hwndDlg, IDC_QUALITY, CB_ADDSTRING, 0, (LPARAM)WASABI_API_LNGSTRINGW(IDS_NORMAL)); + SendDlgItemMessageW(hwndDlg, IDC_QUALITY, CB_ADDSTRING, 0, (LPARAM)WASABI_API_LNGSTRINGW(IDS_LOW)); + SendDlgItemMessageW(hwndDlg, IDC_QUALITY, CB_ADDSTRING, 0, (LPARAM)WASABI_API_LNGSTRINGW(IDS_HIGH)); + SendDlgItemMessageW(hwndDlg, IDC_QUALITY, CB_ADDSTRING, 0, (LPARAM)WASABI_API_LNGSTRINGW(IDS_VOICE)); + SendDlgItemMessageW(hwndDlg, IDC_QUALITY, CB_ADDSTRING, 0, (LPARAM)WASABI_API_LNGSTRINGW(IDS_R3MIX)); + SendDlgItemMessageW(hwndDlg, IDC_QUALITY, CB_ADDSTRING, 0, (LPARAM)WASABI_API_LNGSTRINGW(IDS_VERY_HIGH)); + SendDlgItemMessageW(hwndDlg, IDC_QUALITY, CB_ADDSTRING, 0, (LPARAM)L"--alt-preset standard"); + SendDlgItemMessageW(hwndDlg, IDC_QUALITY, CB_ADDSTRING, 0, (LPARAM)L"--alt-preset fast standard"); + SendDlgItemMessageW(hwndDlg, IDC_QUALITY, CB_ADDSTRING, 0, (LPARAM)L"--alt-preset extreme"); + SendDlgItemMessageW(hwndDlg, IDC_QUALITY, CB_ADDSTRING, 0, (LPARAM)L"--alt-preset fast extreme"); + SendDlgItemMessageW(hwndDlg, IDC_QUALITY, CB_ADDSTRING, 0, (LPARAM)L"--alt-preset insane"); + SendDlgItemMessageW(hwndDlg, IDC_QUALITY, CB_ADDSTRING, 0, (LPARAM)L"--alt-preset abr"); + SendDlgItemMessageW(hwndDlg, IDC_QUALITY, CB_ADDSTRING, 0, (LPARAM)L"--alt-preset cbr"); + SendDlgItemMessageW(hwndDlg, IDC_QUALITY, CB_ADDSTRING, 0, (LPARAM)L"--alt-preset medium"); + SendDlgItemMessageW(hwndDlg, IDC_QUALITY, CB_ADDSTRING, 0, (LPARAM)L"--alt-preset fast medium"); + SendDlgItemMessageW(hwndDlg, IDC_QUALITY, CB_SETCURSEL, wc->cfg.quality, 0); + + int x; + for (x = 0; x < 10; x ++) + { + wchar_t buf[123] = {0}; + StringCchPrintfW(buf, 123, L"%d%s", x, x == 0 ? WASABI_API_LNGSTRINGW(IDS_HIGH_BRACKET) : x == 9 ? WASABI_API_LNGSTRINGW(IDS_LOW_BRACKET) : L""); + SendDlgItemMessageW(hwndDlg, IDC_VBRQ, CB_ADDSTRING, 0, (LPARAM)buf); + } + SendDlgItemMessage(hwndDlg, IDC_VBRQ, CB_SETCURSEL, wc->cfg.vbr, 0); + + SendMessage(hwndDlg, WM_USER + 666, 0, 0); + } + } + + if (uMsg == WM_COMMAND) + { + if (LOWORD(wParam) == IDC_VBRMETHOD && HIWORD(wParam) == CBN_SELCHANGE) + SendMessage(hwndDlg, WM_USER + 666, 0, 0); + if (LOWORD(wParam) == IDC_QUALITY && HIWORD(wParam) == CBN_SELCHANGE) + SendMessage(hwndDlg, WM_USER + 667, 0, 0); + } + + if (uMsg == WM_DESTROY) + { +#if defined (_WIN64) + configwndrec *wc = (configwndrec*)SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0); +#else + configwndrec* wc = (configwndrec*)SetWindowLong(hwndDlg, GWL_USERDATA, 0); +#endif + if (wc) + { + wc->cfg.bitrate = (int)SendDlgItemMessage(hwndDlg, IDC_BITRATE , CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_BITRATE , CB_GETCURSEL, 0, 0), 0); + wc->cfg.vbr_max_bitrate = (int)SendDlgItemMessage(hwndDlg, IDC_MAXBITRATE, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_MAXBITRATE, CB_GETCURSEL, 0, 0), 0); + wc->cfg.abr_bitrate = (int)SendDlgItemMessage(hwndDlg, IDC_AVGBITRATE, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_AVGBITRATE, CB_GETCURSEL, 0, 0), 0); + int vbr_meth = (int)SendDlgItemMessage(hwndDlg, IDC_VBRMETHOD, CB_GETCURSEL, 0, 0); + if (vbr_meth == CB_ERR) vbr_meth = 0; + wc->cfg.vbr_method = vbr_meth - 1; + wc->cfg.stereo_mode = (int)SendDlgItemMessage(hwndDlg, IDC_STEREOMODE, CB_GETCURSEL, 0, 0); + wc->cfg.quality = (int)SendDlgItemMessage(hwndDlg, IDC_QUALITY, CB_GETCURSEL, 0, 0); + wc->cfg.vbr = (int)SendDlgItemMessage(hwndDlg, IDC_VBRQ, CB_GETCURSEL, 0, 0); + writeconfig(wc->configfile, &wc->cfg); + free(wc); + } + } + return 0; + } + + HWND __declspec(dllexport) ConfigAudio3(HWND hwndParent, HINSTANCE hinst, unsigned int outt, char*configfile) + { + if (outt == mmioFOURCC('M', 'P', '3', 'l')) + { + configwndrec *wr = (configwndrec*)malloc(sizeof(configwndrec)); + if (configfile) lstrcpynA(wr->configfile, configfile, MAX_PATH); + else wr->configfile[0] = 0; + + readconfig(configfile, &wr->cfg); + GetLocalisationApiService(); + return WASABI_API_CREATEDIALOGPARAMW(IDD_MP3, hwndParent, DlgProc, (LPARAM)wr); + } + return NULL; + } + + int __declspec(dllexport) SetConfigItem(unsigned int outt, wchar_t*item, char *data, char* configfile) + { + if (outt == mmioFOURCC('M', 'P', '3', 'l')) + { + configtype cfg; + readconfig(configfile, &cfg); + if (!lstrcmpi(item, L"bitrate")) // assume CBR bitrate + { + cfg.abr_bitrate = cfg.bitrate = atoi(data); + cfg.vbr_method = -1; + } + writeconfig(configfile, &cfg); + return 1; + } + return 0; + } + + int __declspec(dllexport) GetConfigItem(unsigned int outt, wchar_t *item, wchar_t *data, int len, char* configfile) + { + if (outt == mmioFOURCC('M', 'P', '3', 'l')) + { + configtype cfg; + readconfig(configfile, &cfg); + if (!lstrcmpi(item, L"bitrate")) + { + int bitrate; + if(cfg.vbr_method == -1) bitrate = cfg.bitrate; + else if(cfg.vbr_method == 4) bitrate = cfg.abr_bitrate; + else bitrate = (cfg.bitrate + cfg.vbr_max_bitrate) / 2; + StringCchPrintf(data,len,L"%d",bitrate); + } + return 1; + } + return 0; + } + + void __declspec(dllexport) SetWinampHWND(HWND hwnd) + { + winampwnd = hwnd; + + // this is called when the encoder is needed (and is slightly better than the dllmain loading from before) + + /*if (!g_lamedll) + { + if (!lamedll[0]) + { + PathCombineW(lamedll, (wchar_t*)SendMessage(hwnd, WM_WA_IPC, 0, IPC_GETSHAREDDLLDIRECTORYW),L"lame_enc.dll"); + } + g_lamedll = LoadLibraryW(lamedll); + }*/ + + /*if (g_lamedll) + { + beInitStream = (BEINITSTREAM) &beInitStream; + beCloseStream = (BECLOSESTREAM) GetProcAddress(g_lamedll, TEXT_BECLOSESTREAM); + beEncodeChunk = (BEENCODECHUNK) GetProcAddress(g_lamedll, TEXT_BEENCODECHUNK); + beDeinitStream = (BEDEINITSTREAM) GetProcAddress(g_lamedll, TEXT_BEDEINITSTREAM); + beWriteVBRHeader = (BEWRITEVBRHEADER) GetProcAddress(g_lamedll, TEXT_BEWRITEVBRHEADER); + beVersion = (BEVERSION) GetProcAddress(g_lamedll, TEXT_BEVERSION); + beEncodeChunkFloatS16NI = (BEENCODECHUNKFLOATS16NI)GetProcAddress(g_lamedll, TEXT_BEENCODECHUNKFLOATS16NI); + }*/ + } +};
\ No newline at end of file diff --git a/Src/Plugins/Encoder/enc_lame/resource.h b/Src/Plugins/Encoder/enc_lame/resource.h new file mode 100644 index 00000000..12db614a --- /dev/null +++ b/Src/Plugins/Encoder/enc_lame/resource.h @@ -0,0 +1,57 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by enc_lame.rc +// +#define IDS_BITRATE 0 +#define IDS_ABR_MIN_BITRATE 1 +#define IDS_VBR_MIN_BITRATE 2 +#define IDS_N_A 3 +#define IDS_ABR_MAX_BITRATE 4 +#define IDS_VBR_MAX_BITRATE 5 +#define IDS_AVERAGE_BITRATE 6 +#define IDS_STEREO 7 +#define IDS_JOINT_STEREO 8 +#define IDS_MULTI_CHANNEL 9 +#define IDS_MONO 10 +#define IDS_NORMAL 11 +#define IDS_LOW 12 +#define IDS_HIGH 13 +#define IDS_VOICE 14 +#define IDS_R3MIX 15 +#define IDS_VERY_HIGH 16 +#define IDS_HIGH_BRACKET 17 +#define IDS_LOW_BRACKET 18 +#define IDS_ENC_LAME_DESC 19 +#define IDS_ENC_LAME_DESC_MISSING 20 +#define IDD_MP3 102 +#define IDD_MP3_MISSING 105 +#define IDC_BITRATE 1000 +#define IDC_VBR 1001 +#define IDC_QUALITY 1002 +#define IDC_JSTEREO1 1003 +#define IDC_JSTEREO2 1004 +#define IDC_BITRATE_TEXT1 1004 +#define IDC_MAXBITRATE 1005 +#define IDC_BITRATE_TEXT2 1006 +#define IDC_MAXBITRATE_TEXT1 1007 +#define IDC_MAXBITRATE_TEXT2 1008 +#define IDC_VBRMETHOD 1009 +#define IDC_AVGBITRATE_TEXT1 1010 +#define IDC_AVGBITRATE 1011 +#define IDC_AVGBITRATE_TEXT2 1012 +#define IDC_STEREOMODE 1013 +#define IDC_VBRQ_TEXT 1014 +#define IDC_VBRQ 1015 +#define IDC_LAMEVERSION 1016 +#define IDC_URL1 1026 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 106 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1017 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/Src/Plugins/Encoder/enc_lame/version.rc2 b/Src/Plugins/Encoder/enc_lame/version.rc2 new file mode 100644 index 00000000..a1a762ea --- /dev/null +++ b/Src/Plugins/Encoder/enc_lame/version.rc2 @@ -0,0 +1,39 @@ + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// +#include "../../../Winamp/buildType.h" +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,38,0,0 + PRODUCTVERSION WINAMP_PRODUCTVER + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", "Winamp SA" + VALUE "FileDescription", "Winamp Encoder Plug-in" + VALUE "FileVersion", "1,38,0,0" + VALUE "InternalName", "Nullsoft MP3 Encoder" + VALUE "LegalCopyright", "Copyright © 2006-2023 Winamp SA" + VALUE "LegalTrademarks", "Nullsoft and Winamp are trademarks of Winamp SA" + VALUE "OriginalFilename", "enc_lame.dll" + VALUE "ProductName", "Winamp" + VALUE "ProductVersion", STR_WINAMP_PRODUCTVER + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END |