diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-05-27 23:47:05 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-05-27 23:48:22 +0200 |
commit | 8381ab143779d25611a1bb05d674bc39fe940f77 (patch) | |
tree | 74773be2c947475433dcc47898aec49a0c4b198b /libavdevice/bktr.c | |
parent | b8773e44d56667edea2d68d067d0c156522ca304 (diff) | |
parent | 79aeade6f6f8fbd7ce1da619fdd475e5db88ae24 (diff) | |
download | ffmpeg-8381ab143779d25611a1bb05d674bc39fe940f77.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master: (29 commits)
ARM: disable ff_vector_fmul_vfp on VFPv3 systems
ARM: check for VFPv3
swscale: Remove unused variables in x86 code.
doc: Drop DJGPP section, Libav now compiles out-of-the-box on FreeDOS.
x86: Add appropriate ifdefs around certain AVX functions.
cmdutils: use sws_freeContext() instead of av_freep().
swscale: delay allocation of formatConvBuffer().
swscale: fix build with --disable-swscale-alpha.
movenc: Deprecate the global RTP hinting flag, use a private AVOption instead
movenc: Add an AVClass for setting muxer specific options
swscale: fix non-bitexact yuv2yuv[X2]() MMX/MMX2 functions.
configure: report yasm/nasm presence properly
tcp: make connect() timeout properly
rawdec: factor video demuxer definitions into a macro.
rtspdec: add initial_pause private option.
lavf: deprecate AVFormatParameters.width/height.
tty: add video_size private option.
rawdec: add video_size private option.
x11grab: add video_size private option.
x11grab: factorize returning error codes.
...
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavdevice/bktr.c')
-rw-r--r-- | libavdevice/bktr.c | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/libavdevice/bktr.c b/libavdevice/bktr.c index 7b0f1b7382..f04f29c3e2 100644 --- a/libavdevice/bktr.c +++ b/libavdevice/bktr.c @@ -26,6 +26,7 @@ #include "libavutil/log.h" #include "libavutil/opt.h" +#include "libavutil/parseutils.h" #if HAVE_DEV_BKTR_IOCTL_METEOR_H && HAVE_DEV_BKTR_IOCTL_BT848_H # include <dev/bktr/ioctl_meteor.h> # include <dev/bktr/ioctl_bt848.h> @@ -57,6 +58,7 @@ typedef struct { int frame_rate_base; uint64_t per_frame; int standard; + char *video_size; /**< String describing video size, set by a private option. */ } VideoData; @@ -249,18 +251,31 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) int width, height; int frame_rate; int frame_rate_base; + int ret = 0; - if (ap->width <= 0 || ap->height <= 0 || ap->time_base.den <= 0) - return -1; + if (ap->time_base.den <= 0) { + ret = AVERROR(EINVAL); + goto out; + } - width = ap->width; - height = ap->height; + if ((ret = av_parse_video_size(&width, &height, s->video_size)) < 0) { + av_log(s1, AV_LOG_ERROR, "Couldn't parse video size.\n"); + goto out; + } +#if FF_API_FORMAT_PARAMETERS + if (ap->width > 0) + width = ap->width; + if (ap->height > 0) + height = ap->height; +#endif frame_rate = ap->time_base.den; frame_rate_base = ap->time_base.num; st = av_new_stream(s1, 0); - if (!st) - return AVERROR(ENOMEM); + if (!st) { + ret = AVERROR(ENOMEM); + goto out; + } av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in use */ s->width = width; @@ -289,13 +304,17 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) #endif if (bktr_init(s1->filename, width, height, s->standard, - &(s->video_fd), &(s->tuner_fd), -1, 0.0) < 0) - return AVERROR(EIO); + &(s->video_fd), &(s->tuner_fd), -1, 0.0) < 0) { + ret = AVERROR(EIO); + goto out; + } nsignals = 0; last_frame_time = 0; - return 0; +out: + av_freep(&s->video_size); + return ret; } static int grab_read_close(AVFormatContext *s1) @@ -316,6 +335,8 @@ static int grab_read_close(AVFormatContext *s1) return 0; } +#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" }, @@ -324,6 +345,7 @@ static const AVOption options[] = { { "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 }, { NULL }, }; |