An error in interjob->vrate calculation lead to specifying a different
timebase for the 1st and 2nd pass which x264 does not allow. This
improves the interjob->vrate calculation accuracy and also guarantees
the timebase is the same on both passes regardless of the calculations
accuracy.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3848
b64f7644-9d1e-0410-96f1-
a4d463321fa5
param.i_threads = ( hb_get_cpu_count() * 3 / 2 );
param.i_width = job->width;
param.i_height = job->height;
- if( job->pass == 2 )
+ if( job->pass == 2 && job->cfr != 1 )
{
hb_interjob_t * interjob = hb_interjob_get( job->h );
param.i_fps_num = interjob->vrate;
{
int last_job; /* job->sequence_id & 0xFFFFFF */
int frame_count; /* number of frames counted by sync */
+ int out_frame_count; /* number of frames counted by render */
uint64_t total_time; /* real length in 90khz (i.e. / 90000 */
- int render_dropped; /* frames droped by telecine */
int vrate; /* actual measured output vrate from 1st pass */
int vrate_base; /* actual measured output vrate_base from 1st pass */
int chapter_val;
int count_frames; // frames output so far
double frame_rate; // 90KHz ticks per frame (for CFR/PFR)
- double out_last_stop; // where last frame ended (for CFR/PFR)
+ uint64_t out_last_stop; // where last frame ended (for CFR/PFR)
int drops; // frames dropped (for CFR/PFR)
int dups; // frames duped (for CFR/PFR)
};
while ( out && out->size > 0 )
{
+ if ( pv->job->cfr == 0 )
+ {
+ ++pv->count_frames;
+ pv->out_last_stop = out->stop;
+ out = out->next;
+ continue;
+ }
+
// this frame has to start where the last one stopped.
out->start = pv->out_last_stop;
{
tail->next = in;
*buf_out = head;
- if ( job->cfr )
- {
- adjust_frame_rate( pv, buf_out );
- }
+ adjust_frame_rate( pv, buf_out );
} else {
*buf_out = in;
}
}
- if ( buf_out && *buf_out && job->cfr )
+ if ( buf_out && *buf_out )
{
adjust_frame_rate( pv, buf_out );
}
hb_interjob_t * interjob = hb_interjob_get( w->private_data->job->h );
/* Preserve dropped frame count for more accurate framerates in 2nd passes. */
- interjob->render_dropped = pv->dropped_frames;
+ interjob->out_frame_count = pv->count_frames;
+ interjob->total_time = pv->out_last_stop;
hb_log("render: lost time: %"PRId64" (%i frames)", pv->total_lost_time, pv->dropped_frames);
hb_log("render: gained time: %"PRId64" (%i frames) (%"PRId64" not accounted for)", pv->total_gained_time, pv->extended_frames, pv->total_lost_time - pv->total_gained_time);
hb_interjob_t * interjob = hb_interjob_get( job->h );
interjob->frame_count = pv->common->count_frames;
interjob->last_job = job->sequence_id;
- interjob->total_time = sync->next_start;
}
if (sync->drops || sync->dups )
pv->common->first_pts[0] = INT64_MAX - 1;
cur->start = sync->next_start;
cur->stop = cur->start + 90000. / ((double)job->vrate / (double)job->vrate_base);
+ sync->next_start += cur->stop - cur->start;;
/* Make sure last frame is reflected in frame count */
pv->common->count_frames++;
/* 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.
// compute actual output vrate from first pass
- real_frames = interjob->frame_count - interjob->render_dropped;
-
- interjob->vrate = job->vrate_base * ( (double)real_frames * 90000 / interjob->total_time );
+ interjob->vrate = job->vrate_base * ( (double)interjob->out_frame_count * 90000 / interjob->total_time );
interjob->vrate_base = job->vrate_base;
}