[go: nahoru, domu]

1/*
2 ** Copyright 2003-2010, VisualOn, Inc.
3 **
4 ** Licensed under the Apache License, Version 2.0 (the "License");
5 ** you may not use this file except in compliance with the License.
6 ** You may obtain a copy of the License at
7 **
8 **     http://www.apache.org/licenses/LICENSE-2.0
9 **
10 ** Unless required by applicable law or agreed to in writing, software
11 ** distributed under the License is distributed on an "AS IS" BASIS,
12 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 ** See the License for the specific language governing permissions and
14 ** limitations under the License.
15 */
16/*******************************************************************************
17	File:		qc_data.h
18
19	Content:	Quantizing & coding structures
20
21*******************************************************************************/
22
23#ifndef _QC_DATA_H
24#define _QC_DATA_H
25
26#include "psy_const.h"
27#include "dyn_bits.h"
28#include "adj_thr_data.h"
29
30
31#define MAX_MODES 10
32
33typedef enum {
34  MODE_INVALID = 0,
35  MODE_1,        /* mono      */
36  MODE_1_1,      /* dual mono */
37  MODE_2         /* stereo    */
38} ENCODER_MODE;
39
40typedef enum {
41  ID_SCE=0,     /* Single Channel Element   */
42  ID_CPE=1,     /* Channel Pair Element     */
43  ID_CCE=2,     /* Coupling Channel Element */
44  ID_LFE=3,     /* LFE Channel Element      */
45  ID_DSE=4,     /* current one DSE element for ancillary is supported */
46  ID_PCE=5,
47  ID_FIL=6,
48  ID_END=7
49}ELEMENT_TYPE;
50
51typedef struct {
52  ELEMENT_TYPE elType;
53  Word16 instanceTag;
54  Word16 nChannelsInEl;
55  Word16 ChannelIndex[MAX_CHANNELS];
56} ELEMENT_INFO;
57
58typedef struct {
59  Word32 paddingRest;
60} PADDING;
61
62
63/* Quantizing & coding stage */
64
65struct QC_INIT{
66  ELEMENT_INFO *elInfo;
67  Word16 maxBits;     /* maximum number of bits in reservoir  */
68  Word16 averageBits; /* average number of bits we should use */
69  Word16 bitRes;
70  Word16 meanPe;
71  Word32 chBitrate;
72  Word16 maxBitFac;
73  Word32 bitrate;
74
75  PADDING padding;
76};
77
78typedef struct
79{
80  Word16          *quantSpec;       /* [FRAME_LEN_LONG];                            */
81  UWord16         *maxValueInSfb;   /* [MAX_GROUPED_SFB];                           */
82  Word16          *scf;             /* [MAX_GROUPED_SFB];                           */
83  Word16          globalGain;
84  Word16          mdctScale;
85  Word16          groupingMask;
86  SECTION_DATA    sectionData;
87  Word16          windowShape;
88} QC_OUT_CHANNEL;
89
90typedef struct
91{
92  Word16		  adtsUsed;
93  Word16          staticBitsUsed; /* for verification purposes */
94  Word16          dynBitsUsed;    /* for verification purposes */
95  Word16          pe;
96  Word16          ancBitsUsed;
97  Word16          fillBits;
98} QC_OUT_ELEMENT;
99
100typedef struct
101{
102  QC_OUT_CHANNEL  qcChannel[MAX_CHANNELS];
103  QC_OUT_ELEMENT  qcElement;
104  Word16          totStaticBitsUsed; /* for verification purposes */
105  Word16          totDynBitsUsed;    /* for verification purposes */
106  Word16          totAncBitsUsed;    /* for verification purposes */
107  Word16          totFillBits;
108  Word16          alignBits;
109  Word16          bitResTot;
110  Word16          averageBitsTot;
111} QC_OUT;
112
113typedef struct {
114  Word32 chBitrate;
115  Word16 averageBits;               /* brutto -> look ancillary.h */
116  Word16 maxBits;
117  Word16 bitResLevel;
118  Word16 maxBitResBits;
119  Word16 relativeBits;            /* Bits relative to total Bits scaled down by 2 */
120} ELEMENT_BITS;
121
122typedef struct
123{
124  /* this is basically struct QC_INIT */
125  Word16 averageBitsTot;
126  Word16 maxBitsTot;
127  Word16 globStatBits;
128  Word16 nChannels;
129  Word16 bitResTot;
130
131  Word16 maxBitFac;
132
133  PADDING   padding;
134
135  ELEMENT_BITS  elementBits;
136  ADJ_THR_STATE adjThr;
137
138  Word16 logSfbFormFactor[MAX_CHANNELS][MAX_GROUPED_SFB];
139  Word16 sfbNRelevantLines[MAX_CHANNELS][MAX_GROUPED_SFB];
140  Word16 logSfbEnergy[MAX_CHANNELS][MAX_GROUPED_SFB];
141} QC_STATE;
142
143#endif /* _QC_DATA_H */
144