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 : EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
35 : ====================================================================================*/
36 :
37 : #include <stdint.h>
38 : #include "options.h"
39 : #ifdef DEBUGGING
40 : #include "debug.h"
41 : #endif
42 : #include "cnst.h"
43 : #include "prot.h"
44 : #include "wmc_auto.h"
45 :
46 : /*-------------------------------------------------------------------*
47 : * cb_shape()
48 : *
49 : * pre-emphasis, pitch sharpening and formant sharpening of the algebraic codebook
50 : *-------------------------------------------------------------------*/
51 :
52 3080219 : void cb_shape(
53 : const int16_t preemphFlag, /* i : flag for pre-emphasis */
54 : const int16_t pitchFlag, /* i : flag for pitch sharpening */
55 : const int16_t scramblingFlag, /* i : flag for phase scrambling */
56 : const int16_t formantFlag, /* i : flag for formant sharpening */
57 : const int16_t formantTiltFlag, /* i : flag for formant tilt */
58 : const float g1, /* i : formant sharpening numerator weighting */
59 : const float g2, /* i : formant sharpening denominator weighting */
60 : const float *p_Aq, /* i : LP filter coefficients */
61 : float *code, /* i/o: signal to shape */
62 : const float tilt_code, /* i : tilt of code */
63 : const float pt_pitch, /* i : pointer to current subframe fractional pitch */
64 : const int16_t L_subfr /* i : subfframe length */
65 : )
66 : {
67 : float buff[M + 2 * L_SUBFR], A_num[M + 1], A_den[M + 1];
68 : float tmp, tilt;
69 : int16_t i, round_T0;
70 :
71 : /* pre-emphasize the algebraic codebook */
72 3080219 : if ( preemphFlag )
73 : {
74 3080219 : tmp = 0.0f;
75 3080219 : preemph( code, tilt_code, L_subfr, &tmp );
76 : }
77 :
78 : /* pitch sharpening */
79 3080219 : if ( pitchFlag )
80 : {
81 3047421 : round_T0 = (int16_t) ( pt_pitch + 0.4f );
82 21214362 : for ( i = round_T0; i < L_subfr; i++ )
83 : {
84 18166941 : code[i] += code[i - round_T0] * PIT_SHARP;
85 : }
86 : }
87 :
88 : /* phase scrambling filter */
89 3080219 : if ( scramblingFlag )
90 : {
91 0 : buff[0] = code[0];
92 0 : for ( i = 1; i < L_subfr; i++ )
93 : {
94 0 : buff[i] = code[i];
95 0 : code[i] = 0.7f * buff[i] + buff[i - 1] - 0.7f * code[i - 1];
96 : }
97 : }
98 :
99 : /* formant sharpening (only on active speech) */
100 3080219 : if ( formantFlag || formantTiltFlag )
101 : {
102 2580646 : weight_a( p_Aq, A_num, g1, M );
103 2580646 : weight_a( p_Aq, A_den, g2, M );
104 :
105 2580646 : set_f( buff, 0, M + L_subfr );
106 :
107 : /* formant tilt */
108 2580646 : if ( formantTiltFlag )
109 : {
110 0 : mvr2r( A_num, buff + M, M + 1 );
111 0 : syn_filt( A_den, M, buff + M, buff + M, L_subfr, buff, 0 );
112 0 : tilt = get_gain( buff + M + 1, buff + M, L_subfr - 1, NULL );
113 0 : tmp = 0.0;
114 0 : preemph( code, 0.5f * tilt_code - 0.25f * tilt, L_subfr, &tmp );
115 : }
116 : else
117 : {
118 2580646 : mvr2r( code, buff + M, L_subfr );
119 2580646 : residu( A_num, M, buff + M, code, L_subfr );
120 2580646 : syn_filt( A_den, M, code, code, L_subfr, buff, 0 );
121 : }
122 : }
123 :
124 3080219 : return;
125 : }
|