[MPlayer-dev-eng] [PATCH] make mplayer's liblzo support compile with lzo 2.x

Reimar D?ffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Sat Jan 27 16:36:52 CET 2007


Hello,
On Fri, Jan 26, 2007 at 05:08:20PM +0100, Carl Eugen Hoyos wrote:
> On 2007-01-17 14:29, Bernhard Rosenkraenzer wrote:
> > SSIA -- the patch is about as simple as it can get, given the API is almost 
> > unchanged.
> 
> Unfortunately, Oberhumer decided to change the installation directory for 
> lzo1x.h to .../include/lzo for version 2:  
> http://www.oberhumer.com/opensource/lzo/lzonews.php (Misc), so I don't think 
> your patch will help for typical(?) installations.
> 
> But why keep support for liblzo1? Most libraries are only supported by mplayer 
> if their newest versions are used. What about the attached patch?

Actually why support liblzo at all? ve_nuv.c e.g. doesn't support it...
We already have included minilzo, and attached is a patch illustrating
what I want to do anyway in the long term, namely using the ffmpeg lzo
after it is moved to libavutil (for the decoding stuff, will have to see
about the encoding later on).

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: demux_mkv.c
===================================================================
--- demux_mkv.c	(revision 22030)
+++ demux_mkv.c	(working copy)
@@ -36,10 +36,10 @@
 #include <zlib.h>
 #endif
 
-#ifdef USE_LIBLZO
-#include <lzo1x.h>
+#ifdef USE_LIBAVUTIL_SO
+#include <ffmpeg/lzo.h>
 #else
-#include "libmpcodecs/native/minilzo.h"
+#include "libavutil/lzo.h"
 #endif
 
 #if !defined(MIN)
@@ -630,23 +627,18 @@
           /* lzo encoded track */
           int dstlen = *size * 3;
 
-          if (lzo_init () != LZO_E_OK)
-            {
-              mp_msg (MSGT_DEMUX, MSGL_WARN,
-                      MSGTR_MPDEMUX_MKV_LzoInitializationFailed);
-              return modified;
-            }
-
           *dest = NULL;
           while (1)
             {
-              *dest = realloc (*dest, dstlen);
-              result = lzo1x_decompress_safe (src, *size, *dest, &dstlen,
-                                              NULL);
-              if (result == LZO_E_OK)
+              int srclen = *size;
+              if (dstlen > SIZE_MAX - 1000) goto lzo_fail;
+              *dest = realloc (*dest, dstlen + LZO_OUTPUT_PADDING);
+              result = lzo1x_decode (*dest, &dstlen, src, &srclen);
+              if (result == 0)
                 break;
-              if (result != LZO_E_OUTPUT_OVERRUN)
+              if (!(result & LZO_OUTPUT_FULL))
                 {
+lzo_fail:
                   mp_msg (MSGT_DEMUX, MSGL_WARN,
                           MSGTR_MPDEMUX_MKV_LzoDecompressionFailed);
                   free(*dest);
@@ -1157,7 +1149,7 @@
 	    // audit: cheap guard against overflows later..
 	    if (num > SIZE_MAX - 1000) return 0;
             l = x + num;
-            track->private_data = malloc (num);
+            track->private_data = malloc (num + LZO_INPUT_PADDING);
             if (stream_read(s, track->private_data, num) != (int) num)
               goto err_out;
             track->private_size = num;
@@ -3409,7 +3370,8 @@
                 case MATROSKA_ID_BLOCK:
                   block_length = ebml_read_length (s, &tmp);
                   free(block);
-                  block = malloc (block_length);
+                  if (block_length > SIZE_MAX - 1000) return 0;
+                  block = malloc (block_length + LZO_INPUT_PADDING);
                   demuxer->filepos = stream_tell (s);
                   if (stream_read (s,block,block_length) != (int) block_length)
                   {


More information about the MPlayer-dev-eng mailing list