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