Commit bbaa9850 authored by Dominik Weckbecker's avatar Dominik Weckbecker 💬
Browse files

Merge branch '774-osba-bitrate-switching-crashes-with-mono-output' into 'main'

[non BE] Resolve "OSBA bitrate switching crashes with MONO output"

See merge request !1084
parents 423900c0 431f8807
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -211,6 +211,7 @@
#define NONBE_FIX_738_SBA_BR_SW_ASAN                          /* FhG: issue 738: fixes bug when switching to an MCT bitrate and previous frame was ACELP */
#define NONBE_CR_FIX_735_SBA_HP20_BRATE_SWITCHING             /* VA: Issue 735: Resolve "HP20 filtering bug in SBA/OSBA bitrate switching" */
#define NONBE_FIX_588_UPDATE_FASTCONV_SD                      /* FhG: issue 588: update FastConv SD HRTFs in CLDFB domain with new conversion method */
#define NONBE_FIX_774_OSBA_MONO_DEC_CRASH                     /* FhG: issue 774: decoder crash for OSBA to mono */
#define NONBE_FIX_802_PARAMUPMIX_HIGHPASS                     /* Dlb: issue 802: Move HighPass filter operation for ParamUpmix */
#define NONBE_FIX_778_TNS_UNFIED_STEREO_MSAN                  /* FhG: Issue 778: MSAN error due to uninitialized TNS configuration */
#define NONBE_FIX_797_OMASA_INACTIVE_SEP_OBJ                 /* VA: issue 797:  fix of crash when the separated object is inactive and the MASA metadata is using very few bits */
+22 −1
Original line number Diff line number Diff line
@@ -68,9 +68,13 @@ ivas_error ivas_mono_dmx_renderer_open(
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for downmixing\n" ) );
    }

#ifdef NONBE_FIX_774_OSBA_MONO_DEC_CRASH
    hDownmix->inputEnergy = 0;
    hDownmix->protoEnergy = 0;
#else
    set_zero( hDownmix->inputEnergy, CLDFB_NO_CHANNELS_MAX );
    set_zero( hDownmix->protoEnergy, CLDFB_NO_CHANNELS_MAX );

#endif
    st_ivas->hMonoDmxRenderer = hDownmix;

    return IVAS_ERR_OK;
@@ -121,19 +125,36 @@ void ivas_mono_downmix_render_passive(
    }

    /* compute the input energy, proto energy after smoothing */
#ifdef NONBE_FIX_774_OSBA_MONO_DEC_CRASH
    hDownmix->inputEnergy *= DOWNMIX_ALPHA;
    hDownmix->protoEnergy *= DOWNMIX_ALPHA;
#else
    hDownmix->inputEnergy[0] *= DOWNMIX_ALPHA;
    hDownmix->protoEnergy[0] *= DOWNMIX_ALPHA;
#endif
    for ( i = 0; i < output_frame; i++ )
    {
#ifdef NONBE_FIX_774_OSBA_MONO_DEC_CRASH
        hDownmix->protoEnergy += proto_signal[i] * proto_signal[i];
#else
        hDownmix->protoEnergy[0] += proto_signal[i] * proto_signal[i];
#endif
        for ( j = 0; j < numInputChannels; j++ )
        {
#ifdef NONBE_FIX_774_OSBA_MONO_DEC_CRASH
            hDownmix->inputEnergy += ( output_f[j][i] * output_f[j][i] );
#else
            hDownmix->inputEnergy[0] += ( output_f[j][i] * output_f[j][i] );
#endif
        }
    }

    /* compute the eq factor */
#ifdef NONBE_FIX_774_OSBA_MONO_DEC_CRASH
    eq = min( DOWNMIX_MAX_GAIN, sqrtf( hDownmix->inputEnergy / ( EPSILON + hDownmix->protoEnergy ) ) );
#else
    eq = min( DOWNMIX_MAX_GAIN, sqrtf( hDownmix->inputEnergy[0] / ( EPSILON + hDownmix->protoEnergy[0] ) ) );
#endif

    /* equalize the downmix */
    v_multc( proto_signal, eq, output_f[0], output_frame );
+21 −0
Original line number Diff line number Diff line
@@ -526,6 +526,27 @@ ivas_error ivas_sba_dec_reconfigure(
                }
            }

#ifdef NONBE_FIX_774_OSBA_MONO_DEC_CRASH
            if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX )
            {
                if ( st_ivas->hMonoDmxRenderer == NULL )
                {
                    if ( ( error = ivas_mono_dmx_renderer_open( st_ivas ) ) != IVAS_ERR_OK )
                    {
                        return error;
                    }
                }
            }
            else
            {
                if ( st_ivas->hMonoDmxRenderer != NULL )
                {
                    free( st_ivas->hMonoDmxRenderer );
                    st_ivas->hMonoDmxRenderer = NULL;
                }
            }
#endif

            if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV )
            {
                /* Allocate TD renderer for the objects in DISC mode */
+5 −0
Original line number Diff line number Diff line
@@ -1539,8 +1539,13 @@ typedef struct ivas_LS_setupconversion_mapping

typedef struct ivas_mono_downmix_renderer_struct
{
#ifdef NONBE_FIX_774_OSBA_MONO_DEC_CRASH
    float inputEnergy;
    float protoEnergy;
#else
    float inputEnergy[CLDFB_NO_CHANNELS_MAX];
    float protoEnergy[CLDFB_NO_CHANNELS_MAX];
#endif

} MONO_DOWNMIX_RENDERER_STRUCT, *MONO_DOWNMIX_RENDERER_HANDLE;