This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DM8168/C674X AAC Set run time dynamic parameters - RPE_Audio

Dear Experts,

My environment: DM8168/SDK Version: VCSDK(based on DVRRDK 2.8).

In my platform, I encoded alsa pcm audio data to aac by RPE method. ( linux alsa audio in -> rpe -> dsp aac encode)
I want to change encode bitrate when encoding audio by using Rpe_control & XDM_SETPARAMS.

But when I call Rpe_control, I will get failed msg.
 : Rpe control call XDM_SETPARAMS failed, status: 1

1) Is it possible to set dyncmic aac encoder parameter during aac encoding?
Plz teach me how to set dynamic aac encoder parameter during aac encoding ~

2) Do I need to call Rpe_acquireCallDescriptor?
In below code, if I call Rpe_acquireCallDescriptor,
I will get RPE_E_INVALIDARG(-1002) return value.
What's the root cause of this error?

Below is my function to set aac encoding run time parameter:
Int32 Audio_SetRuntimeAAC(Void * ctxMem,Int32 bitrate)
{
    Int32           status = -1;                 
    encContextDsp    *ctx;
    encContext     *handle;    
    IAUDENC1_Params *encParams;
    Rpe_CallDescHandle     controlCallDesc = NULL;

    IAUDENC1_DynamicParams      *encDynParams= NULL ;
    IAUDENC1_Status             *encStatus= NULL ;
    IAUDENC1_Cmd                *cmdId= NULL;
    
    OSA_printf("== %s %d == bitrate(%d)\n",__FUNCTION__,__LINE__,bitrate);
    
    handle = ctxMem;
    pthread_mutex_lock(&glock);    
    if(handle)
    {    
        ctx = GET_ENC_INT_STRUCT(handle);
        AUDIO_INFO_PRINT ("AUDIO: ENC Handle %X, Int Handle %X\n", (unsigned int) handle, (unsigned int)ctx);        
        AUDIO_INFO_PRINT("\n\nAUDIO: 111 -> bitrate(%d) , sampleRate(%d)\n\n",
                   ctx->encDynParams->bitRate, ctx->encDynParams->sampleRate);


#if 0 //--------------------------------
        status = Rpe_acquireCallDescriptor (ctx->encClientHandle,
                        RPE_CALL_DESC_PROCESS,  &controlCallDesc,
            &cmdId, &encDynParams, &encStatus);

        if (RPE_S_SUCCESS != status)
        {
            AUDIO_ERROR_PRINT ("AUDIO: ENC -> Rpe_acquireCallDescriptor failed, status: %d\n", status);
            Rpe_delete(ctx->encClientHandle);
            return NULL;
        }
#endif //--------------------------------


        encParams = &ctx->encParams;
        //encDynParams &ctx->encDynParams;

        AUDIO_INFO_PRINT("\nAUDIO: ENC -> bitrate %d inputBitsPerSample %d, sampleRate - %d...\n",
                    encParams->bitRate, encParams->inputBitsPerSample, encParams->sampleRate);

        AUDIO_INFO_PRINT("\nAUDIO: Dyna -> bitrate(%d) , sampleRate(%d)\n",
                   ctx->encDynParams->bitRate, ctx->encDynParams->sampleRate);

/*--------------------------------------------------------------------*/
/* Set AAC encoder run time parameters                                */
/*--------------------------------------------------------------------*/
        *(ctx->cmdId) = XDM_SETPARAMS;
        ctx->encDynParams->bitRate = bitrate;
        ctx->encDynParams->size = sizeof (IAUDENC1_DynamicParams);
        ctx->encStatus->size    = sizeof (IAUDENC1_Status);        

        status = Rpe_control (ctx->encControlCallDesc);

        if (RPE_S_SUCCESS != status)
        {
            AUDIO_ERROR_PRINT ("\n\n AUDIO: ENC -> Rpe control call XDM_SETPARAMS failed, status: %d\n\n", status);
            Rpe_delete(ctx->encClientHandle);
            return NULL;
        }
    }
    pthread_mutex_unlock(&glock);
    return status;
}

thx ~

HB

2 Replies

  • Hi HB,
    AAC Encoder on C674x support dynamically setting paramters like bitrate and RPE sequence looks fine.
    1)What is the new Bitrate being set? Can you check the new bitrate is supported for the input sampleRate. Refer Appendix A of the userGuide.
    2) Are you initializing remaining elements of dynamicParams strcutrue to proper values? From your above code, it looks like to me you are not initializing remaining elements of dynamicparams structure.
  • In reply to Ramprasad:

    Dear Ramprasad,
    Oh, thx a lot ~
    I find reason.
    I set 64kbps at 48K fs, I think this is the root cause of fail. (48k fs only support 80kbps)

    I will try to modify other parameters to see whether each parameter could be modified.

    Note:
    1) I did not call Rpe_acquireCallDescriptor.
    2) I already initialize other parameter when Audio_createAacEncAlgorithm.

    Below is my code that works:
    Int32 Audio_SetRuntimeAAC(Void * ctxMem,Int32 bitrate)
    {
    Int32 status = -1;
    encContextDsp *ctx;
    encContext *handle;
    IAUDENC1_Params *encParams;
    //IAUDENC1_DynamicParams *encDynParams ;
    //IAUDDEC1_Cmd *cmdId = NULL;
    //IAUDDEC1_DynamicParams *adecDynParams = NULL;
    //IAUDDEC1_Status *adecStatus = NULL;
    Rpe_CallDescHandle controlCallDesc = NULL;

    IAUDENC1_DynamicParams *encDynParams= NULL ;
    IAUDENC1_Status *encStatus= NULL ;
    IAUDENC1_Cmd *cmdId= NULL;


    OSA_printf("== %s %d == bitrate(%d)\n",__FUNCTION__,__LINE__,bitrate);

    handle = ctxMem;
    pthread_mutex_lock(&glock);
    if(handle)
    {
    ctx = GET_ENC_INT_STRUCT(handle);
    //AUDIO_INFO_PRINT ("AUDIO: ENC Handle %X, Int Handle %X\n", (unsigned int) handle, (unsigned int)ctx);
    //--------

    encParams = &ctx->encParams;
    //encDynParams &ctx->encDynParams;

    AUDIO_INFO_PRINT("AUDIO: old ENC -> bitrate %d inputBitsPerSample %d, sampleRate - %d...\n",
    encParams->bitRate, encParams->inputBitsPerSample, encParams->sampleRate);

    AUDIO_INFO_PRINT("AUDIO: old Dyna -> bitrate(%d) , sampleRate(%d)\n",
    ctx->encDynParams->bitRate, ctx->encDynParams->sampleRate);

    #if 0
    AUDIO_INFO_PRINT("\nAUDIO: aaa -> bitrate(%d) , sampleRate(%d)\n",
    encDynParams->bitRate, encDynParams->sampleRate);
    #endif
    /*--------------------------------------------------------------------*/
    /* Set AAC encoder run time parameters */
    /*--------------------------------------------------------------------*/
    #if 0
    *cmdId = XDM_GETBUFINFO;
    encDynParams->size = sizeof(IAUDDEC1_DynamicParams);
    encStatus->size = sizeof(IAUDDEC1_Status);
    #else
    *(ctx->cmdId) = XDM_SETPARAMS;
    //*cmdId = XDM_GETBUFINFO;
    *(ctx->cmdId) = XDM_SETPARAMS;
    ctx->encDynParams->bitRate = bitrate;
    encParams->bitRate=bitrate;
    ctx->encDynParams->size = sizeof (IAUDENC1_DynamicParams);
    ctx->encStatus->size = sizeof (IAUDENC1_Status);
    #endif
    status = Rpe_control (ctx->encControlCallDesc);
    if (RPE_S_SUCCESS != status)
    {
    AUDIO_ERROR_PRINT ("\n\n AUDIO: ENC -> Rpe control call XDM_SETPARAMS failed, status: %d\n\n", status);
    //Rpe_delete(ctx->encClientHandle);
    //return NULL;
    }
    AUDIO_INFO_PRINT("AUDIO: new ENC -> bitrate %d inputBitsPerSample %d, sampleRate - %d...\n",
    encParams->bitRate, encParams->inputBitsPerSample, encParams->sampleRate);

    AUDIO_INFO_PRINT("AUDIO: new Dyna -> bitrate(%d) , sampleRate(%d)\n",
    ctx->encDynParams->bitRate, ctx->encDynParams->sampleRate);
    //--------
    }
    pthread_mutex_unlock(&glock);
    return status;
    }

This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.