LCOV - code coverage report
Current view: top level - lib_com - hq_conf.c (source / functions) Hit Total Coverage
Test: Coverage on main @ 6baab0c613aa6c7100498ed7b93676aa8198a493 Lines: 109 109 100.0 %
Date: 2025-05-29 08:28:55 Functions: 1 1 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 "rom_com.h"
      44             : #include "prot.h"
      45             : #include "wmc_auto.h"
      46             : 
      47             : /*--------------------------------------------------------------------------*
      48             :  * hq_configure()
      49             :  *
      50             :  * Configuration routine for HQ mode
      51             :  *--------------------------------------------------------------------------*/
      52             : 
      53      208016 : void hq_configure(
      54             :     const int16_t length,       /* i  : Frame length                              */
      55             :     const int16_t hqswb_clas,   /* i  : HQ SWB class                              */
      56             :     const int32_t core_brate,   /* i  : Codec bitrate                             */
      57             :     int16_t *num_sfm,           /* o  : Total number of subbands                  */
      58             :     int16_t *nb_sfm,            /* o  : Total number of coded bands               */
      59             :     int16_t *start_norm,        /* o  : First norm to be SDE encoded              */
      60             :     int16_t *num_env_bands,     /* o  : Number coded envelope bands               */
      61             :     int16_t *numnrmibits,       /* o  : Number of bits in fall-back norm encoding */
      62             :     int16_t *hq_generic_offset, /* o  : Freq offset for HQ GENERIC                */
      63             :     int16_t *sfmsize,           /* o  : Subband bandwidths                        */
      64             :     int16_t *sfm_start,         /* o  : Subband start coefficients                */
      65             :     int16_t *sfm_end            /* o  : Subband end coefficients                  */
      66             : )
      67             : {
      68             :     const int16_t *p_sfmsize;
      69             :     const int16_t *p_sfm_start;
      70             :     const int16_t *p_sfm_end;
      71             :     int16_t i, bw_ext;
      72             : 
      73      208016 :     bw_ext = 0;
      74      208016 :     *start_norm = 0;
      75             : 
      76      208016 :     if ( length == L_SPEC48k )
      77             :     {
      78       97389 :         if ( hqswb_clas == HQ_GEN_FB )
      79             :         {
      80       34150 :             *num_sfm = NB_SFM;
      81       34150 :             p_sfmsize = band_len_HQ;
      82       34150 :             p_sfm_start = band_start_HQ;
      83       34150 :             p_sfm_end = band_end_HQ;
      84             : 
      85       34150 :             if ( core_brate >= HQ_32k )
      86             :             {
      87         530 :                 *hq_generic_offset = HQ_GENERIC_FOFFSET_32K;
      88             :                 /* setting start frequency of FD BWE */
      89         530 :                 *num_env_bands = SFM_N_STA_10k;
      90             :             }
      91             :             else
      92             :             {
      93       33620 :                 *hq_generic_offset = HQ_GENERIC_FOFFSET_24K4;
      94       33620 :                 *num_env_bands = SFM_N_STA_8k;
      95             :             }
      96             : 
      97       34150 :             *nb_sfm = *num_sfm;
      98             :         }
      99             :         else
     100             :         {
     101       63239 :             if ( hqswb_clas == HQ_HARMONIC )
     102             :             {
     103       10936 :                 *num_sfm = SFM_N_HARM_FB;
     104       10936 :                 *nb_sfm = SFM_N_HARM_FB;
     105       10936 :                 *num_env_bands = SFM_N_HARM_FB;
     106             : 
     107       10936 :                 p_sfmsize = band_len_harm;
     108       10936 :                 p_sfm_start = band_start_harm;
     109       10936 :                 p_sfm_end = band_end_harm;
     110             :             }
     111       52303 :             else if ( hqswb_clas == HQ_HVQ )
     112             :             {
     113       15469 :                 if ( core_brate < HQ_BWE_CROSSOVER_BRATE )
     114             :                 {
     115        9935 :                     *num_sfm = SFM_N_HARM_FB;
     116        9935 :                     *nb_sfm = HVQ_THRES_SFM_24k;
     117        9935 :                     *num_env_bands = *num_sfm - *nb_sfm;
     118        9935 :                     *start_norm = HVQ_THRES_SFM_24k;
     119             :                 }
     120             :                 else
     121             :                 {
     122        5534 :                     *num_sfm = SFM_N_HARM_FB;
     123        5534 :                     *nb_sfm = HVQ_THRES_SFM_32k;
     124        5534 :                     *num_env_bands = *num_sfm - *nb_sfm;
     125        5534 :                     *start_norm = HVQ_THRES_SFM_32k;
     126             :                 }
     127             : 
     128       15469 :                 p_sfmsize = band_len_harm;
     129       15469 :                 p_sfm_start = band_start_harm;
     130       15469 :                 p_sfm_end = band_end_harm;
     131             :             }
     132             :             else
     133             :             {
     134       36834 :                 *num_sfm = NB_SFM;
     135       36834 :                 *nb_sfm = *num_sfm;
     136       36834 :                 *num_env_bands = NB_SFM;
     137             : 
     138       36834 :                 p_sfmsize = band_len_HQ;
     139       36834 :                 p_sfm_start = band_start_HQ;
     140       36834 :                 p_sfm_end = band_end_HQ;
     141             :             }
     142             :         }
     143             :     }
     144      110627 :     else if ( length == L_SPEC32k )
     145             :     {
     146       70320 :         if ( hqswb_clas == HQ_HARMONIC )
     147             :         {
     148       11174 :             *num_sfm = SFM_N_HARM;
     149       11174 :             *nb_sfm = SFM_N_HARM;
     150       11174 :             *num_env_bands = SFM_N_HARM;
     151             : 
     152       11174 :             p_sfmsize = band_len_harm;
     153       11174 :             p_sfm_start = band_start_harm;
     154       11174 :             p_sfm_end = band_end_harm;
     155             :         }
     156       59146 :         else if ( hqswb_clas == HQ_HVQ )
     157             :         {
     158       15034 :             if ( core_brate < HQ_BWE_CROSSOVER_BRATE )
     159             :             {
     160       12779 :                 *num_sfm = SFM_N_HARM;
     161       12779 :                 *nb_sfm = HVQ_THRES_SFM_24k;
     162       12779 :                 *num_env_bands = *num_sfm - *nb_sfm;
     163       12779 :                 *start_norm = HVQ_THRES_SFM_24k;
     164             :             }
     165             :             else
     166             :             {
     167        2255 :                 *num_sfm = SFM_N_HARM;
     168        2255 :                 *nb_sfm = HVQ_THRES_SFM_32k;
     169        2255 :                 *num_env_bands = *num_sfm - *nb_sfm;
     170        2255 :                 *start_norm = HVQ_THRES_SFM_32k;
     171             :             }
     172             : 
     173       15034 :             p_sfmsize = band_len_harm;
     174       15034 :             p_sfm_start = band_start_harm;
     175       15034 :             p_sfm_end = band_end_harm;
     176             :         }
     177       44112 :         else if ( hqswb_clas == HQ_GEN_SWB )
     178             :         {
     179       30470 :             *num_sfm = SFM_N_SWB;
     180       30470 :             p_sfmsize = band_len_HQ;
     181       30470 :             p_sfm_start = band_start_HQ;
     182       30470 :             p_sfm_end = band_end_HQ;
     183             : 
     184       30470 :             if ( core_brate >= HQ_32k )
     185             :             {
     186        1224 :                 *hq_generic_offset = HQ_GENERIC_FOFFSET_32K;
     187             :                 /* setting start frequency of FD BWE */
     188        1224 :                 *num_env_bands = SFM_N_STA_10k;
     189             :             }
     190             :             else
     191             :             {
     192       29246 :                 *hq_generic_offset = HQ_GENERIC_FOFFSET_24K4;
     193             :                 /* setting start frequency of FD BWE */
     194       29246 :                 *num_env_bands = SFM_N_STA_8k;
     195             :             }
     196       30470 :             *nb_sfm = *num_sfm;
     197             :         }
     198             :         else
     199             :         {
     200             :             /* HQ_NORMAL and HQ_TRANSIENT */
     201       13642 :             *num_sfm = SFM_N_SWB;
     202       13642 :             *nb_sfm = *num_sfm;
     203       13642 :             *num_env_bands = SFM_N_SWB;
     204             : 
     205       13642 :             p_sfmsize = band_len_HQ;
     206       13642 :             p_sfm_start = band_start_HQ;
     207       13642 :             p_sfm_end = band_end_HQ;
     208             :         }
     209             :     }
     210       40307 :     else if ( length == L_SPEC48k_EXT )
     211             :     {
     212        1639 :         bw_ext = 1;
     213        1639 :         p_sfmsize = band_len_HQ;
     214        1639 :         p_sfm_start = band_start_HQ;
     215        1639 :         p_sfm_end = band_end_HQ;
     216        1639 :         *num_sfm = NB_SFM;
     217             :     }
     218       38668 :     else if ( length == L_SPEC16k_EXT )
     219             :     {
     220         952 :         bw_ext = 1;
     221         952 :         p_sfmsize = band_len_wb;
     222         952 :         p_sfm_start = band_start_wb;
     223         952 :         p_sfm_end = band_end_wb;
     224         952 :         *num_sfm = SFM_N_WB;
     225             :     }
     226             :     else
     227             :     {
     228       37716 :         *num_sfm = SFM_N_WB;
     229       37716 :         *nb_sfm = *num_sfm;
     230       37716 :         *num_env_bands = SFM_N_WB;
     231             : 
     232       37716 :         p_sfmsize = band_len_wb;
     233       37716 :         p_sfm_start = band_start_wb;
     234       37716 :         p_sfm_end = band_end_wb;
     235             :     }
     236             : 
     237      208016 :     if ( bw_ext )
     238             :     {
     239       99459 :         for ( i = 0; i < *num_sfm; i++ )
     240             :         {
     241       96868 :             sfmsize[i] = (int16_t) ( 1.25f * p_sfmsize[i] );
     242       96868 :             sfm_start[i] = (int16_t) ( 1.25f * p_sfm_start[i] );
     243       96868 :             sfm_end[i] = (int16_t) ( 1.25f * p_sfm_end[i] );
     244             :         }
     245        2591 :         *nb_sfm = *num_sfm;
     246        2591 :         *num_env_bands = *num_sfm;
     247             :     }
     248             :     else
     249             :     {
     250      205425 :         mvs2s( p_sfmsize, sfmsize, *num_sfm );
     251      205425 :         mvs2s( p_sfm_start, sfm_start, *num_sfm );
     252      205425 :         mvs2s( p_sfm_end, sfm_end, *num_sfm );
     253             :     }
     254             : 
     255      208016 :     *numnrmibits = ( *num_env_bands - 1 ) * NORMI_BITS;
     256             : 
     257      208016 :     return;
     258             : }

Generated by: LCOV version 1.14