[vlc-commits] [Git][videolan/vlc][master] packetizer: flac: fix STREAMINFO channel count parsing

Steve Lhomme (@robUx4) gitlab at videolan.org
Fri Aug 21 12:32:11 UTC 2026



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
6c4fb905 by Alaric Senat at 2026-08-21T12:20:45+00:00
packetizer: flac: fix STREAMINFO channel count parsing

RFC 9639 defines the streaminfo channel count as:

    | u(20) | Sample rate in Hz.                                      |
    | u(3)  | (number of channels)-1. FLAC supports from 1 to 8       |
    |       | channels.                                               |

https://www.rfc-editor.org/rfc/rfc9639.html#section-8.2

The channel count is held by bits 100 to 102, right after the 20 bits
sample rate. The previous bitwise was mixing the last channel bit with
the two high bits of the bits per sample field. A stereo 44.1 kHz 16
bits stream, whose byte 12 is 0x42, was parsed as 3 channels.

This bug was found while working on the Chromecast FMP4 flac support.

- - - - -


1 changed file:

- modules/packetizer/flac.h


Changes:

=====================================
modules/packetizer/flac.h
=====================================
@@ -58,7 +58,7 @@ static inline void FLAC_ParseStreamInfo( const uint8_t *p_buf,
     stream_info->max_framesize = GetDWBE( &p_buf[6] ) & 0x00FFFFFF;
 
     stream_info->sample_rate = GetDWBE( &p_buf[10] ) >> 12;
-    stream_info->channels = (p_buf[12] & 0x0F >> 1) + 1;
+    stream_info->channels = ((p_buf[12] >> 1) & 0x07) + 1;
     stream_info->bits_per_sample = (((p_buf[12] & 0x01) << 4) | p_buf[13] >> 4) + 1;
 
     stream_info->total_samples = GetQWBE(&p_buf[4+6]) & ((INT64_C(1)<<36)-1);



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/6c4fb905f0ea260110bf2bf36de45283ad8c0f93

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/6c4fb905f0ea260110bf2bf36de45283ad8c0f93
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help




More information about the vlc-commits mailing list