[FFmpeg-devel] [RFC/HACK] textrel-free x86_64 fft_mmx.asm

Reimar Döffinger Reimar.Doeffinger
Tue Nov 10 16:50:06 CET 2009

it is rather ugly and might affect speed a bit, but it is the only
remaining textrel in x86_64 FFmpeg with --enable-pic.
I really wished there was a RIP-relative, register-argument call.
I'm sure it can be made at least a bit less ugly, this is my first
attempt at both that kind of thing and yasm.
-------------- next part --------------
Index: libavcodec/x86/fft_mmx.asm
--- libavcodec/x86/fft_mmx.asm	(revision 20496)
+++ libavcodec/x86/fft_mmx.asm	(working copy)
@@ -421,16 +421,21 @@
 %macro DECL_FFT 2-3 ; nbits, cpu, suffix
-%xdefine list_of_fft fft4%2, fft8%2
+%ifdef PIC
+%define fft_rel - fft_call%3%2
+%define fft_rel
+%xdefine list_of_fft fft4%2 fft_rel, fft8%2 fft_rel
 %if %1==5
-%xdefine list_of_fft list_of_fft, fft16%2
+%xdefine list_of_fft list_of_fft, fft16%2 fft_rel
 %assign n 1<<%1
 %rep 17-%1
 %assign n2 n/2
 %assign n4 n/4
-%xdefine list_of_fft list_of_fft, fft %+ n %+ %3%2
+%xdefine list_of_fft list_of_fft, fft %+ n %+ %3%2 fft_rel
 align 16
 fft %+ n %+ %3%2:
@@ -462,6 +467,11 @@
 cglobal fft_dispatch%3%2, 2,5,8, z, nbits
     lea r2, [dispatch_tab%3%2 GLOBAL]
     mov r2, [r2 + (nbitsq-2)*gprsize]
+%ifdef PIC
+    lea r3, [fft_call%3%2 GLOBAL]
+    add r2, r3
     call r2
 %endmacro ; DECL_FFT

More information about the ffmpeg-devel mailing list