2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
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)
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
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
23 /* $XConsortium: iljpgutil.c /main/3 1995/10/23 15:57:43 rswiston $ */
24 /**---------------------------------------------------------------------
26 *** (c)Copyright 1992 Hewlett-Packard Co.
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).
38 ***-------------------------------------------------------------------*/
43 /* JPEG zigzag scanning order */
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
57 /* -------------------- _iljpgValidPars -------------------------- */
58 /* Validate the given parameter block and return true iff valid.
61 iljpgBool _iljpgValidPars (
66 iljpgCompDataPtr pCompData;
68 #define VALID_FACTOR(_f) ( ((_f) == 1) || ((_f) == 2) || ((_f) == 4) )
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))
80 for (comp = 0, pCompData = pData->comp; comp < pData->nComps; comp++, pCompData++) {
81 if (!VALID_FACTOR (pCompData->horiFactor)
82 || !VALID_FACTOR (pCompData->vertFactor))
84 index = (unsigned int)pCompData->QTableIndex;
85 if ((index > 3) || !pData->QTables[index])
87 index = (unsigned int)pCompData->DCTableIndex;
88 if ((index > 3) || !pData->DCTables[index])
90 index = (unsigned int)pCompData->ACTableIndex;
91 if ((index > 3) || !pData->ACTables[index])