diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/csg/csg.cpp | 6 | ||||
-rw-r--r-- | modules/gdscript/gdscript.cpp | 3 | ||||
-rw-r--r-- | modules/mono/csharp_script.cpp | 33 | ||||
-rw-r--r-- | modules/mono/editor/GodotSharpTools/GodotSharpTools.csproj | 1 | ||||
-rw-r--r-- | modules/mono/editor/GodotSharpTools/Project/IdentifierUtils.cs | 199 | ||||
-rw-r--r-- | modules/mono/editor/GodotSharpTools/Project/ProjectGenerator.cs | 5 | ||||
-rw-r--r-- | modules/mono/editor/script_class_parser.cpp | 25 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/Array.cs | 13 | ||||
-rw-r--r-- | modules/mono/glue/collections_glue.cpp | 5 | ||||
-rw-r--r-- | modules/mono/glue/collections_glue.h | 2 | ||||
-rw-r--r-- | modules/opus/SCsub | 307 |
11 files changed, 431 insertions, 168 deletions
diff --git a/modules/csg/csg.cpp b/modules/csg/csg.cpp index fb7f829cf0..0eb539b182 100644 --- a/modules/csg/csg.cpp +++ b/modules/csg/csg.cpp @@ -953,13 +953,15 @@ void CSGBrushOperation::_merge_poly(MeshMerge &mesh, int p_face_idx, const Build //duplicate point int insert_at = with_outline_vertex; - polys.write[i].points.insert(insert_at, polys[i].points[insert_at]); + int point = polys[i].points[insert_at]; + polys.write[i].points.insert(insert_at, point); insert_at++; //insert all others, outline should be backwards (must check) int holesize = polys[i].holes[j].size(); for (int k = 0; k <= holesize; k++) { int idx = (from_hole_vertex + k) % holesize; - polys.write[i].points.insert(insert_at, polys[i].holes[j][idx]); + int point2 = polys[i].holes[j][idx]; + polys.write[i].points.insert(insert_at, point2); insert_at++; } diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index dd9b36fd8c..e07911fa44 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -152,12 +152,13 @@ Variant GDScript::_new(const Variant **p_args, int p_argcount, Variant::CallErro } ERR_FAIL_COND_V(_baseptr->native.is_null(), Variant()); - if (_baseptr->native.ptr()) { owner = _baseptr->native->instance(); } else { owner = memnew(Reference); //by default, no base means use reference } + ERR_EXPLAIN("Can't inherit from a virtual class"); + ERR_FAIL_COND_V(!owner, Variant()); Reference *r = Object::cast_to<Reference>(owner); if (r) { diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index a7ac7f46c5..47be3a9959 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -1528,6 +1528,15 @@ MonoObject *CSharpInstance::_internal_new_managed() { CRASH_COND(!gchandle.is_valid()); #endif + // Search the constructor first, to fail with an error if it's not found before allocating anything else. + GDMonoMethod *ctor = script->script_class->get_method(CACHED_STRING_NAME(dotctor), 0); + if (ctor == NULL) { + ERR_PRINTS("Cannot create script instance because the class does not define a default constructor: " + script->get_path()); + + ERR_EXPLAIN("Constructor not found"); + ERR_FAIL_V(NULL); + } + CSharpLanguage::get_singleton()->release_script_gchandle(gchandle); ERR_FAIL_NULL_V(owner, NULL); @@ -1557,7 +1566,6 @@ MonoObject *CSharpInstance::_internal_new_managed() { CACHED_FIELD(GodotObject, ptr)->set_value_raw(mono_object, owner); // Construct - GDMonoMethod *ctor = script->script_class->get_method(CACHED_STRING_NAME(dotctor), 0); ctor->invoke_raw(mono_object, NULL); return mono_object; @@ -1900,13 +1908,21 @@ bool CSharpScript::_update_exports() { MonoObject *tmp_object = mono_object_new(SCRIPTS_DOMAIN, script_class->get_mono_ptr()); if (!tmp_object) { - ERR_PRINT("Failed to create temporary MonoObject"); + ERR_PRINT("Failed to allocate temporary MonoObject"); return false; } uint32_t tmp_pinned_gchandle = MonoGCHandle::new_strong_handle_pinned(tmp_object); // pin it (not sure if needed) GDMonoMethod *ctor = script_class->get_method(CACHED_STRING_NAME(dotctor), 0); + + if (ctor == NULL) { + ERR_PRINTS("Cannot construct temporary MonoObject because the class does not define a default constructor: " + get_path()); + + ERR_EXPLAIN("Constructor not found"); + ERR_FAIL_V(NULL); + } + MonoException *ctor_exc = NULL; ctor->invoke(tmp_object, NULL, &ctor_exc); @@ -2387,6 +2403,18 @@ StringName CSharpScript::get_instance_base_type() const { CSharpInstance *CSharpScript::_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, Variant::CallError &r_error) { /* STEP 1, CREATE */ + + // Search the constructor first, to fail with an error if it's not found before allocating anything else. + GDMonoMethod *ctor = script_class->get_method(CACHED_STRING_NAME(dotctor), p_argcount); + if (ctor == NULL) { + if (p_argcount == 0) { + ERR_PRINTS("Cannot create script instance because the class does not define a default constructor: " + get_path()); + } + + ERR_EXPLAIN("Constructor not found"); + ERR_FAIL_V(NULL); + } + Ref<Reference> ref; if (p_isref) { // Hold it alive. Important if we have to dispose a script instance binding before creating the CSharpInstance. @@ -2453,7 +2481,6 @@ CSharpInstance *CSharpScript::_create_instance(const Variant **p_args, int p_arg CACHED_FIELD(GodotObject, ptr)->set_value_raw(mono_object, instance->owner); // Construct - GDMonoMethod *ctor = script_class->get_method(CACHED_STRING_NAME(dotctor), p_argcount); ctor->invoke(mono_object, p_args); /* STEP 3, PARTY */ diff --git a/modules/mono/editor/GodotSharpTools/GodotSharpTools.csproj b/modules/mono/editor/GodotSharpTools/GodotSharpTools.csproj index 9a5dd24bb1..2871c041f5 100644 --- a/modules/mono/editor/GodotSharpTools/GodotSharpTools.csproj +++ b/modules/mono/editor/GodotSharpTools/GodotSharpTools.csproj @@ -41,6 +41,7 @@ <Compile Include="Build\BuildSystem.cs" /> <Compile Include="Editor\MonoDevelopInstance.cs" /> <Compile Include="Project\ProjectExtensions.cs" /> + <Compile Include="Project\IdentifierUtils.cs" /> <Compile Include="Project\ProjectGenerator.cs" /> <Compile Include="Project\ProjectUtils.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> diff --git a/modules/mono/editor/GodotSharpTools/Project/IdentifierUtils.cs b/modules/mono/editor/GodotSharpTools/Project/IdentifierUtils.cs new file mode 100644 index 0000000000..83e2d2cf8d --- /dev/null +++ b/modules/mono/editor/GodotSharpTools/Project/IdentifierUtils.cs @@ -0,0 +1,199 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Text; + +namespace GodotSharpTools.Project +{ + public static class IdentifierUtils + { + public static string SanitizeQualifiedIdentifier(string qualifiedIdentifier, bool allowEmptyIdentifiers) + { + if (string.IsNullOrEmpty(qualifiedIdentifier)) + throw new ArgumentException($"{nameof(qualifiedIdentifier)} cannot be empty", nameof(qualifiedIdentifier)); + + string[] identifiers = qualifiedIdentifier.Split(new[] { '.' }); + + for (int i = 0; i < identifiers.Length; i++) + { + identifiers[i] = SanitizeIdentifier(identifiers[i], allowEmpty: allowEmptyIdentifiers); + } + + return string.Join(".", identifiers); + } + + public static string SanitizeIdentifier(string identifier, bool allowEmpty) + { + if (string.IsNullOrEmpty(identifier)) + { + if (allowEmpty) + return "Empty"; // Default value for empty identifiers + + throw new ArgumentException($"{nameof(identifier)} cannot be empty if {nameof(allowEmpty)} is false", nameof(identifier)); + } + + if (identifier.Length > 511) + identifier = identifier.Substring(0, 511); + + var identifierBuilder = new StringBuilder(); + int startIndex = 0; + + if (identifier[0] == '@') + { + identifierBuilder.Append('@'); + startIndex += 1; + } + + for (int i = startIndex; i < identifier.Length; i++) + { + char @char = identifier[i]; + + switch (Char.GetUnicodeCategory(@char)) + { + case UnicodeCategory.UppercaseLetter: + case UnicodeCategory.LowercaseLetter: + case UnicodeCategory.TitlecaseLetter: + case UnicodeCategory.ModifierLetter: + case UnicodeCategory.LetterNumber: + case UnicodeCategory.OtherLetter: + identifierBuilder.Append(@char); + break; + case UnicodeCategory.NonSpacingMark: + case UnicodeCategory.SpacingCombiningMark: + case UnicodeCategory.ConnectorPunctuation: + case UnicodeCategory.DecimalDigitNumber: + // Identifiers may start with underscore + if (identifierBuilder.Length > startIndex || @char == '_') + identifierBuilder.Append(@char); + break; + default: + break; + } + } + + if (identifierBuilder.Length == startIndex) + { + // All characters were invalid so now it's empty. Fill it with something. + identifierBuilder.Append("Empty"); + } + + identifier = identifierBuilder.ToString(); + + if (identifier[0] != '@' && IsKeyword(identifier, anyDoubleUnderscore: true)) + identifier = '@' + identifier; + + return identifier; + } + + static bool IsKeyword(string value, bool anyDoubleUnderscore) + { + // Identifiers that start with double underscore are meant to be used for reserved keywords. + // Only existing keywords are enforced, but it may be useful to forbid any identifier + // that begins with double underscore to prevent issues with future C# versions. + if (anyDoubleUnderscore) + { + if (value.Length > 2 && value[0] == '_' && value[1] == '_' && value[2] != '_') + return true; + } + else + { + if (_doubleUnderscoreKeywords.Contains(value)) + return true; + } + + return _keywords.Contains(value); + } + + static HashSet<string> _doubleUnderscoreKeywords = new HashSet<string> + { + "__arglist", + "__makeref", + "__reftype", + "__refvalue", + }; + + static HashSet<string> _keywords = new HashSet<string> + { + "as", + "do", + "if", + "in", + "is", + "for", + "int", + "new", + "out", + "ref", + "try", + "base", + "bool", + "byte", + "case", + "char", + "else", + "enum", + "goto", + "lock", + "long", + "null", + "this", + "true", + "uint", + "void", + "break", + "catch", + "class", + "const", + "event", + "false", + "fixed", + "float", + "sbyte", + "short", + "throw", + "ulong", + "using", + "where", + "while", + "yield", + "double", + "extern", + "object", + "params", + "public", + "return", + "sealed", + "sizeof", + "static", + "string", + "struct", + "switch", + "typeof", + "unsafe", + "ushort", + "checked", + "decimal", + "default", + "finally", + "foreach", + "partial", + "private", + "virtual", + "abstract", + "continue", + "delegate", + "explicit", + "implicit", + "internal", + "operator", + "override", + "readonly", + "volatile", + "interface", + "namespace", + "protected", + "unchecked", + "stackalloc", + }; + } +} diff --git a/modules/mono/editor/GodotSharpTools/Project/ProjectGenerator.cs b/modules/mono/editor/GodotSharpTools/Project/ProjectGenerator.cs index 9135006172..89279c69a6 100644 --- a/modules/mono/editor/GodotSharpTools/Project/ProjectGenerator.cs +++ b/modules/mono/editor/GodotSharpTools/Project/ProjectGenerator.cs @@ -140,6 +140,9 @@ namespace GodotSharpTools.Project public static ProjectRootElement CreateLibraryProject(string name, out ProjectPropertyGroupElement mainGroup) { + if (string.IsNullOrEmpty(name)) + throw new ArgumentException($"{nameof(name)} cannot be empty", nameof(name)); + var root = ProjectRootElement.Create(); root.DefaultTargets = "Build"; @@ -149,7 +152,7 @@ namespace GodotSharpTools.Project mainGroup.AddProperty("ProjectGuid", "{" + Guid.NewGuid().ToString().ToUpper() + "}"); mainGroup.AddProperty("OutputType", "Library"); mainGroup.AddProperty("OutputPath", Path.Combine("bin", "$(Configuration)")); - mainGroup.AddProperty("RootNamespace", name); + mainGroup.AddProperty("RootNamespace", IdentifierUtils.SanitizeQualifiedIdentifier(name, allowEmptyIdentifiers: true)); mainGroup.AddProperty("AssemblyName", name); mainGroup.AddProperty("TargetFrameworkVersion", "v4.5"); diff --git a/modules/mono/editor/script_class_parser.cpp b/modules/mono/editor/script_class_parser.cpp index fcc58c22e8..6b2ec5cc20 100644 --- a/modules/mono/editor/script_class_parser.cpp +++ b/modules/mono/editor/script_class_parser.cpp @@ -322,6 +322,15 @@ Error ScriptClassParser::_parse_type_full_name(String &r_full_name) { r_full_name += String(value); + if (code[idx] == '<') { + idx++; + + // We don't mind if the base is generic, but we skip it any ways since this information is not needed + Error err = _skip_generic_type_params(); + if (err) + return err; + } + if (code[idx] != '.') // We only want to take the next token if it's a period return OK; @@ -344,16 +353,6 @@ Error ScriptClassParser::_parse_class_base(Vector<String> &r_base) { Token tk = get_token(); - bool generic = false; - if (tk == TK_OP_LESS) { - err = _skip_generic_type_params(); - if (err) - return err; - // We don't add it to the base list if it's generic - generic = true; - tk = get_token(); - } - if (tk == TK_COMMA) { err = _parse_class_base(r_base); if (err) @@ -373,9 +372,7 @@ Error ScriptClassParser::_parse_class_base(Vector<String> &r_base) { return ERR_PARSE_ERROR; } - if (!generic) { - r_base.push_back(name); - } + r_base.push_back(name); return OK; } @@ -567,7 +564,7 @@ Error ScriptClassParser::parse(const String &p_code) { if (full_name.length()) full_name += "."; full_name += class_decl.name; - OS::get_singleton()->print("%s", String("Ignoring generic class declaration: " + class_decl.name).utf8().get_data()); + OS::get_singleton()->print("Ignoring generic class declaration: %s\n", class_decl.name.utf8().get_data()); } } } else if (tk == TK_IDENTIFIER && String(value) == "struct") { diff --git a/modules/mono/glue/Managed/Files/Array.cs b/modules/mono/glue/Managed/Files/Array.cs index 9c804eba64..1ee64f3b71 100644 --- a/modules/mono/glue/Managed/Files/Array.cs +++ b/modules/mono/glue/Managed/Files/Array.cs @@ -155,6 +155,11 @@ namespace Godot.Collections godot_icall_Array_RemoveAt(GetPtr(), index); } + public Error Resize(int newSize) + { + return godot_icall_Array_Resize(GetPtr(), newSize); + } + IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); @@ -203,6 +208,9 @@ namespace Godot.Collections internal extern static void godot_icall_Array_RemoveAt(IntPtr ptr, int index); [MethodImpl(MethodImplOptions.InternalCall)] + internal extern static Error godot_icall_Array_Resize(IntPtr ptr, int newSize); + + [MethodImpl(MethodImplOptions.InternalCall)] internal extern static void godot_icall_Array_Generic_GetElementTypeInfo(Type elemType, out int elemTypeEncoding, out IntPtr elemTypeClass); } @@ -339,6 +347,11 @@ namespace Godot.Collections objectArray.RemoveAt(index); } + public Error Resize(int newSize) + { + return objectArray.Resize(newSize); + } + IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); diff --git a/modules/mono/glue/collections_glue.cpp b/modules/mono/glue/collections_glue.cpp index d905810d66..1065ff0868 100644 --- a/modules/mono/glue/collections_glue.cpp +++ b/modules/mono/glue/collections_glue.cpp @@ -130,6 +130,10 @@ void godot_icall_Array_RemoveAt(Array *ptr, int index) { ptr->remove(index); } +Error godot_icall_Array_Resize(Array *ptr, int new_size) { + return ptr->resize(new_size); +} + void godot_icall_Array_Generic_GetElementTypeInfo(MonoReflectionType *refltype, uint32_t *type_encoding, GDMonoClass **type_class) { MonoType *elem_type = mono_reflection_type_get_type(refltype); @@ -274,6 +278,7 @@ void godot_register_collections_icalls() { mono_add_internal_call("Godot.Collections.Array::godot_icall_Array_Insert", (void *)godot_icall_Array_Insert); mono_add_internal_call("Godot.Collections.Array::godot_icall_Array_Remove", (void *)godot_icall_Array_Remove); mono_add_internal_call("Godot.Collections.Array::godot_icall_Array_RemoveAt", (void *)godot_icall_Array_RemoveAt); + mono_add_internal_call("Godot.Collections.Array::godot_icall_Array_Resize", (void *)godot_icall_Array_Resize); mono_add_internal_call("Godot.Collections.Array::godot_icall_Array_Generic_GetElementTypeInfo", (void *)godot_icall_Array_Generic_GetElementTypeInfo); mono_add_internal_call("Godot.Collections.Dictionary::godot_icall_Dictionary_Ctor", (void *)godot_icall_Dictionary_Ctor); diff --git a/modules/mono/glue/collections_glue.h b/modules/mono/glue/collections_glue.h index 52ca98b7f9..c0056d3bce 100644 --- a/modules/mono/glue/collections_glue.h +++ b/modules/mono/glue/collections_glue.h @@ -67,6 +67,8 @@ bool godot_icall_Array_Remove(Array *ptr, MonoObject *item); void godot_icall_Array_RemoveAt(Array *ptr, int index); +Error godot_icall_Array_Resize(Array *ptr, int new_size); + void godot_icall_Array_Generic_GetElementTypeInfo(MonoReflectionType *refltype, uint32_t *type_encoding, GDMonoClass **type_class); // Dictionary diff --git a/modules/opus/SCsub b/modules/opus/SCsub index 508aec7057..aa656c575a 100644 --- a/modules/opus/SCsub +++ b/modules/opus/SCsub @@ -12,187 +12,194 @@ if env['builtin_opus']: thirdparty_dir = "#thirdparty/opus/" thirdparty_sources = [ - "silk/tables_other.c", - "silk/sum_sqr_shift.c", - "silk/PLC.c", - "silk/dec_API.c", - "silk/decode_pulses.c", - "silk/inner_prod_aligned.c", - "silk/init_encoder.c", - "silk/interpolate.c", - "silk/stereo_encode_pred.c", - "silk/decode_frame.c", - "silk/NLSF_del_dec_quant.c", - "silk/VAD.c", - "silk/resampler_private_AR2.c", - "silk/NLSF_unpack.c", - "silk/resampler_down2.c", - "silk/sort.c", - "silk/resampler_private_IIR_FIR.c", - "silk/resampler_down2_3.c", - "silk/resampler_private_up2_HQ.c", - "silk/tables_gain.c", - "silk/stereo_find_predictor.c", - "silk/stereo_quant_pred.c", - "silk/NLSF_stabilize.c", - "silk/ana_filt_bank_1.c", - "silk/check_control_input.c", - "silk/bwexpander.c", - "silk/A2NLSF.c", - "silk/LPC_inv_pred_gain.c", - "silk/log2lin.c", - "silk/process_NLSFs.c", - "silk/sigm_Q15.c", - "silk/VQ_WMat_EC.c", - "silk/quant_LTP_gains.c", - "silk/resampler_private_down_FIR.c", - "silk/NLSF_decode.c", - "silk/control_codec.c", - "silk/NLSF_VQ_weights_laroia.c", - "silk/decode_pitch.c", - "silk/stereo_decode_pred.c", - "silk/tables_pulses_per_block.c", + + # Sync with opus_sources.mk + "opus.c", + "opus_decoder.c", + "opus_encoder.c", + "opus_multistream.c", + "opus_multistream_encoder.c", + "opus_multistream_decoder.c", + "repacketizer.c", + + "analysis.c", + "mlp.c", + "mlp_data.c", + + # Sync with libopusfile Makefile.am + "info.c", + "internal.c", + "opusfile.c", + "stream.c", + + # Sync with celt_sources.mk + "celt/bands.c", + "celt/celt.c", + "celt/celt_encoder.c", + "celt/celt_decoder.c", + "celt/cwrs.c", + "celt/entcode.c", + "celt/entdec.c", + "celt/entenc.c", + "celt/kiss_fft.c", + "celt/laplace.c", + "celt/mathops.c", + "celt/mdct.c", + "celt/modes.c", + "celt/pitch.c", + "celt/celt_lpc.c", + "celt/quant_bands.c", + "celt/rate.c", + "celt/vq.c", + #"celt/arm/arm_celt_map.c", + #"celt/arm/armcpu.c", + #"celt/arm/celt_ne10_fft.c", + #"celt/arm/celt_ne10_mdct.c", + #"celt/arm/celt_neon_intr.c", + + # Sync with silk_sources.mk + "silk/CNG.c", + "silk/code_signs.c", "silk/init_decoder.c", - "silk/table_LSF_cos.c", "silk/decode_core.c", - "silk/code_signs.c", - "silk/enc_API.c", - "silk/tables_LTP.c", - "silk/pitch_est_tables.c", - "silk/biquad_alt.c", - "silk/encode_indices.c", - "silk/tables_NLSF_CB_WB.c", - "silk/debug.c", + "silk/decode_frame.c", "silk/decode_parameters.c", - "silk/tables_pitch_lag.c", - "silk/NLSF2A.c", - "silk/resampler.c", "silk/decode_indices.c", - "silk/NLSF_VQ.c", - "silk/bwexpander_32.c", - "silk/tables_NLSF_CB_NB_MB.c", + "silk/decode_pulses.c", + "silk/decoder_set_fs.c", + "silk/dec_API.c", + "silk/enc_API.c", + "silk/encode_indices.c", "silk/encode_pulses.c", + "silk/gain_quant.c", + "silk/interpolate.c", + "silk/LP_variable_cutoff.c", + "silk/NLSF_decode.c", + "silk/NSQ.c", "silk/NSQ_del_dec.c", - "silk/control_SNR.c", + "silk/PLC.c", "silk/shell_coder.c", + "silk/tables_gain.c", + "silk/tables_LTP.c", + "silk/tables_NLSF_CB_NB_MB.c", + "silk/tables_NLSF_CB_WB.c", + "silk/tables_other.c", + "silk/tables_pitch_lag.c", + "silk/tables_pulses_per_block.c", + "silk/VAD.c", + "silk/control_audio_bandwidth.c", + "silk/quant_LTP_gains.c", + "silk/VQ_WMat_EC.c", + "silk/HP_variable_cutoff.c", "silk/NLSF_encode.c", - "silk/stereo_MS_to_LR.c", + "silk/NLSF_VQ.c", + "silk/NLSF_unpack.c", + "silk/NLSF_del_dec_quant.c", + "silk/process_NLSFs.c", "silk/stereo_LR_to_MS.c", - "silk/HP_variable_cutoff.c", + "silk/stereo_MS_to_LR.c", + "silk/check_control_input.c", + "silk/control_SNR.c", + "silk/init_encoder.c", + "silk/control_codec.c", + "silk/A2NLSF.c", + "silk/ana_filt_bank_1.c", + "silk/biquad_alt.c", + "silk/bwexpander_32.c", + "silk/bwexpander.c", + "silk/debug.c", + "silk/decode_pitch.c", + "silk/inner_prod_aligned.c", + "silk/lin2log.c", + "silk/log2lin.c", "silk/LPC_analysis_filter.c", - "silk/CNG.c", - "silk/decoder_set_fs.c", + "silk/LPC_inv_pred_gain.c", + "silk/table_LSF_cos.c", + "silk/NLSF2A.c", + "silk/NLSF_stabilize.c", + "silk/NLSF_VQ_weights_laroia.c", + "silk/pitch_est_tables.c", + "silk/resampler.c", + "silk/resampler_down2_3.c", + "silk/resampler_down2.c", + "silk/resampler_private_AR2.c", + "silk/resampler_private_down_FIR.c", + "silk/resampler_private_IIR_FIR.c", + "silk/resampler_private_up2_HQ.c", "silk/resampler_rom.c", - "silk/control_audio_bandwidth.c", - "silk/lin2log.c", - "silk/LP_variable_cutoff.c", - "silk/NSQ.c", - "silk/gain_quant.c", - "celt/laplace.c", - "celt/vq.c", - "celt/quant_bands.c", - "celt/kiss_fft.c", - "celt/entcode.c", - "celt/entenc.c", - "celt/celt_lpc.c", - "celt/pitch.c", - "celt/rate.c", - "celt/mathops.c", - #"celt/arm/armcpu.c", - #"celt/arm/celt_neon_intr.c", - #"celt/arm/celt_ne10_mdct.c", - #"celt/arm/celt_ne10_fft.c", - #"celt/arm/arm_celt_map.c", - "celt/celt_encoder.c", - "celt/celt.c", - "celt/bands.c", - "celt/cwrs.c", - "celt/entdec.c", - "celt/celt_decoder.c", - "celt/mdct.c", - "celt/modes.c", - "repacketizer.c", - "mlp_data.c", - "opus_multistream.c", - "opusfile.c", - "opus_encoder.c", - "analysis.c", - "mlp.c", - "info.c", - "stream.c", - "opus_decoder.c", - "internal.c", - "wincerts.c", - "opus.c", - "opus_multistream_encoder.c", - "http.c", - "opus_multistream_decoder.c" + "silk/sigm_Q15.c", + "silk/sort.c", + "silk/sum_sqr_shift.c", + "silk/stereo_decode_pred.c", + "silk/stereo_encode_pred.c", + "silk/stereo_find_predictor.c", + "silk/stereo_quant_pred.c", ] opus_sources_silk = [] - if("opus_fixed_point" in env and env.opus_fixed_point == "yes"): + if env["platform"] in ["android", "iphone", "javascript"]: env_opus.Append(CFLAGS=["-DFIXED_POINT"]) opus_sources_silk = [ - "silk/fixed/schur64_FIX.c", - "silk/fixed/residual_energy16_FIX.c", + "silk/fixed/LTP_analysis_filter_FIX.c", + "silk/fixed/LTP_scale_ctrl_FIX.c", + "silk/fixed/corrMatrix_FIX.c", "silk/fixed/encode_frame_FIX.c", - "silk/fixed/regularize_correlations_FIX.c", - "silk/fixed/apply_sine_window_FIX.c", - "silk/fixed/solve_LS_FIX.c", - "silk/fixed/schur_FIX.c", - "silk/fixed/pitch_analysis_core_FIX.c", - "silk/fixed/noise_shape_analysis_FIX.c", + "silk/fixed/find_LPC_FIX.c", "silk/fixed/find_LTP_FIX.c", - "silk/fixed/vector_ops_FIX.c", - "silk/fixed/autocorr_FIX.c", - "silk/fixed/warped_autocorrelation_FIX.c", "silk/fixed/find_pitch_lags_FIX.c", - "silk/fixed/k2a_Q16_FIX.c", - "silk/fixed/LTP_scale_ctrl_FIX.c", - "silk/fixed/corrMatrix_FIX.c", + "silk/fixed/find_pred_coefs_FIX.c", + "silk/fixed/noise_shape_analysis_FIX.c", "silk/fixed/prefilter_FIX.c", - "silk/fixed/find_LPC_FIX.c", - "silk/fixed/residual_energy_FIX.c", "silk/fixed/process_gains_FIX.c", - "silk/fixed/LTP_analysis_filter_FIX.c", - "silk/fixed/k2a_FIX.c", + "silk/fixed/regularize_correlations_FIX.c", + "silk/fixed/residual_energy16_FIX.c", + "silk/fixed/residual_energy_FIX.c", + "silk/fixed/solve_LS_FIX.c", + "silk/fixed/warped_autocorrelation_FIX.c", + "silk/fixed/apply_sine_window_FIX.c", + "silk/fixed/autocorr_FIX.c", "silk/fixed/burg_modified_FIX.c", - "silk/fixed/find_pred_coefs_FIX.c" + "silk/fixed/k2a_FIX.c", + "silk/fixed/k2a_Q16_FIX.c", + "silk/fixed/pitch_analysis_core_FIX.c", + "silk/fixed/vector_ops_FIX.c", + "silk/fixed/schur64_FIX.c", + "silk/fixed/schur_FIX.c", ] else: opus_sources_silk = [ - "silk/float/LTP_scale_ctrl_FLP.c", - "silk/float/regularize_correlations_FLP.c", + "silk/float/apply_sine_window_FLP.c", "silk/float/corrMatrix_FLP.c", + "silk/float/encode_frame_FLP.c", + "silk/float/find_LPC_FLP.c", + "silk/float/find_LTP_FLP.c", + "silk/float/find_pitch_lags_FLP.c", + "silk/float/find_pred_coefs_FLP.c", "silk/float/LPC_analysis_filter_FLP.c", - "silk/float/levinsondurbin_FLP.c", - "silk/float/schur_FLP.c", - "silk/float/scale_vector_FLP.c", - "silk/float/apply_sine_window_FLP.c", - "silk/float/pitch_analysis_core_FLP.c", - "silk/float/wrappers_FLP.c", - "silk/float/bwexpander_FLP.c", - "silk/float/warped_autocorrelation_FLP.c", + "silk/float/LTP_analysis_filter_FLP.c", + "silk/float/LTP_scale_ctrl_FLP.c", + "silk/float/noise_shape_analysis_FLP.c", + "silk/float/prefilter_FLP.c", + "silk/float/process_gains_FLP.c", + "silk/float/regularize_correlations_FLP.c", + "silk/float/residual_energy_FLP.c", "silk/float/solve_LS_FLP.c", - "silk/float/find_LPC_FLP.c", + "silk/float/warped_autocorrelation_FLP.c", + "silk/float/wrappers_FLP.c", "silk/float/autocorrelation_FLP.c", - "silk/float/find_pred_coefs_FLP.c", - "silk/float/find_pitch_lags_FLP.c", "silk/float/burg_modified_FLP.c", - "silk/float/find_LTP_FLP.c", + "silk/float/bwexpander_FLP.c", "silk/float/energy_FLP.c", - "silk/float/sort_FLP.c", - "silk/float/LPC_inv_pred_gain_FLP.c", - "silk/float/k2a_FLP.c", - "silk/float/noise_shape_analysis_FLP.c", "silk/float/inner_product_FLP.c", - "silk/float/process_gains_FLP.c", - "silk/float/encode_frame_FLP.c", + "silk/float/k2a_FLP.c", + "silk/float/levinsondurbin_FLP.c", + "silk/float/LPC_inv_pred_gain_FLP.c", + "silk/float/pitch_analysis_core_FLP.c", "silk/float/scale_copy_vector_FLP.c", - "silk/float/residual_energy_FLP.c", - "silk/float/LTP_analysis_filter_FLP.c", - "silk/float/prefilter_FLP.c" + "silk/float/scale_vector_FLP.c", + "silk/float/schur_FLP.c", + "silk/float/sort_FLP.c", ] thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources + opus_sources_silk] @@ -213,6 +220,12 @@ if env['builtin_opus']: ] env_opus.Append(CPPPATH=[thirdparty_dir + "/" + dir for dir in thirdparty_include_paths]) + if env["platform"] == "android" or env["platform"] == "iphone": + if ("arch" in env and env["arch"] == "arm") or ("android_arch" in env and env["android_arch"] in ["armv6", "armv7"]): + env_opus.Append(CFLAGS=["-DOPUS_ARM_OPT"]) + elif ("arch" in env and env["arch"] == "arm64") or ("android_arch" in env and env["android_arch"] == "arm64v8"): + env_opus.Append(CFLAGS=["-DOPUS_ARM64_OPT"]) + env_thirdparty = env_opus.Clone() env_thirdparty.disable_warnings() env_thirdparty.add_source_files(env.modules_sources, thirdparty_sources) |