Mercurial > mplayer.hg
annotate loader/dmo/DMO_VideoDecoder.c @ 13809:a9e2fda933be
AMD64 fixes based on patch by Timo Ter¸«£s <timo.teras@iki.fi>
author | faust3 |
---|---|
date | Sat, 30 Oct 2004 12:17:16 +0000 |
parents | 858e2605726c |
children | 0feaed9986d3 |
rev | line source |
---|---|
8294 | 1 /******************************************************** |
2 | |
3 DirectShow Video decoder implementation | |
4 Copyright 2000 Eugene Kuznetsov (divx@euro.ru) | |
5 | |
6 *********************************************************/ | |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
9963
diff
changeset
|
7 #include "config.h" |
8294 | 8 #include "guids.h" |
9 #include "interfaces.h" | |
10 #include "registry.h" | |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
9963
diff
changeset
|
11 #ifdef WIN32_LOADER |
8451 | 12 #include "../ldt_keeper.h" |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
9963
diff
changeset
|
13 #endif |
8294 | 14 |
15 #ifndef NOAVIFILE_HEADERS | |
16 #include "videodecoder.h" | |
17 #else | |
18 #include "libwin32.h" | |
19 #endif | |
20 #include "DMO_Filter.h" | |
21 | |
22 #include "DMO_VideoDecoder.h" | |
23 | |
24 struct _DMO_VideoDecoder | |
25 { | |
26 IVideoDecoder iv; | |
27 | |
28 DMO_Filter* m_pDMO_Filter; | |
29 AM_MEDIA_TYPE m_sOurType, m_sDestType; | |
30 VIDEOINFOHEADER* m_sVhdr; | |
31 VIDEOINFOHEADER* m_sVhdr2; | |
32 int m_Caps;//CAPS m_Caps; // capabilities of DirectShow decoder | |
33 int m_iLastQuality; // remember last quality as integer | |
34 int m_iMinBuffers; | |
35 int m_iMaxAuto; | |
36 }; | |
37 | |
38 //#include "DMO_VideoDecoder.h" | |
39 | |
40 #include "../wine/winerror.h" | |
41 | |
42 #ifndef NOAVIFILE_HEADERS | |
43 #define VFW_E_NOT_RUNNING 0x80040226 | |
44 #include "fourcc.h" | |
45 #include "except.h" | |
46 #endif | |
47 | |
48 #include <unistd.h> | |
49 #include <fcntl.h> | |
50 #include <errno.h> | |
51 #include <sys/types.h> | |
9978 | 52 #ifndef __MINGW32__ |
8294 | 53 #include <sys/mman.h> |
9978 | 54 #endif |
8294 | 55 #include <stdio.h> |
56 #include <stdlib.h> // labs | |
57 | |
58 // strcmp((const char*)info.dll,...) is used instead of (... == ...) | |
59 // so Arpi could use char* pointer in his simplified DMO_VideoDecoder class | |
60 | |
61 #define __MODULE__ "DirectShow_VideoDecoder" | |
62 | |
63 #define false 0 | |
64 #define true 1 | |
65 | |
66 | |
67 //int DMO_VideoDecoder_GetCapabilities(DMO_VideoDecoder *this){return this->m_Caps;} | |
68 | |
69 typedef struct _ct ct; | |
70 | |
71 struct _ct { | |
72 fourcc_t fcc; | |
73 unsigned int bits; | |
74 const GUID* subtype; | |
75 int cap; | |
76 }; | |
77 | |
78 static ct check[] = { | |
79 { fccI420, 12, &MEDIASUBTYPE_I420, CAP_I420 }, | |
80 { fccYV12, 12, &MEDIASUBTYPE_YV12, CAP_YV12 }, | |
81 { fccYUY2, 16, &MEDIASUBTYPE_YUY2, CAP_YUY2 }, | |
82 { fccUYVY, 16, &MEDIASUBTYPE_UYVY, CAP_UYVY }, | |
83 { fccYVYU, 16, &MEDIASUBTYPE_YVYU, CAP_YVYU }, | |
84 { fccIYUV, 24, &MEDIASUBTYPE_IYUV, CAP_IYUV }, | |
85 | |
86 { 8, 8, &MEDIASUBTYPE_RGB8, CAP_NONE }, | |
87 { 15, 16, &MEDIASUBTYPE_RGB555, CAP_NONE }, | |
88 { 16, 16, &MEDIASUBTYPE_RGB565, CAP_NONE }, | |
89 { 24, 24, &MEDIASUBTYPE_RGB24, CAP_NONE }, | |
90 { 32, 32, &MEDIASUBTYPE_RGB32, CAP_NONE }, | |
91 | |
9963 | 92 {0,0,NULL,0}, |
8294 | 93 }; |
94 | |
95 DMO_VideoDecoder * DMO_VideoDecoder_Open(char* dllname, GUID* guid, BITMAPINFOHEADER * format, int flip, int maxauto) | |
96 { | |
97 DMO_VideoDecoder *this; | |
98 HRESULT result; | |
99 ct* c; | |
100 | |
101 this = malloc(sizeof(DMO_VideoDecoder)); | |
102 memset( this, 0, sizeof(DMO_VideoDecoder)); | |
103 | |
104 this->m_sVhdr2 = 0; | |
105 this->m_iLastQuality = -1; | |
106 this->m_iMaxAuto = maxauto; | |
107 | |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
9963
diff
changeset
|
108 #ifdef WIN32_LOADER |
8294 | 109 Setup_LDT_Keeper(); |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
9963
diff
changeset
|
110 #endif |
8294 | 111 |
112 //memset(&m_obh, 0, sizeof(m_obh)); | |
113 //m_obh.biSize = sizeof(m_obh); | |
114 /*try*/ | |
115 { | |
116 unsigned int bihs; | |
117 | |
118 bihs = (format->biSize < (int) sizeof(BITMAPINFOHEADER)) ? | |
119 sizeof(BITMAPINFOHEADER) : format->biSize; | |
120 | |
121 this->iv.m_bh = (BITMAPINFOHEADER*)malloc(bihs); | |
122 memcpy(this->iv.m_bh, format, bihs); | |
123 | |
124 this->iv.m_State = STOP; | |
125 //this->iv.m_pFrame = 0; | |
126 this->iv.m_Mode = DIRECT; | |
127 this->iv.m_iDecpos = 0; | |
128 this->iv.m_iPlaypos = -1; | |
129 this->iv.m_fQuality = 0.0f; | |
130 this->iv.m_bCapable16b = true; | |
131 | |
132 bihs += sizeof(VIDEOINFOHEADER) - sizeof(BITMAPINFOHEADER); | |
133 this->m_sVhdr = (VIDEOINFOHEADER*)malloc(bihs); | |
134 memset(this->m_sVhdr, 0, bihs); | |
135 memcpy(&this->m_sVhdr->bmiHeader, this->iv.m_bh, this->iv.m_bh->biSize); | |
136 this->m_sVhdr->rcSource.left = this->m_sVhdr->rcSource.top = 0; | |
137 this->m_sVhdr->rcSource.right = this->m_sVhdr->bmiHeader.biWidth; | |
138 this->m_sVhdr->rcSource.bottom = this->m_sVhdr->bmiHeader.biHeight; | |
139 //this->m_sVhdr->rcSource.right = 0; | |
140 //this->m_sVhdr->rcSource.bottom = 0; | |
141 this->m_sVhdr->rcTarget = this->m_sVhdr->rcSource; | |
142 | |
143 this->m_sOurType.majortype = MEDIATYPE_Video; | |
144 this->m_sOurType.subtype = MEDIATYPE_Video; | |
145 this->m_sOurType.subtype.f1 = this->m_sVhdr->bmiHeader.biCompression; | |
146 this->m_sOurType.formattype = FORMAT_VideoInfo; | |
147 this->m_sOurType.bFixedSizeSamples = false; | |
148 this->m_sOurType.bTemporalCompression = true; | |
149 this->m_sOurType.pUnk = 0; | |
150 this->m_sOurType.cbFormat = bihs; | |
151 this->m_sOurType.pbFormat = (char*)this->m_sVhdr; | |
152 | |
153 this->m_sVhdr2 = (VIDEOINFOHEADER*)(malloc(sizeof(VIDEOINFOHEADER)+12)); | |
154 memcpy(this->m_sVhdr2, this->m_sVhdr, sizeof(VIDEOINFOHEADER)); | |
155 memset((char*)this->m_sVhdr2 + sizeof(VIDEOINFOHEADER), 0, 12); | |
156 this->m_sVhdr2->bmiHeader.biCompression = 0; | |
157 this->m_sVhdr2->bmiHeader.biBitCount = 24; | |
158 | |
159 // memset((char*)this->m_sVhdr2, 0, sizeof(VIDEOINFOHEADER)+12); | |
160 this->m_sVhdr2->rcTarget = this->m_sVhdr->rcTarget; | |
161 // this->m_sVhdr2->rcSource = this->m_sVhdr->rcSource; | |
162 | |
163 memset(&this->m_sDestType, 0, sizeof(this->m_sDestType)); | |
164 this->m_sDestType.majortype = MEDIATYPE_Video; | |
165 this->m_sDestType.subtype = MEDIASUBTYPE_RGB24; | |
166 this->m_sDestType.formattype = FORMAT_VideoInfo; | |
167 this->m_sDestType.bFixedSizeSamples = true; | |
168 this->m_sDestType.bTemporalCompression = false; | |
169 this->m_sDestType.lSampleSize = labs(this->m_sVhdr2->bmiHeader.biWidth*this->m_sVhdr2->bmiHeader.biHeight | |
170 * ((this->m_sVhdr2->bmiHeader.biBitCount + 7) / 8)); | |
171 this->m_sVhdr2->bmiHeader.biSizeImage = this->m_sDestType.lSampleSize; | |
172 this->m_sDestType.pUnk = 0; | |
173 this->m_sDestType.cbFormat = sizeof(VIDEOINFOHEADER); | |
174 this->m_sDestType.pbFormat = (char*)this->m_sVhdr2; | |
175 | |
176 memset(&this->iv.m_obh, 0, sizeof(this->iv.m_obh)); | |
177 memcpy(&this->iv.m_obh, this->iv.m_bh, sizeof(this->iv.m_obh) < (unsigned) this->iv.m_bh->biSize | |
178 ? sizeof(this->iv.m_obh) : (unsigned) this->iv.m_bh->biSize); | |
179 this->iv.m_obh.biBitCount=24; | |
180 this->iv.m_obh.biSize = sizeof(BITMAPINFOHEADER); | |
181 this->iv.m_obh.biCompression = 0; //BI_RGB | |
182 //this->iv.m_obh.biHeight = labs(this->iv.m_obh.biHeight); | |
183 this->iv.m_obh.biSizeImage = labs(this->iv.m_obh.biWidth * this->iv.m_obh.biHeight) | |
184 * ((this->iv.m_obh.biBitCount + 7) / 8); | |
185 | |
186 | |
187 this->m_pDMO_Filter = DMO_FilterCreate(dllname, guid, &this->m_sOurType, &this->m_sDestType); | |
188 | |
189 if (!this->m_pDMO_Filter) | |
190 { | |
191 printf("Failed to create DMO filter\n"); | |
192 return 0; | |
193 } | |
194 | |
195 if (!flip) | |
196 { | |
197 this->iv.m_obh.biHeight *= -1; | |
198 this->m_sVhdr2->bmiHeader.biHeight = this->iv.m_obh.biHeight; | |
199 // result = this->m_pDMO_Filter->m_pOutputPin->vt->QueryAccept(this->m_pDMO_Filter->m_pOutputPin, &this->m_sDestType); | |
200 result = this->m_pDMO_Filter->m_pMedia->vt->SetOutputType(this->m_pDMO_Filter->m_pMedia, 0, &this->m_sDestType, DMO_SET_TYPEF_TEST_ONLY); | |
201 if (result) | |
202 { | |
203 printf("Decoder does not support upside-down RGB frames\n"); | |
204 this->iv.m_obh.biHeight *= -1; | |
205 this->m_sVhdr2->bmiHeader.biHeight = this->iv.m_obh.biHeight; | |
206 } | |
207 } | |
208 | |
209 memcpy( &this->iv.m_decoder, &this->iv.m_obh, sizeof(this->iv.m_obh) ); | |
210 | |
211 switch (this->iv.m_bh->biCompression) | |
212 { | |
213 #if 0 | |
214 case fccDIV3: | |
215 case fccDIV4: | |
216 case fccDIV5: | |
217 case fccDIV6: | |
218 case fccMP42: | |
219 case fccWMV2: | |
220 //YV12 seems to be broken for DivX :-) codec | |
221 // case fccIV50: | |
222 //produces incorrect picture | |
223 //m_Caps = (CAPS) (m_Caps & ~CAP_YV12); | |
224 //m_Caps = CAP_UYVY;//CAP_YUY2; // | CAP_I420; | |
225 //m_Caps = CAP_I420; | |
226 this->m_Caps = (CAP_YUY2 | CAP_UYVY); | |
227 break; | |
228 #endif | |
229 default: | |
230 | |
231 this->m_Caps = CAP_NONE; | |
232 | |
233 printf("Decoder supports the following YUV formats: "); | |
234 for (c = check; c->bits; c++) | |
235 { | |
236 this->m_sVhdr2->bmiHeader.biBitCount = c->bits; | |
237 this->m_sVhdr2->bmiHeader.biCompression = c->fcc; | |
238 this->m_sDestType.subtype = *c->subtype; | |
239 //result = this->m_pDMO_Filter->m_pOutputPin->vt->QueryAccept(this->m_pDMO_Filter->m_pOutputPin, &this->m_sDestType); | |
240 result = this->m_pDMO_Filter->m_pMedia->vt->SetOutputType(this->m_pDMO_Filter->m_pMedia, 0, &this->m_sDestType, DMO_SET_TYPEF_TEST_ONLY); | |
241 if (!result) | |
242 { | |
243 this->m_Caps = (this->m_Caps | c->cap); | |
8451 | 244 printf("%.4s ", (char*) &c->fcc); |
8294 | 245 } |
246 } | |
247 printf("\n"); | |
248 } | |
249 | |
250 if (this->m_Caps != CAP_NONE) | |
251 printf("Decoder is capable of YUV output (flags 0x%x)\n", (int)this->m_Caps); | |
252 | |
253 this->m_sVhdr2->bmiHeader.biBitCount = 24; | |
254 this->m_sVhdr2->bmiHeader.biCompression = 0; | |
255 this->m_sDestType.subtype = MEDIASUBTYPE_RGB24; | |
256 | |
257 this->m_iMinBuffers = this->iv.VBUFSIZE; | |
258 } | |
259 /*catch (FatalError& error) | |
260 { | |
261 delete[] m_sVhdr; | |
262 delete[] m_sVhdr2; | |
263 delete m_pDMO_Filter; | |
264 throw; | |
265 }*/ | |
266 return this; | |
267 } | |
268 | |
269 void DMO_VideoDecoder_Destroy(DMO_VideoDecoder *this) | |
270 { | |
271 DMO_VideoDecoder_StopInternal(this); | |
272 this->iv.m_State = STOP; | |
273 free(this->m_sVhdr); | |
274 free(this->m_sVhdr2); | |
275 DMO_Filter_Destroy(this->m_pDMO_Filter); | |
276 } | |
277 | |
278 void DMO_VideoDecoder_StartInternal(DMO_VideoDecoder *this) | |
279 { | |
280 #if 0 | |
281 ALLOCATOR_PROPERTIES props, props1; | |
282 Debug printf("DMO_VideoDecoder_StartInternal\n"); | |
283 //cout << "DSSTART" << endl; | |
284 this->m_pDMO_Filter->Start(this->m_pDMO_Filter); | |
285 | |
286 props.cBuffers = 1; | |
287 props.cbBuffer = this->m_sDestType.lSampleSize; | |
288 | |
9503
f47d484d8f28
cbAlign=1 fix for proper Windows support (noticed by Sascha Sommer)
alex
parents:
8451
diff
changeset
|
289 props.cbAlign = 1; |
f47d484d8f28
cbAlign=1 fix for proper Windows support (noticed by Sascha Sommer)
alex
parents:
8451
diff
changeset
|
290 props.cbPrefix = 0; |
8294 | 291 this->m_pDMO_Filter->m_pAll->vt->SetProperties(this->m_pDMO_Filter->m_pAll, &props, &props1); |
292 this->m_pDMO_Filter->m_pAll->vt->Commit(this->m_pDMO_Filter->m_pAll); | |
293 #endif | |
294 this->iv.m_State = START; | |
295 } | |
296 | |
297 void DMO_VideoDecoder_StopInternal(DMO_VideoDecoder *this) | |
298 { | |
299 // this->m_pDMO_Filter->Stop(this->m_pDMO_Filter); | |
300 //??? why was this here ??? m_pOurOutput->SetFramePointer(0); | |
301 } | |
302 | |
303 int DMO_VideoDecoder_DecodeInternal(DMO_VideoDecoder *this, const void* src, int size, int is_keyframe, char* imdata) | |
304 { | |
305 // IMediaSample* sample = 0; | |
306 char* ptr; | |
307 int result; | |
308 unsigned long status; // to be ignored by M$ specs | |
309 DMO_OUTPUT_DATA_BUFFER db; | |
310 CMediaBuffer* bufferin; | |
311 //+ uint8_t* imdata = dest ? dest->Data() : 0; | |
312 | |
313 Debug printf("DMO_VideoDecoder_DecodeInternal(%p,%p,%d,%d,%p)\n",this,src,size,is_keyframe,imdata); | |
314 | |
315 // this->m_pDMO_Filter->m_pAll->vt->GetBuffer(this->m_pDMO_Filter->m_pAll, &sample, 0, 0, 0); | |
316 // if (!sample) | |
317 // { | |
318 // Debug printf("ERROR: null sample\n"); | |
319 // return -1; | |
320 // } | |
321 | |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
9963
diff
changeset
|
322 #ifdef WIN32_LOADER |
8294 | 323 Setup_FS_Segment(); |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
9963
diff
changeset
|
324 #endif |
8294 | 325 |
326 bufferin = CMediaBufferCreate(size, (void*)src, size, 0); | |
327 result = this->m_pDMO_Filter->m_pMedia->vt->ProcessInput(this->m_pDMO_Filter->m_pMedia, 0, | |
328 (IMediaBuffer*)bufferin, | |
329 (is_keyframe) ? DMO_INPUT_DATA_BUFFERF_SYNCPOINT : 0, | |
330 0, 0); | |
331 ((IMediaBuffer*)bufferin)->vt->Release((IUnknown*)bufferin); | |
332 | |
333 if (result != S_OK) | |
334 { | |
335 /* something for process */ | |
336 if (result != S_FALSE) | |
337 printf("ProcessInputError r:0x%x=%d (keyframe: %d)\n", result, result, is_keyframe); | |
338 else | |
339 printf("ProcessInputError FALSE ?? (keyframe: %d)\n", is_keyframe); | |
340 return size; | |
341 } | |
342 | |
343 db.rtTimestamp = 0; | |
344 db.rtTimelength = 0; | |
345 db.dwStatus = 0; | |
346 db.pBuffer = (IMediaBuffer*) CMediaBufferCreate(this->m_sDestType.lSampleSize, | |
347 imdata, 0, 0); | |
348 result = this->m_pDMO_Filter->m_pMedia->vt->ProcessOutput(this->m_pDMO_Filter->m_pMedia, | |
349 (imdata) ? 0 : DMO_PROCESS_OUTPUT_DISCARD_WHEN_NO_BUFFER, | |
350 1, &db, &status); | |
351 //m_pDMO_Filter->m_pMedia->vt->Lock(m_pDMO_Filter->m_pMedia, 0); | |
352 if ((unsigned)result == DMO_E_NOTACCEPTING) | |
353 printf("ProcessOutputError: Not accepting\n"); | |
354 else if (result) | |
355 printf("ProcessOutputError: r:0x%x=%d %ld stat:%ld\n", result, result, status, db.dwStatus); | |
356 | |
357 ((IMediaBuffer*)db.pBuffer)->vt->Release((IUnknown*)db.pBuffer); | |
358 | |
359 //int r = m_pDMO_Filter->m_pMedia->vt->Flush(m_pDMO_Filter->m_pMedia); | |
360 //printf("FLUSH %d\n", r); | |
361 | |
362 return 0; | |
363 } | |
364 | |
365 /* | |
366 * bits == 0 - leave unchanged | |
367 */ | |
368 //int SetDestFmt(DMO_VideoDecoder * this, int bits = 24, fourcc_t csp = 0); | |
369 int DMO_VideoDecoder_SetDestFmt(DMO_VideoDecoder *this, int bits, unsigned int csp) | |
370 { | |
371 HRESULT result; | |
372 int should_test=1; | |
373 int stoped = 0; | |
374 | |
375 Debug printf("DMO_VideoDecoder_SetDestFmt (%p, %d, %d)\n",this,bits,(int)csp); | |
376 | |
377 /* if (!CImage::Supported(csp, bits)) | |
378 return -1; | |
379 */ | |
380 // BitmapInfo temp = m_obh; | |
381 | |
382 if (!csp) // RGB | |
383 { | |
384 int ok = true; | |
385 | |
386 switch (bits) | |
387 { | |
388 case 15: | |
389 this->m_sDestType.subtype = MEDIASUBTYPE_RGB555; | |
390 break; | |
391 case 16: | |
392 this->m_sDestType.subtype = MEDIASUBTYPE_RGB565; | |
393 break; | |
394 case 24: | |
395 this->m_sDestType.subtype = MEDIASUBTYPE_RGB24; | |
396 break; | |
397 case 32: | |
398 this->m_sDestType.subtype = MEDIASUBTYPE_RGB32; | |
399 break; | |
400 default: | |
401 ok = false; | |
402 break; | |
403 } | |
404 | |
405 if (ok) { | |
406 this->iv.m_obh.biBitCount=bits; | |
407 if( bits == 15 || bits == 16 ) { | |
408 this->iv.m_obh.biSize=sizeof(BITMAPINFOHEADER)+12; | |
409 this->iv.m_obh.biCompression=3;//BI_BITFIELDS | |
410 this->iv.m_obh.biSizeImage=abs((int)(2*this->iv.m_obh.biWidth*this->iv.m_obh.biHeight)); | |
411 } | |
412 | |
413 if( bits == 16 ) { | |
414 this->iv.m_obh.colors[0]=0xF800; | |
415 this->iv.m_obh.colors[1]=0x07E0; | |
416 this->iv.m_obh.colors[2]=0x001F; | |
417 } else if ( bits == 15 ) { | |
418 this->iv.m_obh.colors[0]=0x7C00; | |
419 this->iv.m_obh.colors[1]=0x03E0; | |
420 this->iv.m_obh.colors[2]=0x001F; | |
421 } else { | |
422 this->iv.m_obh.biSize = sizeof(BITMAPINFOHEADER); | |
423 this->iv.m_obh.biCompression = 0; //BI_RGB | |
424 //this->iv.m_obh.biHeight = labs(this->iv.m_obh.biHeight); | |
425 this->iv.m_obh.biSizeImage = labs(this->iv.m_obh.biWidth * this->iv.m_obh.biHeight) | |
426 * ((this->iv.m_obh.biBitCount + 7) / 8); | |
427 } | |
428 } | |
429 //.biSizeImage=abs(temp.biWidth*temp.biHeight*((temp.biBitCount+7)/8)); | |
430 } else | |
431 { // YUV | |
432 int ok = true; | |
433 switch (csp) | |
434 { | |
435 case fccYUY2: | |
436 this->m_sDestType.subtype = MEDIASUBTYPE_YUY2; | |
437 break; | |
438 case fccYV12: | |
439 this->m_sDestType.subtype = MEDIASUBTYPE_YV12; | |
440 break; | |
441 case fccIYUV: | |
442 this->m_sDestType.subtype = MEDIASUBTYPE_IYUV; | |
443 break; | |
444 case fccI420: | |
445 this->m_sDestType.subtype = MEDIASUBTYPE_I420; | |
446 break; | |
447 case fccUYVY: | |
448 this->m_sDestType.subtype = MEDIASUBTYPE_UYVY; | |
449 break; | |
450 case fccYVYU: | |
451 this->m_sDestType.subtype = MEDIASUBTYPE_YVYU; | |
452 break; | |
453 case fccYVU9: | |
454 this->m_sDestType.subtype = MEDIASUBTYPE_YVU9; | |
455 default: | |
456 ok = false; | |
457 break; | |
458 } | |
459 | |
460 if (ok) { | |
461 if (csp != 0 && csp != 3 && this->iv.m_obh.biHeight > 0) | |
462 this->iv.m_obh.biHeight *= -1; // YUV formats uses should have height < 0 | |
463 this->iv.m_obh.biSize = sizeof(BITMAPINFOHEADER); | |
464 this->iv.m_obh.biCompression=csp; | |
465 this->iv.m_obh.biBitCount=bits; | |
10887
858e2605726c
fix for the no video/black screen with some dmo/wmv9 movies
pl
parents:
9978
diff
changeset
|
466 |
858e2605726c
fix for the no video/black screen with some dmo/wmv9 movies
pl
parents:
9978
diff
changeset
|
467 this->iv.m_obh.biSizeImage = labs(this->iv.m_obh.biWidth * this->iv.m_obh.biHeight) |
858e2605726c
fix for the no video/black screen with some dmo/wmv9 movies
pl
parents:
9978
diff
changeset
|
468 * ((this->iv.m_obh.biBitCount + 7) / 8); |
8294 | 469 } |
470 } | |
471 this->m_sDestType.lSampleSize = this->iv.m_obh.biSizeImage; | |
472 memcpy(&(this->m_sVhdr2->bmiHeader), &this->iv.m_obh, sizeof(this->iv.m_obh)); | |
473 this->m_sVhdr2->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); | |
474 if (this->m_sVhdr2->bmiHeader.biCompression == 3) | |
475 this->m_sDestType.cbFormat = sizeof(VIDEOINFOHEADER) + 12; | |
476 else | |
477 this->m_sDestType.cbFormat = sizeof(VIDEOINFOHEADER); | |
478 | |
479 | |
480 switch(csp) | |
481 { | |
482 case fccYUY2: | |
483 if(!(this->m_Caps & CAP_YUY2)) | |
484 should_test=false; | |
485 break; | |
486 case fccYV12: | |
487 if(!(this->m_Caps & CAP_YV12)) | |
488 should_test=false; | |
489 break; | |
490 case fccIYUV: | |
491 if(!(this->m_Caps & CAP_IYUV)) | |
492 should_test=false; | |
493 break; | |
494 case fccI420: | |
495 if(!(this->m_Caps & CAP_I420)) | |
496 should_test=false; | |
497 break; | |
498 case fccUYVY: | |
499 if(!(this->m_Caps & CAP_UYVY)) | |
500 should_test=false; | |
501 break; | |
502 case fccYVYU: | |
503 if(!(this->m_Caps & CAP_YVYU)) | |
504 should_test=false; | |
505 break; | |
506 case fccYVU9: | |
507 if(!(this->m_Caps & CAP_YVU9)) | |
508 should_test=false; | |
509 break; | |
510 } | |
511 | |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
9963
diff
changeset
|
512 #ifdef WIN32_LOADER |
8294 | 513 Setup_FS_Segment(); |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
9963
diff
changeset
|
514 #endif |
8294 | 515 |
516 // if(should_test) | |
517 // result = this->m_pDMO_Filter->m_pOutputPin->vt->QueryAccept(this->m_pDMO_Filter->m_pOutputPin, &this->m_sDestType); | |
518 // else | |
519 // result = -1; | |
520 | |
521 // test accept | |
522 if(!this->m_pDMO_Filter) return 0; | |
523 result = this->m_pDMO_Filter->m_pMedia->vt->SetOutputType(this->m_pDMO_Filter->m_pMedia, 0, &this->m_sDestType, DMO_SET_TYPEF_TEST_ONLY); | |
524 | |
525 if (result != 0) | |
526 { | |
527 if (csp) | |
528 printf("Warning: unsupported color space\n"); | |
529 else | |
530 printf("Warning: unsupported bit depth\n"); | |
531 | |
532 this->m_sDestType.lSampleSize = this->iv.m_decoder.biSizeImage; | |
533 memcpy(&(this->m_sVhdr2->bmiHeader), &this->iv.m_decoder, sizeof(this->iv.m_decoder)); | |
534 this->m_sVhdr2->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); | |
535 if (this->m_sVhdr2->bmiHeader.biCompression == 3) | |
536 this->m_sDestType.cbFormat = sizeof(VIDEOINFOHEADER) + 12; | |
537 else | |
538 this->m_sDestType.cbFormat = sizeof(VIDEOINFOHEADER); | |
539 | |
540 return -1; | |
541 } | |
542 | |
543 memcpy( &this->iv.m_decoder, &this->iv.m_obh, sizeof(this->iv.m_obh)); | |
544 | |
545 // m_obh=temp; | |
546 // if(csp) | |
547 // m_obh.biBitCount=BitmapInfo::BitCount(csp); | |
548 this->iv.m_bh->biBitCount = bits; | |
549 | |
550 //DMO_VideoDecoder_Restart(this); | |
551 | |
552 this->m_pDMO_Filter->m_pMedia->vt->SetOutputType(this->m_pDMO_Filter->m_pMedia, 0, &this->m_sDestType, 0); | |
553 | |
554 return 0; | |
555 } | |
556 | |
557 | |
558 int DMO_VideoDecoder_SetDirection(DMO_VideoDecoder *this, int d) | |
559 { | |
560 this->iv.m_obh.biHeight = (d) ? this->iv.m_bh->biHeight : -this->iv.m_bh->biHeight; | |
561 this->m_sVhdr2->bmiHeader.biHeight = this->iv.m_obh.biHeight; | |
562 return 0; | |
563 } | |
564 |