LCOV - code coverage report
Current view: top level - lib_com - tcx_mdct_window.c (source / functions) Hit Total Coverage
Test: Coverage on main -- dec/rend @ 4c82f1d24d39d0296b18d775f18a006f4c7d024b Lines: 158 174 90.8 %
Date: 2025-05-17 01:59:02 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 <assert.h>
      38             : #include <stdint.h>
      39             : #include "options.h"
      40             : #include <math.h>
      41             : #include "cnst.h"
      42             : #include "prot_fx.h"
      43             : #include "rom_com.h"
      44             : #include "wmc_auto.h"
      45             : 
      46             : 
      47             : const PWord16 *getSineWindowTable( Word16 length );
      48             : 
      49             : 
      50      139383 : void mdct_window_sine_IVAS_updated(
      51             :     PWord16 *window,          /* Qx */
      52             :     const Word32 Fs,          /* Q0 */
      53             :     const Word16 n,           /* Q0 */
      54             :     const Word16 window_type, /* Q0 */
      55             :     const Word16 element_mode /* Q0 */
      56             : )
      57             : {
      58      139383 :     IF( element_mode == EVS_MONO )
      59             :     {
      60             :         const PWord16 *table;
      61           0 :         table = getSineWindowTable( n );
      62           0 :         FOR( Word32 i = 0; i < n / 2; i++ )
      63             :         {
      64           0 :             window[i].v.re = table[i].v.re; /* Qx */
      65           0 :             move16();
      66           0 :             window[i].v.im = table[i].v.im; /* Qx */
      67           0 :             move16();
      68             :         }
      69             :         // PMT("getSineWindowTable needs to be updated for IVAS")
      70             :     }
      71             :     ELSE
      72             :     {
      73      139383 :         const Word16 *window_table = 0;
      74      139383 :         Word16 buf_in_size = 0;
      75      139383 :         move16();
      76             :         Word16 temp[420];
      77      139383 :         set16_fx( temp, 0, 420 );
      78      139383 :         SWITCH( window_type )
      79             :         {
      80       46461 :             case FULL_OVERLAP:
      81       46461 :                 window_table = tcx_mdct_window_48_fx; /* Q15 */
      82       46461 :                 buf_in_size = 420;
      83       46461 :                 move16();
      84       46461 :                 BREAK;
      85       46461 :             case HALF_OVERLAP:
      86       46461 :                 window_table = tcx_mdct_window_half_48_fx; /* Q15 */
      87       46461 :                 buf_in_size = 180;
      88       46461 :                 BREAK;
      89       46461 :             case TRANSITION_OVERLAP:
      90             :             case MIN_OVERLAP:
      91       46461 :                 window_table = tcx_mdct_window_trans_48_fx; /* Q15 */
      92       46461 :                 buf_in_size = 60;
      93       46461 :                 move16();
      94       46461 :                 BREAK;
      95             : 
      96           0 :             default:
      97           0 :                 assert( 0 && "Unsupported window type" );
      98             :                 BREAK;
      99             :         }
     100             : 
     101      139383 :         IF( EQ_32( Fs, 48000 ) )
     102             :         {
     103       51729 :             Copy( window_table, temp, n ); /* Q15 */
     104             :         }
     105             :         ELSE
     106             :         {
     107       87654 :             lerp( window_table, temp, n, buf_in_size );
     108             :         }
     109             : 
     110    10341729 :         FOR( Word32 i = 0; i < n / 2; i++ )
     111             :         {
     112    10202346 :             window[i].v.re = temp[n - 1 - i]; /* Qx */
     113    10202346 :             move16();
     114    10202346 :             window[i].v.im = temp[i]; /* Qx */
     115    10202346 :             move16();
     116             :         }
     117             :     }
     118      139383 : }
     119             : 
     120             : ////Use mdct_window_sine_IVAS_updated for IVAS (EVS path covered as well)
     121         280 : void mdct_window_sine(
     122             :     PWord16 *window, /* Qx */
     123             :     Word16 n         /* Q0 */
     124             : )
     125             : {
     126             :     {
     127             :         const PWord16 *table;
     128         280 :         table = getSineWindowTable( n );
     129       14008 :         FOR( Word32 i = 0; i < n / 2; i++ )
     130             :         {
     131       13728 :             window[i].v.re = table[i].v.re; /* Qx */
     132       13728 :             move16();
     133       13728 :             window[i].v.im = table[i].v.im; /* Qx */
     134       13728 :             move16();
     135             :         }
     136             :         // PMT("getSineWindowTable needs to be updated for IVAS")
     137             :     }
     138         280 : }
     139             : 
     140             : 
     141       48100 : void mdct_window_aldo(
     142             :     Word16 *window1,        /* Q15 */
     143             :     PWord16 *window1_trunc, /* Q15 */
     144             :     PWord16 *window2,       /* Q15 */
     145             :     Word16 n                /* Q0 */
     146             : )
     147             : {
     148             :     Word16 i, n0, n1, n2, d, tmp;
     149             :     const Word16 *p1, *p2;
     150             : 
     151             :     /* set table pointers and decimation factor */
     152       48100 :     SWITCH( n )
     153             :     {
     154           0 :         case 320 / 2:
     155           0 :             p1 = window_48kHz_fx + 2;        /* Q15 */
     156           0 :             p2 = window_48kHz_fx + 1110 - 3; /* Q15 */
     157           0 :             d = 6;
     158           0 :             move16();
     159           0 :             BREAK;
     160        6347 :         case 512 / 2:
     161        6347 :             p1 = window_256kHz;           /* Q15 */
     162        6347 :             p2 = window_256kHz + 592 - 1; /* Q15 */
     163        6347 :             d = 2;
     164        6347 :             move16();
     165        6347 :             BREAK;
     166        7702 :         case 640 / 2:
     167        7702 :             p1 = window_48kHz_fx + 1;        /* Q15 */
     168        7702 :             p2 = window_48kHz_fx + 1110 - 2; /* Q15 */
     169        7702 :             d = 3;
     170        7702 :             move16();
     171        7702 :             BREAK;
     172        6604 :         case 1024 / 2:
     173        6604 :             p1 = window_256kHz;           /* Q15 */
     174        6604 :             p2 = window_256kHz + 592 - 1; /* Q15 */
     175        6604 :             d = 1;
     176        6604 :             move16();
     177        6604 :             BREAK;
     178       10190 :         case 1280 / 2:
     179       10190 :             p1 = window_48kHz_fx + 1;        /* Q15 */
     180       10190 :             p2 = window_48kHz_fx + 1110 - 2; /* Q15 */
     181       10190 :             d = 3;
     182       10190 :             move16();
     183       10190 :             BREAK;
     184       17257 :         case 1920 / 2:
     185       17257 :             p1 = window_48kHz_fx;            /* Q15 */
     186       17257 :             p2 = window_48kHz_fx + 1110 - 1; /* Q15 */
     187       17257 :             d = 1;
     188       17257 :             move16();
     189       17257 :             BREAK;
     190           0 :         default:
     191           0 :             assert( 0 );
     192             :             return;
     193             :     }
     194             : 
     195             :     /* set lengths */
     196       48100 :     n0 = shr( imult1616( n, 9 ), 5 );
     197       48100 :     n1 = shr( imult1616( n, 23 ), 5 ); /* left slope length */
     198       48100 :     n2 = shr( imult1616( n, 14 ), 5 ); /* right slope length */
     199             : 
     200             :     /* first part (long slope) */
     201       48100 :     IF( NE_16( n, 1280 / 2 ) )
     202             :     {
     203     6798440 :         FOR( i = 0; i < n0; i++ )
     204             :         {
     205     6760530 :             *window1 = *p1; /* Q15 */
     206     6760530 :             move16();
     207     6760530 :             window1++;
     208     6760530 :             p1 += d;
     209             :         }
     210             : 
     211       37910 :         tmp = shr( n, 1 );
     212     5296100 :         FOR( ; i < tmp; i++ )
     213             :         {
     214     5258190 :             window1_trunc->v.im = *p1; /* Q15 */
     215     5258190 :             move16();
     216     5258190 :             window1_trunc++;
     217     5258190 :             p1 += d;
     218             :         }
     219             : 
     220       37910 :         test();
     221       37910 :         if ( EQ_16( n, 512 / 2 ) || EQ_16( n, 320 / 2 ) )
     222        6347 :             p1++;
     223             : 
     224     5296100 :         FOR( ; i < n1; i++ )
     225             :         {
     226     5258190 :             window1_trunc--;
     227     5258190 :             window1_trunc->v.re = *p1; /* Q15 */
     228     5258190 :             move16();
     229     5258190 :             p1 += d;
     230             :         }
     231             :     }
     232             :     ELSE
     233             :     {
     234       10190 :         const Word16 *pi = window_8_16_32kHz_fx;
     235             : 
     236      927290 :         FOR( i = 0; i < n0; i += 2 )
     237             :         {
     238      917100 :             *window1 = *p1; /* Q15 */
     239      917100 :             move16();
     240      917100 :             window1++;
     241      917100 :             p1 += d;
     242             : 
     243      917100 :             *window1 = *pi; /* Q15 */
     244      917100 :             move16();
     245      917100 :             window1++;
     246      917100 :             pi++;
     247             :         }
     248             : 
     249       10190 :         tmp = shr( n, 1 );
     250      723490 :         FOR( ; i < tmp; i += 2 )
     251             :         {
     252      713300 :             window1_trunc->v.im = *p1; /* Q15 */
     253      713300 :             move16();
     254      713300 :             window1_trunc++;
     255      713300 :             p1 += d;
     256             : 
     257      713300 :             window1_trunc->v.im = *pi; /* Q15 */
     258      713300 :             move16();
     259      713300 :             window1_trunc++;
     260      713300 :             pi++;
     261             :         }
     262             : 
     263      723490 :         FOR( ; i < n1; i += 2 )
     264             :         {
     265      713300 :             window1_trunc--;
     266      713300 :             window1_trunc->v.re = *pi; /* Q15 */
     267      713300 :             move16();
     268      713300 :             pi++;
     269             : 
     270      713300 :             window1_trunc--;
     271      713300 :             window1_trunc->v.re = *p1; /* Q15 */
     272      713300 :             move16();
     273      713300 :             p1 += d;
     274             :         }
     275             :     }
     276             : 
     277             :     /* second part (short slope) */
     278       48100 :     IF( NE_16( n, 1280 / 2 ) )
     279             :     {
     280       37910 :         tmp = shr( n2, 1 );
     281     5296100 :         FOR( i = 0; i < tmp; i++ )
     282             :         {
     283     5258190 :             window2->v.im = *p2; /* Q15 */
     284     5258190 :             move16();
     285     5258190 :             window2++;
     286     5258190 :             p2 -= d;
     287             :         }
     288             : 
     289       37910 :         test();
     290       37910 :         if ( EQ_16( n, 512 / 2 ) || EQ_16( n, 320 / 2 ) )
     291        6347 :             p2--;
     292             : 
     293     5296100 :         FOR( ; i < n2; i++ )
     294             :         {
     295     5258190 :             window2--;
     296     5258190 :             window2->v.re = *p2; /* Q15 */
     297     5258190 :             move16();
     298     5258190 :             p2 -= d;
     299             :         }
     300             :     }
     301             :     ELSE
     302             :     {
     303       10190 :         const Word16 *pi = window_8_16_32kHz_fx + 370 - 1;
     304             : 
     305       10190 :         tmp = shr( n2, 1 );
     306      723490 :         FOR( i = 0; i < tmp; i += 2 )
     307             :         {
     308      713300 :             window2->v.im = *p2; /* Q15 */
     309      713300 :             move16();
     310      713300 :             window2++;
     311      713300 :             p2 -= d;
     312             : 
     313      713300 :             window2->v.im = *pi; /* Q15 */
     314      713300 :             move16();
     315      713300 :             window2++;
     316      713300 :             pi--;
     317             :         }
     318             : 
     319      723490 :         FOR( ; i < n2; i += 2 )
     320             :         {
     321      713300 :             window2--;
     322      713300 :             window2->v.re = *pi; /* Q15 */
     323      713300 :             move16();
     324      713300 :             pi--;
     325             : 
     326      713300 :             window2--;
     327      713300 :             window2->v.re = *p2; /* Q15 */
     328      713300 :             move16();
     329      713300 :             p2 -= d;
     330             :         }
     331             :     }
     332       48100 : }

Generated by: LCOV version 1.14