LCOV - code coverage report
Current view: top level - lib_com - ivas_omasa_com.c (source / functions) Hit Total Coverage
Test: Coverage on main -- short test vectors @ 1ecb9137d23f3dad766c8f6f3eb1e829e795f071 Lines: 163 176 92.6 %
Date: 2025-10-29 06:44:26 Functions: 8 8 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 "options.h"
      34             : #include <stdlib.h>
      35             : #include "ivas_cnst.h"
      36             : #include "ivas_prot.h"
      37             : #include "prot.h"
      38             : #include "ivas_rom_com.h"
      39             : #include <math.h>
      40             : #ifdef DEBUGGING
      41             : #include "debug.h"
      42             : #endif
      43             : 
      44             : /*---------------------------------------------------------------
      45             :  * Local constants
      46             :  *---------------------------------------------------------------*/
      47             : 
      48             : #define GAMMA_ISM_LOW_IMP    0.8f
      49             : #define GAMMA_ISM_MEDIUM_IMP 1.2f
      50             : #define GAMMA_ISM_HIGH_IMP   1.4f
      51             : 
      52             : #define GAMMA_ISM_LOW_IMP2    0.9f
      53             : #define GAMMA_ISM_MEDIUM_IMP2 1.2f
      54             : #define GAMMA_ISM_HIGH_IMP2   1.35f
      55             : 
      56             : #define GAMMA_ISM_LOW_IMP3    0.85f
      57             : #define GAMMA_ISM_MEDIUM_IMP3 1.15f
      58             : #define GAMMA_ISM_HIGH_IMP3   1.3f
      59             : 
      60             : #define GAMMA_ISM_LOW_IMP4    0.8f
      61             : #define GAMMA_ISM_MEDIUM_IMP4 1.0f
      62             : #define GAMMA_ISM_HIGH_IMP4   1.2f
      63             : 
      64             : 
      65             : /*---------------------------------------------------------------
      66             :  * ivas_omasa_ism_mode_select()
      67             :  *
      68             :  * selects the ISM mode base on IVAS total bit-rate and
      69             :  * the number of objects in the combined ISM MASA format mode
      70             :  * ---------------------------------------------------------------*/
      71             : 
      72             : /*! r : ISM format mode */
      73      948464 : ISM_MODE ivas_omasa_ism_mode_select(
      74             :     const int32_t ivas_total_brate, /* i  : IVAS total bitrate      */
      75             :     const int16_t nchan_ism         /* i  : number of input ISM's   */
      76             : )
      77             : {
      78      948464 :     ISM_MODE ism_mode = ISM_MODE_NONE;
      79             : 
      80      948464 :     switch ( nchan_ism )
      81             :     {
      82      274376 :         case 1:
      83      274376 :             if ( ivas_total_brate >= IVAS_24k4 )
      84             :             {
      85      265530 :                 ism_mode = ISM_MASA_MODE_DISC;
      86             :             }
      87             :             else
      88             :             {
      89        8846 :                 ism_mode = ISM_MODE_NONE;
      90             :             }
      91      274376 :             break;
      92      189150 :         case 2:
      93      189150 :             if ( ivas_total_brate >= IVAS_48k )
      94             :             {
      95      167354 :                 ism_mode = ISM_MASA_MODE_DISC;
      96             :             }
      97       21796 :             else if ( ivas_total_brate >= IVAS_32k )
      98             :             {
      99       19658 :                 ism_mode = ISM_MASA_MODE_PARAM_ONE_OBJ;
     100             :             }
     101             :             else
     102             :             {
     103        2138 :                 ism_mode = ISM_MODE_NONE;
     104             :             }
     105      189150 :             break;
     106      205946 :         case 3:
     107      205946 :             if ( ivas_total_brate >= IVAS_96k )
     108             :             {
     109      120034 :                 ism_mode = ISM_MASA_MODE_DISC;
     110             :             }
     111       85912 :             else if ( ivas_total_brate >= IVAS_64k )
     112             :             {
     113       40544 :                 ism_mode = ISM_MASA_MODE_PARAM_ONE_OBJ;
     114             :             }
     115       45368 :             else if ( ivas_total_brate >= IVAS_32k )
     116             :             {
     117       41980 :                 ism_mode = ISM_MASA_MODE_MASA_ONE_OBJ;
     118             :             }
     119             :             else
     120             :             {
     121        3388 :                 ism_mode = ISM_MODE_NONE;
     122             :             }
     123      205946 :             break;
     124      278992 :         case 4:
     125      278992 :             if ( ivas_total_brate >= IVAS_128k )
     126             :             {
     127      124806 :                 ism_mode = ISM_MASA_MODE_DISC;
     128             :             }
     129      154186 :             else if ( ivas_total_brate >= IVAS_64k )
     130             :             {
     131       80254 :                 ism_mode = ISM_MASA_MODE_PARAM_ONE_OBJ;
     132             :             }
     133       73932 :             else if ( ivas_total_brate >= IVAS_32k )
     134             :             {
     135       63410 :                 ism_mode = ISM_MASA_MODE_MASA_ONE_OBJ;
     136             :             }
     137             :             else
     138             :             {
     139       10522 :                 ism_mode = ISM_MODE_NONE;
     140             :             }
     141      278992 :             break;
     142             :     }
     143             : 
     144      948464 :     return ism_mode;
     145             : }
     146             : 
     147             : 
     148             : /*---------------------------------------------------------------
     149             :  * ivas_set_omasa_TC()
     150             :  *
     151             :  * set number of transport channels in OMASA format
     152             :  * ---------------------------------------------------------------*/
     153             : 
     154        9987 : void ivas_set_omasa_TC(
     155             :     const ISM_MODE ism_mode, /* i  : ISM mode                   */
     156             :     const int16_t nchan_ism, /* i  : number of input ISMs       */
     157             :     int16_t *nSCE,           /* o  : number of SCEs             */
     158             :     int16_t *nCPE            /* o  : number of CPEs             */
     159             : )
     160             : {
     161        9987 :     switch ( ism_mode )
     162             :     {
     163        3322 :         case ISM_MASA_MODE_MASA_ONE_OBJ:
     164             :         case ISM_MASA_MODE_PARAM_ONE_OBJ:
     165        3322 :             *nCPE = 1;
     166        3322 :             *nSCE = 1;
     167        3322 :             break;
     168        3829 :         case ISM_MASA_MODE_DISC:
     169        3829 :             *nCPE = 1;
     170        3829 :             *nSCE = nchan_ism;
     171        3829 :             break;
     172        2836 :         case ISM_MODE_NONE:
     173        2836 :             *nCPE = 1;
     174        2836 :             *nSCE = 0;
     175        2836 :             break;
     176           0 :         default:
     177           0 :             break;
     178             :     }
     179             : 
     180        9987 :     return;
     181             : }
     182             : 
     183             : 
     184             : /*---------------------------------------------------------------
     185             :  * ivas_interformat_brate()
     186             :  *
     187             :  * Bit-budget distribution in case of combined-format coding
     188             :  * ---------------------------------------------------------------*/
     189             : 
     190             : /*! r: adjusted bitrate */
     191      987935 : int32_t ivas_interformat_brate(
     192             :     const ISM_MODE ism_mode,     /* i  : ISM mode                           */
     193             :     const int16_t nchan_ism,     /* i  : number of ISM channels             */
     194             :     const int32_t element_brate, /* i  : element bitrate                    */
     195             :     const int16_t ism_imp,       /* i  : ISM importance flag                */
     196             :     const int16_t limit_flag     /* i  : flag to limit the bitrate increase */
     197             : )
     198             : {
     199             :     int32_t element_brate_out;
     200             :     int16_t nBits, limit_low, limit_high;
     201             : 
     202      987935 :     nBits = (int16_t) ( element_brate / FRAMES_PER_SEC );
     203             : 
     204      987935 :     if ( ism_imp == ISM_INACTIVE_IMP )
     205             :     {
     206           0 :         nBits = BITS_ISM_INACTIVE;
     207             :     }
     208             :     else
     209             :     {
     210      987935 :         if ( ism_mode == ISM_MASA_MODE_DISC && ( ( nchan_ism == 4 && element_brate == 24000 ) || ( nchan_ism == 3 && element_brate <= 24000 ) || ( nchan_ism == 2 && element_brate <= 11000 ) ) ) /* for border case in DISC mode */
     211             :         {
     212      121400 :             if ( limit_flag == 1 && ( ( nchan_ism == 4 && element_brate == 24000 ) || ( nchan_ism == 3 && element_brate == 20000 ) || ( nchan_ism == 2 && element_brate <= 11000 ) ) )
     213             :             {
     214       79444 :                 return element_brate;
     215             :             }
     216             : 
     217       41956 :             if ( ism_imp == ISM_LOW_IMP )
     218             :             {
     219        4179 :                 nBits = (int16_t) ( nBits * GAMMA_ISM_LOW_IMP4 );
     220             :             }
     221       37777 :             else if ( ism_imp == ISM_MEDIUM_IMP )
     222             :             {
     223        9687 :                 nBits = (int16_t) ( nBits * GAMMA_ISM_MEDIUM_IMP4 );
     224        9687 :                 if ( limit_flag == -1 )
     225             :                 {
     226           0 :                     nBits = (int16_t) ( nBits * GAMMA_ISM_HIGH_IMP4 );
     227             :                 }
     228             :             }
     229             :             else /* ISM_HIGH_IMP */
     230             :             {
     231       28090 :                 nBits = (int16_t) ( nBits * GAMMA_ISM_HIGH_IMP4 );
     232       28090 :                 if ( limit_flag == -1 )
     233             :                 {
     234           0 :                     nBits = (int16_t) ( nBits * GAMMA_ISM_HIGH_IMP4 );
     235             :                 }
     236             :             }
     237             :         }
     238      866535 :         else if ( ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ||
     239      714066 :                   ( ism_mode == ISM_MASA_MODE_DISC && element_brate == 9600 ) /* this condition corresponds to the ivas_total_brate = 24400 and 1 object */
     240             :         )
     241             :         {
     242      101220 :             if ( ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ && element_brate == IVAS_13k2 )
     243             :             {
     244       11669 :                 if ( ism_imp == ISM_LOW_IMP )
     245             :                 {
     246         649 :                     nBits = (int16_t) ( nBits * GAMMA_ISM_LOW_IMP3 );
     247             :                 }
     248       11020 :                 else if ( ism_imp == ISM_MEDIUM_IMP )
     249             :                 {
     250        2335 :                     nBits = (int16_t) ( nBits * GAMMA_ISM_MEDIUM_IMP3 );
     251             :                 }
     252             :                 else /* ISM_HIGH_IMP */
     253             :                 {
     254        8685 :                     nBits = (int16_t) ( nBits * GAMMA_ISM_HIGH_IMP4 );
     255             :                 }
     256             :             }
     257             :             else
     258             :             {
     259       89551 :                 if ( ism_imp == ISM_LOW_IMP )
     260             :                 {
     261        4408 :                     nBits = (int16_t) ( nBits * GAMMA_ISM_LOW_IMP3 );
     262             :                 }
     263       85143 :                 else if ( ism_imp == ISM_MEDIUM_IMP )
     264             :                 {
     265       18831 :                     nBits = (int16_t) ( nBits * GAMMA_ISM_MEDIUM_IMP3 );
     266             :                 }
     267             :                 else /* ISM_HIGH_IMP */
     268             :                 {
     269       66312 :                     nBits = (int16_t) ( nBits * GAMMA_ISM_HIGH_IMP3 );
     270             :                 }
     271             :             }
     272             :         }
     273      765315 :         else if ( ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ && element_brate == 16000 )
     274             :         {
     275       22893 :             if ( ism_imp == ISM_LOW_IMP )
     276             :             {
     277        1268 :                 nBits = (int16_t) ( nBits * GAMMA_ISM_LOW_IMP );
     278             :             }
     279       21625 :             else if ( ism_imp == ISM_MEDIUM_IMP )
     280             :             {
     281        4984 :                 nBits = (int16_t) ( nBits * GAMMA_ISM_MEDIUM_IMP );
     282             :             }
     283             :             else /* ISM_HIGH_IMP */
     284             :             {
     285       16641 :                 nBits = (int16_t) ( nBits * GAMMA_ISM_HIGH_IMP3 );
     286             :             }
     287             :         }
     288             :         else
     289             :         {
     290      742422 :             if ( ism_imp == ISM_LOW_IMP )
     291             :             {
     292       47621 :                 nBits = (int16_t) ( nBits * GAMMA_ISM_LOW_IMP );
     293             :             }
     294      694801 :             else if ( ism_imp == ISM_MEDIUM_IMP )
     295             :             {
     296      200103 :                 nBits = (int16_t) ( nBits * GAMMA_ISM_MEDIUM_IMP );
     297             :             }
     298             :             else /* ISM_HIGH_IMP */
     299             :             {
     300      494698 :                 nBits = (int16_t) ( nBits * GAMMA_ISM_HIGH_IMP );
     301             :             }
     302             :         }
     303             :     }
     304             : 
     305      908491 :     limit_low = MIN_BRATE_SWB_BWE / FRAMES_PER_SEC;
     306      908491 :     if ( ism_imp == ISM_INACTIVE_IMP )
     307             :     {
     308           0 :         limit_low = BITS_ISM_INACTIVE;
     309             :     }
     310      908491 :     else if ( element_brate >= SCE_CORE_16k_LOW_LIMIT )
     311             :     {
     312      719460 :         limit_low = SCE_CORE_16k_LOW_LIMIT / FRAMES_PER_SEC;
     313             :     }
     314             : 
     315      908491 :     limit_high = IVAS_512k / FRAMES_PER_SEC;
     316      908491 :     if ( element_brate < SCE_CORE_16k_LOW_LIMIT )
     317             :     {
     318      189031 :         limit_high = ACELP_12k8_HIGH_LIMIT / FRAMES_PER_SEC;
     319             :     }
     320             : 
     321      908491 :     nBits = check_bounds_s( nBits, limit_low, limit_high );
     322             : 
     323      908491 :     element_brate_out = nBits * FRAMES_PER_SEC;
     324             : 
     325      908491 :     return element_brate_out;
     326             : }
     327             : 
     328             : 
     329             : /*---------------------------------------------------------------
     330             :  * ivas_combined_format_brate_sanity()
     331             :  *
     332             :  * Sanity check in combined format coding
     333             :  * ---------------------------------------------------------------*/
     334             : 
     335        7221 : void ivas_combined_format_brate_sanity(
     336             :     const int32_t element_brate,       /* i  : element bitrate                */
     337             :     const int16_t core,                /* i  : core                           */
     338             :     const int32_t total_brate,         /* i  : total bitrate                  */
     339             :     int32_t *core_brate,               /* i/o: core bitrate                   */
     340             :     int16_t *inactive_coder_type_flag, /* o  : inactive coder_type flag       */
     341             :     int16_t *diff_nBits                /* o  : number of differential bits    */
     342             : )
     343             : {
     344             :     int16_t limit_high, nBits;
     345             :     int32_t brate_diff;
     346             : 
     347        7221 :     brate_diff = total_brate - *core_brate;
     348             : 
     349             :     /* sanity check: at lowest IVAS bit-rates and one ISM channel coded by
     350             :     low-rate core-coder mode, it can happen that the CPE (MASA) bit-budget
     351             :     for ACELP core-coding @12.8 kHz is too high */
     352             : 
     353        7221 :     if ( element_brate < ACELP_12k8_HIGH_LIMIT )
     354             :     {
     355        3978 :         limit_high = ACELP_12k8_HIGH_LIMIT / FRAMES_PER_SEC;
     356        3978 :         nBits = (int16_t) ( *core_brate / FRAMES_PER_SEC );
     357             : 
     358        3978 :         *diff_nBits = nBits - limit_high;
     359        3978 :         if ( *diff_nBits > 0 )
     360             :         {
     361           0 :             if ( core == TCX_20_CORE || core == TCX_10_CORE )
     362             :             {
     363           0 :                 *diff_nBits = 0;
     364             :             }
     365             :             else /* ACELP core */
     366             :             {
     367           0 :                 *core_brate -= ( *diff_nBits * FRAMES_PER_SEC );
     368             :             }
     369             :         }
     370             :     }
     371             : 
     372             :     /*-----------------------------------------------------------------*
     373             :      * set inactive coder_type flag in ACELP core
     374             :      *-----------------------------------------------------------------*/
     375             : 
     376        7221 :     if ( core == ACELP_CORE )
     377             :     {
     378        4289 :         *inactive_coder_type_flag = 0; /* AVQ by default */
     379        4289 :         if ( *core_brate + brate_diff <= MAX_GSC_INACTIVE_BRATE )
     380             :         {
     381        3189 :             *inactive_coder_type_flag = 1; /* GSC */
     382             :         }
     383             :     }
     384             : 
     385        7221 :     return;
     386             : }
     387             : 
     388             : 
     389             : /*---------------------------------------------------------------
     390             :  * bits_index_ism_ratio()
     391             :  *
     392             :  *
     393             :  * ---------------------------------------------------------------*/
     394             : 
     395             : /*!r : number of bits for ISM ratio index */
     396       73749 : int16_t bits_index_ism_ratio(
     397             :     const int16_t nchan_ism /* i  : number of objects    */
     398             : )
     399             : {
     400             :     int16_t bits_index;
     401             : 
     402       73749 :     bits_index = 0;
     403       73749 :     if ( nchan_ism == 2 )
     404             :     {
     405        9626 :         bits_index = 3;
     406             :     }
     407       64123 :     else if ( nchan_ism == 3 )
     408             :     {
     409       20380 :         bits_index = 6;
     410             :     }
     411       43743 :     else if ( nchan_ism == 4 )
     412             :     {
     413       43743 :         bits_index = 7;
     414             :     }
     415             :     else
     416             :     {
     417           0 :         assert( ( nchan_ism >= 2 && nchan_ism <= 4 ) && "Wrong number of objects for MASA_ISM." );
     418             :     }
     419             : 
     420       73749 :     return bits_index;
     421             : }
     422             : 
     423             : 
     424             : /*---------------------------------------------------------------
     425             :  * calculate_nbits_meta()
     426             :  *
     427             :  *
     428             :  * ---------------------------------------------------------------*/
     429             : 
     430       74520 : void calculate_nbits_meta(
     431             :     const int16_t nchan_ism,
     432             :     float q_energy_ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS],
     433             :     float masa_to_total_energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS],
     434             :     const int16_t numSf,
     435             :     const int16_t numCodingBands,
     436             :     int16_t *bits_ism,
     437             :     const int16_t idx_sep_obj,
     438             :     const int16_t ism_imp )
     439             : {
     440             :     int16_t sf, band, obj;
     441             :     float priority[MAX_NUM_OBJECTS], max_p;
     442             : 
     443       74520 :     if ( nchan_ism > 1 )
     444             :     {
     445       74520 :         set_f( priority, 0.0f, nchan_ism );
     446      341205 :         for ( sf = 0; sf < numSf; sf++ )
     447             :         {
     448     1594044 :             for ( band = 0; band < numCodingBands; band++ )
     449             :             {
     450     6135197 :                 for ( obj = 0; obj < nchan_ism; obj++ )
     451             :                 {
     452     4807838 :                     priority[obj] = max( priority[obj], ( q_energy_ratio_ism[sf][band][obj] * ( 1 - masa_to_total_energy_ratio[sf][band] ) ) );
     453             :                 }
     454             :             }
     455             :         }
     456             :     }
     457             :     else
     458             :     {
     459           0 :         priority[0] = 1;
     460             :     }
     461             : 
     462             :     /* decide parameters for ISM metadata quantization */
     463       74520 :     maximum( priority, nchan_ism, &max_p );
     464      332156 :     for ( obj = 0; obj < nchan_ism; obj++ )
     465             :     {
     466      257636 :         if ( obj == idx_sep_obj )
     467             :         {
     468       74520 :             if ( ism_imp == 3 )
     469             :             {
     470       54627 :                 priority[obj] = 1;
     471             :             }
     472       19893 :             else if ( ism_imp == 2 )
     473             :             {
     474       15789 :                 priority[obj] = ( 1 + max_p ) * 0.5f;
     475             :             }
     476             :             else
     477             :             {
     478        4104 :                 priority[obj] = max_p;
     479             :             }
     480             :         }
     481      257636 :         bits_ism[obj] = bits_direction_masa[0] - (int16_t) ( ( 1 - ( (int16_t) ( priority[obj] * 1000.0f ) ) * 0.001f ) * 6 );
     482             :     }
     483             : 
     484       74520 :     return;
     485             : }
     486             : 
     487             : 
     488             : /*---------------------------------------------------------------
     489             :  * ivas_get_stereo_panning_gains()
     490             :  *
     491             :  *
     492             :  *---------------------------------------------------------------*/
     493             : 
     494      474120 : void ivas_get_stereo_panning_gains(
     495             :     const float aziDeg,
     496             :     const float eleDeg,
     497             :     float panningGains[2] )
     498             : {
     499             :     float aziRad, eleRad;
     500             :     float y, mappedX, aziRadMapped, A, A2, A3;
     501      474120 :     const float LsAngleRad = 30.0f * PI_OVER_180;
     502             :     /* Convert azi and ele to an azi value of the cone of confusion */
     503      474120 :     aziRad = aziDeg * PI_OVER_180;
     504      474120 :     eleRad = eleDeg * PI_OVER_180;
     505      474120 :     y = ( sinf( aziRad ) * cosf( eleRad ) );
     506      474120 :     mappedX = sqrtf( max( 0.0f, 1.0f - ( y * y ) ) );
     507      474120 :     aziRadMapped = atan2f( y, mappedX );
     508             : 
     509      474120 :     if ( aziRadMapped >= LsAngleRad )
     510             :     { /* Left side */
     511       77233 :         panningGains[0] = 1.0f;
     512       77233 :         panningGains[1] = 0.0f;
     513             :     }
     514      396887 :     else if ( aziRadMapped <= -LsAngleRad )
     515             :     { /* Right side */
     516       68354 :         panningGains[0] = 0.0f;
     517       68354 :         panningGains[1] = 1.0f;
     518             :     }
     519             :     else /* Tangent panning law */
     520             :     {
     521      328533 :         A = tanf( aziRadMapped ) / tanf( LsAngleRad );
     522      328533 :         A2 = ( A - 1.0f ) / max( 0.001f, A + 1.0f );
     523      328533 :         A3 = 1.0f / ( A2 * A2 + 1.0f );
     524      328533 :         panningGains[0] = sqrtf( A3 );
     525      328533 :         panningGains[1] = sqrtf( 1.0f - A3 );
     526             :     }
     527             : 
     528      474120 :     return;
     529             : }
     530             : 
     531             : 
     532             : /*---------------------------------------------------------------
     533             :  * calculate_brate_limit_flag()
     534             :  *
     535             :  *
     536             :  *---------------------------------------------------------------*/
     537             : 
     538             : /*! r: limitation flag */
     539      400635 : int16_t calculate_brate_limit_flag(
     540             :     const int16_t ism_imp[], /* i  : ISM importance flags   */
     541             :     const int16_t nchan_ism  /* i  : number of objects      */
     542             : )
     543             : {
     544             :     int16_t n;
     545             :     int16_t brate_limit_flag;
     546             :     int16_t nzeros;
     547             : 
     548      400635 :     brate_limit_flag = 0;
     549      400635 :     nzeros = 0;
     550     1246531 :     for ( n = 0; n < nchan_ism; n++ )
     551             :     {
     552      845896 :         brate_limit_flag += ism_imp[n];
     553      845896 :         if ( ism_imp[n] == 0 )
     554             :         {
     555           0 :             nzeros++;
     556             :         }
     557             :     }
     558             : 
     559      400635 :     if ( brate_limit_flag >= (int16_t) ( nchan_ism * 2.5f ) )
     560             :     {
     561      352102 :         brate_limit_flag = 1;
     562             :     }
     563             :     else
     564             :     {
     565       48533 :         if ( nzeros / (float) nchan_ism >= 0.5f )
     566             :         {
     567           0 :             brate_limit_flag = -1; /* there is no limitation, on the contrary */
     568             :         }
     569             :     }
     570             : 
     571      400635 :     return brate_limit_flag;
     572             : }

Generated by: LCOV version 1.14