LCOV - code coverage report
Current view: top level - lib_com - lsf_msvq_ma.c (source / functions) Hit Total Coverage
Test: Coverage on main -- short test vectors @ 6c9ddc4024a9c0e1ecb8f643f114a84a0e26ec6b Lines: 30 40 75.0 %
Date: 2025-05-23 08:37:30 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /******************************************************************************************************
       2             : 
       3             :    (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
       4             :    Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
       5             :    Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
       6             :    Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
       7             :    contributors to this repository. All Rights Reserved.
       8             : 
       9             :    This software is protected by copyright law and by international treaties.
      10             :    The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
      11             :    Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
      12             :    Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
      13             :    Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
      14             :    contributors to this repository retain full ownership rights in their respective contributions in
      15             :    the software. This notice grants no license of any kind, including but not limited to patent
      16             :    license, nor is any license granted by implication, estoppel or otherwise.
      17             : 
      18             :    Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
      19             :    contributions.
      20             : 
      21             :    This software is provided "AS IS", without any express or implied warranties. The software is in the
      22             :    development stage. It is intended exclusively for experts who have experience with such software and
      23             :    solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
      24             :    and fitness for a particular purpose are hereby disclaimed and excluded.
      25             : 
      26             :    Any dispute, controversy or claim arising under or in relation to providing this software shall be
      27             :    submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
      28             :    accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
      29             :    the United Nations Convention on Contracts on the International Sales of Goods.
      30             : 
      31             : *******************************************************************************************************/
      32             : 
      33             : /*====================================================================================
      34             :     EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
      35             :   ====================================================================================*/
      36             : 
      37             : #include <assert.h>
      38             : #include <stdint.h>
      39             : #include "options.h"
      40             : #ifdef DEBUGGING
      41             : #include "debug.h"
      42             : #endif
      43             : #include "cnst.h"
      44             : #include "prot.h"
      45             : #include "rom_com.h"
      46             : #include "stl.h"
      47             : #include "basop_proto_func.h"
      48             : #include "wmc_auto.h"
      49             : 
      50             : /*---------------------------------------------------------------------*
      51             :  * midlsf_dec()
      52             :  *
      53             :  *
      54             :  *---------------------------------------------------------------------*/
      55             : 
      56        1707 : void midlsf_dec(
      57             :     const float qlsf0[],
      58             :     const float qlsf1[],
      59             :     const int16_t idx,
      60             :     float qlsf[],
      61             :     const int16_t N,
      62             :     const int16_t coder_type,
      63             :     int16_t *mid_lsf_int,
      64             :     const int16_t prev_bfi,
      65             :     const int16_t safety_net )
      66             : {
      67        1707 :     const float *ratio = NULL;
      68             :     int16_t j;
      69        1707 :     int16_t bad_spacing = 0;
      70             :     /* Select codebook */
      71        1707 :     if ( coder_type == UNVOICED )
      72             :     {
      73         104 :         ratio = tbl_mid_unv_wb_5b;
      74             :     }
      75             :     else
      76             :     {
      77        1603 :         ratio = tbl_mid_gen_wb_5b;
      78             :     }
      79             : 
      80       29019 :     for ( j = 0; j < N; j++ )
      81             :     {
      82       27312 :         qlsf[j] = ( 1.0f - ratio[idx * N + j] ) * qlsf0[j] + ratio[idx * N + j] * qlsf1[j];
      83             :     }
      84             : 
      85        1707 :     if ( mid_lsf_int != NULL ) /*at the decoder*/
      86             :     {
      87             :         /* check for incorrect LSF ordering */
      88         990 :         if ( *mid_lsf_int == 1 )
      89             :         {
      90           0 :             for ( j = 1; j < N; j++ )
      91             :             {
      92           0 :                 if ( qlsf[j] < qlsf[j - 1] )
      93             :                 {
      94           0 :                     bad_spacing = 1;
      95           0 :                     break;
      96             :                 }
      97             :             }
      98             :         }
      99             :         /* Redo mid-LSF interpolation with 0.4 in case of LSF instability */
     100         990 :         if ( prev_bfi || ( *mid_lsf_int == 1 && bad_spacing ) )
     101             :         {
     102           0 :             for ( j = 0; j < N; j++ )
     103             :             {
     104             :                 /* redo mid-LSF interpolation with 0.4 */
     105           0 :                 qlsf[j] = 0.4f * qlsf0[j] + 0.6f * qlsf1[j];
     106             : 
     107             :                 /* ensure correct ordering of LSF indices */
     108           0 :                 if ( j > 0 && j < N && qlsf[j] < qlsf[j - 1] + LSF_GAP_MID )
     109             :                 {
     110           0 :                     qlsf[j] = qlsf[j - 1] + LSF_GAP_MID;
     111             :                 }
     112             :             }
     113             :         }
     114             :         else
     115             :         {
     116             :             /* otherwise, use regular LSF spacing and ordering as in the encoder */
     117       16830 :             for ( j = 0; j < N; j++ )
     118             :             {
     119       15840 :                 if ( j > 0 && j < N && qlsf[j] < qlsf[j - 1] + LSF_GAP_MID )
     120             :                 {
     121         102 :                     qlsf[j] = qlsf[j - 1] + LSF_GAP_MID;
     122             :                 }
     123             :             }
     124             :         }
     125         990 :         if ( prev_bfi )
     126             :         {
     127             :             /* continue redoing mid-LSF interpolation with 0.4 in order not to propagate the error */
     128           0 :             *mid_lsf_int = 1;
     129             :         }
     130         990 :         if ( safety_net )
     131             :         {
     132             :             /* safety-net encountered -> stop redoing mid-LSF interpolation with 0.4 */
     133           0 :             *mid_lsf_int = 0;
     134             :         }
     135             :     }
     136             :     else
     137             :     {
     138             :         /* use regular LSF spacing */
     139       12189 :         for ( j = 0; j < N; j++ )
     140             :         {
     141       11472 :             if ( j > 0 && j < N && qlsf[j] < qlsf[j - 1] + LSF_GAP_MID )
     142             :             {
     143          64 :                 qlsf[j] = qlsf[j - 1] + LSF_GAP_MID;
     144             :             }
     145             :         }
     146             :     }
     147             : 
     148        1707 :     return;
     149             : }
     150             : 
     151             : 
     152             : /*---------------------------------------------------------------------*
     153             :  * lsf_ind_is_active()
     154             :  *
     155             :  *
     156             :  *---------------------------------------------------------------------*/
     157             : 
     158       68415 : int16_t lsf_ind_is_active(
     159             :     const Word16 lsf_q_ind[],
     160             :     const float means[],
     161             :     const int16_t narrowband,
     162             :     const int16_t cdk )
     163             : {
     164             :     Word16 lsf[2], min_distance;
     165             : 
     166       68415 :     lsf[0] = add( lsf_q_ind[0], LSFM( means[0] ) );
     167       68415 :     move16();
     168       68415 :     lsf[1] = add( lsf_q_ind[1], LSFM( means[1] ) );
     169       68415 :     move16();
     170             : 
     171       68415 :     min_distance = lsf[0];
     172       68415 :     min_distance = s_min( min_distance, sub( lsf[1], lsf[0] ) );
     173             : 
     174       68415 :     assert( narrowband == 0 || narrowband == 1 );
     175       68415 :     assert( cdk == 0 || cdk == 1 );
     176             : 
     177       68415 :     return sub( min_distance, min_distance_thr[narrowband][cdk] ) < 0;
     178             : }

Generated by: LCOV version 1.14