mirror of
https://github.com/mpv-player/mpv
synced 2025-01-01 12:22:22 +00:00
vf_unsharp: change options, reroute to vf_lavfi
This commit is contained in:
parent
1acb32201b
commit
b21cb279d7
@ -504,31 +504,23 @@ Available filters are:
|
||||
:0: nearest-neighbor sampling, fast but incorrect
|
||||
:1: linear interpolation (default)
|
||||
|
||||
``unsharp[=l|cWxH:amount[:l|cWxH:amount]]``
|
||||
``unsharp[=lx:ly:la:cx:cy:ca]``
|
||||
unsharp mask / gaussian blur
|
||||
|
||||
``l``
|
||||
Apply effect on luma component.
|
||||
``l`` is for the luma component, ``c`` for the chroma component. ``x``/``y``
|
||||
is the filter size. ``a`` is the amount.
|
||||
|
||||
``c``
|
||||
Apply effect on chroma components.
|
||||
|
||||
``<width>x<height>``
|
||||
``lx``, ``ly``, ``cx``, ``cy``
|
||||
width and height of the matrix, odd sized in both directions (min =
|
||||
3x3, max = 13x11 or 11x13, usually something between 3x3 and 7x7)
|
||||
3:3, max = 13:11 or 11:13, usually something between 3:3 and 7:7)
|
||||
|
||||
``amount``
|
||||
``la``, ``ca``
|
||||
Relative amount of sharpness/blur to add to the image (a sane range
|
||||
should be -1.5-1.5).
|
||||
|
||||
:<0: blur
|
||||
:>0: sharpen
|
||||
|
||||
.. note::
|
||||
|
||||
Deprecated. Use libavfilter's ``unsharp`` filter through ``--vf=lavfi``
|
||||
instead.
|
||||
|
||||
``swapuv``
|
||||
Swap U & V plane.
|
||||
|
||||
|
@ -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) );
|
||||
struct vf_priv_s *p = vf->priv;
|
||||
|
||||
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;
|
||||
}
|
||||
p->lumaParam.msizeX |= 1;
|
||||
p->lumaParam.msizeY |= 1;
|
||||
p->chromaParam.msizeX |= 1;
|
||||
p->chromaParam.msizeY |= 1;
|
||||
|
||||
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
|
||||
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}
|
||||
},
|
||||
};
|
||||
|
||||
//===========================================================================//
|
||||
|
Loading…
Reference in New Issue
Block a user