summaryrefslogtreecommitdiffstats
path: root/loader/dshow/DS_VideoDecoder.c
blob: a04817c49590dff5b71d1bdeb7a1554a196416b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
/********************************************************

	DirectShow Video decoder implementation
	Copyright 2000 Eugene Kuznetsov  (divx@euro.ru)

*********************************************************/

#include "guids.h"
#include "interfaces.h"

#include "DS_VideoDecoder.h"
#include "wine/winerror.h"
#include "ldt_keeper.h"
//#include <wine/winerror.h>

#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <cstdio>
#include <iostream>
#include <strstream>

#define __MODULE__ "DirectShow_VideoDecoder"

using namespace std;

DS_VideoDecoder::DS_VideoDecoder(const CodecInfo& info, const BITMAPINFOHEADER& format, int flip)
    :IVideoDecoder(info, format)
{
    m_sVhdr2 = 0;
    m_iLastQuality = -1;
    //memset(&m_obh, 0, sizeof(m_obh));
    //m_obh.biSize = sizeof(m_obh);
    try
    {
	m_pDS_Filter = new DS_Filter();

	unsigned bihs = (format.biSize < (int) sizeof(BITMAPINFOHEADER)) ?
	    sizeof(BITMAPINFOHEADER) : format.biSize;
        bihs = sizeof(VIDEOINFOHEADER) - sizeof(BITMAPINFOHEADER) + bihs;

	m_sVhdr = (VIDEOINFOHEADER*) new char[bihs];
	memset(m_sVhdr, 0, bihs);
	memcpy(&m_sVhdr->bmiHeader, m_bh, m_bh->biSize);
	m_sVhdr->rcSource.left = m_sVhdr->rcSource.top = 0;
	m_sVhdr->rcSource.right = m_sVhdr->bmiHeader.biWidth;
        m_sVhdr->rcSource.bottom = m_sVhdr->bmiHeader.biHeight;
	m_sVhdr->rcTarget = m_sVhdr->rcSource;

	m_sOurType.majortype = MEDIATYPE_Video;
	m_sOurType.subtype = MEDIATYPE_Video;
        m_sOurType.subtype.f1 = m_sVhdr->bmiHeader.biCompression;
	m_sOurType.formattype = FORMAT_VideoInfo;
        m_sOurType.bFixedSizeSamples = false;
	m_sOurType.bTemporalCompression = true;
	m_sOurType.pUnk = 0;
        m_sOurType.cbFormat = bihs;
        m_sOurType.pbFormat = (char*)m_sVhdr;

	m_sVhdr2 = (VIDEOINFOHEADER*)(new char[sizeof(VIDEOINFOHEADER)+12]);
	memcpy(m_sVhdr2, m_sVhdr, sizeof(VIDEOINFOHEADER));
	memset((char*)m_sVhdr2 + sizeof(VIDEOINFOHEADER), 0, 12);
	m_sVhdr2->bmiHeader.biCompression = 0;
	m_sVhdr2->bmiHeader.biBitCount = 24;

	memset(&m_sDestType, 0, sizeof(m_sDestType));
	m_sDestType.majortype = MEDIATYPE_Video;
	m_sDestType.subtype = MEDIASUBTYPE_RGB24;
	m_sDestType.formattype = FORMAT_VideoInfo;
	m_sDestType.bFixedSizeSamples = true;
	m_sDestType.bTemporalCompression = false;
	m_sDestType.lSampleSize = abs(m_sVhdr2->bmiHeader.biWidth*m_sVhdr2->bmiHeader.biHeight
				      * ((m_sVhdr2->bmiHeader.biBitCount + 7) / 8));
	m_sVhdr2->bmiHeader.biSizeImage = m_sDestType.lSampleSize;
	m_sDestType.pUnk = 0;
	m_sDestType.cbFormat = sizeof(VIDEOINFOHEADER);
        m_sDestType.pbFormat = (char*)m_sVhdr2;
	memset(&m_obh, 0, sizeof(m_obh));
	memcpy(&m_obh, m_bh, sizeof(m_obh) < m_bh->biSize ? sizeof(m_obh) : m_bh->biSize);
	m_obh.SetBits(24);

	HRESULT result;

	m_pDS_Filter->Create(info.dll.c_str(), &info.guid, &m_sOurType, &m_sDestType);

	if (!flip)
	{
	    m_sVhdr2->bmiHeader.biHeight *= -1;
	    m_obh.biHeight *= -1;
	    result = m_pDS_Filter->m_pOutputPin->vt->QueryAccept(m_pDS_Filter->m_pOutputPin, &m_sDestType);
	    if (result)
	    {
		cerr << "Decoder does not support upside-down frames" << endl;
		m_sVhdr2->bmiHeader.biHeight *= -1;
		m_obh.biHeight *= -1;
	    }
	}

	m_decoder = m_obh;

	switch (m_bh->biCompression)
	{
	case fccDIV3:
	case fccDIV4:
	case fccDIV5:
	case fccMP42:
	case fccWMV2:
	    //YV12 seems to be broken for DivX :-) codec
	case fccIV50:
	    //produces incorrect picture
	    //m_Caps = (CAPS) (m_Caps & ~CAP_YV12);
	    m_Caps = CAP_YUY2; // | CAP_I420;
	    break;
	default:
	    struct ct {
		unsigned int bits;
		fourcc_t fcc;
		GUID subtype;
		CAPS cap;
	    } check[] = {
		{16, fccYUY2, MEDIASUBTYPE_YUY2, CAP_YUY2},
		{12, fccIYUV, MEDIASUBTYPE_IYUV, CAP_IYUV},
		{16, fccUYVY, MEDIASUBTYPE_UYVY, CAP_UYVY},
		{12, fccYV12, MEDIASUBTYPE_YV12, CAP_YV12},
		{16, fccYV12, MEDIASUBTYPE_YV12, CAP_YV12},
		{16, fccYVYU, MEDIASUBTYPE_YVYU, CAP_YVYU},
		//{12, fccI420, MEDIASUBTYPE_I420, CAP_I420},
		{0},
	    };

	    m_Caps = CAP_NONE;

	    for (ct* c = check; c->bits; c++)
	    {
		m_sVhdr2->bmiHeader.biBitCount = c->bits;
		m_sVhdr2->bmiHeader.biCompression = c->fcc;
		m_sDestType.subtype = c->subtype;
		result = m_pDS_Filter->m_pOutputPin->vt->QueryAccept(m_pDS_Filter->m_pOutputPin, &m_sDestType);
		if (!result)
		    m_Caps = (CAPS)(m_Caps | c->cap);
	    }
	}

	if (m_Caps != CAP_NONE)
	    cout << "Decoder is capable of YUV output ( flags 0x"<<hex<<(int)m_Caps<<dec<<" )"<<endl;

	m_sVhdr2->bmiHeader.biBitCount = 24;
	m_sVhdr2->bmiHeader.biCompression = 0;
	m_sDestType.subtype = MEDIASUBTYPE_RGB24;

	m_bIsDivX = ((info.dll == string("divxcvki.ax"))
		     || (info.dll == string("divx_c32.ax"))
		     || (info.dll == string("wmvds32.ax"))
		     || (info.dll == string("wmv8ds32.ax")));

	printf("m_bIsDivX=%d\n",m_bIsDivX);
    }
    catch (FatalError& error)
    {
	delete[] m_sVhdr2;
        delete m_pDS_Filter;
	throw;
    }
}

DS_VideoDecoder::~DS_VideoDecoder()
{
    Stop();
    delete[] m_sVhdr2;
    delete m_pDS_Filter;
}

void DS_VideoDecoder::StartInternal()
{
    //cout << "DSSTART" << endl;
    m_pDS_Filter->Start();
    ALLOCATOR_PROPERTIES props, props1;
    props.cBuffers = 1;
    props.cbBuffer = m_sDestType.lSampleSize;
    //don't know how to do this correctly
    props.cbAlign = props.cbPrefix = 0;
    m_pDS_Filter->m_pAll->vt->SetProperties(m_pDS_Filter->m_pAll, &props, &props1);
    m_pDS_Filter->m_pAll->vt->Commit(m_pDS_Filter->m_pAll);
}

void DS_VideoDecoder::StopInternal()
{
    //cout << "DSSTOP" << endl;
    m_pDS_Filter->Stop();
    //??? why was this here ??? m_pOurOutput->SetFramePointer(0);
}

int DS_VideoDecoder::DecodeInternal(void* src, size_t size, int is_keyframe, CImage* pImage)
{
    IMediaSample* sample = 0;

    m_pDS_Filter->m_pAll->vt->GetBuffer(m_pDS_Filter->m_pAll, &sample, 0, 0, 0);

    if (!sample)
    {
	Debug cerr << "ERROR: null sample" << endl;
	return -1;
    }

    //cout << "DECODE " << (void*) pImage << "   d: " << (void*) pImage->Data() << endl;
    if (pImage)
    {
	if (!(pImage->Data()))
	{
	    Debug cout << "no m_outFrame??" << endl;
	}
	else
	    m_pDS_Filter->m_pOurOutput->SetPointer2((char*)pImage->Data());
    }

    char* ptr;
    sample->vt->GetPointer(sample, (BYTE **)&ptr);
    memcpy(ptr, src, size);
    sample->vt->SetActualDataLength(sample, size);
    sample->vt->SetSyncPoint(sample, is_keyframe);
    sample->vt->SetPreroll(sample, pImage ? 0 : 1);
    // sample->vt->SetMediaType(sample, &m_sOurType);

    // FIXME: - crashing with YV12 at this place decoder will crash
    //          while doing this call
    // %FS register was not setup for calling into win32 dll. Are all
    // crashes inside ...->Receive() fixed now?
    //
    // nope - but this is surely helpfull - I'll try some more experiments
    Setup_FS_Segment();
#if 0
    if (!m_pDS_Filter || !m_pDS_Filter->m_pImp
	|| !m_pDS_Filter->m_pImp->vt
	|| !m_pDS_Filter->m_pImp->vt->Receive)
	printf("DecodeInternal ERROR???\n");
#endif
    int result = m_pDS_Filter->m_pImp->vt->Receive(m_pDS_Filter->m_pImp, sample);
    if (result)
    {
	Debug printf("DS_VideoDecoder::DecodeInternal() error putting data into input pin %x\n", result);
    }

    sample->vt->Release((IUnknown*)sample);

    if (m_bIsDivX)
    {
	int q;
	IHidden* hidden=(IHidden*)((int)m_pDS_Filter->m_pFilter + 0xb8);
	// always check for actual value
	// this seems to be the only way to know the actual value
	hidden->vt->GetSmth2(hidden, &m_iLastQuality);
	if (m_iLastQuality > 9)
	    m_iLastQuality -= 10;

	if (m_iLastQuality < 0)
	    m_iLastQuality = 0;
	else if (m_iLastQuality > 4)
	    m_iLastQuality = 4;

	//cout << " Qual: " << m_iLastQuality << endl;
	m_fQuality = m_iLastQuality / 4.0;
    }

    // FIXME: last_quality currently works only for DivX movies
    // more general approach is needed here
    // cout << "Q: " << m_iLastQuality << "  rt: " << m_Mode << " dp: " << decpos << endl;
    // also accesing vbuf doesn't look very nice at this place
    // FIXME later - do it as a virtual method

    if (m_Mode == IVideoDecoder::REALTIME_QUALITY_AUTO)
    {
	// adjust Quality - depends on how many cached frames we have
	int buffered = m_iDecpos - m_iPlaypos;

	if (m_bIsDivX)
	{
	    //cout << "qual " << q << "  " << buffered << endl;
	    if (buffered < (m_iLastQuality * 2 + QMARKLO - 1)
		|| buffered > ((m_iLastQuality + 1) * 2 + QMARKLO))
	    {
		// removed old code which was present here
		// and replaced with this new uptodate one

		int to = (buffered - QMARKLO) / 2;
		if (to < 0)
		    to = 0;
		else if (to > 4)
		    to = 4;
		if (m_iLastQuality != to)
		{
		    IHidden* hidden=(IHidden*)((int)m_pDS_Filter->m_pFilter + 0xb8);
		    hidden->vt->SetSmth(hidden, to, 0);
#ifndef QUIET
		    //cout << "Switching quality " << m_iLastQuality <<  " -> " << to << "  b:" << buffered << endl;
#endif
		}
	    }
	}
    }


    return 0;
}

/*
 * bits == 0   - leave unchanged
 */
int DS_VideoDecoder::SetDestFmt(int bits, fourcc_t csp)
{
    if (!CImage::Supported(csp, bits))
	return -1;

    // BitmapInfo temp = m_obh;
    if (bits != 0)
    {
	bool ok = true;

	switch (bits)
        {
	case 15:
	    m_sDestType.subtype = MEDIASUBTYPE_RGB555;
    	    break;
	case 16:
	    m_sDestType.subtype = MEDIASUBTYPE_RGB565;
	    break;
	case 24:
	    m_sDestType.subtype = MEDIASUBTYPE_RGB24;
	    break;
	case 32:
	    m_sDestType.subtype = MEDIASUBTYPE_RGB32;
	    break;
	default:
            ok = false;
	    break;
	}

        if (ok)
	    m_obh.SetBits(bits);
	//.biSizeImage=abs(temp.biWidth*temp.biHeight*((temp.biBitCount+7)/8));
    }

    if (csp != 0)
    {
        bool ok = true;
	switch (csp)
	{
	case fccYUY2:
	    m_sDestType.subtype = MEDIASUBTYPE_YUY2;
	    break;
	case fccYV12:
	    m_sDestType.subtype = MEDIASUBTYPE_YV12;
	    break;
	case fccIYUV:
	    m_sDestType.subtype = MEDIASUBTYPE_IYUV;
	    break;
	case fccUYVY:
	    m_sDestType.subtype = MEDIASUBTYPE_UYVY;
	    break;
	case fccYVYU:
	    m_sDestType.subtype = MEDIASUBTYPE_YVYU;
	    break;
	default:
	    ok = false;
            break;
	}

        if (ok)
	    m_obh.SetSpace(csp);
    }
    m_sDestType.lSampleSize = m_obh.biSizeImage;
    memcpy(&(m_sVhdr2->bmiHeader), &m_obh, sizeof(m_obh));
    m_sVhdr2->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
    if (m_sVhdr2->bmiHeader.biCompression == 3)
        m_sDestType.cbFormat = sizeof(VIDEOINFOHEADER) + 12;
    else
        m_sDestType.cbFormat = sizeof(VIDEOINFOHEADER);

    HRESULT result;
    bool should_test=true;
    switch(csp)
    {
    case fccYUY2:
	if(!(m_Caps & CAP_YUY2))
	    should_test=false;
	break;
    case fccYV12:
	if(!(m_Caps & CAP_YV12))
	    should_test=false;
	break;
    case fccIYUV:
	if(!(m_Caps & CAP_IYUV))
	    should_test=false;
	break;
    case fccUYVY:
	if(!(m_Caps & CAP_UYVY))
	    should_test=false;
	break;
    case fccYVYU:
	if(!(m_Caps & CAP_YVYU))
	    should_test=false;
	break;
    }
    if(should_test)
	result = m_pDS_Filter->m_pOutputPin->vt->QueryAccept(m_pDS_Filter->m_pOutputPin, &m_sDestType);
    else
	result = -1;

    if (result != 0)
    {
	if (csp)
	    cerr << "Warning: unsupported color space" << endl;
	else
	    cerr << "Warning: unsupported bit depth" << endl;

	m_sDestType.lSampleSize = m_decoder.biSizeImage;
	memcpy(&(m_sVhdr2->bmiHeader), &m_decoder, sizeof(m_decoder));
	m_sVhdr2->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
	if(m_sVhdr2->bmiHeader.biCompression == 3)
    	    m_sDestType.cbFormat = sizeof(VIDEOINFOHEADER) + 12;
	else
    	    m_sDestType.cbFormat = sizeof(VIDEOINFOHEADER);

	return 1;
    }

    m_decoder = m_obh;

//    m_obh=temp;
//    if(csp)
//	m_obh.biBitCount=BitmapInfo::BitCount(csp);
    m_bh->biBitCount = bits;

    //Restart();
    bool stoped = false;
    if (m_State == START)
    {
	Stop();
        stoped = true;
    }

    m_pDS_Filter->m_pInputPin->vt->Disconnect(m_pDS_Filter->m_pInputPin);
    m_pDS_Filter->m_pOutputPin->vt->Disconnect(m_pDS_Filter->m_pOutputPin);
    m_pDS_Filter->m_pOurOutput->SetNewFormat(m_sDestType);
    result = m_pDS_Filter->m_pInputPin->vt->ReceiveConnection(m_pDS_Filter->m_pInputPin,
							      m_pDS_Filter->m_pOurInput,
							      &m_sOurType);
    if (result)
    {
	cerr<<"Error reconnecting input pin "<<hex<<result<<dec<<endl;
	return -1;
    }
    result = m_pDS_Filter->m_pOutputPin->vt->ReceiveConnection(m_pDS_Filter->m_pOutputPin,
							       m_pDS_Filter->m_pOurOutput,
							       &m_sDestType);
    if (result)
    {
	cerr<<"Error reconnecting output pin "<<hex<<result<<dec<<endl;
	return -1;
    }

    if (stoped)
	Start();

    return 0;
}

HRESULT DS_VideoDecoder::GetValue(const char* name, int& value)
{
    if (m_bIsDivX)
    {
	if (m_State != START)
	    return VFW_E_NOT_RUNNING;
// brightness 87
// contrast 74
// hue 23
// saturation 20
// post process mode 0
// get1 0x01
// get2 10
// get3=set2 86
// get4=set3 73
// get5=set4 19
// get6=set5 23
	IHidden* hidden=(IHidden*)((int)m_pDS_Filter->m_pFilter+0xb8);
	if (strcmp(name, "Brightness") == 0)
	    return hidden->vt->GetSmth3(hidden, &value);
	if (strcmp(name, "Contrast") == 0)
	    return hidden->vt->GetSmth4(hidden, &value);
	if (strcmp(name, "Hue") == 0)
	    return hidden->vt->GetSmth6(hidden, &value);
	if (strcmp(name, "Saturation") == 0)
	    return hidden->vt->GetSmth5(hidden, &value);
	if (strcmp(name, "Quality") == 0)
	{
#warning NOT SURE
	    int r = hidden->vt->GetSmth2(hidden, &value);
	    if (value >= 10)
		value -= 10;
	    return 0;
	}
    }
    else if (record.dll == string("ir50_32.dll"))
    {
	IHidden2* hidden = 0;
	if (m_pDS_Filter->m_pFilter->vt->QueryInterface((IUnknown*)m_pDS_Filter->m_pFilter, &IID_Iv50Hidden, (void**)&hidden))
	{
	    cerr << "No such interface" << endl;
	    return -1;
	}
#warning FIXME
	int recordpar[30];
	recordpar[0]=0x7c;
	recordpar[1]=fccIV50;
	recordpar[2]=0x10005;
	recordpar[3]=2;
	recordpar[4]=1;
	recordpar[5]=0x80000000;

	if (strcmp(name, "Brightness") == 0)
	    recordpar[5]|=0x20;
	else if (strcmp(name, "Saturation") == 0)
	    recordpar[5]|=0x40;
	else if (strcmp(name, "Contrast") == 0)
	    recordpar[5]|=0x80;
	if (!recordpar[5])
	{
	    hidden->vt->Release((IUnknown*)hidden);
	    return -1;
	}
	if (hidden->vt->DecodeSet(hidden, recordpar))
	    return -1;

	if (strcmp(name, "Brightness") == 0)
	    value = recordpar[18];
	else if (strcmp(name, "Saturation") == 0)
	    value = recordpar[19];
	else if (strcmp(name, "Contrast") == 0)
	    value = recordpar[20];

	hidden->vt->Release((IUnknown*)hidden);
    }

    return 0;
}

HRESULT DS_VideoDecoder::SetValue(const char* name, int value)
{
    if (m_bIsDivX)
    {

	if (m_State != START)
	    return VFW_E_NOT_RUNNING;

    	/* This printf is annoying with autoquality, *
     	 * should be moved into players code - atmos */
	//printf("DS_VideoDecoder::SetValue(%s,%d)\n",name,value);

	//cout << "set value " << name << "  " << value << endl;
// brightness 87
// contrast 74
// hue 23
// saturation 20
// post process mode 0
// get1 0x01
// get2 10
// get3=set2 86
// get4=set3 73
// get5=set4 19
// get6=set5 23
    	IHidden* hidden = (IHidden*)((int)m_pDS_Filter->m_pFilter + 0xb8);
	if (strcmp(name, "Quality") == 0)
	{
            m_iLastQuality = value;
	    return hidden->vt->SetSmth(hidden, value, 0);
	}
	if (strcmp(name, "Brightness") == 0)
	    return hidden->vt->SetSmth2(hidden, value, 0);
	if (strcmp(name, "Contrast") == 0)
	    return hidden->vt->SetSmth3(hidden, value, 0);
	if (strcmp(name, "Saturation") == 0)
	    return hidden->vt->SetSmth4(hidden, value, 0);
	if (strcmp(name, "Hue") == 0)
	    return hidden->vt->SetSmth5(hidden, value, 0);
    }
    else if (record.dll == string("ir50_32.dll"))
    {
	IHidden2* hidden = 0;
	if (m_pDS_Filter->m_pFilter->vt->QueryInterface((IUnknown*)m_pDS_Filter->m_pFilter, &IID_Iv50Hidden, (void**)&hidden))
	{
	    Debug cerr << "No such interface" << endl;
	    return -1;
	}
	int recordpar[30];
	recordpar[0]=0x7c;
	recordpar[1]=fccIV50;
	recordpar[2]=0x10005;
	recordpar[3]=2;
	recordpar[4]=1;
	recordpar[5]=0x80000000;
	if (strcmp(name, "Brightness") == 0)
	{
	    recordpar[5]|=0x20;
	    recordpar[18]=value;
	}
	else if (strcmp(name, "Saturation") == 0)
	{
	    recordpar[5]|=0x40;
	    recordpar[19]=value;
	}
	else if (strcmp(name, "Contrast") == 0)
	{
	    recordpar[5]|=0x80;
	    recordpar[20]=value;
	}
	if(!recordpar[5])
	{
	    hidden->vt->Release((IUnknown*)hidden);
    	    return -1;
	}
	HRESULT result = hidden->vt->DecodeSet(hidden, recordpar);
	hidden->vt->Release((IUnknown*)hidden);

	return result;
    }
    return 0;
}
/*
vim: tabstop=8
*/