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

Changes sync between audio and metadata in OMASA to follow the paradigm in MASA.

parent d34332b6
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -70,7 +70,11 @@ int32_t get_delay(
            delay = IVAS_ENC_DELAY_NS;

#ifdef FIX_350_MASA_DELAY_COMP
#ifdef FIX_OMASA_DELAY_COMP
            if ( ivas_format == MASA_FORMAT || ivas_format == MASA_ISM_FORMAT )
#else
            if ( ivas_format == MASA_FORMAT )
#endif
            {
                delay = 0; /* All delay is compensated in the decoder with MASA */
            }
@@ -108,7 +112,11 @@ int32_t get_delay(


#ifdef FIX_350_MASA_DELAY_COMP
#ifdef FIX_OMASA_DELAY_COMP
            if ( ivas_format == MASA_FORMAT || ivas_format == MASA_ISM_FORMAT )
#else
            if ( ivas_format == MASA_FORMAT )
#endif
            {
                delay += IVAS_ENC_DELAY_NS; /* Compensate also the encoder delay in the decoder with MASA */
            }
+4 −0
Original line number Diff line number Diff line
@@ -5191,8 +5191,12 @@ ivas_error ivas_omasa_enc_open(
);

void ivas_omasa_enc_close(
#ifdef FIX_OMASA_DELAY_COMP
    OMASA_ENC_HANDLE hOMasa                                     /* i/o: encoder OMASA handle                    */
#else
    OMASA_ENC_HANDLE hOMasa,                                    /* i/o: encoder OMASA handle                    */
    const int16_t nchan_ism                                     /* i  : number of objects                       */
#endif
);

#ifdef OMASA_BRATE_SW
+2 −1
Original line number Diff line number Diff line
@@ -144,7 +144,7 @@
#define FIX_103_RA_PARAMS_PARAM_BIN_REND                /* Issue 103: Digest room acoustics parameters for Parametric Binaural Renderer*/
/*#define SBA_HPF_TUNING_DEC*/

/*#define FIX_350_MASA_DELAY_COMP*/                         /* Nokia: Issue 350: MASA audio/meta delay compensation */
#define FIX_350_MASA_DELAY_COMP                         /* Nokia: Issue 350: MASA audio/meta delay compensation */
#define FIX_MDCT_BASED_BWD                              /* FhG: fixes for BWD for issues with reaction to transients for MDCT-stereo and MCT */
#define DISCRETE_ISM_DTX_CNG                            /* FhG/VA: contribution 15 - DTX/CNG for (discrete) ISM */
#define NCHAN_ISM_PARAMETER                             /* VA: make 'nchan_ism' parameter part of st_ivas/hEncoderConfig */
@@ -177,6 +177,7 @@
#define OMASA_BRATE_SW                  /* VA: support of bitrate switching in OMASA format */
#define FIX_TD5_IN_OMASA                // do not transmit extended MD in OMASA
#define OMASA_TUNING_TD_STEREO          /* VA: tuning of TD stereo in OMASA format */
#define FIX_OMASA_DELAY_COMP                            /* Nokia: OMASA audio/meta delay compensation */

#endif  /* MASA_AND_OBJECTS */

+49 −0
Original line number Diff line number Diff line
@@ -479,6 +479,10 @@ ivas_error ivas_dec(
#ifdef MASA_AND_OBJECTS
    else if ( st_ivas->ivas_format == MASA_ISM_FORMAT )
    {
#ifdef FIX_OMASA_DELAY_COMP
        int16_t dirac_bs_md_write_idx = 0;
#endif

        st = st_ivas->hCPE[0]->hCoreCoder[0];
        nb_bits_metadata[0] = 0;
        set_s( nb_bits_metadata, 0, MAX_SCE + 1 );
@@ -498,6 +502,10 @@ ivas_error ivas_dec(
            {
                st_ivas->hDirAC->numIsmDirections = 0;
            }

#ifdef FIX_OMASA_DELAY_COMP
            dirac_bs_md_write_idx = st_ivas->hDirAC->dirac_bs_md_write_idx; /* Store the write-index for this frame */
#endif
        }

        /* MASA metadata decoding */
@@ -548,6 +556,13 @@ ivas_error ivas_dec(
        if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC || st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ )
#endif
        {
#ifdef FIX_OMASA_DELAY_COMP
            int16_t azimuth_ism;
            int16_t elevation_ism;
            int16_t block;
            int16_t meta_write_index;
#endif

            /* decode ISM metadata */
#ifdef NCHAN_ISM_PARAMETER
            if ( ( error = ivas_ism_metadata_dec( ism_total_brate,
@@ -570,14 +585,38 @@ ivas_error ivas_dec(
            {
                for ( n = 0; n < st_ivas->nchan_ism; n++ )
                {
#ifdef FIX_OMASA_DELAY_COMP
                    azimuth_ism = (int16_t) ( st_ivas->hIsmMetaData[n]->azimuth + 0.5f );
                    elevation_ism = (int16_t) ( st_ivas->hIsmMetaData[n]->elevation + 0.5f );

                    for ( block = 0; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++ )
                    {
                        meta_write_index = ( dirac_bs_md_write_idx + block ) % st_ivas->hDirAC->dirac_md_buffer_length;
                        st_ivas->hMasaIsmData->azimuth_ism[n][meta_write_index] = azimuth_ism;
                        st_ivas->hMasaIsmData->elevation_ism[n][meta_write_index] = elevation_ism;
                    }
#else
                    st_ivas->hMasaIsmData->azimuth_ism[n] = (int16_t) ( st_ivas->hIsmMetaData[n]->azimuth + 0.5f );
                    st_ivas->hMasaIsmData->elevation_ism[n] = (int16_t) ( st_ivas->hIsmMetaData[n]->elevation + 0.5f );
#endif
                }
            }
            else /* ISM_MASA_MODE_MASA_ONE_OBJ */
            {
#ifdef FIX_OMASA_DELAY_COMP
                azimuth_ism = (int16_t) ( st_ivas->hIsmMetaData[0]->azimuth + 0.5f );
                elevation_ism = (int16_t) ( st_ivas->hIsmMetaData[0]->elevation + 0.5f );

                for ( block = 0; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++ )
                {
                    meta_write_index = ( dirac_bs_md_write_idx + block ) % st_ivas->hDirAC->dirac_md_buffer_length;
                    st_ivas->hMasaIsmData->azimuth_separated_ism[meta_write_index] = azimuth_ism;
                    st_ivas->hMasaIsmData->elevation_separated_ism[meta_write_index] = elevation_ism;
                }
#else
                st_ivas->hMasaIsmData->azimuth_separated_ism = (int16_t) ( st_ivas->hIsmMetaData[0]->azimuth + 0.5f );
                st_ivas->hMasaIsmData->elevation_separated_ism = (int16_t) ( st_ivas->hIsmMetaData[0]->elevation + 0.5f );
#endif
            }
#else
            for ( n = 0; n < st_ivas->nchan_ism; n++ )
@@ -687,6 +726,10 @@ ivas_error ivas_dec(
#endif
            {
                float data_separated_objects[MAX_NUM_OBJECTS][L_FRAME48k];
#ifdef FIX_OMASA_DELAY_COMP
                int16_t dirac_read_idx;
#endif

#ifdef OMASA_UPDATES
                if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ )
#else
@@ -703,8 +746,14 @@ ivas_error ivas_dec(
                    }
                }

#ifdef FIX_OMASA_DELAY_COMP
                dirac_read_idx = st_ivas->hDirAC->dirac_read_idx;
#endif
                ivas_dirac_dec( st_ivas, output, st_ivas->nchan_transport, NULL, NULL, -1 );

#ifdef FIX_OMASA_DELAY_COMP
                st_ivas->hDirAC->dirac_read_idx = dirac_read_idx; /* Original read index is needed for the next function which will update it again */
#endif
                ivas_masa_ism_separate_object_render( st_ivas, data_separated_objects, output, output_frame );
            }
            else
+4 −0
Original line number Diff line number Diff line
@@ -845,7 +845,11 @@ ivas_error ivas_dirac_dec_config(
        {
            hDirAC->dirac_md_buffer_length = MAX_PARAM_SPATIAL_SUBFRAMES;
        }
#ifdef FIX_OMASA_DELAY_COMP
        else if ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT )
#else
        else if ( st_ivas->ivas_format == MASA_FORMAT )
#endif
        {
            hDirAC->dirac_md_buffer_length = MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR;
            hDirAC->dirac_bs_md_write_idx = DELAY_MASA_PARAM_DEC_SFR;
Loading