SCsub 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. #!/usr/bin/env python
  2. Import("env")
  3. Import("env_modules")
  4. # Only kept to build the thirdparty library used by the webm module.
  5. # AudioStreamOpus was dropped in 3.0 due to incompatibility with the new audio
  6. # engine. If you want to port it, fetch it from the Git history.
  7. env_opus = env_modules.Clone()
  8. # Thirdparty source files
  9. thirdparty_obj = []
  10. # Thirdparty source files
  11. if env["builtin_opus"]:
  12. thirdparty_dir = "#thirdparty/opus/"
  13. thirdparty_sources = [
  14. # Sync with opus_sources.mk
  15. "opus.c",
  16. "opus_decoder.c",
  17. "opus_encoder.c",
  18. "opus_multistream.c",
  19. "opus_multistream_encoder.c",
  20. "opus_multistream_decoder.c",
  21. "repacketizer.c",
  22. "analysis.c",
  23. "mlp.c",
  24. "mlp_data.c",
  25. # Sync with libopusfile Makefile.am
  26. "info.c",
  27. "internal.c",
  28. "opusfile.c",
  29. "stream.c",
  30. # Sync with celt_sources.mk
  31. "celt/bands.c",
  32. "celt/celt.c",
  33. "celt/celt_encoder.c",
  34. "celt/celt_decoder.c",
  35. "celt/cwrs.c",
  36. "celt/entcode.c",
  37. "celt/entdec.c",
  38. "celt/entenc.c",
  39. "celt/kiss_fft.c",
  40. "celt/laplace.c",
  41. "celt/mathops.c",
  42. "celt/mdct.c",
  43. "celt/modes.c",
  44. "celt/pitch.c",
  45. "celt/celt_lpc.c",
  46. "celt/quant_bands.c",
  47. "celt/rate.c",
  48. "celt/vq.c",
  49. # "celt/arm/arm_celt_map.c",
  50. # "celt/arm/armcpu.c",
  51. # "celt/arm/celt_ne10_fft.c",
  52. # "celt/arm/celt_ne10_mdct.c",
  53. # "celt/arm/celt_neon_intr.c",
  54. # Sync with silk_sources.mk
  55. "silk/CNG.c",
  56. "silk/code_signs.c",
  57. "silk/init_decoder.c",
  58. "silk/decode_core.c",
  59. "silk/decode_frame.c",
  60. "silk/decode_parameters.c",
  61. "silk/decode_indices.c",
  62. "silk/decode_pulses.c",
  63. "silk/decoder_set_fs.c",
  64. "silk/dec_API.c",
  65. "silk/enc_API.c",
  66. "silk/encode_indices.c",
  67. "silk/encode_pulses.c",
  68. "silk/gain_quant.c",
  69. "silk/interpolate.c",
  70. "silk/LP_variable_cutoff.c",
  71. "silk/NLSF_decode.c",
  72. "silk/NSQ.c",
  73. "silk/NSQ_del_dec.c",
  74. "silk/PLC.c",
  75. "silk/shell_coder.c",
  76. "silk/tables_gain.c",
  77. "silk/tables_LTP.c",
  78. "silk/tables_NLSF_CB_NB_MB.c",
  79. "silk/tables_NLSF_CB_WB.c",
  80. "silk/tables_other.c",
  81. "silk/tables_pitch_lag.c",
  82. "silk/tables_pulses_per_block.c",
  83. "silk/VAD.c",
  84. "silk/control_audio_bandwidth.c",
  85. "silk/quant_LTP_gains.c",
  86. "silk/VQ_WMat_EC.c",
  87. "silk/HP_variable_cutoff.c",
  88. "silk/NLSF_encode.c",
  89. "silk/NLSF_VQ.c",
  90. "silk/NLSF_unpack.c",
  91. "silk/NLSF_del_dec_quant.c",
  92. "silk/process_NLSFs.c",
  93. "silk/stereo_LR_to_MS.c",
  94. "silk/stereo_MS_to_LR.c",
  95. "silk/check_control_input.c",
  96. "silk/control_SNR.c",
  97. "silk/init_encoder.c",
  98. "silk/control_codec.c",
  99. "silk/A2NLSF.c",
  100. "silk/ana_filt_bank_1.c",
  101. "silk/biquad_alt.c",
  102. "silk/bwexpander_32.c",
  103. "silk/bwexpander.c",
  104. "silk/debug.c",
  105. "silk/decode_pitch.c",
  106. "silk/inner_prod_aligned.c",
  107. "silk/lin2log.c",
  108. "silk/log2lin.c",
  109. "silk/LPC_analysis_filter.c",
  110. "silk/LPC_inv_pred_gain.c",
  111. "silk/table_LSF_cos.c",
  112. "silk/NLSF2A.c",
  113. "silk/NLSF_stabilize.c",
  114. "silk/NLSF_VQ_weights_laroia.c",
  115. "silk/pitch_est_tables.c",
  116. "silk/resampler.c",
  117. "silk/resampler_down2_3.c",
  118. "silk/resampler_down2.c",
  119. "silk/resampler_private_AR2.c",
  120. "silk/resampler_private_down_FIR.c",
  121. "silk/resampler_private_IIR_FIR.c",
  122. "silk/resampler_private_up2_HQ.c",
  123. "silk/resampler_rom.c",
  124. "silk/sigm_Q15.c",
  125. "silk/sort.c",
  126. "silk/sum_sqr_shift.c",
  127. "silk/stereo_decode_pred.c",
  128. "silk/stereo_encode_pred.c",
  129. "silk/stereo_find_predictor.c",
  130. "silk/stereo_quant_pred.c",
  131. ]
  132. opus_sources_silk = []
  133. if env["platform"] in ["android", "iphone", "javascript"]:
  134. env_opus.Append(CPPDEFINES=["FIXED_POINT"])
  135. opus_sources_silk = [
  136. "silk/fixed/LTP_analysis_filter_FIX.c",
  137. "silk/fixed/LTP_scale_ctrl_FIX.c",
  138. "silk/fixed/corrMatrix_FIX.c",
  139. "silk/fixed/encode_frame_FIX.c",
  140. "silk/fixed/find_LPC_FIX.c",
  141. "silk/fixed/find_LTP_FIX.c",
  142. "silk/fixed/find_pitch_lags_FIX.c",
  143. "silk/fixed/find_pred_coefs_FIX.c",
  144. "silk/fixed/noise_shape_analysis_FIX.c",
  145. "silk/fixed/prefilter_FIX.c",
  146. "silk/fixed/process_gains_FIX.c",
  147. "silk/fixed/regularize_correlations_FIX.c",
  148. "silk/fixed/residual_energy16_FIX.c",
  149. "silk/fixed/residual_energy_FIX.c",
  150. "silk/fixed/solve_LS_FIX.c",
  151. "silk/fixed/warped_autocorrelation_FIX.c",
  152. "silk/fixed/apply_sine_window_FIX.c",
  153. "silk/fixed/autocorr_FIX.c",
  154. "silk/fixed/burg_modified_FIX.c",
  155. "silk/fixed/k2a_FIX.c",
  156. "silk/fixed/k2a_Q16_FIX.c",
  157. "silk/fixed/pitch_analysis_core_FIX.c",
  158. "silk/fixed/vector_ops_FIX.c",
  159. "silk/fixed/schur64_FIX.c",
  160. "silk/fixed/schur_FIX.c",
  161. ]
  162. else:
  163. opus_sources_silk = [
  164. "silk/float/apply_sine_window_FLP.c",
  165. "silk/float/corrMatrix_FLP.c",
  166. "silk/float/encode_frame_FLP.c",
  167. "silk/float/find_LPC_FLP.c",
  168. "silk/float/find_LTP_FLP.c",
  169. "silk/float/find_pitch_lags_FLP.c",
  170. "silk/float/find_pred_coefs_FLP.c",
  171. "silk/float/LPC_analysis_filter_FLP.c",
  172. "silk/float/LTP_analysis_filter_FLP.c",
  173. "silk/float/LTP_scale_ctrl_FLP.c",
  174. "silk/float/noise_shape_analysis_FLP.c",
  175. "silk/float/prefilter_FLP.c",
  176. "silk/float/process_gains_FLP.c",
  177. "silk/float/regularize_correlations_FLP.c",
  178. "silk/float/residual_energy_FLP.c",
  179. "silk/float/solve_LS_FLP.c",
  180. "silk/float/warped_autocorrelation_FLP.c",
  181. "silk/float/wrappers_FLP.c",
  182. "silk/float/autocorrelation_FLP.c",
  183. "silk/float/burg_modified_FLP.c",
  184. "silk/float/bwexpander_FLP.c",
  185. "silk/float/energy_FLP.c",
  186. "silk/float/inner_product_FLP.c",
  187. "silk/float/k2a_FLP.c",
  188. "silk/float/levinsondurbin_FLP.c",
  189. "silk/float/LPC_inv_pred_gain_FLP.c",
  190. "silk/float/pitch_analysis_core_FLP.c",
  191. "silk/float/scale_copy_vector_FLP.c",
  192. "silk/float/scale_vector_FLP.c",
  193. "silk/float/schur_FLP.c",
  194. "silk/float/sort_FLP.c",
  195. ]
  196. thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources + opus_sources_silk]
  197. # also requires libogg
  198. if env["builtin_libogg"]:
  199. env_opus.Prepend(CPPPATH=["#thirdparty/libogg"])
  200. env_opus.Append(CPPDEFINES=["HAVE_CONFIG_H"])
  201. thirdparty_include_paths = [
  202. "",
  203. "celt",
  204. "opus",
  205. "silk",
  206. "silk/fixed",
  207. "silk/float",
  208. ]
  209. env_opus.Prepend(CPPPATH=[thirdparty_dir + "/" + dir for dir in thirdparty_include_paths])
  210. if env["platform"] == "android":
  211. if "android_arch" in env and env["android_arch"] == "armv7":
  212. env_opus.Append(CPPDEFINES=["OPUS_ARM_OPT"])
  213. elif "android_arch" in env and env["android_arch"] == "arm64v8":
  214. env_opus.Append(CPPDEFINES=["OPUS_ARM64_OPT"])
  215. elif env["platform"] == "iphone":
  216. if "arch" in env and env["arch"] == "arm":
  217. env_opus.Append(CPPDEFINES=["OPUS_ARM_OPT"])
  218. elif "arch" in env and env["arch"] == "arm64":
  219. env_opus.Append(CPPDEFINES=["OPUS_ARM64_OPT"])
  220. elif env["platform"] == "osx":
  221. if "arch" in env and env["arch"] == "arm64":
  222. env_opus.Append(CPPDEFINES=["OPUS_ARM64_OPT"])
  223. env_thirdparty = env_opus.Clone()
  224. env_thirdparty.disable_warnings()
  225. env_thirdparty.add_source_files(thirdparty_obj, thirdparty_sources)
  226. env.modules_sources += thirdparty_obj
  227. # Godot source files
  228. module_obj = []
  229. env_opus.add_source_files(module_obj, "*.cpp")
  230. env.modules_sources += module_obj
  231. # Needed to force rebuilding the module files when the thirdparty library is updated.
  232. env.Depends(module_obj, thirdparty_obj)