~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/media/v4l2-rect.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /include/media/v4l2-rect.h (Version linux-6.11.5) and /include/media/v4l2-rect.h (Version linux-2.4.37.11)


  1 /* SPDX-License-Identifier: GPL-2.0-only */         1 
  2 /*                                                
  3  * v4l2-rect.h - v4l2_rect helper functions       
  4  *                                                
  5  * Copyright 2014 Cisco Systems, Inc. and/or i    
  6  */                                               
  7                                                   
  8 #ifndef _V4L2_RECT_H_                             
  9 #define _V4L2_RECT_H_                             
 10                                                   
 11 #include <linux/videodev2.h>                      
 12                                                   
 13 /**                                               
 14  * v4l2_rect_set_size_to() - copy the width/he    
 15  * @r: rect whose width and height fields will    
 16  * @size: rect containing the width and height    
 17  */                                               
 18 static inline void v4l2_rect_set_size_to(struc    
 19                                          const    
 20 {                                                 
 21         r->width = size->width;                   
 22         r->height = size->height;                 
 23 }                                                 
 24                                                   
 25 /**                                               
 26  * v4l2_rect_set_min_size() - width and height    
 27  * @r: rect whose width and height will be mod    
 28  * @min_size: rect containing the minimal widt    
 29  */                                               
 30 static inline void v4l2_rect_set_min_size(stru    
 31                                           cons    
 32 {                                                 
 33         if (r->width < min_size->width)           
 34                 r->width = min_size->width;       
 35         if (r->height < min_size->height)         
 36                 r->height = min_size->height;     
 37 }                                                 
 38                                                   
 39 /**                                               
 40  * v4l2_rect_set_max_size() - width and height    
 41  * @r: rect whose width and height will be mod    
 42  * @max_size: rect containing the maximum widt    
 43  */                                               
 44 static inline void v4l2_rect_set_max_size(stru    
 45                                           cons    
 46 {                                                 
 47         if (r->width > max_size->width)           
 48                 r->width = max_size->width;       
 49         if (r->height > max_size->height)         
 50                 r->height = max_size->height;     
 51 }                                                 
 52                                                   
 53 /**                                               
 54  * v4l2_rect_map_inside()- r should be inside     
 55  * @r: rect that will be modified                 
 56  * @boundary: rect containing the boundary for    
 57  */                                               
 58 static inline void v4l2_rect_map_inside(struct    
 59                                         const     
 60 {                                                 
 61         v4l2_rect_set_max_size(r, boundary);      
 62         if (r->left < boundary->left)             
 63                 r->left = boundary->left;         
 64         if (r->top < boundary->top)               
 65                 r->top = boundary->top;           
 66         if (r->left + r->width > boundary->lef    
 67                 r->left = boundary->left + bou    
 68         if (r->top + r->height > boundary->top    
 69                 r->top = boundary->top + bound    
 70 }                                                 
 71                                                   
 72 /**                                               
 73  * v4l2_rect_same_size() - return true if r1 h    
 74  * @r1: rectangle.                                
 75  * @r2: rectangle.                                
 76  *                                                
 77  * Return true if both rectangles have the sam    
 78  */                                               
 79 static inline bool v4l2_rect_same_size(const s    
 80                                        const s    
 81 {                                                 
 82         return r1->width == r2->width && r1->h    
 83 }                                                 
 84                                                   
 85 /**                                               
 86  * v4l2_rect_same_position() - return true if     
 87  * @r1: rectangle.                                
 88  * @r2: rectangle.                                
 89  *                                                
 90  * Return true if both rectangles have the sam    
 91  */                                               
 92 static inline bool v4l2_rect_same_position(con    
 93                                            con    
 94 {                                                 
 95         return r1->top == r2->top && r1->left     
 96 }                                                 
 97                                                   
 98 /**                                               
 99  * v4l2_rect_equal() - return true if r1 equal    
100  * @r1: rectangle.                                
101  * @r2: rectangle.                                
102  *                                                
103  * Return true if both rectangles have the sam    
104  */                                               
105 static inline bool v4l2_rect_equal(const struc    
106                                    const struc    
107 {                                                 
108         return v4l2_rect_same_size(r1, r2) &&     
109 }                                                 
110                                                   
111 /**                                               
112  * v4l2_rect_intersect() - calculate the inter    
113  * @r: intersection of @r1 and @r2.               
114  * @r1: rectangle.                                
115  * @r2: rectangle.                                
116  */                                               
117 static inline void v4l2_rect_intersect(struct     
118                                        const s    
119                                        const s    
120 {                                                 
121         int right, bottom;                        
122                                                   
123         r->top = max(r1->top, r2->top);           
124         r->left = max(r1->left, r2->left);        
125         bottom = min(r1->top + r1->height, r2-    
126         right = min(r1->left + r1->width, r2->    
127         r->height = max(0, bottom - r->top);      
128         r->width = max(0, right - r->left);       
129 }                                                 
130                                                   
131 /**                                               
132  * v4l2_rect_scale() - scale rect r by to/from    
133  * @r: rect to be scaled.                         
134  * @from: from rectangle.                         
135  * @to: to rectangle.                             
136  *                                                
137  * This scales rectangle @r horizontally by @t    
138  * vertically by @to->height / @from->height.     
139  *                                                
140  * Typically @r is a rectangle inside @from an    
141  * it would appear after scaling @from to @to.    
142  * be the scaled rectangle inside @to.            
143  */                                               
144 static inline void v4l2_rect_scale(struct v4l2    
145                                    const struc    
146                                    const struc    
147 {                                                 
148         if (from->width == 0 || from->height =    
149                 r->left = r->top = r->width =     
150                 return;                           
151         }                                         
152         r->left = (((r->left - from->left) * t    
153         r->width = ((r->width * to->width) / f    
154         r->top = ((r->top - from->top) * to->h    
155         r->height = (r->height * to->height) /    
156 }                                                 
157                                                   
158 /**                                               
159  * v4l2_rect_overlap() - do r1 and r2 overlap?    
160  * @r1: rectangle.                                
161  * @r2: rectangle.                                
162  *                                                
163  * Returns true if @r1 and @r2 overlap.           
164  */                                               
165 static inline bool v4l2_rect_overlap(const str    
166                                      const str    
167 {                                                 
168         /*                                        
169          * IF the left side of r1 is to the ri    
170          *    the left side of r2 is to the ri    
171          * they do not overlap.                   
172          */                                       
173         if (r1->left >= r2->left + r2->width |    
174             r2->left >= r1->left + r1->width)     
175                 return false;                     
176         /*                                        
177          * IF the top side of r1 is below the     
178          *    the top side of r2 is below the     
179          * they do not overlap.                   
180          */                                       
181         if (r1->top >= r2->top + r2->height ||    
182             r2->top >= r1->top + r1->height)      
183                 return false;                     
184         return true;                              
185 }                                                 
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 v    
195                                       struct v    
196 {                                                 
197         if (r1->left < r2->left || r1->top < r    
198                 return false;                     
199         if (r1->left + r1->width > r2->left +     
200                 return false;                     
201         if (r1->top + r1->height > r2->top + r    
202                 return false;                     
203                                                   
204         return true;                              
205 }                                                 
206                                                   
207 #endif                                            
208                                                   

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php