107 const char *w_expr,
const char *h_expr,
109 int *ret_w,
int *ret_h)
134 var_values[
VAR_A] = (double) inlink->
w / inlink->
h;
159 eval_w = var_values[
VAR_OUT_W] = var_values[
VAR_OW] = (
int) res == 0 ? inlink->
w : (
int) res;
165 eval_h = var_values[
VAR_OUT_H] = var_values[
VAR_OH] = (
int) res == 0 ? inlink->
h : (
int) res;
171 eval_w = (
int) res == 0 ? inlink->
w : (
int) res;
180 "Error when evaluating the expression '%s'.\n" 181 "Maybe the expression for out_w:'%s' or for out_h:'%s' is self-referencing.\n",
182 expr, w_expr, h_expr);
187 int *ret_w,
int *ret_h,
188 int force_original_aspect_ratio,
int force_divisible_by)
191 int factor_w, factor_h;
207 if (w < 0 && h < 0) {
216 w =
av_rescale(h, inlink->
w, inlink->
h * factor_w) * factor_w;
218 h =
av_rescale(w, inlink->
h, inlink->
w * factor_h) * factor_h;
223 if (force_original_aspect_ratio) {
227 if (force_original_aspect_ratio == 1) {
230 if (force_divisible_by > 1) {
232 w = w / force_divisible_by * force_divisible_by;
233 h = h / force_divisible_by * force_divisible_by;
238 if (force_divisible_by > 1) {
240 w = (w + force_divisible_by - 1) / force_divisible_by * force_divisible_by;
241 h = (h + force_divisible_by - 1) / force_divisible_by * force_divisible_by;
int ff_scale_adjust_dimensions(AVFilterLink *inlink, int *ret_w, int *ret_h, int force_original_aspect_ratio, int force_divisible_by)
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.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
int h
agreed upon image height
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
AVFilterLink ** inputs
array of pointers to input links
A link between two filters.
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.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
int w
agreed upon image width
unsigned nb_inputs
number of input pads
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
AVFilterContext * src
source 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...
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
static const char *const var_names[]
static const char *const var_names_scale2ref[]
This must be kept in sync with var_names so that it is always a complete list of var_names with the s...
simple arithmetic expression evaluator