Commit 7d1ed0ff authored by bayers's avatar bayers
Browse files

fix #834, #839, make sure that the number of channels allocated on the heap...

fix #834, #839, make sure that the number of channels allocated on the heap stays correct in case of rate switching
parent 8e40fa16
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -189,7 +189,7 @@
#define NONBE_FIX_730_DPID_NOT_SET_CORRECTLY                  /* Eri: issue 730: write dpid read from file in correct index, print informative error message when DPID specified is not found. */
#define NONBE_FIX_825_SBA_JBM_MONO_STEREO_OUTPUT              /* FhG: issue #825: Resolve "JBM SBA: AGC and PCA run twice for MONO and STEREO output"   */
#define NONBE_FIX_808_JBM_PARAMUPMIX_RS                       /* FhG: Issue 808: fix JBM MC rate switching */

#define NONBE_FIX_834_839_HEAP_CHANNEL_COUNT                  /* FhG: Issues #834, #839: problems with reallocation of the channels on the heap */
/* ##################### End NON-BE switches ########################### */

/* ################## End DEVELOPMENT switches ######################### */
+6 −0
Original line number Diff line number Diff line
@@ -2247,6 +2247,9 @@ ivas_error ivas_init_decoder(
                return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) );
            }
        }
#ifdef NONBE_FIX_834_839_HEAP_CHANNEL_COUNT
        st_ivas->n_output_buffer_channels = n;
#endif
    }
    else
    {
@@ -2511,6 +2514,9 @@ void ivas_initialize_handles_dec(
    {
        st_ivas->p_output_f[i] = NULL;
    }
#ifdef NONBE_FIX_834_839_HEAP_CHANNEL_COUNT
    st_ivas->n_output_buffer_channels = 0;
#endif

    return;
}
+7 −1
Original line number Diff line number Diff line
@@ -81,7 +81,11 @@ static ivas_error ivas_ism_bitrate_switching_dec(
    st_ivas->ism_mode = last_ism_mode;
    ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old );
    st_ivas->ism_mode = ism_mode;
#ifdef NONBE_FIX_834_839_HEAP_CHANNEL_COUNT
    nchan_out_buff_old = st_ivas->n_output_buffer_channels;
#else
    nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate );
#endif

    if ( ( error = ivas_ism_config( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->nchan_ism, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL, 0 ) ) != IVAS_ERR_OK )
    {
@@ -332,7 +336,9 @@ static ivas_error ivas_ism_bitrate_switching_dec(
    if ( !st_ivas->hDecoderConfig->Opt_5ms )
    {
        nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate );

#ifdef NONBE_FIX_834_839_HEAP_CHANNEL_COUNT
        st_ivas->n_output_buffer_channels = nchan_out_buff;
#endif
        if ( nchan_out_buff > nchan_out_buff_old )
        {
            for ( ch = nchan_out_buff_old; ch < nchan_out_buff; ch++ )
+38 −1
Original line number Diff line number Diff line
@@ -739,11 +739,16 @@ static ivas_error ivas_mc_dec_reconfig(
    int16_t tc_granularity_new;
    AUDIO_CONFIG intern_config_old;
    IVAS_OUTPUT_SETUP hIntSetupOld;

#ifdef NONBE_FIX_834_839_HEAP_CHANNEL_COUNT
    int16_t nchan_out_buf_old;
#endif
    error = IVAS_ERR_OK;

    ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
    nchan_transport_old = st_ivas->nchan_transport;
#ifdef NONBE_FIX_834_839_HEAP_CHANNEL_COUNT
    nchan_out_buf_old = st_ivas->n_output_buffer_channels;
#endif

    last_mc_mode = ivas_mc_mode_select( ivas_mc_map_output_config_to_mc_ls_setup( st_ivas->transport_config ), st_ivas->hDecoderConfig->last_ivas_total_brate ); /* NB: this assumes that LS config remains the same between frames */

@@ -1390,5 +1395,37 @@ static ivas_error ivas_mc_dec_reconfig(
        }
    }

    /*-----------------------------------------------------------------*
     * floating-point output audio buffers
     *-----------------------------------------------------------------*/
#ifdef NONBE_FIX_834_839_HEAP_CHANNEL_COUNT
    if ( !st_ivas->hDecoderConfig->Opt_5ms )
    {
        int16_t nchan_out_buff, ch;
        nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate );

        st_ivas->n_output_buffer_channels = nchan_out_buff;
        if ( nchan_out_buff > nchan_out_buf_old )
        {
            for ( ch = nchan_out_buf_old; ch < nchan_out_buff; ch++ )
            {
                /* note: these are intra-frame heap memories */
                if ( ( st_ivas->p_output_f[ch] = (float *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) /* note: 32000 == max internal sampling rate */
                {
                    return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) );
                }
            }
        }
        else
        {
            for ( ch = nchan_out_buff; ch < nchan_out_buf_old; ch++ )
            {
                free( st_ivas->p_output_f[ch] );
                st_ivas->p_output_f[ch] = NULL;
            }
        }
    }
#endif

    return error;
}
+7 −1
Original line number Diff line number Diff line
@@ -180,7 +180,11 @@ ivas_error ivas_omasa_dec_config(
    ivas_format_orig = st_ivas->ivas_format;
    st_ivas->ivas_format = st_ivas->last_ivas_format;
    ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old );
#ifdef NONBE_FIX_834_839_HEAP_CHANNEL_COUNT
    nchan_out_buff_old = st_ivas->n_output_buffer_channels;
#else
    nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate );
#endif

    st_ivas->ivas_format = ivas_format_orig;

@@ -415,7 +419,9 @@ ivas_error ivas_omasa_dec_config(
        if ( !st_ivas->hDecoderConfig->Opt_5ms )
        {
            nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate );

#ifdef NONBE_FIX_834_839_HEAP_CHANNEL_COUNT
            st_ivas->n_output_buffer_channels = nchan_out_buff;
#endif
            if ( nchan_out_buff > nchan_out_buff_old )
            {
                for ( k = nchan_out_buff_old; k < nchan_out_buff; k++ )
Loading