Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

removed internal liblame as all ports using external libs.

  • Loading branch information...
commit 70abd01469c69e7ca9eec98ccaa51b01491ebfe1 1 parent 982ad3b
wsoltys authored
Showing with 0 additions and 93,718 deletions.
  1. +0 −1,405 lib/liblame/ACM/ACM.cpp
  2. +0 −101 lib/liblame/ACM/ACM.h
  3. +0 −397 lib/liblame/ACM/ACMStream.cpp
  4. +0 −85 lib/liblame/ACM/ACMStream.h
  5. +0 −181 lib/liblame/ACM/ADbg/ADbg.cpp
  6. +0 −102 lib/liblame/ACM/ADbg/ADbg.dsp
  7. +0 −133 lib/liblame/ACM/ADbg/ADbg.h
  8. +0 −465 lib/liblame/ACM/ADbg/ADbg_vc7.vcproj
  9. +0 −10 lib/liblame/ACM/ADbg/Makefile.am
  10. +0 −361 lib/liblame/ACM/ADbg/Makefile.in
  11. +0 −2,027 lib/liblame/ACM/AEncodeProperties.cpp
  12. +0 −448 lib/liblame/ACM/AEncodeProperties.h
  13. +0 −242 lib/liblame/ACM/DecodeStream.cpp
  14. +0 −83 lib/liblame/ACM/DecodeStream.h
  15. +0 −91 lib/liblame/ACM/LameACM.inf
  16. +0 −28 lib/liblame/ACM/Makefile.am
  17. +0 −537 lib/liblame/ACM/Makefile.in
  18. +0 −9 lib/liblame/ACM/TODO
  19. +0 −219 lib/liblame/ACM/acm.rc
  20. +0 −39 lib/liblame/ACM/adebug.h
  21. +0 −6 lib/liblame/ACM/ddk/Makefile.am
  22. +0 −358 lib/liblame/ACM/ddk/Makefile.in
  23. +0 −185 lib/liblame/ACM/ddk/msacmdrv.h
  24. BIN  lib/liblame/ACM/lame.ico
  25. +0 −25 lib/liblame/ACM/lameACM.def
  26. +0 −187 lib/liblame/ACM/lameACM_vc6.dsp
  27. +0 −1,197 lib/liblame/ACM/lameACM_vc7.vcproj
  28. +0 −13 lib/liblame/ACM/lame_acm.xml
  29. +0 −216 lib/liblame/ACM/main.cpp
  30. +0 −29 lib/liblame/ACM/readme.txt
  31. +0 −42 lib/liblame/ACM/resource.h
  32. +0 −20 lib/liblame/ACM/tinyxml/Makefile.am
  33. +0 −372 lib/liblame/ACM/tinyxml/Makefile.in
  34. +0 −150 lib/liblame/ACM/tinyxml/Makefile.tinyxml
  35. +0 −81 lib/liblame/ACM/tinyxml/changes.txt
  36. +0 −708 lib/liblame/ACM/tinyxml/dox
  37. +0 −34 lib/liblame/ACM/tinyxml/makedistlinux
  38. +0 −19 lib/liblame/ACM/tinyxml/makedistwin.bat
  39. +0 −309 lib/liblame/ACM/tinyxml/readme.txt
  40. +0 −95 lib/liblame/ACM/tinyxml/test.dsp
  41. +0 −44 lib/liblame/ACM/tinyxml/test.dsw
  42. +0 −1,007 lib/liblame/ACM/tinyxml/tinyxml.cpp
  43. +0 −115 lib/liblame/ACM/tinyxml/tinyxml.dsp
  44. +0 −804 lib/liblame/ACM/tinyxml/tinyxml.h
  45. +0 −601 lib/liblame/ACM/tinyxml/tinyxml_vc7.vcproj
  46. +0 −26 lib/liblame/ACM/tinyxml/tinyxmlerror.cpp
  47. +0 −928 lib/liblame/ACM/tinyxml/tinyxmlparser.cpp
  48. +0 −326 lib/liblame/ACM/tinyxml/xmltest.cpp
  49. +0 −107 lib/liblame/API
  50. +0 −481 lib/liblame/COPYING
  51. +0 −19,313 lib/liblame/ChangeLog
  52. +0 −45 lib/liblame/DEFINES
  53. +0 −1,021 lib/liblame/Dll/BladeMP3EncDLL.c
  54. +0 −36 lib/liblame/Dll/BladeMP3EncDLL.def
  55. +0 −280 lib/liblame/Dll/BladeMP3EncDLL.h
  56. +0 −288 lib/liblame/Dll/Example.cpp
  57. +0 −90 lib/liblame/Dll/Example_vc6.dsp
  58. +0 −74 lib/liblame/Dll/Example_vc6.dsw
  59. +0 −742 lib/liblame/Dll/LameDLLInterface.htm
  60. +0 −118 lib/liblame/Dll/LameDll_vc6.dsp
  61. +0 −510 lib/liblame/Dll/LameDll_vc8.vcproj
  62. +0 −303 lib/liblame/Dll/MP3export.pas
  63. +0 −15 lib/liblame/Dll/Makefile.am
  64. +0 −367 lib/liblame/Dll/Makefile.in
  65. +0 −39 lib/liblame/Dll/Makefile.mingw32
  66. +0 −21 lib/liblame/Dll/README
  67. +0 −124 lib/liblame/HACKING
  68. +0 −210 lib/liblame/INSTALL
  69. +0 −183 lib/liblame/INSTALL.configure
  70. +0 −13 lib/liblame/LICENSE
  71. +0 −674 lib/liblame/Makefile.MSVC
  72. +0 −67 lib/liblame/Makefile.am
  73. +0 −7 lib/liblame/Makefile.am.global
  74. +0 −724 lib/liblame/Makefile.in
  75. +0 −624 lib/liblame/Makefile.unix
  76. +0 −43 lib/liblame/README
  77. +0 −67 lib/liblame/README.WINGTK
  78. +0 −187 lib/liblame/STYLEGUIDE
  79. +0 −162 lib/liblame/TODO
  80. +0 −779 lib/liblame/USAGE
  81. +0 −88 lib/liblame/acinclude.m4
  82. +0 −7,864 lib/liblame/aclocal.m4
  83. +0 −1,407 lib/liblame/config.guess
  84. +0 −342 lib/liblame/config.h.in
  85. +0 −1,504 lib/liblame/config.sub
  86. +0 −121 lib/liblame/configMS.h
  87. +0 −32,139 lib/liblame/configure
  88. +0 −1,177 lib/liblame/configure.in
  89. +0 −19 lib/liblame/debian/Makefile.am
  90. +0 −374 lib/liblame/debian/Makefile.in
  91. +0 −242 lib/liblame/debian/changelog
  92. +0 −1  lib/liblame/debian/compat
  93. +0 −51 lib/liblame/debian/control
  94. +0 −56 lib/liblame/debian/copyright
  95. +0 −1  lib/liblame/debian/lame.docs
  96. +0 −2  lib/liblame/debian/lame.files
  97. +0 −5 lib/liblame/debian/libmp3lame0-dev.docs
  98. +0 −3  lib/liblame/debian/libmp3lame0-dev.files
  99. +0 −1  lib/liblame/debian/libmp3lame0.files
  100. +0 −85 lib/liblame/debian/rules
  101. +0 −530 lib/liblame/depcomp
  102. +0 −5 lib/liblame/doc/Makefile.am
  103. +0 −515 lib/liblame/doc/Makefile.in
  104. +0 −23 lib/liblame/doc/html/Makefile.am
  105. +0 −396 lib/liblame/doc/html/Makefile.in
  106. +0 −158 lib/liblame/doc/html/basic.html
  107. +0 −173 lib/liblame/doc/html/contributors.html
  108. +0 −44 lib/liblame/doc/html/examples.html
  109. +0 −3,291 lib/liblame/doc/html/history.html
  110. +0 −269 lib/liblame/doc/html/id3.html
  111. +0 −54 lib/liblame/doc/html/index.html
  112. +0 −24 lib/liblame/doc/html/lame.css
  113. +0 −48 lib/liblame/doc/html/modes.html
  114. +0 −132 lib/liblame/doc/html/node6.html
Sorry, we could not display the entire diff because too many files (332) changed.
View
1,405 lib/liblame/ACM/ACM.cpp
@@ -1,1405 +0,0 @@
-/**
- *
- * Lame ACM wrapper, encode/decode MP3 based RIFF/AVI files in MS Windows
- *
- * Copyright (c) 2002 Steve Lhomme <steve.lhomme at free.fr>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-
-/*!
- \author Steve Lhomme
- \version \$Id: ACM.cpp,v 1.20.8.1 2008/11/01 20:41:47 robert Exp $
-*/
-
-#if !defined(STRICT)
-#define STRICT
-#endif // STRICT
-
-#include <algorithm>
-
-#include <windows.h>
-#include <windowsx.h>
-#include <intshcut.h>
-
-#include <mmreg.h>
-#include <msacm.h>
-#include <msacmdrv.h>
-
-#include <assert.h>
-
-#include <lame.h>
-
-#include "adebug.h"
-#include "resource.h"
-#include "ACMStream.h"
-
-#ifdef ENABLE_DECODING
-#include "DecodeStream.h"
-#endif // ENABLE_DECODING
-
-#include "ACM.h"
-
-#ifndef IDC_HAND
-#define IDC_HAND MAKEINTRESOURCE(32649)
-#endif // IDC_HAND
-
-char ACM::VersionString[120];
-
-const char ACM_VERSION[] = "0.9.2";
-
-#ifdef WIN32
-//
-// 32-bit versions
-//
-#if (WINVER >= 0x0400)
- #define VERSION_ACM_DRIVER MAKE_ACM_VERSION(4, 0, 0)
-#else
-#define VERSION_ACM_DRIVER MAKE_ACM_VERSION(3, 51, 0)
-#endif
-#define VERSION_MSACM MAKE_ACM_VERSION(3, 50, 0)
-
-#else
-//
-// 16-bit versions
-//
-#define VERSION_ACM_DRIVER MAKE_ACM_VERSION(1, 0, 0)
-#define VERSION_MSACM MAKE_ACM_VERSION(2, 1, 0)
-
-#endif
-
-#define PERSONAL_FORMAT WAVE_FORMAT_MPEGLAYER3
-#define SIZE_FORMAT_STRUCT sizeof(MPEGLAYER3WAVEFORMAT)
-//#define SIZE_FORMAT_STRUCT 0
-
-//static const char channel_mode[][13] = {"mono","stereo","joint stereo","dual channel"};
-static const char channel_mode[][13] = {"mono","stereo"};
-static const unsigned int mpeg1_freq[] = {48000,44100,32000};
-static const unsigned int mpeg2_freq[] = {24000,22050,16000,12000,11025,8000};
-static const unsigned int mpeg1_bitrate[] = {320, 256, 224, 192, 160, 128, 112, 96, 80, 64, 56, 48, 40, 32};
-static const unsigned int mpeg2_bitrate[] = {160, 144, 128, 112, 96, 80, 64, 56, 48, 40, 32, 24, 16, 8};
-
-#define SIZE_CHANNEL_MODE (sizeof(channel_mode) / (sizeof(char) * 13))
-#define SIZE_FREQ_MPEG1 (sizeof(mpeg1_freq) / sizeof(unsigned int))
-#define SIZE_FREQ_MPEG2 (sizeof(mpeg2_freq) / sizeof(unsigned int))
-#define SIZE_BITRATE_MPEG1 (sizeof(mpeg1_bitrate) / sizeof(unsigned int))
-#define SIZE_BITRATE_MPEG2 (sizeof(mpeg2_bitrate) / sizeof(unsigned int))
-
-static const int FORMAT_TAG_MAX_NB = 2; // PCM and PERSONAL (mandatory to have at least PCM and your format)
-static const int FILTER_TAG_MAX_NB = 0; // this is a codec, not a filter
-
-// number of supported PCM formats
-static const int FORMAT_MAX_NB_PCM =
- 2 * // number of PCM channel mode (stereo/mono)
- (SIZE_FREQ_MPEG1 + // number of MPEG 1 sampling freq
- SIZE_FREQ_MPEG2); // number of MPEG 2 sampling freq
-
-//////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////
-bool bitrate_item::operator<(const bitrate_item & other_bitrate) const
-{
- return (other_bitrate.frequency < frequency ||
- (other_bitrate.frequency == frequency &&
- (other_bitrate.bitrate < bitrate ||
- (other_bitrate.bitrate == bitrate &&
- (other_bitrate.channels < channels)))));
-}
-
-//////////////////////////////////////////////////////////////////////
-// Configuration Dialog
-//////////////////////////////////////////////////////////////////////
-/*
-static CALLBACK ConfigProc(
- HWND hwndDlg, // handle to dialog box
-UINT uMsg, // message
-WPARAM wParam, // first message parameter
-LPARAM lParam // second message parameter
-)
-{
- BOOL bResult;
-
- switch (uMsg) {
- case WM_COMMAND:
- UINT command;
- command = GET_WM_COMMAND_ID(wParam, lParam);
- if (IDOK == command)
- {
- EndDialog(hwndDlg, (IDOK == command));
- } else if (IDCANCEL == command)
- {
- EndDialog(hwndDlg, (IDOK == command));
- }
- bResult = FALSE;
- break;
- default:
- bResult = FALSE; // will be treated by DefWindowProc
-}
- return bResult;
-}
-
-
-inline DWORD ACM::Configure(HWND hParentWindow, LPDRVCONFIGINFO pConfig)
-{
- my_debug.OutPut(DEBUG_LEVEL_FUNC_START, "ACM : Configure (Parent Window = 0x%08X)",hParentWindow);
-
- DialogBoxParam( my_hModule, MAKEINTRESOURCE(IDD_CONFIG), hParentWindow, ::ConfigProc , (LPARAM)this);
-
- return DRVCNF_OK; // Can also return
- // DRVCNF_CANCEL
- // and DRVCNF_RESTART
-}
-*/
-//////////////////////////////////////////////////////////////////////
-// About Dialog
-//////////////////////////////////////////////////////////////////////
-
-static BOOL CALLBACK AboutProc(
- HWND hwndDlg, // handle to dialog box
-UINT uMsg, // message
-WPARAM wParam, // first message parameter
-LPARAM lParam // second message parameter
-)
-{
- static HBRUSH hBrushStatic = NULL;
-// static LOGFONT lf; // structure for font information
-// static HFONT hfnt;
- static HCURSOR hcOverCursor = NULL;
- BOOL bResult;
-
- switch (uMsg) {
- case WM_INITDIALOG:
- char tmp[150];
- wsprintf(tmp,"LAME MP3 codec v%s", ACM::GetVersionString());
- ::SetWindowText(GetDlgItem( hwndDlg, IDC_STATIC_ABOUT_TITLE), tmp);
-
-/*
- ::GetObject(::GetStockObject(DEFAULT_GUI_FONT), sizeof(LOGFONT), &lf);
- lf.lfUnderline = TRUE;
-
- hfnt = ::CreateFontIndirect(&lf);
-
- ::SendMessage(::GetDlgItem(hwndDlg,IDC_STATIC_ABOUT_URL), WM_SETFONT, (WPARAM) hfnt, TRUE);
-* /
- hBrushStatic = ::CreateSolidBrush(::GetSysColor (COLOR_BTNFACE));
-*/ hcOverCursor = ::LoadCursor(NULL,(LPCTSTR)IDC_HAND);
- if (hcOverCursor == NULL)
- hcOverCursor = ::LoadCursor(NULL,(LPCTSTR)IDC_CROSS);
-
- bResult = TRUE;
- break;
-/*
- case WM_CTLCOLORSTATIC:
- /// \todo only if there are URLs
- if ((HWND)lParam == ::GetDlgItem(hwndDlg,IDC_STATIC_ABOUT_URL))
- {
- ::SetTextColor((HDC)wParam, ::GetSysColor (COLOR_HIGHLIGHT));
- ::SetBkColor((HDC)wParam, ::GetSysColor (COLOR_BTNFACE));
-
- return (LRESULT) hBrushStatic;
- }
- else
- return (LRESULT) NULL;
-*/
- case WM_MOUSEMOVE:
- {
- POINT pnt;
- ::GetCursorPos(&pnt);
-
- RECT rect;
- ::GetWindowRect( ::GetDlgItem(hwndDlg,IDC_STATIC_ABOUT_URL), &rect);
-
- if ( ::PtInRect(&rect,pnt) )
- {
- ::SetCursor(hcOverCursor);
- }
-
-
- }
- break;
-
- case WM_LBUTTONUP:
- {
- POINT pnt;
- ::GetCursorPos(&pnt);
-
- RECT rect;
- ::GetWindowRect( ::GetDlgItem(hwndDlg,IDC_STATIC_ABOUT_URL), &rect);
-
- TCHAR Url[200];
- bool bUrl = false;
- if (::PtInRect(&rect,pnt))
- {
- wsprintf(Url,get_lame_url());
- bUrl = true;
- }
-
- if (bUrl)
- {
- LPSTR tmpStr;
- HRESULT hresult = ::TranslateURL(Url, TRANSLATEURL_FL_GUESS_PROTOCOL|TRANSLATEURL_FL_GUESS_PROTOCOL, &tmpStr);
- if (hresult == S_OK)
- ::ShellExecute(hwndDlg,"open",tmpStr,NULL,"",SW_SHOWMAXIMIZED );
- else if (hresult == S_FALSE)
- ::ShellExecute(hwndDlg,"open",Url,NULL,"",SW_SHOWMAXIMIZED );
- }
-
- }
- break;
-
- case WM_COMMAND:
- UINT command;
- command = GET_WM_COMMAND_ID(wParam, lParam);
- if (IDOK == command)
- {
- EndDialog(hwndDlg, TRUE);
- }
- bResult = FALSE;
- break;
-
- case IDC_STATIC_ABOUT_URL:
- break;
- default:
- bResult = FALSE; // will be treated by DefWindowProc
-}
- return bResult;
-}
-
-inline DWORD ACM::About(HWND hParentWindow)
-{
- my_debug.OutPut(DEBUG_LEVEL_FUNC_START, "ACM : About (Parent Window = 0x%08X)",hParentWindow);
-
- DialogBoxParam( my_hModule, MAKEINTRESOURCE(IDD_ABOUT), hParentWindow, ::AboutProc , (LPARAM)this);
-
- return DRVCNF_OK; // Can also return
-// DRVCNF_CANCEL
-// and DRVCNF_RESTART
-}
-
-
-//////////////////////////////////////////////////////////////////////
-// Construction/Destruction
-//////////////////////////////////////////////////////////////////////
-
-ACM::ACM( HMODULE hModule )
- :my_hModule(hModule),
- my_hIcon(NULL),
- my_debug(ADbg(DEBUG_LEVEL_CREATION)),
- my_EncodingProperties(hModule)
-{
- my_EncodingProperties.ParamsRestore();
-
- /// \todo get the debug level from the registry
- unsigned char DebugFileName[512];
-
- char tmp[128];
- wsprintf(tmp,"LAMEacm 0x%08X",this);
- my_debug.setPrefix(tmp); /// \todo get it from the registry
- my_debug.setIncludeTime(true); /// \todo get it from the registry
-
- // Check in the registry if we have to Output Debug information
- DebugFileName[0] = '\0';
-
- HKEY OssKey;
- if (RegOpenKeyEx( HKEY_LOCAL_MACHINE, "SOFTWARE\\MUKOLI", 0, KEY_READ , &OssKey ) == ERROR_SUCCESS) {
- DWORD DataType;
- DWORD DebugFileNameSize = 512;
- if (RegQueryValueEx( OssKey, "DebugFile", NULL, &DataType, DebugFileName, &DebugFileNameSize ) == ERROR_SUCCESS) {
- if (DataType == REG_SZ) {
- my_debug.setUseFile(true);
- my_debug.setDebugFile((char *)DebugFileName);
- my_debug.OutPut("Debug file is %s",(char *)DebugFileName);
- }
- }
- }
- wsprintf(VersionString,"%s - %s", ACM_VERSION, get_lame_version() );
- BuildBitrateTable();
-
- my_debug.OutPut(DEBUG_LEVEL_FUNC_START, "New ACM Creation (0x%08X)",this);
-}
-
-ACM::~ACM()
-{
-// not used, it's done automatically when closing the driver if (my_hIcon != NULL)
-// CloseHandle(my_hIcon);
-
- bitrate_table.clear();
-
- my_debug.OutPut(DEBUG_LEVEL_FUNC_START, "ACM Deleted (0x%08X)",this);
-}
-
-//////////////////////////////////////////////////////////////////////
-// Main message handler
-//////////////////////////////////////////////////////////////////////
-
-LONG ACM::DriverProcedure(const HDRVR hdrvr, const UINT msg, LONG lParam1, LONG lParam2)
-{
- DWORD dwRes = 0L;
-
-//my_debug.OutPut(DEBUG_LEVEL_MSG, "message 0x%08X for ThisACM 0x%08X", msg, this);
-
-switch (msg) {
- case DRV_INSTALL:
- my_debug.OutPut(DEBUG_LEVEL_MSG, "DRV_INSTALL");
- // Sent when the driver is installed.
- dwRes = DRVCNF_OK; // Can also return
- break; // DRVCNF_CANCEL
- // and DRV_RESTART
-
- case DRV_REMOVE:
- // Sent when the driver is removed.
- my_debug.OutPut(DEBUG_LEVEL_MSG, "DRV_REMOVE");
- dwRes = 1L; // return value ignored
- break;
-
- case DRV_QUERYCONFIGURE:
- my_debug.OutPut(DEBUG_LEVEL_MSG, "DRV_QUERYCONFIGURE");
- // Sent to determine if the driver can be
- // configured.
- dwRes = 1L; // Zero indicates configuration
- break; // NOT supported
-
- case DRV_CONFIGURE:
- my_debug.OutPut(DEBUG_LEVEL_MSG, "DRV_CONFIGURE");
- // Sent to display the configuration
- // dialog box for the driver.
-// dwRes = Configure( (HWND) lParam1, (LPDRVCONFIGINFO) lParam2 );
- if (my_EncodingProperties.Config(my_hModule, (HWND) lParam1))
- {
- dwRes = DRVCNF_OK; // Can also return
- // DRVCNF_CANCEL
- // and DRVCNF_RESTART
- } else {
- dwRes = DRVCNF_CANCEL;
- }
- break;
-
- /**************************************
- // ACM additional messages
- ***************************************/
-
- case ACMDM_DRIVER_ABOUT:
- my_debug.OutPut(DEBUG_LEVEL_MSG, "ACMDM_DRIVER_ABOUT");
-
- dwRes = About( (HWND) lParam1 );
-
- break;
-
- case ACMDM_DRIVER_DETAILS: // acmDriverDetails
- // Fill-in general informations about the driver/codec
- my_debug.OutPut(DEBUG_LEVEL_MSG, "ACMDM_DRIVER_DETAILS");
-
- dwRes = OnDriverDetails(hdrvr, (LPACMDRIVERDETAILS) lParam1);
-
- break;
-
- case ACMDM_FORMATTAG_DETAILS: // acmFormatTagDetails
- my_debug.OutPut(DEBUG_LEVEL_MSG, "ACMDM_FORMATTAG_DETAILS");
-
- dwRes = OnFormatTagDetails((LPACMFORMATTAGDETAILS) lParam1, lParam2);
-
- break;
-
- case ACMDM_FORMAT_DETAILS: // acmFormatDetails
- my_debug.OutPut(DEBUG_LEVEL_MSG, "ACMDM_FORMAT_DETAILS");
-
- dwRes = OnFormatDetails((LPACMFORMATDETAILS) lParam1, lParam2);
-
- break;
-
- case ACMDM_FORMAT_SUGGEST: // acmFormatSuggest
- // Sent to determine if the driver can be
- // configured.
- my_debug.OutPut(DEBUG_LEVEL_MSG, "ACMDM_FORMAT_SUGGEST");
- dwRes = OnFormatSuggest((LPACMDRVFORMATSUGGEST) lParam1);
- break;
-
- /**************************************
- // ACM stream messages
- ***************************************/
-
- case ACMDM_STREAM_OPEN:
- // Sent to determine if the driver can be
- // configured.
- my_debug.OutPut(DEBUG_LEVEL_MSG, "ACMDM_STREAM_OPEN");
- dwRes = OnStreamOpen((LPACMDRVSTREAMINSTANCE) lParam1);
- break;
-
- case ACMDM_STREAM_SIZE:
- // returns a recommended size for a source
- // or destination buffer on an ACM stream
- my_debug.OutPut(DEBUG_LEVEL_MSG, "ACMDM_STREAM_SIZE");
- dwRes = OnStreamSize((LPACMDRVSTREAMINSTANCE)lParam1, (LPACMDRVSTREAMSIZE)lParam2);
- break;
-
- case ACMDM_STREAM_PREPARE:
- // prepares an ACMSTREAMHEADER structure for
- // an ACM stream conversion
- my_debug.OutPut(DEBUG_LEVEL_MSG, "ACMDM_STREAM_PREPARE");
- dwRes = OnStreamPrepareHeader((LPACMDRVSTREAMINSTANCE)lParam1, (LPACMSTREAMHEADER) lParam2);
- break;
-
- case ACMDM_STREAM_UNPREPARE:
- // cleans up the preparation performed by
- // the ACMDM_STREAM_PREPARE message for an ACM stream
- my_debug.OutPut(DEBUG_LEVEL_MSG, "ACMDM_STREAM_UNPREPARE");
- dwRes = OnStreamUnPrepareHeader((LPACMDRVSTREAMINSTANCE)lParam1, (LPACMSTREAMHEADER) lParam2);
- break;
-
- case ACMDM_STREAM_CONVERT:
- // perform a conversion on the specified conversion stream
- my_debug.OutPut(DEBUG_LEVEL_MSG, "ACMDM_STREAM_CONVERT");
- dwRes = OnStreamConvert((LPACMDRVSTREAMINSTANCE)lParam1, (LPACMDRVSTREAMHEADER) lParam2);
-
- break;
-
- case ACMDM_STREAM_CLOSE:
- // closes an ACM conversion stream
- my_debug.OutPut(DEBUG_LEVEL_MSG, "ACMDM_STREAM_CLOSE");
- dwRes = OnStreamClose((LPACMDRVSTREAMINSTANCE)lParam1);
- break;
-
- /**************************************
- // Unknown message
- ***************************************/
-
- default:
- // Process any other messages.
- my_debug.OutPut(DEBUG_LEVEL_MSG, "ACM::DriverProc unknown message (0x%08X), lParam1 = 0x%08X, lParam2 = 0x%08X", msg, lParam1, lParam2);
- return DefDriverProc ((DWORD)this, hdrvr, msg, lParam1, lParam2);
- }
-
- return dwRes;
-}
-
-//////////////////////////////////////////////////////////////////////
-// Special message handlers
-//////////////////////////////////////////////////////////////////////
-/*!
- Retreive the config details of this ACM driver
- The index represent the specified format
-
- \param a_FormatDetails will be filled with all the corresponding data
-*/
-inline DWORD ACM::OnFormatDetails(LPACMFORMATDETAILS a_FormatDetails, const LPARAM a_Query)
-{
- DWORD Result = ACMERR_NOTPOSSIBLE;
-
- my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "ACM_FORMATDETAILS a_Query = 0x%08X",a_Query);
- switch (a_Query & ACM_FORMATDETAILSF_QUERYMASK) {
-
- // Fill-in the informations corresponding to the FormatDetails->dwFormatTagIndex
- case ACM_FORMATDETAILSF_INDEX :
- my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "enter ACM_FORMATDETAILSF_INDEX for index 0x%04X:%03d",a_FormatDetails->dwFormatTag,a_FormatDetails->dwFormatIndex);
- if (a_FormatDetails->dwFormatTag == PERSONAL_FORMAT) {
- if (a_FormatDetails->dwFormatIndex < GetNumberEncodingFormats()) {
- LPWAVEFORMATEX WaveExt;
- WaveExt = a_FormatDetails->pwfx;
-
- WaveExt->wFormatTag = PERSONAL_FORMAT;
-
- my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "format in : channels %d, sample rate %d", WaveExt->nChannels, WaveExt->nSamplesPerSec);
- GetMP3FormatForIndex(a_FormatDetails->dwFormatIndex, *WaveExt, a_FormatDetails->szFormat);
- my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "format out : channels %d, sample rate %d", WaveExt->nChannels, WaveExt->nSamplesPerSec);
- Result = MMSYSERR_NOERROR;
- }
- else
- {
- my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "ACM_FORMATDETAILSF_INDEX unknown index 0x%04X:%03d",a_FormatDetails->dwFormatTag,a_FormatDetails->dwFormatIndex);
- }
- }
- else if (a_FormatDetails->dwFormatTag == WAVE_FORMAT_PCM) {
- if (a_FormatDetails->dwFormatIndex < FORMAT_MAX_NB_PCM) {
- LPWAVEFORMATEX WaveExt;
- WaveExt = a_FormatDetails->pwfx;
-
- WaveExt->wFormatTag = WAVE_FORMAT_PCM;
-
- my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "format in : channels %d, sample rate %d", WaveExt->nChannels, WaveExt->nSamplesPerSec);
- GetPCMFormatForIndex(a_FormatDetails->dwFormatIndex, *WaveExt, a_FormatDetails->szFormat);
- my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "format out : channels %d, sample rate %d", WaveExt->nChannels, WaveExt->nSamplesPerSec);
- Result = MMSYSERR_NOERROR;
- }
- else
- {
- my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "ACM_FORMATDETAILSF_INDEX unknown index 0x%04X:%03d",a_FormatDetails->dwFormatTag,a_FormatDetails->dwFormatIndex);
- }
- }
- else
- {
- my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "Unknown a_FormatDetails->dwFormatTag = 0x%08X",a_FormatDetails->dwFormatTag);
- }
-
- case ACM_FORMATDETAILSF_FORMAT :
- /// \todo we may output the corresponding strong (only for personal format)
- LPWAVEFORMATEX WaveExt;
- WaveExt = a_FormatDetails->pwfx;
-
- my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "enter ACM_FORMATDETAILSF_FORMAT : 0x%04X:%03d, format in : channels %d, sample rate %d",a_FormatDetails->dwFormatTag,a_FormatDetails->dwFormatIndex, WaveExt->nChannels, WaveExt->nSamplesPerSec);
-
- Result = MMSYSERR_NOERROR;
- break;
-
- default:
- Result = ACMERR_NOTPOSSIBLE;
- break;
- }
-
- a_FormatDetails->fdwSupport = ACMDRIVERDETAILS_SUPPORTF_CODEC;
-
- return Result;
-}
-
-/*!
- Retreive the details of each known format by this ACM driver
- The index represent the specified format (0 = MP3 / 1 = PCM)
-
- \param a_FormatTagDetails will be filled with all the corresponding data
-*/
-inline DWORD ACM::OnFormatTagDetails(LPACMFORMATTAGDETAILS a_FormatTagDetails, const LPARAM a_Query)
-{
- DWORD Result;
- DWORD the_format = WAVE_FORMAT_UNKNOWN; // the format to give details
-
- if (a_FormatTagDetails->cbStruct >= sizeof(*a_FormatTagDetails)) {
-
- my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "ACMDM_FORMATTAG_DETAILS, a_Query = 0x%08X",a_Query);
- switch(a_Query & ACM_FORMATTAGDETAILSF_QUERYMASK) {
-
- case ACM_FORMATTAGDETAILSF_INDEX:
- // Fill-in the informations corresponding to the a_FormatDetails->dwFormatTagIndex
- my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "get ACM_FORMATTAGDETAILSF_INDEX for index %03d",a_FormatTagDetails->dwFormatTagIndex);
-
- if (a_FormatTagDetails->dwFormatTagIndex < FORMAT_TAG_MAX_NB) {
- switch (a_FormatTagDetails->dwFormatTagIndex)
- {
- case 0:
- the_format = PERSONAL_FORMAT;
- break;
- default :
- the_format = WAVE_FORMAT_PCM;
- break;
- }
- }
- else
- {
- my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "ACM_FORMATTAGDETAILSF_INDEX for unsupported index %03d",a_FormatTagDetails->dwFormatTagIndex);
- Result = ACMERR_NOTPOSSIBLE;
- }
- break;
-
- case ACM_FORMATTAGDETAILSF_FORMATTAG:
- // Fill-in the informations corresponding to the a_FormatDetails->dwFormatTagIndex and hdrvr given
- switch (a_FormatTagDetails->dwFormatTag)
- {
- case WAVE_FORMAT_PCM:
- the_format = WAVE_FORMAT_PCM;
- break;
- case PERSONAL_FORMAT:
- the_format = PERSONAL_FORMAT;
- break;
- default:
- return (ACMERR_NOTPOSSIBLE);
- }
- my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "get ACM_FORMATTAGDETAILSF_FORMATTAG for index 0x%02X, cStandardFormats = %d",a_FormatTagDetails->dwFormatTagIndex,a_FormatTagDetails->cStandardFormats);
- break;
- case ACM_FORMATTAGDETAILSF_LARGESTSIZE:
- my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "ACM_FORMATTAGDETAILSF_LARGESTSIZE not used");
- Result = 0L;
- break;
- default:
- my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "OnFormatTagDetails Unknown Format tag query");
- Result = MMSYSERR_NOTSUPPORTED;
- break;
- }
-
- my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "OnFormatTagDetails the_format = 0x%08X",the_format);
- switch(the_format)
- {
- case WAVE_FORMAT_PCM:
- a_FormatTagDetails->dwFormatTag = WAVE_FORMAT_PCM;
- a_FormatTagDetails->dwFormatTagIndex = 0;
- a_FormatTagDetails->cbFormatSize = sizeof(PCMWAVEFORMAT);
- /// \note 0 may mean we don't know how to decode
- a_FormatTagDetails->fdwSupport = ACMDRIVERDETAILS_SUPPORTF_CODEC;
- a_FormatTagDetails->cStandardFormats = FORMAT_MAX_NB_PCM;
- // should be filled by Windows a_FormatTagDetails->szFormatTag[0] = '\0';
- Result = MMSYSERR_NOERROR;
- break;
- case PERSONAL_FORMAT:
- a_FormatTagDetails->dwFormatTag = PERSONAL_FORMAT;
- a_FormatTagDetails->dwFormatTagIndex = 1;
- a_FormatTagDetails->cbFormatSize = SIZE_FORMAT_STRUCT;
- a_FormatTagDetails->fdwSupport = ACMDRIVERDETAILS_SUPPORTF_CODEC;
- a_FormatTagDetails->cStandardFormats = GetNumberEncodingFormats();
- lstrcpyW( a_FormatTagDetails->szFormatTag, L"Lame MP3" );
- Result = MMSYSERR_NOERROR;
- break;
- default:
- my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "OnFormatTagDetails Unknown format 0x%08X",the_format);
- return (ACMERR_NOTPOSSIBLE);
- }
- my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "OnFormatTagDetails %d possibilities for format 0x%08X",a_FormatTagDetails->cStandardFormats,the_format);
- }
- else
- {
- my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "a_FormatTagDetails->cbStruct < sizeof(*a_FormatDetails)");
- Result = ACMERR_NOTPOSSIBLE;
- }
-
- return Result;
-}
-
-/*!
- Retreive the global details of this ACM driver
-
- \param a_DriverDetail will be filled with all the corresponding data
-*/
-inline DWORD ACM::OnDriverDetails(const HDRVR hdrvr, LPACMDRIVERDETAILS a_DriverDetail)
-{
- if (my_hIcon == NULL)
- my_hIcon = LoadIcon(GetDriverModuleHandle(hdrvr), MAKEINTRESOURCE(IDI_ICON));
- a_DriverDetail->hicon = my_hIcon;
-
- a_DriverDetail->fccType = ACMDRIVERDETAILS_FCCTYPE_AUDIOCODEC;
- a_DriverDetail->fccComp = ACMDRIVERDETAILS_FCCCOMP_UNDEFINED;
-
- /// \note this is an explicit hack of the FhG values
- /// \note later it could be a new value when the decoding is done
- a_DriverDetail->wMid = MM_FRAUNHOFER_IIS;
- a_DriverDetail->wPid = MM_FHGIIS_MPEGLAYER3;
-
- a_DriverDetail->vdwACM = VERSION_MSACM;
- a_DriverDetail->vdwDriver = VERSION_ACM_DRIVER;
- a_DriverDetail->fdwSupport = ACMDRIVERDETAILS_SUPPORTF_CODEC;
- a_DriverDetail->cFormatTags = FORMAT_TAG_MAX_NB; // 2 : MP3 and PCM
-// a_DriverDetail->cFormatTags = 1; // 2 : MP3 and PCM
- a_DriverDetail->cFilterTags = FILTER_TAG_MAX_NB;
-
- lstrcpyW( a_DriverDetail->szShortName, L"LAME MP3" );
- char tmpStr[128];
- wsprintf(tmpStr, "LAME MP3 Codec v%s", GetVersionString());
- int u = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, tmpStr, -1, a_DriverDetail->szLongName, 0);
- MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, tmpStr, -1, a_DriverDetail->szLongName, u);
- lstrcpyW( a_DriverDetail->szCopyright, L"2002 Steve Lhomme" );
- lstrcpyW( a_DriverDetail->szLicensing, L"LGPL (see gnu.org)" );
- /// \todo update this part when the code changes
- lstrcpyW( a_DriverDetail->szFeatures , L"only CBR implementation" );
-
- return MMSYSERR_NOERROR; // Can also return DRVCNF_CANCEL
-}
-
-/*!
- Suggest an output format for the specified input format
-
- \param a_FormatSuggest will be filled with all the corresponding data
-*/
-inline DWORD ACM::OnFormatSuggest(LPACMDRVFORMATSUGGEST a_FormatSuggest)
-{
- DWORD Result = MMSYSERR_NOTSUPPORTED;
- DWORD fdwSuggest = (ACM_FORMATSUGGESTF_TYPEMASK & a_FormatSuggest->fdwSuggest);
-
-my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "Suggest %s%s%s%s (0x%08X)",
- (fdwSuggest & ACM_FORMATSUGGESTF_NCHANNELS) ? "channels, ":"",
- (fdwSuggest & ACM_FORMATSUGGESTF_NSAMPLESPERSEC) ? "samples/sec, ":"",
- (fdwSuggest & ACM_FORMATSUGGESTF_WBITSPERSAMPLE) ? "bits/sample, ":"",
- (fdwSuggest & ACM_FORMATSUGGESTF_WFORMATTAG) ? "format, ":"",
- fdwSuggest);
-
-my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "Suggest for source format = 0x%04X, channels = %d, Samples/s = %d, AvgB/s = %d, BlockAlign = %d, b/sample = %d",
- a_FormatSuggest->pwfxSrc->wFormatTag,
- a_FormatSuggest->pwfxSrc->nChannels,
- a_FormatSuggest->pwfxSrc->nSamplesPerSec,
- a_FormatSuggest->pwfxSrc->nAvgBytesPerSec,
- a_FormatSuggest->pwfxSrc->nBlockAlign,
- a_FormatSuggest->pwfxSrc->wBitsPerSample);
-
-my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "Suggested destination format = 0x%04X, channels = %d, Samples/s = %d, AvgB/s = %d, BlockAlign = %d, b/sample = %d",
- a_FormatSuggest->pwfxDst->wFormatTag,
- a_FormatSuggest->pwfxDst->nChannels,
- a_FormatSuggest->pwfxDst->nSamplesPerSec,
- a_FormatSuggest->pwfxDst->nAvgBytesPerSec,
- a_FormatSuggest->pwfxDst->nBlockAlign,
- a_FormatSuggest->pwfxDst->wBitsPerSample);
-
- switch (a_FormatSuggest->pwfxSrc->wFormatTag)
- {
- case WAVE_FORMAT_PCM:
- /// \todo handle here the decoding ?
- my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "Suggest for PCM source");
- //
- // if the destination format tag is restricted, verify that
- // it is within our capabilities...
- //
- // this driver is able to decode to PCM
- //
- if (ACM_FORMATSUGGESTF_WFORMATTAG & fdwSuggest)
- {
- if (PERSONAL_FORMAT != a_FormatSuggest->pwfxDst->wFormatTag)
- return (ACMERR_NOTPOSSIBLE);
- }
- else
- {
- a_FormatSuggest->pwfxDst->wFormatTag = PERSONAL_FORMAT;
- }
-
-
-my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "Suggest succeed A");
- //
- // if the destination channel count is restricted, verify that
- // it is within our capabilities...
- //
- // this driver is not able to change the number of channels
- //
- if (ACM_FORMATSUGGESTF_NCHANNELS & fdwSuggest)
- {
- if (a_FormatSuggest->pwfxSrc->nChannels != a_FormatSuggest->pwfxDst->nChannels)
- return (ACMERR_NOTPOSSIBLE);
- }
- else
- {
- a_FormatSuggest->pwfxDst->nChannels = a_FormatSuggest->pwfxSrc->nChannels;
- }
-
- if (a_FormatSuggest->pwfxSrc->nChannels != 1 && a_FormatSuggest->pwfxSrc->nChannels != 2)
- return MMSYSERR_INVALPARAM;
-
-
-my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "Suggest succeed B");
- //
- // if the destination samples per second is restricted, verify
- // that it is within our capabilities...
- //
- // this driver is not able to change the sample rate
- //
- if (ACM_FORMATSUGGESTF_NSAMPLESPERSEC & fdwSuggest)
- {
- if (a_FormatSuggest->pwfxSrc->nSamplesPerSec != a_FormatSuggest->pwfxDst->nSamplesPerSec)
- return (ACMERR_NOTPOSSIBLE);
- }
- else
- {
- a_FormatSuggest->pwfxDst->nSamplesPerSec = a_FormatSuggest->pwfxSrc->nSamplesPerSec;
- }
-
-
-my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "Suggest succeed C");
- //
- // if the destination bits per sample is restricted, verify
- // that it is within our capabilities...
- //
- // We prefer decoding to 16-bit PCM.
- //
- if (ACM_FORMATSUGGESTF_WBITSPERSAMPLE & fdwSuggest)
- {
- if ( (16 != a_FormatSuggest->pwfxDst->wBitsPerSample) && (8 != a_FormatSuggest->pwfxDst->wBitsPerSample) )
- return (ACMERR_NOTPOSSIBLE);
- }
- else
- {
- a_FormatSuggest->pwfxDst->wBitsPerSample = 16;
- }
-
- // a_FormatSuggest->pwfxDst->nBlockAlign = FORMAT_BLOCK_ALIGN;
- a_FormatSuggest->pwfxDst->nBlockAlign = a_FormatSuggest->pwfxDst->nChannels * a_FormatSuggest->pwfxDst->wBitsPerSample / 8;
-
- a_FormatSuggest->pwfxDst->nAvgBytesPerSec = a_FormatSuggest->pwfxDst->nChannels * 64000 / 8;
-
- my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "Suggest succeed");
- Result = MMSYSERR_NOERROR;
-
-
- break;
- case PERSONAL_FORMAT:
- my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "Suggest for PERSONAL source");
- //
- // if the destination format tag is restricted, verify that
- // it is within our capabilities...
- //
- // this driver is able to decode to PCM
- //
- if (ACM_FORMATSUGGESTF_WFORMATTAG & fdwSuggest)
- {
- if (WAVE_FORMAT_PCM != a_FormatSuggest->pwfxDst->wFormatTag)
- return (ACMERR_NOTPOSSIBLE);
- }
- else
- {
- a_FormatSuggest->pwfxDst->wFormatTag = WAVE_FORMAT_PCM;
- }
-
-
- //
- // if the destination channel count is restricted, verify that
- // it is within our capabilities...
- //
- // this driver is not able to change the number of channels
- //
- if (ACM_FORMATSUGGESTF_NCHANNELS & fdwSuggest)
- {
- if (a_FormatSuggest->pwfxSrc->nChannels != a_FormatSuggest->pwfxDst->nChannels)
- return (ACMERR_NOTPOSSIBLE);
- }
- else
- {
- a_FormatSuggest->pwfxDst->nChannels = a_FormatSuggest->pwfxSrc->nChannels;
- }
-
-
- //
- // if the destination samples per second is restricted, verify
- // that it is within our capabilities...
- //
- // this driver is not able to change the sample rate
- //
- if (ACM_FORMATSUGGESTF_NSAMPLESPERSEC & fdwSuggest)
- {
- if (a_FormatSuggest->pwfxSrc->nSamplesPerSec != a_FormatSuggest->pwfxDst->nSamplesPerSec)
- return (ACMERR_NOTPOSSIBLE);
- }
- else
- {
- a_FormatSuggest->pwfxDst->nSamplesPerSec = a_FormatSuggest->pwfxSrc->nSamplesPerSec;
- }
-
-
- //
- // if the destination bits per sample is restricted, verify
- // that it is within our capabilities...
- //
- // We prefer decoding to 16-bit PCM.
- //
- if (ACM_FORMATSUGGESTF_WBITSPERSAMPLE & fdwSuggest)
- {
- if ( (16 != a_FormatSuggest->pwfxDst->wBitsPerSample) && (8 != a_FormatSuggest->pwfxDst->wBitsPerSample) )
- return (ACMERR_NOTPOSSIBLE);
- }
- else
- {
- a_FormatSuggest->pwfxDst->wBitsPerSample = 16;
- }
-
- // a_FormatSuggest->pwfxDst->nBlockAlign = FORMAT_BLOCK_ALIGN;
- a_FormatSuggest->pwfxDst->nBlockAlign = a_FormatSuggest->pwfxDst->nChannels * a_FormatSuggest->pwfxDst->wBitsPerSample / 8;
-
- /// \todo this value must be a correct one !
- a_FormatSuggest->pwfxDst->nAvgBytesPerSec = a_FormatSuggest->pwfxDst->nSamplesPerSec * a_FormatSuggest->pwfxDst->nChannels * a_FormatSuggest->pwfxDst->wBitsPerSample / 8;
-
- my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "Suggest succeed");
- Result = MMSYSERR_NOERROR;
-
-
- break;
- }
-
- my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "Suggested destination format = 0x%04X, channels = %d, Samples/s = %d, AvgB/s = %d, BlockAlign = %d, b/sample = %d",
- a_FormatSuggest->pwfxDst->wFormatTag,
- a_FormatSuggest->pwfxDst->nChannels,
- a_FormatSuggest->pwfxDst->nSamplesPerSec,
- a_FormatSuggest->pwfxDst->nAvgBytesPerSec,
- a_FormatSuggest->pwfxDst->nBlockAlign,
- a_FormatSuggest->pwfxDst->wBitsPerSample);
-
- return Result;
-}
-
-/*!
- Create a stream instance for decoding/encoding
-
- \param a_StreamInstance contain information about the stream desired
-*/
-inline DWORD ACM::OnStreamOpen(LPACMDRVSTREAMINSTANCE a_StreamInstance)
-{
- DWORD Result = ACMERR_NOTPOSSIBLE;
-
- //
- // the most important condition to check before doing anything else
- // is that this ACM driver can actually perform the conversion we are
- // being opened for. this check should fail as quickly as possible
- // if the conversion is not possible by this driver.
- //
- // it is VERY important to fail quickly so the ACM can attempt to
- // find a driver that is suitable for the conversion. also note that
- // the ACM may call this driver several times with slightly different
- // format specifications before giving up.
- //
- // this driver first verifies that the source and destination formats
- // are acceptable...
- //
- switch (a_StreamInstance->pwfxSrc->wFormatTag)
- {
- case WAVE_FORMAT_PCM:
- my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "Open stream for PCM source (%05d samples %d channels %d bits/sample)",a_StreamInstance->pwfxSrc->nSamplesPerSec,a_StreamInstance->pwfxSrc->nChannels,a_StreamInstance->pwfxSrc->wBitsPerSample);
- if (a_StreamInstance->pwfxDst->wFormatTag == PERSONAL_FORMAT)
- {
- unsigned int OutputFrequency;
-
- /// \todo Smart mode
- if (my_EncodingProperties.GetSmartOutputMode())
- OutputFrequency = ACMStream::GetOutputSampleRate(a_StreamInstance->pwfxSrc->nSamplesPerSec,a_StreamInstance->pwfxDst->nAvgBytesPerSec,a_StreamInstance->pwfxDst->nChannels);
- else
- OutputFrequency = a_StreamInstance->pwfxSrc->nSamplesPerSec;
-
- my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "Open stream for PERSONAL output (%05d samples %d channels %d bits/sample %d kbps)",a_StreamInstance->pwfxDst->nSamplesPerSec,a_StreamInstance->pwfxDst->nChannels,a_StreamInstance->pwfxDst->wBitsPerSample,8 * a_StreamInstance->pwfxDst->nAvgBytesPerSec);
-
- /// \todo add the possibility to have channel resampling (mono to stereo / stereo to mono)
- /// \todo support resampling ?
- /// \todo only do the test on OutputFrequency in "Smart Output" mode
- if (a_StreamInstance->pwfxDst->nSamplesPerSec != OutputFrequency ||
-// a_StreamInstance->pwfxSrc->nSamplesPerSec != a_StreamInstance->pwfxDst->nSamplesPerSec ||
- a_StreamInstance->pwfxSrc->nChannels != a_StreamInstance->pwfxDst->nChannels ||
- a_StreamInstance->pwfxSrc->wBitsPerSample != 16)
- {
- Result = ACMERR_NOTPOSSIBLE;
- } else {
- if ((a_StreamInstance->fdwOpen & ACM_STREAMOPENF_QUERY) == 0)
- {
- ACMStream * the_stream = ACMStream::Create();
- a_StreamInstance->dwInstance = (DWORD) the_stream;
-
- if (the_stream != NULL)
- {
- MPEGLAYER3WAVEFORMAT * casted = (MPEGLAYER3WAVEFORMAT *) a_StreamInstance->pwfxDst;
- vbr_mode a_mode = (casted->fdwFlags-2 == 0)?vbr_abr:vbr_off;
- if (the_stream->init(a_StreamInstance->pwfxDst->nSamplesPerSec,
- OutputFrequency,
- a_StreamInstance->pwfxDst->nChannels,
- a_StreamInstance->pwfxDst->nAvgBytesPerSec,
- a_mode))
- Result = MMSYSERR_NOERROR;
- else
- ACMStream::Erase( the_stream );
- }
- }
- else
- {
- Result = MMSYSERR_NOERROR;
- }
- }
- }
- break;
- case PERSONAL_FORMAT:
- my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "Open stream for PERSONAL source (%05d samples %d channels %d bits/sample %d kbps)",a_StreamInstance->pwfxSrc->nSamplesPerSec,a_StreamInstance->pwfxSrc->nChannels,a_StreamInstance->pwfxSrc->wBitsPerSample,8 * a_StreamInstance->pwfxSrc->nAvgBytesPerSec);
- if (a_StreamInstance->pwfxDst->wFormatTag == WAVE_FORMAT_PCM)
- {
-#ifdef ENABLE_DECODING
- if ((a_StreamInstance->fdwOpen & ACM_STREAMOPENF_QUERY) == 0)
- {
- /// \todo create the decoding stream
- my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "Open stream for PCM output (%05d samples %d channels %d bits/sample %d B/s)",a_StreamInstance->pwfxDst->nSamplesPerSec,a_StreamInstance->pwfxDst->nChannels,a_StreamInstance->pwfxDst->wBitsPerSample,a_StreamInstance->pwfxDst->nAvgBytesPerSec);
-
- DecodeStream * the_stream = DecodeStream::Create();
- a_StreamInstance->dwInstance = (DWORD) the_stream;
-
- if (the_stream != NULL)
- {
- if (the_stream->init(a_StreamInstance->pwfxDst->nSamplesPerSec,
- a_StreamInstance->pwfxDst->nChannels,
- a_StreamInstance->pwfxDst->nAvgBytesPerSec,
- a_StreamInstance->pwfxSrc->nAvgBytesPerSec))
- Result = MMSYSERR_NOERROR;
- else
- DecodeStream::Erase( the_stream );
- }
- }
- else
- {
- /// \todo decoding verification
- my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "Open stream is valid");
- Result = MMSYSERR_NOERROR;
- }
-#endif // ENABLE_DECODING
- }
- break;
- }
-
- my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "Open stream Result = %d",Result);
- return Result;
-}
-
-inline DWORD ACM::OnStreamSize(LPACMDRVSTREAMINSTANCE a_StreamInstance, LPACMDRVSTREAMSIZE the_StreamSize)
-{
- DWORD Result = ACMERR_NOTPOSSIBLE;
-
- switch (ACM_STREAMSIZEF_QUERYMASK & the_StreamSize->fdwSize)
- {
- case ACM_STREAMSIZEF_DESTINATION:
- my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "Get source buffer size for destination size = %d",the_StreamSize->cbDstLength);
- break;
- case ACM_STREAMSIZEF_SOURCE:
- my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "Get destination buffer size for source size = %d",the_StreamSize->cbSrcLength);
- if (WAVE_FORMAT_PCM == a_StreamInstance->pwfxSrc->wFormatTag &&
- PERSONAL_FORMAT == a_StreamInstance->pwfxDst->wFormatTag)
- {
- ACMStream * the_stream = (ACMStream *) a_StreamInstance->dwInstance;
- if (the_stream != NULL)
- {
- the_StreamSize->cbDstLength = the_stream->GetOutputSizeForInput(the_StreamSize->cbSrcLength);
- Result = MMSYSERR_NOERROR;
- }
- }
- else if (PERSONAL_FORMAT == a_StreamInstance->pwfxSrc->wFormatTag &&
- WAVE_FORMAT_PCM== a_StreamInstance->pwfxDst->wFormatTag)
- {
-#ifdef ENABLE_DECODING
- DecodeStream * the_stream = (DecodeStream *) a_StreamInstance->dwInstance;
- if (the_stream != NULL)
- {
- the_StreamSize->cbDstLength = the_stream->GetOutputSizeForInput(the_StreamSize->cbSrcLength);
- Result = MMSYSERR_NOERROR;
- }
-#endif // ENABLE_DECODING
- }
- break;
- default:
- Result = MMSYSERR_INVALFLAG;
- break;
- }
-
- return Result;
-}
-
-inline DWORD ACM::OnStreamClose(LPACMDRVSTREAMINSTANCE a_StreamInstance)
-{
- DWORD Result = ACMERR_NOTPOSSIBLE;
-
- my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "OnStreamClose the stream 0x%X",a_StreamInstance->dwInstance);
- if (WAVE_FORMAT_PCM == a_StreamInstance->pwfxSrc->wFormatTag &&
- PERSONAL_FORMAT == a_StreamInstance->pwfxDst->wFormatTag)
- {
- ACMStream::Erase( (ACMStream *) a_StreamInstance->dwInstance );
- }
- else if (PERSONAL_FORMAT == a_StreamInstance->pwfxSrc->wFormatTag &&
- WAVE_FORMAT_PCM== a_StreamInstance->pwfxDst->wFormatTag)
- {
-#ifdef ENABLE_DECODING
- DecodeStream::Erase( (DecodeStream *) a_StreamInstance->dwInstance );
-#endif // ENABLE_DECODING
- }
-
- // nothing to do yet
- Result = MMSYSERR_NOERROR;
-
- return Result;
-}
-
-inline DWORD ACM::OnStreamPrepareHeader(LPACMDRVSTREAMINSTANCE a_StreamInstance, LPACMSTREAMHEADER a_StreamHeader)
-{
- DWORD Result = ACMERR_NOTPOSSIBLE;
-
- my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, " prepare : Src : %d (0x%08X) / %d - Dst : %d (0x%08X) / %d"
- , a_StreamHeader->cbSrcLength
- , a_StreamHeader->pbSrc
- , a_StreamHeader->cbSrcLengthUsed
- , a_StreamHeader->cbDstLength
- , a_StreamHeader->pbDst
- , a_StreamHeader->cbDstLengthUsed
- );
-
- if (WAVE_FORMAT_PCM == a_StreamInstance->pwfxSrc->wFormatTag &&
- PERSONAL_FORMAT == a_StreamInstance->pwfxDst->wFormatTag)
- {
- ACMStream * the_stream = (ACMStream *)a_StreamInstance->dwInstance;
-
- if (the_stream->open(my_EncodingProperties))
- Result = MMSYSERR_NOERROR;
- }
- else if (PERSONAL_FORMAT == a_StreamInstance->pwfxSrc->wFormatTag &&
- WAVE_FORMAT_PCM == a_StreamInstance->pwfxDst->wFormatTag)
- {
-#ifdef ENABLE_DECODING
- DecodeStream * the_stream = (DecodeStream *)a_StreamInstance->dwInstance;
-
- if (the_stream->open())
- Result = MMSYSERR_NOERROR;
-#endif // ENABLE_DECODING
- }
-
- return Result;
-}
-
-inline DWORD ACM::OnStreamUnPrepareHeader(LPACMDRVSTREAMINSTANCE a_StreamInstance, LPACMSTREAMHEADER a_StreamHeader)
-{
- DWORD Result = ACMERR_NOTPOSSIBLE;
-
- my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "unprepare : Src : %d / %d - Dst : %d / %d"
- , a_StreamHeader->cbSrcLength
- , a_StreamHeader->cbSrcLengthUsed
- , a_StreamHeader->cbDstLength
- , a_StreamHeader->cbDstLengthUsed
- );
- if (WAVE_FORMAT_PCM == a_StreamInstance->pwfxSrc->wFormatTag &&
- PERSONAL_FORMAT == a_StreamInstance->pwfxDst->wFormatTag)
- {
- ACMStream * the_stream = (ACMStream *)a_StreamInstance->dwInstance;
- DWORD OutputSize = a_StreamHeader->cbDstLength;
-
- if (the_stream->close(a_StreamHeader->pbDst, &OutputSize) && (OutputSize <= a_StreamHeader->cbDstLength))
- {
- a_StreamHeader->cbDstLengthUsed = OutputSize;
- Result = MMSYSERR_NOERROR;
- }
- }
- else if (PERSONAL_FORMAT == a_StreamInstance->pwfxSrc->wFormatTag &&
- WAVE_FORMAT_PCM== a_StreamInstance->pwfxDst->wFormatTag)
- {
-#ifdef ENABLE_DECODING
- DecodeStream * the_stream = (DecodeStream *)a_StreamInstance->dwInstance;
- DWORD OutputSize = a_StreamHeader->cbDstLength;
-
- if (the_stream->close(a_StreamHeader->pbDst, &OutputSize) && (OutputSize <= a_StreamHeader->cbDstLength))
- {
- a_StreamHeader->cbDstLengthUsed = OutputSize;
- Result = MMSYSERR_NOERROR;
- }
-#endif // ENABLE_DECODING
- }
-
- return Result;
-}
-
-inline DWORD ACM::OnStreamConvert(LPACMDRVSTREAMINSTANCE a_StreamInstance, LPACMDRVSTREAMHEADER a_StreamHeader)
-{
- DWORD Result = ACMERR_NOTPOSSIBLE;
-
- if (WAVE_FORMAT_PCM == a_StreamInstance->pwfxSrc->wFormatTag &&
- PERSONAL_FORMAT == a_StreamInstance->pwfxDst->wFormatTag)
- {
- my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "OnStreamConvert SRC = PCM (encode)");
-
- ACMStream * the_stream = (ACMStream *) a_StreamInstance->dwInstance;
- if (the_stream != NULL)
- {
- if (the_stream->ConvertBuffer( a_StreamHeader ))
- Result = MMSYSERR_NOERROR;
- }
- }
- else if (PERSONAL_FORMAT == a_StreamInstance->pwfxSrc->wFormatTag &&
- WAVE_FORMAT_PCM == a_StreamInstance->pwfxDst->wFormatTag)
- {
- my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "OnStreamConvert SRC = MP3 (decode)");
-
-#ifdef ENABLE_DECODING
- DecodeStream * the_stream = (DecodeStream *) a_StreamInstance->dwInstance;
- if (the_stream != NULL)
- {
- if (the_stream->ConvertBuffer( a_StreamHeader ))
- Result = MMSYSERR_NOERROR;
- }
-#endif // ENABLE_DECODING
- }
- else
- my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "OnStreamConvert unsupported conversion");
-
- return Result;
-}
-
-
-void ACM::GetMP3FormatForIndex(const DWORD the_Index, WAVEFORMATEX & the_Format, unsigned short the_String[ACMFORMATDETAILS_FORMAT_CHARS]) const
-{
- int Block_size;
- char temp[ACMFORMATDETAILS_FORMAT_CHARS];
-
-
- if (the_Index < bitrate_table.size())
- {
- // the_Format.wBitsPerSample = 16;
- the_Format.wBitsPerSample = 0;
-
- /// \todo handle more channel modes (mono, stereo, joint-stereo, dual-channel)
- // the_Format.nChannels = SIZE_CHANNEL_MODE - int(the_Index % SIZE_CHANNEL_MODE);
-
- the_Format.nBlockAlign = 1;
-
- the_Format.nSamplesPerSec = bitrate_table[the_Index].frequency;
- the_Format.nAvgBytesPerSec = bitrate_table[the_Index].bitrate * 1000 / 8;
- if (bitrate_table[the_Index].frequency >= mpeg1_freq[SIZE_FREQ_MPEG1-1])
- Block_size = 1152;
- else
- Block_size = 576;
-
- the_Format.nChannels = bitrate_table[the_Index].channels;
-
- the_Format.cbSize = sizeof(MPEGLAYER3WAVEFORMAT) - sizeof(WAVEFORMATEX);
- MPEGLAYER3WAVEFORMAT * tmpFormat = (MPEGLAYER3WAVEFORMAT *) &the_Format;
- tmpFormat->wID = 1;
- // this is the only way I found to know if we do CBR or ABR
- tmpFormat->fdwFlags = 2 + ((bitrate_table[the_Index].mode == vbr_abr)?0:2);
- tmpFormat->nBlockSize = WORD(Block_size * the_Format.nAvgBytesPerSec / the_Format.nSamplesPerSec);
- tmpFormat->nFramesPerBlock = 1;
- tmpFormat->nCodecDelay = 0; // 0x0571 on FHG
-
- /// \todo : generate the string with the appropriate stereo mode
- if (bitrate_table[the_Index].mode == vbr_abr)
- wsprintfA( temp, "%d Hz, %d kbps ABR, %s", the_Format.nSamplesPerSec, the_Format.nAvgBytesPerSec * 8 / 1000, (the_Format.nChannels == 1)?"Mono":"Stereo");
- else
- wsprintfA( temp, "%d Hz, %d kbps CBR, %s", the_Format.nSamplesPerSec, the_Format.nAvgBytesPerSec * 8 / 1000, (the_Format.nChannels == 1)?"Mono":"Stereo");
-
- MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, temp, -1, the_String, ACMFORMATDETAILS_FORMAT_CHARS);
- }
- }
-
-void ACM::GetPCMFormatForIndex(const DWORD the_Index, WAVEFORMATEX & the_Format, unsigned short the_String[ACMFORMATDETAILS_FORMAT_CHARS]) const
-{
- the_Format.nChannels = SIZE_CHANNEL_MODE - int(the_Index % SIZE_CHANNEL_MODE);
- the_Format.wBitsPerSample = 16;
- the_Format.nBlockAlign = the_Format.nChannels * the_Format.wBitsPerSample / 8;
-
-
- DWORD a_Channel_Independent = the_Index / SIZE_CHANNEL_MODE;
-
- // first MPEG1 frequencies
- if (a_Channel_Independent < SIZE_FREQ_MPEG1)
- {
- the_Format.nSamplesPerSec = mpeg1_freq[a_Channel_Independent];
- }
- else
- {
- a_Channel_Independent -= SIZE_FREQ_MPEG1;
- the_Format.nSamplesPerSec = mpeg2_freq[a_Channel_Independent];
- }
-
- the_Format.nAvgBytesPerSec = the_Format.nSamplesPerSec * the_Format.nChannels * the_Format.wBitsPerSample / 8;
-}
-
-DWORD ACM::GetNumberEncodingFormats() const
-{
- return bitrate_table.size();
-}
-
-bool ACM::IsSmartOutput(const int frequency, const int bitrate, const int channels) const
-{
- double compression_ratio = double(frequency * 2 * channels) / double(bitrate * 100);
-
-//my_debug.OutPut(DEBUG_LEVEL_FUNC_DEBUG, "compression_ratio %f, freq %d, bitrate %d, channels %d", compression_ratio, frequency, bitrate, channels);
-
- if(my_EncodingProperties.GetSmartOutputMode())
- return (compression_ratio <= my_EncodingProperties.GetSmartRatio());
- else return true;
-}
-
-void ACM::BuildBitrateTable()
-{
- my_debug.OutPut("entering BuildBitrateTable");
-
- // fill the table
- unsigned int channel,bitrate,freq;
-
- bitrate_table.clear();
-
- // CBR bitrates
- for (channel = 0;channel < SIZE_CHANNEL_MODE;channel++)
- {
- // MPEG I
- for (freq = 0;freq < SIZE_FREQ_MPEG1;freq++)
- {
- for (bitrate = 0;bitrate < SIZE_BITRATE_MPEG1;bitrate++)
- {
-
- if (!my_EncodingProperties.GetSmartOutputMode() || IsSmartOutput(mpeg1_freq[freq], mpeg1_bitrate[bitrate], channel+1))
- {
- bitrate_item bitrate_table_tmp;
-
- bitrate_table_tmp.frequency = mpeg1_freq[freq];
- bitrate_table_tmp.bitrate = mpeg1_bitrate[bitrate];
- bitrate_table_tmp.channels = channel+1;
- bitrate_table_tmp.mode = vbr_off;
- bitrate_table.push_back(bitrate_table_tmp);
- }
- }
- }
- // MPEG II / II.5
- for (freq = 0;freq < SIZE_FREQ_MPEG2;freq++)
- {
- for (bitrate = 0;bitrate < SIZE_BITRATE_MPEG2;bitrate++)
- {
- if (!my_EncodingProperties.GetSmartOutputMode() || IsSmartOutput(mpeg2_freq[freq], mpeg2_bitrate[bitrate], channel+1))
- {
- bitrate_item bitrate_table_tmp;
-
- bitrate_table_tmp.frequency = mpeg2_freq[freq];
- bitrate_table_tmp.bitrate = mpeg2_bitrate[bitrate];
- bitrate_table_tmp.channels = channel+1;
- bitrate_table_tmp.mode = vbr_abr;
- bitrate_table.push_back(bitrate_table_tmp);
- }
- }
- }
- }
-
- if (my_EncodingProperties.GetAbrOutputMode())
- // ABR bitrates
- {
- for (channel = 0;channel < SIZE_CHANNEL_MODE;channel++)
- {
- // MPEG I
- for (freq = 0;freq < SIZE_FREQ_MPEG1;freq++)
- {
- for (bitrate = my_EncodingProperties.GetAbrBitrateMax();
- bitrate >= my_EncodingProperties.GetAbrBitrateMin();
- bitrate -= my_EncodingProperties.GetAbrBitrateStep())
- {
- if (bitrate >= mpeg1_bitrate[SIZE_BITRATE_MPEG1-1] && (!my_EncodingProperties.GetSmartOutputMode() || IsSmartOutput(mpeg1_freq[freq], bitrate, channel+1)))
- {
- bitrate_item bitrate_table_tmp;
-
- bitrate_table_tmp.frequency = mpeg1_freq[freq];
- bitrate_table_tmp.bitrate = bitrate;
- bitrate_table_tmp.channels = channel+1;
- bitrate_table_tmp.mode = vbr_abr;
- bitrate_table.push_back(bitrate_table_tmp);
- }
- }
- }
- // MPEG II / II.5
- for (freq = 0;freq < SIZE_FREQ_MPEG2;freq++)
- {
- for (bitrate = my_EncodingProperties.GetAbrBitrateMax();
- bitrate >= my_EncodingProperties.GetAbrBitrateMin();
- bitrate -= my_EncodingProperties.GetAbrBitrateStep())
- {
- if (bitrate >= mpeg2_bitrate[SIZE_BITRATE_MPEG2-1] && (!my_EncodingProperties.GetSmartOutputMode() || IsSmartOutput(mpeg2_freq[freq], bitrate, channel+1)))
- {
- bitrate_item bitrate_table_tmp;
-
- bitrate_table_tmp.frequency = mpeg2_freq[freq];
- bitrate_table_tmp.bitrate = bitrate;
- bitrate_table_tmp.channels = channel+1;
- bitrate_table_tmp.mode = vbr_abr;
- bitrate_table.push_back(bitrate_table_tmp);
- }
- }
- }
- }
- }
-
- // sorting by frequency/bitrate/channel
- std::sort(bitrate_table.begin(), bitrate_table.end());
-
-/* {
- // display test
- int i=0;
- for (i=0; i<bitrate_table.size();i++)
- {
- my_debug.OutPut("bitrate_table[%d].frequency = %d",i,bitrate_table[i].frequency);
- my_debug.OutPut("bitrate_table[%d].bitrate = %d",i,bitrate_table[i].bitrate);
- my_debug.OutPut("bitrate_table[%d].channel = %d",i,bitrate_table[i].channels);
- my_debug.OutPut("bitrate_table[%d].ABR = %s\n",i,(bitrate_table[i].mode == vbr_abr)?"ABR":"CBR");
- }
- }*/
-
- my_debug.OutPut("leaving BuildBitrateTable");
-}
View
101 lib/liblame/ACM/ACM.h
@@ -1,101 +0,0 @@
-/**
- *
- * Lame ACM wrapper, encode/decode MP3 based RIFF/AVI files in MS Windows
- *
- * Copyright (c) 2002 Steve Lhomme <steve.lhomme at free.fr>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-
-/*!
- \author Steve Lhomme
- \version \$Id: ACM.h,v 1.8 2006/12/25 21:37:34 robert Exp $
-*/
-
-#if !defined(_ACM_H__INCLUDED_)
-#define _ACM_H__INCLUDED_
-
-#if _MSC_VER >= 1000
-#pragma once
-#endif // _MSC_VER >= 1000
-
-#include <vector>
-
-#include <windows.h>
-#include <mmsystem.h>
-#include <mmreg.h>
-#include <msacm.h>
-#include <msacmdrv.h>
-
-
-#include "ADbg/ADbg.h"
-
-class AEncodeProperties;
-
-typedef enum vbr_mode_e vbr_mode;
-
-class bitrate_item {
- public:
- unsigned int frequency;
- unsigned int bitrate;
- unsigned int channels;
- vbr_mode mode;
-
- bool operator<(const bitrate_item & bitrate) const;
-};
-
-class ACM
-{
-public:
- ACM( HMODULE hModule );
- virtual ~ACM();
-
- LONG DriverProcedure(const HDRVR hdrvr, const UINT msg, LONG lParam1, LONG lParam2);
-
- static const char * GetVersionString(void) {return VersionString;}
-
-protected:
-// inline DWORD Configure( HWND hParentWindow, LPDRVCONFIGINFO pConfig );
- inline DWORD About( HWND hParentWindow );
-
- inline DWORD OnDriverDetails(const HDRVR hdrvr, LPACMDRIVERDETAILS a_DriverDetail);
- inline DWORD OnFormatTagDetails(LPACMFORMATTAGDETAILS a_FormatTagDetails, const LPARAM a_Query);
- inline DWORD OnFormatDetails(LPACMFORMATDETAILS a_FormatDetails, const LPARAM a_Query);
- inline DWORD OnFormatSuggest(LPACMDRVFORMATSUGGEST a_FormatSuggest);
- inline DWORD OnStreamOpen(LPACMDRVSTREAMINSTANCE a_StreamInstance);
- inline DWORD OnStreamClose(LPACMDRVSTREAMINSTANCE a_StreamInstance);
- inline DWORD OnStreamSize(LPACMDRVSTREAMINSTANCE a_StreamInstance, LPACMDRVSTREAMSIZE the_StreamSize);
- inline DWORD OnStreamPrepareHeader(LPACMDRVSTREAMINSTANCE a_StreamInstance, LPACMSTREAMHEADER a_StreamHeader);
- inline DWORD OnStreamUnPrepareHeader(LPACMDRVSTREAMINSTANCE a_StreamInstance, LPACMSTREAMHEADER a_StreamHeader);
- inline DWORD OnStreamConvert(LPACMDRVSTREAMINSTANCE a_StreamInstance, LPACMDRVSTREAMHEADER a_StreamHeader);
-
- void GetMP3FormatForIndex(const DWORD the_Index, WAVEFORMATEX & the_Format, unsigned short the_String[ACMFORMATDETAILS_FORMAT_CHARS]) const;
- void GetPCMFormatForIndex(const DWORD the_Index, WAVEFORMATEX & the_Format, unsigned short the_String[ACMFORMATDETAILS_FORMAT_CHARS]) const;
- DWORD GetNumberEncodingFormats() const;
- bool IsSmartOutput(const int frequency, const int bitrate, const int channels) const;
- void BuildBitrateTable();
-
- HMODULE my_hModule;
- HICON my_hIcon;
- ADbg my_debug;
- AEncodeProperties my_EncodingProperties;
- std::vector<bitrate_item> bitrate_table;
-
- static char VersionString[120];
-};
-
-#endif // !defined(_ACM_H__INCLUDED_)
-
View
397 lib/liblame/ACM/ACMStream.cpp
@@ -1,397 +0,0 @@
-/**
- *
- * Lame ACM wrapper, encode/decode MP3 based RIFF/AVI files in MS Windows
- *
- * Copyright (c) 2002 Steve Lhomme <steve.lhomme at free.fr>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-
-/*!
- \author Steve Lhomme
- \version \$Id: ACMStream.cpp,v 1.12.2.1 2008/11/01 20:41:47 robert Exp $
-*/
-
-#if !defined(STRICT)
-#define STRICT
-#endif // STRICT
-
-#include <assert.h>
-#include <windows.h>
-
-#include "adebug.h"
-
-#include "ACMStream.h"
-
-#include <lame.h>
-
-// static methods
-
-ACMStream * ACMStream::Create()
-{
- ACMStream * Result;
-
- Result = new ACMStream;
-
- return Result;
-}
-
-const bool ACMStream::Erase(const ACMStream * a_ACMStream)
-{
- delete a_ACMStream;
- return true;
-}
-
-// class methods
-
-ACMStream::ACMStream() :
- m_WorkingBufferUseSize(0),
- gfp(NULL)
-{
- /// \todo get the debug level from the registry
-my_debug = new ADbg(DEBUG_LEVEL_CREATION);
- if (my_debug != NULL) {
- unsigned char DebugFileName[512];
-
- my_debug->setPrefix("LAMEstream"); /// \todo get it from the registry
-my_debug->setIncludeTime(true); /// \todo get it from the registry
-
-// Check in the registry if we have to Output Debug information
-DebugFileName[0] = '\0';
-
- HKEY OssKey;
- if (RegOpenKeyEx( HKEY_LOCAL_MACHINE, "SOFTWARE\\MUKOLI", 0, KEY_READ , &OssKey ) == ERROR_SUCCESS) {
- DWORD DataType;
- DWORD DebugFileNameSize = 512;
- if (RegQueryValueEx( OssKey, "DebugFile", NULL, &DataType, DebugFileName, &DebugFileNameSize ) == ERROR_SUCCESS) {
- if (DataType == REG_SZ) {
- my_debug->setUseFile(true);
- my_debug->setDebugFile((char *)DebugFileName);
- my_debug->OutPut("Debug file is %s",(char *)DebugFileName);
- }
- }
- }
- my_debug->OutPut(DEBUG_LEVEL_FUNC_START, "ACMStream Creation (0X%08X)",this);
- }
- else {
- ADbg debug;
- debug.OutPut("ACMStream::ACMACMStream : Impossible to create my_debug");
- }
-
-}
-
-ACMStream::~ACMStream()
-{
- // release memory - encoding is finished
- if (gfp) lame_close( gfp );
-
- if (my_debug != NULL)
- {
- my_debug->OutPut(DEBUG_LEVEL_FUNC_START, "ACMStream Deletion (0X%08X)",this);
- delete my_debug;
- }
-}
-
-bool ACMStream::init(const int nSamplesPerSec, const int nOutputSamplesPerSec, const int nChannels, const int nAvgBytesPerSec, const vbr_mode mode)
-{
- bool bResult = false;
-
- my_SamplesPerSec = nSamplesPerSec;
- my_OutBytesPerSec = nOutputSamplesPerSec;
- my_Channels = nChannels;
- my_AvgBytesPerSec = nAvgBytesPerSec;
- my_VBRMode = mode;
-
- bResult = true;
-
- return bResult;
-
-}
-
-bool ACMStream::open(const AEncodeProperties & the_Properties)
-{
- bool bResult = false;
-
- // Init the MP3 Stream
- // Init the global flags structure
- gfp = lame_init();
-
- // Set input sample frequency
- lame_set_in_samplerate( gfp, my_SamplesPerSec );
-
- // Set output sample frequency
- lame_set_out_samplerate( gfp, my_OutBytesPerSec );
-
- lame_set_num_channels( gfp, my_Channels );
- if (my_Channels == 1)
- lame_set_mode( gfp, MONO );
- else
- lame_set_mode( gfp, (MPEG_mode_e)the_Properties.GetChannelModeValue()) ; /// \todo Get the mode from the default configuration
-
-// lame_set_VBR( gfp, vbr_off ); /// \note VBR not supported for the moment
- lame_set_VBR( gfp, my_VBRMode ); /// \note VBR not supported for the moment
-
- if (my_VBRMode == vbr_abr)
- {
- lame_set_VBR_q( gfp, 1 );
-
- lame_set_VBR_mean_bitrate_kbps( gfp, (my_AvgBytesPerSec * 8 + 500) / 1000 );
-
- if (24000 > lame_get_in_samplerate( gfp ))
- {
- // For MPEG-II
- lame_set_VBR_min_bitrate_kbps( gfp, 8);
-
- lame_set_VBR_max_bitrate_kbps( gfp, 160);
- }
- else
- {
- // For MPEG-I
- lame_set_VBR_min_bitrate_kbps( gfp, 32);
-
- lame_set_VBR_max_bitrate_kbps( gfp, 320);
- }
- }
-
- // Set bitrate
- lame_set_brate( gfp, my_AvgBytesPerSec * 8 / 1000 );
-
- /// \todo Get the mode from the default configuration
- // Set copyright flag?
- lame_set_copyright( gfp, the_Properties.GetCopyrightMode()?1:0 );
- // Do we have to tag it as non original
- lame_set_original( gfp, the_Properties.GetOriginalMode()?1:0 );
- // Add CRC?
- lame_set_error_protection( gfp, the_Properties.GetCRCMode()?1:0 );
- // Set private bit?
- lame_set_extension( gfp, the_Properties.GetPrivateMode()?1:0 );
- // INFO tag support not possible in ACM - it requires rewinding
- // output stream to the beginning after encoding is finished.
- lame_set_bWriteVbrTag( gfp, 0 );
-
- if (0 == lame_init_params( gfp ))
- {
- //LAME encoding call will accept any number of samples.
- if ( 0 == lame_get_version( gfp ) )
- {
- // For MPEG-II, only 576 samples per frame per channel
- my_SamplesPerBlock = 576 * lame_get_num_channels( gfp );
- }
- else
- {
- // For MPEG-I, 1152 samples per frame per channel
- my_SamplesPerBlock = 1152 * lame_get_num_channels( gfp );
- }
- }
-
- my_debug->OutPut(DEBUG_LEVEL_FUNC_DEBUG, "version =%d",lame_get_version( gfp ) );
- my_debug->OutPut(DEBUG_LEVEL_FUNC_DEBUG, "Layer =3");
- switch ( lame_get_mode( gfp ) )
- {
- case STEREO: my_debug->OutPut(DEBUG_LEVEL_FUNC_DEBUG, "mode =Stereo" ); break;
- case JOINT_STEREO: my_debug->OutPut(DEBUG_LEVEL_FUNC_DEBUG, "mode =Joint-Stereo" ); break;
- case DUAL_CHANNEL: my_debug->OutPut(DEBUG_LEVEL_FUNC_DEBUG, "mode =Forced Stereo" ); break;
- case MONO: my_debug->OutPut(DEBUG_LEVEL_FUNC_DEBUG, "mode =Mono" ); break;
- case NOT_SET: /* FALLTROUGH */
- default: my_debug->OutPut(DEBUG_LEVEL_FUNC_DEBUG, "mode =Error (unknown)" ); break;
- }
-
- my_debug->OutPut(DEBUG_LEVEL_FUNC_DEBUG, "sampling frequency =%.1f kHz", lame_get_in_samplerate( gfp ) /1000.0 );
- my_debug->OutPut(DEBUG_LEVEL_FUNC_DEBUG, "bitrate =%d kbps", lame_get_brate( gfp ) );
- my_debug->OutPut(DEBUG_LEVEL_FUNC_DEBUG, "Vbr Min bitrate =%d kbps", lame_get_VBR_min_bitrate_kbps( gfp ) );
- my_debug->OutPut(DEBUG_LEVEL_FUNC_DEBUG, "Vbr Max bitrate =%d kbps", lame_get_VBR_max_bitrate_kbps( gfp ) );
- my_debug->OutPut(DEBUG_LEVEL_FUNC_DEBUG, "Quality Setting =%d", lame_get_quality( gfp ) );
-
- my_debug->OutPut(DEBUG_LEVEL_FUNC_DEBUG, "Low pass frequency =%d", lame_get_lowpassfreq( gfp ) );
- my_debug->OutPut(DEBUG_LEVEL_FUNC_DEBUG, "Low pass width =%d", lame_get_lowpasswidth( gfp ) );
-
- my_debug->OutPut(DEBUG_LEVEL_FUNC_DEBUG, "High pass frequency =%d", lame_get_highpassfreq( gfp ) );
- my_debug->OutPut(DEBUG_LEVEL_FUNC_DEBUG, "High pass width =%d", lame_get_highpasswidth( gfp ) );
-
- my_debug->OutPut(DEBUG_LEVEL_FUNC_DEBUG, "No Short Blocks =%d", lame_get_no_short_blocks( gfp ) );
-
- my_debug->OutPut(DEBUG_LEVEL_FUNC_DEBUG, "de-emphasis =%d", lame_get_emphasis( gfp ) );
- my_debug->OutPut(DEBUG_LEVEL_FUNC_DEBUG, "private flag =%d", lame_get_extension( gfp ) );
-
- my_debug->OutPut(DEBUG_LEVEL_FUNC_DEBUG, "copyright flag =%d", lame_get_copyright( gfp ) );
- my_debug->OutPut(DEBUG_LEVEL_FUNC_DEBUG, "original flag =%d", lame_get_original( gfp ) );
- my_debug->OutPut(DEBUG_LEVEL_FUNC_DEBUG, "CRC =%s", lame_get_error_protection( gfp ) ? "on" : "off" );
- my_debug->OutPut(DEBUG_LEVEL_FUNC_DEBUG, "Fast mode =%s", ( lame_get_quality( gfp ) )? "enabled" : "disabled" );
- my_debug->OutPut(DEBUG_LEVEL_FUNC_DEBUG, "Force mid/side stereo =%s", ( lame_get_force_ms( gfp ) )?"enabled":"disabled" );
- my_debug->OutPut(DEBUG_LEVEL_FUNC_DEBUG, "Disable Resorvoir =%d", lame_get_disable_reservoir( gfp ) );
- my_debug->OutPut(DEBUG_LEVEL_FUNC_DEBUG, "VBR =%s, VBR_q =%d, VBR method =",
- ( lame_get_VBR( gfp ) !=vbr_off ) ? "enabled": "disabled",
- lame_get_VBR_q( gfp ) );
-
- switch ( lame_get_VBR( gfp ) )
- {
- case vbr_off: my_debug->OutPut(DEBUG_LEVEL_FUNC_DEBUG, "vbr_off" ); break;
- case vbr_mt : my_debug->OutPut(DEBUG_LEVEL_FUNC_DEBUG, "vbr_mt" ); break;
- case vbr_rh : my_debug->OutPut(DEBUG_LEVEL_FUNC_DEBUG, "vbr_rh" ); break;
- case vbr_mtrh: my_debug->OutPut(DEBUG_LEVEL_FUNC_DEBUG, "vbr_mtrh" ); break;
- case vbr_abr:
- my_debug->OutPut(DEBUG_LEVEL_FUNC_DEBUG, "vbr_abr (average bitrate %d kbps)", lame_get_VBR_mean_bitrate_kbps( gfp ) );
- break;
- default:
- my_debug->OutPut(DEBUG_LEVEL_FUNC_DEBUG, "error, unknown VBR setting");
- break;
- }
-
- my_debug->OutPut(DEBUG_LEVEL_FUNC_DEBUG, "Write VBR Header =%s\n", ( lame_get_bWriteVbrTag( gfp ) ) ?"Yes":"No");
-
-#ifdef FROM_DLL
-beConfig.format.LHV1.dwReSampleRate = my_OutBytesPerSec; // force the user resampling
-#endif // FROM_DLL
-
- bResult = true;
-
- return bResult;
-}
-
-bool ACMStream::close(LPBYTE pOutputBuffer, DWORD *pOutputSize)
-{
-
-bool bResult = false;
-
- int nOutputSamples = 0;
-
- nOutputSamples = lame_encode_flush( gfp, pOutputBuffer, 0 );
-
- if ( nOutputSamples < 0 )
- {
- // BUFFER_TOO_SMALL
-*pOutputSize = 0;
- }
- else
-{
- *pOutputSize = nOutputSamples;
-
- bResult = true;
- }
-
- // lame will be closed in destructor
- //lame_close( gfp );
-
- return bResult;
-}
-
-DWORD ACMStream::GetOutputSizeForInput(const DWORD the_SrcLength) const
-{
-/* double OutputInputRatio;
-
- if (my_VBRMode == vbr_off)
- OutputInputRatio = double(my_AvgBytesPerSec) / double(my_OutBytesPerSec * 2);
- else // reserve the space for 320 kbps
- OutputInputRatio = 40000.0 / double(my_OutBytesPerSec * 2);
-
- OutputInputRatio *= 1.15; // allow 15% more*/
-
- DWORD Result;
-
-// Result = DWORD(double(the_SrcLength) * OutputInputRatio);
- Result = DWORD(1.25*the_SrcLength + 7200);
-
-my_debug->OutPut(DEBUG_LEVEL_FUNC_CODE, "Result = %d",Result);
-
- return Result;
-}
-
-bool ACMStream::ConvertBuffer(LPACMDRVSTREAMHEADER a_StreamHeader)
-{
- bool result;
-
-if (my_debug != NULL)
-{
-my_debug->OutPut(DEBUG_LEVEL_FUNC_DEBUG, "enter ACMStream::ConvertBuffer");
-}
-
- DWORD InSize = a_StreamHeader->cbSrcLength / 2, OutSize = a_StreamHeader->cbDstLength; // 2 for 8<->16 bits
-
-// Encode it
-int dwSamples;
- int nOutputSamples = 0;
-
- dwSamples = InSize / lame_get_num_channels( gfp );
-
- if ( 1 == lame_get_num_channels( gfp ) )
- {
- nOutputSamples = lame_encode_buffer(gfp,(PSHORT)a_StreamHeader->pbSrc,(PSHORT)a_StreamHeader->pbSrc,dwSamples,a_StreamHeader->pbDst,a_StreamHeader->cbDstLength);
- }
- else
- {
- nOutputSamples = lame_encode_buffer_interleaved(gfp,(PSHORT)a_StreamHeader->pbSrc,dwSamples,a_StreamHeader->pbDst,a_StreamHeader->cbDstLength);
- }
-
- a_StreamHeader->cbSrcLengthUsed = a_StreamHeader->cbSrcLength;
- a_StreamHeader->cbDstLengthUsed = nOutputSamples;
-
- result = a_StreamHeader->cbDstLengthUsed <= a_StreamHeader->cbDstLength;
-
- my_debug->OutPut(DEBUG_LEVEL_FUNC_CODE, "UsedSize = %d / EncodedSize = %d, result = %d (%d <= %d)", InSize, OutSize, result, a_StreamHeader->cbDstLengthUsed, a_StreamHeader->cbDstLength);
-
-if (my_debug != NULL)
-{
-my_debug->OutPut(DEBUG_LEVEL_FUNC_DEBUG, "ACMStream::ConvertBuffer result = %d (0x%02X 0x%02X)",result,a_StreamHeader->pbDst[0],a_StreamHeader->pbDst[1]);
-}
-
- return result;
-}
-
-/* map frequency to a valid MP3 sample frequency
- *
- * Robert Hegemann 2000-07-01
- */
-static int
-map2MP3Frequency(int freq)
-{
- if (freq <= 8000)
- return 8000;
- if (freq <= 11025)
- return 11025;
- if (freq <= 12000)
- return 12000;
- if (freq <= 16000)
- return 16000;
- if (freq <= 22050)
- return 22050;
- if (freq <= 24000)
- return 24000;
- if (freq <= 32000)
- return 32000;
- if (freq <= 44100)
- return 44100;
-
- return 48000;
-}
-
-
-unsigned int ACMStream::GetOutputSampleRate(int samples_per_sec, int bitrate, int channels)
-{
- if (bitrate==0)
- bitrate = (64000*channels)/8;
-
- /// \todo pass through the same LAME routine
- unsigned int OutputFrequency;
- double compression_ratio = double(samples_per_sec * 16 * channels / (bitrate * 8));
- if (compression_ratio > 13.)
- OutputFrequency = map2MP3Frequency( int((10. * bitrate * 8) / (16 * channels)));
- else
- OutputFrequency = map2MP3Frequency( int(0.97 * samples_per_sec) );
-
- return OutputFrequency;
-
-}
-
View
85 lib/liblame/ACM/ACMStream.h
@@ -1,85 +0,0 @@
-/**
- *
- * Lame ACM wrapper, encode/decode MP3 based RIFF/AVI files in MS Windows
- *
- * Copyright (c) 2002 Steve Lhomme <steve.lhomme at free.fr>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-
-/*!
- \author Steve Lhomme
- \version \$Id: ACMStream.h,v 1.5 2006/12/25 21:37:34 robert Exp $
-*/
-
-#if !defined(_ACMSTREAM_H__INCLUDED_)
-#define _ACMSTREAM_H__INCLUDED_
-
-#if _MSC_VER >= 1000
-#pragma once
-#endif // _MSC_VER >= 1000
-
-#include <mmreg.h>
-#include <msacm.h>
-#include <msacmdrv.h>
-
-#include "ADbg/ADbg.h"
-
-#include "AEncodeProperties.h"
-
-
-typedef enum vbr_mode_e vbr_mode;
-typedef struct lame_global_struct lame_global_flags;
-
-
-class ACMStream
-{
-public:
- ACMStream( );
- virtual ~ACMStream( );
-
- static ACMStream * Create();
- static const bool Erase(const ACMStream * a_ACMStream);
-
- bool init(const int nSamplesPerSec, const int nOutputSamplesPerSec, const int nChannels, const int nAvgBytesPerSec, const vbr_mode mode);
- bool open(const AEncodeProperties & the_Properties);
- bool close(LPBYTE pOutputBuffer, DWORD *pOutputSize);
-
- DWORD GetOutputSizeForInput(const DWORD the_SrcLength) const;
- bool ConvertBuffer(LPACMDRVSTREAMHEADER a_StreamHeader);
-
- static unsigned int GetOutputSampleRate(int samples_per_sec, int bitrate, int channels);
-
-protected:
- lame_global_flags * gfp;
-
- ADbg * my_debug;
- int my_SamplesPerSec;
- int my_Channels;
- int my_AvgBytesPerSec;
- int my_OutBytesPerSec;
- vbr_mode my_VBRMode;
- DWORD my_SamplesPerBlock;
-
-unsigned int m_WorkingBufferUseSize;
- char m_WorkingBuffer[2304*2]; // should be at least twice my_SamplesPerBlock
-
-inline int GetBytesPerBlock(DWORD bytes_per_sec, DWORD samples_per_sec, int BlockAlign) const;
-
-};
-
-#endif // !defined(_ACMSTREAM_H__INCLUDED_)
-
View
181 lib/liblame/ACM/ADbg/ADbg.cpp
@@ -1,181 +0,0 @@
-/************************************************************************
-Project : C++ debugging class
-File version : 0.4
-
-BSD License post 1999 :
-
-Copyright (c) 2001, Steve Lhomme
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-- Redistributions of source code must retain the above copyright notice, this
-list of conditions and the following disclaimer.
-
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-
-- The name of the author may not be used to endorse or promote products derived
-from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
-WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
-EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
-OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
-IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
-OF SUCH DAMAGE.
-************************************************************************/
-
-#include <stdio.h>
-#include <stdarg.h>
-#include <windows.h>
-
-#include "ADbg.h"
-
-#if !defined(NDEBUG)
-
-//////////////////////////////////////////////////////////////////////
-// Construction/Destruction
-//////////////////////////////////////////////////////////////////////
-
-ADbg::ADbg(int level)
-:my_level(level)
-,my_time_included(false)
-,my_use_file(false)
-,my_debug_output(true)
-,hFile(NULL)
-{
- prefix[0] = '\0';
- OutPut(-1,"ADbg Creation at debug level = %d (0x%08X)",my_level,this);
-}
-
-ADbg::~ADbg()
-{
- unsetDebugFile();
- OutPut(-1,"ADbg Deletion (0x%08X)",this);
-}
-
-inline int ADbg::_OutPut(const char * format,va_list params) const
-{
- int result;
-
- char tst[1000];
- char myformat[256];
-
- if (my_time_included) {
- SYSTEMTIME time;
- GetSystemTime(&time);
- if (prefix[0] == '\0')
- wsprintf(myformat,"%04d/%02d/%02d %02d:%02d:%02d.%03d UTC : %s\r\n",
- time.wYear,
- time.wMonth,
- time.wDay,
- time.wHour,
- time.wMinute,
- time.wSecond,
- time.wMilliseconds,
- format);
- else
- wsprintf(myformat,"%04d/%02d/%02d %02d:%02d:%02d.%03d UTC : %s - %s\r\n",
- time.wYear,
- time.wMonth,
- time.wDay,
- time.wHour,
- time.wMinute,
- time.wSecond,
- time.wMilliseconds,
- prefix,
- format);
- } else {
- if (prefix[0] == '\0')
- wsprintf( myformat, "%s\r\n", format);
- else
- wsprintf( myformat, "%s - %s\r\n", prefix, format);
- }
-
- result = vsprintf(tst,myformat,params);
-
- if (my_debug_output)
- OutputDebugString(tst);
-
- if (my_use_file && (hFile != NULL)) {
- SetFilePointer( hFile, 0, 0, FILE_END );
- DWORD written;
- WriteFile( hFile, tst, lstrlen(tst), &written, NULL );
- }
-
- return result;
-}
-
-int ADbg::OutPut(int forLevel, const char * format,...) const
-{
- int result=0;
-
- if (forLevel >= my_level) {
- va_list tstlist;
- int result;
-
- va_start(tstlist, format);
-
- result = _OutPut(format,tstlist);
-
- }
-
- return result;
-}
-
-int ADbg::OutPut(const char * format,...) const
-{
- va_list tstlist;
-
- va_start(tstlist, format);
-
- return _OutPut(format,tstlist);
-}
-
-bool ADbg::setDebugFile(const char * NewFilename) {
- bool result;
- result = unsetDebugFile();
-
- if (result) {
- result = false;
-
- hFile = CreateFile(NewFilename, GENERIC_WRITE, FILE_SHARE_WRITE|FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
-
- if (hFile != INVALID_HANDLE_VALUE) {
- SetFilePointer( hFile, 0, 0, FILE_END );
-
- result = true;
-
- OutPut(-1,"Debug file Opening succeeded");
-
- }
- else
- OutPut(-1,"Debug file %s Opening failed",NewFilename);
- }
-
- return result;
-}
-
-bool ADbg::unsetDebugFile() {
- bool result = (hFile == NULL);
-
- if (hFile != NULL) {
- result = (CloseHandle(hFile) != 0);
-
- if (result) {
- OutPut(-1,"Debug file Closing succeeded");
- hFile = NULL;
- }
- }
-
- return result;
-}
-
-#endif // !defined(NDEBUG)
View
102 lib/liblame/ACM/ADbg/ADbg.dsp
@@ -1,102 +0,0 @@
-# Microsoft Developer Studio Project File - Name="ADbg" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** NICHT BEARBEITEN **
-
-# TARGTYPE "Win32 (x86) Static Library" 0x0104
-
-CFG=ADbg - Win32 Debug
-!MESSAGE Dies ist kein g�ltiges Makefile. Zum Erstellen dieses Projekts mit NMAKE
-!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und f�hren Sie den Befehl
-!MESSAGE
-!MESSAGE NMAKE /f "ADbg.mak".
-!MESSAGE
-!MESSAGE Sie k�nnen beim Ausf�hren von NMAKE eine Konfiguration angeben
-!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel:
-!MESSAGE
-!MESSAGE NMAKE /f "ADbg.mak" CFG="ADbg - Win32 Debug"
-!MESSAGE
-!MESSAGE F�r die Konfiguration stehen zur Auswahl:
-!MESSAGE
-!MESSAGE "ADbg - Win32 Release" (basierend auf "Win32 (x86) Static Library")
-!MESSAGE "ADbg - Win32 Debug" (basierend auf "Win32 (x86) Static Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "ADbg - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\..\obj\Release"
-# PROP Intermediate_Dir "..\..\obj\Release\ADbg"
-# PROP Target_Dir ""
-LINK32=link.exe
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD BASE RSC /l 0x40c
-# ADD RSC /l 0x40c
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo
-
-!ELSEIF "$(CFG)" == "ADbg - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "..\..\obj\Debug"
-# PROP Intermediate_Dir "..\..\obj\Debug\ADbg"
-# PROP Target_Dir ""
-LINK32=link.exe
-# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD BASE RSC /l 0x40c
-# ADD RSC /l 0x40c
-BSC32=bscmake.exe