├── .gitignore ├── .gitmodules ├── Changelog ├── LICENSE ├── README.md ├── _amr_build.sh ├── _ffmpeg_build.sh ├── _lame_build.sh ├── _settings.sh ├── _vpx_build.sh ├── _x264_build.sh ├── build-ffmpeg4android.sh ├── ffmpeg-android_patch.sh ├── ffmpeg-pkg-config ├── init_update_libs.sh ├── patches ├── 01.ffmpeg_aacoder.patch ├── 02.ffmpeg_hevc_mvs.patch ├── 03.ffmpeg_opus_pvq.patch ├── 04.ffmpeg_v4l2.patch ├── 10.libvpx_configure.sh.patch ├── 10.vpx_encoder_h.patch ├── 11.libvpx_filter_x86.c.patch ├── 12.libvpx_deblock.c.patch ├── 13.libvpx_mem.h.patch ├── 21.x264_configure.patch ├── 31.lame_configure.patch ├── 41.fontconfig_fcxml.patch ├── Readme.txt └── ffmpeg-1.0.10 │ ├── 10.ffmpeg-configure.patch │ ├── 11.ffmpeg-libx264.c.patch │ ├── 12.ffmpeg-pixdesc.c.patch │ ├── 13.ffmpeg-pixdesc.h.patch │ ├── 14.ffmpeg-svq3.c.patch │ └── ffmpeg-1.0.10_patch.sh └── source ├── ffmpeg-4.4.tar.bz2 ├── lame-3.100.tar.gz ├── v1.10.0.tar.gz └── x264-stable.tar.bz2 /.gitignore: -------------------------------------------------------------------------------- 1 | jni/lame/android/*/share 2 | jni/lame/android/*/bin 3 | toolchain-* 4 | libpng 5 | lame 6 | x264 7 | ffmpeg 8 | 9 | # Created by http://www.gitignore.io 10 | # Prerequisites 11 | *.d 12 | 13 | # Object files 14 | *.o 15 | *.ko 16 | *.obj 17 | *.elf 18 | 19 | # Linker output 20 | *.ilk 21 | *.map 22 | *.exp 23 | 24 | # Precompiled Headers 25 | *.gch 26 | *.pch 27 | 28 | # Libraries 29 | *.lib 30 | *.a 31 | *.la 32 | *.lo 33 | 34 | # Shared objects (inc. Windows DLLs) 35 | *.dll 36 | *.so 37 | *.so.* 38 | *.dylib 39 | 40 | # Executables 41 | *.exe 42 | *.out 43 | *.app 44 | *.i*86 45 | *.x86_64 46 | *.hex 47 | 48 | # Debug files 49 | *.dSYM/ 50 | *.su 51 | *.idb 52 | *.pdb 53 | 54 | # Kernel Module Compile Results 55 | *.mod* 56 | *.cmd 57 | .tmp_versions/ 58 | modules.order 59 | Module.symvers 60 | Mkfile.old 61 | dkms.conf 62 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "ffmpeg"] 2 | path = ffmpeg 3 | url = git://source.ffmpeg.org/ffmpeg.git 4 | [submodule "x264"] 5 | path = x264 6 | url = git://git.videolan.org/x264.git 7 | 8 | -------------------------------------------------------------------------------- /Changelog: -------------------------------------------------------------------------------- 1 | # Entries are sorted chronologically from oldest to youngest within each release, 2 | # releases are sorted from youngest to oldest. 3 | #============================================================= 4 | version 1.6.8 (2021/07/19) 5 | - Clean up scripts for all submodules build 6 | - Change method to determine ffmpeg version 7 | - include version check in init_update_libs.sh before taking action 8 | - include patch for libvpx-1.10.0 9 | - Scripts are verified for all latest version libraries only; see init_update_libs.sh 10 | 11 | #============================================================= 12 | version 1.6.7 (2021/05/17) 13 | - Clean up scripts for ffmpeg v4.4 build 14 | - Clean up scripts for x264 v161.3049 build 15 | 16 | #============================================================= 17 | version 1.6.6 (2021/04/28) 18 | - Clean up scripts for libvpx v1.10.0 build 19 | 20 | #============================================================= 21 | version 1.6.5 (2020/07/25) 22 | - add amr codec 23 | - use option --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 24 | 25 | #============================================================= 26 | version 1.6.4 (2020/07/17) 27 | - Clean up scripts for libvpx v1.8.2 build 28 | - Update lame patch file to use configure file for version extraction 29 | - Include solution for ffmpeg 4.1.1 when compiled with NDK r18b 30 | 31 | #============================================================= 32 | version 1.6.3 (2019/05/24) 33 | - use option --enable-runtime-cpu-detect for x86/x86_64 platforms in vpx library build to fix runtime problem 34 | 35 | #============================================================= 36 | version 1.6.2 (2019/03/29) 37 | - Add support for ffmpeg-1.0.10 build with clang (generated *.a libraries seems large) 38 | - Include patches for ffmpeg-1.0.10 39 | - Include --disable-asm for arm/arm64 for ffmpeg-1.0.10 when using clang due to errors 40 | 41 | #============================================================= 42 | vesrion 1.6.1 (2019/03/28) 43 | - Add new patches for libvpx fixing: relocation R_386_GOTOFF against preemptible symbol... (valid for v1.8.0, v1.7.0 & v1.6.1+) 44 | - Add new patches for libvpx fixing: sysroot for arm64-v8a 45 | - Add option --enable-pic (required when using SDK toolchains) 46 | - Add option to build standalone ffmpeg (aTalk) without the inclusion of the codec sub-modules 47 | - Add option --disable-postproc to ffmpeg build 48 | - Add dependency for options that are ABIS depends in __build.sh scripts 49 | - Clean up README.md information 50 | - Display module version in applying patches and building process 51 | 52 | #============================================================= 53 | version 1.6.0 (2019/03/18) 54 | - Use ffmpeg-4.1.1, libvpx-1.8.0, x264-157 and lame-3.100 for verification 55 | - Upate patches to include libvpx and x264 etc 56 | - Update _vpx_build.sh to use SDK or Standalone toolchains (see _vpx_build.sh for details) 57 | - Change prefix to each sub-modules sub-directory for compatibility with aTalk 58 | - prefix all sub-modules script file with '_' for better clarifications 59 | - Cleanup all build scripts and readme file 60 | 61 | #============================================================= 62 | version 1.5.0 (2018/07/24): 63 | - clean up build scripts 64 | - Library ffmpeg use version 4.0.2 65 | - Library libvpx use version 1.7.x (master-20180727) 66 | 67 | #============================================================= 68 | version 1.4.0 (2018/03/24): 69 | - move LDFLAGS to ffmpeg_build.sh - only requires for final ffmpeg linkage 70 | - libvpx still has configure error for Target=arm64-android-gcc 71 | 72 | #============================================================= 73 | version 1.3.0 (2018/03/21): 74 | - cleanup and add libvpx options to _settings.sh 75 | - include libvpx build (ndk-r15c only and r16b has errors - see vpx_build.sh) 76 | - libvpx for arm64-v8a needs neon options, however libvpx.a not compatible with ffmpeg 77 | - remove -nostadlib option in LDFLAGS, lame check stdlib for linkage 78 | 79 | #============================================================= 80 | version 1.2.0 (2018/03/18): 81 | - update init_update_libs.sh to use lame-3.100 for aarch64 support; arm64-v8a libx.a has own undefined references 82 | - change mips/mips64 cpu to use p5600/i6400 - ones that have been verified working 83 | - ABI mips64 : -march=mips64r6 accepts by clang50 but complain by ffmpeg 84 | -march=i6400 works for ffmpeg but complain by clang50; omit it in CFLAG - works for both 85 | 86 | #============================================================= 87 | version 1.1.0 (2018/03/14): 88 | - clean up _settings.sh export parameters 89 | - default to use API-21 for 64bit build 90 | - use same PREFIX directory for all compiled sub-modules static libraries 91 | - change FFMPEG_PKG_CONFIG to point to PREFIX directory 92 | - apply patches for ffmpeg files (#undefine B0) 93 | 94 | #============================================================= 95 | version 1.0.0 (2018/03/11): 96 | - initial release 97 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ffmpeg-android 2 | 3 | * FFmpeg for Android with libvpx, x264 and lame options. The scripts in this repository are configured to build: 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
libraryversionplatform supportarch support
ffmpeg4.4androidarmeabi-v7a arm64-v8a x86 x86_64
x264163androidarmeabi-v7a arm64-v8a x86 x86_64
libvpx1.10.0androidarmeabi-v7a arm64-v8a x86 x86_64
lame3.100androidarmeabi-v7a arm64-v8a x86 x86_64
13 | 14 | ## Supported android ABI's 15 | * armeabi* 16 | * armeabi-v7a 17 | * arm64-v8a 18 | * x86 19 | * x86_64 20 | * mips* 21 | * mips64* 22 | 23 | Note: *-Deprecated in android ndk-r16. Will be removed in ndk-r17.
24 | see https://developer.android.com/ndk/guides/abis.html#Supported ABIs
25 | ffmpeg-andorid releases > v1.5.0 will only verify ABIS=("armeabi-v7a" "arm64-v8a" "x86" "x86_64") 26 | 27 | ## Instructions 28 | * Note: Please refer to https://github.com/cmeng-git/atalk-android/tree/master/aTalk/jni for the latest 29 | updated scripts and build instructions. This repository is not further maintained since v1.6.8. 30 | * Set environment ANDROID_NDK variable; not all ndk releases work with all modules/ABIS combinations 31 | - export ANDROID_NDK={Android NDK Base Path}
32 | e.g. export ANDROID_NDK=/opt/android/android-ndk-r17c (recommended); 33 | - Note: android-ndk-r18b will have problem in some module builds e.g. lame 34 | * If necessary, fetch and update all libraries source (before build); 35 | - review and edit ./init_update_libs.sh file for your desired modules' versions, then run 36 | - ./init_update_libs.sh 37 | - The default codec module extracted sub-directories are ffmpeg, libvpx, x264 and lame 38 | - Optionally, go to the respective directory for each sub-module, and execute ./configure without option;
39 | The configure process may list any missing sdk build tools, please install before continue 40 | - The actual configure with options for each submodule build is done in each submodule _\_build.sh build script 41 | * Edit ./ffmpeg-android_build.sh \[#1] and ./_settings.sh \[#2];
42 | a. remove any of the codec sub-modules or architectures you wish to be excluded from the build
43 | b. add "ffmpeg" only to \[#1] if you want to build standalone ffmpeg without inclusion of the sub-modules integration
44 | c. the default values are defined as: 45 | - MODULES=("vpx" "x264" "lame") \[#1] 46 | - ABIS=("armeabi-v7a" "arm64-v8a" "x86" "x86_64") \[#2] 47 | * To support 64-bit libraries built, ensure _settings.sh#ANDROID_API=21 (min API for 64-bit library build).
48 | Note: application.mk in Android Studio i.e. APP_PLATFORM := android-21 i.e. both must use the same API 49 | * Use the following commands to compile ffmpeg for all or custom defined modules/ABI's combinations 50 | - ./ffmpeg-android_build.sh
: (combinaiton as specified in the \[#1] and \[#2]) 51 | - ./ffmpeg-android_build.sh armeabi-v7a
: (i.e. selected cpu with all predefined codec modules) 52 | - ./ffmpeg-android_build.sh armeabi-v7a x264
: (i.e. selected cpu with only x264 codec module) 53 | * All the generated static/shared libraries and includes files are installed in ./jni/\/android/\. 54 | 55 | ## Linking with versioned shared library in Android NDK 56 | * Note: Manual changes as outlined below are not further required.
57 | the latest _vpx_build.sh has included the scripts to perform the following steps automatically. 58 | * Android has an issue with loading versioned .so shared libraries e.g. x264: 59 | * Causing error during run: java.lang.UnsatisfiedLinkError: dlopen failed: library "libx264.so.147" not found 60 | * Perform the following patches, if you want to link with shared .so libraries for x264. 61 | 1. use GHex to change file content "libx264.so.147" to "libx264_147.so" 62 | 2. change filename from libx264.so.147 to libx264_147.so 63 | 3. Note: the .so filename must match with the file changed content 64 | 65 | 66 | ## Verification Status 67 | * The scripts has been verified working with the following configurations: 68 | - NDK version: ndk-r17c (build may failed with lower or higher versions - see below) 69 | - ABIS: armeabi-v7a, arm64-v8a, x86, x86_64 70 | - MODULES (with applied patches): ffmpeg-v4.4, libvpx-v1.10.0, x264-v163, lame-v3.100 71 | - ANDROID_API: 21 72 | 73 | * x264 (v163, v161, v160, v157 and v152): 74 | - x264 option: --disable-asm
75 | Must exclude the option for arm64. Used by configure, config.mak and Makefile to define AS and to compile required *.S assembly files.
76 | Otherwise will have undefined references e.g. x264_8_... x264_10...
77 | However must include the option for x86 and x86_64; otherwise have relocate text, requires dynamic R_X86_64_PC32 etc when use in aTalk 78 | - ndk-r18b, ndk-r17c, ndk-16b, ndk-r15c (build all) 79 | 80 | * libvpx (v1.10.0, v.1.8.2, v1.8.0): 81 | - libvpx configure.sh needs patches to correctly build the arm64 with NDK standalone toolchains. 82 | - Valid for libvpx v1.8.0 only, option removed for libvpx v1.8.2+:
83 | When --sdk-path is specified, libvpx configure uses SDK toolchains compiler (gcc/g++); 84 | * ndk-r18b, ndk-r17c, ndk-r16b:
85 | To avoid missing stdlib.h and other errors, need to include the following two options for SDK toolchains:
86 | --extra-cflags="-isystem ${NDK}/sysroot/usr/include/${NDK_ABIARCH} -isystem ${NDK}/sysroot/usr/include"
87 | --libc=${NDK_SYSROOT} => use standalone toolchains directory.
88 | libvpx v1.8.0 configure.sh has a problem configure this with SDK properly 89 | * ndk-r18b: gcc option has been removed
90 | build failed with: /home/cmeng/workspace/ndk/ffmpeg-android/toolchain-android/bin/aarch64-linux-android-ld: cannot find -lgcc 91 | - libvpx v1.8.0: When using standalone toolchains, i.e. omit --sdk-path; 92 | * ndk-r18b, ndk-r17c, ndk-r16b:
93 | Build ok with ABIS=("arm64-v8a" "x86" "x86_64") but not "armeabi-v7a" and failed with:
94 | /tmp/vpx-conf-4350-25363.o(.ARM.exidx.text.main+0x0): error: undefined reference to '__aeabi_unwind_cpp_pr0' 95 | - For libvpx v1.8.2+ 96 | * ndk-r18b, ndk-r17c, ndk-r16b:
97 | All built OK. 98 | 99 | * lame (v3.1000): 100 | - ndk-r18b - failed as lame need C++ instead of clang compiler 101 | - ndk-r17b - build all and can integrate with ffmpeg 102 | - ndk-r16b, ndk-r15c (build all) 103 | - PREFIX must use absolution path 104 | 105 | * ffmpeg (v4.4): 106 | - Must include option --disable-asm for x86 and x86_64, otherwise
107 | libavcodec/x86/cabac.h:193:9: error: inline assembly requires more registers than available
108 | ffmpeg (v1.0.10) => must also include this option for arm/arm64 build, otherwise errors during compilation 109 | - ndk-r18b, ndk-r17c => give error on:
110 | libavdevice/v4l2.c:135:9: error: assigning to 'int (*)(int, unsigned long, ...)' from incompatible type '' 111 | SET_WRAPPERS();
112 | add to CFLAG: -DBIONIC_IOCTL_NO_SIGNEDNESS_OVERLOAD; see https://github.com/tanersener/mobile-ffmpeg/issues/48 113 | - ndk-r16b or lower => gives error on:
114 | libavformat/udp.c:290:28: error: member reference base type '__be32' (aka 'unsigned int') is not a structure or union
115 | mreqs.imr_multiaddr.s_addr = ((struct sockaddr_in *)addr)->sin_addr.s_addr; 116 | 117 | * Note: 118 | - NDK verification status (build with clang/clang++ and API-21 unless otherwise specified): 119 | - Recommendation: use ndk-r17c (work for all) and API-21 unless you have other considerations. 120 | - clang support needs min ndk-r12c, but may not necessary works for all ABIS (64-bit built has problem) 121 | - Change _settings.sh with clang=>gcc and clang++=>g++ if you need lower ndk version 122 | - NDK >r18b has obsoleted the support for the gcc/g++ 123 | 124 | ## Help: 125 | * Set up Linux/Ubuntu development environment with the below build tools 126 | - sudo apt-get --quiet --yes install build-essential git autoconf libtool pkg-config gperf gettext yasm python-lxml 127 | * Patches for Sub-module 128 | - ./ffmpeg-android_build.sh includes the patches for the sub-modules 129 | - ffmpeg-android_patch.sh applies patches to the relevant sub-module with patch files from ./pathes directory 130 | - edit these files to include additional patches if required. 131 | * Configuration failed 132 | - You may encounter this problem during the codec sub-module build, navigate to the respective sub-module directory: 133 | - Issue the command line i.e. configure --help to check for the available options 134 | - Refer to config.log of the sub-module for more info. 135 | - Refer to the configure file for more information on CPU types supported 136 | - Edit the script file to make the necessary modifications based on help and errors found in config.log 137 | * During sub-module built, you may encountered compilation or linker errors, changing ndk version
may help to resolve the issues. 138 | However it may create new problems in another areas. 139 | 140 | * Utilize Modern Compiler Flags to Address Potential Security Issues 141 | - Stack execution protection: LDFLAGS="-z noexecstack" 142 | - Data relocation and protection (RELRO): LDLFAGS="-z relro -z now" 143 | - Stack-based Buffer Overrun Detection: CFLAGS=”-fstack-protector-strong” 144 | if using GCC 4.9 or newer, otherwise CFLAGS="-fstack-protector" 145 | - Position Independent Execution (PIE) CFLAGS="-fPIE -fPIC" LDFLAGS="-pie" (PIE for executables only) 146 | - Fortify source: CFLAGS="-O2 -D_FORTIFY_SOURCE=2" 147 | - Format string vulnerabilities: CFLAGS="-Wformat -Wformat-security" 148 | 149 | * All the information provided here are by trial and error; compiling and linkage are very sensitive to the
150 | modules version, configure options, and the NDK version used. You are advice to build without any changes
151 | to the scripts provided here to confirm working, before attempt to make any modifications. 152 | 153 | ## Note: 154 | * The scripts in this folder are not compatible with Unified Headers:
155 | See https://android.googlesource.com/platform/ndk/+/master/docs/UnifiedHeaders.md#supporting-unified-headers-in-your-build-system 156 | 157 | * Both the android NDK, ffmpeg and its sub-modules are in continous update, it is likely that
158 | some of the defined ABI's settings may need to be tweaked as submodule configure have new changes. 159 | 160 | Please refer to the following sites which may offer solution for problems you may experience. 161 | * https://ffmpeg.org/pipermail/ffmpeg-user/2016-January/030202.html 162 | * https://www.mail-archive.com/ffmpeg-devel@ffmpeg.org/msg62644.html 163 | * http://alientechlab.com/how-to-build-ffmpeg-for-android/ 164 | * https://en.wikipedia.org/wiki/List_of_ARM_microarchitectures 165 | * https://github.com/google/ExoPlayer/issues/3520 (VP9 builds failure with android-ndk-r16 #3520) 166 | * https://github.com/android-ndk/ndk/issues/190#issuecomment-375164450 (unknown type name __uint128_t on ndk-build #190) 167 | * https://android.googlesource.com/platform/bionic/+/master/docs/32-bit-abi.md 168 | * https://github.com/android-ndk/ndk/issues/477 (mmap causes compile errors on r15c (unknown identifier) #477) 169 | * https://github.com/android-ndk/ndk/issues/503 (implicit declaration of function 'mmap' #503) 170 | * https://github.com/nodejs/node/issues/18671 (Utilize Modern Compiler Flags to Address Potential Security Issues #18671) 171 | * https://android.googlesource.com/platform/external/libvpx/+/ca30a60d2d6fbab4ac07c63bfbf7bbbd1fe6a583 (Add visibility="protected" attribute for global variables referenced in asm files.) 172 | 173 | 174 | ## License 175 | 176 | ffmpeg, android static library for aTalk VoIP and Instant Messaging client 177 | 178 | Copyright 2014 Eng Chong Meng 179 | 180 | Licensed under the Apache License, Version 2.0 (the "License"); 181 | you may not use this file except in compliance with the License. 182 | You may obtain a copy of the License at 183 | 184 | http://www.apache.org/licenses/LICENSE-2.0 185 | 186 | Unless required by applicable law or agreed to in writing, software 187 | distributed under the License is distributed on an "AS IS" BASIS, 188 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 189 | See the License for the specific language governing permissions and 190 | limitations under the License. 191 | 192 | -------------------------------------------------------------------------------- /_amr_build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | . _settings.sh "$@" 3 | 4 | pushd opencore-amr || exit 5 | 6 | AMR_API="$(grep 'PACKAGE_VERSION=' < ${LIB_OPENCORE}/configure | sed 's/^.*\([0-9]\.[0-9]\.[0-9]*\).*$/\1/')" 7 | echo -e "\n\n** BUILD STARTED: opencore-amr-v${AMR_API} for ${1} **" 8 | 9 | # --disable-asm disable 10 | # Must exclude the option for arm64-v8a. 11 | # The option is used by configure, config.mak and Makefile files to define AS and to compile required *.S assembly files; 12 | # Otherwise will have undefined references e.g. x264_8_pixel_sad_16x16_neon if --disable-asm is specified 13 | # However must include the option for x86 and x86_64; 14 | # Otherwise have relocate text, requires dynamic R_X86_64_PC32 etc when use in aTalk 15 | 16 | DISASM="" 17 | if [[ $1 =~ x86.* ]]; then 18 | DISASM="--disable-asm" 19 | fi 20 | 21 | make clean 22 | ./configure \ 23 | --prefix=${PREFIX} \ 24 | --includedir=${PREFIX}/include/x264 \ 25 | --cross-prefix=${CROSS_PREFIX} \ 26 | --sysroot=${NDK_SYSROOT} \ 27 | --extra-cflags="-isystem ${NDK_SYSROOT}/usr/include/${NDK_ABIARCH} -isystem ${NDK_SYSROOT}/usr/include" \ 28 | --host=${HOST} \ 29 | --enable-pic \ 30 | --enable-static \ 31 | --enable-shared \ 32 | --disable-opencl \ 33 | --disable-thread \ 34 | ${DISASM} \ 35 | --disable-cli || exit 1 36 | 37 | make -j${HOST_NUM_CORES} install || exit 1 38 | echo -e "** BUILD COMPLETED: opencore-amr-v${AMR_API} for ${1} **\n" 39 | popd || true 40 | -------------------------------------------------------------------------------- /_ffmpeg_build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright 2016 Eng Chong Meng 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # set -x 17 | 18 | # https://gcc.gnu.org/onlinedocs/gcc-4.9.4/gcc/Link-Options.html#Link-Options 19 | # Data relocation and protection (RELRO): LDLFAGS="-z relro -z now" 20 | # i686-linux-android-ld: -Wl,-z,relro -Wl,-z,now: unknown options 21 | # lame checks stdlib for linkage! omit -nostdlib 22 | 23 | # LDFLAGS='-pie -fuse-ld=gold -Wl,-z,relro -Wl,-z,now -nostdlib -lc -lm -ldl -llog' 24 | # -fuse-ld=gold: use ld.gold linker but unavailable for ABI mips and mips64 25 | # LDFLAGS='-pie -lc -lm -ldl -llog' 26 | 27 | . _settings.sh "$@" 28 | 29 | LIB_FFMPEG=ffmpeg 30 | 31 | pushd ${LIB_FFMPEG} || return 32 | VERSION=$(cat RELEASE) 33 | 34 | echo -e "\n\n** BUILD STARTED: ${LIB_FFMPEG}-v${VERSION} for ${1} **" 35 | 36 | # Must include option --disable-asm; otherwise ffmpeg-3.4.6 has problem and crash system: 37 | # armeabi-v7a: org.atalk.android A/libc: Fatal signal 7 (SIGBUS), code 1, fault addr 0x9335c00c in tid 20032 (Loop thread: ne) 38 | # x86: ./i686-linux-android/bin/ld: warning: shared library text segment is not shareable 39 | # x86_64: e.g libswresample, libswscale, libavcodec: requires dynamic R_X86_64_PC32 reloc against ... 40 | # libavcodec/x86/cabac.h:193:9: error: inline assembly requires more registers than available 41 | # TA_OPTIONS="--disable-ffserver --disable-asm" 42 | 43 | # Note: Use the following option for ffmpeg 4.0+ build 44 | # Not valid for ffmpeg 4.0+: Removed the ffserver program 45 | # --disable-ffserver \ 46 | # Must include option --disable-asm for v4.1.6+ for x86 and x86_64 build; 47 | # libavcodec/x86/cabac.h:193:9: error: inline assembly requires more registers than available 48 | TA_OPTIONS="" 49 | 50 | case $1 in 51 | armeabi) 52 | LDFLAGS="${LDFLAGS} -Wl,-z,relro -Wl,-z,now" 53 | ;; 54 | armeabi-v7a) 55 | LDFLAGS="${LDFLAGS} -Wl,-z,relro -Wl,-z,now -Wl,--fix-cortex-a8" 56 | ;; 57 | arm64-v8a) 58 | # -Wl,--unresolved-symbols=ignore-in-shared-libs fixes x264 undefined references for arm64-v8a 59 | LDFLAGS="${LDFLAGS} -Wl,-z,relro -Wl,-z,now" 60 | ;; 61 | x86) 62 | # required for x86 in ffmpeg v4.0+ (see note above) 63 | TA_OPTIONS="--disable-asm" 64 | LDFLAGS="${LDFLAGS}" 65 | ;; 66 | x86_64) 67 | TA_OPTIONS="--disable-asm" 68 | LDFLAGS="${LDFLAGS}" 69 | ;; 70 | mips) 71 | LDFLAGS="${LDFLAGS} -Wl,-z,relro -Wl,-z,now" 72 | ;; 73 | mips64) 74 | LDFLAGS="${LDFLAGS} -Wl,-z,relro -Wl,-z,now" 75 | ;; 76 | esac 77 | # export LDFLAGS="-Wl,-rpath-link=${NDK_SYSROOT}/usr/lib -L${NDK_SYSROOT}/usr/lib ${LDFLAGS}" 78 | 79 | INCLUDES="" 80 | LIBS="" 81 | MODULES="" 82 | 83 | for m in "$@" 84 | do 85 | PREFIX_=${BASEDIR}/jni/$m/android/$1 86 | # PREFIX_=../jni/$m/android/$1 87 | [[ -d ${PREFIX}/lib/pkgconfig ]] || mkdir -p ${PREFIX}/lib/pkgconfig 88 | 89 | case $m in 90 | x264) 91 | INCLUDES="${INCLUDES} -I${PREFIX_}/include/$m" 92 | LIBS="${LIBS} -L${PREFIX_}/lib" 93 | cp -r ${PREFIX_}/lib/pkgconfig ${PREFIX}/lib 94 | MODULES="${MODULES} --enable-libx264 --enable-parser=h264" 95 | # --enable-libopenh264 --enable-encoder=libopenh264 --enable-decoder=libopenh264 for openh264 96 | ;; 97 | vpx) 98 | INCLUDES="${INCLUDES} -I${PREFIX_}/include" 99 | LIBS="${LIBS} -L${PREFIX_}/lib" 100 | cp -r ${PREFIX_}/lib/pkgconfig ${PREFIX}/lib 101 | MODULES="${MODULES} --enable-libvpx" 102 | ;; 103 | png) 104 | INCLUDES="${INCLUDES} -I${PREFIX_}/include" 105 | LIBS="${LIBS} -L${PREFIX_}/lib" 106 | cp -r ${PREFIX_}/lib/pkgconfig ${PREFIX}/lib 107 | MODULES="${MODULES} --enable-libpng" 108 | ;; 109 | lame) 110 | INCLUDES="${INCLUDES} -I${PREFIX_}/include" 111 | LIBS="${LIBS} -L${PREFIX_}/lib" 112 | # cp -r ${PREFIX_}/lib/pkgconfig ${PREFIX}/lib/pkgconfig 113 | MODULES="${MODULES} --enable-libmp3lame --disable-iconv" 114 | ;; 115 | amrwb) 116 | INCLUDES="${INCLUDES} -I${PREFIX_}/include" 117 | LIBS="${LIBS} -L${PREFIX_}/lib" 118 | cp -r ${PREFIX_}/lib/pkgconfig ${PREFIX}/lib 119 | MODULES="${MODULES} --enable-libopencore-amrwb --enable-libvo-amrwbenc" 120 | ;; 121 | esac 122 | done 123 | 124 | 125 | # libvpx does not support the build of share library 126 | # 127 | # --enable-gpl required for libpostproc build 128 | # --disable-postproc: https://trac.ffmpeg.org/wiki/Postprocessing 129 | # Anyway, most of the time it won't help to postprocess h.264, HEVC, VP8, or VP9 video. 130 | 131 | # When NDK is r17c or higher, the following error happen (r16b is OK) 132 | # libavdevice/v4l2.c:135:9: error: assigning to 'int (*)(int, unsigned long, ...)' from incompatible type '' 133 | # SET_WRAPPERS(); 134 | # see https://github.com/tanersener/mobile-ffmpeg/issues/48 for solution 135 | 136 | # do no set ld option and use as=gcc for clang 137 | TC_OPTIONS="--nm=${NM} --ar=${AR} --as=${AS} --strip=${STRIP} --cc=${CC} --cxx=${CXX}" 138 | # Below option not valid for ffmpeg-v1.0.10 (aTalk) 139 | # CODEC_DISABLED='--disable-alsa --disable-appkit --disable-avfoundation --disable-libv4l2 --disable-audiotoolbox' 140 | # --disable-programs --enable-x86asm \ 141 | 142 | FFMPEG_PKG_CONFIG=${BASEDIR}/ffmpeg-pkg-config 143 | # FFMPEG_PKG_CONFIG=../ffmpeg-pkg-config 144 | # PREFIX="../jni/ffmpeg/android/$1" 145 | # --disable-ffserver \ # valid for ffmpeg-1.0.10 only 146 | 147 | # Must include option --disable-asm for x86, otherwise 148 | # libavcodec/x86/cabac.h:193:9: error: inline assembly requires more registers than available 149 | # ffmpeg-1.0.10 has inline assembly error when using clang 150 | if [[ $1 =~ x86.* ]] || [[ "${VERSION}" == 1.0.10 ]]; then 151 | TA_OPTIONS="--disable-asm" 152 | fi 153 | 154 | PROGRAM="--disable-programs" 155 | if [[ ${VERSION} == 1.0.10 ]]; then 156 | PROGRAM="--disable-ffserver" 157 | fi 158 | 159 | make clean 160 | ./configure \ 161 | --prefix=${PREFIX} \ 162 | --cross-prefix=${CROSS_PREFIX} \ 163 | --sysroot=${NDK_SYSROOT} \ 164 | --arch=${NDK_ARCH} \ 165 | --cpu=${CPU} \ 166 | ${TC_OPTIONS} \ 167 | --enable-static \ 168 | --disable-shared \ 169 | ${TA_OPTIONS} \ 170 | --enable-cross-compile \ 171 | --target-os=android \ 172 | --enable-pic \ 173 | --disable-doc \ 174 | --disable-debug \ 175 | --disable-runtime-cpudetect \ 176 | --disable-pthreads \ 177 | --enable-hardcoded-tables \ 178 | ${PROGRAM} \ 179 | --enable-version3 \ 180 | --disable-postproc \ 181 | --disable-programs \ 182 | --disable-ffmpeg \ 183 | --disable-ffplay \ 184 | --disable-ffprobe \ 185 | --disable-network \ 186 | --disable-iconv \ 187 | --enable-decoder=mjpeg \ 188 | --enable-parser=mjpeg \ 189 | --enable-filter=format \ 190 | --enable-filter=hflip \ 191 | --enable-filter=scale \ 192 | --enable-filter=nullsink \ 193 | --enable-filter=vflip \ 194 | ${MODULES} \ 195 | --enable-gpl \ 196 | --extra-cflags="${INCLUDES} ${CFLAGS}" \ 197 | --extra-ldflags="${LIBS} ${LDFLAGS}" \ 198 | --extra-cxxflags="$CXXFLAGS" \ 199 | --extra-libs="-lgcc" \ 200 | --pkg-config=${FFMPEG_PKG_CONFIG} || exit 1 201 | 202 | # --extra-libs="-lgcc -lstdc++" \ 203 | # -lstdc++ requires by openh264 204 | 205 | make -j${HOST_NUM_CORES} install || exit 1 206 | echo -e "** BUILD COMPLETED: ${LIB_FFMPEG}-v${VERSION} for ${1} **\n" 207 | popd || exit 208 | -------------------------------------------------------------------------------- /_lame_build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . _settings.sh "$@" 4 | 5 | pushd lame || exit 6 | LAME_VER="$(grep 'PACKAGE_VERSION=' < ./configure | sed 's/^.*\([1-9]\.[0-9]*\).*$/\1/')" 7 | echo -e "\n\n** BUILD STARTED: lame-v${LAME_VER} for ${1} **" 8 | 9 | make clean 10 | 11 | # prefix path must be absolute for lame 12 | ./configure \ 13 | --prefix=${PREFIX} \ 14 | --host="${HOST}" \ 15 | --with-pic \ 16 | --enable-static \ 17 | --enable-nasm \ 18 | --disable-analyzer-hooks \ 19 | --disable-frontend \ 20 | --disable-shared || exit 1 21 | 22 | make -j${HOST_NUM_CORES} install || exit 1 23 | echo -e "** BUILD COMPLETED: lame-v${LAME_VER} for ${1} **\n" 24 | popd || exit 25 | -------------------------------------------------------------------------------- /_settings.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright 2016 Eng Chong Meng 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | # Uncomment the line below to see all script echo to terminal 18 | # set -x 19 | 20 | # When use --sdk-path option for libvpx v1.8.0; must use android-ndk-r17c or lower 21 | # May use android-ndk-r18b" - libvpx v1.10.0 and libvpx v1.8.2 are working with r18b without error 22 | # lame needs android-ndk-r17c 23 | export ANDROID_NDK=/opt/android/android-ndk-r17c 24 | if [[ -z $ANDROID_NDK ]] || [[ ! -d $ANDROID_NDK ]] ; then 25 | echo "You need to set ANDROID_NDK environment variable, exiting" 26 | echo "Use: export ANDROID_NDK=/your/path/to/android-ndk-rxx" 27 | echo "e.g.: export ANDROID_NDK=/opt/android/android-ndk-r17c" 28 | exit 1 29 | fi 30 | 31 | set -u 32 | 33 | # Never mix two api level to build static library for use on the same apk. 34 | # Set to API:21 for aTalk 64-bit architecture support 35 | # Does not build 64-bit arch if ANDROID_API is less than 21 i.e. the minimum supported API level for 64-bit. 36 | ANDROID_API=21 37 | 38 | # set STANDALONE_TOOLCHAINS to 0: SDK toolchains OR 1: standalone toolchains 39 | STANDALONE_TOOLCHAINS=1; 40 | 41 | # Built with command i.e. ./build-ffmpeg4android.sh or following with parameter [ABIS(x)] 42 | # Create custom ABIS or uncomment to build all supported abi for ffmpeg. 43 | # Do not change naming convention of the ABIS; see: 44 | # https://developer.android.com/ndk/guides/abis.html#Native code in app packages 45 | # ABIS=("armeabi" "armeabi-v7a" "arm64-v8a" "x86" "x86_64" "mips" "mips64") 46 | 47 | # Android recommended architecture support; others are deprecated 48 | ABIS=("armeabi-v7a" "arm64-v8a" "x86" "x86_64") 49 | 50 | BASEDIR=`pwd` 51 | TOOLCHAIN_PREFIX=${BASEDIR}/toolchain-android 52 | 53 | #=========================================== 54 | # Do not proceed further on first call without the required 2 parameters 55 | [[ $# -lt 2 ]] && return 56 | 57 | NDK=${ANDROID_NDK} 58 | HOST_NUM_CORES=$(nproc) 59 | 60 | # https://gcc.gnu.org/onlinedocs/gcc-4.9.1/gcc/Optimize-Options.html 61 | # Note: vpx with ABIs x86 and x86_64 build has error with option -fstack-protector-all 62 | 63 | # Note: final libraries built is 20~33% bigger in size when below additional options are specified 64 | # CFLAGS_="-DANDROID -fpic -fpie -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -fno-strict-overflow -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2" 65 | # -DBIONIC_IOCTL_NO_SIGNEDNESS_OVERLOAD: see https://github.com/tanersener/mobile-ffmpeg/issues/48 66 | CFLAGS_="-DANDROID -fpic -fpie -DBIONIC_IOCTL_NO_SIGNEDNESS_OVERLOAD" 67 | 68 | # Enable report-all for earlier detection of errors instead at later stage 69 | # /home/cmeng/workspace/ndk/vpx-android/armeabi-v7a-android-toolchain/bin/arm-linux-androideabi-ld: -Wl,-z,defs -Wl,--unresolved-symbols=report-all: unknown option 70 | # Not compatible with libvpx v.1.8.2 71 | # LDFLAGS_="-Wl,-z,defs -Wl,--unresolved-symbols=report-all" 72 | LDFLAGS_="" 73 | 74 | # Do not modify any of the NDK_ARCH, CPU and -march unless you are very sure. 75 | # The settings are used by -linux-android-gcc and submodule configure 76 | # https://en.wikipedia.org/wiki/List_of_ARM_microarchitectures 77 | # ${NDK}/toolchains/llvm/prebuilt/...../include llvm/ARMTargetParser.def etc 78 | # NDK-ARCH - should be one from $ANDROID_NDK/platforms/android-$API/arch-* [arm / arm64 / mips / mips64 / x86 / x86_64]" 79 | # https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html 80 | 81 | case $1 in 82 | # Deprecated in r16. Will be removed in r17 83 | armeabi) 84 | CPU='armv5' 85 | HOST='arm-linux' 86 | NDK_ARCH="arm" 87 | NDK_ABIARCH='arm-linux-androideabi' 88 | CFLAGS="${CFLAGS_} -march=${CPU} -mthumb -finline-limit=64" 89 | ASFLAGS="" 90 | ;; 91 | # https://gcc.gnu.org/onlinedocs/gcc-4.9.4/gcc/ARM-Options.html#ARM-Options 92 | armeabi-v7a) 93 | CPU='armv7-a' 94 | HOST='arm-linux' 95 | NDK_ARCH='arm' 96 | NDK_ABIARCH='arm-linux-androideabi' 97 | # clang70: warning: -Wl,--fix-cortex-a8: 'linker' input unused [-Wunused-command-line-argument] 98 | # CFLAGS="${CFLAGS_} -Wl,--fix-cortex-a8 -march=${CPU} -mfloat-abi=softfp -mfpu=neon -mtune=cortex-a8 -mthumb -D__thumb__" 99 | CFLAGS="${CFLAGS_} -Os -march=${CPU} -mfloat-abi=softfp -mfpu=neon -mtune=cortex-a8 -mthumb -D__thumb__" 100 | LDFLAGS="${LDFLAGS_} -march=${CPU}" # -Wl,--fix-cortex-a8" not valid option 101 | ASFLAGS="" 102 | 103 | # 1. -march=${CPU} flag targets the armv7 architecture. 104 | # 2. -mfloat-abi=softfp enables hardware-FPU instructions while ensuring that the system passes 105 | # floating-point parameters in core registers, which is critical for ABI compatibility 106 | # 3. -mfpu=neon setting forces the use of VFPv3-D32, per the ARM specifications 107 | # 4. -mthumb forces the generation of 16-bit Thumb-2 instructions (Thumb-1 for armeabi). 108 | # If omitted, the toolchain will emit 32-bit ARM instructions. 109 | # 5. -Wl,--fix-cortex-a8 is required as a workaround for a CPU bug in some Cortex-A8 implementation 110 | # (x264 flags as warning) Standalone toolchains does not accept this option. SDK toolchains (gcc/cg++) is ok. 111 | # /home/cmeng/workspace/ndk/ffmpeg-android/toolchain-android/bin/arm-linux-androideabi-ld: -Wl,--fix-cortex-a8: unknown option 112 | # LDFLAGS="-Wl,--fix-cortex-a8" 113 | 114 | # arm v7vfpv3 115 | # CFLAGS="${CFLAGS_} -march=${CPU} -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb" 116 | 117 | # arm v7 + neon (neon also include vfpv3-32) 118 | # CFLAGS="${CFLAGS_} -march=${CPU} -mfloat-abi=softfp -mfpu=neon -mtune=cortex-a8 -mthumb -D__thumb__" 119 | ;; 120 | arm64-v8a) 121 | # Valid cpu = armv8-a cortex-a35, cortex-a53, cortec-a57 etc. but -march=armv8-a is required 122 | # -march valid only for ‘armv8-a’, ‘armv8.1-a’, ‘armv8.2-a’, ‘armv8.3-a’ or ‘armv8.4-a’ 123 | # or native (only armv8-a is valid for lame build). 124 | CPU='cortex-a57' 125 | HOST='aarch64-linux' 126 | NDK_ARCH='arm64' 127 | NDK_ABIARCH='aarch64-linux-android' 128 | CFLAGS="${CFLAGS_} -O3 -march=armv8-a" 129 | # Supported emulations: aarch64linux aarch64elf aarch64elf32 aarch64elf32b aarch64elfb armelf armelfb 130 | # aarch64linuxb aarch64linux32 aarch64linux32b armelfb_linux_eabi armelf_linux_eabi 131 | #-march=armv8-a or arch64linux: all are not valid for libvpx v1.8.2/v1.10.0 build with standalone toolchains 132 | LDFLAGS="${LDFLAGS_}" 133 | ASFLAGS="" 134 | ;; 135 | x86) 136 | CPU='i686' 137 | HOST='i686-linux' 138 | NDK_ARCH='x86' 139 | NDK_ABIARCH='i686-linux-android' 140 | CFLAGS="${CFLAGS_} -O3 -march=${CPU} -mtune=intel -msse3 -mfpmath=sse -m32 -fPIC" 141 | LDFLAGS="-m32" 142 | ASFLAGS="-D__ANDROID__" 143 | ;; 144 | x86_64) 145 | CPU='x86-64' 146 | HOST='x86_64-linux' 147 | NDK_ARCH='x86_64' 148 | NDK_ABIARCH='x86_64-linux-android' 149 | CFLAGS="${CFLAGS_} -O3 -march=${CPU} -mtune=intel -msse4.2 -mpopcnt -m64 -fPIC" 150 | LDFLAGS="" 151 | ASFLAGS="-D__ANDROID__" 152 | ;; 153 | 154 | # MIPS is deprecated in NDK r16 and will be removed in r17. 155 | # https://gcc.gnu.org/onlinedocs/gcc/MIPS-Options.html#MIPS-Options 156 | # https://en.wikipedia.org/wiki/List_of_MIPS_architecture_processors 157 | mips) 158 | # unknown cpu - optimization disable 159 | CPU='p5600' 160 | HOST='mips-linux' 161 | NDK_ARCH='mips' 162 | NDK_ABIARCH="mipsel-linux-android" 163 | CFLAGS="${CFLAGS_} -EL -march=p5600 -mhard-float" 164 | ASFLAGS="" 165 | ;; 166 | mips64) 167 | # -march=mips64r6 works for clangs but complain by ffmpeg (use -march=${CPU}), reverse effect when -march=i6400 - so omit it in CFLAG works for both 168 | CPU='i6400' 169 | HOST='mips64-linux' 170 | NDK_ARCH='mips64' 171 | NDK_ABIARCH='mips64el-linux-android' 172 | CFLAGS="${CFLAGS_} -EL -mfp64 -mhard-float" 173 | ASFLAGS="" 174 | ;; 175 | esac 176 | 177 | # Create standalone toolchains for the specified architecture - use .py instead of the old .sh 178 | # However for ndk--r19b => Instead use: 179 | # $ ${NDK}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang++ src.cpp 180 | if [[ ${STANDALONE_TOOLCHAINS} == 1 ]]; then 181 | TOOLCHAIN_PREFIX=${BASEDIR}/toolchain-android 182 | NDK_SYSROOT=${TOOLCHAIN_PREFIX}/sysroot 183 | CC_=clang 184 | CXX_=clang++ 185 | 186 | if [[ ! -e ${TOOLCHAIN_PREFIX}/${NDK_ABIARCH} ]]; then 187 | rm -rf ${TOOLCHAIN_PREFIX} 188 | 189 | # Create standalone toolchains for the specified architecture - use .py instead of the old .sh 190 | # However for ndk--r19b => Instead use: 191 | # $ ${NDK}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang++ src.cpp 192 | # cmeng: must ensure AS JNI uses the same STL library or "system" if specified 193 | [[ -d ${TOOLCHAIN_PREFIX} ]] || python ${NDK}/build/tools/make_standalone_toolchain.py \ 194 | --arch ${NDK_ARCH} \ 195 | --api ${ANDROID_API} \ 196 | --stl libc++ \ 197 | --install-dir=${TOOLCHAIN_PREFIX} 198 | fi 199 | else 200 | TOOLCHAIN_PREFIX=${ANDROID_NDK}/toolchains/${NDK_ABIARCH}-49/prebuilt/linux-x86_64 201 | NDK_SYSROOT=${ANDROID_NDK}/platforms/android-${ANDROID_API}/arch-${NDK_ARCH} 202 | CC_=gcc 203 | CXX_=g++ 204 | fi 205 | 206 | # Define the install directory of the libs and include files etc 207 | # lame needs absolute path 208 | # PREFIX=../jni/$2/android/$1 209 | PREFIX=${BASEDIR}/jni/$2/android/$1 210 | 211 | # Add the standalone toolchain to the search path. 212 | export PATH=${TOOLCHAIN_PREFIX}/bin:$PATH 213 | export CROSS_PREFIX=${TOOLCHAIN_PREFIX}/bin/${NDK_ABIARCH}- 214 | export CFLAGS="${CFLAGS}" 215 | export CPPFLAGS="${CFLAGS}" 216 | export CXXFLAGS="${CFLAGS} -std=c++11" 217 | export ASFLAGS="${ASFLAGS}" 218 | export LDFLAGS="${LDFLAGS} -L${NDK_SYSROOT}/usr/lib" 219 | 220 | export AR="${CROSS_PREFIX}ar" 221 | export AS="${CROSS_PREFIX}${CC_}" 222 | export CC="${CROSS_PREFIX}${CC_}" 223 | export CXX="${CROSS_PREFIX}${CXX_}" 224 | export LD="${CROSS_PREFIX}ld" 225 | export STRIP="${CROSS_PREFIX}strip" 226 | export RANLIB="${CROSS_PREFIX}ranlib" 227 | export OBJDUMP="${CROSS_PREFIX}objdump" 228 | export CPP="${CROSS_PREFIX}cpp" 229 | export GCONV="${CROSS_PREFIX}gconv" 230 | export NM="${CROSS_PREFIX}nm" 231 | export SIZE="${CROSS_PREFIX}size" 232 | export PKG_CONFIG="${CROSS_PREFIX}pkg-config" 233 | export PKG_CONFIG_LIBDIR=${PREFIX}/lib/pkgconfig 234 | export PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig 235 | 236 | echo "**********************************************" 237 | echo "### Use NDK=${NDK}" 238 | echo "### Use ANDROID_API=${ANDROID_API}" 239 | echo "### Install directory: PREFIX=${PREFIX}" 240 | echo "**********************************************" 241 | 242 | # Undefined reference in x264 when linked with ffmpeg for arm64-v8a 243 | # https://stackoverflow.com/questions/5555632/can-gcc-not-complain-about-undefined-references 244 | # 245 | #It is possible to avoid reporting undefined references - using --unresolved-symbols linker option. 246 | # 247 | #g++ mm.cpp -Wl,--unresolved-symbols=ignore-in-object-files 248 | #From man ld 249 | # 250 | #--unresolved-symbols=method 251 | #Determine how to handle unresolved symbols. There are four possible values for method: 252 | # 253 | # ignore-all 254 | # Do not report any unresolved symbols. 255 | # 256 | # report-all 257 | # Report all unresolved symbols. This is the default. 258 | # 259 | # ignore-in-object-files 260 | # Report unresolved symbols that are contained in shared 261 | # libraries, but ignore them if they come from regular object 262 | # files. 263 | # 264 | # ignore-in-shared-libs 265 | # Report unresolved symbols that come from regular object 266 | # files, but ignore them if they come from shared libraries. This 267 | # can be useful when creating a dynamic binary and it is known 268 | # that all the shared libraries that it should be referencing 269 | # are included on the linker's command line. 270 | #The behaviour for shared libraries on their own can also be controlled by the --[no-]allow-shlib-undefined option. 271 | # 272 | #Normally the linker will generate an error message for each reported unresolved symbol but the option --warn-unresolved-symbols can change this to a warning. -------------------------------------------------------------------------------- /_vpx_build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright 2016 Eng Chong Meng 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | ### The following scripts are based on vpx v1.6.1, v1.7.0 and v1.8.x configure file options ### 18 | # aTalk v2.6.1 uses libvpx-1.10.0 19 | # aTalk v1.8.1 and below uses libvpx-master i.e. 1.6.1+ (10/13/2017) 20 | # aTalk v1.8.2 uses libvpx-1.8.0 21 | # aTalk v2.3.2 uses libvpx-1.8.2 22 | # aTalk v2.6.1 uses libvpx-1.10.0 23 | 24 | ## Both problems #1 & #2 below have been fixed by patches from: https://android.googlesource.com/platform/external/libvpx/+/ca30a60d2d6fbab4ac07c63bfbf7bbbd1fe6a583 25 | ## However the compiled libjnvpx.so has problem when exec on x86_64 android platform: 26 | ## i.e. org.atalk.android A/libc: Fatal signal 31 (SIGSYS), code 1 in tid 5833 (Loop thread: ne), pid 4781 (g.atalk.android) 27 | 28 | # 1. libvpx >v1.6.1 has the following errors when build with aTalk; v1.6.1 failed with --enable-pic 29 | # ./i686-linux-android/bin/ld: error: vpx/android/x86/lib/libvpx.a(deblock_sse2.asm.o): relocation R_386_GOTOFF against preemptible symbol vpx_rv cannot be used when making a shared object 30 | # ./i686-linux-android/4.9.x/../../../../i686-linux-android/bin/ld: error: vpx/android/x86/lib/libvpx.a(subpixel_mmx.asm.o): relocation R_386_GOTOFF against preemptible symbol # vp8_bilinear_filters_x86_8 cannot be used when making a shared object 31 | # ./i686-linux-android/bin/ld: error: vpx/android/x86/lib/libvpx.a(subpixel_mmx.asm.o): relocation R_386_GOTOFF against preemptible symbol vp8_bilinear_filters_x86_8 cannot be used when making a shared object 32 | # ./i686-linux-android/bin/ld: error: vpx/android/x86/lib/libvpx.a(subpixel_sse2.asm.o): relocation R_386_GOTOFF against preemptible symbol vp8_bilinear_filters_x86_8 cannot be used when making a shared object 33 | # ./i686-linux-android/bin/ld: error: vpx/android/x86/lib/libvpx.a(subpixel_sse2.asm.o): relocation R_386_GOTOFF against preemptible symbol vp8_bilinear_filters_x86_8 cannot be used when making a shared object 34 | 35 | # 2. However libvpx-1.6.1 x86_64 has the same error 36 | # ./x86_64-linux-android/bin/ld: error: vpx/android/x86_64/lib/libvpx.a(deblock_sse2.asm.o): requires dynamic R_X86_64_PC32 reloc against 'vpx_rv' which may overflow at runtime; recompile with -fPIC 37 | 38 | # set -x 39 | 40 | . _settings.sh "$@" 41 | 42 | # libvpx v1.10.0 43 | pushd libvpx || exit 44 | 45 | if [[ -f "./build/make/version.sh" ]]; then 46 | version=`"./build/make/version.sh" --bare .` 47 | fi 48 | echo -e "\n\n** BUILD STARTED: vpx-${version} for ${1} **" 49 | 50 | case $1 in 51 | # libvpx does not provide armv5 build option 52 | armeabi) 53 | TARGET="armv7-android-gcc --disable-neon --disable-neon-asm" 54 | ;; 55 | # need to add --disable-neon-asm for libvpx v1.8.2, otherwise: 56 | # clang70: error: linker command failed with exit code 1 (use -v to see invocation) 57 | # ./lib/crtbegin_dynamic.o:crtbegin.c:function _start_main: error: undefined reference to 'main' 58 | # make[1]: *** [vpx_dsp/arm/intrapred_neon_asm.asm.S.o] Error 1 59 | # make[1]: *** [vpx_dsp/arm/vpx_convolve_copy_neon_asm.asm.S.o] Error 1 60 | armeabi-v7a) 61 | TARGET="armv7-android-gcc --enable-neon --disable-neon-asm" 62 | ;; 63 | arm64-v8a) 64 | # valid arguments to '-mfpu=' are: crypto-neon-fp-armv8 fp-armv8 fpv4-sp-d16 neon neon-fp-armv8 neon-fp16 neon-vfpv4 vfp vfp3 vfpv3 65 | # vfpv3-d16 vfpv3-d16-fp16 vfpv3-fp16 vfpv3xd vfpv3xd-fp16 vfpv4 vfpv4-d16 66 | TARGET="arm64-android-gcc" 67 | ;; 68 | x86) 69 | TARGET="x86-android-gcc" 70 | ;; 71 | x86_64) 72 | TARGET="x86_64-android-gcc" 73 | ;; 74 | mips) 75 | TARGET="mips32-linux-gcc" 76 | ;; 77 | mips64) 78 | TARGET="mips64-linux-gcc" 79 | ;; 80 | esac 81 | 82 | # --sdk-path=${TOOLCHAIN_PREFIX} must use ${NDK} actual path else cannot find CC for arm64-android-gcc 83 | # ==> (Unable to invoke compiler: /arm-linux-androideabi-gcc) 84 | # https://bugs.chromium.org/p/webm/issues/detail?id=1476 85 | 86 | # fixed by patch 10.libvpx_configure.sh.patch 87 | # https://github.com/google/ExoPlayer/issues/3520 (VP9 builds failure with android-ndk-r16 #3520) 88 | # https://github.com/android-ndk/ndk/issues/190#issuecomment-375164450 (unknown type name __uint128_t on ndk-build #190) 89 | # Has configure error with Target=arm64-android-gcc which uses incorrect cc i.e. arm-linux-androideabi-gcc; 90 | 91 | # ./asm/sigcontext.h:39:3: error: unknown type name '__uint128_t' 92 | # GCC has builtin support for the types __int128, unsigned __int128, __int128_t and __uint128_t. Use them to define your own types: 93 | # typedef __int128 int128_t; 94 | # typedef unsigned __int128 uint128_t; 95 | # Standalone toolchains fixed the problem? 96 | 97 | # need --as=yasm which is required by x86 and x86-64; cannot use define in _settings.sh which uses clang 98 | # see https://github.com/webmproject/libvpx 99 | 100 | # --sdk-path=${NDK} when specified - configure will use SDK toolchains and gcc/g++ as the default compiler/linker 101 | # must specified --extra-cflags and --libc if use --sdk-path 102 | # --sdk-path=${NDK} \ 103 | # --extra-cflags="-isystem ${NDK}/sysroot/usr/include/${NDK_ABIARCH} -isystem ${NDK}/sysroot/usr/include" \ 104 | # must specified -libc from standalone toolchains, libvpx configure.sh cannot get the right arch to use 105 | 106 | # SDK toolchains has error with ndk-r18b; however ndk-R17c and ndk-r16b are ok (gcc/g++) 107 | # SDK toolchains ndk-r18b is working with libvpx v1.10.0 & v1.8.2 without the sdk option 108 | 109 | # Standalone toolchains built has problem with ABIS="armeabi-v7a" 110 | # /tmp/vpx-conf-31901-2664.o(.ARM.exidx.text.main+0x0): error: undefined reference to '__aeabi_unwind_cpp_pr0' 111 | # 112 | # Cannot define option add_ldflags "-Wl,--fix-cortex-a8" 113 | # Standalone: arm-linux-androideabi-ld: -Wl,--fix-cortex-a8: unknown option 114 | 115 | # Fixed by: https://android.googlesource.com/platform/external/libvpx/+/ca30a60d2d6fbab4ac07c63bfbf7bbbd1fe6a583 116 | # libvpx has the following errors for x86 and x86_64 when build in aTalk app; 117 | # ./i686-linux-android/bin/ld: error: vpx/android/x86/lib/libvpx.a(deblock_sse2.asm.o): relocation R_386_GOTOFF against preemptible symbol vpx_rv cannot be used when making a shared object 118 | # ./i686-linux-android/4.9.x/../../../../i686-linux-android/bin/ld: error: vpx/android/x86/lib/libvpx.a(subpixel_mmx.asm.o): relocation R_386_GOTOFF against preemptible symbol # vp8_bilinear_filters_x86_8 cannot be used when making a shared object 119 | # ./i686-linux-android/bin/ld: error: vpx/android/x86/lib/libvpx.a(subpixel_mmx.asm.o): relocation R_386_GOTOFF against preemptible symbol vp8_bilinear_filters_x86_8 cannot be used when making a shared object 120 | # ./i686-linux-android/bin/ld: error: vpx/android/x86/lib/libvpx.a(subpixel_sse2.asm.o): relocation R_386_GOTOFF against preemptible symbol vp8_bilinear_filters_x86_8 cannot be used when making a shared object 121 | # ./i686-linux-android/bin/ld: error: vpx/android/x86/lib/libvpx.a(subpixel_sse2.asm.o): relocation R_386_GOTOFF against preemptible symbol vp8_bilinear_filters_x86_8 cannot be used when making a shared object 122 | # ./x86_64-linux-android/bin/ld: error: vpx/android/x86_64/lib/libvpx.a(deblock_sse2.asm.o): requires dynamic R_X86_64_PC32 reloc against 'vpx_rv' which may overflow at runtime; recompile with -fPIC 123 | 124 | # Need --disable-avx2 to fix x86_64 problem OR enable --enable-runtime-cpu-detect option 125 | # org.atalk.android A/libc: Fatal signal 4 (SIGILL), code 2 (ILL_ILLOPN), fault addr 0x77b2ac1757e6 in tid 20780 (Loop thread: ne), pid 20363 (g.atalk.android) 126 | # see https://bugs.chromium.org/p/webm/issues/detail?id=1623#c1 127 | # OR use option --enable-runtime-cpu-detect for x86/x86_64 ABIS platforms 128 | 129 | CPU_DETECT="--disable-runtime-cpu-detect" 130 | if [[ $1 =~ x86.* ]]; then 131 | CPU_DETECT="--enable-runtime-cpu-detect" 132 | fi 133 | 134 | # When use --sdk-path option for libvpx v1.8.0; must use android-ndk-r17c or lower 135 | # For libvpx v1.8.2+: in order to use standalone toolchanis, must not specified --sdk-path (option removed) 136 | # --sdk-path=${NDK} 137 | 138 | if [[ -f "config.log" ]]; then 139 | config_target="$(grep "Configuring for target" < "config.log" | sed "s/^.* '\(.*\)'$/\1/")" 140 | if [[ ${TARGET} != "${config_target}" ]]; then 141 | make clean 142 | fi 143 | else 144 | make clean 145 | fi 146 | 147 | # --extra-cflags="-isystem ${NDK_SYSROOT}/usr/include/${NDK_ABIARCH} -isystem ${NDK_SYSROOT}/usr/include" \ 148 | # --libc=${NDK_SYSROOT} \ 149 | 150 | ./configure \ 151 | --prefix=${PREFIX} \ 152 | --target=${TARGET} \ 153 | --as=yasm \ 154 | --enable-pic \ 155 | --disable-docs \ 156 | --enable-static \ 157 | --enable-libyuv \ 158 | --disable-examples \ 159 | --disable-tools \ 160 | --disable-debug \ 161 | --disable-unit-tests \ 162 | --enable-realtime-only \ 163 | --enable-vp8 --enable-vp9 \ 164 | --enable-vp9-postproc \ 165 | --enable-vp9-highbitdepth \ 166 | --disable-webm-io || exit 1 167 | 168 | make -j${HOST_NUM_CORES} install || exit 1 169 | echo -e "** BUILD COMPLETED: vpx-${version} for ${1} **\n" 170 | popd || true 171 | 172 | -------------------------------------------------------------------------------- /_x264_build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | . _settings.sh "$@" 3 | 4 | pushd x264 || exit 5 | X264_API="$(grep '#define X264_BUILD' < x264.h | sed 's/^.* \([1-9][0-9]*\).*$/\1/')" 6 | echo -e "\n\n** BUILD STARTED: x264-v${X264_API} for ${1} **" 7 | 8 | # --disable-asm disable 9 | # Must not include the option for arm64-v8a. 10 | # The option is used by configure, config.mak and Makefile files to define AS and to compile required *.S assembly files; 11 | # Otherwise will have undefined references e.g. x264_8_pixel_sad_16x16_neon if --disable-asm is specified 12 | # However must include the option for x86 and x86_64; 13 | # Otherwise have relocate text, requires dynamic R_X86_64_PC32 etc when use in aTalk 14 | 15 | # for ndk-r16b and above must have 16 | # --extra-cflags="-isystem ${NDK_SYSROOT}/usr/include/${NDK_ABIARCH} -isystem ${NDK_SYSROOT}/usr/include" 17 | 18 | # Must include --disable-asm for x86 and x64_86 ABIS; otherwise problem in aTalk libjnffmpeg.so build i.e. 19 | # x86: ./i686-linux-android/bin/ld: warning: shared library text segment is not shareable 20 | # x86_64: e.g libswresample, libswscale, libavcodec: requires dynamic R_X86_64_PC32 reloc against ... 21 | DISASM="" 22 | if [[ $1 =~ x86.* ]]; then 23 | DISASM="--disable-asm" 24 | fi 25 | 26 | # --bit-depth not valid for v152 27 | BITDEPTH="--bit-depth=all" 28 | if [[ X264_API -le 152 ]]; then 29 | BITDEPTH="" 30 | fi 31 | 32 | make clean 33 | 34 | ./configure \ 35 | --prefix=${PREFIX} \ 36 | --includedir=${PREFIX}/include/x264 \ 37 | --cross-prefix=${CROSS_PREFIX} \ 38 | --sysroot=${NDK_SYSROOT} \ 39 | --host=${HOST} \ 40 | --extra-cflags="-isystem ${NDK_SYSROOT}/usr/include/${NDK_ABIARCH} -isystem ${NDK_SYSROOT}/usr/include" \ 41 | ${DISASM} \ 42 | --enable-shared \ 43 | --enable-static \ 44 | --enable-pic \ 45 | --enable-strip \ 46 | --disable-thread \ 47 | --disable-opencl \ 48 | ${BITDEPTH} \ 49 | --disable-cli || exit 1 50 | 51 | make -j${HOST_NUM_CORES} install || exit 1 52 | 53 | pushd ${PREFIX}/lib || exit 54 | if [[ -f libx264.so.$X264_API ]]; then 55 | mv libx264.so.${X264_API} libx264_${X264_API}.so 56 | sed -i "s/libx264.so.${X264_API}/libx264_${X264_API}.so/g" libx264_${X264_API}.so 57 | rm libx264.so 58 | ln -f -s libx264_${X264_API}.so libx264.so 59 | fi 60 | 61 | echo -e "** BUILD COMPLETED: x264-v${X264_API} for ${1} **\n" 62 | popd || exit 63 | -------------------------------------------------------------------------------- /build-ffmpeg4android.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | . _settings.sh 3 | 4 | # defined modules to be included in ffmpeg built 5 | # if include ffmpeg, then ffmpeg is built without the codec submodule 6 | MODULES=("x264" "vpx" "lame") 7 | FFMPEG_SA=("ffmpeg") 8 | 9 | # Build only the specified module if given as second parameter 10 | if [[ $# -eq 2 ]]; then 11 | MODULES=("$2") 12 | fi 13 | 14 | # Auto fetch and unarchive both ffmpeg and x264 from online repository 15 | VERSION_FFMPEG=4.4 16 | VERSION_X264=163 17 | VERSION_VPX=v1.10.0 18 | 19 | ./init_update_libs.sh $VERSION_FFMPEG $VERSION_X264 $VERSION_VPX 20 | 21 | # Applying required patches 22 | . ffmpeg-android_patch.sh "${MODULES[@]}" 23 | 24 | for ((i=0; i < ${#ABIS[@]}; i++)) 25 | do 26 | if [[ $# -eq 0 ]] || [[ "$1" == "${ABIS[i]}" ]]; then 27 | # Do not build 64-bit ABI if ANDROID_API is less than 21 - minimum supported API level for 64 bit. 28 | [[ ${ANDROID_API} -lt 21 ]] && ( echo "${ABIS[i]}" | grep 64 > /dev/null ) && continue; 29 | rm -rf ${TOOLCHAIN_PREFIX} 30 | 31 | # $1 = architecture 32 | # $2 = required for proceed to start setup default compiler environment variables 33 | for m in "${MODULES[@]}" 34 | do 35 | case $m in 36 | x264) 37 | ./_x264_build.sh "${ABIS[i]}" $m || exit 1 38 | ;; 39 | vpx) 40 | ./_vpx_build.sh "${ABIS[i]}" $m || exit 1 41 | ;; 42 | png) 43 | ./_libpng_build.sh "${ABIS[i]}" $m || exit 1 44 | ;; 45 | lame) 46 | ./_lame_build.sh "${ABIS[i]}" $m || exit 1 47 | ;; 48 | amrwb) 49 | ./_amr_build.sh "${ABIS[i]}" $m || exit 1 50 | ;; 51 | esac 52 | done 53 | 54 | if [[ " ${MODULES[*]} " =~ " ffmpeg " ]]; then 55 | ./_ffmpeg_build.sh "${ABIS[i]}" 'ffmpeg' "${FFMPEG_SA[@]}" || exit 1 56 | else 57 | ./_ffmpeg_build.sh "${ABIS[i]}" 'ffmpeg' "${MODULES[@]}" || exit 1 58 | fi 59 | fi 60 | done 61 | 62 | echo -e "*** BUILD COMPLETED ***\n" 63 | 64 | -------------------------------------------------------------------------------- /ffmpeg-android_patch.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # set -x 3 | # Applying required patches for all the codec modules 4 | 5 | # =============================== 6 | # ffmpeg patches 7 | # =============================== 8 | if [[ -f "ffmpeg/ffbuild/version.sh" ]]; then 9 | ffmpeg_VER=$(ffmpeg/ffbuild/version.sh ./ffmpeg) 10 | else 11 | ffmpeg_VER=$(ffmpeg/version.sh ./ffmpeg) 12 | fi 13 | 14 | if [[ ! (${ffmpeg_VER} > 3.4.8) ]]; then 15 | echo -e "### Applying patches for ffmpeg-v${ffmpeg_VER} modules" 16 | 17 | if [[ ${ffmpeg_VER} == 1.0.10 ]]; then 18 | patch -p0 -N --dry-run --silent -f ./ffmpeg/configure < ./patches/ffmpeg-1.0.10/10.ffmpeg-configure.patch 1>/dev/null 19 | if [[ $? -eq 0 ]]; then 20 | patch -p0 -f ./ffmpeg/configure < ./patches/ffmpeg-1.0.10/10.ffmpeg-configure.patch 21 | fi 22 | 23 | patch -p0 -N --dry-run --silent -f ./ffmpeg/libavcodec/libx264.c < ./patches/ffmpeg-1.0.10/11.ffmpeg-libx264.c.patch 1>/dev/null 24 | if [[ $? -eq 0 ]]; then 25 | patch -p0 -f ./ffmpeg/libavcodec/libx264.c < ./patches/ffmpeg-1.0.10/11.ffmpeg-libx264.c.patch 26 | fi 27 | 28 | patch -p0 -N --dry-run --silent -f ./ffmpeg/libavutil/pixdesc.c < ./patches/ffmpeg-1.0.10/12.ffmpeg-pixdesc.c.patch 1>/dev/null 29 | if [[ $? -eq 0 ]]; then 30 | patch -p0 -f ./ffmpeg/libavutil/pixdesc.c < ./patches/ffmpeg-1.0.10/12.ffmpeg-pixdesc.c.patch 31 | fi 32 | 33 | patch -p0 -N --dry-run --silent -f ./ffmpeg/libavutil/pixdesc.h < ./patches/ffmpeg-1.0.10/13.ffmpeg-pixdesc.h.patch 1>/dev/null 34 | if [[ $? -eq 0 ]]; then 35 | patch -p0 -f ./ffmpeg/libavutil/pixdesc.h < ./patches/ffmpeg-1.0.10/13.ffmpeg-pixdesc.h.patch 36 | fi 37 | 38 | patch -p0 -N --dry-run --silent -f ./ffmpeg/libavcodec/svq3.c < ./patches/ffmpeg-1.0.10/14.ffmpeg-svq3.c.patch 1>/dev/null 39 | if [[ $? -eq 0 ]]; then 40 | patch -p0 -f ./ffmpeg/libavcodec/svq3.c < ./patches/ffmpeg-1.0.10/14.ffmpeg-svq3.c.patch 41 | fi 42 | else 43 | patch -p0 -N --dry-run --silent -f ./ffmpeg/libavcodec/aaccoder.c < ./patches/01.ffmpeg_aacoder.patch 1>/dev/null 44 | if [[ $? -eq 0 ]]; then 45 | patch -p0 -f ./ffmpeg/libavcodec/aaccoder.c < ./patches/01.ffmpeg_aacoder.patch 46 | fi 47 | 48 | patch -p0 -N --dry-run --silent -f ./ffmpeg/libavcodec/hevc_mvs.c < ./patches/02.ffmpeg_hevc_mvs.patch 1>/dev/null 49 | if [[ $? -eq 0 ]]; then 50 | patch -p0 -f ./ffmpeg/libavcodec/hevc_mvs.c < ./patches/02.ffmpeg_hevc_mvs.patch 51 | fi 52 | 53 | patch -p0 -N --dry-run --silent -f ./ffmpeg/libavcodec/opus_pvq.c < ./patches/03.ffmpeg_opus_pvq.patch 1>/dev/null 54 | if [[ $? -eq 0 ]]; then 55 | patch -p0 -f ./ffmpeg/libavcodec/opus_pvq.c < ./patches/03.ffmpeg_opus_pvq.patch 56 | fi 57 | 58 | patch -p0 -N --dry-run --silent -f ./ffmpeg/libaudevice/v4l2.c < ./patches/04.ffmpeg_v4l2.patch 1>/dev/null 59 | if [[ $? -eq 0 ]]; then 60 | patch -p0 -f ./ffmpeg/libaudevice/v4l2.c < ./patches/03.ffmpeg_v4l2.patch 61 | fi 62 | fi 63 | fi 64 | 65 | # =============================== 66 | # x264 patches - seems no require for the latest source x264-snapshot-20191217-2245.tar.bz2 or v161 67 | # =============================== 68 | if [[ " ${MODULES[@]} " =~ " x264 " ]]; then 69 | ./x264/version.sh > x264_version 70 | X264_REV="$(grep '#define X264_REV ' < ./x264_version | sed 's/^.* \([1-9][0-9]*\)$/\1/')" 71 | 72 | if [[ ! (${X264_REV} == 3049) ]]; then 73 | X264_API="$(grep '#define X264_BUILD' < x264/x264.h | sed 's/^.* \([1-9][0-9]*\)$/\1/')" 74 | echo -e "### Applying patches for x264-v${X264_API}.${X264_REV} modules" 75 | 76 | patch -p0 -N --dry-run --silent -f ./x264/configure < ./patches/21.x264_configure.patch 1>/dev/null 77 | if [[ $? -eq 0 ]]; then 78 | patch -p0 -f ./x264/configure < ./patches/21.x264_configure.patch 79 | fi 80 | fi 81 | fi 82 | 83 | # =============================== 84 | # libvpx patches for version 1.8.0, 1.7.0 and 1.6.1+ 85 | # None is applicable and are skipped for the libvpx version 1.10.0 86 | # =============================== 87 | LIB_VPX="libvpx" 88 | if [[ -f "${LIB_VPX}/build/make/version.sh" ]]; then 89 | version=`"${LIB_VPX}/build/make/version.sh" --bare "${LIB_VPX}"` 90 | else 91 | version='v1.10.0' 92 | fi 93 | 94 | if [[ (${version} < v1.10.0 ) ]]; then 95 | 96 | echo -e "### Applying patches for libvpx-${version} modules" 97 | 98 | patch -p0 -N --dry-run --silent -f ./${LIB_VPX}/build/make/configure.sh < ./patches/10.libvpx_configure.sh.patch 1>/dev/null 99 | if [[ $? -eq 0 ]]; then 100 | patch -p0 -f ./${LIB_VPX}/build/make/configure.sh < ./patches/10.libvpx_configure.sh.patch 101 | fi 102 | 103 | # v1.8.0 does not have filter_x86.c 104 | if [[ "${version}" == v1.7.0 ]] || [[ "${version}" == v1.6.1 ]]; then 105 | patch -p0 -N --dry-run --silent -f ./${LIB_VPX}/vp8/common/x86/filter_x86.c < ./patches/11.libvpx_filter_x86.c.patch 1>/dev/null 106 | if [[ $? -eq 0 ]]; then 107 | patch -p0 -f ./${LIB_VPX}/vp8/common/x86/filter_x86.c < ./patches/11.libvpx_filter_x86.c.patch 108 | fi 109 | 110 | patch -p0 -N --dry-run --silent -f ./${LIB_VPX}/vpx_dsp/deblock.c < ./patches/12.libvpx_deblock.c.patch 1>/dev/null 111 | if [[ $? -eq 0 ]]; then 112 | patch -p0 -f ./${LIB_VPX}/vpx_dsp/deblock.c < ./patches/12.libvpx_deblock.c.patch 113 | fi 114 | 115 | patch -p0 -N --dry-run --silent -f ./${LIB_VPX}/vpx_ports/mem.h < ./patches/13.libvpx_mem.h.patch 1>/dev/null 116 | if [[ $? -eq 0 ]]; then 117 | patch -p0 -f ./${LIB_VPX}/vpx_ports/mem.h < ./patches/13.libvpx_mem.h.patch 118 | fi 119 | fi 120 | fi 121 | 122 | # =============================== 123 | # Patches for libvpx version 1.10.0 124 | # v1.10.0 need below patch for vp9 encode to work properly; master copy has been fixed 125 | # =============================== 126 | 127 | if [[ "${version}" == v1.10.0 ]]; then 128 | echo -e "\n*** Applying patches for: ${LIB_VPX} (${version}) ***" 129 | patch -p0 -N --dry-run --silent -f ./${LIB_VPX}/vpx/vpx_encoder.h < ./patches/10.vpx_encoder_h.patch 1>/dev/null 130 | if [[ $? -eq 0 ]]; then 131 | patch -p0 -f ./${LIB_VPX}/vpx/vpx_encoder.h < ./patches/10.vpx_encoder_h.patch 132 | fi 133 | fi 134 | 135 | # =============================== 136 | # lame patches 137 | # =============================== 138 | if [[ " ${MODULES[@]} " =~ " lame " ]]; then 139 | LAME_VER="$(grep 'PACKAGE_VERSION=' < lame/configure | sed 's/^.*\([1-9]\.[0-9]*\).*$/\1/')" 140 | echo -e "### Applying patches for lame-v${LAME_VER} modules" 141 | 142 | patch -p0 -N --dry-run --silent -f ./lame/configure < ./patches/31.lame_configure.patch 1>/dev/null 143 | if [[ $? -eq 0 ]]; then 144 | patch -p0 -f ./lame/configure < ./patches/31.lame_configure.patch 145 | fi 146 | fi 147 | 148 | # =============================== 149 | # fontconfig patches 150 | # =============================== 151 | patch -p0 -N --dry-run --silent -f ./fontconfig/src/fcxml.c < ./patches/41.fontconfig_fcxml.patch 1>/dev/null 152 | if [[ $? -eq 0 ]]; then 153 | patch -p0 -f ./fontconfig/src/fcxml.c < ./patches/41.fontconfig_fcxml.patch 154 | fi 155 | -------------------------------------------------------------------------------- /ffmpeg-pkg-config: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # set -x 3 | pkg_name=${@: -1} 4 | 5 | SCRIPT=$(readlink -f "$0") 6 | BASEDIR=$(dirname "$SCRIPT") 7 | #export PKG_CONFIG_PATH=${BASEDIR}/toolchains-android/lib/pkgconfig 8 | export PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig 9 | case $1 in 10 | --exists) 11 | pkg-config --exists $pkg_name 12 | ;; 13 | --cflags) 14 | echo $(pkg-config --cflags $pkg_name) 15 | ;; 16 | --libs) 17 | echo $(pkg-config --libs $pkg_name) 18 | ;; 19 | *) 20 | echo "FFmpeg pkg-config to build FFmpeg for Android!" 21 | ;; 22 | esac 23 | -------------------------------------------------------------------------------- /init_update_libs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # set -x 3 | 4 | # aTalk v2.6.1 is compatible with the following module versions: 5 | # a. ffmpeg-v4.4 6 | # b. x264-v161.3049 #define X264_VERSION "r3049 55d517b" 7 | # c. Libvpx-v1.10.0 8 | 9 | if [[ $# -eq 3 ]]; then 10 | VERSION_FFMPEG=$1 11 | VERSION_X264=$2 12 | VERSION_VPX=$3 13 | else 14 | VERSION_FFMPEG=4.4 15 | VERSION_X264=163 16 | VERSION_VPX=v1.10.0 17 | fi 18 | 19 | VERSION_LAME=3.100 20 | VERSION_OPENCORE='0.1.5' 21 | 22 | LIB_FFMPEG=ffmpeg 23 | LIB_X264=x264 24 | LIB_VPX=libvpx 25 | LIB_LAME=lame 26 | LIB_OPENCORE=opencore-amr 27 | 28 | # ================================================================================ 29 | echo -e "\n========== init library for: $LIB_FFMPEG ($VERSION_FFMPEG) ==========" 30 | if [[ -d $LIB_FFMPEG ]]; then 31 | version_ffmpeg=$(cat ${LIB_FFMPEG}/RELEASE) 32 | if [[ $VERSION_FFMPEG == "$version_ffmpeg" ]]; then 33 | echo -e "\n========== Current ffmpeg source is: $LIB_FFMPEG ($version_ffmpeg) ==========" 34 | else 35 | rm -rf $LIB_FFMPEG 36 | fi 37 | fi 38 | 39 | if [[ ! -d $LIB_FFMPEG ]]; then 40 | echo -e "\n========== Fetching library source for: $LIB_FFMPEG ($VERSION_FFMPEG) ==========" 41 | wget -O- https://www.ffmpeg.org/releases/ffmpeg-${VERSION_FFMPEG}.tar.bz2 | tar xj --strip-components=1 --one-top-level=ffmpeg 42 | fi 43 | 44 | # ================================================================================ 45 | echo -e "\n========== init library for: $LIB_X264 ($VERSION_X264) ==========" 46 | if [[ -d $LIB_X264 ]]; then 47 | version_x264="$(grep '#define X264_BUILD' < ${LIB_X264}/x264.h | sed 's/^.* \([1-9][0-9]*\).*$/\1/')" 48 | if [[ $VERSION_X264 == "$version_x264" ]]; then 49 | echo -e "\n========== Current x264 source is: $LIB_X264 ($version_x264) ==========" 50 | else 51 | rm -rf $LIB_X264 52 | fi 53 | fi 54 | 55 | if [[ ! -d $LIB_X264 ]]; then 56 | echo -e "\n========== Fetching library source for: $LIB_X264 ($VERSION_X264) ==========" 57 | git clone https://code.videolan.org/videolan/x264.git --branch stable 58 | fi 59 | 60 | # ================================================================================ 61 | echo -e "\n========== init library for: $LIB_VPX ($VERSION_VPX) ==========" 62 | if [[ -d ${LIB_VPX} ]] && [[ -f "${LIB_VPX}/build/make/version.sh" ]]; then 63 | version_vpx=`"${LIB_VPX}/build/make/version.sh" --bare "${LIB_VPX}"` 64 | if [[ (${VERSION_VPX} == "${version_vpx}") ]]; then 65 | echo -e "\n========== Current libvpx source is: ${LIB_VPX} (${version_vpx}) ==========" 66 | else 67 | rm -rf $LIB_VPX 68 | fi 69 | else 70 | rm -rf $LIB_VPX 71 | fi 72 | 73 | if [[ ! -d ${LIB_VPX} ]]; then 74 | echo -e "\n========== Fetching library source for: ${LIB_VPX} (${VERSION_VPX}) ==========" 75 | wget -O- https://github.com/webmproject/libvpx/archive/refs/tags/${VERSION_VPX}.tar.gz | tar xz --strip-components=1 --one-top-level=${LIB_VPX} 76 | fi 77 | 78 | # ================================================================================ 79 | echo -e "\n========== init library for: $LIB_LAME ($VERSION_LAME) ==========" 80 | if [[ -d $LIB_LAME ]]; then 81 | version_lame="$(grep 'PACKAGE_VERSION=' < ${LIB_LAME}/configure | sed 's/^.*\([1-9]\.[0-9]*\).*$/\1/')" 82 | if [[ (${VERSION_LAME} == "${version_lame}") ]]; then 83 | echo -e "\n========== Current lame source is: ${LIB_LAME} (${version_lame}) ==========" 84 | else 85 | rm -rf $LIB_LAME 86 | fi 87 | fi 88 | 89 | if [[ ! -d $LIB_LAME ]]; then 90 | echo -e "\n========== Fetching library source for: ${LIB_LAME} (${VERSION_VPX}) ==========" 91 | wget -O- https://sourceforge.net/projects/lame/files/lame/${VERSION_LAME}/lame-${VERSION_LAME}.tar.gz | tar xz --strip-components=1 --one-top-level=${LIB_LAME} 92 | fi 93 | 94 | # ================================================================================ 95 | echo -e "\n========== init library for: $LIB_OPENCORE ($VERSION_OPENCORE) ==========" 96 | if [[ -d $LIB_OPENCORE ]]; then 97 | version_opencore="$(grep 'PACKAGE_VERSION=' < ${LIB_OPENCORE}/configure | sed 's/^.*\([0-9]\.[0-9]\.[0-9]*\).*$/\1/')" 98 | if [[ (${VERSION_OPENCORE} == "${version_opencore}") ]]; then 99 | echo -e "\n========== Current opencore source is: ${LIB_OPENCORE} (${version_opencore}) ==========" 100 | else 101 | rm -rf $LIB_LIB_OPENCORE 102 | fi 103 | fi 104 | 105 | if [[ ! -d $LIB_OPENCORE ]]; then 106 | echo -e "\n========== Fetching library source for: ${LIB_OPENCORE} (${VERSION_VPX}) ==========" 107 | wget -O- https://sourceforge.net/projects/opencore-amr/files/opencore-amr/opencore-amr-${VERSION_OPENCORE}.tar.gz | tar xz --strip-components=1 --one-top-level=${LIB_OPENCORE} 108 | fi 109 | 110 | # rm -rf libpng-* 111 | # wget -O- ftp://ftp-osl.osuosl.org/pub/libpng/src/libpng16/libpng-1.6.34.tar.xz | tar xz 112 | echo "========== Completed sub modules update ==========" 113 | 114 | 115 | -------------------------------------------------------------------------------- /patches/01.ffmpeg_aacoder.patch: -------------------------------------------------------------------------------- 1 | --- a/ffmpeg/libavcodec/aaccoder.c 2 | +++ b/ffmpeg/libavcodec/aaccoder.c 3 | @@ -58,12 +58,13 @@ 4 | 5 | /* Parameter of f(x) = a*(100/lambda), defines how much PNS is allowed to 6 | * replace low energy non zero bands */ 7 | #define NOISE_LAMBDA_REPLACE 1.948f 8 | 9 | #include "libavcodec/aaccoder_trellis.h" 10 | +#undef B0 11 | 12 | /** 13 | * structure used in optimal codebook search 14 | */ 15 | typedef struct BandCodingPath { 16 | int prev_idx; ///< pointer to the previous path point 17 | -------------------------------------------------------------------------------- /patches/02.ffmpeg_hevc_mvs.patch: -------------------------------------------------------------------------------- 1 | --- a/ffmpeg/libavcodec/hevc_mvs.c 2 | +++ b/ffmpeg/libavcodec/hevc_mvs.c 3 | @@ -20,12 +20,13 @@ 4 | * License along with FFmpeg; if not, write to the Free Software 5 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | */ 7 | 8 | #include "hevc.h" 9 | #include "hevcdec.h" 10 | +#undef B0 11 | 12 | static const uint8_t l0_l1_cand_idx[12][2] = { 13 | { 0, 1, }, 14 | { 1, 0, }, 15 | { 0, 2, }, 16 | { 2, 0, }, 17 | -------------------------------------------------------------------------------- /patches/03.ffmpeg_opus_pvq.patch: -------------------------------------------------------------------------------- 1 | --- a/ffmpeg/libavcodec/opus_pvq.c 2 | +++ b/ffmpeg/libavcodec/opus_pvq.c 3 | @@ -22,13 +22,14 @@ 4 | * License along with FFmpeg; if not, write to the Free Software 5 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | */ 7 | 8 | #include "opustab.h" 9 | #include "opus_pvq.h" 10 | - 11 | +#undef B0 12 | + 13 | #define CELT_PVQ_U(n, k) (ff_celt_pvq_u_row[FFMIN(n, k)][FFMAX(n, k)]) 14 | #define CELT_PVQ_V(n, k) (CELT_PVQ_U(n, k) + CELT_PVQ_U(n, (k) + 1)) 15 | 16 | static inline int16_t celt_cos(int16_t x) 17 | { 18 | x = (MUL16(x, x) + 4096) >> 13; 19 | -------------------------------------------------------------------------------- /patches/04.ffmpeg_v4l2.patch: -------------------------------------------------------------------------------- 1 | --- a/ffmpeg/libavdevice/v4l2.c 2019-02-10 04:56:02.000000000 2 | +++ b/ffmpeg/libavdevice/v4l2.c 2019-03-18 10:25:49.000000000 3 | @@ -129,13 +129,13 @@ 4 | SET_WRAPPERS(v4l2_); 5 | #else 6 | av_log(ctx, AV_LOG_ERROR, "libavdevice is not built with libv4l2 support.\n"); 7 | return AVERROR(EINVAL); 8 | #endif 9 | } else { 10 | - SET_WRAPPERS(); 11 | + /* SET_WRAPPERS(); */ 12 | } 13 | 14 | #define v4l2_open s->open_f 15 | #define v4l2_close s->close_f 16 | #define v4l2_dup s->dup_f 17 | #define v4l2_ioctl s->ioctl_f 18 | -------------------------------------------------------------------------------- /patches/10.libvpx_configure.sh.patch: -------------------------------------------------------------------------------- 1 | --- a/libvpx/build/make/configure.sh 2019-03-13 08:20:13.000000000 2 | +++ b/libvpx/build/build/make/configure.sh 2019-04-15 09:33:34.000000000 3 | @@ -1013,17 +1013,14 @@ 4 | win*) 5 | asm_conversion_cmd="$asm_conversion_cmd -noelf" 6 | AS="$CC -c" 7 | EXE_SFX=.exe 8 | enable_feature thumb 9 | ;; 10 | - *) 11 | - check_add_asflags --defsym ARCHITECTURE=${arch_int} 12 | - ;; 13 | - esac 14 | - 15 | + esac 16 | + 17 | if enabled thumb; then 18 | asm_conversion_cmd="$asm_conversion_cmd -thumb" 19 | check_add_cflags -mthumb 20 | check_add_asflags -mthumb -mimplicit-it=always 21 | fi 22 | ;; 23 | @@ -1087,13 +1084,12 @@ 24 | check_add_cflags --cpu=${tgt_isa##armv} 25 | check_add_asflags --cpu=${tgt_isa##armv} 26 | fi 27 | fi 28 | arch_int=${tgt_isa##armv} 29 | arch_int=${arch_int%%te} 30 | - check_add_asflags --pd "\"ARCHITECTURE SETA ${arch_int}\"" 31 | enabled debug && add_asflags -g 32 | add_cflags --gnu 33 | add_cflags --enum_is_int 34 | add_cflags --wchar32 35 | ;; 36 | esac 37 | @@ -1104,40 +1100,59 @@ 38 | disable_feature os_support 39 | ;; 40 | 41 | android*) 42 | if [ -n "${sdk_path}" ]; then 43 | SDK_PATH=${sdk_path} 44 | - COMPILER_LOCATION=`find "${SDK_PATH}" \ 45 | - -name "arm-linux-androideabi-gcc*" -print -quit` 46 | - TOOLCHAIN_PATH=${COMPILER_LOCATION%/*}/arm-linux-androideabi- 47 | + if [ ${tgt_isa} = "arm64" ] || [ ${tgt_isa} = "armv8" ]; then 48 | + COMPILER_LOCATION=`find "${SDK_PATH}" \ 49 | + -name "aarch64-linux-android-gcc*" -print -quit` 50 | + TOOLCHAIN_PATH=${COMPILER_LOCATION%/*}/aarch64-linux-android- 51 | + else 52 | + COMPILER_LOCATION=`find "${SDK_PATH}" \ 53 | + -name "arm-linux-androideabi-gcc*" -print -quit` 54 | + TOOLCHAIN_PATH=${COMPILER_LOCATION%/*}/arm-linux-androideabi- 55 | + fi 56 | + 57 | CC=${TOOLCHAIN_PATH}gcc 58 | CXX=${TOOLCHAIN_PATH}g++ 59 | AR=${TOOLCHAIN_PATH}ar 60 | LD=${TOOLCHAIN_PATH}gcc 61 | AS=${TOOLCHAIN_PATH}as 62 | STRIP=${TOOLCHAIN_PATH}strip 63 | NM=${TOOLCHAIN_PATH}nm 64 | 65 | if [ -z "${alt_libc}" ]; then 66 | - alt_libc=`find "${SDK_PATH}" -name arch-arm -print | \ 67 | - awk '{n = split($0,a,"/"); \ 68 | - split(a[n-1],b,"-"); \ 69 | - print $0 " " b[2]}' | \ 70 | - sort -g -k 2 | \ 71 | - awk '{ print $1 }' | tail -1` 72 | + if [ ${tgt_isa} = "armv7" ]; then 73 | + alt_libc=`find "${SDK_PATH}" -name arch-arm -print | \ 74 | + awk '{n = split($0,a,"/"); \ 75 | + split(a[n-1],b,"-"); \ 76 | + print $0 " " b[2]}' | \ 77 | + sort -g -k 2 | \ 78 | + awk '{ print $1 }' | tail -1` 79 | + else 80 | + alt_libc=`find "${SDK_PATH}" -name arch-${tgt_isa} -print | \ 81 | + awk '{n = split($0,a,"/"); \ 82 | + split(a[n-1],b,"-"); \ 83 | + print $0 " " b[2]}' | \ 84 | + sort -g -k 2 | \ 85 | + awk '{ print $1 }' | tail -1` 86 | + fi 87 | fi 88 | 89 | if [ -d "${alt_libc}" ]; then 90 | add_cflags "--sysroot=${alt_libc}" 91 | add_ldflags "--sysroot=${alt_libc}" 92 | fi 93 | 94 | - # linker flag that routes around a CPU bug in some 95 | - # Cortex-A8 implementations (NDK Dev Guide) 96 | - add_ldflags "-Wl,--fix-cortex-a8" 97 | + if [ ${tgt_isa} = "armv7" ] || [ ${tgt_isa} = "armv7s" ]; then 98 | + # linker flag that routes around a CPU bug in some 99 | + # Cortex-A8 implementations (NDK Dev Guide) 100 | + # only valid for armv7 and clang/clang++ does not recognize this option 101 | + add_ldflags "-Wl,--fix-cortex-a8" 102 | + fi 103 | 104 | enable_feature pic 105 | soft_enable realtime_only 106 | if [ ${tgt_isa} = "armv7" ]; then 107 | soft_enable runtime_cpu_detect 108 | fi 109 | -------------------------------------------------------------------------------- /patches/10.vpx_encoder_h.patch: -------------------------------------------------------------------------------- 1 | --- libvpx-1.10.0/vpx/vpx_encoder.h 2021-03-19 03:59:46.000000000 2 | +++ atalk-android/aTalk/jni/static_library_built/libvpx/libvpx/vpx/vpx_encoder.h 2021-07-03 09:46:07.000000000 3 | @@ -55,13 +55,13 @@ 4 | * If this file is altered in any way that changes the ABI, this value 5 | * must be bumped. Examples include, but are not limited to, changing 6 | * types, removing or reassigning enums, adding/removing/rearranging 7 | * fields to structures 8 | */ 9 | #define VPX_ENCODER_ABI_VERSION \ 10 | - (14 + VPX_CODEC_ABI_VERSION + \ 11 | + (15 + VPX_CODEC_ABI_VERSION + \ 12 | VPX_EXT_RATECTRL_ABI_VERSION) /**<\hideinitializer*/ 13 | 14 | /*! \brief Encoder capabilities bitfield 15 | * 16 | * Each encoder advertises the capabilities it supports as part of its 17 | * ::vpx_codec_iface_t interface structure. Capabilities are extra 18 | -------------------------------------------------------------------------------- /patches/11.libvpx_filter_x86.c.patch: -------------------------------------------------------------------------------- 1 | --- a/vp8/common/x86/filter_x86.c 2017-10-13 08:37:57.000000000 2 | +++ b/vp8/common/x86/filter_x86.c 2019-03-20 17:47:49.000000000 3 | @@ -14,16 +14,16 @@ 4 | { 128, 128, 128, 128, 0, 0, 0, 0 }, { 112, 112, 112, 112, 16, 16, 16, 16 }, 5 | { 96, 96, 96, 96, 32, 32, 32, 32 }, { 80, 80, 80, 80, 48, 48, 48, 48 }, 6 | { 64, 64, 64, 64, 64, 64, 64, 64 }, { 48, 48, 48, 48, 80, 80, 80, 80 }, 7 | { 32, 32, 32, 32, 96, 96, 96, 96 }, { 16, 16, 16, 16, 112, 112, 112, 112 } 8 | }; 9 | 10 | -DECLARE_ALIGNED(16, const short, vp8_bilinear_filters_x86_8[8][16]) = { 11 | +DECLARE_PROTECTED(DECLARE_ALIGNED(16, const short, vp8_bilinear_filters_x86_8[8][16])) = { 12 | { 128, 128, 128, 128, 128, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 0 }, 13 | { 112, 112, 112, 112, 112, 112, 112, 112, 16, 16, 16, 16, 16, 16, 16, 16 }, 14 | { 96, 96, 96, 96, 96, 96, 96, 96, 32, 32, 32, 32, 32, 32, 32, 32 }, 15 | { 80, 80, 80, 80, 80, 80, 80, 80, 48, 48, 48, 48, 48, 48, 48, 48 }, 16 | { 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 }, 17 | { 48, 48, 48, 48, 48, 48, 48, 48, 80, 80, 80, 80, 80, 80, 80, 80 }, 18 | { 32, 32, 32, 32, 32, 32, 32, 32, 96, 96, 96, 96, 96, 96, 96, 96 }, 19 | { 16, 16, 16, 16, 16, 16, 16, 16, 112, 112, 112, 112, 112, 112, 112, 112 } 20 | }; 21 | -------------------------------------------------------------------------------- /patches/12.libvpx_deblock.c.patch: -------------------------------------------------------------------------------- 1 | --- a/vpx_dsp/deblock.c 2017-10-13 08:37:57.000000000 2 | +++ b/vpx_dsp/deblock.c 2019-03-20 17:50:28.000000000 3 | @@ -7,15 +7,15 @@ 4 | * in the file PATENTS. All contributing project authors may 5 | * be found in the AUTHORS file in the root of the source tree. 6 | */ 7 | #include 8 | #include 9 | #include "./vpx_dsp_rtcd.h" 10 | -#include "vpx/vpx_integer.h" 11 | +#include "vpx_ports/mem.h" 12 | 13 | -const int16_t vpx_rv[] = { 14 | +DECLARE_PROTECTED(const int16_t vpx_rv[]) = { 15 | 8, 5, 2, 2, 8, 12, 4, 9, 8, 3, 0, 3, 9, 0, 0, 0, 8, 3, 14, 16 | 4, 10, 1, 11, 14, 1, 14, 9, 6, 12, 11, 8, 6, 10, 0, 0, 8, 9, 0, 17 | 3, 14, 8, 11, 13, 4, 2, 9, 0, 3, 9, 6, 1, 2, 3, 14, 13, 1, 8, 18 | 2, 9, 7, 3, 3, 1, 13, 13, 6, 6, 5, 2, 7, 11, 9, 11, 8, 7, 3, 19 | 2, 0, 13, 13, 14, 4, 12, 5, 12, 10, 8, 10, 13, 10, 4, 14, 4, 10, 0, 20 | 8, 11, 1, 13, 7, 7, 14, 6, 14, 13, 2, 13, 5, 4, 4, 0, 10, 0, 5, 21 | -------------------------------------------------------------------------------- /patches/13.libvpx_mem.h.patch: -------------------------------------------------------------------------------- 1 | --- a/vpx_ports/mem.h 2017-10-13 08:37:57.000000000 2 | +++ b/vpx_ports/mem.h 2019-03-20 17:54:48.000000000 3 | @@ -20,12 +20,18 @@ 4 | #define DECLARE_ALIGNED(n, typ, val) __declspec(align(n)) typ val 5 | #else 6 | #warning No alignment directives known for this compiler. 7 | #define DECLARE_ALIGNED(n, typ, val) typ val 8 | #endif 9 | 10 | +#if defined(__GNUC__) && __GNUC__ >= 4 && !defined(_WIN32) 11 | +#define DECLARE_PROTECTED(decl) decl __attribute__((visibility("protected"))) 12 | +#else 13 | +#define DECLARE_PROTECTED(decl) decl 14 | +#endif 15 | + 16 | #if HAVE_NEON && defined(_MSC_VER) 17 | #define __builtin_prefetch(x) 18 | #endif 19 | 20 | /* Shift down with rounding */ 21 | #define ROUND_POWER_OF_TWO(value, n) (((value) + (1 << ((n)-1))) >> (n)) 22 | -------------------------------------------------------------------------------- /patches/21.x264_configure.patch: -------------------------------------------------------------------------------- 1 | --- a/x264/configure 2018-08-07 04:45:05.000000000 2 | +++ b/x264/configure 2019-03-27 12:04:46.000000000 3 | @@ -78,13 +78,13 @@ 4 | # several non gcc compilers issue an incredibly large number of warnings on high warning levels, 5 | # suppress them by reducing the warning level rather than having to use #pragmas 6 | for arg in $*; do 7 | [[ "$arg" = -falign-loops* ]] && arg= 8 | [ "$arg" = -fno-tree-vectorize ] && arg= 9 | [ "$arg" = -Wshadow ] && arg= 10 | - [ "$arg" = -Wno-maybe-uninitialized ] && arg= 11 | + [ "$arg" = -Wuninitialized ] && arg= 12 | [[ "$arg" = -mpreferred-stack-boundary* ]] && arg= 13 | [[ "$arg" = -l* ]] && arg= 14 | [[ "$arg" = -L* ]] && arg= 15 | if [ $compiler_style = MS ]; then 16 | [ "$arg" = -ffast-math ] && arg="-fp:fast" 17 | [ "$arg" = -Wall ] && arg= 18 | @@ -112,13 +112,13 @@ 19 | [ "$arg" = -Wl,--large-address-aware ] && arg=-largeaddressaware 20 | [ "$arg" = -s ] && arg= 21 | [ "$arg" = -Wl,-Bsymbolic ] && arg= 22 | [ "$arg" = -fno-tree-vectorize ] && arg= 23 | [ "$arg" = -Werror ] && arg= 24 | [ "$arg" = -Wshadow ] && arg= 25 | - [ "$arg" = -Wmaybe-uninitialized ] && arg= 26 | + [ "$arg" = -Wuninitialized ] && arg= 27 | [[ "$arg" = -Qdiag-error* ]] && arg= 28 | 29 | arg=${arg/pthreadGC/pthreadVC} 30 | [ "$arg" = avifil32.lib ] && arg=vfw32.lib 31 | [ "$arg" = gpac_static.lib ] && arg=libgpac_static.lib 32 | [ "$arg" = x264.lib ] && arg=libx264.lib 33 | @@ -586,17 +586,17 @@ 34 | if [[ "$cc_base" = icc || "$cc_base" = icc[\ .]* ]]; then 35 | AR="xiar" 36 | compiler=ICC 37 | fi 38 | fi 39 | 40 | -if [ $compiler = GNU ]; then 41 | - if cc_check '' -Werror=unknown-warning-option ; then 42 | - CHECK_CFLAGS="$CHECK_CFLAGS -Werror=unknown-warning-option" 43 | - fi 44 | -fi 45 | +#if [ $compiler = GNU ]; then 46 | +# if cc_check '' -Werror=unknown-warning-option ; then 47 | +# CHECK_CFLAGS="$CHECK_CFLAGS -Werror=unknown-warning-option" 48 | +# fi 49 | +#fi 50 | 51 | libm="" 52 | case $host_os in 53 | beos*) 54 | SYS="BEOS" 55 | define HAVE_MALLOC_H 56 | @@ -1254,14 +1254,14 @@ 57 | fi 58 | 59 | if cc_check '' -Wshadow ; then 60 | CFLAGS="-Wshadow $CFLAGS" 61 | fi 62 | 63 | -if cc_check '' -Wmaybe-uninitialized ; then 64 | - CFLAGS="-Wno-maybe-uninitialized $CFLAGS" 65 | +if cc_check '' -Wuninitialized ; then 66 | + CFLAGS="-Wuninitialized $CFLAGS" 67 | fi 68 | 69 | if [ $compiler = ICC -o $compiler = ICL ] ; then 70 | if cc_check 'extras/intel_dispatcher.h' '' 'x264_intel_dispatcher_override();' ; then 71 | define HAVE_INTEL_DISPATCHER 72 | fi 73 | -------------------------------------------------------------------------------- /patches/31.lame_configure.patch: -------------------------------------------------------------------------------- 1 | --- a/lame/configure 2017-08-15 23:17:12.000000000 2 | +++ b/lame/configure 2018-03-21 11:22:33.000000000 3 | @@ -3633,13 +3633,13 @@ 4 | See \`config.log' for more details" "$LINENO" 5; } 5 | 6 | # Provide some information about the compiler. 7 | $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 8 | set X $ac_compile 9 | ac_compiler=$2 10 | -for ac_option in --version -v -V -qversion; do 11 | +for ac_option in --version -v; do 12 | { { ac_try="$ac_compiler $ac_option >&5" 13 | case "(($ac_try" in 14 | *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; 15 | *) ac_try_echo=$ac_try;; 16 | esac 17 | eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" 18 | @@ -12747,13 +12747,13 @@ 19 | See \`config.log' for more details" "$LINENO" 5; } 20 | 21 | # Provide some information about the compiler. 22 | $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 23 | set X $ac_compile 24 | ac_compiler=$2 25 | -for ac_option in --version -v -V -qversion; do 26 | +for ac_option in --version -v; do 27 | { { ac_try="$ac_compiler $ac_option >&5" 28 | case "(($ac_try" in 29 | *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; 30 | *) ac_try_echo=$ac_try;; 31 | esac 32 | eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" 33 | -------------------------------------------------------------------------------- /patches/41.fontconfig_fcxml.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/fcxml.c b/src/fcxml.c 2 | index 91d166f..cf5345e 100644 3 | --- a/src/fcxml.c 4 | +++ b/src/fcxml.c 5 | @@ -1314,6 +1314,7 @@ FcParseInt (FcConfigParse *parse) 6 | static double 7 | FcStrtod (char *s, char **end) 8 | { 9 | +#ifndef __ANDROID__ 10 | struct lconv *locale_data; 11 | char *dot; 12 | double v; 13 | @@ -1360,6 +1361,9 @@ FcStrtod (char *s, char **end) 14 | else 15 | v = strtod (s, end); 16 | return v; 17 | +#else 18 | + return strtod (s, end); 19 | +#endif 20 | } 21 | 22 | static void 23 | -------------------------------------------------------------------------------- /patches/Readme.txt: -------------------------------------------------------------------------------- 1 | Site: https://android.googlesource.com/platform/external/libvpx/+/ca30a60d2d6fbab4ac07c63bfbf7bbbd1fe6a583 2 | 3 | ================= 4 | libvpx: Cherry-pick 0d88e15 from upstream 5 | 6 | Description from upstream: 7 | Add visibility="protected" attribute for global variables referenced 8 | in asm files. 9 | 10 | During aosp builds with binutils-2.27, we're seeing linker error 11 | messages of this form: 12 | libvpx.a(subpixel_mmx.o): relocation R_386_GOTOFF against preemptible 13 | symbol vp8_bilinear_filters_x86_8 cannot be used when making a shared 14 | object 15 | 16 | subpixel_mmx.o is assembled from "vp8/common/x86/subpixel_mmx.asm". 17 | Other messages refer to symbol references from deblock_sse2.o and 18 | subpixel_sse2.o, also assembled from asm files. 19 | 20 | This change marks such symbols as having "protected" visibility. This 21 | satisfies the linker as the symbols are not preemptible from outside 22 | the shared library now, which I think is the original intent anyway. 23 | 24 | Bug: 37955747 25 | Test: lunch aosp_x86-userdebug && m 26 | 27 | Change-Id: Ica100155c1b65dd44740941d4d3c25abf7b08487 28 | ==================== 29 | 30 | libvpx/vp8/common/x86/filter_x86.c[diff] 31 | libvpx/vpx_dsp/deblock.c[diff] 32 | libvpx/vpx_ports/mem.h[diff] 33 | 3 files changed 34 | -------------------------------------------------------------------------------- /patches/ffmpeg-1.0.10/10.ffmpeg-configure.patch: -------------------------------------------------------------------------------- 1 | --- a/ffmpeg-x264/ffmpeg/configure 2014-07-21 01:25:31.000000000 2 | +++ b/ffmpeg-x264/ffmpeg-1.0.10/configure 2019-03-22 11:42:34.000000000 3 | @@ -2074,17 +2074,17 @@ 4 | LIBSUF=".a" 5 | FULLNAME='$(NAME)$(BUILDSUF)' 6 | LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)' 7 | SLIBPREF="lib" 8 | SLIBSUF=".so" 9 | SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)' 10 | -SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)' 11 | -SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)' 12 | +SLIBNAME_WITH_VERSION='$(SLIBNAME)' 13 | +SLIBNAME_WITH_MAJOR='$(SLIBNAME)' 14 | LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"' 15 | SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)' 16 | -SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR) $(SLIBNAME)' 17 | +#SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR) $(SLIBNAME)' 18 | 19 | asflags_filter=echo 20 | cflags_filter=echo 21 | ldflags_filter=echo 22 | 23 | AS_C='-c' 24 | @@ -2998,12 +2998,20 @@ 25 | 26 | enable $subarch 27 | enabled spic && enable pic 28 | 29 | # OS specific 30 | case $target_os in 31 | + android) 32 | + disable symver 33 | + enable section_data_rel_ro 34 | + add_cflags -fPIE 35 | + SLIB_INSTALL_NAME='$(SLIBNAME)' 36 | + SLIB_INSTALL_LINKS= 37 | + SHFLAGS='-shared -Wl,-soname,$(SLIBNAME)' 38 | + ;; 39 | haiku) 40 | prefix_default="/boot/common" 41 | network_extralibs="-lnetwork" 42 | host_libs= 43 | ;; 44 | sunos) 45 | -------------------------------------------------------------------------------- /patches/ffmpeg-1.0.10/11.ffmpeg-libx264.c.patch: -------------------------------------------------------------------------------- 1 | --- a/ffmpeg-x264/ffmpeg/libavcodec/libx264.c 2015-08-01 00:35:36.000000000 2 | +++ b/ffmpeg-x264/ffmpeg/libavcodec/libx264.c 2019-03-23 12:10:41.000000000 3 | @@ -155,13 +155,17 @@ 4 | x264_nal_t *nal; 5 | int nnal, i, ret; 6 | x264_picture_t pic_out; 7 | 8 | x264_picture_init( &x4->pic ); 9 | x4->pic.img.i_csp = x4->params.i_csp; 10 | +#if X264_BUILD >= 153 11 | + if (x4->params.i_bitdepth > 8) 12 | +#else 13 | if (x264_bit_depth > 8) 14 | +#endif 15 | x4->pic.img.i_csp |= X264_CSP_HIGH_DEPTH; 16 | x4->pic.img.i_plane = avfmt2_num_planes(ctx->pix_fmt); 17 | 18 | if (frame) { 19 | for (i = 0; i < x4->pic.img.i_plane; i++) { 20 | x4->pic.img.plane[i] = frame->data[i]; 21 | @@ -307,12 +311,15 @@ 22 | x4->params.i_level_idc = avctx->level; 23 | 24 | x4->params.pf_log = X264_log; 25 | x4->params.p_log_private = avctx; 26 | x4->params.i_log_level = X264_LOG_DEBUG; 27 | x4->params.i_csp = convert_pix_fmt(avctx->pix_fmt); 28 | +#if X264_BUILD >= 153 29 | + x4->params.i_bitdepth = av_pix_fmt_desc_get(avctx->pix_fmt)->comp[0].depth; 30 | +#endif 31 | 32 | OPT_STR("weightp", x4->wpredp); 33 | 34 | if (avctx->bit_rate) { 35 | x4->params.rc.i_bitrate = avctx->bit_rate / 1000; 36 | x4->params.rc.i_rc_method = X264_RC_ABR; 37 | @@ -577,28 +584,38 @@ 38 | static const enum PixelFormat pix_fmts_10bit[] = { 39 | PIX_FMT_YUV420P10, 40 | PIX_FMT_YUV422P10, 41 | PIX_FMT_YUV444P10, 42 | PIX_FMT_NONE 43 | }; 44 | +static const enum PixelFormat pix_fmts_all[] = { 45 | + PIX_FMT_YUV420P, 46 | + PIX_FMT_YUV422P, 47 | + PIX_FMT_YUV444P, 48 | + PIX_FMT_NONE 49 | +}; 50 | static const enum PixelFormat pix_fmts_8bit_rgb[] = { 51 | #ifdef X264_CSP_BGR 52 | PIX_FMT_BGR24, 53 | PIX_FMT_RGB24, 54 | #endif 55 | PIX_FMT_NONE 56 | }; 57 | 58 | static av_cold void X264_init_static(AVCodec *codec) 59 | { 60 | +#if X264_BUILD < 153 61 | if (x264_bit_depth == 8) 62 | codec->pix_fmts = pix_fmts_8bit; 63 | else if (x264_bit_depth == 9) 64 | codec->pix_fmts = pix_fmts_9bit; 65 | else if (x264_bit_depth == 10) 66 | codec->pix_fmts = pix_fmts_10bit; 67 | +#else 68 | + codec->pix_fmts = pix_fmts_all; 69 | +#endif 70 | } 71 | 72 | #define OFFSET(x) offsetof(X264Context, x) 73 | #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM 74 | static const AVOption options[] = { 75 | { "preset", "Set the encoding preset (cf. x264 --fullhelp)", OFFSET(preset), AV_OPT_TYPE_STRING, { .str = "medium" }, 0, 0, VE}, 76 | -------------------------------------------------------------------------------- /patches/ffmpeg-1.0.10/12.ffmpeg-pixdesc.c.patch: -------------------------------------------------------------------------------- 1 | --- a/ffmpeg-x264/ffmpeg/libavutil/pixdesc.c 2015-08-01 00:35:36.000000000 2 | +++ b/ffmpeg-x264/ffmpeg/libavutil/pixdesc.c 2019-03-23 13:16:50.000000000 3 | @@ -1482,6 +1482,13 @@ 4 | snprintf(buf, buf_size, "%-11s %7d %10d", pixdesc->name, 5 | pixdesc->nb_components, av_get_bits_per_pixel(pixdesc)); 6 | } 7 | 8 | return buf; 9 | } 10 | + 11 | +const AVPixFmtDescriptor *av_pix_fmt_desc_get(enum PixelFormat pix_fmt) 12 | +{ 13 | + if (pix_fmt < 0 || pix_fmt >= PIX_FMT_NB) 14 | + return NULL; 15 | + return &av_pix_fmt_descriptors[pix_fmt]; 16 | +} 17 | -------------------------------------------------------------------------------- /patches/ffmpeg-1.0.10/13.ffmpeg-pixdesc.h.patch: -------------------------------------------------------------------------------- 1 | --- a/ffmpeg-x264/ffmpeg/libavutil/pixdesc.h 2015-08-01 00:35:36.000000000 2 | +++ b/ffmpeg-x264/ffmpeg/libavutil/pixdesc.h 2019-03-23 13:00:57.000000000 3 | @@ -38,12 +38,16 @@ 4 | * Number of elements before the component of the first pixel plus 1. 5 | * Elements are bits for bitstream formats, bytes otherwise. 6 | */ 7 | uint16_t offset_plus1 :3; 8 | uint16_t shift :3; ///< number of least significant bits that must be shifted away to get the value 9 | uint16_t depth_minus1 :4; ///< number of bits in the component minus 1 10 | + /** 11 | + * Number of bits in the component. 12 | + */ 13 | + int depth; 14 | }AVComponentDescriptor; 15 | 16 | /** 17 | * Descriptor that unambiguously describes how the bits of a pixel are 18 | * stored in the up to 4 data planes of an image. It also stores the 19 | * subsampling factors and number of components. 20 | @@ -100,12 +104,18 @@ 21 | #define PIX_FMT_PSEUDOPAL 64 22 | 23 | /** 24 | * The array of all the pixel format descriptors. 25 | */ 26 | extern const AVPixFmtDescriptor av_pix_fmt_descriptors[]; 27 | + 28 | +/** 29 | + * @return a pixel format descriptor for provided pixel format or NULL if 30 | + * this pixel format is unknown. 31 | + */ 32 | +const AVPixFmtDescriptor *av_pix_fmt_desc_get(enum PixelFormat pix_fmt); 33 | 34 | /** 35 | * Read a line from an image, and write the values of the 36 | * pixel format component c to dst. 37 | * 38 | * @param data the array containing the pointers to the planes of the image 39 | -------------------------------------------------------------------------------- /patches/ffmpeg-1.0.10/14.ffmpeg-svq3.c.patch: -------------------------------------------------------------------------------- 1 | --- a/ffmpeg-x264/ffmpeg/libavcodec/svq3.c 2015-08-01 00:35:36.000000000 2 | +++ b/ffmpeg-x264/ffmpeg/libavcodec/svq3.c 2017-10-31 11:25:47.000000000 3 | @@ -408,24 +408,21 @@ 4 | 5 | /* update mv_cache */ 6 | if (mode != PREDICT_MODE) { 7 | int32_t mv = pack16to32(mx,my); 8 | 9 | if (part_height == 8 && i < 8) { 10 | - *(int32_t *) h->mv_cache[dir][scan8[k] + 1*8] = mv; 11 | + AV_WN32A(h->mv_cache[dir][scan8[k] + 1 * 8], mv); 12 | 13 | - if (part_width == 8 && j < 8) { 14 | - *(int32_t *) h->mv_cache[dir][scan8[k] + 1 + 1*8] = mv; 15 | - } 16 | + if (part_width == 8 && j < 8) 17 | + AV_WN32A(h->mv_cache[dir][scan8[k] + 1 + 1 * 8], mv); 18 | } 19 | - if (part_width == 8 && j < 8) { 20 | - *(int32_t *) h->mv_cache[dir][scan8[k] + 1] = mv; 21 | - } 22 | - if (part_width == 4 || part_height == 4) { 23 | - *(int32_t *) h->mv_cache[dir][scan8[k]] = mv; 24 | - } 25 | + if (part_width == 8 && j < 8) 26 | + AV_WN32A(h->mv_cache[dir][scan8[k] + 1], mv); 27 | + if (part_width == 4 || part_height == 4) 28 | + AV_WN32A(h->mv_cache[dir][scan8[k]], mv); 29 | } 30 | 31 | /* write back motion vectors */ 32 | fill_rectangle(s->current_picture.f.motion_val[dir][b_xy], 33 | part_width >> 2, part_height >> 2, h->b_stride, 34 | pack16to32(mx, my), 4); 35 | @@ -486,32 +483,35 @@ 36 | N??11111 37 | */ 38 | 39 | for (m = 0; m < 2; m++) { 40 | if (s->mb_x > 0 && h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - 1]+6] != -1) { 41 | for (i = 0; i < 4; i++) { 42 | - *(uint32_t *) h->mv_cache[m][scan8[0] - 1 + i*8] = *(uint32_t *) s->current_picture.f.motion_val[m][b_xy - 1 + i*h->b_stride]; 43 | + AV_COPY32(h->mv_cache[m][scan8[0] - 1 + i*8], 44 | + *(uint32_t *) s->current_picture.f.motion_val[m][b_xy - 1 + i*h->b_stride]); 45 | } 46 | } else { 47 | for (i = 0; i < 4; i++) { 48 | - *(uint32_t *) h->mv_cache[m][scan8[0] - 1 + i*8] = 0; 49 | + AV_ZERO32(h->mv_cache[m][scan8[0] - 1 + i*8]); 50 | } 51 | } 52 | if (s->mb_y > 0) { 53 | memcpy(h->mv_cache[m][scan8[0] - 1*8], s->current_picture.f.motion_val[m][b_xy - h->b_stride], 4*2*sizeof(int16_t)); 54 | memset(&h->ref_cache[m][scan8[0] - 1*8], (h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride]] == -1) ? PART_NOT_AVAILABLE : 1, 4); 55 | 56 | if (s->mb_x < (s->mb_width - 1)) { 57 | - *(uint32_t *) h->mv_cache[m][scan8[0] + 4 - 1*8] = *(uint32_t *) s->current_picture.f.motion_val[m][b_xy - h->b_stride + 4]; 58 | + AV_COPY32(h->mv_cache[m][scan8[0] + 4 - 1*8], 59 | + s->current_picture.f.motion_val[m][b_xy - h->b_stride + 4]); 60 | h->ref_cache[m][scan8[0] + 4 - 1*8] = 61 | (h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride + 1]+6] == -1 || 62 | h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride ] ] == -1) ? PART_NOT_AVAILABLE : 1; 63 | }else 64 | h->ref_cache[m][scan8[0] + 4 - 1*8] = PART_NOT_AVAILABLE; 65 | if (s->mb_x > 0) { 66 | - *(uint32_t *) h->mv_cache[m][scan8[0] - 1 - 1*8] = *(uint32_t *) s->current_picture.f.motion_val[m][b_xy - h->b_stride - 1]; 67 | + AV_COPY32(h->mv_cache[m][scan8[0] - 1 - 1*8], 68 | + s->current_picture.f.motion_val[m][b_xy - h->b_stride - 1]); 69 | h->ref_cache[m][scan8[0] - 1 - 1*8] = (h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride - 1]+3] == -1) ? PART_NOT_AVAILABLE : 1; 70 | }else 71 | h->ref_cache[m][scan8[0] - 1 - 1*8] = PART_NOT_AVAILABLE; 72 | }else 73 | memset(&h->ref_cache[m][scan8[0] - 1*8 - 1], PART_NOT_AVAILABLE, 8); 74 | 75 | -------------------------------------------------------------------------------- /patches/ffmpeg-1.0.10/ffmpeg-1.0.10_patch.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x 3 | # Applying required patches 4 | 5 | # =============================== 6 | # ffmpeg patches 7 | # =============================== 8 | 9 | patch -p0 -N --dry-run --silent -f ./ffmpeg/configure < ./patches/10.ffmpeg-configure.patch 1>/dev/null 10 | if [[ $? -eq 0 ]]; then 11 | patch -p0 -f ./ffmpeg/configure < ./patches/10.ffmpeg-configure.patch 12 | fi 13 | 14 | patch -p0 -N --dry-run --silent -f ./ffmpeg/libavcodec/libx264.c < ./patches/11.ffmpeg-libx264.c.patch 1>/dev/null 15 | if [[ $? -eq 0 ]]; then 16 | patch -p0 -f ./ffmpeg/libavcodec/libx264.c < ./patches/11.ffmpeg-libx264.c.patch 17 | fi 18 | 19 | patch -p0 -N --dry-run --silent -f ./ffmpeg/libavutil/pixdesc.c < ./patches/12.ffmpeg-pixdesc.c.patch 1>/dev/null 20 | if [[ $? -eq 0 ]]; then 21 | patch -p0 -f ./ffmpeg/libavutil/pixdesc.c < ./patches/12.ffmpeg-pixdesc.c.patch 22 | fi 23 | 24 | patch -p0 -N --dry-run --silent -f ./ffmpeg/libavutil/pixdesc.h < ./patches/13.ffmpeg-pixdesc.h.patch 1>/dev/null 25 | if [[ $? -eq 0 ]]; then 26 | patch -p0 -f ./ffmpeg/libavutil/pixdesc.h < ./patches/13.ffmpeg-pixdesc.h.patch 27 | fi 28 | 29 | patch -p0 -N --dry-run --silent -f ./ffmpeg/libavcodec/svq3.c < ./patches/14.ffmpeg-svq3.c.patch 1>/dev/null 30 | if [[ $? -eq 0 ]]; then 31 | patch -p0 -f ./ffmpeg/libavcodec/svq3.c < ./patches/14.ffmpeg-svq3.c.patch 32 | fi 33 | -------------------------------------------------------------------------------- /source/ffmpeg-4.4.tar.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cmeng-git/ffmpeg-android/a0175e5f8ea6ac25256671144639f48c2fb42c22/source/ffmpeg-4.4.tar.bz2 -------------------------------------------------------------------------------- /source/lame-3.100.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cmeng-git/ffmpeg-android/a0175e5f8ea6ac25256671144639f48c2fb42c22/source/lame-3.100.tar.gz -------------------------------------------------------------------------------- /source/v1.10.0.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cmeng-git/ffmpeg-android/a0175e5f8ea6ac25256671144639f48c2fb42c22/source/v1.10.0.tar.gz -------------------------------------------------------------------------------- /source/x264-stable.tar.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cmeng-git/ffmpeg-android/a0175e5f8ea6ac25256671144639f48c2fb42c22/source/x264-stable.tar.bz2 --------------------------------------------------------------------------------