LCOV - code coverage report
Current view: top level - lib_lc3plus - residual_coding.c (source / functions) Hit Total Coverage
Test: Coverage on main -- conformance test test_26252.py @ a21f94bc6bac334fe001a5bad2f7b32b79038097 Lines: 33 37 89.2 %
Date: 2025-11-01 05:07:43 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      586911 : void processResidualCoding_fl(LC3_FLOAT x[], LC3_INT xq[], LC3_FLOAT gain, LC3_INT L_spec, LC3_INT targetBits, LC3_INT nBits, uint8_t* resBits, LC3_INT* numResBits, LC3_INT hrmode
      15             : #ifdef ENABLE_12p5_DMS_MODE
      16             :                 , LC3PLUS_FrameDuration frame_dms
      17             : #endif
      18             : )
      19             : {
      20      586911 :     LC3_INT n = 0, m = 0, k = 0;
      21      586911 :     LC3_INT iter=0;
      22             :     LC3_FLOAT offset[3];
      23      586911 :     LC3_INT iter_max = 1;
      24             :     LC3_INT nz_idx[MAX_LEN];
      25      586911 :     LC3_INT N_nz = 0, idx = 0;
      26             : 
      27             : 
      28      586911 :     memset(resBits, 0, MAX_RESBITS_LEN);
      29             : 
      30      586911 :     m = targetBits - nBits + 4;
      31      586911 :     if (hrmode)
      32             :     {
      33           0 :         m += 10;
      34             :     }
      35             : 
      36      586911 :     assert(m <= MAX_RESBITS);
      37             : 
      38      586911 :     offset[2] = .5;
      39      586911 :     if (hrmode)
      40             :     {
      41           0 :         iter_max = EXT_RES_ITER_MAX;
      42             :     }
      43             : #ifdef ENABLE_12p5_DMS_MODE
      44      586911 :     else if (frame_dms == LC3PLUS_FRAME_DURATION_1p25MS) 
      45             :     {
      46           0 :         iter_max = 3;
      47           0 :         offset[2] = .375;
      48             :     }
      49             : #endif
      50             : 
      51             :     /* init offset */
      52      586911 :     offset[0] = offset[2] / 2.;
      53      586911 :     offset[1] = (1.-offset[2]) / 2.;
      54             : 
      55   124363911 :     for (k = 0; k < L_spec; k ++)
      56             :     {
      57   123777000 :         if (xq[k])
      58             :         {
      59   102719498 :             nz_idx[N_nz ++] = k;
      60             :         }
      61             :     }
      62     1173822 :     while (iter < iter_max && n < m)
      63             :     {
      64      586911 :         k = 0;
      65    12071581 :         while (k < N_nz && n < m)
      66             :         {
      67    11484670 :             idx = nz_idx[k];
      68             :             
      69    11484670 :             if (x[idx] >= (LC3_FLOAT)xq[idx] * gain)
      70             :             {
      71     5742764 :                 resBits[n >> 3] |= 1 << (n & 7);
      72     5742764 :                 x[idx] -= gain * offset[x[idx] > 0];
      73             :             }
      74             :             else
      75             :             {
      76     5741906 :                 resBits[n >> 3] &= ~(1 << (n & 7));
      77     5741906 :                 x[idx] += gain * offset[x[idx] < 0];
      78             :             }
      79             :             
      80    11484670 :             n++;
      81             :             
      82    11484670 :             k++;
      83             :         }
      84      586911 :         iter ++;
      85      586911 :         offset[0] *= .5;
      86      586911 :         offset[1] *= .5;
      87             :     }
      88             : 
      89      586911 :     *numResBits = n;
      90      586911 : }

Generated by: LCOV version 1.14