1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
/*
ChibiOS/GFX - Copyright (C) 2012, 2013
Joel Bodenmann aka Tectu <joel@unormal.org>
This file is part of ChibiOS/GFX.
ChibiOS/GFX is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
ChibiOS/GFX is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file include/gmisc/gmisc.h
* @brief GMISC - Miscellaneous Routines header file.
*
* @addtogroup GAUDIN
*
* @{
*/
#ifndef _GMISC_H
#define _GMISC_H
#include "gfx.h"
/*===========================================================================*/
/* Type definitions */
/*===========================================================================*/
/**
* @brief Sample data formats
* @note These are defined regardless of whether you use the GMISC module
* or not as they are used in lots of places.
*/
typedef enum ArrayDataFormat_e {
ARRAY_DATA_4BITUNSIGNED = 4, ARRAY_DATA_4BITSIGNED = 5,
ARRAY_DATA_8BITUNSIGNED = 8, ARRAY_DATA_8BITSIGNED = 9,
ARRAY_DATA_10BITUNSIGNED = 10, ARRAY_DATA_10BITSIGNED = 11,
ARRAY_DATA_12BITUNSIGNED = 12, ARRAY_DATA_12BITSIGNED = 13,
ARRAY_DATA_14BITUNSIGNED = 14, ARRAY_DATA_14BITSIGNED = 15,
ARRAY_DATA_16BITUNSIGNED = 16, ARRAY_DATA_16BITSIGNED = 17,
} ArrayDataFormat;
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/
#if GFX_USE_GMISC || defined(__DOXYGEN__)
#ifdef __cplusplus
extern "C" {
#endif
#if GMISC_NEED_ARRAYOPS || defined(__DOXYGEN__)
/**
* @brief Convert from one array format to another array format.
*
* @param[in] srcfmt The format of the source array
* @param[in] src The source array
* @param[in] dstfmt The format of the destination array
* @param[in] dst The dstination array
* @param[in] cnt The number of array elements to convert
*
* @note Assumes the destination buffer is large enough for the resultant data.
* @note This routine is optimised to perform as fast as possible.
* @note No type checking is performed on the source format. It is assumed to
* have only valid values eg. ARRAY_DATA_4BITSIGNED will have values
* 0000 -> 0111 for positive numbers and 1111 -> 1000 for negative numbers
* Bits 5 -> 8 in the storage byte are treated in an undefined manner.
* @note If srcfmt or dstfmt is an unknown format, this routine does nothing
* with no warning that something is wrong
*
* @api
*/
void gmiscArrayConvert(ArrayDataFormat srcfmt, void *src, ArrayDataFormat dstfmt, void *dst, size_t cnt);
#if 0
void gmiscArrayTranslate(ArrayDataFormat fmt, void *src, void *dst, size_t cnt, int trans);
void gmiscArrayMultiply(ArrayDataFormat fmt, void *src, void *dst, size_t cnt, int mult);
void gmiscArrayDivide(ArrayDataFormat fmt, void *src, void *dst, size_t cnt, int mdiv);
void gmiscArrayMultDiv(ArrayDataFormat fmt, void *src, void *dst, size_t cnt, int mult, int div);
void gmiscArrayAdd(ArrayDataFormat fmt, void *src1, void *src2, void *dst, size_t cnt);
void gmiscArrayAddNoOverflow(ArrayDataFormat fmt, void *src1, void *src2, void *dst, size_t cnt);
#endif
#endif
#ifdef __cplusplus
}
#endif
#endif /* GFX_USE_MISC */
#endif /* _GMISC_H */
/** @} */
|