aboutsummaryrefslogtreecommitdiff
path: root/Patches/vframe.h
blob: 232b16612dc02db11717c2fb5decb4e58e5cc8d0 (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
#ifndef __VFRAME_H
#define __VFRAME_H

#include "plugin.h"

struct vframeimage
{
	char bitsname[40];	// name of shared memory to image data
				// use this, not f.bits!
	_frame f;		// image header, see Plugins\plugin.h
};

LPVOID openframedatabyid(	int id,
				HANDLE *hvf, HANDLE *hbits,
				LPVOID *memvf, LPVOID *membits,
				struct vframeimage **vfp )
{
	char s[80];

	if(*membits!=NULL) smfree(hbits, *membits);
	if(*memvf!=NULL) smfree(hvf, *memvf);

	*membits=NULL;

	itoa(id, s, 10);

	*memvf = smopen(hvf, s);
	if(*memvf!=NULL)
	{
		*vfp = *memvf;

		*membits = smopen(hbits, ((struct vframeimage *)*vfp)->bitsname);
		if(*membits==NULL)
		{
			printf("membits open error.\n");
			smfree(hvf, *memvf);
		} else {
		}
	}
	return(*membits);
}

float max16 = 2<<14;
float max32 = 2<<23;

__inline float colortosample16(short c)
{
	return(c / max16);
}

__inline float colortosample32(long c)
{
	return(c / max32);
}

__inline short sampletocolor16(float s)
{
	return(s * max16);
}

__inline long sampletocolor32(float s)
{
	return(s * max32);
}

#endif