summaryrefslogtreecommitdiffstats
path: root/libhb
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2011-09-19 23:19:30 +0000
committerjstebbins <[email protected]>2011-09-19 23:19:30 +0000
commit0ddbb44151ad80ff7eaa1ccd9efa201b2a014c71 (patch)
treee023f19c644981f7a814c99f2996d424e7ada74b /libhb
parentd522dcb3ab53099ad4e6d7546037a588de3adad3 (diff)
Force title dimensions to be even
HandBrake's video pipeline uses yuv420 color which requires even dimensions. The input video may be a diffent color space that allows odd dimensions. So crop a row or colomn if necessary. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4239 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r--libhb/decavcodec.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/libhb/decavcodec.c b/libhb/decavcodec.c
index 478934b3b..09ad0ce80 100644
--- a/libhb/decavcodec.c
+++ b/libhb/decavcodec.c
@@ -527,10 +527,11 @@ static hb_buffer_t *copy_frame( hb_work_private_t *pv, AVFrame *frame )
int w, h;
if ( ! pv->job )
{
- // if the dimensions are odd, drop the lsb since h264 requires that
- // both width and height be even.
- w = ( context->width >> 1 ) << 1;
- h = ( context->height >> 1 ) << 1;
+ // HandBrake's video pipeline uses yuv420 color. This means all
+ // dimensions must be even. So we must adjust the dimensions
+ // of incoming video if not even.
+ w = context->width & ~1;
+ h = context->height & ~1;
}
else
{
@@ -549,11 +550,12 @@ static hb_buffer_t *copy_frame( hb_work_private_t *pv, AVFrame *frame )
if ( ! pv->sws_context )
{
- pv->sws_context = hb_sws_get_context( context->width, context->height, context->pix_fmt,
+ pv->sws_context = hb_sws_get_context( w, h, context->pix_fmt,
w, h, PIX_FMT_YUV420P,
SWS_LANCZOS|SWS_ACCURATE_RND);
}
- sws_scale( pv->sws_context, (const uint8_t* const *)frame->data, frame->linesize, 0, h,
+ sws_scale( pv->sws_context, (const uint8_t* const *)frame->data,
+ frame->linesize, 0, h,
dstpic.data, dstpic.linesize );
}
else
@@ -1276,8 +1278,11 @@ static int decavcodecvInfo( hb_work_object_t *w, hb_work_info_t *info )
memset( info, 0, sizeof(*info) );
info->bitrate = pv->context->bit_rate;
- info->width = pv->context->width;
- info->height = pv->context->height;
+ // HandBrake's video pipeline uses yuv420 color. This means all
+ // dimensions must be even. So we must adjust the dimensions
+ // of incoming video if not even.
+ info->width = pv->context->width & ~1;
+ info->height = pv->context->height & ~1;
info->pixel_aspect_width = pv->context->sample_aspect_ratio.num;
info->pixel_aspect_height = pv->context->sample_aspect_ratio.den;