LCOV - code coverage report
Current view: top level - lib_com - igf_base.c (source / functions) Hit Total Coverage
Test: Coverage on main -- short test vectors @ 0064f65d29702af3856e67d2f7f4f8b9469b6049 Lines: 335 349 96.0 %
Date: 2026-01-29 08:02:53 Functions: 5 5 100.0 %

          Line data    Source code
       1             : /******************************************************************************************************
       2             : 
       3             :    (C) 2022-2026 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 "prot.h"
      44             : #include "rom_com.h"
      45             : #include "wmc_auto.h"
      46             : 
      47             : /*---------------------------------------------------------------------*
      48             :  * IGF_ApplyTransFac()
      49             :  *
      50             :  *
      51             :  *---------------------------------------------------------------------*/
      52             : 
      53             : /*! r: | multiplication factor */
      54    21079649 : int16_t IGF_ApplyTransFac(
      55             :     const int16_t val,   /* i  : Q15 | input value for multiplication, Q15                                          */
      56             :     const float transFac /* i  : Q14 | multiplicator for variable val, Q14: 1.25f=0x5000, 1.0f=0x4000, 0.5f=0x2000  */
      57             : )
      58             : {
      59    21079649 :     int16_t ret = val;
      60             : 
      61    21079649 :     if ( transFac != 1.f )
      62             :     {
      63    13846169 :         ret = (int16_t) round_f( val * transFac );
      64    13846169 :         ret += ( ret & 1 );
      65             :     }
      66             : 
      67    21079649 :     return ret;
      68             : }
      69             : 
      70             : 
      71             : /*---------------------------------------------------------------------*
      72             :  * IGF_MapBitRateToIndex()
      73             :  *
      74             :  * maps a given bitrate to the IGF_BITRATE index
      75             :  *---------------------------------------------------------------------*/
      76             : 
      77             : /*! r: bitrate index */
      78     8592436 : int16_t IGF_MapBitRateToIndex(
      79             :     const int32_t brate,        /* i  :  bitrate                    */
      80             :     const int16_t bwidth,       /* i  :  audio bandwidth            */
      81             :     const int16_t element_mode, /* i  :  element mode               */
      82             :     const int16_t rf_mode       /* i  :  flag to signal the RF mode */
      83             : )
      84             : {
      85     8592436 :     int16_t bitRateIndex = IGF_BITRATE_UNKNOWN;
      86             : 
      87             :     /* Stereo/CPE modes */
      88     8592436 :     if ( element_mode > IVAS_SCE )
      89             :     {
      90     8255288 :         switch ( bwidth )
      91             :         {
      92        1600 :             case IGF_MODE_WB:
      93        1600 :                 if ( brate <= IVAS_13k2 && rf_mode == 1 )
      94             :                 {
      95           0 :                     bitRateIndex = IGF_BITRATE_RF_WB_13200;
      96             :                 }
      97        1600 :                 else if ( brate <= ACELP_9k60 )
      98             :                 {
      99        1160 :                     bitRateIndex = IGF_BITRATE_WB_13200_CPE;
     100             :                 }
     101         440 :                 else if ( brate <= IVAS_13k2 )
     102             :                 {
     103         440 :                     bitRateIndex = IGF_BITRATE_WB_16400_CPE;
     104             :                 }
     105        1600 :                 break;
     106     2239428 :             case IGF_MODE_SWB:
     107             :                 /* DFT and TD Stereo bitrates */
     108     2239428 :                 if ( brate <= ACELP_9k60 )
     109             :                 {
     110        6542 :                     bitRateIndex = IGF_BITRATE_SWB_13200_CPE;
     111             :                 }
     112     2232886 :                 else if ( brate <= IVAS_13k2 )
     113             :                 {
     114        4736 :                     if ( rf_mode == 1 )
     115             :                     {
     116           0 :                         bitRateIndex = IGF_BITRATE_RF_SWB_13200;
     117             :                     }
     118             :                     else
     119             :                     {
     120        4736 :                         bitRateIndex = IGF_BITRATE_SWB_16400_CPE;
     121             :                     }
     122             :                 }
     123     2228150 :                 else if ( brate <= IVAS_16k4 )
     124             :                 {
     125       13688 :                     bitRateIndex = IGF_BITRATE_SWB_24400_CPE;
     126             :                 }
     127     2214462 :                 else if ( brate <= IVAS_24k4 )
     128             :                 {
     129        3776 :                     bitRateIndex = IGF_BITRATE_SWB_32000_CPE;
     130             :                 }
     131     2210686 :                 else if ( brate <= IVAS_32k )
     132             :                 {
     133           0 :                     bitRateIndex = IGF_BITRATE_SWB_32000;
     134             :                 }
     135             :                 /* MDCT Stereo bitrates */
     136     2210686 :                 else if ( brate <= IVAS_48k )
     137             :                 {
     138      715818 :                     bitRateIndex = IGF_BITRATE_SWB_48000_CPE;
     139             :                 }
     140     1494868 :                 else if ( brate <= IVAS_64k )
     141             :                 {
     142      620238 :                     bitRateIndex = IGF_BITRATE_SWB_64000_CPE;
     143             :                 }
     144      874630 :                 else if ( brate <= IVAS_80k )
     145             :                 {
     146      368152 :                     bitRateIndex = IGF_BITRATE_SWB_80000_CPE;
     147             :                 }
     148      506478 :                 else if ( brate <= IVAS_96k )
     149             :                 {
     150      506478 :                     bitRateIndex = IGF_BITRATE_SWB_96000_CPE;
     151             :                 }
     152     2239428 :                 break;
     153     6014260 :             case IGF_MODE_FB:
     154             :                 /* DFT and TD Stereo bitrates */
     155     6014260 :                 if ( brate <= IVAS_16k4 )
     156             :                 {
     157        7602 :                     bitRateIndex = IGF_BITRATE_FB_24400_CPE;
     158             :                 }
     159     6006658 :                 else if ( brate <= IVAS_24k4 )
     160             :                 {
     161        6370 :                     bitRateIndex = IGF_BITRATE_FB_32000_CPE;
     162             :                 }
     163     6000288 :                 else if ( brate <= IVAS_32k )
     164             :                 {
     165           0 :                     bitRateIndex = IGF_BITRATE_FB_32000;
     166             :                 }
     167             :                 /* MDCT Stereo bitrates */
     168     6000288 :                 else if ( brate <= IVAS_48k )
     169             :                 {
     170      840650 :                     bitRateIndex = IGF_BITRATE_FB_48000_CPE;
     171             :                 }
     172     5159638 :                 else if ( brate <= IVAS_64k )
     173             :                 {
     174     1446004 :                     bitRateIndex = IGF_BITRATE_FB_64000_CPE;
     175             :                 }
     176     3713634 :                 else if ( brate <= IVAS_80k )
     177             :                 {
     178      741139 :                     bitRateIndex = IGF_BITRATE_FB_80000_CPE;
     179             :                 }
     180     2972495 :                 else if ( brate <= IVAS_96k )
     181             :                 {
     182      768569 :                     bitRateIndex = IGF_BITRATE_FB_96000_CPE;
     183             :                 }
     184     2203926 :                 else if ( brate <= IVAS_128k )
     185             :                 {
     186     2203926 :                     bitRateIndex = IGF_BITRATE_FB_128000_CPE;
     187             :                 }
     188     6014260 :                 break;
     189             :         }
     190     8255288 :     }
     191             :     /* SCE modes: use tunings done for DFT stereo bitrates also for according SCE bitrates, otherwise same config as mono modes */
     192      337148 :     else if ( element_mode == IVAS_SCE )
     193             :     {
     194      334450 :         switch ( bwidth )
     195             :         {
     196       10422 :             case IGF_MODE_WB:
     197       10422 :                 if ( brate <= IVAS_13k2 && rf_mode == 1 )
     198             :                 {
     199           0 :                     bitRateIndex = IGF_BITRATE_RF_WB_13200;
     200             :                 }
     201       10422 :                 else if ( brate <= ACELP_9k60 ) /* bitrates 8000 and 9600 */
     202             :                 {
     203       10422 :                     bitRateIndex = IGF_BITRATE_WB_9600;
     204             :                 }
     205       10422 :                 break;
     206      141306 :             case IGF_MODE_SWB:
     207      141306 :                 if ( brate <= ACELP_9k60 )
     208             :                 {
     209       38968 :                     bitRateIndex = IGF_BITRATE_SWB_13200_CPE;
     210             :                 }
     211      102338 :                 else if ( brate <= IVAS_13k2 )
     212             :                 {
     213       41080 :                     if ( rf_mode == 1 )
     214             :                     {
     215           0 :                         bitRateIndex = IGF_BITRATE_RF_SWB_13200;
     216             :                     }
     217             :                     else
     218             :                     {
     219       41080 :                         bitRateIndex = IGF_BITRATE_SWB_16400_CPE;
     220             :                     }
     221             :                 }
     222       61258 :                 else if ( brate <= IVAS_16k4 )
     223             :                 {
     224       16528 :                     bitRateIndex = IGF_BITRATE_SWB_24400_CPE;
     225             :                 }
     226       44730 :                 else if ( brate <= IVAS_24k4 )
     227             :                 {
     228       14900 :                     bitRateIndex = IGF_BITRATE_SWB_32000_CPE;
     229             :                 }
     230       29830 :                 else if ( brate <= IVAS_32k )
     231             :                 {
     232       12418 :                     bitRateIndex = IGF_BITRATE_SWB_32000;
     233             :                 }
     234       17412 :                 else if ( brate <= IVAS_48k )
     235             :                 {
     236       10290 :                     bitRateIndex = IGF_BITRATE_SWB_48000;
     237             :                 }
     238        7122 :                 else if ( brate <= IVAS_64k )
     239             :                 {
     240        7122 :                     bitRateIndex = IGF_BITRATE_SWB_64000;
     241             :                 }
     242      141306 :                 break;
     243      182722 :             case IGF_MODE_FB:
     244      182722 :                 if ( brate <= IVAS_16k4 )
     245             :                 {
     246       28270 :                     bitRateIndex = IGF_BITRATE_FB_24400_CPE;
     247             :                 }
     248      154452 :                 else if ( brate <= IVAS_24k4 )
     249             :                 {
     250       43854 :                     bitRateIndex = IGF_BITRATE_FB_32000_CPE;
     251             :                 }
     252      110598 :                 else if ( brate <= IVAS_32k )
     253             :                 {
     254       44238 :                     bitRateIndex = IGF_BITRATE_FB_32000;
     255             :                 }
     256       66360 :                 else if ( brate <= IVAS_48k )
     257             :                 {
     258       28616 :                     bitRateIndex = IGF_BITRATE_FB_48000;
     259             :                 }
     260       37744 :                 else if ( brate <= IVAS_64k )
     261             :                 {
     262       17568 :                     bitRateIndex = IGF_BITRATE_FB_64000;
     263             :                 }
     264       20176 :                 else if ( brate <= IVAS_96k )
     265             :                 {
     266       13246 :                     bitRateIndex = IGF_BITRATE_FB_96000;
     267             :                 }
     268        6930 :                 else if ( brate <= IVAS_128k )
     269             :                 {
     270        6930 :                     bitRateIndex = IGF_BITRATE_FB_128000;
     271             :                 }
     272      182722 :                 break;
     273             :         }
     274      334450 :     }
     275             :     /* EVS mono */
     276             :     else
     277             :     {
     278        2698 :         switch ( bwidth )
     279             :         {
     280         234 :             case IGF_MODE_WB:
     281         234 :                 if ( brate <= ACELP_13k20 && rf_mode == 1 )
     282             :                 {
     283          96 :                     bitRateIndex = IGF_BITRATE_RF_WB_13200;
     284             :                 }
     285         138 :                 else if ( brate <= ACELP_9k60 ) /* bitrates 8000 and 9600 */
     286             :                 {
     287         138 :                     bitRateIndex = IGF_BITRATE_WB_9600;
     288             :                 }
     289         234 :                 break;
     290        1726 :             case IGF_MODE_SWB:
     291        1726 :                 if ( brate <= ACELP_9k60 )
     292             :                 {
     293          78 :                     bitRateIndex = IGF_BITRATE_SWB_9600;
     294             :                 }
     295        1648 :                 else if ( brate <= ACELP_13k20 )
     296             :                 {
     297         408 :                     if ( rf_mode == 1 )
     298             :                     {
     299          96 :                         bitRateIndex = IGF_BITRATE_RF_SWB_13200;
     300             :                     }
     301             :                     else
     302             :                     {
     303         312 :                         bitRateIndex = IGF_BITRATE_SWB_13200;
     304             :                     }
     305             :                 }
     306        1240 :                 else if ( brate <= ACELP_16k40 )
     307             :                 {
     308         102 :                     bitRateIndex = IGF_BITRATE_SWB_16400;
     309             :                 }
     310        1138 :                 else if ( brate <= ACELP_24k40 )
     311             :                 {
     312        1012 :                     bitRateIndex = IGF_BITRATE_SWB_24400;
     313             :                 }
     314         126 :                 else if ( brate <= ACELP_32k )
     315             :                 {
     316           0 :                     bitRateIndex = IGF_BITRATE_SWB_32000;
     317             :                 }
     318         126 :                 else if ( brate <= ACELP_48k )
     319             :                 {
     320         126 :                     bitRateIndex = IGF_BITRATE_SWB_48000;
     321             :                 }
     322           0 :                 else if ( brate <= ACELP_64k )
     323             :                 {
     324           0 :                     bitRateIndex = IGF_BITRATE_SWB_64000;
     325             :                 }
     326        1726 :                 break;
     327         738 :             case IGF_MODE_FB:
     328         738 :                 if ( brate <= ACELP_16k40 )
     329             :                 {
     330         102 :                     bitRateIndex = IGF_BITRATE_FB_16400;
     331             :                 }
     332         636 :                 else if ( brate <= ACELP_24k40 )
     333             :                 {
     334         330 :                     bitRateIndex = IGF_BITRATE_FB_24400;
     335             :                 }
     336         306 :                 else if ( brate <= ACELP_32k )
     337             :                 {
     338           0 :                     bitRateIndex = IGF_BITRATE_FB_32000;
     339             :                 }
     340         306 :                 else if ( brate <= ACELP_48k )
     341             :                 {
     342          90 :                     bitRateIndex = IGF_BITRATE_FB_48000;
     343             :                 }
     344         216 :                 else if ( brate <= ACELP_64k )
     345             :                 {
     346           0 :                     bitRateIndex = IGF_BITRATE_FB_64000;
     347             :                 }
     348         216 :                 else if ( brate <= HQ_96k )
     349             :                 {
     350         102 :                     bitRateIndex = IGF_BITRATE_FB_96000;
     351             :                 }
     352         114 :                 else if ( brate <= HQ_128k )
     353             :                 {
     354         114 :                     bitRateIndex = IGF_BITRATE_FB_128000;
     355             :                 }
     356         738 :                 break;
     357             :         }
     358     8592436 :     }
     359             : 
     360     8592436 :     return bitRateIndex;
     361             : }
     362             : 
     363             : 
     364             : /*---------------------------------------------------------------------*
     365             :  * IGF_gridSetUp()
     366             :  *
     367             :  * IGF grid setup
     368             :  *---------------------------------------------------------------------*/
     369             : 
     370     1061031 : static void IGF_gridSetUp(
     371             :     H_IGF_GRID hGrid,         /* o  : IGF grid handle                                                    */
     372             :     int16_t bitRateIndex,     /* i  : IGF bitrate index                                                  */
     373             :     const int32_t sampleRate, /* i  : sample rate                                                        */
     374             :     int16_t frameLength,      /* i  : frame length                                                       */
     375             :     const float transFac,     /* i  : transFac                                                           */
     376             :     const int16_t igfMinFq    /* i  : IGF minimum frequency indicating lower start frequency for copy up */
     377             : )
     378             : {
     379             :     int16_t t, k;
     380             :     int16_t sfb;
     381             :     int16_t swb_offset_len;
     382             :     const int16_t *swb_offset;
     383             :     float bandwidth;
     384             :     const int16_t *igf_tile_offset;
     385             : 
     386             :     /* inits */
     387     1061031 :     swb_offset = NULL;
     388     1061031 :     swb_offset_len = 0;
     389     1061031 :     if ( transFac == 0.5f && bitRateIndex == IGF_BITRATE_SWB_48000_CPE )
     390             :     {
     391       10108 :         bitRateIndex = IGF_BITRATE_SWB_48000_CPE_TCX10;
     392             :     }
     393     1050923 :     else if ( transFac == 0.5f && bitRateIndex == IGF_BITRATE_FB_48000_CPE )
     394             :     {
     395       23412 :         bitRateIndex = IGF_BITRATE_FB_48000_CPE_TCX10;
     396             :     }
     397             : 
     398     1061031 :     if ( bitRateIndex != IGF_BITRATE_UNKNOWN )
     399             :     {
     400     1061031 :         swb_offset = &swb_offset_LB_new[bitRateIndex][1];
     401     1061031 :         swb_offset_len = swb_offset_LB_new[bitRateIndex][0];
     402     1061031 :         mvr2r( &igf_whitening_TH[bitRateIndex][0][0], &hGrid->whiteningThreshold[0][0], IGF_MAX_TILES * 2 );
     403             :     }
     404             :     else
     405             :     {
     406           0 :         assert( 0 );
     407             :     }
     408             : 
     409     8590263 :     for ( sfb = 0; sfb < swb_offset_len; sfb++ )
     410             :     {
     411     7529232 :         hGrid->swb_offset[sfb] = IGF_ApplyTransFac( swb_offset[sfb], transFac );
     412             :     }
     413    17935512 :     for ( sfb = swb_offset_len; sfb < IGF_MAX_SFB; sfb++ )
     414             :     {
     415    16874481 :         hGrid->swb_offset[sfb] = 0;
     416             :     }
     417             : 
     418     1061031 :     hGrid->infoIsRefined = 0;
     419     1061031 :     frameLength = IGF_ApplyTransFac( frameLength, transFac );
     420     1061031 :     bandwidth = (float) sampleRate / 2.0f / (float) frameLength;
     421     1061031 :     hGrid->swb_offset_len = swb_offset_len;
     422     1061031 :     hGrid->startSfb = 0;
     423     1061031 :     hGrid->stopSfb = hGrid->swb_offset_len - 1;
     424     1061031 :     hGrid->startLine = hGrid->swb_offset[hGrid->startSfb];
     425     1061031 :     hGrid->stopLine = hGrid->swb_offset[hGrid->stopSfb];
     426     1061031 :     hGrid->startFrequency = (int16_t) round_f( bandwidth * hGrid->startLine );
     427     1061031 :     hGrid->stopFrequency = (int16_t) round_f( bandwidth * hGrid->stopLine );
     428     1061031 :     hGrid->minSrcSubband = (int16_t) round_f( ( igfMinFq * ( frameLength ) ) / ( sampleRate >> 1 ) );
     429     1061031 :     hGrid->minSrcSubband += hGrid->minSrcSubband % 2;
     430     1061031 :     hGrid->minSrcFrequency = (int16_t) round_f( bandwidth * hGrid->minSrcSubband );
     431     1061031 :     hGrid->infoGranuleLen = frameLength;
     432     1061031 :     hGrid->sfbWrap[0] = 0;
     433     1061031 :     hGrid->tile[0] = hGrid->startLine;
     434             : 
     435     1061031 :     igf_tile_offset = &igf_tile_offset_table[bitRateIndex][1];
     436     1061031 :     hGrid->nTiles = igf_tile_offset_table[bitRateIndex][0];
     437     1061031 :     hGrid->tile[0] = hGrid->startLine;
     438     1061031 :     hGrid->sfbWrap[0] = 0;
     439     5665335 :     for ( k = 0; k < hGrid->nTiles; k++ )
     440             :     {
     441     4604304 :         hGrid->sfbWrap[k + 1] = igf_tile_offset[2 * k];
     442     4604304 :         hGrid->sbWrap[k] = hGrid->minSrcSubband + IGF_ApplyTransFac( igf_tile_offset[2 * k + 1], transFac );
     443     4604304 :         hGrid->tile[k + 1] = hGrid->swb_offset[igf_tile_offset[2 * k]];
     444             :     }
     445     6081342 :     for ( t = hGrid->nTiles + 1; t < IGF_MAX_TILES; t++ )
     446             :     {
     447     5020311 :         hGrid->tile[t] = 0;
     448     5020311 :         hGrid->sbWrap[t - 1] = 0;
     449     5020311 :         hGrid->sfbWrap[t] = 0;
     450             :     }
     451             : 
     452             :     /* adapt level envelope: */
     453     1061031 :     switch ( bitRateIndex )
     454             :     {
     455       18384 :         case IGF_BITRATE_RF_WB_13200:
     456             :         case IGF_BITRATE_WB_9600:
     457             :         case IGF_BITRATE_WB_13200_CPE:
     458             :         case IGF_BITRATE_WB_16400_CPE:
     459       18384 :             hGrid->gFactor = 0.800f;
     460       18384 :             hGrid->fFactor = 0.70f;
     461       18384 :             hGrid->lFactor = 0.60f;
     462       18384 :             break;
     463      168630 :         case IGF_BITRATE_SWB_13200:
     464             :         case IGF_BITRATE_SWB_16400_CPE:
     465             :         case IGF_BITRATE_FB_16400:
     466             :         case IGF_BITRATE_SWB_16400:
     467             :         case IGF_BITRATE_FB_24400_CPE:
     468             :         case IGF_BITRATE_SWB_24400_CPE:
     469      168630 :             hGrid->gFactor = 0.930f;
     470      168630 :             hGrid->fFactor = 0.20f;
     471      168630 :             hGrid->lFactor = 0.85f;
     472      168630 :             break;
     473      252320 :         case IGF_BITRATE_FB_24400:
     474             :         case IGF_BITRATE_SWB_24400:
     475             :         case IGF_BITRATE_FB_32000_CPE:
     476             :         case IGF_BITRATE_SWB_32000_CPE:
     477             :         case IGF_BITRATE_FB_32000:
     478             :         case IGF_BITRATE_SWB_32000:
     479             :         case IGF_BITRATE_SWB_48000_CPE:
     480             :         case IGF_BITRATE_SWB_64000_CPE:
     481      252320 :             hGrid->gFactor = 0.965f;
     482      252320 :             hGrid->fFactor = 0.20f;
     483      252320 :             hGrid->lFactor = 0.85f;
     484      252320 :             break;
     485      142617 :         case IGF_BITRATE_FB_48000:
     486             :         case IGF_BITRATE_SWB_48000:
     487             :         case IGF_BITRATE_FB_64000:
     488             :         case IGF_BITRATE_SWB_64000:
     489             :         case IGF_BITRATE_SWB_80000_CPE:
     490             :         case IGF_BITRATE_SWB_96000_CPE:
     491      142617 :             hGrid->gFactor = 1.000f;
     492      142617 :             hGrid->fFactor = 0.20f;
     493      142617 :             hGrid->lFactor = 1.000f;
     494      142617 :             break;
     495      479080 :         case IGF_BITRATE_SWB_9600:
     496             :         case IGF_BITRATE_SWB_13200_CPE:
     497             :         case IGF_BITRATE_RF_SWB_13200:
     498             :         default:
     499      479080 :             hGrid->gFactor = 1.000f;
     500      479080 :             hGrid->fFactor = 0.00f;
     501      479080 :             hGrid->lFactor = 1.000f;
     502             :     }
     503             : 
     504     6081342 :     for ( t = hGrid->nTiles + 1; t < IGF_MAX_TILES; t++ )
     505             :     {
     506     5020311 :         hGrid->tile[t] = 0;
     507     5020311 :         hGrid->sbWrap[t - 1] = 0;
     508     5020311 :         hGrid->sfbWrap[t] = 0;
     509             :     }
     510             : 
     511     1061031 :     return;
     512             : }
     513             : 
     514             : 
     515             : /*---------------------------------------------------------------------*
     516             :  * IGFCommonFuncsIGFConfiguration()
     517             :  *
     518             :  * changes the IGF configuration
     519             :  *---------------------------------------------------------------------*/
     520             : 
     521             : /*! r: error value: 0 -> error, 1 -> ok */
     522      353677 : int16_t IGFCommonFuncsIGFConfiguration(
     523             :     const int32_t total_brate,  /* i  : bitrate in bs e.g. 9600 for 9.6kbs  */
     524             :     const int16_t bwidth,       /* i  : audio bandwidth                     */
     525             :     const int16_t element_mode, /* i  : element mode                        */
     526             :     H_IGF_INFO hIGFInfo,        /* o  : IGF info handle                     */
     527             :     const int16_t rf_mode       /* i  : flag to signal the RF mode          */
     528             : )
     529             : {
     530             :     H_IGF_GRID hGrid;
     531             :     int16_t retValue;
     532             :     int32_t sampleRate;
     533             :     int16_t frameLength;
     534             :     int16_t igfMinFq;
     535             :     int16_t maxHopsize;
     536             : 
     537      353677 :     retValue = 0; /* bitrate index is unknown -> error! */
     538             : 
     539             :     /* interface call for reading in settings */
     540      353677 :     hIGFInfo->bitRateIndex = IGF_MapBitRateToIndex( total_brate, bwidth, element_mode, rf_mode );
     541             : 
     542      353677 :     if ( hIGFInfo->bitRateIndex != IGF_BITRATE_UNKNOWN )
     543             :     {
     544      353677 :         retValue = 1; /* no error */
     545             : 
     546             :         /* mapping to local values */
     547      353677 :         sampleRate = igfMode[hIGFInfo->bitRateIndex].sampleRate;
     548      353677 :         frameLength = igfMode[hIGFInfo->bitRateIndex].frameLength;
     549      353677 :         igfMinFq = igfMode[hIGFInfo->bitRateIndex].igfMinFq;
     550      353677 :         maxHopsize = igfMode[hIGFInfo->bitRateIndex].maxHopsize;
     551             : 
     552             :         /* basic information */
     553      353677 :         hIGFInfo->sampleRate = sampleRate;
     554      353677 :         hIGFInfo->frameLength = frameLength;
     555      353677 :         hIGFInfo->maxHopsize = maxHopsize;
     556      353677 :         hIGFInfo->nfSeedBuf[0] = 0;
     557      353677 :         hIGFInfo->nfSeedBuf[1] = 0;
     558      353677 :         hIGFInfo->nfSeed = &hIGFInfo->nfSeedBuf[0];
     559             : 
     560             :         /* set up regular IGF grid for TCX 20  (transfac = 1.f) */
     561      353677 :         hGrid = &hIGFInfo->grid[IGF_GRID_LB_NORM];
     562      353677 :         IGF_gridSetUp( hGrid, hIGFInfo->bitRateIndex, sampleRate, frameLength, 1.00f, igfMinFq );
     563             : 
     564             :         /* set up IGF grid for CELP->TCX 20 transitions (transfac = 1.25) */
     565      353677 :         hGrid = &hIGFInfo->grid[IGF_GRID_LB_TRAN];
     566      353677 :         IGF_gridSetUp( hGrid, hIGFInfo->bitRateIndex, sampleRate, frameLength, 1.25f, igfMinFq );
     567             : 
     568             :         /* set up IGF grid for TCX 10 (transfac = 0.5) */
     569      353677 :         hGrid = &hIGFInfo->grid[IGF_GRID_LB_SHORT];
     570      353677 :         IGF_gridSetUp( hGrid, hIGFInfo->bitRateIndex, sampleRate, frameLength, 0.50f, igfMinFq );
     571             :     }
     572             : 
     573      353677 :     return retValue;
     574             : }
     575             : 
     576             : 
     577             : /*---------------------------------------------------------------------*
     578             :  * IGFCommonFuncsIGFGetCFTables()
     579             :  *
     580             :  * selects cumulative frequency tables and offsets for the IGF SCF arithmetic coder
     581             :  *---------------------------------------------------------------------*/
     582             : 
     583             : /*! r: error value: 0 -> error, 1 -> ok */
     584      353677 : int16_t IGFCommonFuncsIGFGetCFTables(
     585             :     const int32_t total_brate,   /* i  : bitrate in bs e.g. 9600 for 9.6kbs  */
     586             :     const int16_t bwidth,        /* i  : audio bandwidth                     */
     587             :     const int16_t element_mode,  /* i  : element mode                        */
     588             :     const int16_t rf_mode,       /* i  : flag to signal the RF mode          */
     589             :     const uint16_t **cf_se00,    /* o  : CF table for t == 0 and f == 0      */
     590             :     const uint16_t **cf_se01,    /* o  : CF table for t == 0 and f == 1      */
     591             :     int16_t *cf_off_se01,        /* o  : offset for CF table above           */
     592             :     const uint16_t **cf_se02,    /* o  : CF tables for t == 0 and f >= 2     */
     593             :     const int16_t **cf_off_se02, /* o  : offsets for CF tables above         */
     594             :     const uint16_t **cf_se10,    /* o  : CF table for t == 1 and f == 0      */
     595             :     int16_t *cf_off_se10,        /* o  : offset for CF table above           */
     596             :     const uint16_t **cf_se11,    /* o  : CF tables for t == 1 and f >= 1     */
     597             :     const int16_t **cf_off_se11  /* o  : offsets for CF tables above         */
     598             : )
     599             : {
     600             :     int16_t retValue;
     601             :     int16_t bitRateIndex;
     602             : 
     603      353677 :     retValue = 0; /* bitrate index is unknown -> error! */
     604             : 
     605      353677 :     bitRateIndex = IGF_MapBitRateToIndex( total_brate, bwidth, element_mode, rf_mode );
     606             : 
     607      353677 :     if ( bitRateIndex != IGF_BITRATE_UNKNOWN )
     608             :     {
     609      353677 :         retValue = 1; /* no error */
     610             : 
     611      353677 :         switch ( bitRateIndex )
     612             :         {
     613         580 :             case IGF_BITRATE_WB_13200_CPE:
     614         580 :                 bitRateIndex = IGF_BITRATE_WB_9600;
     615         580 :                 break;
     616         220 :             case IGF_BITRATE_WB_16400_CPE:
     617         220 :                 bitRateIndex = IGF_BITRATE_WB_9600;
     618         220 :                 break;
     619       22755 :             case IGF_BITRATE_SWB_13200_CPE:
     620       22755 :                 bitRateIndex = IGF_BITRATE_SWB_9600;
     621       22755 :                 break;
     622       22908 :             case IGF_BITRATE_SWB_16400_CPE:
     623       22908 :                 bitRateIndex = IGF_BITRATE_SWB_13200;
     624       22908 :                 break;
     625       15108 :             case IGF_BITRATE_SWB_24400_CPE:
     626       15108 :                 bitRateIndex = IGF_BITRATE_SWB_16400;
     627       15108 :                 break;
     628       17936 :             case IGF_BITRATE_FB_24400_CPE:
     629       17936 :                 bitRateIndex = IGF_BITRATE_FB_16400;
     630       17936 :                 break;
     631        9338 :             case IGF_BITRATE_SWB_32000_CPE:
     632        9338 :                 bitRateIndex = IGF_BITRATE_SWB_24400;
     633        9338 :                 break;
     634       25112 :             case IGF_BITRATE_FB_32000_CPE:
     635       25112 :                 bitRateIndex = IGF_BITRATE_FB_24400;
     636       25112 :                 break;
     637       57936 :             case IGF_BITRATE_FB_48000_CPE:
     638             :             case IGF_BITRATE_FB_64000_CPE:
     639       57936 :                 bitRateIndex = IGF_BITRATE_FB_32000;
     640       57936 :                 break;
     641             :         }
     642             : 
     643      353677 :         switch ( bitRateIndex )
     644             :         {
     645       92015 :             case IGF_BITRATE_WB_9600:
     646             :             case IGF_BITRATE_RF_WB_13200:
     647             :             case IGF_BITRATE_SWB_9600:
     648             :             case IGF_BITRATE_SWB_13200:
     649             :             case IGF_BITRATE_RF_SWB_13200:
     650             :             case IGF_BITRATE_SWB_16400:
     651             :             case IGF_BITRATE_SWB_24400:
     652             :             case IGF_BITRATE_SWB_32000:
     653             :             case IGF_BITRATE_SWB_48000:
     654             :             case IGF_BITRATE_SWB_64000:
     655       92015 :                 *cf_se00 = cf_se00_tab;
     656       92015 :                 *cf_se01 = cf_se01_tab[bitRateIndex];
     657       92015 :                 *cf_off_se01 = cf_off_se01_tab[bitRateIndex];
     658       92015 :                 *cf_se02 = &cf_se02_tab[bitRateIndex][0][0];
     659       92015 :                 *cf_off_se02 = &cf_off_se02_tab[bitRateIndex][0];
     660       92015 :                 *cf_se10 = &cf_se10_tab[0];
     661       92015 :                 *cf_off_se10 = cf_off_se10_tab;
     662       92015 :                 *cf_se11 = &cf_se11_tab[0][0][0];
     663       92015 :                 *cf_off_se11 = &cf_off_se11_tab[0][0];
     664       92015 :                 break;
     665      123319 :             case IGF_BITRATE_FB_16400:
     666             :             case IGF_BITRATE_FB_24400:
     667             :             case IGF_BITRATE_FB_32000:
     668      123319 :                 bitRateIndex = bitRateIndex - IGF_BITRATE_FB_16400 + IGF_BITRATE_SWB_16400;
     669      123319 :                 *cf_se00 = cf_se00_tab;
     670      123319 :                 *cf_se01 = cf_se01_tab[bitRateIndex];
     671      123319 :                 *cf_off_se01 = cf_off_se01_tab[bitRateIndex];
     672      123319 :                 *cf_se02 = &cf_se02_tab[bitRateIndex][0][0];
     673      123319 :                 *cf_off_se02 = &cf_off_se02_tab[bitRateIndex][0];
     674      123319 :                 *cf_se10 = &cf_se10_tab[0];
     675      123319 :                 *cf_off_se10 = cf_off_se10_tab;
     676      123319 :                 *cf_se11 = &cf_se11_tab[0][0][0];
     677      123319 :                 *cf_off_se11 = &cf_off_se11_tab[0][0];
     678      123319 :                 break;
     679       23137 :             case IGF_BITRATE_FB_48000:
     680             :             case IGF_BITRATE_FB_64000:
     681       23137 :                 bitRateIndex = bitRateIndex - IGF_BITRATE_FB_48000 + IGF_BITRATE_SWB_48000;
     682       23137 :                 *cf_se00 = cf_se00_tab;
     683       23137 :                 *cf_se01 = cf_se01_tab[bitRateIndex];
     684       23137 :                 *cf_off_se01 = cf_off_se01_tab[bitRateIndex];
     685       23137 :                 *cf_se02 = &cf_se02_tab[bitRateIndex][0][0];
     686       23137 :                 *cf_off_se02 = &cf_off_se02_tab[bitRateIndex][0];
     687       23137 :                 *cf_se10 = &cf_se10_tab[0];
     688       23137 :                 *cf_off_se10 = cf_off_se10_tab;
     689       23137 :                 *cf_se11 = &cf_se11_tab[0][0][0];
     690       23137 :                 *cf_off_se11 = &cf_off_se11_tab[0][0];
     691       23137 :                 break;
     692       75546 :             case IGF_BITRATE_FB_96000:
     693             :             case IGF_BITRATE_FB_128000:
     694             :             case IGF_BITRATE_FB_80000_CPE:
     695             :             case IGF_BITRATE_FB_96000_CPE:
     696             :             case IGF_BITRATE_FB_128000_CPE:
     697       75546 :                 bitRateIndex = IGF_BITRATE_SWB_48000;
     698       75546 :                 *cf_se00 = cf_se00_tab;
     699       75546 :                 *cf_se01 = cf_se01_tab[bitRateIndex];
     700       75546 :                 *cf_off_se01 = cf_off_se01_tab[bitRateIndex];
     701       75546 :                 *cf_se02 = &cf_se02_tab[bitRateIndex][0][0];
     702       75546 :                 *cf_off_se02 = &cf_off_se02_tab[bitRateIndex][0];
     703       75546 :                 *cf_se10 = &cf_se10_tab[0];
     704       75546 :                 *cf_off_se10 = cf_off_se10_tab;
     705       75546 :                 *cf_se11 = &cf_se11_tab[0][0][0];
     706       75546 :                 *cf_off_se11 = &cf_off_se11_tab[0][0];
     707       75546 :                 break;
     708       10108 :             case IGF_BITRATE_SWB_48000_CPE:
     709       10108 :                 bitRateIndex = IGF_BITRATE_SWB_16400;
     710       10108 :                 *cf_se00 = cf_se00_tab;
     711       10108 :                 *cf_se01 = cf_se01_tab[bitRateIndex];
     712       10108 :                 *cf_off_se01 = cf_off_se01_tab[bitRateIndex];
     713       10108 :                 *cf_se02 = &cf_se02_tab[bitRateIndex][0][0];
     714       10108 :                 *cf_off_se02 = &cf_off_se02_tab[bitRateIndex][0];
     715       10108 :                 *cf_se10 = &cf_se10_tab[0];
     716       10108 :                 *cf_off_se10 = cf_off_se10_tab;
     717       10108 :                 *cf_se11 = &cf_se11_tab[0][0][0];
     718       10108 :                 *cf_off_se11 = &cf_off_se11_tab[0][0];
     719       10108 :                 break;
     720       29552 :             case IGF_BITRATE_SWB_64000_CPE:
     721             :             case IGF_BITRATE_SWB_80000_CPE:
     722             :             case IGF_BITRATE_SWB_96000_CPE:
     723       29552 :                 bitRateIndex = IGF_BITRATE_SWB_48000; /*bitRateIndex-IGF_BITRATE_SWB_56000+IGF_BITRATE_SWB_48000;*/
     724       29552 :                 *cf_se00 = cf_se00_tab;
     725       29552 :                 *cf_se01 = cf_se01_tab[bitRateIndex];
     726       29552 :                 *cf_off_se01 = cf_off_se01_tab[bitRateIndex];
     727       29552 :                 *cf_se02 = &cf_se02_tab[bitRateIndex][0][0];
     728       29552 :                 *cf_off_se02 = &cf_off_se02_tab[bitRateIndex][0];
     729       29552 :                 *cf_se10 = &cf_se10_tab[0];
     730       29552 :                 *cf_off_se10 = cf_off_se10_tab;
     731       29552 :                 *cf_se11 = &cf_se11_tab[0][0][0];
     732       29552 :                 *cf_off_se11 = &cf_off_se11_tab[0][0];
     733       29552 :                 break;
     734           0 :             case IGF_BITRATE_UNKNOWN:
     735             :             default:
     736           0 :                 assert( 0 );
     737             :         }
     738             :     }
     739             : 
     740      353677 :     return retValue;
     741             : }

Generated by: LCOV version 1.14