Commit aa7f4539 authored by vaclav's avatar vaclav
Browse files

fix (avoid the adjustment in the very first frame)

parent 134ce55e
Loading
Loading
Loading
Loading
Loading
+24 −13
Original line number Diff line number Diff line
@@ -1053,21 +1053,17 @@ ivas_error IVAS_DEC_ReadFormat(

#ifdef NONBE_1303_REND_GRANULARITY
        if ( ( renderer_type_old != st_ivas->renderer_type && renderer_type_old != RENDERER_DISABLE ) ||
             ( renderer_type_sec_old != renderer_type_sec_new ) )
#else
        if ( ( renderer_type_old != st_ivas->renderer_type && renderer_type_old != RENDERER_DISABLE ) ||
             ( st_ivas->ini_active_frame > 0 && ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode != ISM_MASA_MODE_DISC ) )
#endif
             ( renderer_type_sec_old != renderer_type_sec_new && st_ivas->ini_active_frame > 0 ) )
        {
            /* JBM: when granularity goes down (e.g. Discrete ISM with TD Obj Renderer -> ParamISM with binaural fastconv
            render what still fits in the new granularity */
#ifdef NONBE_1303_REND_GRANULARITY
            int16_t tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, renderer_type_sec_new, st_ivas->hDecoderConfig->output_Fs );
#else
            int16_t tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs );
#endif
            st_ivas->nchan_transport = nchan_transport_old;

            if ( st_ivas->hTcBuffer == NULL )
            {
                return IVAS_ERR_UNEXPECTED_NULL_POINTER;
            }

            /* JBM: when granularity goes down, render what still fits in the new granularity */
            if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity )
            {
                if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &st_ivas->hIntSetup, mc_mode_old, ism_mode_old, &hIvasDec->nSamplesFlushed, pcm_type_API_to_internal( hIvasDec->pcmType ), hIvasDec->flushbuffer ) ) != IVAS_ERR_OK )
@@ -1075,8 +1071,7 @@ ivas_error IVAS_DEC_ReadFormat(
                    return error;
                }
            }
#ifdef NONBE_1303_REND_GRANULARITY
            /* JBM: when granularity goes up set samples to discard at the beginning of the frame */
            /* JBM: when granularity goes up, discard samples at the beginning of the frame */
            else if ( tc_granularity_new > st_ivas->hTcBuffer->n_samples_granularity )
            {
                if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK )
@@ -1084,6 +1079,22 @@ ivas_error IVAS_DEC_ReadFormat(
                    return error;
                }
            }
#else
        if ( ( renderer_type_old != st_ivas->renderer_type && renderer_type_old != RENDERER_DISABLE ) ||
             ( st_ivas->ini_active_frame > 0 && ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode != ISM_MASA_MODE_DISC ) )
        {
            /* JBM: when granularity goes down (e.g. Discrete ISM with TD Obj Renderer -> ParamISM with binaural fastconv
            render what still fits in the new granularity */
            int16_t tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs );
            st_ivas->nchan_transport = nchan_transport_old;

            if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity )
            {
                if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &st_ivas->hIntSetup, mc_mode_old, ism_mode_old, &hIvasDec->nSamplesFlushed, pcm_type_API_to_internal( hIvasDec->pcmType ), hIvasDec->flushbuffer ) ) != IVAS_ERR_OK )
                {
                    return error;
                }
            }
#endif
        }
    }