Skip to content

Commit d324633

Browse files
bparrotmchehab
authored andcommitted
media: v4l2-rect.h: add enclosed rectangle helper
Add a helper function to check if one rectangle is enclosed inside another. Signed-off-by: Benoit Parrot <bparrot@ti.com> Acked-by: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com> Reviewed-by: Lad Prabhakar <prabhakar.csengg@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
1 parent 6756165 commit d324633

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

‎include/media/v4l2-rect.h‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,4 +184,24 @@ static inline bool v4l2_rect_overlap(const struct v4l2_rect *r1,
184184
return true;
185185
}
186186

187+
/**
188+
* v4l2_rect_enclosed() - is r1 enclosed in r2?
189+
* @r1: rectangle.
190+
* @r2: rectangle.
191+
*
192+
* Returns true if @r1 is enclosed in @r2.
193+
*/
194+
static inline bool v4l2_rect_enclosed(struct v4l2_rect *r1,
195+
struct v4l2_rect *r2)
196+
{
197+
if (r1->left < r2->left || r1->top < r2->top)
198+
return false;
199+
if (r1->left + r1->width > r2->left + r2->width)
200+
return false;
201+
if (r1->top + r1->height > r2->top + r2->height)
202+
return false;
203+
204+
return true;
205+
}
206+
187207
#endif

0 commit comments

Comments
 (0)