[FFmpeg-devel] [PATCH] fix pcm_read_seek with negative timestamp

Kamry Abdallah kamryco
Sat Mar 14 13:59:38 CET 2009

--- On Sat, 3/14/09, Reimar D?ffinger <Reimar.Doeffinger at gmx.de> wrote:

From: Reimar D?ffinger <Reimar.Doeffinger at gmx.de>
Subject: [FFmpeg-devel] [PATCH] fix pcm_read_seek with negative timestamp
To: ffmpeg-devel at mplayerhq.hu
Date: Saturday, March 14, 2009, 4:04 AM

-----Inline Attachment Follows-----

currently pcm_read seek for negative timestamps either seeks somewhere
before data_offset (clearly broken) or fails (possibly broken).
This patch treats negative time stamps as 0, which would be
consistent with the behaviour of the generic index handling code.
I am not really sure which behaviour is right, but I am convinced that
1) we should never seek before data_offset and 2) behaviour of the
different seek functions should be consistent.
Attached is the diff of the seek regression test, except for the flac
part, the changes are a supersection of what the GENERIC_INDEX patch

diff --git a/libavformat/raw.c b/libavformat/raw.c
index 224c26f..ba73dca 100644
--- a/libavformat/raw.c
+++ b/libavformat/raw.c
@@ -232,6 +232,7 @@ int pcm_read_seek(AVFormatContext *s,
? ???if (block_align <= 0 || byte_rate <= 0)
? ? ? ???return -1;
+? ? if (timestamp < 0) timestamp = 0;
? ???/* compute the position by aligning it to block_align */
? ???pos = av_rescale_rnd(timestamp * byte_rate,

Reimar D?ffinger

-----Inline Attachment Follows-----

ffmpeg-devel mailing list
ffmpeg-devel at mplayerhq.hu


More information about the ffmpeg-devel mailing list