summaryrefslogtreecommitdiffstats
path: root/libhb/work.c
diff options
context:
space:
mode:
authorjbrjake <[email protected]>2009-06-04 17:52:01 +0000
committerjbrjake <[email protected]>2009-06-04 17:52:01 +0000
commita9eb0fba5299b12a951f2116276ef3382c1ff50a (patch)
treea4ee5ec78bca4077b8de2c522ee600824ff1696e /libhb/work.c
parent2c5699a0b597b55a6c6f7cc663e473dd4a7345e1 (diff)
Adds an interjob structure to preserve some encode data across jobs within an instance of libhb. This allows correcting the estimated bitrate/filesize of 2-pass encodes of variable framerate content, as the actual frame count is known after the first pass. Thanks for putting the idea into code, Shaya.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2482 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/work.c')
-rw-r--r--libhb/work.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/libhb/work.c b/libhb/work.c
index 5be4bdf9f..92f04f483 100644
--- a/libhb/work.c
+++ b/libhb/work.c
@@ -335,6 +335,25 @@ void hb_display_job_info( hb_job_t * job )
}
}
+/* 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 ) )
+ 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 * ( real_frames / ( interjob->total_time / 90000 ) );
+}
+
+
/**
* Job initialization rountine.
* Initializes fifos.
@@ -363,6 +382,11 @@ static void do_job( hb_job_t * job, int cpu_count )
title = job->title;
+ if( job->pass == 2 && !job->cfr )
+ {
+ correct_framerate( job );
+ }
+
job->list_work = hb_list_init();
hb_log( "starting job" );