Commit 6a7dca9f authored by Dominik Weckbecker's avatar Dominik Weckbecker 💬
Browse files

fix encoder side bitrate calculation

parent 41966a71
Loading
Loading
Loading
Loading
+18 −13
Original line number Diff line number Diff line
@@ -181,6 +181,9 @@ ivas_error ivas_osba_enc_reconfig(
    int32_t ivas_total_brate;
    ivas_error error;
    ENCODER_CONFIG_HANDLE hEncoderConfig;
#ifdef NONBE_FIX_ISM_XOVER_BR
    int16_t n_all, n_all_old;
#endif

    error = IVAS_ERR_OK;
    hEncoderConfig = st_ivas->hEncoderConfig;
@@ -212,6 +215,9 @@ ivas_error ivas_osba_enc_reconfig(
        nchan_transport_old = st_ivas->nchan_transport;
        nCPE_old = st_ivas->nCPE;
        nSCE_old = st_ivas->nSCE;
#ifdef NONBE_FIX_ISM_XOVER_BR
        n_all_old = nchan_transport_old + st_ivas->hEncoderConfig->nchan_ism;
#endif
        st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, hEncoderConfig->sba_order );
        analysis_order_old = ivas_sba_get_analysis_order( hEncoderConfig->last_ivas_total_brate, hEncoderConfig->sba_order );
        nbands_old = st_ivas->hQMetaData->q_direction->cfg.nbands;
@@ -338,32 +344,31 @@ ivas_error ivas_osba_enc_reconfig(
         * Allocate, initialize, and configure SCE/CPE/MCT handles
         *-----------------------------------------------------------------*/

#ifdef NONBE_FIX_ISM_XOVER_BR
        n_all = st_ivas->nchan_transport;
#endif
        if ( old_ism_mode == ISM_MODE_NONE && st_ivas->ism_mode == ISM_SBA_MODE_DISC )
        {
#ifdef NONBE_FIX_ISM_XOVER_BR
            {
                int16_t n_all;

            n_all = st_ivas->nchan_transport + st_ivas->hEncoderConfig->nchan_ism;
            st_ivas->nCPE = ( n_all / 2 ) + ( n_all % 2 );
            }
#else
            st_ivas->nCPE += ( st_ivas->hEncoderConfig->nchan_ism + 1 ) >> 1;
#endif
        }
        else if ( old_ism_mode == ISM_SBA_MODE_DISC && st_ivas->ism_mode == ISM_MODE_NONE )
        {
#ifdef NONBE_FIX_ISM_XOVER_BR
            n_all = st_ivas->nchan_transport;
#else
            nchan_transport_old += st_ivas->hEncoderConfig->nchan_ism;
#endif
        }
        else if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC )
        {
#ifdef NONBE_FIX_ISM_XOVER_BR
            {
                int16_t n_all;

            n_all = st_ivas->nchan_transport + st_ivas->hEncoderConfig->nchan_ism;
            st_ivas->nCPE = ( n_all / 2 ) + ( n_all % 2 );
            }
#else
            st_ivas->nCPE += ( st_ivas->hEncoderConfig->nchan_ism + 1 ) >> 1;
            nCPE_old = st_ivas->nCPE;
@@ -372,7 +377,7 @@ ivas_error ivas_osba_enc_reconfig(
#endif
        }

        if ( ( error = 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 ) ) != IVAS_ERR_OK )
        if ( ( error = ivas_corecoder_enc_reconfig( st_ivas, nSCE_old, nCPE_old, n_all_old, ivas_total_brate /n_all, ( ivas_total_brate / n_all ) * CPE_CHANNELS, MC_MODE_NONE ) ) != IVAS_ERR_OK )
        {
            return error;
        }