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

Roland Scheidegger rscheidegger_lists at hispeed.ch
Fri Apr 13 15:26:07 CEST 2012

Am 13.04.2012 11:35, schrieb Loren Merritt:
> 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.
> 1:
> 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)

Ah that's neat. I tried to calculate the difference between two symbols
and figured out it indeed doesn't compile, but this trick was too clever
for me :-).


More information about the ffmpeg-devel mailing list