58static int eval_dimension(
void *log_ctx,
const char *expr,
const double *var_values,
59 int in_dimension,
int *out_dimension)
66 if (!(res >= INT32_MIN && res <= INT32_MAX))
69 *out_dimension = (int) res == 0 ? in_dimension : (int) res;
74 const char *w_expr,
const char *h_expr,
76 int *ret_w,
int *ret_h)
83 double var_values[
VARS_NB], res;
104 if ((
ret =
eval_dimension(log_ctx, (expr = h_expr), var_values, inlink->
h, &eval_h)) < 0)
109 if ((
ret =
eval_dimension(log_ctx, (expr = w_expr), var_values, inlink->
w, &eval_w)) < 0)
119 "Error when evaluating the expression '%s'.\n"
120 "Maybe the expression for out_w:'%s' or for out_h:'%s' is self-referencing.\n",
121 expr, w_expr, h_expr);
126 int *ret_w,
int *ret_h,
127 int force_original_aspect_ratio,
int force_divisible_by,
147 if (
w < 0 &&
h < 0) {
148 w = inlink->
w * w_adj;
156 w =
av_rescale(
h, inlink->
w * w_adj, inlink->
h * factor_w) * factor_w;
158 h =
av_rescale(
w, inlink->
h, inlink->
w * w_adj * factor_h) * factor_h;
166 * force_divisible_by;
168 * force_divisible_by;
173 if (force_divisible_by > 1) {
175 w =
w / force_divisible_by * force_divisible_by;
176 h =
h / force_divisible_by * force_divisible_by;
181 if (force_divisible_by > 1) {
183 w = (
w + force_divisible_by - 1) / force_divisible_by * force_divisible_by;
184 h = (
h + force_divisible_by - 1) / force_divisible_by * force_divisible_by;
192 if (
w <= 0 ||
h <= 0) {
194 "Rescaled dimensions %"PRId64
"x%"PRId64
" are invalid, "
195 "output dimensions must be positive.\n",
w,
h);
static __device__ float trunc(float a)
int av_expr_parse_and_eval(double *d, const char *s, const char *const *const_names, const double *const_values, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), void *opaque, int log_offset, void *log_ctx)
Parse and evaluate an expression.
simple arithmetic expression evaluator
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
static const char *const var_names[]
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
static int eval_dimension(void *log_ctx, const char *expr, const double *var_values, int in_dimension, int *out_dimension)
int ff_scale_adjust_dimensions(AVFilterLink *inlink, int *ret_w, int *ret_h, int force_original_aspect_ratio, int force_divisible_by, double w_adj)
Transform evaluated width and height obtained from ff_scale_eval_dimensions into actual target width ...
int ff_scale_eval_dimensions(void *log_ctx, const char *w_expr, const char *h_expr, AVFilterLink *inlink, AVFilterLink *outlink, int *ret_w, int *ret_h)
Parse and evaluate string expressions for width and height.
@ SCALE_FORCE_OAR_DISABLE
@ SCALE_FORCE_OAR_DECREASE
A link between two filters.
int w
agreed upon image width
int h
agreed upon image height
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
AVFilterContext * dst
dest filter
int format
agreed upon media format
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.