Commit 36ee1af7 authored by vaclav's avatar vaclav
Browse files

Merge branch 'main' into my_development

parents f582b623 7bb94b29
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -120,7 +120,11 @@ typedef struct
    const char *ca_config_file;
    bool mimeOutput;

#ifdef AGC_ENABLE_FOR_LBR
    IVAS_ENC_AGC agc;
#else
    bool agc;
#endif
    bool pca;
#ifdef DEBUG_FOA_AGC
    FILE *agcBitstream; /* temporary */
@@ -870,7 +874,11 @@ static void initArgStruct( EncArguments *arg )
    arg->ca_config_file = NULL;
    arg->mimeOutput = false;

#ifdef AGC_ENABLE_FOR_LBR
    arg->agc = IVAS_ENC_AGC_UNDEFINED;
#else
    arg->agc = IVAS_DEFAULT_AGC;
#endif
    arg->pca = false;
#ifdef DEBUG_FOA_AGC
    arg->agcBitstream = NULL;
@@ -1381,7 +1389,11 @@ static bool parseCmdlIVAS_enc(
            i++;
            if ( i < argc - 4 )
            {
#ifdef AGC_ENABLE_FOR_LBR
                arg->agc = ( atoi( argv[i] ) ) ? IVAS_ENC_AGC_ENABLED : IVAS_ENC_AGC_DISABLED;
#else
                arg->agc = (int16_t) atoi( argv[i] );
#endif
                if ( argv[i] == NULL || atoi( argv[i] ) < 0 || atoi( argv[i] ) > 1 )
                {
                    fprintf( stderr, "Error: wrong adaptive gain control option specified (%d), expected 0 or 1\n\n", (int32_t) atoi( argv[i] ) );
@@ -1636,7 +1648,14 @@ static void usage_enc( void )
#ifdef DEBUG_SBA
    fprintf( stdout, "-tag                : Tag name for intermediate debug files\n" );
#endif
#ifdef AGC_ENABLE_FOR_LBR
    fprintf( stdout, "-agc op             : SBA Adaptive gain control, op = (0, 1).  \n" );
    fprintf( stdout, "                      By default op is 1 (activated) for bitrates between 24400 and 32000,\n" );
    fprintf( stdout, "                      otherwise it is 0 (deactivated) for all other bitrates\n" );
#else
    fprintf( stdout, "-agc op             : SBA Adaptive gain control, op = (0, 1), by default op is 0 or deactivated\n" );
#endif

    fprintf( stdout, "-bypass mode        : SBA PCA by-pass, mode = (1, 2), 1 = PCA off, 2 = signal adaptive, default is 1\n" );
#ifdef DEBUGGING
    fprintf( stdout, "-force T            : Force specific mode, T = (speech, music, ACELP, GSC, TCX, HQ),\n" );
+0 −8
Original line number Diff line number Diff line
@@ -90,18 +90,10 @@ void fill_spectrum(
    const int16_t element_mode         /* i  : element mode                                          */
)
{
#ifdef FIX_I178_HQ_BUFFER_OVERRUN
    float CodeBook[L_SPEC48k_EXT];
#else
    float CodeBook[FREQ_LENGTH];
#endif
    int16_t cb_size = 0;
    int16_t last_sfm;
#ifdef FIX_I178_HQ_BUFFER_OVERRUN
    float CodeBook_mod[L_SPEC48k_EXT];
#else
    float CodeBook_mod[FREQ_LENGTH];
#endif
    float norm_adj[NB_SFM];
    int16_t high_sfm = 23;
    int16_t flag_32K_env_hangover;
+29 −0
Original line number Diff line number Diff line
@@ -40,6 +40,9 @@
#endif
#include <math.h>
#include "wmops.h"
#ifdef AGC_TUNING_IMPROVEMENT
#include "prot.h"
#endif

/*------------------------------------------------------------------------------------------*
 * Local constants
@@ -47,6 +50,11 @@

#define SQRKMAX     ( 1.5f )
#define NBITS_DIFFG ( 2 )
#ifdef AGC_TUNING_IMPROVEMENT
#define DBSTEP       ( -6.f ) /* desired dB step value in dB*/
#define ABS_EMIN_MAX ( 3 )
#define MAXATTEXP    ( 1 ) /* the desired maximum attenuation exponent range per frame*/
#endif

/*-----------------------------------------------------------------------------------------*
 * Function ivas_agc_initWindowFunc()
@@ -60,12 +68,22 @@ void ivas_agc_initWindowFunc(
{
    int16_t i;
    float N;
#ifdef AGC_TUNING_IMPROVEMENT
    float a;
#endif

    N = (float) ( length - 1 );
#ifdef AGC_TUNING_IMPROVEMENT
    a = 0.5f * ( 1.f - powf( 10.f, DBSTEP / 20.f ) );
#endif

    for ( i = 0; i < length; i++ )
    {
#ifdef AGC_TUNING_IMPROVEMENT
        pWinFunc[i] = 1.f + a * ( cosf( EVS_PI * i / N ) - 1.f );
#else
        pWinFunc[i] = 0.75f + 0.25f * cosf( EVS_PI * i / N );
#endif
    }

    return;
@@ -89,7 +107,11 @@ void ivas_agc_calcGainParams(

    nbits = NBITS_DIFFG;

#ifdef AGC_TUNING_IMPROVEMENT
    *absEmin = max( ABS_EMIN_MAX, (uint16_t) ceilf( logf( ceilf( SQRKMAX * numCoeffs ) ) * INV_LOG_2 ) );
#else
    *absEmin = (uint16_t) ceilf( logf( ceilf( SQRKMAX * numCoeffs ) ) * INV_LOG_2 );
#endif

    totExp = *absEmin + AGC_EMAX + 1;
    *betaE = (uint16_t) ceilf( logf( totExp ) * INV_LOG_2 );
@@ -98,10 +120,17 @@ void ivas_agc_calcGainParams(

    if ( nbits > 0 )
    {
#ifdef AGC_TUNING_IMPROVEMENT
        Bm = min( AGC_BITS_PER_CH - 1, NBITS_DIFFG );
#else
        Bm = NBITS_DIFFG;
#endif
    }

    *maxAttExp = ( (uint16_t) powf( 2, Bm ) ) - 2;
#ifdef AGC_TUNING_IMPROVEMENT
    *maxAttExp = min( MAXATTEXP, *maxAttExp );
#endif

    return;
}
+0 −4
Original line number Diff line number Diff line
@@ -1321,11 +1321,7 @@ typedef enum
#define PANNING_ELE_RESOLUTION                  5

#define EFAP_MAX_CHAN_NUM                       5                           /* Maximum number of channels that constitute a polygon, 4 or 5 */
#ifdef ALLRAD_OPTIM
#define EFAP_MAX_POLY_SET                       50                          /* Upper bound on number of polygons; with a Speaker setup of 16.0, we obtain 44 polygons/triangles in the matlab implementation. */
#else
#define EFAP_MAX_POLY_SET                       70                          /* Upper bound on number of polygons; with a Speaker setup of 26.0, we obtain 54 polygons/triangles in the matlab implementation. */
#endif

#define EFAP_MODE_EFAP                          0                           /* EFAP Panning */
#define EFAP_MODE_EFIP                          1                           /* EFIP Panning */
+4 −37
Original line number Diff line number Diff line
@@ -169,36 +169,22 @@ void ivas_spar_covar_smooth_enc_close(

static void ivas_compute_smooth_cov(
    ivas_cov_smooth_state_t *hCovState,
#ifndef SBA_SPAR_HARM
    ivas_cov_smooth_in_buf_t *pIn_buf,
#endif
    ivas_filterbank_t *pFb,
    float *pCov_buf[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH],
    float *pPrior_cov_buf[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH],
    const float fac,
    const int16_t start_band,
    const int16_t end_band
#ifdef SBA_SPAR_HARM
    ,
    const int16_t end_band,
    const int16_t num_ch,
    const int16_t transient_det
#endif
)
    const int16_t transient_det )
{
    int16_t i, j, k;
    int16_t prev_idx = hCovState->prior_bank_idx;
#ifndef SBA_SPAR_HARM
    int16_t num_ch = pIn_buf->num_ch;
#endif
    float factor = 0;

    assert( end_band <= pFb->filterbank_num_bands );

#ifdef SBA_SPAR_HARM
    if ( prev_idx == -1 || transient_det == 1 )
#else
    if ( prev_idx == -1 || pIn_buf->reset_cov == 1 )
#endif
    {
        for ( i = 0; i < num_ch; i++ )
        {
@@ -243,42 +229,23 @@ static void ivas_compute_smooth_cov(

void ivas_cov_smooth_process(
    ivas_cov_smooth_state_t *hCovState, /* i/o: Covariance state handle */
#ifdef SBA_SPAR_HARM
    float *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH],
#else
    ivas_cov_smooth_in_buf_t *pIn_buf,
#endif
    ivas_filterbank_t *pFb, /* i/o: FB handle               */
    const int16_t start_band,
    const int16_t end_band
#ifdef SBA_SPAR_HARM
    ,
    const int16_t end_band,
    const int16_t num_ch,
    const int16_t transient_det
#endif
)
    const int16_t transient_det )
{
    int16_t i, j;
#ifndef SBA_SPAR_HARM
    int16_t num_ch = pIn_buf->num_ch;
#endif
    int16_t num_bands = end_band - start_band;

#ifdef SBA_SPAR_HARM
    ivas_compute_smooth_cov( hCovState, pFb, cov_real, hCovState->pPrior_cov_real, 1e-20f, start_band, end_band, num_ch, transient_det );
#else
    ivas_compute_smooth_cov( hCovState, pIn_buf, pFb, pIn_buf->cov_real, hCovState->pPrior_cov_real, 1e-20f, start_band, end_band );
#endif

    for ( i = 0; i < num_ch; i++ )
    {
        for ( j = 0; j < num_ch; j++ )
        {
#ifdef SBA_SPAR_HARM
            mvr2r( &cov_real[i][j][start_band], &hCovState->pPrior_cov_real[i][j][start_band], num_bands );
#else
            mvr2r( &pIn_buf->cov_real[i][j][start_band], &hCovState->pPrior_cov_real[i][j][start_band], num_bands );
#endif
        }
    }

Loading