summaryrefslogtreecommitdiffstats
path: root/libhb/encx264.c
diff options
context:
space:
mode:
authorvan <[email protected]>2008-11-08 06:50:15 +0000
committervan <[email protected]>2008-11-08 06:50:15 +0000
commitfa63e466c782f2d803cd800148fdfd266d26bfe7 (patch)
tree52bbc3e91f3ed43ee536c46ca54660a04aedb086 /libhb/encx264.c
parent89eef8d080649cc44a1abc7ed0a0248c6976951d (diff)
Correct chroma size for raw video frames - width & height need to be rounded up if they're odd before dividing by 2.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1905 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/encx264.c')
-rw-r--r--libhb/encx264.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/libhb/encx264.c b/libhb/encx264.c
index e2d90cd31..97de03e8e 100644
--- a/libhb/encx264.c
+++ b/libhb/encx264.c
@@ -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 )
{