From e73688eff43727eb79eb344a4def49540d463902 Mon Sep 17 00:00:00 2001 From: Gyan Doshi Date: Sun, 8 Dec 2019 16:42:36 +0530 Subject: avfilter: rename scale.c,h to scale_eval scale.c is too generic; scale_eval is more representative --- libavfilter/Makefile | 10 +- libavfilter/scale.c | 250 ------------------------------------------- libavfilter/scale.h | 48 --------- libavfilter/scale_eval.c | 250 +++++++++++++++++++++++++++++++++++++++++++ libavfilter/scale_eval.h | 48 +++++++++ libavfilter/vf_scale.c | 2 +- libavfilter/vf_scale_cuda.c | 2 +- libavfilter/vf_scale_npp.c | 2 +- libavfilter/vf_scale_vaapi.c | 2 +- 9 files changed, 307 insertions(+), 307 deletions(-) delete mode 100644 libavfilter/scale.c delete mode 100644 libavfilter/scale.h create mode 100644 libavfilter/scale_eval.c create mode 100644 libavfilter/scale_eval.h diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 52f3616b2f..446c802b98 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -359,12 +359,12 @@ OBJS-$(CONFIG_ROBERTS_OPENCL_FILTER) += vf_convolution_opencl.o opencl.o opencl/convolution.o OBJS-$(CONFIG_ROTATE_FILTER) += vf_rotate.o OBJS-$(CONFIG_SAB_FILTER) += vf_sab.o -OBJS-$(CONFIG_SCALE_FILTER) += vf_scale.o scale.o -OBJS-$(CONFIG_SCALE_CUDA_FILTER) += vf_scale_cuda.o vf_scale_cuda.ptx.o scale.o -OBJS-$(CONFIG_SCALE_NPP_FILTER) += vf_scale_npp.o scale.o +OBJS-$(CONFIG_SCALE_FILTER) += vf_scale.o scale_eval.o +OBJS-$(CONFIG_SCALE_CUDA_FILTER) += vf_scale_cuda.o vf_scale_cuda.ptx.o scale_eval.o +OBJS-$(CONFIG_SCALE_NPP_FILTER) += vf_scale_npp.o scale_eval.o OBJS-$(CONFIG_SCALE_QSV_FILTER) += vf_scale_qsv.o -OBJS-$(CONFIG_SCALE_VAAPI_FILTER) += vf_scale_vaapi.o scale.o vaapi_vpp.o -OBJS-$(CONFIG_SCALE2REF_FILTER) += vf_scale.o scale.o +OBJS-$(CONFIG_SCALE_VAAPI_FILTER) += vf_scale_vaapi.o scale_eval.o vaapi_vpp.o +OBJS-$(CONFIG_SCALE2REF_FILTER) += vf_scale.o scale_eval.o OBJS-$(CONFIG_SCROLL_FILTER) += vf_scroll.o OBJS-$(CONFIG_SELECT_FILTER) += f_select.o OBJS-$(CONFIG_SELECTIVECOLOR_FILTER) += vf_selectivecolor.o diff --git a/libavfilter/scale.c b/libavfilter/scale.c deleted file mode 100644 index 4f00c5c72e..0000000000 --- a/libavfilter/scale.c +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Copyright (c) 2007 Bobby Bingham - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include "scale.h" -#include "libavutil/eval.h" -#include "libavutil/mathematics.h" -#include "libavutil/pixdesc.h" - -static const char *const var_names[] = { - "PI", - "PHI", - "E", - "in_w", "iw", - "in_h", "ih", - "out_w", "ow", - "out_h", "oh", - "a", - "sar", - "dar", - "hsub", - "vsub", - "ohsub", - "ovsub", - NULL -}; - -enum var_name { - VAR_PI, - VAR_PHI, - VAR_E, - VAR_IN_W, VAR_IW, - VAR_IN_H, VAR_IH, - VAR_OUT_W, VAR_OW, - VAR_OUT_H, VAR_OH, - VAR_A, - VAR_SAR, - VAR_DAR, - VAR_HSUB, - VAR_VSUB, - VAR_OHSUB, - VAR_OVSUB, - VARS_NB -}; - -/** - * This must be kept in sync with var_names so that it is always a - * complete list of var_names with the scale2ref specific names - * appended. scale2ref values must appear in the order they appear - * in the var_name_scale2ref enum but also be below all of the - * non-scale2ref specific values. - */ -static const char *const var_names_scale2ref[] = { - "PI", - "PHI", - "E", - "in_w", "iw", - "in_h", "ih", - "out_w", "ow", - "out_h", "oh", - "a", - "sar", - "dar", - "hsub", - "vsub", - "ohsub", - "ovsub", - "main_w", - "main_h", - "main_a", - "main_sar", - "main_dar", "mdar", - "main_hsub", - "main_vsub", - NULL -}; - -enum var_name_scale2ref { - VAR_S2R_MAIN_W, - VAR_S2R_MAIN_H, - VAR_S2R_MAIN_A, - VAR_S2R_MAIN_SAR, - VAR_S2R_MAIN_DAR, VAR_S2R_MDAR, - VAR_S2R_MAIN_HSUB, - VAR_S2R_MAIN_VSUB, - VARS_S2R_NB -}; - -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) -{ - const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); - const AVPixFmtDescriptor *out_desc = av_pix_fmt_desc_get(outlink->format); - const char *expr; - int eval_w, eval_h; - int ret; - const char scale2ref = outlink->src->nb_inputs == 2 && outlink->src->inputs[1] == inlink; - double var_values[VARS_NB + VARS_S2R_NB], res; - const AVPixFmtDescriptor *main_desc; - const AVFilterLink *main_link; - const char *const *names = scale2ref ? var_names_scale2ref : var_names; - - if (scale2ref) { - main_link = outlink->src->inputs[0]; - main_desc = av_pix_fmt_desc_get(main_link->format); - } - - var_values[VAR_PI] = M_PI; - var_values[VAR_PHI] = M_PHI; - var_values[VAR_E] = M_E; - var_values[VAR_IN_W] = var_values[VAR_IW] = inlink->w; - var_values[VAR_IN_H] = var_values[VAR_IH] = inlink->h; - var_values[VAR_OUT_W] = var_values[VAR_OW] = NAN; - var_values[VAR_OUT_H] = var_values[VAR_OH] = NAN; - var_values[VAR_A] = (double) inlink->w / inlink->h; - var_values[VAR_SAR] = inlink->sample_aspect_ratio.num ? - (double) inlink->sample_aspect_ratio.num / inlink->sample_aspect_ratio.den : 1; - var_values[VAR_DAR] = var_values[VAR_A] * var_values[VAR_SAR]; - var_values[VAR_HSUB] = 1 << desc->log2_chroma_w; - var_values[VAR_VSUB] = 1 << desc->log2_chroma_h; - var_values[VAR_OHSUB] = 1 << out_desc->log2_chroma_w; - var_values[VAR_OVSUB] = 1 << out_desc->log2_chroma_h; - - if (scale2ref) { - var_values[VARS_NB + VAR_S2R_MAIN_W] = main_link->w; - var_values[VARS_NB + VAR_S2R_MAIN_H] = main_link->h; - var_values[VARS_NB + VAR_S2R_MAIN_A] = (double) main_link->w / main_link->h; - var_values[VARS_NB + VAR_S2R_MAIN_SAR] = main_link->sample_aspect_ratio.num ? - (double) main_link->sample_aspect_ratio.num / main_link->sample_aspect_ratio.den : 1; - var_values[VARS_NB + VAR_S2R_MAIN_DAR] = var_values[VARS_NB + VAR_S2R_MDAR] = - var_values[VARS_NB + VAR_S2R_MAIN_A] * var_values[VARS_NB + VAR_S2R_MAIN_SAR]; - var_values[VARS_NB + VAR_S2R_MAIN_HSUB] = 1 << main_desc->log2_chroma_w; - var_values[VARS_NB + VAR_S2R_MAIN_VSUB] = 1 << main_desc->log2_chroma_h; - } - - /* evaluate width and height */ - av_expr_parse_and_eval(&res, (expr = w_expr), - names, var_values, - NULL, NULL, NULL, NULL, NULL, 0, log_ctx); - eval_w = var_values[VAR_OUT_W] = var_values[VAR_OW] = (int) res == 0 ? inlink->w : (int) res; - - if ((ret = av_expr_parse_and_eval(&res, (expr = h_expr), - names, var_values, - NULL, NULL, NULL, NULL, NULL, 0, log_ctx)) < 0) - goto fail; - eval_h = var_values[VAR_OUT_H] = var_values[VAR_OH] = (int) res == 0 ? inlink->h : (int) res; - /* evaluate again the width, as it may depend on the output height */ - if ((ret = av_expr_parse_and_eval(&res, (expr = w_expr), - names, var_values, - NULL, NULL, NULL, NULL, NULL, 0, log_ctx)) < 0) - goto fail; - eval_w = (int) res == 0 ? inlink->w : (int) res; - - *ret_w = eval_w; - *ret_h = eval_h; - - return 0; - -fail: - av_log(log_ctx, AV_LOG_ERROR, - "Error when evaluating the expression '%s'.\n" - "Maybe the expression for out_w:'%s' or for out_h:'%s' is self-referencing.\n", - expr, w_expr, h_expr); - return ret; -} - -int ff_scale_adjust_dimensions(AVFilterLink *inlink, - int *ret_w, int *ret_h, - int force_original_aspect_ratio, int force_divisible_by) -{ - int w, h; - int factor_w, factor_h; - - w = *ret_w; - h = *ret_h; - - /* Check if it is requested that the result has to be divisible by some - * factor (w or h = -n with n being the factor). */ - factor_w = 1; - factor_h = 1; - if (w < -1) { - factor_w = -w; - } - if (h < -1) { - factor_h = -h; - } - - if (w < 0 && h < 0) { - w = inlink->w; - h = inlink->h; - } - - /* Make sure that the result is divisible by the factor we determined - * earlier. If no factor was set, nothing will happen as the default - * factor is 1 */ - if (w < 0) - w = av_rescale(h, inlink->w, inlink->h * factor_w) * factor_w; - if (h < 0) - h = av_rescale(w, inlink->h, inlink->w * factor_h) * factor_h; - - /* Note that force_original_aspect_ratio may overwrite the previous set - * dimensions so that it is not divisible by the set factors anymore - * unless force_divisible_by is defined as well */ - if (force_original_aspect_ratio) { - int tmp_w = av_rescale(h, inlink->w, inlink->h); - int tmp_h = av_rescale(w, inlink->h, inlink->w); - - if (force_original_aspect_ratio == 1) { - w = FFMIN(tmp_w, w); - h = FFMIN(tmp_h, h); - if (force_divisible_by > 1) { - // round down - w = w / force_divisible_by * force_divisible_by; - h = h / force_divisible_by * force_divisible_by; - } - } else { - w = FFMAX(tmp_w, w); - h = FFMAX(tmp_h, h); - if (force_divisible_by > 1) { - // round up - w = (w + force_divisible_by - 1) / force_divisible_by * force_divisible_by; - h = (h + force_divisible_by - 1) / force_divisible_by * force_divisible_by; - } - } - } - - *ret_w = w; - *ret_h = h; - - return 0; -} diff --git a/libavfilter/scale.h b/libavfilter/scale.h deleted file mode 100644 index 6e1c8a1f4c..0000000000 --- a/libavfilter/scale.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVFILTER_SCALE_H -#define AVFILTER_SCALE_H - -#include "avfilter.h" - -/** - * Parse and evaluate string expressions for width and height. Upon success, - * ff_scale_adjust_dimensions must be called with evaluated width and height - * to obtain actual target dimensions. - * - * Returns 0 upon success, negative value if one of the expressions could - * not be parsed or if NaN was the result of their evaluation. - */ -int ff_scale_eval_dimensions(void *ctx, - const char *w_expr, const char *h_expr, - AVFilterLink *inlink, AVFilterLink *outlink, - int *ret_w, int *ret_h); - -/** - * Transform evaluated width and height obtained from ff_scale_eval_dimensions - * into actual target width and height for scaling. Adjustment can occur if one - * or both of the evaluated values are of the form '-n' or if - * force_original_aspect_ratio is set. - * - * Returns 0. - */ -int ff_scale_adjust_dimensions(AVFilterLink *inlink, - int *ret_w, int *ret_h, - int force_original_aspect_ratio, int force_divisible_by); -#endif diff --git a/libavfilter/scale_eval.c b/libavfilter/scale_eval.c new file mode 100644 index 0000000000..a3439a95e0 --- /dev/null +++ b/libavfilter/scale_eval.c @@ -0,0 +1,250 @@ +/* + * Copyright (c) 2007 Bobby Bingham + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include "scale_eval.h" +#include "libavutil/eval.h" +#include "libavutil/mathematics.h" +#include "libavutil/pixdesc.h" + +static const char *const var_names[] = { + "PI", + "PHI", + "E", + "in_w", "iw", + "in_h", "ih", + "out_w", "ow", + "out_h", "oh", + "a", + "sar", + "dar", + "hsub", + "vsub", + "ohsub", + "ovsub", + NULL +}; + +enum var_name { + VAR_PI, + VAR_PHI, + VAR_E, + VAR_IN_W, VAR_IW, + VAR_IN_H, VAR_IH, + VAR_OUT_W, VAR_OW, + VAR_OUT_H, VAR_OH, + VAR_A, + VAR_SAR, + VAR_DAR, + VAR_HSUB, + VAR_VSUB, + VAR_OHSUB, + VAR_OVSUB, + VARS_NB +}; + +/** + * This must be kept in sync with var_names so that it is always a + * complete list of var_names with the scale2ref specific names + * appended. scale2ref values must appear in the order they appear + * in the var_name_scale2ref enum but also be below all of the + * non-scale2ref specific values. + */ +static const char *const var_names_scale2ref[] = { + "PI", + "PHI", + "E", + "in_w", "iw", + "in_h", "ih", + "out_w", "ow", + "out_h", "oh", + "a", + "sar", + "dar", + "hsub", + "vsub", + "ohsub", + "ovsub", + "main_w", + "main_h", + "main_a", + "main_sar", + "main_dar", "mdar", + "main_hsub", + "main_vsub", + NULL +}; + +enum var_name_scale2ref { + VAR_S2R_MAIN_W, + VAR_S2R_MAIN_H, + VAR_S2R_MAIN_A, + VAR_S2R_MAIN_SAR, + VAR_S2R_MAIN_DAR, VAR_S2R_MDAR, + VAR_S2R_MAIN_HSUB, + VAR_S2R_MAIN_VSUB, + VARS_S2R_NB +}; + +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) +{ + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); + const AVPixFmtDescriptor *out_desc = av_pix_fmt_desc_get(outlink->format); + const char *expr; + int eval_w, eval_h; + int ret; + const char scale2ref = outlink->src->nb_inputs == 2 && outlink->src->inputs[1] == inlink; + double var_values[VARS_NB + VARS_S2R_NB], res; + const AVPixFmtDescriptor *main_desc; + const AVFilterLink *main_link; + const char *const *names = scale2ref ? var_names_scale2ref : var_names; + + if (scale2ref) { + main_link = outlink->src->inputs[0]; + main_desc = av_pix_fmt_desc_get(main_link->format); + } + + var_values[VAR_PI] = M_PI; + var_values[VAR_PHI] = M_PHI; + var_values[VAR_E] = M_E; + var_values[VAR_IN_W] = var_values[VAR_IW] = inlink->w; + var_values[VAR_IN_H] = var_values[VAR_IH] = inlink->h; + var_values[VAR_OUT_W] = var_values[VAR_OW] = NAN; + var_values[VAR_OUT_H] = var_values[VAR_OH] = NAN; + var_values[VAR_A] = (double) inlink->w / inlink->h; + var_values[VAR_SAR] = inlink->sample_aspect_ratio.num ? + (double) inlink->sample_aspect_ratio.num / inlink->sample_aspect_ratio.den : 1; + var_values[VAR_DAR] = var_values[VAR_A] * var_values[VAR_SAR]; + var_values[VAR_HSUB] = 1 << desc->log2_chroma_w; + var_values[VAR_VSUB] = 1 << desc->log2_chroma_h; + var_values[VAR_OHSUB] = 1 << out_desc->log2_chroma_w; + var_values[VAR_OVSUB] = 1 << out_desc->log2_chroma_h; + + if (scale2ref) { + var_values[VARS_NB + VAR_S2R_MAIN_W] = main_link->w; + var_values[VARS_NB + VAR_S2R_MAIN_H] = main_link->h; + var_values[VARS_NB + VAR_S2R_MAIN_A] = (double) main_link->w / main_link->h; + var_values[VARS_NB + VAR_S2R_MAIN_SAR] = main_link->sample_aspect_ratio.num ? + (double) main_link->sample_aspect_ratio.num / main_link->sample_aspect_ratio.den : 1; + var_values[VARS_NB + VAR_S2R_MAIN_DAR] = var_values[VARS_NB + VAR_S2R_MDAR] = + var_values[VARS_NB + VAR_S2R_MAIN_A] * var_values[VARS_NB + VAR_S2R_MAIN_SAR]; + var_values[VARS_NB + VAR_S2R_MAIN_HSUB] = 1 << main_desc->log2_chroma_w; + var_values[VARS_NB + VAR_S2R_MAIN_VSUB] = 1 << main_desc->log2_chroma_h; + } + + /* evaluate width and height */ + av_expr_parse_and_eval(&res, (expr = w_expr), + names, var_values, + NULL, NULL, NULL, NULL, NULL, 0, log_ctx); + eval_w = var_values[VAR_OUT_W] = var_values[VAR_OW] = (int) res == 0 ? inlink->w : (int) res; + + if ((ret = av_expr_parse_and_eval(&res, (expr = h_expr), + names, var_values, + NULL, NULL, NULL, NULL, NULL, 0, log_ctx)) < 0) + goto fail; + eval_h = var_values[VAR_OUT_H] = var_values[VAR_OH] = (int) res == 0 ? inlink->h : (int) res; + /* evaluate again the width, as it may depend on the output height */ + if ((ret = av_expr_parse_and_eval(&res, (expr = w_expr), + names, var_values, + NULL, NULL, NULL, NULL, NULL, 0, log_ctx)) < 0) + goto fail; + eval_w = (int) res == 0 ? inlink->w : (int) res; + + *ret_w = eval_w; + *ret_h = eval_h; + + return 0; + +fail: + av_log(log_ctx, AV_LOG_ERROR, + "Error when evaluating the expression '%s'.\n" + "Maybe the expression for out_w:'%s' or for out_h:'%s' is self-referencing.\n", + expr, w_expr, h_expr); + return ret; +} + +int ff_scale_adjust_dimensions(AVFilterLink *inlink, + int *ret_w, int *ret_h, + int force_original_aspect_ratio, int force_divisible_by) +{ + int w, h; + int factor_w, factor_h; + + w = *ret_w; + h = *ret_h; + + /* Check if it is requested that the result has to be divisible by some + * factor (w or h = -n with n being the factor). */ + factor_w = 1; + factor_h = 1; + if (w < -1) { + factor_w = -w; + } + if (h < -1) { + factor_h = -h; + } + + if (w < 0 && h < 0) { + w = inlink->w; + h = inlink->h; + } + + /* Make sure that the result is divisible by the factor we determined + * earlier. If no factor was set, nothing will happen as the default + * factor is 1 */ + if (w < 0) + w = av_rescale(h, inlink->w, inlink->h * factor_w) * factor_w; + if (h < 0) + h = av_rescale(w, inlink->h, inlink->w * factor_h) * factor_h; + + /* Note that force_original_aspect_ratio may overwrite the previous set + * dimensions so that it is not divisible by the set factors anymore + * unless force_divisible_by is defined as well */ + if (force_original_aspect_ratio) { + int tmp_w = av_rescale(h, inlink->w, inlink->h); + int tmp_h = av_rescale(w, inlink->h, inlink->w); + + if (force_original_aspect_ratio == 1) { + w = FFMIN(tmp_w, w); + h = FFMIN(tmp_h, h); + if (force_divisible_by > 1) { + // round down + w = w / force_divisible_by * force_divisible_by; + h = h / force_divisible_by * force_divisible_by; + } + } else { + w = FFMAX(tmp_w, w); + h = FFMAX(tmp_h, h); + if (force_divisible_by > 1) { + // round up + w = (w + force_divisible_by - 1) / force_divisible_by * force_divisible_by; + h = (h + force_divisible_by - 1) / force_divisible_by * force_divisible_by; + } + } + } + + *ret_w = w; + *ret_h = h; + + return 0; +} diff --git a/libavfilter/scale_eval.h b/libavfilter/scale_eval.h new file mode 100644 index 0000000000..fceb023fec --- /dev/null +++ b/libavfilter/scale_eval.h @@ -0,0 +1,48 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVFILTER_SCALE_EVAL_H +#define AVFILTER_SCALE_EVAL_H + +#include "avfilter.h" + +/** + * Parse and evaluate string expressions for width and height. Upon success, + * ff_scale_adjust_dimensions must be called with evaluated width and height + * to obtain actual target dimensions. + * + * Returns 0 upon success, negative value if one of the expressions could + * not be parsed or if NaN was the result of their evaluation. + */ +int ff_scale_eval_dimensions(void *ctx, + const char *w_expr, const char *h_expr, + AVFilterLink *inlink, AVFilterLink *outlink, + int *ret_w, int *ret_h); + +/** + * Transform evaluated width and height obtained from ff_scale_eval_dimensions + * into actual target width and height for scaling. Adjustment can occur if one + * or both of the evaluated values are of the form '-n' or if + * force_original_aspect_ratio is set. + * + * Returns 0. + */ +int ff_scale_adjust_dimensions(AVFilterLink *inlink, + int *ret_w, int *ret_h, + int force_original_aspect_ratio, int force_divisible_by); +#endif diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index b7f541be1f..8620d1c44e 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -29,7 +29,7 @@ #include "avfilter.h" #include "formats.h" #include "internal.h" -#include "scale.h" +#include "scale_eval.h" #include "video.h" #include "libavutil/avstring.h" #include "libavutil/internal.h" diff --git a/libavfilter/vf_scale_cuda.c b/libavfilter/vf_scale_cuda.c index cca68dd835..1ffb73f831 100644 --- a/libavfilter/vf_scale_cuda.c +++ b/libavfilter/vf_scale_cuda.c @@ -35,7 +35,7 @@ #include "avfilter.h" #include "formats.h" #include "internal.h" -#include "scale.h" +#include "scale_eval.h" #include "video.h" static const enum AVPixelFormat supported_formats[] = { diff --git a/libavfilter/vf_scale_npp.c b/libavfilter/vf_scale_npp.c index 09c3d51727..502ecfda94 100644 --- a/libavfilter/vf_scale_npp.c +++ b/libavfilter/vf_scale_npp.c @@ -37,7 +37,7 @@ #include "avfilter.h" #include "formats.h" #include "internal.h" -#include "scale.h" +#include "scale_eval.h" #include "video.h" #define CHECK_CU(x) FF_CUDA_CHECK_DL(ctx, device_hwctx->internal->cuda_dl, x) diff --git a/libavfilter/vf_scale_vaapi.c b/libavfilter/vf_scale_vaapi.c index 88642cbe73..8298a013da 100644 --- a/libavfilter/vf_scale_vaapi.c +++ b/libavfilter/vf_scale_vaapi.c @@ -26,7 +26,7 @@ #include "avfilter.h" #include "formats.h" #include "internal.h" -#include "scale.h" +#include "scale_eval.h" #include "video.h" #include "vaapi_vpp.h" -- cgit v1.2.3