Commit 8f28ec2
committed
Fix bug in decoding residuals
A partition order could occur, such that the block size was not a
multiple of 2^order. Computation of the number of samples per partition
did not account for this case, rounding down due to the bit shift. This
meant that we would not fill the entire decode buffer.
Claxon does not zero the decode buffer because it is (should be)
overwritten anyway, and in the case of a format error, where the buffer
might be only partially full, the buffer is not exposed again.
Furthermore, the way decoding works in most places, is that we fill the
entire buffer, just by looping to fill it. If the input bitstream does
not contain enough data to fill the buffer, then that's a format error.
In a few places though, we need to slice up the buffer before decoding
into it: for decoding individual channels, and also for decoding
residuals, which are split into partitions.
This particular format error was especially nasty because it did not
cause a format error down the line. Instead, it caused the buffer to be
sliced in a way where the slices together did not cover the entire
buffer, and so parts of uninitialized memory could remain in the buffer.
Thanks a lot to Sergey "Shnatsel" Davidoff for reporting this bug,
together with elaborate steps to reproduce that allowed me to pinpoint
the cause quickly.1 parent cd82be3 commit 8f28ec2
1 file changed
+19
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
254 | 254 | | |
255 | 255 | | |
256 | 256 | | |
257 | | - | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
258 | 271 | | |
259 | 272 | | |
260 | 273 | | |
261 | 274 | | |
262 | | - | |
| 275 | + | |
263 | 276 | | |
264 | 277 | | |
265 | 278 | | |
266 | 279 | | |
267 | 280 | | |
268 | 281 | | |
269 | 282 | | |
270 | | - | |
| 283 | + | |
271 | 284 | | |
272 | 285 | | |
273 | 286 | | |
274 | 287 | | |
275 | | - | |
| 288 | + | |
276 | 289 | | |
277 | 290 | | |
278 | 291 | | |
279 | 292 | | |
280 | | - | |
| 293 | + | |
281 | 294 | | |
282 | 295 | | |
283 | 296 | | |
284 | 297 | | |
285 | | - | |
| 298 | + | |
286 | 299 | | |
287 | 300 | | |
288 | 301 | | |
| |||
0 commit comments