1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
--- libquicktime-0.9.9/plugins/x264/x264.c 2006/06/25 13:10:30 1.7
+++ libquicktime-0.9.9/plugins/x264/x264.c 2006/07/25 12:17:37 1.8
@@ -437,7 +437,7 @@
codec->stats_filename = malloc(strlen(stats_file)+1);
strcpy(codec->stats_filename, stats_file);
- fprintf(stderr, "set_pass_x264 %d %d %s\n", pass, total_passes, stats_file);
+ // fprintf(stderr, "set_pass_x264 %d %d %s\n", pass, total_passes, stats_file);
return 1;
}
@@ -488,22 +488,28 @@
codec->params.i_fps_den = lqt_frame_duration(file, track, NULL);
/* Set multipass control */
-
- /* Open encoder */
- if(codec->pass == 1)
+ if(codec->total_passes)
{
- /* Strings will be made private by x264 */
- codec->params.rc.psz_stat_out = codec->stats_filename;
- codec->params.rc.b_stat_write = 1;
- }
- else if(codec->total_passes && (codec->pass == codec->total_passes))
- {
- /* Strings will be made private by x264 */
- codec->params.rc.psz_stat_in = codec->stats_filename;
- codec->params.rc.b_stat_read = 1;
+ /* Force ABR */
+ codec->params.rc.i_rc_method = X264_RC_ABR;
+ codec->params.rc.i_rf_constant = 0;
+ if(codec->pass == 1)
+ {
+ /* Strings will be made private by x264 */
+ codec->params.rc.psz_stat_out = codec->stats_filename;
+ codec->params.rc.b_stat_write = 1;
+ }
+ else if(codec->pass == codec->total_passes)
+ {
+ /* Strings will be made private by x264 */
+ codec->params.rc.psz_stat_in = codec->stats_filename;
+ codec->params.rc.b_stat_read = 1;
+ }
}
+ /* Open encoder */
+
codec->enc = x264_encoder_open(&codec->params);
if(!codec->enc)
{
@@ -621,6 +627,14 @@
{ "Auto", X264_DIRECT_PRED_AUTO }
};
+enum_t rc_methods[] =
+ {
+ { "Constant quality", X264_RC_CQP },
+ { "Average bitrate", X264_RC_ABR },
+ { "CRF based VBR", X264_RC_CRF }
+ };
+
+
static int set_parameter(quicktime_t *file,
int track,
char *key,
@@ -637,22 +651,11 @@
INTPARAM("x264_i_bframe_bias", codec->params.i_bframe_bias);
INTPARAM("x264_b_bframe_pyramid", codec->params.b_bframe_pyramid);
- if(!strcasecmp(key, "x264_i_bitrate"))
- {
- if(*(int*)(value))
- {
- codec->params.rc.b_cbr = 1;
- codec->params.rc.i_bitrate = *(int*)(value);
- }
- else
- {
- codec->params.rc.b_cbr = 0;
- codec->params.rc.i_bitrate = 0;
- }
- found = 1;
- }
-
+ ENUMPARAM("x264_i_rc_method", codec->params.rc.i_rc_method, rc_methods);
+ INTPARAM("x264_i_bitrate", codec->params.rc.i_bitrate);
+
INTPARAM("x264_i_qp_constant", codec->params.rc.i_qp_constant);
+ INTPARAM("x264_i_rf_constant", codec->params.rc.i_rf_constant);
INTPARAM("x264_i_qp_min", codec->params.rc.i_qp_min);
INTPARAM("x264_i_qp_max", codec->params.rc.i_qp_max);
INTPARAM("x264_i_qp_step", codec->params.rc.i_qp_step);
--- libquicktime-0.9.9/plugins/x264/lqt_x264.c 2006/04/10 21:46:15 1.2
+++ libquicktime-0.9.9/plugins/x264/lqt_x264.c 2006/07/25 12:17:37 1.3
@@ -74,6 +74,21 @@
type: LQT_PARAMETER_SECTION
},
{
+ name: "x264_i_rc_method",
+ real_name: "Ratecontrol method",
+ type: LQT_PARAMETER_STRINGLIST,
+ val_default: { val_string: "Constant quality" },
+ stringlist_options: (char*[]){ "Constant quality",
+ "Average bitrate",
+ "CRF based VBR",
+ (char*)0 },
+ help_string: "Ratecontrol method:\n\
+Constant quality: Specify a quantizer parameter below\n\
+Average bitrate: Specify a bitrate below\n\
+CRF based VBR: Specify a rate factor below\n\
+Selecting 2-pass encoding will force Average bitrate.",
+ },
+ {
name: "x264_i_bitrate",
real_name: "Bitrate",
type: LQT_PARAMETER_INT,
@@ -81,6 +96,16 @@
help_string: "Bitrate in kbit/s. 0 means VBR (recommended)"
},
{
+ name: "x264_i_rf_constant",
+ real_name: "Nominal Quantizer parameter",
+ type: LQT_PARAMETER_INT,
+ val_default: { val_int: 26 },
+ val_min: { val_int: 0 },
+ val_max: { val_int: 51 },
+ help_string: "This selects the nominal quantizer to use (1 to 51). Lower values result in " \
+ "better fidelity, but higher bitrates. 26 is a good default value. 0 means lossless."
+ },
+ {
name: "x264_i_qp_constant",
real_name: "Quantizer parameter",
type: LQT_PARAMETER_INT,
@@ -90,7 +115,9 @@
help_string: "This selects the quantizer to use (1 to 51). Lower values result in " \
"better fidelity, but higher bitrates. 26 is a good default value. 0 means lossless."
},
- {
+
+
+{
name: "x264_i_qp_min",
real_name: "Minimum quantizer parameter",
type: LQT_PARAMETER_INT,
|