Commit a3ceaf4e authored by Tapani Pihlajakuja's avatar Tapani Pihlajakuja
Browse files

Adds split rendering support for OMASA

parent b6db33cb
Loading
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -163,6 +163,8 @@
#define FIX_1002_DEC_PHASE_ECU_USAN_OF_PHASE            /* Eri: issue #1002, usan-value-out-of-range-for-int16, kept BE for PLC-conditions   */
#define FIX_960_SYN_OUTPUT                              /* VA: issue 960: unused function syn_output() is removed */

#define FIX_766_OMASA_SPLIT_REND                        /* Nokia: issue #766: split-rendering support for OMASA */

/* #################### End BE switches ################################## */

/* #################### Start NON-BE switches ############################ */
+19 −0
Original line number Diff line number Diff line
@@ -95,8 +95,16 @@ static ivas_error ivas_dec_reconfig_split_rend(
    isCldfbNeeded = 0;
#ifndef SPLIT_REND_WITH_HEAD_ROT
    cldfbMode = CLDFB_ANALYSIS;
#else
#ifdef FIX_766_OMASA_SPLIT_REND
    if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ivas_format == SBA_ISM_FORMAT ) ||
         ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) )
    {
        cldfb_in_flag = 0;  /* this allocates cldfb analysis for td-rend results */
    }
#else
    if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ivas_format == SBA_ISM_FORMAT )
#endif
    {
        cldfb_in_flag = 0;
    }
@@ -193,8 +201,14 @@ static ivas_error ivas_dec_reconfig_split_rend(
    }

#ifdef SPLIT_REND_WITH_HEAD_ROT
#ifdef FIX_766_OMASA_SPLIT_REND
    if ( ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD ) &&
         ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV || st_ivas->ivas_format != SBA_ISM_FORMAT ) &&
         !( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) )  /* td-rend not needed? */
#else
    if ( ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD ) &&
         ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV || st_ivas->ivas_format != SBA_ISM_FORMAT ) )
#endif
#else
    if ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD )
#endif
@@ -253,7 +267,12 @@ static ivas_error ivas_dec_init_split_rend(
    }

#ifdef SPLIT_REND_WITH_HEAD_ROT
#ifdef FIX_766_OMASA_SPLIT_REND
    if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ivas_format == SBA_ISM_FORMAT ) ||
         ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) )
#else
    if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ivas_format == SBA_ISM_FORMAT )
#endif
    {
        cldfb_in_flag = 0;
    }
+12 −1
Original line number Diff line number Diff line
@@ -932,7 +932,18 @@ void ivas_jbm_dec_feed_tc_to_renderer(
                    {
                        v_multc( st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], OMASA_TDREND_MATCHING_GAIN, st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available );
                    }
#ifdef FIX_766_OMASA_SPLIT_REND
#ifdef SPLIT_REND_WITH_HEAD_ROT
                    if ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
                    {
#endif
#endif
                        delay_signal( st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size );
#ifdef FIX_766_OMASA_SPLIT_REND
#ifdef SPLIT_REND_WITH_HEAD_ROT
                    }
#endif
#endif
                }
            }
        }
+48 −1
Original line number Diff line number Diff line
@@ -749,6 +749,49 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm(
    /* reset combined orientation access index before calling the td renderer */
    ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData );

#ifdef FIX_766_OMASA_SPLIT_REND
#ifdef SPLIT_REND_WITH_HEAD_ROT
    if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
    {
        int16_t slot_idx, num_cldfb_bands, nchan_transport_orig, cldfb_slots;
        float Cldfb_RealBuffer[CLDFB_NO_CHANNELS_MAX];
        float Cldfb_ImagBuffer[CLDFB_NO_CHANNELS_MAX];

        float data_rend_objects[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][L_FRAME48k];  /* float[8 * 2][960] */
        float *p_rend_obj[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS];

        for ( n = 0; n < MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; n++ )
        {
            p_rend_obj[n] = &data_rend_objects[n][0];
        }

        num_cldfb_bands = st_ivas->hSplitBinRend.splitrend.hCldfbHandles->cldfbAna[0]->no_channels;
        nchan_transport_orig = st_ivas->nchan_transport;
        st_ivas->nchan_transport = st_ivas->nchan_ism;

        if ( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, p_rend_obj, *nSamplesRendered ) ) != IVAS_ERR_OK )  /* objects are read from st_ivas->hTcBuffer->tc[2..(1+n_isms)] */
        {
            return error;
        }
        st_ivas->nchan_transport = nchan_transport_orig;
        cldfb_slots = *nSamplesRendered / num_cldfb_bands;

        for ( n = 0; n < st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses * BINAURAL_CHANNELS; ++n )
        {
            for ( slot_idx = 0; slot_idx < cldfb_slots; slot_idx++ )
            {
                cldfbAnalysis_ts( &( p_rend_obj[n][num_cldfb_bands * slot_idx] ), Cldfb_RealBuffer, Cldfb_ImagBuffer, num_cldfb_bands, st_ivas->hSplitBinRend.splitrend.hCldfbHandles->cldfbAna[n] );

                /* this differs from OSBA by: no scaling by 0.5, and omit slot offset in right-hand side buffer as this is always 0 */
                v_add( st_ivas->hSplitBinRend.hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[n][slot_idx], Cldfb_RealBuffer, st_ivas->hSplitBinRend.hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[n][slot_idx], num_cldfb_bands );
                v_add( st_ivas->hSplitBinRend.hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[n][slot_idx], Cldfb_ImagBuffer, st_ivas->hSplitBinRend.hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[n][slot_idx], num_cldfb_bands );
            }
        }
    }
    else
    {
#endif
#endif
    if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_sepobj, *nSamplesRendered ) ) != IVAS_ERR_OK )
    {
        return error;
@@ -757,7 +800,11 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm(
    {
        v_add( output_f[n], p_sepobj[n], output_f[n], *nSamplesRendered );
    }

#ifdef FIX_766_OMASA_SPLIT_REND
#ifdef SPLIT_REND_WITH_HEAD_ROT
    }
#endif
#endif
    return IVAS_ERR_OK;
}

+24 −0
Original line number Diff line number Diff line
@@ -1107,9 +1107,21 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream(
        slots_rendered = 0;
    }
    else
    {
#ifdef FIX_766_OMASA_SPLIT_REND
        /* TODO: check correctness: this is needed for OMASA-DISC, because the td-rend granularity is 240 samples at 48kHz, leading to wrong slot count. */
        if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC )
        {
            slots_rendered = st_ivas->hTcBuffer->n_samples_rendered / NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS );
        }
        else
        {
            slots_rendered = st_ivas->hTcBuffer->n_samples_rendered / st_ivas->hTcBuffer->n_samples_granularity;
        }
#else
        slots_rendered = st_ivas->hTcBuffer->n_samples_rendered / st_ivas->hTcBuffer->n_samples_granularity;
#endif
    }


    /* Decode and render */
@@ -1136,9 +1148,21 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream(
        slots_rendered_new = 0;
    }
    else
    {
#ifdef FIX_766_OMASA_SPLIT_REND
        /* TODO: check correctness: this is needed for OMASA-DISC, because the td-rend granularity is 240 samples at 48kHz, leading to wrong slot count. */
        if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC )
        {
            slots_rendered_new = st_ivas->hTcBuffer->n_samples_rendered / NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS );
        }
        else
        {
            slots_rendered_new = st_ivas->hTcBuffer->n_samples_rendered / st_ivas->hTcBuffer->n_samples_granularity;
        }
#else
        slots_rendered_new = st_ivas->hTcBuffer->n_samples_rendered / st_ivas->hTcBuffer->n_samples_granularity;
#endif
    }

    for ( i = 0; i < BINAURAL_CHANNELS * numPoses; ++i )
    {