Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Benoit Parrot and committed by
Mauro Carvalho Chehab
d3246337 67561655

+20
+20
include/media/v4l2-rect.h
··· 184 184 return true; 185 185 } 186 186 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 + 187 207 #endif