59 const char *w_expr,
const char *h_expr,
61 int *ret_w,
int *ret_h)
68 double var_values[
VARS_NB], res;
93 if (!(res >= INT32_MIN && res <= INT32_MAX)) {
98 eval_h = var_values[
VAR_OUT_H] = var_values[
VAR_OH] = (int) res == 0 ? inlink->
h : (int) res;
104 if (!(res >= INT32_MIN && res <= INT32_MAX)) {
108 eval_w = (int) res == 0 ? inlink->
w : (int) res;
117 "Error when evaluating the expression '%s'.\n"
118 "Maybe the expression for out_w:'%s' or for out_h:'%s' is self-referencing.\n",
119 expr, w_expr, h_expr);
124 int *ret_w,
int *ret_h,
125 int force_original_aspect_ratio,
int force_divisible_by,
145 if (
w < 0 &&
h < 0) {
146 w = inlink->
w * w_adj;
154 w =
av_rescale(
h, inlink->
w * w_adj, inlink->
h * factor_w) * factor_w;
156 h =
av_rescale(
w, inlink->
h, inlink->
w * w_adj * factor_h) * factor_h;
164 * force_divisible_by;
166 * force_divisible_by;
171 if (force_divisible_by > 1) {
173 w =
w / force_divisible_by * force_divisible_by;
174 h =
h / force_divisible_by * force_divisible_by;
179 if (force_divisible_by > 1) {
181 w = (
w + force_divisible_by - 1) / force_divisible_by * force_divisible_by;
182 h = (
h + force_divisible_by - 1) / force_divisible_by * force_divisible_by;
190 if (
w <= 0 ||
h <= 0) {
192 "Rescaled dimensions %"PRId64
"x%"PRId64
" are invalid, "
193 "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)
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.