[MPlayer-cvslog] r31045 - in trunk/libmpcodecs: mp_image.c vd_dmo.c vf.c vf_noise.c vf_screenshot.c vf_unsharp.c
zuxy
subversion at mplayerhq.hu
Tue Apr 20 06:33:03 CEST 2010
Author: zuxy
Date: Tue Apr 20 06:33:00 2010
New Revision: 31045
Log:
Replace memalign(x) (x > 8) to av_malloc() to prevent crashes on systems
lacking memalign(), e.g. Win32.
Modified:
trunk/libmpcodecs/mp_image.c
trunk/libmpcodecs/vd_dmo.c
trunk/libmpcodecs/vf.c
trunk/libmpcodecs/vf_noise.c
trunk/libmpcodecs/vf_screenshot.c
trunk/libmpcodecs/vf_unsharp.c
Modified: trunk/libmpcodecs/mp_image.c
==============================================================================
--- trunk/libmpcodecs/mp_image.c Sat Apr 17 04:19:34 2010 (r31044)
+++ trunk/libmpcodecs/mp_image.c Tue Apr 20 06:33:00 2010 (r31045)
@@ -30,14 +30,15 @@
#include "libmpcodecs/mp_image.h"
#include "libvo/fastmemcpy.h"
+#include "libavutil/mem.h"
void mp_image_alloc_planes(mp_image_t *mpi) {
// IF09 - allocate space for 4. plane delta info - unused
if (mpi->imgfmt == IMGFMT_IF09) {
- mpi->planes[0]=memalign(64, mpi->bpp*mpi->width*(mpi->height+2)/8+
+ mpi->planes[0]=av_malloc(mpi->bpp*mpi->width*(mpi->height+2)/8+
mpi->chroma_width*mpi->chroma_height);
} else
- mpi->planes[0]=memalign(64, mpi->bpp*mpi->width*(mpi->height+2)/8);
+ mpi->planes[0]=av_malloc(mpi->bpp*mpi->width*(mpi->height+2)/8);
if (mpi->flags&MP_IMGFLAG_PLANAR) {
int bpp = IMGFMT_IS_YUVP16(mpi->imgfmt)? 2 : 1;
// YV12/I420/YVU9/IF09. feel free to add other planar formats here...
@@ -65,7 +66,7 @@ void mp_image_alloc_planes(mp_image_t *m
} else {
mpi->stride[0]=mpi->width*mpi->bpp/8;
if (mpi->flags & MP_IMGFLAG_RGB_PALETTE)
- mpi->planes[1] = memalign(64, 1024);
+ mpi->planes[1] = av_malloc(1024);
}
mpi->flags|=MP_IMGFLAG_ALLOCATED;
}
@@ -191,9 +192,9 @@ void free_mp_image(mp_image_t* mpi){
if(!mpi) return;
if(mpi->flags&MP_IMGFLAG_ALLOCATED){
/* becouse we allocate the whole image in once */
- if(mpi->planes[0]) free(mpi->planes[0]);
+ if(mpi->planes[0]) av_free(mpi->planes[0]);
if (mpi->flags & MP_IMGFLAG_RGB_PALETTE)
- free(mpi->planes[1]);
+ av_free(mpi->planes[1]);
}
free(mpi);
}
Modified: trunk/libmpcodecs/vd_dmo.c
==============================================================================
--- trunk/libmpcodecs/vd_dmo.c Sat Apr 17 04:19:34 2010 (r31044)
+++ trunk/libmpcodecs/vd_dmo.c Tue Apr 20 06:33:00 2010 (r31045)
@@ -83,7 +83,7 @@ static int init(sh_video_t *sh){
if (sh->disp_w & 3)
{
ctx->stride = ((sh->disp_w * 3) + 3) & ~3;
- ctx->buffer = memalign(64, ctx->stride * sh->disp_h);
+ ctx->buffer = av_malloc(ctx->stride * sh->disp_h);
}
default:
DMO_VideoDecoder_SetDestFmt(ctx->decoder,out_fmt&255,0); // RGB/BGR
@@ -97,6 +97,7 @@ static int init(sh_video_t *sh){
static void uninit(sh_video_t *sh){
struct context *ctx = sh->context;
DMO_VideoDecoder_Destroy(ctx->decoder);
+ av_free(ctx->buffer);
free(ctx);
sh->context = NULL;
}
Modified: trunk/libmpcodecs/vf.c
==============================================================================
--- trunk/libmpcodecs/vf.c Sat Apr 17 04:19:34 2010 (r31044)
+++ trunk/libmpcodecs/vf.c Tue Apr 20 06:33:00 2010 (r31045)
@@ -40,6 +40,7 @@
#include "vf.h"
#include "libvo/fastmemcpy.h"
+#include "libavutil/mem.h"
extern const vf_info_t vf_info_vo;
extern const vf_info_t vf_info_rectangle;
@@ -350,7 +351,7 @@ mp_image_t* vf_get_image(vf_instance_t*
if(mpi->flags&MP_IMGFLAG_ALLOCATED){
if(mpi->width<w2 || mpi->height<h){
// need to re-allocate buffer memory:
- free(mpi->planes[0]);
+ av_free(mpi->planes[0]);
mpi->flags&=~MP_IMGFLAG_ALLOCATED;
mp_msg(MSGT_VFILTER,MSGL_V,"vf.c: have to REALLOCATE buffer memory :(\n");
}
Modified: trunk/libmpcodecs/vf_noise.c
==============================================================================
--- trunk/libmpcodecs/vf_noise.c Sat Apr 17 04:19:34 2010 (r31044)
+++ trunk/libmpcodecs/vf_noise.c Tue Apr 20 06:33:00 2010 (r31045)
@@ -36,6 +36,7 @@
#include "mp_image.h"
#include "vf.h"
#include "libvo/fastmemcpy.h"
+#include "libavutil/mem.h"
#define MAX_NOISE 4096
#define MAX_SHIFT 1024
@@ -80,7 +81,7 @@ static int8_t *initNoise(FilterParam *fp
int uniform= fp->uniform;
int averaged= fp->averaged;
int pattern= fp->pattern;
- int8_t *noise= memalign(16, MAX_NOISE*sizeof(int8_t));
+ int8_t *noise= av_malloc(MAX_NOISE*sizeof(int8_t));
int i, j;
srand(123457);
@@ -369,10 +370,10 @@ static int put_image(struct vf_instance
static void uninit(struct vf_instance *vf){
if(!vf->priv) return;
- if(vf->priv->chromaParam.noise) free(vf->priv->chromaParam.noise);
+ if(vf->priv->chromaParam.noise) av_free(vf->priv->chromaParam.noise);
vf->priv->chromaParam.noise= NULL;
- if(vf->priv->lumaParam.noise) free(vf->priv->lumaParam.noise);
+ if(vf->priv->lumaParam.noise) av_free(vf->priv->lumaParam.noise);
vf->priv->lumaParam.noise= NULL;
free(vf->priv);
Modified: trunk/libmpcodecs/vf_screenshot.c
==============================================================================
--- trunk/libmpcodecs/vf_screenshot.c Sat Apr 17 04:19:34 2010 (r31044)
+++ trunk/libmpcodecs/vf_screenshot.c Tue Apr 20 06:33:00 2010 (r31045)
@@ -131,7 +131,7 @@ static void scale_image(struct vf_priv_s
dst_stride[0] = priv->stride;
if (!priv->buffer)
- priv->buffer = memalign(16, dst_stride[0]*priv->dh);
+ priv->buffer = av_malloc(dst_stride[0]*priv->dh);
dst[0] = priv->buffer;
sws_scale(priv->ctx, mpi->planes, mpi->stride, 0, priv->dh, dst, dst_stride);
@@ -144,7 +144,7 @@ static void start_slice(struct vf_instan
if (vf->priv->shot) {
vf->priv->store_slices = 1;
if (!vf->priv->buffer)
- vf->priv->buffer = memalign(16, vf->priv->stride*vf->priv->dh);
+ vf->priv->buffer = av_malloc(vf->priv->stride*vf->priv->dh);
}
}
@@ -277,7 +277,7 @@ static void uninit(vf_instance_t *vf)
avcodec_close(vf->priv->avctx);
av_freep(&vf->priv->avctx);
if(vf->priv->ctx) sws_freeContext(vf->priv->ctx);
- if (vf->priv->buffer) free(vf->priv->buffer);
+ if (vf->priv->buffer) av_free(vf->priv->buffer);
free(vf->priv->outbuffer);
free(vf->priv);
}
Modified: trunk/libmpcodecs/vf_unsharp.c
==============================================================================
--- trunk/libmpcodecs/vf_unsharp.c Sat Apr 17 04:19:34 2010 (r31044)
+++ trunk/libmpcodecs/vf_unsharp.c Tue Apr 20 06:33:00 2010 (r31045)
@@ -143,7 +143,7 @@ static int config( struct vf_instance *v
stepsX = fp->msizeX/2;
stepsY = fp->msizeY/2;
for( z=0; z<2*stepsY; z++ )
- fp->SC[z] = memalign( 16, sizeof(*(fp->SC[z])) * (width+2*stepsX) );
+ fp->SC[z] = av_malloc(sizeof(*(fp->SC[z])) * (width+2*stepsX));
fp = &vf->priv->chromaParam;
effect = fp->amount == 0 ? "don't touch" : fp->amount < 0 ? "blur" : "sharpen";
@@ -152,7 +152,7 @@ static int config( struct vf_instance *v
stepsX = fp->msizeX/2;
stepsY = fp->msizeY/2;
for( z=0; z<2*stepsY; z++ )
- fp->SC[z] = memalign( 16, sizeof(*(fp->SC[z])) * (width+2*stepsX) );
+ fp->SC[z] = av_malloc(sizeof(*(fp->SC[z])) * (width+2*stepsX));
return vf_next_config( vf, width, height, d_width, d_height, flags, outfmt );
}
@@ -212,12 +212,12 @@ static void uninit( struct vf_instance *
fp = &vf->priv->lumaParam;
for( z=0; z<sizeof(fp->SC)/sizeof(fp->SC[0]); z++ ) {
- if( fp->SC[z] ) free( fp->SC[z] );
+ if( fp->SC[z] ) av_free( fp->SC[z] );
fp->SC[z] = NULL;
}
fp = &vf->priv->chromaParam;
for( z=0; z<sizeof(fp->SC)/sizeof(fp->SC[0]); z++ ) {
- if( fp->SC[z] ) free( fp->SC[z] );
+ if( fp->SC[z] ) av_free( fp->SC[z] );
fp->SC[z] = NULL;
}
More information about the MPlayer-cvslog
mailing list