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