Commit a489d692 authored by Jan Brouwer's avatar Jan Brouwer
Browse files

initialize memory pointers for safe freeing, correct handling of REVERBFILE...

initialize memory pointers for safe freeing, correct handling of REVERBFILE parsing in render_config_reader.c
only print max quantization errors if greater than float32 resolution in text_to_binary_payload.py
parent e7b4161c
Loading
Loading
Loading
Loading
Loading
+23 −5
Original line number Diff line number Diff line
@@ -903,7 +903,7 @@ static ivas_error get_distance(

static ivas_error get_absorption(
    RenderConfigReader *this, /* i/o  : Render config reader handle */
    float *pResult            /* o    : Distance value              */
    float *pResult            /* o    : Absorption value            */
)
{
    ivas_error error;
@@ -1004,6 +1004,15 @@ static int16_t read_vector(
}


#ifdef CONTROL_METADATA_REVERB
/*-----------------------------------------------------------------------------------------*
 * Function strip_spaces()
 *
 * Strips the spaces from a buffer
 *-----------------------------------------------------------------------------------------*/

static void strip_spaces(
#else
/*-----------------------------------------------------------------------------------------*
 * Function strip_spaces_upper()
 *
@@ -1011,6 +1020,7 @@ static int16_t read_vector(
 *-----------------------------------------------------------------------------------------*/

static void strip_spaces_upper(
#endif
    char *pStr /* i  : String to read from */
)
{
@@ -1025,7 +1035,9 @@ static void strip_spaces_upper(
        read_idx++;
    }
    pStr[write_idx] = '\0';
#ifndef CONTROL_METADATA_REVERB
    to_upper( pStr );
#endif

    return;
}
@@ -1521,6 +1533,9 @@ static ivas_error RenderConfigReader_readReverb(
            {
                return IVAS_ERR_FAILED_ALLOC;
            }
            /* Initialize memory pointers to allow safe freeing ico eg errors */
            pRenderConfigReader->pAE[n].pEarlyReflections->pAbsCoeff = 0;
            pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin = 0;

            /* Room sizes */
            if ( ( error = get_distance( pRenderConfigReader, true, &pRenderConfigReader->pAE[n].pEarlyReflections->dimensions.x ) ) != IVAS_ERR_OK )
@@ -1682,7 +1697,13 @@ ivas_error RenderConfigReader_read(
            /* go back one line */
            fseek( pRenderConfigReader->pConfigFile, read_idx, SEEK_SET );

#ifdef CONTROL_METADATA_REVERB
            strip_spaces( pParams );
            strcpy( pTemp, pParams );
            to_upper( pParams );
#else
            strip_spaces_upper( pParams );
#endif
            to_upper( chapter );

            /* interpret params */
@@ -1938,11 +1959,8 @@ void RenderConfigReader_close(
    {
#ifdef CONTROL_METADATA_EARLY_REFLECTIONS
        if ( ( *ppRenderConfigReader )->pAE[n].pEarlyReflections != NULL )
        {
            if ( ( *ppRenderConfigReader )->pAE[n].pEarlyReflections->pListenerOrigin != NULL )
        {
            free( ( *ppRenderConfigReader )->pAE[n].pEarlyReflections->pListenerOrigin );
            }
            free( ( *ppRenderConfigReader )->pAE[n].pEarlyReflections->pAbsCoeff );
            free( ( *ppRenderConfigReader )->pAE[n].pEarlyReflections );
        }
+9 −6
Original line number Diff line number Diff line
@@ -152,9 +152,12 @@ if __name__ == "__main__":
    parse_reverb_text_configuration_and_generate_binary_payload(args.configuration_file)

    print("\nNote: the conversion algorithm uses quantization, which may lead to quantization errors.")
    print('Maximum relative quantization errors:')
    print('    duration  : {:.1e}'.format(max_quantization_error['duration']))
    print('    frequency : {:.1e}'.format(max_quantization_error['frequency']))
    print('    DSR       : {:.1e}'.format(max_quantization_error['dsr']))
    print('    distance  : {:.1e}'.format(max_quantization_error['distance']))
    print('    absorption: {:.1e}'.format(max_quantization_error['absorption']))

    # print maximum quantization errors exceeding float32 resolution
    epsilon = 2e-7  # slighly larger than float32 epsilon
    text = ''
    for name in max_quantization_error.keys():
        if max_quantization_error[name] > epsilon:
           text += '\n    {:10s}: {:.1e}'.format(name, max_quantization_error[name])
    if len(text) > 0:
        print('Maximum relative quantization errors > {}:'.format(epsilon) + text)
 No newline at end of file