aboutsummaryrefslogtreecommitdiff
path: root/Plugins/vf2fs.c
blob: 31460f187b7df799fd169a13e80840e3f1aa0f33 (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
//
// vf2fs.c
// used to display vframe objects
//
// 1st argument is name of shared memory
// to struct vframeimage (see Patches\vframe.h)
//

#include <memory.h>
#include "plugin.h"
#include "sharemem.h"
#include "vframe.h"

INFO("display vframe contents, used automatically by fs.frame")

void perform_effect(_frame f, _args a)
{
	HANDLE hlvframe=NULL, hl=NULL;
	LPVOID p=NULL;
	struct vframeimage *vfp=NULL;
	unsigned long c;

	if(!a.s) return;

	vfp = (struct vframeimage *)smopen(&hlvframe, a.s);
	if(vfp==NULL) return;

//	printf("name %s width %d height %d pf %d bits %s\n",
//	 a.s, vfp->f.width, vfp->f.height, vfp->f.pixelformat, vfp->bitsname);

	if(f.pixelformat != vfp->f.pixelformat)
	{
		printf("vf2fs: pixelformats are different. no resampling available.\n");
		return;
	}

	p = smopen(&hl, vfp->bitsname);
	if(p==NULL)
	{
		CloseHandle(hlvframe);
		return;
	}

	c = (f.height*f.lpitch < vfp->f.height*vfp->f.lpitch) ?
	 f.height*f.lpitch : vfp->f.height*vfp->f.lpitch;

	memcpy(f.bits, p, c);

	smfree(&hl, p);
	smfree(&hlvframe, vfp);
}