diff options
author | Rodeo <[email protected]> | 2013-05-22 20:16:20 +0000 |
---|---|---|
committer | Rodeo <[email protected]> | 2013-05-22 20:16:20 +0000 |
commit | a9a2621f49f1e29aceda4d33f57c24c21fdebcf1 (patch) | |
tree | a92de46e41cf69f63b1f064a801d2177fab380a3 | |
parent | b4439911971a0801b944ad87aee08ea7f3bb8616 (diff) |
libhb: fix hb_vfr_info() and refactor hb_vfr_init() a bit.
Since SVN revision 5058, hb_vfr_init didn't have access to title->rate, rate_base - which are needed to set the input framerate for CFR/PFR. It was therefore printing the output framerate in both cases, regardless of the input framerate:
[22:13:04] + frame rate: 23.976 fps -> constant 30.000 fps
[22:13:04] + filters
[22:13:04] + Framerate Shaper (1:27000000:900000)
[22:13:04] + frame rate: 30.000 fps -> constant 30.000 fps
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5499 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | libhb/common.h | 6 | ||||
-rw-r--r-- | libhb/vfr.c | 61 | ||||
-rw-r--r-- | libhb/work.c | 10 |
3 files changed, 29 insertions, 48 deletions
diff --git a/libhb/common.h b/libhb/common.h index 8e7afb326..443127e9e 100644 --- a/libhb/common.h +++ b/libhb/common.h @@ -362,8 +362,6 @@ struct hb_job_s int vcodec; float vquality; int vbitrate; - int pfr_vrate; - int pfr_vrate_base; int vrate; int vrate_base; int cfr; @@ -971,8 +969,8 @@ typedef struct hb_filter_init_s int crop[4]; int vrate_base; int vrate; - int pfr_vrate_base; - int pfr_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 844beef80..c2156f72d 100644 --- a/libhb/vfr.c +++ b/libhb/vfr.c @@ -301,20 +301,21 @@ static void adjust_frame_rate( hb_filter_private_t *pv, hb_buffer_t **buf_out ) } } -static int hb_vfr_init( hb_filter_object_t * filter, - hb_filter_init_t * init ) +static int hb_vfr_init(hb_filter_object_t *filter, hb_filter_init_t *init) { - filter->private_data = calloc( 1, sizeof(struct hb_filter_private_s) ); - hb_filter_private_t * pv = filter->private_data; - - build_gamma_lut( pv ); - pv->cfr = init->cfr; - pv->input_vrate = pv->vrate = init->vrate; - pv->input_vrate_base = pv->vrate_base = init->vrate_base; - if( filter->settings ) + filter->private_data = calloc(1, sizeof(struct hb_filter_private_s)); + hb_filter_private_t *pv = filter->private_data; + 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; + if (filter->settings != NULL) { - sscanf( filter->settings, "%d:%d:%d", - &pv->cfr, &pv->vrate, &pv->vrate_base ); + sscanf(filter->settings, "%d:%d:%d", + &pv->cfr, &pv->vrate, &pv->vrate_base); } pv->job = init->job; @@ -336,36 +337,18 @@ static int hb_vfr_init( hb_filter_object_t * filter, 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 == 0 ) + if (!pv->cfr) { /* Ensure we're using "Same as source" FPS */ - pv->vrate_base = init->vrate_base; - pv->vrate = init->vrate; - } - else 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)init->vrate / init->vrate_base; - double peak_fps = (double)pv->vrate / pv->vrate_base; - if ( source_fps > peak_fps ) - { - // peak framerate is lower than source framerate. so signal - // that the nominal framerate will be changed. - init->vrate = pv->vrate; - init->vrate_base = pv->vrate_base; - } - init->pfr_vrate = pv->vrate; - init->pfr_vrate_base = pv->vrate_base; - } - else - { - // Constant framerate. Signal the framerate we are using. - init->vrate = pv->vrate; - init->vrate_base = pv->vrate_base; + pv->vrate_base = pv->input_vrate_base; + pv->vrate = pv->input_vrate; } - init->cfr = pv->cfr; - pv->frame_rate = (double)pv->vrate_base * 90000. / pv->vrate; + 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; } diff --git a/libhb/work.c b/libhb/work.c index 45d341e7d..dfaa5d760 100644 --- a/libhb/work.c +++ b/libhb/work.c @@ -258,7 +258,7 @@ void hb_display_job_info( hb_job_t * job ) { 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 ); + (float) job->vrate / (float) job->vrate_base ); } // Filters can modify dimensions. So show them first. @@ -698,8 +698,8 @@ static void do_job( hb_job_t * job ) memcpy(init.crop, job->crop, sizeof(int[4])); init.vrate_base = job->vrate_base; init.vrate = job->vrate; - init.pfr_vrate_base = job->pfr_vrate_base; - init.pfr_vrate = job->pfr_vrate; + init.title_rate_base = title->rate_base; + init.title_rate = title->rate; init.cfr = 0; for( i = 0; i < hb_list_count( job->list_filter ); ) { @@ -721,8 +721,8 @@ 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; - job->pfr_vrate_base = init.pfr_vrate_base; - job->pfr_vrate = init.pfr_vrate; + title->rate_base = init.title_rate_base; + title->rate = init.title_rate; job->cfr = init.cfr; } |