00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #pragma once
00023
00024 #include <atlcoll.h>
00025 #include <afxtempl.h>
00026 #include "libmad-0.15.0b\msvc++\mad.h"
00027 #include "a52dec-0.7.4\vc++\inttypes.h"
00028 #include "a52dec-0.7.4\include\a52.h"
00029 #include "dtsdec-0.0.1\include\dts.h"
00030
00031 #include "..\..\..\decss\DeCSSInputPin.h"
00032 #include "IMpaDecFilter.h"
00033
00034 struct aac_state_t
00035 {
00036 void* h;
00037 DWORD freq;
00038 BYTE channels;
00039
00040 aac_state_t();
00041 ~aac_state_t();
00042 bool open();
00043 void close();
00044 bool init(CMediaType& mt);
00045 };
00046
00047 struct ps2_state_t
00048 {
00049 bool sync;
00050 double a[2], b[2];
00051 struct ps2_state_t() {reset();}
00052 void reset() {sync = false; a[0] = a[1] = b[0] = b[1] = 0;}
00053 };
00054
00055 [uuid("3D446B6F-71DE-4437-BE15-8CE47174340F")]
00056 class CMpaDecFilter : public CTransformFilter, public IMpaDecFilter
00057 {
00058 protected:
00059 CCritSec m_csReceive;
00060
00061 a52_state_t* m_a52_state;
00062 dts_state_t* m_dts_state;
00063 aac_state_t m_aac_state;
00064 mad_stream m_stream;
00065 mad_frame m_frame;
00066 mad_synth m_synth;
00067 ps2_state_t m_ps2_state;
00068
00069 CArray<BYTE> m_buff;
00070 REFERENCE_TIME m_rtStart;
00071 bool m_fDiscontinuity;
00072
00073 float m_sample_max;
00074
00075 HRESULT ProcessLPCM();
00076 HRESULT ProcessAC3();
00077 HRESULT ProcessDTS();
00078 HRESULT ProcessAAC();
00079 HRESULT ProcessPS2PCM();
00080 HRESULT ProcessPS2ADPCM();
00081 HRESULT ProcessMPA();
00082
00083 HRESULT GetDeliveryBuffer(IMediaSample** pSample, BYTE** pData);
00084 HRESULT Deliver(CArray<float>& pBuff, DWORD nSamplesPerSec, WORD nChannels, DWORD dwChannelMask = 0);
00085 HRESULT Deliver(BYTE* pBuff, int size, int bit_rate, BYTE type);
00086 HRESULT ReconnectOutput(int nSamples, CMediaType& mt);
00087 CMediaType CreateMediaType(SampleFormat sf, DWORD nSamplesPerSec, WORD nChannels, DWORD dwChannelMask = 0);
00088 CMediaType CreateMediaTypeSPDIF();
00089
00090 protected:
00091 CCritSec m_csProps;
00092 SampleFormat m_iSampleFormat;
00093 bool m_fNormalize;
00094 int m_iSpeakerConfig[etlast];
00095 bool m_fDynamicRangeControl[etlast];
00096 float m_boost;
00097
00098 public:
00099 CMpaDecFilter(LPUNKNOWN lpunk, HRESULT* phr);
00100 virtual ~CMpaDecFilter();
00101
00102 DECLARE_IUNKNOWN
00103 STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
00104
00105 HRESULT EndOfStream();
00106 HRESULT BeginFlush();
00107 HRESULT EndFlush();
00108 HRESULT NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
00109 HRESULT Receive(IMediaSample* pIn);
00110
00111 HRESULT CheckInputType(const CMediaType* mtIn);
00112 HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
00113 HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
00114 HRESULT GetMediaType(int iPosition, CMediaType* pMediaType);
00115
00116 HRESULT StartStreaming();
00117 HRESULT StopStreaming();
00118
00119
00120
00121 STDMETHODIMP SetSampleFormat(SampleFormat sf);
00122 STDMETHODIMP_(SampleFormat) GetSampleFormat();
00123 STDMETHODIMP SetNormalize(bool fNormalize);
00124 STDMETHODIMP_(bool) GetNormalize();
00125 STDMETHODIMP SetSpeakerConfig(enctype et, int sc);
00126 STDMETHODIMP_(int) GetSpeakerConfig(enctype et);
00127 STDMETHODIMP SetDynamicRangeControl(enctype et, bool fDRC);
00128 STDMETHODIMP_(bool) GetDynamicRangeControl(enctype et);
00129 STDMETHODIMP SetBoost(float boost);
00130 STDMETHODIMP_(float) GetBoost();
00131 };
00132
00133 class CMpaDecInputPin : public CDeCSSInputPin
00134 {
00135 public:
00136 CMpaDecInputPin(CTransformFilter* pFilter, HRESULT* phr, LPWSTR pName);
00137 };