diff options
author | Benoit Parrot <bparrot@ti.com> | 2020-05-28 15:26:04 +0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+huawei@kernel.org> | 2020-07-04 12:29:38 +0200 |
commit | d3246337d00fcb635e4ade45f748f155e4056b28 (patch) | |
tree | 6e5a0a4ec7a93a1ee0bf02ce8fe91663bb86f1c8 /include/media | |
parent | 675616554d0a5caff138008ee9bd4623bc4390b2 (diff) |
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>
Diffstat (limited to 'include/media')
-rw-r--r-- | include/media/v4l2-rect.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/include/media/v4l2-rect.h b/include/media/v4l2-rect.h index 8800a640c224..bd587d0c0dc3 100644 --- a/include/media/v4l2-rect.h +++ b/include/media/v4l2-rect.h @@ -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 |