Mercurial > mplayer.hg
annotate loader/dshow/DS_VideoDecoder.c @ 35073:cae3fc699368
Merge declaration and initialization.
author | reimar |
---|---|
date | Tue, 11 Sep 2012 21:23:00 +0000 |
parents | 2a2e9b6551d8 |
children | 389d43c448b3 |
rev | line source |
---|---|
1545 | 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:
9581
diff
changeset
|
7 #include "config.h" |
1545 | 8 #include "guids.h" |
9 #include "interfaces.h" | |
30170
008338d7679f
Drop -Iloader from CPPFLAGS for the loader subdirectory.
diego
parents:
29263
diff
changeset
|
10 #include "loader/registry.h" |
3946 | 11 #include "libwin32.h" |
12 #include "DS_Filter.h" | |
13 | |
25794
2c8cdb9123b8
Fix a ton of illegal identifiers. Identifiers starting with __ or _ and a
diego
parents:
25681
diff
changeset
|
14 struct DS_VideoDecoder |
3946 | 15 { |
16 IVideoDecoder iv; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26544
diff
changeset
|
17 |
3946 | 18 DS_Filter* m_pDS_Filter; |
19 AM_MEDIA_TYPE m_sOurType, m_sDestType; | |
20 VIDEOINFOHEADER* m_sVhdr; | |
21 VIDEOINFOHEADER* m_sVhdr2; | |
22 int m_Caps;//CAPS m_Caps; // capabilities of DirectShow decoder | |
23 int m_iLastQuality; // remember last quality as integer | |
24 int m_iMinBuffers; | |
25 int m_iMaxAuto; | |
26 int m_bIsDivX; // for speed | |
27 int m_bIsDivX4; // for speed | |
28 }; | |
22398
49f01f8fbd60
Rework of copying samples from directshow codecs.
voroshil
parents:
22307
diff
changeset
|
29 static SampleProcUserData sampleProcData; |
3946 | 30 |
1545 | 31 #include "DS_VideoDecoder.h" |
3946 | 32 |
30170
008338d7679f
Drop -Iloader from CPPFLAGS for the loader subdirectory.
diego
parents:
29263
diff
changeset
|
33 #include "loader/wine/winerror.h" |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
9581
diff
changeset
|
34 #ifdef WIN32_LOADER |
30170
008338d7679f
Drop -Iloader from CPPFLAGS for the loader subdirectory.
diego
parents:
29263
diff
changeset
|
35 #include "loader/ldt_keeper.h" |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
9581
diff
changeset
|
36 #endif |
3059 | 37 |
1545 | 38 #include <unistd.h> |
39 #include <fcntl.h> | |
40 #include <errno.h> | |
41 #include <sys/types.h> | |
33412
2a2e9b6551d8
configure: Convert HAVE_SYS_MMAN_H into a 0/1 definition.
diego
parents:
32394
diff
changeset
|
42 #if HAVE_SYS_MMAN_H |
1545 | 43 #include <sys/mman.h> |
9978 | 44 #endif |
3059 | 45 #include <stdio.h> |
46 #include <stdlib.h> // labs | |
2072 | 47 |
3059 | 48 // strcmp((const char*)info.dll,...) is used instead of (... == ...) |
49 // so Arpi could use char* pointer in his simplified DS_VideoDecoder class | |
1545 | 50 |
3059 | 51 #define false 0 |
52 #define true 1 | |
53 | |
54 int DS_VideoDecoder_GetCapabilities(DS_VideoDecoder *this) | |
55 {return this->m_Caps;} | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26544
diff
changeset
|
56 |
25794
2c8cdb9123b8
Fix a ton of illegal identifiers. Identifiers starting with __ or _ and a
diego
parents:
25681
diff
changeset
|
57 typedef struct ct ct; |
1545 | 58 |
25794
2c8cdb9123b8
Fix a ton of illegal identifiers. Identifiers starting with __ or _ and a
diego
parents:
25681
diff
changeset
|
59 struct ct { |
3059 | 60 unsigned int bits; |
61 fourcc_t fcc; | |
8451 | 62 const GUID *subtype; |
3059 | 63 int cap; |
64 }; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26544
diff
changeset
|
65 |
3059 | 66 static ct check[] = { |
67 {16, fccYUY2, &MEDIASUBTYPE_YUY2, CAP_YUY2}, | |
68 {12, fccIYUV, &MEDIASUBTYPE_IYUV, CAP_IYUV}, | |
69 {16, fccUYVY, &MEDIASUBTYPE_UYVY, CAP_UYVY}, | |
70 {12, fccYV12, &MEDIASUBTYPE_YV12, CAP_YV12}, | |
6527 | 71 //{16, fccYV12, &MEDIASUBTYPE_YV12, CAP_YV12}, |
3059 | 72 {16, fccYVYU, &MEDIASUBTYPE_YVYU, CAP_YVYU}, |
6527 | 73 {12, fccI420, &MEDIASUBTYPE_I420, CAP_I420}, |
74 {9, fccYVU9, &MEDIASUBTYPE_YVU9, CAP_YVU9}, | |
9581 | 75 {0, 0, 0, 0}, |
3059 | 76 }; |
77 | |
78 | |
3444 | 79 DS_VideoDecoder * DS_VideoDecoder_Open(char* dllname, GUID* guid, BITMAPINFOHEADER * format, int flip, int maxauto) |
1545 | 80 { |
3059 | 81 DS_VideoDecoder *this; |
82 HRESULT result; | |
83 ct* c; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26544
diff
changeset
|
84 |
3059 | 85 this = malloc(sizeof(DS_VideoDecoder)); |
86 memset( this, 0, sizeof(DS_VideoDecoder)); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26544
diff
changeset
|
87 |
3059 | 88 this->m_sVhdr2 = 0; |
89 this->m_iLastQuality = -1; | |
90 this->m_iMaxAuto = maxauto; | |
91 | |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
9581
diff
changeset
|
92 #ifdef WIN32_LOADER |
3063 | 93 Setup_LDT_Keeper(); |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
9581
diff
changeset
|
94 #endif |
3063 | 95 |
1545 | 96 //memset(&m_obh, 0, sizeof(m_obh)); |
97 //m_obh.biSize = sizeof(m_obh); | |
3059 | 98 /*try*/ |
1545 | 99 { |
3059 | 100 unsigned int bihs; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26544
diff
changeset
|
101 |
3059 | 102 bihs = (format->biSize < (int) sizeof(BITMAPINFOHEADER)) ? |
103 sizeof(BITMAPINFOHEADER) : format->biSize; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26544
diff
changeset
|
104 |
18878 | 105 this->iv.m_bh = malloc(bihs); |
3059 | 106 memcpy(this->iv.m_bh, format, bihs); |
22187
88b36fd17976
Precent overflow of this->m_sVhdr->bmiHeader buffer, may have been
rtogni
parents:
22001
diff
changeset
|
107 this->iv.m_bh->biSize = bihs; |
4205
c42ab0e5bbbc
possible sig11 fixed - noticed by Fredrik Kuivinen <freku045@student.liu.se>
arpi
parents:
3978
diff
changeset
|
108 |
3059 | 109 this->iv.m_State = STOP; |
110 //this->iv.m_pFrame = 0; | |
111 this->iv.m_Mode = DIRECT; | |
112 this->iv.m_iDecpos = 0; | |
113 this->iv.m_iPlaypos = -1; | |
114 this->iv.m_fQuality = 0.0f; | |
115 this->iv.m_bCapable16b = true; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26544
diff
changeset
|
116 |
4205
c42ab0e5bbbc
possible sig11 fixed - noticed by Fredrik Kuivinen <freku045@student.liu.se>
arpi
parents:
3978
diff
changeset
|
117 bihs += sizeof(VIDEOINFOHEADER) - sizeof(BITMAPINFOHEADER); |
18878 | 118 this->m_sVhdr = malloc(bihs); |
3059 | 119 memset(this->m_sVhdr, 0, bihs); |
120 memcpy(&this->m_sVhdr->bmiHeader, this->iv.m_bh, this->iv.m_bh->biSize); | |
121 this->m_sVhdr->rcSource.left = this->m_sVhdr->rcSource.top = 0; | |
122 this->m_sVhdr->rcSource.right = this->m_sVhdr->bmiHeader.biWidth; | |
123 this->m_sVhdr->rcSource.bottom = this->m_sVhdr->bmiHeader.biHeight; | |
124 //this->m_sVhdr->rcSource.right = 0; | |
125 //this->m_sVhdr->rcSource.bottom = 0; | |
126 this->m_sVhdr->rcTarget = this->m_sVhdr->rcSource; | |
1545 | 127 |
3059 | 128 this->m_sOurType.majortype = MEDIATYPE_Video; |
129 this->m_sOurType.subtype = MEDIATYPE_Video; | |
130 this->m_sOurType.subtype.f1 = this->m_sVhdr->bmiHeader.biCompression; | |
131 this->m_sOurType.formattype = FORMAT_VideoInfo; | |
132 this->m_sOurType.bFixedSizeSamples = false; | |
133 this->m_sOurType.bTemporalCompression = true; | |
134 this->m_sOurType.pUnk = 0; | |
135 this->m_sOurType.cbFormat = bihs; | |
136 this->m_sOurType.pbFormat = (char*)this->m_sVhdr; | |
137 | |
25681 | 138 this->m_sVhdr2 = malloc(sizeof(VIDEOINFOHEADER)+12); |
3059 | 139 memcpy(this->m_sVhdr2, this->m_sVhdr, sizeof(VIDEOINFOHEADER)); |
140 memset((char*)this->m_sVhdr2 + sizeof(VIDEOINFOHEADER), 0, 12); | |
141 this->m_sVhdr2->bmiHeader.biCompression = 0; | |
142 this->m_sVhdr2->bmiHeader.biBitCount = 24; | |
1545 | 143 |
3059 | 144 memset(&this->m_sDestType, 0, sizeof(this->m_sDestType)); |
145 this->m_sDestType.majortype = MEDIATYPE_Video; | |
146 this->m_sDestType.subtype = MEDIASUBTYPE_RGB24; | |
147 this->m_sDestType.formattype = FORMAT_VideoInfo; | |
148 this->m_sDestType.bFixedSizeSamples = true; | |
149 this->m_sDestType.bTemporalCompression = false; | |
150 this->m_sDestType.lSampleSize = labs(this->m_sVhdr2->bmiHeader.biWidth*this->m_sVhdr2->bmiHeader.biHeight | |
151 * ((this->m_sVhdr2->bmiHeader.biBitCount + 7) / 8)); | |
152 this->m_sVhdr2->bmiHeader.biSizeImage = this->m_sDestType.lSampleSize; | |
153 this->m_sDestType.pUnk = 0; | |
154 this->m_sDestType.cbFormat = sizeof(VIDEOINFOHEADER); | |
155 this->m_sDestType.pbFormat = (char*)this->m_sVhdr2; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26544
diff
changeset
|
156 |
3059 | 157 memset(&this->iv.m_obh, 0, sizeof(this->iv.m_obh)); |
158 memcpy(&this->iv.m_obh, this->iv.m_bh, sizeof(this->iv.m_obh) < (unsigned) this->iv.m_bh->biSize | |
159 ? sizeof(this->iv.m_obh) : (unsigned) this->iv.m_bh->biSize); | |
160 this->iv.m_obh.biBitCount=24; | |
161 this->iv.m_obh.biSize = sizeof(BITMAPINFOHEADER); | |
162 this->iv.m_obh.biCompression = 0; //BI_RGB | |
163 //this->iv.m_obh.biHeight = labs(this->iv.m_obh.biHeight); | |
164 this->iv.m_obh.biSizeImage = labs(this->iv.m_obh.biWidth * this->iv.m_obh.biHeight) | |
165 * ((this->iv.m_obh.biBitCount + 7) / 8); | |
1545 | 166 |
167 | |
22398
49f01f8fbd60
Rework of copying samples from directshow codecs.
voroshil
parents:
22307
diff
changeset
|
168 this->m_pDS_Filter = DS_FilterCreate(dllname, guid, &this->m_sOurType, &this->m_sDestType,&sampleProcData); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26544
diff
changeset
|
169 |
3456 | 170 if (!this->m_pDS_Filter) |
171 { | |
172 printf("Failed to create DirectShow filter\n"); | |
173 return 0; | |
174 } | |
1545 | 175 |
176 if (!flip) | |
177 { | |
3059 | 178 this->iv.m_obh.biHeight *= -1; |
3466 | 179 this->m_sVhdr2->bmiHeader.biHeight = this->iv.m_obh.biHeight; |
3059 | 180 result = this->m_pDS_Filter->m_pOutputPin->vt->QueryAccept(this->m_pDS_Filter->m_pOutputPin, &this->m_sDestType); |
1545 | 181 if (result) |
182 { | |
3466 | 183 printf("Decoder does not support upside-down RGB frames\n"); |
3059 | 184 this->iv.m_obh.biHeight *= -1; |
3466 | 185 this->m_sVhdr2->bmiHeader.biHeight = this->iv.m_obh.biHeight; |
1545 | 186 } |
187 } | |
188 | |
3059 | 189 memcpy( &this->iv.m_decoder, &this->iv.m_obh, sizeof(this->iv.m_obh) ); |
1545 | 190 |
3059 | 191 switch (this->iv.m_bh->biCompression) |
1545 | 192 { |
6527 | 193 #if 0 |
1545 | 194 case fccDIV3: |
195 case fccDIV4: | |
196 case fccDIV5: | |
3059 | 197 case fccDIV6: |
1545 | 198 case fccMP42: |
199 case fccWMV2: | |
200 //YV12 seems to be broken for DivX :-) codec | |
3060 | 201 // case fccIV50: |
1545 | 202 //produces incorrect picture |
203 //m_Caps = (CAPS) (m_Caps & ~CAP_YV12); | |
3059 | 204 //m_Caps = CAP_UYVY;//CAP_YUY2; // | CAP_I420; |
205 //m_Caps = CAP_I420; | |
206 this->m_Caps = (CAP_YUY2 | CAP_UYVY); | |
1545 | 207 break; |
6527 | 208 #endif |
1545 | 209 default: |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26544
diff
changeset
|
210 |
3059 | 211 this->m_Caps = CAP_NONE; |
1545 | 212 |
6527 | 213 printf("Decoder supports the following YUV formats: "); |
3059 | 214 for (c = check; c->bits; c++) |
1545 | 215 { |
3059 | 216 this->m_sVhdr2->bmiHeader.biBitCount = c->bits; |
217 this->m_sVhdr2->bmiHeader.biCompression = c->fcc; | |
218 this->m_sDestType.subtype = *c->subtype; | |
219 result = this->m_pDS_Filter->m_pOutputPin->vt->QueryAccept(this->m_pDS_Filter->m_pOutputPin, &this->m_sDestType); | |
1545 | 220 if (!result) |
6527 | 221 { |
3059 | 222 this->m_Caps = (this->m_Caps | c->cap); |
8451 | 223 printf("%.4s ", (char *)&c->fcc); |
6527 | 224 } |
1545 | 225 } |
6527 | 226 printf("\n"); |
1545 | 227 } |
228 | |
3059 | 229 if (this->m_Caps != CAP_NONE) |
6527 | 230 printf("Decoder is capable of YUV output (flags 0x%x)\n", (int)this->m_Caps); |
1545 | 231 |
3059 | 232 this->m_sVhdr2->bmiHeader.biBitCount = 24; |
233 this->m_sVhdr2->bmiHeader.biCompression = 0; | |
234 this->m_sDestType.subtype = MEDIASUBTYPE_RGB24; | |
1545 | 235 |
3059 | 236 this->m_iMinBuffers = this->iv.VBUFSIZE; |
3444 | 237 this->m_bIsDivX = (strcmp(dllname, "divxcvki.ax") == 0 |
238 || strcmp(dllname, "divx_c32.ax") == 0 | |
239 || strcmp(dllname, "wmvds32.ax") == 0 | |
240 || strcmp(dllname, "wmv8ds32.ax") == 0); | |
241 this->m_bIsDivX4 = (strcmp(dllname, "divxdec.ax") == 0); | |
3059 | 242 if (this->m_bIsDivX) |
243 this->iv.VBUFSIZE += 7; | |
244 else if (this->m_bIsDivX4) | |
245 this->iv.VBUFSIZE += 9; | |
1545 | 246 } |
3059 | 247 /*catch (FatalError& error) |
1545 | 248 { |
3059 | 249 delete[] m_sVhdr; |
1545 | 250 delete[] m_sVhdr2; |
251 delete m_pDS_Filter; | |
252 throw; | |
3059 | 253 }*/ |
254 return this; | |
1545 | 255 } |
256 | |
3059 | 257 void DS_VideoDecoder_Destroy(DS_VideoDecoder *this) |
1545 | 258 { |
3059 | 259 DS_VideoDecoder_StopInternal(this); |
260 this->iv.m_State = STOP; | |
261 free(this->m_sVhdr); | |
262 free(this->m_sVhdr2); | |
263 DS_Filter_Destroy(this->m_pDS_Filter); | |
1545 | 264 } |
265 | |
3059 | 266 void DS_VideoDecoder_StartInternal(DS_VideoDecoder *this) |
1545 | 267 { |
3059 | 268 Debug printf("DS_VideoDecoder_StartInternal\n"); |
1545 | 269 //cout << "DSSTART" << endl; |
22304
254733f57707
Fixed loading of VoxWare and wma9sp binary audio codecs using dshow engine.
voroshil
parents:
22187
diff
changeset
|
270 this->m_pDS_Filter->m_pAll->vt->Commit(this->m_pDS_Filter->m_pAll); |
3063 | 271 this->m_pDS_Filter->Start(this->m_pDS_Filter); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26544
diff
changeset
|
272 |
3957
49290522ab06
SetValue fixed, iv_State=START enabled (silly xine developers disabled for unknown reason)
arpi
parents:
3946
diff
changeset
|
273 this->iv.m_State = START; |
1545 | 274 } |
275 | |
3059 | 276 void DS_VideoDecoder_StopInternal(DS_VideoDecoder *this) |
1545 | 277 { |
3063 | 278 this->m_pDS_Filter->Stop(this->m_pDS_Filter); |
1545 | 279 //??? why was this here ??? m_pOurOutput->SetFramePointer(0); |
280 } | |
281 | |
3063 | 282 int DS_VideoDecoder_DecodeInternal(DS_VideoDecoder *this, const void* src, int size, int is_keyframe, char* pImage) |
1545 | 283 { |
284 IMediaSample* sample = 0; | |
3059 | 285 char* ptr; |
286 int result; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26544
diff
changeset
|
287 |
3063 | 288 Debug printf("DS_VideoDecoder_DecodeInternal(%p,%p,%d,%d,%p)\n",this,src,size,is_keyframe,pImage); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26544
diff
changeset
|
289 |
3059 | 290 this->m_pDS_Filter->m_pAll->vt->GetBuffer(this->m_pDS_Filter->m_pAll, &sample, 0, 0, 0); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26544
diff
changeset
|
291 |
1545 | 292 if (!sample) |
293 { | |
3059 | 294 Debug printf("ERROR: null sample\n"); |
1545 | 295 return -1; |
296 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26544
diff
changeset
|
297 |
1545 | 298 //cout << "DECODE " << (void*) pImage << " d: " << (void*) pImage->Data() << endl; |
299 | |
3059 | 300 |
3466 | 301 sample->vt->SetActualDataLength(sample, size); |
1545 | 302 sample->vt->GetPointer(sample, (BYTE **)&ptr); |
303 memcpy(ptr, src, size); | |
304 sample->vt->SetSyncPoint(sample, is_keyframe); | |
305 sample->vt->SetPreroll(sample, pImage ? 0 : 1); | |
306 // sample->vt->SetMediaType(sample, &m_sOurType); | |
307 | |
308 // FIXME: - crashing with YV12 at this place decoder will crash | |
309 // while doing this call | |
310 // %FS register was not setup for calling into win32 dll. Are all | |
311 // crashes inside ...->Receive() fixed now? | |
312 // | |
313 // nope - but this is surely helpfull - I'll try some more experiments | |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
9581
diff
changeset
|
314 #ifdef WIN32_LOADER |
3060 | 315 Setup_FS_Segment(); |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
9581
diff
changeset
|
316 #endif |
1545 | 317 #if 0 |
3059 | 318 if (!this->m_pDS_Filter || !this->m_pDS_Filter->m_pImp |
319 || !this->m_pDS_Filter->m_pImp->vt | |
320 || !this->m_pDS_Filter->m_pImp->vt->Receive) | |
1545 | 321 printf("DecodeInternal ERROR???\n"); |
322 #endif | |
3059 | 323 result = this->m_pDS_Filter->m_pImp->vt->Receive(this->m_pDS_Filter->m_pImp, sample); |
1545 | 324 if (result) |
325 { | |
326 Debug printf("DS_VideoDecoder::DecodeInternal() error putting data into input pin %x\n", result); | |
327 } | |
22398
49f01f8fbd60
Rework of copying samples from directshow codecs.
voroshil
parents:
22307
diff
changeset
|
328 if (pImage) |
49f01f8fbd60
Rework of copying samples from directshow codecs.
voroshil
parents:
22307
diff
changeset
|
329 { |
49f01f8fbd60
Rework of copying samples from directshow codecs.
voroshil
parents:
22307
diff
changeset
|
330 memcpy(pImage, sampleProcData.frame_pointer, sampleProcData.frame_size); |
49f01f8fbd60
Rework of copying samples from directshow codecs.
voroshil
parents:
22307
diff
changeset
|
331 } |
1545 | 332 sample->vt->Release((IUnknown*)sample); |
333 | |
3059 | 334 #if 0 |
335 if (this->m_bIsDivX) | |
1545 | 336 { |
337 int q; | |
3059 | 338 IHidden* hidden=(IHidden*)((int)this->m_pDS_Filter->m_pFilter + 0xb8); |
1545 | 339 // always check for actual value |
340 // this seems to be the only way to know the actual value | |
3059 | 341 hidden->vt->GetSmth2(hidden, &this->m_iLastQuality); |
342 if (this->m_iLastQuality > 9) | |
343 this->m_iLastQuality -= 10; | |
344 | |
345 if (this->m_iLastQuality < 0) | |
346 this->m_iLastQuality = 0; | |
347 else if (this->m_iLastQuality > this->m_iMaxAuto) | |
348 this->m_iLastQuality = this->m_iMaxAuto; | |
1545 | 349 |
3059 | 350 //cout << " Qual: " << this->m_iLastQuality << endl; |
351 this->iv.m_fQuality = this->m_iLastQuality / 4.0; | |
352 } | |
353 else if (this->m_bIsDivX4) | |
354 { | |
355 | |
356 // maybe access methods directly to safe some cpu cycles... | |
357 DS_VideoDecoder_GetValue(this, "Postprocessing", this->m_iLastQuality); | |
358 if (this->m_iLastQuality < 0) | |
359 this->m_iLastQuality = 0; | |
360 else if (this->m_iLastQuality > this->m_iMaxAuto) | |
361 this->m_iLastQuality = this->m_iMaxAuto; | |
1545 | 362 |
363 //cout << " Qual: " << m_iLastQuality << endl; | |
3059 | 364 this->iv.m_fQuality = this->m_iLastQuality / 6.0; |
1545 | 365 } |
366 | |
3059 | 367 if (this->iv.m_Mode == -1 ) // ???BUFFERED_QUALITY_AUTO) |
1545 | 368 { |
369 // adjust Quality - depends on how many cached frames we have | |
3059 | 370 int buffered = this->iv.m_iDecpos - this->iv.m_iPlaypos; |
1545 | 371 |
3059 | 372 if (this->m_bIsDivX || this->m_bIsDivX4) |
373 { | |
374 int to = buffered - this->m_iMinBuffers; | |
375 if (to < 0) | |
376 to = 0; | |
377 if (to != this->m_iLastQuality) | |
378 { | |
379 if (to > this->m_iMaxAuto) | |
380 to = this->m_iMaxAuto; | |
381 if (this->m_iLastQuality != to) | |
1545 | 382 { |
3059 | 383 if (this->m_bIsDivX) |
384 { | |
385 IHidden* hidden=(IHidden*)((int)this->m_pDS_Filter->m_pFilter + 0xb8); | |
386 hidden->vt->SetSmth(hidden, to, 0); | |
387 } | |
388 else | |
389 DS_VideoDecoder_SetValue(this, "Postprocessing", to); | |
1545 | 390 #ifndef QUIET |
3059 | 391 //printf("Switching quality %d -> %d b:%d\n",m_iLastQuality, to, buffered); |
1545 | 392 #endif |
393 } | |
394 } | |
395 } | |
396 } | |
3059 | 397 #endif |
1545 | 398 |
399 return 0; | |
400 } | |
401 | |
402 /* | |
403 * bits == 0 - leave unchanged | |
404 */ | |
3059 | 405 //int SetDestFmt(DS_VideoDecoder * this, int bits = 24, fourcc_t csp = 0); |
3946 | 406 int DS_VideoDecoder_SetDestFmt(DS_VideoDecoder *this, int bits, unsigned int csp) |
1545 | 407 { |
3059 | 408 HRESULT result; |
22307
68125c62b6eb
Fix loading of mpeg4ds direct show video codec under win32, broken in r22322
voroshil
parents:
22304
diff
changeset
|
409 ALLOCATOR_PROPERTIES props,props1; |
3059 | 410 int should_test=1; |
24394 | 411 int stopped = 0; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26544
diff
changeset
|
412 |
3059 | 413 Debug printf("DS_VideoDecoder_SetDestFmt (%p, %d, %d)\n",this,bits,(int)csp); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26544
diff
changeset
|
414 |
3059 | 415 /* if (!CImage::Supported(csp, bits)) |
1545 | 416 return -1; |
3059 | 417 */ |
1545 | 418 // BitmapInfo temp = m_obh; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26544
diff
changeset
|
419 |
3063 | 420 if (!csp) // RGB |
1545 | 421 { |
3059 | 422 int ok = true; |
1545 | 423 |
424 switch (bits) | |
425 { | |
426 case 15: | |
3059 | 427 this->m_sDestType.subtype = MEDIASUBTYPE_RGB555; |
1545 | 428 break; |
429 case 16: | |
3059 | 430 this->m_sDestType.subtype = MEDIASUBTYPE_RGB565; |
1545 | 431 break; |
432 case 24: | |
3059 | 433 this->m_sDestType.subtype = MEDIASUBTYPE_RGB24; |
1545 | 434 break; |
435 case 32: | |
3059 | 436 this->m_sDestType.subtype = MEDIASUBTYPE_RGB32; |
1545 | 437 break; |
438 default: | |
439 ok = false; | |
440 break; | |
441 } | |
442 | |
3059 | 443 if (ok) { |
9581 | 444 if (bits == 15) |
445 this->iv.m_obh.biBitCount=16; | |
446 else | |
447 this->iv.m_obh.biBitCount=bits; | |
3059 | 448 if( bits == 15 || bits == 16 ) { |
449 this->iv.m_obh.biSize=sizeof(BITMAPINFOHEADER)+12; | |
450 this->iv.m_obh.biCompression=3;//BI_BITFIELDS | |
451 this->iv.m_obh.biSizeImage=abs((int)(2*this->iv.m_obh.biWidth*this->iv.m_obh.biHeight)); | |
452 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26544
diff
changeset
|
453 |
3059 | 454 if( bits == 16 ) { |
455 this->iv.m_obh.colors[0]=0xF800; | |
456 this->iv.m_obh.colors[1]=0x07E0; | |
457 this->iv.m_obh.colors[2]=0x001F; | |
458 } else if ( bits == 15 ) { | |
459 this->iv.m_obh.colors[0]=0x7C00; | |
460 this->iv.m_obh.colors[1]=0x03E0; | |
461 this->iv.m_obh.colors[2]=0x001F; | |
462 } else { | |
463 this->iv.m_obh.biSize = sizeof(BITMAPINFOHEADER); | |
464 this->iv.m_obh.biCompression = 0; //BI_RGB | |
465 //this->iv.m_obh.biHeight = labs(this->iv.m_obh.biHeight); | |
466 this->iv.m_obh.biSizeImage = labs(this->iv.m_obh.biWidth * this->iv.m_obh.biHeight) | |
467 * ((this->iv.m_obh.biBitCount + 7) / 8); | |
468 } | |
469 } | |
1545 | 470 //.biSizeImage=abs(temp.biWidth*temp.biHeight*((temp.biBitCount+7)/8)); |
3063 | 471 } else |
472 { // YUV | |
3059 | 473 int ok = true; |
1545 | 474 switch (csp) |
475 { | |
476 case fccYUY2: | |
3059 | 477 this->m_sDestType.subtype = MEDIASUBTYPE_YUY2; |
1545 | 478 break; |
479 case fccYV12: | |
3059 | 480 this->m_sDestType.subtype = MEDIASUBTYPE_YV12; |
1545 | 481 break; |
482 case fccIYUV: | |
3059 | 483 this->m_sDestType.subtype = MEDIASUBTYPE_IYUV; |
1545 | 484 break; |
6527 | 485 case fccI420: |
486 this->m_sDestType.subtype = MEDIASUBTYPE_I420; | |
487 break; | |
1545 | 488 case fccUYVY: |
3059 | 489 this->m_sDestType.subtype = MEDIASUBTYPE_UYVY; |
1545 | 490 break; |
491 case fccYVYU: | |
3059 | 492 this->m_sDestType.subtype = MEDIASUBTYPE_YVYU; |
1545 | 493 break; |
6527 | 494 case fccYVU9: |
495 this->m_sDestType.subtype = MEDIASUBTYPE_YVU9; | |
1545 | 496 default: |
497 ok = false; | |
498 break; | |
499 } | |
500 | |
3059 | 501 if (ok) { |
502 if (csp != 0 && csp != 3 && this->iv.m_obh.biHeight > 0) | |
503 this->iv.m_obh.biHeight *= -1; // YUV formats uses should have height < 0 | |
504 this->iv.m_obh.biSize = sizeof(BITMAPINFOHEADER); | |
505 this->iv.m_obh.biCompression=csp; | |
506 this->iv.m_obh.biBitCount=bits; | |
507 this->iv.m_obh.biSizeImage=labs(this->iv.m_obh.biBitCount* | |
508 this->iv.m_obh.biWidth*this->iv.m_obh.biHeight)>>3; | |
509 } | |
1545 | 510 } |
3059 | 511 this->m_sDestType.lSampleSize = this->iv.m_obh.biSizeImage; |
512 memcpy(&(this->m_sVhdr2->bmiHeader), &this->iv.m_obh, sizeof(this->iv.m_obh)); | |
513 this->m_sVhdr2->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); | |
514 if (this->m_sVhdr2->bmiHeader.biCompression == 3) | |
515 this->m_sDestType.cbFormat = sizeof(VIDEOINFOHEADER) + 12; | |
1545 | 516 else |
3059 | 517 this->m_sDestType.cbFormat = sizeof(VIDEOINFOHEADER); |
1545 | 518 |
3059 | 519 |
1545 | 520 switch(csp) |
521 { | |
522 case fccYUY2: | |
3059 | 523 if(!(this->m_Caps & CAP_YUY2)) |
1545 | 524 should_test=false; |
525 break; | |
526 case fccYV12: | |
3059 | 527 if(!(this->m_Caps & CAP_YV12)) |
1545 | 528 should_test=false; |
529 break; | |
530 case fccIYUV: | |
3059 | 531 if(!(this->m_Caps & CAP_IYUV)) |
1545 | 532 should_test=false; |
533 break; | |
6527 | 534 case fccI420: |
535 if(!(this->m_Caps & CAP_I420)) | |
536 should_test=false; | |
537 break; | |
1545 | 538 case fccUYVY: |
3059 | 539 if(!(this->m_Caps & CAP_UYVY)) |
1545 | 540 should_test=false; |
541 break; | |
542 case fccYVYU: | |
3059 | 543 if(!(this->m_Caps & CAP_YVYU)) |
1545 | 544 should_test=false; |
545 break; | |
6527 | 546 case fccYVU9: |
547 if(!(this->m_Caps & CAP_YVU9)) | |
548 should_test=false; | |
549 break; | |
1545 | 550 } |
551 if(should_test) | |
3059 | 552 result = this->m_pDS_Filter->m_pOutputPin->vt->QueryAccept(this->m_pDS_Filter->m_pOutputPin, &this->m_sDestType); |
1545 | 553 else |
554 result = -1; | |
555 | |
556 if (result != 0) | |
557 { | |
558 if (csp) | |
3059 | 559 printf("Warning: unsupported color space\n"); |
1545 | 560 else |
3059 | 561 printf("Warning: unsupported bit depth\n"); |
1545 | 562 |
3059 | 563 this->m_sDestType.lSampleSize = this->iv.m_decoder.biSizeImage; |
564 memcpy(&(this->m_sVhdr2->bmiHeader), &this->iv.m_decoder, sizeof(this->iv.m_decoder)); | |
565 this->m_sVhdr2->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); | |
566 if (this->m_sVhdr2->bmiHeader.biCompression == 3) | |
567 this->m_sDestType.cbFormat = sizeof(VIDEOINFOHEADER) + 12; | |
1545 | 568 else |
3059 | 569 this->m_sDestType.cbFormat = sizeof(VIDEOINFOHEADER); |
1545 | 570 |
3059 | 571 return -1; |
1545 | 572 } |
573 | |
3059 | 574 memcpy( &this->iv.m_decoder, &this->iv.m_obh, sizeof(this->iv.m_obh)); |
1545 | 575 |
576 // m_obh=temp; | |
577 // if(csp) | |
578 // m_obh.biBitCount=BitmapInfo::BitCount(csp); | |
3059 | 579 this->iv.m_bh->biBitCount = bits; |
580 | |
581 //DS_VideoDecoder_Restart(this); | |
1545 | 582 |
3059 | 583 if (this->iv.m_State == START) |
1545 | 584 { |
3059 | 585 DS_VideoDecoder_StopInternal(this); |
586 this->iv.m_State = STOP; | |
24394 | 587 stopped = true; |
1545 | 588 } |
589 | |
3059 | 590 this->m_pDS_Filter->m_pInputPin->vt->Disconnect(this->m_pDS_Filter->m_pInputPin); |
591 this->m_pDS_Filter->m_pOutputPin->vt->Disconnect(this->m_pDS_Filter->m_pOutputPin); | |
3063 | 592 this->m_pDS_Filter->m_pOurOutput->SetNewFormat(this->m_pDS_Filter->m_pOurOutput,&this->m_sDestType); |
3059 | 593 result = this->m_pDS_Filter->m_pInputPin->vt->ReceiveConnection(this->m_pDS_Filter->m_pInputPin, |
594 this->m_pDS_Filter->m_pOurInput, | |
595 &this->m_sOurType); | |
1545 | 596 if (result) |
597 { | |
3059 | 598 printf("Error reconnecting input pin 0x%x\n", (int)result); |
1545 | 599 return -1; |
600 } | |
22307
68125c62b6eb
Fix loading of mpeg4ds direct show video codec under win32, broken in r22322
voroshil
parents:
22304
diff
changeset
|
601 |
68125c62b6eb
Fix loading of mpeg4ds direct show video codec under win32, broken in r22322
voroshil
parents:
22304
diff
changeset
|
602 if(this->m_pDS_Filter->m_pAll) |
68125c62b6eb
Fix loading of mpeg4ds direct show video codec under win32, broken in r22322
voroshil
parents:
22304
diff
changeset
|
603 this->m_pDS_Filter->m_pAll->vt->Release(this->m_pDS_Filter->m_pAll); |
68125c62b6eb
Fix loading of mpeg4ds direct show video codec under win32, broken in r22322
voroshil
parents:
22304
diff
changeset
|
604 this->m_pDS_Filter->m_pAll=MemAllocatorCreate(); |
68125c62b6eb
Fix loading of mpeg4ds direct show video codec under win32, broken in r22322
voroshil
parents:
22304
diff
changeset
|
605 if (!this->m_pDS_Filter->m_pAll) |
68125c62b6eb
Fix loading of mpeg4ds direct show video codec under win32, broken in r22322
voroshil
parents:
22304
diff
changeset
|
606 { |
68125c62b6eb
Fix loading of mpeg4ds direct show video codec under win32, broken in r22322
voroshil
parents:
22304
diff
changeset
|
607 printf("Call to MemAllocatorCreate failed\n"); |
68125c62b6eb
Fix loading of mpeg4ds direct show video codec under win32, broken in r22322
voroshil
parents:
22304
diff
changeset
|
608 return -1; |
68125c62b6eb
Fix loading of mpeg4ds direct show video codec under win32, broken in r22322
voroshil
parents:
22304
diff
changeset
|
609 } |
68125c62b6eb
Fix loading of mpeg4ds direct show video codec under win32, broken in r22322
voroshil
parents:
22304
diff
changeset
|
610 //Seting allocator property according to our media type |
68125c62b6eb
Fix loading of mpeg4ds direct show video codec under win32, broken in r22322
voroshil
parents:
22304
diff
changeset
|
611 props.cBuffers=1; |
68125c62b6eb
Fix loading of mpeg4ds direct show video codec under win32, broken in r22322
voroshil
parents:
22304
diff
changeset
|
612 props.cbBuffer=this->m_sDestType.lSampleSize; |
68125c62b6eb
Fix loading of mpeg4ds direct show video codec under win32, broken in r22322
voroshil
parents:
22304
diff
changeset
|
613 props.cbAlign=1; |
68125c62b6eb
Fix loading of mpeg4ds direct show video codec under win32, broken in r22322
voroshil
parents:
22304
diff
changeset
|
614 props.cbPrefix=0; |
68125c62b6eb
Fix loading of mpeg4ds direct show video codec under win32, broken in r22322
voroshil
parents:
22304
diff
changeset
|
615 this->m_pDS_Filter->m_pAll->vt->SetProperties(this->m_pDS_Filter->m_pAll, &props, &props1); |
68125c62b6eb
Fix loading of mpeg4ds direct show video codec under win32, broken in r22322
voroshil
parents:
22304
diff
changeset
|
616 //Notify remote pin about choosed allocator |
68125c62b6eb
Fix loading of mpeg4ds direct show video codec under win32, broken in r22322
voroshil
parents:
22304
diff
changeset
|
617 this->m_pDS_Filter->m_pImp->vt->NotifyAllocator(this->m_pDS_Filter->m_pImp, this->m_pDS_Filter->m_pAll, 0); |
68125c62b6eb
Fix loading of mpeg4ds direct show video codec under win32, broken in r22322
voroshil
parents:
22304
diff
changeset
|
618 |
3059 | 619 result = this->m_pDS_Filter->m_pOutputPin->vt->ReceiveConnection(this->m_pDS_Filter->m_pOutputPin, |
620 (IPin *)this->m_pDS_Filter->m_pOurOutput, | |
621 &this->m_sDestType); | |
1545 | 622 if (result) |
623 { | |
3059 | 624 printf("Error reconnecting output pin 0x%x\n", (int)result); |
1545 | 625 return -1; |
626 } | |
627 | |
24394 | 628 if (stopped) |
3059 | 629 { |
630 DS_VideoDecoder_StartInternal(this); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26544
diff
changeset
|
631 this->iv.m_State = START; |
3059 | 632 } |
1545 | 633 |
634 return 0; | |
635 } | |
636 | |
3059 | 637 |
638 int DS_VideoDecoder_SetDirection(DS_VideoDecoder *this, int d) | |
639 { | |
640 this->iv.m_obh.biHeight = (d) ? this->iv.m_bh->biHeight : -this->iv.m_bh->biHeight; | |
641 this->m_sVhdr2->bmiHeader.biHeight = this->iv.m_obh.biHeight; | |
642 return 0; | |
643 } | |
644 | |
3946 | 645 int DS_VideoDecoder_GetValue(DS_VideoDecoder *this, const char* name, int* value) |
1545 | 646 { |
3059 | 647 /* |
648 if (m_bIsDivX4) | |
649 { | |
650 IDivxFilterInterface* pIDivx; | |
651 if (m_pDS_Filter->m_pFilter->vt->QueryInterface((IUnknown*)m_pDS_Filter->m_pFilter, &IID_IDivxFilterInterface, (void**)&pIDivx)) | |
652 { | |
653 Debug printf("No such interface\n"); | |
654 return -1; | |
655 } | |
656 if (strcmp(name, "Postprocessing") == 0) | |
657 { | |
658 pIDivx->vt->get_PPLevel(pIDivx, &value); | |
659 value /= 10; | |
660 } | |
661 else if (strcmp(name, "Brightness") == 0) | |
662 pIDivx->vt->get_Brightness(pIDivx, &value); | |
663 else if (strcmp(name, "Contrast") == 0) | |
664 pIDivx->vt->get_Contrast(pIDivx, &value); | |
665 else if (strcmp(name, "Saturation") == 0) | |
666 pIDivx->vt->get_Saturation(pIDivx, &value); | |
667 else if (strcmp(name, "MaxAuto") == 0) | |
668 value = m_iMaxAuto; | |
669 pIDivx->vt->Release((IUnknown*)pIDivx); | |
670 return 0; | |
671 } | |
672 else if (m_bIsDivX) | |
1545 | 673 { |
674 if (m_State != START) | |
675 return VFW_E_NOT_RUNNING; | |
676 // brightness 87 | |
677 // contrast 74 | |
678 // hue 23 | |
679 // saturation 20 | |
680 // post process mode 0 | |
681 // get1 0x01 | |
682 // get2 10 | |
683 // get3=set2 86 | |
684 // get4=set3 73 | |
685 // get5=set4 19 | |
686 // get6=set5 23 | |
687 IHidden* hidden=(IHidden*)((int)m_pDS_Filter->m_pFilter+0xb8); | |
3059 | 688 if (strcmp(name, "Quality") == 0) |
689 { | |
32394
914208d188b9
Remove #warning preprocessor directives or replace them by suitable comments.
diego
parents:
32139
diff
changeset
|
690 // NOT SURE |
3059 | 691 int r = hidden->vt->GetSmth2(hidden, &value); |
692 if (value >= 10) | |
693 value -= 10; | |
694 return 0; | |
695 } | |
1545 | 696 if (strcmp(name, "Brightness") == 0) |
697 return hidden->vt->GetSmth3(hidden, &value); | |
698 if (strcmp(name, "Contrast") == 0) | |
699 return hidden->vt->GetSmth4(hidden, &value); | |
700 if (strcmp(name, "Hue") == 0) | |
701 return hidden->vt->GetSmth6(hidden, &value); | |
702 if (strcmp(name, "Saturation") == 0) | |
703 return hidden->vt->GetSmth5(hidden, &value); | |
3059 | 704 if (strcmp(name, "MaxAuto") == 0) |
1545 | 705 { |
3059 | 706 value = m_iMaxAuto; |
707 return 0; | |
1545 | 708 } |
709 } | |
3059 | 710 else if (strcmp((const char*)record.dll, "ir50_32.dll") == 0) |
1545 | 711 { |
712 IHidden2* hidden = 0; | |
713 if (m_pDS_Filter->m_pFilter->vt->QueryInterface((IUnknown*)m_pDS_Filter->m_pFilter, &IID_Iv50Hidden, (void**)&hidden)) | |
714 { | |
3059 | 715 Debug printf("No such interface\n"); |
1545 | 716 return -1; |
717 } | |
32394
914208d188b9
Remove #warning preprocessor directives or replace them by suitable comments.
diego
parents:
32139
diff
changeset
|
718 // FIXME |
1545 | 719 int recordpar[30]; |
720 recordpar[0]=0x7c; | |
721 recordpar[1]=fccIV50; | |
722 recordpar[2]=0x10005; | |
723 recordpar[3]=2; | |
724 recordpar[4]=1; | |
725 recordpar[5]=0x80000000; | |
726 | |
727 if (strcmp(name, "Brightness") == 0) | |
728 recordpar[5]|=0x20; | |
729 else if (strcmp(name, "Saturation") == 0) | |
730 recordpar[5]|=0x40; | |
731 else if (strcmp(name, "Contrast") == 0) | |
732 recordpar[5]|=0x80; | |
733 if (!recordpar[5]) | |
734 { | |
735 hidden->vt->Release((IUnknown*)hidden); | |
736 return -1; | |
737 } | |
738 if (hidden->vt->DecodeSet(hidden, recordpar)) | |
739 return -1; | |
740 | |
741 if (strcmp(name, "Brightness") == 0) | |
742 value = recordpar[18]; | |
743 else if (strcmp(name, "Saturation") == 0) | |
744 value = recordpar[19]; | |
745 else if (strcmp(name, "Contrast") == 0) | |
746 value = recordpar[20]; | |
747 | |
748 hidden->vt->Release((IUnknown*)hidden); | |
749 } | |
3059 | 750 */ |
1545 | 751 return 0; |
752 } | |
753 | |
3946 | 754 int DS_VideoDecoder_SetValue(DS_VideoDecoder *this, const char* name, int value) |
1545 | 755 { |
3957
49290522ab06
SetValue fixed, iv_State=START enabled (silly xine developers disabled for unknown reason)
arpi
parents:
3946
diff
changeset
|
756 if (this->m_bIsDivX4) { |
49290522ab06
SetValue fixed, iv_State=START enabled (silly xine developers disabled for unknown reason)
arpi
parents:
3946
diff
changeset
|
757 IDivxFilterInterface* pIDivx=NULL; |
3978 | 758 // printf("DS_SetValue for DIVX4, name=%s value=%d\n",name,value); |
3957
49290522ab06
SetValue fixed, iv_State=START enabled (silly xine developers disabled for unknown reason)
arpi
parents:
3946
diff
changeset
|
759 if (this->m_pDS_Filter->m_pFilter->vt->QueryInterface((IUnknown*)this->m_pDS_Filter->m_pFilter, &IID_IDivxFilterInterface, (void**)&pIDivx)) |
3059 | 760 { |
3957
49290522ab06
SetValue fixed, iv_State=START enabled (silly xine developers disabled for unknown reason)
arpi
parents:
3946
diff
changeset
|
761 printf("No such interface\n"); |
3059 | 762 return -1; |
763 } | |
6801 | 764 if (strcasecmp(name, "Postprocessing") == 0) |
3059 | 765 pIDivx->vt->put_PPLevel(pIDivx, value * 10); |
6801 | 766 else if (strcasecmp(name, "Brightness") == 0) |
3059 | 767 pIDivx->vt->put_Brightness(pIDivx, value); |
6801 | 768 else if (strcasecmp(name, "Contrast") == 0) |
3059 | 769 pIDivx->vt->put_Contrast(pIDivx, value); |
6801 | 770 else if (strcasecmp(name, "Saturation") == 0) |
3059 | 771 pIDivx->vt->put_Saturation(pIDivx, value); |
6801 | 772 else if (strcasecmp(name, "MaxAuto") == 0) |
3957
49290522ab06
SetValue fixed, iv_State=START enabled (silly xine developers disabled for unknown reason)
arpi
parents:
3946
diff
changeset
|
773 this->m_iMaxAuto = value; |
3059 | 774 pIDivx->vt->Release((IUnknown*)pIDivx); |
775 //printf("Set %s %d\n", name, value); | |
776 return 0; | |
777 } | |
3957
49290522ab06
SetValue fixed, iv_State=START enabled (silly xine developers disabled for unknown reason)
arpi
parents:
3946
diff
changeset
|
778 |
49290522ab06
SetValue fixed, iv_State=START enabled (silly xine developers disabled for unknown reason)
arpi
parents:
3946
diff
changeset
|
779 if (this->m_bIsDivX) { |
49290522ab06
SetValue fixed, iv_State=START enabled (silly xine developers disabled for unknown reason)
arpi
parents:
3946
diff
changeset
|
780 IHidden* hidden; |
49290522ab06
SetValue fixed, iv_State=START enabled (silly xine developers disabled for unknown reason)
arpi
parents:
3946
diff
changeset
|
781 if (this->iv.m_State != START) |
1545 | 782 return VFW_E_NOT_RUNNING; |
783 | |
784 //cout << "set value " << name << " " << value << endl; | |
785 // brightness 87 | |
786 // contrast 74 | |
787 // hue 23 | |
788 // saturation 20 | |
789 // post process mode 0 | |
790 // get1 0x01 | |
791 // get2 10 | |
792 // get3=set2 86 | |
793 // get4=set3 73 | |
794 // get5=set4 19 | |
3059 | 795 // get6=set5 23 |
3957
49290522ab06
SetValue fixed, iv_State=START enabled (silly xine developers disabled for unknown reason)
arpi
parents:
3946
diff
changeset
|
796 hidden = (IHidden*)((int)this->m_pDS_Filter->m_pFilter + 0xb8); |
7316 | 797 //printf("DS_SetValue for DIVX, name=%s value=%d\n",name,value); |
6801 | 798 if (strcasecmp(name, "Quality") == 0) |
1545 | 799 { |
3957
49290522ab06
SetValue fixed, iv_State=START enabled (silly xine developers disabled for unknown reason)
arpi
parents:
3946
diff
changeset
|
800 this->m_iLastQuality = value; |
1545 | 801 return hidden->vt->SetSmth(hidden, value, 0); |
802 } | |
6801 | 803 if (strcasecmp(name, "Brightness") == 0) |
1545 | 804 return hidden->vt->SetSmth2(hidden, value, 0); |
6801 | 805 if (strcasecmp(name, "Contrast") == 0) |
1545 | 806 return hidden->vt->SetSmth3(hidden, value, 0); |
6801 | 807 if (strcasecmp(name, "Saturation") == 0) |
1545 | 808 return hidden->vt->SetSmth4(hidden, value, 0); |
6801 | 809 if (strcasecmp(name, "Hue") == 0) |
1545 | 810 return hidden->vt->SetSmth5(hidden, value, 0); |
6801 | 811 if (strcasecmp(name, "MaxAuto") == 0) |
3059 | 812 { |
3957
49290522ab06
SetValue fixed, iv_State=START enabled (silly xine developers disabled for unknown reason)
arpi
parents:
3946
diff
changeset
|
813 this->m_iMaxAuto = value; |
3059 | 814 } |
3957
49290522ab06
SetValue fixed, iv_State=START enabled (silly xine developers disabled for unknown reason)
arpi
parents:
3946
diff
changeset
|
815 return 0; |
1545 | 816 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26544
diff
changeset
|
817 #if 0 |
3957
49290522ab06
SetValue fixed, iv_State=START enabled (silly xine developers disabled for unknown reason)
arpi
parents:
3946
diff
changeset
|
818 if (strcmp((const char*)record.dll, "ir50_32.dll") == 0) |
1545 | 819 { |
820 IHidden2* hidden = 0; | |
821 if (m_pDS_Filter->m_pFilter->vt->QueryInterface((IUnknown*)m_pDS_Filter->m_pFilter, &IID_Iv50Hidden, (void**)&hidden)) | |
822 { | |
3059 | 823 Debug printf("No such interface\n"); |
1545 | 824 return -1; |
825 } | |
826 int recordpar[30]; | |
827 recordpar[0]=0x7c; | |
828 recordpar[1]=fccIV50; | |
829 recordpar[2]=0x10005; | |
830 recordpar[3]=2; | |
831 recordpar[4]=1; | |
832 recordpar[5]=0x80000000; | |
833 if (strcmp(name, "Brightness") == 0) | |
834 { | |
835 recordpar[5]|=0x20; | |
836 recordpar[18]=value; | |
837 } | |
838 else if (strcmp(name, "Saturation") == 0) | |
839 { | |
840 recordpar[5]|=0x40; | |
841 recordpar[19]=value; | |
842 } | |
843 else if (strcmp(name, "Contrast") == 0) | |
844 { | |
845 recordpar[5]|=0x80; | |
846 recordpar[20]=value; | |
847 } | |
848 if(!recordpar[5]) | |
849 { | |
850 hidden->vt->Release((IUnknown*)hidden); | |
851 return -1; | |
852 } | |
853 HRESULT result = hidden->vt->DecodeSet(hidden, recordpar); | |
854 hidden->vt->Release((IUnknown*)hidden); | |
855 | |
856 return result; | |
857 } | |
3957
49290522ab06
SetValue fixed, iv_State=START enabled (silly xine developers disabled for unknown reason)
arpi
parents:
3946
diff
changeset
|
858 #endif |
3978 | 859 // printf("DS_SetValue for ????, name=%s value=%d\n",name,value); |
1545 | 860 return 0; |
861 } | |
3063 | 862 |
863 int DS_SetAttr_DivX(char* attribute, int value){ | |
7472
c4434bdf6e51
tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents:
7316
diff
changeset
|
864 int result, status, newkey; |
6801 | 865 if(strcasecmp(attribute, "Quality")==0){ |
3063 | 866 char* keyname="SOFTWARE\\Microsoft\\Scrunch"; |
867 result=RegCreateKeyExA(HKEY_CURRENT_USER, keyname, 0, 0, 0, 0, 0, &newkey, &status); | |
868 if(result!=0) | |
869 { | |
870 printf("VideoDecoder::SetExtAttr: registry failure\n"); | |
871 return -1; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26544
diff
changeset
|
872 } |
3063 | 873 result=RegSetValueExA(newkey, "Current Post Process Mode", 0, REG_DWORD, &value, 4); |
874 if(result!=0) | |
875 { | |
876 printf("VideoDecoder::SetExtAttr: error writing value\n"); | |
877 return -1; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26544
diff
changeset
|
878 } |
3063 | 879 value=-1; |
880 result=RegSetValueExA(newkey, "Force Post Process Mode", 0, REG_DWORD, &value, 4); | |
881 if(result!=0) | |
882 { | |
883 printf("VideoDecoder::SetExtAttr: error writing value\n"); | |
884 return -1; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26544
diff
changeset
|
885 } |
3063 | 886 RegCloseKey(newkey); |
887 return 0; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26544
diff
changeset
|
888 } |
3063 | 889 |
890 if( | |
6801 | 891 (strcasecmp(attribute, "Saturation")==0) || |
892 (strcasecmp(attribute, "Hue")==0) || | |
893 (strcasecmp(attribute, "Contrast")==0) || | |
894 (strcasecmp(attribute, "Brightness")==0) | |
3063 | 895 ) |
896 { | |
897 char* keyname="SOFTWARE\\Microsoft\\Scrunch\\Video"; | |
898 result=RegCreateKeyExA(HKEY_CURRENT_USER, keyname, 0, 0, 0, 0, 0, &newkey, &status); | |
899 if(result!=0) | |
900 { | |
901 printf("VideoDecoder::SetExtAttr: registry failure\n"); | |
902 return -1; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26544
diff
changeset
|
903 } |
3063 | 904 result=RegSetValueExA(newkey, attribute, 0, REG_DWORD, &value, 4); |
905 if(result!=0) | |
906 { | |
907 printf("VideoDecoder::SetExtAttr: error writing value\n"); | |
908 return -1; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26544
diff
changeset
|
909 } |
3063 | 910 RegCloseKey(newkey); |
911 return 0; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26544
diff
changeset
|
912 } |
3063 | 913 |
914 printf("Unknown attribute!\n"); | |
915 return -200; | |
916 } |