diff --git a/lib_com/options.h b/lib_com/options.h index f81f82b1635780ea3482c33f53e9d7e605598337..1e44c32497a747098ea431b6d2d7e3a0e1f819aa 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -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 */ diff --git a/lib_dec/ivas_mono_dmx_renderer.c b/lib_dec/ivas_mono_dmx_renderer.c index 599bee9ff9d1414dda3b1e6e1c483332d7f77ea4..6dd42d3a5690617158cee12a5cc30f2944caafbc 100644 --- a/lib_dec/ivas_mono_dmx_renderer.c +++ b/lib_dec/ivas_mono_dmx_renderer.c @@ -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 ); diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 62b735f218856c01514e8cbd09b9bd944972232d..dcc2c023d8685e1f051720105ad052073b18a238 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -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 */ diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 7cb19be7482736a07a917d259e35c8885691e53f..d1a19e6317192da4a56621ffe608ede7897601f5 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -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;