LCOV - code coverage report
Current view: top level - lib_com - tcx_mdct_window.c (source / functions) Hit Total Coverage
Test: Coverage on main -- merged total coverage @ 9b04ec3cb36f5e8dc438cf854fa3e349998fa1e9 Lines: 111 115 96.5 %
Date: 2025-10-31 05:45:46 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 <math.h>
      44             : #include "cnst.h"
      45             : #include "prot.h"
      46             : #include "rom_com.h"
      47             : #include "wmc_auto.h"
      48             : 
      49             : /*-------------------------------------------------------------------
      50             :  * mdct_window_sine()
      51             :  *
      52             :  *
      53             :  *-------------------------------------------------------------------*/
      54    16286302 : void mdct_window_sine(
      55             :     float *window,
      56             :     const int32_t Fs,
      57             :     const int16_t n,
      58             :     const int16_t window_type,
      59             :     const int16_t element_mode )
      60             : {
      61    16286302 :     if ( element_mode == EVS_MONO )
      62             :     {
      63             :         int16_t i;
      64             :         float c;
      65             : 
      66       23289 :         c = EVS_PI / ( 2.0f * (float) n );
      67             : 
      68     2689403 :         for ( i = 0; i < n; i++ )
      69             :         {
      70     2666114 :             window[i] = (float) sin( c * ( 0.5f + (float) i ) );
      71             :         }
      72             :     }
      73             :     else
      74             :     {
      75    16263013 :         const float *window_table = 0;
      76    16263013 :         int16_t buf_in_size = 0;
      77    16263013 :         switch ( window_type )
      78             :         {
      79     7684305 :             case FULL_OVERLAP:
      80     7684305 :                 window_table = tcx_mdct_window_48;
      81     7684305 :                 buf_in_size = 420;
      82     7684305 :                 break;
      83     4289354 :             case HALF_OVERLAP:
      84     4289354 :                 window_table = tcx_mdct_window_half_48;
      85     4289354 :                 buf_in_size = 180;
      86     4289354 :                 break;
      87     4289354 :             case TRANSITION_OVERLAP:
      88             :             case MIN_OVERLAP:
      89     4289354 :                 window_table = tcx_mdct_window_trans_48;
      90     4289354 :                 buf_in_size = 60;
      91     4289354 :                 break;
      92             : 
      93           0 :             default:
      94           0 :                 assert( 0 && "Unsupported window type" );
      95             :                 break;
      96             :         }
      97             : 
      98    16263013 :         if ( Fs == 48000 )
      99             :         {
     100     4676903 :             mvr2r( window_table, window, n );
     101             :         }
     102             :         else
     103             :         {
     104    11586110 :             lerp( window_table, window, n, buf_in_size );
     105             :         }
     106             :     }
     107             : 
     108    16286302 :     return;
     109             : }
     110             : 
     111             : 
     112             : /*-------------------------------------------------------------------
     113             :  * mdct_window_aldo()
     114             :  *
     115             :  *
     116             :  *-------------------------------------------------------------------*/
     117             : 
     118     4560400 : void mdct_window_aldo(
     119             :     float *window1,
     120             :     float *window2,
     121             :     const int16_t n )
     122             : {
     123             :     int16_t i, n1, n2, d;
     124             :     const float *p1, *p2;
     125             : 
     126             :     /* set table pointers and decimation factor */
     127     4560400 :     switch ( n )
     128             :     {
     129         151 :         case 320 / 2:
     130         151 :             p1 = window_48kHz + 2;
     131         151 :             p2 = window_48kHz + 1110 - 3;
     132         151 :             d = 6;
     133         151 :             break;
     134      484490 :         case 512 / 2:
     135      484490 :             p1 = window_256kHz;
     136      484490 :             p2 = window_256kHz + 592 - 1;
     137      484490 :             d = 2;
     138      484490 :             break;
     139      900712 :         case 640 / 2:
     140      900712 :             p1 = window_48kHz + 1;
     141      900712 :             p2 = window_48kHz + 1110 - 2;
     142      900712 :             d = 3;
     143      900712 :             break;
     144      695916 :         case 1024 / 2:
     145      695916 :             p1 = window_256kHz;
     146      695916 :             p2 = window_256kHz + 592 - 1;
     147      695916 :             d = 1;
     148      695916 :             break;
     149      924270 :         case 1280 / 2:
     150      924270 :             p1 = window_48kHz + 1;
     151      924270 :             p2 = window_48kHz + 1110 - 2;
     152      924270 :             d = 3;
     153      924270 :             break;
     154     1554861 :         case 1920 / 2:
     155     1554861 :             p1 = window_48kHz;
     156     1554861 :             p2 = window_48kHz + 1110 - 1;
     157     1554861 :             d = 1;
     158     1554861 :             break;
     159           0 :         default:
     160           0 :             assert( 0 );
     161             :             return;
     162             :     }
     163             : 
     164             :     /* set lengths */
     165     4560400 :     n1 = n * 23 / 32; /* left slope length */
     166     4560400 :     n2 = n * 14 / 32; /* right slope length */
     167             : 
     168             :     /* first part (long slope) */
     169     4560400 :     if ( n != 1280 / 2 )
     170             :     {
     171  1134264626 :         for ( i = 0; i < n / 2; i++ )
     172             :         {
     173  1130628496 :             *window1 = *p1;
     174  1130628496 :             window1++;
     175  1130628496 :             p1 += d;
     176             :         }
     177             : 
     178     3636130 :         if ( ( n == 512 / 2 ) || ( n == 320 / 2 ) )
     179      484641 :             p1++;
     180             : 
     181   498286097 :         for ( ; i < n1; i++ )
     182             :         {
     183   494649967 :             *window1 = *p1;
     184   494649967 :             window1++;
     185   494649967 :             p1 += d;
     186             :         }
     187             :     }
     188             :     else
     189             :     {
     190      924270 :         const float *pi = window_8_16_32kHz;
     191             : 
     192   148807470 :         for ( i = 0; i < n / 2; i += 2 )
     193             :         {
     194   147883200 :             *window1 = *p1;
     195   147883200 :             window1++;
     196   147883200 :             p1 += d;
     197             : 
     198   147883200 :             *window1 = *pi;
     199   147883200 :             window1++;
     200   147883200 :             pi++;
     201             :         }
     202    65623170 :         for ( ; i < n1; i += 2 )
     203             :         {
     204    64698900 :             *window1 = *pi;
     205    64698900 :             window1++;
     206    64698900 :             pi++;
     207             : 
     208    64698900 :             *window1 = *p1;
     209    64698900 :             window1++;
     210    64698900 :             p1 += d;
     211             :         }
     212             :     }
     213             : 
     214             :     /* second part (short slope) */
     215             : 
     216     4560400 :     if ( n != 1280 / 2 )
     217             :     {
     218   498286097 :         for ( i = 0; i < n2 / 2; i++ )
     219             :         {
     220   494649967 :             *window2 = *p2;
     221   494649967 :             window2++;
     222   494649967 :             p2 -= d;
     223             :         }
     224             : 
     225     3636130 :         if ( ( n == 512 / 2 ) || ( n == 320 / 2 ) )
     226      484641 :             p2--;
     227             : 
     228   498286097 :         for ( ; i < n2; i++ )
     229             :         {
     230   494649967 :             *window2 = *p2;
     231   494649967 :             window2++;
     232   494649967 :             p2 -= d;
     233             :         }
     234             :     }
     235             :     else
     236             :     {
     237      924270 :         const float *pi = window_8_16_32kHz + 370 - 1;
     238             : 
     239    65623170 :         for ( i = 0; i < n2 / 2; i += 2 )
     240             :         {
     241    64698900 :             *window2 = *p2;
     242    64698900 :             window2++;
     243    64698900 :             p2 -= d;
     244             : 
     245    64698900 :             *window2 = *pi;
     246    64698900 :             window2++;
     247    64698900 :             pi--;
     248             :         }
     249             : 
     250    65623170 :         for ( ; i < n2; i += 2 )
     251             :         {
     252    64698900 :             *window2 = *pi;
     253    64698900 :             window2++;
     254    64698900 :             pi--;
     255             : 
     256    64698900 :             *window2 = *p2;
     257    64698900 :             window2++;
     258    64698900 :             p2 -= d;
     259             :         }
     260             :     }
     261             : 
     262     4560400 :     return;
     263             : }

Generated by: LCOV version 1.14