[FFmpeg-devel] ff_idct_xvid_sse2-cannot-be-inline.patch

Måns Rullgård mans
Tue Mar 9 13:34:57 CET 2010


Pavel Pavlov <pavel at summit-tech.ca> writes:

>> On Mar 8, 2010, at 8:41 PM, Pavel Pavlov wrote:
>> 
>> >>>> On Mon, Mar 08, 2010 at 06:43:11PM -0500, Pavel Pavlov wrote:
>> >>>>>>> The function ff_idct_xvid_sse2 simply cannot be static because
>> >>>>>>> it's
>> >>>>>> referenced inside dsputil_mmx.c:
>> >>>>>>>  c->idct    = ff_idct_xvid_sse2;
>> >>>>>>> I have no idea how gcc could compile/link this kind of code. There
>> >>>>>>> should have been a link error at least
>> >>>>>>> <ff_idct_xvid_sse2-cannot-be-inline.patch>
>> >>>>>>
>> >>>>>> It's C99 inline. C99 doesn't make inline functions static if
>> >>>>>> there's a prototype, and there is one.
>> >>>>>>
>> >>>>>
>> >>>>>
>> >>>>> I don't know why I wrote static, if it's actually inline :)
>> >>>>> Anyways, I'm getting a link error and I have to remove inline
>> >>>>> to fix it.
>> >>>>
>> >>>> the function in question must be marked inline due to speed reasons
>> >>>>
>> >>>
>> >>> In this case I think there should be
>> >>> static av_inline_always void ff_idct_xvid_sse2_static(short *block){
>> >>> ...
>> >>> }
>> >>>
>> >>> void ff_idct_xvid_sse2(short *block){
>> >>>   ff_idct_xvid_sse2_static(block);
>> >>> }
>> >>>
>> >>> And the other two places should call ff_idct_xvid_sse2_static instead
>> >>
>> >> Yes, something like that is the correct solution.  A non-static inline
>> >> function should not produce an external definition.  That's what the
>> >> spec says.
>
> A non-static or a static? I think a static inline definitely should
> not produce an external definition.
> Basically, from my understanding, if there is a static function in a
> file, then if you compile that file and then disassemble the object
> file you won't see that function in the list of functions. In case
> of inline function I'm not really sure if there should be symbol
> defined in the object file. Probably, if it was completely inlined
> in all places of the .c file then compiler is free not to export it?

C99 defines three cases for inline functions:

- static inline: this is semantically equivalent to plain static.  The
  inline specifier is merely a hint to the compiler that this function is
  suitable for inlining.  The compiler is free to inline it or not,
  and to skip an actual definition of the function if all calls are
  inlined, just like it can do without the explicit inline specifier.

- extern inline: this creates an external definition and also hints
  the compiler to inline calls in the same translation unit.

- inline: this creates an inline definition, which the compiler may
  use in place of an external call.  Each time the function is called,
  the compiler will choose to use either the inline definition or make
  an external reference.  A suitable external definition is expected
  to be provided elsewhere.

>> What happens if you add 'extern' to ff_idct_xvid_sse2 in
>> libavcodec/x86/idct_xvid.h?
>
> In that case I don't get a link error 

That is because your compiler uses the C99 inline semantics.  GCC
versions prior to 4.2 use different, incompatible semantics for the
inline specifier.  To support both, only static inline functions may
be used.

-- 
M?ns Rullg?rd
mans at mansr.com



More information about the ffmpeg-devel mailing list