[FFmpeg-devel] [PATCH] h264: assembly version of get_cabac for x86_64 with PIC

Loren Merritt lorenm at u.washington.edu
Fri Apr 13 11:35:40 CEST 2012

On Fri, 13 Apr 2012, Michael Niedermayer wrote:
> On Fri, Apr 13, 2012 at 05:13:46AM +0000, Loren Merritt wrote:
>> @GOTPCREL isn't actually necessary unless you want the application to be
>> able to override those symbols (which we don't).
>> lea    ff_h264_lps_range(%%rip), "tmp2q"
>> movzbl ("tmp2q", %%rcx), "range"
>> movzbl ff_h264_norm_shift-ff_h264_lps_range("tmp2q", "rangeq"), %%ecx
>> movzbl ff_h264_mlps_state-ff_h264_lps_range+128("tmp2q", "retq"), "tmp"
>> ...Which fails to compile. Well, you can do something like that in yasm,
>> but I don't know how to subtract one symbol from another in inline asm.
> If the symbols are defined in a single yasm file/object then it can
> get the difference, otherwise i dont see how but i might be missing
> something.

You're right about two extern symbols, but it's possible to take the
difference between one extern symbol and one static .text symbol. And
there's one degree of freedom in the offsets, so the static symbol can
be anything and is unrelated to where the actual data is stored.

Ah, I used "$$" in yasm and was slightly set back by the lack of any
equivalent in inline asm, but making an actual label for it works too.

lea    1b(%%rip), "tmp2q"
movzbl ff_h264_lps_range-1b("tmp2q", %%rcx), "range"
movzbl ff_h264_norm_shift-1b("tmp2q", "rangeq"), %%ecx
movzbl ff_h264_mlps_state-1b+128("tmp2q", "retq"), "tmp"

See also x264/common/x86/trellis-64.asm (grep for GLOBAL)

--Loren Merritt

More information about the ffmpeg-devel mailing list