Need Some help with the mp3encoder

Need Some help with the mp3encoder


i am a newbie to the ipp.   i want to use the IPP to encoder PCM to MP3.

Now we use the lame ( to do this thing, encoder PCM to MP3.

we want to use the IPP 8.0  to instead of lame.  

PCM  DATA is   8000hz      2channels

so i am tring like this.

    audio_encoder_params = new MP3EncoderParams();

    audio_encoder_params->m_info.audioInfo.m_iChannelMask =  CHANNEL_FRONT_LEFT | CHANNEL_FRONT_RIGHT;
    audio_encoder_params->m_info.audioInfo.m_iSampleFrequency = samplerate;
    audio_encoder_params->m_info.audioInfo.m_iChannels = channels;
    audio_encoder_params->m_info.iBitrate = 128000;
    audio_encoder_params->stereo_mode = UMC_MPA_LR_STEREO;
    audio_encoder_params->ns_mode = 0;
    audio_encoder_params->layer = 3;
    audio_encoder_params->force_mpeg1 = 0;
    audio_encoder_params->mc_matrix_procedure = 0;
    audio_encoder_params->mc_lfe_filter_off = 0;
    audio_encoder_params->mode = UMC_MPAENC_CBR;
    audio_encoder_params->m_pData = NULL;

    pAudioEncoder = new MP3Encoder();
    if (pAudioEncoder == NULL) {
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't create audio codec object MP3!\n");
        return SWITCH_STATUS_FALSE;

    sts = pAudioEncoder->Init(audio_encoder_params);
    if (sts != UMC_OK) {
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "audioCodec Init failed: %d\n", sts);
        return SWITCH_STATUS_FALSE;
    sts = pAudioEncoder->GetInfo(audio_encoder_params);
    if (sts < 0) {
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "audioCodec GetInfo failed\n");
        return SWITCH_STATUS_FALSE;
    pOut = new MediaData();
    if (NULL == pOut) {
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory allocation error\n");
        return SWITCH_STATUS_FALSE;
    pIn = new MediaData();
    if (NULL == pOut) {
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory allocation error\n");
        return SWITCH_STATUS_FALSE;
    memcpy((void *)pIn->GetBufferPointer(), (void *)audio, nsamples);
    log_printf(CHANNEL_LOG, LOG_DEBUG, "Input Data, Size: %d \n", pIn->GetDataSize());
    sts = pAudioEncoder->GetFrame(pIn, pOut);
    if (sts == UMC_OK) {
        log_printf(CHANNEL_LOG, LOG_DEBUG, "GetFrame OK, Size: %d \n", pOut->GetDataSize());
    } else {
        log_printf(CHANNEL_LOG, LOG_ERROR, "GetFrame Error: %d\n", sts);
    rlen = pOut->GetDataSize();

    if (rlen) {
        int ret = fwrite(pOut->GetBufferPointer(), 1, rlen, fp);
        if (ret < 0) {
            return STATUS_FALSE;

the question is

the data i input size is 16384

the pOut->GetDataSize()  just is 321.

when i use cool edit to view the mp3 file.   it just silence.

pls help me.  thank you very much.

5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hi John,

Looks like the rest of output data stalled in the encoder. Try to do one more GetFrame (or several  GetFrame calls) with datasize in pIn set to zero until pOut.GetDataSize() shows 0.


To Sergey , Thank you very much.  i will do a test, then give you the result.

@Sergey , i have got a try tonight. Things become not so bad.

 .the file i save is almost noise. but a bit of the file is normal voice.  i add the wave by cooledit on attach.

by the way, whne i use the cooledit, i must chose the file type. 

i think that  i use the wrong param.   

More suggestions ?


Downloadimage/png tm-20130905094018.png169.35 KB

@sergey, i have sovled the prolble.   GetFrame and fwrite the pOut to file.

thank you very much.

god bless intel.

Leave a Comment

Please sign in to add a comment. Not a member? Join today