vlc compilation on Android, using Visual studio...

VLC for Android and Chrome OS specific usage questions
TarmoPikaro
Blank Cone
Blank Cone
Posts: 34
Joined: 01 Mar 2017 22:08

vlc compilation on Android, using Visual studio...

Postby TarmoPikaro » 03 Jun 2017 15:17

Hi !

I'm trying to port my own compilation of vlc on https://sourceforge.net/p/vlc2/code/HEAD/tree/ , using my own tool for that purpose - syncProj ( https://docs.google.com/document/d/1C1Y ... 3iysp1v35q ).

My own compilation is already somehow working on Win32 / Debug configuration, now I'm working towards android / arm cpu.

I have already compiled some of the projects to arm, but now I'm stumbled upon extlibs\ffmpeg\libavcodec - how to compile it for Android.

There exists instructions on how to cross compile ffmpeg projects using Visual studio native compiler, but I need more details on how to compile
extlibs\ffmpeg\libavcodec\arm\*.S assembly files.

I've understood that .S assembly files can be compiled using gcc compiler, and I have tried to execute gcc manually, but it gives some errors:
C:\Prototyping\vlc2\extlibs\ffmpeg\libavcodec\arm>C:\ProgramData\Microsoft\Andro
idNDK64\android-ndk-r11c\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x
86_64\bin\arm-linux-androideabi-gcc.exe -I..\.. -c aacpsdsp_neon.S -o test.o 2>z

for example like this:

aacpsdsp_neon.S:26: Error: selected processor does not support ARM mode `vld1.32 {q0},[r1,:128]!'
...

I understand that there could be a lot of different command line parameters, controlling processor architecture / floating point processor architecture, something you can see in configure -
-mthumb, -mfpu=vfp, etc...

Can anyone give me exact command lines for .S assembly files, or perhaps even some guidance where to search more information.

I have even msys installed, I could try to configure ffmpeg for Android processor, but also need more information on used configure parameters - is it also available in some readme ?

TarmoPikaro
Blank Cone
Blank Cone
Posts: 34
Joined: 01 Mar 2017 22:08

Re: vlc compilation on Android, using Visual studio...

Postby TarmoPikaro » 11 Jun 2017 15:49

Mostly figured out what was missing, reconfigured ffmpeg for arm, configure command line looks approximately like this:

Code: Select all

./configure --target-os=linux --cross-prefix=arm-linux-androideabi- --arch=arm --enable-shared --disable-symver --enable-small --disable-everything --extra-cflags="-march=armv7-a -mfloat-abi=softfp" --sysroot="C:\ProgramData\Microsoft\AndroidNDK64\android-ndk-r11c\platforms\android-21\arch-arm"
And managed to reconfigure / compile most of projects, using custom build parameters like this: "-march=armv7-a -marm" - I'm still puzzled how to map hw specs to what features specific cpu / hardware actually provides, but let's first try to reach run-time, then will analyze bit deeper.

However - currently I see following link errors:

Code: Select all

9>------ Build started: Project: avcodec_android, Configuration: Debug ARM ------ 9> ANDROID_HOME=C:\Program Files (x86)\Android\android-sdk 9> ANT_HOME=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Apps\apache-ant-1.9.3\ 9> JAVA_HOME= 9> NDK_ROOT=C:\ProgramData\Microsoft\AndroidNDK64\android-ndk-r11c\ 9>aviobuf.c(484): error : undefined reference to 'av_crc_get_table' 9>aviobuf.c(484): error : undefined reference to 'av_crc' 9>aviobuf.c(490): error : undefined reference to 'av_crc_get_table' 9>aviobuf.c(490): error : undefined reference to 'av_crc' 9>httpauth.c(131): error : undefined reference to 'av_md5_update' 9>httpauth.c(274): error : undefined reference to 'av_base64_encode' 9>httpauth.c(161): error : undefined reference to 'av_md5_alloc' 9>httpauth.c(165): error : undefined reference to 'av_md5_init' 9>httpauth.c(167): error : undefined reference to 'av_md5_final' 9>httpauth.c(184): error : undefined reference to 'av_md5_init' 9>httpauth.c(186): error : undefined reference to 'av_md5_final' 9>httpauth.c(190): error : undefined reference to 'av_md5_init' 9>httpauth.c(196): error : undefined reference to 'av_md5_final' 9>httpauth.c(173): error : undefined reference to 'av_md5_init' 9>httpauth.c(175): error : undefined reference to 'av_md5_final' 9>mov.c(3685): error : undefined reference to 'av_timecode_init' 9>mov.c(3689): error : undefined reference to 'av_timecode_make_string' 9>mpegts.c(421): error : undefined reference to 'av_crc_get_table' 9>mpegts.c(421): error : undefined reference to 'av_crc' 9>rdt.c(404): error : undefined reference to 'av_base64_decode' 9>rdt.c(119): error : undefined reference to 'av_md5_sum' 9>rtpdec_asf.c(108): error : undefined reference to 'av_base64_decode' 9>rtpdec_h264.c(134): error : undefined reference to 'av_base64_decode' 9>rtpdec_hevc.c(124): error : undefined reference to 'av_base64_decode' 9>rtsp.c(1270): error : undefined reference to 'av_base64_encode' 9>rtsp.c(1270): error : undefined reference to 'av_base64_encode' 9>rtsp.c(1183): error : undefined reference to 'av_base64_encode' 9>rtsp.c(1846): error : undefined reference to 'ff_log2_tab' 9>srtp.c(48): error : undefined reference to 'av_aes_crypt' 9>srtp.c(48): error : undefined reference to 'av_aes_crypt' 9>srtp.c(37): error : undefined reference to 'av_hmac_free' 9>srtp.c(92): error : undefined reference to 'av_aes_alloc' 9>srtp.c(93): error : undefined reference to 'av_hmac_alloc' 9>srtp.c(100): error : undefined reference to 'av_aes_init' 9>srtp.c(147): error : undefined reference to 'av_hmac_init' 9>srtp.c(149): error : undefined reference to 'av_hmac_update' 9>srtp.c(178): error : undefined reference to 'av_hmac_final' 9>srtp.c(147): error : undefined reference to 'av_hmac_init' 9>srtp.c(149): error : undefined reference to 'av_hmac_update' 9>srtp.c(175): error : undefined reference to 'av_hmac_update' 9>srtp.c(232): error : undefined reference to 'av_aes_init' 9>srtp.c(305): error : undefined reference to 'av_aes_init' 9>srtp.c(313): error : undefined reference to 'av_hmac_init' 9>srtp.c(314): error : undefined reference to 'av_hmac_update' 9>srtp.c(320): error : undefined reference to 'av_hmac_final' 9>srtp.c(305): error : undefined reference to 'av_aes_init' 9>srtp.c(313): error : undefined reference to 'av_hmac_init' 9>udp.c(942): error : undefined reference to 'av_fifo_freep' 9>udp.c(826): error : undefined reference to 'av_fifo_freep' 9>asfcrypt.c(164): error : undefined reference to 'av_rc4_init' 9>asfcrypt.c(165): error : undefined reference to 'av_rc4_crypt' 9>asfcrypt.c(170): error : undefined reference to 'av_des_init' 9>asfcrypt.c(171): error : undefined reference to 'av_des_crypt' 9>asfcrypt.c(174): error : undefined reference to 'av_rc4_init' 9>asfcrypt.c(175): error : undefined reference to 'av_rc4_crypt' 9>utils.c(2986): error : undefined reference to 'av_get_media_type_string' 9>collect2.exe : error : ld returned 1 exit status
I have tried to check what is inside libavutil.a, and it looks like at least "av_crc_get_table", using "C:\ProgramData\Microsoft\AndroidNDK64\android-ndk-r11c\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin\arm-linux-androideabi-nm.exe"
-gC

Code: Select all

crc.o: 00000000 T av_crc 00000000 T av_crc_get_table 00000000 T av_crc_init
Most interesting thing is that other symbols were resolved successfully, so only something libavformat does not like for some reason libavutil / crc and other security entities.

I had idea maybe library is not linked, but diagnostic log looks like linking is done:

Code: Select all

C:\ProgramData\Microsoft\AndroidNDK64\android-ndk-r11c\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin\arm-linux-androideabi-gcc.exe -o"..\\..\\obj\\Debug_ARM_android_avcodec\\libavcodec_plugin.so" -Wl,-rpath-link="C:\\ProgramData\\Microsoft\\AndroidNDK64\\android-ndk-r11c\\\\platforms\\android-21\\arch-arm\\usr\\lib" -Wl,-L"C:\\ProgramData\\Microsoft\\AndroidNDK64\\android-ndk-r11c\\\\platforms\\android-21\\arch-arm\\usr\\lib" -Wl,-L"C:\\ProgramData\\Microsoft\\AndroidNDK64\\android-ndk-r11c\\\\toolchains\\arm-linux-androideabi-4.9\\prebuilt\\windows-x86_64\\lib\\gcc\\arm-linux-androideabi\\4.9\\armv7-a" -Wl,-L"C:\\ProgramData\\Microsoft\\AndroidNDK64\\android-ndk-r11c\\\\platforms\\android-21\\arch-arm\\usr\\lib" -Wl,--no-undefined --sysroot="C:\\ProgramData\\Microsoft\\AndroidNDK64\\android-ndk-r11c\\\\platforms\\android-21\\arch-arm" -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack -shared ..\\..\\obj\\Debug_ARM_android_avcodec\\avio.o ..\\..\\obj\\Debug_ARM_android_avcodec\\audio.o ..\\..\\obj\\Debug_ARM_android_avcodec\\avcodec.o ..\\..\\obj\\Debug_ARM_android_avcodec\\chroma.o ..\\..\\obj\\Debug_ARM_android_avcodec\\encoder.o ..\\..\\obj\\Debug_ARM_android_avcodec\\fourcc.o ..\\..\\obj\\Debug_ARM_android_avcodec\\subtitle.o ..\\..\\obj\\Debug_ARM_android_avcodec\\va.o ..\\..\\obj\\Debug_ARM_android_avcodec\\video.o ..\\..\\obj\\Debug_ARM_android_avcodec\\demux.o ..\\..\\obj\\Debug_ARM_android_avcodec\\mux.o ..\\..\\obj\\Debug_ARM_android_avcodec\\avparser.o C:\\Prototyping\\vlc2\\bin\\Debug_ARM_android\\libvlccore.so C:\\Prototyping\\vlc2\\extlibs\\ffmpeg\\bin\\Debug_ARM_android\\libavutil.a C:\\Prototyping\\vlc2\\extlibs\\ffmpeg\\bin\\Debug_ARM_android\\libavformat.a C:\\Prototyping\\vlc2\\extlibs\\ffmpeg\\bin\\Debug_ARM_android\\libavcodec.a C:\\Prototyping\\vlc2\\extlibs\\ffmpeg\\bin\\Debug_ARM_android\\libswresample.a C:\\Prototyping\\vlc2\\extlibs\\bin\\Debug_ARM_android\\zlib.a -lstdc++ -llog -landroid -lm
So summary - libavutil, includes crc.c, which is compiled with "-march=armv7-a -marm", and using same parameter is compiled also libavformat, and aviobuf.c included into that library.

Does linking requires some special flag to link -marm <> -marm static libraries ?

Any ideas ?

TarmoPikaro
Blank Cone
Blank Cone
Posts: 34
Joined: 01 Mar 2017 22:08

Re: vlc compilation on Android, using Visual studio...

Postby TarmoPikaro » 11 Jun 2017 23:07

Wow !

Apparently linking order of libraries plays along in whole compilation process.
I've changed code from:

Code: Select all

references(@"..\..\extlibs\ffmpeg\libavutil\libavutil_" + platform + ".vcxproj", ""); references(@"..\..\extlibs\ffmpeg\libavformat\libavformat_" + platform + ".vcxproj", ""); references(@"..\..\extlibs\ffmpeg\libavcodec\libavcodec_" + platform + ".vcxproj", ""); references(@"..\..\extlibs\ffmpeg\libswresample\libswresample_" + platform + ".vcxproj", ""); references( @"..\..\extlibs\zlib\zlib_" + platform + ".vcxproj", "" );
to

Code: Select all

references(@"..\..\extlibs\ffmpeg\libavformat\libavformat_" + platform + ".vcxproj", ""); references(@"..\..\extlibs\ffmpeg\libavcodec\libavcodec_" + platform + ".vcxproj", ""); references(@"..\..\extlibs\ffmpeg\libswresample\libswresample_" + platform + ".vcxproj", ""); references( @"..\..\extlibs\zlib\zlib_" + platform + ".vcxproj", "" ); references(@"..\..\extlibs\ffmpeg\libavutil\libavutil_" + platform + ".vcxproj", "");
And after that link was successful.

According to this article: https://stackoverflow.com/questions/451 ... gcc/409470 - gcc scans libraries from in left to right order, which means that you need to specify libraries in right to left order (low level - on right, highest level - on left).

Incredible.

I'm also not sure how simple this to achieve with Visual Studio UI, because there is no operation like move upper / move lower, but with syncProj it's easy of course (switch lines).

TarmoPikaro
Blank Cone
Blank Cone
Posts: 34
Joined: 01 Mar 2017 22:08

Re: vlc compilation on Android, using Visual studio...

Postby TarmoPikaro » 17 Jun 2017 00:42

Yees, finally managed to compile ffmpeg projects for Android, but I still haven't reached run-time.

I guess most interesting functions are ffmpeg_asmFiles & ffmpeg_setCommonProjectOptions
https://sourceforge.net/p/vlc2/code/103/#diff-20

I'm just cherry picking everything what project has under x86 & arm folder, and then slightly filter out (**test.c, **template.c") unnecessary files, and then start to configure each file individually.

arm asm compilation parameters are almost guessed, I suspect they still needs to analyzed slightly deeper.

config.h is simple:
#ifndef _CONFIG_H_
#define _CONFIG_H_

#ifdef _WIN32
#include "config_windows.h"
#else
#include "config_android.h"
#endif

#endif //_CONFIG_H_

But those config*.h parameters are incredibly complex to solve. A lot of legacy and unnecessary stuff.

I suspect that used CPU and CPU features do needs to be configured, but not in global central config file, changing which will require whole ffmpeg to be reconfigured.

For now x86 & arm architectures are supported only, I'll check later if x64 / other architectures can be added easily.

TarmoPikaro
Blank Cone
Blank Cone
Posts: 34
Joined: 01 Mar 2017 22:08

Re: vlc compilation on Android, using Visual studio...

Postby TarmoPikaro » 17 Jun 2017 17:11

Now I can compile vlc for Android with Visual studio:

Windows:
========== Build: 0 succeeded, 0 failed, 81 up-to-date, 0 skipped ==========
Android:
========== Build: 75 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========

Now need to analyze deeper what it will take to launch it on device, and how...


Return to “VLC for Android and Chrome OS”

Who is online

Users browsing this forum: No registered users and 8 guests