diff options
author | jstebbins <[email protected]> | 2014-12-16 16:50:50 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2014-12-16 16:50:50 +0000 |
commit | f56efd7b52c89da8cac55b4d4a187f2c87fdfee6 (patch) | |
tree | 24eacb856704fa8e4b8b8f0edc76568916f70255 /libhb/vfr.c | |
parent | d0a975e42dcab93e1d2eead350fb1ba3951d977c (diff) |
json: add json APIs
There are several changes to job and title structs that break
current windows interop code. The interop code should be changed
such that it only uses json APIs. So if there is any missing
features (or bugs) in these APIs, please let me know.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6602 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/vfr.c')
-rw-r--r-- | libhb/vfr.c | 40 |
1 files changed, 16 insertions, 24 deletions
diff --git a/libhb/vfr.c b/libhb/vfr.c index 592310548..f45fd57e9 100644 --- a/libhb/vfr.c +++ b/libhb/vfr.c @@ -13,10 +13,8 @@ struct hb_filter_private_s { hb_job_t * job; int cfr; - int input_vrate; - int input_vrate_base; - int vrate; - int vrate_base; + hb_rational_t input_vrate; + hb_rational_t vrate; hb_fifo_t * delay_queue; int dropped_frames; int extended_frames; @@ -142,12 +140,12 @@ static float motion_metric( hb_filter_private_t * pv, hb_buffer_t * a, hb_buffer // 0 - Variable Frame Rate (VFR) or 'same as source': frame times // are left alone // 1 - Constant Frame Rate (CFR): Frame timings are adjusted so that all -// frames are exactly vrate_base ticks apart. Frames are dropped +// frames are exactly vrate.den ticks apart. Frames are dropped // or duplicated if necessary to maintain this spacing. -// 2 - Peak Frame Rate (PFR): vrate_base is treated as the peak +// 2 - Peak Frame Rate (PFR): vrate.den is treated as the peak // average frame rate. I.e., the average frame rate (current frame // end time divided by number of frames so far) is never allowed to be -// greater than vrate_base and frames are dropped if necessary +// greater than vrate.den and frames are dropped if necessary // to keep the average under this value. Other than those drops, frame // times are left alone. // @@ -309,11 +307,10 @@ static int hb_vfr_init(hb_filter_object_t *filter, hb_filter_init_t *init) pv->cfr = init->cfr; 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", - &pv->cfr, &pv->vrate, &pv->vrate_base); + &pv->cfr, &pv->vrate.num, &pv->vrate.den); } pv->job = init->job; @@ -339,22 +336,20 @@ static int hb_vfr_init(hb_filter_object_t *filter, hb_filter_init_t *init) { // 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; + double source_fps = (double)init->vrate.num / init->vrate.den; + double peak_fps = (double)pv->vrate.num / pv->vrate.den; 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; + pv->frame_rate = (double)pv->vrate.den * 90000. / pv->vrate.num; init->cfr = pv->cfr; return 0; @@ -369,26 +364,23 @@ 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->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; + double source_fps = (double)pv->input_vrate.num / pv->input_vrate.den; + double peak_fps = (double)pv->vrate.num / pv->vrate.den; 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 ) @@ -396,14 +388,14 @@ static int hb_vfr_info( hb_filter_object_t * filter, /* Ensure we're using "Same as source" FPS */ sprintf( info->human_readable_desc, "frame rate: same as source (around %.3f fps)", - (float)pv->vrate / pv->vrate_base ); + (float)pv->vrate.num / pv->vrate.den ); } 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)pv->input_vrate / pv->input_vrate_base; - double peak_fps = (double)pv->vrate / pv->vrate_base; + double source_fps = (double)pv->input_vrate.num / pv->input_vrate.den; + double peak_fps = (double)pv->vrate.num / pv->vrate.den; sprintf( info->human_readable_desc, "frame rate: %.3f fps -> peak rate limited to %.3f fps", source_fps , peak_fps ); @@ -411,8 +403,8 @@ static int hb_vfr_info( hb_filter_object_t * filter, else { // Constant framerate. Signal the framerate we are using. - double source_fps = (double)pv->input_vrate / pv->input_vrate_base; - double constant_fps = (double)pv->vrate / pv->vrate_base; + double source_fps = (double)pv->input_vrate.num / pv->input_vrate.den; + double constant_fps = (double)pv->vrate.num / pv->vrate.den; sprintf( info->human_readable_desc, "frame rate: %.3f fps -> constant %.3f fps", source_fps , constant_fps ); |