2002-10-29 22:37:11 +00:00
|
|
|
/*
|
2008-05-13 10:16:20 +00:00
|
|
|
* Copyright (C) 2002 Remi Guyomarch <rguyom@pobox.com>
|
|
|
|
*
|
|
|
|
* This file is part of MPlayer.
|
|
|
|
*
|
|
|
|
* MPlayer is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* MPlayer is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2002-10-29 22:37:11 +00:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2013-12-17 01:39:45 +00:00
|
|
|
#include "common/msg.h"
|
2013-12-17 01:02:25 +00:00
|
|
|
#include "options/m_option.h"
|
2002-10-29 22:37:11 +00:00
|
|
|
|
|
|
|
#include "vf.h"
|
|
|
|
|
2013-12-03 21:30:07 +00:00
|
|
|
#include "vf_lavfi.h"
|
|
|
|
|
2002-10-29 22:37:11 +00:00
|
|
|
typedef struct FilterParam {
|
|
|
|
int msizeX, msizeY;
|
|
|
|
double amount;
|
|
|
|
} FilterParam;
|
|
|
|
|
|
|
|
struct vf_priv_s {
|
|
|
|
FilterParam lumaParam;
|
|
|
|
FilterParam chromaParam;
|
2013-12-03 21:30:07 +00:00
|
|
|
struct vf_lw_opts *lw_opts;
|
2002-10-29 22:37:11 +00:00
|
|
|
};
|
|
|
|
|
2014-03-16 09:39:11 +00:00
|
|
|
static int vf_open(vf_instance_t *vf)
|
video/filter: change filter API, use refcounting, remove filter DR
Change the entire filter API to use reference counted images instead
of vf_get_image().
Remove filter "direct rendering". This was useful for vf_expand and (in
rare cases) vf_sub: DR allowed these filters to pass a cropped image to
the filters before them. Then, on filtering, the image was "uncropped",
so that black bars could be added around the image without copying. This
means that in some cases, vf_expand will be slower (-vf gradfun,expand
for example).
Note that another form of DR used for in-place filters has been replaced
by simpler logic. Instead of trying to do DR, filters can check if the
image is writeable (with mp_image_is_writeable()), and do true in-place
if that's the case. This affects filters like vf_gradfun and vf_sub.
Everything has to support strides now. If something doesn't, making a
copy of the image data is required.
2012-11-05 13:25:04 +00:00
|
|
|
{
|
2013-12-03 21:30:07 +00:00
|
|
|
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;
|
2002-10-29 22:37:11 +00:00
|
|
|
}
|
|
|
|
|
2014-03-16 09:39:11 +00:00
|
|
|
MP_FATAL(vf, "Requires libavfilter.\n");
|
|
|
|
return 0;
|
2002-10-29 22:37:11 +00:00
|
|
|
}
|
|
|
|
|
2013-12-03 21:30:07 +00:00
|
|
|
// same as MIN_/MAX_MATRIX_SIZE
|
|
|
|
#define MIN_SIZE 3
|
|
|
|
#define MAX_SIZE 63
|
|
|
|
|
|
|
|
#define OPT_BASE_STRUCT struct vf_priv_s
|
2007-12-02 14:57:15 +00:00
|
|
|
const vf_info_t vf_info_unsharp = {
|
2013-10-23 17:06:42 +00:00
|
|
|
.description = "unsharp mask & gaussian blur",
|
|
|
|
.name = "unsharp",
|
|
|
|
.open = vf_open,
|
2013-12-03 21:30:07 +00:00
|
|
|
.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}
|
|
|
|
},
|
2002-10-29 22:37:11 +00:00
|
|
|
};
|