aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-02-03 21:55:28 +0100
committerMax Kellermann <max@duempel.org>2009-02-03 22:51:41 +0100
commitf3b73b824f849f7c1280a59ddb67f5c3d187a5af (patch)
treebb905d0fc2414936c4c61d2118f9d69815023ef4
parent81b6c0d77bc377a26906fe66fb11f51a6247be0a (diff)
downloadmpd-f3b73b824f849f7c1280a59ddb67f5c3d187a5af.tar.gz
mpd-f3b73b824f849f7c1280a59ddb67f5c3d187a5af.tar.xz
mpd-f3b73b824f849f7c1280a59ddb67f5c3d187a5af.zip
ffmpeg: check if the time stamp is valid
When ffmpeg cannot estimate the elapsed time, it sets AVPacket.pts=AV_NOPTS_VALUE. Our ffmpeg decoder plugin did not check for that special value.
-rw-r--r--NEWS1
-rw-r--r--src/decoder/ffmpeg_plugin.c9
2 files changed, 6 insertions, 4 deletions
diff --git a/NEWS b/NEWS
index d0d94f221..c3980302e 100644
--- a/NEWS
+++ b/NEWS
@@ -38,6 +38,7 @@ ver 0.14.2 (2009/??/??)
* decoders:
- ffmpeg: added support for the tags comment, genre, year
- ffmpeg: don't warn of empty packet output
+ - ffmpeg: check if the time stamp is valid
- wavpack: pass NULL if the .wvc file fails to open
- mikmod: call MikMod_Exit() only in the finish() method
* audio outputs:
diff --git a/src/decoder/ffmpeg_plugin.c b/src/decoder/ffmpeg_plugin.c
index 80cc00a5e..c48918067 100644
--- a/src/decoder/ffmpeg_plugin.c
+++ b/src/decoder/ffmpeg_plugin.c
@@ -230,10 +230,6 @@ ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is,
&audio_size,
packet_data, packet_size);
-
- position = av_rescale_q(packet->pts, *time_base,
- (AVRational){1, 1});
-
if (len < 0) {
/* if error, we skip the frame */
g_message("decoding failed\n");
@@ -246,6 +242,11 @@ ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is,
if (audio_size <= 0)
continue;
+ position = packet->pts != (int64_t)AV_NOPTS_VALUE
+ ? av_rescale_q(packet->pts, *time_base,
+ (AVRational){1, 1})
+ : 0;
+
cmd = decoder_data(decoder, is,
audio_buf, audio_size,
position,