summaryrefslogtreecommitdiffstats
path: root/libhb/hb.c
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2015-03-07 22:25:48 +0000
committerjstebbins <[email protected]>2015-03-07 22:25:48 +0000
commit7705413a03a90c16734b40fb7bc492be8b56ab6f (patch)
tree2b3c861e0a7b78e45869a191b20f7dc57c0fe48b /libhb/hb.c
parenta4ad5062c3fa1787b208389123bb81ea57483142 (diff)
json: automatically scan title when processing json jobs
Simplifies the WinGui. This also changes how jobs are processed. Creating the sub-jobs for multiple passes is delayed until after scanning and immediately before running the job. Working status has also changed. Sub-job passes are identified in status with an ID that allows the frontend to definitively identify what pass is in progress. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6976 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/hb.c')
-rw-r--r--libhb/hb.c108
1 files changed, 57 insertions, 51 deletions
diff --git a/libhb/hb.c b/libhb/hb.c
index 9514de3ee..84347d768 100644
--- a/libhb/hb.c
+++ b/libhb/hb.c
@@ -48,8 +48,6 @@ struct hb_handle_s
from this one (see work.c) */
hb_list_t * jobs;
hb_job_t * current_job;
- int job_count;
- int job_count_permanent;
volatile int work_die;
hb_error_code work_error;
hb_thread_t * work_thread;
@@ -1255,7 +1253,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.
*/
-static void hb_add_internal( hb_handle_t * h, hb_job_t * job )
+static void hb_add_internal( hb_handle_t * h, hb_job_t * job, hb_list_t *list_pass )
{
hb_job_t * job_copy;
hb_audio_t * audio;
@@ -1336,21 +1334,64 @@ static void hb_add_internal( hb_handle_t * h, hb_job_t * job )
job_copy->file = strdup(job->file);
job_copy->h = h;
- job_copy->pause = h->pause_lock;
/* Copy the job filter list */
job_copy->list_filter = hb_filter_list_copy( job->list_filter );
/* Add the job to the list */
- hb_list_add( h->jobs, job_copy );
- h->job_count = hb_count(h);
- h->job_count_permanent++;
+ hb_list_add( list_pass, job_copy );
+}
+
+hb_job_t* hb_job_copy(hb_job_t * job)
+{
+ hb_job_t * job_copy;
+
+ /* Copy the job */
+ job_copy = calloc( sizeof( hb_job_t ), 1 );
+ if (job_copy == NULL)
+ return NULL;
+
+ if (job->json != NULL)
+ {
+ // JSON jobs should only have the json string set.
+ job_copy->json = strdup(job->json);
+ return job_copy;
+ }
+ memcpy( job_copy, job, sizeof( hb_job_t ) );
+
+ job_copy->list_subtitle = hb_subtitle_list_copy( job->list_subtitle );
+ job_copy->list_chapter = hb_chapter_list_copy( job->list_chapter );
+ job_copy->list_audio = hb_audio_list_copy( job->list_audio );
+ job_copy->list_attachment = hb_attachment_list_copy( job->list_attachment );
+ job_copy->metadata = hb_metadata_copy( job->metadata );
+
+ if (job->encoder_preset != NULL)
+ job_copy->encoder_preset = strdup(job->encoder_preset);
+ if (job->encoder_tune != NULL)
+ job_copy->encoder_tune = strdup(job->encoder_tune);
+ if (job->encoder_options != NULL)
+ job_copy->encoder_options = strdup(job->encoder_options);
+ if (job->encoder_profile != NULL)
+ job_copy->encoder_profile = strdup(job->encoder_profile);
+ if (job->encoder_level != NULL)
+ job_copy->encoder_level = strdup(job->encoder_level);
+ if (job->file != NULL)
+ job_copy->file = strdup(job->file);
+
+ job_copy->list_filter = hb_filter_list_copy( job->list_filter );
+
+ return job_copy;
}
void hb_add( hb_handle_t * h, hb_job_t * job )
{
- int sub_id = 0;
+ hb_job_t *job_copy = hb_job_copy(job);
+ job_copy->h = h;
+ hb_list_add(h->jobs, job_copy);
+}
+void hb_job_setup_passes(hb_handle_t * h, hb_job_t * job, hb_list_t * list_pass)
+{
if (job->vquality >= 0)
{
job->twopass = 0;
@@ -1358,26 +1399,22 @@ void hb_add( hb_handle_t * h, hb_job_t * job )
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->pass_id = HB_PASS_SUBTITLE;
+ hb_add_internal(h, job, list_pass);
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);
+ job->pass_id = HB_PASS_ENCODE_1ST;
+ hb_add_internal(h, job, list_pass);
+ job->pass_id = HB_PASS_ENCODE_2ND;
+ hb_add_internal(h, job, list_pass);
}
else
{
- job->pass = 0;
- job->sequence_id = (job->sequence_id & 0xFFFFFF) | (sub_id++ << 24);
- hb_add_internal(h, job);
+ job->pass_id = HB_PASS_ENCODE;
+ hb_add_internal(h, job, list_pass);
}
}
@@ -1389,12 +1426,6 @@ void hb_add( hb_handle_t * h, hb_job_t * job )
void hb_rem( hb_handle_t * h, hb_job_t * job )
{
hb_list_rem( h->jobs, job );
-
- h->job_count = hb_count(h);
- if (h->job_count_permanent)
- h->job_count_permanent--;
-
- /* XXX free everything XXX */
}
/**
@@ -1405,16 +1436,10 @@ void hb_rem( hb_handle_t * h, hb_job_t * job )
*/
void hb_start( hb_handle_t * h )
{
- /* XXX Hack */
- h->job_count = hb_list_count( h->jobs );
- h->job_count_permanent = h->job_count;
-
hb_lock( h->state_lock );
h->state.state = HB_STATE_WORKING;
#define p h->state.param.working
p.progress = 0.0;
- p.job_cur = 1;
- p.job_count = h->job_count;
p.rate_cur = 0.0;
p.rate_avg = 0.0;
p.hours = -1;
@@ -1477,10 +1502,6 @@ void hb_resume( hb_handle_t * h )
void hb_stop( hb_handle_t * h )
{
h->work_die = 1;
-
- h->job_count = hb_count(h);
- h->job_count_permanent = 0;
-
hb_resume( h );
}
@@ -1491,10 +1512,6 @@ void hb_stop( hb_handle_t * h )
void hb_scan_stop( hb_handle_t * h )
{
h->scan_die = 1;
-
- h->job_count = hb_count(h);
- h->job_count_permanent = 0;
-
hb_resume( h );
}
@@ -1735,9 +1752,6 @@ static void thread_func( void * _h )
h->state.state = HB_STATE_WORKDONE;
h->state.param.workdone.error = h->work_error;
- h->job_count = hb_count(h);
- if (h->job_count < 1)
- h->job_count_permanent = 0;
hb_unlock( h->state_lock );
}
@@ -1813,14 +1827,6 @@ void hb_set_state( hb_handle_t * h, hb_state_t * s )
if( h->state.state == HB_STATE_WORKING ||
h->state.state == HB_STATE_SEARCHING )
{
- /* XXX Hack */
- if (h->job_count < 1)
- h->job_count_permanent = 1;
-
- h->state.param.working.job_cur =
- h->job_count_permanent - hb_list_count( h->jobs );
- h->state.param.working.job_count = h->job_count_permanent;
-
// Set which job is being worked on
if (h->current_job)
h->state.param.working.sequence_id = h->current_job->sequence_id & 0xFFFFFF;