Browse Source

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".
Stefano Sabatini 13 years ago
parent
commit
61d55fda2b
4 changed files with 23 additions and 11 deletions
  1. 10 4
      doc/filters.texi
  2. 1 1
      libavfilter/avfilter.h
  3. 6 3
      libavfilter/vf_pad.c
  4. 6 3
      libavfilter/vf_scale.c

+ 10 - 4
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.

+ 1 - 1
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, \

+ 6 - 3
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<<pad->hsub;
     var_values[VAR_VSUB]  = 1<<pad->vsub;
 

+ 6 - 3
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<<av_pix_fmt_descriptors[inlink->format].log2_chroma_w;
     var_values[VAR_VSUB]  = 1<<av_pix_fmt_descriptors[inlink->format].log2_chroma_h;