diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-01-14 14:16:21 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-01-14 14:16:21 +0100 |
commit | a646ac8ef5c51d6a47eb564d58d04564c0489871 (patch) | |
tree | 7a9365c0d598a40815932f254a16d38eb3a13646 /libavdevice | |
parent | 53c2f401f726732e56343377452e487c8c6a0ee1 (diff) | |
parent | 90cfc084e3e6d37ab88fc96a95f0401d8e8b4cd1 (diff) | |
download | ffmpeg-a646ac8ef5c51d6a47eb564d58d04564c0489871.tar.gz |
Merge commit '90cfc084e3e6d37ab88fc96a95f0401d8e8b4cd1'
* commit '90cfc084e3e6d37ab88fc96a95f0401d8e8b4cd1':
avpacket: free side data in av_free_packet().
v4l2: do not assert on a value received from outside of Libav
v4l2: set the average framerate instead of codec timebase.
Conflicts:
libavcodec/avpacket.c
libavdevice/v4l2.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavdevice')
-rw-r--r-- | libavdevice/v4l2.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c index 5e12575e00..c82a9084d0 100644 --- a/libavdevice/v4l2.c +++ b/libavdevice/v4l2.c @@ -498,8 +498,8 @@ static int init_convert_timestamp(AVFormatContext *ctx, int64_t ts) now = av_gettime_monotonic(); if (s->ts_mode == V4L_TS_MONO2ABS || (ts <= now + 1 * AV_TIME_BASE && ts >= now - 10 * AV_TIME_BASE)) { - int64_t period = av_rescale_q(1, ctx->streams[0]->codec->time_base, - AV_TIME_BASE_Q); + int64_t period = av_rescale_q(1, AV_TIME_BASE_Q, + ctx->streams[0]->avg_frame_rate); av_log(ctx, AV_LOG_INFO, "Detected monotonic timestamps, converting\n"); /* microseconds instead of seconds, MHz instead of Hz */ s->timefilter = ff_timefilter_new(1, period, 1.0E-6); @@ -554,7 +554,11 @@ static int mmap_read_frame(AVFormatContext *ctx, AVPacket *pkt) return AVERROR(errno); } - av_assert0(buf.index < s->buffers); + + if (buf.index >= s->buffers) { + av_log(ctx, AV_LOG_ERROR, "Invalid buffer index received.\n"); + return AVERROR(EINVAL); + } /* CPIA is a compressed format and we don't know the exact number of bytes * used by a frame, so set it here as the driver announces it. @@ -735,8 +739,8 @@ static int v4l2_set_parameters(AVFormatContext *s1) return AVERROR(errno); } } - s1->streams[0]->codec->time_base.den = tpf->denominator; - s1->streams[0]->codec->time_base.num = tpf->numerator; + s1->streams[0]->avg_frame_rate.num = tpf->denominator; + s1->streams[0]->avg_frame_rate.den = tpf->numerator; return 0; } @@ -878,7 +882,7 @@ static int v4l2_read_header(AVFormatContext *s1) st->codec->codec_tag = MKTAG('Y', 'V', '1', '2'); st->codec->width = s->width; st->codec->height = s->height; - st->codec->bit_rate = s->frame_size * 1/av_q2d(st->codec->time_base) * 8; + st->codec->bit_rate = s->frame_size * av_q2d(st->avg_frame_rate) * 8; return 0; } |