Commit bf824395 authored by vaclav's avatar vaclav
Browse files

- comments

- rename function ObjRenderIVASFrame to ivas_td_binaural_renderer()
parent e252d752
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -4850,7 +4850,7 @@ ivas_error ivas_td_binaural_open(
);


void ObjRenderIVASFrame(
void ivas_td_binaural_renderer(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                  */
    float output[][L_FRAME48k],                                 /* i/o: SCE channels / Binaural synthesis       */
    const int16_t output_frame                                  /* i  : output frame length                     */
@@ -4985,7 +4985,7 @@ ivas_error ivas_crend_init_from_hrtf_handle(
	HRTFS_HANDLE hrtf);
#endif

ivas_error destroy_SetOfHRTF(
void destroy_SetOfHRTF(
	HRTFS_CREND_HANDLE hSetOfHRTF                               /* i/o: Set of HRTF CRend handle                */
);

+2 −2
Original line number Diff line number Diff line
@@ -204,7 +204,7 @@ ivas_error ivas_dec(
            /* Binaural rendering */
            if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD )
            {
                ObjRenderIVASFrame( st_ivas, output, output_frame );
                ivas_td_binaural_renderer( st_ivas, output, output_frame );
            }
            else if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM )
            {
@@ -434,7 +434,7 @@ ivas_error ivas_dec(
            }
            else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD )
            {
                ObjRenderIVASFrame( st_ivas, output, output_frame );
                ivas_td_binaural_renderer( st_ivas, output, output_frame );
                ivas_binaural_add_LFE( st_ivas, output_frame, output );
            }
        }
+2 −2
Original line number Diff line number Diff line
@@ -190,7 +190,7 @@ static ivas_error destroy_HRTF(
 * Destroy the HRTF data set.
 *---------------------------------------------------------------------*/

ivas_error destroy_SetOfHRTF(
void destroy_SetOfHRTF(
    HRTFS_CREND_HANDLE hSetOfHRTF /* i/o: Set of HRTF CRend handle              */
)
{
@@ -201,7 +201,7 @@ ivas_error destroy_SetOfHRTF(
        destroy_HRTF( &( hSetOfHRTF->hHRTF_brir_combined ) );
    }

    return IVAS_ERR_OK;
    return;
}


+39 −38
Original line number Diff line number Diff line
@@ -135,11 +135,11 @@ static ivas_error read_and_check_hrtf_binary_file_header(
{
    int32_t file_size;

    // [Declaration of the binary file]
    //      File Identifier         (8 bytes)
    //      Size of file in bytes   (4 bytes)
    //      Number of HRTF          (2 bytes)
    //      Max length of HRTF data (4 bytes)
    /* [Declaration of the binary file]       */
    /*      File Identifier         (8 bytes) */
    /*      Size of file in bytes   (4 bytes) */
    /*      Number of HRTF          (2 bytes) */
    /*      Max length of HRTF data (4 bytes) */

    fseek( f_hrtf, 0, SEEK_END );
    file_size = ftell( f_hrtf );
@@ -178,7 +178,7 @@ static ivas_error read_and_check_hrtf_binary_file_header(
static ivas_error check_hrtf_binary_header(
    ivas_hrtfs_header_t *hrtf_header )
{
    // Check the renderer type
    /* Check the renderer type */
    if ( ( hrtf_header->rend_type != RENDERER_BINAURAL_MIXER_CONV ) && ( hrtf_header->rend_type != RENDERER_BINAURAL_MIXER_CONV_ROOM ) &&
#ifdef HRTF_BINARY_FILE
         ( hrtf_header->rend_type != RENDERER_BINAURAL_FASTCONV ) && ( hrtf_header->rend_type != RENDERER_BINAURAL_FASTCONV_ROOM ) &&
@@ -189,16 +189,16 @@ static ivas_error check_hrtf_binary_header(
        return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Header of HRTF binary file not compliant (renderer type)" );
    }

    // Check the output format of the decoder
    /* Check the output format of the decoder */
    if ( ( hrtf_header->input_cfg != BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) && ( hrtf_header->input_cfg != BINAURAL_INPUT_AUDIO_CONFIG_HOA ) && ( hrtf_header->input_cfg != BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED ) )
    {
        return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Header of HRTF binary file not compliant (input audio configuration)" );
    }

    // Check the sampling frequency
    /* Check the sampling frequency */
    if ( ( hrtf_header->frequency != 48000 ) && ( hrtf_header->frequency != 32000 ) && ( hrtf_header->frequency != 16000 ) )
    {
        return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Header of HRTF binary file not compliant (sampling frequency)" );
        return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "Header of HRTF binary file not compliant (sampling frequency)" );
    }

    return IVAS_ERR_OK;
@@ -215,11 +215,11 @@ static ivas_error read_hrtf_binary_header(
    ivas_hrtfs_header_t *hrtf_header,
    FILE *f_hrtf )
{
    // HRTF Header
    //      Renderer type         (4 bytes) : See "RENDERER_TYPE"
    //      Input configuration   (4 bytes) : See "BINAURAL_INPUT_AUDIO_CONFIG"
    //      Sampling Frequency    (4 bytes)
    //      Raw data size         (4 bytes)
    /* HRTF Header                                                              */
    /*      Renderer type         (4 bytes) : See "RENDERER_TYPE"               */
    /*      Input configuration   (4 bytes) : See "BINAURAL_INPUT_AUDIO_CONFIG" */
    /*      Sampling Frequency    (4 bytes)                                     */
    /*      Raw data size         (4 bytes)                                     */

    if ( ( fread( &( hrtf_header->rend_type ), sizeof( int32_t ), 1, f_hrtf ) == 1 ) && ( fread( &( hrtf_header->input_cfg ), sizeof( int32_t ), 1, f_hrtf ) == 1 ) && ( fread( &( hrtf_header->frequency ), sizeof( int32_t ), 1, f_hrtf ) == 1 ) && ( fread( &( hrtf_header->data_size ), sizeof( int32_t ), 1, f_hrtf ) == 1 ) )
    {
@@ -786,26 +786,26 @@ static ivas_error create_HRTF_from_rawdata(

    hrtf_data_rptr = hrtf_data;

    // latency_s
    /* latency_s */
    ( *hHRTF )->latency_s = *( (float *) ( hrtf_data_rptr ) );
    hrtf_data_rptr += sizeof( float );

    // max_num_ir
    /* max_num_ir */
    ( *hHRTF )->max_num_ir = *( (uint16_t *) ( hrtf_data_rptr ) );
    hrtf_data_rptr += sizeof( uint16_t );

    // BINAURAL_CHANNELS
    /* BINAURAL_CHANNELS */
    if ( BINAURAL_CHANNELS != *( (int16_t *) ( hrtf_data_rptr ) ) )
    {
        return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file format not compliant (BINAURAL_CHANNELS)" );
    }
    hrtf_data_rptr += sizeof( uint16_t );

    // max_num_iterations
    /* max_num_iterations */
    ( *hHRTF )->max_num_iterations = *( (int16_t *) ( hrtf_data_rptr ) );
    hrtf_data_rptr += sizeof( int16_t );

    // num_iterations
    /* num_iterations */
    for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ )
    {
        for ( j = 0; j < BINAURAL_CHANNELS; j++ )
@@ -815,7 +815,7 @@ static ivas_error create_HRTF_from_rawdata(
        }
    }

    // pIndex_frequency_max
    /* pIndex_frequency_max */
    for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ )
    {
        for ( j = 0; j < BINAURAL_CHANNELS; j++ )
@@ -831,20 +831,20 @@ static ivas_error create_HRTF_from_rawdata(
        }
    }

    // max_num_iterations_diffuse
    /* max_num_iterations_diffuse */
    max_num_iterations_diffuse = *( (int16_t *) ( hrtf_data_rptr ) );
    hrtf_data_rptr += sizeof( int16_t );

    if ( max_num_iterations_diffuse != 0 )
    {
        // num_iterations_diffuse
        /* num_iterations_diffuse */
        for ( j = 0; j < BINAURAL_CHANNELS; j++ )
        {
            ( *hHRTF )->num_iterations_diffuse[j] = *( (uint16_t *) ( hrtf_data_rptr ) );
            hrtf_data_rptr += sizeof( uint16_t );
        }

        // pIndex_frequency_max_diffuse (the size depends on num_iterations_diffuse)
        /* pIndex_frequency_max_diffuse (the size depends on num_iterations_diffuse) */
        for ( j = 0; j < BINAURAL_CHANNELS; j++ )
        {
            mem_size = ( *hHRTF )->num_iterations_diffuse[j] * sizeof( uint16_t );
@@ -858,22 +858,22 @@ static ivas_error create_HRTF_from_rawdata(
        }
    }

    // index_frequency_max_diffuse
    /* index_frequency_max_diffuse */
    ( *hHRTF )->index_frequency_max_diffuse = *( (uint16_t *) ( hrtf_data_rptr ) );
    hrtf_data_rptr += sizeof( uint16_t );

    // inv_diffuse_weight
    /* inv_diffuse_weight */
    for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ )
    {
        ( *hHRTF )->inv_diffuse_weight[i] = *( (float *) ( hrtf_data_rptr ) );
        hrtf_data_rptr += sizeof( float );
    }

    // max_total_num_fsamp_per_iteration
    /* max_total_num_fsamp_per_iteration */
    max_total_num_fsamp_per_iteration = *( (uint16_t *) ( hrtf_data_rptr ) );
    hrtf_data_rptr += sizeof( uint16_t );

    // coeff_re (the size depends on pIndex_frequency_max)
    /* coeff_re (the size depends on pIndex_frequency_max) */
    for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ )
    {
        for ( j = 0; j < BINAURAL_CHANNELS; j++ )
@@ -897,7 +897,7 @@ static ivas_error create_HRTF_from_rawdata(
        }
    }

    // coeff_im (the size depends on pIndex_frequency_max)
    /* coeff_im (the size depends on pIndex_frequency_max) */
    for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ )
    {
        for ( j = 0; j < BINAURAL_CHANNELS; j++ )
@@ -921,13 +921,13 @@ static ivas_error create_HRTF_from_rawdata(
        }
    }

    // max_total_num_fsamp_per_iteration_diff
    /* max_total_num_fsamp_per_iteration_diff */
    max_total_num_fsamp_per_iteration_diff = *( (uint16_t *) ( hrtf_data_rptr ) );
    hrtf_data_rptr += sizeof( uint16_t );

    if ( max_total_num_fsamp_per_iteration_diff != 0 )
    {
        // coeff_diffuse_re : The size depends on pIndex_frequency_max_diffuse
        /* coeff_diffuse_re : The size depends on pIndex_frequency_max_diffuse */
        for ( j = 0; j < BINAURAL_CHANNELS; j++ )
        {
            mem_size = max_total_num_fsamp_per_iteration_diff * sizeof( float );
@@ -948,7 +948,7 @@ static ivas_error create_HRTF_from_rawdata(
            }
        }

        // coeff_diffuse_im : The size depends on pIndex_frequency_max_diffuse
        /* coeff_diffuse_im : The size depends on pIndex_frequency_max_diffuse */
        for ( j = 0; j < BINAURAL_CHANNELS; j++ )
        {
            mem_size = max_total_num_fsamp_per_iteration_diff * sizeof( float );
@@ -1215,7 +1215,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata(
            }
        }

        // Reverb Parameters
        /* Reverb Parameters */
        if ( CLDFB_NO_CHANNELS_MAX != *( (uint16_t *) ( hrtf_data_rptr ) ) )
        {
            return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (CLDFB_NO_CHANNELS_MAX)" );
@@ -1295,7 +1295,7 @@ ivas_error load_fastconv_HRTF_from_binary(
                return IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "Error in HRTF file reading" );
            }

            // Create the HRTF reading the raw data from the binary file
            /* Create the HRTF reading the raw data from the binary file */
            if ( ( create_fastconv_HRTF_from_rawdata( &hHrtfFastConv, hrtf_data, hrtf_header.rend_type, hrtf_header.input_cfg ) ) != IVAS_ERR_OK )
            {
                free( hrtf_data );
@@ -1332,21 +1332,21 @@ static ivas_error create_parambin_HRTF_from_rawdata(

    hrtf_data_rptr = hrtf_data;

    // HRTF_SH_CHANNELS
    /* HRTF_SH_CHANNELS */
    if ( HRTF_SH_CHANNELS != *( (uint16_t *) ( hrtf_data_rptr ) ) )
    {
        return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HRTF_SH_CHANNELS)" );
    }
    hrtf_data_rptr += sizeof( uint16_t );

    // HRTF_NUM_BINS
    /* HRTF_NUM_BINS */
    if ( HRTF_NUM_BINS != *( (uint16_t *) ( hrtf_data_rptr ) ) )
    {
        return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HRTF_NUM_BINS)" );
    }
    hrtf_data_rptr += sizeof( uint16_t );

    // HRTF
    /* HRTF */
    data_size_tmp = HRTF_NUM_BINS * sizeof( float );
    for ( i = 0; i < BINAURAL_CHANNELS; i++ )
    {
@@ -1365,7 +1365,7 @@ static ivas_error create_parambin_HRTF_from_rawdata(
        }
    }

    // Reverb Parameters
    /* Reverb Parameters */
    if ( CLDFB_NO_CHANNELS_MAX != *( (uint16_t *) ( hrtf_data_rptr ) ) )
    {
        return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (CLDFB_NO_CHANNELS_MAX)" );
@@ -1445,7 +1445,7 @@ ivas_error load_parambin_HRTF_from_binary(
                return IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "Error in HRTF file reading" );
            }

            // Create the HRTF reading the raw data from the binary file
            /* Create the HRTF reading the raw data from the binary file */
            if ( ( create_parambin_HRTF_from_rawdata( &hHrtfParamBin, hrtf_data ) ) != IVAS_ERR_OK )
            {
                free( hrtf_data );
@@ -1559,6 +1559,7 @@ ivas_error create_SetOfHRTF_from_binary(

    if ( ( ( *hSetOfHRTF ).hHRTF_hrir_combined == NULL ) || ( ( *hSetOfHRTF ).hHRTF_brir_combined == NULL ) || ( ( *hSetOfHRTF ).hHRTF_hrir_hoa3 == NULL ) )
    {
        // VE2AT: Makefile build returns "undefined reference to `destroy_SetOfHRTF'"; MSCV is happy...
        destroy_SetOfHRTF( hSetOfHRTF );
        return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Could not create all the HRTF from binary file" );
    }