hello
i am a newbie to the ipp. i want to use the IPP to encoder PCM to MP3.
Now we use the lame (lame.sourceforge.net) 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;
}
pOut->Alloc(context->mp3buflen);
pIn = new MediaData();
if (NULL == pOut) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory allocation error\n");
return SWITCH_STATUS_FALSE;
}
pIn->Alloc(nsamples);
memcpy((void *)pIn->GetBufferPointer(), (void *)audio, nsamples);
pIn->SetDataSize(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.