x264编译-2、集成x264库

1、编写Android.mk

#x264
include $(CLEAR_VARS)
LOCAL_MODULE    := x264
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/x264/include
LOCAL_SRC_FILES := libs/libx264.a
$(info $(LOCAL_SRC_FILES))
include $(PREBUILT_STATIC_LIBRARY)

2、编写Application.mk

APP_ABI :=  armeabi
APP_PLATFORM := android-19
APP_STL := gnustl_static

3、遇到的坑

    1、报错 
libs/libfaac.a
live/live.c
[armeabi] Compile thumb  : live <= live.c
In file included from jni/live/live.c:2:0:
jni/x264/include/x264.h:40:4: warning: #warning You must include stdint.h or inttypes.h before x264.h [-Wcpp]
 #  warning You must include stdint.h or inttypes.h before x264.h
    ^
In file included from jni/live/live.c:2:0:
jni/x264/include/x264.h:110:5: error: unknown type name 'uint8_t'
     uint8_t *p_payload;
     ^
In file included from jni/live/live.c:2:0:
jni/x264/include/x264.h:353:5: error: unknown type name 'uint8_t'
     uint8_t     cqm_4iy[16];        /* used only if i_cqm_preset == X264_CQM_CUSTOM */
     ^
jni/x264/include/x264.h:354:5: error: unknown type name 'uint8_t'
     uint8_t     cqm_4py[16];
     ^
jni/x264/include/x264.h:355:5: error: unknown type name 'uint8_t'
     uint8_t     cqm_4ic[16];
     ^
jni/x264/include/x264.h:356:5: error: unknown type name 'uint8_t'
     uint8_t     cqm_4pc[16];
     ^
jni/x264/include/x264.h:357:5: error: unknown type name 'uint8_t'
     uint8_t     cqm_8iy[64];
     ^
jni/x264/include/x264.h:358:5: error: unknown type name 'uint8_t'
     uint8_t     cqm_8py[64];
     ^
jni/x264/include/x264.h:359:5: error: unknown type name 'uint8_t'
     uint8_t     cqm_8ic[64];
     ^
jni/x264/include/x264.h:360:5: error: unknown type name 'uint8_t'
     uint8_t     cqm_8pc[64];
     ^
jni/x264/include/x264.h:475:5: error: unknown type name 'uint32_t'
     uint32_t i_fps_num;
     ^
jni/x264/include/x264.h:476:5: error: unknown type name 'uint32_t'
     uint32_t i_fps_den;
     ^
jni/x264/include/x264.h:477:5: error: unknown type name 'uint32_t'
     uint32_t i_timebase_num;    /* Timebase numerator */
     ^
jni/x264/include/x264.h:478:5: error: unknown type name 'uint32_t'
     uint32_t i_timebase_den;    /* Timebase denominator */
     ^
jni/x264/include/x264.h:563:34: error: unknown type name 'uint8_t'
 void x264_nal_encode( x264_t *h, uint8_t *dst, x264_nal_t *nal );
                                  ^
jni/x264/include/x264.h:571:5: error: unknown type name 'uint8_t'
     uint8_t  level_idc;
     ^
jni/x264/include/x264.h:572:5: error: unknown type name 'uint32_t'
     uint32_t mbps;        /* max macroblock processing rate (macroblocks/sec) */
     ^
jni/x264/include/x264.h:573:5: error: unknown type name 'uint32_t'
     uint32_t frame_size;  /* max frame size (macroblocks) */
     ^
jni/x264/include/x264.h:574:5: error: unknown type name 'uint32_t'
     uint32_t dpb;         /* max decoded picture buffer (mbs) */
     ^
jni/x264/include/x264.h:575:5: error: unknown type name 'uint32_t'
     uint32_t bitrate;     /* max bitrate (kbit/sec) */
     ^
jni/x264/include/x264.h:576:5: error: unknown type name 'uint32_t'
     uint32_t cpb;         /* max vbv buffer (kbit) */
     ^
jni/x264/include/x264.h:577:5: error: unknown type name 'uint16_t'
     uint16_t mv_range;    /* max vertical mv component range (pixels) */
     ^
jni/x264/include/x264.h:578:5: error: unknown type name 'uint8_t'
     uint8_t  mvs_per_2mb; /* max mvs per 2 consecutive mbs. */
     ^
jni/x264/include/x264.h:579:5: error: unknown type name 'uint8_t'
     uint8_t  slice_rate;  /* ?? */
     ^
jni/x264/include/x264.h:580:5: error: unknown type name 'uint8_t'
     uint8_t  mincr;       /* min compression ratio */
     ^
jni/x264/include/x264.h:581:5: error: unknown type name 'uint8_t'
     uint8_t  bipred8x8;   /* limit bipred to >=8x8 */
     ^
jni/x264/include/x264.h:582:5: error: unknown type name 'uint8_t'
     uint8_t  direct8x8;   /* limit b_direct to >=8x8 */
     ^
jni/x264/include/x264.h:583:5: error: unknown type name 'uint8_t'
     uint8_t  frame_only;  /* forbid interlacing */
     ^
jni/x264/include/x264.h:719:5: error: unknown type name 'uint8_t'
     uint8_t *payload;
     ^
jni/x264/include/x264.h:735:5: error: unknown type name 'uint8_t'
     uint8_t *plane[4];   /* Pointers to each plane */
     ^
jni/x264/include/x264.h:775:5: error: unknown type name 'uint8_t'
     uint8_t *mb_info;
     ^
jni/x264/include/x264.h:811:5: error: unknown type name 'int64_t'
     int64_t i_pts;
     ^
jni/x264/include/x264.h:814:5: error: unknown type name 'int64_t'
     int64_t i_dts;
     ^
jni/x264/include/x264.h:951:50: error: unknown type name 'int64_t'
 int x264_encoder_invalidate_reference( x264_t *, int64_t pts );
                                                  ^
make: *** [obj/local/armeabi/objs/live/live/live.o] Error 1

**** Build Finished ****

错误原因:在使用x264头文件前需要引入#include

#include <stdint.h>
#include "x264/include/x264.h"

2、错误:


**** Build of configuration Default for project Live ****

/Users/liujian/dev/adt-bundle-mac-x86_64-20140702/ndk/android-ndk-r10e/ndk-build all 
libs/libx264.a
libs/libfaac.a
live/live.c
[armeabi] Compile thumb  : live <= live.c
[armeabi] SharedLibrary  : liblive.so
jni/libs/libx264.a(encoder-8.o):encoder.c:function validate_parameters: error: undefined reference to 'log2f'
jni/libs/libx264.a(encoder-8.o):encoder.c:function validate_parameters: error: undefined reference to 'log2f'
jni/libs/libx264.a(encoder-8.o):encoder.c:function x264_8_encoder_reconfig: error: undefined reference to 'log2f'
jni/libs/libx264.a(encoder-8.o):encoder.c:function x264_8_encoder_reconfig: error: undefined reference to 'log2f'
jni/libs/libx264.a(ratecontrol-8.o):ratecontrol.c:function x264_8_ratecontrol_new: error: undefined reference to 'log2'
jni/libs/libx264.a(ratecontrol-8.o):ratecontrol.c:function x264_8_ratecontrol_new: error: undefined reference to 'log2'
jni/libs/libx264.a(ratecontrol-8.o):ratecontrol.c:function x264_8_ratecontrol_new: error: undefined reference to 'log2'
jni/libs/libx264.a(ratecontrol-10.o):ratecontrol.c:function x264_10_ratecontrol_new: error: undefined reference to 'log2'
collect2: error: ld returned 1 exit status
make: *** [obj/local/armeabi/liblive.so] Error 1

**** Build Finished ****

错误位置:

APP_PLATFORM := android-9

解决方法:
在Application.mk使用

APP_PLATFORM := android-19

猜你喜欢

转载自blog.csdn.net/liujian8654562/article/details/80165345