Commit eb137f09 authored by vasilache's avatar vasilache
Browse files

Merge branch '760-coherence-coding-misalignment-masa' into 'main'

[non-BE] Fix MASA coherence crash

See merge request !1051
parents 6c38d924 3629a30f
Loading
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1187,7 +1187,11 @@ enum

#define QMETADATA_MAXBIT_REQ_MASA               900                         /* max bit-bit/direction for avoiding requantization in MASA path */
#define QMETADATA_MAXBIT_REQ_SBA                400                         /* max bit-bit/direction for avoiding requantization in SBA path */
#ifdef NONBE_FIX_760_COHERENCE_MASA
#define MASA_COH_LIMIT_2IDX                     96                          /* limit for sum of values across components for having two joint indexes */
#else
#define MASA_COH_LIMIT_2IDX                     144                         /* limit for sum of values across components for having two joint indexes */
#endif
#define QMETADATA_MAX_NO_DIRECTIONS             2
#define MASA_MAX_BITS                           1300                        /* max. bit-budget for MASA metadata */

+1 −1
Original line number Diff line number Diff line
@@ -168,7 +168,7 @@
#define NONBE_FIX_746_NONDIEGETIC_MD                          /* Eri: Issue 746: The non-diegetic panning flag affects the encoder bitstream even if extended metadata is not enabled. Crashes the decoder.*/
#define NONBE_FIX_729_ASAN_2ISM_ACELP                         /* VA: issue 729: fix ASAN ACELP errors with 2 ISM coding using LTV */
#define NONBE_FIX_694_OMASA_ACELP                             /* Nokia: Issue #694: OMASA crash in ACELP with extreme item */

#define NONBE_FIX_760_COHERENCE_MASA                          /* Nokia: Issue 760: fixes decoder crash for some cases when all energy ratios are 1 */
/* ##################### End NON-BE switches ############################# */

/* ################## End DEVELOPMENT switches ######################### */
+18 −3
Original line number Diff line number Diff line
@@ -3774,9 +3774,13 @@ static int16_t read_coherence_data(
    uint16_t byteBuffer;
    int16_t idx_ER;
    int16_t min_index;

#ifdef NONBE_FIX_760_COHERENCE_MASA
    int16_t extra_cv;
#endif
    coding_subbands = hQMetaData->q_direction[idx_dir].cfg.nbands;

#ifdef NONBE_FIX_760_COHERENCE_MASA
    extra_cv = (int16_t) ( coding_subbands / MASA_FACTOR_CV_COH );
#endif
    q_direction = &( hQMetaData->q_direction[idx_dir] );
    bit_pos = *p_bit_pos;
    nbits = 0;
@@ -3787,12 +3791,19 @@ static int16_t read_coherence_data(
        {
            if ( hrmasa_flag )
            {
#ifdef NONBE_FIX_760_COHERENCE_MASA
                idx_ER = 7 - ( q_direction->band_data[j].energy_ratio_index_mod[0] >> 1 ) + extra_cv;
#else
                idx_ER = 7 - ( q_direction->band_data[j].energy_ratio_index_mod[0] >> 1 ) + coding_subbands / MASA_FACTOR_CV_COH;
#endif
            }
            else
            {

#ifdef NONBE_FIX_760_COHERENCE_MASA
                idx_ER = 7 - q_direction->band_data[j].energy_ratio_index_mod[0] + extra_cv;
#else
                idx_ER = 7 - q_direction->band_data[j].energy_ratio_index_mod[0] + coding_subbands / MASA_FACTOR_CV_COH;
#endif
            }
            no_cv_vec[j] = idx_ER + 1;
        }
@@ -3812,7 +3823,11 @@ static int16_t read_coherence_data(
        if ( byteBuffer & 1 )
        {
            /* decode GR min removed */
#ifdef NONBE_FIX_760_COHERENCE_MASA
            nbits += read_GR_min_removed_data( bitstream, &bit_pos, no_cv_vec, coding_subbands, decoded_idx, MASA_MAX_NO_CV_SUR_COH + extra_cv );
#else
            nbits += read_GR_min_removed_data( bitstream, &bit_pos, no_cv_vec, coding_subbands, decoded_idx, MASA_MAX_NO_CV_SUR_COH );
#endif
            for ( j = 0; j < coding_subbands; j++ )
            {
                if ( no_cv_vec[j] > 1 )