concentus icon indicating copy to clipboard operation
concentus copied to clipboard

Crash during encoding

Open g3gg0 opened this issue 5 years ago • 7 comments

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.

g3gg0 avatar Jan 17 '20 21:01 g3gg0

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.

lostromb avatar Jan 20 '20 00:01 lostromb

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.

JamDoggie avatar Jul 31 '21 01:07 JamDoggie

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.

lostromb avatar Jul 31 '21 05:07 lostromb

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?

JamDoggie avatar Jul 31 '21 08:07 JamDoggie

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

lostromb avatar Jul 31 '21 17:07 lostromb

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.

JamDoggie avatar Aug 01 '21 07:08 JamDoggie

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

JamDoggie avatar Aug 01 '21 07:08 JamDoggie