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