[Libav-user] I can't get audio decoding to work.
rdstevens at gmail.com
Thu Jun 23 23:34:18 CEST 2016
On Wed, Jun 22, 2016 at 9:58 PM, Bill Messenger <apothemmusic at gmail.com> wrote:
> I added some code to check if it was crashing because dataSize is negative.
> It's not. Also, I found out that dtSize in this instance is 4608, and no
> matter what I do, sizeof(frame->data) is always 8. Also, I tried
> sizeof(frame->data) which returned 64.
> int dtSize = av_samples_get_buffer_size(nullptr, codecCtx->channels,
> frame->nb_samples, codecCtx->sample_fmt, 1);
> wxGetApp().popUpErrorDialog("dtSize: " + std::to_string(dtSize));
> dataSize = dtSize;
> while(totalBufferSize + dataSize > estimatedBuffSize)
> estimatedBuffSize *= 1.1;
> sampleBuffer = (uint8_t*)std::realloc(sampleBuffer, estimatedBuffSize);
> wxGetApp().popUpErrorDialog("sizeof(frame->data): " +
> std::memcpy(sampleBuffer + totalBufferSize, frame->data, dataSize);
> totalBufferSize += dataSize;
> totalSamples += frame->nb_samples;
The sizeof function will not tell you the size of dynamically
allocated arrays. It will only tell you the sizes of things that are
known at compile time, like the size of a pointer, or a statically
defined array, as in the two examples you gave.
Did you try using _heapchk as I suggested?
More information about the Libav-user