Removed inlines
[liblqr.git] / lqr / lqr_base.h
blob1af4d50edea848de5176191617b5a2eb0c4f077e
1 /* LiquidRescaling Library
2 * Copyright (C) 2007-2009 Carlo Baldassi (the "Author") <carlobaldassi@gmail.com>.
3 * All Rights Reserved.
5 * This library implements the algorithm described in the paper
6 * "Seam Carving for Content-Aware Image Resizing"
7 * by Shai Avidan and Ariel Shamir
8 * which can be found at http://www.faculty.idc.ac.il/arik/imret.pdf
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as published by
12 * the Free Software Foundation; version 3 dated June, 2007.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, see <http://www.gnu.org/licenses/>
23 #ifndef __LQR_BASE_H__
24 #define __LQR_BASE_H__
26 #define LQR_MAX_NAME_LENGTH (1024)
28 #if defined(G_OS_WIN32) && ! defined(LQR_DISABLE_DECLSPEC)
29 # ifdef LQR_EXPORTS
30 # define LQR_PUBLIC __declspec(dllexport)
31 # else
32 # define LQR_PUBLIC __declspec(dllimport)
33 # endif /* LQR_EXPORTS */
34 #elif defined(__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
35 # ifndef GCC_HASCLASSVISIBILITY
36 # define GCC_HASCLASSVISIBILITY
37 # endif /* !GCC_HASCLASSVISIBILITY */
38 # ifdef GCC_HASCLASSVISIBILITY
39 # define LQR_PUBLIC __attribute__((visibility("default")))
40 # else
41 # define LQR_PUBLIC
42 # endif /* GCC_HASCLASSVISIBILITY */
43 #else
44 # define LQR_PUBLIC
45 #endif /* G_OS_WIN32 */
47 #if 0
48 #define __LQR_DEBUG__
49 #endif
51 #if 0
52 #define __LQR_VERBOSE__
53 #endif
55 /**** RETURN VALUES (signals) ****/
56 enum _LqrRetVal {
57 LQR_ERROR, /* generic error */
58 LQR_OK, /* ok */
59 LQR_NOMEM, /* not enough memory */
60 LQR_USRCANCEL /* action cancelled by user */
63 typedef enum _LqrRetVal LqrRetVal;
65 #define LQR_TRY_N_N(assign) if ((assign) == NULL) { return NULL; }
67 #define LQR_TRY_F_N(assign) if ((assign) == FALSE) { return NULL; }
68 #define LQR_TRY_N_F(assign) if ((assign) == NULL) { return FALSE; }
69 #define LQR_TRY_F_F(assign) if ((assign) == FALSE) { return FALSE; }
72 /* generic signal processing macros */
73 #define LQR_CATCH(expr) G_STMT_START { \
74 LqrRetVal ret_val; \
75 if ((ret_val = (expr)) != LQR_OK) \
76 { \
77 return ret_val; \
78 } \
79 } G_STMT_END
81 /* convert a NULL assignment to an error signal */
82 #define LQR_CATCH_MEM(expr) G_STMT_START { \
83 if ((expr) == NULL) \
84 { \
85 return LQR_NOMEM; \
86 } \
87 } G_STMT_END
89 /* convert a boolean value to an error signal */
90 #define LQR_CATCH_F(expr) G_STMT_START { \
91 if ((expr) == FALSE) \
92 { \
93 return LQR_ERROR; \
94 } \
95 } G_STMT_END
97 /* legacy */
98 #ifndef LQR_DISABLE_LEGACY_MACROS
99 # define CATCH(expr) LQR_CATCH(expr)
100 # define CATCH_MEM(expr) LQR_CATCH_MEM(expr)
101 # define CATCH_F(expr) LQR_CATCH_F(expr)
102 # define TRY_N_N(expr) LQR_TRY_N_N(expr)
103 #endif /* LQR_DISABLE_LEGACY_MACROS */
105 /**** IMAGE DEPTH ****/
106 enum _LqrColDepth {
107 LQR_COLDEPTH_8I,
108 LQR_COLDEPTH_16I,
109 LQR_COLDEPTH_32F,
110 LQR_COLDEPTH_64F
113 typedef enum _LqrColDepth LqrColDepth;
115 /**** IMAGE BASE TYPES ****/
116 typedef guchar lqr_t_8i;
117 typedef guint16 lqr_t_16i;
118 typedef gfloat lqr_t_32f;
119 typedef gdouble lqr_t_64f;
121 /**** RESIZE ORDER ****/
122 enum _LqrResizeOrder {
123 LQR_RES_ORDER_HOR,
124 LQR_RES_ORDER_VERT
127 typedef enum _LqrResizeOrder LqrResizeOrder;
129 /**** IMAGE TYPE ****/
130 enum _LqrImageType {
131 LQR_RGB_IMAGE,
132 LQR_RGBA_IMAGE,
133 LQR_GREY_IMAGE,
134 LQR_GREYA_IMAGE,
135 LQR_CMY_IMAGE,
136 LQR_CMYK_IMAGE,
137 LQR_CMYKA_IMAGE,
138 LQR_CUSTOM_IMAGE
141 typedef enum _LqrImageType LqrImageType;
143 /**** CLASSES DECLARATIONS ****/
145 struct _LqrCarver;
147 typedef struct _LqrCarver LqrCarver;
149 #endif /* __LQR_BASE_H__ */