SCsub 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. #!/usr/bin/env python
  2. Import('env')
  3. Import('env_modules')
  4. # Thirdparty sources
  5. libvpx_dir = "#thirdparty/libvpx/"
  6. libvpx_sources = [
  7. "vp8/vp8_dx_iface.c",
  8. "vp8/common/generic/systemdependent.c",
  9. "vp8/common/alloccommon.c",
  10. "vp8/common/blockd.c",
  11. "vp8/common/copy_c.c",
  12. "vp8/common/debugmodes.c",
  13. "vp8/common/dequantize.c",
  14. "vp8/common/entropy.c",
  15. "vp8/common/entropymode.c",
  16. "vp8/common/entropymv.c",
  17. "vp8/common/extend.c",
  18. "vp8/common/filter.c",
  19. "vp8/common/findnearmv.c",
  20. "vp8/common/idct_blk.c",
  21. "vp8/common/idctllm.c",
  22. "vp8/common/loopfilter_filters.c",
  23. "vp8/common/mbpitch.c",
  24. "vp8/common/modecont.c",
  25. "vp8/common/quant_common.c",
  26. "vp8/common/reconinter.c",
  27. "vp8/common/reconintra.c",
  28. "vp8/common/reconintra4x4.c",
  29. "vp8/common/rtcd.c",
  30. "vp8/common/setupintrarecon.c",
  31. "vp8/common/swapyv12buffer.c",
  32. "vp8/common/treecoder.c",
  33. "vp8/common/vp8_loopfilter.c",
  34. "vp8/decoder/dboolhuff.c",
  35. "vp8/decoder/decodeframe.c",
  36. "vp8/decoder/decodemv.c",
  37. "vp8/decoder/detokenize.c",
  38. "vp8/decoder/onyxd_if.c",
  39. "vp9/vp9_dx_iface.c",
  40. "vp9/common/vp9_alloccommon.c",
  41. "vp9/common/vp9_blockd.c",
  42. "vp9/common/vp9_common_data.c",
  43. "vp9/common/vp9_debugmodes.c",
  44. "vp9/common/vp9_entropy.c",
  45. "vp9/common/vp9_entropymode.c",
  46. "vp9/common/vp9_entropymv.c",
  47. "vp9/common/vp9_filter.c",
  48. "vp9/common/vp9_frame_buffers.c",
  49. "vp9/common/vp9_idct.c",
  50. "vp9/common/vp9_loopfilter.c",
  51. "vp9/common/vp9_mvref_common.c",
  52. "vp9/common/vp9_pred_common.c",
  53. "vp9/common/vp9_quant_common.c",
  54. "vp9/common/vp9_reconinter.c",
  55. "vp9/common/vp9_reconintra.c",
  56. "vp9/common/vp9_rtcd.c",
  57. "vp9/common/vp9_scale.c",
  58. "vp9/common/vp9_scan.c",
  59. "vp9/common/vp9_seg_common.c",
  60. "vp9/common/vp9_thread_common.c",
  61. "vp9/common/vp9_tile_common.c",
  62. "vp9/decoder/vp9_decodeframe.c",
  63. "vp9/decoder/vp9_decodemv.c",
  64. "vp9/decoder/vp9_decoder.c",
  65. "vp9/decoder/vp9_detokenize.c",
  66. "vp9/decoder/vp9_dsubexp.c",
  67. "vp9/decoder/vp9_dthread.c",
  68. "vpx/src/vpx_codec.c",
  69. "vpx/src/vpx_decoder.c",
  70. "vpx/src/vpx_image.c",
  71. "vpx/src/vpx_psnr.c",
  72. "vpx_dsp/bitreader.c",
  73. "vpx_dsp/bitreader_buffer.c",
  74. "vpx_dsp/intrapred.c",
  75. "vpx_dsp/inv_txfm.c",
  76. "vpx_dsp/loopfilter.c",
  77. "vpx_dsp/prob.c",
  78. "vpx_dsp/vpx_convolve.c",
  79. "vpx_dsp/vpx_dsp_rtcd.c",
  80. "vpx_mem/vpx_mem.c",
  81. "vpx_scale/vpx_scale_rtcd.c",
  82. "vpx_scale/generic/yv12config.c",
  83. "vpx_scale/generic/yv12extend.c",
  84. "vpx_util/vpx_thread.c"
  85. ]
  86. libvpx_sources_mt = [
  87. "vp8/decoder/threading.c",
  88. ]
  89. libvpx_sources_intrin_x86 = [
  90. "vp8/common/x86/filter_x86.c",
  91. "vp8/common/x86/loopfilter_x86.c",
  92. "vp8/common/x86/vp8_asm_stubs.c",
  93. "vpx_dsp/x86/vpx_asm_stubs.c"
  94. ]
  95. libvpx_sources_intrin_x86_mmx = [
  96. "vp8/common/x86/idct_blk_mmx.c",
  97. ]
  98. libvpx_sources_intrin_x86_sse2 = [
  99. "vp8/common/x86/idct_blk_sse2.c",
  100. "vp9/common/x86/vp9_idct_intrin_sse2.c",
  101. "vpx_dsp/x86/inv_txfm_sse2.c",
  102. "vpx_dsp/x86/loopfilter_sse2.c",
  103. ]
  104. libvpx_sources_intrin_x86_ssse3 = [
  105. "vpx_dsp/x86/vpx_subpixel_8t_intrin_ssse3.c"
  106. ]
  107. libvpx_sources_intrin_x86_avx2 = [
  108. "vpx_dsp/x86/loopfilter_avx2.c",
  109. "vpx_dsp/x86/vpx_subpixel_8t_intrin_avx2.c"
  110. ]
  111. libvpx_sources_x86asm = [
  112. "vp8/common/x86/copy_sse2.asm",
  113. "vp8/common/x86/copy_sse3.asm",
  114. "vp8/common/x86/dequantize_mmx.asm",
  115. "vp8/common/x86/idctllm_mmx.asm",
  116. "vp8/common/x86/idctllm_sse2.asm",
  117. "vp8/common/x86/iwalsh_mmx.asm",
  118. "vp8/common/x86/iwalsh_sse2.asm",
  119. "vp8/common/x86/loopfilter_sse2.asm",
  120. "vp8/common/x86/recon_mmx.asm",
  121. "vp8/common/x86/recon_sse2.asm",
  122. "vp8/common/x86/subpixel_mmx.asm",
  123. "vp8/common/x86/subpixel_sse2.asm",
  124. "vp8/common/x86/subpixel_ssse3.asm",
  125. "vp8/common/x86/vp8_loopfilter_mmx.asm",
  126. "vpx_dsp/x86/intrapred_sse2.asm",
  127. "vpx_dsp/x86/intrapred_ssse3.asm",
  128. "vpx_dsp/x86/inv_wht_sse2.asm",
  129. "vpx_dsp/x86/vpx_convolve_copy_sse2.asm",
  130. "vpx_dsp/x86/vpx_subpixel_8t_sse2.asm",
  131. "vpx_dsp/x86/vpx_subpixel_8t_ssse3.asm",
  132. "vpx_dsp/x86/vpx_subpixel_bilinear_sse2.asm",
  133. "vpx_dsp/x86/vpx_subpixel_bilinear_ssse3.asm",
  134. "vpx_ports/emms.asm"
  135. ]
  136. libvpx_sources_x86_64asm = [
  137. "vp8/common/x86/loopfilter_block_sse2_x86_64.asm",
  138. "vpx_dsp/x86/inv_txfm_ssse3_x86_64.asm"
  139. ]
  140. libvpx_sources_arm = [
  141. "vpx_ports/arm_cpudetect.c",
  142. "vp8/common/arm/loopfilter_arm.c",
  143. ]
  144. libvpx_sources_arm_neon = [
  145. "vp8/common/arm/neon/bilinearpredict_neon.c",
  146. "vp8/common/arm/neon/copymem_neon.c",
  147. "vp8/common/arm/neon/dc_only_idct_add_neon.c",
  148. "vp8/common/arm/neon/dequant_idct_neon.c",
  149. "vp8/common/arm/neon/dequantizeb_neon.c",
  150. "vp8/common/arm/neon/idct_blk_neon.c",
  151. "vp8/common/arm/neon/idct_dequant_0_2x_neon.c",
  152. "vp8/common/arm/neon/idct_dequant_full_2x_neon.c",
  153. "vp8/common/arm/neon/iwalsh_neon.c",
  154. "vp8/common/arm/neon/loopfiltersimplehorizontaledge_neon.c",
  155. "vp8/common/arm/neon/loopfiltersimpleverticaledge_neon.c",
  156. "vp8/common/arm/neon/mbloopfilter_neon.c",
  157. "vp8/common/arm/neon/shortidct4x4llm_neon.c",
  158. "vp8/common/arm/neon/sixtappredict_neon.c",
  159. "vp8/common/arm/neon/vp8_loopfilter_neon.c",
  160. "vp9/common/arm/neon/vp9_iht4x4_add_neon.c",
  161. "vp9/common/arm/neon/vp9_iht8x8_add_neon.c",
  162. "vpx_dsp/arm/idct16x16_1_add_neon.c",
  163. "vpx_dsp/arm/idct16x16_add_neon.c",
  164. "vpx_dsp/arm/idct16x16_neon.c",
  165. "vpx_dsp/arm/idct32x32_1_add_neon.c",
  166. "vpx_dsp/arm/idct32x32_add_neon.c",
  167. "vpx_dsp/arm/idct4x4_1_add_neon.c",
  168. "vpx_dsp/arm/idct4x4_add_neon.c",
  169. "vpx_dsp/arm/idct8x8_1_add_neon.c",
  170. "vpx_dsp/arm/idct8x8_add_neon.c",
  171. "vpx_dsp/arm/intrapred_neon.c",
  172. "vpx_dsp/arm/loopfilter_16_neon.c",
  173. "vpx_dsp/arm/loopfilter_4_neon.c",
  174. "vpx_dsp/arm/loopfilter_8_neon.c",
  175. "vpx_dsp/arm/loopfilter_neon.c",
  176. "vpx_dsp/arm/vpx_convolve8_avg_neon.c",
  177. "vpx_dsp/arm/vpx_convolve8_neon.c",
  178. "vpx_dsp/arm/vpx_convolve_avg_neon.c",
  179. "vpx_dsp/arm/vpx_convolve_copy_neon.c",
  180. "vpx_dsp/arm/vpx_convolve_neon.c"
  181. ]
  182. libvpx_sources_arm_neon_gas = [
  183. "vpx_dsp/arm/gas/intrapred_neon_asm.s",
  184. "vpx_dsp/arm/gas/loopfilter_mb_neon.s",
  185. "vpx_dsp/arm/gas/save_reg_neon.s"
  186. ]
  187. libvpx_sources_arm_neon_armasm_ms = [
  188. "vpx_dsp/arm/armasm_ms/intrapred_neon_asm.asm",
  189. "vpx_dsp/arm/armasm_ms/loopfilter_mb_neon.asm",
  190. "vpx_dsp/arm/armasm_ms/save_reg_neon.asm"
  191. ]
  192. libvpx_sources_arm_neon_gas_apple = [
  193. "vpx_dsp/arm/gas_apple/intrapred_neon_asm.s",
  194. "vpx_dsp/arm/gas_apple/loopfilter_mb_neon.s",
  195. "vpx_dsp/arm/gas_apple/save_reg_neon.s"
  196. ]
  197. libvpx_sources = [libvpx_dir + file for file in libvpx_sources]
  198. libvpx_sources_mt = [libvpx_dir + file for file in libvpx_sources_mt]
  199. libvpx_sources_intrin_x86 = [libvpx_dir + file for file in libvpx_sources_intrin_x86]
  200. libvpx_sources_intrin_x86_mmx = [libvpx_dir + file for file in libvpx_sources_intrin_x86_mmx]
  201. libvpx_sources_intrin_x86_sse2 = [libvpx_dir + file for file in libvpx_sources_intrin_x86_sse2]
  202. libvpx_sources_intrin_x86_ssse3 = [libvpx_dir + file for file in libvpx_sources_intrin_x86_ssse3]
  203. libvpx_sources_intrin_x86_avx2 = [libvpx_dir + file for file in libvpx_sources_intrin_x86_avx2]
  204. libvpx_sources_x86asm = [libvpx_dir + file for file in libvpx_sources_x86asm]
  205. libvpx_sources_x86_64asm = [libvpx_dir + file for file in libvpx_sources_x86_64asm]
  206. libvpx_sources_arm = [libvpx_dir + file for file in libvpx_sources_arm]
  207. libvpx_sources_arm_neon = [libvpx_dir + file for file in libvpx_sources_arm_neon]
  208. libvpx_sources_arm_neon_gas = [libvpx_dir + file for file in libvpx_sources_arm_neon_gas]
  209. libvpx_sources_arm_neon_armasm_ms = [libvpx_dir + file for file in libvpx_sources_arm_neon_armasm_ms]
  210. libvpx_sources_arm_neon_gas_apple = [libvpx_dir + file for file in libvpx_sources_arm_neon_gas_apple]
  211. env_libvpx = env_modules.Clone()
  212. env_libvpx.disable_warnings()
  213. env_libvpx.Append(CPPPATH=[libvpx_dir])
  214. webm_multithread = env["platform"] != 'javascript'
  215. cpu_bits = env["bits"]
  216. webm_cpu_x86 = False
  217. webm_cpu_arm = False
  218. if env["platform"] == 'uwp':
  219. if 'arm' in env["PROGSUFFIX"]:
  220. webm_cpu_arm = True
  221. else:
  222. webm_cpu_x86 = True
  223. else:
  224. import platform
  225. is_x11_or_server_arm = ((env["platform"] == 'x11' or env["platform"] == 'server') and (platform.machine().startswith('arm') or platform.machine().startswith('aarch')))
  226. is_ios_x86 = (env["platform"] == 'iphone' and ("arch" in env and env["arch"].startswith('x86')))
  227. is_android_x86 = (env["platform"] == 'android' and env["android_arch"] == 'x86')
  228. if is_android_x86:
  229. cpu_bits = '32'
  230. webm_cpu_x86 = not is_x11_or_server_arm and (cpu_bits == '32' or cpu_bits == '64') and (env["platform"] == 'windows' or env["platform"] == 'x11' or env["platform"] == 'osx' or env["platform"] == 'haiku' or is_android_x86 or is_ios_x86)
  231. webm_cpu_arm = is_x11_or_server_arm or (not is_ios_x86 and env["platform"] == 'iphone') or (not is_android_x86 and env["platform"] == 'android')
  232. if webm_cpu_x86:
  233. import subprocess
  234. import os
  235. yasm_paths = [
  236. "yasm",
  237. "../../../yasm",
  238. ]
  239. yasm_found = False
  240. devnull = open(os.devnull)
  241. for yasm_path in yasm_paths:
  242. try:
  243. yasm_found = True
  244. subprocess.Popen([yasm_path, "--version"], stdout=devnull, stderr=devnull).communicate()
  245. except:
  246. yasm_found = False
  247. if yasm_found:
  248. break
  249. if not yasm_found:
  250. webm_cpu_x86 = False
  251. print("YASM is necessary for WebM SIMD optimizations.")
  252. webm_simd_optimizations = False
  253. if webm_cpu_x86:
  254. if env["platform"] == 'windows' or env["platform"] == 'uwp':
  255. env_libvpx["ASFORMAT"] = 'win'
  256. elif env["platform"] == 'osx' or env["platform"] == "iphone":
  257. env_libvpx["ASFORMAT"] = 'macho'
  258. else:
  259. env_libvpx["ASFORMAT"] = 'elf'
  260. env_libvpx["ASFORMAT"] += cpu_bits
  261. env_libvpx["AS"] = 'yasm'
  262. env_libvpx["ASFLAGS"] = '-I' + libvpx_dir[1:] + ' -f $ASFORMAT -D $ASCPU'
  263. env_libvpx["ASCOM"] = '$AS $ASFLAGS -o $TARGET $SOURCES'
  264. if cpu_bits == '32':
  265. env_libvpx["ASCPU"] = 'X86_32'
  266. elif cpu_bits == '64':
  267. env_libvpx["ASCPU"] = 'X86_64'
  268. env_libvpx.Append(CCFLAGS=['-DWEBM_X86ASM'])
  269. webm_simd_optimizations = True
  270. if webm_cpu_arm:
  271. if env["platform"] == 'iphone':
  272. env_libvpx["ASFLAGS"] = '-arch armv7'
  273. elif env["platform"] == 'android' and env["android_arch"] == 'armv7' or env["platform"] == 'x11' or env["platform"] == 'server':
  274. env_libvpx["ASFLAGS"] = '-mfpu=neon'
  275. elif env["platform"] == 'uwp':
  276. env_libvpx["AS"] = 'armasm'
  277. env_libvpx["ASFLAGS"] = ''
  278. env_libvpx["ASCOM"] = '$AS $ASFLAGS -o $TARGET $SOURCES'
  279. env_libvpx.Append(CCFLAGS=['-DWEBM_ARMASM'])
  280. webm_simd_optimizations = True
  281. if webm_simd_optimizations == False:
  282. print("WebM SIMD optimizations are disabled. Check if your CPU architecture, CPU bits or platform are supported!")
  283. env_libvpx.add_source_files(env.modules_sources, libvpx_sources)
  284. if webm_multithread:
  285. env_libvpx.add_source_files(env.modules_sources, libvpx_sources_mt)
  286. if webm_cpu_x86:
  287. is_clang_or_gcc = ('gcc' in os.path.basename(env["CC"])) or ('clang' in os.path.basename(env["CC"])) or ("osxcross" in env)
  288. env_libvpx_mmx = env_libvpx.Clone()
  289. if cpu_bits == '32' and is_clang_or_gcc:
  290. env_libvpx_mmx.Append(CCFLAGS=['-mmmx'])
  291. env_libvpx_mmx.add_source_files(env.modules_sources, libvpx_sources_intrin_x86_mmx)
  292. env_libvpx_sse2 = env_libvpx.Clone()
  293. if cpu_bits == '32' and is_clang_or_gcc:
  294. env_libvpx_sse2.Append(CCFLAGS=['-msse2'])
  295. env_libvpx_sse2.add_source_files(env.modules_sources, libvpx_sources_intrin_x86_sse2)
  296. env_libvpx_ssse3 = env_libvpx.Clone()
  297. if is_clang_or_gcc:
  298. env_libvpx_ssse3.Append(CCFLAGS=['-mssse3'])
  299. env_libvpx_ssse3.add_source_files(env.modules_sources, libvpx_sources_intrin_x86_ssse3)
  300. env_libvpx_avx2 = env_libvpx.Clone()
  301. if is_clang_or_gcc:
  302. env_libvpx_avx2.Append(CCFLAGS=['-mavx2'])
  303. env_libvpx_avx2.add_source_files(env.modules_sources, libvpx_sources_intrin_x86_avx2)
  304. env_libvpx.add_source_files(env.modules_sources, libvpx_sources_intrin_x86)
  305. env_libvpx.add_source_files(env.modules_sources, libvpx_sources_x86asm)
  306. if cpu_bits == '64':
  307. env_libvpx.add_source_files(env.modules_sources, libvpx_sources_x86_64asm)
  308. elif webm_cpu_arm:
  309. env_libvpx.add_source_files(env.modules_sources, libvpx_sources_arm)
  310. if env["platform"] == 'android':
  311. env_libvpx.Append(CPPPATH=[libvpx_dir + "third_party/android"])
  312. env_libvpx.add_source_files(env.modules_sources, [libvpx_dir + "third_party/android/cpu-features.c"])
  313. env_libvpx_neon = env_libvpx.Clone()
  314. if env["platform"] == 'android' and env["android_arch"] == 'armv6':
  315. env_libvpx_neon.Append(CCFLAGS=['-mfpu=neon'])
  316. env_libvpx_neon.add_source_files(env.modules_sources, libvpx_sources_arm_neon)
  317. if env["platform"] == 'uwp':
  318. env_libvpx.add_source_files(env.modules_sources, libvpx_sources_arm_neon_armasm_ms)
  319. elif env["platform"] == 'iphone':
  320. env_libvpx.add_source_files(env.modules_sources, libvpx_sources_arm_neon_gas_apple)
  321. elif (is_x11_or_server_arm and cpu_bits == '32') or (env["platform"] == 'android' and not env["android_arch"] == 'arm64v8'):
  322. env_libvpx.add_source_files(env.modules_sources, libvpx_sources_arm_neon_gas)