LCOV - code coverage report
Current view: top level - lib_com - int_lsp.c (source / functions) Hit Total Coverage
Test: Coverage on main enc/dec/rend @ 3b2f07138c61dcf997bbf4165d0882f794b2995f Lines: 74 82 90.2 %
Date: 2025-05-03 01:55:50 Functions: 3 3 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 <stdint.h>
      38             : #include "options.h"
      39             : #include "cnst.h"
      40             : #include "prot_fx.h"
      41             : #include "rom_com.h"
      42             : #include "wmc_auto.h"
      43             : 
      44             : 
      45      122400 : void int_lsp_fx(
      46             :     const Word16 L_frame,     /* i  : length of the frame               */
      47             :     const Word16 lsp_old[],   /* i  : Q15 LSPs from past frame              */
      48             :     const Word16 lsp_new[],   /* i  : Q15 LSPs from present frame           */
      49             :     Word16 *Aq,               /* o  : Q12 LP coefficients in both subframes */
      50             :     const Word16 m,           /* i  : order of LP filter                */
      51             :     const Word16 *int_coeffs, /* i  : Q15 interpolation coefficients        */
      52             :     const Word16 Opt_AMR_WB   /* i  : Q0 flag indicating AMR-WB IO mode    */
      53             : )
      54             : {
      55             :     Word16 lsp[M], fnew, fold;
      56             :     Word16 i, k;
      57      122400 :     const Word16 *pt_int_coeffs = NULL;
      58             :     Word32 L_tmp;
      59             :     Word16 tmp;
      60             : 
      61      122400 :     tmp = shr( L_frame, 6 ); /*L_frame/L_SUBFR */
      62             : 
      63      122400 :     IF( EQ_16( L_frame, L_FRAME ) )
      64             :     {
      65       48199 :         pt_int_coeffs = int_coeffs; /*Q15*/
      66       48199 :         move16();
      67             :     }
      68             :     ELSE /* L_frame == L_FRAME16k */
      69             :     {
      70       74201 :         pt_int_coeffs = interpol_frac_16k_fx; /*Q15*/
      71             :     }
      72      686201 :     FOR( k = 0; k < tmp; k++ )
      73             :     {
      74      563801 :         fnew = pt_int_coeffs[k];
      75      563801 :         move16();
      76      563801 :         fold = sub( 32767, fnew ); /* 1.0 - fac_new */
      77      563801 :         if ( fold != 0 )
      78             :         {
      79      441401 :             fold = add( fold, 1 );
      80             :         }
      81     9584617 :         FOR( i = 0; i < m; i++ )
      82             :         {
      83     9020816 :             L_tmp = L_mult( lsp_old[i], fold );       /*Q31*/
      84     9020816 :             L_tmp = L_mac( L_tmp, lsp_new[i], fnew ); /*Q31*/
      85     9020816 :             IF( fold == 0 )
      86             :             {
      87     1958400 :                 L_tmp = L_mac( L_tmp, lsp_new[i], 1 ); /* 'fnew' should have been 32768 */
      88             :             }
      89     9020816 :             lsp[i] = round_fx( L_tmp ); /*Q15*/
      90             :         }
      91      563801 :         IF( Opt_AMR_WB )
      92             :         {
      93           0 :             E_LPC_f_isp_a_conversion( lsp, Aq, m );
      94             :         }
      95             :         ELSE
      96             :         {
      97      563801 :             E_LPC_f_lsp_a_conversion( lsp, Aq, m );
      98             :         }
      99      563801 :         Aq += ( m + 1 );
     100             :     }
     101             : 
     102      122400 :     return;
     103             : }
     104             : 
     105             : 
     106        2102 : void int_lsp4_fx(
     107             :     const Word16 L_frame,        /* i  : length of the frame                   */
     108             :     const Word16 lsp_old[],      /* i  : LSPs from past frame               Q15*/
     109             :     const Word16 lsp_mid[],      /* i  : LSPs from mid-frame                              Q15*/
     110             :     const Word16 lsp_new[],      /* i  : LSPs from present frame            Q15*/
     111             :     Word16 *Aq,                  /* o  : LP coefficients in both subframes  Q12*/
     112             :     const Word16 m,              /* i  : order of LP filter                    */
     113             :     Word16 relax_prev_lsf_interp /* i  : relax prev frame lsf interp after erasure */
     114             : )
     115             : {
     116             :     Word16 lsp[M16k];
     117             :     Word16 i, j, k;
     118             :     Word32 L_tmp;
     119             :     const Word16 *pt_int_coeffs;
     120             : 
     121        2102 :     IF( EQ_16( L_frame, L_FRAME ) )
     122             :     {
     123        1090 :         IF( EQ_16( relax_prev_lsf_interp, 1 ) )
     124             :         {
     125           0 :             pt_int_coeffs = interpol_frac_mid_relaxprev_12k8_fx; /*Q15*/
     126             :         }
     127        1090 :         ELSE IF( EQ_16( relax_prev_lsf_interp, 2 ) )
     128             :         {
     129           0 :             pt_int_coeffs = interpol_frac_mid_FEC_fx; /*Q15*/
     130             :         }
     131        1090 :         ELSE IF( EQ_16( relax_prev_lsf_interp, -1 ) )
     132             :         {
     133           0 :             pt_int_coeffs = interpol_frac_mid_relaxprev_pred_12k8_fx; /*Q15*/
     134             :         }
     135             :         ELSE
     136             :         {
     137        1090 :             pt_int_coeffs = interpol_frac_mid_fx; /*Q15*/
     138             :         }
     139             :     }
     140             :     ELSE /* L_frame == L_FRAME16k */
     141             :     {
     142        1012 :         IF( EQ_16( relax_prev_lsf_interp, 1 ) )
     143             :         {
     144           0 :             pt_int_coeffs = interpol_frac_mid_relaxprev_16k_fx; /*Q15*/
     145             :         }
     146        1012 :         ELSE IF( EQ_16( relax_prev_lsf_interp, 2 ) )
     147             :         {
     148           0 :             pt_int_coeffs = interpol_frac_mid_16k_FEC_fx; /*Q15*/
     149             :         }
     150        1012 :         ELSE IF( EQ_16( relax_prev_lsf_interp, -1 ) )
     151             :         {
     152           0 :             pt_int_coeffs = interpol_frac_mid_relaxprev_pred_16k_fx; /*Q15*/
     153             :         }
     154             :         ELSE
     155             :         {
     156        1012 :             pt_int_coeffs = interpol_frac_mid_16k_fx; /*Q15*/
     157             :         }
     158             :     }
     159        2102 :     k = sub( shr( L_frame, 6 ), 1 );
     160        9420 :     FOR( j = 0; j < k; j++ )
     161             :     {
     162      124406 :         FOR( i = 0; i < m; i++ )
     163             :         {
     164      117088 :             L_tmp = L_mult( lsp_old[i], *pt_int_coeffs );               /*Q31 */
     165      117088 :             L_tmp = L_mac( L_tmp, lsp_mid[i], *( pt_int_coeffs + 1 ) ); /*Q31 */
     166      117088 :             lsp[i] = mac_r( L_tmp, lsp_new[i], *( pt_int_coeffs + 2 ) );
     167      117088 :             move16();
     168             :         }
     169        7318 :         pt_int_coeffs += 3;
     170             : 
     171        7318 :         E_LPC_f_lsp_a_conversion( lsp, Aq, m );
     172        7318 :         Aq += add( m, 1 );
     173             :     }
     174             : 
     175             :     /* Last subframe */
     176        2102 :     E_LPC_f_lsp_a_conversion( lsp_new, Aq, m );
     177             : 
     178        2102 :     return;
     179             : }
     180             : 
     181     1594951 : void int_lsp4_ivas_fx(
     182             :     const Word16 L_frame,        /* i  : length of the frame                   */
     183             :     const Word16 lsp_old[],      /* i  : LSPs from past frame               Q15*/
     184             :     const Word16 lsp_mid[],      /* i  : LSPs from mid-frame                              Q15*/
     185             :     const Word16 lsp_new[],      /* i  : LSPs from present frame            Q15*/
     186             :     Word16 *Aq,                  /* o  : LP coefficients in both subframes  Q12*/
     187             :     const Word16 m,              /* i  : order of LP filter                    */
     188             :     Word16 relax_prev_lsf_interp /* i  : relax prev frame lsf interp after erasure */
     189             : )
     190             : {
     191             :     Word16 lsp[M16k];
     192             :     Word16 i, j, k;
     193             :     Word32 L_tmp;
     194             :     const Word16 *pt_int_coeffs;
     195             : 
     196     1594951 :     IF( EQ_16( L_frame, L_FRAME ) )
     197             :     {
     198     1288559 :         IF( EQ_16( relax_prev_lsf_interp, 1 ) )
     199             :         {
     200          48 :             pt_int_coeffs = interpol_frac_mid_relaxprev_12k8_fx; /*Q15*/
     201             :         }
     202     1288511 :         ELSE IF( EQ_16( relax_prev_lsf_interp, 2 ) )
     203             :         {
     204          41 :             pt_int_coeffs = interpol_frac_mid_FEC_fx; /*Q15*/
     205             :         }
     206     1288470 :         ELSE IF( EQ_16( relax_prev_lsf_interp, -1 ) )
     207             :         {
     208           3 :             pt_int_coeffs = interpol_frac_mid_relaxprev_pred_12k8_fx; /*Q15*/
     209             :         }
     210     1288467 :         ELSE IF( EQ_16( relax_prev_lsf_interp, -2 ) )
     211             :         {
     212             :             // This condition not present in int_lsp4_fx
     213           5 :             pt_int_coeffs = interpol_frac2_mid_fx; /*Q15*/
     214             :         }
     215             :         ELSE
     216             :         {
     217     1288462 :             pt_int_coeffs = interpol_frac_mid_fx; /*Q15*/
     218             :         }
     219             :     }
     220             :     ELSE /* L_frame == L_FRAME16k */
     221             :     {
     222      306392 :         IF( EQ_16( relax_prev_lsf_interp, 1 ) )
     223             :         {
     224         130 :             pt_int_coeffs = interpol_frac_mid_relaxprev_16k_fx; /*Q15*/
     225             :         }
     226      306262 :         ELSE IF( EQ_16( relax_prev_lsf_interp, 2 ) )
     227             :         {
     228          58 :             pt_int_coeffs = interpol_frac_mid_16k_FEC_fx; /*Q15*/
     229             :         }
     230      306204 :         ELSE IF( EQ_16( relax_prev_lsf_interp, -1 ) )
     231             :         {
     232           0 :             pt_int_coeffs = interpol_frac_mid_relaxprev_pred_16k_fx; /*Q15*/
     233             :         }
     234             :         ELSE
     235             :         {
     236      306204 :             pt_int_coeffs = interpol_frac_mid_16k_fx; /*Q15*/
     237             :         }
     238             :     }
     239     1594951 :     k = sub( shr( L_frame, 6 ), 1 );
     240     6686196 :     FOR( j = 0; j < k; j++ )
     241             :     {
     242    86551165 :         FOR( i = 0; i < m; i++ )
     243             :         {
     244    81459920 :             L_tmp = L_mult( lsp_old[i], *pt_int_coeffs );               /*Q31 */
     245    81459920 :             L_tmp = L_mac( L_tmp, lsp_mid[i], *( pt_int_coeffs + 1 ) ); /*Q31 */
     246    81459920 :             lsp[i] = mac_r( L_tmp, lsp_new[i], *( pt_int_coeffs + 2 ) );
     247    81459920 :             move16();
     248             :         }
     249     5091245 :         pt_int_coeffs += 3;
     250             : 
     251     5091245 :         E_LPC_f_lsp_a_conversion( lsp, Aq, m );
     252     5091245 :         Aq += add( m, 1 );
     253             :     }
     254             : 
     255             :     /* Last subframe */
     256     1594951 :     E_LPC_f_lsp_a_conversion( lsp_new, Aq, m );
     257             : 
     258     1594951 :     return;
     259             : }

Generated by: LCOV version 1.14