---
libavdevice/bktr.c | 24 +++++++++++++++---------
1 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/libavdevice/bktr.c b/libavdevice/bktr.c
index 8215671..e0fa8da 100644
--- a/libavdevice/bktr.c
+++ b/libavdevice/bktr.c
@@ -246,15 +246,21 @@ static int grab_read_header(AVFormatContext *s1,
AVFormatParameters *ap)
{
VideoData *s = s1->priv_data;
AVStream *st;
- int width, height;
int frame_rate;
int frame_rate_base;
- if (ap->width <= 0 || ap->height <= 0 || ap->time_base.den <= 0)
+ if (ap->time_base.den <= 0)
return -1;
- width = ap->width;
- height = ap->height;
+ if (ap->width > 0)
+ s->width = ap->width;
+ if (ap->height > 0)
+ s->height = ap->height;
+ if (s->height <= 0 || s->width <= 0) {
+ av_log(s1, AV_LOG_ERROR, "Invalid width/height: %dx%d", s->width,
s->height);
+ return AVERROR(EINVAL);
+ }
+
frame_rate = ap->time_base.den;
frame_rate_base = ap->time_base.num;
@@ -263,8 +269,6 @@ static int grab_read_header(AVFormatContext *s1,
AVFormatParameters *ap)
return AVERROR(ENOMEM);
av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in use */
- s->width = width;
- s->height = height;
s->frame_rate = frame_rate;
s->frame_rate_base = frame_rate_base;
s->per_frame = ((uint64_t)1000000 * s->frame_rate_base) / s->frame_rate;
@@ -272,8 +276,8 @@ static int grab_read_header(AVFormatContext *s1,
AVFormatParameters *ap)
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->pix_fmt = PIX_FMT_YUV420P;
st->codec->codec_id = CODEC_ID_RAWVIDEO;
- st->codec->width = width;
- st->codec->height = height;
+ st->codec->width = s->width;
+ st->codec->height = s->height;
st->codec->time_base.den = frame_rate;
st->codec->time_base.num = frame_rate_base;
@@ -288,7 +292,7 @@ static int grab_read_header(AVFormatContext *s1,
AVFormatParameters *ap)
}
#endif
- if (bktr_init(s1->filename, width, height, s->standard,
+ if (bktr_init(s1->filename, s->width, s->height, s->standard,
&(s->video_fd), &(s->tuner_fd), -1, 0.0) < 0)
return AVERROR(EIO);
@@ -324,6 +328,8 @@ 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" },
+ { "width", "", offsetof(VideoData, width), FF_OPT_TYPE_INT, {.dbl =
640}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
+ { "height", "", offsetof(VideoData, height), FF_OPT_TYPE_INT, {.dbl =
480}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
{ NULL },
};
--
1.7.5.1
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel