changeset 29064:67c256364220

Consistently use MP_MAX_PLANES as size for plane pointer/stride arrays in libmpcodecs. This might avoid some issues since sws_scale in some cases assumes these have at least 4 valid entries.
author reimar
date Sun, 29 Mar 2009 14:46:59 +0000
parents ea02e8fa3042
children 1ae39343cd81
files libmpcodecs/vf_sab.c libmpcodecs/vf_scale.c libmpcodecs/vf_screenshot.c libmpcodecs/vf_smartblur.c
diffstat 4 files changed, 18 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/vf_sab.c	Sun Mar 29 14:43:11 2009 +0000
+++ b/libmpcodecs/vf_sab.c	Sun Mar 29 14:46:59 2009 +0000
@@ -174,10 +174,10 @@
 	int x, y;
 	FilterParam f= *fp;
 	const int radius= f.distWidth/2;
-	uint8_t *srcArray[3]= {src, NULL, NULL};
-	uint8_t *dstArray[3]= {f.preFilterBuf, NULL, NULL};
-	int srcStrideArray[3]= {srcStride, 0, 0};
-	int dstStrideArray[3]= {f.preFilterStride, 0, 0};
+	uint8_t *srcArray[MP_MAX_PLANES]= {src};
+	uint8_t *dstArray[MP_MAX_PLANES]= {f.preFilterBuf};
+	int srcStrideArray[MP_MAX_PLANES]= {srcStride};
+	int dstStrideArray[MP_MAX_PLANES]= {f.preFilterStride};
 
 //	f.preFilterContext->swScale(f.preFilterContext, srcArray, srcStrideArray, 0, h, dstArray, dstStrideArray);
 	sws_scale(f.preFilterContext, srcArray, srcStrideArray, 0, h, dstArray, dstStrideArray);
--- a/libmpcodecs/vf_scale.c	Sun Mar 29 14:43:11 2009 +0000
+++ b/libmpcodecs/vf_scale.c	Sun Mar 29 14:46:59 2009 +0000
@@ -319,9 +319,9 @@
 	vf->priv->w, vf->priv->h);
 }
 
-static void scale(struct SwsContext *sws1, struct SwsContext *sws2, uint8_t *src[3], int src_stride[3], int y, int h, 
-                  uint8_t *dst[3], int dst_stride[3], int interlaced){
-    uint8_t *src2[3]={src[0], src[1], src[2]};
+static void scale(struct SwsContext *sws1, struct SwsContext *sws2, uint8_t *src[MP_MAX_PLANES], int src_stride[MP_MAX_PLANES],
+                  int y, int h,  uint8_t *dst[MP_MAX_PLANES], int dst_stride[MP_MAX_PLANES], int interlaced){
+    uint8_t *src2[MP_MAX_PLANES]={src[0], src[1], src[2]};
 #ifdef WORDS_BIGENDIAN
     uint32_t pal2[256];
     if (src[1] && !src[2]){
@@ -334,9 +334,9 @@
 
     if(interlaced){
         int i;
-        uint8_t *dst2[3]={dst[0], dst[1], dst[2]};
-        int src_stride2[3]={2*src_stride[0], 2*src_stride[1], 2*src_stride[2]};
-        int dst_stride2[3]={2*dst_stride[0], 2*dst_stride[1], 2*dst_stride[2]};
+        uint8_t *dst2[MP_MAX_PLANES]={dst[0], dst[1], dst[2]};
+        int src_stride2[MP_MAX_PLANES]={2*src_stride[0], 2*src_stride[1], 2*src_stride[2]};
+        int dst_stride2[MP_MAX_PLANES]={2*dst_stride[0], 2*dst_stride[1], 2*dst_stride[2]};
 
         sws_scale_ordered(sws1, src2, src_stride2, y>>1, h>>1, dst2, dst_stride2);
         for(i=0; i<3; i++){
--- a/libmpcodecs/vf_screenshot.c	Sun Mar 29 14:43:11 2009 +0000
+++ b/libmpcodecs/vf_screenshot.c	Sun Mar 29 14:46:59 2009 +0000
@@ -108,16 +108,14 @@
 
 static void scale_image(struct vf_priv_s* priv, mp_image_t *mpi)
 {
-    uint8_t *dst[3];
-    int dst_stride[3];
+    uint8_t *dst[MP_MAX_PLANES] = {NULL};
+    int dst_stride[MP_MAX_PLANES] = {0};
 
     dst_stride[0] = priv->stride;
-    dst_stride[1] = dst_stride[2] = 0;
     if (!priv->buffer)
         priv->buffer = memalign(16, dst_stride[0]*priv->dh);
 
     dst[0] = priv->buffer;
-    dst[1] = dst[2] = 0;
     sws_scale_ordered(priv->ctx, mpi->planes, mpi->stride, 0, priv->dh, dst, dst_stride);
 }
 
@@ -137,12 +135,10 @@
                        int* stride, int w,int h, int x, int y)
 {
     if (vf->priv->store_slices) {
-        uint8_t *dst[3];
-        int dst_stride[3];
+        uint8_t *dst[MP_MAX_PLANES] = {NULL};
+        int dst_stride[MP_MAX_PLANES] = {0};
         dst_stride[0] = vf->priv->stride;
-        dst_stride[1] = dst_stride[2] = 0;
         dst[0] = vf->priv->buffer;
-        dst[1] = dst[2] = 0;
         sws_scale_ordered(vf->priv->ctx, src, stride, y, h, dst, dst_stride);
     }
     vf_next_draw_slice(vf,src,stride,w,h,x,y);
--- a/libmpcodecs/vf_smartblur.c	Sun Mar 29 14:43:11 2009 +0000
+++ b/libmpcodecs/vf_smartblur.c	Sun Mar 29 14:46:59 2009 +0000
@@ -132,10 +132,10 @@
 static inline void blur(uint8_t *dst, uint8_t *src, int w, int h, int dstStride, int srcStride, FilterParam *fp){
 	int x, y;
 	FilterParam f= *fp;
-	uint8_t *srcArray[3]= {src, NULL, NULL};
-	uint8_t *dstArray[3]= {dst, NULL, NULL};
-	int srcStrideArray[3]= {srcStride, 0, 0};
-	int dstStrideArray[3]= {dstStride, 0, 0};
+	uint8_t *srcArray[MP_MAX_PLANES]= {src};
+	uint8_t *dstArray[MP_MAX_PLANES]= {dst};
+	int srcStrideArray[MP_MAX_PLANES]= {srcStride};
+	int dstStrideArray[MP_MAX_PLANES]= {dstStride};
 
 	sws_scale(f.filterContext, srcArray, srcStrideArray, 0, h, dstArray, dstStrideArray);