Commit 646517ef authored by vaclav's avatar vaclav
Browse files

harmonize channel indexes

parent b7b40a9b
Loading
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -3996,8 +3996,8 @@ void ivas_spar_get_parameters(
    SPAR_DEC_HANDLE hSpar,                                      /* i/o: SPAR decoder handle                     */
    const DECODER_CONFIG_HANDLE hDecoderConfig,                 /* i  : configuration structure                 */
    const int16_t ts,                                           /* i  : time slot index                         */
    const int16_t num_ch_out,                                   /* i  : number of channels out                  */
    const int16_t num_ch_in,                                    /* i  : number of channels in                   */
    const int16_t nchan_out,                                    /* i  : number of channels out                  */
    const int16_t nchan_inp,                                    /* i  : number of channels in                   */
    const int16_t num_spar_bands,                               /* i  : number of SPAR bands                    */
    float par_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS]   /* o  : mixing matrix               */
);
+25 −25
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ ivas_error ivas_dec(
    int16_t *data            /* o  : output synthesis signal     */
)
{
    int16_t n, output_frame, nchan_out;
    int16_t ch, output_frame, nchan_out;
    Decoder_State *st;                                                                                                     /* used for bitstream handling */
    float output[MAX_OUTPUT_CHANNELS][L_FRAME48k]; /* 'float' buffer for output synthesis, MAX_OUTPUT_CHANNELS channels */ /* IVAS_fmToDo: buffer can be allocated dynamically based on the actual number of output channels */
    int16_t nchan_remapped;
@@ -103,9 +103,9 @@ ivas_error ivas_dec(
    if ( st_ivas->bfi && st_ivas->ini_frame == 0 )
    {
        /* zero output when first frame(s) is lost */
        for ( n = 0; n < nchan_out; n++ )
        for ( ch = 0; ch < nchan_out; ch++ )
        {
            set_f( output[n], 0.0f, output_frame );
            set_f( output[ch], 0.0f, output_frame );
        }

#ifdef DEBUG_MODE_INFO
@@ -125,9 +125,9 @@ ivas_error ivas_dec(
        }

        /* HP filtering */
        for ( n = 0; n < min( nchan_out, st_ivas->nchan_transport ); n++ )
        for ( ch = 0; ch < min( nchan_out, st_ivas->nchan_transport ); ch++ )
        {
            hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs );
            hp20( output[ch], output_frame, st_ivas->mem_hp20_out[ch], output_Fs );
        }

        /* Rendering */
@@ -148,15 +148,15 @@ ivas_error ivas_dec(
            ivas_ism_metadata_dec( ivas_total_brate, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, NULL );
        }

        for ( n = 0; n < st_ivas->nchan_transport; n++ )
        for ( ch = 0; ch < st_ivas->nchan_transport; ch++ )
        {
            if ( ( error = ivas_sce_dec( st_ivas, n, &output[n], output_frame, nb_bits_metadata[n] ) ) != IVAS_ERR_OK )
            if ( ( error = ivas_sce_dec( st_ivas, ch, &output[ch], output_frame, nb_bits_metadata[ch] ) ) != IVAS_ERR_OK )
            {
                return error;
            }

            /* HP filtering */
            hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs );
            hp20( output[ch], output_frame, st_ivas->mem_hp20_out[ch], output_Fs );
        }

        /* Rendering */
@@ -297,9 +297,9 @@ ivas_error ivas_dec(

        /* HP filtering */
#ifndef DEBUG_SPAR_BYPASS_EVS_CODEC
        for ( n = 0; n < nchan_remapped; n++ )
        for ( ch = 0; ch < nchan_remapped; ch++ )
        {
            hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs );
            hp20( output[ch], output_frame, st_ivas->mem_hp20_out[ch], output_Fs );
        }
#endif
        if ( st_ivas->ivas_format == SBA_FORMAT )
@@ -320,9 +320,9 @@ ivas_error ivas_dec(
        {
            float gain = 0.8414f; /* Todo: Temporary gain for roughly matching the loudness. To be tuned later together with other outputs. */

            for ( n = 0; n < nchan_remapped; n++ )
            for ( ch = 0; ch < nchan_remapped; ch++ )
            {
                v_multc( output[n], gain, output[n], output_frame );
                v_multc( output[ch], gain, output[ch], output_frame );
            }
        }

@@ -368,11 +368,11 @@ ivas_error ivas_dec(
            mvr2r( output_lfe_ch, output[LFE_CHANNEL], output_frame );

            /* HP filtering */
            for ( n = 0; n < st_ivas->nchan_transport; n++ )
            for ( ch = 0; ch < st_ivas->nchan_transport; ch++ )
            {
                if ( n != LFE_CHANNEL )
                if ( ch != LFE_CHANNEL )
                {
                    hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs );
                    hp20( output[ch], output_frame, st_ivas->mem_hp20_out[ch], output_Fs );
                }
            }

@@ -427,9 +427,9 @@ ivas_error ivas_dec(
            }

            /* HP filtering */
            for ( n = 0; n < st_ivas->nchan_transport; n++ )
            for ( ch = 0; ch < st_ivas->nchan_transport; ch++ )
            {
                hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs );
                hp20( output[ch], output_frame, st_ivas->mem_hp20_out[ch], output_Fs );
            }

            /* Rendering */
@@ -464,10 +464,10 @@ ivas_error ivas_dec(
                }

                /* Identify the index of the separated channel */
                n = st_ivas->hOutSetup.separateChannelIndex;
                ch = st_ivas->hOutSetup.separateChannelIndex;

                /* Decode the separated channel to output[n] to be combined with the synthesized channels */
                if ( ( error = ivas_sce_dec( st_ivas, 0, &output[n], output_frame, 0 ) ) != IVAS_ERR_OK )
                if ( ( error = ivas_sce_dec( st_ivas, 0, &output[ch], output_frame, 0 ) ) != IVAS_ERR_OK )
                {
                    return error;
                }
@@ -477,12 +477,12 @@ ivas_error ivas_dec(
                     output_config == AUDIO_CONFIG_5_1_4 || output_config == AUDIO_CONFIG_7_1_4 ||
                     output_config == AUDIO_CONFIG_5_1_2 || ( output_config == AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.num_lfe > 0 ) )
                {
                    ivas_lfe_synth_with_filters( st_ivas->hMasa->hMasaLfeSynth, output, output_frame, n, LFE_CHANNEL );
                    ivas_lfe_synth_with_filters( st_ivas->hMasa->hMasaLfeSynth, output, output_frame, ch, LFE_CHANNEL );
                }
                else if ( output_config == AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.num_lfe == 0 )
                {
                    /* Delay the separated channel to sync with the DirAC rendering */
                    delay_signal( output[n], output_frame, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_size );
                    delay_signal( output[ch], output_frame, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_size );
                }
            }
            else
@@ -509,9 +509,9 @@ ivas_error ivas_dec(
            }

            /* HP filtering */
            for ( n = 0; n < getNumChanSynthesis( st_ivas ); n++ )
            for ( ch = 0; ch < getNumChanSynthesis( st_ivas ); ch++ )
            {
                hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs );
                hp20( output[ch], output_frame, st_ivas->mem_hp20_out[ch], output_Fs );
            }

            /* Rendering */
@@ -529,9 +529,9 @@ ivas_error ivas_dec(
                }
                else if ( st_ivas->intern_config == AUDIO_CONFIG_5_1 && ( output_config == AUDIO_CONFIG_5_1_2 || output_config == AUDIO_CONFIG_5_1_4 || output_config == AUDIO_CONFIG_7_1 ) )
                {
                    for ( n = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; n < st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; n++ )
                    for ( ch = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; ch < st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; ch++ )
                    {
                        set_zero( output[n], output_frame );
                        set_zero( output[ch], output_frame );
                    }
                }
            }
+5 −5
Original line number Diff line number Diff line
@@ -2343,12 +2343,12 @@ void ivas_dirac_dec(
        {
            float *RealBuffer[MAX_PARAM_SPATIAL_SUBFRAMES];
            float *ImagBuffer[MAX_PARAM_SPATIAL_SUBFRAMES];
            int16_t outchannels;
            int16_t nchan_out;

            idx_in = 0;
            idx_lfe = 0;

            outchannels = hDirAC->hOutSetup.nchan_out_woLFE + hDirAC->hOutSetup.num_lfe;
            nchan_out = hDirAC->hOutSetup.nchan_out_woLFE + hDirAC->hOutSetup.num_lfe;
            if ( hDirAC->hOutSetup.separateChannelEnabled && ( hDirAC->hOutSetup.output_config == AUDIO_CONFIG_5_1 ||
                                                               hDirAC->hOutSetup.output_config == AUDIO_CONFIG_7_1 ||
                                                               hDirAC->hOutSetup.output_config == AUDIO_CONFIG_5_1_2 ||
@@ -2356,7 +2356,7 @@ void ivas_dirac_dec(
                                                               hDirAC->hOutSetup.output_config == AUDIO_CONFIG_7_1_4 ||
                                                               ( hDirAC->hOutSetup.output_config == AUDIO_CONFIG_LS_CUSTOM && st_ivas->hLsSetupCustom->separate_ch_found ) ) )
            {
                outchannels++;
                nchan_out++;
            }

            if ( hDirAC->hOutSetup.separateChannelEnabled && hDirAC->hOutSetup.output_config == AUDIO_CONFIG_LS_CUSTOM )
@@ -2370,7 +2370,7 @@ void ivas_dirac_dec(
                mvr2r( &( output_f[st_ivas->hOutSetup.separateChannelIndex][subframe_start_sample] ), tmp_separated, num_samples_subframe );
                mvr2r( &( output_f[LFE_CHANNEL][subframe_start_sample] ), tmp_lfe, num_samples_subframe );

                for ( ch = 0; ch < outchannels; ch++ )
                for ( ch = 0; ch < nchan_out; ch++ )
                {
                    if ( ( hDirAC->hOutSetup.num_lfe > 0 ) && ( hDirAC->hOutSetup.index_lfe[idx_lfe] == ch ) )
                    {
@@ -2411,7 +2411,7 @@ void ivas_dirac_dec(
            }
            else
            {
                for ( ch = 0; ch < outchannels; ch++ )
                for ( ch = 0; ch < nchan_out; ch++ )
                {
                    if ( ( hDirAC->hOutSetup.num_lfe > 0 ) && ( hDirAC->hOutSetup.index_lfe[idx_lfe] == ch ) )
                    {
+11 −11
Original line number Diff line number Diff line
@@ -285,7 +285,7 @@ static void ivas_param_ism_rendering(
    const int16_t num_ch_LS,
    const int16_t nchan_transport )
{
    int16_t outchIdx, inchIdx, bin_idx;
    int16_t ch_out, ch_inp, bin_idx;
    float tmp_1, mixing_matrix_smooth;

    tmp_1 = hDirAC->hParamIsmRendering->interpolator[slot_idx];
@@ -293,15 +293,15 @@ static void ivas_param_ism_rendering(
    for ( bin_idx = 0; bin_idx < hDirAC->num_freq_bands; bin_idx++ )
    {
        /* smooth the mixing matrix */
        for ( outchIdx = 0; outchIdx < num_ch_LS; outchIdx++ )
        for ( ch_out = 0; ch_out < num_ch_LS; ch_out++ )
        {
            for ( inchIdx = 0; inchIdx < nchan_transport; inchIdx++ )
            for ( ch_inp = 0; ch_inp < nchan_transport; ch_inp++ )
            {
                mixing_matrix_smooth = tmp_1 * mixing_matrix[bin_idx][outchIdx + inchIdx * num_ch_LS] +
                                       ( 1 - tmp_1 ) * hDirAC->hParamIsmRendering->mixing_matrix_lin_old[bin_idx][outchIdx + inchIdx * num_ch_LS];
                mixing_matrix_smooth = tmp_1 * mixing_matrix[bin_idx][ch_out + ch_inp * num_ch_LS] +
                                       ( 1 - tmp_1 ) * hDirAC->hParamIsmRendering->mixing_matrix_lin_old[bin_idx][ch_out + ch_inp * num_ch_LS];

                Cldfb_RealBuffer[outchIdx][out_slot_idx][bin_idx] += mixing_matrix_smooth * Cldfb_RealBuffer_in[inchIdx][slot_idx][bin_idx];
                Cldfb_ImagBuffer[outchIdx][out_slot_idx][bin_idx] += mixing_matrix_smooth * Cldfb_ImagBuffer_in[inchIdx][slot_idx][bin_idx];
                Cldfb_RealBuffer[ch_out][out_slot_idx][bin_idx] += mixing_matrix_smooth * Cldfb_RealBuffer_in[ch_inp][slot_idx][bin_idx];
                Cldfb_ImagBuffer[ch_out][out_slot_idx][bin_idx] += mixing_matrix_smooth * Cldfb_ImagBuffer_in[ch_inp][slot_idx][bin_idx];
            }
        }
    }
@@ -354,7 +354,7 @@ static void ivas_param_ism_update_mixing_matrix(
    const int16_t nchan_inp,
    const int16_t nchan_out )
{
    int16_t inchIdx, outchIdx, bin_idx, band_idx;
    int16_t ch_inp, ch_out, bin_idx, band_idx;
    int16_t brange[2];

    for ( band_idx = 0; band_idx < hDirAC->hParamIsm->nbands; band_idx++ )
@@ -364,11 +364,11 @@ static void ivas_param_ism_update_mixing_matrix(

        for ( bin_idx = brange[0]; bin_idx < brange[1]; bin_idx++ )
        {
            for ( inchIdx = 0; inchIdx < nchan_inp; inchIdx++ )
            for ( ch_inp = 0; ch_inp < nchan_inp; ch_inp++ )
            {
                for ( outchIdx = 0; outchIdx < nchan_out; outchIdx++ )
                for ( ch_out = 0; ch_out < nchan_out; ch_out++ )
                {
                    hDirAC->hParamIsmRendering->mixing_matrix_lin_old[bin_idx][outchIdx + inchIdx * nchan_out] = mixing_matrix[bin_idx][outchIdx + inchIdx * nchan_out];
                    hDirAC->hParamIsmRendering->mixing_matrix_lin_old[bin_idx][ch_out + ch_inp * nchan_out] = mixing_matrix[bin_idx][ch_out + ch_inp * nchan_out];
                }
            }
        }
+17 −18
Original line number Diff line number Diff line
@@ -256,7 +256,7 @@ void ivas_sba_mix_matrix_determiner(
{
    int16_t i, ch;
    float temp;
    int16_t num_bands_out, nchan_transport, nchan_out;
    int16_t num_bands_out, nchan_transport;

    /* Convert numeric range */
    for ( ch = 0; ch < nchan_remapped; ch++ )
@@ -281,11 +281,10 @@ void ivas_sba_mix_matrix_determiner(

    /* AGC */
    nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport;
    nchan_out = nchan_transport;
    ivas_agc_dec_process( hSpar->hAgcDec, output, output, nchan_transport, output_frame );

    /* Convert numeric range back */
    for ( ch = 0; ch < nchan_out; ch++ )
    for ( ch = 0; ch < nchan_transport; ch++ )
    {
        for ( i = 0; i < output_frame; i++ )
        {
@@ -322,7 +321,7 @@ void ivas_sba_prototype_renderer(
    int16_t b, ts;
    int16_t num_cldfb_bands, nchan_inp, nchan_out;
    int16_t cldfb_band;
    int16_t out_ch, in_ch;
    int16_t ch_out, ch_in;
    int16_t firstSlot, slotEnd, firstInCh, inChEnd, firstOutCh, outChEnd;
    int16_t sf_idx;

@@ -367,17 +366,17 @@ void ivas_sba_prototype_renderer(
            float cldfb_par;
            ivas_fb_bin_to_band_data_t *bin2band = &hSpar->hFbMixer->pFb->fb_bin_to_band;

            for ( out_ch = firstOutCh; out_ch < outChEnd; out_ch++ )
            for ( ch_out = firstOutCh; ch_out < outChEnd; ch_out++ )
            {
                out_re[out_ch] = 0.0f;
                out_im[out_ch] = 0.0f;
                out_re[ch_out] = 0.0f;
                out_im[ch_out] = 0.0f;

                for ( in_ch = firstInCh; in_ch < inChEnd; in_ch++ )
                for ( ch_in = firstInCh; ch_in < inChEnd; ch_in++ )
                {
                    if ( cldfb_band < CLDFB_PAR_WEIGHT_START_BAND ) /* tuning parameter, depends on how much SPAR Filters overlap for the CLDFB bands */
                    {
                        spar_band = bin2band->p_cldfb_map_to_spar_band[cldfb_band];
                        cldfb_par = mixer_mat[out_ch][in_ch][spar_band];
                        cldfb_par = mixer_mat[ch_out][ch_in][spar_band];
                    }
                    else
                    {
@@ -385,20 +384,20 @@ void ivas_sba_prototype_renderer(
                        for ( spar_band = bin2band->p_spar_start_bands[cldfb_band]; spar_band < num_spar_bands; spar_band++ )
                        {
                            /* accumulate contributions from all SPAR bands */
                            cldfb_par += mixer_mat[out_ch][in_ch][spar_band] * bin2band->pp_cldfb_weights_per_spar_band[cldfb_band][spar_band];
                            cldfb_par += mixer_mat[ch_out][ch_in][spar_band] * bin2band->pp_cldfb_weights_per_spar_band[cldfb_band][spar_band];
                        }
                    }

                    out_re[out_ch] += inRe[in_ch][ts][cldfb_band] * cldfb_par;
                    out_im[out_ch] += inIm[in_ch][ts][cldfb_band] * cldfb_par;
                    out_re[ch_out] += inRe[ch_in][ts][cldfb_band] * cldfb_par;
                    out_im[ch_out] += inIm[ch_in][ts][cldfb_band] * cldfb_par;
                }
            }

            /*update CLDFB data with the parameter-modified data*/
            for ( out_ch = firstOutCh; out_ch < outChEnd; out_ch++ )
            for ( ch_out = firstOutCh; ch_out < outChEnd; ch_out++ )
            {
                inRe[out_ch][ts][cldfb_band] = out_re[out_ch];
                inIm[out_ch][ts][cldfb_band] = out_im[out_ch];
                inRe[ch_out][ts][cldfb_band] = out_re[ch_out];
                inIm[ch_out][ts][cldfb_band] = out_im[ch_out];
            }
        }

@@ -413,13 +412,13 @@ void ivas_sba_prototype_renderer(
            mvr2r( hSpar->hMdDec->mixer_mat_prev[3][0][0], hSpar->hMdDec->mixer_mat_prev[2][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS );
            mvr2r( hSpar->hMdDec->mixer_mat_prev[4][0][0], hSpar->hMdDec->mixer_mat_prev[3][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS );

            for ( out_ch = 0; out_ch < nchan_out; out_ch++ )
            for ( ch_out = 0; ch_out < nchan_out; ch_out++ )
            {
                for ( in_ch = 0; in_ch < nchan_inp; in_ch++ )
                for ( ch_in = 0; ch_in < nchan_inp; ch_in++ )
                {
                    for ( b = 0; b < num_spar_bands; b++ )
                    {
                        hSpar->hMdDec->mixer_mat_prev[4][out_ch][in_ch][b] = hSpar->hMdDec->mixer_mat[out_ch][in_ch][b + sf_idx * IVAS_MAX_NUM_BANDS];
                        hSpar->hMdDec->mixer_mat_prev[4][ch_out][ch_in][b] = hSpar->hMdDec->mixer_mat[ch_out][ch_in][b + sf_idx * IVAS_MAX_NUM_BANDS];
                    }
                }
            }
Loading