From 61d55fda2b513caf18e37b27aba680a87840904a Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Wed, 27 Jul 2011 10:58:24 +0200 Subject: [PATCH] lavfi: tweak display aspect ratio variables in pad and scale filters Previously, "dar" and "a" were documented like "input display aspect ratio", but their actual value was "in_w/in_h". In order to avoid to break scripts which rely on the "a" variable, the patch keeps the same semantics but fixes the corresponding docs, and fixes the semantics of the recently added "dar" variable, which now correctly expresses the input Display Aspect Ratio value as "(inw_w/in_h)*sar". --- doc/filters.texi | 14 ++++++++++---- libavfilter/avfilter.h | 2 +- libavfilter/vf_pad.c | 9 ++++++--- libavfilter/vf_scale.c | 9 ++++++--- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 8054bffb1d..2e419a8edf 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -1184,12 +1184,15 @@ same as @var{out_w} and @var{out_h} x and y offsets as specified by the @var{x} and @var{y} expressions, or NAN if not yet specified -@item dar, a -input display aspect ratio, same as @var{iw} / @var{ih} +@item a +same as @var{iw} / @var{ih} @item sar input sample aspect ratio +@item dar +input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar} + @item hsub, vsub horizontal and vertical chroma subsample values. For example for the pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1. @@ -1289,12 +1292,15 @@ the output (cropped) width and heigth @item ow, oh same as @var{out_w} and @var{out_h} -@item dar, a -input display aspect ratio, same as @var{iw} / @var{ih} +@item a +same as @var{iw} / @var{ih} @item sar input sample aspect ratio +@item dar +input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar} + @item hsub, vsub horizontal and vertical chroma subsample values. For example for the pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1. diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 913a52b22f..6746176c0d 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -30,7 +30,7 @@ #define LIBAVFILTER_VERSION_MAJOR 2 #define LIBAVFILTER_VERSION_MINOR 27 -#define LIBAVFILTER_VERSION_MICRO 3 +#define LIBAVFILTER_VERSION_MICRO 4 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ LIBAVFILTER_VERSION_MINOR, \ diff --git a/libavfilter/vf_pad.c b/libavfilter/vf_pad.c index e01a750d94..c4edc23cc5 100644 --- a/libavfilter/vf_pad.c +++ b/libavfilter/vf_pad.c @@ -45,8 +45,9 @@ static const char *var_names[] = { "out_h", "oh", "x", "y", - "a", "dar", + "a", "sar", + "dar", "hsub", "vsub", NULL @@ -62,8 +63,9 @@ enum var_name { VAR_OUT_H, VAR_OH, VAR_X, VAR_Y, - VAR_A, VAR_DAR, + VAR_A, VAR_SAR, + VAR_DAR, VAR_HSUB, VAR_VSUB, VARS_NB @@ -158,9 +160,10 @@ static int config_input(AVFilterLink *inlink) 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_DAR] = var_values[VAR_A] = (float) inlink->w / inlink->h; + var_values[VAR_A] = (float) inlink->w / inlink->h; var_values[VAR_SAR] = inlink->sample_aspect_ratio.num ? (float) 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<hsub; var_values[VAR_VSUB] = 1<vsub; diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index 3be5d99e96..044b2843bc 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -39,8 +39,9 @@ static const char *var_names[] = { "in_h", "ih", "out_w", "ow", "out_h", "oh", - "a", "dar", + "a", "sar", + "dar", "hsub", "vsub", NULL @@ -54,8 +55,9 @@ enum var_name { VAR_IN_H, VAR_IH, VAR_OUT_W, VAR_OW, VAR_OUT_H, VAR_OH, - VAR_A, VAR_DAR, + VAR_A, VAR_SAR, + VAR_DAR, VAR_HSUB, VAR_VSUB, VARS_NB @@ -160,9 +162,10 @@ static int config_props(AVFilterLink *outlink) 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_DAR] = var_values[VAR_A] = (float) inlink->w / inlink->h; + var_values[VAR_A] = (float) inlink->w / inlink->h; var_values[VAR_SAR] = inlink->sample_aspect_ratio.num ? (float) 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<format].log2_chroma_w; var_values[VAR_VSUB] = 1<format].log2_chroma_h;