summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gtk/src/hb-backend.c72
-rw-r--r--libhb/common.c1
-rw-r--r--libhb/common.h3
-rw-r--r--libhb/hb.c38
-rw-r--r--libhb/hb_json.c27
-rw-r--r--macosx/HBCore.m49
-rw-r--r--macosx/HBJob.m1
-rw-r--r--macosx/HBPreviewGenerator.m38
-rw-r--r--test/test.c69
9 files changed, 53 insertions, 245 deletions
diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c
index da7252f78..509c9acc8 100644
--- a/gtk/src/hb-backend.c
+++ b/gtk/src/hb-backend.c
@@ -4178,7 +4178,6 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, int titleindex)
hb_list_t * list;
const hb_title_t * title;
hb_job_t * job;
- gint sub_id = 0;
hb_filter_object_t * filter;
gchar *filter_str;
gchar *dest_str = NULL;
@@ -4705,72 +4704,11 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, int titleindex)
}
free(meta);
- if (job->indepth_scan == 1)
- {
- // Subtitle scan. Look for subtitle matching audio language
-
- /*
- * When subtitle scan is enabled do a fast pre-scan job
- * which will determine which subtitles to enable, if any.
- */
- job->pass = -1;
- job->indepth_scan = 1;
- hb_job_set_encoder_options(job, NULL);
-
- /*
- * Add the pre-scan job
- */
- job->sequence_id = (unique_id & 0xFFFFFF) | (sub_id++ << 24);
- hb_add( h, job );
- }
-
- if( ghb_settings_get_boolean(js, "VideoTwoPass") &&
- !ghb_settings_get_boolean(js, "vquality_type_constant"))
- {
- /*
- * If subtitle_scan is enabled then only turn it on
- * for the second pass and then off again for the
- * second.
- */
- job->pass = 1;
- job->indepth_scan = 0;
- ghb_set_video_encoder_opts(job, js);
-
- /*
- * If turbo options have been selected then set job->fastfirstpass
- */
- if(ghb_settings_get_boolean(js, "VideoTurboTwoPass") &&
- (job->vcodec == HB_VCODEC_X264 || job->vcodec == HB_VCODEC_X265))
- {
- job->fastfirstpass = 1;
- }
- else
- {
- job->fastfirstpass = 0;
- }
-
- job->sequence_id = (unique_id & 0xFFFFFF) | (sub_id++ << 24);
- hb_add( h, job );
-
- job->pass = 2;
- /*
- * On the second pass we turn off subtitle scan so that we
- * can actually encode using any subtitles that were auto
- * selected in the first pass (using the whacky select-subtitle
- * attribute of the job).
- */
- job->indepth_scan = 0;
- job->sequence_id = (unique_id & 0xFFFFFF) | (sub_id++ << 24);
- hb_add( h, job );
- }
- else
- {
- ghb_set_video_encoder_opts(job, js);
- job->indepth_scan = 0;
- job->pass = 0;
- job->sequence_id = (unique_id & 0xFFFFFF) | (sub_id++ << 24);
- hb_add( h, job );
- }
+ job->twopass = ghb_settings_get_boolean(js, "VideoTwoPass");
+ job->fastfirstpass = ghb_settings_get_boolean(js, "VideoTurboTwoPass");
+ job->sequence_id = unique_id;
+ ghb_set_video_encoder_opts(job, js);
+ hb_add(h, job);
hb_job_close(&job);
}
diff --git a/libhb/common.c b/libhb/common.c
index fed775b4b..29b8ea833 100644
--- a/libhb/common.c
+++ b/libhb/common.c
@@ -3001,6 +3001,7 @@ static void job_setup(hb_job_t * job, hb_title_t * title)
job->vcodec = HB_VCODEC_FFMPEG_MPEG4;
job->vquality = -1.0;
job->vbitrate = 1000;
+ job->twopass = 0;
job->pass = 0;
job->vrate = title->vrate;
diff --git a/libhb/common.h b/libhb/common.h
index f7952181f..0478d2b5d 100644
--- a/libhb/common.h
+++ b/libhb/common.h
@@ -494,7 +494,8 @@ struct hb_job_s
int vbitrate;
hb_rational_t vrate;
int cfr;
- int pass;
+ PRIVATE int pass;
+ int twopass; // Enable 2-pass encode. Boolean
int fastfirstpass;
char *encoder_preset;
char *encoder_tune;
diff --git a/libhb/hb.c b/libhb/hb.c
index 73dbd448c..b447c3fd0 100644
--- a/libhb/hb.c
+++ b/libhb/hb.c
@@ -1255,7 +1255,7 @@ hb_job_t * hb_current_job( hb_handle_t * h )
* @param h Handle to hb_handle_t.
* @param job Handle to hb_job_t.
*/
-void hb_add( hb_handle_t * h, hb_job_t * job )
+static void hb_add_internal( hb_handle_t * h, hb_job_t * job )
{
hb_job_t * job_copy;
hb_audio_t * audio;
@@ -1347,6 +1347,40 @@ void hb_add( hb_handle_t * h, hb_job_t * job )
h->job_count_permanent++;
}
+void hb_add( hb_handle_t * h, hb_job_t * job )
+{
+ int sub_id = 0;
+
+ if (job->vquality >= 0)
+ {
+ job->twopass = 0;
+ }
+ if (job->indepth_scan)
+ {
+ hb_deep_log(2, "Adding subtitle scan pass");
+ job->pass = -1;
+ job->sequence_id = (job->sequence_id & 0xFFFFFF) | (sub_id++ << 24);
+ hb_add_internal(h, job);
+ job->indepth_scan = 0;
+ }
+ if (job->twopass)
+ {
+ hb_deep_log(2, "Adding two-pass encode");
+ job->pass = 1;
+ job->sequence_id = (job->sequence_id & 0xFFFFFF) | (sub_id++ << 24);
+ hb_add_internal(h, job);
+ job->pass = 2;
+ job->sequence_id = (job->sequence_id & 0xFFFFFF) | (sub_id++ << 24);
+ hb_add_internal(h, job);
+ }
+ else
+ {
+ job->pass = 0;
+ job->sequence_id = (job->sequence_id & 0xFFFFFF) | (sub_id++ << 24);
+ hb_add_internal(h, job);
+ }
+}
+
/**
* Removes a job from the job list.
* @param h Handle to hb_handle_t.
@@ -1789,7 +1823,7 @@ void hb_set_state( hb_handle_t * h, hb_state_t * s )
// Set which job is being worked on
if (h->current_job)
- h->state.param.working.sequence_id = h->current_job->sequence_id;
+ h->state.param.working.sequence_id = h->current_job->sequence_id & 0xFFFFFF;
else
h->state.param.working.sequence_id = 0;
}
diff --git a/libhb/hb_json.c b/libhb/hb_json.c
index 111dfc3a4..75a657efb 100644
--- a/libhb/hb_json.c
+++ b/libhb/hb_json.c
@@ -479,7 +479,7 @@ char* hb_job_to_json( const hb_job_t * job )
else
{
json_object_set_new(video_dict, "Bitrate", json_integer(job->vbitrate));
- json_object_set_new(video_dict, "TwoPass", json_boolean(job->pass));
+ json_object_set_new(video_dict, "TwoPass", json_boolean(job->twopass));
json_object_set_new(video_dict, "Turbo",
json_boolean(job->fastfirstpass));
}
@@ -705,6 +705,7 @@ hb_job_t* hb_json_to_job( hb_handle_t * h, const char * json_job )
result = json_unpack_ex(dict, &error, 0,
"{"
+ // SequenceID
"s:i,"
// Destination {File, Mux, ChapterMarkers, Mp4Options {
// Mp4Optimize, IpodAtom}
@@ -758,7 +759,7 @@ hb_job_t* hb_json_to_job( hb_handle_t * h, const char * json_job )
"Profile", unpack_s(&video_profile),
"Level", unpack_s(&video_level),
"Options", unpack_s(&video_options),
- "TwoPass", unpack_b(&job->pass),
+ "TwoPass", unpack_b(&job->twopass),
"Turbo", unpack_b(&job->fastfirstpass),
"ColorMatrixCode", unpack_i(&job->color_matrix_code),
"Audio",
@@ -1087,27 +1088,7 @@ int hb_add_json( hb_handle_t * h, const char * json_job )
if (job == NULL)
return -1;
- if (job->indepth_scan)
- {
- hb_deep_log(2, "Adding subtitle scan pass");
- int pass = job->pass;
- job->pass = -1;
- hb_add(h, job);
- job->pass = pass;
- job->indepth_scan = 0;
- }
- if (job->pass)
- {
- hb_deep_log(2, "Adding two-pass encode");
- job->pass = 1;
- hb_add(h, job);
- job->pass = 2;
- hb_add(h, job);
- }
- else
- {
- hb_add(h, job);
- }
+ hb_add(h, job);
hb_job_close(&job);
return 0;
diff --git a/macosx/HBCore.m b/macosx/HBCore.m
index a7156ab22..a1b9c995c 100644
--- a/macosx/HBCore.m
+++ b/macosx/HBCore.m
@@ -238,54 +238,7 @@ NSString *HBCoreMuxingNotification = @"HBCoreMuxingNotification";
[HBUtilities writeToActivityLog: "processNewQueueEncode number of passes expected is: %d", (job.video.twoPass + 1)];
hb_job_set_file(hb_job, job.destURL.path.fileSystemRepresentation);
- // If scanning we need to do some extra setup of the job.
- if (hb_job->indepth_scan == 1)
- {
- char *encoder_preset_tmp = hb_job->encoder_preset != NULL ? strdup(hb_job->encoder_preset) : NULL;
- char *encoder_tune_tmp = hb_job->encoder_tune != NULL ? strdup(hb_job->encoder_tune) : NULL;
- char *encoder_options_tmp = hb_job->encoder_options != NULL ? strdup(hb_job->encoder_options) : NULL;
- char *encoder_profile_tmp = hb_job->encoder_profile != NULL ? strdup(hb_job->encoder_profile) : NULL;
- char *encoder_level_tmp = hb_job->encoder_level != NULL ? strdup(hb_job->encoder_level) : NULL;
- /*
- * When subtitle scan is enabled do a fast pre-scan job
- * which will determine which subtitles to enable, if any.
- */
- hb_job_set_encoder_preset (hb_job, NULL);
- hb_job_set_encoder_tune (hb_job, NULL);
- hb_job_set_encoder_options(hb_job, NULL);
- hb_job_set_encoder_profile(hb_job, NULL);
- hb_job_set_encoder_level (hb_job, NULL);
- hb_job->pass = -1;
- hb_add(self.hb_handle, hb_job);
- /*
- * reset the advanced settings
- */
- hb_job_set_encoder_preset (hb_job, encoder_preset_tmp);
- hb_job_set_encoder_tune (hb_job, encoder_tune_tmp);
- hb_job_set_encoder_options(hb_job, encoder_options_tmp);
- hb_job_set_encoder_profile(hb_job, encoder_profile_tmp);
- hb_job_set_encoder_level (hb_job, encoder_level_tmp);
- free(encoder_preset_tmp);
- free(encoder_tune_tmp);
- free(encoder_options_tmp);
- free(encoder_profile_tmp);
- free(encoder_level_tmp);
- }
-
- if (job.video.twoPass)
- {
- hb_job->indepth_scan = 0;
- hb_job->pass = 1;
- hb_add(self.hb_handle, hb_job);
- hb_job->pass = 2;
- hb_add(self.hb_handle, hb_job);
- }
- else
- {
- hb_job->indepth_scan = 0;
- hb_job->pass = 0;
- hb_add(self.hb_handle, hb_job);
- }
+ hb_add(self.hb_handle, hb_job);
// Free the job
hb_job_close(&hb_job);
diff --git a/macosx/HBJob.m b/macosx/HBJob.m
index 62280becc..6bb19b2c0 100644
--- a/macosx/HBJob.m
+++ b/macosx/HBJob.m
@@ -233,6 +233,7 @@ NSString *keyContainerTag = @"keyContainerTag";
job->ipod_atom = self.mp4iPodCompatible;
}
+ job->twopass = self.video.twoPass;
if (job->vcodec == HB_VCODEC_X264 || job->vcodec == HB_VCODEC_X265)
{
// set fastfirstpass if 2-pass and Turbo are enabled
diff --git a/macosx/HBPreviewGenerator.m b/macosx/HBPreviewGenerator.m
index 70eec3d74..f60305622 100644
--- a/macosx/HBPreviewGenerator.m
+++ b/macosx/HBPreviewGenerator.m
@@ -242,46 +242,8 @@ typedef enum EncodeState : NSUInteger {
self.core = [[[HBCore alloc] initWithLoggingLevel:loggingLevel] autorelease];
self.core.name = @"PreviewCore";
- /*
- * If scanning we need to do some extra setup of the job.
- */
- if (job->indepth_scan == 1)
- {
- char *encoder_preset_tmp = job->encoder_preset != NULL ? strdup(job->encoder_preset) : NULL;
- char *encoder_tune_tmp = job->encoder_tune != NULL ? strdup(job->encoder_tune) : NULL;
- char *encoder_options_tmp = job->encoder_options != NULL ? strdup(job->encoder_options) : NULL;
- char *encoder_profile_tmp = job->encoder_profile != NULL ? strdup(job->encoder_profile) : NULL;
- char *encoder_level_tmp = job->encoder_level != NULL ? strdup(job->encoder_level) : NULL;
- /*
- * When subtitle scan is enabled do a fast pre-scan job
- * which will determine which subtitles to enable, if any.
- */
- hb_job_set_encoder_preset (job, NULL);
- hb_job_set_encoder_tune (job, NULL);
- hb_job_set_encoder_options(job, NULL);
- hb_job_set_encoder_profile(job, NULL);
- hb_job_set_encoder_level (job, NULL);
- job->pass = -1;
- hb_add(self.core.hb_handle, job);
- /*
- * reset the advanced settings
- */
- hb_job_set_encoder_preset (job, encoder_preset_tmp);
- hb_job_set_encoder_tune (job, encoder_tune_tmp);
- hb_job_set_encoder_options(job, encoder_options_tmp);
- hb_job_set_encoder_profile(job, encoder_profile_tmp);
- hb_job_set_encoder_level (job, encoder_level_tmp);
- free(encoder_preset_tmp);
- free(encoder_tune_tmp);
- free(encoder_options_tmp);
- free(encoder_profile_tmp);
- free(encoder_level_tmp);
- }
/* Go ahead and perform the actual encoding preview scan */
- job->indepth_scan = 0;
- job->pass = 0;
-
hb_add(self.core.hb_handle, job);
/* we need to clean up the various lists after the job(s) have been set */
diff --git a/test/test.c b/test/test.c
index 4277f8172..59640d3f6 100644
--- a/test/test.c
+++ b/test/test.c
@@ -2810,74 +2810,11 @@ static int HandleEvents( hb_handle_t * h )
/* OpenCL */
job->use_opencl = use_opencl;
- if( subtitle_scan )
- {
- /*
- * When subtitle scan is enabled do a fast pre-scan job
- * which will determine which subtitles to enable, if any.
- */
- job->pass = -1;
-
- hb_job_set_encoder_options(job, NULL);
-
- job->indepth_scan = subtitle_scan;
- fprintf( stderr, "Subtitle Scan Enabled - enabling "
- "subtitles if found for foreign language segments\n");
-
- /*
- * Add the pre-scan job
- */
- hb_add( h, job );
- }
-
+ job->indepth_scan = subtitle_scan;
+ job->twopass = twoPass;
hb_job_set_encoder_options(job, advanced_opts);
- if( twoPass )
- {
- /*
- * If subtitle_scan is enabled then only turn it on
- * for the first pass and then off again for the
- * second.
- */
- job->pass = 1;
-
- job->indepth_scan = 0;
-
- /* Turbo first pass */
- if( turbo_opts_enabled )
- {
- job->fastfirstpass = 1;
- }
- else
- {
- job->fastfirstpass = 0;
- }
-
- hb_add( h, job );
-
- job->pass = 2;
- /*
- * On the second pass we turn off subtitle scan so that we
- * can actually encode using any subtitles that were auto
- * selected in the first pass (using the whacky select-subtitle
- * attribute of the job).
- */
- job->indepth_scan = 0;
-
- hb_add( h, job );
- }
- else
- {
- /*
- * Turn on subtitle scan if requested, note that this option
- * precludes encoding of any actual subtitles.
- */
-
- job->indepth_scan = 0;
- job->pass = 0;
-
- hb_add( h, job );
- }
+ hb_add( h, job );
hb_job_close( &job );
hb_start( h );
break;