Open main menu

Difference between revisions of "Compiling ScummVM/Visual Studio/Compiling Libraries"

Add detailed instructions on how to get libmpeg2 working
(Update with libfaad instructions)
(Add detailed instructions on how to get libmpeg2 working)
Line 33: Line 33:
* [https://github.com/gypified/libfaad libfaad] for AAC support.
* [https://github.com/gypified/libfaad libfaad] for AAC support.
You need the latest libfaad source code.
You need the latest libfaad source code.
* [http://libmpeg2.sourceforge.net/ libmpeg2] for MPEG-2 support.
You need the latest libmpeg2 source code from the downloads section.


== Building the libraries ==
== Building the libraries ==
Line 229: Line 232:
     static INLINE int lrintf(float f)
     static INLINE int lrintf(float f)
     {
     {
</source>
=== libmpeg2 ===
Since the MSVC project files for libmpeg2 haven't been updated for a *very* long time, we'll need to recreate them from scratch. For libmpeg2, ALL the MMX optimizations have to be disabled, as libmpeg2 is using AT&T ASM syntax (GCC style), whereas MSVC uses the Intel syntax.
In order to create the project files, do the following:
* Create a new empty C++ project, named "libmpeg2"
* Copy inttypes.h and config.h from the vc++ directory into the libmpeg2 directory
* Copy attributes.h and mpeg2.h from the include directory into the libmpeg2 directory
* Add the following files to the project, from the libmpeg2 folder:
** alloc.c
** config.h
** decode.c
** header.c
** idct.c
** inttypes.h
** motion_comp.c
** mpeg2.h
** mpeg2_internal.h
** slice.c
* Find all occurences of:
<source lang="C">
* #include <inttypes.h>
</source>
and change them to:
<source lang="C">
* #include "inttypes.h"
</source>
* Open config.h and comment out this line:
<source lang="C">
#define restrict __restrict
</source>
* Change configuration to "Release"
* Right click project->Properties
** Configuration Properties->General, change "Configuration type" to "Static library(.lib)"
** Configuration Properties->C/C++->Code Generation, change "Runtime Library" to "Multi-threaded (/MT)"
** Configuration Properties->Librarian->General->Set "Link Time Code Generation" to "No"
Now, we'll remove all the MMX optimization references from the files that have been added to the project. Perform the following:
- Open idct.c, go to line 238 (inside mpeg2_idct_init) and change:
<source lang="C">
#ifdef ARCH_X86
</source>
to:
<source lang="C">
#if defined(ARCH_X86) && !defined(_MSC_VER)
</source>
-  Open motion_comp.c, go to line 36 (inside mpeg2_mc_init) and change:
<source lang="C">
#ifdef ARCH_X86
</source>
to:
<source lang="C">
#if defined(ARCH_X86) && !defined(_MSC_VER)
</source>
- Open slice.c, replace these lines:
<source lang="C">
extern void (* mpeg2_cpu_state_save) (cpu_state_t * state);
extern void (* mpeg2_cpu_state_restore) (cpu_state_t * state);
</source>
with:
<source lang="C">
void (* mpeg2_cpu_state_save) (cpu_state_t * state) = 0;
void (* mpeg2_cpu_state_restore) (cpu_state_t * state) = 0;
uint32_t mpeg2_detect_accel (uint32_t accel) { return 0; }
void mpeg2_cpu_state_init (uint32_t accel) {}
</source>
</source>
1,489

edits