English | 中文文档
@think3r
2019-08-18 20:45:21
Reference:
Accelerate the following two multimedia OSD character overlay functions through neon technology under the arm platform :
-
Expand
1bit
dot-matrix-fonts(bitmap-fonts) to8bit
/16bit
; -
Render dot matrix fonts on several
YUV
formats;
- NEON-Accelerate :
- Dot-matrix(1bit) expanded to
1Byte
and2Byte
;- The output of
2Byte
can be any value, such asARGB1555, ARGB4444, RGB565
etc.
- The output of
- Draw OSD directly on the following YUV format :
YUV420
support :I420
,YV12
,NV12
,NV21
;YUV422
support :YUYV
,UYVY
;
- Dot-matrix(1bit) expanded to
- Support character types :
- ASCII, base size
8x16
; - Chinese (
HZK16
), base size16*16
;
- ASCII, base size
- Support character specifications:
- Dot-matrix expanded :
1Byte
:x2
,x4
;TODO : x1, x3
2Byte
:x1, x2, x3, x4
, contains two implementations:- Normal cpu expanded : @
./osd_Draw/cpu_osd.c
- Arm-neon cpu expanded with neon (Performance optimized) : @
./osd_Draw/neon_osd.c
- Normal cpu expanded : @
- YUV-OSD-Overlay :
x2, x4
;- Does not support
x1
&x3
, because YUV420 sampling 1/2 on horizontal and vertical ;
- Does not support
- Dot-matrix expanded :
./
├── CMakeLists.txt # 分离的 cmake : 上层文件;
├── CMakeLists_one.txt # 单独的 Cmake 文件(完整);
├── build # cmake 构建文件夹
├── demo
│ ├── ASCII8 #英文字库
│ ├── CMakeLists.txt # 分离的 cmake : demo 编译文件;
│ ├── HZK16 #汉字字库 GB2312
│ ├── inc
│ │ ├── build_time.h
│ │ ├── common.h
│ │ ├── neon_intrinsics_test.h
│ │ └── osd_test.h
│ ├── Makefile
│ ├── Makefile.android.clang #高版本 ndk
│ ├── Makefile.android.gcc #低版本 ndk
│ └── src
│ ├── build_time.c
│ ├── neon_intrinsics_test.c #noen 内嵌函数测试, 与本项目无关
│ ├── osd_test.c
│ └── test.c
└── osd_Draw
├── CMakeLists.txt # 分离的 cmake : 库文件编译;
├── cpu_osd.c #cpu 拓展 osd 字符点阵, 仅支持 u16
├── cpu_osd.h
├── neon_osd.c #neon 加速实现 : 拓展 osd 字符点阵和 yuv 绘制字符
├── neon_osd.h
├── osd_base.c #初始化相关
└── osd_base.h
-
The following three compilation methods are provided:
- Makefile base on
ndk-r20+ clang
-->Makefile.android.clang
;- To compile
@64bit
version;
- To compile
- Makefile base on
ndk-r10e gcc
-->Makefile.android.gcc
;- To compile
@32bit
version;
- To compile
- CMake -->
CMakeLists.txt
和CMakeLists_one.txt
- To compile
@32bit
version;
- To compile
- Makefile base on
-
Build steps (take the
clang
compilation ofndk-r20
as an example) :- Open the content you want to test in
test.c
:test_CreatOsdDot_u16_func()
---> u16 dot-expand;test_DrawOsd_YUV_func()
---> yuv superimposed osd character test;
- Pick Makefile :
cp Makefile.android.clang Makefile
vi Makefile
and changndk-r20
path;make clean && make
- Send the executable-binary and necessary yuv files to the phone, then run
./osd_demo
- Open the content you want to test in
-
u8
和u16
点阵简易查看方式:beyond Compare 4
:- 16 进制比较生成的两个 bin 文件
osdOut.bin
和osdOut_copy.bin
(文件内容相同); 视图
->布局
中的 每组字节数, 配置为程序运行输出的pitch
值; 如下图所示:
- 16 进制比较生成的两个 bin 文件
-
yuv-overlay example:
-
Test data size :
256,0000
-
Compiler optimization level :
-O2
-
Test phone :
xiaomi-6
,Snapdragon-835
Redmi K30 Pro
,Snapdragon-865
-
Phone environment:
termux
-
Compiler:
ndk-r20-clang @ununtu
-
The test procedure is
@64bit
; -
result
835
:front scale cpu all cpu average neon all neon average 8 * 16 433 ms 0.169 us 132 ms 0.052 us 16 * 32 1206 ms 0.471 us 341 ms 0.133 us 24 * 48 2164 ms 0.845 us 565 ms 0.221 us 32 * 64 2686 ms 1.049 us 861 ms 0.334 us -
result
865
:front scale cpu all cpu average neon all neon average 16 * 32 490 ms 0.191 us 113 ms 0.044 us