Parent Directory | Revision Log
Revision 2096 - (view) (download)
1 : | Isibaar | 2096 | /***************************************************************************** |
2 : | * | ||
3 : | * Xvid MiniConvert | ||
4 : | * - Header for helper filters - | ||
5 : | * | ||
6 : | * Copyright(C) 2011-2014 Xvid Solutions GmbH | ||
7 : | * | ||
8 : | * 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 | ||
10 : | * the Free Software Foundation ; either version 2 of the License, or | ||
11 : | * (at your option) any later version. | ||
12 : | * | ||
13 : | * This program is distributed in the hope that it will be useful, | ||
14 : | * but WITHOUT ANY WARRANTY ; without even the implied warranty of | ||
15 : | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 : | * GNU General Public License for more details. | ||
17 : | * | ||
18 : | * You should have received a copy of the GNU General Public License | ||
19 : | * along with this program ; if not, write to the Free Software | ||
20 : | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
21 : | * | ||
22 : | * $Id: filters.h 2080 2014-04-08 20:01:07Z Isibaar $ | ||
23 : | * | ||
24 : | ****************************************************************************/ | ||
25 : | /* | ||
26 : | * Author(s): Ireneusz Hallmann | ||
27 : | * | ||
28 : | ****************************************************************************/ | ||
29 : | |||
30 : | #ifndef _FILTERS_H_ | ||
31 : | #define _FILTERS_H_ | ||
32 : | |||
33 : | // {4A4FA86F-789F-4912-B547-C4BFAA6D2D96} | ||
34 : | static const GUID CLSID_ChangeSubtypeT = | ||
35 : | { 0x4a4fa86f, 0x789f, 0x4912, { 0xb5, 0x47, 0xc4, 0xbf, 0xaa, 0x6d, 0x2d, 0x96 } }; | ||
36 : | |||
37 : | // {31550865-FA54-4019-89F4-A1A77083BD06} | ||
38 : | static const GUID IID_IRecProgressNotify = | ||
39 : | { 0x31550865, 0xfa54, 0x4019, { 0x89, 0xf4, 0xa1, 0xa7, 0x70, 0x83, 0xbd, 0x6 } }; | ||
40 : | |||
41 : | // {6C203582-9CB7-4775-81BA-CAE05D7DB9C6} | ||
42 : | static const GUID CLSID_ProgressNotifyFilter = | ||
43 : | { 0x6c203582, 0x9cb7, 0x4775, { 0x81, 0xba, 0xca, 0xe0, 0x5d, 0x7d, 0xb9, 0xc6 } }; | ||
44 : | |||
45 : | // 00000050-0000-0010-8000-00AA00389B71 MEDIASUBTYPE_MP3 | ||
46 : | static const GUID MEDIASUBTYPE_MP3 = | ||
47 : | { 0x00000055, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 } }; | ||
48 : | |||
49 : | // 6B6D0801-9ADA-11D0-A520-00A0D10129C0 | ||
50 : | static const GUID MEDIASUBTYPE_ASF = | ||
51 : | {0x6B6D0801, 0x9ADA, 0x11D0, { 0xA5, 0x20, 0x00, 0xA0, 0xD1, 0x01, 0x29, 0xC0 } }; | ||
52 : | |||
53 : | static const GUID CLSID_HaaliMediaSplitter_AR = | ||
54 : | {0x564fd788, 0x86c9, 0x4444, { 0x97, 0x1e, 0xcc, 0x4a, 0x24, 0x3d, 0xa1, 0x50 } }; | ||
55 : | |||
56 : | static const GUID CLSID_HaaliMediaSplitter = | ||
57 : | {0x55DA30FC, 0xF16B, 0x49FC, { 0xBA, 0xA5, 0xAE, 0x59, 0xFC, 0x65, 0xF8, 0x2D } }; | ||
58 : | |||
59 : | // B98D13E7-55DB-4385-A33D-09FD1BA26338 | ||
60 : | static const GUID CLSID_LAVSource = | ||
61 : | { 0xB98D13E7, 0x55DB, 0x4385, { 0xA3, 0x3D, 0x09, 0xFD, 0x1B, 0xA2, 0x63, 0x38 }}; | ||
62 : | |||
63 : | // 171252A0-8820-4AFE-9DF8-5C92B2D66B04 | ||
64 : | static const GUID CLSID_LAVSplitter = | ||
65 : | { 0x171252A0, 0x8820, 0x4AFE, { 0x9D, 0xF8, 0x5C, 0x92, 0xB2, 0xD6, 0x6B, 0x04 }}; | ||
66 : | |||
67 : | // 0F40E1E5-4F79-4988-B1A9-CC98794E6B55 | ||
68 : | static const GUID CLSID_FFDshowAudioDecoder = | ||
69 : | { 0x0F40E1E5, 0x4F79, 0x4988, { 0xB1, 0xA9, 0xCC, 0x98, 0x79, 0x4E, 0x6B, 0x55 }}; | ||
70 : | |||
71 : | // 04FE9017-F873-410E-871E-AB91661A4EF7 | ||
72 : | static const GUID CLSID_FFDshowVideoDecoder = | ||
73 : | { 0x04FE9017, 0xF873, 0x410E, { 0x87, 0x1E, 0xAB, 0x91, 0x66, 0x1A, 0x4E, 0xF7 }}; | ||
74 : | |||
75 : | DECLARE_INTERFACE_(IRecProgressNotify, IUnknown) | ||
76 : | { | ||
77 : | STDMETHOD (SetPass)(int in_Pass) PURE; | ||
78 : | STDMETHOD (SetTotalFrames)(DWORD in_TotalFrames) PURE; | ||
79 : | STDMETHOD (SetNotifyWnd)(HWND in_hWnd) PURE; | ||
80 : | STDMETHOD (GetBitrate)(DWORD &OutFramesCount, LONGLONG &OutTotalDataSize) PURE; | ||
81 : | STDMETHOD (GetDimensions)(DWORD &Width, DWORD &Height) PURE; | ||
82 : | STDMETHOD (SetTotalSize)(int nbTotal) PURE; | ||
83 : | STDMETHOD (SetElapsedSize)(int nbElapsed) PURE; | ||
84 : | STDMETHOD (SetCurSize)(int nbCur) PURE; | ||
85 : | STDMETHOD (GetMeasuredTimes) (LONGLONG &outStopTimeMin, LONGLONG &outStopTimeMax, LONGLONG &outm_StartTimeMin, LONGLONG &outm_StartTimeMax) PURE; | ||
86 : | STDMETHOD (SetForceTimeParams) (LONGLONG inStartTimeOffset, LONGLONG inFpsNom, LONGLONG inFpsDen) PURE; | ||
87 : | STDMETHOD (SetAudioBitrate) (int Bitrate) PURE; | ||
88 : | }; | ||
89 : | |||
90 : | class CIRecProgressNotify : public IRecProgressNotify | ||
91 : | { | ||
92 : | protected: | ||
93 : | int m_Pass; | ||
94 : | HWND m_MessageWnd; | ||
95 : | DWORD m_TotalFrames; | ||
96 : | int m_SampleCnt; | ||
97 : | LONGLONG m_TotalDataSize; | ||
98 : | int m_Type; | ||
99 : | LONGLONG m_startTime; | ||
100 : | LONGLONG m_stopTime; | ||
101 : | int m_Width, m_Height; | ||
102 : | int m_curSize, m_totalSize, m_elapsedSize; | ||
103 : | LONGLONG m_FpsNom, m_FpsDen; | ||
104 : | LONGLONG m_StopTimeMin, m_StopTimeMax, m_StartTimeMin, m_StartTimeMax; | ||
105 : | int m_bForceTimeStamps; | ||
106 : | int m_AudioBitrate; | ||
107 : | |||
108 : | public: | ||
109 : | CIRecProgressNotify(); | ||
110 : | STDMETHODIMP SetPass(int in_Pass) ; | ||
111 : | STDMETHODIMP SetTotalFrames(DWORD in_TotalFrames) ; | ||
112 : | STDMETHODIMP SetNotifyWnd(HWND in_hWnd); | ||
113 : | STDMETHODIMP GetBitrate(DWORD &OutFramesCount, LONGLONG &OutTotalDataSize); | ||
114 : | STDMETHODIMP GetDimensions(DWORD &Width, DWORD &Height); | ||
115 : | STDMETHODIMP SetTotalSize(int nbTotal); | ||
116 : | STDMETHODIMP SetCurSize(int nbCur); | ||
117 : | STDMETHODIMP SetElapsedSize(int nbElapsed); | ||
118 : | STDMETHODIMP GetMeasuredTimes (LONGLONG &outStopTimeMin, LONGLONG &outStopTimeMax, LONGLONG &outStartTimeMin, LONGLONG &outStartTimeMax); | ||
119 : | STDMETHODIMP SetForceTimeParams (LONGLONG inStartTimeOffset, LONGLONG inFpsNom, LONGLONG inFpsDen); | ||
120 : | STDMETHODIMP SetAudioBitrate(int Bitrate); | ||
121 : | }; | ||
122 : | |||
123 : | class CProgressNotifyFilter : public CTransInPlaceFilter, CIRecProgressNotify | ||
124 : | { | ||
125 : | public: | ||
126 : | static CUnknown * WINAPI CreateInstance(IUnknown *pUnk, HRESULT *phr, int Type); | ||
127 : | CProgressNotifyFilter(LPUNKNOWN pUnk, HRESULT *phr, int Type); | ||
128 : | ~CProgressNotifyFilter(); | ||
129 : | int m_MinSampleSize; | ||
130 : | |||
131 : | virtual HRESULT CompleteConnect(PIN_DIRECTION direction, IPin *pReceivePin); | ||
132 : | LONGLONG m_AvgTimeForFrame; | ||
133 : | CMediaType m_MediaType; | ||
134 : | |||
135 : | // IUnknown | ||
136 : | DECLARE_IUNKNOWN | ||
137 : | |||
138 : | // CUnknown | ||
139 : | STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void ** ppv); | ||
140 : | |||
141 : | HRESULT CheckInputType(const CMediaType *mtIn); | ||
142 : | HRESULT Transform(IMediaSample *pSample); | ||
143 : | |||
144 : | HRESULT DecideBufferSize(IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *pProperties); | ||
145 : | }; | ||
146 : | |||
147 : | class ChangeSubtypeT : | ||
148 : | public CTransformFilter, CIRecProgressNotify | ||
149 : | { | ||
150 : | public: | ||
151 : | static CUnknown * WINAPI CreateInstance(IUnknown *pUnk, HRESULT *phr); | ||
152 : | ChangeSubtypeT(LPUNKNOWN pUnk, HRESULT *phr); | ||
153 : | ~ChangeSubtypeT(void); | ||
154 : | |||
155 : | // IUnknown | ||
156 : | DECLARE_IUNKNOWN | ||
157 : | |||
158 : | // CUnknown | ||
159 : | STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void ** ppv); | ||
160 : | |||
161 : | HRESULT CheckInputType(const CMediaType *pmt); | ||
162 : | HRESULT CheckTransform(const CMediaType *pmtIn, const CMediaType *pmtOut); | ||
163 : | |||
164 : | virtual HRESULT GetMediaType(int iPosition, CMediaType *pMediaType); | ||
165 : | virtual HRESULT DecideBufferSize(IMemAllocator * pAlloc, ALLOCATOR_PROPERTIES * ppropInputRequest); | ||
166 : | virtual HRESULT Transform(IMediaSample *pIn, IMediaSample *pOut); | ||
167 : | virtual HRESULT CompleteConnect(PIN_DIRECTION direction, IPin *pReceivePin); | ||
168 : | |||
169 : | CMediaType m_InMediaType, m_OutMediaType; | ||
170 : | |||
171 : | GUID m_SubtypeID; | ||
172 : | int m_OutFcc; | ||
173 : | |||
174 : | LONGLONG m_UnitDuration, m_UnitTimeDelta, m_MaxStartTime, m_MaxStopTime; | ||
175 : | DWORD m_AvgTimeForFrame; | ||
176 : | |||
177 : | BYTE *m_pMpeg4Sequence; | ||
178 : | int m_Mpeg4SequenceSize; | ||
179 : | }; | ||
180 : | |||
181 : | |||
182 : | /***************************************************************************** | ||
183 : | * Bitstream helper functions | ||
184 : | ****************************************************************************/ | ||
185 : | |||
186 : | /* Copied from bitstream.h of xvidcore - TODO: BAD... | ||
187 : | /* Copyright (C) 2001-2003 Peter Ross <pross@xvid.org> */ | ||
188 : | |||
189 : | /* Input buffer should be readable as full chunks of 8bytes, including | ||
190 : | the end of the buffer. Padding might be appropriate. If only chunks | ||
191 : | of 4bytes are applicable, define XVID_SAFE_BS_TAIL. Note that this will | ||
192 : | slow decoding, so consider this as a last-resort solution */ | ||
193 : | |||
194 : | /* #define XVID_SAFE_BS_TAIL */ | ||
195 : | |||
196 : | #define BSWAP(a) __asm mov eax,a __asm bswap eax __asm mov a, eax | ||
197 : | |||
198 : | #define VIDOBJLAY_START_CODE_MASK 0x0000000f | ||
199 : | #define VIDOBJLAY_START_CODE 0x00000120 /* ..0x0000012f */ | ||
200 : | #define VISOBJ_START_CODE 0x000001b5 | ||
201 : | |||
202 : | #define VIDOBJLAY_SHAPE_RECTANGULAR 0 | ||
203 : | #define VISOBJ_TYPE_VIDEO 1 | ||
204 : | #define VIDOBJLAY_AR_EXTPAR 15 | ||
205 : | |||
206 : | #define READ_MARKER() BitstreamSkip(bs, 1) | ||
207 : | |||
208 : | #define MAX(a, b) ((a > b) ? (a) : (b)) | ||
209 : | |||
210 : | |||
211 : | typedef struct | ||
212 : | { | ||
213 : | unsigned int bufa; | ||
214 : | unsigned int bufb; | ||
215 : | unsigned int buf; | ||
216 : | unsigned int pos; | ||
217 : | unsigned int *tail; | ||
218 : | unsigned int *start; | ||
219 : | unsigned int length; | ||
220 : | unsigned int initpos; | ||
221 : | } | ||
222 : | Bitstream; | ||
223 : | |||
224 : | |||
225 : | /* initialise bitstream structure */ | ||
226 : | |||
227 : | static void __inline | ||
228 : | BitstreamInit(Bitstream * const bs, | ||
229 : | void *const bitstream, | ||
230 : | unsigned int length) | ||
231 : | { | ||
232 : | unsigned int tmp; | ||
233 : | size_t bitpos; | ||
234 : | unsigned int adjbitstream = (unsigned int)bitstream; | ||
235 : | |||
236 : | /* | ||
237 : | * Start the stream on a uint32_t boundary, by rounding down to the | ||
238 : | * previous uint32_t and skipping the intervening bytes. | ||
239 : | */ | ||
240 : | bitpos = ((sizeof(unsigned int)-1) & (size_t)bitstream); | ||
241 : | adjbitstream = adjbitstream - bitpos; | ||
242 : | bs->start = bs->tail = (unsigned int *) adjbitstream; | ||
243 : | |||
244 : | tmp = *bs->start; | ||
245 : | #ifndef ARCH_IS_BIG_ENDIAN | ||
246 : | BSWAP(tmp); | ||
247 : | #endif | ||
248 : | bs->bufa = tmp; | ||
249 : | |||
250 : | tmp = *(bs->start + 1); | ||
251 : | #ifndef ARCH_IS_BIG_ENDIAN | ||
252 : | BSWAP(tmp); | ||
253 : | #endif | ||
254 : | bs->bufb = tmp; | ||
255 : | |||
256 : | bs->pos = bs->initpos = (unsigned int) bitpos*8; | ||
257 : | /* preserve the intervening bytes */ | ||
258 : | if (bs->initpos > 0) | ||
259 : | bs->buf = bs->bufa & (0xffffffff << (32 - bs->initpos)); | ||
260 : | else | ||
261 : | bs->buf = 0; | ||
262 : | bs->length = length; | ||
263 : | } | ||
264 : | |||
265 : | |||
266 : | /* reads n bits from bitstream without changing the stream pos */ | ||
267 : | |||
268 : | static unsigned int __inline | ||
269 : | BitstreamShowBits(Bitstream * const bs, | ||
270 : | const unsigned int bits) | ||
271 : | { | ||
272 : | int nbit = (bits + bs->pos) - 32; | ||
273 : | |||
274 : | if (nbit > 0) { | ||
275 : | return ((bs->bufa & (0xffffffff >> bs->pos)) << nbit) | (bs-> | ||
276 : | bufb >> (32 - | ||
277 : | nbit)); | ||
278 : | } else { | ||
279 : | return (bs->bufa & (0xffffffff >> bs->pos)) >> (32 - bs->pos - bits); | ||
280 : | } | ||
281 : | } | ||
282 : | |||
283 : | |||
284 : | /* skip n bits forward in bitstream */ | ||
285 : | |||
286 : | static __inline void | ||
287 : | BitstreamSkip(Bitstream * const bs, | ||
288 : | const unsigned int bits) | ||
289 : | { | ||
290 : | bs->pos += bits; | ||
291 : | |||
292 : | if (bs->pos >= 32) { | ||
293 : | unsigned int tmp; | ||
294 : | |||
295 : | bs->bufa = bs->bufb; | ||
296 : | #if defined(XVID_SAFE_BS_TAIL) | ||
297 : | if (bs->tail<(bs->start+((bs->length+3)>>2))) | ||
298 : | #endif | ||
299 : | { | ||
300 : | tmp = *((unsigned int *) bs->tail + 2); | ||
301 : | #ifndef ARCH_IS_BIG_ENDIAN | ||
302 : | BSWAP(tmp); | ||
303 : | #endif | ||
304 : | bs->bufb = tmp; | ||
305 : | bs->tail++; | ||
306 : | } | ||
307 : | #if defined(XVID_SAFE_BS_TAIL) | ||
308 : | else { | ||
309 : | bs->bufb = 0; | ||
310 : | } | ||
311 : | #endif | ||
312 : | bs->pos -= 32; | ||
313 : | } | ||
314 : | } | ||
315 : | |||
316 : | |||
317 : | /* move forward to the next byte boundary */ | ||
318 : | |||
319 : | static __inline void | ||
320 : | BitstreamByteAlign(Bitstream * const bs) | ||
321 : | { | ||
322 : | unsigned int remainder = bs->pos % 8; | ||
323 : | |||
324 : | if (remainder) { | ||
325 : | BitstreamSkip(bs, 8 - remainder); | ||
326 : | } | ||
327 : | } | ||
328 : | |||
329 : | |||
330 : | /* bitstream length (unit bits) */ | ||
331 : | |||
332 : | static unsigned int __inline | ||
333 : | BitstreamPos(const Bitstream * const bs) | ||
334 : | { | ||
335 : | return((unsigned int)(8*((unsigned int)bs->tail - (unsigned int)bs->start) + bs->pos - bs->initpos)); | ||
336 : | } | ||
337 : | |||
338 : | |||
339 : | /* read n bits from bitstream */ | ||
340 : | |||
341 : | static unsigned int __inline | ||
342 : | BitstreamGetBits(Bitstream * const bs, | ||
343 : | const unsigned int n) | ||
344 : | { | ||
345 : | unsigned int ret = BitstreamShowBits(bs, n); | ||
346 : | |||
347 : | BitstreamSkip(bs, n); | ||
348 : | return ret; | ||
349 : | } | ||
350 : | |||
351 : | |||
352 : | /* read single bit from bitstream */ | ||
353 : | |||
354 : | static unsigned int __inline | ||
355 : | BitstreamGetBit(Bitstream * const bs) | ||
356 : | { | ||
357 : | return BitstreamGetBits(bs, 1); | ||
358 : | } | ||
359 : | |||
360 : | /*****************************************************************************/ | ||
361 : | |||
362 : | #endif /* _FILTERS_H_ */ |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |