1 /***********************************************************************
2 Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 Redistribution and use in source and binary forms, with or without
4 modification, are permitted provided that the following conditions
5 are met:
6 - Redistributions of source code must retain the above copyright notice,
7 this list of conditions and the following disclaimer.
8 - Redistributions in binary form must reproduce the above copyright
9 notice, this list of conditions and the following disclaimer in the
10 documentation and/or other materials provided with the distribution.
11 - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 names of specific contributors, may be used to endorse or promote
13 products derived from this software without specific prior written
14 permission.
15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 POSSIBILITY OF SUCH DAMAGE.
26 ***********************************************************************/
27 
28 #ifndef SILK_STRUCTS_FIX_H
29 #define SILK_STRUCTS_FIX_H
30 
31 #include "typedef.h"
32 #include "main.h"
33 #include "structs.h"
34 
35 #ifdef __cplusplus
36 extern "C"
37 {
38 #endif
39 
40 /********************************/
41 /* Noise shaping analysis state */
42 /********************************/
43 typedef struct {
44     opus_int8                   LastGainIndex;
45     opus_int32                  HarmBoost_smth_Q16;
46     opus_int32                  HarmShapeGain_smth_Q16;
47     opus_int32                  Tilt_smth_Q16;
48 } silk_shape_state_FIX;
49 
50 /********************************/
51 /* Encoder state FIX            */
52 /********************************/
53 typedef struct {
54     silk_encoder_state          sCmn;                                   /* Common struct, shared with floating-point code       */
55     silk_shape_state_FIX        sShape;                                 /* Shape state                                          */
56 
57     /* Buffer for find pitch and noise shape analysis */
58     silk_DWORD_ALIGN opus_int16 x_buf[ 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ];/* Buffer for find pitch and noise shape analysis  */
59     opus_int                    LTPCorr_Q15;                            /* Normalized correlation from pitch lag estimator      */
60     opus_int32                    resNrgSmth;
61 } silk_encoder_state_FIX;
62 
63 /************************/
64 /* Encoder control FIX  */
65 /************************/
66 typedef struct {
67     /* Prediction and coding parameters */
68     opus_int32                  Gains_Q16[ MAX_NB_SUBFR ];
69     silk_DWORD_ALIGN opus_int16 PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ];
70     opus_int16                  LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ];
71     opus_int                    LTP_scale_Q14;
72     opus_int                    pitchL[ MAX_NB_SUBFR ];
73 
74     /* Noise shaping parameters */
75     /* Testing */
76     silk_DWORD_ALIGN opus_int16 AR_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ];
77     opus_int32                  LF_shp_Q14[        MAX_NB_SUBFR ];      /* Packs two int16 coefficients per int32 value         */
78     opus_int                    Tilt_Q14[          MAX_NB_SUBFR ];
79     opus_int                    HarmShapeGain_Q14[ MAX_NB_SUBFR ];
80     opus_int                    Lambda_Q10;
81     opus_int                    input_quality_Q14;
82     opus_int                    coding_quality_Q14;
83 
84     /* measures */
85     opus_int32                  predGain_Q16;
86     opus_int                    LTPredCodGain_Q7;
87     opus_int32                  ResNrg[ MAX_NB_SUBFR ];                 /* Residual energy per subframe                         */
88     opus_int                    ResNrgQ[ MAX_NB_SUBFR ];                /* Q domain for the residual energy > 0                 */
89 
90     /* Parameters for CBR mode */
91     opus_int32                  GainsUnq_Q16[ MAX_NB_SUBFR ];
92     opus_int8                   lastGainIndexPrev;
93 } silk_encoder_control_FIX;
94 
95 /************************/
96 /* Encoder Super Struct */
97 /************************/
98 typedef struct {
99     silk_encoder_state_FIX      state_Fxx[ ENCODER_NUM_CHANNELS ];
100     stereo_enc_state            sStereo;
101     opus_int32                  nBitsUsedLBRR;
102     opus_int32                  nBitsExceeded;
103     opus_int                    nChannelsAPI;
104     opus_int                    nChannelsInternal;
105     opus_int                    nPrevChannelsInternal;
106     opus_int                    timeSinceSwitchAllowed_ms;
107     opus_int                    allowBandwidthSwitch;
108     opus_int                    prev_decode_only_middle;
109 } silk_encoder;
110 
111 
112 #ifdef __cplusplus
113 }
114 #endif
115 
116 #endif
117