LCOV - code coverage report
Current view: top level - lib_com - interleave_spectrum.c (source / functions) Hit Total Coverage
Test: Coverage on main -- short test vectors @ 6c9ddc4024a9c0e1ecb8f643f114a84a0e26ec6b Lines: 65 65 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             : #ifdef DEBUGGING
      40             : #include "debug.h"
      41             : #endif
      42             : #include "cnst.h"
      43             : #include "prot.h"
      44             : #include "rom_com.h"
      45             : #include "wmc_auto.h"
      46             : 
      47             : /*--------------------------------------------------------------------------*
      48             :  * interleave_spectrum()
      49             :  *
      50             :  * Interleave the spectrum
      51             :  *--------------------------------------------------------------------------*/
      52             : 
      53         562 : void interleave_spectrum(
      54             :     float *coefs,        /* i/o: input and output coefficients                 */
      55             :     const int16_t length /* i  : length of spectrum                            */
      56             : )
      57             : {
      58             :     int16_t i, j, k;
      59             :     float *p1, *p2, *p3, *p4;
      60             :     float *p_out;
      61             :     float coefs_out[STOP_BAND];
      62             :     int16_t sublen;
      63             :     int16_t grps;
      64             :     const int16_t *bw;
      65             :     const int16_t *cnt;
      66             :     int16_t l_frame;
      67             : 
      68         562 :     l_frame = length;
      69             : 
      70         562 :     if ( length == L_SPEC48k )
      71             :     {
      72         408 :         bw = intl_bw_48;
      73         408 :         cnt = intl_cnt_48;
      74         408 :         grps = N_INTL_GRP_48;
      75         408 :         l_frame = L_FRAME48k;
      76             :     }
      77         154 :     else if ( length == L_SPEC32k )
      78             :     {
      79         135 :         bw = intl_bw_32;
      80         135 :         cnt = intl_cnt_32;
      81         135 :         grps = N_INTL_GRP_32;
      82             :     }
      83             :     else /* length == L_SPEC16k */
      84             :     {
      85          19 :         bw = intl_bw_16;
      86          19 :         cnt = intl_cnt_16;
      87          19 :         grps = N_INTL_GRP_16;
      88             :     }
      89             : 
      90         562 :     sublen = l_frame / 4;
      91         562 :     p1 = coefs;
      92         562 :     p2 = coefs + sublen;
      93         562 :     p3 = coefs + sublen * 2;
      94         562 :     p4 = coefs + sublen * 3;
      95         562 :     p_out = coefs_out;
      96             : 
      97        2094 :     for ( i = 0; i < grps; i++ )
      98             :     {
      99        6379 :         for ( j = 0; j < cnt[i]; j++ )
     100             :         {
     101      109567 :             for ( k = 0; k < bw[i]; k++ )
     102             :             {
     103      104720 :                 *p_out++ = *p1++;
     104             :             }
     105             : 
     106      109567 :             for ( k = 0; k < bw[i]; k++ )
     107             :             {
     108      104720 :                 *p_out++ = *p2++;
     109             :             }
     110             : 
     111      109567 :             for ( k = 0; k < bw[i]; k++ )
     112             :             {
     113      104720 :                 *p_out++ = *p3++;
     114             :             }
     115             : 
     116      109567 :             for ( k = 0; k < bw[i]; k++ )
     117             :             {
     118      104720 :                 *p_out++ = *p4++;
     119             :             }
     120             :         }
     121             :     }
     122             : 
     123             :     /* For FB the interleaved spectrum is 800 samples */
     124         562 :     mvr2r( coefs_out, coefs, (int16_t) ( p_out - coefs_out ) );
     125             : 
     126         562 :     return;
     127             : }
     128             : 
     129             : 
     130             : /*--------------------------------------------------------------------------*
     131             :  * de_interleave_spectrum()
     132             :  *
     133             :  * Deinterleave the spectrum
     134             :  *--------------------------------------------------------------------------*/
     135             : 
     136        2179 : void de_interleave_spectrum(
     137             :     float *coefs,  /* i/o: input and output coefficients  */
     138             :     int16_t length /* i  : length of spectrum             */
     139             : )
     140             : {
     141             :     int16_t i, j, k;
     142             :     float *p1, *p2, *p3, *p4;
     143             :     float *p_in;
     144             :     float coefs_out[L_FRAME48k];
     145             :     int16_t sublen;
     146             :     int16_t grps;
     147             :     const int16_t *bw;
     148             :     const int16_t *cnt;
     149             :     int16_t l_frame;
     150             : 
     151        2179 :     l_frame = length;
     152             : 
     153        2179 :     if ( length == L_SPEC48k )
     154             :     {
     155        1584 :         bw = intl_bw_48;
     156        1584 :         cnt = intl_cnt_48;
     157        1584 :         grps = N_INTL_GRP_48;
     158        1584 :         l_frame = L_FRAME48k;
     159             :     }
     160         595 :     else if ( length == L_FRAME32k )
     161             :     {
     162         519 :         bw = intl_bw_32;
     163         519 :         cnt = intl_cnt_32;
     164         519 :         grps = N_INTL_GRP_32;
     165             :     }
     166             :     else /* length == L_FRAME16k */
     167             :     {
     168          76 :         bw = intl_bw_16;
     169          76 :         cnt = intl_cnt_16;
     170          76 :         grps = N_INTL_GRP_16;
     171             :     }
     172             : 
     173        2179 :     set_f( coefs_out, 0, L_FRAME48k );
     174             : 
     175        2179 :     sublen = l_frame / 4;
     176        2179 :     p1 = coefs_out;
     177        2179 :     p2 = coefs_out + sublen;
     178        2179 :     p3 = coefs_out + sublen * 2;
     179        2179 :     p4 = coefs_out + sublen * 3;
     180        2179 :     p_in = coefs;
     181             : 
     182        8121 :     for ( i = 0; i < grps; i++ )
     183             :     {
     184       24730 :         for ( j = 0; j < cnt[i]; j++ )
     185             :         {
     186      424708 :             for ( k = 0; k < bw[i]; k++ )
     187             :             {
     188      405920 :                 *p1++ = *p_in++;
     189             :             }
     190      424708 :             for ( k = 0; k < bw[i]; k++ )
     191             :             {
     192      405920 :                 *p2++ = *p_in++;
     193             :             }
     194      424708 :             for ( k = 0; k < bw[i]; k++ )
     195             :             {
     196      405920 :                 *p3++ = *p_in++;
     197             :             }
     198      424708 :             for ( k = 0; k < bw[i]; k++ )
     199             :             {
     200      405920 :                 *p4++ = *p_in++;
     201             :             }
     202             :         }
     203             :     }
     204             : 
     205        2179 :     mvr2r( coefs_out, coefs, l_frame );
     206             : 
     207        2179 :     return;
     208             : }

Generated by: LCOV version 1.14