[Mplayer-cvslog] CVS: main/libmpcodecs vf.h,1.7,1.8 vf.c,1.14,1.15

Arpi of Ize arpi at mplayerhq.hu
Wed Apr 17 21:05:17 CEST 2002


Update of /cvsroot/mplayer/main/libmpcodecs
In directory mail:/var/tmp.root/cvs-serv20526

Modified Files:
	vf.h vf.c 
Log Message:
mpi clear func

Index: vf.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vf.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- vf.h	15 Apr 2002 22:41:06 -0000	1.7
+++ vf.h	17 Apr 2002 19:05:14 -0000	1.8
@@ -55,6 +55,7 @@
 #include "vfcap.h"
 
 // functions:
+void vf_mpi_clear(mp_image_t* mpi,int x0,int y0,int w,int h);
 mp_image_t* vf_get_image(vf_instance_t* vf, unsigned int outfmt, int mp_imgtype, int mp_imgflag, int w, int h);
 
 vf_instance_t* vf_open_plugin(vf_info_t** filter_list, vf_instance_t* next, char *name, char *args);

Index: vf.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vf.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- vf.c	13 Apr 2002 19:14:31 -0000	1.14
+++ vf.c	17 Apr 2002 19:05:14 -0000	1.15
@@ -39,9 +39,44 @@
 };
 
 //============================================================================
-
 // mpi stuff:
 
+void vf_mpi_clear(mp_image_t* mpi,int x0,int y0,int w,int h){
+    int y;
+    if(mpi->flags&MP_IMGFLAG_PLANAR){
+	if(x==0 && w==mpi->width){
+	    // full width clear:
+	    memset(mpi->planes[0]+mpi->stride[0]*y0,0,mpi->stride[0]*h);
+	    memset(mpi->planes[1]+mpi->stride[1]*(y0>>1),128,mpi->stride[1]*(h>>1));
+	    memset(mpi->planes[2]+mpi->stride[2]*(y0>>1),128,mpi->stride[2]*(h>>1));
+	    return;
+	}
+	for(y=y0;y<y0+h;y+=2){
+	    memset(mpi->planes[0]+x0+mpi->stride[0]*y,0,w);
+	    memset(mpi->planes[0]+x0+mpi->stride[0]*(y+1),0,w);
+	    memset(mpi->planes[1]+(x0>>1)+mpi->stride[1]*(y>>1),128,(w>>1));
+	    memset(mpi->planes[2]+(x0>>1)+mpi->stride[2]*(y>>1),128,(w>>1));
+	}
+    }
+    // packed:
+    for(y=y0;y<y0+h;y++){
+	unsigned char* dst=mpi->planes[0]+mpi->stride[0]*y+(mpi->bpp>>3)*x0;
+	if(mpi->flags&MP_IMGFLAG_YUV){
+	    unsigned int* p=dst;
+	    int size=(mpi->bpp>>3)*w/4;
+	    int i;
+	    if(mpi->flags&MP_IMGFLAG_SWAPPED){
+	        for(i=0;i<size;i+=4) p[i]=p[i+1]=p[i+2]=p[i+3]=0x00800080;
+		for(;i<size;i++) p[i]=0x00800080;
+	    } else {
+	        for(i=0;i<size;i+=4) p[i]=p[i+1]=p[i+2]=p[i+3]=0x80008000;
+		for(;i<size;i++) p[i]=0x80008000;
+	    }
+	} else
+	    memset(dst,0,(mpi->bpp>>3)*w);
+    }
+}
+
 mp_image_t* vf_get_image(vf_instance_t* vf, unsigned int outfmt, int mp_imgtype, int mp_imgflag, int w, int h){
   mp_image_t* mpi=NULL;
   int w2=w; //(mp_imgflag&MP_IMGFLAG_ACCEPT_STRIDE)?((w+15)&(~15)):w;
@@ -108,23 +143,10 @@
 	          mpi->planes[2]=mpi->planes[0]+mpi->width*mpi->height;
 	          mpi->planes[1]=mpi->planes[2]+(mpi->width>>1)*(mpi->height>>1);
 	      }
-	      // clear!
-	      memset(mpi->planes[0],0,mpi->stride[0]*mpi->height);
-	      memset(mpi->planes[1],128,mpi->stride[1]*(mpi->height>>1));
-	      memset(mpi->planes[2],128,mpi->stride[2]*(mpi->height>>1));
 	  } else {
 	      if(!mpi->stride[0]) mpi->stride[0]=mpi->width*mpi->bpp/8;
-	      if(mpi->flags&MP_IMGFLAG_YUV){
-		  int size=mpi->bpp*mpi->width*mpi->height/8/4;
-		  unsigned int* p=mpi->planes[0];
-		  int i;
-		  if(mpi->flags&MP_IMGFLAG_SWAPPED)
-		      for(i=0;i<size;i+=4) p[i]=p[i+1]=p[i+2]=p[i+3]=0x00800080;
-		  else
-		      for(i=0;i<size;i+=4) p[i]=p[i+1]=p[i+2]=p[i+3]=0x80008000;
-	      } else
-	          memset(mpi->planes[0],0,mpi->bpp*mpi->width*mpi->height/8);
 	  }
+	  vf_mpi_clear(mpi,mpi->width,mpi->height);
 	  mpi->flags|=MP_IMGFLAG_ALLOCATED;
         }
     }




More information about the MPlayer-cvslog mailing list