aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven O'Brien <steven_obrien1@yahoo.co.uk>2013-12-20 20:45:07 +0000
committerMax Kellermann <max@duempel.org>2013-12-20 22:28:33 +0100
commit6b3b8c6f2e436c110d9cf895130c9bce54aa307c (patch)
tree295f43a10ed9ff9fb5b9ce814267762ed7fbcf55
parenta191db84f2acfc2d6e40fb00dff15888e507faa6 (diff)
downloadmpd-6b3b8c6f2e436c110d9cf895130c9bce54aa307c.tar.gz
mpd-6b3b8c6f2e436c110d9cf895130c9bce54aa307c.tar.xz
mpd-6b3b8c6f2e436c110d9cf895130c9bce54aa307c.zip
fix FfmpegDecoderPlugin to use relative timestamps
-rw-r--r--NEWS2
-rw-r--r--src/decoder/FfmpegDecoderPlugin.cxx10
2 files changed, 8 insertions, 4 deletions
diff --git a/NEWS b/NEWS
index 572e71234..347ad8f5a 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,8 @@ ver 0.18.6 (not yet released)
- cdio_paranoia: support libcdio-paranoia 0.90
* tags
- riff: recognize upper-case "ID3" chunk name
+* decoder
+ - ffmpeg: use relative timestamps
* output
- openal: fix build failure on Mac OS X
- osx: fix build failure
diff --git a/src/decoder/FfmpegDecoderPlugin.cxx b/src/decoder/FfmpegDecoderPlugin.cxx
index 6add90045..47e1a3384 100644
--- a/src/decoder/FfmpegDecoderPlugin.cxx
+++ b/src/decoder/FfmpegDecoderPlugin.cxx
@@ -251,13 +251,14 @@ static DecoderCommand
ffmpeg_send_packet(Decoder &decoder, InputStream &is,
const AVPacket *packet,
AVCodecContext *codec_context,
- const AVRational *time_base,
+ const AVStream *stream,
AVFrame *frame,
uint8_t **buffer, int *buffer_size)
{
if (packet->pts >= 0 && packet->pts != (int64_t)AV_NOPTS_VALUE)
decoder_timestamp(decoder,
- time_from_ffmpeg(packet->pts, *time_base));
+ time_from_ffmpeg(packet->pts - stream->start_time,
+ stream->time_base));
AVPacket packet2 = *packet;
@@ -470,7 +471,7 @@ ffmpeg_decode(Decoder &decoder, InputStream &input)
if (packet.stream_index == audio_stream)
cmd = ffmpeg_send_packet(decoder, input,
&packet, codec_context,
- &av_stream->time_base,
+ av_stream,
frame,
&interleaved_buffer, &interleaved_buffer_size);
else
@@ -481,7 +482,8 @@ ffmpeg_decode(Decoder &decoder, InputStream &input)
if (cmd == DecoderCommand::SEEK) {
int64_t where =
time_to_ffmpeg(decoder_seek_where(decoder),
- av_stream->time_base);
+ av_stream->time_base) +
+ av_stream->start_time;
if (av_seek_frame(format_context, audio_stream, where,
AV_TIME_BASE) < 0)