Skip to content

Commit

Permalink
Version 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
M-HT committed Apr 29, 2015
0 parents commit db9f27d
Show file tree
Hide file tree
Showing 26 changed files with 6,025 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.o
59 changes: 59 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# neon_scalers

Implementation of various scalers with following properties:
- written in pure assembler
- uses ARMv7 and NEON instructions
- uses instruction scheduling for Cortex-A8 processors
- no checking for corectness of parameters
- no clipping
- MIT license


The scaler function definitions are in the header files in the include directory.<br/>
Compiled libaries (static and shared) are in the lib directory.


##Description of scaler function names
neon_NAME_SP_DP

where NAME is the scaler name,<br/>
SP is the number of bits per source pixel,<br/>
DP is the number of bits per destination pixel

list of values:<br/>
NAME: normal1x, normal2x, normal3x, normal4x, scale2x, scale3x, scale4x, eagle2x<br/>
SP->DP: 8->8, 8->16, 16->16


##Description of scaler function parameters
**src**<br/>
pointer to the first source pixel<br/>
if bits per source pixel is 16 then src must be aligned to 16 bits (2 bytes)<br/>
**dst**<br/>
pointer to the first destination pixel<br/>
if bits per destination pixel is 16 then dst must be aligned to 16 bits (2 bytes)<br/>
**palette**<br/>
pointer to an array of 256 32-bit values<br/>
upper 16 bits of every value must be zero<br/>
must be aligned to 32 bits (4 bytes)<br/>
**width**<br/>
width of the source image (in pixels)<br/>
minimum width is 32<br/>
**srcstride**<br/>
stride of the source image (in bytes) = distance between two lines in the source image<br/>
**dststride**<br/>
stride of the destination image (in bytes) = distance between two lines in the destination image<br/>
**height**<br/>
height of the source image<br/>
minimum height is 3


##Example
Scaling 320x200 image (16-bits per pixel) using scale2x to the center of a 800x480 frame

```c_cpp
uint16_t src[320*200];
uint16_t dst[800x480];
neon_scale2x_16_16(&(src[0]), &(dst[((480 - 2*200) / 2) * 800 + (800 - 320 * 2) / 2]), 320, 320*2, 800*2, 200);
```
43 changes: 43 additions & 0 deletions benchmark.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Benchmarking was done on Pandora at stock speed - 600 MHz

Benchmark consists of 60000 calls to scaler function with following parameter combinations:
Source width (pixels): (varying) 305 - 320
Source height: 240
Source alignment (modulo 16): (varying) 0 - 15

Results:
|Total |Time per |Calls per |Cycles per
Scaler function |time (s) |call (ms)|second |source pixel
--------------------|---------|---------|----------|------------
neon_normal1x_8_8 | 18.524 | 0.309 | 3239.041 | 2.470
neon_normal1x_16_16 | 40.422 | 0.674 | 1484.340 | 5.390
neon_normal1x_8_16 | 31.516 | 0.525 | 1903.795 | 4.202
--------------------|---------|---------|----------|------------
neon_normal2x_8_8 | 52.414 | 0.874 | 1144.732 | 6.989
neon_normal2x_16_16 | 101.016 | 1.684 | 593.965 | 13.469
neon_normal2x_8_16 | 87.836 | 1.464 | 683.091 | 11.711
--------------------|---------|---------|----------|------------
neon_normal3x_8_8 | 108.157 | 1.803 | 554.749 | 14.421
neon_normal3x_16_16 | 211.363 | 3.523 | 283.872 | 28.182
neon_normal3x_8_16 | 193.407 | 3.223 | 310.227 | 25.788
--------------------|---------|---------|----------|------------
neon_normal4x_8_8 | 170.703 | 2.845 | 351.488 | 22.760
neon_normal4x_16_16 | 322.047 | 5.367 | 186.308 | 42.940
neon_normal4x_8_16 | 301.430 | 5.024 | 199.051 | 40.191
--------------------|---------|---------|----------|------------
neon_scale2x_8_8 | 52.141 | 0.869 | 1150.726 | 6.952
neon_scale2x_16_16 | 100.641 | 1.677 | 596.178 | 13.419
neon_scale2x_8_16 | 122.594 | 2.043 | 489.420 | 16.346
--------------------|---------|---------|----------|------------
neon_scale3x_8_8 | 129.516 | 2.159 | 463.263 | 17.269
neon_scale3x_16_16 | 255.836 | 4.264 | 234.525 | 34.111
neon_scale3x_8_16 | 272.914 | 4.549 | 219.849 | 36.389
--------------------|---------|---------|----------|------------
neon_scale4x_8_8 | 217.157 | 3.619 | 276.298 | 28.954
neon_scale4x_16_16 | 404.563 | 6.743 | 148.308 | 53.942
neon_scale4x_8_16 | 403.852 | 6.731 | 148.569 | 53.847
--------------------|---------|---------|----------|------------
neon_eagle2x_8_8 | 53.368 | 0.889 | 1124.269 | 7.116
neon_eagle2x_16_16 | 104.555 | 1.743 | 573.861 | 13.941
neon_eagle2x_8_16 | 123.930 | 2.066 | 484.144 | 16.524
----------------------------------------------------------------
11 changes: 11 additions & 0 deletions compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# create static library
$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
$PNDSDK/bin/arm-none-linux-gnueabi-ar -cqs lib/libneon_scalers.a *.o
rm *.o

# create shared library
$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
$PNDSDK/bin/arm-none-linux-gnueabi-gcc -shared -Wl,-soname,libneon_scalers.so.1 -o lib/libneon_scalers.so.1.0 *.o
ln -sf libneon_scalers.so.1.0 lib/libneon_scalers.so
ln -sf libneon_scalers.so.1.0 lib/libneon_scalers.so.1
rm *.o
44 changes: 44 additions & 0 deletions include/neon_eagle2x.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
*
* Copyright (C) 2012 Roman Pauer
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/

#if !defined(_NEON_EAGLE2X_H_INCLUDED_)
#define _NEON_EAGLE2X_H_INCLUDED_

#include <inttypes.h>

#ifdef __cplusplus
extern "C" {
#endif

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);
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);

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);

#ifdef __cplusplus
}
#endif


#endif /* _NEON_EAGLE2X_H_INCLUDED_ */
44 changes: 44 additions & 0 deletions include/neon_normal1x.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
*
* Copyright (C) 2012 Roman Pauer
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/

#if !defined(_NEON_NORMAL1X_H_INCLUDED_)
#define _NEON_NORMAL1X_H_INCLUDED_

#include <inttypes.h>

#ifdef __cplusplus
extern "C" {
#endif

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);
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);

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);

#ifdef __cplusplus
}
#endif


#endif /* _NEON_NORMAL1X_H_INCLUDED_ */
44 changes: 44 additions & 0 deletions include/neon_normal2x.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
*
* Copyright (C) 2012 Roman Pauer
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/

#if !defined(_NEON_NORMAL2X_H_INCLUDED_)
#define _NEON_NORMAL2X_H_INCLUDED_

#include <inttypes.h>

#ifdef __cplusplus
extern "C" {
#endif

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);
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);

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);

#ifdef __cplusplus
}
#endif


#endif /* _NEON_NORMAL2X_H_INCLUDED_ */
44 changes: 44 additions & 0 deletions include/neon_normal3x.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
*
* Copyright (C) 2012 Roman Pauer
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/

#if !defined(_NEON_NORMAL3X_H_INCLUDED_)
#define _NEON_NORMAL3X_H_INCLUDED_

#include <inttypes.h>

#ifdef __cplusplus
extern "C" {
#endif

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);
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);

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);

#ifdef __cplusplus
}
#endif


#endif /* _NEON_NORMAL3X_H_INCLUDED_ */
44 changes: 44 additions & 0 deletions include/neon_normal4x.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
*
* Copyright (C) 2012 Roman Pauer
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/

#if !defined(_NEON_NORMAL4X_H_INCLUDED_)
#define _NEON_NORMAL4X_H_INCLUDED_

#include <inttypes.h>

#ifdef __cplusplus
extern "C" {
#endif

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);
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);

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);

#ifdef __cplusplus
}
#endif


#endif /* _NEON_NORMAL4X_H_INCLUDED_ */
44 changes: 44 additions & 0 deletions include/neon_scale2x.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
*
* Copyright (C) 2012 Roman Pauer
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/

#if !defined(_NEON_SCALE2X_H_INCLUDED_)
#define _NEON_SCALE2X_H_INCLUDED_

#include <inttypes.h>

#ifdef __cplusplus
extern "C" {
#endif

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);
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);

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);

#ifdef __cplusplus
}
#endif


#endif /* _NEON_SCALE2X_H_INCLUDED_ */
Loading

0 comments on commit db9f27d

Please sign in to comment.