[FFmpeg-devel] [PATCH] swresample/arm: avoid conditional branch to PLT in THUMB-2.

Rahul Chaudhry rahulchaudhry at chromium.org
Tue Apr 17 22:36:45 EEST 2018

On Tue, Apr 17, 2018 at 6:17 AM, Michael Niedermayer
<michael at niedermayer.cc> wrote:
> why does it go through the PLT at all ?

You're right. The branches don't have to go through the PLT at all.

Here's an alternate patch that modifies the branches to skip the PLT
and jump directly to the targets.

Note that unlike the previous patch, this patch changes semantics.
When branches were going through PLT, the targets could be overridden
at runtime by another shared library or the main executable. With
this patch, they can no longer be overridden. The branches will always
go to the corresponding functions defined in this assembly file.

--- libswresample/arm/audio_convert_neon.S
+++ libswresample/arm/audio_convert_neon.S
@@ -22,6 +22,7 @@
 #include "libavutil/arm/asm.S"

 function swri_oldapi_conv_flt_to_s16_neon, export=1
         subs            r2,  r2,  #8
         vld1.32         {q0},     [r1,:128]!
         vcvt.s32.f32    q8,  q0,  #31
@@ -66,6 +67,7 @@ function swri_oldapi_conv_flt_to_s16_neon, export=1

 function swri_oldapi_conv_fltp_to_s16_2ch_neon, export=1
         ldm             r1,  {r1, r3}
         subs            r2,  r2,  #8
         vld1.32         {q0},     [r1,:128]!
@@ -133,8 +135,8 @@ function swri_oldapi_conv_fltp_to_s16_nch_neon, export=1
         cmp             r3,  #2
         itt             lt
         ldrlt           r1,  [r1]
-        blt             X(swri_oldapi_conv_flt_to_s16_neon)
-        beq             X(swri_oldapi_conv_fltp_to_s16_2ch_neon)
+        blt             _swri_oldapi_conv_flt_to_s16_neon
+        beq             _swri_oldapi_conv_fltp_to_s16_2ch_neon

         push            {r4-r8, lr}
         cmp             r3,  #4

More information about the ffmpeg-devel mailing list