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