LCOV - code coverage report
Current view: top level - lib_com - enh1632.h (source / functions) Hit Total Coverage
Test: Coverage on main -- short test vectors @ 6c9ddc4024a9c0e1ecb8f643f114a84a0e26ec6b Lines: 32 38 84.2 %
Date: 2025-05-23 08:37:30 Functions: 8 10 80.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             : /*
      34             :   ===========================================================================
      35             :    File: ENH1632.H                                       v.2.3 - 30.Nov.2009
      36             :   ===========================================================================
      37             : 
      38             :             ITU-T        STL        BASIC       OPERATORS
      39             : 
      40             :             ENHANCED 16-BIT & 32-BIT ARITHMETIC OPERATORS
      41             : 
      42             :    History:
      43             :    07 Nov 04   v2.0     Incorporation of new 32-bit / 40-bit / control
      44             :                         operators for the ITU-T Standard Tool Library as
      45             :                         described in Geneva, 20-30 January 2004 WP 3/16 Q10/16
      46             :                         TD 11 document and subsequent discussions on the
      47             :                         wp3audio@yahoogroups.com email reflector.
      48             :    March 06   v2.1      Changed to improve portability.
      49             :                         Some counters incrementations were missing (s_and,
      50             :                         s_or, s_xor).
      51             :    30 Nov 09   v2.3     saturate() removed
      52             : 
      53             :   ============================================================================
      54             : */
      55             : 
      56             : 
      57             : #ifndef _ENH1632_H
      58             : #define _ENH1632_H
      59             : 
      60             : 
      61             : /*****************************************************************************
      62             :  *
      63             :  *  Constants and Globals
      64             :  *
      65             :  *****************************************************************************/
      66             : 
      67             : 
      68             : #include "stl.h"
      69             : 
      70             : 
      71             : /*****************************************************************************
      72             :  *
      73             :  *  Prototypes for enhanced 16/32 bit arithmetic operators
      74             :  *
      75             :  *****************************************************************************/
      76             : Word16 shl_r( Word16 var1, Word16 var2 );
      77             : Word32 L_shl_r( Word32 L_var1, Word16 var2 );
      78             : 
      79             : 
      80             : Word16 lshl( Word16 var1, Word16 var2 );
      81             : Word16 lshr( Word16 var1, Word16 var2 );
      82             : Word32 L_lshl( Word32 L_var1, Word16 var2 );
      83             : Word32 L_lshr( Word32 L_var1, Word16 var2 );
      84             : 
      85             : Word16 rotr( Word16 var1, Word16 var2, Word16 *var3 );
      86             : Word16 rotl( Word16 var1, Word16 var2, Word16 *var3 );
      87             : Word32 L_rotr( Word32 var1, Word16 var2, Word16 *var3 );
      88             : Word32 L_rotl( Word32 var1, Word16 var2, Word16 *var3 );
      89             : 
      90             : 
      91             : /*****************************************************************************
      92             :  *
      93             :  *  Functions
      94             :  *
      95             :  *****************************************************************************/
      96             : 
      97             : /*****************************************************************************
      98             :  *
      99             :  *  Function Name : s_max
     100             :  *
     101             :  *  Purpose :
     102             :  *
     103             :  *    Compares var1 and var2 and returns the maximum value.
     104             :  *
     105             :  *  Complexity weight : 1
     106             :  *
     107             :  *  Inputs :
     108             :  *
     109             :  *    var1        16 bit short signed integer (Word16) whose value falls in
     110             :  *                the range : 0x8000 <= var1 <= 0x7fff.
     111             :  *
     112             :  *    var2        16 bit short signed integer (Word16) whose value falls in
     113             :  *                the range : 0x8000 <= var2 <= 0x7fff.
     114             :  *
     115             :  *  Outputs :
     116             :  *
     117             :  *    none
     118             :  *
     119             :  *  Return Value :
     120             :  *
     121             :  *    var_out     16 bit short signed integer (Word16) whose value falls in
     122             :  *                the range : 0x8000 <= L_var_out <= 0x7fff.
     123             :  *
     124             :  *****************************************************************************/
     125     9606888 : static __inline Word16 s_max( Word16 var1, Word16 var2 )
     126             : {
     127             :     Word16 var_out;
     128             : 
     129     9606888 :     if ( var1 >= var2 )
     130     8412106 :         var_out = var1;
     131             :     else
     132     1194782 :         var_out = var2;
     133             : 
     134             : #ifdef WMOPS
     135             :     multiCounter[currCounter].s_max++;
     136             : #endif
     137             : 
     138     9606888 :     return ( var_out );
     139             : }
     140             : 
     141             : 
     142             : /*****************************************************************************
     143             :  *
     144             :  *  Function Name : s_min
     145             :  *
     146             :  *  Purpose :
     147             :  *
     148             :  *    Compares var1 and var2 and returns the minimum value.
     149             :  *
     150             :  *  Complexity weight : 1
     151             :  *
     152             :  *  Inputs :
     153             :  *
     154             :  *    var1        16 bit short signed integer (Word16) whose value falls in
     155             :  *                the range : 0x8000  <= var1 <= 0x7fff.
     156             :  *
     157             :  *    var2        16 bit short signed integer (Word16) whose value falls in
     158             :  *                the range : 0x8000  <= var2 <= 0x7fff.
     159             :  *
     160             :  *  Outputs :
     161             :  *
     162             :  *    none
     163             :  *
     164             :  *  Return Value :
     165             :  *
     166             :  *    var_out     16 bit short signed integer (Word16) whose value falls in
     167             :  *                the range : 0x8000 <= var_out <= 0x7fff.
     168             :  *
     169             :  *****************************************************************************/
     170     7047209 : static __inline Word16 s_min( Word16 var1, Word16 var2 )
     171             : {
     172             :     Word16 var_out;
     173             : 
     174     7047209 :     if ( var1 <= var2 )
     175     5543670 :         var_out = var1;
     176             :     else
     177     1503539 :         var_out = var2;
     178             : 
     179             : #ifdef WMOPS
     180             :     multiCounter[currCounter].s_min++;
     181             : #endif
     182             : 
     183     7047209 :     return ( var_out );
     184             : }
     185             : 
     186             : 
     187             : /*****************************************************************************
     188             :  *
     189             :  *  Function Name : L_max
     190             :  *
     191             :  *  Purpose :
     192             :  *
     193             :  *    Compares L_var1 and L_var2 and returns the maximum value.
     194             :  *
     195             :  *  Complexity weight : 1
     196             :  *
     197             :  *  Inputs :
     198             :  *
     199             :  *    L_var1      32 bit long signed integer (Word32) whose value falls in the
     200             :  *                range : 0x8000 0000  <= L_var1 <= 0x7fff ffff.
     201             :  *
     202             :  *    L_var2      32 bit long signed integer (Word32) whose value falls in the
     203             :  *                range : 0x8000 0000  <= L_var2 <= 0x7fff ffff.
     204             :  *
     205             :  *  Outputs :
     206             :  *
     207             :  *    none
     208             :  *
     209             :  *  Return Value :
     210             :  *
     211             :  *    L_var_out   32 bit long signed integer (Word32) whose value falls in the
     212             :  *                range : 0x8000 0000 <= L_var_out <= 0x7fff ffff.
     213             :  *
     214             :  *****************************************************************************/
     215    56288835 : static __inline Word32 L_max( Word32 L_var1, Word32 L_var2 )
     216             : {
     217             :     Word32 L_var_out;
     218             : 
     219    56288835 :     if ( L_var1 >= L_var2 )
     220    41376263 :         L_var_out = L_var1;
     221             :     else
     222    14912572 :         L_var_out = L_var2;
     223             : 
     224             : #ifdef WMOPS
     225             :     multiCounter[currCounter].L_max++;
     226             : #endif
     227             : 
     228    56288835 :     return ( L_var_out );
     229             : }
     230             : 
     231             : 
     232             : /*****************************************************************************
     233             :  *
     234             :  *  Function Name : L_min
     235             :  *
     236             :  *  Purpose :
     237             :  *
     238             :  *    Compares L_var1 and L_var2 and returns the minimum value.
     239             :  *
     240             :  *  Complexity weight : 1
     241             :  *
     242             :  *  Inputs :
     243             :  *
     244             :  *    L_var1      32 bit long signed integer (Word32) whose value falls in the
     245             :  *                range : 0x8000 0000  <= L_var1 <= 0x7fff ffff.
     246             :  *
     247             :  *    L_var2      32 bit long signed integer (Word32) whose value falls in the
     248             :  *                range : 0x8000 0000  <= L_var2 <= 0x7fff ffff.
     249             :  *
     250             :  *  Outputs :
     251             :  *
     252             :  *    none
     253             :  *
     254             :  *  Return Value :
     255             :  *
     256             :  *    L_var_out   32 bit long signed integer (Word32) whose value falls in the
     257             :  *                range : 0x8000 0000 <= L_var_out <= 0x7fff ffff.
     258             :  *
     259             :  *****************************************************************************/
     260    43078452 : static __inline Word32 L_min( Word32 L_var1, Word32 L_var2 )
     261             : {
     262             :     Word32 L_var_out;
     263             : 
     264    43078452 :     if ( L_var1 <= L_var2 )
     265    42295364 :         L_var_out = L_var1;
     266             :     else
     267      783088 :         L_var_out = L_var2;
     268             : 
     269             : #ifdef WMOPS
     270             :     multiCounter[currCounter].L_min++;
     271             : #endif
     272             : 
     273    43078452 :     return ( L_var_out );
     274             : }
     275             : 
     276             : 
     277             : /*****************************************************************************
     278             :  *
     279             :  *  Function Name : s_and
     280             :  *
     281             :  *  Purpose :
     282             :  *
     283             :  *    Performs logical AND of the two 16 bit input variables.
     284             :  *    var_out = var1 & var2
     285             :  *
     286             :  *  Complexity weight : 1
     287             :  *
     288             :  *  Inputs :
     289             :  *
     290             :  *    var1        16 bit short signed integer (Word16) whose value
     291             :  *                falls in the range 0xffff 8000 <= var1 <= 0x0000 7fff.
     292             :  *
     293             :  *    var2        16 bit short signed integer (Word16) whose value
     294             :  *                falls in the range 0xffff 8000 <= var2 <= 0x0000 7fff.
     295             :  *
     296             :  *  Outputs :
     297             :  *
     298             :  *    none
     299             :  *
     300             :  *  Return Value :
     301             :  *
     302             :  *    var_out     16 bit short signed integer (Word16) whose value
     303             :  *                falls in the range 0xffff 8000 <= var_out <= 0x0000 7fff.
     304             :  *
     305             :  *****************************************************************************/
     306   210067305 : static __inline Word16 s_and( Word16 var1, Word16 var2 )
     307             : {
     308             :     Word16 var_out;
     309             : 
     310   210067305 :     var_out = var1 & var2;
     311             : 
     312             : #ifdef WMOPS
     313             :     multiCounter[currCounter].s_and++;
     314             : #endif
     315             : 
     316   210067305 :     return ( var_out );
     317             : }
     318             : 
     319             : 
     320             : /*****************************************************************************
     321             :  *
     322             :  *  Function Name : L_and
     323             :  *
     324             :  *  Purpose :
     325             :  *
     326             :  *    Performs logical AND of the two 32 bit input variables.
     327             :  *    L_var_out = L_var1 & L_var2
     328             :  *
     329             :  *  Complexity weight : 1
     330             :  *
     331             :  *  Inputs :
     332             :  *
     333             :  *    L_var1      32 bit long signed integer (Word32) whose value
     334             :  *                falls in the range 0x8000 0000 <= L_var1 <= 0x7fff ffff.
     335             :  *
     336             :  *    L_var2      32 bit long signed integer (Word32) whose value
     337             :  *                falls in the range 0x8000 0000 <= L_var2 <= 0x7fff ffff.
     338             :  *
     339             :  *  Outputs :
     340             :  *
     341             :  *    none
     342             :  *
     343             :  *  Return Value :
     344             :  *
     345             :  *    L_var_out   32 bit long signed integer (Word32) whose value
     346             :  *                falls in the range 0x8000 0000 <= L_var_out <= 0x7fff ffff.
     347             :  *
     348             :  *****************************************************************************/
     349     1267104 : static __inline Word32 L_and( Word32 L_var1, Word32 L_var2 )
     350             : {
     351             :     Word32 L_var_out;
     352             : 
     353     1267104 :     L_var_out = L_var1 & L_var2;
     354             : 
     355             : #ifdef WMOPS
     356             :     multiCounter[currCounter].L_and++;
     357             : #endif
     358             : 
     359     1267104 :     return ( L_var_out );
     360             : }
     361             : 
     362             : 
     363             : /*****************************************************************************
     364             :  *
     365             :  *  Function Name : s_or
     366             :  *
     367             :  *  Purpose :
     368             :  *
     369             :  *    Performs logical OR of the two 16 bit input variables.
     370             :  *    var_out = var1 | var2
     371             :  *
     372             :  *  Complexity weight : 1
     373             :  *
     374             :  *  Inputs :
     375             :  *
     376             :  *    var1        16 bit short signed integer (Word16) whose value
     377             :  *                falls in the range 0xffff 8000 <= var1 <= 0x0000 7fff.
     378             :  *
     379             :  *    var2        16 bit short signed integer (Word16) whose value
     380             :  *                falls in the range 0xffff 8000 <= var2 <= 0x0000 7fff.
     381             :  *
     382             :  *  Outputs :
     383             :  *
     384             :  *    none
     385             :  *
     386             :  *  Return Value :
     387             :  *
     388             :  *    var_out     16 bit short signed integer (Word16) whose value
     389             :  *                falls in the range 0xffff 8000 <= var_out <= 0x0000 7fff.
     390             :  *
     391             :  *****************************************************************************/
     392           0 : static __inline Word16 s_or( Word16 var1, Word16 var2 )
     393             : {
     394             :     Word16 var_out;
     395             : 
     396           0 :     var_out = var1 | var2;
     397             : 
     398             : #ifdef WMOPS
     399             :     multiCounter[currCounter].s_or++;
     400             : #endif
     401             : 
     402           0 :     return ( var_out );
     403             : }
     404             : 
     405             : 
     406             : /*****************************************************************************
     407             :  *
     408             :  *  Function Name : L_or
     409             :  *
     410             :  *  Purpose :
     411             :  *
     412             :  *    Performs logical OR of the two 32 bit input variables.
     413             :  *    L_var_out = L_var1 | L_var2
     414             :  *
     415             :  *  Complexity weight : 1
     416             :  *
     417             :  *  Inputs :
     418             :  *
     419             :  *    L_var1      32 bit long signed integer (Word32) whose value
     420             :  *                falls in the range 0x8000 0000 <= L_var1 <= 0x7fff ffff.
     421             :  *
     422             :  *    L_var2      32 bit long signed integer (Word32) whose value
     423             :  *                falls in the range 0x8000 0000 <= L_var2 <= 0x7fff ffff.
     424             :  *
     425             :  *  Outputs :
     426             :  *
     427             :  *    none
     428             :  *
     429             :  *  Return Value :
     430             :  *
     431             :  *    L_var_out   32 bit long signed integer (Word32) whose value
     432             :  *                falls in the range 0x8000 0000 <= L_var_out <= 0x7fff ffff.
     433             :  *
     434             :  *****************************************************************************/
     435           0 : static __inline Word32 L_or( Word32 L_var1, Word32 L_var2 )
     436             : {
     437             : 
     438             :     Word32 L_var_out;
     439             : 
     440           0 :     L_var_out = L_var1 | L_var2;
     441             : 
     442             : #ifdef WMOPS
     443             :     multiCounter[currCounter].L_or++;
     444             : #endif
     445             : 
     446           0 :     return ( L_var_out );
     447             : }
     448             : 
     449             : 
     450             : /*****************************************************************************
     451             :  *
     452             :  *  Function Name : s_xor
     453             :  *
     454             :  *  Purpose :
     455             :  *
     456             :  *    Performs logical XOR of the two 16 bit input variables.
     457             :  *    var_out = var1 ^ var2
     458             :  *
     459             :  *  Complexity weight : 1
     460             :  *
     461             :  *  Inputs :
     462             :  *
     463             :  *    var1        16 bit short signed integer (Word16) whose value
     464             :  *                falls in the range 0xffff 8000 <= var1 <= 0x0000 7fff.
     465             :  *
     466             :  *    var2        16 bit short signed integer (Word16) whose value
     467             :  *                falls in the range 0xffff 8000 <= var2 <= 0x0000 7fff.
     468             :  *
     469             :  *  Outputs :
     470             :  *
     471             :  *    none
     472             :  *
     473             :  *  Return Value :
     474             :  *
     475             :  *    var_out     16 bit short signed integer (Word16) whose value
     476             :  *                falls in the range 0xffff 8000 <= var_out <= 0x0000 7fff.
     477             :  *
     478             :  *****************************************************************************/
     479       10647 : static __inline Word16 s_xor( Word16 var1, Word16 var2 )
     480             : {
     481             :     Word16 var_out;
     482             : 
     483       10647 :     var_out = var1 ^ var2;
     484             : 
     485             : #ifdef WMOPS
     486             :     multiCounter[currCounter].s_xor++;
     487             : #endif
     488             : 
     489       10647 :     return ( var_out );
     490             : }
     491             : 
     492             : 
     493             : /*****************************************************************************
     494             :  *
     495             :  *  Function Name : L_xor
     496             :  *
     497             :  *  Purpose :
     498             :  *
     499             :  *    Performs logical OR of the two 32 bit input variables.
     500             :  *    L_var_out = L_var1 ^ L_var2
     501             :  *
     502             :  *  Complexity weight : 1
     503             :  *
     504             :  *  Inputs :
     505             :  *
     506             :  *    L_var1      32 bit long signed integer (Word32) whose value
     507             :  *                falls in the range 0x8000 0000 <= L_var1 <= 0x7fff ffff.
     508             :  *
     509             :  *    L_var2      32 bit long signed integer (Word32) whose value
     510             :  *                falls in the range 0x8000 0000 <= L_var2 <= 0x7fff ffff.
     511             :  *
     512             :  *  Outputs :
     513             :  *
     514             :  *    none
     515             :  *
     516             :  *  Return Value :
     517             :  *
     518             :  *    L_var_out   32 bit long signed integer (Word32) whose value
     519             :  *                falls in the range 0x8000 0000 <= L_var_out <= 0x7fff ffff.
     520             :  *
     521             :  *****************************************************************************/
     522       18693 : static __inline Word32 L_xor( Word32 L_var1, Word32 L_var2 )
     523             : {
     524             :     Word32 L_var_out;
     525             : 
     526       18693 :     L_var_out = L_var1 ^ L_var2;
     527             : 
     528             : #ifdef WMOPS
     529             :     multiCounter[currCounter].L_xor++;
     530             : #endif
     531             : 
     532       18693 :     return ( L_var_out );
     533             : }
     534             : 
     535             : 
     536             : #endif /*_ENH1632_H*/
     537             : 
     538             : /* end of file */

Generated by: LCOV version 1.14