LCOV - code coverage report
Current view: top level - lib_dec - ivas_ism_dtx_dec.c (source / functions) Hit Total Coverage
Test: Coverage on main -- short test vectors @ 6c9ddc4024a9c0e1ecb8f643f114a84a0e26ec6b Lines: 48 48 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             : #include <stdint.h>
      34             : #include <math.h>
      35             : #include "options.h"
      36             : #include "ivas_prot.h"
      37             : #include "prot.h"
      38             : #ifdef DEBUGGING
      39             : #include "debug.h"
      40             : #endif
      41             : #include "wmc_auto.h"
      42             : 
      43             : 
      44             : /*-------------------------------------------------------------------*
      45             :  * ivas_ism_dtx_dec()
      46             :  *
      47             :  * ISM DTX Metadata decoding routine
      48             :  *-------------------------------------------------------------------*/
      49             : 
      50        6399 : void ivas_ism_dtx_dec(
      51             :     Decoder_Struct *st_ivas,  /* i/o: IVAS decoder structure    */
      52             :     int16_t *nb_bits_metadata /* o  : number of metadata bits   */
      53             : )
      54             : {
      55             :     int16_t ch, nchan_ism, nchan_ism_prev;
      56             :     int32_t ivas_total_brate;
      57             :     int16_t md_diff_flag[MAX_NUM_OBJECTS];
      58             :     int16_t flag_noisy_speech, sce_id_dtx;
      59             :     Decoder_State *st;
      60             : 
      61        6399 :     ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
      62             : 
      63             : 
      64        6399 :     nchan_ism_prev = st_ivas->nchan_ism;
      65             : 
      66        6399 :     if ( !st_ivas->bfi && ivas_total_brate == IVAS_SID_5k2 )
      67             :     {
      68             :         /* 'nchan_ism' was read in ivas_dec_setup() */
      69        1626 :         nchan_ism = st_ivas->nchan_ism;
      70             : 
      71             :         /* ism_mode was read in ivas_dec_setup() as well as reconfiguration ivas_ism_dec_config() */
      72             :     }
      73             :     else
      74             :     {
      75        4773 :         nchan_ism = nchan_ism_prev;
      76             :     }
      77             : 
      78             :     /* Metadata decoding and dequantization  */
      79        6399 :     ivas_ism_metadata_sid_dec( st_ivas->hSCE, ivas_total_brate, st_ivas->bfi, nchan_ism, st_ivas->nchan_transport, st_ivas->ism_mode,
      80        6399 :                                &flag_noisy_speech, &sce_id_dtx, st_ivas->hIsmMetaData, nb_bits_metadata );
      81             : 
      82        6399 :     if ( ivas_total_brate == IVAS_SID_5k2 && !st_ivas->bfi )
      83             :     {
      84        1626 :         if ( st_ivas->hParamIsmDec != NULL )
      85             :         {
      86         321 :             st_ivas->hParamIsmDec->hParamIsm->flag_noisy_speech = flag_noisy_speech;
      87             :         }
      88             : 
      89        1626 :         st_ivas->hISMDTX.sce_id_dtx = sce_id_dtx;
      90             :     }
      91             : 
      92        6399 :     set_s( md_diff_flag, 1, nchan_ism );
      93             : 
      94        6399 :     if ( st_ivas->ism_mode == ISM_MODE_PARAM )
      95             :     {
      96        4860 :         for ( ch = 0; ch < nchan_ism; ch++ )
      97             :         {
      98        3888 :             st_ivas->hParamIsmDec->azimuth_values[ch] = st_ivas->hIsmMetaData[ch]->azimuth;
      99        3888 :             st_ivas->hParamIsmDec->elevation_values[ch] = st_ivas->hIsmMetaData[ch]->elevation;
     100             :         }
     101             :     }
     102             : 
     103             :     /* synch common seed between SCEs */
     104        6399 :     if ( st_ivas->ism_mode == ISM_MODE_DISC )
     105             :     {
     106       19269 :         for ( ch = 0; ch < nchan_ism; ++ch )
     107             :         {
     108       13842 :             st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed = st_ivas->hSCE[st_ivas->hISMDTX.sce_id_dtx]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed;
     109             :         }
     110             :     }
     111             : 
     112        6399 :     update_last_metadata( nchan_ism, st_ivas->hIsmMetaData, md_diff_flag );
     113             : 
     114        6399 :     st_ivas->hISMDTX.ism_dtx_hangover_cnt = 0;
     115             : 
     116        6399 :     if ( ivas_total_brate == IVAS_SID_5k2 && !st_ivas->bfi )
     117             :     {
     118        6381 :         for ( ch = 0; ch < st_ivas->nchan_transport; ch++ )
     119             :         {
     120        4755 :             nb_bits_metadata[ch] = nb_bits_metadata[sce_id_dtx];
     121             :         }
     122             :     }
     123             : 
     124        6399 :     if ( !st_ivas->bfi )
     125             :     {
     126       22185 :         for ( ch = 0; ch < st_ivas->nchan_transport; ch++ )
     127             :         {
     128       15786 :             st = st_ivas->hSCE[ch]->hCoreCoder[0];
     129       15786 :             st->bit_stream = st_ivas->hSCE[0]->hCoreCoder[0]->bit_stream;
     130       15786 :             st->next_bit_pos = 0; /* note: needed in paramISM -> discISM switching */
     131       15786 :             st->cng_ism_flag = 1;
     132       15786 :             st->L_frame = min( st->L_frame, L_FRAME16k ); /* note: needed for switching from active frame with L_frame=640 to CNG in object with no SID */
     133             :         }
     134             :     }
     135             : 
     136        6399 :     return;
     137             : }
     138             : 
     139             : 
     140             : /*-------------------------------------------------------------------*
     141             :  * ivs_ism_dtx_limit_noise_energy_for_near_silence()
     142             :  *
     143             :  * for DTX frames where the energy of the sent noise estimate of the dominant object
     144             :  * is near silence, limit the other objects CNG energies to the same level
     145             :  *-------------------------------------------------------------------*/
     146             : 
     147        6399 : void ivas_ism_dtx_limit_noise_energy_for_near_silence(
     148             :     SCE_DEC_HANDLE hSCE[],        /* i/o: SCE decoder structures          */
     149             :     const int16_t sce_id_dtx,     /* i  : SCE DTX ID                      */
     150             :     const int16_t nchan_transport /* i  : number of transport channels    */
     151             : )
     152             : {
     153             :     float fac, cng_noise_nrg_obj, cng_noise_nrg_dominant;
     154             :     int16_t ch, cng_noise_level_len;
     155             :     HANDLE_FD_CNG_COM hFdCngCom;
     156             : 
     157        6399 :     hFdCngCom = hSCE[sce_id_dtx]->hCoreCoder[0]->hFdCngDec->hFdCngCom;
     158        6399 :     cng_noise_level_len = hFdCngCom->stopFFTbin - hFdCngCom->startBand;
     159        6399 :     cng_noise_nrg_dominant = dotp( hFdCngCom->cngNoiseLevel, hFdCngCom->cngNoiseLevel, cng_noise_level_len );
     160             : 
     161        6399 :     if ( cng_noise_nrg_dominant < 1.f )
     162             :     {
     163        8376 :         for ( ch = 0; ch < nchan_transport; ch++ )
     164             :         {
     165        6129 :             if ( ch == sce_id_dtx )
     166             :             {
     167        2247 :                 continue;
     168             :             }
     169             : 
     170        3882 :             hFdCngCom = hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom;
     171        3882 :             cng_noise_level_len = hFdCngCom->stopFFTbin - hFdCngCom->startBand;
     172        3882 :             cng_noise_nrg_obj = dotp( hFdCngCom->cngNoiseLevel, hFdCngCom->cngNoiseLevel, cng_noise_level_len );
     173             : 
     174        3882 :             if ( cng_noise_nrg_obj > cng_noise_nrg_dominant )
     175             :             {
     176         930 :                 fac = sqrtf( cng_noise_nrg_dominant / cng_noise_nrg_obj );
     177         930 :                 v_multc( hFdCngCom->cngNoiseLevel, fac, hFdCngCom->cngNoiseLevel, cng_noise_level_len );
     178             :             }
     179             :         }
     180             :     }
     181             : 
     182        6399 :     return;
     183             : }

Generated by: LCOV version 1.14