[Mplayer-cvslog] CVS: main/libmpcodecs vd_zlib.c,1.8,1.9

Alex Beregszaszi alex at mplayerhq.hu
Sat Aug 31 20:59:50 CEST 2002


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

Modified Files:
	vd_zlib.c 
Log Message:
made compatible to LCL

Index: vd_zlib.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vd_zlib.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- vd_zlib.c	31 Aug 2002 13:09:23 -0000	1.8
+++ vd_zlib.c	31 Aug 2002 18:59:47 -0000	1.9
@@ -1,3 +1,9 @@
+/*
+    AVIzlib decoder
+    
+    http://www.pcisys.net/~melanson/codecs/lcl.txt
+*/
+
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -14,8 +20,8 @@
 	"AVIzlib decoder",
 	"zlib",
 	"Alex",
-	"based on vd_ijpg.c",
-	"uses zlib, supports only BGR24 (as AVIzlib)"
+	"Alex",
+	"based on vd_ijpg.c, uses zlib, supports only BGR24 (as AVIzlib)"
 };
 
 LIBVD_EXTERN(zlib)
@@ -23,10 +29,21 @@
 typedef struct {
     int width;
     int height;
-    int depth;
+    int imgformat;
+    int decompsize;
     z_stream zstrm;
 } vd_zlib_ctx;
 
+/* BITMAPINFOHEADER LCL Extension */
+typedef struct {
+    unsigned char filler[sizeof(BITMAPINFOHEADER)];
+    unsigned char unknown[4];
+    unsigned char imgtype;
+    unsigned char compression;
+    unsigned char flags;
+    unsigned char codec;
+} bih_lcl_ext;
+
 // to set/get/query special features/parameters
 static int control(sh_video_t *sh, int cmd, void *arg, ...)
 {
@@ -35,7 +52,7 @@
     {
 	case VDCTRL_QUERY_FORMAT:
 	{
-	    if (*((int*)arg) == (IMGFMT_BGR|ctx->depth))
+	    if (*((int*)arg) == (ctx->imgformat))
 		return(CONTROL_TRUE);
 	    else
 		return(CONTROL_FALSE);
@@ -49,6 +66,7 @@
 {
     int zret;
     vd_zlib_ctx *ctx;
+    bih_lcl_ext *ext;
     
     ctx = sh->context = malloc(sizeof(vd_zlib_ctx));
     if (!ctx)
@@ -57,7 +75,39 @@
 
     ctx->width = sh->bih->biWidth;
     ctx->height = sh->bih->biHeight;
-    ctx->depth = sh->bih->biBitCount;
+    ctx->imgformat = IMGFMT_BGR24;
+    ctx->decompsize = ctx->width*ctx->height*((24+7)/8);
+    
+    if (sh->bih->biSize > sizeof(BITMAPINFOHEADER))
+    {
+	ext = sh->bih;
+	if (ext->codec != 3) /* 1 == MSZH, 3 == ZLIB */
+	    return(0);
+	switch(ext->imgtype)
+	{
+	    case 2: /* RGB24 */
+		ctx->imgformat = IMGFMT_BGR24;
+		ctx->decompsize = ctx->width*ctx->height*((24+7)/8);
+		break;
+	    case 0: /* YUV411 */
+//		ctx->imgformat = IMGFMT_YVU9;
+//		ctx->decompsize = ctx->width*(ctx->height+2)/8*9;
+//		break;
+	    case 1: /* YUV422 */
+//		ctx->imgformat = IMGFMT_YUY2;
+//		ctx->decompsize = ctx->width*(ctx->height+2)/8*16;
+//		break;
+	    case 5: /* YUV420 */
+//		ctx->imgformat = IMGFMT_YV12;
+//		ctx->decompsize = ctx->width*(ctx->height+2)/8*12;
+//		break;
+	    case 3: /* YUV411 */
+	    case 4: /* YUV211 */
+	    default:
+		printf("Unknown imgtype\n");
+		return(0);
+	}
+    }
 
     ctx->zstrm.zalloc = (alloc_func)NULL;
     ctx->zstrm.zfree = (free_func)NULL;
@@ -71,7 +121,7 @@
 	return(NULL);
     }
 
-    if (!mpcodecs_config_vo(sh, ctx->width, ctx->height, IMGFMT_BGR|ctx->depth))
+    if (!mpcodecs_config_vo(sh, ctx->width, ctx->height, ctx->imgformat))
 	return(NULL);
 
 
@@ -96,7 +146,6 @@
     mp_image_t *mpi;
     vd_zlib_ctx *ctx = sh->context;
     int zret;
-    int decomp_size = ctx->width*ctx->height*((ctx->depth+7)/8);
     z_stream *zstrm = &ctx->zstrm;
 
     if (len <= 0)
@@ -108,7 +157,7 @@
     zstrm->next_in = data;
     zstrm->avail_in = len;
     zstrm->next_out = mpi->planes[0];
-    zstrm->avail_out = decomp_size;
+    zstrm->avail_out = ctx->decompsize;
 
     mp_dbg(MSGT_DECVIDEO, MSGL_DBG2, "[vd_zlib] input: %p (%d bytes), output: %p (%d bytes)\n",
 	zstrm->next_in, zstrm->avail_in, zstrm->next_out, zstrm->avail_out);
@@ -121,10 +170,10 @@
 	return(NULL);
     }
     
-    if (decomp_size != (int)zstrm->total_out)
+    if (ctx->decompsize != (int)zstrm->total_out)
     {
 	mp_msg(MSGT_DECVIDEO, MSGL_WARN, "[vd_zlib] decoded size differs (%d != %d)\n",
-	    decomp_size, zstrm->total_out);
+	    ctx->decompsize, zstrm->total_out);
 	return(NULL);
     }
 




More information about the MPlayer-cvslog mailing list