]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/vf_pad.c
Merge remote-tracking branch 'qatar/master'
[ffmpeg] / libavfilter / vf_pad.c
index e41ebe89648d0bb0a0ead026ea4be40379859c60..e01a750d94d4db9a96d16590ae5a6736a69a8766 100644 (file)
@@ -21,7 +21,7 @@
 
 /**
  * @file
- * video padding filter and color source
+ * video padding filter
  */
 
 #include "avfilter.h"
@@ -32,6 +32,7 @@
 #include "libavutil/avassert.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/parseutils.h"
+#include "libavutil/mathematics.h"
 #include "drawutils.h"
 
 static const char *var_names[] = {
@@ -44,7 +45,8 @@ static const char *var_names[] = {
     "out_h",  "oh",
     "x",
     "y",
-    "a",
+    "a", "dar",
+    "sar",
     "hsub",
     "vsub",
     NULL
@@ -60,7 +62,8 @@ enum var_name {
     VAR_OUT_H,  VAR_OH,
     VAR_X,
     VAR_Y,
-    VAR_A,
+    VAR_A, VAR_DAR,
+    VAR_SAR,
     VAR_HSUB,
     VAR_VSUB,
     VARS_NB
@@ -83,7 +86,7 @@ static int query_formats(AVFilterContext *ctx)
         PIX_FMT_NONE
     };
 
-    avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts));
+    avfilter_set_common_pixel_formats(ctx, avfilter_make_format_list(pix_fmts));
     return 0;
 }
 
@@ -155,9 +158,11 @@ 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_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<<pad->hsub;
-    var_values[VAR_VSUB]  = 2<<pad->vsub;
+    var_values[VAR_VSUB]  = 1<<pad->vsub;
 
     /* evaluate width and height */
     av_expr_parse_and_eval(&res, (expr = pad->w_expr),