Commit 61d20540 authored by emerit's avatar emerit
Browse files

Merge branch '1202_ref_step_1_fix_crash_long_brir_2' into 'float-pc'

port MR 1202 to float-pc v2

See merge request !1383
parents 66c435e2 a2327df2
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -2958,6 +2958,13 @@ int16_t check_bounds_s(
    const int16_t high                                          /* i  : High limit                              */
);

#ifdef FIX_CRASH_LONG_BRIR
void set_zero_l(
    float *vec,         /* o  : input vector                                    */
    const uint32_t lvec /* i  : length of the vector                            */
);
#endif

ivas_error stereo_memory_enc(
    CPE_ENC_HANDLE hCPE,                                        /* i  : CPE encoder structure                   */
    const int32_t input_Fs,                                     /* i  : input sampling rate                     */
+22 −0
Original line number Diff line number Diff line
@@ -581,6 +581,28 @@ int16_t check_bounds_s(
    return value_adj;
}

#ifdef FIX_CRASH_LONG_BRIR
/*---------------------------------------------------------------------*
 * set_zero_l()
 *
 * Set a vector vec[] of dimension lvec to zero
 *---------------------------------------------------------------------*/

void set_zero_l(
    float *vec,         /* i/o: input/output vector     */
    const uint32_t lvec /* i  : length of the vector    */
)
{
    uint32_t i;

    for ( i = 0; i < lvec; i++ )
    {
        *vec++ = 0.0f;
    }

    return;
}
#endif

/****************************************************************************/
/* matrix functions                                                         */
+1 −1
Original line number Diff line number Diff line
@@ -184,7 +184,6 @@
#define NONBE_FIX_1277_EVS_DTX_HIGH_RATE_THRESHOLD      /* VA/Eri: FLP issue 1277: Fix Mismatch in DTX high-rate threshold between EVS float and BASOP */
#define NONBE_FIX_708_OSBA_BR_SWITCHING_CRASH           /* FhG: issue 708: fix crash in OSBA BR switching with long test vectors */


#define NONBE_1319_M2R_PRECISION_ALIGN                  /* Nokia: bring updates from PC code related to OMASA masa2total ratios */

/* #################### End FIXES switches ############################ */
@@ -209,6 +208,7 @@
#define FIX_910_REMOVE_DUPLICATION_TD_REND              /* VA: issue 910: remove duplication of function ivas_td_binaural_renderer() */
#define FIX_940_DEBUGGING_VARIABLE                      /* Nokia: issue #940: remove debugging variable */
#define NONBE_FIX_931_IGF_STEREO_DEC_NOISE	                  /* FhG: issue #931: fix noise substitution in the stereo IGF decoder      */
#define FIX_CRASH_LONG_BRIR                             /* Orange : Fix crash when long BRIR is set */

/* #################### End BASOP porting switches ############################ */

+32 −0
Original line number Diff line number Diff line
@@ -1249,7 +1249,11 @@ ivas_error ivas_rend_openCrend(
)
{
    int16_t i, subframe_length;
#ifdef FIX_CRASH_LONG_BRIR
    int32_t max_total_ir_len;
#else
    int16_t max_total_ir_len;
#endif
    HRTFS_HANDLE hHrtf;
    CREND_HANDLE hCrend;
    ivas_error error;
@@ -1299,13 +1303,21 @@ ivas_error ivas_rend_openCrend(
                {
                    return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" );
                }
#ifdef FIX_CRASH_LONG_BRIR
                set_zero_l( hCrend->freq_buffer_re[i], max_total_ir_len );
#else
                set_zero( hCrend->freq_buffer_re[i], max_total_ir_len );
#endif

                if ( ( hCrend->freq_buffer_im[i] = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL )
                {
                    return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" );
                }
#ifdef FIX_CRASH_LONG_BRIR
                set_zero_l( hCrend->freq_buffer_im[i], max_total_ir_len );
#else
                set_zero( hCrend->freq_buffer_im[i], max_total_ir_len );
#endif
            }

            for ( i = 0; i < BINAURAL_CHANNELS; i++ )
@@ -1314,7 +1326,11 @@ ivas_error ivas_rend_openCrend(
                {
                    return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" );
                }
#ifdef FIX_CRASH_LONG_BRIR
                set_zero_l( hCrend->prev_out_buffer[i], subframe_length );
#else
                set_zero( hCrend->prev_out_buffer[i], subframe_length );
#endif
            }

            max_total_ir_len = hHrtf->num_iterations_diffuse[0] * subframe_length;
@@ -1325,13 +1341,21 @@ ivas_error ivas_rend_openCrend(
                {
                    return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" );
                }
#ifdef FIX_CRASH_LONG_BRIR
                set_zero_l( hCrend->freq_buffer_re_diffuse, max_total_ir_len );
#else
                set_zero( hCrend->freq_buffer_re_diffuse, max_total_ir_len );
#endif

                if ( ( hCrend->freq_buffer_im_diffuse = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL )
                {
                    return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" );
                }
#ifdef FIX_CRASH_LONG_BRIR
                set_zero_l( hCrend->freq_buffer_im_diffuse, max_total_ir_len );
#else
                set_zero( hCrend->freq_buffer_im_diffuse, max_total_ir_len );
#endif
            }
            else
            {
@@ -1346,7 +1370,11 @@ ivas_error ivas_rend_openCrend(
                {
                    return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" );
                }
#ifdef FIX_CRASH_LONG_BRIR
                set_zero_l( hCrend->lfe_delay_line, max_total_ir_len );
#else
                set_zero( hCrend->lfe_delay_line, max_total_ir_len );
#endif
            }
            else
            {
@@ -1589,7 +1617,11 @@ static ivas_error ivas_rend_crendConvolver(
    int16_t i, j, k, m;
    int16_t subframe_length, idx_in;
    int16_t lfe_idx_in;
#ifdef FIX_CRASH_LONG_BRIR
    int32_t offset, offset_in, offset_diffuse;
#else
    int16_t offset, offset_in, offset_diffuse;
#endif
    int16_t nchan_in, nchan_out;
    const float *pIn;
    float *pFreq_buf_re, *pFreq_buf_im;