Commit 858b25b9 authored by bayers's avatar bayers
Browse files

Merge branch '834-rs-number-of-existing-channels-on-the-heap-mem-wrong' into 'main'

[Non-BE] Resolve "MC RS does not reallocate the necessary number of channels on the heap"

See merge request !1130
parents 0b2b1ac3 96df11ff
Loading
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -294,6 +294,14 @@ ivas_error ivas_init_decoder(
    Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder structure                  */
);

#ifdef NONBE_FIX_839_MC_RS_CHANNEL_ALLOC
ivas_error ivas_output_buff_dec(
    float *p_output_f[],                                        /* i/o: output audio buffers                    */
    const int16_t nchan_out_buff_old,                           /* i  : previous frame number of output channels*/
    const int16_t nchan_out_buff                                /* i  : number of output channels               */   
);
#endif

ivas_error stereo_dmx_evs_init_encoder(
    STEREO_DMX_EVS_ENC_HANDLE *hStereoDmxEVS,                   /* o  : Stereo downmix for EVS encoder handle   */
    const int32_t input_Fs                                      /* i  : input sampling rate                     */

lib_com/options.h

100755 → 100644
+1 −1
Original line number Diff line number Diff line
@@ -186,7 +186,7 @@
#define NONBE_FIX_826_JBM_MASA_CNA_CNG                        /* FhG: issue #826:  Resolve "JBM MASA: CNA and CNG not in sync with non-JBM decoding" */
#define NONBE_FIX_835_JBM_PARAMUPMIX_HEADROT                  /* FhG: issue #835: Resolve "JBM: ParamUpmix head rotation broken" */
#define NONBE_FIX_838_CRASH_24_4_WB                           /* FhG: Issue 838: fix encoder crashes for Unified Stereo and MASA 2 TC at 24.4 kbps WB due to missing IGF (re-) allocation */

#define NONBE_FIX_839_MC_RS_CHANNEL_ALLOC                     /* FhG: Issues #839: problems with reallocation of the channels on the heap in case of MC RS */
/* ##################### End NON-BE switches ########################### */

/* ################## End DEVELOPMENT switches ######################### */
+17 −0
Original line number Diff line number Diff line
@@ -67,7 +67,11 @@ static ivas_error ivas_ism_bitrate_switching_dec(
    int16_t tc_nchan_tc_new;
    int16_t tc_nchan_allocate_new;
    int16_t tc_granularity_new;
#ifdef NONBE_FIX_839_MC_RS_CHANNEL_ALLOC
    int16_t nchan_out_buff, nchan_out_buff_old;
#else
    int16_t ch, nchan_out_buff, nchan_out_buff_old;
#endif
    AUDIO_CONFIG intern_config_old;
    IVAS_OUTPUT_SETUP hIntSetupOld;
    RENDERER_TYPE renderer_type_old;
@@ -81,7 +85,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_839_MC_RS_CHANNEL_ALLOC
    nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 );
#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 )
    {
@@ -331,6 +339,14 @@ static ivas_error ivas_ism_bitrate_switching_dec(

    if ( !st_ivas->hDecoderConfig->Opt_5ms )
    {
#ifdef NONBE_FIX_839_MC_RS_CHANNEL_ALLOC
        nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 );

        if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#else
        nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate );

        if ( nchan_out_buff > nchan_out_buff_old )
@@ -352,6 +368,7 @@ static ivas_error ivas_ism_bitrate_switching_dec(
                st_ivas->p_output_f[ch] = NULL;
            }
        }
#endif
    }

    /*-----------------------------------------------------------------*
+4 −0
Original line number Diff line number Diff line
@@ -443,7 +443,11 @@ void ivas_mc_paramupmix_dec(
        }
    }

#ifdef NONBE_FIX_839_MC_RS_CHANNEL_ALLOC
    for ( ch = first_empty_channel; ch < ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ); ch++ )
#else
    for ( ch = first_empty_channel; ch < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); ch++ )
#endif
    {
        set_f( output_f[ch], 0.0f, output_frame );
    }
+47 −2
Original line number Diff line number Diff line
@@ -731,12 +731,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_839_MC_RS_CHANNEL_ALLOC
    int16_t nchan_out_buff_old, nchan_out_buff;
#endif

    error = IVAS_ERR_OK;

    ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
    nchan_transport_old = st_ivas->nchan_transport;

#ifdef NONBE_FIX_839_MC_RS_CHANNEL_ALLOC
    nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 );
#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 */

    /* we have to temporally set the current mc_mode back to the previous one to make sure the following call to
@@ -1386,5 +1390,46 @@ static ivas_error ivas_mc_dec_reconfig(
        }
    }

#ifdef NONBE_FIX_839_MC_RS_CHANNEL_ALLOC
    /*-----------------------------------------------------------------*
     * floating-point output audio buffers
     *-----------------------------------------------------------------*/

    if ( !st_ivas->hDecoderConfig->Opt_5ms )
    {
#ifdef NONBE_FIX_839_MC_RS_CHANNEL_ALLOC
        nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 );

        if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#else
        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 );

        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
    }
#endif

    return error;
}
Loading