summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-07-11 19:13:44 +0200
committerwm4 <wm4@nowhere>2013-07-11 19:13:44 +0200
commit995fe05254449e71f3cb93f58e03e119685bdced (patch)
tree835cdb70cba2545282bef573b62d71f42dd5cec7
parent8a3615f2d8a902bc5aaf12550eb26f4d3f40c7ae (diff)
downloadmpv-995fe05254449e71f3cb93f58e03e119685bdced.tar.bz2
mpv-995fe05254449e71f3cb93f58e03e119685bdced.tar.xz
mplayer: remove "old" audio PTS calculation code
Removing this code doesn't change anything. All remaining audio decoders are well-behaved enough to not overwrite sh_audio->pts if they don't know the PTS. And if they don't know the PTS, the d_audio->last_pts field can't contain any usable value either, because both fields contain theame value: the last known valid PTS found in an audio packet.
-rw-r--r--core/mplayer.c36
1 files changed, 9 insertions, 27 deletions
diff --git a/core/mplayer.c b/core/mplayer.c
index 97bde0bc4d..87bef0e3c5 100644
--- a/core/mplayer.c
+++ b/core/mplayer.c
@@ -1668,36 +1668,18 @@ static double written_audio_pts(struct MPContext *mpctx)
sh_audio_t *sh_audio = mpctx->sh_audio;
if (!sh_audio)
return MP_NOPTS_VALUE;
- demux_stream_t *d_audio = mpctx->sh_audio->ds;
// first calculate the end pts of audio that has been output by decoder
double a_pts = sh_audio->pts;
- if (a_pts != MP_NOPTS_VALUE)
- // Good, decoder supports new way of calculating audio pts.
- // sh_audio->pts is the timestamp of the latest input packet with
- // known pts that the decoder has decoded. sh_audio->pts_bytes is
- // the amount of bytes the decoder has written after that timestamp.
- a_pts += sh_audio->pts_bytes / (double) sh_audio->o_bps;
- else {
- // Decoder doesn't support new way of calculating pts (or we're
- // being called before it has decoded anything with known timestamp).
- // Use the old method of audio pts calculation: take the timestamp
- // of last packet with known pts the decoder has read data from,
- // and add amount of bytes read after the beginning of that packet
- // divided by input bps. This will be inaccurate if the input/output
- // ratio is not constant for every audio packet or if it is constant
- // but not accurately known in sh_audio->i_bps.
-
- a_pts = d_audio->last_pts;
- if (a_pts == MP_NOPTS_VALUE)
- return a_pts;
-
- // ds_tell_pts returns bytes read after last timestamp from
- // demuxing layer
- if (sh_audio->i_bps)
- a_pts += d_audio->last_pts_bytes / (double)sh_audio->i_bps;
- }
+ if (a_pts == MP_NOPTS_VALUE)
+ return MP_NOPTS_VALUE;
+
+ // sh_audio->pts is the timestamp of the latest input packet with
+ // known pts that the decoder has decoded. sh_audio->pts_bytes is
+ // the amount of bytes the decoder has written after that timestamp.
+ a_pts += sh_audio->pts_bytes / (double) sh_audio->o_bps;
+
// Now a_pts hopefully holds the pts for end of audio from decoder.
- // Substract data in buffers between decoder and audio out.
+ // Subtract data in buffers between decoder and audio out.
// Decoded but not filtered
a_pts -= sh_audio->a_buffer_len / (double)sh_audio->o_bps;