LCOV - code coverage report
Current view: top level - lib_com - tcx_mdct.c (source / functions) Hit Total Coverage
Test: Coverage on main -- short test vectors @ 6c9ddc4024a9c0e1ecb8f643f114a84a0e26ec6b Lines: 63 63 100.0 %
Date: 2025-05-23 08:37:30 Functions: 5 5 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 "cnst.h"
      41             : #include "prot.h"
      42             : #include "wmc_auto.h"
      43             : 
      44             : /*-------------------------------------------------------------------*
      45             :  * TCX_MDCT()
      46             :  *
      47             :  *
      48             :  *-------------------------------------------------------------------*/
      49             : 
      50      425828 : void TCX_MDCT(
      51             :     const float *x,
      52             :     float *y,
      53             :     const int16_t l,
      54             :     const int16_t m,
      55             :     const int16_t r,
      56             :     const int16_t element_mode )
      57             : {
      58             :     int16_t i;
      59             :     float dctInBuffer[N_MAX];
      60             : 
      61             :     /* Init */
      62    40521740 :     for ( i = 0; i < m / 2; i++ )
      63             :     {
      64    40095912 :         dctInBuffer[m / 2 + r / 2 + i] = -1.0f * x[l + m / 2 - 1 - i];
      65             :     }
      66             : 
      67    23633556 :     for ( i = 0; i < l / 2; i++ )
      68             :     {
      69    23207728 :         dctInBuffer[m / 2 + r / 2 + m / 2 + i] = x[i] - x[l - 1 - i];
      70             :     }
      71             : 
      72    40521740 :     for ( i = 0; i < m / 2; i++ )
      73             :     {
      74    40095912 :         dctInBuffer[m / 2 + r / 2 - 1 - i] = -1.0f * x[l + m / 2 + i];
      75             :     }
      76             : 
      77    26235476 :     for ( i = 0; i < r / 2; i++ )
      78             :     {
      79    25809648 :         dctInBuffer[m / 2 + r / 2 - 1 - m / 2 - i] = -1.0f * x[l + m + i] - x[l + m + r - 1 - i];
      80             :     }
      81             : 
      82      425828 :     edct( dctInBuffer, y, l / 2 + m + r / 2, element_mode );
      83             : 
      84      425828 :     v_multc( y, (float) sqrt( (float) NORM_MDCT_FACTOR / ( l / 2 + m + r / 2 ) ), y, l / 2 + m + r / 2 );
      85             : 
      86      425828 :     return;
      87             : }
      88             : 
      89             : 
      90             : /*-------------------------------------------------------------------*
      91             :  * TCX_MDST()
      92             :  *
      93             :  *
      94             :  *-------------------------------------------------------------------*/
      95             : 
      96      284866 : void TCX_MDST(
      97             :     const float *x,
      98             :     float *y,
      99             :     const int16_t l,
     100             :     const int16_t m,
     101             :     const int16_t r,
     102             :     const int16_t element_mode )
     103             : {
     104             :     int16_t i;
     105             :     float dctInBuffer[N_MAX];
     106             : 
     107             :     /* Init */
     108    68292966 :     for ( i = 0; i < m / 2; i++ )
     109             :     {
     110    68008100 :         dctInBuffer[m / 2 + r / 2 + i] = -1.0f * x[l + m / 2 - 1 - i];
     111             :     }
     112    47990286 :     for ( i = 0; i < l / 2; i++ )
     113             :     {
     114    47705420 :         dctInBuffer[m / 2 + r / 2 + m / 2 + i] = -1.0f * x[i] - x[l - 1 - i];
     115             :     }
     116    68292966 :     for ( i = 0; i < m / 2; i++ )
     117             :     {
     118    68008100 :         dctInBuffer[m / 2 + r / 2 - 1 - i] = -1.0f * x[l + m / 2 + i];
     119             :     }
     120    50564606 :     for ( i = 0; i < r / 2; i++ )
     121             :     {
     122    50279740 :         dctInBuffer[m / 2 + r / 2 - 1 - m / 2 - i] = -1.0f * x[l + m + i] + x[l + m + r - 1 - i];
     123             :     }
     124             : 
     125      284866 :     edst( dctInBuffer, y, l / 2 + m + r / 2, element_mode );
     126             : 
     127      284866 :     v_multc( y, (float) sqrt( (float) NORM_MDCT_FACTOR / ( l / 2 + m + r / 2 ) ), y, l / 2 + m + r / 2 );
     128             : 
     129      284866 :     return;
     130             : }
     131             : 
     132             : 
     133             : /*-------------------------------------------------------------------*
     134             :  * TCX_MDCT_Inverse()
     135             :  *
     136             :  *
     137             :  *-------------------------------------------------------------------*/
     138             : 
     139      424884 : void TCX_MDCT_Inverse(
     140             :     const float *x,
     141             :     float *y,
     142             :     const int16_t l,
     143             :     const int16_t m,
     144             :     const int16_t r,
     145             :     const int16_t element_mode )
     146             : {
     147             :     int16_t i;
     148      424884 :     const int16_t L2 = l >> 1, R2 = r >> 1;
     149             :     float f;
     150             : 
     151      424884 :     edct( x, y + L2, L2 + m + R2, element_mode );
     152             : 
     153    32349271 :     for ( i = 0; i < R2; i++ )
     154             :     {
     155    31924387 :         y[l + m + R2 + i] = -1.0f * y[L2 + i]; /* fold out right end of DCT */
     156             :     }
     157             : 
     158      424884 :     mvr2r( y + L2 + m + R2, y, L2 ); /* negate, fold out left end of DCT */
     159             : 
     160    62497404 :     for ( i = 0; i < ( ( L2 + m + R2 ) >> 1 ); i++ )
     161             :     {
     162    62072520 :         f = y[L2 + i];
     163    62072520 :         y[L2 + i] = -1.0f * y[l + m + R2 - 1 - i]; /* time-reverse mid of DCT */
     164    62072520 :         y[l + m + R2 - 1 - i] = -1.0f * f;
     165             :     }
     166             : 
     167      424884 :     v_multc( y, (float) sqrt( (float) ( l / 2 + m + r / 2 ) / NORM_MDCT_FACTOR ), y, l + m + r );
     168             : 
     169      424884 :     return;
     170             : }
     171             : 
     172             : 
     173             : /*-------------------------------------------------------------------*
     174             :  * TCX_MDST_Inverse()
     175             :  *
     176             :  *
     177             :  *-------------------------------------------------------------------*/
     178             : 
     179          60 : void TCX_MDST_Inverse(
     180             :     const float *x,
     181             :     float *y,
     182             :     const int16_t l,
     183             :     const int16_t m,
     184             :     const int16_t r,
     185             :     const int16_t element_mode )
     186             : {
     187             :     int16_t i;
     188          60 :     const int16_t L2 = l >> 1, R2 = r >> 1;
     189             :     float f;
     190             : 
     191          60 :     edst( x, y + L2, L2 + m + R2, element_mode );
     192             : 
     193          60 :     mvr2r( y + L2, y + l + m + R2, R2 ); /* negate, fold out right end of DST */
     194             : 
     195        2802 :     for ( i = 0; i < L2; i++ )
     196             :     {
     197        2742 :         y[i] = -1.0f * y[L2 + m + R2 + i]; /* fold out left end of DST */
     198             :     }
     199             : 
     200        4668 :     for ( i = 0; i < ( ( L2 + m + R2 ) >> 1 ); i++ )
     201             :     {
     202        4608 :         f = y[L2 + i];
     203        4608 :         y[L2 + i] = -1.0f * y[l + m + R2 - 1 - i]; /* time-reverse mid of DST */
     204        4608 :         y[l + m + R2 - 1 - i] = -1.0f * f;
     205             :     }
     206             : 
     207          60 :     v_multc( y, (float) sqrt( (float) ( l / 2 + m + r / 2 ) / NORM_MDCT_FACTOR ), y, l + m + r );
     208             : 
     209          60 :     return;
     210             : }
     211             : 
     212             : 
     213             : /*-------------------------------------------------------------------*
     214             :  * TCX_MDXT_Inverse()
     215             :  *
     216             :  *
     217             :  *-------------------------------------------------------------------*/
     218             : 
     219         192 : void TCX_MDXT_Inverse(
     220             :     const float *x,
     221             :     float *y,
     222             :     const int16_t l,
     223             :     const int16_t m,
     224             :     const int16_t r,
     225             :     const uint16_t kernel_type )
     226             : {
     227         192 :     const float signLeft = ( kernel_type >= MDCT_II ? -1.f : 1.f );
     228         192 :     const float signRight = ( kernel_type & 1 ? 1.f : -1.f );
     229             :     int16_t i;
     230         192 :     const int16_t L2 = l >> 1, R2 = r >> 1;
     231             :     float f;
     232             : 
     233         192 :     edxt( x, y + L2, L2 + m + R2, kernel_type, TRUE );
     234             : 
     235       10698 :     for ( i = 0; i < L2; i++ )
     236             :     {
     237       10506 :         y[i] = signLeft * y[L2 + m + R2 + i]; /* fold out the left end */
     238             :     }
     239             : 
     240       10818 :     for ( i = 0; i < R2; i++ )
     241             :     {
     242       10626 :         y[l + m + R2 + i] = signRight * y[L2 + i]; /* ...and right end */
     243             :     }
     244             : 
     245       14736 :     for ( i = 0; i < ( ( L2 + m + R2 ) >> 1 ); i++ )
     246             :     {
     247       14544 :         f = y[L2 + i];
     248       14544 :         y[L2 + i] = -1.0f * y[l + m + R2 - 1 - i]; /* time-reverse mid */
     249       14544 :         y[l + m + R2 - 1 - i] = -1.0f * f;
     250             :     }
     251             : 
     252         192 :     v_multc( y, (float) sqrt( (float) ( l / 2 + m + r / 2 ) / NORM_MDCT_FACTOR ), y, l + m + r );
     253             : 
     254         192 :     return;
     255             : }

Generated by: LCOV version 1.14