LCOV - code coverage report
Current view: top level - lib_com - ivas_mc_com_fx.c (source / functions) Hit Total Coverage
Test: Coverage on main @ 22b74eaeaa63d28e0fcc8ed21c8f7c451f461847 Lines: 121 131 92.4 %
Date: 2025-10-18 02:19:22 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 <assert.h>
      34             : #include <stdint.h>
      35             : #include "options.h"
      36             : #include <math.h>
      37             : #include "prot_fx.h"
      38             : #include "wmc_auto.h"
      39             : #include "ivas_prot_fx.h"
      40             : 
      41             : 
      42             : /*---------------------------------------------------------------
      43             :  * ivas_mc_mode_select()
      44             :  *
      45             :  * selects the multichannel mode base on bitrate and LS setup
      46             :  * ---------------------------------------------------------------*/
      47             : 
      48             : /*! r : MC format mode */
      49      147688 : MC_MODE ivas_mc_mode_select_fx(
      50             :     const MC_LS_SETUP mc_ls_setup, /* i  : MC loudspeaker setup           */
      51             :     const Word32 total_brate       /* i  : IVAS total bitrate             */
      52             : )
      53             : {
      54      147688 :     MC_MODE mc_mode = MC_MODE_MCT;
      55      147688 :     move32();
      56             : 
      57      147688 :     SWITCH( mc_ls_setup )
      58             :     {
      59      130097 :         case MC_LS_SETUP_5_1:
      60      130097 :             IF( LT_32( total_brate, IVAS_48k ) )
      61             :             {
      62       30260 :                 mc_mode = MC_MODE_MCMASA;
      63       30260 :                 move32();
      64             :             }
      65       99837 :             ELSE IF( LT_32( total_brate, IVAS_96k ) )
      66             :             {
      67       29400 :                 mc_mode = MC_MODE_PARAMMC;
      68       29400 :                 move32();
      69             :             }
      70      130097 :             BREAK;
      71        1878 :         case MC_LS_SETUP_7_1:
      72        1878 :             IF( LT_32( total_brate, IVAS_48k ) )
      73             :             {
      74         445 :                 mc_mode = MC_MODE_MCMASA;
      75         445 :                 move32();
      76             :             }
      77        1433 :             ELSE IF( LT_32( total_brate, IVAS_128k ) )
      78             :             {
      79         416 :                 mc_mode = MC_MODE_PARAMMC;
      80         416 :                 move32();
      81             :             }
      82        1878 :             BREAK;
      83        2748 :         case MC_LS_SETUP_5_1_2:
      84        2748 :             IF( LT_32( total_brate, IVAS_48k ) )
      85             :             {
      86         729 :                 mc_mode = MC_MODE_MCMASA;
      87         729 :                 move32();
      88             :             }
      89        2019 :             ELSE IF( LT_32( total_brate, IVAS_128k ) )
      90             :             {
      91        1190 :                 mc_mode = MC_MODE_PARAMMC;
      92        1190 :                 move32();
      93             :             }
      94        2748 :             BREAK;
      95        2732 :         case MC_LS_SETUP_5_1_4:
      96        2732 :             IF( LT_32( total_brate, IVAS_96k ) )
      97             :             {
      98         740 :                 mc_mode = MC_MODE_MCMASA;
      99         740 :                 move32();
     100             :             }
     101        1992 :             ELSE IF( LT_32( total_brate, IVAS_160k ) )
     102             :             {
     103           0 :                 mc_mode = MC_MODE_PARAMMC;
     104           0 :                 move32();
     105             :             }
     106        2732 :             BREAK;
     107       10233 :         case MC_LS_SETUP_7_1_4:
     108       10233 :             IF( LT_32( total_brate, IVAS_128k ) )
     109             :             {
     110        3071 :                 mc_mode = MC_MODE_MCMASA;
     111        3071 :                 move32();
     112             :             }
     113        7162 :             ELSE IF( LT_32( total_brate, IVAS_160k ) )
     114             :             {
     115         266 :                 mc_mode = MC_MODE_PARAMMC;
     116         266 :                 move32();
     117             :             }
     118        6896 :             ELSE IF( LT_32( total_brate, IVAS_192k ) )
     119             :             {
     120        2381 :                 mc_mode = MC_MODE_PARAMUPMIX;
     121        2381 :                 move32();
     122             :             }
     123       10233 :             BREAK;
     124           0 :         default:
     125           0 :             assert( 0 && "LS Setup not supported or defined for MC mode!\n" );
     126             :     }
     127             : 
     128      147688 :     return mc_mode;
     129             : }
     130             : 
     131             : 
     132             : /*---------------------------------------------------------------
     133             :  * ivas_mc_setup_get_num_channels()
     134             :  *
     135             :  * returns the number of channels (including the LFE) for a MC LS setup
     136             :  * ---------------------------------------------------------------*/
     137             : 
     138             : /*! r : number of loudspeaker channels */
     139       26947 : Word16 ivas_mc_ls_setup_get_num_channels_fx(
     140             :     const MC_LS_SETUP mc_ls_setup /* i  : multi channel loudspeaker setup */
     141             : )
     142             : {
     143             :     Word16 nchan;
     144             : 
     145       26947 :     nchan = 0;
     146       26947 :     move16();
     147             : 
     148       26947 :     SWITCH( mc_ls_setup )
     149             :     {
     150       24038 :         case MC_LS_SETUP_5_1:
     151       24038 :             nchan = 6;
     152       24038 :             move16();
     153       24038 :             BREAK;
     154         369 :         case MC_LS_SETUP_7_1:
     155         369 :             nchan = 8;
     156         369 :             move16();
     157         369 :             break;
     158         300 :         case MC_LS_SETUP_5_1_2:
     159         300 :             nchan = 8;
     160         300 :             move16();
     161         300 :             BREAK;
     162         684 :         case MC_LS_SETUP_5_1_4:
     163         684 :             nchan = 10;
     164         684 :             move16();
     165         684 :             BREAK;
     166        1556 :         case MC_LS_SETUP_7_1_4:
     167        1556 :             nchan = 12;
     168        1556 :             move16();
     169        1556 :             BREAK;
     170           0 :         default:
     171           0 :             assert( 0 && "LS Setup not supported or defined for MC mode!\n" );
     172             :     }
     173             : 
     174       26947 :     return nchan;
     175             : }
     176             : 
     177             : 
     178             : /*---------------------------------------------------------------
     179             :  * ivas_mc_map_output_config_to_mc_ls_setup()
     180             :  *
     181             :  * maps output configuration multi channel loudspeaker setup
     182             :  * ---------------------------------------------------------------*/
     183             : 
     184             : /*! r : multi channel loudspeaker setup */
     185      136951 : MC_LS_SETUP ivas_mc_map_output_config_to_mc_ls_setup_fx(
     186             :     const AUDIO_CONFIG output_config /* i  : output audio configuration */
     187             : )
     188             : {
     189             :     MC_LS_SETUP mc_ls_setup;
     190             : 
     191      136951 :     mc_ls_setup = MC_LS_SETUP_INVALID;
     192      136951 :     move32();
     193             : 
     194      136951 :     SWITCH( output_config )
     195             :     {
     196      120861 :         case IVAS_AUDIO_CONFIG_5_1:
     197      120861 :             mc_ls_setup = MC_LS_SETUP_5_1;
     198      120861 :             move32();
     199      120861 :             BREAK;
     200        1772 :         case IVAS_AUDIO_CONFIG_7_1:
     201        1772 :             mc_ls_setup = MC_LS_SETUP_7_1;
     202        1772 :             move32();
     203        1772 :             BREAK;
     204        2369 :         case IVAS_AUDIO_CONFIG_5_1_2:
     205        2369 :             mc_ls_setup = MC_LS_SETUP_5_1_2;
     206        2369 :             move32();
     207        2369 :             BREAK;
     208        2735 :         case IVAS_AUDIO_CONFIG_5_1_4:
     209        2735 :             mc_ls_setup = MC_LS_SETUP_5_1_4;
     210        2735 :             move32();
     211        2735 :             BREAK;
     212        9214 :         case IVAS_AUDIO_CONFIG_7_1_4:
     213        9214 :             mc_ls_setup = MC_LS_SETUP_7_1_4;
     214        9214 :             move32();
     215        9214 :             BREAK;
     216           0 :         default:
     217           0 :             assert( 0 && "Output config is not a valid MC loudspeaker setup!\n" );
     218             :     }
     219             : 
     220      136951 :     return mc_ls_setup;
     221             : }
     222             : 
     223             : 
     224             : /*---------------------------------------------------------------
     225             :  * ivas_mc_map_ls_setup_to_output_config
     226             :  *
     227             :  * maps multi channel loudspeaker setup to audio configuration
     228             :  * ---------------------------------------------------------------*/
     229             : 
     230             : /*! r: audio configuration*/
     231       96626 : AUDIO_CONFIG ivas_mc_map_ls_setup_to_output_config_fx(
     232             :     const MC_LS_SETUP mc_ls_setup /* i  : multi channel loudspeaker setup*/
     233             : )
     234             : {
     235             :     AUDIO_CONFIG audio_config;
     236       96626 :     audio_config = IVAS_AUDIO_CONFIG_INVALID;
     237       96626 :     move32();
     238             : 
     239       96626 :     SWITCH( mc_ls_setup )
     240             :     {
     241       85286 :         case MC_LS_SETUP_5_1:
     242       85286 :             audio_config = IVAS_AUDIO_CONFIG_5_1;
     243       85286 :             move32();
     244       85286 :             BREAK;
     245        1194 :         case MC_LS_SETUP_7_1:
     246        1194 :             audio_config = IVAS_AUDIO_CONFIG_7_1;
     247        1194 :             move32();
     248        1194 :             BREAK;
     249        1788 :         case MC_LS_SETUP_5_1_2:
     250        1788 :             audio_config = IVAS_AUDIO_CONFIG_5_1_2;
     251        1788 :             move32();
     252        1788 :             BREAK;
     253        1800 :         case MC_LS_SETUP_5_1_4:
     254        1800 :             audio_config = IVAS_AUDIO_CONFIG_5_1_4;
     255        1800 :             move32();
     256        1800 :             BREAK;
     257        6558 :         case MC_LS_SETUP_7_1_4:
     258        6558 :             audio_config = IVAS_AUDIO_CONFIG_7_1_4;
     259        6558 :             move32();
     260        6558 :             BREAK;
     261           0 :         default:
     262           0 :             assert( 0 && "MC loudspeaker setup is not valid!\n" );
     263             :     }
     264             : 
     265       96626 :     return audio_config;
     266             : }

Generated by: LCOV version 1.14