X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=libhb%2Fencx264.c;h=eb8d8426d22ff284a342b5a2c3e079812f63f380;hb=c5c381e3579de78ead6a777da6c8b934aeaba19e;hp=0e3edd04057bde894bafa494f4570286e95c99ce;hpb=229de90d16af6a55f8a3c89f4ef7594ce6d7c595;p=handbrake-jp%2Fhandbrake-jp-git.git diff --git a/libhb/encx264.c b/libhb/encx264.c index 0e3edd04..eb8d8426 100644 --- a/libhb/encx264.c +++ b/libhb/encx264.c @@ -209,7 +209,7 @@ int encx264Init( hb_work_object_t * w, hb_job_t * job ) param.vui.i_transfer = 1; param.vui.i_colmatrix = 1; } - else if ( job->title->width >= 1280 || job->title->width >= 720 ) + else if ( job->title->width >= 1280 || job->title->height >= 720 ) { // we guess that 720p or above is ITU BT.709 HD content param.vui.i_colorprim = 1; @@ -224,10 +224,10 @@ int encx264Init( hb_work_object_t * w, hb_job_t * job ) param.vui.i_colmatrix = 6; } - if( job->pixel_ratio ) + if( job->anamorphic.mode ) { - param.vui.i_sar_width = job->pixel_aspect_width; - param.vui.i_sar_height = job->pixel_aspect_height; + param.vui.i_sar_width = job->anamorphic.par_width; + param.vui.i_sar_height = job->anamorphic.par_height; hb_log( "encx264: encoding with stored aspect %d/%d", param.vui.i_sar_width, param.vui.i_sar_height ); @@ -312,6 +312,7 @@ int encx264Init( hb_work_object_t * w, hb_job_t * job ) x264_picture_alloc( &pv->pic_in, X264_CSP_I420, job->width, job->height ); + pv->pic_in.img.i_stride[2] = pv->pic_in.img.i_stride[1] = ( ( job->width + 1 ) >> 1 ); pv->x264_allocated_pic = pv->pic_in.img.plane[0]; if (job->areBframes) @@ -391,7 +392,7 @@ static hb_buffer_t *nal_encode( hb_work_object_t *w, x264_picture_t *pic_out, hb_job_t *job = pv->job; /* Should be way too large */ - buf = hb_buffer_init( 3 * job->width * job->height / 2 ); + buf = hb_video_buffer_init( job->width, job->height ); buf->size = 0; buf->frametype = 0; @@ -505,17 +506,18 @@ static hb_buffer_t *x264_encode( hb_work_object_t *w, hb_buffer_t *in ) /* Point x264 at our current buffers Y(UV) data. */ pv->pic_in.img.plane[0] = in->data; + int uvsize = ( (job->width + 1) >> 1 ) * ( (job->height + 1) >> 1 ); if( job->grayscale ) { /* XXX x264 has currently no option for grayscale encoding */ - memset( pv->pic_in.img.plane[1], 0x80, job->width * job->height / 4 ); - memset( pv->pic_in.img.plane[2], 0x80, job->width * job->height / 4 ); + memset( pv->pic_in.img.plane[1], 0x80, uvsize ); + memset( pv->pic_in.img.plane[2], 0x80, uvsize ); } else { /* Point x264 at our buffers (Y)UV data */ pv->pic_in.img.plane[1] = in->data + job->width * job->height; - pv->pic_in.img.plane[2] = in->data + 5 * job->width * job->height / 4; + pv->pic_in.img.plane[2] = pv->pic_in.img.plane[1] + uvsize; } if( in->new_chap && job->chapter_markers ) {