Commit 0b2b7dd8 authored by lefort's avatar lefort
Browse files

Default binary files with parametric. Minor changes for table_format_converter tool.

parent 8901d207
Loading
Loading
Loading
Loading
+39 −45
Original line number Diff line number Diff line
@@ -53,9 +53,7 @@

#define DEFAULT_INPUT_ROM_FILE    "ivas_binaural"
#define DEFAULT_INPUT_TD_BIN_FILE "hrfilter_model"
#define DEFAULT_ROM_FILE_EXT      ".c"
#define DEFAULT_BIN_FILE_EXT      ".bin"
#define DECLARATION_NAME          "CRendBin"

#define IVAS_NB_RENDERER_TYPE 7
#define IVAS_NB_AUDIO_CONFIG  2
@@ -85,7 +83,7 @@ const int16_t file_identifier_len = 8;
 * Structures declaration
 *------------------------------------------------------------------------------------------ */

typedef struct _hrtf_tables_dimensions
typedef struct _crend_hrtf_tables_dimensions
{
    int16_t max_num_ir;
    int16_t max_num_iterations;
@@ -93,9 +91,9 @@ typedef struct _hrtf_tables_dimensions
    uint16_t max_total_num_fsamp_per_iteration;
    uint16_t max_total_num_fsamp_per_iteration_diff;

} hrtf_tables_dimensions;
} crend_hrtf_tables_dimensions;

typedef struct _hrtf_tables_pointers
typedef struct _crend_hrtf_tables_pointers
{
    float *latency_s;
    uint16_t *num_iterations;
@@ -109,7 +107,7 @@ typedef struct _hrtf_tables_pointers
    float *coeff_diffuse_re;
    float *coeff_diffuse_im;

} hrtf_tables_pointers;
} crend_hrtf_tables_pointers;

/*---------------------------------------------------------------------*
 * Local function prototypes
@@ -121,19 +119,19 @@ void rom2bin_terminat( void );
char *to_upper( char *str );

char *create_hrtf_crend( RENDERER_TYPE rend_type, BINAURAL_INPUT_AUDIO_CONFIG input_cfg, int32_t frequency, int32_t *hrtf_size /*OUT*/ );
char *create_hrtf_fastconv(
    RENDERER_TYPE rend_type,
    BINAURAL_INPUT_AUDIO_CONFIG input_cfg,
    int32_t frequency,
    int32_t *hrtf_size );
char *create_hrtf_fastconv( RENDERER_TYPE rend_type, BINAURAL_INPUT_AUDIO_CONFIG input_cfg, int32_t frequency, int32_t *hrtf_size );
char *create_hrtf_parametric( int32_t *hrtf_size );
char *create_hrtf_tdrend( int32_t frequency, int32_t *hrtf_size /*OUT*/ );

int32_t read_hrtf_size( char *hrtf );
int16_t check_bin_file( FILE *hrtf_bin_file );
int16_t get_hrtf_tables( RENDERER_TYPE rend_type, BINAURAL_INPUT_AUDIO_CONFIG input_cfg, int32_t frequency, hrtf_tables_pointers *hrtf_table_ptrs /*OUT*/, hrtf_tables_dimensions *hrtf_table_dims /*OUT*/ );
int32_t compute_hrtf_data_size( hrtf_tables_pointers *hrtf_table_ptrs, hrtf_tables_dimensions *hrtf_table_dims );
int16_t check_hrtf_data( RENDERER_TYPE rend_type, BINAURAL_INPUT_AUDIO_CONFIG input_cfg, int32_t frequency, char *hrtf_data_in, int32_t hrtf_size_in );

/*---------------------------------------------------------------------*/

int16_t get_crend_hrtf_tables( RENDERER_TYPE rend_type, BINAURAL_INPUT_AUDIO_CONFIG input_cfg, int32_t frequency, crend_hrtf_tables_pointers *hrtf_table_ptrs /*OUT*/, crend_hrtf_tables_dimensions *hrtf_table_dims /*OUT*/ );
int32_t compute_crend_hrtf_data_size( crend_hrtf_tables_pointers *hrtf_table_ptrs, crend_hrtf_tables_dimensions *hrtf_table_dims );

/*---------------------------------------------------------------------*
 * usage_gen_crend_tables()
 *
@@ -441,8 +439,8 @@ int main( int argc, char *argv[] )
 *---------------------------------------------------------------------*/
char *create_hrtf_crend( RENDERER_TYPE rend_type, BINAURAL_INPUT_AUDIO_CONFIG input_cfg, int32_t frequency, int32_t *hrtf_size )
{
    hrtf_tables_dimensions tabs_dims;
    hrtf_tables_pointers tabs_ptrs;
    crend_hrtf_tables_dimensions tabs_dims;
    crend_hrtf_tables_pointers tabs_ptrs;

    /*   uint16_t max_num_iterations, max_num_iterations_diffuse, index_frequency_max_diffuse; */
    uint16_t *pIndex_rptr, iChan, iIR;
@@ -453,8 +451,8 @@ char *create_hrtf_crend( RENDERER_TYPE rend_type, BINAURAL_INPUT_AUDIO_CONFIG in
    float *coeff_rptr;
    char *hrtf = NULL, *hrtf_wptr;

    memset( &tabs_dims, 0x00, sizeof( hrtf_tables_dimensions ) );
    memset( &tabs_ptrs, 0x00, sizeof( hrtf_tables_pointers ) );
    memset( &tabs_dims, 0x00, sizeof( crend_hrtf_tables_dimensions ) );
    memset( &tabs_ptrs, 0x00, sizeof( crend_hrtf_tables_pointers ) );
    hrtf_data_size = 0;
    *hrtf_size = 0;

@@ -462,32 +460,32 @@ char *create_hrtf_crend( RENDERER_TYPE rend_type, BINAURAL_INPUT_AUDIO_CONFIG in

            latency_s => float

            max_num_ir => New: uint16_t
            BINAURAL_CHANNELS => New: uint16_t (BINAURAL_CHANNELS)
            max_num_ir => uint16_t
            BINAURAL_CHANNELS => uint16_t (BINAURAL_CHANNELS)

            max_num_iterations => int16_t
            num_iterations => uint16_t[max_num_ir][BINAURAL_CHANNELS]
            pIndex_frequency_max => uint16_t[max_num_ir][BINAURAL_CHANNELS][max_num_iterations] (Pointer)

            max_num_iterations_diffuse => New: int16_t
            max_num_iterations_diffuse => int16_t
            num_iterations_diffuse => uint16_t[BINAURAL_CHANNELS]
            pIndex_frequency_max_diffuse => uint16_t[BINAURAL_CHANNELS][max_num_iterations_diffuse] (Pointer)

            index_frequency_max_diffuse => uint16_t
            inv_diffuse_weight => float[max_num_ir]

            max_total_num_fsamp_per_iteration => New: uint16_t
            max_total_num_fsamp_per_iteration => uint16_t
            coeff_re => float[max_num_ir][BINAURAL_CHANNELS][max_total_num_fsamp_per_iteration] (Pointer)
            coeff_im => float[max_num_ir][BINAURAL_CHANNELS][max_total_num_fsamp_per_iteration] (Pointer)

            max_total_num_fsamp_per_iteration_diff => New: uint16_t
            max_total_num_fsamp_per_iteration_diff => uint16_t
            coeff_diffuse_re => float[BINAURAL_CHANNELS][max_total_num_fsamp_per_iteration] (Pointer)
            coeff_diffuse_im => float[BINAURAL_CHANNELS][max_total_num_fsamp_per_iteration] (Pointer)
    */

    // First, get the tables and the relative dimensions

    if ( get_hrtf_tables( rend_type, input_cfg, frequency, &tabs_ptrs, &tabs_dims ) == -1 )
    if ( get_crend_hrtf_tables( rend_type, input_cfg, frequency, &tabs_ptrs, &tabs_dims ) == -1 )
    {
        fprintf( stderr, "Get table failed!\n\n" );
        free( hrtf );
@@ -504,7 +502,7 @@ char *create_hrtf_crend( RENDERER_TYPE rend_type, BINAURAL_INPUT_AUDIO_CONFIG in

    // Then, determine the block size

    hrtf_data_size = compute_hrtf_data_size( &tabs_ptrs, &tabs_dims );
    hrtf_data_size = compute_crend_hrtf_data_size( &tabs_ptrs, &tabs_dims );

    // Header [Declaration of the HRTF]
    //      Renderer type          (4 bytes) : See "RENDERER_TYPE"
@@ -753,11 +751,7 @@ char *create_hrtf_tdrend( int32_t frequency, int32_t *hrtf_size )
 * create_hrtf_fastconv()
 *
 *---------------------------------------------------------------------*/
char *create_hrtf_fastconv(
    RENDERER_TYPE rend_type,
    BINAURAL_INPUT_AUDIO_CONFIG input_cfg,
    int32_t frequency,
    int32_t *hrtf_size )
char *create_hrtf_fastconv( RENDERER_TYPE rend_type, BINAURAL_INPUT_AUDIO_CONFIG input_cfg, int32_t frequency, int32_t *hrtf_size )
{
    char *hrtf = NULL, *hrtf_wptr;
    uint32_t hrtf_data_size;
@@ -1180,20 +1174,20 @@ char *create_hrtf_parametric( int32_t *hrtf_size )
}

/*---------------------------------------------------------------------*
 * get_hrtf_tables()
 * get_crend_hrtf_tables()
 *
 *---------------------------------------------------------------------*/
int16_t get_hrtf_tables( RENDERER_TYPE rend_type, BINAURAL_INPUT_AUDIO_CONFIG input_cfg, int32_t frequency, hrtf_tables_pointers *hrtf_table_ptrs /*OUT*/, hrtf_tables_dimensions *hrtf_table_dims /*OUT*/ )
int16_t get_crend_hrtf_tables( RENDERER_TYPE rend_type, BINAURAL_INPUT_AUDIO_CONFIG input_cfg, int32_t frequency, crend_hrtf_tables_pointers *hrtf_table_ptrs /*OUT*/, crend_hrtf_tables_dimensions *hrtf_table_dims /*OUT*/ )
{
    int16_t result = -1;
    uint16_t iChan, iIR, iIter, iIndex, max_num_iterations;
    uint16_t total_num_fsamp_per_iteration, total_num_fsamp_per_iteration_diff;

    hrtf_tables_pointers hrtf_table_ptrs_out;
    hrtf_tables_dimensions hrtf_table_dims_out;
    crend_hrtf_tables_pointers hrtf_table_ptrs_out;
    crend_hrtf_tables_dimensions hrtf_table_dims_out;

    memset( &hrtf_table_ptrs_out, 0x00, sizeof( hrtf_tables_pointers ) );
    memset( &hrtf_table_dims_out, 0x00, sizeof( hrtf_tables_dimensions ) );
    memset( &hrtf_table_ptrs_out, 0x00, sizeof( crend_hrtf_tables_pointers ) );
    memset( &hrtf_table_dims_out, 0x00, sizeof( crend_hrtf_tables_dimensions ) );

    if ( rend_type == RENDERER_BINAURAL_MIXER_CONV )
    {
@@ -1471,22 +1465,22 @@ int16_t get_hrtf_tables( RENDERER_TYPE rend_type, BINAURAL_INPUT_AUDIO_CONFIG in
    // Copy the results
    if ( ( result == 0 ) && ( hrtf_table_ptrs != NULL ) )
    {
        memcpy( hrtf_table_ptrs, &hrtf_table_ptrs_out, sizeof( hrtf_tables_pointers ) );
        memcpy( hrtf_table_ptrs, &hrtf_table_ptrs_out, sizeof( crend_hrtf_tables_pointers ) );
    }

    if ( ( result == 0 ) && ( hrtf_table_dims != NULL ) )
    {
        memcpy( hrtf_table_dims, &hrtf_table_dims_out, sizeof( hrtf_tables_dimensions ) );
        memcpy( hrtf_table_dims, &hrtf_table_dims_out, sizeof( crend_hrtf_tables_dimensions ) );
    }

    return result;
}

/*---------------------------------------------------------------------*
 * compute_hrtf_data_size()
 * compute_crend_hrtf_data_size()
 *
 *---------------------------------------------------------------------*/
int32_t compute_hrtf_data_size( hrtf_tables_pointers *hrtf_table_ptrs, hrtf_tables_dimensions *hrtf_table_dims )
int32_t compute_crend_hrtf_data_size( crend_hrtf_tables_pointers *hrtf_table_ptrs, crend_hrtf_tables_dimensions *hrtf_table_dims )
{
    int32_t hrtf_data_size = 0;
    int32_t iChan, iIR, iIndex, iIter;
@@ -1703,8 +1697,8 @@ int16_t check_hrtf_data( RENDERER_TYPE rend_type, BINAURAL_INPUT_AUDIO_CONFIG in
    float *coeff_rptr;
    char *hrtf_data_in_rptr;

    hrtf_tables_dimensions tabs_dims;
    hrtf_tables_pointers tabs_ptrs;
    crend_hrtf_tables_dimensions tabs_dims;
    crend_hrtf_tables_pointers tabs_ptrs;

    if ( rend_type == RENDERER_BINAURAL_OBJECTS_TD ||
         rend_type == RENDERER_BINAURAL_FASTCONV || rend_type == RENDERER_BINAURAL_FASTCONV_ROOM ||
@@ -1713,15 +1707,15 @@ int16_t check_hrtf_data( RENDERER_TYPE rend_type, BINAURAL_INPUT_AUDIO_CONFIG in
        return 0;
    }

    memset( &tabs_dims, 0x00, sizeof( hrtf_tables_dimensions ) );
    memset( &tabs_ptrs, 0x00, sizeof( hrtf_tables_pointers ) );
    memset( &tabs_dims, 0x00, sizeof( crend_hrtf_tables_dimensions ) );
    memset( &tabs_ptrs, 0x00, sizeof( crend_hrtf_tables_pointers ) );

    hrtf_data_size = 0;
    result = 0;

    // First, determine the block size

    if ( get_hrtf_tables( rend_type, input_cfg, frequency, &tabs_ptrs, &tabs_dims ) == -1 )
    if ( get_crend_hrtf_tables( rend_type, input_cfg, frequency, &tabs_ptrs, &tabs_dims ) == -1 )
    {
        fprintf( stderr, "Get table's dimensions failed!\n\n" );
        return -1;
@@ -1732,7 +1726,7 @@ int16_t check_hrtf_data( RENDERER_TYPE rend_type, BINAURAL_INPUT_AUDIO_CONFIG in
        return -1;
    }

    hrtf_data_size = compute_hrtf_data_size( &tabs_ptrs, &tabs_dims );
    hrtf_data_size = compute_crend_hrtf_data_size( &tabs_ptrs, &tabs_dims );

    if ( hrtf_data_size != hrtf_size_in )
    {