[MPlayer-cvslog] r20272 - in trunk/libmpcodecs: Makefile vf.c vf_geq.c
michael
subversion at mplayerhq.hu
Mon Oct 16 17:47:32 CEST 2006
Author: michael
Date: Mon Oct 16 17:47:32 2006
New Revision: 20272
Added:
trunk/libmpcodecs/vf_geq.c
- copied, changed from r20265, /trunk/libmpcodecs/vf_qp.c
Modified:
trunk/libmpcodecs/Makefile
trunk/libmpcodecs/vf.c
Log:
generic equation filter
example: -vf 'geq=(p(X\,Y)+p(mod(Y*2-X*2\,W)\,mod(Y*2+X*2+sin((X-Y)/10/SW+N)*SW*20\,H)))/2'
Modified: trunk/libmpcodecs/Makefile
==============================================================================
--- trunk/libmpcodecs/Makefile (original)
+++ trunk/libmpcodecs/Makefile Mon Oct 16 17:47:32 2006
@@ -188,6 +188,7 @@
VFILTER_LAVC_DSPUTIL_SRCS += vf_uspp.c \
vf_fspp.c \
vf_qp.c \
+ vf_geq.c \
vf_spp.c \
vf_mcdeint.c \
Modified: trunk/libmpcodecs/vf.c
==============================================================================
--- trunk/libmpcodecs/vf.c (original)
+++ trunk/libmpcodecs/vf.c Mon Oct 16 17:47:32 2006
@@ -98,6 +98,7 @@
extern vf_info_t vf_info_mcdeint;
extern vf_info_t vf_info_yadif;
extern vf_info_t vf_info_blackframe;
+extern vf_info_t vf_info_geq;
// list of available filters:
static vf_info_t* filter_list[]={
@@ -195,6 +196,9 @@
#endif
&vf_info_yadif,
&vf_info_blackframe,
+#ifdef USE_LIBAVCODEC_DSPUTIL
+ &vf_info_geq,
+#endif
NULL
};
Copied: trunk/libmpcodecs/vf_geq.c (from r20265, /trunk/libmpcodecs/vf_qp.c)
==============================================================================
--- /trunk/libmpcodecs/vf_qp.c (original)
+++ trunk/libmpcodecs/vf_geq.c Mon Oct 16 17:47:32 2006
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2004 Michael Niedermayer <michaelni at gmx.at>
+ Copyright (C) 2006 Michael Niedermayer <michaelni at gmx.at>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -57,40 +57,16 @@
struct vf_priv_s {
- char eq[200];
- int8_t *qp;
- int8_t lut[257];
- int qp_stride;
+ char eq[3][200];
+ int framenum;
+ mp_image_t *mpi;
};
static int config(struct vf_instance_s* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
- int h= (height+15)>>4;
int i;
- vf->priv->qp_stride= (width+15)>>4;
- vf->priv->qp= av_malloc(vf->priv->qp_stride*h*sizeof(int8_t));
-
- for(i=-129; i<128; i++){
- double const_values[]={
- M_PI,
- M_E,
- i != -129,
- i,
- 0
- };
- static const char *const_names[]={
- "PI",
- "E",
- "known",
- "qp",
- NULL
- };
-
- vf->priv->lut[i+129]= lrintf(ff_eval(vf->priv->eq, const_values, const_names, NULL, NULL, NULL, NULL, NULL));
- }
-
return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
}
@@ -111,9 +87,51 @@
mpi->flags|=MP_IMGFLAG_DIRECT;
}
+//FIXME spatial interpolate
+//FIXME keep the last few frames
+static double lum(struct vf_instance_s* vf, double x, double y){
+ mp_image_t *mpi= vf->priv->mpi;
+ x= clip(x, 0, vf->priv->mpi->w-1);
+ y= clip(y, 0, vf->priv->mpi->h-1);
+ return mpi->planes[0][(int)x + (int)y * mpi->stride[0]];
+}
+
+static double cb(struct vf_instance_s* vf, double x, double y){
+ mp_image_t *mpi= vf->priv->mpi;
+ x= clip(x, 0, (vf->priv->mpi->w >> mpi->chroma_x_shift)-1);
+ y= clip(y, 0, (vf->priv->mpi->h >> mpi->chroma_y_shift)-1);
+ return mpi->planes[1][(int)x + (int)y * mpi->stride[1]];
+}
+
+static double cr(struct vf_instance_s* vf, double x, double y){
+ mp_image_t *mpi= vf->priv->mpi;
+ x= clip(x, 0, (vf->priv->mpi->w >> mpi->chroma_x_shift)-1);
+ y= clip(y, 0, (vf->priv->mpi->h >> mpi->chroma_y_shift)-1);
+ return mpi->planes[2][(int)x + (int)y * mpi->stride[2]];
+}
+
static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
mp_image_t *dmpi;
- int x,y;
+ int x,y, plane;
+ static const char *const_names[]={
+ "PI",
+ "E",
+ "X",
+ "Y",
+ "W",
+ "H",
+ "N",
+ "SW",
+ "SH",
+ NULL
+ };
+ static const char *func2_names[]={
+ "lum",
+ "cb",
+ "cr",
+ "p",
+ NULL
+ };
if(!(mpi->flags&MP_IMGFLAG_DIRECT)){
// no DR, so get a new image! hope we'll get DR buffer:
@@ -123,43 +141,51 @@
}
dmpi= vf->dmpi;
-
- if(!(mpi->flags&MP_IMGFLAG_DIRECT)){
- memcpy_pic(dmpi->planes[0], mpi->planes[0], mpi->w, mpi->h, dmpi->stride[0], mpi->stride[0]);
- if(mpi->flags&MP_IMGFLAG_PLANAR){
- memcpy_pic(dmpi->planes[1], mpi->planes[1], mpi->w>>mpi->chroma_x_shift, mpi->h>>mpi->chroma_y_shift, dmpi->stride[1], mpi->stride[1]);
- memcpy_pic(dmpi->planes[2], mpi->planes[2], mpi->w>>mpi->chroma_x_shift, mpi->h>>mpi->chroma_y_shift, dmpi->stride[2], mpi->stride[2]);
- }
- }
+ vf->priv->mpi= mpi;
+
vf_clone_mpi_attributes(dmpi, mpi);
-
- dmpi->qscale = vf->priv->qp;
- dmpi->qstride= vf->priv->qp_stride;
- if(mpi->qscale){
- for(y=0; y<((dmpi->h+15)>>4); y++){
- for(x=0; x<vf->priv->qp_stride; x++){
- dmpi->qscale[x + dmpi->qstride*y]=
- vf->priv->lut[ 129 + ((int8_t)mpi->qscale[x + mpi->qstride*y]) ];
- }
- }
- }else{
- int qp= vf->priv->lut[0];
- for(y=0; y<((dmpi->h+15)>>4); y++){
- for(x=0; x<vf->priv->qp_stride; x++){
- dmpi->qscale[x + dmpi->qstride*y]= qp;
+
+ for(plane=0; plane<3; plane++){
+ int w= mpi->w >> (plane ? mpi->chroma_x_shift : 0);
+ int h= mpi->h >> (plane ? mpi->chroma_y_shift : 0);
+ uint8_t *dst = dmpi->planes[plane];
+ int dst_stride= dmpi->stride[plane];
+ double (*func2[])(void *, double, double)={
+ lum,
+ cb,
+ cr,
+ plane==0 ? lum : (plane==1 ? cb : cr),
+ NULL
+ };
+ double const_values[]={
+ M_PI,
+ M_E,
+ 0,
+ 0,
+ w,
+ h,
+ vf->priv->framenum,
+ w/(double)mpi->w,
+ h/(double)mpi->h,
+ 0
+ };
+ for(y=0; y<h; y++){
+ const_values[3]=y;
+ for(x=0; x<w; x++){
+ const_values[2]=x;
+ dst[x+y* dst_stride]= ff_eval(vf->priv->eq[plane], const_values, const_names, NULL, NULL, func2, func2_names, vf);
}
}
}
+ vf->priv->framenum++;
+
return vf_next_put_image(vf,dmpi, pts);
}
static void uninit(struct vf_instance_s* vf){
if(!vf->priv) return;
- if(vf->priv->qp) av_free(vf->priv->qp);
- vf->priv->qp= NULL;
-
av_free(vf->priv);
vf->priv=NULL;
}
@@ -168,21 +194,22 @@
static int open(vf_instance_t *vf, char* args){
vf->config=config;
vf->put_image=put_image;
- vf->get_image=get_image;
+// vf->get_image=get_image;
vf->uninit=uninit;
vf->priv=av_malloc(sizeof(struct vf_priv_s));
memset(vf->priv, 0, sizeof(struct vf_priv_s));
-
-// avcodec_init();
- if (args) strncpy(vf->priv->eq, args, 199);
-
+ if (args) sscanf(args, "%199s:%199s:%199s", vf->priv->eq[0], vf->priv->eq[1], vf->priv->eq[2]);
+
+ if(!vf->priv->eq[1][0]) strncpy(vf->priv->eq[1], vf->priv->eq[0], 199);
+ if(!vf->priv->eq[2][0]) strncpy(vf->priv->eq[2], vf->priv->eq[1], 199);
+
return 1;
}
-vf_info_t vf_info_qp = {
- "QP changer",
- "qp",
+vf_info_t vf_info_geq = {
+ "generic equation filter",
+ "geq",
"Michael Niedermayer",
"",
open,
More information about the MPlayer-cvslog
mailing list