Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash during encoding #25

Open
g3gg0 opened this issue Jan 17, 2020 · 7 comments
Open

Crash during encoding #25

g3gg0 opened this issue Jan 17, 2020 · 7 comments

Comments

@g3gg0
Copy link

g3gg0 commented Jan 17, 2020

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.

@lostromb
Copy link
Owner

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.

@JamDoggie
Copy link

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.

@lostromb
Copy link
Owner

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.

@JamDoggie
Copy link

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?

@lostromb
Copy link
Owner

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

@JamDoggie
Copy link

JamDoggie commented Aug 1, 2021

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants