Update: I found out that it only crashes in debug mode. When I build it in release mode, it doesn't crash. It must be a bug in MSVC 2015 or something.
On Fri, Jun 17, 2016 at 4:06 PM, Bill Messenger <[email protected]> wrote: > I'm trying to create a class that uses FFmpeg to decode any audio file and > store it into memory. Then it has a function that returns a float value of > any sample in that buffer. The code I wrote works perfectly for wav and > flac files, produces weird audio for mp3 and ogg files, and crashes on > certain mp3 files. I spent days trying to figure out why it isn't working, > but I can't come up with anything. > > I think the reason why the audio is weird for mp3 and ogg files is that it > uses planar audio instead of interleaved audio, but I don't see what's > wrong with the code I wrote. I may be missing something though. For > example, to get a sample for 16 bit interleaved audio I use: > > int16_t tmp = ((int16_t*)sampleBuffer)[numChannels*sample + channel]; > rv = (float)tmp / 32767.0f; > > and to get a sample for 16 bit planar audio I use: > > int16_t tmp = ((int16_t*)sampleBuffer)[sample + numSamples*channel]; > rv = (float)tmp / 32767.0f; > > And I have no clue why it crashes on certain mp3 files. I paid close > attention to make sure there is enough memory allocated in the buffer. > What's even weirder is that the file I created "Chiptune 15 2.mp3" didn't > crash, but when I renamed it to "test.mp3", it crashed! These crashes > happen on line 139 of "AudioDecoder.cpp": > > std::memcpy(sampleBuffer + totalBufferSize, frame->extended_data[0], > dataSize); > > with an "Access violation reading location" error in vcruntime140d.dll. It > says it isn't with location 0x0000000000000000 or 0xFFFFFFFFFFFFFFFF > though, it's a different random location. > > I attached a zip file with the c++ code and two mp3's. Oh yeah, I should > also mention that I'm using MSVC 2015 Community in Windows 10. >
_______________________________________________ Libav-user mailing list [email protected] http://ffmpeg.org/mailman/listinfo/libav-user
