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