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

MP3Decoder Question

Yuen_Wu
Beginner
701 Views

Hi, I have encoded a block ofWAV data with sample frequency 8000B,16 bits per sample, 1 channel,and successfully encode it to a file (can be played).

My aim is to record voice into a small blockand encode it to mp3 format and decode it directly and play, it still recording, called real-time recording, encoding and decoding. Since I have encoded successfully, the WAV data size before encoding is A and after decode the size will increse lots, says B. I have no idea what kind of data after decoding is. Anyone can help me? thanks.

*IPP 6.1.2 with libraries from sample code

0 Kudos
12 Replies
Ying_H_Intel
Employee
701 Views

Hello Yuen,

Do you have a wav data which sample frequency 16KHz, 16bit per sample, 1 channel? What is the result if try the 16KHz sample freqency?It looks because the decoder will decode your 8KHz bitstream as 16KHz by defaut, so the size will increase a lot (may bedouble)

Best Regards,
Ying

0 Kudos
Ivan_Ryzhachkin__Int
New Contributor I
701 Views

Hi,

It's simple. Probably you know that the typicalencode->decode scheme looks like the following:

format A, size N =>

encoder=>

intermediate compressed format, size N/(n1>1) =>

decoder=>

format A, size N.

(If encoder and decoder are compliant :) ).

It would be easier to help having moredetails abouttheschemeused.

Thanks,

Ivan (video/speech coding).

0 Kudos
Yuen_Wu
Beginner
701 Views

Thank Ying H. and Ivan Ryzhachkin.

Sample frequency 16KB seems works, but the encoded data is not unsettled, for me, I record a voice real-timewith 16KB into a block size is 4608 Bytes due to MP3Encoder told me the suggested input size is 1152. Hence, I had 4 frames of MP3, there's no problem.

When the decoding, I decoded the data just encodedback and predicted the size of decoded would be sameas original (4608 Bytes), but sometime there were 3 frames and remained some data because it is not enough for decoding anymore. It seems I need to keep these data in buffer and append new data next stageand decode it.

However, this aim is for real-time, howlong data isrecorded(encoded), and how long data might beplayed(decoded). Is it possible? Thanks again.

0 Kudos
woleakande
Beginner
701 Views

Hi there,

I have never encoded a wav file successfully but am still oncourse.

Pls advice whether some fourier transfrom equatios (whever one) can make a video or audio output similar in format to any well known format.

Thanks.

0 Kudos
Ying_H_Intel
Employee
701 Views

Hi Yuen,

When you feed the 4 frames block data to Encoder->GetFrame(), does each frame is encoded? (in orther words, how many time UMC_OK retuned by Encoder->GetFrame()?)

In general, theUMC Audio codecs is not supposed to be used in real time applications.

Best Regards,

Ying

0 Kudos
Ying_H_Intel
Employee
701 Views

Hello Woleakande,

Could you clarify what is the problem you run into? Attached is oneaudio codec sample in previous version. You may try to extract it to UMC application folder. then build it in MSVC 2005 and see if you can make it work. (please read the readme.htm, please run the application).

The UMC mp3 encoder ask a raw PCM file as input and output a mp3 file which can be recoginized by general player likewindows media player.

Best Regards,
Ying

0 Kudos
Yuen_Wu
Beginner
701 Views

Thanks Ying H. again,

The setting of my system is following: (Sorry about pasting code)

[cpp]	// define the parameters, default setup
	m_encoderParam.m_info_in.sample_frequency = 16000;	// Input PCM sample rate
	m_encoderParam.m_info_in.channels = 1; // Input PCM amount of channel
	m_encoderParam.m_info_in.channel_mask = 0;

	m_encoderParam.m_info_out.bitrate = 24000; // Fixes bitrate of output

	m_encoderParam.layer = 3;	
	m_encoderParam.force_mpeg1 = 0;
	m_encoderParam.stereo_mode = UMC_MPA_LR_STEREO;
	m_encoderParam.mode = 0;
	m_encoderParam.ns_mode = 0;
	m_encoderParam.mc_matrix_procedure = 0;
	m_encoderParam.mc_lfe_filter_off = 0;[/cpp]

I feed the 4 frames block data (this block is 4608 bytesbecauseMP3Encoder told me the suggestedinput size is 1152, that I choose 4 times of it)to encoder, and I got 4 times of UMC_OK. And the sequence of output data(encoded data)size is 15, 157, 127, 107, and the next time I feed 4 frames again and got 4 times UMC_OK as the same with the encoded data sizes 101, 106, 107, 106. I'm surely the encode moduleworks successfully due to the fact that every time I encode 4 frames block data and I got 4 times UMC_OK. But a little strange why the size of the first frameis reallysmaller than others, I cannot figure out.

However, the manual said that decoder might initialize with

[cpp]m_mp3decoder->Init(NULL)[/cpp]

but if I initialize with that, I will got uninitialize error code from MP3Decoder->Getframe(). Therefore I initialized it with m_mp3decoder->Init(&param) where param is a MP3EncoderParams with same setting of MP3Encoder I used.

I traced the Decoder->Getframe(), I often got 3 decoded frames with size 1152*3, and there remains some data in input buffer because decoder said there is not enough input data to decode.

I uploaded some files, the .mp3 file is encoded by MP3Encoder, and .wav is reconstructed by MP3Decoder, you can figure out the .wav seems like miss a frame every 4 frames, hence it sounds intermittently.

0 Kudos
Yuen_Wu
Beginner
701 Views
After all, I solved the problem.The solution is do not clear remained data ininput bufferof decoder, although the first time it will missthe lastframe, the next time and following will decode 4 (or more but limit it with 4)frames surely. However, the first time decode, it will lost the last frame but not influence the following. That this module works for real time system indeed :-)
0 Kudos
woleakande
Beginner
701 Views

Hi Ying H ,

I thank you for the link but do you know I was not able to download it.

The download was never complete and did not bring any usefl info.

Pls give me insight into the right syntaxes to use under win32 so that i can do the home work and get back to you.

Thanks.

0 Kudos
woleakande
Beginner
701 Views

Hi Ying H,

I was able to download the sound.wav and sound.mp3 attached files of Yuen Wu.

I think the reason for not been able to download yours is bcos I don't have an IPP tools.

I will try and write my own code even though it will be win32 and get back to you soon.

Thanks.

0 Kudos
woleakande
Beginner
701 Views
Thanks so much for your email,I hope to get an intel compiler soonest.
0 Kudos
Ying_H_Intel
Employee
701 Views

Hello Wole,

You may get a evaluation Intel Compiler by click "Evaluate" on the webpage http://software.intel.com/en-us/intel-compilers/

One more comments,

You can build these applications by Microsoft* Visual Studio 2005 or 2008/2010. Intel Compilercan help on performane but it is not necessarywhen building IPP sample.

Best Regards,

Ying

0 Kudos
Reply