summaryrefslogtreecommitdiffstats
path: root/libhb/encx264.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/encx264.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/encx264.c')
-rw-r--r--libhb/encx264.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/libhb/encx264.c b/libhb/encx264.c
index d00479468..880ca23ed 100644
--- a/libhb/encx264.c
+++ b/libhb/encx264.c
@@ -98,15 +98,28 @@ int encx264Init( hb_work_object_t * w, hb_job_t * job )
*/
if (job->vrate_base != 1080000)
{
- int fps = job->vrate / job->vrate_base;
-
- /* adjust +1 when fps has remainder to bump { 23.976, 29.976, 59.94 } to { 24, 30, 60 } */
- if (job->vrate % job->vrate_base)
- fps += 1;
+ if (job->pass == 2 && !job->cfr )
+ {
+ /* Even though the framerate might be different due to VFR,
+ we still want the same keyframe intervals as the 1st pass,
+ so the 1st pass stats won't conflict on frame decisions. */
+ hb_interjob_t * interjob = hb_interjob_get( job->h );
+ param.i_keyint_min = ( interjob->vrate / interjob->vrate_base ) + 1;
+ param.i_keyint_max = ( 10 * interjob->vrate / interjob->vrate_base ) + 1;
+ }
+ else
+ {
+ int fps = job->vrate / job->vrate_base;
- param.i_keyint_min = fps;
- param.i_keyint_max = fps * 10;
+ /* adjust +1 when fps has remainder to bump
+ { 23.976, 29.976, 59.94 } to { 24, 30, 60 } */
+ if (job->vrate % job->vrate_base)
+ fps += 1;
+ param.i_keyint_min = fps;
+ param.i_keyint_max = fps * 10;
+ }
+
hb_log("encx264: keyint-min: %i, keyint-max: %i", param.i_keyint_min, param.i_keyint_max);
}