I'm trying to use libav to read in audio PCM data. I've got it to read
in my .wav sample data correctly (the byte format is AV_SAMPLE_FMT_S16).
However, my .mp3 sample is getting a lot of strange spikes in the data.
The sample format for the .mp3 is AV_SAMPLE_FMT_FLTP and while most of
the samples appear to be correct, about 10% of them have very large
magnitudes. I'm wondering what's going wrong, and if this might have
something to do with the exponent of the floating point number being
translated incorrectly. It's not clear to me what the difference
between AV_SAMPLE_FMT_FLT and AV_SAMPLE_FMT_FLTP is.
This is a sample of the bit of my code that reads the data from the
frame. Am I reading it correctly?
int bufferSize = av_samples_get_buffer_size(NULL,
uint8_t *dataBuf = aFrame->data;
for (int i = 0; i < aFrame->nb_samples; i++)
for (int ch = 0; ch < numChannels; ch++)
float val = 0;
val = ((float*)dataBuf)[ch + i * numChannels];
if (val > 1 || val < -1)
qDebug("Sample out of range %f", val);
val = 0;
Libav-user mailing list
To unsubscribe, visit link above, or email
libav-user-requ...@ffmpeg.org with subject "unsubscribe".