Skip to content

Commit a0bcc9d

Browse files
kleinesfilmroellchenADKaster
authored andcommitted
LibAudio: Skip empty MP3 scale factor bands in stereo intensity process
These were intentionally set up to be at the end of the granule size, but since the stereo intensity loop is intentionally using a <= end comparison (that’s how the scale factor bands work), we must skip these dummy bands which would otherwise cause an out-of-bounds index.
1 parent 24f5914 commit a0bcc9d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Userland/Libraries/LibAudio/MP3Loader.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,9 @@ void MP3LoaderPlugin::process_stereo(MP3::MP3Frame& frame, size_t granule_index)
724724

725725
auto process_intensity_stereo = [&](MP3::Tables::ScaleFactorBand const& band, float intensity_stereo_ratio) {
726726
for (size_t i = band.start; i <= band.end; i++) {
727+
// Superflous empty scale factor band.
728+
if (i >= MP3::granule_size)
729+
continue;
727730
float const sample_left = granule_left.samples[i];
728731
float const coeff_l = intensity_stereo_ratio / (1 + intensity_stereo_ratio);
729732
float const coeff_r = 1 / (1 + intensity_stereo_ratio);

0 commit comments

Comments
 (0)