Mercurial > mplayer.hg
comparison libmpcodecs/vf_noise.c @ 31003:00825525514e
Replace memalign(x) (x > 8) by av_malloc() to prevent crashes on systems
lacking memalign(), e.g. Win32.
author | zuxy |
---|---|
date | Tue, 20 Apr 2010 04:33:00 +0000 |
parents | 8a96d56b01f0 |
children | 8fa2f43cb760 |
comparison
equal
deleted
inserted
replaced
31002:8eecc5573a65 | 31003:00825525514e |
---|---|
34 | 34 |
35 #include "img_format.h" | 35 #include "img_format.h" |
36 #include "mp_image.h" | 36 #include "mp_image.h" |
37 #include "vf.h" | 37 #include "vf.h" |
38 #include "libvo/fastmemcpy.h" | 38 #include "libvo/fastmemcpy.h" |
39 #include "libavutil/mem.h" | |
39 | 40 |
40 #define MAX_NOISE 4096 | 41 #define MAX_NOISE 4096 |
41 #define MAX_SHIFT 1024 | 42 #define MAX_SHIFT 1024 |
42 #define MAX_RES (MAX_NOISE-MAX_SHIFT) | 43 #define MAX_RES (MAX_NOISE-MAX_SHIFT) |
43 | 44 |
78 static int8_t *initNoise(FilterParam *fp){ | 79 static int8_t *initNoise(FilterParam *fp){ |
79 int strength= fp->strength; | 80 int strength= fp->strength; |
80 int uniform= fp->uniform; | 81 int uniform= fp->uniform; |
81 int averaged= fp->averaged; | 82 int averaged= fp->averaged; |
82 int pattern= fp->pattern; | 83 int pattern= fp->pattern; |
83 int8_t *noise= memalign(16, MAX_NOISE*sizeof(int8_t)); | 84 int8_t *noise= av_malloc(MAX_NOISE*sizeof(int8_t)); |
84 int i, j; | 85 int i, j; |
85 | 86 |
86 srand(123457); | 87 srand(123457); |
87 | 88 |
88 for(i=0,j=0; i<MAX_NOISE; i++,j++) | 89 for(i=0,j=0; i<MAX_NOISE; i++,j++) |
367 } | 368 } |
368 | 369 |
369 static void uninit(struct vf_instance *vf){ | 370 static void uninit(struct vf_instance *vf){ |
370 if(!vf->priv) return; | 371 if(!vf->priv) return; |
371 | 372 |
372 if(vf->priv->chromaParam.noise) free(vf->priv->chromaParam.noise); | 373 if(vf->priv->chromaParam.noise) av_free(vf->priv->chromaParam.noise); |
373 vf->priv->chromaParam.noise= NULL; | 374 vf->priv->chromaParam.noise= NULL; |
374 | 375 |
375 if(vf->priv->lumaParam.noise) free(vf->priv->lumaParam.noise); | 376 if(vf->priv->lumaParam.noise) av_free(vf->priv->lumaParam.noise); |
376 vf->priv->lumaParam.noise= NULL; | 377 vf->priv->lumaParam.noise= NULL; |
377 | 378 |
378 free(vf->priv); | 379 free(vf->priv); |
379 vf->priv=NULL; | 380 vf->priv=NULL; |
380 } | 381 } |