diff options
author | Rodeo <[email protected]> | 2012-11-05 14:17:38 +0000 |
---|---|---|
committer | Rodeo <[email protected]> | 2012-11-05 14:17:38 +0000 |
commit | 20c5dd3faa9a524efa9772faf1300523f3ae675a (patch) | |
tree | 469ecf8304b017c021e2fa8d29deb2c867a93726 | |
parent | 48e2482dc710dc2b53f1bce12c5cbda761915fb2 (diff) |
Add a utility function to check whether an H.264 level can be used given the current encoding parameters.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5044 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | libhb/encx264.c | 15 | ||||
-rw-r--r-- | libhb/encx264.h | 15 |
2 files changed, 30 insertions, 0 deletions
diff --git a/libhb/encx264.c b/libhb/encx264.c index 49e99973a..2da886a68 100644 --- a/libhb/encx264.c +++ b/libhb/encx264.c @@ -627,6 +627,21 @@ int encx264Work( hb_work_object_t * w, hb_buffer_t ** buf_in, return HB_WORK_OK; } +int hb_check_h264_level(const char *h264_level, int width, int height, + int fps_num, int fps_den, int interlaced, + int fake_interlaced) +{ + x264_param_t param; + x264_param_default(¶m); + param.i_width = width; + param.i_height = height; + param.i_fps_num = fps_num; + param.i_fps_den = fps_den; + param.b_interlaced = !!interlaced; + param.b_fake_interlaced = !!fake_interlaced; + return (hb_apply_h264_level(¶m, h264_level, NULL, 1) != 0); +} + int hb_apply_h264_level(x264_param_t *param, const char *h264_level, const char *x264_profile, int be_quiet) { diff --git a/libhb/encx264.h b/libhb/encx264.h index 56b0163e9..a9c9dac97 100644 --- a/libhb/encx264.h +++ b/libhb/encx264.h @@ -41,6 +41,21 @@ static const char * const hb_x264_encopt_synonyms[][2] = }; /* + * Check whether a valid h264_level is compatible with the given framerate, + * resolution and interlaced compression/flags combination. + * + * width, height, fps_num and fps_den should be greater than zero. + * + * interlacing parameters can be set to zero when the information is + * unavailable, as hb_apply_h264_level() will disable interlacing if necessary. + * + * Returns 0 if the level is valid and compatible, 1 otherwise. + */ +int hb_check_h264_level(const char *h264_level, int width, int height, + int fps_num, int fps_den, int interlaced, + int fake_interlaced); + +/* * Applies the restrictions of the requested H.264 level to an x264_param_t. * * Returns -1 if an invalid level (or no level) is specified. GUIs should be |