comparison libmpcodecs/ve_x264.c @ 15413:561f617e8944

sync to x264 rev223 (options: ratetol, vbv_*)
author lorenm
date Wed, 11 May 2005 16:00:12 +0000
parents d8ee4d45ec8d
children 40d5e0ccce93
comparison
equal deleted inserted replaced
15412:ead83e8d0c95 15413:561f617e8944
60 60
61 static int bitrate = -1; 61 static int bitrate = -1;
62 static int qp_constant = 26; 62 static int qp_constant = 26;
63 static int frame_ref = 1; 63 static int frame_ref = 1;
64 static int keyint_max = 250; 64 static int keyint_max = 250;
65 static int keyint_min = -1; 65 static int keyint_min = 25;
66 static int scenecut_threshold = 40; 66 static int scenecut_threshold = 40;
67 static int bframe = 0; 67 static int bframe = 0;
68 static int bframe_adaptive = 1; 68 static int bframe_adaptive = 1;
69 static int bframe_bias = 0; 69 static int bframe_bias = 0;
70 static int bframe_pyramid = 0; 70 static int bframe_pyramid = 0;
79 static int weight_b = 0; 79 static int weight_b = 0;
80 static int chroma_me = 1; 80 static int chroma_me = 1;
81 static int chroma_qp_offset = 0; 81 static int chroma_qp_offset = 0;
82 static float ip_factor = 1.4; 82 static float ip_factor = 1.4;
83 static float pb_factor = 1.3; 83 static float pb_factor = 1.3;
84 static int rc_buffer_size = -1; 84 static float ratetol = 1.0;
85 static float rc_init_buffer = 0.25; 85 static int vbv_maxrate = 0;
86 static int rc_sens = 4; 86 static int vbv_bufsize = 0;
87 static float vbv_init = 0.9;
87 static int qp_min = 10; 88 static int qp_min = 10;
88 static int qp_max = 51; 89 static int qp_max = 51;
89 static int qp_step = 1; 90 static int qp_step = 2;
90 static int pass = 0; 91 static int pass = 0;
91 static float qcomp = 0.6; 92 static float qcomp = 0.6;
92 static float qblur = 0.5; 93 static float qblur = 0.5;
93 static float complexity_blur = 20; 94 static float complexity_blur = 20;
94 static char *rc_eq = "blurCplx^(1-qComp)"; 95 static char *rc_eq = "blurCplx^(1-qComp)";
130 {"chroma_me", &chroma_me, CONF_TYPE_FLAG, 0, 0, 1, NULL}, 131 {"chroma_me", &chroma_me, CONF_TYPE_FLAG, 0, 0, 1, NULL},
131 {"nochroma_me", &chroma_me, CONF_TYPE_FLAG, 0, 1, 0, NULL}, 132 {"nochroma_me", &chroma_me, CONF_TYPE_FLAG, 0, 1, 0, NULL},
132 {"chroma_qp_offset", &chroma_qp_offset, CONF_TYPE_INT, CONF_RANGE, -12, 12, NULL}, 133 {"chroma_qp_offset", &chroma_qp_offset, CONF_TYPE_INT, CONF_RANGE, -12, 12, NULL},
133 {"ip_factor", &ip_factor, CONF_TYPE_FLOAT, CONF_RANGE, -10.0, 10.0, NULL}, 134 {"ip_factor", &ip_factor, CONF_TYPE_FLOAT, CONF_RANGE, -10.0, 10.0, NULL},
134 {"pb_factor", &pb_factor, CONF_TYPE_FLOAT, CONF_RANGE, -10.0, 10.0, NULL}, 135 {"pb_factor", &pb_factor, CONF_TYPE_FLOAT, CONF_RANGE, -10.0, 10.0, NULL},
135 {"rc_buffer_size", &rc_buffer_size, CONF_TYPE_INT, CONF_RANGE, 0, 24000000, NULL}, 136 {"ratetol", &ratetol, CONF_TYPE_FLOAT, CONF_RANGE, 0.1, 100.0, NULL},
136 {"rc_init_buffer", &rc_init_buffer, CONF_TYPE_FLOAT, CONF_RANGE, 0, 24000000, NULL}, 137 {"vbv_maxrate", &vbv_maxrate, CONF_TYPE_INT, CONF_RANGE, 0, 24000000, NULL},
137 {"rc_sens", &rc_sens, CONF_TYPE_INT, CONF_RANGE, 0, 100, NULL}, 138 {"vbv_bufsize", &vbv_bufsize, CONF_TYPE_INT, CONF_RANGE, 0, 24000000, NULL},
139 {"vbv_init", &vbv_init, CONF_TYPE_FLOAT, CONF_RANGE, 0.0, 1.0, NULL},
138 {"qp_min", &qp_min, CONF_TYPE_INT, CONF_RANGE, 1, 51, NULL}, 140 {"qp_min", &qp_min, CONF_TYPE_INT, CONF_RANGE, 1, 51, NULL},
139 {"qp_max", &qp_max, CONF_TYPE_INT, CONF_RANGE, 1, 51, NULL}, 141 {"qp_max", &qp_max, CONF_TYPE_INT, CONF_RANGE, 1, 51, NULL},
140 {"qp_step", &qp_step, CONF_TYPE_INT, CONF_RANGE, 1, 50, NULL}, 142 {"qp_step", &qp_step, CONF_TYPE_INT, CONF_RANGE, 1, 50, NULL},
141 {"pass", &pass, CONF_TYPE_INT, CONF_RANGE, 1, 3, NULL}, 143 {"pass", &pass, CONF_TYPE_INT, CONF_RANGE, 1, 3, NULL},
142 {"rc_eq", &rc_eq, CONF_TYPE_STRING, 0, 0, 0, NULL}, 144 {"rc_eq", &rc_eq, CONF_TYPE_STRING, 0, 0, 0, NULL},
163 mod->mux->aspect = (float)d_width/d_height; 165 mod->mux->aspect = (float)d_width/d_height;
164 166
165 x264_param_default(&mod->param); 167 x264_param_default(&mod->param);
166 mod->param.i_frame_reference = frame_ref; 168 mod->param.i_frame_reference = frame_ref;
167 mod->param.i_keyint_max = keyint_max; 169 mod->param.i_keyint_max = keyint_max;
168 mod->param.i_keyint_min = keyint_min > 0 ? keyint_min : keyint_max * 2 / 5; 170 mod->param.i_keyint_min = keyint_min;
169 mod->param.i_scenecut_threshold = scenecut_threshold; 171 mod->param.i_scenecut_threshold = scenecut_threshold;
170 mod->param.i_bframe = bframe; 172 mod->param.i_bframe = bframe;
171 mod->param.b_bframe_adaptive = bframe_adaptive; 173 mod->param.b_bframe_adaptive = bframe_adaptive;
172 mod->param.i_bframe_bias = bframe_bias; 174 mod->param.i_bframe_bias = bframe_bias;
173 mod->param.b_bframe_pyramid = bframe_pyramid; 175 mod->param.b_bframe_pyramid = bframe_pyramid;
187 mod->param.rc.psz_rc_eq = rc_eq; 189 mod->param.rc.psz_rc_eq = rc_eq;
188 mod->param.rc.f_qcompress = qcomp; 190 mod->param.rc.f_qcompress = qcomp;
189 mod->param.rc.f_qblur = qblur; 191 mod->param.rc.f_qblur = qblur;
190 mod->param.rc.f_complexity_blur = complexity_blur; 192 mod->param.rc.f_complexity_blur = complexity_blur;
191 mod->param.analyse.i_subpel_refine = subq; 193 mod->param.analyse.i_subpel_refine = subq;
194 mod->param.analyse.i_me_method = subq==1 ? X264_ME_DIA : X264_ME_HEX;
192 mod->param.rc.psz_stat_out = passtmpfile; 195 mod->param.rc.psz_stat_out = passtmpfile;
193 mod->param.rc.psz_stat_in = passtmpfile; 196 mod->param.rc.psz_stat_in = passtmpfile;
194 if((pass & 2) && bitrate <= 0) 197 if((pass & 2) && bitrate <= 0)
195 { 198 {
196 mp_msg(MSGT_MENCODER, MSGL_ERR, 199 mp_msg(MSGT_MENCODER, MSGL_ERR,
214 mod->param.rc.b_stat_write = 1; 217 mod->param.rc.b_stat_write = 1;
215 mod->param.rc.b_stat_read = 1; 218 mod->param.rc.b_stat_read = 1;
216 break; 219 break;
217 } 220 }
218 if(bitrate > 0) { 221 if(bitrate > 0) {
219 if(rc_buffer_size <= 0) 222 if((vbv_maxrate > 0) != (vbv_bufsize > 0)) {
220 rc_buffer_size = bitrate; 223 mp_msg(MSGT_MENCODER, MSGL_ERR,
224 "VBV requires both vbv_maxrate and vbv_bufsize.\n");
225 return 0;
226 }
221 mod->param.rc.b_cbr = 1; 227 mod->param.rc.b_cbr = 1;
222 mod->param.rc.i_bitrate = bitrate; 228 mod->param.rc.i_bitrate = bitrate;
223 mod->param.rc.i_rc_buffer_size = rc_buffer_size; 229 mod->param.rc.f_rate_tolerance = ratetol;
224 if(rc_init_buffer > 1) 230 mod->param.rc.i_vbv_max_bitrate = vbv_maxrate;
225 mod->param.rc.i_rc_init_buffer = rc_init_buffer; 231 mod->param.rc.i_vbv_buffer_size = vbv_bufsize;
226 else 232 mod->param.rc.f_vbv_buffer_init = vbv_init;
227 mod->param.rc.i_rc_init_buffer = rc_buffer_size * rc_init_buffer;
228 mod->param.rc.i_rc_sens = rc_sens;
229 } 233 }
230 mod->param.rc.f_ip_factor = ip_factor; 234 mod->param.rc.f_ip_factor = ip_factor;
231 mod->param.rc.f_pb_factor = pb_factor; 235 mod->param.rc.f_pb_factor = pb_factor;
232 switch(me_method) { 236 switch(me_method) {
233 case 1: mod->param.analyse.i_me_method = X264_ME_DIA; break; 237 case 1: mod->param.analyse.i_me_method = X264_ME_DIA; break;