Initial community commit

This commit is contained in:
Jef 2024-09-24 14:54:57 +02:00
parent 537bcbc862
commit fc06254474
16440 changed files with 4239995 additions and 2 deletions

View file

@ -0,0 +1,256 @@
//=========================================================================
//
// THIS SOFTWARE HAS BEEN LICENSED FROM MICROSOFT CORPORATION PURSUANT
// TO THE TERMS OF AN END USER LICENSE AGREEMENT ("EULA").
// PLEASE REFER TO THE TEXT OF THE EULA TO DETERMINE THE RIGHTS TO USE THE SOFTWARE.
//
// Copyright (C) Microsoft Corporation, 1996 - 1998 All Rights Reserved.
//
//=========================================================================
///////////////////////////////////////////////////////////////////////////
//
// ASFErr.h - definition of ASF HRESULT codes
//
// Copyright (C) Microsoft Corporation, 1997 - 1998
//
// This file is generated by the MC tool from ASFErr.mc
//
#ifndef _ASFERR_H
#define _ASFERR_H
#define STATUS_SEVERITY(hr) (((hr) >> 30) & 0x3)
///////////////////////////////////////////////////////////////////////////
//
// Advanced Streaming Format (ASF) Errors (2000 - 2999)
//
//
// Values are 32 bit values layed out as follows:
//
// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
// +---+-+-+-----------------------+-------------------------------+
// |Sev|C|R| Facility | Code |
// +---+-+-+-----------------------+-------------------------------+
//
// where
//
// Sev - is the severity code
//
// 00 - Success
// 01 - Informational
// 10 - Warning
// 11 - Error
//
// C - is the Customer code flag
//
// R - is a reserved bit
//
// Facility - is the facility code
//
// Code - is the facility's status code
//
//
// Define the facility codes
//
#define FACILITY_NS 0xD
//
// Define the severity codes
//
#define STATUS_SEVERITY_WARNING 0x2
#define STATUS_SEVERITY_SUCCESS 0x0
#define STATUS_SEVERITY_INFORMATIONAL 0x1
#define STATUS_SEVERITY_ERROR 0x3
//
// MessageId: ASF_E_BUFFEROVERRUN
//
// MessageText:
//
// An attempt was made to seek or position past the end of a buffer.%0
//
#define ASF_E_BUFFEROVERRUN 0xC00D07D0L
//
// MessageId: ASF_E_BUFFERTOOSMALL
//
// MessageText:
//
// The supplied input or output buffer was too small.%0
//
#define ASF_E_BUFFERTOOSMALL 0xC00D07D1L
//
// MessageId: ASF_E_BADLANGUAGEID
//
// MessageText:
//
// The language ID was not found.%0
//
#define ASF_E_BADLANGUAGEID 0xC00D07D2L
//
// MessageId: ASF_E_NOPAYLOADLENGTH
//
// MessageText:
//
// The multiple payload packet is missing the payload length.%0
//
#define ASF_E_NOPAYLOADLENGTH 0xC00D07DBL
//
// MessageId: ASF_E_TOOMANYPAYLOADS
//
// MessageText:
//
// The packet contains too many payloads.%0
//
#define ASF_E_TOOMANYPAYLOADS 0xC00D07DCL
//
// MessageId: ASF_E_PACKETCONTENTTOOLARGE
//
// MessageText:
//
// ASF_E_PACKETCONTENTTOOLARGE
//
#define ASF_E_PACKETCONTENTTOOLARGE 0xC00D07DEL
//
// MessageId: ASF_E_UNKNOWNPACKETSIZE
//
// MessageText:
//
// Expecting a fixed packet size but min. and max. are not equal.%0
//
#define ASF_E_UNKNOWNPACKETSIZE 0xC00D07E0L
//
// MessageId: ASF_E_INVALIDHEADER
//
// MessageText:
//
// ASF_E_INVALIDHEADER
//
#define ASF_E_INVALIDHEADER 0xC00D07E2L
//
// MessageId: ASF_E_NOCLOCKOBJECT
//
// MessageText:
//
// The object does not have a valid clock object.%0
//
#define ASF_E_NOCLOCKOBJECT 0xC00D07E6L
//
// MessageId: ASF_E_UNKNOWNCLOCKTYPE
//
// MessageText:
//
// ASF_E_UNKNOWNCLOCKTYPE
//
#define ASF_E_UNKNOWNCLOCKTYPE 0xC00D07EBL
//
// MessageId: ASF_E_OPAQUEPACKET
//
// MessageText:
//
// An attempt was made to restore or access an opaque packet.%0
//
#define ASF_E_OPAQUEPACKET 0xC00D07EDL
//
// MessageId: ASF_E_WRONGVERSION
//
// MessageText:
//
// ASF_E_WRONGVERSION
//
#define ASF_E_WRONGVERSION 0xC00D07EEL
//
// MessageId: ASF_E_OVERFLOW
//
// MessageText:
//
// An attempt was made to store a value which was larger than then destination's maximum value.%0
//
#define ASF_E_OVERFLOW 0xC00D07EFL
//
// MessageId: ASF_E_NOTFOUND
//
// MessageText:
//
// The object was not found.%0
//
#define ASF_E_NOTFOUND 0xC00D07F0L
//
// MessageId: ASF_E_OBJECTTOOBIG
//
// MessageText:
//
// The object is too large to be processed in the requested manner.%0
//
#define ASF_E_OBJECTTOOBIG 0xC00D07F1L
//
// MessageId: ASF_E_UNEXPECTEDVALUE
//
// MessageText:
//
// A value was not set as expected.%0
//
#define ASF_E_UNEXPECTEDVALUE 0xC00D07F2L
//
// MessageId: ASF_E_INVALIDSTATE
//
// MessageText:
//
// The request is not valid in the object's current state.%0
//
#define ASF_E_INVALIDSTATE 0xC00D07F3L
//
// MessageId: ASF_E_NOLIBRARY
//
// MessageText:
//
// This object does not have a valid library pointer; it has not been Init()'ed or it has been Shutdown().%0
//
#define ASF_E_NOLIBRARY 0xC00D07F4L
///////////////////////////////////////////////////////////////////////////
//
// Advanced Streaming Format (ASF) Success Codes (2000 - 2999)
//
//
// MessageId: ASF_S_OPAQUEPACKET
//
// MessageText:
//
// ASF_S_OPAQUEPACKET
//
#define ASF_S_OPAQUEPACKET 0x000D07F0L
///////////////////////////////////////////////////////////////////////////
//
// Advanced Streaming Format (ASF) Warnings (2000 - 2999)
//
#endif // _ASFERR_H

View file

@ -0,0 +1,468 @@
#include <windows.h>
#include <mmreg.h>
#include <msacm.h>
#include "../nu/ns_wc.h"
#include "resource.h"
#include "wmsdk.h" // for IWMWriterSink
#include "AudioCoderWMA.h"
#include <cassert>
#include <exception>
#include "../nu/AutoLock.h"
#include "../nu/AutoWide.h"
#include "../Winamp/strutil.h"
#include "../Agave/Language/api_language.h"
/* TODO: implement 2-pass encoding via IWMWriterPreprocess */
int config_bitrate, config_samplerate, config_nch;
// New globals for encoder query
class CustomIndexStatus : public IWMStatusCallback
{
public:
CustomIndexStatus( HANDLE _done ) : done(_done), IWMStatusCallback(), refcount(1)
{}
// IUnknown methods
public:
virtual ULONG STDMETHODCALLTYPE AddRef()
{
return ++refcount;
}
virtual ULONG STDMETHODCALLTYPE Release()
{
// If we go to zero, who cares?
return --refcount;
}
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void **ppvObject)
{
HRESULT hRetval = E_NOINTERFACE;
if (IID_IWMStatusCallback == iid)
{
*ppvObject = static_cast<IWMStatusCallback *>(this);
hRetval = S_OK;
}
else
{
*ppvObject = NULL;
}
return hRetval;
}
// IWMStatusCallback methods
public:
HRESULT STDMETHODCALLTYPE OnStatus( WMT_STATUS Status, HRESULT hr, WMT_ATTR_DATATYPE dwType, BYTE* pValue, void* pvContext )
{
switch ( Status )
{
case WMT_CLOSED:
// You may want to deal with the HRESULT value passed with the status.
// If you do, you should do it here.
// Signal the event.
SetEvent(done);
break;
}
return S_OK;
}
protected:
ULONG refcount;
HANDLE done;
};
// Our custom buffer object, used by the writer sink.
AudioCoderWMA::AudioCoderWMA(int numchannels, int samplerate, int bitspersamp, configtype *cfg, char *configfile) : AudioCoder()
{
lastByteCount=0;
writerAdvanced=0;
begin_writing = false;
error = WMA_NO_ERROR;
sink = NULL;
// Get globals from Winamp.ini config file
config_bitrate = cfg->config_bitrate;
config_samplerate = cfg->config_samplesSec;
config_nch = cfg->config_nch;
timeunits_per_byte = ( ( (10000000.0) / (double)samplerate ) / (double)numchannels ) / ( (double)bitspersamp / 8.0 );
//char t[100] = {0};
//wsprintf(t,"%d", timeunits_per_byte);
//::MessageBox(NULL, t, t, MB_OK);
input_bytecount = 0;
HRESULT hr = CreateAndConfigureWriter(numchannels, samplerate, bitspersamp, configfile);
if ( FAILED(hr) )
{
error = WMA_CANT_CREATE_WRITER;
}
}
AudioCoderWMA::~AudioCoderWMA()
{
if (writer)
{
if ( begin_writing )
{
begin_writing = false;
writer->EndWriting();
}
writer->Release();
writer = NULL;
}
if (writerAdvanced)
{
writerAdvanced->Release();
writerAdvanced=0;
}
if (sink)
{
sink->Release();
sink=0;
}
}
int AudioCoderWMA::GetLastError()
{
return error;
}
void AudioCoderWMA::PrepareToFinish()
{
// We don't want to kill the objects here, because there might still be data in the pipeline.
if (writer && begin_writing)
{
begin_writing = false;
// Tell WM that we're done giving it input data.
writer->EndWriting();
// TODO: do we have to wait for this to finish?
}
}
void AudioCoderWMA::OnFinished(const wchar_t *wfname)
{
//
// Okay, here we need to go back and index the file we just wrote so it's seekable.
//
// From: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmform/htm/toconfiguretheindexer.asp
// And: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmform/htm/toindexanasffile.asp
IWMIndexer* pBaseIndexer = NULL;
IWMIndexer2* pMyIndexer = NULL;
// Create an indexer.
WMCreateIndexer(&pBaseIndexer);
// Retrieve an IWMIndexer2 interface pointer for the indexer just created.
pBaseIndexer->QueryInterface(IID_IWMIndexer2, (void **) & pMyIndexer);
// Release the base indexer.
pBaseIndexer->Release();
pBaseIndexer = NULL;
// Configure the indexer to create a timecode-based index.
pMyIndexer->Configure(0, // Stream Number, use all.
WMT_IT_PRESENTATION_TIME, // Indexer type.
NULL, // Index interval, use default.
NULL); // Index type, use default.
// Create an event for asynchronous calls.
HANDLE done = CreateEvent(NULL, TRUE, FALSE, NULL);
// Give that to the status object
CustomIndexStatus status( done );
// Start the indexer.
pMyIndexer->StartIndexing(tempFilename, &status, NULL);
// Wait for the indexer to finish.
WaitForSingleObject(done, INFINITE);
// Release the remaining interface.
pMyIndexer->Release();
pMyIndexer = NULL;
// Cleanup
CloseHandle( done );
DeleteFileW(wfname);
MoveFileW(tempFilename, wfname);
}
int AudioCoderWMA::Encode(int framepos, void *in, int in_avail, int *in_used, void *out, int out_avail)
{
HRESULT hr = S_OK;
int retval = 0; // number of bytes written into "out"
*in_used = 0; // number of bytes read from "in"
if ( !framepos && !in_avail )
{
int x = 0;
x++;
}
assert(writer);
// Hopefully, at the end of the stream, we still get called with "Encode" until we return 0?
if (in_avail)
{
// Allocate an INSSBuffer of the proper size to hold all the data.
INSSBuffer* pSample = NULL;
if (FAILED(writer->AllocateSample(in_avail, &pSample))) return -1;
// Get its internal memory buffer
DWORD newBufferLength;
pSample->GetLength(&newBufferLength);
assert(newBufferLength == in_avail);
BYTE *pdwBuffer = NULL;
if (FAILED(pSample->GetBuffer(&pdwBuffer))) return -1;
memcpy(pdwBuffer, in, in_avail); // Send all the available bytes in the input buffer into the IWMWriter,
pSample->SetLength(in_avail); // Tell the buffer object how much we used
QWORD timeunits = (QWORD)( (double)input_bytecount * timeunits_per_byte ); // Compute the current timecode
// And stuff it into the writer
hr = writer->WriteSample(0, timeunits, 0, pSample);
if (FAILED(hr))
{
}
else
{
// Increment the bytecount to be able to calculate the next timecode
input_bytecount += in_avail;
// And tell the host we used up all the available input data.
*in_used = in_avail;
}
// Release immediately
pSample->Release();
}
WM_WRITER_STATISTICS stats;
writerAdvanced->GetStatistics(0, &stats);
retval = (int)(stats.qwByteCount - lastByteCount);
retval = min(retval, out_avail);
lastByteCount+=retval;
memset(out, 0, retval); // so we don't write random memory to disk
return retval;
}
HRESULT AudioCoderWMA::SelectAndLoadResampler(int numchannels, int samplerate, int bitspersamp)
{
DWORD inCount = 0;
BOOL success = false;
//wsprintf(junk,"IN Chan=%d, SRate=%d, BPS=%d", numchannels, samplerate,bitspersamp);
//MessageBox(NULL, junk, "INPUT FMT", MB_OK);
// First get the number of input streams
HRESULT hr = writer->GetInputCount(&inCount);
if(!FAILED(hr)){
//wsprintf(junk, "Input Count = %d", inCount);
//MessageBox(NULL, junk, "DEBUG", MB_OK);
// Now get the number of input formats we can resample for
DWORD fmtCount = 0;
hr = writer->GetInputFormatCount(0, &fmtCount);
if(!FAILED(hr)){
//wsprintf(junk, "Format Count = %d", fmtCount);
//MessageBox(NULL, junk, "DEBUG", MB_OK);
// Now cycle through and find the one that matches our input fmt
for(size_t i = 0;i < fmtCount;i++){
IWMInputMediaProps* pProps = NULL;
hr = writer->GetInputFormat(0, (DWORD)i, &pProps);
if(!FAILED(hr)){
DWORD cbSize = 0;
// Get the size of the media type structure.
pProps->GetMediaType(NULL, &cbSize);
// Allocate memory for the media type structure.
WM_MEDIA_TYPE* pType = (WM_MEDIA_TYPE*) new BYTE[cbSize];
if(pType != NULL){
WAVEFORMATEX* pwave = NULL;
// Get the media type structure.
hr = pProps->GetMediaType(pType, &cbSize);
// Check that the format data is present.
if (pType->cbFormat >= sizeof(WAVEFORMATEX)){
pwave = (WAVEFORMATEX*)pType->pbFormat;
//wsprintf(junk, "Cnannels = %d, SPerSec = %d, AvgBPS = %d, BPS = %d BALIGN = %d",
// pwave->nChannels,
// pwave->nSamplesPerSec,
// pwave->nAvgBytesPerSec,
// pwave->wBitsPerSample,
// pwave->nBlockAlign);
//MessageBox(NULL, junk, "DEBUG", MB_OK);
}
else{
break;
}
// Try to match the channels/samplerate/and bits/samp
if((pwave->nChannels == numchannels) && (pwave->nSamplesPerSec == samplerate) && (pwave->wBitsPerSample == bitspersamp)){
writer->SetInputProps(0, pProps);
success = true;
break;
}
}
}
}
}
}
if(success != 1){
wchar_t junk[FILETITLE_SIZE] = {0};
wsprintfW(junk,WASABI_API_LNGSTRINGW(IDS_CANNOT_FIND_INPUT_FORMATTER),
numchannels, samplerate,bitspersamp);
MessageBoxW(NULL, junk, WASABI_API_LNGSTRINGW(IDS_WARNING), MB_OK);
}
if (success)
return S_OK;
else if (FAILED(hr)) // if we have an error code, return it
return hr;
else
return E_FAIL;
}
HRESULT AudioCoderWMA::CreateAndConfigureWriter(WORD numchannels, WORD samplerate, WORD bitspersamp, char *configfile)
{
// First, create the writer.
HRESULT hr = WMCreateWriter( NULL, &writer );
if ( !FAILED(hr) )
{
// Create and Configure a stream profile with the given wave limits.
WAVEFORMATEX WaveLimits =
{
WAVE_FORMAT_PCM,
numchannels,
samplerate,
samplerate * numchannels * bitspersamp / (DWORD)8,
numchannels * bitspersamp / (DWORD)8,
bitspersamp,
0
};
IWMProfile* pProfile = NULL;
hr = CreateAndConfigureProfile(&WaveLimits, &pProfile, configfile);
if ( !FAILED(hr) )
{
// Set the profile into the writer
hr = writer->SetProfile( pProfile );
if ( !FAILED(hr) )
{
// Go get the input resampler and load it to the profile
hr = SelectAndLoadResampler(numchannels, samplerate, bitspersamp);
if (!FAILED(hr))
{
wchar_t tempPath[MAX_PATH] = {0};
GetTempPathW(MAX_PATH,tempPath);
GetTempFileNameW(tempPath, L"wma", 0, tempFilename);
// Make the custom data sink object
WMCreateWriterFileSink(&sink);
//sink = new CustomWMWriterSink;
if ( sink )
{
sink->Open(tempFilename);
HRESULT hr;
// From MSDN: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmform/htm/addingsinkstothewriter.asp
IWMWriterSink* pSinkBase = NULL;
hr = writer->QueryInterface( IID_IWMWriterAdvanced, (void **) & writerAdvanced );
if ( !FAILED(hr) )
{
hr = sink->QueryInterface( IID_IWMWriterSink, (void**) & pSinkBase );
if ( !FAILED(hr) )
{
// Stuff the custom data sink into the writer.
hr = writerAdvanced->AddSink(pSinkBase);
if ( !FAILED(hr) )
{
// And let the writer initialize itself for output.
hr = writer->BeginWriting();
if ( !FAILED(hr) )
{
begin_writing = true;
}
}
else
{
error = WMA_CANT_ADD_SINK;
}
}
else
{
error = WMA_CANT_QUERY_SINK_INTERFACE;
}
}
else
{
error = WMA_CANT_QUERY_WRITER_INTERFACE;
}
}
else
{
error = WMA_CANT_MAKE_CUSTOM_SINK;
}
}
}
}
}
return hr;
}
HRESULT AudioCoderWMA::CreateAndConfigureProfile(WAVEFORMATEX* pWaveLimits, IWMProfile** ppProfile, char *configfile)
{
IWMProfileManager* pProfileMgr = NULL;
// Instantiate a profile manager object.
HRESULT hr = WMCreateProfileManager(&pProfileMgr);
if ( !FAILED(hr) )
{
/* SAVE
// Create the empty profile.
//hr = pProfileMgr->CreateEmptyProfile(WMT_VER_9_0, ppProfile);
if ( !FAILED(hr) ){
IWMCodecInfo3 *codecInfo = NULL;
hr = pProfileMgr->QueryInterface(&codecInfo);
if(!FAILED(hr)){
// Find the proper IWMStreamConfig that matches the WAVEFORMATEX data.
IWMStreamConfig* pStreamConfig = NULL;
//hr = FindAudioFormat(WMMEDIASUBTYPE_WMAudioV2, pProfileMgr, pWaveLimits, config_bitrate * 1000, FALSE, &pStreamConfig);
hr = codecInfo->GetCodecFormat(WMMEDIATYPE_Audio, config_encOffset, config_formatOffset, &pStreamConfig);
if ( !FAILED(hr) ){
// Config the stream.
// hr = pStreamConfig->SetBitrate( config_bitrate );
hr = pStreamConfig->SetConnectionName( L"enc_wma" );
hr = pStreamConfig->SetStreamName( L"enc_wma" );
hr = pStreamConfig->SetStreamNumber( 1 );
// Stuff it into the profile
hr = (*ppProfile)->AddStream( pStreamConfig );
}
}
}
*/
if ( !FAILED(hr) ){
// Load the .prx file into the writer
if(configfile == NULL){
hr = E_FAIL;
}
else{
wchar_t cstring[4000] = {0};
GetPrivateProfileStructW(L"audio_wma", L"profile", cstring, sizeof(cstring)/sizeof(*cstring), AutoWide(configfile));
hr = pProfileMgr->LoadProfileByData(cstring, ppProfile);
if(hr != S_OK){
hr = E_FAIL;
}
}
}
pProfileMgr->Release();
}
return hr;
}

View file

@ -0,0 +1,50 @@
#ifndef AUDIOCODERWMA_H
#define AUDIOCODERWMA_H
#include "../nsv/enc_if.h"
#include "main.h"
class CustomWMWriterSink;
class AudioCoderWMA : public AudioCoder
{
public:
AudioCoderWMA(int nch, int srate, int bps, configtype *cfg, char *configfile);
virtual int Encode(int framepos, void *in, int in_avail, int *in_used, void *out, int out_avail); //returns bytes in out
virtual ~AudioCoderWMA();
int GetLastError();
void PrepareToFinish();
void OnFinished(const wchar_t *filename);
HRESULT SelectAndLoadResampler(int numchannels, int samplerate, int bitpersamp);
HRESULT CreateAndConfigureWriter(WORD nch, WORD srate, WORD bps, char *configfile);
HRESULT CreateAndConfigureProfile(WAVEFORMATEX* pWaveLimits, IWMProfile** ppProfile, char *configfile);
private:
bool begin_writing;
int error;
IWMWriterFileSink *sink;
IWMWriter *writer;
IWMWriterAdvanced *writerAdvanced;
double timeunits_per_byte; // "100 nanosecond units" -- ie: ( ( (10000000.0) / (double)samplerate ) / (double)numchannels ) / ( (double)bitspersamp/ 8.0 )
int input_bytecount;
QWORD lastByteCount;
wchar_t tempFilename[MAX_PATH];
};
enum AudioCoderWMAErrors
{
WMA_NO_ERROR = 0,
WMA_CANT_FIND_WMSDK = -1,
WMA_CANT_LOAD_CREATOR = -2,
WMA_CANT_CREATE_WRITER = -3,
WMA_CANT_SET_INPUT_FORMAT = -4,
WMA_CANT_SET_OUTPUT_FORMAT = -5,
WMA_CANT_MAKE_CUSTOM_SINK = -6,
WMA_CANT_QUERY_WRITER_INTERFACE = -7,
WMA_CANT_QUERY_SINK_INTERFACE = -8,
WMA_CANT_ADD_SINK = -9,
};
#endif//AUDIOCODERWMA_H

View file

@ -0,0 +1,648 @@
#include <windows.h>
// LGIVEN Mods 4-10-05
#include "main.h"
#include <wmsdk.h>
#include "../nu/AutoWide.h"
#include "../nu/ns_wc.h"
#include "../Agave/Language/api_language.h"
#include <MMSystem.h>
#include <assert.h>
#define MAX_PASSES 1 // limited to 1pass encoding until we work out some code for 2pass encoding
// LGIVEN Mods 4-10-05
void readconfig(char *configfile, configtype *cfg)
{
cfg->config_bitrate = 0;
cfg->config_bitsSample = 0;
cfg->config_nch = 0;
cfg->config_samplesSec = 0;
cfg->config_encoder = 0;
cfg->config_vbr = 0;
cfg->config_passes = 1;
if (configfile)
{
GetPrivateProfileStructA("audio_wma", "conf", cfg, sizeof(configtype), configfile);
}
}
void writeconfig(char *configfile, configtype *cfg)
{
if (configfile)
{
WritePrivateProfileStructA("audio_wma", "conf", cfg, sizeof(configtype), configfile);
}
}
// New global table for channels,samplerates and bitrates
static EncoderType* encs = NULL; // Pointer to the TABLE with all config data
// Globals store current selections from Config Dialog
// Number of encoders
static int encNumbs = 0; // Total number of encoders installed WMA
// New routine to read all config info from WMA encoder and load tables
static BOOL loadWMATables()
{
IWMProfileManager *profileManager;
IWMProfileManager2 *profileManager2;
IWMCodecInfo3 *codecInfo;
WAVEFORMATEX *pwave;
HRESULT hr;
int legalFormats = 0;
WMCreateProfileManager(&profileManager);
profileManager->QueryInterface(&profileManager2);
profileManager2->SetSystemProfileVersion(WMT_VER_9_0);
profileManager->QueryInterface(&codecInfo);
// Get the number of AUDIO Codecs
DWORD numCodecs = 0;
codecInfo->GetCodecInfoCount(WMMEDIATYPE_Audio, &numCodecs);
// If there are no encoders, just return
if (numCodecs == 0)
{
return false;
}
// Allocate structs for codecs and zero them all
encs = (EncoderType *) calloc(numCodecs * 4, sizeof(struct EncoderType));
if (encs != NULL)
{
encNumbs = numCodecs * 4;
}
else
{
wchar_t titleStr[32] = {0};
MessageBoxW(NULL, WASABI_API_LNGSTRINGW(IDS_CANNOT_ALLOCATE_MEM),
WASABI_API_LNGSTRINGW_BUF(IDS_WMA_ENCODER_ERROR,titleStr,32), MB_OK);
return false;
}
// Now cycle through the codecs
EncoderType* encp = encs;
for (BOOL isVBR = 0;isVBR != 2;isVBR++)
for (DWORD numPasses = 1;numPasses <= MAX_PASSES;numPasses++)
for (DWORD i = 0;i != numCodecs;i++)
{
wchar_t codecName[5000] = {0};
DWORD codecNameSize = 5000;
codecInfo->SetCodecEnumerationSetting(WMMEDIATYPE_Audio, i, g_wszVBREnabled, WMT_TYPE_BOOL, (BYTE *)&isVBR, sizeof(BOOL));
codecInfo->SetCodecEnumerationSetting(WMMEDIATYPE_Audio, i, g_wszNumPasses, WMT_TYPE_DWORD, (BYTE *)&numPasses, sizeof(DWORD));
codecInfo->GetCodecName(WMMEDIATYPE_Audio, i, codecName, &codecNameSize);
// Get the number of formats for this codec
DWORD formatCount = 0;
hr = codecInfo->GetCodecFormatCount( WMMEDIATYPE_Audio, i, &formatCount );
if (FAILED(hr))
{
continue;
}
else if (formatCount == 0)
{
continue;
}
else
{
// Fill the EncoderType struct and allocate structs for format info
// First allocate the space for all the formatType structs
encp->formats = (formatType *) malloc(formatCount * sizeof(struct formatType));
if (encp->formats == NULL)
{
wchar_t titleStr[32] = {0};
MessageBoxW(NULL, WASABI_API_LNGSTRINGW(IDS_CANNOT_ALLOCATE_MEM),
WASABI_API_LNGSTRINGW_BUF(IDS_WMA_ENCODER_ERROR,titleStr,32), MB_OK);
return false;
}
// Now fill the EncoderType struct with name and info
encp->encoderName = _wcsdup(codecName);
encp->numFormats = formatCount;
encp->offset = i;
encp->vbr = isVBR;
encp->numPasses = numPasses;
}
// Now cycle through the formats for this codec
legalFormats = 0;
formatType *fmts = encp->formats;
for (DWORD f = 0;f != formatCount;f++)
{
wchar_t fDesc[5000] = {0};
DWORD size = 5000;
// Get the config info for this encoding format in string format
IWMStreamConfig *streamConfig;
codecInfo->GetCodecFormatDesc(WMMEDIATYPE_Audio, i, f, &streamConfig, fDesc, &size);
// Now get the config info
IWMMediaProps *props;
streamConfig->QueryInterface(&props);
// Get the bitrate
//DWORD bitRate;
//streamConfig->GetBitrate(&bitRate);
// Get the Media Encoder type
DWORD mediaTypeSize;
props->GetMediaType(0, &mediaTypeSize);
WM_MEDIA_TYPE *mediaType = (WM_MEDIA_TYPE *)new char[mediaTypeSize];
props->GetMediaType(mediaType, &mediaTypeSize);
// Go get the WAVEFORMATEX Struct from the
if (mediaType->cbFormat >= sizeof(WAVEFORMATEX))
{
pwave = (WAVEFORMATEX*)mediaType->pbFormat;
if (pwave != NULL)
{
// Check to see if this is an A/V codec format
// If so, do not save it
/*
if ((pwave->nAvgBytesPerSec / pwave->nBlockAlign) ==
((pwave->nAvgBytesPerSec >= 3995) ? 5 : 3))
{
delete(mediaType);
props->Release();
streamConfig->Release();
continue;
}*/
// old way of checking
if ((wcsstr(fDesc, L"A/V")) != NULL)
{
delete[] (mediaType);
props->Release();
streamConfig->Release();
continue;
}
// Load the format name
fmts->formatName = _wcsdup(fDesc);
// Load all the format values and the offset
if ((pwave->nAvgBytesPerSec & 0x7FFFFF00) == 0x7FFFFF00)
{
fmts->bitrate = (pwave->nAvgBytesPerSec & 0x000000FF);
fmts->vbr = 1;
}
else
{
fmts->bitrate = (pwave->nAvgBytesPerSec * 8);
fmts->vbr = 0;
}
fmts->bitsSample = pwave->wBitsPerSample;
fmts->nChannels = pwave->nChannels;
fmts->samplesSec = pwave->nSamplesPerSec;
fmts->offset = f;
}
else
{
wchar_t titleStr[32] = {0};
MessageBoxW(NULL, WASABI_API_LNGSTRINGW(IDS_CANNOT_GET_STRUCTURE),
WASABI_API_LNGSTRINGW_BUF(IDS_WMA_ENCODER_ERROR,titleStr,32), MB_OK);
return false;
}
}
else
{
wchar_t titleStr[32] = {0};
MessageBoxW(NULL, WASABI_API_LNGSTRINGW(IDS_CANNOT_GET_ENCODER4_INFO),
WASABI_API_LNGSTRINGW_BUF(IDS_WMA_ENCODER_ERROR,titleStr,32), MB_OK);
return false;
}
// Set the media type value in the EncoderType struct on first legal format
if (f == 0)
{
encp->mediaType = mediaType->subtype;
}
// Now point to the next table block and inc the legal formats count
fmts++;
legalFormats++;
// And release the props and streams structs
delete[] (mediaType);
props->Release();
streamConfig->Release();
}
// If there are no legal formats for this codec then skip it
if (legalFormats == 0)
{
delete[] encp->encoderName;
encp->encoderName = NULL;
encp->numFormats = legalFormats;
encp->offset = 0;
}
// Else load number of legal formats and save it
else
{
encp->numFormats = legalFormats;
encp++;
}
}
return true;
}
static int FindFormatNumber(formatType *formats, int numFormats, configtype *cfg)
{
for (int i = 0;i < numFormats;i++, formats++)
{
if (formats->bitrate == cfg->config_bitrate
&& formats->bitsSample == cfg->config_bitsSample
&& formats->nChannels == cfg->config_nch
&& formats->samplesSec == cfg->config_samplesSec)
return formats->offset;
}
return 0;
}
static VOID dumpProfile(char *configfile, BOOL isVBR, DWORD numPasses, int encNumb, int fmtNumb)
{
// Create a Profile and dump it
IWMProfileManager *pmgr = NULL;
IWMProfile *prof = NULL;
IWMStreamConfig *sconf = NULL;
IWMCodecInfo3 *cinfo = NULL;
DWORD ssize;
wchar_t errorTitle[128] = {0};
WASABI_API_LNGSTRINGW_BUF(IDS_WMA_CONFIG_FILE_ERROR,errorTitle,128);
HRESULT hr = WMCreateProfileManager(&pmgr);
if (!FAILED(hr))
{
hr = pmgr->CreateEmptyProfile(WMT_VER_9_0, &prof);
if (!FAILED(hr))
{
hr = pmgr->QueryInterface(&cinfo);
if (!FAILED(hr))
{
cinfo->SetCodecEnumerationSetting(WMMEDIATYPE_Audio, encNumb, g_wszVBREnabled, WMT_TYPE_BOOL, (BYTE *)&isVBR, sizeof(BOOL));
cinfo->SetCodecEnumerationSetting(WMMEDIATYPE_Audio, encNumb, g_wszNumPasses, WMT_TYPE_DWORD, (BYTE *)&numPasses, sizeof(DWORD));
cinfo->GetCodecFormat(WMMEDIATYPE_Audio, encNumb, fmtNumb, &sconf);
sconf->SetConnectionName(L"enc_wma");
sconf->SetStreamName(L"enc_wma");
sconf->SetStreamNumber(1);
hr = prof->AddStream(sconf);
if (!FAILED(hr))
{
hr = pmgr->SaveProfile(prof, NULL, &ssize);
if (!FAILED(hr))
{
WCHAR* pstring = new WCHAR[ssize];
if (pstring != NULL)
{
hr = pmgr->SaveProfile(prof, pstring, &ssize);
if (!FAILED(hr))
{
wchar_t cstring[4000] = {0};
wcsncpy(cstring, pstring, 4000 - 1);
WritePrivateProfileStructW(L"audio_wma", L"profile", cstring, sizeof(cstring) / sizeof(*cstring), AutoWide(configfile));
}
else{ MessageBoxW(NULL, WASABI_API_LNGSTRINGW(IDS_SAVE_PROFILE_READ_ERROR), errorTitle, MB_OK); }
}
else{ MessageBoxW(NULL, WASABI_API_LNGSTRINGW(IDS_MEM_ALLOCATION_ERROR), errorTitle, MB_OK); }
}
else{ MessageBoxW(NULL, WASABI_API_LNGSTRINGW(IDS_PROFILE_SAVE_SIZE_ERROR), errorTitle, MB_OK); }
}
else{ MessageBoxW(NULL, WASABI_API_LNGSTRINGW(IDS_CANNOT_READ_AUDIO_STREAM), errorTitle, MB_OK); }
}
else{ MessageBoxW(NULL, WASABI_API_LNGSTRINGW(IDS_CANNOT_GET_CODEC_INFO), errorTitle, MB_OK); }
}
else{ MessageBoxW(NULL, WASABI_API_LNGSTRINGW(IDS_CANNOT_CREATE_A_PROFILE), errorTitle, MB_OK); }
}
else{ MessageBoxW(NULL, WASABI_API_LNGSTRINGW(IDS_CANNOT_CREATE_PROFILE_MANAGER), errorTitle, MB_OK); }
pmgr->Release();
prof->Release();
sconf->Release();
cinfo->Release();
}
static bool Has(HWND hwndDlg, int item, int data)
{
int numChoices = SendDlgItemMessage(hwndDlg, item, CB_GETCOUNT, 0, 0);
for (int i = 0;i < numChoices;i++)
{
if (SendDlgItemMessage(hwndDlg, item, CB_GETITEMDATA, i, 0) == data)
return true;
}
return false;
}
static int EncodeSampleFormat(int bps, int numChannels, int sampleRate)
{
// 20 bits sampleRate
assert((sampleRate & 0xFFFFF) == sampleRate);
// 6 bits numChannels
assert((numChannels & 0x3F) == numChannels);
// 6 bits bps
assert((bps & 0x3F) == bps);
return (sampleRate << 12) | (numChannels << 6) | (bps);
}
static void DecodeSampleFormat(int data, int &bps, int &numChannels, int &sampleRate)
{
bps = data & 0x3F;
data >>= 6;
numChannels = data & 0x3F;
data >>= 6;
sampleRate = data;
}
static int EncodeVBR(BOOL isVBR, DWORD numPasses)
{
// 1 bits VBR
assert((isVBR & 0x1) == isVBR);
// 15 bits numPasses
assert((numPasses & 0x7FFF) == numPasses);
return (isVBR << 15) | (numPasses);
}
static void DecodeVBR(int data, BOOL &isVBR, DWORD &numPasses)
{
numPasses = data & 0x7FFF;
data >>= 15;
isVBR = data & 0x1;
}
static void AutoSelect(HWND hwndDlg, int dlgItem)
{
if (SendDlgItemMessage(hwndDlg, dlgItem, CB_GETCURSEL, 0, 0) == CB_ERR)
SendDlgItemMessage(hwndDlg, dlgItem, CB_SETCURSEL, 0, 0);
}
static EncoderType *FindEncoder(int encoderNumber, BOOL isVBR, DWORD numPasses)
{
EncoderType* enc = encs;
for (int i = 0;i < encNumbs;i++, enc++)
{
if (enc->encoderName == NULL)
return 0; //WTF?
if (enc->offset == encoderNumber && enc->vbr == isVBR && enc->numPasses == numPasses)
return enc;
}
return 0; //WTF?
}
#define MASK_ENCODER 0x1
#define MASK_VBR 0x2
#define MASK_SAMPLE_FORMAT 0x4
#define MASK_BITRATE 0x8
#define MASK_ALL 0xF
static void ResetConfig(HWND hwndDlg, EncoderType *encs, configtype *cfg, int mask)
{
wchar_t buf1[100] = {0};
EncoderType* enc = encs;
if (mask & MASK_ENCODER) SendDlgItemMessage(hwndDlg, IDC_ENCODER, CB_RESETCONTENT, 0, 0);
if (mask & MASK_SAMPLE_FORMAT) SendDlgItemMessage(hwndDlg, IDC_SAMPLE_FORMAT, CB_RESETCONTENT, 0, 0);
if (mask & MASK_BITRATE) SendDlgItemMessage(hwndDlg, IDC_BRATE, CB_RESETCONTENT, 0, 0);
if (mask & MASK_VBR) SendDlgItemMessage(hwndDlg, IDC_VBR, CB_RESETCONTENT, 0, 0);
// reset encoders
int thisVBR = EncodeVBR(cfg->config_vbr, cfg->config_passes);
for (int i = 0;i < encNumbs;i++, enc++)
{
if (enc->encoderName == NULL)
break;
else if ((mask & MASK_ENCODER) && !Has(hwndDlg, IDC_ENCODER, enc->offset))
{
int newpos = SendDlgItemMessage(hwndDlg, IDC_ENCODER, CB_ADDSTRING, 0, (LPARAM)enc->encoderName);
SendDlgItemMessage(hwndDlg, IDC_ENCODER, CB_SETITEMDATA, newpos, enc->offset);
if (cfg->config_encoder == enc->offset)
{
SendDlgItemMessage(hwndDlg, IDC_ENCODER, CB_SETCURSEL, newpos, 0);
}
}
int data = EncodeVBR(enc->vbr, enc->numPasses);
if ((mask & MASK_VBR) && cfg->config_encoder == enc->offset && !Has(hwndDlg, IDC_VBR, data))
{
int newpos = CB_ERR;
if (enc->vbr == FALSE && enc->numPasses == 1)
newpos = SendDlgItemMessageW(hwndDlg, IDC_VBR, CB_ADDSTRING, 0, (LPARAM)WASABI_API_LNGSTRINGW(IDS_CBR));
else if (enc->vbr == FALSE && enc->numPasses == 2)
newpos = SendDlgItemMessageW(hwndDlg, IDC_VBR, CB_ADDSTRING, 0, (LPARAM)WASABI_API_LNGSTRINGW(IDS_2_PASS_CBR));
else if (enc->vbr == TRUE && enc->numPasses == 1)
newpos = SendDlgItemMessageW(hwndDlg, IDC_VBR, CB_ADDSTRING, 0, (LPARAM)WASABI_API_LNGSTRINGW(IDS_VBR));
else if (enc->vbr == TRUE && enc->numPasses == 2)
newpos = SendDlgItemMessageW(hwndDlg, IDC_VBR, CB_ADDSTRING, 0, (LPARAM)WASABI_API_LNGSTRINGW(IDS_ABR));
SendDlgItemMessage(hwndDlg, IDC_VBR, CB_SETITEMDATA, newpos, data);
if (thisVBR == data)
SendDlgItemMessage(hwndDlg, IDC_VBR, CB_SETCURSEL, newpos, 0);
}
}
AutoSelect(hwndDlg, IDC_ENCODER);
AutoSelect(hwndDlg, IDC_VBR);
int pos = SendDlgItemMessage(hwndDlg, IDC_VBR, CB_GETCURSEL, 0, 0);
int data = SendDlgItemMessage(hwndDlg, IDC_VBR, CB_GETITEMDATA, pos, 0);
DecodeVBR(data, cfg->config_vbr, cfg->config_passes);
pos = SendDlgItemMessage(hwndDlg, IDC_ENCODER, CB_GETCURSEL, 0, 0);
data = SendDlgItemMessage(hwndDlg, IDC_ENCODER, CB_GETITEMDATA, pos, 0);
cfg->config_encoder = data;
// Now set up for dialog fill
enc = FindEncoder(cfg->config_encoder, cfg->config_vbr, cfg->config_passes);
// Fill the current values
formatType *fmt = enc->formats;
int thisSampleFormat = EncodeSampleFormat(cfg->config_bitsSample, cfg->config_nch, cfg->config_samplesSec);
for (int i = 0;i < enc->numFormats;i++, fmt++)
{
int data = EncodeSampleFormat(fmt->bitsSample, fmt->nChannels, fmt->samplesSec);
// Add channels to list
if ((mask & MASK_SAMPLE_FORMAT) && !Has(hwndDlg, IDC_SAMPLE_FORMAT, data))
{
if (fmt->nChannels == 1)
wsprintfW(buf1, WASABI_API_LNGSTRINGW(IDS_MONO_INFO), fmt->bitsSample, fmt->samplesSec);
else if (fmt->nChannels == 2)
wsprintfW(buf1, WASABI_API_LNGSTRINGW(IDS_STEREO_INFO), fmt->bitsSample, fmt->samplesSec);
else
wsprintfW(buf1, WASABI_API_LNGSTRINGW(IDS_CHANNELS_INFO), fmt->bitsSample, fmt->nChannels, fmt->samplesSec);
int newpos;
if (fmt->bitsSample)
newpos = SendDlgItemMessageW(hwndDlg, IDC_SAMPLE_FORMAT, CB_ADDSTRING, 0, (LPARAM)buf1);
else
newpos = SendDlgItemMessageW(hwndDlg, IDC_SAMPLE_FORMAT, CB_ADDSTRING, 0, (LPARAM)buf1 + 8); // skip "0 bits, "
SendDlgItemMessage(hwndDlg, IDC_SAMPLE_FORMAT, CB_SETITEMDATA, newpos, data);
// Now set current select for number of channels sample
if (thisSampleFormat == data)
SendDlgItemMessage(hwndDlg, IDC_SAMPLE_FORMAT, CB_SETCURSEL, newpos, 0);
}
}
if (SendDlgItemMessage(hwndDlg, IDC_SAMPLE_FORMAT, CB_GETCURSEL, 0, 0) == CB_ERR)
{
int num = SendDlgItemMessage(hwndDlg, IDC_SAMPLE_FORMAT, CB_GETCOUNT, 0, 0);
int defaultSampleFormat = EncodeSampleFormat(16, 2, 44100);
for (int i = 0;i < num;i++)
{
int data = SendDlgItemMessage(hwndDlg, IDC_SAMPLE_FORMAT, CB_GETITEMDATA, i, 0);
if (data == defaultSampleFormat)
SendDlgItemMessage(hwndDlg, IDC_SAMPLE_FORMAT, CB_SETCURSEL, i, 0);
}
}
AutoSelect(hwndDlg, IDC_SAMPLE_FORMAT);
pos = SendDlgItemMessage(hwndDlg, IDC_SAMPLE_FORMAT, CB_GETCURSEL, 0, 0);
data = SendDlgItemMessage(hwndDlg, IDC_SAMPLE_FORMAT, CB_GETITEMDATA, pos, 0);
DecodeSampleFormat(data, cfg->config_bitsSample, cfg->config_nch, cfg->config_samplesSec);
thisSampleFormat = EncodeSampleFormat(cfg->config_bitsSample, cfg->config_nch, cfg->config_samplesSec);
// Next Show the Bitrates
fmt = enc->formats;
for (int i = 0;i < enc->numFormats;i++, fmt++)
{
int data = EncodeSampleFormat(fmt->bitsSample, fmt->nChannels, fmt->samplesSec);
if (thisSampleFormat == data)
{
if ((mask & MASK_BITRATE) && !Has(hwndDlg, IDC_BRATE, fmt->bitrate))
{
if (fmt->vbr)
SetDlgItemTextW(hwndDlg, IDC_STATIC_BITRATE, WASABI_API_LNGSTRINGW(IDS_QUALITY));
else
SetDlgItemTextW(hwndDlg, IDC_STATIC_BITRATE, WASABI_API_LNGSTRINGW(IDS_BITRATE));
wsprintfW(buf1, L"%d", fmt->bitrate);
int newpos = SendDlgItemMessageW(hwndDlg, IDC_BRATE, CB_ADDSTRING, 0, (LPARAM)buf1);
SendDlgItemMessage(hwndDlg, IDC_BRATE, CB_SETITEMDATA, newpos, fmt->bitrate);
// Set the current bit rate
if (cfg->config_bitrate == fmt->bitrate)
{
SendDlgItemMessage(hwndDlg, IDC_BRATE, CB_SETCURSEL, newpos, 0);
}
}
}
}
if (SendDlgItemMessage(hwndDlg, IDC_BRATE, CB_GETCURSEL, 0, 0) == CB_ERR)
{
int num = SendDlgItemMessage(hwndDlg, IDC_BRATE, CB_GETCOUNT, 0, 0);
for (int i = 0;i < num;i++)
{
int data = SendDlgItemMessage(hwndDlg, IDC_BRATE, CB_GETITEMDATA, i, 0);
if (data == 50 || (data / 1000 == 128))
SendDlgItemMessage(hwndDlg, IDC_BRATE, CB_SETCURSEL, i, 0);
}
}
AutoSelect(hwndDlg, IDC_BRATE);
pos = SendDlgItemMessage(hwndDlg, IDC_BRATE, CB_GETCURSEL, 0, 0);
data = SendDlgItemMessage(hwndDlg, IDC_BRATE, CB_GETITEMDATA, pos, 0);
cfg->config_bitrate = data;
}
BOOL CALLBACK ConfigProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
configwndrec *wc = NULL;
if (uMsg == WM_INITDIALOG)
{
// LGIVEN Mod 4-10-05
#if defined(_WIN64)
SetWindowLong(hwndDlg, GWLP_USERDATA, lParam);
#else
SetWindowLong(hwndDlg, GWL_USERDATA, lParam);
#endif
if (lParam)
{
// Get the saved params
wc = (configwndrec*)lParam;
loadWMATables();
ResetConfig(hwndDlg, encs , &wc->cfg, MASK_ALL);
}
return 1;
}
if (uMsg == WM_DESTROY)
{
#if defined(_WIN64)
wc = (configwndrec*)SetWindowLong(hwndDlg, GWLP_USERDATA, 0);
#else
wc = (configwndrec*)SetWindowLong(hwndDlg, GWL_USERDATA, 0);
#endif
if (wc)
{
EncoderType *encoder=FindEncoder(wc->cfg.config_encoder,wc->cfg.config_vbr, wc->cfg.config_passes);
int formatNumber = FindFormatNumber(encoder->formats, encoder->numFormats, &wc->cfg);
// Dump the profile in WMA format
dumpProfile(wc->configfile, wc->cfg.config_vbr, wc->cfg.config_passes, wc->cfg.config_encoder, formatNumber);
// Write it to config file
writeconfig(wc->configfile, &wc->cfg);
free(wc->configfile);
free(wc);
}
return 0;
}
if (uMsg == WM_COMMAND)
{
switch (LOWORD(wParam))
{
case IDC_VBR:
if ((HIWORD(wParam) == CBN_SELCHANGE))
{
#if defined(_WIN64)
wc = (configwndrec*)GetWindowLong(hwndDlg, GWLP_USERDATA);
#else
wc = (configwndrec*)GetWindowLong(hwndDlg, GWL_USERDATA);
#endif
int pos = SendDlgItemMessage(hwndDlg, IDC_VBR, CB_GETCURSEL, 0, 0);
int data = SendDlgItemMessage(hwndDlg, IDC_VBR, CB_GETITEMDATA, pos, 0);
DecodeVBR(data, wc->cfg.config_vbr, wc->cfg.config_passes);
ResetConfig(hwndDlg, encs, &wc->cfg, MASK_BITRATE | MASK_SAMPLE_FORMAT);
}
break;
case IDC_SAMPLE_FORMAT:
if ((HIWORD(wParam) == CBN_SELCHANGE))
{
#if defined(_WIN64)
wc = (configwndrec*)GetWindowLong(hwndDlg, GWLP_USERDATA);
#else
wc = (configwndrec*)GetWindowLong(hwndDlg, GWL_USERDATA);
#endif
int pos = SendDlgItemMessage(hwndDlg, IDC_SAMPLE_FORMAT, CB_GETCURSEL, 0, 0);
int data = SendDlgItemMessage(hwndDlg, IDC_SAMPLE_FORMAT, CB_GETITEMDATA, pos, 0);
DecodeSampleFormat(data, wc->cfg.config_bitsSample, wc->cfg.config_nch, wc->cfg.config_samplesSec);
ResetConfig(hwndDlg, encs, &wc->cfg, MASK_BITRATE);
}
break;
case IDC_BRATE:
if ((HIWORD(wParam) == CBN_SELCHANGE))
{
#if defined(_WIN64)
wc = (configwndrec*)GetWindowLong(hwndDlg, GWLP_USERDATA);
#else
wc = (configwndrec*)GetWindowLong(hwndDlg, GWL_USERDATA);
#endif
int pos = SendDlgItemMessage(hwndDlg, IDC_BRATE, CB_GETCURSEL, 0, 0);
int data = SendDlgItemMessage(hwndDlg, IDC_BRATE, CB_GETITEMDATA, pos, 0);
wc->cfg.config_bitrate = data;
}
break;
case IDC_ENCODER:
if ((HIWORD(wParam) == CBN_SELCHANGE))
{
#if defined(_WIN64)
wc = (configwndrec*)GetWindowLong(hwndDlg, GWLP_USERDATA);
#else
wc = (configwndrec*)GetWindowLong(hwndDlg, GWL_USERDATA);
#endif
if (wc)
{
int pos = SendDlgItemMessage(hwndDlg, IDC_ENCODER, CB_GETCURSEL, 0, 0);
int data = SendDlgItemMessage(hwndDlg, IDC_ENCODER, CB_GETITEMDATA, pos, 0);
wc->cfg.config_encoder = data;
ResetConfig(hwndDlg, encs, &wc->cfg, MASK_VBR | MASK_SAMPLE_FORMAT | MASK_BITRATE);
}
}
break;
}
}
return 0;
}

View file

@ -0,0 +1,128 @@
// 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
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_DIALOG1 DIALOGEX 0, 0, 256, 167
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
GROUPBOX "Windows Media Audio",IDC_STATIC,0,0,256,167
COMBOBOX IDC_ENCODER,18,13,145,148,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "Encoder Format",IDC_STATIC,166,13,60,12,SS_CENTERIMAGE
COMBOBOX IDC_SAMPLE_FORMAT,17,30,145,133,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "Sample Format",IDC_STATIC,166,30,71,12,SS_CENTERIMAGE
COMBOBOX IDC_VBR,18,48,59,67,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_BRATE,86,48,77,116,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "Bitrate (Bits/Sec)",IDC_STATIC_BITRATE,165,48,54,12,SS_CENTERIMAGE
CTEXT "Portions utilize Microsoft Windows Media Technologies.\nCopyright © 1992-2019 Microsoft Corporation. All Rights Reserved.",IDC_STATIC,14,144,227,18
END
#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
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE
BEGIN
65535 "{33BC12FD-E7F7-42ec-8FE3-2D8BD3A977C2}"
END
STRINGTABLE
BEGIN
IDS_CANNOT_FIND_INPUT_FORMATTER
"Cannot find input formatter for:\n\nChannels = %d, Sample Rate = %d, Bits/Sample = %d\n\nNo resampler available for this input format"
IDS_WARNING "WARNING"
IDS_CANNOT_ALLOCATE_MEM "Cannot allocate memory for WMA encoder format info"
IDS_WMA_ENCODER_ERROR "WMA Encoder Error"
IDS_CANNOT_GET_STRUCTURE "Cannot get structure with format details"
IDS_CANNOT_GET_ENCODER4_INFO "Cannot get detail info for Encoder4 format"
IDS_SAVE_PROFILE_READ_ERROR "Save profile read error"
IDS_MEM_ALLOCATION_ERROR "Memory allocation error"
IDS_PROFILE_SAVE_SIZE_ERROR "Profile save size get error"
IDS_CANNOT_READ_AUDIO_STREAM "Cannot create audio stream"
IDS_CANNOT_GET_CODEC_INFO "Cannot get codec interface"
IDS_CANNOT_CREATE_A_PROFILE "Cannot create a profile"
IDS_CANNOT_CREATE_PROFILE_MANAGER "Cannot create a profile manager"
IDS_WMA_CONFIG_FILE_ERROR "WMA Config File Error"
END
STRINGTABLE
BEGIN
IDS_CBR "CBR"
IDS_2_PASS_CBR "2-pass CBR"
IDS_VBR "VBR"
IDS_ABR "ABR"
IDS_MONO_INFO "%d bits, mono, %d Hz"
IDS_STEREO_INFO "%d bits, stereo, %d Hz"
IDS_CHANNELS_INFO "%d bits, %d channels, %d Hz"
IDS_QUALITY "Quality (0-100)"
IDS_BITRATE "Bitrate (Bits/Sec)"
IDS_ENC_WMA_DESC "WMA Encoder %s"
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#include "version.rc2"
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View file

@ -0,0 +1,30 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29613.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "enc_wma", "enc_wma.vcxproj", "{5F4B0989-B35B-40C0-BAA1-E7058377B398}"
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
{5F4B0989-B35B-40C0-BAA1-E7058377B398}.Debug|Win32.ActiveCfg = Debug|Win32
{5F4B0989-B35B-40C0-BAA1-E7058377B398}.Debug|Win32.Build.0 = Debug|Win32
{5F4B0989-B35B-40C0-BAA1-E7058377B398}.Debug|x64.ActiveCfg = Debug|x64
{5F4B0989-B35B-40C0-BAA1-E7058377B398}.Debug|x64.Build.0 = Debug|x64
{5F4B0989-B35B-40C0-BAA1-E7058377B398}.Release|Win32.ActiveCfg = Release|Win32
{5F4B0989-B35B-40C0-BAA1-E7058377B398}.Release|Win32.Build.0 = Release|Win32
{5F4B0989-B35B-40C0-BAA1-E7058377B398}.Release|x64.ActiveCfg = Release|x64
{5F4B0989-B35B-40C0-BAA1-E7058377B398}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {424261B8-8392-4100-A876-CD8560D5D1AC}
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,276 @@
<?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>{5F4B0989-B35B-40C0-BAA1-E7058377B398}</ProjectGuid>
<RootNamespace>enc_wma</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;NSV_CODER_WMA_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<BrowseInformation>true</BrowseInformation>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
<Link>
<AdditionalDependencies>wmvcore.lib;shlwapi.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>%(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;NSV_CODER_WMA_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<BrowseInformation>true</BrowseInformation>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>4244;4312;4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
<Link>
<AdditionalDependencies>wmvcore.lib;shlwapi.lib;%(AdditionalDependencies)</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>%(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>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<AdditionalIncludeDirectories>.;..\..\..\Wasabi;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;NSV_CODER_WMA_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<BufferSecurityCheck>true</BufferSecurityCheck>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>None</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
<Link>
<AdditionalOptions>/ignore:4210 %(AdditionalOptions)</AdditionalOptions>
<AdditionalDependencies>wmvcore.lib;shlwapi.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>%(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>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<AdditionalIncludeDirectories>.;..\..\..\Wasabi;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN64;NDEBUG;_WINDOWS;_USRDLL;NSV_CODER_WMA_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<BufferSecurityCheck>true</BufferSecurityCheck>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>None</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>4244;4312;4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
<Link>
<AdditionalOptions>/ignore:4210 %(AdditionalOptions)</AdditionalOptions>
<AdditionalDependencies>wmvcore.lib;shlwapi.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>%(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="AudioCoderWMA.cpp" />
<ClCompile Include="config.cpp" />
<ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="AudioCoderWMA.h" />
<ClInclude Include="CustomWMWriterSink.h" />
<ClInclude Include="main.h" />
<ClInclude Include="resource.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="enc_wma.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>

View file

@ -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="AudioCoderWMA.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="config.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="AudioCoderWMA.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="CustomWMWriterSink.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="main.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="Header Files">
<UniqueIdentifier>{497dbf34-c784-481d-bc15-343f4d25c508}</UniqueIdentifier>
</Filter>
<Filter Include="Ressource Files">
<UniqueIdentifier>{a60f8eac-325c-466b-8a17-69b1064e57fb}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files">
<UniqueIdentifier>{33266828-89ee-4119-b784-03c8edaad9a1}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="enc_wma.rc">
<Filter>Ressource Files</Filter>
</ResourceCompile>
</ItemGroup>
</Project>

View file

@ -0,0 +1,212 @@
/*
** 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.23"
#include <windows.h>
#include <stdio.h>
#include <wmsdk.h>
#include <mmreg.h>
#include <msacm.h>
#include "AudioCoderWMA.h"
#include "../nu/AutoWideFn.h"
// 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;
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
return TRUE;
}
int getwrittentime();
HINSTANCE g_hinst;
int g_srate, g_numchan, g_bps;
volatile int writtentime, w_offset;
// LGIVEN Mod 4-10-05
void readconfig(char *configfile, configtype *cfg);
void writeconfig(char *configfile, configtype *cfg);
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(),EncWMALangGUID);
}
}
// ==================================================================
//
// Published enc_wma methods.
//
// ==================================================================
#include <cassert>
extern "C"
{
unsigned int __declspec(dllexport) GetAudioTypes3(int idx, char *desc)
{
if ( idx == 0 )
{
GetLocalisationApiService();
StringCchPrintfA(desc, 1024, WASABI_API_LNGSTRING(IDS_ENC_WMA_DESC), ENC_VERSION);
return mmioFOURCC('W', 'M', 'A', ' ');
}
return 0;
}
AudioCoder __declspec(dllexport) *CreateAudio3(int nch, int srate, int bps, unsigned int srct, unsigned int *outt, char *configfile)
{
if (srct == mmioFOURCC('P', 'C', 'M', ' ') && *outt == mmioFOURCC('W', 'M', 'A', ' '))
{
GetLocalisationApiService();
configtype cfg;
readconfig(configfile, &cfg);
AudioCoderWMA *t = new AudioCoderWMA(nch, srate, bps, &cfg, configfile);
if ( t && t->GetLastError())
{
delete t;
return NULL;
}
else return t;
}
return NULL;
}
void __declspec(dllexport) FinishAudio3(const char *filename, AudioCoder *coder)
{
((AudioCoderWMA*)coder)->OnFinished(AutoWideFn(filename));
}
void __declspec(dllexport) FinishAudio3W(const wchar_t *filename, AudioCoder *coder)
{
((AudioCoderWMA*)coder)->OnFinished(filename);
}
void __declspec(dllexport) PrepareToFinish(const char *filename, AudioCoder *coder)
{
((AudioCoderWMA*)coder)->PrepareToFinish();
}
void __declspec(dllexport) PrepareToFinishW(const wchar_t *filename, AudioCoder *coder)
{
((AudioCoderWMA*)coder)->PrepareToFinish();
}
HWND __declspec(dllexport) ConfigAudio3(HWND hwndParent, HINSTANCE hinst, unsigned int outt, char *configfile)
{
if (outt == mmioFOURCC('W', 'M', 'A', ' '))
{
configwndrec *wr = (configwndrec*)malloc(sizeof(configwndrec));
if (configfile)
{
wr->configfile = _strdup(configfile);
}
else
{
wr->configfile = 0;
}
readconfig(configfile, &wr->cfg);
GetLocalisationApiService();
return WASABI_API_CREATEDIALOGPARAMW(IDD_DIALOG1, hwndParent, ConfigProc, (LPARAM)wr);
}
return NULL;
}
int __declspec(dllexport) SetConfigItem(unsigned int outt, char *item, char *data, char *configfile)
{
if (outt == mmioFOURCC('W', 'M', 'A', ' '))
{
configtype cfg;
readconfig(configfile, &cfg);
if (!lstrcmpiA(item, "bitrate"))
{
//cfg.config_bitrate = atoi(data) * 1000;
}
writeconfig(configfile, &cfg);
return 1;
}
return 0;
}
int __declspec(dllexport) GetConfigItem(unsigned int outt, char *item, char *data, int len, char *configfile)
{
if (outt == mmioFOURCC('W', 'M', 'A', ' '))
{
configtype cfg;
readconfig(configfile, &cfg);
if (!lstrcmpiA(item, "bitrate"))
{
StringCchPrintfA(data, len, "%d", cfg.config_bitrate / 1000);
}
return 1;
}
return 0;
}
void __declspec(dllexport) SetWinampHWND(HWND hwnd)
{
winampwnd = hwnd;
}
};

View file

@ -0,0 +1,55 @@
#include <windows.h>
#include <stdio.h>
#include "../nsv/enc_if.h"
#include "resource.h"
// LGIVEN Mods 4-25-05
// Config info saved in Winamp.ini [enc_wma]---conf=xxxxxxxxxxx
typedef struct
{
int config_nch; // Number of channels of encoder/fmt selected
int config_bitrate; // Bitrate of encoder/fmt selected
int config_bitsSample; // Bits/Sample of encoder/fmt selected
int config_samplesSec; // Sample rate of encoder/fmt selected
int config_encoder; // Encoder offset in table in Config Dialog
BOOL config_vbr; // VBR or not
DWORD config_passes; // number of passes (1 or 2)
}
configtype;
typedef struct
{
configtype cfg; // config type struct
char *configfile; // Name of config file (...\Winamp.ini)
}
configwndrec;
// Data table values in Config Dialog
// One of these for each format
struct formatType
{
wchar_t *formatName; // Format Name (for display)
int offset; // offset in WMEncoder for this Encoder
int nChannels; // number of channels
int bitsSample; // Bits per sample
int samplesSec; // Samples per sec
int bitrate; // Bitrate value
int vbr;
};
// One of these for each encoder
struct EncoderType
{
wchar_t *encoderName; // Encoder name (for display)
int offset; // Offset in WMEncoder
int numFormats; // Number of formats in WMEncoder for this encoder
struct _GUID mediaType; // Media type GUID
BOOL vbr;
DWORD numPasses;
formatType* formats;
};
BOOL CALLBACK ConfigProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,57 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by Script1.rc
//
#define IDS_CANNOT_FIND_INPUT_FORMATTER 0
#define IDS_WARNING 1
#define IDOK2 2
#define IDS_CANNOT_ALLOCATE_MEM 2
#define IDS_WMA_ENCODER_ERROR 3
#define IDS_CANNOT_GET_STRUCTURE 4
#define IDS_CANNOT_GET_ENCODER4_INFO 5
#define IDS_SAVE_PROFILE_READ_ERROR 6
#define IDS_MEM_ALLOCATION_ERROR 7
#define IDS_PROFILE_SAVE_SIZE_ERROR 8
#define IDS_CANNOT_READ_AUDIO_STREAM 9
#define IDS_CANNOT_GET_CODEC_INFO 10
#define IDS_CANNOT_CREATE_A_PROFILE 11
#define IDS_CANNOT_CREATE_PROFILE_MANAGER 12
#define IDS_WMA_CONFIG_FILE_ERROR 13
#define IDS_CBR 16
#define IDS_2_PASS_CBR 17
#define IDS_VBR 18
#define IDS_ABR 19
#define IDS_MONO_INFO 20
#define IDS_STEREO_INFO 21
#define IDS_CHANNELS_INFO 22
#define IDS_QUALITY 23
#define IDS_BITRATE 24
#define IDS_ENC_WMA_DESC 25
#define IDD_DIALOG1 101
#define IDC_DIR 1000
#define IDC_SRATE 1001
#define IDC_BRATE 1002
#define IDC_NCH 1003
#define IDC_PROFILE 1004
#define IDC_ABRATE 1005
#define IDC_CBR 1005
#define IDC_ENCODER 1006
#define IDC_BPSAMPLE 1007
#define IDC_VBR 1008
#define IDC_1PASS 1009
#define IDC_RADIO4 1010
#define IDC_2PASS 1010
#define IDC_STATIC_BITRATE 1011
#define IDC_SAMPLE_FORMAT 1012
#define IDC_COMBO1 1013
// 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 1014
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View file

@ -0,0 +1,39 @@
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
#include "../../../Winamp/buildType.h"
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,23,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,23,0,0"
VALUE "InternalName", "Nullsoft WMA Encoder"
VALUE "LegalCopyright", "Copyright © 2006-2023 Winamp SA"
VALUE "LegalTrademarks", "Nullsoft and Winamp are trademarks of Winamp SA"
VALUE "OriginalFilename", "enc_wma.dll"
VALUE "ProductName", "Winamp"
VALUE "ProductVersion", STR_WINAMP_PRODUCTVER
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END

File diff suppressed because it is too large Load diff