From 5dc8dc739ccb8f69b15542e569430905e760f1c6 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Fri, 13 Jan 2023 13:13:09 +0100 Subject: [PATCH 1/7] [cleanup] accept BRATE_SWITCHING_RENDERING --- lib_com/ivas_prot.h | 2 - lib_com/options.h | 1 - lib_debug/coan_out_000000 | 924 ++++++++++++++++++++ lib_dec/ivas_corecoder_dec_reconfig.c | 2 - lib_dec/ivas_dirac_dec_binaural_functions.c | 12 - lib_dec/ivas_sba_dec.c | 112 --- lib_rend/ivas_binauralRenderer.c | 2 - lib_rend/ivas_binaural_reverb.c | 2 - 8 files changed, 924 insertions(+), 133 deletions(-) create mode 100644 lib_debug/coan_out_000000 diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 4ab1098236..336e6f91e9 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3145,14 +3145,12 @@ void ivas_init_dec_get_num_cldfb_instances( int16_t *numCldfbSyntheses /* o : number of CLDFB synthesis instances */ ); -#ifdef BRATE_SWITCHING_RENDERING ivas_error ivas_cldfb_dec_reconfig( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t nchan_transport_old, /* i : number of TCs in previous frame */ int16_t numCldfbAnalyses_old, /* i : number of CLDFB analysis instances in previous frame */ const int16_t numCldfbSyntheses_old /* i : number of CLDFB synthesis instances in previous frame */ ); -#endif /*! r: Ambisonic (SBA) order */ int16_t ivas_sba_get_order( const int16_t nb_channels, /* i : Number of ambisonic channels */ diff --git a/lib_com/options.h b/lib_com/options.h index 471b41f502..bb77a02db8 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -145,7 +145,6 @@ #ifdef SBA_BR_SWITCHING #define SBA_BR_SWITCHING_RECONFIG /* Issue 114: Changes for SBA bitrate switching with reconfiguration for bitrates with different number of transport channels*/ #endif -#define BRATE_SWITCHING_RENDERING /* Bitrate switching changes related to the renderers */ #define FIX_I59_DELAY_ROUNDING /* Issue 59: rounding in sample domain instead of nanosec for IVAS_ENC_GetDelay() and IVAS_DEC_GetDelay() */ #define FIX_FIX_I59 /* Issue 59: small fix concerning LFE delay rounding */ #define MC_BITRATE_SWITCHING /* Issue 116: support bitrate switching in MC format */ diff --git a/lib_debug/coan_out_000000 b/lib_debug/coan_out_000000 new file mode 100644 index 0000000000..bf31e63cef --- /dev/null +++ b/lib_debug/coan_out_000000 @@ -0,0 +1,924 @@ +/* + * (C) 2022 copyright VoiceAge Corporation. All Rights Reserved. + * + * This software is protected by copyright law and by international treaties. The source code, and all of its derivations, + * is provided by VoiceAge Corporation under the "ITU-T Software Tools' General Public License". Please, read the license file + * or refer to ITU-T Recommendation G.191 on "SOFTWARE TOOLS FOR SPEECH AND AUDIO CODING STANDARDS". + * + * Any use of this software is permitted provided that this notice is not removed and that neither the authors nor + * VoiceAge Corporation are deemed to have made any representations as to the suitability of this software + * for any purpose nor are held responsible for any defects of this software. THERE IS NO WARRANTY FOR THIS SOFTWARE. + * + * Authors: Guy Richard, Vladimir Malenovsky (Vladimir.Malenovsky@USherbrooke.ca) + */ + +#ifndef WMOPS_H +#define WMOPS_H + +#ifndef EXIT_FAILURE +#include /* stdlib is needed for exit() */ +#endif + +#ifndef EOF +#include /* stdio is needed for fprintf() */ +#endif + + +/* To Prevent "warning: '$' in identifier or number" message under GCC */ +#ifdef __GNUC__ +#pragma GCC system_header +#endif + +/* Real-time relationships */ +#define FRAMES_PER_SECOND 50.0 +#define MILLION_CYCLES 1e6 +#define WMOPS_BOOST_FAC ( 1.0f ) /* scaling factor for equalizing the difference between automatic and manual instrumentation */ +#define FAC ( FRAMES_PER_SECOND / MILLION_CYCLES * WMOPS_BOOST_FAC ) +#define NUM_INST 20 /* Total number of instruction types (in enum below) */ + + +#ifdef WMOPS +enum instructions +{ + _ADD, + _ABS, + _MULT, + _MAC, + _MOVE, + _STORE, + _LOGIC, + _SHIFT, + _BRANCH, + _DIV, + _SQRT, + _TRANS, + _FUNC, + _LOOP, + _INDIRECT, + _PTR_INIT, + _TEST, + _POWER, + _LOG, + _MISC +}; + +#define _ADD_C 1 +#define _ABS_C 1 +#define _MULT_C 1 +#define _MAC_C 1 +#define _MOVE_C 1 +#define _STORE_C 1 +#define _LOGIC_C 1 +#define _SHIFT_C 1 +#define _BRANCH_C 4 +#define _DIV_C 18 +#define _SQRT_C 10 +#define _TRANS_C 25 +#define _FUNC_C 2 /* need to add number of arguments */ +#define _LOOP_C 3 +#define _INDIRECT_C 2 +#define _PTR_INIT_C 1 +#define _TEST_C 2 +#define _POWER_C 25 +#define _LOG_C 25 +#define _MISC_C 1 + +#define _ADD_P 1 +#define _ABS_P 1 +#define _MULT_P 1 +#define _MAC_P 1 +#define _MOVE_P 1 +#define _STORE_P 0 +#define _LOGIC_P 1 +#define _SHIFT_P 1 +#define _BRANCH_P 2 +#define _DIV_P 2 +#define _SQRT_P 2 +#define _TRANS_P 2 +#define _FUNC_P 2 /* need to add number of arguments */ +#define _LOOP_P 1 +#define _INDIRECT_P 2 +#define _PTR_INIT_P 1 +#define _TEST_P 1 +#define _POWER_P 2 +#define _LOG_P 2 +#define _MISC_P 1 + +#define ADD( x ) \ + { \ + { \ + ops_cnt += ( _ADD_C * ( x ) ); \ + inst_cnt[_ADD] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _ADD_P * ( x ) ); \ + } \ + } \ + } \ + } +#define ABS( x ) \ + { \ + { \ + ops_cnt += ( _ABS_C * ( x ) ); \ + inst_cnt[_ABS] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _ABS_P * ( x ) ); \ + } \ + } \ + } \ + } +#define MULT( x ) \ + { \ + { \ + ops_cnt += ( _MULT_C * ( x ) ); \ + inst_cnt[_MULT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MULT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define MAC( x ) \ + { \ + { \ + ops_cnt += ( _MAC_C * ( x ) ); \ + inst_cnt[_MAC] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MAC_P * ( x ) ); \ + } \ + } \ + } \ + } +#define MOVE( x ) \ + { \ + { \ + ops_cnt += ( _MOVE_C * ( x ) ); \ + inst_cnt[_MOVE] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MOVE_P * ( x ) ); \ + } \ + } \ + } \ + } +#define STORE( x ) \ + { \ + { \ + ops_cnt += ( _STORE_C * ( x ) ); \ + inst_cnt[_STORE] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _STORE_P * ( x ) ); \ + } \ + } \ + } \ + } +#define LOGIC( x ) \ + { \ + { \ + ops_cnt += ( _LOGIC_C * ( x ) ); \ + inst_cnt[_LOGIC] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _LOGIC_P * ( x ) ); \ + } \ + } \ + } \ + } +#define SHIFT( x ) \ + { \ + { \ + ops_cnt += ( _SHIFT_C * ( x ) ); \ + inst_cnt[_SHIFT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _SHIFT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define BRANCH( x ) \ + { \ + { \ + ops_cnt += ( _BRANCH_C * ( x ) ); \ + inst_cnt[_BRANCH] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _BRANCH_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DIV( x ) \ + { \ + { \ + ops_cnt += ( _DIV_C * ( x ) ); \ + inst_cnt[_DIV] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _DIV_P * ( x ) ); \ + } \ + } \ + } \ + } +#define SQRT( x ) \ + { \ + { \ + ops_cnt += ( _SQRT_C * ( x ) ); \ + inst_cnt[_SQRT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _SQRT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define TRANS( x ) \ + { \ + { \ + ops_cnt += ( _TRANS_C * ( x ) ); \ + inst_cnt[_TRANS] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _TRANS_P * ( x ) ); \ + } \ + } \ + } \ + } +#define LOOP( x ) \ + { \ + { \ + ops_cnt += ( _LOOP_C * ( x ) ); \ + inst_cnt[_LOOP] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _LOOP_P * ( x ) ); \ + } \ + } \ + } \ + } +#define INDIRECT( x ) \ + { \ + { \ + ops_cnt += ( _INDIRECT_C * ( x ) ); \ + inst_cnt[_INDIRECT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _INDIRECT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define PTR_INIT( x ) \ + { \ + { \ + ops_cnt += ( _PTR_INIT_C * ( x ) ); \ + inst_cnt[_PTR_INIT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _PTR_INIT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define TEST( x ) \ + { \ + { \ + ops_cnt += ( _TEST_C * ( x ) ); \ + inst_cnt[_TEST] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _TEST_P * ( x ) ); \ + } \ + } \ + } \ + } +#define POWER( x ) \ + { \ + { \ + ops_cnt += ( _POWER_C * ( x ) ); \ + inst_cnt[_POWER] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _POWER_P * ( x ) ); \ + } \ + } \ + } \ + } +#define LOG( x ) \ + { \ + { \ + ops_cnt += ( _LOG_C * ( x ) ); \ + inst_cnt[_LOG] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _LOG_P * ( x ) ); \ + } \ + } \ + } \ + } +#define MISC( x ) \ + { \ + { \ + ops_cnt += ( _MISC_C * ( x ) ); \ + inst_cnt[_MISC] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MISC_P * ( x ) ); \ + } \ + } \ + } \ + } + +#define FUNC( x ) \ + { \ + { \ + ops_cnt += ( _FUNC_C + _MOVE_C * ( x ) ); \ + inst_cnt[_FUNC]++; \ + inst_cnt[_MOVE] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _FUNC_P + _MOVE_P * ( x ) ); \ + } \ + } \ + } \ + } + +#define DADD( x ) \ + { \ + { \ + ops_cnt += ( 2 * _ADD_C * ( x ) ); \ + inst_cnt[_ADD] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _ADD_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DMULT( x ) \ + { \ + { \ + ops_cnt += ( 2 * _MULT_C * ( x ) ); \ + inst_cnt[_MULT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MULT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DMAC( x ) \ + { \ + { \ + ops_cnt += ( 2 * _MAC_C * ( x ) ); \ + inst_cnt[_MAC] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MAC_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DMOVE( x ) \ + { \ + { \ + ops_cnt += ( 2 * _MOVE_C * ( x ) ); \ + inst_cnt[_MOVE] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MOVE_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DSTORE( x ) \ + { \ + { \ + ops_cnt += ( 2 * _STORE_C * ( x ) ); \ + inst_cnt[_STORE] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _STORE_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DLOGIC( x ) \ + { \ + { \ + ops_cnt += ( 2 * _LOGIC_C * ( x ) ); \ + inst_cnt[_LOGIC] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _LOGIC_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DSHIFT( x ) \ + { \ + { \ + ops_cnt += ( 2 * _SHIFT_C * ( x ) ); \ + inst_cnt[_SHIFT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _SHIFT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DDIV( x ) \ + { \ + { \ + ops_cnt += ( 2 * _DIV_C * ( x ) ); \ + inst_cnt[_DIV] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _DIV_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DSQRT( x ) \ + { \ + { \ + ops_cnt += ( 2 * _SQRT_C * ( x ) ); \ + inst_cnt[_SQRT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _SQRT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DTRANS( x ) \ + { \ + { \ + ops_cnt += ( 2 * _TRANS_C * ( x ) ); \ + inst_cnt[_TRANS] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _TRANS_P * ( x ) ); \ + } \ + } \ + } \ + } + +extern double ops_cnt; +extern double prom_cnt; +extern double inst_cnt[NUM_INST]; +extern int ops_cnt_activ; + +void reset_wmops( void ); +void push_wmops( const char *label ); +void pop_wmops( void ); +void update_wmops( void ); +void update_mem( void ); +void print_wmops( void ); + +#else /* WMOPS counting disabled */ + +#define reset_wmops() +extern int cntr_push_pop; +#define push_wmops( x ) ( cntr_push_pop++ ) +#define pop_wmops() ( cntr_push_pop-- ) +#define update_wmops() ( assert( cntr_push_pop == 0 ) ) +#define update_mem() +#define print_wmops() + +#define ADD( x ) +#define ABS( x ) +#define MULT( x ) +#define MAC( x ) +#define MOVE( x ) +#define STORE( x ) +#define LOGIC( x ) +#define SHIFT( x ) +#define BRANCH( x ) +#define DIV( x ) +#define SQRT( x ) +#define TRANS( x ) +#define FUNC( x ) +#define LOOP( x ) +#define INDIRECT( x ) +#define PTR_INIT( x ) +#define TEST( x ) +#define POWER( x ) +#define LOG( x ) +#define MISC( x ) + +#define DADD( x ) +#define DMULT( x ) +#define DMAC( x ) +#define DMOVE( x ) +#define DSTORE( x ) +#define DLOGIC( x ) +#define DSHIFT( x ) +#define DDIV( x ) +#define DSQRT( x ) +#define DTRANS( x ) + +#endif + +/* mac & msu (Non Instrumented Versions) */ +#ifndef mac +#define mac( a, b, c ) ( ( a ) + ( b ) * ( c ) ) +#endif +#ifndef mac +#define msu( a, b, c ) ( ( a ) - ( b ) * ( c ) ) +#endif + +#ifndef WMOPS +/* DESACTIVATE the Counting Mechanism */ +#define OP_COUNT_( op, n ) + +/* DESACTIVATE Operation Counter Wrappers */ +#define OP_COUNT_WRAPPER1_( op, val ) ( val ) +#define OP_COUNT_WRAPPER2_( expr ) +#define OP_COUNT_WRAPPER3_( op, expr ) expr + +/* DESACTIVATE Logical & Ternary Operators */ +#define __ +#define _ + +#else + +/* '*ops_cnt_ptr' is Used to Avoid: "warning: operation on 'ops_cnt' may be undefined" with Cygwin gcc Compiler */ +static double *ops_cnt_ptr = &ops_cnt; +#define OP_COUNT_( op, x ) ( *ops_cnt_ptr += ( op##_C * ( x ) ), inst_cnt[op] += ( x ) ) + +/******************************************************************/ +/* NOTES: */ +/* The 'wmc_flag_' flag is global to avoid declaration in every */ +/* function and 'static' to avoid clashing with other modules */ +/* that include this header file. */ +/* */ +/* The declarations of 'wmc_flag_' and 'wops_' in this header */ +/* file prevent the addition of a 'C' file to the Project. */ +/******************************************************************/ + +/* General Purpose Global Flag */ +static int wmc_flag_ = 0; + +/* Operation Counter Wrappers */ +#define OP_COUNT_WRAPPER1_( op, val ) ( op, val ) +#define OP_COUNT_WRAPPER2_( expr ) \ + if ( expr, 0 ) \ + ; \ + else +#define OP_COUNT_WRAPPER3_( op, expr ) \ + if ( op, 0 ) \ + ; \ + else \ + expr + +#endif + +/* Define all Macros without '{' & '}' (None of these should be called externally!) */ +#define ABS_( x ) OP_COUNT_( _ABS, ( x ) / WMOPS_BOOST_FAC ) +#define ADD_( x ) OP_COUNT_( _ADD, ( x ) / WMOPS_BOOST_FAC ) +#define MULT_( x ) OP_COUNT_( _MULT, ( x ) / WMOPS_BOOST_FAC ) +#define MAC_( x ) OP_COUNT_( _MAC, ( x ) / WMOPS_BOOST_FAC ) +#define MOVE_( x ) OP_COUNT_( _MOVE, ( x ) / WMOPS_BOOST_FAC ) +#define STORE_( x ) OP_COUNT_( _STORE, ( x ) / WMOPS_BOOST_FAC ) +#define LOGIC_( x ) OP_COUNT_( _LOGIC, ( x ) / WMOPS_BOOST_FAC ) +#define SHIFT_( x ) OP_COUNT_( _SHIFT, ( x ) / WMOPS_BOOST_FAC ) +#define BRANCH_( x ) OP_COUNT_( _BRANCH, ( x ) / WMOPS_BOOST_FAC ) +#define DIV_( x ) OP_COUNT_( _DIV, ( x ) / WMOPS_BOOST_FAC ) +#define SQRT_( x ) OP_COUNT_( _SQRT, ( x ) / WMOPS_BOOST_FAC ) +#define TRANS_( x ) OP_COUNT_( _TRANS, ( x ) / WMOPS_BOOST_FAC ) +#define POWER_( x ) TRANS_( x ) +#define LOG_( x ) TRANS_( x ) +#define LOOP_( x ) OP_COUNT_( _LOOP, ( x ) / WMOPS_BOOST_FAC ) +#define INDIRECT_( x ) OP_COUNT_( _INDIRECT, ( x ) / WMOPS_BOOST_FAC ) +#define PTR_INIT_( x ) OP_COUNT_( _PTR_INIT, ( x ) / WMOPS_BOOST_FAC ) +#define FUNC_( x ) ( OP_COUNT_( _MOVE, ( x ) / WMOPS_BOOST_FAC ), OP_COUNT_( _FUNC, 1 ) ) +#define MISC_( x ) ABS_( x ) + +/* Math Operations */ +#define abs_ OP_COUNT_WRAPPER1_( ABS_( 1 ), abs ) +#define fabs_ OP_COUNT_WRAPPER1_( ABS_( 1 ), fabs ) +#define labs_ OP_COUNT_WRAPPER1_( ABS_( 1 ), labs ) +#define floor_ OP_COUNT_WRAPPER1_( MISC_( 1 ), floor ) +#define sqrt_ OP_COUNT_WRAPPER1_( SQRT_( 1 ), sqrt ) +#define pow_ OP_COUNT_WRAPPER1_( POWER_( 1 ), pow ) +#define exp_ OP_COUNT_WRAPPER1_( POWER_( 1 ), exp ) +#define log_ OP_COUNT_WRAPPER1_( LOG_( 1 ), log ) +#define log10_ OP_COUNT_WRAPPER1_( LOG_( 1 ), log10 ) +#define cos_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), cos ) +#define sin_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), sin ) +#define tan_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), tan ) +#define acos_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), acos ) +#define asin_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), asin ) +#define atan_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), atan ) +#define atan2_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), atan2 ) +#define cosh_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), cosh ) +#define sinh_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), sinh ) +#define tanh_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), tanh ) +#define fmod_ OP_COUNT_WRAPPER1_( DIV_( 1 ), fmod ) +/* these macros use any local macros already defined */ +/* min/max and their Variants */ +#define min_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), min( ( a ), ( b ) ) ) +#define max_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), max( ( a ), ( b ) ) ) +#define MIN_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), MIN( ( a ), ( b ) ) ) +#define MAX_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), MAX( ( a ), ( b ) ) ) +#define Min_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), Min( ( a ), ( b ) ) ) +#define Max_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), Max( ( a ), ( b ) ) ) +/* Square and its Variants */ +#define sqr_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), sqr( ( x ) ) ) +#define Sqr_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), Sqr( ( x ) ) ) +#define SQR_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), SQR( ( x ) ) ) +#define square_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), square( ( x ) ) ) +#define Square_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), Square( ( x ) ) ) +#define SQUARE_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), SQUARE( ( x ) ) ) +/* Sign and its Variants */ +#define sign_( x ) OP_COUNT_WRAPPER1_( MOVE_( 1 ), sign( ( x ) ) ) +#define Sign_( x ) OP_COUNT_WRAPPER1_( MOVE_( 1 ), Sign( ( x ) ) ) +#define SIGN_( x ) OP_COUNT_WRAPPER1_( MOVE_( 1 ), SIGN( ( x ) ) ) +/* Square Root and its Variants */ +#define sqrtf_( x ) OP_COUNT_WRAPPER1_( SQRT_( 1 ), sqrtf( ( x ) ) ) +/* Invert Square Root and its Variants */ +#define inv_sqrt_( x ) OP_COUNT_WRAPPER1_( SQRT_( 1 ), inv_sqrt( ( x ) ) ) +/* Others */ +#define log_base_2_( x ) OP_COUNT_WRAPPER1_( ( LOG_( 1 ), MULT_( 1 ) ), log_base_2( ( x ) ) ) +#define log2_f_( x ) OP_COUNT_WRAPPER1_( ( LOG_( 1 ), MULT_( 1 ) ), log2_f( ( x ) ) ) +/* The 'wmc_flag_=wmc_flag_' is Used to Avoid: "warning: left-hand operand of comma expression has no effect" + with Cygwin gcc Compiler */ +#define _round_( x ) OP_COUNT_WRAPPER1_( wmc_flag_ = wmc_flag_, _round( ( x ) ) ) +#define round_f_( x ) OP_COUNT_WRAPPER1_( wmc_flag_ = wmc_flag_, round_f( ( x ) ) ) +#define _squant_( x ) OP_COUNT_WRAPPER1_( wmc_flag_ = wmc_flag_, _squant( ( x ) ) ) +/* Set Min/Max */ +#define set_min_( a, b ) OP_COUNT_WRAPPER3_( ( ADD_( 1 ), BRANCH_( 1 ), MOVE_( 1 ) ), set_min( ( a ), ( b ) ) ) +#define set_max_( a, b ) OP_COUNT_WRAPPER3_( ( ADD_( 1 ), BRANCH_( 1 ), MOVE_( 1 ) ), set_max( ( a ), ( b ) ) ) +/* mac & msu (Instrumented Versions) */ +#define mac_( a, b, c ) OP_COUNT_WRAPPER1_( MAC_( 1 ), mac( a, b, c ) ) +#define msu_( a, b, c ) OP_COUNT_WRAPPER1_( MAC_( 1 ), msu( a, b, c ) ) + +/* Functions */ +#define func_( name, x ) OP_COUNT_WRAPPER1_( FUNC_( x ), name ) + +/* Logical Operators */ +#ifndef __ +#define __ ( BRANCH_( 1 ), 1 ) && +#endif + +/* Ternary Operators (? and :) */ +#ifndef _ +#define _ ( BRANCH_( 1 ), 0 ) ? 0: +#endif + +/* Flow Control keywords */ +#define if_ \ + OP_COUNT_WRAPPER2_( BRANCH_( 1 ) ) \ + if +#define for_ OP_COUNT_WRAPPER2_( LOOP_(1)) for +#define while_( c ) \ + while \ + OP_COUNT_WRAPPER1_( BRANCH_( 1 ), ( c ) ) /* needs extra "()" if ',' encountered */ +#define do_ \ + do \ + { +#define _while \ + BRANCH_( 1 ); \ + } \ + while + +#define goto_ \ + OP_COUNT_WRAPPER2_( BRANCH_( 1 ) ) \ + goto +#define break_ \ + OP_COUNT_WRAPPER2_( BRANCH_( 1 ) ) \ + break +#define continue_ \ + OP_COUNT_WRAPPER2_( BRANCH_( 1 ) ) \ + continue +#define return_ \ + OP_COUNT_WRAPPER2_( ( wmc_flag_ = stack_tree_level_, STACK_DEPTH_FCT_RETURN ) ) \ + return + +#define switch_ \ + OP_COUNT_WRAPPER2_( ( BRANCH_( 1 ), wmc_flag_ = 1 ) ) \ + switch +#define cost_( n ) OP_COUNT_WRAPPER2_( wmc_flag_ ? ( ADD_( n ), BRANCH_( n ), wmc_flag_ = 0 ) : 0 ); + +#ifdef WMOPS + +#define ACC 2 +#define MUL 1 + +/* Counting Function (should not be called externally!) */ +static void wops_( const char *ops ) +{ + char lm = 0; /* lm: Last Operation is Math */ + static char lo = 0; /* Last Operation */ + + void ( *fct )( const char *ops ) = wops_; + +st: + while ( *ops != '\0' ) + { + switch ( *ops++ ) + { + int cnt; + case '-': + for ( cnt = 0; ops[cnt] == '>'; cnt++ ) + ; + if ( cnt & 1 ) + goto ind; + case '+': + lm = 2; + if ( lo & MUL ) + { + MULT_( -1 ); + MAC_( 1 ); + break; + } + lo = ACC << 2; + case 'U': + case 'D': + ADD_( 1 ); + break; + case '*': + lm = 2; + if ( lo & ACC ) + { + ADD_( -1 ); + MAC_( 1 ); + break; + } + lo = MUL << 2; + MULT_( 1 ); + break; + case '/': + case '%': + lm = 2; + DIV_( 1 ); + break; + case '&': + case '|': + case '^': + lm = 2; + case '~': + LOGIC_( 1 ); + break; + case '<': + case '>': + if ( *ops != ops[-1] ) + goto error; + ops++; + case -85: + case -69: + lm = 2; + SHIFT_( 1 ); + break; + case 'L': + case 'G': + if ( *ops == 't' ) + goto comp; + case 'E': + case 'N': + if ( *ops != 'e' ) + goto error; + comp: + ops++; + ADD_( 1 ); + break; + case '!': + MISC_( 2 ); + break; + case 'M': + MOVE_( 1 ); + break; + case 'S': + STORE_( 1 ); + break; + case 'P': + PTR_INIT_( 1 ); + break; + case '[': + case ']': + goto st; + ind: + ops++; + case 'I': + case '.': + INDIRECT_( 1 ); + break; + case '=': + if ( lm ) + goto st; + case '\0': + /* This Shouldn't Happen */ + /* These are Used to Avoid: "warning: 'name' defined but not used" with Cygwin gcc Compiler */ + wmc_flag_ = wmc_flag_; + ops_cnt_ptr = ops_cnt_ptr; + fct( "" ); + error: + default: + fprintf( stderr, "\r wops: Invalid Counting Operation '%s'\n", ops - 1 ); + exit( -1 ); + } + lm >>= 1; + lo >>= 2; + } + + return; +} + +#endif + +/* All Other Operations */ diff --git a/lib_dec/ivas_corecoder_dec_reconfig.c b/lib_dec/ivas_corecoder_dec_reconfig.c index 792d4cbd24..7c6d17bca2 100644 --- a/lib_dec/ivas_corecoder_dec_reconfig.c +++ b/lib_dec/ivas_corecoder_dec_reconfig.c @@ -480,7 +480,6 @@ ivas_error ivas_hp20_dec_reconfig( } -#ifdef BRATE_SWITCHING_RENDERING /*-------------------------------------------------------------------* * ivas_cldfb_dec_reconfig() * @@ -572,4 +571,3 @@ ivas_error ivas_cldfb_dec_reconfig( #endif return IVAS_ERR_OK; } -#endif diff --git a/lib_dec/ivas_dirac_dec_binaural_functions.c b/lib_dec/ivas_dirac_dec_binaural_functions.c index 0a98a92d23..573d302ec7 100644 --- a/lib_dec/ivas_dirac_dec_binaural_functions.c +++ b/lib_dec/ivas_dirac_dec_binaural_functions.c @@ -98,21 +98,17 @@ ivas_error ivas_dirac_dec_init_binaural_data( float binCenterFreq, tmpFloat; ivas_error error; -#ifdef BRATE_SWITCHING_RENDERING hBinaural = st_ivas->hDiracDecBin; if ( hBinaural == NULL ) -#endif { if ( ( hBinaural = (DIRAC_DEC_BIN_HANDLE) malloc( sizeof( DIRAC_DEC_BIN_DATA ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC binaural handle " ); } -#ifdef BRATE_SWITCHING_RENDERING hBinaural->hTdDecorr = NULL; hBinaural->hReverb = NULL; -#endif } nBins = st_ivas->hDirAC->num_freq_bands; @@ -201,7 +197,6 @@ ivas_error ivas_dirac_dec_init_binaural_data( { mvr2r( parametricEarlyPartEneCorrection, hBinaural->earlyPartEneCorrection, nBins ); -#ifdef BRATE_SWITCHING_RENDERING /* reconfiguration needed when Reverb. parameters are changed -> close and open the handle again */ if ( hBinaural->hReverb != NULL && ( ( hBinaural->hReverb->numBins != nBins ) || ( hBinaural->useSubframeMode && hBinaural->hReverb->blockSize != CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES ) || @@ -211,7 +206,6 @@ ivas_error ivas_dirac_dec_init_binaural_data( } if ( hBinaural->hReverb == NULL ) -#endif { if ( hBinaural->useSubframeMode ) { @@ -244,9 +238,7 @@ ivas_error ivas_dirac_dec_init_binaural_data( { if ( st_ivas->hDecoderConfig->ivas_total_brate >= IVAS_13k2 && st_ivas->ivas_format == SBA_FORMAT ) { -#ifdef BRATE_SWITCHING_RENDERING if ( hBinaural->hTdDecorr == NULL ) -#endif { ivas_spar_td_decorr_dec_open( &( hBinaural->hTdDecorr ), output_Fs, 3, 1 ); } @@ -267,11 +259,7 @@ ivas_error ivas_dirac_dec_init_binaural_data( } else { -#ifdef BRATE_SWITCHING_RENDERING ivas_spar_td_decorr_dec_close( &( hBinaural->hTdDecorr ) ); -#else - hBinaural->hTdDecorr = NULL; -#endif } st_ivas->hDiracDecBin = hBinaural; diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 8d48bf75c8..7853345225 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -533,17 +533,9 @@ ivas_error ivas_sba_dec_reconfigure( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { -#ifdef BRATE_SWITCHING_RENDERING int16_t nchan_transport_old, nSCE_old, nCPE_old, nchan_hp20_old; -#else - int16_t i, nchan_transport_old, nSCE_old, nCPE_old, nchan_hp20_old; -#endif AUDIO_CONFIG intern_config_old; -#ifdef BRATE_SWITCHING_RENDERING int16_t numCldfbAnalyses_old, numCldfbSyntheses_old; -#else - int16_t numCldfbAnalyses_old, numCldfbAnalyses, numCldfbSyntheses, numCldfbSyntheses_old; -#endif int16_t sba_dirac_stereo_flag_old; #ifdef SBA_BR_SWITCHING_RECONFIG SBA_MODE sba_mode_old; @@ -578,9 +570,6 @@ ivas_error ivas_sba_dec_reconfigure( *-----------------------------------------------------------------*/ ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); -#ifndef BRATE_SWITCHING_RENDERING - numCldfbAnalyses = 0; -#endif nchan_hp20_old = getNumChanSynthesis( st_ivas ); @@ -773,7 +762,6 @@ ivas_error ivas_sba_dec_reconfigure( ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config ); } -#ifdef BRATE_SWITCHING_RENDERING /*-------------------------------------------------------------------* * Reallocate and initialize binaural rendering handles *--------------------------------------------------------------------*/ @@ -809,7 +797,6 @@ ivas_error ivas_sba_dec_reconfigure( { ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); } -#endif #ifdef SBA_BR_SWITCHING_RECONFIG if ( ( ( st_ivas->renderer_type != RENDERER_DISABLE ) && ( st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC ) ) || ( sba_mode_old != st_ivas->sba_mode ) ) { @@ -948,107 +935,8 @@ ivas_error ivas_sba_dec_reconfigure( * CLDFB instances *-----------------------------------------------------------------*/ -#ifdef BRATE_SWITCHING_RENDERING ivas_cldfb_dec_reconfig( st_ivas, nchan_transport_old, numCldfbAnalyses_old, numCldfbSyntheses_old ); -#else - ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses, &numCldfbSyntheses ); - /* special case, if there was one transport channel in the previous frame and more than one in the current frame, - remove the second CLDFB here, it was for CNA/CNG */ - if ( nchan_transport_old == 1 && numCldfbAnalyses_old == 2 && st_ivas->nchan_transport > 1 ) - { - deleteCldfb( &( st_ivas->cldfbAnaDec[1] ) ); - st_ivas->cldfbAnaDec[1] = NULL; - numCldfbAnalyses_old--; - } - -#ifdef BRATE_SWITCHING_RENDERING - /* resample CLDFB analysis instances */ - for ( i = 0; i < min( numCldfbAnalyses, numCldfbAnalyses_old ); i++ ) - { - if ( ( st_ivas->cldfbAnaDec[i]->no_channels * st_ivas->cldfbAnaDec[i]->no_col ) != ( hDecoderConfig->output_Fs / FRAMES_PER_SEC ) ) - { - resampleCldfb( st_ivas->cldfbAnaDec[i], hDecoderConfig->output_Fs ); - } - } -#endif - - /* Analysis*/ - if ( numCldfbAnalyses_old > numCldfbAnalyses ) - { - /* delete superfluous CLDFB synthesis instances */ - for ( i = numCldfbAnalyses; i < numCldfbAnalyses_old; i++ ) - { - deleteCldfb( &( st_ivas->cldfbAnaDec[i] ) ); - st_ivas->cldfbAnaDec[i] = NULL; - } - } - else if ( numCldfbAnalyses_old < numCldfbAnalyses ) - { - /* create additional CLDFB synthesis instances */ - for ( i = numCldfbAnalyses_old; i < numCldfbAnalyses; i++ ) - { - if ( ( error = openCldfb( &( st_ivas->cldfbAnaDec[i] ), CLDFB_ANALYSIS, hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) - { - return error; - } - } - } - - /* Synthesis */ - if ( numCldfbSyntheses_old > numCldfbSyntheses ) - { - /* delete superfluous CLDFB synthesis instances */ - for ( i = numCldfbSyntheses; i < numCldfbSyntheses_old; i++ ) - { - deleteCldfb( &( st_ivas->cldfbSynDec[i] ) ); - st_ivas->cldfbSynDec[i] = NULL; - } - } - else if ( numCldfbSyntheses_old < numCldfbSyntheses ) - { - /* create additional CLDFB synthesis instances */ - for ( i = numCldfbSyntheses_old; i < numCldfbSyntheses; i++ ) - { - if ( ( error = openCldfb( &( st_ivas->cldfbSynDec[i] ), CLDFB_SYNTHESIS, hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) - { - return error; - } - } - } -#endif - -#ifndef BRATE_SWITCHING_RENDERING - /*-------------------------------------------------------------------* - * Reallocate and initialize binaural rendering handles - *--------------------------------------------------------------------*/ - - if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) && st_ivas->hBinRenderer == NULL ) - { - /* open fastconv binaural renderer */ - if ( ( error = ivas_binRenderer_open( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else if ( st_ivas->hBinRenderer != NULL && ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV && st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM ) ) - { - ivas_binRenderer_close( &st_ivas->hBinRenderer ); - } - - if ( st_ivas->hDiracDecBin == NULL && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) ) - { - /* open parametric binaural renderer */ - if ( ( error = ivas_dirac_dec_init_binaural_data( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else if ( st_ivas->hDiracDecBin != NULL && ( st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM && st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC ) ) - { - ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); - } -#endif return error; } diff --git a/lib_rend/ivas_binauralRenderer.c b/lib_rend/ivas_binauralRenderer.c index d266c5c955..be2a8193c8 100644 --- a/lib_rend/ivas_binauralRenderer.c +++ b/lib_rend/ivas_binauralRenderer.c @@ -553,9 +553,7 @@ ivas_error ivas_binRenderer_open( ivas_output_init( &out_setup, AUDIO_CONFIG_7_1_4 ); -#ifdef BRATE_SWITCHING_RENDERING if ( st_ivas->hoa_dec_mtx == NULL ) -#endif { if ( ( error = ivas_sba_get_hoa_dec_matrix( out_setup, &st_ivas->hoa_dec_mtx, st_ivas->hIntSetup.ambisonics_order ) ) != IVAS_ERR_OK ) { diff --git a/lib_rend/ivas_binaural_reverb.c b/lib_rend/ivas_binaural_reverb.c index 061bbb61a6..1609edde82 100644 --- a/lib_rend/ivas_binaural_reverb.c +++ b/lib_rend/ivas_binaural_reverb.c @@ -538,9 +538,7 @@ void ivas_binaural_reverb_close( } free( ( *hReverb ) ); -#ifdef BRATE_SWITCHING_RENDERING ( *hReverb ) = NULL; -#endif return; } -- GitLab From 9eea17bef724bc9f6f65b2de5e3ea7444791e95c Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Fri, 13 Jan 2023 13:14:31 +0100 Subject: [PATCH 2/7] [cleanup] accept MC_BITRATE_SWITCHING --- lib_com/bitstream.c | 6 - lib_com/ivas_mc_param_com.c | 78 --- lib_com/ivas_mcmasa_com.c | 24 - lib_com/ivas_prot.h | 29 - lib_com/options.h | 1 - lib_com/prot.h | 4 - lib_com/swb_tbe_com.c | 2 - lib_debug/coan_out_000001 | 924 ++++++++++++++++++++++++++ lib_dec/ivas_corecoder_dec_reconfig.c | 50 -- lib_dec/ivas_cpe_dec.c | 6 - lib_dec/ivas_dec.c | 4 - lib_dec/ivas_init_dec.c | 42 -- lib_dec/ivas_ism_param_dec.c | 8 - lib_dec/ivas_mc_param_dec.c | 6 - lib_dec/ivas_mcmasa_dec.c | 2 - lib_dec/ivas_mct_dec.c | 76 --- lib_dec/ivas_mdct_core_dec.c | 4 - lib_dec/ivas_sba_dec.c | 4 - lib_dec/ivas_stereo_switching_dec.c | 4 - lib_enc/amr_wb_enc.c | 4 - lib_enc/evs_enc.c | 4 - lib_enc/ivas_core_enc.c | 4 - lib_enc/ivas_corecoder_enc_reconfig.c | 62 -- lib_enc/ivas_cpe_enc.c | 4 - lib_enc/ivas_init_enc.c | 55 -- lib_enc/ivas_ism_param_enc.c | 8 - lib_enc/ivas_mc_param_enc.c | 2 - lib_enc/ivas_mcmasa_enc.c | 4 - lib_enc/ivas_mct_enc.c | 18 - lib_enc/ivas_mdct_core_enc.c | 8 - lib_enc/ivas_sba_enc.c | 4 - lib_enc/updt_enc.c | 7 - 32 files changed, 924 insertions(+), 534 deletions(-) create mode 100644 lib_debug/coan_out_000001 diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c index c75d192a34..fc89af3fbd 100644 --- a/lib_com/bitstream.c +++ b/lib_com/bitstream.c @@ -879,12 +879,6 @@ static ivas_error write_indices_element( for ( n = 0; n < n_channels; n++ ) { -#ifndef MC_BITRATE_SWITCHING - if ( ( st_ivas->hEncoderConfig->ivas_format == MC_FORMAT ) && ( st_ivas->mc_mode == MC_MODE_MCT ) && ( element_id * CPE_CHANNELS + n == LFE_CHANNEL ) ) - { - continue; - } -#endif reset_indices_enc( sts[n]->hBstr, MAX_NUM_INDICES ); } } diff --git a/lib_com/ivas_mc_param_com.c b/lib_com/ivas_mc_param_com.c index 1102c3385e..55734101b8 100644 --- a/lib_com/ivas_mc_param_com.c +++ b/lib_com/ivas_mc_param_com.c @@ -330,7 +330,6 @@ void ivas_param_mc_default_icc_map( } -#ifdef MC_BITRATE_SWITCHING /*------------------------------------------------------------------------- * ivas_param_mc_get_num_param_bands() * @@ -422,7 +421,6 @@ static int16_t ivas_param_mc_get_num_param_bands( return num_parameter_bands; } -#endif /*------------------------------------------------------------------------- * Local functions @@ -521,82 +519,6 @@ static void ivas_param_mc_set_coding_scheme( assert( 0 && "PARAM_MC: channel configuration not supported!" ); } -#ifdef MC_BITRATE_SWITCHING hMetadataPMC->num_parameter_bands = ivas_param_mc_get_num_param_bands( mc_ls_setup, ivas_total_brate ); -#else - /* parameter bands */ - switch ( mc_ls_setup ) - { - case MC_LS_SETUP_5_1: - switch ( ivas_total_brate ) - { - case IVAS_48k: - hMetadataPMC->num_parameter_bands = 10; - break; - case IVAS_64k: - case IVAS_80k: - hMetadataPMC->num_parameter_bands = 14; - break; - default: - assert( 0 && "PARAM_MC: bitrate for CICP6 not supported!" ); - } - break; - - case MC_LS_SETUP_7_1: - switch ( ivas_total_brate ) - { - case IVAS_48k: - hMetadataPMC->num_parameter_bands = 10; - break; - case IVAS_64k: - case IVAS_80k: - hMetadataPMC->num_parameter_bands = 14; - break; - case IVAS_96k: - hMetadataPMC->num_parameter_bands = 20; - break; - } - break; - case MC_LS_SETUP_5_1_2: - switch ( ivas_total_brate ) - { - case IVAS_48k: - hMetadataPMC->num_parameter_bands = 10; - break; - case IVAS_64k: - case IVAS_80k: - hMetadataPMC->num_parameter_bands = 14; - break; - case IVAS_96k: - hMetadataPMC->num_parameter_bands = 20; - break; - } - break; - case MC_LS_SETUP_5_1_4: - switch ( ivas_total_brate ) - { - case IVAS_96k: - hMetadataPMC->num_parameter_bands = 14; - break; - case IVAS_128k: - hMetadataPMC->num_parameter_bands = 20; - break; - } - break; - case MC_LS_SETUP_7_1_4: - switch ( ivas_total_brate ) - { - case IVAS_128k: - hMetadataPMC->num_parameter_bands = 20; - break; - case IVAS_160k: - hMetadataPMC->num_parameter_bands = 20; - break; - } - break; - default: - assert( 0 && "PARAM_MC: channel configuration not supportet!" ); - } -#endif return; } diff --git a/lib_com/ivas_mcmasa_com.c b/lib_com/ivas_mcmasa_com.c index 3e63d721be..5ccde3ed37 100644 --- a/lib_com/ivas_mcmasa_com.c +++ b/lib_com/ivas_mcmasa_com.c @@ -92,29 +92,6 @@ void ivas_mcmasa_set_separate_channel_mode( } -#ifndef MC_BITRATE_SWITCHING -/*--------------------------------------------------------------------------* - * ivas_mcmasa_mono_brate() - * - * Set SCE bitrate for McMASA mono separated channel - *--------------------------------------------------------------------------*/ - -/*! r: McMASA SCE bitrate */ -int32_t ivas_mcmasa_mono_brate( - const int32_t ivas_total_brate /* i : IVAS total bitrate */ -) -{ - /* 25% of total bitrate is used for SCE below 96 kb/s (separated mono channel), otherwise 30% */ - if ( ivas_total_brate < IVAS_96k ) - { - return (int32_t) ( MCMASA_MONOBITRATIO_64k * ivas_total_brate ); - } - else - { - return (int32_t) ( MCMASA_MONOBITRATIO * ivas_total_brate ); - } -} -#else /*--------------------------------------------------------------------------* * ivas_mcmasa_split_brate() * @@ -152,4 +129,3 @@ void ivas_mcmasa_split_brate( return; } -#endif diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 336e6f91e9..eb14bfdc43 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -149,14 +149,10 @@ ivas_error ivas_corecoder_enc_reconfig( Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ const int16_t nSCE_old, /* i : number of SCEs in previous frame */ const int16_t nCPE_old, /* i : number of CPEs in previous frame */ -#ifdef MC_BITRATE_SWITCHING const int16_t nchan_transport_old, /* i : number of TCs in previous frame */ const int32_t brate_SCE, /* i : bitrate to be set for the SCEs */ const int32_t brate_CPE, /* i : bitrate to be set for the CPEs */ const MC_MODE last_mc_mode /* i : switching between MC modes: last mode */ -#else - const int16_t nchan_transport_old /* i : number of TCs in previous frame */ -#endif ); ivas_error ivas_sce_enc( @@ -358,7 +354,6 @@ void ivas_mct_dec_close( ); ivas_error ivas_corecoder_dec_reconfig( -#ifdef MC_BITRATE_SWITCHING Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t nSCE_old, /* i : number of SCEs in previous frame */ int16_t nCPE_old, /* i : number of CPEs in previous frame */ @@ -366,13 +361,6 @@ ivas_error ivas_corecoder_dec_reconfig( const int16_t sba_dirac_stereo_flag_old, /* i : signal stereo rendering using DFT upmix in previous frame */ const int32_t brate_SCE, /* i : bitrate to be set for the SCEs */ const int32_t brate_CPE /* i : bitrate to be set for the CPEs */ -#else - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t nSCE_old, /* i : number of SCEs in previous frame */ - const int16_t nCPE_old, /* i : number of CPEs in previous frame */ - const int16_t nchan_transport_old, /* i : number of TCs in previous frame */ - const int16_t sba_dirac_stereo_flag_old /* i : signal stereo output for SBA DirAC in previous frame */ -#endif ); ivas_error ivas_hp20_dec_reconfig( @@ -2630,9 +2618,7 @@ ivas_error stereo_memory_dec( const int16_t nb_bits_metadata, /* i : number of metadata bits */ const int32_t output_Fs, /* i : output sampling rate */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ -#ifdef MC_BITRATE_SWITCHING const MC_MODE mc_mode, /* i : MC mode */ -#endif const int16_t nchan_transport /* i : number of transport channels */ ); @@ -3569,11 +3555,9 @@ ivas_error ivas_param_mc_enc_open( Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ ); -#ifdef MC_BITRATE_SWITCHING ivas_error ivas_param_mc_enc_reconfig( Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ ); -#endif void ivas_param_mc_enc_close( PARAM_MC_ENC_HANDLE hParamMC, /* i/o: Parametric MC encoder handle */ @@ -3591,11 +3575,9 @@ ivas_error ivas_param_mc_dec_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); -#ifdef MC_BITRATE_SWITCHING ivas_error ivas_param_mc_dec_reconfig( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); -#endif void ivas_param_mc_dec_close( PARAM_MC_DEC_HANDLE *hParamMC /* i/o: Parametric MC decoder handle */ @@ -4869,7 +4851,6 @@ void ivas_mcmasa_enc_close( const int32_t input_Fs /* i : input sampling rate */ ); -#ifdef MC_BITRATE_SWITCHING ivas_error ivas_mcmasa_enc_reconfig( Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ ); @@ -4877,7 +4858,6 @@ ivas_error ivas_mcmasa_enc_reconfig( ivas_error ivas_mcmasa_dec_reconfig( Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ ); -#endif void ivas_mcmasa_setNumTransportChannels( int16_t* nchan_transport, /* o : Pointer to number of transport channels to be set */ @@ -4891,12 +4871,6 @@ void ivas_mcmasa_set_separate_channel_mode( const int32_t ivas_total_brate /* i : Total bitrate of IVAS */ ); -#ifndef MC_BITRATE_SWITCHING -/*! r: McMASA SCE bitrate */ -int32_t ivas_mcmasa_mono_brate( - const int32_t ivas_total_brate /* i : IVAS total bitrate */ -); -#else void ivas_mcmasa_split_brate( const uint8_t separateChannelEnabled, /* i : Transport running in "separate channel" mode */ const int32_t ivas_total_brate, /* i : Total bitrate available to be split */ @@ -4905,7 +4879,6 @@ void ivas_mcmasa_split_brate( int32_t *brate_sce, /* o : Pointer to SCE element bitrate */ int32_t *brate_cpe /* o : Pointer to CPE element bitrate */ ); -#endif void ivas_mcmasa_enc( MCMASA_ENC_HANDLE hMcMasa, /* i/o: Encoder McMASA handle */ @@ -4930,14 +4903,12 @@ void ivas_mcmasa_param_est_enc( const int16_t nchan_inp /* i : Number of input channels */ ); -#ifdef MC_BITRATE_SWITCHING void ivas_mcmasa_dmx_modify( const int16_t n_samples, /* i : input frame length in samples */ float dmx[][L_FRAME48k + NS2SA( 48000, IVAS_FB_ENC_DELAY_NS )], /* i/o: downmix signal to be transformed into another format */ const int16_t n_chnls_dmx_old, /* i : number of downmix channels in the old format */ const int16_t n_chnls_dmx_new /* i : number of downmix channels in the target format */ ); -#endif void v_multc_acc( const float x[], /* i : Input vector */ diff --git a/lib_com/options.h b/lib_com/options.h index bb77a02db8..4f27ece852 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -147,7 +147,6 @@ #endif #define FIX_I59_DELAY_ROUNDING /* Issue 59: rounding in sample domain instead of nanosec for IVAS_ENC_GetDelay() and IVAS_DEC_GetDelay() */ #define FIX_FIX_I59 /* Issue 59: small fix concerning LFE delay rounding */ -#define MC_BITRATE_SWITCHING /* Issue 116: support bitrate switching in MC format */ #define MC_JBM /* FhG: extend JBM beyond mono for running IVAS in VoIP mode (contribution 19) */ #define FIX_265_MC_BRATE_SWITCHING /* Issue 265: fix use-of-uninitialized-value in MC bitrate switching */ #define FIX_ANGLE_WRAPPING /* Issue 244: Problems with angle wrapping*/ diff --git a/lib_com/prot.h b/lib_com/prot.h index 97882cb318..a0e03c9d21 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -3896,10 +3896,6 @@ void updt_enc( void updt_enc_common( Encoder_State *st /* i/o: encoder state structure */ -#ifndef MC_BITRATE_SWITCHING - , - const float Etot /* i : total energy */ -#endif ); void updt_IO_switch_enc( diff --git a/lib_com/swb_tbe_com.c b/lib_com/swb_tbe_com.c index feb5b68f1a..d3482c0a00 100644 --- a/lib_com/swb_tbe_com.c +++ b/lib_com/swb_tbe_com.c @@ -1897,9 +1897,7 @@ void tbe_celp_exc( return; } -#ifdef MC_BITRATE_SWITCHING assert( bwe_exc != NULL && "BWE excitation is NULL" ); -#endif if ( L_frame == L_FRAME ) { diff --git a/lib_debug/coan_out_000001 b/lib_debug/coan_out_000001 new file mode 100644 index 0000000000..bf31e63cef --- /dev/null +++ b/lib_debug/coan_out_000001 @@ -0,0 +1,924 @@ +/* + * (C) 2022 copyright VoiceAge Corporation. All Rights Reserved. + * + * This software is protected by copyright law and by international treaties. The source code, and all of its derivations, + * is provided by VoiceAge Corporation under the "ITU-T Software Tools' General Public License". Please, read the license file + * or refer to ITU-T Recommendation G.191 on "SOFTWARE TOOLS FOR SPEECH AND AUDIO CODING STANDARDS". + * + * Any use of this software is permitted provided that this notice is not removed and that neither the authors nor + * VoiceAge Corporation are deemed to have made any representations as to the suitability of this software + * for any purpose nor are held responsible for any defects of this software. THERE IS NO WARRANTY FOR THIS SOFTWARE. + * + * Authors: Guy Richard, Vladimir Malenovsky (Vladimir.Malenovsky@USherbrooke.ca) + */ + +#ifndef WMOPS_H +#define WMOPS_H + +#ifndef EXIT_FAILURE +#include /* stdlib is needed for exit() */ +#endif + +#ifndef EOF +#include /* stdio is needed for fprintf() */ +#endif + + +/* To Prevent "warning: '$' in identifier or number" message under GCC */ +#ifdef __GNUC__ +#pragma GCC system_header +#endif + +/* Real-time relationships */ +#define FRAMES_PER_SECOND 50.0 +#define MILLION_CYCLES 1e6 +#define WMOPS_BOOST_FAC ( 1.0f ) /* scaling factor for equalizing the difference between automatic and manual instrumentation */ +#define FAC ( FRAMES_PER_SECOND / MILLION_CYCLES * WMOPS_BOOST_FAC ) +#define NUM_INST 20 /* Total number of instruction types (in enum below) */ + + +#ifdef WMOPS +enum instructions +{ + _ADD, + _ABS, + _MULT, + _MAC, + _MOVE, + _STORE, + _LOGIC, + _SHIFT, + _BRANCH, + _DIV, + _SQRT, + _TRANS, + _FUNC, + _LOOP, + _INDIRECT, + _PTR_INIT, + _TEST, + _POWER, + _LOG, + _MISC +}; + +#define _ADD_C 1 +#define _ABS_C 1 +#define _MULT_C 1 +#define _MAC_C 1 +#define _MOVE_C 1 +#define _STORE_C 1 +#define _LOGIC_C 1 +#define _SHIFT_C 1 +#define _BRANCH_C 4 +#define _DIV_C 18 +#define _SQRT_C 10 +#define _TRANS_C 25 +#define _FUNC_C 2 /* need to add number of arguments */ +#define _LOOP_C 3 +#define _INDIRECT_C 2 +#define _PTR_INIT_C 1 +#define _TEST_C 2 +#define _POWER_C 25 +#define _LOG_C 25 +#define _MISC_C 1 + +#define _ADD_P 1 +#define _ABS_P 1 +#define _MULT_P 1 +#define _MAC_P 1 +#define _MOVE_P 1 +#define _STORE_P 0 +#define _LOGIC_P 1 +#define _SHIFT_P 1 +#define _BRANCH_P 2 +#define _DIV_P 2 +#define _SQRT_P 2 +#define _TRANS_P 2 +#define _FUNC_P 2 /* need to add number of arguments */ +#define _LOOP_P 1 +#define _INDIRECT_P 2 +#define _PTR_INIT_P 1 +#define _TEST_P 1 +#define _POWER_P 2 +#define _LOG_P 2 +#define _MISC_P 1 + +#define ADD( x ) \ + { \ + { \ + ops_cnt += ( _ADD_C * ( x ) ); \ + inst_cnt[_ADD] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _ADD_P * ( x ) ); \ + } \ + } \ + } \ + } +#define ABS( x ) \ + { \ + { \ + ops_cnt += ( _ABS_C * ( x ) ); \ + inst_cnt[_ABS] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _ABS_P * ( x ) ); \ + } \ + } \ + } \ + } +#define MULT( x ) \ + { \ + { \ + ops_cnt += ( _MULT_C * ( x ) ); \ + inst_cnt[_MULT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MULT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define MAC( x ) \ + { \ + { \ + ops_cnt += ( _MAC_C * ( x ) ); \ + inst_cnt[_MAC] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MAC_P * ( x ) ); \ + } \ + } \ + } \ + } +#define MOVE( x ) \ + { \ + { \ + ops_cnt += ( _MOVE_C * ( x ) ); \ + inst_cnt[_MOVE] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MOVE_P * ( x ) ); \ + } \ + } \ + } \ + } +#define STORE( x ) \ + { \ + { \ + ops_cnt += ( _STORE_C * ( x ) ); \ + inst_cnt[_STORE] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _STORE_P * ( x ) ); \ + } \ + } \ + } \ + } +#define LOGIC( x ) \ + { \ + { \ + ops_cnt += ( _LOGIC_C * ( x ) ); \ + inst_cnt[_LOGIC] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _LOGIC_P * ( x ) ); \ + } \ + } \ + } \ + } +#define SHIFT( x ) \ + { \ + { \ + ops_cnt += ( _SHIFT_C * ( x ) ); \ + inst_cnt[_SHIFT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _SHIFT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define BRANCH( x ) \ + { \ + { \ + ops_cnt += ( _BRANCH_C * ( x ) ); \ + inst_cnt[_BRANCH] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _BRANCH_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DIV( x ) \ + { \ + { \ + ops_cnt += ( _DIV_C * ( x ) ); \ + inst_cnt[_DIV] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _DIV_P * ( x ) ); \ + } \ + } \ + } \ + } +#define SQRT( x ) \ + { \ + { \ + ops_cnt += ( _SQRT_C * ( x ) ); \ + inst_cnt[_SQRT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _SQRT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define TRANS( x ) \ + { \ + { \ + ops_cnt += ( _TRANS_C * ( x ) ); \ + inst_cnt[_TRANS] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _TRANS_P * ( x ) ); \ + } \ + } \ + } \ + } +#define LOOP( x ) \ + { \ + { \ + ops_cnt += ( _LOOP_C * ( x ) ); \ + inst_cnt[_LOOP] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _LOOP_P * ( x ) ); \ + } \ + } \ + } \ + } +#define INDIRECT( x ) \ + { \ + { \ + ops_cnt += ( _INDIRECT_C * ( x ) ); \ + inst_cnt[_INDIRECT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _INDIRECT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define PTR_INIT( x ) \ + { \ + { \ + ops_cnt += ( _PTR_INIT_C * ( x ) ); \ + inst_cnt[_PTR_INIT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _PTR_INIT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define TEST( x ) \ + { \ + { \ + ops_cnt += ( _TEST_C * ( x ) ); \ + inst_cnt[_TEST] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _TEST_P * ( x ) ); \ + } \ + } \ + } \ + } +#define POWER( x ) \ + { \ + { \ + ops_cnt += ( _POWER_C * ( x ) ); \ + inst_cnt[_POWER] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _POWER_P * ( x ) ); \ + } \ + } \ + } \ + } +#define LOG( x ) \ + { \ + { \ + ops_cnt += ( _LOG_C * ( x ) ); \ + inst_cnt[_LOG] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _LOG_P * ( x ) ); \ + } \ + } \ + } \ + } +#define MISC( x ) \ + { \ + { \ + ops_cnt += ( _MISC_C * ( x ) ); \ + inst_cnt[_MISC] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MISC_P * ( x ) ); \ + } \ + } \ + } \ + } + +#define FUNC( x ) \ + { \ + { \ + ops_cnt += ( _FUNC_C + _MOVE_C * ( x ) ); \ + inst_cnt[_FUNC]++; \ + inst_cnt[_MOVE] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _FUNC_P + _MOVE_P * ( x ) ); \ + } \ + } \ + } \ + } + +#define DADD( x ) \ + { \ + { \ + ops_cnt += ( 2 * _ADD_C * ( x ) ); \ + inst_cnt[_ADD] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _ADD_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DMULT( x ) \ + { \ + { \ + ops_cnt += ( 2 * _MULT_C * ( x ) ); \ + inst_cnt[_MULT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MULT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DMAC( x ) \ + { \ + { \ + ops_cnt += ( 2 * _MAC_C * ( x ) ); \ + inst_cnt[_MAC] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MAC_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DMOVE( x ) \ + { \ + { \ + ops_cnt += ( 2 * _MOVE_C * ( x ) ); \ + inst_cnt[_MOVE] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MOVE_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DSTORE( x ) \ + { \ + { \ + ops_cnt += ( 2 * _STORE_C * ( x ) ); \ + inst_cnt[_STORE] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _STORE_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DLOGIC( x ) \ + { \ + { \ + ops_cnt += ( 2 * _LOGIC_C * ( x ) ); \ + inst_cnt[_LOGIC] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _LOGIC_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DSHIFT( x ) \ + { \ + { \ + ops_cnt += ( 2 * _SHIFT_C * ( x ) ); \ + inst_cnt[_SHIFT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _SHIFT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DDIV( x ) \ + { \ + { \ + ops_cnt += ( 2 * _DIV_C * ( x ) ); \ + inst_cnt[_DIV] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _DIV_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DSQRT( x ) \ + { \ + { \ + ops_cnt += ( 2 * _SQRT_C * ( x ) ); \ + inst_cnt[_SQRT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _SQRT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DTRANS( x ) \ + { \ + { \ + ops_cnt += ( 2 * _TRANS_C * ( x ) ); \ + inst_cnt[_TRANS] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _TRANS_P * ( x ) ); \ + } \ + } \ + } \ + } + +extern double ops_cnt; +extern double prom_cnt; +extern double inst_cnt[NUM_INST]; +extern int ops_cnt_activ; + +void reset_wmops( void ); +void push_wmops( const char *label ); +void pop_wmops( void ); +void update_wmops( void ); +void update_mem( void ); +void print_wmops( void ); + +#else /* WMOPS counting disabled */ + +#define reset_wmops() +extern int cntr_push_pop; +#define push_wmops( x ) ( cntr_push_pop++ ) +#define pop_wmops() ( cntr_push_pop-- ) +#define update_wmops() ( assert( cntr_push_pop == 0 ) ) +#define update_mem() +#define print_wmops() + +#define ADD( x ) +#define ABS( x ) +#define MULT( x ) +#define MAC( x ) +#define MOVE( x ) +#define STORE( x ) +#define LOGIC( x ) +#define SHIFT( x ) +#define BRANCH( x ) +#define DIV( x ) +#define SQRT( x ) +#define TRANS( x ) +#define FUNC( x ) +#define LOOP( x ) +#define INDIRECT( x ) +#define PTR_INIT( x ) +#define TEST( x ) +#define POWER( x ) +#define LOG( x ) +#define MISC( x ) + +#define DADD( x ) +#define DMULT( x ) +#define DMAC( x ) +#define DMOVE( x ) +#define DSTORE( x ) +#define DLOGIC( x ) +#define DSHIFT( x ) +#define DDIV( x ) +#define DSQRT( x ) +#define DTRANS( x ) + +#endif + +/* mac & msu (Non Instrumented Versions) */ +#ifndef mac +#define mac( a, b, c ) ( ( a ) + ( b ) * ( c ) ) +#endif +#ifndef mac +#define msu( a, b, c ) ( ( a ) - ( b ) * ( c ) ) +#endif + +#ifndef WMOPS +/* DESACTIVATE the Counting Mechanism */ +#define OP_COUNT_( op, n ) + +/* DESACTIVATE Operation Counter Wrappers */ +#define OP_COUNT_WRAPPER1_( op, val ) ( val ) +#define OP_COUNT_WRAPPER2_( expr ) +#define OP_COUNT_WRAPPER3_( op, expr ) expr + +/* DESACTIVATE Logical & Ternary Operators */ +#define __ +#define _ + +#else + +/* '*ops_cnt_ptr' is Used to Avoid: "warning: operation on 'ops_cnt' may be undefined" with Cygwin gcc Compiler */ +static double *ops_cnt_ptr = &ops_cnt; +#define OP_COUNT_( op, x ) ( *ops_cnt_ptr += ( op##_C * ( x ) ), inst_cnt[op] += ( x ) ) + +/******************************************************************/ +/* NOTES: */ +/* The 'wmc_flag_' flag is global to avoid declaration in every */ +/* function and 'static' to avoid clashing with other modules */ +/* that include this header file. */ +/* */ +/* The declarations of 'wmc_flag_' and 'wops_' in this header */ +/* file prevent the addition of a 'C' file to the Project. */ +/******************************************************************/ + +/* General Purpose Global Flag */ +static int wmc_flag_ = 0; + +/* Operation Counter Wrappers */ +#define OP_COUNT_WRAPPER1_( op, val ) ( op, val ) +#define OP_COUNT_WRAPPER2_( expr ) \ + if ( expr, 0 ) \ + ; \ + else +#define OP_COUNT_WRAPPER3_( op, expr ) \ + if ( op, 0 ) \ + ; \ + else \ + expr + +#endif + +/* Define all Macros without '{' & '}' (None of these should be called externally!) */ +#define ABS_( x ) OP_COUNT_( _ABS, ( x ) / WMOPS_BOOST_FAC ) +#define ADD_( x ) OP_COUNT_( _ADD, ( x ) / WMOPS_BOOST_FAC ) +#define MULT_( x ) OP_COUNT_( _MULT, ( x ) / WMOPS_BOOST_FAC ) +#define MAC_( x ) OP_COUNT_( _MAC, ( x ) / WMOPS_BOOST_FAC ) +#define MOVE_( x ) OP_COUNT_( _MOVE, ( x ) / WMOPS_BOOST_FAC ) +#define STORE_( x ) OP_COUNT_( _STORE, ( x ) / WMOPS_BOOST_FAC ) +#define LOGIC_( x ) OP_COUNT_( _LOGIC, ( x ) / WMOPS_BOOST_FAC ) +#define SHIFT_( x ) OP_COUNT_( _SHIFT, ( x ) / WMOPS_BOOST_FAC ) +#define BRANCH_( x ) OP_COUNT_( _BRANCH, ( x ) / WMOPS_BOOST_FAC ) +#define DIV_( x ) OP_COUNT_( _DIV, ( x ) / WMOPS_BOOST_FAC ) +#define SQRT_( x ) OP_COUNT_( _SQRT, ( x ) / WMOPS_BOOST_FAC ) +#define TRANS_( x ) OP_COUNT_( _TRANS, ( x ) / WMOPS_BOOST_FAC ) +#define POWER_( x ) TRANS_( x ) +#define LOG_( x ) TRANS_( x ) +#define LOOP_( x ) OP_COUNT_( _LOOP, ( x ) / WMOPS_BOOST_FAC ) +#define INDIRECT_( x ) OP_COUNT_( _INDIRECT, ( x ) / WMOPS_BOOST_FAC ) +#define PTR_INIT_( x ) OP_COUNT_( _PTR_INIT, ( x ) / WMOPS_BOOST_FAC ) +#define FUNC_( x ) ( OP_COUNT_( _MOVE, ( x ) / WMOPS_BOOST_FAC ), OP_COUNT_( _FUNC, 1 ) ) +#define MISC_( x ) ABS_( x ) + +/* Math Operations */ +#define abs_ OP_COUNT_WRAPPER1_( ABS_( 1 ), abs ) +#define fabs_ OP_COUNT_WRAPPER1_( ABS_( 1 ), fabs ) +#define labs_ OP_COUNT_WRAPPER1_( ABS_( 1 ), labs ) +#define floor_ OP_COUNT_WRAPPER1_( MISC_( 1 ), floor ) +#define sqrt_ OP_COUNT_WRAPPER1_( SQRT_( 1 ), sqrt ) +#define pow_ OP_COUNT_WRAPPER1_( POWER_( 1 ), pow ) +#define exp_ OP_COUNT_WRAPPER1_( POWER_( 1 ), exp ) +#define log_ OP_COUNT_WRAPPER1_( LOG_( 1 ), log ) +#define log10_ OP_COUNT_WRAPPER1_( LOG_( 1 ), log10 ) +#define cos_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), cos ) +#define sin_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), sin ) +#define tan_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), tan ) +#define acos_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), acos ) +#define asin_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), asin ) +#define atan_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), atan ) +#define atan2_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), atan2 ) +#define cosh_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), cosh ) +#define sinh_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), sinh ) +#define tanh_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), tanh ) +#define fmod_ OP_COUNT_WRAPPER1_( DIV_( 1 ), fmod ) +/* these macros use any local macros already defined */ +/* min/max and their Variants */ +#define min_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), min( ( a ), ( b ) ) ) +#define max_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), max( ( a ), ( b ) ) ) +#define MIN_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), MIN( ( a ), ( b ) ) ) +#define MAX_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), MAX( ( a ), ( b ) ) ) +#define Min_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), Min( ( a ), ( b ) ) ) +#define Max_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), Max( ( a ), ( b ) ) ) +/* Square and its Variants */ +#define sqr_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), sqr( ( x ) ) ) +#define Sqr_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), Sqr( ( x ) ) ) +#define SQR_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), SQR( ( x ) ) ) +#define square_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), square( ( x ) ) ) +#define Square_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), Square( ( x ) ) ) +#define SQUARE_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), SQUARE( ( x ) ) ) +/* Sign and its Variants */ +#define sign_( x ) OP_COUNT_WRAPPER1_( MOVE_( 1 ), sign( ( x ) ) ) +#define Sign_( x ) OP_COUNT_WRAPPER1_( MOVE_( 1 ), Sign( ( x ) ) ) +#define SIGN_( x ) OP_COUNT_WRAPPER1_( MOVE_( 1 ), SIGN( ( x ) ) ) +/* Square Root and its Variants */ +#define sqrtf_( x ) OP_COUNT_WRAPPER1_( SQRT_( 1 ), sqrtf( ( x ) ) ) +/* Invert Square Root and its Variants */ +#define inv_sqrt_( x ) OP_COUNT_WRAPPER1_( SQRT_( 1 ), inv_sqrt( ( x ) ) ) +/* Others */ +#define log_base_2_( x ) OP_COUNT_WRAPPER1_( ( LOG_( 1 ), MULT_( 1 ) ), log_base_2( ( x ) ) ) +#define log2_f_( x ) OP_COUNT_WRAPPER1_( ( LOG_( 1 ), MULT_( 1 ) ), log2_f( ( x ) ) ) +/* The 'wmc_flag_=wmc_flag_' is Used to Avoid: "warning: left-hand operand of comma expression has no effect" + with Cygwin gcc Compiler */ +#define _round_( x ) OP_COUNT_WRAPPER1_( wmc_flag_ = wmc_flag_, _round( ( x ) ) ) +#define round_f_( x ) OP_COUNT_WRAPPER1_( wmc_flag_ = wmc_flag_, round_f( ( x ) ) ) +#define _squant_( x ) OP_COUNT_WRAPPER1_( wmc_flag_ = wmc_flag_, _squant( ( x ) ) ) +/* Set Min/Max */ +#define set_min_( a, b ) OP_COUNT_WRAPPER3_( ( ADD_( 1 ), BRANCH_( 1 ), MOVE_( 1 ) ), set_min( ( a ), ( b ) ) ) +#define set_max_( a, b ) OP_COUNT_WRAPPER3_( ( ADD_( 1 ), BRANCH_( 1 ), MOVE_( 1 ) ), set_max( ( a ), ( b ) ) ) +/* mac & msu (Instrumented Versions) */ +#define mac_( a, b, c ) OP_COUNT_WRAPPER1_( MAC_( 1 ), mac( a, b, c ) ) +#define msu_( a, b, c ) OP_COUNT_WRAPPER1_( MAC_( 1 ), msu( a, b, c ) ) + +/* Functions */ +#define func_( name, x ) OP_COUNT_WRAPPER1_( FUNC_( x ), name ) + +/* Logical Operators */ +#ifndef __ +#define __ ( BRANCH_( 1 ), 1 ) && +#endif + +/* Ternary Operators (? and :) */ +#ifndef _ +#define _ ( BRANCH_( 1 ), 0 ) ? 0: +#endif + +/* Flow Control keywords */ +#define if_ \ + OP_COUNT_WRAPPER2_( BRANCH_( 1 ) ) \ + if +#define for_ OP_COUNT_WRAPPER2_( LOOP_(1)) for +#define while_( c ) \ + while \ + OP_COUNT_WRAPPER1_( BRANCH_( 1 ), ( c ) ) /* needs extra "()" if ',' encountered */ +#define do_ \ + do \ + { +#define _while \ + BRANCH_( 1 ); \ + } \ + while + +#define goto_ \ + OP_COUNT_WRAPPER2_( BRANCH_( 1 ) ) \ + goto +#define break_ \ + OP_COUNT_WRAPPER2_( BRANCH_( 1 ) ) \ + break +#define continue_ \ + OP_COUNT_WRAPPER2_( BRANCH_( 1 ) ) \ + continue +#define return_ \ + OP_COUNT_WRAPPER2_( ( wmc_flag_ = stack_tree_level_, STACK_DEPTH_FCT_RETURN ) ) \ + return + +#define switch_ \ + OP_COUNT_WRAPPER2_( ( BRANCH_( 1 ), wmc_flag_ = 1 ) ) \ + switch +#define cost_( n ) OP_COUNT_WRAPPER2_( wmc_flag_ ? ( ADD_( n ), BRANCH_( n ), wmc_flag_ = 0 ) : 0 ); + +#ifdef WMOPS + +#define ACC 2 +#define MUL 1 + +/* Counting Function (should not be called externally!) */ +static void wops_( const char *ops ) +{ + char lm = 0; /* lm: Last Operation is Math */ + static char lo = 0; /* Last Operation */ + + void ( *fct )( const char *ops ) = wops_; + +st: + while ( *ops != '\0' ) + { + switch ( *ops++ ) + { + int cnt; + case '-': + for ( cnt = 0; ops[cnt] == '>'; cnt++ ) + ; + if ( cnt & 1 ) + goto ind; + case '+': + lm = 2; + if ( lo & MUL ) + { + MULT_( -1 ); + MAC_( 1 ); + break; + } + lo = ACC << 2; + case 'U': + case 'D': + ADD_( 1 ); + break; + case '*': + lm = 2; + if ( lo & ACC ) + { + ADD_( -1 ); + MAC_( 1 ); + break; + } + lo = MUL << 2; + MULT_( 1 ); + break; + case '/': + case '%': + lm = 2; + DIV_( 1 ); + break; + case '&': + case '|': + case '^': + lm = 2; + case '~': + LOGIC_( 1 ); + break; + case '<': + case '>': + if ( *ops != ops[-1] ) + goto error; + ops++; + case -85: + case -69: + lm = 2; + SHIFT_( 1 ); + break; + case 'L': + case 'G': + if ( *ops == 't' ) + goto comp; + case 'E': + case 'N': + if ( *ops != 'e' ) + goto error; + comp: + ops++; + ADD_( 1 ); + break; + case '!': + MISC_( 2 ); + break; + case 'M': + MOVE_( 1 ); + break; + case 'S': + STORE_( 1 ); + break; + case 'P': + PTR_INIT_( 1 ); + break; + case '[': + case ']': + goto st; + ind: + ops++; + case 'I': + case '.': + INDIRECT_( 1 ); + break; + case '=': + if ( lm ) + goto st; + case '\0': + /* This Shouldn't Happen */ + /* These are Used to Avoid: "warning: 'name' defined but not used" with Cygwin gcc Compiler */ + wmc_flag_ = wmc_flag_; + ops_cnt_ptr = ops_cnt_ptr; + fct( "" ); + error: + default: + fprintf( stderr, "\r wops: Invalid Counting Operation '%s'\n", ops - 1 ); + exit( -1 ); + } + lm >>= 1; + lo >>= 2; + } + + return; +} + +#endif + +/* All Other Operations */ diff --git a/lib_dec/ivas_corecoder_dec_reconfig.c b/lib_dec/ivas_corecoder_dec_reconfig.c index 7c6d17bca2..b56f10d138 100644 --- a/lib_dec/ivas_corecoder_dec_reconfig.c +++ b/lib_dec/ivas_corecoder_dec_reconfig.c @@ -53,7 +53,6 @@ *-------------------------------------------------------------------*/ ivas_error ivas_corecoder_dec_reconfig( -#ifdef MC_BITRATE_SWITCHING Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t nSCE_old, /* i : number of SCEs in previous frame */ int16_t nCPE_old, /* i : number of CPEs in previous frame */ @@ -61,21 +60,12 @@ ivas_error ivas_corecoder_dec_reconfig( const int16_t sba_dirac_stereo_flag_old, /* i : signal stereo rendering using DFT upmix in previous frame */ const int32_t brate_SCE, /* i : bitrate to be set for the SCEs */ const int32_t brate_CPE /* i : bitrate to be set for the CPEs */ -#else - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t nSCE_old, /* i : number of SCEs in previous frame */ - const int16_t nCPE_old, /* i : number of CPEs in previous frame */ - const int16_t nchan_transport_old, /* i : number of TCs in previous frame */ - const int16_t sba_dirac_stereo_flag_old /* i : signal stereo output for SBA DirAC in previous frame */ -#endif ) { int16_t n, sce_id, cpe_id, output_frame; int16_t nSCE_existing, nCPE_existing; int32_t ivas_total_brate; -#ifdef MC_BITRATE_SWITCHING MC_MODE last_mc_mode; -#endif DECODER_CONFIG_HANDLE hDecoderConfig; ivas_error error; @@ -88,7 +78,6 @@ ivas_error ivas_corecoder_dec_reconfig( error = IVAS_ERR_OK; output_frame = (int16_t) ( hDecoderConfig->output_Fs / FRAMES_PER_SEC ); -#ifdef MC_BITRATE_SWITCHING if ( st_ivas->ivas_format == MC_FORMAT ) { last_mc_mode = ivas_mc_mode_select( ivas_mc_map_output_config_to_mc_ls_setup( st_ivas->transport_config ), st_ivas->hDecoderConfig->last_ivas_total_brate ); /* NB: this assumes that LS config remains the same between frames */ @@ -97,18 +86,13 @@ ivas_error ivas_corecoder_dec_reconfig( { last_mc_mode = MC_MODE_NONE; } -#endif /*-----------------------------------------------------------------* * Allocate, initalize, and configure SCE/CPE/MCT handles *-----------------------------------------------------------------*/ /* remove dummy CPE element for DFT stereo-like upmix */ -#ifdef MC_BITRATE_SWITCHING if ( ( st_ivas->ivas_format == SBA_FORMAT && sba_dirac_stereo_flag_old && !st_ivas->sba_dirac_stereo_flag ) || ( st_ivas->ivas_format == MC_FORMAT && last_mc_mode == MC_MODE_MCMASA && sba_dirac_stereo_flag_old && !st_ivas->sba_dirac_stereo_flag ) ) -#else - if ( st_ivas->ivas_format == SBA_FORMAT && sba_dirac_stereo_flag_old && !st_ivas->sba_dirac_stereo_flag ) -#endif { st_ivas->hCPE[0]->hCoreCoder[0] = NULL; st_ivas->hCPE[0]->hCoreCoder[1] = NULL; @@ -125,29 +109,17 @@ ivas_error ivas_corecoder_dec_reconfig( } } -#ifdef MC_BITRATE_SWITCHING if ( st_ivas->nchan_transport == nchan_transport_old && st_ivas->nSCE == nSCE_old && st_ivas->nCPE == nCPE_old ) -#else - if ( st_ivas->nchan_transport == nchan_transport_old ) -#endif { for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) { -#ifdef MC_BITRATE_SWITCHING st_ivas->hSCE[sce_id]->element_brate = brate_SCE; -#else - st_ivas->hSCE[sce_id]->element_brate = ivas_total_brate / st_ivas->nchan_transport; -#endif st_ivas->hSCE[sce_id]->hCoreCoder[0]->total_brate = st_ivas->hSCE[sce_id]->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ } for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { -#ifdef MC_BITRATE_SWITCHING st_ivas->hCPE[cpe_id]->element_brate = brate_CPE; -#else - st_ivas->hCPE[cpe_id]->element_brate = ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS; -#endif /* prepare bitstream buffers */ for ( n = 0; n < CPE_CHANNELS; n++ ) { @@ -182,7 +154,6 @@ ivas_error ivas_corecoder_dec_reconfig( st_ivas->hCPE[cpe_id] = NULL; } -#ifdef MC_BITRATE_SWITCHING /* the CPE-internal settings depend from ivas_format and mc_mode, so clean-up when switching between mc_modes */ if ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode != last_mc_mode && ( st_ivas->mc_mode == MC_MODE_MCMASA || last_mc_mode == MC_MODE_MCMASA ) ) { @@ -194,7 +165,6 @@ ivas_error ivas_corecoder_dec_reconfig( nCPE_old = 0; nCPE_existing = min( nCPE_old, st_ivas->nCPE ); } -#endif if ( st_ivas->nCPE <= 1 && st_ivas->hMCT != NULL ) { ivas_mct_dec_close( &st_ivas->hMCT ); @@ -209,20 +179,12 @@ ivas_error ivas_corecoder_dec_reconfig( for ( sce_id = 0; sce_id < nSCE_existing; sce_id++ ) { -#ifdef MC_BITRATE_SWITCHING st_ivas->hSCE[sce_id]->element_brate = brate_SCE; -#else - st_ivas->hSCE[sce_id]->element_brate = ivas_total_brate / st_ivas->nchan_transport; -#endif st_ivas->hSCE[sce_id]->hCoreCoder[0]->total_brate = st_ivas->hSCE[sce_id]->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ } for ( ; sce_id < st_ivas->nSCE; sce_id++ ) { -#ifdef MC_BITRATE_SWITCHING if ( ( error = create_sce_dec( st_ivas, sce_id, brate_SCE ) ) != IVAS_ERR_OK ) -#else - if ( ( error = create_sce_dec( st_ivas, sce_id, ivas_total_brate / st_ivas->nchan_transport ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -230,11 +192,7 @@ ivas_error ivas_corecoder_dec_reconfig( for ( cpe_id = 0; cpe_id < nCPE_existing; cpe_id++ ) { -#ifdef MC_BITRATE_SWITCHING st_ivas->hCPE[cpe_id]->element_brate = brate_CPE; -#else - st_ivas->hCPE[cpe_id]->element_brate = ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS; -#endif /* prepare bitstream buffers */ for ( n = 0; n < CPE_CHANNELS; n++ ) { @@ -243,7 +201,6 @@ ivas_error ivas_corecoder_dec_reconfig( } for ( ; cpe_id < st_ivas->nCPE; cpe_id++ ) { -#ifdef MC_BITRATE_SWITCHING #ifdef FIX_265_MC_BRATE_SWITCHING if ( st_ivas->mc_mode == MC_MODE_MCMASA && st_ivas->hOutSetup.separateChannelEnabled ) { @@ -251,9 +208,6 @@ ivas_error ivas_corecoder_dec_reconfig( } #endif if ( ( error = create_cpe_dec( st_ivas, cpe_id, brate_CPE ) ) != IVAS_ERR_OK ) -#else - if ( ( error = create_cpe_dec( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -309,12 +263,8 @@ ivas_error ivas_corecoder_dec_reconfig( } /* create dummy CPE element for DFT stereo-like upmix */ -#ifdef MC_BITRATE_SWITCHING if ( ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->sba_dirac_stereo_flag && !sba_dirac_stereo_flag_old ) || ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCMASA && st_ivas->sba_dirac_stereo_flag && !sba_dirac_stereo_flag_old ) ) -#else - if ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->sba_dirac_stereo_flag && !sba_dirac_stereo_flag_old ) -#endif { if ( ( error = create_cpe_dec( st_ivas, 0, ivas_total_brate / ( st_ivas->nSCE + st_ivas->nCPE ) ) ) != IVAS_ERR_OK ) { diff --git a/lib_dec/ivas_cpe_dec.c b/lib_dec/ivas_cpe_dec.c index 3ac34a6009..bb8c9a9484 100644 --- a/lib_dec/ivas_cpe_dec.c +++ b/lib_dec/ivas_cpe_dec.c @@ -103,11 +103,7 @@ ivas_error ivas_cpe_dec( * dynamically allocate data structures depending on the actual stereo mode *----------------------------------------------------------------*/ -#ifdef MC_BITRATE_SWITCHING if ( ( error = stereo_memory_dec( ivas_total_brate, hCPE, nb_bits_metadata, st_ivas->hDecoderConfig->output_Fs, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->nchan_transport ) ) != IVAS_ERR_OK ) -#else - if ( ( error = stereo_memory_dec( ivas_total_brate, hCPE, nb_bits_metadata, st_ivas->hDecoderConfig->output_Fs, st_ivas->ivas_format, st_ivas->nchan_transport ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -833,13 +829,11 @@ void destroy_cpe_dec( int16_t n; Decoder_State *st; -#ifdef MC_BITRATE_SWITCHING /* make sure we deallocate a potential distinct hTcxCfg for a MCT LFE channel (can only happen in rs) */ if ( hCPE->hCoreCoder[1] != NULL && hCPE->hCoreCoder[1]->mct_chan_mode == MCT_CHAN_MODE_LFE && hCPE->hCoreCoder[1]->hTcxCfg != hCPE->hCoreCoder[0]->hTcxCfg ) { hCPE->hCoreCoder[1]->mct_chan_mode = MCT_CHAN_MODE_IGNORE; } -#endif for ( n = 0; n < CPE_CHANNELS; n++ ) { diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 752bc587eb..2b5b073142 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -356,14 +356,10 @@ ivas_error ivas_dec( /* LFE channel decoder */ if ( st_ivas->mc_mode == MC_MODE_MCT ) { -#ifdef MC_BITRATE_SWITCHING if ( st_ivas->hCPE[1]->hCoreCoder[1]->hTcxCfg == NULL ) { -#endif st_ivas->hCPE[1]->hCoreCoder[1]->hTcxCfg = st_ivas->hCPE[1]->hCoreCoder[0]->hTcxCfg; -#ifdef MC_BITRATE_SWITCHING } -#endif ivas_lfe_dec( st_ivas->hLFE, st, output_frame, st_ivas->bfi, output_lfe_ch ); } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 26e8612c16..595b362223 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -996,9 +996,7 @@ ivas_error ivas_init_decoder( } else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { -#ifdef MC_BITRATE_SWITCHING int32_t brate_sce, brate_cpe; -#endif ivas_mcmasa_setNumTransportChannels( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), ivas_total_brate ); @@ -1036,65 +1034,25 @@ ivas_error ivas_init_decoder( } } -#ifdef MC_BITRATE_SWITCHING ivas_mcmasa_split_brate( st_ivas->hOutSetup.separateChannelEnabled, ivas_total_brate, st_ivas->nSCE, st_ivas->nCPE, &brate_sce, &brate_cpe ); -#endif for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) { -#ifdef MC_BITRATE_SWITCHING if ( ( error = create_sce_dec( st_ivas, sce_id, brate_sce ) ) != IVAS_ERR_OK ) { return error; } -#else - if ( st_ivas->hOutSetup.separateChannelEnabled ) - { - if ( ( error = create_sce_dec( st_ivas, sce_id, ivas_mcmasa_mono_brate( ivas_total_brate ) ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else - { - if ( ( error = create_sce_dec( st_ivas, sce_id, ivas_total_brate / ( st_ivas->nSCE + st_ivas->nCPE ) ) ) != IVAS_ERR_OK ) - { - return error; - } - } -#endif reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] ); } for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { -#ifdef MC_BITRATE_SWITCHING st_ivas->element_mode_init = IVAS_CPE_MDCT; /* element_mode_init was IVAS_SCE for SCE initialization */ if ( ( error = create_cpe_dec( st_ivas, cpe_id, brate_cpe ) ) != IVAS_ERR_OK ) { return error; } -#else - if ( st_ivas->hOutSetup.separateChannelEnabled ) - { - st_ivas->element_mode_init = IVAS_CPE_MDCT; /* element_mode_init was IVAS_SCE for SCE initialization */ - - if ( ( error = create_cpe_dec( st_ivas, cpe_id, ivas_total_brate - st_ivas->hSCE[0]->element_brate ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else - { - st_ivas->element_mode_init = IVAS_CPE_MDCT; - - if ( ( error = create_cpe_dec( st_ivas, cpe_id, ivas_total_brate / ( st_ivas->nSCE + st_ivas->nCPE ) ) ) != IVAS_ERR_OK ) - { - return error; - } - } -#endif for ( n = 0; n < CPE_CHANNELS; n++ ) { diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 095cd89f64..63cbbd91ad 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -1019,25 +1019,17 @@ static ivas_error ivas_ism_bitrate_switching( { ivas_error error; int32_t element_brate_tmp[MAX_NUM_OBJECTS]; -#ifdef MC_BITRATE_SWITCHING int16_t nSCE_old, nCPE_old; -#endif error = IVAS_ERR_OK; -#ifdef MC_BITRATE_SWITCHING nCPE_old = st_ivas->nCPE; nSCE_old = st_ivas->nSCE; -#endif ivas_ism_config( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, num_obj, NULL, NULL, NULL, element_brate_tmp, NULL, NULL ); st_ivas->nSCE = st_ivas->nchan_transport; -#ifdef MC_BITRATE_SWITCHING ivas_corecoder_dec_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, 0, st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport, ( st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ); -#else - ivas_corecoder_dec_reconfig( st_ivas, nchan_transport_old, 0, nchan_transport_old, 0 ); -#endif ivas_hp20_dec_reconfig( st_ivas, nchan_transport_old ); diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 78a6cface9..082b39da50 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -57,7 +57,6 @@ #define PARAM_MC_LOCAL_SZ_LFE_MAP 5 -#ifdef MC_BITRATE_SWITCHING /*-----------------------------------------------------------------------* * Local typedefs *-----------------------------------------------------------------------*/ @@ -69,7 +68,6 @@ typedef struct parameter_band_mapping_struct float source_band_factor[20][4]; } PARAM_MC_PARAMETER_BAND_MAPPING; -#endif /*-----------------------------------------------------------------------* * Local function prototypes @@ -101,9 +99,7 @@ static void param_mc_get_diff_proto_info( const float *proto_mtx, const uint16_t static void ivas_param_mc_mc2sba_cldfb( IVAS_OUTPUT_SETUP hTransSetup, float *hoa_encoder, const int16_t slot_idx, float Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], float Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], const int16_t nBands, const float gain_lfe ); -#ifdef MC_BITRATE_SWITCHING static void ivas_param_mc_get_param_band_mapping( const int16_t n_target_bands, const int16_t *target_band_grouping, const int16_t n_source_bands, const int16_t *source_band_grouping, PARAM_MC_PARAMETER_BAND_MAPPING *parameter_band_mapping ); -#endif static void ivas_param_mc_bs_decode_parameter_values( uint16_t bit_buffer[], int16_t *bit_pos, const int16_t max_bits, int16_t *BER_detect, HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC, HANDLE_PARAM_MC_PARAMETER_CODING_INFO hParamCodingInfo, const int16_t map_size_wo_lfe, const int16_t map_size, const int16_t num_lfe_bands, const int16_t band_step, const int16_t num_param_bands, float *value_buffer ); @@ -429,7 +425,6 @@ ivas_error ivas_param_mc_dec_open( } -#ifdef MC_BITRATE_SWITCHING /*------------------------------------------------------------------------- * ivas_param_mc_get_param_band_mapping() * @@ -910,7 +905,6 @@ ivas_error ivas_param_mc_dec_reconfig( return error; } -#endif /*------------------------------------------------------------------------- * param_mc_get_num_cldfb_syntheses() diff --git a/lib_dec/ivas_mcmasa_dec.c b/lib_dec/ivas_mcmasa_dec.c index 87ab621ae8..2c257f4dbd 100644 --- a/lib_dec/ivas_mcmasa_dec.c +++ b/lib_dec/ivas_mcmasa_dec.c @@ -40,7 +40,6 @@ the United Nations Convention on Contracts on the International Sales of Goods. #endif #include "wmc_auto.h" -#ifdef MC_BITRATE_SWITCHING /*------------------------------------------------------------------------- * ivas_mcmasa_dec_reconfig() @@ -139,4 +138,3 @@ ivas_error ivas_mcmasa_dec_reconfig( return error; } -#endif diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 1616fa7c1b..14c8cc3be1 100755 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -49,13 +49,11 @@ #endif -#ifdef MC_BITRATE_SWITCHING /*-----------------------------------------------------------------------* * Local function prototypes *-----------------------------------------------------------------------*/ static ivas_error ivas_mc_dec_reconfig( Decoder_Struct *st_ivas ); -#endif /*--------------------------------------------------------------------------* @@ -468,9 +466,7 @@ ivas_error mct_dec_reconfigure( * run into a number of problems */ for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { -#ifdef MC_BITRATE_SWITCHING st_ivas->hCPE[cpe_id]->element_brate = cp_bitrate; -#endif for ( n = 0; n < CPE_CHANNELS; n++ ) { st = st_ivas->hCPE[cpe_id]->hCoreCoder[n]; @@ -635,11 +631,7 @@ ivas_error ivas_mc_dec_config( { if ( st_ivas->hDecoderConfig->last_ivas_total_brate != st_ivas->hDecoderConfig->ivas_total_brate || st_ivas->transport_config != signaled_config || last_mc_mode != st_ivas->mc_mode ) { -#ifdef MC_BITRATE_SWITCHING ivas_mc_dec_reconfig( st_ivas ); -#else - return IVAS_ERROR( IVAS_ERR_RECONFIGURE_NOT_SUPPORTED, "Error: MC format switching not supported yet!!!\n\n" ); -#endif } } @@ -650,7 +642,6 @@ ivas_error ivas_mc_dec_config( } -#ifdef MC_BITRATE_SWITCHING /*------------------------------------------------------------------------- * ivas_mc_dec_reconfig() * @@ -662,11 +653,7 @@ static ivas_error ivas_mc_dec_reconfig( ) { int16_t nchan_transport_old, nSCE_old, nCPE_old, sba_dirac_stereo_flag_old, nchan_hp20_old; -#ifdef MC_BITRATE_SWITCHING int16_t numCldfbAnalyses_old, numCldfbSyntheses_old; -#else - int16_t numCldfbAnalyses_old, numCldfbAnalyses, numCldfbSyntheses, numCldfbSyntheses_old, i; -#endif int32_t new_brate_SCE, new_brate_CPE, ivas_total_brate; RENDERER_TYPE renderer_type_old; ivas_error error; @@ -964,70 +951,8 @@ static ivas_error ivas_mc_dec_reconfig( * CLDFB instances *-----------------------------------------------------------------*/ -#ifdef MC_BITRATE_SWITCHING ivas_cldfb_dec_reconfig( st_ivas, nchan_transport_old, numCldfbAnalyses_old, numCldfbSyntheses_old ); -#else - ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses, &numCldfbSyntheses ); - - /* Analysis*/ - if ( numCldfbAnalyses_old > numCldfbAnalyses ) - { - /* delete superfluous CLDFB synthesis instances */ - for ( i = numCldfbAnalyses; i < numCldfbAnalyses_old; i++ ) - { - deleteCldfb( &( st_ivas->cldfbAnaDec[i] ) ); - st_ivas->cldfbAnaDec[i] = NULL; - } - } - else if ( numCldfbAnalyses_old < numCldfbAnalyses ) - { - /* create additional CLDFB synthesis instances */ - for ( i = numCldfbAnalyses_old; i < numCldfbAnalyses; i++ ) - { - if ( ( error = openCldfb( &( st_ivas->cldfbAnaDec[i] ), CLDFB_ANALYSIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) - { - return error; - } - } - } - - if ( ( last_mc_mode == MC_MODE_MCMASA ) && ( nchan_transport_old == 1 ) && ( ( renderer_type_old == RENDERER_BINAURAL_PARAMETRIC ) || ( renderer_type_old == RENDERER_BINAURAL_PARAMETRIC_ROOM ) || ( renderer_type_old == RENDERER_STEREO_PARAMETRIC ) ) ) - { - /* cldfbAnaDec[1] might be modified by DirAC (ivas_dirac_dec_binaural_internal) -> re-instantiate it */ - if ( ( numCldfbAnalyses_old > 1 ) && ( numCldfbAnalyses > 1 ) ) - { - deleteCldfb( &( st_ivas->cldfbAnaDec[1] ) ); - st_ivas->cldfbAnaDec[1] = NULL; - if ( ( error = openCldfb( &( st_ivas->cldfbAnaDec[1] ), CLDFB_ANALYSIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) - { - return error; - } - } - } - - /* Synthesis */ - if ( numCldfbSyntheses_old > numCldfbSyntheses ) - { - /* delete superfluous CLDFB synthesis instances */ - for ( i = numCldfbSyntheses; i < numCldfbSyntheses_old; i++ ) - { - deleteCldfb( &( st_ivas->cldfbSynDec[i] ) ); - st_ivas->cldfbSynDec[i] = NULL; - } - } - else if ( numCldfbSyntheses_old < numCldfbSyntheses ) - { - /* create additional CLDFB synthesis instances */ - for ( i = numCldfbSyntheses_old; i < numCldfbSyntheses; i++ ) - { - if ( ( error = openCldfb( &( st_ivas->cldfbSynDec[i] ), CLDFB_SYNTHESIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) - { - return error; - } - } - } -#endif /*-----------------------------------------------------------------* * Allocate the LFE handle that is coded seperately after the allocation of the core coders @@ -1199,4 +1124,3 @@ static ivas_error ivas_mc_dec_reconfig( return error; } -#endif diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index b0ce627c61..336b42c06f 100755 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -404,11 +404,7 @@ void ivas_mdct_dec_side_bits_frame_channel( param_lpc[0][0] = get_next_indice( st0, 1 ) << 1; /* read low br mode flag (if it is possible to be non-zero) */ -#ifdef MC_BITRATE_SWITCHING if ( sts[0]->element_brate == IVAS_48k && !( ( sts[0]->core == TCX_20 && sts[1]->core == TCX_20 ) || sts[1]->mct_chan_mode == MCT_CHAN_MODE_LFE ) ) -#else - if ( sts[0]->element_brate == IVAS_48k && !( sts[0]->core == TCX_20 && sts[1]->core == TCX_20 ) ) -#endif { sns_low_br_mode = get_next_indice( st0, 1 ); } diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 7853345225..82123af232 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -919,11 +919,7 @@ ivas_error ivas_sba_dec_reconfigure( * Allocate, initalize, and configure SCE/CPE/MCT handles *-----------------------------------------------------------------*/ -#ifdef MC_BITRATE_SWITCHING ivas_corecoder_dec_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, sba_dirac_stereo_flag_old, st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport, ( st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ); -#else - ivas_corecoder_dec_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, sba_dirac_stereo_flag_old ); -#endif /*-----------------------------------------------------------------* * HP20 memories diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index 165d7dc896..d8fb4d0272 100755 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -345,9 +345,7 @@ ivas_error stereo_memory_dec( const int16_t nb_bits_metadata, /* i : number of metadata bits */ const int32_t output_Fs, /* i : output sampling rate */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ -#ifdef MC_BITRATE_SWITCHING const MC_MODE mc_mode, /* i : MC mode */ -#endif const int16_t nchan_transport /* i : number of transport channels*/ ) { @@ -962,7 +960,6 @@ ivas_error stereo_memory_dec( } } -#ifdef MC_BITRATE_SWITCHING /*--------------------------------------------------------------* * Bitrate switching in MASA format *---------------------------------------------------------------*/ @@ -1007,7 +1004,6 @@ ivas_error stereo_memory_dec( } } } -#endif return error; } diff --git a/lib_enc/amr_wb_enc.c b/lib_enc/amr_wb_enc.c index b40be98fc2..52117ee7cd 100644 --- a/lib_enc/amr_wb_enc.c +++ b/lib_enc/amr_wb_enc.c @@ -531,11 +531,7 @@ void amr_wb_enc( updt_enc( st, old_exc, pitch_buf, 0, Aq, isf_new, isp_new, dummy_buf ); /* update main codec paramaters */ -#ifdef MC_BITRATE_SWITCHING updt_enc_common( st ); -#else - updt_enc_common( st, Etot ); -#endif #ifdef DEBUG_MODE_INFO diff --git a/lib_enc/evs_enc.c b/lib_enc/evs_enc.c index 54e639923e..584ccb7d50 100644 --- a/lib_enc/evs_enc.c +++ b/lib_enc/evs_enc.c @@ -489,11 +489,7 @@ ivas_error evs_enc( * Updates *---------------------------------------------------------------------*/ -#ifdef MC_BITRATE_SWITCHING updt_enc_common( st ); -#else - updt_enc_common( st, Etot ); -#endif if ( st->mdct_sw == MODE1 ) { diff --git a/lib_enc/ivas_core_enc.c b/lib_enc/ivas_core_enc.c index 0d1bcf6381..1ee672efed 100644 --- a/lib_enc/ivas_core_enc.c +++ b/lib_enc/ivas_core_enc.c @@ -399,14 +399,10 @@ ivas_error ivas_core_enc( * Common updates *---------------------------------------------------------------------*/ -#ifdef MC_BITRATE_SWITCHING if ( !MCT_flag ) /* for MCT do this later, otherwise there can be a problem because TCX quant happens later and might get the wrong last_core on a bit rate switch */ { updt_enc_common( st ); } -#else - updt_enc_common( st, Etot ); -#endif } diff --git a/lib_enc/ivas_corecoder_enc_reconfig.c b/lib_enc/ivas_corecoder_enc_reconfig.c index df8dbbb458..3fa89eb5b7 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig.c +++ b/lib_enc/ivas_corecoder_enc_reconfig.c @@ -50,7 +50,6 @@ *-------------------------------------------------------------------*/ ivas_error ivas_corecoder_enc_reconfig( -#ifdef MC_BITRATE_SWITCHING Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ const int16_t nSCE_old, /* i : number of SCEs in previous frame */ const int16_t nCPE_old, /* i : number of CPEs in previous frame */ @@ -58,12 +57,6 @@ ivas_error ivas_corecoder_enc_reconfig( const int32_t brate_SCE, /* i : bitrate to be set for the SCEs */ const int32_t brate_CPE, /* i : bitrate to be set for the CPEs */ const MC_MODE last_mc_mode /* i : switching between MC modes: last mode */ -#else - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - const int16_t nSCE_old, /* i : number of SCEs in previous frame */ - const int16_t nCPE_old, /* i : number of CPEs in previous frame */ - const int16_t nchan_transport_old /* i : number of TCs in previous frame */ -#endif ) { int16_t n, sce_id, cpe_id; @@ -72,9 +65,6 @@ ivas_error ivas_corecoder_enc_reconfig( BSTR_ENC_HANDLE hBstr, hMetaData; Indice *ind_list, *ind_list_metadata; int16_t nb_bits_tot, next_ind, last_ind; -#ifndef MC_BITRATE_SWITCHING - int32_t ivas_total_brate; -#endif ENCODER_CONFIG_HANDLE hEncoderConfig; ivas_error error; @@ -83,9 +73,6 @@ ivas_error ivas_corecoder_enc_reconfig( *-----------------------------------------------------------------*/ hEncoderConfig = st_ivas->hEncoderConfig; -#ifndef MC_BITRATE_SWITCHING - ivas_total_brate = hEncoderConfig->ivas_total_brate; -#endif error = IVAS_ERR_OK; len_inp_memory = (int16_t) ( hEncoderConfig->input_Fs / FRAMES_PER_SEC ); @@ -98,30 +85,18 @@ ivas_error ivas_corecoder_enc_reconfig( * Switching between SCE(s)/CPE(s)/MCT *-----------------------------------------------------------------*/ -#ifdef MC_BITRATE_SWITCHING if ( st_ivas->nchan_transport == nchan_transport_old && st_ivas->nSCE == nSCE_old && st_ivas->nCPE == nCPE_old ) /* in McMASA, nchan_transport may be the same, but nSCE/nCPE differs */ -#else - if ( st_ivas->nchan_transport == nchan_transport_old ) -#endif { for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) { copy_encoder_config( st_ivas, st_ivas->hSCE[sce_id]->hCoreCoder[0], 0 ); -#ifdef MC_BITRATE_SWITCHING st_ivas->hSCE[sce_id]->element_brate = brate_SCE; -#else - st_ivas->hSCE[sce_id]->element_brate = ivas_total_brate / st_ivas->nchan_transport; -#endif st_ivas->hSCE[sce_id]->hCoreCoder[0]->total_brate = st_ivas->hSCE[sce_id]->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ } for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { -#ifdef MC_BITRATE_SWITCHING st_ivas->hCPE[cpe_id]->element_brate = brate_CPE; -#else - st_ivas->hCPE[cpe_id]->element_brate = ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS; -#endif /* prepare bitstream buffers */ for ( n = 0; n < CPE_CHANNELS; n++ ) { @@ -141,7 +116,6 @@ ivas_error ivas_corecoder_enc_reconfig( } else { -#ifdef MC_BITRATE_SWITCHING int16_t nchan_transport_real, nchan_transport_old_real; nchan_transport_old_real = nchan_transport_old; @@ -159,9 +133,6 @@ ivas_error ivas_corecoder_enc_reconfig( /* something in transport changes */ ind_list = NULL; ind_list_metadata = NULL; -#else - ind_list = NULL; -#endif hBstr = NULL; hMetaData = NULL; @@ -190,7 +161,6 @@ ivas_error ivas_corecoder_enc_reconfig( last_ind = hBstr->last_ind; ind_list_metadata = hMetaData->ind_list; /* pointer to the beginning of the global list */ -#ifdef MC_BITRATE_SWITCHING if ( hEncoderConfig->ivas_format == MC_FORMAT && last_mc_mode == MC_MODE_MCMASA && st_ivas->mc_mode == MC_MODE_MCMASA ) { /* within McMASA we can modify the transport signals when switching */ @@ -218,9 +188,6 @@ ivas_error ivas_corecoder_enc_reconfig( { n_CoreCoder_existing = min( nchan_transport_real, nchan_transport_old_real ); } -#else - n_CoreCoder_existing = min( st_ivas->nchan_transport, nchan_transport_old ); -#endif /* destroy superfluous core-coder elements */ for ( sce_id = st_ivas->nSCE; sce_id < nSCE_old; sce_id++ ) @@ -271,21 +238,13 @@ ivas_error ivas_corecoder_enc_reconfig( for ( sce_id = 0; sce_id < nSCE_existing; sce_id++ ) { copy_encoder_config( st_ivas, st_ivas->hSCE[sce_id]->hCoreCoder[0], 0 ); -#ifdef MC_BITRATE_SWITCHING st_ivas->hSCE[sce_id]->element_brate = brate_SCE; -#else - st_ivas->hSCE[sce_id]->element_brate = ivas_total_brate / st_ivas->nchan_transport; -#endif st_ivas->hSCE[sce_id]->hCoreCoder[0]->total_brate = st_ivas->hSCE[sce_id]->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ } for ( sce_id = nSCE_existing; sce_id < st_ivas->nSCE; sce_id++ ) { -#ifdef MC_BITRATE_SWITCHING if ( ( error = create_sce_enc( st_ivas, sce_id, brate_SCE ) ) != IVAS_ERR_OK ) -#else - if ( ( error = create_sce_enc( st_ivas, sce_id, ivas_total_brate / st_ivas->nchan_transport ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -322,18 +281,13 @@ ivas_error ivas_corecoder_enc_reconfig( for ( cpe_id = 0; cpe_id < nCPE_existing; cpe_id++ ) { -#ifdef MC_BITRATE_SWITCHING st_ivas->hCPE[cpe_id]->element_brate = brate_CPE; -#else - st_ivas->hCPE[cpe_id]->element_brate = ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS; -#endif /* prepare bitstream buffers */ for ( n = 0; n < CPE_CHANNELS; n++ ) { copy_encoder_config( st_ivas, st_ivas->hCPE[cpe_id]->hCoreCoder[n], 0 ); st_ivas->hCPE[cpe_id]->hCoreCoder[n]->total_brate = st_ivas->hCPE[cpe_id]->element_brate / ( st_ivas->nCPE > 1 ? 1 : CPE_CHANNELS ); /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ -#ifdef MC_BITRATE_SWITCHING st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->ind_list = ind_list + ( cpe_id * CPE_CHANNELS + n + st_ivas->nSCE ) * MAX_NUM_INDICES; if ( cpe_id * CPE_CHANNELS + n > 0 || ( st_ivas->mc_mode == MC_MODE_MCMASA && st_ivas->nSCE > 0 ) ) { @@ -345,22 +299,17 @@ ivas_error ivas_corecoder_enc_reconfig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->nb_bits_tot = nb_bits_tot; st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->next_ind = next_ind; } -#endif } } for ( cpe_id = nCPE_existing; cpe_id < st_ivas->nCPE; cpe_id++ ) { -#ifdef MC_BITRATE_SWITCHING if ( st_ivas->mc_mode == MC_MODE_MCMASA && st_ivas->hMcMasa->separateChannelEnabled ) { st_ivas->hEncoderConfig->element_mode_init = IVAS_CPE_MDCT; } if ( ( error = create_cpe_enc( st_ivas, cpe_id, brate_CPE ) ) != IVAS_ERR_OK ) -#else - if ( ( error = create_cpe_enc( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -377,13 +326,8 @@ ivas_error ivas_corecoder_enc_reconfig( /* prepare bitstream buffers */ for ( n = 0; n < CPE_CHANNELS; n++ ) { -#ifdef MC_BITRATE_SWITCHING st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->ind_list = ind_list + ( cpe_id * CPE_CHANNELS + n + st_ivas->nSCE ) * MAX_NUM_INDICES; if ( cpe_id * CPE_CHANNELS + n > 0 || ( st_ivas->mc_mode == MC_MODE_MCMASA && st_ivas->nSCE > 0 ) ) -#else - st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->ind_list = ind_list + ( cpe_id * CPE_CHANNELS + n ) * MAX_NUM_INDICES; - if ( cpe_id * CPE_CHANNELS + n > 0 ) -#endif { reset_indices_enc( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr, MAX_NUM_INDICES ); } @@ -402,7 +346,6 @@ ivas_error ivas_corecoder_enc_reconfig( } } -#ifdef MC_BITRATE_SWITCHING if ( last_mc_mode == MC_MODE_MCMASA && st_ivas->mc_mode == MC_MODE_MCMASA ) { /* restore modified transport signal */ @@ -418,7 +361,6 @@ ivas_error ivas_corecoder_enc_reconfig( } } } -#endif if ( st_ivas->nCPE > 1 && nCPE_old <= 1 ) { @@ -471,11 +413,7 @@ ivas_error ivas_corecoder_enc_reconfig( } } -#ifdef MC_BITRATE_SWITCHING st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData->ind_list = ind_list_metadata + st_ivas->nSCE * MAX_NUM_INDICES; -#else - st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData->ind_list = ind_list_metadata; -#endif reset_indices_enc( st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData, MAX_BITS_METADATA ); for ( cpe_id = 0; cpe_id < st_ivas->nCPE - 1; cpe_id++ ) diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 1ab8a5084c..2440cc4fa6 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -792,14 +792,10 @@ ivas_error create_cpe_enc( * Metadata: allocate and initialize *-----------------------------------------------------------------*/ -#ifdef MC_BITRATE_SWITCHING /* we need the meta data handle also if we init as MC_FORMAT/MCT since it might be needed at a bit rate switch to ParamMC or McMASA and the metadata index list is only really reachable in the ivas_init_encoder() function and has to be connected to the MD handle there */ if ( cpe_id == ( st_ivas->nCPE - 1 ) ) -#else - if ( !( ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCT ) && ( cpe_id == ( st_ivas->nCPE - 1 ) ) ) -#endif { if ( ( hCPE->hMetaData = (BSTR_ENC_HANDLE) malloc( sizeof( BSTR_ENC_DATA ) ) ) == NULL ) { diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 6f2d8e377c..764419ad7c 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -528,12 +528,6 @@ ivas_error ivas_init_encoder( st_ivas->mc_mode = ivas_mc_mode_select( hEncoderConfig->mc_input_setup, ivas_total_brate ); hEncoderConfig->nchan_inp = ivas_mc_ls_setup_get_num_channels( hEncoderConfig->mc_input_setup ); -#ifndef MC_BITRATE_SWITCHING - if ( ( error = ivas_create_lfe_enc( &st_ivas->hLFE, input_Fs ) ) != IVAS_ERR_OK ) - { - return error; - } -#endif if ( st_ivas->mc_mode == MC_MODE_MCT ) { @@ -551,13 +545,6 @@ ivas_error ivas_init_encoder( { /* we need the correct bitstream also for the LFE channel since it might become a proper coded channel when switching to ParamMC and ind_list is only visible here, can't be done later */ -#ifndef MC_BITRATE_SWITCHING - if ( cpe_id * CPE_CHANNELS + n == LFE_CHANNEL ) - { - st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->nb_bits_tot = 0; - continue; - } -#endif st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->ind_list = ind_list[cpe_id * CPE_CHANNELS + n]; reset_indices_enc( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr, MAX_NUM_INDICES ); } @@ -574,12 +561,10 @@ ivas_error ivas_init_encoder( return error; } -#ifdef MC_BITRATE_SWITCHING if ( ( error = ivas_create_lfe_enc( &st_ivas->hLFE, input_Fs ) ) != IVAS_ERR_OK ) { return error; } -#endif st_ivas->nchan_transport = ivas_mc_ls_setup_get_num_channels( st_ivas->hEncoderConfig->mc_input_setup ); } @@ -623,9 +608,7 @@ ivas_error ivas_init_encoder( } else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { -#ifdef MC_BITRATE_SWITCHING int32_t brate_sce, brate_cpe; -#endif ivas_mcmasa_setNumTransportChannels( &( st_ivas->nchan_transport ), &( hEncoderConfig->element_mode_init ), ivas_total_brate ); @@ -644,33 +627,14 @@ ivas_error ivas_init_encoder( return error; } -#ifdef MC_BITRATE_SWITCHING ivas_mcmasa_split_brate( st_ivas->hMcMasa->separateChannelEnabled, ivas_total_brate, st_ivas->nSCE, st_ivas->nCPE, &brate_sce, &brate_cpe ); -#endif for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) { -#ifdef MC_BITRATE_SWITCHING if ( ( error = create_sce_enc( st_ivas, sce_id, brate_sce ) ) != IVAS_ERR_OK ) { return error; } -#else - if ( st_ivas->hMcMasa->separateChannelEnabled ) - { - if ( ( error = create_sce_enc( st_ivas, sce_id, ivas_mcmasa_mono_brate( ivas_total_brate ) ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else - { - if ( ( error = create_sce_enc( st_ivas, sce_id, ivas_total_brate / ( st_ivas->nCPE + st_ivas->nSCE ) ) ) != IVAS_ERR_OK ) - { - return error; - } - } -#endif /* prepare bitstream buffers */ st_ivas->hSCE[sce_id]->hCoreCoder[0]->hBstr->ind_list = ind_list[sce_id]; @@ -682,31 +646,12 @@ ivas_error ivas_init_encoder( for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { -#ifdef MC_BITRATE_SWITCHING hEncoderConfig->element_mode_init = IVAS_CPE_MDCT; if ( ( error = create_cpe_enc( st_ivas, cpe_id, brate_cpe ) ) != IVAS_ERR_OK ) { return error; } -#else - if ( st_ivas->hMcMasa->separateChannelEnabled ) - { - hEncoderConfig->element_mode_init = IVAS_CPE_MDCT; - - if ( ( error = create_cpe_enc( st_ivas, cpe_id, ivas_total_brate - st_ivas->hSCE[0]->element_brate ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else - { - if ( ( error = create_cpe_enc( st_ivas, cpe_id, ivas_total_brate / ( st_ivas->nCPE + st_ivas->nSCE ) ) ) != IVAS_ERR_OK ) - { - return error; - } - } -#endif /* prepare bitstream buffers */ for ( n = 0; n < CPE_CHANNELS; n++ ) diff --git a/lib_enc/ivas_ism_param_enc.c b/lib_enc/ivas_ism_param_enc.c index b74358af2f..66ad379c4a 100644 --- a/lib_enc/ivas_ism_param_enc.c +++ b/lib_enc/ivas_ism_param_enc.c @@ -415,9 +415,7 @@ ivas_error ivas_ism_enc_config( ivas_error error; ISM_MODE last_ism_mode; int16_t nchan_transport_old; -#ifdef MC_BITRATE_SWITCHING int16_t nSCE_old, nCPE_old; -#endif error = IVAS_ERR_OK; last_ism_mode = st_ivas->ism_mode; @@ -442,19 +440,13 @@ ivas_error ivas_ism_enc_config( st_ivas->nchan_transport = st_ivas->hEncoderConfig->nchan_inp; } -#ifdef MC_BITRATE_SWITCHING nCPE_old = st_ivas->nCPE; nSCE_old = st_ivas->nSCE; -#endif st_ivas->nSCE = st_ivas->nchan_transport; st_ivas->nCPE = 0; ivas_ism_config( st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hEncoderConfig->nchan_inp, NULL, NULL, NULL, element_brate_tmp, NULL, NULL ); -#ifdef MC_BITRATE_SWITCHING ivas_corecoder_enc_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, st_ivas->hEncoderConfig->ivas_total_brate / st_ivas->nchan_transport, ( st_ivas->hEncoderConfig->ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS, MC_MODE_NONE ); -#else - ivas_corecoder_enc_reconfig( st_ivas, nchan_transport_old, 0, nchan_transport_old ); -#endif if ( st_ivas->ism_mode == ISM_MODE_PARAM && last_ism_mode == ISM_MODE_DISC ) { diff --git a/lib_enc/ivas_mc_param_enc.c b/lib_enc/ivas_mc_param_enc.c index 2a3ee7f749..a819e30300 100644 --- a/lib_enc/ivas_mc_param_enc.c +++ b/lib_enc/ivas_mc_param_enc.c @@ -220,7 +220,6 @@ ivas_error ivas_param_mc_enc_open( } -#ifdef MC_BITRATE_SWITCHING /*------------------------------------------------------------------------- * ivas_param_mc_enc_reconfig() * @@ -354,7 +353,6 @@ ivas_error ivas_param_mc_enc_reconfig( return error; } -#endif /*------------------------------------------------------------------------- diff --git a/lib_enc/ivas_mcmasa_enc.c b/lib_enc/ivas_mcmasa_enc.c index 5b66d03abb..8af6c351c6 100644 --- a/lib_enc/ivas_mcmasa_enc.c +++ b/lib_enc/ivas_mcmasa_enc.c @@ -396,7 +396,6 @@ ivas_error ivas_mcmasa_enc_open( } -#ifdef MC_BITRATE_SWITCHING /*------------------------------------------------------------------------- * ivas_mcmasa_enc_reconfig() * @@ -440,7 +439,6 @@ ivas_error ivas_mcmasa_enc_reconfig( return error; } -#endif /*--------------------------------------------------------------------------* * ivas_mcmasa_enc_close() @@ -1203,7 +1201,6 @@ void ivas_mcmasa_param_est_enc( * *--------------------------------------------------------------------------*/ -#ifdef MC_BITRATE_SWITCHING void ivas_mcmasa_dmx_modify( const int16_t n_samples, /* i : input frame length in samples */ float dmx[][L_FRAME48k + NS2SA( 48000, IVAS_FB_ENC_DELAY_NS )], /* i/o: downmix signal to be transformed into another format. TODO: buffer size into define? */ @@ -1276,7 +1273,6 @@ void ivas_mcmasa_dmx_modify( return; } -#endif /*--------------------------------------------------------------------------* diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c index dd1d1fe02a..08d9057403 100755 --- a/lib_enc/ivas_mct_enc.c +++ b/lib_enc/ivas_mct_enc.c @@ -44,13 +44,11 @@ #include "wmc_auto.h" -#ifdef MC_BITRATE_SWITCHING /*-----------------------------------------------------------------------* * Local function prototypes *-----------------------------------------------------------------------*/ static ivas_error ivas_mc_enc_reconfig( Encoder_Struct *st_ivas, const int16_t last_mc_mode ); -#endif /*-------------------------------------------------------------------* @@ -176,11 +174,7 @@ ivas_error ivas_mct_enc( /* joint MCT encoding */ ivas_mct_core_enc( ivas_format, hMCT, st_ivas->hCPE, hMCT->nchan_out_woLFE + hMCT->num_lfe, ivas_total_brate, switch_bw, -#ifdef MC_BITRATE_SWITCHING ( ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCT ) ? (int16_t) st_ivas->hLFE->lfe_bits : 0 -#else - ivas_format == MC_FORMAT ? (int16_t) st_ivas->hLFE->lfe_bits : 0 -#endif , st_ivas->hEncoderConfig->sba_order ); @@ -196,10 +190,8 @@ ivas_error ivas_mct_enc( { mvr2r( hCPE->hCoreCoder[n]->input, hCPE->hCoreCoder[n]->old_input_signal, input_frame ); -#ifdef MC_BITRATE_SWITCHING /* common encoder updates */ updt_enc_common( hCPE->hCoreCoder[n] ); -#endif } } @@ -373,13 +365,11 @@ ivas_error mct_enc_reconfigure( hMCT->nchan_out_woLFE = st_ivas->hEncoderConfig->nchan_inp - 1; /* LFE channel is coded separately */ hMCT->num_lfe = TRUE; } -#ifdef MC_BITRATE_SWITCHING else if ( ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_PARAMMC ) { hMCT->nchan_out_woLFE = ivas_param_mc_getNumTransportChannels( ivas_total_brate, st_ivas->hEncoderConfig->mc_input_setup ); hMCT->num_lfe = FALSE; } -#endif else if ( ivas_format == SBA_FORMAT ) { hMCT->nchan_out_woLFE = st_ivas->nchan_transport; @@ -396,9 +386,7 @@ ivas_error mct_enc_reconfigure( /* indicate LFE for appropriate core-coder channel */ for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { -#ifdef MC_BITRATE_SWITCHING st_ivas->hCPE[cpe_id]->element_brate = cp_bitrate; -#endif for ( n = 0; n < CPE_CHANNELS; n++ ) { st_ivas->hCPE[cpe_id]->hCoreCoder[n]->mct_chan_mode = MCT_CHAN_MODE_REGULAR; @@ -571,18 +559,13 @@ ivas_error ivas_mc_enc_config( /* MC format switching */ if ( st_ivas->hEncoderConfig->last_ivas_total_brate != st_ivas->hEncoderConfig->ivas_total_brate || st_ivas->mc_mode != last_mc_mode ) { -#ifdef MC_BITRATE_SWITCHING ivas_mc_enc_reconfig( st_ivas, last_mc_mode ); -#else - return IVAS_ERROR( IVAS_ERR_RECONFIGURE_NOT_SUPPORTED, "Error: MC format switching not supported yet!!!\n\n" ); -#endif } return error; } -#ifdef MC_BITRATE_SWITCHING /*------------------------------------------------------------------------- * ivas_mc_enc_reconfig() * @@ -834,4 +817,3 @@ static ivas_error ivas_mc_enc_reconfig( return error; } -#endif diff --git a/lib_enc/ivas_mdct_core_enc.c b/lib_enc/ivas_mdct_core_enc.c index 6dba0fb321..3bdbc31e2d 100755 --- a/lib_enc/ivas_mdct_core_enc.c +++ b/lib_enc/ivas_mdct_core_enc.c @@ -894,11 +894,7 @@ void ivas_mdct_core_whitening_enc( } /* set low br mode, if possible. Can later be discarded, depending on the stereo mode used for SNS parameter decoding */ -#ifdef MC_BITRATE_SWITCHING if ( hCPE->element_brate == IVAS_48k && !( ( sts[0]->core == TCX_20 && sts[1]->core == TCX_20 ) || sts[1]->mct_chan_mode == MCT_CHAN_MODE_LFE ) ) -#else - if ( hCPE->element_brate == IVAS_48k && !( sts[0]->core == TCX_20 && sts[1]->core == TCX_20 ) ) -#endif { sns_low_br_mode = !sts[0]->sp_aud_decision0; } @@ -1114,11 +1110,7 @@ void ivas_mdct_core_whitening_enc( { push_next_indice( hBstr, param_lpc[0][0] >> 1, 1 ); -#ifdef MC_BITRATE_SWITCHING if ( st->element_brate == IVAS_48k && !( ( sts[0]->core == TCX_20 && sts[1]->core == TCX_20 ) || sts[1]->mct_chan_mode == MCT_CHAN_MODE_LFE ) ) -#else - if ( st->element_brate == IVAS_48k && !( sts[0]->core == TCX_20 && sts[1]->core == TCX_20 ) ) -#endif { /* write classifier decision to signal low br mode for SNS encoding, for all other configs, low_br mode is not possible */ push_next_indice( hBstr, sns_low_br_mode, 1 ); diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index 71ad626a4a..1556d2ee7e 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -514,11 +514,7 @@ ivas_error ivas_sba_enc_reconfigure( * Allocate, initalize, and configure SCE/CPE/MCT handles *-----------------------------------------------------------------*/ -#ifdef MC_BITRATE_SWITCHING ivas_corecoder_enc_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, ivas_total_brate / st_ivas->nchan_transport, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS, MC_MODE_NONE ); -#else - ivas_corecoder_enc_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old ); -#endif #ifdef SBA_BR_SWITCHING_RECONFIG if ( st_ivas->hEncoderConfig->Opt_DTX_ON ) diff --git a/lib_enc/updt_enc.c b/lib_enc/updt_enc.c index 4fe89cd967..057d9144bc 100644 --- a/lib_enc/updt_enc.c +++ b/lib_enc/updt_enc.c @@ -291,10 +291,6 @@ void updt_IO_switch_enc( void updt_enc_common( Encoder_State *st /* i/o: encoder state structure */ -#ifndef MC_BITRATE_SWITCHING - , - const float Etot /* i : total energy */ -#endif ) { /*---------------------------------------------------------------------* @@ -312,9 +308,6 @@ void updt_enc_common( st->last_extl = st->extl; st->last_input_bwidth = st->input_bwidth; st->last_bwidth = st->bwidth; -#ifndef MC_BITRATE_SWITCHING - st->hNoiseEst->Etot_last = Etot; -#endif st->last_coder_type_raw = st->coder_type_raw; if ( st->core_brate > SID_2k40 && st->hDtxEnc != NULL ) -- GitLab From 6484731139dea8ef7e9bf3370fa814011d55016e Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Fri, 13 Jan 2023 13:15:34 +0100 Subject: [PATCH 3/7] [cleanup] accept MC_JBM --- apps/decoder.c | 276 ----------- lib_com/bitstream.c | 120 ----- lib_com/common_api_types.h | 11 - lib_com/ivas_error.h | 2 - lib_com/options.h | 1 - lib_com/prot.h | 15 - lib_debug/coan_out_000002 | 924 +++++++++++++++++++++++++++++++++++++ lib_dec/jbm_jb4sb.h | 5 - lib_dec/jbm_pcmdsp_apa.c | 49 -- lib_dec/jbm_pcmdsp_apa.h | 10 - lib_dec/jbm_pcmdsp_fifo.c | 16 - lib_dec/jbm_pcmdsp_fifo.h | 8 - lib_dec/lib_dec.c | 200 -------- lib_dec/lib_dec.h | 16 - lib_util/evs_rtp_payload.c | 32 -- lib_util/evs_rtp_payload.h | 3 - lib_util/jbm_file_writer.c | 24 - 17 files changed, 924 insertions(+), 788 deletions(-) create mode 100644 lib_debug/coan_out_000002 diff --git a/apps/decoder.c b/apps/decoder.c index 3a89b15f54..88f7322691 100755 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -122,9 +122,7 @@ static void usage_dec( void ); static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, HeadRotFileReader *headRotReader, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HANDLE hIvasDec ); #ifdef DEBUGGING -#ifdef MC_JBM static ivas_error printBitstreamInfoVoip( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HANDLE hIvasDec ); -#endif static int16_t app_own_random( int16_t *seed ); static IVAS_DEC_FORCED_REND_MODE parseForcedRendModeDec( char *forcedRendModeChar ); #endif @@ -287,15 +285,11 @@ int main( if ( arg.voipMode ) { -#ifdef MC_JBM if ( ( error = printBitstreamInfoVoip( arg, hBsReader, hIvasDec ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Error while previewing VoIP bitstream: %s\n", ivas_error_to_string( error ) ); goto cleanup; } -#else - IVAS_DEC_PrintConfig( hIvasDec, arg.quietModeEnabled, arg.voipMode ); -#endif } else { @@ -454,13 +448,6 @@ int main( if ( arg.voipMode ) { -#ifndef MC_JBM - if ( arg.decMode != IVAS_DEC_MODE_EVS ) - { - fprintf( stderr, "\nError: VoIP not yet supported for decMode: %d\n\n", arg.decMode ); - goto cleanup; - } -#endif if ( ( error = IVAS_DEC_EnableVoIP( hIvasDec, 60, arg.inputFormat ) ) != IVAS_ERR_OK ) { @@ -1087,7 +1074,6 @@ static int16_t app_own_random( int16_t *seed ) } #endif -#ifdef MC_JBM static ivas_error initOnFirstGoodFrame( IVAS_DEC_HANDLE hIvasDec, /* i/o: */ const DecArguments arg, /* i : */ @@ -1242,7 +1228,6 @@ static ivas_error initOnFirstGoodFrame( return IVAS_ERR_OK; } -#endif /*---------------------------------------------------------------------* * decodeG192() @@ -1260,11 +1245,7 @@ static ivas_error decodeG192( { bool decodingFailed = true; /* Assume failure until cleanup is reached without errors */ uint16_t bit_stream[IVAS_MAX_BITS_PER_FRAME + 4 * 8]; -#ifdef MC_JBM int16_t i, num_bits; -#else - int16_t i, j, num_bits; -#endif int16_t bfi = 0; #ifdef DEBUGGING int16_t fec_seed = 12558; /* FEC_SEED */ @@ -1276,9 +1257,6 @@ static ivas_error decodeG192( int16_t nOutChannels = 0; int16_t delayNumSamples = -1; int16_t delayNumSamples_orig = 0; -#ifndef MC_JBM - int16_t zeroPad = 0; -#endif int16_t nOutSamples = 0; int32_t delayTimeScale = 0; ivas_error error = IVAS_ERR_UNKNOWN; @@ -1386,7 +1364,6 @@ static ivas_error decodeG192( /* Once good frame decoded, catch up */ if ( decodedGoodFrame ) { -#ifdef MC_JBM error = initOnFirstGoodFrame( hIvasDec, arg, @@ -1405,128 +1382,6 @@ static ivas_error decodeG192( { goto cleanup; } -#else - - /* Now number of output channels and frame size are known */ - if ( ( error = IVAS_DEC_GetNumOutputChannels( hIvasDec, &nOutChannels ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError in IVAS_DEC_GetNumOutputChannels, code: %d\n", error ); - goto cleanup; - } - - int32_t pcmFrameSize; - - if ( ( error = IVAS_DEC_GetPcmFrameSize( hIvasDec, &pcmFrameSize ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError in IVAS_DEC_GetPcmFrameSize, error code: %d\n", error ); - goto cleanup; - } - - /* Open audio writer and write all previously skipped bad frames now that frame size is known */ - if ( ( error = AudioFileWriter_open( &afWriter, arg.outputWavFilename, arg.output_Fs, nOutChannels ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nUnable to open output file %s\n", arg.outputWavFilename ); - goto cleanup; - } - - int16_t *zeroBuf = malloc( pcmFrameSize * sizeof( int16_t ) ); - memset( zeroBuf, 0, pcmFrameSize * sizeof( int16_t ) ); - - for ( i = 0; i < numInitialBadFrames; ++i ) - { - if ( delayNumSamples < nOutSamples ) - { - if ( ( error = AudioFileWriter_write( afWriter, zeroBuf, nOutSamples * nOutChannels - ( delayNumSamples * nOutChannels ) ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nOutput audio file writer error\n" ); - goto cleanup; - } - delayNumSamples = 0; - } - else - { - delayNumSamples -= nOutSamples; - } - } - - free( zeroBuf ); - - /* Open other output files if EXT output config - now details about ISM or MASA are known */ - if ( arg.outputFormat == IVAS_DEC_OUTPUT_EXT ) - { - if ( ( error = IVAS_DEC_GetFormat( hIvasDec, &bsFormat ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError in IVAS_DEC_GetFormat, code: %d\n", error ); - goto cleanup; - } - - /* If outputting ISM, get number of objects, open output files and write zero metadata for initial bad frames */ - if ( bsFormat == IVAS_DEC_BS_OBJ ) - { - if ( ( error = IVAS_DEC_GetNumObjects( hIvasDec, &numObj ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError in IVAS_DEC_GetNumObjects: %s\n", IVAS_DEC_GetErrorMessage( error ) ); - goto cleanup; - } - - for ( i = 0; i < numObj; ++i ) - { - if ( ( error = IsmFileWriter_open( arg.outputWavFilename, i, &ismWriters[i] ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError: Error opening ISM decoded metadata file %s\n", IsmFileWriter_getFilePath( ismWriters[i] ) ); - goto cleanup; - } - } - - for ( j = 0; j < numInitialBadFrames; ++j ) - { - /* write zero metadata */ - for ( i = 0; i < numObj; ++i ) - { - IVAS_ISM_METADATA IsmMetadata; - - if ( ( error = IVAS_DEC_GetObjectMetadata( hIvasDec, &IsmMetadata, 1, i ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError in IVAS_DEC_GetObjectMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) ); - goto cleanup; - } - - if ( ( IsmFileWriter_writeFrame( IsmMetadata, ismWriters[i] ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError writing ISM metadata to file %s\n", IsmFileWriter_getFilePath( ismWriters[i] ) ); - goto cleanup; - } - } - } - } - /* If outputting MASA, open output file and write metadata for initial bad frames */ - else if ( bsFormat == IVAS_DEC_BS_MASA ) - { - if ( ( error = MasaFileWriter_open( arg.outputWavFilename, &masaWriter ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError: Error opening MASA decoded metadata file %s\n", MasaFileWriter_getFilePath( masaWriter ) ); - goto cleanup; - } - - /* Duplicate good first frame metadata to fill the beginning of stream. */ - IVAS_MASA_QMETADATA_HANDLE qMetadata = NULL; - if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &qMetadata ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) ); - goto cleanup; - } - - for ( j = 0; j < numInitialBadFrames; ++j ) - { - if ( ( MasaFileWriter_writeFrame( masaWriter, qMetadata ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError writing MASA metadata to file: %s\n", MasaFileWriter_getFilePath( masaWriter ) ); - goto cleanup; - } - } - } - } -#endif } else { @@ -1534,25 +1389,6 @@ static ivas_error decodeG192( } } -#ifndef MC_JBM - if ( delayNumSamples == -1 ) - { - if ( arg.delayCompensationEnabled ) - { - if ( ( error = IVAS_DEC_GetDelay( hIvasDec, &delayNumSamples, &delayTimeScale ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nUnable to get delay of decoder: %s\n", IVAS_DEC_GetErrorMessage( error ) ); - goto cleanup; - } - delayNumSamples_orig = delayNumSamples; - } - else - { - delayNumSamples = 0; - } - zeroPad = delayNumSamples; - } -#endif /* Write current frame */ if ( decodedGoodFrame ) @@ -1663,21 +1499,12 @@ static ivas_error decodeG192( } /* add zeros at the end to have equal length of synthesized signals */ -#ifdef MC_JBM memset( pcmBuf, 0, delayNumSamples_orig * nOutChannels * sizeof( int16_t ) ); if ( ( error = AudioFileWriter_write( afWriter, pcmBuf, delayNumSamples_orig * nOutChannels ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError writing output file: %s\n", ivas_error_to_string( error ) ); goto cleanup; } -#else - memset( pcmBuf, 0, zeroPad * nOutChannels * sizeof( int16_t ) ); - if ( ( error = AudioFileWriter_write( afWriter, pcmBuf, zeroPad * nOutChannels ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nOutput audio file writer error\n" ); - goto cleanup; - } -#endif /*------------------------------------------------------------------------------------------* * Close files and deallocate resources @@ -1702,7 +1529,6 @@ cleanup: return error; } -#ifdef MC_JBM #ifdef DEBUGGING /*---------------------------------------------------------------------* * printBitstreamInfoVoip() @@ -1804,16 +1630,13 @@ cleanup: return IVAS_ERR_OK; } #endif -#endif -#ifdef MC_JBM #ifdef SUPPORT_JBM_TRACEFILE static ivas_error writeJbmTraceFileFrameWrapper( const void *data, void *writer ) { return JbmTraceFileWriter_writeFrame( data, writer ); } #endif -#endif /*---------------------------------------------------------------------* @@ -1839,7 +1662,6 @@ static ivas_error decodeVoIP( uint16_t rtpSequenceNumber; uint32_t rtpTimeStamp; -#ifdef MC_JBM bool decodedGoodFrame = false; int16_t numInitialBadFrames = 0; /* Number of bad frames received until first good frame is decoded */ int16_t nOutChannels = 0; @@ -1847,15 +1669,6 @@ static ivas_error decodeVoIP( uint16_t numObj = 0; int16_t pcmBuf[MAX_OUTPUT_PCM_BUFFER_SIZE]; -#else - /* For now always assume output with one channel. When adding VoIP to IVAS, - * initialization of the memory for jitter buffer etc. needs to happen after - * first good frame has been decoded because for some configs (such as EXT - * renderer) only then the number of output channels is known.*/ - const int16_t nOutChannels = 1; - const uint32_t pcmBufSizeWithSampleBasedTimeScaling = 3 * MAX_FRAME_SIZE; - int16_t pcmBuf[3 * MAX_FRAME_SIZE]; -#endif AudioFileWriter *afWriter = NULL; #ifdef SUPPORT_JBM_TRACEFILE JbmTraceFileWriter *jbmTraceWriter = NULL; @@ -1865,9 +1678,6 @@ static ivas_error decodeVoIP( int16_t delayNumSamples_orig = -1; int16_t delayNumSamples = -1; int32_t delayTimeScale = -1; -#ifndef MC_JBM - int16_t zeroPad = 0; -#endif FILE *f_rtpstream = NULL; EVS_RTPDUMP_DEPACKER rtpdumpDepacker; @@ -1877,16 +1687,12 @@ static ivas_error decodeVoIP( uint16_t frameTypeIndex; bool qBit; -#ifdef MC_JBM IVAS_DEC_BS_FORMAT bsFormat = IVAS_DEC_BS_UNKOWN; IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS]; for ( int16_t i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i ) { ismWriters[i] = NULL; } -#else - memset( pcmBuf, 0, pcmBufSizeWithSampleBasedTimeScaling ); -#endif rtpdumpDepacker.rtpdump = NULL; @@ -1917,13 +1723,6 @@ static ivas_error decodeVoIP( goto cleanup; } -#ifndef MC_JBM - if ( ( error = AudioFileWriter_open( &afWriter, arg.outputWavFilename, arg.output_Fs, nOutChannels ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nUnable to open output file %s\n", arg.outputWavFilename ); - goto cleanup; - } -#endif #ifdef SUPPORT_JBM_TRACEFILE if ( arg.jbmTraceFilename != NULL ) @@ -1951,12 +1750,6 @@ static ivas_error decodeVoIP( if ( arg.inputFormat == IVAS_DEC_INPUT_FORMAT_G192 ) { error = BS_Reader_ReadVoipFrame_compact( hBsReader, au, &auSize, &rtpSequenceNumber, &rtpTimeStamp, &nextPacketRcvTime_ms ); -#ifndef MC_JBM - if ( !evsPayload_getFrameTypeFromSize( auSize, &isAMRWB_IOmode, &frameTypeIndex ) ) - { - error = IVAS_ERR_BITSTREAM_READER_INVALID_DATA; - } -#endif qBit = 1; /* good q_bit for INPUT_FORMAT_G192 */ } else @@ -2002,11 +1795,7 @@ static ivas_error decodeVoIP( while ( nextPacketRcvTime_ms <= systemTime_ms ) { /* feed the previous read packet into the receiver now */ -#ifdef MC_JBM error = IVAS_DEC_VoIP_FeedFrame( hIvasDec, auPtr, auSize, rtpSequenceNumber, rtpTimeStamp, nextPacketRcvTime_ms, qBit ); -#else - error = IVAS_DEC_VoIP_FeedFrame( hIvasDec, auPtr, auSize, rtpSequenceNumber, rtpTimeStamp, nextPacketRcvTime_ms, isAMRWB_IOmode, frameTypeIndex, qBit ); -#endif if ( error != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_VoIP_FeedFrame: %s\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -2019,12 +1808,6 @@ static ivas_error decodeVoIP( { error = BS_Reader_ReadVoipFrame_compact( hBsReader, au, &auSize, &rtpSequenceNumber, &rtpTimeStamp, &nextPacketRcvTime_ms ); -#ifndef MC_JBM - if ( !evsPayload_getFrameTypeFromSize( auSize, &isAMRWB_IOmode, &frameTypeIndex ) ) - { - error = IVAS_ERR_BITSTREAM_READER_INVALID_DATA; - } -#endif qBit = 1; /* good q_bit for VOIP_G192_RTP */ } else @@ -2056,7 +1839,6 @@ static ivas_error decodeVoIP( break; } -#ifdef MC_JBM nOutSamples = (int16_t) ( arg.output_Fs / 50 ); /* decode and get samples */ @@ -2067,36 +1849,11 @@ static ivas_error decodeVoIP( jbmTraceWriter #endif ) ) != IVAS_ERR_OK ) -#else - /* decode and get samples */ - if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, &nOutSamples, pcmBuf, pcmBufSizeWithSampleBasedTimeScaling, systemTime_ms ) ) != IVAS_ERR_OK ) -#endif { fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } -#ifndef MC_JBM -#ifdef SUPPORT_JBM_TRACEFILE - /* write JBM trace file entry - only done for EVS testing */ - if ( jbmTraceWriter != NULL ) - { - IVAS_JBM_TRACE_DATA JbmTraceData; - - if ( ( error = IVAS_DEC_GetJbmData( hIvasDec, &JbmTraceData ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError in IVAS_DEC_GetJbmData: %s\n", IVAS_DEC_GetErrorMessage( error ) ); - goto cleanup; - } - - if ( ( JbmTraceFileWriter_writeFrame( &JbmTraceData, jbmTraceWriter ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError writing JBM Trace data to file %s\n", arg.jbmTraceFilename ); - goto cleanup; - } - } -#endif -#endif /* write JBM Offset file entry */ if ( jbmOffsetWriter != NULL ) @@ -2116,7 +1873,6 @@ static ivas_error decodeVoIP( } } -#ifdef MC_JBM /* Continue checking for first good frame until it is found */ if ( !decodedGoodFrame ) { @@ -2153,33 +1909,11 @@ static ivas_error decodeVoIP( ++numInitialBadFrames; } } -#endif -#ifndef MC_JBM - if ( delayNumSamples == -1 ) - { - if ( arg.delayCompensationEnabled ) - { - if ( ( error = IVAS_DEC_GetDelay( hIvasDec, &delayNumSamples, &delayTimeScale ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nUnable to get delay of decoder: %s\n", IVAS_DEC_GetErrorMessage( error ) ); - goto cleanup; - } - delayNumSamples_orig = delayNumSamples; - } - else - { - delayNumSamples = 0; - } - zeroPad = delayNumSamples; - } -#endif /* Write current frame */ -#ifdef MC_JBM if ( decodedGoodFrame ) { -#endif if ( delayNumSamples < nOutSamples ) { if ( ( error = AudioFileWriter_write( afWriter, &pcmBuf[delayNumSamples * nOutChannels], nOutSamples * nOutChannels - ( delayNumSamples * nOutChannels ) ) ) != IVAS_ERR_OK ) @@ -2193,9 +1927,7 @@ static ivas_error decodeVoIP( { delayNumSamples -= nOutSamples; } -#ifdef MC_JBM } -#endif if ( !arg.quietModeEnabled ) { @@ -2213,7 +1945,6 @@ static ivas_error decodeVoIP( #endif } -#ifdef MC_JBM /* add zeros at the end to have equal length of synthesized signals */ memset( pcmBuf, 0, delayNumSamples_orig * nOutChannels * sizeof( int16_t ) ); if ( ( error = AudioFileWriter_write( afWriter, pcmBuf, delayNumSamples_orig * nOutChannels ) ) != IVAS_ERR_OK ) @@ -2221,11 +1952,6 @@ static ivas_error decodeVoIP( fprintf( stderr, "\nError writing output file: %s\n", ivas_error_to_string( error ) ); goto cleanup; } -#else - /* add zeros at the end to have equal length of synthesized signals */ - memset( pcmBuf, 0, zeroPad * nOutChannels * sizeof( int16_t ) ); - AudioFileWriter_write( afWriter, pcmBuf, zeroPad * nOutChannels ); -#endif /*------------------------------------------------------------------------------------------* * Printouts after decoding has finished @@ -2244,9 +1970,7 @@ static ivas_error decodeVoIP( cleanup: -#ifdef MC_JBM EVS_RTPDUMP_DEPACKER_close( &rtpdumpDepacker ); -#endif AudioFileWriter_close( &afWriter ); JbmOffsetFileWriter_close( &jbmOffsetWriter ); #ifdef SUPPORT_JBM_TRACEFILE diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c index fc89af3fbd..7fa4791dfa 100644 --- a/lib_com/bitstream.c +++ b/lib_com/bitstream.c @@ -2012,11 +2012,7 @@ ivas_error read_indices( file_read_FECpattern( &st_ivas->bfi ); st_ivas->bfi |= bfi; -#ifdef MC_JBM if ( bfi == FRAMEMODE_MISSING ) /* TODO(mcjbm): This fixes channel-aware mode BE. Still requires review from a bitstream reading expert */ -#else - if ( bfi ) -#endif { for ( k = 0; k < num_bits; k++ ) { @@ -2182,9 +2178,7 @@ ivas_error read_indices( /* handle bad/lost speech frame(and CS bad SID frame) in the decoders CNG synthesis settings pair (total_brate, bfi) */ if ( ( -#ifdef MC_JBM bfi != FRAMEMODE_FUTURE && /* TODO(mcjbm): This fixes channel-aware mode BE. Still requires review from a bitstream reading expert */ -#endif ( *CNG != 0 ) && ( ( speech_bad != 0 ) || ( speech_lost != 0 ) ) ) || /* SP_BAD or SPEECH_LOST) --> stay in CNG */ ( sid_upd_bad != 0 ) ) /* SID_UPD_BAD --> start CNG */ { @@ -2229,9 +2223,7 @@ ivas_error read_indices( /* GOOD frame */ if ( st_ivas->bfi == 0 -#ifdef MC_JBM || st_ivas->bfi == FRAMEMODE_FUTURE /* TODO(mcjbm): This fixes channel-aware mode BE. Still requires review from a bitstream reading expert */ -#endif ) { /* GOOD frame - convert ITU-T G.192 words to short values */ @@ -2735,118 +2727,6 @@ void get_NextCoderType( return; } -#ifndef MC_JBM -/*-------------------------------------------------------------------* - * read_indices_from_djb() - * - * Read indices from the de-jitter buffer payload (works also for AMR-WB IO mode) - *-------------------------------------------------------------------*/ -void read_indices_from_djb( - Decoder_State *st, /* i/o: decoder state structure */ - uint8_t *pt_stream, /* i : bitstream file */ - int16_t *CNG, - const int16_t num_bits, /* i : input frame length in bits */ - const Word16 isAMRWB_IOmode, - const Word16 core_mode, - const Word16 qbit, - const Word16 bitstreamformat, - const Word16 amrwb_rfc4867_flag, - const int16_t partialframe, /* i : partial frame information */ - const int16_t next_coder_type /* i : next coder type information */ -) -{ - int16_t k; - UWord8 mask = 0x80; - Word16 no_data = 0; - Word16 sti = -1; - uint16_t *bit_stream_ptr; - int32_t total_brate; - int16_t speech_lost = 0; - - st->bfi = 0; - st->BER_detect = 0; - st->mdct_sw_enable = 0; - st->mdct_sw = 0; - reset_indices_dec( st ); - - st->bfi = !qbit; - total_brate = (Word32) (num_bits) *50; - - if ( num_bits == 0 ) /* guess type of missing frame for SP_LOST and NO_DATA */ - { - speech_lost = *CNG == 0; - no_data = *CNG != 0; - } - - if ( partialframe || st->prev_use_partial_copy ) - { - st->next_coder_type = next_coder_type; - } - else - { - st->next_coder_type = INACTIVE; - } - - if ( partialframe == 1 ) - { - st->bfi = 2; - } - - /* unpack speech data */ - bit_stream_ptr = st->bit_stream; - /* convert bitstream from compact bytes to short values and store it in decoder state */ - for ( k = 0; k < num_bits; k++ ) - { - if ( bitstreamformat == VOIP_RTPDUMP && isAMRWB_IOmode ) - { - st->bit_stream[sort_ptr[core_mode][k]] = unpack_bit( &pt_stream, &mask ); - bit_stream_ptr++; - } - else - { - *bit_stream_ptr++ = unpack_bit( &pt_stream, &mask ); - } - } - - /* unpack auxiliary bits */ - if ( isAMRWB_IOmode && total_brate == SID_1k75 ) - { - if ( bitstreamformat == VOIP_RTPDUMP ) - { - /* A.2.2.1.3: AMR-WB SID_1k75 frame is followed by STI bit and CMI bits */ - sti = unpack_bit( &pt_stream, &mask ); - } - else - { - /* VOIP_G192_RTP does not contain STI and CMI */ - sti = 1; - } - read_indices_mime_handle_sti_and_all_zero_bits( st, &total_brate, sti ); - } - - /* add two zero bytes for arithmetic coder flush */ - for ( k = 0; k < 8 * 2; ++k ) - { - *bit_stream_ptr++ = 0; - } - - total_brate = read_indices_mime_handle_dtx( st, CNG, isAMRWB_IOmode, core_mode, total_brate, sti, speech_lost, no_data, amrwb_rfc4867_flag ); - /* st->CNG set inside */ - - if ( st->bfi != 1 ) - { - /* select Mode 1 or Mode 2 */ - decoder_selectCodec( st, total_brate, *st->bit_stream ? 1 : 0 ); - - /* a change of the total bitrate should not be known to the decoder, if the received frame was truly lost */ - st->total_brate = total_brate; - - mdct_switching_dec( st ); - } - - return; -} -#endif /*-------------------------------------------------------------------* * get_indice_preview() diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index a0edd4313f..b6d4a21c5d 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -134,28 +134,17 @@ typedef struct ivas_LS_setup_custom IVAS_LSSETUP_CUSTOM_STRUCT; typedef struct _IVAS_JBM_TRACE_DATA { -#ifdef MC_JBM uint32_t systemTimestamp_ms; uint16_t extBufferedSamples; uint16_t lastDecodedWasActive; int32_t output_Fs; int16_t dataUnit_flag; -#else - double playTime; - int16_t partialCopyOffset; -#endif uint16_t sequenceNumber; uint32_t timeStamp; uint32_t rcvTime; -#ifdef MC_JBM int16_t partial_frame; int16_t partialCopyOffset; -#else - int16_t lastDecodedWasActive; - int16_t partial_frame_flag; - int16_t dataUnit_flag; -#endif } IVAS_JBM_TRACE_DATA; diff --git a/lib_com/ivas_error.h b/lib_com/ivas_error.h index 4539fd19d8..4e7fd3213d 100644 --- a/lib_com/ivas_error.h +++ b/lib_com/ivas_error.h @@ -81,9 +81,7 @@ typedef enum IVAS_ERR_INVALID_INDEX, IVAS_ERR_NOT_SUPPORTED_OPTION, IVAS_ERR_NOT_IMPLEMENTED, -#ifdef MC_JBM IVAS_ERR_WAITING_FOR_BITSTREAM, -#endif IVAS_ERR_FILE_READER_TIMESTAMP_MISMATCH, IVAS_ERR_ISM_FILE_READER_INVALID_METADATA_FORMAT, IVAS_ERR_ISM_INVALID_METADATA_VALUE, diff --git a/lib_com/options.h b/lib_com/options.h index 4f27ece852..6d57fde43c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -147,7 +147,6 @@ #endif #define FIX_I59_DELAY_ROUNDING /* Issue 59: rounding in sample domain instead of nanosec for IVAS_ENC_GetDelay() and IVAS_DEC_GetDelay() */ #define FIX_FIX_I59 /* Issue 59: small fix concerning LFE delay rounding */ -#define MC_JBM /* FhG: extend JBM beyond mono for running IVAS in VoIP mode (contribution 19) */ #define FIX_265_MC_BRATE_SWITCHING /* Issue 265: fix use-of-uninitialized-value in MC bitrate switching */ #define FIX_ANGLE_WRAPPING /* Issue 244: Problems with angle wrapping*/ #define FIX_245_RANGE_CODER_VOIP_MSAN /* Issue 245: fix use-of-uninitialized-value in range coder in VoIP mode */ diff --git a/lib_com/prot.h b/lib_com/prot.h index a0e03c9d21..116bc7aba1 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -643,21 +643,6 @@ void evs_dec_previewFrame( int16_t *partialCopyOffset /* o : offset of the partial copy relative to the primary copy */ ); -#ifndef MC_JBM -void read_indices_from_djb( - Decoder_State *st, /* i/o: decoder state structure */ - uint8_t *pt_stream, /* i : bitstream file */ - int16_t *CNG, - const int16_t num_bits, /* i : input frame length in bits */ - const Word16 isAMRWB_IOmode, /* i : AMRWB flag */ - const Word16 core_mode, /* i : core mode for frame */ - const Word16 qbit, /* i : Q bit for AMR-WB IO */ - const Word16 bitstreamformat, - const Word16 amrwb_rfc4867_flag, - const int16_t partialframe, /* i : partial frame information */ - const int16_t next_coder_type /* i : next coder type information */ -); -#endif void getPartialCopyInfo( Decoder_State *st, /* i : decoder state structure */ diff --git a/lib_debug/coan_out_000002 b/lib_debug/coan_out_000002 new file mode 100644 index 0000000000..bf31e63cef --- /dev/null +++ b/lib_debug/coan_out_000002 @@ -0,0 +1,924 @@ +/* + * (C) 2022 copyright VoiceAge Corporation. All Rights Reserved. + * + * This software is protected by copyright law and by international treaties. The source code, and all of its derivations, + * is provided by VoiceAge Corporation under the "ITU-T Software Tools' General Public License". Please, read the license file + * or refer to ITU-T Recommendation G.191 on "SOFTWARE TOOLS FOR SPEECH AND AUDIO CODING STANDARDS". + * + * Any use of this software is permitted provided that this notice is not removed and that neither the authors nor + * VoiceAge Corporation are deemed to have made any representations as to the suitability of this software + * for any purpose nor are held responsible for any defects of this software. THERE IS NO WARRANTY FOR THIS SOFTWARE. + * + * Authors: Guy Richard, Vladimir Malenovsky (Vladimir.Malenovsky@USherbrooke.ca) + */ + +#ifndef WMOPS_H +#define WMOPS_H + +#ifndef EXIT_FAILURE +#include /* stdlib is needed for exit() */ +#endif + +#ifndef EOF +#include /* stdio is needed for fprintf() */ +#endif + + +/* To Prevent "warning: '$' in identifier or number" message under GCC */ +#ifdef __GNUC__ +#pragma GCC system_header +#endif + +/* Real-time relationships */ +#define FRAMES_PER_SECOND 50.0 +#define MILLION_CYCLES 1e6 +#define WMOPS_BOOST_FAC ( 1.0f ) /* scaling factor for equalizing the difference between automatic and manual instrumentation */ +#define FAC ( FRAMES_PER_SECOND / MILLION_CYCLES * WMOPS_BOOST_FAC ) +#define NUM_INST 20 /* Total number of instruction types (in enum below) */ + + +#ifdef WMOPS +enum instructions +{ + _ADD, + _ABS, + _MULT, + _MAC, + _MOVE, + _STORE, + _LOGIC, + _SHIFT, + _BRANCH, + _DIV, + _SQRT, + _TRANS, + _FUNC, + _LOOP, + _INDIRECT, + _PTR_INIT, + _TEST, + _POWER, + _LOG, + _MISC +}; + +#define _ADD_C 1 +#define _ABS_C 1 +#define _MULT_C 1 +#define _MAC_C 1 +#define _MOVE_C 1 +#define _STORE_C 1 +#define _LOGIC_C 1 +#define _SHIFT_C 1 +#define _BRANCH_C 4 +#define _DIV_C 18 +#define _SQRT_C 10 +#define _TRANS_C 25 +#define _FUNC_C 2 /* need to add number of arguments */ +#define _LOOP_C 3 +#define _INDIRECT_C 2 +#define _PTR_INIT_C 1 +#define _TEST_C 2 +#define _POWER_C 25 +#define _LOG_C 25 +#define _MISC_C 1 + +#define _ADD_P 1 +#define _ABS_P 1 +#define _MULT_P 1 +#define _MAC_P 1 +#define _MOVE_P 1 +#define _STORE_P 0 +#define _LOGIC_P 1 +#define _SHIFT_P 1 +#define _BRANCH_P 2 +#define _DIV_P 2 +#define _SQRT_P 2 +#define _TRANS_P 2 +#define _FUNC_P 2 /* need to add number of arguments */ +#define _LOOP_P 1 +#define _INDIRECT_P 2 +#define _PTR_INIT_P 1 +#define _TEST_P 1 +#define _POWER_P 2 +#define _LOG_P 2 +#define _MISC_P 1 + +#define ADD( x ) \ + { \ + { \ + ops_cnt += ( _ADD_C * ( x ) ); \ + inst_cnt[_ADD] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _ADD_P * ( x ) ); \ + } \ + } \ + } \ + } +#define ABS( x ) \ + { \ + { \ + ops_cnt += ( _ABS_C * ( x ) ); \ + inst_cnt[_ABS] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _ABS_P * ( x ) ); \ + } \ + } \ + } \ + } +#define MULT( x ) \ + { \ + { \ + ops_cnt += ( _MULT_C * ( x ) ); \ + inst_cnt[_MULT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MULT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define MAC( x ) \ + { \ + { \ + ops_cnt += ( _MAC_C * ( x ) ); \ + inst_cnt[_MAC] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MAC_P * ( x ) ); \ + } \ + } \ + } \ + } +#define MOVE( x ) \ + { \ + { \ + ops_cnt += ( _MOVE_C * ( x ) ); \ + inst_cnt[_MOVE] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MOVE_P * ( x ) ); \ + } \ + } \ + } \ + } +#define STORE( x ) \ + { \ + { \ + ops_cnt += ( _STORE_C * ( x ) ); \ + inst_cnt[_STORE] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _STORE_P * ( x ) ); \ + } \ + } \ + } \ + } +#define LOGIC( x ) \ + { \ + { \ + ops_cnt += ( _LOGIC_C * ( x ) ); \ + inst_cnt[_LOGIC] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _LOGIC_P * ( x ) ); \ + } \ + } \ + } \ + } +#define SHIFT( x ) \ + { \ + { \ + ops_cnt += ( _SHIFT_C * ( x ) ); \ + inst_cnt[_SHIFT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _SHIFT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define BRANCH( x ) \ + { \ + { \ + ops_cnt += ( _BRANCH_C * ( x ) ); \ + inst_cnt[_BRANCH] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _BRANCH_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DIV( x ) \ + { \ + { \ + ops_cnt += ( _DIV_C * ( x ) ); \ + inst_cnt[_DIV] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _DIV_P * ( x ) ); \ + } \ + } \ + } \ + } +#define SQRT( x ) \ + { \ + { \ + ops_cnt += ( _SQRT_C * ( x ) ); \ + inst_cnt[_SQRT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _SQRT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define TRANS( x ) \ + { \ + { \ + ops_cnt += ( _TRANS_C * ( x ) ); \ + inst_cnt[_TRANS] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _TRANS_P * ( x ) ); \ + } \ + } \ + } \ + } +#define LOOP( x ) \ + { \ + { \ + ops_cnt += ( _LOOP_C * ( x ) ); \ + inst_cnt[_LOOP] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _LOOP_P * ( x ) ); \ + } \ + } \ + } \ + } +#define INDIRECT( x ) \ + { \ + { \ + ops_cnt += ( _INDIRECT_C * ( x ) ); \ + inst_cnt[_INDIRECT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _INDIRECT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define PTR_INIT( x ) \ + { \ + { \ + ops_cnt += ( _PTR_INIT_C * ( x ) ); \ + inst_cnt[_PTR_INIT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _PTR_INIT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define TEST( x ) \ + { \ + { \ + ops_cnt += ( _TEST_C * ( x ) ); \ + inst_cnt[_TEST] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _TEST_P * ( x ) ); \ + } \ + } \ + } \ + } +#define POWER( x ) \ + { \ + { \ + ops_cnt += ( _POWER_C * ( x ) ); \ + inst_cnt[_POWER] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _POWER_P * ( x ) ); \ + } \ + } \ + } \ + } +#define LOG( x ) \ + { \ + { \ + ops_cnt += ( _LOG_C * ( x ) ); \ + inst_cnt[_LOG] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _LOG_P * ( x ) ); \ + } \ + } \ + } \ + } +#define MISC( x ) \ + { \ + { \ + ops_cnt += ( _MISC_C * ( x ) ); \ + inst_cnt[_MISC] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MISC_P * ( x ) ); \ + } \ + } \ + } \ + } + +#define FUNC( x ) \ + { \ + { \ + ops_cnt += ( _FUNC_C + _MOVE_C * ( x ) ); \ + inst_cnt[_FUNC]++; \ + inst_cnt[_MOVE] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _FUNC_P + _MOVE_P * ( x ) ); \ + } \ + } \ + } \ + } + +#define DADD( x ) \ + { \ + { \ + ops_cnt += ( 2 * _ADD_C * ( x ) ); \ + inst_cnt[_ADD] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _ADD_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DMULT( x ) \ + { \ + { \ + ops_cnt += ( 2 * _MULT_C * ( x ) ); \ + inst_cnt[_MULT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MULT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DMAC( x ) \ + { \ + { \ + ops_cnt += ( 2 * _MAC_C * ( x ) ); \ + inst_cnt[_MAC] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MAC_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DMOVE( x ) \ + { \ + { \ + ops_cnt += ( 2 * _MOVE_C * ( x ) ); \ + inst_cnt[_MOVE] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MOVE_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DSTORE( x ) \ + { \ + { \ + ops_cnt += ( 2 * _STORE_C * ( x ) ); \ + inst_cnt[_STORE] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _STORE_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DLOGIC( x ) \ + { \ + { \ + ops_cnt += ( 2 * _LOGIC_C * ( x ) ); \ + inst_cnt[_LOGIC] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _LOGIC_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DSHIFT( x ) \ + { \ + { \ + ops_cnt += ( 2 * _SHIFT_C * ( x ) ); \ + inst_cnt[_SHIFT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _SHIFT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DDIV( x ) \ + { \ + { \ + ops_cnt += ( 2 * _DIV_C * ( x ) ); \ + inst_cnt[_DIV] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _DIV_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DSQRT( x ) \ + { \ + { \ + ops_cnt += ( 2 * _SQRT_C * ( x ) ); \ + inst_cnt[_SQRT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _SQRT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DTRANS( x ) \ + { \ + { \ + ops_cnt += ( 2 * _TRANS_C * ( x ) ); \ + inst_cnt[_TRANS] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _TRANS_P * ( x ) ); \ + } \ + } \ + } \ + } + +extern double ops_cnt; +extern double prom_cnt; +extern double inst_cnt[NUM_INST]; +extern int ops_cnt_activ; + +void reset_wmops( void ); +void push_wmops( const char *label ); +void pop_wmops( void ); +void update_wmops( void ); +void update_mem( void ); +void print_wmops( void ); + +#else /* WMOPS counting disabled */ + +#define reset_wmops() +extern int cntr_push_pop; +#define push_wmops( x ) ( cntr_push_pop++ ) +#define pop_wmops() ( cntr_push_pop-- ) +#define update_wmops() ( assert( cntr_push_pop == 0 ) ) +#define update_mem() +#define print_wmops() + +#define ADD( x ) +#define ABS( x ) +#define MULT( x ) +#define MAC( x ) +#define MOVE( x ) +#define STORE( x ) +#define LOGIC( x ) +#define SHIFT( x ) +#define BRANCH( x ) +#define DIV( x ) +#define SQRT( x ) +#define TRANS( x ) +#define FUNC( x ) +#define LOOP( x ) +#define INDIRECT( x ) +#define PTR_INIT( x ) +#define TEST( x ) +#define POWER( x ) +#define LOG( x ) +#define MISC( x ) + +#define DADD( x ) +#define DMULT( x ) +#define DMAC( x ) +#define DMOVE( x ) +#define DSTORE( x ) +#define DLOGIC( x ) +#define DSHIFT( x ) +#define DDIV( x ) +#define DSQRT( x ) +#define DTRANS( x ) + +#endif + +/* mac & msu (Non Instrumented Versions) */ +#ifndef mac +#define mac( a, b, c ) ( ( a ) + ( b ) * ( c ) ) +#endif +#ifndef mac +#define msu( a, b, c ) ( ( a ) - ( b ) * ( c ) ) +#endif + +#ifndef WMOPS +/* DESACTIVATE the Counting Mechanism */ +#define OP_COUNT_( op, n ) + +/* DESACTIVATE Operation Counter Wrappers */ +#define OP_COUNT_WRAPPER1_( op, val ) ( val ) +#define OP_COUNT_WRAPPER2_( expr ) +#define OP_COUNT_WRAPPER3_( op, expr ) expr + +/* DESACTIVATE Logical & Ternary Operators */ +#define __ +#define _ + +#else + +/* '*ops_cnt_ptr' is Used to Avoid: "warning: operation on 'ops_cnt' may be undefined" with Cygwin gcc Compiler */ +static double *ops_cnt_ptr = &ops_cnt; +#define OP_COUNT_( op, x ) ( *ops_cnt_ptr += ( op##_C * ( x ) ), inst_cnt[op] += ( x ) ) + +/******************************************************************/ +/* NOTES: */ +/* The 'wmc_flag_' flag is global to avoid declaration in every */ +/* function and 'static' to avoid clashing with other modules */ +/* that include this header file. */ +/* */ +/* The declarations of 'wmc_flag_' and 'wops_' in this header */ +/* file prevent the addition of a 'C' file to the Project. */ +/******************************************************************/ + +/* General Purpose Global Flag */ +static int wmc_flag_ = 0; + +/* Operation Counter Wrappers */ +#define OP_COUNT_WRAPPER1_( op, val ) ( op, val ) +#define OP_COUNT_WRAPPER2_( expr ) \ + if ( expr, 0 ) \ + ; \ + else +#define OP_COUNT_WRAPPER3_( op, expr ) \ + if ( op, 0 ) \ + ; \ + else \ + expr + +#endif + +/* Define all Macros without '{' & '}' (None of these should be called externally!) */ +#define ABS_( x ) OP_COUNT_( _ABS, ( x ) / WMOPS_BOOST_FAC ) +#define ADD_( x ) OP_COUNT_( _ADD, ( x ) / WMOPS_BOOST_FAC ) +#define MULT_( x ) OP_COUNT_( _MULT, ( x ) / WMOPS_BOOST_FAC ) +#define MAC_( x ) OP_COUNT_( _MAC, ( x ) / WMOPS_BOOST_FAC ) +#define MOVE_( x ) OP_COUNT_( _MOVE, ( x ) / WMOPS_BOOST_FAC ) +#define STORE_( x ) OP_COUNT_( _STORE, ( x ) / WMOPS_BOOST_FAC ) +#define LOGIC_( x ) OP_COUNT_( _LOGIC, ( x ) / WMOPS_BOOST_FAC ) +#define SHIFT_( x ) OP_COUNT_( _SHIFT, ( x ) / WMOPS_BOOST_FAC ) +#define BRANCH_( x ) OP_COUNT_( _BRANCH, ( x ) / WMOPS_BOOST_FAC ) +#define DIV_( x ) OP_COUNT_( _DIV, ( x ) / WMOPS_BOOST_FAC ) +#define SQRT_( x ) OP_COUNT_( _SQRT, ( x ) / WMOPS_BOOST_FAC ) +#define TRANS_( x ) OP_COUNT_( _TRANS, ( x ) / WMOPS_BOOST_FAC ) +#define POWER_( x ) TRANS_( x ) +#define LOG_( x ) TRANS_( x ) +#define LOOP_( x ) OP_COUNT_( _LOOP, ( x ) / WMOPS_BOOST_FAC ) +#define INDIRECT_( x ) OP_COUNT_( _INDIRECT, ( x ) / WMOPS_BOOST_FAC ) +#define PTR_INIT_( x ) OP_COUNT_( _PTR_INIT, ( x ) / WMOPS_BOOST_FAC ) +#define FUNC_( x ) ( OP_COUNT_( _MOVE, ( x ) / WMOPS_BOOST_FAC ), OP_COUNT_( _FUNC, 1 ) ) +#define MISC_( x ) ABS_( x ) + +/* Math Operations */ +#define abs_ OP_COUNT_WRAPPER1_( ABS_( 1 ), abs ) +#define fabs_ OP_COUNT_WRAPPER1_( ABS_( 1 ), fabs ) +#define labs_ OP_COUNT_WRAPPER1_( ABS_( 1 ), labs ) +#define floor_ OP_COUNT_WRAPPER1_( MISC_( 1 ), floor ) +#define sqrt_ OP_COUNT_WRAPPER1_( SQRT_( 1 ), sqrt ) +#define pow_ OP_COUNT_WRAPPER1_( POWER_( 1 ), pow ) +#define exp_ OP_COUNT_WRAPPER1_( POWER_( 1 ), exp ) +#define log_ OP_COUNT_WRAPPER1_( LOG_( 1 ), log ) +#define log10_ OP_COUNT_WRAPPER1_( LOG_( 1 ), log10 ) +#define cos_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), cos ) +#define sin_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), sin ) +#define tan_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), tan ) +#define acos_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), acos ) +#define asin_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), asin ) +#define atan_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), atan ) +#define atan2_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), atan2 ) +#define cosh_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), cosh ) +#define sinh_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), sinh ) +#define tanh_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), tanh ) +#define fmod_ OP_COUNT_WRAPPER1_( DIV_( 1 ), fmod ) +/* these macros use any local macros already defined */ +/* min/max and their Variants */ +#define min_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), min( ( a ), ( b ) ) ) +#define max_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), max( ( a ), ( b ) ) ) +#define MIN_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), MIN( ( a ), ( b ) ) ) +#define MAX_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), MAX( ( a ), ( b ) ) ) +#define Min_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), Min( ( a ), ( b ) ) ) +#define Max_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), Max( ( a ), ( b ) ) ) +/* Square and its Variants */ +#define sqr_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), sqr( ( x ) ) ) +#define Sqr_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), Sqr( ( x ) ) ) +#define SQR_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), SQR( ( x ) ) ) +#define square_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), square( ( x ) ) ) +#define Square_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), Square( ( x ) ) ) +#define SQUARE_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), SQUARE( ( x ) ) ) +/* Sign and its Variants */ +#define sign_( x ) OP_COUNT_WRAPPER1_( MOVE_( 1 ), sign( ( x ) ) ) +#define Sign_( x ) OP_COUNT_WRAPPER1_( MOVE_( 1 ), Sign( ( x ) ) ) +#define SIGN_( x ) OP_COUNT_WRAPPER1_( MOVE_( 1 ), SIGN( ( x ) ) ) +/* Square Root and its Variants */ +#define sqrtf_( x ) OP_COUNT_WRAPPER1_( SQRT_( 1 ), sqrtf( ( x ) ) ) +/* Invert Square Root and its Variants */ +#define inv_sqrt_( x ) OP_COUNT_WRAPPER1_( SQRT_( 1 ), inv_sqrt( ( x ) ) ) +/* Others */ +#define log_base_2_( x ) OP_COUNT_WRAPPER1_( ( LOG_( 1 ), MULT_( 1 ) ), log_base_2( ( x ) ) ) +#define log2_f_( x ) OP_COUNT_WRAPPER1_( ( LOG_( 1 ), MULT_( 1 ) ), log2_f( ( x ) ) ) +/* The 'wmc_flag_=wmc_flag_' is Used to Avoid: "warning: left-hand operand of comma expression has no effect" + with Cygwin gcc Compiler */ +#define _round_( x ) OP_COUNT_WRAPPER1_( wmc_flag_ = wmc_flag_, _round( ( x ) ) ) +#define round_f_( x ) OP_COUNT_WRAPPER1_( wmc_flag_ = wmc_flag_, round_f( ( x ) ) ) +#define _squant_( x ) OP_COUNT_WRAPPER1_( wmc_flag_ = wmc_flag_, _squant( ( x ) ) ) +/* Set Min/Max */ +#define set_min_( a, b ) OP_COUNT_WRAPPER3_( ( ADD_( 1 ), BRANCH_( 1 ), MOVE_( 1 ) ), set_min( ( a ), ( b ) ) ) +#define set_max_( a, b ) OP_COUNT_WRAPPER3_( ( ADD_( 1 ), BRANCH_( 1 ), MOVE_( 1 ) ), set_max( ( a ), ( b ) ) ) +/* mac & msu (Instrumented Versions) */ +#define mac_( a, b, c ) OP_COUNT_WRAPPER1_( MAC_( 1 ), mac( a, b, c ) ) +#define msu_( a, b, c ) OP_COUNT_WRAPPER1_( MAC_( 1 ), msu( a, b, c ) ) + +/* Functions */ +#define func_( name, x ) OP_COUNT_WRAPPER1_( FUNC_( x ), name ) + +/* Logical Operators */ +#ifndef __ +#define __ ( BRANCH_( 1 ), 1 ) && +#endif + +/* Ternary Operators (? and :) */ +#ifndef _ +#define _ ( BRANCH_( 1 ), 0 ) ? 0: +#endif + +/* Flow Control keywords */ +#define if_ \ + OP_COUNT_WRAPPER2_( BRANCH_( 1 ) ) \ + if +#define for_ OP_COUNT_WRAPPER2_( LOOP_(1)) for +#define while_( c ) \ + while \ + OP_COUNT_WRAPPER1_( BRANCH_( 1 ), ( c ) ) /* needs extra "()" if ',' encountered */ +#define do_ \ + do \ + { +#define _while \ + BRANCH_( 1 ); \ + } \ + while + +#define goto_ \ + OP_COUNT_WRAPPER2_( BRANCH_( 1 ) ) \ + goto +#define break_ \ + OP_COUNT_WRAPPER2_( BRANCH_( 1 ) ) \ + break +#define continue_ \ + OP_COUNT_WRAPPER2_( BRANCH_( 1 ) ) \ + continue +#define return_ \ + OP_COUNT_WRAPPER2_( ( wmc_flag_ = stack_tree_level_, STACK_DEPTH_FCT_RETURN ) ) \ + return + +#define switch_ \ + OP_COUNT_WRAPPER2_( ( BRANCH_( 1 ), wmc_flag_ = 1 ) ) \ + switch +#define cost_( n ) OP_COUNT_WRAPPER2_( wmc_flag_ ? ( ADD_( n ), BRANCH_( n ), wmc_flag_ = 0 ) : 0 ); + +#ifdef WMOPS + +#define ACC 2 +#define MUL 1 + +/* Counting Function (should not be called externally!) */ +static void wops_( const char *ops ) +{ + char lm = 0; /* lm: Last Operation is Math */ + static char lo = 0; /* Last Operation */ + + void ( *fct )( const char *ops ) = wops_; + +st: + while ( *ops != '\0' ) + { + switch ( *ops++ ) + { + int cnt; + case '-': + for ( cnt = 0; ops[cnt] == '>'; cnt++ ) + ; + if ( cnt & 1 ) + goto ind; + case '+': + lm = 2; + if ( lo & MUL ) + { + MULT_( -1 ); + MAC_( 1 ); + break; + } + lo = ACC << 2; + case 'U': + case 'D': + ADD_( 1 ); + break; + case '*': + lm = 2; + if ( lo & ACC ) + { + ADD_( -1 ); + MAC_( 1 ); + break; + } + lo = MUL << 2; + MULT_( 1 ); + break; + case '/': + case '%': + lm = 2; + DIV_( 1 ); + break; + case '&': + case '|': + case '^': + lm = 2; + case '~': + LOGIC_( 1 ); + break; + case '<': + case '>': + if ( *ops != ops[-1] ) + goto error; + ops++; + case -85: + case -69: + lm = 2; + SHIFT_( 1 ); + break; + case 'L': + case 'G': + if ( *ops == 't' ) + goto comp; + case 'E': + case 'N': + if ( *ops != 'e' ) + goto error; + comp: + ops++; + ADD_( 1 ); + break; + case '!': + MISC_( 2 ); + break; + case 'M': + MOVE_( 1 ); + break; + case 'S': + STORE_( 1 ); + break; + case 'P': + PTR_INIT_( 1 ); + break; + case '[': + case ']': + goto st; + ind: + ops++; + case 'I': + case '.': + INDIRECT_( 1 ); + break; + case '=': + if ( lm ) + goto st; + case '\0': + /* This Shouldn't Happen */ + /* These are Used to Avoid: "warning: 'name' defined but not used" with Cygwin gcc Compiler */ + wmc_flag_ = wmc_flag_; + ops_cnt_ptr = ops_cnt_ptr; + fct( "" ); + error: + default: + fprintf( stderr, "\r wops: Invalid Counting Operation '%s'\n", ops - 1 ); + exit( -1 ); + } + lm >>= 1; + lo >>= 2; + } + + return; +} + +#endif + +/* All Other Operations */ diff --git a/lib_dec/jbm_jb4sb.h b/lib_dec/jbm_jb4sb.h index 7142a6fd20..526ec7a011 100644 --- a/lib_dec/jbm_jb4sb.h +++ b/lib_dec/jbm_jb4sb.h @@ -63,11 +63,6 @@ struct JB4_DATAUNIT uint32_t rcvTime; /** true, if the data unit contains only silence */ bool silenceIndicator; -#ifndef MC_JBM - Word16 isAMRWB_IOmode; - /** for EVS payload */ - Word16 frameTypeIndex; -#endif /** Q bit for AMR-WB IO */ Word16 qBit; diff --git a/lib_dec/jbm_pcmdsp_apa.c b/lib_dec/jbm_pcmdsp_apa.c index f4434e916c..b92fcc1219 100644 --- a/lib_dec/jbm_pcmdsp_apa.c +++ b/lib_dec/jbm_pcmdsp_apa.c @@ -66,20 +66,12 @@ struct apa_state_t { /* output buffer */ -#ifdef MC_JBM int16_t *buf_out; uint16_t buf_out_capacity; -#else - int16_t buf_out[APA_BUF]; -#endif uint16_t l_buf_out; /* Hann window */ -#ifdef MC_JBM float win[APA_BUF_PER_CHANNEL]; -#else - float win[APA_BUF]; -#endif uint16_t l_halfwin; /* sampling rate [Hz] */ @@ -149,10 +141,8 @@ static bool extend_frm( apa_state_t *ps, const int16_t frm_in[], int16_t frm_out /* Allocates memory for state struct and initializes elements. */ uint8_t apa_init( apa_state_t **pps -#ifdef MC_JBM , int32_t num_channels -#endif ) { apa_state_t *ps = NULL; @@ -169,7 +159,6 @@ uint8_t apa_init( { return 2; } -#ifdef MC_JBM ps->num_channels = (uint16_t) num_channels; ps->buf_out_capacity = (uint16_t) ( APA_BUF_PER_CHANNEL * num_channels ); ps->buf_out = malloc( sizeof( float ) * ps->buf_out_capacity ); @@ -177,7 +166,6 @@ uint8_t apa_init( { return 2; } -#endif apa_reset( ps ); *pps = ps; @@ -209,9 +197,6 @@ void apa_reset( ps->last_pitch = 0; ps->bad_frame_count = 0; ps->good_frame_count = 0; -#ifndef MC_JBM - ps->num_channels = 0; -#endif return; } @@ -221,10 +206,6 @@ void apa_reset( bool apa_set_rate( apa_state_t *ps, const int32_t output_Fs -#ifndef MC_JBM - , - const int16_t num_channels -#endif ) { /* make sure pointer is valid */ @@ -245,15 +226,10 @@ bool apa_set_rate( /* copy rate to state struct */ ps->rate = (uint16_t) output_Fs; -#ifdef MC_JBM if ( ps->num_channels > APA_MAX_NUM_CHANNELS ) { return 1; } -#else - /* set number of channels */ - ps->num_channels = num_channels; -#endif /* * several other parameters depend on the sampling rate @@ -271,12 +247,7 @@ bool apa_set_rate( ps->l_seg = ( ps->rate / 100 ) * ps->num_channels; /* init Hann window */ -#ifdef MC_JBM /* Note: l_win < APA_BUF_PER_CHANNEL is required */ -#else - /* Note: l_win < APA_BUF is required, which is assured */ - /* because APA_MAX_RATE/100 = l_win = 441 < 2048 = APA_BUF */ -#endif /* Length of Hann window should be independent of * number of channels - same window applied to all channels */ ps->l_halfwin = ps->rate / 100; @@ -441,10 +412,8 @@ bool apa_exit( return 0; } -#ifdef MC_JBM /* deallocate state struct members */ free( ( *pps )->buf_out ); -#endif /* deallocate state struct */ free( *pps ); @@ -507,10 +476,8 @@ uint8_t apa_exec( statsResetThreshold = 1637; statsResetShift = 2; -#ifdef MC_JBM /* Convert max_scaling from "per channel" to total */ maxScaling *= ps->num_channels; -#endif /* make sure no invalid output is used */ *l_out = 0; @@ -615,11 +582,7 @@ uint8_t apa_exec( /* copy output to internal buffer */ /* avoid buffer overflow: */ /* discard old samples; always keep at least most recent l_frm samples */ -#ifdef MC_JBM if ( ( ps->l_buf_out + l_frm_out ) > ps->buf_out_capacity ) -#else - if ( ( ps->l_buf_out + l_frm_out ) > APA_BUF ) -#endif { int16_t *buf_out_ptr1 = ps->buf_out; int16_t *buf_out_ptr2; @@ -637,11 +600,7 @@ uint8_t apa_exec( ps->l_buf_out = l_rem; } /* append new output samples */ -#ifdef MC_JBM if ( ( ps->l_buf_out + l_frm_out ) > ps->buf_out_capacity ) -#else - if ( ( ps->l_buf_out + l_frm_out ) > APA_BUF ) -#endif { return 5; } @@ -876,11 +835,7 @@ static bool logarithmic_search( do { coeff_max = -FLT_MAX; /* will always be overwritten with result of first correlation */ -#ifdef MC_JBM for ( i = s_start; i < s_start + inlen; i += css * ps->num_channels ) -#else - for ( i = s_start; i < s_start + inlen; i += css ) -#endif { if ( ( wss == 1 ) && ( ps->num_channels == 1 ) ) { @@ -991,11 +946,7 @@ static bool find_synch( /* pass last pitch to search function as prediction value */ *synch_pos = ps->last_pitch; -#ifdef MC_JBM logarithmic_search( ps, in, s_start, s_len, offset, fixed_pos, corr_len, ps->wss, ps->css, synch_pos ); -#else - logarithmic_search( ps, in, s_start, s_len, offset, fixed_pos, corr_len, ps->wss, ps->css * ps->num_channels, synch_pos ); -#endif /* assert synch_pos is cleanly divisible by number of channels */ assert( *synch_pos % ps->num_channels == 0 ); diff --git a/lib_dec/jbm_pcmdsp_apa.h b/lib_dec/jbm_pcmdsp_apa.h index ab2cbdcb30..9f93307c64 100644 --- a/lib_dec/jbm_pcmdsp_apa.h +++ b/lib_dec/jbm_pcmdsp_apa.h @@ -50,13 +50,9 @@ */ /* size of IO buffers (a_in[], a_out[]) for apa_exec() */ -#ifdef MC_JBM #define APA_BUF_PER_CHANNEL ( 960 * 3 ) #define APA_MAX_NUM_CHANNELS 16 #define APA_BUF ( APA_BUF_PER_CHANNEL * APA_MAX_NUM_CHANNELS ) -#else -#define APA_BUF 4096 * 3 -#endif /* min/max sampling rate [Hz] */ #define APA_MIN_RATE 1000 @@ -96,10 +92,8 @@ typedef struct apa_state_t *PCMDSP_APA_HANDLE; /*! Allocates memory for state struct and initializes elements. * @return 0 on success, 1 on failure */ uint8_t apa_init( apa_state_t **s -#ifdef MC_JBM , int32_t num_channels -#endif ); /*! Sets state variables to initial value. */ @@ -115,10 +109,6 @@ void apa_reset( apa_state_t *s ); * @param[in] num_channels number of channels * @return 0 on success, 1 on failure */ bool apa_set_rate( apa_state_t *ps, const int32_t output_Fs -#ifndef MC_JBM - , - const int16_t num_channels -#endif ); /*! Set scaling. diff --git a/lib_dec/jbm_pcmdsp_fifo.c b/lib_dec/jbm_pcmdsp_fifo.c index 300adc3e74..32922cf58d 100644 --- a/lib_dec/jbm_pcmdsp_fifo.c +++ b/lib_dec/jbm_pcmdsp_fifo.c @@ -97,27 +97,15 @@ void pcmdsp_fifo_destroy( /* Initializes the FIFO with a fixed maximum allowed number audio samples. */ int16_t pcmdsp_fifo_init( PCMDSP_FIFO_HANDLE h, -#ifdef MC_JBM uint16_t nSamplesPerChannel, -#else - uint16_t nSamples, -#endif uint16_t nChannels, uint16_t nBytesPerSample ) { -#ifdef MC_JBM uint32_t nDataBytes; /* Must be 32-bit, otherwise overflows for multichannel */ h->capacity = nSamplesPerChannel; h->nBytesPerSampleSet = nChannels * nBytesPerSample; nDataBytes = nSamplesPerChannel * h->nBytesPerSampleSet; -#else - uint16_t nDataBytes; - - h->capacity = nSamples; - h->nBytesPerSampleSet = nChannels * nBytesPerSample; - nDataBytes = nSamples * h->nBytesPerSampleSet; -#endif h->dataBegin = malloc( nDataBytes ); h->dataEnd = h->dataBegin + nDataBytes; h->dataWriteIterator = h->dataBegin; @@ -213,11 +201,7 @@ int16_t pcmdsp_fifo_read( /* Returns the number of samples per channel that can be read (number of currently stored samples). */ -#ifdef MC_JBM uint16_t pcmdsp_fifo_nReadableSamplesPerChannel( -#else -uint16_t pcmdsp_fifo_nReadableSamples( -#endif const PCMDSP_FIFO_HANDLE h ) { return h->size; diff --git a/lib_dec/jbm_pcmdsp_fifo.h b/lib_dec/jbm_pcmdsp_fifo.h index 85312ace99..577f86cec0 100644 --- a/lib_dec/jbm_pcmdsp_fifo.h +++ b/lib_dec/jbm_pcmdsp_fifo.h @@ -70,20 +70,12 @@ int16_t pcmdsp_fifo_create( PCMDSP_FIFO_HANDLE *ph ); void pcmdsp_fifo_destroy( PCMDSP_FIFO_HANDLE *ph ); -#ifdef MC_JBM int16_t pcmdsp_fifo_init( PCMDSP_FIFO_HANDLE h, uint16_t nSamplesPerChannel, uint16_t nChannels, uint16_t nBytesPerSample ); -#else -int16_t pcmdsp_fifo_init( PCMDSP_FIFO_HANDLE h, uint16_t nSamples, uint16_t nChannels, uint16_t nBytesPerSample ); -#endif int16_t pcmdsp_fifo_write( PCMDSP_FIFO_HANDLE h, const uint8_t *samples, uint16_t nSamplesPerChannel ); int16_t pcmdsp_fifo_read( PCMDSP_FIFO_HANDLE h, uint16_t nSamplesPerChannel, uint8_t *samples ); -#ifdef MC_JBM uint16_t pcmdsp_fifo_nReadableSamplesPerChannel( const PCMDSP_FIFO_HANDLE h ); -#else -uint16_t pcmdsp_fifo_nReadableSamples( const PCMDSP_FIFO_HANDLE h ); -#endif #endif /* JBM_PCMDSP_FIFO_H */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 5b7e5f9046..7aea25bab8 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -55,11 +55,9 @@ struct IVAS_DEC_VOIP PCMDSP_APA_HANDLE hTimeScaler; PCMDSP_FIFO_HANDLE hFifoAfterTimeScaler; uint16_t lastDecodedWasActive; -#ifdef MC_JBM int16_t *apaExecBuffer; /* Buffer for APA scaling */ JB4_DATAUNIT_HANDLE hCurrentDataUnit; /* Points to the currently processed data unit */ uint16_t *bs_conversion_buf; /* Buffer for bitstream conversion from packed to serial */ -#endif #ifdef SUPPORT_JBM_TRACEFILE IVAS_JBM_TRACE_DATA JbmTraceData; #endif @@ -489,30 +487,13 @@ ivas_error IVAS_DEC_EnableVoIP( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } -#ifndef MC_JBM - if ( !hIvasDec->isInitialized ) - { - if ( ( error = ivas_init_decoder( hIvasDec->st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - - hIvasDec->st_ivas->hDecoderConfig->ivas_total_brate = ACELP_8k00; - hIvasDec->isInitialized = true; - } -#endif hDecoderConfig = hIvasDec->st_ivas->hDecoderConfig; hIvasDec->Opt_VOIP = 1; -#ifdef MC_JBM hDecoderConfig->nchan_out = audioCfg2channels( hDecoderConfig->output_config ); assert( hDecoderConfig->nchan_out > 0 && "EXT output not yet supported in VoIP mode" ); -#else - hIvasDec->st_ivas->hSCE[0]->hCoreCoder[0]->codec_mode = 0; - hDecoderConfig->nchan_out = 1; /* VoIP only supported in mono */ -#endif if ( ( error = input_format_API_to_internal( inputFormat, &hIvasDec->bitstreamformat, &hIvasDec->sdp_hf_only, true ) ) != IVAS_ERR_OK ) { @@ -525,14 +506,9 @@ ivas_error IVAS_DEC_EnableVoIP( } hIvasDec->hVoIP->lastDecodedWasActive = 0; -#ifdef MC_JBM hIvasDec->hVoIP->hCurrentDataUnit = NULL; hIvasDec->hVoIP->nSamplesFrame = (uint16_t) ( hDecoderConfig->output_Fs * hDecoderConfig->nchan_out / FRAMES_PER_SEC ); -#else - hIvasDec->hVoIP->nSamplesFrame = (uint16_t) ( hDecoderConfig->output_Fs / FRAMES_PER_SEC ); -#endif -#ifdef MC_JBM hIvasDec->hVoIP->apaExecBuffer = malloc( sizeof( int16_t ) * APA_BUF_PER_CHANNEL * hDecoderConfig->nchan_out ); if ( hIvasDec->hVoIP->apaExecBuffer == NULL ) { @@ -552,7 +528,6 @@ ivas_error IVAS_DEC_EnableVoIP( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate VoIP handle" ); } -#endif /* initialize JBM */ if ( ( error = JB4_Create( &hIvasDec->hVoIP->hJBM ) != IVAS_ERR_OK ) != IVAS_ERR_OK ) @@ -590,16 +565,10 @@ ivas_error IVAS_DEC_EnableVoIP( } if ( apa_init( &hIvasDec->hVoIP->hTimeScaler -#ifdef MC_JBM , hDecoderConfig->nchan_out -#endif ) != 0 || apa_set_rate( hIvasDec->hVoIP->hTimeScaler, hDecoderConfig->output_Fs -#ifndef MC_JBM - , - hDecoderConfig->nchan_out -#endif ) != 0 || apa_set_complexity_options( hIvasDec->hVoIP->hTimeScaler, wss, css ) != 0 || apa_set_quality( hIvasDec->hVoIP->hTimeScaler, 1, 4, 4 ) != 0 || @@ -641,7 +610,6 @@ ivas_error IVAS_DEC_FeedFrame_Serial( return error; } -#ifdef MC_JBM if ( hIvasDec->hVoIP != NULL && hIvasDec->hVoIP->hCurrentDataUnit != NULL ) { DEC_CORE_HANDLE st = hIvasDec->st_ivas->hSCE[0]->hCoreCoder[0]; @@ -653,9 +621,6 @@ ivas_error IVAS_DEC_FeedFrame_Serial( { hIvasDec->st_ivas->hDecoderConfig->ivas_total_brate = ACELP_8k00; } -#else - hIvasDec->st_ivas->hDecoderConfig->ivas_total_brate = ACELP_8k00; -#endif } hIvasDec->isInitialized = true; @@ -666,7 +631,6 @@ ivas_error IVAS_DEC_FeedFrame_Serial( hIvasDec->hasBeenFedFirstGoodFrame = true; } -#ifdef MC_JBM /* Update redundant frame information in EVS (pre- read indices) */ if ( hIvasDec->mode == IVAS_DEC_MODE_EVS && hIvasDec->hVoIP != NULL && hIvasDec->hVoIP->hCurrentDataUnit != NULL ) { @@ -687,11 +651,9 @@ ivas_error IVAS_DEC_FeedFrame_Serial( bfi = 2; } } -#endif error = read_indices( hIvasDec->st_ivas, serial, num_bits, &hIvasDec->prev_ft_speech, &hIvasDec->CNG, bfi ); -#ifdef MC_JBM /* Update redundant frame information in EVS (post- read indices) */ if ( hIvasDec->mode == IVAS_DEC_MODE_EVS && hIvasDec->hVoIP != NULL && @@ -702,7 +664,6 @@ ivas_error IVAS_DEC_FeedFrame_Serial( st->codec_mode = MODE2; st->use_partial_copy = 1; } -#endif return error; } @@ -1150,13 +1111,11 @@ ivas_error IVAS_DEC_GetDelay( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } -#ifdef MC_JBM if ( !hIvasDec->hasDecodedFirstGoodFrame ) { /* Delay depends on IVAS format, which is unknown until first frame has been decoded */ return IVAS_ERR_WAITING_FOR_BITSTREAM; } -#endif st_ivas = hIvasDec->st_ivas; hDecoderConfig = st_ivas->hDecoderConfig; @@ -1249,7 +1208,6 @@ static bool isSidFrame( return false; } -#ifdef MC_JBM static void bsCompactToSerial( const uint8_t *compact, uint16_t *serial, uint16_t num_bits ) { /* Bitstream conversion is not counted towards complexity and memory usage */ @@ -1279,7 +1237,6 @@ static void bsCompactToSerial( const uint8_t *compact, uint16_t *serial, uint16_ #endif #undef WMC_TOOL_SKIP } -#endif /*---------------------------------------------------------------------* @@ -1295,10 +1252,6 @@ ivas_error IVAS_DEC_VoIP_FeedFrame( const uint16_t rtpSequenceNumber, /* i : RTP sequence number (16 bits) */ const uint32_t rtpTimeStamp, /* i : RTP timestamp (32 bits) */ const uint32_t rcvTime_ms, /* i : receive time of the RTP packet in milliseconds */ -#ifndef MC_JBM - const bool isAMRWB_IOmode, /* i : AMRWB flag */ - const uint16_t frameTypeIndex, /* i : core mode for frame */ -#endif const bool qBit /* i : Q bit for AMR-WB IO */ ) { @@ -1330,10 +1283,6 @@ ivas_error IVAS_DEC_VoIP_FeedFrame( dataUnit->timeStamp = rtpTimeStamp; dataUnit->partial_frame = 0; dataUnit->partialCopyOffset = partialCopyOffset; -#ifndef MC_JBM - dataUnit->isAMRWB_IOmode = isAMRWB_IOmode; - dataUnit->frameTypeIndex = frameTypeIndex; -#endif dataUnit->qBit = qBit; /* add the frame to the JBM */ @@ -1357,10 +1306,6 @@ ivas_error IVAS_DEC_VoIP_FeedFrame( dataUnit->timeStamp = rtpTimeStamp - partialCopyOffset * dataUnit->duration; dataUnit->partial_frame = 1; dataUnit->partialCopyOffset = partialCopyOffset; -#ifndef MC_JBM - dataUnit->isAMRWB_IOmode = isAMRWB_IOmode; - dataUnit->frameTypeIndex = frameTypeIndex; -#endif dataUnit->qBit = qBit; /* add the frame to the JBM */ @@ -1383,40 +1328,23 @@ ivas_error IVAS_DEC_VoIP_FeedFrame( ivas_error IVAS_DEC_VoIP_GetSamples( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ -#ifdef MC_JBM uint16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ -#else - int16_t *nOutSamples, /* o : number of samples written to output buffer */ - int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ - const uint32_t pcmBufSize, /* i : size of the PCM output buffer */ -#endif const uint32_t systemTimestamp_ms /* i : current system timestamp */ -#ifdef MC_JBM #ifdef SUPPORT_JBM_TRACEFILE , JbmTraceFileWriterFn jbmWriterFn, void *jbmWriter #endif -#endif ) { Decoder_Struct *st_ivas; DECODER_CONFIG_HANDLE hDecoderConfig; -#ifndef MC_JBM - Decoder_State *st; -#endif IVAS_DEC_VOIP *hVoIP; uint32_t extBufferedTime_ms, scale, maxScaling; uint16_t nTimeScalerOutSamples; JB4_DATAUNIT_HANDLE dataUnit; -#ifndef MC_JBM - uint16_t bit_stream[MAX_BITS_PER_FRAME + 4 * 8]; -#endif int16_t nOutSamplesElse; -#ifndef MC_JBM - uint16_t soundCardFrameSize; -#endif uint16_t extBufferedSamples; int16_t timeScalingDone; int16_t result; @@ -1427,37 +1355,18 @@ ivas_error IVAS_DEC_VoIP_GetSamples( st_ivas = hIvasDec->st_ivas; hDecoderConfig = st_ivas->hDecoderConfig; hVoIP = hIvasDec->hVoIP; -#ifndef MC_JBM - st = st_ivas->hSCE[0]->hCoreCoder[0]; - soundCardFrameSize = hVoIP->nSamplesFrame; -#endif timeScalingDone = 0; -#ifdef MC_JBM /* TODO(mcjbm): ringbuffer capacity should be configurable by user */ if ( nSamplesPerChannel > hVoIP->hFifoAfterTimeScaler->capacity || nSamplesPerChannel == 0 ) { return IVAS_ERR_WRONG_PARAMS; } -#else - assert( hVoIP->nSamplesFrame <= pcmBufSize ); - assert( hVoIP->nSamplesFrame <= APA_BUF ); - - st_ivas->hSCE[0]->hCoreCoder[0]->bit_stream = bit_stream; -#endif /* make sure that the FIFO after decoder/scaler contains at least one sound card frame (i.e. 20ms) */ -#ifdef MC_JBM while ( pcmdsp_fifo_nReadableSamplesPerChannel( hVoIP->hFifoAfterTimeScaler ) < nSamplesPerChannel ) -#else - while ( pcmdsp_fifo_nReadableSamples( hVoIP->hFifoAfterTimeScaler ) < soundCardFrameSize ) -#endif { -#ifdef MC_JBM extBufferedSamples = pcmdsp_fifo_nReadableSamplesPerChannel( hVoIP->hFifoAfterTimeScaler ); -#else - extBufferedSamples = pcmdsp_fifo_nReadableSamples( hVoIP->hFifoAfterTimeScaler ); -#endif extBufferedTime_ms = extBufferedSamples * 1000 / hDecoderConfig->output_Fs; dataUnit = NULL; /* pop one access unit from the jitter buffer */ @@ -1484,79 +1393,27 @@ ivas_error IVAS_DEC_VoIP_GetSamples( /* copy bitstream into decoder state */ if ( dataUnit ) { -#ifdef MC_JBM hIvasDec->hVoIP->hCurrentDataUnit = dataUnit; bsCompactToSerial( dataUnit->data, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize ); IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize, 0 ); -#else - if ( st->codec_mode != 0 ) - { - read_indices_from_djb( st, dataUnit->data, &hIvasDec->CNG, dataUnit->dataSize, - dataUnit->isAMRWB_IOmode, dataUnit->frameTypeIndex, dataUnit->qBit, hIvasDec->bitstreamformat, hIvasDec->amrwb_rfc4867_flag, - ( dataUnit->partial_frame == TRUE ) ? 1 : 0, dataUnit->nextCoderType ); - - if ( dataUnit->partial_frame != 0 ) - { - st->codec_mode = MODE2; - st->use_partial_copy = 1; - } - } - else /* initialize decoder with first received frame */ - { - /* initialize, since this is needed within read_indices_from_djb, to correctly set st->last_codec_mode */ - st->ini_frame = 0; - st->prev_use_partial_copy = 0; - st_ivas->hDecoderConfig->ivas_total_brate = dataUnit->dataSize * FRAMES_PER_SEC; - - read_indices_from_djb( st, dataUnit->data, &hIvasDec->CNG, dataUnit->dataSize, - dataUnit->isAMRWB_IOmode, dataUnit->frameTypeIndex, dataUnit->qBit, hIvasDec->bitstreamformat, hIvasDec->amrwb_rfc4867_flag, - 0, 0 ); - } -#endif } -#ifdef MC_JBM else if ( hIvasDec->hasDecodedFirstGoodFrame ) { /* Decoder has been initialized with first good frame - do PLC */ IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, 0, 1 ); -#else - else if ( st->codec_mode != 0 ) - { - read_indices_from_djb( st, NULL, &hIvasDec->CNG, 0, - 0, 0, 0, hIvasDec->bitstreamformat, 0, - 0, 0 ); -#endif } /* decode */ -#ifdef MC_JBM if ( !hIvasDec->hasBeenFedFirstGoodFrame ) { /* codec mode to use not known yet - simply output silence */ set_s( hVoIP->apaExecBuffer, 0, hVoIP->nSamplesFrame ); /* TODO(mcjbm): Could be optimized: just write directly to output buffer */ -#else - if ( st->codec_mode == 0 ) - { - /* codec mode to use not known yet */ - set_s( pcmBuf, 0, hVoIP->nSamplesFrame ); -#endif } else { -#ifndef MC_JBM - if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) - { - /* Update total bitrate after reading indices */ - hIvasDec->st_ivas->hDecoderConfig->ivas_total_brate = st->total_brate; - } -#endif -#ifdef MC_JBM if ( ( error = IVAS_DEC_GetSamples( hIvasDec, hVoIP->apaExecBuffer, &nOutSamplesElse ) ) != IVAS_ERR_OK ) -#else - if ( ( error = IVAS_DEC_GetSamples( hIvasDec, pcmBuf, &nOutSamplesElse ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -1591,31 +1448,19 @@ ivas_error IVAS_DEC_VoIP_GetSamples( { return IVAS_ERR_UNKNOWN; } -#ifdef MC_JBM result = apa_exec( hVoIP->hTimeScaler, hVoIP->apaExecBuffer, hVoIP->nSamplesFrame, (uint16_t) maxScaling, hVoIP->apaExecBuffer, &nTimeScalerOutSamples ); -#else - result = apa_exec( hVoIP->hTimeScaler, pcmBuf, (uint16_t) ( hVoIP->nSamplesFrame * hDecoderConfig->nchan_out ), (uint16_t) maxScaling, pcmBuf, &nTimeScalerOutSamples ); -#endif if ( result != 0 ) { return IVAS_ERR_UNKNOWN; } -#ifndef MC_JBM - assert( nTimeScalerOutSamples <= pcmBufSize ); -#endif assert( nTimeScalerOutSamples <= APA_BUF ); /* append scaled samples to FIFO */ -#ifdef MC_JBM if ( pcmdsp_fifo_write( hVoIP->hFifoAfterTimeScaler, (uint8_t *) hVoIP->apaExecBuffer, (uint16_t) ( nTimeScalerOutSamples / hDecoderConfig->nchan_out ) ) != 0 ) -#else - if ( pcmdsp_fifo_write( hVoIP->hFifoAfterTimeScaler, (uint8_t *) pcmBuf, (uint16_t) ( nTimeScalerOutSamples / hDecoderConfig->nchan_out ) ) != 0 ) -#endif { return IVAS_ERR_UNKNOWN; } -#ifdef MC_JBM #ifdef SUPPORT_JBM_TRACEFILE /* jbmWriterFn and jbmWriter may be NULL if tracefile writing was not requested on CLI */ if ( jbmWriterFn != NULL && jbmWriter != NULL ) @@ -1628,23 +1473,11 @@ ivas_error IVAS_DEC_VoIP_GetSamples( return IVAS_ERR_UNKNOWN; } } -#endif -#else -#ifdef SUPPORT_JBM_TRACEFILE - /* store JBM trace data entry */ - store_JbmData( hVoIP, dataUnit, systemTimestamp_ms, extBufferedSamples, hDecoderConfig->output_Fs ); -#endif #endif } -#ifdef MC_JBM /* fetch a user-specified number of samples from FIFO */ if ( pcmdsp_fifo_read( hVoIP->hFifoAfterTimeScaler, nSamplesPerChannel, (uint8_t *) pcmBuf ) != 0 ) -#else - /* fetch one frame for the sound card from FIFO */ - *nOutSamples = (int16_t) soundCardFrameSize; - if ( pcmdsp_fifo_read( hVoIP->hFifoAfterTimeScaler, *nOutSamples, (uint8_t *) pcmBuf ) != 0 ) -#endif { return IVAS_ERR_UNKNOWN; } @@ -1706,7 +1539,6 @@ static void IVAS_DEC_Close_VoIP( pcmdsp_fifo_destroy( &hVoIP->hFifoAfterTimeScaler ); -#ifdef MC_JBM if ( hVoIP->apaExecBuffer != NULL ) { free( hVoIP->apaExecBuffer ); @@ -1719,7 +1551,6 @@ static void IVAS_DEC_Close_VoIP( free( hVoIP->bs_conversion_buf ); #undef WMC_TOOL_SKIP } -#endif free( hVoIP ); @@ -1750,7 +1581,6 @@ static void store_JbmData( JbmTraceData = &hVoIP->JbmTraceData; -#ifdef MC_JBM JbmTraceData->systemTimestamp_ms = systemTimestamp_ms; JbmTraceData->extBufferedSamples = extBufferedSamples; JbmTraceData->lastDecodedWasActive = hVoIP->lastDecodedWasActive; @@ -1764,34 +1594,6 @@ static void store_JbmData( JbmTraceData->partial_frame = dataUnit->partial_frame; JbmTraceData->partialCopyOffset = dataUnit->partialCopyOffset; } -#else - /* the first sample of the decoded/concealed frame will be played after the samples in the ring buffer */ - JbmTraceData->playTime = systemTimestamp_ms + extBufferedSamples * 1000.0 / output_Fs; - - /* rtpSeqNo;rtpTs;rcvTime;playTime;active\n */ - if ( dataUnit ) - { - JbmTraceData->sequenceNumber = dataUnit->sequenceNumber; - JbmTraceData->partialCopyOffset = dataUnit->partialCopyOffset; - JbmTraceData->timeStamp = dataUnit->timeStamp; - JbmTraceData->rcvTime = dataUnit->rcvTime; - JbmTraceData->lastDecodedWasActive = hVoIP->lastDecodedWasActive; - - JbmTraceData->dataUnit_flag = 1; - if ( dataUnit->partial_frame == 1 ) - { - JbmTraceData->partial_frame_flag = 1; - } - else - { - JbmTraceData->partial_frame_flag = 0; - } - } - else - { - JbmTraceData->dataUnit_flag = 0; - } -#endif return; } @@ -2110,7 +1912,6 @@ void IVAS_DEC_PrintConfigWithBitstream( return; } -#ifdef MC_JBM void IVAS_DEC_PrintConfigWithVoipBitstream( IVAS_DEC_HANDLE hIvasDec, const bool quietModeEnabled, @@ -2136,7 +1937,6 @@ void IVAS_DEC_PrintConfigWithVoipBitstream( return; } -#endif #undef WMC_TOOL_SKIP #endif diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 5d57d330a9..1af44bb43f 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -103,12 +103,10 @@ typedef enum _IVAS_DEC_BS_FORMAT typedef struct IVAS_DEC *IVAS_DEC_HANDLE; -#ifdef MC_JBM #ifdef SUPPORT_JBM_TRACEFILE /* Callback function for JBM tracefile writing */ typedef ivas_error ( *JbmTraceFileWriterFn )( const void *data, void *writer ); #endif -#endif /* clang-format off */ @@ -190,31 +188,19 @@ ivas_error IVAS_DEC_VoIP_FeedFrame( const uint16_t rtpSequenceNumber, /* i : RTP sequence number (16 bits) */ const uint32_t rtpTimeStamp, /* i : RTP timestamp (32 bits) */ const uint32_t rcvTime_ms, /* i : receive time of the RTP packet in milliseconds */ -#ifndef MC_JBM - const bool isAMRWB_IOmode, /* i : AMRWB flag */ - const uint16_t frameTypeIndex, /* i : core mode for frame */ -#endif const bool qBit /* i : Q bit for AMR-WB IO */ ); /*! r: error code */ ivas_error IVAS_DEC_VoIP_GetSamples( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ -#ifdef MC_JBM uint16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ -#else - int16_t *nOutSamples, /* o : number of samples written to output buffer */ - int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ - const uint32_t pcmBufSize, /* i : size of the PCM output buffer */ -#endif const uint32_t systemTimestamp_ms /* i : current system timestamp */ -#ifdef MC_JBM #ifdef SUPPORT_JBM_TRACEFILE , JbmTraceFileWriterFn jbmWriterFn, void* jbmWriter #endif -#endif ); /* Setter functions - apply changes to decoder configuration */ @@ -368,7 +354,6 @@ void IVAS_DEC_PrintConfigWithBitstream( const int16_t num_bits /* i : number of bits in bitstream */ ); -#ifdef MC_JBM void IVAS_DEC_PrintConfigWithVoipBitstream( IVAS_DEC_HANDLE hIvasDec, /* i : IVAS decoder handle */ const bool quietModeEnabled, /* i : quiet mode flag: if true, reduces the amount of config info printed */ @@ -376,7 +361,6 @@ void IVAS_DEC_PrintConfigWithVoipBitstream( const uint16_t auSizeBits /* i : size of the access unit in bits */ ); #endif -#endif void IVAS_DEC_PrintDisclaimer( void diff --git a/lib_util/evs_rtp_payload.c b/lib_util/evs_rtp_payload.c index 5adb67d1af..ec5be566bd 100644 --- a/lib_util/evs_rtp_payload.c +++ b/lib_util/evs_rtp_payload.c @@ -141,38 +141,6 @@ static void evsHeaderFullPayload_parseToc( uint8_t toc, bool *isAMRWB_IOmode, bo } } -#ifndef MC_JBM -bool evsPayload_getFrameTypeFromSize( int16_t frameSizeBits, bool *isAMRWB_IOmode, uint16_t *frameTypeIndex ) -{ - int16_t i; - int32_t rate; - rate = frameSizeBits * 50; - if ( rate == 0 ) - { - assert( 0 ); /* VOIP_G192_RTP should not transmit empty frames */ - return false; /* no information available */ - } - for ( i = 0; i <= 9; ++i ) - { - if ( rate == AMRWB_IOmode2rate[i] ) - { - *isAMRWB_IOmode = true; - *frameTypeIndex = i; - return true; - } - } - for ( i = 0; i <= 12; ++i ) - { - if ( rate == PRIMARYmode2rate[i] ) - { - *isAMRWB_IOmode = false; - *frameTypeIndex = i; - return true; - } - } - return false; -} -#endif bool evsHeaderFullPayload_unpackFrame( char *payload, uint16_t payloadSizeBytes, uint16_t frameIndex, bool *isAMRWB_IOmode, bool *frameFollowing, uint16_t *frameTypeIndex, bool *qBit, unsigned char **frame, uint16_t *frameSizeInBits ) { diff --git a/lib_util/evs_rtp_payload.h b/lib_util/evs_rtp_payload.h index a39811c1f2..0aa665d227 100644 --- a/lib_util/evs_rtp_payload.h +++ b/lib_util/evs_rtp_payload.h @@ -160,9 +160,6 @@ extern "C" bool evsPayload_unpackFrame( bool hf_only, char *payload, uint16_t payloadSizeBytes, uint16_t frameIndex, bool *isAMRWB_IOmode, bool *frameFollowing, uint16_t *frameTypeIndex, bool *qBit, unsigned char **framePtr, uint16_t *frameSizeBits ); -#ifndef MC_JBM - bool evsPayload_getFrameTypeFromSize( int16_t frameSizeBits, bool *isAMRWB_IOmode, uint16_t *frameTypeIndex ); -#endif bool evsHeaderFullPayload_unpackFrame( char *payload, uint16_t payloadSizeBytes, uint16_t frameIndex, bool *isAMRWB_IOmode, bool *frameFollowing, uint16_t *frameTypeIndex, bool *qBit, unsigned char **frame, uint16_t *frameSizeBits ); diff --git a/lib_util/jbm_file_writer.c b/lib_util/jbm_file_writer.c index cb5e16e14b..c0c288c43d 100644 --- a/lib_util/jbm_file_writer.c +++ b/lib_util/jbm_file_writer.c @@ -224,11 +224,7 @@ ivas_error JbmTraceFileWriter_open( /*! r: error code */ ivas_error JbmTraceFileWriter_writeFrame( -#ifdef MC_JBM const IVAS_JBM_TRACE_DATA *data, /* i : JBM trace data */ -#else - const IVAS_JBM_TRACE_DATA *JbmTraceData, /* i : JBM trace data */ -#endif JbmTraceFileWriter *jbmTraceWriter /* o : JbmTraceFileWriter handle */ ) { @@ -243,43 +239,23 @@ ivas_error JbmTraceFileWriter_writeFrame( if ( file ) { -#ifdef MC_JBM /* the first sample of the decoded/concealed frame will be played after the samples in the ring buffer */ double playTime = data->systemTimestamp_ms + data->extBufferedSamples * 1000.0 / data->output_Fs; -#endif /* rtpSeqNo;rtpTs;rcvTime;playTime;active\n */ -#ifdef MC_JBM if ( data->dataUnit_flag ) { if ( data->partial_frame == 1 ) -#else - if ( JbmTraceData->dataUnit_flag ) - { - if ( JbmTraceData->partial_frame_flag == 1 ) -#endif { -#ifdef MC_JBM fprintf( file, "%d;%d;%d;%f;%d;%d\n", -1, -1, -1, playTime, data->lastDecodedWasActive, data->partialCopyOffset ); -#else - fprintf( file, "%d;%d;%d;%f;%d;%d\n", -1, -1, -1, JbmTraceData->playTime, JbmTraceData->lastDecodedWasActive, JbmTraceData->partialCopyOffset ); -#endif } else { -#ifdef MC_JBM fprintf( file, "%u;%u;%u;%f;%d\n", data->sequenceNumber, data->timeStamp, data->rcvTime, playTime, data->lastDecodedWasActive ); -#else - fprintf( file, "%u;%u;%u;%f;%d\n", JbmTraceData->sequenceNumber, JbmTraceData->timeStamp, JbmTraceData->rcvTime, JbmTraceData->playTime, JbmTraceData->lastDecodedWasActive ); -#endif } } else { -#ifdef MC_JBM fprintf( file, "%d;%d;%d;%f;%d\n", -1, -1, -1, playTime, data->lastDecodedWasActive ); -#else - fprintf( file, "%d;%d;%d;%f;%d\n", -1, -1, -1, JbmTraceData->playTime, JbmTraceData->lastDecodedWasActive ); -#endif } } else -- GitLab From 2f3b6cfaa3aea0bcd61299de355897e7b41882a4 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Fri, 13 Jan 2023 13:18:42 +0100 Subject: [PATCH 4/7] [cleanup] accept FIX_265_MC_BRATE_SWITCHING --- lib_com/options.h | 1 - lib_debug/coan_out_000003 | 924 ++++++++++++++++++++++++++ lib_dec/ivas_corecoder_dec_reconfig.c | 2 - lib_dec/ivas_stereo_switching_dec.c | 4 - lib_enc/ivas_stereo_switching_enc.c | 4 - 5 files changed, 924 insertions(+), 11 deletions(-) create mode 100644 lib_debug/coan_out_000003 diff --git a/lib_com/options.h b/lib_com/options.h index 6d57fde43c..28b03667c6 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -147,7 +147,6 @@ #endif #define FIX_I59_DELAY_ROUNDING /* Issue 59: rounding in sample domain instead of nanosec for IVAS_ENC_GetDelay() and IVAS_DEC_GetDelay() */ #define FIX_FIX_I59 /* Issue 59: small fix concerning LFE delay rounding */ -#define FIX_265_MC_BRATE_SWITCHING /* Issue 265: fix use-of-uninitialized-value in MC bitrate switching */ #define FIX_ANGLE_WRAPPING /* Issue 244: Problems with angle wrapping*/ #define FIX_245_RANGE_CODER_VOIP_MSAN /* Issue 245: fix use-of-uninitialized-value in range coder in VoIP mode */ #define FIX_272_COV /* Issue 272: Cleanup for code coverage related to calls to ivas_binaural_cldfb() */ diff --git a/lib_debug/coan_out_000003 b/lib_debug/coan_out_000003 new file mode 100644 index 0000000000..bf31e63cef --- /dev/null +++ b/lib_debug/coan_out_000003 @@ -0,0 +1,924 @@ +/* + * (C) 2022 copyright VoiceAge Corporation. All Rights Reserved. + * + * This software is protected by copyright law and by international treaties. The source code, and all of its derivations, + * is provided by VoiceAge Corporation under the "ITU-T Software Tools' General Public License". Please, read the license file + * or refer to ITU-T Recommendation G.191 on "SOFTWARE TOOLS FOR SPEECH AND AUDIO CODING STANDARDS". + * + * Any use of this software is permitted provided that this notice is not removed and that neither the authors nor + * VoiceAge Corporation are deemed to have made any representations as to the suitability of this software + * for any purpose nor are held responsible for any defects of this software. THERE IS NO WARRANTY FOR THIS SOFTWARE. + * + * Authors: Guy Richard, Vladimir Malenovsky (Vladimir.Malenovsky@USherbrooke.ca) + */ + +#ifndef WMOPS_H +#define WMOPS_H + +#ifndef EXIT_FAILURE +#include /* stdlib is needed for exit() */ +#endif + +#ifndef EOF +#include /* stdio is needed for fprintf() */ +#endif + + +/* To Prevent "warning: '$' in identifier or number" message under GCC */ +#ifdef __GNUC__ +#pragma GCC system_header +#endif + +/* Real-time relationships */ +#define FRAMES_PER_SECOND 50.0 +#define MILLION_CYCLES 1e6 +#define WMOPS_BOOST_FAC ( 1.0f ) /* scaling factor for equalizing the difference between automatic and manual instrumentation */ +#define FAC ( FRAMES_PER_SECOND / MILLION_CYCLES * WMOPS_BOOST_FAC ) +#define NUM_INST 20 /* Total number of instruction types (in enum below) */ + + +#ifdef WMOPS +enum instructions +{ + _ADD, + _ABS, + _MULT, + _MAC, + _MOVE, + _STORE, + _LOGIC, + _SHIFT, + _BRANCH, + _DIV, + _SQRT, + _TRANS, + _FUNC, + _LOOP, + _INDIRECT, + _PTR_INIT, + _TEST, + _POWER, + _LOG, + _MISC +}; + +#define _ADD_C 1 +#define _ABS_C 1 +#define _MULT_C 1 +#define _MAC_C 1 +#define _MOVE_C 1 +#define _STORE_C 1 +#define _LOGIC_C 1 +#define _SHIFT_C 1 +#define _BRANCH_C 4 +#define _DIV_C 18 +#define _SQRT_C 10 +#define _TRANS_C 25 +#define _FUNC_C 2 /* need to add number of arguments */ +#define _LOOP_C 3 +#define _INDIRECT_C 2 +#define _PTR_INIT_C 1 +#define _TEST_C 2 +#define _POWER_C 25 +#define _LOG_C 25 +#define _MISC_C 1 + +#define _ADD_P 1 +#define _ABS_P 1 +#define _MULT_P 1 +#define _MAC_P 1 +#define _MOVE_P 1 +#define _STORE_P 0 +#define _LOGIC_P 1 +#define _SHIFT_P 1 +#define _BRANCH_P 2 +#define _DIV_P 2 +#define _SQRT_P 2 +#define _TRANS_P 2 +#define _FUNC_P 2 /* need to add number of arguments */ +#define _LOOP_P 1 +#define _INDIRECT_P 2 +#define _PTR_INIT_P 1 +#define _TEST_P 1 +#define _POWER_P 2 +#define _LOG_P 2 +#define _MISC_P 1 + +#define ADD( x ) \ + { \ + { \ + ops_cnt += ( _ADD_C * ( x ) ); \ + inst_cnt[_ADD] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _ADD_P * ( x ) ); \ + } \ + } \ + } \ + } +#define ABS( x ) \ + { \ + { \ + ops_cnt += ( _ABS_C * ( x ) ); \ + inst_cnt[_ABS] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _ABS_P * ( x ) ); \ + } \ + } \ + } \ + } +#define MULT( x ) \ + { \ + { \ + ops_cnt += ( _MULT_C * ( x ) ); \ + inst_cnt[_MULT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MULT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define MAC( x ) \ + { \ + { \ + ops_cnt += ( _MAC_C * ( x ) ); \ + inst_cnt[_MAC] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MAC_P * ( x ) ); \ + } \ + } \ + } \ + } +#define MOVE( x ) \ + { \ + { \ + ops_cnt += ( _MOVE_C * ( x ) ); \ + inst_cnt[_MOVE] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MOVE_P * ( x ) ); \ + } \ + } \ + } \ + } +#define STORE( x ) \ + { \ + { \ + ops_cnt += ( _STORE_C * ( x ) ); \ + inst_cnt[_STORE] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _STORE_P * ( x ) ); \ + } \ + } \ + } \ + } +#define LOGIC( x ) \ + { \ + { \ + ops_cnt += ( _LOGIC_C * ( x ) ); \ + inst_cnt[_LOGIC] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _LOGIC_P * ( x ) ); \ + } \ + } \ + } \ + } +#define SHIFT( x ) \ + { \ + { \ + ops_cnt += ( _SHIFT_C * ( x ) ); \ + inst_cnt[_SHIFT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _SHIFT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define BRANCH( x ) \ + { \ + { \ + ops_cnt += ( _BRANCH_C * ( x ) ); \ + inst_cnt[_BRANCH] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _BRANCH_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DIV( x ) \ + { \ + { \ + ops_cnt += ( _DIV_C * ( x ) ); \ + inst_cnt[_DIV] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _DIV_P * ( x ) ); \ + } \ + } \ + } \ + } +#define SQRT( x ) \ + { \ + { \ + ops_cnt += ( _SQRT_C * ( x ) ); \ + inst_cnt[_SQRT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _SQRT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define TRANS( x ) \ + { \ + { \ + ops_cnt += ( _TRANS_C * ( x ) ); \ + inst_cnt[_TRANS] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _TRANS_P * ( x ) ); \ + } \ + } \ + } \ + } +#define LOOP( x ) \ + { \ + { \ + ops_cnt += ( _LOOP_C * ( x ) ); \ + inst_cnt[_LOOP] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _LOOP_P * ( x ) ); \ + } \ + } \ + } \ + } +#define INDIRECT( x ) \ + { \ + { \ + ops_cnt += ( _INDIRECT_C * ( x ) ); \ + inst_cnt[_INDIRECT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _INDIRECT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define PTR_INIT( x ) \ + { \ + { \ + ops_cnt += ( _PTR_INIT_C * ( x ) ); \ + inst_cnt[_PTR_INIT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _PTR_INIT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define TEST( x ) \ + { \ + { \ + ops_cnt += ( _TEST_C * ( x ) ); \ + inst_cnt[_TEST] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _TEST_P * ( x ) ); \ + } \ + } \ + } \ + } +#define POWER( x ) \ + { \ + { \ + ops_cnt += ( _POWER_C * ( x ) ); \ + inst_cnt[_POWER] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _POWER_P * ( x ) ); \ + } \ + } \ + } \ + } +#define LOG( x ) \ + { \ + { \ + ops_cnt += ( _LOG_C * ( x ) ); \ + inst_cnt[_LOG] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _LOG_P * ( x ) ); \ + } \ + } \ + } \ + } +#define MISC( x ) \ + { \ + { \ + ops_cnt += ( _MISC_C * ( x ) ); \ + inst_cnt[_MISC] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MISC_P * ( x ) ); \ + } \ + } \ + } \ + } + +#define FUNC( x ) \ + { \ + { \ + ops_cnt += ( _FUNC_C + _MOVE_C * ( x ) ); \ + inst_cnt[_FUNC]++; \ + inst_cnt[_MOVE] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _FUNC_P + _MOVE_P * ( x ) ); \ + } \ + } \ + } \ + } + +#define DADD( x ) \ + { \ + { \ + ops_cnt += ( 2 * _ADD_C * ( x ) ); \ + inst_cnt[_ADD] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _ADD_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DMULT( x ) \ + { \ + { \ + ops_cnt += ( 2 * _MULT_C * ( x ) ); \ + inst_cnt[_MULT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MULT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DMAC( x ) \ + { \ + { \ + ops_cnt += ( 2 * _MAC_C * ( x ) ); \ + inst_cnt[_MAC] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MAC_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DMOVE( x ) \ + { \ + { \ + ops_cnt += ( 2 * _MOVE_C * ( x ) ); \ + inst_cnt[_MOVE] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MOVE_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DSTORE( x ) \ + { \ + { \ + ops_cnt += ( 2 * _STORE_C * ( x ) ); \ + inst_cnt[_STORE] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _STORE_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DLOGIC( x ) \ + { \ + { \ + ops_cnt += ( 2 * _LOGIC_C * ( x ) ); \ + inst_cnt[_LOGIC] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _LOGIC_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DSHIFT( x ) \ + { \ + { \ + ops_cnt += ( 2 * _SHIFT_C * ( x ) ); \ + inst_cnt[_SHIFT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _SHIFT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DDIV( x ) \ + { \ + { \ + ops_cnt += ( 2 * _DIV_C * ( x ) ); \ + inst_cnt[_DIV] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _DIV_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DSQRT( x ) \ + { \ + { \ + ops_cnt += ( 2 * _SQRT_C * ( x ) ); \ + inst_cnt[_SQRT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _SQRT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DTRANS( x ) \ + { \ + { \ + ops_cnt += ( 2 * _TRANS_C * ( x ) ); \ + inst_cnt[_TRANS] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _TRANS_P * ( x ) ); \ + } \ + } \ + } \ + } + +extern double ops_cnt; +extern double prom_cnt; +extern double inst_cnt[NUM_INST]; +extern int ops_cnt_activ; + +void reset_wmops( void ); +void push_wmops( const char *label ); +void pop_wmops( void ); +void update_wmops( void ); +void update_mem( void ); +void print_wmops( void ); + +#else /* WMOPS counting disabled */ + +#define reset_wmops() +extern int cntr_push_pop; +#define push_wmops( x ) ( cntr_push_pop++ ) +#define pop_wmops() ( cntr_push_pop-- ) +#define update_wmops() ( assert( cntr_push_pop == 0 ) ) +#define update_mem() +#define print_wmops() + +#define ADD( x ) +#define ABS( x ) +#define MULT( x ) +#define MAC( x ) +#define MOVE( x ) +#define STORE( x ) +#define LOGIC( x ) +#define SHIFT( x ) +#define BRANCH( x ) +#define DIV( x ) +#define SQRT( x ) +#define TRANS( x ) +#define FUNC( x ) +#define LOOP( x ) +#define INDIRECT( x ) +#define PTR_INIT( x ) +#define TEST( x ) +#define POWER( x ) +#define LOG( x ) +#define MISC( x ) + +#define DADD( x ) +#define DMULT( x ) +#define DMAC( x ) +#define DMOVE( x ) +#define DSTORE( x ) +#define DLOGIC( x ) +#define DSHIFT( x ) +#define DDIV( x ) +#define DSQRT( x ) +#define DTRANS( x ) + +#endif + +/* mac & msu (Non Instrumented Versions) */ +#ifndef mac +#define mac( a, b, c ) ( ( a ) + ( b ) * ( c ) ) +#endif +#ifndef mac +#define msu( a, b, c ) ( ( a ) - ( b ) * ( c ) ) +#endif + +#ifndef WMOPS +/* DESACTIVATE the Counting Mechanism */ +#define OP_COUNT_( op, n ) + +/* DESACTIVATE Operation Counter Wrappers */ +#define OP_COUNT_WRAPPER1_( op, val ) ( val ) +#define OP_COUNT_WRAPPER2_( expr ) +#define OP_COUNT_WRAPPER3_( op, expr ) expr + +/* DESACTIVATE Logical & Ternary Operators */ +#define __ +#define _ + +#else + +/* '*ops_cnt_ptr' is Used to Avoid: "warning: operation on 'ops_cnt' may be undefined" with Cygwin gcc Compiler */ +static double *ops_cnt_ptr = &ops_cnt; +#define OP_COUNT_( op, x ) ( *ops_cnt_ptr += ( op##_C * ( x ) ), inst_cnt[op] += ( x ) ) + +/******************************************************************/ +/* NOTES: */ +/* The 'wmc_flag_' flag is global to avoid declaration in every */ +/* function and 'static' to avoid clashing with other modules */ +/* that include this header file. */ +/* */ +/* The declarations of 'wmc_flag_' and 'wops_' in this header */ +/* file prevent the addition of a 'C' file to the Project. */ +/******************************************************************/ + +/* General Purpose Global Flag */ +static int wmc_flag_ = 0; + +/* Operation Counter Wrappers */ +#define OP_COUNT_WRAPPER1_( op, val ) ( op, val ) +#define OP_COUNT_WRAPPER2_( expr ) \ + if ( expr, 0 ) \ + ; \ + else +#define OP_COUNT_WRAPPER3_( op, expr ) \ + if ( op, 0 ) \ + ; \ + else \ + expr + +#endif + +/* Define all Macros without '{' & '}' (None of these should be called externally!) */ +#define ABS_( x ) OP_COUNT_( _ABS, ( x ) / WMOPS_BOOST_FAC ) +#define ADD_( x ) OP_COUNT_( _ADD, ( x ) / WMOPS_BOOST_FAC ) +#define MULT_( x ) OP_COUNT_( _MULT, ( x ) / WMOPS_BOOST_FAC ) +#define MAC_( x ) OP_COUNT_( _MAC, ( x ) / WMOPS_BOOST_FAC ) +#define MOVE_( x ) OP_COUNT_( _MOVE, ( x ) / WMOPS_BOOST_FAC ) +#define STORE_( x ) OP_COUNT_( _STORE, ( x ) / WMOPS_BOOST_FAC ) +#define LOGIC_( x ) OP_COUNT_( _LOGIC, ( x ) / WMOPS_BOOST_FAC ) +#define SHIFT_( x ) OP_COUNT_( _SHIFT, ( x ) / WMOPS_BOOST_FAC ) +#define BRANCH_( x ) OP_COUNT_( _BRANCH, ( x ) / WMOPS_BOOST_FAC ) +#define DIV_( x ) OP_COUNT_( _DIV, ( x ) / WMOPS_BOOST_FAC ) +#define SQRT_( x ) OP_COUNT_( _SQRT, ( x ) / WMOPS_BOOST_FAC ) +#define TRANS_( x ) OP_COUNT_( _TRANS, ( x ) / WMOPS_BOOST_FAC ) +#define POWER_( x ) TRANS_( x ) +#define LOG_( x ) TRANS_( x ) +#define LOOP_( x ) OP_COUNT_( _LOOP, ( x ) / WMOPS_BOOST_FAC ) +#define INDIRECT_( x ) OP_COUNT_( _INDIRECT, ( x ) / WMOPS_BOOST_FAC ) +#define PTR_INIT_( x ) OP_COUNT_( _PTR_INIT, ( x ) / WMOPS_BOOST_FAC ) +#define FUNC_( x ) ( OP_COUNT_( _MOVE, ( x ) / WMOPS_BOOST_FAC ), OP_COUNT_( _FUNC, 1 ) ) +#define MISC_( x ) ABS_( x ) + +/* Math Operations */ +#define abs_ OP_COUNT_WRAPPER1_( ABS_( 1 ), abs ) +#define fabs_ OP_COUNT_WRAPPER1_( ABS_( 1 ), fabs ) +#define labs_ OP_COUNT_WRAPPER1_( ABS_( 1 ), labs ) +#define floor_ OP_COUNT_WRAPPER1_( MISC_( 1 ), floor ) +#define sqrt_ OP_COUNT_WRAPPER1_( SQRT_( 1 ), sqrt ) +#define pow_ OP_COUNT_WRAPPER1_( POWER_( 1 ), pow ) +#define exp_ OP_COUNT_WRAPPER1_( POWER_( 1 ), exp ) +#define log_ OP_COUNT_WRAPPER1_( LOG_( 1 ), log ) +#define log10_ OP_COUNT_WRAPPER1_( LOG_( 1 ), log10 ) +#define cos_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), cos ) +#define sin_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), sin ) +#define tan_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), tan ) +#define acos_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), acos ) +#define asin_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), asin ) +#define atan_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), atan ) +#define atan2_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), atan2 ) +#define cosh_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), cosh ) +#define sinh_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), sinh ) +#define tanh_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), tanh ) +#define fmod_ OP_COUNT_WRAPPER1_( DIV_( 1 ), fmod ) +/* these macros use any local macros already defined */ +/* min/max and their Variants */ +#define min_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), min( ( a ), ( b ) ) ) +#define max_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), max( ( a ), ( b ) ) ) +#define MIN_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), MIN( ( a ), ( b ) ) ) +#define MAX_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), MAX( ( a ), ( b ) ) ) +#define Min_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), Min( ( a ), ( b ) ) ) +#define Max_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), Max( ( a ), ( b ) ) ) +/* Square and its Variants */ +#define sqr_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), sqr( ( x ) ) ) +#define Sqr_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), Sqr( ( x ) ) ) +#define SQR_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), SQR( ( x ) ) ) +#define square_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), square( ( x ) ) ) +#define Square_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), Square( ( x ) ) ) +#define SQUARE_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), SQUARE( ( x ) ) ) +/* Sign and its Variants */ +#define sign_( x ) OP_COUNT_WRAPPER1_( MOVE_( 1 ), sign( ( x ) ) ) +#define Sign_( x ) OP_COUNT_WRAPPER1_( MOVE_( 1 ), Sign( ( x ) ) ) +#define SIGN_( x ) OP_COUNT_WRAPPER1_( MOVE_( 1 ), SIGN( ( x ) ) ) +/* Square Root and its Variants */ +#define sqrtf_( x ) OP_COUNT_WRAPPER1_( SQRT_( 1 ), sqrtf( ( x ) ) ) +/* Invert Square Root and its Variants */ +#define inv_sqrt_( x ) OP_COUNT_WRAPPER1_( SQRT_( 1 ), inv_sqrt( ( x ) ) ) +/* Others */ +#define log_base_2_( x ) OP_COUNT_WRAPPER1_( ( LOG_( 1 ), MULT_( 1 ) ), log_base_2( ( x ) ) ) +#define log2_f_( x ) OP_COUNT_WRAPPER1_( ( LOG_( 1 ), MULT_( 1 ) ), log2_f( ( x ) ) ) +/* The 'wmc_flag_=wmc_flag_' is Used to Avoid: "warning: left-hand operand of comma expression has no effect" + with Cygwin gcc Compiler */ +#define _round_( x ) OP_COUNT_WRAPPER1_( wmc_flag_ = wmc_flag_, _round( ( x ) ) ) +#define round_f_( x ) OP_COUNT_WRAPPER1_( wmc_flag_ = wmc_flag_, round_f( ( x ) ) ) +#define _squant_( x ) OP_COUNT_WRAPPER1_( wmc_flag_ = wmc_flag_, _squant( ( x ) ) ) +/* Set Min/Max */ +#define set_min_( a, b ) OP_COUNT_WRAPPER3_( ( ADD_( 1 ), BRANCH_( 1 ), MOVE_( 1 ) ), set_min( ( a ), ( b ) ) ) +#define set_max_( a, b ) OP_COUNT_WRAPPER3_( ( ADD_( 1 ), BRANCH_( 1 ), MOVE_( 1 ) ), set_max( ( a ), ( b ) ) ) +/* mac & msu (Instrumented Versions) */ +#define mac_( a, b, c ) OP_COUNT_WRAPPER1_( MAC_( 1 ), mac( a, b, c ) ) +#define msu_( a, b, c ) OP_COUNT_WRAPPER1_( MAC_( 1 ), msu( a, b, c ) ) + +/* Functions */ +#define func_( name, x ) OP_COUNT_WRAPPER1_( FUNC_( x ), name ) + +/* Logical Operators */ +#ifndef __ +#define __ ( BRANCH_( 1 ), 1 ) && +#endif + +/* Ternary Operators (? and :) */ +#ifndef _ +#define _ ( BRANCH_( 1 ), 0 ) ? 0: +#endif + +/* Flow Control keywords */ +#define if_ \ + OP_COUNT_WRAPPER2_( BRANCH_( 1 ) ) \ + if +#define for_ OP_COUNT_WRAPPER2_( LOOP_(1)) for +#define while_( c ) \ + while \ + OP_COUNT_WRAPPER1_( BRANCH_( 1 ), ( c ) ) /* needs extra "()" if ',' encountered */ +#define do_ \ + do \ + { +#define _while \ + BRANCH_( 1 ); \ + } \ + while + +#define goto_ \ + OP_COUNT_WRAPPER2_( BRANCH_( 1 ) ) \ + goto +#define break_ \ + OP_COUNT_WRAPPER2_( BRANCH_( 1 ) ) \ + break +#define continue_ \ + OP_COUNT_WRAPPER2_( BRANCH_( 1 ) ) \ + continue +#define return_ \ + OP_COUNT_WRAPPER2_( ( wmc_flag_ = stack_tree_level_, STACK_DEPTH_FCT_RETURN ) ) \ + return + +#define switch_ \ + OP_COUNT_WRAPPER2_( ( BRANCH_( 1 ), wmc_flag_ = 1 ) ) \ + switch +#define cost_( n ) OP_COUNT_WRAPPER2_( wmc_flag_ ? ( ADD_( n ), BRANCH_( n ), wmc_flag_ = 0 ) : 0 ); + +#ifdef WMOPS + +#define ACC 2 +#define MUL 1 + +/* Counting Function (should not be called externally!) */ +static void wops_( const char *ops ) +{ + char lm = 0; /* lm: Last Operation is Math */ + static char lo = 0; /* Last Operation */ + + void ( *fct )( const char *ops ) = wops_; + +st: + while ( *ops != '\0' ) + { + switch ( *ops++ ) + { + int cnt; + case '-': + for ( cnt = 0; ops[cnt] == '>'; cnt++ ) + ; + if ( cnt & 1 ) + goto ind; + case '+': + lm = 2; + if ( lo & MUL ) + { + MULT_( -1 ); + MAC_( 1 ); + break; + } + lo = ACC << 2; + case 'U': + case 'D': + ADD_( 1 ); + break; + case '*': + lm = 2; + if ( lo & ACC ) + { + ADD_( -1 ); + MAC_( 1 ); + break; + } + lo = MUL << 2; + MULT_( 1 ); + break; + case '/': + case '%': + lm = 2; + DIV_( 1 ); + break; + case '&': + case '|': + case '^': + lm = 2; + case '~': + LOGIC_( 1 ); + break; + case '<': + case '>': + if ( *ops != ops[-1] ) + goto error; + ops++; + case -85: + case -69: + lm = 2; + SHIFT_( 1 ); + break; + case 'L': + case 'G': + if ( *ops == 't' ) + goto comp; + case 'E': + case 'N': + if ( *ops != 'e' ) + goto error; + comp: + ops++; + ADD_( 1 ); + break; + case '!': + MISC_( 2 ); + break; + case 'M': + MOVE_( 1 ); + break; + case 'S': + STORE_( 1 ); + break; + case 'P': + PTR_INIT_( 1 ); + break; + case '[': + case ']': + goto st; + ind: + ops++; + case 'I': + case '.': + INDIRECT_( 1 ); + break; + case '=': + if ( lm ) + goto st; + case '\0': + /* This Shouldn't Happen */ + /* These are Used to Avoid: "warning: 'name' defined but not used" with Cygwin gcc Compiler */ + wmc_flag_ = wmc_flag_; + ops_cnt_ptr = ops_cnt_ptr; + fct( "" ); + error: + default: + fprintf( stderr, "\r wops: Invalid Counting Operation '%s'\n", ops - 1 ); + exit( -1 ); + } + lm >>= 1; + lo >>= 2; + } + + return; +} + +#endif + +/* All Other Operations */ diff --git a/lib_dec/ivas_corecoder_dec_reconfig.c b/lib_dec/ivas_corecoder_dec_reconfig.c index b56f10d138..4abec8503a 100644 --- a/lib_dec/ivas_corecoder_dec_reconfig.c +++ b/lib_dec/ivas_corecoder_dec_reconfig.c @@ -201,12 +201,10 @@ ivas_error ivas_corecoder_dec_reconfig( } for ( ; cpe_id < st_ivas->nCPE; cpe_id++ ) { -#ifdef FIX_265_MC_BRATE_SWITCHING if ( st_ivas->mc_mode == MC_MODE_MCMASA && st_ivas->hOutSetup.separateChannelEnabled ) { st_ivas->element_mode_init = IVAS_CPE_MDCT; } -#endif if ( ( error = create_cpe_dec( st_ivas, cpe_id, brate_CPE ) ) != IVAS_ERR_OK ) { return error; diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index d8fb4d0272..0d50fb9a91 100755 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -40,9 +40,7 @@ #include "prot.h" #include "ivas_prot.h" #include "ivas_rom_com.h" -#ifdef FIX_265_MC_BRATE_SWITCHING #include "assert.h" -#endif #include "wmc_auto.h" #include @@ -355,9 +353,7 @@ ivas_error stereo_memory_dec( error = IVAS_ERR_OK; -#ifdef FIX_265_MC_BRATE_SWITCHING assert( hCPE->last_element_mode >= IVAS_CPE_DFT && "Switching from SCE to CPE is not a valid configuration!" ); -#endif hCPE->hCoreCoder[0]->element_mode = hCPE->element_mode; diff --git a/lib_enc/ivas_stereo_switching_enc.c b/lib_enc/ivas_stereo_switching_enc.c index 8f39a1f15d..855f851ce8 100644 --- a/lib_enc/ivas_stereo_switching_enc.c +++ b/lib_enc/ivas_stereo_switching_enc.c @@ -37,9 +37,7 @@ #include "prot.h" #include "ivas_prot.h" #include "ivas_rom_com.h" -#ifdef FIX_265_MC_BRATE_SWITCHING #include "assert.h" -#endif #include "wmc_auto.h" #ifdef DEBUGGING #include "debug.h" @@ -233,9 +231,7 @@ ivas_error stereo_memory_enc( error = IVAS_ERR_OK; -#ifdef FIX_265_MC_BRATE_SWITCHING assert( hCPE->last_element_mode >= IVAS_CPE_DFT && "Switching from SCE to CPE is not a valid configuration!" ); -#endif /*--------------------------------------------------------------* * save parameters from structures that will be freed -- GitLab From fb26c3b55dd9443afbd0cf5480fa4c80f3888fe1 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Fri, 13 Jan 2023 13:22:12 +0100 Subject: [PATCH 5/7] [cleanup] accept FIX_265_MC_BRATE_SWITCHING --- lib_com/ivas_tools.c | 74 --- lib_com/options.h | 1 - lib_debug/coan_out_000004 | 924 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 924 insertions(+), 75 deletions(-) create mode 100644 lib_debug/coan_out_000004 diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools.c index 6b35161fd5..bea1b0fb15 100644 --- a/lib_com/ivas_tools.c +++ b/lib_com/ivas_tools.c @@ -1007,7 +1007,6 @@ void lls_interp_n( return; } -#ifdef FIX_ANGLE_WRAPPING /* helper function for panning_wrap_angles */ static float wrap_azi( const float azi_deg ) @@ -1095,79 +1094,6 @@ void panning_wrap_angles( return; } } -#else -/*-------------------------------------------------------------------* - * panning_wrap_angles() - * - * Wrap angles for amplitude panning to the range: - * azimuth = (-180, 180] - * elevation = [-90, 90] - * Considers direction changes from large elevation values - *-------------------------------------------------------------------*/ -void panning_wrap_angles( - const float azi_deg, /* i : azimuth in degrees for panning direction (positive left) */ - const float ele_deg, /* i : elevation in degrees for panning direction (positive up) */ - float *azi_wrapped, /* o : wrapped azimuth component */ - float *ele_wrapped /* o : wrapped elevation component */ -) -{ - float azi, ele; - - azi = azi_deg; - ele = ele_deg; - - /* Special case when elevation is a multiple of 90; azimuth is irrelevant */ - if ( ( ele != 0 ) && ( fmodf( ele, 90 ) == 0 ) ) - { - azi = 0; - while ( fabsf( ele ) > 90 ) - { - ele -= 360; - } - } - else - { - /* Wrap elevation and adjust azimuth accordingly */ - while ( fabsf( ele ) > 90 ) - { - /* Flip to other hemisphere */ - azi += 180; - - /* Compensate elevation accordingly */ - if ( ele > 90 ) - { - ele -= 180; - } - else if ( ele < -90 ) - { - ele += 180; - } - } - - /* Wrap azimuth value */ - while ( fabsf( azi ) > 180 ) - { - azi = fmodf( azi + 180, 360 ); - if ( azi < 0 ) - { - azi += 360; - } - azi -= 180; - } - } - - /* Set -180 to 180 for deduplication purposes; angles are otherwise identical */ - if ( azi == -180 ) - { - azi = 180; - } - - *azi_wrapped = azi; - *ele_wrapped = ele; - - return; -} -#endif /*-------------------------------------------------------------------------* * v_sort_ind() diff --git a/lib_com/options.h b/lib_com/options.h index 28b03667c6..5f0b2b83b2 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -147,7 +147,6 @@ #endif #define FIX_I59_DELAY_ROUNDING /* Issue 59: rounding in sample domain instead of nanosec for IVAS_ENC_GetDelay() and IVAS_DEC_GetDelay() */ #define FIX_FIX_I59 /* Issue 59: small fix concerning LFE delay rounding */ -#define FIX_ANGLE_WRAPPING /* Issue 244: Problems with angle wrapping*/ #define FIX_245_RANGE_CODER_VOIP_MSAN /* Issue 245: fix use-of-uninitialized-value in range coder in VoIP mode */ #define FIX_272_COV /* Issue 272: Cleanup for code coverage related to calls to ivas_binaural_cldfb() */ #define FIX_235 /* Issue 235: Deallocation of HR filter memory separately for lib_rend (ROM) and lib_util (from file) */ diff --git a/lib_debug/coan_out_000004 b/lib_debug/coan_out_000004 new file mode 100644 index 0000000000..bf31e63cef --- /dev/null +++ b/lib_debug/coan_out_000004 @@ -0,0 +1,924 @@ +/* + * (C) 2022 copyright VoiceAge Corporation. All Rights Reserved. + * + * This software is protected by copyright law and by international treaties. The source code, and all of its derivations, + * is provided by VoiceAge Corporation under the "ITU-T Software Tools' General Public License". Please, read the license file + * or refer to ITU-T Recommendation G.191 on "SOFTWARE TOOLS FOR SPEECH AND AUDIO CODING STANDARDS". + * + * Any use of this software is permitted provided that this notice is not removed and that neither the authors nor + * VoiceAge Corporation are deemed to have made any representations as to the suitability of this software + * for any purpose nor are held responsible for any defects of this software. THERE IS NO WARRANTY FOR THIS SOFTWARE. + * + * Authors: Guy Richard, Vladimir Malenovsky (Vladimir.Malenovsky@USherbrooke.ca) + */ + +#ifndef WMOPS_H +#define WMOPS_H + +#ifndef EXIT_FAILURE +#include /* stdlib is needed for exit() */ +#endif + +#ifndef EOF +#include /* stdio is needed for fprintf() */ +#endif + + +/* To Prevent "warning: '$' in identifier or number" message under GCC */ +#ifdef __GNUC__ +#pragma GCC system_header +#endif + +/* Real-time relationships */ +#define FRAMES_PER_SECOND 50.0 +#define MILLION_CYCLES 1e6 +#define WMOPS_BOOST_FAC ( 1.0f ) /* scaling factor for equalizing the difference between automatic and manual instrumentation */ +#define FAC ( FRAMES_PER_SECOND / MILLION_CYCLES * WMOPS_BOOST_FAC ) +#define NUM_INST 20 /* Total number of instruction types (in enum below) */ + + +#ifdef WMOPS +enum instructions +{ + _ADD, + _ABS, + _MULT, + _MAC, + _MOVE, + _STORE, + _LOGIC, + _SHIFT, + _BRANCH, + _DIV, + _SQRT, + _TRANS, + _FUNC, + _LOOP, + _INDIRECT, + _PTR_INIT, + _TEST, + _POWER, + _LOG, + _MISC +}; + +#define _ADD_C 1 +#define _ABS_C 1 +#define _MULT_C 1 +#define _MAC_C 1 +#define _MOVE_C 1 +#define _STORE_C 1 +#define _LOGIC_C 1 +#define _SHIFT_C 1 +#define _BRANCH_C 4 +#define _DIV_C 18 +#define _SQRT_C 10 +#define _TRANS_C 25 +#define _FUNC_C 2 /* need to add number of arguments */ +#define _LOOP_C 3 +#define _INDIRECT_C 2 +#define _PTR_INIT_C 1 +#define _TEST_C 2 +#define _POWER_C 25 +#define _LOG_C 25 +#define _MISC_C 1 + +#define _ADD_P 1 +#define _ABS_P 1 +#define _MULT_P 1 +#define _MAC_P 1 +#define _MOVE_P 1 +#define _STORE_P 0 +#define _LOGIC_P 1 +#define _SHIFT_P 1 +#define _BRANCH_P 2 +#define _DIV_P 2 +#define _SQRT_P 2 +#define _TRANS_P 2 +#define _FUNC_P 2 /* need to add number of arguments */ +#define _LOOP_P 1 +#define _INDIRECT_P 2 +#define _PTR_INIT_P 1 +#define _TEST_P 1 +#define _POWER_P 2 +#define _LOG_P 2 +#define _MISC_P 1 + +#define ADD( x ) \ + { \ + { \ + ops_cnt += ( _ADD_C * ( x ) ); \ + inst_cnt[_ADD] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _ADD_P * ( x ) ); \ + } \ + } \ + } \ + } +#define ABS( x ) \ + { \ + { \ + ops_cnt += ( _ABS_C * ( x ) ); \ + inst_cnt[_ABS] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _ABS_P * ( x ) ); \ + } \ + } \ + } \ + } +#define MULT( x ) \ + { \ + { \ + ops_cnt += ( _MULT_C * ( x ) ); \ + inst_cnt[_MULT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MULT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define MAC( x ) \ + { \ + { \ + ops_cnt += ( _MAC_C * ( x ) ); \ + inst_cnt[_MAC] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MAC_P * ( x ) ); \ + } \ + } \ + } \ + } +#define MOVE( x ) \ + { \ + { \ + ops_cnt += ( _MOVE_C * ( x ) ); \ + inst_cnt[_MOVE] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MOVE_P * ( x ) ); \ + } \ + } \ + } \ + } +#define STORE( x ) \ + { \ + { \ + ops_cnt += ( _STORE_C * ( x ) ); \ + inst_cnt[_STORE] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _STORE_P * ( x ) ); \ + } \ + } \ + } \ + } +#define LOGIC( x ) \ + { \ + { \ + ops_cnt += ( _LOGIC_C * ( x ) ); \ + inst_cnt[_LOGIC] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _LOGIC_P * ( x ) ); \ + } \ + } \ + } \ + } +#define SHIFT( x ) \ + { \ + { \ + ops_cnt += ( _SHIFT_C * ( x ) ); \ + inst_cnt[_SHIFT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _SHIFT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define BRANCH( x ) \ + { \ + { \ + ops_cnt += ( _BRANCH_C * ( x ) ); \ + inst_cnt[_BRANCH] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _BRANCH_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DIV( x ) \ + { \ + { \ + ops_cnt += ( _DIV_C * ( x ) ); \ + inst_cnt[_DIV] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _DIV_P * ( x ) ); \ + } \ + } \ + } \ + } +#define SQRT( x ) \ + { \ + { \ + ops_cnt += ( _SQRT_C * ( x ) ); \ + inst_cnt[_SQRT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _SQRT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define TRANS( x ) \ + { \ + { \ + ops_cnt += ( _TRANS_C * ( x ) ); \ + inst_cnt[_TRANS] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _TRANS_P * ( x ) ); \ + } \ + } \ + } \ + } +#define LOOP( x ) \ + { \ + { \ + ops_cnt += ( _LOOP_C * ( x ) ); \ + inst_cnt[_LOOP] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _LOOP_P * ( x ) ); \ + } \ + } \ + } \ + } +#define INDIRECT( x ) \ + { \ + { \ + ops_cnt += ( _INDIRECT_C * ( x ) ); \ + inst_cnt[_INDIRECT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _INDIRECT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define PTR_INIT( x ) \ + { \ + { \ + ops_cnt += ( _PTR_INIT_C * ( x ) ); \ + inst_cnt[_PTR_INIT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _PTR_INIT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define TEST( x ) \ + { \ + { \ + ops_cnt += ( _TEST_C * ( x ) ); \ + inst_cnt[_TEST] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _TEST_P * ( x ) ); \ + } \ + } \ + } \ + } +#define POWER( x ) \ + { \ + { \ + ops_cnt += ( _POWER_C * ( x ) ); \ + inst_cnt[_POWER] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _POWER_P * ( x ) ); \ + } \ + } \ + } \ + } +#define LOG( x ) \ + { \ + { \ + ops_cnt += ( _LOG_C * ( x ) ); \ + inst_cnt[_LOG] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _LOG_P * ( x ) ); \ + } \ + } \ + } \ + } +#define MISC( x ) \ + { \ + { \ + ops_cnt += ( _MISC_C * ( x ) ); \ + inst_cnt[_MISC] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MISC_P * ( x ) ); \ + } \ + } \ + } \ + } + +#define FUNC( x ) \ + { \ + { \ + ops_cnt += ( _FUNC_C + _MOVE_C * ( x ) ); \ + inst_cnt[_FUNC]++; \ + inst_cnt[_MOVE] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _FUNC_P + _MOVE_P * ( x ) ); \ + } \ + } \ + } \ + } + +#define DADD( x ) \ + { \ + { \ + ops_cnt += ( 2 * _ADD_C * ( x ) ); \ + inst_cnt[_ADD] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _ADD_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DMULT( x ) \ + { \ + { \ + ops_cnt += ( 2 * _MULT_C * ( x ) ); \ + inst_cnt[_MULT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MULT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DMAC( x ) \ + { \ + { \ + ops_cnt += ( 2 * _MAC_C * ( x ) ); \ + inst_cnt[_MAC] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MAC_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DMOVE( x ) \ + { \ + { \ + ops_cnt += ( 2 * _MOVE_C * ( x ) ); \ + inst_cnt[_MOVE] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MOVE_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DSTORE( x ) \ + { \ + { \ + ops_cnt += ( 2 * _STORE_C * ( x ) ); \ + inst_cnt[_STORE] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _STORE_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DLOGIC( x ) \ + { \ + { \ + ops_cnt += ( 2 * _LOGIC_C * ( x ) ); \ + inst_cnt[_LOGIC] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _LOGIC_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DSHIFT( x ) \ + { \ + { \ + ops_cnt += ( 2 * _SHIFT_C * ( x ) ); \ + inst_cnt[_SHIFT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _SHIFT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DDIV( x ) \ + { \ + { \ + ops_cnt += ( 2 * _DIV_C * ( x ) ); \ + inst_cnt[_DIV] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _DIV_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DSQRT( x ) \ + { \ + { \ + ops_cnt += ( 2 * _SQRT_C * ( x ) ); \ + inst_cnt[_SQRT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _SQRT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DTRANS( x ) \ + { \ + { \ + ops_cnt += ( 2 * _TRANS_C * ( x ) ); \ + inst_cnt[_TRANS] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _TRANS_P * ( x ) ); \ + } \ + } \ + } \ + } + +extern double ops_cnt; +extern double prom_cnt; +extern double inst_cnt[NUM_INST]; +extern int ops_cnt_activ; + +void reset_wmops( void ); +void push_wmops( const char *label ); +void pop_wmops( void ); +void update_wmops( void ); +void update_mem( void ); +void print_wmops( void ); + +#else /* WMOPS counting disabled */ + +#define reset_wmops() +extern int cntr_push_pop; +#define push_wmops( x ) ( cntr_push_pop++ ) +#define pop_wmops() ( cntr_push_pop-- ) +#define update_wmops() ( assert( cntr_push_pop == 0 ) ) +#define update_mem() +#define print_wmops() + +#define ADD( x ) +#define ABS( x ) +#define MULT( x ) +#define MAC( x ) +#define MOVE( x ) +#define STORE( x ) +#define LOGIC( x ) +#define SHIFT( x ) +#define BRANCH( x ) +#define DIV( x ) +#define SQRT( x ) +#define TRANS( x ) +#define FUNC( x ) +#define LOOP( x ) +#define INDIRECT( x ) +#define PTR_INIT( x ) +#define TEST( x ) +#define POWER( x ) +#define LOG( x ) +#define MISC( x ) + +#define DADD( x ) +#define DMULT( x ) +#define DMAC( x ) +#define DMOVE( x ) +#define DSTORE( x ) +#define DLOGIC( x ) +#define DSHIFT( x ) +#define DDIV( x ) +#define DSQRT( x ) +#define DTRANS( x ) + +#endif + +/* mac & msu (Non Instrumented Versions) */ +#ifndef mac +#define mac( a, b, c ) ( ( a ) + ( b ) * ( c ) ) +#endif +#ifndef mac +#define msu( a, b, c ) ( ( a ) - ( b ) * ( c ) ) +#endif + +#ifndef WMOPS +/* DESACTIVATE the Counting Mechanism */ +#define OP_COUNT_( op, n ) + +/* DESACTIVATE Operation Counter Wrappers */ +#define OP_COUNT_WRAPPER1_( op, val ) ( val ) +#define OP_COUNT_WRAPPER2_( expr ) +#define OP_COUNT_WRAPPER3_( op, expr ) expr + +/* DESACTIVATE Logical & Ternary Operators */ +#define __ +#define _ + +#else + +/* '*ops_cnt_ptr' is Used to Avoid: "warning: operation on 'ops_cnt' may be undefined" with Cygwin gcc Compiler */ +static double *ops_cnt_ptr = &ops_cnt; +#define OP_COUNT_( op, x ) ( *ops_cnt_ptr += ( op##_C * ( x ) ), inst_cnt[op] += ( x ) ) + +/******************************************************************/ +/* NOTES: */ +/* The 'wmc_flag_' flag is global to avoid declaration in every */ +/* function and 'static' to avoid clashing with other modules */ +/* that include this header file. */ +/* */ +/* The declarations of 'wmc_flag_' and 'wops_' in this header */ +/* file prevent the addition of a 'C' file to the Project. */ +/******************************************************************/ + +/* General Purpose Global Flag */ +static int wmc_flag_ = 0; + +/* Operation Counter Wrappers */ +#define OP_COUNT_WRAPPER1_( op, val ) ( op, val ) +#define OP_COUNT_WRAPPER2_( expr ) \ + if ( expr, 0 ) \ + ; \ + else +#define OP_COUNT_WRAPPER3_( op, expr ) \ + if ( op, 0 ) \ + ; \ + else \ + expr + +#endif + +/* Define all Macros without '{' & '}' (None of these should be called externally!) */ +#define ABS_( x ) OP_COUNT_( _ABS, ( x ) / WMOPS_BOOST_FAC ) +#define ADD_( x ) OP_COUNT_( _ADD, ( x ) / WMOPS_BOOST_FAC ) +#define MULT_( x ) OP_COUNT_( _MULT, ( x ) / WMOPS_BOOST_FAC ) +#define MAC_( x ) OP_COUNT_( _MAC, ( x ) / WMOPS_BOOST_FAC ) +#define MOVE_( x ) OP_COUNT_( _MOVE, ( x ) / WMOPS_BOOST_FAC ) +#define STORE_( x ) OP_COUNT_( _STORE, ( x ) / WMOPS_BOOST_FAC ) +#define LOGIC_( x ) OP_COUNT_( _LOGIC, ( x ) / WMOPS_BOOST_FAC ) +#define SHIFT_( x ) OP_COUNT_( _SHIFT, ( x ) / WMOPS_BOOST_FAC ) +#define BRANCH_( x ) OP_COUNT_( _BRANCH, ( x ) / WMOPS_BOOST_FAC ) +#define DIV_( x ) OP_COUNT_( _DIV, ( x ) / WMOPS_BOOST_FAC ) +#define SQRT_( x ) OP_COUNT_( _SQRT, ( x ) / WMOPS_BOOST_FAC ) +#define TRANS_( x ) OP_COUNT_( _TRANS, ( x ) / WMOPS_BOOST_FAC ) +#define POWER_( x ) TRANS_( x ) +#define LOG_( x ) TRANS_( x ) +#define LOOP_( x ) OP_COUNT_( _LOOP, ( x ) / WMOPS_BOOST_FAC ) +#define INDIRECT_( x ) OP_COUNT_( _INDIRECT, ( x ) / WMOPS_BOOST_FAC ) +#define PTR_INIT_( x ) OP_COUNT_( _PTR_INIT, ( x ) / WMOPS_BOOST_FAC ) +#define FUNC_( x ) ( OP_COUNT_( _MOVE, ( x ) / WMOPS_BOOST_FAC ), OP_COUNT_( _FUNC, 1 ) ) +#define MISC_( x ) ABS_( x ) + +/* Math Operations */ +#define abs_ OP_COUNT_WRAPPER1_( ABS_( 1 ), abs ) +#define fabs_ OP_COUNT_WRAPPER1_( ABS_( 1 ), fabs ) +#define labs_ OP_COUNT_WRAPPER1_( ABS_( 1 ), labs ) +#define floor_ OP_COUNT_WRAPPER1_( MISC_( 1 ), floor ) +#define sqrt_ OP_COUNT_WRAPPER1_( SQRT_( 1 ), sqrt ) +#define pow_ OP_COUNT_WRAPPER1_( POWER_( 1 ), pow ) +#define exp_ OP_COUNT_WRAPPER1_( POWER_( 1 ), exp ) +#define log_ OP_COUNT_WRAPPER1_( LOG_( 1 ), log ) +#define log10_ OP_COUNT_WRAPPER1_( LOG_( 1 ), log10 ) +#define cos_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), cos ) +#define sin_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), sin ) +#define tan_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), tan ) +#define acos_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), acos ) +#define asin_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), asin ) +#define atan_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), atan ) +#define atan2_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), atan2 ) +#define cosh_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), cosh ) +#define sinh_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), sinh ) +#define tanh_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), tanh ) +#define fmod_ OP_COUNT_WRAPPER1_( DIV_( 1 ), fmod ) +/* these macros use any local macros already defined */ +/* min/max and their Variants */ +#define min_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), min( ( a ), ( b ) ) ) +#define max_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), max( ( a ), ( b ) ) ) +#define MIN_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), MIN( ( a ), ( b ) ) ) +#define MAX_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), MAX( ( a ), ( b ) ) ) +#define Min_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), Min( ( a ), ( b ) ) ) +#define Max_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), Max( ( a ), ( b ) ) ) +/* Square and its Variants */ +#define sqr_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), sqr( ( x ) ) ) +#define Sqr_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), Sqr( ( x ) ) ) +#define SQR_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), SQR( ( x ) ) ) +#define square_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), square( ( x ) ) ) +#define Square_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), Square( ( x ) ) ) +#define SQUARE_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), SQUARE( ( x ) ) ) +/* Sign and its Variants */ +#define sign_( x ) OP_COUNT_WRAPPER1_( MOVE_( 1 ), sign( ( x ) ) ) +#define Sign_( x ) OP_COUNT_WRAPPER1_( MOVE_( 1 ), Sign( ( x ) ) ) +#define SIGN_( x ) OP_COUNT_WRAPPER1_( MOVE_( 1 ), SIGN( ( x ) ) ) +/* Square Root and its Variants */ +#define sqrtf_( x ) OP_COUNT_WRAPPER1_( SQRT_( 1 ), sqrtf( ( x ) ) ) +/* Invert Square Root and its Variants */ +#define inv_sqrt_( x ) OP_COUNT_WRAPPER1_( SQRT_( 1 ), inv_sqrt( ( x ) ) ) +/* Others */ +#define log_base_2_( x ) OP_COUNT_WRAPPER1_( ( LOG_( 1 ), MULT_( 1 ) ), log_base_2( ( x ) ) ) +#define log2_f_( x ) OP_COUNT_WRAPPER1_( ( LOG_( 1 ), MULT_( 1 ) ), log2_f( ( x ) ) ) +/* The 'wmc_flag_=wmc_flag_' is Used to Avoid: "warning: left-hand operand of comma expression has no effect" + with Cygwin gcc Compiler */ +#define _round_( x ) OP_COUNT_WRAPPER1_( wmc_flag_ = wmc_flag_, _round( ( x ) ) ) +#define round_f_( x ) OP_COUNT_WRAPPER1_( wmc_flag_ = wmc_flag_, round_f( ( x ) ) ) +#define _squant_( x ) OP_COUNT_WRAPPER1_( wmc_flag_ = wmc_flag_, _squant( ( x ) ) ) +/* Set Min/Max */ +#define set_min_( a, b ) OP_COUNT_WRAPPER3_( ( ADD_( 1 ), BRANCH_( 1 ), MOVE_( 1 ) ), set_min( ( a ), ( b ) ) ) +#define set_max_( a, b ) OP_COUNT_WRAPPER3_( ( ADD_( 1 ), BRANCH_( 1 ), MOVE_( 1 ) ), set_max( ( a ), ( b ) ) ) +/* mac & msu (Instrumented Versions) */ +#define mac_( a, b, c ) OP_COUNT_WRAPPER1_( MAC_( 1 ), mac( a, b, c ) ) +#define msu_( a, b, c ) OP_COUNT_WRAPPER1_( MAC_( 1 ), msu( a, b, c ) ) + +/* Functions */ +#define func_( name, x ) OP_COUNT_WRAPPER1_( FUNC_( x ), name ) + +/* Logical Operators */ +#ifndef __ +#define __ ( BRANCH_( 1 ), 1 ) && +#endif + +/* Ternary Operators (? and :) */ +#ifndef _ +#define _ ( BRANCH_( 1 ), 0 ) ? 0: +#endif + +/* Flow Control keywords */ +#define if_ \ + OP_COUNT_WRAPPER2_( BRANCH_( 1 ) ) \ + if +#define for_ OP_COUNT_WRAPPER2_( LOOP_(1)) for +#define while_( c ) \ + while \ + OP_COUNT_WRAPPER1_( BRANCH_( 1 ), ( c ) ) /* needs extra "()" if ',' encountered */ +#define do_ \ + do \ + { +#define _while \ + BRANCH_( 1 ); \ + } \ + while + +#define goto_ \ + OP_COUNT_WRAPPER2_( BRANCH_( 1 ) ) \ + goto +#define break_ \ + OP_COUNT_WRAPPER2_( BRANCH_( 1 ) ) \ + break +#define continue_ \ + OP_COUNT_WRAPPER2_( BRANCH_( 1 ) ) \ + continue +#define return_ \ + OP_COUNT_WRAPPER2_( ( wmc_flag_ = stack_tree_level_, STACK_DEPTH_FCT_RETURN ) ) \ + return + +#define switch_ \ + OP_COUNT_WRAPPER2_( ( BRANCH_( 1 ), wmc_flag_ = 1 ) ) \ + switch +#define cost_( n ) OP_COUNT_WRAPPER2_( wmc_flag_ ? ( ADD_( n ), BRANCH_( n ), wmc_flag_ = 0 ) : 0 ); + +#ifdef WMOPS + +#define ACC 2 +#define MUL 1 + +/* Counting Function (should not be called externally!) */ +static void wops_( const char *ops ) +{ + char lm = 0; /* lm: Last Operation is Math */ + static char lo = 0; /* Last Operation */ + + void ( *fct )( const char *ops ) = wops_; + +st: + while ( *ops != '\0' ) + { + switch ( *ops++ ) + { + int cnt; + case '-': + for ( cnt = 0; ops[cnt] == '>'; cnt++ ) + ; + if ( cnt & 1 ) + goto ind; + case '+': + lm = 2; + if ( lo & MUL ) + { + MULT_( -1 ); + MAC_( 1 ); + break; + } + lo = ACC << 2; + case 'U': + case 'D': + ADD_( 1 ); + break; + case '*': + lm = 2; + if ( lo & ACC ) + { + ADD_( -1 ); + MAC_( 1 ); + break; + } + lo = MUL << 2; + MULT_( 1 ); + break; + case '/': + case '%': + lm = 2; + DIV_( 1 ); + break; + case '&': + case '|': + case '^': + lm = 2; + case '~': + LOGIC_( 1 ); + break; + case '<': + case '>': + if ( *ops != ops[-1] ) + goto error; + ops++; + case -85: + case -69: + lm = 2; + SHIFT_( 1 ); + break; + case 'L': + case 'G': + if ( *ops == 't' ) + goto comp; + case 'E': + case 'N': + if ( *ops != 'e' ) + goto error; + comp: + ops++; + ADD_( 1 ); + break; + case '!': + MISC_( 2 ); + break; + case 'M': + MOVE_( 1 ); + break; + case 'S': + STORE_( 1 ); + break; + case 'P': + PTR_INIT_( 1 ); + break; + case '[': + case ']': + goto st; + ind: + ops++; + case 'I': + case '.': + INDIRECT_( 1 ); + break; + case '=': + if ( lm ) + goto st; + case '\0': + /* This Shouldn't Happen */ + /* These are Used to Avoid: "warning: 'name' defined but not used" with Cygwin gcc Compiler */ + wmc_flag_ = wmc_flag_; + ops_cnt_ptr = ops_cnt_ptr; + fct( "" ); + error: + default: + fprintf( stderr, "\r wops: Invalid Counting Operation '%s'\n", ops - 1 ); + exit( -1 ); + } + lm >>= 1; + lo >>= 2; + } + + return; +} + +#endif + +/* All Other Operations */ -- GitLab From fbe36a7fcc44a4bebc57ff3d8179c417eb1e48d5 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Fri, 13 Jan 2023 13:23:05 +0100 Subject: [PATCH 6/7] [cleanup] accept FIX_272_COV --- lib_com/options.h | 1 - lib_debug/coan_out_000005 | 924 ++++++++++++++++++++++++++++++++++++++ lib_dec/ivas_dec.c | 7 - 3 files changed, 924 insertions(+), 8 deletions(-) create mode 100644 lib_debug/coan_out_000005 diff --git a/lib_com/options.h b/lib_com/options.h index 5f0b2b83b2..2efbe0375d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -148,7 +148,6 @@ #define FIX_I59_DELAY_ROUNDING /* Issue 59: rounding in sample domain instead of nanosec for IVAS_ENC_GetDelay() and IVAS_DEC_GetDelay() */ #define FIX_FIX_I59 /* Issue 59: small fix concerning LFE delay rounding */ #define FIX_245_RANGE_CODER_VOIP_MSAN /* Issue 245: fix use-of-uninitialized-value in range coder in VoIP mode */ -#define FIX_272_COV /* Issue 272: Cleanup for code coverage related to calls to ivas_binaural_cldfb() */ #define FIX_235 /* Issue 235: Deallocation of HR filter memory separately for lib_rend (ROM) and lib_util (from file) */ /*#define ENV_STAB_FIX*/ /* Contribution 23: HQ envelope stability memory fix */ #define STABILIZE_GIPD /* FhG: Contribution 22: gIPD stabilization */ diff --git a/lib_debug/coan_out_000005 b/lib_debug/coan_out_000005 new file mode 100644 index 0000000000..bf31e63cef --- /dev/null +++ b/lib_debug/coan_out_000005 @@ -0,0 +1,924 @@ +/* + * (C) 2022 copyright VoiceAge Corporation. All Rights Reserved. + * + * This software is protected by copyright law and by international treaties. The source code, and all of its derivations, + * is provided by VoiceAge Corporation under the "ITU-T Software Tools' General Public License". Please, read the license file + * or refer to ITU-T Recommendation G.191 on "SOFTWARE TOOLS FOR SPEECH AND AUDIO CODING STANDARDS". + * + * Any use of this software is permitted provided that this notice is not removed and that neither the authors nor + * VoiceAge Corporation are deemed to have made any representations as to the suitability of this software + * for any purpose nor are held responsible for any defects of this software. THERE IS NO WARRANTY FOR THIS SOFTWARE. + * + * Authors: Guy Richard, Vladimir Malenovsky (Vladimir.Malenovsky@USherbrooke.ca) + */ + +#ifndef WMOPS_H +#define WMOPS_H + +#ifndef EXIT_FAILURE +#include /* stdlib is needed for exit() */ +#endif + +#ifndef EOF +#include /* stdio is needed for fprintf() */ +#endif + + +/* To Prevent "warning: '$' in identifier or number" message under GCC */ +#ifdef __GNUC__ +#pragma GCC system_header +#endif + +/* Real-time relationships */ +#define FRAMES_PER_SECOND 50.0 +#define MILLION_CYCLES 1e6 +#define WMOPS_BOOST_FAC ( 1.0f ) /* scaling factor for equalizing the difference between automatic and manual instrumentation */ +#define FAC ( FRAMES_PER_SECOND / MILLION_CYCLES * WMOPS_BOOST_FAC ) +#define NUM_INST 20 /* Total number of instruction types (in enum below) */ + + +#ifdef WMOPS +enum instructions +{ + _ADD, + _ABS, + _MULT, + _MAC, + _MOVE, + _STORE, + _LOGIC, + _SHIFT, + _BRANCH, + _DIV, + _SQRT, + _TRANS, + _FUNC, + _LOOP, + _INDIRECT, + _PTR_INIT, + _TEST, + _POWER, + _LOG, + _MISC +}; + +#define _ADD_C 1 +#define _ABS_C 1 +#define _MULT_C 1 +#define _MAC_C 1 +#define _MOVE_C 1 +#define _STORE_C 1 +#define _LOGIC_C 1 +#define _SHIFT_C 1 +#define _BRANCH_C 4 +#define _DIV_C 18 +#define _SQRT_C 10 +#define _TRANS_C 25 +#define _FUNC_C 2 /* need to add number of arguments */ +#define _LOOP_C 3 +#define _INDIRECT_C 2 +#define _PTR_INIT_C 1 +#define _TEST_C 2 +#define _POWER_C 25 +#define _LOG_C 25 +#define _MISC_C 1 + +#define _ADD_P 1 +#define _ABS_P 1 +#define _MULT_P 1 +#define _MAC_P 1 +#define _MOVE_P 1 +#define _STORE_P 0 +#define _LOGIC_P 1 +#define _SHIFT_P 1 +#define _BRANCH_P 2 +#define _DIV_P 2 +#define _SQRT_P 2 +#define _TRANS_P 2 +#define _FUNC_P 2 /* need to add number of arguments */ +#define _LOOP_P 1 +#define _INDIRECT_P 2 +#define _PTR_INIT_P 1 +#define _TEST_P 1 +#define _POWER_P 2 +#define _LOG_P 2 +#define _MISC_P 1 + +#define ADD( x ) \ + { \ + { \ + ops_cnt += ( _ADD_C * ( x ) ); \ + inst_cnt[_ADD] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _ADD_P * ( x ) ); \ + } \ + } \ + } \ + } +#define ABS( x ) \ + { \ + { \ + ops_cnt += ( _ABS_C * ( x ) ); \ + inst_cnt[_ABS] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _ABS_P * ( x ) ); \ + } \ + } \ + } \ + } +#define MULT( x ) \ + { \ + { \ + ops_cnt += ( _MULT_C * ( x ) ); \ + inst_cnt[_MULT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MULT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define MAC( x ) \ + { \ + { \ + ops_cnt += ( _MAC_C * ( x ) ); \ + inst_cnt[_MAC] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MAC_P * ( x ) ); \ + } \ + } \ + } \ + } +#define MOVE( x ) \ + { \ + { \ + ops_cnt += ( _MOVE_C * ( x ) ); \ + inst_cnt[_MOVE] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MOVE_P * ( x ) ); \ + } \ + } \ + } \ + } +#define STORE( x ) \ + { \ + { \ + ops_cnt += ( _STORE_C * ( x ) ); \ + inst_cnt[_STORE] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _STORE_P * ( x ) ); \ + } \ + } \ + } \ + } +#define LOGIC( x ) \ + { \ + { \ + ops_cnt += ( _LOGIC_C * ( x ) ); \ + inst_cnt[_LOGIC] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _LOGIC_P * ( x ) ); \ + } \ + } \ + } \ + } +#define SHIFT( x ) \ + { \ + { \ + ops_cnt += ( _SHIFT_C * ( x ) ); \ + inst_cnt[_SHIFT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _SHIFT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define BRANCH( x ) \ + { \ + { \ + ops_cnt += ( _BRANCH_C * ( x ) ); \ + inst_cnt[_BRANCH] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _BRANCH_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DIV( x ) \ + { \ + { \ + ops_cnt += ( _DIV_C * ( x ) ); \ + inst_cnt[_DIV] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _DIV_P * ( x ) ); \ + } \ + } \ + } \ + } +#define SQRT( x ) \ + { \ + { \ + ops_cnt += ( _SQRT_C * ( x ) ); \ + inst_cnt[_SQRT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _SQRT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define TRANS( x ) \ + { \ + { \ + ops_cnt += ( _TRANS_C * ( x ) ); \ + inst_cnt[_TRANS] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _TRANS_P * ( x ) ); \ + } \ + } \ + } \ + } +#define LOOP( x ) \ + { \ + { \ + ops_cnt += ( _LOOP_C * ( x ) ); \ + inst_cnt[_LOOP] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _LOOP_P * ( x ) ); \ + } \ + } \ + } \ + } +#define INDIRECT( x ) \ + { \ + { \ + ops_cnt += ( _INDIRECT_C * ( x ) ); \ + inst_cnt[_INDIRECT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _INDIRECT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define PTR_INIT( x ) \ + { \ + { \ + ops_cnt += ( _PTR_INIT_C * ( x ) ); \ + inst_cnt[_PTR_INIT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _PTR_INIT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define TEST( x ) \ + { \ + { \ + ops_cnt += ( _TEST_C * ( x ) ); \ + inst_cnt[_TEST] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _TEST_P * ( x ) ); \ + } \ + } \ + } \ + } +#define POWER( x ) \ + { \ + { \ + ops_cnt += ( _POWER_C * ( x ) ); \ + inst_cnt[_POWER] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _POWER_P * ( x ) ); \ + } \ + } \ + } \ + } +#define LOG( x ) \ + { \ + { \ + ops_cnt += ( _LOG_C * ( x ) ); \ + inst_cnt[_LOG] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _LOG_P * ( x ) ); \ + } \ + } \ + } \ + } +#define MISC( x ) \ + { \ + { \ + ops_cnt += ( _MISC_C * ( x ) ); \ + inst_cnt[_MISC] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MISC_P * ( x ) ); \ + } \ + } \ + } \ + } + +#define FUNC( x ) \ + { \ + { \ + ops_cnt += ( _FUNC_C + _MOVE_C * ( x ) ); \ + inst_cnt[_FUNC]++; \ + inst_cnt[_MOVE] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _FUNC_P + _MOVE_P * ( x ) ); \ + } \ + } \ + } \ + } + +#define DADD( x ) \ + { \ + { \ + ops_cnt += ( 2 * _ADD_C * ( x ) ); \ + inst_cnt[_ADD] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _ADD_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DMULT( x ) \ + { \ + { \ + ops_cnt += ( 2 * _MULT_C * ( x ) ); \ + inst_cnt[_MULT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MULT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DMAC( x ) \ + { \ + { \ + ops_cnt += ( 2 * _MAC_C * ( x ) ); \ + inst_cnt[_MAC] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MAC_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DMOVE( x ) \ + { \ + { \ + ops_cnt += ( 2 * _MOVE_C * ( x ) ); \ + inst_cnt[_MOVE] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _MOVE_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DSTORE( x ) \ + { \ + { \ + ops_cnt += ( 2 * _STORE_C * ( x ) ); \ + inst_cnt[_STORE] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _STORE_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DLOGIC( x ) \ + { \ + { \ + ops_cnt += ( 2 * _LOGIC_C * ( x ) ); \ + inst_cnt[_LOGIC] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _LOGIC_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DSHIFT( x ) \ + { \ + { \ + ops_cnt += ( 2 * _SHIFT_C * ( x ) ); \ + inst_cnt[_SHIFT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _SHIFT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DDIV( x ) \ + { \ + { \ + ops_cnt += ( 2 * _DIV_C * ( x ) ); \ + inst_cnt[_DIV] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _DIV_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DSQRT( x ) \ + { \ + { \ + ops_cnt += ( 2 * _SQRT_C * ( x ) ); \ + inst_cnt[_SQRT] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _SQRT_P * ( x ) ); \ + } \ + } \ + } \ + } +#define DTRANS( x ) \ + { \ + { \ + ops_cnt += ( 2 * _TRANS_C * ( x ) ); \ + inst_cnt[_TRANS] += ( x ); \ + { \ + static int pcnt; \ + if ( !pcnt ) \ + { \ + pcnt = 1; \ + prom_cnt += ( _TRANS_P * ( x ) ); \ + } \ + } \ + } \ + } + +extern double ops_cnt; +extern double prom_cnt; +extern double inst_cnt[NUM_INST]; +extern int ops_cnt_activ; + +void reset_wmops( void ); +void push_wmops( const char *label ); +void pop_wmops( void ); +void update_wmops( void ); +void update_mem( void ); +void print_wmops( void ); + +#else /* WMOPS counting disabled */ + +#define reset_wmops() +extern int cntr_push_pop; +#define push_wmops( x ) ( cntr_push_pop++ ) +#define pop_wmops() ( cntr_push_pop-- ) +#define update_wmops() ( assert( cntr_push_pop == 0 ) ) +#define update_mem() +#define print_wmops() + +#define ADD( x ) +#define ABS( x ) +#define MULT( x ) +#define MAC( x ) +#define MOVE( x ) +#define STORE( x ) +#define LOGIC( x ) +#define SHIFT( x ) +#define BRANCH( x ) +#define DIV( x ) +#define SQRT( x ) +#define TRANS( x ) +#define FUNC( x ) +#define LOOP( x ) +#define INDIRECT( x ) +#define PTR_INIT( x ) +#define TEST( x ) +#define POWER( x ) +#define LOG( x ) +#define MISC( x ) + +#define DADD( x ) +#define DMULT( x ) +#define DMAC( x ) +#define DMOVE( x ) +#define DSTORE( x ) +#define DLOGIC( x ) +#define DSHIFT( x ) +#define DDIV( x ) +#define DSQRT( x ) +#define DTRANS( x ) + +#endif + +/* mac & msu (Non Instrumented Versions) */ +#ifndef mac +#define mac( a, b, c ) ( ( a ) + ( b ) * ( c ) ) +#endif +#ifndef mac +#define msu( a, b, c ) ( ( a ) - ( b ) * ( c ) ) +#endif + +#ifndef WMOPS +/* DESACTIVATE the Counting Mechanism */ +#define OP_COUNT_( op, n ) + +/* DESACTIVATE Operation Counter Wrappers */ +#define OP_COUNT_WRAPPER1_( op, val ) ( val ) +#define OP_COUNT_WRAPPER2_( expr ) +#define OP_COUNT_WRAPPER3_( op, expr ) expr + +/* DESACTIVATE Logical & Ternary Operators */ +#define __ +#define _ + +#else + +/* '*ops_cnt_ptr' is Used to Avoid: "warning: operation on 'ops_cnt' may be undefined" with Cygwin gcc Compiler */ +static double *ops_cnt_ptr = &ops_cnt; +#define OP_COUNT_( op, x ) ( *ops_cnt_ptr += ( op##_C * ( x ) ), inst_cnt[op] += ( x ) ) + +/******************************************************************/ +/* NOTES: */ +/* The 'wmc_flag_' flag is global to avoid declaration in every */ +/* function and 'static' to avoid clashing with other modules */ +/* that include this header file. */ +/* */ +/* The declarations of 'wmc_flag_' and 'wops_' in this header */ +/* file prevent the addition of a 'C' file to the Project. */ +/******************************************************************/ + +/* General Purpose Global Flag */ +static int wmc_flag_ = 0; + +/* Operation Counter Wrappers */ +#define OP_COUNT_WRAPPER1_( op, val ) ( op, val ) +#define OP_COUNT_WRAPPER2_( expr ) \ + if ( expr, 0 ) \ + ; \ + else +#define OP_COUNT_WRAPPER3_( op, expr ) \ + if ( op, 0 ) \ + ; \ + else \ + expr + +#endif + +/* Define all Macros without '{' & '}' (None of these should be called externally!) */ +#define ABS_( x ) OP_COUNT_( _ABS, ( x ) / WMOPS_BOOST_FAC ) +#define ADD_( x ) OP_COUNT_( _ADD, ( x ) / WMOPS_BOOST_FAC ) +#define MULT_( x ) OP_COUNT_( _MULT, ( x ) / WMOPS_BOOST_FAC ) +#define MAC_( x ) OP_COUNT_( _MAC, ( x ) / WMOPS_BOOST_FAC ) +#define MOVE_( x ) OP_COUNT_( _MOVE, ( x ) / WMOPS_BOOST_FAC ) +#define STORE_( x ) OP_COUNT_( _STORE, ( x ) / WMOPS_BOOST_FAC ) +#define LOGIC_( x ) OP_COUNT_( _LOGIC, ( x ) / WMOPS_BOOST_FAC ) +#define SHIFT_( x ) OP_COUNT_( _SHIFT, ( x ) / WMOPS_BOOST_FAC ) +#define BRANCH_( x ) OP_COUNT_( _BRANCH, ( x ) / WMOPS_BOOST_FAC ) +#define DIV_( x ) OP_COUNT_( _DIV, ( x ) / WMOPS_BOOST_FAC ) +#define SQRT_( x ) OP_COUNT_( _SQRT, ( x ) / WMOPS_BOOST_FAC ) +#define TRANS_( x ) OP_COUNT_( _TRANS, ( x ) / WMOPS_BOOST_FAC ) +#define POWER_( x ) TRANS_( x ) +#define LOG_( x ) TRANS_( x ) +#define LOOP_( x ) OP_COUNT_( _LOOP, ( x ) / WMOPS_BOOST_FAC ) +#define INDIRECT_( x ) OP_COUNT_( _INDIRECT, ( x ) / WMOPS_BOOST_FAC ) +#define PTR_INIT_( x ) OP_COUNT_( _PTR_INIT, ( x ) / WMOPS_BOOST_FAC ) +#define FUNC_( x ) ( OP_COUNT_( _MOVE, ( x ) / WMOPS_BOOST_FAC ), OP_COUNT_( _FUNC, 1 ) ) +#define MISC_( x ) ABS_( x ) + +/* Math Operations */ +#define abs_ OP_COUNT_WRAPPER1_( ABS_( 1 ), abs ) +#define fabs_ OP_COUNT_WRAPPER1_( ABS_( 1 ), fabs ) +#define labs_ OP_COUNT_WRAPPER1_( ABS_( 1 ), labs ) +#define floor_ OP_COUNT_WRAPPER1_( MISC_( 1 ), floor ) +#define sqrt_ OP_COUNT_WRAPPER1_( SQRT_( 1 ), sqrt ) +#define pow_ OP_COUNT_WRAPPER1_( POWER_( 1 ), pow ) +#define exp_ OP_COUNT_WRAPPER1_( POWER_( 1 ), exp ) +#define log_ OP_COUNT_WRAPPER1_( LOG_( 1 ), log ) +#define log10_ OP_COUNT_WRAPPER1_( LOG_( 1 ), log10 ) +#define cos_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), cos ) +#define sin_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), sin ) +#define tan_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), tan ) +#define acos_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), acos ) +#define asin_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), asin ) +#define atan_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), atan ) +#define atan2_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), atan2 ) +#define cosh_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), cosh ) +#define sinh_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), sinh ) +#define tanh_ OP_COUNT_WRAPPER1_( TRANS_( 1 ), tanh ) +#define fmod_ OP_COUNT_WRAPPER1_( DIV_( 1 ), fmod ) +/* these macros use any local macros already defined */ +/* min/max and their Variants */ +#define min_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), min( ( a ), ( b ) ) ) +#define max_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), max( ( a ), ( b ) ) ) +#define MIN_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), MIN( ( a ), ( b ) ) ) +#define MAX_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), MAX( ( a ), ( b ) ) ) +#define Min_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), Min( ( a ), ( b ) ) ) +#define Max_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), Max( ( a ), ( b ) ) ) +/* Square and its Variants */ +#define sqr_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), sqr( ( x ) ) ) +#define Sqr_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), Sqr( ( x ) ) ) +#define SQR_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), SQR( ( x ) ) ) +#define square_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), square( ( x ) ) ) +#define Square_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), Square( ( x ) ) ) +#define SQUARE_( x ) OP_COUNT_WRAPPER1_( MULT_( 1 ), SQUARE( ( x ) ) ) +/* Sign and its Variants */ +#define sign_( x ) OP_COUNT_WRAPPER1_( MOVE_( 1 ), sign( ( x ) ) ) +#define Sign_( x ) OP_COUNT_WRAPPER1_( MOVE_( 1 ), Sign( ( x ) ) ) +#define SIGN_( x ) OP_COUNT_WRAPPER1_( MOVE_( 1 ), SIGN( ( x ) ) ) +/* Square Root and its Variants */ +#define sqrtf_( x ) OP_COUNT_WRAPPER1_( SQRT_( 1 ), sqrtf( ( x ) ) ) +/* Invert Square Root and its Variants */ +#define inv_sqrt_( x ) OP_COUNT_WRAPPER1_( SQRT_( 1 ), inv_sqrt( ( x ) ) ) +/* Others */ +#define log_base_2_( x ) OP_COUNT_WRAPPER1_( ( LOG_( 1 ), MULT_( 1 ) ), log_base_2( ( x ) ) ) +#define log2_f_( x ) OP_COUNT_WRAPPER1_( ( LOG_( 1 ), MULT_( 1 ) ), log2_f( ( x ) ) ) +/* The 'wmc_flag_=wmc_flag_' is Used to Avoid: "warning: left-hand operand of comma expression has no effect" + with Cygwin gcc Compiler */ +#define _round_( x ) OP_COUNT_WRAPPER1_( wmc_flag_ = wmc_flag_, _round( ( x ) ) ) +#define round_f_( x ) OP_COUNT_WRAPPER1_( wmc_flag_ = wmc_flag_, round_f( ( x ) ) ) +#define _squant_( x ) OP_COUNT_WRAPPER1_( wmc_flag_ = wmc_flag_, _squant( ( x ) ) ) +/* Set Min/Max */ +#define set_min_( a, b ) OP_COUNT_WRAPPER3_( ( ADD_( 1 ), BRANCH_( 1 ), MOVE_( 1 ) ), set_min( ( a ), ( b ) ) ) +#define set_max_( a, b ) OP_COUNT_WRAPPER3_( ( ADD_( 1 ), BRANCH_( 1 ), MOVE_( 1 ) ), set_max( ( a ), ( b ) ) ) +/* mac & msu (Instrumented Versions) */ +#define mac_( a, b, c ) OP_COUNT_WRAPPER1_( MAC_( 1 ), mac( a, b, c ) ) +#define msu_( a, b, c ) OP_COUNT_WRAPPER1_( MAC_( 1 ), msu( a, b, c ) ) + +/* Functions */ +#define func_( name, x ) OP_COUNT_WRAPPER1_( FUNC_( x ), name ) + +/* Logical Operators */ +#ifndef __ +#define __ ( BRANCH_( 1 ), 1 ) && +#endif + +/* Ternary Operators (? and :) */ +#ifndef _ +#define _ ( BRANCH_( 1 ), 0 ) ? 0: +#endif + +/* Flow Control keywords */ +#define if_ \ + OP_COUNT_WRAPPER2_( BRANCH_( 1 ) ) \ + if +#define for_ OP_COUNT_WRAPPER2_( LOOP_(1)) for +#define while_( c ) \ + while \ + OP_COUNT_WRAPPER1_( BRANCH_( 1 ), ( c ) ) /* needs extra "()" if ',' encountered */ +#define do_ \ + do \ + { +#define _while \ + BRANCH_( 1 ); \ + } \ + while + +#define goto_ \ + OP_COUNT_WRAPPER2_( BRANCH_( 1 ) ) \ + goto +#define break_ \ + OP_COUNT_WRAPPER2_( BRANCH_( 1 ) ) \ + break +#define continue_ \ + OP_COUNT_WRAPPER2_( BRANCH_( 1 ) ) \ + continue +#define return_ \ + OP_COUNT_WRAPPER2_( ( wmc_flag_ = stack_tree_level_, STACK_DEPTH_FCT_RETURN ) ) \ + return + +#define switch_ \ + OP_COUNT_WRAPPER2_( ( BRANCH_( 1 ), wmc_flag_ = 1 ) ) \ + switch +#define cost_( n ) OP_COUNT_WRAPPER2_( wmc_flag_ ? ( ADD_( n ), BRANCH_( n ), wmc_flag_ = 0 ) : 0 ); + +#ifdef WMOPS + +#define ACC 2 +#define MUL 1 + +/* Counting Function (should not be called externally!) */ +static void wops_( const char *ops ) +{ + char lm = 0; /* lm: Last Operation is Math */ + static char lo = 0; /* Last Operation */ + + void ( *fct )( const char *ops ) = wops_; + +st: + while ( *ops != '\0' ) + { + switch ( *ops++ ) + { + int cnt; + case '-': + for ( cnt = 0; ops[cnt] == '>'; cnt++ ) + ; + if ( cnt & 1 ) + goto ind; + case '+': + lm = 2; + if ( lo & MUL ) + { + MULT_( -1 ); + MAC_( 1 ); + break; + } + lo = ACC << 2; + case 'U': + case 'D': + ADD_( 1 ); + break; + case '*': + lm = 2; + if ( lo & ACC ) + { + ADD_( -1 ); + MAC_( 1 ); + break; + } + lo = MUL << 2; + MULT_( 1 ); + break; + case '/': + case '%': + lm = 2; + DIV_( 1 ); + break; + case '&': + case '|': + case '^': + lm = 2; + case '~': + LOGIC_( 1 ); + break; + case '<': + case '>': + if ( *ops != ops[-1] ) + goto error; + ops++; + case -85: + case -69: + lm = 2; + SHIFT_( 1 ); + break; + case 'L': + case 'G': + if ( *ops == 't' ) + goto comp; + case 'E': + case 'N': + if ( *ops != 'e' ) + goto error; + comp: + ops++; + ADD_( 1 ); + break; + case '!': + MISC_( 2 ); + break; + case 'M': + MOVE_( 1 ); + break; + case 'S': + STORE_( 1 ); + break; + case 'P': + PTR_INIT_( 1 ); + break; + case '[': + case ']': + goto st; + ind: + ops++; + case 'I': + case '.': + INDIRECT_( 1 ); + break; + case '=': + if ( lm ) + goto st; + case '\0': + /* This Shouldn't Happen */ + /* These are Used to Avoid: "warning: 'name' defined but not used" with Cygwin gcc Compiler */ + wmc_flag_ = wmc_flag_; + ops_cnt_ptr = ops_cnt_ptr; + fct( "" ); + error: + default: + fprintf( stderr, "\r wops: Invalid Counting Operation '%s'\n", ops - 1 ); + exit( -1 ); + } + lm >>= 1; + lo >>= 2; + } + + return; +} + +#endif + +/* All Other Operations */ diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 2b5b073142..fa341b093f 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -392,13 +392,6 @@ ivas_error ivas_dec( ivas_crend_process( st_ivas, output ); ivas_binaural_add_LFE( st_ivas, output_frame, output ); } -#ifndef FIX_272_COV - else if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) - { - ivas_binaural_cldfb( st_ivas, output ); - ivas_binaural_add_LFE( st_ivas, output_frame, output ); - } -#endif else if ( st_ivas->renderer_type == RENDERER_MC ) { ivas_ls_setup_conversion( st_ivas, output_frame, output ); -- GitLab From 556206b36e4da11dbe0faec73688b8f7a1246f0a Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Fri, 13 Jan 2023 13:36:31 +0100 Subject: [PATCH 7/7] formatting --- lib_com/bitstream.c | 5 ++--- lib_dec/ivas_stereo_switching_dec.c | 4 ++-- lib_dec/jbm_pcmdsp_apa.c | 9 +++------ lib_dec/jbm_pcmdsp_apa.h | 9 +++------ lib_dec/lib_dec.c | 19 ++++++++----------- lib_enc/ivas_mct_enc.c | 3 +-- lib_util/jbm_file_writer.c | 2 +- 7 files changed, 20 insertions(+), 31 deletions(-) mode change 100755 => 100644 lib_dec/ivas_stereo_switching_dec.c mode change 100755 => 100644 lib_enc/ivas_mct_enc.c diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c index 7fa4791dfa..e9d9cd13c5 100644 --- a/lib_com/bitstream.c +++ b/lib_com/bitstream.c @@ -2178,7 +2178,7 @@ ivas_error read_indices( /* handle bad/lost speech frame(and CS bad SID frame) in the decoders CNG synthesis settings pair (total_brate, bfi) */ if ( ( - bfi != FRAMEMODE_FUTURE && /* TODO(mcjbm): This fixes channel-aware mode BE. Still requires review from a bitstream reading expert */ + bfi != FRAMEMODE_FUTURE && /* TODO(mcjbm): This fixes channel-aware mode BE. Still requires review from a bitstream reading expert */ ( *CNG != 0 ) && ( ( speech_bad != 0 ) || ( speech_lost != 0 ) ) ) || /* SP_BAD or SPEECH_LOST) --> stay in CNG */ ( sid_upd_bad != 0 ) ) /* SID_UPD_BAD --> start CNG */ { @@ -2222,8 +2222,7 @@ ivas_error read_indices( } /* GOOD frame */ - if ( st_ivas->bfi == 0 - || st_ivas->bfi == FRAMEMODE_FUTURE /* TODO(mcjbm): This fixes channel-aware mode BE. Still requires review from a bitstream reading expert */ + if ( st_ivas->bfi == 0 || st_ivas->bfi == FRAMEMODE_FUTURE /* TODO(mcjbm): This fixes channel-aware mode BE. Still requires review from a bitstream reading expert */ ) { /* GOOD frame - convert ITU-T G.192 words to short values */ diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c old mode 100755 new mode 100644 index 0d50fb9a91..73ca81c997 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -343,8 +343,8 @@ ivas_error stereo_memory_dec( const int16_t nb_bits_metadata, /* i : number of metadata bits */ const int32_t output_Fs, /* i : output sampling rate */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const MC_MODE mc_mode, /* i : MC mode */ - const int16_t nchan_transport /* i : number of transport channels*/ + const MC_MODE mc_mode, /* i : MC mode */ + const int16_t nchan_transport /* i : number of transport channels*/ ) { DEC_CORE_HANDLE st; diff --git a/lib_dec/jbm_pcmdsp_apa.c b/lib_dec/jbm_pcmdsp_apa.c index b92fcc1219..9142e347b6 100644 --- a/lib_dec/jbm_pcmdsp_apa.c +++ b/lib_dec/jbm_pcmdsp_apa.c @@ -140,10 +140,8 @@ static bool extend_frm( apa_state_t *ps, const int16_t frm_in[], int16_t frm_out /* Allocates memory for state struct and initializes elements. */ uint8_t apa_init( - apa_state_t **pps - , - int32_t num_channels -) + apa_state_t **pps, + int32_t num_channels ) { apa_state_t *ps = NULL; @@ -205,8 +203,7 @@ void apa_reset( /* Sets the audio configuration. */ bool apa_set_rate( apa_state_t *ps, - const int32_t output_Fs -) + const int32_t output_Fs ) { /* make sure pointer is valid */ if ( ps == NULL ) diff --git a/lib_dec/jbm_pcmdsp_apa.h b/lib_dec/jbm_pcmdsp_apa.h index 9f93307c64..ac54e97e75 100644 --- a/lib_dec/jbm_pcmdsp_apa.h +++ b/lib_dec/jbm_pcmdsp_apa.h @@ -91,10 +91,8 @@ typedef struct apa_state_t *PCMDSP_APA_HANDLE; /*! Allocates memory for state struct and initializes elements. * @return 0 on success, 1 on failure */ -uint8_t apa_init( apa_state_t **s - , - int32_t num_channels -); +uint8_t apa_init( apa_state_t **s, + int32_t num_channels ); /*! Sets state variables to initial value. */ void apa_reset( apa_state_t *s ); @@ -108,8 +106,7 @@ void apa_reset( apa_state_t *s ); * @param[in] output_Fs sample rate [Hz] * @param[in] num_channels number of channels * @return 0 on success, 1 on failure */ -bool apa_set_rate( apa_state_t *ps, const int32_t output_Fs -); +bool apa_set_rate( apa_state_t *ps, const int32_t output_Fs ); /*! Set scaling. * The scale is given in % and will be valid until changed again. diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 7aea25bab8..13a5d96953 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -564,12 +564,9 @@ ivas_error IVAS_DEC_EnableVoIP( return IVAS_ERR_INIT_ERROR; } - if ( apa_init( &hIvasDec->hVoIP->hTimeScaler - , - hDecoderConfig->nchan_out - ) != 0 || - apa_set_rate( hIvasDec->hVoIP->hTimeScaler, hDecoderConfig->output_Fs - ) != 0 || + if ( apa_init( &hIvasDec->hVoIP->hTimeScaler, + hDecoderConfig->nchan_out ) != 0 || + apa_set_rate( hIvasDec->hVoIP->hTimeScaler, hDecoderConfig->output_Fs ) != 0 || apa_set_complexity_options( hIvasDec->hVoIP->hTimeScaler, wss, css ) != 0 || apa_set_quality( hIvasDec->hVoIP->hTimeScaler, 1, 4, 4 ) != 0 || pcmdsp_fifo_create( &hIvasDec->hVoIP->hFifoAfterTimeScaler ) != 0 || @@ -1252,7 +1249,7 @@ ivas_error IVAS_DEC_VoIP_FeedFrame( const uint16_t rtpSequenceNumber, /* i : RTP sequence number (16 bits) */ const uint32_t rtpTimeStamp, /* i : RTP timestamp (32 bits) */ const uint32_t rcvTime_ms, /* i : receive time of the RTP packet in milliseconds */ - const bool qBit /* i : Q bit for AMR-WB IO */ + const bool qBit /* i : Q bit for AMR-WB IO */ ) { JB4_DATAUNIT_HANDLE dataUnit; @@ -1327,9 +1324,9 @@ ivas_error IVAS_DEC_VoIP_FeedFrame( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_VoIP_GetSamples( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - uint16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ - int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + uint16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ + int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ const uint32_t systemTimestamp_ms /* i : current system timestamp */ #ifdef SUPPORT_JBM_TRACEFILE , @@ -1455,7 +1452,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( } assert( nTimeScalerOutSamples <= APA_BUF ); -/* append scaled samples to FIFO */ + /* append scaled samples to FIFO */ if ( pcmdsp_fifo_write( hVoIP->hFifoAfterTimeScaler, (uint8_t *) hVoIP->apaExecBuffer, (uint16_t) ( nTimeScalerOutSamples / hDecoderConfig->nchan_out ) ) != 0 ) { return IVAS_ERR_UNKNOWN; diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c old mode 100755 new mode 100644 index 08d9057403..2595dd847e --- a/lib_enc/ivas_mct_enc.c +++ b/lib_enc/ivas_mct_enc.c @@ -174,8 +174,7 @@ ivas_error ivas_mct_enc( /* joint MCT encoding */ ivas_mct_core_enc( ivas_format, hMCT, st_ivas->hCPE, hMCT->nchan_out_woLFE + hMCT->num_lfe, ivas_total_brate, switch_bw, - ( ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCT ) ? (int16_t) st_ivas->hLFE->lfe_bits : 0 - , + ( ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCT ) ? (int16_t) st_ivas->hLFE->lfe_bits : 0, st_ivas->hEncoderConfig->sba_order ); /* Spectrum quantization and coding */ diff --git a/lib_util/jbm_file_writer.c b/lib_util/jbm_file_writer.c index c0c288c43d..3cbf02eac5 100644 --- a/lib_util/jbm_file_writer.c +++ b/lib_util/jbm_file_writer.c @@ -224,7 +224,7 @@ ivas_error JbmTraceFileWriter_open( /*! r: error code */ ivas_error JbmTraceFileWriter_writeFrame( - const IVAS_JBM_TRACE_DATA *data, /* i : JBM trace data */ + const IVAS_JBM_TRACE_DATA *data, /* i : JBM trace data */ JbmTraceFileWriter *jbmTraceWriter /* o : JbmTraceFileWriter handle */ ) { -- GitLab