Commit 6f59f91a authored by vaclav's avatar vaclav
Browse files

port MR

parent 545f05d1
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -221,7 +221,7 @@
#define FIX_1369_HQ_LR_OVERFLOW                         /* FhG: fix BASOP overflow in hq_lr_enc(), brings floating-point code inline with FX */
#define NONBE_1118_EVS_LR_HQ_BITERROR                   /* VA: issue 1118: fix EVS decoder crash in LR-HQ in case of bit errors */
#define FIX_1139_REV_COLORATION_SHORT_T60               /* Nokia,FhG: Fix issue 1139, prevent sound coloration artefacts at very low reverberation times */

#define NONBE_1302_FIX_OMASA_JBM_FLUSH                  /* VA: issue 1302: fix OMASA JBM bitrate switching flush in binaural output */
#define NONBE_1328_FIX_NON_LINEARITY                    /* VA: Fix possible issue when computing bwe_exc_extended and previous frame were almost 0  */

/* #################### End BASOP porting switches ############################ */
+42 −1
Original line number Diff line number Diff line
@@ -1701,13 +1701,49 @@ ivas_error ivas_jbm_dec_flush_renderer(
#else
                float *tc_local[MAX_TRANSPORT_CHANNELS];
#endif
#ifdef NONBE_1302_FIX_OMASA_JBM_FLUSH
                int16_t last_dirac_md_idx;
                uint16_t nSamplesAvailableNext;
                ISM_MODE ism_mode_orig;
                RENDERER_TYPE renderer_type_orig;
                int32_t ivas_total_brate;
#endif

                /* copy from ISM delay buffer to the correct place in TCs */
                for ( ch_idx = 0; ch_idx < st_ivas->nchan_ism; ch_idx++ )
                {
                    tc_local[ch_idx] = &st_ivas->hTcBuffer->tc[ch_idx + 2][hTcBuffer->n_samples_rendered];
                    mvr2r( st_ivas->hMasaIsmData->delayBuffer[ch_idx], tc_local[ch_idx], st_ivas->hMasaIsmData->delayBuffer_size );
                }

#ifdef NONBE_1302_FIX_OMASA_JBM_FLUSH
                /* to render flushed samples, use configuration from the last received frame */
                ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
                renderer_type_orig = st_ivas->renderer_type;
                ism_mode_orig = st_ivas->ism_mode;
                st_ivas->ism_mode = ism_mode_old;
                st_ivas->renderer_type = renderer_type_old;
                st_ivas->hDecoderConfig->ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate;
                last_dirac_md_idx = st_ivas->hSpatParamRendCom->render_to_md_map[st_ivas->hSpatParamRendCom->slots_rendered - 1];

                /* transfer adapted sf info from hTcBuffer to DirAC */
                st_ivas->hSpatParamRendCom->nb_subframes = 1;
                st_ivas->hSpatParamRendCom->subframes_rendered = 0;
                st_ivas->hSpatParamRendCom->subframe_nbslots[0] = JBM_CLDFB_SLOTS_IN_SUBFRAME;
                st_ivas->hSpatParamRendCom->slots_rendered = 0;
                st_ivas->hSpatParamRendCom->num_slots = JBM_CLDFB_SLOTS_IN_SUBFRAME;
                set_s( st_ivas->hSpatParamRendCom->render_to_md_map, last_dirac_md_idx, n_slots_still_available );

                if ( ( error = ivas_omasa_dirac_td_binaural_jbm( st_ivas, (uint16_t) hTcBuffer->n_samples_granularity, nSamplesRendered, &nSamplesAvailableNext, CPE_CHANNELS, p_output ) ) != IVAS_ERR_OK )
                {
                    return error;
                }

                /* restore original configuration */
                st_ivas->ism_mode = ism_mode_orig;
                st_ivas->renderer_type = renderer_type_orig;
                st_ivas->hDecoderConfig->ivas_total_brate = ivas_total_brate;
#else
#ifdef NONBE_1220_OMASA_JBM_BRATE_SW_FLUSH
                if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_output, hTcBuffer->n_samples_granularity ) ) != IVAS_ERR_OK )
                {
@@ -1730,6 +1766,7 @@ ivas_error ivas_jbm_dec_flush_renderer(
                    st_ivas->hTcBuffer->slots_rendered += 1;
                    st_ivas->hTcBuffer->subframes_rendered += 1;
                }
#endif
#endif
            }
        }
@@ -1740,12 +1777,14 @@ ivas_error ivas_jbm_dec_flush_renderer(
            int16_t last_dirac_md_idx;
            uint16_t nSamplesAvailableNext;

            /* to render flushed samples, use configuration from the last received frame */

            last_spar_md_idx = st_ivas->hSpar->render_to_md_map[st_ivas->hSpar->slots_rendered - 1];
            last_dirac_md_idx = st_ivas->hSpatParamRendCom->render_to_md_map[st_ivas->hSpatParamRendCom->slots_rendered - 1];
#ifdef DEBUGGING
            assert( ism_mode_old == ISM_SBA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV );
#endif
            /* copy from ISM delay buffer to the correct place in tcs */
            /* copy from ISM delay buffer to the correct place in TCs */
            for ( ch_idx = 0; ch_idx < st_ivas->nchan_ism; ch_idx++ )
            {
                tc_local[ch_idx] = &st_ivas->hTcBuffer->tc[ch_idx + 2][hTcBuffer->n_samples_rendered];
@@ -1773,6 +1812,8 @@ ivas_error ivas_jbm_dec_flush_renderer(
            {
                return error;
            }

            /* restore original configuration */
        }
        else
        {