X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavdevice%2Fbktr.c;h=06f4d860c2d69902d37d2ed351ac7feec6a09242;hb=0652e024c680420d298cdf3719d0a0c030173fe3;hp=f1ae9ea6857a50254e304bd608247cdf55880d60;hpb=41b68dce4d148b6a227d001b32deb275c01aa550;p=ffmpeg diff --git a/libavdevice/bktr.c b/libavdevice/bktr.c index f1ae9ea6857..06f4d860c2d 100644 --- a/libavdevice/bktr.c +++ b/libavdevice/bktr.c @@ -25,9 +25,12 @@ */ #include "libavformat/avformat.h" +#include "libavformat/internal.h" +#include "libavutil/internal.h" #include "libavutil/log.h" #include "libavutil/opt.h" #include "libavutil/parseutils.h" +#include "libavutil/time.h" #if HAVE_DEV_BKTR_IOCTL_METEOR_H && HAVE_DEV_BKTR_IOCTL_BT848_H # include # include @@ -47,7 +50,6 @@ #include #include #include -#include typedef struct { AVClass *class; @@ -102,7 +104,7 @@ static av_cold int bktr_init(const char *video_device, int width, int height, long ioctl_frequency; char *arg; int c; - struct sigaction act, old; + struct sigaction act = { 0 }, old; if (idev < 0 || idev > 4) { @@ -131,16 +133,15 @@ static av_cold int bktr_init(const char *video_device, int width, int height, frequency = 0.0; } - memset(&act, 0, sizeof(act)); sigemptyset(&act.sa_mask); act.sa_handler = catchsignal; sigaction(SIGUSR1, &act, &old); - *tuner_fd = open("/dev/tuner0", O_RDONLY); + *tuner_fd = avpriv_open("/dev/tuner0", O_RDONLY); if (*tuner_fd < 0) av_log(NULL, AV_LOG_ERROR, "Warning. Tuner not opened, continuing: %s\n", strerror(errno)); - *video_fd = open(video_device, O_RDONLY); + *video_fd = avpriv_open(video_device, O_RDONLY); if (*video_fd < 0) { av_log(NULL, AV_LOG_ERROR, "%s: %s\n", video_device, strerror(errno)); return -1; @@ -243,7 +244,7 @@ static int grab_read_packet(AVFormatContext *s1, AVPacket *pkt) return video_buf_size; } -static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) +static int grab_read_header(AVFormatContext *s1) { VideoData *s = s1->priv_data; AVStream *st; @@ -251,17 +252,6 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) AVRational framerate; int ret = 0; -#if FF_API_FORMAT_PARAMETERS - if (ap->standard) { - if (!strcasecmp(ap->standard, "pal")) - s->standard = PAL; - else if (!strcasecmp(ap->standard, "secam")) - s->standard = SECAM; - else if (!strcasecmp(ap->standard, "ntsc")) - s->standard = NTSC; - } -#endif - if ((ret = av_parse_video_size(&width, &height, s->video_size)) < 0) { av_log(s1, AV_LOG_ERROR, "Could not parse video size '%s'.\n", s->video_size); goto out; @@ -281,29 +271,21 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) av_log(s1, AV_LOG_ERROR, "Could not parse framerate '%s'.\n", s->framerate); goto out; } -#if FF_API_FORMAT_PARAMETERS - if (ap->width > 0) - width = ap->width; - if (ap->height > 0) - height = ap->height; - if (ap->time_base.num) - framerate = (AVRational){ap->time_base.den, ap->time_base.num}; -#endif - st = av_new_stream(s1, 0); + st = avformat_new_stream(s1, NULL); if (!st) { ret = AVERROR(ENOMEM); goto out; } - av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in use */ + avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in use */ s->width = width; s->height = height; s->per_frame = ((uint64_t)1000000 * framerate.den) / framerate.num; st->codec->codec_type = AVMEDIA_TYPE_VIDEO; - st->codec->pix_fmt = PIX_FMT_YUV420P; - st->codec->codec_id = CODEC_ID_RAWVIDEO; + st->codec->pix_fmt = AV_PIX_FMT_YUV420P; + st->codec->codec_id = AV_CODEC_ID_RAWVIDEO; st->codec->width = width; st->codec->height = height; st->codec->time_base.den = framerate.num; @@ -311,7 +293,7 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) if (bktr_init(s1->filename, width, height, s->standard, - &(s->video_fd), &(s->tuner_fd), -1, 0.0) < 0) { + &s->video_fd, &s->tuner_fd, -1, 0.0) < 0) { ret = AVERROR(EIO); goto out; } @@ -344,15 +326,15 @@ static int grab_read_close(AVFormatContext *s1) #define OFFSET(x) offsetof(VideoData, x) #define DEC AV_OPT_FLAG_DECODING_PARAM static const AVOption options[] = { - { "standard", "", offsetof(VideoData, standard), FF_OPT_TYPE_INT, {.dbl = VIDEO_FORMAT}, PAL, NTSCJ, AV_OPT_FLAG_DECODING_PARAM, "standard" }, - { "PAL", "", 0, FF_OPT_TYPE_CONST, {.dbl = PAL}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "standard" }, - { "NTSC", "", 0, FF_OPT_TYPE_CONST, {.dbl = NTSC}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "standard" }, - { "SECAM", "", 0, FF_OPT_TYPE_CONST, {.dbl = SECAM}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "standard" }, - { "PALN", "", 0, FF_OPT_TYPE_CONST, {.dbl = PALN}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "standard" }, - { "PALM", "", 0, FF_OPT_TYPE_CONST, {.dbl = PALM}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "standard" }, - { "NTSCJ", "", 0, FF_OPT_TYPE_CONST, {.dbl = NTSCJ}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "standard" }, - { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = "vga"}, 0, 0, DEC }, - { "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, + { "standard", "", offsetof(VideoData, standard), AV_OPT_TYPE_INT, {.i64 = VIDEO_FORMAT}, PAL, NTSCJ, AV_OPT_FLAG_DECODING_PARAM, "standard" }, + { "PAL", "", 0, AV_OPT_TYPE_CONST, {.i64 = PAL}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "standard" }, + { "NTSC", "", 0, AV_OPT_TYPE_CONST, {.i64 = NTSC}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "standard" }, + { "SECAM", "", 0, AV_OPT_TYPE_CONST, {.i64 = SECAM}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "standard" }, + { "PALN", "", 0, AV_OPT_TYPE_CONST, {.i64 = PALN}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "standard" }, + { "PALM", "", 0, AV_OPT_TYPE_CONST, {.i64 = PALM}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "standard" }, + { "NTSCJ", "", 0, AV_OPT_TYPE_CONST, {.i64 = NTSCJ}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "standard" }, + { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), AV_OPT_TYPE_STRING, {.str = "vga"}, 0, 0, DEC }, + { "framerate", "", OFFSET(framerate), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, { NULL }, }; @@ -364,13 +346,12 @@ static const AVClass bktr_class = { }; AVInputFormat ff_bktr_demuxer = { - "bktr", - NULL_IF_CONFIG_SMALL("video grab"), - sizeof(VideoData), - NULL, - grab_read_header, - grab_read_packet, - grab_read_close, - .flags = AVFMT_NOFILE, - .priv_class = &bktr_class, + .name = "bktr", + .long_name = NULL_IF_CONFIG_SMALL("video grab"), + .priv_data_size = sizeof(VideoData), + .read_header = grab_read_header, + .read_packet = grab_read_packet, + .read_close = grab_read_close, + .flags = AVFMT_NOFILE, + .priv_class = &bktr_class, };