LCOV - code coverage report
Current view: top level - lib_com - mslvq_com.c (source / functions) Hit Total Coverage
Test: Coverage on main enc/dec/rend @ 3b2f07138c61dcf997bbf4165d0882f794b2995f Lines: 47 76 61.8 %
Date: 2025-05-03 01:55:50 Functions: 3 4 75.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 <stdint.h>
      38             : #include "options.h"
      39             : #include "cnst.h"
      40             : #include "rom_com.h"
      41             : #include "prot_fx.h"
      42             : #include "wmc_auto.h"
      43             : #include "ivas_prot_fx.h"
      44             : 
      45             : /*-----------------------------------------------------------------*
      46             :  * Local function prototypes
      47             :  *-----------------------------------------------------------------*/
      48             : 
      49     2701344 : static void make_offset_scale(
      50             :     const UWord32 tab_no_cv[],
      51             :     const Word8 *no_ld,
      52             :     const Word16 no_scl,
      53             :     UWord32 *offset_scale )
      54             : {
      55             :     Word16 i;
      56             : 
      57     2701344 :     offset_scale[0] = 1;
      58     2701344 :     move32();
      59    10805376 :     FOR( i = 1; i <= no_scl; i++ )
      60             :     {
      61     8104032 :         offset_scale[i] = UL_addNsD( offset_scale[i - 1], tab_no_cv[(Word16) no_ld[i - 1]] );
      62     8104032 :         move32();
      63             :     }
      64             : 
      65     2701344 :     return;
      66             : }
      67             : 
      68             : /*-----------------------------------------------------------------*
      69             :  * create_offset()
      70             :  *
      71             :  *
      72             :  *-----------------------------------------------------------------*/
      73             : 
      74     1350672 : void create_offset(
      75             :     UWord32 *offset_scale1,
      76             :     UWord32 *offset_scale2,
      77             :     const Word16 mode,
      78             :     const Word16 prediction_flag )
      79             : {
      80             :     Word16 tmp, tmp1;
      81             : 
      82     1350672 :     if ( prediction_flag == 0 )
      83             :     {
      84             :         /* safety_net */
      85      233028 :         tmp = no_lead_idx[mode][0];
      86      233028 :         if ( ( tmp <= LIMIT_LEADER ) && ( tmp < no_lead_idx[mode][1] - 2 ) )
      87             :         {
      88           0 :             tmp += DELTA_LEADER;
      89             :         }
      90      233028 :         make_offset_scale( table_no_cv, leaders_short[tmp], MAX_NO_SCALES, offset_scale1 );
      91      233028 :         make_offset_scale( table_no_cv, leaders_short[no_lead_idx[mode][1]], MAX_NO_SCALES, offset_scale2 );
      92             :     }
      93             :     else
      94             :     {
      95     1117644 :         tmp = no_lead_p_idx[mode][0];
      96     1117644 :         tmp1 = no_lead_p_idx[mode][1];
      97     1117644 :         if ( ( tmp <= LIMIT_LEADER ) && ( tmp < tmp1 - 2 ) )
      98             :         {
      99       25805 :             tmp += DELTA_LEADER;
     100             :         }
     101             : 
     102     1117644 :         if ( ( tmp == LIMIT_LEADER ) && ( tmp1 == 0 ) )
     103             :         {
     104           0 :             tmp += DELTA_LEADER;
     105           0 :             tmp1 = DELTA_LEADER;
     106             :         }
     107             : 
     108     1117644 :         make_offset_scale( table_no_cv, leaders_short[tmp], MAX_NO_SCALES, offset_scale1 );
     109     1117644 :         make_offset_scale( table_no_cv, leaders_short[tmp1], MAX_NO_SCALES, offset_scale2 );
     110             :     }
     111             : 
     112     1350672 :     return;
     113             : }
     114             : 
     115             : /*-----------------------------------------------------------------*
     116             :  * sort_desc_ind()
     117             :  *
     118             :  * sorts in descending order and computes indices in the sorted vector
     119             :  *-----------------------------------------------------------------*/
     120           0 : void sort_desc_ind_16_fx(
     121             :     Word16 *s,        /* i/o: vector to be sorted Qx*/
     122             :     const Word16 len, /* i  : vector length       */
     123             :     Word16 *ind       /* o  : array of indices    */
     124             : )
     125             : {
     126             :     Word16 i, k, sorted, a;
     127             :     Word16 t;
     128             : 
     129           0 :     FOR( i = 0; i < len; i++ )
     130             :     {
     131           0 :         ind[i] = i;
     132           0 :         move16();
     133             :     }
     134           0 :     sorted = 0;
     135           0 :     move16();
     136           0 :     FOR( k = len - 1; k && !sorted; k-- )
     137             :     {
     138           0 :         sorted = 1;
     139           0 :         move16();
     140           0 :         FOR( i = 0; i < k; i++ )
     141             :         {
     142           0 :             IF( LT_16( s[i], s[i + 1] ) )
     143             :             {
     144           0 :                 sorted = 0;
     145           0 :                 move16();
     146           0 :                 t = s[i];
     147           0 :                 move16();
     148           0 :                 s[i] = s[i + 1];
     149           0 :                 move16();
     150           0 :                 s[i + 1] = t;
     151           0 :                 move16();
     152           0 :                 a = ind[i];
     153           0 :                 move16();
     154           0 :                 ind[i] = ind[i + 1];
     155           0 :                 move16();
     156           0 :                 ind[i + 1] = a;
     157           0 :                 move16();
     158             :             }
     159             :         }
     160             :     }
     161             : 
     162           0 :     return;
     163             : }
     164             : 
     165        4346 : void sort_desc_ind_32_fx(
     166             :     Word32 *s,        /* i/o: vector to be sorted Qx*/
     167             :     const Word16 len, /* i  : vector length       */
     168             :     Word16 *ind       /* o  : array of indices    */
     169             : )
     170             : {
     171             :     Word16 i, k, sorted, a;
     172             :     Word32 t;
     173             : 
     174       21499 :     FOR( i = 0; i < len; i++ )
     175             :     {
     176       17153 :         ind[i] = i;
     177       17153 :         move16();
     178             :     }
     179        4346 :     sorted = 0;
     180        4346 :     move16();
     181       14675 :     FOR( k = len - 1; k && !sorted; k-- )
     182             :     {
     183       10329 :         sorted = 1;
     184       10329 :         move16();
     185       32824 :         FOR( i = 0; i < k; i++ )
     186             :         {
     187       22495 :             IF( LT_32( s[i], s[i + 1] ) )
     188             :             {
     189       10461 :                 sorted = 0;
     190       10461 :                 move16();
     191       10461 :                 t = s[i];
     192       10461 :                 move16();
     193       10461 :                 s[i] = s[i + 1];
     194       10461 :                 move16();
     195       10461 :                 s[i + 1] = t;
     196       10461 :                 move16();
     197       10461 :                 a = ind[i];
     198       10461 :                 move16();
     199       10461 :                 ind[i] = ind[i + 1];
     200       10461 :                 move16();
     201       10461 :                 ind[i + 1] = a;
     202       10461 :                 move16();
     203             :             }
     204             :         }
     205             :     }
     206             : 
     207        4346 :     return;
     208             : }

Generated by: LCOV version 1.14