- Main Page
- Namespaces
- Classes
- Files
- Directories

- File List
- File Members

# FLICSource.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 <atlbase.h>
    00025 #include <afxtempl.h>
    00026
    00027 #pragma pack(push, 1)
    00028 enum
    00029 {
    00030         FLIC_256_COLOR = 4,
    00031         FLIC_DELTA = 7,
    00032         FLIC_64_COLOR = 11,
    00033         FLIC_LC = 12,
    00034         FLIC_BLACK = 13,
    00035         FLIC_BRUN = 15,
    00036         FLIC_COPY = 16,
    00037         FLIC_MINI = 18
    00038 };
    00039
    00040 struct FLIC
    00041 {
    00042         DWORD size;
    00043         WORD id; // 0xaf11 or 0xaf12
    00044         WORD frames, x, y, bpp;
    00045         WORD flags, ticks;
    00046         DWORD next, frit;
    00047         BYTE reserved[102];
    00048 };
    00049
    00050 struct FLIC_PREFIX
    00051 {
    00052         DWORD size;
    00053         WORD id; // 0xf100
    00054         WORD chunks;
    00055         BYTE reserved[8];
    00056 };
    00057
    00058 struct FLIC_FRAME
    00059 {
    00060         DWORD size;
    00061         WORD id; // 0xf1fa
    00062         WORD chunks;
    00063         BYTE reserved[8];
    00064 };
    00065
    00066 struct FLIC_CHUNK
    00067 {
    00068         DWORD size;
    00069         WORD type;
    00070 };
    00071 #pragma pack(pop)
    00072
    00073 struct FLIC_FRAME_ENTRY
    00074 {
    00075         __int64 pos;
    00076         bool fKeyframe;
    00077         FLIC_FRAME hdr;
    00078 };
    00079
    00080 [uuid("17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4")]
    00081 class CFLICSource
    00082         : public CSource
    00083         , public IFileSourceFilter
    00084         , public IAMFilterMiscFlags
    00085 {
    00086         CStringW m_fn;
    00087
    00088 public:
    00089         CFLICSource(LPUNKNOWN lpunk, HRESULT* phr);
    00090         virtual ~CFLICSource();
    00091
    00092         DECLARE_IUNKNOWN;
    00093     STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
    00094
    00095         // IFileSourceFilter
    00096         STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
    00097         STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt);
    00098
    00099         // IAMFilterMiscFlags
    00100         STDMETHODIMP_(ULONG) GetMiscFlags();
    00101 };
    00102
    00103 class CFLICStream
    00104         : public CSourceStream
    00105         , public CSourceSeeking
    00106 {
    00107         CFile m_flic;
    00108         FLIC m_hdr;
    00109         CArray<FLIC_FRAME_ENTRY> m_frames;
    00110
    00111         CCritSec m_cSharedState;
    00112
    00113         REFERENCE_TIME m_AvgTimePerFrame;
    00114         REFERENCE_TIME m_rtSampleTime, m_rtPosition;
    00115
    00116         BOOL m_bDiscontinuity, m_bFlushing;
    00117
    00118         HRESULT OnThreadStartPlay();
    00119         HRESULT OnThreadCreate();
    00120
    00121         void UpdateFromSeek();
    00122         STDMETHODIMP SetRate(double dRate);
    00123
    00124         HRESULT ChangeStart();
    00125     HRESULT ChangeStop();
    00126     HRESULT ChangeRate() {return S_OK;}
    00127
    00128 private:
    00129         int m_nLastFrameNum;
    00130         DWORD m_pPalette[256];
    00131         CAutoVectorPtr<BYTE> m_pFrameBuffer;
    00132
    00133         void SeekToNearestKeyFrame(int nFrame);
    00134         void ExtractFrame(int nFrame);
    00135         void _blackchunk();
    00136         void _copychunk();
    00137         bool _colorchunk(bool f64);
    00138         void _brunchunk();
    00139         void _lcchunk();
    00140         void _deltachunk();
    00141
    00142 public:
    00143     CFLICStream(const WCHAR* wfn, CFLICSource* pParent, HRESULT* phr);
    00144         virtual ~CFLICStream();
    00145
    00146     STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
    00147
    00148     HRESULT DecideBufferSize(IMemAllocator* pIMemAlloc, ALLOCATOR_PROPERTIES* pProperties);
    00149     HRESULT FillBuffer(IMediaSample* pSample);
    00150         HRESULT CheckConnect(IPin* pPin);
    00151     HRESULT CheckMediaType(const CMediaType* pMediaType);
    00152     HRESULT GetMediaType(int iPosition, CMediaType* pmt);
    00153
    00154         STDMETHODIMP Notify(IBaseFilter* pSender, Quality q);
    00155 };
    00156