Commit 5e008193 authored by Jan Kiene's avatar Jan Kiene
Browse files

Accept FIX_FLOAT_1578_OMASA_REND_SPIKES

parent b2ceb7b6
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -1256,12 +1256,8 @@ typedef enum
{
    MASA_STEREO_NOT_DEFINED,
    MASA_STEREO_SPACED_MICS,
#ifdef FIX_FLOAT_1578_OMASA_REND_SPIKES
    MASA_STEREO_DOWNMIX,
    MASA_DUAL_MONO
#else
    MASA_STEREO_DOWNMIX
#endif
} MASA_TRANSPORT_SIGNAL_TYPE;

typedef enum
+0 −1
Original line number Diff line number Diff line
@@ -100,7 +100,6 @@

#define FIX_1576_LCLD_CRASH_DIFFERENT_CODEC_ISAR_FRAME_SIZE  /* Dolby: float issue 1576: fix for crash in LCLD mode when codec frame size is less than isar frame size */
#define NONBE_FIX_ISSUE_2206_MDCT_STEREO_FIX_2549       /* FhG: Correct scale inconsistency of old_inp_16k_fx buffer scale. */
#define FIX_FLOAT_1578_OMASA_REND_SPIKES                /* Nokia: Float issue 1578: Fix spikes and collapsed perception in OMASA/MASA rendering to FOA/HOA */
#define FIX_1521_SBA_LOUDNESS_STEREO                    /* FhG: issue 1521: Fix loudness for SBA to stereo rendering */
#define FIX_1559                                        /* Eri/FhG: fix for Issue 1559 in FD CNG with bitrate/bw switching */
#define FIX_BASOP_2571_MASA_EXT_RENDER_FIXES            /* Nokia: BASOP issue 2571: Fix MASA EXT DirAC renderer by unifying it with decoder */
+0 −4
Original line number Diff line number Diff line
@@ -364,11 +364,7 @@ static ivas_error ivas_dirac_rend_config_fx(
                return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) );
            }
        }
#ifdef FIX_FLOAT_1578_OMASA_REND_SPIKES
        ivas_masa_init_stereotype_detection_fx( hDirACRend->masa_stereo_type_detect, ivas_total_brate );
#else
        ivas_masa_init_stereotype_detection_fx( hDirACRend->masa_stereo_type_detect );
#endif
    }
    ELSE
    {
+0 −2
Original line number Diff line number Diff line
@@ -3001,14 +3001,12 @@ void ivas_dirac_dec_compute_directional_responses_fx(
                                move32();
                            }
                        }
#ifdef FIX_FLOAT_1578_OMASA_REND_SPIKES
                        ELSE IF( EQ_16( transport_signal_type, MASA_DUAL_MONO ) )
                        {
                            direct_response_fx[0] = ONE_IN_Q29; /*q29*/
                            move32();
                            /* direct_response[1] is not adjusted for dual mono input */
                        }
#endif
                        ELSE
                        {
                            set32_fx( direct_response_fx, ONE_IN_Q29, hDirACRend->num_protos_ambi ); /*q29*/
+0 −147
Original line number Diff line number Diff line
@@ -41,7 +41,6 @@
#include "ivas_prot_fx.h"
#include "ivas_rom_binaural_crend_head.h"

#ifdef FIX_FLOAT_1578_OMASA_REND_SPIKES
/*------------------------------------------------------------------------------------------*
 * Local constants
 *------------------------------------------------------------------------------------------*/
@@ -49,7 +48,6 @@
/* Constants for MASA dual mono detection */
#define MASA_DUAL_MONO_TAU1_FX 33554432 /* Q31, float 0.01562500000000000f, which is 2^-6, which is about -18 dB */
#define MASA_DUAL_MONO_TAU2_FX 16384    /* Q31, float 0.00000762939453125f, which is 2^-17, which is about -51 dB */
#endif

/*-------------------------------------------------------------------------
 * ivas_dirac_allocate_parameters()
@@ -1730,16 +1728,11 @@ void protoSignalComputation2_fx(
    Word16 q_sum_total_ratio = 0;
    move16();
    Word32 a_fx, b_fx, a2_fx, b2_fx;
#ifdef FIX_FLOAT_1578_OMASA_REND_SPIKES
    Word16 interpolatorSpaced_fx, interpolatorDmx_fx, interpolatorDualMono_fx;
    Word32 tempSpaced_fx, tempDmx_fx, tempDualMono_fx;
    Word64 inst_diff_bb_power_64fx;
    Word16 inst_diff_bb_power_norm;
    Word16 max_band_diff_ene;
#else
    Word16 interpolatorSpaced_fx, interpolatorDmx_fx;
    Word32 tempSpaced_fx, tempDmx_fx;
#endif
    Word16 q_shift, min_q_shift[2], exp, q_temp[2];
    Word32 temp;
    Word64 W_tmp1, W_tmp2, W_tmp3;
@@ -1760,7 +1753,6 @@ void protoSignalComputation2_fx(
    move16();
    interpolatorDmx_fx = MAX16B;
    move16();
#ifdef FIX_FLOAT_1578_OMASA_REND_SPIKES
    interpolatorDualMono_fx = 0;
    move16();

@@ -1770,7 +1762,6 @@ void protoSignalComputation2_fx(
    {
        max_band_diff_ene = s_min( stereo_type_detect->max_band_diff_ene, num_freq_bands ); /* Local version for correct maximum */
    }
#endif

    /* Calculate the max shift possible for the buffers RealBuffer_fx and ImagBuffer_fx */
    FOR( l = 0; l < 2; l++ )
@@ -1943,7 +1934,6 @@ void protoSignalComputation2_fx(
        total_hi_power_fx = 0;
        move32();

#ifdef FIX_FLOAT_1578_OMASA_REND_SPIKES
        inst_diff_bb_power_64fx = 0;
        move64();

@@ -1957,7 +1947,6 @@ void protoSignalComputation2_fx(
        stereo_type_detect->q_inst_total_bb_power_fx = Q31;
        move16();

#endif
        dipole_freq_range[0] = stereo_type_detect->dipole_freq_range[0];
        move16();
        dipole_freq_range[1] = stereo_type_detect->dipole_freq_range[1];
@@ -1978,12 +1967,9 @@ void protoSignalComputation2_fx(
                /* interpolatorSpaced = ( (float) ( stereo_type_detect->interpolator ) ) / ( (float) MASA_STEREO_INTERPOLATION_SLOTS ); */
                interpolatorSpaced_fx = i_mult_sat( stereo_type_detect->interpolator, 2048 /* 1 / MASA_STEREO_INTERPOLATION_SLOTS in Q15 */ ); /* Q15 */
                interpolatorDmx_fx = sub( MAX16B, interpolatorSpaced_fx );                                                                     /* Q15 */
#ifdef FIX_FLOAT_1578_OMASA_REND_SPIKES
                interpolatorDualMono_fx = interpolatorDmx_fx;
                move16();
#endif
            }
#ifdef FIX_FLOAT_1578_OMASA_REND_SPIKES
            ELSE IF( EQ_16( stereo_type_detect->type_change_direction, MASA_DUAL_MONO ) )
            {
                /* interpolatorDualMono = ( (float) ( stereo_type_detect->interpolator ) ) / ( (float) MASA_STEREO_INTERPOLATION_SLOTS ); */
@@ -1992,16 +1978,13 @@ void protoSignalComputation2_fx(
                interpolatorSpaced_fx = interpolatorDmx_fx;
                move16();
            }
#endif
            ELSE
            {
                /* interpolatorDmx = ( (float) ( stereo_type_detect->interpolator ) ) / ( (float) MASA_STEREO_INTERPOLATION_SLOTS ); */
                interpolatorDmx_fx = i_mult_sat( stereo_type_detect->interpolator, 2048 /* 1 / MASA_STEREO_INTERPOLATION_SLOTS in Q15 */ ); /* Q15 */
                interpolatorSpaced_fx = sub( MAX16B, interpolatorDmx_fx );                                                                  /* Q15 */
#ifdef FIX_FLOAT_1578_OMASA_REND_SPIKES
                interpolatorDualMono_fx = interpolatorSpaced_fx;
                move16();
#endif
            }
        }

@@ -2142,7 +2125,6 @@ void protoSignalComputation2_fx(
                q_sum_total_ratio = s_max( q_sum_total_ratio, exp_sum_total_ratio_fx[l] );
            }

#ifdef FIX_FLOAT_1578_OMASA_REND_SPIKES
            RealSubtract_fx = L_sub( re1, re2 ); // q_cldfb+min_q_shift
            ImagSubtract_fx = L_sub( im1, im2 ); // q_cldfb+min_q_shift

@@ -2179,80 +2161,12 @@ void protoSignalComputation2_fx(
                    }
                }
            }
#else
            IF( l == 0 )
            {
                RealSubtract_fx = L_sub( re1, re2 ); // q_cldfb+min_q_shift
                ImagSubtract_fx = L_sub( im1, im2 ); // q_cldfb+min_q_shift

                temp = Madd_32_32( Mpy_32_32( RealSubtract_fx, RealSubtract_fx ), ImagSubtract_fx, ImagSubtract_fx ); // 2*(q_cldfb+min_q_shift)-31
                assert( qidx == 0 );
                IF( LT_16( q_temp[qidx], stereo_type_detect->q_subtract_power_y ) )
                {
                    stereo_type_detect->subtract_power_y_fx = L_add( L_shr( stereo_type_detect->subtract_power_y_fx, sub( stereo_type_detect->q_subtract_power_y, q_temp[qidx] ) ), temp ); // q_temp
                    move32();
                    stereo_type_detect->q_subtract_power_y = q_temp[qidx];
                    move16();
                }
                ELSE
                {
                    stereo_type_detect->subtract_power_y_fx = L_add( stereo_type_detect->subtract_power_y_fx, L_shr( temp, sub( q_temp[qidx], stereo_type_detect->q_subtract_power_y ) ) ); // stereo_type_detect->q_subtract_power_y
                    move32();
                }
            }
#endif

            /* Compute protos (and their power) for direct sound rendering */

            /* W prototype */
            IF( stereo_type_detect->interpolator > 0 )
            {
#ifndef FIX_FLOAT_1578_OMASA_REND_SPIKES
                IF( L_or( LT_16( l, sub( dipole_freq_range[1], 1 ) ), GE_16( l, MASA_SUM_PROTO_START_BIN ) ) )
                {
                    Real_aux_fx = Madd_32_16( Mpy_32_16_1( Real_aux_fx, shr( interpolatorSpaced_fx, 1 ) ), Real_aux_fx, interpolatorDmx_fx ); // q_cldfb+min_q_shift
                    Imag_aux_fx = Madd_32_16( Mpy_32_16_1( Imag_aux_fx, shr( interpolatorSpaced_fx, 1 ) ), Imag_aux_fx, interpolatorDmx_fx ); // q_cldfb+min_q_shift

                    temp = Madd_32_32( Mpy_32_32( Real_aux_fx, Real_aux_fx ), Imag_aux_fx, Imag_aux_fx ); // 2*(q_cldfb+min_q_shift) -31
                    IF( LT_16( q_temp[qidx], q_proto_power_smooth[qidx] ) )
                    {
                        proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( q_proto_power_smooth[qidx], q_temp[qidx] ) ), temp ); // q_temp
                        move32();
                    }
                    ELSE
                    {
                        proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( temp, sub( q_temp[qidx], q_proto_power_smooth[qidx] ) ) ); // q_proto_power_smooth
                        move32();
                    }

                    p_proto_buffer_fx[2 * l] = Real_aux_fx; // q_cldfb+min_q_shift
                    move32();
                    p_proto_buffer_fx[2 * l + 1] = Imag_aux_fx; // q_cldfb+min_q_shift
                    move32();
                }
                ELSE
                {
                    tempSpaced_fx = Madd_32_32( Mpy_32_32( re1, re1 ), im1, im1 );                              // 2*(q_cldfb+min_q_shift)-31
                    tempDmx_fx = Madd_32_32( Mpy_32_32( Real_aux_fx, Real_aux_fx ), Imag_aux_fx, Imag_aux_fx ); // 2*(q_cldfb+min_q_shift)-31

                    temp = Madd_32_16( Mpy_32_16_1( tempSpaced_fx, interpolatorSpaced_fx ), tempDmx_fx, interpolatorDmx_fx ); // 2*(q_cldfb+min_q_shift)-31
                    IF( LT_16( q_temp[qidx], q_proto_power_smooth[qidx] ) )
                    {
                        proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( q_proto_power_smooth[qidx], q_temp[qidx] ) ), temp ); // q_temp
                        move32();
                    }
                    ELSE
                    {
                        proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( temp, sub( q_temp[qidx], q_proto_power_smooth[qidx] ) ) ); // q_proto_power_smooth
                        move32();
                    }

                    p_proto_buffer_fx[2 * l] = Madd_32_16( Mpy_32_16_1( re1, interpolatorSpaced_fx ), Real_aux_fx, interpolatorDmx_fx ); // q_cldfb+min_q_shift
                    move32();
                    p_proto_buffer_fx[2 * l + 1] = Madd_32_16( Mpy_32_16_1( im1, interpolatorSpaced_fx ), Imag_aux_fx, interpolatorDmx_fx ); // q_cldfb+min_q_shift
                    move32();
                }
#else
                test();
                test();
                test();
@@ -2383,7 +2297,6 @@ void protoSignalComputation2_fx(
                    p_proto_buffer_fx[2 * l + 1] = Imag_aux_fx; // q_cldfb+min_q_shift
                    move32();
                }
#endif
            }
            ELSE IF( EQ_16( stereo_type_detect->masa_stereo_type, MASA_STEREO_SPACED_MICS ) )
            {
@@ -2429,7 +2342,6 @@ void protoSignalComputation2_fx(
                    move32();
                }
            }
#ifdef FIX_FLOAT_1578_OMASA_REND_SPIKES
            ELSE IF( EQ_16( stereo_type_detect->masa_stereo_type, MASA_DUAL_MONO ) )
            {
                Real_aux_fx = L_shr( Real_aux_fx, 1 );                                                // q_cldfb+min_q_shift
@@ -2452,9 +2364,6 @@ void protoSignalComputation2_fx(
                move32();
            }
            ELSE /* MASA_STEREO_DOWNMIX */
#else
            ELSE
#endif
            {
                temp = Madd_32_32( Mpy_32_32( Real_aux_fx, Real_aux_fx ), Imag_aux_fx, Imag_aux_fx ); // 2*(q_cldfb+min_q_shift)-31
                IF( LT_16( q_temp[qidx], q_proto_power_smooth[qidx] ) )
@@ -2477,41 +2386,6 @@ void protoSignalComputation2_fx(
            /* Y prototype */
            IF( stereo_type_detect->interpolator > 0 )
            {
#ifndef FIX_FLOAT_1578_OMASA_REND_SPIKES
                IF( LT_16( l, dipole_freq_range[0] ) )
                {
                    p_proto_buffer_fx[2 * ( num_freq_bands + l )] = Madd_32_16( Mpy_32_16_1( p_proto_buffer_fx[2 * l], interpolatorSpaced_fx ), L_sub( re1, re2 ), interpolatorDmx_fx ); // q_cldfb+min_q_shift
                    move32();
                    p_proto_buffer_fx[2 * ( num_freq_bands + l ) + 1] = Madd_32_16( Mpy_32_16_1( p_proto_buffer_fx[2 * l + 1], interpolatorSpaced_fx ), L_sub( im1, im2 ), interpolatorDmx_fx ); // q_cldfb+min_q_shift
                    move32();
                }
                ELSE IF( LT_16( l, dipole_freq_range[1] ) )
                {
                    p_proto_buffer_fx[2 * ( num_freq_bands + l )] = Madd_32_16( Mpy_32_16_1( L_sub( im1, im2 ), interpolatorSpaced_fx ), L_sub( re1, re2 ), interpolatorDmx_fx ); // q_cldfb+min_q_shift
                    move32();
                    p_proto_buffer_fx[2 * ( num_freq_bands + l ) + 1] = Madd_32_16( Mpy_32_16_1( -L_sub( re1, re2 ), interpolatorSpaced_fx ), L_sub( im1, im2 ), interpolatorDmx_fx ); // q_cldfb+min_q_shift
                    move32();
                }
                ELSE
                {
                    p_proto_buffer_fx[2 * ( num_freq_bands + l )] = Madd_32_16( Mpy_32_16_1( p_proto_buffer_fx[2 * l], interpolatorSpaced_fx ), L_sub( re1, re2 ), interpolatorDmx_fx ); // q_cldfb+min_q_shift
                    move32();
                    p_proto_buffer_fx[2 * ( num_freq_bands + l ) + 1] = Madd_32_16( Mpy_32_16_1( p_proto_buffer_fx[2 * l + 1], interpolatorSpaced_fx ), L_sub( im1, im2 ), interpolatorDmx_fx ); // q_cldfb+min_q_shift
                    move32();
                }

                temp = Madd_32_32( Mpy_32_32( p_proto_buffer_fx[2 * ( num_freq_bands + l )], p_proto_buffer_fx[2 * ( num_freq_bands + l )] ), p_proto_buffer_fx[2 * ( num_freq_bands + l ) + 1], p_proto_buffer_fx[2 * ( num_freq_bands + l ) + 1] ); // 2*(q_cldfb+min_q_shift)-31
                IF( LT_16( q_temp[qidx], q_proto_power_smooth[qidx] ) )
                {
                    proto_power_smooth_fx[l + num_freq_bands] = L_add( L_shr( proto_power_smooth_fx[l + num_freq_bands], sub( q_proto_power_smooth[qidx], q_temp[qidx] ) ), temp ); // q_temp
                    move32();
                }
                ELSE
                {
                    proto_power_smooth_fx[l + num_freq_bands] = L_add( proto_power_smooth_fx[l + num_freq_bands], L_shr( temp, sub( q_temp[qidx], q_proto_power_smooth[qidx] ) ) ); // q_proto_power_smooth
                    move32();
                }
#else
                test();
                test();
                test();
@@ -2587,7 +2461,6 @@ void protoSignalComputation2_fx(
                    proto_power_smooth_fx[l + num_freq_bands] = L_add( proto_power_smooth_fx[l + num_freq_bands], L_shr( temp, sub( q_temp[qidx], q_proto_power_smooth[qidx] ) ) ); // q_proto_power_smooth
                    move32();
                }
#endif
            }
            ELSE IF( EQ_16( stereo_type_detect->masa_stereo_type, MASA_STEREO_SPACED_MICS ) )
            {
@@ -2629,7 +2502,6 @@ void protoSignalComputation2_fx(
                    move32();
                }
            }
#ifdef FIX_FLOAT_1578_OMASA_REND_SPIKES
            ELSE IF( EQ_16( stereo_type_detect->masa_stereo_type, MASA_DUAL_MONO ) )
            {
                /* proto = W */
@@ -2641,9 +2513,6 @@ void protoSignalComputation2_fx(
                move32();
            }
            ELSE /* MASA_STEREO_DOWNMIX */
#else
            ELSE
#endif
            {
                p_proto_buffer_fx[2 * ( num_freq_bands + l )] = L_sub( re1, re2 ); // q_cldfb+min_q_shift
                move32();
@@ -2818,14 +2687,12 @@ void protoSignalComputation2_fx(
        stereo_type_detect->min_sum_total_ratio_db_fx = min_sum_total_ratio_db_fx; // Q21
        move32();

#ifdef FIX_FLOAT_1578_OMASA_REND_SPIKES
        /* Convert inst_diff to Word32 */
        inst_diff_bb_power_norm = W_norm( inst_diff_bb_power_64fx );
        stereo_type_detect->inst_diff_bb_power_fx = W_extract_h( W_shl( inst_diff_bb_power_64fx, inst_diff_bb_power_norm ) );
        move32();
        stereo_type_detect->q_inst_diff_bb_power_fx = add( shl( add( q_cldfb, s_min( min_q_shift[0], min_q_shift[1] ) ), 1 ), sub( inst_diff_bb_power_norm, 32 ) );
        move16();
#endif

        ivas_masa_stereotype_detection_fx( stereo_type_detect );
    }
@@ -3394,12 +3261,8 @@ void computeDirectionAngles_fx(
 *------------------------------------------------------------------------*/

void ivas_masa_init_stereotype_detection_fx(
#ifdef FIX_FLOAT_1578_OMASA_REND_SPIKES
    MASA_STEREO_TYPE_DETECT *stereo_type_detect,
    Word32 ivas_total_brate_fx )
#else
    MASA_STEREO_TYPE_DETECT *stereo_type_detect )
#endif
{
    stereo_type_detect->masa_stereo_type = MASA_STEREO_DOWNMIX;
    move32();
@@ -3471,7 +3334,6 @@ void ivas_masa_init_stereotype_detection_fx(
    move32();
    stereo_type_detect->subtract_target_ratio_db_fx = 0;
    move32();
#ifdef FIX_FLOAT_1578_OMASA_REND_SPIKES

    stereo_type_detect->inst_diff_bb_power_fx = 0;
    move32();
@@ -3489,7 +3351,6 @@ void ivas_masa_init_stereotype_detection_fx(
        stereo_type_detect->max_band_diff_ene = 18;
        move16();
    }
#endif

    return;
}
@@ -3518,12 +3379,10 @@ void ivas_masa_stereotype_detection_fx(
    Word32 lr_total_bb_temp_fx;
    Word32 lr_total_hi_temp_fx;
    Word32 temp;
#ifdef FIX_FLOAT_1578_OMASA_REND_SPIKES
    Word16 change_to_dual_mono_selection;
    Word32 diffPerSum_fx; /* Q31 */
    Word16 scale;
    Word32 tau; /* Q31 */
#endif

    lr_total_bb_ratio_db_fx = stereo_type_detect->lr_total_bb_ratio_db_fx; // q21
    move32();
@@ -3534,7 +3393,6 @@ void ivas_masa_stereotype_detection_fx(
    subtract_target_ratio_db_fx = stereo_type_detect->subtract_target_ratio_db_fx; // q21
    move32();

#ifdef FIX_FLOAT_1578_OMASA_REND_SPIKES
    /* Determine if broadband energy and ratio between difference broadband energy and broadband energy indicate
     * that the signal type is dual mono */
    change_to_dual_mono_selection = 0;
@@ -3560,7 +3418,6 @@ void ivas_masa_stereotype_detection_fx(
        }
    }

#endif
    /* Determine if the determined features match the spaced mic type */
    change_to_spaced_selection = 0;
    move16();
@@ -3637,16 +3494,12 @@ void ivas_masa_stereotype_detection_fx(
    }
    ELSE
    {
#ifdef FIX_FLOAT_1578_OMASA_REND_SPIKES
        IF( EQ_16( change_to_dual_mono_selection, 1 ) )
        {
            stereo_type_detect->masa_stereo_type = MASA_DUAL_MONO;
            move32();
        }
        ELSE IF( EQ_16( change_to_spaced_selection, 1 ) )
#else
        IF( EQ_16( change_to_spaced_selection, 1 ) )
#endif
        {
            stereo_type_detect->masa_stereo_type = MASA_STEREO_SPACED_MICS;
            move32();
Loading