LCOV - code coverage report
Current view: top level - lib_dec - hq_env_dec.c (source / functions) Hit Total Coverage
Test: Coverage on main -- short test vectors @ 6c9ddc4024a9c0e1ecb8f643f114a84a0e26ec6b Lines: 47 52 90.4 %
Date: 2025-05-23 08:37:30 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /******************************************************************************************************
       2             : 
       3             :    (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
       4             :    Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
       5             :    Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
       6             :    Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
       7             :    contributors to this repository. All Rights Reserved.
       8             : 
       9             :    This software is protected by copyright law and by international treaties.
      10             :    The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
      11             :    Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
      12             :    Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
      13             :    Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
      14             :    contributors to this repository retain full ownership rights in their respective contributions in
      15             :    the software. This notice grants no license of any kind, including but not limited to patent
      16             :    license, nor is any license granted by implication, estoppel or otherwise.
      17             : 
      18             :    Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
      19             :    contributions.
      20             : 
      21             :    This software is provided "AS IS", without any express or implied warranties. The software is in the
      22             :    development stage. It is intended exclusively for experts who have experience with such software and
      23             :    solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
      24             :    and fitness for a particular purpose are hereby disclaimed and excluded.
      25             : 
      26             :    Any dispute, controversy or claim arising under or in relation to providing this software shall be
      27             :    submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
      28             :    accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
      29             :    the United Nations Convention on Contracts on the International Sales of Goods.
      30             : 
      31             : *******************************************************************************************************/
      32             : 
      33             : /*====================================================================================
      34             :     EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
      35             :   ====================================================================================*/
      36             : 
      37             : #include <stdint.h>
      38             : #include "options.h"
      39             : #ifdef DEBUGGING
      40             : #include "debug.h"
      41             : #endif
      42             : #include "prot.h"
      43             : #include "rom_com.h"
      44             : #include "wmc_auto.h"
      45             : 
      46             : /*------------------------------------------------------------------------*
      47             :  * decode_envelope_indices()
      48             :  *
      49             :  * Decode envelope indices
      50             :  *------------------------------------------------------------------------*/
      51             : 
      52             : /*! r: Number of bits */
      53       24801 : int16_t decode_envelope_indices(
      54             :     Decoder_State *st,         /* i/o: decoder state structure           */
      55             :     const int16_t start_norm,  /* i  : starting band index               */
      56             :     const int16_t num_sfm,     /* i  : Number of subbands                */
      57             :     const int16_t numnrmibits, /* i  : Bitrate of fall-back coding mode  */
      58             :     int16_t *difidx,           /* o  : Diff indices/encoded diff indices */
      59             :     const int16_t flag_HQ2,    /* i  : indicator of HQ2 core             */
      60             :     const int16_t is_transient /* i  : transient flag                    */
      61             : )
      62             : {
      63             :     int16_t hcode_l;
      64             :     int16_t i;
      65             :     int16_t LCmode;
      66             : 
      67       24801 :     if ( flag_HQ2 == LOW_RATE_HQ_CORE || flag_HQ2 == LOW_RATE_HQ_CORE_TRAN )
      68             :     {
      69          96 :         LCmode = get_next_indice( st, BITS_DE_HMODE );
      70          96 :         difidx[start_norm] = get_next_indice( st, BITS_DE_FCOMP );
      71             :     }
      72             :     else
      73             :     {
      74       24705 :         LCmode = get_next_indice( st, 2 );
      75       24705 :         difidx[start_norm] = get_next_indice( st, NORM0_BITS );
      76             :     }
      77             : 
      78       24801 :     if ( is_transient && flag_HQ2 == LOW_RATE_HQ_CORE_TRAN )
      79             :     {
      80           6 :         hcode_l = 0;
      81           6 :         if ( LCmode == 1 )
      82             :         {
      83           6 :             hdecnrm_tran( st, num_sfm, &difidx[start_norm + 1] );
      84         192 :             for ( i = start_norm + 1; i < start_norm + num_sfm; i++ )
      85             :             {
      86         186 :                 hcode_l += huffsizn_tran[difidx[i]];
      87             :             }
      88             :         }
      89             :         else
      90             :         {
      91           0 :             hdecnrm_context( st, num_sfm, &difidx[start_norm], &hcode_l );
      92             :         }
      93             :     }
      94             :     else
      95             :     {
      96       24795 :         hcode_l = 0;
      97       24795 :         if ( LCmode == 0 )
      98             :         {
      99       14409 :             hdecnrm_context( st, num_sfm, &difidx[start_norm], &hcode_l );
     100             :         }
     101       10386 :         else if ( LCmode == 1 )
     102             :         {
     103        7053 :             hdecnrm_resize( st, num_sfm, &difidx[start_norm + 1] );
     104             : 
     105      212559 :             for ( i = start_norm + 1; i < start_norm + num_sfm; i++ )
     106             :             {
     107      205506 :                 hcode_l += resize_huffsizn[difidx[i]];
     108             :             }
     109             : 
     110      205506 :             for ( i = start_norm + 2; i < start_norm + num_sfm; i++ )
     111             :             {
     112      198453 :                 if ( difidx[i - 1] > 17 )
     113             :                 {
     114       35424 :                     difidx[i] = difidx[i] - min( difidx[i - 1] - 17, 3 );
     115             :                 }
     116             : 
     117      198453 :                 if ( difidx[i - 1] < 13 )
     118             :                 {
     119       21618 :                     difidx[i] = difidx[i] - max( difidx[i - 1] - 13, -3 );
     120             :                 }
     121             :             }
     122             :         }
     123        3333 :         else if ( LCmode == 2 )
     124             :         {
     125        2961 :             hdecnrm( st, num_sfm, &difidx[start_norm + 1] );
     126       83166 :             for ( i = start_norm + 1; i < start_norm + num_sfm; i++ )
     127             :             {
     128       80205 :                 hcode_l += huffsizn[difidx[i]];
     129             :             }
     130             :         }
     131             :         else
     132             :         {
     133        8616 :             for ( i = start_norm + 1; i < start_norm + num_sfm; i++ )
     134             :             {
     135        8244 :                 difidx[i] = get_next_indice( st, NORMI_BITS );
     136             :             }
     137         372 :             hcode_l = numnrmibits;
     138             :         }
     139             :     }
     140             : 
     141       24801 :     return hcode_l;
     142             : }
     143             : 
     144             : /*------------------------------------------------------------------------*
     145             :  * dequantize_norms()
     146             :  *
     147             :  * De-quantization of norms
     148             :  *------------------------------------------------------------------------*/
     149             : 
     150             : /*! r: Number of bits */
     151       24705 : void dequantize_norms(
     152             :     Decoder_State *st,          /* i/o: decoder state structure           */
     153             :     const int16_t start_norm,   /* i  : First SDE encoded norm            */
     154             :     const int16_t num_sfm,      /* i  : Number of norms                   */
     155             :     const int16_t is_transient, /* i  : Transient flag                    */
     156             :     int16_t *ynrm,              /* o  : Decoded norm indices              */
     157             :     int16_t *normqlg2           /* o  : Log2 of decoded norms             */
     158             : )
     159             : {
     160             :     int16_t i, j, k;
     161             :     int16_t idxbuf[NB_SFM];
     162             : 
     163             :     /* First sub-frame */
     164       24705 :     normqlg2[start_norm] = dicnlg2[ynrm[start_norm]];
     165             : 
     166             :     /* Other sub-frames */
     167       24705 :     if ( is_transient )
     168             :     {
     169             :         /* Recover quantization indices and quantized norms */
     170        1617 :         idxbuf[0] = ynrm[0];
     171       68202 :         for ( i = 1; i < num_sfm; i++ )
     172             :         {
     173       66585 :             idxbuf[i] = ynrm[i] + idxbuf[i - 1] - 15;
     174             :             /* safety check in case of bit errors */
     175       66585 :             if ( idxbuf[i] < 0 || idxbuf[i] > 39 )
     176             :             {
     177           0 :                 idxbuf[i] = 39;
     178           0 :                 st->BER_detect = 1;
     179             :             }
     180             :         }
     181             : 
     182        1617 :         recovernorm( idxbuf, ynrm, normqlg2, num_sfm );
     183             :     }
     184             :     else
     185             :     {
     186      664065 :         for ( i = start_norm + 1; i < start_norm + num_sfm; i++ )
     187             :         {
     188      640977 :             j = i - 1;
     189      640977 :             k = ynrm[j] - 15;
     190      640977 :             ynrm[i] = ynrm[i] + k;
     191             :             /* safety check in case of bit errors */
     192      640977 :             if ( ynrm[i] < 0 || ynrm[i] > 39 )
     193             :             {
     194           0 :                 ynrm[i] = 39;
     195           0 :                 st->BER_detect = 1;
     196             :             }
     197      640977 :             normqlg2[i] = dicnlg2[ynrm[i]];
     198             :         }
     199             :     }
     200             : 
     201       24705 :     return;
     202             : }

Generated by: LCOV version 1.14