LCOV - code coverage report
Current view: top level - lib_com - ivas_mcmasa_com-fx.c (source / functions) Hit Total Coverage
Test: Coverage on main enc/dec/rend @ 3b2f07138c61dcf997bbf4165d0882f794b2995f Lines: 45 45 100.0 %
Date: 2025-05-03 01:55:50 Functions: 3 3 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 "ivas_cnst.h"
      34             : #include "options.h"
      35             : #include "wmc_auto.h"
      36             : #include "ivas_prot_fx.h"
      37             : 
      38             : 
      39             : /*--------------------------------------------------------------------------*
      40             :  * ivas_mcmasa_setNumTransportChannels()
      41             :  *
      42             :  * Set number of transport channels in McMASA
      43             :  *--------------------------------------------------------------------------*/
      44             : 
      45         739 : void ivas_mcmasa_setNumTransportChannels_fx(
      46             :     Word16 *nchan_transport,      /* o  : Pointer to number of transport channels to be set */
      47             :     Word16 *element_mode,         /* o  : Pointer to element mode to be set                 */
      48             :     const Word32 ivas_total_brate /* i  : Total bitrate of IVAS                             */
      49             : )
      50             : {
      51         739 :     IF( GE_32( ivas_total_brate, IVAS_48k ) )
      52             :     {
      53         117 :         *nchan_transport = 2;
      54         117 :         move16();
      55         117 :         *element_mode = IVAS_CPE_MDCT;
      56         117 :         move16();
      57             :     }
      58             :     ELSE
      59             :     {
      60         622 :         *nchan_transport = 1;
      61         622 :         move16();
      62         622 :         *element_mode = IVAS_SCE;
      63         622 :         move16();
      64             :     }
      65             : 
      66         739 :     return;
      67             : }
      68             : 
      69             : 
      70             : /*--------------------------------------------------------------------------*
      71             :  * ivas_mcmasa_set_separate_channel_mode()
      72             :  *
      73             :  * Set separate channel parameters in McMASA based on bitrate
      74             :  *--------------------------------------------------------------------------*/
      75             : 
      76         947 : void ivas_mcmasa_set_separate_channel_mode_fx(
      77             :     UWord8 *separateChannelEnabled, /* o  : Pointer to separate channel toggle                */
      78             :     Word16 *separateChannelIndex,   /* o  : Pointer to separate channel index                 */
      79             :     const Word32 ivas_total_brate   /* i  : Total bitrate of IVAS                             */
      80             : )
      81             : {
      82         947 :     IF( GE_32( ivas_total_brate, MCMASA_SEPARATE_BRATE ) )
      83             :     {
      84          79 :         *separateChannelEnabled = 1;
      85          79 :         move16();
      86          79 :         *separateChannelIndex = 2; /* Center channel */
      87          79 :         move16();
      88             :     }
      89             :     ELSE
      90             :     {
      91         868 :         *separateChannelEnabled = 0;
      92         868 :         move16();
      93         868 :         *separateChannelIndex = 0;
      94         868 :         move16();
      95             :     }
      96             : 
      97         947 :     return;
      98             : }
      99             : 
     100             : 
     101             : /*--------------------------------------------------------------------------*
     102             :  * ivas_mcmasa_split_brate()
     103             :  *
     104             :  * Split the total bitrate to elements in McMASA
     105             :  *--------------------------------------------------------------------------*/
     106             : 
     107         508 : void ivas_mcmasa_split_brate_fx(
     108             :     const UWord8 separateChannelEnabled, /* i  : Transport running in "separate channel" mode      */
     109             :     const Word32 ivas_total_brate,       /* i  : IVAS total bitrate available to be split          */
     110             :     const Word16 nSCE,                   /* i  : Number of SCEs in use (0 or 1)                    */
     111             :     const Word16 nCPE,                   /* i  : Number of CPEs in use (0 or 1)                    */
     112             :     Word32 *brate_sce,                   /* o  : Pointer to SCE element bitrate                    */
     113             :     Word32 *brate_cpe                    /* o  : Pointer to CPE element bitrate                    */
     114             : )
     115             : {
     116         508 :     IF( separateChannelEnabled )
     117             :     {
     118             :         /* 25% of total bitrate is used for SCE below 96 kb/s (separated mono channel), otherwise 30% */
     119          46 :         IF( LT_32( ivas_total_brate, IVAS_96k ) )
     120             :         {
     121          39 :             *brate_sce = Mpy_32_32( MCMASA_MONOBITRATIO_64k_Q31, ivas_total_brate ); /* Q0 */
     122          39 :             move32();
     123             :         }
     124             :         ELSE
     125             :         {
     126           7 :             *brate_sce = Mpy_32_32( MCMASA_MONOBITRATIO_Q31, ivas_total_brate ); /* Q0 */
     127           7 :             move32();
     128             :         }
     129             : 
     130          46 :         *brate_cpe = L_sub( ivas_total_brate, *brate_sce );
     131          46 :         move32();
     132             :     }
     133             :     ELSE
     134             :     {
     135             :         Word16 tmp, tmp_e;
     136         462 :         tmp_e = 0;
     137         462 :         move16();
     138         462 :         tmp = BASOP_Util_Divide3216_Scale( ivas_total_brate, ( add( nCPE, nSCE ) ), &tmp_e );
     139         462 :         IF( nSCE > 0 )
     140             :         {
     141         424 :             *brate_sce = L_shr( (Word32) tmp, negate( add( 1, tmp_e ) ) );
     142         424 :             move32();
     143             :         }
     144             :         ELSE
     145             :         {
     146          38 :             *brate_sce = 0;
     147          38 :             move32();
     148             :         }
     149         462 :         IF( nCPE > 0 )
     150             :         {
     151          38 :             *brate_cpe = L_shr( (Word32) tmp, negate( add( 1, tmp_e ) ) );
     152          38 :             move32();
     153             :         }
     154             :         ELSE
     155             :         {
     156         424 :             *brate_cpe = 0;
     157         424 :             move32();
     158             :         }
     159             :     }
     160             : 
     161         508 :     return;
     162             : }

Generated by: LCOV version 1.14