From f1d7ae3bbf4ba295f3a69812c7f19f58f24b1503 Mon Sep 17 00:00:00 2001 From: Michael Giacomelli Date: Tue, 6 Oct 2026 01:11:45 -0400 Subject: [PATCH] atrac3: give the decoder its frame size for RM files Since 2e314093c8 the ATRAC3 decoder takes its frame size from id3->bytesperframe, which the RM metadata parser does not set. With a frame size of zero, a file in plain stereo mode had its second channel decoded from the first channel's data: both outputs were the left channel. Set it from the RM sub packet size before the decoder is opened. Checked with perfsim (Sansa e200v1 build) on six ATRAC3 .rm files: the two channels were identical sample for sample before, and each now follows its own channel of ffmpeg's decode. Co-Authored-By: Claude Opus 5.5 --- lib/rbcodec/codecs/atrac3_rm.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/rbcodec/codecs/atrac3_rm.c b/lib/rbcodec/codecs/atrac3_rm.c index 0ce961fd96..21be96587e 100644 --- a/lib/rbcodec/codecs/atrac3_rm.c +++ b/lib/rbcodec/codecs/atrac3_rm.c @@ -107,6 +107,10 @@ enum codec_status codec_run(void) scrambling_unit_size = h * (fs + packet_header_size); spn = h * fs / sps; + /* The decoder takes its frame size from the id3, which the RM + * metadata parser does not fill in. */ + ci->id3->bytesperframe = sps; + res = atrac3_decode_init(&q, ci->id3, rmctx.nb_channels, rmctx.extradata_size); if(res < 0) { DEBUGF("failed to initialize RM atrac decoder\n");