X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fgrab_bktr.c;h=e40082fcc27dcb54d1be2e2167cb08e55b19b092;hb=e5c29287cf495ca83faecd1b94caf2e130481f55;hp=37ec92916615bc077ea0c58cccba2b33f6105768;hpb=9f747cc328de389eb3748038202f753316a0a6ab;p=ffmpeg diff --git a/libavformat/grab_bktr.c b/libavformat/grab_bktr.c index 37ec9291661..e40082fcc27 100644 --- a/libavformat/grab_bktr.c +++ b/libavformat/grab_bktr.c @@ -7,33 +7,33 @@ * and * simple_grab.c Copyright (c) 1999 Roger Hardiman * - * This library is free software; you can redistribute it and/or + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "avformat.h" -#if defined(__FreeBSD__) -# if __FreeBSD__ >= 502100 -# include -# include -# else -# include -# include -# endif -#elseif defined(__DragonFly__) +#if defined (HAVE_DEV_BKTR_IOCTL_METEOR_H) && defined (HAVE_DEV_BKTR_IOCTL_BT848_H) +# include +# include +#elif defined (HAVE_MACHINE_IOCTL_METEOR_H) && defined (HAVE_MACHINE_IOCTL_BT848_H) +# include +# include +#elif defined (HAVE_DEV_VIDEO_METEOR_IOCTL_METEOR_H) && defined (HAVE_DEV_VIDEO_METEOR_IOCTL_BT848_H) # include # include -#else +#elif HAVE_DEV_IC_BT8XX_H # include #endif #include @@ -174,7 +174,7 @@ static int bktr_init(const char *video_device, int width, int height, video_buf_size = width * height * 12 / 8; - video_buf = (uint8_t *)mmap((caddr_t)0, video_buf_size, + video_buf = (uint8_t *)mmap((caddr_t)0, video_buf_size, PROT_READ, MAP_SHARED, *video_fd, (off_t)0); if (video_buf == MAP_FAILED) { perror("mmap"); @@ -182,7 +182,7 @@ static int bktr_init(const char *video_device, int width, int height, } if (frequency != 0.0) { - ioctl_frequency = (unsigned long)(frequency*16); + ioctl_frequency = (unsigned long)(frequency*16); if (ioctl(*tuner_fd, TVTUNER_SETFREQ, &ioctl_frequency) < 0) perror("TVTUNER_SETFREQ"); } @@ -225,11 +225,11 @@ static int grab_read_packet(AVFormatContext *s1, AVPacket *pkt) VideoData *s = s1->priv_data; if (av_new_packet(pkt, video_buf_size) < 0) - return -EIO; + return AVERROR(EIO); bktr_getframe(s->per_frame); - pkt->pts = av_gettime() & ((1LL << 48) - 1); + pkt->pts = av_gettime(); memcpy(pkt->data, video_buf, video_buf_size); return video_buf_size; @@ -243,9 +243,8 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) int frame_rate; int frame_rate_base; int format = -1; - const char *video_device; - if (!ap || ap->width <= 0 || ap->height <= 0 || ap->time_base.den <= 0) + if (ap->width <= 0 || ap->height <= 0 || ap->time_base.den <= 0) return -1; width = ap->width; @@ -253,14 +252,10 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) frame_rate = ap->time_base.den; frame_rate_base = ap->time_base.num; - video_device = ap->device; - if (!video_device) - video_device = "/dev/bktr0"; - st = av_new_stream(s1, 0); if (!st) - return -ENOMEM; - av_set_pts_info(st, 48, 1, 1000000); /* 48 bits pts in use */ + return AVERROR(ENOMEM); + av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in use */ s->width = width; s->height = height; @@ -285,9 +280,9 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) format = NTSC; } - if (bktr_init(video_device, width, height, format, + if (bktr_init(s1->filename, width, height, format, &(s->video_fd), &(s->tuner_fd), -1, 0.0) < 0) - return -EIO; + return AVERROR(EIO); nsignals = 0; last_frame_time = 0; @@ -313,19 +308,13 @@ static int grab_read_close(AVFormatContext *s1) return 0; } -AVInputFormat video_grab_device_format = { +AVInputFormat video_grab_bktr_demuxer = { "bktr", "video grab", - sizeof(VideoData), - NULL, + sizeof(VideoData), + NULL, grab_read_header, grab_read_packet, grab_read_close, .flags = AVFMT_NOFILE, }; - -int video_grab_init(void) -{ - av_register_input_format(&video_grab_device_format); - return 0; -}