Commit efa4d765 authored by vaclav's avatar vaclav
Browse files

add comments

parent aa7f4539
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -485,7 +485,7 @@ void ivas_renderer_select(
/*-------------------------------------------------------------------------*
 * ivas_renderer_secondary_select()
 *
 * Select and configure IVAS secondary binaural renderer (used in combine formats)
 * Select IVAS secondary binaural renderer (used in combine formats)
 *-------------------------------------------------------------------------*/

/*! r: secondary binaural renderer type */
+58 −6
Original line number Diff line number Diff line
@@ -896,6 +896,49 @@ ivas_error IVAS_DEC_FeedFrame_Serial(
    return IVAS_ERR_OK;
}

#ifdef NONBE_1303_REND_GRANULARITY

/*---------------------------------------------------------------------*
 * renderer_type_to_mode()
 *
 * Convert (codec library) renderer type to (API public) binaural renderer mode
 *---------------------------------------------------------------------*/

/*! r: binaural renderer mode (API type) */
static IVAS_BIN_RENDERER_TYPE renderer_type_to_mode(
    const RENDERER_TYPE renderer_type /* i  : renderer type (codec library type) */
)
{
    IVAS_BIN_RENDERER_TYPE binaural_renderer;

    switch ( renderer_type )
    {
        case RENDERER_BINAURAL_OBJECTS_TD:
            binaural_renderer = IVAS_BIN_RENDERER_TYPE_TDREND;
            break;
        case RENDERER_BINAURAL_MIXER_CONV:
        case RENDERER_BINAURAL_MIXER_CONV_ROOM:
            binaural_renderer = IVAS_BIN_RENDERER_TYPE_CREND;
            break;
        case RENDERER_BINAURAL_FASTCONV:
            binaural_renderer = IVAS_BIN_RENDERER_TYPE_FASTCONV;
            break;
        case RENDERER_BINAURAL_FASTCONV_ROOM:
            binaural_renderer = IVAS_BIN_RENDERER_TYPE_FASTCONV;
            break;
        case RENDERER_BINAURAL_PARAMETRIC:
        case RENDERER_BINAURAL_PARAMETRIC_ROOM:
            binaural_renderer = IVAS_BIN_RENDERER_TYPE_PARAMBIN;
            break;
        default:
            binaural_renderer = IVAS_BIN_RENDERER_TYPE_NONE;
            break;
    }

    return binaural_renderer;
}

#endif

/*---------------------------------------------------------------------*
 * IVAS_DEC_ReadFormat( )
@@ -962,11 +1005,15 @@ ivas_error IVAS_DEC_ReadFormat(
            return ( IVAS_ERROR( IVAS_ERR_INVALID_INPUT_FORMAT, "IVAS format switching is not allowed." ) );
        }

        /* Select binaural renderer */
        ivas_renderer_select( st_ivas );
#ifdef NONBE_1303_REND_GRANULARITY
        renderer_type_sec_new = ivas_renderer_secondary_select( st_ivas );
#endif
        *binaural_renderer = renderer_type_to_mode( st_ivas->renderer_type );

        /* Select secondary binaural renderer (used in combine formats) */
        renderer_type_sec_new = ivas_renderer_secondary_select( st_ivas );
        *binaural_renderer_sec = renderer_type_to_mode( renderer_type_sec_new );
#else
        switch ( st_ivas->renderer_type )
        {
            case RENDERER_BINAURAL_OBJECTS_TD:
@@ -1002,8 +1049,10 @@ ivas_error IVAS_DEC_ReadFormat(
        {
            *binaural_renderer_sec = IVAS_BIN_RENDERER_TYPE_TDREND;
        }
#endif
#endif

        /* select HRTF audio configuration to load the right HRTF set for the external binary file */
        *hrtf_set_audio_cfg = IVAS_AUDIO_CONFIG_INVALID;
        if ( *binaural_renderer == IVAS_BIN_RENDERER_TYPE_FASTCONV )
        {
@@ -1052,10 +1101,13 @@ 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 && st_ivas->ini_active_frame > 0 ) )
        /* JBM: handle cases when binaural renderer granularity changes (happens in bitrate switching) */
        if ( st_ivas->ini_active_frame > 0 && st_ivas->hDecoderConfig->Opt_tsm &&
             ( ( renderer_type_old != st_ivas->renderer_type ) ||
               ( renderer_type_sec_old != renderer_type_sec_new ) ) )
        {
            int16_t tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, renderer_type_sec_new, st_ivas->hDecoderConfig->output_Fs );

            st_ivas->nchan_transport = nchan_transport_old;

            if ( st_ivas->hTcBuffer == NULL )
@@ -1063,7 +1115,7 @@ ivas_error IVAS_DEC_ReadFormat(
                return IVAS_ERR_UNEXPECTED_NULL_POINTER;
            }

            /* JBM: when granularity goes down, render what still fits in the new granularity */
            /* 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 )
@@ -1071,7 +1123,7 @@ ivas_error IVAS_DEC_ReadFormat(
                    return error;
                }
            }
            /* JBM: when granularity goes up, discard samples at the beginning of the frame */
            /* 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 )