summaryrefslogtreecommitdiffstats
path: root/libhb/common.c
diff options
context:
space:
mode:
authorJohn Stebbins <[email protected]>2015-11-03 09:46:28 -0800
committerJohn Stebbins <[email protected]>2015-11-09 11:06:59 -0800
commita986f54a4109bb8c3b2fb57849b4b0ea01e3c522 (patch)
tree7add9d007dc8bdd72114637c8f3f7361621ad4a5 /libhb/common.c
parent63b340ebc33d57aeda22e340dab48b1df2106541 (diff)
libhb: make muxer, sync, and reader behave like other work objects
simplify job initialization sequence, clean up code, and document dependencies in the sequence better. Make hb_add set job->sequence_id. It is no longer necessary for the frontend to do this. If the frontend needs the sequence_id, it is returned by hb_add(). Clean up use of interjob. do_job() now uses sequence_id to detect when a new sequence of related jobs is running and automatically clears interjob.
Diffstat (limited to 'libhb/common.c')
-rw-r--r--libhb/common.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/libhb/common.c b/libhb/common.c
index 47f1b26f9..3e91635be 100644
--- a/libhb/common.c
+++ b/libhb/common.c
@@ -694,6 +694,26 @@ const hb_rate_t* hb_video_framerate_get_next(const hb_rate_t *last)
return ((hb_rate_internal_t*)last)->next;
}
+int hb_video_framerate_get_close(hb_rational_t *framerate, double thresh)
+{
+ double fps_in;
+ const hb_rate_t * rate = NULL;
+ int result = -1;
+ double closest = thresh;
+
+ fps_in = (double)framerate->num / framerate->den;
+ while ((rate = hb_video_framerate_get_next(rate)) != NULL)
+ {
+ double fps = (double)hb_video_rate_clock / rate->rate;
+ if (ABS(fps - fps_in) < closest)
+ {
+ result = rate->rate;
+ closest = ABS(fps - fps_in);
+ }
+ }
+ return result;
+}
+
int hb_audio_samplerate_get_best(uint32_t codec, int samplerate, int *sr_shift)
{
int best_samplerate;