Commit 81460fd9 authored by bayers's avatar bayers
Browse files

Merge branch...

Merge branch '572-mc-parammc-mcmasa-lfe-channel-is-not-low-pass-filtered-before-encoding' into 'main'

[Non-BE] Resolve "MC (ParamMC, McMASA): LFE channel is not low pass filtered before encoding"

See merge request !778
parents 8f037b8c 611fcb44
Loading
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -5447,6 +5447,26 @@ void ivas_lfe_synth_with_filters(
    const int16_t lfeChannelIndex                               /* i  : LFE channel index                               */
);

#ifdef FIX_572_LFE_LPF_ENC
/*----------------------------------------------------------------------------------*
 * LFE encoder low pass filter prototypes
 *----------------------------------------------------------------------------------*/

ivas_error ivas_create_lfe_lpf_enc(
    ivas_filters_process_state_t **ph_lfe_lpf_filter_state, /* o  : IVAS LFE encoder structure   */
    const int32_t input_Fs                                  /* i  : input sampling rate          */
);

void ivas_lfe_lpf_enc_close(
    ivas_filters_process_state_t **ph_lfe_lpf_filter_state /* i/o: LFE encoder handle */
);

void ivas_lfe_lpf_enc_apply(
    ivas_filters_process_state_t *h_lfe_lpf_filter_state, /* i/o: LFE encoder handle */
    float data_lfe_ch[],       /* i  : input LFE signal                         */
    const int16_t input_frame  /* i  : input frame length per channel           */
);
#endif

/*----------------------------------------------------------------------------------*
 * LFE Coding prototypes

lib_com/options.h

100644 → 100755
+1 −0
Original line number Diff line number Diff line
@@ -152,6 +152,7 @@
#define FIX_565_SBA_BURST_IN_FEC                        /* VA: Issue 565: Fix noise burst during FEC, due to wrong total_brate initialization */
#define FIX_562_ISM2_64KBPS                             /* VA: issue 562: fix ISM2 at 64kbps issue */
#define FIX_559_EXTL_IGF_MISMATCH                       /* VA: issue 559: fix mismatch between st->extl and st->igf observed as crash in PlanarSBA bitrate switching */
#define FIX_572_LFE_LPF_ENC                             /* FhG: issue 572: always apply the low pass filter to the LFE channel */

#define FIX_QMETA_SID_5k2                               /* Nokia: Issue 137: enable using full 5.2k bitrate in MASA SID */

+5 −0
Original line number Diff line number Diff line
@@ -276,6 +276,11 @@ ivas_error ivas_enc(

        hMetaData = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData : st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData;

#ifdef FIX_572_LFE_LPF_ENC
        /* LFE low pass filter */
        ivas_lfe_lpf_enc_apply( st_ivas->lfe_lpf_state, data_f[LFE_CHANNEL], input_frame );
#endif

        /* LFE channel encoder */
        if ( st_ivas->mc_mode == MC_MODE_MCT )
        {
+14 −0
Original line number Diff line number Diff line
@@ -314,6 +314,11 @@ void ivas_initialize_handles_enc(
    /* LFE  handle */
    st_ivas->hLFE = NULL;

#ifdef FIX_572_LFE_LPF_ENC
    /* LFE low pass filter state */
    st_ivas->lfe_lpf_state = NULL;
#endif

    return;
}

@@ -543,6 +548,10 @@ ivas_error ivas_init_encoder(

        hEncoderConfig->nchan_inp = ivas_mc_ls_setup_get_num_channels( hEncoderConfig->mc_input_setup );

#ifdef FIX_572_LFE_LPF_ENC
        ivas_create_lfe_lpf_enc( &st_ivas->lfe_lpf_state, hEncoderConfig->input_Fs );
#endif

        if ( st_ivas->mc_mode == MC_MODE_MCT )
        {
            st_ivas->nSCE = 0;
@@ -944,6 +953,11 @@ void ivas_destroy_enc(
    /* LFE handle */
    ivas_lfe_enc_close( &( st_ivas->hLFE ) );

#ifdef FIX_572_LFE_LPF_ENC
    /* LFE low pass filter state */
    ivas_lfe_lpf_enc_close( &( st_ivas->lfe_lpf_state ) );
#endif

    /* Param-Upmix MC handle */
    ivas_mc_paramupmix_enc_close( &( st_ivas->hMCParamUpmix ), st_ivas->hEncoderConfig->input_Fs );

+79 −1
Original line number Diff line number Diff line
@@ -344,9 +344,10 @@ void ivas_lfe_enc(
    zero_pad_len = hLFE->pWindow_state->zero_pad_len;
    pWindow_coeffs = hLFE->pWindow_state->pWindow_coeffs;

#ifndef FIX_572_LFE_LPF_ENC
    /*Low Pass Filter */
    ivas_filter_process( &hLFE->filter_state, data_lfe_ch, input_frame );

#endif
    /* Windowing */
    ivas_dct_windowing( fade_len, full_len, dct_len, zero_pad_len, pWindow_coeffs, input_frame, wtda_audio, hLFE->old_wtda_audio, data_lfe_ch );

@@ -381,7 +382,9 @@ ivas_error ivas_create_lfe_enc(
{
    int16_t input_frame;
    LFE_ENC_HANDLE hLFE;
#ifndef FIX_572_LFE_LPF_ENC
    const float *filt_coeff;
#endif
    int16_t i, j;

    input_frame = (int16_t) ( input_Fs / FRAMES_PER_SEC );
@@ -423,8 +426,10 @@ ivas_error ivas_create_lfe_enc(

    lfe_window_init( hLFE->pWindow_state, input_Fs, input_frame );

#ifndef FIX_572_LFE_LPF_ENC
    ivas_lfe_lpf_select_filt_coeff( input_Fs, IVAS_FILTER_ORDER_4, &filt_coeff );
    ivas_filters_init( &hLFE->filter_state, filt_coeff, IVAS_FILTER_ORDER_4 );
#endif

    /* Initialization for entropy coding */
    hLFE->cum_freq_models[0][0] = ivas_str_lfe_freq_models.entropy_coder_model_fine_sg1;
@@ -483,3 +488,76 @@ void ivas_lfe_enc_close(

    return;
}

#ifdef FIX_572_LFE_LPF_ENC
/*-------------------------------------------------------------------------
 * ivas_create_lfe_lpf_enc()
 *
 * Create, allocate and initialize IVAS encoder LFE low pass filter state handle
 *-------------------------------------------------------------------------*/

ivas_error ivas_create_lfe_lpf_enc(
    ivas_filters_process_state_t **ph_lfe_lpf_filter_state, /* o  : IVAS LFE encoder structure   */
    const int32_t input_Fs                                  /* i  : input sampling rate          */
)
{
    const float *filt_coeff;

    if ( ph_lfe_lpf_filter_state == NULL )
    {
        return ( IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "Can not allocate memory for LFE LPF\n" ) );
    }

    /*-----------------------------------------------------------------*
     * Allocate LFE LPF handle
     *-----------------------------------------------------------------*/

    if ( ( *ph_lfe_lpf_filter_state = (ivas_filters_process_state_t *) malloc( sizeof( ivas_filters_process_state_t ) ) ) == NULL )
    {
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LFE LPF\n" ) );
    }


    ivas_lfe_lpf_select_filt_coeff( input_Fs, IVAS_FILTER_ORDER_4, &filt_coeff );
    ivas_filters_init( *ph_lfe_lpf_filter_state, filt_coeff, IVAS_FILTER_ORDER_4 );

    return IVAS_ERR_OK;
}


/*-------------------------------------------------------------------------
 * ivas_lfe_lpf_enc_close()
 *
 * Destroy IVAS cncoder LFE low pass filter state
 *-------------------------------------------------------------------------*/

void ivas_lfe_lpf_enc_close(
    ivas_filters_process_state_t **ph_lfe_lpf_filter_state /* i/o: LFE encoder handle */
)
{
    if ( ph_lfe_lpf_filter_state == NULL || *ph_lfe_lpf_filter_state == NULL )
    {
        return;
    }

    free( ( *ph_lfe_lpf_filter_state ) );
    ( *ph_lfe_lpf_filter_state ) = NULL;
    return;
}

/*-------------------------------------------------------------------------
 * ivas_lfe_lpf_enc_apply()
 *
 * Apply IVAS cncoder LFE low pass filter
 *-------------------------------------------------------------------------*/

void ivas_lfe_lpf_enc_apply(
    ivas_filters_process_state_t *h_lfe_lpf_filter_state, /* i/o: LFE encoder handle */
    float data_lfe_ch[],                                  /* i  : input LFE signal                         */
    const int16_t input_frame                             /* i  : input frame length per channel           */
)
{

    ivas_filter_process( h_lfe_lpf_filter_state, data_lfe_ch, input_frame );
}
#endif
Loading