1
mirror of https://github.com/mpv-player/mpv synced 2025-01-01 04:36:24 +01:00

direct rendering (hopefully at least, TFM for the video filters is a bit nonexistent or iam just too stupid) ;)

uninit


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@6448 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
michael 2002-06-16 13:45:52 +00:00
parent d25b34b971
commit 73510c3d0b

View File

@ -55,6 +55,8 @@ typedef struct FilterParam{
struct vf_priv_s {
FilterParam lumaParam;
FilterParam chromaParam;
mp_image_t *dmpi;
unsigned int outfmt;
};
static int nonTempRandShift[MAX_RES]= {-1};
@ -62,7 +64,7 @@ static int nonTempRandShift[MAX_RES]= {-1};
static int8_t *initNoise(FilterParam *fp){
int strength= fp->strength;
int uniform= fp->uniform;
int8_t *noise= memalign(16, MAX_NOISE*sizeof(int8_t)); //FIXME deallocate
int8_t *noise= memalign(16, MAX_NOISE*sizeof(int8_t));
int i;
srand(123457);
@ -178,6 +180,8 @@ static void noise(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int
if(!noise)
{
if(src==dst) return;
if(dstStride==srcStride) memcpy(dst, src, srcStride*height);
else
{
@ -209,13 +213,37 @@ static int config(struct vf_instance_s* vf,
return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
}
static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
if(mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change
if(!(mpi->flags&MP_IMGFLAG_ACCEPT_STRIDE) && mpi->imgfmt!=vf->priv->outfmt)
return; // colorspace differ
// ok, we can do pp in-place (or pp disabled):
vf->priv->dmpi=vf_get_image(vf->next,mpi->imgfmt,
mpi->type, mpi->flags, mpi->w, mpi->h);
mpi->planes[0]=vf->priv->dmpi->planes[0];
mpi->stride[0]=vf->priv->dmpi->stride[0];
mpi->width=vf->priv->dmpi->width;
if(mpi->flags&MP_IMGFLAG_PLANAR){
mpi->planes[1]=vf->priv->dmpi->planes[1];
mpi->planes[2]=vf->priv->dmpi->planes[2];
mpi->stride[1]=vf->priv->dmpi->stride[1];
mpi->stride[2]=vf->priv->dmpi->stride[2];
}
mpi->flags|=MP_IMGFLAG_DIRECT;
}
static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
mp_image_t *dmpi;
// hope we'll get DR buffer:
dmpi=vf_get_image(vf->next,mpi->imgfmt,
if(!(mpi->flags&MP_IMGFLAG_DIRECT)){
// no DR, so get a new image! hope we'll get DR buffer:
vf->priv->dmpi=vf_get_image(vf->next,vf->priv->outfmt,
MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
mpi->w, mpi->h);
mpi->w,mpi->h);
//printf("nodr\n");
}
//else printf("dr\n");
dmpi= vf->priv->dmpi;
noise(dmpi->planes[0], mpi->planes[0], dmpi->stride[0], mpi->stride[0], mpi->w, mpi->h, &vf->priv->lumaParam);
noise(dmpi->planes[1], mpi->planes[1], dmpi->stride[1], mpi->stride[1], mpi->w/2, mpi->h/2, &vf->priv->chromaParam);
@ -234,6 +262,19 @@ static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
vf_next_put_image(vf,dmpi);
}
static void uninit(struct vf_instance_s* vf){
if(!vf->priv) return;
if(vf->priv->chromaParam.noise) free(vf->priv->chromaParam.noise);
vf->priv->chromaParam.noise= NULL;
if(vf->priv->lumaParam.noise) free(vf->priv->lumaParam.noise);
vf->priv->lumaParam.noise= NULL;
free(vf->priv);
vf->priv=NULL;
}
//===========================================================================//
static int query_format(struct vf_instance_s* vf, unsigned int fmt){
@ -242,7 +283,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt){
case IMGFMT_YV12:
case IMGFMT_I420:
case IMGFMT_IYUV:
return vf_next_query_format(vf,fmt);
return vf_next_query_format(vf,vf->priv->outfmt);
}
return 0;
}
@ -262,10 +303,19 @@ static void parse(FilterParam *fp, char* args){
if(fp->strength) initNoise(fp);
}
static unsigned int fmt_list[]={
IMGFMT_YV12,
IMGFMT_I420,
IMGFMT_IYUV,
0
};
static int open(vf_instance_t *vf, char* args){
vf->config=config;
vf->put_image=put_image;
vf->get_image=get_image;
vf->query_format=query_format;
vf->uninit=uninit;
vf->priv=malloc(sizeof(struct vf_priv_s));
memset(vf->priv, 0, sizeof(struct vf_priv_s));
if(args)
@ -274,6 +324,15 @@ static int open(vf_instance_t *vf, char* args){
if(arg2) parse(&vf->priv->chromaParam, arg2+1);
parse(&vf->priv->lumaParam, args);
}
// check csp:
vf->priv->outfmt=vf_match_csp(&vf->next,fmt_list,IMGFMT_YV12);
if(!vf->priv->outfmt)
{
uninit(vf);
return 0; // no csp match :(
}
#ifdef HAVE_MMX
if(gCpuCaps.hasMMX) lineNoise= lineNoise_MMX;