+/* Corrects framerates when actual duration and frame count numbers are known. */
+void correct_framerate( hb_job_t * job )
+{
+ int real_frames;
+
+ hb_interjob_t * interjob = hb_interjob_get( job->h );
+
+ if( ( job->sequence_id & 0xFFFFFF ) != ( interjob->last_job & 0xFFFFFF) )
+ return; // Interjob information is for a different encode.
+
+ /* Cache the original framerate before altering it. */
+ interjob->vrate = job->vrate;
+ interjob->vrate_base = job->vrate_base;
+
+ real_frames = interjob->frame_count - interjob->render_dropped;
+
+ job->vrate = job->vrate_base * ( (double)real_frames * 90000 / interjob->total_time );
+}
+
+
+/**
+ * Job initialization rountine.
+ * Initializes fifos.
+ * Creates work objects for synchronizer, video decoder, video renderer, video decoder, audio decoder, audio encoder, reader, muxer.
+ * Launches thread for each work object with work_loop.
+ * Loops while monitoring status of work threads and fifos.
+ * Exits loop when conversion is done and fifos are empty.
+ * Closes threads and frees fifos.
+ * @param job Handle work hb_job_t.
+ * @param cpu_count number of CPUs found in system.
+ */
+static void do_job( hb_job_t * job, int cpu_count )
+{
+ hb_title_t * title;
+ int i, j;
+ hb_work_object_t * w;
+ hb_interjob_t * interjob;
+
+ hb_audio_t * audio;
+ hb_subtitle_t * subtitle;
+ unsigned int subtitle_highest = 0;
+ unsigned int subtitle_highest_id = 0;
+ unsigned int subtitle_lowest = -1;
+ unsigned int subtitle_lowest_id = 0;
+ unsigned int subtitle_forced_id = 0;
+ unsigned int subtitle_hit = 0;
+
+ title = job->title;
+ interjob = hb_interjob_get( job->h );
+
+ if( job->pass == 2 && !job->cfr )