1 /* libhpojip -- HP OfficeJet image-processing library. */
3 /* Copyright (C) 1995-2002 Hewlett-Packard Company
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and
13 * NON-INFRINGEMENT. See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20 * In addition, as a special exception, Hewlett-Packard Company
21 * gives permission to link the code of this program with any
22 * version of the OpenSSL library which is distributed under a
23 * license identical to that listed in the included LICENSE.OpenSSL
24 * file, and distribute linked combinations including the two.
25 * You must obey the GNU General Public License in all respects
26 * for all of the code used other than OpenSSL. If you modify
27 * this file, you may extend this exception to your version of the
28 * file, but you are not obligated to do so. If you do not wish to
29 * do so, delete this exception statement from your version.
32 /* Original author: Mark Overton and others.
34 * Ported to Linux by David Paschal.
37 /*****************************************************************************\
39 * ipdefs.h - Definitions common among image processor files
41 * Mark Overton, Jan 1998
43 \*****************************************************************************/
45 #if ! defined IPDEFS_INC
48 #ifdef EXPORT_TRANSFORM
49 #define fatalBreakPoint() assert(0);
51 extern void fatalBreakPoint(void);
54 #define INSURE(must_be_true) \
56 if (! (must_be_true)) { \
63 #define HANDLE_TO_PTR(hJob_macpar, inst_macpar) \
65 inst_macpar = (void*)hJob_macpar; \
66 INSURE (inst_macpar->dwValidChk == CHECK_VALUE); \
70 #define IP_MEM_ALLOC(nBytes_macpar, ptr_macpar) \
72 /* the weirdness below is equivalent to a type cast */ \
73 /* the 12 below is buffer-overrun allowance */ \
74 /* *(void**)&(ptr_macpar) = (void*) malloc(nBytes_macpar+12); */ \
75 (ptr_macpar) = malloc(nBytes_macpar+12); \
76 INSURE (ptr_macpar != NULL); \
80 #define IP_MEM_FREE(ptr_macpar) \
82 if (ptr_macpar != NULL) \
87 #define IP_MAX(valOne,valTwo) \
88 ((valOne)>(valTwo) ? (valOne) : (valTwo))
90 #define IP_MIN(valOne,valTwo) \
91 ((valOne)<(valTwo) ? (valOne) : (valTwo))
94 /* We use approx NTSC weights of 5/16, 9/16, 2/16 for R, G and B respectively. */
95 #define NTSC_LUMINANCE(Rval,Gval,Bval) \
96 ((((Rval)<<2) + (Rval) + ((Gval)<<3) + (Gval) + ((Bval)<<1)) >> 4)
99 /* The MUL32HIHALF macro does a signed 32x32->64 multiply, and then
100 * discards the low 32 bits, giving you the high 32 bits. The way
101 * this is done is compiler-dependent.
104 #define MUL32HIHALF(firstpar, secondpar, hihalfresult) { \
106 prod64 = (__int64)(firstpar) * (secondpar); \
107 hihalfresult = ((int*)&prod64)[1]; \
108 /* above, use a [0] for big endian */
110 #define MUL32HIHALF(firstpar, secondpar, hihalfresult) { \
111 hihalfresult = ((__int64)(firstpar) * (secondpar)) >> 32; \