Commit a646ac8e authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit '90cfc084'

* commit '90cfc084':
  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: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 53c2f401 90cfc084
......@@ -41,8 +41,6 @@ void av_destruct_packet(AVPacket *pkt)
av_free(pkt->data);
pkt->data = NULL;
pkt->size = 0;
ff_packet_free_side_data(pkt);
}
void av_init_packet(AVPacket *pkt)
......@@ -174,11 +172,16 @@ int av_copy_packet(AVPacket *dst, AVPacket *src)
void av_free_packet(AVPacket *pkt)
{
if (pkt) {
int i;
if (pkt->destruct)
pkt->destruct(pkt);
pkt->data = NULL;
pkt->size = 0;
pkt->side_data = NULL;
for (i = 0; i < pkt->side_data_elems; i++)
av_free(pkt->side_data[i].data);
av_freep(&pkt->side_data);
pkt->side_data_elems = 0;
}
}
......
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment