Commit 46a44754 authored by Dominik Weckbecker's avatar Dominik Weckbecker 💬
Browse files

add ISM_SBA_FORMAT condition to ivas_jbm_dec_tc and ivas_jbm_dec_render

parent 0fc9528d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -158,6 +158,7 @@
#define OSBA_SPLIT_RENDERING
#endif

#define JBM_FOR_OSBA

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

+143 −7
Original line number Diff line number Diff line
@@ -402,6 +402,121 @@ ivas_error ivas_jbm_dec_tc(
            ivas_jbm_dec_copy_masa_meta_to_buffer( st_ivas );
        }
    }
#ifdef JBM_FOR_OSBA
    else if ( st_ivas->ivas_format == SBA_ISM_FORMAT )
    {
        int16_t nchan_ism, sba_ch_idx;

        set_s( nb_bits_metadata, 0, MAX_SCE + 1 );
        nchan_ism = st_ivas->nchan_ism;
        if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC )
        {
            /* set ISM parameters and decode ISM metadata in OSBA format */
            if ( ( error = ivas_osba_ism_metadata_dec( st_ivas, ivas_total_brate, &nchan_ism, &nb_bits_metadata[1] ) ) != IVAS_ERR_OK )
            {
                return error;
            }
            sba_ch_idx = st_ivas->nchan_ism;
        }
        else
        {
            nb_bits_metadata[1] += NO_BITS_MASA_ISM_NO_OBJ;
            sba_ch_idx = 0;
        }

        /* SBA metadata decoding */
        if ( ( error = ivas_spar_dec( st_ivas, nb_bits_metadata ) ) != IVAS_ERR_OK )
        {
            return error;
        }

        if ( st_ivas->nchan_transport == CPE_CHANNELS && st_ivas->nCPE >= 1 )
        {
            st_ivas->hCPE[0]->element_brate = ivas_total_brate;
        }

        /* core-decoding of transport channels */
        if ( st_ivas->nSCE == 1 )
        {
            st = st_ivas->hSCE[0]->hCoreCoder[0];
            if ( ( error = ivas_sce_dec( st_ivas, 0, &output[0], output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK )
            {
                return error;
            }
        }
        else if ( st_ivas->nCPE == 1 )
        {
            st = st_ivas->hCPE[0]->hCoreCoder[0];
            if ( ( error = ivas_cpe_dec( st_ivas, 0, output, output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK )
            {
                return error;
            }
        }
        else if ( st_ivas->nCPE > 1 )
        {
            st = st_ivas->hCPE[0]->hCoreCoder[0];
            if ( ( error = ivas_mct_dec( st_ivas, output, output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK )
            {
                return error;
            }
        }

        if ( st_ivas->sba_dirac_stereo_flag )
        {
            ivas_agc_dec_process( st_ivas->hSpar->hAgcDec, &output[sba_ch_idx], &output[sba_ch_idx], st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, output_frame );

            if ( st_ivas->hSpar->hPCA != NULL )
            {
                ivas_pca_dec( st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, &output[sba_ch_idx] );
            }

            ivas_spar_dec_gen_umx_mat( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi,
                                       ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate,
                                                                           st_ivas->last_active_ivas_total_brate ) );

            ivas_sba_dirac_stereo_dec( st_ivas, &output[sba_ch_idx], output_frame, 0 );
        }

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

        nchan_remapped = ivas_sba_remapTCs( &output[sba_ch_idx], st_ivas, output_frame );

#ifdef DEBUG_OSBA
        if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC )
        {
            int16_t nchan = st_ivas->nchan_transport + st_ivas->nchan_ism;
            for ( int16_t t = 0; t < output_frame; t++ )
            {
                for ( int16_t c = 0; c < nchan; c++ )
                {
                    int16_t val = ( int16_t )( output[c][t] + 0.5f );
                    dbgwrite( &val, sizeof( int16_t ), 1, 1, "./res/TC_dec_core_out.raw" );
                }
            }
        }
#endif
        if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM )
        {
            num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate );

            ivas_sba_mix_matrix_determiner( st_ivas->hSpar, &output[sba_ch_idx], st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames );
        }
        else if ( st_ivas->renderer_type != RENDERER_DISABLE )
        {
            ivas_spar_dec_agc_pca( st_ivas, &output[sba_ch_idx], output_frame );
        }

        if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM )
        {
            /* loudness correction */
            ivas_dirac_dec_binaural_sba_gain( &output[sba_ch_idx], nchan_remapped, output_frame );
        }
    }
#endif
    else if ( st_ivas->ivas_format == MC_FORMAT )
    {
        st = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0];
@@ -962,6 +1077,27 @@ ivas_error ivas_jbm_dec_render(
            ivas_omasa_dirac_rend_jbm( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output );
        }
    }
#ifdef JBM_FOR_OSBA
    else if ( st_ivas->ivas_format == SBA_ISM_FORMAT )
    {
        nchan_remapped = nchan_transport;

        /* Loudspeakers, Ambisonics or Binaural rendering */

		if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC )
        {
			assert( 0 && "This is not supported!" );
		}
		else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM )
        {
            ivas_dirac_dec_binaural_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output );
        }
        else /* SBA_MODE_SPAR */
        {
            ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output );
        }
	}
#endif
    else if ( st_ivas->ivas_format == MC_FORMAT )
    {
        if ( st_ivas->mc_mode == MC_MODE_MCT )