MpaDecFilter.h
上传用户:xjjlds
上传日期:2015-12-05
资源大小:22823k
文件大小:4k
- /*
- * Copyright (C) 2003-2005 Gabest
- * http://www.gabest.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
- #pragma once
- #include <atlcoll.h>
- #include <afxtempl.h>
- #include "libmad-0.15.0bmsvc++mad.h"
- #include "a52dec-0.7.4vc++inttypes.h"
- #include "a52dec-0.7.4includea52.h"
- #include "dtsdec-0.0.1includedts.h"
- // #include "faad2includeneaacdec.h" // conflicts with dxtrans.h
- #include "......decssDeCSSInputPin.h"
- #include "IMpaDecFilter.h"
- struct aac_state_t
- {
- void* h; // NeAACDecHandle h;
- DWORD freq;
- BYTE channels;
- aac_state_t();
- ~aac_state_t();
- bool open();
- void close();
- bool init(CMediaType& mt);
- };
- struct ps2_state_t
- {
- bool sync;
- double a[2], b[2];
- struct ps2_state_t() {reset();}
- void reset() {sync = false; a[0] = a[1] = b[0] = b[1] = 0;}
- };
- [uuid("3D446B6F-71DE-4437-BE15-8CE47174340F")]
- class CMpaDecFilter : public CTransformFilter, public IMpaDecFilter
- {
- protected:
- CCritSec m_csReceive;
- a52_state_t* m_a52_state;
- dts_state_t* m_dts_state;
- aac_state_t m_aac_state;
- mad_stream m_stream;
- mad_frame m_frame;
- mad_synth m_synth;
- ps2_state_t m_ps2_state;
- CArray<BYTE> m_buff;
- REFERENCE_TIME m_rtStart;
- bool m_fDiscontinuity;
- float m_sample_max;
- HRESULT ProcessLPCM();
- HRESULT ProcessAC3();
- HRESULT ProcessDTS();
- HRESULT ProcessAAC();
- HRESULT ProcessPS2PCM();
- HRESULT ProcessPS2ADPCM();
- HRESULT ProcessMPA();
- HRESULT GetDeliveryBuffer(IMediaSample** pSample, BYTE** pData);
- HRESULT Deliver(CArray<float>& pBuff, DWORD nSamplesPerSec, WORD nChannels, DWORD dwChannelMask = 0);
- HRESULT Deliver(BYTE* pBuff, int size, int bit_rate, BYTE type);
- HRESULT ReconnectOutput(int nSamples, CMediaType& mt);
- CMediaType CreateMediaType(SampleFormat sf, DWORD nSamplesPerSec, WORD nChannels, DWORD dwChannelMask = 0);
- CMediaType CreateMediaTypeSPDIF();
- protected:
- CCritSec m_csProps;
- SampleFormat m_iSampleFormat;
- bool m_fNormalize;
- int m_iSpeakerConfig[etlast];
- bool m_fDynamicRangeControl[etlast];
- float m_boost;
- public:
- CMpaDecFilter(LPUNKNOWN lpunk, HRESULT* phr);
- virtual ~CMpaDecFilter();
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- HRESULT EndOfStream();
- HRESULT BeginFlush();
- HRESULT EndFlush();
- HRESULT NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
- HRESULT Receive(IMediaSample* pIn);
- HRESULT CheckInputType(const CMediaType* mtIn);
- HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
- HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT GetMediaType(int iPosition, CMediaType* pMediaType);
- HRESULT StartStreaming();
- HRESULT StopStreaming();
- // IMpaDecFilter
- STDMETHODIMP SetSampleFormat(SampleFormat sf);
- STDMETHODIMP_(SampleFormat) GetSampleFormat();
- STDMETHODIMP SetNormalize(bool fNormalize);
- STDMETHODIMP_(bool) GetNormalize();
- STDMETHODIMP SetSpeakerConfig(enctype et, int sc);
- STDMETHODIMP_(int) GetSpeakerConfig(enctype et);
- STDMETHODIMP SetDynamicRangeControl(enctype et, bool fDRC);
- STDMETHODIMP_(bool) GetDynamicRangeControl(enctype et);
- STDMETHODIMP SetBoost(float boost);
- STDMETHODIMP_(float) GetBoost();
- };
- class CMpaDecInputPin : public CDeCSSInputPin
- {
- public:
- CMpaDecInputPin(CTransformFilter* pFilter, HRESULT* phr, LPWSTR pName);
- };