[MPlayer-cvslog] r22096 - trunk/libmpcodecs/vd_lzo.c

reimar subversion at mplayerhq.hu
Wed Jan 31 23:17:53 CET 2007


Author: reimar
Date: Wed Jan 31 23:17:52 2007
New Revision: 22096

Modified:
   trunk/libmpcodecs/vd_lzo.c

Log:
Use export type mpi, everything else is a fragile hack.


Modified: trunk/libmpcodecs/vd_lzo.c
==============================================================================
--- trunk/libmpcodecs/vd_lzo.c	(original)
+++ trunk/libmpcodecs/vd_lzo.c	Wed Jan 31 23:17:52 2007
@@ -28,6 +28,8 @@
 
 typedef struct {
     lzo_byte *wrkmem;
+    uint8_t *buffer;
+    int bufsz;
     int codec;
 } lzo_context_t;
 
@@ -60,6 +62,8 @@
 	mp_msg (MSGT_DECVIDEO, MSGL_ERR, "[%s] memory allocation failed\n", MOD_NAME);
 	return 0;
     }
+    priv->bufsz = sh->bih->biSizeImage;
+    priv->buffer = malloc(priv->bufsz);
     priv->codec = -1;
     sh->context = priv;
 
@@ -82,6 +86,7 @@
     {
 	if (priv->wrkmem)
 	    lzo_free(priv->wrkmem);
+	free(priv->buffer);
 	free(priv);
     }
 
@@ -93,35 +98,27 @@
 {
     int r;
     mp_image_t* mpi;
-    int w;
     lzo_context_t *priv = sh->context;
+    int w = priv->bufsz;
 
     if (len <= 0) {
 	    return NULL; // skipped frame
     }
     
+    r = lzo1x_decompress_safe (data, len, priv->buffer, &w, priv->wrkmem);
+    if (r != LZO_E_OK) {
+	/* this should NEVER happen */
+	mp_msg (MSGT_DECVIDEO, MSGL_ERR, 
+		"[%s] internal error - decompression failed: %d\n", MOD_NAME, r);
+      return NULL;
+    }
 
     if (priv->codec == -1) {
-	lzo_byte *tmp = lzo_malloc(sh->bih->biSizeImage);
-	
-	// decompress one frame to see if its
-	// either YV12 or RGB24
+	// detect RGB24 vs. YV12 via decoded size
 	mp_msg (MSGT_DECVIDEO, MSGL_V, "[%s] 2 depth %d, format %d data %p len (%d) (%d)\n",
 	    MOD_NAME, sh->bih->biBitCount, sh->format, data, len, sh->bih->biSizeImage
 	    );
 
-	/* decompress the frame */
-	w = sh->bih->biSizeImage;
-	r = lzo1x_decompress_safe (data, len, tmp, &w, priv->wrkmem);
-	free(tmp);
-
-	if (r != LZO_E_OK) {
-	    /* this should NEVER happen */
-	    mp_msg (MSGT_DECVIDEO, MSGL_ERR, 
-		    "[%s] internal error - decompression failed: %d\n", MOD_NAME, r);
-	    return NULL;
-	}
-
 	if        (w == (sh->bih->biSizeImage))   {
 	    priv->codec = IMGFMT_BGR24;
 	    mp_msg (MSGT_DECVIDEO, MSGL_V, "[%s] codec choosen is BGR24\n", MOD_NAME);
@@ -140,7 +137,7 @@
 	}
     }
 
-    mpi = mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, 0,
+    mpi = mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, 0,
 	sh->disp_w, sh->disp_h);
 
 
@@ -149,13 +146,15 @@
 	    return NULL;
     }
 
-    w = (mpi->w * mpi->h * mpi->bpp) / 8;
-    r = lzo1x_decompress_safe (data, len, mpi->planes[0], &w, priv->wrkmem);
-    if (r != LZO_E_OK) {
-	/* this should NEVER happen */
-	mp_msg (MSGT_DECVIDEO, MSGL_ERR, 
-		"[%s] internal error - decompression failed: %d\n", MOD_NAME, r);
-      return NULL;
+    mpi->planes[0] = priv->buffer;
+    if (priv->codec == IMGFMT_BGR24)
+        mpi->stride[0] = 3 * sh->disp_w;
+    else {
+        mpi->stride[0] = sh->disp_w;
+        mpi->planes[2] = priv->buffer + sh->disp_w*sh->disp_h;
+        mpi->stride[2] = sh->disp_w / 2;
+        mpi->planes[1] = priv->buffer + sh->disp_w*sh->disp_h*5/4;
+        mpi->stride[1] = sh->disp_w / 2;
     }
 
     mp_msg (MSGT_DECVIDEO, MSGL_DBG2, 



More information about the MPlayer-cvslog mailing list