Commit 56bf24ad authored by Anton Khirnov's avatar Anton Khirnov

r3d: don't set codec timebase.

It's not supposed to be set by demuxers.

Set avg_frame_rate and r_frame_rate instead.
parent efec3bc6
......@@ -57,6 +57,7 @@ static int r3d_read_red1(AVFormatContext *s)
char filename[258];
int tmp;
int av_unused tmp2;
AVRational framerate;
if (!st)
return AVERROR(ENOMEM);
......@@ -84,8 +85,10 @@ static int r3d_read_red1(AVFormatContext *s)
tmp = avio_rb16(s->pb); // unknown
av_dlog(s, "unknown2 %d\n", tmp);
st->codec->time_base.den = avio_rb16(s->pb);
st->codec->time_base.num = avio_rb16(s->pb);
framerate.num = avio_rb16(s->pb);
framerate.den = avio_rb16(s->pb);
if (framerate.num && framerate.den)
st->r_frame_rate = st->avg_frame_rate = framerate;
tmp = avio_r8(s->pb); // audio channels
av_dlog(s, "audio channels %d\n", tmp);
......@@ -107,7 +110,7 @@ static int r3d_read_red1(AVFormatContext *s)
av_dlog(s, "resolution %dx%d\n", st->codec->width, st->codec->height);
av_dlog(s, "timescale %d\n", st->time_base.den);
av_dlog(s, "frame rate %d/%d\n",
st->codec->time_base.num, st->codec->time_base.den);
framerate.num, framerate.den);
return 0;
}
......@@ -132,9 +135,11 @@ static int r3d_read_rdvo(AVFormatContext *s, Atom *atom)
av_dlog(s, "video offset %d: %#x\n", i, r3d->video_offsets[i]);
}
if (st->codec->time_base.den)
st->duration = (uint64_t)r3d->video_offsets_count*
st->time_base.den*st->codec->time_base.num/st->codec->time_base.den;
if (st->r_frame_rate.num)
st->duration = av_rescale_q(r3d->video_offsets_count,
(AVRational){st->r_frame_rate.den,
st->r_frame_rate.num},
st->time_base);
av_dlog(s, "duration %"PRId64"\n", st->duration);
return 0;
......@@ -257,9 +262,9 @@ static int r3d_read_redv(AVFormatContext *s, AVPacket *pkt, Atom *atom)
pkt->stream_index = 0;
pkt->dts = dts;
if (st->codec->time_base.den)
if (st->r_frame_rate.num)
pkt->duration = (uint64_t)st->time_base.den*
st->codec->time_base.num/st->codec->time_base.den;
st->r_frame_rate.den/st->r_frame_rate.num;
av_dlog(s, "pkt dts %"PRId64" duration %d\n", pkt->dts, pkt->duration);
return 0;
......@@ -357,11 +362,11 @@ static int r3d_seek(AVFormatContext *s, int stream_index, int64_t sample_time, i
R3DContext *r3d = s->priv_data;
int frame_num;
if (!st->codec->time_base.num || !st->time_base.den)
if (!st->r_frame_rate.num)
return -1;
frame_num = sample_time*st->codec->time_base.den/
((int64_t)st->codec->time_base.num*st->time_base.den);
frame_num = av_rescale_q(sample_time, st->time_base,
(AVRational){st->r_frame_rate.den, st->r_frame_rate.num});
av_dlog(s, "seek frame num %d timestamp %"PRId64"\n",
frame_num, sample_time);
......
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