1 #define NG_PRIVATE
2 #include "config.h"
3 
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <unistd.h>
7 #include <pthread.h>
8 #include <sys/time.h>
9 #include <sys/types.h>
10 
11 #include "grab-ng.h"
12 
13 /* ------------------------------------------------------------------- */
14 
15 void*
ng_packed_init(struct ng_video_fmt * out,void * priv)16 ng_packed_init(struct ng_video_fmt *out, void *priv)
17 {
18     return priv;
19 }
20 
21 void
ng_packed_frame(void * handle,struct ng_video_buf * out,struct ng_video_buf * in)22 ng_packed_frame(void *handle, struct ng_video_buf *out,
23 		struct ng_video_buf *in)
24 {
25     int (*func)(unsigned char *dest, unsigned char *src, int p) = handle;
26     unsigned char *sp,*dp;
27     unsigned int i,sw,dw;
28 
29     dw  = (out->fmt.width * ng_vfmt_to_depth[out->fmt.fmtid]) >> 3;
30     sw  = (in->fmt.width  * ng_vfmt_to_depth[in->fmt.fmtid])  >> 3;
31     if (in->fmt.bytesperline == sw && out->fmt.bytesperline == dw) {
32 	/* can convert in one go */
33 	func(out->data, in->data, in->fmt.width * in->fmt.height);
34     } else {
35 	/* convert line by line */
36 	dp = out->data;
37 	sp = in->data;
38 	for (i = 0; i < in->fmt.height; i++) {
39 	    func(dp,sp,in->fmt.width);
40 	    dp += out->fmt.bytesperline;
41 	    sp += in->fmt.bytesperline;
42 	}
43     }
44 }
45 
46 /* ------------------------------------------------------------------- */
47 
48 void*
ng_conv_nop_init(struct ng_video_fmt * out,void * priv)49 ng_conv_nop_init(struct ng_video_fmt *out, void *priv)
50 {
51     /* nothing */
52     return NULL;
53 }
54 
55 void
ng_conv_nop_fini(void * handle)56 ng_conv_nop_fini(void *handle)
57 {
58     /* nothing */
59 }
60