LCOV - code coverage report
Current view: top level - lib_com - range_com_fx.c (source / functions) Hit Total Coverage
Test: Coverage on main enc/dec/rend @ 3b2f07138c61dcf997bbf4165d0882f794b2995f Lines: 25 25 100.0 %
Date: 2025-05-03 01:55:50 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /*====================================================================================
       2             :     EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
       3             :   ====================================================================================*/
       4             : 
       5             : #include <stdint.h>
       6             : #include "options.h" /* Compilation switches                   */
       7             : #include "cnst.h"    /* Common constants                       */
       8             : #include "prot_fx.h" /* Function prototypes                    */
       9             : 
      10             : /*-------------------------------------------------------------------*
      11             :  * rc_get_bits2()
      12             :  *
      13             :  *  Get number of bits needed to finalize range coder
      14             :  *-------------------------------------------------------------------*/
      15             : 
      16      515313 : Word16 rc_get_bits2_fx(                     /* o: Number of bits needed                         Q0*/
      17             :                         const Word16 N,     /* i: Number of bits currently used         Q0*/
      18             :                         const UWord32 range /* i: Range of range coder                          Q0*/
      19             : )
      20             : {
      21      515313 :     return add( add( N, 2 ), norm_ul( range ) );
      22             : }
      23             : 
      24             : /*-------------------------------------------------------------------*
      25             :  * rangeCoderFinalizationFBits()
      26             :  *
      27             :  * Fractional (Q3) bits for range coder finalization
      28             :  *-------------------------------------------------------------------*/
      29             : 
      30      686383 : void rangeCoderFinalizationFBits_fx(
      31             :     Word16 Brc,    /*  i  : Current number of decoded bits      Q0*/
      32             :     UWord32 INTrc, /*  i  : Range coder state                           Q0*/
      33             :     Word16 *FBits  /*  i  : Fractional finalization bits        Q0*/
      34             : )
      35             : {
      36             :     Word32 L_Bq15;
      37             :     UWord32 h, UL_tmp;
      38             :     UWord16 Bq15ui16, l;
      39             :     Word16 B, E, x, k;
      40      686383 :     *FBits = shl( add( Brc, 32 ), 3 ); /* Q0 */
      41             : 
      42      686383 :     B = sub( 30, norm_ul( INTrc ) ); /* Q0 */
      43      686383 :     x = sub( B, RCF_INIT_SHIFT );    /* Q0 */
      44      686383 :     L_Bq15 = 0;
      45      686383 :     move16();
      46      686383 :     if ( x >= 0 )
      47             :     {
      48      686383 :         L_Bq15 = (Word32) UL_lshr( INTrc, x ); /* Q0 */
      49      686383 :         move32();
      50             :     }
      51             : 
      52      686383 :     E = 2;
      53      686383 :     move16();
      54     2745532 :     FOR( k = 1; k < 4; k++ )
      55             :     {
      56     2059149 :         Bq15ui16 = u_extract_l( L_shr( L_Bq15, s_and( E, 1 ) ) ); /* Q0 */
      57     2059149 :         UL_tmp = UL_lshl( UL_deposit_l( Bq15ui16 ), 1 );          /* Q0 */
      58     2059149 :         Mpy_32_16_uu( UL_tmp, Bq15ui16, &h, &l );                 /* Q0 */
      59     2059149 :         L_Bq15 = (Word32) h;
      60     2059149 :         move32();
      61     2059149 :         E = add( shl( B, 1 ), extract_l( L_lshr( L_sub( ( ( 1L << 16 ) - 1L ), L_Bq15 ), 31 ) ) ); /* Q0 */
      62     2059149 :         B = E;
      63     2059149 :         move16();
      64             :     }
      65      686383 :     *FBits = sub( *FBits, B ); /* Q0 */
      66      686383 :     move16();
      67      686383 :     return;
      68             : }

Generated by: LCOV version 1.14