annotate grab.c @ 95:89e992063014 libavformat

cleanup; unused pipe() stuff removed.
author mmu_man
date Thu, 27 Mar 2003 13:37:47 +0000
parents 25062c9b1f86
children 7d698c3213a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1 /*
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
2 * Linux video grab interface
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
3 * Copyright (c) 2000,2001 Fabrice Bellard.
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
4 *
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
5 * This library is free software; you can redistribute it and/or
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
8 * version 2 of the License, or (at your option) any later version.
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
9 *
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
10 * This library is distributed in the hope that it will be useful,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
13 * Lesser General Public License for more details.
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
14 *
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
16 * License along with this library; if not, write to the Free Software
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
18 */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
19 #include "avformat.h"
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
20 #include <linux/videodev.h>
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
21 #include <unistd.h>
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
22 #include <fcntl.h>
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
23 #include <sys/ioctl.h>
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
24 #include <sys/mman.h>
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
25 #include <sys/time.h>
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
26 #include <time.h>
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
27
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
28 typedef struct {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
29 int fd;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
30 int frame_format; /* see VIDEO_PALETTE_xxx */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
31 int use_mmap;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
32 int width, height;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
33 int frame_rate;
85
25062c9b1f86 per context frame_rate_base, this should finally fix frame_rate related av sync issues
michaelni
parents: 65
diff changeset
34 int frame_rate_base;
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 30
diff changeset
35 int64_t time_frame;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
36 int frame_size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
37 struct video_capability video_cap;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
38 struct video_audio audio_saved;
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 30
diff changeset
39 uint8_t *video_buf;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
40 struct video_mbuf gb_buffers;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
41 struct video_mmap gb_buf;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
42 int gb_frame;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
43
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
44 /* ATI All In Wonder specific stuff */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
45 /* XXX: remove and merge in libavcodec/imgconvert.c */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
46 int aiw_enabled;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
47 int deint;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
48 int halfw;
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 30
diff changeset
49 uint8_t *src_mem;
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 30
diff changeset
50 uint8_t *lum_m4_mem;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
51 } VideoData;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
52
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
53 static int aiw_init(VideoData *s);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
54 static int aiw_read_picture(VideoData *s, uint8_t *data);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
55 static int aiw_close(VideoData *s);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
56
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
57 static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
58 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
59 VideoData *s = s1->priv_data;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
60 AVStream *st;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
61 int width, height;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
62 int video_fd, frame_size;
85
25062c9b1f86 per context frame_rate_base, this should finally fix frame_rate related av sync issues
michaelni
parents: 65
diff changeset
63 int ret, frame_rate, frame_rate_base;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
64 int desired_palette;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
65 struct video_audio audio;
30
90fd30dd68b3 grab device is in AVFormatParameter (at least better than global variable)
bellard
parents: 27
diff changeset
66 const char *video_device;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
67
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
68 if (!ap || ap->width <= 0 || ap->height <= 0 || ap->frame_rate <= 0)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
69 return -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
70
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
71 width = ap->width;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
72 height = ap->height;
85
25062c9b1f86 per context frame_rate_base, this should finally fix frame_rate related av sync issues
michaelni
parents: 65
diff changeset
73 frame_rate = ap->frame_rate;
25062c9b1f86 per context frame_rate_base, this should finally fix frame_rate related av sync issues
michaelni
parents: 65
diff changeset
74 frame_rate_base = ap->frame_rate_base;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
75
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
76 st = av_new_stream(s1, 0);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
77 if (!st)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
78 return -ENOMEM;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
79
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
80 s->width = width;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
81 s->height = height;
85
25062c9b1f86 per context frame_rate_base, this should finally fix frame_rate related av sync issues
michaelni
parents: 65
diff changeset
82 s->frame_rate = frame_rate;
25062c9b1f86 per context frame_rate_base, this should finally fix frame_rate related av sync issues
michaelni
parents: 65
diff changeset
83 s->frame_rate_base = frame_rate_base;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
84
30
90fd30dd68b3 grab device is in AVFormatParameter (at least better than global variable)
bellard
parents: 27
diff changeset
85 video_device = ap->device;
90fd30dd68b3 grab device is in AVFormatParameter (at least better than global variable)
bellard
parents: 27
diff changeset
86 if (!video_device)
90fd30dd68b3 grab device is in AVFormatParameter (at least better than global variable)
bellard
parents: 27
diff changeset
87 video_device = "/dev/video";
27
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents: 0
diff changeset
88 video_fd = open(video_device, O_RDWR);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
89 if (video_fd < 0) {
27
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents: 0
diff changeset
90 perror(video_device);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
91 goto fail;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
92 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
93
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
94 if (ioctl(video_fd,VIDIOCGCAP, &s->video_cap) < 0) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
95 perror("VIDIOCGCAP");
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
96 goto fail;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
97 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
98
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
99 if (!(s->video_cap.type & VID_TYPE_CAPTURE)) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
100 fprintf(stderr, "Fatal: grab device does not handle capture\n");
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
101 goto fail;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
102 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
103
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
104 desired_palette = -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
105 if (st->codec.pix_fmt == PIX_FMT_YUV420P) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
106 desired_palette = VIDEO_PALETTE_YUV420P;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
107 } else if (st->codec.pix_fmt == PIX_FMT_YUV422) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
108 desired_palette = VIDEO_PALETTE_YUV422;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
109 } else if (st->codec.pix_fmt == PIX_FMT_BGR24) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
110 desired_palette = VIDEO_PALETTE_RGB24;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
111 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
112
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
113 /* unmute audio */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
114 audio.audio = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
115 ioctl(video_fd, VIDIOCGAUDIO, &audio);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
116 memcpy(&s->audio_saved, &audio, sizeof(audio));
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
117 audio.flags &= ~VIDEO_AUDIO_MUTE;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
118 ioctl(video_fd, VIDIOCSAUDIO, &audio);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
119
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
120 ret = ioctl(video_fd,VIDIOCGMBUF,&s->gb_buffers);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
121 if (ret < 0) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
122 /* try to use read based access */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
123 struct video_window win;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
124 struct video_picture pict;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
125 int val;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
126
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
127 win.x = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
128 win.y = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
129 win.width = width;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
130 win.height = height;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
131 win.chromakey = -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
132 win.flags = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
133
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
134 ioctl(video_fd, VIDIOCSWIN, &win);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
135
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
136 ioctl(video_fd, VIDIOCGPICT, &pict);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
137 #if 0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
138 printf("v4l: colour=%d hue=%d brightness=%d constrast=%d whiteness=%d\n",
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
139 pict.colour,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
140 pict.hue,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
141 pict.brightness,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
142 pict.contrast,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
143 pict.whiteness);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
144 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
145 /* try to choose a suitable video format */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
146 pict.palette = desired_palette;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
147 if (desired_palette == -1 || (ret = ioctl(video_fd, VIDIOCSPICT, &pict)) < 0) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
148 pict.palette=VIDEO_PALETTE_YUV420P;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
149 ret = ioctl(video_fd, VIDIOCSPICT, &pict);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
150 if (ret < 0) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
151 pict.palette=VIDEO_PALETTE_YUV422;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
152 ret = ioctl(video_fd, VIDIOCSPICT, &pict);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
153 if (ret < 0) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
154 pict.palette=VIDEO_PALETTE_RGB24;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
155 ret = ioctl(video_fd, VIDIOCSPICT, &pict);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
156 if (ret < 0)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
157 goto fail1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
158 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
159 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
160 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
161
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
162 s->frame_format = pict.palette;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
163
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
164 val = 1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
165 ioctl(video_fd, VIDIOCCAPTURE, &val);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
166
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
167 s->time_frame = av_gettime();
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
168 s->use_mmap = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
169
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
170 /* ATI All In Wonder automatic activation */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
171 if (!strcmp(s->video_cap.name, "Km")) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
172 if (aiw_init(s) < 0)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
173 goto fail;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
174 s->aiw_enabled = 1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
175 /* force 420P format because convertion from YUV422 to YUV420P
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
176 is done in this driver (ugly) */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
177 s->frame_format = VIDEO_PALETTE_YUV420P;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
178 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
179 } else {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
180 s->video_buf = mmap(0,s->gb_buffers.size,PROT_READ|PROT_WRITE,MAP_SHARED,video_fd,0);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
181 if ((unsigned char*)-1 == s->video_buf) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
182 perror("mmap");
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
183 goto fail;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
184 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
185 s->gb_frame = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
186 s->time_frame = av_gettime();
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
187
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
188 /* start to grab the first frame */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
189 s->gb_buf.frame = s->gb_frame % s->gb_buffers.frames;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
190 s->gb_buf.height = height;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
191 s->gb_buf.width = width;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
192 s->gb_buf.format = desired_palette;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
193
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
194 if (desired_palette == -1 || (ret = ioctl(video_fd, VIDIOCMCAPTURE, &s->gb_buf)) < 0) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
195 s->gb_buf.format = VIDEO_PALETTE_YUV420P;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
196
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
197 ret = ioctl(video_fd, VIDIOCMCAPTURE, &s->gb_buf);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
198 if (ret < 0 && errno != EAGAIN) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
199 /* try YUV422 */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
200 s->gb_buf.format = VIDEO_PALETTE_YUV422;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
201
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
202 ret = ioctl(video_fd, VIDIOCMCAPTURE, &s->gb_buf);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
203 if (ret < 0 && errno != EAGAIN) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
204 /* try RGB24 */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
205 s->gb_buf.format = VIDEO_PALETTE_RGB24;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
206 ret = ioctl(video_fd, VIDIOCMCAPTURE, &s->gb_buf);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
207 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
208 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
209 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
210 if (ret < 0) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
211 if (errno != EAGAIN) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
212 fail1:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
213 fprintf(stderr, "Fatal: grab device does not support suitable format\n");
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
214 } else {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
215 fprintf(stderr,"Fatal: grab device does not receive any video signal\n");
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
216 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
217 goto fail;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
218 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
219 s->frame_format = s->gb_buf.format;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
220 s->use_mmap = 1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
221 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
222
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
223 switch(s->frame_format) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
224 case VIDEO_PALETTE_YUV420P:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
225 frame_size = (width * height * 3) / 2;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
226 st->codec.pix_fmt = PIX_FMT_YUV420P;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
227 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
228 case VIDEO_PALETTE_YUV422:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
229 frame_size = width * height * 2;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
230 st->codec.pix_fmt = PIX_FMT_YUV422;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
231 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
232 case VIDEO_PALETTE_RGB24:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
233 frame_size = width * height * 3;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
234 st->codec.pix_fmt = PIX_FMT_BGR24; /* NOTE: v4l uses BGR24, not RGB24 ! */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
235 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
236 default:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
237 goto fail;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
238 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
239 s->fd = video_fd;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
240 s->frame_size = frame_size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
241
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
242 st->codec.codec_type = CODEC_TYPE_VIDEO;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
243 st->codec.codec_id = CODEC_ID_RAWVIDEO;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
244 st->codec.width = width;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
245 st->codec.height = height;
85
25062c9b1f86 per context frame_rate_base, this should finally fix frame_rate related av sync issues
michaelni
parents: 65
diff changeset
246 st->codec.frame_rate = frame_rate;
25062c9b1f86 per context frame_rate_base, this should finally fix frame_rate related av sync issues
michaelni
parents: 65
diff changeset
247 st->codec.frame_rate_base = frame_rate_base;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
248
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
249 av_set_pts_info(s1, 48, 1, 1000000); /* 48 bits pts in us */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
250
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
251 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
252 fail:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
253 if (video_fd >= 0)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
254 close(video_fd);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
255 av_free(st);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
256 return -EIO;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
257 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
258
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 30
diff changeset
259 static int v4l_mm_read_picture(VideoData *s, uint8_t *buf)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
260 {
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 30
diff changeset
261 uint8_t *ptr;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
262
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
263 /* Setup to capture the next frame */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
264 s->gb_buf.frame = (s->gb_frame + 1) % s->gb_buffers.frames;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
265 if (ioctl(s->fd, VIDIOCMCAPTURE, &s->gb_buf) < 0) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
266 if (errno == EAGAIN)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
267 fprintf(stderr,"Cannot Sync\n");
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
268 else
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
269 perror("VIDIOCMCAPTURE");
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
270 return -EIO;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
271 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
272
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
273 while (ioctl(s->fd, VIDIOCSYNC, &s->gb_frame) < 0 &&
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
274 (errno == EAGAIN || errno == EINTR));
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
275
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
276 ptr = s->video_buf + s->gb_buffers.offsets[s->gb_frame];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
277 memcpy(buf, ptr, s->frame_size);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
278
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
279 /* This is now the grabbing frame */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
280 s->gb_frame = s->gb_buf.frame;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
281
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
282 return s->frame_size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
283 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
284
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
285 static int grab_read_packet(AVFormatContext *s1, AVPacket *pkt)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
286 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
287 VideoData *s = s1->priv_data;
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 30
diff changeset
288 int64_t curtime, delay;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
289 struct timespec ts;
85
25062c9b1f86 per context frame_rate_base, this should finally fix frame_rate related av sync issues
michaelni
parents: 65
diff changeset
290 int64_t per_frame = (int64_t_C(1000000) * s->frame_rate_base) / s->frame_rate;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
291
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
292 /* Calculate the time of the next frame */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
293 s->time_frame += per_frame;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
294
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
295 /* wait based on the frame rate */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
296 for(;;) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
297 curtime = av_gettime();
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
298 delay = s->time_frame - curtime;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
299 if (delay <= 0) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
300 if (delay < -per_frame) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
301 /* printf("grabbing is %d frames late (dropping)\n", (int) -(delay / 16666)); */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
302 s->time_frame += per_frame;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
303 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
304 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
305 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
306 ts.tv_sec = delay / 1000000;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
307 ts.tv_nsec = (delay % 1000000) * 1000;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
308 nanosleep(&ts, NULL);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
309 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
310
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
311 if (av_new_packet(pkt, s->frame_size) < 0)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
312 return -EIO;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
313
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
314 pkt->pts = curtime & ((1LL << 48) - 1);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
315
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
316 /* read one frame */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
317 if (s->aiw_enabled) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
318 return aiw_read_picture(s, pkt->data);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
319 } else if (s->use_mmap) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
320 return v4l_mm_read_picture(s, pkt->data);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
321 } else {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
322 if (read(s->fd, pkt->data, pkt->size) != pkt->size)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
323 return -EIO;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
324 return s->frame_size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
325 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
326 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
327
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
328 static int grab_read_close(AVFormatContext *s1)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
329 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
330 VideoData *s = s1->priv_data;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
331
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
332 if (s->aiw_enabled)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
333 aiw_close(s);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
334
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
335 if (s->use_mmap)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
336 munmap(s->video_buf, s->gb_buffers.size);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
337
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
338 /* mute audio. we must force it because the BTTV driver does not
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
339 return its state correctly */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
340 s->audio_saved.flags |= VIDEO_AUDIO_MUTE;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
341 ioctl(s->fd, VIDIOCSAUDIO, &s->audio_saved);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
342
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
343 close(s->fd);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
344 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
345 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
346
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
347 static AVInputFormat video_grab_device_format = {
27
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents: 0
diff changeset
348 "video4linux",
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
349 "video grab",
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
350 sizeof(VideoData),
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
351 NULL,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
352 grab_read_header,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
353 grab_read_packet,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
354 grab_read_close,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
355 .flags = AVFMT_NOFILE,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
356 };
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
357
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
358 /* All in Wonder specific stuff */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
359 /* XXX: remove and merge in libavcodec/imgconvert.c */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
360
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
361 static int aiw_init(VideoData *s)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
362 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
363 int width, height;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
364
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
365 width = s->width;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
366 height = s->height;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
367
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
368 if ((width == s->video_cap.maxwidth && height == s->video_cap.maxheight) ||
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
369 (width == s->video_cap.maxwidth && height == s->video_cap.maxheight*2) ||
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
370 (width == s->video_cap.maxwidth/2 && height == s->video_cap.maxheight)) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
371
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
372 s->deint=0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
373 s->halfw=0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
374 if (height == s->video_cap.maxheight*2) s->deint=1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
375 if (width == s->video_cap.maxwidth/2) s->halfw=1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
376 } else {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
377 fprintf(stderr,"\nIncorrect Grab Size Supplied - Supported Sizes Are:\n");
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
378 fprintf(stderr," %dx%d %dx%d %dx%d\n\n",
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
379 s->video_cap.maxwidth,s->video_cap.maxheight,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
380 s->video_cap.maxwidth,s->video_cap.maxheight*2,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
381 s->video_cap.maxwidth/2,s->video_cap.maxheight);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
382 goto fail;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
383 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
384
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
385 if (s->halfw == 0) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
386 s->src_mem = av_malloc(s->width*2);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
387 } else {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
388 s->src_mem = av_malloc(s->width*4);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
389 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
390 if (!s->src_mem) goto fail;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
391
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
392 s->lum_m4_mem = av_malloc(s->width);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
393 if (!s->lum_m4_mem)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
394 goto fail;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
395 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
396 fail:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
397 av_freep(&s->src_mem);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
398 av_freep(&s->lum_m4_mem);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
399 return -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
400 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
401
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
402 #ifdef HAVE_MMX
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
403 #include "../libavcodec/i386/mmx.h"
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
404
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
405 #define LINE_WITH_UV \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
406 movq_m2r(ptr[0],mm0); \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
407 movq_m2r(ptr[8],mm1); \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
408 movq_r2r(mm0, mm4); \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
409 punpcklbw_r2r(mm1,mm0); \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
410 punpckhbw_r2r(mm1,mm4); \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
411 movq_r2r(mm0,mm5); \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
412 punpcklbw_r2r(mm4,mm0); \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
413 punpckhbw_r2r(mm4,mm5); \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
414 movq_r2r(mm0,mm1); \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
415 punpcklbw_r2r(mm5,mm1); \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
416 movq_r2m(mm1,lum[0]); \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
417 movq_m2r(ptr[16],mm2); \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
418 movq_m2r(ptr[24],mm1); \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
419 movq_r2r(mm2,mm4); \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
420 punpcklbw_r2r(mm1,mm2); \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
421 punpckhbw_r2r(mm1,mm4); \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
422 movq_r2r(mm2,mm3); \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
423 punpcklbw_r2r(mm4,mm2); \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
424 punpckhbw_r2r(mm4,mm3); \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
425 movq_r2r(mm2,mm1); \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
426 punpcklbw_r2r(mm3,mm1); \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
427 movq_r2m(mm1,lum[8]); \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
428 punpckhdq_r2r(mm2,mm0); \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
429 punpckhdq_r2r(mm3,mm5); \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
430 movq_r2m(mm0,cb[0]); \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
431 movq_r2m(mm5,cr[0]);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
432
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
433 #define LINE_NO_UV \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
434 movq_m2r(ptr[0],mm0);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
435 movq_m2r(ptr[8],mm1);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
436 movq_r2r(mm0, mm4);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
437 punpcklbw_r2r(mm1,mm0); \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
438 punpckhbw_r2r(mm1,mm4);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
439 movq_r2r(mm0,mm5);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
440 punpcklbw_r2r(mm4,mm0);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
441 punpckhbw_r2r(mm4,mm5);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
442 movq_r2r(mm0,mm1);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
443 punpcklbw_r2r(mm5,mm1);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
444 movq_r2m(mm1,lum[0]);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
445 movq_m2r(ptr[16],mm2);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
446 movq_m2r(ptr[24],mm1);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
447 movq_r2r(mm2,mm4);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
448 punpcklbw_r2r(mm1,mm2);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
449 punpckhbw_r2r(mm1,mm4);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
450 movq_r2r(mm2,mm3);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
451 punpcklbw_r2r(mm4,mm2);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
452 punpckhbw_r2r(mm4,mm3);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
453 movq_r2r(mm2,mm1);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
454 punpcklbw_r2r(mm3,mm1);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
455 movq_r2m(mm1,lum[8]);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
456
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
457 #define LINE_WITHUV_AVG \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
458 movq_m2r(ptr[0], mm0);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
459 movq_m2r(ptr[8], mm1);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
460 movq_r2r(mm0, mm4);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
461 punpcklbw_r2r(mm1,mm0);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
462 punpckhbw_r2r(mm1,mm4);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
463 movq_r2r(mm0,mm5);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
464 punpcklbw_r2r(mm4,mm0);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
465 punpckhbw_r2r(mm4,mm5);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
466 movq_r2r(mm0,mm1);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
467 movq_r2r(mm5,mm2);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
468 punpcklbw_r2r(mm7,mm1);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
469 punpcklbw_r2r(mm7,mm2);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
470 paddw_r2r(mm6,mm1);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
471 paddw_r2r(mm2,mm1);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
472 psraw_i2r(1,mm1);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
473 packuswb_r2r(mm7,mm1);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
474 movd_r2m(mm1,lum[0]);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
475 movq_m2r(ptr[16],mm2);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
476 movq_m2r(ptr[24],mm1);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
477 movq_r2r(mm2,mm4);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
478 punpcklbw_r2r(mm1,mm2);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
479 punpckhbw_r2r(mm1,mm4);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
480 movq_r2r(mm2,mm3);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
481 punpcklbw_r2r(mm4,mm2);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
482 punpckhbw_r2r(mm4,mm3);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
483 movq_r2r(mm2,mm1);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
484 movq_r2r(mm3,mm4);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
485 punpcklbw_r2r(mm7,mm1);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
486 punpcklbw_r2r(mm7,mm4);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
487 paddw_r2r(mm6,mm1);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
488 paddw_r2r(mm4,mm1);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
489 psraw_i2r(1,mm1);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
490 packuswb_r2r(mm7,mm1);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
491 movd_r2m(mm1,lum[4]);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
492 punpckhbw_r2r(mm7,mm0);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
493 punpckhbw_r2r(mm7,mm2);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
494 paddw_r2r(mm6,mm0);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
495 paddw_r2r(mm2,mm0);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
496 psraw_i2r(1,mm0);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
497 packuswb_r2r(mm7,mm0);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
498 punpckhbw_r2r(mm7,mm5);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
499 punpckhbw_r2r(mm7,mm3);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
500 paddw_r2r(mm6,mm5);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
501 paddw_r2r(mm3,mm5);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
502 psraw_i2r(1,mm5);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
503 packuswb_r2r(mm7,mm5);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
504 movd_r2m(mm0,cb[0]);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
505 movd_r2m(mm5,cr[0]);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
506
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
507 #define LINE_NOUV_AVG \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
508 movq_m2r(ptr[0],mm0);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
509 movq_m2r(ptr[8],mm1);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
510 pand_r2r(mm5,mm0);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
511 pand_r2r(mm5,mm1);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
512 pmaddwd_r2r(mm6,mm0);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
513 pmaddwd_r2r(mm6,mm1);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
514 packssdw_r2r(mm1,mm0);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
515 paddw_r2r(mm6,mm0);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
516 psraw_i2r(1,mm0);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
517 movq_m2r(ptr[16],mm2);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
518 movq_m2r(ptr[24],mm3);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
519 pand_r2r(mm5,mm2);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
520 pand_r2r(mm5,mm3);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
521 pmaddwd_r2r(mm6,mm2);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
522 pmaddwd_r2r(mm6,mm3);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
523 packssdw_r2r(mm3,mm2);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
524 paddw_r2r(mm6,mm2);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
525 psraw_i2r(1,mm2);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
526 packuswb_r2r(mm2,mm0);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
527 movq_r2m(mm0,lum[0]);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
528
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
529 #define DEINT_LINE_LUM(ptroff) \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
530 movd_m2r(lum_m4[(ptroff)],mm0);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
531 movd_m2r(lum_m3[(ptroff)],mm1);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
532 movd_m2r(lum_m2[(ptroff)],mm2);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
533 movd_m2r(lum_m1[(ptroff)],mm3);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
534 movd_m2r(lum[(ptroff)],mm4);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
535 punpcklbw_r2r(mm7,mm0);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
536 movd_r2m(mm2,lum_m4[(ptroff)]);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
537 punpcklbw_r2r(mm7,mm1);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
538 punpcklbw_r2r(mm7,mm2);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
539 punpcklbw_r2r(mm7,mm3);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
540 punpcklbw_r2r(mm7,mm4);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
541 psllw_i2r(2,mm1);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
542 psllw_i2r(1,mm2);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
543 paddw_r2r(mm6,mm1);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
544 psllw_i2r(2,mm3);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
545 paddw_r2r(mm2,mm1);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
546 paddw_r2r(mm4,mm0);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
547 paddw_r2r(mm3,mm1);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
548 psubusw_r2r(mm0,mm1);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
549 psrlw_i2r(3,mm1);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
550 packuswb_r2r(mm7,mm1);\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
551 movd_r2m(mm1,lum_m2[(ptroff)]);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
552
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
553 #else
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
554 #include "../libavcodec/dsputil.h"
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
555
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
556 #define LINE_WITH_UV \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
557 lum[0]=ptr[0];lum[1]=ptr[2];lum[2]=ptr[4];lum[3]=ptr[6];\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
558 cb[0]=ptr[1];cb[1]=ptr[5];\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
559 cr[0]=ptr[3];cr[1]=ptr[7];\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
560 lum[4]=ptr[8];lum[5]=ptr[10];lum[6]=ptr[12];lum[7]=ptr[14];\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
561 cb[2]=ptr[9];cb[3]=ptr[13];\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
562 cr[2]=ptr[11];cr[3]=ptr[15];\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
563 lum[8]=ptr[16];lum[9]=ptr[18];lum[10]=ptr[20];lum[11]=ptr[22];\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
564 cb[4]=ptr[17];cb[5]=ptr[21];\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
565 cr[4]=ptr[19];cr[5]=ptr[23];\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
566 lum[12]=ptr[24];lum[13]=ptr[26];lum[14]=ptr[28];lum[15]=ptr[30];\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
567 cb[6]=ptr[25];cb[7]=ptr[29];\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
568 cr[6]=ptr[27];cr[7]=ptr[31];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
569
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
570 #define LINE_NO_UV \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
571 lum[0]=ptr[0];lum[1]=ptr[2];lum[2]=ptr[4];lum[3]=ptr[6];\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
572 lum[4]=ptr[8];lum[5]=ptr[10];lum[6]=ptr[12];lum[7]=ptr[14];\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
573 lum[8]=ptr[16];lum[9]=ptr[18];lum[10]=ptr[20];lum[11]=ptr[22];\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
574 lum[12]=ptr[24];lum[13]=ptr[26];lum[14]=ptr[28];lum[15]=ptr[30];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
575
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
576 #define LINE_WITHUV_AVG \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
577 sum=(ptr[0]+ptr[2]+1) >> 1;lum[0]=sum; \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
578 sum=(ptr[4]+ptr[6]+1) >> 1;lum[1]=sum; \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
579 sum=(ptr[1]+ptr[5]+1) >> 1;cb[0]=sum; \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
580 sum=(ptr[3]+ptr[7]+1) >> 1;cr[0]=sum; \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
581 sum=(ptr[8]+ptr[10]+1) >> 1;lum[2]=sum; \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
582 sum=(ptr[12]+ptr[14]+1) >> 1;lum[3]=sum; \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
583 sum=(ptr[9]+ptr[13]+1) >> 1;cb[1]=sum; \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
584 sum=(ptr[11]+ptr[15]+1) >> 1;cr[1]=sum; \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
585 sum=(ptr[16]+ptr[18]+1) >> 1;lum[4]=sum; \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
586 sum=(ptr[20]+ptr[22]+1) >> 1;lum[5]=sum; \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
587 sum=(ptr[17]+ptr[21]+1) >> 1;cb[2]=sum; \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
588 sum=(ptr[19]+ptr[23]+1) >> 1;cr[2]=sum; \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
589 sum=(ptr[24]+ptr[26]+1) >> 1;lum[6]=sum; \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
590 sum=(ptr[28]+ptr[30]+1) >> 1;lum[7]=sum; \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
591 sum=(ptr[25]+ptr[29]+1) >> 1;cb[3]=sum; \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
592 sum=(ptr[27]+ptr[31]+1) >> 1;cr[3]=sum;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
593
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
594 #define LINE_NOUV_AVG \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
595 sum=(ptr[0]+ptr[2]+1) >> 1;lum[0]=sum; \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
596 sum=(ptr[4]+ptr[6]+1) >> 1;lum[1]=sum; \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
597 sum=(ptr[8]+ptr[10]+1) >> 1;lum[2]=sum; \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
598 sum=(ptr[12]+ptr[14]+1) >> 1;lum[3]=sum; \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
599 sum=(ptr[16]+ptr[18]+1) >> 1;lum[4]=sum; \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
600 sum=(ptr[20]+ptr[22]+1) >> 1;lum[5]=sum; \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
601 sum=(ptr[24]+ptr[26]+1) >> 1;lum[6]=sum; \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
602 sum=(ptr[28]+ptr[30]+1) >> 1;lum[7]=sum;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
603
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
604 #define DEINT_LINE_LUM(ptroff) \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
605 sum=(-lum_m4[(ptroff)]+(lum_m3[(ptroff)]<<2)+(lum_m2[(ptroff)]<<1)+(lum_m1[(ptroff)]<<2)-lum[(ptroff)]); \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
606 lum_m4[(ptroff)]=lum_m2[(ptroff)];\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
607 lum_m2[(ptroff)]=cm[(sum+4)>>3];\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
608 sum=(-lum_m4[(ptroff)+1]+(lum_m3[(ptroff)+1]<<2)+(lum_m2[(ptroff)+1]<<1)+(lum_m1[(ptroff)+1]<<2)-lum[(ptroff)+1]); \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
609 lum_m4[(ptroff)+1]=lum_m2[(ptroff)+1];\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
610 lum_m2[(ptroff)+1]=cm[(sum+4)>>3];\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
611 sum=(-lum_m4[(ptroff)+2]+(lum_m3[(ptroff)+2]<<2)+(lum_m2[(ptroff)+2]<<1)+(lum_m1[(ptroff)+2]<<2)-lum[(ptroff)+2]); \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
612 lum_m4[(ptroff)+2]=lum_m2[(ptroff)+2];\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
613 lum_m2[(ptroff)+2]=cm[(sum+4)>>3];\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
614 sum=(-lum_m4[(ptroff)+3]+(lum_m3[(ptroff)+3]<<2)+(lum_m2[(ptroff)+3]<<1)+(lum_m1[(ptroff)+3]<<2)-lum[(ptroff)+3]); \
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
615 lum_m4[(ptroff)+3]=lum_m2[(ptroff)+3];\
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
616 lum_m2[(ptroff)+3]=cm[(sum+4)>>3];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
617
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
618 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
619
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
620
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
621 /* Read two fields separately. */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
622 static int aiw_read_picture(VideoData *s, uint8_t *data)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
623 {
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 30
diff changeset
624 uint8_t *ptr, *lum, *cb, *cr;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
625 int h;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
626 #ifndef HAVE_MMX
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
627 int sum;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
628 #endif
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 30
diff changeset
629 uint8_t* src = s->src_mem;
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 30
diff changeset
630 uint8_t *ptrend = &src[s->width*2];
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
631 lum=data;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
632 cb=&lum[s->width*s->height];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
633 cr=&cb[(s->width*s->height)/4];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
634 if (s->deint == 0 && s->halfw == 0) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
635 while (read(s->fd,src,s->width*2) < 0) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
636 usleep(100);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
637 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
638 for (h = 0; h < s->height-2; h+=2) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
639 for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=16, cb+=8, cr+=8) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
640 LINE_WITH_UV
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
641 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
642 read(s->fd,src,s->width*2);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
643 for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=16) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
644 LINE_NO_UV
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
645 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
646 read(s->fd,src,s->width*2);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
647 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
648 /*
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
649 * Do last two lines
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
650 */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
651 for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=16, cb+=8, cr+=8) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
652 LINE_WITH_UV
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
653 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
654 read(s->fd,src,s->width*2);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
655 for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=16) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
656 LINE_NO_UV
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
657 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
658 /* drop second field */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
659 while (read(s->fd,src,s->width*2) < 0) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
660 usleep(100);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
661 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
662 for (h = 0; h < s->height - 1; h++) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
663 read(s->fd,src,s->width*2);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
664 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
665 } else if (s->halfw == 1) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
666 #ifdef HAVE_MMX
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
667 mmx_t rounder;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
668 mmx_t masker;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
669 rounder.uw[0]=1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
670 rounder.uw[1]=1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
671 rounder.uw[2]=1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
672 rounder.uw[3]=1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
673 masker.ub[0]=0xff;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
674 masker.ub[1]=0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
675 masker.ub[2]=0xff;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
676 masker.ub[3]=0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
677 masker.ub[4]=0xff;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
678 masker.ub[5]=0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
679 masker.ub[6]=0xff;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
680 masker.ub[7]=0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
681 pxor_r2r(mm7,mm7);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
682 movq_m2r(rounder,mm6);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
683 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
684 while (read(s->fd,src,s->width*4) < 0) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
685 usleep(100);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
686 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
687 ptrend = &src[s->width*4];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
688 for (h = 0; h < s->height-2; h+=2) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
689 for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=8, cb+=4, cr+=4) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
690 LINE_WITHUV_AVG
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
691 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
692 read(s->fd,src,s->width*4);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
693 #ifdef HAVE_MMX
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
694 movq_m2r(masker,mm5);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
695 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
696 for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=8) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
697 LINE_NOUV_AVG
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
698 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
699 read(s->fd,src,s->width*4);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
700 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
701 /*
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
702 * Do last two lines
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
703 */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
704 for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=8, cb+=4, cr+=4) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
705 LINE_WITHUV_AVG
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
706 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
707 read(s->fd,src,s->width*4);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
708 #ifdef HAVE_MMX
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
709 movq_m2r(masker,mm5);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
710 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
711 for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=8) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
712 LINE_NOUV_AVG
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
713 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
714 /* drop second field */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
715 while (read(s->fd,src,s->width*4) < 0) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
716 usleep(100);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
717 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
718 for (h = 0; h < s->height - 1; h++) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
719 read(s->fd,src,s->width*4);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
720 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
721 } else {
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 30
diff changeset
722 uint8_t *lum_m1, *lum_m2, *lum_m3, *lum_m4;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
723 #ifdef HAVE_MMX
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
724 mmx_t rounder;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
725 rounder.uw[0]=4;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
726 rounder.uw[1]=4;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
727 rounder.uw[2]=4;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
728 rounder.uw[3]=4;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
729 movq_m2r(rounder,mm6);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
730 pxor_r2r(mm7,mm7);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
731 #else
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 30
diff changeset
732 uint8_t *cm = cropTbl + MAX_NEG_CROP;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
733 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
734
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
735 /* read two fields and deinterlace them */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
736 while (read(s->fd,src,s->width*2) < 0) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
737 usleep(100);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
738 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
739 for (h = 0; h < (s->height/2)-2; h+=2) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
740 for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=16, cb+=8, cr+=8) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
741 LINE_WITH_UV
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
742 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
743 read(s->fd,src,s->width*2);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
744 /* skip a luminance line - will be filled in later */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
745 lum += s->width;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
746 for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=16, cb+=8, cr+=8) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
747 LINE_WITH_UV
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
748 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
749 /* skip a luminance line - will be filled in later */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
750 lum += s->width;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
751 read(s->fd,src,s->width*2);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
752 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
753 /*
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
754 * Do last two lines
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
755 */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
756 for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=16, cb+=8, cr+=8) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
757 LINE_WITH_UV
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
758 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
759 /* skip a luminance line - will be filled in later */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
760 lum += s->width;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
761 read(s->fd,src,s->width*2);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
762 for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=16, cb+=8, cr+=8) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
763 LINE_WITH_UV
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
764 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
765 /*
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
766 *
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
767 * SECOND FIELD
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
768 *
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
769 */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
770 lum=&data[s->width];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
771 while (read(s->fd,src,s->width*2) < 0) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
772 usleep(10);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
773 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
774 /* First (and last) two lines not interlaced */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
775 for (h = 0; h < 2; h++) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
776 for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=16) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
777 LINE_NO_UV
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
778 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
779 read(s->fd,src,s->width*2);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
780 /* skip a luminance line */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
781 lum += s->width;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
782 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
783 lum_m1=&lum[-s->width];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
784 lum_m2=&lum_m1[-s->width];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
785 lum_m3=&lum_m2[-s->width];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
786 memmove(s->lum_m4_mem,&lum_m3[-s->width],s->width);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
787 for (; h < (s->height/2)-1; h++) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
788 lum_m4=s->lum_m4_mem;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
789 for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=16,lum_m1+=16,lum_m2+=16,lum_m3+=16,lum_m4+=16) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
790 LINE_NO_UV
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
791
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
792 DEINT_LINE_LUM(0)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
793 DEINT_LINE_LUM(4)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
794 DEINT_LINE_LUM(8)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
795 DEINT_LINE_LUM(12)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
796 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
797 read(s->fd,src,s->width*2);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
798 /* skip a luminance line */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
799 lum += s->width;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
800 lum_m1 += s->width;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
801 lum_m2 += s->width;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
802 lum_m3 += s->width;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
803 // lum_m4 += s->width;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
804 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
805 /*
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
806 * Do last line
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
807 */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
808 lum_m4=s->lum_m4_mem;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
809 for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=16, lum_m1+=16, lum_m2+=16, lum_m3+=16, lum_m4+=16) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
810 LINE_NO_UV
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
811
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
812 DEINT_LINE_LUM(0)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
813 DEINT_LINE_LUM(4)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
814 DEINT_LINE_LUM(8)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
815 DEINT_LINE_LUM(12)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
816 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
817 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
818 #ifdef HAVE_MMX
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
819 emms();
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
820 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
821 return s->frame_size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
822 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
823
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
824 static int aiw_close(VideoData *s)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
825 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
826 av_freep(&s->lum_m4_mem);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
827 av_freep(&s->src_mem);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
828 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
829 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
830
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
831 int video_grab_init(void)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
832 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
833 av_register_input_format(&video_grab_device_format);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
834 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
835 }