Initial community commit
This commit is contained in:
parent
537bcbc862
commit
fc06254474
16440 changed files with 4239995 additions and 2 deletions
265
Src/Plugins/Encoder/enc_wav/ACMEncoder.cpp
Normal file
265
Src/Plugins/Encoder/enc_wav/ACMEncoder.cpp
Normal file
|
@ -0,0 +1,265 @@
|
|||
#include "ACMEncoder.h"
|
||||
|
||||
#define rev32(X) ((((DWORD)(X)&0xFF)<<24)|(((DWORD)(X)&0xFF00)<<8)|(((DWORD)(X)&0xFF0000)>>8)|(((DWORD)(X)&0xFF000000)>>24))
|
||||
|
||||
static DWORD FileTell(HANDLE hFile)
|
||||
{
|
||||
return SetFilePointer(hFile, 0, 0, FILE_CURRENT);
|
||||
}
|
||||
static void FileAlign(HANDLE hFile)
|
||||
{
|
||||
if (FileTell(hFile)&1) SetFilePointer(hFile, 1, 0, FILE_CURRENT);
|
||||
}
|
||||
|
||||
#define BUFSIZE 0x20000
|
||||
|
||||
ACMEncoder::ACMEncoder(int srate, int nch, int bps, ACMConfig *config)
|
||||
{
|
||||
m_did_header = 0;
|
||||
m_srate = srate;
|
||||
m_nch = nch;
|
||||
m_bps = bps;
|
||||
m_error = 0;
|
||||
hStream = 0;
|
||||
hStreamResample = 0;
|
||||
m_acm_resample_buf = NULL;
|
||||
m_acm_resample_outbuf = NULL;
|
||||
m_bytes_done = 0;
|
||||
m_hlen = 0;
|
||||
m_nsam = 0;
|
||||
|
||||
m_acm_buf = (unsigned char *)malloc(BUFSIZE);
|
||||
m_acm_outbuf = (unsigned char *)malloc(BUFSIZE);
|
||||
m_bytes_inbuf = 0;
|
||||
m_bytes_outbuf = 0;
|
||||
m_convert_wfx = config->convert_wfx;
|
||||
do_header = config->header;
|
||||
|
||||
m_wfx_src.wFormatTag = WAVE_FORMAT_PCM;
|
||||
m_wfx_src.nChannels = nch;
|
||||
m_wfx_src.nSamplesPerSec = srate;
|
||||
m_wfx_src.nAvgBytesPerSec = srate * nch * (bps >> 3);
|
||||
m_wfx_src.nBlockAlign = nch * (bps >> 3);
|
||||
m_wfx_src.wBitsPerSample = bps;
|
||||
m_wfx_src.cbSize = 0;
|
||||
MMRESULT rs = acmStreamOpen(&hStream, 0, &m_wfx_src, &m_convert_wfx.wfx, 0, 0, 0, ACM_STREAMOPENF_NONREALTIME);
|
||||
if (rs)
|
||||
{
|
||||
// need resampling
|
||||
WAVEFORMATEX wfx1;
|
||||
ZeroMemory(&wfx1, sizeof(wfx1));
|
||||
wfx1.wFormatTag = WAVE_FORMAT_PCM;
|
||||
if (acmFormatSuggest(0, &m_convert_wfx.wfx, &wfx1, sizeof(WAVEFORMATEX), ACM_FORMATSUGGESTF_WFORMATTAG)) m_error = 1;
|
||||
else if (acmStreamOpen(&hStream, 0, &wfx1, &m_convert_wfx.wfx, 0, 0, 0, ACM_STREAMOPENF_NONREALTIME)) m_error = 1;
|
||||
else if (acmStreamOpen(&hStreamResample, 0, &m_wfx_src, &wfx1, 0, 0, 0, ACM_STREAMOPENF_NONREALTIME)) m_error = 1;
|
||||
else
|
||||
{
|
||||
ZeroMemory(&ahdResample, sizeof(ahdResample));
|
||||
ahdResample.cbStruct = sizeof(ahdResample);
|
||||
ahdResample.pbSrc = m_acm_resample_buf = (unsigned char *)malloc(BUFSIZE);
|
||||
ahdResample.cbSrcLength = BUFSIZE;
|
||||
ahdResample.pbDst = m_acm_resample_outbuf = (unsigned char *)malloc(BUFSIZE);
|
||||
ahdResample.cbDstLength = BUFSIZE;
|
||||
if (acmStreamPrepareHeader(hStreamResample, &ahdResample, 0)) m_error = 1;
|
||||
m_bytes_inbuf_resample = 0;
|
||||
m_bytes_outbuf_resample = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hStream)
|
||||
{
|
||||
m_error = 1;
|
||||
return ;
|
||||
}
|
||||
|
||||
ZeroMemory(&ahd, sizeof(ahd));
|
||||
ahd.cbStruct = sizeof(ahd);
|
||||
ahd.pbSrc = m_acm_buf;
|
||||
ahd.cbSrcLength = BUFSIZE;
|
||||
ahd.pbDst = m_acm_outbuf;
|
||||
ahd.cbDstLength = BUFSIZE;
|
||||
if (acmStreamPrepareHeader(hStream, &ahd, 0)) m_error = 1;
|
||||
}
|
||||
|
||||
ACMEncoder::~ACMEncoder()
|
||||
{
|
||||
free(m_acm_buf);
|
||||
free(m_acm_outbuf);
|
||||
free(m_acm_resample_buf);
|
||||
free(m_acm_resample_outbuf);
|
||||
if (hStream)
|
||||
{
|
||||
if (ahd.fdwStatus & ACMSTREAMHEADER_STATUSF_PREPARED) acmStreamUnprepareHeader(hStream, &ahd, 0);
|
||||
acmStreamClose(hStream, 0);
|
||||
}
|
||||
if (hStreamResample)
|
||||
{
|
||||
if (ahdResample.fdwStatus & ACMSTREAMHEADER_STATUSF_PREPARED) acmStreamUnprepareHeader(hStreamResample, &ahdResample, 0);
|
||||
acmStreamClose(hStreamResample, 0);
|
||||
}
|
||||
}
|
||||
|
||||
int ACMEncoder::Encode(int framepos, void *in, int in_avail, int *in_used, void *out, int out_avail)
|
||||
{
|
||||
char *pout = (char *)out;
|
||||
int retval = 0;
|
||||
|
||||
if (!m_did_header && do_header)
|
||||
{
|
||||
int s = 4 + 4 + 12 - 4;
|
||||
|
||||
int t;
|
||||
if (m_convert_wfx.wfx.wFormatTag == WAVE_FORMAT_PCM) t = 0x10;
|
||||
else t = sizeof(WAVEFORMATEX) + m_convert_wfx.wfx.cbSize;
|
||||
s += 4 + t;
|
||||
if (s&1) s++;
|
||||
|
||||
if (m_convert_wfx.wfx.wFormatTag != WAVE_FORMAT_PCM)
|
||||
s += 12;
|
||||
|
||||
s += 8;
|
||||
|
||||
if (out_avail < s) return 0;
|
||||
//xx bytes of randomness
|
||||
m_hlen = s;
|
||||
m_did_header = 1;
|
||||
out_avail -= s;
|
||||
pout += s;
|
||||
retval = s;
|
||||
}
|
||||
|
||||
if (!m_bytes_outbuf)
|
||||
{
|
||||
if (hStreamResample)
|
||||
{
|
||||
if (!m_bytes_outbuf_resample)
|
||||
{
|
||||
DWORD flags = ACM_STREAMCONVERTF_BLOCKALIGN;
|
||||
|
||||
int l = min(in_avail, BUFSIZE - m_bytes_inbuf_resample);
|
||||
if (l < 0) l = 0;
|
||||
if (l > 0) memcpy(m_acm_resample_buf + m_bytes_inbuf_resample, in, l);
|
||||
m_bytes_inbuf_resample += l;
|
||||
*in_used = l;
|
||||
m_nsam += l;
|
||||
|
||||
ahdResample.cbSrcLength = m_bytes_inbuf_resample;
|
||||
acmStreamConvert(hStreamResample, &ahdResample, flags);
|
||||
m_bytes_inbuf_resample -= ahdResample.cbSrcLengthUsed;
|
||||
memcpy(m_acm_resample_buf, m_acm_resample_buf + ahdResample.cbSrcLengthUsed, m_bytes_inbuf_resample); //memmove
|
||||
m_bytes_outbuf_resample = ahdResample.cbDstLengthUsed;
|
||||
}
|
||||
in = (void*)m_acm_resample_outbuf;
|
||||
in_avail = m_bytes_outbuf_resample;
|
||||
m_bytes_outbuf_resample = 0;
|
||||
in_used = NULL;
|
||||
}
|
||||
|
||||
DWORD flags = ACM_STREAMCONVERTF_BLOCKALIGN;
|
||||
|
||||
int l = min(in_avail, BUFSIZE - m_bytes_inbuf);
|
||||
if (l < 0) l = 0;
|
||||
if (l > 0) memcpy(m_acm_buf + m_bytes_inbuf, in, l);
|
||||
m_bytes_inbuf += l;
|
||||
if (in_used)
|
||||
{
|
||||
*in_used = l;
|
||||
m_nsam += l;
|
||||
}
|
||||
|
||||
if (m_bytes_inbuf)
|
||||
{
|
||||
ahd.cbSrcLength = m_bytes_inbuf;
|
||||
acmStreamConvert(hStream, &ahd, flags);
|
||||
m_bytes_inbuf -= ahd.cbSrcLengthUsed;
|
||||
memcpy(m_acm_buf, m_acm_buf + ahd.cbSrcLengthUsed, m_bytes_inbuf); //memmove
|
||||
m_bytes_outbuf = ahd.cbDstLengthUsed;
|
||||
m_bytes_done += l;
|
||||
}
|
||||
}
|
||||
if (m_bytes_outbuf)
|
||||
{
|
||||
int l = min(out_avail, m_bytes_outbuf);
|
||||
memcpy(pout, m_acm_outbuf, l);
|
||||
m_bytes_outbuf -= l;
|
||||
memcpy(m_acm_outbuf, m_acm_outbuf + l, m_bytes_outbuf);
|
||||
retval += l;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
void ACMEncoder::FinishAudio(const wchar_t *filename)
|
||||
{
|
||||
if (!do_header) return ;
|
||||
|
||||
HANDLE fh = CreateFileW(filename, GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
|
||||
if (fh == INVALID_HANDLE_VALUE)
|
||||
return;
|
||||
|
||||
int len, i;
|
||||
const unsigned char ispred1[4] =
|
||||
{
|
||||
0x52 , 0x49 , 0x46 , 0x46
|
||||
};
|
||||
const unsigned char ispred2[12] =
|
||||
{
|
||||
0x57, 0x41 , 0x56 , 0x45 , 0x66 , 0x6d , 0x74 , 0x20 , 0x10 , 0x0 , 0x0 , 0x0
|
||||
};
|
||||
|
||||
len = m_bytes_done;
|
||||
DWORD a = 0;
|
||||
|
||||
FileAlign(fh);
|
||||
|
||||
SetFilePointer(fh, 0, 0, FILE_BEGIN);
|
||||
|
||||
WriteFile(fh, ispred1, sizeof(ispred1), &a, NULL);
|
||||
i = len + (m_hlen) - 8;
|
||||
if (i&1) i++;
|
||||
a = 0; WriteFile(fh, &i, 4, &a, NULL);
|
||||
a = 0; WriteFile(fh, ispred2, sizeof(ispred2) - (hStream ? 4 : 0), &a, NULL);
|
||||
|
||||
int t;
|
||||
if (m_convert_wfx.wfx.wFormatTag == WAVE_FORMAT_PCM) t = 0x10;
|
||||
else t = sizeof(WAVEFORMATEX) + m_convert_wfx.wfx.cbSize;
|
||||
a = 0; WriteFile(fh, &t, 4, &a, 0);
|
||||
a = 0; WriteFile(fh, &m_convert_wfx.wfx, t, &a, 0);
|
||||
|
||||
FileAlign(fh);
|
||||
|
||||
DWORD fact_ofs = 0;
|
||||
if (m_convert_wfx.wfx.wFormatTag != WAVE_FORMAT_PCM)
|
||||
{
|
||||
t = rev32('fact');
|
||||
a = 0; WriteFile(fh, &t, 4, &a, 0);
|
||||
t = 4;
|
||||
a = 0; WriteFile(fh, &t, 4, &a, 0);
|
||||
fact_ofs = FileTell(fh);
|
||||
SetFilePointer(fh, 4, 0, FILE_CURRENT);
|
||||
}
|
||||
|
||||
t = rev32('data');
|
||||
WriteFile(fh, &t, 4, &a, 0);
|
||||
DWORD data_ofs = FileTell(fh);
|
||||
|
||||
{
|
||||
DWORD t, bw = 0;
|
||||
SetFilePointer(fh, 4, 0, FILE_BEGIN);
|
||||
t = GetFileSize(fh, 0) - 8;
|
||||
WriteFile(fh, &t, 4, &bw, 0);
|
||||
DWORD data_size = GetFileSize(fh, 0) - (data_ofs + 4);
|
||||
SetFilePointer(fh, data_ofs, 0, FILE_BEGIN);
|
||||
bw = 0; WriteFile(fh, &data_size, 4, &bw, 0);
|
||||
if (fact_ofs)
|
||||
{
|
||||
SetFilePointer(fh, fact_ofs, 0, FILE_BEGIN);
|
||||
t = m_nsam / ((m_bps >> 3) * m_nch);
|
||||
WriteFile(fh, &t, 4, &bw, 0);
|
||||
}
|
||||
}
|
||||
|
||||
CloseHandle(fh);
|
||||
}
|
||||
|
||||
int ACMEncoder::GetLastError() { return m_error; }
|
47
Src/Plugins/Encoder/enc_wav/ACMEncoder.h
Normal file
47
Src/Plugins/Encoder/enc_wav/ACMEncoder.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
#ifndef NULLSOFT_ENC_ACM_ACMENCODER_H
|
||||
#define NULLSOFT_ENC_ACM_ACMENCODER_H
|
||||
|
||||
#include <windows.h>
|
||||
#include <mmreg.h>
|
||||
#include <msacm.h>
|
||||
#include "../nsv/enc_if.h"
|
||||
#include "Config.h"
|
||||
#include "Finisher.h"
|
||||
|
||||
class ACMEncoder : public AudioCommon
|
||||
{
|
||||
public:
|
||||
ACMEncoder(int srate, int nch, int bps, ACMConfig *config);
|
||||
virtual ~ACMEncoder();
|
||||
|
||||
virtual int Encode(int framepos, void *in, int in_avail, int *in_used, void *out, int out_avail);
|
||||
void FinishAudio(const wchar_t *filename);
|
||||
|
||||
int GetLastError();
|
||||
|
||||
int m_did_header;
|
||||
int m_nch, m_srate, m_bps;
|
||||
int m_bytes_done;
|
||||
int m_error;
|
||||
int m_hlen;
|
||||
int m_nsam;
|
||||
|
||||
EXT_WFX m_convert_wfx;
|
||||
|
||||
WAVEFORMATEX m_wfx_src;
|
||||
HACMSTREAM hStream, hStreamResample;
|
||||
|
||||
ACMSTREAMHEADER ahd, ahdResample;
|
||||
|
||||
unsigned char *m_acm_buf, *m_acm_outbuf;
|
||||
int m_bytes_inbuf, m_bytes_outbuf;
|
||||
unsigned char *m_acm_resample_buf, *m_acm_resample_outbuf;
|
||||
int m_bytes_inbuf_resample, m_bytes_outbuf_resample;
|
||||
|
||||
bool do_header;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
110
Src/Plugins/Encoder/enc_wav/Config.cpp
Normal file
110
Src/Plugins/Encoder/enc_wav/Config.cpp
Normal file
|
@ -0,0 +1,110 @@
|
|||
#include <windows.h>
|
||||
#include <mmreg.h>
|
||||
#include <msacm.h>
|
||||
#include "Config.h"
|
||||
#include "resource.h"
|
||||
#include <strsafe.h>
|
||||
|
||||
static void ACM_gettext(HWND hwndDlg, char* tx)
|
||||
{
|
||||
ConfigWnd *wc = (ConfigWnd *)GetWindowLongPtr(hwndDlg,GWLP_USERDATA);
|
||||
ACMFORMATTAGDETAILSA aftd;
|
||||
ZeroMemory(&aftd, sizeof(aftd));
|
||||
aftd.cbStruct = sizeof(aftd);
|
||||
aftd.dwFormatTag = wc->cfg.convert_wfx.wfx.wFormatTag;
|
||||
if (!acmFormatTagDetailsA(0, &aftd, ACM_FORMATTAGDETAILSF_FORMATTAG))
|
||||
{
|
||||
char* p = aftd.szFormatTag;
|
||||
while (p && *p) *(tx++) = *(p++);
|
||||
*(tx++) = 13;
|
||||
*(tx++) = 10;
|
||||
}
|
||||
ACMFORMATDETAILSA afd;
|
||||
ZeroMemory(&afd, sizeof(afd));
|
||||
afd.cbStruct = sizeof(afd);
|
||||
afd.dwFormatTag = wc->cfg.convert_wfx.wfx.wFormatTag;
|
||||
afd.pwfx = &wc->cfg.convert_wfx.wfx;
|
||||
afd.cbwfx = sizeof(wc->cfg.convert_wfx);
|
||||
if (!acmFormatDetailsA(0, &afd, ACM_FORMATDETAILSF_FORMAT))
|
||||
{
|
||||
char* p = afd.szFormat;
|
||||
while (p && *p) *(tx++) = *(p++);
|
||||
}
|
||||
*tx = 0;
|
||||
}
|
||||
|
||||
static void ACM_choose(HWND hwndDlg, bool pcm)
|
||||
{
|
||||
ConfigWnd *wc = (ConfigWnd *)GetWindowLongPtr(hwndDlg,GWLP_USERDATA);
|
||||
ACMFORMATCHOOSE afc;
|
||||
memset(&afc, 0, sizeof(afc));
|
||||
afc.cbStruct = sizeof(afc);
|
||||
afc.fdwStyle = ACMFORMATCHOOSE_STYLEF_INITTOWFXSTRUCT;
|
||||
afc.pwfx = &wc->cfg.convert_wfx.wfx;
|
||||
afc.cbwfx = sizeof(wc->cfg.convert_wfx);
|
||||
|
||||
afc.hwndOwner = hwndDlg;
|
||||
|
||||
if (!acmFormatChoose(&afc))
|
||||
{
|
||||
{
|
||||
char tmp[512];
|
||||
StringCchPrintfA(tmp, 512,"%s\x0d\x0a%s", afc.szFormatTag, afc.szFormat);
|
||||
SetDlgItemTextA(hwndDlg, IDC_FORMAT_DESCRIPTION, tmp);
|
||||
|
||||
StringCchPrintfA(tmp, 512,"%d", wc->cfg.convert_wfx.wfx.cbSize);
|
||||
WritePrivateProfileStringA("enc_wav","fmtsize", tmp, wc->configfile);
|
||||
WritePrivateProfileStructA("enc_wav", "fmt", &wc->cfg.convert_wfx, sizeof(wc->cfg.convert_wfx.wfx) + wc->cfg.convert_wfx.wfx.cbSize, wc->configfile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
INT_PTR WINAPI DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
ConfigWnd *wc = (ConfigWnd *)GetWindowLongPtr(hwndDlg,GWLP_USERDATA);
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
if (!lParam) // this should NEVER happen
|
||||
return 0;
|
||||
|
||||
SetWindowLongPtr(hwndDlg,GWLP_USERDATA,(LONG)lParam);
|
||||
wc=(ConfigWnd*)lParam;
|
||||
|
||||
char tmp[256];
|
||||
ACM_gettext(hwndDlg, tmp);
|
||||
SetDlgItemTextA(hwndDlg, IDC_FORMAT_DESCRIPTION, tmp);
|
||||
CheckDlgButton(hwndDlg, IDC_HEADER, wc->cfg.header);
|
||||
CheckDlgButton(hwndDlg, IDC_DO_CONVERT, wc->cfg.convert);
|
||||
SetDlgItemTextA(hwndDlg, IDC_EXTENSION, wc->cfg.wav_ext);
|
||||
SendDlgItemMessage(hwndDlg, IDC_EXTENSION, EM_SETLIMITTEXT, 4, 0);
|
||||
}
|
||||
break;
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDC_CHOOSE_FORMAT:
|
||||
ACM_choose(hwndDlg, 0);
|
||||
break;
|
||||
case IDC_HEADER:
|
||||
wc->cfg.header = !!IsDlgButtonChecked(hwndDlg, IDC_HEADER);
|
||||
WritePrivateProfileStringA("enc_wav", "header", wc->cfg.header?"1":"0", wc->configfile);
|
||||
break;
|
||||
case IDC_DO_CONVERT:
|
||||
wc->cfg.convert = !!IsDlgButtonChecked(hwndDlg, IDC_DO_CONVERT);
|
||||
WritePrivateProfileStringA("enc_wav", "convert", wc->cfg.convert?"1":"0", wc->configfile);
|
||||
break;
|
||||
case IDC_EXTENSION:
|
||||
if (HIWORD(wParam) == EN_CHANGE)
|
||||
{
|
||||
GetDlgItemTextA(hwndDlg, IDC_EXTENSION, wc->cfg.wav_ext, sizeof(wc->cfg.wav_ext));
|
||||
WritePrivateProfileStringA("enc_wav", "ext", wc->cfg.wav_ext, wc->configfile);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
31
Src/Plugins/Encoder/enc_wav/Config.h
Normal file
31
Src/Plugins/Encoder/enc_wav/Config.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
#ifndef NULLSOFT_ENC_ACM_CONFIG_H
|
||||
#define NULLSOFT_ENC_ACM_CONFIG_H
|
||||
|
||||
#include <windows.h>
|
||||
#include <mmreg.h>
|
||||
#include <msacm.h>
|
||||
|
||||
#define WFSIZ 0x800
|
||||
struct EXT_WFX
|
||||
{
|
||||
WAVEFORMATEX wfx;
|
||||
BYTE crap[WFSIZ];
|
||||
};
|
||||
|
||||
struct ACMConfig
|
||||
{
|
||||
EXT_WFX convert_wfx;
|
||||
char wav_ext[32];
|
||||
bool header;
|
||||
bool convert;
|
||||
};
|
||||
|
||||
struct ConfigWnd
|
||||
{
|
||||
ACMConfig cfg;
|
||||
char *configfile;
|
||||
};
|
||||
|
||||
INT_PTR WINAPI DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
#endif
|
10
Src/Plugins/Encoder/enc_wav/Finisher.h
Normal file
10
Src/Plugins/Encoder/enc_wav/Finisher.h
Normal file
|
@ -0,0 +1,10 @@
|
|||
#ifndef NULLSOFT_ENC_WAV_FINISHER_H
|
||||
#define NULLSOFT_ENC_WAV_FINISHER_H
|
||||
|
||||
class AudioCommon : public AudioCoder
|
||||
{
|
||||
public:
|
||||
virtual void FinishAudio(const wchar_t *filename)=0;
|
||||
};
|
||||
|
||||
#endif
|
72
Src/Plugins/Encoder/enc_wav/WAVEncoder.cpp
Normal file
72
Src/Plugins/Encoder/enc_wav/WAVEncoder.cpp
Normal file
|
@ -0,0 +1,72 @@
|
|||
#include "WAVEncoder.h"
|
||||
|
||||
#define rev32(X) ((((DWORD)(X)&0xFF)<<24)|(((DWORD)(X)&0xFF00)<<8)|(((DWORD)(X)&0xFF0000)>>8)|(((DWORD)(X)&0xFF000000)>>24))
|
||||
|
||||
WAVEncoder::WAVEncoder(int nch, int srate, int bps, ACMConfig *config)
|
||||
{
|
||||
numBytes = 0;
|
||||
|
||||
inputFormat.wFormatTag = WAVE_FORMAT_PCM;
|
||||
inputFormat.nChannels = nch;
|
||||
inputFormat.nSamplesPerSec = srate;
|
||||
inputFormat.nAvgBytesPerSec = srate * nch * (bps >> 3);
|
||||
inputFormat.nBlockAlign = nch * (bps >> 3);
|
||||
inputFormat.wBitsPerSample = bps;
|
||||
inputFormat.cbSize = 0;
|
||||
|
||||
do_header = config->header;
|
||||
if (do_header)
|
||||
first = 44;
|
||||
}
|
||||
|
||||
int WAVEncoder::Encode(int framepos, void *in, int in_avail, int *in_used, void *out, int out_avail)
|
||||
{
|
||||
if (first)
|
||||
{
|
||||
int valid = min(first, out_avail);
|
||||
first -= valid;
|
||||
*in_used = 0;
|
||||
return valid;
|
||||
}
|
||||
|
||||
int valid = min(in_avail, out_avail);
|
||||
|
||||
memcpy(out, in, valid);
|
||||
*in_used = valid;
|
||||
numBytes += valid;
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
void WAVEncoder::PrepareToFinish()
|
||||
{}
|
||||
|
||||
void WAVEncoder::FinishAudio(const wchar_t *filename)
|
||||
{
|
||||
if (!do_header) return;
|
||||
// open old file
|
||||
HANDLE tempfile = CreateFileW(filename, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);
|
||||
|
||||
if (tempfile)
|
||||
{
|
||||
// rewrite initial 44 bytes
|
||||
DWORD bw = 0;
|
||||
unsigned __int32 t;
|
||||
t = rev32('RIFF');
|
||||
WriteFile(tempfile, &t, 4, &bw, 0); // RIFF (4 bytes)
|
||||
t = (unsigned __int32)numBytes + 36;
|
||||
bw = 0;WriteFile(tempfile, &t, 4, &bw, 0); // size of chunk (4 bytes)
|
||||
t = rev32('WAVE');
|
||||
bw = 0;WriteFile(tempfile, &t, 4, &bw, 0); // WAVE (4 bytes)
|
||||
t = rev32('fmt ');
|
||||
bw = 0;WriteFile(tempfile, &t, 4, &bw, 0);// fmt (4 bytes)
|
||||
t = 16;
|
||||
bw = 0;WriteFile(tempfile, &t, 4, &bw, 0);// size of chunk (4 bytes)
|
||||
bw = 0;WriteFile(tempfile, &inputFormat, 16, &bw, 0); // write WAVEFORMAT out (16 bytes)
|
||||
t = rev32('data');
|
||||
bw = 0;WriteFile(tempfile, &t, 4, &bw, 0);// data (4 bytes)
|
||||
bw = 0;WriteFile(tempfile, &numBytes, 4, &bw, 0);// size of chunk (4 bytes)
|
||||
|
||||
CloseHandle(tempfile);
|
||||
}
|
||||
}
|
25
Src/Plugins/Encoder/enc_wav/WAVEncoder.h
Normal file
25
Src/Plugins/Encoder/enc_wav/WAVEncoder.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
#ifndef NULLSOFT_ENC_WAV_WAVENCODER_H
|
||||
#define NULLSOFT_ENC_WAV_WAVENCODER_H
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
#include <mmreg.h>
|
||||
#include <msacm.h>
|
||||
#include "../nsv/enc_if.h"
|
||||
#include "Config.h"
|
||||
#include "Finisher.h"
|
||||
class WAVEncoder : public AudioCommon
|
||||
{
|
||||
public:
|
||||
WAVEncoder(int nch, int srate, int bps, ACMConfig *config);
|
||||
int Encode(int framepos, void *in, int in_avail, int *in_used, void *out, int out_avail); //returns bytes in out
|
||||
void FinishAudio(const wchar_t *filename);
|
||||
void PrepareToFinish();
|
||||
|
||||
WAVEFORMATEX inputFormat;
|
||||
size_t numBytes;
|
||||
int first;
|
||||
bool do_header;
|
||||
};
|
||||
|
||||
#endif
|
111
Src/Plugins/Encoder/enc_wav/enc_wav.rc
Normal file
111
Src/Plugins/Encoder/enc_wav/enc_wav.rc
Normal file
|
@ -0,0 +1,111 @@
|
|||
// 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_CONFIG DIALOGEX 0, 0, 256, 105
|
||||
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_SYSMENU
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
CONTROL "Write RIFF Header (otherwise write RAW data)",IDC_HEADER,
|
||||
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,13,248,10
|
||||
CONTROL "Convert to format:",IDC_DO_CONVERT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,26,77,10
|
||||
PUSHBUTTON "Choose Format",IDC_CHOOSE_FORMAT,7,40,63,14
|
||||
EDITTEXT IDC_FORMAT_DESCRIPTION,7,59,240,22,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY
|
||||
LTEXT "Extension:",IDC_STATIC,8,86,35,13,SS_CENTERIMAGE
|
||||
EDITTEXT IDC_EXTENSION,48,86,40,13,ES_AUTOHSCROLL
|
||||
GROUPBOX "Wav Encoder Options",IDC_STATIC,0,0,256,105
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.K.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
65535 "{34DF1A2D-7EAD-41ab-B1A7-9AFA6DE2AFF1}"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_ENC_WAV_DESC "WAV Encoder %s"
|
||||
END
|
||||
|
||||
#endif // English (U.K.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
#include "version.rc2"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
30
Src/Plugins/Encoder/enc_wav/enc_wav.sln
Normal file
30
Src/Plugins/Encoder/enc_wav/enc_wav.sln
Normal file
|
@ -0,0 +1,30 @@
|
|||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.29519.181
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "enc_wav", "enc_wav.vcxproj", "{7B43D768-8CD3-4929-B91E-DEB97F121656}"
|
||||
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
|
||||
{7B43D768-8CD3-4929-B91E-DEB97F121656}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{7B43D768-8CD3-4929-B91E-DEB97F121656}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{7B43D768-8CD3-4929-B91E-DEB97F121656}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{7B43D768-8CD3-4929-B91E-DEB97F121656}.Debug|x64.Build.0 = Debug|x64
|
||||
{7B43D768-8CD3-4929-B91E-DEB97F121656}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{7B43D768-8CD3-4929-B91E-DEB97F121656}.Release|Win32.Build.0 = Release|Win32
|
||||
{7B43D768-8CD3-4929-B91E-DEB97F121656}.Release|x64.ActiveCfg = Release|x64
|
||||
{7B43D768-8CD3-4929-B91E-DEB97F121656}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {ECC95181-336A-4B52-8743-F687749093EA}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
252
Src/Plugins/Encoder/enc_wav/enc_wav.vcxproj
Normal file
252
Src/Plugins/Encoder/enc_wav/enc_wav.vcxproj
Normal file
|
@ -0,0 +1,252 @@
|
|||
<?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>{7B43D768-8CD3-4929-B91E-DEB97F121656}</ProjectGuid>
|
||||
<RootNamespace>enc_wav</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)'=='Release|x64'" 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>
|
||||
<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>
|
||||
</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>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Vcpkg">
|
||||
<VcpkgEnabled>false</VcpkgEnabled>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<VcpkgConfiguration>Debug</VcpkgConfiguration>
|
||||
<VcpkgTriplet>
|
||||
</VcpkgTriplet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<VcpkgTriplet>
|
||||
</VcpkgTriplet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<VcpkgConfiguration>Debug</VcpkgConfiguration>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>.;..\..\..\Wasabi;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;ENC_WAV_EXPORTS;%(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>
|
||||
<Link>
|
||||
<AdditionalDependencies>msacm32.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>$(IntDir)$(TargetName).pdb</ProgramDatabaseFile>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
|
||||
<AdditionalLibraryDirectories>%(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\ </Command>
|
||||
<Message>Post build event: 'xcopy /Y /D $(OutDir)$(TargetName)$(TargetExt) ..\..\..\..\Build\Winamp_$(PlatformShortName)_$(Configuration)\Plugins\'</Message>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>.;..\..\..\Wasabi;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN64;_DEBUG;_WINDOWS;_USRDLL;ENC_WAV_EXPORTS;%(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>
|
||||
<Link>
|
||||
<AdditionalDependencies>msacm32.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>$(IntDir)$(TargetName).pdb</ProgramDatabaseFile>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
|
||||
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
|
||||
<AdditionalLibraryDirectories>%(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\ </Command>
|
||||
<Message>Post build event: 'xcopy /Y /D $(OutDir)$(TargetName)$(TargetExt) ..\..\..\..\Build\Winamp_$(PlatformShortName)_$(Configuration)\Plugins\'</Message>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>MinSpace</Optimization>
|
||||
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
|
||||
<AdditionalIncludeDirectories>.;..\..\..\Wasabi;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;ENC_WAV_EXPORTS;%(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>
|
||||
<Link>
|
||||
<AdditionalDependencies>msacm32.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>$(IntDir)$(TargetName).pdb</ProgramDatabaseFile>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
|
||||
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>xcopy /Y /D $(OutDir)$(TargetName)$(TargetExt) ..\..\..\..\Build\Winamp_$(PlatformShortName)_$(Configuration)\Plugins\ </Command>
|
||||
<Message>Post build event: 'xcopy /Y /D $(OutDir)$(TargetName)$(TargetExt) ..\..\..\..\Build\Winamp_$(PlatformShortName)_$(Configuration)\Plugins\'</Message>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<Optimization>MinSpace</Optimization>
|
||||
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
|
||||
<AdditionalIncludeDirectories>.;..\..\..\Wasabi;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN64;NDEBUG;_WINDOWS;_USRDLL;ENC_WAV_EXPORTS;%(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>
|
||||
<Link>
|
||||
<AdditionalDependencies>msacm32.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>$(IntDir)$(TargetName).pdb</ProgramDatabaseFile>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
|
||||
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
|
||||
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>xcopy /Y /D $(OutDir)$(TargetName)$(TargetExt) ..\..\..\..\Build\Winamp_$(PlatformShortName)_$(Configuration)\Plugins\ </Command>
|
||||
<Message>Post build event: 'xcopy /Y /D $(OutDir)$(TargetName)$(TargetExt) ..\..\..\..\Build\Winamp_$(PlatformShortName)_$(Configuration)\Plugins\'</Message>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="ACMEncoder.cpp" />
|
||||
<ClCompile Include="Config.cpp" />
|
||||
<ClCompile Include="main.cpp" />
|
||||
<ClCompile Include="WAVEncoder.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="ACMEncoder.h" />
|
||||
<ClInclude Include="Config.h" />
|
||||
<ClInclude Include="Finisher.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include="WAVEncoder.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="enc_wav.rc" />
|
||||
</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>
|
50
Src/Plugins/Encoder/enc_wav/enc_wav.vcxproj.filters
Normal file
50
Src/Plugins/Encoder/enc_wav/enc_wav.vcxproj.filters
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClCompile Include="ACMEncoder.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Config.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="WAVEncoder.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="ACMEncoder.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Config.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Finisher.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="resource.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="WAVEncoder.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{ee875982-d629-49cc-a8ae-2ba63dc64a78}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Ressource Files">
|
||||
<UniqueIdentifier>{2e191036-3949-43a0-9fce-044245ce82aa}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{df114c96-e301-4277-8849-778ec6cf693a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="enc_wav.rc">
|
||||
<Filter>Ressource Files</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
176
Src/Plugins/Encoder/enc_wav/main.cpp
Normal file
176
Src/Plugins/Encoder/enc_wav/main.cpp
Normal file
|
@ -0,0 +1,176 @@
|
|||
#define ENC_VERSION "v1.02a"
|
||||
|
||||
#include "Config.h"
|
||||
#include "resource.h"
|
||||
#include "../nsv/enc_if.h"
|
||||
#include "ACMEncoder.h"
|
||||
#include "WAVEncoder.h"
|
||||
#include "../nu/AutoWideFn.h"
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// wasabi based services for localisation support
|
||||
#include <api/service/waServiceFactory.h>
|
||||
#include "../Agave/Language/api_language.h"
|
||||
#include "../winamp/wa_ipc.h"
|
||||
|
||||
#include <strsafe.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;
|
||||
|
||||
static const WAVEFORMATEX wfx_default =
|
||||
{
|
||||
WAVE_FORMAT_PCM,
|
||||
2,
|
||||
44100,
|
||||
44100 * 4,
|
||||
4,
|
||||
16,
|
||||
0
|
||||
};
|
||||
|
||||
static void ReadConfig(ACMConfig *config, char *INI_FILE)
|
||||
{
|
||||
int l = GetPrivateProfileIntA("enc_wav", "fmtsize", 0, INI_FILE);
|
||||
|
||||
EXT_WFX convert_wfx_temp;
|
||||
if (GetPrivateProfileStructA("enc_wav", "fmt", &convert_wfx_temp, sizeof(WAVEFORMATEX) + l, INI_FILE))
|
||||
memcpy(&config->convert_wfx, &convert_wfx_temp, sizeof(config->convert_wfx));
|
||||
else
|
||||
config->convert_wfx.wfx = wfx_default;
|
||||
|
||||
GetPrivateProfileStringA("enc_wav", "ext", "WAV", config->wav_ext, sizeof(config->wav_ext), INI_FILE);
|
||||
config->header = !!GetPrivateProfileIntA("enc_wav", "header", 1, INI_FILE);
|
||||
config->convert = !!GetPrivateProfileIntA("enc_wav", "convert", 0, INI_FILE);
|
||||
}
|
||||
|
||||
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(),EncWavLangGUID);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C"
|
||||
{
|
||||
AudioCoder __declspec(dllexport) *CreateAudio3(int nch, int srate, int bps, unsigned int srct, unsigned int *outt, char *configfile)
|
||||
{
|
||||
if (srct == mmioFOURCC('P','C','M',' '))
|
||||
{
|
||||
if (*outt == mmioFOURCC('A','C','M',' '))
|
||||
{
|
||||
ACMConfig config;
|
||||
ReadConfig(&config, configfile);
|
||||
if (config.convert)
|
||||
{
|
||||
ACMEncoder *encoder = new ACMEncoder(srate, nch, bps, &config);
|
||||
if (encoder->GetLastError())
|
||||
{
|
||||
delete encoder;
|
||||
encoder=0;
|
||||
}
|
||||
return encoder;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new WAVEncoder(nch, srate, bps, &config);
|
||||
}
|
||||
}
|
||||
else if (*outt == mmioFOURCC('W','A','V',' '))
|
||||
{
|
||||
ACMConfig config;
|
||||
ReadConfig(&config, configfile);
|
||||
return new WAVEncoder(nch, srate, bps, &config);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned int __declspec(dllexport) GetAudioTypes3(int idx, char *desc)
|
||||
{
|
||||
switch(idx)
|
||||
{
|
||||
case 0:
|
||||
GetLocalisationApiService();
|
||||
StringCchPrintfA(desc, 1024, WASABI_API_LNGSTRING(IDS_ENC_WAV_DESC), ENC_VERSION);
|
||||
return mmioFOURCC('A','C','M',' ');
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
HWND __declspec(dllexport) ConfigAudio3(HWND hwndParent, HINSTANCE hinst, unsigned int outt, char *configfile)
|
||||
{
|
||||
if (outt == mmioFOURCC('A', 'C','M',' '))
|
||||
{
|
||||
ConfigWnd configwnd;
|
||||
ReadConfig(&configwnd.cfg, configfile);
|
||||
configwnd.configfile = configfile;
|
||||
GetLocalisationApiService();
|
||||
return WASABI_API_CREATEDIALOGPARAMW(IDD_CONFIG, hwndParent, DlgProc, (LPARAM)&configwnd);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void __declspec(dllexport) FinishAudio3(const char *filename, AudioCoder *coder)
|
||||
{
|
||||
((AudioCommon*)coder)->FinishAudio(AutoWideFn(filename));
|
||||
}
|
||||
|
||||
void __declspec(dllexport) FinishAudio3W(const wchar_t *filename, AudioCoder *coder)
|
||||
{
|
||||
((AudioCommon*)coder)->FinishAudio(filename);
|
||||
}
|
||||
|
||||
int __declspec(dllexport) GetConfigItem(unsigned int outt, char *item, char *data, int len, char *configfile)
|
||||
{
|
||||
if (outt==mmioFOURCC('A','C','M',' '))
|
||||
{
|
||||
ACMConfig config;
|
||||
ReadConfig(&config, configfile);
|
||||
if (!_stricmp(item, "extension"))
|
||||
{
|
||||
lstrcpynA(data, config.wav_ext, len);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void __declspec(dllexport) SetWinampHWND(HWND hwnd)
|
||||
{
|
||||
winampwnd = hwnd;
|
||||
}
|
||||
};
|
1
Src/Plugins/Encoder/enc_wav/preferences.cpp
Normal file
1
Src/Plugins/Encoder/enc_wav/preferences.cpp
Normal file
|
@ -0,0 +1 @@
|
|||
// TODO: acmFormatChoose
|
23
Src/Plugins/Encoder/enc_wav/resource.h
Normal file
23
Src/Plugins/Encoder/enc_wav/resource.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by enc_acm.rc
|
||||
//
|
||||
#define IDD_CONFIG 101
|
||||
#define IDS_ENC_WAV_DESC 104
|
||||
#define IDC_FORMAT_DESCRIPTION 1001
|
||||
#define IDC_CHOOSE_FORMAT 1002
|
||||
#define IDC_EXTENSION 1003
|
||||
#define IDC_HEADER 1004
|
||||
#define IDC_CHECK1 1005
|
||||
#define IDC_DO_CONVERT 1005
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 105
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1006
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
39
Src/Plugins/Encoder/enc_wav/version.rc2
Normal file
39
Src/Plugins/Encoder/enc_wav/version.rc2
Normal file
|
@ -0,0 +1,39 @@
|
|||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
#include "../../../Winamp/buildType.h"
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,2,1
|
||||
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,0,2,1"
|
||||
VALUE "InternalName", "Nullsoft WAV Encoder"
|
||||
VALUE "LegalCopyright", "Copyright © 2006-2023 Winamp SA"
|
||||
VALUE "LegalTrademarks", "Nullsoft and Winamp are trademarks of Winamp SA"
|
||||
VALUE "OriginalFilename", "enc_wav.dll"
|
||||
VALUE "ProductName", "Winamp"
|
||||
VALUE "ProductVersion", STR_WINAMP_PRODUCTVER
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
Loading…
Add table
Add a link
Reference in a new issue