LCOV - code coverage report
Current view: top level - lib_com - interleave_spectrum.c (source / functions) Hit Total Coverage
Test: Coverage on main enc/dec/rend @ 3b2f07138c61dcf997bbf4165d0882f794b2995f Lines: 170 198 85.9 %
Date: 2025-05-03 01:55:50 Functions: 4 4 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 "cnst.h"
      40             : #include "prot_fx.h"
      41             : #include "rom_com.h"
      42             : #include "wmc_auto.h"
      43             : #include "ivas_prot_fx.h"
      44             : 
      45             : 
      46          35 : void interleave_spectrum_fx(
      47             :     Word32 *coefs,      /* i/o: input and output coefficients   Q12  */
      48             :     const Word16 length /* i  : length of spectrum              Q0   */
      49             : )
      50             : {
      51             :     Word16 i, j, k;
      52             :     Word32 *p1, *p2, *p3, *p4;
      53             :     Word32 *p_out;
      54             :     Word32 coefs_out[L_FRAME48k];
      55          35 :     Word16 sublen[3] = { 240, 160, 80 };
      56             :     Word16 grps;
      57             :     const Word16 *bw;
      58             :     const Word16 *cnt;
      59             : 
      60          35 :     move16();
      61          35 :     move16();
      62          35 :     move16();
      63             :     /* Common inits */
      64          35 :     p1 = coefs; /*Q12*/
      65          35 :     p_out = coefs_out;
      66          35 :     IF( EQ_16( length, L_FRAME48k ) )
      67             :     {
      68           0 :         bw = intl_bw_48;   /*Q0*/
      69           0 :         cnt = intl_cnt_48; /*Q0*/
      70           0 :         grps = N_INTL_GRP_48;
      71           0 :         move16();
      72           0 :         p2 = p1 + sublen[0];
      73           0 :         p3 = p2 + sublen[0];
      74           0 :         p4 = p3 + sublen[0];
      75             :     }
      76          35 :     ELSE IF( EQ_16( length, L_SPEC32k ) )
      77             :     {
      78          35 :         bw = intl_bw_32;   /*Q0*/
      79          35 :         cnt = intl_cnt_32; /*Q0*/
      80          35 :         grps = N_INTL_GRP_32;
      81          35 :         move16();
      82          35 :         p2 = p1 + sublen[1];
      83          35 :         p3 = p2 + sublen[1];
      84          35 :         p4 = p3 + sublen[1];
      85             :     }
      86             :     ELSE /* length == L_SPEC16k */
      87             :     {
      88           0 :         bw = intl_bw_16;   /*Q0*/
      89           0 :         cnt = intl_cnt_16; /*Q0*/
      90           0 :         grps = N_INTL_GRP_16;
      91           0 :         move16();
      92           0 :         p2 = p1 + sublen[2];
      93           0 :         p3 = p2 + sublen[2];
      94           0 :         p4 = p3 + sublen[2];
      95             :     }
      96             : 
      97         105 :     FOR( i = 0; i < grps; i++ )
      98             :     {
      99         350 :         FOR( j = 0; j < cnt[i]; j++ )
     100             :         {
     101        5880 :             FOR( k = 0; k < bw[i]; k++ )
     102             :             {
     103        5600 :                 *p_out++ = *p1++; /*Q12*/
     104        5600 :                 move32();
     105             :             }
     106        5880 :             FOR( k = 0; k < bw[i]; k++ )
     107             :             {
     108        5600 :                 *p_out++ = *p2++; /*Q12*/
     109        5600 :                 move32();
     110             :             }
     111        5880 :             FOR( k = 0; k < bw[i]; k++ )
     112             :             {
     113        5600 :                 *p_out++ = *p3++; /*Q12*/
     114        5600 :                 move32();
     115             :             }
     116        5880 :             FOR( k = 0; k < bw[i]; k++ )
     117             :             {
     118        5600 :                 *p_out++ = *p4++; /*Q12*/
     119        5600 :                 move32();
     120             :             }
     121             :         }
     122             :     }
     123             : 
     124             :     /* For FB the interleaved spectrum is 800 samples */
     125          35 :     Copy32( coefs_out, coefs, (Word16) ( p_out - coefs_out ) );
     126             : 
     127          35 :     return;
     128             : }
     129             : 
     130         458 : void interleave_spectrum_ivas_fx(
     131             :     Word32 *coefs,      /* i/o: input and output coefficients   Q12  */
     132             :     const Word16 length /* i  : length of spectrum              Q0   */
     133             : )
     134             : {
     135             :     Word16 i, j, k;
     136             :     Word32 *p1, *p2, *p3, *p4;
     137             :     Word32 *p_out;
     138             :     Word32 coefs_out[L_FRAME48k];
     139         458 :     Word16 sublen[3] = { 240, 160, 80 };
     140         458 :     move16();
     141         458 :     move16();
     142         458 :     move16();
     143             :     Word16 grps;
     144             :     const Word16 *bw;
     145             :     const Word16 *cnt;
     146             : 
     147             :     /* Common inits */
     148         458 :     p1 = coefs; /*Q12*/
     149         458 :     p_out = coefs_out;
     150             : 
     151         458 :     IF( EQ_16( length, L_SPEC48k ) )
     152             :     {
     153         382 :         bw = intl_bw_48;   /*Q0*/
     154         382 :         cnt = intl_cnt_48; /*Q0*/
     155         382 :         grps = N_INTL_GRP_48;
     156         382 :         move16();
     157         382 :         p2 = p1 + sublen[0];
     158         382 :         p3 = p2 + sublen[0];
     159         382 :         p4 = p3 + sublen[0];
     160             :     }
     161          76 :     ELSE IF( EQ_16( length, L_SPEC32k ) )
     162             :     {
     163          60 :         bw = intl_bw_32;   /*Q0*/
     164          60 :         cnt = intl_cnt_32; /*Q0*/
     165          60 :         grps = N_INTL_GRP_32;
     166          60 :         move16();
     167          60 :         p2 = p1 + sublen[1];
     168          60 :         p3 = p2 + sublen[1];
     169          60 :         p4 = p3 + sublen[1];
     170             :     }
     171             :     ELSE /* length == L_SPEC16k */
     172             :     {
     173          16 :         bw = intl_bw_16;   /*Q0*/
     174          16 :         cnt = intl_cnt_16; /*Q0*/
     175          16 :         grps = N_INTL_GRP_16;
     176          16 :         move16();
     177          16 :         p2 = p1 + sublen[2];
     178          16 :         p3 = p2 + sublen[2];
     179          16 :         p4 = p3 + sublen[2];
     180             :     }
     181             : 
     182        1756 :     FOR( i = 0; i < grps; i++ )
     183             :     {
     184        5296 :         FOR( j = 0; j < cnt[i]; j++ )
     185             :         {
     186       91278 :             FOR( k = 0; k < bw[i]; k++ )
     187             :             {
     188       87280 :                 *p_out++ = *p1++; /*Q12*/
     189       87280 :                 move32();
     190             :             }
     191       91278 :             FOR( k = 0; k < bw[i]; k++ )
     192             :             {
     193       87280 :                 *p_out++ = *p2++; /*Q12*/
     194       87280 :                 move32();
     195             :             }
     196       91278 :             FOR( k = 0; k < bw[i]; k++ )
     197             :             {
     198       87280 :                 *p_out++ = *p3++; /*Q12*/
     199       87280 :                 move32();
     200             :             }
     201       91278 :             FOR( k = 0; k < bw[i]; k++ )
     202             :             {
     203       87280 :                 *p_out++ = *p4++; /*Q12*/
     204       87280 :                 move32();
     205             :             }
     206             :         }
     207             :     }
     208             : 
     209             :     /* For FB the interleaved spectrum is 800 samples */
     210         458 :     Copy32( coefs_out, coefs, (Word16) ( p_out - coefs_out ) );
     211             : 
     212         458 :     return;
     213             : }
     214             : 
     215             : 
     216         935 : void ivas_de_interleave_spectrum_fx(
     217             :     Word32 *coefs,      /* i/o: input and output coefficients   Q12 */
     218             :     const Word16 length /* i  : length of spectrum              Q0  */
     219             : )
     220             : {
     221             :     Word16 i, j, k;
     222             :     Word32 *p1, *p2, *p3, *p4;
     223             :     Word32 *p_in;
     224             :     Word32 coefs_out[L_FRAME48k];
     225         935 :     Word16 sublen[] = { 80, 160, 240, 320, 480, 720 };
     226         935 :     move16();
     227         935 :     move16();
     228         935 :     move16();
     229         935 :     move16();
     230         935 :     move16();
     231         935 :     move16();
     232             :     Word16 grps;
     233             :     Word16 l_frame;
     234             :     const Word16 *bw;
     235             :     const Word16 *cnt;
     236             : 
     237             :     /* common for all groups */
     238         935 :     p1 = coefs_out;
     239         935 :     l_frame = length;
     240         935 :     move16();
     241         935 :     IF( EQ_16( length, L_SPEC48k ) )
     242             :     {
     243         742 :         bw = intl_bw_48;   /*Q0*/
     244         742 :         cnt = intl_cnt_48; /*Q0*/
     245         742 :         grps = N_INTL_GRP_48;
     246         742 :         move16();
     247         742 :         l_frame = L_FRAME48k;
     248         742 :         move16();
     249         742 :         p2 = coefs_out + sublen[2]; /* 240, length/4 */
     250         742 :         p3 = coefs_out + sublen[4]; /* 480, 2*length/4 */
     251         742 :         p4 = coefs_out + sublen[5]; /* 720, 3*length/4 */
     252             :     }
     253         193 :     ELSE IF( EQ_16( length, L_FRAME32k ) )
     254             :     {
     255         158 :         bw = intl_bw_32;   /*Q0*/
     256         158 :         cnt = intl_cnt_32; /*Q0*/
     257         158 :         grps = N_INTL_GRP_32;
     258         158 :         move16();
     259             : 
     260         158 :         p2 = coefs_out + sublen[1]; /* 160 */
     261         158 :         p3 = coefs_out + sublen[3]; /* 320 */
     262         158 :         p4 = coefs_out + sublen[4]; /* 480 */
     263             :     }
     264             :     ELSE /* length == L_SPEC16k */
     265             :     {
     266          35 :         bw = intl_bw_16;   /*Q0*/
     267          35 :         cnt = intl_cnt_16; /*Q0*/
     268          35 :         grps = N_INTL_GRP_16;
     269          35 :         move16();
     270             : 
     271          35 :         p2 = coefs_out + sublen[0]; /* 80 */
     272          35 :         p3 = coefs_out + sublen[1]; /* 160 */
     273          35 :         p4 = coefs_out + sublen[2]; /* 240 */
     274             :     }
     275             : 
     276         935 :     set32_fx( coefs_out, 0, L_FRAME48k );
     277         935 :     p_in = coefs; /*Q12*/
     278             : 
     279        3547 :     FOR( i = 0; i < grps; i++ )
     280             :     {
     281       10729 :         FOR( j = 0; j < cnt[i]; j++ )
     282             :         {
     283      184597 :             FOR( k = 0; k < bw[i]; k++ )
     284             :             {
     285      176480 :                 *p1++ = *p_in++; /*Q12*/
     286      176480 :                 move32();
     287             :             }
     288      184597 :             FOR( k = 0; k < bw[i]; k++ )
     289             :             {
     290      176480 :                 *p2++ = *p_in++; /*Q12*/
     291      176480 :                 move32();
     292             :             }
     293      184597 :             FOR( k = 0; k < bw[i]; k++ )
     294             :             {
     295      176480 :                 *p3++ = *p_in++; /*Q12*/
     296      176480 :                 move32();
     297             :             }
     298      184597 :             FOR( k = 0; k < bw[i]; k++ )
     299             :             {
     300      176480 :                 *p4++ = *p_in++; /*Q12*/
     301      176480 :                 move32();
     302             :             }
     303             :         }
     304             :     }
     305             : 
     306         935 :     Copy32( coefs_out, coefs, l_frame );
     307             : 
     308         935 :     return;
     309             : }
     310             : 
     311          35 : void de_interleave_spectrum_fx(
     312             :     Word32 *coefs,      /* i/o: input and output coefficients   Q12 */
     313             :     const Word16 length /* i  : length of spectrum              Q0  */
     314             : )
     315             : {
     316             :     Word16 i, j, k;
     317             :     Word32 *p1, *p2, *p3, *p4;
     318             :     Word32 *p_in;
     319             :     Word32 coefs_out[L_FRAME48k];
     320          35 :     Word16 sublen[] = { 80, 160, 240, 320, 480, 720 };
     321          35 :     move16();
     322          35 :     move16();
     323          35 :     move16();
     324          35 :     move16();
     325          35 :     move16();
     326          35 :     move16();
     327             :     Word16 grps;
     328             :     Word16 l_frame;
     329             :     const Word16 *bw;
     330             :     const Word16 *cnt;
     331             : 
     332             :     /* common for all groups */
     333          35 :     p1 = coefs_out;
     334          35 :     l_frame = length;
     335          35 :     move16();
     336          35 :     IF( EQ_16( length, L_FRAME48k ) )
     337             :     {
     338           0 :         bw = intl_bw_48;   /*Q0*/
     339           0 :         cnt = intl_cnt_48; /*Q0*/
     340           0 :         grps = N_INTL_GRP_48;
     341           0 :         move16();
     342           0 :         p2 = coefs_out + sublen[2]; /* 240, length/4 */
     343           0 :         p3 = coefs_out + sublen[4]; /* 480, 2*length/4 */
     344           0 :         p4 = coefs_out + sublen[5]; /* 720, 3*length/4 */
     345             :     }
     346          35 :     ELSE IF( EQ_16( length, L_SPEC32k ) )
     347             :     {
     348          35 :         bw = intl_bw_32;   /*Q0*/
     349          35 :         cnt = intl_cnt_32; /*Q0*/
     350          35 :         grps = N_INTL_GRP_32;
     351          35 :         move16();
     352             : 
     353          35 :         p2 = coefs_out + sublen[1]; /* 160 */
     354          35 :         p3 = coefs_out + sublen[3]; /* 320 */
     355          35 :         p4 = coefs_out + sublen[4]; /* 480 */
     356             :     }
     357             :     ELSE /* length == L_SPEC16k */
     358             :     {
     359           0 :         bw = intl_bw_16;   /*Q0*/
     360           0 :         cnt = intl_cnt_16; /*Q0*/
     361           0 :         grps = N_INTL_GRP_16;
     362           0 :         move16();
     363             : 
     364           0 :         p2 = coefs_out + sublen[0]; /* 80 */
     365           0 :         p3 = coefs_out + sublen[1]; /* 160 */
     366           0 :         p4 = coefs_out + sublen[2]; /* 240 */
     367             :     }
     368             : 
     369          35 :     set32_fx( coefs_out, 0, L_FRAME48k );
     370          35 :     p_in = coefs; /*Q12*/
     371             : 
     372         105 :     FOR( i = 0; i < grps; i++ )
     373             :     {
     374         350 :         FOR( j = 0; j < cnt[i]; j++ )
     375             :         {
     376        5880 :             FOR( k = 0; k < bw[i]; k++ )
     377             :             {
     378        5600 :                 *p1++ = *p_in++; /*Q12*/
     379        5600 :                 move32();
     380             :             }
     381        5880 :             FOR( k = 0; k < bw[i]; k++ )
     382             :             {
     383        5600 :                 *p2++ = *p_in++; /*Q12*/
     384        5600 :                 move32();
     385             :             }
     386        5880 :             FOR( k = 0; k < bw[i]; k++ )
     387             :             {
     388        5600 :                 *p3++ = *p_in++; /*Q12*/
     389        5600 :                 move32();
     390             :             }
     391        5880 :             FOR( k = 0; k < bw[i]; k++ )
     392             :             {
     393        5600 :                 *p4++ = *p_in++; /*Q12*/
     394        5600 :                 move32();
     395             :             }
     396             :         }
     397             :     }
     398             : 
     399          35 :     Copy32( coefs_out, coefs, l_frame );
     400             : 
     401          35 :     return;
     402             : }

Generated by: LCOV version 1.14