1 /*
2 * Copyright (c) 2002 Michael Niedermayer <michaelni@gmx.at>
3 * Copyright (c) 2011 Stefano Sabatini
4 * Copyright (c) 2018 Danil Iashchenko
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
25
27 "w",
28 "h",
29 "cw",
30 "ch",
31 "hsub",
32 "vsub",
34 };
35
44 };
45
46
51 {
55 int cw, ch;
56 double var_values[
VARS_NB], res;
57 char *expr;
59
63 }
64
65 /* fill missing params */
70 }
71 if (chroma_param->
power < 0)
73
78 }
79 if (alpha_param->
power < 0)
81
88
89 #define EVAL_RADIUS_EXPR(comp) \
90 expr = comp->radius_expr; \
91 ret = av_expr_parse_and_eval(&res, expr, var_names, var_values, \
92 NULL, NULL, NULL, NULL, NULL, 0, ctx); \
93 comp->radius = res; \
94 if (ret < 0) { \
95 av_log(ctx, AV_LOG_ERROR, \
96 "Error when evaluating " #comp " radius expression '%s'\n", expr); \
97 return ret; \
98 }
99
103
105 "luma_radius:%d luma_power:%d "
106 "chroma_radius:%d chroma_power:%d "
107 "alpha_radius:%d alpha_power:%d "
108 "w:%d chroma_w:%d h:%d chroma_h:%d\n",
109 luma_param ->radius, luma_param ->
power,
113
114
115 #define CHECK_RADIUS_VAL(w_, h_, comp) \
116 if (comp->radius < 0 || \
117 2*comp->radius > FFMIN(w_, h_)) { \
118 av_log(ctx, AV_LOG_ERROR, \
119 "Invalid " #comp " radius value %d, must be >= 0 and <= %d\n", \
120 comp->radius, FFMIN(w_, h_)/2); \
121 return AVERROR(EINVAL); \
122 }
126
127 return 0;
128 }