LCOV - code coverage report
Current view: top level - lib_enc - subband_fft.c (source / functions) Hit Total Coverage
Test: Coverage on main -- short test vectors @ 6c9ddc4024a9c0e1ecb8f643f114a84a0e26ec6b Lines: 82 82 100.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 <stdint.h>
      38             : #include "options.h"
      39             : #include <math.h>
      40             : #include "prot.h"
      41             : #include "rom_enc.h"
      42             : #include "wmc_auto.h"
      43             : 
      44             : 
      45             : /*-------------------------------------------------------------------*
      46             :  * fft16()
      47             :  *
      48             :  *
      49             :  *-------------------------------------------------------------------*/
      50             : 
      51       31000 : static void fft16( float *r_samp, float *i_samp )
      52             : {
      53             :     int16_t i, j, N, Nv2, nm1, k;
      54             :     float tmpr[16], tmpi[16];
      55             :     float r1, s1, r2, s2;
      56             : 
      57      527000 :     for ( i = 0; i < 16; i++ )
      58             :     {
      59      496000 :         tmpr[i] = r_samp[i] * M_inr[i] - i_samp[i] * M_ini[i];
      60      496000 :         tmpi[i] = r_samp[i] * M_ini[i] + i_samp[i] * M_inr[i];
      61             :     }
      62             : 
      63      279000 :     for ( i = 0; i < 8; i++ )
      64             :     {
      65      248000 :         s1 = tmpr[i] - tmpr[8 + i];
      66      248000 :         r1 = tmpi[i] - tmpi[8 + i];
      67             : 
      68      248000 :         tmpr[i] = tmpr[i] + tmpr[8 + i];
      69      248000 :         tmpi[i] = tmpi[i] + tmpi[8 + i];
      70             : 
      71      248000 :         tmpr[i + 8] = s1 * M_r[i] - r1 * M_i[i];
      72      248000 :         tmpi[i + 8] = s1 * M_i[i] + r1 * M_r[i];
      73             :     }
      74             : 
      75      155000 :     for ( i = 0; i < 4; i++ )
      76             :     {
      77      124000 :         s1 = tmpr[i] - tmpr[4 + i];
      78      124000 :         r1 = tmpi[i] - tmpi[4 + i];
      79             : 
      80      124000 :         tmpr[i] = tmpr[i] + tmpr[4 + i];
      81      124000 :         tmpi[i] = tmpi[i] + tmpi[4 + i];
      82             : 
      83      124000 :         tmpr[i + 4] = s1 * M_r[2 * i] - r1 * M_i[2 * i];
      84      124000 :         tmpi[i + 4] = s1 * M_i[2 * i] + r1 * M_r[2 * i];
      85             :     }
      86      155000 :     for ( i = 0; i < 4; i++ )
      87             :     {
      88      124000 :         s1 = tmpr[i + 8] - tmpr[12 + i];
      89      124000 :         r1 = tmpi[i + 8] - tmpi[12 + i];
      90             : 
      91      124000 :         tmpr[i + 8] = tmpr[i + 8] + tmpr[12 + i];
      92      124000 :         tmpi[i + 8] = tmpi[i + 8] + tmpi[12 + i];
      93             : 
      94      124000 :         tmpr[i + 12] = s1 * M_r[2 * i] - r1 * M_i[2 * i];
      95      124000 :         tmpi[i + 12] = s1 * M_i[2 * i] + r1 * M_r[2 * i];
      96             :     }
      97             : 
      98             : 
      99      155000 :     for ( i = 0; i < 16; i = i + 4 )
     100             :     {
     101      124000 :         s1 = tmpr[i] - tmpr[2 + i];
     102      124000 :         r1 = tmpi[i] - tmpi[2 + i];
     103      124000 :         s2 = tmpr[i + 1] - tmpr[3 + i];
     104      124000 :         r2 = tmpi[i + 1] - tmpi[3 + i];
     105             : 
     106      124000 :         tmpr[i] = tmpr[i] + tmpr[2 + i];
     107      124000 :         tmpi[i] = tmpi[i] + tmpi[2 + i];
     108      124000 :         tmpr[i + 1] = tmpr[i + 1] + tmpr[3 + i];
     109      124000 :         tmpi[i + 1] = tmpi[i + 1] + tmpi[3 + i];
     110             : 
     111      124000 :         tmpr[i + 2] = s1 * M_r[0] - r1 * M_i[0];
     112      124000 :         tmpi[i + 2] = s1 * M_i[0] + r1 * M_r[0];
     113      124000 :         tmpr[i + 3] = s2 * M_r[4] - r2 * M_i[4];
     114      124000 :         tmpi[i + 3] = s2 * M_i[4] + r2 * M_r[4];
     115             :     }
     116             : 
     117      279000 :     for ( i = 0; i < 16; i = i + 2 )
     118             :     {
     119      248000 :         s1 = tmpr[i] - tmpr[1 + i];
     120      248000 :         r1 = tmpi[i] - tmpi[1 + i];
     121             : 
     122      248000 :         tmpr[i] = tmpr[i] + tmpr[1 + i];
     123      248000 :         tmpi[i] = tmpi[i] + tmpi[1 + i];
     124             : 
     125      248000 :         tmpr[i + 1] = s1 * M_r[0] - r1 * M_i[0];
     126      248000 :         tmpi[i + 1] = s1 * M_i[0] + r1 * M_r[0];
     127             :     }
     128             : 
     129       31000 :     N = 16;
     130       31000 :     Nv2 = N >> 1;
     131       31000 :     nm1 = N - 1;
     132       31000 :     j = 0;
     133      496000 :     for ( i = 0; i < nm1; i++ )
     134             :     {
     135      465000 :         if ( i < j )
     136             :         {
     137      186000 :             r_samp[j] = tmpr[i] * M_Wr[j] - tmpi[i] * M_Wi[j];
     138      186000 :             i_samp[j] = tmpr[i] * M_Wi[j] + tmpi[i] * M_Wr[j];
     139      186000 :             r_samp[i] = tmpr[j] * M_Wr[i] - tmpi[j] * M_Wi[i];
     140      186000 :             i_samp[i] = tmpr[j] * M_Wi[i] + tmpi[j] * M_Wr[i];
     141             :         }
     142      279000 :         else if ( i == j )
     143             :         {
     144       93000 :             r_samp[i] = tmpr[i] * M_Wr[i] - tmpi[i] * M_Wi[i];
     145       93000 :             i_samp[i] = tmpr[i] * M_Wi[i] + tmpi[i] * M_Wr[i];
     146             :         }
     147             : 
     148      465000 :         k = Nv2;
     149      806000 :         while ( k <= j )
     150             :         {
     151      341000 :             j -= k;
     152      341000 :             k >>= 1;
     153             :         }
     154      465000 :         j += k;
     155             :     }
     156             : 
     157       31000 :     r_samp[15] = tmpr[15] * M_Wr[15] - tmpi[15] * M_Wi[15];
     158       31000 :     i_samp[15] = tmpr[15] * M_Wi[15] + tmpi[15] * M_Wr[15];
     159             : 
     160       31000 :     return;
     161             : }
     162             : 
     163             : 
     164             : /*-------------------------------------------------------------------*
     165             :  * subband_FFT()
     166             :  *
     167             :  *
     168             :  *-------------------------------------------------------------------*/
     169             : 
     170        3100 : void subband_FFT(
     171             :     float Sr[16][60], /* i  : real part of the cldfb    */
     172             :     float Si[16][60], /* i  : imag part of the cldfb    */
     173             :     float *spec_amp   /* o  : spectral amplitude        */
     174             : )
     175             : {
     176             :     int16_t i, j;
     177             :     float tmpr[16], tmpi[16];
     178             :     float ptmp[16], tmp1;
     179             : 
     180       34100 :     for ( i = 0; i < 10; i++ )
     181             :     {
     182      527000 :         for ( j = 0; j < 16; j++ )
     183             :         {
     184      496000 :             tmpr[j] = Sr[j][i];
     185      496000 :             tmpi[j] = Si[j][i];
     186             :         }
     187             : 
     188       31000 :         fft16( tmpr, tmpi );
     189             : 
     190      527000 :         for ( j = 0; j < 16; j++ )
     191             :         {
     192      496000 :             ptmp[j] = tmpr[j] * tmpr[j] + tmpi[j] * tmpi[j];
     193             :         }
     194       31000 :         if ( i % 2 == 0 )
     195             :         {
     196      139500 :             for ( j = 0; j < 8; j++ )
     197             :             {
     198      124000 :                 tmp1 = ptmp[j] + ptmp[15 - j];
     199      124000 :                 spec_amp[i * 8 + j] = (float) sqrt( tmp1 );
     200             :             }
     201             :         }
     202             :         else
     203             :         {
     204      139500 :             for ( j = 0; j < 8; j++ )
     205             :             {
     206      124000 :                 tmp1 = ptmp[j] + ptmp[15 - j];
     207      124000 :                 spec_amp[i * 8 + 7 - j] = (float) sqrt( tmp1 );
     208             :             }
     209             :         }
     210             :     }
     211             : 
     212        3100 :     return;
     213             : }

Generated by: LCOV version 1.14