Chih-Wei Huang | 0d92eda | 2012-02-07 16:55:49 +0800 | [diff] [blame] | 1 | /* |
| 2 | libcamera: An implementation of the library required by Android OS 3.2 so |
| 3 | it can access V4L2 devices as cameras. |
| 4 | |
Chih-Wei Huang | d5590eb | 2019-02-26 17:48:45 +0800 | [diff] [blame] | 5 | (C) 2011 Eduardo José Tagle <ejtagle@tutopia.com> |
Chih-Wei Huang | 0d92eda | 2012-02-07 16:55:49 +0800 | [diff] [blame] | 6 | |
| 7 | Based on several packages: |
| 8 | - luvcview: Sdl video Usb Video Class grabber |
| 9 | (C) 2005,2006,2007 Laurent Pinchart && Michel Xhaard |
| 10 | |
| 11 | - spcaview |
| 12 | (C) 2003,2004,2005,2006 Michel Xhaard |
| 13 | |
| 14 | - JPEG decoder from http://www.bootsplash.org/ |
| 15 | (C) August 2001 by Michael Schroeder, <mls@suse.de> |
| 16 | |
| 17 | - libcamera V4L for Android 2.2 |
| 18 | (C) 2009 0xlab.org - http://0xlab.org/ |
| 19 | (C) 2010 SpectraCore Technologies |
| 20 | Author: Venkat Raju <codredruids@spectracoretech.com> |
| 21 | Based on a code from http://code.google.com/p/android-m912/downloads/detail?name=v4l2_camera_v2.patch |
| 22 | |
| 23 | - guvcview: http://guvcview.berlios.de |
| 24 | Paulo Assis <pj.assis@gmail.com> |
| 25 | Nobuhiro Iwamatsu <iwamatsu@nigauri.org> |
| 26 | |
| 27 | This program is free software: you can redistribute it and/or modify |
| 28 | it under the terms of the GNU General Public License as published by |
| 29 | the Free Software Foundation, either version 3 of the License, or |
| 30 | (at your option) any later version. |
| 31 | |
| 32 | This program is distributed in the hope that it will be useful, |
| 33 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 34 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 35 | GNU General Public License for more details. |
| 36 | |
| 37 | You should have received a copy of the GNU General Public License |
| 38 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 39 | |
| 40 | */ |
| 41 | |
| 42 | |
| 43 | #ifndef __SURFSIZE_H |
| 44 | #define __SURFSIZE_H |
| 45 | |
| 46 | namespace android { |
| 47 | |
| 48 | class SurfaceSize { |
| 49 | protected: |
| 50 | int width; |
| 51 | int height; |
| 52 | |
| 53 | public: |
| 54 | // Constructors |
| 55 | SurfaceSize() : width(0), height(0) {} |
| 56 | SurfaceSize(const SurfaceSize& v) : width(v.width), height(v.height) {} |
| 57 | SurfaceSize(int pwidth,int pheight) : |
| 58 | width(pwidth), height(pheight) {} |
| 59 | |
| 60 | // Assignment operators |
| 61 | const SurfaceSize& operator=(const SurfaceSize& v) { |
| 62 | width = v.width; height = v.height; |
| 63 | return *this; |
| 64 | } |
| 65 | |
| 66 | // Accessors |
| 67 | inline int getWidth() const { return width; } |
| 68 | inline int getHeight() const { return height; } |
| 69 | inline int getArea() const { return width * height; } |
| 70 | |
| 71 | // Operators |
| 72 | inline void set(int w,int h) { width = w; height = h; } |
| 73 | |
| 74 | // Comparison operators |
| 75 | int compare(const SurfaceSize& other) const; |
| 76 | |
| 77 | inline bool operator<(const SurfaceSize& other) const; |
| 78 | inline bool operator<=(const SurfaceSize& other) const; |
| 79 | inline bool operator==(const SurfaceSize& other) const; |
| 80 | inline bool operator!=(const SurfaceSize& other) const; |
| 81 | inline bool operator>=(const SurfaceSize& other) const; |
| 82 | inline bool operator>(const SurfaceSize& other) const; |
| 83 | |
| 84 | }; |
| 85 | |
| 86 | inline int compare_type(const SurfaceSize& lhs, const SurfaceSize& rhs) |
| 87 | { |
| 88 | return lhs.compare(rhs); |
| 89 | } |
| 90 | |
| 91 | inline int strictly_order_type(const SurfaceSize& lhs, const SurfaceSize& rhs) |
| 92 | { |
| 93 | return compare_type(lhs, rhs) < 0; |
| 94 | } |
| 95 | |
| 96 | inline bool SurfaceSize::operator<(const SurfaceSize& other) const |
| 97 | { |
| 98 | return compare(other) < 0; |
| 99 | } |
| 100 | |
| 101 | inline bool SurfaceSize::operator<=(const SurfaceSize& other) const |
| 102 | { |
| 103 | return compare(other) <= 0; |
| 104 | } |
| 105 | |
| 106 | inline bool SurfaceSize::operator==(const SurfaceSize& other) const |
| 107 | { |
| 108 | return compare(other) == 0; |
| 109 | } |
| 110 | |
| 111 | inline bool SurfaceSize::operator!=(const SurfaceSize& other) const |
| 112 | { |
| 113 | return compare(other) != 0; |
| 114 | } |
| 115 | |
| 116 | inline bool SurfaceSize::operator>=(const SurfaceSize& other) const |
| 117 | { |
| 118 | return compare(other) >= 0; |
| 119 | } |
| 120 | |
| 121 | inline bool SurfaceSize::operator>(const SurfaceSize& other) const |
| 122 | { |
| 123 | return compare(other) > 0; |
| 124 | } |
| 125 | |
| 126 | }; |
| 127 | |
| 128 | #endif |