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"
7 : #include "basop_util.h"
8 : #include "cnst.h"
9 : #include "prot_fx.h"
10 : #include "rom_com.h"
11 :
12 : /* Returns: index of next coefficient */
13 4485332 : Word16 get_next_coeff_mapped(
14 : Word16 ii[2], /* i/o: coefficient indexes Q0*/
15 : Word16 *pp, /* o : peak(1)/hole(0) indicator Q0*/
16 : Word16 *idx, /* o : index in unmapped domain Q0*/
17 : CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */
18 : )
19 : {
20 : Word16 p;
21 :
22 4485332 : p = s_and( sub( ii[1], hm_cfg->numPeakIndices ), sub( hm_cfg->indexBuffer[ii[1]], hm_cfg->indexBuffer[ii[0]] ) ); /* Q0 */
23 4485332 : if ( p > 0 )
24 : {
25 2045746 : p = 0;
26 2045746 : move16();
27 : }
28 4485332 : if ( p < 0 )
29 : {
30 1610737 : p = 1;
31 1610737 : move16();
32 : }
33 4485332 : *pp = p; /* Q0 */
34 4485332 : move16();
35 4485332 : *idx = ii[p]; /* Q0 */
36 4485332 : move16();
37 4485332 : ii[p] = add( ii[p], 1 ); /* Q0 */
38 4485332 : move16();
39 4485332 : return hm_cfg->indexBuffer[*idx];
40 : }
41 :
42 : /* Returns: index of next coefficient */
43 120092 : Word16 get_next_coeff_unmapped(
44 : Word16 ii[2], /* i/o: coefficient indexes Q0*/
45 : Word16 *pp, /* o : peak(1)/hole(0) indicator Q0*/
46 : Word16 *idx, /* o : index in unmapped domain Q0*/
47 : CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */
48 : )
49 : {
50 : (void) pp;
51 : (void) hm_cfg;
52 :
53 120092 : *idx = ii[0]; /* Q0 */
54 120092 : move16();
55 120092 : ii[0] = add( ii[0], 1 ); /* Q0 */
56 120092 : move16();
57 120092 : return *idx;
58 : }
59 :
60 206029 : Word16 update_mixed_context(
61 : Word16 ctx, /* Q0 */
62 : Word16 a /* Q0 */
63 : )
64 : {
65 : Word32 t32;
66 206029 : Word16 t = 0; /* initialize just to avoid compiler warning */
67 :
68 206029 : t32 = L_mac0( 1 - 13, s_and( a, ~1 ), add( shr( a, 2 ), 1 ) ); /* Q0 */
69 206029 : if ( t32 <= 0 )
70 : {
71 196194 : t = extract_l( t32 ); /* Q0 */
72 : }
73 206029 : a = shr( a, 3 );
74 206029 : if ( t32 > 0 )
75 : {
76 9835 : t = s_min( a, 2 ); /* Q0 */
77 : }
78 206029 : return add( shl( s_and( ctx, 0xf ), 4 ), add( t, 13 ) );
79 : }
80 :
81 0 : Word32 update_mixed_context_ivas_fx(
82 : Word32 ctx, /* Q0 */
83 : Word16 a /* Q0 */
84 : )
85 : {
86 : Word32 t32;
87 :
88 0 : t32 = L_mac0( 1 - 13, s_and( a, ~1 ), add( shr( a, 2 ), 1 ) ); /* Q0 */
89 :
90 0 : a = shr( a, 3 ); /* Q0 */
91 :
92 0 : IF( t32 > 0 )
93 : {
94 0 : t32 = L_min( a, 2 ); /* Q0 */
95 : }
96 0 : return L_add( L_shl( L_and( ctx, 0xf ), 4 ), L_add( t32, 13 ) );
97 : }
98 :
99 : /*-------------------------------------------------------------------*
100 : * get_next_coeff_mapped_ivas()
101 : *
102 : *
103 : *-------------------------------------------------------------------*/
104 :
105 : /*! r: index of next coefficient */
106 0 : Word16 get_next_coeff_mapped_ivas_fx(
107 : Word16 ii[2], /* i/o: coefficient indexes Q0*/
108 : Word32 *pp, /* o : peak(1)/hole(0) indicator Q0*/
109 : Word16 *idx, /* o : index in unmapped domain Q0*/
110 : CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */
111 : )
112 : {
113 : UWord32 p;
114 :
115 0 : p = s_and( sub( ii[1], hm_cfg->numPeakIndices ), sub( hm_cfg->indexBuffer[ii[1]], hm_cfg->indexBuffer[ii[0]] ) ); /* Q0 */
116 0 : p = UL_lshr( p, sub( sizeof( p ) * 8, 1 ) ); /* Q0 */
117 0 : *pp = p; /* Q0 */
118 0 : move32();
119 0 : *idx = ii[p]; /* Q0 */
120 0 : move16();
121 0 : ii[p] = add( ii[p], 1 ); /* Q0 */
122 0 : move16();
123 :
124 0 : return hm_cfg->indexBuffer[*idx];
125 : }
|