Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

MP3Encoder and bits per sample.

mhand75
Beginner
332 Views

I am using the UMC MP3Encoder class. I am having trouble figuring out how to handle audio files with 8 bits per sample. When trying to encode these files, I get distorted audio (the MP3 audio that results from the encoding is about half the length that it should be and vocals sound like a chipmunk). This only happens when I am working with WAV files that have a bits per sample of 8. When I test files with 16 it works fine.

Is there something I am doing wrong with my initialization:

// Read wav file into buffer
AudioData inMediaBuffer;
WavFile::Info wavInfo;
.... Read in WAV file ....

// Setup encoder defaults
MP3EncoderParams MP3EncoderParams;
MP3EncoderParams.m_pData = &inMediaBuffer;

MP3EncoderParams.m_info_in.sample_frequency = wavInfo.sample_rate;
MP3EncoderParams.m_info_in.channels = wavInfo.channels_number;
MP3EncoderParams.m_info_in.channel_mask = wavInfo.channel_mask;
MP3EncoderParams.m_info_in.bitPerSample = wavInfo.resolution;

MP3EncoderParams.m_info_out.bitrate = 128000;
MP3EncoderParams.m_info_out.sample_frequency = wavInfo.sample_rate;
MP3EncoderParams.m_info_out.channels = wavInfo.channels_number;
MP3EncoderParams.m_info_out.channel_mask = wavInfo.channel_mask;
MP3EncoderParams.m_info_out.stream_type = UMC::MP1L3_AUDIO;
MP3EncoderParams.m_info_out.bitPerSample = wavInfo.resolution;

// Initialize encoder
MP3Encoder MP3Encoder;
MP3Encoder.Init(&MP3EncoderParams);



Thanks for your help.
0 Kudos
3 Replies
Vladimir_Dudnik
Employee
332 Views
Hello, what version of IPP do you use?

Vladimir
0 Kudos
mhand75
Beginner
332 Views
Hello, what version of IPP do you use?

Vladimir

Hi Vladimir,

We are using 6.0, Update 2.


0 Kudos
Vladimir_Dudnik
Employee
332 Views

There is comment from our expert:


Input stream format for all UMC audio encoders is 16 bit PCM. To encode 8 bit per sample audio stream you should convert it to 16 bit audio stream. You should also take into account that 8 bit stream can have linear, mu-law or a-law format (information about actual format of your file you can find in the WAV file header)


Regards,
Vladimir
0 Kudos
Reply