changeset 22079:d018c5b9e0e6

use ffmpeg's LZO
author reimar
date Wed, 31 Jan 2007 23:04:20 +0000
parents 9fd2145ddb43
children fc27312ae599
files libmpcodecs/vd_lzo.c
diffstat 1 files changed, 9 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/vd_lzo.c	Wed Jan 31 22:17:52 2007 +0000
+++ b/libmpcodecs/vd_lzo.c	Wed Jan 31 23:04:20 2007 +0000
@@ -6,12 +6,10 @@
 
 #include "vd_internal.h"
 
-#ifdef USE_LIBLZO
-#include <lzo1x.h>
+#ifdef USE_LIBAVUTIL_SO
+#include <ffmpeg/lzo.h>
 #else
-#include "native/minilzo.h"
-#define lzo_malloc malloc
-#define lzo_free free
+#include "libavutil/lzo.h"
 #endif
 
 #define MOD_NAME "DecLZO"
@@ -27,7 +25,6 @@
 LIBVD_EXTERN(lzo)
 
 typedef struct {
-    lzo_byte *wrkmem;
     uint8_t *buffer;
     int bufsz;
     int codec;
@@ -51,8 +48,8 @@
 {
     lzo_context_t *priv;
 
-    if (lzo_init() != LZO_E_OK) {
-	mp_msg (MSGT_DECVIDEO, MSGL_ERR, "[%s] lzo_init() failed\n", MOD_NAME);
+    if (sh->bih->biSizeImage <= 0) {
+	mp_msg (MSGT_DECVIDEO, MSGL_ERR, "[%s] Invalid frame size\n", MOD_NAME);
 	return 0; 
     }
 
@@ -63,17 +60,10 @@
 	return 0;
     }
     priv->bufsz = sh->bih->biSizeImage;
-    priv->buffer = malloc(priv->bufsz);
+    priv->buffer = malloc(priv->bufsz + LZO_OUTPUT_PADDING);
     priv->codec = -1;
     sh->context = priv;
 
-    priv->wrkmem = (lzo_bytep) lzo_malloc(LZO1X_1_MEM_COMPRESS);
-
-    if (priv->wrkmem == NULL) {
-	mp_msg (MSGT_DECVIDEO, MSGL_ERR, "[%s] Cannot alloc work memory\n", MOD_NAME);
-	return 0;
-    }
-
     return 1;
 }
 
@@ -84,8 +74,6 @@
     
     if (priv)
     {
-	if (priv->wrkmem)
-	    lzo_free(priv->wrkmem);
 	free(priv->buffer);
 	free(priv);
     }
@@ -105,8 +93,8 @@
 	    return NULL; // skipped frame
     }
     
-    r = lzo1x_decompress_safe (data, len, priv->buffer, &w, priv->wrkmem);
-    if (r != LZO_E_OK) {
+    r = lzo1x_decode(priv->buffer, &w, data, &len);
+    if (r) {
 	/* this should NEVER happen */
 	mp_msg (MSGT_DECVIDEO, MSGL_ERR, 
 		"[%s] internal error - decompression failed: %d\n", MOD_NAME, r);
@@ -119,7 +107,7 @@
 	    MOD_NAME, sh->bih->biBitCount, sh->format, data, len, sh->bih->biSizeImage
 	    );
 
-	if        (w == (sh->bih->biSizeImage))   {
+	if (w == 0) {
 	    priv->codec = IMGFMT_BGR24;
 	    mp_msg (MSGT_DECVIDEO, MSGL_V, "[%s] codec choosen is BGR24\n", MOD_NAME);
 	} else if (w == (sh->bih->biSizeImage)/2) {