aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-10-15 16:24:43 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-10-15 18:19:58 +0200
commit2b37864e7f2bb78fd78904074f03449f70331e3d (patch)
treee69100e9ec952178637e8569796735921fe3388d /libavformat
parent18255441dd74e0bde4fbc8f2f6a1a356fc14df6e (diff)
parent2d6e58497e76836604364b037df9b00ba3d75b69 (diff)
downloadffmpeg-2b37864e7f2bb78fd78904074f03449f70331e3d.tar.gz
Merge commit '2d6e58497e76836604364b037df9b00ba3d75b69'
* commit '2d6e58497e76836604364b037df9b00ba3d75b69': lavf: switch to AVCodecContext.framerate for demuxing Conflicts: libavformat/utils.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/internal.h2
-rw-r--r--libavformat/mux.c2
-rw-r--r--libavformat/rawdec.c1
-rw-r--r--libavformat/utils.c18
4 files changed, 15 insertions, 8 deletions
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 30117069a9..f254e4c016 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -334,7 +334,7 @@ void ff_free_stream(AVFormatContext *s, AVStream *st);
/**
* Return the frame duration in seconds. Return 0 if not available.
*/
-void ff_compute_frame_duration(int *pnum, int *pden, AVStream *st,
+void ff_compute_frame_duration(AVFormatContext *s, int *pnum, int *pden, AVStream *st,
AVCodecParserContext *pc, AVPacket *pkt);
unsigned int ff_codec_get_tag(const AVCodecTag *tags, enum AVCodecID id);
diff --git a/libavformat/mux.c b/libavformat/mux.c
index 3c4853594c..f29d7319e6 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -455,7 +455,7 @@ static int compute_pkt_fields2(AVFormatContext *s, AVStream *st, AVPacket *pkt)
/* duration field */
if (pkt->duration == 0) {
- ff_compute_frame_duration(&num, &den, st, NULL, pkt);
+ ff_compute_frame_duration(s, &num, &den, st, NULL, pkt);
if (den && num) {
pkt->duration = av_rescale(1, num * (int64_t)st->time_base.den * st->codec->ticks_per_frame, den * (int64_t)st->time_base.num);
}
diff --git a/libavformat/rawdec.c b/libavformat/rawdec.c
index ca9b2829d6..69b95bc6e9 100644
--- a/libavformat/rawdec.c
+++ b/libavformat/rawdec.c
@@ -84,6 +84,7 @@ int ff_raw_video_read_header(AVFormatContext *s)
st->codec->codec_id = s->iformat->raw_codec_id;
st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
+ st->codec->framerate = s1->framerate;
st->codec->time_base = av_inv_q(s1->framerate);
avpriv_set_pts_info(st, 64, 1, 1200000);
diff --git a/libavformat/utils.c b/libavformat/utils.c
index b0554d3e14..20e1b21e4c 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -708,9 +708,11 @@ static int determinable_frame_size(AVCodecContext *avctx)
/**
* Return the frame duration in seconds. Return 0 if not available.
*/
-void ff_compute_frame_duration(int *pnum, int *pden, AVStream *st,
+void ff_compute_frame_duration(AVFormatContext *s, int *pnum, int *pden, AVStream *st,
AVCodecParserContext *pc, AVPacket *pkt)
{
+ AVRational codec_framerate = s->iformat ? st->codec->framerate :
+ av_inv_q(st->codec->time_base);
int frame_size;
*pnum = 0;
@@ -723,10 +725,14 @@ void ff_compute_frame_duration(int *pnum, int *pden, AVStream *st,
} else if (st->time_base.num * 1000LL > st->time_base.den) {
*pnum = st->time_base.num;
*pden = st->time_base.den;
- } else if (st->codec->time_base.num * 1000LL > st->codec->time_base.den) {
- *pnum = st->codec->time_base.num;
- *pden = st->codec->time_base.den;
+ } else if (codec_framerate.den * 1000LL > codec_framerate.num) {
+ *pnum = codec_framerate.den;
+ *pden = codec_framerate.num;
+
+ *pden *= st->codec->ticks_per_frame;
+ av_assert0(st->codec->ticks_per_frame);
if (pc && pc->repeat_pict) {
+ av_assert0(s->iformat); // this may be wrong for interlaced encoding but its not used for that case
if (*pnum > INT_MAX / (1 + pc->repeat_pict))
*pden /= 1 + pc->repeat_pict;
else
@@ -1015,7 +1021,7 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
duration = av_mul_q((AVRational) {pkt->duration, 1}, st->time_base);
if (pkt->duration == 0) {
- ff_compute_frame_duration(&num, &den, st, pc, pkt);
+ ff_compute_frame_duration(s, &num, &den, st, pc, pkt);
if (den && num) {
duration = (AVRational) {num, den};
pkt->duration = av_rescale_rnd(1,
@@ -2374,7 +2380,7 @@ static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset)
(st->start_time != AV_NOPTS_VALUE ||
st->first_dts != AV_NOPTS_VALUE)) {
if (pkt->duration == 0) {
- ff_compute_frame_duration(&num, &den, st, st->parser, pkt);
+ ff_compute_frame_duration(ic, &num, &den, st, st->parser, pkt);
if (den && num) {
pkt->duration = av_rescale_rnd(1,
num * (int64_t) st->time_base.den,