[MPlayer-dev-eng] [PATCH] H.264 encoding in mencoder

Jeff Clagg snacky at ikaruga.co.uk
Tue Sep 7 00:13:57 CEST 2004


This time, with less wrong stuff in the manpage.

-------------- next part --------------
diff -ruN main.orig/DOCS/man/en/mplayer.1 main/DOCS/man/en/mplayer.1
--- main.orig/DOCS/man/en/mplayer.1	2004-09-06 16:58:28.000000000 -0400
+++ main/DOCS/man/en/mplayer.1	2004-09-06 18:06:33.000000000 -0400
@@ -6247,9 +6247,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>
@@ -6285,7 +6284,7 @@
 Affects the maximum allowed gradient within two adjacent blocks.
 .
 .TP
-.B cabac
+.B cabac\ \ \ 
 Use CABAC (Context-Adaptive Binary Arithmetic Coding).
 .
 .TP
@@ -6316,18 +6315,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>
@@ -6345,7 +6340,7 @@
 .
 .TP
 .B rc_sens=<0-100>
-ratecontrol sensitivity (default: 100)
+ratecontrol sensitivity (default: 4)
 .
 .TP
 .B ip_factor=<value>
@@ -6368,7 +6363,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.
@@ -6384,17 +6379,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.
 .
 .
diff -ruN main.orig/libmpcodecs/ve_x264.c main/libmpcodecs/ve_x264.c
--- main.orig/libmpcodecs/ve_x264.c	2004-08-27 16:43:05.000000000 -0400
+++ main/libmpcodecs/ve_x264.c	2004-09-06 17:54:11.000000000 -0400
@@ -29,7 +29,9 @@
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
+#ifdef HAVE_STDINT_H
 #include <stdint.h>
+#endif
 
 #include "../config.h"
 #include "../mp_msg.h"
@@ -133,44 +135,57 @@
     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;
 
+    if(fullinter)
+        mod->param.analyse.inter = X264_ANALYSE_I4x4 |
+            X264_ANALYSE_PSUB16x16 | X264_ANALYSE_PSUB8x8;
     mod->param.i_width = width;
     mod->param.i_height = height;
     mod->param.i_fps_num = mod->mux->h.dwRate;


More information about the MPlayer-dev-eng mailing list