LCOV - code coverage report
Current view: top level - lib_lc3plus - resamp12k8.c (source / functions) Hit Total Coverage
Test: Coverage on main -- conformance test test_26252.py @ 0c5691e6405a865cd50088c4936e8acb16f658a1 Lines: 48 59 81.4 %
Date: 2025-12-18 05:24:35 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      590506 : void process_resamp12k8_fl(LC3_FLOAT x[], LC3_INT x_len, LC3_FLOAT mem_in[], LC3_INT mem_in_len, LC3_FLOAT mem_50[], LC3_FLOAT mem_out[],
      15             :                            LC3_INT mem_out_len, LC3_FLOAT y[], LC3_INT* y_len, LC3_INT fs_idx, LC3PLUS_FrameDuration frame_dms, LC3_INT fs)
      16             : {
      17             :     
      18             : 
      19      590506 :     LC3_INT   len_12k8 = 0, N12k8, i, k;
      20             :     LC3_FLOAT mac, bufdown[128], buf[120 + MAX_LEN];
      21             :     LC3_INT32 index_int, index_frac, resamp_upfac, resamp_delay, resamp_off_int, resamp_off_frac;
      22             :     LC3_FLOAT u_11, u_21, u_1, u_2;
      23             :     const LC3_FLOAT *filter;
      24             :     const LC3_FLOAT *filt_input, *filt_coeff;
      25             : 
      26      590506 :     switch (frame_dms)
      27             :     {
      28             : #ifdef CR9_C_ADD_1p25MS
      29           0 :         case LC3PLUS_FRAME_DURATION_1p25MS:
      30           0 :             len_12k8 = LEN_12K8 / 8;
      31           0 :             break;
      32             : #endif
      33           0 :         case LC3PLUS_FRAME_DURATION_2p5MS:
      34           0 :             len_12k8 = LEN_12K8 / 4;
      35           0 :             break;
      36      558314 :         case LC3PLUS_FRAME_DURATION_5MS:
      37      558314 :             len_12k8 = LEN_12K8 / 2;
      38      558314 :             break;
      39           0 :         case LC3PLUS_FRAME_DURATION_7p5MS:
      40           0 :             len_12k8 = (LEN_12K8 / 4) * 3;
      41           0 :             break;
      42       32192 :         case LC3PLUS_FRAME_DURATION_10MS:
      43       32192 :             len_12k8 = LEN_12K8;
      44       32192 :             break;
      45           0 :         case LC3PLUS_FRAME_DURATION_UNDEFINED:
      46           0 :             assert(0);
      47             :     }
      48             : 
      49      590506 :     *y_len = len_12k8;
      50      590506 :     N12k8  = x_len * 12800 / fs;
      51             : 
      52             :     /* Init Input Buffer */
      53      590506 :     memmove(buf, mem_in, mem_in_len * sizeof(LC3_FLOAT));
      54      590506 :     memmove(&buf[mem_in_len], x, x_len * sizeof(LC3_FLOAT));
      55      590506 :     memmove(mem_in, &buf[x_len], mem_in_len * sizeof(LC3_FLOAT));
      56             : 
      57      590506 :     filter = lp_filter[fs_idx];
      58             : 
      59             :     /* Upsampling & Low-pass Filtering & Downsampling */
      60             : 
      61      590506 :     index_int  = 1;
      62      590506 :     index_frac = 0;
      63      590506 :     resamp_upfac    = resamp_params[fs_idx][0];
      64      590506 :     resamp_delay    = resamp_params[fs_idx][1];
      65      590506 :     resamp_off_int  = resamp_params[fs_idx][2];
      66      590506 :     resamp_off_frac = resamp_params[fs_idx][3];
      67             : 
      68      590506 :     k = 0;
      69    40443178 :     for (i = 0; i < N12k8; i++) {
      70             : 
      71    39852672 :         filt_input = &buf[index_int];
      72    39852672 :         filt_coeff = &filter[index_frac * resamp_delay * 2];
      73             : 
      74    39852672 :         mac = mac_loop(filt_input, filt_coeff, (2 * resamp_delay));
      75             :         
      76    39852672 :         bufdown[k++] = mac;
      77             :         
      78    39852672 :         index_int  = index_int + resamp_off_int;
      79    39852672 :         index_frac = index_frac + resamp_off_frac;
      80             :         
      81    39852672 :         if ((resamp_upfac - index_frac) <= 0)
      82             :         {
      83    29889504 :             index_int  = index_int + 1;
      84    29889504 :             index_frac = index_frac - resamp_upfac;
      85             :         }
      86             :     }
      87             : 
      88             : 
      89             :     /* 50Hz High-Pass */
      90      590506 :     u_11 = mem_50[0];
      91      590506 :     u_21 = mem_50[1];
      92             : 
      93    40443178 :     for (i = 0; i < len_12k8; i++) {
      94    39852672 :         LC3_FLOAT y1  = (highpass50_filt_b[0] * bufdown[i] + u_11);
      95    39852672 :         u_1        = (highpass50_filt_b[1] * bufdown[i] + u_21) - highpass50_filt_a[1] * y1;
      96    39852672 :         u_2        = highpass50_filt_b[2] * bufdown[i] - highpass50_filt_a[2] * y1;
      97    39852672 :         u_11       = u_1;
      98    39852672 :         u_21       = u_2;
      99    39852672 :         bufdown[i] = (LC3_FLOAT)y1;
     100             :     }
     101             : 
     102      590506 :     mem_50[0] = (LC3_FLOAT)u_11;
     103      590506 :     mem_50[1] = (LC3_FLOAT)u_21;
     104             : 
     105             :     /* Output Buffer */
     106      590506 :     memmove(buf, mem_out, mem_out_len * sizeof(LC3_FLOAT));
     107             : 
     108      590506 :     memmove(&buf[mem_out_len], bufdown, len_12k8 * sizeof(LC3_FLOAT));
     109             : 
     110      590506 :     memmove(y, buf, (*y_len + 1) * sizeof(LC3_FLOAT));
     111             : 
     112      590506 :     memmove(mem_out, &buf[N12k8], mem_out_len * sizeof(LC3_FLOAT));
     113      590506 : }

Generated by: LCOV version 1.14