+ if ( job->cfr == 1 )
+ {
+ param.i_timebase_num = 0;
+ param.i_timebase_den = 0;
+ param.b_vfr_input = 0;
+ }
+ else
+ {
+ param.i_timebase_num = 1;
+ param.i_timebase_den = 90000;
+ }
+
+ /* Disable annexb. Inserts size into nal header instead of start code */
+ param.b_annexb = 0;
+
+ /* Set min:max key intervals ratio to 1:10 of fps.
+ * This section is skipped if fps=25 (default).
+ */
+ if (job->vrate_base != 1080000)
+ {
+ if (job->pass == 2 && !job->cfr )
+ {
+ /* Even though the framerate might be different due to VFR,
+ we still want the same keyframe intervals as the 1st pass,
+ so the 1st pass stats won't conflict on frame decisions. */
+ hb_interjob_t * interjob = hb_interjob_get( job->h );
+ param.i_keyint_max = 10 * (int)( (double)interjob->vrate / (double)interjob->vrate_base + 0.5 );
+ }
+ else
+ {
+ /* adjust +0.5 for when fps has remainder to bump
+ { 23.976, 29.976, 59.94 } to { 24, 30, 60 } */
+ param.i_keyint_max = 10 * (int)( (double)job->vrate / (double)job->vrate_base + 0.5 );
+ }
+ }
+
+ param.i_log_level = X264_LOG_INFO;
+
+ /*
+ This section passes the string x264opts to libx264 for parsing into
+ parameter names and values.
+
+ The string is set up like this:
+ option1=value1:option2=value 2
+
+ So, you have to iterate through based on the colons, and then put
+ the left side of the equals sign in "name" and the right side into
+ "value." Then you hand those strings off to x264 for interpretation.
+
+ This is all based on the universal x264 option handling Loren
+ Merritt implemented in the Mplayer/Mencoder project.
+ */
+
+ if( job->x264opts != NULL && *job->x264opts != '\0' )
+ {
+ char *x264opts, *x264opts_start;
+
+ x264opts = x264opts_start = strdup(job->x264opts);
+
+ while( x264opts_start && *x264opts )
+ {
+ char *name = x264opts;
+ char *value;
+ int ret;
+
+ x264opts += strcspn( x264opts, ":" );
+ if( *x264opts )
+ {
+ *x264opts = 0;
+ x264opts++;
+ }
+
+ value = strchr( name, '=' );
+ if( value )
+ {
+ *value = 0;
+ value++;
+ }
+
+ /* Here's where the strings are passed to libx264 for parsing. */
+ ret = x264_param_parse( ¶m, name, value );
+
+ /* Let x264 sanity check the options for us*/
+ if( ret == X264_PARAM_BAD_NAME )
+ hb_log( "x264 options: Unknown suboption %s", name );
+ if( ret == X264_PARAM_BAD_VALUE )
+ hb_log( "x264 options: Bad argument %s=%s", name, value ? value : "(null)" );
+ }
+ free(x264opts_start);
+ }
+
+ /* B-frames are on by default.*/
+ job->areBframes = 1;
+
+ if( param.i_bframe && param.i_bframe_pyramid )
+ {
+ /* Note b-pyramid here, so the initial delay can be doubled */
+ job->areBframes = 2;
+ }
+ else if( !param.i_bframe )