Commit 74ed7383 authored by Tapani Pihlajakuja's avatar Tapani Pihlajakuja
Browse files

Merge remote-tracking branch 'origin/main' into 2186_change_object_editing_gain_limitation

parents 9ae4502d f4e8657d
Loading
Loading
Loading
Loading
Loading
+95 −85
Original line number Diff line number Diff line
@@ -48,8 +48,9 @@
#define N40 ( 20 )
#define N60 ( 30 )

static void
cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs );
static Word16 CLDFB_getNumChannels( const Word32 sampleRate );

static void cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs );

#define cplxMpyS( yr, yi, xr, xi, cr, ci, syr, syi, sxr, sxi, CL_x, CL_z, C_c ) \
    CL_x = CL_form( *xr, *xi );                                                 \
@@ -722,7 +723,7 @@ void cldfbSynthesis_fx(
    scaleLB = limitScale32( sub( scale, scaleFactor->lb_scale ) );
    scaleHB = limitScale32( sub( scale, scaleFactor->hb_scale ) );

    outScale = cldfbBank->synFilterHeadroom;
    outScale = SYN_FILTER_HEADROOM_2_5MS;
    move16();

    scaleMod = sub( add( scale, cldfbBank->outScalefactor ), outScale );
@@ -811,7 +812,6 @@ void cldfbSynthesis_fx(
                        &iBuffer[0], &iBuffer[1], &iAnalysisS[0], &iAnalysisS[m - 1], 2, 2, 2, -2,
                        rRotVctr, iRotVctr, m );


        /* FFT of DST IV */
        scale = 0;
        move16();
@@ -909,25 +909,29 @@ void cldfbSynthesis_fx(
    /* move filter states */
    Copy( &cldfbBank->FilterStates[nTimeSlots * L2], cldfbBank->FilterStates, statesSizeM2 );
    set16_fx( &cldfbBank->FilterStates[statesSizeM2], 0, L2 );

    return;
}


/*-------------------------------------------------------------------*
 * configureClfdb()
 * configureCldfb()
 *
 * configures a CLDFB handle
 *--------------------------------------------------------------------*/

void configureCldfb( HANDLE_CLDFB_FILTER_BANK h_cldfb, /*!< Returns handle */
                     const Word16 no_channels,         /*!< Number of channels (bands) */
                     const Word16 frameSize            /*!< FrameSize */
void configureCldfb(
    HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i/o: Returns handle    */
    const Word32 sampling_rate        /* i  : sampling rate     */
)
{
    Word16 no_channels;
    no_channels = CLDFB_getNumChannels( sampling_rate );

    h_cldfb->no_channels = no_channels;
    h_cldfb->no_channels = extract_l( Mpy_32_32_r( sampling_rate, INV_CLDFB_BANDWIDTH_Q31 ) );
    move16();
    assert( h_cldfb->no_channels >= 10 );
    h_cldfb->no_col = div_l( frameSize, shr( h_cldfb->no_channels, 1 ) );
    h_cldfb->no_col = CLDFB_NO_COL_MAX;
    move16();

    /* was cldfbInitFilterBank()*/
@@ -937,8 +941,6 @@ void configureCldfb( HANDLE_CLDFB_FILTER_BANK h_cldfb, /*!< Returns handle */
    move16();
    h_cldfb->bandsToZero = 0;
    move16();
    h_cldfb->filtermode = 0;
    move16();
    h_cldfb->memory = 0;
    move16();
    h_cldfb->memory_length = 0;
@@ -954,14 +956,13 @@ void configureCldfb( HANDLE_CLDFB_FILTER_BANK h_cldfb, /*!< Returns handle */

    h_cldfb->zeros = 0;
    move16();
    h_cldfb->synFilterHeadroom = SYN_FILTER_HEADROOM_2_5MS;
    move16();

    cldfb_init_proto_and_twiddles( h_cldfb );

    /* the following is related to the EVS implentation only */
    h_cldfb->lsb = no_channels;
    move16();
    h_cldfb->usb = s_min( no_channels, h_cldfb->no_channels ); /* Does this make any sense? in the previous implemenatation lsb, usb and no_channels are all maxCldfbBands */
    h_cldfb->usb = s_min( no_channels, h_cldfb->no_channels );
    move16();

    h_cldfb->FilterStates = (void *) h_cldfb->FilterStates;
@@ -971,19 +972,23 @@ void configureCldfb( HANDLE_CLDFB_FILTER_BANK h_cldfb, /*!< Returns handle */
    return;
}


/*-------------------------------------------------------------------*
 * openClfdb()
 *
 * open and configures a CLDFB handle
 *--------------------------------------------------------------------*/

ivas_error openCldfb(
    HANDLE_CLDFB_FILTER_BANK *h_cldfb, /*!< Returns handle */
    const Word16 type,                 /*!< analysis or synthesis */
    const Word16 maxCldfbBands,        /*!< number of cldfb bands */
    const Word16 frameSize             /*!< FrameSize */
    HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: Returns handle           */
    const Word16 type,                 /* i  : analysis or synthesis    */
    const Word32 sampling_rate         /* i  : sampling rate            */
)
{
    HANDLE_CLDFB_FILTER_BANK hs;
    Word16 buf_len, maxCldfbBands;

    maxCldfbBands = CLDFB_getNumChannels( sampling_rate );

    hs = (HANDLE_CLDFB_FILTER_BANK) malloc( sizeof( CLDFB_FILTER_BANK ) );
    IF( hs == NULL )
@@ -994,23 +999,31 @@ ivas_error openCldfb(
    hs->type = type;
    move16();

    configureCldfb( hs, sampling_rate );

    IF( type == CLDFB_ANALYSIS )
    {
        hs->FilterStates = (Word16 *) malloc( STATE_BUFFER_SIZE * maxCldfbBands * sizeof( Word16 ) );
        // buf_len = sub( hs->p_filter_length, hs->no_channels );
        buf_len = STATE_BUFFER_SIZE * maxCldfbBands;
    }
    ELSE
    {
        hs->FilterStates = (Word16 *) malloc( 2 * STATE_BUFFER_SIZE * maxCldfbBands * sizeof( Word16 ) );
        // buf_len = hs->p_filter_length;
        buf_len = 2 * STATE_BUFFER_SIZE * maxCldfbBands;
        move16();
    }
    if ( hs->FilterStates == NULL )

    IF( ( hs->FilterStates = (Word16 *) malloc( buf_len * sizeof( Word16 ) ) ) == NULL )
    {
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" );
    }

    hs->flags = s_and( hs->flags, ~CLDFB_FLAG_KEEP_STATES );
    move16();
    configureCldfb( hs, maxCldfbBands, frameSize );

    hs->memory = NULL;
    hs->memory32 = NULL;
    hs->cldfb_state_fx = NULL;
    hs->memory_length = 0;
    move16();

@@ -1019,7 +1032,7 @@ ivas_error openCldfb(
        test();
        IF( ( s_and( hs->flags, CLDFB_FLAG_KEEP_STATES ) == 0 ) && ( hs->FilterStates != 0 ) )
        {
            set16_fx( hs->FilterStates, 0, i_mult( STATE_BUFFER_SIZE, hs->no_channels ) );
            set16_fx( hs->FilterStates, 0, buf_len );
            set16_fx( hs->FilterStates_e, 0, sizeof( hs->FilterStates_e ) / sizeof( hs->FilterStates_e[0] ) );

            hs->FilterStates_eg = 0;
@@ -1032,7 +1045,7 @@ ivas_error openCldfb(
        {
            IF( s_and( hs->flags, CLDFB_FLAG_KEEP_STATES ) == 0 )
            {
                set16_fx( hs->FilterStates, 0, i_mult( shl( STATE_BUFFER_SIZE, 1 ), hs->no_channels ) );
                set16_fx( hs->FilterStates, 0, buf_len );
            }
        }
        hs->FilterStates_eg = 0;
@@ -1053,8 +1066,10 @@ ivas_error openCldfb(
 *
 * Change sample rate of filter bank
 *--------------------------------------------------------------------*/
void resampleCldfb( HANDLE_CLDFB_FILTER_BANK hs,
                    const Word16 newCldfbBands,

void resampleCldfb(
    HANDLE_CLDFB_FILTER_BANK hs,
    const Word32 sampling_rate, /* i  : sampling rate      */
    const Word16 frameSize,
    const Word8 firstFrame )

@@ -1072,7 +1087,7 @@ void resampleCldfb( HANDLE_CLDFB_FILTER_BANK hs,
    move16();

    /* new settings */
    configureCldfb( hs, newCldfbBands, frameSize );
    configureCldfb( hs, sampling_rate );

    /* resample cldfb state buffer */
    timeOffset = sub( sub( hs->p_filter_length, hs->no_channels ), hs->zeros );
@@ -1104,8 +1119,9 @@ void resampleCldfb( HANDLE_CLDFB_FILTER_BANK hs,
    Returns:
       headroom
*/
Word16
AnalysisPostSpectrumScaling_Fx( HANDLE_CLDFB_FILTER_BANK cldfbBank, /*!< Handle of cldfbBank  */

Word16 AnalysisPostSpectrumScaling_Fx(
    HANDLE_CLDFB_FILTER_BANK cldfbBank, /*!< Handle of cldfbBank  */
    Word32 **rSubband32,                /*!< Real bands Q(cldfbSacle)*/
    Word32 **iSubband32,                /*!< Imaginary bands Q(cldfbSacle)*/
    Word16 **rSubband16,                /*!< Real bands Q(cldfbSacle)*/
@@ -1117,7 +1133,6 @@ AnalysisPostSpectrumScaling_Fx( HANDLE_CLDFB_FILTER_BANK cldfbBank, /*!< Handle
    Word16 j;
    Word16 headRoom;


    headRoom = BASOP_util_norm_l_dim2_cplx(
        (const Word32 *const *) rSubband32,
        (const Word32 *const *) iSubband32,
@@ -1215,7 +1230,9 @@ void analysisCldfbEncoder_fx(
    return;
}

void GetEnergyCldfb( Word32 *energyLookahead,     /*!< o: Q(*sf_energyLookahead) |   pointer to the result in the core look-ahead slot */

void GetEnergyCldfb(
    Word32 *energyLookahead,     /*!< o: Q(*sf_energyLookahead) |   pointer to the result in the core look-ahead slot */
    Word16 *sf_energyLookahead,  /*!< o:         pointer to the scalefactor of the result in the core look-ahead slot  */
    const Word16 numLookahead,   /*!< i: Q0      the number of look-ahead time-slots */
    Word16 **realValues,         /*!< i: Q(sf_Values) |   the real part of the CLDFB subsamples */
@@ -1374,14 +1391,12 @@ void GetEnergyCldfb( Word32 *energyLookahead, /*!< o: Q(*sf_energyLookahead)
}


Word16
CLDFB_getNumChannels( Word32 sampleRate )
static Word16 CLDFB_getNumChannels(
    const Word32 sampleRate )
{

    Word16 nChannels = 0;
    move16();


    SWITCH( sampleRate )
    {
        case 48000:
@@ -1413,13 +1428,15 @@ CLDFB_getNumChannels( Word32 sampleRate )
    return ( nChannels );
}


/*-------------------------------------------------------------------*
 * cldfb_get_memory_length()
 *
 * Return length of filter state for recovery
 *--------------------------------------------------------------------*/
static Word16
cldfb_get_memory_length( HANDLE_CLDFB_FILTER_BANK hs )

static Word16 cldfb_get_memory_length(
    HANDLE_CLDFB_FILTER_BANK hs )
{
    IF( EQ_16( hs->type, CLDFB_ANALYSIS ) )
    {
@@ -1431,39 +1448,21 @@ cldfb_get_memory_length( HANDLE_CLDFB_FILTER_BANK hs )
    }
}

/*-------------------------------------------------------------------*
 * GetEnergyCldfb()
 *
 * Remove handle
 *--------------------------------------------------------------------*/
void deleteCldfb( HANDLE_CLDFB_FILTER_BANK *h_cldfb ) /* i: cldfb handle */
{
    IF( *h_cldfb != NULL )
    {
        IF( ( *h_cldfb )->FilterStates != NULL )
        {
            free( ( *h_cldfb )->FilterStates );
        }
        free( *h_cldfb );
    }
    *h_cldfb = NULL;
}


/*-------------------------------------------------------------------*
 * cldfb_init_proto_and_twiddles()
 *
 * Initializes rom pointer
 *--------------------------------------------------------------------*/
static void
cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs ) /* i: cldfb handle */
{

static void cldfb_init_proto_and_twiddles(
    HANDLE_CLDFB_FILTER_BANK hs /* i: cldfb handle */
)
{
    /*find appropriate set of rotVecs*/
    SWITCH( hs->no_channels )
    {
        case 10:

            hs->rRotVctr = rRotVectr_10;
            hs->iRotVctr = iRotVectr_10;
            hs->synGain = cldfb_synGain[0];
@@ -1571,6 +1570,8 @@ cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs ) /* i: cldfb handle
            }
            BREAK;
    }

    return;
}


@@ -1581,8 +1582,10 @@ cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs ) /* i: cldfb handle
 *
 * Save the memory of filter; to be restored with cldfb_restore_memory()
 *--------------------------------------------------------------------*/
ivas_error
cldfb_save_memory( HANDLE_CLDFB_FILTER_BANK hs ) /* i: cldfb handle */

ivas_error cldfb_save_memory(
    HANDLE_CLDFB_FILTER_BANK hs /* i: cldfb handle */
)
{
    test();
    IF( hs->memory != NULL || hs->memory_length != 0 )
@@ -1603,6 +1606,7 @@ cldfb_save_memory( HANDLE_CLDFB_FILTER_BANK hs ) /* i: cldfb handle */
    {
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB\n" );
    }

    return IVAS_ERR_OK;
}

@@ -1612,12 +1616,14 @@ cldfb_save_memory( HANDLE_CLDFB_FILTER_BANK hs ) /* i: cldfb handle */
 *
 * Restores the memory of filter; memory to be save by cldfb_save_memory()
 *--------------------------------------------------------------------*/
void cldfb_restore_memory( HANDLE_CLDFB_FILTER_BANK hs ) /* i/o: cldfb handle */

void cldfb_restore_memory(
    HANDLE_CLDFB_FILTER_BANK hs /* i/o: cldfb handle */
)

{
    Word16 size;


    size = cldfb_get_memory_length( hs );

    /* read the memory */
@@ -1626,7 +1632,6 @@ void cldfb_restore_memory( HANDLE_CLDFB_FILTER_BANK hs ) /* i/o: cldfb handle */
    hs->FilterStates_eg = hs->memory[hs->memory_length + CLDFB_MEM_EXPONENTS];
    move16();


    /* adjust sample rate if it was changed in the meanwhile */
    IF( NE_16( hs->memory_length, size ) )
    {
@@ -1640,12 +1645,16 @@ void cldfb_restore_memory( HANDLE_CLDFB_FILTER_BANK hs ) /* i/o: cldfb handle */
    return;
}


/*-------------------------------------------------------------------*
 * cldfb_reset_memory()
 *
 * Resets the memory of filter.
 *--------------------------------------------------------------------*/
void cldfb_reset_memory( HANDLE_CLDFB_FILTER_BANK hs ) /* i/o: cldfb handle */

void cldfb_reset_memory(
    HANDLE_CLDFB_FILTER_BANK hs /* i/o: cldfb handle */
)
{
    Word16 length;

@@ -1655,5 +1664,6 @@ void cldfb_reset_memory( HANDLE_CLDFB_FILTER_BANK hs ) /* i/o: cldfb handle */
    set16_fx( hs->FilterStates_e, 0, sizeof( hs->FilterStates_e ) / sizeof( hs->FilterStates_e[0] ) );
    hs->FilterStates_eg = 0;
    move16();

    return;
}
+42 −384

File changed.

Preview size limit exceeded, changes collapsed.

+1 −12
Original line number Diff line number Diff line
@@ -60,15 +60,8 @@ void ivas_masa_dec_close_fx(
    MASA_DECODER_HANDLE *hMasa                                  /* i/o: MASA metadata structure                 */
);

ivas_error create_evs_sce_enc_fx(
    Encoder_Struct *st_ivas,                                    /* i/o: IVAS encoder structure                  */
    const Word16 sce_id,                                        /* i  : SCE # identifier                        */
    const Word32 element_brate                                  /* i  : element bitrate                         */
);

void destroy_sce_enc_fx(
    SCE_ENC_HANDLE hSCE,                                        /* i/o: SCE encoder structure                   */
    Flag is_evs                                                 /* i  : Flag to indicate EVS encoder            */
    SCE_ENC_HANDLE hSCE /* i/o: SCE encoder structure                   */
);

void generate_gridEq_fx(
@@ -800,10 +793,6 @@ void destroy_core_enc_fx(
    ENC_CORE_HANDLE hCoreCoder                                  /* i/o: core encoder structure                  */
);

void destroy_evs_core_enc_fx(
    ENC_CORE_HANDLE hCoreCoder                                  /* i/o: core encoder structure                  */
);

ivas_error ivas_sce_dec_fx(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                  */
    const Word16 sce_id,                                        /* i  : SCE # identifier                        */
+17 −42
Original line number Diff line number Diff line
@@ -4800,21 +4800,19 @@ void cldfbSynthesis_fx(
);
void configureCldfb(
    HANDLE_CLDFB_FILTER_BANK h_cldfb, /*!< CLDFB Handle */
    const Word16 no_channels,         /*!< Number of critically sampled bands */
    const Word16 frameSize            /*!< FrameSize */
    HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i/o: Returns handle    */
    const Word32 sampling_rate        /* i  : sampling rate     */
);
ivas_error openCldfb(
    HANDLE_CLDFB_FILTER_BANK *h_cldfb, /*!< CLDFB Handle */
    const Word16 type,                 /*!< analysis or synthesis */
    const Word16 maxCldfbBands,        /*!< number of cldfb bands */
    const Word16 frameSize             /*!< FrameSize */
    HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: Returns handle           */
    const Word16 type,                 /* i  : analysis or synthesis    */
    const Word32 sampling_rate         /* i  : sampling rate            */
);
void resampleCldfb(
    HANDLE_CLDFB_FILTER_BANK hs, /*!< CLDFB Handle */
    const Word16 newCldfbBands,  /*!< number of cldfb bands */
    const Word32 sampling_rate,  /* i  : sampling rate      */
    const Word16 frameSize,      /*!< FrameSize */
    const Word8 firstFrame );
@@ -4852,9 +4850,6 @@ void GetEnergyCldfb(
    Word16 *energyValuesSum_Exp, /*!< o:         pointer to exponents of energyValuesSum, not initialized */
    TEC_ENC_HANDLE hTECEnc );
Word16 CLDFB_getNumChannels(
    Word32 sampleRate );
void deleteCldfb(
    HANDLE_CLDFB_FILTER_BANK *h_cldfb ); /*!< CLDFB Handle */
@@ -6828,11 +6823,7 @@ void gsc_dec_fx(
    Word16 *exc_wo_nf,         /* o  : excitation (in f domain) without noisefill            Q_exc*/
    Word16 *Q_exc );
void GSC_dec_init(
    GSC_DEC_HANDLE hGSCDec /* i/o: GSC data handle  */
);
void GSC_dec_init_ivas_fx(
void GSC_dec_init_fx(
    GSC_DEC_HANDLE hGSCDec /* i/o: GSC data handle  */
);
@@ -7413,7 +7404,7 @@ ivas_error createFdCngDec_fx(
void initFdCngDec_fx(
    DEC_CORE_HANDLE st, /* i/o: decoder state structure     */
    Word16 scale );
    const Word16 scale );
/* Delete the instance of type FD_CNG */
void deleteFdCngDec_fx(
@@ -7530,11 +7521,6 @@ void generate_masking_noise_mdct_ivas_fx(
    HANDLE_FD_CNG_COM st /* i/o: FD_CNG structure containing all buffers and variables */ );
ivas_error init_decoder_fx(
    Decoder_State *st_fx, /* o:   Decoder static variables structure */
    const Word16 idchan   /* i  : channel ID                          */
);
ivas_error init_decoder_ivas_fx(
    Decoder_State *st_fx, /* o  : Decoder static variables structure  */
    const Word16 idchan,  /* i  : channel ID                          */
    const MC_MODE mc_mode /* i  : MC mode                             */
@@ -9570,7 +9556,7 @@ Word16 deindex_lvq_ivas_fx(
    Word16 no_bits  /* i  : number of bits for lattice                               */
);
void deleteCldfb_ivas_fx(
void deleteCldfb_fx(
    HANDLE_CLDFB_FILTER_BANK *h_cldfb /* i/o: filter bank handle  */
);
@@ -10438,10 +10424,6 @@ ivas_error acelp_core_dec_fx(
    const Word16 read_sid_info           /* i  : read SID info flag                                                      */
);
void destroy_cldfb_decoder_ivas_fx(
    Decoder_State *st /* o  :   Decoder static variables structure */
);
void wtda_fx32(
    const Word32 *new_audio, /* i  : input audio            Q11             */
    Word32 *wtda_audio,      /* o  : windowed audio          Q11            */
@@ -10955,11 +10937,6 @@ ivas_error IGF_Reconfig_fx(
    const Word16 rf_mode              /* i  : flag to signal the RF mode      */
);
void configureCldfb_ivas_enc_fx(
    HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i/o: filter bank handle        */
    const Word32 sampling_rate        /* i  : sampling rate             */
);
void core_switching_post_enc_ivas_fx(
    Encoder_State *st,       /* i/o: encoder state structure             */
    Word16 *old_inp_12k8_fx, /* i  : old input signal @12.8kHz           */
@@ -11250,12 +11227,10 @@ void read_next_force(
);
#endif
ivas_error init_encoder_ivas_fx(
ivas_error init_encoder_fx(
    Encoder_State *st,          /* i/o: state structure                      */
    Encoder_Struct *st_ivas,    /* i/o: encoder state structure              */
    const Word16 idchan,        /* i  : channel ID                           */
    const Word16 var_SID_rate_flag, /* i  : flag for variable SID update rate    */
    const Word16 interval_SID,      /* i  : interval for SID update              */
    const Word16 vad_only_flag, /* i  : flag to indicate front-VAD structure */
    const ISM_MODE ism_mode,    /* i  : ISM mode                             */
    const Word32 element_brate  /* i  : element bitrate                      */
+1 −1
Original line number Diff line number Diff line
@@ -1133,7 +1133,7 @@ extern const Word16 cldfb_synGain[]; // Q0
extern const Word16 *cldfb_protoFilter_2_5ms[];
// extern const Word16 *cldfb_protoFilter_5_0ms[];
extern const Word16 cldfb_scale_2_5ms[7]; // Q8
extern const Word16 cldfb_scale_5_0ms[7]; // Q8


extern const Word32 rot_vec_syn_re_L10_fx[5];  // Q31
extern const Word32 rot_vec_syn_im_L10_fx[5];  // Q31
Loading