[FFmpeg-devel] [PATCH 1/2] avcodec/adpcm_data: extend ff_adpcm_ima_cunning_index_table
Zane van Iperen
zane at zanevaniperen.com
Fri May 29 06:47:03 EEST 2020
On Thu, 28 May 2020 18:44:55 +0200
"Michael Niedermayer" <michael at niedermayer.cc> wrote:
> > The index table should only ever be indexed between [0,7], so this
> > looks like a bug in adpcm_ima_cunning_expand_nibble() instead.
>
> maybe it should be only 0..7 but abs(-8 .. 7) needs a 8th entrty or a
> check
>
>
> >
> > Where would one go to see the inputs for this? I'd like to
> > investigate (and test against the original decoder).
>
> The file is from a fuzzer so is random trash and it needs
> target_dec_fuzzer.c to be read. It wont be read as "Pro Pinball
> Series Soundbank" so i think that file will not be useful to test the
> behavior of the original decoder as i would assume it will not accept
> the target_dec_fuzzer data but i surely can send it to you privatly
> if you need it. just say if you want me to send you the file
>
No need, I've found an existing file that has the same problem. Out of
all the 453 files I have, only one of them triggers this.
tl;dr: Change the 5 to -1.
ff_adpcm_ima_cunning_index_table[abs(nibble)] is wrong in the case
where nibble == -8.
If you take the unsigned nibble, and apply f():
f(x) = 16 - x if x > 8 else x & 0x7
you'll get the same value as abs() applied with the signed nibble,
except for this one case (abs(-8) == 8, f(8) == 0).
Instead of changing the abs(), a cleaner fix is to simply change the 5
to -1. That should give the correct output.
Zane
More information about the ffmpeg-devel
mailing list