summaryrefslogtreecommitdiffstats
path: root/libhb/work.c
diff options
context:
space:
mode:
authorjstebbins <jstebbins.hb@gmail.com>2011-03-08 16:12:57 +0000
committerjstebbins <jstebbins.hb@gmail.com>2011-03-08 16:12:57 +0000
commit673a841b1ef2dcd31647fce00829dc4a3f2b0715 (patch)
treeb11d12d19c798463a8756d8f5f989e6d2865765b /libhb/work.c
parent6444014c71cd881ad4874e96a6138ea268be8b4d (diff)
make keyint match between 1st and 2nd passes of vfr and pfr encodes.
make keyint and fps settings consistent across video encoders. make interjob->vrate changes for pfr mode like we do for vfr since pfr is the same as vfr except when it hits it's peak. in mkv, set track default duration to actual measured vrate on 2 pass encodes. thanks to Rodeo for the corrections in encx264 git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3831 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/work.c')
-rw-r--r--libhb/work.c45
1 files changed, 31 insertions, 14 deletions
diff --git a/libhb/work.c b/libhb/work.c
index d05a22aa7..a5f0e7418 100644
--- a/libhb/work.c
+++ b/libhb/work.c
@@ -200,20 +200,23 @@ void hb_display_job_info( hb_job_t * job )
hb_log( " + bitrate %d kbps", title->video_bitrate / 1000 );
}
- if( !job->cfr )
+ if( job->cfr == 0 )
{
hb_log( " + frame rate: same as source (around %.3f fps)",
(float) title->rate / (float) title->rate_base );
}
- else
+ else if( job->cfr == 1 )
{
- static const char *frtypes[] = {
- "", "constant", "peak rate limited to"
- };
- hb_log( " + frame rate: %.3f fps -> %s %.3f fps",
- (float) title->rate / (float) title->rate_base, frtypes[job->cfr],
+ hb_log( " + frame rate: %.3f fps -> constant %.3f fps",
+ (float) title->rate / (float) title->rate_base,
(float) job->vrate / (float) job->vrate_base );
}
+ else if( job->cfr == 2 )
+ {
+ hb_log( " + frame rate: %.3f fps -> peak rate limited to %.3f fps",
+ (float) title->rate / (float) title->rate_base,
+ (float) job->pfr_vrate / (float) job->pfr_vrate_base );
+ }
if( job->anamorphic.mode )
{
@@ -380,13 +383,11 @@ void correct_framerate( hb_job_t * job )
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;
-
+ // compute actual output vrate from first pass
real_frames = interjob->frame_count - interjob->render_dropped;
- job->vrate = job->vrate_base * ( (double)real_frames * 90000 / interjob->total_time );
+ interjob->vrate = job->vrate_base * ( (double)real_frames * 90000 / interjob->total_time );
+ interjob->vrate_base = job->vrate_base;
}
static int check_ff_audio( hb_list_t *list_audio, hb_audio_t *ff_audio )
@@ -442,7 +443,7 @@ static void do_job( hb_job_t * job )
title = job->title;
interjob = hb_interjob_get( job->h );
- if( job->pass == 2 && !job->cfr )
+ if( job->pass == 2 )
{
correct_framerate( job );
}
@@ -492,8 +493,25 @@ static void do_job( hb_job_t * job )
if ( job->cfr == 0 )
{
/* Ensure we're using "Same as source" FPS */
+ job->vrate = title->rate;
job->vrate_base = title->rate_base;
}
+ else if ( job->cfr == 2 )
+ {
+ job->pfr_vrate = job->vrate;
+ job->pfr_vrate_base = job->vrate_base;
+
+ // Ensure we're using "Same as source" FPS, with peak set by pfr_vrate_*
+ // For PFR, we want the framerate based on the source's actual
+ // framerate, unless it's higher than the specified peak framerate.
+ double source_fps = (double)job->title->rate / job->title->rate_base;
+ double peak_l_fps = (double)job->vrate / job->vrate_base;
+ if ( source_fps < peak_l_fps )
+ {
+ job->vrate_base = title->rate_base;
+ job->vrate = title->rate;
+ }
+ }
job->fifo_mpeg2 = hb_fifo_init( FIFO_LARGE, FIFO_LARGE_WAKE );
job->fifo_raw = hb_fifo_init( FIFO_SMALL, FIFO_SMALL_WAKE );
@@ -1221,7 +1239,6 @@ static void work_loop( void * _w )
}
break;
}
-
// Invalidate buf_out so that if there is no output
// we don't try to pass along junk.
buf_out = NULL;