libhwjpeg: resolve compilation errors
[GitHub/LineageOS/android_hardware_samsung_slsi_exynos.git] / libscaler / libscaler-common.h
1 /*
2 * Copyright (C) 2014 The Android Open Source Project
3 * Copyright@ Samsung Electronics Co. LTD
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 /*!
19 * \file libscaler-common.h
20 * \brief source file for Scaler HAL
21 * \author Cho KyongHo <pullip.cho@samsung.com>
22 * \date 2014/05/08
23 *
24 * <b>Revision History: </b>
25 * - 2014.05.08 : Cho KyongHo (pullip.cho@samsung.com) \n
26 * Create
27 */
28 #ifndef _LIBSCALER_COMMON_H_
29 #define _LIBSCALER_COMMON_H_
30
31 #define LOG_TAG "libexynosscaler"
32 #include <cutils/log.h>
33 #include <cerrno>
34 #include <cstring>
35
36 //#define LOG_NDEBUG 0
37
38 #ifdef __GNUC__
39 # define __UNUSED__ __attribute__((__unused__))
40 #else
41 # define __UNUSED__
42 #endif
43
44 #define SC_LOGERR(fmt, args...) ((void)ALOG(LOG_ERROR, LOG_TAG, "%s: " fmt " [%s]", __func__, ##args, strerror(errno)))
45 #define SC_LOGE(fmt, args...) ((void)ALOG(LOG_ERROR, LOG_TAG, "%s: " fmt, __func__, ##args))
46 #define SC_LOGI(fmt, args...) ((void)ALOG(LOG_INFO, LOG_TAG, "%s: " fmt, __func__, ##args))
47 #define SC_LOGI_IF(cond, fmt, args...) do { \
48 if (cond) \
49 SC_LOGI(fmt, ##args); \
50 } while (0)
51 #define SC_LOGE_IF(cond, fmt, args...) do { \
52 if (cond) \
53 SC_LOGE(fmt, ##args); \
54 } while (0)
55 #define SC_LOG_ASSERT(cont, fmt, args...) ((void)ALOG_ASSERT(cond, "%s: " fmt, __func__, ##args))
56
57 #ifdef SC_DEBUG
58 #define SC_LOGD(args...) ((void)ALOG(LOG_INFO, LOG_TAG, ##args))
59 #define SC_LOGD_IF(cond, fmt, args...) do { \
60 if (cond) \
61 SC_LOGD(fmt, ##args); \
62 } while (0)
63 #else
64 #define SC_LOGD(args...) do { } while (0)
65 #define SC_LOGD_IF(cond, fmt, args...) do { } while (0)
66 #endif
67
68 #define ARRSIZE(arr) (sizeof(arr)/sizeof(arr[0]))
69
70
71
72 namespace LibScaler {
73 template <typename T>
74 static inline T min (T a, T b) {
75 return (a > b) ? b : a;
76 }
77
78 template <typename T>
79 static inline void swap(T &a, T &b) {
80 T __unused t = a;
81 a = b;
82 b = a;
83 }
84
85 static inline bool UnderOne16thScaling(unsigned int srcw, unsigned int srch,
86 unsigned int dstw, unsigned int dsth, unsigned int rot) {
87 if ((rot == 90) || (rot == 270))
88 swap(srcw, srch);
89
90 return ((srcw > (dstw * 16)) || (srch > (dsth * 16)));
91 }
92
93 };
94 // marker for output parameters
95 #define __out
96
97 #endif //_LIBSCALER_COMMON_H_