Commit d3246337 authored by Benoit Parrot's avatar Benoit Parrot Committed by Mauro Carvalho Chehab

media: v4l2-rect.h: add enclosed rectangle helper

Add a helper function to check if one rectangle is enclosed inside
another.
Signed-off-by: default avatarBenoit Parrot <bparrot@ti.com>
Acked-by: default avatarAndrzej Pietrasiewicz <andrzejtp2010@gmail.com>
Reviewed-by: default avatarLad Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 67561655
......@@ -184,4 +184,24 @@ static inline bool v4l2_rect_overlap(const struct v4l2_rect *r1,
return true;
}
/**
* v4l2_rect_enclosed() - is r1 enclosed in r2?
* @r1: rectangle.
* @r2: rectangle.
*
* Returns true if @r1 is enclosed in @r2.
*/
static inline bool v4l2_rect_enclosed(struct v4l2_rect *r1,
struct v4l2_rect *r2)
{
if (r1->left < r2->left || r1->top < r2->top)
return false;
if (r1->left + r1->width > r2->left + r2->width)
return false;
if (r1->top + r1->height > r2->top + r2->height)
return false;
return true;
}
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment