From b93ed625205920c3e5d41c3f65a83a2709ca03fa Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Thu, 2 Dec 2021 17:27:21 +0100 Subject: [PATCH] mp3: small workaround for some slightly bad encodes --- nihav-mpeg/src/codecs/mpegaudio/mp3code.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 }; -- 2.39.5