[FFmpeg-devel] [PATCH] avfilter/scale: refactor common code for scaling height/width expressions

Michael Niedermayer michaelni at gmx.at
Wed Feb 1 15:51:01 EET 2017


On Tue, Jan 31, 2017 at 04:46:25PM -0800, Aman Gupta wrote:
> From: Aman Gupta <aman at tmm1.net>
> 
> Implements support for height/width expressions in vf_scale_vaapi,
> by refactoring common code into a new libavfilter/scale.c
> ---
>  libavfilter/Makefile         |   8 +--
>  libavfilter/scale.c          | 143 +++++++++++++++++++++++++++++++++++++++++++
>  libavfilter/scale.h          |  31 ++++++++++
>  libavfilter/vf_scale.c       | 109 +++------------------------------
>  libavfilter/vf_scale_npp.c   |  87 +++-----------------------
>  libavfilter/vf_scale_vaapi.c |  18 +++++-
>  6 files changed, 208 insertions(+), 188 deletions(-)
>  create mode 100644 libavfilter/scale.c
>  create mode 100644 libavfilter/scale.h
> 
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index 68a94be..3231f08 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -257,10 +257,10 @@ OBJS-$(CONFIG_REPEATFIELDS_FILTER)           += vf_repeatfields.o
>  OBJS-$(CONFIG_REVERSE_FILTER)                += f_reverse.o
>  OBJS-$(CONFIG_ROTATE_FILTER)                 += vf_rotate.o
>  OBJS-$(CONFIG_SAB_FILTER)                    += vf_sab.o
> -OBJS-$(CONFIG_SCALE_FILTER)                  += vf_scale.o
> -OBJS-$(CONFIG_SCALE_NPP_FILTER)              += vf_scale_npp.o
> -OBJS-$(CONFIG_SCALE_VAAPI_FILTER)            += vf_scale_vaapi.o
> -OBJS-$(CONFIG_SCALE2REF_FILTER)              += vf_scale.o
> +OBJS-$(CONFIG_SCALE_FILTER)                  += vf_scale.o scale.o
> +OBJS-$(CONFIG_SCALE_NPP_FILTER)              += vf_scale_npp.o scale.o
> +OBJS-$(CONFIG_SCALE_VAAPI_FILTER)            += vf_scale_vaapi.o scale.o
> +OBJS-$(CONFIG_SCALE2REF_FILTER)              += vf_scale.o scale.o
>  OBJS-$(CONFIG_SELECT_FILTER)                 += f_select.o
>  OBJS-$(CONFIG_SELECTIVECOLOR_FILTER)         += vf_selectivecolor.o
>  OBJS-$(CONFIG_SENDCMD_FILTER)                += f_sendcmd.o
> diff --git a/libavfilter/scale.c b/libavfilter/scale.c
> new file mode 100644
> index 0000000..b0f4be2
> --- /dev/null
> +++ b/libavfilter/scale.c
> @@ -0,0 +1,143 @@
> +/*
> + * This file is part of FFmpeg.

Theres a copyright line in libavfilter/vf_scale.c
but none in the file the code is moved too


> + *
> + * 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 "scale.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
> +};
> +

> +int ff_scale_eval_dimensions(void *ctx,

please call ctx, log_ctx


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Democracy is the form of government in which you can choose your dictator
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20170201/c0a64d62/attachment.sig>


More information about the ffmpeg-devel mailing list