From 9a0c598cf129b58c808ece0acbb8a50ca2be6739 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Mon, 7 Mar 2022 23:59:14 -0800 Subject: [PATCH] MAD Decoder: Correct length of iTunes MP3 files The total frames count in the iTunSMPB header is the encoded length, so add the start and end padding to it for the decoder implementation, which expects this variable to contain the total decodable length including the start and end padding. Fixes gapless decoding of iTunes files. Signed-off-by: Christopher Snowhill --- Plugins/MAD/MADDecoder.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Plugins/MAD/MADDecoder.m b/Plugins/MAD/MADDecoder.m index 3142d32c7..ac5199cd9 100644 --- a/Plugins/MAD/MADDecoder.m +++ b/Plugins/MAD/MADDecoder.m @@ -163,7 +163,8 @@ if(end_pad >= 528 + 1) { _startPadding = start_pad + 528 + 1; _endPadding = end_pad - (528 + 1); - totalFrames = temp_duration; + // iTunes encodes the original length of the file here + totalFrames = temp_duration + _startPadding + _endPadding; _foundiTunSMPB = YES; } }