On Wed, Jun 22, 2016 at 9:58 PM, Bill Messenger <[email protected]> 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[0]) 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[0]): " + > std::to_string(sizeof(frame->data[0]))); > > std::memcpy(sampleBuffer + totalBufferSize, frame->data[0], 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? Cheers, Rob _______________________________________________ Libav-user mailing list [email protected] http://ffmpeg.org/mailman/listinfo/libav-user
