Compilation of Xvid under Linux/Unix (Cygwin/VMware)

### Date: 2017/4/1

### Advised at 2017/4/4

### Author: SoaringLee

      In the past two days, I have been learning the open source implementation of MPEG4 - xvid. The first is to compile the xvid source code. The previous article introduced the compilation method of the xvid source code on win32 (VS2013). This article introduces the compilation process of Xvid under Linux/Unix.

      The compilation directory is under build/generic. First, configure the current platform by running configure. Unix-like environment can use mingw32 or cygwin. But here, since mingw32 cannot generate the corresponding configuration of the linux platform through configure, it is compiled here in cygwin.

      After configuration, make directly, but the following error occurred:


Here is an error in the linker ld. The reason is that the object file obj generated by the assembly cannot be recognized. The specific reason is not clear? This problem is free to solve slowly later! ~

problem solved:

     Before analyzing the Xvid source code, I have been thinking about the cause of this problem for a few days. The target file format is not recognized, it should be because different target file formats are used in Windows and Linux, and there is no recognition here. Found the question on Stack overflow:

If you are using a shared file system, you need to call make clean when switching between Windows and Linux.

Windows and Linux use different object file formats, and as such you can not use the object files of one OS on another. When using a shared file system, the make will not automatically guess that the object files should be recompiled and would use the old files compiled under a different OS. That would result in the error you observed.

But what is the specific reason?

     By comparing the platform.inc generated by configure on the virtual machine and the platform.inc generated under cygwin, I finally found the reason. As can be seen from the figure below, the architecture configurations in the two platforms are different. The left side is generated under cygwin, the architecture is x86, the dynamic library is .dll, and the object file is .obj, these are the current windows platform configuration; the right side is generated under the virtual machine, the architecture is GENERIC, the dynamic library is .so, The object file is .o. Therefore, the formats of dynamic library files and object files under Windows and Linux are different. Here, the setting of the current architecture does not recognize the object file. So the problem is with the configuration!


The result after compilation is as follows:


Finally, compile and run the encoder demo and decoder demo under the examples folder. Successfully run!


In addition, you can move to the virtual machine to continue compiling:

The steps are the same as above, but there is no problem on cygwin. It seems that the configuration of this Unix-like simulation environment is still prone to problems!

(1)./configure


(2)make


Here libxvidcore.a and libxvidcore.so.4.3 generated under the =build folder are the libraries we need to generate.

It is easy and pleasant to complete the compilation of the xvid library on the linux platform!

(3)make install

However, the installation of this library requires root privileges. Get root privileges via su - and install just fine.

(4) Next, compile and run the encoder demo and decoder demo below the examples.

After make, the corresponding executable file is generated.

Encode foreman_cif.yuv:


The operation is successful, and the mpeg4 stream file foreman.m4v is generated after encoding.

Decode the foreman.m4v stream:


The operation is successful, and the reconstructed yuv file dec.yuv is obtained after decoding.

But found 2 small problems:

(1) After encoding the original yuv video with the xvid mpeg4 encoder, the problem of video color distortion after decoding of the encoded code stream occurs.   

(2) But unfortunately, the yuvplayer software only has the Windows version of the exe, not the Linux version, so the dec.yuv obtained after decoding cannot be played and the correctness of the decoding cannot be verified. In general, the encoding and decoding here should be correct.

      In order to solve the problem that yuv files cannot be played under Linux, the next step is to study the source code of yuvplayer and write the makefile for the Linux platform, and then compile it under Linux to get the corresponding executable file.

Source address of yuvplayer: https://github.com/Tee0125/yuvplayer

                                      (https://sourceforge.net/p/raw-yuvplayer/code/HEAD/tree/)

                                        https://github.com/latelee/YUVPlayer

       To be continued~~~~

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325991250&siteId=291194637