Submitted By:            Randy McMurchy <randy_at_linuxfromscratch_dot_org>
Date:                    2006-01-10
Initial Package Version: 1.0pre7try2
Upstream Status:         From upstream CVS
Origin:                  Upstream CVS
Description:             Fixes x264 codec build issues


diff -Naur MPlayer-1.0pre7try2-orig/configure MPlayer-1.0pre7try2/configure
--- MPlayer-1.0pre7try2-orig/configure	2005-04-13 11:46:35.000000000 +0000
+++ MPlayer-1.0pre7try2/configure	2006-01-10 20:26:01.000000000 +0000
@@ -5940,7 +5940,7 @@
 #endif
 int main(void) { x264_encoder_open((void*)0); return 0; }
 EOF
-_ld_x264="$_ld_x264 -lx264 $_ld_lm"
+_ld_x264="$_ld_x264 -lx264 -lpthread $_ld_lm"
 if test "$_x264" != no && cc_check $_inc_x264 $_ld_x264 ; then
   _x264=yes
   _def_x264='#define HAVE_X264 1'

diff -Naur MPlayer-1.0pre7try2-orig/libmpcodecs/ve_x264.c MPlayer-1.0pre7try2/libmpcodecs/ve_x264.c
--- MPlayer-1.0pre7try2-orig/libmpcodecs/ve_x264.c	2005-04-13 19:10:29.000000000 +0000
+++ MPlayer-1.0pre7try2/libmpcodecs/ve_x264.c	2006-01-10 20:26:01.000000000 +0000
@@ -62,7 +62,7 @@
 static int qp_constant = 26;
 static int frame_ref = 1;
 static int keyint_max = 250;
-static int keyint_min = -1;
+static int keyint_min = 25;
 static int scenecut_threshold = 40;
 static int bframe = 0;
 static int bframe_adaptive = 1;
@@ -81,12 +81,14 @@
 static int chroma_qp_offset = 0;
 static float ip_factor = 1.4;
 static float pb_factor = 1.3;
-static int rc_buffer_size = -1;
-static float rc_init_buffer = 0.25;
-static int rc_sens = 4;
+static float ratetol = 1.0; 
+static int vbv_maxrate = 0; 
+static int vbv_bufsize = 0; 
+static float vbv_init = 0.9; 
+
 static int qp_min = 10;
 static int qp_max = 51;
-static int qp_step = 1;
+static int qp_step = 2;
 static int pass = 0;
 static float qcomp = 0.6;
 static float qblur = 0.5;
@@ -130,9 +132,10 @@
     {"chroma_qp_offset", &chroma_qp_offset, CONF_TYPE_INT, CONF_RANGE, -12, 12, NULL},
     {"ip_factor", &ip_factor, CONF_TYPE_FLOAT, CONF_RANGE, -10.0, 10.0, NULL},
     {"pb_factor", &pb_factor, CONF_TYPE_FLOAT, CONF_RANGE, -10.0, 10.0, NULL},
-    {"rc_buffer_size", &rc_buffer_size, CONF_TYPE_INT, CONF_RANGE, 0, 24000000, NULL},
-    {"rc_init_buffer", &rc_init_buffer, CONF_TYPE_FLOAT, CONF_RANGE, 0, 24000000, NULL},
-    {"rc_sens", &rc_sens, CONF_TYPE_INT, CONF_RANGE, 0, 100, NULL},
+    {"ratetol", &ratetol, CONF_TYPE_FLOAT, CONF_RANGE, 0.1, 100.0, NULL}, 
+    {"vbv_maxrate", &vbv_maxrate, CONF_TYPE_INT, CONF_RANGE, 0, 24000000, NULL}, 
+    {"vbv_bufsize", &vbv_bufsize, CONF_TYPE_INT, CONF_RANGE, 0, 24000000, NULL}, 
+    {"vbv_init", &vbv_init, CONF_TYPE_FLOAT, CONF_RANGE, 0.0, 1.0, NULL}, 
     {"qp_min", &qp_min, CONF_TYPE_INT, CONF_RANGE, 1, 51, NULL},
     {"qp_max", &qp_max, CONF_TYPE_INT, CONF_RANGE, 1, 51, NULL},
     {"qp_step", &qp_step, CONF_TYPE_INT, CONF_RANGE, 1, 50, NULL},
@@ -161,7 +164,7 @@
     x264_param_default(&mod->param);
     mod->param.i_frame_reference = frame_ref;
     mod->param.i_keyint_max = keyint_max;
-    mod->param.i_keyint_min = keyint_min > 0 ? keyint_min : keyint_max * 2 / 5;
+    mod->param.i_keyint_min = keyint_min;
     mod->param.i_scenecut_threshold = scenecut_threshold;
     mod->param.i_bframe = bframe;
     mod->param.b_bframe_adaptive = bframe_adaptive;
@@ -185,6 +188,7 @@
     mod->param.rc.f_qblur = qblur;
     mod->param.rc.f_complexity_blur = complexity_blur;
     mod->param.analyse.i_subpel_refine = subq;
+    mod->param.analyse.i_me_method = subq==1 ? X264_ME_DIA : X264_ME_HEX;
     mod->param.rc.psz_stat_out = passtmpfile;
     mod->param.rc.psz_stat_in = passtmpfile;
     if((pass & 2) && bitrate <= 0)
@@ -212,16 +216,17 @@
         break;
     }
     if(bitrate > 0) {
-        if(rc_buffer_size <= 0)
-            rc_buffer_size = bitrate;
-        mod->param.rc.b_cbr = 1;
-        mod->param.rc.i_bitrate = bitrate;
-        mod->param.rc.i_rc_buffer_size = rc_buffer_size;
-        if(rc_init_buffer > 1)
-            mod->param.rc.i_rc_init_buffer = rc_init_buffer;
-        else
-            mod->param.rc.i_rc_init_buffer = rc_buffer_size * rc_init_buffer;
-        mod->param.rc.i_rc_sens = rc_sens;
+        if((vbv_maxrate > 0) != (vbv_bufsize > 0)) {
+            mp_msg(MSGT_MENCODER, MSGL_ERR,           
+                "VBV requires both vbv_maxrate and vbv_bufsize.\n");               
+            return 0;            
+        }            
+        mod->param.rc.b_cbr = 1; 
+        mod->param.rc.i_bitrate = bitrate; 
+        mod->param.rc.f_rate_tolerance = ratetol; 
+        mod->param.rc.i_vbv_max_bitrate = vbv_maxrate;                                
+        mod->param.rc.i_vbv_buffer_size = vbv_bufsize; 
+        mod->param.rc.f_vbv_buffer_init = vbv_init;           
     }
     mod->param.rc.f_ip_factor = ip_factor;
     mod->param.rc.f_pb_factor = pb_factor;

