Commit 3fe07f2d authored by malenov's avatar malenov
Browse files

front-end and back-end (reset_mem(), print_mem())

parent 4c9c3530
Loading
Loading
Loading
Loading
+10 −64
Original line number Diff line number Diff line
@@ -30,6 +30,9 @@

*******************************************************************************************************/

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "lib_dec.h"
#include "cmdl_tools.h"
#include "audio_file_writer.h"
@@ -41,21 +44,10 @@
#include "head_rotation_file_reader.h"
#include "jbm_file_writer.h"
#include "evs_rtp_payload.h"
#include <stdio.h>
#include <string.h>
#ifdef WMOPS
#include "PROM_Size_lib_com.h"
#include "PROM_Size_lib_dec.h"
#include "wmc_auto.h"
#endif
#ifdef RAM_COUNTING_TOOL
#include "mem_count.h"
#else
#include <stdlib.h>
#endif
#ifdef DEBUGGING
#include "debug.h"
#endif
#include "wmc_auto.h"
#include "render_config_reader.h"


@@ -142,41 +134,6 @@ static IVAS_DEC_FORCED_REND_MODE parseForcedRendModeDec( char *forcedRendModeCha
#endif


#ifdef WMOPS
/*------------------------------------------------------------------------------------------*
 * Function to print complexity & memory estimates at the decoder
 *------------------------------------------------------------------------------------------*/

extern int16_t *ptr_base_stack;
extern int16_t *ptr_base_stack;
extern int16_t *ptr_max_stack;
extern int32_t wc_frame;
extern char location_max_stack[256];
void print_stack_call_tree( void );

static void print_mem_dec( size_t SRAM_size )
{
    fprintf( stdout, "\n\n --- Decoder memory usage ---  \n\n" );

    fprintf( stdout, "PROM size (decoder):                      %d words (or instructions)\n", PROM_Size_lib_dec );
    fprintf( stdout, "PROM size (common):                       %d words (or instructions)\n", PROM_Size_lib_com );
    fprintf( stdout, "Stack size (decoder):                     %ld words in %s() in frame #%d\n", ( ( ptr_base_stack - ptr_max_stack ) * sizeof( int16_t ) ) / sizeof( float ), location_max_stack, wc_frame );
    fprintf( stdout, "Table ROM size (decoder):                 %ld words\n", ( Const_Data_Size_rom_dec() + Const_Data_Size_ivas_rom_dec() ) / sizeof( float ) );
    fprintf( stdout, "Table ROM size (binaural renderer):       %ld words\n", ( Const_Data_Size_ivas_rom_binauralRen() + Const_Data_Size_ivas_rom_TdBinauralR() + Const_Data_Size_ivas_rom_binaural_cr() ) / sizeof( float ) );
    fprintf( stdout, "Table ROM size (common):                  %ld words\n", ( Const_Data_Size_rom_com() + Const_Data_Size_ivas_rom_com() ) / sizeof( float ) );
#ifdef RAM_COUNTING_TOOL
    fprintf( stdout, "Static RAM size (decoder):                %ld words\n\n", SRAM_size );
#endif
    print_stack_call_tree();

    fprintf( stdout, "Note: this is an optimistic estimate of the memory consumption assuming\n" );
    fprintf( stdout, "      that each variable (short, long or float) in the codec requires\n" );
    fprintf( stdout, "      32 bits of memory and may therefore be represented by 1 word.\n" );
    fprintf( stdout, "      The following formula is used: sizeof('memory array')/sizeof(float)\n\n" );
}
#endif


/*------------------------------------------------------------------------------------------*
 * main()
 *
@@ -205,20 +162,10 @@ int main(
#endif
#endif

#ifdef WMOPS
    size_t SRAM_size = 0;
    reset_stack();
    reset_wmops();
#endif

#ifdef DEBUGGING
    dbgargs( &argc, argv );
#endif

#ifdef RAM_COUNTING_TOOL
    mem_count_init( 0, USE_32BITS );
#endif

    /*------------------------------------------------------------------------------------------*
     * Parse command-line arguments
     *------------------------------------------------------------------------------------------*/
@@ -497,6 +444,11 @@ int main(
        }
    }

#ifdef WMOPS
    reset_wmops();
    rest_mem( USE_32BITS );
#endif

    /*-----------------------------------------------------------------*
     * Decoding
     *-----------------------------------------------------------------*/
@@ -574,15 +526,9 @@ cleanup:
        fprintf( stderr, "\nError while closing file: %s\nContinuing...\n\n", arg.inputBitstreamFilename );
    }

#ifdef RAM_COUNTING_TOOL
#ifdef WMOPS
    SRAM_size =
#endif
        mem_count_summary( USE_DEFAULT );
#endif
#ifdef WMOPS
    print_wmops();
    print_mem_dec( SRAM_size );
    print_mem();
#endif

    if ( !arg.quietModeEnabled )
+6 −65
Original line number Diff line number Diff line
@@ -30,6 +30,9 @@

*******************************************************************************************************/

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "lib_enc.h"
#include "cmdl_tools.h"
#include "audio_file_reader.h"
@@ -37,25 +40,13 @@
#include "jbm_file_reader.h"
#include "masa_file_reader.h"
#include "ism_file_reader.h"
#include <stdio.h>
#include <string.h>
#ifdef WMOPS
#include "PROM_Size_lib_com.h"
#include "PROM_Size_lib_enc.h"
#include "wmc_auto.h"
#endif
#ifdef RAM_COUNTING_TOOL
#include "mem_count.h"
#else
#include <stdlib.h>
#endif
#ifdef DEBUGGING
#include "debug.h"
#endif
#include "wmc_auto.h"

#define WMC_TOOL_SKIP


/*------------------------------------------------------------------------------------------*
 * Local constants, enums, structures
 *------------------------------------------------------------------------------------------*/
@@ -154,40 +145,6 @@ static IVAS_ENC_FORCED_MODE parseForcedMode( char *forcedModeChar );
#endif


#ifdef WMOPS
/*------------------------------------------------------------------------------------------*
 * Function to print complexity & memory estimates at the encoder
 *------------------------------------------------------------------------------------------*/

extern int16_t *ptr_base_stack;
extern int16_t *ptr_base_stack;
extern int16_t *ptr_max_stack;
extern int32_t wc_frame;
extern char location_max_stack[256];
void print_stack_call_tree( void );

static void print_mem_enc( size_t SRAM_size )
{
    fprintf( stdout, "\n\n --- Encoder memory usage ---  \n\n" );

    fprintf( stdout, "PROM size (encoder):                      %d words (or instructions)\n", PROM_Size_lib_enc );
    fprintf( stdout, "PROM size (common):                       %d words (or instructions)\n", PROM_Size_lib_com );
    fprintf( stdout, "Stack size (encoder):                     %ld words in %s() in frame #%d\n", ( ( ptr_base_stack - ptr_max_stack ) * sizeof( int16_t ) ) / sizeof( float ), location_max_stack, wc_frame );
    fprintf( stdout, "Table ROM size (encoder):                 %ld words\n", ( Const_Data_Size_rom_enc() + Const_Data_Size_ivas_rom_enc() ) / sizeof( float ) );
    fprintf( stdout, "Table ROM size (common):                  %ld words\n", ( Const_Data_Size_rom_com() + Const_Data_Size_ivas_rom_com() ) / sizeof( float ) );
#ifdef RAM_COUNTING_TOOL
    fprintf( stdout, "Static RAM size (encoder):                %ld words\n\n", SRAM_size );
#endif
    print_stack_call_tree();

    fprintf( stdout, "Note: this is an optimistic estimate of the memory consumption assuming\n" );
    fprintf( stdout, "      that each variable (short, long or float) in the codec requires\n" );
    fprintf( stdout, "      32 bits of memory and may therefore be represented by 1 word.\n" );
    fprintf( stdout, "      The following formula is used: sizeof('memory array')/sizeof(float)\n\n" );
}
#endif


/*------------------------------------------------------------------------------------------*
 * main()
 *
@@ -224,20 +181,10 @@ int main(
#endif
#endif

#ifdef WMOPS
    size_t SRAM_size = 0;
    reset_wmops();
    reset_stack();
#endif

#ifdef DEBUGGING
    dbgargs( &argc, argv );
#endif

#ifdef RAM_COUNTING_TOOL
    mem_count_init( 0, USE_32BITS );
#endif

    initArgStruct( &arg );

    /*------------------------------------------------------------------------------------------*
@@ -600,8 +547,8 @@ int main(
    }

#ifdef WMOPS
    reset_stack();
    reset_wmops();
    reset_mem( USE_32BITS );
#endif

    /*------------------------------------------------------------------------------------------*
@@ -829,15 +776,9 @@ cleanup:

    IVAS_ENC_Close( &hIvasEnc );

#ifdef RAM_COUNTING_TOOL
#ifdef WMOPS
    SRAM_size =
#endif
        mem_count_summary( USE_DEFAULT );
#endif
#ifdef WMOPS
    print_wmops();
    print_mem_enc( SRAM_size );
    print_mem( );
#endif

#ifdef DEBUGGING
+9 −74
Original line number Diff line number Diff line
@@ -30,6 +30,13 @@

*******************************************************************************************************/

#include <assert.h>
#include <ctype.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "options.h"
#include "debug.h"
#include "audio_file_reader.h"
@@ -45,33 +52,9 @@
#include "masa_file_reader.h"
#include "prot.h"
#include "render_config_reader.h"
#ifdef WMOPS
#include "PROM_Size_lib_rend.h"
#include "wmc_auto.h"
#endif
#ifdef RAM_COUNTING_TOOL
#include "mem_count.h"
#endif
#include <assert.h>
#include <ctype.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>

#ifdef EXT_RENDERER
#ifndef count_malloc
#ifdef RAM_COUNTING_TOOL
#define count_malloc( n1 )     MALLOC_FCT_CALL( n1 )
#define count_calloc( n1, n2 ) CALLOC_FCT_CALL( n1, n2 )
#define count_free( ptr )      FREE_FCT_CALL( ptr )
#else
#define count_malloc( n1 )     malloc( n1 )
#define count_calloc( n1, n2 ) calloc( n1, n2 )
#define count_free( ptr )      free( ptr )
#endif
#endif

#ifndef min
#define min( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) )
@@ -96,37 +79,6 @@ static
#define SEP_FOLDER '/'
#endif

#ifdef WMOPS
void print_stack_call_tree( void );
int Const_Data_Size_ivas_rom_rend( void );
extern int16_t *ptr_base_stack;
extern int16_t *ptr_max_stack;
extern int32_t wc_frame;
extern char location_max_stack[256];

/*------------------------------------------------------------------------------------------*
 * Function to print complexity & memory estimates
 *------------------------------------------------------------------------------------------*/
static void print_mem_renderer( size_t SRAM_size )
{
    fprintf( stdout, "\n\n --- Renderer memory usage ---  \n\n" );

    fprintf( stdout, "PROM size (renderer):                     %d words (or instructions)\n", PROM_Size_lib_rend );
    fprintf( stdout, "Stack size:                               %d words in %s() in frame #%d\n", ( ptr_base_stack - ptr_max_stack ) * sizeof( int16_t ) / sizeof( float ), location_max_stack, wc_frame );
    fprintf( stdout, "Table ROM size(renderer):                 %d words\n", ( Const_Data_Size_ivas_rom_rend() ) / sizeof( float ) );
    fprintf( stdout, "Table ROM size (binaural renderer):       %ld words\n", ( Const_Data_Size_ivas_rom_binauralRen() + Const_Data_Size_ivas_rom_TdBinauralR() + Const_Data_Size_ivas_rom_binaural_cr() ) / sizeof( float ) );
#ifdef RAM_COUNTING_TOOL
    fprintf( stdout, "Static RAM size:                          %d words\n\n", SRAM_size );
#endif
    print_stack_call_tree();

    fprintf( stdout, "Note: this is an optimistic estimate of the memory consumption assuming\n" );
    fprintf( stdout, "      that each variable (short, long or float) in the codec requires\n" );
    fprintf( stdout, "      32 bits of memory and may therefore be represented by 1 word.\n" );
    fprintf( stdout, "      The following formula is used: sizeof('memory array')/sizeof(float)\n\n" );
}
#endif

typedef struct
{
    uint32_t frameCounter;
@@ -595,18 +547,6 @@ int main(
    int32_t delayTimeScale = 0;
    int16_t i, numChannels;
    ivas_error error = IVAS_ERR_OK;
#ifdef WMOPS
    size_t SRAM_size;
#endif

#ifdef WMOPS
    reset_wmops();
    reset_stack();
#endif

#ifdef RAM_COUNTING_TOOL
    mem_count_init( 0, USE_32BITS );
#endif

    for ( i = 0; i < RENDERER_MAX_MASA_INPUTS; ++i )
    {
@@ -856,6 +796,7 @@ int main(

#ifdef WMOPS
    reset_wmops();
    reset_mem( USE_32BITS );
#endif

    if ( !args.quietModeEnabled )
@@ -1107,15 +1048,9 @@ int main(
    IsmPositionProvider_close( positionProvider );
    RenderConfigReader_close( &renderConfigReader );

#ifdef RAM_COUNTING_TOOL
#ifdef WMOPS
    SRAM_size =
#endif
        mem_count_summary( USE_DEFAULT );
#endif
#ifdef WMOPS
    print_wmops();
    print_mem_renderer( SRAM_size );
    print_mem();
#endif

    return 0;
+0 −1
Original line number Diff line number Diff line
@@ -41,7 +41,6 @@
/* ################### Start compiler switches ######################## */

#define SUPPORT_JBM_TRACEFILE                   /* support for JBM tracefile, which is needed for 3GPP objective/subjective testing, but not relevant for real-world implementations */
#define RAM_COUNTING_TOOL                       /* tool to automatically count the dynamically alocated static memory consumption */

/* #################### End compiler switches ######################### */

+2 −24
Original line number Diff line number Diff line
@@ -37,15 +37,13 @@
#ifndef PROT_H
#define PROT_H

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "options.h"
#ifdef DEBUGGING
#include "debug.h"
#endif
#include <stdio.h>
#ifndef RAM_COUNTING_TOOL
#include <stdlib.h>
#endif
#include "typedef.h"
#include "stat_enc.h"
#include "stat_dec.h"
@@ -55,28 +53,8 @@
#include "ivas_stat_dec.h"
#include "cnst.h"
#include "stl.h"
#ifdef RAM_COUNTING_TOOL
#include "mem_count.h"
#endif
#include "ivas_error_utils.h"

/*----------------------------------------------------------------------------------*
 * Prototypes of RAM counting tool macros
 *----------------------------------------------------------------------------------*/

#ifdef RAM_COUNTING_TOOL
#define count_malloc( n1 )     MALLOC_FCT_CALL( n1 )
#define count_calloc( n1, n2 ) CALLOC_FCT_CALL( n1, n2 )
#define count_free( ptr )      FREE_FCT_CALL( ptr )
#else
#define count_malloc( n1 )     malloc( n1 )
#define count_calloc( n1, n2 ) calloc( n1, n2 )
#define count_free( ptr )      free( ptr )
#endif

#define dynamic_malloc( n1 )     malloc( n1 )
#define dynamic_calloc( n1, n2 ) calloc( n1, n2 )
#define dynamic_free( n1 )       free( n1 )

/*----------------------------------------------------------------------------------*
 * Prototypes of global macros
Loading