Skip to content

Commit db9f27d

Browse files
committed
Version 1.0.0
0 parents  commit db9f27d

26 files changed

+6025
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.o

README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# neon_scalers
2+
3+
Implementation of various scalers with following properties:
4+
- written in pure assembler
5+
- uses ARMv7 and NEON instructions
6+
- uses instruction scheduling for Cortex-A8 processors
7+
- no checking for corectness of parameters
8+
- no clipping
9+
- MIT license
10+
11+
12+
The scaler function definitions are in the header files in the include directory.<br/>
13+
Compiled libaries (static and shared) are in the lib directory.
14+
15+
16+
##Description of scaler function names
17+
neon_NAME_SP_DP
18+
19+
where NAME is the scaler name,<br/>
20+
SP is the number of bits per source pixel,<br/>
21+
DP is the number of bits per destination pixel
22+
23+
list of values:<br/>
24+
NAME: normal1x, normal2x, normal3x, normal4x, scale2x, scale3x, scale4x, eagle2x<br/>
25+
SP->DP: 8->8, 8->16, 16->16
26+
27+
28+
##Description of scaler function parameters
29+
**src**<br/>
30+
pointer to the first source pixel<br/>
31+
if bits per source pixel is 16 then src must be aligned to 16 bits (2 bytes)<br/>
32+
**dst**<br/>
33+
pointer to the first destination pixel<br/>
34+
if bits per destination pixel is 16 then dst must be aligned to 16 bits (2 bytes)<br/>
35+
**palette**<br/>
36+
pointer to an array of 256 32-bit values<br/>
37+
upper 16 bits of every value must be zero<br/>
38+
must be aligned to 32 bits (4 bytes)<br/>
39+
**width**<br/>
40+
width of the source image (in pixels)<br/>
41+
minimum width is 32<br/>
42+
**srcstride**<br/>
43+
stride of the source image (in bytes) = distance between two lines in the source image<br/>
44+
**dststride**<br/>
45+
stride of the destination image (in bytes) = distance between two lines in the destination image<br/>
46+
**height**<br/>
47+
height of the source image<br/>
48+
minimum height is 3
49+
50+
51+
##Example
52+
Scaling 320x200 image (16-bits per pixel) using scale2x to the center of a 800x480 frame
53+
54+
```c_cpp
55+
uint16_t src[320*200];
56+
uint16_t dst[800x480];
57+
58+
neon_scale2x_16_16(&(src[0]), &(dst[((480 - 2*200) / 2) * 800 + (800 - 320 * 2) / 2]), 320, 320*2, 800*2, 200);
59+
```

benchmark.txt

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
Benchmarking was done on Pandora at stock speed - 600 MHz
2+
3+
Benchmark consists of 60000 calls to scaler function with following parameter combinations:
4+
Source width (pixels): (varying) 305 - 320
5+
Source height: 240
6+
Source alignment (modulo 16): (varying) 0 - 15
7+
8+
Results:
9+
|Total |Time per |Calls per |Cycles per
10+
Scaler function |time (s) |call (ms)|second |source pixel
11+
--------------------|---------|---------|----------|------------
12+
neon_normal1x_8_8 | 18.524 | 0.309 | 3239.041 | 2.470
13+
neon_normal1x_16_16 | 40.422 | 0.674 | 1484.340 | 5.390
14+
neon_normal1x_8_16 | 31.516 | 0.525 | 1903.795 | 4.202
15+
--------------------|---------|---------|----------|------------
16+
neon_normal2x_8_8 | 52.414 | 0.874 | 1144.732 | 6.989
17+
neon_normal2x_16_16 | 101.016 | 1.684 | 593.965 | 13.469
18+
neon_normal2x_8_16 | 87.836 | 1.464 | 683.091 | 11.711
19+
--------------------|---------|---------|----------|------------
20+
neon_normal3x_8_8 | 108.157 | 1.803 | 554.749 | 14.421
21+
neon_normal3x_16_16 | 211.363 | 3.523 | 283.872 | 28.182
22+
neon_normal3x_8_16 | 193.407 | 3.223 | 310.227 | 25.788
23+
--------------------|---------|---------|----------|------------
24+
neon_normal4x_8_8 | 170.703 | 2.845 | 351.488 | 22.760
25+
neon_normal4x_16_16 | 322.047 | 5.367 | 186.308 | 42.940
26+
neon_normal4x_8_16 | 301.430 | 5.024 | 199.051 | 40.191
27+
--------------------|---------|---------|----------|------------
28+
neon_scale2x_8_8 | 52.141 | 0.869 | 1150.726 | 6.952
29+
neon_scale2x_16_16 | 100.641 | 1.677 | 596.178 | 13.419
30+
neon_scale2x_8_16 | 122.594 | 2.043 | 489.420 | 16.346
31+
--------------------|---------|---------|----------|------------
32+
neon_scale3x_8_8 | 129.516 | 2.159 | 463.263 | 17.269
33+
neon_scale3x_16_16 | 255.836 | 4.264 | 234.525 | 34.111
34+
neon_scale3x_8_16 | 272.914 | 4.549 | 219.849 | 36.389
35+
--------------------|---------|---------|----------|------------
36+
neon_scale4x_8_8 | 217.157 | 3.619 | 276.298 | 28.954
37+
neon_scale4x_16_16 | 404.563 | 6.743 | 148.308 | 53.942
38+
neon_scale4x_8_16 | 403.852 | 6.731 | 148.569 | 53.847
39+
--------------------|---------|---------|----------|------------
40+
neon_eagle2x_8_8 | 53.368 | 0.889 | 1124.269 | 7.116
41+
neon_eagle2x_16_16 | 104.555 | 1.743 | 573.861 | 13.941
42+
neon_eagle2x_8_16 | 123.930 | 2.066 | 484.144 | 16.524
43+
----------------------------------------------------------------

compile.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# create static library
2+
$PNDSDK/bin/arm-none-linux-gnueabi-gcc -Os -pipe -march=armv7-a -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp -std=c99 -Wall -c *.S
3+
$PNDSDK/bin/arm-none-linux-gnueabi-ar -cqs lib/libneon_scalers.a *.o
4+
rm *.o
5+
6+
# create shared library
7+
$PNDSDK/bin/arm-none-linux-gnueabi-gcc -Os -pipe -march=armv7-a -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp -std=c99 -Wall -fPIC -c *.S
8+
$PNDSDK/bin/arm-none-linux-gnueabi-gcc -shared -Wl,-soname,libneon_scalers.so.1 -o lib/libneon_scalers.so.1.0 *.o
9+
ln -sf libneon_scalers.so.1.0 lib/libneon_scalers.so
10+
ln -sf libneon_scalers.so.1.0 lib/libneon_scalers.so.1
11+
rm *.o

include/neon_eagle2x.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
*
3+
* Copyright (C) 2012 Roman Pauer
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
* this software and associated documentation files (the "Software"), to deal in
7+
* the Software without restriction, including without limitation the rights to
8+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9+
* of the Software, and to permit persons to whom the Software is furnished to do
10+
* so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in all
13+
* copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
* SOFTWARE.
22+
*
23+
*/
24+
25+
#if !defined(_NEON_EAGLE2X_H_INCLUDED_)
26+
#define _NEON_EAGLE2X_H_INCLUDED_
27+
28+
#include <inttypes.h>
29+
30+
#ifdef __cplusplus
31+
extern "C" {
32+
#endif
33+
34+
extern void neon_eagle2x_8_8(const uint8_t *src, uint8_t *dst, unsigned int width, unsigned int srcstride, unsigned int dststride, unsigned int height);
35+
extern void neon_eagle2x_16_16(const uint16_t *src, uint16_t *dst, unsigned int width, unsigned int srcstride, unsigned int dststride, unsigned int height);
36+
37+
extern void neon_eagle2x_8_16(const uint8_t *src, uint16_t *dst, const uint32_t *palette, unsigned int width, unsigned int srcstride, unsigned int dststride, unsigned int height);
38+
39+
#ifdef __cplusplus
40+
}
41+
#endif
42+
43+
44+
#endif /* _NEON_EAGLE2X_H_INCLUDED_ */

include/neon_normal1x.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
*
3+
* Copyright (C) 2012 Roman Pauer
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
* this software and associated documentation files (the "Software"), to deal in
7+
* the Software without restriction, including without limitation the rights to
8+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9+
* of the Software, and to permit persons to whom the Software is furnished to do
10+
* so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in all
13+
* copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
* SOFTWARE.
22+
*
23+
*/
24+
25+
#if !defined(_NEON_NORMAL1X_H_INCLUDED_)
26+
#define _NEON_NORMAL1X_H_INCLUDED_
27+
28+
#include <inttypes.h>
29+
30+
#ifdef __cplusplus
31+
extern "C" {
32+
#endif
33+
34+
extern void neon_normal1x_8_8(const uint8_t *src, uint8_t *dst, unsigned int width, unsigned int srcstride, unsigned int dststride, unsigned int height);
35+
extern void neon_normal1x_16_16(const uint16_t *src, uint16_t *dst, unsigned int width, unsigned int srcstride, unsigned int dststride, unsigned int height);
36+
37+
extern void neon_normal1x_8_16(const uint8_t *src, uint16_t *dst, const uint32_t *palette, unsigned int width, unsigned int srcstride, unsigned int dststride, unsigned int height);
38+
39+
#ifdef __cplusplus
40+
}
41+
#endif
42+
43+
44+
#endif /* _NEON_NORMAL1X_H_INCLUDED_ */

include/neon_normal2x.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
*
3+
* Copyright (C) 2012 Roman Pauer
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
* this software and associated documentation files (the "Software"), to deal in
7+
* the Software without restriction, including without limitation the rights to
8+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9+
* of the Software, and to permit persons to whom the Software is furnished to do
10+
* so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in all
13+
* copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
* SOFTWARE.
22+
*
23+
*/
24+
25+
#if !defined(_NEON_NORMAL2X_H_INCLUDED_)
26+
#define _NEON_NORMAL2X_H_INCLUDED_
27+
28+
#include <inttypes.h>
29+
30+
#ifdef __cplusplus
31+
extern "C" {
32+
#endif
33+
34+
extern void neon_normal2x_8_8(const uint8_t *src, uint8_t *dst, unsigned int width, unsigned int srcstride, unsigned int dststride, unsigned int height);
35+
extern void neon_normal2x_16_16(const uint16_t *src, uint16_t *dst, unsigned int width, unsigned int srcstride, unsigned int dststride, unsigned int height);
36+
37+
extern void neon_normal2x_8_16(const uint8_t *src, uint16_t *dst, const uint32_t *palette, unsigned int width, unsigned int srcstride, unsigned int dststride, unsigned int height);
38+
39+
#ifdef __cplusplus
40+
}
41+
#endif
42+
43+
44+
#endif /* _NEON_NORMAL2X_H_INCLUDED_ */

include/neon_normal3x.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
*
3+
* Copyright (C) 2012 Roman Pauer
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
* this software and associated documentation files (the "Software"), to deal in
7+
* the Software without restriction, including without limitation the rights to
8+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9+
* of the Software, and to permit persons to whom the Software is furnished to do
10+
* so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in all
13+
* copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
* SOFTWARE.
22+
*
23+
*/
24+
25+
#if !defined(_NEON_NORMAL3X_H_INCLUDED_)
26+
#define _NEON_NORMAL3X_H_INCLUDED_
27+
28+
#include <inttypes.h>
29+
30+
#ifdef __cplusplus
31+
extern "C" {
32+
#endif
33+
34+
extern void neon_normal3x_8_8(const uint8_t *src, uint8_t *dst, unsigned int width, unsigned int srcstride, unsigned int dststride, unsigned int height);
35+
extern void neon_normal3x_16_16(const uint16_t *src, uint16_t *dst, unsigned int width, unsigned int srcstride, unsigned int dststride, unsigned int height);
36+
37+
extern void neon_normal3x_8_16(const uint8_t *src, uint16_t *dst, const uint32_t *palette, unsigned int width, unsigned int srcstride, unsigned int dststride, unsigned int height);
38+
39+
#ifdef __cplusplus
40+
}
41+
#endif
42+
43+
44+
#endif /* _NEON_NORMAL3X_H_INCLUDED_ */

include/neon_normal4x.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
*
3+
* Copyright (C) 2012 Roman Pauer
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
* this software and associated documentation files (the "Software"), to deal in
7+
* the Software without restriction, including without limitation the rights to
8+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9+
* of the Software, and to permit persons to whom the Software is furnished to do
10+
* so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in all
13+
* copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
* SOFTWARE.
22+
*
23+
*/
24+
25+
#if !defined(_NEON_NORMAL4X_H_INCLUDED_)
26+
#define _NEON_NORMAL4X_H_INCLUDED_
27+
28+
#include <inttypes.h>
29+
30+
#ifdef __cplusplus
31+
extern "C" {
32+
#endif
33+
34+
extern void neon_normal4x_8_8(const uint8_t *src, uint8_t *dst, unsigned int width, unsigned int srcstride, unsigned int dststride, unsigned int height);
35+
extern void neon_normal4x_16_16(const uint16_t *src, uint16_t *dst, unsigned int width, unsigned int srcstride, unsigned int dststride, unsigned int height);
36+
37+
extern void neon_normal4x_8_16(const uint8_t *src, uint16_t *dst, const uint32_t *palette, unsigned int width, unsigned int srcstride, unsigned int dststride, unsigned int height);
38+
39+
#ifdef __cplusplus
40+
}
41+
#endif
42+
43+
44+
#endif /* _NEON_NORMAL4X_H_INCLUDED_ */

include/neon_scale2x.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
*
3+
* Copyright (C) 2012 Roman Pauer
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
* this software and associated documentation files (the "Software"), to deal in
7+
* the Software without restriction, including without limitation the rights to
8+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9+
* of the Software, and to permit persons to whom the Software is furnished to do
10+
* so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in all
13+
* copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
* SOFTWARE.
22+
*
23+
*/
24+
25+
#if !defined(_NEON_SCALE2X_H_INCLUDED_)
26+
#define _NEON_SCALE2X_H_INCLUDED_
27+
28+
#include <inttypes.h>
29+
30+
#ifdef __cplusplus
31+
extern "C" {
32+
#endif
33+
34+
extern void neon_scale2x_8_8(const uint8_t *src, uint8_t *dst, unsigned int width, unsigned int srcstride, unsigned int dststride, unsigned int height);
35+
extern void neon_scale2x_16_16(const uint16_t *src, uint16_t *dst, unsigned int width, unsigned int srcstride, unsigned int dststride, unsigned int height);
36+
37+
extern void neon_scale2x_8_16(const uint8_t *src, uint16_t *dst, const uint32_t *palette, unsigned int width, unsigned int srcstride, unsigned int dststride, unsigned int height);
38+
39+
#ifdef __cplusplus
40+
}
41+
#endif
42+
43+
44+
#endif /* _NEON_SCALE2X_H_INCLUDED_ */

0 commit comments

Comments
 (0)