Commit 028d6837 authored by lintervo's avatar lintervo
Browse files

Merge branch '2186_change_object_editing_gain_limitation' into 'main'

[non-BE][allow regression] Add object editing gain limitations as agreed.

See merge request !2518
parents c885e400 c6ad3409
Loading
Loading
Loading
Loading
Loading
+13 −4
Original line number Diff line number Diff line
@@ -202,6 +202,15 @@ typedef enum
#define MAX_SPAR_INTERNAL_CHANNELS              IVAS_SPAR_MAX_CH
#define MAX_CLDFB_DIGEST_CHANNELS               3                           /* == maximum of ParamISM TCs and ParamMC TCs */

#ifdef FIX_GAIN_EDIT_LIMITS
#define EDIT_GAIN_MIN_Q29                       33874260                    /* Minimum allowed object gain edit with parametric modes in Q29: 0.0630957f, -24 dB */
#define EDIT_GAIN_MAX_Q29                       2137321728                  /* Maximum allowed object gain edit in Q29: 3.9810719f,  +12 dB */
#define EDIT_GAIN_MIN_Q12                       258                         /* Minimum allowed object gain edit with parametric modes in Q12: 0.0630957f, -24 dB */
#define EDIT_GAIN_MAX_Q12                       16306                       /* Maximum allowed object gain edit in Q12: 3.9810719f,  +12 dB */
#endif



typedef enum
{
    TC_BUFFER_MODE_RENDERER,
@@ -1266,10 +1275,10 @@ enum
#define MASA_MAXIMUM_TWO_DIR_BANDS              24
#define NBITS_HR_COH                            4
#define OMASA_TDREND_MATCHING_GAIN_FX 26026
//TODO: insert proper Q representations
#define OMASA_GAIN_EDIT_THR_FX                  246                         /* OMASA gain change threshold, 0.06f in Q12 */
#define OMASA_AZI_EDIT_THR_FX                   ONE_IN_Q22                  /* OMASA-DISC azimuth change threshold, 1.0f in Q22 */
#define OMASA_ELE_EDIT_THR_FX                   ONE_IN_Q23                  /* OMASA-DISC elevation change threshold, 2.0f in Q22 */

#define OMASA_GAIN_EDIT_THR_Q12                 246                         /* OMASA gain change threshold, 0.06f in Q12 */
#define OMASA_AZI_EDIT_THR_Q22                  ONE_IN_Q22                  /* OMASA-DISC azimuth change threshold, 1.0f in Q22 */
#define OMASA_ELE_EDIT_THR_Q22                  ONE_IN_Q23                  /* OMASA-DISC elevation change threshold, 2.0f in Q22 */

#define MASA_INV_ANGLE_AT_EQUATOR_DEG_Q30       1453366656l                 /* 1.353553128183453f in Q30 */

+1 −0
Original line number Diff line number Diff line
@@ -90,6 +90,7 @@
#define FIX_2170_ASSERT_IN_FFT3                              /* Eri: Assert in fft3_fx from EVS, adding _sat */
#define FIX_2082_FP_LEFTOVERS_OMASA_DEC                      /* Nokia: fix for issue 2082, cleaning remaining floating point code */
#define FIX_2174_JBM_BASOP_ALIGNMENT                         /* VoiceAge, Nokia: Fixes to JBM BASOP implementation and alignment to float */
#define FIX_GAIN_EDIT_LIMITS                                 /* Harmonize gain edit limits for all opertation points. For all modes, limit to max +12dB. For parametric modes, limit to min -24dB. */

#define FIX_2176_ASSERT_DEC_MAP_PARAMS_DIRAC2STEREO          /* FhG: Reduce hStereoDft->q_smooth_buf_fx by one to prevent overflow in the subframe_band_nrg[][] calculation */
#define FIX_2015_PREMPH_SAT_ALT                              /* VA: saturation can happen during preemphasis filtering due to a too aggressive scaling factor, allows preemphis to get 1 more bit headroom */
+114 −13
Original line number Diff line number Diff line
@@ -4182,7 +4182,7 @@ ivas_error IVAS_DEC_GetEditableParameters(
                move32();
                hIvasEditableParameters->ism_metadata[obj].radius_fx = 0;
                move16();
                hIvasEditableParameters->ism_metadata[obj].gain_fx = ONE_IN_Q29; // TODO check Q-value
                hIvasEditableParameters->ism_metadata[obj].gain_fx = ONE_IN_Q29;
                move32();
                hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = 0;
                move16();
@@ -4344,16 +4344,42 @@ ivas_error IVAS_DEC_SetEditableParameters(
                move32();
                st_ivas->hIsmMetaData[obj]->edited_pitch_fx = hIvasEditableParameters.ism_metadata[obj].pitch_fx;
                move32();
#ifdef FIX_GAIN_EDIT_LIMITS
                IF( GT_32( hIvasEditableParameters.ism_metadata[obj].gain_fx, EDIT_GAIN_MAX_Q29 ) )
                {
                    st_ivas->hIsmMetaData[obj]->edited_gain_fx = EDIT_GAIN_MAX_Q29;
                    move32();
                }
                ELSE
                {
                    st_ivas->hIsmMetaData[obj]->edited_gain_fx = hIvasEditableParameters.ism_metadata[obj].gain_fx;
                    move32();
                }
#else
                st_ivas->hIsmMetaData[obj]->edited_gain_fx = hIvasEditableParameters.ism_metadata[obj].gain_fx;
                move32();
#endif
                st_ivas->hIsmMetaData[obj]->non_diegetic_flag = hIvasEditableParameters.ism_metadata[obj].non_diegetic_flag;
                move16();
            }

            IF( EQ_32( ism_mode, ISM_SBA_MODE_DISC ) )
            {
#ifdef FIX_GAIN_EDIT_LIMITS
                IF( GT_32( hIvasEditableParameters.gain_bed_fx, EDIT_GAIN_MAX_Q29 ) )
                {
                    st_ivas->hSbaIsmData->gain_bed_fx = EDIT_GAIN_MAX_Q29;
                    move32();
                }
                ELSE
                {
                    st_ivas->hSbaIsmData->gain_bed_fx = hIvasEditableParameters.gain_bed_fx;
                    move32();
                }
#else
                st_ivas->hSbaIsmData->gain_bed_fx = hIvasEditableParameters.gain_bed_fx;
                move32();
#endif
            }
        }
        ELSE IF( EQ_32( ism_mode, ISM_MODE_PARAM ) )
@@ -4369,12 +4395,31 @@ ivas_error IVAS_DEC_SetEditableParameters(
                move32();
                IF( st_ivas->hMasaIsmData != NULL )
                {
#ifdef FIX_GAIN_EDIT_LIMITS
                    /* Limit gain edit to a range of +12dB to -24dB with parametric ISM mode */
                    IF( GT_32( hIvasEditableParameters.gain_bed_fx, EDIT_GAIN_MAX_Q29 ) )
                    {
                        st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = EDIT_GAIN_MAX_Q12; // Q12
                        move16();
                    }
                    ELSE IF( LT_32( hIvasEditableParameters.gain_bed_fx, EDIT_GAIN_MIN_Q29 ) )
                    {
                        st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = EDIT_GAIN_MIN_Q12; // Q12
                        move16();
                    }
                    ELSE
                    {
                        st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = shr( extract_h( hIvasEditableParameters.ism_metadata[obj].gain_fx ), Q1 ); // Q29 -> Q12
                        move16();
                    }
#else
                    st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = shr( extract_h( hIvasEditableParameters.ism_metadata[obj].gain_fx ), Q1 ); // Q29 -> Q12
                    move32();
#endif

                    /* Detect direction editing in Param-ISM mode  */
                    IF( GT_32( L_abs( L_sub( st_ivas->hParamIsmDec->azimuth_values_fx[obj], hIvasEditableParameters.ism_metadata[obj].azimuth_fx ) ), OMASA_AZI_EDIT_THR_FX ) ||
                        GT_32( L_abs( L_sub( st_ivas->hParamIsmDec->elevation_values_fx[obj], hIvasEditableParameters.ism_metadata[obj].elevation_fx ) ), OMASA_ELE_EDIT_THR_FX ) )
                    IF( GT_32( L_abs( L_sub( st_ivas->hParamIsmDec->azimuth_values_fx[obj], hIvasEditableParameters.ism_metadata[obj].azimuth_fx ) ), OMASA_AZI_EDIT_THR_Q22 ) ||    // | azi_orig[obj] - azi_edit[obj] | > azi_threshold
                        GT_32( L_abs( L_sub( st_ivas->hParamIsmDec->elevation_values_fx[obj], hIvasEditableParameters.ism_metadata[obj].elevation_fx ) ), OMASA_ELE_EDIT_THR_Q22 ) ) // | ele_orig[obj] - ele_edit[obj] | > ele_threshold
                    {
                        st_ivas->hMasaIsmData->ism_dir_is_edited[obj] = 1;
                    }
@@ -4385,7 +4430,7 @@ ivas_error IVAS_DEC_SetEditableParameters(
                    move16();

                    /* Detect gain editing in Param-ISM mode */
                    IF( GT_16( abs_s( sub( ONE_IN_Q12, shr( extract_h( hIvasEditableParameters.ism_metadata[obj].gain_fx ), Q1 ) ) ), OMASA_GAIN_EDIT_THR_FX ) ) // TODO: check Q values
                    IF( GT_16( abs_s( sub( ONE_IN_Q12, shr( extract_h( hIvasEditableParameters.ism_metadata[obj].gain_fx ), Q1 ) ) ), OMASA_GAIN_EDIT_THR_Q12 ) ) // | 1.0f - gain_edit[obj] | > gain_threshold
                    {
                        st_ivas->hMasaIsmData->ism_gain_is_edited[obj] = 1;
                    }
@@ -4469,8 +4514,8 @@ ivas_error IVAS_DEC_SetEditableParameters(
                    threshold_ele = delta_theta_masa_fx[st_ivas->hMasaIsmData->bits_ism[obj] - 3];

                    test();
                    IF( ( GT_32( L_shl( abs_s( sub( new_azi, st_ivas->hMasaIsmData->azimuth_ism_fx[obj][dirac_read_idx] ) ), 22 ), threshold_azi ) ) ||
                        ( GT_32( L_shl( abs_s( sub( new_ele, st_ivas->hMasaIsmData->elevation_ism_fx[obj][dirac_read_idx] ) ), 22 ), threshold_ele ) ) )
                    IF( ( GT_32( L_shl( abs_s( sub( new_azi, st_ivas->hMasaIsmData->azimuth_ism_fx[obj][dirac_read_idx] ) ), 22 ), threshold_azi ) ) ||  // | azi_edit[obj] - azi_orig[obj] | > azi_threshold
                        ( GT_32( L_shl( abs_s( sub( new_ele, st_ivas->hMasaIsmData->elevation_ism_fx[obj][dirac_read_idx] ) ), 22 ), threshold_ele ) ) ) // | ele_edit[obj] - ele_orig[obj] | > ele_threshold
                    {
                        /* at least one of the threshold is exceeded, so use new direction value and set editing detection flag */
                        st_ivas->hMasaIsmData->azimuth_ism_edited_fx[obj] = new_azi;
@@ -4490,8 +4535,8 @@ ivas_error IVAS_DEC_SetEditableParameters(
                {
                    /* detect editing in ISM_MASA_MODE_DISC mode */
                    test();
                    IF( L_abs( L_sub( st_ivas->hIsmMetaData[obj]->azimuth_fx, hIvasEditableParameters.ism_metadata[obj].azimuth_fx ) ) > OMASA_AZI_EDIT_THR_FX ||
                        L_abs( L_sub( st_ivas->hIsmMetaData[obj]->elevation_fx, hIvasEditableParameters.ism_metadata[obj].elevation_fx ) ) > OMASA_ELE_EDIT_THR_FX )
                    IF( L_abs( L_sub( st_ivas->hIsmMetaData[obj]->azimuth_fx, hIvasEditableParameters.ism_metadata[obj].azimuth_fx ) ) > OMASA_AZI_EDIT_THR_Q22 ||    // | azi_orig[obj] - azi_edit[obj] | > azi_threshold
                        L_abs( L_sub( st_ivas->hIsmMetaData[obj]->elevation_fx, hIvasEditableParameters.ism_metadata[obj].elevation_fx ) ) > OMASA_ELE_EDIT_THR_Q22 ) // | ele_orig[obj] - ele_edit[obj] | > ele_threshold
                    {
                        st_ivas->hMasaIsmData->azimuth_ism_edited_fx[obj] = new_azi;
                        move32();
@@ -4508,11 +4553,31 @@ ivas_error IVAS_DEC_SetEditableParameters(
                }

                /* compare pre-edit gain and the edited one to detect editing */
                IF( GT_16( abs_s( sub( shr( extract_h( st_ivas->hIsmMetaData[obj]->edited_gain_fx ), Q1 ), shr( extract_h( hIvasEditableParameters.ism_metadata[obj].gain_fx ), Q1 ) ) ), OMASA_GAIN_EDIT_THR_FX ) ) // TODO: check incoming Q value
                IF( GT_16( abs_s( sub( shr( extract_h( st_ivas->hIsmMetaData[obj]->edited_gain_fx ), Q1 ), shr( extract_h( hIvasEditableParameters.ism_metadata[obj].gain_fx ), Q1 ) ) ), OMASA_GAIN_EDIT_THR_Q12 ) ) // | gain_edit[obj] - gain_orig[obj] | > gain_threshold
                {
                    st_ivas->hMasaIsmData->ism_gain_is_edited[obj] = 1;
#ifdef FIX_GAIN_EDIT_LIMITS
                    /* Limit gain edit to a range of +12dB to -24dB with parametric OMASA mode */
                    test();
                    IF( GT_32( hIvasEditableParameters.ism_metadata[obj].gain_fx, EDIT_GAIN_MAX_Q29 ) )
                    {
                        st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = EDIT_GAIN_MAX_Q12;
                        move16();
                    }
                    ELSE IF( EQ_16( ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) && LT_32( hIvasEditableParameters.ism_metadata[obj].gain_fx, EDIT_GAIN_MIN_Q29 ) )
                    {
                        st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = EDIT_GAIN_MIN_Q12;
                        move16();
                    }
                    ELSE
                    {
                        st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = shr( extract_h( hIvasEditableParameters.ism_metadata[obj].gain_fx ), Q1 ); // Q29 --> Q12
                        move16();
                    }
#else
                    st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = shr( extract_h( hIvasEditableParameters.ism_metadata[obj].gain_fx ), Q1 ); // Q29 --> Q12
                    move16();
#endif
                }
                ELSE
                {
@@ -4546,17 +4611,53 @@ ivas_error IVAS_DEC_SetEditableParameters(
                st_ivas->hIsmMetaData[obj]->radius_fx = hIvasEditableParameters.ism_metadata[obj].radius_fx;
                move32();
#endif
                st_ivas->hIsmMetaData[obj]->edited_gain_fx = hIvasEditableParameters.ism_metadata[obj].gain_fx; // TODO: check incoming Q value
#ifdef FIX_GAIN_EDIT_LIMITS
                test();
                IF( GT_32( hIvasEditableParameters.ism_metadata[obj].gain_fx, EDIT_GAIN_MAX_Q29 ) )
                {
                    st_ivas->hIsmMetaData[obj]->edited_gain_fx = EDIT_GAIN_MAX_Q29;
                }
                ELSE IF( EQ_16( ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) && LT_32( hIvasEditableParameters.ism_metadata[obj].gain_fx, EDIT_GAIN_MIN_Q29 ) )
                {
                    st_ivas->hIsmMetaData[obj]->edited_gain_fx = EDIT_GAIN_MIN_Q29;
                }
                ELSE
                {
                    st_ivas->hIsmMetaData[obj]->edited_gain_fx = hIvasEditableParameters.ism_metadata[obj].gain_fx;
                }
#else
                st_ivas->hIsmMetaData[obj]->edited_gain_fx = hIvasEditableParameters.ism_metadata[obj].gain_fx;
                move32();
#endif
                st_ivas->hIsmMetaData[obj]->non_diegetic_flag = hIvasEditableParameters.ism_metadata[obj].non_diegetic_flag;
                move16();
            }
        }

        IF( GT_16( abs_s( sub( shr( extract_h( hIvasEditableParameters.gain_bed_fx ), Q1 ), ONE_IN_Q12 ) ), OMASA_GAIN_EDIT_THR_FX ) ) // TODO: check Q value
        IF( GT_16( abs_s( sub( shr( extract_h( hIvasEditableParameters.gain_bed_fx ), Q1 ), ONE_IN_Q12 ) ), OMASA_GAIN_EDIT_THR_Q12 ) ) // | gain_bed - 1.0f | > gain_threshold
        {
#ifdef FIX_GAIN_EDIT_LIMITS
            /* Limit gain edit to a range of +12dB to -24dB with parametric OMASA mode */
            test();
            IF( GT_32( hIvasEditableParameters.gain_bed_fx, EDIT_GAIN_MAX_Q29 ) )
            {
                st_ivas->hMasaIsmData->gain_masa_edited_fx = EDIT_GAIN_MAX_Q12;
                move16();
            }
            ELSE IF( EQ_16( ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) && LT_32( hIvasEditableParameters.gain_bed_fx, EDIT_GAIN_MIN_Q29 ) )
            {
                st_ivas->hMasaIsmData->gain_masa_edited_fx = EDIT_GAIN_MIN_Q12;
                move16();
            }
            ELSE
            {
            st_ivas->hMasaIsmData->gain_masa_edited_fx = shr( extract_h( hIvasEditableParameters.gain_bed_fx ), Q1 ); // TODO: check type
                st_ivas->hMasaIsmData->gain_masa_edited_fx = shr( extract_h( hIvasEditableParameters.gain_bed_fx ), Q1 );
                move16();
            }
#else
            st_ivas->hMasaIsmData->gain_masa_edited_fx = shr( extract_h( hIvasEditableParameters.gain_bed_fx ), Q1 );
            move32();
#endif
            st_ivas->hMasaIsmData->masa_gain_is_edited = 1;
        }
        ELSE
+7 −0
Original line number Diff line number Diff line
@@ -41,10 +41,17 @@ the United Nations Convention on Contracts on the International Sales of Goods.
 * Constants ans structures
 *---------------------------------------------------------------------*/

#ifdef FIX_GAIN_EDIT_LIMITS
#define OBJ_EDIT_GAIN_MIN_FX 0          /* Q29, 0.0f, -inf dB */
#define OBJ_EDIT_GAIN_MAX_FX 2137321728 /* Q29, 3.9810719f,  +12 dB */
#define OBJ_EDIT_GAIN_MIN    0.0f       /* -inf dB */
#define OBJ_EDIT_GAIN_MAX    3.9810719f /* +12 dB */
#else
#define OBJ_EDIT_GAIN_MIN_FX 33874262    /* Q29, 0.06309573f, -24 dB */
#define OBJ_EDIT_GAIN_MAX_FX 2127207375  /* Q29, 3.9622325f,  +12 dB, TODO: align with float */
#define OBJ_EDIT_GAIN_MIN    0.06309573f /* -24 dB */
#define OBJ_EDIT_GAIN_MAX    3.9622325f  /* +12 dB */
#endif

typedef struct ObjectEditFileReader ObjectEditFileReader;
typedef struct ReadObjectEditInfo ReadObjectEditInfo;