Commit ad02a6b1 authored by Jan Kiene's avatar Jan Kiene
Browse files

Merge branch 'fix_todos_in_fd_cng_enc' into 'main'

[non-BE] Issue 451 - address todo comments in fd_cng_enc

See merge request !695
parents 8f6adfe1 9bffef3c
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -160,6 +160,7 @@
#define FIX_TODO_NON_DIEGETIC_PAN_NOT_IMPLELENTED_IN_RENDERER /* ..\apps\renderer.c(240):  .... (todo: implementation)",*/
#define REMOVE_OBS_CODE                                 /* FhG: Remove unnecessary assignement after LFE cleanup (Issue #451)*/

#define FIX_TODO_FD_CNG_SBA_CLEANUP                     /* FhG: BE, address TODO comment in fd_cng_enc */
#define ENHANCED_STEREO_DMX                             /* Orange : Contribution 48 - Enhanced stereo downmix. */

#define BINAURAL_AUDIO_CMDLINE
+34 −6
Original line number Diff line number Diff line
@@ -1034,7 +1034,9 @@ void FdCngEncodeMDCTStereoSID(
        ms_ptr[ch] = &logNoiseEst[ch][0];
        lr_out_ptr[ch] = &sts[ch]->hFdCngEnc->hFdCngCom->sidNoiseEst[0];
    }
#ifdef DEBUGGING
    assert( sts[0]->hFdCngEnc->npartDec == sts[1]->hFdCngEnc->npartDec );
#endif
    N = sts[0]->hFdCngEnc->npartDec;
    set_f( weights, 1.f, NPART );

@@ -1275,12 +1277,21 @@ void FdCngEncodeDiracMDCTStereoSID(
        lr_out_ptr[ch] = &sts[ch]->hFdCngEnc->hFdCngCom->sidNoiseEst[0];
    }
    set_f( weights, 1.f, NPART );
#ifdef FIX_TODO_FD_CNG_SBA_CLEANUP
#ifdef DEBUGGING
    assert( N[0] == N[1] );
#endif
#endif

    /* apply log and save energy of original left and right channels */
    for ( ch = 0; ch < CPE_CHANNELS; ch++ )
    {
        E[ch] = 0.0f;
        for ( p = 0; p < NPART; p++ ) /* TODO Note:   NPART should likely be N[ch] if N[ch] may change */
#ifdef FIX_TODO_FD_CNG_SBA_CLEANUP
        for ( p = 0; p < N[ch]; p++ )
#else
        for ( p = 0; p < NPART; p++ )
#endif
        {
            ms_ptr[ch][p] = 10.f * log10f( lr_in_ptr[ch][p] + EPSILON );
            E[ch] += ms_ptr[ch][p];
@@ -1288,10 +1299,15 @@ void FdCngEncodeDiracMDCTStereoSID(
    }

    /* M/S transform on log envelopes */
    convertToMS( NPART, ms_ptr[0], ms_ptr[1], 0.5f ); /* TODO Note:   NPART should likely be N[0] if N[0] may change */
#ifdef FIX_TODO_FD_CNG_SBA_CLEANUP
    convertToMS( N[0], ms_ptr[0], ms_ptr[1], 0.5f );

    E[0] = sum_f( ms_ptr[0], NPART ); /* TODO Note:   NPART should likely be N[0] if N[0] may change */
    E[0] = sum_f( ms_ptr[0], N[0] );
#else
    convertToMS( NPART, ms_ptr[0], ms_ptr[1], 0.5f );

    E[0] = sum_f( ms_ptr[0], NPART );
#endif

    /* Quantize M noise shape */
    /* Normalize MSVQ input */
@@ -1326,7 +1342,11 @@ void FdCngEncodeDiracMDCTStereoSID(
    set_zero( ms_ptr[1], NPART );

    /* compute M gain */
    gain[0] = sum_f( ms_ptr[0], NPART ); /* TODO Note:   NPART should likely be N[0] if N[0] may change */
#ifdef FIX_TODO_FD_CNG_SBA_CLEANUP
    gain[0] = sum_f( ms_ptr[0], N[0] );
#else
    gain[0] = sum_f( ms_ptr[0], NPART );
#endif
    gain[0] = ( E[0] - gain[0] ) / (float) N[0];
    apply_scale( &gain[0], sts[0]->hFdCngEnc->hFdCngCom->CngBandwidth, sts[0]->hDtxEnc->last_active_brate, scaleTableStereo, SIZE_SCALE_TABLE_STEREO );

@@ -1338,7 +1358,11 @@ void FdCngEncodeDiracMDCTStereoSID(
    gain[1] = gain[0];

    /* undo M/S */
    convertToMS( NPART, ms_ptr[0], ms_ptr[1], 1.0f ); /* TODO Note:   NPART should likely be N[0] if N[0] may change */
#ifdef FIX_TODO_FD_CNG_SBA_CLEANUP
    convertToMS( NPART, ms_ptr[0], ms_ptr[1], 1.0f );
#else
    convertToMS( N[0], ms_ptr[0], ms_ptr[1], 1.0f );
#endif

    /* restore channel noise envelopes */
    for ( ch = 0; ch < CPE_CHANNELS; ch++ )
@@ -1346,7 +1370,11 @@ void FdCngEncodeDiracMDCTStereoSID(
        HANDLE_FD_CNG_ENC hFdCngEnc = sts[ch]->hFdCngEnc;
        HANDLE_FD_CNG_COM hFdCngCom = hFdCngEnc->hFdCngCom;

        for ( p = 0; p < NPART; p++ ) /* TODO Note:   NPART should likely be N[0] if N[0] may change */
#ifdef FIX_TODO_FD_CNG_SBA_CLEANUP
        for ( p = 0; p < N[0]; p++ )
#else
        for ( p = 0; p < NPART; p++ )
#endif
        {
            lr_out_ptr[ch][p] = powf( 10.f, ( ms_ptr[ch][p] + gain[ch] ) / 10.f );
        }