- if (!job->indepth_scan || job->subtitle_force) {
- /*
- * Don't add threads for subtitles when we are scanning, unless
- * looking for forced subtitles.
- */
- if( sub_w != NULL )
- {
- /*
- * Need to copy the prior subtitle structure so that we
- * don't overwrite the fifos.
- */
- sub_w = calloc( sizeof( hb_work_object_t ), 1 );
- sub_w = memcpy( sub_w, w, sizeof( hb_work_object_t ));
- } else {
- w = sub_w = getWork( WORK_DECSUB );
- }
- hb_list_add( job->list_work, sub_w );
- sub_w->fifo_in = subtitle->fifo_in;
- sub_w->fifo_out = subtitle->fifo_raw;
+ if ( audio->config.out.dynamic_range_compression && (audio->config.out.codec != HB_ACODEC_AC3_PASS) && (audio->config.out.codec != HB_ACODEC_DCA_PASS))
+ {
+ hb_log(" + dynamic range compression: %f", audio->config.out.dynamic_range_compression);
+ }
+
+ if( (audio->config.out.codec == HB_ACODEC_AC3_PASS) || (audio->config.out.codec == HB_ACODEC_DCA_PASS) )
+ {
+ hb_log( " + %s passthrough", (audio->config.out.codec == HB_ACODEC_AC3_PASS) ?
+ "AC3" : "DCA" );
+ }
+ else
+ {
+ hb_log( " + encoder: %s",
+ ( audio->config.out.codec == HB_ACODEC_FAAC ) ? "faac" :
+ ( ( audio->config.out.codec == HB_ACODEC_LAME ) ? "lame" :
+ ( ( audio->config.out.codec == HB_ACODEC_CA_AAC ) ? "ca_aac" :
+ ( ( audio->config.out.codec == HB_ACODEC_AC3 ) ? "ffac3" :
+ "vorbis" ) ) ) );
+ hb_log( " + bitrate: %d kbps, samplerate: %d Hz", audio->config.out.bitrate, audio->config.out.samplerate );
+ }
+ }
+ }
+}
+
+/* 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_work_object_t * sync;
+ hb_work_object_t * muxer;
+ hb_interjob_t * interjob;
+
+ hb_audio_t * audio;
+ hb_subtitle_t * subtitle;
+ hb_attachment_t * attachment;
+ 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 )
+ {
+ correct_framerate( job );
+ }
+
+ job->list_work = hb_list_init();
+
+ hb_log( "starting job" );
+
+ if( job->anamorphic.mode )
+ {
+ hb_set_anamorphic_size(job, &job->width, &job->height, &job->anamorphic.par_width, &job->anamorphic.par_height);
+
+ if( job->vcodec == HB_VCODEC_FFMPEG )
+ {
+ /* Just to make working with ffmpeg even more fun,
+ lavc's MPEG-4 encoder can't handle PAR values >= 255,
+ even though AVRational does. Adjusting downwards
+ distorts the display aspect slightly, but such is life. */
+ while ((job->anamorphic.par_width & ~0xFF) ||
+ (job->anamorphic.par_height & ~0xFF))
+ {
+ job->anamorphic.par_width >>= 1;
+ job->anamorphic.par_height >>= 1;