2 * Linux video grab interface
3 * Copyright (c) 2000,2001 Fabrice Bellard.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include <linux/videodev.h>
23 #include <sys/ioctl.h>
30 int frame_format; /* see VIDEO_PALETTE_xxx */
36 struct video_capability video_cap;
37 struct video_audio audio_saved;
39 struct video_mbuf gb_buffers;
40 struct video_mmap gb_buf;
43 /* ATI All In Wonder specific stuff */
44 /* XXX: remove and merge in libavcodec/imgconvert.c */
52 static int aiw_init(VideoData *s);
53 static int aiw_read_picture(VideoData *s, uint8_t *data);
54 static int aiw_close(VideoData *s);
56 static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
58 VideoData *s = s1->priv_data;
61 int video_fd, frame_size;
64 struct video_audio audio;
66 if (!ap || ap->width <= 0 || ap->height <= 0 || ap->frame_rate <= 0)
71 frame_rate = ap->frame_rate;
73 st = av_new_stream(s1, 0);
79 s->frame_rate = frame_rate;
81 video_fd = open(video_device, O_RDWR);
87 if (ioctl(video_fd,VIDIOCGCAP, &s->video_cap) < 0) {
92 if (!(s->video_cap.type & VID_TYPE_CAPTURE)) {
93 fprintf(stderr, "Fatal: grab device does not handle capture\n");
98 if (st->codec.pix_fmt == PIX_FMT_YUV420P) {
99 desired_palette = VIDEO_PALETTE_YUV420P;
100 } else if (st->codec.pix_fmt == PIX_FMT_YUV422) {
101 desired_palette = VIDEO_PALETTE_YUV422;
102 } else if (st->codec.pix_fmt == PIX_FMT_BGR24) {
103 desired_palette = VIDEO_PALETTE_RGB24;
108 ioctl(video_fd, VIDIOCGAUDIO, &audio);
109 memcpy(&s->audio_saved, &audio, sizeof(audio));
110 audio.flags &= ~VIDEO_AUDIO_MUTE;
111 ioctl(video_fd, VIDIOCSAUDIO, &audio);
113 ret = ioctl(video_fd,VIDIOCGMBUF,&s->gb_buffers);
115 /* try to use read based access */
116 struct video_window win;
117 struct video_picture pict;
127 ioctl(video_fd, VIDIOCSWIN, &win);
129 ioctl(video_fd, VIDIOCGPICT, &pict);
131 printf("v4l: colour=%d hue=%d brightness=%d constrast=%d whiteness=%d\n",
138 /* try to choose a suitable video format */
139 pict.palette = desired_palette;
140 if (desired_palette == -1 || (ret = ioctl(video_fd, VIDIOCSPICT, &pict)) < 0) {
141 pict.palette=VIDEO_PALETTE_YUV420P;
142 ret = ioctl(video_fd, VIDIOCSPICT, &pict);
144 pict.palette=VIDEO_PALETTE_YUV422;
145 ret = ioctl(video_fd, VIDIOCSPICT, &pict);
147 pict.palette=VIDEO_PALETTE_RGB24;
148 ret = ioctl(video_fd, VIDIOCSPICT, &pict);
155 s->frame_format = pict.palette;
158 ioctl(video_fd, VIDIOCCAPTURE, &val);
160 s->time_frame = av_gettime();
163 /* ATI All In Wonder automatic activation */
164 if (!strcmp(s->video_cap.name, "Km")) {
168 /* force 420P format because convertion from YUV422 to YUV420P
169 is done in this driver (ugly) */
170 s->frame_format = VIDEO_PALETTE_YUV420P;
173 s->video_buf = mmap(0,s->gb_buffers.size,PROT_READ|PROT_WRITE,MAP_SHARED,video_fd,0);
174 if ((unsigned char*)-1 == s->video_buf) {
179 s->time_frame = av_gettime();
181 /* start to grab the first frame */
182 s->gb_buf.frame = s->gb_frame % s->gb_buffers.frames;
183 s->gb_buf.height = height;
184 s->gb_buf.width = width;
185 s->gb_buf.format = desired_palette;
187 if (desired_palette == -1 || (ret = ioctl(video_fd, VIDIOCMCAPTURE, &s->gb_buf)) < 0) {
188 s->gb_buf.format = VIDEO_PALETTE_YUV420P;
190 ret = ioctl(video_fd, VIDIOCMCAPTURE, &s->gb_buf);
191 if (ret < 0 && errno != EAGAIN) {
193 s->gb_buf.format = VIDEO_PALETTE_YUV422;
195 ret = ioctl(video_fd, VIDIOCMCAPTURE, &s->gb_buf);
196 if (ret < 0 && errno != EAGAIN) {
198 s->gb_buf.format = VIDEO_PALETTE_RGB24;
199 ret = ioctl(video_fd, VIDIOCMCAPTURE, &s->gb_buf);
204 if (errno != EAGAIN) {
206 fprintf(stderr, "Fatal: grab device does not support suitable format\n");
208 fprintf(stderr,"Fatal: grab device does not receive any video signal\n");
212 s->frame_format = s->gb_buf.format;
216 switch(s->frame_format) {
217 case VIDEO_PALETTE_YUV420P:
218 frame_size = (width * height * 3) / 2;
219 st->codec.pix_fmt = PIX_FMT_YUV420P;
221 case VIDEO_PALETTE_YUV422:
222 frame_size = width * height * 2;
223 st->codec.pix_fmt = PIX_FMT_YUV422;
225 case VIDEO_PALETTE_RGB24:
226 frame_size = width * height * 3;
227 st->codec.pix_fmt = PIX_FMT_BGR24; /* NOTE: v4l uses BGR24, not RGB24 ! */
233 s->frame_size = frame_size;
235 st->codec.codec_type = CODEC_TYPE_VIDEO;
236 st->codec.codec_id = CODEC_ID_RAWVIDEO;
237 st->codec.width = width;
238 st->codec.height = height;
239 st->codec.frame_rate = frame_rate;
241 av_set_pts_info(s1, 48, 1, 1000000); /* 48 bits pts in us */
251 static int v4l_mm_read_picture(VideoData *s, UINT8 *buf)
255 /* Setup to capture the next frame */
256 s->gb_buf.frame = (s->gb_frame + 1) % s->gb_buffers.frames;
257 if (ioctl(s->fd, VIDIOCMCAPTURE, &s->gb_buf) < 0) {
259 fprintf(stderr,"Cannot Sync\n");
261 perror("VIDIOCMCAPTURE");
265 while (ioctl(s->fd, VIDIOCSYNC, &s->gb_frame) < 0 &&
266 (errno == EAGAIN || errno == EINTR));
268 ptr = s->video_buf + s->gb_buffers.offsets[s->gb_frame];
269 memcpy(buf, ptr, s->frame_size);
271 /* This is now the grabbing frame */
272 s->gb_frame = s->gb_buf.frame;
274 return s->frame_size;
277 static int grab_read_packet(AVFormatContext *s1, AVPacket *pkt)
279 VideoData *s = s1->priv_data;
280 INT64 curtime, delay;
282 INT64 per_frame = (INT64_C(1000000) * FRAME_RATE_BASE) / s->frame_rate;
284 /* Calculate the time of the next frame */
285 s->time_frame += per_frame;
287 /* wait based on the frame rate */
289 curtime = av_gettime();
290 delay = s->time_frame - curtime;
292 if (delay < -per_frame) {
293 /* printf("grabbing is %d frames late (dropping)\n", (int) -(delay / 16666)); */
294 s->time_frame += per_frame;
298 ts.tv_sec = delay / 1000000;
299 ts.tv_nsec = (delay % 1000000) * 1000;
300 nanosleep(&ts, NULL);
303 if (av_new_packet(pkt, s->frame_size) < 0)
306 pkt->pts = curtime & ((1LL << 48) - 1);
309 if (s->aiw_enabled) {
310 return aiw_read_picture(s, pkt->data);
311 } else if (s->use_mmap) {
312 return v4l_mm_read_picture(s, pkt->data);
314 if (read(s->fd, pkt->data, pkt->size) != pkt->size)
316 return s->frame_size;
320 static int grab_read_close(AVFormatContext *s1)
322 VideoData *s = s1->priv_data;
328 munmap(s->video_buf, s->gb_buffers.size);
330 /* mute audio. we must force it because the BTTV driver does not
331 return its state correctly */
332 s->audio_saved.flags |= VIDEO_AUDIO_MUTE;
333 ioctl(s->fd, VIDIOCSAUDIO, &s->audio_saved);
339 static AVInputFormat video_grab_device_format = {
347 .flags = AVFMT_NOFILE,
350 /* All in Wonder specific stuff */
351 /* XXX: remove and merge in libavcodec/imgconvert.c */
353 static int aiw_init(VideoData *s)
360 if ((width == s->video_cap.maxwidth && height == s->video_cap.maxheight) ||
361 (width == s->video_cap.maxwidth && height == s->video_cap.maxheight*2) ||
362 (width == s->video_cap.maxwidth/2 && height == s->video_cap.maxheight)) {
366 if (height == s->video_cap.maxheight*2) s->deint=1;
367 if (width == s->video_cap.maxwidth/2) s->halfw=1;
369 fprintf(stderr,"\nIncorrect Grab Size Supplied - Supported Sizes Are:\n");
370 fprintf(stderr," %dx%d %dx%d %dx%d\n\n",
371 s->video_cap.maxwidth,s->video_cap.maxheight,
372 s->video_cap.maxwidth,s->video_cap.maxheight*2,
373 s->video_cap.maxwidth/2,s->video_cap.maxheight);
378 s->src_mem = av_malloc(s->width*2);
380 s->src_mem = av_malloc(s->width*4);
382 if (!s->src_mem) goto fail;
384 s->lum_m4_mem = av_malloc(s->width);
389 av_freep(&s->src_mem);
390 av_freep(&s->lum_m4_mem);
395 #include "../libavcodec/i386/mmx.h"
397 #define LINE_WITH_UV \
398 movq_m2r(ptr[0],mm0); \
399 movq_m2r(ptr[8],mm1); \
400 movq_r2r(mm0, mm4); \
401 punpcklbw_r2r(mm1,mm0); \
402 punpckhbw_r2r(mm1,mm4); \
404 punpcklbw_r2r(mm4,mm0); \
405 punpckhbw_r2r(mm4,mm5); \
407 punpcklbw_r2r(mm5,mm1); \
408 movq_r2m(mm1,lum[0]); \
409 movq_m2r(ptr[16],mm2); \
410 movq_m2r(ptr[24],mm1); \
412 punpcklbw_r2r(mm1,mm2); \
413 punpckhbw_r2r(mm1,mm4); \
415 punpcklbw_r2r(mm4,mm2); \
416 punpckhbw_r2r(mm4,mm3); \
418 punpcklbw_r2r(mm3,mm1); \
419 movq_r2m(mm1,lum[8]); \
420 punpckhdq_r2r(mm2,mm0); \
421 punpckhdq_r2r(mm3,mm5); \
422 movq_r2m(mm0,cb[0]); \
426 movq_m2r(ptr[0],mm0);\
427 movq_m2r(ptr[8],mm1);\
429 punpcklbw_r2r(mm1,mm0); \
430 punpckhbw_r2r(mm1,mm4);\
432 punpcklbw_r2r(mm4,mm0);\
433 punpckhbw_r2r(mm4,mm5);\
435 punpcklbw_r2r(mm5,mm1);\
436 movq_r2m(mm1,lum[0]);\
437 movq_m2r(ptr[16],mm2);\
438 movq_m2r(ptr[24],mm1);\
440 punpcklbw_r2r(mm1,mm2);\
441 punpckhbw_r2r(mm1,mm4);\
443 punpcklbw_r2r(mm4,mm2);\
444 punpckhbw_r2r(mm4,mm3);\
446 punpcklbw_r2r(mm3,mm1);\
447 movq_r2m(mm1,lum[8]);
449 #define LINE_WITHUV_AVG \
450 movq_m2r(ptr[0], mm0);\
451 movq_m2r(ptr[8], mm1);\
453 punpcklbw_r2r(mm1,mm0);\
454 punpckhbw_r2r(mm1,mm4);\
456 punpcklbw_r2r(mm4,mm0);\
457 punpckhbw_r2r(mm4,mm5);\
460 punpcklbw_r2r(mm7,mm1);\
461 punpcklbw_r2r(mm7,mm2);\
465 packuswb_r2r(mm7,mm1);\
466 movd_r2m(mm1,lum[0]);\
467 movq_m2r(ptr[16],mm2);\
468 movq_m2r(ptr[24],mm1);\
470 punpcklbw_r2r(mm1,mm2);\
471 punpckhbw_r2r(mm1,mm4);\
473 punpcklbw_r2r(mm4,mm2);\
474 punpckhbw_r2r(mm4,mm3);\
477 punpcklbw_r2r(mm7,mm1);\
478 punpcklbw_r2r(mm7,mm4);\
482 packuswb_r2r(mm7,mm1);\
483 movd_r2m(mm1,lum[4]);\
484 punpckhbw_r2r(mm7,mm0);\
485 punpckhbw_r2r(mm7,mm2);\
489 packuswb_r2r(mm7,mm0);\
490 punpckhbw_r2r(mm7,mm5);\
491 punpckhbw_r2r(mm7,mm3);\
495 packuswb_r2r(mm7,mm5);\
496 movd_r2m(mm0,cb[0]);\
499 #define LINE_NOUV_AVG \
500 movq_m2r(ptr[0],mm0);\
501 movq_m2r(ptr[8],mm1);\
504 pmaddwd_r2r(mm6,mm0);\
505 pmaddwd_r2r(mm6,mm1);\
506 packssdw_r2r(mm1,mm0);\
509 movq_m2r(ptr[16],mm2);\
510 movq_m2r(ptr[24],mm3);\
513 pmaddwd_r2r(mm6,mm2);\
514 pmaddwd_r2r(mm6,mm3);\
515 packssdw_r2r(mm3,mm2);\
518 packuswb_r2r(mm2,mm0);\
519 movq_r2m(mm0,lum[0]);
521 #define DEINT_LINE_LUM(ptroff) \
522 movd_m2r(lum_m4[(ptroff)],mm0);\
523 movd_m2r(lum_m3[(ptroff)],mm1);\
524 movd_m2r(lum_m2[(ptroff)],mm2);\
525 movd_m2r(lum_m1[(ptroff)],mm3);\
526 movd_m2r(lum[(ptroff)],mm4);\
527 punpcklbw_r2r(mm7,mm0);\
528 movd_r2m(mm2,lum_m4[(ptroff)]);\
529 punpcklbw_r2r(mm7,mm1);\
530 punpcklbw_r2r(mm7,mm2);\
531 punpcklbw_r2r(mm7,mm3);\
532 punpcklbw_r2r(mm7,mm4);\
540 psubusw_r2r(mm0,mm1);\
542 packuswb_r2r(mm7,mm1);\
543 movd_r2m(mm1,lum_m2[(ptroff)]);
546 #include "../libavcodec/dsputil.h"
548 #define LINE_WITH_UV \
549 lum[0]=ptr[0];lum[1]=ptr[2];lum[2]=ptr[4];lum[3]=ptr[6];\
550 cb[0]=ptr[1];cb[1]=ptr[5];\
551 cr[0]=ptr[3];cr[1]=ptr[7];\
552 lum[4]=ptr[8];lum[5]=ptr[10];lum[6]=ptr[12];lum[7]=ptr[14];\
553 cb[2]=ptr[9];cb[3]=ptr[13];\
554 cr[2]=ptr[11];cr[3]=ptr[15];\
555 lum[8]=ptr[16];lum[9]=ptr[18];lum[10]=ptr[20];lum[11]=ptr[22];\
556 cb[4]=ptr[17];cb[5]=ptr[21];\
557 cr[4]=ptr[19];cr[5]=ptr[23];\
558 lum[12]=ptr[24];lum[13]=ptr[26];lum[14]=ptr[28];lum[15]=ptr[30];\
559 cb[6]=ptr[25];cb[7]=ptr[29];\
560 cr[6]=ptr[27];cr[7]=ptr[31];
563 lum[0]=ptr[0];lum[1]=ptr[2];lum[2]=ptr[4];lum[3]=ptr[6];\
564 lum[4]=ptr[8];lum[5]=ptr[10];lum[6]=ptr[12];lum[7]=ptr[14];\
565 lum[8]=ptr[16];lum[9]=ptr[18];lum[10]=ptr[20];lum[11]=ptr[22];\
566 lum[12]=ptr[24];lum[13]=ptr[26];lum[14]=ptr[28];lum[15]=ptr[30];
568 #define LINE_WITHUV_AVG \
569 sum=(ptr[0]+ptr[2]+1) >> 1;lum[0]=sum; \
570 sum=(ptr[4]+ptr[6]+1) >> 1;lum[1]=sum; \
571 sum=(ptr[1]+ptr[5]+1) >> 1;cb[0]=sum; \
572 sum=(ptr[3]+ptr[7]+1) >> 1;cr[0]=sum; \
573 sum=(ptr[8]+ptr[10]+1) >> 1;lum[2]=sum; \
574 sum=(ptr[12]+ptr[14]+1) >> 1;lum[3]=sum; \
575 sum=(ptr[9]+ptr[13]+1) >> 1;cb[1]=sum; \
576 sum=(ptr[11]+ptr[15]+1) >> 1;cr[1]=sum; \
577 sum=(ptr[16]+ptr[18]+1) >> 1;lum[4]=sum; \
578 sum=(ptr[20]+ptr[22]+1) >> 1;lum[5]=sum; \
579 sum=(ptr[17]+ptr[21]+1) >> 1;cb[2]=sum; \
580 sum=(ptr[19]+ptr[23]+1) >> 1;cr[2]=sum; \
581 sum=(ptr[24]+ptr[26]+1) >> 1;lum[6]=sum; \
582 sum=(ptr[28]+ptr[30]+1) >> 1;lum[7]=sum; \
583 sum=(ptr[25]+ptr[29]+1) >> 1;cb[3]=sum; \
584 sum=(ptr[27]+ptr[31]+1) >> 1;cr[3]=sum;
586 #define LINE_NOUV_AVG \
587 sum=(ptr[0]+ptr[2]+1) >> 1;lum[0]=sum; \
588 sum=(ptr[4]+ptr[6]+1) >> 1;lum[1]=sum; \
589 sum=(ptr[8]+ptr[10]+1) >> 1;lum[2]=sum; \
590 sum=(ptr[12]+ptr[14]+1) >> 1;lum[3]=sum; \
591 sum=(ptr[16]+ptr[18]+1) >> 1;lum[4]=sum; \
592 sum=(ptr[20]+ptr[22]+1) >> 1;lum[5]=sum; \
593 sum=(ptr[24]+ptr[26]+1) >> 1;lum[6]=sum; \
594 sum=(ptr[28]+ptr[30]+1) >> 1;lum[7]=sum;
596 #define DEINT_LINE_LUM(ptroff) \
597 sum=(-lum_m4[(ptroff)]+(lum_m3[(ptroff)]<<2)+(lum_m2[(ptroff)]<<1)+(lum_m1[(ptroff)]<<2)-lum[(ptroff)]); \
598 lum_m4[(ptroff)]=lum_m2[(ptroff)];\
599 lum_m2[(ptroff)]=cm[(sum+4)>>3];\
600 sum=(-lum_m4[(ptroff)+1]+(lum_m3[(ptroff)+1]<<2)+(lum_m2[(ptroff)+1]<<1)+(lum_m1[(ptroff)+1]<<2)-lum[(ptroff)+1]); \
601 lum_m4[(ptroff)+1]=lum_m2[(ptroff)+1];\
602 lum_m2[(ptroff)+1]=cm[(sum+4)>>3];\
603 sum=(-lum_m4[(ptroff)+2]+(lum_m3[(ptroff)+2]<<2)+(lum_m2[(ptroff)+2]<<1)+(lum_m1[(ptroff)+2]<<2)-lum[(ptroff)+2]); \
604 lum_m4[(ptroff)+2]=lum_m2[(ptroff)+2];\
605 lum_m2[(ptroff)+2]=cm[(sum+4)>>3];\
606 sum=(-lum_m4[(ptroff)+3]+(lum_m3[(ptroff)+3]<<2)+(lum_m2[(ptroff)+3]<<1)+(lum_m1[(ptroff)+3]<<2)-lum[(ptroff)+3]); \
607 lum_m4[(ptroff)+3]=lum_m2[(ptroff)+3];\
608 lum_m2[(ptroff)+3]=cm[(sum+4)>>3];
613 /* Read two fields separately. */
614 static int aiw_read_picture(VideoData *s, uint8_t *data)
616 UINT8 *ptr, *lum, *cb, *cr;
621 UINT8* src = s->src_mem;
622 UINT8 *ptrend = &src[s->width*2];
624 cb=&lum[s->width*s->height];
625 cr=&cb[(s->width*s->height)/4];
626 if (s->deint == 0 && s->halfw == 0) {
627 while (read(s->fd,src,s->width*2) < 0) {
630 for (h = 0; h < s->height-2; h+=2) {
631 for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=16, cb+=8, cr+=8) {
634 read(s->fd,src,s->width*2);
635 for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=16) {
638 read(s->fd,src,s->width*2);
643 for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=16, cb+=8, cr+=8) {
646 read(s->fd,src,s->width*2);
647 for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=16) {
650 /* drop second field */
651 while (read(s->fd,src,s->width*2) < 0) {
654 for (h = 0; h < s->height - 1; h++) {
655 read(s->fd,src,s->width*2);
657 } else if (s->halfw == 1) {
674 movq_m2r(rounder,mm6);
676 while (read(s->fd,src,s->width*4) < 0) {
679 ptrend = &src[s->width*4];
680 for (h = 0; h < s->height-2; h+=2) {
681 for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=8, cb+=4, cr+=4) {
684 read(s->fd,src,s->width*4);
686 movq_m2r(masker,mm5);
688 for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=8) {
691 read(s->fd,src,s->width*4);
696 for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=8, cb+=4, cr+=4) {
699 read(s->fd,src,s->width*4);
701 movq_m2r(masker,mm5);
703 for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=8) {
706 /* drop second field */
707 while (read(s->fd,src,s->width*4) < 0) {
710 for (h = 0; h < s->height - 1; h++) {
711 read(s->fd,src,s->width*4);
714 UINT8 *lum_m1, *lum_m2, *lum_m3, *lum_m4;
721 movq_m2r(rounder,mm6);
724 UINT8 *cm = cropTbl + MAX_NEG_CROP;
727 /* read two fields and deinterlace them */
728 while (read(s->fd,src,s->width*2) < 0) {
731 for (h = 0; h < (s->height/2)-2; h+=2) {
732 for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=16, cb+=8, cr+=8) {
735 read(s->fd,src,s->width*2);
736 /* skip a luminance line - will be filled in later */
738 for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=16, cb+=8, cr+=8) {
741 /* skip a luminance line - will be filled in later */
743 read(s->fd,src,s->width*2);
748 for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=16, cb+=8, cr+=8) {
751 /* skip a luminance line - will be filled in later */
753 read(s->fd,src,s->width*2);
754 for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=16, cb+=8, cr+=8) {
763 while (read(s->fd,src,s->width*2) < 0) {
766 /* First (and last) two lines not interlaced */
767 for (h = 0; h < 2; h++) {
768 for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=16) {
771 read(s->fd,src,s->width*2);
772 /* skip a luminance line */
775 lum_m1=&lum[-s->width];
776 lum_m2=&lum_m1[-s->width];
777 lum_m3=&lum_m2[-s->width];
778 memmove(s->lum_m4_mem,&lum_m3[-s->width],s->width);
779 for (; h < (s->height/2)-1; h++) {
780 lum_m4=s->lum_m4_mem;
781 for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=16,lum_m1+=16,lum_m2+=16,lum_m3+=16,lum_m4+=16) {
789 read(s->fd,src,s->width*2);
790 /* skip a luminance line */
795 // lum_m4 += s->width;
800 lum_m4=s->lum_m4_mem;
801 for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=16, lum_m1+=16, lum_m2+=16, lum_m3+=16, lum_m4+=16) {
813 return s->frame_size;
816 static int aiw_close(VideoData *s)
818 av_freep(&s->lum_m4_mem);
819 av_freep(&s->src_mem);
823 int video_grab_init(void)
825 av_register_input_format(&video_grab_device_format);