]> git.videolan.org Git - x264.git/commitdiff
Fix a crash in --dump-yuv for odd resolutions
authorLoren Merritt <pengvado@akuvian.org>
Sun, 14 Nov 2010 10:54:02 +0000 (02:54 -0800)
committerJason Garrett-Glaser <darkshikari@gmail.com>
Sun, 14 Nov 2010 10:54:02 +0000 (02:54 -0800)
common/mc.h
encoder/encoder.c

index 680c5ddb9cfeed8dab91230aa3083c70577bdcf8..a04b5c5a6c0d098b1b22dc0a06f28b0a3e70f4cf 100644 (file)
@@ -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 );
index 2a6b0df2fc23f09bc68bd3b9eaf05234b1388fe9..ede1c28fb41e53f9ddc941f56df8aa67deac4bf2 100644 (file)
@@ -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 );
 }