Commit 05371776 authored by Jan Kiene's avatar Jan Kiene
Browse files

add limiter for remaining formats with downmixing

needs to be reviewed by respective experts
parent 5ab88232
Loading
Loading
Loading
Loading
+46 −0
Original line number Diff line number Diff line
@@ -263,6 +263,14 @@ ivas_error ivas_enc(
        if ( ivas_format == SBA_FORMAT )
        {
            ivas_sba_getTCs( data_f, st_ivas, input_frame );
#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX

            /* Apply limiter on transport channels */
            if ( st_ivas->hLimiter != NULL )
            {
                ivas_limiter_apply( st_ivas->hLimiter, data_f, st_ivas->nchan_transport, input_frame, BER_detect_dummy );
            }
#endif
        }

        /* core-coding of transport channels */
@@ -290,11 +298,25 @@ ivas_error ivas_enc(
    }
    else if ( ivas_format == MASA_ISM_FORMAT )
    {
#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX
        int16_t num_channels;
#endif
        float *data_separated_object;
        int16_t idx_separated_object;
        int16_t flag_omasa_ener_brate;

        flag_omasa_ener_brate = 0;
#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX
        num_channels = st_ivas->nchan_transport;
        if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC )
        {
            num_channels += hEncoderConfig->nchan_ism;
        }
        else if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ )
        {
            num_channels += 1;
        }
#endif

        /* Stereo transport is used also with monoMASA, duplicate mono if monoMASA */
        if ( ( st_ivas->hEncoderConfig->nchan_inp - hEncoderConfig->nchan_ism ) == 1 )
@@ -323,6 +345,14 @@ ivas_error ivas_enc(
            ivas_omasa_enc( st_ivas->hOMasa, st_ivas->hMasa, st_ivas->hIsmMetaData, data_f, input_frame, st_ivas->nchan_transport, hEncoderConfig->nchan_ism, st_ivas->ism_mode, data_separated_object, &idx_separated_object );
        }

#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX
            /* Apply limiter on downmix */
            if ( st_ivas->hLimiter != NULL )
            {
                ivas_limiter_apply( st_ivas->hLimiter, data_f, num_channels, input_frame, BER_detect_dummy );
            }
#endif

        /* Encode ISMs transport channels */
        n = 0;
        if ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ )
@@ -429,6 +459,14 @@ ivas_error ivas_enc(
            ivas_sba_getTCs( &data_f[n], st_ivas, input_frame );
        }

#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX
        /* Apply limiter on downmix */
        if ( st_ivas->hLimiter != NULL )
        {
            ivas_limiter_apply( st_ivas->hLimiter, data_f, st_ivas->nchan_transport, input_frame, BER_detect_dummy );
        }
#endif

        /* core-coding of transport channels */
        if ( st_ivas->nSCE == 1 )
        {
@@ -536,6 +574,14 @@ ivas_error ivas_enc(
                return error;
            }

#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX
            /* Apply limiter on downmix */
            if ( st_ivas->hLimiter != NULL )
            {
                ivas_limiter_apply( st_ivas->hLimiter, data_f, st_ivas->nchan_transport, input_frame, BER_detect_dummy );
            }
#endif

            if ( st_ivas->hMcMasa->separateChannelEnabled )
            {
                if ( ( error = ivas_sce_enc( st_ivas, 0, data_f[2], input_frame, 0 ) ) != IVAS_ERR_OK )
+45 −0
Original line number Diff line number Diff line
@@ -632,14 +632,38 @@ ivas_error ivas_init_encoder(
                return error;
            }
        }

#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX
        if ( ivas_format == SBA_FORMAT)
        {
            if ( ( error = ivas_limiter_open( &st_ivas->hLimiter, st_ivas->nchan_transport, st_ivas->hEncoderConfig->input_Fs ) ) != IVAS_ERR_OK )
            {
                return error;
            }
        }
#endif
    }
    else if ( ivas_format == MASA_ISM_FORMAT )
    {
#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX
        int16_t num_channels;
#endif
        int32_t ism_total_brate;
        int16_t k;

        st_ivas->ism_mode = ivas_omasa_ism_mode_select( ivas_total_brate, hEncoderConfig->nchan_ism );
        st_ivas->nchan_transport = 2;
#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX
        num_channels = st_ivas->nchan_transport;
        if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC )
        {
            num_channels += hEncoderConfig->nchan_ism;
        }
        else if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ )
        {
            num_channels += 1;
        }
#endif

        if ( ( error = ivas_ism_metadata_enc_create( st_ivas, hEncoderConfig->nchan_ism, element_brate_tmp ) ) != IVAS_ERR_OK )
        {
@@ -692,6 +716,13 @@ ivas_error ivas_init_encoder(
        {
            return error;
        }

#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX
        if ( ( error = ivas_limiter_open( &st_ivas->hLimiter, num_channels, st_ivas->hEncoderConfig->input_Fs ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#endif
    }
    else if ( ivas_format == SBA_ISM_FORMAT )
    {
@@ -777,6 +808,13 @@ ivas_error ivas_init_encoder(
        {
            return error;
        }

#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX
        if ( ( error = ivas_limiter_open( &st_ivas->hLimiter, st_ivas->nchan_transport, st_ivas->hEncoderConfig->input_Fs ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#endif
    }
    else if ( ivas_format == MC_FORMAT )
    {
@@ -912,6 +950,13 @@ ivas_error ivas_init_encoder(
                    return error;
                }
            }

#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX
            if ( ( error = ivas_limiter_open( &st_ivas->hLimiter, st_ivas->nchan_transport, st_ivas->hEncoderConfig->input_Fs ) ) != IVAS_ERR_OK )
            {
                return error;
            }
#endif
        }
    }
#ifdef DEBUGGING