x264 android移植

x264 android移植  ndk下编译

1.下载x264源码(我的版本是x264-snapshot-20130215-2245)

    http://www.videolan.org/developers/x264.html

2.解压,生成x264-snapshot-20130215-2245目录,我这改成x264(只为简单),进到x264目录下,新建jni目录,将其他的所有文件及文件夹放到jni目录下

3.进到x264/jni目录下,在终端中打开,并运行

[cpp]  view plain  copy
  1. lx@PC120288:~/x264/jni$ ./configure --disable-asm  

4.打开config.h文件,将里面的所有内容替换为

[cpp]  view plain  copy
  1. #define HAVE_MALLOC_H 1  
  2. #define ARCH_ARM 1  
  3. #define SYS_LINUX 0  
  4. #define HAVE_POSIXTHREAD 1  
  5. #define HAVE_CPU_COUNT 1  
  6. #define HAVE_THREAD 1  
  7. #define HAVE_LOG2F 0  
  8. #define HAVE_SWSCALE 0  
  9. #define HAVE_VECTOREXT 1  
  10. #define fseek fseeko  
  11. #define ftell ftello  
  12. #define HAVE_GPL 1  
  13. #define HAVE_INTERLACED 1  
  14. #define HAVE_ALTIVEC 0  
  15. #define HAVE_ALTIVEC_H 0  
  16. #define HAVE_MMX 0  
  17. #define HAVE_ARMV6 0  
  18. #define HAVE_ARMV6T2 0  
  19. #define HAVE_NEON 0  
  20. #define HAVE_BEOSTHREAD 0  
  21. #define HAVE_WIN32THREAD 0  
  22. #define HAVE_VISUALIZE 0  
  23. #define HAVE_LAVF 0  
  24. #define HAVE_FFMS 0  
  25. #define HAVE_GPAC 0  
  26. #define HAVE_GF_MALLOC 0  
  27. #define HAVE_AVS 0  

5.新建Android.mk文件,里面的内容为

[cpp]  view plain  copy
  1. LOCAL_PATH := $(call my-dir)  
  2.   
  3. include $(CLEAR_VARS)  
  4.   
  5. CONFIG := $(shell cat config.h)  
  6.   
  7. SRCS = common/mc.c common/predict.c common/pixel.c common/macroblock.c \  
  8.        common/frame.c common/dct.c common/cpu.c common/cabac.c \  
  9.        common/common.c common/osdep.c common/rectangle.c \  
  10.        common/set.c common/quant.c common/deblock.c common/vlc.c \  
  11.        common/mvpred.c common/bitstream.c \  
  12.        encoder/analyse.c encoder/me.c encoder/ratecontrol.c \  
  13.        encoder/set.c encoder/macroblock.c encoder/cabac.c \  
  14.        encoder/cavlc.c encoder/encoder.c encoder/lookahead.c  
  15.   
  16. SRCCLI = x264.c input/input.c input/timecode.c input/raw.c input/y4m.c \  
  17.          output/raw.c output/matroska.c output/matroska_ebml.c \  
  18.          output/flv.c output/flv_bytestream.c filters/filters.c \  
  19.          filters/video/video.c filters/video/source.c filters/video/internal.c \  
  20.          filters/video/resize.c filters/video/cache.c filters/video/fix_vfr_pts.c \  
  21.          filters/video/select_every.c filters/video/crop.c filters/video/depth.c  
  22.   
  23. # GPL-only files  
  24. ifneq ($(findstring HAVE_GPL 1, $(CONFIG)),)  
  25. SRCCLI +=  
  26. endif  
  27.   
  28. # Optional module sources  
  29. ifneq ($(findstring HAVE_AVS 1, $(CONFIG)),)  
  30. SRCCLI += input/avs.c  
  31. endif  
  32.   
  33. ifneq ($(findstring HAVE_THREAD 1, $(CONFIG)),)  
  34. SRCCLI += input/thread.c  
  35. SRCS   += common/threadpool.c  
  36. endif  
  37.   
  38. ifneq ($(findstring HAVE_WIN32THREAD 1, $(CONFIG)),)  
  39. SRCS += common/win32thread.c  
  40. endif  
  41.   
  42. ifneq ($(findstring HAVE_LAVF 1, $(CONFIG)),)  
  43. SRCCLI += input/lavf.c  
  44. endif  
  45.   
  46. ifneq ($(findstring HAVE_FFMS 1, $(CONFIG)),)  
  47. SRCCLI += input/ffms.c  
  48. endif  
  49.   
  50. ifneq ($(findstring HAVE_GPAC 1, $(CONFIG)),)  
  51. SRCCLI += output/mp4.c  
  52. endif  
  53.   
  54. # Visualization sources  
  55. ifneq ($(findstring HAVE_VISUALIZE 1, $(CONFIG)),)  
  56. SRCS   += common/visualize.c common/display-x11.c  
  57. endif  
  58.   
  59. # NEON optims  
  60.   
  61. ASMSRC += common/arm/cpu-a.S common/arm/pixel-a.S common/arm/mc-a.S \  
  62.           common/arm/dct-a.S common/arm/quant-a.S common/arm/deblock-a.S \  
  63.           common/arm/predict-a.S  
  64. SRCS   += common/arm/mc-c.c common/arm/predict-c.c  
  65.   
  66.   
  67. ifneq ($(HAVE_GETOPT_LONG),1)  
  68. SRCCLI += extras/getopt.c  
  69. endif  
  70.   
  71. LOCAL_SRC_FILES := $(SRCS) $(SRCCLI) $(ASMSRC)  
  72.   
  73. LOCAL_C_INCLUDES :=  \  
  74.     $(LOCAL_PATH) \  
  75.     $(LOCAL_PATH)/input \  
  76.     $(LOCAL_PATH)/output \  
  77.     $(LOCAL_PATH)/encoder \  
  78.     $(LOCAL_PATH)/filters \  
  79.     $(LOCAL_PATH)/filters/video \  
  80.     $(LOCAL_PATH)/common \  
  81.     $(LOCAL_PATH)/common/arm \  
  82.   
  83.   
  84. LOCAL_PRELINK_MODULE := false  
  85. LOCAL_MODULE := libx264  
  86. LOCAL_CFLAGS+= -std=c99    
  87. LOCAL_CFLAGS+= -lpthread -lm  
  88.   
  89. LOCAL_ARM_MODE:= arm  
  90.   
  91.   
  92. LOCAL_MODULE_TAGS := optional  
  93.   
  94. include $(BUILD_SHARED_LIBRARY)  

6.运行

[cpp]  view plain  copy
  1. lx@PC120288:~/x264/jni$ ndk-build  

7.有报错,是两个汇编文件,注释掉出错的对应行(在出错的行前面加'#'注释)


8.再次编译运行,即可生成so库,我这边的结果如下

[cpp]  view plain  copy
  1. Compile arm    : x264 <= mc.c  
  2. Compile arm    : x264 <= predict.c  
  3. Compile arm    : x264 <= pixel.c  
  4. Compile arm    : x264 <= macroblock.c  
  5. Compile arm    : x264 <= frame.c  
  6. Compile arm    : x264 <= dct.c  
  7. Compile arm    : x264 <= cpu.c  
  8. Compile arm    : x264 <= cabac.c  
  9. Compile arm    : x264 <= common.c  
  10. Compile arm    : x264 <= osdep.c  
  11. Compile arm    : x264 <= rectangle.c  
  12. Compile arm    : x264 <= set.c  
  13. Compile arm    : x264 <= quant.c  
  14. Compile arm    : x264 <= deblock.c  
  15. Compile arm    : x264 <= vlc.c  
  16. Compile arm    : x264 <= mvpred.c  
  17. Compile arm    : x264 <= bitstream.c  
  18. Compile arm    : x264 <= analyse.c  
  19. Compile arm    : x264 <= me.c  
  20. Compile arm    : x264 <= ratecontrol.c  
  21. Compile arm    : x264 <= set.c  
  22. Compile arm    : x264 <= macroblock.c  
  23. Compile arm    : x264 <= cabac.c  
  24. Compile arm    : x264 <= cavlc.c  
  25. Compile arm    : x264 <= encoder.c  
  26. Compile arm    : x264 <= lookahead.c  
  27. Compile arm    : x264 <= threadpool.c  
  28. Compile arm    : x264 <= mc-c.c  
  29. /home/lx/x264/jni/common/arm/mc-c.c: In function 'x264_weight_cache_neon':  
  30. /home/lx/x264/jni/common/arm/mc-c.c:89: warning: assignment discards qualifiers from pointer target type  
  31. /home/lx/x264/jni/common/arm/mc-c.c:94: warning: assignment discards qualifiers from pointer target type  
  32. /home/lx/x264/jni/common/arm/mc-c.c:99: warning: assignment discards qualifiers from pointer target type  
  33. /home/lx/x264/jni/common/arm/mc-c.c:101: warning: assignment discards qualifiers from pointer target type  
  34. /home/lx/x264/jni/common/arm/mc-c.c: In function 'x264_mc_init_arm':  
  35. /home/lx/x264/jni/common/arm/mc-c.c:236: warning: assignment discards qualifiers from pointer target type  
  36. /home/lx/x264/jni/common/arm/mc-c.c:237: warning: assignment discards qualifiers from pointer target type  
  37. /home/lx/x264/jni/common/arm/mc-c.c:238: warning: assignment discards qualifiers from pointer target type  
  38. Compile arm    : x264 <= predict-c.c  
  39. Compile arm    : x264 <= x264.c  
  40. Compile arm    : x264 <= input.c  
  41. Compile arm    : x264 <= timecode.c  
  42. Compile arm    : x264 <= raw.c  
  43. Compile arm    : x264 <= y4m.c  
  44. Compile arm    : x264 <= raw.c  
  45. Compile arm    : x264 <= matroska.c  
  46. Compile arm    : x264 <= matroska_ebml.c  
  47. Compile arm    : x264 <= flv.c  
  48. Compile arm    : x264 <= flv_bytestream.c  
  49. Compile arm    : x264 <= filters.c  
  50. Compile arm    : x264 <= video.c  
  51. Compile arm    : x264 <= source.c  
  52. Compile arm    : x264 <= internal.c  
  53. Compile arm    : x264 <= resize.c  
  54. Compile arm    : x264 <= cache.c  
  55. Compile arm    : x264 <= fix_vfr_pts.c  
  56. Compile arm    : x264 <= select_every.c  
  57. Compile arm    : x264 <= crop.c  
  58. Compile arm    : x264 <= depth.c  
  59. Compile arm    : x264 <= thread.c  
  60. Compile arm    : x264 <= getopt.c  
  61. /home/lx/x264/jni/extras/getopt.c: In function '_getopt_internal':  
  62. /home/lx/x264/jni/extras/getopt.c:577: warning: implicit declaration of function 'strcmp'  
  63. /home/lx/x264/jni/extras/getopt.c:653: warning: implicit declaration of function 'strncmp'  
  64. /home/lx/x264/jni/extras/getopt.c:656: warning: implicit declaration of function 'strlen'  
  65. /home/lx/x264/jni/extras/getopt.c:656: warning: incompatible implicit declaration of built-in function 'strlen'  
  66. /home/lx/x264/jni/extras/getopt.c:683: warning: incompatible implicit declaration of built-in function 'strlen'  
  67. /home/lx/x264/jni/extras/getopt.c:715: warning: incompatible implicit declaration of built-in function 'strlen'  
  68. /home/lx/x264/jni/extras/getopt.c:731: warning: incompatible implicit declaration of built-in function 'strlen'  
  69. /home/lx/x264/jni/extras/getopt.c:736: warning: incompatible implicit declaration of built-in function 'strlen'  
  70. /home/lx/x264/jni/extras/getopt.c:847: warning: incompatible implicit declaration of built-in function 'strlen'  
  71. /home/lx/x264/jni/extras/getopt.c:870: warning: incompatible implicit declaration of built-in function 'strlen'  
  72. /home/lx/x264/jni/extras/getopt.c:890: warning: incompatible implicit declaration of built-in function 'strlen'  
  73. /home/lx/x264/jni/extras/getopt.c:904: warning: incompatible implicit declaration of built-in function 'strlen'  
  74. /home/lx/x264/jni/extras/getopt.c:908: warning: incompatible implicit declaration of built-in function 'strlen'  
  75. Compile arm    : x264 <= cpu-a.S  
  76. Compile arm    : x264 <= pixel-a.S  
  77. Compile arm    : x264 <= mc-a.S  
  78. Compile arm    : x264 <= dct-a.S  
  79. Compile arm    : x264 <= quant-a.S  
  80. /home/lx/x264/jni/common/arm/quant-a.S: Assembler messages:  
  81. /home/lx/x264/jni/common/arm/quant-a.S:222: Rd and Rm should be different in mul  
  82. /home/lx/x264/jni/common/arm/quant-a.S:223: Rd and Rm should be different in mul  
  83. /home/lx/x264/jni/common/arm/quant-a.S:227: Rd and Rm should be different in mul  
  84. Compile arm    : x264 <= deblock-a.S  
  85. Compile arm    : x264 <= predict-a.S  
  86. SharedLibrary  : libx264.so  
  87. Install        : libx264.so => libs/armeabi/libx264.so  

大家可以一试,可能有的代码并未编进库中。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值