Commit 6cde32ae authored by multrus's avatar multrus
Browse files

merge from main

parents 1bbf29ee b90711b9
Loading
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -77,7 +77,6 @@ static void interpTargetChannel(
        return;
    }

    /* IVAS-220: QCToDo: (check N for dependency on the inputFs) */
    N = L_shift_adapt;
    factor = ( (float) N ) / abs( d );
    interp_factor2 = factor / INTERP_FACTOR1;
+2 −1
Original line number Diff line number Diff line
@@ -183,6 +183,7 @@
#define FIX_621_MSVQ_UBSAN_NULL_PTR_OFFSET              /* Eri: Issue 621 :  UBSAN:  applying non-zero offset 7200 to null pointer in lsf_msvq_ma_enc.c  */
#define FIX_600_CLEANUP_OF_MANUAL_INSTRUMENTATION       /* Eri: Issue 600 :  removed manual WMCtool instrumentation outside of WMC_TOOL_SKIP defines     */
#define NONBE_FIX_539_MASA_384K_CHIRP                   /* Nokia: issue 539, puts the normalization of the energy ratios at the correct place, affect MASA 384k only */
#define FIX_635_UBSAN_UNDEFINED_BEHAVIOUR_QMETA         /* Nokia: issue 635 adding cast to uint16_t in q_metadata_enc */

/* Fixes for bugs found during split rendering contribution development */
#define TD_TDREND_FIX_NULLPTR_ACCESS                    /* FhG: avoid nullptr access in ivas_rend_TDObjRendOpen */
@@ -206,7 +207,7 @@
#define FIX_279_CODE_COVERAGE                           /* Dlb : issue 279 , clean up unused function */
#define FIX_549_PARAM_ISM_BIN_GAIN                      /* FhG: Issue 549 : fix too quiet binaural output in ParamISM */
#define FIX_618_STEREO_SW_DIV_BY_ZERO                   /* VA: fix issue 618 - UBSAN: division-by-zero in stereo bitrate switching */

#define FIX_625_IDX_OOB                                 /* FhG: Fix index out-of-bounds UBSAN error (issue 625) */

/* ################## End BE DEVELOPMENT switches ######################### */

+6 −3
Original line number Diff line number Diff line
@@ -1265,7 +1265,7 @@ int16_t ivas_qmetadata_dec_sid_decode(
    start_index = *index;

    /* read MASA SID descriptor */
    if ( ivas_format == MASA_FORMAT && nchan_transport == 2 ) /* corresponding to SID_MASA case; Todo: needs to be checked for SBA */
    if ( ivas_format == MASA_FORMAT && nchan_transport == 2 )
    {
        b = bitstream[( *index )--];
        if ( b )
@@ -1456,11 +1456,14 @@ int16_t ivas_qmetadata_dec_sid_decode(
        }
    }


#if !( defined FIX_137_SID_MD_BITS && defined FIX_QMETA_SID_5k2 )
    /* TODO: temporary hack to keep BE */
    if ( ivas_format != SBA_FORMAT )
    {
        metadata_sid_bits = ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS;
    }

#endif
    /*Read filling bits*/
    while ( start_index - *index < metadata_sid_bits )
    {
@@ -2372,7 +2375,7 @@ static uint16_t ivas_qmetadata_DecodeQuasiUniform(
    uint16_t tresh, value;

#ifdef DEBUGGING
    assert( ( alphabet_size >= 1 ) ); /* ToDo: fcs: to check if this additional conditon is really needed: && (alphabet_size <= (1U << 31) - 1));*/
    assert( ( alphabet_size >= 1 ) );
#endif

    bits = 30 - norm_l( alphabet_size ); /* bits = floor(log2(alphabet_size)) */

lib_dec/ivas_spar_decoder.c

100644 → 100755
+8 −0
Original line number Diff line number Diff line
@@ -1019,14 +1019,22 @@ static void ivas_spar_calc_smooth_facs(
    bin = 0;
    for ( b = 0; b < nbands_spar; b++ )
    {
#ifdef FIX_625_IDX_OOB
        if ( bin >= CLDFB_NO_CHANNELS_MAX || ( b > 0 && bin2band->p_cldfb_map_to_spar_band[bin] < bin2band->p_cldfb_map_to_spar_band[bin - 1] ) )
#else
        if ( b > 0 && bin2band->p_cldfb_map_to_spar_band[bin] < bin2band->p_cldfb_map_to_spar_band[bin - 1] )
#endif
        {
            break;
        }

        /* calculate band-wise subframe energies */
        subframe_band_nrg[b] = 0.f;
#ifdef FIX_625_IDX_OOB
        while ( bin < CLDFB_NO_CHANNELS_MAX && b == bin2band->p_cldfb_map_to_spar_band[bin] )
#else
        while ( b == bin2band->p_cldfb_map_to_spar_band[bin] )
#endif
        {
            for ( ts = 0; ts < MAX_PARAM_SPATIAL_SUBFRAMES; ts++ )
            {
+46 −7
Original line number Diff line number Diff line
@@ -991,6 +991,7 @@ void ivas_qmetadata_enc_sid_encode(

        metadata_sid_bits = ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS;
#else
        /* TODO: still use old sid frame size to keep bitexactness */
        metadata_sid_bits = ( 4400 /*IVAS_SID_5k2*/ - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS;
#endif
    }
@@ -1231,11 +1232,13 @@ void ivas_qmetadata_enc_sid_encode(
    }
#endif

#if !( defined FIX_137_SID_MD_BITS && defined FIX_QMETA_SID_5k2 )
    /* TODO: temporary to keep BE */
    if ( ivas_format != SBA_FORMAT )
    {
        metadata_sid_bits = ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS;
    }

#endif
    /* fill bits*/
    assert( ( hMetaData->nb_bits_tot - bit_pos_start ) <= metadata_sid_bits && "Too many written bits!" );
    while ( ( hMetaData->nb_bits_tot - bit_pos_start ) < metadata_sid_bits )
@@ -2272,7 +2275,7 @@ static void ivas_qmetadata_encode_quasi_uniform(
    int16_t bits;
    uint16_t tresh;
#ifdef DEBUGGING
    assert( ( alphabet_size >= 1 ) ); /* ToDo: fcs: to check if this additional conditon is really needed: && (alphabet_size <= (1U << 31) - 1));*/
    assert( ( alphabet_size >= 1 ) );
    assert( value < alphabet_size );
#endif

@@ -2511,7 +2514,7 @@ static int16_t ivas_qmetadata_encode_quasi_uniform_length(
    int16_t bits;
    uint16_t tresh;
#ifdef DEBUGGING
    assert( ( alphabet_size >= 1 ) ); /* ToDo: fcs: to check if this additional conditon is really needed: && (alphabet_size <= (1U << 31) - 1));*/
    assert( ( alphabet_size >= 1 ) );
    assert( value < alphabet_size );
#endif

@@ -2550,9 +2553,15 @@ static int16_t ivas_qmetadata_entropy_encode_dir(
    float avg_direction_vector[3], direction_vector[3], avg_azimuth, avg_elevation;
    int16_t avg_azimuth_alphabet, avg_elevation_alphabet;
    uint16_t avg_azimuth_index, avg_elevation_index;
#ifdef FIX_635_UBSAN_UNDEFINED_BEHAVIOUR_QMETA
    int16_t avg_elevation_index_projected;
    int16_t avg_azimuth_index_projected;
    uint16_t avg_elevation_index_initial, avg_elevation_offset;
    uint16_t avg_azimuth_index_initial, avg_azimuth_offset;
#else
    int16_t avg_elevation_index_initial, avg_elevation_offset, avg_elevation_index_projected;
    int16_t avg_azimuth_index_initial, avg_azimuth_offset, avg_azimuth_index_projected;

#endif
    int16_t elevation_bits_ec_best, azimuth_bits_ec_best;

    int16_t gr_param_elevation_best = 0, avg_elevation_index_best = 0;
@@ -2672,15 +2681,30 @@ static int16_t ivas_qmetadata_entropy_encode_dir(
    }
    else
    {
#ifdef FIX_635_UBSAN_UNDEFINED_BEHAVIOUR_QMETA
        if ( sign_th < 0 )
        {
            avg_elevation_index = ( avg_elevation_alphabet >> 1 ) - avg_elevation_index;
        }
        else
        {
            avg_elevation_index += ( avg_elevation_alphabet >> 1 );
        }
        avg_elevation *= sign_th;
#else
        if ( sign_th < 0 )
        {
            avg_elevation_index = -avg_elevation_index;
        }
        avg_elevation *= sign_th;
        avg_elevation_index += ( avg_elevation_alphabet >> 1 );
#endif
    }
#ifdef FIX_635_UBSAN_UNDEFINED_BEHAVIOUR_QMETA
    avg_azimuth_index = (uint16_t) ( quantize_phi( avg_azimuth + 180, 0, &avg_azimuth, avg_azimuth_alphabet ) );
#else
    avg_azimuth_index = quantize_phi( avg_azimuth + 180, 0, &avg_azimuth, avg_azimuth_alphabet );

#endif
    /* Elevation only if not 2D */
    if ( q_direction->not_in_2D > 0 )
    {
@@ -2697,10 +2721,17 @@ static int16_t ivas_qmetadata_entropy_encode_dir(
            }
            else
            {
#ifdef FIX_635_UBSAN_UNDEFINED_BEHAVIOUR_QMETA
                avg_elevation_index = (uint16_t) ( avg_elevation_index_initial + ivas_qmetadata_dereorder_generic( avg_elevation_offset ) );
#else
                avg_elevation_index = avg_elevation_index_initial + ivas_qmetadata_dereorder_generic( avg_elevation_offset );
#endif
            }

#ifdef FIX_635_UBSAN_UNDEFINED_BEHAVIOUR_QMETA
            avg_elevation_index = (uint16_t) ( ( avg_elevation_index + avg_elevation_alphabet ) % avg_elevation_alphabet );
#else
            avg_elevation_index = ( avg_elevation_index + avg_elevation_alphabet ) % avg_elevation_alphabet;
#endif

            all_zero_dist_elevation_indexes = 1;
            if ( q_direction->cfg.mc_ls_setup != MC_LS_SETUP_INVALID )
@@ -2803,7 +2834,11 @@ static int16_t ivas_qmetadata_entropy_encode_dir(
    if ( ( nbands - start_band >= 5 ) && ( q_direction->cfg.mc_ls_setup != MC_LS_SETUP_INVALID ) && ( nblocks > 1 ) )
    {
        use_adapt_avg = calc_var_azi( q_direction, diffuseness_index_max_ec_frame, avg_azimuth - 180, &avg_azimuth );
#ifdef FIX_635_UBSAN_UNDEFINED_BEHAVIOUR_QMETA
        avg_azimuth_index = (uint16_t) ( quantize_phi( avg_azimuth + 180, 0, &avg_azimuth, avg_azimuth_alphabet ) );
#else
        avg_azimuth_index = quantize_phi( avg_azimuth + 180, 0, &avg_azimuth, avg_azimuth_alphabet );
#endif
    }
    avg_azimuth_index_initial = avg_azimuth_index; /* avg_azimuth_index;*/
    azimuth_bits_ec_best = MAX16B;
@@ -2813,9 +2848,13 @@ static int16_t ivas_qmetadata_entropy_encode_dir(
    for ( avg_azimuth_offset = 0; avg_azimuth_offset < q_direction->cfg.search_effort; avg_azimuth_offset++ )
    {
        set_zero( avg_direction_vector, 3 );
#ifdef FIX_635_UBSAN_UNDEFINED_BEHAVIOUR_QMETA
        avg_azimuth_index = (uint16_t) ( avg_azimuth_index_initial + ivas_qmetadata_dereorder_generic( avg_azimuth_offset ) );
        avg_azimuth_index = (uint16_t) ( ( avg_azimuth_index + avg_azimuth_alphabet ) % avg_azimuth_alphabet );
#else
        avg_azimuth_index = avg_azimuth_index_initial + ivas_qmetadata_dereorder_generic( avg_azimuth_offset );
        avg_azimuth_index = ( avg_azimuth_index + avg_azimuth_alphabet ) % avg_azimuth_alphabet;

#endif
        all_zero_dist_azimuth_indexes = 1;
        azimuth_bits_ec = ivas_qmetadata_encode_quasi_uniform_length( ivas_qmetadata_reorder_generic( avg_azimuth_index - ( avg_azimuth_alphabet >> 1 ) ), avg_azimuth_alphabet );

Loading