diff --git a/lib_com/ivas_qmetadata_com.c b/lib_com/ivas_qmetadata_com.c index b7fcd9f668e97167ced27f100b171f5641b77e62..538d74c71e977c864fa3d020acbc40f462fba59c 100644 --- a/lib_com/ivas_qmetadata_com.c +++ b/lib_com/ivas_qmetadata_com.c @@ -526,9 +526,14 @@ ivas_error only_reduce_bits_direction_fx( Word16 *bits_dir0; Word16 bits_sph_idx_orig[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES]; +#ifdef FIX_QMETADATA_PENALTY + Word32 penalty[MASA_MAXIMUM_CODING_SUBBANDS]; + Word16 tmp; +#else Word16 penalty[MASA_MAXIMUM_CODING_SUBBANDS]; Word16 shift, tmp, tmp_e, flag; Word32 tmp_32; +#endif FOR( j = 0; j < coding_subbands; j++ ) { FOR( k = 0; k < no_subframes; k++ ) @@ -612,6 +617,53 @@ ivas_error only_reduce_bits_direction_fx( } ELSE { +#ifdef FIX_QMETADATA_PENALTY + + Word16 m, sorted, index1, index2; + + FOR( j = 0; j < coding_subbands; j++ ) + { + ind_order[j] = j; + move16(); + } + sorted = 0; + move16(); + FOR( m = coding_subbands - 1; m && !sorted; m-- ) + { + sorted = 1; + move16(); + FOR( j = 0; j < m; j++ ) + { + index1 = ind_order[j]; + index2 = ind_order[j + 1]; + tmp = 0; + move16(); + FOR( k = 0; k < no_subframes; k++ ) + { + tmp = add( tmp, sub( bits_sph_idx_orig[index1][k], q_direction->band_data[index1].bits_sph_idx[k] ) ); + } + penalty[0] = L_shr( W_extract_l( W_mult_32_16( tmp, bits_sph_idx_orig[index2][0] ) ), 1 ); + tmp = 0; + move16(); + FOR( k = 0; k < no_subframes; k++ ) + { + tmp = add( tmp, sub( bits_sph_idx_orig[index2][k], q_direction->band_data[index2].bits_sph_idx[k] ) ); + } + penalty[1] = L_shr( W_extract_l( W_mult_32_16( tmp, bits_sph_idx_orig[index1][0] ) ), 1 ); + IF( LT_32( penalty[0], penalty[1] ) ) + { + sorted = 0; + move16(); + ind_order[j] = index2; + move16(); + ind_order[j + 1] = index1; + move16(); + } + } + } + + +#else FOR( j = 0; j < coding_subbands; j++ ) { penalty[j] = 0; @@ -669,6 +721,7 @@ ivas_error only_reduce_bits_direction_fx( } } sort_desc_ind_16_fx( penalty, coding_subbands, ind_order ); +#endif } *reduce_bits_out = negate( reduce_bits ); diff --git a/lib_com/options.h b/lib_com/options.h index 366354dc890d594c3814771366c0b9b3bc016745..b7a13d5bd14fbb5a6bc9b22013092488331ae937 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -121,6 +121,8 @@ #define FIX_ISSUE_723_INFO_TCX_NOISE /*FhG: Issue 723: fix for IGF that introduces wrong noise filling behavion*/ +#define FIX_QMETADATA_PENALTY /* Nokia: transform penalty calculation in qmetadata into integer operations */ + /* ##################### End NON-BE switches ########################### */ #define FIX_740_HQ_CORE_OVA // Proposed fix to solve overlap and add issue for HQ_CORE #define FIX_746 // proposed fix to solve low bit-rate frame boundaries issues