LCOV - code coverage report
Current view: top level - lib_enc - analy_lp.c (source / functions) Hit Total Coverage
Test: Coverage on main -- short test vectors @ 6c9ddc4024a9c0e1ecb8f643f114a84a0e26ec6b Lines: 22 35 62.9 %
Date: 2025-05-23 08:37:30 Functions: 1 2 50.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             : #ifdef DEBUGGING
      40             : #include "debug.h"
      41             : #endif
      42             : #include "cnst.h"
      43             : #include "rom_com.h"
      44             : #include "prot.h"
      45             : #include "wmc_auto.h"
      46             : 
      47             : /*-------------------------------------------------------------------*
      48             :  * analy_lp()
      49             :  *
      50             :  * Perform LP analysis
      51             :  *
      52             :  * - autocorrelations + lag windowing
      53             :  * - Levinson-Durbin algorithm to find A(z)
      54             :  * - convert A(z) to LSPs
      55             :  * - find interpolated LSPs and convert back to A(z) for all subframes
      56             :  * - update LSPs for the next frame
      57             :  *-------------------------------------------------------------------*/
      58             : 
      59     1319689 : void analy_lp(
      60             :     const float speech[],           /* i  : pointer to the speech frame                         */
      61             :     const int16_t L_frame,          /* i  : length of the frame                                 */
      62             :     const int16_t L_look,           /* i  : look-ahead                                          */
      63             :     float *ener,                    /* o  : residual energy from Levinson-Durbin                */
      64             :     float A[],                      /* o  : A(z) filter coefficients                            */
      65             :     float epsP[],                   /* o  : LP analysis residual energies for each iteration    */
      66             :     float lsp_new[],                /* o  : current frame LSPs                                  */
      67             :     float lsp_mid[],                /* o  : current mid-frame LSPs                              */
      68             :     float lsp_old[],                /* i/o: previous frame unquantized LSPs                     */
      69             :     const int16_t Top[2],           /* i  : open loop pitch lag                                 */
      70             :     const float Tnc[2],             /* i  : open loop pitch gain                                */
      71             :     const int32_t sr_core,          /* i  : internal sampling rate                              */
      72             :     const int16_t sec_chan_low_rate /* i  : TD secondary channel flag                           */
      73             : )
      74             : {
      75             :     int16_t i_subfr, wind_length, half_frame;
      76             :     float r[M + 1], *lsp;
      77             :     const float *wind, *pt;
      78             :     int16_t half_frame_idx;
      79             : 
      80     1319689 :     if ( L_frame == L_FRAME )
      81             :     {
      82     1153834 :         wind_length = L_LP;
      83     1153834 :         wind = LP_assym_window;
      84             :     }
      85             :     else /* L_frame == L_FRAME16k */
      86             :     {
      87      165855 :         wind_length = L_LP_16k;
      88      165855 :         wind = LP_assym_window_16k;
      89             :     }
      90     1319689 :     lsp = lsp_mid;
      91     1319689 :     half_frame = L_frame >> 1;
      92             : 
      93     1319689 :     half_frame_idx = 0;
      94     3959067 :     for ( i_subfr = half_frame; i_subfr <= L_frame; i_subfr = i_subfr + half_frame )
      95             :     {
      96     2639378 :         pt = speech + i_subfr + L_look - wind_length;
      97             : 
      98             :         /* Autocorrelations */
      99     2639378 :         autocorr( pt, r, M, wind_length, wind, 0, 0, 0 );
     100             : 
     101             :         /* Lag windowing */
     102     2639378 :         adapt_lag_wind( r, M, Top[half_frame_idx], Tnc[half_frame_idx], sr_core );
     103     2639378 :         ++half_frame_idx;
     104             : 
     105             :         /* Levinson-Durbin */
     106     2639378 :         lev_dur( A, r, M, epsP );
     107             : 
     108             :         /* Conversion of A(z) to LSPs */
     109     2639378 :         a2lsp_stab( A, lsp, lsp_old );
     110             : 
     111     2639378 :         lsp = lsp_new;
     112             :     }
     113             : 
     114     1319689 :     if ( sec_chan_low_rate == 1 )
     115             :     {
     116           0 :         int_lsp4( L_frame, lsp_old, lsp_mid, lsp_new, A, M, -2 );
     117             :     }
     118             :     else
     119             :     {
     120             :         /* LSP interpolation */
     121     1319689 :         int_lsp4( L_frame, lsp_old, lsp_mid, lsp_new, A, M, 0 );
     122             :     }
     123             : 
     124             :     /* updates */
     125     1319689 :     mvr2r( lsp_new, lsp_old, M );
     126             : 
     127     1319689 :     *ener = epsP[M];
     128             : 
     129     1319689 :     return;
     130             : }
     131             : 
     132             : 
     133             : /*-------------------------------------------------------------------*
     134             :  * analy_lp_AMR_WB()
     135             :  *
     136             :  * Perform LP analysis for AMR-WB IO mode
     137             :  *
     138             :  * - autocorrelations + lag windowing
     139             :  * - Levinson-Durbin algorithm to find A(z)
     140             :  * - convert A(z) to ISPs
     141             :  * - find interpolated ISPs and convert back to A(z) for all subframes
     142             :  * - update ISPs for the next frame
     143             :  *-------------------------------------------------------------------*/
     144             : 
     145           0 : void analy_lp_AMR_WB(
     146             :     const float speech[], /* i  : pointer to the speech frame                      */
     147             :     float *ener,          /* o  : residual energy from Levinson-Durbin             */
     148             :     float A[],            /* o  : A(z) filter coefficients                         */
     149             :     float epsP[],         /* o  : LP analysis residual energies for each iteration */
     150             :     float isp_new[],      /* o  : current frame ISPs                               */
     151             :     float isp_old[],      /* i/o: previous frame unquantized ISPs                  */
     152             :     float isf_new[],      /* o  : current frame ISFs                               */
     153             :     const int16_t Top,    /* i  : open loop pitch lag                              */
     154             :     const float Tnc       /* i  : open loop pitch gain                             */
     155             : )
     156             : {
     157             :     int16_t wind_length;
     158             :     float r[M + 1];
     159             :     const float *wind;
     160             : 
     161             :     /* Initialization */
     162           0 :     wind_length = L_LP_AMR_WB;
     163           0 :     wind = hamcos_window;
     164             : 
     165             :     /* Autocorrelations */
     166           0 :     autocorr( speech - L_SUBFR, r, M, wind_length, wind, 0, 0, 0 );
     167             : 
     168             :     /* Lag windowing */
     169           0 :     adapt_lag_wind( r, M, Top, Tnc, 12800 );
     170             : 
     171             :     /* Levinson-Durbin  */
     172           0 :     lev_dur( A, r, M, epsP );
     173             : 
     174           0 :     a2isf( A, isf_new, stable_ISF, M );
     175           0 :     isf2isp( isf_new, isp_new, M, INT_FS_12k8 );
     176             : 
     177             :     /* ISP interpolation */
     178           0 :     int_lsp( L_FRAME, isp_old, isp_new, A, M, interpol_isp_amr_wb, 1 );
     179             : 
     180           0 :     *ener = epsP[M];
     181             : 
     182             :     /* updates */
     183           0 :     mvr2r( isp_new, isp_old, M );
     184             : 
     185           0 :     return;
     186             : }

Generated by: LCOV version 1.14