LCOV - code coverage report
Current view: top level - lib_com - ivas_stereo_psychlpc_com_fx.c (source / functions) Hit Total Coverage
Test: Coverage on main enc/dec/rend @ 994b685932144965e2ff73e92e667127e862d60e Lines: 41 44 93.2 %
Date: 2025-05-15 02:05:59 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             : #include <stdint.h>
      34             : #include "options.h"
      35             : #include "ivas_rom_com.h"
      36             : #include "prot_fx.h"
      37             : #include "wmc_auto.h"
      38             : #include <assert.h>
      39             : 
      40             : #include "ivas_prot_fx.h"
      41             : 
      42             : /*-------------------------------------------------------------------*
      43             :  *  SpectrumWeighting_Init()
      44             :  *
      45             :  *
      46             :  *-------------------------------------------------------------------*/
      47             : 
      48       86984 : static void SpectrumWeighting_Init_fx(
      49             :     SpectrumWarping const *pSpectrumWarping,
      50             :     const Word16 isTCX20, /*Q0*/
      51             :     PsychoacousticParameters *pPsychParams )
      52             : {
      53       86984 :     IF( isTCX20 )
      54             :     {
      55       43492 :         pPsychParams->bandLengths = pSpectrumWarping->bandLengthsTCX20; /*Q0*/
      56             :     }
      57             :     ELSE
      58             :     {
      59       43492 :         pPsychParams->bandLengths = pSpectrumWarping->bandLengthsTCX10; /*Q0*/
      60             :     }
      61             : 
      62       86984 :     return;
      63             : }
      64             : 
      65             : 
      66             : /*-------------------------------------------------------------------*
      67             :  *  PsychoacousticParameters_Init()
      68             :  *
      69             :  *  initialize a PsychoacousticParameters structure
      70             :  *-------------------------------------------------------------------*/
      71             : 
      72      117465 : ivas_error PsychoacousticParameters_Init_fx(
      73             :     const Word32 sr_core,  /* i  : sampling rate of core-coder                                     Q0*/
      74             :     const Word16 nBins,    /* i  : Number of bins (spectral lines)                                 Q0*/
      75             :     const Word8 nBands,    /* i  : Number of spectrum subbands                                     Q0*/
      76             :     const Word16 isTCX20,  /* i  : Flag indicating if the subband division is for TCX20 or TCX10   Q0*/
      77             :     const Word16 isWarped, /* i  : Flag indicating if the scale is linear or warped                */
      78             :     PsychoacousticParameters *pPsychParams )
      79             : {
      80             : 
      81      117465 :     IF( pPsychParams == NULL )
      82             :     {
      83           0 :         return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "PsychParams handle is NULL" );
      84             :     }
      85             : 
      86      117465 :     pPsychParams->nBins = nBins;   /*Q0*/
      87      117465 :     pPsychParams->nBands = nBands; /*Q0*/
      88      117465 :     move16();
      89      117465 :     move16();
      90             : 
      91      117465 :     IF( !isWarped )
      92             :     {
      93       30481 :         pPsychParams->bandLengths = NULL;
      94             :     }
      95             :     ELSE
      96             :     {
      97       86984 :         assert( EQ_16( pPsychParams->nBands, 64 ) );
      98       86984 :         SWITCH( sr_core )
      99             :         {
     100       28714 :             case 16000:
     101       28714 :                 SpectrumWeighting_Init_fx( sw16000Hz, isTCX20, pPsychParams );
     102       28714 :                 BREAK;
     103       31202 :             case 25600:
     104       31202 :                 SpectrumWeighting_Init_fx( sw25600Hz, isTCX20, pPsychParams );
     105       31202 :                 BREAK;
     106       27068 :             case 32000:
     107       27068 :                 SpectrumWeighting_Init_fx( sw32000Hz, isTCX20, pPsychParams );
     108       27068 :                 BREAK;
     109           0 :             default:
     110           0 :                 return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Subband division not defined for this sampling rate" );
     111             :         }
     112             :     }
     113             : 
     114      117465 :     return IVAS_ERR_OK;
     115             : }
     116             : 
     117             : /*-------------------------------------------------------------------*
     118             :  *  InitPsychLPC()
     119             :  *
     120             :  *
     121             :  *-------------------------------------------------------------------*/
     122             : 
     123       30481 : void InitPsychLPC_fx(
     124             :     const Word32 sr_core,           /* i  : sampling rate of core-coder   Q0*/
     125             :     const Word16 L_frame,           /* i  : frame length                  Q0*/
     126             :     const TCX_CONFIG_HANDLE hTcxCfg /* i  : TCX configuration handle      */
     127             : )
     128             : {
     129       30481 :     Word16 L_frame_ext = add( L_frame, shr( L_frame, 2 ) ); /*Q0*/
     130             : 
     131       30481 :     hTcxCfg->psychParamsCurrent = NULL;
     132             : 
     133       30481 :     PsychoacousticParameters_Init_fx( sr_core, shr( L_frame, 1 ), 64, 0, 1, &hTcxCfg->psychParamsTCX10 );
     134       30481 :     PsychoacousticParameters_Init_fx( sr_core, L_frame, 64, 1, 1, &hTcxCfg->psychParamsTCX20 );
     135       30481 :     PsychoacousticParameters_Init_fx( sr_core, L_frame_ext, 64, 1, 0, &hTcxCfg->psychParamsTCX20AfterACELP );
     136             : 
     137       30481 :     return;
     138             : }
     139             : 
     140             : /*-------------------------------------------------------------------*
     141             :  *  SetCurrentPsychParams()
     142             :  *
     143             :  *
     144             :  *-------------------------------------------------------------------*/
     145             : 
     146     1185185 : void SetCurrentPsychParams(
     147             :     const Word16 core,                         /*Q0*/
     148             :     const Word16 last_frame_was_concealed_cng, /*Q0*/
     149             :     TCX_CONFIG_HANDLE hTcxCfg )
     150             : {
     151     1185185 :     test();
     152     1185185 :     IF( EQ_16( hTcxCfg->tcx_last_overlap_mode, TRANSITION_OVERLAP ) && ( last_frame_was_concealed_cng == 0 ) )
     153             :     {
     154        2566 :         assert( core == TCX_20_CORE );
     155        2566 :         hTcxCfg->psychParamsCurrent = &hTcxCfg->psychParamsTCX20AfterACELP;
     156             :     }
     157             :     ELSE
     158             :     {
     159     1182619 :         IF( EQ_16( core, TCX_10_CORE ) )
     160             :         {
     161       26422 :             hTcxCfg->psychParamsCurrent = &hTcxCfg->psychParamsTCX10;
     162             :         }
     163             :         ELSE
     164             :         {
     165     1156197 :             hTcxCfg->psychParamsCurrent = &hTcxCfg->psychParamsTCX20;
     166             :         }
     167             :     }
     168             : 
     169     1185185 :     return;
     170             : }

Generated by: LCOV version 1.14