Commit 50d1461d authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

[fix] enable support for radius parameter in config

parent ea5a8b5e
Loading
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -66,8 +66,22 @@ ivas_error ivas_td_binaural_open(
        return IVAS_ERROR( IVAS_ERR_INTERNAL, "HRTF binary file present but not used in TD renderer" );
    }

#ifdef FIX_1419_MONO_STEREO_UMX
    return ivas_td_binaural_open_unwrap( &st_ivas->hHrtfTD,
                                         st_ivas->hDecoderConfig->output_Fs,
                                         num_src,
                                         st_ivas->ivas_format,
                                         st_ivas->transport_config,
                                         st_ivas->hRenderConfig->directivity,
                                         st_ivas->hRenderConfig->distAtt,
                                         ( st_ivas->hRenderConfig != NULL ) ? &st_ivas->hRenderConfig->mono_stereo_upmix_config.radius : NULL,
                                         st_ivas->hTransSetup,
                                         &st_ivas->hBinRendererTd,
                                         &st_ivas->binaural_latency_ns );
#else
    return ivas_td_binaural_open_unwrap( &st_ivas->hHrtfTD, st_ivas->hDecoderConfig->output_Fs, num_src, st_ivas->ivas_format,
                                         st_ivas->transport_config, st_ivas->hRenderConfig->directivity, st_ivas->hRenderConfig->distAtt, st_ivas->hTransSetup, &st_ivas->hBinRendererTd, &st_ivas->binaural_latency_ns );
#endif
}


@@ -312,6 +326,9 @@ ivas_error ivas_td_binaural_renderer_sf_splitBinaural(
                                                     st_ivas->transport_config,
                                                     st_ivas->hRenderConfig->directivity,
                                                     st_ivas->hRenderConfig->distAtt,
#ifdef FIX_1419_MONO_STEREO_UMX
                                                     ( st_ivas->hRenderConfig != NULL ) ? &st_ivas->hRenderConfig->mono_stereo_upmix_config.radius : NULL,
#endif
                                                     st_ivas->hTransSetup,
                                                     &st_ivas->hTdRendHandles[i],
                                                     &st_ivas->binaural_latency_ns ) ) != IVAS_ERR_OK )
+1 −1
Original line number Diff line number Diff line
@@ -3437,7 +3437,7 @@ ivas_error IVAS_DEC_FeedRenderConfig(
        mvr2r( renderConfig.mono_stereo_upmix_config.azi, hRenderConfig->mono_stereo_upmix_config.azi, 2 );
        mvr2r( renderConfig.mono_stereo_upmix_config.ele, hRenderConfig->mono_stereo_upmix_config.ele, 2 );

        /* validate configuration */
        /* validate configuration early - repeated in IVAS_DEC_PrepareRenderer when input format is available */
        if ( ( error = ms_upmix_validate_config( &hRenderConfig->mono_stereo_upmix_config,
                                                 st_ivas->ivas_format,
                                                 st_ivas->hDecoderConfig->output_config ) ) != IVAS_ERR_OK )
+40 −7
Original line number Diff line number Diff line
@@ -67,6 +67,9 @@ ivas_error ivas_td_binaural_open_unwrap(
    const AUDIO_CONFIG transport_config, /* i  : Transport configuration             */
    const float *directivity,            /* i  : Directivity pattern (used for ISM)  */
    const float *distAtt,                /* i  : Distance attenuation (used for ISM) */
#ifdef FIX_1419_MONO_STEREO_UMX
    const float *radius_ms_umx, /* i  : Radius (used for mono/stereo upmix) */
#endif
    const IVAS_OUTPUT_SETUP hTransSetup,                /* i  : Loudspeaker layout                  */
    BINAURAL_TD_OBJECT_RENDERER_HANDLE *hBinRendererTd, /* o  : TD renderer handle                  */
    int32_t *binaural_latency_ns                        /* i  : Binauralization delay               */
@@ -77,6 +80,9 @@ ivas_error ivas_td_binaural_open_unwrap(
    int16_t nS;
    int16_t SrcInd[MAX_NUM_TDREND_CHANNELS];
    const float *ls_azimuth, *ls_elevation;
#ifdef FIX_1419_MONO_STEREO_UMX
    float radius;
#endif
    float Pos[3];
    float Dir[3];
    TDREND_DirAtten_t *DirAtten_p;
@@ -187,8 +193,21 @@ ivas_error ivas_td_binaural_open_unwrap(

        for ( nS = 0; nS < nchan_rend; nS++ )
        {
#ifdef FIX_1419_MONO_STEREO_UMX
            /* set radius from render configuration file for mono/stereo upmix; otherwise 1.f */
            radius = 1.f;
            if ( ( transport_config == IVAS_AUDIO_CONFIG_MONO || transport_config == IVAS_AUDIO_CONFIG_STEREO ) &&
                 radius_ms_umx != NULL )
            {
                radius = *radius_ms_umx;
            }

            /* Set source positions according to loudspeaker layout */
            angles_to_vec( radius, ls_azimuth[nS], ls_elevation[nS], Pos );
#else
            /* Set source positions according to loudspeaker layout */
            angles_to_vec( 1.0f, ls_azimuth[nS], ls_elevation[nS], Pos );
#endif
            Dir[0] = 1.0f;
            Dir[1] = 0.0f;
            Dir[2] = 0.0f;
@@ -722,7 +741,21 @@ ivas_error ivas_td_binaural_open_ext(
        distAtt = hRendCfg->distAtt;
    }

#ifdef FIX_1419_MONO_STEREO_UMX
    return ivas_td_binaural_open_unwrap( pTDRend->hHrtfTD,
                                         outFs,
                                         nchan_transport,
                                         ivas_format,
                                         transport_config,
                                         directivity,
                                         distAtt,
                                         ( hRendCfg != NULL ) ? &hRendCfg->mono_stereo_upmix_config.radius : NULL,
                                         hTransSetup,
                                         &pTDRend->hBinRendererTd,
                                         &pTDRend->binaural_latency_ns );
#else
    return ivas_td_binaural_open_unwrap( pTDRend->hHrtfTD, outFs, nchan_transport, ivas_format, transport_config, directivity, distAtt, hTransSetup, &pTDRend->hBinRendererTd, &pTDRend->binaural_latency_ns );
#endif
}


+9 −2
Original line number Diff line number Diff line
@@ -493,9 +493,16 @@ ivas_error ms_upmix_validate_config(
    }

    /* validate radius */
    if ( pMsUpmixConfig->radius < 0.f || pMsUpmixConfig->radius > 1.f )
    if ( pMsUpmixConfig->radius < 0.f || pMsUpmixConfig->radius > 15.75f )
    {
        return IVAS_ERROR( IVAS_ERR_INVALID_RENDER_CONFIG, "Radius must be between 0 and 1" );
        return IVAS_ERROR( IVAS_ERR_INVALID_RENDER_CONFIG, "Radius must be between 0 and 15.75" );
    }

    /* zero radius corresponds to non-spatial */
    if ( pMsUpmixConfig->radius == 0.f )
    {
        pMsUpmixConfig->spatialEnabled = FALSE;
        return IVAS_ERR_OK;
    }

    /* obtain absolute values */
+3 −0
Original line number Diff line number Diff line
@@ -651,6 +651,9 @@ ivas_error ivas_td_binaural_open_unwrap(
    const AUDIO_CONFIG transport_config,                        /* i  : Transport configuration                 */
    const float *directivity,                                   /* i  : Directivity pattern (used for ISM)      */
    const float *distAtt,                                       /* i  : Distance attenuation (used for ISM)     */
#ifdef FIX_1419_MONO_STEREO_UMX
    const float *radius_ms_umx,                                 /* i  : Radius (used for mono/stereo upmix)     */
#endif
    const IVAS_OUTPUT_SETUP hTransSetup,                        /* i  : Loudspeaker layout                      */
    BINAURAL_TD_OBJECT_RENDERER_HANDLE *hBinRendererTd,         /* o  : TD renderer handle                      */
    int32_t *binaural_latency_ns                                /* i  : Binauralization delay                   */