xiph / flac

Free Lossless Audio Codec
https://xiph.org/flac/
GNU Free Documentation License v1.3
1.58k stars 278 forks source link

Error in latest pull request #705

Closed Quake4 closed 1 month ago

Quake4 commented 1 month ago

Wrong start max value by bits count (max_abs_sample_value). Must be: (1 << bps) - 1

https://github.com/xiph/flac/commit/cfe3afca9b3f27f0877203570705e072f0981b2e

ktmf01 commented 1 month ago

The code should calculate the largest possible absolute value there, not the largest possible value. For example, for a signed 16-bit int, the largest possible absolute value is 32768, which is 1 << 15. Indeed, if I wanted to calculate the maximum possible value for an unsigned int, it would have been (1 << 16) - 1, but that is not the case here.

So, I don't think the code is wrong.