MediaArea/MediaInfoLib

MediaInfoLib in ARM64

ReneeBolivar opened this issue · 17 comments

Hello everyone,

Is it possible to build MediaInfoLib DLLs for Windows ARM64?

Is there any issue when you use the source code for building for ARM64? As far as we know there is nothing blocking the compilation.
If you mean that we should provide the ARM64 build, for the moment we don't see enough Windows ARM64 usage for putting that on our build farm and we note your interest, we'll see if there are more people interested.
Can also be part of professional services if you need it before we find enough users for doing it within the free support.

I tried to create the DLL for ARM64, but I received an error in the "aes_ni.c" file. I found that the original AES repository has a pending update, but I think just updating wouldn't be enough to fix the error.
I tried to use the DLLs from ARM32, but on new devices with Windows 11, the bridge that currently supports the old DLLs will no longer receive support.

Examining the code, it appears that the specified cryptography for ARM64 is AES. However, AES is not supported on ARM64. Can you recommend an alternative cryptographic solution within the code that is compatible with this architecture?

Examining the code, it appears that the specified cryptography for ARM64 is AES.

Could you explain more?
AFAIK this is standard C and should compile well, I didn't yet install ARM64 support on my Visual Studio but I bet on tiny details.

By the way, AES support is for very specific use cases e.g. encrypted HLS content and as a quick workaround you can disable it with MEDIAINFO_AES_NO preprocessor directive and removal of the aes dir in the Visual Studio project.

if we try compilated the dll to arm64, because of AES is not possible to generate MediaInfo-Static_UWP.pch throw this exception: "
the Severity  Code  Description  Project  File  Line  Suppression State  Details Error  C1083  Cannot open precompiled header file: 'ARM64\Debug\MediaInfo-Static_UWP.pch'" I do not know why but to arm64 he enters in this defined "#if defined( USE_INTEL_AES_IF_PRESENT )"

If we skip the AES, it is possible to create the "MediaInfo-Static_UWP.pch', but the media info is not working.

Definition is there:

#if 1 && defined( _WIN64 ) && defined( _MSC_VER )
#  define INTEL_AES_POSSIBLE
#endif

#if defined( INTEL_AES_POSSIBLE ) && !defined( USE_INTEL_AES_IF_PRESENT )
#  define USE_INTEL_AES_IF_PRESENT
#endif

I guess that the _WIN64 unfortunately includes ARM64 and it is the wrong check, so just comment the define lines.

If we skip the AES, it is possible to create the "MediaInfo-Static_UWP.pch', but the media info is not working.

How not working? Which kind of behavior?

From Mircrosoft docs, it seems that the first line should have an additional && defined(_M_AMD64), could you test?

I will test with the suggested solution. The exception related to AES occurs when attempting to open a new file for metadata analysis. Currently, I no longer encounter the exception, but on Monday, I'll provide additional details. I believe the absence of any cryptographic method to open the file might be the root cause. The modification we made to build the library added the flag "!ARM64" in the AES file. Thank you for your assistance.

After many tests, I finally can build the mediainfolib to ARM64.
The only change necessary to work is on Aesopt. h, change this line of code.

#if defined( INTEL_AES_POSSIBLE ) && !defined( USE_INTEL_AES_IF_PRESENT ) && !defined(_M_ARM64)
#  define USE_INTEL_AES_IF_PRESENT
#endif

!defined(_M_ARM64)

I prefer defined(_M_AMD64) because we'll have the issue again if Microsoft decides to support another platform, could you confirm that replacing !defined(_M_ARM64) by defined(_M_AMD64) is fine for you?

I tried using _M_AMD64 and not working.
I think the defined _M_AMD64 is for devices architecture x64 from AMD.

The device of the test is a Windows arm, with the processor from Snapdragon

I think the defined _M_AMD64 is for devices architecture x64 from AMD.

Exactly, and the idea is that I expect that it is not defined with ARM64 build.

I tried using _M_AMD64 and not working.

Do you mean that _M_AMD64 is defined (note that the ! is not present with the _M_AMD64 check) with ARM build?

I do not understand, why add in definition AMD64 because the first part of sentence check if machine is Intel, not has any another situation with machine is Intel and amd64 in same time. You can explain how scenario this occurs?

why add in definition AMD64 because the first part of sentence check if machine is Intel

No, it tests if a custom flag is already set.

You can explain how scenario this occurs?

Your patch tests if it is not ARM64. if another architecture appears, the issue comes back (considered as Intel even if it is not)
My proposal is to test if it is AMD64. if another architecture appears, the issue does not come back (considered as not Intel)

In practice, your and my test should be a line above.

it is currently

#if 1 && defined( _WIN64 ) && defined( _MSC_VER )
#  define INTEL_AES_POSSIBLE
#endif

#if defined( INTEL_AES_POSSIBLE ) && !defined( USE_INTEL_AES_IF_PRESENT )
#  define USE_INTEL_AES_IF_PRESENT
#endif

the test on _WIN64 is wrong because it includes both AMD64 and ARM64, and it should be replace by _M_AMD64.

So please test with:

#if 1 && defined( _M_AMD64 ) && defined( _MSC_VER )
#  define INTEL_AES_POSSIBLE
#endif

#if defined( INTEL_AES_POSSIBLE ) && !defined( USE_INTEL_AES_IF_PRESENT )
#  define USE_INTEL_AES_IF_PRESENT
#endif

The only change is _WIN64 replaced by _M_AMD64.

Hi,

I tested your suggestion, and it worked well. Thank you!