Mercurial > mplayer.hg
annotate loader/dmo/DMO_VideoDecoder.c @ 23304:7e25711f6427
Remove extern C declarations for C++.
FFmpeg is pure C and not all public headers have the declarations.
author | diego |
---|---|
date | Wed, 16 May 2007 12:26:47 +0000 |
parents | b99edbf76db4 |
children | 450bb2a75cba |
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 |
15 #ifndef NOAVIFILE_HEADERS | |
16 #include "videodecoder.h" | |
17 #else | |
22607
b99edbf76db4
Use explicit path for headers from the dshow/ subdirectory.
diego
parents:
22186
diff
changeset
|
18 #include "dshow/libwin32.h" |
8294 | 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); |
22186
c6edb6c59a7a
Precent overflow of this->m_sVhdr->bmiHeader buffer, may have been
rtogni
parents:
22001
diff
changeset
|
122 this->iv.m_bh->biSize = bihs; |
8294 | 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); | |
18878 | 133 this->m_sVhdr = malloc(bihs); |
8294 | 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 | |
15574
0feaed9986d3
This currently sends control characters to the terminal instead of
rtognimp
parents:
10887
diff
changeset
|
233 printf("Decoder supports the following formats: "); |
8294 | 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); | |
15574
0feaed9986d3
This currently sends control characters to the terminal instead of
rtognimp
parents:
10887
diff
changeset
|
244 if (c->name) |
0feaed9986d3
This currently sends control characters to the terminal instead of
rtognimp
parents:
10887
diff
changeset
|
245 printf("%s ", c->name); |
0feaed9986d3
This currently sends control characters to the terminal instead of
rtognimp
parents:
10887
diff
changeset
|
246 else |
0feaed9986d3
This currently sends control characters to the terminal instead of
rtognimp
parents:
10887
diff
changeset
|
247 printf("%.4s ", (char*) &c->fcc); |
8294 | 248 } |
249 } | |
250 printf("\n"); | |
251 } | |
252 | |
253 if (this->m_Caps != CAP_NONE) | |
254 printf("Decoder is capable of YUV output (flags 0x%x)\n", (int)this->m_Caps); | |
255 | |
256 this->m_sVhdr2->bmiHeader.biBitCount = 24; | |
257 this->m_sVhdr2->bmiHeader.biCompression = 0; | |
258 this->m_sDestType.subtype = MEDIASUBTYPE_RGB24; | |
259 | |
260 this->m_iMinBuffers = this->iv.VBUFSIZE; | |
261 } | |
262 /*catch (FatalError& error) | |
263 { | |
264 delete[] m_sVhdr; | |
265 delete[] m_sVhdr2; | |
266 delete m_pDMO_Filter; | |
267 throw; | |
268 }*/ | |
269 return this; | |
270 } | |
271 | |
272 void DMO_VideoDecoder_Destroy(DMO_VideoDecoder *this) | |
273 { | |
274 DMO_VideoDecoder_StopInternal(this); | |
275 this->iv.m_State = STOP; | |
276 free(this->m_sVhdr); | |
277 free(this->m_sVhdr2); | |
278 DMO_Filter_Destroy(this->m_pDMO_Filter); | |
279 } | |
280 | |
281 void DMO_VideoDecoder_StartInternal(DMO_VideoDecoder *this) | |
282 { | |
283 #if 0 | |
284 ALLOCATOR_PROPERTIES props, props1; | |
285 Debug printf("DMO_VideoDecoder_StartInternal\n"); | |
286 //cout << "DSSTART" << endl; | |
287 this->m_pDMO_Filter->Start(this->m_pDMO_Filter); | |
288 | |
289 props.cBuffers = 1; | |
290 props.cbBuffer = this->m_sDestType.lSampleSize; | |
291 | |
9503
f47d484d8f28
cbAlign=1 fix for proper Windows support (noticed by Sascha Sommer)
alex
parents:
8451
diff
changeset
|
292 props.cbAlign = 1; |
f47d484d8f28
cbAlign=1 fix for proper Windows support (noticed by Sascha Sommer)
alex
parents:
8451
diff
changeset
|
293 props.cbPrefix = 0; |
8294 | 294 this->m_pDMO_Filter->m_pAll->vt->SetProperties(this->m_pDMO_Filter->m_pAll, &props, &props1); |
295 this->m_pDMO_Filter->m_pAll->vt->Commit(this->m_pDMO_Filter->m_pAll); | |
296 #endif | |
297 this->iv.m_State = START; | |
298 } | |
299 | |
300 void DMO_VideoDecoder_StopInternal(DMO_VideoDecoder *this) | |
301 { | |
302 // this->m_pDMO_Filter->Stop(this->m_pDMO_Filter); | |
303 //??? why was this here ??? m_pOurOutput->SetFramePointer(0); | |
304 } | |
305 | |
306 int DMO_VideoDecoder_DecodeInternal(DMO_VideoDecoder *this, const void* src, int size, int is_keyframe, char* imdata) | |
307 { | |
308 // IMediaSample* sample = 0; | |
309 char* ptr; | |
310 int result; | |
311 unsigned long status; // to be ignored by M$ specs | |
312 DMO_OUTPUT_DATA_BUFFER db; | |
313 CMediaBuffer* bufferin; | |
314 //+ uint8_t* imdata = dest ? dest->Data() : 0; | |
315 | |
316 Debug printf("DMO_VideoDecoder_DecodeInternal(%p,%p,%d,%d,%p)\n",this,src,size,is_keyframe,imdata); | |
317 | |
318 // this->m_pDMO_Filter->m_pAll->vt->GetBuffer(this->m_pDMO_Filter->m_pAll, &sample, 0, 0, 0); | |
319 // if (!sample) | |
320 // { | |
321 // Debug printf("ERROR: null sample\n"); | |
322 // return -1; | |
323 // } | |
324 | |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
9963
diff
changeset
|
325 #ifdef WIN32_LOADER |
8294 | 326 Setup_FS_Segment(); |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
9963
diff
changeset
|
327 #endif |
8294 | 328 |
329 bufferin = CMediaBufferCreate(size, (void*)src, size, 0); | |
330 result = this->m_pDMO_Filter->m_pMedia->vt->ProcessInput(this->m_pDMO_Filter->m_pMedia, 0, | |
331 (IMediaBuffer*)bufferin, | |
15919
b612f732e420
hardcode SYNC flag, so no problems could rise if first frame is skipped
iive
parents:
15574
diff
changeset
|
332 DMO_INPUT_DATA_BUFFERF_SYNCPOINT, |
8294 | 333 0, 0); |
334 ((IMediaBuffer*)bufferin)->vt->Release((IUnknown*)bufferin); | |
335 | |
336 if (result != S_OK) | |
337 { | |
338 /* something for process */ | |
339 if (result != S_FALSE) | |
340 printf("ProcessInputError r:0x%x=%d (keyframe: %d)\n", result, result, is_keyframe); | |
341 else | |
342 printf("ProcessInputError FALSE ?? (keyframe: %d)\n", is_keyframe); | |
343 return size; | |
344 } | |
345 | |
346 db.rtTimestamp = 0; | |
347 db.rtTimelength = 0; | |
348 db.dwStatus = 0; | |
349 db.pBuffer = (IMediaBuffer*) CMediaBufferCreate(this->m_sDestType.lSampleSize, | |
350 imdata, 0, 0); | |
351 result = this->m_pDMO_Filter->m_pMedia->vt->ProcessOutput(this->m_pDMO_Filter->m_pMedia, | |
352 (imdata) ? 0 : DMO_PROCESS_OUTPUT_DISCARD_WHEN_NO_BUFFER, | |
353 1, &db, &status); | |
354 //m_pDMO_Filter->m_pMedia->vt->Lock(m_pDMO_Filter->m_pMedia, 0); | |
355 if ((unsigned)result == DMO_E_NOTACCEPTING) | |
356 printf("ProcessOutputError: Not accepting\n"); | |
357 else if (result) | |
358 printf("ProcessOutputError: r:0x%x=%d %ld stat:%ld\n", result, result, status, db.dwStatus); | |
359 | |
360 ((IMediaBuffer*)db.pBuffer)->vt->Release((IUnknown*)db.pBuffer); | |
361 | |
362 //int r = m_pDMO_Filter->m_pMedia->vt->Flush(m_pDMO_Filter->m_pMedia); | |
363 //printf("FLUSH %d\n", r); | |
364 | |
365 return 0; | |
366 } | |
367 | |
368 /* | |
369 * bits == 0 - leave unchanged | |
370 */ | |
371 //int SetDestFmt(DMO_VideoDecoder * this, int bits = 24, fourcc_t csp = 0); | |
372 int DMO_VideoDecoder_SetDestFmt(DMO_VideoDecoder *this, int bits, unsigned int csp) | |
373 { | |
374 HRESULT result; | |
375 int should_test=1; | |
376 int stoped = 0; | |
377 | |
378 Debug printf("DMO_VideoDecoder_SetDestFmt (%p, %d, %d)\n",this,bits,(int)csp); | |
379 | |
380 /* if (!CImage::Supported(csp, bits)) | |
381 return -1; | |
382 */ | |
383 // BitmapInfo temp = m_obh; | |
384 | |
385 if (!csp) // RGB | |
386 { | |
387 int ok = true; | |
388 | |
389 switch (bits) | |
390 { | |
391 case 15: | |
392 this->m_sDestType.subtype = MEDIASUBTYPE_RGB555; | |
393 break; | |
394 case 16: | |
395 this->m_sDestType.subtype = MEDIASUBTYPE_RGB565; | |
396 break; | |
397 case 24: | |
398 this->m_sDestType.subtype = MEDIASUBTYPE_RGB24; | |
399 break; | |
400 case 32: | |
401 this->m_sDestType.subtype = MEDIASUBTYPE_RGB32; | |
402 break; | |
403 default: | |
404 ok = false; | |
405 break; | |
406 } | |
407 | |
408 if (ok) { | |
409 this->iv.m_obh.biBitCount=bits; | |
410 if( bits == 15 || bits == 16 ) { | |
411 this->iv.m_obh.biSize=sizeof(BITMAPINFOHEADER)+12; | |
412 this->iv.m_obh.biCompression=3;//BI_BITFIELDS | |
413 this->iv.m_obh.biSizeImage=abs((int)(2*this->iv.m_obh.biWidth*this->iv.m_obh.biHeight)); | |
414 } | |
415 | |
416 if( bits == 16 ) { | |
417 this->iv.m_obh.colors[0]=0xF800; | |
418 this->iv.m_obh.colors[1]=0x07E0; | |
419 this->iv.m_obh.colors[2]=0x001F; | |
420 } else if ( bits == 15 ) { | |
421 this->iv.m_obh.colors[0]=0x7C00; | |
422 this->iv.m_obh.colors[1]=0x03E0; | |
423 this->iv.m_obh.colors[2]=0x001F; | |
424 } else { | |
425 this->iv.m_obh.biSize = sizeof(BITMAPINFOHEADER); | |
426 this->iv.m_obh.biCompression = 0; //BI_RGB | |
427 //this->iv.m_obh.biHeight = labs(this->iv.m_obh.biHeight); | |
428 this->iv.m_obh.biSizeImage = labs(this->iv.m_obh.biWidth * this->iv.m_obh.biHeight) | |
429 * ((this->iv.m_obh.biBitCount + 7) / 8); | |
430 } | |
431 } | |
432 //.biSizeImage=abs(temp.biWidth*temp.biHeight*((temp.biBitCount+7)/8)); | |
433 } else | |
434 { // YUV | |
435 int ok = true; | |
436 switch (csp) | |
437 { | |
438 case fccYUY2: | |
439 this->m_sDestType.subtype = MEDIASUBTYPE_YUY2; | |
440 break; | |
441 case fccYV12: | |
442 this->m_sDestType.subtype = MEDIASUBTYPE_YV12; | |
443 break; | |
444 case fccIYUV: | |
445 this->m_sDestType.subtype = MEDIASUBTYPE_IYUV; | |
446 break; | |
447 case fccI420: | |
448 this->m_sDestType.subtype = MEDIASUBTYPE_I420; | |
449 break; | |
450 case fccUYVY: | |
451 this->m_sDestType.subtype = MEDIASUBTYPE_UYVY; | |
452 break; | |
453 case fccYVYU: | |
454 this->m_sDestType.subtype = MEDIASUBTYPE_YVYU; | |
455 break; | |
456 case fccYVU9: | |
457 this->m_sDestType.subtype = MEDIASUBTYPE_YVU9; | |
458 default: | |
459 ok = false; | |
460 break; | |
461 } | |
462 | |
463 if (ok) { | |
464 if (csp != 0 && csp != 3 && this->iv.m_obh.biHeight > 0) | |
465 this->iv.m_obh.biHeight *= -1; // YUV formats uses should have height < 0 | |
466 this->iv.m_obh.biSize = sizeof(BITMAPINFOHEADER); | |
467 this->iv.m_obh.biCompression=csp; | |
468 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
|
469 |
858e2605726c
fix for the no video/black screen with some dmo/wmv9 movies
pl
parents:
9978
diff
changeset
|
470 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
|
471 * ((this->iv.m_obh.biBitCount + 7) / 8); |
8294 | 472 } |
473 } | |
474 this->m_sDestType.lSampleSize = this->iv.m_obh.biSizeImage; | |
475 memcpy(&(this->m_sVhdr2->bmiHeader), &this->iv.m_obh, sizeof(this->iv.m_obh)); | |
476 this->m_sVhdr2->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); | |
477 if (this->m_sVhdr2->bmiHeader.biCompression == 3) | |
478 this->m_sDestType.cbFormat = sizeof(VIDEOINFOHEADER) + 12; | |
479 else | |
480 this->m_sDestType.cbFormat = sizeof(VIDEOINFOHEADER); | |
481 | |
482 | |
483 switch(csp) | |
484 { | |
485 case fccYUY2: | |
486 if(!(this->m_Caps & CAP_YUY2)) | |
487 should_test=false; | |
488 break; | |
489 case fccYV12: | |
490 if(!(this->m_Caps & CAP_YV12)) | |
491 should_test=false; | |
492 break; | |
493 case fccIYUV: | |
494 if(!(this->m_Caps & CAP_IYUV)) | |
495 should_test=false; | |
496 break; | |
497 case fccI420: | |
498 if(!(this->m_Caps & CAP_I420)) | |
499 should_test=false; | |
500 break; | |
501 case fccUYVY: | |
502 if(!(this->m_Caps & CAP_UYVY)) | |
503 should_test=false; | |
504 break; | |
505 case fccYVYU: | |
506 if(!(this->m_Caps & CAP_YVYU)) | |
507 should_test=false; | |
508 break; | |
509 case fccYVU9: | |
510 if(!(this->m_Caps & CAP_YVU9)) | |
511 should_test=false; | |
512 break; | |
513 } | |
514 | |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
9963
diff
changeset
|
515 #ifdef WIN32_LOADER |
8294 | 516 Setup_FS_Segment(); |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
9963
diff
changeset
|
517 #endif |
8294 | 518 |
519 // if(should_test) | |
520 // result = this->m_pDMO_Filter->m_pOutputPin->vt->QueryAccept(this->m_pDMO_Filter->m_pOutputPin, &this->m_sDestType); | |
521 // else | |
522 // result = -1; | |
523 | |
524 // test accept | |
525 if(!this->m_pDMO_Filter) return 0; | |
526 result = this->m_pDMO_Filter->m_pMedia->vt->SetOutputType(this->m_pDMO_Filter->m_pMedia, 0, &this->m_sDestType, DMO_SET_TYPEF_TEST_ONLY); | |
527 | |
528 if (result != 0) | |
529 { | |
530 if (csp) | |
531 printf("Warning: unsupported color space\n"); | |
532 else | |
533 printf("Warning: unsupported bit depth\n"); | |
534 | |
535 this->m_sDestType.lSampleSize = this->iv.m_decoder.biSizeImage; | |
536 memcpy(&(this->m_sVhdr2->bmiHeader), &this->iv.m_decoder, sizeof(this->iv.m_decoder)); | |
537 this->m_sVhdr2->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); | |
538 if (this->m_sVhdr2->bmiHeader.biCompression == 3) | |
539 this->m_sDestType.cbFormat = sizeof(VIDEOINFOHEADER) + 12; | |
540 else | |
541 this->m_sDestType.cbFormat = sizeof(VIDEOINFOHEADER); | |
542 | |
543 return -1; | |
544 } | |
545 | |
546 memcpy( &this->iv.m_decoder, &this->iv.m_obh, sizeof(this->iv.m_obh)); | |
547 | |
548 // m_obh=temp; | |
549 // if(csp) | |
550 // m_obh.biBitCount=BitmapInfo::BitCount(csp); | |
551 this->iv.m_bh->biBitCount = bits; | |
552 | |
553 //DMO_VideoDecoder_Restart(this); | |
554 | |
555 this->m_pDMO_Filter->m_pMedia->vt->SetOutputType(this->m_pDMO_Filter->m_pMedia, 0, &this->m_sDestType, 0); | |
556 | |
557 return 0; | |
558 } | |
559 | |
560 | |
561 int DMO_VideoDecoder_SetDirection(DMO_VideoDecoder *this, int d) | |
562 { | |
563 this->iv.m_obh.biHeight = (d) ? this->iv.m_bh->biHeight : -this->iv.m_bh->biHeight; | |
564 this->m_sVhdr2->bmiHeader.biHeight = this->iv.m_obh.biHeight; | |
565 return 0; | |
566 } | |
567 |