1 /*
2  * Copyright (c) 2022, Alliance for Open Media. All rights reserved
3  *
4  * This source code is subject to the terms of the BSD 2 Clause License and
5  * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6  * was not distributed with this source code in the LICENSE file, you can
7  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8  * Media Patent License 1.0 was not distributed with this source code in the
9  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10  */
11 
12 #ifndef AOM_AOM_DSP_RECT_H_
13 #define AOM_AOM_DSP_RECT_H_
14 
15 #include "config/aom_config.h"
16 
17 #include <stdbool.h>
18 
19 // Struct representing a rectangle of pixels.
20 // The axes are inclusive-exclusive, ie. the point (top, left) is included
21 // in the rectangle but (bottom, right) is not.
22 typedef struct {
23   int left, right, top, bottom;
24 } PixelRect;
25 
rect_width(const PixelRect * r)26 static INLINE int rect_width(const PixelRect *r) { return r->right - r->left; }
27 
rect_height(const PixelRect * r)28 static INLINE int rect_height(const PixelRect *r) { return r->bottom - r->top; }
29 
is_inside_rect(const int x,const int y,const PixelRect * r)30 static INLINE bool is_inside_rect(const int x, const int y,
31                                   const PixelRect *r) {
32   return (r->left <= x && x < r->right) && (r->top <= y && y < r->bottom);
33 }
34 
35 #endif  // AOM_AOM_DSP_RECT_H_
36