This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 968b36b308095dbd632c4948a1ec021f041a02cd Author: Romain Beauxis <[email protected]> AuthorDate: Sun Nov 22 08:23:22 2026 -0500 Commit: Romain Beauxis <[email protected]> CommitDate: Mon Nov 30 09:49:26 2026 -0600 avformat/ogg/demuxer/vorbis: factor out the page start timestamp Move the scan deriving the timestamp of the first packet of a page from its granule into a function, for use at the start of the stream. --- libavformat/ogg/demuxer/vorbis.c | 50 +++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/libavformat/ogg/demuxer/vorbis.c b/libavformat/ogg/demuxer/vorbis.c index fd5b26fbd3..2b4ccea305 100644 --- a/libavformat/ogg/demuxer/vorbis.c +++ b/libavformat/ogg/demuxer/vorbis.c @@ -347,6 +347,36 @@ static int vorbis_check_packet_order(AVFormatContext *s, return error ? AVERROR_INVALIDDATA : 0; } +/** + * Timestamp of the current packet, the first one of its page, from the page + * granule and the durations of the packets the page completes. + */ +static int64_t vorbis_page_start_pts(struct ogg_stream *os, + struct oggvorbis_private *priv) +{ + int page_duration = os->pduration, flags = 0; + uint8_t *last_pkt = os->buf + os->pstart + os->psize; + uint8_t *next_pkt = last_pkt; + + for (int seg = os->segp; seg < os->nsegs; seg++) { + next_pkt += os->segments[seg]; + if (os->segments[seg] < 255 && next_pkt != last_pkt) { + int pkt_flags = 0; + int d = av_vorbis_parse_frame_flags(priv->vp, last_pkt, 1, &pkt_flags); + if (d < 0) { + page_duration = os->granule; + break; + } + page_duration += d; + last_pkt = next_pkt; + } + } + /* Restore the parser state to the one following the current packet. */ + av_vorbis_parse_frame_flags(priv->vp, os->buf + os->pstart, 1, &flags); + + return os->granule - page_duration; +} + static int vorbis_packet(AVFormatContext *s, int idx) { struct ogg *ogg = s->priv_data; @@ -403,26 +433,8 @@ static int vorbis_packet(AVFormatContext *s, int idx) os->lastdts -= priv->ts_offset; } else if (os->page_start && os->lastpts == AV_NOPTS_VALUE && !(os->flags & OGG_FLAG_EOS) && (int64_t)os->granule >= 0) { - int seg, page_duration = os->pduration; - uint8_t *last_pkt = os->buf + os->pstart + os->psize; - uint8_t *next_pkt = last_pkt; - - for (seg = os->segp; seg < os->nsegs; seg++) { - next_pkt += os->segments[seg]; - if (os->segments[seg] < 255 && next_pkt != last_pkt) { - int pkt_flags = 0; - int d = av_vorbis_parse_frame_flags(priv->vp, last_pkt, 1, &pkt_flags); - if (d < 0) { - page_duration = os->granule; - break; - } - page_duration += d; - last_pkt = next_pkt; - } - } - av_vorbis_parse_frame_flags(priv->vp, os->buf + os->pstart, 1, &flags); os->lastpts = - os->lastdts = os->granule - page_duration; + os->lastdts = vorbis_page_start_pts(os, priv); } /* Broken files may have granule=0 on pages that contain audio data. -- To stop receiving notification emails like this one, please contact [email protected]. _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
