3 |
* XVID MPEG-4 VIDEO CODEC |
* XVID MPEG-4 VIDEO CODEC |
4 |
* - XviD Decoder part of the DShow Filter - |
* - XviD Decoder part of the DShow Filter - |
5 |
* |
* |
6 |
* Copyright(C) 2002-2003 Peter Ross <pross@xvid.org> |
* Copyright(C) 2002-2010 Peter Ross <pross@xvid.org> |
7 |
* |
* |
8 |
* This program is free software ; you can redistribute it and/or modify |
* This program is free software ; you can redistribute it and/or modify |
9 |
* it under the terms of the GNU General Public License as published by |
* it under the terms of the GNU General Public License as published by |
19 |
* along with this program ; if not, write to the Free Software |
* along with this program ; if not, write to the Free Software |
20 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 |
* |
* |
22 |
* $Id: CXvidDecoder.h,v 1.4 2004-07-16 15:38:01 syskin Exp $ |
* $Id: CXvidDecoder.h,v 1.9 2010-10-17 18:31:46 Isibaar Exp $ |
23 |
* |
* |
24 |
****************************************************************************/ |
****************************************************************************/ |
25 |
|
|
29 |
#include <xvid.h> |
#include <xvid.h> |
30 |
#include "IXvidDecoder.h" |
#include "IXvidDecoder.h" |
31 |
|
|
32 |
|
#define XVID_NAME_L L"Xvid MPEG-4 Video Decoder" |
|
#define XVID_NAME_L L"XviD MPEG-4 Video Decoder" |
|
33 |
|
|
34 |
/* --- fourcc --- */ |
/* --- fourcc --- */ |
35 |
|
|
36 |
#define FOURCC_XVID mmioFOURCC('X','V','I','D') |
#define FOURCC_XVID mmioFOURCC('X','V','I','D') |
37 |
#define FOURCC_DIVX mmioFOURCC('D','I','V','X') |
#define FOURCC_DIVX mmioFOURCC('D','I','V','X') |
38 |
#define FOURCC_DX50 mmioFOURCC('D','X','5','0') |
#define FOURCC_DX50 mmioFOURCC('D','X','5','0') |
39 |
#define FOURCC_MP4V mmioFOURCC('m','p','4','v') |
#define FOURCC_MP4V mmioFOURCC('M','P','4','V') |
40 |
|
#define FOURCC_mp4v mmioFOURCC('m','p','4','v') |
41 |
|
|
42 |
/* --- media uids --- */ |
/* --- media uids --- */ |
43 |
|
|
48 |
DEFINE_GUID(CLSID_DX50, mmioFOURCC('d','x','5','0'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71); |
DEFINE_GUID(CLSID_DX50, mmioFOURCC('d','x','5','0'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71); |
49 |
DEFINE_GUID(CLSID_DX50_UC, mmioFOURCC('D','X','5','0'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71); |
DEFINE_GUID(CLSID_DX50_UC, mmioFOURCC('D','X','5','0'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71); |
50 |
DEFINE_GUID(CLSID_MP4V, mmioFOURCC('m','p','4','v'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71); |
DEFINE_GUID(CLSID_MP4V, mmioFOURCC('m','p','4','v'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71); |
51 |
|
DEFINE_GUID(CLSID_MP4V_UC, mmioFOURCC('M','P','4','V'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71); |
52 |
|
|
53 |
|
|
54 |
/* MEDIATYPE_IYUV is not always defined in the directx headers */ |
/* MEDIATYPE_IYUV is not always defined in the directx headers */ |
55 |
DEFINE_GUID(CLSID_MEDIASUBTYPE_IYUV, 0x56555949, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71); |
DEFINE_GUID(CLSID_MEDIASUBTYPE_IYUV, 0x56555949, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71); |
56 |
|
|
57 |
|
|
58 |
class CXvidDecoder : public CVideoTransformFilter, public IXvidDecoder, public ISpecifyPropertyPages |
class CXvidDecoder : |
59 |
|
public CVideoTransformFilter, |
60 |
|
public IXvidDecoder, |
61 |
|
public ISpecifyPropertyPages |
62 |
|
#if defined(XVID_USE_MFT) |
63 |
|
,public IMFTransform |
64 |
|
#endif |
65 |
{ |
{ |
66 |
|
|
67 |
public : |
public : |
73 |
CXvidDecoder(LPUNKNOWN punk, HRESULT *phr); |
CXvidDecoder(LPUNKNOWN punk, HRESULT *phr); |
74 |
~CXvidDecoder(); |
~CXvidDecoder(); |
75 |
|
|
76 |
|
HRESULT CompleteConnect(PIN_DIRECTION direction, IPin *pReceivePin); |
77 |
|
HRESULT BreakConnect(PIN_DIRECTION dir); |
78 |
|
|
79 |
HRESULT CheckInputType(const CMediaType * mtIn); |
HRESULT CheckInputType(const CMediaType * mtIn); |
80 |
HRESULT GetMediaType(int iPos, CMediaType * pmt); |
HRESULT GetMediaType(int iPos, CMediaType * pmt); |
81 |
HRESULT SetMediaType(PIN_DIRECTION direction, const CMediaType *pmt); |
HRESULT SetMediaType(PIN_DIRECTION direction, const CMediaType *pmt); |
88 |
STDMETHODIMP GetPages(CAUUID * pPages); |
STDMETHODIMP GetPages(CAUUID * pPages); |
89 |
STDMETHODIMP FreePages(CAUUID * pPages); |
STDMETHODIMP FreePages(CAUUID * pPages); |
90 |
|
|
91 |
|
/* IMFTransform */ |
92 |
|
#if defined(XVID_USE_MFT) |
93 |
|
STDMETHODIMP MFTGetStreamLimits(DWORD *pdwInputMinimum, DWORD *pdwInputMaximum, DWORD *pdwOutputMinimum, DWORD *pdwOutputMaximum); |
94 |
|
STDMETHODIMP MFTGetStreamCount(DWORD *pcInputStreams, DWORD *pcOutputStreams); |
95 |
|
STDMETHODIMP MFTGetStreamIDs(DWORD dwInputIDArraySize, DWORD *pdwInputIDs, DWORD dwOutputIDArraySize, DWORD *pdwOutputIDs); |
96 |
|
STDMETHODIMP MFTGetInputStreamInfo(DWORD dwInputStreamID, MFT_INPUT_STREAM_INFO *pStreamInfo); |
97 |
|
STDMETHODIMP MFTGetOutputStreamInfo(DWORD dwOutputStreamID, MFT_OUTPUT_STREAM_INFO *pStreamInfo); |
98 |
|
STDMETHODIMP GetAttributes(IMFAttributes** pAttributes); |
99 |
|
STDMETHODIMP GetInputStreamAttributes(DWORD dwInputStreamID, IMFAttributes **ppAttributes); |
100 |
|
STDMETHODIMP GetOutputStreamAttributes(DWORD dwOutputStreamID, IMFAttributes **ppAttributes); |
101 |
|
STDMETHODIMP MFTDeleteInputStream(DWORD dwStreamID); |
102 |
|
STDMETHODIMP MFTAddInputStreams(DWORD cStreams, DWORD *adwStreamIDs); |
103 |
|
STDMETHODIMP MFTGetInputAvailableType(DWORD dwInputStreamID, DWORD dwTypeIndex, IMFMediaType **ppType); |
104 |
|
STDMETHODIMP MFTGetOutputAvailableType(DWORD dwOutputStreamID, DWORD dwTypeIndex, IMFMediaType **ppType); |
105 |
|
STDMETHODIMP MFTSetInputType(DWORD dwInputStreamID, IMFMediaType *pType, DWORD dwFlags); |
106 |
|
STDMETHODIMP MFTSetOutputType(DWORD dwOutputStreamID, IMFMediaType *pType, DWORD dwFlags); |
107 |
|
STDMETHODIMP MFTGetInputCurrentType(DWORD dwInputStreamID, IMFMediaType **ppType); |
108 |
|
STDMETHODIMP MFTGetOutputCurrentType(DWORD dwOutputStreamID, IMFMediaType **ppType); |
109 |
|
STDMETHODIMP MFTGetInputStatus(DWORD dwInputStreamID, DWORD *pdwFlags); |
110 |
|
STDMETHODIMP MFTGetOutputStatus(DWORD *pdwFlags); |
111 |
|
STDMETHODIMP MFTSetOutputBounds(LONGLONG hnsLowerBound, LONGLONG hnsUpperBound); |
112 |
|
STDMETHODIMP MFTProcessEvent(DWORD dwInputStreamID, IMFMediaEvent *pEvent); |
113 |
|
STDMETHODIMP MFTProcessMessage(MFT_MESSAGE_TYPE eMessage, ULONG_PTR ulParam); |
114 |
|
|
115 |
|
STDMETHODIMP MFTProcessInput(DWORD dwInputStreamID, IMFSample *pSample, DWORD dwFlags); |
116 |
|
STDMETHODIMP MFTProcessOutput(DWORD dwFlags, DWORD cOutputBufferCount, MFT_OUTPUT_DATA_BUFFER *pOutputSamples, DWORD *pdwStatus); |
117 |
|
#endif /* XVID_USE_MFT */ |
118 |
|
|
119 |
private : |
private : |
120 |
|
|
121 |
HRESULT ChangeColorspace(GUID subtype, GUID formattype, void * format); |
HRESULT ChangeColorspace(GUID subtype, GUID formattype, void * format); |
122 |
|
HRESULT OpenLib(); |
123 |
void CloseLib(); |
void CloseLib(); |
124 |
|
|
125 |
xvid_dec_create_t m_create; |
xvid_dec_create_t m_create; |
132 |
bool forced_ar; |
bool forced_ar; |
133 |
|
|
134 |
int rgb_flip; |
int rgb_flip; |
135 |
|
int out_stride; |
136 |
|
|
137 |
|
/* mft stuff */ |
138 |
|
#if defined(XVID_USE_MFT) |
139 |
|
BOOL HasPendingOutput() const { return m_frame.output.plane[1] != NULL; } |
140 |
|
|
141 |
|
HRESULT OnSetInputType(IMFMediaType *pmt); |
142 |
|
HRESULT OnCheckInputType(IMFMediaType *pmt); |
143 |
|
|
144 |
|
HRESULT OnSetOutputType(IMFMediaType *pmt); |
145 |
|
|
146 |
|
IMFMediaType *m_pInputType; |
147 |
|
IMFMediaType *m_pOutputType; |
148 |
|
|
149 |
|
CRITICAL_SECTION m_mft_lock; |
150 |
|
REFERENCE_TIME m_timestamp; |
151 |
|
REFERENCE_TIME m_timelength; |
152 |
|
|
153 |
|
int m_discont; |
154 |
|
|
155 |
|
/* Used to construct or interpolate missing timestamps */ |
156 |
|
REFERENCE_TIME m_rtFrame; |
157 |
|
MFRatio m_frameRate; |
158 |
|
UINT64 m_duration; |
159 |
|
#endif |
160 |
|
|
161 |
|
#ifdef XVID_USE_TRAYICON |
162 |
|
HWND MSG_hwnd; /* message handler window */ |
163 |
|
}; |
164 |
|
#define WM_ICONMESSAGE (WM_USER + 1) |
165 |
|
#else |
166 |
}; |
}; |
167 |
|
#endif |
168 |
|
|
169 |
static const int PARS[][2] = { |
static const int PARS[][2] = { |
170 |
{1, 1}, |
{1, 1}, |
175 |
{0, 0}, |
{0, 0}, |
176 |
}; |
}; |
177 |
|
|
|
|
|
178 |
#endif /* _FILTER_H_ */ |
#endif /* _FILTER_H_ */ |