Commit 83d86954 authored by vaclav's avatar vaclav
Browse files

fix ISM BRSW crash + fix USAN warning

parent ac1738e4
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -221,6 +221,7 @@
#define FIX_653_BUG_IN_SKIP_MATRIX                      /* Dlb: fix for issue #653, bug in the ivas_spar_get_skip_mat function*/
#define FIX_663_PARAM_ISM_EXT                           /* FhG: Issue 663: ParamISM EXT output improvement */
#define FIX_673_OMASA_OBJ_MD_SYNC                       /* Nokia: Fix issue 673 by updating metadata in the third subframe to account for audio delay. */

#define FIX_264_AUDIO_CHANNELS_TO_HEAP                  /* VA: issue 243: Move audio channels memory from stack to heap */


+3 −1
Original line number Diff line number Diff line
@@ -123,8 +123,10 @@ ivas_error ivas_dec(
    {
#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP
        output[n] = st_ivas->p_output_f[n];
#endif
        p_output[n] = output[n];
#else
        p_output[n] = &output[n][0];
#endif
    }

    /*----------------------------------------------------------------*
+34 −0
Original line number Diff line number Diff line
@@ -62,6 +62,9 @@ static ivas_error ivas_ism_bitrate_switching(
    int16_t tc_nchan_tc_new;
    int16_t tc_nchan_allocate_new;
    int16_t tc_granularity_new;
#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP
    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;
@@ -75,6 +78,9 @@ static ivas_error ivas_ism_bitrate_switching(
    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 FIX_264_AUDIO_CHANNELS_TO_HEAP
    nchan_out_buff_old = ivas_get_nchan_buffers( st_ivas );
#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
#ifdef MASA_AND_OBJECTS
@@ -336,6 +342,34 @@ static ivas_error ivas_ism_bitrate_switching(
        return error;
    }

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

    nchan_out_buff = ivas_get_nchan_buffers( st_ivas );

    if ( nchan_out_buff > nchan_out_buff_old )
    {
        for ( ch = nchan_out_buff_old; ch < nchan_out_buff; ch++ )
        {
            /* note: these are intra-frame heap memories */
            if ( ( st_ivas->p_output_f[ch] = (float *) malloc( ( max( st_ivas->hDecoderConfig->output_Fs, 32000 ) / 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_buff_old; ch++ )
        {
            free( st_ivas->p_output_f[ch] );
            st_ivas->p_output_f[ch] = NULL;
        }
    }
#endif

    /*-----------------------------------------------------------------*
     * Reconfigure TC buffer
     *-----------------------------------------------------------------*/