# HG changeset patch # User reimar # Date 1236609041 0 # Node ID 8cfb1d6272fe2205ec37311c254cef515ac4f4be # Parent 3420ff87048ef0815a42cd688399b9b6ceaec10b Allocate buffer for lzo compression correctly also for large frame sizes. diff -r 3420ff87048e -r 8cfb1d6272fe libmpcodecs/ve_nuv.c --- a/libmpcodecs/ve_nuv.c Mon Mar 09 13:37:55 2009 +0000 +++ b/libmpcodecs/ve_nuv.c Mon Mar 09 14:30:41 2009 +0000 @@ -24,8 +24,7 @@ #include "native/rtjpegn.h" #define LZO_AL(size) (((size) + (sizeof(long) - 1)) / sizeof(long)) -#define LZO_IN_LEN (1024*1024L) -#define LZO_OUT_LEN (LZO_IN_LEN + LZO_IN_LEN / 64 + 16 + 3) +#define LZO_OUT_LEN(in) ((in) + (in) / 64 + 16 + 3) //===========================================================================// @@ -85,6 +84,8 @@ mux_v->bih->biSizeImage=mux_v->bih->biWidth*mux_v->bih->biHeight*(mux_v->bih->biBitCount/8); mux_v->aspect = (float)d_width/d_height; vf->priv->buffer = realloc(vf->priv->buffer,vf->priv->buf_size); + if (vf->priv->lzo) + vf->priv->zbuffer = realloc(vf->priv->zbuffer, FRAMEHEADERSIZE + LZO_OUT_LEN(vf->priv->buf_size)); vf->priv->tbl_wrote = 0; return 1; @@ -218,8 +219,7 @@ if(lzo_init() != LZO_E_OK) { mp_msg(MSGT_VFILTER,MSGL_WARN,"LZO init failed: no lzo compression\n"); vf->priv->lzo = 0; - } - vf->priv->zbuffer = (lzo_bytep)malloc(FRAMEHEADERSIZE + LZO_OUT_LEN); + } else vf->priv->zmem = malloc(sizeof(long)*LZO_AL(LZO1X_1_MEM_COMPRESS)); }