blob: 1c4cedd418832a52abcb186d40d41e24ecf5f873 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26
27
28/*
29 * FUNCTION
30 * mlib_ImageConvVersion - Get Conv* funtions version
31 * 0 - "C" version
32 * 1 - "VIS" version
33 * 2 - "i386" version
34 * 3 - "MMX" version
35 *
36 * SYNOPSIS
37 * mlib_s32 mlib_ImageConvVersion(mlib_s32 m,
38 * mlib_s32 n,
39 * mlib_s32 scale,
40 * mlib_type type)
41 *
42 */
43
44#include "mlib_image.h"
45
46/***************************************************************/
47#define MAX_U8 8
48#define MAX_S16 32
49
50/***************************************************************/
51mlib_s32 mlib_ImageConvVersion(mlib_s32 m,
52 mlib_s32 n,
53 mlib_s32 scale,
54 mlib_type type)
55{
56 mlib_d64 dscale = 1.0 / (1 << scale); /* 16 < scale <= 31 */
57
58 if (type == MLIB_BYTE) {
59 if ((m * n * dscale * 32768.0 * 512.0) > MAX_U8)
60 return 0;
61 return 1;
62 }
63 else if ((type == MLIB_USHORT) || (type == MLIB_SHORT)) {
64
65 if ((m != 2) || (n != 2))
66 return 0;
67
68 if ((m * n * dscale * 32768.0 * 32768.0) > MAX_S16)
69 return 0;
70 return 1;
71 }
72 else
73 return 0;
74}
75
76/***************************************************************/