Commit 84d6df09 authored by vaclav's avatar vaclav
Browse files

- call PCA decoder only when needed

- improve comments
parent afc6325b
Loading
Loading
Loading
Loading
+11 −8
Original line number Diff line number Diff line
@@ -3064,7 +3064,7 @@ ivas_error ivas_sba_linear_renderer(
    const int16_t nchan_in,                                     /* i  : number of input ambisonics channels                     */
    const AUDIO_CONFIG output_config,                           /* i  : output audio configuration                              */
    const IVAS_OUTPUT_SETUP output_setup,                       /* i  : output format setup                                     */
    const float hoa_dec_mtx[]                                   /* i  : hoa decoding mtx                                        */
    const float hoa_dec_mtx[]                                   /* i  : HOA decoding mtx                                        */
);

int16_t ivas_sba_remapTCs(
@@ -3848,6 +3848,9 @@ ivas_error ivas_spar_foa_enc_process(
ivas_error ivas_spar_foa_dec_open(
    ivas_spar_foa_dec_state_t **hSparFoa,                       /* i/o: SPAR FOA decoder handle                 */
    const DECODER_CONFIG_HANDLE hDecoderConfig,                 /* i  : configuration structure                 */
#ifdef SBA_CLEANING
    const int16_t sba_order,                                    /* i  : Ambisonic (SBA) order                   */
#endif
    const int16_t nchan_internal                                /* i  : number of internal channels             */
);

@@ -4126,7 +4129,7 @@ void ivas_td_decorr_process(


/* PCA */
void init_pca_enc( 
void ivas_pca_enc_init( 
    PCA_ENC_STATE *hPCA                                         /* i/o: PCA encoder structure                   */
);

@@ -4144,7 +4147,7 @@ void ivas_pca_read_bits(
    PCA_DEC_STATE *hPCA                                         /* i/o: PCA encoder structure                   */
);

void init_pca_dec( 
void ivas_pca_dec_int( 
    PCA_DEC_STATE *hPCA                                         /* i/o: PCA decoder structure                   */
);

@@ -4586,7 +4589,7 @@ void ivas_sba2mc_cldfb(
    float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: cldfb imag part                     */
    const int16_t nb_channels_out,                                          /* i  : nb of output channels               */
    const int16_t nb_bands,                                                 /* i  : nb of CLDFB bands to process        */
    const float *hoa_dec_mtx                                                /* i  : hoa decoding mtx                    */
    const float *hoa_dec_mtx                                                /* i  : HOA decoding mtx                    */
);

void ivas_ism2sba(
+34 −24
Original line number Diff line number Diff line
@@ -62,25 +62,6 @@ static int32_t ivas_bitstream_read_int32(
}


void ivas_pca_read_bits(
    Decoder_State *st0, /* i/o: decoder state structure - for bitstream handling*/
    PCA_DEC_STATE *hPCA )
{
    /*first bit in the PCA payload (first bit after 3 header bits) signals bypass/active*/
    hPCA->pca_bypass = get_next_indice( st0, 1 );

    if ( hPCA->pca_bypass == PCA_MODE_INACTIVE )
    {
        return;
    }

    hPCA->index[0] = ivas_bitstream_read_int32( st0, IVAS_PCA_QBITS - 1 );
    hPCA->index[1] = ivas_bitstream_read_int32( st0, IVAS_PCA_QBITS );

    return;
}


static void pca_dec_reset_dquat(
    float *ql,
    float *qr )
@@ -126,6 +107,7 @@ static void pca_inv_transform_sub(
        {
            buffer_data[k] = transformed_data[k][j + start];
        }

        for ( k = 0; k < n_channels; k++ )
        {
            temp = 0.0f;
@@ -158,14 +140,16 @@ static void pca_dec_inv_transform(
    pca_interp_preproc( hPCA->prev_ql, hPCA->prev_qr, ql, qr, IVAS_PCA_N_SLOTS, ql_interp, qr_interp );

    slot_len = (int16_t) ( n_samples / IVAS_PCA_N_SLOTS );

    for ( j = 0; j < IVAS_PCA_N_SLOTS; j++ )
    {
        /* convert from double quaternion to 4D matrix */
        dquat2mat( &ql_interp[4 * j], &qr_interp[4 * j], &hPCA->mem_eigVec_interp[16 * j + IVAS_PCA_DELAY_CMP * 16] );

        pca_inv_transform_sub( &hPCA->mem_eigVec_interp[16 * j], decoded_data,
                               slot_len * j, slot_len, n_channels );
        pca_inv_transform_sub( &hPCA->mem_eigVec_interp[16 * j], decoded_data, slot_len * j, slot_len, n_channels );
    }

    return;
}


@@ -183,12 +167,12 @@ static void pca_dec_update_dquat(


/*-------------------------------------------------------------------------
 * init_pca_dec()
 * ivas_pca_dec_int()
 *
 * initialize PCA decoder
 * Initialize PCA decoder
 *------------------------------------------------------------------------*/

void init_pca_dec(
void ivas_pca_dec_int(
    PCA_DEC_STATE *hPCA /* i/o: PCA decoder structure  */
)
{
@@ -202,6 +186,31 @@ void init_pca_dec(
}


/*-------------------------------------------------------------------------
 * ivas_pca_read_bits()
 *
 * Decode PCA indexes
 *------------------------------------------------------------------------*/

void ivas_pca_read_bits(
    Decoder_State *st0, /* i/o: decoder state structure - for bitstream handling*/
    PCA_DEC_STATE *hPCA )
{
    /*first bit in the PCA payload (first bit after 3 header bits) signals bypass/active*/
    hPCA->pca_bypass = get_next_indice( st0, 1 );

    if ( hPCA->pca_bypass == PCA_MODE_INACTIVE )
    {
        return;
    }

    hPCA->index[0] = ivas_bitstream_read_int32( st0, IVAS_PCA_QBITS - 1 );
    hPCA->index[1] = ivas_bitstream_read_int32( st0, IVAS_PCA_QBITS );

    return;
}


/*-------------------------------------------------------------------------
 * ivas_pca_dec()
 *
@@ -220,6 +229,7 @@ void ivas_pca_dec(
{
    float ql[4], qr[4];
    int16_t pca_bypass;

    mvr2r( &hPCA->mem_eigVec_interp[IVAS_PCA_N_SLOTS * 16], hPCA->mem_eigVec_interp, IVAS_PCA_DELAY_CMP * 16 );

    /* @@@TODO: check how ivas_total_brate is set if bfi == 1 */ // VE: and what happens in DTX where "ivas_total_brate" can be close to zero?
+1 −1
Original line number Diff line number Diff line
@@ -150,7 +150,7 @@ void ivas_sba2mc_cldfb(
    float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: cldfb imag part               */
    const int16_t nb_channels_out,                                          /* i  : nb of output channels         */
    const int16_t nb_bands,                                                 /* i  : nb of CLDFB bands to process  */
    const float *hoa_dec_mtx                                                /* i  : hoa decoding mtx              */
    const float *hoa_dec_mtx                                                /* i  : HOA decoding mtx              */
)
{
    int16_t iBlock, iBand, n, m;
+2 −2
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ ivas_error ivas_sba_linear_renderer(
    const int16_t nchan_in,               /* i  : number of input ambisonics channels                     */
    const AUDIO_CONFIG output_config,     /* i  : output audio configuration                              */
    const IVAS_OUTPUT_SETUP output_setup, /* i  : output format setup                                     */
    const float hoa_dec_mtx[]             /* i  : hoa decoding mtx                                        */
    const float hoa_dec_mtx[]             /* i  : HOA decoding mtx                                        */
)
{
    int16_t i;
@@ -147,7 +147,7 @@ static void ivas_sba_mtx_mult(
    const int16_t output_frame,     /* i  : output frame length per channel                         */
    const int16_t nchan_in,         /* i  : Number of ambisonic channels                            */
    IVAS_OUTPUT_SETUP output_setup, /* i  : Output configuration                                    */
    const float *mtx_hoa_decoder    /* i  : Hoa decoding mtx                                        */
    const float *mtx_hoa_decoder    /* i  : HOA decoding mtx                                        */
)
{
    int16_t i, k, ch_idx;
+4 −0
Original line number Diff line number Diff line
@@ -75,7 +75,11 @@ ivas_error ivas_spar_dec_open(
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR decoder" );
    }

#ifdef SBA_CLEANING
    if ( ( error = ivas_spar_foa_dec_open( &hSpar->hSparFoa, st_ivas->hDecoderConfig, sba_order_internal, num_channels_internal ) ) != IVAS_ERR_OK )
#else
    if ( ( error = ivas_spar_foa_dec_open( &hSpar->hSparFoa, st_ivas->hDecoderConfig, num_channels_internal ) ) != IVAS_ERR_OK )
#endif
    {
        return error;
    }
Loading