lostromb/concentus

Crash during encoding

Opened this issue · 7 comments

g3gg0 commented

During recoding some mp3 files i faced an assert in bitexact_cos because the tmp value was 58252.

Going back the whole story, i ended up in celt_rcp with optimized code that had an integer overflow for the value 1 for x while it was called by celt_atan2p(1,1)

The PCM data fed into the encoder was from the MP3's first few blocks and mostly zero with a few stray 1 here and there.

It's possible something slipped through when I did fuzz testing of the API. Funnily enough, I found a lot of these overflows during development that were actual bugs in the original C opus library and ended up backporting a lot of fixes. This looks like it could be one of them; however, I can't do anything about it unless I have repro steps. At minimum I would need you to list the encode parameters used (bitrate, channels, frame size, force mode, VBR...) and a dump of the input samples that were given to the encoder.

Same issue here. My tmp value was 51200. My audio is encoding using shorts(16 bit), 48khz, VBR enabled (doesn't seem to make a difference, except I found with certain bitrates it didn't happen as much with VBR enabled), and with variable bitrates.

At 64kbps nothing happens. However I am using opus for VoIP so when there are 5 people or more I lower the bitrate to 32kbps and then slightly further down if there's more people until it hits a minimum of 24 kbps. 32 kbps seems to work fine but it seems to happen under 32 (like maybe 31 or 30 it doesn't like). 8 kbps does seem to work though, so it might just be certain bitrates.

Try sending the same audio through the C libopus to see if it's an issue there as well. Concentus is just a 1:1 port of the C code (albeit a bit outdated now) so the same bug should exist in both places. If so, report it on the libopus side.

May have to do this with a P/Invoke wrapper since I'm not very handy with C or C++. Any recommendations for wrappers I could plop the newest opus binaries into if need be?

There's one in the demo project you can reuse.

Ok so that example you led to me was perfect because I was funnily enough using the OpusCodec wrapper class from probably some other Concentus demo, which meant I could literally just plug and play that class into my codebase and have it work.

The results:
I cloned this repo to my pc and built it as a x64 DLL. This should be on the latest version of opus (1.3.1). I used this as my opus dll.

Using weird bitrates like 31, 30, etc. don't seem to have any issue at all with this wrapper. I also confirmed changing the bitrate at all was working by cranking it all the way down to 8 to get that sweet telephone quality goodness.

My guess is somewhere between the version concentus is built off of and the newest version this bug was fixed.