[MPlayer-cvslog] r29103 - in trunk/libmpcodecs: vf_sab.c vf_scale.c vf_screenshot.c vf_smartblur.c

reimar subversion at mplayerhq.hu
Sun Mar 29 16:46:59 CEST 2009


Author: reimar
Date: Sun Mar 29 16:46:59 2009
New Revision: 29103

Log:
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.

Modified:
   trunk/libmpcodecs/vf_sab.c
   trunk/libmpcodecs/vf_scale.c
   trunk/libmpcodecs/vf_screenshot.c
   trunk/libmpcodecs/vf_smartblur.c

Modified: trunk/libmpcodecs/vf_sab.c
==============================================================================
--- trunk/libmpcodecs/vf_sab.c	Sun Mar 29 16:43:11 2009	(r29102)
+++ trunk/libmpcodecs/vf_sab.c	Sun Mar 29 16:46:59 2009	(r29103)
@@ -174,10 +174,10 @@ static inline void blur(uint8_t *dst, ui
 	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);

Modified: trunk/libmpcodecs/vf_scale.c
==============================================================================
--- trunk/libmpcodecs/vf_scale.c	Sun Mar 29 16:43:11 2009	(r29102)
+++ trunk/libmpcodecs/vf_scale.c	Sun Mar 29 16:46:59 2009	(r29103)
@@ -319,9 +319,9 @@ static void start_slice(struct vf_instan
 	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 @@ static void scale(struct SwsContext *sws
 
     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++){

Modified: trunk/libmpcodecs/vf_screenshot.c
==============================================================================
--- trunk/libmpcodecs/vf_screenshot.c	Sun Mar 29 16:43:11 2009	(r29102)
+++ trunk/libmpcodecs/vf_screenshot.c	Sun Mar 29 16:46:59 2009	(r29103)
@@ -108,16 +108,14 @@ static void gen_fname(struct vf_priv_s* 
 
 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 @@ static void draw_slice(struct vf_instanc
                        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);

Modified: trunk/libmpcodecs/vf_smartblur.c
==============================================================================
--- trunk/libmpcodecs/vf_smartblur.c	Sun Mar 29 16:43:11 2009	(r29102)
+++ trunk/libmpcodecs/vf_smartblur.c	Sun Mar 29 16:46:59 2009	(r29103)
@@ -132,10 +132,10 @@ static void uninit(struct vf_instance_s*
 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);
 	


More information about the MPlayer-cvslog mailing list