Loading lib_dec/ivas_cpe_dec.c +52 −26 Original line number Diff line number Diff line Loading @@ -52,6 +52,10 @@ static void read_stereo_mode_and_bwidth( CPE_DEC_HANDLE hCPE, const Decoder_Struct *st_ivas ); #ifdef FIX_OMASA_STEREO_SWITCHING static void stereo_mode_combined_format_dec( const Decoder_Struct *st_ivas, CPE_DEC_HANDLE hCPE ); #endif /*--------------------------------------------------------------------------* * ivas_cpe_dec() Loading Loading @@ -98,9 +102,6 @@ ivas_error ivas_cpe_dec( sts[0]->BER_detect |= st_ivas->BER_detect; sts[1]->BER_detect |= st_ivas->BER_detect; #ifdef FIX_OMASA_STEREO_SWITCHING element_brate_ref = hCPE->element_brate; #endif #ifdef FIX_OMASA_STEREO_SWITCHING element_brate_ref = hCPE->element_brate; Loading @@ -109,31 +110,11 @@ ivas_error ivas_cpe_dec( /*------------------------------------------------------------------* * Read stereo technology info & audio bandwidth *-----------------------------------------------------------------*/ #ifdef FIX_OMASA_STEREO_SWITCHING if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) { if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && ( ( st_ivas->nchan_ism == 3 && ivas_total_brate == IVAS_96k ) || ( st_ivas->nchan_ism == 4 && ivas_total_brate == IVAS_128k ) ) ) { /* read OMASA stereo mode signalling */ if ( get_next_indice( sts[0], NBITS_ELEMENT_MODE ) ) { hCPE->element_mode = IVAS_CPE_MDCT; } else { hCPE->element_mode = IVAS_CPE_DFT; } if ( hCPE->element_mode == IVAS_CPE_MDCT ) { hCPE->element_brate = IVAS_64k; hCPE->brate_surplus -= ( hCPE->element_brate - element_brate_ref ); } } } #ifdef FIX_OMASA_STEREO_SWITCHING stereo_mode_combined_format_dec( st_ivas, hCPE ); #endif read_stereo_mode_and_bwidth( hCPE, st_ivas ); /*----------------------------------------------------------------* Loading Loading @@ -1168,3 +1149,48 @@ static void read_stereo_mode_and_bwidth( return; } #ifdef FIX_OMASA_STEREO_SWITCHING /*------------------------------------------------------------------------- * stereo_mode_combined_format_dec() * * Set stereo format in a combined format *-------------------------------------------------------------------------*/ static void stereo_mode_combined_format_dec( const Decoder_Struct *st_ivas, /* i : decoder main structure */ CPE_DEC_HANDLE hCPE /* i/o: CPE handle */ ) { int32_t element_brate_ref; if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) { element_brate_ref = hCPE->element_brate; if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && ( ( st_ivas->nchan_ism == 3 && st_ivas->hDecoderConfig->ivas_total_brate == IVAS_96k ) || ( st_ivas->nchan_ism == 4 && st_ivas->hDecoderConfig->ivas_total_brate == IVAS_128k ) ) ) { /* read OMASA stereo mode signalling */ if ( get_next_indice( hCPE->hCoreCoder[0], NBITS_ELEMENT_MODE ) ) { hCPE->element_mode = IVAS_CPE_MDCT; } else { hCPE->element_mode = IVAS_CPE_DFT; } if ( hCPE->element_mode == IVAS_CPE_MDCT ) { hCPE->element_brate = IVAS_64k; hCPE->brate_surplus -= ( hCPE->element_brate - element_brate_ref ); } } } return; } #endif lib_enc/ivas_cpe_enc.c +71 −34 Original line number Diff line number Diff line Loading @@ -45,6 +45,15 @@ #include "wmc_auto.h" #ifdef FIX_OMASA_STEREO_SWITCHING /*--------------------------------------------------------------------------* * Local function prototypes *--------------------------------------------------------------------------*/ static void stereo_mode_combined_format_enc( const Encoder_Struct *st_ivas, CPE_ENC_HANDLE hCPE ); #endif /*-------------------------------------------------------------------* * ivas_cpe_enc() * Loading Loading @@ -176,42 +185,11 @@ ivas_error ivas_cpe_enc( { hCPE->element_mode = select_stereo_mode( hCPE, ivas_format, ivas_total_brate ); } #ifdef FIX_OMASA_STEREO_SWITCHING if ( ivas_format == MASA_ISM_FORMAT ) { if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && ( ( hEncoderConfig->nchan_ism == 3 && ivas_total_brate == IVAS_96k ) || ( hEncoderConfig->nchan_ism == 4 && ivas_total_brate == IVAS_128k ) ) ) { if ( hCPE->element_brate + hCPE->brate_surplus > IVAS_64k ) { st_ivas->hMasa->data.omasa_stereo_sw_cnt = 0; } else { st_ivas->hMasa->data.omasa_stereo_sw_cnt++; st_ivas->hMasa->data.omasa_stereo_sw_cnt = min( st_ivas->hMasa->data.omasa_stereo_sw_cnt, OMASA_STEREO_SW_CNT_MAX ); } if ( st_ivas->hMasa->data.omasa_stereo_sw_cnt < OMASA_STEREO_SW_CNT_MAX ) { hCPE->element_mode = IVAS_CPE_MDCT; hCPE->element_brate = IVAS_64k; hCPE->brate_surplus -= ( hCPE->element_brate - element_brate_ref ); } /* write OMASA stereo mode signalling */ if ( hCPE->element_mode == IVAS_CPE_MDCT ) { push_indice( hCPE->hCoreCoder[0]->hBstr, IND_SMODE_OMASA, 1, NBITS_ELEMENT_MODE ); } else { push_indice( hCPE->hCoreCoder[0]->hBstr, IND_SMODE_OMASA, 0, NBITS_ELEMENT_MODE ); } } } #ifdef FIX_OMASA_STEREO_SWITCHING stereo_mode_combined_format_enc( st_ivas, hCPE ); #endif if ( ( error = front_vad( hCPE, NULL, hEncoderConfig, &hCPE->hFrontVad[0], st_ivas->hMCT != NULL, input_frame, vad_flag_dtx, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, vad_hover_flag, band_energies_LR, NULL, NULL ) ) != IVAS_ERR_OK ) { return error; Loading Loading @@ -1232,3 +1210,62 @@ void destroy_cpe_enc( return; } #ifdef FIX_OMASA_STEREO_SWITCHING /*------------------------------------------------------------------------- * stereo_mode_combined_format_enc() * * Set stereo format in a combined format *-------------------------------------------------------------------------*/ static void stereo_mode_combined_format_enc( const Encoder_Struct *st_ivas, /* i : encoder main structure */ CPE_ENC_HANDLE hCPE /* i/o: CPE handle */ ) { ENCODER_CONFIG_HANDLE hEncoderConfig; int32_t element_brate_ref; hEncoderConfig = st_ivas->hEncoderConfig; if ( hEncoderConfig->ivas_format == MASA_ISM_FORMAT ) { element_brate_ref = hCPE->element_brate; if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && ( ( hEncoderConfig->nchan_ism == 3 && hEncoderConfig->ivas_total_brate == IVAS_96k ) || ( hEncoderConfig->nchan_ism == 4 && hEncoderConfig->ivas_total_brate == IVAS_128k ) ) ) { if ( hCPE->element_brate + hCPE->brate_surplus > IVAS_64k ) { st_ivas->hMasa->data.omasa_stereo_sw_cnt = 0; } else { st_ivas->hMasa->data.omasa_stereo_sw_cnt++; st_ivas->hMasa->data.omasa_stereo_sw_cnt = min( st_ivas->hMasa->data.omasa_stereo_sw_cnt, OMASA_STEREO_SW_CNT_MAX ); } if ( st_ivas->hMasa->data.omasa_stereo_sw_cnt < OMASA_STEREO_SW_CNT_MAX ) { hCPE->element_mode = IVAS_CPE_MDCT; hCPE->element_brate = IVAS_64k; hCPE->brate_surplus -= ( hCPE->element_brate - element_brate_ref ); } /* write OMASA stereo mode signalling */ if ( hCPE->element_mode == IVAS_CPE_MDCT ) { push_indice( hCPE->hCoreCoder[0]->hBstr, IND_SMODE_OMASA, 1, NBITS_ELEMENT_MODE ); } else { push_indice( hCPE->hCoreCoder[0]->hBstr, IND_SMODE_OMASA, 0, NBITS_ELEMENT_MODE ); } } } return; } #endif Loading
lib_dec/ivas_cpe_dec.c +52 −26 Original line number Diff line number Diff line Loading @@ -52,6 +52,10 @@ static void read_stereo_mode_and_bwidth( CPE_DEC_HANDLE hCPE, const Decoder_Struct *st_ivas ); #ifdef FIX_OMASA_STEREO_SWITCHING static void stereo_mode_combined_format_dec( const Decoder_Struct *st_ivas, CPE_DEC_HANDLE hCPE ); #endif /*--------------------------------------------------------------------------* * ivas_cpe_dec() Loading Loading @@ -98,9 +102,6 @@ ivas_error ivas_cpe_dec( sts[0]->BER_detect |= st_ivas->BER_detect; sts[1]->BER_detect |= st_ivas->BER_detect; #ifdef FIX_OMASA_STEREO_SWITCHING element_brate_ref = hCPE->element_brate; #endif #ifdef FIX_OMASA_STEREO_SWITCHING element_brate_ref = hCPE->element_brate; Loading @@ -109,31 +110,11 @@ ivas_error ivas_cpe_dec( /*------------------------------------------------------------------* * Read stereo technology info & audio bandwidth *-----------------------------------------------------------------*/ #ifdef FIX_OMASA_STEREO_SWITCHING if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) { if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && ( ( st_ivas->nchan_ism == 3 && ivas_total_brate == IVAS_96k ) || ( st_ivas->nchan_ism == 4 && ivas_total_brate == IVAS_128k ) ) ) { /* read OMASA stereo mode signalling */ if ( get_next_indice( sts[0], NBITS_ELEMENT_MODE ) ) { hCPE->element_mode = IVAS_CPE_MDCT; } else { hCPE->element_mode = IVAS_CPE_DFT; } if ( hCPE->element_mode == IVAS_CPE_MDCT ) { hCPE->element_brate = IVAS_64k; hCPE->brate_surplus -= ( hCPE->element_brate - element_brate_ref ); } } } #ifdef FIX_OMASA_STEREO_SWITCHING stereo_mode_combined_format_dec( st_ivas, hCPE ); #endif read_stereo_mode_and_bwidth( hCPE, st_ivas ); /*----------------------------------------------------------------* Loading Loading @@ -1168,3 +1149,48 @@ static void read_stereo_mode_and_bwidth( return; } #ifdef FIX_OMASA_STEREO_SWITCHING /*------------------------------------------------------------------------- * stereo_mode_combined_format_dec() * * Set stereo format in a combined format *-------------------------------------------------------------------------*/ static void stereo_mode_combined_format_dec( const Decoder_Struct *st_ivas, /* i : decoder main structure */ CPE_DEC_HANDLE hCPE /* i/o: CPE handle */ ) { int32_t element_brate_ref; if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) { element_brate_ref = hCPE->element_brate; if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && ( ( st_ivas->nchan_ism == 3 && st_ivas->hDecoderConfig->ivas_total_brate == IVAS_96k ) || ( st_ivas->nchan_ism == 4 && st_ivas->hDecoderConfig->ivas_total_brate == IVAS_128k ) ) ) { /* read OMASA stereo mode signalling */ if ( get_next_indice( hCPE->hCoreCoder[0], NBITS_ELEMENT_MODE ) ) { hCPE->element_mode = IVAS_CPE_MDCT; } else { hCPE->element_mode = IVAS_CPE_DFT; } if ( hCPE->element_mode == IVAS_CPE_MDCT ) { hCPE->element_brate = IVAS_64k; hCPE->brate_surplus -= ( hCPE->element_brate - element_brate_ref ); } } } return; } #endif
lib_enc/ivas_cpe_enc.c +71 −34 Original line number Diff line number Diff line Loading @@ -45,6 +45,15 @@ #include "wmc_auto.h" #ifdef FIX_OMASA_STEREO_SWITCHING /*--------------------------------------------------------------------------* * Local function prototypes *--------------------------------------------------------------------------*/ static void stereo_mode_combined_format_enc( const Encoder_Struct *st_ivas, CPE_ENC_HANDLE hCPE ); #endif /*-------------------------------------------------------------------* * ivas_cpe_enc() * Loading Loading @@ -176,42 +185,11 @@ ivas_error ivas_cpe_enc( { hCPE->element_mode = select_stereo_mode( hCPE, ivas_format, ivas_total_brate ); } #ifdef FIX_OMASA_STEREO_SWITCHING if ( ivas_format == MASA_ISM_FORMAT ) { if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && ( ( hEncoderConfig->nchan_ism == 3 && ivas_total_brate == IVAS_96k ) || ( hEncoderConfig->nchan_ism == 4 && ivas_total_brate == IVAS_128k ) ) ) { if ( hCPE->element_brate + hCPE->brate_surplus > IVAS_64k ) { st_ivas->hMasa->data.omasa_stereo_sw_cnt = 0; } else { st_ivas->hMasa->data.omasa_stereo_sw_cnt++; st_ivas->hMasa->data.omasa_stereo_sw_cnt = min( st_ivas->hMasa->data.omasa_stereo_sw_cnt, OMASA_STEREO_SW_CNT_MAX ); } if ( st_ivas->hMasa->data.omasa_stereo_sw_cnt < OMASA_STEREO_SW_CNT_MAX ) { hCPE->element_mode = IVAS_CPE_MDCT; hCPE->element_brate = IVAS_64k; hCPE->brate_surplus -= ( hCPE->element_brate - element_brate_ref ); } /* write OMASA stereo mode signalling */ if ( hCPE->element_mode == IVAS_CPE_MDCT ) { push_indice( hCPE->hCoreCoder[0]->hBstr, IND_SMODE_OMASA, 1, NBITS_ELEMENT_MODE ); } else { push_indice( hCPE->hCoreCoder[0]->hBstr, IND_SMODE_OMASA, 0, NBITS_ELEMENT_MODE ); } } } #ifdef FIX_OMASA_STEREO_SWITCHING stereo_mode_combined_format_enc( st_ivas, hCPE ); #endif if ( ( error = front_vad( hCPE, NULL, hEncoderConfig, &hCPE->hFrontVad[0], st_ivas->hMCT != NULL, input_frame, vad_flag_dtx, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, vad_hover_flag, band_energies_LR, NULL, NULL ) ) != IVAS_ERR_OK ) { return error; Loading Loading @@ -1232,3 +1210,62 @@ void destroy_cpe_enc( return; } #ifdef FIX_OMASA_STEREO_SWITCHING /*------------------------------------------------------------------------- * stereo_mode_combined_format_enc() * * Set stereo format in a combined format *-------------------------------------------------------------------------*/ static void stereo_mode_combined_format_enc( const Encoder_Struct *st_ivas, /* i : encoder main structure */ CPE_ENC_HANDLE hCPE /* i/o: CPE handle */ ) { ENCODER_CONFIG_HANDLE hEncoderConfig; int32_t element_brate_ref; hEncoderConfig = st_ivas->hEncoderConfig; if ( hEncoderConfig->ivas_format == MASA_ISM_FORMAT ) { element_brate_ref = hCPE->element_brate; if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && ( ( hEncoderConfig->nchan_ism == 3 && hEncoderConfig->ivas_total_brate == IVAS_96k ) || ( hEncoderConfig->nchan_ism == 4 && hEncoderConfig->ivas_total_brate == IVAS_128k ) ) ) { if ( hCPE->element_brate + hCPE->brate_surplus > IVAS_64k ) { st_ivas->hMasa->data.omasa_stereo_sw_cnt = 0; } else { st_ivas->hMasa->data.omasa_stereo_sw_cnt++; st_ivas->hMasa->data.omasa_stereo_sw_cnt = min( st_ivas->hMasa->data.omasa_stereo_sw_cnt, OMASA_STEREO_SW_CNT_MAX ); } if ( st_ivas->hMasa->data.omasa_stereo_sw_cnt < OMASA_STEREO_SW_CNT_MAX ) { hCPE->element_mode = IVAS_CPE_MDCT; hCPE->element_brate = IVAS_64k; hCPE->brate_surplus -= ( hCPE->element_brate - element_brate_ref ); } /* write OMASA stereo mode signalling */ if ( hCPE->element_mode == IVAS_CPE_MDCT ) { push_indice( hCPE->hCoreCoder[0]->hBstr, IND_SMODE_OMASA, 1, NBITS_ELEMENT_MODE ); } else { push_indice( hCPE->hCoreCoder[0]->hBstr, IND_SMODE_OMASA, 0, NBITS_ELEMENT_MODE ); } } } return; } #endif