Commit 9ef90cc2 authored by vaclav's avatar vaclav
Browse files

- ROM tables

- move of few functions
parent b4c67ae9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -752,7 +752,7 @@ ivas_error ivas_binRenderer_open(
        {
            for ( k = 0; k < hBinRenderer->nInChannels; k++ )
            {
                hBinRenderer->hReverb->dmxmtx[chIdx][k] = dmxmtx[chIdx][k];
                hBinRenderer->hReverb->dmxmtx[chIdx][k] = dmxmtx_table[chIdx][k];
            }
        }
    }
+0 −177
Original line number Diff line number Diff line
@@ -43,183 +43,6 @@
#include "wmc_auto.h"


/*-------------------------------------------------------------------*
 * Local constants
 *-------------------------------------------------------------------*/

#define RESAMPLE_FACTOR_16_48 ( 16.0f / 48.0f )
#define RESAMPLE_FACTOR_32_48 ( 32.0f / 48.0f )


/*-------------------------------------------------------------------*
 * BSplineModelEvalAlloc()
 *
 * Allocate the B Spline HR Filter model.
 --------------------------------------------------------------------*/

static void BSplineModelEvalAlloc(
    ModelParams_t *model,  /* i  : Model parameters           */
    ModelEval_t *modelEval /* i/o: Model evaluation structure */
)
{
    modelEval->hrfModL = (float *) malloc( model->K * sizeof( float ) );
    modelEval->hrfModR = (float *) malloc( model->K * sizeof( float ) );

    return;
}


/*-------------------------------------------------------------------*
 * DefaultBSplineModel()
 *
 * Init default HRTF model
 --------------------------------------------------------------------*/

void DefaultBSplineModel(
    TDREND_HRFILT_FiltSet_t *HrFiltSet_p, /* o  : Loaded HR filter set      */
    const int32_t output_Fs               /* i  : Output sampling rate      */
)
{
    ModelParams_t *model;
    ModelParamsITD_t *modelITD;
    int16_t i, j;

    HrFiltSet_p->FilterMethod = TDREND_HRFILT_Method_BSplineModel;
    model = &( HrFiltSet_p->ModelParams );
    modelITD = &( HrFiltSet_p->ModelParamsITD );

    /* Set ROM flag for correct deallocation */
    model->modelROM = TRUE;

    /* int16_t parameters */
    model->UseItdModel = 1;
    model->SplineDegree = 4;
    model->elevDim2 = 20;
    model->elevDim3 = 18;
    model->AlphaN = 578;
    model->num_unique_azim_splines = 1;
    model->elevSegSamples = 3;
    model->elevBsLen[0] = 4;
    model->elevBsLen[1] = 7;
    model->elevBsLen[2] = 10;
    model->elevBsLen[3] = 7;
    model->elevBsStart[0] = 0;
    model->elevBsStart[1] = 4;
    model->elevBsStart[2] = 11;
    model->elevBsStart[3] = 21;

    model->azimDim2 = orange53_rom_azimDim2;
    model->azimDim3 = orange53_rom_azimDim3;
    model->azim_start_idx = orange53_rom_azim_start_idx;
    model->azimSegSamples = orange53_rom_azimSegSamples;
    model->azimShapeIdx = orange53_rom_azimShapeIdx;
    model->azimShapeSampFactor = orange53_rom_azimShapeSampFactor;

    /* float parameters */
    model->elevKSeq = (const float *) orange53_rom_elevKSeq;
    model->elevBsShape = (const float *) orange53_rom_elevBsShape;

    model->azimBsShape = (const float **) malloc( model->num_unique_azim_splines * sizeof( float * ) );
    model->azimBsShape[0] = (const float *) orange53_rom_azimBsShape;
    model->azimKSeq = (float **) malloc( 18 * sizeof( float * ) );
    model->azimKSeq[0] = (float *) malloc( 2 * sizeof( float * ) );
    model->azimKSeq[17] = (float *) malloc( 2 * sizeof( float * ) );
    model->azimKSeq[0][0] = 0.0f;
    model->azimKSeq[17][0] = 0.0f;
    model->azimKSeq[0][1] = 360.0f;
    model->azimKSeq[17][1] = 360.0f;

    for ( i = 1; i < 17; i++ )
    {
        model->azimKSeq[i] = (float *) malloc( model->azimDim2[i] * sizeof( float * ) ); /* azimDim2[i] = 91, i=2..15 */
        for ( j = 0; j < model->azimDim2[i]; j++ )
        {
            model->azimKSeq[i][j] = (float) orange53_rom_azimSegSamples[0] * j;
        }
    }

    switch ( output_Fs )
    {
        case 48000:
            model->AlphaL = (const float *) orange53_rom_AlphaL48;
            model->AlphaR = (const float *) orange53_rom_AlphaR48;
            model->EL = (const float *) orange53_rom_EL48;
            model->ER = (const float *) orange53_rom_ER48;
            model->K = 128;
            if ( HrFiltSet_p->ModelParams.UseItdModel )
            {
                modelITD->resamp_factor = 1.0f;
            }
            break;
        case 32000:
            model->AlphaL = (const float *) orange53_rom_AlphaL32;
            model->AlphaR = (const float *) orange53_rom_AlphaR32;
            model->EL = (const float *) orange53_rom_EL32;
            model->ER = (const float *) orange53_rom_ER32;
            model->K = 86;
            if ( HrFiltSet_p->ModelParams.UseItdModel )
            {
                modelITD->resamp_factor = RESAMPLE_FACTOR_32_48;
            }
            break;
        case 16000:
            model->AlphaL = (const float *) orange53_rom_AlphaL16;
            model->AlphaR = (const float *) orange53_rom_AlphaR16;
            model->EL = (const float *) orange53_rom_EL16;
            model->ER = (const float *) orange53_rom_ER16;
            model->K = 43;
            if ( HrFiltSet_p->ModelParams.UseItdModel )
            {
                modelITD->resamp_factor = RESAMPLE_FACTOR_16_48;
            }
            break;
        default:
            break;
    }

    modelITD->N = 4;
    modelITD->elevDim2 = 20;
    modelITD->elevDim3 = 18;
    modelITD->azimDim2 = 41;
    modelITD->azimDim3 = 41;
    modelITD->elevSegSamples = 3;
    modelITD->elevBsLen[0] = 4;
    modelITD->elevBsLen[1] = 7;
    modelITD->elevBsLen[2] = 10;
    modelITD->elevBsLen[3] = 7;
    modelITD->elevBsStart[0] = 0;
    modelITD->elevBsStart[1] = 4;
    modelITD->elevBsStart[2] = 11;
    modelITD->elevBsStart[3] = 21;

    modelITD->elevKSeq = model->elevKSeq;

    modelITD->azimBsLen[0] = 11;
    modelITD->azimBsLen[1] = 21;
    modelITD->azimBsLen[2] = 31;
    modelITD->azimBsLen[3] = 21;
    modelITD->azimBsStart[0] = 0;
    modelITD->azimBsStart[1] = 11;
    modelITD->azimBsStart[2] = 32;
    modelITD->azimBsStart[3] = 63;

    modelITD->azimSegSamples = 10;

    modelITD->azimKSeq = orange53_rom_ITD_azimKSeq;
    modelITD->W = (const float *) orange53_rom_ITD_W;
    modelITD->azimBsShape = (const float *) orange53_rom_ITD_azimBsShape;
    modelITD->elevBsShape = (const float *) orange53_rom_ITD_elevBsShape;

    HRTF_model_precalc( model );

    HrFiltSet_p->SampleRate = output_Fs;
    HrFiltSet_p->FiltLength = HrFiltSet_p->ModelParams.K;
    BSplineModelEvalAlloc( &HrFiltSet_p->ModelParams, &HrFiltSet_p->ModelEval );

    return;
}


/*-----------------------------------------------------------------------*
 * ivas_HRTF_binary_open()
 *
+0 −5
Original line number Diff line number Diff line
@@ -168,11 +168,6 @@ ivas_error ivas_rend_TDObjRendOpen(
    const int32_t output_Fs 
);

void DefaultBSplineModel(
    TDREND_HRFILT_FiltSet_t *HrFiltSet_p,                       /* o  : Loaded HR filter set                    */
    const int32_t output_Fs                                     /* i  : Output sampling rate                    */
);

/* ----- Object renderer - hrfilt ----- */

void GetFilterFromAngle( 
+186 −0
Original line number Diff line number Diff line
@@ -35,12 +35,28 @@
#include "prot.h"
#include "ivas_prot.h"
#include "ivas_lib_rend_internal.h"
#include "ivas_rom_TdBinauralRenderer.h"
#include "wmc_auto.h"
#ifdef DEBUGGING
#include "debug.h"
#endif


/*-------------------------------------------------------------------*
 * Local constants
 *-------------------------------------------------------------------*/

#define RESAMPLE_FACTOR_16_48 ( 16.0f / 48.0f )
#define RESAMPLE_FACTOR_32_48 ( 32.0f / 48.0f )


/*-------------------------------------------------------------------------
 * Local functions
 *-------------------------------------------------------------------------*/

static void DefaultBSplineModel( TDREND_HRFILT_FiltSet_t *HrFiltSet_p, const int32_t output_Fs );


/*-------------------------------------------------------------------*
 * TDREND_MIX_LIST_SetPos()
 *
@@ -317,3 +333,173 @@ ivas_error TDREND_MIX_AddSrc(

    return error;
}


/*-------------------------------------------------------------------*
 * BSplineModelEvalAlloc()
 *
 * Allocate the B Spline HR Filter model.
 --------------------------------------------------------------------*/

static void BSplineModelEvalAlloc(
    ModelParams_t *model,  /* i  : Model parameters           */
    ModelEval_t *modelEval /* i/o: Model evaluation structure */
)
{
    modelEval->hrfModL = (float *) malloc( model->K * sizeof( float ) );
    modelEval->hrfModR = (float *) malloc( model->K * sizeof( float ) );

    return;
}


/*-------------------------------------------------------------------*
 * DefaultBSplineModel()
 *
 * Init default HRTF model
 --------------------------------------------------------------------*/

static void DefaultBSplineModel(
    TDREND_HRFILT_FiltSet_t *HrFiltSet_p, /* o  : Loaded HR filter set      */
    const int32_t output_Fs               /* i  : Output sampling rate      */
)
{
    ModelParams_t *model;
    ModelParamsITD_t *modelITD;
    int16_t i, j;

    HrFiltSet_p->FilterMethod = TDREND_HRFILT_Method_BSplineModel;
    model = &( HrFiltSet_p->ModelParams );
    modelITD = &( HrFiltSet_p->ModelParamsITD );

    /* Set ROM flag for correct deallocation */
    model->modelROM = TRUE;

    /* int16_t parameters */
    model->UseItdModel = 1;
    model->SplineDegree = 4;
    model->elevDim2 = 20;
    model->elevDim3 = 18;
    model->AlphaN = 578;
    model->num_unique_azim_splines = 1;
    model->elevSegSamples = 3;
    model->elevBsLen[0] = 4;
    model->elevBsLen[1] = 7;
    model->elevBsLen[2] = 10;
    model->elevBsLen[3] = 7;
    model->elevBsStart[0] = 0;
    model->elevBsStart[1] = 4;
    model->elevBsStart[2] = 11;
    model->elevBsStart[3] = 21;

    model->azimDim2 = orange53_rom_azimDim2;
    model->azimDim3 = orange53_rom_azimDim3;
    model->azim_start_idx = orange53_rom_azim_start_idx;
    model->azimSegSamples = orange53_rom_azimSegSamples;
    model->azimShapeIdx = orange53_rom_azimShapeIdx;
    model->azimShapeSampFactor = orange53_rom_azimShapeSampFactor;

    /* float parameters */
    model->elevKSeq = (const float *) orange53_rom_elevKSeq;
    model->elevBsShape = (const float *) orange53_rom_elevBsShape;

    model->azimBsShape = (const float **) malloc( model->num_unique_azim_splines * sizeof( float * ) );
    model->azimBsShape[0] = (const float *) orange53_rom_azimBsShape;
    model->azimKSeq = (float **) malloc( 18 * sizeof( float * ) );
    model->azimKSeq[0] = (float *) malloc( 2 * sizeof( float * ) );
    model->azimKSeq[17] = (float *) malloc( 2 * sizeof( float * ) );
    model->azimKSeq[0][0] = 0.0f;
    model->azimKSeq[17][0] = 0.0f;
    model->azimKSeq[0][1] = 360.0f;
    model->azimKSeq[17][1] = 360.0f;

    for ( i = 1; i < 17; i++ )
    {
        model->azimKSeq[i] = (float *) malloc( model->azimDim2[i] * sizeof( float * ) ); /* azimDim2[i] = 91, i=2..15 */
        for ( j = 0; j < model->azimDim2[i]; j++ )
        {
            model->azimKSeq[i][j] = (float) orange53_rom_azimSegSamples[0] * j;
        }
    }

    switch ( output_Fs )
    {
        case 48000:
            model->AlphaL = (const float *) orange53_rom_AlphaL48;
            model->AlphaR = (const float *) orange53_rom_AlphaR48;
            model->EL = (const float *) orange53_rom_EL48;
            model->ER = (const float *) orange53_rom_ER48;
            model->K = 128;
            if ( HrFiltSet_p->ModelParams.UseItdModel )
            {
                modelITD->resamp_factor = 1.0f;
            }
            break;
        case 32000:
            model->AlphaL = (const float *) orange53_rom_AlphaL32;
            model->AlphaR = (const float *) orange53_rom_AlphaR32;
            model->EL = (const float *) orange53_rom_EL32;
            model->ER = (const float *) orange53_rom_ER32;
            model->K = 86;
            if ( HrFiltSet_p->ModelParams.UseItdModel )
            {
                modelITD->resamp_factor = RESAMPLE_FACTOR_32_48;
            }
            break;
        case 16000:
            model->AlphaL = (const float *) orange53_rom_AlphaL16;
            model->AlphaR = (const float *) orange53_rom_AlphaR16;
            model->EL = (const float *) orange53_rom_EL16;
            model->ER = (const float *) orange53_rom_ER16;
            model->K = 43;
            if ( HrFiltSet_p->ModelParams.UseItdModel )
            {
                modelITD->resamp_factor = RESAMPLE_FACTOR_16_48;
            }
            break;
        default:
            break;
    }

    modelITD->N = 4;
    modelITD->elevDim2 = 20;
    modelITD->elevDim3 = 18;
    modelITD->azimDim2 = 41;
    modelITD->azimDim3 = 41;
    modelITD->elevSegSamples = 3;
    modelITD->elevBsLen[0] = 4;
    modelITD->elevBsLen[1] = 7;
    modelITD->elevBsLen[2] = 10;
    modelITD->elevBsLen[3] = 7;
    modelITD->elevBsStart[0] = 0;
    modelITD->elevBsStart[1] = 4;
    modelITD->elevBsStart[2] = 11;
    modelITD->elevBsStart[3] = 21;

    modelITD->elevKSeq = model->elevKSeq;

    modelITD->azimBsLen[0] = 11;
    modelITD->azimBsLen[1] = 21;
    modelITD->azimBsLen[2] = 31;
    modelITD->azimBsLen[3] = 21;
    modelITD->azimBsStart[0] = 0;
    modelITD->azimBsStart[1] = 11;
    modelITD->azimBsStart[2] = 32;
    modelITD->azimBsStart[3] = 63;

    modelITD->azimSegSamples = 10;

    modelITD->azimKSeq = orange53_rom_ITD_azimKSeq;
    modelITD->W = (const float *) orange53_rom_ITD_W;
    modelITD->azimBsShape = (const float *) orange53_rom_ITD_azimBsShape;
    modelITD->elevBsShape = (const float *) orange53_rom_ITD_elevBsShape;

    HRTF_model_precalc( model );

    HrFiltSet_p->SampleRate = output_Fs;
    HrFiltSet_p->FiltLength = HrFiltSet_p->ModelParams.K;

    BSplineModelEvalAlloc( &HrFiltSet_p->ModelParams, &HrFiltSet_p->ModelEval );

    return;
}
+1 −24
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@
 * FASTCONV and PARAMETRIC binaural renderer ROM tables
 *----------------------------------------------------------------------------------*/

const float dmxmtx[BINAURAL_CHANNELS][11] = // VE2AT: rename, otherwise could be confusing with hReverb->dmxmtx[][]
const float dmxmtx_table[BINAURAL_CHANNELS][11] =
{
    { 1.0f, 0.0f, 0.70709997f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f },
    { 0.0f, 1.0f, 0.70709997f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f },
@@ -76,29 +76,6 @@ const int16_t channelIndex_CICP19[11] = { 0, 1, 2, 3, 4, 7, 8, 9, 10, 13, 14 };
 * TD ISm binaural renderer ROM tables
 *----------------------------------------------------------------------------------*/

 /* The maximum target times set to 100 msec. */
const int16_t TDREND_SRC_REND_MaxTargetTimes[IVAS_NUM_SUPPORTED_FS] =
{
    1600, 3200, 4800 /* Corresponds to 16kHz, 32kHz, 48kHz */
};

/* The maximum lengths of the blocks internally in the effect. Corresponds to 6 msec. This means also that  */
/* if the length of the input block is just above 6 msec, the block will be divided into two 3 msec blocks. */
const int16_t TDREND_SRC_REND_MaxBlockLengths[IVAS_NUM_SUPPORTED_FS] =
{
    96, 192, 288 /* Corresponds to 16kHz, 32kHz, 48kHz */
};

const int16_t TDREND_MaxITD[IVAS_NUM_SUPPORTED_FS] =
{
    111, 222, 333 /* Corresponds to 16kHz, 32kHz, 48kHz */
};

const float TDREND_MaxITD_Incr[IVAS_NUM_SUPPORTED_FS] =
{
    0.0925f, 0.1850f, 0.2775f /* Corresponds to 16kHz, 32kHz, 48kHz, e.g. ( ( 2 * MaxITD ) / ( 0.05 * 48000 ) ) */
};

const int16_t HRTF_MODEL_N_CPTS_VAR[HRTF_MODEL_N_SECTIONS] =
{
    13, 12, 11
Loading