Commit f8edfde8 authored by Devansh Kandpal's avatar Devansh Kandpal
Browse files

Code Cleanup

parent ac343713
Loading
Loading
Loading
Loading
+0 −137
Original line number Diff line number Diff line
@@ -289,156 +289,19 @@ ivas_error ivas_HRTF_statistics_init(
    switch ( sampleRate )
    {
        case 48000:
#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB
            HrtfStatistics->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( float ) );
            if ( HrtfStatistics->average_energy_l_dyn == NULL )
            {
                return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
            }
            HrtfStatistics->average_energy_r_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( float ) );
            if ( HrtfStatistics->average_energy_r_dyn == NULL )
            {
                return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
            }
            HrtfStatistics->inter_aural_coherence_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( float ) );
            if ( HrtfStatistics->inter_aural_coherence_dyn == NULL )
            {
                return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
            }
            floatToFixed_arr32( (float*) defaultHRIR_left_avg_power_48kHz, HrtfStatistics->average_energy_l_dyn, Q23, LR_IAC_LENGTH_NR_FC );  /* tables from which lr_energy_and_iac is updated has Q23 for i=2 */
            floatToFixed_arr32( (float*) defaultHRIR_right_avg_power_48kHz, HrtfStatistics->average_energy_r_dyn, Q23, LR_IAC_LENGTH_NR_FC ); /* tables from which lr_energy_and_iac is updated has Q23 for i=2 */
            floatToFixed_arr32( (float*) defaultHRIR_coherence_48kHz, HrtfStatistics->inter_aural_coherence_dyn, Q27, LR_IAC_LENGTH_NR_FC );  /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */
            HrtfStatistics->average_energy_l = (const Word32 *) HrtfStatistics->average_energy_l_dyn;
            HrtfStatistics->average_energy_r = (const Word32 *) HrtfStatistics->average_energy_r_dyn;
            HrtfStatistics->inter_aural_coherence = (const Word32 *) HrtfStatistics->inter_aural_coherence_dyn;
            // TODO: dump the converted fixed point arrays to an array
            printf( "average_energy_l = {\n" );
            for ( int i = 0; i < LR_IAC_LENGTH_NR_FC; i++ )
            {
                printf( "%d, ", HrtfStatistics->average_energy_l_dyn[i] );
            }
            printf( "};\n" );

            printf( "average_energy_r = {\n" );
            for ( int i = 0; i < LR_IAC_LENGTH_NR_FC; i++ )
            {
                printf( "%d, ", HrtfStatistics->average_energy_r_dyn[i] );
            }
            printf( "};\n" );

            printf( "inter_aural_coherence = {\n" );
            for ( int i = 0; i < LR_IAC_LENGTH_NR_FC; i++ )
            {
                printf( "%d, ", HrtfStatistics->inter_aural_coherence_dyn[i] );
            }
            printf( "};\n" );
#else
            HrtfStatistics->average_energy_l = defaultHRIR_left_avg_power_48kHz_fx;
            HrtfStatistics->average_energy_r = defaultHRIR_right_avg_power_48kHz_fx;
            HrtfStatistics->inter_aural_coherence = defaultHRIR_coherence_48kHz_fx;
#endif
            break;
        case 32000:
#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB
            HrtfStatistics->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( float ) );
            if ( HrtfStatistics->average_energy_l_dyn == NULL )
            {
                return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
            }
            HrtfStatistics->average_energy_r_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( float ) );
            if ( HrtfStatistics->average_energy_r_dyn == NULL )
            {
                return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
            }
            HrtfStatistics->inter_aural_coherence_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( float ) );
            if ( HrtfStatistics->inter_aural_coherence_dyn == NULL )
            {
                return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
            }
            floatToFixed_arr32( (float*) defaultHRIR_left_avg_power_32kHz, HrtfStatistics->average_energy_l_dyn, Q23, LR_IAC_LENGTH_NR_FC );  /* tables from which lr_energy_and_iac is updated has Q23 for i=2 */
            floatToFixed_arr32( (float *) defaultHRIR_right_avg_power_32kHz, HrtfStatistics->average_energy_r_dyn, Q23, LR_IAC_LENGTH_NR_FC ); /* tables from which lr_energy_and_iac is updated has Q23 for i=2 */
            floatToFixed_arr32( (float *) defaultHRIR_coherence_32kHz, HrtfStatistics->inter_aural_coherence_dyn, Q27, LR_IAC_LENGTH_NR_FC );  /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */
            HrtfStatistics->average_energy_l = (const Word32 *) HrtfStatistics->average_energy_l_dyn;
            HrtfStatistics->average_energy_r = (const Word32 *) HrtfStatistics->average_energy_r_dyn;
            HrtfStatistics->inter_aural_coherence = (const Word32 *) HrtfStatistics->inter_aural_coherence_dyn;
            // TODO: dump the converted fixed point arrays to a string

            printf( "average_energy_l = {\n" );
            for ( int i = 0; i < LR_IAC_LENGTH_NR_FC; i++ )
            {
                printf( "%d, ", HrtfStatistics->average_energy_l_dyn[i] );
            }
            printf( "};\n" );

            printf( "average_energy_r = {\n" );
            for ( int i = 0; i < LR_IAC_LENGTH_NR_FC; i++ )
            {
                printf( "%d, ", HrtfStatistics->average_energy_r_dyn[i] );
            }
            printf( "};\n" );

            printf( "inter_aural_coherence = {\n" );
            for ( int i = 0; i < LR_IAC_LENGTH_NR_FC; i++ )
            {
                printf( "%d, ", HrtfStatistics->inter_aural_coherence_dyn[i] );
            }
            printf( "};\n" );
#else
            HrtfStatistics->average_energy_l = defaultHRIR_left_avg_power_32kHz_fx;
            HrtfStatistics->average_energy_r = defaultHRIR_right_avg_power_32kHz_fx;
            HrtfStatistics->inter_aural_coherence = defaultHRIR_coherence_32kHz_fx;
#endif
            break;
        case 16000:
#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB
            HrtfStatistics->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( float ) );
            if ( HrtfStatistics->average_energy_l_dyn == NULL )
            {
                return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
            }
            HrtfStatistics->average_energy_r_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( float ) );
            if ( HrtfStatistics->average_energy_r_dyn == NULL )
            {
                return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
            }
            HrtfStatistics->inter_aural_coherence_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( float ) );
            if ( HrtfStatistics->inter_aural_coherence_dyn == NULL )
            {
                return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
            }
            floatToFixed_arr32( (float*) defaultHRIR_left_avg_power_16kHz, HrtfStatistics->average_energy_l_dyn, Q23, LR_IAC_LENGTH_NR_FC_16KHZ );  /* tables from which lr_energy_and_iac is updated has Q23 for i=2 */
            floatToFixed_arr32( (float*) defaultHRIR_right_avg_power_16kHz, HrtfStatistics->average_energy_r_dyn, Q23, LR_IAC_LENGTH_NR_FC_16KHZ ); /* tables from which lr_energy_and_iac is updated has Q23 for i=2 */
            floatToFixed_arr32( (float*) defaultHRIR_coherence_16kHz, HrtfStatistics->inter_aural_coherence_dyn, Q27, LR_IAC_LENGTH_NR_FC_16KHZ );  /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */
            HrtfStatistics->average_energy_l = (const Word32 *) HrtfStatistics->average_energy_l_dyn;
            HrtfStatistics->average_energy_r = (const Word32 *) HrtfStatistics->average_energy_r_dyn;
            HrtfStatistics->inter_aural_coherence = (const Word32 *) HrtfStatistics->inter_aural_coherence_dyn;

            printf( "\naverage_energy_l = {\n" );
            for ( int i = 0; i < LR_IAC_LENGTH_NR_FC_16KHZ; i++ )
            {
                printf( "%d, ", HrtfStatistics->average_energy_l_dyn[i] );
            }
            printf( "};\n" );

            printf( "average_energy_r = {\n" );
            for ( int i = 0; i < LR_IAC_LENGTH_NR_FC_16KHZ; i++ )
            {
                printf( "%d, ", HrtfStatistics->average_energy_r_dyn[i] );
            }
            printf( "};\n" );

            printf( "inter_aural_coherence = {\n" );
            for ( int i = 0; i < LR_IAC_LENGTH_NR_FC_16KHZ; i++ )
            {
                printf( "%d, ", HrtfStatistics->inter_aural_coherence_dyn[i] );
            }
            printf( "};\n" );
#else

            HrtfStatistics->average_energy_l = defaultHRIR_left_avg_power_16kHz_fx;
            HrtfStatistics->average_energy_r = defaultHRIR_right_avg_power_16kHz_fx;
            HrtfStatistics->inter_aural_coherence = defaultHRIR_coherence_16kHz_fx;
#endif
            break;
    }
    HrtfStatistics->fromROM = TRUE;
+0 −345

File changed.

Preview size limit exceeded, changes collapsed.