changeset 7051:d03fad6123a3

asserts to check buffer size and non overlapingness
author michael
date Wed, 21 Aug 2002 19:08:24 +0000
parents a5b2b377ab50
children f3b2f31332fc
files libmpcodecs/vd_ffmpeg.c
diffstat 1 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/vd_ffmpeg.c	Tue Aug 20 14:15:25 2002 +0000
+++ b/libmpcodecs/vd_ffmpeg.c	Wed Aug 21 19:08:24 2002 +0000
@@ -351,6 +351,21 @@
     if(avctx->dr_uvstride && avctx->dr_uvstride !=mpi->stride[1]){
         mp_msg(MSGT_DECVIDEO,MSGL_ERR, "Error: uvstride changed\n");
     }
+    
+    assert(mpi->width  >= ((width +align)&(~align)));   
+    assert(mpi->height >= ((height+align)&(~align)));
+    assert(mpi->stride[0] >= mpi->width);
+    if(mpi->imgfmt==IMGFMT_I420 || mpi->imgfmt==IMGFMT_YV12 || mpi->imgfmt==IMGFMT_IYUV){
+        const int y_size= mpi->stride[0] * mpi->height;
+        const int c_size= mpi->stride[1] * mpi->chroma_height;
+        
+        assert(mpi->planes[0] > mpi->planes[1] || mpi->planes[0] + y_size <= mpi->planes[1]);
+        assert(mpi->planes[0] > mpi->planes[2] || mpi->planes[0] + y_size <= mpi->planes[2]);
+        assert(mpi->planes[1] > mpi->planes[0] || mpi->planes[1] + c_size <= mpi->planes[0]);
+        assert(mpi->planes[1] > mpi->planes[2] || mpi->planes[1] + c_size <= mpi->planes[2]);
+        assert(mpi->planes[2] > mpi->planes[0] || mpi->planes[2] + c_size <= mpi->planes[0]);
+        assert(mpi->planes[2] > mpi->planes[1] || mpi->planes[2] + c_size <= mpi->planes[1]);
+    }
 
     avctx->dr_stride   = mpi->stride[0];
     avctx->dr_uvstride = mpi->stride[1];