summaryrefslogtreecommitdiff
path: root/libavfilter
diff options
context:
space:
mode:
authorSteven Liu <lq@chinaffmpeg.org>2019-09-04 23:53:05 +0800
committerSteven Liu <lq@chinaffmpeg.org>2019-10-10 10:26:57 +0800
commitaea82dfe225ef195f558df0350b20175a82be901 (patch)
tree9ffef08cfe569285bcb3753130f954970850953f /libavfilter
parent9f0b9ae8bd84b45dc8bc7bcb96607c2948d546d7 (diff)
avfilter/vf_delogo: add auto set the area inside of the frame
when the area outside of the frame, then use expr should give user warning message and auto set to the area inside of the frame. Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/vf_delogo.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/libavfilter/vf_delogo.c b/libavfilter/vf_delogo.c
index 376c5e850f..9c58418e11 100644
--- a/libavfilter/vf_delogo.c
+++ b/libavfilter/vf_delogo.c
@@ -327,6 +327,21 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
s->w = av_expr_eval(s->w_pexpr, s->var_values, s);
s->h = av_expr_eval(s->h_pexpr, s->var_values, s);
+ if (s->x + (s->band - 1) <= 0 || s->x + s->w - (s->band*2 - 2) > inlink->w ||
+ s->y + (s->band - 1) <= 0 || s->y + s->h - (s->band*2 - 2) > inlink->h) {
+ av_log(s, AV_LOG_WARNING, "Logo area is outside of the frame,"
+ " auto set the area inside of the frame\n");
+ }
+
+ if (s->x + (s->band - 1) <= 0)
+ s->x = 1 + s->band;
+ if (s->y + (s->band - 1) <= 0)
+ s->y = 1 + s->band;
+ if (s->x + s->w - (s->band*2 - 2) > inlink->w)
+ s->w = inlink->w - s->x - (s->band*2 - 2);
+ if (s->y + s->h - (s->band*2 - 2) > inlink->h)
+ s->h = inlink->h - s->y - (s->band*2 - 2);
+
ret = config_input(inlink);
if (ret < 0) {
av_frame_free(&in);