Commit 03b8d839 authored by Jan Kiene's avatar Jan Kiene
Browse files

address todo comments in fd_cng_enc

parent 08305d0c
Loading
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -228,6 +228,8 @@
#define FIX_510                                         /* FhG: fix issue 510, misleading error message for invalid input format */
#define FIX_509                                         /* FhG: fix issue 509, too low number of bitsream indices in SBA */

#define FIX_TODO_FD_CNG_SBA_CLEANUP

/* ################## End DEVELOPMENT switches ######################### */
/* clang-format on */

+30 −6
Original line number Diff line number Diff line
@@ -1275,12 +1275,19 @@ 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
    assert ( N[0] == N[1] );
#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++ ) /* TBD 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 +1295,15 @@ void FdCngEncodeDiracMDCTStereoSID(
    }

    /* M/S transform on log envelopes */
    convertToMS( NPART, ms_ptr[0], ms_ptr[1], 0.5f ); /* TBD 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 ); /* TBD 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 +1338,11 @@ void FdCngEncodeDiracMDCTStereoSID(
    set_zero( ms_ptr[1], NPART );

    /* compute M gain */
    gain[0] = sum_f( ms_ptr[0], NPART ); /* TBD 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 +1354,11 @@ void FdCngEncodeDiracMDCTStereoSID(
    gain[1] = gain[0];

    /* undo M/S */
    convertToMS( NPART, ms_ptr[0], ms_ptr[1], 1.0f ); /* TBD 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 +1366,11 @@ void FdCngEncodeDiracMDCTStereoSID(
        HANDLE_FD_CNG_ENC hFdCngEnc = sts[ch]->hFdCngEnc;
        HANDLE_FD_CNG_COM hFdCngCom = hFdCngEnc->hFdCngCom;

        for ( p = 0; p < NPART; p++ ) /* TBD 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 );
        }