[FFmpeg-devel] [PATCH] avfilter/vf_morpho: Fix compilation with MSVC

Soft Works softworkz at hotmail.com
Wed Sep 29 08:23:38 EEST 2021



> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces at ffmpeg.org> On Behalf Of
> Andreas Rheinhardt
> Sent: Wednesday, 29 September 2021 07:10
> To: ffmpeg-devel at ffmpeg.org
> Cc: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> Subject: [FFmpeg-devel] [PATCH] avfilter/vf_morpho: Fix compilation
> with MSVC
> 
> MSVC (or rather the windef.h header) defines min and max as macros,
> breaking compilation here. Fix this by adding parentheses around min
> and max, so that they are no longer recognizable as function-like
> macros.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> ---
> Untested as I don't have an MSVC setup.
> 
>  libavfilter/vf_morpho.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavfilter/vf_morpho.c b/libavfilter/vf_morpho.c
> index fd181ddaa5..b2a0a61543 100644
> --- a/libavfilter/vf_morpho.c
> +++ b/libavfilter/vf_morpho.c
> @@ -304,7 +304,7 @@ static void compute_min_row(IPlane *f, LUT *Ty,
> chord_set *SE, int r, int y)
>      for (int i = 1; i < SE->Lnum; i++) {
>          int d = SE->R[i] - SE->R[i - 1];
> 
> -        f->min(Ty->arr[r][i] - Ty->pre_pad_x * f->type_size,
> +        (f->min)(Ty->arr[r][i] - Ty->pre_pad_x * f->type_size,
>              Ty->arr[r][i - 1] - Ty->pre_pad_x * f->type_size,
>              Ty->arr[r][i - 1] + (d - Ty->pre_pad_x) * f->type_size,
>              Ty->X + Ty->pre_pad_x - d);
> @@ -358,7 +358,7 @@ static void compute_max_row(IPlane *f, LUT *Ty,
> chord_set *SE, int r, int y)
>      for (int i = 1; i < SE->Lnum; i++) {
>          int d = SE->R[i] - SE->R[i - 1];
> 
> -        f->max(Ty->arr[r][i] - Ty->pre_pad_x * f->type_size,
> +        (f->max)(Ty->arr[r][i] - Ty->pre_pad_x * f->type_size,
>              Ty->arr[r][i - 1] - Ty->pre_pad_x * f->type_size,
>              Ty->arr[r][i - 1] + (d - Ty->pre_pad_x) * f->type_size,
>              Ty->X + Ty->pre_pad_x - d);
> --

It compiles successfully with MSVC. 

But I think you should add some comments explaining the parentheses
to prevent other developers from thinking they would be useless 
and could be removed.

softworkz



More information about the ffmpeg-devel mailing list