summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-12-03 22:30:07 +0100
committerwm4 <wm4@nowhere>2013-12-04 00:07:39 +0100
commitb21cb279d7aba450faa6629adbc500773ab27f58 (patch)
treeaf67b1ef374c93b671f8dfd9bfae288ac0a187a4 /video
parent1acb32201b813b77bd9f1b52ec665567fade0826 (diff)
downloadmpv-b21cb279d7aba450faa6629adbc500773ab27f58.tar.bz2
mpv-b21cb279d7aba450faa6629adbc500773ab27f58.tar.xz
vf_unsharp: change options, reroute to vf_lavfi
Diffstat (limited to 'video')
-rw-r--r--video/filter/vf_unsharp.c87
1 files changed, 37 insertions, 50 deletions
diff --git a/video/filter/vf_unsharp.c b/video/filter/vf_unsharp.c
index cd65687780..5a81f8c395 100644
--- a/video/filter/vf_unsharp.c
+++ b/video/filter/vf_unsharp.c
@@ -27,6 +27,7 @@
#include "config.h"
#include "mpvcore/mp_msg.h"
#include "mpvcore/cpudetect.h"
+#include "mpvcore/m_option.h"
#include "video/img_format.h"
#include "video/mp_image.h"
@@ -34,6 +35,8 @@
#include "video/memcpy_pic.h"
#include "libavutil/common.h"
+#include "vf_lavfi.h"
+
//===========================================================================//
#define MIN_MATRIX_SIZE 3
@@ -49,6 +52,7 @@ struct vf_priv_s {
FilterParam lumaParam;
FilterParam chromaParam;
unsigned int outfmt;
+ struct vf_lw_opts *lw_opts;
};
@@ -212,32 +216,6 @@ static int query_format( struct vf_instance *vf, unsigned int fmt ) {
return 0;
}
-//===========================================================================//
-
-static void parse( FilterParam *fp, char* args ) {
-
- // l7x5:0.8:c3x3:-0.2
-
- char *z;
- char *pos = args;
- char *max = args + strlen(args);
-
- // parse matrix sizes
- fp->msizeX = ( pos && pos+1<max ) ? atoi( pos+1 ) : 0;
- z = strchr( pos+1, 'x' );
- fp->msizeY = ( z && z+1<max ) ? atoi( pos=z+1 ) : fp->msizeX;
-
- // min/max & odd
- fp->msizeX = 1 | av_clip(fp->msizeX, MIN_MATRIX_SIZE, MAX_MATRIX_SIZE);
- fp->msizeY = 1 | av_clip(fp->msizeY, MIN_MATRIX_SIZE, MAX_MATRIX_SIZE);
-
- // parse amount
- pos = strchr( pos+1, ':' );
- fp->amount = ( pos && pos+1<max ) ? atof( pos+1 ) : 0;
-}
-
-//===========================================================================//
-
static const unsigned int fmt_list[] = {
IMGFMT_420P,
0
@@ -248,30 +226,19 @@ static int vf_open( vf_instance_t *vf, char *args ) {
vf->filter = filter;
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 ) {
- char *args2 = strchr( args, 'l' );
- if( args2 )
- parse( &vf->priv->lumaParam, args2 );
- else {
- vf->priv->lumaParam.amount =
- vf->priv->lumaParam.msizeX =
- vf->priv->lumaParam.msizeY = 0;
- }
-
- args2 = strchr( args, 'c' );
- if( args2 )
- parse( &vf->priv->chromaParam, args2 );
- else {
- vf->priv->chromaParam.amount =
- vf->priv->chromaParam.msizeX =
- vf->priv->chromaParam.msizeY = 0;
- }
-
- if( !vf->priv->lumaParam.msizeX && !vf->priv->chromaParam.msizeX )
- return 0; // nothing to do
+ struct vf_priv_s *p = vf->priv;
+
+ p->lumaParam.msizeX |= 1;
+ p->lumaParam.msizeY |= 1;
+ p->chromaParam.msizeX |= 1;
+ p->chromaParam.msizeY |= 1;
+
+ if (vf_lw_set_graph(vf, p->lw_opts, "unsharp", "%d:%d:%f:%d:%d:%f",
+ p->lumaParam.msizeX, p->lumaParam.msizeY, p->lumaParam.amount,
+ p->chromaParam.msizeX, p->chromaParam.msizeY, p->chromaParam.amount)
+ >= 0)
+ {
+ return 1;
}
// check csp:
@@ -284,10 +251,30 @@ static int vf_open( vf_instance_t *vf, char *args ) {
return 1;
}
+// same as MIN_/MAX_MATRIX_SIZE
+#define MIN_SIZE 3
+#define MAX_SIZE 63
+
+#define OPT_BASE_STRUCT struct vf_priv_s
const vf_info_t vf_info_unsharp = {
.description = "unsharp mask & gaussian blur",
.name = "unsharp",
.open = vf_open,
+ .priv_size = sizeof(struct vf_priv_s),
+ .priv_defaults = &(const struct vf_priv_s){
+ .lumaParam = {5, 5, 1.0},
+ .chromaParam = {5, 5, 0.0},
+ },
+ .options = (const struct m_option[]){
+ OPT_INTRANGE("lx", lumaParam.msizeX, 0, MIN_SIZE, MAX_SIZE),
+ OPT_INTRANGE("ly", lumaParam.msizeY, 0, MIN_SIZE, MAX_SIZE),
+ OPT_DOUBLE("la", lumaParam.amount, CONF_RANGE, .min = -2, .max = 6),
+ OPT_INTRANGE("cx", chromaParam.msizeX, 0, MIN_SIZE, MAX_SIZE),
+ OPT_INTRANGE("cy", chromaParam.msizeY, 0, MIN_SIZE, MAX_SIZE),
+ OPT_DOUBLE("ca", chromaParam.amount, CONF_RANGE, .min = -2, .max = 6),
+ OPT_SUBSTRUCT("", lw_opts, vf_lw_conf, 0),
+ {0}
+ },
};
//===========================================================================//