diff mbox series

[FFmpeg-devel,v4,04/21] lavfi/vpp_qsv: add "a", "dar" and "sar" variables

Message ID 20210729052509.30992-5-haihao.xiang@intel.com
State New
Headers show
Series clean-up QSV filters | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Xiang, Haihao July 29, 2021, 5:24 a.m. UTC
Also fix the coding style for VAR index. This is in preparation for
re-using VPPContext for scale_qsv filter
---
 libavfilter/vf_vpp_qsv.c | 29 +++++++++++++++++++----------
 1 file changed, 19 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
index fa4288f69f..cc8fe1645e 100644
--- a/libavfilter/vf_vpp_qsv.c
+++ b/libavfilter/vf_vpp_qsv.c
@@ -140,18 +140,22 @@  static const char *const var_names[] = {
     "ch",
     "cx",
     "cy",
+    "a", "dar",
+    "sar",
     NULL
 };
 
 enum var_name {
-    VAR_iW, VAR_IN_W,
-    VAR_iH, VAR_IN_H,
-    VAR_oW, VAR_OUT_W, VAR_W,
-    VAR_oH, VAR_OUT_H, VAR_H,
+    VAR_IW, VAR_IN_W,
+    VAR_IH, VAR_IN_H,
+    VAR_OW, VAR_OUT_W, VAR_W,
+    VAR_OH, VAR_OUT_H, VAR_H,
     CW,
     CH,
     CX,
     CY,
+    VAR_A, VAR_DAR,
+    VAR_SAR,
     VAR_VARS_NB
 };
 
@@ -183,12 +187,17 @@  static int eval_expr(AVFilterContext *ctx)
     PASS_EXPR(cx_expr, vpp->cx);
     PASS_EXPR(cy_expr, vpp->cy);
 
-    var_values[VAR_iW] =
+    var_values[VAR_IW] =
     var_values[VAR_IN_W] = ctx->inputs[0]->w;
 
-    var_values[VAR_iH] =
+    var_values[VAR_IH] =
     var_values[VAR_IN_H] = ctx->inputs[0]->h;
 
+    var_values[VAR_A] = (double)var_values[VAR_IN_W] / var_values[VAR_IN_H];
+    var_values[VAR_SAR] = ctx->inputs[0]->sample_aspect_ratio.num ?
+        (double)ctx->inputs[0]->sample_aspect_ratio.num / ctx->inputs[0]->sample_aspect_ratio.den : 1;
+    var_values[VAR_DAR] = var_values[VAR_A] * var_values[VAR_SAR];
+
     /* crop params */
     CALC_EXPR(cw_expr, var_values[CW], vpp->crop_w);
     CALC_EXPR(ch_expr, var_values[CH], vpp->crop_h);
@@ -197,15 +206,15 @@  static int eval_expr(AVFilterContext *ctx)
     CALC_EXPR(cw_expr, var_values[CW], vpp->crop_w);
 
     CALC_EXPR(w_expr,
-            var_values[VAR_OUT_W] = var_values[VAR_oW] = var_values[VAR_W],
+            var_values[VAR_OUT_W] = var_values[VAR_OW] = var_values[VAR_W],
             vpp->out_width);
     CALC_EXPR(h_expr,
-            var_values[VAR_OUT_H] = var_values[VAR_oH] = var_values[VAR_H],
+            var_values[VAR_OUT_H] = var_values[VAR_OH] = var_values[VAR_H],
             vpp->out_height);
 
     /* calc again in case ow is relative to oh */
     CALC_EXPR(w_expr,
-            var_values[VAR_OUT_W] = var_values[VAR_oW] = var_values[VAR_W],
+            var_values[VAR_OUT_W] = var_values[VAR_OW] = var_values[VAR_W],
             vpp->out_width);
 
 
@@ -215,7 +224,7 @@  static int eval_expr(AVFilterContext *ctx)
     /* calc again in case cx is relative to cy */
     CALC_EXPR(cx_expr, var_values[CX], vpp->crop_x);
 
-    if ((vpp->crop_w != var_values[VAR_iW]) || (vpp->crop_h != var_values[VAR_iH]))
+    if ((vpp->crop_w != var_values[VAR_IW]) || (vpp->crop_h != var_values[VAR_IH]))
         vpp->use_crop = 1;
 
 release: