Commit a24d12dd authored by bayers's avatar bayers
Browse files

further dissect the decoder functions to have a single point in the processing...

further dissect the decoder functions to have a single point in the processing chain for editing object data, add stubs to the API for editable object data handling
parent 3e4d33e7
Loading
Loading
Loading
Loading
+66 −6
Original line number Diff line number Diff line
@@ -2081,6 +2081,9 @@ static ivas_error decodeG192(
#ifdef SPLIT_REND_WITH_HEAD_ROT
    SplitFileReadWrite *splitRendWriter = NULL;
#endif
#ifdef OBJ_EDITING_INTERFACE
    IVAS_EDITABLE_PARAMETERS editableParameters;
#endif

    for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i )
    {
@@ -2342,6 +2345,30 @@ static ivas_error decodeG192(
                    fprintf( stderr, "\nError: could not feed frame to decoder: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
                    goto cleanup;
                }
#ifdef OBJ_EDITING_INTERFACE
                /* Do object info editing here */
                /* get object parameters */
                if ( ( error = IVAS_DEC_GetEditableParameters( hIvasDec, &editableParameters ) ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "\nError: could not get the editable parameters: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
                    goto cleanup;
                }

                /* edit object parameters...*/
                /* set new object parameters*/
                if ( ( error = IVAS_DEC_SetEditableParameters( hIvasDec, editableParameters ) ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "\nError: could not set the editable parameters: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
                    goto cleanup;
                }

                /* Do the final preparations needed for rendering */
                if ( ( error = IVAS_DEC_PrepareRenderer( hIvasDec ) ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "\nError: could not prepare the renderer: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
                    goto cleanup;
                }
#endif
            }

#ifdef SPLIT_REND_WITH_HEAD_ROT
@@ -2932,6 +2959,11 @@ static ivas_error decodeVoIP(
    int16_t vec_pos_update, vec_pos_len;
    int16_t nOutSamples = 0;

#ifdef OBJ_EDITING_INTERFACE
    bool parameterAvailableForEditing = false;
    uint16_t nSamplesRendered = 0;
#endif

    vec_pos_update = 0;
    if ( ( error = IVAS_DEC_GetRenderFramesizeMs( hIvasDec, &systemTimeInc_ms ) ) != IVAS_ERR_OK )
    {
@@ -3048,7 +3080,9 @@ static ivas_error decodeVoIP(

    while ( 1 )
    {

#ifdef OBJ_EDITING_INTERFACE
        nSamplesRendered = 0;
#endif
        /* reference vector */
        if ( arg.enableReferenceVectorTracking && vec_pos_update == 0 )
        {
@@ -3219,7 +3253,25 @@ static ivas_error decodeVoIP(


        /* decode and get samples */

#ifdef OBJ_EDITING_INTERFACE
        while ( nSamplesRendered < nOutSamples )
        {
#endif
#ifdef OBJ_EDITING_INTERFACE
#ifdef SPLIT_REND_WITH_HEAD_ROT
#ifdef SUPPORT_JBM_TRACEFILE
            if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter, &nSamplesRendered, &parameterAvailableForEditing ) ) != IVAS_ERR_OK )
#else
            if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, &nSamplesRendered, &parameterAvailableForEditing ) ) != IVAS_ERR_OK )
#endif
#else
#ifdef SUPPORT_JBM_TRACEFILE
            if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter, &nSamplesRendered, &parameterAvailableForEditing ) ) != IVAS_ERR_OK )
#else
            if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, pcmBuf, systemTime_ms, &nSamplesRendered, &parameterAvailableForEditing ) ) != IVAS_ERR_OK )
#endif
#endif
#else
#ifdef SPLIT_REND_WITH_HEAD_ROT
#ifdef SUPPORT_JBM_TRACEFILE
        if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter ) ) != IVAS_ERR_OK )
@@ -3232,11 +3284,19 @@ static ivas_error decodeVoIP(
#else
        if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, pcmBuf, systemTime_ms ) ) != IVAS_ERR_OK )
#endif
#endif
#endif
            {
                fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                goto cleanup;
            }
#ifdef OBJ_EDITING_INTERFACE
            if ( parameterAvailableForEditing == true )
            {
                /* do the object editing here */
            }
        } /* while ( nSamplesRendered < nOutSamples ) */
#endif

        /* write JBM Offset file entry */
        if ( jbmOffsetWriter != NULL )
+11 −0
Original line number Diff line number Diff line
@@ -122,9 +122,20 @@ typedef struct _IVAS_ISM_METADATA
    float yaw;
    float pitch;
    int16_t non_diegetic_flag;
#ifdef OBJ_EDITING_INTERFACE
    float gain;
#endif

} IVAS_ISM_METADATA;

typedef struct _IVAS_EDITABLE_PARAMETERS
{

	int16_t num_obj;
    IVAS_ISM_METADATA ism_metadata[IVAS_MAX_NUM_OBJECTS];
    float gain_bed;
} IVAS_EDITABLE_PARAMETERS;

typedef struct
{
    float w, x, y, z;
+20 −0
Original line number Diff line number Diff line
@@ -822,6 +822,12 @@ void ivas_jbm_dec_feed_tc_to_renderer(
    float *data                                                 /* i/o: transport channels/output synthesis signal                  */
);

#ifdef OBJ_EDITING_INTERFACE
void ivas_jbm_dec_prepare_renderer(
    Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder structure                                      */
);
#endif

ivas_error ivas_jbm_dec_set_discard_samples(
    Decoder_Struct *st_ivas                                     /* i/o: main IVAS decoder structre                                  */
);
@@ -1112,6 +1118,13 @@ void ivas_param_ism_dec_digest_tc(
    float *transport_channels_f[]                               /* i  : synthesized core-coder transport channels/DirAC output  */
);

#ifdef OBJ_EDITING_INTERFACE
void ivas_param_ism_dec_prepare_renderer(
    Decoder_Struct *st_ivas,   /* i/o: IVAS decoder handle                                     */
    const uint16_t nCldfbSlots /* i  : number of CLFBS slots in the transport channels         */
);
#endif

void ivas_ism_param_dec_tc_gain_ajust(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder handle                         */
    const uint16_t nSamples,                                    /* i  : number of samples to be compensate          */
@@ -3861,6 +3874,13 @@ void ivas_param_mc_dec_digest_tc(
    float *transport_channels_f[]                               /* i  : synthesized core-coder transport channels/DirAC output*/
);

#ifdef OBJ_EDITING_INTERFACE
void ivas_param_mc_dec_prepare_renderer(
    Decoder_Struct *st_ivas,  /* i/o: IVAS decoder handle                                       */
    const uint8_t nCldfbSlots /* i  : number of CLFBS slots in the transport channels           */
);
#endif

void ivas_param_mc_dec_render(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder handle                                 */
    const uint16_t nSamplesAsked,                               /* i  : number of CLDFB slots requested                     */
+4 −0
Original line number Diff line number Diff line
@@ -87,6 +87,10 @@ typedef struct
    float q_azimuth_old;
    float q_elevation_old;

#ifdef OBJ_EDITING_INTERFACE
    float gain;
#endif

} ISM_METADATA_FRAME, *ISM_METADATA_HANDLE;


+165 −5
Original line number Diff line number Diff line
@@ -1086,14 +1086,20 @@ void ivas_param_ism_dec_digest_tc(
    float *transport_channels_f[] /* i  : synthesized core-coder transport channels/DirAC output  */
)
{
    int16_t ch, nchan_transport, nchan_out, nchan_out_woLFE, i;
    int16_t slot_idx, bin_idx;
    int16_t ch, nchan_transport;
    int16_t slot_idx;
#ifndef OBJ_EDITING_INTERFACE
    int16_t nchan_out, nchan_out_woLFE, i;
    int16_t bin_idx;
    int32_t ivas_total_brate;
#endif
    int16_t output_frame;
#ifndef OBJ_EDITING_INTERFACE
    float ref_power[CLDFB_NO_CHANNELS_MAX];
    float cx_diag[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX];
    /* Direct Response/EFAP Gains */
    float direct_response[MAX_NUM_OBJECTS][PARAM_ISM_MAX_CHAN];
#endif
    PARAM_ISM_DEC_HANDLE hParamIsmDec;
    SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom;
    int16_t fade_len;
@@ -1107,6 +1113,8 @@ void ivas_param_ism_dec_digest_tc(
    fade_len = output_frame / 2;

    nchan_transport = st_ivas->nchan_transport;

#ifndef OBJ_EDITING_INTERFACE
    ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;

    if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL )
@@ -1120,9 +1128,10 @@ void ivas_param_ism_dec_digest_tc(
        nchan_out = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe;
        nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE;
    }

#endif
    push_wmops( "ivas_param_ism_dec_digest_tc" );

#ifndef OBJ_EDITING_INTERFACE
    /* general setup */
    ivas_jbm_dec_get_adapted_linear_interpolator( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbSlots, hParamIsmDec->hParamIsmRendering->interpolator );

@@ -1197,7 +1206,7 @@ void ivas_param_ism_dec_digest_tc(
            }
        }
    }

#endif
    if ( st_ivas->hDecoderConfig->Opt_tsm )
    {
        /*TODO : FhG to check*/
@@ -1219,11 +1228,13 @@ void ivas_param_ism_dec_digest_tc(
                mvr2r( RealBuffer, &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands );
                mvr2r( ImagBuffer, &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands );
            }

#ifndef OBJ_EDITING_INTERFACE
            ivas_param_ism_collect_slot( hParamIsmDec, &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], ch, ref_power, cx_diag );
#endif
        }
    }

#ifndef OBJ_EDITING_INTERFACE
    /* Obtain Mixing Matrix on a frame-level */
    for ( bin_idx = 0; bin_idx < hSpatParamRendCom->num_freq_bands; bin_idx++ )
    {
@@ -1232,6 +1243,7 @@ void ivas_param_ism_dec_digest_tc(

    /* Compute mixing matrix */
    ivas_param_ism_compute_mixing_matrix( st_ivas->nchan_ism, hParamIsmDec, st_ivas->hISMDTX, direct_response, nchan_transport, nchan_out_woLFE, cx_diag, ref_power, hParamIsmDec->hParamIsmRendering->mixing_matrix_lin );
#endif

    pop_wmops();

@@ -1239,6 +1251,154 @@ void ivas_param_ism_dec_digest_tc(
}


#ifdef OBJ_EDITING_INTERFACE
/*-------------------------------------------------------------------------*
 * ivas_param_ism_dec_prepare_renderer()
 *
 *
 *-------------------------------------------------------------------------*/

void ivas_param_ism_dec_prepare_renderer(
    Decoder_Struct *st_ivas,   /* i/o: IVAS decoder handle                                     */
    const uint16_t nCldfbSlots /* i  : number of CLFBS slots in the transport channels         */
)
{
    int16_t ch, nchan_transport, nchan_out, nchan_out_woLFE, i;
    int16_t slot_idx, bin_idx;
    int32_t ivas_total_brate;
    int16_t output_frame;
    float ref_power[CLDFB_NO_CHANNELS_MAX];
    float cx_diag[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX];
    /* Direct Response/EFAP Gains */
    float direct_response[MAX_NUM_OBJECTS][PARAM_ISM_MAX_CHAN];
    PARAM_ISM_DEC_HANDLE hParamIsmDec;
    SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom;
    int16_t fade_len;

    /* Initialization */
    hParamIsmDec = st_ivas->hParamIsmDec;
    assert( hParamIsmDec );
    hSpatParamRendCom = st_ivas->hSpatParamRendCom;
    assert( hSpatParamRendCom );
    output_frame = nCldfbSlots * hSpatParamRendCom->num_freq_bands;
    fade_len = output_frame / 2;

    nchan_transport = st_ivas->nchan_transport;
    ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;

    if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL )
    {
        nchan_out = st_ivas->nchan_ism;
        nchan_out_woLFE = nchan_out;
        st_ivas->hDecoderConfig->nchan_out = nchan_out;
    }
    else
    {
        nchan_out = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe;
        nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE;
    }

    push_wmops( "ivas_param_ism_dec_digest_tc" );

    /* general setup */
    ivas_jbm_dec_get_adapted_linear_interpolator( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbSlots, hParamIsmDec->hParamIsmRendering->interpolator );

    ivas_dirac_dec_set_md_map( st_ivas, nCldfbSlots );

    /* set buffers to zero */
    for ( bin_idx = 0; bin_idx < CLDFB_NO_CHANNELS_MAX; bin_idx++ )
    {
        set_zero( cx_diag[bin_idx], PARAM_ISM_MAX_DMX );
    }
    set_zero( ref_power, CLDFB_NO_CHANNELS_MAX );

    /* Frame-level Processing */
    /* De-quantization */
    if ( !( ivas_total_brate == IVAS_SID_5k2 || ivas_total_brate == FRAME_NO_DATA ) )
    {
        ivas_param_ism_dec_dequant_DOA( hParamIsmDec, st_ivas->nchan_ism );
        ivas_param_ism_dec_dequant_powrat( hParamIsmDec );
        st_ivas->hISMDTX.dtx_flag = 0;
    }
    else
    {
        st_ivas->hISMDTX.dtx_flag = 1;
    }

    /* obtain the direct response using EFAP */
    if ( !( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) )
    {
        for ( i = 0; i < st_ivas->nchan_ism; i++ )
        {
            efap_determine_gains( st_ivas->hEFAPdata, direct_response[i], hParamIsmDec->azimuth_values[i], hParamIsmDec->elevation_values[i], EFAP_MODE_EFAP );
        }
    }
    else
    {
        int16_t j;

        for ( i = 0; i < st_ivas->nchan_ism; i++ )
        {
            for ( j = 0; j < nchan_out_woLFE; j++ )
            {
                if ( i == j )
                {
                    direct_response[i][j] = 1.0f;
                }
                else
                {
                    direct_response[i][j] = 0.0f;
                }
            }
        }

        for ( j = 0; j < nchan_out_woLFE; j++ )
        {
            if ( hParamIsmDec->azimuth_values[j] > 0.0f )
            {
                hParamIsmDec->hParamIsmRendering->proto_matrix[j] = 1.0f;
                hParamIsmDec->hParamIsmRendering->proto_matrix[nchan_out_woLFE + j] = 0.0f;
            }
            else
            {
                if ( hParamIsmDec->azimuth_values[j] < 0.0f )
                {
                    hParamIsmDec->hParamIsmRendering->proto_matrix[j] = 0.0f;
                    hParamIsmDec->hParamIsmRendering->proto_matrix[nchan_out_woLFE + j] = 1.0f;
                }
                else /* == 0.0f */
                {
                    hParamIsmDec->hParamIsmRendering->proto_matrix[j] = 0.5f;
                    hParamIsmDec->hParamIsmRendering->proto_matrix[nchan_out_woLFE + j] = 0.5f;
                }
            }
        }
    }

    for ( ch = 0; ch < nchan_transport; ch++ )
    {
        /* CLDFB Analysis */
        for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ )
        {
            ivas_param_ism_collect_slot( hParamIsmDec, &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], ch, ref_power, cx_diag );
        }
    }

    /* Obtain Mixing Matrix on a frame-level */
    for ( bin_idx = 0; bin_idx < hSpatParamRendCom->num_freq_bands; bin_idx++ )
    {
        set_f( hParamIsmDec->hParamIsmRendering->mixing_matrix_lin[bin_idx], 0.0f, nchan_transport * nchan_out_woLFE );
    }

    /* Compute mixing matrix */
    ivas_param_ism_compute_mixing_matrix( st_ivas->nchan_ism, hParamIsmDec, st_ivas->hISMDTX, direct_response, nchan_transport, nchan_out_woLFE, cx_diag, ref_power, hParamIsmDec->hParamIsmRendering->mixing_matrix_lin );

    pop_wmops();

    return;
}
#endif

/*-------------------------------------------------------------------------*
 * ivas_ism_param_dec_tc_gain_ajust()
 *
Loading