Commit 6c3779fe authored by bayers's avatar bayers
Browse files

added changes to check for excessive limiter usage

parent 843dbdf7
Loading
Loading
Loading
Loading
+17 −3
Original line number Diff line number Diff line
@@ -201,9 +201,15 @@ int main(
#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
    IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics = NULL;
#endif
#ifdef LIMITER_CHECK
    int32_t cnt_frames_limited;
    float   ratio_frames_limited;
    float   avg_limiter_gain;
    float   avg_limiter_gain_in_limited_frames;
    float   max_limiter_gain;
#endif
#ifdef DEBUGGING
    int32_t noClipping;
    int32_t cnt_frames_limited;
#ifdef DEBUG_SBA_AUDIO_DUMP
    int16_t numOutChannels, numTransportChannels, pca_ingest_channels;
#endif
@@ -870,11 +876,19 @@ int main(
        goto cleanup;
    }

#ifdef DEBUGGING
#ifdef LIMITER_CHECK
    if ( ( cnt_frames_limited = IVAS_DEC_GetCntFramesLimited( hIvasDec ) ) > 0 )
    {
        fprintf( stdout, "Limiter applied in %d frames.\n\n", cnt_frames_limited );
        fprintf( stdout, "Total frames with Limiter application: %d\n\n", cnt_frames_limited );
        ratio_frames_limited = IVAS_DEC_GetRatioFramesLimited( hIvasDec );
        fprintf( stdout, "Ratio of frames with limiting: %0.2f\n\n", ratio_frames_limited);
        IVAS_DEC_GetLimiterGainInfo( hIvasDec, &avg_limiter_gain, &max_limiter_gain, &avg_limiter_gain_in_limited_frames  );
        fprintf( stdout, "Average Limiter Gain (dB): %0.2f\n", avg_limiter_gain);
        fprintf( stdout, "Average Limiter Gain (limited frames only) (dB): %0.2f\n", avg_limiter_gain_in_limited_frames);
        fprintf( stdout, "Max Limiter Gain (dB): %0.2f\n", max_limiter_gain);
    }
#endif
#ifdef DEBUGGING
    if ( ( noClipping = IVAS_DEC_GetNoCLipping( hIvasDec ) ) > 0 )
    {
        fprintf( stdout, "Clipping (saturation) detected: %d samples clipped!!!\n\n", noClipping );
+1 −0
Original line number Diff line number Diff line
@@ -150,6 +150,7 @@

/*#define FIX_I4_OL_PITCH*/                             /* fix open-loop pitch used for EVS core switching */
/*#define SPLIT_REND_WITH_HEAD_ROT  */                  /* Dlb,FhG: Split Rendering contributions 21 and 35 */
#define LIMITER_CHECK

#define FIX_963_USAN_ERROR                              /* Eri: Issue 963: USAN error in Stereo CNG, division by zero */
#define FIX_971_LOG2_IDX_GAIN_0                         /* VA: prevent -Inf due to log2(ratio==0) */
+68 −18
Original line number Diff line number Diff line
@@ -3308,61 +3308,111 @@ static ivas_error evs_dec_main(
    return IVAS_ERR_OK;
}

#ifdef LIMITER_CHECK

#ifdef DEBUGGING
/*---------------------------------------------------------------------*
 * IVAS_DEC_GetBer_detect_flag()
 * IVAS_DEC_GetCntFramesLimited()
 *
 * return BER_detect flag
 * return number of frames where limiter is applied
 *---------------------------------------------------------------------*/

bool IVAS_DEC_GetBerDetectFlag(
int32_t IVAS_DEC_GetCntFramesLimited(
    IVAS_DEC_HANDLE hIvasDec /* i  : IVAS decoder handle   */
)
{
    if ( hIvasDec->st_ivas->BER_detect == 1 )
    if ( hIvasDec->st_ivas->hLimiter == NULL )
    {
        return 1;
        return 0;
    }
    else
    {
        return 0;
        return hIvasDec->st_ivas->hLimiter->cnt_frames_limited;
    }
}


/*---------------------------------------------------------------------*
 * IVAS_DEC_GetNoCLipping()
 * IVAS_DEC_GetRatioFramesLimited()
 *
 * return number of clipped samples
 * return number of frames where limiter is applied
 *---------------------------------------------------------------------*/

int32_t IVAS_DEC_GetNoCLipping(
float IVAS_DEC_GetRatioFramesLimited(
    IVAS_DEC_HANDLE hIvasDec /* i  : IVAS decoder handle   */
)
{
    return hIvasDec->st_ivas->noClipping;
    if ( hIvasDec->st_ivas->hLimiter == NULL )
    {
        return 0;
    }
    else
    {
        return hIvasDec->st_ivas->hLimiter->frames_limited_avg;
    }
}


/*---------------------------------------------------------------------*
 * IVAS_DEC_GetCntFramesLimited()
 * IVAS_DEC_GetRatioFramesLimited()
 *
 * return number of frames where limiter is applied
 *---------------------------------------------------------------------*/

int32_t IVAS_DEC_GetCntFramesLimited(
    IVAS_DEC_HANDLE hIvasDec /* i  : IVAS decoder handle   */
void IVAS_DEC_GetLimiterGainInfo(
    IVAS_DEC_HANDLE hIvasDec, /* i  : IVAS decoder handle   */
    float   *gain_avg,
    float   *gain_max,
    float   *gain_avg_in_limited_frames
)
{
    if ( hIvasDec->st_ivas->hLimiter == NULL )
    {
        return 0;
        *gain_avg = 0.0f;
        *gain_max = 0.0f;
        *gain_avg_in_limited_frames = 0.0f;
    }
    else
    {
        return hIvasDec->st_ivas->hLimiter->cnt_frames_limited;
        *gain_avg = hIvasDec->st_ivas->hLimiter->gain_avg;
        *gain_max = 20*log10f(1.0f/(hIvasDec->st_ivas->hLimiter->gain_max + EPSILON));
        *gain_avg_in_limited_frames = hIvasDec->st_ivas->hLimiter->gain_avg_in_limited_frames;
    }
    return;
}
#endif


#ifdef DEBUGGING
/*---------------------------------------------------------------------*
 * IVAS_DEC_GetBer_detect_flag()
 *
 * return BER_detect flag
 *---------------------------------------------------------------------*/

bool IVAS_DEC_GetBerDetectFlag(
    IVAS_DEC_HANDLE hIvasDec /* i  : IVAS decoder handle   */
)
{
    if ( hIvasDec->st_ivas->BER_detect == 1 )
    {
        return 1;
    }
    else
    {
        return 0;
    }
}


/*---------------------------------------------------------------------*
 * IVAS_DEC_GetNoCLipping()
 *
 * return number of clipped samples
 *---------------------------------------------------------------------*/

int32_t IVAS_DEC_GetNoCLipping(
    IVAS_DEC_HANDLE hIvasDec /* i  : IVAS decoder handle   */
)
{
    return hIvasDec->st_ivas->noClipping;
}


+17 −4
Original line number Diff line number Diff line
@@ -342,16 +342,29 @@ ivas_error IVAS_DEC_GetRenderFramesizeMs(
    uint32_t *render_framesize /* o  : render framesize in samples  */
);

#ifdef DEBUGGING
bool IVAS_DEC_GetBerDetectFlag(
#ifdef LIMITER_CHECK
int32_t IVAS_DEC_GetCntFramesLimited(
    IVAS_DEC_HANDLE hIvasDec                    /* i  : IVAS decoder handle                                                     */
);

int32_t IVAS_DEC_GetNoCLipping(
float IVAS_DEC_GetRatioFramesLimited(
    IVAS_DEC_HANDLE hIvasDec /* i  : IVAS decoder handle   */
);

int32_t IVAS_DEC_GetCntFramesLimited(
void IVAS_DEC_GetLimiterGainInfo(
    IVAS_DEC_HANDLE hIvasDec, /* i  : IVAS decoder handle   */
    float   *gain_avg,
    float   *gain_max,
    float   *gain_avg_in_limited_frames
);
#endif

#ifdef DEBUGGING
bool IVAS_DEC_GetBerDetectFlag(
    IVAS_DEC_HANDLE hIvasDec                    /* i  : IVAS decoder handle                                                     */
);

int32_t IVAS_DEC_GetNoCLipping(
    IVAS_DEC_HANDLE hIvasDec                    /* i  : IVAS decoder handle                                                     */
);

+20 −2
Original line number Diff line number Diff line
@@ -132,8 +132,13 @@ ivas_error ivas_limiter_open(
    hLimiter->release_heuristic = 0.f;
    hLimiter->attack_constant = powf( 0.01f, 1.0f / ( IVAS_LIMITER_ATTACK_SECONDS * sampling_rate ) );
    hLimiter->strong_saturation_count = 0;
#ifdef DEBUGGING
#ifdef LIMITER_CHECK
    hLimiter->cnt_frames_limited = 0;
    hLimiter->cnt_frames = 0;
    hLimiter->gain_avg = 0.0f;
    hLimiter->frames_limited_avg = 0.0f;
    hLimiter->gain_avg_in_limited_frames = 0.0f;
    hLimiter->gain_max=1.0f;
#endif

    for ( i = 0; i < max_num_channels; ++i )
@@ -294,7 +299,7 @@ void limiter_process(
         *                                                            ^
         *                                                          React faster when release time should be increased
         */
#ifdef DEBUGGING
#ifdef LIMITER_CHECK
        if ( max_val > threshold )
        {
            hLimiter->cnt_frames_limited++;
@@ -379,6 +384,19 @@ void limiter_process(
    /* Save last gain and release heuristic values for next frame */
    hLimiter->gain = gain;
    hLimiter->release_heuristic = releaseHeuristic;
#ifdef LIMITER_CHECK
    hLimiter->cnt_frames++;
    hLimiter->frames_limited_avg = (float)hLimiter->cnt_frames_limited/(float)hLimiter->cnt_frames;
    hLimiter->gain_avg = hLimiter->gain_avg + (20*log10f(1.0f/(hLimiter->gain + EPSILON))-hLimiter->gain_avg)/(float)hLimiter->cnt_frames;
    if ( max_val > threshold )
    {
        hLimiter->gain_avg_in_limited_frames = hLimiter->gain_avg_in_limited_frames + (20*log10f(1.0f/(hLimiter->gain + EPSILON))-hLimiter->gain_avg_in_limited_frames)/(float)hLimiter->cnt_frames_limited;
    }
    if ( hLimiter->gain_max > hLimiter->gain )
    {
    	hLimiter->gain_max = hLimiter->gain;
    }
#endif

    return;
}
Loading