LCOV - code coverage report
Current view: top level - lib_com - ivas_omasa_com.c (source / functions) Hit Total Coverage
Test: Coverage on main @ 6baab0c613aa6c7100498ed7b93676aa8198a493 Lines: 171 176 97.2 %
Date: 2025-05-29 08:28:55 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     1565808 : 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     1565808 :     ISM_MODE ism_mode = ISM_MODE_NONE;
      79             : 
      80     1565808 :     switch ( nchan_ism )
      81             :     {
      82      261952 :         case 1:
      83      261952 :             if ( ivas_total_brate >= IVAS_24k4 )
      84             :             {
      85      248727 :                 ism_mode = ISM_MASA_MODE_DISC;
      86             :             }
      87             :             else
      88             :             {
      89       13225 :                 ism_mode = ISM_MODE_NONE;
      90             :             }
      91      261952 :             break;
      92      286026 :         case 2:
      93      286026 :             if ( ivas_total_brate >= IVAS_48k )
      94             :             {
      95      217454 :                 ism_mode = ISM_MASA_MODE_DISC;
      96             :             }
      97       68572 :             else if ( ivas_total_brate >= IVAS_32k )
      98             :             {
      99       52606 :                 ism_mode = ISM_MASA_MODE_PARAM_ONE_OBJ;
     100             :             }
     101             :             else
     102             :             {
     103       15966 :                 ism_mode = ISM_MODE_NONE;
     104             :             }
     105      286026 :             break;
     106      458624 :         case 3:
     107      458624 :             if ( ivas_total_brate >= IVAS_96k )
     108             :             {
     109      190404 :                 ism_mode = ISM_MASA_MODE_DISC;
     110             :             }
     111      268220 :             else if ( ivas_total_brate >= IVAS_64k )
     112             :             {
     113      110836 :                 ism_mode = ISM_MASA_MODE_PARAM_ONE_OBJ;
     114             :             }
     115      157384 :             else if ( ivas_total_brate >= IVAS_32k )
     116             :             {
     117      130548 :                 ism_mode = ISM_MASA_MODE_MASA_ONE_OBJ;
     118             :             }
     119             :             else
     120             :             {
     121       26836 :                 ism_mode = ISM_MODE_NONE;
     122             :             }
     123      458624 :             break;
     124      559206 :         case 4:
     125      559206 :             if ( ivas_total_brate >= IVAS_128k )
     126             :             {
     127      214041 :                 ism_mode = ISM_MASA_MODE_DISC;
     128             :             }
     129      345165 :             else if ( ivas_total_brate >= IVAS_64k )
     130             :             {
     131      154287 :                 ism_mode = ISM_MASA_MODE_PARAM_ONE_OBJ;
     132             :             }
     133      190878 :             else if ( ivas_total_brate >= IVAS_32k )
     134             :             {
     135      154838 :                 ism_mode = ISM_MASA_MODE_MASA_ONE_OBJ;
     136             :             }
     137             :             else
     138             :             {
     139       36040 :                 ism_mode = ISM_MODE_NONE;
     140             :             }
     141      559206 :             break;
     142             :     }
     143             : 
     144     1565808 :     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      103477 : 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      103477 :     switch ( ism_mode )
     162             :     {
     163       45389 :         case ISM_MASA_MODE_MASA_ONE_OBJ:
     164             :         case ISM_MASA_MODE_PARAM_ONE_OBJ:
     165       45389 :             *nCPE = 1;
     166       45389 :             *nSCE = 1;
     167       45389 :             break;
     168       29526 :         case ISM_MASA_MODE_DISC:
     169       29526 :             *nCPE = 1;
     170       29526 :             *nSCE = nchan_ism;
     171       29526 :             break;
     172       28562 :         case ISM_MODE_NONE:
     173       28562 :             *nCPE = 1;
     174       28562 :             *nSCE = 0;
     175       28562 :             break;
     176           0 :         default:
     177           0 :             break;
     178             :     }
     179             : 
     180      103477 :     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     1644324 : 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     1644324 :     nBits = (int16_t) ( element_brate / FRAMES_PER_SEC );
     203             : 
     204     1644324 :     if ( ism_imp == ISM_INACTIVE_IMP )
     205             :     {
     206       32155 :         nBits = BITS_ISM_INACTIVE;
     207             :     }
     208             :     else
     209             :     {
     210     1612169 :         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      202501 :             if ( limit_flag == 1 && ( ( nchan_ism == 4 && element_brate == 24000 ) || ( nchan_ism == 3 && element_brate == 20000 ) || ( nchan_ism == 2 && element_brate <= 11000 ) ) )
     213             :             {
     214      146758 :                 return element_brate;
     215             :             }
     216             : 
     217       55743 :             if ( ism_imp == ISM_LOW_IMP )
     218             :             {
     219        6283 :                 nBits = (int16_t) ( nBits * GAMMA_ISM_LOW_IMP4 );
     220             :             }
     221       49460 :             else if ( ism_imp == ISM_MEDIUM_IMP )
     222             :             {
     223       12490 :                 nBits = (int16_t) ( nBits * GAMMA_ISM_MEDIUM_IMP4 );
     224       12490 :                 if ( limit_flag == -1 )
     225             :                 {
     226           0 :                     nBits = (int16_t) ( nBits * GAMMA_ISM_HIGH_IMP4 );
     227             :                 }
     228             :             }
     229             :             else /* ISM_HIGH_IMP */
     230             :             {
     231       36970 :                 nBits = (int16_t) ( nBits * GAMMA_ISM_HIGH_IMP4 );
     232       36970 :                 if ( limit_flag == -1 )
     233             :                 {
     234          24 :                     nBits = (int16_t) ( nBits * GAMMA_ISM_HIGH_IMP4 );
     235             :                 }
     236             :             }
     237             :         }
     238     1409668 :         else if ( ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ||
     239     1000784 :                   ( ism_mode == ISM_MASA_MODE_DISC && element_brate == 9600 ) /* this condition corresponds to the ivas_total_brate = 24400 and 1 object */
     240             :         )
     241             :         {
     242      254178 :             if ( ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ && element_brate == IVAS_13k2 )
     243             :             {
     244       40447 :                 if ( ism_imp == ISM_LOW_IMP )
     245             :                 {
     246        3414 :                     nBits = (int16_t) ( nBits * GAMMA_ISM_LOW_IMP3 );
     247             :                 }
     248       37033 :                 else if ( ism_imp == ISM_MEDIUM_IMP )
     249             :                 {
     250        9005 :                     nBits = (int16_t) ( nBits * GAMMA_ISM_MEDIUM_IMP3 );
     251             :                 }
     252             :                 else /* ISM_HIGH_IMP */
     253             :                 {
     254       28028 :                     nBits = (int16_t) ( nBits * GAMMA_ISM_HIGH_IMP4 );
     255             :                 }
     256             :             }
     257             :             else
     258             :             {
     259      213731 :                 if ( ism_imp == ISM_LOW_IMP )
     260             :                 {
     261       19936 :                     nBits = (int16_t) ( nBits * GAMMA_ISM_LOW_IMP3 );
     262             :                 }
     263      193795 :                 else if ( ism_imp == ISM_MEDIUM_IMP )
     264             :                 {
     265       57487 :                     nBits = (int16_t) ( nBits * GAMMA_ISM_MEDIUM_IMP3 );
     266             :                 }
     267             :                 else /* ISM_HIGH_IMP */
     268             :                 {
     269      136308 :                     nBits = (int16_t) ( nBits * GAMMA_ISM_HIGH_IMP3 );
     270             :                 }
     271             :             }
     272             :         }
     273     1155490 :         else if ( ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ && element_brate == 16000 )
     274             :         {
     275       87467 :             if ( ism_imp == ISM_LOW_IMP )
     276             :             {
     277       10192 :                 nBits = (int16_t) ( nBits * GAMMA_ISM_LOW_IMP );
     278             :             }
     279       77275 :             else if ( ism_imp == ISM_MEDIUM_IMP )
     280             :             {
     281       24159 :                 nBits = (int16_t) ( nBits * GAMMA_ISM_MEDIUM_IMP );
     282             :             }
     283             :             else /* ISM_HIGH_IMP */
     284             :             {
     285       53116 :                 nBits = (int16_t) ( nBits * GAMMA_ISM_HIGH_IMP3 );
     286             :             }
     287             :         }
     288             :         else
     289             :         {
     290     1068023 :             if ( ism_imp == ISM_LOW_IMP )
     291             :             {
     292       81645 :                 nBits = (int16_t) ( nBits * GAMMA_ISM_LOW_IMP );
     293             :             }
     294      986378 :             else if ( ism_imp == ISM_MEDIUM_IMP )
     295             :             {
     296      265759 :                 nBits = (int16_t) ( nBits * GAMMA_ISM_MEDIUM_IMP );
     297             :             }
     298             :             else /* ISM_HIGH_IMP */
     299             :             {
     300      720619 :                 nBits = (int16_t) ( nBits * GAMMA_ISM_HIGH_IMP );
     301             :             }
     302             :         }
     303             :     }
     304             : 
     305     1497566 :     limit_low = MIN_BRATE_SWB_BWE / FRAMES_PER_SEC;
     306     1497566 :     if ( ism_imp == ISM_INACTIVE_IMP )
     307             :     {
     308       32155 :         limit_low = BITS_ISM_INACTIVE;
     309             :     }
     310     1465411 :     else if ( element_brate >= SCE_CORE_16k_LOW_LIMIT )
     311             :     {
     312     1093758 :         limit_low = SCE_CORE_16k_LOW_LIMIT / FRAMES_PER_SEC;
     313             :     }
     314             : 
     315     1497566 :     limit_high = IVAS_512k / FRAMES_PER_SEC;
     316     1497566 :     if ( element_brate < SCE_CORE_16k_LOW_LIMIT )
     317             :     {
     318      378692 :         limit_high = ACELP_12k8_HIGH_LIMIT / FRAMES_PER_SEC;
     319             :     }
     320             : 
     321     1497566 :     nBits = check_bounds_s( nBits, limit_low, limit_high );
     322             : 
     323     1497566 :     element_brate_out = nBits * FRAMES_PER_SEC;
     324             : 
     325     1497566 :     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       30918 : 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       30918 :     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       30918 :     if ( element_brate < ACELP_12k8_HIGH_LIMIT )
     354             :     {
     355       14353 :         limit_high = ACELP_12k8_HIGH_LIMIT / FRAMES_PER_SEC;
     356       14353 :         nBits = (int16_t) ( *core_brate / FRAMES_PER_SEC );
     357             : 
     358       14353 :         *diff_nBits = nBits - limit_high;
     359       14353 :         if ( *diff_nBits > 0 )
     360             :         {
     361        2438 :             if ( core == TCX_20_CORE || core == TCX_10_CORE )
     362             :             {
     363        2010 :                 *diff_nBits = 0;
     364             :             }
     365             :             else /* ACELP core */
     366             :             {
     367         428 :                 *core_brate -= ( *diff_nBits * FRAMES_PER_SEC );
     368             :             }
     369             :         }
     370             :     }
     371             : 
     372             :     /*-----------------------------------------------------------------*
     373             :      * set inactive coder_type flag in ACELP core
     374             :      *-----------------------------------------------------------------*/
     375             : 
     376       30918 :     if ( core == ACELP_CORE )
     377             :     {
     378       11795 :         *inactive_coder_type_flag = 0; /* AVQ by default */
     379       11795 :         if ( *core_brate + brate_diff <= MAX_GSC_INACTIVE_BRATE )
     380             :         {
     381        8183 :             *inactive_coder_type_flag = 1; /* GSC */
     382             :         }
     383             :     }
     384             : 
     385       30918 :     return;
     386             : }
     387             : 
     388             : 
     389             : /*---------------------------------------------------------------
     390             :  * bits_index_ism_ratio()
     391             :  *
     392             :  *
     393             :  * ---------------------------------------------------------------*/
     394             : 
     395             : /*!r : number of bits for ISM ratio index */
     396      153446 : 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      153446 :     bits_index = 0;
     403      153446 :     if ( nchan_ism == 2 )
     404             :     {
     405       23402 :         bits_index = 3;
     406             :     }
     407      130044 :     else if ( nchan_ism == 3 )
     408             :     {
     409       52692 :         bits_index = 6;
     410             :     }
     411       77352 :     else if ( nchan_ism == 4 )
     412             :     {
     413       77352 :         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      153446 :     return bits_index;
     421             : }
     422             : 
     423             : 
     424             : /*---------------------------------------------------------------
     425             :  * calculate_nbits_meta()
     426             :  *
     427             :  *
     428             :  * ---------------------------------------------------------------*/
     429             : 
     430      178094 : 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      178094 :     if ( nchan_ism > 1 )
     444             :     {
     445      178094 :         set_f( priority, 0.0f, nchan_ism );
     446      674326 :         for ( sf = 0; sf < numSf; sf++ )
     447             :         {
     448     3260452 :             for ( band = 0; band < numCodingBands; band++ )
     449             :             {
     450    12442428 :                 for ( obj = 0; obj < nchan_ism; obj++ )
     451             :                 {
     452     9678208 :                     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      178094 :     maximum( priority, nchan_ism, &max_p );
     464      769516 :     for ( obj = 0; obj < nchan_ism; obj++ )
     465             :     {
     466      591422 :         if ( obj == idx_sep_obj )
     467             :         {
     468      178094 :             if ( ism_imp == 3 )
     469             :             {
     470      113236 :                 priority[obj] = 1;
     471             :             }
     472       64858 :             else if ( ism_imp == 2 )
     473             :             {
     474       45754 :                 priority[obj] = ( 1 + max_p ) * 0.5f;
     475             :             }
     476             :             else
     477             :             {
     478       19104 :                 priority[obj] = max_p;
     479             :             }
     480             :         }
     481      591422 :         bits_ism[obj] = bits_direction_masa[0] - (int16_t) ( ( 1 - ( (int16_t) ( priority[obj] * 1000.0f ) ) * 0.001f ) * 6 );
     482             :     }
     483             : 
     484      178094 :     return;
     485             : }
     486             : 
     487             : 
     488             : /*---------------------------------------------------------------
     489             :  * ivas_get_stereo_panning_gains()
     490             :  *
     491             :  *
     492             :  *---------------------------------------------------------------*/
     493             : 
     494     1771455 : 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     1771455 :     const float LsAngleRad = 30.0f * PI_OVER_180;
     502             :     /* Convert azi and ele to an azi value of the cone of confusion */
     503     1771455 :     aziRad = aziDeg * PI_OVER_180;
     504     1771455 :     eleRad = eleDeg * PI_OVER_180;
     505     1771455 :     y = ( sinf( aziRad ) * cosf( eleRad ) );
     506     1771455 :     mappedX = sqrtf( max( 0.0f, 1.0f - ( y * y ) ) );
     507     1771455 :     aziRadMapped = atan2f( y, mappedX );
     508             : 
     509     1771455 :     if ( aziRadMapped >= LsAngleRad )
     510             :     { /* Left side */
     511      373619 :         panningGains[0] = 1.0f;
     512      373619 :         panningGains[1] = 0.0f;
     513             :     }
     514     1397836 :     else if ( aziRadMapped <= -LsAngleRad )
     515             :     { /* Right side */
     516      367098 :         panningGains[0] = 0.0f;
     517      367098 :         panningGains[1] = 1.0f;
     518             :     }
     519             :     else /* Tangent panning law */
     520             :     {
     521     1030738 :         A = tanf( aziRadMapped ) / tanf( LsAngleRad );
     522     1030738 :         A2 = ( A - 1.0f ) / max( 0.001f, A + 1.0f );
     523     1030738 :         A3 = 1.0f / ( A2 * A2 + 1.0f );
     524     1030738 :         panningGains[0] = sqrtf( A3 );
     525     1030738 :         panningGains[1] = sqrtf( 1.0f - A3 );
     526             :     }
     527             : 
     528     1771455 :     return;
     529             : }
     530             : 
     531             : 
     532             : /*---------------------------------------------------------------
     533             :  * calculate_brate_limit_flag()
     534             :  *
     535             :  *
     536             :  *---------------------------------------------------------------*/
     537             : 
     538             : /*! r: limitation flag */
     539      569205 : 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      569205 :     brate_limit_flag = 0;
     549      569205 :     nzeros = 0;
     550     1860383 :     for ( n = 0; n < nchan_ism; n++ )
     551             :     {
     552     1291178 :         brate_limit_flag += ism_imp[n];
     553     1291178 :         if ( ism_imp[n] == 0 )
     554             :         {
     555       25449 :             nzeros++;
     556             :         }
     557             :     }
     558             : 
     559      569205 :     if ( brate_limit_flag >= (int16_t) ( nchan_ism * 2.5f ) )
     560             :     {
     561      484118 :         brate_limit_flag = 1;
     562             :     }
     563             :     else
     564             :     {
     565       85087 :         if ( nzeros / (float) nchan_ism >= 0.5f )
     566             :         {
     567        9507 :             brate_limit_flag = -1; /* there is no limitation, on the contrary */
     568             :         }
     569             :     }
     570             : 
     571      569205 :     return brate_limit_flag;
     572             : }

Generated by: LCOV version 1.14