diff options
Diffstat (limited to 'libhb')
-rw-r--r-- | libhb/common.h | 2 | ||||
-rw-r--r-- | libhb/vfr.c | 54 | ||||
-rw-r--r-- | libhb/work.c | 32 |
3 files changed, 45 insertions, 43 deletions
diff --git a/libhb/common.h b/libhb/common.h index 443127e9e..2951def5d 100644 --- a/libhb/common.h +++ b/libhb/common.h @@ -969,8 +969,6 @@ typedef struct hb_filter_init_s int crop[4]; int vrate_base; int vrate; - int title_rate_base; - int title_rate; int cfr; } hb_filter_init_t; diff --git a/libhb/vfr.c b/libhb/vfr.c index c2156f72d..009f88c43 100644 --- a/libhb/vfr.c +++ b/libhb/vfr.c @@ -308,10 +308,8 @@ static int hb_vfr_init(hb_filter_object_t *filter, hb_filter_init_t *init) build_gamma_lut(pv); pv->cfr = init->cfr; - pv->vrate = init->vrate; - pv->vrate_base = init->vrate_base; - pv->input_vrate = init->title_rate; - pv->input_vrate_base = init->title_rate_base; + pv->input_vrate = pv->vrate = init->vrate; + pv->input_vrate_base = pv->vrate_base = init->vrate_base; if (filter->settings != NULL) { sscanf(filter->settings, "%d:%d:%d", @@ -337,18 +335,27 @@ static int hb_vfr_init(hb_filter_object_t *filter, hb_filter_init_t *init) pv->lost_time[0] = 0; pv->lost_time[1] = 0; pv->lost_time[2] = 0; pv->lost_time[3] = 0; pv->frame_metric = 1000; // Force first frame - if (!pv->cfr) + if (pv->cfr == 2) { - /* Ensure we're using "Same as source" FPS */ - pv->vrate_base = pv->input_vrate_base; - pv->vrate = pv->input_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)init->vrate / init->vrate_base; + double peak_fps = (double)pv->vrate / pv->vrate_base; + if (source_fps > peak_fps) + { + // peak framerate is lower than the source framerate. + // so signal that the framerate will be the peak fps. + init->vrate = pv->vrate; + init->vrate_base = pv->vrate_base; + } + } + else + { + init->vrate = pv->vrate; + init->vrate_base = pv->vrate_base; } pv->frame_rate = (double)pv->vrate_base * 90000. / pv->vrate; init->cfr = pv->cfr; - init->vrate = pv->vrate; - init->vrate_base = pv->vrate_base; - init->title_rate = pv->input_vrate; - init->title_rate_base = pv->input_vrate_base; return 0; } @@ -362,8 +369,27 @@ static int hb_vfr_info( hb_filter_object_t * filter, return 1; memset( info, 0, sizeof( hb_filter_info_t ) ); - info->out.vrate_base = pv->vrate_base; - info->out.vrate = pv->vrate; + info->out.vrate_base = pv->input_vrate_base; + info->out.vrate = pv->input_vrate; + if (pv->cfr == 2) + { + // 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)pv->input_vrate / pv->input_vrate_base; + double peak_fps = (double)pv->vrate / pv->vrate_base; + if (source_fps > peak_fps) + { + // peak framerate is lower than the source framerate. + // so signal that the framerate will be the peak fps. + info->out.vrate = pv->vrate; + info->out.vrate_base = pv->vrate_base; + } + } + else + { + info->out.vrate = pv->vrate; + info->out.vrate_base = pv->vrate_base; + } info->out.cfr = pv->cfr; if ( pv->cfr == 0 ) { diff --git a/libhb/work.c b/libhb/work.c index dfaa5d760..72d758eed 100644 --- a/libhb/work.c +++ b/libhb/work.c @@ -243,24 +243,6 @@ void hb_display_job_info( hb_job_t * job ) hb_log( " + bitrate %d kbps", title->video_bitrate / 1000 ); } - if( job->cfr == 0 ) - { - hb_log( " + frame rate: same as source (around %.3f fps)", - (float) title->rate / (float) title->rate_base ); - } - else if( job->cfr == 1 ) - { - 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->vrate / (float) job->vrate_base ); - } - // Filters can modify dimensions. So show them first. if( hb_list_count( job->list_filter ) ) { @@ -691,15 +673,13 @@ static void do_job( hb_job_t * job ) init.job = job; init.pix_fmt = AV_PIX_FMT_YUV420P; - init.width = title->width; - init.height = title->height; + init.width = title->width - (title->crop[2] + title->crop[3]); + init.height = title->height - (title->crop[0] + title->crop[1]); init.par_width = job->anamorphic.par_width; init.par_height = job->anamorphic.par_height; - memcpy(init.crop, job->crop, sizeof(int[4])); - init.vrate_base = job->vrate_base; - init.vrate = job->vrate; - init.title_rate_base = title->rate_base; - init.title_rate = title->rate; + memcpy(init.crop, title->crop, sizeof(int[4])); + init.vrate_base = title->rate_base; + init.vrate = title->rate; init.cfr = 0; for( i = 0; i < hb_list_count( job->list_filter ); ) { @@ -721,8 +701,6 @@ static void do_job( hb_job_t * job ) memcpy(job->crop, init.crop, sizeof(int[4])); job->vrate_base = init.vrate_base; job->vrate = init.vrate; - title->rate_base = init.title_rate_base; - title->rate = init.title_rate; job->cfr = init.cfr; } |