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 4878694 : 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 4878694 : p = s_and( sub( ii[1], hm_cfg->numPeakIndices ), sub( hm_cfg->indexBuffer[ii[1]], hm_cfg->indexBuffer[ii[0]] ) ); /* Q0 */
23 4878694 : if ( p > 0 )
24 : {
25 2152156 : p = 0;
26 2152156 : move16();
27 : }
28 4878694 : if ( p < 0 )
29 : {
30 1839262 : p = 1;
31 1839262 : move16();
32 : }
33 4878694 : *pp = p; /* Q0 */
34 4878694 : move16();
35 4878694 : *idx = ii[p]; /* Q0 */
36 4878694 : move16();
37 4878694 : ii[p] = add( ii[p], 1 ); /* Q0 */
38 4878694 : move16();
39 4878694 : return hm_cfg->indexBuffer[*idx];
40 : }
41 :
42 : /* Returns: index of next coefficient */
43 892996 : 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 892996 : *idx = ii[0]; /* Q0 */
54 892996 : move16();
55 892996 : ii[0] = add( ii[0], 1 ); /* Q0 */
56 892996 : move16();
57 892996 : return *idx;
58 : }
59 :
60 232620 : Word16 update_mixed_context(
61 : Word16 ctx, /* Q0 */
62 : Word16 a /* Q0 */
63 : )
64 : {
65 : Word32 t32;
66 232620 : Word16 t = 0; /* initialize just to avoid compiler warning */
67 :
68 232620 : t32 = L_mac0( 1 - 13, s_and( a, ~1 ), add( shr( a, 2 ), 1 ) ); /* Q0 */
69 232620 : if ( t32 <= 0 )
70 : {
71 222680 : t = extract_l( t32 ); /* Q0 */
72 : }
73 232620 : a = shr( a, 3 );
74 232620 : if ( t32 > 0 )
75 : {
76 9940 : t = s_min( a, 2 ); /* Q0 */
77 : }
78 232620 : return add( shl( s_and( ctx, 0xf ), 4 ), add( t, 13 ) );
79 : }
80 :
81 14992461 : Word32 update_mixed_context_ivas_fx(
82 : Word32 ctx, /* Q0 */
83 : Word16 a /* Q0 */
84 : )
85 : {
86 : Word32 t32;
87 :
88 14992461 : t32 = L_mac0( 1 - 13, s_and( a, ~1 ), add( shr( a, 2 ), 1 ) ); /* Q0 */
89 :
90 14992461 : a = shr( a, 3 ); /* Q0 */
91 :
92 14992461 : IF( t32 > 0 )
93 : {
94 347429 : t32 = L_min( a, 2 ); /* Q0 */
95 : }
96 14992461 : 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 170871500 : 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 170871500 : p = s_and( sub( ii[1], hm_cfg->numPeakIndices ), sub( hm_cfg->indexBuffer[ii[1]], hm_cfg->indexBuffer[ii[0]] ) ); /* Q0 */
116 170871500 : p = UL_lshr( p, sub( sizeof( p ) * 8, 1 ) ); /* Q0 */
117 170871500 : *pp = p; /* Q0 */
118 170871500 : move32();
119 170871500 : *idx = ii[p]; /* Q0 */
120 170871500 : move16();
121 170871500 : ii[p] = add( ii[p], 1 ); /* Q0 */
122 170871500 : move16();
123 :
124 170871500 : return hm_cfg->indexBuffer[*idx];
125 : }
|