Commit d7d22b13 authored by emerit's avatar emerit
Browse files

fix decalarations

parent 6532f05f
Loading
Loading
Loading
Loading
+157 −23
Original line number Diff line number Diff line
@@ -251,6 +251,10 @@ int main( int argc, char *argv[] )
        }
    }

#ifndef USE_SYMETRIC_HRIR_FILTERS
    sym_hrir = -1;
#endif

    if ( ( strlen( argv[i] ) != 1 ) && ( strlen( argv[i] ) != 2 ) )
    {
        fprintf( stderr, "Unknown option: %s need to specify frame length in ms\n\n", argv[i] );
@@ -583,6 +587,10 @@ int main( int argc, char *argv[] )
                return -1;
            }
        }
#ifndef USE_SYMETRIC_HRIR_FILTERS
        current_sym_hrir = -1;
#endif

        err = generate_crend_ivas_tables_from_sofa( cTmp, no_optim, current_sym_hrir );
        if ( err != 0 )
            return err;
@@ -1295,8 +1303,9 @@ void update_c_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const int
    {
        /* float latency_s; */
        fprintf( fp, "\n\n/********************** %s_%s **********************/\n", DECLARATION_NAME, lscfg.name );

#ifdef USE_SYMETRIC_HRIR_FILTERS
        fprintf( fp, "\nconst uint16_t %s_%s_Use_Symetric_Filters = %d; /* 0 not symetric, 1 left, 2 right */", DECLARATION_NAME, lscfg.name, sym_hrir + 1 );
#endif
#ifdef FIX_BINAURAL_DELAY_PRECISION
        fprintf( fp, "\n#ifdef FIX_BINAURAL_DELAY_PRECISION\nconst float %s_%s_latency_s = %10.9ff;\n#else", DECLARATION_NAME, lscfg.name, hrtf->latency_s );
        fprintf( fp, "\nconst float %s_%s_latency_s = %16.15ff;\n#endif", DECLARATION_NAME, lscfg.name, hrtf->latency_s - 0.000000001f );
@@ -1310,7 +1319,14 @@ void update_c_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const int
    /* int16_t max_num_iterations; */
    fprintf( fp, "\nconst int16_t %s_%s_max_num_iterations_%2dkHz = %d;", DECLARATION_NAME, lscfg.name, samplerate / 1000, hrtf->max_num_iterations );
    /*    uint16_t num_iterations[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS];*/
    if ( sym_hrir < 0 )
    {
        fprintf( fp, "\nconst uint16_t %s_%s_num_iterations_%2dkHz[%d][BINAURAL_CHANNELS]={", DECLARATION_NAME, lscfg.name, samplerate / 1000, hrtf->max_num_ir );
    }
    else
    {
        fprintf( fp, "\nconst uint16_t %s_%s_num_iterations_%2dkHz[%d][%d]={", DECLARATION_NAME, lscfg.name, samplerate / 1000, hrtf->max_num_ir, nb_ear );
    }
    for ( i = 0; i < hrtf->max_num_ir - 1; i++ )
    {
        if ( nb_ear == 2 )
@@ -1327,13 +1343,20 @@ void update_c_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const int

    /*  uint16_t num_iterations_diffuse[BINAURAL_CHANNELS];*/
    if ( nb_ear == 2 )
        fprintf( fp, "\nconst uint16_t %s_%s_num_iterations_diffuse_%2dkHz[%d] = {%u, %u};", DECLARATION_NAME, lscfg.name, samplerate / 1000, nb_ear, hrtf->num_iterations_diffuse[0], hrtf->num_iterations_diffuse[1] );
        fprintf( fp, "\nconst uint16_t %s_%s_num_iterations_diffuse_%2dkHz[BINAURAL_CHANNELS] = {%u, %u};", DECLARATION_NAME, lscfg.name, samplerate / 1000, hrtf->num_iterations_diffuse[0], hrtf->num_iterations_diffuse[1] );
    else
        fprintf( fp, "\nconst uint16_t %s_%s_num_iterations_diffuse_%2dkHz[%d] = {%u};", DECLARATION_NAME, lscfg.name, samplerate / 1000, nb_ear, hrtf->num_iterations_diffuse[sym_hrir] );


    /*uint16_t *pIndex_frequency_max[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS]; */
    if ( sym_hrir < 0 )
    {
        fprintf( fp, "\nconst uint16_t %s_%s_pIndex_frequency_max_%2dkHz[%d][BINAURAL_CHANNELS][%d]={", DECLARATION_NAME, lscfg.name, samplerate / 1000, hrtf->max_num_ir, hrtf->max_num_iterations );
    }
    else
    {
        fprintf( fp, "\nconst uint16_t %s_%s_pIndex_frequency_max_%2dkHz[%d][%d][%d]={", DECLARATION_NAME, lscfg.name, samplerate / 1000, hrtf->max_num_ir, nb_ear, hrtf->max_num_iterations );
    }
    for ( i = 0; i < hrtf->max_num_ir - 1; i++ )
    {
        fprintf( fp, "{" );
@@ -1373,14 +1396,29 @@ void update_c_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const int

    /*   uint16_t *pIndex_frequency_max_diffuse[BINAURAL_CHANNELS];*/
    if ( hrtf->pIndex_frequency_max_diffuse[0] == NULL )
    {
        if ( sym_hrir < 0 )
        {
            fprintf( fp, "\nconst uint16_t *%s_%s_pIndex_frequency_max_diffuse_%2dkHz[BINAURAL_CHANNELS]=%s;", DECLARATION_NAME, lscfg.name, samplerate / 1000, nb_ear == 2 ? "{NULL,NULL}" : "{NULL}" );
        }
        else
        {
            fprintf( fp, "\nconst uint16_t *%s_%s_pIndex_frequency_max_diffuse_%2dkHz[%d]=%s;", DECLARATION_NAME, lscfg.name, samplerate / 1000, nb_ear, nb_ear == 2 ? "{NULL,NULL}" : "{NULL}" );
        }
    }
    else
    {
        if ( sym_hrir <= 0 )
        {
            if ( sym_hrir < 0 )
            {
                fprintf( fp, "\nconst uint16_t %s_%s_pIndex_frequency_max_diffuse_%2dkHz[BINAURAL_CHANNELS][%u]={", DECLARATION_NAME, lscfg.name, samplerate / 1000, ( hrtf->num_iterations_diffuse[0] > hrtf->num_iterations_diffuse[1] ) ? hrtf->num_iterations_diffuse[0] : hrtf->num_iterations_diffuse[1] );
            }
            else
            {
                fprintf( fp, "\nconst uint16_t %s_%s_pIndex_frequency_max_diffuse_%2dkHz[%d][%u]={", DECLARATION_NAME, lscfg.name, samplerate / 1000, nb_ear, ( hrtf->num_iterations_diffuse[0] > hrtf->num_iterations_diffuse[1] ) ? hrtf->num_iterations_diffuse[0] : hrtf->num_iterations_diffuse[1] );
            }

            if ( hrtf->pIndex_frequency_max_diffuse[0] && ( sym_hrir <= 0 ) )
            {
                write_array_uint16_to_file( fp, hrtf->pIndex_frequency_max_diffuse[0], hrtf->num_iterations_diffuse[0], hrtf->num_iterations_diffuse[0], 0, TAB_WITH_SPACE_OR_NOT );
@@ -1399,7 +1437,14 @@ void update_c_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const int
    }

    /* float *pOut_to_bin[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS];*/
    if ( sym_hrir < 0 )
    {
        fprintf( fp, "\nconst float %s_%s_coeff_re_%2dkHz[%d][BINAURAL_CHANNELS][%u]={", DECLARATION_NAME, lscfg.name, samplerate / 1000, hrtf->max_num_ir, maxTotalNumFreqSampPerIterations );
    }
    else
    {
        fprintf( fp, "\nconst float %s_%s_coeff_re_%2dkHz[%d][%d][%u]={", DECLARATION_NAME, lscfg.name, samplerate / 1000, hrtf->max_num_ir, nb_ear, maxTotalNumFreqSampPerIterations );
    }
    for ( i = 0; i < hrtf->max_num_ir - 1; i++ )
    {
        fprintf( fp, "\n%s{\n", TAB_WITH_SPACE_OR_NOT );
@@ -1435,7 +1480,14 @@ void update_c_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const int
        fprintf( fp, "%s}", TAB_WITH_SPACE_OR_NOT );
    fprintf( fp, "\n};" );

    if ( sym_hrir < 0 )
    {
        fprintf( fp, "\nconst float %s_%s_coeff_im_%2dkHz[%d][BINAURAL_CHANNELS][%u]={", DECLARATION_NAME, lscfg.name, samplerate / 1000, hrtf->max_num_ir, maxTotalNumFreqSampPerIterations );
    }
    else
    {
        fprintf( fp, "\nconst float %s_%s_coeff_im_%2dkHz[%d][%d][%u]={", DECLARATION_NAME, lscfg.name, samplerate / 1000, hrtf->max_num_ir, nb_ear, maxTotalNumFreqSampPerIterations );
    }
    for ( i = 0; i < hrtf->max_num_ir - 1; i++ )
    {
        fprintf( fp, "\n%s{\n", TAB_WITH_SPACE_OR_NOT );
@@ -1473,12 +1525,26 @@ void update_c_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const int

    /*   float *pOut_to_bin_diffuse_re[BINAURAL_CHANNELS];*/
    if ( hrtf->pOut_to_bin_diffuse_re[0] == NULL )
    {
        if ( sym_hrir < 0 )
        {
            fprintf( fp, "\nconst float *%s_%s_coeff_diffuse_re_%2dkHz[BINAURAL_CHANNELS]=%s;", DECLARATION_NAME, lscfg.name, samplerate / 1000, nb_ear == 2 ? "{NULL,NULL}" : "{NULL}" );
        }
        else
        {
            fprintf( fp, "\nconst float *%s_%s_coeff_diffuse_re_%2dkHz[%d]=%s;", DECLARATION_NAME, lscfg.name, samplerate / 1000, nb_ear, nb_ear == 2 ? "{NULL,NULL}" : "{NULL}" );
        }
    }
    else
    {
        if ( sym_hrir < 0 )
        {
            fprintf( fp, "\nconst float %s_%s_coeff_diffuse_re_%2dkHz[BINAURAL_CHANNELS][%u]={", DECLARATION_NAME, lscfg.name, samplerate / 1000, maxTotalNumFreqSampPerIterationsDiffuse );
        }
        else
        {
            fprintf( fp, "\nconst float %s_%s_coeff_diffuse_re_%2dkHz[%d][%u]={", DECLARATION_NAME, lscfg.name, samplerate / 1000, nb_ear, maxTotalNumFreqSampPerIterationsDiffuse );
        }
        if ( hrtf->pOut_to_bin_diffuse_re[0] )
        {
            write_array_float_to_file( fp, hrtf->pOut_to_bin_diffuse_re[0], pTotalNumFreqSampPerIterationsDiffuse[0], NUM_SAMPLES_PER_LINES, FORMAT_FLOAT, 2, TAB_WITH_SPACE_OR_NOT );
@@ -1497,12 +1563,26 @@ void update_c_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const int

    /*   float *pOut_to_bin_diffuse_im[BINAURAL_CHANNELS];*/
    if ( hrtf->pOut_to_bin_diffuse_im[0] == NULL )
    {
        if ( sym_hrir < 0 )
        {
            fprintf( fp, "\nconst float *%s_%s_coeff_diffuse_im_%2dkHz[BINAURAL_CHANNELS]=%s;", DECLARATION_NAME, lscfg.name, samplerate / 1000, nb_ear == 2 ? "{NULL,NULL}" : "{NULL}" );
        }
        else
        {
            fprintf( fp, "\nconst float *%s_%s_coeff_diffuse_im_%2dkHz[%d]=%s;", DECLARATION_NAME, lscfg.name, samplerate / 1000, nb_ear, nb_ear == 2 ? "{NULL,NULL}" : "{NULL}" );
        }
    }
    else
    {
        if ( sym_hrir < 0 )
        {
            fprintf( fp, "\nconst float %s_%s_coeff_diffuse_im_%2dkHz[BINAURAL_CHANNELS][%u]={", DECLARATION_NAME, lscfg.name, samplerate / 1000, maxTotalNumFreqSampPerIterationsDiffuse );
        }
        else
        {
            fprintf( fp, "\nconst float %s_%s_coeff_diffuse_im_%2dkHz[%d][%u]={", DECLARATION_NAME, lscfg.name, samplerate / 1000, nb_ear, maxTotalNumFreqSampPerIterationsDiffuse );
        }
        if ( hrtf->pOut_to_bin_diffuse_im[0] )
        {
            write_array_float_to_file( fp, hrtf->pOut_to_bin_diffuse_im[0], pTotalNumFreqSampPerIterationsDiffuse[0], NUM_SAMPLES_PER_LINES, FORMAT_FLOAT, 2, TAB_WITH_SPACE_OR_NOT );
@@ -1612,7 +1692,9 @@ void update_h_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const int
    {
        /* float latency_s; */
        fprintf( fp, "\n\n/********************** %s_%s **********************/\n", DECLARATION_NAME, lscfg.name );
#ifdef USE_SYMETRIC_HRIR_FILTERS
        fprintf( fp, "\nextern uint16_t %s_%s_Use_Symetric_Filters;", DECLARATION_NAME, lscfg.name );
#endif
        fprintf( fp, "\nextern float %s_%s_latency_s;", DECLARATION_NAME, lscfg.name );
    }

@@ -1621,12 +1703,21 @@ void update_h_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const int
    /* int16_t max_num_iterations; */
    fprintf( fp, "\nextern int16_t %s_%s_max_num_iterations_%2dkHz;", DECLARATION_NAME, lscfg.name, samplerate / 1000 );
    /*    uint16_t num_iterations[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS];*/
    if ( sym_hrir < 0 )
        fprintf( fp, "\nextern uint16_t %s_%s_num_iterations_%2dkHz[%d][BINAURAL_CHANNELS];", DECLARATION_NAME, lscfg.name, samplerate / 1000, hrtf->max_num_ir );
    else
        fprintf( fp, "\nextern uint16_t %s_%s_num_iterations_%2dkHz[%d][%d];", DECLARATION_NAME, lscfg.name, samplerate / 1000, hrtf->max_num_ir, nb_ear );

    /*  uint16_t num_iterations_diffuse[BINAURAL_CHANNELS];*/
    if ( sym_hrir < 0 )
        fprintf( fp, "\nextern uint16_t %s_%s_num_iterations_diffuse_%2dkHz[BINAURAL_CHANNELS];", DECLARATION_NAME, lscfg.name, samplerate / 1000 );
    else
        fprintf( fp, "\nextern uint16_t %s_%s_num_iterations_diffuse_%2dkHz[%d];", DECLARATION_NAME, lscfg.name, samplerate / 1000, nb_ear );

    /*uint16_t *pIndex_frequency_max[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS]; */
    if ( sym_hrir < 0 )
        fprintf( fp, "\nextern uint16_t %s_%s_pIndex_frequency_max_%2dkHz[%d][BINAURAL_CHANNELS][%d];", DECLARATION_NAME, lscfg.name, samplerate / 1000, hrtf->max_num_ir, hrtf->max_num_iterations );
    else
        fprintf( fp, "\nextern uint16_t %s_%s_pIndex_frequency_max_%2dkHz[%d][%d][%d];", DECLARATION_NAME, lscfg.name, samplerate / 1000, hrtf->max_num_ir, nb_ear, hrtf->max_num_iterations );

    /* uint16_t index_frequency_max_diffuse; */
@@ -1638,36 +1729,79 @@ void update_h_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const int
    /*   uint16_t *pIndex_frequency_max_diffuse[BINAURAL_CHANNELS];*/
    if ( hrtf->pIndex_frequency_max_diffuse[0] == NULL )
    {
        fprintf( fp, "\nextern uint16_t *%s_%s_pIndex_frequency_max_diffuse_%2dkHz[%d];", DECLARATION_NAME, lscfg.name, samplerate / 1000, nb_ear );
        fprintf( fp, "\nextern uint16_t *%s_%s_pIndex_frequency_max_diffuse_%2dkHz[BINAURAL_CHANNELS];", DECLARATION_NAME, lscfg.name, samplerate / 1000 );
    }
    else
    {
        if ( sym_hrir < 0 )
        {
            fprintf( fp, "\nextern uint16_t %s_%s_pIndex_frequency_max_diffuse_%2dkHz[BINAURAL_CHANNELS][%u];", DECLARATION_NAME, lscfg.name, samplerate / 1000, ( hrtf->num_iterations_diffuse[0] > hrtf->num_iterations_diffuse[1] ) ? hrtf->num_iterations_diffuse[0] : hrtf->num_iterations_diffuse[1] );
        }
        else
        {
            fprintf( fp, "\nextern uint16_t %s_%s_pIndex_frequency_max_diffuse_%2dkHz[%d][%u];", DECLARATION_NAME, lscfg.name, samplerate / 1000, nb_ear, ( hrtf->num_iterations_diffuse[0] > hrtf->num_iterations_diffuse[1] ) ? hrtf->num_iterations_diffuse[0] : hrtf->num_iterations_diffuse[1] );
        }
    }

    /* float *pOut_to_bin[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS];*/
    if ( sym_hrir < 0 )
    {
        fprintf( fp, "\nextern float %s_%s_coeff_re_%2dkHz[%d][BINAURAL_CHANNELS][%u];", DECLARATION_NAME, lscfg.name, samplerate / 1000, hrtf->max_num_ir, maxTotalNumFreqSampPerIterations );
        fprintf( fp, "\nextern float %s_%s_coeff_im_%2dkHz[%d][BINAURAL_CHANNELS][%u];", DECLARATION_NAME, lscfg.name, samplerate / 1000, hrtf->max_num_ir, maxTotalNumFreqSampPerIterations );
    }
    else
    {
        fprintf( fp, "\nextern float %s_%s_coeff_re_%2dkHz[%d][%d][%u];", DECLARATION_NAME, lscfg.name, samplerate / 1000, hrtf->max_num_ir, nb_ear, maxTotalNumFreqSampPerIterations );
        fprintf( fp, "\nextern float %s_%s_coeff_im_%2dkHz[%d][%d][%u];", DECLARATION_NAME, lscfg.name, samplerate / 1000, hrtf->max_num_ir, nb_ear, maxTotalNumFreqSampPerIterations );
    }

    /*   float *pOut_to_bin_diffuse_re[BINAURAL_CHANNELS];*/
    if ( hrtf->pOut_to_bin_diffuse_re[0] == NULL )
    {
        if ( sym_hrir < 0 )
        {
            fprintf( fp, "\nextern float *%s_%s_coeff_diffuse_re_%2dkHz[BINAURAL_CHANNELS];", DECLARATION_NAME, lscfg.name, samplerate / 1000 );
        }
        else
        {
            fprintf( fp, "\nextern float *%s_%s_coeff_diffuse_re_%2dkHz[%d];", DECLARATION_NAME, lscfg.name, samplerate / 1000, nb_ear );
        }
    }
    else
    {
        if ( sym_hrir < 0 )
        {
            fprintf( fp, "\nextern float %s_%s_coeff_diffuse_re_%2dkHz[BINAURAL_CHANNELS][%u];", DECLARATION_NAME, lscfg.name, samplerate / 1000, maxTotalNumFreqSampPerIterationsDiffuse );
        }
        else
        {
            fprintf( fp, "\nextern float %s_%s_coeff_diffuse_re_%2dkHz[%d][%u];", DECLARATION_NAME, lscfg.name, samplerate / 1000, nb_ear, maxTotalNumFreqSampPerIterationsDiffuse );
        }
    }

    /*   float *pOut_to_bin_diffuse_im[BINAURAL_CHANNELS];*/
    if ( hrtf->pOut_to_bin_diffuse_im[0] == NULL )
    {
        if ( sym_hrir < 0 )
        {
            fprintf( fp, "\nextern float *%s_%s_coeff_diffuse_im_%2dkHz[BINAURAL_CHANNELS];", DECLARATION_NAME, lscfg.name, samplerate / 1000 );
        }
        else
        {
            fprintf( fp, "\nextern float *%s_%s_coeff_diffuse_im_%2dkHz[%d];", DECLARATION_NAME, lscfg.name, samplerate / 1000, nb_ear );
        }
    }
    else
    {
        if ( sym_hrir < 0 )
        {
            fprintf( fp, "\nextern float %s_%s_coeff_diffuse_im_%2dkHz[BINAURAL_CHANNELS][%u];", DECLARATION_NAME, lscfg.name, samplerate / 1000, maxTotalNumFreqSampPerIterationsDiffuse );
        }
        else
        {
            fprintf( fp, "\nextern float %s_%s_coeff_diffuse_im_%2dkHz[%d][%u];", DECLARATION_NAME, lscfg.name, samplerate / 1000, nb_ear, maxTotalNumFreqSampPerIterationsDiffuse );
        }
    }

    if ( fp )
        fclose( fp );