移植x264到RISC-V
安装好RISC-V工具链后。
# 移植nasm
下载地址:https://www.nasm.us/pub/nasm/releasebuilds/2.14.01/
下载nasm-2.14.01.tar.bz2
tar -jxvf nasm-2.14.01.tar.bz2
1
1
./configure --prefix=/usr/local/nasm --build=riscv64-unknown-linux-gnu
1
1
make
make install
1
2
2
1
2
2
# 移植x264
官网: x264, the best H.264/AVC encoder - VideoLAN (opens new window)
tar -jxvf x264-master.tar.bz2
1
1
./configure --prefix=/usr/local/x264 --enable-shared --enable-static --cross-prefix=riscv64-unknown-linux-gnu- --host=riscv64-unknown-linux-gnu
1
1
如果报错
checking whether riscv64-unknown-linux-gnu-gcc works... no
Failed commandline was:
--------------------------------------------------
riscv64-unknown-linux-gnu-gcc conftest.c -m64 -Wall -I. -I$(SRCPATH) -Werror=attributes -Werror=ignored-attributes -m64 -lm -o conftest
riscv64-unknown-linux-gnu-gcc: error: unrecognized command-line option '-m64'
riscv64-unknown-linux-gnu-gcc: error: unrecognized command-line option '-m64'
--------------------------------------------------
Failed program was:
--------------------------------------------------
int main (void) { return 0; }
--------------------------------------------------
DIED: No working C compiler found.
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
在configure中删除 -m64
sudo gedit ~/.bashrc
# 添加一句
export LD_LIBRARY_PATH=/xxxx/TensorRT-7.0.0.11/lib:$LD_LIBRARY_PATH
# 保存退出
source ~/.bashrc
1
2
3
4
5
2
3
4
5
1
2
3
4
5
2
3
4
5
# 测试
如果用riscv64-unknown-linux-gnu-gcc
编译
不知道为什么只能在x264文件夹下编译:
riscv64-unknown-linux-gnu-gcc demo.c -o demo -L /usr/local/x264/lib -lx264
1
1
QEMU执行
/home/jiaolong/riscvv/qemu-7.1.0/build/riscv64-linux-user/qemu-riscv64 -cpu rv64,v=true,vlen=256,vext_spec=v1.0 -L $RISCV/sysroot /home/jiaolong/x264/x264-master/demo
1
1
# 对比:
测试文件:
YUV Sequences (asu.edu) (opens new window)
2001 Frames 352x288
代码来源:(37条消息) 最简单的视频编码器:基于libx264(编码YUV为H.264)_雷霄骅的博客-CSDN博客 (opens new window)
gcc下测试
gcc demo.c -o demo -L /usr/local/x264_86/lib -lx264
1
1
root@ubuntu:/home/jiaolong/x264_86/x264-master# time ./demo
x264 [warning]: b-pyramid normal + intra-refresh is not supported
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
x264 [info]: profile High, level 2.1, 4:2:0, 8-bit
x264 [info]: frame I:433 Avg QP:28.45 size: 21940
x264 [info]: frame P:1110 Avg QP:30.57 size: 14737
x264 [info]: mb I I16..4: 24.9% 25.8% 49.3%
x264 [info]: mb P I16..4: 21.8% 15.8% 20.3% P16..4: 26.9% 7.9% 7.3% 0.0% 0.0% skip: 0.0%
x264 [info]: 8x8 transform intra:26.7% inter:35.0%
x264 [info]: coded y,uvDC,uvAC intra: 75.1% 95.1% 93.0% inter: 63.3% 100.0% 96.3%
x264 [info]: i16 v,h,dc,p: 19% 61% 18% 2%
x264 [info]: i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 1% 61% 22% 1% 1% 1% 3% 1% 10%
x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 3% 78% 7% 1% 1% 1% 3% 1% 7%
x264 [info]: i8c dc,h,v,p: 18% 77% 1% 4%
x264 [info]: Weighted P-Frames: Y:21.9% UV:21.9%
x264 [info]: kb/s:3351.60
real 0m6.565s
user 0m5.570s
sys 0m0.987s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
riscv下测试
root@ubuntu:/home/jiaolong/x264/x264-master# time /home/jiaolong/riscvv/qemu-7.1.0/build/riscv64-linux-user/qemu-riscv64 -cpu rv64,v=true,vlen=256,vext_spec=v1.0 -L $RISCV/sysroot /home/jiaolong/x264/x264-master/demo
x264 [warning]: b-pyramid normal + intra-refresh is not supported
x264 [info]: using cpu capabilities: none!
x264 [info]: profile High, level 2.1, 4:2:0, 8-bit
x264 [info]: frame I:433 Avg QP:28.45 size: 21994
x264 [info]: frame P:1110 Avg QP:30.57 size: 14755
x264 [info]: mb I I16..4: 25.4% 25.9% 48.7%
x264 [info]: mb P I16..4: 22.1% 15.7% 19.9% P16..4: 27.0% 7.9% 7.3% 0.0% 0.0% skip: 0.0%
x264 [info]: 8x8 transform intra:26.7% inter:35.1%
x264 [info]: coded y,uvDC,uvAC intra: 75.1% 95.2% 93.0% inter: 63.4% 100.0% 96.4%
x264 [info]: i16 v,h,dc,p: 19% 61% 18% 3%
x264 [info]: i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 1% 61% 24% 1% 1% 0% 2% 1% 9%
x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 3% 79% 8% 1% 2% 0% 2% 1% 5%
x264 [info]: i8c dc,h,v,p: 18% 77% 1% 4%
x264 [info]: Weighted P-Frames: Y:21.9% UV:21.9%
x264 [info]: kb/s:3357.30
real 2m18.586s
user 2m17.160s
sys 0m1.103s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Last updated: 2022/12/04, 13:58:10