vf_pp: use option parser

This commit is contained in:
wm4 2013-12-03 23:41:14 +01:00
parent a605fae6fa
commit fabfb23232
3 changed files with 23 additions and 9 deletions

View File

@ -177,7 +177,7 @@ Command Line Switches
``-af volnorm`` ``--af=drc`` (renamed) ``-af volnorm`` ``--af=drc`` (renamed)
``-zoom`` Inverse available as ``--video-unscaled`` ``-zoom`` Inverse available as ``--video-unscaled``
``-panscanrange`` ``--video-zoom``, ``--video-pan-x/y`` ``-panscanrange`` ``--video-zoom``, ``--video-pan-x/y``
``-pp`` ``-vf=pp`` ``-pp`` ``'--vf=[pp]'``
``-pphelp`` ``--vf=pp:help`` ``-pphelp`` ``--vf=pp:help``
=========================== ======================================== =========================== ========================================

View File

@ -241,7 +241,7 @@ Available filters are:
``<fmt>`` ``<fmt>``
Format name, e.g. rgb15, bgr24, 420p, etc. (default: 420p). Format name, e.g. rgb15, bgr24, 420p, etc. (default: 420p).
``pp[=filter1[:option1[:option2...]]/[-]filter2...]`` ``pp[=[filter1[:option1[:option2...]]/[-]filter2...]]``
Enables the specified chain of postprocessing subfilters. Subfilters must Enables the specified chain of postprocessing subfilters. Subfilters must
be separated by '/' and can be disabled by prepending a '-'. Each be separated by '/' and can be disabled by prepending a '-'. Each
subfilter and some options have a short and a long name that can be used subfilter and some options have a short and a long name that can be used
@ -261,6 +261,11 @@ Available filters are:
``--vf=pp:help`` shows a list of available subfilters. ``--vf=pp:help`` shows a list of available subfilters.
.. note::
Unlike in MPlayer or in earlier versions, you must quote the pp string
if it contains ``:`` characters, e.g. ``'--vf=pp=[...]'``.
Available subfilters are: Available subfilters are:
``hb/hdeblock[:difference[:flatness]]`` ``hb/hdeblock[:difference[:flatness]]``
@ -373,10 +378,10 @@ Available filters are:
``--vf=pp=de/-al`` ``--vf=pp=de/-al``
default filters without brightness/contrast correction default filters without brightness/contrast correction
``--vf=pp=default/tmpnoise:1:2:3`` ``--vf=pp=[default/tmpnoise:1:2:3]``
Enable default filters & temporal denoiser. Enable default filters & temporal denoiser.
``--vf=pp=hb:y/vb:a`` ``--vf=pp=[hb:y/vb:a]``
Horizontal deblocking on luminance only, and switch vertical Horizontal deblocking on luminance only, and switch vertical
deblocking on or off automatically depending on available CPU time. deblocking on or off automatically depending on available CPU time.

View File

@ -26,6 +26,7 @@
#include "config.h" #include "config.h"
#include "mpvcore/mp_msg.h" #include "mpvcore/mp_msg.h"
#include "mpvcore/cpudetect.h" #include "mpvcore/cpudetect.h"
#include "mpvcore/m_option.h"
#include "video/img_format.h" #include "video/img_format.h"
#include "video/mp_image.h" #include "video/mp_image.h"
@ -37,6 +38,7 @@ struct vf_priv_s {
pp_mode *ppMode[PP_QUALITY_MAX+1]; pp_mode *ppMode[PP_QUALITY_MAX+1];
void *context; void *context;
unsigned int outfmt; unsigned int outfmt;
char *arg;
}; };
//===========================================================================// //===========================================================================//
@ -132,17 +134,13 @@ static int vf_open(vf_instance_t *vf, char *args){
vf->config=config; vf->config=config;
vf->filter=filter; vf->filter=filter;
vf->uninit=uninit; vf->uninit=uninit;
vf->priv=malloc(sizeof(struct vf_priv_s));
vf->priv->context=NULL;
// check csp: // check csp:
vf->priv->outfmt=vf_match_csp(&vf->next,fmt_list,IMGFMT_420P); vf->priv->outfmt=vf_match_csp(&vf->next,fmt_list,IMGFMT_420P);
if(!vf->priv->outfmt) return 0; // no csp match :( if(!vf->priv->outfmt) return 0; // no csp match :(
char *name = args ? args : "de";
for(i=0; i<=PP_QUALITY_MAX; i++){ for(i=0; i<=PP_QUALITY_MAX; i++){
vf->priv->ppMode[i]= pp_get_mode_by_name_and_quality(name, i); vf->priv->ppMode[i]= pp_get_mode_by_name_and_quality(vf->priv->arg, i);
if(vf->priv->ppMode[i]==NULL) return -1; if(vf->priv->ppMode[i]==NULL) return -1;
} }
@ -153,13 +151,24 @@ static int vf_open(vf_instance_t *vf, char *args){
static void print_help(void) static void print_help(void)
{ {
mp_msg(MSGT_CFGPARSER, MSGL_INFO, "%s", pp_help); mp_msg(MSGT_CFGPARSER, MSGL_INFO, "%s", pp_help);
mp_msg(MSGT_CFGPARSER, MSGL_INFO,
"Don't forget to quote the filter list, e.g.: '--vf=pp=[tn:64:128:256]'\n\n");
} }
#define OPT_BASE_STRUCT struct vf_priv_s
const vf_info_t vf_info_pp = { const vf_info_t vf_info_pp = {
.description = "postprocessing", .description = "postprocessing",
.name = "pp", .name = "pp",
.open = vf_open, .open = vf_open,
.print_help = print_help, .print_help = print_help,
.priv_size = sizeof(struct vf_priv_s),
.priv_defaults = &(const struct vf_priv_s){
.arg = "de",
},
.options = (const struct m_option[]){
OPT_STRING("filters", arg, 0),
{0}
},
}; };
//===========================================================================// //===========================================================================//