Commit 2f13d4ca authored by emerit's avatar emerit
Browse files

fix fastconv memory allocation

parent 02c25129
Loading
Loading
Loading
Loading
Loading
+75 −16
Original line number Diff line number Diff line
@@ -1821,24 +1821,17 @@ static ivas_error create_fastconv_HRTF_from_rawdata_fx(

    ( *hHRTF )->allocate_init_flag = 0;

#ifndef FIX_1123_FASTCONV_16BIT_ROM
    if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV )
    {
#ifdef FIX_1123_FASTCONV_16BIT_ROM
        if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, IVAS_AUDIO_CONFIG_INVALID, input_cfg, RENDERER_BINAURAL_FASTCONV, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK )
#else
        if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, 0, input_cfg, RENDERER_BINAURAL_FASTCONV, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK )
#endif
        {
            return error;
        }
    }
    else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM )
    {
#ifdef FIX_1123_FASTCONV_16BIT_ROM
        if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, IVAS_AUDIO_CONFIG_INVALID, input_cfg, RENDERER_BINAURAL_FASTCONV_ROOM, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK )
#else
        if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, 0, input_cfg, RENDERER_BINAURAL_FASTCONV_ROOM, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK )
#endif
        {
            return error;
        }
@@ -1847,6 +1840,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata_fx(
    {
        return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "renderer type not compliant" );
    }
#endif

    hrtf_data_rptr = hrtf_data;

@@ -1883,6 +1877,13 @@ static ivas_error create_fastconv_HRTF_from_rawdata_fx(
#endif
        hrtf_data_rptr += sizeof( uint16_t );

#ifdef FIX_1123_FASTCONV_16BIT_ROM
        if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, IVAS_AUDIO_CONFIG_INVALID, input_cfg, RENDERER_BINAURAL_FASTCONV, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#endif

        /* HRIR Q factor*/
        factorQ = *( (Word16 *) ( hrtf_data_rptr ) );
        hrtf_data_rptr += sizeof( Word16 );
@@ -2020,6 +2021,13 @@ static ivas_error create_fastconv_HRTF_from_rawdata_fx(
#endif
        hrtf_data_rptr += sizeof( uint16_t );

#ifdef FIX_1123_FASTCONV_16BIT_ROM
        if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, IVAS_AUDIO_CONFIG_INVALID, input_cfg, RENDERER_BINAURAL_FASTCONV, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#endif

        /* HRIR Q factor*/
        factorQ = *( (Word16 *) ( hrtf_data_rptr ) );
        hrtf_data_rptr += sizeof( Word16 );
@@ -2157,6 +2165,13 @@ static ivas_error create_fastconv_HRTF_from_rawdata_fx(
#endif
        hrtf_data_rptr += sizeof( uint16_t );

#ifdef FIX_1123_FASTCONV_16BIT_ROM
        if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, IVAS_AUDIO_CONFIG_INVALID, input_cfg, RENDERER_BINAURAL_FASTCONV, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#endif

        /* HRIR Q factor*/
        factorQ = *( (Word16 *) ( hrtf_data_rptr ) );
        hrtf_data_rptr += sizeof( Word16 );
@@ -2295,6 +2310,13 @@ static ivas_error create_fastconv_HRTF_from_rawdata_fx(
#endif
        hrtf_data_rptr += sizeof( uint16_t );

#ifdef FIX_1123_FASTCONV_16BIT_ROM
        if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, IVAS_AUDIO_CONFIG_INVALID, input_cfg, RENDERER_BINAURAL_FASTCONV, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#endif

        /* HRIR Q factor*/
        factorQ = *( (Word16 *) ( hrtf_data_rptr ) );
        hrtf_data_rptr += sizeof( Word16 );
@@ -2433,6 +2455,13 @@ static ivas_error create_fastconv_HRTF_from_rawdata_fx(
#endif
        hrtf_data_rptr += sizeof( uint16_t );

#ifdef FIX_1123_FASTCONV_16BIT_ROM
        if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, IVAS_AUDIO_CONFIG_INVALID, input_cfg, RENDERER_BINAURAL_FASTCONV_ROOM, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#endif

        /* BRIR Q factor*/
        factorQ = *( (Word16 *) ( hrtf_data_rptr ) );
        hrtf_data_rptr += sizeof( Word16 );
@@ -2693,24 +2722,17 @@ static ivas_error create_fastconv_HRTF_from_rawdata(

    ( *hHRTF )->allocate_init_flag = 0;

#ifndef FIX_1123_FASTCONV_16BIT_ROM
    if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV )
    {
#ifdef FIX_1123_FASTCONV_16BIT_ROM
        if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, IVAS_AUDIO_CONFIG_INVALID, input_cfg, RENDERER_BINAURAL_FASTCONV, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK )
#else
        if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, 0, input_cfg, RENDERER_BINAURAL_FASTCONV, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK )
#endif
        {
            return error;
        }
    }
    else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM )
    {
#ifdef FIX_1123_FASTCONV_16BIT_ROM
        if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, IVAS_AUDIO_CONFIG_INVALID, input_cfg, RENDERER_BINAURAL_FASTCONV_ROOM, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK )
#else
        if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, 0, input_cfg, RENDERER_BINAURAL_FASTCONV_ROOM, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK )
#endif
        {
            return error;
        }
@@ -2719,6 +2741,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata(
    {
        return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "renderer type not compliant" );
    }
#endif

    hrtf_data_rptr = hrtf_data;

@@ -2750,6 +2773,13 @@ static ivas_error create_fastconv_HRTF_from_rawdata(
#endif
        hrtf_data_rptr += sizeof( uint16_t );

#ifdef FIX_1123_FASTCONV_16BIT_ROM
        if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, IVAS_AUDIO_CONFIG_INVALID, input_cfg, RENDERER_BINAURAL_FASTCONV, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#endif

        for ( i = 0; i < BINAURAL_CONVBANDS; i++ )
        {
            for ( j = 0; j < HRTF_LS_CHANNELS; j++ )
@@ -2830,6 +2860,14 @@ static ivas_error create_fastconv_HRTF_from_rawdata(
        }
#endif
        hrtf_data_rptr += sizeof( uint16_t );

#ifdef FIX_1123_FASTCONV_16BIT_ROM
        if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, IVAS_AUDIO_CONFIG_INVALID, input_cfg, RENDERER_BINAURAL_FASTCONV, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#endif

        for ( i = 0; i < BINAURAL_CONVBANDS; i++ )
        {
            for ( j = 0; j < HOA3_CHANNELS; j++ )
@@ -2911,6 +2949,13 @@ static ivas_error create_fastconv_HRTF_from_rawdata(
#endif
        hrtf_data_rptr += sizeof( uint16_t );

#ifdef FIX_1123_FASTCONV_16BIT_ROM
        if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, IVAS_AUDIO_CONFIG_INVALID, input_cfg, RENDERER_BINAURAL_FASTCONV, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#endif

        for ( i = 0; i < BINAURAL_CONVBANDS; i++ )
        {
            for ( j = 0; j < HOA2_CHANNELS; j++ )
@@ -2992,6 +3037,13 @@ static ivas_error create_fastconv_HRTF_from_rawdata(
#endif
        hrtf_data_rptr += sizeof( uint16_t );

#ifdef FIX_1123_FASTCONV_16BIT_ROM
        if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, IVAS_AUDIO_CONFIG_INVALID, input_cfg, RENDERER_BINAURAL_FASTCONV, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#endif

        for ( i = 0; i < BINAURAL_CONVBANDS; i++ )
        {
            for ( j = 0; j < FOA_CHANNELS; j++ )
@@ -3073,6 +3125,13 @@ static ivas_error create_fastconv_HRTF_from_rawdata(
#endif
        hrtf_data_rptr += sizeof( uint16_t );

#ifdef FIX_1123_FASTCONV_16BIT_ROM
        if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, IVAS_AUDIO_CONFIG_INVALID, input_cfg, RENDERER_BINAURAL_FASTCONV_ROOM, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#endif

        for ( i = 0; i < BINAURAL_CONVBANDS; i++ )
        {
            for ( j = 0; j < HRTF_LS_CHANNELS; j++ )