ACMStream.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /**
  2. *
  3. * Lame ACM wrapper, encode/decode MP3 based RIFF/AVI files in MS Windows
  4. *
  5. * Copyright (c) 2002 Steve Lhomme <steve.lhomme at free.fr>
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. *
  21. */
  22. /*!
  23. \author Steve Lhomme
  24. \version \$Id$
  25. */
  26. #if !defined(_ACMSTREAM_H__INCLUDED_)
  27. #define _ACMSTREAM_H__INCLUDED_
  28. #if _MSC_VER >= 1000
  29. #pragma once
  30. #endif // _MSC_VER >= 1000
  31. #include <mmreg.h>
  32. #include <msacm.h>
  33. #include <msacmdrv.h>
  34. #include "ADbg/ADbg.h"
  35. #include "AEncodeProperties.h"
  36. typedef enum vbr_mode_e vbr_mode;
  37. typedef struct lame_global_struct lame_global_flags;
  38. class ACMStream
  39. {
  40. public:
  41. ACMStream( );
  42. virtual ~ACMStream( );
  43. static ACMStream * Create();
  44. static const bool Erase(const ACMStream * a_ACMStream);
  45. bool init(const int nSamplesPerSec, const int nOutputSamplesPerSec, const int nChannels, const int nAvgBytesPerSec, const vbr_mode mode);
  46. bool open(const AEncodeProperties & the_Properties);
  47. bool close(LPBYTE pOutputBuffer, DWORD *pOutputSize);
  48. DWORD GetOutputSizeForInput(const DWORD the_SrcLength) const;
  49. bool ConvertBuffer(LPACMDRVSTREAMHEADER a_StreamHeader);
  50. static unsigned int GetOutputSampleRate(int samples_per_sec, int bitrate, int channels);
  51. protected:
  52. lame_global_flags * gfp;
  53. ADbg * my_debug;
  54. int my_SamplesPerSec;
  55. int my_Channels;
  56. int my_AvgBytesPerSec;
  57. int my_OutBytesPerSec;
  58. vbr_mode my_VBRMode;
  59. DWORD my_SamplesPerBlock;
  60. unsigned int m_WorkingBufferUseSize;
  61. char m_WorkingBuffer[2304*2]; // should be at least twice my_SamplesPerBlock
  62. inline int GetBytesPerBlock(DWORD bytes_per_sec, DWORD samples_per_sec, int BlockAlign) const;
  63. };
  64. #endif // !defined(_ACMSTREAM_H__INCLUDED_)