Trying to add decoding support for LATM wrapped AAC audio, problem with libfaad2
#1
I'm trying to patch in LATM wrapped AAC support for playback of digital terrestrial recorded content here in New Zealand.

I'm working with patches to ffmpeg that a colleague has got working for MythTV here in New Zealand (available in his personal Ubuntu PPA).

I have applied all of the patches to ffmpeg and tweaked where necessary to compile, but am having some issues with the references to some of the libfaad2 libraries.

Part of the AAC decoding relies on some of the functions available in libfaad2 (defined in the libfaad2/include/neaacdec.h header file). I can't see where the actual code is that relates to that header file though, and sure enough at runtime when playing I get the following error.

Quote:00:06:44 T:3068172128 M: 54714368 NOTICE: DVDPlayer: Opening: /var/multimedia/videos/DVB-T Samples/02-12_00-25-24_TV ONE_ONE Sport Rugby The IRB Sevens World Series.ts
00:06:44 T:3068172128 M: 54714368 WARNING: CDVDMessageQueue:Tongueut MSGQ_NOT_INITIALIZED
00:06:44 T:2662427536 M: 54714368 DEBUG: Running thread 2662427536
00:06:44 T:2662427536 M: 54714368 DEBUG: thread start, auto delete: 0
00:06:44 T:2662427536 M: 54714368 NOTICE: Creating InputStream
00:06:44 T:2662427536 M: 54714368 INFO: CDVDFactorySubtitle::GetSubtitles, searching subtitles
00:06:44 T:2662427536 M: 54714368 DEBUG: CacheSubtitles: START
00:06:44 T:2662427536 M: 54714368 DEBUG: CacheSubtitles: Checking for common subirs...
00:06:44 T:2662427536 M: 54714368 DEBUG: CacheSubtitles: Done (time: 1 ms)
00:06:44 T:2662427536 M: 54714368 DEBUG: CacheSubtitles: Searching for subtitles...
00:06:44 T:2662427536 M: 54714368 DEBUG: CacheSubtitles: Done (time: 0 ms)
00:06:44 T:2662427536 M: 54714368 DEBUG: CacheSubtitles: END (total time: 1 ms)
00:06:44 T:2662427536 M: 54714368 INFO: CDVDFactorySubtitle::GetSubtitles, searching subtitles done
00:06:44 T:2662427536 M: 54714368 NOTICE: Creating Demuxer
00:06:44 T:2662427536 M: 54714368 DEBUG: SECTION:LoadDLL(Q:\system\players\dvdplayer\avcodec-51-i486-linux.so)
00:06:44 T:2662427536 M: 54714368 DEBUG: Loading: /usr/local/share/xbmc/system/players/dvdplayer/avcodec-51-i486-linux.so
00:06:44 T:2662427536 M: 54714368 ERROR: Unable to load /usr/local/share/xbmc/system/players/dvdplayer/avcodec-51-i486-linux.so, reason: /usr/local/share/xbmc/system/players/dvdplayer/avcodec-51-i486-linux.so: undefined symbol: NeAACDecClose
00:06:44 T:2662427536 M: 54714368 ERROR: CDVDDemuxFFmpeg::Open - failed to load ffmpeg libraries
00:06:44 T:2662427536 M: 54714368 ERROR: OpenDemuxStream - Error creating demuxer

Can anyone point me in the right direction? I can send through an svn diff of my current setup if that will help.
Reply
#2
After much frustration with this not working when it seemed like it should I've spent hours poring over all the Makefiles, configure files and make logs. I've found that XBMC doesn't actually use the ffmpeg built libavcodec.so file and instead completely rebuilds a "different but similar" avcodec.so file.

The XBMC built avcodec.so file loses all of the linking to external libraries that are setup as part of the ffmpeg configure routine though. In my particular case it lost the linking to faad that is setup through the --enable-libfaad parameter to configure for ffmpeg. This is what was causing my undefined symbol errors - no link to faad, no way to resolve the symbols.

The linking to faad and other things like pthread libraries in the ffmpeg built libavcodec.so file is correct, but not in the XBMC built avcodec.so.

Code:
david@davbuntu:~/XBMC/linuxport/XBMC/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec$ ldd -d libavcodec.so
    linux-gate.so.1 =>  (0xb7f68000)
    libavutil.so.49 => not found
    libz.so.1 => /usr/lib/libz.so.1 (0xb7a63000)
    libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0xb7a3d000)
[b]    libfaad.so.0 => /usr/lib/libfaad.so.0 (0xb79ff000)
    libpthread.so.0 => /lib/tls/i686/cmov/libpthread.so.0 (0xb79e7000)[/b]
    libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7898000)
    /lib/ld-linux.so.2 (0xb7f69000)
undefined symbol: av_freep    (./libavcodec.so)
undefined symbol: av_realloc    (./libavcodec.so)
undefined symbol: av_log    (./libavcodec.so)
undefined symbol: av_free    (./libavcodec.so)
undefined symbol: av_mallocz    (./libavcodec.so)
undefined symbol: av_malloc    (./libavcodec.so)
undefined symbol: av_d2q    (./libavcodec.so)
undefined symbol: av_log_get_level    (./libavcodec.so)
undefined symbol: ff_gcd    (./libavcodec.so)
undefined symbol: av_reduce    (./libavcodec.so)
undefined symbol: av_init_random    (./libavcodec.so)
undefined symbol: av_random_generate_untempered_numbers    (./libavcodec.so)
undefined symbol: av_crc_get_table    (./libavcodec.so)
undefined symbol: av_crc    (./libavcodec.so)
undefined symbol: ff_log2_tab    (./libavcodec.so)
undefined symbol: ff_sqrt_tab    (./libavcodec.so)
undefined symbol: lzo1x_decode    (./libavcodec.so)
undefined symbol: av_div_q    (./libavcodec.so)
undefined symbol: av_crc_init    (./libavcodec.so)

The XBMC built avcodec file is missing many of the links that ffmpeg includes, which was causing my runtime problems Sad

Code:
david@davbuntu:~/XBMC/linuxport/XBMC/system/players/dvdplayer$ ldd -d avcodec-51-i486-linux.so
    linux-gate.so.1 =>  (0xb7f61000)
    libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb791b000)
    /lib/ld-linux.so.2 (0xb7f62000)
undefined symbol: av_freep    (./avcodec-51-i486-linux.so)
undefined symbol: av_log    (./avcodec-51-i486-linux.so)
undefined symbol: powf    (./avcodec-51-i486-linux.so)
undefined symbol: av_init_random    (./avcodec-51-i486-linux.so)
undefined symbol: av_mallocz    (./avcodec-51-i486-linux.so)
undefined symbol: av_random_generate_untempered_numbers    (./avcodec-51-i486-linux.so)
undefined symbol: av_crc_get_table    (./avcodec-51-i486-linux.so)
undefined symbol: av_crc    (./avcodec-51-i486-linux.so)
undefined symbol: av_free    (./avcodec-51-i486-linux.so)
undefined symbol: ff_log2_tab    (./avcodec-51-i486-linux.so)
undefined symbol: av_malloc    (./avcodec-51-i486-linux.so)
undefined symbol: av_realloc    (./avcodec-51-i486-linux.so)
undefined symbol: sin    (./avcodec-51-i486-linux.so)
undefined symbol: pow    (./avcodec-51-i486-linux.so)
undefined symbol: lroundf    (./avcodec-51-i486-linux.so)
undefined symbol: lrintf    (./avcodec-51-i486-linux.so)
undefined symbol: lzo1x_decode    (./avcodec-51-i486-linux.so)
undefined symbol: uncompress    (./avcodec-51-i486-linux.so)
undefined symbol: cos    (./avcodec-51-i486-linux.so)
undefined symbol: exp    (./avcodec-51-i486-linux.so)
undefined symbol: floor    (./avcodec-51-i486-linux.so)
undefined symbol: sinh    (./avcodec-51-i486-linux.so)
undefined symbol: cosh    (./avcodec-51-i486-linux.so)
undefined symbol: tanh    (./avcodec-51-i486-linux.so)
undefined symbol: tan    (./avcodec-51-i486-linux.so)
undefined symbol: atan    (./avcodec-51-i486-linux.so)
undefined symbol: asin    (./avcodec-51-i486-linux.so)
undefined symbol: acos    (./avcodec-51-i486-linux.so)
undefined symbol: log    (./avcodec-51-i486-linux.so)
undefined symbol: fabs    (./avcodec-51-i486-linux.so)
undefined symbol: cosf    (./avcodec-51-i486-linux.so)
undefined symbol: inflateEnd    (./avcodec-51-i486-linux.so)
undefined symbol: inflateInit_    (./avcodec-51-i486-linux.so)
undefined symbol: inflateReset    (./avcodec-51-i486-linux.so)
undefined symbol: inflate    (./avcodec-51-i486-linux.so)
undefined symbol: inflateSync    (./avcodec-51-i486-linux.so)
undefined symbol: ff_gcd    (./avcodec-51-i486-linux.so)
undefined symbol: av_reduce    (./avcodec-51-i486-linux.so)
[b]undefined symbol: NeAACDecClose    (./avcodec-51-i486-linux.so)
undefined symbol: NeAACDecOpen    (./avcodec-51-i486-linux.so)
undefined symbol: NeAACDecInit2    (./avcodec-51-i486-linux.so)
undefined symbol: NeAACDecDecode    (./avcodec-51-i486-linux.so)
undefined symbol: NeAACDecGetCurrentConfiguration    (./avcodec-51-i486-linux.so)
undefined symbol: NeAACDecSetConfiguration    (./avcodec-51-i486-linux.so)
undefined symbol: NeAACDecInit    (./avcodec-51-i486-linux.so)
undefined symbol: NeAACDecGetErrorMessage    (./avcodec-51-i486-linux.so)[/b]
undefined symbol: av_crc_init    (./avcodec-51-i486-linux.so)
undefined symbol: av_div_q    (./avcodec-51-i486-linux.so)
undefined symbol: av_d2q    (./avcodec-51-i486-linux.so)
undefined symbol: llrint    (./avcodec-51-i486-linux.so)
undefined symbol: ff_sqrt_tab    (./avcodec-51-i486-linux.so)
undefined symbol: pthread_join    (./avcodec-51-i486-linux.so)
undefined symbol: pthread_create    (./avcodec-51-i486-linux.so)
undefined symbol: sinf    (./avcodec-51-i486-linux.so)
undefined symbol: log10    (./avcodec-51-i486-linux.so)
undefined symbol: ceil    (./avcodec-51-i486-linux.so)
undefined symbol: av_log_get_level    (./avcodec-51-i486-linux.so)

The avcodec.so file is created at the end of the Codecs make routine.

Code:
/usr/bin/ccache gcc -o ../../../../system/players/dvdplayer/avcodec-51-i486-linux.so -shared -fPIC -rdynamic --soname,../../../../system/players/dvdplayer/avcodec-51-i486-linux.so [b]ffmpeg/libavcodec/*.o[/b] \
        ffmpeg/libavcodec/i386/*.o `cat ../../DllLoader/exports/wrapper.def` ../../DllLoader/exports/wrapper.o

Does anyone know why XBMC builds avcodec.so completely independently of the one already built by ffmpeg after XBMC has gone through the trouble to make sure that ffmpeg has been configure'd correctly in the top level XBMC configure file? It looks like there is some function wrapping going on, but with all of the missing library links the resulting .so file doesn't work.

I've worked around this by hacking in the additional linking parts that ffmpeg used for building the initial avcodec.so file into the Makefile in the Codecs directory.

Quote:EXTRALIBS=-lz -lbz2 -pthread -lm -lfaad
$(SYSDIR)/avcodec-51-$(ARCH).so: $(WRAPPER) ffmpeg/libavcodec/libavcodec.so
$(CC) -o $@ $(LDFLAGS) --soname,$@ ffmpeg/libavcodec/*.o \
ffmpeg/libavcodec/i386/*.o `cat $(WRAPPER:.o=.def)` $(WRAPPER) $(EXTRALIBS)

EXTRALIBS is copied directly out of the configure built config.mak file in the ffmpeg directory.

Surely there's a cleaner more robust way to do this. Any ideasHuh

At least now I finally have HE-AAC audio working for the DVB-T digitally broadcast television here in New Zealand (and other countries like Norway) in XBMC. Booyah!!!
Reply

Logout Mark Read Team Forum Stats Members Help
Trying to add decoding support for LATM wrapped AAC audio, problem with libfaad20