1 |
/*===========================================================================* |
2 |
* rate.h * |
3 |
* * |
4 |
* Procedures concerned with rate control |
5 |
* * |
6 |
* EXPORTED PROCEDURES: * |
7 |
* getRateMode() |
8 |
* setBitRate() |
9 |
* getBitRate() |
10 |
* setBufferSize() |
11 |
* getBufferSize() |
12 |
* initRateControl() |
13 |
* targetRateControl() |
14 |
* updateRateControl() |
15 |
* MB_RateOut() |
16 |
* * |
17 |
*===========================================================================*/ |
18 |
|
19 |
/* COPYRIGHT INFO HERE */ |
20 |
|
21 |
#define VARIABLE_RATE 0 |
22 |
#define FIXED_RATE 1 |
23 |
|
24 |
|
25 |
/*==================* |
26 |
* Exported VARIABLES * |
27 |
*==================*/ |
28 |
|
29 |
|
30 |
extern int rc_bitsThisMB; |
31 |
extern int rc_numBlocks; |
32 |
extern int rc_totalQuant; |
33 |
extern int rc_quantOverride; |
34 |
|
35 |
|
36 |
/*=====================* |
37 |
* EXPORTED PROCEDURES * |
38 |
*=====================*/ |
39 |
|
40 |
/*===========================================================================* |
41 |
* |
42 |
* initRateControl |
43 |
* |
44 |
* initialize the allocation parameters. |
45 |
*===========================================================================*/ |
46 |
extern int initRateControl _ANSI_ARGS_((void)); |
47 |
|
48 |
|
49 |
/*===========================================================================* |
50 |
* |
51 |
* targetRateControl |
52 |
* |
53 |
* Determine the target allocation for given picture type. |
54 |
* |
55 |
* RETURNS: target size in bits |
56 |
*===========================================================================*/ |
57 |
extern void targetRateControl _ANSI_ARGS_((MpegFrame *frame)); |
58 |
|
59 |
|
60 |
/*===========================================================================* |
61 |
* |
62 |
* MB_RateOut |
63 |
* |
64 |
* Prints out sampling of MB rate control data. Every "nth" block |
65 |
* stats are printed, with "n" controled by global RC_MB_SAMPLE_RATE |
66 |
* |
67 |
* RETURNS: nothing |
68 |
*===========================================================================*/ |
69 |
extern void MB_RateOut _ANSI_ARGS_((int type)); |
70 |
|
71 |
|
72 |
/*===========================================================================* |
73 |
* |
74 |
* updateRateControl |
75 |
* |
76 |
* Update the statistics kept, after end of frame |
77 |
* |
78 |
* RETURNS: nothing |
79 |
* |
80 |
* SIDE EFFECTS: many global variables |
81 |
*===========================================================================*/ |
82 |
extern void updateRateControl _ANSI_ARGS_((int type)); |
83 |
|
84 |
|
85 |
/*===========================================================================* |
86 |
* |
87 |
* needQScaleChange(current Q scale, 4 luminance blocks) |
88 |
* |
89 |
* |
90 |
* RETURNS: new Qscale |
91 |
*===========================================================================*/ |
92 |
extern int needQScaleChange _ANSI_ARGS_((int oldQScale, Block blk0, Block blk1, Block blk2, Block blk3)); |
93 |
|
94 |
/*===========================================================================* |
95 |
* |
96 |
* incNumBlocks() |
97 |
* |
98 |
* |
99 |
* RETURNS: nothing |
100 |
*===========================================================================*/ |
101 |
extern void incNumBlocks _ANSI_ARGS_((int num)); |
102 |
|
103 |
|
104 |
/*===========================================================================* |
105 |
* |
106 |
* incMacroBlockBits() |
107 |
* |
108 |
* Increments the number of Macro Block bits and the total of Frame |
109 |
* bits by the number passed. |
110 |
* |
111 |
* RETURNS: nothing |
112 |
*===========================================================================*/ |
113 |
extern void incMacroBlockBits _ANSI_ARGS_((int num)); |
114 |
|
115 |
|
116 |
/*===========================================================================* |
117 |
* |
118 |
* SetRateControl () |
119 |
* |
120 |
* Checks the string parsed from the parameter file. Verifies |
121 |
* number and sets global values. |
122 |
* |
123 |
* RETURNS: nothing |
124 |
*===========================================================================*/ |
125 |
extern void SetRateControl _ANSI_ARGS_((char *charPtr)); |
126 |
|
127 |
|
128 |
/*===========================================================================* |
129 |
* |
130 |
* setBufferSize () |
131 |
* |
132 |
* Checks the string parsed from the parameter file. Verifies |
133 |
* number and sets global values. |
134 |
* |
135 |
* RETURNS: nothing |
136 |
*===========================================================================*/ |
137 |
extern void setBufferSize _ANSI_ARGS_((char *charPtr)); |
138 |
|
139 |
|
140 |
/*===========================================================================* |
141 |
* |
142 |
* getBufferSize () |
143 |
* |
144 |
* returns the buffer size read from the parameter file. Size is |
145 |
* in bits- not in units of 16k as written to the sequence header. |
146 |
* |
147 |
* RETURNS: int (or -1 if invalid) |
148 |
*===========================================================================*/ |
149 |
extern int getBufferSize _ANSI_ARGS_((void)); |
150 |
|
151 |
|
152 |
/*===========================================================================* |
153 |
* |
154 |
* setBitRate () |
155 |
* |
156 |
* Checks the string parsed from the parameter file. Verifies |
157 |
* number and sets global values. |
158 |
* |
159 |
* RETURNS: nothing |
160 |
* |
161 |
* SIDE EFFECTS: global variables |
162 |
*===========================================================================*/ |
163 |
extern void setBitRate _ANSI_ARGS_((char *charPtr)); |
164 |
|
165 |
|
166 |
/*===========================================================================* |
167 |
* |
168 |
* getBitRate () |
169 |
* |
170 |
* Returns the bit rate read from the parameter file. This is the |
171 |
* real rate in bits per second, not in 400 bit units as is written to |
172 |
* the sequence header. |
173 |
* |
174 |
* RETURNS: int (-1 if Variable mode operation) |
175 |
*===========================================================================*/ |
176 |
extern int getBitRate _ANSI_ARGS_((void)); |
177 |
|
178 |
|
179 |
/*===========================================================================* |
180 |
* |
181 |
* getRateMode () |
182 |
* |
183 |
* Returns the rate mode- interpreted waa either Fixed or Variable |
184 |
* |
185 |
* RETURNS: integer |
186 |
*===========================================================================*/ |
187 |
extern int getRateMode _ANSI_ARGS_((void)); |
188 |
|
189 |
|
190 |
/*===========================================================================* |
191 |
* |
192 |
* incQuantOverride() |
193 |
* |
194 |
* counter of override of quantization |
195 |
* |
196 |
* RETURNS: nothing |
197 |
*===========================================================================*/ |
198 |
extern void incQuantOverride _ANSI_ARGS_((int num)); |