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 /*!
24 	\author Steve Lhomme
25 	\version \$Id$
26 */
27 
28 #if !defined(_DECODESTREAM_H__INCLUDED_)
29 #define _DECODESTREAM_H__INCLUDED_
30 
31 #if _MSC_VER >= 1000
32 #pragma once
33 #endif // _MSC_VER >= 1000
34 
35 #include <mmreg.h>
36 #include <msacm.h>
37 #include <msacmdrv.h>
38 
39 #include "ADbg/ADbg.h"
40 
41 
42 struct lame_global_flags;
43 
44 
45 class DecodeStream
46 {
47 public:
48 	DecodeStream( );
49 	virtual ~DecodeStream( );
50 
51 	static DecodeStream * Create();
52 	static const bool Erase(const DecodeStream * a_ACMStream);
53 
54 	bool init(const int nSamplesPerSec, const int nChannels, const int nAvgBytesPerSec, const int nSourceBitrate);
55 	bool open();
56 	bool close(LPBYTE pOutputBuffer, DWORD *pOutputSize);
57 
58 	DWORD GetOutputSizeForInput(const DWORD the_SrcLength) const;
59 	bool  ConvertBuffer(LPACMDRVSTREAMHEADER a_StreamHeader);
60 
61 	static unsigned int GetOutputSampleRate(int samples_per_sec, int bitrate, int channels);
62 
63 protected:
64 	lame_global_flags * gfp;
65 
66 	ADbg * my_debug;
67 	int my_SamplesPerSec;
68 	int my_Channels;
69 	int my_AvgBytesPerSec;
70 	DWORD  my_SamplesPerBlock;
71 	int my_SourceBitrate;
72 
73 	MPSTR my_DecodeData;
74 
75 	unsigned int m_WorkingBufferUseSize;
76 	char m_WorkingBuffer[2304*2]; // should be at least twice my_SamplesPerBlock
77 
78 	inline int GetBytesPerBlock(DWORD bytes_per_sec, DWORD samples_per_sec, int BlockAlign) const;
79 
80 };
81 
82 #endif // !defined(_DECODESTREAM_H__INCLUDED_)
83 
84