diff options
author | jstebbins <[email protected]> | 2008-09-30 17:28:04 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2008-09-30 17:28:04 +0000 |
commit | a1cbb75e9084928b3ebd305c880238e6fd3e0c50 (patch) | |
tree | 3b8e39d4cfb9b31769a627a8fb8cbed803f6ce8e /libhb | |
parent | 868b9d0db5b5607fa8e5d4cdc1ad862eef275054 (diff) |
ffmpeg requires framerate num/den to be reducable to 16 bit quanitites for
mpeg-4. So round odd framerates to "close" standard framerate (which are
reducable). If there is no "close" framerate, the the rate is truncated
down to 16 bits.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1795 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r-- | libhb/encavcodec.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/libhb/encavcodec.c b/libhb/encavcodec.c index f3837b3e7..d102548b0 100644 --- a/libhb/encavcodec.c +++ b/libhb/encavcodec.c @@ -32,6 +32,7 @@ int encavcodecInit( hb_work_object_t * w, hb_job_t * job ) { AVCodec * codec; AVCodecContext * context; + int rate_num, rate_den; hb_work_private_t * pv = calloc( 1, sizeof( hb_work_private_t ) ); w->private_data = pv; @@ -71,13 +72,38 @@ int encavcodecInit( hb_work_object_t * w, hb_job_t * job ) { context->global_quality = FF_QP2LAMBDA * job->vquality + 0.5; } - context->mb_decision = 1; + context->mb_decision = 1; hb_log( "encavcodec: encoding at constant quantizer %d", context->global_quality ); } context->width = job->width; context->height = job->height; - context->time_base = (AVRational) { job->vrate_base, job->vrate }; + rate_num = job->vrate_base; + rate_den = job->vrate; + if (rate_den == 27000000) + { + int ii; + for (ii = 0; ii < hb_video_rates_count; ii++) + { + if (abs(rate_num - hb_video_rates[ii].rate) < 10) + { + rate_num = hb_video_rates[ii].rate; + break; + } + } + } + hb_reduce(&rate_num, &rate_den, rate_num, rate_den); + if ((rate_num & ~0xFFFF) || (rate_den & ~0xFFFF)) + { + hb_log( "encavcodec: truncating framerate %d / %d", + rate_num, rate_den ); + } + while ((rate_num & ~0xFFFF) || (rate_den & ~0xFFFF)) + { + rate_num >>= 1; + rate_den >>= 1; + } + context->time_base = (AVRational) { rate_num, rate_den }; context->gop_size = 10 * job->vrate / job->vrate_base; context->pix_fmt = PIX_FMT_YUV420P; |