Hi all,
I using dm365_aaclcdec_6_1_00 production codecs and the demo "audio.c(dec)" in the folder "dvsdk_2_10_01_18_demos_update" to decode the AAC file, but i cannot decode successfully without /with ADTS headers. The aac file is single channel with 16000 samplerate(using dm365_aaclcenc_3_5_00 to encode), here are my configurations:
AUDDEC1_Params defaultParams = Adec1_Params_DEFAULT;
AUDDEC1_DynamicParams defaultDynParams = Adec1_DynamicParams_DEFAULT;
const AUDDEC1_Params Adec1_Params_DEFAULT = {
sizeof(AUDDEC1_Params),
16,
IAUDIO_INTERLEAVED,
XDM_LE_16,
};
const AUDDEC1_DynamicParams Adec1_DynamicParams_DEFAULT = {
sizeof(AUDDEC1_DynamicParams),
XDAS_FALSE,
};
Sound_Attrs sAttrs = Sound_Attrs_STEREO_DEFAULT;
sAttrs.sampleRate = 16000;
sAttrs.channels = 1;
sAttrs.bufSize = 4096;
sAttrs.mode = Sound_Mode_OUTPUT;
sAttrs.soundStd = Sound_Std_ALSA;
And the Adec1.c file:
/******************************************************************************
* Adec1_create
******************************************************************************/
Adec1_Handle Adec1_create(Engine_Handle hEngine, Char *codecName,
AUDDEC1_Params *params,
AUDDEC1_DynamicParams *dynParams)
{
Adec1_Handle hAd1;
AUDDEC1_Handle hDecode;
AUDDEC1_Status decStatus;
XDAS_Int32 status;
if (hEngine == NULL || codecName == NULL ||
params == NULL || dynParams == NULL) {
Dmai_err0("Cannot pass null for engine, codec name, params or "
"dynamic params\n");
return NULL;
}
/* Allocate space for the object */
hAd1 = (Adec1_Handle)calloc(1, sizeof(Adec1_Object));
if (hAd1 == NULL) {
Dmai_err0("Failed to allocate space for Adec1 Object\n");
return NULL;
}
/* Create audio decoder */
hDecode = AUDDEC1_create(hEngine, codecName, params);
if (hDecode == NULL) {
Dmai_err1("Failed to open audio decode algorithm: %s\n", codecName);
cleanup(hAd1);
return NULL;
}
/* Set dynamic parameters */
decStatus.data.buf = NULL;
decStatus.size = sizeof(AUDDEC1_Status);
status = AUDDEC1_control(hDecode, XDM_SETPARAMS, dynParams, &decStatus);
if (status != AUDDEC1_EOK) {
Dmai_err1("XDM_SETPARAMS failed, status=%d\n", status);
cleanup(hAd1);
return NULL;
}
/* Get buffer information from audio decoder */
status = AUDDEC1_control(hDecode, XDM_GETBUFINFO, dynParams, &decStatus);
if (status != AUDDEC1_EOK) {
Dmai_err0("XDM_GETBUFINFO control failed\n");
cleanup(hAd1);
return NULL;
}
Dmai_dbg2("Codec requires buffer sizes in %u and out %u\n",
decStatus.bufInfo.minInBufSize[0],
decStatus.bufInfo.minOutBufSize[0]);
memcpy(hAd1->minInBufSize,
decStatus.bufInfo.minInBufSize, sizeof(hAd1->minInBufSize));
hAd1->minNumInBufs = decStatus.bufInfo.minNumInBufs;
memcpy(hAd1->minOutBufSize,
decStatus.bufInfo.minOutBufSize, sizeof(hAd1->minOutBufSize));
hAd1->minNumOutBufs = decStatus.bufInfo.minNumOutBufs;
hAd1->hDecode = hDecode;
hAd1->sampleRate = 0; // Do i need to change this to 16000?
return hAd1;
}
Int Adec1_process(Adec1_Handle hAd1, Buffer_Handle hInBuf, Buffer_Handle hOutBuf)
{
XDM1_BufDesc inBufDesc;
XDM1_BufDesc outBufDesc;
XDAS_Int32 status;
AUDDEC1_InArgs inArgs;
AUDDEC1_OutArgs outArgs;
Int channels;
assert(hAd1);
assert(hInBuf);
assert(hOutBuf);
assert(Buffer_getUserPtr(hInBuf));
assert(Buffer_getUserPtr(hOutBuf));
assert(Buffer_getNumBytesUsed(hInBuf));
assert(Buffer_getSize(hOutBuf));
inBufDesc.numBufs = 1;
inBufDesc.descs[0].buf = Buffer_getUserPtr(hInBuf);
inBufDesc.descs[0].bufSize = Buffer_getNumBytesUsed(hInBuf);
outBufDesc.numBufs = 1;
outBufDesc.descs[0].buf = Buffer_getUserPtr(hOutBuf);
outBufDesc.descs[0].bufSize = Buffer_getSize(hOutBuf);
inArgs.size = sizeof(AUDDEC1_InArgs);
inArgs.numBytes = Buffer_getNumBytesUsed(hInBuf);
inArgs.desiredChannelMode = IAUDIO_1_0; // the default value is IAUDIO_2_0, i modify it to IAUDIO_1_0, am i right?
inArgs.lfeFlag = XDAS_FALSE;
outArgs.size = sizeof(AUDDEC1_OutArgs);
/* Decode the audio buffer */
status = AUDDEC1_process(hAd1->hDecode, &inBufDesc, &outBufDesc, &inArgs,
&outArgs);
Dmai_dbg3("AUDDEC1_process() ret %d, consumed %d, created %d samples\n",
(Int) status, (Int) outArgs.bytesConsumed,
(Int) outArgs.numSamples);
if (status != AUDDEC1_EOK) {
if (XDM_ISFATALERROR(outArgs.extendedError)) {
Dmai_err2("AUDDEC1_process() failed with error (%d ext: 0x%x)\n",
(Int)status, (Uns) outArgs.extendedError);
return Dmai_EFAIL;
}
else {
Dmai_dbg1("AUDDEC1_process() non-fatal error 0x%x\n",
(Uns) outArgs.extendedError);
return Dmai_EBITERROR;
}
}
Buffer_setNumBytesUsed(hInBuf, outArgs.bytesConsumed);
channels = numChans[outArgs.channelMode];
Buffer_setNumBytesUsed(hOutBuf, outArgs.numSamples * 1 * channels); // // the default value is *2, i modify it to *1, am i right?
hAd1->sampleRate = outArgs.sampleRate;
return Dmai_EOK;
}
The Adec1_process call returns no errors, but the decoded sound is very noisy. Can you point out which parts are wrong?
Should i need to change the Adec1 configuration to ITTIAM_ENHAACPDEC_Params aacParams = ENHAACPDECODER_ITTIAM_PARAMS , if so, what are the exact parameters the ENHAACPDECODER_ITTIAM_PARAMS used? Can you provide me a demo using this?
I really need your help, any advices will be appreciated. Thanks.