[FFmpeg-devel] [PATCH] vf_scale: add a "sar" variable

Stefano Sabatini stefano.sabatini-lala at poste.it
Sat Jul 2 17:32:39 CEST 2011


Also create a "dar" alias to the "a" variable, for avoiding possible
confusion between dar/sar.
---
 doc/filters.texi       |    5 ++++-
 libavfilter/vf_scale.c |   11 ++++++++---
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index b4ffcd9..15b43ad 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -1231,9 +1231,12 @@ the output (cropped) width and heigth
 @item ow, oh
 same as @var{out_w} and @var{out_h}
 
- at item a
+ at item dar, a
 input display aspect ratio, same as @var{iw} / @var{ih}
 
+ at item sar
+input sample aspect ratio
+
 @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/vf_scale.c b/libavfilter/vf_scale.c
index e172a2e..f3b4bd1 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -38,7 +38,8 @@ static const char *var_names[] = {
     "in_h",   "ih",
     "out_w",  "ow",
     "out_h",  "oh",
-    "a",
+    "a", "dar",
+    "sar",
     "hsub",
     "vsub",
     NULL
@@ -52,7 +53,8 @@ enum var_name {
     VAR_IN_H,   VAR_IH,
     VAR_OUT_W,  VAR_OW,
     VAR_OUT_H,  VAR_OH,
-    VAR_A,
+    VAR_A, VAR_DAR,
+    VAR_SAR,
     VAR_HSUB,
     VAR_VSUB,
     VARS_NB
@@ -157,7 +159,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_A]     = (float) inlink->w / inlink->h;
+    var_values[VAR_DAR]   = 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_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;
 
-- 
1.7.2.5



More information about the ffmpeg-devel mailing list