FS#10111 - Pops and clicks when playing 24 bit FLAC files

Attached to Project: Rockbox
Opened by Boris Gjenero (dreamlayers) - Thursday, 09 April 2009, 04:41 GMT
Last edited by Boris Gjenero (dreamlayers) - Friday, 10 April 2009, 02:16 GMT
Task Type Bugs
Category Codecs
Status Closed
Assigned To No-one
Operating System SW-codec
Severity Low
Priority Normal
Reported Version Daily build (which?)
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


When playing 24 bit FLAC files I can hear some pops. For example, a 27 second 44100 Hz 24 bit FLAC file encoded by flac-1.2.1 has about 5 pops of varying intensity. They are always at the same positions. There are no pops when Winamp plays the same FLAC file or when Rockbox plays a 44100 Hz 24 bit WAV version of the same sound.

This is on my 5G 30GB iPod running r20636. The problem was first reported on 24/96 FLAC file on an iRiver iHP -120 by Kitlope at:
This task depends upon

Closed by  Boris Gjenero (dreamlayers)
Friday, 10 April 2009, 02:16 GMT
Reason for closing:  Fixed
Additional comments about closing:  Fixed in r20671
Comment by Boris Gjenero (dreamlayers) - Thursday, 09 April 2009, 06:17 GMT
The Rockbox FLAC decoder comes from ffmpeg. Here is a thread about this issue in ffmpeg:
According to that post the problem is due to improper decoding of RICE2 entropy coding.
Comment by Boris Gjenero (dreamlayers) - Thursday, 09 April 2009, 18:01 GMT
This was fixed in ffmpeg r15334 by michael:
Then the fix was fixed in ffmpeg r15338 by michael:
Finally, another fix was applied to that line in ffmpeg r17550 by mru:
The last fix is irrelevant because MIN_CACHE_BITS is 25 and Rockbox doesn't have A32_BITSTREAM_READER. I still think including the last fix is a good thing, in case the ARM-optimized A32_BITSTREAM_READER is added in the future. Here is a patch with the final form of the fix. This code is also used in the Shorten (SHN) codec.

Unfortunately, I haven't taken the time to understand this code. All I can say is that it makes the pops go away and it is the only change in get_ur_golomb_jpegls() in ffmpeg-0.5.