Add shared libswscale support.
[mplayer/glamo.git] / xvid_vbr.h
blob8243f88614d6b5522e37e746511aa775173fde6e
1 /******************************************************************************
3 * XviD VBR Library
4 *
5 * Copyright (C) 2002 Edouard Gomez <ed.gomez@wanadoo.fr>
7 * The curve treatment algorithm is based on work done by Foxer <email?> and
8 * Dirk Knop <dknop@gwdg.de> for the XviD vfw dynamic library.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 *****************************************************************************/
26 #ifndef MPLAYER_XVID_VBR_H
27 #define MPLAYER_XVID_VBR_H
29 #define VBR_VERSION 0
31 /******************************************************************************
32 * Function types used in the vbr controler
33 *****************************************************************************/
35 typedef int (vbr_init_function)(void *state);
36 typedef vbr_init_function *vbr_init_function_ptr;
38 typedef int (vbr_get_quant_function)(void *state);
39 typedef vbr_get_quant_function *vbr_get_quant_function_ptr;
41 typedef int (vbr_get_intra_function)(void *state);
42 typedef vbr_get_intra_function *vbr_get_intra_function_ptr;
44 typedef int (vbr_update_function)(void *state,
45 int quant,
46 int intra,
47 int header_bytes,
48 int total_bytes,
49 int kblocks,
50 int mblocks,
51 int ublocks);
52 typedef vbr_update_function *vbr_update_function_ptr;
54 typedef int (vbr_finish_function)(void *state);
55 typedef vbr_finish_function *vbr_finish_function_ptr;
57 /******************************************************************************
58 * The VBR CONTROLER structure - the spin of the library
59 *****************************************************************************/
61 typedef struct vbr_control_t
64 /* All modes - specifies what VBR algorithm has to be used */
65 int mode;
67 /* All modes - specifies what fps the movie uses */
68 float fps;
70 /* All modes */
71 int debug;
74 * For VBR_MODE_2PASS_1/2 - specifies from/to what file the vbr
75 * controller has to write/read stats
77 char *filename;
79 /* For VBR_MODE_2PASS_2 - Target size */
80 int desired_bitrate;
82 /* For VBR_MODE_2PASS_2 - Credits parameters */
83 int credits_mode;
84 int credits_start;
85 int credits_start_begin;
86 int credits_start_end;
87 int credits_end;
88 int credits_end_begin;
89 int credits_end_end;
90 int credits_quant_ratio;
91 int credits_fixed_quant;
92 int credits_quant_i;
93 int credits_quant_p;
94 int credits_start_size;
95 int credits_end_size;
97 /* For VBR_MODE_2PASS_2 - keyframe parameters */
98 int keyframe_boost;
99 int kftreshold;
100 int kfreduction;
101 int min_key_interval;
102 int max_key_interval;
104 /* For VBR_MODE_2PASS_2 - Normal curve */
105 int curve_compression_high;
106 int curve_compression_low;
108 /* For VBR_MODE_2PASS_2 - Alternate curve parameters */
109 int use_alt_curve;
110 int alt_curve_type;
111 int alt_curve_low_dist;
112 int alt_curve_high_dist;
113 int alt_curve_min_rel_qual;
114 int alt_curve_use_auto;
115 int alt_curve_auto_str;
116 int alt_curve_use_auto_bonus_bias;
117 int alt_curve_bonus_bias;
118 int bitrate_payback_method;
119 int bitrate_payback_delay;
120 int max_iquant;
121 int min_iquant;
122 int max_pquant;
123 int min_pquant;
124 int twopass_max_bitrate;
125 int twopass_max_overflow_improvement;
126 int twopass_max_overflow_degradation;
129 * For VBR_MODE_FIXED_QUANT - the quantizer that has to be used for all
130 * frames
132 int fixed_quant;
134 /* ----------- Internal data - Do not modify ----------- */
135 void *debug_file;
136 void *pass1_file;
138 long long desired_size;
140 int cur_frame;
141 int nb_frames;
142 int nb_keyframes;
144 int *keyframe_locations;
145 int last_keyframe;
147 double credits_start_curve;
148 double credits_end_curve;
149 double movie_curve;
150 double average_frame;
151 double alt_curve_low;
152 double alt_curve_low_diff;
153 double alt_curve_high;
154 double alt_curve_high_diff;
155 double alt_curve_mid_qual;
156 double alt_curve_qual_dev;
157 double curve_bias_bonus;
158 double curve_comp_scale;
159 double curve_comp_error;
161 int pass1_quant;
162 int pass1_intra;
163 int pass1_bytes;
165 int bytes1;
166 int bytes2;
167 int desired_bytes2;
168 int max_framesize;
169 int last_quant;
170 int quant_count[32];
171 double quant_error[32];
173 int overflow;
174 int KFoverflow;
175 int KFoverflow_partial;
176 int KF_idx;
178 int debug_quant_count[32];
180 /* ----------- Internal data - do not modify ----------- */
181 vbr_init_function_ptr init;
182 vbr_get_quant_function_ptr getquant;
183 vbr_get_intra_function_ptr getintra;
184 vbr_update_function_ptr update;
185 vbr_finish_function_ptr finish;
187 }vbr_control_t;
189 /******************************************************************************
190 * Constants
191 *****************************************************************************/
193 /* Constants for the mode member */
194 #define VBR_MODE_1PASS 0x01
195 #define VBR_MODE_2PASS_1 0x02
196 #define VBR_MODE_2PASS_2 0x04
197 #define VBR_MODE_FIXED_QUANT 0x08
199 /* Constants for the credits mode */
200 #define VBR_CREDITS_MODE_RATE 0x01
201 #define VBR_CREDITS_MODE_QUANT 0x02
202 #define VBR_CREDITS_MODE_SIZE 0x04
204 /* Alternate curve treatment types */
205 #define VBR_ALT_CURVE_SOFT 0x01
206 #define VBR_ALT_CURVE_LINEAR 0x02
207 #define VBR_ALT_CURVE_AGGRESIVE 0x04
209 /* Payback modes */
210 #define VBR_PAYBACK_BIAS 0x01
211 #define VBR_PAYBACK_PROPORTIONAL 0x02
213 /******************************************************************************
214 * VBR API
215 *****************************************************************************/
217 extern int vbrSetDefaults(vbr_control_t *state);
218 extern int vbrInit(vbr_control_t *state);
219 extern int vbrGetQuant(vbr_control_t *state);
220 extern int vbrGetIntra(vbr_control_t *state);
221 extern int vbrUpdate(vbr_control_t *state,
222 int quant,
223 int intra,
224 int header_bytes,
225 int total_bytes,
226 int kblocks,
227 int mblocks,
228 int ublocks);
229 extern int vbrFinish(vbr_control_t *state);
231 #endif /* MPLAYER_XVID_VBR_H */