[FFmpeg-cvslog] avformat/oggparseopus: fix segmented timestamps
Mark Harris
git at videolan.org
Sat Jan 4 22:46:28 CET 2014
ffmpeg | branch: master | Mark Harris <mark.hsj at gmail.com> | Tue Dec 31 11:04:54 2013 -0800| [262451878bab87670fba06fa6c9d798a81d39646] | committer: Michael Niedermayer
avformat/oggparseopus: fix segmented timestamps
Fix timestamp calculation for code 3 Ogg Opus packets with less than
2 bytes in the last segment (e.g. packet length 255 or 256).
A sample that would seek incorrectly in ffplay can be created with:
ffmpeg -i in.wav -b:a 34k -vbr off -frame_duration 60 out.opus
and libopus 1.1
Also do not read past the end of the buffer when a packet has length 0.
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=262451878bab87670fba06fa6c9d798a81d39646
---
libavformat/oggparseopus.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/libavformat/oggparseopus.c b/libavformat/oggparseopus.c
index aafefbb..553ddb0 100644
--- a/libavformat/oggparseopus.c
+++ b/libavformat/oggparseopus.c
@@ -130,16 +130,13 @@ static int opus_packet(AVFormatContext *avf, int idx)
duration += d;
last_pkt = next_pkt = next_pkt + os->psize;
for (; seg < os->nsegs; seg++) {
- if (os->segments[seg] < 255) {
- int d = opus_duration(last_pkt, os->segments[seg]);
- if (d < 0) {
- duration = os->granule;
- break;
- }
- duration += d;
- last_pkt = next_pkt + os->segments[seg];
- }
next_pkt += os->segments[seg];
+ if (os->segments[seg] < 255 && next_pkt != last_pkt) {
+ int d = opus_duration(last_pkt, next_pkt - last_pkt);
+ if (d > 0)
+ duration += d;
+ last_pkt = next_pkt;
+ }
}
os->lastpts =
os->lastdts = os->granule - duration;
More information about the ffmpeg-cvslog
mailing list