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 "prot_fx.h" /* Function prototypes */ 8 : 9 : /*-------------------------------------------------------------------------- 10 : * re8_dec_fx() 11 : * 12 : * MULTI-RATE INDEXING OF A POINT y in THE LATTICE RE8 (INDEX DECODING) 13 : * note: the index I is defined as a 32-bit word, but only 14 : * 16 bits are required (long can be replaced by unsigned integer) 15 : *--------------------------------------------------------------------------*/ 16 : 17 1637882 : void re8_dec_fx( 18 : Word16 n, /* i : codebook number (*n is an integer defined in {0,2,3,4,..,n_max}) */ 19 : const UWord16 I, /* i : index of c (pointer to unsigned 16-bit word) */ 20 : const Word16 k[], /* i : index of v (8-dimensional vector of binary indices) = Voronoi index */ 21 : Word16 y[] /* o : point in RE8 (8-dimensional integer vector) */ 22 : ) 23 : { 24 : Word16 i, m, v[8]; 25 : 26 : /*------------------------------------------------------------------------* 27 : * decode the sub-indices I and kv[] according to the codebook number n: 28 : * if n=0,2,3,4, decode I (no Voronoi extension) 29 : * if n>4, Voronoi extension is used, decode I and kv[] 30 : *------------------------------------------------------------------------*/ 31 1637882 : IF( LE_16( n, 4 ) ) 32 : { 33 1558219 : re8_decode_base_index_fx( n, I, y ); 34 : } 35 : ELSE 36 : { 37 : /*--------------------------------------------------------------------* 38 : * compute the Voronoi modulo m = 2^r where r is extension order 39 : *--------------------------------------------------------------------*/ 40 79663 : m = 0; 41 79663 : move16(); 42 : 43 160850 : FOR( ; n > 4; n -= 2 ) 44 : { 45 81187 : m = add( m, 1 ); 46 : } 47 : 48 : /*--------------------------------------------------------------------* 49 : * decode base codebook index I into c (c is an element of Q3 or Q4) 50 : * [here c is stored in y to save memory] 51 : *--------------------------------------------------------------------*/ 52 : 53 79663 : re8_decode_base_index_fx( n, I, y ); 54 : 55 : /*--------------------------------------------------------------------* 56 : * decode Voronoi index k[] into v 57 : *--------------------------------------------------------------------*/ 58 79663 : re8_k2y_fx( k, m, v ); 59 : 60 : /*--------------------------------------------------------------------* 61 : * reconstruct y as y = m c + v (with m=2^r, r integer >=1) 62 : *--------------------------------------------------------------------*/ 63 716967 : FOR( i = 0; i < 8; i++ ) 64 : { 65 : /* y[i] = m*y[i] + v[i] */ 66 637304 : y[i] = add( shl( y[i], m ), v[i] ); 67 637304 : move16(); 68 : } 69 : } 70 : 71 1637882 : return; 72 : }