changeset 13325:f26d2c9aec04

2pass encoding support for x264(r46). patch by Loren Merritt and Jeff Clagg
author iive
date Sun, 12 Sep 2004 15:36:43 +0000
parents dcbdd8ea356d
children b76aca3e4c2f
files DOCS/man/en/mplayer.1 libmpcodecs/ve_x264.c
diffstat 2 files changed, 42 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/DOCS/man/en/mplayer.1	Sun Sep 12 14:01:13 2004 +0000
+++ b/DOCS/man/en/mplayer.1	Sun Sep 12 15:36:43 2004 +0000
@@ -6489,9 +6489,8 @@
 .TP
 .B frameref=<value>
 Number of previous frames used as predictors in a P-frame (default: 1).
-.br
-.I NOTE:
-As of x264 r38 this feature is not implemented yet.
+This may cause tiny changes in bitrate and PSNR.
+Some decoders are unable to deal with large frameref values.
 .
 .TP
 .B idrframe=<value>
@@ -6527,7 +6526,7 @@
 Affects the maximum allowed gradient within two adjacent blocks.
 .
 .TP
-.B cabac
+.B cabac\ \ \ 
 Use CABAC (Context-Adaptive Binary Arithmetic Coding).
 .
 .TP
@@ -6558,18 +6557,14 @@
 is about a factor of 10.
 Useful quantizers in H.264 tend to be very large compared to MPEG[124].
 .br
-.I NOTE:
-This option takes effect even if you specify a CBR encode.
-In such a case, the first encoded frame will use the quantization factor you
-specified, but in later frames, the ratecontrol decides what quants to use.
 .
 .TP
 .B qp_min=<2-51> (CBR only)
-Minimum quantizer, 20-40 seems to be a useful range (default: 2).
+Minimum quantizer, 15-35 seems to be a useful range (default: 10).
 .
 .TP
 .B qp_max=<2-51>  (CBR only)
-Maximum quantizer
+maximum quantizer (default: 51)
 .
 .TP
 .B qp_step=<value>
@@ -6587,7 +6582,7 @@
 .
 .TP
 .B rc_sens=<0-100>
-ratecontrol sensitivity (default: 100)
+ratecontrol sensitivity (default: 4)
 .
 .TP
 .B ip_factor=<value>
@@ -6610,7 +6605,7 @@
 more constant.
 .
 .TP
-.B qblur=<0-1>
+.B qblur=<0-99>
 Temporal blur of the quantization parameter (default: 0.5).
 Lower values allow the quantizer value to jump around more,
 higher values force it to vary more smoothly.
@@ -6626,17 +6621,18 @@
 .RSs
 -1: none
 .br
- 0: errors (for debugging x264)
+ 0: Print errors only.
 .br
  1: warnings
 .br
- 2: PSNR and other analysis stats when the encode finishes (default)
+ 2: PSNR, encoding times, and other analysis stats when the encode finishes
+(default)
 .br
  3: PSNR, QP, frametype, size, and other stats for every frame
 .REss
 .
 .TP
-.B psnr
+.B psnr\ \ \ 
 Print signal-to-noise ratio statistics.
 .
 .
--- a/libmpcodecs/ve_x264.c	Sun Sep 12 14:01:13 2004 +0000
+++ b/libmpcodecs/ve_x264.c	Sun Sep 12 15:36:43 2004 +0000
@@ -133,43 +133,55 @@
     mod->param.i_deblocking_filter_beta = deblockbeta;
     mod->param.b_cabac = cabac;
     mod->param.i_cabac_init_idc = cabacidc;
-    mod->param.i_qp_constant = qp_constant;
+
+    mod->param.rc.i_qp_constant = qp_constant;
     if(qp_min > qp_constant)
         qp_min = qp_constant;
     if(qp_max < qp_constant)
         qp_max = qp_constant;
-    mod->param.i_qp_min = qp_min;
-    mod->param.i_qp_max = qp_max;
-    mod->param.i_qp_step = qp_step;
-#if 0
-    mod->param.i_pass = pass;
-    mod->param.s_rc_eq = rc_eq;
-    mod->param.f_qcompress = qcomp;
-    mod->param.f_qblur = qblur;
-    mod->param.s_2pass_file_out = passtmpfile;
-    mod->param.s_2pass_file_in = passtmpfile;
+    mod->param.rc.i_qp_min = qp_min;
+    mod->param.rc.i_qp_max = qp_max;
+    mod->param.rc.i_qp_step = qp_step;
+    mod->param.rc.psz_rc_eq = rc_eq;
+    mod->param.rc.f_qcompress = qcomp;
+    mod->param.rc.f_qblur = qblur;
+    mod->param.rc.psz_stat_out = passtmpfile;
+    mod->param.rc.psz_stat_in = passtmpfile;
     if((pass & 2) && bitrate <= 0)
     {
         mp_msg(MSGT_MENCODER, MSGL_ERR,
                "2 pass encoding enabled, but no bitrate specified.\n");
         return 0;
     }
-#endif
+    switch(pass) {
+    case 0:
+        mod->param.rc.b_stat_write = 0;
+        mod->param.rc.b_stat_read = 0;
+        break;
+    case 1:
+        mod->param.rc.b_stat_write = 1;
+        mod->param.rc.b_stat_read = 0;
+        break;
+    case 2:
+        mod->param.rc.b_stat_write = 0;
+        mod->param.rc.b_stat_read = 1;
+        break;
+    }
     if(bitrate > 0) {
         if(rc_buffer_size <= 0)
             rc_buffer_size = bitrate;
         if(rc_init_buffer < 0)
             rc_init_buffer = rc_buffer_size/4;
-        mod->param.b_cbr = 1;
-        mod->param.i_bitrate = bitrate;
-        mod->param.i_rc_buffer_size = rc_buffer_size;
-        mod->param.i_rc_init_buffer = rc_init_buffer;
-        mod->param.i_rc_sens = rc_sens;
+        mod->param.rc.b_cbr = 1;
+        mod->param.rc.i_bitrate = bitrate;
+        mod->param.rc.i_rc_buffer_size = rc_buffer_size;
+        mod->param.rc.i_rc_init_buffer = rc_init_buffer;
+        mod->param.rc.i_rc_sens = rc_sens;
     }
     if(fullinter)
         mod->param.analyse.inter = X264_ANALYSE_I4x4 | X264_ANALYSE_PSUB16x16 | X264_ANALYSE_PSUB8x8;
-    mod->param.f_ip_factor = ip_factor;
-    mod->param.f_pb_factor = pb_factor;
+    mod->param.rc.f_ip_factor = ip_factor;
+    mod->param.rc.f_pb_factor = pb_factor;
 
     mod->param.i_width = width;
     mod->param.i_height = height;