summaryrefslogtreecommitdiffstats
path: root/libmpdemux
diff options
context:
space:
mode:
authorwm4 <wm4@mplayer2.org>2012-04-28 00:39:19 +0200
committerwm4 <wm4@mplayer2.org>2012-04-28 00:54:26 +0200
commit87f4cafe9c0881743d1117c2e8cd7e3376e33302 (patch)
treef41caa5aad8969d769a777c0a7912751721a66bd /libmpdemux
parent1324eaece08d84fbe3eb539642dba99b74dd1c07 (diff)
parentb711624ef350d1e971f5fcc57eb4af9f74233d2a (diff)
downloadmpv-87f4cafe9c0881743d1117c2e8cd7e3376e33302.tar.bz2
mpv-87f4cafe9c0881743d1117c2e8cd7e3376e33302.tar.xz
Merge remote-tracking branch 'origin/master'
Conflicts: command.c libao2/ao_alsa.c libao2/ao_dsound.c libao2/ao_pulse.c libao2/audio_out.h mixer.c mixer.h mplayer.c Replace my mixer changes with uau's implementation, which is based on my code.
Diffstat (limited to 'libmpdemux')
-rw-r--r--libmpdemux/demux_lavf.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/libmpdemux/demux_lavf.c b/libmpdemux/demux_lavf.c
index f8311e215c..62cb0bad1b 100644
--- a/libmpdemux/demux_lavf.c
+++ b/libmpdemux/demux_lavf.c
@@ -417,8 +417,22 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i)
sh_video->video.dwRate = codec->time_base.den;
sh_video->video.dwScale = codec->time_base.num;
}
- sh_video->fps = av_q2d(st->r_frame_rate);
- sh_video->frametime = 1 / av_q2d(st->r_frame_rate);
+ /* Try to make up some frame rate value, even if it's not reliable.
+ * FPS information is needed to support subtitle formats which base
+ * timing on frame numbers.
+ * Libavformat seems to report no "reliable" FPS value for AVI files,
+ * while they are typically constant enough FPS that the value this
+ * heuristic makes up works with subtitles in practice.
+ */
+ double fps;
+ if (st->r_frame_rate.num)
+ fps = av_q2d(st->r_frame_rate);
+ else
+ fps = 1.0 / FFMAX(av_q2d(st->time_base),
+ av_q2d(st->codec->time_base) *
+ st->codec->ticks_per_frame);
+ sh_video->fps = fps;
+ sh_video->frametime = 1 / fps;
sh_video->format = bih->biCompression;
if (st->sample_aspect_ratio.num)
sh_video->aspect = codec->width * st->sample_aspect_ratio.num