Mercurial > vloopback
annotate example/invert.c @ 17:5afb0aa410ec default tip
update to 2.6.34
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Sun, 25 Jul 2010 23:29:20 +0900 |
parents | 2fce9e157b8d |
children |
rev | line source |
---|---|
0 | 1 /* invert.c |
2 * | |
3 * Example program for videoloopback device. | |
4 * Copyright 2000 by Jeroen Vreeken (pe1rxq@amsat.org) | |
5 * Copyright 2005 by Angel Carpintero (ack@telefonica.net) | |
6 * This software is distributed under the GNU public license version 2 | |
7 * See also the file 'COPYING'. | |
8 * | |
9 */ | |
10 | |
11 #include <unistd.h> | |
12 #include <stdlib.h> | |
13 #include <stdio.h> | |
14 #include <fcntl.h> | |
15 #include <string.h> | |
16 #include <errno.h> | |
17 #include <sys/ioctl.h> | |
18 #include <sys/mman.h> | |
19 #include <signal.h> | |
20 #include <sys/wait.h> | |
21 #include <linux/videodev.h> | |
22 | |
23 | |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
24 int fmt = 0; |
0 | 25 int noexit = 1; |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
26 int read_img = 0; |
0 | 27 |
28 char *start_capture (int dev, int width, int height) | |
29 { | |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
30 struct video_capability vid_caps; |
0 | 31 struct video_window vid_win; |
32 struct video_mbuf vid_buf; | |
33 char *map; | |
34 | |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
35 if (ioctl(dev, VIDIOCGCAP, &vid_caps) == -1) { |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
36 printf ("ioctl (VIDIOCGCAP)\nError[%s]\n", strerror(errno)); |
0 | 37 return (NULL); |
38 } | |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
39 if (vid_caps.type & VID_TYPE_MONOCHROME) |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
40 fmt = VIDEO_PALETTE_GREY; |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
41 |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
42 if (ioctl(dev, VIDIOCGMBUF, &vid_buf) == -1) { |
0 | 43 fprintf(stderr, "no mmap falling back on read\n"); |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
44 |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
45 if (ioctl(dev, VIDIOCGWIN, &vid_win) == -1) { |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
46 printf ("ioctl VIDIOCGWIN\nError[%s]\n", strerror(errno)); |
0 | 47 return (NULL); |
48 } | |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
49 |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
50 vid_win.width = width; |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
51 vid_win.height = height; |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
52 |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
53 if (ioctl (dev, VIDIOCSWIN, &vid_win) == -1) { |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
54 printf ("ioctl VIDIOCSWIN\nError[%s]\n", strerror(errno)); |
0 | 55 return (NULL); |
56 } | |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
57 |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
58 read_img = 1; |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
59 map = malloc(width * height * 3); |
0 | 60 return (map); |
61 } | |
62 /* If we are going to capture greyscale we need room to blow the image up */ | |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
63 if (fmt == VIDEO_PALETTE_GREY) |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
64 map = mmap(0, vid_buf.size * 3, PROT_READ|PROT_WRITE, MAP_SHARED, dev, 0); |
0 | 65 else |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
66 map = mmap(0, vid_buf.size, PROT_READ|PROT_WRITE, MAP_SHARED, dev, 0); |
0 | 67 |
68 if ((unsigned char *)-1 == (unsigned char *)map) | |
69 return (NULL); | |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
70 |
0 | 71 return map; |
72 } | |
73 | |
74 int start_pipe (int dev, int width, int height) | |
75 { | |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
76 struct video_capability vid_caps; |
0 | 77 struct video_window vid_win; |
78 struct video_picture vid_pic; | |
79 | |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
80 if (ioctl(dev, VIDIOCGCAP, &vid_caps) == -1) { |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
81 printf ("ioctl (VIDIOCGCAP)\nError[%s]\n", strerror(errno)); |
0 | 82 return (1); |
83 } | |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
84 |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
85 if (ioctl(dev, VIDIOCGPICT, &vid_pic)== -1) { |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
86 printf ("ioctl VIDIOCGPICT\nError[%s]\n", strerror(errno)); |
0 | 87 return (1); |
88 } | |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
89 |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
90 vid_pic.palette = fmt; |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
91 |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
92 if (ioctl(dev, VIDIOCSPICT, &vid_pic) == -1) { |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
93 printf ("ioctl VIDIOCSPICT\nError[%s]\n", strerror(errno)); |
0 | 94 return (1); |
95 } | |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
96 |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
97 if (ioctl (dev, VIDIOCGWIN, &vid_win) == -1) { |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
98 printf ("ioctl VIDIOCGWIN\nError[%s]\n", strerror(errno)); |
0 | 99 return (1); |
100 } | |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
101 |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
102 vid_win.width = width; |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
103 vid_win.height = height; |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
104 |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
105 if (ioctl(dev, VIDIOCSWIN, &vid_win)== -1) { |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
106 printf ("ioctl VIDIOCSWIN\nError[%s]\n", strerror(errno)); |
0 | 107 return (1); |
108 } | |
109 return 0; | |
110 } | |
111 | |
112 char *next_capture (int dev, char *map, int width, int height) | |
113 { | |
114 int i; | |
115 char *grey, *rgb; | |
116 struct video_mmap vid_mmap; | |
117 | |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
118 sigset_t set, old; |
0 | 119 |
120 if (read_img) { | |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
121 if (fmt == VIDEO_PALETTE_GREY) { |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
122 size_t size = width * height; |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
123 if (read(dev, map, size) != size) |
0 | 124 return NULL; |
125 } else { | |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
126 size_t size = width * height * 3; |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
127 if (read(dev, map, size) != size) |
0 | 128 return NULL; |
129 } | |
130 } else { | |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
131 vid_mmap.format = fmt; |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
132 vid_mmap.frame = 0; |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
133 vid_mmap.width = width; |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
134 vid_mmap.height = height; |
0 | 135 |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
136 sigemptyset (&set); //BTTV hates signals during IOCTL |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
137 sigaddset (&set, SIGCHLD); //block SIGCHLD & SIGALRM |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
138 sigaddset (&set, SIGALRM); //for the time of ioctls |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
139 sigprocmask (SIG_BLOCK, &set, &old); |
0 | 140 |
141 if (ioctl(dev, VIDIOCMCAPTURE, &vid_mmap) == -1) { | |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
142 sigprocmask (SIG_UNBLOCK, &old, NULL); |
0 | 143 return (NULL); |
144 } | |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
145 |
0 | 146 if (ioctl(dev, VIDIOCSYNC, &vid_mmap) == -1) { |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
147 sigprocmask (SIG_UNBLOCK, &old, NULL); |
0 | 148 return (NULL); |
149 } | |
150 | |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
151 sigprocmask (SIG_UNBLOCK, &old, NULL); //undo the signal blocking |
0 | 152 } |
153 /* Blow up a grey */ | |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
154 if (fmt == VIDEO_PALETTE_GREY) { |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
155 i = width * height; |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
156 grey =map + i - 1; |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
157 rgb = map + i * 3; |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
158 for (; i >= 0; i--, grey--) { |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
159 *(rgb--) =*grey; |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
160 *(rgb--) =*grey; |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
161 *(rgb--) =*grey; |
0 | 162 } |
163 } | |
164 return map; | |
165 } | |
166 | |
167 int put_image(int dev, char *image, int width, int height) | |
168 { | |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
169 if (write(dev, image, width * height * 3) != width * height * 3) { |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
170 printf("Error writing image to pipe!\nError[%s]\n", strerror(errno)); |
0 | 171 return 0; |
172 } | |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
173 |
0 | 174 return 1; |
175 } | |
176 | |
177 | |
178 void sig_handler(int signo) | |
179 { | |
180 noexit = 0; | |
181 } | |
182 | |
183 int main (int argc, char **argv) | |
184 { | |
185 int i, devin, devout; | |
186 int width; | |
187 int height; | |
188 char *image_out, *image_new; | |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
189 char palette[10] = {'\0'}; |
0 | 190 |
191 if (argc != 5) { | |
192 printf("Usage:\n\n"); | |
193 printf("invert input output widthxheight rgb24|yuv420p\n\n"); | |
194 printf("example: invert /dev/video0 /dev/video1 352x288 yuv420p\n\n"); | |
195 exit(1); | |
196 } | |
197 sscanf(argv[3], "%dx%d", &width, &height); | |
198 sscanf(argv[4], "%s", palette); | |
199 | |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
200 if (!strcmp(palette,"rgb24")) |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
201 fmt = VIDEO_PALETTE_RGB24; |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
202 else if (!strcmp(palette,"yuv420p")) |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
203 fmt = VIDEO_PALETTE_YUV420P; |
0 | 204 else fmt = VIDEO_PALETTE_RGB24; |
205 | |
206 | |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
207 image_out = malloc(width * height * 3); |
0 | 208 |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
209 devin = open (argv[1], O_RDWR); |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
210 |
0 | 211 if (devin < 0) { |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
212 printf("Failed to open input video device [%s]\nError:[%s]\n", argv[1], strerror(errno)); |
0 | 213 exit(1); |
214 } | |
215 | |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
216 devout = open (argv[2], O_RDWR); |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
217 |
0 | 218 if (devout < 0) { |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
219 printf ("Failed to open output video device [%s]\nError:[%s]\n", argv[2], strerror(errno)); |
0 | 220 exit(1); |
221 } | |
222 | |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
223 image_new = start_capture(devin, width, height); |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
224 |
0 | 225 if (!image_new) { |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
226 printf("Capture error \n Error[%s]\n", strerror(errno)); |
0 | 227 exit(1); |
228 } | |
229 | |
230 start_pipe(devout, width, height); | |
231 | |
232 signal(SIGTERM, sig_handler); | |
233 | |
234 printf("Starting video stream.\n"); | |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
235 |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
236 while ( (next_capture(devin, image_new, width, height)) && (noexit) ) { |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
237 for (i = width * height * 3; i >= 0; i--) |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
238 image_out[i] =-image_new[i]; |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
239 |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
240 if (put_image(devout, image_out, width, height) == 0) { |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
241 if ((read_img) && (image_new)) |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
242 free(image_new); |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
243 else if (fmt == VIDEO_PALETTE_GREY) |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
244 munmap(image_new, width * height * 3); |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
245 else |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
246 munmap(image_new, width * height); |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
247 free(image_out); |
0 | 248 exit(1); |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
249 } |
0 | 250 } |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
251 |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
252 printf("You bought vaporware!\nError[%s]\n", strerror(errno)); |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
253 |
0 | 254 close (devin); |
255 close (devout); | |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
256 |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
257 if ((read_img) && (image_new)) |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
258 free(image_new); |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
259 else if (fmt == VIDEO_PALETTE_GREY) |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
260 munmap(image_new, width * height * 3); |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
261 else |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
262 munmap(image_new, width * height); |
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
263 |
0 | 264 free(image_out); |
7
2fce9e157b8d
Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents:
0
diff
changeset
|
265 |
0 | 266 exit(0); |
267 } |