Commit 461ba669cd for ffmpeg
commit 461ba669cdf852f3a7c171ea41c4020f7150acf5
Author: Michael Niedermayer <michael@niedermayer.cc>
Date: Fri Nov 27 23:34:27 2026 +0000
avcodec/vorbis_parser: use zero mode bits when there is one mode
A one-mode setup codes no mode bits in its audio packets (Vorbis I 4.3.1).
The parser reserved one bit, so for a long-window mode it read the next
window flag as the previous one and got the packet duration wrong.
diff --git a/libavcodec/vorbis_parser.c b/libavcodec/vorbis_parser.c
index dfe9dbcfdb..0193a0fcfd 100644
--- a/libavcodec/vorbis_parser.c
+++ b/libavcodec/vorbis_parser.c
@@ -160,7 +160,7 @@ static int parse_setup_header(AVVorbisParseContext *s,
s->mode_count = mode_count = last_mode_count;
/* Determine the number of bits required to code the mode and turn that
* into a bitmask to directly access the mode from the first frame byte. */
- s->mode_mask = ((1 << (av_log2(mode_count - 1) + 1)) - 1) << 1;
+ s->mode_mask = ((1 << av_ceil_log2(mode_count)) - 1) << 1;
/* The previous window flag is the next bit after the mode */
s->prev_mask = (s->mode_mask | 0x1) + 1;