diff options
author | Rodeo <[email protected]> | 2012-09-11 11:58:47 +0000 |
---|---|---|
committer | Rodeo <[email protected]> | 2012-09-11 11:58:47 +0000 |
commit | cc4f4495b5b5f740bba085679c0d0d4ce354f64f (patch) | |
tree | d531ab10a81a8dc1baf77a76403b2ee0db11a281 /libhb/encx264.c | |
parent | d6ef48e29dc4de84bfb2c79122244257d528c933 (diff) |
hb_apply_h264_level: return 1 in case of warnings and make return values > 0 non-fatal.
This could be used by a GUI to remove incompatible levels from a drop-down, for example.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4955 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/encx264.c')
-rw-r--r-- | libhb/encx264.c | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/libhb/encx264.c b/libhb/encx264.c index 2faaf6e5d..3e9e3cbf2 100644 --- a/libhb/encx264.c +++ b/libhb/encx264.c @@ -285,7 +285,7 @@ int encx264Init( hb_work_object_t * w, hb_job_t * job ) if (job->h264_level != NULL) { if (hb_apply_h264_level(¶m, job->width, job->height, - job->h264_level, job->x264_profile, 0)) + job->h264_level, job->x264_profile, 0) < 0) { free(pv); pv = NULL; @@ -643,7 +643,7 @@ int hb_apply_h264_level(x264_param_t *param, { float f_framerate; const x264_level_t *x264_level = NULL; - int i, i_mb_size, i_mb_rate, i_mb_width, i_mb_height, max_mb_side; + int i, i_mb_size, i_mb_rate, i_mb_width, i_mb_height, max_mb_side, ret; enum { // the H.264 profile determines VBV constraints @@ -741,6 +741,9 @@ int hb_apply_h264_level(x264_param_t *param, return -1; } + /* a return value of 1 means there were warnings */ + ret = 0; + /* some levels do not support interlaced encoding */ if (x264_level->frame_only && (param->b_interlaced || param->b_fake_interlaced)) @@ -750,6 +753,7 @@ int hb_apply_h264_level(x264_param_t *param, hb_log("hb_apply_h264_level [warning]: interlaced flag not supported for level %s, disabling", h264_level); } + ret = 1; param->b_interlaced = param->b_fake_interlaced = 0; } @@ -827,38 +831,51 @@ int hb_apply_h264_level(x264_param_t *param, /* TODO: check the rest of the limits */ /* things we can do nothing about (too late to change resolution or fps), print warnings */ - if (!be_quiet) + if (x264_level->frame_size < i_mb_size) { - if (x264_level->frame_size < i_mb_size) + if (!be_quiet) { hb_log("hb_apply_h264_level [warning]: frame size (%dx%d, %d macroblocks) too high for level %s (max. %d macroblocks)", i_mb_width * 16, i_mb_height * 16, i_mb_size, h264_level, x264_level->frame_size); } - else if (x264_level->mbps < i_mb_rate) + ret = 1; + } + else if (x264_level->mbps < i_mb_rate) + { + if (!be_quiet) { hb_log("hb_apply_h264_level [warning]: framerate (%.3f) too high for level %s at %dx%d (max. %.3f)", f_framerate, h264_level, width, height, (float)x264_level->mbps / i_mb_size); } - // width or height squared may not exceed 8 * frame_size (in macroblocks) - // thus neither dimension may exceed sqrt(8 * frame_size) - max_mb_side = sqrt(x264_level->frame_size * 8); - if (i_mb_width > max_mb_side) + ret = 1; + } + // width or height squared may not exceed 8 * frame_size (in macroblocks) + // thus neither dimension may exceed sqrt(8 * frame_size) + max_mb_side = sqrt(x264_level->frame_size * 8); + if (i_mb_width > max_mb_side) + { + if (!be_quiet) { hb_log("hb_apply_h264_level [warning]: frame too wide (%d) for level %s (max. %d)", width, h264_level, max_mb_side * 16); } - if (i_mb_height > max_mb_side) + ret = 1; + } + if (i_mb_height > max_mb_side) + { + if (!be_quiet) { hb_log("hb_apply_h264_level [warning]: frame too tall (%d) for level %s (max. %d)", height, h264_level, max_mb_side * 16); } + ret = 1; } /* level successfully applied, yay! */ param->i_level_idc = x264_level->level_idc; - return 0; + return ret; } const char * const * hb_x264_presets() |