Compile method of Xvid under Windows (VS2013)

   ###Date: 2017/3/31

   ###Author: SoaringLee


        Time flies so fast, it's the end of March in a flash, and it's only 3 months before graduation. When I was an intern at Dahua some time ago, I was mainly learning about the compilation and maintenance of the Mpeg4 decoding library. Later, through the in-depth study of the Mpeg4 standard, I basically understood the basic content of this standard. The core of the Mpeg4 standard is object-based encoding, but because the object extraction technology has not progressed, in fact, Mpeg4 is actually the same as the previous Mpeg2 and H.263. It still encodes rectangular frames. Now the two profiles, Simple Profile (SP) and Advanced Simple Profile (ASP), are actually used.

     In the process of learning and analyzing the source code of the Mpeg4 decoding library, I always found the word xvid, so I went to the Internet to check it, and I found out that Xvid is an open-source Mpeg4 codec, so I plan to learn the relevant content of this library.

    The following introduces the method of compiling Xvid under VS2013.

     (1) First look at the xvidcore project directory, which includes the source code src, documentation doc, compilation folder build, and two folders that are not clear (dshow and vfw). We know that dshow and vfw are Microsoft's audio and video processing encapsulation libraries in different periods. These two folders should be the encapsulation of xvid.

    (2) Go to the buid-win32 folder, you can see that there is a VC6 project, which needs to be converted to VS2010. Open libxvidcore.sln, you can see that there are 3 projects under this solution, libxvidcore, xvid_encraw and xvid_decraw.

    The libxvidcore project is a source code project;

    xvid_encraw is the encoder demo project, and xvid_decraw is the decoder demo project.

    (3) Now compile the source code project libxvidcore, it will prompt that nasm is not a defined command. Because there are assembly files in the source code, the assembler nasm is required. The download of nasm can be downloaded from the official website http://www.nasm.us/ or from sourceforge (http://sourceforge.net/projects/nasm). After downloading and installing nasm, copy the assembler nasm.exe to the VC/bin directory under the installation path of VS2013. This problem can be solved.

   (4) Compile the source code project again, and the compilation is successful. The library files generated at this time are xvidcore.dll.a and xvidcore.dll. Where xvidcore.dll.a is the static library corresponding to the dynamic library file. In order to generate xvidcore.lib, you only need to project libxvidcore, properties - configuration properties - advanced - import library, and modify bin\xvidcore.dll.a to bin\xvidcore.lib.

   (5) Next, compile the encoder demo and decoder demo.

First, the additional dependencies in the demo properties of the decoder need to be modified: modify xvidcore.dll.a to xvidcore.lib. Then select the decoder project xvid_decraw as the startup project, compile and run, succeed, and get xvid_decraw.exe.


The compilation process of the encoder demo is the same as above, the compilation is successful, and xvid_encraw.exe is obtained


 At this point, the compilation of Xvid under VS2013 is completed. Next, we need to analyze the source code of Xvid.

In addition, since the VS2015 version is installed on my laboratory computer, I also compiled and run it on VS2015, but a bug appeared when compiling the xvid_encraw project:


As can be seen from the screenshot, this is a link error after compiling xvid_encraw.c. The specific reason is that the functions SetRect and CoInitializeEx cannot be resolved. These two functions are included in Windows, why can't they be parsed and haven't figured it out yet?

And because these two functions are used in setting the AVI output file, they have little effect on compiling the mpeg4 encoder demo, so you can successfully compile by turning off the following macros.

//#define XVID_AVI_INPUT
//#define XVID_AVI_OUTPUT

OK, now it can be successfully compiled on VS2015.


Guess you like

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