Linphone-android在android6.0上X264
2017-11-27 本文已影响0人
Cui三土
https://mailman.videolan.org/pipermail/x264-devel/2015-October/011479.html
linphone使用open264做编解码器时在很多机型上会有严重卡顿的问题,问题在于open264编解码效率较低,在编译时使用x264做编码可以解决由于效率低而造成卡顿的问题,但在android6.0以上使用x264编码时会出现问题。
linphone在android6.0以上机型上无法正常加载x264编码器,原因是Android 6不会将共享库与文本重定位链接起来。
需要对以下汇编文件做修改。实测改善了部分机型的体验,linphone使用h264编码坑比较多,推荐使用VP8编码。
---
common/arm/asm.S | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++-
common/arm/mc-a.S | 5 +++--
common/arm/quant-a.S | 4 ++--
3 files changed, 65 insertions(+), 5 deletions(-)
diff --git a/common/arm/asm.S b/common/arm/asm.S
index c363c38..a96e0a7 100644
--- a/common/arm/asm.S
+++ b/common/arm/asm.S
@@ -56,6 +56,12 @@
# define FUNC @
#endif
+#if SYS_LINUX
+#define HAVE_SECTION_DATA_REL_RO 1
+#else
+#define HAVE_SECTION_DATA_REL_RO 0
+#endif
+
.macro require8, val=1
ELF .eabi_attribute 24, \val
.endm
@@ -85,8 +91,30 @@ FUNC .func \name
.endif
.endm
+.macro const name, align=2, relocate=0
+ .macro endconst
+ELF .size \name, . - \name
+ .purgem endconst
+ .endm
+.if HAVE_SECTION_DATA_REL_RO && \relocate
+ .section .data.rel.ro
+.else
+ .section .rodata
+.endif
+ .align \align
+\name:
+.endm
+
.macro movrel rd, val
-#if HAVE_ARMV6T2 && !defined(PIC)
+#if defined(PIC)
+ ldr \rd, 1f
+ b 2f
+1:
+@ FIXME: thumb
+ .word \val - (2f + 8)
+2:
+ add \rd, \rd, pc
+#elif HAVE_ARMV6T2
movw \rd, #:lower16:\val
movt \rd, #:upper16:\val
#else
@@ -94,6 +122,37 @@ FUNC .func \name
#endif
.endm
+.macro movrelx rd, val, got
+#if defined(PIC) && defined(__ELF__)
+ ldr \got, 2f
+ ldr \rd, 1f
+ b 3f
+1:
+@ FIXME: thumb
+ .word \val(GOT)
+2:
+ .word _GLOBAL_OFFSET_TABLE_ - (3f + 8)
+3:
+ add \got, \got, pc
+ ldr \rd, [\got, \rd]
+#elif defined(PIC) && defined(__APPLE__)
+ ldr \rd, 1f
+ b 2f
+1:
+@ FIXME: thumb
+ .word 3f - (2f + 8)
+2:
+ ldr \rd, [pc, \rd]
+ .non_lazy_symbol_pointer
+3:
+ .indirect_symbol \val
+ .word 0
+ .text
+#else
+ movrel \rd, \val
+#endif
+.endm
+
.macro movconst rd, val
#if HAVE_ARMV6T2
movw \rd, #:lower16:\val
diff --git a/common/arm/mc-a.S b/common/arm/mc-a.S
index 30d1c1a..cee1b4a 100644
--- a/common/arm/mc-a.S
+++ b/common/arm/mc-a.S
@@ -140,12 +140,13 @@ MEMCPY_ALIGNED 16, 8
MEMCPY_ALIGNED 8, 16
MEMCPY_ALIGNED 8, 8
-.section .rodata
-memcpy_table:
+const memcpy_table align=2, relocate=1
.word memcpy_aligned_16_16_neon
.word memcpy_aligned_16_8_neon
.word memcpy_aligned_8_16_neon
.word memcpy_aligned_8_8_neon
+endconst
+
.text
.ltorg
diff --git a/common/arm/quant-a.S b/common/arm/quant-a.S
index 7a2667f..1a5aa03 100644
--- a/common/arm/quant-a.S
+++ b/common/arm/quant-a.S
@@ -346,7 +346,7 @@ function x264_decimate_score\size\()_neon
lsr r1, r1, #2
.endif
rbit r1, r1
- movrel r3, X(x264_decimate_table4)
+ movrelx r3, X(x264_decimate_table4), r2
1:
clz r2, r1
lsl r1, r1, r2
@@ -415,7 +415,7 @@ function x264_decimate_score64_neon
mvn r12, r12
mov r0, #0
mov lr, #32
- movrel r3, X(x264_decimate_table8)
+ movrelx r3, X(x264_decimate_table8), r2
beq 2f
1:
clz r2, r1
--
2.6.1