Commit b029297c authored by vaclav's avatar vaclav
Browse files

introduce function ivas_omasa_dirac_td_binaural() in order to safe stack memory

parent 214ddc70
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -5233,7 +5233,13 @@ ivas_error ivas_omasa_ism_metadata_dec(
    int16_t nb_bits_metadata[]                                  /* o  : number of ISM metadata bits             */
);

void ivas_omasa_rend(
ivas_error ivas_omasa_dirac_td_binaural(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                  */
    float output[][L_FRAME48k],                                 /* o  : output synthesis signal                 */
    const int16_t output_frame                                  /* i  : output frame length per channel         */
);

void ivas_omasa_dirac_rend(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                  */
    float output[][L_FRAME48k],                                 /* o  : output synthesis signal                 */
    const int16_t output_frame                                  /* i  : output frame length per channel         */
+4 −25
Original line number Diff line number Diff line
@@ -405,7 +405,7 @@ ivas_error ivas_dec(
    else if ( st_ivas->ivas_format == MASA_ISM_FORMAT )
    {
        int16_t nchan_ism, nchan_transport_ism;
        int16_t dirac_bs_md_write_idx, dirac_read_idx;
        int16_t dirac_bs_md_write_idx;

        st = st_ivas->hCPE[0]->hCoreCoder[0];
        set_s( nb_bits_metadata, 0, MAX_SCE + 1 );
@@ -474,31 +474,10 @@ ivas_error ivas_dec(
        {
            if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC )
            {
                float data_separated_objects[MAX_NUM_OBJECTS][L_FRAME48k];
                float gain = 0.7943f; /* Todo Nokia: Temporary gain for roughly matching the loudness of other processing paths. */

                for ( n = 0; n < st_ivas->nchan_ism; n++ )
                {
                    mvr2r( output[2 + n], data_separated_objects[n], output_frame );
                    v_multc( data_separated_objects[n], gain, data_separated_objects[n], output_frame );
                }

                for ( n = 0; n < st_ivas->nchan_ism; n++ )
                {
                    delay_signal( data_separated_objects[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size );
                }

                ivas_dirac_dec_binaural( st_ivas, output, st_ivas->nchan_transport );

                if ( ( error = ivas_td_binaural_renderer( st_ivas, data_separated_objects, output_frame ) ) != IVAS_ERR_OK )
                if ( ( error = ivas_omasa_dirac_td_binaural( st_ivas, output, output_frame ) ) != IVAS_ERR_OK )
                {
                    return error;
                }

                for ( n = 0; n < BINAURAL_CHANNELS; n++ )
                {
                    v_add( output[n], data_separated_objects[n], output[n], output_frame );
                }
            }
            else
            {
@@ -513,11 +492,11 @@ ivas_error ivas_dec(
        {
            if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_DISC )
            {
                ivas_omasa_rend( st_ivas, output, output_frame );
                ivas_omasa_dirac_rend( st_ivas, output, output_frame );
            }
            else
            {
                // VE2TP: this should never happen (ISM_MODE_NONE is renderered via ivas_format==MASA_FORMAT if branch)
                // VE2TP: please verify - this should probably never happen (ISM_MODE_NONE is renderered via "ivas_format == MASA_FORMAT" if branch)
                ivas_dirac_dec( st_ivas, output, st_ivas->nchan_transport, NULL, NULL, -1 );
            }
        }
+46 −2
Original line number Diff line number Diff line
@@ -470,12 +470,12 @@ ivas_error ivas_omasa_ism_metadata_dec(


/*--------------------------------------------------------------------------*
 * ivas_omasa_rend()
 * ivas_omasa_dirac_rend()
 *
 * Rendering in OMASA format
 *--------------------------------------------------------------------------*/

void ivas_omasa_rend(
void ivas_omasa_dirac_rend(
    Decoder_Struct *st_ivas,    /* i/o: IVAS decoder structure          */
    float output[][L_FRAME48k], /* o  : output synthesis signal         */
    const int16_t output_frame  /* i  : output frame length per channel */
@@ -506,4 +506,48 @@ void ivas_omasa_rend(

    return;
}


/*--------------------------------------------------------------------------*
 * ivas_omasa_dirac_td_binaural()
 *
 * Binaural rendering in OMASA format
 *--------------------------------------------------------------------------*/

ivas_error ivas_omasa_dirac_td_binaural(
    Decoder_Struct *st_ivas,    /* i/o: IVAS decoder structure          */
    float output[][L_FRAME48k], /* o  : output synthesis signal         */
    const int16_t output_frame  /* i  : output frame length per channel */
)
{
    int16_t n;
    float data_separated_objects[MAX_NUM_OBJECTS][L_FRAME48k];
    float gain = 0.7943f; /* Todo Nokia: Temporary gain for roughly matching the loudness of other processing paths. */
    ivas_error error;

    for ( n = 0; n < st_ivas->nchan_ism; n++ )
    {
        mvr2r( output[2 + n], data_separated_objects[n], output_frame );
        v_multc( data_separated_objects[n], gain, data_separated_objects[n], output_frame );
    }

    for ( n = 0; n < st_ivas->nchan_ism; n++ )
    {
        delay_signal( data_separated_objects[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size );
    }

    ivas_dirac_dec_binaural( st_ivas, output, st_ivas->nchan_transport );

    if ( ( error = ivas_td_binaural_renderer( st_ivas, data_separated_objects, output_frame ) ) != IVAS_ERR_OK )
    {
        return error;
    }

    for ( n = 0; n < BINAURAL_CHANNELS; n++ )
    {
        v_add( output[n], data_separated_objects[n], output[n], output_frame );
    }

    return IVAS_ERR_OK;
}
#endif