lib/DtHelp/il: remove register keyword
[oweals/cde.git] / cde / lib / DtHelp / il / iljpgutil.c
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these libraries and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: iljpgutil.c /main/3 1995/10/23 15:57:43 rswiston $ */
24 /**---------------------------------------------------------------------
25 ***     
26 ***    (c)Copyright 1992 Hewlett-Packard Co.
27 ***    
28 ***                             RESTRICTED RIGHTS LEGEND
29 ***    Use, duplication, or disclosure by the U.S. Government is subject to
30 ***    restrictions as set forth in sub-paragraph (c)(1)(ii) of the Rights in
31 ***    Technical Data and Computer Software clause in DFARS 252.227-7013.
32 ***                             Hewlett-Packard Company
33 ***                             3000 Hanover Street
34 ***                             Palo Alto, CA 94304 U.S.A.
35 ***    Rights for non-DOD U.S. Government Departments and Agencies are as set
36 ***    forth in FAR 52.227-19(c)(1,2).
37 ***
38 ***-------------------------------------------------------------------*/
39
40 #include "iljpgint.h"
41
42
43     /* JPEG zigzag scanning order */
44     ILJPG_PRIVATE
45 int _iljpgZigzagTable[64] = {
46  0, 1, 5, 6,14,15,27,28,
47  2, 4, 7,13,16,26,29,42,
48  3, 8,12,17,25,30,41,43,
49  9,11,18,24,31,40,44,53,
50 10,19,23,32,39,45,52,54,
51 20,22,33,38,46,51,55,60,
52 21,34,37,47,50,56,59,61,
53 35,36,48,49,57,58,62,63
54 };
55
56
57     /*  -------------------- _iljpgValidPars -------------------------- */
58     /*  Validate the given parameter block and return true iff valid.
59     */
60     ILJPG_PRIVATE
61 iljpgBool _iljpgValidPars (
62     iljpgDataPtr pData
63     )
64 {
65     int                 comp;
66     iljpgCompDataPtr    pCompData;
67     unsigned int   index;
68 #define VALID_FACTOR(_f) ( ((_f) == 1) || ((_f) == 2) || ((_f) == 4) )
69
70         /*  Validate *pData: valid hori/vertFactor, tables present, etc. */
71     if ((pData->nComps <= 0) 
72      || (pData->nComps > ILJPG_MAX_COMPS)
73      || (pData->nComps > ILJPG_MAX_COMPS)
74      || !VALID_FACTOR (pData->maxHoriFactor)
75      || !VALID_FACTOR (pData->maxVertFactor)
76      || (pData->width <= 0)
77      || (pData->height <= 0))
78         return FALSE;
79
80     for (comp = 0, pCompData = pData->comp; comp < pData->nComps; comp++, pCompData++) {
81         if (!VALID_FACTOR (pCompData->horiFactor)
82          || !VALID_FACTOR (pCompData->vertFactor))
83             return FALSE;
84         index = (unsigned int)pCompData->QTableIndex;
85         if ((index > 3) || !pData->QTables[index])
86             return FALSE;
87         index = (unsigned int)pCompData->DCTableIndex;
88         if ((index > 3) || !pData->DCTables[index])
89             return FALSE;
90         index = (unsigned int)pCompData->ACTableIndex;
91         if ((index > 3) || !pData->ACTables[index])
92             return FALSE;
93         }
94
95     return TRUE;
96 }
97
98