From e6e72aa8a890469d9deb6f0e2c3bcf763b8989cc Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 3 May 2024 21:53:08 +0530 Subject: [PATCH 1/2] alternative to qmetadata penalty calculation --- lib_com/ivas_qmetadata_com.c | 34 ++++++++++++++++++++++++++++++++++ lib_com/options.h | 2 ++ 2 files changed, 36 insertions(+) diff --git a/lib_com/ivas_qmetadata_com.c b/lib_com/ivas_qmetadata_com.c index b7fcd9f66..ac89ed19d 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,34 @@ ivas_error only_reduce_bits_direction_fx( } ELSE { +#ifdef FIX_QMETADATA_PENALTY + FOR( j = 0; j < coding_subbands; j++ ) + { + penalty[j] = 1; + move32(); + FOR( k = 0; k < coding_subbands; k++ ) + { + IF( NE_16(k, j) ) + { + penalty[j] = L_shr( W_extract_l( W_mult_32_16( penalty[j], bits_sph_idx_orig[k][0] ) ), 1 ); + } + } + + tmp = sub( bits_sph_idx_orig[j][0], q_direction->band_data[j].bits_sph_idx[0] ); + FOR( k = 1; k < no_subframes; k++ ) + { + tmp = add( tmp, sub( bits_sph_idx_orig[j][k], q_direction->band_data[j].bits_sph_idx[k] ) ) ; + } + + penalty[j] = L_shr(W_extract_l( W_mult_32_16( penalty[j], tmp )), 1); + } + sort_desc_ind_32_fx( penalty, coding_subbands, ind_order ); + for ( j = 0; j < coding_subbands; j++ ) + { + printf( "%d ", ind_order[j] ); + } + printf( "\n" ); +#else FOR( j = 0; j < coding_subbands; j++ ) { penalty[j] = 0; @@ -669,6 +702,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 366354dc8..b7a13d5bd 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 -- GitLab From c5f570062655365dc1abd9f97d2fc667ad5083be Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 8 May 2024 13:32:07 +0530 Subject: [PATCH 2/2] fix the penalty calculation update --- lib_com/ivas_qmetadata_com.c | 51 +++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/lib_com/ivas_qmetadata_com.c b/lib_com/ivas_qmetadata_com.c index ac89ed19d..538d74c71 100644 --- a/lib_com/ivas_qmetadata_com.c +++ b/lib_com/ivas_qmetadata_com.c @@ -618,32 +618,51 @@ ivas_error only_reduce_bits_direction_fx( ELSE { #ifdef FIX_QMETADATA_PENALTY + + Word16 m, sorted, index1, index2; + FOR( j = 0; j < coding_subbands; j++ ) { - penalty[j] = 1; - move32(); - FOR( k = 0; k < coding_subbands; k++ ) + 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++ ) { - IF( NE_16(k, j) ) + index1 = ind_order[j]; + index2 = ind_order[j + 1]; + tmp = 0; + move16(); + FOR( k = 0; k < no_subframes; k++ ) { - penalty[j] = L_shr( W_extract_l( W_mult_32_16( penalty[j], bits_sph_idx_orig[k][0] ) ), 1 ); + 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] ) ); } - - tmp = sub( bits_sph_idx_orig[j][0], q_direction->band_data[j].bits_sph_idx[0] ); - FOR( k = 1; k < no_subframes; 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] ) ) { - tmp = add( tmp, sub( bits_sph_idx_orig[j][k], q_direction->band_data[j].bits_sph_idx[k] ) ) ; + sorted = 0; + move16(); + ind_order[j] = index2; + move16(); + ind_order[j + 1] = index1; + move16(); } - - penalty[j] = L_shr(W_extract_l( W_mult_32_16( penalty[j], tmp )), 1); } - sort_desc_ind_32_fx( penalty, coding_subbands, ind_order ); - for ( j = 0; j < coding_subbands; j++ ) - { - printf( "%d ", ind_order[j] ); } - printf( "\n" ); + + #else FOR( j = 0; j < coding_subbands; j++ ) { -- GitLab