summaryrefslogtreecommitdiffstats
path: root/libmpcodecs
diff options
context:
space:
mode:
authorzuxy <zuxy@b3059339-0415-0410-9bf9-f77b7e298cf2>2010-04-20 04:33:00 +0000
committerzuxy <zuxy@b3059339-0415-0410-9bf9-f77b7e298cf2>2010-04-20 04:33:00 +0000
commit6fe158d7e74d7fc6b23da1605be9aa7bbb187859 (patch)
tree2fe136d3b3a4acb5c74e7a9642f474c3a6931f3d /libmpcodecs
parent57b5a5cf652922d167958ce35a4a8c8ccb287e1f (diff)
downloadmpv-6fe158d7e74d7fc6b23da1605be9aa7bbb187859.tar.bz2
mpv-6fe158d7e74d7fc6b23da1605be9aa7bbb187859.tar.xz
Replace memalign(x) (x > 8) by av_malloc() to prevent crashes on systems
lacking memalign(), e.g. Win32. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31045 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpcodecs')
-rw-r--r--libmpcodecs/mp_image.c11
-rw-r--r--libmpcodecs/vd_dmo.c3
-rw-r--r--libmpcodecs/vf.c3
-rw-r--r--libmpcodecs/vf_noise.c7
-rw-r--r--libmpcodecs/vf_screenshot.c6
-rw-r--r--libmpcodecs/vf_unsharp.c8
6 files changed, 21 insertions, 17 deletions
diff --git a/libmpcodecs/mp_image.c b/libmpcodecs/mp_image.c
index e71821129d..898f5fac96 100644
--- a/libmpcodecs/mp_image.c
+++ b/libmpcodecs/mp_image.c
@@ -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 *mpi) {
} 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);
}
diff --git a/libmpcodecs/vd_dmo.c b/libmpcodecs/vd_dmo.c
index 6866aa202b..ffb0844a6e 100644
--- a/libmpcodecs/vd_dmo.c
+++ b/libmpcodecs/vd_dmo.c
@@ -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;
}
diff --git a/libmpcodecs/vf.c b/libmpcodecs/vf.c
index 02b0f1a8b1..0760b09602 100644
--- a/libmpcodecs/vf.c
+++ b/libmpcodecs/vf.c
@@ -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* vf, unsigned int outfmt, int mp_imgtype,
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");
}
diff --git a/libmpcodecs/vf_noise.c b/libmpcodecs/vf_noise.c
index 6cddd0912b..525776ca8f 100644
--- a/libmpcodecs/vf_noise.c
+++ b/libmpcodecs/vf_noise.c
@@ -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 *vf, mp_image_t *mpi, double pts){
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);
diff --git a/libmpcodecs/vf_screenshot.c b/libmpcodecs/vf_screenshot.c
index 5c74d38f86..55ed820b1e 100644
--- a/libmpcodecs/vf_screenshot.c
+++ b/libmpcodecs/vf_screenshot.c
@@ -131,7 +131,7 @@ static void scale_image(struct vf_priv_s* priv, mp_image_t *mpi)
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_instance *vf, mp_image_t *mpi)
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);
}
diff --git a/libmpcodecs/vf_unsharp.c b/libmpcodecs/vf_unsharp.c
index dd0bec03ff..ae5f13654f 100644
--- a/libmpcodecs/vf_unsharp.c
+++ b/libmpcodecs/vf_unsharp.c
@@ -143,7 +143,7 @@ static int config( struct vf_instance *vf,
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 *vf,
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 *vf ) {
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;
}