VS2010 compiling x264 (20091006)--------x264 Learning Notes BYMK

Source: Internet
Author: User

H264 can be said is now the trend of video development, more and more video abandoned rmvb put into the arms of H264.
I press the video is H264 encoded, so want to learn H264 coding, of course, there are professional reasons.
To learn H264, the first part is compiling x264.

If you just need to use x264, you can go here. Download: http://x264.nl/
x264 source code Download Address: http://www.videolan.org/developers/x264.html
Historical version download address: ftp://ftp.videolan.org/pub/videolan/x264/snapshots/
Since the latest version of the source code has not been the VS project, this article compiled the source code is the last version with the VS Project x264-snapshot-20091006-2245 version.
Here we also need yasm (assembler): http://yasm.tortall.net/Download.html
Unzip and put in the Build\win32, change the Vsyasm.exe to Yasm.exe

Ready to complete, double-click x264.sln,vs2010 will prompt the conversion project, next, complete.
First compile libx264, right-click to set as Startup item. Start compiling, press F7, fail, prompt:

1>g:\x264-snapshot-20091006-2245\common/common.h: Error C2143: Syntax errors: Missing ";" (in front of "type")
1>g:\x264-snapshot-20091006-2245\common/common.h (171): Error C2065: "I": undeclared identifier
1>g:\x264-snapshot-20091006-2245\common/common.h (171): Error C2065: "I": undeclared identifier

There are a lot of similar errors in the following, because the MS vs compiler does not support the C99 standard and does not support mixing definitions and declaring variables in functions.
Workaround: Define the variables uniformly at the beginning of the function.
such as the first error above, the original is:

static always_inline int x264_exp2fix8 (float x) {if (x >= 512.f/6.f) return 0; if (x >6) >> 8;}

Put the definition of I at the beginning of the function body:

static always_inline int x264_exp2fix8 (float x) {int i; if (x >= 512.f/6.f) return 0; if (x >6) >> 8;}

Errors disappear and similar errors are resolved in this way. (and most of it is this kind of mistake, really troublesome.) )
Compile again, warning will not be the tube. The error occurs again with the prompt:

1>....\ENCODER\ANALYSE.C (2950): Error C2059: syntax error: "["

Double-click the prompt to find the wrong location.

static const uint8_t Check_mv_lists[x264_mbtype_max] = {[P_l0]=1, [B_l0_l0]=1, [b_l1_l1]=2};

Switch

static const uint8_t Check_mv_lists[x264_mbtype_max] ={0,0,0,0,1,0,0,0,1,0,0,0,2,0,0,0,0,0,0};

Compile, prompt:

2>....\MUXERS.C (299): Error C2146: syntax error: Missing ")" (in front of identifier "PRIx32")

Put

fprintf (stderr, "Bad header Magic (%" PRIx32 "%s) \ n", * ((uint32_t*) header), header);

Switch

fprintf (stderr, "Bad Header Magic (%ld%s) \ n", * ((uint32_t*) header), header);

To continue compiling, prompt:

2>libx264.lib (encoder.obj): Error LNK2019: unresolved external symbol _x264_lookahead_init, which is referenced in function _x264_encoder_open_76
2>libx264.lib (encoder.obj): Error LNK2019: unresolved external symbol _x264_lookahead_is_empty, which is referenced in function _x264_encoder_encode
2>libx264.lib (encoder.obj): Error LNK2019: unresolved external symbol _x264_lookahead_get_frames, which is referenced in function _x264_encoder_encode
2>libx264.lib (encoder.obj): Error LNK2019: unresolved external symbol _x264_lookahead_put_frame, which is referenced in function _x264_encoder_encode
2>libx264.lib (encoder.obj): Error LNK2019: unresolved external symbol _x264_lookahead_delete, which is referenced in function _x264_encoder_close
2>libx264.lib (analyse.obj): Error LNK2019: unresolved external symbol _log2f, which is referenced in function _x264_analyse_init_costs

This is due to the fact that the LIBX264 project did not add the Lookahead.c file, thus missing several function definitions resulting from the addition of LOOKAHEAD.C into the project. Compile again, modify several errors in Lookahead.c, succeed 1, fail 1, prompt:

2>libx264.lib (analyse.obj): Error LNK2019: unresolved external symbol _log2f, which is referenced in function _x264_analyse_init_costs

This is just a log2f (x) to define.
Add the log2f (x) definition in Osdep.h.

#ifdef _msc_ver #define Inline __inline #define STRCASECMP stricmp #define STRNCASECMP strnicmp #define SNPRINTF _snprintf #define FSEEK _fseeki64 #define Ftell _ftelli64 #define Isfinite _finite #define STRTOK_R strtok_s #define _crt_secure_no _deprecate #define X264_version ""//No Configure script for MSVC #define LOG2F (x) (LOGF (x) *1.4426950408889634f) #endif

Compiled, 2 successful.
Successfully generated libx264.lib and x264.exe two files under the Bin folder.
Recommended Blog: http://jmvc.blog.sohu.com/145356341.html (there are some functions in the annotations very good)

Original website: http://wuyuans.com/2011/12/vs2010-complies-x264-20091006/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.