[FFmpeg-devel] Added HW H.264 and HEVC encoding for AMD GPUs based on AMF SDK

Mark Thompson sw at jkqxz.net
Wed Nov 8 17:15:27 EET 2017


On 06/11/17 22:46, Michael Niedermayer wrote:
> ...
> In file included from src/libavcodec/amfenc.h:24:0,
>                  from src/libavcodec/amfenc.c:27:
> src/compat/amd/amfsdkenc.h:191:23: error: no previous prototype for ‘AMFConstructRect’ [-Werror=missing-prototypes]
>  AMF_INLINE struct AMFRect AMFConstructRect(amf_int32 left, amf_int32 top, amf_int32 right, amf_int32 bottom)
>                        ^
> src/compat/amd/amfsdkenc.h:203:23: error: no previous prototype for ‘AMFConstructSize’ [-Werror=missing-prototypes]
>  AMF_INLINE struct AMFSize AMFConstructSize(amf_int32 width, amf_int32 height)
>                        ^
> src/compat/amd/amfsdkenc.h:215:24: error: no previous prototype for ‘AMFConstructPoint’ [-Werror=missing-prototypes]
>  AMF_INLINE struct AMFPoint AMFConstructPoint(amf_int32 x, amf_int32 y)
>                         ^
> src/compat/amd/amfsdkenc.h:227:23: error: no previous prototype for ‘AMFConstructRate’ [-Werror=missing-prototypes]
>  AMF_INLINE struct AMFRate AMFConstructRate(amf_uint32 num, amf_uint32 den)
>                        ^
> src/compat/amd/amfsdkenc.h:239:24: error: no previous prototype for ‘AMFConstructRatio’ [-Werror=missing-prototypes]
>  AMF_INLINE struct AMFRatio AMFConstructRatio(amf_uint32 num, amf_uint32 den)
>                         ^
> In file included from src/libavcodec/amfenc.h:24:0,
>                  from src/libavcodec/amfenc.c:27:
> src/compat/amd/amfsdkenc.h:275:24: error: no previous prototype for ‘AMFConstructColor’ [-Werror=missing-prototypes]
>  AMF_INLINE struct AMFColor AMFConstructColor(amf_uint8 r, amf_uint8 g, amf_uint8 b, amf_uint8 a)
>                         ^
> In file included from src/libavcodec/amfenc.h:24:0,
>                  from src/libavcodec/amfenc.c:27:
> src/compat/amd/amfsdkenc.h:293:45: error: no previous prototype for ‘amf_variant_alloc’ [-Werror=missing-prototypes]
>      AMF_INLINE void* AMF_CDECL_CALL amf_variant_alloc(amf_size count)
>                                              ^
> src/compat/amd/amfsdkenc.h:297:44: error: no previous prototype for ‘amf_variant_free’ [-Werror=missing-prototypes]
>      AMF_INLINE void AMF_CDECL_CALL amf_variant_free(void* ptr)
>                                             ^
> cc1: some warnings being treated as errors
> make: *** [libavcodec/amfenc.o] Error 1

This is showing an error in the AMF C API.

AMF_INLINE is defined at <https://github.com/GPUOpen-LibrariesAndSDKs/AMF/blob/master/amf/public/include/core/Platform.h#L99> as just "__inline__" (i.e. "inline"), so these functions are all inline without a storage class specifier.  But, no external definition actually exists anywhere, so if the compiler doesn't inline all instances you will fail to link.

(The behaviour is not the same in C++, where external versions are generated anyway in this case and then the multiple instances collapsed together later by invoking the ODR.)

Trivial test case (gcc defaults to not inlining anything when no optimisation options are given):

$ cat amf-inline.c
#include "Platform.h"

int main(void)
{
    AMFSize size;
    size = AMFConstructSize(123, 456);
    return 0;
}
$ gcc -std=c99 amf-inline.c
In file included from amf-inline.c:1:0:
Platform.h: In function ‘AMFCompareGUIDs’:
Platform.h:421:16: warning: implicit declaration of function ‘memcmp’ [-Wimplicit-function-declaration]
         return memcmp(&guid1, &guid2, sizeof(guid1)) == 0;
                ^
/tmp/ccMCUBTW.o: In function `main':
amf-inline.c:(.text+0x13): undefined reference to `AMFConstructSize'
collect2: error: ld returned 1 exit status
$ gcc -c -std=c99 amf-inline.c
In file included from amf-inline.c:1:0:
Platform.h: In function ‘AMFCompareGUIDs’:
Platform.h:421:16: warning: implicit declaration of function ‘memcmp’ [-Wimplicit-function-declaration]
         return memcmp(&guid1, &guid2, sizeof(guid1)) == 0;
                ^
$ nm amf-inline.o 
                 U AMFConstructSize
0000000000000000 T main
$ gcc -O1 -std=c99 amf-inline.c
In file included from amf-inline.c:1:0:
Platform.h: In function ‘AMFCompareGUIDs’:
Platform.h:421:16: warning: implicit declaration of function ‘memcmp’ [-Wimplicit-function-declaration]
         return memcmp(&guid1, &guid2, sizeof(guid1)) == 0;
                ^
$ 

I think AMF_INLINE should for these functions instead be "static inline" (though I didn't look at all uses, so there may be others where this isn't true).

- Mark


More information about the ffmpeg-devel mailing list