From 8c16b4d3311126bc37ae0ea7071c683e280f388c Mon Sep 17 00:00:00 2001 From: Loren Merritt Date: Sun, 14 Nov 2010 02:54:02 -0800 Subject: [PATCH] Fix a crash in --dump-yuv for odd resolutions --- common/mc.h | 1 + encoder/encoder.c | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/common/mc.h b/common/mc.h index 680c5ddb..a04b5c5a 100644 --- a/common/mc.h +++ b/common/mc.h @@ -92,6 +92,7 @@ typedef struct void (*plane_copy_interleave)( pixel *dst, int i_dst, uint8_t *srcu, int i_srcu, uint8_t *srcv, int i_srcv, int w, int h ); + /* may write up to 15 pixels off the end of each plane */ void (*plane_copy_deinterleave)( pixel *dstu, int i_dstu, pixel *dstv, int i_dstv, pixel *src, int i_src, int w, int h ); diff --git a/encoder/encoder.c b/encoder/encoder.c index 2a6b0df2..ede1c28f 100644 --- a/encoder/encoder.c +++ b/encoder/encoder.c @@ -77,10 +77,11 @@ static void x264_frame_dump( x264_t *h ) fwrite( &h->fdec->plane[0][y*h->fdec->i_stride[0]], sizeof(pixel), h->param.i_width, f ); int cw = h->param.i_width>>1; int ch = h->param.i_height>>1; - pixel *planeu = x264_malloc( cw*ch*2*sizeof(pixel) ); - pixel *planev = planeu + cw*ch; + pixel *planeu = x264_malloc( (cw*ch*2+32)*sizeof(pixel) ); + pixel *planev = planeu + cw*ch + 16; h->mc.plane_copy_deinterleave( planeu, cw, planev, cw, h->fdec->plane[1], h->fdec->i_stride[1], cw, ch ); - fwrite( planeu, 1, cw*ch*2*sizeof(pixel), f ); + fwrite( planeu, 1, cw*ch*sizeof(pixel), f ); + fwrite( planev, 1, cw*ch*sizeof(pixel), f ); x264_free( planeu ); fclose( f ); } -- 2.47.3