[Mplayer-cvslog] CVS: main/libmpcodecs vf_scale.c,1.26,1.27

Arpi of Ize arpi at mplayerhq.hu
Thu Oct 17 23:53:33 CEST 2002


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

Modified Files:
	vf_scale.c 
Log Message:
exporting palette for 4/8bpp modes


Index: vf_scale.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vf_scale.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- vf_scale.c	13 Oct 2002 00:30:38 -0000	1.26
+++ vf_scale.c	17 Oct 2002 21:53:30 -0000	1.27
@@ -19,6 +19,7 @@
     int param;
     unsigned int fmt;
     SwsContext *ctx;
+    unsigned char* palette;
 };
 
 extern int opt_screen_size_x;
@@ -162,6 +163,32 @@
     }
     vf->priv->fmt=best;
 
+    if(vf->priv->palette){
+	free(vf->priv->palette);
+	vf->priv->palette=NULL;
+    }
+    switch(best){
+    case IMGFMT_BGR8: {
+      /* set 332 palette for 8 bpp */
+	int i;
+	vf->priv->palette=malloc(4*256);
+	for(i=0; i<256; i++){
+	    vf->priv->palette[4*i+0]=4*(i&3)*21;
+	    vf->priv->palette[4*i+1]=4*((i>>2)&7)*9;
+	    vf->priv->palette[4*i+2]=4*((i>>5)&7)*9;
+	}
+	break; }
+    case IMGFMT_BGR4: {
+	int i;
+	vf->priv->palette=malloc(4*16);
+	for(i=0; i<16; i++){
+	    vf->priv->palette[4*i+0]=4*(i&1)*63;
+	    vf->priv->palette[4*i+1]=4*((i>>1)&3)*21;
+	    vf->priv->palette[4*i+2]=4*((i>>3)&1)*63;
+	}
+	break; }
+    }
+
     if(!opt_screen_size_x && !opt_screen_size_y){
 	d_width=d_width*vf->priv->w/width;
 	d_height=d_height*vf->priv->h/height;
@@ -184,6 +211,8 @@
 	dmpi->qscale=mpi->qscale;
 	dmpi->qstride=mpi->qstride;
     }
+
+    if(vf->priv->palette) dmpi->planes[1]=vf->priv->palette; // export palette!
     
     return vf_next_put_image(vf,dmpi);
 }
@@ -237,6 +266,7 @@
     vf->priv->h=-1;
     vf->priv->v_chr_drop=0;
     vf->priv->param=0;
+    vf->priv->palette=NULL;
     if(args) sscanf(args, "%d:%d:%d:%d",
     &vf->priv->w,
     &vf->priv->h,




More information about the MPlayer-cvslog mailing list