summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRodeo <[email protected]>2012-03-28 23:09:08 +0000
committerRodeo <[email protected]>2012-03-28 23:09:08 +0000
commitcca9c898d2f57047ab2cdabee8c794ddf2775aa7 (patch)
tree00092d02ab4c0d905296f875c5f1f3865aa23ad9
parenta9d238763d17fafb04f96deed93b798310303f7d (diff)
encx264: use x264_param_apply_fastfirstpass.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4551 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r--gtk/src/hb-backend.c58
-rw-r--r--libhb/common.h1
-rw-r--r--libhb/encx264.c6
-rw-r--r--libhb/work.c8
-rw-r--r--macosx/Controller.m24
-rw-r--r--test/test.c44
6 files changed, 32 insertions, 109 deletions
diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c
index e48f8eaba..2b2b66348 100644
--- a/gtk/src/hb-backend.c
+++ b/gtk/src/hb-backend.c
@@ -3083,12 +3083,6 @@ init_ui_combo_boxes(GtkBuilder *builder)
init_combo_box(builder, combo_name_map[ii].name);
}
}
-
-static const char * turbo_lavc_opts = "";
-
-static const char * turbo_x264_opts =
- "ref=1:subme=2:me=dia:analyse=none:trellis=0:"
- "no-fast-pskip=0:8x8dct=0";
// Construct the advanced options string
// The result is allocated, so someone must free it at some point.
@@ -5176,58 +5170,19 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex)
*/
job->pass = 1;
job->indepth_scan = 0;
+ job->advanced_opts = advanced_opts;
/*
- * If turbo options have been selected then append them
- * to the advanced_opts now (size includes one ':' and the '\0')
+ * If turbo options have been selected then set job->fastfirstpass
*/
- if( ghb_settings_get_boolean(js, "VideoTurboTwoPass") )
+ if( ghb_settings_get_boolean(js, "VideoTurboTwoPass") &&
+ job->vcodec == HB_VCODEC_X264 )
{
- gchar *tmp_advanced_opts;
- gchar *extra_opts;
-
- if (job->vcodec == HB_VCODEC_X264)
- {
- gint badapt;
-
- badapt = ghb_lookup_badapt(advanced_opts);
- if (badapt == 2)
- {
- extra_opts = g_strdup_printf("%s", turbo_x264_opts);
- }
- else
- {
- extra_opts = g_strdup_printf("%s:weightb=0", turbo_x264_opts);
- }
- }
- else if (job->vcodec == HB_VCODEC_FFMPEG_MPEG4)
- {
- extra_opts = g_strdup_printf("%s", turbo_lavc_opts);
- }
- else
- {
- extra_opts = g_strdup("");
- }
-
- if ( advanced_opts )
- {
- tmp_advanced_opts = g_strdup_printf("%s:%s", advanced_opts, extra_opts);
- }
- else
- {
- /*
- * No advanced_opts to modify, but apply the turbo options
- * anyway as they may be modifying defaults
- */
- tmp_advanced_opts = g_strdup_printf("%s", extra_opts);
- }
- g_free(extra_opts);
-
- job->advanced_opts = tmp_advanced_opts;
+ job->fastfirstpass = 1;
}
else
{
- job->advanced_opts = advanced_opts;
+ job->fastfirstpass = 0;
}
job->sequence_id = (unique_id & 0xFFFFFF) | (sub_id++ << 24);
hb_add( h, job );
@@ -5242,7 +5197,6 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex)
* attribute of the job).
*/
job->indepth_scan = 0;
- job->advanced_opts = advanced_opts;
job->sequence_id = (unique_id & 0xFFFFFF) | (sub_id++ << 24);
hb_add( h, job );
//if (job->advanced_opts != NULL)
diff --git a/libhb/common.h b/libhb/common.h
index 1f9dfa97a..e8ca7e1fd 100644
--- a/libhb/common.h
+++ b/libhb/common.h
@@ -291,6 +291,7 @@ struct hb_job_s
int vrate_base;
int cfr;
int pass;
+ int fastfirstpass;
char *advanced_opts;
char *x264_profile;
char *x264_preset;
diff --git a/libhb/encx264.c b/libhb/encx264.c
index 7836b9add..f48aa499a 100644
--- a/libhb/encx264.c
+++ b/libhb/encx264.c
@@ -263,6 +263,12 @@ int encx264Init( hb_work_object_t * w, hb_job_t * job )
hb_apply_h264_level( &param, job->h264_level, job->x264_profile );
}
+ /* Turbo first pass */
+ if( job->pass == 1 && job->fastfirstpass == 1 )
+ {
+ x264_param_apply_fastfirstpass( &param );
+ }
+
/* B-frames are on by default.*/
job->areBframes = 1;
diff --git a/libhb/work.c b/libhb/work.c
index 7b84cd30b..96c3b9263 100644
--- a/libhb/work.c
+++ b/libhb/work.c
@@ -369,6 +369,14 @@ void hb_display_job_info( hb_job_t * job )
else
{
hb_log( " + bitrate: %d kbps, pass: %d", job->vbitrate, job->pass );
+ if( job->pass == 1 && job->fastfirstpass == 1 &&
+ job->vcodec == HB_VCODEC_X264 )
+ {
+ hb_log( " + fast first pass" );
+ hb_log( " + options: ref=1:8x8dct=0:me=dia:trellis=0" );
+ hb_log( " analyse=i4x4 (if originally enabled, else analyse=none)" );
+ hb_log( " subq=2 (if originally greater than 2, else subq unchanged)" );
+ }
}
}
diff --git a/macosx/Controller.m b/macosx/Controller.m
index 918de6588..522615f79 100644
--- a/macosx/Controller.m
+++ b/macosx/Controller.m
@@ -2718,24 +2718,12 @@ fWorkingCount = 0;
if( [[queueToApply objectForKey:@"VideoTwoPass"] intValue] == 1 )
{
job->indepth_scan = 0;
-
-
-
job->pass = 1;
hb_add( fQueueEncodeLibhb, job );
job->pass = 2;
- if( job->vcodec == HB_VCODEC_X264 )
- {
- job->advanced_opts = strdup( [[queueToApply objectForKey:@"x264Option"] UTF8String] );
- }
- else if( job->vcodec & HB_VCODEC_FFMPEG_MASK )
- {
- job->advanced_opts = strdup( [[queueToApply objectForKey:@"lavcOption"] UTF8String] );
- }
-
hb_add( fQueueEncodeLibhb, job );
}
@@ -3093,6 +3081,7 @@ fWorkingCount = 0;
/* Below Sends x264 options to the core library if x264 is selected*/
/* Lets use this as per Nyx, Thanks Nyx! */
/* For previews we ignore the turbo option for the first pass of two since we only use 1 pass */
+ job->fastfirstpass = 0;
job->advanced_opts = strdup( [[fAdvancedOptions optionsString] UTF8String] );
@@ -3589,18 +3578,13 @@ bool one_burned = FALSE;
/* Turbo first pass if two pass and Turbo First pass is selected */
if( [[queueToApply objectForKey:@"VideoTwoPass"] intValue] == 1 && [[queueToApply objectForKey:@"VideoTurboTwoPass"] intValue] == 1 )
{
- /* pass the "Turbo" string to be appended to the existing x264 opts string into a variable for the first pass */
- NSString *firstPassOptStringTurbo = @":ref=1:subme=2:me=dia:analyse=none:trellis=0:no-fast-pskip=0:8x8dct=0:weightb=0";
- /* append the "Turbo" string variable to the existing opts string.
- * Note: the "Turbo" string must be appended, not prepended to work properly */
- NSString *firstPassOptStringCombined = [[queueToApply objectForKey:@"x264Option"] stringByAppendingString:firstPassOptStringTurbo];
- job->advanced_opts = strdup( [firstPassOptStringCombined UTF8String] );
+ job->fastfirstpass = 1;
}
else
{
- job->advanced_opts = strdup( [[queueToApply objectForKey:@"x264Option"] UTF8String] );
+ job->fastfirstpass = 0;
}
-
+ job->advanced_opts = strdup( [[queueToApply objectForKey:@"x264Option"] UTF8String] );
}
else if( job->vcodec & HB_VCODEC_FFMPEG_MASK )
{
diff --git a/test/test.c b/test/test.c
index 411c0adc6..f8d375b64 100644
--- a/test/test.c
+++ b/test/test.c
@@ -116,7 +116,6 @@ static int chapter_end = 0;
static int chapter_markers = 0;
static char * marker_file = NULL;
static char * advanced_opts = NULL;
-static char * advanced_opts2 = NULL;
static char * x264_profile = NULL;
static char * x264_preset = NULL;
static char * x264_tune = NULL;
@@ -124,7 +123,6 @@ static char * h264_level = NULL;
static int maxHeight = 0;
static int maxWidth = 0;
static int turbo_opts_enabled = 0;
-static char * turbo_opts = "ref=1:subme=2:me=dia:analyse=none:trellis=0:no-fast-pskip=0:8x8dct=0:weightb=0";
static int largeFileSize = 0;
static int preset = 0;
static char * preset_name = 0;
@@ -367,8 +365,7 @@ int main( int argc, char ** argv )
str_vfree( acompressions );
if( acodecs ) free( acodecs );
if (native_language ) free (native_language );
- if( advanced_opts ) free (advanced_opts );
- if( advanced_opts2 ) free (advanced_opts2 );
+ if( advanced_opts ) free (advanced_opts );
if (preset_name) free (preset_name);
if( stop_at_string ) free( stop_at_string );
if( start_at_string ) free( start_at_string );
@@ -2485,41 +2482,16 @@ static int HandleEvents( hb_handle_t * h )
job->indepth_scan = 0;
- if (advanced_opts)
+ /* Turbo first pass */
+ if( turbo_opts_enabled )
{
- advanced_opts2 = strdup(advanced_opts);
+ job->fastfirstpass = 1;
}
-
- /*
- * If turbo options have been selected then append them
- * to the advanced_opts now (size includes one ':' and the '\0')
- */
- if( turbo_opts_enabled )
+ else
{
- int size = (advanced_opts ? strlen(advanced_opts) : 0) + strlen(turbo_opts) + 2;
- char *tmp_advanced_opts;
-
- tmp_advanced_opts = malloc(size * sizeof(char));
- if( advanced_opts )
- {
- snprintf( tmp_advanced_opts, size, "%s:%s",
- advanced_opts, turbo_opts );
- free( advanced_opts );
- } else {
- /*
- * No advanced_opts to modify, but apply the turbo options
- * anyway as they may be modifying defaults
- */
- snprintf( tmp_advanced_opts, size, "%s",
- turbo_opts );
- }
- advanced_opts = tmp_advanced_opts;
-
- fprintf( stderr, "Modified x264 options for pass 1 to append turbo options: %s\n",
- advanced_opts );
-
- job->advanced_opts = advanced_opts;
+ job->fastfirstpass = 0;
}
+
hb_add( h, job );
job->pass = 2;
@@ -2531,8 +2503,6 @@ static int HandleEvents( hb_handle_t * h )
*/
job->indepth_scan = 0;
- job->advanced_opts = advanced_opts2;
-
hb_add( h, job );
}
else