Commit 26245187 authored by Mark Harris's avatar Mark Harris Committed by 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: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 5e0c7eab
...@@ -130,16 +130,13 @@ static int opus_packet(AVFormatContext *avf, int idx) ...@@ -130,16 +130,13 @@ static int opus_packet(AVFormatContext *avf, int idx)
duration += d; duration += d;
last_pkt = next_pkt = next_pkt + os->psize; last_pkt = next_pkt = next_pkt + os->psize;
for (; seg < os->nsegs; seg++) { for (; seg < os->nsegs; seg++) {
if (os->segments[seg] < 255) { next_pkt += os->segments[seg];
int d = opus_duration(last_pkt, os->segments[seg]); if (os->segments[seg] < 255 && next_pkt != last_pkt) {
if (d < 0) { int d = opus_duration(last_pkt, next_pkt - last_pkt);
duration = os->granule; if (d > 0)
break;
}
duration += d; duration += d;
last_pkt = next_pkt + os->segments[seg]; last_pkt = next_pkt;
} }
next_pkt += os->segments[seg];
} }
os->lastpts = os->lastpts =
os->lastdts = os->granule - duration; os->lastdts = os->granule - duration;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment