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