From: "Xiang, Haihao" <haihao.xiang-at-intel.com@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: Haihao Xiang <haihao.xiang@intel.com>
Subject: [FFmpeg-devel] [PATCH 2/8] lavfi/vf_vpp_qsv: handle NULL pointer when evaluating an expression
Date: Mon, 9 Jan 2023 15:12:04 +0800
Message-ID: <20230109071210.1829699-2-haihao.xiang@intel.com> (raw)
In-Reply-To: <20230109071210.1829699-1-haihao.xiang@intel.com>
From: Haihao Xiang <haihao.xiang@intel.com>
This patch provides default value if the expression is NULL.
This is in preparation for reusing the code for other QSV filters.
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
---
libavfilter/vf_vpp_qsv.c | 36 ++++++++++++++++++++----------------
1 file changed, 20 insertions(+), 16 deletions(-)
diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
index 8d4227f841..3a0a395732 100644
--- a/libavfilter/vf_vpp_qsv.c
+++ b/libavfilter/vf_vpp_qsv.c
@@ -172,14 +172,19 @@ enum var_name {
static int eval_expr(AVFilterContext *ctx)
{
#define PASS_EXPR(e, s) {\
- ret = av_expr_parse(&e, s, var_names, NULL, NULL, NULL, NULL, 0, ctx); \
- if (ret < 0) {\
- av_log(ctx, AV_LOG_ERROR, "Error when passing '%s'.\n", s);\
- goto release;\
+ if (s) {\
+ ret = av_expr_parse(&e, s, var_names, NULL, NULL, NULL, NULL, 0, ctx); \
+ if (ret < 0) { \
+ av_log(ctx, AV_LOG_ERROR, "Error when passing '%s'.\n", s); \
+ goto release; \
+ } \
}\
}
-#define CALC_EXPR(e, v, i) {\
- i = v = av_expr_eval(e, var_values, NULL); \
+#define CALC_EXPR(e, v, i, d) {\
+ if (e)\
+ i = v = av_expr_eval(e, var_values, NULL); \
+ else\
+ i = v = d;\
}
VPPContext *vpp = ctx->priv;
double var_values[VAR_VARS_NB] = { NAN };
@@ -209,30 +214,29 @@ static int eval_expr(AVFilterContext *ctx)
var_values[VAR_DAR] = var_values[VAR_A] * var_values[VAR_SAR];
/* crop params */
- CALC_EXPR(cw_expr, var_values[VAR_CW], vpp->crop_w);
- CALC_EXPR(ch_expr, var_values[VAR_CH], vpp->crop_h);
+ CALC_EXPR(cw_expr, var_values[VAR_CW], vpp->crop_w, var_values[VAR_IW]);
+ CALC_EXPR(ch_expr, var_values[VAR_CH], vpp->crop_h, var_values[VAR_IH]);
/* calc again in case cw is relative to ch */
- CALC_EXPR(cw_expr, var_values[VAR_CW], vpp->crop_w);
+ CALC_EXPR(cw_expr, var_values[VAR_CW], vpp->crop_w, var_values[VAR_IW]);
CALC_EXPR(w_expr,
var_values[VAR_OUT_W] = var_values[VAR_OW] = var_values[VAR_W],
- vpp->out_width);
+ vpp->out_width, var_values[VAR_CW]);
CALC_EXPR(h_expr,
var_values[VAR_OUT_H] = var_values[VAR_OH] = var_values[VAR_H],
- vpp->out_height);
+ vpp->out_height, var_values[VAR_CH]);
/* 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],
- vpp->out_width);
+ vpp->out_width, var_values[VAR_CW]);
-
- CALC_EXPR(cx_expr, var_values[VAR_CX], vpp->crop_x);
- CALC_EXPR(cy_expr, var_values[VAR_CY], vpp->crop_y);
+ CALC_EXPR(cx_expr, var_values[VAR_CX], vpp->crop_x, (var_values[VAR_IW] - var_values[VAR_OW]) / 2);
+ CALC_EXPR(cy_expr, var_values[VAR_CY], vpp->crop_y, (var_values[VAR_IH] - var_values[VAR_OH]) / 2);
/* calc again in case cx is relative to cy */
- CALC_EXPR(cx_expr, var_values[VAR_CX], vpp->crop_x);
+ CALC_EXPR(cx_expr, var_values[VAR_CX], vpp->crop_x, (var_values[VAR_IW] - var_values[VAR_OW]) / 2);
if ((vpp->crop_w != var_values[VAR_IW]) || (vpp->crop_h != var_values[VAR_IH]))
vpp->use_crop = 1;
--
2.25.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2023-01-09 7:12 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-09 7:12 [FFmpeg-devel] [PATCH 1/8] lavfi/vf_vpp_qsv: add "a", "dar" and "sar" variables Xiang, Haihao
2023-01-09 7:12 ` Xiang, Haihao [this message]
2023-01-12 4:01 ` [FFmpeg-devel] [PATCH 2/8] lavfi/vf_vpp_qsv: handle NULL pointer when evaluating an expression Andreas Rheinhardt
2023-01-12 6:20 ` Xiang, Haihao
2023-01-16 4:34 ` Xiang, Haihao
2023-01-09 7:12 ` [FFmpeg-devel] [PATCH 3/8] lavfi/vf_vpp_qsv: allow special values for the output video dimensions Xiang, Haihao
2023-01-09 7:12 ` [FFmpeg-devel] [PATCH 4/8] lavfi/vf_vpp_qsv: add vpp_preinit callback Xiang, Haihao
2023-01-12 4:11 ` Andreas Rheinhardt
2023-01-12 4:44 ` Xiang, Haihao
2023-01-12 4:49 ` Andreas Rheinhardt
2023-01-12 5:41 ` Xiang, Haihao
2023-01-09 7:12 ` [FFmpeg-devel] [PATCH 5/8] lavfi/vf_vpp_qsv: add has_passthrough flag in VPPContext Xiang, Haihao
2023-01-12 4:31 ` Andreas Rheinhardt
2023-01-12 4:53 ` Xiang, Haihao
2023-01-09 7:12 ` [FFmpeg-devel] [PATCH 6/8] lavfi/vf_vpp_qsv: check output format string against NULL pointer Xiang, Haihao
2023-01-09 7:12 ` [FFmpeg-devel] [PATCH 7/8] lavfi/qsvvpp: set output frame durations Xiang, Haihao
2023-01-09 7:12 ` [FFmpeg-devel] [PATCH 8/8] lavfi/qsv: use QSVVPPContext as base context in vf_vpp_qsv/vf_overlay_qsv Xiang, Haihao
2023-01-12 3:58 ` [FFmpeg-devel] [PATCH 1/8] lavfi/vf_vpp_qsv: add "a", "dar" and "sar" variables Xiang, Haihao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230109071210.1829699-2-haihao.xiang@intel.com \
--to=haihao.xiang-at-intel.com@ffmpeg.org \
--cc=ffmpeg-devel@ffmpeg.org \
--cc=haihao.xiang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git