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.
Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -327,6 +327,21 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 326 unmodified lines | |||
| 327 | s->w = av_expr_eval(s->w_pexpr, s->var_values, s); | 327 | s->w = av_expr_eval(s->w_pexpr, s->var_values, s); |
| 328 | s->h = av_expr_eval(s->h_pexpr, s->var_values, s); | 328 | s->h = av_expr_eval(s->h_pexpr, s->var_values, s); |
| 329 | 329 | ||
| 330 | if (s->x + (s->band - 1) <= 0 || s->x + s->w - (s->band*2 - 2) > inlink->w || | ||
| 331 | s->y + (s->band - 1) <= 0 || s->y + s->h - (s->band*2 - 2) > inlink->h) { | ||
| 332 | av_log(s, AV_LOG_WARNING, "Logo area is outside of the frame," | ||
| 333 | " auto set the area inside of the frame\n"); | ||
| 334 | } | ||
| 335 | |||
| 336 | if (s->x + (s->band - 1) <= 0) | ||
| 337 | s->x = 1 + s->band; | ||
| 338 | if (s->y + (s->band - 1) <= 0) | ||
| 339 | s->y = 1 + s->band; | ||
| 340 | if (s->x + s->w - (s->band*2 - 2) > inlink->w) | ||
| 341 | s->w = inlink->w - s->x - (s->band*2 - 2); | ||
| 342 | if (s->y + s->h - (s->band*2 - 2) > inlink->h) | ||
| 343 | s->h = inlink->h - s->y - (s->band*2 - 2); | ||
| 344 | |||
| 330 | ret = config_input(inlink); | 345 | ret = config_input(inlink); |
| 331 | if (ret < 0) { | 346 | if (ret < 0) { |
| 332 | av_frame_free(&in); | 347 | av_frame_free(&in); |