From: Kostya Shishkov Date: Thu, 2 Dec 2021 16:27:21 +0000 (+0100) Subject: mp3: small workaround for some slightly bad encodes X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=b93ed625205920c3e5d41c3f65a83a2709ca03fa;p=nihav.git mp3: small workaround for some slightly bad encodes --- diff --git a/nihav-mpeg/src/codecs/mpegaudio/mp3code.rs b/nihav-mpeg/src/codecs/mpegaudio/mp3code.rs index e43988c..c00696c 100644 --- a/nihav-mpeg/src/codecs/mpegaudio/mp3code.rs +++ b/nihav-mpeg/src/codecs/mpegaudio/mp3code.rs @@ -752,7 +752,7 @@ fn read_region_quad(br: &mut BitReader, br_end: usize, coeffs: &mut [f32], scale } for (i, (cquad, scquad)) in coeffs[start..SAMPLES/2].chunks_exact_mut(4).zip(scales[start..].chunks_exact(4)).enumerate() { zero_part = start + i * 4 + 4; - if br.tell() >= br_end { + if br.tell() >= br_end || (br.tell() + 3 >= br_end && cb.is_none()) { break; } let val = if let Some(cbook) = cb { br.read_cb(cbook)? } else { (br.read(4)? as u8) ^ 0xF };