@@ -0,0 +1,26160 @@
+diff -uNr lame-398-2.orig/dshow/Mpegac.cpp lame-398-2/dshow/Mpegac.cpp
+--- lame-398-2.orig/dshow/Mpegac.cpp 2008-06-22 20:31:14.000000000 +0200
++++ lame-398-2/dshow/Mpegac.cpp 2009-05-11 00:06:09.000000000 +0200
+@@ -66,13 +66,60 @@
+ #define DEFAULT_VBR_QUALITY 4
+ #define DEFAULT_PES 0
+
++#define DEFAULT_FILTER_MERIT MERIT_DO_NOT_USE // Standard compressor merit value
++
++#define GET_DATARATE(kbps) (kbps * 1000 / 8)
++#define GET_FRAMELENGTH(bitrate, sample_rate) ((WORD)(((sample_rate < 32000 ? 72000 : 144000) * (bitrate))/(sample_rate)))
++#define DECLARE_PTR(type, ptr, expr) type* ptr = (type*)(expr);
++
++// Create a list of all (or mostly all) of the encoder CBR output capabilities which
++// will be parsed into a list of capabilities used by the IAMStreamConfig Interface
++output_caps_t OutputCapabilities[] =
++{ // {SampleRate, BitRate}
++ { 48000, 320 },{ 48000, 256 },{ 48000, 224 },{ 48000, 192 }, // MPEG 1.0 Spec @ 48KHz
++ { 48000, 160 },{ 48000, 128 },{ 48000, 112 },{ 48000, 96 },
++ { 48000, 80 },{ 48000, 64 },{ 48000, 56 },{ 48000, 48 },
++ { 48000, 40 },{ 48000, 32 },
++
++ { 24000, 160 },{ 24000, 144 },{ 24000, 128 },{ 24000, 112 }, // MPEG 2.0 Spec @ 24KHz
++ { 24000, 96 },{ 24000, 80 },{ 24000, 64 },{ 24000, 56 },
++ { 24000, 48 },{ 24000, 40 },{ 24000, 32 },{ 24000, 24 },
++ { 24000, 16 },{ 24000, 8 },
++
++ { 12000, 64 },{ 12000, 56 },{ 12000, 48 },{ 12000, 40 }, // MPEG 2.5 Spec @ 12KHz
++ { 12000, 32 },{ 12000, 24 },{ 12000, 16 },{ 12000, 8 },
++ // --------------------------- --------------------------
++ { 44100, 320 },{ 44100, 256 },{ 44100, 224 },{ 44100, 192 }, // MPEG 1.0 Spec @ 44.1KHz
++ { 44100, 160 },{ 44100, 128 },{ 44100, 112 },{ 44100, 96 },
++ { 44100, 80 },{ 44100, 64 },{ 44100, 56 },{ 44100, 48 },
++ { 44100, 40 },{ 44100, 32 },
++
++ { 22050, 160 },{ 22050, 144 },{ 22050, 128 },{ 22050, 112 }, // MPEG 2.0 Spec @ 22.05KHz
++ { 22050, 96 },{ 22050, 80 },{ 22050, 64 },{ 22050, 56 },
++ { 22050, 48 },{ 22050, 40 },{ 22050, 32 },{ 22050, 24 },
++ { 22050, 16 },{ 22050, 8 },
++
++ { 11025, 64 },{ 11025, 56 },{ 11025, 48 },{ 11025, 40 }, // MPEG 2.5 Spec @ 11.025KHz
++ { 11025, 32 },{ 11025, 24 },{ 11025, 16 },{ 11025, 8 },
++ // --------------------------- --------------------------
++ { 32000, 320 },{ 32000, 256 },{ 32000, 224 },{ 32000, 192 }, // MPEG 1.0 Spec @ 32KHz
++ { 32000, 160 },{ 32000, 128 },{ 32000, 112 },{ 32000, 96 },
++ { 32000, 80 },{ 32000, 64 },{ 32000, 56 },{ 32000, 48 },
++ { 32000, 40 },{ 32000, 32 },
++
++ { 16000, 160 },{ 16000, 144 },{ 16000, 128 },{ 16000, 112 }, // MPEG 2.0 Spec @ 16KHz
++ { 16000, 96 },{ 16000, 80 },{ 16000, 64 },{ 16000, 56 },
++ { 16000, 48 },{ 16000, 40 },{ 16000, 32 },{ 16000, 24 },
++ { 16000, 16 },{ 16000, 8 },
++
++ { 8000, 64 },{ 8000, 56 },{ 8000, 48 },{ 8000, 40 }, // MPEG 2.5 Spec @ 8KHz
++ { 8000, 32 },{ 8000, 24 },{ 8000, 16 },{ 8000, 8 }
++};
++
+
+ /* Registration setup stuff */
+ // Setup data
+
+-#define OUT_STREAM_TYPE MEDIATYPE_Stream
+-#define OUT_STREAM_SUBTYPE MEDIASUBTYPE_MPEG1Audio
+-//#define OUT_STREAM_SUBTYPE MEDIASUBTYPE_NULL
+
+ AMOVIESETUP_MEDIATYPE sudMpgInputType[] =
+ {
+@@ -82,7 +129,8 @@
+ {
+ { &MEDIATYPE_Audio, &MEDIASUBTYPE_MPEG1AudioPayload },
+ { &MEDIATYPE_Audio, &MEDIASUBTYPE_MPEG2_AUDIO },
+- { &OUT_STREAM_TYPE, &OUT_STREAM_SUBTYPE},
++ { &MEDIATYPE_Audio, &MEDIASUBTYPE_MP3 },
++ { &MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG1Audio }
+ };
+
+ AMOVIESETUP_PIN sudMpgPins[] =
+@@ -113,16 +161,17 @@
+ {
+ &CLSID_LAMEDShowFilter,
+ L"LAME Audio Encoder",
+- MERIT_SW_COMPRESSOR, // Don't use us for real!
+- NUMELMS(sudMpgPins), // 3 pins
++ DEFAULT_FILTER_MERIT, // Standard compressor merit value
++ NUMELMS(sudMpgPins), // 2 pins
+ sudMpgPins
+ };
+
+ /*****************************************************************************/
+ // COM Global table of objects in this dll
++static WCHAR g_wszName[] = L"LAME Audio Encoder";
+ CFactoryTemplate g_Templates[] =
+ {
+- { L"LAME Audio Encoder", &CLSID_LAMEDShowFilter, CMpegAudEnc::CreateInstance, NULL, &sudMpgAEnc },
++ { g_wszName, &CLSID_LAMEDShowFilter, CMpegAudEnc::CreateInstance, NULL, &sudMpgAEnc },
+ { L"LAME Audio Encoder Property Page", &CLSID_LAMEDShow_PropertyPage, CMpegAudEncPropertyPage::CreateInstance},
+ { L"LAME Audio Encoder Property Page", &CLSID_LAMEDShow_PropertyPageAdv, CMpegAudEncPropertyPageAdv::CreateInstance},
+ { L"LAME Audio Encoder About", &CLSID_LAMEDShow_About, CMAEAbout::CreateInstance}
+@@ -130,24 +179,114 @@
+ // Count of objects listed in g_cTemplates
+ int g_cTemplates = sizeof(g_Templates) / sizeof(g_Templates[0]);
+
++
++
++////////////////////////////////////////////
++// Declare the DirectShow filter information.
++
++// Used by IFilterMapper2() in the call to DllRegisterServer()
++// to register the filter in the CLSID_AudioCompressorCategory.
++REGFILTER2 rf2FilterReg = {
++ 1, // Version number.
++ DEFAULT_FILTER_MERIT, // Merit. This should match the merit specified in the AMOVIESETUP_FILTER definition
++ NUMELMS(sudMpgPins), // Number of pins.
++ sudMpgPins // Pointer to pin information.
++};
++
++STDAPI DllRegisterServer(void)
++{
++ HRESULT hr = AMovieDllRegisterServer2(TRUE);
++ if (FAILED(hr)) {
++ return hr;
++ }
++
++ IFilterMapper2 *pFM2 = NULL;
++ hr = CoCreateInstance(CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER, IID_IFilterMapper2, (void **)&pFM2);
++ if (SUCCEEDED(hr)) {
++ hr = pFM2->RegisterFilter(
++ CLSID_LAMEDShowFilter, // Filter CLSID.
++ g_wszName, // Filter name.
++ NULL, // Device moniker.
++ &CLSID_AudioCompressorCategory, // Audio compressor category.
++ g_wszName, // Instance data.
++ &rf2FilterReg // Filter information.
++ );
++ pFM2->Release();
++ }
++ return hr;
++}
++
++STDAPI DllUnregisterServer()
++{
++ HRESULT hr = AMovieDllRegisterServer2(FALSE);
++ if (FAILED(hr)) {
++ return hr;
++ }
++
++ IFilterMapper2 *pFM2 = NULL;
++ hr = CoCreateInstance(CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER, IID_IFilterMapper2, (void **)&pFM2);
++ if (SUCCEEDED(hr)) {
++ hr = pFM2->UnregisterFilter(&CLSID_AudioCompressorCategory, g_wszName, CLSID_LAMEDShowFilter);
++ pFM2->Release();
++ }
++ return hr;
++}
++
++
++
+ CUnknown *CMpegAudEnc::CreateInstance(LPUNKNOWN lpunk, HRESULT *phr)
+ {
+- CUnknown *punk = new CMpegAudEnc(lpunk, phr);
++ CMpegAudEnc *punk = new CMpegAudEnc(lpunk, phr);
+ if (punk == NULL)
+ *phr = E_OUTOFMEMORY;
+ return punk;
+ }
+
+ CMpegAudEnc::CMpegAudEnc(LPUNKNOWN lpunk, HRESULT *phr)
+- : CTransformFilter(NAME("LAME Audio Encoder"), lpunk,
+- CLSID_LAMEDShowFilter),
++ : CTransformFilter(NAME("LAME Audio Encoder"), lpunk, CLSID_LAMEDShowFilter),
+ CPersistStream(lpunk, phr)
+ {
++ // ENCODER OUTPUT PIN
++ // Override the output pin with our own which will implement the IAMStreamConfig Interface
++ CTransformOutputPin *pOut = new CMpegAudEncOutPin( this, phr );
++ if (pOut == NULL) {
++ *phr = E_OUTOFMEMORY;
++ return;
++ }
++ else if (FAILED(*phr)) { // A failed return code should delete the object
++ delete pOut;
++ return;
++ }
++ m_pOutput = pOut;
++
++ // ENCODER INPUT PIN
++ // Since we've created our own output pin we must also create
++ // the input pin ourselves because the CTransformFilter base class
++ // will create an extra output pin if the input pin wasn't created.
++ CTransformInputPin *pIn = new CTransformInputPin(NAME("LameEncoderInputPin"),
++ this, // Owner filter
++ phr, // Result code
++ L"Input"); // Pin name
++
++ if (pIn == NULL) {
++ *phr = E_OUTOFMEMORY;
++ return;
++ }
++ else if (FAILED(*phr)) { // A failed return code should delete the object
|