LCOV - code coverage report
Current view: top level - lib_lc3plus - near_nyquist_detector.c (source / functions) Hit Total Coverage
Test: Coverage on main -- short test vectors @ 867217ee32c8e8cd2cf5aae69e60c58e00160b49 Lines: 12 42 28.6 %
Date: 2025-12-13 06:47:12 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             : *                        ETSI TS 103 634 V1.6.1                               *
       3             : *              Low Complexity Communication Codec Plus (LC3plus)              *
       4             : *                                                                             *
       5             : * Copyright licence is solely granted through ETSI Intellectual Property      *
       6             : * Rights Policy, 3rd April 2019. No patent licence is granted by implication, *
       7             : * estoppel or otherwise.                                                      *
       8             : ******************************************************************************/
       9             : 
      10             : #include "options.h"
      11             : #include "wmc_auto.h"
      12             : #include "functions.h"
      13             : 
      14     1189311 : void processNearNyquistdetector_fl(LC3_INT16* near_nyquist_flag, const LC3_INT fs_idx, const LC3_INT near_nyquist_index,
      15             :                                    const LC3_INT bands_number, const LC3_FLOAT* ener                   
      16             :                                    , const LC3PLUS_FrameDuration frame_dms, const LC3_INT16 hrmode)                                 
      17             : {
      18     1189311 :     *near_nyquist_flag = 0;
      19     1189311 :     if (hrmode == 0){
      20     1189311 :         if (fs_idx < 4)
      21             :         { 
      22           8 :             LC3_INT   i = 0;
      23           8 :             LC3_FLOAT ener_low = FLT_EPSILON, ener_high = 0;
      24             : 
      25         504 :             for (i=0; i<near_nyquist_index; i++)
      26             :             {
      27         496 :                 ener_low += ener[i];
      28             :             }
      29             : 
      30          24 :             for (i=near_nyquist_index; i<bands_number; i++)
      31             :             {
      32          16 :                 ener_high += ener[i];
      33             :             }
      34             : 
      35           8 :             if (ener_high > NN_thresh * ener_low){
      36           0 :                 *near_nyquist_flag = 1;
      37             :             }
      38             :         }
      39             :     } 
      40             :     else /* hrmode == 1 */
      41             :     {
      42             :         /* inverse spectral flatness = mean(energy) ./ 2^(mean(log2(energy))); */
      43           0 :         LC3_INT32 td_thresh, i = 0;
      44           0 :         LC3_FLOAT mean_ener = 0, mean_ener_log2 = 0, inv_flatness = 0;
      45             : 
      46           0 :         switch (frame_dms)
      47             :         {
      48             : #ifdef CR9_C_ADD_1p25MS
      49           0 :         case LC3PLUS_FRAME_DURATION_1p25MS:
      50           0 :             assert(0);
      51             :             break;
      52             : #endif
      53           0 :         case LC3PLUS_FRAME_DURATION_2p5MS:
      54           0 :             td_thresh = TD_HR_thresh_2_5ms;
      55           0 :             break;
      56           0 :         case LC3PLUS_FRAME_DURATION_5MS:
      57           0 :             td_thresh = TD_HR_thresh_5ms;
      58           0 :             break;
      59           0 :         case LC3PLUS_FRAME_DURATION_7p5MS:
      60           0 :             td_thresh = TD_HR_thresh_7_5ms;
      61           0 :             break;
      62           0 :         case LC3PLUS_FRAME_DURATION_10MS:
      63           0 :             td_thresh = TD_HR_thresh_10ms;
      64           0 :             break;
      65           0 :         case LC3PLUS_FRAME_DURATION_UNDEFINED:
      66           0 :             assert(0);
      67             :         }
      68             : 
      69             :         /* calculate arithmetic mean */
      70           0 :         for (i = 0; i < bands_number; i++)
      71             :         {
      72           0 :             mean_ener += ener[i];
      73             :         }
      74           0 :         mean_ener = mean_ener / bands_number;
      75             : 
      76             :         /* calculate geometric mean */
      77           0 :         for (i = 0; i < bands_number; i++)
      78             :         {    
      79           0 :             if (ener[i] != 0) {
      80           0 :                 mean_ener_log2 += LC3_LOGTWO(ener[i]);
      81             :             }
      82             :         }
      83           0 :         mean_ener_log2 = mean_ener_log2 / bands_number;
      84             : 
      85           0 :         inv_flatness = mean_ener / LC3_POW(2,mean_ener_log2);
      86             : 
      87           0 :         if (inv_flatness > td_thresh) {
      88           0 :             *near_nyquist_flag = 1;
      89             :         } 
      90             :     }
      91     1189311 : }

Generated by: LCOV version 1.14