- Main Page
- Namespaces
- Classes
- Files
- Directories

- File List
- File Members

# MpaDecFilter.h

    00001 /*
    00002  *      Copyright (C) 2003-2005 Gabest
    00003  *      http://www.gabest.org
    00004  *
    00005  *  This Program is free software; you can redistribute it and/or modify
    00006  *  it under the terms of the GNU General Public License as published by
    00007  *  the Free Software Foundation; either version 2, or (at your option)
    00008  *  any later version.
    00009  *
    00010  *  This Program is distributed in the hope that it will be useful,
    00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    00013  *  GNU General Public License for more details.
    00014  *
    00015  *  You should have received a copy of the GNU General Public License
    00016  *  along with GNU Make; see the file COPYING.  If not, write to
    00017  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
    00018  *  http://www.gnu.org/copyleft/gpl.html
    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 // #include "faad2\include\neaacdec.h" // conflicts with dxtrans.h
    00031 #include "..\..\..\decss\DeCSSInputPin.h"
    00032 #include "IMpaDecFilter.h"
    00033
    00034 struct aac_state_t
    00035 {
    00036         void* h; // NeAACDecHandle 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         // IMpaDecFilter
    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 };