diff options
374 files changed, 15124 insertions, 7216 deletions
diff --git a/core/translation.cpp b/core/translation.cpp index e4dad8d8de..85e207e08d 100644 --- a/core/translation.cpp +++ b/core/translation.cpp @@ -665,6 +665,22 @@ void TranslationServer::setup() { } +void TranslationServer::set_tool_translation(const Ref<Translation>& p_translation) { + tool_translation=p_translation; +} + +StringName TranslationServer::tool_translate(const StringName& p_message) const { + + if (tool_translation.is_valid()) { + StringName r = tool_translation->tr(p_message); + if (r) + return r; + } + + return p_message; +} + + void TranslationServer::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_locale","locale"),&TranslationServer::set_locale); diff --git a/core/translation.h b/core/translation.h index 5be6b8913a..cdb22bfeca 100644 --- a/core/translation.h +++ b/core/translation.h @@ -75,6 +75,7 @@ class TranslationServer : public Object { Set< Ref<Translation> > translations; + Ref<Translation> tool_translation; bool enabled; @@ -102,6 +103,9 @@ public: static Vector<String> get_all_locales(); static Vector<String> get_all_locale_names(); + void set_tool_translation(const Ref<Translation>& p_translation); + StringName tool_translate(const StringName& p_message) const; + void setup(); void clear(); diff --git a/core/ustring.cpp b/core/ustring.cpp index a9d0012ebe..573c362389 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -3955,3 +3955,14 @@ String String::sprintf(const Array& values, bool* error) const { *error = false; return formatted; } + +#include "translation.h" + +String TTR(const String& p_text) { + + if (TranslationServer::get_singleton()) { + return TranslationServer::get_singleton()->translate(p_text); + } + + return p_text; +} diff --git a/core/ustring.h b/core/ustring.h index 6310d0a854..ec0932e54d 100644 --- a/core/ustring.h +++ b/core/ustring.h @@ -256,5 +256,7 @@ struct NoCaseComparator { /* end of namespace */ +//tool translate +String TTR(const String&); #endif diff --git a/doc/base/classes.xml b/doc/base/classes.xml index dd0b729286..cba5425d3f 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -2735,14 +2735,14 @@ <argument index="1" name="custom_blend" type="float" default="-1"> </argument> <description> - Play a given animation by the animation name in reverse. + Play a given animation by the animation name in reverse. </description> </method> <method name="stop"> <argument index="0" name="reset" type="bool" default="true"> </argument> <description> - Stop the currently playing animation. + Stop the currently playing animation. </description> </method> <method name="stop_all"> @@ -2902,7 +2902,7 @@ <argument index="0" name="delta" type="float"> </argument> <description> - Used to skip ahead or skip back in an animation. Delta is the time in seconds to skip. + Used to skip ahead or skip back in an animation. Delta is the time in seconds to skip. </description> </method> </methods> @@ -2911,7 +2911,7 @@ <argument index="0" name="name" type="String"> </argument> <description> - Notifies when an animation starts playing. + Notifies when an animation starts playing. </description> </signal> <signal name="animation_changed"> @@ -8292,10 +8292,10 @@ </class> <class name="ColorRamp" inherits="Resource" category="Core"> <brief_description> - Color interpolator node + Color interpolator node </brief_description> <description> - Given a set of colors, this node will interpolate them in order, meaning, that if you have color 1, color 2 and color3, the ramp will interpolate (generate the colors between two colors) from color 1 to color 2 and from color 2 to color 3. Initially the ramp will have 2 colors (black and white), one (black) at ramp lower offset offset 0 and the other (white) at the ramp higher offset 1. + Given a set of colors, this node will interpolate them in order, meaning, that if you have color 1, color 2 and color3, the ramp will interpolate (generate the colors between two colors) from color 1 to color 2 and from color 2 to color 3. Initially the ramp will have 2 colors (black and white), one (black) at ramp lower offset offset 0 and the other (white) at the ramp higher offset 1. </description> <methods> <method name="add_point"> @@ -8304,14 +8304,14 @@ <argument index="1" name="color" type="Color"> </argument> <description> - Adds the specified color to the end of the ramp, with the specified offset + Adds the specified color to the end of the ramp, with the specified offset </description> </method> <method name="remove_point"> <argument index="0" name="offset" type="int"> </argument> <description> - Removes the color at the index [i]offset[/i] + Removes the color at the index [i]offset[/i] </description> </method> <method name="set_offset"> @@ -8320,7 +8320,7 @@ <argument index="1" name="offset" type="float"> </argument> <description> - Sets the offset for the ramp color at index [i]point[/i] + Sets the offset for the ramp color at index [i]point[/i] </description> </method> <method name="get_offset" qualifiers="const"> @@ -8329,7 +8329,7 @@ <argument index="0" name="point" type="int"> </argument> <description> - Returns the offset of the ramp color at index [i]point[/i] + Returns the offset of the ramp color at index [i]point[/i] </description> </method> <method name="set_color"> @@ -8338,7 +8338,7 @@ <argument index="1" name="color" type="Color"> </argument> <description> - Sets the color of the ramp color at index [i]point[/i] + Sets the color of the ramp color at index [i]point[/i] </description> </method> <method name="get_color" qualifiers="const"> @@ -8347,7 +8347,7 @@ <argument index="0" name="point" type="int"> </argument> <description> - Returns the color of the ramp color at index [i]point[/i] + Returns the color of the ramp color at index [i]point[/i] </description> </method> <method name="interpolate"> @@ -8356,42 +8356,42 @@ <argument index="0" name="offset" type="float"> </argument> <description> - Returns the interpolated color specified by [i]offset[/i] + Returns the interpolated color specified by [i]offset[/i] </description> </method> <method name="get_point_count" qualifiers="const"> <return type="int"> </return> <description> - Returns the number of colors in the ramp + Returns the number of colors in the ramp </description> </method> <method name="set_offsets"> <argument index="0" name="offsets" type="RealArray"> </argument> <description> - Sets the offset for the specified amount of elements. Calling this function with a different number of elements than previously defined causes the ramp to resize its colors and offsets array to accomodate the new elements, all new colors will be black by default. + Sets the offset for the specified amount of elements. Calling this function with a different number of elements than previously defined causes the ramp to resize its colors and offsets array to accomodate the new elements, all new colors will be black by default. </description> </method> <method name="get_offsets" qualifiers="const"> <return type="RealArray"> </return> <description> - Returns the offsets for the colors in this ramp + Returns the offsets for the colors in this ramp </description> </method> <method name="set_colors"> <argument index="0" name="colors" type="ColorArray"> </argument> <description> - Sets the colors for the specified amount of elements. Calling this function with a different number of elements than previously defined causes the ramp to resize its colors and offsets array to accomodate the new elements. + Sets the colors for the specified amount of elements. Calling this function with a different number of elements than previously defined causes the ramp to resize its colors and offsets array to accomodate the new elements. </description> </method> <method name="get_colors" qualifiers="const"> <return type="ColorArray"> </return> <description> - Returns the colors in the ramp + Returns the colors in the ramp </description> </method> </methods> @@ -10221,6 +10221,50 @@ Returns an empty String "" at the end of the list. <constants> </constants> </class> +<class name="DynamicFont" inherits="Font" category="Core"> + <brief_description> + </brief_description> + <description> + </description> + <methods> + <method name="set_font_data"> + <argument index="0" name="data" type="DynamicFontData"> + </argument> + <description> + </description> + </method> + <method name="get_font_data" qualifiers="const"> + <return type="DynamicFontData"> + </return> + <description> + </description> + </method> + <method name="set_size"> + <argument index="0" name="data" type="int"> + </argument> + <description> + </description> + </method> + <method name="get_size" qualifiers="const"> + <return type="int"> + </return> + <description> + </description> + </method> + </methods> + <constants> + </constants> +</class> +<class name="DynamicFontData" inherits="Resource" category="Core"> + <brief_description> + </brief_description> + <description> + </description> + <methods> + </methods> + <constants> + </constants> +</class> <class name="EditorExportPlugin" inherits="Reference" category="Core"> <brief_description> Editor plugin to control the export process. @@ -14987,8 +15031,10 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) </class> <class name="Input" inherits="Object" category="Core"> <brief_description> + A Singleton that deals with inputs. </brief_description> <description> + A Singleton that deals with inputs. This includes key presses, mouse buttons and movement, joysticks, and input actions. </description> <methods> <method name="is_key_pressed"> @@ -14997,6 +15043,7 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) <argument index="0" name="scancode" type="int"> </argument> <description> + Returns true or false depending on whether the key is pressed or not. You can pass KEY_*, which are pre-defined constants listed in [@Global Scope]. </description> </method> <method name="is_mouse_button_pressed"> @@ -15025,6 +15072,7 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) <argument index="0" name="action" type="String"> </argument> <description> + Returns true or false depending on whether the action event is pressed. Actions and their events can be set in the Project Settings / Input Map tab. Or be set with [InputMap]. </description> </method> <method name="add_joy_mapping"> @@ -15085,48 +15133,56 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) <return type="Vector3"> </return> <description> + If the device has an accelerometer, this will return the movement. </description> </method> <method name="get_mouse_speed" qualifiers="const"> <return type="Vector2"> </return> <description> + Returns the mouse speed. </description> </method> <method name="get_mouse_button_mask" qualifiers="const"> <return type="int"> </return> <description> + Returns mouse buttons as a bitmask. If multiple mouse buttons are pressed at the same time the bits are added together. </description> </method> <method name="set_mouse_mode"> <argument index="0" name="mode" type="int"> </argument> <description> + Set the mouse mode. See the constants for more information. </description> </method> <method name="get_mouse_mode" qualifiers="const"> <return type="int"> </return> <description> + Return the mouse mode. See the constants for more information. </description> </method> <method name="warp_mouse_pos"> <argument index="0" name="to" type="Vector2"> </argument> <description> + Sets the mouse position to the specified vector. </description> </method> <method name="action_press"> <argument index="0" name="action" type="String"> </argument> <description> + This will simulate pressing the specificed action. </description> </method> <method name="action_release"> <argument index="0" name="action" type="String"> </argument> <description> + If the specified action is already pressed, this will release it. </description> </method> <method name="set_custom_mouse_cursor"> @@ -15135,6 +15191,7 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) <argument index="1" name="hotspot" type="Vector2" default="Vector2(0,0)"> </argument> <description> + Set a custom mouse cursor image, which is only visible inside the game window. The hotspot can also be specified. </description> </method> </methods> @@ -15151,10 +15208,13 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) </signals> <constants> <constant name="MOUSE_MODE_VISIBLE" value="0"> + Makes the mouse cursor visible if it is hidden. </constant> <constant name="MOUSE_MODE_HIDDEN" value="1"> + Makes the mouse cursor hidden if it is visible. </constant> <constant name="MOUSE_MODE_CAPTURED" value="2"> + Captures the mouse. The mouse will be hidden and unable to leave the game window. But it will still register movement and mouse button presses. </constant> </constants> </class> @@ -23011,66 +23071,66 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) </class> <class name="Particles2D" inherits="Node2D" category="Core"> <brief_description> - 2D Particle emitter + 2D Particle emitter </brief_description> <description> - Particles2D is a particle system 2D [Node] that is used to simulate several types of particle effects, such as explosions, rain, snow, fireflies, or other magical-like shinny sparkles. Particles are drawn using impostors, and given their dynamic behavior, the user must provide a visibility AABB (although helpers to create one automatically exist). + Particles2D is a particle system 2D [Node] that is used to simulate several types of particle effects, such as explosions, rain, snow, fireflies, or other magical-like shinny sparkles. Particles are drawn using impostors, and given their dynamic behavior, the user must provide a visibility AABB (although helpers to create one automatically exist). </description> <methods> <method name="set_emitting"> <argument index="0" name="active" type="bool"> </argument> <description> - If this is set to true then the particle emitter will emit particles, if its false it will not. + If this is set to true then the particle emitter will emit particles, if its false it will not. </description> </method> <method name="is_emitting" qualifiers="const"> <return type="bool"> </return> <description> - Returns whether this emitter is currently emitting or not + Returns whether this emitter is currently emitting or not </description> </method> <method name="set_amount"> <argument index="0" name="amount" type="int"> </argument> <description> - Sets the amount of particles spawned at each emission + Sets the amount of particles spawned at each emission </description> </method> <method name="get_amount" qualifiers="const"> <return type="int"> </return> <description> - Returns the amount of particles spawned at each emission + Returns the amount of particles spawned at each emission </description> </method> <method name="set_lifetime"> <argument index="0" name="lifetime" type="float"> </argument> <description> - Sets the amount of seconds that each particle will be visible. + Sets the amount of seconds that each particle will be visible. </description> </method> <method name="get_lifetime" qualifiers="const"> <return type="float"> </return> <description> - Gets the amount of seconds that each particle will be visible. + Gets the amount of seconds that each particle will be visible. </description> </method> <method name="set_time_scale"> <argument index="0" name="time_scale" type="float"> </argument> <description> - Sets the increment or decrement for the particle lifetime. for example: if the time scale is set to 2, the particles will die and move twice as fast. + Sets the increment or decrement for the particle lifetime. for example: if the time scale is set to 2, the particles will die and move twice as fast. </description> </method> <method name="get_time_scale" qualifiers="const"> <return type="float"> </return> <description> - Returns the emitter time scale + Returns the emitter time scale </description> </method> <method name="set_pre_process_time"> @@ -23089,14 +23149,14 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) <argument index="0" name="value" type="float"> </argument> <description> - Sets the amount of seconds during which the emitter will spawn particles, after the specified seconds the emitter state will be set to non emitting, so calling [method is_emitting] will return false. If the timeout is 0 the emitter will spawn forever. + Sets the amount of seconds during which the emitter will spawn particles, after the specified seconds the emitter state will be set to non emitting, so calling [method is_emitting] will return false. If the timeout is 0 the emitter will spawn forever. </description> </method> <method name="get_emit_timeout" qualifiers="const"> <return type="float"> </return> <description> - Returns the amount of seconds during which the emitter will spawn particles + Returns the amount of seconds during which the emitter will spawn particles </description> </method> <method name="set_param"> @@ -23105,7 +23165,7 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) <argument index="1" name="value" type="float"> </argument> <description> - Sets the value of the specified emitter parameter (see the constants secction for the list of parameters) + Sets the value of the specified emitter parameter (see the constants secction for the list of parameters) </description> </method> <method name="get_param" qualifiers="const"> @@ -23114,7 +23174,7 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) <argument index="0" name="param" type="int"> </argument> <description> - Returns the value of the specified emitter parameter + Returns the value of the specified emitter parameter </description> </method> <method name="set_randomness"> @@ -23123,7 +23183,7 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) <argument index="1" name="value" type="float"> </argument> <description> - Sets the randomness value of the specified emitter parameter (see the constants secction for the list of parameters), 0 means no randomness, so every particle will have the parameters specified, 1 means that the parameter will be choosen at random, the closer the randomness value gets to 0 the more conservative the variation of the parameter will be. + Sets the randomness value of the specified emitter parameter (see the constants secction for the list of parameters), 0 means no randomness, so every particle will have the parameters specified, 1 means that the parameter will be choosen at random, the closer the randomness value gets to 0 the more conservative the variation of the parameter will be. </description> </method> <method name="get_randomness" qualifiers="const"> @@ -23132,7 +23192,7 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) <argument index="0" name="param" type="int"> </argument> <description> - Returns the randomness value of the specified emitter parameter + Returns the randomness value of the specified emitter parameter </description> </method> <method name="set_texture"> @@ -23141,28 +23201,28 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) <argument index="0" name="texture" type="Object"> </argument> <description> - Sets the texture for each particle + Sets the texture for each particle </description> </method> <method name="get_texture" qualifiers="const"> <return type="Texture"> </return> <description> - Returns the texture for emitted particles + Returns the texture for emitted particles </description> </method> <method name="set_color"> <argument index="0" name="color" type="Color"> </argument> <description> - Set the tint color for each particle. + Set the tint color for each particle. </description> </method> <method name="get_color" qualifiers="const"> <return type="Color"> </return> <description> - Returns the tint color for each particle. + Returns the tint color for each particle. </description> </method> <method name="set_color_ramp"> @@ -23171,28 +23231,28 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) <argument index="0" name="color_ramp" type="Object"> </argument> <description> - Sets the [ColorRamp] used to tint each particle. Particle will be tinted according to their lifetimes. + Sets the [ColorRamp] used to tint each particle. Particle will be tinted according to their lifetimes. </description> </method> <method name="get_color_ramp" qualifiers="const"> <return type="ColorRamp"> </return> <description> - Returns the [ColorRamp] used to tint each particle + Returns the [ColorRamp] used to tint each particle </description> </method> <method name="set_emissor_offset"> <argument index="0" name="offset" type="Vector2"> </argument> <description> - Sets the particle spawn origin position relative to the emitter center. for example if this value is set to (50, 50), the particle will spawn 50 units to the right and 50 units to the bottom of the emitter center. + Sets the particle spawn origin position relative to the emitter center. for example if this value is set to (50, 50), the particle will spawn 50 units to the right and 50 units to the bottom of the emitter center. </description> </method> <method name="get_emissor_offset" qualifiers="const"> <return type="Vector2"> </return> <description> - Returns the particle spawn origin position relative to the emitter. + Returns the particle spawn origin position relative to the emitter. </description> </method> <method name="set_flip_h"> @@ -23247,14 +23307,14 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) <argument index="0" name="extents" type="Vector2"> </argument> <description> - Sets the half extents of the emission box, particles will be spawned at random inside this box. + Sets the half extents of the emission box, particles will be spawned at random inside this box. </description> </method> <method name="get_emission_half_extents" qualifiers="const"> <return type="Vector2"> </return> <description> - Returns the half extents of the emission box. + Returns the half extents of the emission box. </description> </method> <method name="set_color_phases"> @@ -23362,7 +23422,7 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) </methods> <constants> <constant name="PARAM_DIRECTION" value="0"> - Direction in degrees at which the particles will be launched, Notice that when the direction is set to 0 the particles will be launched to the negative + Direction in degrees at which the particles will be launched, Notice that when the direction is set to 0 the particles will be launched to the negative </constant> <constant name="PARAM_SPREAD" value="1"> </constant> @@ -38539,7 +38599,7 @@ This method controls whether the position between two cached points is interpola </class> <class name="Timer" inherits="Node" category="Core"> <brief_description> - A simple Timer node. + A simple Timer node. </brief_description> <description> Timer node. This is a simple node that will emit a timeout callback when the timer runs out. It can optionally be set to loop. @@ -38601,14 +38661,14 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="active" type="bool"> </argument> <description> - Set whether the timer is active or not. An inactive timer will be paused until it is activated again. + Set whether the timer is active or not. An inactive timer will be paused until it is activated again. </description> </method> <method name="is_active" qualifiers="const"> <return type="bool"> </return> <description> - Return if the timer is active or not. + Return if the timer is active or not. </description> </method> <method name="get_time_left" qualifiers="const"> @@ -43891,24 +43951,24 @@ This method controls whether the position between two cached points is interpola </class> <class name="YSort" inherits="Node2D" category="Core"> <brief_description> - Sort all child nodes based on their Y positions. + Sort all child nodes based on their Y positions. </brief_description> <description> - Sort all child nodes based on their Y positions. The child node must inherit from [CanvasItem] for it to be sorted. Nodes that have a higher Y position will be drawn later, so they will appear on top of nodes that have a lower Y position. + Sort all child nodes based on their Y positions. The child node must inherit from [CanvasItem] for it to be sorted. Nodes that have a higher Y position will be drawn later, so they will appear on top of nodes that have a lower Y position. </description> <methods> <method name="set_sort_enabled"> <argument index="0" name="enabled" type="bool"> </argument> <description> - Set whether the children nodes are sorted or not. (default true) + Set whether the children nodes are sorted or not. (default true) </description> </method> <method name="is_sort_enabled" qualifiers="const"> <return type="bool"> </return> <description> - Returns true if the children nodes are being sorted. + Returns true if the children nodes are being sorted. </description> </method> </methods> @@ -43929,7 +43989,7 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="from" type="int"> </argument> <description> - Cast an [int] value to a boolean value, this method will return true if called with an integer value different to 0 and false in other case. + Cast an [int] value to a boolean value, this method will return true if called with an integer value different to 0 and false in other case. </description> </method> <method name="bool"> @@ -43938,7 +43998,7 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="from" type="float"> </argument> <description> - Cast a [float] value to a boolean value, this method will return true if called with a floating point value different to 0 and false in other case. + Cast a [float] value to a boolean value, this method will return true if called with a floating point value different to 0 and false in other case. </description> </method> <method name="bool"> @@ -43947,7 +44007,7 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="from" type="String"> </argument> <description> - Cast a [String] value to a boolean value, this method will return true if called with a non empty string and false in other case. Examples: [code]bool('False')[/code] returns true, [code]bool('')[/code]. returns false + Cast a [String] value to a boolean value, this method will return true if called with a non empty string and false in other case. Examples: [code]bool('False')[/code] returns true, [code]bool('')[/code]. returns false </description> </method> </methods> @@ -43956,10 +44016,10 @@ This method controls whether the position between two cached points is interpola </class> <class name="float" category="Built-In Types"> <brief_description> - Float built-in type + Float built-in type </brief_description> <description> - Float built-in type. + Float built-in type. </description> <methods> <method name="float"> @@ -43968,7 +44028,7 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="from" type="bool"> </argument> <description> - Cast a [bool] value to a floating point value, [code]float(true)[/code] will be equals to 1.0 and [code]float(false)[/code] will be equals to 0.0. + Cast a [bool] value to a floating point value, [code]float(true)[/code] will be equals to 1.0 and [code]float(false)[/code] will be equals to 0.0. </description> </method> <method name="float"> @@ -43977,7 +44037,7 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="from" type="int"> </argument> <description> - Cast an [int] value to a floating point value, [code]float(1)[/code] will be equals to 1.0. + Cast an [int] value to a floating point value, [code]float(1)[/code] will be equals to 1.0. </description> </method> <method name="float"> @@ -43986,7 +44046,7 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="from" type="String"> </argument> <description> - Cast a [String] value to a floating point value. This method accepts float value strings like [code] '1.23' [/code] and exponential notation strings for its parameter so calling [code] float('1e3') [/code] will return 1000.0 and calling [code] float('1e-3') [/code] will return -0.001. + Cast a [String] value to a floating point value. This method accepts float value strings like [code] '1.23' [/code] and exponential notation strings for its parameter so calling [code] float('1e3') [/code] will return 1000.0 and calling [code] float('1e-3') [/code] will return -0.001. </description> </method> </methods> @@ -44007,7 +44067,7 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="from" type="bool"> </argument> <description> - Cast a [bool] value to an integer value, [code]int(true)[/code] will be equals to 1 and [code]int(false)[/code] will be equals to 0. + Cast a [bool] value to an integer value, [code]int(true)[/code] will be equals to 1 and [code]int(false)[/code] will be equals to 0. </description> </method> <method name="int"> @@ -44016,7 +44076,7 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="from" type="float"> </argument> <description> - Cast a float value to an integer value, this method simply removes the number fractions, so for example [code]int(2.7)[/code] will be equals to 2, [code]int(.1)[/code] will be equals to 0 and [code]int(-2.7)[/code] will be equals to -2. + Cast a float value to an integer value, this method simply removes the number fractions, so for example [code]int(2.7)[/code] will be equals to 2, [code]int(.1)[/code] will be equals to 0 and [code]int(-2.7)[/code] will be equals to -2. </description> </method> <method name="int"> @@ -44025,7 +44085,7 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="from" type="String"> </argument> <description> - Cast a [String] value to an integer value, this method is an integer parser from a string, so calling this method with an invalid integer string will return 0, a valid string will be something like [code]'1.7'[/code]. This method will ignore all non-number characters, so calling [code]int('1e3')[/code] will return 13. + Cast a [String] value to an integer value, this method is an integer parser from a string, so calling this method with an invalid integer string will return 0, a valid string will be something like [code]'1.7'[/code]. This method will ignore all non-number characters, so calling [code]int('1e3')[/code] will return 13. </description> </method> </methods> diff --git a/drivers/opus/SCsub b/drivers/opus/SCsub index 59c746209b..0e94c7aeda 100644 --- a/drivers/opus/SCsub +++ b/drivers/opus/SCsub @@ -7,188 +7,190 @@ opus_sources = [ opus_sources_silk=[] opus_sources_lib = [ - "opus/celt/bands.c", - "opus/celt/celt_lpc.c", - "opus/celt/entenc.c", - "opus/celt/mdct.c", - "opus/celt/quant_bands.c", - "opus/celt/celt.c", - "opus/celt/cwrs.c", - "opus/celt/kiss_fft.c", - "opus/celt/modes.c", - "opus/celt/rate.c", - "opus/celt/celt_decoder.c", - "opus/celt/entcode.c", - "opus/celt/laplace.c", - #opus/celt/opus_custom_demo.c", - "opus/celt/vq.c", - "opus/celt/celt_encoder.c", - "opus/celt/entdec.c", - "opus/celt/mathops.c", - "opus/celt/pitch.c", - "opus/silk/A2NLSF.c", - "opus/silk/decoder_set_fs.c", + "opus/silk/tables_other.c", + "opus/silk/sum_sqr_shift.c", + "opus/silk/PLC.c", + "opus/silk/dec_API.c", + "opus/silk/decode_pulses.c", + "opus/silk/inner_prod_aligned.c", + "opus/silk/init_encoder.c", + "opus/silk/interpolate.c", + "opus/silk/stereo_encode_pred.c", + "opus/silk/decode_frame.c", + "opus/silk/NLSF_del_dec_quant.c", + "opus/silk/VAD.c", + "opus/silk/resampler_private_AR2.c", + "opus/silk/NLSF_unpack.c", + "opus/silk/resampler_down2.c", + "opus/silk/sort.c", + "opus/silk/resampler_private_IIR_FIR.c", + "opus/silk/resampler_down2_3.c", + "opus/silk/resampler_private_up2_HQ.c", + "opus/silk/tables_gain.c", + "opus/silk/stereo_find_predictor.c", + "opus/silk/stereo_quant_pred.c", "opus/silk/NLSF_stabilize.c", - "opus/silk/sigm_Q15.c", "opus/silk/ana_filt_bank_1.c", + "opus/silk/check_control_input.c", + "opus/silk/bwexpander.c", + "opus/silk/A2NLSF.c", + "opus/silk/LPC_inv_pred_gain.c", + "opus/silk/log2lin.c", + "opus/silk/process_NLSFs.c", + "opus/silk/sigm_Q15.c", + "opus/silk/VQ_WMat_EC.c", + "opus/silk/quant_LTP_gains.c", + "opus/silk/resampler_private_down_FIR.c", + "opus/silk/NLSF_decode.c", + "opus/silk/control_codec.c", + "opus/silk/NLSF_VQ_weights_laroia.c", + "opus/silk/decode_pitch.c", + "opus/silk/stereo_decode_pred.c", + "opus/silk/tables_pulses_per_block.c", + "opus/silk/init_decoder.c", + "opus/silk/table_LSF_cos.c", + "opus/silk/decode_core.c", + "opus/silk/code_signs.c", "opus/silk/enc_API.c", - "opus/silk/NLSF_unpack.c", - "opus/silk/sort.c", + "opus/silk/tables_LTP.c", + "opus/silk/pitch_est_tables.c", "opus/silk/biquad_alt.c", "opus/silk/encode_indices.c", + "opus/silk/tables_NLSF_CB_WB.c", + "opus/silk/debug.c", + "opus/silk/decode_parameters.c", + "opus/silk/tables_pitch_lag.c", + "opus/silk/NLSF2A.c", + "opus/silk/resampler.c", + "opus/silk/decode_indices.c", "opus/silk/NLSF_VQ.c", - "opus/silk/stereo_decode_pred.c", "opus/silk/bwexpander_32.c", + "opus/silk/tables_NLSF_CB_NB_MB.c", "opus/silk/encode_pulses.c", - "opus/silk/NLSF_VQ_weights_laroia.c", - "opus/silk/stereo_encode_pred.c", - "opus/silk/bwexpander.c", - "opus/silk/gain_quant.c", - "opus/silk/NSQ.c", - "opus/silk/stereo_find_predictor.c", - "opus/silk/check_control_input.c", - "opus/silk/HP_variable_cutoff.c", "opus/silk/NSQ_del_dec.c", + "opus/silk/control_SNR.c", + "opus/silk/shell_coder.c", + "opus/silk/NLSF_encode.c", + "opus/silk/stereo_MS_to_LR.c", "opus/silk/stereo_LR_to_MS.c", + "opus/silk/HP_variable_cutoff.c", + "opus/silk/LPC_analysis_filter.c", "opus/silk/CNG.c", - "opus/silk/init_decoder.c", - "opus/silk/pitch_est_tables.c", - "opus/silk/stereo_MS_to_LR.c", - "opus/silk/code_signs.c", - "opus/silk/init_encoder.c", - "opus/silk/PLC.c", - "opus/silk/stereo_quant_pred.c", + "opus/silk/decoder_set_fs.c", + "opus/silk/resampler_rom.c", "opus/silk/control_audio_bandwidth.c", - "opus/silk/inner_prod_aligned.c", - "opus/silk/process_NLSFs.c", - "opus/silk/sum_sqr_shift.c", - "opus/silk/control_codec.c", - "opus/silk/interpolate.c", - "opus/silk/quant_LTP_gains.c", - "opus/silk/table_LSF_cos.c", - "opus/silk/control_SNR.c", "opus/silk/lin2log.c", - "opus/silk/resampler.c", - "opus/silk/tables_gain.c", - "opus/silk/debug.c", - "opus/silk/log2lin.c", - "opus/silk/resampler_down2_3.c", - "opus/silk/tables_LTP.c", - "opus/silk/dec_API.c", - "opus/silk/LPC_analysis_filter.c", - "opus/silk/resampler_down2.c", - "opus/silk/tables_NLSF_CB_NB_MB.c", - "opus/silk/decode_core.c", - "opus/silk/LPC_inv_pred_gain.c", - "opus/silk/resampler_private_AR2.c", - "opus/silk/tables_NLSF_CB_WB.c", - "opus/silk/decode_frame.c", "opus/silk/LP_variable_cutoff.c", - "opus/silk/resampler_private_down_FIR.c", - "opus/silk/tables_other.c", - "opus/silk/decode_indices.c", - "opus/silk/NLSF2A.c", - "opus/silk/resampler_private_IIR_FIR.c", - "opus/silk/tables_pitch_lag.c", - "opus/silk/decode_parameters.c", - "opus/silk/NLSF_decode.c", - "opus/silk/resampler_private_up2_HQ.c", - "opus/silk/tables_pulses_per_block.c", - "opus/silk/decode_pitch.c", - "opus/silk/NLSF_del_dec_quant.c", - "opus/silk/resampler_rom.c", - "opus/silk/VAD.c", - "opus/silk/decode_pulses.c", - "opus/silk/NLSF_encode.c", - "opus/silk/shell_coder.c", - "opus/silk/VQ_WMat_EC.c", - "opus/analysis.c", - "opus/internal.c", - "opus/opus.c", - #"opus/opus_demo.c", - "opus/opus_multistream.c", + "opus/silk/NSQ.c", + "opus/silk/gain_quant.c", + "opus/celt/laplace.c", + "opus/celt/vq.c", + "opus/celt/quant_bands.c", + "opus/celt/kiss_fft.c", + "opus/celt/entcode.c", + "opus/celt/entenc.c", + "opus/celt/celt_lpc.c", + "opus/celt/pitch.c", + "opus/celt/rate.c", + "opus/celt/mathops.c", + #"opus/celt/arm/armcpu.c", + #"opus/celt/arm/celt_neon_intr.c", + #"opus/celt/arm/celt_ne10_mdct.c", + #"opus/celt/arm/celt_ne10_fft.c", + #"opus/celt/arm/arm_celt_map.c", + "opus/celt/celt_encoder.c", + "opus/celt/celt.c", + "opus/celt/bands.c", + "opus/celt/cwrs.c", + "opus/celt/entdec.c", + "opus/celt/celt_decoder.c", + "opus/celt/mdct.c", + "opus/celt/modes.c", "opus/repacketizer.c", - "opus/wincerts.c", - "opus/http.c", - "opus/mlp.c", - #"opus/opus_compare.c", + "opus/mlp_data.c", + "opus/opus_multistream.c", + "opus/opusfile.c", "opus/opus_encoder.c", - "opus/opus_multistream_decoder.c", - #"opus/repacketizer_demo.c", + "opus/analysis.c", + "opus/mlp.c", "opus/info.c", - "opus/mlp_data.c", + "opus/stream.c", "opus/opus_decoder.c", - "opus/opusfile.c", + "opus/opus_compare.c", + "opus/internal.c", + "opus/wincerts.c", + "opus/opus.c", "opus/opus_multistream_encoder.c", - "opus/stream.c" + "opus/http.c", + "opus/opus_multistream_decoder.c" ] if("opus_fixed_point" in env and env.opus_fixed_point=="yes"): env.Append(CFLAGS=["-DOPUS_FIXED_POINT"]) opus_sources_silk = [ - "opus/silk/fixed/apply_sine_window_FIX.c", - "opus/silk/fixed/k2a_FIX.c", - "opus/silk/fixed/residual_energy16_FIX.c", - "opus/silk/fixed/autocorr_FIX.c", - "opus/silk/fixed/k2a_Q16_FIX.c", - "opus/silk/fixed/residual_energy_FIX.c", - "opus/silk/fixed/burg_modified_FIX.c", - "opus/silk/fixed/LTP_analysis_filter_FIX.c", "opus/silk/fixed/schur64_FIX.c", - "opus/silk/fixed/corrMatrix_FIX.c", - "opus/silk/fixed/LTP_scale_ctrl_FIX.c", - "opus/silk/fixed/schur_FIX.c", + "opus/silk/fixed/residual_energy16_FIX.c", "opus/silk/fixed/encode_frame_FIX.c", - "opus/silk/fixed/noise_shape_analysis_FIX.c", + "opus/silk/fixed/regularize_correlations_FIX.c", + "opus/silk/fixed/apply_sine_window_FIX.c", "opus/silk/fixed/solve_LS_FIX.c", - "opus/silk/fixed/find_LPC_FIX.c", + "opus/silk/fixed/schur_FIX.c", "opus/silk/fixed/pitch_analysis_core_FIX.c", - "opus/silk/fixed/vector_ops_FIX.c", + "opus/silk/fixed/noise_shape_analysis_FIX.c", "opus/silk/fixed/find_LTP_FIX.c", - "opus/silk/fixed/prefilter_FIX.c", + "opus/silk/fixed/vector_ops_FIX.c", + "opus/silk/fixed/autocorr_FIX.c", "opus/silk/fixed/warped_autocorrelation_FIX.c", "opus/silk/fixed/find_pitch_lags_FIX.c", + "opus/silk/fixed/k2a_Q16_FIX.c", + "opus/silk/fixed/LTP_scale_ctrl_FIX.c", + "opus/silk/fixed/corrMatrix_FIX.c", + "opus/silk/fixed/prefilter_FIX.c", + "opus/silk/fixed/find_LPC_FIX.c", + "opus/silk/fixed/residual_energy_FIX.c", "opus/silk/fixed/process_gains_FIX.c", - "opus/silk/fixed/find_pred_coefs_FIX.c", - "opus/silk/fixed/regularize_correlations_FIX.c" + "opus/silk/fixed/LTP_analysis_filter_FIX.c", + "opus/silk/fixed/k2a_FIX.c", + "opus/silk/fixed/burg_modified_FIX.c", + "opus/silk/fixed/find_pred_coefs_FIX.c" ] else: opus_sources_silk = [ - "opus/silk/float/apply_sine_window_FLP.c", - "opus/silk/float/inner_product_FLP.c", + "opus/silk/float/LTP_scale_ctrl_FLP.c", "opus/silk/float/regularize_correlations_FLP.c", - "opus/silk/float/autocorrelation_FLP.c", - "opus/silk/float/k2a_FLP.c", - "opus/silk/float/residual_energy_FLP.c", - "opus/silk/float/burg_modified_FLP.c", - "opus/silk/float/levinsondurbin_FLP.c", - "opus/silk/float/scale_copy_vector_FLP.c", - "opus/silk/float/bwexpander_FLP.c", - "opus/silk/float/LPC_analysis_filter_FLP.c", - "opus/silk/float/scale_vector_FLP.c", "opus/silk/float/corrMatrix_FLP.c", - "opus/silk/float/LPC_inv_pred_gain_FLP.c", + "opus/silk/float/LPC_analysis_filter_FLP.c", + "opus/silk/float/levinsondurbin_FLP.c", "opus/silk/float/schur_FLP.c", - "opus/silk/float/encode_frame_FLP.c", - "opus/silk/float/LTP_analysis_filter_FLP.c", + "opus/silk/float/scale_vector_FLP.c", + "opus/silk/float/apply_sine_window_FLP.c", + "opus/silk/float/pitch_analysis_core_FLP.c", + "opus/silk/float/wrappers_FLP.c", + "opus/silk/float/bwexpander_FLP.c", + "opus/silk/float/warped_autocorrelation_FLP.c", "opus/silk/float/solve_LS_FLP.c", + "opus/silk/float/find_LPC_FLP.c", + "opus/silk/float/autocorrelation_FLP.c", + "opus/silk/float/find_pred_coefs_FLP.c", + "opus/silk/float/find_pitch_lags_FLP.c", + "opus/silk/float/burg_modified_FLP.c", + "opus/silk/float/find_LTP_FLP.c", "opus/silk/float/energy_FLP.c", - "opus/silk/float/LTP_scale_ctrl_FLP.c", "opus/silk/float/sort_FLP.c", - "opus/silk/float/find_LPC_FLP.c", + "opus/silk/float/LPC_inv_pred_gain_FLP.c", + "opus/silk/float/k2a_FLP.c", "opus/silk/float/noise_shape_analysis_FLP.c", - "opus/silk/float/warped_autocorrelation_FLP.c", - "opus/silk/float/find_LTP_FLP.c", - "opus/silk/float/pitch_analysis_core_FLP.c", - "opus/silk/float/wrappers_FLP.c", - "opus/silk/float/find_pitch_lags_FLP.c", - "opus/silk/float/prefilter_FLP.c", - "opus/silk/float/find_pred_coefs_FLP.c", - "opus/silk/float/process_gains_FLP.c" + "opus/silk/float/inner_product_FLP.c", + "opus/silk/float/process_gains_FLP.c", + "opus/silk/float/encode_frame_FLP.c", + "opus/silk/float/scale_copy_vector_FLP.c", + "opus/silk/float/residual_energy_FLP.c", + "opus/silk/float/LTP_analysis_filter_FLP.c", + "opus/silk/float/prefilter_FLP.c" ] -opus_sources_lib+=opus_sources_silk +env.drivers_sources+=opus_sources_silk env.drivers_sources+=opus_sources_lib env.drivers_sources+=opus_sources diff --git a/drivers/opus/analysis.c b/drivers/opus/analysis.c index e27e948178..6a0cd30113 100644 --- a/drivers/opus/analysis.c +++ b/drivers/opus/analysis.c @@ -24,14 +24,11 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/celt/kiss_fft.h" #include "opus/celt/celt.h" -#include "opus/celt/opus_modes.h" +#include "opus/celt/modes.h" #include "opus/celt/arch.h" #include "opus/celt/quant_bands.h" #include <stdio.h> @@ -39,8 +36,6 @@ #include "opus/mlp.h" #include "opus/celt/stack_alloc.h" -extern const MLP net; - #ifndef M_PI #define M_PI 3.141592653 #endif @@ -140,6 +135,21 @@ static OPUS_INLINE float fast_atan2f(float y, float x) { } } +void tonality_analysis_init(TonalityAnalysisState *tonal) +{ + /* Initialize reusable fields. */ + tonal->arch = opus_select_arch(); + /* Clear remaining fields. */ + tonality_analysis_reset(tonal); +} + +void tonality_analysis_reset(TonalityAnalysisState *tonal) +{ + /* Clear non-reusable fields. */ + char *start = (char*)&tonal->TONALITY_ANALYSIS_RESET_START; + OPUS_CLEAR(start, sizeof(TonalityAnalysisState) - (start - (char*)tonal)); +} + void tonality_get_info(TonalityAnalysisState *tonal, AnalysisInfo *info_out, int len) { int pos; @@ -189,7 +199,7 @@ void tonality_get_info(TonalityAnalysisState *tonal, AnalysisInfo *info_out, int info_out->music_prob = psum; } -void tonality_analysis(TonalityAnalysisState *tonal, AnalysisInfo *info_out, const CELTMode *celt_mode, const void *x, int len, int offset, int c1, int c2, int C, int lsb_depth, downmix_func downmix) +static void tonality_analysis(TonalityAnalysisState *tonal, const CELTMode *celt_mode, const void *x, int len, int offset, int c1, int c2, int C, int lsb_depth, downmix_func downmix) { int i, b; const kiss_fft_state *kfft; @@ -262,7 +272,16 @@ void tonality_analysis(TonalityAnalysisState *tonal, AnalysisInfo *info_out, con remaining = len - (ANALYSIS_BUF_SIZE-tonal->mem_fill); downmix(x, &tonal->inmem[240], remaining, offset+ANALYSIS_BUF_SIZE-tonal->mem_fill, c1, c2, C); tonal->mem_fill = 240 + remaining; - opus_fft(kfft, in, out); + opus_fft(kfft, in, out, tonal->arch); +#ifndef OPUS_FIXED_POINT + /* If there's any NaN on the input, the entire output will be NaN, so we only need to check one value. */ + if (celt_isnan(out[0].r)) + { + info->valid = 0; + RESTORE_STACK; + return; + } +#endif for (i=1;i<N2;i++) { @@ -334,6 +353,16 @@ void tonality_analysis(TonalityAnalysisState *tonal, AnalysisInfo *info_out, con tE += binE*tonality[i]; nE += binE*2.f*(.5f-noisiness[i]); } +#ifndef OPUS_FIXED_POINT + /* Check for extreme band energies that could cause NaNs later. */ + if (!(E<1e9f) || celt_isnan(E)) + { + info->valid = 0; + RESTORE_STACK; + return; + } +#endif + tonal->E[tonal->E_count][b] = E; frame_noisiness += nE/(1e-15f+E); @@ -611,8 +640,6 @@ void tonality_analysis(TonalityAnalysisState *tonal, AnalysisInfo *info_out, con /*printf("%d %d\n", info->bandwidth, info->opus_bandwidth);*/ info->noisiness = frame_noisiness; info->valid = 1; - if (info_out!=NULL) - OPUS_COPY(info_out, info, 1); RESTORE_STACK; } @@ -631,7 +658,7 @@ void run_analysis(TonalityAnalysisState *analysis, const CELTMode *celt_mode, co pcm_len = analysis_frame_size - analysis->analysis_offset; offset = analysis->analysis_offset; do { - tonality_analysis(analysis, NULL, celt_mode, analysis_pcm, IMIN(480, pcm_len), offset, c1, c2, C, lsb_depth, downmix); + tonality_analysis(analysis, celt_mode, analysis_pcm, IMIN(480, pcm_len), offset, c1, c2, C, lsb_depth, downmix); offset += 480; pcm_len -= 480; } while (pcm_len>0); diff --git a/drivers/opus/analysis.h b/drivers/opus/analysis.h index 548614d529..9d81164e25 100644 --- a/drivers/opus/analysis.h +++ b/drivers/opus/analysis.h @@ -39,6 +39,8 @@ #define DETECT_SIZE 200 typedef struct { + int arch; +#define TONALITY_ANALYSIS_RESET_START angle float angle[240]; float d_angle[240]; float d2_angle[240]; @@ -78,8 +80,19 @@ typedef struct { AnalysisInfo info[DETECT_SIZE]; } TonalityAnalysisState; -void tonality_analysis(TonalityAnalysisState *tonal, AnalysisInfo *info, - const CELTMode *celt_mode, const void *x, int len, int offset, int c1, int c2, int C, int lsb_depth, downmix_func downmix); +/** Initialize a TonalityAnalysisState struct. + * + * This performs some possibly slow initialization steps which should + * not be repeated every analysis step. No allocated memory is retained + * by the state struct, so no cleanup call is required. + */ +void tonality_analysis_init(TonalityAnalysisState *analysis); + +/** Reset a TonalityAnalysisState stuct. + * + * Call this when there's a discontinuity in the data. + */ +void tonality_analysis_reset(TonalityAnalysisState *analysis); void tonality_get_info(TonalityAnalysisState *tonal, AnalysisInfo *info_out, int len); diff --git a/drivers/opus/celt/_kiss_fft_guts.h b/drivers/opus/celt/_kiss_fft_guts.h index 2a4ee744ef..a41f9a1a05 100644 --- a/drivers/opus/celt/_kiss_fft_guts.h +++ b/drivers/opus/celt/_kiss_fft_guts.h @@ -65,10 +65,6 @@ do{ (m).r = ADD32(S_MUL((a).r,(b).r) , S_MUL((a).i,(b).i)); \ (m).i = SUB32(S_MUL((a).i,(b).r) , S_MUL((a).r,(b).i)); }while(0) -# define C_MUL4(m,a,b) \ - do{ (m).r = SHR32(SUB32(S_MUL((a).r,(b).r) , S_MUL((a).i,(b).i)),2); \ - (m).i = SHR32(ADD32(S_MUL((a).r,(b).i) , S_MUL((a).i,(b).r)),2); }while(0) - # define C_MULBYSCALAR( c, s ) \ do{ (c).r = S_MUL( (c).r , s ) ;\ (c).i = S_MUL( (c).i , s ) ; }while(0) @@ -95,14 +91,17 @@ }while(0) #if defined(OPUS_ARM_INLINE_ASM) -#include "arm/kiss_fft_armv4.h" +#include "opus/celt/arm/kiss_fft_armv4.h" #endif #if defined(OPUS_ARM_INLINE_EDSP) -#include "arm/kiss_fft_armv5e.h" +#include "opus/celt/arm/kiss_fft_armv5e.h" +#endif +#if defined(MIPSr1_ASM) +#include "opus/celt/mips/kiss_fft_mipsr1.h" #endif -#else /* not OPUS_FIXED_POINT*/ +#else /* not FIXED_POINT*/ # define S_MUL(a,b) ( (a)*(b) ) #define C_MUL(m,a,b) \ @@ -153,8 +152,8 @@ #endif /* C_ADD defined */ #ifdef OPUS_FIXED_POINT -# define KISS_FFT_COS(phase) TRIG_UPSCALE*floor(MIN(32767,MAX(-32767,.5+32768 * cos (phase)))) -# define KISS_FFT_SIN(phase) TRIG_UPSCALE*floor(MIN(32767,MAX(-32767,.5+32768 * sin (phase)))) +/*# define KISS_FFT_COS(phase) TRIG_UPSCALE*floor(MIN(32767,MAX(-32767,.5+32768 * cos (phase)))) +# define KISS_FFT_SIN(phase) TRIG_UPSCALE*floor(MIN(32767,MAX(-32767,.5+32768 * sin (phase))))*/ # define KISS_FFT_COS(phase) floor(.5+TWID_MAX*cos (phase)) # define KISS_FFT_SIN(phase) floor(.5+TWID_MAX*sin (phase)) # define HALF_OF(x) ((x)>>1) diff --git a/drivers/opus/celt/arch.h b/drivers/opus/celt/arch.h index d964f8d90c..7fb036e9fe 100644 --- a/drivers/opus/celt/arch.h +++ b/drivers/opus/celt/arch.h @@ -69,11 +69,8 @@ static OPUS_INLINE void _celt_fatal(const char *str, const char *file, int line) #define IMUL32(a,b) ((a)*(b)) -#define ABS(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute integer value. */ -#define ABS16(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute 16-bit value. */ #define MIN16(a,b) ((a) < (b) ? (a) : (b)) /**< Minimum 16-bit value. */ #define MAX16(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 16-bit value. */ -#define ABS32(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute 32-bit value. */ #define MIN32(a,b) ((a) < (b) ? (a) : (b)) /**< Minimum 32-bit value. */ #define MAX32(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 32-bit value. */ #define IMIN(a,b) ((a) < (b) ? (a) : (b)) /**< Minimum int value. */ @@ -108,6 +105,13 @@ typedef opus_val32 celt_ener; #define SCALEIN(a) (a) #define SCALEOUT(a) (a) +#define ABS16(x) ((x) < 0 ? (-(x)) : (x)) +#define ABS32(x) ((x) < 0 ? (-(x)) : (x)) + +static OPUS_INLINE opus_int16 SAT16(opus_int32 x) { + return x > 32767 ? 32767 : x < -32768 ? -32768 : (opus_int16)x; +} + #ifdef FIXED_DEBUG #include "opus/celt/fixed_debug.h" #else @@ -115,9 +119,9 @@ typedef opus_val32 celt_ener; #include "opus/celt/fixed_generic.h" #ifdef OPUS_ARM_INLINE_EDSP -#include "arm/fixed_armv5e.h" +#include "opus/celt/arm/fixed_armv5e.h" #elif defined (OPUS_ARM_INLINE_ASM) -#include "arm/fixed_armv4.h" +#include "opus/celt/arm/fixed_armv4.h" #elif defined (BFIN_ASM) #include "fixed_bfin.h" #elif defined (TI_C5X_ASM) @@ -128,7 +132,7 @@ typedef opus_val32 celt_ener; #endif -#else /* OPUS_FIXED_POINT */ +#else /* FIXED_POINT */ typedef float opus_val16; typedef float opus_val32; @@ -137,6 +141,22 @@ typedef float celt_sig; typedef float celt_norm; typedef float celt_ener; +#ifdef FLOAT_APPROX +/* This code should reliably detect NaN/inf even when -ffast-math is used. + Assumes IEEE 754 format. */ +static OPUS_INLINE int celt_isnan(float x) +{ + union {float f; opus_uint32 i;} in; + in.f = x; + return ((in.i>>23)&0xFF)==0xFF && (in.i&0x007FFFFF)!=0; +} +#else +#ifdef __FAST_MATH__ +#error Cannot build libopus with -ffast-math unless FLOAT_APPROX is defined. This could result in crashes on extreme (e.g. NaN) input +#endif +#define celt_isnan(x) ((x)!=(x)) +#endif + #define Q15ONE 1.0f #define NORM_SCALING 1.f @@ -146,6 +166,10 @@ typedef float celt_ener; #define VERY_LARGE16 1e15f #define Q15_ONE ((opus_val16)1.f) +/* This appears to be the same speed as C99's fabsf() but it's more portable. */ +#define ABS16(x) ((float)fabs(x)) +#define ABS32(x) ((float)fabs(x)) + #define QCONST16(x,bits) (x) #define QCONST32(x,bits) (x) @@ -184,6 +208,7 @@ typedef float celt_ener; #define MULT32_32_Q31(a,b) ((a)*(b)) #define MAC16_32_Q15(c,a,b) ((c)+(a)*(b)) +#define MAC16_32_Q16(c,a,b) ((c)+(a)*(b)) #define MULT16_16_Q11_32(a,b) ((a)*(b)) #define MULT16_16_Q11(a,b) ((a)*(b)) @@ -201,7 +226,9 @@ typedef float celt_ener; #define SCALEIN(a) ((a)*CELT_SIG_SCALE) #define SCALEOUT(a) ((a)*(1/CELT_SIG_SCALE)) -#endif /* !OPUS_FIXED_POINT */ +#define SIG2WORD16(x) (x) + +#endif /* !FIXED_POINT */ #ifndef GLOBAL_STACK_SIZE #ifdef OPUS_FIXED_POINT diff --git a/drivers/opus/celt/arm/arm2gnu.pl b/drivers/opus/celt/arm/arm2gnu.pl index eab42efa2b..6c922ac819 100755 --- a/drivers/opus/celt/arm/arm2gnu.pl +++ b/drivers/opus/celt/arm/arm2gnu.pl @@ -1,7 +1,33 @@ #!/usr/bin/perl +# Copyright (C) 2002-2013 Xiph.org Foundation +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# - Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# - Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER +# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. my $bigend; # little/big endian my $nxstack; +my $apple = 0; +my $symprefix = ""; $nxstack = 0; @@ -10,11 +36,16 @@ eval 'exec /usr/local/bin/perl -S $0 ${1+"$@"}' while ($ARGV[0] =~ /^-/) { $_ = shift; - last if /^--/; - if (/^-n/) { + last if /^--$/; + if (/^-n$/) { $nflag++; next; } + if (/^--apple$/) { + $apple = 1; + $symprefix = "_"; + next; + } die "I don't recognize this switch: $_\\n"; } $printit++ unless $nflag; @@ -25,6 +56,8 @@ $n=0; $thumb = 0; # ARM mode by default, not Thumb. @proc_stack = (); +printf (" .syntax unified\n"); + LINE: while (<>) { @@ -53,7 +86,7 @@ while (<>) { s/\bINCLUDE[ \t]*([^ \t\n]+)/.include \"$1\"/; s/\bGET[ \t]*([^ \t\n]+)/.include \"${ my $x=$1; $x =~ s|\.s|-gnu.S|; \$x }\"/; s/\bIMPORT\b/.extern/; - s/\bEXPORT\b/.global/; + s/\bEXPORT\b\s*/.global $symprefix/; s/^(\s+)\[/$1IF/; s/^(\s+)\|/$1ELSE/; s/^(\s+)\]/$1ENDIF/; @@ -109,7 +142,7 @@ while (<>) { # won't match the original source file (we could use the .line # directive, which is documented to be obsolete, but then gdb will # show the wrong line in the translated source file). - s/$/; .arch armv7-a\n .fpu neon\n .object_arch armv4t/; + s/$/; .arch armv7-a\n .fpu neon\n .object_arch armv4t/ unless ($apple); } } @@ -131,9 +164,13 @@ while (<>) { $prefix = ""; if ($proc) { - $prefix = $prefix.sprintf("\t.type\t%s, %%function; ",$proc); + $prefix = $prefix.sprintf("\t.type\t%s, %%function; ",$proc) unless ($apple); + # Make sure we $prefix isn't empty here (for the $apple case). + # We handle mangling the label here, make sure it doesn't match + # the label handling below (if $prefix would be empty). + $prefix = "; "; push(@proc_stack, $proc); - s/^[A-Za-z_\.]\w+/$&:/; + s/^[A-Za-z_\.]\w+/$symprefix$&:/; } $prefix = $prefix."\t.thumb_func; " if ($thumb); s/\bPROC\b/@ $&/; @@ -146,7 +183,7 @@ while (<>) { my $proc; s/\bENDP\b/@ $&/; $proc = pop(@proc_stack); - $_ = "\t.size $proc, .-$proc".$_ if ($proc); + $_ = "\t.size $proc, .-$proc".$_ if ($proc && !$apple); } s/\bSUBT\b/@ $&/; s/\bDATA\b/@ $&/; # DATA directive is deprecated -- Asm guide, p.7-25 @@ -311,6 +348,6 @@ while (<>) { } #If we had a code section, mark that this object doesn't need an executable # stack. -if ($nxstack) { +if ($nxstack && !$apple) { printf (" .section\t.note.GNU-stack,\"\",\%\%progbits\n"); } diff --git a/drivers/opus/celt/arm/arm_celt_map.c b/drivers/opus/celt/arm/arm_celt_map.c index 31e7d5b319..92c83c1763 100644 --- a/drivers/opus/celt/arm/arm_celt_map.c +++ b/drivers/opus/celt/arm/arm_celt_map.c @@ -24,16 +24,15 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/celt/pitch.h" +#include "opus/celt/kiss_fft.h" +#include "opus/celt/mdct.h" #if defined(OPUS_HAVE_RTCD) -# if defined(OPUS_FIXED_POINT) +# if defined(FIXED_POINT) opus_val32 (*const CELT_PITCH_XCORR_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *, const opus_val16 *, opus_val32 *, int , int) = { celt_pitch_xcorr_c, /* ARMv4 */ @@ -41,9 +40,79 @@ opus_val32 (*const CELT_PITCH_XCORR_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *, MAY_HAVE_MEDIA(celt_pitch_xcorr), /* Media */ MAY_HAVE_NEON(celt_pitch_xcorr) /* NEON */ }; -# else -# error "Floating-point implementation is not supported by ARM asm yet." \ - "Reconfigure with --disable-rtcd or send patches." -# endif +# else /* !FIXED_POINT */ +# if defined(OPUS_ARM_MAY_HAVE_NEON_INTR) +void (*const CELT_PITCH_XCORR_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *, + const opus_val16 *, opus_val32 *, int, int) = { + celt_pitch_xcorr_c, /* ARMv4 */ + celt_pitch_xcorr_c, /* EDSP */ + celt_pitch_xcorr_c, /* Media */ + celt_pitch_xcorr_float_neon /* Neon */ +}; +# endif +# endif /* FIXED_POINT */ + +# if defined(OPUS_ARM_MAY_HAVE_NEON_INTR) +# if defined(HAVE_ARM_NE10) +# if defined(CUSTOM_MODES) +int (*const OPUS_FFT_ALLOC_ARCH_IMPL[OPUS_ARCHMASK+1])(kiss_fft_state *st) = { + opus_fft_alloc_arch_c, /* ARMv4 */ + opus_fft_alloc_arch_c, /* EDSP */ + opus_fft_alloc_arch_c, /* Media */ + opus_fft_alloc_arm_neon /* Neon with NE10 library support */ +}; + +void (*const OPUS_FFT_FREE_ARCH_IMPL[OPUS_ARCHMASK+1])(kiss_fft_state *st) = { + opus_fft_free_arch_c, /* ARMv4 */ + opus_fft_free_arch_c, /* EDSP */ + opus_fft_free_arch_c, /* Media */ + opus_fft_free_arm_neon /* Neon with NE10 */ +}; +# endif /* CUSTOM_MODES */ + +void (*const OPUS_FFT[OPUS_ARCHMASK+1])(const kiss_fft_state *cfg, + const kiss_fft_cpx *fin, + kiss_fft_cpx *fout) = { + opus_fft_c, /* ARMv4 */ + opus_fft_c, /* EDSP */ + opus_fft_c, /* Media */ + opus_fft_neon /* Neon with NE10 */ +}; + +void (*const OPUS_IFFT[OPUS_ARCHMASK+1])(const kiss_fft_state *cfg, + const kiss_fft_cpx *fin, + kiss_fft_cpx *fout) = { + opus_ifft_c, /* ARMv4 */ + opus_ifft_c, /* EDSP */ + opus_ifft_c, /* Media */ + opus_ifft_neon /* Neon with NE10 */ +}; + +void (*const CLT_MDCT_FORWARD_IMPL[OPUS_ARCHMASK+1])(const mdct_lookup *l, + kiss_fft_scalar *in, + kiss_fft_scalar * OPUS_RESTRICT out, + const opus_val16 *window, + int overlap, int shift, + int stride, int arch) = { + clt_mdct_forward_c, /* ARMv4 */ + clt_mdct_forward_c, /* EDSP */ + clt_mdct_forward_c, /* Media */ + clt_mdct_forward_neon /* Neon with NE10 */ +}; + +void (*const CLT_MDCT_BACKWARD_IMPL[OPUS_ARCHMASK+1])(const mdct_lookup *l, + kiss_fft_scalar *in, + kiss_fft_scalar * OPUS_RESTRICT out, + const opus_val16 *window, + int overlap, int shift, + int stride, int arch) = { + clt_mdct_backward_c, /* ARMv4 */ + clt_mdct_backward_c, /* EDSP */ + clt_mdct_backward_c, /* Media */ + clt_mdct_backward_neon /* Neon with NE10 */ +}; + +# endif /* HAVE_ARM_NE10 */ +# endif /* OPUS_ARM_MAY_HAVE_NEON_INTR */ -#endif +#endif /* OPUS_HAVE_RTCD */ diff --git a/drivers/opus/celt/arm/armcpu.c b/drivers/opus/celt/arm/armcpu.c index fb7f2421fe..ac8ad2ec14 100644 --- a/drivers/opus/celt/arm/armcpu.c +++ b/drivers/opus/celt/arm/armcpu.c @@ -26,10 +26,7 @@ */ /* Original code from libtheora modified to suit to Opus */ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #ifdef OPUS_HAVE_RTCD @@ -73,7 +70,7 @@ static OPUS_INLINE opus_uint32 opus_cpu_capabilities(void){ __except(GetExceptionCode()==EXCEPTION_ILLEGAL_INSTRUCTION){ /*Ignore exception.*/ } -# if defined(OPUS_ARM_MAY_HAVE_NEON) +# if defined(OPUS_ARM_MAY_HAVE_NEON) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR) __try{ /*VORR q0,q0,q0*/ __emit(0xF2200150); @@ -107,7 +104,7 @@ opus_uint32 opus_cpu_capabilities(void) while(fgets(buf, 512, cpuinfo) != NULL) { -# if defined(OPUS_ARM_MAY_HAVE_EDSP) || defined(OPUS_ARM_MAY_HAVE_NEON) +# if defined(OPUS_ARM_MAY_HAVE_EDSP) || defined(OPUS_ARM_MAY_HAVE_NEON) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR) /* Search for edsp and neon flag */ if(memcmp(buf, "Features", 8) == 0) { @@ -118,7 +115,7 @@ opus_uint32 opus_cpu_capabilities(void) flags |= OPUS_CPU_ARM_EDSP; # endif -# if defined(OPUS_ARM_MAY_HAVE_NEON) +# if defined(OPUS_ARM_MAY_HAVE_NEON) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR) p = strstr(buf, " neon"); if(p != NULL && (p[5] == ' ' || p[5] == '\n')) flags |= OPUS_CPU_ARM_NEON; diff --git a/drivers/opus/celt/arm/celt_ne10_fft.c b/drivers/opus/celt/arm/celt_ne10_fft.c new file mode 100644 index 0000000000..e57d23ee1d --- /dev/null +++ b/drivers/opus/celt/arm/celt_ne10_fft.c @@ -0,0 +1,172 @@ +/* Copyright (c) 2015 Xiph.Org Foundation + Written by Viswanath Puttagunta */ +/** + @file celt_ne10_fft.c + @brief ARM Neon optimizations for fft using NE10 library + */ + +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef SKIP_CONFIG_H +#include "opus/opus_config.h" +#endif + +#include <NE10_init.h> +#include <NE10_dsp.h> +#include "opus/celt/os_support.h" +#include "opus/celt/kiss_fft.h" +#include "opus/celt/stack_alloc.h" + +#if !defined(FIXED_POINT) +# define NE10_FFT_ALLOC_C2C_TYPE_NEON ne10_fft_alloc_c2c_float32_neon +# define NE10_FFT_CFG_TYPE_T ne10_fft_cfg_float32_t +# define NE10_FFT_STATE_TYPE_T ne10_fft_state_float32_t +# define NE10_FFT_DESTROY_C2C_TYPE ne10_fft_destroy_c2c_float32 +# define NE10_FFT_CPX_TYPE_T ne10_fft_cpx_float32_t +# define NE10_FFT_C2C_1D_TYPE_NEON ne10_fft_c2c_1d_float32_neon +#else +# define NE10_FFT_ALLOC_C2C_TYPE_NEON(nfft) ne10_fft_alloc_c2c_int32_neon(nfft) +# define NE10_FFT_CFG_TYPE_T ne10_fft_cfg_int32_t +# define NE10_FFT_STATE_TYPE_T ne10_fft_state_int32_t +# define NE10_FFT_DESTROY_C2C_TYPE ne10_fft_destroy_c2c_int32 +# define NE10_FFT_DESTROY_C2C_TYPE ne10_fft_destroy_c2c_int32 +# define NE10_FFT_CPX_TYPE_T ne10_fft_cpx_int32_t +# define NE10_FFT_C2C_1D_TYPE_NEON ne10_fft_c2c_1d_int32_neon +#endif + +#if defined(CUSTOM_MODES) + +/* nfft lengths in NE10 that support scaled fft */ +# define NE10_FFTSCALED_SUPPORT_MAX 4 +static const int ne10_fft_scaled_support[NE10_FFTSCALED_SUPPORT_MAX] = { + 480, 240, 120, 60 +}; + +int opus_fft_alloc_arm_neon(kiss_fft_state *st) +{ + int i; + size_t memneeded = sizeof(struct arch_fft_state); + + st->arch_fft = (arch_fft_state *)opus_alloc(memneeded); + if (!st->arch_fft) + return -1; + + for (i = 0; i < NE10_FFTSCALED_SUPPORT_MAX; i++) { + if(st->nfft == ne10_fft_scaled_support[i]) + break; + } + if (i == NE10_FFTSCALED_SUPPORT_MAX) { + /* This nfft length (scaled fft) is not supported in NE10 */ + st->arch_fft->is_supported = 0; + st->arch_fft->priv = NULL; + } + else { + st->arch_fft->is_supported = 1; + st->arch_fft->priv = (void *)NE10_FFT_ALLOC_C2C_TYPE_NEON(st->nfft); + if (st->arch_fft->priv == NULL) { + return -1; + } + } + return 0; +} + +void opus_fft_free_arm_neon(kiss_fft_state *st) +{ + NE10_FFT_CFG_TYPE_T cfg; + + if (!st->arch_fft) + return; + + cfg = (NE10_FFT_CFG_TYPE_T)st->arch_fft->priv; + if (cfg) + NE10_FFT_DESTROY_C2C_TYPE(cfg); + opus_free(st->arch_fft); +} +#endif + +void opus_fft_neon(const kiss_fft_state *st, + const kiss_fft_cpx *fin, + kiss_fft_cpx *fout) +{ + NE10_FFT_STATE_TYPE_T state; + NE10_FFT_CFG_TYPE_T cfg = &state; + VARDECL(NE10_FFT_CPX_TYPE_T, buffer); + SAVE_STACK; + ALLOC(buffer, st->nfft, NE10_FFT_CPX_TYPE_T); + + if (!st->arch_fft->is_supported) { + /* This nfft length (scaled fft) not supported in NE10 */ + opus_fft_c(st, fin, fout); + } + else { + memcpy((void *)cfg, st->arch_fft->priv, sizeof(NE10_FFT_STATE_TYPE_T)); + state.buffer = (NE10_FFT_CPX_TYPE_T *)&buffer[0]; +#if !defined(FIXED_POINT) + state.is_forward_scaled = 1; + + NE10_FFT_C2C_1D_TYPE_NEON((NE10_FFT_CPX_TYPE_T *)fout, + (NE10_FFT_CPX_TYPE_T *)fin, + cfg, 0); +#else + NE10_FFT_C2C_1D_TYPE_NEON((NE10_FFT_CPX_TYPE_T *)fout, + (NE10_FFT_CPX_TYPE_T *)fin, + cfg, 0, 1); +#endif + } + RESTORE_STACK; +} + +void opus_ifft_neon(const kiss_fft_state *st, + const kiss_fft_cpx *fin, + kiss_fft_cpx *fout) +{ + NE10_FFT_STATE_TYPE_T state; + NE10_FFT_CFG_TYPE_T cfg = &state; + VARDECL(NE10_FFT_CPX_TYPE_T, buffer); + SAVE_STACK; + ALLOC(buffer, st->nfft, NE10_FFT_CPX_TYPE_T); + + if (!st->arch_fft->is_supported) { + /* This nfft length (scaled fft) not supported in NE10 */ + opus_ifft_c(st, fin, fout); + } + else { + memcpy((void *)cfg, st->arch_fft->priv, sizeof(NE10_FFT_STATE_TYPE_T)); + state.buffer = (NE10_FFT_CPX_TYPE_T *)&buffer[0]; +#if !defined(FIXED_POINT) + state.is_backward_scaled = 0; + + NE10_FFT_C2C_1D_TYPE_NEON((NE10_FFT_CPX_TYPE_T *)fout, + (NE10_FFT_CPX_TYPE_T *)fin, + cfg, 1); +#else + NE10_FFT_C2C_1D_TYPE_NEON((NE10_FFT_CPX_TYPE_T *)fout, + (NE10_FFT_CPX_TYPE_T *)fin, + cfg, 1, 0); +#endif + } + RESTORE_STACK; +} diff --git a/drivers/opus/celt/arm/celt_ne10_mdct.c b/drivers/opus/celt/arm/celt_ne10_mdct.c new file mode 100644 index 0000000000..eb407b674f --- /dev/null +++ b/drivers/opus/celt/arm/celt_ne10_mdct.c @@ -0,0 +1,256 @@ +/* Copyright (c) 2015 Xiph.Org Foundation + Written by Viswanath Puttagunta */ +/** + @file celt_ne10_mdct.c + @brief ARM Neon optimizations for mdct using NE10 library + */ + +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef SKIP_CONFIG_H +#include "opus/opus_config.h" +#endif + +#include "opus/celt/kiss_fft.h" +#include "opus/celt/_kiss_fft_guts.h" +#include "opus/celt/mdct.h" +#include "opus/celt/stack_alloc.h" + +void clt_mdct_forward_neon(const mdct_lookup *l, + kiss_fft_scalar *in, + kiss_fft_scalar * OPUS_RESTRICT out, + const opus_val16 *window, + int overlap, int shift, int stride, int arch) +{ + int i; + int N, N2, N4; + VARDECL(kiss_fft_scalar, f); + VARDECL(kiss_fft_cpx, f2); + const kiss_fft_state *st = l->kfft[shift]; + const kiss_twiddle_scalar *trig; + + SAVE_STACK; + + N = l->n; + trig = l->trig; + for (i=0;i<shift;i++) + { + N >>= 1; + trig += N; + } + N2 = N>>1; + N4 = N>>2; + + ALLOC(f, N2, kiss_fft_scalar); + ALLOC(f2, N4, kiss_fft_cpx); + + /* Consider the input to be composed of four blocks: [a, b, c, d] */ + /* Window, shuffle, fold */ + { + /* Temp pointers to make it really clear to the compiler what we're doing */ + const kiss_fft_scalar * OPUS_RESTRICT xp1 = in+(overlap>>1); + const kiss_fft_scalar * OPUS_RESTRICT xp2 = in+N2-1+(overlap>>1); + kiss_fft_scalar * OPUS_RESTRICT yp = f; + const opus_val16 * OPUS_RESTRICT wp1 = window+(overlap>>1); + const opus_val16 * OPUS_RESTRICT wp2 = window+(overlap>>1)-1; + for(i=0;i<((overlap+3)>>2);i++) + { + /* Real part arranged as -d-cR, Imag part arranged as -b+aR*/ + *yp++ = MULT16_32_Q15(*wp2, xp1[N2]) + MULT16_32_Q15(*wp1,*xp2); + *yp++ = MULT16_32_Q15(*wp1, *xp1) - MULT16_32_Q15(*wp2, xp2[-N2]); + xp1+=2; + xp2-=2; + wp1+=2; + wp2-=2; + } + wp1 = window; + wp2 = window+overlap-1; + for(;i<N4-((overlap+3)>>2);i++) + { + /* Real part arranged as a-bR, Imag part arranged as -c-dR */ + *yp++ = *xp2; + *yp++ = *xp1; + xp1+=2; + xp2-=2; + } + for(;i<N4;i++) + { + /* Real part arranged as a-bR, Imag part arranged as -c-dR */ + *yp++ = -MULT16_32_Q15(*wp1, xp1[-N2]) + MULT16_32_Q15(*wp2, *xp2); + *yp++ = MULT16_32_Q15(*wp2, *xp1) + MULT16_32_Q15(*wp1, xp2[N2]); + xp1+=2; + xp2-=2; + wp1+=2; + wp2-=2; + } + } + /* Pre-rotation */ + { + kiss_fft_scalar * OPUS_RESTRICT yp = f; + const kiss_twiddle_scalar *t = &trig[0]; + for(i=0;i<N4;i++) + { + kiss_fft_cpx yc; + kiss_twiddle_scalar t0, t1; + kiss_fft_scalar re, im, yr, yi; + t0 = t[i]; + t1 = t[N4+i]; + re = *yp++; + im = *yp++; + yr = S_MUL(re,t0) - S_MUL(im,t1); + yi = S_MUL(im,t0) + S_MUL(re,t1); + yc.r = yr; + yc.i = yi; + f2[i] = yc; + } + } + + opus_fft(st, f2, (kiss_fft_cpx *)f, arch); + + /* Post-rotate */ + { + /* Temp pointers to make it really clear to the compiler what we're doing */ + const kiss_fft_cpx * OPUS_RESTRICT fp = (kiss_fft_cpx *)f; + kiss_fft_scalar * OPUS_RESTRICT yp1 = out; + kiss_fft_scalar * OPUS_RESTRICT yp2 = out+stride*(N2-1); + const kiss_twiddle_scalar *t = &trig[0]; + /* Temp pointers to make it really clear to the compiler what we're doing */ + for(i=0;i<N4;i++) + { + kiss_fft_scalar yr, yi; + yr = S_MUL(fp->i,t[N4+i]) - S_MUL(fp->r,t[i]); + yi = S_MUL(fp->r,t[N4+i]) + S_MUL(fp->i,t[i]); + *yp1 = yr; + *yp2 = yi; + fp++; + yp1 += 2*stride; + yp2 -= 2*stride; + } + } + RESTORE_STACK; +} + +void clt_mdct_backward_neon(const mdct_lookup *l, + kiss_fft_scalar *in, + kiss_fft_scalar * OPUS_RESTRICT out, + const opus_val16 * OPUS_RESTRICT window, + int overlap, int shift, int stride, int arch) +{ + int i; + int N, N2, N4; + VARDECL(kiss_fft_scalar, f); + const kiss_twiddle_scalar *trig; + const kiss_fft_state *st = l->kfft[shift]; + + N = l->n; + trig = l->trig; + for (i=0;i<shift;i++) + { + N >>= 1; + trig += N; + } + N2 = N>>1; + N4 = N>>2; + + ALLOC(f, N2, kiss_fft_scalar); + + /* Pre-rotate */ + { + /* Temp pointers to make it really clear to the compiler what we're doing */ + const kiss_fft_scalar * OPUS_RESTRICT xp1 = in; + const kiss_fft_scalar * OPUS_RESTRICT xp2 = in+stride*(N2-1); + kiss_fft_scalar * OPUS_RESTRICT yp = f; + const kiss_twiddle_scalar * OPUS_RESTRICT t = &trig[0]; + for(i=0;i<N4;i++) + { + kiss_fft_scalar yr, yi; + yr = S_MUL(*xp2, t[i]) + S_MUL(*xp1, t[N4+i]); + yi = S_MUL(*xp1, t[i]) - S_MUL(*xp2, t[N4+i]); + yp[2*i] = yr; + yp[2*i+1] = yi; + xp1+=2*stride; + xp2-=2*stride; + } + } + + opus_ifft(st, (kiss_fft_cpx *)f, (kiss_fft_cpx*)(out+(overlap>>1)), arch); + + /* Post-rotate and de-shuffle from both ends of the buffer at once to make + it in-place. */ + { + kiss_fft_scalar * yp0 = out+(overlap>>1); + kiss_fft_scalar * yp1 = out+(overlap>>1)+N2-2; + const kiss_twiddle_scalar *t = &trig[0]; + /* Loop to (N4+1)>>1 to handle odd N4. When N4 is odd, the + middle pair will be computed twice. */ + for(i=0;i<(N4+1)>>1;i++) + { + kiss_fft_scalar re, im, yr, yi; + kiss_twiddle_scalar t0, t1; + re = yp0[0]; + im = yp0[1]; + t0 = t[i]; + t1 = t[N4+i]; + /* We'd scale up by 2 here, but instead it's done when mixing the windows */ + yr = S_MUL(re,t0) + S_MUL(im,t1); + yi = S_MUL(re,t1) - S_MUL(im,t0); + re = yp1[0]; + im = yp1[1]; + yp0[0] = yr; + yp1[1] = yi; + + t0 = t[(N4-i-1)]; + t1 = t[(N2-i-1)]; + /* We'd scale up by 2 here, but instead it's done when mixing the windows */ + yr = S_MUL(re,t0) + S_MUL(im,t1); + yi = S_MUL(re,t1) - S_MUL(im,t0); + yp1[0] = yr; + yp0[1] = yi; + yp0 += 2; + yp1 -= 2; + } + } + + /* Mirror on both sides for TDAC */ + { + kiss_fft_scalar * OPUS_RESTRICT xp1 = out+overlap-1; + kiss_fft_scalar * OPUS_RESTRICT yp1 = out; + const opus_val16 * OPUS_RESTRICT wp1 = window; + const opus_val16 * OPUS_RESTRICT wp2 = window+overlap-1; + + for(i = 0; i < overlap/2; i++) + { + kiss_fft_scalar x1, x2; + x1 = *xp1; + x2 = *yp1; + *yp1++ = MULT16_32_Q15(*wp2, x2) - MULT16_32_Q15(*wp1, x1); + *xp1-- = MULT16_32_Q15(*wp1, x2) + MULT16_32_Q15(*wp2, x1); + wp1++; + wp2--; + } + } + RESTORE_STACK; +} diff --git a/drivers/opus/celt/arm/celt_neon_intr.c b/drivers/opus/celt/arm/celt_neon_intr.c new file mode 100644 index 0000000000..82b6958644 --- /dev/null +++ b/drivers/opus/celt/arm/celt_neon_intr.c @@ -0,0 +1,249 @@ +/* Copyright (c) 2014-2015 Xiph.Org Foundation + Written by Viswanath Puttagunta */ +/** + @file celt_neon_intr.c + @brief ARM Neon Intrinsic optimizations for celt + */ + +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#include "opus/opus_config.h" + +#include <arm_neon.h> +#include "opus/celt/pitch.h" + +#if !defined(FIXED_POINT) +/* + * Function: xcorr_kernel_neon_float + * --------------------------------- + * Computes 4 correlation values and stores them in sum[4] + */ +static void xcorr_kernel_neon_float(const float32_t *x, const float32_t *y, + float32_t sum[4], int len) { + float32x4_t YY[3]; + float32x4_t YEXT[3]; + float32x4_t XX[2]; + float32x2_t XX_2; + float32x4_t SUMM; + const float32_t *xi = x; + const float32_t *yi = y; + + celt_assert(len>0); + + YY[0] = vld1q_f32(yi); + SUMM = vdupq_n_f32(0); + + /* Consume 8 elements in x vector and 12 elements in y + * vector. However, the 12'th element never really gets + * touched in this loop. So, if len == 8, then we only + * must access y[0] to y[10]. y[11] must not be accessed + * hence make sure len > 8 and not len >= 8 + */ + while (len > 8) { + yi += 4; + YY[1] = vld1q_f32(yi); + yi += 4; + YY[2] = vld1q_f32(yi); + + XX[0] = vld1q_f32(xi); + xi += 4; + XX[1] = vld1q_f32(xi); + xi += 4; + + SUMM = vmlaq_lane_f32(SUMM, YY[0], vget_low_f32(XX[0]), 0); + YEXT[0] = vextq_f32(YY[0], YY[1], 1); + SUMM = vmlaq_lane_f32(SUMM, YEXT[0], vget_low_f32(XX[0]), 1); + YEXT[1] = vextq_f32(YY[0], YY[1], 2); + SUMM = vmlaq_lane_f32(SUMM, YEXT[1], vget_high_f32(XX[0]), 0); + YEXT[2] = vextq_f32(YY[0], YY[1], 3); + SUMM = vmlaq_lane_f32(SUMM, YEXT[2], vget_high_f32(XX[0]), 1); + + SUMM = vmlaq_lane_f32(SUMM, YY[1], vget_low_f32(XX[1]), 0); + YEXT[0] = vextq_f32(YY[1], YY[2], 1); + SUMM = vmlaq_lane_f32(SUMM, YEXT[0], vget_low_f32(XX[1]), 1); + YEXT[1] = vextq_f32(YY[1], YY[2], 2); + SUMM = vmlaq_lane_f32(SUMM, YEXT[1], vget_high_f32(XX[1]), 0); + YEXT[2] = vextq_f32(YY[1], YY[2], 3); + SUMM = vmlaq_lane_f32(SUMM, YEXT[2], vget_high_f32(XX[1]), 1); + + YY[0] = YY[2]; + len -= 8; + } + + /* Consume 4 elements in x vector and 8 elements in y + * vector. However, the 8'th element in y never really gets + * touched in this loop. So, if len == 4, then we only + * must access y[0] to y[6]. y[7] must not be accessed + * hence make sure len>4 and not len>=4 + */ + if (len > 4) { + yi += 4; + YY[1] = vld1q_f32(yi); + + XX[0] = vld1q_f32(xi); + xi += 4; + + SUMM = vmlaq_lane_f32(SUMM, YY[0], vget_low_f32(XX[0]), 0); + YEXT[0] = vextq_f32(YY[0], YY[1], 1); + SUMM = vmlaq_lane_f32(SUMM, YEXT[0], vget_low_f32(XX[0]), 1); + YEXT[1] = vextq_f32(YY[0], YY[1], 2); + SUMM = vmlaq_lane_f32(SUMM, YEXT[1], vget_high_f32(XX[0]), 0); + YEXT[2] = vextq_f32(YY[0], YY[1], 3); + SUMM = vmlaq_lane_f32(SUMM, YEXT[2], vget_high_f32(XX[0]), 1); + + YY[0] = YY[1]; + len -= 4; + } + + while (--len > 0) { + XX_2 = vld1_dup_f32(xi++); + SUMM = vmlaq_lane_f32(SUMM, YY[0], XX_2, 0); + YY[0]= vld1q_f32(++yi); + } + + XX_2 = vld1_dup_f32(xi); + SUMM = vmlaq_lane_f32(SUMM, YY[0], XX_2, 0); + + vst1q_f32(sum, SUMM); +} + +/* + * Function: xcorr_kernel_neon_float_process1 + * --------------------------------- + * Computes single correlation values and stores in *sum + */ +static void xcorr_kernel_neon_float_process1(const float32_t *x, + const float32_t *y, float32_t *sum, int len) { + float32x4_t XX[4]; + float32x4_t YY[4]; + float32x2_t XX_2; + float32x2_t YY_2; + float32x4_t SUMM; + float32x2_t SUMM_2[2]; + const float32_t *xi = x; + const float32_t *yi = y; + + SUMM = vdupq_n_f32(0); + + /* Work on 16 values per iteration */ + while (len >= 16) { + XX[0] = vld1q_f32(xi); + xi += 4; + XX[1] = vld1q_f32(xi); + xi += 4; + XX[2] = vld1q_f32(xi); + xi += 4; + XX[3] = vld1q_f32(xi); + xi += 4; + + YY[0] = vld1q_f32(yi); + yi += 4; + YY[1] = vld1q_f32(yi); + yi += 4; + YY[2] = vld1q_f32(yi); + yi += 4; + YY[3] = vld1q_f32(yi); + yi += 4; + + SUMM = vmlaq_f32(SUMM, YY[0], XX[0]); + SUMM = vmlaq_f32(SUMM, YY[1], XX[1]); + SUMM = vmlaq_f32(SUMM, YY[2], XX[2]); + SUMM = vmlaq_f32(SUMM, YY[3], XX[3]); + len -= 16; + } + + /* Work on 8 values */ + if (len >= 8) { + XX[0] = vld1q_f32(xi); + xi += 4; + XX[1] = vld1q_f32(xi); + xi += 4; + + YY[0] = vld1q_f32(yi); + yi += 4; + YY[1] = vld1q_f32(yi); + yi += 4; + + SUMM = vmlaq_f32(SUMM, YY[0], XX[0]); + SUMM = vmlaq_f32(SUMM, YY[1], XX[1]); + len -= 8; + } + + /* Work on 4 values */ + if (len >= 4) { + XX[0] = vld1q_f32(xi); + xi += 4; + YY[0] = vld1q_f32(yi); + yi += 4; + SUMM = vmlaq_f32(SUMM, YY[0], XX[0]); + len -= 4; + } + + /* Start accumulating results */ + SUMM_2[0] = vget_low_f32(SUMM); + if (len >= 2) { + /* While at it, consume 2 more values if available */ + XX_2 = vld1_f32(xi); + xi += 2; + YY_2 = vld1_f32(yi); + yi += 2; + SUMM_2[0] = vmla_f32(SUMM_2[0], YY_2, XX_2); + len -= 2; + } + SUMM_2[1] = vget_high_f32(SUMM); + SUMM_2[0] = vadd_f32(SUMM_2[0], SUMM_2[1]); + SUMM_2[0] = vpadd_f32(SUMM_2[0], SUMM_2[0]); + /* Ok, now we have result accumulated in SUMM_2[0].0 */ + + if (len > 0) { + /* Case when you have one value left */ + XX_2 = vld1_dup_f32(xi); + YY_2 = vld1_dup_f32(yi); + SUMM_2[0] = vmla_f32(SUMM_2[0], XX_2, YY_2); + } + + vst1_lane_f32(sum, SUMM_2[0], 0); +} + +void celt_pitch_xcorr_float_neon(const opus_val16 *_x, const opus_val16 *_y, + opus_val32 *xcorr, int len, int max_pitch) { + int i; + celt_assert(max_pitch > 0); + celt_assert((((unsigned char *)_x-(unsigned char *)NULL)&3)==0); + + for (i = 0; i < (max_pitch-3); i += 4) { + xcorr_kernel_neon_float((const float32_t *)_x, (const float32_t *)_y+i, + (float32_t *)xcorr+i, len); + } + + /* In case max_pitch isn't multiple of 4 + * compute single correlation value per iteration + */ + for (; i < max_pitch; i++) { + xcorr_kernel_neon_float_process1((const float32_t *)_x, + (const float32_t *)_y+i, (float32_t *)xcorr+i, len); + } +} +#endif diff --git a/drivers/opus/celt/arm/celt_pitch_xcorr_arm-gnu.S b/drivers/opus/celt/arm/celt_pitch_xcorr_arm-gnu.S new file mode 100644 index 0000000000..5b2ee55a10 --- /dev/null +++ b/drivers/opus/celt/arm/celt_pitch_xcorr_arm-gnu.S @@ -0,0 +1,551 @@ + .syntax unified +@ Copyright (c) 2007-2008 CSIRO +@ Copyright (c) 2007-2009 Xiph.Org Foundation +@ Copyright (c) 2013 Parrot +@ Written by Aurélien Zanelli +@ +@ Redistribution and use in source and binary forms, with or without +@ modification, are permitted provided that the following conditions +@ are met: +@ +@ - Redistributions of source code must retain the above copyright +@ notice, this list of conditions and the following disclaimer. +@ +@ - Redistributions in binary form must reproduce the above copyright +@ notice, this list of conditions and the following disclaimer in the +@ documentation and/or other materials provided with the distribution. +@ +@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +@ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +@ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +@ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER +@ OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +@ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +@ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +@ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + .text; .p2align 2; .arch armv7-a + .fpu neon + .object_arch armv4t + + .include "celt/arm/armopts-gnu.S" + + .if OPUS_ARM_MAY_HAVE_EDSP + .global celt_pitch_xcorr_edsp + .endif + + .if OPUS_ARM_MAY_HAVE_NEON + .global celt_pitch_xcorr_neon + .endif + + .if OPUS_ARM_MAY_HAVE_NEON + +@ Compute sum[k]=sum(x[j]*y[j+k],j=0...len-1), k=0...3 +; xcorr_kernel_neon: @ PROC +xcorr_kernel_neon_start: + @ input: + @ r3 = int len + @ r4 = opus_val16 *x + @ r5 = opus_val16 *y + @ q0 = opus_val32 sum[4] + @ output: + @ q0 = opus_val32 sum[4] + @ preserved: r0-r3, r6-r11, d2, q4-q7, q9-q15 + @ internal usage: + @ r12 = int j + @ d3 = y_3|y_2|y_1|y_0 + @ q2 = y_B|y_A|y_9|y_8|y_7|y_6|y_5|y_4 + @ q3 = x_7|x_6|x_5|x_4|x_3|x_2|x_1|x_0 + @ q8 = scratch + @ + @ Load y[0...3] + @ This requires len>0 to always be valid (which we assert in the C code). + VLD1.16 {d5}, [r5]! + SUBS r12, r3, #8 + BLE xcorr_kernel_neon_process4 +@ Process 8 samples at a time. +@ This loop loads one y value more than we actually need. Therefore we have to +@ stop as soon as there are 8 or fewer samples left (instead of 7), to avoid +@ reading past the end of the array. +xcorr_kernel_neon_process8: + @ This loop has 19 total instructions (10 cycles to issue, minimum), with + @ - 2 cycles of ARM insrtuctions, + @ - 10 cycles of load/store/byte permute instructions, and + @ - 9 cycles of data processing instructions. + @ On a Cortex A8, we dual-issue the maximum amount (9 cycles) between the + @ latter two categories, meaning the whole loop should run in 10 cycles per + @ iteration, barring cache misses. + @ + @ Load x[0...7] + VLD1.16 {d6, d7}, [r4]! + @ Unlike VMOV, VAND is a data processsing instruction (and doesn't get + @ assembled to VMOV, like VORR would), so it dual-issues with the prior VLD1. + VAND d3, d5, d5 + SUBS r12, r12, #8 + @ Load y[4...11] + VLD1.16 {d4, d5}, [r5]! + VMLAL.S16 q0, d3, d6[0] + VEXT.16 d16, d3, d4, #1 + VMLAL.S16 q0, d4, d7[0] + VEXT.16 d17, d4, d5, #1 + VMLAL.S16 q0, d16, d6[1] + VEXT.16 d16, d3, d4, #2 + VMLAL.S16 q0, d17, d7[1] + VEXT.16 d17, d4, d5, #2 + VMLAL.S16 q0, d16, d6[2] + VEXT.16 d16, d3, d4, #3 + VMLAL.S16 q0, d17, d7[2] + VEXT.16 d17, d4, d5, #3 + VMLAL.S16 q0, d16, d6[3] + VMLAL.S16 q0, d17, d7[3] + BGT xcorr_kernel_neon_process8 +@ Process 4 samples here if we have > 4 left (still reading one extra y value). +xcorr_kernel_neon_process4: + ADDS r12, r12, #4 + BLE xcorr_kernel_neon_process2 + @ Load x[0...3] + VLD1.16 d6, [r4]! + @ Use VAND since it's a data processing instruction again. + VAND d4, d5, d5 + SUB r12, r12, #4 + @ Load y[4...7] + VLD1.16 d5, [r5]! + VMLAL.S16 q0, d4, d6[0] + VEXT.16 d16, d4, d5, #1 + VMLAL.S16 q0, d16, d6[1] + VEXT.16 d16, d4, d5, #2 + VMLAL.S16 q0, d16, d6[2] + VEXT.16 d16, d4, d5, #3 + VMLAL.S16 q0, d16, d6[3] +@ Process 2 samples here if we have > 2 left (still reading one extra y value). +xcorr_kernel_neon_process2: + ADDS r12, r12, #2 + BLE xcorr_kernel_neon_process1 + @ Load x[0...1] + VLD2.16 {d6[],d7[]}, [r4]! + @ Use VAND since it's a data processing instruction again. + VAND d4, d5, d5 + SUB r12, r12, #2 + @ Load y[4...5] + VLD1.32 {d5[]}, [r5]! + VMLAL.S16 q0, d4, d6 + VEXT.16 d16, d4, d5, #1 + @ Replace bottom copy of {y5,y4} in d5 with {y3,y2} from d4, using VSRI + @ instead of VEXT, since it's a data-processing instruction. + VSRI.64 d5, d4, #32 + VMLAL.S16 q0, d16, d7 +@ Process 1 sample using the extra y value we loaded above. +xcorr_kernel_neon_process1: + @ Load next *x + VLD1.16 {d6[]}, [r4]! + ADDS r12, r12, #1 + @ y[0...3] are left in d5 from prior iteration(s) (if any) + VMLAL.S16 q0, d5, d6 + MOVLE pc, lr +@ Now process 1 last sample, not reading ahead. + @ Load last *y + VLD1.16 {d4[]}, [r5]! + VSRI.64 d4, d5, #16 + @ Load last *x + VLD1.16 {d6[]}, [r4]! + VMLAL.S16 q0, d4, d6 + MOV pc, lr + .size xcorr_kernel_neon, .-xcorr_kernel_neon @ ENDP + +@ opus_val32 celt_pitch_xcorr_neon(opus_val16 *_x, opus_val16 *_y, +@ opus_val32 *xcorr, int len, int max_pitch) +; celt_pitch_xcorr_neon: @ PROC + @ input: + @ r0 = opus_val16 *_x + @ r1 = opus_val16 *_y + @ r2 = opus_val32 *xcorr + @ r3 = int len + @ output: + @ r0 = int maxcorr + @ internal usage: + @ r4 = opus_val16 *x (for xcorr_kernel_neon()) + @ r5 = opus_val16 *y (for xcorr_kernel_neon()) + @ r6 = int max_pitch + @ r12 = int j + @ q15 = int maxcorr[4] (q15 is not used by xcorr_kernel_neon()) + STMFD sp!, {r4-r6, lr} + LDR r6, [sp, #16] + VMOV.S32 q15, #1 + @ if (max_pitch < 4) goto celt_pitch_xcorr_neon_process4_done + SUBS r6, r6, #4 + BLT celt_pitch_xcorr_neon_process4_done +celt_pitch_xcorr_neon_process4: + @ xcorr_kernel_neon parameters: + @ r3 = len, r4 = _x, r5 = _y, q0 = {0, 0, 0, 0} + MOV r4, r0 + MOV r5, r1 + VEOR q0, q0, q0 + @ xcorr_kernel_neon only modifies r4, r5, r12, and q0...q3. + @ So we don't save/restore any other registers. + BL xcorr_kernel_neon_start + SUBS r6, r6, #4 + VST1.32 {q0}, [r2]! + @ _y += 4 + ADD r1, r1, #8 + VMAX.S32 q15, q15, q0 + @ if (max_pitch < 4) goto celt_pitch_xcorr_neon_process4_done + BGE celt_pitch_xcorr_neon_process4 +@ We have less than 4 sums left to compute. +celt_pitch_xcorr_neon_process4_done: + ADDS r6, r6, #4 + @ Reduce maxcorr to a single value + VMAX.S32 d30, d30, d31 + VPMAX.S32 d30, d30, d30 + @ if (max_pitch <= 0) goto celt_pitch_xcorr_neon_done + BLE celt_pitch_xcorr_neon_done +@ Now compute each remaining sum one at a time. +celt_pitch_xcorr_neon_process_remaining: + MOV r4, r0 + MOV r5, r1 + VMOV.I32 q0, #0 + SUBS r12, r3, #8 + BLT celt_pitch_xcorr_neon_process_remaining4 +@ Sum terms 8 at a time. +celt_pitch_xcorr_neon_process_remaining_loop8: + @ Load x[0...7] + VLD1.16 {q1}, [r4]! + @ Load y[0...7] + VLD1.16 {q2}, [r5]! + SUBS r12, r12, #8 + VMLAL.S16 q0, d4, d2 + VMLAL.S16 q0, d5, d3 + BGE celt_pitch_xcorr_neon_process_remaining_loop8 +@ Sum terms 4 at a time. +celt_pitch_xcorr_neon_process_remaining4: + ADDS r12, r12, #4 + BLT celt_pitch_xcorr_neon_process_remaining4_done + @ Load x[0...3] + VLD1.16 {d2}, [r4]! + @ Load y[0...3] + VLD1.16 {d3}, [r5]! + SUB r12, r12, #4 + VMLAL.S16 q0, d3, d2 +celt_pitch_xcorr_neon_process_remaining4_done: + @ Reduce the sum to a single value. + VADD.S32 d0, d0, d1 + VPADDL.S32 d0, d0 + ADDS r12, r12, #4 + BLE celt_pitch_xcorr_neon_process_remaining_loop_done +@ Sum terms 1 at a time. +celt_pitch_xcorr_neon_process_remaining_loop1: + VLD1.16 {d2[]}, [r4]! + VLD1.16 {d3[]}, [r5]! + SUBS r12, r12, #1 + VMLAL.S16 q0, d2, d3 + BGT celt_pitch_xcorr_neon_process_remaining_loop1 +celt_pitch_xcorr_neon_process_remaining_loop_done: + VST1.32 {d0[0]}, [r2]! + VMAX.S32 d30, d30, d0 + SUBS r6, r6, #1 + @ _y++ + ADD r1, r1, #2 + @ if (--max_pitch > 0) goto celt_pitch_xcorr_neon_process_remaining + BGT celt_pitch_xcorr_neon_process_remaining +celt_pitch_xcorr_neon_done: + VMOV.32 r0, d30[0] + LDMFD sp!, {r4-r6, pc} + .size celt_pitch_xcorr_neon, .-celt_pitch_xcorr_neon @ ENDP + + .endif + + .if OPUS_ARM_MAY_HAVE_EDSP + +@ This will get used on ARMv7 devices without NEON, so it has been optimized +@ to take advantage of dual-issuing where possible. +; xcorr_kernel_edsp: @ PROC +xcorr_kernel_edsp_start: + @ input: + @ r3 = int len + @ r4 = opus_val16 *_x (must be 32-bit aligned) + @ r5 = opus_val16 *_y (must be 32-bit aligned) + @ r6...r9 = opus_val32 sum[4] + @ output: + @ r6...r9 = opus_val32 sum[4] + @ preserved: r0-r5 + @ internal usage + @ r2 = int j + @ r12,r14 = opus_val16 x[4] + @ r10,r11 = opus_val16 y[4] + STMFD sp!, {r2,r4,r5,lr} + LDR r10, [r5], #4 @ Load y[0...1] + SUBS r2, r3, #4 @ j = len-4 + LDR r11, [r5], #4 @ Load y[2...3] + BLE xcorr_kernel_edsp_process4_done + LDR r12, [r4], #4 @ Load x[0...1] + @ Stall +xcorr_kernel_edsp_process4: + @ The multiplies must issue from pipeline 0, and can't dual-issue with each + @ other. Every other instruction here dual-issues with a multiply, and is + @ thus "free". There should be no stalls in the body of the loop. + SMLABB r6, r12, r10, r6 @ sum[0] = MAC16_16(sum[0],x_0,y_0) + LDR r14, [r4], #4 @ Load x[2...3] + SMLABT r7, r12, r10, r7 @ sum[1] = MAC16_16(sum[1],x_0,y_1) + SUBS r2, r2, #4 @ j-=4 + SMLABB r8, r12, r11, r8 @ sum[2] = MAC16_16(sum[2],x_0,y_2) + SMLABT r9, r12, r11, r9 @ sum[3] = MAC16_16(sum[3],x_0,y_3) + SMLATT r6, r12, r10, r6 @ sum[0] = MAC16_16(sum[0],x_1,y_1) + LDR r10, [r5], #4 @ Load y[4...5] + SMLATB r7, r12, r11, r7 @ sum[1] = MAC16_16(sum[1],x_1,y_2) + SMLATT r8, r12, r11, r8 @ sum[2] = MAC16_16(sum[2],x_1,y_3) + SMLATB r9, r12, r10, r9 @ sum[3] = MAC16_16(sum[3],x_1,y_4) + LDRGT r12, [r4], #4 @ Load x[0...1] + SMLABB r6, r14, r11, r6 @ sum[0] = MAC16_16(sum[0],x_2,y_2) + SMLABT r7, r14, r11, r7 @ sum[1] = MAC16_16(sum[1],x_2,y_3) + SMLABB r8, r14, r10, r8 @ sum[2] = MAC16_16(sum[2],x_2,y_4) + SMLABT r9, r14, r10, r9 @ sum[3] = MAC16_16(sum[3],x_2,y_5) + SMLATT r6, r14, r11, r6 @ sum[0] = MAC16_16(sum[0],x_3,y_3) + LDR r11, [r5], #4 @ Load y[6...7] + SMLATB r7, r14, r10, r7 @ sum[1] = MAC16_16(sum[1],x_3,y_4) + SMLATT r8, r14, r10, r8 @ sum[2] = MAC16_16(sum[2],x_3,y_5) + SMLATB r9, r14, r11, r9 @ sum[3] = MAC16_16(sum[3],x_3,y_6) + BGT xcorr_kernel_edsp_process4 +xcorr_kernel_edsp_process4_done: + ADDS r2, r2, #4 + BLE xcorr_kernel_edsp_done + LDRH r12, [r4], #2 @ r12 = *x++ + SUBS r2, r2, #1 @ j-- + @ Stall + SMLABB r6, r12, r10, r6 @ sum[0] = MAC16_16(sum[0],x,y_0) + LDRHGT r14, [r4], #2 @ r14 = *x++ + SMLABT r7, r12, r10, r7 @ sum[1] = MAC16_16(sum[1],x,y_1) + SMLABB r8, r12, r11, r8 @ sum[2] = MAC16_16(sum[2],x,y_2) + SMLABT r9, r12, r11, r9 @ sum[3] = MAC16_16(sum[3],x,y_3) + BLE xcorr_kernel_edsp_done + SMLABT r6, r14, r10, r6 @ sum[0] = MAC16_16(sum[0],x,y_1) + SUBS r2, r2, #1 @ j-- + SMLABB r7, r14, r11, r7 @ sum[1] = MAC16_16(sum[1],x,y_2) + LDRH r10, [r5], #2 @ r10 = y_4 = *y++ + SMLABT r8, r14, r11, r8 @ sum[2] = MAC16_16(sum[2],x,y_3) + LDRHGT r12, [r4], #2 @ r12 = *x++ + SMLABB r9, r14, r10, r9 @ sum[3] = MAC16_16(sum[3],x,y_4) + BLE xcorr_kernel_edsp_done + SMLABB r6, r12, r11, r6 @ sum[0] = MAC16_16(sum[0],tmp,y_2) + CMP r2, #1 @ j-- + SMLABT r7, r12, r11, r7 @ sum[1] = MAC16_16(sum[1],tmp,y_3) + LDRH r2, [r5], #2 @ r2 = y_5 = *y++ + SMLABB r8, r12, r10, r8 @ sum[2] = MAC16_16(sum[2],tmp,y_4) + LDRHGT r14, [r4] @ r14 = *x + SMLABB r9, r12, r2, r9 @ sum[3] = MAC16_16(sum[3],tmp,y_5) + BLE xcorr_kernel_edsp_done + SMLABT r6, r14, r11, r6 @ sum[0] = MAC16_16(sum[0],tmp,y_3) + LDRH r11, [r5] @ r11 = y_6 = *y + SMLABB r7, r14, r10, r7 @ sum[1] = MAC16_16(sum[1],tmp,y_4) + SMLABB r8, r14, r2, r8 @ sum[2] = MAC16_16(sum[2],tmp,y_5) + SMLABB r9, r14, r11, r9 @ sum[3] = MAC16_16(sum[3],tmp,y_6) +xcorr_kernel_edsp_done: + LDMFD sp!, {r2,r4,r5,pc} + .size xcorr_kernel_edsp, .-xcorr_kernel_edsp @ ENDP + +; celt_pitch_xcorr_edsp: @ PROC + @ input: + @ r0 = opus_val16 *_x (must be 32-bit aligned) + @ r1 = opus_val16 *_y (only needs to be 16-bit aligned) + @ r2 = opus_val32 *xcorr + @ r3 = int len + @ output: + @ r0 = maxcorr + @ internal usage + @ r4 = opus_val16 *x + @ r5 = opus_val16 *y + @ r6 = opus_val32 sum0 + @ r7 = opus_val32 sum1 + @ r8 = opus_val32 sum2 + @ r9 = opus_val32 sum3 + @ r1 = int max_pitch + @ r12 = int j + STMFD sp!, {r4-r11, lr} + MOV r5, r1 + LDR r1, [sp, #36] + MOV r4, r0 + TST r5, #3 + @ maxcorr = 1 + MOV r0, #1 + BEQ celt_pitch_xcorr_edsp_process1u_done +@ Compute one sum at the start to make y 32-bit aligned. + SUBS r12, r3, #4 + @ r14 = sum = 0 + MOV r14, #0 + LDRH r8, [r5], #2 + BLE celt_pitch_xcorr_edsp_process1u_loop4_done + LDR r6, [r4], #4 + MOV r8, r8, LSL #16 +celt_pitch_xcorr_edsp_process1u_loop4: + LDR r9, [r5], #4 + SMLABT r14, r6, r8, r14 @ sum = MAC16_16(sum, x_0, y_0) + LDR r7, [r4], #4 + SMLATB r14, r6, r9, r14 @ sum = MAC16_16(sum, x_1, y_1) + LDR r8, [r5], #4 + SMLABT r14, r7, r9, r14 @ sum = MAC16_16(sum, x_2, y_2) + SUBS r12, r12, #4 @ j-=4 + SMLATB r14, r7, r8, r14 @ sum = MAC16_16(sum, x_3, y_3) + LDRGT r6, [r4], #4 + BGT celt_pitch_xcorr_edsp_process1u_loop4 + MOV r8, r8, LSR #16 +celt_pitch_xcorr_edsp_process1u_loop4_done: + ADDS r12, r12, #4 +celt_pitch_xcorr_edsp_process1u_loop1: + LDRHGE r6, [r4], #2 + @ Stall + SMLABBGE r14, r6, r8, r14 @ sum = MAC16_16(sum, *x, *y) + SUBSGE r12, r12, #1 + LDRHGT r8, [r5], #2 + BGT celt_pitch_xcorr_edsp_process1u_loop1 + @ Restore _x + SUB r4, r4, r3, LSL #1 + @ Restore and advance _y + SUB r5, r5, r3, LSL #1 + @ maxcorr = max(maxcorr, sum) + CMP r0, r14 + ADD r5, r5, #2 + MOVLT r0, r14 + SUBS r1, r1, #1 + @ xcorr[i] = sum + STR r14, [r2], #4 + BLE celt_pitch_xcorr_edsp_done +celt_pitch_xcorr_edsp_process1u_done: + @ if (max_pitch < 4) goto celt_pitch_xcorr_edsp_process2 + SUBS r1, r1, #4 + BLT celt_pitch_xcorr_edsp_process2 +celt_pitch_xcorr_edsp_process4: + @ xcorr_kernel_edsp parameters: + @ r3 = len, r4 = _x, r5 = _y, r6...r9 = sum[4] = {0, 0, 0, 0} + MOV r6, #0 + MOV r7, #0 + MOV r8, #0 + MOV r9, #0 + BL xcorr_kernel_edsp_start @ xcorr_kernel_edsp(_x, _y+i, xcorr+i, len) + @ maxcorr = max(maxcorr, sum0, sum1, sum2, sum3) + CMP r0, r6 + @ _y+=4 + ADD r5, r5, #8 + MOVLT r0, r6 + CMP r0, r7 + MOVLT r0, r7 + CMP r0, r8 + MOVLT r0, r8 + CMP r0, r9 + MOVLT r0, r9 + STMIA r2!, {r6-r9} + SUBS r1, r1, #4 + BGE celt_pitch_xcorr_edsp_process4 +celt_pitch_xcorr_edsp_process2: + ADDS r1, r1, #2 + BLT celt_pitch_xcorr_edsp_process1a + SUBS r12, r3, #4 + @ {r10, r11} = {sum0, sum1} = {0, 0} + MOV r10, #0 + MOV r11, #0 + LDR r8, [r5], #4 + BLE celt_pitch_xcorr_edsp_process2_loop_done + LDR r6, [r4], #4 + LDR r9, [r5], #4 +celt_pitch_xcorr_edsp_process2_loop4: + SMLABB r10, r6, r8, r10 @ sum0 = MAC16_16(sum0, x_0, y_0) + LDR r7, [r4], #4 + SMLABT r11, r6, r8, r11 @ sum1 = MAC16_16(sum1, x_0, y_1) + SUBS r12, r12, #4 @ j-=4 + SMLATT r10, r6, r8, r10 @ sum0 = MAC16_16(sum0, x_1, y_1) + LDR r8, [r5], #4 + SMLATB r11, r6, r9, r11 @ sum1 = MAC16_16(sum1, x_1, y_2) + LDRGT r6, [r4], #4 + SMLABB r10, r7, r9, r10 @ sum0 = MAC16_16(sum0, x_2, y_2) + SMLABT r11, r7, r9, r11 @ sum1 = MAC16_16(sum1, x_2, y_3) + SMLATT r10, r7, r9, r10 @ sum0 = MAC16_16(sum0, x_3, y_3) + LDRGT r9, [r5], #4 + SMLATB r11, r7, r8, r11 @ sum1 = MAC16_16(sum1, x_3, y_4) + BGT celt_pitch_xcorr_edsp_process2_loop4 +celt_pitch_xcorr_edsp_process2_loop_done: + ADDS r12, r12, #2 + BLE celt_pitch_xcorr_edsp_process2_1 + LDR r6, [r4], #4 + @ Stall + SMLABB r10, r6, r8, r10 @ sum0 = MAC16_16(sum0, x_0, y_0) + LDR r9, [r5], #4 + SMLABT r11, r6, r8, r11 @ sum1 = MAC16_16(sum1, x_0, y_1) + SUB r12, r12, #2 + SMLATT r10, r6, r8, r10 @ sum0 = MAC16_16(sum0, x_1, y_1) + MOV r8, r9 + SMLATB r11, r6, r9, r11 @ sum1 = MAC16_16(sum1, x_1, y_2) +celt_pitch_xcorr_edsp_process2_1: + LDRH r6, [r4], #2 + ADDS r12, r12, #1 + @ Stall + SMLABB r10, r6, r8, r10 @ sum0 = MAC16_16(sum0, x_0, y_0) + LDRHGT r7, [r4], #2 + SMLABT r11, r6, r8, r11 @ sum1 = MAC16_16(sum1, x_0, y_1) + BLE celt_pitch_xcorr_edsp_process2_done + LDRH r9, [r5], #2 + SMLABT r10, r7, r8, r10 @ sum0 = MAC16_16(sum0, x_0, y_1) + SMLABB r11, r7, r9, r11 @ sum1 = MAC16_16(sum1, x_0, y_2) +celt_pitch_xcorr_edsp_process2_done: + @ Restore _x + SUB r4, r4, r3, LSL #1 + @ Restore and advance _y + SUB r5, r5, r3, LSL #1 + @ maxcorr = max(maxcorr, sum0) + CMP r0, r10 + ADD r5, r5, #2 + MOVLT r0, r10 + SUB r1, r1, #2 + @ maxcorr = max(maxcorr, sum1) + CMP r0, r11 + @ xcorr[i] = sum + STR r10, [r2], #4 + MOVLT r0, r11 + STR r11, [r2], #4 +celt_pitch_xcorr_edsp_process1a: + ADDS r1, r1, #1 + BLT celt_pitch_xcorr_edsp_done + SUBS r12, r3, #4 + @ r14 = sum = 0 + MOV r14, #0 + BLT celt_pitch_xcorr_edsp_process1a_loop_done + LDR r6, [r4], #4 + LDR r8, [r5], #4 + LDR r7, [r4], #4 + LDR r9, [r5], #4 +celt_pitch_xcorr_edsp_process1a_loop4: + SMLABB r14, r6, r8, r14 @ sum = MAC16_16(sum, x_0, y_0) + SUBS r12, r12, #4 @ j-=4 + SMLATT r14, r6, r8, r14 @ sum = MAC16_16(sum, x_1, y_1) + LDRGE r6, [r4], #4 + SMLABB r14, r7, r9, r14 @ sum = MAC16_16(sum, x_2, y_2) + LDRGE r8, [r5], #4 + SMLATT r14, r7, r9, r14 @ sum = MAC16_16(sum, x_3, y_3) + LDRGE r7, [r4], #4 + LDRGE r9, [r5], #4 + BGE celt_pitch_xcorr_edsp_process1a_loop4 +celt_pitch_xcorr_edsp_process1a_loop_done: + ADDS r12, r12, #2 + LDRGE r6, [r4], #4 + LDRGE r8, [r5], #4 + @ Stall + SMLABBGE r14, r6, r8, r14 @ sum = MAC16_16(sum, x_0, y_0) + SUBGE r12, r12, #2 + SMLATTGE r14, r6, r8, r14 @ sum = MAC16_16(sum, x_1, y_1) + ADDS r12, r12, #1 + LDRHGE r6, [r4], #2 + LDRHGE r8, [r5], #2 + @ Stall + SMLABBGE r14, r6, r8, r14 @ sum = MAC16_16(sum, *x, *y) + @ maxcorr = max(maxcorr, sum) + CMP r0, r14 + @ xcorr[i] = sum + STR r14, [r2], #4 + MOVLT r0, r14 +celt_pitch_xcorr_edsp_done: + LDMFD sp!, {r4-r11, pc} + .size celt_pitch_xcorr_edsp, .-celt_pitch_xcorr_edsp @ ENDP + + .endif + +@ END: + .section .note.GNU-stack,"",%progbits diff --git a/drivers/opus/celt/arm/celt_pitch_xcorr_arm.s b/drivers/opus/celt/arm/celt_pitch_xcorr_arm.s index 09917b16bf..f96e0a88bb 100644 --- a/drivers/opus/celt/arm/celt_pitch_xcorr_arm.s +++ b/drivers/opus/celt/arm/celt_pitch_xcorr_arm.s @@ -42,6 +42,7 @@ IF OPUS_ARM_MAY_HAVE_NEON ; Compute sum[k]=sum(x[j]*y[j+k],j=0...len-1), k=0...3 xcorr_kernel_neon PROC +xcorr_kernel_neon_start ; input: ; r3 = int len ; r4 = opus_val16 *x @@ -181,7 +182,7 @@ celt_pitch_xcorr_neon_process4 VEOR q0, q0, q0 ; xcorr_kernel_neon only modifies r4, r5, r12, and q0...q3. ; So we don't save/restore any other registers. - BL xcorr_kernel_neon + BL xcorr_kernel_neon_start SUBS r6, r6, #4 VST1.32 {q0}, [r2]! ; _y += 4 @@ -257,6 +258,7 @@ IF OPUS_ARM_MAY_HAVE_EDSP ; This will get used on ARMv7 devices without NEON, so it has been optimized ; to take advantage of dual-issuing where possible. xcorr_kernel_edsp PROC +xcorr_kernel_edsp_start ; input: ; r3 = int len ; r4 = opus_val16 *_x (must be 32-bit aligned) @@ -309,7 +311,7 @@ xcorr_kernel_edsp_process4_done SUBS r2, r2, #1 ; j-- ; Stall SMLABB r6, r12, r10, r6 ; sum[0] = MAC16_16(sum[0],x,y_0) - LDRGTH r14, [r4], #2 ; r14 = *x++ + LDRHGT r14, [r4], #2 ; r14 = *x++ SMLABT r7, r12, r10, r7 ; sum[1] = MAC16_16(sum[1],x,y_1) SMLABB r8, r12, r11, r8 ; sum[2] = MAC16_16(sum[2],x,y_2) SMLABT r9, r12, r11, r9 ; sum[3] = MAC16_16(sum[3],x,y_3) @@ -319,7 +321,7 @@ xcorr_kernel_edsp_process4_done SMLABB r7, r14, r11, r7 ; sum[1] = MAC16_16(sum[1],x,y_2) LDRH r10, [r5], #2 ; r10 = y_4 = *y++ SMLABT r8, r14, r11, r8 ; sum[2] = MAC16_16(sum[2],x,y_3) - LDRGTH r12, [r4], #2 ; r12 = *x++ + LDRHGT r12, [r4], #2 ; r12 = *x++ SMLABB r9, r14, r10, r9 ; sum[3] = MAC16_16(sum[3],x,y_4) BLE xcorr_kernel_edsp_done SMLABB r6, r12, r11, r6 ; sum[0] = MAC16_16(sum[0],tmp,y_2) @@ -327,7 +329,7 @@ xcorr_kernel_edsp_process4_done SMLABT r7, r12, r11, r7 ; sum[1] = MAC16_16(sum[1],tmp,y_3) LDRH r2, [r5], #2 ; r2 = y_5 = *y++ SMLABB r8, r12, r10, r8 ; sum[2] = MAC16_16(sum[2],tmp,y_4) - LDRGTH r14, [r4] ; r14 = *x + LDRHGT r14, [r4] ; r14 = *x SMLABB r9, r12, r2, r9 ; sum[3] = MAC16_16(sum[3],tmp,y_5) BLE xcorr_kernel_edsp_done SMLABT r6, r14, r11, r6 ; sum[0] = MAC16_16(sum[0],tmp,y_3) @@ -387,11 +389,11 @@ celt_pitch_xcorr_edsp_process1u_loop4 celt_pitch_xcorr_edsp_process1u_loop4_done ADDS r12, r12, #4 celt_pitch_xcorr_edsp_process1u_loop1 - LDRGEH r6, [r4], #2 + LDRHGE r6, [r4], #2 ; Stall SMLABBGE r14, r6, r8, r14 ; sum = MAC16_16(sum, *x, *y) - SUBGES r12, r12, #1 - LDRGTH r8, [r5], #2 + SUBSGE r12, r12, #1 + LDRHGT r8, [r5], #2 BGT celt_pitch_xcorr_edsp_process1u_loop1 ; Restore _x SUB r4, r4, r3, LSL #1 @@ -416,7 +418,7 @@ celt_pitch_xcorr_edsp_process4 MOV r7, #0 MOV r8, #0 MOV r9, #0 - BL xcorr_kernel_edsp ; xcorr_kernel_edsp(_x, _y+i, xcorr+i, len) + BL xcorr_kernel_edsp_start ; xcorr_kernel_edsp(_x, _y+i, xcorr+i, len) ; maxcorr = max(maxcorr, sum0, sum1, sum2, sum3) CMP r0, r6 ; _y+=4 @@ -474,7 +476,7 @@ celt_pitch_xcorr_edsp_process2_1 ADDS r12, r12, #1 ; Stall SMLABB r10, r6, r8, r10 ; sum0 = MAC16_16(sum0, x_0, y_0) - LDRGTH r7, [r4], #2 + LDRHGT r7, [r4], #2 SMLABT r11, r6, r8, r11 ; sum1 = MAC16_16(sum1, x_0, y_1) BLE celt_pitch_xcorr_edsp_process2_done LDRH r9, [r5], #2 @@ -527,8 +529,8 @@ celt_pitch_xcorr_edsp_process1a_loop_done SUBGE r12, r12, #2 SMLATTGE r14, r6, r8, r14 ; sum = MAC16_16(sum, x_1, y_1) ADDS r12, r12, #1 - LDRGEH r6, [r4], #2 - LDRGEH r8, [r5], #2 + LDRHGE r6, [r4], #2 + LDRHGE r8, [r5], #2 ; Stall SMLABBGE r14, r6, r8, r14 ; sum = MAC16_16(sum, *x, *y) ; maxcorr = max(maxcorr, sum) diff --git a/drivers/opus/celt/arm/armopts.s b/drivers/opus/celt/arm/fft_arm.h index fb9196072a..c99458b4af 100644 --- a/drivers/opus/celt/arm/armopts.s +++ b/drivers/opus/celt/arm/fft_arm.h @@ -1,4 +1,10 @@ -/* Copyright (C) 2013 Mozilla Corporation */ +/* Copyright (c) 2015 Xiph.Org Foundation + Written by Viswanath Puttagunta */ +/** + @file fft_arm.h + @brief ARM Neon Intrinsic optimizations for fft using NE10 library + */ + /* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -24,14 +30,43 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -; Set the following to 1 if we have EDSP instructions -; (LDRD/STRD, etc., ARMv5E and later). -OPUS_ARM_MAY_HAVE_EDSP * -; Set the following to 1 if we have ARMv6 media instructions. -OPUS_ARM_MAY_HAVE_MEDIA * +#if !defined(FFT_ARM_H) +#define FFT_ARM_H + +#include "opus/opus_config.h" +#include "opus/celt/kiss_fft.h" + +#if defined(HAVE_ARM_NE10) + +int opus_fft_alloc_arm_neon(kiss_fft_state *st); +void opus_fft_free_arm_neon(kiss_fft_state *st); + +void opus_fft_neon(const kiss_fft_state *st, + const kiss_fft_cpx *fin, + kiss_fft_cpx *fout); + +void opus_ifft_neon(const kiss_fft_state *st, + const kiss_fft_cpx *fin, + kiss_fft_cpx *fout); + +#if !defined(OPUS_HAVE_RTCD) +#define OVERRIDE_OPUS_FFT (1) + +#define opus_fft_alloc_arch(_st, arch) \ + ((void)(arch), opus_fft_alloc_arm_neon(_st)) + +#define opus_fft_free_arch(_st, arch) \ + ((void)(arch), opus_fft_free_arm_neon(_st)) + +#define opus_fft(_st, _fin, _fout, arch) \ + ((void)(arch), opus_fft_neon(_st, _fin, _fout)) + +#define opus_ifft(_st, _fin, _fout, arch) \ + ((void)(arch), opus_ifft_neon(_st, _fin, _fout)) + +#endif /* OPUS_HAVE_RTCD */ -; Set the following to 1 if we have NEON (some ARMv7) -OPUS_ARM_MAY_HAVE_NEON * +#endif /* HAVE_ARM_NE10 */ -END +#endif diff --git a/drivers/opus/celt/arm/fixed_armv4.h b/drivers/opus/celt/arm/fixed_armv4.h index b690bc8cea..efb3b1896a 100644 --- a/drivers/opus/celt/arm/fixed_armv4.h +++ b/drivers/opus/celt/arm/fixed_armv4.h @@ -68,6 +68,10 @@ static OPUS_INLINE opus_val32 MULT16_32_Q15_armv4(opus_val16 a, opus_val32 b) #undef MAC16_32_Q15 #define MAC16_32_Q15(c, a, b) ADD32(c, MULT16_32_Q15(a, b)) +/** 16x32 multiply, followed by a 16-bit shift right and 32-bit add. + Result fits in 32 bits. */ +#undef MAC16_32_Q16 +#define MAC16_32_Q16(c, a, b) ADD32(c, MULT16_32_Q16(a, b)) /** 32x32 multiplication, followed by a 31-bit shift right. Results fits in 32 bits */ #undef MULT32_32_Q31 diff --git a/drivers/opus/celt/arm/fixed_armv5e.h b/drivers/opus/celt/arm/fixed_armv5e.h index cb6e4c1da9..2db23262e8 100644 --- a/drivers/opus/celt/arm/fixed_armv5e.h +++ b/drivers/opus/celt/arm/fixed_armv5e.h @@ -82,6 +82,23 @@ static OPUS_INLINE opus_val32 MAC16_32_Q15_armv5e(opus_val32 c, opus_val16 a, } #define MAC16_32_Q15(c, a, b) (MAC16_32_Q15_armv5e(c, a, b)) +/** 16x32 multiply, followed by a 16-bit shift right and 32-bit add. + Result fits in 32 bits. */ +#undef MAC16_32_Q16 +static OPUS_INLINE opus_val32 MAC16_32_Q16_armv5e(opus_val32 c, opus_val16 a, + opus_val32 b) +{ + int res; + __asm__( + "#MAC16_32_Q16\n\t" + "smlawb %0, %1, %2, %3;\n" + : "=r"(res) + : "r"(b), "r"(a), "r"(c) + ); + return res; +} +#define MAC16_32_Q16(c, a, b) (MAC16_32_Q16_armv5e(c, a, b)) + /** 16x16 multiply-add where the result fits in 32 bits */ #undef MAC16_16 static OPUS_INLINE opus_val32 MAC16_16_armv5e(opus_val32 c, opus_val16 a, @@ -113,4 +130,22 @@ static OPUS_INLINE opus_val32 MULT16_16_armv5e(opus_val16 a, opus_val16 b) } #define MULT16_16(a, b) (MULT16_16_armv5e(a, b)) +#ifdef OPUS_ARM_INLINE_MEDIA + +#undef SIG2WORD16 +static OPUS_INLINE opus_val16 SIG2WORD16_armv6(opus_val32 x) +{ + celt_sig res; + __asm__( + "#SIG2WORD16\n\t" + "ssat %0, #16, %1, ASR #12\n\t" + : "=r"(res) + : "r"(x+2048) + ); + return EXTRACT16(res); +} +#define SIG2WORD16(x) (SIG2WORD16_armv6(x)) + +#endif /* OPUS_ARM_INLINE_MEDIA */ + #endif diff --git a/drivers/opus/celt/arm/kiss_fft_armv4.h b/drivers/opus/celt/arm/kiss_fft_armv4.h index 773464628b..0f5617324d 100644 --- a/drivers/opus/celt/arm/kiss_fft_armv4.h +++ b/drivers/opus/celt/arm/kiss_fft_armv4.h @@ -116,6 +116,6 @@ } \ while(0) -#endif /* OPUS_FIXED_POINT */ +#endif /* FIXED_POINT */ #endif /* KISS_FFT_ARMv4_H */ diff --git a/drivers/opus/celt/arm/kiss_fft_armv5e.h b/drivers/opus/celt/arm/kiss_fft_armv5e.h index 1eff56a66a..0ab75fbc58 100644 --- a/drivers/opus/celt/arm/kiss_fft_armv5e.h +++ b/drivers/opus/celt/arm/kiss_fft_armv5e.h @@ -113,6 +113,6 @@ } \ while(0) -#endif /* OPUS_FIXED_POINT */ +#endif /* FIXED_POINT */ #endif /* KISS_FFT_GUTS_H */ diff --git a/drivers/opus/celt/arm/mdct_arm.h b/drivers/opus/celt/arm/mdct_arm.h new file mode 100644 index 0000000000..faf3c8acab --- /dev/null +++ b/drivers/opus/celt/arm/mdct_arm.h @@ -0,0 +1,60 @@ +/* Copyright (c) 2015 Xiph.Org Foundation + Written by Viswanath Puttagunta */ +/** + @file arm_mdct.h + @brief ARM Neon Intrinsic optimizations for mdct using NE10 library + */ + +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#if !defined(MDCT_ARM_H) +#define MDCT_ARM_H + +#include "opus/opus_config.h" +#include "opus/celt/mdct.h" + +#if defined(HAVE_ARM_NE10) +/** Compute a forward MDCT and scale by 4/N, trashes the input array */ +void clt_mdct_forward_neon(const mdct_lookup *l, kiss_fft_scalar *in, + kiss_fft_scalar * OPUS_RESTRICT out, + const opus_val16 *window, int overlap, + int shift, int stride, int arch); + +void clt_mdct_backward_neon(const mdct_lookup *l, kiss_fft_scalar *in, + kiss_fft_scalar * OPUS_RESTRICT out, + const opus_val16 *window, int overlap, + int shift, int stride, int arch); + +#if !defined(OPUS_HAVE_RTCD) +#define OVERRIDE_OPUS_MDCT (1) +#define clt_mdct_forward(_l, _in, _out, _window, _int, _shift, _stride, _arch) \ + clt_mdct_forward_neon(_l, _in, _out, _window, _int, _shift, _stride, _arch) +#define clt_mdct_backward(_l, _in, _out, _window, _int, _shift, _stride, _arch) \ + clt_mdct_backward_neon(_l, _in, _out, _window, _int, _shift, _stride, _arch) +#endif /* OPUS_HAVE_RTCD */ +#endif /* HAVE_ARM_NE10 */ + +#endif diff --git a/drivers/opus/celt/arm/pitch_arm.h b/drivers/opus/celt/arm/pitch_arm.h index 18d1f2e75e..996fbc7fd9 100644 --- a/drivers/opus/celt/arm/pitch_arm.h +++ b/drivers/opus/celt/arm/pitch_arm.h @@ -30,7 +30,7 @@ # include "opus/celt/arm/armcpu.h" -# if defined(OPUS_FIXED_POINT) +# if defined(FIXED_POINT) # if defined(OPUS_ARM_MAY_HAVE_NEON) opus_val32 celt_pitch_xcorr_neon(const opus_val16 *_x, const opus_val16 *_y, @@ -52,6 +52,17 @@ opus_val32 celt_pitch_xcorr_edsp(const opus_val16 *_x, const opus_val16 *_y, ((void)(arch),PRESUME_NEON(celt_pitch_xcorr)(_x, _y, xcorr, len, max_pitch)) # endif -# endif +#else /* Start !FIXED_POINT */ +/* Float case */ +#if defined(OPUS_ARM_MAY_HAVE_NEON_INTR) +void celt_pitch_xcorr_float_neon(const opus_val16 *_x, const opus_val16 *_y, + opus_val32 *xcorr, int len, int max_pitch); +#if !defined(OPUS_HAVE_RTCD) || defined(OPUS_ARM_PRESUME_NEON_INTR) +#define OVERRIDE_PITCH_XCORR (1) +# define celt_pitch_xcorr(_x, _y, xcorr, len, max_pitch, arch) \ + ((void)(arch),celt_pitch_xcorr_float_neon(_x, _y, xcorr, len, max_pitch)) +#endif +#endif +#endif /* end !FIXED_POINT */ #endif diff --git a/drivers/opus/celt/bands.c b/drivers/opus/celt/bands.c index 5a6b23d87f..bdd87dd327 100644 --- a/drivers/opus/celt/bands.c +++ b/drivers/opus/celt/bands.c @@ -26,14 +26,11 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include <math.h> #include "opus/celt/bands.h" -#include "opus/celt/opus_modes.h" +#include "opus/celt/modes.h" #include "opus/celt/vq.h" #include "opus/celt/cwrs.h" #include "opus/celt/stack_alloc.h" @@ -92,11 +89,11 @@ static int bitexact_log2tan(int isin,int icos) #ifdef OPUS_FIXED_POINT /* Compute the amplitude (sqrt energy) in each of the bands */ -void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *bandE, int end, int C, int M) +void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *bandE, int end, int C, int LM) { int i, c, N; const opus_int16 *eBands = m->eBands; - N = M*m->shortMdctSize; + N = m->shortMdctSize<<LM; c=0; do { for (i=0;i<end;i++) { @@ -104,18 +101,23 @@ void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *band opus_val32 maxval=0; opus_val32 sum = 0; - j=M*eBands[i]; do { - maxval = MAX32(maxval, X[j+c*N]); - maxval = MAX32(maxval, -X[j+c*N]); - } while (++j<M*eBands[i+1]); - + maxval = celt_maxabs32(&X[c*N+(eBands[i]<<LM)], (eBands[i+1]-eBands[i])<<LM); if (maxval > 0) { - int shift = celt_ilog2(maxval)-10; - j=M*eBands[i]; do { - sum = MAC16_16(sum, EXTRACT16(VSHR32(X[j+c*N],shift)), - EXTRACT16(VSHR32(X[j+c*N],shift))); - } while (++j<M*eBands[i+1]); + int shift = celt_ilog2(maxval) - 14 + (((m->logN[i]>>BITRES)+LM+1)>>1); + j=eBands[i]<<LM; + if (shift>0) + { + do { + sum = MAC16_16(sum, EXTRACT16(SHR32(X[j+c*N],shift)), + EXTRACT16(SHR32(X[j+c*N],shift))); + } while (++j<eBands[i+1]<<LM); + } else { + do { + sum = MAC16_16(sum, EXTRACT16(SHL32(X[j+c*N],-shift)), + EXTRACT16(SHL32(X[j+c*N],-shift))); + } while (++j<eBands[i+1]<<LM); + } /* We're adding one here to ensure the normalized band isn't larger than unity norm */ bandE[i+c*m->nbEBands] = EPSILON+VSHR32(EXTEND32(celt_sqrt(sum)),-shift); } else { @@ -148,20 +150,18 @@ void normalise_bands(const CELTMode *m, const celt_sig * OPUS_RESTRICT freq, cel } while (++c<C); } -#else /* OPUS_FIXED_POINT */ +#else /* FIXED_POINT */ /* Compute the amplitude (sqrt energy) in each of the bands */ -void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *bandE, int end, int C, int M) +void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *bandE, int end, int C, int LM) { int i, c, N; const opus_int16 *eBands = m->eBands; - N = M*m->shortMdctSize; + N = m->shortMdctSize<<LM; c=0; do { for (i=0;i<end;i++) { - int j; - opus_val32 sum = 1e-27f; - for (j=M*eBands[i];j<M*eBands[i+1];j++) - sum += X[j+c*N]*X[j+c*N]; + opus_val32 sum; + sum = 1e-27f + celt_inner_prod_c(&X[c*N+(eBands[i]<<LM)], &X[c*N+(eBands[i]<<LM)], (eBands[i+1]-eBands[i])<<LM); bandE[i+c*m->nbEBands] = celt_sqrt(sum); /*printf ("%f ", bandE[i+c*m->nbEBands]);*/ } @@ -186,78 +186,84 @@ void normalise_bands(const CELTMode *m, const celt_sig * OPUS_RESTRICT freq, cel } while (++c<C); } -#endif /* OPUS_FIXED_POINT */ +#endif /* FIXED_POINT */ /* De-normalise the energy to produce the synthesis from the unit-energy bands */ void denormalise_bands(const CELTMode *m, const celt_norm * OPUS_RESTRICT X, - celt_sig * OPUS_RESTRICT freq, const opus_val16 *bandLogE, int start, int end, int C, int M) + celt_sig * OPUS_RESTRICT freq, const opus_val16 *bandLogE, int start, + int end, int M, int downsample, int silence) { - int i, c, N; + int i, N; + int bound; + celt_sig * OPUS_RESTRICT f; + const celt_norm * OPUS_RESTRICT x; const opus_int16 *eBands = m->eBands; N = M*m->shortMdctSize; - celt_assert2(C<=2, "denormalise_bands() not implemented for >2 channels"); - c=0; do { - celt_sig * OPUS_RESTRICT f; - const celt_norm * OPUS_RESTRICT x; - f = freq+c*N; - x = X+c*N+M*eBands[start]; - for (i=0;i<M*eBands[start];i++) - *f++ = 0; - for (i=start;i<end;i++) - { - int j, band_end; - opus_val16 g; - opus_val16 lg; + bound = M*eBands[end]; + if (downsample!=1) + bound = IMIN(bound, N/downsample); + if (silence) + { + bound = 0; + start = end = 0; + } + f = freq; + x = X+M*eBands[start]; + for (i=0;i<M*eBands[start];i++) + *f++ = 0; + for (i=start;i<end;i++) + { + int j, band_end; + opus_val16 g; + opus_val16 lg; #ifdef OPUS_FIXED_POINT - int shift; + int shift; #endif - j=M*eBands[i]; - band_end = M*eBands[i+1]; - lg = ADD16(bandLogE[i+c*m->nbEBands], SHL16((opus_val16)eMeans[i],6)); + j=M*eBands[i]; + band_end = M*eBands[i+1]; + lg = ADD16(bandLogE[i], SHL16((opus_val16)eMeans[i],6)); #ifndef OPUS_FIXED_POINT - g = celt_exp2(lg); + g = celt_exp2(lg); #else - /* Handle the integer part of the log energy */ - shift = 16-(lg>>DB_SHIFT); - if (shift>31) - { - shift=0; - g=0; - } else { - /* Handle the fractional part. */ - g = celt_exp2_frac(lg&((1<<DB_SHIFT)-1)); - } - /* Handle extreme gains with negative shift. */ - if (shift<0) - { - /* For shift < -2 we'd be likely to overflow, so we're capping + /* Handle the integer part of the log energy */ + shift = 16-(lg>>DB_SHIFT); + if (shift>31) + { + shift=0; + g=0; + } else { + /* Handle the fractional part. */ + g = celt_exp2_frac(lg&((1<<DB_SHIFT)-1)); + } + /* Handle extreme gains with negative shift. */ + if (shift<0) + { + /* For shift < -2 we'd be likely to overflow, so we're capping the gain here. This shouldn't happen unless the bitstream is already corrupted. */ - if (shift < -2) - { - g = 32767; - shift = -2; - } - do { - *f++ = SHL32(MULT16_16(*x++, g), -shift); - } while (++j<band_end); - } else + if (shift < -2) + { + g = 32767; + shift = -2; + } + do { + *f++ = SHL32(MULT16_16(*x++, g), -shift); + } while (++j<band_end); + } else #endif /* Be careful of the fixed-point "else" just above when changing this code */ do { *f++ = SHR32(MULT16_16(*x++, g), shift); } while (++j<band_end); - } - celt_assert(start <= end); - for (i=M*eBands[end];i<N;i++) - *f++ = 0; - } while (++c<C); + } + celt_assert(start <= end); + OPUS_CLEAR(&freq[bound], N-bound); } /* This prevents energy collapse for transients with multiple short MDCTs */ void anti_collapse(const CELTMode *m, celt_norm *X_, unsigned char *collapse_masks, int LM, int C, int size, - int start, int end, opus_val16 *logE, opus_val16 *prev1logE, - opus_val16 *prev2logE, int *pulses, opus_uint32 seed) + int start, int end, const opus_val16 *logE, const opus_val16 *prev1logE, + const opus_val16 *prev2logE, const int *pulses, opus_uint32 seed, int arch) { int c, i, j, k; for (i=start;i<end;i++) @@ -272,7 +278,8 @@ void anti_collapse(const CELTMode *m, celt_norm *X_, unsigned char *collapse_mas N0 = m->eBands[i+1]-m->eBands[i]; /* depth in 1/8 bits */ - depth = (1+pulses[i])/((m->eBands[i+1]-m->eBands[i])<<LM); + celt_assert(pulses[i]>=0); + depth = celt_udiv(1+pulses[i], (m->eBands[i+1]-m->eBands[i]))>>LM; #ifdef OPUS_FIXED_POINT thresh32 = SHR32(celt_exp2(-SHL16(depth, 10-BITRES)),1); @@ -345,12 +352,12 @@ void anti_collapse(const CELTMode *m, celt_norm *X_, unsigned char *collapse_mas } /* We just added some energy, so we need to renormalise */ if (renormalize) - renormalise_vector(X, N0<<LM, Q15ONE); + renormalise_vector(X, N0<<LM, Q15ONE, arch); } while (++c<C); } } -static void intensity_stereo(const CELTMode *m, celt_norm *X, celt_norm *Y, const celt_ener *bandE, int bandID, int N) +static void intensity_stereo(const CELTMode *m, celt_norm * OPUS_RESTRICT X, const celt_norm * OPUS_RESTRICT Y, const celt_ener *bandE, int bandID, int N) { int i = bandID; int j; @@ -370,25 +377,25 @@ static void intensity_stereo(const CELTMode *m, celt_norm *X, celt_norm *Y, cons celt_norm r, l; l = X[j]; r = Y[j]; - X[j] = MULT16_16_Q14(a1,l) + MULT16_16_Q14(a2,r); + X[j] = EXTRACT16(SHR32(MAC16_16(MULT16_16(a1, l), a2, r), 14)); /* Side is not encoded, no need to calculate */ } } -static void stereo_split(celt_norm *X, celt_norm *Y, int N) +static void stereo_split(celt_norm * OPUS_RESTRICT X, celt_norm * OPUS_RESTRICT Y, int N) { int j; for (j=0;j<N;j++) { - celt_norm r, l; - l = MULT16_16_Q15(QCONST16(.70710678f,15), X[j]); - r = MULT16_16_Q15(QCONST16(.70710678f,15), Y[j]); - X[j] = l+r; - Y[j] = r-l; + opus_val32 r, l; + l = MULT16_16(QCONST16(.70710678f, 15), X[j]); + r = MULT16_16(QCONST16(.70710678f, 15), Y[j]); + X[j] = EXTRACT16(SHR32(ADD32(l, r), 15)); + Y[j] = EXTRACT16(SHR32(SUB32(r, l), 15)); } } -static void stereo_merge(celt_norm *X, celt_norm *Y, opus_val16 mid, int N) +static void stereo_merge(celt_norm * OPUS_RESTRICT X, celt_norm * OPUS_RESTRICT Y, opus_val16 mid, int N, int arch) { int j; opus_val32 xp=0, side=0; @@ -400,7 +407,7 @@ static void stereo_merge(celt_norm *X, celt_norm *Y, opus_val16 mid, int N) opus_val32 t, lgain, rgain; /* Compute the norm of X+Y and X-Y as |X|^2 + |Y|^2 +/- sum(xy) */ - dual_inner_prod(Y, X, Y, N, &xp, &side); + dual_inner_prod(Y, X, Y, N, &xp, &side, arch); /* Compensating for the mid normalization */ xp = MULT16_32_Q15(mid, xp); /* mid and side are in Q15, not Q14 like X and Y */ @@ -409,8 +416,7 @@ static void stereo_merge(celt_norm *X, celt_norm *Y, opus_val16 mid, int N) Er = MULT16_16(mid2, mid2) + side + 2*xp; if (Er < QCONST32(6e-4f, 28) || El < QCONST32(6e-4f, 28)) { - for (j=0;j<N;j++) - Y[j] = X[j]; + OPUS_COPY(Y, X, N); return; } @@ -434,7 +440,7 @@ static void stereo_merge(celt_norm *X, celt_norm *Y, opus_val16 mid, int N) { celt_norm r, l; /* Apply mid scaling (side is already scaled) */ - l = MULT16_16_Q15(mid, X[j]); + l = MULT16_16_P15(mid, X[j]); r = Y[j]; X[j] = EXTRACT16(PSHR32(MULT16_16(lgain, SUB16(l,r)), kl+1)); Y[j] = EXTRACT16(PSHR32(MULT16_16(rgain, ADD16(l,r)), kr+1)); @@ -442,7 +448,7 @@ static void stereo_merge(celt_norm *X, celt_norm *Y, opus_val16 mid, int N) } /* Decide whether we should spread the pulses in the current frame */ -int spreading_decision(const CELTMode *m, celt_norm *X, int *average, +int spreading_decision(const CELTMode *m, const celt_norm *X, int *average, int last_decision, int *hf_average, int *tapset_decision, int update_hf, int end, int C, int M) { @@ -463,7 +469,7 @@ int spreading_decision(const CELTMode *m, celt_norm *X, int *average, { int j, N, tmp=0; int tcount[3] = {0,0,0}; - celt_norm * OPUS_RESTRICT x = X+M*eBands[i]+c*N0; + const celt_norm * OPUS_RESTRICT x = X+M*eBands[i]+c*N0; N = M*(eBands[i+1]-eBands[i]); if (N<=8) continue; @@ -483,7 +489,7 @@ int spreading_decision(const CELTMode *m, celt_norm *X, int *average, /* Only include four last bands (8 kHz and up) */ if (i>m->nbEBands-4) - hf_sum += 32*(tcount[1]+tcount[0])/N; + hf_sum += celt_udiv(32*(tcount[1]+tcount[0]), N); tmp = (2*tcount[2] >= N) + (2*tcount[1] >= N) + (2*tcount[0] >= N); sum += tmp*256; nbBands++; @@ -493,7 +499,7 @@ int spreading_decision(const CELTMode *m, celt_norm *X, int *average, if (update_hf) { if (hf_sum) - hf_sum /= C*(4-m->nbEBands+end); + hf_sum = celt_udiv(hf_sum, C*(4-m->nbEBands+end)); *hf_average = (*hf_average+hf_sum)>>1; hf_sum = *hf_average; if (*tapset_decision==2) @@ -509,7 +515,8 @@ int spreading_decision(const CELTMode *m, celt_norm *X, int *average, } /*printf("%d %d %d\n", hf_sum, *hf_average, *tapset_decision);*/ celt_assert(nbBands>0); /* end has to be non-zero */ - sum /= nbBands; + celt_assert(sum>=0); + sum = celt_udiv(sum, nbBands); /* Recursive averaging */ sum = (sum+*average)>>1; *average = sum; @@ -567,8 +574,7 @@ static void deinterleave_hadamard(celt_norm *X, int N0, int stride, int hadamard for (j=0;j<N0;j++) tmp[i*N0+j] = X[j*stride+i]; } - for (j=0;j<N;j++) - X[j] = tmp[j]; + OPUS_COPY(X, tmp, N); RESTORE_STACK; } @@ -591,8 +597,7 @@ static void interleave_hadamard(celt_norm *X, int N0, int stride, int hadamard) for (j=0;j<N0;j++) tmp[j*stride+i] = X[i*N0+j]; } - for (j=0;j<N;j++) - X[j] = tmp[j]; + OPUS_COPY(X, tmp, N); RESTORE_STACK; } @@ -603,11 +608,11 @@ void haar1(celt_norm *X, int N0, int stride) for (i=0;i<stride;i++) for (j=0;j<N0;j++) { - celt_norm tmp1, tmp2; - tmp1 = MULT16_16_Q15(QCONST16(.70710678f,15), X[stride*2*j+i]); - tmp2 = MULT16_16_Q15(QCONST16(.70710678f,15), X[stride*(2*j+1)+i]); - X[stride*2*j+i] = tmp1 + tmp2; - X[stride*(2*j+1)+i] = tmp1 - tmp2; + opus_val32 tmp1, tmp2; + tmp1 = MULT16_16(QCONST16(.70710678f,15), X[stride*2*j+i]); + tmp2 = MULT16_16(QCONST16(.70710678f,15), X[stride*(2*j+1)+i]); + X[stride*2*j+i] = EXTRACT16(PSHR32(ADD32(tmp1, tmp2), 15)); + X[stride*(2*j+1)+i] = EXTRACT16(PSHR32(SUB32(tmp1, tmp2), 15)); } } @@ -622,7 +627,8 @@ static int compute_qn(int N, int b, int offset, int pulse_cap, int stereo) /* The upper limit ensures that in a stereo split with itheta==16384, we'll always have enough bits left over to code at least one pulse in the side; otherwise it would collapse, since it doesn't get folded. */ - qb = IMIN(b-pulse_cap-(4<<BITRES), (b+N2*offset)/N2); + qb = celt_sudiv(b+N2*offset, N2); + qb = IMIN(b-pulse_cap-(4<<BITRES), qb); qb = IMIN(8<<BITRES, qb); @@ -647,6 +653,7 @@ struct band_ctx { opus_int32 remaining_bits; const celt_ener *bandE; opus_uint32 seed; + int arch; }; struct split_ctx { @@ -698,7 +705,7 @@ static void compute_theta(struct band_ctx *ctx, struct split_ctx *sctx, side and mid. With just that parameter, we can re-scale both mid and side because we know that 1) they have unit norm and 2) they are orthogonal. */ - itheta = stereo_itheta(X, Y, stereo, N); + itheta = stereo_itheta(X, Y, stereo, N, ctx->arch); } tell = ec_tell_frac(ec); if (qn!=1) @@ -769,7 +776,8 @@ static void compute_theta(struct band_ctx *ctx, struct split_ctx *sctx, ec_dec_update(ec, fl, fl+fs, ft); } } - itheta = (opus_int32)itheta*16384/qn; + celt_assert(itheta>=0); + itheta = celt_udiv((opus_int32)itheta*16384, qn); if (encode && stereo) { if (itheta==0) @@ -1021,8 +1029,7 @@ static unsigned quant_partition(struct band_ctx *ctx, celt_norm *X, fill &= cm_mask; if (!fill) { - for (j=0;j<N;j++) - X[j] = 0; + OPUS_CLEAR(X, N); } else { if (lowband == NULL) { @@ -1046,7 +1053,7 @@ static unsigned quant_partition(struct band_ctx *ctx, celt_norm *X, } cm = fill; } - renormalise_vector(X, N, gain); + renormalise_vector(X, N, gain, ctx->arch); } } } @@ -1084,7 +1091,7 @@ static unsigned quant_band(struct band_ctx *ctx, celt_norm *X, longBlocks = B0==1; - N_B /= B; + N_B = celt_udiv(N_B, B); /* Special case for one sample */ if (N==1) @@ -1098,9 +1105,7 @@ static unsigned quant_band(struct band_ctx *ctx, celt_norm *X, if (lowband_scratch && lowband && (recombine || ((N_B&1) == 0 && tf_change<0) || B0>1)) { - int j; - for (j=0;j<N;j++) - lowband_scratch[j] = lowband[j]; + OPUS_COPY(lowband_scratch, lowband, N); lowband = lowband_scratch; } @@ -1340,7 +1345,7 @@ static unsigned quant_band_stereo(struct band_ctx *ctx, celt_norm *X, celt_norm if (resynth) { if (N!=2) - stereo_merge(X, Y, mid, N); + stereo_merge(X, Y, mid, N, ctx->arch); if (inv) { int j; @@ -1353,9 +1358,11 @@ static unsigned quant_band_stereo(struct band_ctx *ctx, celt_norm *X, celt_norm void quant_all_bands(int encode, const CELTMode *m, int start, int end, - celt_norm *X_, celt_norm *Y_, unsigned char *collapse_masks, const celt_ener *bandE, int *pulses, - int shortBlocks, int spread, int dual_stereo, int intensity, int *tf_res, - opus_int32 total_bits, opus_int32 balance, ec_ctx *ec, int LM, int codedBands, opus_uint32 *seed) + celt_norm *X_, celt_norm *Y_, unsigned char *collapse_masks, + const celt_ener *bandE, int *pulses, int shortBlocks, int spread, + int dual_stereo, int intensity, int *tf_res, opus_int32 total_bits, + opus_int32 balance, ec_ctx *ec, int LM, int codedBands, + opus_uint32 *seed, int arch) { int i; opus_int32 remaining_bits; @@ -1397,6 +1404,7 @@ void quant_all_bands(int encode, const CELTMode *m, int start, int end, ctx.m = m; ctx.seed = *seed; ctx.spread = spread; + ctx.arch = arch; for (i=start;i<end;i++) { opus_int32 tell; @@ -1428,7 +1436,7 @@ void quant_all_bands(int encode, const CELTMode *m, int start, int end, ctx.remaining_bits = remaining_bits; if (i <= codedBands-1) { - curr_balance = balance / IMIN(3, codedBands-i); + curr_balance = celt_sudiv(balance, IMIN(3, codedBands-i)); b = IMAX(0, IMIN(16383, IMIN(remaining_bits+1,pulses[i]+curr_balance))); } else { b = 0; diff --git a/drivers/opus/celt/bands.h b/drivers/opus/celt/bands.h index 1ef7cbc8ee..eb7ea4cc24 100644 --- a/drivers/opus/celt/bands.h +++ b/drivers/opus/celt/bands.h @@ -31,7 +31,7 @@ #define BANDS_H #include "opus/celt/arch.h" -#include "opus/celt/opus_modes.h" +#include "opus/celt/modes.h" #include "opus/celt/entenc.h" #include "opus/celt/entdec.h" #include "opus/celt/rate.h" @@ -41,7 +41,7 @@ * @param X Spectrum * @param bandE Square root of the energy for each band (returned) */ -void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *bandE, int end, int C, int M); +void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *bandE, int end, int C, int LM); /*void compute_noise_energies(const CELTMode *m, const celt_sig *X, const opus_val16 *tonality, celt_ener *bandE);*/ @@ -59,14 +59,15 @@ void normalise_bands(const CELTMode *m, const celt_sig * OPUS_RESTRICT freq, cel * @param bandE Square root of the energy for each band */ void denormalise_bands(const CELTMode *m, const celt_norm * OPUS_RESTRICT X, - celt_sig * OPUS_RESTRICT freq, const opus_val16 *bandE, int start, int end, int C, int M); + celt_sig * OPUS_RESTRICT freq, const opus_val16 *bandE, int start, + int end, int M, int downsample, int silence); #define SPREAD_NONE (0) #define SPREAD_LIGHT (1) #define SPREAD_NORMAL (2) #define SPREAD_AGGRESSIVE (3) -int spreading_decision(const CELTMode *m, celt_norm *X, int *average, +int spreading_decision(const CELTMode *m, const celt_norm *X, int *average, int last_decision, int *hf_average, int *tapset_decision, int update_hf, int end, int C, int M); @@ -97,15 +98,20 @@ void haar1(celt_norm *X, int N0, int stride); * @param LM log2() of the number of 2.5 subframes in the frame * @param codedBands Last band to receive bits + 1 * @param seed Random generator seed + * @param arch Run-time architecture (see opus_select_arch()) */ void quant_all_bands(int encode, const CELTMode *m, int start, int end, - celt_norm * X, celt_norm * Y, unsigned char *collapse_masks, const celt_ener *bandE, int *pulses, - int shortBlocks, int spread, int dual_stereo, int intensity, int *tf_res, - opus_int32 total_bits, opus_int32 balance, ec_ctx *ec, int M, int codedBands, opus_uint32 *seed); - -void anti_collapse(const CELTMode *m, celt_norm *X_, unsigned char *collapse_masks, int LM, int C, int size, - int start, int end, opus_val16 *logE, opus_val16 *prev1logE, - opus_val16 *prev2logE, int *pulses, opus_uint32 seed); + celt_norm * X, celt_norm * Y, unsigned char *collapse_masks, + const celt_ener *bandE, int *pulses, int shortBlocks, int spread, + int dual_stereo, int intensity, int *tf_res, opus_int32 total_bits, + opus_int32 balance, ec_ctx *ec, int M, int codedBands, opus_uint32 *seed, + int arch); + +void anti_collapse(const CELTMode *m, celt_norm *X_, + unsigned char *collapse_masks, int LM, int C, int size, int start, + int end, const opus_val16 *logE, const opus_val16 *prev1logE, + const opus_val16 *prev2logE, const int *pulses, opus_uint32 seed, + int arch); opus_uint32 celt_lcg_rand(opus_uint32 seed); diff --git a/drivers/opus/celt/celt.c b/drivers/opus/celt/celt.c index d99a91ba29..4a16651441 100644 --- a/drivers/opus/celt/celt.c +++ b/drivers/opus/celt/celt.c @@ -26,10 +26,7 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #define CELT_C @@ -39,7 +36,7 @@ #include "opus/celt/celt.h" #include "opus/celt/pitch.h" #include "opus/celt/bands.h" -#include "opus/celt/opus_modes.h" +#include "opus/celt/modes.h" #include "opus/celt/entcode.h" #include "opus/celt/quant_bands.h" #include "opus/celt/rate.h" @@ -54,6 +51,10 @@ #define PACKAGE_VERSION "unknown" #endif +#if defined(MIPSr1_ASM) +#include "opus/celt/mips/celt_mipsr1.h" +#endif + int resampling_factor(opus_int32 rate) { @@ -85,8 +86,71 @@ int resampling_factor(opus_int32 rate) return ret; } -#ifndef OVERRIDE_COMB_FILTER_CONST -static void comb_filter_const(opus_val32 *y, opus_val32 *x, int T, int N, +#if !defined(OVERRIDE_COMB_FILTER_CONST) || defined(NON_STATIC_COMB_FILTER_CONST_C) +/* This version should be faster on ARM */ +#ifdef OPUS_ARM_ASM +#ifndef NON_STATIC_COMB_FILTER_CONST_C +static +#endif +void comb_filter_const_c(opus_val32 *y, opus_val32 *x, int T, int N, + opus_val16 g10, opus_val16 g11, opus_val16 g12) +{ + opus_val32 x0, x1, x2, x3, x4; + int i; + x4 = SHL32(x[-T-2], 1); + x3 = SHL32(x[-T-1], 1); + x2 = SHL32(x[-T], 1); + x1 = SHL32(x[-T+1], 1); + for (i=0;i<N-4;i+=5) + { + opus_val32 t; + x0=SHL32(x[i-T+2],1); + t = MAC16_32_Q16(x[i], g10, x2); + t = MAC16_32_Q16(t, g11, ADD32(x1,x3)); + t = MAC16_32_Q16(t, g12, ADD32(x0,x4)); + y[i] = t; + x4=SHL32(x[i-T+3],1); + t = MAC16_32_Q16(x[i+1], g10, x1); + t = MAC16_32_Q16(t, g11, ADD32(x0,x2)); + t = MAC16_32_Q16(t, g12, ADD32(x4,x3)); + y[i+1] = t; + x3=SHL32(x[i-T+4],1); + t = MAC16_32_Q16(x[i+2], g10, x0); + t = MAC16_32_Q16(t, g11, ADD32(x4,x1)); + t = MAC16_32_Q16(t, g12, ADD32(x3,x2)); + y[i+2] = t; + x2=SHL32(x[i-T+5],1); + t = MAC16_32_Q16(x[i+3], g10, x4); + t = MAC16_32_Q16(t, g11, ADD32(x3,x0)); + t = MAC16_32_Q16(t, g12, ADD32(x2,x1)); + y[i+3] = t; + x1=SHL32(x[i-T+6],1); + t = MAC16_32_Q16(x[i+4], g10, x3); + t = MAC16_32_Q16(t, g11, ADD32(x2,x4)); + t = MAC16_32_Q16(t, g12, ADD32(x1,x0)); + y[i+4] = t; + } +#ifdef CUSTOM_MODES + for (;i<N;i++) + { + opus_val32 t; + x0=SHL32(x[i-T+2],1); + t = MAC16_32_Q16(x[i], g10, x2); + t = MAC16_32_Q16(t, g11, ADD32(x1,x3)); + t = MAC16_32_Q16(t, g12, ADD32(x0,x4)); + y[i] = t; + x4=x3; + x3=x2; + x2=x1; + x1=x0; + } +#endif +} +#else +#ifndef NON_STATIC_COMB_FILTER_CONST_C +static +#endif +void comb_filter_const_c(opus_val32 *y, opus_val32 *x, int T, int N, opus_val16 g10, opus_val16 g11, opus_val16 g12) { opus_val32 x0, x1, x2, x3, x4; @@ -110,10 +174,12 @@ static void comb_filter_const(opus_val32 *y, opus_val32 *x, int T, int N, } #endif +#endif +#ifndef OVERRIDE_comb_filter void comb_filter(opus_val32 *y, opus_val32 *x, int T0, int T1, int N, opus_val16 g0, opus_val16 g1, int tapset0, int tapset1, - const opus_val16 *window, int overlap) + const opus_val16 *window, int overlap, int arch) { int i; /* printf ("%d %d %f %f\n", T0, T1, g0, g1); */ @@ -131,16 +197,19 @@ void comb_filter(opus_val32 *y, opus_val32 *x, int T0, int T1, int N, OPUS_MOVE(y, x, N); return; } - g00 = MULT16_16_Q15(g0, gains[tapset0][0]); - g01 = MULT16_16_Q15(g0, gains[tapset0][1]); - g02 = MULT16_16_Q15(g0, gains[tapset0][2]); - g10 = MULT16_16_Q15(g1, gains[tapset1][0]); - g11 = MULT16_16_Q15(g1, gains[tapset1][1]); - g12 = MULT16_16_Q15(g1, gains[tapset1][2]); + g00 = MULT16_16_P15(g0, gains[tapset0][0]); + g01 = MULT16_16_P15(g0, gains[tapset0][1]); + g02 = MULT16_16_P15(g0, gains[tapset0][2]); + g10 = MULT16_16_P15(g1, gains[tapset1][0]); + g11 = MULT16_16_P15(g1, gains[tapset1][1]); + g12 = MULT16_16_P15(g1, gains[tapset1][2]); x1 = x[-T1+1]; x2 = x[-T1 ]; x3 = x[-T1-1]; x4 = x[-T1-2]; + /* If the filter didn't change, we don't need the overlap */ + if (g0==g1 && T0==T1 && tapset0==tapset1) + overlap=0; for (i=0;i<overlap;i++) { opus_val16 f; @@ -168,8 +237,9 @@ void comb_filter(opus_val32 *y, opus_val32 *x, int T0, int T1, int N, } /* Compute the part with the constant filter. */ - comb_filter_const(y+i, x+i, T1, N-i, g10, g11, g12); + comb_filter_const(y+i, x+i, T1, N-i, g10, g11, g12, arch); } +#endif /* OVERRIDE_comb_filter */ const signed char tf_select_table[4][8] = { {0, -1, 0, -1, 0,-1, 0,-1}, @@ -213,6 +283,9 @@ const char *opus_strerror(int error) const char *opus_get_version_string(void) { return "libopus " PACKAGE_VERSION + /* Applications may rely on the presence of this substring in the version + string to determine if they have a fixed-point or floating-point build + at runtime. */ #ifdef OPUS_FIXED_POINT "-fixed" #endif diff --git a/drivers/opus/celt/celt.h b/drivers/opus/celt/celt.h index 2b7dc3fa72..72814dc0de 100644 --- a/drivers/opus/celt/celt.h +++ b/drivers/opus/celt/celt.h @@ -134,7 +134,8 @@ int celt_decoder_get_size(int channels); int celt_decoder_init(CELTDecoder *st, opus_int32 sampling_rate, int channels); -int celt_decode_with_ec(OpusCustomDecoder * OPUS_RESTRICT st, const unsigned char *data, int len, opus_val16 * OPUS_RESTRICT pcm, int frame_size, ec_dec *dec); +int celt_decode_with_ec(OpusCustomDecoder * OPUS_RESTRICT st, const unsigned char *data, + int len, opus_val16 * OPUS_RESTRICT pcm, int frame_size, ec_dec *dec, int accum); #define celt_encoder_ctl opus_custom_encoder_ctl #define celt_decoder_ctl opus_custom_decoder_ctl @@ -200,15 +201,25 @@ void celt_preemphasis(const opus_val16 * OPUS_RESTRICT pcmp, celt_sig * OPUS_RES void comb_filter(opus_val32 *y, opus_val32 *x, int T0, int T1, int N, opus_val16 g0, opus_val16 g1, int tapset0, int tapset1, - const opus_val16 *window, int overlap); + const opus_val16 *window, int overlap, int arch); + +#ifdef NON_STATIC_COMB_FILTER_CONST_C +void comb_filter_const_c(opus_val32 *y, opus_val32 *x, int T, int N, + opus_val16 g10, opus_val16 g11, opus_val16 g12); +#endif + +#ifndef OVERRIDE_COMB_FILTER_CONST +# define comb_filter_const(y, x, T, N, g10, g11, g12, arch) \ + ((void)(arch),comb_filter_const_c(y, x, T, N, g10, g11, g12)) +#endif void init_caps(const CELTMode *m,int *cap,int LM,int C); #ifdef RESYNTH -void deemphasis(celt_sig *in[], opus_val16 *pcm, int N, int C, int downsample, const opus_val16 *coef, celt_sig *mem, celt_sig * OPUS_RESTRICT scratch); - -void compute_inv_mdcts(const CELTMode *mode, int shortBlocks, celt_sig *X, - celt_sig * OPUS_RESTRICT out_mem[], int C, int LM); +void deemphasis(celt_sig *in[], opus_val16 *pcm, int N, int C, int downsample, const opus_val16 *coef, celt_sig *mem); +void celt_synthesis(const CELTMode *mode, celt_norm *X, celt_sig * out_syn[], + opus_val16 *oldBandE, int start, int effEnd, int C, int CC, int isTransient, + int LM, int downsample, int silence); #endif #ifdef __cplusplus diff --git a/drivers/opus/celt/celt_decoder.c b/drivers/opus/celt/celt_decoder.c index 67c3789439..88072ed110 100644 --- a/drivers/opus/celt/celt_decoder.c +++ b/drivers/opus/celt/celt_decoder.c @@ -26,10 +26,7 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #define CELT_DECODER_C @@ -40,7 +37,7 @@ #include "opus/celt/celt.h" #include "opus/celt/pitch.h" #include "opus/celt/bands.h" -#include "opus/celt/opus_modes.h" +#include "opus/celt/modes.h" #include "opus/celt/entcode.h" #include "opus/celt/quant_bands.h" #include "opus/celt/rate.h" @@ -51,6 +48,9 @@ #include "opus/celt/celt_lpc.h" #include "opus/celt/vq.h" +#if defined(SMALL_FOOTPRINT) && defined(FIXED_POINT) +#define NORM_ALIASING_HACK +#endif /**********************************************************************/ /* */ /* DECODER */ @@ -175,28 +175,24 @@ void opus_custom_decoder_destroy(CELTDecoder *st) } #endif /* CUSTOM_MODES */ -static OPUS_INLINE opus_val16 SIG2WORD16(celt_sig x) -{ -#ifdef OPUS_FIXED_POINT - x = PSHR32(x, SIG_SHIFT); - x = MAX32(x, -32768); - x = MIN32(x, 32767); - return EXTRACT16(x); -#else - return (opus_val16)x; -#endif -} #ifndef RESYNTH static #endif -void deemphasis(celt_sig *in[], opus_val16 *pcm, int N, int C, int downsample, const opus_val16 *coef, celt_sig *mem, celt_sig * OPUS_RESTRICT scratch) +void deemphasis(celt_sig *in[], opus_val16 *pcm, int N, int C, int downsample, const opus_val16 *coef, + celt_sig *mem, int accum) { int c; int Nd; int apply_downsampling=0; opus_val16 coef0; - + VARDECL(celt_sig, scratch); + SAVE_STACK; +#ifndef OPUS_FIXED_POINT + (void)accum; + celt_assert(accum==0); +#endif + ALLOC(scratch, N, celt_sig); coef0 = coef[0]; Nd = N/downsample; c=0; do { @@ -234,11 +230,24 @@ void deemphasis(celt_sig *in[], opus_val16 *pcm, int N, int C, int downsample, c apply_downsampling=1; } else { /* Shortcut for the standard (non-custom modes) case */ - for (j=0;j<N;j++) +#ifdef OPUS_FIXED_POINT + if (accum) { - celt_sig tmp = x[j] + m + VERY_SMALL; - m = MULT16_32_Q15(coef0, tmp); - y[j*C] = SCALEOUT(SIG2WORD16(tmp)); + for (j=0;j<N;j++) + { + celt_sig tmp = x[j] + m + VERY_SMALL; + m = MULT16_32_Q15(coef0, tmp); + y[j*C] = SAT16(ADD32(y[j*C], SCALEOUT(SIG2WORD16(tmp)))); + } + } else +#endif + { + for (j=0;j<N;j++) + { + celt_sig tmp = x[j] + m + VERY_SMALL; + m = MULT16_32_Q15(coef0, tmp); + y[j*C] = SCALEOUT(SIG2WORD16(tmp)); + } } } mem[c] = m; @@ -246,41 +255,95 @@ void deemphasis(celt_sig *in[], opus_val16 *pcm, int N, int C, int downsample, c if (apply_downsampling) { /* Perform down-sampling */ - for (j=0;j<Nd;j++) - y[j*C] = SCALEOUT(SIG2WORD16(scratch[j*downsample])); +#ifdef OPUS_FIXED_POINT + if (accum) + { + for (j=0;j<Nd;j++) + y[j*C] = SAT16(ADD32(y[j*C], SCALEOUT(SIG2WORD16(scratch[j*downsample])))); + } else +#endif + { + for (j=0;j<Nd;j++) + y[j*C] = SCALEOUT(SIG2WORD16(scratch[j*downsample])); + } } } while (++c<C); + RESTORE_STACK; } -/** Compute the IMDCT and apply window for all sub-frames and - all channels in a frame */ #ifndef RESYNTH static #endif -void compute_inv_mdcts(const CELTMode *mode, int shortBlocks, celt_sig *X, - celt_sig * OPUS_RESTRICT out_mem[], int C, int LM) +void celt_synthesis(const CELTMode *mode, celt_norm *X, celt_sig * out_syn[], + opus_val16 *oldBandE, int start, int effEnd, int C, int CC, + int isTransient, int LM, int downsample, + int silence, int arch) { - int b, c; + int c, i; + int M; + int b; int B; - int N; + int N, NB; int shift; - const int overlap = OVERLAP(mode); + int nbEBands; + int overlap; + VARDECL(celt_sig, freq); + SAVE_STACK; + + overlap = mode->overlap; + nbEBands = mode->nbEBands; + N = mode->shortMdctSize<<LM; + ALLOC(freq, N, celt_sig); /**< Interleaved signal MDCTs */ + M = 1<<LM; - if (shortBlocks) + if (isTransient) { - B = shortBlocks; - N = mode->shortMdctSize; + B = M; + NB = mode->shortMdctSize; shift = mode->maxLM; } else { B = 1; - N = mode->shortMdctSize<<LM; + NB = mode->shortMdctSize<<LM; shift = mode->maxLM-LM; } - c=0; do { - /* IMDCT on the interleaved the sub-frames, overlap-add is performed by the IMDCT */ + + if (CC==2&&C==1) + { + /* Copying a mono streams to two channels */ + celt_sig *freq2; + denormalise_bands(mode, X, freq, oldBandE, start, effEnd, M, + downsample, silence); + /* Store a temporary copy in the output buffer because the IMDCT destroys its input. */ + freq2 = out_syn[1]+overlap/2; + OPUS_COPY(freq2, freq, N); for (b=0;b<B;b++) - clt_mdct_backward(&mode->mdct, &X[b+c*N*B], out_mem[c]+N*b, mode->window, overlap, shift, B); - } while (++c<C); + clt_mdct_backward(&mode->mdct, &freq2[b], out_syn[0]+NB*b, mode->window, overlap, shift, B, arch); + for (b=0;b<B;b++) + clt_mdct_backward(&mode->mdct, &freq[b], out_syn[1]+NB*b, mode->window, overlap, shift, B, arch); + } else if (CC==1&&C==2) + { + /* Downmixing a stereo stream to mono */ + celt_sig *freq2; + freq2 = out_syn[0]+overlap/2; + denormalise_bands(mode, X, freq, oldBandE, start, effEnd, M, + downsample, silence); + /* Use the output buffer as temp array before downmixing. */ + denormalise_bands(mode, X+N, freq2, oldBandE+nbEBands, start, effEnd, M, + downsample, silence); + for (i=0;i<N;i++) + freq[i] = HALF32(ADD32(freq[i],freq2[i])); + for (b=0;b<B;b++) + clt_mdct_backward(&mode->mdct, &freq[b], out_syn[0]+NB*b, mode->window, overlap, shift, B, arch); + } else { + /* Normal case (mono or stereo) */ + c=0; do { + denormalise_bands(mode, X+c*N, freq, oldBandE+c*nbEBands, start, effEnd, M, + downsample, silence); + for (b=0;b<B;b++) + clt_mdct_backward(&mode->mdct, &freq[b], out_syn[c]+NB*b, mode->window, overlap, shift, B, arch); + } while (++c<CC); + } + RESTORE_STACK; } static void tf_decode(int start, int end, int isTransient, int *tf_res, int LM, ec_dec *dec) @@ -330,7 +393,23 @@ static void tf_decode(int start, int end, int isTransient, int *tf_res, int LM, pitch of 480 Hz. */ #define PLC_PITCH_LAG_MIN (100) -static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, opus_val16 * OPUS_RESTRICT pcm, int N, int LM) +static int celt_plc_pitch_search(celt_sig *decode_mem[2], int C, int arch) +{ + int pitch_index; + VARDECL( opus_val16, lp_pitch_buf ); + SAVE_STACK; + ALLOC( lp_pitch_buf, DECODE_BUFFER_SIZE>>1, opus_val16 ); + pitch_downsample(decode_mem, lp_pitch_buf, + DECODE_BUFFER_SIZE, C, arch); + pitch_search(lp_pitch_buf+(PLC_PITCH_LAG_MAX>>1), lp_pitch_buf, + DECODE_BUFFER_SIZE-PLC_PITCH_LAG_MAX, + PLC_PITCH_LAG_MAX-PLC_PITCH_LAG_MIN, &pitch_index, arch); + pitch_index = PLC_PITCH_LAG_MAX-pitch_index; + RESTORE_STACK; + return pitch_index; +} + +static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM) { int c; int i; @@ -343,11 +422,9 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, opus_val16 * OPUS_R int nbEBands; int overlap; int start; - int downsample; int loss_count; int noise_based; const opus_int16 *eBands; - VARDECL(celt_sig, scratch); SAVE_STACK; mode = st->mode; @@ -367,40 +444,37 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, opus_val16 * OPUS_R loss_count = st->loss_count; start = st->start; - downsample = st->downsample; noise_based = loss_count >= 5 || start != 0; - ALLOC(scratch, noise_based?N*C:N, celt_sig); if (noise_based) { /* Noise-based PLC/CNG */ - celt_sig *freq; +#ifdef NORM_ALIASING_HACK + celt_norm *X; +#else VARDECL(celt_norm, X); +#endif opus_uint32 seed; - opus_val16 *plcLogE; int end; int effEnd; - + opus_val16 decay; end = st->end; effEnd = IMAX(start, IMIN(end, mode->effEBands)); - /* Share the interleaved signal MDCT coefficient buffer with the - deemphasis scratch buffer. */ - freq = scratch; +#ifdef NORM_ALIASING_HACK + /* This is an ugly hack that breaks aliasing rules and would be easily broken, + but it saves almost 4kB of stack. */ + X = (celt_norm*)(out_syn[C-1]+overlap/2); +#else ALLOC(X, C*N, celt_norm); /**< Interleaved normalised MDCTs */ +#endif - if (loss_count >= 5) - plcLogE = backgroundLogE; - else { - /* Energy decay */ - opus_val16 decay = loss_count==0 ? - QCONST16(1.5f, DB_SHIFT) : QCONST16(.5f, DB_SHIFT); - c=0; do - { - for (i=start;i<end;i++) - oldBandE[c*nbEBands+i] -= decay; - } while (++c<C); - plcLogE = oldBandE; - } + /* Energy decay */ + decay = loss_count==0 ? QCONST16(1.5f, DB_SHIFT) : QCONST16(.5f, DB_SHIFT); + c=0; do + { + for (i=start;i<end;i++) + oldBandE[c*nbEBands+i] = MAX16(backgroundLogE[c*nbEBands+i], oldBandE[c*nbEBands+i] - decay); + } while (++c<C); seed = st->rng; for (c=0;c<C;c++) { @@ -416,25 +490,17 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, opus_val16 * OPUS_R seed = celt_lcg_rand(seed); X[boffs+j] = (celt_norm)((opus_int32)seed>>20); } - renormalise_vector(X+boffs, blen, Q15ONE); + renormalise_vector(X+boffs, blen, Q15ONE, st->arch); } } st->rng = seed; - denormalise_bands(mode, X, freq, plcLogE, start, effEnd, C, 1<<LM); - - c=0; do { - int bound = eBands[effEnd]<<LM; - if (downsample!=1) - bound = IMIN(bound, N/downsample); - for (i=bound;i<N;i++) - freq[c*N+i] = 0; - } while (++c<C); c=0; do { OPUS_MOVE(decode_mem[c], decode_mem[c]+N, DECODE_BUFFER_SIZE-N+(overlap>>1)); } while (++c<C); - compute_inv_mdcts(mode, 0, freq, out_syn, C, LM); + + celt_synthesis(mode, X, out_syn, oldBandE, start, effEnd, C, C, 0, LM, st->downsample, 0, st->arch); } else { /* Pitch-based PLC */ const opus_val16 *window; @@ -445,15 +511,7 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, opus_val16 * OPUS_R if (loss_count == 0) { - VARDECL( opus_val16, lp_pitch_buf ); - ALLOC( lp_pitch_buf, DECODE_BUFFER_SIZE>>1, opus_val16 ); - pitch_downsample(decode_mem, lp_pitch_buf, - DECODE_BUFFER_SIZE, C, st->arch); - pitch_search(lp_pitch_buf+(PLC_PITCH_LAG_MAX>>1), lp_pitch_buf, - DECODE_BUFFER_SIZE-PLC_PITCH_LAG_MAX, - PLC_PITCH_LAG_MAX-PLC_PITCH_LAG_MIN, &pitch_index, st->arch); - pitch_index = PLC_PITCH_LAG_MAX-pitch_index; - st->last_pitch_index = pitch_index; + st->last_pitch_index = pitch_index = celt_plc_pitch_search(decode_mem, C, st->arch); } else { pitch_index = st->last_pitch_index; fade = QCONST16(.8f,15); @@ -516,7 +574,7 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, opus_val16 * OPUS_R } /* Compute the excitation for exc_length samples before the loss. */ celt_fir(exc+MAX_PERIOD-exc_length, lpc+c*LPC_ORDER, - exc+MAX_PERIOD-exc_length, exc_length, LPC_ORDER, lpc_mem); + exc+MAX_PERIOD-exc_length, exc_length, LPC_ORDER, lpc_mem, st->arch); } /* Check if the waveform is decaying, and if so how fast. @@ -583,7 +641,7 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, opus_val16 * OPUS_R the signal domain. */ celt_iir(buf+DECODE_BUFFER_SIZE-N, lpc+c*LPC_ORDER, buf+DECODE_BUFFER_SIZE-N, extrapolation_len, LPC_ORDER, - lpc_mem); + lpc_mem, st->arch); } /* Check if the synthesis energy is higher than expected, which can @@ -631,7 +689,7 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, opus_val16 * OPUS_R comb_filter(etmp, buf+DECODE_BUFFER_SIZE, st->postfilter_period, st->postfilter_period, overlap, -st->postfilter_gain, -st->postfilter_gain, - st->postfilter_tapset, st->postfilter_tapset, NULL, 0); + st->postfilter_tapset, st->postfilter_tapset, NULL, 0, st->arch); /* Simulate TDAC on the concealed audio so that it blends with the MDCT of the next frame. */ @@ -644,22 +702,23 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, opus_val16 * OPUS_R } while (++c<C); } - deemphasis(out_syn, pcm, N, C, downsample, - mode->preemph, st->preemph_memD, scratch); - st->loss_count = loss_count+1; RESTORE_STACK; } -int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *data, int len, opus_val16 * OPUS_RESTRICT pcm, int frame_size, ec_dec *dec) +int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *data, + int len, opus_val16 * OPUS_RESTRICT pcm, int frame_size, ec_dec *dec, int accum) { int c, i, N; int spread_decision; opus_int32 bits; ec_dec _dec; - VARDECL(celt_sig, freq); +#ifdef NORM_ALIASING_HACK + celt_norm *X; +#else VARDECL(celt_norm, X); +#endif VARDECL(int, fine_quant); VARDECL(int, pulses); VARDECL(int, cap); @@ -677,6 +736,8 @@ int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *dat int intra_ener; const int CC = st->channels; int LM, M; + int start; + int end; int effEnd; int codedBands; int alloc_trim; @@ -703,11 +764,10 @@ int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *dat nbEBands = mode->nbEBands; overlap = mode->overlap; eBands = mode->eBands; + start = st->start; + end = st->end; frame_size *= st->downsample; - c=0; do { - decode_mem[c] = st->_decode_mem + c*(DECODE_BUFFER_SIZE+overlap); - } while (++c<CC); lpc = (opus_val16*)(st->_decode_mem+(DECODE_BUFFER_SIZE+overlap)*CC); oldBandE = lpc+CC*LPC_ORDER; oldLogE = oldBandE + 2*nbEBands; @@ -725,7 +785,7 @@ int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *dat if (data0<0) return OPUS_INVALID_PACKET; } - st->end = IMAX(1, mode->effEBands-2*(data0>>5)); + st->end = end = IMAX(1, mode->effEBands-2*(data0>>5)); LM = (data0>>3)&0x3; C = 1 + ((data0>>2)&0x1); data++; @@ -752,14 +812,19 @@ int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *dat return OPUS_BAD_ARG; N = M*mode->shortMdctSize; + c=0; do { + decode_mem[c] = st->_decode_mem + c*(DECODE_BUFFER_SIZE+overlap); + out_syn[c] = decode_mem[c]+DECODE_BUFFER_SIZE-N; + } while (++c<CC); - effEnd = st->end; + effEnd = end; if (effEnd > mode->effEBands) effEnd = mode->effEBands; if (data == NULL || len<=1) { - celt_decode_lost(st, pcm, N, LM); + celt_decode_lost(st, N, LM); + deemphasis(out_syn, pcm, N, CC, st->downsample, mode->preemph, st->preemph_memD, accum); RESTORE_STACK; return frame_size/st->downsample; } @@ -795,7 +860,7 @@ int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *dat postfilter_gain = 0; postfilter_pitch = 0; postfilter_tapset = 0; - if (st->start==0 && tell+16 <= total_bits) + if (start==0 && tell+16 <= total_bits) { if(ec_dec_bit_logp(dec, 1)) { @@ -826,11 +891,11 @@ int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *dat /* Decode the global flags (first symbols in the stream) */ intra_ener = tell+3<=total_bits ? ec_dec_bit_logp(dec, 3) : 0; /* Get band energies */ - unquant_coarse_energy(mode, st->start, st->end, oldBandE, + unquant_coarse_energy(mode, start, end, oldBandE, intra_ener, dec, C, LM); ALLOC(tf_res, nbEBands, int); - tf_decode(st->start, st->end, isTransient, tf_res, LM, dec); + tf_decode(start, end, isTransient, tf_res, LM, dec); tell = ec_tell(dec); spread_decision = SPREAD_NORMAL; @@ -846,7 +911,7 @@ int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *dat dynalloc_logp = 6; total_bits<<=BITRES; tell = ec_tell_frac(dec); - for (i=st->start;i<st->end;i++) + for (i=start;i<end;i++) { int width, quanta; int dynalloc_loop_logp; @@ -885,84 +950,62 @@ int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *dat ALLOC(pulses, nbEBands, int); ALLOC(fine_priority, nbEBands, int); - codedBands = compute_allocation(mode, st->start, st->end, offsets, cap, + codedBands = compute_allocation(mode, start, end, offsets, cap, alloc_trim, &intensity, &dual_stereo, bits, &balance, pulses, fine_quant, fine_priority, C, LM, dec, 0, 0, 0); - unquant_fine_energy(mode, st->start, st->end, oldBandE, fine_quant, dec, C); + unquant_fine_energy(mode, start, end, oldBandE, fine_quant, dec, C); + + c=0; do { + OPUS_MOVE(decode_mem[c], decode_mem[c]+N, DECODE_BUFFER_SIZE-N+overlap/2); + } while (++c<CC); /* Decode fixed codebook */ ALLOC(collapse_masks, C*nbEBands, unsigned char); + +#ifdef NORM_ALIASING_HACK + /* This is an ugly hack that breaks aliasing rules and would be easily broken, + but it saves almost 4kB of stack. */ + X = (celt_norm*)(out_syn[CC-1]+overlap/2); +#else ALLOC(X, C*N, celt_norm); /**< Interleaved normalised MDCTs */ +#endif - quant_all_bands(0, mode, st->start, st->end, X, C==2 ? X+N : NULL, collapse_masks, + quant_all_bands(0, mode, start, end, X, C==2 ? X+N : NULL, collapse_masks, NULL, pulses, shortBlocks, spread_decision, dual_stereo, intensity, tf_res, - len*(8<<BITRES)-anti_collapse_rsv, balance, dec, LM, codedBands, &st->rng); + len*(8<<BITRES)-anti_collapse_rsv, balance, dec, LM, codedBands, &st->rng, st->arch); if (anti_collapse_rsv > 0) { anti_collapse_on = ec_dec_bits(dec, 1); } - unquant_energy_finalise(mode, st->start, st->end, oldBandE, + unquant_energy_finalise(mode, start, end, oldBandE, fine_quant, fine_priority, len*8-ec_tell(dec), dec, C); if (anti_collapse_on) anti_collapse(mode, X, collapse_masks, LM, C, N, - st->start, st->end, oldBandE, oldLogE, oldLogE2, pulses, st->rng); - - ALLOC(freq, IMAX(CC,C)*N, celt_sig); /**< Interleaved signal MDCTs */ + start, end, oldBandE, oldLogE, oldLogE2, pulses, st->rng, st->arch); if (silence) { for (i=0;i<C*nbEBands;i++) oldBandE[i] = -QCONST16(28.f,DB_SHIFT); - for (i=0;i<C*N;i++) - freq[i] = 0; - } else { - /* Synthesis */ - denormalise_bands(mode, X, freq, oldBandE, st->start, effEnd, C, M); } - c=0; do { - OPUS_MOVE(decode_mem[c], decode_mem[c]+N, DECODE_BUFFER_SIZE-N+overlap/2); - } while (++c<CC); - c=0; do { - int bound = M*eBands[effEnd]; - if (st->downsample!=1) - bound = IMIN(bound, N/st->downsample); - for (i=bound;i<N;i++) - freq[c*N+i] = 0; - } while (++c<C); - - c=0; do { - out_syn[c] = decode_mem[c]+DECODE_BUFFER_SIZE-N; - } while (++c<CC); - - if (CC==2&&C==1) - { - for (i=0;i<N;i++) - freq[N+i] = freq[i]; - } - if (CC==1&&C==2) - { - for (i=0;i<N;i++) - freq[i] = HALF32(ADD32(freq[i],freq[N+i])); - } - - /* Compute inverse MDCTs */ - compute_inv_mdcts(mode, shortBlocks, freq, out_syn, CC, LM); + celt_synthesis(mode, X, out_syn, oldBandE, start, effEnd, + C, CC, isTransient, LM, st->downsample, silence, st->arch); c=0; do { st->postfilter_period=IMAX(st->postfilter_period, COMBFILTER_MINPERIOD); st->postfilter_period_old=IMAX(st->postfilter_period_old, COMBFILTER_MINPERIOD); comb_filter(out_syn[c], out_syn[c], st->postfilter_period_old, st->postfilter_period, mode->shortMdctSize, st->postfilter_gain_old, st->postfilter_gain, st->postfilter_tapset_old, st->postfilter_tapset, - mode->window, overlap); + mode->window, overlap, st->arch); if (LM!=0) comb_filter(out_syn[c]+mode->shortMdctSize, out_syn[c]+mode->shortMdctSize, st->postfilter_period, postfilter_pitch, N-mode->shortMdctSize, st->postfilter_gain, postfilter_gain, st->postfilter_tapset, postfilter_tapset, - mode->window, overlap); + mode->window, overlap, st->arch); } while (++c<CC); st->postfilter_period_old = st->postfilter_period; @@ -978,32 +1021,36 @@ int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *dat st->postfilter_tapset_old = st->postfilter_tapset; } - if (C==1) { - for (i=0;i<nbEBands;i++) - oldBandE[nbEBands+i]=oldBandE[i]; - } + if (C==1) + OPUS_COPY(&oldBandE[nbEBands], oldBandE, nbEBands); /* In case start or end were to change */ if (!isTransient) { + opus_val16 max_background_increase; + OPUS_COPY(oldLogE2, oldLogE, 2*nbEBands); + OPUS_COPY(oldLogE, oldBandE, 2*nbEBands); + /* In normal circumstances, we only allow the noise floor to increase by + up to 2.4 dB/second, but when we're in DTX, we allow up to 6 dB + increase for each update.*/ + if (st->loss_count < 10) + max_background_increase = M*QCONST16(0.001f,DB_SHIFT); + else + max_background_increase = QCONST16(1.f,DB_SHIFT); for (i=0;i<2*nbEBands;i++) - oldLogE2[i] = oldLogE[i]; - for (i=0;i<2*nbEBands;i++) - oldLogE[i] = oldBandE[i]; - for (i=0;i<2*nbEBands;i++) - backgroundLogE[i] = MIN16(backgroundLogE[i] + M*QCONST16(0.001f,DB_SHIFT), oldBandE[i]); + backgroundLogE[i] = MIN16(backgroundLogE[i] + max_background_increase, oldBandE[i]); } else { for (i=0;i<2*nbEBands;i++) oldLogE[i] = MIN16(oldLogE[i], oldBandE[i]); } c=0; do { - for (i=0;i<st->start;i++) + for (i=0;i<start;i++) { oldBandE[c*nbEBands+i]=0; oldLogE[c*nbEBands+i]=oldLogE2[c*nbEBands+i]=-QCONST16(28.f,DB_SHIFT); } - for (i=st->end;i<nbEBands;i++) + for (i=end;i<nbEBands;i++) { oldBandE[c*nbEBands+i]=0; oldLogE[c*nbEBands+i]=oldLogE2[c*nbEBands+i]=-QCONST16(28.f,DB_SHIFT); @@ -1011,8 +1058,7 @@ int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *dat } while (++c<2); st->rng = dec->rng; - /* We reuse freq[] as scratch space for the de-emphasis */ - deemphasis(out_syn, pcm, N, CC, st->downsample, mode->preemph, st->preemph_memD, freq); + deemphasis(out_syn, pcm, N, CC, st->downsample, mode->preemph, st->preemph_memD, accum); st->loss_count = 0; RESTORE_STACK; if (ec_tell(dec) > 8*len) @@ -1028,7 +1074,7 @@ int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *dat #ifdef OPUS_FIXED_POINT int opus_custom_decode(CELTDecoder * OPUS_RESTRICT st, const unsigned char *data, int len, opus_int16 * OPUS_RESTRICT pcm, int frame_size) { - return celt_decode_with_ec(st, data, len, pcm, frame_size, NULL); + return celt_decode_with_ec(st, data, len, pcm, frame_size, NULL, 0); } #ifndef DISABLE_FLOAT_API @@ -1045,7 +1091,7 @@ int opus_custom_decode_float(CELTDecoder * OPUS_RESTRICT st, const unsigned char N = frame_size; ALLOC(out, C*N, opus_int16); - ret=celt_decode_with_ec(st, data, len, out, frame_size, NULL); + ret=celt_decode_with_ec(st, data, len, out, frame_size, NULL, 0); if (ret>0) for (j=0;j<C*ret;j++) pcm[j]=out[j]*(1.f/32768.f); @@ -1059,7 +1105,7 @@ int opus_custom_decode_float(CELTDecoder * OPUS_RESTRICT st, const unsigned char int opus_custom_decode_float(CELTDecoder * OPUS_RESTRICT st, const unsigned char *data, int len, float * OPUS_RESTRICT pcm, int frame_size) { - return celt_decode_with_ec(st, data, len, pcm, frame_size, NULL); + return celt_decode_with_ec(st, data, len, pcm, frame_size, NULL, 0); } int opus_custom_decode(CELTDecoder * OPUS_RESTRICT st, const unsigned char *data, int len, opus_int16 * OPUS_RESTRICT pcm, int frame_size) @@ -1075,7 +1121,7 @@ int opus_custom_decode(CELTDecoder * OPUS_RESTRICT st, const unsigned char *data N = frame_size; ALLOC(out, C*N, celt_sig); - ret=celt_decode_with_ec(st, data, len, out, frame_size, NULL); + ret=celt_decode_with_ec(st, data, len, out, frame_size, NULL, 0); if (ret>0) for (j=0;j<C*ret;j++) diff --git a/drivers/opus/celt/celt_encoder.c b/drivers/opus/celt/celt_encoder.c index 810ee5d743..9099bcd278 100644 --- a/drivers/opus/celt/celt_encoder.c +++ b/drivers/opus/celt/celt_encoder.c @@ -26,10 +26,7 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #define CELT_ENCODER_C @@ -40,7 +37,7 @@ #include "opus/celt/celt.h" #include "opus/celt/pitch.h" #include "opus/celt/bands.h" -#include "opus/celt/opus_modes.h" +#include "opus/celt/modes.h" #include "opus/celt/entcode.h" #include "opus/celt/quant_bands.h" #include "opus/celt/rate.h" @@ -57,7 +54,6 @@ */ struct OpusCustomEncoder { const OpusCustomMode *mode; /**< Mode used by the encoder */ - int overlap; int channels; int stream_channels; @@ -173,7 +169,6 @@ static int opus_custom_encoder_init_arch(CELTEncoder *st, const CELTMode *mode, OPUS_CLEAR((char*)st, opus_custom_encoder_get_size(mode, channels)); st->mode = mode; - st->overlap = mode->overlap; st->stream_channels = st->channels = channels; st->upsample = 1; @@ -276,8 +271,7 @@ static int transient_analysis(const opus_val32 * OPUS_RESTRICT in, int len, int } /*printf("\n");*/ /* First few samples are bad because we don't propagate the memory */ - for (i=0;i<12;i++) - tmp[i] = 0; + OPUS_CLEAR(tmp, 12); #ifdef OPUS_FIXED_POINT /* Normalize tmp to max range */ @@ -346,9 +340,9 @@ static int transient_analysis(const opus_val32 * OPUS_RESTRICT in, int len, int { int id; #ifdef OPUS_FIXED_POINT - id = IMAX(0,IMIN(127,MULT16_32_Q15(tmp[i],norm))); /* Do not round to nearest */ + id = MAX32(0,MIN32(127,MULT16_32_Q15(tmp[i]+EPSILON,norm))); /* Do not round to nearest */ #else - id = IMAX(0,IMIN(127,(int)floor(64*norm*tmp[i]))); /* Do not round to nearest */ + id = (int)MAX32(0,MIN32(127,floor(64*norm*(tmp[i]+EPSILON)))); /* Do not round to nearest */ #endif unmask += inv_table[id]; } @@ -366,7 +360,7 @@ static int transient_analysis(const opus_val32 * OPUS_RESTRICT in, int len, int /* Arbitrary metric for VBR boost */ tf_max = MAX16(0,celt_sqrt(27*mask_metric)-42); /* *tf_estimate = 1 + MIN16(1, sqrt(MAX16(0, tf_max-30))/20); */ - *tf_estimate = celt_sqrt(MAX16(0, SHL32(MULT16_16(QCONST16(0.0069,14),MIN16(163,tf_max)),14)-QCONST32(0.139,28))); + *tf_estimate = celt_sqrt(MAX32(0, SHL32(MULT16_16(QCONST16(0.0069,14),MIN16(163,tf_max)),14)-QCONST32(0.139,28))); /*printf("%d %f\n", tf_max, mask_metric);*/ RESTORE_STACK; #ifdef FUZZING @@ -378,8 +372,8 @@ static int transient_analysis(const opus_val32 * OPUS_RESTRICT in, int len, int /* Looks for sudden increases of energy to decide whether we need to patch the transient decision */ -int patch_transient_decision(opus_val16 *newE, opus_val16 *oldE, int nbEBands, - int end, int C) +static int patch_transient_decision(opus_val16 *newE, opus_val16 *oldE, int nbEBands, + int start, int end, int C) { int i, c; opus_val32 mean_diff=0; @@ -388,28 +382,28 @@ int patch_transient_decision(opus_val16 *newE, opus_val16 *oldE, int nbEBands, avoid false detection caused by irrelevant bands */ if (C==1) { - spread_old[0] = oldE[0]; - for (i=1;i<end;i++) + spread_old[start] = oldE[start]; + for (i=start+1;i<end;i++) spread_old[i] = MAX16(spread_old[i-1]-QCONST16(1.0f, DB_SHIFT), oldE[i]); } else { - spread_old[0] = MAX16(oldE[0],oldE[nbEBands]); - for (i=1;i<end;i++) + spread_old[start] = MAX16(oldE[start],oldE[start+nbEBands]); + for (i=start+1;i<end;i++) spread_old[i] = MAX16(spread_old[i-1]-QCONST16(1.0f, DB_SHIFT), MAX16(oldE[i],oldE[i+nbEBands])); } - for (i=end-2;i>=0;i--) + for (i=end-2;i>=start;i--) spread_old[i] = MAX16(spread_old[i], spread_old[i+1]-QCONST16(1.0f, DB_SHIFT)); /* Compute mean increase */ c=0; do { - for (i=2;i<end-1;i++) + for (i=IMAX(2,start);i<end-1;i++) { opus_val16 x1, x2; - x1 = MAX16(0, newE[i]); + x1 = MAX16(0, newE[i + c*nbEBands]); x2 = MAX16(0, spread_old[i]); mean_diff = ADD32(mean_diff, EXTEND32(MAX16(0, SUB16(x1, x2)))); } } while (++c<C); - mean_diff = DIV32(mean_diff, C*(end-3)); + mean_diff = DIV32(mean_diff, C*(end-1-IMAX(2,start))); /*printf("%f %f %d\n", mean_diff, max_diff, count);*/ return mean_diff > QCONST16(1.f, DB_SHIFT); } @@ -417,9 +411,10 @@ int patch_transient_decision(opus_val16 *newE, opus_val16 *oldE, int nbEBands, /** Apply window and compute the MDCT for all sub-frames and all channels in a frame */ static void compute_mdcts(const CELTMode *mode, int shortBlocks, celt_sig * OPUS_RESTRICT in, - celt_sig * OPUS_RESTRICT out, int C, int CC, int LM, int upsample) + celt_sig * OPUS_RESTRICT out, int C, int CC, int LM, int upsample, + int arch) { - const int overlap = OVERLAP(mode); + const int overlap = mode->overlap; int N; int B; int shift; @@ -438,7 +433,9 @@ static void compute_mdcts(const CELTMode *mode, int shortBlocks, celt_sig * OPUS for (b=0;b<B;b++) { /* Interleaving the sub-frames while doing the MDCTs */ - clt_mdct_forward(&mode->mdct, in+c*(B*N+overlap)+b*N, &out[b+c*N*B], mode->window, overlap, shift, B); + clt_mdct_forward(&mode->mdct, in+c*(B*N+overlap)+b*N, + &out[b+c*N*B], mode->window, overlap, shift, B, + arch); } } while (++c<CC); if (CC==2&&C==1) @@ -453,8 +450,7 @@ static void compute_mdcts(const CELTMode *mode, int shortBlocks, celt_sig * OPUS int bound = B*N/upsample; for (i=0;i<bound;i++) out[c*B*N+i] *= upsample; - for (;i<B*N;i++) - out[c*B*N+i] = 0; + OPUS_CLEAR(&out[c*B*N+bound], B*N-bound); } while (++c<C); } } @@ -469,26 +465,30 @@ void celt_preemphasis(const opus_val16 * OPUS_RESTRICT pcmp, celt_sig * OPUS_RES int Nu; coef0 = coef[0]; + m = *mem; + /* Fast path for the normal 48kHz case and no clipping */ + if (coef[1] == 0 && upsample == 1 && !clip) + { + for (i=0;i<N;i++) + { + opus_val16 x; + x = SCALEIN(pcmp[CC*i]); + /* Apply pre-emphasis */ + inp[i] = SHL32(x, SIG_SHIFT) - m; + m = SHR32(MULT16_16(coef0, x), 15-SIG_SHIFT); + } + *mem = m; + return; + } Nu = N/upsample; if (upsample!=1) { - for (i=0;i<N;i++) - inp[i] = 0; + OPUS_CLEAR(inp, N); } for (i=0;i<Nu;i++) - { - celt_sig x; - - x = SCALEIN(pcmp[CC*i]); -#ifndef OPUS_FIXED_POINT - /* Replace NaNs with zeros */ - if (!(x==x)) - x = 0; -#endif - inp[i*upsample] = x; - } + inp[i*upsample] = SCALEIN(pcmp[CC*i]); #ifndef OPUS_FIXED_POINT if (clip) @@ -500,7 +500,6 @@ void celt_preemphasis(const opus_val16 * OPUS_RESTRICT pcmp, celt_sig * OPUS_RES #else (void)clip; /* Avoids a warning about clip being unused. */ #endif - m = *mem; #ifdef CUSTOM_MODES if (coef[1] != 0) { @@ -520,11 +519,11 @@ void celt_preemphasis(const opus_val16 * OPUS_RESTRICT pcmp, celt_sig * OPUS_RES { for (i=0;i<N;i++) { - celt_sig x; - x = SHL32(inp[i], SIG_SHIFT); + opus_val16 x; + x = inp[i]; /* Apply pre-emphasis */ - inp[i] = x + m; - m = - MULT16_32_Q15(coef0, x); + inp[i] = SHL32(x, SIG_SHIFT) - m; + m = SHR32(MULT16_16(coef0, x), 15-SIG_SHIFT); } } *mem = m; @@ -575,15 +574,14 @@ static int tf_analysis(const CELTMode *m, int len, int isTransient, *tf_sum = 0; for (i=0;i<len;i++) { - int j, k, N; + int k, N; int narrow; opus_val32 L1, best_L1; int best_level=0; N = (m->eBands[i+1]-m->eBands[i])<<LM; /* band is too narrow to be split down to LM=-1 */ narrow = (m->eBands[i+1]-m->eBands[i])==1; - for (j=0;j<N;j++) - tmp[j] = X[tf_chan*N0 + j+(m->eBands[i]<<LM)]; + OPUS_COPY(tmp, &X[tf_chan*N0 + (m->eBands[i]<<LM)], N); /* Just add the right channel if we're in stereo */ /*if (C==2) for (j=0;j<N;j++) @@ -593,8 +591,7 @@ static int tf_analysis(const CELTMode *m, int len, int isTransient, /* Check the -1 case for transients */ if (isTransient && !narrow) { - for (j=0;j<N;j++) - tmp_1[j] = tmp[j]; + OPUS_COPY(tmp_1, tmp, N); haar1(tmp_1, N>>LM, 1<<LM); L1 = l1_metric(tmp_1, N, LM+1, bias); if (L1<best_L1) @@ -754,12 +751,12 @@ static void tf_encode(int start, int end, int isTransient, int *tf_res, int LM, static int alloc_trim_analysis(const CELTMode *m, const celt_norm *X, const opus_val16 *bandLogE, int end, int LM, int C, int N0, AnalysisInfo *analysis, opus_val16 *stereo_saving, opus_val16 tf_estimate, - int intensity, opus_val16 surround_trim) + int intensity, opus_val16 surround_trim, int arch) { int i; opus_val32 diff=0; int c; - int trim_index = 5; + int trim_index; opus_val16 trim = QCONST16(5.f, 8); opus_val16 logXC, logXC2; if (C==2) @@ -769,10 +766,9 @@ static int alloc_trim_analysis(const CELTMode *m, const celt_norm *X, /* Compute inter-channel correlation for low frequencies */ for (i=0;i<8;i++) { - int j; - opus_val32 partial = 0; - for (j=m->eBands[i]<<LM;j<m->eBands[i+1]<<LM;j++) - partial = MAC16_16(partial, X[j], X[N0+j]); + opus_val32 partial; + partial = celt_inner_prod(&X[m->eBands[i]<<LM], &X[N0+(m->eBands[i]<<LM)], + (m->eBands[i+1]-m->eBands[i])<<LM, arch); sum = ADD16(sum, EXTRACT16(SHR32(partial, 18))); } sum = MULT16_16_Q15(QCONST16(1.f/8, 15), sum); @@ -780,22 +776,13 @@ static int alloc_trim_analysis(const CELTMode *m, const celt_norm *X, minXC = sum; for (i=8;i<intensity;i++) { - int j; - opus_val32 partial = 0; - for (j=m->eBands[i]<<LM;j<m->eBands[i+1]<<LM;j++) - partial = MAC16_16(partial, X[j], X[N0+j]); + opus_val32 partial; + partial = celt_inner_prod(&X[m->eBands[i]<<LM], &X[N0+(m->eBands[i]<<LM)], + (m->eBands[i+1]-m->eBands[i])<<LM, arch); minXC = MIN16(minXC, ABS16(EXTRACT16(SHR32(partial, 18)))); } minXC = MIN16(QCONST16(1.f, 10), ABS16(minXC)); /*printf ("%f\n", sum);*/ - if (sum > QCONST16(.995f,10)) - trim_index-=4; - else if (sum > QCONST16(.92f,10)) - trim_index-=3; - else if (sum > QCONST16(.85f,10)) - trim_index-=2; - else if (sum > QCONST16(.8f,10)) - trim_index-=1; /* mid-side savings estimations based on the LF average*/ logXC = celt_log2(QCONST32(1.001f, 20)-MULT16_16(sum, sum)); /* mid-side savings estimations based on min correlation */ @@ -819,14 +806,6 @@ static int alloc_trim_analysis(const CELTMode *m, const celt_norm *X, } while (++c<C); diff /= C*(end-1); /*printf("%f\n", diff);*/ - if (diff > QCONST16(2.f, DB_SHIFT)) - trim_index--; - if (diff > QCONST16(8.f, DB_SHIFT)) - trim_index--; - if (diff < -QCONST16(4.f, DB_SHIFT)) - trim_index++; - if (diff < -QCONST16(10.f, DB_SHIFT)) - trim_index++; trim -= MAX16(-QCONST16(2.f, 8), MIN16(QCONST16(2.f, 8), SHR16(diff+QCONST16(1.f, DB_SHIFT),DB_SHIFT-8)/6 )); trim -= SHR16(surround_trim, DB_SHIFT-8); trim -= 2*SHR16(tf_estimate, 14-8); @@ -836,6 +815,8 @@ static int alloc_trim_analysis(const CELTMode *m, const celt_norm *X, trim -= MAX16(-QCONST16(2.f, 8), MIN16(QCONST16(2.f, 8), (opus_val16)(QCONST16(2.f, 8)*(analysis->tonality_slope+.05f)))); } +#else + (void)analysis; #endif #ifdef OPUS_FIXED_POINT @@ -843,10 +824,7 @@ static int alloc_trim_analysis(const CELTMode *m, const celt_norm *X, #else trim_index = (int)floor(.5f+trim); #endif - if (trim_index<0) - trim_index = 0; - if (trim_index>10) - trim_index = 10; + trim_index = IMAX(0, IMIN(10, trim_index)); /*printf("%d\n", trim_index);*/ #ifdef FUZZING trim_index = rand()%11; @@ -886,6 +864,66 @@ static int stereo_analysis(const CELTMode *m, const celt_norm *X, > MULT16_32_Q15(m->eBands[13]<<(LM+1), sumLR); } +#define MSWAP(a,b) do {opus_val16 tmp = a;a=b;b=tmp;} while(0) +static opus_val16 median_of_5(const opus_val16 *x) +{ + opus_val16 t0, t1, t2, t3, t4; + t2 = x[2]; + if (x[0] > x[1]) + { + t0 = x[1]; + t1 = x[0]; + } else { + t0 = x[0]; + t1 = x[1]; + } + if (x[3] > x[4]) + { + t3 = x[4]; + t4 = x[3]; + } else { + t3 = x[3]; + t4 = x[4]; + } + if (t0 > t3) + { + MSWAP(t0, t3); + MSWAP(t1, t4); + } + if (t2 > t1) + { + if (t1 < t3) + return MIN16(t2, t3); + else + return MIN16(t4, t1); + } else { + if (t2 < t3) + return MIN16(t1, t3); + else + return MIN16(t2, t4); + } +} + +static opus_val16 median_of_3(const opus_val16 *x) +{ + opus_val16 t0, t1, t2; + if (x[0] > x[1]) + { + t0 = x[1]; + t1 = x[0]; + } else { + t0 = x[0]; + t1 = x[1]; + } + t2 = x[2]; + if (t1 < t2) + return t1; + else if (t0 < t2) + return t2; + else + return t0; +} + static opus_val16 dynalloc_analysis(const opus_val16 *bandLogE, const opus_val16 *bandLogE2, int nbEBands, int start, int end, int C, int *offsets, int lsb_depth, const opus_int16 *logN, int isTransient, int vbr, int constrained_vbr, const opus_int16 *eBands, int LM, @@ -899,8 +937,7 @@ static opus_val16 dynalloc_analysis(const opus_val16 *bandLogE, const opus_val16 SAVE_STACK; ALLOC(follower, C*nbEBands, opus_val16); ALLOC(noise_floor, C*nbEBands, opus_val16); - for (i=0;i<nbEBands;i++) - offsets[i] = 0; + OPUS_CLEAR(offsets, nbEBands); /* Dynamic allocation code */ maxDepth=-QCONST16(31.9f, DB_SHIFT); for (i=0;i<end;i++) @@ -922,7 +959,11 @@ static opus_val16 dynalloc_analysis(const opus_val16 *bandLogE, const opus_val16 int last=0; c=0;do { - follower[c*nbEBands] = bandLogE2[c*nbEBands]; + opus_val16 offset; + opus_val16 tmp; + opus_val16 *f; + f = &follower[c*nbEBands]; + f[0] = bandLogE2[c*nbEBands]; for (i=1;i<end;i++) { /* The last band to be at least 3 dB higher than the previous one @@ -930,12 +971,26 @@ static opus_val16 dynalloc_analysis(const opus_val16 *bandLogE, const opus_val16 bandlimited signals. */ if (bandLogE2[c*nbEBands+i] > bandLogE2[c*nbEBands+i-1]+QCONST16(.5f,DB_SHIFT)) last=i; - follower[c*nbEBands+i] = MIN16(follower[c*nbEBands+i-1]+QCONST16(1.5f,DB_SHIFT), bandLogE2[c*nbEBands+i]); + f[i] = MIN16(f[i-1]+QCONST16(1.5f,DB_SHIFT), bandLogE2[c*nbEBands+i]); } for (i=last-1;i>=0;i--) - follower[c*nbEBands+i] = MIN16(follower[c*nbEBands+i], MIN16(follower[c*nbEBands+i+1]+QCONST16(2.f,DB_SHIFT), bandLogE2[c*nbEBands+i])); + f[i] = MIN16(f[i], MIN16(f[i+1]+QCONST16(2.f,DB_SHIFT), bandLogE2[c*nbEBands+i])); + + /* Combine with a median filter to avoid dynalloc triggering unnecessarily. + The "offset" value controls how conservative we are -- a higher offset + reduces the impact of the median filter and makes dynalloc use more bits. */ + offset = QCONST16(1.f, DB_SHIFT); + for (i=2;i<end-2;i++) + f[i] = MAX16(f[i], median_of_5(&bandLogE2[c*nbEBands+i-2])-offset); + tmp = median_of_3(&bandLogE2[c*nbEBands])-offset; + f[0] = MAX16(f[0], tmp); + f[1] = MAX16(f[1], tmp); + tmp = median_of_3(&bandLogE2[c*nbEBands+end-3])-offset; + f[end-2] = MAX16(f[end-2], tmp); + f[end-1] = MAX16(f[end-1], tmp); + for (i=0;i<end;i++) - follower[c*nbEBands+i] = MAX16(follower[c*nbEBands+i], noise_floor[i]); + f[i] = MAX16(f[i], noise_floor[i]); } while (++c<C); if (C==2) { @@ -1016,9 +1071,11 @@ static int run_prefilter(CELTEncoder *st, celt_sig *in, celt_sig *prefilter_mem, opus_val16 pf_threshold; int pf_on; int qg; + int overlap; SAVE_STACK; mode = st->mode; + overlap = mode->overlap; ALLOC(_pre, CC*(N+COMBFILTER_MAXPERIOD), celt_sig); pre[0] = _pre; @@ -1027,7 +1084,7 @@ static int run_prefilter(CELTEncoder *st, celt_sig *in, celt_sig *prefilter_mem, c=0; do { OPUS_COPY(pre[c], prefilter_mem+c*COMBFILTER_MAXPERIOD, COMBFILTER_MAXPERIOD); - OPUS_COPY(pre[c]+COMBFILTER_MAXPERIOD, in+c*(N+st->overlap)+st->overlap, N); + OPUS_COPY(pre[c]+COMBFILTER_MAXPERIOD, in+c*(N+overlap)+overlap, N); } while (++c<CC); if (enabled) @@ -1044,7 +1101,7 @@ static int run_prefilter(CELTEncoder *st, celt_sig *in, celt_sig *prefilter_mem, pitch_index = COMBFILTER_MAXPERIOD-pitch_index; gain1 = remove_doubling(pitch_buf, COMBFILTER_MAXPERIOD, COMBFILTER_MINPERIOD, - N, &pitch_index, st->prefilter_period, st->prefilter_gain); + N, &pitch_index, st->prefilter_period, st->prefilter_gain, st->arch); if (pitch_index > COMBFILTER_MAXPERIOD-2) pitch_index = COMBFILTER_MAXPERIOD-2; gain1 = MULT16_16_Q15(QCONST16(.7f,15),gain1); @@ -1100,18 +1157,18 @@ static int run_prefilter(CELTEncoder *st, celt_sig *in, celt_sig *prefilter_mem, /*printf("%d %f\n", pitch_index, gain1);*/ c=0; do { - int offset = mode->shortMdctSize-st->overlap; + int offset = mode->shortMdctSize-overlap; st->prefilter_period=IMAX(st->prefilter_period, COMBFILTER_MINPERIOD); - OPUS_COPY(in+c*(N+st->overlap), st->in_mem+c*(st->overlap), st->overlap); + OPUS_COPY(in+c*(N+overlap), st->in_mem+c*(overlap), overlap); if (offset) - comb_filter(in+c*(N+st->overlap)+st->overlap, pre[c]+COMBFILTER_MAXPERIOD, + comb_filter(in+c*(N+overlap)+overlap, pre[c]+COMBFILTER_MAXPERIOD, st->prefilter_period, st->prefilter_period, offset, -st->prefilter_gain, -st->prefilter_gain, - st->prefilter_tapset, st->prefilter_tapset, NULL, 0); + st->prefilter_tapset, st->prefilter_tapset, NULL, 0, st->arch); - comb_filter(in+c*(N+st->overlap)+st->overlap+offset, pre[c]+COMBFILTER_MAXPERIOD+offset, + comb_filter(in+c*(N+overlap)+overlap+offset, pre[c]+COMBFILTER_MAXPERIOD+offset, st->prefilter_period, pitch_index, N-offset, -st->prefilter_gain, -gain1, - st->prefilter_tapset, prefilter_tapset, mode->window, st->overlap); - OPUS_COPY(st->in_mem+c*(st->overlap), in+c*(N+st->overlap)+N, st->overlap); + st->prefilter_tapset, prefilter_tapset, mode->window, overlap, st->arch); + OPUS_COPY(st->in_mem+c*(overlap), in+c*(N+overlap)+N, overlap); if (N>COMBFILTER_MAXPERIOD) { @@ -1196,6 +1253,9 @@ static int compute_vbr(const CELTMode *mode, AnalysisInfo *analysis, opus_int32 /*printf("%f %f ", analysis->tonality, tonal);*/ target = tonal_target; } +#else + (void)analysis; + (void)pitch_change; #endif if (has_surround_mask&&!lfe) @@ -1273,6 +1333,8 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, int LM, M; int tf_select; int nbFilledBytes, nbAvailableBytes; + int start; + int end; int effEnd; int codedBands; int tf_sum; @@ -1316,6 +1378,8 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, nbEBands = mode->nbEBands; overlap = mode->overlap; eBands = mode->eBands; + start = st->start; + end = st->end; tf_estimate = 0; if (nbCompressedBytes<2 || pcm==NULL) { @@ -1335,8 +1399,8 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, M=1<<LM; N = M*mode->shortMdctSize; - prefilter_mem = st->in_mem+CC*(st->overlap); - oldBandE = (opus_val16*)(st->in_mem+CC*(st->overlap+COMBFILTER_MAXPERIOD)); + prefilter_mem = st->in_mem+CC*(overlap); + oldBandE = (opus_val16*)(st->in_mem+CC*(overlap+COMBFILTER_MAXPERIOD)); oldLogE = oldBandE + CC*nbEBands; oldLogE2 = oldLogE + CC*nbEBands; @@ -1352,8 +1416,8 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, #ifdef CUSTOM_MODES if (st->signalling && enc==NULL) { - int tmp = (mode->effEBands-st->end)>>1; - st->end = IMAX(1, mode->effEBands-tmp); + int tmp = (mode->effEBands-end)>>1; + end = st->end = IMAX(1, mode->effEBands-tmp); compressed[0] = tmp<<5; compressed[0] |= LM<<3; compressed[0] |= (C==2)<<2; @@ -1436,11 +1500,11 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, } total_bits = nbCompressedBytes*8; - effEnd = st->end; + effEnd = end; if (effEnd > mode->effEBands) effEnd = mode->effEBands; - ALLOC(in, CC*(N+st->overlap), celt_sig); + ALLOC(in, CC*(N+overlap), celt_sig); sample_max=MAX32(st->overlap_max, celt_maxabs16(pcm, C*(N-overlap)/st->upsample)); st->overlap_max=celt_maxabs16(pcm+C*(N-overlap)/st->upsample, C*overlap/st->upsample); @@ -1474,8 +1538,12 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, enc->nbits_total+=tell-ec_tell(enc); } c=0; do { - celt_preemphasis(pcm+c, in+c*(N+st->overlap)+st->overlap, N, CC, st->upsample, - mode->preemph, st->preemph_memE+c, st->clip); + int need_clip=0; +#ifndef OPUS_FIXED_POINT + need_clip = st->clip && sample_max>65536.f; +#endif + celt_preemphasis(pcm+c, in+c*(N+overlap)+overlap, N, CC, st->upsample, + mode->preemph, st->preemph_memE+c, need_clip); } while (++c<CC); @@ -1484,7 +1552,7 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, { int enabled; int qg; - enabled = ((st->lfe&&nbAvailableBytes>3) || nbAvailableBytes>12*C) && st->start==0 && !silence && !st->disable_pf + enabled = ((st->lfe&&nbAvailableBytes>3) || nbAvailableBytes>12*C) && start==0 && !silence && !st->disable_pf && st->complexity >= 5 && !(st->consec_transient && LM!=3 && st->variable_duration==OPUS_FRAMESIZE_VARIABLE); prefilter_tapset = st->tapset_decision; @@ -1494,7 +1562,7 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, pitch_change = 1; if (pf_on==0) { - if(st->start==0 && tell+16<=total_bits) + if(start==0 && tell+16<=total_bits) ec_enc_bit_logp(enc, 0, 1); } else { /*This block is not gated by a total bits check only because @@ -1515,7 +1583,7 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, shortBlocks = 0; if (st->complexity >= 1 && !st->lfe) { - isTransient = transient_analysis(in, N+st->overlap, CC, + isTransient = transient_analysis(in, N+overlap, CC, &tf_estimate, &tf_chan); } if (LM>0 && ec_tell(enc)+3<=total_bits) @@ -1535,33 +1603,32 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, ALLOC(bandLogE2, C*nbEBands, opus_val16); if (secondMdct) { - compute_mdcts(mode, 0, in, freq, C, CC, LM, st->upsample); - compute_band_energies(mode, freq, bandE, effEnd, C, M); - amp2Log2(mode, effEnd, st->end, bandE, bandLogE2, C); + compute_mdcts(mode, 0, in, freq, C, CC, LM, st->upsample, st->arch); + compute_band_energies(mode, freq, bandE, effEnd, C, LM); + amp2Log2(mode, effEnd, end, bandE, bandLogE2, C); for (i=0;i<C*nbEBands;i++) bandLogE2[i] += HALF16(SHL16(LM, DB_SHIFT)); } - compute_mdcts(mode, shortBlocks, in, freq, C, CC, LM, st->upsample); + compute_mdcts(mode, shortBlocks, in, freq, C, CC, LM, st->upsample, st->arch); if (CC==2&&C==1) tf_chan = 0; - compute_band_energies(mode, freq, bandE, effEnd, C, M); + compute_band_energies(mode, freq, bandE, effEnd, C, LM); if (st->lfe) { - for (i=2;i<st->end;i++) + for (i=2;i<end;i++) { bandE[i] = IMIN(bandE[i], MULT16_32_Q15(QCONST16(1e-4f,15),bandE[0])); bandE[i] = MAX32(bandE[i], EPSILON); } } - amp2Log2(mode, effEnd, st->end, bandE, bandLogE, C); + amp2Log2(mode, effEnd, end, bandE, bandLogE, C); ALLOC(surround_dynalloc, C*nbEBands, opus_val16); - for(i=0;i<st->end;i++) - surround_dynalloc[i] = 0; + OPUS_CLEAR(surround_dynalloc, end); /* This computes how much masking takes place between surround channels */ - if (st->start==0&&st->energy_mask&&!st->lfe) + if (start==0&&st->energy_mask&&!st->lfe) { int mask_end; int midband; @@ -1584,6 +1651,7 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, diff += MULT16_16(mask, 1+2*i-mask_end); } } + celt_assert(count>0); mask_avg = DIV32_16(mask_avg,count); mask_avg += QCONST16(.2f, DB_SHIFT); diff = diff*6/(C*(mask_end-1)*(mask_end+1)*mask_end); @@ -1621,8 +1689,7 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, disabling masking. */ mask_avg = 0; diff = 0; - for(i=0;i<mask_end;i++) - surround_dynalloc[i] = 0; + OPUS_CLEAR(surround_dynalloc, mask_end); } else { for(i=0;i<mask_end;i++) surround_dynalloc[i] = MAX16(0, surround_dynalloc[i]-QCONST16(.25f, DB_SHIFT)); @@ -1640,14 +1707,14 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, opus_val16 follow=-QCONST16(10.0f,DB_SHIFT); opus_val32 frame_avg=0; opus_val16 offset = shortBlocks?HALF16(SHL16(LM, DB_SHIFT)):0; - for(i=st->start;i<st->end;i++) + for(i=start;i<end;i++) { follow = MAX16(follow-QCONST16(1.f, DB_SHIFT), bandLogE[i]-offset); if (C==2) follow = MAX16(follow, bandLogE[i+nbEBands]-offset); frame_avg += follow; } - frame_avg /= (st->end-st->start); + frame_avg /= (end-start); temporal_vbr = SUB16(frame_avg,st->spec_avg); temporal_vbr = MIN16(QCONST16(3.f, DB_SHIFT), MAX16(-QCONST16(1.5f, DB_SHIFT), temporal_vbr)); st->spec_avg += MULT16_16_Q15(QCONST16(.02f, 15), temporal_vbr); @@ -1658,21 +1725,20 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, if (!secondMdct) { - for (i=0;i<C*nbEBands;i++) - bandLogE2[i] = bandLogE[i]; + OPUS_COPY(bandLogE2, bandLogE, C*nbEBands); } /* Last chance to catch any transient we might have missed in the time-domain analysis */ if (LM>0 && ec_tell(enc)+3<=total_bits && !isTransient && st->complexity>=5 && !st->lfe) { - if (patch_transient_decision(bandLogE, oldBandE, nbEBands, st->end, C)) + if (patch_transient_decision(bandLogE, oldBandE, nbEBands, start, end, C)) { isTransient = 1; shortBlocks = M; - compute_mdcts(mode, shortBlocks, in, freq, C, CC, LM, st->upsample); - compute_band_energies(mode, freq, bandE, effEnd, C, M); - amp2Log2(mode, effEnd, st->end, bandE, bandLogE, C); + compute_mdcts(mode, shortBlocks, in, freq, C, CC, LM, st->upsample, st->arch); + compute_band_energies(mode, freq, bandE, effEnd, C, LM); + amp2Log2(mode, effEnd, end, bandE, bandLogE, C); /* Compensate for the scaling of short vs long mdcts */ for (i=0;i<C*nbEBands;i++) bandLogE2[i] += HALF16(SHL16(LM, DB_SHIFT)); @@ -1690,7 +1756,7 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, ALLOC(tf_res, nbEBands, int); /* Disable variable tf resolution for hybrid and at very low bitrate */ - if (effectiveBytes>=15*C && st->start==0 && st->complexity>=2 && !st->lfe) + if (effectiveBytes>=15*C && start==0 && st->complexity>=2 && !st->lfe) { int lambda; if (effectiveBytes<40) @@ -1703,22 +1769,22 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, lambda = 3; lambda*=2; tf_select = tf_analysis(mode, effEnd, isTransient, tf_res, lambda, X, N, LM, &tf_sum, tf_estimate, tf_chan); - for (i=effEnd;i<st->end;i++) + for (i=effEnd;i<end;i++) tf_res[i] = tf_res[effEnd-1]; } else { tf_sum = 0; - for (i=0;i<st->end;i++) + for (i=0;i<end;i++) tf_res[i] = isTransient; tf_select=0; } ALLOC(error, C*nbEBands, opus_val16); - quant_coarse_energy(mode, st->start, st->end, effEnd, bandLogE, + quant_coarse_energy(mode, start, end, effEnd, bandLogE, oldBandE, total_bits, error, enc, C, LM, nbAvailableBytes, st->force_intra, &st->delayedIntra, st->complexity >= 4, st->loss_rate, st->lfe); - tf_encode(st->start, st->end, isTransient, tf_res, LM, tf_select, enc); + tf_encode(start, end, isTransient, tf_res, LM, tf_select, enc); if (ec_tell(enc)+4<=total_bits) { @@ -1726,7 +1792,7 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, { st->tapset_decision = 0; st->spread_decision = SPREAD_NORMAL; - } else if (shortBlocks || st->complexity < 3 || nbAvailableBytes < 10*C || st->start != 0) + } else if (shortBlocks || st->complexity < 3 || nbAvailableBytes < 10*C || start != 0) { if (st->complexity == 0) st->spread_decision = SPREAD_NONE; @@ -1760,7 +1826,7 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, ALLOC(offsets, nbEBands, int); - maxDepth = dynalloc_analysis(bandLogE, bandLogE2, nbEBands, st->start, st->end, C, offsets, + maxDepth = dynalloc_analysis(bandLogE, bandLogE2, nbEBands, start, end, C, offsets, st->lsb_depth, mode->logN, isTransient, st->vbr, st->constrained_vbr, eBands, LM, effectiveBytes, &tot_boost, st->lfe, surround_dynalloc); /* For LFE, everything interesting is in the first band */ @@ -1773,7 +1839,7 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, total_bits<<=BITRES; total_boost = 0; tell = ec_tell_frac(enc); - for (i=st->start;i<st->end;i++) + for (i=start;i<end;i++) { int width, quanta; int dynalloc_loop_logp; @@ -1818,7 +1884,7 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, st->intensity = hysteresis_decision((opus_val16)(equiv_rate/1000), intensity_thresholds, intensity_histeresis, 21, st->intensity); - st->intensity = IMIN(st->end,IMAX(st->start, st->intensity)); + st->intensity = IMIN(end,IMAX(start, st->intensity)); } alloc_trim = 5; @@ -1828,7 +1894,8 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, alloc_trim = 5; else alloc_trim = alloc_trim_analysis(mode, X, bandLogE, - st->end, LM, C, N, &st->analysis, &st->stereo_saving, tf_estimate, st->intensity, surround_trim); + end, LM, C, N, &st->analysis, &st->stereo_saving, tf_estimate, + st->intensity, surround_trim, st->arch); ec_enc_icdf(enc, alloc_trim, trim_icdf, 7); tell = ec_tell_frac(enc); } @@ -1930,7 +1997,7 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, bits = (((opus_int32)nbCompressedBytes*8)<<BITRES) - ec_tell_frac(enc) - 1; anti_collapse_rsv = isTransient&&LM>=2&&bits>=((LM+2)<<BITRES) ? (1<<BITRES) : 0; bits -= anti_collapse_rsv; - signalBandwidth = st->end-1; + signalBandwidth = end-1; #ifndef DISABLE_FLOAT_API if (st->analysis.valid) { @@ -1950,7 +2017,7 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, #endif if (st->lfe) signalBandwidth = 1; - codedBands = compute_allocation(mode, st->start, st->end, offsets, cap, + codedBands = compute_allocation(mode, start, end, offsets, cap, alloc_trim, &st->intensity, &dual_stereo, bits, &balance, pulses, fine_quant, fine_priority, C, LM, enc, 1, st->lastCodedBands, signalBandwidth); if (st->lastCodedBands) @@ -1958,13 +2025,14 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, else st->lastCodedBands = codedBands; - quant_fine_energy(mode, st->start, st->end, oldBandE, error, fine_quant, enc, C); + quant_fine_energy(mode, start, end, oldBandE, error, fine_quant, enc, C); /* Residual quantisation */ ALLOC(collapse_masks, C*nbEBands, unsigned char); - quant_all_bands(1, mode, st->start, st->end, X, C==2 ? X+N : NULL, collapse_masks, - bandE, pulses, shortBlocks, st->spread_decision, dual_stereo, st->intensity, tf_res, - nbCompressedBytes*(8<<BITRES)-anti_collapse_rsv, balance, enc, LM, codedBands, &st->rng); + quant_all_bands(1, mode, start, end, X, C==2 ? X+N : NULL, collapse_masks, + bandE, pulses, shortBlocks, st->spread_decision, + dual_stereo, st->intensity, tf_res, nbCompressedBytes*(8<<BITRES)-anti_collapse_rsv, + balance, enc, LM, codedBands, &st->rng, st->arch); if (anti_collapse_rsv > 0) { @@ -1974,7 +2042,7 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, #endif ec_enc_bits(enc, anti_collapse_on, 1); } - quant_energy_finalise(mode, st->start, st->end, oldBandE, error, fine_quant, fine_priority, nbCompressedBytes*8-ec_tell(enc), enc, C); + quant_energy_finalise(mode, start, end, oldBandE, error, fine_quant, fine_priority, nbCompressedBytes*8-ec_tell(enc), enc, C); if (silence) { @@ -1990,40 +2058,26 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, if (anti_collapse_on) { anti_collapse(mode, X, collapse_masks, LM, C, N, - st->start, st->end, oldBandE, oldLogE, oldLogE2, pulses, st->rng); - } - - if (silence) - { - for (i=0;i<C*N;i++) - freq[i] = 0; - } else { - /* Synthesis */ - denormalise_bands(mode, X, freq, oldBandE, st->start, effEnd, C, M); + start, end, oldBandE, oldLogE, oldLogE2, pulses, st->rng); } c=0; do { OPUS_MOVE(st->syn_mem[c], st->syn_mem[c]+N, 2*MAX_PERIOD-N+overlap/2); } while (++c<CC); - if (CC==2&&C==1) - { - for (i=0;i<N;i++) - freq[N+i] = freq[i]; - } - c=0; do { out_mem[c] = st->syn_mem[c]+2*MAX_PERIOD-N; } while (++c<CC); - compute_inv_mdcts(mode, shortBlocks, freq, out_mem, CC, LM); + celt_synthesis(mode, X, out_mem, oldBandE, start, effEnd, + C, CC, isTransient, LM, st->upsample, silence, st->arch); c=0; do { st->prefilter_period=IMAX(st->prefilter_period, COMBFILTER_MINPERIOD); st->prefilter_period_old=IMAX(st->prefilter_period_old, COMBFILTER_MINPERIOD); comb_filter(out_mem[c], out_mem[c], st->prefilter_period_old, st->prefilter_period, mode->shortMdctSize, st->prefilter_gain_old, st->prefilter_gain, st->prefilter_tapset_old, st->prefilter_tapset, - mode->window, st->overlap); + mode->window, overlap); if (LM!=0) comb_filter(out_mem[c]+mode->shortMdctSize, out_mem[c]+mode->shortMdctSize, st->prefilter_period, pitch_index, N-mode->shortMdctSize, st->prefilter_gain, gain1, st->prefilter_tapset, prefilter_tapset, @@ -2031,7 +2085,7 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, } while (++c<CC); /* We reuse freq[] as scratch space for the de-emphasis */ - deemphasis(out_mem, (opus_val16*)pcm, N, CC, st->upsample, mode->preemph, st->preemph_memD, freq); + deemphasis(out_mem, (opus_val16*)pcm, N, CC, st->upsample, mode->preemph, st->preemph_memD); st->prefilter_period_old = st->prefilter_period; st->prefilter_gain_old = st->prefilter_gain; st->prefilter_tapset_old = st->prefilter_tapset; @@ -2051,16 +2105,13 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, #endif if (CC==2&&C==1) { - for (i=0;i<nbEBands;i++) - oldBandE[nbEBands+i]=oldBandE[i]; + OPUS_COPY(&oldBandE[nbEBands], oldBandE, nbEBands); } if (!isTransient) { - for (i=0;i<CC*nbEBands;i++) - oldLogE2[i] = oldLogE[i]; - for (i=0;i<CC*nbEBands;i++) - oldLogE[i] = oldBandE[i]; + OPUS_COPY(oldLogE2, oldLogE, CC*nbEBands); + OPUS_COPY(oldLogE, oldBandE, CC*nbEBands); } else { for (i=0;i<CC*nbEBands;i++) oldLogE[i] = MIN16(oldLogE[i], oldBandE[i]); @@ -2068,12 +2119,12 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, /* In case start or end were to change */ c=0; do { - for (i=0;i<st->start;i++) + for (i=0;i<start;i++) { oldBandE[c*nbEBands+i]=0; oldLogE[c*nbEBands+i]=oldLogE2[c*nbEBands+i]=-QCONST16(28.f,DB_SHIFT); } - for (i=st->end;i<nbEBands;i++) + for (i=end;i<nbEBands;i++) { oldBandE[c*nbEBands+i]=0; oldLogE[c*nbEBands+i]=oldLogE2[c*nbEBands+i]=-QCONST16(28.f,DB_SHIFT); @@ -2274,7 +2325,7 @@ int opus_custom_encoder_ctl(CELTEncoder * OPUS_RESTRICT st, int request, ...) { int i; opus_val16 *oldBandE, *oldLogE, *oldLogE2; - oldBandE = (opus_val16*)(st->in_mem+st->channels*(st->overlap+COMBFILTER_MAXPERIOD)); + oldBandE = (opus_val16*)(st->in_mem+st->channels*(st->mode->overlap+COMBFILTER_MAXPERIOD)); oldLogE = oldBandE + st->channels*st->mode->nbEBands; oldLogE2 = oldLogE + st->channels*st->mode->nbEBands; OPUS_CLEAR((char*)&st->ENCODER_RESET_START, diff --git a/drivers/opus/celt/celt_lpc.c b/drivers/opus/celt/celt_lpc.c index ad0a6dfd43..5b8c01021f 100644 --- a/drivers/opus/celt/celt_lpc.c +++ b/drivers/opus/celt/celt_lpc.c @@ -24,10 +24,7 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/celt/celt_lpc.h" #include "opus/celt/stack_alloc.h" @@ -88,12 +85,15 @@ int p #endif } -void celt_fir(const opus_val16 *_x, + +void celt_fir_c( + const opus_val16 *_x, const opus_val16 *num, opus_val16 *_y, int N, int ord, - opus_val16 *mem) + opus_val16 *mem, + int arch) { int i,j; VARDECL(opus_val16, rnum); @@ -111,6 +111,7 @@ void celt_fir(const opus_val16 *_x, for(i=0;i<ord;i++) mem[i] = _x[N-i-1]; #ifdef SMALL_FOOTPRINT + (void)arch; for (i=0;i<N;i++) { opus_val32 sum = SHL32(EXTEND32(_x[i]), SIG_SHIFT); @@ -124,7 +125,7 @@ void celt_fir(const opus_val16 *_x, for (i=0;i<N-3;i+=4) { opus_val32 sum[4]={0,0,0,0}; - xcorr_kernel(rnum, x+i, sum, ord); + xcorr_kernel(rnum, x+i, sum, ord, arch); _y[i ] = SATURATE16(ADD32(EXTEND32(_x[i ]), PSHR32(sum[0], SIG_SHIFT))); _y[i+1] = SATURATE16(ADD32(EXTEND32(_x[i+1]), PSHR32(sum[1], SIG_SHIFT))); _y[i+2] = SATURATE16(ADD32(EXTEND32(_x[i+2]), PSHR32(sum[2], SIG_SHIFT))); @@ -146,10 +147,12 @@ void celt_iir(const opus_val32 *_x, opus_val32 *_y, int N, int ord, - opus_val16 *mem) + opus_val16 *mem, + int arch) { #ifdef SMALL_FOOTPRINT int i,j; + (void)arch; for (i=0;i<N;i++) { opus_val32 sum = _x[i]; @@ -187,7 +190,7 @@ void celt_iir(const opus_val32 *_x, sum[1]=_x[i+1]; sum[2]=_x[i+2]; sum[3]=_x[i+3]; - xcorr_kernel(rden, y+i, sum, ord); + xcorr_kernel(rden, y+i, sum, ord, arch); /* Patch up the result to compensate for the fact that this is an IIR */ y[i+ord ] = -ROUND16(sum[0],SIG_SHIFT); diff --git a/drivers/opus/celt/celt_lpc.h b/drivers/opus/celt/celt_lpc.h index 12bb78a6fd..dc0352d468 100644 --- a/drivers/opus/celt/celt_lpc.h +++ b/drivers/opus/celt/celt_lpc.h @@ -29,24 +29,37 @@ #define PLC_H #include "opus/celt/arch.h" +#include "opus/celt/cpu_support.h" + +#if defined(OPUS_X86_MAY_HAVE_SSE4_1) +#include "opus/celt/x86/celt_lpc_sse.h" +#endif #define LPC_ORDER 24 void _celt_lpc(opus_val16 *_lpc, const opus_val32 *ac, int p); -void celt_fir(const opus_val16 *x, +void celt_fir_c( + const opus_val16 *x, const opus_val16 *num, opus_val16 *y, int N, int ord, - opus_val16 *mem); + opus_val16 *mem, + int arch); + +#if !defined(OVERRIDE_CELT_FIR) +#define celt_fir(x, num, y, N, ord, mem, arch) \ + (celt_fir_c(x, num, y, N, ord, mem, arch)) +#endif void celt_iir(const opus_val32 *x, const opus_val16 *den, opus_val32 *y, int N, int ord, - opus_val16 *mem); + opus_val16 *mem, + int arch); int _celt_autocorr(const opus_val16 *x, opus_val32 *ac, const opus_val16 *window, int overlap, int lag, int n, int arch); diff --git a/drivers/opus/celt/cpu_support.h b/drivers/opus/celt/cpu_support.h index f682a1d19e..2507e1861e 100644 --- a/drivers/opus/celt/cpu_support.h +++ b/drivers/opus/celt/cpu_support.h @@ -31,8 +31,9 @@ #include "opus/opus_types.h" #include "opus/opus_defines.h" -#if defined(OPUS_HAVE_RTCD) && defined(OPUS_ARM_ASM) -#include "arm/armcpu.h" +#if defined(OPUS_HAVE_RTCD) && \ + (defined(OPUS_ARM_ASM) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR)) +#include "opus/celt/arm/armcpu.h" /* We currently support 4 ARM variants: * arch[0] -> ARMv4 @@ -42,6 +43,22 @@ */ #define OPUS_ARCHMASK 3 +#elif (defined(OPUS_X86_MAY_HAVE_SSE) && !defined(OPUS_X86_PRESUME_SSE)) || \ + (defined(OPUS_X86_MAY_HAVE_SSE2) && !defined(OPUS_X86_PRESUME_SSE2)) || \ + (defined(OPUS_X86_MAY_HAVE_SSE4_1) && !defined(OPUS_X86_PRESUME_SSE4_1)) || \ + (defined(OPUS_X86_MAY_HAVE_AVX) && !defined(OPUS_X86_PRESUME_AVX)) + +#include "opus/celt/x86/x86cpu.h" +/* We currently support 5 x86 variants: + * arch[0] -> non-sse + * arch[1] -> sse + * arch[2] -> sse2 + * arch[3] -> sse4.1 + * arch[4] -> avx + */ +#define OPUS_ARCHMASK 7 +int opus_select_arch(void); + #else #define OPUS_ARCHMASK 0 @@ -50,5 +67,4 @@ static OPUS_INLINE int opus_select_arch(void) return 0; } #endif - #endif diff --git a/drivers/opus/celt/cwrs.c b/drivers/opus/celt/cwrs.c index bae9d21b97..983d4580a9 100644 --- a/drivers/opus/celt/cwrs.c +++ b/drivers/opus/celt/cwrs.c @@ -26,10 +26,7 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/celt/os_support.h" #include "opus/celt/cwrs.h" @@ -460,10 +457,12 @@ void encode_pulses(const int *_y,int _n,int _k,ec_enc *_enc){ ec_enc_uint(_enc,icwrs(_n,_y),CELT_PVQ_V(_n,_k)); } -static void cwrsi(int _n,int _k,opus_uint32 _i,int *_y){ +static opus_val32 cwrsi(int _n,int _k,opus_uint32 _i,int *_y){ opus_uint32 p; int s; int k0; + opus_int16 val; + opus_val32 yy=0; celt_assert(_k>0); celt_assert(_n>1); while(_n>2){ @@ -487,7 +486,9 @@ static void cwrsi(int _n,int _k,opus_uint32 _i,int *_y){ } else for(p=row[_k];p>_i;p=row[_k])_k--; _i-=p; - *_y++=(k0-_k+s)^s; + val=(k0-_k+s)^s; + *_y++=val; + yy=MAC16_16(yy,val,val); } /*Lots of dimensions case:*/ else{ @@ -507,7 +508,9 @@ static void cwrsi(int _n,int _k,opus_uint32 _i,int *_y){ do p=CELT_PVQ_U_ROW[--_k][_n]; while(p>_i); _i-=p; - *_y++=(k0-_k+s)^s; + val=(k0-_k+s)^s; + *_y++=val; + yy=MAC16_16(yy,val,val); } } _n--; @@ -519,14 +522,19 @@ static void cwrsi(int _n,int _k,opus_uint32 _i,int *_y){ k0=_k; _k=(_i+1)>>1; if(_k)_i-=2*_k-1; - *_y++=(k0-_k+s)^s; + val=(k0-_k+s)^s; + *_y++=val; + yy=MAC16_16(yy,val,val); /*_n==1*/ s=-(int)_i; - *_y=(_k+s)^s; + val=(_k+s)^s; + *_y=val; + yy=MAC16_16(yy,val,val); + return yy; } -void decode_pulses(int *_y,int _n,int _k,ec_dec *_dec){ - cwrsi(_n,_k,ec_dec_uint(_dec,CELT_PVQ_V(_n,_k)),_y); +opus_val32 decode_pulses(int *_y,int _n,int _k,ec_dec *_dec){ + return cwrsi(_n,_k,ec_dec_uint(_dec,CELT_PVQ_V(_n,_k)),_y); } #else /* SMALL_FOOTPRINT */ @@ -591,8 +599,10 @@ static opus_uint32 ncwrs_urow(unsigned _n,unsigned _k,opus_uint32 *_u){ _y: Returns the vector of pulses. _u: Must contain entries [0..._k+1] of row _n of U() on input. Its contents will be destructively modified.*/ -static void cwrsi(int _n,int _k,opus_uint32 _i,int *_y,opus_uint32 *_u){ +static opus_val32 cwrsi(int _n,int _k,opus_uint32 _i,int *_y,opus_uint32 *_u){ int j; + opus_int16 val; + opus_val32 yy=0; celt_assert(_n>0); j=0; do{ @@ -607,10 +617,13 @@ static void cwrsi(int _n,int _k,opus_uint32 _i,int *_y,opus_uint32 *_u){ while(p>_i)p=_u[--_k]; _i-=p; yj-=_k; - _y[j]=(yj+s)^s; + val=(yj+s)^s; + _y[j]=val; + yy=MAC16_16(yy,val,val); uprev(_u,_k+2,0); } while(++j<_n); + return yy; } /*Returns the index of the given combination of K elements chosen from a set @@ -685,13 +698,15 @@ void encode_pulses(const int *_y,int _n,int _k,ec_enc *_enc){ RESTORE_STACK; } -void decode_pulses(int *_y,int _n,int _k,ec_dec *_dec){ +opus_val32 decode_pulses(int *_y,int _n,int _k,ec_dec *_dec){ VARDECL(opus_uint32,u); + int ret; SAVE_STACK; celt_assert(_k>0); ALLOC(u,_k+2U,opus_uint32); - cwrsi(_n,_k,ec_dec_uint(_dec,ncwrs_urow(_n,_k,u)),_y,u); + ret = cwrsi(_n,_k,ec_dec_uint(_dec,ncwrs_urow(_n,_k,u)),_y,u); RESTORE_STACK; + return ret; } #endif /* SMALL_FOOTPRINT */ diff --git a/drivers/opus/celt/cwrs.h b/drivers/opus/celt/cwrs.h index 5400afa6a4..f0ea844e5e 100644 --- a/drivers/opus/celt/cwrs.h +++ b/drivers/opus/celt/cwrs.h @@ -43,6 +43,6 @@ void get_required_bits(opus_int16 *bits, int N, int K, int frac); void encode_pulses(const int *_y, int N, int K, ec_enc *enc); -void decode_pulses(int *_y, int N, int K, ec_dec *dec); +opus_val32 decode_pulses(int *_y, int N, int K, ec_dec *dec); #endif /* CWRS_H */ diff --git a/drivers/opus/celt/entcode.c b/drivers/opus/celt/entcode.c index 5c9874908d..d1c6b25c7f 100644 --- a/drivers/opus/celt/entcode.c +++ b/drivers/opus/celt/entcode.c @@ -24,10 +24,7 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/celt/entcode.h" #include "opus/celt/arch.h" @@ -62,6 +59,27 @@ int ec_ilog(opus_uint32 _v){ } #endif +#if 1 +/* This is a faster version of ec_tell_frac() that takes advantage + of the low (1/8 bit) resolution to use just a linear function + followed by a lookup to determine the exact transition thresholds. */ +opus_uint32 ec_tell_frac(ec_ctx *_this){ + static const unsigned correction[8] = + {35733, 38967, 42495, 46340, + 50535, 55109, 60097, 65535}; + opus_uint32 nbits; + opus_uint32 r; + int l; + unsigned b; + nbits=_this->nbits_total<<BITRES; + l=EC_ILOG(_this->rng); + r=_this->rng>>(l-16); + b = (r>>12)-8; + b += r>correction[b]; + l = (l<<3)+b; + return nbits-l; +} +#else opus_uint32 ec_tell_frac(ec_ctx *_this){ opus_uint32 nbits; opus_uint32 r; @@ -91,3 +109,42 @@ opus_uint32 ec_tell_frac(ec_ctx *_this){ } return nbits-l; } +#endif + +#ifdef USE_SMALL_DIV_TABLE +/* Result of 2^32/(2*i+1), except for i=0. */ +const opus_uint32 SMALL_DIV_TABLE[129] = { + 0xFFFFFFFF, 0x55555555, 0x33333333, 0x24924924, + 0x1C71C71C, 0x1745D174, 0x13B13B13, 0x11111111, + 0x0F0F0F0F, 0x0D79435E, 0x0C30C30C, 0x0B21642C, + 0x0A3D70A3, 0x097B425E, 0x08D3DCB0, 0x08421084, + 0x07C1F07C, 0x07507507, 0x06EB3E45, 0x06906906, + 0x063E7063, 0x05F417D0, 0x05B05B05, 0x0572620A, + 0x05397829, 0x05050505, 0x04D4873E, 0x04A7904A, + 0x047DC11F, 0x0456C797, 0x04325C53, 0x04104104, + 0x03F03F03, 0x03D22635, 0x03B5CC0E, 0x039B0AD1, + 0x0381C0E0, 0x0369D036, 0x03531DEC, 0x033D91D2, + 0x0329161F, 0x03159721, 0x03030303, 0x02F14990, + 0x02E05C0B, 0x02D02D02, 0x02C0B02C, 0x02B1DA46, + 0x02A3A0FD, 0x0295FAD4, 0x0288DF0C, 0x027C4597, + 0x02702702, 0x02647C69, 0x02593F69, 0x024E6A17, + 0x0243F6F0, 0x0239E0D5, 0x02302302, 0x0226B902, + 0x021D9EAD, 0x0214D021, 0x020C49BA, 0x02040810, + 0x01FC07F0, 0x01F44659, 0x01ECC07B, 0x01E573AC, + 0x01DE5D6E, 0x01D77B65, 0x01D0CB58, 0x01CA4B30, + 0x01C3F8F0, 0x01BDD2B8, 0x01B7D6C3, 0x01B20364, + 0x01AC5701, 0x01A6D01A, 0x01A16D3F, 0x019C2D14, + 0x01970E4F, 0x01920FB4, 0x018D3018, 0x01886E5F, + 0x0183C977, 0x017F405F, 0x017AD220, 0x01767DCE, + 0x01724287, 0x016E1F76, 0x016A13CD, 0x01661EC6, + 0x01623FA7, 0x015E75BB, 0x015AC056, 0x01571ED3, + 0x01539094, 0x01501501, 0x014CAB88, 0x0149539E, + 0x01460CBC, 0x0142D662, 0x013FB013, 0x013C995A, + 0x013991C2, 0x013698DF, 0x0133AE45, 0x0130D190, + 0x012E025C, 0x012B404A, 0x01288B01, 0x0125E227, + 0x01234567, 0x0120B470, 0x011E2EF3, 0x011BB4A4, + 0x01194538, 0x0116E068, 0x011485F0, 0x0112358E, + 0x010FEF01, 0x010DB20A, 0x010B7E6E, 0x010953F3, + 0x01073260, 0x0105197F, 0x0103091B, 0x01010101 +}; +#endif diff --git a/drivers/opus/celt/entcode.h b/drivers/opus/celt/entcode.h index c129f9b7d9..4d736d4dca 100644 --- a/drivers/opus/celt/entcode.h +++ b/drivers/opus/celt/entcode.h @@ -34,6 +34,12 @@ # include <stddef.h> # include "opus/celt/ecintrin.h" +extern const opus_uint32 SMALL_DIV_TABLE[129]; + +#ifdef OPUS_ARM_ASM +#define USE_SMALL_DIV_TABLE +#endif + /*OPT: ec_window must be at least 32 bits, but if you have fast arithmetic on a larger type, you can speed up the decoder by using it here.*/ typedef opus_uint32 ec_window; @@ -114,4 +120,33 @@ static OPUS_INLINE int ec_tell(ec_ctx *_this){ rounding error is in the positive direction).*/ opus_uint32 ec_tell_frac(ec_ctx *_this); +/* Tested exhaustively for all n and for 1<=d<=256 */ +static OPUS_INLINE opus_uint32 celt_udiv(opus_uint32 n, opus_uint32 d) { + celt_assert(d>0); +#ifdef USE_SMALL_DIV_TABLE + if (d>256) + return n/d; + else { + opus_uint32 t, q; + t = EC_ILOG(d&-d); + q = (opus_uint64)SMALL_DIV_TABLE[d>>t]*(n>>(t-1))>>32; + return q+(n-q*d >= d); + } +#else + return n/d; +#endif +} + +static OPUS_INLINE opus_int32 celt_sudiv(opus_int32 n, opus_int32 d) { + celt_assert(d>0); +#ifdef USE_SMALL_DIV_TABLE + if (n<0) + return -(opus_int32)celt_udiv(-n, d); + else + return celt_udiv(n, d); +#else + return n/d; +#endif +} + #endif diff --git a/drivers/opus/celt/entdec.c b/drivers/opus/celt/entdec.c index 0ec4d460d2..fdc49c92c1 100644 --- a/drivers/opus/celt/entdec.c +++ b/drivers/opus/celt/entdec.c @@ -24,10 +24,7 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include <stddef.h> #include "opus/celt/os_support.h" @@ -138,7 +135,7 @@ void ec_dec_init(ec_dec *_this,unsigned char *_buf,opus_uint32 _storage){ unsigned ec_decode(ec_dec *_this,unsigned _ft){ unsigned s; - _this->ext=_this->rng/_ft; + _this->ext=celt_udiv(_this->rng,_ft); s=(unsigned)(_this->val/_this->ext); return _ft-EC_MINI(s+1,_ft); } diff --git a/drivers/opus/celt/entenc.c b/drivers/opus/celt/entenc.c index 085b2b2816..da7f2c8e62 100644 --- a/drivers/opus/celt/entenc.c +++ b/drivers/opus/celt/entenc.c @@ -24,10 +24,7 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#if defined(OPUS_ENABLED) -# include "opus/opus_config.h" -#endif +#include "opus/opus_config.h" #include "opus/celt/os_support.h" #include "opus/celt/arch.h" #include "opus/celt/entenc.h" @@ -98,7 +95,7 @@ static void ec_enc_carry_out(ec_enc *_this,int _c){ else _this->ext++; } -static void ec_enc_normalize(ec_enc *_this){ +static OPUS_INLINE void ec_enc_normalize(ec_enc *_this){ /*If the range is too small, output some bits and rescale it.*/ while(_this->rng<=EC_CODE_BOT){ ec_enc_carry_out(_this,(int)(_this->val>>EC_CODE_SHIFT)); @@ -127,7 +124,7 @@ void ec_enc_init(ec_enc *_this,unsigned char *_buf,opus_uint32 _size){ void ec_encode(ec_enc *_this,unsigned _fl,unsigned _fh,unsigned _ft){ opus_uint32 r; - r=_this->rng/_ft; + r=celt_udiv(_this->rng,_ft); if(_fl>0){ _this->val+=_this->rng-IMUL32(r,(_ft-_fl)); _this->rng=IMUL32(r,(_fh-_fl)); diff --git a/drivers/opus/celt/fixed_debug.h b/drivers/opus/celt/fixed_debug.h index 0ed16baa17..3b8d5ef7a9 100644 --- a/drivers/opus/celt/fixed_debug.h +++ b/drivers/opus/celt/fixed_debug.h @@ -496,6 +496,7 @@ static OPUS_INLINE int MULT16_32_PX_(int a, opus_int64 b, int Q, char *file, int #define MULT16_32_Q15(a,b) MULT16_32_QX(a,b,15) #define MAC16_32_Q15(c,a,b) (celt_mips-=2,ADD32((c),MULT16_32_Q15((a),(b)))) +#define MAC16_32_Q16(c,a,b) (celt_mips-=2,ADD32((c),MULT16_32_Q16((a),(b)))) static OPUS_INLINE int SATURATE(int a, int b) { @@ -767,6 +768,16 @@ static OPUS_INLINE int DIV32_(opus_int64 a, opus_int64 b, char *file, int line) return res; } +static OPUS_INLINE opus_val16 SIG2WORD16_generic(celt_sig x) +{ + x = PSHR32(x, SIG_SHIFT); + x = MAX32(x, -32768); + x = MIN32(x, 32767); + return EXTRACT16(x); +} +#define SIG2WORD16(x) (SIG2WORD16_generic(x)) + + #undef PRINT_MIPS #define PRINT_MIPS(file) do {fprintf (file, "total complexity = %llu MIPS\n", celt_mips);} while (0); diff --git a/drivers/opus/celt/fixed_generic.h b/drivers/opus/celt/fixed_generic.h index ecf018a244..71ab048e4a 100644 --- a/drivers/opus/celt/fixed_generic.h +++ b/drivers/opus/celt/fixed_generic.h @@ -113,7 +113,11 @@ /** 16x32 multiply, followed by a 15-bit shift right and 32-bit add. b must fit in 31 bits. Result fits in 32 bits. */ -#define MAC16_32_Q15(c,a,b) ADD32(c,ADD32(MULT16_16((a),SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15))) +#define MAC16_32_Q15(c,a,b) ADD32((c),ADD32(MULT16_16((a),SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15))) + +/** 16x32 multiplication, followed by a 16-bit shift right and 32-bit add. + Results fits in 32 bits */ +#define MAC16_32_Q16(c,a,b) ADD32((c),ADD32(MULT16_16((a),SHR((b),16)), SHR(MULT16_16SU((a),((b)&0x0000ffff)),16))) #define MULT16_16_Q11_32(a,b) (SHR(MULT16_16((a),(b)),11)) #define MULT16_16_Q11(a,b) (SHR(MULT16_16((a),(b)),11)) @@ -131,4 +135,17 @@ /** Divide a 32-bit value by a 32-bit value. Result fits in 32 bits */ #define DIV32(a,b) (((opus_val32)(a))/((opus_val32)(b))) +#if defined(MIPSr1_ASM) +#include "opus/celt/mips/fixed_generic_mipsr1.h" +#endif + +static OPUS_INLINE opus_val16 SIG2WORD16_generic(celt_sig x) +{ + x = PSHR32(x, SIG_SHIFT); + x = MAX32(x, -32768); + x = MIN32(x, 32767); + return EXTRACT16(x); +} +#define SIG2WORD16(x) (SIG2WORD16_generic(x)) + #endif diff --git a/drivers/opus/celt/float_cast.h b/drivers/opus/celt/float_cast.h index 86e80a93ff..36a1bfe671 100644 --- a/drivers/opus/celt/float_cast.h +++ b/drivers/opus/celt/float_cast.h @@ -90,14 +90,14 @@ #include <math.h> #define float2int(x) lrint(x) -#elif (defined(_MSC_VER) && _MSC_VER >= 1400) && (defined (WIN64) || defined (_WIN64)) +#elif (defined(_MSC_VER) && _MSC_VER >= 1400) && defined (_M_X64) #include <xmmintrin.h> __inline long int float2int(float value) { return _mm_cvtss_si32(_mm_load_ss(&value)); } -#elif (defined(_MSC_VER) && _MSC_VER >= 1400) && (defined (WIN32) || defined (_WIN32)) +#elif (defined(_MSC_VER) && _MSC_VER >= 1400) && defined (_M_IX86) #include <math.h> /* Win32 doesn't seem to have these functions. diff --git a/drivers/opus/celt/kiss_fft.c b/drivers/opus/celt/kiss_fft.c index 89a1790b24..cf8d049fa1 100644 --- a/drivers/opus/celt/kiss_fft.c +++ b/drivers/opus/celt/kiss_fft.c @@ -30,9 +30,7 @@ heavily modified to better suit Opus */ #ifndef SKIP_CONFIG_H -# ifdef OPUS_ENABLED #include "opus/opus_config.h" -# endif #endif #include "opus/celt/_kiss_fft_guts.h" @@ -47,64 +45,56 @@ static void kf_bfly2( kiss_fft_cpx * Fout, - const size_t fstride, - const kiss_fft_state *st, int m, - int N, - int mm + int N ) { kiss_fft_cpx * Fout2; - const kiss_twiddle_cpx * tw1; - int i,j; - kiss_fft_cpx * Fout_beg = Fout; - for (i=0;i<N;i++) + int i; + (void)m; +#ifdef CUSTOM_MODES + if (m==1) { - Fout = Fout_beg + i*mm; - Fout2 = Fout + m; - tw1 = st->twiddles; - for(j=0;j<m;j++) + celt_assert(m==1); + for (i=0;i<N;i++) { kiss_fft_cpx t; - Fout->r = SHR32(Fout->r, 1);Fout->i = SHR32(Fout->i, 1); - Fout2->r = SHR32(Fout2->r, 1);Fout2->i = SHR32(Fout2->i, 1); - C_MUL (t, *Fout2 , *tw1); - tw1 += fstride; + Fout2 = Fout + 1; + t = *Fout2; C_SUB( *Fout2 , *Fout , t ); C_ADDTO( *Fout , t ); - ++Fout2; - ++Fout; + Fout += 2; } - } -} - -static void ki_bfly2( - kiss_fft_cpx * Fout, - const size_t fstride, - const kiss_fft_state *st, - int m, - int N, - int mm - ) -{ - kiss_fft_cpx * Fout2; - const kiss_twiddle_cpx * tw1; - kiss_fft_cpx t; - int i,j; - kiss_fft_cpx * Fout_beg = Fout; - for (i=0;i<N;i++) + } else +#endif { - Fout = Fout_beg + i*mm; - Fout2 = Fout + m; - tw1 = st->twiddles; - for(j=0;j<m;j++) + opus_val16 tw; + tw = QCONST16(0.7071067812f, 15); + /* We know that m==4 here because the radix-2 is just after a radix-4 */ + celt_assert(m==4); + for (i=0;i<N;i++) { - C_MULC (t, *Fout2 , *tw1); - tw1 += fstride; - C_SUB( *Fout2 , *Fout , t ); - C_ADDTO( *Fout , t ); - ++Fout2; - ++Fout; + kiss_fft_cpx t; + Fout2 = Fout + 4; + t = Fout2[0]; + C_SUB( Fout2[0] , Fout[0] , t ); + C_ADDTO( Fout[0] , t ); + + t.r = S_MUL(Fout2[1].r+Fout2[1].i, tw); + t.i = S_MUL(Fout2[1].i-Fout2[1].r, tw); + C_SUB( Fout2[1] , Fout[1] , t ); + C_ADDTO( Fout[1] , t ); + + t.r = Fout2[2].i; + t.i = -Fout2[2].r; + C_SUB( Fout2[2] , Fout[2] , t ); + C_ADDTO( Fout[2] , t ); + + t.r = S_MUL(Fout2[3].i-Fout2[3].r, tw); + t.i = S_MUL(-Fout2[3].i-Fout2[3].r, tw); + C_SUB( Fout2[3] , Fout[3] , t ); + C_ADDTO( Fout[3] , t ); + Fout += 8; } } } @@ -118,89 +108,67 @@ static void kf_bfly4( int mm ) { - const kiss_twiddle_cpx *tw1,*tw2,*tw3; - kiss_fft_cpx scratch[6]; - const size_t m2=2*m; - const size_t m3=3*m; - int i, j; + int i; - kiss_fft_cpx * Fout_beg = Fout; - for (i=0;i<N;i++) + if (m==1) { - Fout = Fout_beg + i*mm; - tw3 = tw2 = tw1 = st->twiddles; - for (j=0;j<m;j++) + /* Degenerate case where all the twiddles are 1. */ + for (i=0;i<N;i++) { - C_MUL4(scratch[0],Fout[m] , *tw1 ); - C_MUL4(scratch[1],Fout[m2] , *tw2 ); - C_MUL4(scratch[2],Fout[m3] , *tw3 ); - - Fout->r = PSHR32(Fout->r, 2); - Fout->i = PSHR32(Fout->i, 2); - C_SUB( scratch[5] , *Fout, scratch[1] ); - C_ADDTO(*Fout, scratch[1]); - C_ADD( scratch[3] , scratch[0] , scratch[2] ); - C_SUB( scratch[4] , scratch[0] , scratch[2] ); - C_SUB( Fout[m2], *Fout, scratch[3] ); - tw1 += fstride; - tw2 += fstride*2; - tw3 += fstride*3; - C_ADDTO( *Fout , scratch[3] ); - - Fout[m].r = scratch[5].r + scratch[4].i; - Fout[m].i = scratch[5].i - scratch[4].r; - Fout[m3].r = scratch[5].r - scratch[4].i; - Fout[m3].i = scratch[5].i + scratch[4].r; - ++Fout; + kiss_fft_cpx scratch0, scratch1; + + C_SUB( scratch0 , *Fout, Fout[2] ); + C_ADDTO(*Fout, Fout[2]); + C_ADD( scratch1 , Fout[1] , Fout[3] ); + C_SUB( Fout[2], *Fout, scratch1 ); + C_ADDTO( *Fout , scratch1 ); + C_SUB( scratch1 , Fout[1] , Fout[3] ); + + Fout[1].r = scratch0.r + scratch1.i; + Fout[1].i = scratch0.i - scratch1.r; + Fout[3].r = scratch0.r - scratch1.i; + Fout[3].i = scratch0.i + scratch1.r; + Fout+=4; } - } -} - -static void ki_bfly4( - kiss_fft_cpx * Fout, - const size_t fstride, - const kiss_fft_state *st, - int m, - int N, - int mm - ) -{ - const kiss_twiddle_cpx *tw1,*tw2,*tw3; - kiss_fft_cpx scratch[6]; - const size_t m2=2*m; - const size_t m3=3*m; - int i, j; - - kiss_fft_cpx * Fout_beg = Fout; - for (i=0;i<N;i++) - { - Fout = Fout_beg + i*mm; - tw3 = tw2 = tw1 = st->twiddles; - for (j=0;j<m;j++) + } else { + int j; + kiss_fft_cpx scratch[6]; + const kiss_twiddle_cpx *tw1,*tw2,*tw3; + const int m2=2*m; + const int m3=3*m; + kiss_fft_cpx * Fout_beg = Fout; + for (i=0;i<N;i++) { - C_MULC(scratch[0],Fout[m] , *tw1 ); - C_MULC(scratch[1],Fout[m2] , *tw2 ); - C_MULC(scratch[2],Fout[m3] , *tw3 ); - - C_SUB( scratch[5] , *Fout, scratch[1] ); - C_ADDTO(*Fout, scratch[1]); - C_ADD( scratch[3] , scratch[0] , scratch[2] ); - C_SUB( scratch[4] , scratch[0] , scratch[2] ); - C_SUB( Fout[m2], *Fout, scratch[3] ); - tw1 += fstride; - tw2 += fstride*2; - tw3 += fstride*3; - C_ADDTO( *Fout , scratch[3] ); - - Fout[m].r = scratch[5].r - scratch[4].i; - Fout[m].i = scratch[5].i + scratch[4].r; - Fout[m3].r = scratch[5].r + scratch[4].i; - Fout[m3].i = scratch[5].i - scratch[4].r; - ++Fout; + Fout = Fout_beg + i*mm; + tw3 = tw2 = tw1 = st->twiddles; + /* m is guaranteed to be a multiple of 4. */ + for (j=0;j<m;j++) + { + C_MUL(scratch[0],Fout[m] , *tw1 ); + C_MUL(scratch[1],Fout[m2] , *tw2 ); + C_MUL(scratch[2],Fout[m3] , *tw3 ); + + C_SUB( scratch[5] , *Fout, scratch[1] ); + C_ADDTO(*Fout, scratch[1]); + C_ADD( scratch[3] , scratch[0] , scratch[2] ); + C_SUB( scratch[4] , scratch[0] , scratch[2] ); + C_SUB( Fout[m2], *Fout, scratch[3] ); + tw1 += fstride; + tw2 += fstride*2; + tw3 += fstride*3; + C_ADDTO( *Fout , scratch[3] ); + + Fout[m].r = scratch[5].r + scratch[4].i; + Fout[m].i = scratch[5].i - scratch[4].r; + Fout[m3].r = scratch[5].r - scratch[4].i; + Fout[m3].i = scratch[5].i + scratch[4].r; + ++Fout; + } } } } + #ifndef RADIX_TWO_ONLY static void kf_bfly3( @@ -220,14 +188,19 @@ static void kf_bfly3( kiss_twiddle_cpx epi3; kiss_fft_cpx * Fout_beg = Fout; +#ifdef OPUS_FIXED_POINT + epi3.r = -16384; + epi3.i = -28378; +#else epi3 = st->twiddles[fstride*m]; +#endif for (i=0;i<N;i++) { Fout = Fout_beg + i*mm; tw1=tw2=st->twiddles; + /* For non-custom modes, m is guaranteed to be a multiple of 4. */ k=m; do { - C_FIXDIV(*Fout,3); C_FIXDIV(Fout[m],3); C_FIXDIV(Fout[m2],3); C_MUL(scratch[1],Fout[m] , *tw1); C_MUL(scratch[2],Fout[m2] , *tw2); @@ -255,56 +228,8 @@ static void kf_bfly3( } } -static void ki_bfly3( - kiss_fft_cpx * Fout, - const size_t fstride, - const kiss_fft_state *st, - int m, - int N, - int mm - ) -{ - int i, k; - const size_t m2 = 2*m; - const kiss_twiddle_cpx *tw1,*tw2; - kiss_fft_cpx scratch[5]; - kiss_twiddle_cpx epi3; - - kiss_fft_cpx * Fout_beg = Fout; - epi3 = st->twiddles[fstride*m]; - for (i=0;i<N;i++) - { - Fout = Fout_beg + i*mm; - tw1=tw2=st->twiddles; - k=m; - do{ - - C_MULC(scratch[1],Fout[m] , *tw1); - C_MULC(scratch[2],Fout[m2] , *tw2); - - C_ADD(scratch[3],scratch[1],scratch[2]); - C_SUB(scratch[0],scratch[1],scratch[2]); - tw1 += fstride; - tw2 += fstride*2; - - Fout[m].r = Fout->r - HALF_OF(scratch[3].r); - Fout[m].i = Fout->i - HALF_OF(scratch[3].i); - - C_MULBYSCALAR( scratch[0] , -epi3.i ); - - C_ADDTO(*Fout,scratch[3]); - - Fout[m2].r = Fout[m].r + scratch[0].i; - Fout[m2].i = Fout[m].i - scratch[0].r; - - Fout[m].r -= scratch[0].i; - Fout[m].i += scratch[0].r; - - ++Fout; - }while(--k); - } -} +#ifndef OVERRIDE_kf_bfly5 static void kf_bfly5( kiss_fft_cpx * Fout, const size_t fstride, @@ -317,13 +242,19 @@ static void kf_bfly5( kiss_fft_cpx *Fout0,*Fout1,*Fout2,*Fout3,*Fout4; int i, u; kiss_fft_cpx scratch[13]; - const kiss_twiddle_cpx * twiddles = st->twiddles; const kiss_twiddle_cpx *tw; kiss_twiddle_cpx ya,yb; kiss_fft_cpx * Fout_beg = Fout; - ya = twiddles[fstride*m]; - yb = twiddles[fstride*2*m]; +#ifdef OPUS_FIXED_POINT + ya.r = 10126; + ya.i = -31164; + yb.r = -26510; + yb.i = -19261; +#else + ya = st->twiddles[fstride*m]; + yb = st->twiddles[fstride*2*m]; +#endif tw=st->twiddles; for (i=0;i<N;i++) @@ -335,8 +266,8 @@ static void kf_bfly5( Fout3=Fout0+3*m; Fout4=Fout0+4*m; + /* For non-custom modes, m is guaranteed to be a multiple of 4. */ for ( u=0; u<m; ++u ) { - C_FIXDIV( *Fout0,5); C_FIXDIV( *Fout1,5); C_FIXDIV( *Fout2,5); C_FIXDIV( *Fout3,5); C_FIXDIV( *Fout4,5); scratch[0] = *Fout0; C_MUL(scratch[1] ,*Fout1, tw[u*fstride]); @@ -373,74 +304,8 @@ static void kf_bfly5( } } } +#endif /* OVERRIDE_kf_bfly5 */ -static void ki_bfly5( - kiss_fft_cpx * Fout, - const size_t fstride, - const kiss_fft_state *st, - int m, - int N, - int mm - ) -{ - kiss_fft_cpx *Fout0,*Fout1,*Fout2,*Fout3,*Fout4; - int i, u; - kiss_fft_cpx scratch[13]; - const kiss_twiddle_cpx * twiddles = st->twiddles; - const kiss_twiddle_cpx *tw; - kiss_twiddle_cpx ya,yb; - kiss_fft_cpx * Fout_beg = Fout; - - ya = twiddles[fstride*m]; - yb = twiddles[fstride*2*m]; - tw=st->twiddles; - - for (i=0;i<N;i++) - { - Fout = Fout_beg + i*mm; - Fout0=Fout; - Fout1=Fout0+m; - Fout2=Fout0+2*m; - Fout3=Fout0+3*m; - Fout4=Fout0+4*m; - - for ( u=0; u<m; ++u ) { - scratch[0] = *Fout0; - - C_MULC(scratch[1] ,*Fout1, tw[u*fstride]); - C_MULC(scratch[2] ,*Fout2, tw[2*u*fstride]); - C_MULC(scratch[3] ,*Fout3, tw[3*u*fstride]); - C_MULC(scratch[4] ,*Fout4, tw[4*u*fstride]); - - C_ADD( scratch[7],scratch[1],scratch[4]); - C_SUB( scratch[10],scratch[1],scratch[4]); - C_ADD( scratch[8],scratch[2],scratch[3]); - C_SUB( scratch[9],scratch[2],scratch[3]); - - Fout0->r += scratch[7].r + scratch[8].r; - Fout0->i += scratch[7].i + scratch[8].i; - - scratch[5].r = scratch[0].r + S_MUL(scratch[7].r,ya.r) + S_MUL(scratch[8].r,yb.r); - scratch[5].i = scratch[0].i + S_MUL(scratch[7].i,ya.r) + S_MUL(scratch[8].i,yb.r); - - scratch[6].r = -S_MUL(scratch[10].i,ya.i) - S_MUL(scratch[9].i,yb.i); - scratch[6].i = S_MUL(scratch[10].r,ya.i) + S_MUL(scratch[9].r,yb.i); - - C_SUB(*Fout1,scratch[5],scratch[6]); - C_ADD(*Fout4,scratch[5],scratch[6]); - - scratch[11].r = scratch[0].r + S_MUL(scratch[7].r,yb.r) + S_MUL(scratch[8].r,ya.r); - scratch[11].i = scratch[0].i + S_MUL(scratch[7].i,yb.r) + S_MUL(scratch[8].i,ya.r); - scratch[12].r = S_MUL(scratch[10].i,yb.i) - S_MUL(scratch[9].i,ya.i); - scratch[12].i = -S_MUL(scratch[10].r,yb.i) + S_MUL(scratch[9].r,ya.i); - - C_ADD(*Fout2,scratch[11],scratch[12]); - C_SUB(*Fout3,scratch[11],scratch[12]); - - ++Fout0;++Fout1;++Fout2;++Fout3;++Fout4; - } - } -} #endif @@ -488,6 +353,9 @@ static int kf_factor(int n,opus_int16 * facbuf) { int p=4; + int i; + int stages=0; + int nbak = n; /*factor out powers of 4, powers of 2, then any remaining primes */ do { @@ -509,9 +377,30 @@ int kf_factor(int n,opus_int16 * facbuf) { return 0; } - *facbuf++ = p; - *facbuf++ = n; + facbuf[2*stages] = p; + if (p==2 && stages > 1) + { + facbuf[2*stages] = 4; + facbuf[2] = 2; + } + stages++; } while (n > 1); + n = nbak; + /* Reverse the order to get the radix 4 at the end, so we can use the + fast degenerate case. It turns out that reversing the order also + improves the noise behaviour. */ + for (i=0;i<stages/2;i++) + { + int tmp; + tmp = facbuf[2*i]; + facbuf[2*i] = facbuf[2*(stages-i-1)]; + facbuf[2*(stages-i-1)] = tmp; + } + for (i=0;i<stages;i++) + { + n /= facbuf[2*i]; + facbuf[2*i+1] = n; + } return 1; } @@ -532,13 +421,19 @@ static void compute_twiddles(kiss_twiddle_cpx *twiddles, int nfft) #endif } +int opus_fft_alloc_arch_c(kiss_fft_state *st) { + (void)st; + return 0; +} + /* * * Allocates all necessary storage space for the fft and ifft. * The return value is a contiguous block of memory. As such, * It can be freed with free(). * */ -kiss_fft_state *opus_fft_alloc_twiddles(int nfft,void * mem,size_t * lenmem, const kiss_fft_state *base) +kiss_fft_state *opus_fft_alloc_twiddles(int nfft,void * mem,size_t * lenmem, + const kiss_fft_state *base, int arch) { kiss_fft_state *st=NULL; size_t memneeded = sizeof(struct kiss_fft_state); /* twiddle factors*/ @@ -555,14 +450,20 @@ kiss_fft_state *opus_fft_alloc_twiddles(int nfft,void * mem,size_t * lenmem, co kiss_twiddle_cpx *twiddles; st->nfft=nfft; -#ifndef OPUS_FIXED_POINT +#ifdef OPUS_FIXED_POINT + st->scale_shift = celt_ilog2(st->nfft); + if (st->nfft == 1<<st->scale_shift) + st->scale = Q15ONE; + else + st->scale = (1073741824+st->nfft/2)/st->nfft>>(15-st->scale_shift); +#else st->scale = 1.f/nfft; #endif if (base != NULL) { st->twiddles = base->twiddles; st->shift = 0; - while (nfft<<st->shift != base->nfft && st->shift < 32) + while (st->shift < 32 && nfft<<st->shift != base->nfft) st->shift++; if (st->shift>=32) goto fail; @@ -581,22 +482,31 @@ kiss_fft_state *opus_fft_alloc_twiddles(int nfft,void * mem,size_t * lenmem, co if (st->bitrev==NULL) goto fail; compute_bitrev_table(0, bitrev, 1,1, st->factors,st); + + /* Initialize architecture specific fft parameters */ + if (opus_fft_alloc_arch(st, arch)) + goto fail; } return st; fail: - opus_fft_free(st); + opus_fft_free(st, arch); return NULL; } -kiss_fft_state *opus_fft_alloc(int nfft,void * mem,size_t * lenmem ) +kiss_fft_state *opus_fft_alloc(int nfft,void * mem,size_t * lenmem, int arch) { - return opus_fft_alloc_twiddles(nfft, mem, lenmem, NULL); + return opus_fft_alloc_twiddles(nfft, mem, lenmem, NULL, arch); +} + +void opus_fft_free_arch_c(kiss_fft_state *st) { + (void)st; } -void opus_fft_free(const kiss_fft_state *cfg) +void opus_fft_free(const kiss_fft_state *cfg, int arch) { if (cfg) { + opus_fft_free_arch((kiss_fft_state *)cfg, arch); opus_free((opus_int16*)cfg->bitrev); if (cfg->shift < 0) opus_free((kiss_twiddle_cpx*)cfg->twiddles); @@ -606,7 +516,7 @@ void opus_fft_free(const kiss_fft_state *cfg) #endif /* CUSTOM_MODES */ -void opus_fft(const kiss_fft_state *st,const kiss_fft_cpx *fin,kiss_fft_cpx *fout) +void opus_fft_impl(const kiss_fft_state *st,kiss_fft_cpx *fout) { int m2, m; int p; @@ -618,17 +528,6 @@ void opus_fft(const kiss_fft_state *st,const kiss_fft_cpx *fin,kiss_fft_cpx *fou /* st->shift can be -1 */ shift = st->shift>0 ? st->shift : 0; - celt_assert2 (fin != fout, "In-place FFT not supported"); - /* Bit-reverse the input */ - for (i=0;i<st->nfft;i++) - { - fout[st->bitrev[i]] = fin[i]; -#ifndef OPUS_FIXED_POINT - fout[st->bitrev[i]].r *= st->scale; - fout[st->bitrev[i]].i *= st->scale; -#endif - } - fstride[0] = 1; L=0; do { @@ -647,7 +546,7 @@ void opus_fft(const kiss_fft_state *st,const kiss_fft_cpx *fin,kiss_fft_cpx *fou switch (st->factors[2*i]) { case 2: - kf_bfly2(fout,fstride[i]<<shift,st,m, fstride[i], m2); + kf_bfly2(fout, m, fstride[i]); break; case 4: kf_bfly4(fout,fstride[i]<<shift,st,m, fstride[i], m2); @@ -665,55 +564,39 @@ void opus_fft(const kiss_fft_state *st,const kiss_fft_cpx *fin,kiss_fft_cpx *fou } } -void opus_ifft(const kiss_fft_state *st,const kiss_fft_cpx *fin,kiss_fft_cpx *fout) +void opus_fft_c(const kiss_fft_state *st,const kiss_fft_cpx *fin,kiss_fft_cpx *fout) { - int m2, m; - int p; - int L; - int fstride[MAXFACTORS]; int i; - int shift; + opus_val16 scale; +#ifdef OPUS_FIXED_POINT + /* Allows us to scale with MULT16_32_Q16(), which is faster than + MULT16_32_Q15() on ARM. */ + int scale_shift = st->scale_shift-1; +#endif + scale = st->scale; - /* st->shift can be -1 */ - shift = st->shift>0 ? st->shift : 0; celt_assert2 (fin != fout, "In-place FFT not supported"); /* Bit-reverse the input */ for (i=0;i<st->nfft;i++) - fout[st->bitrev[i]] = fin[i]; - - fstride[0] = 1; - L=0; - do { - p = st->factors[2*L]; - m = st->factors[2*L+1]; - fstride[L+1] = fstride[L]*p; - L++; - } while(m!=1); - m = st->factors[2*L-1]; - for (i=L-1;i>=0;i--) { - if (i!=0) - m2 = st->factors[2*i-1]; - else - m2 = 1; - switch (st->factors[2*i]) - { - case 2: - ki_bfly2(fout,fstride[i]<<shift,st,m, fstride[i], m2); - break; - case 4: - ki_bfly4(fout,fstride[i]<<shift,st,m, fstride[i], m2); - break; -#ifndef RADIX_TWO_ONLY - case 3: - ki_bfly3(fout,fstride[i]<<shift,st,m, fstride[i], m2); - break; - case 5: - ki_bfly5(fout,fstride[i]<<shift,st,m, fstride[i], m2); - break; -#endif - } - m = m2; + kiss_fft_cpx x = fin[i]; + fout[st->bitrev[i]].r = SHR32(MULT16_32_Q16(scale, x.r), scale_shift); + fout[st->bitrev[i]].i = SHR32(MULT16_32_Q16(scale, x.i), scale_shift); } + opus_fft_impl(st, fout); } + +void opus_ifft_c(const kiss_fft_state *st,const kiss_fft_cpx *fin,kiss_fft_cpx *fout) +{ + int i; + celt_assert2 (fin != fout, "In-place FFT not supported"); + /* Bit-reverse the input */ + for (i=0;i<st->nfft;i++) + fout[st->bitrev[i]] = fin[i]; + for (i=0;i<st->nfft;i++) + fout[i].i = -fout[i].i; + opus_fft_impl(st, fout); + for (i=0;i<st->nfft;i++) + fout[i].i = -fout[i].i; +} diff --git a/drivers/opus/celt/kiss_fft.h b/drivers/opus/celt/kiss_fft.h index db2532c692..6229044c43 100644 --- a/drivers/opus/celt/kiss_fft.h +++ b/drivers/opus/celt/kiss_fft.h @@ -32,6 +32,7 @@ #include <stdlib.h> #include <math.h> #include "opus/celt/arch.h" +#include "opus/celt/cpu_support.h" #ifdef __cplusplus extern "C" { @@ -77,17 +78,28 @@ typedef struct { 4*4*4*2 */ +typedef struct arch_fft_state{ + int is_supported; + void *priv; +} arch_fft_state; + typedef struct kiss_fft_state{ int nfft; -#ifndef OPUS_FIXED_POINT - kiss_fft_scalar scale; + opus_val16 scale; +#ifdef OPUS_FIXED_POINT + int scale_shift; #endif int shift; opus_int16 factors[2*MAXFACTORS]; const opus_int16 *bitrev; const kiss_twiddle_cpx *twiddles; + arch_fft_state *arch_fft; } kiss_fft_state; +#if defined(HAVE_ARM_NE10) +#include "opus/celt/arm/fft_arm.h" +#endif + /*typedef struct kiss_fft_state* kiss_fft_cfg;*/ /** @@ -113,9 +125,9 @@ typedef struct kiss_fft_state{ * buffer size in *lenmem. * */ -kiss_fft_state *opus_fft_alloc_twiddles(int nfft,void * mem,size_t * lenmem, const kiss_fft_state *base); +kiss_fft_state *opus_fft_alloc_twiddles(int nfft,void * mem,size_t * lenmem, const kiss_fft_state *base, int arch); -kiss_fft_state *opus_fft_alloc(int nfft,void * mem,size_t * lenmem); +kiss_fft_state *opus_fft_alloc(int nfft,void * mem,size_t * lenmem, int arch); /** * opus_fft(cfg,in_out_buf) @@ -127,10 +139,59 @@ kiss_fft_state *opus_fft_alloc(int nfft,void * mem,size_t * lenmem); * Note that each element is complex and can be accessed like f[k].r and f[k].i * */ -void opus_fft(const kiss_fft_state *cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout); -void opus_ifft(const kiss_fft_state *cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout); +void opus_fft_c(const kiss_fft_state *cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout); +void opus_ifft_c(const kiss_fft_state *cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout); + +void opus_fft_impl(const kiss_fft_state *st,kiss_fft_cpx *fout); +void opus_ifft_impl(const kiss_fft_state *st,kiss_fft_cpx *fout); + +void opus_fft_free(const kiss_fft_state *cfg, int arch); + + +void opus_fft_free_arch_c(kiss_fft_state *st); +int opus_fft_alloc_arch_c(kiss_fft_state *st); + +#if !defined(OVERRIDE_OPUS_FFT) +/* Is run-time CPU detection enabled on this platform? */ +#if defined(OPUS_HAVE_RTCD) && (defined(HAVE_ARM_NE10)) + +extern int (*const OPUS_FFT_ALLOC_ARCH_IMPL[OPUS_ARCHMASK+1])( + kiss_fft_state *st); + +#define opus_fft_alloc_arch(_st, arch) \ + ((*OPUS_FFT_ALLOC_ARCH_IMPL[(arch)&OPUS_ARCHMASK])(_st)) + +extern void (*const OPUS_FFT_FREE_ARCH_IMPL[OPUS_ARCHMASK+1])( + kiss_fft_state *st); +#define opus_fft_free_arch(_st, arch) \ + ((*OPUS_FFT_FREE_ARCH_IMPL[(arch)&OPUS_ARCHMASK])(_st)) + +extern void (*const OPUS_FFT[OPUS_ARCHMASK+1])(const kiss_fft_state *cfg, + const kiss_fft_cpx *fin, kiss_fft_cpx *fout); +#define opus_fft(_cfg, _fin, _fout, arch) \ + ((*OPUS_FFT[(arch)&OPUS_ARCHMASK])(_cfg, _fin, _fout)) + +extern void (*const OPUS_IFFT[OPUS_ARCHMASK+1])(const kiss_fft_state *cfg, + const kiss_fft_cpx *fin, kiss_fft_cpx *fout); +#define opus_ifft(_cfg, _fin, _fout, arch) \ + ((*OPUS_IFFT[(arch)&OPUS_ARCHMASK])(_cfg, _fin, _fout)) + +#else /* else for if defined(OPUS_HAVE_RTCD) && (defined(HAVE_ARM_NE10)) */ + +#define opus_fft_alloc_arch(_st, arch) \ + ((void)(arch), opus_fft_alloc_arch_c(_st)) + +#define opus_fft_free_arch(_st, arch) \ + ((void)(arch), opus_fft_free_arch_c(_st)) + +#define opus_fft(_cfg, _fin, _fout, arch) \ + ((void)(arch), opus_fft_c(_cfg, _fin, _fout)) + +#define opus_ifft(_cfg, _fin, _fout, arch) \ + ((void)(arch), opus_ifft_c(_cfg, _fin, _fout)) -void opus_fft_free(const kiss_fft_state *cfg); +#endif /* end if defined(OPUS_HAVE_RTCD) && (defined(HAVE_ARM_NE10)) */ +#endif /* end if !defined(OVERRIDE_OPUS_FFT) */ #ifdef __cplusplus } diff --git a/drivers/opus/celt/laplace.c b/drivers/opus/celt/laplace.c index 9dc4d94d24..5bc956af45 100644 --- a/drivers/opus/celt/laplace.c +++ b/drivers/opus/celt/laplace.c @@ -25,10 +25,7 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/celt/laplace.h" #include "opus/celt/mathops.h" diff --git a/drivers/opus/celt/mathops.c b/drivers/opus/celt/mathops.c index 88e5aea129..3f7c1a8bdd 100644 --- a/drivers/opus/celt/mathops.c +++ b/drivers/opus/celt/mathops.c @@ -30,10 +30,7 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/celt/mathops.h" diff --git a/drivers/opus/celt/mathops.h b/drivers/opus/celt/mathops.h index 759f58d1b7..a008d71e18 100644 --- a/drivers/opus/celt/mathops.h +++ b/drivers/opus/celt/mathops.h @@ -254,5 +254,5 @@ static OPUS_INLINE opus_val16 celt_atan2p(opus_val16 y, opus_val16 x) } } -#endif /* OPUS_FIXED_POINT */ +#endif /* FIXED_POINT */ #endif /* MATHOPS_H */ diff --git a/drivers/opus/celt/mdct.c b/drivers/opus/celt/mdct.c index ae34538d6c..641a20e49a 100644 --- a/drivers/opus/celt/mdct.c +++ b/drivers/opus/celt/mdct.c @@ -1,4 +1,4 @@ - /* Copyright (c) 2007-2008 CSIRO +/* Copyright (c) 2007-2008 CSIRO Copyright (c) 2007-2008 Xiph.Org Foundation Written by Jean-Marc Valin */ /* @@ -40,10 +40,8 @@ */ #ifndef SKIP_CONFIG_H -#ifdef OPUS_ENABLED #include "opus/opus_config.h" #endif -#endif #include "opus/celt/mdct.h" #include "opus/celt/kiss_fft.h" @@ -53,76 +51,100 @@ #include "opus/celt/mathops.h" #include "opus/celt/stack_alloc.h" +#if defined(MIPSr1_ASM) +#include "opus/celt/mips/mdct_mipsr1.h" +#endif + + #ifdef CUSTOM_MODES -int clt_mdct_init(celt_mdct_lookup *l,int N, int maxshift) +int clt_mdct_init(mdct_lookup *l,int N, int maxshift, int arch) { int i; - int N4; kiss_twiddle_scalar *trig; -#if defined(OPUS_FIXED_POINT) + int shift; int N2=N>>1; -#endif l->n = N; - N4 = N>>2; l->maxshift = maxshift; for (i=0;i<=maxshift;i++) { if (i==0) - l->kfft[i] = opus_fft_alloc(N>>2>>i, 0, 0); + l->kfft[i] = opus_fft_alloc(N>>2>>i, 0, 0, arch); else - l->kfft[i] = opus_fft_alloc_twiddles(N>>2>>i, 0, 0, l->kfft[0]); + l->kfft[i] = opus_fft_alloc_twiddles(N>>2>>i, 0, 0, l->kfft[0], arch); #ifndef ENABLE_TI_DSPLIB55 if (l->kfft[i]==NULL) return 0; #endif } - l->trig = trig = (kiss_twiddle_scalar*)opus_alloc((N4+1)*sizeof(kiss_twiddle_scalar)); + l->trig = trig = (kiss_twiddle_scalar*)opus_alloc((N-(N2>>maxshift))*sizeof(kiss_twiddle_scalar)); if (l->trig==NULL) return 0; - /* We have enough points that sine isn't necessary */ -#if defined(OPUS_FIXED_POINT) - for (i=0;i<=N4;i++) - trig[i] = TRIG_UPSCALE*celt_cos_norm(DIV32(ADD32(SHL32(EXTEND32(i),17),N2),N)); + for (shift=0;shift<=maxshift;shift++) + { + /* We have enough points that sine isn't necessary */ +#if defined(FIXED_POINT) +#if 1 + for (i=0;i<N2;i++) + trig[i] = TRIG_UPSCALE*celt_cos_norm(DIV32(ADD32(SHL32(EXTEND32(i),17),N2+16384),N)); #else - for (i=0;i<=N4;i++) - trig[i] = (kiss_twiddle_scalar)cos(2*PI*i/N); + for (i=0;i<N2;i++) + trig[i] = (kiss_twiddle_scalar)MAX32(-32767,MIN32(32767,floor(.5+32768*cos(2*M_PI*(i+.125)/N)))); #endif +#else + for (i=0;i<N2;i++) + trig[i] = (kiss_twiddle_scalar)cos(2*PI*(i+.125)/N); +#endif + trig += N2; + N2 >>= 1; + N >>= 1; + } return 1; } -void clt_mdct_clear(celt_mdct_lookup *l) +void clt_mdct_clear(mdct_lookup *l, int arch) { int i; for (i=0;i<=l->maxshift;i++) - opus_fft_free(l->kfft[i]); + opus_fft_free(l->kfft[i], arch); opus_free((kiss_twiddle_scalar*)l->trig); } #endif /* CUSTOM_MODES */ /* Forward MDCT trashes the input array */ -void clt_mdct_forward(const celt_mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * OPUS_RESTRICT out, - const opus_val16 *window, int overlap, int shift, int stride) +#ifndef OVERRIDE_clt_mdct_forward +void clt_mdct_forward_c(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * OPUS_RESTRICT out, + const opus_val16 *window, int overlap, int shift, int stride, int arch) { int i; int N, N2, N4; - kiss_twiddle_scalar sine; VARDECL(kiss_fft_scalar, f); - VARDECL(kiss_fft_scalar, f2); + VARDECL(kiss_fft_cpx, f2); + const kiss_fft_state *st = l->kfft[shift]; + const kiss_twiddle_scalar *trig; + opus_val16 scale; +#ifdef OPUS_FIXED_POINT + /* Allows us to scale with MULT16_32_Q16(), which is faster than + MULT16_32_Q15() on ARM. */ + int scale_shift = st->scale_shift-1; +#endif SAVE_STACK; + (void)arch; + scale = st->scale; + N = l->n; - N >>= shift; + trig = l->trig; + for (i=0;i<shift;i++) + { + N >>= 1; + trig += N; + } N2 = N>>1; N4 = N>>2; + ALLOC(f, N2, kiss_fft_scalar); - ALLOC(f2, N2, kiss_fft_scalar); - /* sin(x) ~= x here */ -#ifdef OPUS_FIXED_POINT - sine = TRIG_UPSCALE*(QCONST16(0.7853981f, 15)+N2)/N; -#else - sine = (kiss_twiddle_scalar)2*PI*(.125f)/N; -#endif + ALLOC(f2, N4, kiss_fft_cpx); /* Consider the input to be composed of four blocks: [a, b, c, d] */ /* Window, shuffle, fold */ @@ -167,123 +189,131 @@ void clt_mdct_forward(const celt_mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_s /* Pre-rotation */ { kiss_fft_scalar * OPUS_RESTRICT yp = f; - const kiss_twiddle_scalar *t = &l->trig[0]; + const kiss_twiddle_scalar *t = &trig[0]; for(i=0;i<N4;i++) { + kiss_fft_cpx yc; + kiss_twiddle_scalar t0, t1; kiss_fft_scalar re, im, yr, yi; - re = yp[0]; - im = yp[1]; - yr = -S_MUL(re,t[i<<shift]) - S_MUL(im,t[(N4-i)<<shift]); - yi = -S_MUL(im,t[i<<shift]) + S_MUL(re,t[(N4-i)<<shift]); - /* works because the cos is nearly one */ - *yp++ = yr + S_MUL(yi,sine); - *yp++ = yi - S_MUL(yr,sine); + t0 = t[i]; + t1 = t[N4+i]; + re = *yp++; + im = *yp++; + yr = S_MUL(re,t0) - S_MUL(im,t1); + yi = S_MUL(im,t0) + S_MUL(re,t1); + yc.r = yr; + yc.i = yi; + yc.r = PSHR32(MULT16_32_Q16(scale, yc.r), scale_shift); + yc.i = PSHR32(MULT16_32_Q16(scale, yc.i), scale_shift); + f2[st->bitrev[i]] = yc; } } - /* N/4 complex FFT, down-scales by 4/N */ - opus_fft(l->kfft[shift], (kiss_fft_cpx *)f, (kiss_fft_cpx *)f2); + /* N/4 complex FFT, does not downscale anymore */ + opus_fft_impl(st, f2); /* Post-rotate */ { /* Temp pointers to make it really clear to the compiler what we're doing */ - const kiss_fft_scalar * OPUS_RESTRICT fp = f2; + const kiss_fft_cpx * OPUS_RESTRICT fp = f2; kiss_fft_scalar * OPUS_RESTRICT yp1 = out; kiss_fft_scalar * OPUS_RESTRICT yp2 = out+stride*(N2-1); - const kiss_twiddle_scalar *t = &l->trig[0]; + const kiss_twiddle_scalar *t = &trig[0]; /* Temp pointers to make it really clear to the compiler what we're doing */ for(i=0;i<N4;i++) { kiss_fft_scalar yr, yi; - yr = S_MUL(fp[1],t[(N4-i)<<shift]) + S_MUL(fp[0],t[i<<shift]); - yi = S_MUL(fp[0],t[(N4-i)<<shift]) - S_MUL(fp[1],t[i<<shift]); - /* works because the cos is nearly one */ - *yp1 = yr - S_MUL(yi,sine); - *yp2 = yi + S_MUL(yr,sine);; - fp += 2; + yr = S_MUL(fp->i,t[N4+i]) - S_MUL(fp->r,t[i]); + yi = S_MUL(fp->r,t[N4+i]) + S_MUL(fp->i,t[i]); + *yp1 = yr; + *yp2 = yi; + fp++; yp1 += 2*stride; yp2 -= 2*stride; } } RESTORE_STACK; } +#endif /* OVERRIDE_clt_mdct_forward */ -void clt_mdct_backward(const celt_mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * OPUS_RESTRICT out, - const opus_val16 * OPUS_RESTRICT window, int overlap, int shift, int stride) +#ifndef OVERRIDE_clt_mdct_backward +void clt_mdct_backward_c(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * OPUS_RESTRICT out, + const opus_val16 * OPUS_RESTRICT window, int overlap, int shift, int stride, int arch) { int i; int N, N2, N4; - kiss_twiddle_scalar sine; - VARDECL(kiss_fft_scalar, f2); - SAVE_STACK; + const kiss_twiddle_scalar *trig; + (void) arch; + N = l->n; - N >>= shift; + trig = l->trig; + for (i=0;i<shift;i++) + { + N >>= 1; + trig += N; + } N2 = N>>1; N4 = N>>2; - ALLOC(f2, N2, kiss_fft_scalar); - /* sin(x) ~= x here */ -#ifdef OPUS_FIXED_POINT - sine = TRIG_UPSCALE*(QCONST16(0.7853981f, 15)+N2)/N; -#else - sine = (kiss_twiddle_scalar)2*PI*(.125f)/N; -#endif /* Pre-rotate */ { /* Temp pointers to make it really clear to the compiler what we're doing */ const kiss_fft_scalar * OPUS_RESTRICT xp1 = in; const kiss_fft_scalar * OPUS_RESTRICT xp2 = in+stride*(N2-1); - kiss_fft_scalar * OPUS_RESTRICT yp = f2; - const kiss_twiddle_scalar *t = &l->trig[0]; + kiss_fft_scalar * OPUS_RESTRICT yp = out+(overlap>>1); + const kiss_twiddle_scalar * OPUS_RESTRICT t = &trig[0]; + const opus_int16 * OPUS_RESTRICT bitrev = l->kfft[shift]->bitrev; for(i=0;i<N4;i++) { + int rev; kiss_fft_scalar yr, yi; - yr = -S_MUL(*xp2, t[i<<shift]) + S_MUL(*xp1,t[(N4-i)<<shift]); - yi = -S_MUL(*xp2, t[(N4-i)<<shift]) - S_MUL(*xp1,t[i<<shift]); - /* works because the cos is nearly one */ - *yp++ = yr - S_MUL(yi,sine); - *yp++ = yi + S_MUL(yr,sine); + rev = *bitrev++; + yr = S_MUL(*xp2, t[i]) + S_MUL(*xp1, t[N4+i]); + yi = S_MUL(*xp1, t[i]) - S_MUL(*xp2, t[N4+i]); + /* We swap real and imag because we use an FFT instead of an IFFT. */ + yp[2*rev+1] = yr; + yp[2*rev] = yi; + /* Storing the pre-rotation directly in the bitrev order. */ xp1+=2*stride; xp2-=2*stride; } } - /* Inverse N/4 complex FFT. This one should *not* downscale even in fixed-point */ - opus_ifft(l->kfft[shift], (kiss_fft_cpx *)f2, (kiss_fft_cpx *)(out+(overlap>>1))); + opus_fft_impl(l->kfft[shift], (kiss_fft_cpx*)(out+(overlap>>1))); /* Post-rotate and de-shuffle from both ends of the buffer at once to make it in-place. */ { - kiss_fft_scalar * OPUS_RESTRICT yp0 = out+(overlap>>1); - kiss_fft_scalar * OPUS_RESTRICT yp1 = out+(overlap>>1)+N2-2; - const kiss_twiddle_scalar *t = &l->trig[0]; + kiss_fft_scalar * yp0 = out+(overlap>>1); + kiss_fft_scalar * yp1 = out+(overlap>>1)+N2-2; + const kiss_twiddle_scalar *t = &trig[0]; /* Loop to (N4+1)>>1 to handle odd N4. When N4 is odd, the middle pair will be computed twice. */ for(i=0;i<(N4+1)>>1;i++) { kiss_fft_scalar re, im, yr, yi; kiss_twiddle_scalar t0, t1; - re = yp0[0]; - im = yp0[1]; - t0 = t[i<<shift]; - t1 = t[(N4-i)<<shift]; + /* We swap real and imag because we're using an FFT instead of an IFFT. */ + re = yp0[1]; + im = yp0[0]; + t0 = t[i]; + t1 = t[N4+i]; /* We'd scale up by 2 here, but instead it's done when mixing the windows */ - yr = S_MUL(re,t0) - S_MUL(im,t1); - yi = S_MUL(im,t0) + S_MUL(re,t1); - re = yp1[0]; - im = yp1[1]; - /* works because the cos is nearly one */ - yp0[0] = -(yr - S_MUL(yi,sine)); - yp1[1] = yi + S_MUL(yr,sine); + yr = S_MUL(re,t0) + S_MUL(im,t1); + yi = S_MUL(re,t1) - S_MUL(im,t0); + /* We swap real and imag because we're using an FFT instead of an IFFT. */ + re = yp1[1]; + im = yp1[0]; + yp0[0] = yr; + yp1[1] = yi; - t0 = t[(N4-i-1)<<shift]; - t1 = t[(i+1)<<shift]; + t0 = t[(N4-i-1)]; + t1 = t[(N2-i-1)]; /* We'd scale up by 2 here, but instead it's done when mixing the windows */ - yr = S_MUL(re,t0) - S_MUL(im,t1); - yi = S_MUL(im,t0) + S_MUL(re,t1); - /* works because the cos is nearly one */ - yp1[0] = -(yr - S_MUL(yi,sine)); - yp0[1] = yi + S_MUL(yr,sine); + yr = S_MUL(re,t0) + S_MUL(im,t1); + yi = S_MUL(re,t1) - S_MUL(im,t0); + yp1[0] = yr; + yp0[1] = yi; yp0 += 2; yp1 -= 2; } @@ -307,5 +337,5 @@ void clt_mdct_backward(const celt_mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_ wp2--; } } - RESTORE_STACK; } +#endif /* OVERRIDE_clt_mdct_backward */ diff --git a/drivers/opus/celt/mdct.h b/drivers/opus/celt/mdct.h index 492afeae1e..2ec98a92e5 100644 --- a/drivers/opus/celt/mdct.h +++ b/drivers/opus/celt/mdct.h @@ -51,20 +51,62 @@ typedef struct { int maxshift; const kiss_fft_state *kfft[4]; const kiss_twiddle_scalar * OPUS_RESTRICT trig; -} celt_mdct_lookup; +} mdct_lookup; + +#if defined(HAVE_ARM_NE10) +#include "opus/celt/arm/mdct_arm.h" +#endif -int clt_mdct_init(celt_mdct_lookup *l,int N, int maxshift); -void clt_mdct_clear(celt_mdct_lookup *l); + +int clt_mdct_init(mdct_lookup *l,int N, int maxshift, int arch); +void clt_mdct_clear(mdct_lookup *l, int arch); /** Compute a forward MDCT and scale by 4/N, trashes the input array */ -void clt_mdct_forward(const celt_mdct_lookup *l, kiss_fft_scalar *in, - kiss_fft_scalar * OPUS_RESTRICT out, - const opus_val16 *window, int overlap, int shift, int stride); +void clt_mdct_forward_c(const mdct_lookup *l, kiss_fft_scalar *in, + kiss_fft_scalar * OPUS_RESTRICT out, + const opus_val16 *window, int overlap, + int shift, int stride, int arch); /** Compute a backward MDCT (no scaling) and performs weighted overlap-add (scales implicitly by 1/2) */ -void clt_mdct_backward(const celt_mdct_lookup *l, kiss_fft_scalar *in, +void clt_mdct_backward_c(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * OPUS_RESTRICT out, - const opus_val16 * OPUS_RESTRICT window, int overlap, int shift, int stride); + const opus_val16 * OPUS_RESTRICT window, + int overlap, int shift, int stride, int arch); + +#if !defined(OVERRIDE_OPUS_MDCT) +/* Is run-time CPU detection enabled on this platform? */ +#if defined(OPUS_HAVE_RTCD) && defined(HAVE_ARM_NE10) + +extern void (*const CLT_MDCT_FORWARD_IMPL[OPUS_ARCHMASK+1])( + const mdct_lookup *l, kiss_fft_scalar *in, + kiss_fft_scalar * OPUS_RESTRICT out, const opus_val16 *window, + int overlap, int shift, int stride, int arch); + +#define clt_mdct_forward(_l, _in, _out, _window, _overlap, _shift, _stride, _arch) \ + ((*CLT_MDCT_FORWARD_IMPL[(arch)&OPUS_ARCHMASK])(_l, _in, _out, \ + _window, _overlap, _shift, \ + _stride, _arch)) + +extern void (*const CLT_MDCT_BACKWARD_IMPL[OPUS_ARCHMASK+1])( + const mdct_lookup *l, kiss_fft_scalar *in, + kiss_fft_scalar * OPUS_RESTRICT out, const opus_val16 *window, + int overlap, int shift, int stride, int arch); + +#define clt_mdct_backward(_l, _in, _out, _window, _overlap, _shift, _stride, _arch) \ + (*CLT_MDCT_BACKWARD_IMPL[(arch)&OPUS_ARCHMASK])(_l, _in, _out, \ + _window, _overlap, _shift, \ + _stride, _arch) + +#else /* if defined(OPUS_HAVE_RTCD) && defined(HAVE_ARM_NE10) */ + +#define clt_mdct_forward(_l, _in, _out, _window, _overlap, _shift, _stride, _arch) \ + clt_mdct_forward_c(_l, _in, _out, _window, _overlap, _shift, _stride, _arch) + +#define clt_mdct_backward(_l, _in, _out, _window, _overlap, _shift, _stride, _arch) \ + clt_mdct_backward_c(_l, _in, _out, _window, _overlap, _shift, _stride, _arch) + +#endif /* end if defined(OPUS_HAVE_RTCD) && defined(HAVE_ARM_NE10) && !defined(FIXED_POINT) */ +#endif /* end if !defined(OVERRIDE_OPUS_MDCT) */ #endif diff --git a/drivers/opus/celt/mips/celt_mipsr1.h b/drivers/opus/celt/mips/celt_mipsr1.h new file mode 100644 index 0000000000..906848f1ec --- /dev/null +++ b/drivers/opus/celt/mips/celt_mipsr1.h @@ -0,0 +1,148 @@ +/* Copyright (c) 2007-2008 CSIRO + Copyright (c) 2007-2010 Xiph.Org Foundation + Copyright (c) 2008 Gregory Maxwell + Written by Jean-Marc Valin and Gregory Maxwell */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef __CELT_MIPSR1_H__ +#define __CELT_MIPSR1_H__ +#include "opus/opus_config.h" + +#define CELT_C + +#include "opus/celt/os_support.h" +#include "opus/celt/mdct.h" +#include <math.h> +#include "opus/celt/celt.h" +#include "opus/celt/pitch.h" +#include "opus/celt/bands.h" +#include "opus/celt/modes.h" +#include "opus/celt/entcode.h" +#include "opus/celt/quant_bands.h" +#include "opus/celt/rate.h" +#include "opus/celt/stack_alloc.h" +#include "opus/celt/mathops.h" +#include "opus/celt/float_cast.h" +#include <stdarg.h> +#include "opus/celt/celt_lpc.h" +#include "opus/celt/vq.h" + +#define OVERRIDE_comb_filter +void comb_filter(opus_val32 *y, opus_val32 *x, int T0, int T1, int N, + opus_val16 g0, opus_val16 g1, int tapset0, int tapset1, + const opus_val16 *window, int overlap, int arch) +{ + int i; + opus_val32 x0, x1, x2, x3, x4; + + (void)arch; + + /* printf ("%d %d %f %f\n", T0, T1, g0, g1); */ + opus_val16 g00, g01, g02, g10, g11, g12; + static const opus_val16 gains[3][3] = { + {QCONST16(0.3066406250f, 15), QCONST16(0.2170410156f, 15), QCONST16(0.1296386719f, 15)}, + {QCONST16(0.4638671875f, 15), QCONST16(0.2680664062f, 15), QCONST16(0.f, 15)}, + {QCONST16(0.7998046875f, 15), QCONST16(0.1000976562f, 15), QCONST16(0.f, 15)}}; + + if (g0==0 && g1==0) + { + /* OPT: Happens to work without the OPUS_MOVE(), but only because the current encoder already copies x to y */ + if (x!=y) + OPUS_MOVE(y, x, N); + return; + } + + g00 = MULT16_16_P15(g0, gains[tapset0][0]); + g01 = MULT16_16_P15(g0, gains[tapset0][1]); + g02 = MULT16_16_P15(g0, gains[tapset0][2]); + g10 = MULT16_16_P15(g1, gains[tapset1][0]); + g11 = MULT16_16_P15(g1, gains[tapset1][1]); + g12 = MULT16_16_P15(g1, gains[tapset1][2]); + x1 = x[-T1+1]; + x2 = x[-T1 ]; + x3 = x[-T1-1]; + x4 = x[-T1-2]; + /* If the filter didn't change, we don't need the overlap */ + if (g0==g1 && T0==T1 && tapset0==tapset1) + overlap=0; + + for (i=0;i<overlap;i++) + { + opus_val16 f; + opus_val32 res; + f = MULT16_16_Q15(window[i],window[i]); + x0= x[i-T1+2]; + + asm volatile("MULT $ac1, %0, %1" : : "r" ((int)MULT16_16_Q15((Q15ONE-f),g00)), "r" ((int)x[i-T0])); + + asm volatile("MADD $ac1, %0, %1" : : "r" ((int)MULT16_16_Q15((Q15ONE-f),g01)), "r" ((int)ADD32(x[i-T0-1],x[i-T0+1]))); + asm volatile("MADD $ac1, %0, %1" : : "r" ((int)MULT16_16_Q15((Q15ONE-f),g02)), "r" ((int)ADD32(x[i-T0-2],x[i-T0+2]))); + asm volatile("MADD $ac1, %0, %1" : : "r" ((int)MULT16_16_Q15(f,g10)), "r" ((int)x2)); + asm volatile("MADD $ac1, %0, %1" : : "r" ((int)MULT16_16_Q15(f,g11)), "r" ((int)ADD32(x3,x1))); + asm volatile("MADD $ac1, %0, %1" : : "r" ((int)MULT16_16_Q15(f,g12)), "r" ((int)ADD32(x4,x0))); + + asm volatile("EXTR.W %0,$ac1, %1" : "=r" (res): "i" (15)); + + y[i] = x[i] + res; + + x4=x3; + x3=x2; + x2=x1; + x1=x0; + } + + x4 = x[i-T1-2]; + x3 = x[i-T1-1]; + x2 = x[i-T1]; + x1 = x[i-T1+1]; + + if (g1==0) + { + /* OPT: Happens to work without the OPUS_MOVE(), but only because the current encoder already copies x to y */ + if (x!=y) + OPUS_MOVE(y+overlap, x+overlap, N-overlap); + return; + } + + for (i=overlap;i<N;i++) + { + opus_val32 res; + x0=x[i-T1+2]; + + asm volatile("MULT $ac1, %0, %1" : : "r" ((int)g10), "r" ((int)x2)); + + asm volatile("MADD $ac1, %0, %1" : : "r" ((int)g11), "r" ((int)ADD32(x3,x1))); + asm volatile("MADD $ac1, %0, %1" : : "r" ((int)g12), "r" ((int)ADD32(x4,x0))); + asm volatile("EXTR.W %0,$ac1, %1" : "=r" (res): "i" (15)); + y[i] = x[i] + res; + x4=x3; + x3=x2; + x2=x1; + x1=x0; + } +} + +#endif /* __CELT_MIPSR1_H__ */ diff --git a/drivers/opus/celt/mips/fixed_generic_mipsr1.h b/drivers/opus/celt/mips/fixed_generic_mipsr1.h new file mode 100644 index 0000000000..4a05efbf85 --- /dev/null +++ b/drivers/opus/celt/mips/fixed_generic_mipsr1.h @@ -0,0 +1,126 @@ +/* Copyright (C) 2007-2009 Xiph.Org Foundation + Copyright (C) 2003-2008 Jean-Marc Valin + Copyright (C) 2007-2008 CSIRO */ +/** + @file fixed_generic.h + @brief Generic fixed-point operations +*/ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef CELT_FIXED_GENERIC_MIPSR1_H +#define CELT_FIXED_GENERIC_MIPSR1_H + +#undef MULT16_32_Q15_ADD +static inline int MULT16_32_Q15_ADD(int a, int b, int c, int d) { + int m; + asm volatile("MULT $ac1, %0, %1" : : "r" ((int)a), "r" ((int)b)); + asm volatile("madd $ac1, %0, %1" : : "r" ((int)c), "r" ((int)d)); + asm volatile("EXTR.W %0,$ac1, %1" : "=r" (m): "i" (15)); + return m; +} + +#undef MULT16_32_Q15_SUB +static inline int MULT16_32_Q15_SUB(int a, int b, int c, int d) { + int m; + asm volatile("MULT $ac1, %0, %1" : : "r" ((int)a), "r" ((int)b)); + asm volatile("msub $ac1, %0, %1" : : "r" ((int)c), "r" ((int)d)); + asm volatile("EXTR.W %0,$ac1, %1" : "=r" (m): "i" (15)); + return m; +} + +#undef MULT16_16_Q15_ADD +static inline int MULT16_16_Q15_ADD(int a, int b, int c, int d) { + int m; + asm volatile("MULT $ac1, %0, %1" : : "r" ((int)a), "r" ((int)b)); + asm volatile("madd $ac1, %0, %1" : : "r" ((int)c), "r" ((int)d)); + asm volatile("EXTR.W %0,$ac1, %1" : "=r" (m): "i" (15)); + return m; +} + +#undef MULT16_16_Q15_SUB +static inline int MULT16_16_Q15_SUB(int a, int b, int c, int d) { + int m; + asm volatile("MULT $ac1, %0, %1" : : "r" ((int)a), "r" ((int)b)); + asm volatile("msub $ac1, %0, %1" : : "r" ((int)c), "r" ((int)d)); + asm volatile("EXTR.W %0,$ac1, %1" : "=r" (m): "i" (15)); + return m; +} + + +#undef MULT16_32_Q16 +static inline int MULT16_32_Q16(int a, int b) +{ + int c; + asm volatile("MULT $ac1,%0, %1" : : "r" (a), "r" (b)); + asm volatile("EXTR.W %0,$ac1, %1" : "=r" (c): "i" (16)); + return c; +} + +#undef MULT16_32_P16 +static inline int MULT16_32_P16(int a, int b) +{ + int c; + asm volatile("MULT $ac1, %0, %1" : : "r" (a), "r" (b)); + asm volatile("EXTR_R.W %0,$ac1, %1" : "=r" (c): "i" (16)); + return c; +} + +#undef MULT16_32_Q15 +static inline int MULT16_32_Q15(int a, int b) +{ + int c; + asm volatile("MULT $ac1, %0, %1" : : "r" (a), "r" (b)); + asm volatile("EXTR.W %0,$ac1, %1" : "=r" (c): "i" (15)); + return c; +} + +#undef MULT32_32_Q31 +static inline int MULT32_32_Q31(int a, int b) +{ + int r; + asm volatile("MULT $ac1, %0, %1" : : "r" (a), "r" (b)); + asm volatile("EXTR.W %0,$ac1, %1" : "=r" (r): "i" (31)); + return r; +} + +#undef PSHR32 +static inline int PSHR32(int a, int shift) +{ + int r; + asm volatile ("SHRAV_R.W %0, %1, %2" :"=r" (r): "r" (a), "r" (shift)); + return r; +} + +#undef MULT16_16_P15 +static inline int MULT16_16_P15(int a, int b) +{ + int r; + asm volatile ("mul %0, %1, %2" :"=r" (r): "r" (a), "r" (b)); + asm volatile ("SHRA_R.W %0, %1, %2" : "+r" (r): "0" (r), "i"(15)); + return r; +} + +#endif /* CELT_FIXED_GENERIC_MIPSR1_H */ diff --git a/drivers/opus/celt/mips/kiss_fft_mipsr1.h b/drivers/opus/celt/mips/kiss_fft_mipsr1.h new file mode 100644 index 0000000000..09dc9af464 --- /dev/null +++ b/drivers/opus/celt/mips/kiss_fft_mipsr1.h @@ -0,0 +1,167 @@ +/*Copyright (c) 2013, Xiph.Org Foundation and contributors. + + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE.*/ + +#ifndef KISS_FFT_MIPSR1_H +#define KISS_FFT_MIPSR1_H + +#if !defined(KISS_FFT_GUTS_H) +#error "This file should only be included from _kiss_fft_guts.h" +#endif + +#ifdef OPUS_FIXED_POINT + +#define S_MUL_ADD(a, b, c, d) (S_MUL(a,b)+S_MUL(c,d)) +#define S_MUL_SUB(a, b, c, d) (S_MUL(a,b)-S_MUL(c,d)) + +#undef S_MUL_ADD +static inline int S_MUL_ADD(int a, int b, int c, int d) { + int m; + asm volatile("MULT $ac1, %0, %1" : : "r" ((int)a), "r" ((int)b)); + asm volatile("madd $ac1, %0, %1" : : "r" ((int)c), "r" ((int)d)); + asm volatile("EXTR.W %0,$ac1, %1" : "=r" (m): "i" (15)); + return m; +} + +#undef S_MUL_SUB +static inline int S_MUL_SUB(int a, int b, int c, int d) { + int m; + asm volatile("MULT $ac1, %0, %1" : : "r" ((int)a), "r" ((int)b)); + asm volatile("msub $ac1, %0, %1" : : "r" ((int)c), "r" ((int)d)); + asm volatile("EXTR.W %0,$ac1, %1" : "=r" (m): "i" (15)); + return m; +} + +#undef C_MUL +# define C_MUL(m,a,b) (m=C_MUL_fun(a,b)) +static inline kiss_fft_cpx C_MUL_fun(kiss_fft_cpx a, kiss_twiddle_cpx b) { + kiss_fft_cpx m; + + asm volatile("MULT $ac1, %0, %1" : : "r" ((int)a.r), "r" ((int)b.r)); + asm volatile("msub $ac1, %0, %1" : : "r" ((int)a.i), "r" ((int)b.i)); + asm volatile("EXTR.W %0,$ac1, %1" : "=r" (m.r): "i" (15)); + asm volatile("MULT $ac1, %0, %1" : : "r" ((int)a.r), "r" ((int)b.i)); + asm volatile("madd $ac1, %0, %1" : : "r" ((int)a.i), "r" ((int)b.r)); + asm volatile("EXTR.W %0,$ac1, %1" : "=r" (m.i): "i" (15)); + + return m; +} +#undef C_MULC +# define C_MULC(m,a,b) (m=C_MULC_fun(a,b)) +static inline kiss_fft_cpx C_MULC_fun(kiss_fft_cpx a, kiss_twiddle_cpx b) { + kiss_fft_cpx m; + + asm volatile("MULT $ac1, %0, %1" : : "r" ((int)a.r), "r" ((int)b.r)); + asm volatile("madd $ac1, %0, %1" : : "r" ((int)a.i), "r" ((int)b.i)); + asm volatile("EXTR.W %0,$ac1, %1" : "=r" (m.r): "i" (15)); + asm volatile("MULT $ac1, %0, %1" : : "r" ((int)a.i), "r" ((int)b.r)); + asm volatile("msub $ac1, %0, %1" : : "r" ((int)a.r), "r" ((int)b.i)); + asm volatile("EXTR.W %0,$ac1, %1" : "=r" (m.i): "i" (15)); + + return m; +} + +#endif /* FIXED_POINT */ + +#define OVERRIDE_kf_bfly5 +static void kf_bfly5( + kiss_fft_cpx * Fout, + const size_t fstride, + const kiss_fft_state *st, + int m, + int N, + int mm + ) +{ + kiss_fft_cpx *Fout0,*Fout1,*Fout2,*Fout3,*Fout4; + int i, u; + kiss_fft_cpx scratch[13]; + + const kiss_twiddle_cpx *tw; + kiss_twiddle_cpx ya,yb; + kiss_fft_cpx * Fout_beg = Fout; + +#ifdef OPUS_FIXED_POINT + ya.r = 10126; + ya.i = -31164; + yb.r = -26510; + yb.i = -19261; +#else + ya = st->twiddles[fstride*m]; + yb = st->twiddles[fstride*2*m]; +#endif + + tw=st->twiddles; + + for (i=0;i<N;i++) + { + Fout = Fout_beg + i*mm; + Fout0=Fout; + Fout1=Fout0+m; + Fout2=Fout0+2*m; + Fout3=Fout0+3*m; + Fout4=Fout0+4*m; + + /* For non-custom modes, m is guaranteed to be a multiple of 4. */ + for ( u=0; u<m; ++u ) { + scratch[0] = *Fout0; + + + C_MUL(scratch[1] ,*Fout1, tw[u*fstride]); + C_MUL(scratch[2] ,*Fout2, tw[2*u*fstride]); + C_MUL(scratch[3] ,*Fout3, tw[3*u*fstride]); + C_MUL(scratch[4] ,*Fout4, tw[4*u*fstride]); + + C_ADD( scratch[7],scratch[1],scratch[4]); + C_SUB( scratch[10],scratch[1],scratch[4]); + C_ADD( scratch[8],scratch[2],scratch[3]); + C_SUB( scratch[9],scratch[2],scratch[3]); + + Fout0->r += scratch[7].r + scratch[8].r; + Fout0->i += scratch[7].i + scratch[8].i; + scratch[5].r = scratch[0].r + S_MUL_ADD(scratch[7].r,ya.r,scratch[8].r,yb.r); + scratch[5].i = scratch[0].i + S_MUL_ADD(scratch[7].i,ya.r,scratch[8].i,yb.r); + + scratch[6].r = S_MUL_ADD(scratch[10].i,ya.i,scratch[9].i,yb.i); + scratch[6].i = -S_MUL_ADD(scratch[10].r,ya.i,scratch[9].r,yb.i); + + C_SUB(*Fout1,scratch[5],scratch[6]); + C_ADD(*Fout4,scratch[5],scratch[6]); + + scratch[11].r = scratch[0].r + S_MUL_ADD(scratch[7].r,yb.r,scratch[8].r,ya.r); + scratch[11].i = scratch[0].i + S_MUL_ADD(scratch[7].i,yb.r,scratch[8].i,ya.r); + + scratch[12].r = S_MUL_SUB(scratch[9].i,ya.i,scratch[10].i,yb.i); + scratch[12].i = S_MUL_SUB(scratch[10].r,yb.i,scratch[9].r,ya.i); + + C_ADD(*Fout2,scratch[11],scratch[12]); + C_SUB(*Fout3,scratch[11],scratch[12]); + + ++Fout0;++Fout1;++Fout2;++Fout3;++Fout4; + } + } +} + + +#endif /* KISS_FFT_MIPSR1_H */ diff --git a/drivers/opus/celt/mips/mdct_mipsr1.h b/drivers/opus/celt/mips/mdct_mipsr1.h new file mode 100644 index 0000000000..0bb8b5a056 --- /dev/null +++ b/drivers/opus/celt/mips/mdct_mipsr1.h @@ -0,0 +1,286 @@ +/* Copyright (c) 2007-2008 CSIRO + Copyright (c) 2007-2008 Xiph.Org Foundation + Written by Jean-Marc Valin */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* This is a simple MDCT implementation that uses a N/4 complex FFT + to do most of the work. It should be relatively straightforward to + plug in pretty much and FFT here. + + This replaces the Vorbis FFT (and uses the exact same API), which + was a bit too messy and that was ending up duplicating code + (might as well use the same FFT everywhere). + + The algorithm is similar to (and inspired from) Fabrice Bellard's + MDCT implementation in FFMPEG, but has differences in signs, ordering + and scaling in many places. +*/ +#ifndef __MDCT_MIPSR1_H__ +#define __MDCT_MIPSR1_H__ + +#ifndef SKIP_CONFIG_H +#include "opus/opus_config.h" +#endif + +#include "opus/celt/mdct.h" +#include "opus/celt/kiss_fft.h" +#include "opus/celt/_kiss_fft_guts.h" +#include <math.h> +#include "opus/celt/os_support.h" +#include "opus/celt/mathops.h" +#include "opus/celt/stack_alloc.h" + +/* Forward MDCT trashes the input array */ +#define OVERRIDE_clt_mdct_forward +void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * OPUS_RESTRICT out, + const opus_val16 *window, int overlap, int shift, int stride, int arch) +{ + int i; + int N, N2, N4; + VARDECL(kiss_fft_scalar, f); + VARDECL(kiss_fft_cpx, f2); + const kiss_fft_state *st = l->kfft[shift]; + const kiss_twiddle_scalar *trig; + opus_val16 scale; +#ifdef OPUS_FIXED_POINT + /* Allows us to scale with MULT16_32_Q16(), which is faster than + MULT16_32_Q15() on ARM. */ + int scale_shift = st->scale_shift-1; +#endif + + (void)arch; + + SAVE_STACK; + scale = st->scale; + + N = l->n; + trig = l->trig; + for (i=0;i<shift;i++) + { + N >>= 1; + trig += N; + } + N2 = N>>1; + N4 = N>>2; + + ALLOC(f, N2, kiss_fft_scalar); + ALLOC(f2, N4, kiss_fft_cpx); + + /* Consider the input to be composed of four blocks: [a, b, c, d] */ + /* Window, shuffle, fold */ + { + /* Temp pointers to make it really clear to the compiler what we're doing */ + const kiss_fft_scalar * OPUS_RESTRICT xp1 = in+(overlap>>1); + const kiss_fft_scalar * OPUS_RESTRICT xp2 = in+N2-1+(overlap>>1); + kiss_fft_scalar * OPUS_RESTRICT yp = f; + const opus_val16 * OPUS_RESTRICT wp1 = window+(overlap>>1); + const opus_val16 * OPUS_RESTRICT wp2 = window+(overlap>>1)-1; + for(i=0;i<((overlap+3)>>2);i++) + { + /* Real part arranged as -d-cR, Imag part arranged as -b+aR*/ + *yp++ = S_MUL_ADD(*wp2, xp1[N2],*wp1,*xp2); + *yp++ = S_MUL_SUB(*wp1, *xp1,*wp2, xp2[-N2]); + xp1+=2; + xp2-=2; + wp1+=2; + wp2-=2; + } + wp1 = window; + wp2 = window+overlap-1; + for(;i<N4-((overlap+3)>>2);i++) + { + /* Real part arranged as a-bR, Imag part arranged as -c-dR */ + *yp++ = *xp2; + *yp++ = *xp1; + xp1+=2; + xp2-=2; + } + for(;i<N4;i++) + { + /* Real part arranged as a-bR, Imag part arranged as -c-dR */ + *yp++ = S_MUL_SUB(*wp2, *xp2, *wp1, xp1[-N2]); + *yp++ = S_MUL_ADD(*wp2, *xp1, *wp1, xp2[N2]); + xp1+=2; + xp2-=2; + wp1+=2; + wp2-=2; + } + } + /* Pre-rotation */ + { + kiss_fft_scalar * OPUS_RESTRICT yp = f; + const kiss_twiddle_scalar *t = &trig[0]; + for(i=0;i<N4;i++) + { + kiss_fft_cpx yc; + kiss_twiddle_scalar t0, t1; + kiss_fft_scalar re, im, yr, yi; + t0 = t[i]; + t1 = t[N4+i]; + re = *yp++; + im = *yp++; + + yr = S_MUL_SUB(re,t0,im,t1); + yi = S_MUL_ADD(im,t0,re,t1); + + yc.r = yr; + yc.i = yi; + yc.r = PSHR32(MULT16_32_Q16(scale, yc.r), scale_shift); + yc.i = PSHR32(MULT16_32_Q16(scale, yc.i), scale_shift); + f2[st->bitrev[i]] = yc; + } + } + + /* N/4 complex FFT, does not downscale anymore */ + opus_fft_impl(st, f2); + + /* Post-rotate */ + { + /* Temp pointers to make it really clear to the compiler what we're doing */ + const kiss_fft_cpx * OPUS_RESTRICT fp = f2; + kiss_fft_scalar * OPUS_RESTRICT yp1 = out; + kiss_fft_scalar * OPUS_RESTRICT yp2 = out+stride*(N2-1); + const kiss_twiddle_scalar *t = &trig[0]; + /* Temp pointers to make it really clear to the compiler what we're doing */ + for(i=0;i<N4;i++) + { + kiss_fft_scalar yr, yi; + yr = S_MUL_SUB(fp->i,t[N4+i] , fp->r,t[i]); + yi = S_MUL_ADD(fp->r,t[N4+i] ,fp->i,t[i]); + *yp1 = yr; + *yp2 = yi; + fp++; + yp1 += 2*stride; + yp2 -= 2*stride; + } + } + RESTORE_STACK; +} + +#define OVERRIDE_clt_mdct_backward +void clt_mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * OPUS_RESTRICT out, + const opus_val16 * OPUS_RESTRICT window, int overlap, int shift, int stride, int arch) +{ + int i; + int N, N2, N4; + const kiss_twiddle_scalar *trig; + + (void)arch; + + N = l->n; + trig = l->trig; + for (i=0;i<shift;i++) + { + N >>= 1; + trig += N; + } + N2 = N>>1; + N4 = N>>2; + + /* Pre-rotate */ + { + /* Temp pointers to make it really clear to the compiler what we're doing */ + const kiss_fft_scalar * OPUS_RESTRICT xp1 = in; + const kiss_fft_scalar * OPUS_RESTRICT xp2 = in+stride*(N2-1); + kiss_fft_scalar * OPUS_RESTRICT yp = out+(overlap>>1); + const kiss_twiddle_scalar * OPUS_RESTRICT t = &trig[0]; + const opus_int16 * OPUS_RESTRICT bitrev = l->kfft[shift]->bitrev; + for(i=0;i<N4;i++) + { + int rev; + kiss_fft_scalar yr, yi; + rev = *bitrev++; + yr = S_MUL_ADD(*xp2, t[i] , *xp1, t[N4+i]); + yi = S_MUL_SUB(*xp1, t[i] , *xp2, t[N4+i]); + /* We swap real and imag because we use an FFT instead of an IFFT. */ + yp[2*rev+1] = yr; + yp[2*rev] = yi; + /* Storing the pre-rotation directly in the bitrev order. */ + xp1+=2*stride; + xp2-=2*stride; + } + } + + opus_fft_impl(l->kfft[shift], (kiss_fft_cpx*)(out+(overlap>>1))); + + /* Post-rotate and de-shuffle from both ends of the buffer at once to make + it in-place. */ + { + kiss_fft_scalar * OPUS_RESTRICT yp0 = out+(overlap>>1); + kiss_fft_scalar * OPUS_RESTRICT yp1 = out+(overlap>>1)+N2-2; + const kiss_twiddle_scalar *t = &trig[0]; + /* Loop to (N4+1)>>1 to handle odd N4. When N4 is odd, the + middle pair will be computed twice. */ + for(i=0;i<(N4+1)>>1;i++) + { + kiss_fft_scalar re, im, yr, yi; + kiss_twiddle_scalar t0, t1; + /* We swap real and imag because we're using an FFT instead of an IFFT. */ + re = yp0[1]; + im = yp0[0]; + t0 = t[i]; + t1 = t[N4+i]; + /* We'd scale up by 2 here, but instead it's done when mixing the windows */ + yr = S_MUL_ADD(re,t0 , im,t1); + yi = S_MUL_SUB(re,t1 , im,t0); + /* We swap real and imag because we're using an FFT instead of an IFFT. */ + re = yp1[1]; + im = yp1[0]; + yp0[0] = yr; + yp1[1] = yi; + + t0 = t[(N4-i-1)]; + t1 = t[(N2-i-1)]; + /* We'd scale up by 2 here, but instead it's done when mixing the windows */ + yr = S_MUL_ADD(re,t0,im,t1); + yi = S_MUL_SUB(re,t1,im,t0); + yp1[0] = yr; + yp0[1] = yi; + yp0 += 2; + yp1 -= 2; + } + } + + /* Mirror on both sides for TDAC */ + { + kiss_fft_scalar * OPUS_RESTRICT xp1 = out+overlap-1; + kiss_fft_scalar * OPUS_RESTRICT yp1 = out; + const opus_val16 * OPUS_RESTRICT wp1 = window; + const opus_val16 * OPUS_RESTRICT wp2 = window+overlap-1; + + for(i = 0; i < overlap/2; i++) + { + kiss_fft_scalar x1, x2; + x1 = *xp1; + x2 = *yp1; + *yp1++ = MULT16_32_Q15(*wp2, x2) - MULT16_32_Q15(*wp1, x1); + *xp1-- = MULT16_32_Q15(*wp1, x2) + MULT16_32_Q15(*wp2, x1); + wp1++; + wp2--; + } + } +} +#endif /* __MDCT_MIPSR1_H__ */ diff --git a/drivers/opus/celt/mips/pitch_mipsr1.h b/drivers/opus/celt/mips/pitch_mipsr1.h new file mode 100644 index 0000000000..a9500aff58 --- /dev/null +++ b/drivers/opus/celt/mips/pitch_mipsr1.h @@ -0,0 +1,161 @@ +/* Copyright (c) 2007-2008 CSIRO + Copyright (c) 2007-2009 Xiph.Org Foundation + Written by Jean-Marc Valin */ +/** + @file pitch.h + @brief Pitch analysis + */ + +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef PITCH_MIPSR1_H +#define PITCH_MIPSR1_H + +#define OVERRIDE_DUAL_INNER_PROD +static inline void dual_inner_prod(const opus_val16 *x, const opus_val16 *y01, const opus_val16 *y02, + int N, opus_val32 *xy1, opus_val32 *xy2, int arch) +{ + int j; + opus_val32 xy01=0; + opus_val32 xy02=0; + + (void)arch; + + asm volatile("MULT $ac1, $0, $0"); + asm volatile("MULT $ac2, $0, $0"); + /* Compute the norm of X+Y and X-Y as |X|^2 + |Y|^2 +/- sum(xy) */ + for (j=0;j<N;j++) + { + asm volatile("MADD $ac1, %0, %1" : : "r" ((int)x[j]), "r" ((int)y01[j])); + asm volatile("MADD $ac2, %0, %1" : : "r" ((int)x[j]), "r" ((int)y02[j])); + ++j; + asm volatile("MADD $ac1, %0, %1" : : "r" ((int)x[j]), "r" ((int)y01[j])); + asm volatile("MADD $ac2, %0, %1" : : "r" ((int)x[j]), "r" ((int)y02[j])); + } + asm volatile ("mflo %0, $ac1": "=r"(xy01)); + asm volatile ("mflo %0, $ac2": "=r"(xy02)); + *xy1 = xy01; + *xy2 = xy02; +} + +static inline void xcorr_kernel_mips(const opus_val16 * x, + const opus_val16 * y, opus_val32 sum[4], int len) +{ + int j; + opus_val16 y_0, y_1, y_2, y_3; + + opus_int64 sum_0, sum_1, sum_2, sum_3; + sum_0 = (opus_int64)sum[0]; + sum_1 = (opus_int64)sum[1]; + sum_2 = (opus_int64)sum[2]; + sum_3 = (opus_int64)sum[3]; + + y_3=0; /* gcc doesn't realize that y_3 can't be used uninitialized */ + y_0=*y++; + y_1=*y++; + y_2=*y++; + for (j=0;j<len-3;j+=4) + { + opus_val16 tmp; + tmp = *x++; + y_3=*y++; + + sum_0 = __builtin_mips_madd( sum_0, tmp, y_0); + sum_1 = __builtin_mips_madd( sum_1, tmp, y_1); + sum_2 = __builtin_mips_madd( sum_2, tmp, y_2); + sum_3 = __builtin_mips_madd( sum_3, tmp, y_3); + + tmp=*x++; + y_0=*y++; + + sum_0 = __builtin_mips_madd( sum_0, tmp, y_1 ); + sum_1 = __builtin_mips_madd( sum_1, tmp, y_2 ); + sum_2 = __builtin_mips_madd( sum_2, tmp, y_3); + sum_3 = __builtin_mips_madd( sum_3, tmp, y_0); + + tmp=*x++; + y_1=*y++; + + sum_0 = __builtin_mips_madd( sum_0, tmp, y_2 ); + sum_1 = __builtin_mips_madd( sum_1, tmp, y_3 ); + sum_2 = __builtin_mips_madd( sum_2, tmp, y_0); + sum_3 = __builtin_mips_madd( sum_3, tmp, y_1); + + + tmp=*x++; + y_2=*y++; + + sum_0 = __builtin_mips_madd( sum_0, tmp, y_3 ); + sum_1 = __builtin_mips_madd( sum_1, tmp, y_0 ); + sum_2 = __builtin_mips_madd( sum_2, tmp, y_1); + sum_3 = __builtin_mips_madd( sum_3, tmp, y_2); + + } + if (j++<len) + { + opus_val16 tmp = *x++; + y_3=*y++; + + sum_0 = __builtin_mips_madd( sum_0, tmp, y_0 ); + sum_1 = __builtin_mips_madd( sum_1, tmp, y_1 ); + sum_2 = __builtin_mips_madd( sum_2, tmp, y_2); + sum_3 = __builtin_mips_madd( sum_3, tmp, y_3); + } + + if (j++<len) + { + opus_val16 tmp=*x++; + y_0=*y++; + + sum_0 = __builtin_mips_madd( sum_0, tmp, y_1 ); + sum_1 = __builtin_mips_madd( sum_1, tmp, y_2 ); + sum_2 = __builtin_mips_madd( sum_2, tmp, y_3); + sum_3 = __builtin_mips_madd( sum_3, tmp, y_0); + } + + if (j<len) + { + opus_val16 tmp=*x++; + y_1=*y++; + + sum_0 = __builtin_mips_madd( sum_0, tmp, y_2 ); + sum_1 = __builtin_mips_madd( sum_1, tmp, y_3 ); + sum_2 = __builtin_mips_madd( sum_2, tmp, y_0); + sum_3 = __builtin_mips_madd( sum_3, tmp, y_1); + + } + + sum[0] = (opus_val32)sum_0; + sum[1] = (opus_val32)sum_1; + sum[2] = (opus_val32)sum_2; + sum[3] = (opus_val32)sum_3; +} + +#define OVERRIDE_XCORR_KERNEL +#define xcorr_kernel(x, y, sum, len, arch) \ + ((void)(arch), xcorr_kernel_mips(x, y, sum, len)) + +#endif /* PITCH_MIPSR1_H */ diff --git a/drivers/opus/celt/mips/vq_mipsr1.h b/drivers/opus/celt/mips/vq_mipsr1.h new file mode 100644 index 0000000000..c68159972f --- /dev/null +++ b/drivers/opus/celt/mips/vq_mipsr1.h @@ -0,0 +1,122 @@ +/* Copyright (c) 2007-2008 CSIRO + Copyright (c) 2007-2009 Xiph.Org Foundation + Written by Jean-Marc Valin */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef __VQ_MIPSR1_H__ +#define __VQ_MIPSR1_H__ +#include "opus/opus_config.h" + +#include "opus/celt/mathops.h" +#include "opus/celt/arch.h" + +static unsigned extract_collapse_mask(int *iy, int N, int B); +static void normalise_residual(int * OPUS_RESTRICT iy, celt_norm * OPUS_RESTRICT X, int N, opus_val32 Ryy, opus_val16 gain); +static void exp_rotation(celt_norm *X, int len, int dir, int stride, int K, int spread); +static void renormalise_vector_mips(celt_norm *X, int N, opus_val16 gain, int arch); + +#define OVERRIDE_vq_exp_rotation1 +static void exp_rotation1(celt_norm *X, int len, int stride, opus_val16 c, opus_val16 s) +{ + int i; + opus_val16 ms; + celt_norm *Xptr; + Xptr = X; + ms = NEG16(s); + for (i=0;i<len-stride;i++) + { + celt_norm x1, x2; + x1 = Xptr[0]; + x2 = Xptr[stride]; + Xptr[stride] = EXTRACT16(PSHR32(MAC16_16(MULT16_16(c, x2), s, x1), 15)); + *Xptr++ = EXTRACT16(PSHR32(MAC16_16(MULT16_16(c, x1), ms, x2), 15)); + } + Xptr = &X[len-2*stride-1]; + for (i=len-2*stride-1;i>=0;i--) + { + celt_norm x1, x2; + x1 = Xptr[0]; + x2 = Xptr[stride]; + Xptr[stride] = EXTRACT16(PSHR32(MAC16_16(MULT16_16(c, x2), s, x1), 15)); + *Xptr-- = EXTRACT16(PSHR32(MAC16_16(MULT16_16(c, x1), ms, x2), 15)); + } +} + +#define OVERRIDE_renormalise_vector + +#define renormalise_vector(X, N, gain, arch) \ + (renormalise_vector_mips(X, N, gain, arch)) + +void renormalise_vector_mips(celt_norm *X, int N, opus_val16 gain, int arch) +{ + int i; +#ifdef OPUS_FIXED_POINT + int k; +#endif + opus_val32 E = EPSILON; + opus_val16 g; + opus_val32 t; + celt_norm *xptr = X; + int X0, X1; + + (void)arch; + + asm volatile("mult $ac1, $0, $0"); + asm volatile("MTLO %0, $ac1" : :"r" (E)); + /*if(N %4) + printf("error");*/ + for (i=0;i<N-2;i+=2) + { + X0 = (int)*xptr++; + asm volatile("MADD $ac1, %0, %1" : : "r" (X0), "r" (X0)); + + X1 = (int)*xptr++; + asm volatile("MADD $ac1, %0, %1" : : "r" (X1), "r" (X1)); + } + + for (;i<N;i++) + { + X0 = (int)*xptr++; + asm volatile("MADD $ac1, %0, %1" : : "r" (X0), "r" (X0)); + } + + asm volatile("MFLO %0, $ac1" : "=r" (E)); +#ifdef OPUS_FIXED_POINT + k = celt_ilog2(E)>>1; +#endif + t = VSHR32(E, 2*(k-7)); + g = MULT16_16_P15(celt_rsqrt_norm(t),gain); + + xptr = X; + for (i=0;i<N;i++) + { + *xptr = EXTRACT16(PSHR32(MULT16_16(g, *xptr), k+1)); + xptr++; + } + /*return celt_sqrt(E);*/ +} + +#endif /* __VQ_MIPSR1_H__ */ diff --git a/drivers/opus/celt/modes.c b/drivers/opus/celt/modes.c index aef2681443..d628f1468b 100644 --- a/drivers/opus/celt/modes.c +++ b/drivers/opus/celt/modes.c @@ -26,17 +26,15 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/celt/celt.h" -#include "opus/celt/opus_modes.h" +#include "opus/celt/modes.h" #include "opus/celt/rate.h" #include "opus/celt/os_support.h" #include "opus/celt/stack_alloc.h" #include "opus/celt/quant_bands.h" +#include "opus/celt/cpu_support.h" static const opus_int16 eband5ms[] = { /*0 200 400 600 800 1k 1.2 1.4 1.6 2k 2.4 2.8 3.2 4k 4.8 5.6 6.8 8k 9.6 12k 15.6 */ @@ -229,6 +227,7 @@ CELTMode *opus_custom_mode_create(opus_int32 Fs, int frame_size, int *error) opus_val16 *window; opus_int16 *logN; int LM; + int arch = opus_select_arch(); ALLOC_STACK; #if !defined(VAR_ARRAYS) && !defined(USE_ALLOCA) if (global_stack==NULL) @@ -389,7 +388,7 @@ CELTMode *opus_custom_mode_create(opus_int32 Fs, int frame_size, int *error) compute_pulse_cache(mode, mode->maxLM); if (clt_mdct_init(&mode->mdct, 2*mode->shortMdctSize*mode->nbShortMdcts, - mode->maxLM) == 0) + mode->maxLM, arch) == 0) goto failure; if (error) @@ -408,6 +407,8 @@ failure: #ifdef CUSTOM_MODES void opus_custom_mode_destroy(CELTMode *mode) { + int arch = opus_select_arch(); + if (mode == NULL) return; #ifndef CUSTOM_MODES_ONLY @@ -431,7 +432,7 @@ void opus_custom_mode_destroy(CELTMode *mode) opus_free((opus_int16*)mode->cache.index); opus_free((unsigned char*)mode->cache.bits); opus_free((unsigned char*)mode->cache.caps); - clt_mdct_clear(&mode->mdct); + clt_mdct_clear(&mode->mdct, arch); opus_free((CELTMode *)mode); } diff --git a/drivers/opus/celt/opus_modes.h b/drivers/opus/celt/modes.h index 38e5844535..a5f1c30ac9 100644 --- a/drivers/opus/celt/opus_modes.h +++ b/drivers/opus/celt/modes.h @@ -27,8 +27,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef OPUS_MODES_H -#define OPUS_MODES_H +#ifndef MODES_H +#define MODES_H #include "opus/opus_types.h" #include "opus/celt/celt.h" @@ -39,14 +39,6 @@ #define MAX_PERIOD 1024 -#ifndef OVERLAP -#define OVERLAP(mode) ((mode)->overlap) -#endif - -#ifndef FRAMESIZE -#define FRAMESIZE(mode) ((mode)->mdctSize) -#endif - typedef struct { int size; const opus_int16 *index; @@ -75,7 +67,7 @@ struct OpusCustomMode { const opus_int16 *logN; const opus_val16 *window; - celt_mdct_lookup mdct; + mdct_lookup mdct; PulseCache cache; }; diff --git a/drivers/opus/celt/opus_custom_demo.c b/drivers/opus/celt/opus_custom_demo.c index b3129de779..956bec4e45 100644 --- a/drivers/opus/celt/opus_custom_demo.c +++ b/drivers/opus/celt/opus_custom_demo.c @@ -25,10 +25,7 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/opus_custom.h" #include "opus/celt/arch.h" @@ -52,7 +49,7 @@ int main(int argc, char *argv[]) int bytes_per_packet; unsigned char data[MAX_PACKET]; int complexity; -#if !(defined (OPUS_FIXED_POINT) && !defined(CUSTOM_MODES)) && defined(RESYNTH) +#if !(defined (FIXED_POINT) && !defined(CUSTOM_MODES)) && defined(RESYNTH) int i; double rmsd = 0; #endif @@ -174,7 +171,7 @@ int main(int argc, char *argv[]) for (i=0;i<ret*channels;i++) out[i] = in[i]; #endif -#if !(defined (OPUS_FIXED_POINT) && !defined(CUSTOM_MODES)) && defined(RESYNTH) +#if !(defined (FIXED_POINT) && !defined(CUSTOM_MODES)) && defined(RESYNTH) for (i=0;i<ret*channels;i++) { rmsd += (in[i]-out[i])*1.0*(in[i]-out[i]); @@ -194,7 +191,7 @@ int main(int argc, char *argv[]) opus_custom_mode_destroy(mode); free(in); free(out); -#if !(defined (OPUS_FIXED_POINT) && !defined(CUSTOM_MODES)) && defined(RESYNTH) +#if !(defined (FIXED_POINT) && !defined(CUSTOM_MODES)) && defined(RESYNTH) if (rmsd > 0) { rmsd = sqrt(rmsd/(1.0*frame_size*channels*count)); diff --git a/drivers/opus/celt/os_support.h b/drivers/opus/celt/os_support.h index e1cf884467..5e36b3ae56 100644 --- a/drivers/opus/celt/os_support.h +++ b/drivers/opus/celt/os_support.h @@ -67,18 +67,18 @@ static OPUS_INLINE void opus_free (void *ptr) } #endif -/** Copy n bytes of memory from src to dst. The 0* term provides compile-time type checking */ +/** Copy n elements from src to dst. The 0* term provides compile-time type checking */ #ifndef OVERRIDE_OPUS_COPY #define OPUS_COPY(dst, src, n) (memcpy((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) )) #endif -/** Copy n bytes of memory from src to dst, allowing overlapping regions. The 0* term +/** Copy n elements from src to dst, allowing overlapping regions. The 0* term provides compile-time type checking */ #ifndef OVERRIDE_OPUS_MOVE #define OPUS_MOVE(dst, src, n) (memmove((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) )) #endif -/** Set n elements of dst to zero, starting at address s */ +/** Set n elements of dst to zero */ #ifndef OVERRIDE_OPUS_CLEAR #define OPUS_CLEAR(dst, n) (memset((dst), 0, (n)*sizeof(*(dst)))) #endif diff --git a/drivers/opus/celt/pitch.c b/drivers/opus/celt/pitch.c index c7c2b98c00..1bcbabe943 100644 --- a/drivers/opus/celt/pitch.c +++ b/drivers/opus/celt/pitch.c @@ -30,14 +30,11 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/celt/pitch.h" #include "opus/celt/os_support.h" -#include "opus/celt/opus_modes.h" +#include "opus/celt/modes.h" #include "opus/celt/stack_alloc.h" #include "opus/celt/mathops.h" #include "opus/celt/celt_lpc.h" @@ -214,25 +211,35 @@ void pitch_downsample(celt_sig * OPUS_RESTRICT x[], opus_val16 * OPUS_RESTRICT x celt_fir5(x_lp, lpc2, x_lp, len>>1, mem); } -#if 0 /* This is a simple version of the pitch correlation that should work - well on DSPs like Blackfin and TI C5x/C6x */ - +/* Pure C implementation. */ #ifdef OPUS_FIXED_POINT opus_val32 #else void #endif -celt_pitch_xcorr(opus_val16 *x, opus_val16 *y, opus_val32 *xcorr, int len, int max_pitch) +#if defined(OVERRIDE_PITCH_XCORR) +celt_pitch_xcorr_c(const opus_val16 *_x, const opus_val16 *_y, + opus_val32 *xcorr, int len, int max_pitch) +#else +celt_pitch_xcorr(const opus_val16 *_x, const opus_val16 *_y, + opus_val32 *xcorr, int len, int max_pitch, int arch) +#endif { + +#if 0 /* This is a simple version of the pitch correlation that should work + well on DSPs like Blackfin and TI C5x/C6x */ int i, j; #ifdef OPUS_FIXED_POINT opus_val32 maxcorr=1; #endif +#if !defined(OVERRIDE_PITCH_XCORR) + (void)arch; +#endif for (i=0;i<max_pitch;i++) { opus_val32 sum = 0; for (j=0;j<len;j++) - sum = MAC16_16(sum, x[j],y[i+j]); + sum = MAC16_16(sum, _x[j], _y[i+j]); xcorr[i] = sum; #ifdef OPUS_FIXED_POINT maxcorr = MAX32(maxcorr, sum); @@ -241,30 +248,25 @@ celt_pitch_xcorr(opus_val16 *x, opus_val16 *y, opus_val32 *xcorr, int len, int m #ifdef OPUS_FIXED_POINT return maxcorr; #endif -} #else /* Unrolled version of the pitch correlation -- runs faster on x86 and ARM */ - -#ifdef OPUS_FIXED_POINT -opus_val32 -#else -void -#endif -celt_pitch_xcorr_c(const opus_val16 *_x, const opus_val16 *_y, opus_val32 *xcorr, int len, int max_pitch) -{ - int i,j; + int i; /*The EDSP version requires that max_pitch is at least 1, and that _x is 32-bit aligned. Since it's hard to put asserts in assembly, put them here.*/ - celt_assert(max_pitch>0); - celt_assert((((unsigned char *)_x-(unsigned char *)NULL)&3)==0); #ifdef OPUS_FIXED_POINT opus_val32 maxcorr=1; #endif + celt_assert(max_pitch>0); + celt_assert((((unsigned char *)_x-(unsigned char *)NULL)&3)==0); for (i=0;i<max_pitch-3;i+=4) { opus_val32 sum[4]={0,0,0,0}; - xcorr_kernel(_x, _y+i, sum, len); +#if defined(OVERRIDE_PITCH_XCORR) + xcorr_kernel_c(_x, _y+i, sum, len); +#else + xcorr_kernel(_x, _y+i, sum, len, arch); +#endif xcorr[i]=sum[0]; xcorr[i+1]=sum[1]; xcorr[i+2]=sum[2]; @@ -279,9 +281,12 @@ celt_pitch_xcorr_c(const opus_val16 *_x, const opus_val16 *_y, opus_val32 *xcorr /* In case max_pitch isn't a multiple of 4, do non-unrolled version. */ for (;i<max_pitch;i++) { - opus_val32 sum = 0; - for (j=0;j<len;j++) - sum = MAC16_16(sum, _x[j],_y[i+j]); + opus_val32 sum; +#if defined(OVERRIDE_PITCH_XCORR) + sum = celt_inner_prod_c(_x, _y+i, len); +#else + sum = celt_inner_prod(_x, _y+i, len, arch); +#endif xcorr[i] = sum; #ifdef OPUS_FIXED_POINT maxcorr = MAX32(maxcorr, sum); @@ -290,9 +295,9 @@ celt_pitch_xcorr_c(const opus_val16 *_x, const opus_val16 *_y, opus_val32 *xcorr #ifdef OPUS_FIXED_POINT return maxcorr; #endif +#endif } -#endif void pitch_search(const opus_val16 * OPUS_RESTRICT x_lp, opus_val16 * OPUS_RESTRICT y, int len, int max_pitch, int *pitch, int arch) { @@ -361,12 +366,17 @@ void pitch_search(const opus_val16 * OPUS_RESTRICT x_lp, opus_val16 * OPUS_RESTR #endif for (i=0;i<max_pitch>>1;i++) { - opus_val32 sum=0; + opus_val32 sum; xcorr[i] = 0; if (abs(i-2*best_pitch[0])>2 && abs(i-2*best_pitch[1])>2) continue; +#ifdef OPUS_FIXED_POINT + sum = 0; for (j=0;j<len>>1;j++) sum += SHR32(MULT16_16(x_lp[j],y[i+j]), shift); +#else + sum = celt_inner_prod_c(x_lp, y+i, len>>1); +#endif xcorr[i] = MAX32(-1, sum); #ifdef OPUS_FIXED_POINT maxcorr = MAX32(maxcorr, sum); @@ -401,7 +411,7 @@ void pitch_search(const opus_val16 * OPUS_RESTRICT x_lp, opus_val16 * OPUS_RESTR static const int second_check[16] = {0, 0, 3, 2, 3, 2, 5, 2, 3, 2, 3, 2, 5, 2, 3, 2}; opus_val16 remove_doubling(opus_val16 *x, int maxperiod, int minperiod, - int N, int *T0_, int prev_period, opus_val16 prev_gain) + int N, int *T0_, int prev_period, opus_val16 prev_gain, int arch) { int k, i, T, T0; opus_val16 g, g0; @@ -426,7 +436,7 @@ opus_val16 remove_doubling(opus_val16 *x, int maxperiod, int minperiod, T = T0 = *T0_; ALLOC(yy_lookup, maxperiod+1, opus_val32); - dual_inner_prod(x, x, x-T0, N, &xx, &xy); + dual_inner_prod(x, x, x-T0, N, &xx, &xy, arch); yy_lookup[0] = xx; yy=xx; for (i=1;i<=maxperiod;i++) @@ -456,7 +466,7 @@ opus_val16 remove_doubling(opus_val16 *x, int maxperiod, int minperiod, opus_val16 g1; opus_val16 cont=0; opus_val16 thresh; - T1 = (2*T0+k)/(2*k); + T1 = celt_udiv(2*T0+k, 2*k); if (T1 < minperiod) break; /* Look for another strong correlation at T1b */ @@ -468,9 +478,9 @@ opus_val16 remove_doubling(opus_val16 *x, int maxperiod, int minperiod, T1b = T0+T1; } else { - T1b = (2*second_check[k]*T0+k)/(2*k); + T1b = celt_udiv(2*second_check[k]*T0+k, 2*k); } - dual_inner_prod(x, &x[-T1], &x[-T1b], N, &xy, &xy2); + dual_inner_prod(x, &x[-T1], &x[-T1b], N, &xy, &xy2, arch); xy += xy2; yy = yy_lookup[T1] + yy_lookup[T1b]; #ifdef OPUS_FIXED_POINT @@ -513,13 +523,7 @@ opus_val16 remove_doubling(opus_val16 *x, int maxperiod, int minperiod, pg = SHR32(frac_div32(best_xy,best_yy+1),16); for (k=0;k<3;k++) - { - int T1 = T+k-1; - xy = 0; - for (i=0;i<N;i++) - xy = MAC16_16(xy, x[i], x[i-T1]); - xcorr[k] = xy; - } + xcorr[k] = celt_inner_prod(x, x-(T+k-1), N, arch); if ((xcorr[2]-xcorr[0]) > MULT16_32_Q15(QCONST16(.7f,15),xcorr[1]-xcorr[0])) offset = 1; else if ((xcorr[0]-xcorr[2]) > MULT16_32_Q15(QCONST16(.7f,15),xcorr[1]-xcorr[2])) diff --git a/drivers/opus/celt/pitch.h b/drivers/opus/celt/pitch.h index f599f5fc76..ecae7667b8 100644 --- a/drivers/opus/celt/pitch.h +++ b/drivers/opus/celt/pitch.h @@ -34,15 +34,21 @@ #ifndef PITCH_H #define PITCH_H -#include "opus/celt/opus_modes.h" +#include "opus/celt/modes.h" #include "opus/celt/cpu_support.h" -#if defined(__SSE__) && !defined(OPUS_FIXED_POINT) -#include "x86/pitch_sse.h" +#if (defined(OPUS_X86_MAY_HAVE_SSE) && !defined(FIXED_POINT)) \ + || ((defined(OPUS_X86_MAY_HAVE_SSE4_1) || defined(OPUS_X86_MAY_HAVE_SSE2)) && defined(FIXED_POINT)) +#include "opus/celt/x86/pitch_sse.h" #endif -#if defined(OPUS_ARM_ASM) && defined(OPUS_FIXED_POINT) -# include "arm/pitch_arm.h" +#if defined(MIPSr1_ASM) +#include "opus/celt/mips/pitch_mipsr1.h" +#endif + +#if ((defined(OPUS_ARM_ASM) && defined(FIXED_POINT)) \ + || defined(OPUS_ARM_MAY_HAVE_NEON_INTR)) +# include "opus/celt/arm/pitch_arm.h" #endif void pitch_downsample(celt_sig * OPUS_RESTRICT x[], opus_val16 * OPUS_RESTRICT x_lp, @@ -52,12 +58,12 @@ void pitch_search(const opus_val16 * OPUS_RESTRICT x_lp, opus_val16 * OPUS_RESTR int len, int max_pitch, int *pitch, int arch); opus_val16 remove_doubling(opus_val16 *x, int maxperiod, int minperiod, - int N, int *T0, int prev_period, opus_val16 prev_gain); + int N, int *T0, int prev_period, opus_val16 prev_gain, int arch); + /* OPT: This is the kernel you really want to optimize. It gets used a lot by the prefilter and by the PLC. */ -#ifndef OVERRIDE_XCORR_KERNEL -static OPUS_INLINE void xcorr_kernel(const opus_val16 * x, const opus_val16 * y, opus_val32 sum[4], int len) +static OPUS_INLINE void xcorr_kernel_c(const opus_val16 * x, const opus_val16 * y, opus_val32 sum[4], int len) { int j; opus_val16 y_0, y_1, y_2, y_3; @@ -122,10 +128,14 @@ static OPUS_INLINE void xcorr_kernel(const opus_val16 * x, const opus_val16 * y, sum[3] = MAC16_16(sum[3],tmp,y_1); } } + +#ifndef OVERRIDE_XCORR_KERNEL +#define xcorr_kernel(x, y, sum, len, arch) \ + ((void)(arch),xcorr_kernel_c(x, y, sum, len)) #endif /* OVERRIDE_XCORR_KERNEL */ -#ifndef OVERRIDE_DUAL_INNER_PROD -static OPUS_INLINE void dual_inner_prod(const opus_val16 *x, const opus_val16 *y01, const opus_val16 *y02, + +static OPUS_INLINE void dual_inner_prod_c(const opus_val16 *x, const opus_val16 *y01, const opus_val16 *y02, int N, opus_val32 *xy1, opus_val32 *xy2) { int i; @@ -139,8 +149,35 @@ static OPUS_INLINE void dual_inner_prod(const opus_val16 *x, const opus_val16 *y *xy1 = xy01; *xy2 = xy02; } + +#ifndef OVERRIDE_DUAL_INNER_PROD +# define dual_inner_prod(x, y01, y02, N, xy1, xy2, arch) \ + ((void)(arch),dual_inner_prod_c(x, y01, y02, N, xy1, xy2)) +#endif + +/*We make sure a C version is always available for cases where the overhead of + vectorization and passing around an arch flag aren't worth it.*/ +static OPUS_INLINE opus_val32 celt_inner_prod_c(const opus_val16 *x, + const opus_val16 *y, int N) +{ + int i; + opus_val32 xy=0; + for (i=0;i<N;i++) + xy = MAC16_16(xy, x[i], y[i]); + return xy; +} + +#if !defined(OVERRIDE_CELT_INNER_PROD) +# define celt_inner_prod(x, y, N, arch) \ + ((void)(arch),celt_inner_prod_c(x, y, N)) #endif +#ifdef NON_STATIC_COMB_FILTER_CONST_C +void comb_filter_const_c(opus_val32 *y, opus_val32 *x, int T, int N, + opus_val16 g10, opus_val16 g11, opus_val16 g12); +#endif + + #ifdef OPUS_FIXED_POINT opus_val32 #else @@ -151,9 +188,11 @@ celt_pitch_xcorr_c(const opus_val16 *_x, const opus_val16 *_y, #if !defined(OVERRIDE_PITCH_XCORR) /*Is run-time CPU detection enabled on this platform?*/ -# if defined(OPUS_HAVE_RTCD) +# if defined(OPUS_HAVE_RTCD) && (defined(OPUS_ARM_ASM) \ + || (defined(OPUS_ARM_MAY_HAVE_NEON_INTR) \ + && !defined(OPUS_ARM_PRESUME_NEON_INTR))) extern -# if defined(OPUS_FIXED_POINT) +# if defined(FIXED_POINT) opus_val32 # else void @@ -161,12 +200,20 @@ void (*const CELT_PITCH_XCORR_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *, const opus_val16 *, opus_val32 *, int, int); +# define OVERRIDE_PITCH_XCORR # define celt_pitch_xcorr(_x, _y, xcorr, len, max_pitch, arch) \ ((*CELT_PITCH_XCORR_IMPL[(arch)&OPUS_ARCHMASK])(_x, _y, \ xcorr, len, max_pitch)) # else -# define celt_pitch_xcorr(_x, _y, xcorr, len, max_pitch, arch) \ - ((void)(arch),celt_pitch_xcorr_c(_x, _y, xcorr, len, max_pitch)) + +#ifdef OPUS_FIXED_POINT +opus_val32 +#else +void +#endif +celt_pitch_xcorr(const opus_val16 *_x, const opus_val16 *_y, + opus_val32 *xcorr, int len, int max_pitch, int arch); + # endif #endif diff --git a/drivers/opus/celt/quant_bands.c b/drivers/opus/celt/quant_bands.c index e64ed28f22..b38bfa8b8e 100644 --- a/drivers/opus/celt/quant_bands.c +++ b/drivers/opus/celt/quant_bands.c @@ -25,10 +25,7 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/celt/quant_bands.h" #include "opus/celt/laplace.h" @@ -292,7 +289,7 @@ void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd, #endif } if (lfe) - max_decay=3; + max_decay = QCONST16(3.f,DB_SHIFT); enc_start_state = *enc; ALLOC(oldEBands_intra, C*m->nbEBands, opus_val16); diff --git a/drivers/opus/celt/quant_bands.h b/drivers/opus/celt/quant_bands.h index 85d011e6e0..31d4b94e41 100644 --- a/drivers/opus/celt/quant_bands.h +++ b/drivers/opus/celt/quant_bands.h @@ -30,7 +30,7 @@ #define QUANT_BANDS #include "opus/celt/arch.h" -#include "opus/celt/opus_modes.h" +#include "opus/celt/modes.h" #include "opus/celt/entenc.h" #include "opus/celt/entdec.h" #include "opus/celt/mathops.h" diff --git a/drivers/opus/celt/rate.c b/drivers/opus/celt/rate.c index ecc0ab2a4f..e69fb3f030 100644 --- a/drivers/opus/celt/rate.c +++ b/drivers/opus/celt/rate.c @@ -25,13 +25,10 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include <math.h> -#include "opus/celt/opus_modes.h" +#include "opus/celt/modes.h" #include "opus/celt/cwrs.h" #include "opus/celt/arch.h" #include "opus/celt/os_support.h" @@ -131,7 +128,7 @@ void compute_pulse_cache(CELTMode *m, int LM) for (i=0;i<nbEntries;i++) { unsigned char *ptr = bits+entryI[i]; - opus_int16 tmp[MAX_PULSES+1]; + opus_int16 tmp[CELT_MAX_PULSES+1]; get_required_bits(tmp, entryN[i], get_pulses(entryK[i]), BITRES); for (j=1;j<=entryK[i];j++) ptr[j] = tmp[get_pulses(j)]-1; @@ -333,7 +330,7 @@ static OPUS_INLINE int interp_bits2pulses(const CELTMode *m, int start, int end, /*Figure out how many left-over bits we would be adding to this band. This can include bits we've stolen back from higher, skipped bands.*/ left = total-psum; - percoeff = left/(m->eBands[codedBands]-m->eBands[start]); + percoeff = celt_udiv(left, m->eBands[codedBands]-m->eBands[start]); left -= (m->eBands[codedBands]-m->eBands[start])*percoeff; rem = IMAX(left-(m->eBands[j]-m->eBands[start]),0); band_width = m->eBands[codedBands]-m->eBands[j]; @@ -414,7 +411,7 @@ static OPUS_INLINE int interp_bits2pulses(const CELTMode *m, int start, int end, /* Allocate the remaining bits */ left = total-psum; - percoeff = left/(m->eBands[codedBands]-m->eBands[start]); + percoeff = celt_udiv(left, m->eBands[codedBands]-m->eBands[start]); left -= (m->eBands[codedBands]-m->eBands[start])*percoeff; for (j=start;j<codedBands;j++) bits[j] += ((int)percoeff*(m->eBands[j+1]-m->eBands[j])); @@ -465,7 +462,8 @@ static OPUS_INLINE int interp_bits2pulses(const CELTMode *m, int start, int end, offset += NClogN>>3; /* Divide with rounding */ - ebits[j] = IMAX(0, (bits[j] + offset + (den<<(BITRES-1))) / (den<<BITRES)); + ebits[j] = IMAX(0, (bits[j] + offset + (den<<(BITRES-1)))); + ebits[j] = celt_udiv(ebits[j], den)>>BITRES; /* Make sure not to bust */ if (C*ebits[j] > (bits[j]>>BITRES)) diff --git a/drivers/opus/celt/rate.h b/drivers/opus/celt/rate.h index e12dd29db8..cf8085fccf 100644 --- a/drivers/opus/celt/rate.h +++ b/drivers/opus/celt/rate.h @@ -32,7 +32,7 @@ #define MAX_PSEUDO 40 #define LOG_MAX_PSEUDO 6 -#define MAX_PULSES 128 +#define CELT_MAX_PULSES 128 #define MAX_FINE_BITS 8 @@ -41,7 +41,7 @@ #define QTHETA_OFFSET_TWOPHASE 16 #include "opus/celt/cwrs.h" -#include "opus/celt/opus_modes.h" +#include "opus/celt/modes.h" void compute_pulse_cache(CELTMode *m, int LM); diff --git a/drivers/opus/celt/stack_alloc.h b/drivers/opus/celt/stack_alloc.h index 464a6d0b7f..7cd6c56ccf 100644 --- a/drivers/opus/celt/stack_alloc.h +++ b/drivers/opus/celt/stack_alloc.h @@ -36,21 +36,17 @@ #include "opus/opus_defines.h" #if (!defined (VAR_ARRAYS) && !defined (USE_ALLOCA) && !defined (NONTHREADSAFE_PSEUDOSTACK)) -#define VAR_ARRAYS +#error "Opus requires one of VAR_ARRAYS, USE_ALLOCA, or NONTHREADSAFE_PSEUDOSTACK be defined to select the temporary allocation mode." #endif #ifdef USE_ALLOCA # ifdef WIN32 # include <malloc.h> # else -# ifdef OPUS_HAVE_ALLOCA_H +# ifdef HAVE_ALLOCA_H # include <alloca.h> # else -# ifdef __linux__ -# include <alloca.h> -# else -# include <stdlib.h> -# endif +# include <stdlib.h> # endif # endif #endif @@ -120,9 +116,11 @@ #else #ifdef CELT_C +char *scratch_ptr=0; char *global_stack=0; #else extern char *global_stack; +extern char *scratch_ptr; #endif /* CELT_C */ #ifdef ENABLE_VALGRIND @@ -144,8 +142,12 @@ extern char *global_stack_top; #define ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1)) #define PUSH(stack, size, type) (ALIGN((stack),sizeof(type)/sizeof(char)),(stack)+=(size)*(sizeof(type)/sizeof(char)),(type*)((stack)-(size)*(sizeof(type)/sizeof(char)))) +#if 0 /* Set this to 1 to instrument pseudostack usage */ +#define RESTORE_STACK (printf("%ld %s:%d\n", global_stack-scratch_ptr, __FILE__, __LINE__),global_stack = _saved_stack) +#else #define RESTORE_STACK (global_stack = _saved_stack) -#define ALLOC_STACK char *_saved_stack; (global_stack = (global_stack==0) ? opus_alloc_scratch(GLOBAL_STACK_SIZE) : global_stack); _saved_stack = global_stack; +#endif +#define ALLOC_STACK char *_saved_stack; (global_stack = (global_stack==0) ? (scratch_ptr=opus_alloc_scratch(GLOBAL_STACK_SIZE)) : global_stack); _saved_stack = global_stack; #endif /* ENABLE_VALGRIND */ diff --git a/drivers/opus/celt/static_modes_fixed.h b/drivers/opus/celt/static_modes_fixed.h index 1d92fc4b27..352642f507 100644 --- a/drivers/opus/celt/static_modes_fixed.h +++ b/drivers/opus/celt/static_modes_fixed.h @@ -1,9 +1,14 @@ /* The contents of this file was automatically generated by dump_modes.c with arguments: 48000 960 It contains static definitions for some pre-defined modes. */ -#include "opus/celt/opus_modes.h" +#include "opus/celt/modes.h" #include "opus/celt/rate.h" +#ifdef HAVE_ARM_NE10 +#define OVERRIDE_FFT 1 +#include "opus/celt/static_modes_fixed_arm_ne10.h" +#endif + #ifndef DEF_WINDOW120 #define DEF_WINDOW120 static const opus_val16 window120[120] = { @@ -341,84 +346,84 @@ static const kiss_twiddle_cpx fft_twiddles48000_960[480] = { #ifndef FFT_BITREV480 #define FFT_BITREV480 static const opus_int16 fft_bitrev480[480] = { -0, 120, 240, 360, 30, 150, 270, 390, 60, 180, 300, 420, 90, 210, 330, -450, 15, 135, 255, 375, 45, 165, 285, 405, 75, 195, 315, 435, 105, 225, -345, 465, 5, 125, 245, 365, 35, 155, 275, 395, 65, 185, 305, 425, 95, -215, 335, 455, 20, 140, 260, 380, 50, 170, 290, 410, 80, 200, 320, 440, -110, 230, 350, 470, 10, 130, 250, 370, 40, 160, 280, 400, 70, 190, 310, -430, 100, 220, 340, 460, 25, 145, 265, 385, 55, 175, 295, 415, 85, 205, -325, 445, 115, 235, 355, 475, 1, 121, 241, 361, 31, 151, 271, 391, 61, -181, 301, 421, 91, 211, 331, 451, 16, 136, 256, 376, 46, 166, 286, 406, -76, 196, 316, 436, 106, 226, 346, 466, 6, 126, 246, 366, 36, 156, 276, -396, 66, 186, 306, 426, 96, 216, 336, 456, 21, 141, 261, 381, 51, 171, -291, 411, 81, 201, 321, 441, 111, 231, 351, 471, 11, 131, 251, 371, 41, -161, 281, 401, 71, 191, 311, 431, 101, 221, 341, 461, 26, 146, 266, 386, -56, 176, 296, 416, 86, 206, 326, 446, 116, 236, 356, 476, 2, 122, 242, -362, 32, 152, 272, 392, 62, 182, 302, 422, 92, 212, 332, 452, 17, 137, -257, 377, 47, 167, 287, 407, 77, 197, 317, 437, 107, 227, 347, 467, 7, -127, 247, 367, 37, 157, 277, 397, 67, 187, 307, 427, 97, 217, 337, 457, -22, 142, 262, 382, 52, 172, 292, 412, 82, 202, 322, 442, 112, 232, 352, -472, 12, 132, 252, 372, 42, 162, 282, 402, 72, 192, 312, 432, 102, 222, -342, 462, 27, 147, 267, 387, 57, 177, 297, 417, 87, 207, 327, 447, 117, -237, 357, 477, 3, 123, 243, 363, 33, 153, 273, 393, 63, 183, 303, 423, -93, 213, 333, 453, 18, 138, 258, 378, 48, 168, 288, 408, 78, 198, 318, -438, 108, 228, 348, 468, 8, 128, 248, 368, 38, 158, 278, 398, 68, 188, -308, 428, 98, 218, 338, 458, 23, 143, 263, 383, 53, 173, 293, 413, 83, -203, 323, 443, 113, 233, 353, 473, 13, 133, 253, 373, 43, 163, 283, 403, -73, 193, 313, 433, 103, 223, 343, 463, 28, 148, 268, 388, 58, 178, 298, -418, 88, 208, 328, 448, 118, 238, 358, 478, 4, 124, 244, 364, 34, 154, -274, 394, 64, 184, 304, 424, 94, 214, 334, 454, 19, 139, 259, 379, 49, -169, 289, 409, 79, 199, 319, 439, 109, 229, 349, 469, 9, 129, 249, 369, -39, 159, 279, 399, 69, 189, 309, 429, 99, 219, 339, 459, 24, 144, 264, -384, 54, 174, 294, 414, 84, 204, 324, 444, 114, 234, 354, 474, 14, 134, -254, 374, 44, 164, 284, 404, 74, 194, 314, 434, 104, 224, 344, 464, 29, -149, 269, 389, 59, 179, 299, 419, 89, 209, 329, 449, 119, 239, 359, 479, +0, 96, 192, 288, 384, 32, 128, 224, 320, 416, 64, 160, 256, 352, 448, +8, 104, 200, 296, 392, 40, 136, 232, 328, 424, 72, 168, 264, 360, 456, +16, 112, 208, 304, 400, 48, 144, 240, 336, 432, 80, 176, 272, 368, 464, +24, 120, 216, 312, 408, 56, 152, 248, 344, 440, 88, 184, 280, 376, 472, +4, 100, 196, 292, 388, 36, 132, 228, 324, 420, 68, 164, 260, 356, 452, +12, 108, 204, 300, 396, 44, 140, 236, 332, 428, 76, 172, 268, 364, 460, +20, 116, 212, 308, 404, 52, 148, 244, 340, 436, 84, 180, 276, 372, 468, +28, 124, 220, 316, 412, 60, 156, 252, 348, 444, 92, 188, 284, 380, 476, +1, 97, 193, 289, 385, 33, 129, 225, 321, 417, 65, 161, 257, 353, 449, +9, 105, 201, 297, 393, 41, 137, 233, 329, 425, 73, 169, 265, 361, 457, +17, 113, 209, 305, 401, 49, 145, 241, 337, 433, 81, 177, 273, 369, 465, +25, 121, 217, 313, 409, 57, 153, 249, 345, 441, 89, 185, 281, 377, 473, +5, 101, 197, 293, 389, 37, 133, 229, 325, 421, 69, 165, 261, 357, 453, +13, 109, 205, 301, 397, 45, 141, 237, 333, 429, 77, 173, 269, 365, 461, +21, 117, 213, 309, 405, 53, 149, 245, 341, 437, 85, 181, 277, 373, 469, +29, 125, 221, 317, 413, 61, 157, 253, 349, 445, 93, 189, 285, 381, 477, +2, 98, 194, 290, 386, 34, 130, 226, 322, 418, 66, 162, 258, 354, 450, +10, 106, 202, 298, 394, 42, 138, 234, 330, 426, 74, 170, 266, 362, 458, +18, 114, 210, 306, 402, 50, 146, 242, 338, 434, 82, 178, 274, 370, 466, +26, 122, 218, 314, 410, 58, 154, 250, 346, 442, 90, 186, 282, 378, 474, +6, 102, 198, 294, 390, 38, 134, 230, 326, 422, 70, 166, 262, 358, 454, +14, 110, 206, 302, 398, 46, 142, 238, 334, 430, 78, 174, 270, 366, 462, +22, 118, 214, 310, 406, 54, 150, 246, 342, 438, 86, 182, 278, 374, 470, +30, 126, 222, 318, 414, 62, 158, 254, 350, 446, 94, 190, 286, 382, 478, +3, 99, 195, 291, 387, 35, 131, 227, 323, 419, 67, 163, 259, 355, 451, +11, 107, 203, 299, 395, 43, 139, 235, 331, 427, 75, 171, 267, 363, 459, +19, 115, 211, 307, 403, 51, 147, 243, 339, 435, 83, 179, 275, 371, 467, +27, 123, 219, 315, 411, 59, 155, 251, 347, 443, 91, 187, 283, 379, 475, +7, 103, 199, 295, 391, 39, 135, 231, 327, 423, 71, 167, 263, 359, 455, +15, 111, 207, 303, 399, 47, 143, 239, 335, 431, 79, 175, 271, 367, 463, +23, 119, 215, 311, 407, 55, 151, 247, 343, 439, 87, 183, 279, 375, 471, +31, 127, 223, 319, 415, 63, 159, 255, 351, 447, 95, 191, 287, 383, 479, }; #endif #ifndef FFT_BITREV240 #define FFT_BITREV240 static const opus_int16 fft_bitrev240[240] = { -0, 60, 120, 180, 15, 75, 135, 195, 30, 90, 150, 210, 45, 105, 165, -225, 5, 65, 125, 185, 20, 80, 140, 200, 35, 95, 155, 215, 50, 110, -170, 230, 10, 70, 130, 190, 25, 85, 145, 205, 40, 100, 160, 220, 55, -115, 175, 235, 1, 61, 121, 181, 16, 76, 136, 196, 31, 91, 151, 211, -46, 106, 166, 226, 6, 66, 126, 186, 21, 81, 141, 201, 36, 96, 156, -216, 51, 111, 171, 231, 11, 71, 131, 191, 26, 86, 146, 206, 41, 101, -161, 221, 56, 116, 176, 236, 2, 62, 122, 182, 17, 77, 137, 197, 32, -92, 152, 212, 47, 107, 167, 227, 7, 67, 127, 187, 22, 82, 142, 202, -37, 97, 157, 217, 52, 112, 172, 232, 12, 72, 132, 192, 27, 87, 147, -207, 42, 102, 162, 222, 57, 117, 177, 237, 3, 63, 123, 183, 18, 78, -138, 198, 33, 93, 153, 213, 48, 108, 168, 228, 8, 68, 128, 188, 23, -83, 143, 203, 38, 98, 158, 218, 53, 113, 173, 233, 13, 73, 133, 193, -28, 88, 148, 208, 43, 103, 163, 223, 58, 118, 178, 238, 4, 64, 124, -184, 19, 79, 139, 199, 34, 94, 154, 214, 49, 109, 169, 229, 9, 69, -129, 189, 24, 84, 144, 204, 39, 99, 159, 219, 54, 114, 174, 234, 14, -74, 134, 194, 29, 89, 149, 209, 44, 104, 164, 224, 59, 119, 179, 239, +0, 48, 96, 144, 192, 16, 64, 112, 160, 208, 32, 80, 128, 176, 224, +4, 52, 100, 148, 196, 20, 68, 116, 164, 212, 36, 84, 132, 180, 228, +8, 56, 104, 152, 200, 24, 72, 120, 168, 216, 40, 88, 136, 184, 232, +12, 60, 108, 156, 204, 28, 76, 124, 172, 220, 44, 92, 140, 188, 236, +1, 49, 97, 145, 193, 17, 65, 113, 161, 209, 33, 81, 129, 177, 225, +5, 53, 101, 149, 197, 21, 69, 117, 165, 213, 37, 85, 133, 181, 229, +9, 57, 105, 153, 201, 25, 73, 121, 169, 217, 41, 89, 137, 185, 233, +13, 61, 109, 157, 205, 29, 77, 125, 173, 221, 45, 93, 141, 189, 237, +2, 50, 98, 146, 194, 18, 66, 114, 162, 210, 34, 82, 130, 178, 226, +6, 54, 102, 150, 198, 22, 70, 118, 166, 214, 38, 86, 134, 182, 230, +10, 58, 106, 154, 202, 26, 74, 122, 170, 218, 42, 90, 138, 186, 234, +14, 62, 110, 158, 206, 30, 78, 126, 174, 222, 46, 94, 142, 190, 238, +3, 51, 99, 147, 195, 19, 67, 115, 163, 211, 35, 83, 131, 179, 227, +7, 55, 103, 151, 199, 23, 71, 119, 167, 215, 39, 87, 135, 183, 231, +11, 59, 107, 155, 203, 27, 75, 123, 171, 219, 43, 91, 139, 187, 235, +15, 63, 111, 159, 207, 31, 79, 127, 175, 223, 47, 95, 143, 191, 239, }; #endif #ifndef FFT_BITREV120 #define FFT_BITREV120 static const opus_int16 fft_bitrev120[120] = { -0, 30, 60, 90, 15, 45, 75, 105, 5, 35, 65, 95, 20, 50, 80, -110, 10, 40, 70, 100, 25, 55, 85, 115, 1, 31, 61, 91, 16, 46, -76, 106, 6, 36, 66, 96, 21, 51, 81, 111, 11, 41, 71, 101, 26, -56, 86, 116, 2, 32, 62, 92, 17, 47, 77, 107, 7, 37, 67, 97, -22, 52, 82, 112, 12, 42, 72, 102, 27, 57, 87, 117, 3, 33, 63, -93, 18, 48, 78, 108, 8, 38, 68, 98, 23, 53, 83, 113, 13, 43, -73, 103, 28, 58, 88, 118, 4, 34, 64, 94, 19, 49, 79, 109, 9, -39, 69, 99, 24, 54, 84, 114, 14, 44, 74, 104, 29, 59, 89, 119, +0, 24, 48, 72, 96, 8, 32, 56, 80, 104, 16, 40, 64, 88, 112, +4, 28, 52, 76, 100, 12, 36, 60, 84, 108, 20, 44, 68, 92, 116, +1, 25, 49, 73, 97, 9, 33, 57, 81, 105, 17, 41, 65, 89, 113, +5, 29, 53, 77, 101, 13, 37, 61, 85, 109, 21, 45, 69, 93, 117, +2, 26, 50, 74, 98, 10, 34, 58, 82, 106, 18, 42, 66, 90, 114, +6, 30, 54, 78, 102, 14, 38, 62, 86, 110, 22, 46, 70, 94, 118, +3, 27, 51, 75, 99, 11, 35, 59, 83, 107, 19, 43, 67, 91, 115, +7, 31, 55, 79, 103, 15, 39, 63, 87, 111, 23, 47, 71, 95, 119, }; #endif #ifndef FFT_BITREV60 #define FFT_BITREV60 static const opus_int16 fft_bitrev60[60] = { -0, 15, 30, 45, 5, 20, 35, 50, 10, 25, 40, 55, 1, 16, 31, -46, 6, 21, 36, 51, 11, 26, 41, 56, 2, 17, 32, 47, 7, 22, -37, 52, 12, 27, 42, 57, 3, 18, 33, 48, 8, 23, 38, 53, 13, -28, 43, 58, 4, 19, 34, 49, 9, 24, 39, 54, 14, 29, 44, 59, +0, 12, 24, 36, 48, 4, 16, 28, 40, 52, 8, 20, 32, 44, 56, +1, 13, 25, 37, 49, 5, 17, 29, 41, 53, 9, 21, 33, 45, 57, +2, 14, 26, 38, 50, 6, 18, 30, 42, 54, 10, 22, 34, 46, 58, +3, 15, 27, 39, 51, 7, 19, 31, 43, 55, 11, 23, 35, 47, 59, }; #endif @@ -426,10 +431,17 @@ static const opus_int16 fft_bitrev60[60] = { #define FFT_STATE48000_960_0 static const kiss_fft_state fft_state48000_960_0 = { 480, /* nfft */ +17476, /* scale */ +8, /* scale_shift */ -1, /* shift */ -{4, 120, 4, 30, 2, 15, 3, 5, 5, 1, 0, 0, 0, 0, 0, 0, }, /* factors */ +{5, 96, 3, 32, 4, 8, 2, 4, 4, 1, 0, 0, 0, 0, 0, 0, }, /* factors */ fft_bitrev480, /* bitrev */ fft_twiddles48000_960, /* bitrev */ +#ifdef OVERRIDE_FFT +(arch_fft_state *)&cfg_arch_480, +#else +NULL, +#endif }; #endif @@ -437,10 +449,17 @@ fft_twiddles48000_960, /* bitrev */ #define FFT_STATE48000_960_1 static const kiss_fft_state fft_state48000_960_1 = { 240, /* nfft */ +17476, /* scale */ +7, /* scale_shift */ 1, /* shift */ -{4, 60, 4, 15, 3, 5, 5, 1, 0, 0, 0, 0, 0, 0, 0, 0, }, /* factors */ +{5, 48, 3, 16, 4, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, }, /* factors */ fft_bitrev240, /* bitrev */ fft_twiddles48000_960, /* bitrev */ +#ifdef OVERRIDE_FFT +(arch_fft_state *)&cfg_arch_240, +#else +NULL, +#endif }; #endif @@ -448,10 +467,17 @@ fft_twiddles48000_960, /* bitrev */ #define FFT_STATE48000_960_2 static const kiss_fft_state fft_state48000_960_2 = { 120, /* nfft */ +17476, /* scale */ +6, /* scale_shift */ 2, /* shift */ -{4, 30, 2, 15, 3, 5, 5, 1, 0, 0, 0, 0, 0, 0, 0, 0, }, /* factors */ +{5, 24, 3, 8, 2, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, }, /* factors */ fft_bitrev120, /* bitrev */ fft_twiddles48000_960, /* bitrev */ +#ifdef OVERRIDE_FFT +(arch_fft_state *)&cfg_arch_120, +#else +NULL, +#endif }; #endif @@ -459,10 +485,17 @@ fft_twiddles48000_960, /* bitrev */ #define FFT_STATE48000_960_3 static const kiss_fft_state fft_state48000_960_3 = { 60, /* nfft */ +17476, /* scale */ +5, /* scale_shift */ 3, /* shift */ -{4, 15, 3, 5, 5, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* factors */ +{5, 12, 3, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* factors */ fft_bitrev60, /* bitrev */ fft_twiddles48000_960, /* bitrev */ +#ifdef OVERRIDE_FFT +(arch_fft_state *)&cfg_arch_60, +#else +NULL, +#endif }; #endif @@ -470,104 +503,368 @@ fft_twiddles48000_960, /* bitrev */ #ifndef MDCT_TWIDDLES960 #define MDCT_TWIDDLES960 -static const opus_val16 mdct_twiddles960[481] = { -32767, 32767, 32767, 32767, 32766, -32763, 32762, 32759, 32757, 32753, -32751, 32747, 32743, 32738, 32733, -32729, 32724, 32717, 32711, 32705, -32698, 32690, 32683, 32676, 32667, -32658, 32650, 32640, 32631, 32620, -32610, 32599, 32588, 32577, 32566, -32554, 32541, 32528, 32515, 32502, -32487, 32474, 32459, 32444, 32429, -32413, 32397, 32381, 32364, 32348, -32331, 32313, 32294, 32277, 32257, -32239, 32219, 32200, 32180, 32159, -32138, 32118, 32096, 32074, 32051, -32029, 32006, 31984, 31960, 31936, -31912, 31888, 31863, 31837, 31812, -31786, 31760, 31734, 31707, 31679, -31652, 31624, 31596, 31567, 31539, -31508, 31479, 31450, 31419, 31388, -31357, 31326, 31294, 31262, 31230, -31198, 31164, 31131, 31097, 31063, -31030, 30994, 30959, 30924, 30889, -30853, 30816, 30779, 30743, 30705, -30668, 30629, 30592, 30553, 30515, -30475, 30435, 30396, 30356, 30315, -30274, 30233, 30191, 30149, 30107, -30065, 30022, 29979, 29936, 29891, -29847, 29803, 29758, 29713, 29668, -29622, 29577, 29529, 29483, 29436, -29390, 29341, 29293, 29246, 29197, -29148, 29098, 29050, 29000, 28949, -28899, 28848, 28797, 28746, 28694, -28642, 28590, 28537, 28485, 28432, -28378, 28324, 28271, 28217, 28162, -28106, 28051, 27995, 27940, 27884, -27827, 27770, 27713, 27657, 27598, -27540, 27481, 27423, 27365, 27305, -27246, 27187, 27126, 27066, 27006, -26945, 26883, 26822, 26760, 26698, -26636, 26574, 26510, 26448, 26383, -26320, 26257, 26191, 26127, 26062, -25997, 25931, 25866, 25800, 25734, -25667, 25601, 25533, 25466, 25398, -25330, 25262, 25194, 25125, 25056, -24987, 24917, 24848, 24778, 24707, -24636, 24566, 24495, 24424, 24352, -24280, 24208, 24135, 24063, 23990, -23917, 23842, 23769, 23695, 23622, -23546, 23472, 23398, 23322, 23246, -23171, 23095, 23018, 22942, 22866, -22788, 22711, 22634, 22557, 22478, -22400, 22322, 22244, 22165, 22085, -22006, 21927, 21846, 21766, 21687, -21606, 21524, 21443, 21363, 21282, -21199, 21118, 21035, 20954, 20870, -20788, 20705, 20621, 20538, 20455, -20371, 20286, 20202, 20118, 20034, -19947, 19863, 19777, 19692, 19606, -19520, 19434, 19347, 19260, 19174, -19088, 18999, 18911, 18825, 18737, -18648, 18560, 18472, 18384, 18294, -18205, 18116, 18025, 17936, 17846, -17757, 17666, 17576, 17485, 17395, -17303, 17212, 17122, 17030, 16937, -16846, 16755, 16662, 16569, 16477, -16385, 16291, 16198, 16105, 16012, -15917, 15824, 15730, 15636, 15541, -15447, 15352, 15257, 15162, 15067, -14973, 14875, 14781, 14685, 14589, -14493, 14396, 14300, 14204, 14107, -14010, 13914, 13815, 13718, 13621, -13524, 13425, 13328, 13230, 13133, -13033, 12935, 12836, 12738, 12638, -12540, 12441, 12341, 12241, 12142, -12044, 11943, 11843, 11744, 11643, -11542, 11442, 11342, 11241, 11139, -11039, 10939, 10836, 10736, 10635, -10534, 10431, 10330, 10228, 10127, -10024, 9921, 9820, 9718, 9614, -9512, 9410, 9306, 9204, 9101, -8998, 8895, 8791, 8689, 8585, -8481, 8377, 8274, 8171, 8067, -7962, 7858, 7753, 7650, 7545, -7441, 7336, 7231, 7129, 7023, -6917, 6813, 6709, 6604, 6498, -6393, 6288, 6182, 6077, 5973, -5867, 5760, 5656, 5549, 5445, -5339, 5232, 5127, 5022, 4914, -4809, 4703, 4596, 4490, 4384, -4278, 4171, 4065, 3958, 3852, -3745, 3640, 3532, 3426, 3318, -3212, 3106, 2998, 2891, 2786, -2679, 2570, 2465, 2358, 2251, -2143, 2037, 1929, 1823, 1715, -1609, 1501, 1393, 1287, 1180, -1073, 964, 858, 751, 644, -535, 429, 322, 214, 107, -0, }; +static const opus_val16 mdct_twiddles960[1800] = { +32767, 32767, 32767, 32766, 32765, +32763, 32761, 32759, 32756, 32753, +32750, 32746, 32742, 32738, 32733, +32728, 32722, 32717, 32710, 32704, +32697, 32690, 32682, 32674, 32666, +32657, 32648, 32639, 32629, 32619, +32609, 32598, 32587, 32576, 32564, +32552, 32539, 32526, 32513, 32500, +32486, 32472, 32457, 32442, 32427, +32411, 32395, 32379, 32362, 32345, +32328, 32310, 32292, 32274, 32255, +32236, 32217, 32197, 32177, 32157, +32136, 32115, 32093, 32071, 32049, +32027, 32004, 31981, 31957, 31933, +31909, 31884, 31859, 31834, 31809, +31783, 31756, 31730, 31703, 31676, +31648, 31620, 31592, 31563, 31534, +31505, 31475, 31445, 31415, 31384, +31353, 31322, 31290, 31258, 31226, +31193, 31160, 31127, 31093, 31059, +31025, 30990, 30955, 30920, 30884, +30848, 30812, 30775, 30738, 30701, +30663, 30625, 30587, 30548, 30509, +30470, 30430, 30390, 30350, 30309, +30269, 30227, 30186, 30144, 30102, +30059, 30016, 29973, 29930, 29886, +29842, 29797, 29752, 29707, 29662, +29616, 29570, 29524, 29477, 29430, +29383, 29335, 29287, 29239, 29190, +29142, 29092, 29043, 28993, 28943, +28892, 28842, 28791, 28739, 28688, +28636, 28583, 28531, 28478, 28425, +28371, 28317, 28263, 28209, 28154, +28099, 28044, 27988, 27932, 27876, +27820, 27763, 27706, 27648, 27591, +27533, 27474, 27416, 27357, 27298, +27238, 27178, 27118, 27058, 26997, +26936, 26875, 26814, 26752, 26690, +26628, 26565, 26502, 26439, 26375, +26312, 26247, 26183, 26119, 26054, +25988, 25923, 25857, 25791, 25725, +25658, 25592, 25524, 25457, 25389, +25322, 25253, 25185, 25116, 25047, +24978, 24908, 24838, 24768, 24698, +24627, 24557, 24485, 24414, 24342, +24270, 24198, 24126, 24053, 23980, +23907, 23834, 23760, 23686, 23612, +23537, 23462, 23387, 23312, 23237, +23161, 23085, 23009, 22932, 22856, +22779, 22701, 22624, 22546, 22468, +22390, 22312, 22233, 22154, 22075, +21996, 21916, 21836, 21756, 21676, +21595, 21515, 21434, 21352, 21271, +21189, 21107, 21025, 20943, 20860, +20777, 20694, 20611, 20528, 20444, +20360, 20276, 20192, 20107, 20022, +19937, 19852, 19767, 19681, 19595, +19509, 19423, 19336, 19250, 19163, +19076, 18988, 18901, 18813, 18725, +18637, 18549, 18460, 18372, 18283, +18194, 18104, 18015, 17925, 17835, +17745, 17655, 17565, 17474, 17383, +17292, 17201, 17110, 17018, 16927, +16835, 16743, 16650, 16558, 16465, +16372, 16279, 16186, 16093, 15999, +15906, 15812, 15718, 15624, 15529, +15435, 15340, 15245, 15150, 15055, +14960, 14864, 14769, 14673, 14577, +14481, 14385, 14288, 14192, 14095, +13998, 13901, 13804, 13706, 13609, +13511, 13414, 13316, 13218, 13119, +13021, 12923, 12824, 12725, 12626, +12527, 12428, 12329, 12230, 12130, +12030, 11930, 11831, 11730, 11630, +11530, 11430, 11329, 11228, 11128, +11027, 10926, 10824, 10723, 10622, +10520, 10419, 10317, 10215, 10113, +10011, 9909, 9807, 9704, 9602, +9499, 9397, 9294, 9191, 9088, +8985, 8882, 8778, 8675, 8572, +8468, 8364, 8261, 8157, 8053, +7949, 7845, 7741, 7637, 7532, +7428, 7323, 7219, 7114, 7009, +6905, 6800, 6695, 6590, 6485, +6380, 6274, 6169, 6064, 5958, +5853, 5747, 5642, 5536, 5430, +5325, 5219, 5113, 5007, 4901, +4795, 4689, 4583, 4476, 4370, +4264, 4157, 4051, 3945, 3838, +3732, 3625, 3518, 3412, 3305, +3198, 3092, 2985, 2878, 2771, +2664, 2558, 2451, 2344, 2237, +2130, 2023, 1916, 1809, 1702, +1594, 1487, 1380, 1273, 1166, +1059, 952, 844, 737, 630, +523, 416, 308, 201, 94, +-13, -121, -228, -335, -442, +-550, -657, -764, -871, -978, +-1086, -1193, -1300, -1407, -1514, +-1621, -1728, -1835, -1942, -2049, +-2157, -2263, -2370, -2477, -2584, +-2691, -2798, -2905, -3012, -3118, +-3225, -3332, -3439, -3545, -3652, +-3758, -3865, -3971, -4078, -4184, +-4290, -4397, -4503, -4609, -4715, +-4821, -4927, -5033, -5139, -5245, +-5351, -5457, -5562, -5668, -5774, +-5879, -5985, -6090, -6195, -6301, +-6406, -6511, -6616, -6721, -6826, +-6931, -7036, -7140, -7245, -7349, +-7454, -7558, -7663, -7767, -7871, +-7975, -8079, -8183, -8287, -8390, +-8494, -8597, -8701, -8804, -8907, +-9011, -9114, -9217, -9319, -9422, +-9525, -9627, -9730, -9832, -9934, +-10037, -10139, -10241, -10342, -10444, +-10546, -10647, -10748, -10850, -10951, +-11052, -11153, -11253, -11354, -11455, +-11555, -11655, -11756, -11856, -11955, +-12055, -12155, -12254, -12354, -12453, +-12552, -12651, -12750, -12849, -12947, +-13046, -13144, -13242, -13340, -13438, +-13536, -13633, -13731, -13828, -13925, +-14022, -14119, -14216, -14312, -14409, +-14505, -14601, -14697, -14793, -14888, +-14984, -15079, -15174, -15269, -15364, +-15459, -15553, -15647, -15741, -15835, +-15929, -16023, -16116, -16210, -16303, +-16396, -16488, -16581, -16673, -16766, +-16858, -16949, -17041, -17133, -17224, +-17315, -17406, -17497, -17587, -17678, +-17768, -17858, -17948, -18037, -18127, +-18216, -18305, -18394, -18483, -18571, +-18659, -18747, -18835, -18923, -19010, +-19098, -19185, -19271, -19358, -19444, +-19531, -19617, -19702, -19788, -19873, +-19959, -20043, -20128, -20213, -20297, +-20381, -20465, -20549, -20632, -20715, +-20798, -20881, -20963, -21046, -21128, +-21210, -21291, -21373, -21454, -21535, +-21616, -21696, -21776, -21856, -21936, +-22016, -22095, -22174, -22253, -22331, +-22410, -22488, -22566, -22643, -22721, +-22798, -22875, -22951, -23028, -23104, +-23180, -23256, -23331, -23406, -23481, +-23556, -23630, -23704, -23778, -23852, +-23925, -23998, -24071, -24144, -24216, +-24288, -24360, -24432, -24503, -24574, +-24645, -24716, -24786, -24856, -24926, +-24995, -25064, -25133, -25202, -25270, +-25339, -25406, -25474, -25541, -25608, +-25675, -25742, -25808, -25874, -25939, +-26005, -26070, -26135, -26199, -26264, +-26327, -26391, -26455, -26518, -26581, +-26643, -26705, -26767, -26829, -26891, +-26952, -27013, -27073, -27133, -27193, +-27253, -27312, -27372, -27430, -27489, +-27547, -27605, -27663, -27720, -27777, +-27834, -27890, -27946, -28002, -28058, +-28113, -28168, -28223, -28277, -28331, +-28385, -28438, -28491, -28544, -28596, +-28649, -28701, -28752, -28803, -28854, +-28905, -28955, -29006, -29055, -29105, +-29154, -29203, -29251, -29299, -29347, +-29395, -29442, -29489, -29535, -29582, +-29628, -29673, -29719, -29764, -29808, +-29853, -29897, -29941, -29984, -30027, +-30070, -30112, -30154, -30196, -30238, +-30279, -30320, -30360, -30400, -30440, +-30480, -30519, -30558, -30596, -30635, +-30672, -30710, -30747, -30784, -30821, +-30857, -30893, -30929, -30964, -30999, +-31033, -31068, -31102, -31135, -31168, +-31201, -31234, -31266, -31298, -31330, +-31361, -31392, -31422, -31453, -31483, +-31512, -31541, -31570, -31599, -31627, +-31655, -31682, -31710, -31737, -31763, +-31789, -31815, -31841, -31866, -31891, +-31915, -31939, -31963, -31986, -32010, +-32032, -32055, -32077, -32099, -32120, +-32141, -32162, -32182, -32202, -32222, +-32241, -32260, -32279, -32297, -32315, +-32333, -32350, -32367, -32383, -32399, +-32415, -32431, -32446, -32461, -32475, +-32489, -32503, -32517, -32530, -32542, +-32555, -32567, -32579, -32590, -32601, +-32612, -32622, -32632, -32641, -32651, +-32659, -32668, -32676, -32684, -32692, +-32699, -32706, -32712, -32718, -32724, +-32729, -32734, -32739, -32743, -32747, +-32751, -32754, -32757, -32760, -32762, +-32764, -32765, -32767, -32767, -32767, +32767, 32767, 32765, 32761, 32756, +32750, 32742, 32732, 32722, 32710, +32696, 32681, 32665, 32647, 32628, +32608, 32586, 32562, 32538, 32512, +32484, 32455, 32425, 32393, 32360, +32326, 32290, 32253, 32214, 32174, +32133, 32090, 32046, 32001, 31954, +31906, 31856, 31805, 31753, 31700, +31645, 31588, 31530, 31471, 31411, +31349, 31286, 31222, 31156, 31089, +31020, 30951, 30880, 30807, 30733, +30658, 30582, 30504, 30425, 30345, +30263, 30181, 30096, 30011, 29924, +29836, 29747, 29656, 29564, 29471, +29377, 29281, 29184, 29086, 28987, +28886, 28784, 28681, 28577, 28471, +28365, 28257, 28147, 28037, 27925, +27812, 27698, 27583, 27467, 27349, +27231, 27111, 26990, 26868, 26744, +26620, 26494, 26367, 26239, 26110, +25980, 25849, 25717, 25583, 25449, +25313, 25176, 25038, 24900, 24760, +24619, 24477, 24333, 24189, 24044, +23898, 23751, 23602, 23453, 23303, +23152, 22999, 22846, 22692, 22537, +22380, 22223, 22065, 21906, 21746, +21585, 21423, 21261, 21097, 20933, +20767, 20601, 20434, 20265, 20096, +19927, 19756, 19584, 19412, 19239, +19065, 18890, 18714, 18538, 18361, +18183, 18004, 17824, 17644, 17463, +17281, 17098, 16915, 16731, 16546, +16361, 16175, 15988, 15800, 15612, +15423, 15234, 15043, 14852, 14661, +14469, 14276, 14083, 13889, 13694, +13499, 13303, 13107, 12910, 12713, +12515, 12317, 12118, 11918, 11718, +11517, 11316, 11115, 10913, 10710, +10508, 10304, 10100, 9896, 9691, +9486, 9281, 9075, 8869, 8662, +8455, 8248, 8040, 7832, 7623, +7415, 7206, 6996, 6787, 6577, +6366, 6156, 5945, 5734, 5523, +5311, 5100, 4888, 4675, 4463, +4251, 4038, 3825, 3612, 3399, +3185, 2972, 2758, 2544, 2330, +2116, 1902, 1688, 1474, 1260, +1045, 831, 617, 402, 188, +-27, -241, -456, -670, -885, +-1099, -1313, -1528, -1742, -1956, +-2170, -2384, -2598, -2811, -3025, +-3239, -3452, -3665, -3878, -4091, +-4304, -4516, -4728, -4941, -5153, +-5364, -5576, -5787, -5998, -6209, +-6419, -6629, -6839, -7049, -7258, +-7467, -7676, -7884, -8092, -8300, +-8507, -8714, -8920, -9127, -9332, +-9538, -9743, -9947, -10151, -10355, +-10558, -10761, -10963, -11165, -11367, +-11568, -11768, -11968, -12167, -12366, +-12565, -12762, -12960, -13156, -13352, +-13548, -13743, -13937, -14131, -14324, +-14517, -14709, -14900, -15091, -15281, +-15470, -15659, -15847, -16035, -16221, +-16407, -16593, -16777, -16961, -17144, +-17326, -17508, -17689, -17869, -18049, +-18227, -18405, -18582, -18758, -18934, +-19108, -19282, -19455, -19627, -19799, +-19969, -20139, -20308, -20475, -20642, +-20809, -20974, -21138, -21301, -21464, +-21626, -21786, -21946, -22105, -22263, +-22420, -22575, -22730, -22884, -23037, +-23189, -23340, -23490, -23640, -23788, +-23935, -24080, -24225, -24369, -24512, +-24654, -24795, -24934, -25073, -25211, +-25347, -25482, -25617, -25750, -25882, +-26013, -26143, -26272, -26399, -26526, +-26651, -26775, -26898, -27020, -27141, +-27260, -27379, -27496, -27612, -27727, +-27841, -27953, -28065, -28175, -28284, +-28391, -28498, -28603, -28707, -28810, +-28911, -29012, -29111, -29209, -29305, +-29401, -29495, -29587, -29679, -29769, +-29858, -29946, -30032, -30118, -30201, +-30284, -30365, -30445, -30524, -30601, +-30677, -30752, -30825, -30897, -30968, +-31038, -31106, -31172, -31238, -31302, +-31365, -31426, -31486, -31545, -31602, +-31658, -31713, -31766, -31818, -31869, +-31918, -31966, -32012, -32058, -32101, +-32144, -32185, -32224, -32262, -32299, +-32335, -32369, -32401, -32433, -32463, +-32491, -32518, -32544, -32568, -32591, +-32613, -32633, -32652, -32669, -32685, +-32700, -32713, -32724, -32735, -32744, +-32751, -32757, -32762, -32766, -32767, +32767, 32764, 32755, 32741, 32720, +32694, 32663, 32626, 32583, 32535, +32481, 32421, 32356, 32286, 32209, +32128, 32041, 31948, 31850, 31747, +31638, 31523, 31403, 31278, 31148, +31012, 30871, 30724, 30572, 30415, +30253, 30086, 29913, 29736, 29553, +29365, 29172, 28974, 28771, 28564, +28351, 28134, 27911, 27684, 27452, +27216, 26975, 26729, 26478, 26223, +25964, 25700, 25432, 25159, 24882, +24601, 24315, 24026, 23732, 23434, +23133, 22827, 22517, 22204, 21886, +21565, 21240, 20912, 20580, 20244, +19905, 19563, 19217, 18868, 18516, +18160, 17802, 17440, 17075, 16708, +16338, 15964, 15588, 15210, 14829, +14445, 14059, 13670, 13279, 12886, +12490, 12093, 11693, 11291, 10888, +10482, 10075, 9666, 9255, 8843, +8429, 8014, 7597, 7180, 6760, +6340, 5919, 5496, 5073, 4649, +4224, 3798, 3372, 2945, 2517, +2090, 1661, 1233, 804, 375, +-54, -483, -911, -1340, -1768, +-2197, -2624, -3052, -3479, -3905, +-4330, -4755, -5179, -5602, -6024, +-6445, -6865, -7284, -7702, -8118, +-8533, -8946, -9358, -9768, -10177, +-10584, -10989, -11392, -11793, -12192, +-12589, -12984, -13377, -13767, -14155, +-14541, -14924, -15305, -15683, -16058, +-16430, -16800, -17167, -17531, -17892, +-18249, -18604, -18956, -19304, -19649, +-19990, -20329, -20663, -20994, -21322, +-21646, -21966, -22282, -22595, -22904, +-23208, -23509, -23806, -24099, -24387, +-24672, -24952, -25228, -25499, -25766, +-26029, -26288, -26541, -26791, -27035, +-27275, -27511, -27741, -27967, -28188, +-28405, -28616, -28823, -29024, -29221, +-29412, -29599, -29780, -29957, -30128, +-30294, -30455, -30611, -30761, -30906, +-31046, -31181, -31310, -31434, -31552, +-31665, -31773, -31875, -31972, -32063, +-32149, -32229, -32304, -32373, -32437, +-32495, -32547, -32594, -32635, -32671, +-32701, -32726, -32745, -32758, -32766, +32767, 32754, 32717, 32658, 32577, +32473, 32348, 32200, 32029, 31837, +31624, 31388, 31131, 30853, 30553, +30232, 29891, 29530, 29148, 28746, +28324, 27883, 27423, 26944, 26447, +25931, 25398, 24847, 24279, 23695, +23095, 22478, 21846, 21199, 20538, +19863, 19174, 18472, 17757, 17030, +16291, 15541, 14781, 14010, 13230, +12441, 11643, 10837, 10024, 9204, +8377, 7545, 6708, 5866, 5020, +4171, 3319, 2464, 1608, 751, +-107, -965, -1822, -2678, -3532, +-4383, -5232, -6077, -6918, -7754, +-8585, -9409, -10228, -11039, -11843, +-12639, -13426, -14204, -14972, -15730, +-16477, -17213, -17937, -18648, -19347, +-20033, -20705, -21363, -22006, -22634, +-23246, -23843, -24423, -24986, -25533, +-26062, -26573, -27066, -27540, -27995, +-28431, -28848, -29245, -29622, -29979, +-30315, -30630, -30924, -31197, -31449, +-31679, -31887, -32074, -32239, -32381, +-32501, -32600, -32675, -32729, -32759, +}; #endif static const CELTMode mode48000_960_120 = { diff --git a/drivers/opus/celt/static_modes_fixed_arm_ne10.h b/drivers/opus/celt/static_modes_fixed_arm_ne10.h new file mode 100644 index 0000000000..b8ef0cee98 --- /dev/null +++ b/drivers/opus/celt/static_modes_fixed_arm_ne10.h @@ -0,0 +1,388 @@ +/* The contents of this file was automatically generated by + * dump_mode_arm_ne10.c with arguments: 48000 960 + * It contains static definitions for some pre-defined modes. */ +#include <NE10_init.h> + +#ifndef NE10_FFT_PARAMS48000_960 +#define NE10_FFT_PARAMS48000_960 +static const ne10_int32_t ne10_factors_480[64] = { +4, 40, 4, 30, 2, 15, 5, 3, 3, 1, 1, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, }; +static const ne10_int32_t ne10_factors_240[64] = { +3, 20, 4, 15, 5, 3, 3, 1, 1, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, }; +static const ne10_int32_t ne10_factors_120[64] = { +3, 10, 2, 15, 5, 3, 3, 1, 1, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, }; +static const ne10_int32_t ne10_factors_60[64] = { +2, 5, 5, 3, 3, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, }; +static const ne10_fft_cpx_int32_t ne10_twiddles_480[480] = { +{0,0}, {2147483647,0}, {2147483647,0}, +{2147483647,0}, {1961823921,-873460313}, {1436946998,-1595891394}, +{2147483647,0}, {1436946998,-1595891394}, {-224473265,-2135719496}, +{2147483647,0}, {663608871,-2042378339}, {-1737350854,-1262259096}, +{2147483647,0}, {-224473265,-2135719496}, {-2100555935,446487152}, +{2147483647,0}, {2100555974,-446486968}, {1961823921,-873460313}, +{1737350743,-1262259248}, {1436946998,-1595891394}, {1073741769,-1859775424}, +{663608871,-2042378339}, {224473078,-2135719516}, {-224473265,-2135719496}, +{-663609049,-2042378281}, {-1073741932,-1859775330}, {-1436947137,-1595891268}, +{-1737350854,-1262259096}, {-1961823997,-873460141}, {-2100556013,-446486785}, +{2147483647,0}, {2144540595,-112390613}, {2135719506,-224473172}, +{2121044558,-335940465}, {2100555974,-446486968}, {2074309912,-555809682}, +{2042378310,-663608960}, {2004848691,-769589332}, {1961823921,-873460313}, +{1913421927,-974937199}, {1859775377,-1073741851}, {1801031311,-1169603450}, +{1737350743,-1262259248}, {1668908218,-1351455280}, {1595891331,-1436947067}, +{1518500216,-1518500282}, {1436946998,-1595891394}, {1351455207,-1668908277}, +{1262259172,-1737350799}, {1169603371,-1801031362}, {1073741769,-1859775424}, +{974937230,-1913421912}, {873460227,-1961823959}, {769589125,-2004848771}, +{663608871,-2042378339}, {555809715,-2074309903}, {446486876,-2100555994}, +{335940246,-2121044593}, {224473078,-2135719516}, {112390647,-2144540593}, +{2147483647,0}, {2135719506,-224473172}, {2100555974,-446486968}, +{2042378310,-663608960}, {1961823921,-873460313}, {1859775377,-1073741851}, +{1737350743,-1262259248}, {1595891331,-1436947067}, {1436946998,-1595891394}, +{1262259172,-1737350799}, {1073741769,-1859775424}, {873460227,-1961823959}, +{663608871,-2042378339}, {446486876,-2100555994}, {224473078,-2135719516}, +{-94,-2147483647}, {-224473265,-2135719496}, {-446487060,-2100555955}, +{-663609049,-2042378281}, {-873460398,-1961823883}, {-1073741932,-1859775330}, +{-1262259116,-1737350839}, {-1436947137,-1595891268}, {-1595891628,-1436946738}, +{-1737350854,-1262259096}, {-1859775343,-1073741910}, {-1961823997,-873460141}, +{-2042378447,-663608538}, {-2100556013,-446486785}, {-2135719499,-224473240}, +{2147483647,0}, {2121044558,-335940465}, {2042378310,-663608960}, +{1913421927,-974937199}, {1737350743,-1262259248}, {1518500216,-1518500282}, +{1262259172,-1737350799}, {974937230,-1913421912}, {663608871,-2042378339}, +{335940246,-2121044593}, {-94,-2147483647}, {-335940431,-2121044564}, +{-663609049,-2042378281}, {-974937397,-1913421827}, {-1262259116,-1737350839}, +{-1518500258,-1518500240}, {-1737350854,-1262259096}, {-1913422071,-974936918}, +{-2042378447,-663608538}, {-2121044568,-335940406}, {-2147483647,188}, +{-2121044509,335940777}, {-2042378331,663608895}, {-1913421900,974937252}, +{-1737350633,1262259400}, {-1518499993,1518500506}, {-1262258813,1737351059}, +{-974936606,1913422229}, {-663609179,2042378239}, {-335940566,2121044542}, +{2147483647,0}, {2147299667,-28109693}, {2146747758,-56214570}, +{2145828015,-84309815}, {2144540595,-112390613}, {2142885719,-140452154}, +{2140863671,-168489630}, {2138474797,-196498235}, {2135719506,-224473172}, +{2132598271,-252409646}, {2129111626,-280302871}, {2125260168,-308148068}, +{2121044558,-335940465}, {2116465518,-363675300}, {2111523833,-391347822}, +{2106220349,-418953288}, {2100555974,-446486968}, {2094531681,-473944146}, +{2088148500,-501320115}, {2081407525,-528610186}, {2074309912,-555809682}, +{2066856885,-582913912}, {2059049696,-609918325}, {2050889698,-636818231}, +{2042378310,-663608960}, {2033516972,-690285983}, {2024307180,-716844791}, +{2014750533,-743280770}, {2004848691,-769589332}, {1994603329,-795766029}, +{1984016179,-821806435}, {1973089077,-847706028}, {1961823921,-873460313}, +{1950222618,-899064934}, {1938287127,-924515564}, {1926019520,-949807783}, +{1913421927,-974937199}, {1900496481,-999899565}, {1887245364,-1024690661}, +{1873670877,-1049306180}, {1859775377,-1073741851}, {1845561215,-1097993541}, +{1831030826,-1122057097}, {1816186632,-1145928502}, {1801031311,-1169603450}, +{1785567394,-1193077993}, {1769797456,-1216348214}, {1753724345,-1239409914}, +{1737350743,-1262259248}, {1720679456,-1284892300}, {1703713340,-1307305194}, +{1686455222,-1329494189}, {1668908218,-1351455280}, {1651075255,-1373184807}, +{1632959307,-1394679144}, {1614563642,-1415934412}, {1595891331,-1436947067}, +{1576945572,-1457713510}, {1557729613,-1478230181}, {1538246655,-1498493658}, +{1518500216,-1518500282}, {1498493590,-1538246721}, {1478230113,-1557729677}, +{1457713441,-1576945636}, {1436946998,-1595891394}, {1415934341,-1614563704}, +{1394679073,-1632959368}, {1373184735,-1651075315}, {1351455207,-1668908277}, +{1329494115,-1686455280}, {1307305120,-1703713397}, {1284892225,-1720679512}, +{1262259172,-1737350799}, {1239409837,-1753724400}, {1216348136,-1769797510}, +{1193077915,-1785567446}, {1169603371,-1801031362}, {1145928423,-1816186682}, +{1122057017,-1831030875}, {1097993571,-1845561197}, {1073741769,-1859775424}, +{1049305987,-1873670985}, {1024690635,-1887245378}, {999899482,-1900496524}, +{974937230,-1913421912}, {949807699,-1926019561}, {924515422,-1938287195}, +{899064965,-1950222603}, {873460227,-1961823959}, {847705824,-1973089164}, +{821806407,-1984016190}, {795765941,-1994603364}, {769589125,-2004848771}, +{743280682,-2014750566}, {716844642,-2024307233}, {690286016,-2033516961}, +{663608871,-2042378339}, {636818019,-2050889764}, {609918296,-2059049705}, +{582913822,-2066856911}, {555809715,-2074309903}, {528610126,-2081407540}, +{501319962,-2088148536}, {473944148,-2094531680}, {446486876,-2100555994}, +{418953102,-2106220386}, {391347792,-2111523838}, {363675176,-2116465540}, +{335940246,-2121044593}, {308148006,-2125260177}, {280302715,-2129111646}, +{252409648,-2132598271}, {224473078,-2135719516}, {196498046,-2138474814}, +{168489600,-2140863674}, {140452029,-2142885728}, {112390647,-2144540593}, +{84309753,-2145828017}, {56214412,-2146747762}, {28109695,-2147299667}, +{2147483647,0}, {2146747758,-56214570}, {2144540595,-112390613}, +{2140863671,-168489630}, {2135719506,-224473172}, {2129111626,-280302871}, +{2121044558,-335940465}, {2111523833,-391347822}, {2100555974,-446486968}, +{2088148500,-501320115}, {2074309912,-555809682}, {2059049696,-609918325}, +{2042378310,-663608960}, {2024307180,-716844791}, {2004848691,-769589332}, +{1984016179,-821806435}, {1961823921,-873460313}, {1938287127,-924515564}, +{1913421927,-974937199}, {1887245364,-1024690661}, {1859775377,-1073741851}, +{1831030826,-1122057097}, {1801031311,-1169603450}, {1769797456,-1216348214}, +{1737350743,-1262259248}, {1703713340,-1307305194}, {1668908218,-1351455280}, +{1632959307,-1394679144}, {1595891331,-1436947067}, {1557729613,-1478230181}, +{1518500216,-1518500282}, {1478230113,-1557729677}, {1436946998,-1595891394}, +{1394679073,-1632959368}, {1351455207,-1668908277}, {1307305120,-1703713397}, +{1262259172,-1737350799}, {1216348136,-1769797510}, {1169603371,-1801031362}, +{1122057017,-1831030875}, {1073741769,-1859775424}, {1024690635,-1887245378}, +{974937230,-1913421912}, {924515422,-1938287195}, {873460227,-1961823959}, +{821806407,-1984016190}, {769589125,-2004848771}, {716844642,-2024307233}, +{663608871,-2042378339}, {609918296,-2059049705}, {555809715,-2074309903}, +{501319962,-2088148536}, {446486876,-2100555994}, {391347792,-2111523838}, +{335940246,-2121044593}, {280302715,-2129111646}, {224473078,-2135719516}, +{168489600,-2140863674}, {112390647,-2144540593}, {56214412,-2146747762}, +{-94,-2147483647}, {-56214600,-2146747757}, {-112390835,-2144540584}, +{-168489787,-2140863659}, {-224473265,-2135719496}, {-280302901,-2129111622}, +{-335940431,-2121044564}, {-391347977,-2111523804}, {-446487060,-2100555955}, +{-501320144,-2088148493}, {-555809896,-2074309855}, {-609918476,-2059049651}, +{-663609049,-2042378281}, {-716844819,-2024307170}, {-769589300,-2004848703}, +{-821806581,-1984016118}, {-873460398,-1961823883}, {-924515591,-1938287114}, +{-974937397,-1913421827}, {-1024690575,-1887245411}, {-1073741932,-1859775330}, +{-1122057395,-1831030643}, {-1169603421,-1801031330}, {-1216348291,-1769797403}, +{-1262259116,-1737350839}, {-1307305268,-1703713283}, {-1351455453,-1668908078}, +{-1394679021,-1632959413}, {-1436947137,-1595891268}, {-1478230435,-1557729372}, +{-1518500258,-1518500240}, {-1557729742,-1478230045}, {-1595891628,-1436946738}, +{-1632959429,-1394679001}, {-1668908417,-1351455035}, {-1703713298,-1307305248}, +{-1737350854,-1262259096}, {-1769797708,-1216347848}, {-1801031344,-1169603400}, +{-1831030924,-1122056937}, {-1859775343,-1073741910}, {-1887245423,-1024690552}, +{-1913422071,-974936918}, {-1938287125,-924515568}, {-1961823997,-873460141}, +{-1984016324,-821806084}, {-2004848713,-769589276}, {-2024307264,-716844553}, +{-2042378447,-663608538}, {-2059049731,-609918206}, {-2074309994,-555809377}, +{-2088148499,-501320119}, {-2100556013,-446486785}, {-2111523902,-391347448}, +{-2121044568,-335940406}, {-2129111659,-280302621}, {-2135719499,-224473240}, +{-2140863681,-168489506}, {-2144540612,-112390298}, {-2146747758,-56214574}, +{2147483647,0}, {2145828015,-84309815}, {2140863671,-168489630}, +{2132598271,-252409646}, {2121044558,-335940465}, {2106220349,-418953288}, +{2088148500,-501320115}, {2066856885,-582913912}, {2042378310,-663608960}, +{2014750533,-743280770}, {1984016179,-821806435}, {1950222618,-899064934}, +{1913421927,-974937199}, {1873670877,-1049306180}, {1831030826,-1122057097}, +{1785567394,-1193077993}, {1737350743,-1262259248}, {1686455222,-1329494189}, +{1632959307,-1394679144}, {1576945572,-1457713510}, {1518500216,-1518500282}, +{1457713441,-1576945636}, {1394679073,-1632959368}, {1329494115,-1686455280}, +{1262259172,-1737350799}, {1193077915,-1785567446}, {1122057017,-1831030875}, +{1049305987,-1873670985}, {974937230,-1913421912}, {899064965,-1950222603}, +{821806407,-1984016190}, {743280682,-2014750566}, {663608871,-2042378339}, +{582913822,-2066856911}, {501319962,-2088148536}, {418953102,-2106220386}, +{335940246,-2121044593}, {252409648,-2132598271}, {168489600,-2140863674}, +{84309753,-2145828017}, {-94,-2147483647}, {-84309940,-2145828010}, +{-168489787,-2140863659}, {-252409834,-2132598249}, {-335940431,-2121044564}, +{-418953286,-2106220349}, {-501320144,-2088148493}, {-582914003,-2066856860}, +{-663609049,-2042378281}, {-743280858,-2014750501}, {-821806581,-1984016118}, +{-899065136,-1950222525}, {-974937397,-1913421827}, {-1049306374,-1873670768}, +{-1122057395,-1831030643}, {-1193078284,-1785567199}, {-1262259116,-1737350839}, +{-1329494061,-1686455323}, {-1394679021,-1632959413}, {-1457713485,-1576945595}, +{-1518500258,-1518500240}, {-1576945613,-1457713466}, {-1632959429,-1394679001}, +{-1686455338,-1329494041}, {-1737350854,-1262259096}, {-1785567498,-1193077837}, +{-1831030924,-1122056937}, {-1873671031,-1049305905}, {-1913422071,-974936918}, +{-1950222750,-899064648}, {-1984016324,-821806084}, {-2014750687,-743280354}, +{-2042378447,-663608538}, {-2066856867,-582913978}, {-2088148499,-501320119}, +{-2106220354,-418953261}, {-2121044568,-335940406}, {-2132598282,-252409555}, +{-2140863681,-168489506}, {-2145828021,-84309659}, {-2147483647,188}, +{-2145828006,84310034}, {-2140863651,168489881}, {-2132598237,252409928}, +{-2121044509,335940777}, {-2106220281,418953629}, {-2088148411,501320484}, +{-2066856765,582914339}, {-2042378331,663608895}, {-2014750557,743280706}, +{-1984016181,821806431}, {-1950222593,899064989}, {-1913421900,974937252}, +{-1873670848,1049306232}, {-1831030728,1122057257}, {-1785567289,1193078149}, +{-1737350633,1262259400}, {-1686455106,1329494336}, {-1632959185,1394679287}, +{-1576945358,1457713742}, {-1518499993,1518500506}, {-1457713209,1576945850}, +{-1394678735,1632959656}, {-1329493766,1686455555}, {-1262258813,1737351059}, +{-1193077546,1785567692}, {-1122056638,1831031107}, {-1049305599,1873671202}, +{-974936606,1913422229}, {-899064330,1950222896}, {-821805761,1984016458}, +{-743280025,2014750808}, {-663609179,2042378239}, {-582914134,2066856823}, +{-501320277,2088148461}, {-418953420,2106220322}, {-335940566,2121044542}, +{-252409716,2132598263}, {-168489668,2140863668}, {-84309821,2145828015}, +}; +static const ne10_fft_cpx_int32_t ne10_twiddles_240[240] = { +{0,0}, {2147483647,0}, {2147483647,0}, +{2147483647,0}, {1961823921,-873460313}, {1436946998,-1595891394}, +{2147483647,0}, {1436946998,-1595891394}, {-224473265,-2135719496}, +{2147483647,0}, {663608871,-2042378339}, {-1737350854,-1262259096}, +{2147483647,0}, {-224473265,-2135719496}, {-2100555935,446487152}, +{2147483647,0}, {2135719506,-224473172}, {2100555974,-446486968}, +{2042378310,-663608960}, {1961823921,-873460313}, {1859775377,-1073741851}, +{1737350743,-1262259248}, {1595891331,-1436947067}, {1436946998,-1595891394}, +{1262259172,-1737350799}, {1073741769,-1859775424}, {873460227,-1961823959}, +{663608871,-2042378339}, {446486876,-2100555994}, {224473078,-2135719516}, +{2147483647,0}, {2100555974,-446486968}, {1961823921,-873460313}, +{1737350743,-1262259248}, {1436946998,-1595891394}, {1073741769,-1859775424}, +{663608871,-2042378339}, {224473078,-2135719516}, {-224473265,-2135719496}, +{-663609049,-2042378281}, {-1073741932,-1859775330}, {-1436947137,-1595891268}, +{-1737350854,-1262259096}, {-1961823997,-873460141}, {-2100556013,-446486785}, +{2147483647,0}, {2042378310,-663608960}, {1737350743,-1262259248}, +{1262259172,-1737350799}, {663608871,-2042378339}, {-94,-2147483647}, +{-663609049,-2042378281}, {-1262259116,-1737350839}, {-1737350854,-1262259096}, +{-2042378447,-663608538}, {-2147483647,188}, {-2042378331,663608895}, +{-1737350633,1262259400}, {-1262258813,1737351059}, {-663609179,2042378239}, +{2147483647,0}, {2146747758,-56214570}, {2144540595,-112390613}, +{2140863671,-168489630}, {2135719506,-224473172}, {2129111626,-280302871}, +{2121044558,-335940465}, {2111523833,-391347822}, {2100555974,-446486968}, +{2088148500,-501320115}, {2074309912,-555809682}, {2059049696,-609918325}, +{2042378310,-663608960}, {2024307180,-716844791}, {2004848691,-769589332}, +{1984016179,-821806435}, {1961823921,-873460313}, {1938287127,-924515564}, +{1913421927,-974937199}, {1887245364,-1024690661}, {1859775377,-1073741851}, +{1831030826,-1122057097}, {1801031311,-1169603450}, {1769797456,-1216348214}, +{1737350743,-1262259248}, {1703713340,-1307305194}, {1668908218,-1351455280}, +{1632959307,-1394679144}, {1595891331,-1436947067}, {1557729613,-1478230181}, +{1518500216,-1518500282}, {1478230113,-1557729677}, {1436946998,-1595891394}, +{1394679073,-1632959368}, {1351455207,-1668908277}, {1307305120,-1703713397}, +{1262259172,-1737350799}, {1216348136,-1769797510}, {1169603371,-1801031362}, +{1122057017,-1831030875}, {1073741769,-1859775424}, {1024690635,-1887245378}, +{974937230,-1913421912}, {924515422,-1938287195}, {873460227,-1961823959}, +{821806407,-1984016190}, {769589125,-2004848771}, {716844642,-2024307233}, +{663608871,-2042378339}, {609918296,-2059049705}, {555809715,-2074309903}, +{501319962,-2088148536}, {446486876,-2100555994}, {391347792,-2111523838}, +{335940246,-2121044593}, {280302715,-2129111646}, {224473078,-2135719516}, +{168489600,-2140863674}, {112390647,-2144540593}, {56214412,-2146747762}, +{2147483647,0}, {2144540595,-112390613}, {2135719506,-224473172}, +{2121044558,-335940465}, {2100555974,-446486968}, {2074309912,-555809682}, +{2042378310,-663608960}, {2004848691,-769589332}, {1961823921,-873460313}, +{1913421927,-974937199}, {1859775377,-1073741851}, {1801031311,-1169603450}, +{1737350743,-1262259248}, {1668908218,-1351455280}, {1595891331,-1436947067}, +{1518500216,-1518500282}, {1436946998,-1595891394}, {1351455207,-1668908277}, +{1262259172,-1737350799}, {1169603371,-1801031362}, {1073741769,-1859775424}, +{974937230,-1913421912}, {873460227,-1961823959}, {769589125,-2004848771}, +{663608871,-2042378339}, {555809715,-2074309903}, {446486876,-2100555994}, +{335940246,-2121044593}, {224473078,-2135719516}, {112390647,-2144540593}, +{-94,-2147483647}, {-112390835,-2144540584}, {-224473265,-2135719496}, +{-335940431,-2121044564}, {-446487060,-2100555955}, {-555809896,-2074309855}, +{-663609049,-2042378281}, {-769589300,-2004848703}, {-873460398,-1961823883}, +{-974937397,-1913421827}, {-1073741932,-1859775330}, {-1169603421,-1801031330}, +{-1262259116,-1737350839}, {-1351455453,-1668908078}, {-1436947137,-1595891268}, +{-1518500258,-1518500240}, {-1595891628,-1436946738}, {-1668908417,-1351455035}, +{-1737350854,-1262259096}, {-1801031344,-1169603400}, {-1859775343,-1073741910}, +{-1913422071,-974936918}, {-1961823997,-873460141}, {-2004848713,-769589276}, +{-2042378447,-663608538}, {-2074309994,-555809377}, {-2100556013,-446486785}, +{-2121044568,-335940406}, {-2135719499,-224473240}, {-2144540612,-112390298}, +{2147483647,0}, {2140863671,-168489630}, {2121044558,-335940465}, +{2088148500,-501320115}, {2042378310,-663608960}, {1984016179,-821806435}, +{1913421927,-974937199}, {1831030826,-1122057097}, {1737350743,-1262259248}, +{1632959307,-1394679144}, {1518500216,-1518500282}, {1394679073,-1632959368}, +{1262259172,-1737350799}, {1122057017,-1831030875}, {974937230,-1913421912}, +{821806407,-1984016190}, {663608871,-2042378339}, {501319962,-2088148536}, +{335940246,-2121044593}, {168489600,-2140863674}, {-94,-2147483647}, +{-168489787,-2140863659}, {-335940431,-2121044564}, {-501320144,-2088148493}, +{-663609049,-2042378281}, {-821806581,-1984016118}, {-974937397,-1913421827}, +{-1122057395,-1831030643}, {-1262259116,-1737350839}, {-1394679021,-1632959413}, +{-1518500258,-1518500240}, {-1632959429,-1394679001}, {-1737350854,-1262259096}, +{-1831030924,-1122056937}, {-1913422071,-974936918}, {-1984016324,-821806084}, +{-2042378447,-663608538}, {-2088148499,-501320119}, {-2121044568,-335940406}, +{-2140863681,-168489506}, {-2147483647,188}, {-2140863651,168489881}, +{-2121044509,335940777}, {-2088148411,501320484}, {-2042378331,663608895}, +{-1984016181,821806431}, {-1913421900,974937252}, {-1831030728,1122057257}, +{-1737350633,1262259400}, {-1632959185,1394679287}, {-1518499993,1518500506}, +{-1394678735,1632959656}, {-1262258813,1737351059}, {-1122056638,1831031107}, +{-974936606,1913422229}, {-821805761,1984016458}, {-663609179,2042378239}, +{-501320277,2088148461}, {-335940566,2121044542}, {-168489668,2140863668}, +}; +static const ne10_fft_cpx_int32_t ne10_twiddles_120[120] = { +{0,0}, {2147483647,0}, {2147483647,0}, +{2147483647,0}, {1961823921,-873460313}, {1436946998,-1595891394}, +{2147483647,0}, {1436946998,-1595891394}, {-224473265,-2135719496}, +{2147483647,0}, {663608871,-2042378339}, {-1737350854,-1262259096}, +{2147483647,0}, {-224473265,-2135719496}, {-2100555935,446487152}, +{2147483647,0}, {2100555974,-446486968}, {1961823921,-873460313}, +{1737350743,-1262259248}, {1436946998,-1595891394}, {1073741769,-1859775424}, +{663608871,-2042378339}, {224473078,-2135719516}, {-224473265,-2135719496}, +{-663609049,-2042378281}, {-1073741932,-1859775330}, {-1436947137,-1595891268}, +{-1737350854,-1262259096}, {-1961823997,-873460141}, {-2100556013,-446486785}, +{2147483647,0}, {2144540595,-112390613}, {2135719506,-224473172}, +{2121044558,-335940465}, {2100555974,-446486968}, {2074309912,-555809682}, +{2042378310,-663608960}, {2004848691,-769589332}, {1961823921,-873460313}, +{1913421927,-974937199}, {1859775377,-1073741851}, {1801031311,-1169603450}, +{1737350743,-1262259248}, {1668908218,-1351455280}, {1595891331,-1436947067}, +{1518500216,-1518500282}, {1436946998,-1595891394}, {1351455207,-1668908277}, +{1262259172,-1737350799}, {1169603371,-1801031362}, {1073741769,-1859775424}, +{974937230,-1913421912}, {873460227,-1961823959}, {769589125,-2004848771}, +{663608871,-2042378339}, {555809715,-2074309903}, {446486876,-2100555994}, +{335940246,-2121044593}, {224473078,-2135719516}, {112390647,-2144540593}, +{2147483647,0}, {2135719506,-224473172}, {2100555974,-446486968}, +{2042378310,-663608960}, {1961823921,-873460313}, {1859775377,-1073741851}, +{1737350743,-1262259248}, {1595891331,-1436947067}, {1436946998,-1595891394}, +{1262259172,-1737350799}, {1073741769,-1859775424}, {873460227,-1961823959}, +{663608871,-2042378339}, {446486876,-2100555994}, {224473078,-2135719516}, +{-94,-2147483647}, {-224473265,-2135719496}, {-446487060,-2100555955}, +{-663609049,-2042378281}, {-873460398,-1961823883}, {-1073741932,-1859775330}, +{-1262259116,-1737350839}, {-1436947137,-1595891268}, {-1595891628,-1436946738}, +{-1737350854,-1262259096}, {-1859775343,-1073741910}, {-1961823997,-873460141}, +{-2042378447,-663608538}, {-2100556013,-446486785}, {-2135719499,-224473240}, +{2147483647,0}, {2121044558,-335940465}, {2042378310,-663608960}, +{1913421927,-974937199}, {1737350743,-1262259248}, {1518500216,-1518500282}, +{1262259172,-1737350799}, {974937230,-1913421912}, {663608871,-2042378339}, +{335940246,-2121044593}, {-94,-2147483647}, {-335940431,-2121044564}, +{-663609049,-2042378281}, {-974937397,-1913421827}, {-1262259116,-1737350839}, +{-1518500258,-1518500240}, {-1737350854,-1262259096}, {-1913422071,-974936918}, +{-2042378447,-663608538}, {-2121044568,-335940406}, {-2147483647,188}, +{-2121044509,335940777}, {-2042378331,663608895}, {-1913421900,974937252}, +{-1737350633,1262259400}, {-1518499993,1518500506}, {-1262258813,1737351059}, +{-974936606,1913422229}, {-663609179,2042378239}, {-335940566,2121044542}, +}; +static const ne10_fft_cpx_int32_t ne10_twiddles_60[60] = { +{0,0}, {2147483647,0}, {2147483647,0}, +{2147483647,0}, {1961823921,-873460313}, {1436946998,-1595891394}, +{2147483647,0}, {1436946998,-1595891394}, {-224473265,-2135719496}, +{2147483647,0}, {663608871,-2042378339}, {-1737350854,-1262259096}, +{2147483647,0}, {-224473265,-2135719496}, {-2100555935,446487152}, +{2147483647,0}, {2135719506,-224473172}, {2100555974,-446486968}, +{2042378310,-663608960}, {1961823921,-873460313}, {1859775377,-1073741851}, +{1737350743,-1262259248}, {1595891331,-1436947067}, {1436946998,-1595891394}, +{1262259172,-1737350799}, {1073741769,-1859775424}, {873460227,-1961823959}, +{663608871,-2042378339}, {446486876,-2100555994}, {224473078,-2135719516}, +{2147483647,0}, {2100555974,-446486968}, {1961823921,-873460313}, +{1737350743,-1262259248}, {1436946998,-1595891394}, {1073741769,-1859775424}, +{663608871,-2042378339}, {224473078,-2135719516}, {-224473265,-2135719496}, +{-663609049,-2042378281}, {-1073741932,-1859775330}, {-1436947137,-1595891268}, +{-1737350854,-1262259096}, {-1961823997,-873460141}, {-2100556013,-446486785}, +{2147483647,0}, {2042378310,-663608960}, {1737350743,-1262259248}, +{1262259172,-1737350799}, {663608871,-2042378339}, {-94,-2147483647}, +{-663609049,-2042378281}, {-1262259116,-1737350839}, {-1737350854,-1262259096}, +{-2042378447,-663608538}, {-2147483647,188}, {-2042378331,663608895}, +{-1737350633,1262259400}, {-1262258813,1737351059}, {-663609179,2042378239}, +}; +static const ne10_fft_state_int32_t ne10_fft_state_int32_t_480 = { +120, +(ne10_int32_t *)ne10_factors_480, +(ne10_fft_cpx_int32_t *)ne10_twiddles_480, +NULL, +(ne10_fft_cpx_int32_t *)&ne10_twiddles_480[120], +}; +static const arch_fft_state cfg_arch_480 = { +1, +(void *)&ne10_fft_state_int32_t_480, +}; + +static const ne10_fft_state_int32_t ne10_fft_state_int32_t_240 = { +60, +(ne10_int32_t *)ne10_factors_240, +(ne10_fft_cpx_int32_t *)ne10_twiddles_240, +NULL, +(ne10_fft_cpx_int32_t *)&ne10_twiddles_240[60], +}; +static const arch_fft_state cfg_arch_240 = { +1, +(void *)&ne10_fft_state_int32_t_240, +}; + +static const ne10_fft_state_int32_t ne10_fft_state_int32_t_120 = { +30, +(ne10_int32_t *)ne10_factors_120, +(ne10_fft_cpx_int32_t *)ne10_twiddles_120, +NULL, +(ne10_fft_cpx_int32_t *)&ne10_twiddles_120[30], +}; +static const arch_fft_state cfg_arch_120 = { +1, +(void *)&ne10_fft_state_int32_t_120, +}; + +static const ne10_fft_state_int32_t ne10_fft_state_int32_t_60 = { +15, +(ne10_int32_t *)ne10_factors_60, +(ne10_fft_cpx_int32_t *)ne10_twiddles_60, +NULL, +(ne10_fft_cpx_int32_t *)&ne10_twiddles_60[15], +}; +static const arch_fft_state cfg_arch_60 = { +1, +(void *)&ne10_fft_state_int32_t_60, +}; + +#endif /* end NE10_FFT_PARAMS48000_960 */ diff --git a/drivers/opus/celt/static_modes_float.h b/drivers/opus/celt/static_modes_float.h index 362be6cca8..f7d501a993 100644 --- a/drivers/opus/celt/static_modes_float.h +++ b/drivers/opus/celt/static_modes_float.h @@ -1,9 +1,14 @@ /* The contents of this file was automatically generated by dump_modes.c with arguments: 48000 960 It contains static definitions for some pre-defined modes. */ -#include "opus/celt/opus_modes.h" +#include "opus/celt/modes.h" #include "opus/celt/rate.h" +#ifdef HAVE_ARM_NE10 +#define OVERRIDE_FFT 1 +#include "opus/celt/static_modes_float_arm_ne10.h" +#endif + #ifndef DEF_WINDOW120 #define DEF_WINDOW120 static const opus_val16 window120[120] = { @@ -341,84 +346,84 @@ static const kiss_twiddle_cpx fft_twiddles48000_960[480] = { #ifndef FFT_BITREV480 #define FFT_BITREV480 static const opus_int16 fft_bitrev480[480] = { -0, 120, 240, 360, 30, 150, 270, 390, 60, 180, 300, 420, 90, 210, 330, -450, 15, 135, 255, 375, 45, 165, 285, 405, 75, 195, 315, 435, 105, 225, -345, 465, 5, 125, 245, 365, 35, 155, 275, 395, 65, 185, 305, 425, 95, -215, 335, 455, 20, 140, 260, 380, 50, 170, 290, 410, 80, 200, 320, 440, -110, 230, 350, 470, 10, 130, 250, 370, 40, 160, 280, 400, 70, 190, 310, -430, 100, 220, 340, 460, 25, 145, 265, 385, 55, 175, 295, 415, 85, 205, -325, 445, 115, 235, 355, 475, 1, 121, 241, 361, 31, 151, 271, 391, 61, -181, 301, 421, 91, 211, 331, 451, 16, 136, 256, 376, 46, 166, 286, 406, -76, 196, 316, 436, 106, 226, 346, 466, 6, 126, 246, 366, 36, 156, 276, -396, 66, 186, 306, 426, 96, 216, 336, 456, 21, 141, 261, 381, 51, 171, -291, 411, 81, 201, 321, 441, 111, 231, 351, 471, 11, 131, 251, 371, 41, -161, 281, 401, 71, 191, 311, 431, 101, 221, 341, 461, 26, 146, 266, 386, -56, 176, 296, 416, 86, 206, 326, 446, 116, 236, 356, 476, 2, 122, 242, -362, 32, 152, 272, 392, 62, 182, 302, 422, 92, 212, 332, 452, 17, 137, -257, 377, 47, 167, 287, 407, 77, 197, 317, 437, 107, 227, 347, 467, 7, -127, 247, 367, 37, 157, 277, 397, 67, 187, 307, 427, 97, 217, 337, 457, -22, 142, 262, 382, 52, 172, 292, 412, 82, 202, 322, 442, 112, 232, 352, -472, 12, 132, 252, 372, 42, 162, 282, 402, 72, 192, 312, 432, 102, 222, -342, 462, 27, 147, 267, 387, 57, 177, 297, 417, 87, 207, 327, 447, 117, -237, 357, 477, 3, 123, 243, 363, 33, 153, 273, 393, 63, 183, 303, 423, -93, 213, 333, 453, 18, 138, 258, 378, 48, 168, 288, 408, 78, 198, 318, -438, 108, 228, 348, 468, 8, 128, 248, 368, 38, 158, 278, 398, 68, 188, -308, 428, 98, 218, 338, 458, 23, 143, 263, 383, 53, 173, 293, 413, 83, -203, 323, 443, 113, 233, 353, 473, 13, 133, 253, 373, 43, 163, 283, 403, -73, 193, 313, 433, 103, 223, 343, 463, 28, 148, 268, 388, 58, 178, 298, -418, 88, 208, 328, 448, 118, 238, 358, 478, 4, 124, 244, 364, 34, 154, -274, 394, 64, 184, 304, 424, 94, 214, 334, 454, 19, 139, 259, 379, 49, -169, 289, 409, 79, 199, 319, 439, 109, 229, 349, 469, 9, 129, 249, 369, -39, 159, 279, 399, 69, 189, 309, 429, 99, 219, 339, 459, 24, 144, 264, -384, 54, 174, 294, 414, 84, 204, 324, 444, 114, 234, 354, 474, 14, 134, -254, 374, 44, 164, 284, 404, 74, 194, 314, 434, 104, 224, 344, 464, 29, -149, 269, 389, 59, 179, 299, 419, 89, 209, 329, 449, 119, 239, 359, 479, +0, 96, 192, 288, 384, 32, 128, 224, 320, 416, 64, 160, 256, 352, 448, +8, 104, 200, 296, 392, 40, 136, 232, 328, 424, 72, 168, 264, 360, 456, +16, 112, 208, 304, 400, 48, 144, 240, 336, 432, 80, 176, 272, 368, 464, +24, 120, 216, 312, 408, 56, 152, 248, 344, 440, 88, 184, 280, 376, 472, +4, 100, 196, 292, 388, 36, 132, 228, 324, 420, 68, 164, 260, 356, 452, +12, 108, 204, 300, 396, 44, 140, 236, 332, 428, 76, 172, 268, 364, 460, +20, 116, 212, 308, 404, 52, 148, 244, 340, 436, 84, 180, 276, 372, 468, +28, 124, 220, 316, 412, 60, 156, 252, 348, 444, 92, 188, 284, 380, 476, +1, 97, 193, 289, 385, 33, 129, 225, 321, 417, 65, 161, 257, 353, 449, +9, 105, 201, 297, 393, 41, 137, 233, 329, 425, 73, 169, 265, 361, 457, +17, 113, 209, 305, 401, 49, 145, 241, 337, 433, 81, 177, 273, 369, 465, +25, 121, 217, 313, 409, 57, 153, 249, 345, 441, 89, 185, 281, 377, 473, +5, 101, 197, 293, 389, 37, 133, 229, 325, 421, 69, 165, 261, 357, 453, +13, 109, 205, 301, 397, 45, 141, 237, 333, 429, 77, 173, 269, 365, 461, +21, 117, 213, 309, 405, 53, 149, 245, 341, 437, 85, 181, 277, 373, 469, +29, 125, 221, 317, 413, 61, 157, 253, 349, 445, 93, 189, 285, 381, 477, +2, 98, 194, 290, 386, 34, 130, 226, 322, 418, 66, 162, 258, 354, 450, +10, 106, 202, 298, 394, 42, 138, 234, 330, 426, 74, 170, 266, 362, 458, +18, 114, 210, 306, 402, 50, 146, 242, 338, 434, 82, 178, 274, 370, 466, +26, 122, 218, 314, 410, 58, 154, 250, 346, 442, 90, 186, 282, 378, 474, +6, 102, 198, 294, 390, 38, 134, 230, 326, 422, 70, 166, 262, 358, 454, +14, 110, 206, 302, 398, 46, 142, 238, 334, 430, 78, 174, 270, 366, 462, +22, 118, 214, 310, 406, 54, 150, 246, 342, 438, 86, 182, 278, 374, 470, +30, 126, 222, 318, 414, 62, 158, 254, 350, 446, 94, 190, 286, 382, 478, +3, 99, 195, 291, 387, 35, 131, 227, 323, 419, 67, 163, 259, 355, 451, +11, 107, 203, 299, 395, 43, 139, 235, 331, 427, 75, 171, 267, 363, 459, +19, 115, 211, 307, 403, 51, 147, 243, 339, 435, 83, 179, 275, 371, 467, +27, 123, 219, 315, 411, 59, 155, 251, 347, 443, 91, 187, 283, 379, 475, +7, 103, 199, 295, 391, 39, 135, 231, 327, 423, 71, 167, 263, 359, 455, +15, 111, 207, 303, 399, 47, 143, 239, 335, 431, 79, 175, 271, 367, 463, +23, 119, 215, 311, 407, 55, 151, 247, 343, 439, 87, 183, 279, 375, 471, +31, 127, 223, 319, 415, 63, 159, 255, 351, 447, 95, 191, 287, 383, 479, }; #endif #ifndef FFT_BITREV240 #define FFT_BITREV240 static const opus_int16 fft_bitrev240[240] = { -0, 60, 120, 180, 15, 75, 135, 195, 30, 90, 150, 210, 45, 105, 165, -225, 5, 65, 125, 185, 20, 80, 140, 200, 35, 95, 155, 215, 50, 110, -170, 230, 10, 70, 130, 190, 25, 85, 145, 205, 40, 100, 160, 220, 55, -115, 175, 235, 1, 61, 121, 181, 16, 76, 136, 196, 31, 91, 151, 211, -46, 106, 166, 226, 6, 66, 126, 186, 21, 81, 141, 201, 36, 96, 156, -216, 51, 111, 171, 231, 11, 71, 131, 191, 26, 86, 146, 206, 41, 101, -161, 221, 56, 116, 176, 236, 2, 62, 122, 182, 17, 77, 137, 197, 32, -92, 152, 212, 47, 107, 167, 227, 7, 67, 127, 187, 22, 82, 142, 202, -37, 97, 157, 217, 52, 112, 172, 232, 12, 72, 132, 192, 27, 87, 147, -207, 42, 102, 162, 222, 57, 117, 177, 237, 3, 63, 123, 183, 18, 78, -138, 198, 33, 93, 153, 213, 48, 108, 168, 228, 8, 68, 128, 188, 23, -83, 143, 203, 38, 98, 158, 218, 53, 113, 173, 233, 13, 73, 133, 193, -28, 88, 148, 208, 43, 103, 163, 223, 58, 118, 178, 238, 4, 64, 124, -184, 19, 79, 139, 199, 34, 94, 154, 214, 49, 109, 169, 229, 9, 69, -129, 189, 24, 84, 144, 204, 39, 99, 159, 219, 54, 114, 174, 234, 14, -74, 134, 194, 29, 89, 149, 209, 44, 104, 164, 224, 59, 119, 179, 239, +0, 48, 96, 144, 192, 16, 64, 112, 160, 208, 32, 80, 128, 176, 224, +4, 52, 100, 148, 196, 20, 68, 116, 164, 212, 36, 84, 132, 180, 228, +8, 56, 104, 152, 200, 24, 72, 120, 168, 216, 40, 88, 136, 184, 232, +12, 60, 108, 156, 204, 28, 76, 124, 172, 220, 44, 92, 140, 188, 236, +1, 49, 97, 145, 193, 17, 65, 113, 161, 209, 33, 81, 129, 177, 225, +5, 53, 101, 149, 197, 21, 69, 117, 165, 213, 37, 85, 133, 181, 229, +9, 57, 105, 153, 201, 25, 73, 121, 169, 217, 41, 89, 137, 185, 233, +13, 61, 109, 157, 205, 29, 77, 125, 173, 221, 45, 93, 141, 189, 237, +2, 50, 98, 146, 194, 18, 66, 114, 162, 210, 34, 82, 130, 178, 226, +6, 54, 102, 150, 198, 22, 70, 118, 166, 214, 38, 86, 134, 182, 230, +10, 58, 106, 154, 202, 26, 74, 122, 170, 218, 42, 90, 138, 186, 234, +14, 62, 110, 158, 206, 30, 78, 126, 174, 222, 46, 94, 142, 190, 238, +3, 51, 99, 147, 195, 19, 67, 115, 163, 211, 35, 83, 131, 179, 227, +7, 55, 103, 151, 199, 23, 71, 119, 167, 215, 39, 87, 135, 183, 231, +11, 59, 107, 155, 203, 27, 75, 123, 171, 219, 43, 91, 139, 187, 235, +15, 63, 111, 159, 207, 31, 79, 127, 175, 223, 47, 95, 143, 191, 239, }; #endif #ifndef FFT_BITREV120 #define FFT_BITREV120 static const opus_int16 fft_bitrev120[120] = { -0, 30, 60, 90, 15, 45, 75, 105, 5, 35, 65, 95, 20, 50, 80, -110, 10, 40, 70, 100, 25, 55, 85, 115, 1, 31, 61, 91, 16, 46, -76, 106, 6, 36, 66, 96, 21, 51, 81, 111, 11, 41, 71, 101, 26, -56, 86, 116, 2, 32, 62, 92, 17, 47, 77, 107, 7, 37, 67, 97, -22, 52, 82, 112, 12, 42, 72, 102, 27, 57, 87, 117, 3, 33, 63, -93, 18, 48, 78, 108, 8, 38, 68, 98, 23, 53, 83, 113, 13, 43, -73, 103, 28, 58, 88, 118, 4, 34, 64, 94, 19, 49, 79, 109, 9, -39, 69, 99, 24, 54, 84, 114, 14, 44, 74, 104, 29, 59, 89, 119, +0, 24, 48, 72, 96, 8, 32, 56, 80, 104, 16, 40, 64, 88, 112, +4, 28, 52, 76, 100, 12, 36, 60, 84, 108, 20, 44, 68, 92, 116, +1, 25, 49, 73, 97, 9, 33, 57, 81, 105, 17, 41, 65, 89, 113, +5, 29, 53, 77, 101, 13, 37, 61, 85, 109, 21, 45, 69, 93, 117, +2, 26, 50, 74, 98, 10, 34, 58, 82, 106, 18, 42, 66, 90, 114, +6, 30, 54, 78, 102, 14, 38, 62, 86, 110, 22, 46, 70, 94, 118, +3, 27, 51, 75, 99, 11, 35, 59, 83, 107, 19, 43, 67, 91, 115, +7, 31, 55, 79, 103, 15, 39, 63, 87, 111, 23, 47, 71, 95, 119, }; #endif #ifndef FFT_BITREV60 #define FFT_BITREV60 static const opus_int16 fft_bitrev60[60] = { -0, 15, 30, 45, 5, 20, 35, 50, 10, 25, 40, 55, 1, 16, 31, -46, 6, 21, 36, 51, 11, 26, 41, 56, 2, 17, 32, 47, 7, 22, -37, 52, 12, 27, 42, 57, 3, 18, 33, 48, 8, 23, 38, 53, 13, -28, 43, 58, 4, 19, 34, 49, 9, 24, 39, 54, 14, 29, 44, 59, +0, 12, 24, 36, 48, 4, 16, 28, 40, 52, 8, 20, 32, 44, 56, +1, 13, 25, 37, 49, 5, 17, 29, 41, 53, 9, 21, 33, 45, 57, +2, 14, 26, 38, 50, 6, 18, 30, 42, 54, 10, 22, 34, 46, 58, +3, 15, 27, 39, 51, 7, 19, 31, 43, 55, 11, 23, 35, 47, 59, }; #endif @@ -428,9 +433,14 @@ static const kiss_fft_state fft_state48000_960_0 = { 480, /* nfft */ 0.002083333f, /* scale */ -1, /* shift */ -{4, 120, 4, 30, 2, 15, 3, 5, 5, 1, 0, 0, 0, 0, 0, 0, }, /* factors */ +{5, 96, 3, 32, 4, 8, 2, 4, 4, 1, 0, 0, 0, 0, 0, 0, }, /* factors */ fft_bitrev480, /* bitrev */ fft_twiddles48000_960, /* bitrev */ +#ifdef OVERRIDE_FFT +(arch_fft_state *)&cfg_arch_480, +#else +NULL, +#endif }; #endif @@ -440,9 +450,14 @@ static const kiss_fft_state fft_state48000_960_1 = { 240, /* nfft */ 0.004166667f, /* scale */ 1, /* shift */ -{4, 60, 4, 15, 3, 5, 5, 1, 0, 0, 0, 0, 0, 0, 0, 0, }, /* factors */ +{5, 48, 3, 16, 4, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, }, /* factors */ fft_bitrev240, /* bitrev */ fft_twiddles48000_960, /* bitrev */ +#ifdef OVERRIDE_FFT +(arch_fft_state *)&cfg_arch_240, +#else +NULL, +#endif }; #endif @@ -452,9 +467,14 @@ static const kiss_fft_state fft_state48000_960_2 = { 120, /* nfft */ 0.008333333f, /* scale */ 2, /* shift */ -{4, 30, 2, 15, 3, 5, 5, 1, 0, 0, 0, 0, 0, 0, 0, 0, }, /* factors */ +{5, 24, 3, 8, 2, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, }, /* factors */ fft_bitrev120, /* bitrev */ fft_twiddles48000_960, /* bitrev */ +#ifdef OVERRIDE_FFT +(arch_fft_state *)&cfg_arch_120, +#else +NULL, +#endif }; #endif @@ -464,9 +484,14 @@ static const kiss_fft_state fft_state48000_960_3 = { 60, /* nfft */ 0.016666667f, /* scale */ 3, /* shift */ -{4, 15, 3, 5, 5, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* factors */ +{5, 12, 3, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* factors */ fft_bitrev60, /* bitrev */ fft_twiddles48000_960, /* bitrev */ +#ifdef OVERRIDE_FFT +(arch_fft_state *)&cfg_arch_60, +#else +NULL, +#endif }; #endif @@ -474,104 +499,368 @@ fft_twiddles48000_960, /* bitrev */ #ifndef MDCT_TWIDDLES960 #define MDCT_TWIDDLES960 -static const opus_val16 mdct_twiddles960[481] = { -1.0000000f, 0.99999465f, 0.99997858f, 0.99995181f, 0.99991433f, -0.99986614f, 0.99980724f, 0.99973764f, 0.99965732f, 0.99956631f, -0.99946459f, 0.99935216f, 0.99922904f, 0.99909521f, 0.99895068f, -0.99879546f, 0.99862953f, 0.99845292f, 0.99826561f, 0.99806761f, -0.99785892f, 0.99763955f, 0.99740949f, 0.99716875f, 0.99691733f, -0.99665524f, 0.99638247f, 0.99609903f, 0.99580493f, 0.99550016f, -0.99518473f, 0.99485864f, 0.99452190f, 0.99417450f, 0.99381646f, -0.99344778f, 0.99306846f, 0.99267850f, 0.99227791f, 0.99186670f, -0.99144486f, 0.99101241f, 0.99056934f, 0.99011566f, 0.98965139f, -0.98917651f, 0.98869104f, 0.98819498f, 0.98768834f, 0.98717112f, -0.98664333f, 0.98610497f, 0.98555606f, 0.98499659f, 0.98442657f, -0.98384600f, 0.98325491f, 0.98265328f, 0.98204113f, 0.98141846f, -0.98078528f, 0.98014159f, 0.97948742f, 0.97882275f, 0.97814760f, -0.97746197f, 0.97676588f, 0.97605933f, 0.97534232f, 0.97461487f, -0.97387698f, 0.97312866f, 0.97236992f, 0.97160077f, 0.97082121f, -0.97003125f, 0.96923091f, 0.96842019f, 0.96759909f, 0.96676764f, -0.96592582f, 0.96507367f, 0.96421118f, 0.96333837f, 0.96245523f, -0.96156180f, 0.96065806f, 0.95974403f, 0.95881973f, 0.95788517f, -0.95694034f, 0.95598526f, 0.95501995f, 0.95404440f, 0.95305864f, -0.95206267f, 0.95105651f, 0.95004016f, 0.94901364f, 0.94797697f, -0.94693013f, 0.94587315f, 0.94480604f, 0.94372882f, 0.94264149f, -0.94154406f, 0.94043656f, 0.93931897f, 0.93819133f, 0.93705365f, -0.93590592f, 0.93474818f, 0.93358042f, 0.93240268f, 0.93121493f, -0.93001722f, 0.92880955f, 0.92759193f, 0.92636438f, 0.92512690f, -0.92387953f, 0.92262225f, 0.92135509f, 0.92007809f, 0.91879121f, -0.91749449f, 0.91618795f, 0.91487161f, 0.91354545f, 0.91220952f, -0.91086382f, 0.90950836f, 0.90814316f, 0.90676824f, 0.90538363f, -0.90398929f, 0.90258528f, 0.90117161f, 0.89974828f, 0.89831532f, -0.89687273f, 0.89542055f, 0.89395877f, 0.89248742f, 0.89100652f, -0.88951606f, 0.88801610f, 0.88650661f, 0.88498764f, 0.88345918f, -0.88192125f, 0.88037390f, 0.87881711f, 0.87725090f, 0.87567531f, -0.87409035f, 0.87249599f, 0.87089232f, 0.86927933f, 0.86765699f, -0.86602540f, 0.86438453f, 0.86273437f, 0.86107503f, 0.85940641f, -0.85772862f, 0.85604161f, 0.85434547f, 0.85264014f, 0.85092572f, -0.84920218f, 0.84746955f, 0.84572781f, 0.84397704f, 0.84221721f, -0.84044838f, 0.83867056f, 0.83688375f, 0.83508799f, 0.83328325f, -0.83146961f, 0.82964704f, 0.82781562f, 0.82597530f, 0.82412620f, -0.82226820f, 0.82040144f, 0.81852589f, 0.81664154f, 0.81474847f, -0.81284665f, 0.81093620f, 0.80901698f, 0.80708914f, 0.80515262f, -0.80320752f, 0.80125378f, 0.79929149f, 0.79732067f, 0.79534125f, -0.79335335f, 0.79135691f, 0.78935204f, 0.78733867f, 0.78531691f, -0.78328674f, 0.78124818f, 0.77920122f, 0.77714595f, 0.77508232f, -0.77301043f, 0.77093026f, 0.76884183f, 0.76674517f, 0.76464026f, -0.76252720f, 0.76040593f, 0.75827656f, 0.75613907f, 0.75399349f, -0.75183978f, 0.74967807f, 0.74750833f, 0.74533054f, 0.74314481f, -0.74095112f, 0.73874950f, 0.73653993f, 0.73432251f, 0.73209718f, -0.72986405f, 0.72762307f, 0.72537438f, 0.72311787f, 0.72085359f, -0.71858162f, 0.71630192f, 0.71401459f, 0.71171956f, 0.70941701f, -0.70710677f, 0.70478900f, 0.70246363f, 0.70013079f, 0.69779041f, -0.69544260f, 0.69308738f, 0.69072466f, 0.68835458f, 0.68597709f, -0.68359229f, 0.68120013f, 0.67880072f, 0.67639404f, 0.67398011f, -0.67155892f, 0.66913059f, 0.66669509f, 0.66425240f, 0.66180265f, -0.65934581f, 0.65688191f, 0.65441092f, 0.65193298f, 0.64944801f, -0.64695613f, 0.64445727f, 0.64195160f, 0.63943902f, 0.63691954f, -0.63439328f, 0.63186019f, 0.62932037f, 0.62677377f, 0.62422055f, -0.62166055f, 0.61909394f, 0.61652065f, 0.61394081f, 0.61135435f, -0.60876139f, 0.60616195f, 0.60355593f, 0.60094349f, 0.59832457f, -0.59569929f, 0.59306758f, 0.59042957f, 0.58778523f, 0.58513460f, -0.58247766f, 0.57981452f, 0.57714518f, 0.57446961f, 0.57178793f, -0.56910013f, 0.56640624f, 0.56370623f, 0.56100023f, 0.55828818f, -0.55557020f, 0.55284627f, 0.55011641f, 0.54738067f, 0.54463901f, -0.54189157f, 0.53913828f, 0.53637921f, 0.53361450f, 0.53084398f, -0.52806787f, 0.52528601f, 0.52249852f, 0.51970543f, 0.51690688f, -0.51410279f, 0.51129310f, 0.50847793f, 0.50565732f, 0.50283139f, -0.49999997f, 0.49716321f, 0.49432122f, 0.49147383f, 0.48862118f, -0.48576340f, 0.48290042f, 0.48003216f, 0.47715876f, 0.47428025f, -0.47139677f, 0.46850813f, 0.46561448f, 0.46271584f, 0.45981235f, -0.45690383f, 0.45399042f, 0.45107214f, 0.44814915f, 0.44522124f, -0.44228868f, 0.43935137f, 0.43640926f, 0.43346247f, 0.43051104f, -0.42755511f, 0.42459449f, 0.42162932f, 0.41865964f, 0.41568558f, -0.41270697f, 0.40972393f, 0.40673661f, 0.40374494f, 0.40074884f, -0.39774844f, 0.39474390f, 0.39173501f, 0.38872193f, 0.38570469f, -0.38268343f, 0.37965796f, 0.37662842f, 0.37359496f, 0.37055739f, -0.36751585f, 0.36447038f, 0.36142122f, 0.35836797f, 0.35531089f, -0.35225000f, 0.34918544f, 0.34611704f, 0.34304493f, 0.33996926f, -0.33688983f, 0.33380680f, 0.33072019f, 0.32763015f, 0.32453650f, -0.32143936f, 0.31833890f, 0.31523503f, 0.31212767f, 0.30901696f, -0.30590306f, 0.30278577f, 0.29966524f, 0.29654150f, 0.29341470f, -0.29028464f, 0.28715147f, 0.28401522f, 0.28087605f, 0.27773376f, -0.27458861f, 0.27144052f, 0.26828940f, 0.26513541f, 0.26197859f, -0.25881907f, 0.25565666f, 0.25249152f, 0.24932367f, 0.24615327f, -0.24298012f, 0.23980436f, 0.23662604f, 0.23344530f, 0.23026206f, -0.22707623f, 0.22388809f, 0.22069744f, 0.21750443f, 0.21430908f, -0.21111156f, 0.20791165f, 0.20470953f, 0.20150520f, 0.19829884f, -0.19509024f, 0.19187955f, 0.18866692f, 0.18545227f, 0.18223552f, -0.17901681f, 0.17579631f, 0.17257380f, 0.16934945f, 0.16612328f, -0.16289546f, 0.15966577f, 0.15643437f, 0.15320141f, 0.14996669f, -0.14673037f, 0.14349260f, 0.14025329f, 0.13701235f, 0.13376995f, -0.13052612f, 0.12728101f, 0.12403442f, 0.12078650f, 0.11753740f, -0.11428693f, 0.11103523f, 0.10778234f, 0.10452842f, 0.10127326f, -0.098017137f, 0.094759842f, 0.091501652f, 0.088242363f, 0.084982129f, -0.081721103f, 0.078459084f, 0.075196224f, 0.071932560f, 0.068668243f, -0.065403073f, 0.062137201f, 0.058870665f, 0.055603617f, 0.052335974f, -0.049067651f, 0.045798921f, 0.042529582f, 0.039259788f, 0.035989573f, -0.032719092f, 0.029448142f, 0.026176876f, 0.022905329f, 0.019633657f, -0.016361655f, 0.013089478f, 0.0098171604f, 0.0065449764f, 0.0032724839f, --4.3711390e-08f, }; +static const opus_val16 mdct_twiddles960[1800] = { +0.99999994f, 0.99999321f, 0.99997580f, 0.99994773f, 0.99990886f, +0.99985933f, 0.99979913f, 0.99972820f, 0.99964654f, 0.99955416f, +0.99945110f, 0.99933738f, 0.99921292f, 0.99907774f, 0.99893188f, +0.99877530f, 0.99860805f, 0.99843007f, 0.99824142f, 0.99804211f, +0.99783206f, 0.99761140f, 0.99737996f, 0.99713790f, 0.99688518f, +0.99662173f, 0.99634761f, 0.99606287f, 0.99576741f, 0.99546129f, +0.99514455f, 0.99481714f, 0.99447906f, 0.99413031f, 0.99377096f, +0.99340093f, 0.99302030f, 0.99262899f, 0.99222708f, 0.99181455f, +0.99139136f, 0.99095762f, 0.99051321f, 0.99005818f, 0.98959261f, +0.98911643f, 0.98862964f, 0.98813224f, 0.98762429f, 0.98710573f, +0.98657662f, 0.98603696f, 0.98548669f, 0.98492593f, 0.98435456f, +0.98377270f, 0.98318028f, 0.98257732f, 0.98196387f, 0.98133987f, +0.98070538f, 0.98006040f, 0.97940493f, 0.97873890f, 0.97806245f, +0.97737551f, 0.97667813f, 0.97597027f, 0.97525197f, 0.97452319f, +0.97378403f, 0.97303438f, 0.97227436f, 0.97150391f, 0.97072303f, +0.96993178f, 0.96913016f, 0.96831810f, 0.96749574f, 0.96666300f, +0.96581990f, 0.96496642f, 0.96410263f, 0.96322852f, 0.96234411f, +0.96144938f, 0.96054435f, 0.95962906f, 0.95870346f, 0.95776761f, +0.95682150f, 0.95586514f, 0.95489854f, 0.95392174f, 0.95293468f, +0.95193744f, 0.95093000f, 0.94991243f, 0.94888461f, 0.94784665f, +0.94679856f, 0.94574034f, 0.94467193f, 0.94359344f, 0.94250488f, +0.94140619f, 0.94029742f, 0.93917859f, 0.93804967f, 0.93691075f, +0.93576175f, 0.93460274f, 0.93343377f, 0.93225473f, 0.93106574f, +0.92986679f, 0.92865789f, 0.92743903f, 0.92621022f, 0.92497152f, +0.92372292f, 0.92246443f, 0.92119598f, 0.91991776f, 0.91862965f, +0.91733170f, 0.91602397f, 0.91470635f, 0.91337901f, 0.91204184f, +0.91069490f, 0.90933824f, 0.90797186f, 0.90659571f, 0.90520984f, +0.90381432f, 0.90240908f, 0.90099424f, 0.89956969f, 0.89813554f, +0.89669174f, 0.89523834f, 0.89377540f, 0.89230281f, 0.89082074f, +0.88932908f, 0.88782793f, 0.88631725f, 0.88479710f, 0.88326746f, +0.88172835f, 0.88017982f, 0.87862182f, 0.87705445f, 0.87547767f, +0.87389153f, 0.87229604f, 0.87069118f, 0.86907703f, 0.86745358f, +0.86582077f, 0.86417878f, 0.86252749f, 0.86086690f, 0.85919720f, +0.85751826f, 0.85583007f, 0.85413277f, 0.85242635f, 0.85071075f, +0.84898609f, 0.84725231f, 0.84550947f, 0.84375757f, 0.84199661f, +0.84022665f, 0.83844769f, 0.83665979f, 0.83486289f, 0.83305705f, +0.83124226f, 0.82941860f, 0.82758605f, 0.82574469f, 0.82389444f, +0.82203537f, 0.82016748f, 0.81829083f, 0.81640542f, 0.81451124f, +0.81260836f, 0.81069672f, 0.80877650f, 0.80684757f, 0.80490994f, +0.80296379f, 0.80100900f, 0.79904562f, 0.79707366f, 0.79509324f, +0.79310423f, 0.79110676f, 0.78910083f, 0.78708643f, 0.78506362f, +0.78303236f, 0.78099275f, 0.77894479f, 0.77688843f, 0.77482378f, +0.77275085f, 0.77066964f, 0.76858020f, 0.76648247f, 0.76437658f, +0.76226246f, 0.76014024f, 0.75800985f, 0.75587130f, 0.75372469f, +0.75157005f, 0.74940729f, 0.74723655f, 0.74505776f, 0.74287105f, +0.74067634f, 0.73847371f, 0.73626316f, 0.73404479f, 0.73181850f, +0.72958434f, 0.72734243f, 0.72509271f, 0.72283524f, 0.72057003f, +0.71829706f, 0.71601641f, 0.71372813f, 0.71143216f, 0.70912862f, +0.70681745f, 0.70449871f, 0.70217246f, 0.69983864f, 0.69749737f, +0.69514859f, 0.69279242f, 0.69042879f, 0.68805778f, 0.68567938f, +0.68329364f, 0.68090063f, 0.67850029f, 0.67609268f, 0.67367786f, +0.67125577f, 0.66882652f, 0.66639012f, 0.66394657f, 0.66149592f, +0.65903819f, 0.65657341f, 0.65410155f, 0.65162271f, 0.64913690f, +0.64664418f, 0.64414448f, 0.64163786f, 0.63912445f, 0.63660413f, +0.63407701f, 0.63154310f, 0.62900239f, 0.62645501f, 0.62390089f, +0.62134010f, 0.61877263f, 0.61619854f, 0.61361790f, 0.61103064f, +0.60843682f, 0.60583651f, 0.60322970f, 0.60061646f, 0.59799677f, +0.59537065f, 0.59273821f, 0.59009939f, 0.58745426f, 0.58480281f, +0.58214509f, 0.57948118f, 0.57681108f, 0.57413477f, 0.57145232f, +0.56876373f, 0.56606907f, 0.56336832f, 0.56066155f, 0.55794877f, +0.55523002f, 0.55250537f, 0.54977477f, 0.54703826f, 0.54429591f, +0.54154772f, 0.53879374f, 0.53603399f, 0.53326851f, 0.53049731f, +0.52772039f, 0.52493787f, 0.52214974f, 0.51935595f, 0.51655668f, +0.51375180f, 0.51094145f, 0.50812566f, 0.50530440f, 0.50247771f, +0.49964568f, 0.49680826f, 0.49396557f, 0.49111754f, 0.48826426f, +0.48540577f, 0.48254207f, 0.47967321f, 0.47679919f, 0.47392011f, +0.47103590f, 0.46814668f, 0.46525243f, 0.46235323f, 0.45944905f, +0.45653993f, 0.45362595f, 0.45070711f, 0.44778344f, 0.44485497f, +0.44192174f, 0.43898380f, 0.43604112f, 0.43309379f, 0.43014181f, +0.42718524f, 0.42422408f, 0.42125839f, 0.41828820f, 0.41531351f, +0.41233435f, 0.40935081f, 0.40636289f, 0.40337059f, 0.40037400f, +0.39737311f, 0.39436796f, 0.39135858f, 0.38834500f, 0.38532731f, +0.38230544f, 0.37927949f, 0.37624949f, 0.37321547f, 0.37017745f, +0.36713544f, 0.36408952f, 0.36103970f, 0.35798600f, 0.35492846f, +0.35186714f, 0.34880206f, 0.34573323f, 0.34266070f, 0.33958447f, +0.33650464f, 0.33342120f, 0.33033419f, 0.32724363f, 0.32414958f, +0.32105204f, 0.31795108f, 0.31484672f, 0.31173897f, 0.30862790f, +0.30551350f, 0.30239585f, 0.29927495f, 0.29615086f, 0.29302359f, +0.28989318f, 0.28675964f, 0.28362307f, 0.28048345f, 0.27734083f, +0.27419522f, 0.27104670f, 0.26789525f, 0.26474094f, 0.26158381f, +0.25842386f, 0.25526115f, 0.25209570f, 0.24892756f, 0.24575676f, +0.24258332f, 0.23940729f, 0.23622867f, 0.23304754f, 0.22986393f, +0.22667783f, 0.22348931f, 0.22029841f, 0.21710514f, 0.21390954f, +0.21071166f, 0.20751151f, 0.20430915f, 0.20110460f, 0.19789790f, +0.19468907f, 0.19147816f, 0.18826519f, 0.18505022f, 0.18183327f, +0.17861435f, 0.17539354f, 0.17217083f, 0.16894630f, 0.16571994f, +0.16249183f, 0.15926196f, 0.15603039f, 0.15279715f, 0.14956227f, +0.14632578f, 0.14308774f, 0.13984816f, 0.13660708f, 0.13336454f, +0.13012058f, 0.12687522f, 0.12362850f, 0.12038045f, 0.11713112f, +0.11388054f, 0.11062872f, 0.10737573f, 0.10412160f, 0.10086634f, +0.097609997f, 0.094352618f, 0.091094226f, 0.087834857f, 0.084574550f, +0.081313334f, 0.078051247f, 0.074788325f, 0.071524605f, 0.068260118f, +0.064994894f, 0.061728980f, 0.058462404f, 0.055195201f, 0.051927410f, +0.048659060f, 0.045390189f, 0.042120833f, 0.038851023f, 0.035580799f, +0.032310195f, 0.029039243f, 0.025767982f, 0.022496443f, 0.019224664f, +0.015952680f, 0.012680525f, 0.0094082337f, 0.0061358409f, 0.0028633832f, +-0.00040910527f, -0.0036815894f, -0.0069540343f, -0.010226404f, -0.013498665f, +-0.016770782f, -0.020042717f, -0.023314439f, -0.026585912f, -0.029857099f, +-0.033127967f, -0.036398482f, -0.039668605f, -0.042938303f, -0.046207540f, +-0.049476285f, -0.052744497f, -0.056012146f, -0.059279196f, -0.062545612f, +-0.065811358f, -0.069076397f, -0.072340697f, -0.075604223f, -0.078866936f, +-0.082128808f, -0.085389800f, -0.088649876f, -0.091909006f, -0.095167145f, +-0.098424271f, -0.10168034f, -0.10493532f, -0.10818918f, -0.11144188f, +-0.11469338f, -0.11794366f, -0.12119267f, -0.12444039f, -0.12768677f, +-0.13093179f, -0.13417540f, -0.13741758f, -0.14065829f, -0.14389749f, +-0.14713514f, -0.15037122f, -0.15360570f, -0.15683852f, -0.16006967f, +-0.16329910f, -0.16652679f, -0.16975269f, -0.17297678f, -0.17619900f, +-0.17941935f, -0.18263777f, -0.18585424f, -0.18906870f, -0.19228116f, +-0.19549155f, -0.19869985f, -0.20190603f, -0.20511003f, -0.20831184f, +-0.21151142f, -0.21470875f, -0.21790376f, -0.22109644f, -0.22428675f, +-0.22747467f, -0.23066014f, -0.23384315f, -0.23702365f, -0.24020162f, +-0.24337701f, -0.24654980f, -0.24971995f, -0.25288740f, -0.25605217f, +-0.25921419f, -0.26237345f, -0.26552987f, -0.26868346f, -0.27183419f, +-0.27498198f, -0.27812684f, -0.28126872f, -0.28440759f, -0.28754342f, +-0.29067615f, -0.29380578f, -0.29693225f, -0.30005556f, -0.30317566f, +-0.30629250f, -0.30940607f, -0.31251630f, -0.31562322f, -0.31872672f, +-0.32182685f, -0.32492352f, -0.32801670f, -0.33110636f, -0.33419248f, +-0.33727503f, -0.34035397f, -0.34342924f, -0.34650084f, -0.34956875f, +-0.35263291f, -0.35569328f, -0.35874987f, -0.36180258f, -0.36485144f, +-0.36789638f, -0.37093741f, -0.37397444f, -0.37700745f, -0.38003644f, +-0.38306138f, -0.38608220f, -0.38909888f, -0.39211139f, -0.39511973f, +-0.39812380f, -0.40112361f, -0.40411916f, -0.40711036f, -0.41009718f, +-0.41307965f, -0.41605768f, -0.41903123f, -0.42200032f, -0.42496487f, +-0.42792490f, -0.43088034f, -0.43383113f, -0.43677729f, -0.43971881f, +-0.44265559f, -0.44558764f, -0.44851488f, -0.45143735f, -0.45435500f, +-0.45726776f, -0.46017563f, -0.46307856f, -0.46597654f, -0.46886954f, +-0.47175750f, -0.47464043f, -0.47751826f, -0.48039100f, -0.48325855f, +-0.48612097f, -0.48897815f, -0.49183011f, -0.49467680f, -0.49751821f, +-0.50035429f, -0.50318497f, -0.50601029f, -0.50883019f, -0.51164466f, +-0.51445359f, -0.51725709f, -0.52005500f, -0.52284735f, -0.52563411f, +-0.52841520f, -0.53119069f, -0.53396046f, -0.53672451f, -0.53948283f, +-0.54223537f, -0.54498214f, -0.54772300f, -0.55045801f, -0.55318713f, +-0.55591035f, -0.55862761f, -0.56133890f, -0.56404412f, -0.56674337f, +-0.56943649f, -0.57212353f, -0.57480448f, -0.57747924f, -0.58014780f, +-0.58281022f, -0.58546633f, -0.58811617f, -0.59075975f, -0.59339696f, +-0.59602785f, -0.59865236f, -0.60127044f, -0.60388207f, -0.60648727f, +-0.60908598f, -0.61167812f, -0.61426371f, -0.61684275f, -0.61941516f, +-0.62198097f, -0.62454009f, -0.62709254f, -0.62963831f, -0.63217729f, +-0.63470948f, -0.63723493f, -0.63975352f, -0.64226526f, -0.64477009f, +-0.64726806f, -0.64975911f, -0.65224314f, -0.65472025f, -0.65719032f, +-0.65965337f, -0.66210932f, -0.66455823f, -0.66700000f, -0.66943461f, +-0.67186207f, -0.67428231f, -0.67669535f, -0.67910111f, -0.68149966f, +-0.68389088f, -0.68627477f, -0.68865126f, -0.69102043f, -0.69338220f, +-0.69573659f, -0.69808346f, -0.70042288f, -0.70275480f, -0.70507920f, +-0.70739603f, -0.70970529f, -0.71200693f, -0.71430099f, -0.71658736f, +-0.71886611f, -0.72113711f, -0.72340041f, -0.72565591f, -0.72790372f, +-0.73014367f, -0.73237586f, -0.73460019f, -0.73681659f, -0.73902518f, +-0.74122584f, -0.74341851f, -0.74560326f, -0.74778003f, -0.74994880f, +-0.75210953f, -0.75426215f, -0.75640678f, -0.75854325f, -0.76067162f, +-0.76279181f, -0.76490390f, -0.76700771f, -0.76910341f, -0.77119076f, +-0.77326995f, -0.77534080f, -0.77740335f, -0.77945763f, -0.78150350f, +-0.78354102f, -0.78557014f, -0.78759086f, -0.78960317f, -0.79160696f, +-0.79360235f, -0.79558921f, -0.79756755f, -0.79953730f, -0.80149853f, +-0.80345118f, -0.80539525f, -0.80733067f, -0.80925739f, -0.81117553f, +-0.81308490f, -0.81498563f, -0.81687760f, -0.81876087f, -0.82063532f, +-0.82250100f, -0.82435787f, -0.82620591f, -0.82804507f, -0.82987541f, +-0.83169687f, -0.83350939f, -0.83531296f, -0.83710766f, -0.83889335f, +-0.84067005f, -0.84243774f, -0.84419644f, -0.84594607f, -0.84768665f, +-0.84941816f, -0.85114056f, -0.85285389f, -0.85455805f, -0.85625303f, +-0.85793889f, -0.85961550f, -0.86128294f, -0.86294121f, -0.86459017f, +-0.86622989f, -0.86786032f, -0.86948150f, -0.87109333f, -0.87269586f, +-0.87428904f, -0.87587279f, -0.87744725f, -0.87901229f, -0.88056785f, +-0.88211405f, -0.88365078f, -0.88517809f, -0.88669586f, -0.88820416f, +-0.88970292f, -0.89119220f, -0.89267188f, -0.89414203f, -0.89560264f, +-0.89705360f, -0.89849502f, -0.89992678f, -0.90134889f, -0.90276134f, +-0.90416414f, -0.90555727f, -0.90694070f, -0.90831441f, -0.90967834f, +-0.91103262f, -0.91237706f, -0.91371179f, -0.91503674f, -0.91635185f, +-0.91765714f, -0.91895264f, -0.92023826f, -0.92151409f, -0.92277998f, +-0.92403603f, -0.92528218f, -0.92651838f, -0.92774469f, -0.92896110f, +-0.93016750f, -0.93136400f, -0.93255049f, -0.93372697f, -0.93489349f, +-0.93604994f, -0.93719643f, -0.93833286f, -0.93945926f, -0.94057560f, +-0.94168180f, -0.94277799f, -0.94386405f, -0.94494003f, -0.94600588f, +-0.94706154f, -0.94810712f, -0.94914252f, -0.95016778f, -0.95118284f, +-0.95218778f, -0.95318246f, -0.95416695f, -0.95514119f, -0.95610523f, +-0.95705903f, -0.95800257f, -0.95893586f, -0.95985889f, -0.96077162f, +-0.96167403f, -0.96256620f, -0.96344805f, -0.96431959f, -0.96518075f, +-0.96603161f, -0.96687216f, -0.96770233f, -0.96852213f, -0.96933156f, +-0.97013056f, -0.97091925f, -0.97169751f, -0.97246534f, -0.97322279f, +-0.97396982f, -0.97470641f, -0.97543252f, -0.97614825f, -0.97685349f, +-0.97754824f, -0.97823256f, -0.97890645f, -0.97956979f, -0.98022264f, +-0.98086500f, -0.98149687f, -0.98211825f, -0.98272908f, -0.98332942f, +-0.98391914f, -0.98449844f, -0.98506713f, -0.98562527f, -0.98617285f, +-0.98670989f, -0.98723638f, -0.98775226f, -0.98825759f, -0.98875231f, +-0.98923647f, -0.98971003f, -0.99017298f, -0.99062532f, -0.99106705f, +-0.99149817f, -0.99191868f, -0.99232858f, -0.99272782f, -0.99311644f, +-0.99349445f, -0.99386179f, -0.99421853f, -0.99456459f, -0.99489999f, +-0.99522477f, -0.99553883f, -0.99584228f, -0.99613506f, -0.99641716f, +-0.99668860f, -0.99694937f, -0.99719942f, -0.99743885f, -0.99766755f, +-0.99788558f, -0.99809295f, -0.99828959f, -0.99847561f, -0.99865085f, +-0.99881548f, -0.99896932f, -0.99911255f, -0.99924499f, -0.99936682f, +-0.99947786f, -0.99957830f, -0.99966794f, -0.99974692f, -0.99981517f, +-0.99987274f, -0.99991959f, -0.99995571f, -0.99998116f, -0.99999589f, +0.99999964f, 0.99997288f, 0.99990326f, 0.99979085f, 0.99963558f, +0.99943751f, 0.99919659f, 0.99891287f, 0.99858636f, 0.99821711f, +0.99780506f, 0.99735034f, 0.99685282f, 0.99631262f, 0.99572974f, +0.99510419f, 0.99443603f, 0.99372530f, 0.99297196f, 0.99217612f, +0.99133772f, 0.99045694f, 0.98953366f, 0.98856801f, 0.98756003f, +0.98650974f, 0.98541719f, 0.98428243f, 0.98310548f, 0.98188645f, +0.98062533f, 0.97932225f, 0.97797716f, 0.97659022f, 0.97516143f, +0.97369087f, 0.97217858f, 0.97062469f, 0.96902919f, 0.96739221f, +0.96571374f, 0.96399397f, 0.96223283f, 0.96043050f, 0.95858705f, +0.95670253f, 0.95477700f, 0.95281059f, 0.95080340f, 0.94875544f, +0.94666684f, 0.94453770f, 0.94236809f, 0.94015813f, 0.93790787f, +0.93561745f, 0.93328691f, 0.93091643f, 0.92850608f, 0.92605597f, +0.92356616f, 0.92103678f, 0.91846794f, 0.91585976f, 0.91321236f, +0.91052586f, 0.90780038f, 0.90503591f, 0.90223277f, 0.89939094f, +0.89651060f, 0.89359182f, 0.89063478f, 0.88763964f, 0.88460642f, +0.88153529f, 0.87842643f, 0.87527996f, 0.87209594f, 0.86887461f, +0.86561602f, 0.86232042f, 0.85898781f, 0.85561842f, 0.85221243f, +0.84876984f, 0.84529096f, 0.84177583f, 0.83822471f, 0.83463764f, +0.83101481f, 0.82735640f, 0.82366252f, 0.81993335f, 0.81616908f, +0.81236988f, 0.80853581f, 0.80466717f, 0.80076402f, 0.79682660f, +0.79285502f, 0.78884947f, 0.78481019f, 0.78073722f, 0.77663082f, +0.77249116f, 0.76831841f, 0.76411277f, 0.75987434f, 0.75560343f, +0.75130010f, 0.74696463f, 0.74259710f, 0.73819780f, 0.73376691f, +0.72930455f, 0.72481096f, 0.72028631f, 0.71573079f, 0.71114463f, +0.70652801f, 0.70188117f, 0.69720417f, 0.69249737f, 0.68776089f, +0.68299496f, 0.67819971f, 0.67337549f, 0.66852236f, 0.66364062f, +0.65873051f, 0.65379208f, 0.64882571f, 0.64383155f, 0.63880974f, +0.63376063f, 0.62868434f, 0.62358117f, 0.61845124f, 0.61329484f, +0.60811216f, 0.60290343f, 0.59766883f, 0.59240872f, 0.58712316f, +0.58181250f, 0.57647687f, 0.57111657f, 0.56573176f, 0.56032276f, +0.55488980f, 0.54943299f, 0.54395270f, 0.53844911f, 0.53292239f, +0.52737290f, 0.52180082f, 0.51620632f, 0.51058978f, 0.50495136f, +0.49929130f, 0.49360985f, 0.48790723f, 0.48218375f, 0.47643960f, +0.47067502f, 0.46489030f, 0.45908567f, 0.45326138f, 0.44741765f, +0.44155475f, 0.43567297f, 0.42977250f, 0.42385364f, 0.41791660f, +0.41196167f, 0.40598908f, 0.39999911f, 0.39399201f, 0.38796803f, +0.38192743f, 0.37587047f, 0.36979741f, 0.36370850f, 0.35760403f, +0.35148421f, 0.34534934f, 0.33919969f, 0.33303553f, 0.32685706f, +0.32066461f, 0.31445843f, 0.30823877f, 0.30200592f, 0.29576012f, +0.28950164f, 0.28323078f, 0.27694780f, 0.27065292f, 0.26434645f, +0.25802869f, 0.25169984f, 0.24536023f, 0.23901010f, 0.23264973f, +0.22627939f, 0.21989937f, 0.21350993f, 0.20711134f, 0.20070387f, +0.19428782f, 0.18786344f, 0.18143101f, 0.17499080f, 0.16854310f, +0.16208819f, 0.15562633f, 0.14915779f, 0.14268288f, 0.13620184f, +0.12971498f, 0.12322257f, 0.11672486f, 0.11022217f, 0.10371475f, +0.097202882f, 0.090686858f, 0.084166944f, 0.077643424f, 0.071116582f, +0.064586692f, 0.058054037f, 0.051518895f, 0.044981543f, 0.038442269f, +0.031901345f, 0.025359053f, 0.018815678f, 0.012271495f, 0.0057267868f, +-0.00081816671f, -0.0073630852f, -0.013907688f, -0.020451695f, -0.026994826f, +-0.033536803f, -0.040077340f, -0.046616159f, -0.053152986f, -0.059687532f, +-0.066219524f, -0.072748676f, -0.079274714f, -0.085797355f, -0.092316322f, +-0.098831341f, -0.10534211f, -0.11184838f, -0.11834986f, -0.12484626f, +-0.13133731f, -0.13782275f, -0.14430228f, -0.15077563f, -0.15724251f, +-0.16370267f, -0.17015581f, -0.17660165f, -0.18303993f, -0.18947038f, +-0.19589271f, -0.20230664f, -0.20871192f, -0.21510825f, -0.22149536f, +-0.22787298f, -0.23424086f, -0.24059868f, -0.24694622f, -0.25328314f, +-0.25960925f, -0.26592422f, -0.27222782f, -0.27851975f, -0.28479972f, +-0.29106751f, -0.29732284f, -0.30356544f, -0.30979502f, -0.31601134f, +-0.32221413f, -0.32840309f, -0.33457801f, -0.34073856f, -0.34688455f, +-0.35301566f, -0.35913166f, -0.36523229f, -0.37131724f, -0.37738630f, +-0.38343921f, -0.38947567f, -0.39549544f, -0.40149832f, -0.40748394f, +-0.41345215f, -0.41940263f, -0.42533514f, -0.43124944f, -0.43714526f, +-0.44302234f, -0.44888046f, -0.45471936f, -0.46053877f, -0.46633846f, +-0.47211814f, -0.47787762f, -0.48361665f, -0.48933494f, -0.49503228f, +-0.50070840f, -0.50636309f, -0.51199609f, -0.51760709f, -0.52319598f, +-0.52876246f, -0.53430629f, -0.53982723f, -0.54532504f, -0.55079949f, +-0.55625033f, -0.56167740f, -0.56708032f, -0.57245898f, -0.57781315f, +-0.58314258f, -0.58844697f, -0.59372622f, -0.59897995f, -0.60420811f, +-0.60941035f, -0.61458647f, -0.61973625f, -0.62485951f, -0.62995601f, +-0.63502556f, -0.64006782f, -0.64508271f, -0.65007001f, -0.65502942f, +-0.65996075f, -0.66486382f, -0.66973841f, -0.67458433f, -0.67940134f, +-0.68418926f, -0.68894786f, -0.69367695f, -0.69837630f, -0.70304573f, +-0.70768511f, -0.71229410f, -0.71687263f, -0.72142041f, -0.72593731f, +-0.73042315f, -0.73487765f, -0.73930067f, -0.74369204f, -0.74805158f, +-0.75237900f, -0.75667429f, -0.76093709f, -0.76516730f, -0.76936477f, +-0.77352923f, -0.77766061f, -0.78175867f, -0.78582323f, -0.78985411f, +-0.79385114f, -0.79781419f, -0.80174309f, -0.80563760f, -0.80949765f, +-0.81332302f, -0.81711352f, -0.82086903f, -0.82458937f, -0.82827437f, +-0.83192390f, -0.83553779f, -0.83911592f, -0.84265804f, -0.84616417f, +-0.84963393f, -0.85306740f, -0.85646427f, -0.85982448f, -0.86314780f, +-0.86643422f, -0.86968350f, -0.87289548f, -0.87607014f, -0.87920725f, +-0.88230664f, -0.88536829f, -0.88839203f, -0.89137769f, -0.89432514f, +-0.89723432f, -0.90010506f, -0.90293723f, -0.90573072f, -0.90848541f, +-0.91120118f, -0.91387796f, -0.91651553f, -0.91911387f, -0.92167282f, +-0.92419231f, -0.92667222f, -0.92911243f, -0.93151283f, -0.93387336f, +-0.93619382f, -0.93847424f, -0.94071442f, -0.94291431f, -0.94507378f, +-0.94719279f, -0.94927126f, -0.95130903f, -0.95330608f, -0.95526224f, +-0.95717752f, -0.95905179f, -0.96088499f, -0.96267700f, -0.96442777f, +-0.96613729f, -0.96780539f, -0.96943200f, -0.97101706f, -0.97256058f, +-0.97406244f, -0.97552258f, -0.97694093f, -0.97831738f, -0.97965199f, +-0.98094457f, -0.98219514f, -0.98340368f, -0.98457009f, -0.98569429f, +-0.98677629f, -0.98781598f, -0.98881340f, -0.98976845f, -0.99068111f, +-0.99155134f, -0.99237907f, -0.99316430f, -0.99390697f, -0.99460709f, +-0.99526459f, -0.99587947f, -0.99645168f, -0.99698120f, -0.99746799f, +-0.99791211f, -0.99831343f, -0.99867201f, -0.99898779f, -0.99926084f, +-0.99949104f, -0.99967843f, -0.99982297f, -0.99992472f, -0.99998361f, +0.99999869f, 0.99989158f, 0.99961317f, 0.99916345f, 0.99854255f, +0.99775058f, 0.99678761f, 0.99565387f, 0.99434954f, 0.99287480f, +0.99122995f, 0.98941529f, 0.98743105f, 0.98527765f, 0.98295540f, +0.98046476f, 0.97780609f, 0.97497988f, 0.97198665f, 0.96882683f, +0.96550101f, 0.96200979f, 0.95835376f, 0.95453346f, 0.95054960f, +0.94640291f, 0.94209403f, 0.93762374f, 0.93299282f, 0.92820197f, +0.92325211f, 0.91814411f, 0.91287869f, 0.90745693f, 0.90187967f, +0.89614785f, 0.89026248f, 0.88422459f, 0.87803519f, 0.87169534f, +0.86520612f, 0.85856867f, 0.85178405f, 0.84485358f, 0.83777827f, +0.83055943f, 0.82319832f, 0.81569612f, 0.80805415f, 0.80027372f, +0.79235619f, 0.78430289f, 0.77611518f, 0.76779449f, 0.75934225f, +0.75075996f, 0.74204898f, 0.73321080f, 0.72424710f, 0.71515924f, +0.70594883f, 0.69661748f, 0.68716675f, 0.67759830f, 0.66791373f, +0.65811473f, 0.64820296f, 0.63818014f, 0.62804794f, 0.61780810f, +0.60746247f, 0.59701276f, 0.58646071f, 0.57580817f, 0.56505698f, +0.55420899f, 0.54326600f, 0.53222996f, 0.52110273f, 0.50988621f, +0.49858227f, 0.48719296f, 0.47572014f, 0.46416581f, 0.45253196f, +0.44082057f, 0.42903364f, 0.41717321f, 0.40524128f, 0.39323992f, +0.38117120f, 0.36903715f, 0.35683987f, 0.34458145f, 0.33226398f, +0.31988961f, 0.30746040f, 0.29497850f, 0.28244606f, 0.26986524f, +0.25723818f, 0.24456702f, 0.23185398f, 0.21910121f, 0.20631088f, +0.19348522f, 0.18062639f, 0.16773662f, 0.15481812f, 0.14187308f, +0.12890373f, 0.11591230f, 0.10290100f, 0.089872077f, 0.076827750f, +0.063770257f, 0.050701842f, 0.037624735f, 0.024541186f, 0.011453429f, +-0.0016362892f, -0.014725727f, -0.027812643f, -0.040894791f, -0.053969935f, +-0.067035832f, -0.080090240f, -0.093130924f, -0.10615565f, -0.11916219f, +-0.13214831f, -0.14511178f, -0.15805040f, -0.17096193f, -0.18384418f, +-0.19669491f, -0.20951195f, -0.22229309f, -0.23503613f, -0.24773891f, +-0.26039925f, -0.27301496f, -0.28558388f, -0.29810387f, -0.31057280f, +-0.32298848f, -0.33534884f, -0.34765175f, -0.35989508f, -0.37207675f, +-0.38419467f, -0.39624676f, -0.40823093f, -0.42014518f, -0.43198743f, +-0.44375566f, -0.45544785f, -0.46706200f, -0.47859612f, -0.49004826f, +-0.50141639f, -0.51269865f, -0.52389306f, -0.53499764f, -0.54601061f, +-0.55693001f, -0.56775403f, -0.57848072f, -0.58910829f, -0.59963489f, +-0.61005878f, -0.62037814f, -0.63059121f, -0.64069623f, -0.65069145f, +-0.66057515f, -0.67034572f, -0.68000144f, -0.68954057f, -0.69896162f, +-0.70826286f, -0.71744281f, -0.72649974f, -0.73543227f, -0.74423873f, +-0.75291771f, -0.76146764f, -0.76988715f, -0.77817470f, -0.78632891f, +-0.79434842f, -0.80223179f, -0.80997771f, -0.81758487f, -0.82505190f, +-0.83237761f, -0.83956063f, -0.84659988f, -0.85349399f, -0.86024189f, +-0.86684239f, -0.87329435f, -0.87959671f, -0.88574833f, -0.89174819f, +-0.89759529f, -0.90328854f, -0.90882701f, -0.91420978f, -0.91943592f, +-0.92450452f, -0.92941469f, -0.93416560f, -0.93875647f, -0.94318646f, +-0.94745487f, -0.95156091f, -0.95550388f, -0.95928317f, -0.96289814f, +-0.96634805f, -0.96963239f, -0.97275060f, -0.97570217f, -0.97848648f, +-0.98110318f, -0.98355180f, -0.98583186f, -0.98794299f, -0.98988485f, +-0.99165714f, -0.99325943f, -0.99469161f, -0.99595332f, -0.99704438f, +-0.99796462f, -0.99871385f, -0.99929196f, -0.99969882f, -0.99993443f, +0.99999464f, 0.99956632f, 0.99845290f, 0.99665523f, 0.99417448f, +0.99101239f, 0.98717111f, 0.98265326f, 0.97746199f, 0.97160077f, +0.96507365f, 0.95788515f, 0.95004016f, 0.94154406f, 0.93240267f, +0.92262226f, 0.91220951f, 0.90117162f, 0.88951606f, 0.87725091f, +0.86438453f, 0.85092574f, 0.83688372f, 0.82226819f, 0.80708915f, +0.79135692f, 0.77508235f, 0.75827658f, 0.74095112f, 0.72311783f, +0.70478898f, 0.68597710f, 0.66669506f, 0.64695615f, 0.62677377f, +0.60616189f, 0.58513457f, 0.56370622f, 0.54189157f, 0.51970547f, +0.49716324f, 0.47428027f, 0.45107225f, 0.42755505f, 0.40374488f, +0.37965798f, 0.35531086f, 0.33072025f, 0.30590299f, 0.28087607f, +0.25565663f, 0.23026201f, 0.20470956f, 0.17901683f, 0.15320139f, +0.12728097f, 0.10127331f, 0.075196236f, 0.049067631f, 0.022905400f, +-0.0032725304f, -0.029448219f, -0.055603724f, -0.081721120f, -0.10778251f, +-0.13377003f, -0.15966587f, -0.18545228f, -0.21111161f, -0.23662624f, +-0.26197869f, -0.28715160f, -0.31212771f, -0.33688989f, -0.36142120f, +-0.38570482f, -0.40972409f, -0.43346253f, -0.45690393f, -0.48003218f, +-0.50283146f, -0.52528608f, -0.54738069f, -0.56910020f, -0.59042966f, +-0.61135447f, -0.63186026f, -0.65193301f, -0.67155898f, -0.69072473f, +-0.70941705f, -0.72762316f, -0.74533063f, -0.76252723f, -0.77920127f, +-0.79534131f, -0.81093621f, -0.82597536f, -0.84044844f, -0.85434550f, +-0.86765707f, -0.88037395f, -0.89248747f, -0.90398932f, -0.91487163f, +-0.92512697f, -0.93474823f, -0.94372886f, -0.95206273f, -0.95974404f, +-0.96676767f, -0.97312868f, -0.97882277f, -0.98384601f, -0.98819500f, +-0.99186671f, -0.99485862f, -0.99716878f, -0.99879545f, -0.99973762f, +}; #endif static const CELTMode mode48000_960_120 = { diff --git a/drivers/opus/celt/static_modes_float_arm_ne10.h b/drivers/opus/celt/static_modes_float_arm_ne10.h new file mode 100644 index 0000000000..934a82a420 --- /dev/null +++ b/drivers/opus/celt/static_modes_float_arm_ne10.h @@ -0,0 +1,404 @@ +/* The contents of this file was automatically generated by + * dump_mode_arm_ne10.c with arguments: 48000 960 + * It contains static definitions for some pre-defined modes. */ +#include <NE10_init.h> + +#ifndef NE10_FFT_PARAMS48000_960 +#define NE10_FFT_PARAMS48000_960 +static const ne10_int32_t ne10_factors_480[64] = { +4, 40, 4, 30, 2, 15, 5, 3, 3, 1, 1, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, }; +static const ne10_int32_t ne10_factors_240[64] = { +3, 20, 4, 15, 5, 3, 3, 1, 1, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, }; +static const ne10_int32_t ne10_factors_120[64] = { +3, 10, 2, 15, 5, 3, 3, 1, 1, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, }; +static const ne10_int32_t ne10_factors_60[64] = { +2, 5, 5, 3, 3, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, }; +static const ne10_fft_cpx_float32_t ne10_twiddles_480[480] = { +{1.0000000f,0.0000000f}, {1.0000000f,-0.0000000f}, {1.0000000f,-0.0000000f}, +{1.0000000f,-0.0000000f}, {0.91354543f,-0.40673664f}, {0.66913056f,-0.74314487f}, +{1.0000000f,-0.0000000f}, {0.66913056f,-0.74314487f}, {-0.10452851f,-0.99452192f}, +{1.0000000f,-0.0000000f}, {0.30901697f,-0.95105654f}, {-0.80901700f,-0.58778518f}, +{1.0000000f,-0.0000000f}, {-0.10452851f,-0.99452192f}, {-0.97814757f,0.20791179f}, +{1.0000000f,-0.0000000f}, {0.97814763f,-0.20791170f}, {0.91354543f,-0.40673664f}, +{0.80901700f,-0.58778524f}, {0.66913056f,-0.74314487f}, {0.49999997f,-0.86602545f}, +{0.30901697f,-0.95105654f}, {0.10452842f,-0.99452192f}, {-0.10452851f,-0.99452192f}, +{-0.30901703f,-0.95105648f}, {-0.50000006f,-0.86602533f}, {-0.66913068f,-0.74314475f}, +{-0.80901700f,-0.58778518f}, {-0.91354549f,-0.40673658f}, {-0.97814763f,-0.20791161f}, +{1.0000000f,-0.0000000f}, {0.99862951f,-0.052335959f}, {0.99452192f,-0.10452846f}, +{0.98768836f,-0.15643448f}, {0.97814763f,-0.20791170f}, {0.96592581f,-0.25881904f}, +{0.95105648f,-0.30901700f}, {0.93358040f,-0.35836795f}, {0.91354543f,-0.40673664f}, +{0.89100653f,-0.45399052f}, {0.86602545f,-0.50000000f}, {0.83867055f,-0.54463905f}, +{0.80901700f,-0.58778524f}, {0.77714598f,-0.62932038f}, {0.74314475f,-0.66913062f}, +{0.70710677f,-0.70710683f}, {0.66913056f,-0.74314487f}, {0.62932038f,-0.77714598f}, +{0.58778524f,-0.80901700f}, {0.54463899f,-0.83867055f}, {0.49999997f,-0.86602545f}, +{0.45399052f,-0.89100653f}, {0.40673661f,-0.91354549f}, {0.35836786f,-0.93358046f}, +{0.30901697f,-0.95105654f}, {0.25881907f,-0.96592581f}, {0.20791166f,-0.97814763f}, +{0.15643437f,-0.98768836f}, {0.10452842f,-0.99452192f}, {0.052335974f,-0.99862951f}, +{1.0000000f,-0.0000000f}, {0.99452192f,-0.10452846f}, {0.97814763f,-0.20791170f}, +{0.95105648f,-0.30901700f}, {0.91354543f,-0.40673664f}, {0.86602545f,-0.50000000f}, +{0.80901700f,-0.58778524f}, {0.74314475f,-0.66913062f}, {0.66913056f,-0.74314487f}, +{0.58778524f,-0.80901700f}, {0.49999997f,-0.86602545f}, {0.40673661f,-0.91354549f}, +{0.30901697f,-0.95105654f}, {0.20791166f,-0.97814763f}, {0.10452842f,-0.99452192f}, +{-4.3711388e-08f,-1.0000000f}, {-0.10452851f,-0.99452192f}, {-0.20791174f,-0.97814757f}, +{-0.30901703f,-0.95105648f}, {-0.40673670f,-0.91354543f}, {-0.50000006f,-0.86602533f}, +{-0.58778518f,-0.80901700f}, {-0.66913068f,-0.74314475f}, {-0.74314493f,-0.66913044f}, +{-0.80901700f,-0.58778518f}, {-0.86602539f,-0.50000006f}, {-0.91354549f,-0.40673658f}, +{-0.95105654f,-0.30901679f}, {-0.97814763f,-0.20791161f}, {-0.99452192f,-0.10452849f}, +{1.0000000f,-0.0000000f}, {0.98768836f,-0.15643448f}, {0.95105648f,-0.30901700f}, +{0.89100653f,-0.45399052f}, {0.80901700f,-0.58778524f}, {0.70710677f,-0.70710683f}, +{0.58778524f,-0.80901700f}, {0.45399052f,-0.89100653f}, {0.30901697f,-0.95105654f}, +{0.15643437f,-0.98768836f}, {-4.3711388e-08f,-1.0000000f}, {-0.15643445f,-0.98768836f}, +{-0.30901703f,-0.95105648f}, {-0.45399061f,-0.89100647f}, {-0.58778518f,-0.80901700f}, +{-0.70710677f,-0.70710677f}, {-0.80901700f,-0.58778518f}, {-0.89100659f,-0.45399037f}, +{-0.95105654f,-0.30901679f}, {-0.98768836f,-0.15643445f}, {-1.0000000f,8.7422777e-08f}, +{-0.98768830f,0.15643461f}, {-0.95105654f,0.30901697f}, {-0.89100653f,0.45399055f}, +{-0.80901694f,0.58778536f}, {-0.70710665f,0.70710689f}, {-0.58778507f,0.80901712f}, +{-0.45399022f,0.89100665f}, {-0.30901709f,0.95105648f}, {-0.15643452f,0.98768830f}, +{1.0000000f,-0.0000000f}, {0.99991435f,-0.013089596f}, {0.99965733f,-0.026176950f}, +{0.99922901f,-0.039259817f}, {0.99862951f,-0.052335959f}, {0.99785894f,-0.065403134f}, +{0.99691731f,-0.078459099f}, {0.99580491f,-0.091501623f}, {0.99452192f,-0.10452846f}, +{0.99306846f,-0.11753740f}, {0.99144489f,-0.13052620f}, {0.98965138f,-0.14349262f}, +{0.98768836f,-0.15643448f}, {0.98555607f,-0.16934951f}, {0.98325491f,-0.18223552f}, +{0.98078525f,-0.19509032f}, {0.97814763f,-0.20791170f}, {0.97534233f,-0.22069745f}, +{0.97236991f,-0.23344538f}, {0.96923089f,-0.24615330f}, {0.96592581f,-0.25881904f}, +{0.96245521f,-0.27144045f}, {0.95881975f,-0.28401536f}, {0.95501995f,-0.29654160f}, +{0.95105648f,-0.30901700f}, {0.94693011f,-0.32143945f}, {0.94264150f,-0.33380687f}, +{0.93819129f,-0.34611708f}, {0.93358040f,-0.35836795f}, {0.92880952f,-0.37055743f}, +{0.92387956f,-0.38268346f}, {0.91879117f,-0.39474389f}, {0.91354543f,-0.40673664f}, +{0.90814316f,-0.41865975f}, {0.90258527f,-0.43051112f}, {0.89687270f,-0.44228873f}, +{0.89100653f,-0.45399052f}, {0.88498765f,-0.46561453f}, {0.87881708f,-0.47715878f}, +{0.87249601f,-0.48862126f}, {0.86602545f,-0.50000000f}, {0.85940641f,-0.51129311f}, +{0.85264015f,-0.52249855f}, {0.84572786f,-0.53361452f}, {0.83867055f,-0.54463905f}, +{0.83146960f,-0.55557024f}, {0.82412618f,-0.56640625f}, {0.81664151f,-0.57714522f}, +{0.80901700f,-0.58778524f}, {0.80125380f,-0.59832460f}, {0.79335332f,-0.60876143f}, +{0.78531694f,-0.61909395f}, {0.77714598f,-0.62932038f}, {0.76884180f,-0.63943899f}, +{0.76040596f,-0.64944810f}, {0.75183982f,-0.65934587f}, {0.74314475f,-0.66913062f}, +{0.73432249f,-0.67880076f}, {0.72537434f,-0.68835455f}, {0.71630192f,-0.69779050f}, +{0.70710677f,-0.70710683f}, {0.69779044f,-0.71630198f}, {0.68835455f,-0.72537440f}, +{0.67880070f,-0.73432255f}, {0.66913056f,-0.74314487f}, {0.65934581f,-0.75183982f}, +{0.64944804f,-0.76040596f}, {0.63943899f,-0.76884186f}, {0.62932038f,-0.77714598f}, +{0.61909395f,-0.78531694f}, {0.60876137f,-0.79335338f}, {0.59832460f,-0.80125386f}, +{0.58778524f,-0.80901700f}, {0.57714516f,-0.81664151f}, {0.56640625f,-0.82412618f}, +{0.55557019f,-0.83146960f}, {0.54463899f,-0.83867055f}, {0.53361452f,-0.84572786f}, +{0.52249849f,-0.85264015f}, {0.51129311f,-0.85940641f}, {0.49999997f,-0.86602545f}, +{0.48862118f,-0.87249601f}, {0.47715876f,-0.87881708f}, {0.46561447f,-0.88498765f}, +{0.45399052f,-0.89100653f}, {0.44228867f,-0.89687276f}, {0.43051103f,-0.90258533f}, +{0.41865975f,-0.90814316f}, {0.40673661f,-0.91354549f}, {0.39474380f,-0.91879129f}, +{0.38268343f,-0.92387956f}, {0.37055740f,-0.92880958f}, {0.35836786f,-0.93358046f}, +{0.34611705f,-0.93819135f}, {0.33380681f,-0.94264150f}, {0.32143947f,-0.94693011f}, +{0.30901697f,-0.95105654f}, {0.29654151f,-0.95501995f}, {0.28401533f,-0.95881975f}, +{0.27144039f,-0.96245527f}, {0.25881907f,-0.96592581f}, {0.24615327f,-0.96923089f}, +{0.23344530f,-0.97236991f}, {0.22069745f,-0.97534233f}, {0.20791166f,-0.97814763f}, +{0.19509023f,-0.98078531f}, {0.18223552f,-0.98325491f}, {0.16934945f,-0.98555607f}, +{0.15643437f,-0.98768836f}, {0.14349259f,-0.98965138f}, {0.13052613f,-0.99144489f}, +{0.11753740f,-0.99306846f}, {0.10452842f,-0.99452192f}, {0.091501534f,-0.99580491f}, +{0.078459084f,-0.99691731f}, {0.065403074f,-0.99785894f}, {0.052335974f,-0.99862951f}, +{0.039259788f,-0.99922901f}, {0.026176875f,-0.99965733f}, {0.013089597f,-0.99991435f}, +{1.0000000f,-0.0000000f}, {0.99965733f,-0.026176950f}, {0.99862951f,-0.052335959f}, +{0.99691731f,-0.078459099f}, {0.99452192f,-0.10452846f}, {0.99144489f,-0.13052620f}, +{0.98768836f,-0.15643448f}, {0.98325491f,-0.18223552f}, {0.97814763f,-0.20791170f}, +{0.97236991f,-0.23344538f}, {0.96592581f,-0.25881904f}, {0.95881975f,-0.28401536f}, +{0.95105648f,-0.30901700f}, {0.94264150f,-0.33380687f}, {0.93358040f,-0.35836795f}, +{0.92387956f,-0.38268346f}, {0.91354543f,-0.40673664f}, {0.90258527f,-0.43051112f}, +{0.89100653f,-0.45399052f}, {0.87881708f,-0.47715878f}, {0.86602545f,-0.50000000f}, +{0.85264015f,-0.52249855f}, {0.83867055f,-0.54463905f}, {0.82412618f,-0.56640625f}, +{0.80901700f,-0.58778524f}, {0.79335332f,-0.60876143f}, {0.77714598f,-0.62932038f}, +{0.76040596f,-0.64944810f}, {0.74314475f,-0.66913062f}, {0.72537434f,-0.68835455f}, +{0.70710677f,-0.70710683f}, {0.68835455f,-0.72537440f}, {0.66913056f,-0.74314487f}, +{0.64944804f,-0.76040596f}, {0.62932038f,-0.77714598f}, {0.60876137f,-0.79335338f}, +{0.58778524f,-0.80901700f}, {0.56640625f,-0.82412618f}, {0.54463899f,-0.83867055f}, +{0.52249849f,-0.85264015f}, {0.49999997f,-0.86602545f}, {0.47715876f,-0.87881708f}, +{0.45399052f,-0.89100653f}, {0.43051103f,-0.90258533f}, {0.40673661f,-0.91354549f}, +{0.38268343f,-0.92387956f}, {0.35836786f,-0.93358046f}, {0.33380681f,-0.94264150f}, +{0.30901697f,-0.95105654f}, {0.28401533f,-0.95881975f}, {0.25881907f,-0.96592581f}, +{0.23344530f,-0.97236991f}, {0.20791166f,-0.97814763f}, {0.18223552f,-0.98325491f}, +{0.15643437f,-0.98768836f}, {0.13052613f,-0.99144489f}, {0.10452842f,-0.99452192f}, +{0.078459084f,-0.99691731f}, {0.052335974f,-0.99862951f}, {0.026176875f,-0.99965733f}, +{-4.3711388e-08f,-1.0000000f}, {-0.026176963f,-0.99965733f}, {-0.052336060f,-0.99862951f}, +{-0.078459173f,-0.99691731f}, {-0.10452851f,-0.99452192f}, {-0.13052621f,-0.99144489f}, +{-0.15643445f,-0.98768836f}, {-0.18223560f,-0.98325491f}, {-0.20791174f,-0.97814757f}, +{-0.23344538f,-0.97236991f}, {-0.25881916f,-0.96592581f}, {-0.28401542f,-0.95881969f}, +{-0.30901703f,-0.95105648f}, {-0.33380687f,-0.94264150f}, {-0.35836795f,-0.93358040f}, +{-0.38268352f,-0.92387950f}, {-0.40673670f,-0.91354543f}, {-0.43051112f,-0.90258527f}, +{-0.45399061f,-0.89100647f}, {-0.47715873f,-0.87881708f}, {-0.50000006f,-0.86602533f}, +{-0.52249867f,-0.85264009f}, {-0.54463905f,-0.83867055f}, {-0.56640631f,-0.82412612f}, +{-0.58778518f,-0.80901700f}, {-0.60876143f,-0.79335332f}, {-0.62932050f,-0.77714586f}, +{-0.64944804f,-0.76040596f}, {-0.66913068f,-0.74314475f}, {-0.68835467f,-0.72537428f}, +{-0.70710677f,-0.70710677f}, {-0.72537446f,-0.68835449f}, {-0.74314493f,-0.66913044f}, +{-0.76040596f,-0.64944804f}, {-0.77714604f,-0.62932026f}, {-0.79335332f,-0.60876143f}, +{-0.80901700f,-0.58778518f}, {-0.82412624f,-0.56640613f}, {-0.83867055f,-0.54463899f}, +{-0.85264021f,-0.52249849f}, {-0.86602539f,-0.50000006f}, {-0.87881714f,-0.47715873f}, +{-0.89100659f,-0.45399037f}, {-0.90258527f,-0.43051112f}, {-0.91354549f,-0.40673658f}, +{-0.92387956f,-0.38268328f}, {-0.93358040f,-0.35836792f}, {-0.94264150f,-0.33380675f}, +{-0.95105654f,-0.30901679f}, {-0.95881975f,-0.28401530f}, {-0.96592587f,-0.25881892f}, +{-0.97236991f,-0.23344538f}, {-0.97814763f,-0.20791161f}, {-0.98325491f,-0.18223536f}, +{-0.98768836f,-0.15643445f}, {-0.99144489f,-0.13052608f}, {-0.99452192f,-0.10452849f}, +{-0.99691737f,-0.078459039f}, {-0.99862957f,-0.052335810f}, {-0.99965733f,-0.026176952f}, +{1.0000000f,-0.0000000f}, {0.99922901f,-0.039259817f}, {0.99691731f,-0.078459099f}, +{0.99306846f,-0.11753740f}, {0.98768836f,-0.15643448f}, {0.98078525f,-0.19509032f}, +{0.97236991f,-0.23344538f}, {0.96245521f,-0.27144045f}, {0.95105648f,-0.30901700f}, +{0.93819129f,-0.34611708f}, {0.92387956f,-0.38268346f}, {0.90814316f,-0.41865975f}, +{0.89100653f,-0.45399052f}, {0.87249601f,-0.48862126f}, {0.85264015f,-0.52249855f}, +{0.83146960f,-0.55557024f}, {0.80901700f,-0.58778524f}, {0.78531694f,-0.61909395f}, +{0.76040596f,-0.64944810f}, {0.73432249f,-0.67880076f}, {0.70710677f,-0.70710683f}, +{0.67880070f,-0.73432255f}, {0.64944804f,-0.76040596f}, {0.61909395f,-0.78531694f}, +{0.58778524f,-0.80901700f}, {0.55557019f,-0.83146960f}, {0.52249849f,-0.85264015f}, +{0.48862118f,-0.87249601f}, {0.45399052f,-0.89100653f}, {0.41865975f,-0.90814316f}, +{0.38268343f,-0.92387956f}, {0.34611705f,-0.93819135f}, {0.30901697f,-0.95105654f}, +{0.27144039f,-0.96245527f}, {0.23344530f,-0.97236991f}, {0.19509023f,-0.98078531f}, +{0.15643437f,-0.98768836f}, {0.11753740f,-0.99306846f}, {0.078459084f,-0.99691731f}, +{0.039259788f,-0.99922901f}, {-4.3711388e-08f,-1.0000000f}, {-0.039259877f,-0.99922901f}, +{-0.078459173f,-0.99691731f}, {-0.11753749f,-0.99306846f}, {-0.15643445f,-0.98768836f}, +{-0.19509032f,-0.98078525f}, {-0.23344538f,-0.97236991f}, {-0.27144048f,-0.96245521f}, +{-0.30901703f,-0.95105648f}, {-0.34611711f,-0.93819129f}, {-0.38268352f,-0.92387950f}, +{-0.41865984f,-0.90814310f}, {-0.45399061f,-0.89100647f}, {-0.48862135f,-0.87249595f}, +{-0.52249867f,-0.85264009f}, {-0.55557036f,-0.83146954f}, {-0.58778518f,-0.80901700f}, +{-0.61909389f,-0.78531694f}, {-0.64944804f,-0.76040596f}, {-0.67880076f,-0.73432249f}, +{-0.70710677f,-0.70710677f}, {-0.73432249f,-0.67880070f}, {-0.76040596f,-0.64944804f}, +{-0.78531694f,-0.61909389f}, {-0.80901700f,-0.58778518f}, {-0.83146966f,-0.55557019f}, +{-0.85264021f,-0.52249849f}, {-0.87249607f,-0.48862115f}, {-0.89100659f,-0.45399037f}, +{-0.90814322f,-0.41865960f}, {-0.92387956f,-0.38268328f}, {-0.93819135f,-0.34611690f}, +{-0.95105654f,-0.30901679f}, {-0.96245521f,-0.27144048f}, {-0.97236991f,-0.23344538f}, +{-0.98078531f,-0.19509031f}, {-0.98768836f,-0.15643445f}, {-0.99306846f,-0.11753736f}, +{-0.99691737f,-0.078459039f}, {-0.99922901f,-0.039259743f}, {-1.0000000f,8.7422777e-08f}, +{-0.99922901f,0.039259918f}, {-0.99691731f,0.078459218f}, {-0.99306846f,0.11753753f}, +{-0.98768830f,0.15643461f}, {-0.98078525f,0.19509049f}, {-0.97236985f,0.23344554f}, +{-0.96245515f,0.27144065f}, {-0.95105654f,0.30901697f}, {-0.93819135f,0.34611705f}, +{-0.92387956f,0.38268346f}, {-0.90814316f,0.41865975f}, {-0.89100653f,0.45399055f}, +{-0.87249601f,0.48862129f}, {-0.85264015f,0.52249861f}, {-0.83146960f,0.55557030f}, +{-0.80901694f,0.58778536f}, {-0.78531688f,0.61909401f}, {-0.76040590f,0.64944816f}, +{-0.73432243f,0.67880082f}, {-0.70710665f,0.70710689f}, {-0.67880058f,0.73432261f}, +{-0.64944792f,0.76040608f}, {-0.61909378f,0.78531706f}, {-0.58778507f,0.80901712f}, +{-0.55557001f,0.83146977f}, {-0.52249837f,0.85264033f}, {-0.48862100f,0.87249613f}, +{-0.45399022f,0.89100665f}, {-0.41865945f,0.90814328f}, {-0.38268313f,0.92387968f}, +{-0.34611672f,0.93819147f}, {-0.30901709f,0.95105648f}, {-0.27144054f,0.96245521f}, +{-0.23344545f,0.97236991f}, {-0.19509038f,0.98078525f}, {-0.15643452f,0.98768830f}, +{-0.11753743f,0.99306846f}, {-0.078459114f,0.99691731f}, {-0.039259821f,0.99922901f}, +}; +static const ne10_fft_cpx_float32_t ne10_twiddles_240[240] = { +{1.0000000f,0.0000000f}, {1.0000000f,-0.0000000f}, {1.0000000f,-0.0000000f}, +{1.0000000f,-0.0000000f}, {0.91354543f,-0.40673664f}, {0.66913056f,-0.74314487f}, +{1.0000000f,-0.0000000f}, {0.66913056f,-0.74314487f}, {-0.10452851f,-0.99452192f}, +{1.0000000f,-0.0000000f}, {0.30901697f,-0.95105654f}, {-0.80901700f,-0.58778518f}, +{1.0000000f,-0.0000000f}, {-0.10452851f,-0.99452192f}, {-0.97814757f,0.20791179f}, +{1.0000000f,-0.0000000f}, {0.99452192f,-0.10452846f}, {0.97814763f,-0.20791170f}, +{0.95105648f,-0.30901700f}, {0.91354543f,-0.40673664f}, {0.86602545f,-0.50000000f}, +{0.80901700f,-0.58778524f}, {0.74314475f,-0.66913062f}, {0.66913056f,-0.74314487f}, +{0.58778524f,-0.80901700f}, {0.49999997f,-0.86602545f}, {0.40673661f,-0.91354549f}, +{0.30901697f,-0.95105654f}, {0.20791166f,-0.97814763f}, {0.10452842f,-0.99452192f}, +{1.0000000f,-0.0000000f}, {0.97814763f,-0.20791170f}, {0.91354543f,-0.40673664f}, +{0.80901700f,-0.58778524f}, {0.66913056f,-0.74314487f}, {0.49999997f,-0.86602545f}, +{0.30901697f,-0.95105654f}, {0.10452842f,-0.99452192f}, {-0.10452851f,-0.99452192f}, +{-0.30901703f,-0.95105648f}, {-0.50000006f,-0.86602533f}, {-0.66913068f,-0.74314475f}, +{-0.80901700f,-0.58778518f}, {-0.91354549f,-0.40673658f}, {-0.97814763f,-0.20791161f}, +{1.0000000f,-0.0000000f}, {0.95105648f,-0.30901700f}, {0.80901700f,-0.58778524f}, +{0.58778524f,-0.80901700f}, {0.30901697f,-0.95105654f}, {-4.3711388e-08f,-1.0000000f}, +{-0.30901703f,-0.95105648f}, {-0.58778518f,-0.80901700f}, {-0.80901700f,-0.58778518f}, +{-0.95105654f,-0.30901679f}, {-1.0000000f,8.7422777e-08f}, {-0.95105654f,0.30901697f}, +{-0.80901694f,0.58778536f}, {-0.58778507f,0.80901712f}, {-0.30901709f,0.95105648f}, +{1.0000000f,-0.0000000f}, {0.99965733f,-0.026176950f}, {0.99862951f,-0.052335959f}, +{0.99691731f,-0.078459099f}, {0.99452192f,-0.10452846f}, {0.99144489f,-0.13052620f}, +{0.98768836f,-0.15643448f}, {0.98325491f,-0.18223552f}, {0.97814763f,-0.20791170f}, +{0.97236991f,-0.23344538f}, {0.96592581f,-0.25881904f}, {0.95881975f,-0.28401536f}, +{0.95105648f,-0.30901700f}, {0.94264150f,-0.33380687f}, {0.93358040f,-0.35836795f}, +{0.92387956f,-0.38268346f}, {0.91354543f,-0.40673664f}, {0.90258527f,-0.43051112f}, +{0.89100653f,-0.45399052f}, {0.87881708f,-0.47715878f}, {0.86602545f,-0.50000000f}, +{0.85264015f,-0.52249855f}, {0.83867055f,-0.54463905f}, {0.82412618f,-0.56640625f}, +{0.80901700f,-0.58778524f}, {0.79335332f,-0.60876143f}, {0.77714598f,-0.62932038f}, +{0.76040596f,-0.64944810f}, {0.74314475f,-0.66913062f}, {0.72537434f,-0.68835455f}, +{0.70710677f,-0.70710683f}, {0.68835455f,-0.72537440f}, {0.66913056f,-0.74314487f}, +{0.64944804f,-0.76040596f}, {0.62932038f,-0.77714598f}, {0.60876137f,-0.79335338f}, +{0.58778524f,-0.80901700f}, {0.56640625f,-0.82412618f}, {0.54463899f,-0.83867055f}, +{0.52249849f,-0.85264015f}, {0.49999997f,-0.86602545f}, {0.47715876f,-0.87881708f}, +{0.45399052f,-0.89100653f}, {0.43051103f,-0.90258533f}, {0.40673661f,-0.91354549f}, +{0.38268343f,-0.92387956f}, {0.35836786f,-0.93358046f}, {0.33380681f,-0.94264150f}, +{0.30901697f,-0.95105654f}, {0.28401533f,-0.95881975f}, {0.25881907f,-0.96592581f}, +{0.23344530f,-0.97236991f}, {0.20791166f,-0.97814763f}, {0.18223552f,-0.98325491f}, +{0.15643437f,-0.98768836f}, {0.13052613f,-0.99144489f}, {0.10452842f,-0.99452192f}, +{0.078459084f,-0.99691731f}, {0.052335974f,-0.99862951f}, {0.026176875f,-0.99965733f}, +{1.0000000f,-0.0000000f}, {0.99862951f,-0.052335959f}, {0.99452192f,-0.10452846f}, +{0.98768836f,-0.15643448f}, {0.97814763f,-0.20791170f}, {0.96592581f,-0.25881904f}, +{0.95105648f,-0.30901700f}, {0.93358040f,-0.35836795f}, {0.91354543f,-0.40673664f}, +{0.89100653f,-0.45399052f}, {0.86602545f,-0.50000000f}, {0.83867055f,-0.54463905f}, +{0.80901700f,-0.58778524f}, {0.77714598f,-0.62932038f}, {0.74314475f,-0.66913062f}, +{0.70710677f,-0.70710683f}, {0.66913056f,-0.74314487f}, {0.62932038f,-0.77714598f}, +{0.58778524f,-0.80901700f}, {0.54463899f,-0.83867055f}, {0.49999997f,-0.86602545f}, +{0.45399052f,-0.89100653f}, {0.40673661f,-0.91354549f}, {0.35836786f,-0.93358046f}, +{0.30901697f,-0.95105654f}, {0.25881907f,-0.96592581f}, {0.20791166f,-0.97814763f}, +{0.15643437f,-0.98768836f}, {0.10452842f,-0.99452192f}, {0.052335974f,-0.99862951f}, +{-4.3711388e-08f,-1.0000000f}, {-0.052336060f,-0.99862951f}, {-0.10452851f,-0.99452192f}, +{-0.15643445f,-0.98768836f}, {-0.20791174f,-0.97814757f}, {-0.25881916f,-0.96592581f}, +{-0.30901703f,-0.95105648f}, {-0.35836795f,-0.93358040f}, {-0.40673670f,-0.91354543f}, +{-0.45399061f,-0.89100647f}, {-0.50000006f,-0.86602533f}, {-0.54463905f,-0.83867055f}, +{-0.58778518f,-0.80901700f}, {-0.62932050f,-0.77714586f}, {-0.66913068f,-0.74314475f}, +{-0.70710677f,-0.70710677f}, {-0.74314493f,-0.66913044f}, {-0.77714604f,-0.62932026f}, +{-0.80901700f,-0.58778518f}, {-0.83867055f,-0.54463899f}, {-0.86602539f,-0.50000006f}, +{-0.89100659f,-0.45399037f}, {-0.91354549f,-0.40673658f}, {-0.93358040f,-0.35836792f}, +{-0.95105654f,-0.30901679f}, {-0.96592587f,-0.25881892f}, {-0.97814763f,-0.20791161f}, +{-0.98768836f,-0.15643445f}, {-0.99452192f,-0.10452849f}, {-0.99862957f,-0.052335810f}, +{1.0000000f,-0.0000000f}, {0.99691731f,-0.078459099f}, {0.98768836f,-0.15643448f}, +{0.97236991f,-0.23344538f}, {0.95105648f,-0.30901700f}, {0.92387956f,-0.38268346f}, +{0.89100653f,-0.45399052f}, {0.85264015f,-0.52249855f}, {0.80901700f,-0.58778524f}, +{0.76040596f,-0.64944810f}, {0.70710677f,-0.70710683f}, {0.64944804f,-0.76040596f}, +{0.58778524f,-0.80901700f}, {0.52249849f,-0.85264015f}, {0.45399052f,-0.89100653f}, +{0.38268343f,-0.92387956f}, {0.30901697f,-0.95105654f}, {0.23344530f,-0.97236991f}, +{0.15643437f,-0.98768836f}, {0.078459084f,-0.99691731f}, {-4.3711388e-08f,-1.0000000f}, +{-0.078459173f,-0.99691731f}, {-0.15643445f,-0.98768836f}, {-0.23344538f,-0.97236991f}, +{-0.30901703f,-0.95105648f}, {-0.38268352f,-0.92387950f}, {-0.45399061f,-0.89100647f}, +{-0.52249867f,-0.85264009f}, {-0.58778518f,-0.80901700f}, {-0.64944804f,-0.76040596f}, +{-0.70710677f,-0.70710677f}, {-0.76040596f,-0.64944804f}, {-0.80901700f,-0.58778518f}, +{-0.85264021f,-0.52249849f}, {-0.89100659f,-0.45399037f}, {-0.92387956f,-0.38268328f}, +{-0.95105654f,-0.30901679f}, {-0.97236991f,-0.23344538f}, {-0.98768836f,-0.15643445f}, +{-0.99691737f,-0.078459039f}, {-1.0000000f,8.7422777e-08f}, {-0.99691731f,0.078459218f}, +{-0.98768830f,0.15643461f}, {-0.97236985f,0.23344554f}, {-0.95105654f,0.30901697f}, +{-0.92387956f,0.38268346f}, {-0.89100653f,0.45399055f}, {-0.85264015f,0.52249861f}, +{-0.80901694f,0.58778536f}, {-0.76040590f,0.64944816f}, {-0.70710665f,0.70710689f}, +{-0.64944792f,0.76040608f}, {-0.58778507f,0.80901712f}, {-0.52249837f,0.85264033f}, +{-0.45399022f,0.89100665f}, {-0.38268313f,0.92387968f}, {-0.30901709f,0.95105648f}, +{-0.23344545f,0.97236991f}, {-0.15643452f,0.98768830f}, {-0.078459114f,0.99691731f}, +}; +static const ne10_fft_cpx_float32_t ne10_twiddles_120[120] = { +{1.0000000f,0.0000000f}, {1.0000000f,-0.0000000f}, {1.0000000f,-0.0000000f}, +{1.0000000f,-0.0000000f}, {0.91354543f,-0.40673664f}, {0.66913056f,-0.74314487f}, +{1.0000000f,-0.0000000f}, {0.66913056f,-0.74314487f}, {-0.10452851f,-0.99452192f}, +{1.0000000f,-0.0000000f}, {0.30901697f,-0.95105654f}, {-0.80901700f,-0.58778518f}, +{1.0000000f,-0.0000000f}, {-0.10452851f,-0.99452192f}, {-0.97814757f,0.20791179f}, +{1.0000000f,-0.0000000f}, {0.97814763f,-0.20791170f}, {0.91354543f,-0.40673664f}, +{0.80901700f,-0.58778524f}, {0.66913056f,-0.74314487f}, {0.49999997f,-0.86602545f}, +{0.30901697f,-0.95105654f}, {0.10452842f,-0.99452192f}, {-0.10452851f,-0.99452192f}, +{-0.30901703f,-0.95105648f}, {-0.50000006f,-0.86602533f}, {-0.66913068f,-0.74314475f}, +{-0.80901700f,-0.58778518f}, {-0.91354549f,-0.40673658f}, {-0.97814763f,-0.20791161f}, +{1.0000000f,-0.0000000f}, {0.99862951f,-0.052335959f}, {0.99452192f,-0.10452846f}, +{0.98768836f,-0.15643448f}, {0.97814763f,-0.20791170f}, {0.96592581f,-0.25881904f}, +{0.95105648f,-0.30901700f}, {0.93358040f,-0.35836795f}, {0.91354543f,-0.40673664f}, +{0.89100653f,-0.45399052f}, {0.86602545f,-0.50000000f}, {0.83867055f,-0.54463905f}, +{0.80901700f,-0.58778524f}, {0.77714598f,-0.62932038f}, {0.74314475f,-0.66913062f}, +{0.70710677f,-0.70710683f}, {0.66913056f,-0.74314487f}, {0.62932038f,-0.77714598f}, +{0.58778524f,-0.80901700f}, {0.54463899f,-0.83867055f}, {0.49999997f,-0.86602545f}, +{0.45399052f,-0.89100653f}, {0.40673661f,-0.91354549f}, {0.35836786f,-0.93358046f}, +{0.30901697f,-0.95105654f}, {0.25881907f,-0.96592581f}, {0.20791166f,-0.97814763f}, +{0.15643437f,-0.98768836f}, {0.10452842f,-0.99452192f}, {0.052335974f,-0.99862951f}, +{1.0000000f,-0.0000000f}, {0.99452192f,-0.10452846f}, {0.97814763f,-0.20791170f}, +{0.95105648f,-0.30901700f}, {0.91354543f,-0.40673664f}, {0.86602545f,-0.50000000f}, +{0.80901700f,-0.58778524f}, {0.74314475f,-0.66913062f}, {0.66913056f,-0.74314487f}, +{0.58778524f,-0.80901700f}, {0.49999997f,-0.86602545f}, {0.40673661f,-0.91354549f}, +{0.30901697f,-0.95105654f}, {0.20791166f,-0.97814763f}, {0.10452842f,-0.99452192f}, +{-4.3711388e-08f,-1.0000000f}, {-0.10452851f,-0.99452192f}, {-0.20791174f,-0.97814757f}, +{-0.30901703f,-0.95105648f}, {-0.40673670f,-0.91354543f}, {-0.50000006f,-0.86602533f}, +{-0.58778518f,-0.80901700f}, {-0.66913068f,-0.74314475f}, {-0.74314493f,-0.66913044f}, +{-0.80901700f,-0.58778518f}, {-0.86602539f,-0.50000006f}, {-0.91354549f,-0.40673658f}, +{-0.95105654f,-0.30901679f}, {-0.97814763f,-0.20791161f}, {-0.99452192f,-0.10452849f}, +{1.0000000f,-0.0000000f}, {0.98768836f,-0.15643448f}, {0.95105648f,-0.30901700f}, +{0.89100653f,-0.45399052f}, {0.80901700f,-0.58778524f}, {0.70710677f,-0.70710683f}, +{0.58778524f,-0.80901700f}, {0.45399052f,-0.89100653f}, {0.30901697f,-0.95105654f}, +{0.15643437f,-0.98768836f}, {-4.3711388e-08f,-1.0000000f}, {-0.15643445f,-0.98768836f}, +{-0.30901703f,-0.95105648f}, {-0.45399061f,-0.89100647f}, {-0.58778518f,-0.80901700f}, +{-0.70710677f,-0.70710677f}, {-0.80901700f,-0.58778518f}, {-0.89100659f,-0.45399037f}, +{-0.95105654f,-0.30901679f}, {-0.98768836f,-0.15643445f}, {-1.0000000f,8.7422777e-08f}, +{-0.98768830f,0.15643461f}, {-0.95105654f,0.30901697f}, {-0.89100653f,0.45399055f}, +{-0.80901694f,0.58778536f}, {-0.70710665f,0.70710689f}, {-0.58778507f,0.80901712f}, +{-0.45399022f,0.89100665f}, {-0.30901709f,0.95105648f}, {-0.15643452f,0.98768830f}, +}; +static const ne10_fft_cpx_float32_t ne10_twiddles_60[60] = { +{1.0000000f,0.0000000f}, {1.0000000f,-0.0000000f}, {1.0000000f,-0.0000000f}, +{1.0000000f,-0.0000000f}, {0.91354543f,-0.40673664f}, {0.66913056f,-0.74314487f}, +{1.0000000f,-0.0000000f}, {0.66913056f,-0.74314487f}, {-0.10452851f,-0.99452192f}, +{1.0000000f,-0.0000000f}, {0.30901697f,-0.95105654f}, {-0.80901700f,-0.58778518f}, +{1.0000000f,-0.0000000f}, {-0.10452851f,-0.99452192f}, {-0.97814757f,0.20791179f}, +{1.0000000f,-0.0000000f}, {0.99452192f,-0.10452846f}, {0.97814763f,-0.20791170f}, +{0.95105648f,-0.30901700f}, {0.91354543f,-0.40673664f}, {0.86602545f,-0.50000000f}, +{0.80901700f,-0.58778524f}, {0.74314475f,-0.66913062f}, {0.66913056f,-0.74314487f}, +{0.58778524f,-0.80901700f}, {0.49999997f,-0.86602545f}, {0.40673661f,-0.91354549f}, +{0.30901697f,-0.95105654f}, {0.20791166f,-0.97814763f}, {0.10452842f,-0.99452192f}, +{1.0000000f,-0.0000000f}, {0.97814763f,-0.20791170f}, {0.91354543f,-0.40673664f}, +{0.80901700f,-0.58778524f}, {0.66913056f,-0.74314487f}, {0.49999997f,-0.86602545f}, +{0.30901697f,-0.95105654f}, {0.10452842f,-0.99452192f}, {-0.10452851f,-0.99452192f}, +{-0.30901703f,-0.95105648f}, {-0.50000006f,-0.86602533f}, {-0.66913068f,-0.74314475f}, +{-0.80901700f,-0.58778518f}, {-0.91354549f,-0.40673658f}, {-0.97814763f,-0.20791161f}, +{1.0000000f,-0.0000000f}, {0.95105648f,-0.30901700f}, {0.80901700f,-0.58778524f}, +{0.58778524f,-0.80901700f}, {0.30901697f,-0.95105654f}, {-4.3711388e-08f,-1.0000000f}, +{-0.30901703f,-0.95105648f}, {-0.58778518f,-0.80901700f}, {-0.80901700f,-0.58778518f}, +{-0.95105654f,-0.30901679f}, {-1.0000000f,8.7422777e-08f}, {-0.95105654f,0.30901697f}, +{-0.80901694f,0.58778536f}, {-0.58778507f,0.80901712f}, {-0.30901709f,0.95105648f}, +}; +static const ne10_fft_state_float32_t ne10_fft_state_float32_t_480 = { +120, +(ne10_int32_t *)ne10_factors_480, +(ne10_fft_cpx_float32_t *)ne10_twiddles_480, +NULL, +(ne10_fft_cpx_float32_t *)&ne10_twiddles_480[120], +/* is_forward_scaled = true */ +(ne10_int32_t) 1, +/* is_backward_scaled = false */ +(ne10_int32_t) 0, +}; +static const arch_fft_state cfg_arch_480 = { +1, +(void *)&ne10_fft_state_float32_t_480, +}; + +static const ne10_fft_state_float32_t ne10_fft_state_float32_t_240 = { +60, +(ne10_int32_t *)ne10_factors_240, +(ne10_fft_cpx_float32_t *)ne10_twiddles_240, +NULL, +(ne10_fft_cpx_float32_t *)&ne10_twiddles_240[60], +/* is_forward_scaled = true */ +(ne10_int32_t) 1, +/* is_backward_scaled = false */ +(ne10_int32_t) 0, +}; +static const arch_fft_state cfg_arch_240 = { +1, +(void *)&ne10_fft_state_float32_t_240, +}; + +static const ne10_fft_state_float32_t ne10_fft_state_float32_t_120 = { +30, +(ne10_int32_t *)ne10_factors_120, +(ne10_fft_cpx_float32_t *)ne10_twiddles_120, +NULL, +(ne10_fft_cpx_float32_t *)&ne10_twiddles_120[30], +/* is_forward_scaled = true */ +(ne10_int32_t) 1, +/* is_backward_scaled = false */ +(ne10_int32_t) 0, +}; +static const arch_fft_state cfg_arch_120 = { +1, +(void *)&ne10_fft_state_float32_t_120, +}; + +static const ne10_fft_state_float32_t ne10_fft_state_float32_t_60 = { +15, +(ne10_int32_t *)ne10_factors_60, +(ne10_fft_cpx_float32_t *)ne10_twiddles_60, +NULL, +(ne10_fft_cpx_float32_t *)&ne10_twiddles_60[15], +/* is_forward_scaled = true */ +(ne10_int32_t) 1, +/* is_backward_scaled = false */ +(ne10_int32_t) 0, +}; +static const arch_fft_state cfg_arch_60 = { +1, +(void *)&ne10_fft_state_float32_t_60, +}; + +#endif /* end NE10_FFT_PARAMS48000_960 */ diff --git a/drivers/opus/celt/tests/test_unit_cwrs32.c b/drivers/opus/celt/tests/test_unit_cwrs32.c deleted file mode 100644 index db43e3392b..0000000000 --- a/drivers/opus/celt/tests/test_unit_cwrs32.c +++ /dev/null @@ -1,161 +0,0 @@ -/* Copyright (c) 2008-2011 Xiph.Org Foundation, Mozilla Corporation, - Gregory Maxwell - Written by Jean-Marc Valin, Gregory Maxwell, and Timothy B. Terriberry */ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER - OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifdef OPUS_ENABLED -#include "opus/opus_config.h" -#endif - -#include <stdio.h> -#include <string.h> - -#ifndef CUSTOM_MODES -#define CUSTOM_MODES -#else -#define TEST_CUSTOM_MODES -#endif - -#define CELT_C -#include "opus/celt/stack_alloc.h" -#include "opus/celt/entenc.c" -#include "opus/celt/entdec.c" -#include "opus/celt/entcode.c" -#include "opus/celt/cwrs.c" -#include "opus/celt/mathops.c" -#include "opus/celt/rate.h" - -#define NMAX (240) -#define KMAX (128) - -#ifdef TEST_CUSTOM_MODES - -#define NDIMS (44) -static const int pn[NDIMS]={ - 2, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 18, 20, 22, - 24, 26, 28, 30, 32, 36, 40, 44, 48, - 52, 56, 60, 64, 72, 80, 88, 96, 104, - 112, 120, 128, 144, 160, 176, 192, 208 -}; -static const int pkmax[NDIMS]={ - 128, 128, 128, 128, 88, 52, 36, 26, 22, - 18, 16, 15, 13, 12, 12, 11, 10, 9, - 9, 8, 8, 7, 7, 7, 7, 6, 6, - 6, 6, 6, 5, 5, 5, 5, 5, 5, - 4, 4, 4, 4, 4, 4, 4, 4 -}; - -#else /* TEST_CUSTOM_MODES */ - -#define NDIMS (22) -static const int pn[NDIMS]={ - 2, 3, 4, 6, 8, 9, 11, 12, 16, - 18, 22, 24, 32, 36, 44, 48, 64, 72, - 88, 96, 144, 176 -}; -static const int pkmax[NDIMS]={ - 128, 128, 128, 88, 36, 26, 18, 16, 12, - 11, 9, 9, 7, 7, 6, 6, 5, 5, - 5, 5, 4, 4 -}; - -#endif - -int main(void){ - int t; - int n; - ALLOC_STACK; - for(t=0;t<NDIMS;t++){ - int pseudo; - n=pn[t]; - for(pseudo=1;pseudo<41;pseudo++) - { - int k; -#if defined(SMALL_FOOTPRINT) - opus_uint32 uu[KMAX+2U]; -#endif - opus_uint32 inc; - opus_uint32 nc; - opus_uint32 i; - k=get_pulses(pseudo); - if (k>pkmax[t])break; - printf("Testing CWRS with N=%i, K=%i...\n",n,k); -#if defined(SMALL_FOOTPRINT) - nc=ncwrs_urow(n,k,uu); -#else - nc=CELT_PVQ_V(n,k); -#endif - inc=nc/20000; - if(inc<1)inc=1; - for(i=0;i<nc;i+=inc){ -#if defined(SMALL_FOOTPRINT) - opus_uint32 u[KMAX+2U]; -#endif - int y[NMAX]; - int sy; - opus_uint32 v; - opus_uint32 ii; - int j; -#if defined(SMALL_FOOTPRINT) - memcpy(u,uu,(k+2U)*sizeof(*u)); - cwrsi(n,k,i,y,u); -#else - cwrsi(n,k,i,y); -#endif - sy=0; - for(j=0;j<n;j++)sy+=ABS(y[j]); - if(sy!=k){ - fprintf(stderr,"N=%d Pulse count mismatch in cwrsi (%d!=%d).\n", - n,sy,k); - return 99; - } - /*printf("%6u of %u:",i,nc); - for(j=0;j<n;j++)printf(" %+3i",y[j]); - printf(" ->");*/ -#if defined(SMALL_FOOTPRINT) - ii=icwrs(n,k,&v,y,u); -#else - ii=icwrs(n,y); - v=CELT_PVQ_V(n,k); -#endif - if(ii!=i){ - fprintf(stderr,"Combination-index mismatch (%lu!=%lu).\n", - (long)ii,(long)i); - return 1; - } - if(v!=nc){ - fprintf(stderr,"Combination count mismatch (%lu!=%lu).\n", - (long)v,(long)nc); - return 2; - } - /*printf(" %6u\n",i);*/ - } - /*printf("\n");*/ - } - } - return 0; -} diff --git a/drivers/opus/celt/tests/test_unit_dft.c b/drivers/opus/celt/tests/test_unit_dft.c deleted file mode 100644 index 9c0db3e9ac..0000000000 --- a/drivers/opus/celt/tests/test_unit_dft.c +++ /dev/null @@ -1,164 +0,0 @@ -/* Copyright (c) 2008 Xiph.Org Foundation - Written by Jean-Marc Valin */ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER - OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifdef OPUS_ENABLED -#include "opus/opus_config.h" -#endif - -#define SKIP_CONFIG_H - -#ifndef CUSTOM_MODES -#define CUSTOM_MODES -#endif - -#include <stdio.h> - -#define CELT_C -#include "opus/celt/stack_alloc.h" -#include "opus/celt/kiss_fft.h" -#include "opus/celt/kiss_fft.c" -#include "opus/celt/mathops.c" -#include "opus/celt/entcode.c" - - -#ifndef M_PI -#define M_PI 3.141592653 -#endif - -int ret = 0; - -void check(kiss_fft_cpx * in,kiss_fft_cpx * out,int nfft,int isinverse) -{ - int bin,k; - double errpow=0,sigpow=0, snr; - - for (bin=0;bin<nfft;++bin) { - double ansr = 0; - double ansi = 0; - double difr; - double difi; - - for (k=0;k<nfft;++k) { - double phase = -2*M_PI*bin*k/nfft; - double re = cos(phase); - double im = sin(phase); - if (isinverse) - im = -im; - - if (!isinverse) - { - re /= nfft; - im /= nfft; - } - - ansr += in[k].r * re - in[k].i * im; - ansi += in[k].r * im + in[k].i * re; - } - /*printf ("%d %d ", (int)ansr, (int)ansi);*/ - difr = ansr - out[bin].r; - difi = ansi - out[bin].i; - errpow += difr*difr + difi*difi; - sigpow += ansr*ansr+ansi*ansi; - } - snr = 10*log10(sigpow/errpow); - printf("nfft=%d inverse=%d,snr = %f\n",nfft,isinverse,snr ); - if (snr<60) { - printf( "** poor snr: %f ** \n", snr); - ret = 1; - } -} - -void test1d(int nfft,int isinverse) -{ - size_t buflen = sizeof(kiss_fft_cpx)*nfft; - - kiss_fft_cpx * in = (kiss_fft_cpx*)malloc(buflen); - kiss_fft_cpx * out= (kiss_fft_cpx*)malloc(buflen); - kiss_fft_state *cfg = opus_fft_alloc(nfft,0,0); - int k; - - for (k=0;k<nfft;++k) { - in[k].r = (rand() % 32767) - 16384; - in[k].i = (rand() % 32767) - 16384; - } - - for (k=0;k<nfft;++k) { - in[k].r *= 32768; - in[k].i *= 32768; - } - - if (isinverse) - { - for (k=0;k<nfft;++k) { - in[k].r /= nfft; - in[k].i /= nfft; - } - } - - /*for (k=0;k<nfft;++k) printf("%d %d ", in[k].r, in[k].i);printf("\n");*/ - - if (isinverse) - opus_ifft(cfg,in,out); - else - opus_fft(cfg,in,out); - - /*for (k=0;k<nfft;++k) printf("%d %d ", out[k].r, out[k].i);printf("\n");*/ - - check(in,out,nfft,isinverse); - - free(in); - free(out); - free(cfg); -} - -int main(int argc,char ** argv) -{ - ALLOC_STACK; - if (argc>1) { - int k; - for (k=1;k<argc;++k) { - test1d(atoi(argv[k]),0); - test1d(atoi(argv[k]),1); - } - }else{ - test1d(32,0); - test1d(32,1); - test1d(128,0); - test1d(128,1); - test1d(256,0); - test1d(256,1); -#ifndef RADIX_TWO_ONLY - test1d(36,0); - test1d(36,1); - test1d(50,0); - test1d(50,1); - test1d(120,0); - test1d(120,1); -#endif - } - return ret; -} diff --git a/drivers/opus/celt/tests/test_unit_entropy.c b/drivers/opus/celt/tests/test_unit_entropy.c deleted file mode 100644 index 8c2defa8b3..0000000000 --- a/drivers/opus/celt/tests/test_unit_entropy.c +++ /dev/null @@ -1,382 +0,0 @@ -/* Copyright (c) 2007-2011 Xiph.Org Foundation, Mozilla Corporation, - Gregory Maxwell - Written by Jean-Marc Valin, Gregory Maxwell, and Timothy B. Terriberry */ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER - OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifdef OPUS_ENABLED -#include "opus/opus_config.h" -#endif - -#include <stdlib.h> -#include <stdio.h> -#include <math.h> -#include <time.h> -#include "opus/celt/entcode.h" -#include "opus/celt/entenc.h" -#include "opus/celt/entdec.h" -#include <string.h> - -#include "opus/celt/entenc.c" -#include "opus/celt/entdec.c" -#include "opus/celt/entcode.c" - -#ifndef M_LOG2E -# define M_LOG2E 1.4426950408889634074 -#endif -#define DATA_SIZE 10000000 -#define DATA_SIZE2 10000 - -int main(int _argc,char **_argv){ - ec_enc enc; - ec_dec dec; - long nbits; - long nbits2; - double entropy; - int ft; - int ftb; - int sz; - int i; - int ret; - unsigned int sym; - unsigned int seed; - unsigned char *ptr; - const char *env_seed; - ret=0; - entropy=0; - if (_argc > 2) { - fprintf(stderr, "Usage: %s [<seed>]\n", _argv[0]); - return 1; - } - env_seed = getenv("SEED"); - if (_argc > 1) - seed = atoi(_argv[1]); - else if (env_seed) - seed = atoi(env_seed); - else - seed = time(NULL); - /*Testing encoding of raw bit values.*/ - ptr = (unsigned char *)malloc(DATA_SIZE); - ec_enc_init(&enc,ptr, DATA_SIZE); - for(ft=2;ft<1024;ft++){ - for(i=0;i<ft;i++){ - entropy+=log(ft)*M_LOG2E; - ec_enc_uint(&enc,i,ft); - } - } - /*Testing encoding of raw bit values.*/ - for(ftb=1;ftb<16;ftb++){ - for(i=0;i<(1<<ftb);i++){ - entropy+=ftb; - nbits=ec_tell(&enc); - ec_enc_bits(&enc,i,ftb); - nbits2=ec_tell(&enc); - if(nbits2-nbits!=ftb){ - fprintf(stderr,"Used %li bits to encode %i bits directly.\n", - nbits2-nbits,ftb); - ret=-1; - } - } - } - nbits=ec_tell_frac(&enc); - ec_enc_done(&enc); - fprintf(stderr, - "Encoded %0.2lf bits of entropy to %0.2lf bits (%0.3lf%% wasted).\n", - entropy,ldexp(nbits,-3),100*(nbits-ldexp(entropy,3))/nbits); - fprintf(stderr,"Packed to %li bytes.\n",(long)ec_range_bytes(&enc)); - ec_dec_init(&dec,ptr,DATA_SIZE); - for(ft=2;ft<1024;ft++){ - for(i=0;i<ft;i++){ - sym=ec_dec_uint(&dec,ft); - if(sym!=(unsigned)i){ - fprintf(stderr,"Decoded %i instead of %i with ft of %i.\n",sym,i,ft); - ret=-1; - } - } - } - for(ftb=1;ftb<16;ftb++){ - for(i=0;i<(1<<ftb);i++){ - sym=ec_dec_bits(&dec,ftb); - if(sym!=(unsigned)i){ - fprintf(stderr,"Decoded %i instead of %i with ftb of %i.\n",sym,i,ftb); - ret=-1; - } - } - } - nbits2=ec_tell_frac(&dec); - if(nbits!=nbits2){ - fprintf(stderr, - "Reported number of bits used was %0.2lf, should be %0.2lf.\n", - ldexp(nbits2,-3),ldexp(nbits,-3)); - ret=-1; - } - /*Testing an encoder bust prefers range coder data over raw bits. - This isn't a general guarantee, will only work for data that is buffered in - the encoder state and not yet stored in the user buffer, and should never - get used in practice. - It's mostly here for code coverage completeness.*/ - /*Start with a 16-bit buffer.*/ - ec_enc_init(&enc,ptr,2); - /*Write 7 raw bits.*/ - ec_enc_bits(&enc,0x55,7); - /*Write 12.3 bits of range coder data.*/ - ec_enc_uint(&enc,1,2); - ec_enc_uint(&enc,1,3); - ec_enc_uint(&enc,1,4); - ec_enc_uint(&enc,1,5); - ec_enc_uint(&enc,2,6); - ec_enc_uint(&enc,6,7); - ec_enc_done(&enc); - ec_dec_init(&dec,ptr,2); - if(!enc.error - /*The raw bits should have been overwritten by the range coder data.*/ - ||ec_dec_bits(&dec,7)!=0x05 - /*And all the range coder data should have been encoded correctly.*/ - ||ec_dec_uint(&dec,2)!=1 - ||ec_dec_uint(&dec,3)!=1 - ||ec_dec_uint(&dec,4)!=1 - ||ec_dec_uint(&dec,5)!=1 - ||ec_dec_uint(&dec,6)!=2 - ||ec_dec_uint(&dec,7)!=6){ - fprintf(stderr,"Encoder bust overwrote range coder data with raw bits.\n"); - ret=-1; - } - srand(seed); - fprintf(stderr,"Testing random streams... Random seed: %u (%.4X)\n", seed, rand() % 65536); - for(i=0;i<409600;i++){ - unsigned *data; - unsigned *tell; - unsigned tell_bits; - int j; - int zeros; - ft=rand()/((RAND_MAX>>(rand()%11U))+1U)+10; - sz=rand()/((RAND_MAX>>(rand()%9U))+1U); - data=(unsigned *)malloc(sz*sizeof(*data)); - tell=(unsigned *)malloc((sz+1)*sizeof(*tell)); - ec_enc_init(&enc,ptr,DATA_SIZE2); - zeros = rand()%13==0; - tell[0]=ec_tell_frac(&enc); - for(j=0;j<sz;j++){ - if (zeros) - data[j]=0; - else - data[j]=rand()%ft; - ec_enc_uint(&enc,data[j],ft); - tell[j+1]=ec_tell_frac(&enc); - } - if (rand()%2==0) - while(ec_tell(&enc)%8 != 0) - ec_enc_uint(&enc, rand()%2, 2); - tell_bits = ec_tell(&enc); - ec_enc_done(&enc); - if(tell_bits!=(unsigned)ec_tell(&enc)){ - fprintf(stderr,"ec_tell() changed after ec_enc_done(): %i instead of %i (Random seed: %u)\n", - ec_tell(&enc),tell_bits,seed); - ret=-1; - } - if ((tell_bits+7)/8 < ec_range_bytes(&enc)) - { - fprintf (stderr, "ec_tell() lied, there's %i bytes instead of %d (Random seed: %u)\n", - ec_range_bytes(&enc), (tell_bits+7)/8,seed); - ret=-1; - } - ec_dec_init(&dec,ptr,DATA_SIZE2); - if(ec_tell_frac(&dec)!=tell[0]){ - fprintf(stderr, - "Tell mismatch between encoder and decoder at symbol %i: %i instead of %i (Random seed: %u).\n", - 0,ec_tell_frac(&dec),tell[0],seed); - } - for(j=0;j<sz;j++){ - sym=ec_dec_uint(&dec,ft); - if(sym!=data[j]){ - fprintf(stderr, - "Decoded %i instead of %i with ft of %i at position %i of %i (Random seed: %u).\n", - sym,data[j],ft,j,sz,seed); - ret=-1; - } - if(ec_tell_frac(&dec)!=tell[j+1]){ - fprintf(stderr, - "Tell mismatch between encoder and decoder at symbol %i: %i instead of %i (Random seed: %u).\n", - j+1,ec_tell_frac(&dec),tell[j+1],seed); - } - } - free(tell); - free(data); - } - /*Test compatibility between multiple different encode/decode routines.*/ - for(i=0;i<409600;i++){ - unsigned *logp1; - unsigned *data; - unsigned *tell; - unsigned *enc_method; - int j; - sz=rand()/((RAND_MAX>>(rand()%9U))+1U); - logp1=(unsigned *)malloc(sz*sizeof(*logp1)); - data=(unsigned *)malloc(sz*sizeof(*data)); - tell=(unsigned *)malloc((sz+1)*sizeof(*tell)); - enc_method=(unsigned *)malloc(sz*sizeof(*enc_method)); - ec_enc_init(&enc,ptr,DATA_SIZE2); - tell[0]=ec_tell_frac(&enc); - for(j=0;j<sz;j++){ - data[j]=rand()/((RAND_MAX>>1)+1); - logp1[j]=(rand()%15)+1; - enc_method[j]=rand()/((RAND_MAX>>2)+1); - switch(enc_method[j]){ - case 0:{ - ec_encode(&enc,data[j]?(1<<logp1[j])-1:0, - (1<<logp1[j])-(data[j]?0:1),1<<logp1[j]); - }break; - case 1:{ - ec_encode_bin(&enc,data[j]?(1<<logp1[j])-1:0, - (1<<logp1[j])-(data[j]?0:1),logp1[j]); - }break; - case 2:{ - ec_enc_bit_logp(&enc,data[j],logp1[j]); - }break; - case 3:{ - unsigned char icdf[2]; - icdf[0]=1; - icdf[1]=0; - ec_enc_icdf(&enc,data[j],icdf,logp1[j]); - }break; - } - tell[j+1]=ec_tell_frac(&enc); - } - ec_enc_done(&enc); - if((ec_tell(&enc)+7U)/8U<ec_range_bytes(&enc)){ - fprintf(stderr,"tell() lied, there's %i bytes instead of %d (Random seed: %u)\n", - ec_range_bytes(&enc),(ec_tell(&enc)+7)/8,seed); - ret=-1; - } - ec_dec_init(&dec,ptr,DATA_SIZE2); - if(ec_tell_frac(&dec)!=tell[0]){ - fprintf(stderr, - "Tell mismatch between encoder and decoder at symbol %i: %i instead of %i (Random seed: %u).\n", - 0,ec_tell_frac(&dec),tell[0],seed); - } - for(j=0;j<sz;j++){ - int fs; - int dec_method; - dec_method=rand()/((RAND_MAX>>2)+1); - switch(dec_method){ - case 0:{ - fs=ec_decode(&dec,1<<logp1[j]); - sym=fs>=(1<<logp1[j])-1; - ec_dec_update(&dec,sym?(1<<logp1[j])-1:0, - (1<<logp1[j])-(sym?0:1),1<<logp1[j]); - }break; - case 1:{ - fs=ec_decode_bin(&dec,logp1[j]); - sym=fs>=(1<<logp1[j])-1; - ec_dec_update(&dec,sym?(1<<logp1[j])-1:0, - (1<<logp1[j])-(sym?0:1),1<<logp1[j]); - }break; - case 2:{ - sym=ec_dec_bit_logp(&dec,logp1[j]); - }break; - case 3:{ - unsigned char icdf[2]; - icdf[0]=1; - icdf[1]=0; - sym=ec_dec_icdf(&dec,icdf,logp1[j]); - }break; - } - if(sym!=data[j]){ - fprintf(stderr, - "Decoded %i instead of %i with logp1 of %i at position %i of %i (Random seed: %u).\n", - sym,data[j],logp1[j],j,sz,seed); - fprintf(stderr,"Encoding method: %i, decoding method: %i\n", - enc_method[j],dec_method); - ret=-1; - } - if(ec_tell_frac(&dec)!=tell[j+1]){ - fprintf(stderr, - "Tell mismatch between encoder and decoder at symbol %i: %i instead of %i (Random seed: %u).\n", - j+1,ec_tell_frac(&dec),tell[j+1],seed); - } - } - free(enc_method); - free(tell); - free(data); - free(logp1); - } - ec_enc_init(&enc,ptr,DATA_SIZE2); - ec_enc_bit_logp(&enc,0,1); - ec_enc_bit_logp(&enc,0,1); - ec_enc_bit_logp(&enc,0,1); - ec_enc_bit_logp(&enc,0,1); - ec_enc_bit_logp(&enc,0,2); - ec_enc_patch_initial_bits(&enc,3,2); - if(enc.error){ - fprintf(stderr,"patch_initial_bits failed"); - ret=-1; - } - ec_enc_patch_initial_bits(&enc,0,5); - if(!enc.error){ - fprintf(stderr,"patch_initial_bits didn't fail when it should have"); - ret=-1; - } - ec_enc_done(&enc); - if(ec_range_bytes(&enc)!=1||ptr[0]!=192){ - fprintf(stderr,"Got %d when expecting 192 for patch_initial_bits",ptr[0]); - ret=-1; - } - ec_enc_init(&enc,ptr,DATA_SIZE2); - ec_enc_bit_logp(&enc,0,1); - ec_enc_bit_logp(&enc,0,1); - ec_enc_bit_logp(&enc,1,6); - ec_enc_bit_logp(&enc,0,2); - ec_enc_patch_initial_bits(&enc,0,2); - if(enc.error){ - fprintf(stderr,"patch_initial_bits failed"); - ret=-1; - } - ec_enc_done(&enc); - if(ec_range_bytes(&enc)!=2||ptr[0]!=63){ - fprintf(stderr,"Got %d when expecting 63 for patch_initial_bits",ptr[0]); - ret=-1; - } - ec_enc_init(&enc,ptr,2); - ec_enc_bit_logp(&enc,0,2); - for(i=0;i<48;i++){ - ec_enc_bits(&enc,0,1); - } - ec_enc_done(&enc); - if(!enc.error){ - fprintf(stderr,"Raw bits overfill didn't fail when it should have"); - ret=-1; - } - ec_enc_init(&enc,ptr,2); - for(i=0;i<17;i++){ - ec_enc_bits(&enc,0,1); - } - ec_enc_done(&enc); - if(!enc.error){ - fprintf(stderr,"17 raw bits encoded in two bytes"); - ret=-1; - } - free(ptr); - return ret; -} diff --git a/drivers/opus/celt/tests/test_unit_laplace.c b/drivers/opus/celt/tests/test_unit_laplace.c deleted file mode 100644 index e4fe83c4d6..0000000000 --- a/drivers/opus/celt/tests/test_unit_laplace.c +++ /dev/null @@ -1,92 +0,0 @@ -/* Copyright (c) 2008-2011 Xiph.Org Foundation, Mozilla Corporation - Written by Jean-Marc Valin and Timothy B. Terriberry */ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER - OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifdef OPUS_ENABLED -#include "opus/opus_config.h" -#endif - -#include <stdio.h> -#include <stdlib.h> -#include "opus/celt/laplace.h" -#define CELT_C -#include "opus/celt/stack_alloc.h" - -#include "opus/celt/entenc.c" -#include "opus/celt/entdec.c" -#include "opus/celt/entcode.c" -#include "opus/celt/laplace.c" - -#define DATA_SIZE 40000 - -int ec_laplace_get_start_freq(int decay) -{ - opus_uint32 ft = 32768 - LAPLACE_MINP*(2*LAPLACE_NMIN+1); - int fs = (ft*(16384-decay))/(16384+decay); - return fs+LAPLACE_MINP; -} - -int main(void) -{ - int i; - int ret = 0; - ec_enc enc; - ec_dec dec; - unsigned char *ptr; - int val[10000], decay[10000]; - ALLOC_STACK; - ptr = (unsigned char *)malloc(DATA_SIZE); - ec_enc_init(&enc,ptr,DATA_SIZE); - - val[0] = 3; decay[0] = 6000; - val[1] = 0; decay[1] = 5800; - val[2] = -1; decay[2] = 5600; - for (i=3;i<10000;i++) - { - val[i] = rand()%15-7; - decay[i] = rand()%11000+5000; - } - for (i=0;i<10000;i++) - ec_laplace_encode(&enc, &val[i], - ec_laplace_get_start_freq(decay[i]), decay[i]); - - ec_enc_done(&enc); - - ec_dec_init(&dec,ec_get_buffer(&enc),ec_range_bytes(&enc)); - - for (i=0;i<10000;i++) - { - int d = ec_laplace_decode(&dec, - ec_laplace_get_start_freq(decay[i]), decay[i]); - if (d != val[i]) - { - fprintf (stderr, "Got %d instead of %d\n", d, val[i]); - ret = 1; - } - } - - return ret; -} diff --git a/drivers/opus/celt/tests/test_unit_mathops.c b/drivers/opus/celt/tests/test_unit_mathops.c deleted file mode 100644 index 0e3f300d40..0000000000 --- a/drivers/opus/celt/tests/test_unit_mathops.c +++ /dev/null @@ -1,275 +0,0 @@ -/* Copyright (c) 2008-2011 Xiph.Org Foundation, Mozilla Corporation, - Gregory Maxwell - Written by Jean-Marc Valin, Gregory Maxwell, and Timothy B. Terriberry */ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER - OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifdef OPUS_ENABLED -#include "opus/opus_config.h" -#endif - -#ifndef CUSTOM_MODES -#define CUSTOM_MODES -#endif - -#define CELT_C - -#include "opus/celt/mathops.c" -#include "opus/celt/entenc.c" -#include "opus/celt/entdec.c" -#include "opus/celt/entcode.c" -#include "opus/celt/bands.c" -#include "opus/celt/quant_bands.c" -#include "opus/celt/laplace.c" -#include "opus/celt/vq.c" -#include "opus/celt/cwrs.c" -#include <stdio.h> -#include <math.h> - -#ifdef OPUS_FIXED_POINT -#define WORD "%d" -#else -#define WORD "%f" -#endif - -int ret = 0; - -void testdiv(void) -{ - opus_int32 i; - for (i=1;i<=327670;i++) - { - double prod; - opus_val32 val; - val = celt_rcp(i); -#ifdef OPUS_FIXED_POINT - prod = (1./32768./65526.)*val*i; -#else - prod = val*i; -#endif - if (fabs(prod-1) > .00025) - { - fprintf (stderr, "div failed: 1/%d="WORD" (product = %f)\n", i, val, prod); - ret = 1; - } - } -} - -void testsqrt(void) -{ - opus_int32 i; - for (i=1;i<=1000000000;i++) - { - double ratio; - opus_val16 val; - val = celt_sqrt(i); - ratio = val/sqrt(i); - if (fabs(ratio - 1) > .0005 && fabs(val-sqrt(i)) > 2) - { - fprintf (stderr, "sqrt failed: sqrt(%d)="WORD" (ratio = %f)\n", i, val, ratio); - ret = 1; - } - i+= i>>10; - } -} - -void testbitexactcos(void) -{ - int i; - opus_int32 min_d,max_d,last,chk; - chk=max_d=0; - last=min_d=32767; - for(i=64;i<=16320;i++) - { - opus_int32 d; - opus_int32 q=bitexact_cos(i); - chk ^= q*i; - d = last - q; - if (d>max_d)max_d=d; - if (d<min_d)min_d=d; - last = q; - } - if ((chk!=89408644)||(max_d!=5)||(min_d!=0)||(bitexact_cos(64)!=32767)|| - (bitexact_cos(16320)!=200)||(bitexact_cos(8192)!=23171)) - { - fprintf (stderr, "bitexact_cos failed\n"); - ret = 1; - } -} - -void testbitexactlog2tan(void) -{ - int i,fail; - opus_int32 min_d,max_d,last,chk; - fail=chk=max_d=0; - last=min_d=15059; - for(i=64;i<8193;i++) - { - opus_int32 d; - opus_int32 mid=bitexact_cos(i); - opus_int32 side=bitexact_cos(16384-i); - opus_int32 q=bitexact_log2tan(mid,side); - chk ^= q*i; - d = last - q; - if (q!=-1*bitexact_log2tan(side,mid)) - fail = 1; - if (d>max_d)max_d=d; - if (d<min_d)min_d=d; - last = q; - } - if ((chk!=15821257)||(max_d!=61)||(min_d!=-2)||fail|| - (bitexact_log2tan(32767,200)!=15059)||(bitexact_log2tan(30274,12540)!=2611)|| - (bitexact_log2tan(23171,23171)!=0)) - { - fprintf (stderr, "bitexact_log2tan failed\n"); - ret = 1; - } -} - -#ifndef OPUS_FIXED_POINT -void testlog2(void) -{ - float x; - for (x=0.001;x<1677700.0;x+=(x/8.0)) - { - float error = fabs((1.442695040888963387*log(x))-celt_log2(x)); - if (error>0.0009) - { - fprintf (stderr, "celt_log2 failed: fabs((1.442695040888963387*log(x))-celt_log2(x))>0.001 (x = %f, error = %f)\n", x,error); - ret = 1; - } - } -} - -void testexp2(void) -{ - float x; - for (x=-11.0;x<24.0;x+=0.0007) - { - float error = fabs(x-(1.442695040888963387*log(celt_exp2(x)))); - if (error>0.0002) - { - fprintf (stderr, "celt_exp2 failed: fabs(x-(1.442695040888963387*log(celt_exp2(x))))>0.0005 (x = %f, error = %f)\n", x,error); - ret = 1; - } - } -} - -void testexp2log2(void) -{ - float x; - for (x=-11.0;x<24.0;x+=0.0007) - { - float error = fabs(x-(celt_log2(celt_exp2(x)))); - if (error>0.001) - { - fprintf (stderr, "celt_log2/celt_exp2 failed: fabs(x-(celt_log2(celt_exp2(x))))>0.001 (x = %f, error = %f)\n", x,error); - ret = 1; - } - } -} -#else -void testlog2(void) -{ - opus_val32 x; - for (x=8;x<1073741824;x+=(x>>3)) - { - float error = fabs((1.442695040888963387*log(x/16384.0))-celt_log2(x)/1024.0); - if (error>0.003) - { - fprintf (stderr, "celt_log2 failed: x = %ld, error = %f\n", (long)x,error); - ret = 1; - } - } -} - -void testexp2(void) -{ - opus_val16 x; - for (x=-32768;x<15360;x++) - { - float error1 = fabs(x/1024.0-(1.442695040888963387*log(celt_exp2(x)/65536.0))); - float error2 = fabs(exp(0.6931471805599453094*x/1024.0)-celt_exp2(x)/65536.0); - if (error1>0.0002&&error2>0.00004) - { - fprintf (stderr, "celt_exp2 failed: x = "WORD", error1 = %f, error2 = %f\n", x,error1,error2); - ret = 1; - } - } -} - -void testexp2log2(void) -{ - opus_val32 x; - for (x=8;x<65536;x+=(x>>3)) - { - float error = fabs(x-0.25*celt_exp2(celt_log2(x)))/16384; - if (error>0.004) - { - fprintf (stderr, "celt_log2/celt_exp2 failed: fabs(x-(celt_exp2(celt_log2(x))))>0.001 (x = %ld, error = %f)\n", (long)x,error); - ret = 1; - } - } -} - -void testilog2(void) -{ - opus_val32 x; - for (x=1;x<=268435455;x+=127) - { - opus_val32 lg; - opus_val32 y; - - lg = celt_ilog2(x); - if (lg<0 || lg>=31) - { - printf("celt_ilog2 failed: 0<=celt_ilog2(x)<31 (x = %d, celt_ilog2(x) = %d)\n",x,lg); - ret = 1; - } - y = 1<<lg; - - if (x<y || (x>>1)>=y) - { - printf("celt_ilog2 failed: 2**celt_ilog2(x)<=x<2**(celt_ilog2(x)+1) (x = %d, 2**celt_ilog2(x) = %d)\n",x,y); - ret = 1; - } - } -} -#endif - -int main(void) -{ - testbitexactcos(); - testbitexactlog2tan(); - testdiv(); - testsqrt(); - testlog2(); - testexp2(); - testexp2log2(); -#ifdef OPUS_FIXED_POINT - testilog2(); -#endif - return ret; -} diff --git a/drivers/opus/celt/tests/test_unit_mdct.c b/drivers/opus/celt/tests/test_unit_mdct.c deleted file mode 100644 index 0be03db2e8..0000000000 --- a/drivers/opus/celt/tests/test_unit_mdct.c +++ /dev/null @@ -1,210 +0,0 @@ -/* Copyright (c) 2008-2011 Xiph.Org Foundation - Written by Jean-Marc Valin */ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER - OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifdef OPUS_ENABLED -#include "opus/opus_config.h" -#endif - -#define SKIP_CONFIG_H - -#ifndef CUSTOM_MODES -#define CUSTOM_MODES -#endif - -#include <stdio.h> - -#define CELT_C -#include "opus/celt/mdct.h" -#include "opus/celt/stack_alloc.h" - -#include "opus/celt/kiss_fft.c" -#include "opus/celt/mdct.c" -#include "opus/celt/mathops.c" -#include "opus/celt/entcode.c" - -#ifndef M_PI -#define M_PI 3.141592653 -#endif - -int ret = 0; -void check(kiss_fft_scalar * in,kiss_fft_scalar * out,int nfft,int isinverse) -{ - int bin,k; - double errpow=0,sigpow=0; - double snr; - for (bin=0;bin<nfft/2;++bin) { - double ansr = 0; - double difr; - - for (k=0;k<nfft;++k) { - double phase = 2*M_PI*(k+.5+.25*nfft)*(bin+.5)/nfft; - double re = cos(phase); - - re /= nfft/4; - - ansr += in[k] * re; - } - /*printf ("%f %f\n", ansr, out[bin]);*/ - difr = ansr - out[bin]; - errpow += difr*difr; - sigpow += ansr*ansr; - } - snr = 10*log10(sigpow/errpow); - printf("nfft=%d inverse=%d,snr = %f\n",nfft,isinverse,snr ); - if (snr<60) { - printf( "** poor snr: %f **\n", snr); - ret = 1; - } -} - -void check_inv(kiss_fft_scalar * in,kiss_fft_scalar * out,int nfft,int isinverse) -{ - int bin,k; - double errpow=0,sigpow=0; - double snr; - for (bin=0;bin<nfft;++bin) { - double ansr = 0; - double difr; - - for (k=0;k<nfft/2;++k) { - double phase = 2*M_PI*(bin+.5+.25*nfft)*(k+.5)/nfft; - double re = cos(phase); - - /*re *= 2;*/ - - ansr += in[k] * re; - } - /*printf ("%f %f\n", ansr, out[bin]);*/ - difr = ansr - out[bin]; - errpow += difr*difr; - sigpow += ansr*ansr; - } - snr = 10*log10(sigpow/errpow); - printf("nfft=%d inverse=%d,snr = %f\n",nfft,isinverse,snr ); - if (snr<60) { - printf( "** poor snr: %f **\n", snr); - ret = 1; - } -} - - -void test1d(int nfft,int isinverse) -{ - celt_mdct_lookup cfg; - size_t buflen = sizeof(kiss_fft_scalar)*nfft; - - kiss_fft_scalar * in = (kiss_fft_scalar*)malloc(buflen); - kiss_fft_scalar * in_copy = (kiss_fft_scalar*)malloc(buflen); - kiss_fft_scalar * out= (kiss_fft_scalar*)malloc(buflen); - opus_val16 * window= (opus_val16*)malloc(sizeof(opus_val16)*nfft/2); - int k; - - clt_mdct_init(&cfg, nfft, 0); - for (k=0;k<nfft;++k) { - in[k] = (rand() % 32768) - 16384; - } - - for (k=0;k<nfft/2;++k) { - window[k] = Q15ONE; - } - for (k=0;k<nfft;++k) { - in[k] *= 32768; - } - - if (isinverse) - { - for (k=0;k<nfft;++k) { - in[k] /= nfft; - } - } - - for (k=0;k<nfft;++k) - in_copy[k] = in[k]; - /*for (k=0;k<nfft;++k) printf("%d %d ", in[k].r, in[k].i);printf("\n");*/ - - if (isinverse) - { - for (k=0;k<nfft;++k) - out[k] = 0; - clt_mdct_backward(&cfg,in,out, window, nfft/2, 0, 1); - /* apply TDAC because clt_mdct_backward() no longer does that */ - for (k=0;k<nfft/4;++k) - out[nfft-k-1] = out[nfft/2+k]; - check_inv(in,out,nfft,isinverse); - } else { - clt_mdct_forward(&cfg,in,out,window, nfft/2, 0, 1); - check(in_copy,out,nfft,isinverse); - } - /*for (k=0;k<nfft;++k) printf("%d %d ", out[k].r, out[k].i);printf("\n");*/ - - - free(in); - free(out); - clt_mdct_clear(&cfg); -} - -int main(int argc,char ** argv) -{ - ALLOC_STACK; - if (argc>1) { - int k; - for (k=1;k<argc;++k) { - test1d(atoi(argv[k]),0); - test1d(atoi(argv[k]),1); - } - }else{ - test1d(32,0); - test1d(32,1); - test1d(256,0); - test1d(256,1); - test1d(512,0); - test1d(512,1); - test1d(1024,0); - test1d(1024,1); - test1d(2048,0); - test1d(2048,1); -#ifndef RADIX_TWO_ONLY - test1d(36,0); - test1d(36,1); - test1d(40,0); - test1d(40,1); - test1d(60,0); - test1d(60,1); - test1d(120,0); - test1d(120,1); - test1d(240,0); - test1d(240,1); - test1d(480,0); - test1d(480,1); - test1d(960,0); - test1d(960,1); - test1d(1920,0); - test1d(1920,1); -#endif - } - return ret; -} diff --git a/drivers/opus/celt/tests/test_unit_rotation.c b/drivers/opus/celt/tests/test_unit_rotation.c deleted file mode 100644 index a57bf11e79..0000000000 --- a/drivers/opus/celt/tests/test_unit_rotation.c +++ /dev/null @@ -1,90 +0,0 @@ -/* Copyright (c) 2008-2011 Xiph.Org Foundation - Written by Jean-Marc Valin */ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER - OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifdef OPUS_ENABLED -#include "opus/opus_config.h" -#endif - -#ifndef CUSTOM_MODES -#define CUSTOM_MODES -#endif - -#define CELT_C - -#include <stdio.h> -#include <stdlib.h> -#include "opus/celt/vq.c" -#include "opus/celt/cwrs.c" -#include "opus/celt/entcode.c" -#include "opus/celt/entenc.c" -#include "opus/celt/entdec.c" -#include "opus/celt/mathops.c" -#include "opus/celt/bands.h" -#include <math.h> -#define MAX_SIZE 100 - -int ret=0; -void test_rotation(int N, int K) -{ - int i; - double err = 0, ener = 0, snr, snr0; - opus_val16 x0[MAX_SIZE]; - opus_val16 x1[MAX_SIZE]; - for (i=0;i<N;i++) - x1[i] = x0[i] = rand()%32767-16384; - exp_rotation(x1, N, 1, 1, K, SPREAD_NORMAL); - for (i=0;i<N;i++) - { - err += (x0[i]-(double)x1[i])*(x0[i]-(double)x1[i]); - ener += x0[i]*(double)x0[i]; - } - snr0 = 20*log10(ener/err); - err = ener = 0; - exp_rotation(x1, N, -1, 1, K, SPREAD_NORMAL); - for (i=0;i<N;i++) - { - err += (x0[i]-(double)x1[i])*(x0[i]-(double)x1[i]); - ener += x0[i]*(double)x0[i]; - } - snr = 20*log10(ener/err); - printf ("SNR for size %d (%d pulses) is %f (was %f without inverse)\n", N, K, snr, snr0); - if (snr < 60 || snr0 > 20) - { - fprintf(stderr, "FAIL!\n"); - ret = 1; - } -} - -int main(void) -{ - ALLOC_STACK; - test_rotation(15, 3); - test_rotation(23, 5); - test_rotation(50, 3); - test_rotation(80, 1); - return ret; -} diff --git a/drivers/opus/celt/vq.c b/drivers/opus/celt/vq.c index 29a98a3a63..3061e3006f 100644 --- a/drivers/opus/celt/vq.c +++ b/drivers/opus/celt/vq.c @@ -25,10 +25,7 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/celt/mathops.h" #include "opus/celt/cwrs.h" @@ -37,19 +34,23 @@ #include "opus/celt/os_support.h" #include "opus/celt/bands.h" #include "opus/celt/rate.h" +#include "opus/celt/pitch.h" +#ifndef OVERRIDE_vq_exp_rotation1 static void exp_rotation1(celt_norm *X, int len, int stride, opus_val16 c, opus_val16 s) { int i; + opus_val16 ms; celt_norm *Xptr; Xptr = X; + ms = NEG16(s); for (i=0;i<len-stride;i++) { celt_norm x1, x2; x1 = Xptr[0]; x2 = Xptr[stride]; - Xptr[stride] = EXTRACT16(SHR32(MULT16_16(c,x2) + MULT16_16(s,x1), 15)); - *Xptr++ = EXTRACT16(SHR32(MULT16_16(c,x1) - MULT16_16(s,x2), 15)); + Xptr[stride] = EXTRACT16(PSHR32(MAC16_16(MULT16_16(c, x2), s, x1), 15)); + *Xptr++ = EXTRACT16(PSHR32(MAC16_16(MULT16_16(c, x1), ms, x2), 15)); } Xptr = &X[len-2*stride-1]; for (i=len-2*stride-1;i>=0;i--) @@ -57,10 +58,11 @@ static void exp_rotation1(celt_norm *X, int len, int stride, opus_val16 c, opus_ celt_norm x1, x2; x1 = Xptr[0]; x2 = Xptr[stride]; - Xptr[stride] = EXTRACT16(SHR32(MULT16_16(c,x2) + MULT16_16(s,x1), 15)); - *Xptr-- = EXTRACT16(SHR32(MULT16_16(c,x1) - MULT16_16(s,x2), 15)); + Xptr[stride] = EXTRACT16(PSHR32(MAC16_16(MULT16_16(c, x2), s, x1), 15)); + *Xptr-- = EXTRACT16(PSHR32(MAC16_16(MULT16_16(c, x1), ms, x2), 15)); } } +#endif /* OVERRIDE_vq_exp_rotation1 */ static void exp_rotation(celt_norm *X, int len, int dir, int stride, int K, int spread) { @@ -91,7 +93,7 @@ static void exp_rotation(celt_norm *X, int len, int dir, int stride, int K, int } /*NOTE: As a minor optimization, we could be passing around log2(B), not B, for both this and for extract_collapse_mask().*/ - len /= stride; + len = celt_udiv(len, stride); for (i=0;i<stride;i++) { if (dir < 0) @@ -140,13 +142,15 @@ static unsigned extract_collapse_mask(int *iy, int N, int B) return 1; /*NOTE: As a minor optimization, we could be passing around log2(B), not B, for both this and for exp_rotation().*/ - N0 = N/B; + N0 = celt_udiv(N, B); collapse_mask = 0; i=0; do { int j; + unsigned tmp=0; j=0; do { - collapse_mask |= (iy[i*N0+j]!=0)<<i; + tmp |= iy[i*N0+j]; } while (++j<N0); + collapse_mask |= (tmp!=0)<<i; } while (++i<B); return collapse_mask; } @@ -322,7 +326,6 @@ unsigned alg_quant(celt_norm *X, int N, int K, int spread, int B, ec_enc *enc unsigned alg_unquant(celt_norm *X, int N, int K, int spread, int B, ec_dec *dec, opus_val16 gain) { - int i; opus_val32 Ryy; unsigned collapse_mask; VARDECL(int, iy); @@ -331,12 +334,7 @@ unsigned alg_unquant(celt_norm *X, int N, int K, int spread, int B, celt_assert2(K>0, "alg_unquant() needs at least one pulse"); celt_assert2(N>1, "alg_unquant() needs at least two dimensions"); ALLOC(iy, N, int); - decode_pulses(iy, N, K, dec); - Ryy = 0; - i=0; - do { - Ryy = MAC16_16(Ryy, iy[i], iy[i]); - } while (++i < N); + Ryy = decode_pulses(iy, N, K, dec); normalise_residual(iy, X, N, Ryy, gain); exp_rotation(X, N, -1, B, K, spread); collapse_mask = extract_collapse_mask(iy, N, B); @@ -344,21 +342,18 @@ unsigned alg_unquant(celt_norm *X, int N, int K, int spread, int B, return collapse_mask; } -void renormalise_vector(celt_norm *X, int N, opus_val16 gain) +#ifndef OVERRIDE_renormalise_vector +void renormalise_vector(celt_norm *X, int N, opus_val16 gain, int arch) { int i; #ifdef OPUS_FIXED_POINT int k; #endif - opus_val32 E = EPSILON; + opus_val32 E; opus_val16 g; opus_val32 t; - celt_norm *xptr = X; - for (i=0;i<N;i++) - { - E = MAC16_16(E, *xptr, *xptr); - xptr++; - } + celt_norm *xptr; + E = EPSILON + celt_inner_prod(X, X, N, arch); #ifdef OPUS_FIXED_POINT k = celt_ilog2(E)>>1; #endif @@ -373,8 +368,9 @@ void renormalise_vector(celt_norm *X, int N, opus_val16 gain) } /*return celt_sqrt(E);*/ } +#endif /* OVERRIDE_renormalise_vector */ -int stereo_itheta(celt_norm *X, celt_norm *Y, int stereo, int N) +int stereo_itheta(const celt_norm *X, const celt_norm *Y, int stereo, int N, int arch) { int i; int itheta; @@ -393,14 +389,8 @@ int stereo_itheta(celt_norm *X, celt_norm *Y, int stereo, int N) Eside = MAC16_16(Eside, s, s); } } else { - for (i=0;i<N;i++) - { - celt_norm m, s; - m = X[i]; - s = Y[i]; - Emid = MAC16_16(Emid, m, m); - Eside = MAC16_16(Eside, s, s); - } + Emid += celt_inner_prod(X, X, N, arch); + Eside += celt_inner_prod(Y, Y, N, arch); } mid = celt_sqrt(Emid); side = celt_sqrt(Eside); diff --git a/drivers/opus/celt/vq.h b/drivers/opus/celt/vq.h index b52b1a0982..10b5e55306 100644 --- a/drivers/opus/celt/vq.h +++ b/drivers/opus/celt/vq.h @@ -35,7 +35,12 @@ #include "opus/celt/entenc.h" #include "opus/celt/entdec.h" -#include "opus/celt/opus_modes.h" +#include "opus/celt/modes.h" + +#if defined(MIPSr1_ASM) +#include "opus/celt/mips/vq_mipsr1.h" +#endif + /** Algebraic pulse-vector quantiser. The signal x is replaced by the sum of * the pitch and a combination of pulses such that its norm is still equal @@ -63,8 +68,8 @@ unsigned alg_quant(celt_norm *X, int N, int K, int spread, int B, unsigned alg_unquant(celt_norm *X, int N, int K, int spread, int B, ec_dec *dec, opus_val16 gain); -void renormalise_vector(celt_norm *X, int N, opus_val16 gain); +void renormalise_vector(celt_norm *X, int N, opus_val16 gain, int arch); -int stereo_itheta(celt_norm *X, celt_norm *Y, int stereo, int N); +int stereo_itheta(const celt_norm *X, const celt_norm *Y, int stereo, int N, int arch); #endif /* VQ_H */ diff --git a/drivers/opus/celt/x86/celt_lpc_sse.c b/drivers/opus/celt/x86/celt_lpc_sse.c new file mode 100644 index 0000000000..cfc86dc66c --- /dev/null +++ b/drivers/opus/celt/x86/celt_lpc_sse.c @@ -0,0 +1,129 @@ +/* Copyright (c) 2014, Cisco Systems, INC + Written by XiangMingZhu WeiZhou MinPeng YanWang + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#include "opus/opus_config.h" + +#include <xmmintrin.h> +#include <emmintrin.h> +#include <smmintrin.h> +#include "opus/celt/celt_lpc.h" +#include "opus/celt/stack_alloc.h" +#include "opus/celt/mathops.h" +#include "opus/celt/pitch.h" +#include "opus/celt/x86/x86cpu.h" + +#if defined(FIXED_POINT) + +void celt_fir_sse4_1(const opus_val16 *_x, + const opus_val16 *num, + opus_val16 *_y, + int N, + int ord, + opus_val16 *mem, + int arch) +{ + int i,j; + VARDECL(opus_val16, rnum); + VARDECL(opus_val16, x); + + __m128i vecNoA; + opus_int32 noA ; + SAVE_STACK; + + ALLOC(rnum, ord, opus_val16); + ALLOC(x, N+ord, opus_val16); + for(i=0;i<ord;i++) + rnum[i] = num[ord-i-1]; + for(i=0;i<ord;i++) + x[i] = mem[ord-i-1]; + + for (i=0;i<N-7;i+=8) + { + x[i+ord ]=_x[i ]; + x[i+ord+1]=_x[i+1]; + x[i+ord+2]=_x[i+2]; + x[i+ord+3]=_x[i+3]; + x[i+ord+4]=_x[i+4]; + x[i+ord+5]=_x[i+5]; + x[i+ord+6]=_x[i+6]; + x[i+ord+7]=_x[i+7]; + } + + for (;i<N-3;i+=4) + { + x[i+ord ]=_x[i ]; + x[i+ord+1]=_x[i+1]; + x[i+ord+2]=_x[i+2]; + x[i+ord+3]=_x[i+3]; + } + + for (;i<N;i++) + x[i+ord]=_x[i]; + + for(i=0;i<ord;i++) + mem[i] = _x[N-i-1]; +#ifdef SMALL_FOOTPRINT + for (i=0;i<N;i++) + { + opus_val32 sum = SHL32(EXTEND32(_x[i]), SIG_SHIFT); + for (j=0;j<ord;j++) + { + sum = MAC16_16(sum,rnum[j],x[i+j]); + } + _y[i] = SATURATE16(PSHR32(sum, SIG_SHIFT)); + } +#else + noA = EXTEND32(1) << SIG_SHIFT >> 1; + vecNoA = _mm_set_epi32(noA, noA, noA, noA); + + for (i=0;i<N-3;i+=4) + { + opus_val32 sums[4] = {0}; + __m128i vecSum, vecX; + + xcorr_kernel(rnum, x+i, sums, ord, arch); + + vecSum = _mm_loadu_si128((__m128i *)sums); + vecSum = _mm_add_epi32(vecSum, vecNoA); + vecSum = _mm_srai_epi32(vecSum, SIG_SHIFT); + vecX = OP_CVTEPI16_EPI32_M64(_x + i); + vecSum = _mm_add_epi32(vecSum, vecX); + vecSum = _mm_packs_epi32(vecSum, vecSum); + _mm_storel_epi64((__m128i *)(_y + i), vecSum); + } + for (;i<N;i++) + { + opus_val32 sum = 0; + for (j=0;j<ord;j++) + sum = MAC16_16(sum, rnum[j], x[i + j]); + _y[i] = SATURATE16(ADD32(EXTEND32(_x[i]), PSHR32(sum, SIG_SHIFT))); + } + +#endif + RESTORE_STACK; +} + +#endif diff --git a/drivers/opus/celt/tests/test_unit_types.c b/drivers/opus/celt/x86/celt_lpc_sse.h index 12d5ca72f8..3787afd3ff 100644 --- a/drivers/opus/celt/tests/test_unit_types.c +++ b/drivers/opus/celt/x86/celt_lpc_sse.h @@ -1,6 +1,6 @@ -/* Copyright (c) 2008-2011 Xiph.Org Foundation - Written by Jean-Marc Valin */ -/* +/* Copyright (c) 2014, Cisco Systems, INC + Written by XiangMingZhu WeiZhou MinPeng YanWang + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -25,26 +25,41 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef OPUS_ENABLED +#ifndef CELT_LPC_SSE_H +#define CELT_LPC_SSE_H #include "opus/opus_config.h" + +#if defined(OPUS_X86_MAY_HAVE_SSE4_1) && defined(FIXED_POINT) +#define OVERRIDE_CELT_FIR + +void celt_fir_sse4_1( + const opus_val16 *x, + const opus_val16 *num, + opus_val16 *y, + int N, + int ord, + opus_val16 *mem, + int arch); + +#if defined(OPUS_X86_PRESUME_SSE4_1) +#define celt_fir(x, num, y, N, ord, mem, arch) \ + ((void)arch, celt_fir_sse4_1(x, num, y, N, ord, mem, arch)) + +#else + +extern void (*const CELT_FIR_IMPL[OPUS_ARCHMASK + 1])( + const opus_val16 *x, + const opus_val16 *num, + opus_val16 *y, + int N, + int ord, + opus_val16 *mem, + int arch); + +# define celt_fir(x, num, y, N, ord, mem, arch) \ + ((*CELT_FIR_IMPL[(arch) & OPUS_ARCHMASK])(x, num, y, N, ord, mem, arch)) + +#endif #endif -#include "opus/opus_types.h" -#include <stdio.h> - -int main(void) -{ - opus_int16 i = 1; - i <<= 14; - if (i>>14 != 1) - { - fprintf(stderr, "opus_int16 isn't 16 bits\n"); - return 1; - } - if (sizeof(opus_int16)*2 != sizeof(opus_int32)) - { - fprintf(stderr, "16*2 != 32\n"); - return 1; - } - return 0; -} +#endif diff --git a/drivers/opus/celt/x86/pitch_sse.c b/drivers/opus/celt/x86/pitch_sse.c new file mode 100644 index 0000000000..9f22ffd9ab --- /dev/null +++ b/drivers/opus/celt/x86/pitch_sse.c @@ -0,0 +1,182 @@ +/* Copyright (c) 2014, Cisco Systems, INC + Written by XiangMingZhu WeiZhou MinPeng YanWang + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#include "opus/opus_config.h" + +#include "opus/silk/macros.h" +#include "opus/celt/celt_lpc.h" +#include "opus/celt/stack_alloc.h" +#include "opus/celt/mathops.h" +#include "opus/celt/pitch.h" + +#if defined(OPUS_X86_MAY_HAVE_SSE) && !defined(FIXED_POINT) + +#include <xmmintrin.h> +#include "opus/celt/arch.h" + +void xcorr_kernel_sse(const opus_val16 *x, const opus_val16 *y, opus_val32 sum[4], int len) +{ + int j; + __m128 xsum1, xsum2; + xsum1 = _mm_loadu_ps(sum); + xsum2 = _mm_setzero_ps(); + + for (j = 0; j < len-3; j += 4) + { + __m128 x0 = _mm_loadu_ps(x+j); + __m128 yj = _mm_loadu_ps(y+j); + __m128 y3 = _mm_loadu_ps(y+j+3); + + xsum1 = _mm_add_ps(xsum1,_mm_mul_ps(_mm_shuffle_ps(x0,x0,0x00),yj)); + xsum2 = _mm_add_ps(xsum2,_mm_mul_ps(_mm_shuffle_ps(x0,x0,0x55), + _mm_shuffle_ps(yj,y3,0x49))); + xsum1 = _mm_add_ps(xsum1,_mm_mul_ps(_mm_shuffle_ps(x0,x0,0xaa), + _mm_shuffle_ps(yj,y3,0x9e))); + xsum2 = _mm_add_ps(xsum2,_mm_mul_ps(_mm_shuffle_ps(x0,x0,0xff),y3)); + } + if (j < len) + { + xsum1 = _mm_add_ps(xsum1,_mm_mul_ps(_mm_load1_ps(x+j),_mm_loadu_ps(y+j))); + if (++j < len) + { + xsum2 = _mm_add_ps(xsum2,_mm_mul_ps(_mm_load1_ps(x+j),_mm_loadu_ps(y+j))); + if (++j < len) + { + xsum1 = _mm_add_ps(xsum1,_mm_mul_ps(_mm_load1_ps(x+j),_mm_loadu_ps(y+j))); + } + } + } + _mm_storeu_ps(sum,_mm_add_ps(xsum1,xsum2)); +} + + +void dual_inner_prod_sse(const opus_val16 *x, const opus_val16 *y01, const opus_val16 *y02, + int N, opus_val32 *xy1, opus_val32 *xy2) +{ + int i; + __m128 xsum1, xsum2; + xsum1 = _mm_setzero_ps(); + xsum2 = _mm_setzero_ps(); + for (i=0;i<N-3;i+=4) + { + __m128 xi = _mm_loadu_ps(x+i); + __m128 y1i = _mm_loadu_ps(y01+i); + __m128 y2i = _mm_loadu_ps(y02+i); + xsum1 = _mm_add_ps(xsum1,_mm_mul_ps(xi, y1i)); + xsum2 = _mm_add_ps(xsum2,_mm_mul_ps(xi, y2i)); + } + /* Horizontal sum */ + xsum1 = _mm_add_ps(xsum1, _mm_movehl_ps(xsum1, xsum1)); + xsum1 = _mm_add_ss(xsum1, _mm_shuffle_ps(xsum1, xsum1, 0x55)); + _mm_store_ss(xy1, xsum1); + xsum2 = _mm_add_ps(xsum2, _mm_movehl_ps(xsum2, xsum2)); + xsum2 = _mm_add_ss(xsum2, _mm_shuffle_ps(xsum2, xsum2, 0x55)); + _mm_store_ss(xy2, xsum2); + for (;i<N;i++) + { + *xy1 = MAC16_16(*xy1, x[i], y01[i]); + *xy2 = MAC16_16(*xy2, x[i], y02[i]); + } +} + +opus_val32 celt_inner_prod_sse(const opus_val16 *x, const opus_val16 *y, + int N) +{ + int i; + float xy; + __m128 sum; + sum = _mm_setzero_ps(); + /* FIXME: We should probably go 8-way and use 2 sums. */ + for (i=0;i<N-3;i+=4) + { + __m128 xi = _mm_loadu_ps(x+i); + __m128 yi = _mm_loadu_ps(y+i); + sum = _mm_add_ps(sum,_mm_mul_ps(xi, yi)); + } + /* Horizontal sum */ + sum = _mm_add_ps(sum, _mm_movehl_ps(sum, sum)); + sum = _mm_add_ss(sum, _mm_shuffle_ps(sum, sum, 0x55)); + _mm_store_ss(&xy, sum); + for (;i<N;i++) + { + xy = MAC16_16(xy, x[i], y[i]); + } + return xy; +} + +void comb_filter_const_sse(opus_val32 *y, opus_val32 *x, int T, int N, + opus_val16 g10, opus_val16 g11, opus_val16 g12) +{ + int i; + __m128 x0v; + __m128 g10v, g11v, g12v; + g10v = _mm_load1_ps(&g10); + g11v = _mm_load1_ps(&g11); + g12v = _mm_load1_ps(&g12); + x0v = _mm_loadu_ps(&x[-T-2]); + for (i=0;i<N-3;i+=4) + { + __m128 yi, yi2, x1v, x2v, x3v, x4v; + const opus_val32 *xp = &x[i-T-2]; + yi = _mm_loadu_ps(x+i); + x4v = _mm_loadu_ps(xp+4); +#if 0 + /* Slower version with all loads */ + x1v = _mm_loadu_ps(xp+1); + x2v = _mm_loadu_ps(xp+2); + x3v = _mm_loadu_ps(xp+3); +#else + x2v = _mm_shuffle_ps(x0v, x4v, 0x4e); + x1v = _mm_shuffle_ps(x0v, x2v, 0x99); + x3v = _mm_shuffle_ps(x2v, x4v, 0x99); +#endif + + yi = _mm_add_ps(yi, _mm_mul_ps(g10v,x2v)); +#if 0 /* Set to 1 to make it bit-exact with the non-SSE version */ + yi = _mm_add_ps(yi, _mm_mul_ps(g11v,_mm_add_ps(x3v,x1v))); + yi = _mm_add_ps(yi, _mm_mul_ps(g12v,_mm_add_ps(x4v,x0v))); +#else + /* Use partial sums */ + yi2 = _mm_add_ps(_mm_mul_ps(g11v,_mm_add_ps(x3v,x1v)), + _mm_mul_ps(g12v,_mm_add_ps(x4v,x0v))); + yi = _mm_add_ps(yi, yi2); +#endif + x0v=x4v; + _mm_storeu_ps(y+i, yi); + } +#ifdef CUSTOM_MODES + for (;i<N;i++) + { + y[i] = x[i] + + MULT16_32_Q15(g10,x[i-T]) + + MULT16_32_Q15(g11,ADD32(x[i-T+1],x[i-T-1])) + + MULT16_32_Q15(g12,ADD32(x[i-T+2],x[i-T-2])); + } +#endif +} + + +#endif diff --git a/drivers/opus/celt/x86/pitch_sse.h b/drivers/opus/celt/x86/pitch_sse.h index 1542b87232..2b4b54f61f 100644 --- a/drivers/opus/celt/x86/pitch_sse.h +++ b/drivers/opus/celt/x86/pitch_sse.h @@ -1,4 +1,5 @@ -/* Copyright (c) 2013 Jean-Marc Valin and John Ridges */ +/* Copyright (c) 2013 Jean-Marc Valin and John Ridges + Copyright (c) 2014, Cisco Systems, INC MingXiang WeiZhou MinPeng YanWang*/ /** @file pitch_sse.h @brief Pitch analysis @@ -31,126 +32,158 @@ #ifndef PITCH_SSE_H #define PITCH_SSE_H +#include "opus/opus_config.h" -#include <xmmintrin.h> -#include "opus/celt/arch.h" +#if defined(OPUS_X86_MAY_HAVE_SSE4_1) && defined(FIXED_POINT) +void xcorr_kernel_sse4_1( + const opus_int16 *x, + const opus_int16 *y, + opus_val32 sum[4], + int len); +#endif + +#if defined(OPUS_X86_MAY_HAVE_SSE) && !defined(FIXED_POINT) +void xcorr_kernel_sse( + const opus_val16 *x, + const opus_val16 *y, + opus_val32 sum[4], + int len); +#endif +#if defined(OPUS_X86_PRESUME_SSE4_1) && defined(FIXED_POINT) #define OVERRIDE_XCORR_KERNEL -static OPUS_INLINE void xcorr_kernel(const opus_val16 *x, const opus_val16 *y, opus_val32 sum[4], int len) -{ - int j; - __m128 xsum1, xsum2; - xsum1 = _mm_loadu_ps(sum); - xsum2 = _mm_setzero_ps(); - - for (j = 0; j < len-3; j += 4) - { - __m128 x0 = _mm_loadu_ps(x+j); - __m128 yj = _mm_loadu_ps(y+j); - __m128 y3 = _mm_loadu_ps(y+j+3); - - xsum1 = _mm_add_ps(xsum1,_mm_mul_ps(_mm_shuffle_ps(x0,x0,0x00),yj)); - xsum2 = _mm_add_ps(xsum2,_mm_mul_ps(_mm_shuffle_ps(x0,x0,0x55), - _mm_shuffle_ps(yj,y3,0x49))); - xsum1 = _mm_add_ps(xsum1,_mm_mul_ps(_mm_shuffle_ps(x0,x0,0xaa), - _mm_shuffle_ps(yj,y3,0x9e))); - xsum2 = _mm_add_ps(xsum2,_mm_mul_ps(_mm_shuffle_ps(x0,x0,0xff),y3)); - } - if (j < len) - { - xsum1 = _mm_add_ps(xsum1,_mm_mul_ps(_mm_load1_ps(x+j),_mm_loadu_ps(y+j))); - if (++j < len) - { - xsum2 = _mm_add_ps(xsum2,_mm_mul_ps(_mm_load1_ps(x+j),_mm_loadu_ps(y+j))); - if (++j < len) - { - xsum1 = _mm_add_ps(xsum1,_mm_mul_ps(_mm_load1_ps(x+j),_mm_loadu_ps(y+j))); - } - } - } - _mm_storeu_ps(sum,_mm_add_ps(xsum1,xsum2)); -} +#define xcorr_kernel(x, y, sum, len, arch) \ + ((void)arch, xcorr_kernel_sse4_1(x, y, sum, len)) -#define OVERRIDE_DUAL_INNER_PROD -static OPUS_INLINE void dual_inner_prod(const opus_val16 *x, const opus_val16 *y01, const opus_val16 *y02, - int N, opus_val32 *xy1, opus_val32 *xy2) -{ - int i; - __m128 xsum1, xsum2; - xsum1 = _mm_setzero_ps(); - xsum2 = _mm_setzero_ps(); - for (i=0;i<N-3;i+=4) - { - __m128 xi = _mm_loadu_ps(x+i); - __m128 y1i = _mm_loadu_ps(y01+i); - __m128 y2i = _mm_loadu_ps(y02+i); - xsum1 = _mm_add_ps(xsum1,_mm_mul_ps(xi, y1i)); - xsum2 = _mm_add_ps(xsum2,_mm_mul_ps(xi, y2i)); - } - /* Horizontal sum */ - xsum1 = _mm_add_ps(xsum1, _mm_movehl_ps(xsum1, xsum1)); - xsum1 = _mm_add_ss(xsum1, _mm_shuffle_ps(xsum1, xsum1, 0x55)); - _mm_store_ss(xy1, xsum1); - xsum2 = _mm_add_ps(xsum2, _mm_movehl_ps(xsum2, xsum2)); - xsum2 = _mm_add_ss(xsum2, _mm_shuffle_ps(xsum2, xsum2, 0x55)); - _mm_store_ss(xy2, xsum2); - for (;i<N;i++) - { - *xy1 = MAC16_16(*xy1, x[i], y01[i]); - *xy2 = MAC16_16(*xy2, x[i], y02[i]); - } -} +#elif defined(OPUS_X86_PRESUME_SSE) && !defined(FIXED_POINT) +#define OVERRIDE_XCORR_KERNEL +#define xcorr_kernel(x, y, sum, len, arch) \ + ((void)arch, xcorr_kernel_sse(x, y, sum, len)) + +#elif (defined(OPUS_X86_MAY_HAVE_SSE4_1) && defined(FIXED_POINT)) || (defined(OPUS_X86_MAY_HAVE_SSE) && !defined(FIXED_POINT)) + +extern void (*const XCORR_KERNEL_IMPL[OPUS_ARCHMASK + 1])( + const opus_val16 *x, + const opus_val16 *y, + opus_val32 sum[4], + int len); + +#define OVERRIDE_XCORR_KERNEL +#define xcorr_kernel(x, y, sum, len, arch) \ + ((*XCORR_KERNEL_IMPL[(arch) & OPUS_ARCHMASK])(x, y, sum, len)) + +#endif + +#if defined(OPUS_X86_MAY_HAVE_SSE4_1) && defined(FIXED_POINT) +opus_val32 celt_inner_prod_sse4_1( + const opus_int16 *x, + const opus_int16 *y, + int N); +#endif + +#if defined(OPUS_X86_MAY_HAVE_SSE2) && defined(FIXED_POINT) +opus_val32 celt_inner_prod_sse2( + const opus_int16 *x, + const opus_int16 *y, + int N); +#endif + +#if defined(OPUS_X86_MAY_HAVE_SSE2) && !defined(FIXED_POINT) +opus_val32 celt_inner_prod_sse( + const opus_val16 *x, + const opus_val16 *y, + int N); +#endif + + +#if defined(OPUS_X86_PRESUME_SSE4_1) && defined(FIXED_POINT) +#define OVERRIDE_CELT_INNER_PROD +#define celt_inner_prod(x, y, N, arch) \ + ((void)arch, celt_inner_prod_sse4_1(x, y, N)) + +#elif defined(OPUS_X86_PRESUME_SSE2) && defined(FIXED_POINT) && !defined(OPUS_X86_MAY_HAVE_SSE4_1) +#define OVERRIDE_CELT_INNER_PROD +#define celt_inner_prod(x, y, N, arch) \ + ((void)arch, celt_inner_prod_sse2(x, y, N)) + +#elif defined(OPUS_X86_PRESUME_SSE) && !defined(FIXED_POINT) +#define OVERRIDE_CELT_INNER_PROD +#define celt_inner_prod(x, y, N, arch) \ + ((void)arch, celt_inner_prod_sse(x, y, N)) + + +#elif ((defined(OPUS_X86_MAY_HAVE_SSE4_1) || defined(OPUS_X86_MAY_HAVE_SSE2)) && defined(FIXED_POINT)) || \ + (defined(OPUS_X86_MAY_HAVE_SSE) && !defined(FIXED_POINT)) + +extern opus_val32 (*const CELT_INNER_PROD_IMPL[OPUS_ARCHMASK + 1])( + const opus_val16 *x, + const opus_val16 *y, + int N); + +#define OVERRIDE_CELT_INNER_PROD +#define celt_inner_prod(x, y, N, arch) \ + ((*CELT_INNER_PROD_IMPL[(arch) & OPUS_ARCHMASK])(x, y, N)) -#define OVERRIDE_COMB_FILTER_CONST -static OPUS_INLINE void comb_filter_const(opus_val32 *y, opus_val32 *x, int T, int N, - opus_val16 g10, opus_val16 g11, opus_val16 g12) -{ - int i; - __m128 x0v; - __m128 g10v, g11v, g12v; - g10v = _mm_load1_ps(&g10); - g11v = _mm_load1_ps(&g11); - g12v = _mm_load1_ps(&g12); - x0v = _mm_loadu_ps(&x[-T-2]); - for (i=0;i<N-3;i+=4) - { - __m128 yi, yi2, x1v, x2v, x3v, x4v; - const opus_val32 *xp = &x[i-T-2]; - yi = _mm_loadu_ps(x+i); - x4v = _mm_loadu_ps(xp+4); -#if 0 - /* Slower version with all loads */ - x1v = _mm_loadu_ps(xp+1); - x2v = _mm_loadu_ps(xp+2); - x3v = _mm_loadu_ps(xp+3); -#else - x2v = _mm_shuffle_ps(x0v, x4v, 0x4e); - x1v = _mm_shuffle_ps(x0v, x2v, 0x99); - x3v = _mm_shuffle_ps(x2v, x4v, 0x99); #endif - yi = _mm_add_ps(yi, _mm_mul_ps(g10v,x2v)); -#if 0 /* Set to 1 to make it bit-exact with the non-SSE version */ - yi = _mm_add_ps(yi, _mm_mul_ps(g11v,_mm_add_ps(x3v,x1v))); - yi = _mm_add_ps(yi, _mm_mul_ps(g12v,_mm_add_ps(x4v,x0v))); +#if defined(OPUS_X86_MAY_HAVE_SSE) && !defined(FIXED_POINT) + +#define OVERRIDE_DUAL_INNER_PROD +#define OVERRIDE_COMB_FILTER_CONST + +#undef dual_inner_prod +#undef comb_filter_const + +void dual_inner_prod_sse(const opus_val16 *x, + const opus_val16 *y01, + const opus_val16 *y02, + int N, + opus_val32 *xy1, + opus_val32 *xy2); + +void comb_filter_const_sse(opus_val32 *y, + opus_val32 *x, + int T, + int N, + opus_val16 g10, + opus_val16 g11, + opus_val16 g12); + + +#if defined(OPUS_X86_PRESUME_SSE) +# define dual_inner_prod(x, y01, y02, N, xy1, xy2, arch) \ + ((void)(arch),dual_inner_prod_sse(x, y01, y02, N, xy1, xy2)) + +# define comb_filter_const(y, x, T, N, g10, g11, g12, arch) \ + ((void)(arch),comb_filter_const_sse(y, x, T, N, g10, g11, g12)) #else - /* Use partial sums */ - yi2 = _mm_add_ps(_mm_mul_ps(g11v,_mm_add_ps(x3v,x1v)), - _mm_mul_ps(g12v,_mm_add_ps(x4v,x0v))); - yi = _mm_add_ps(yi, yi2); + +extern void (*const DUAL_INNER_PROD_IMPL[OPUS_ARCHMASK + 1])( + const opus_val16 *x, + const opus_val16 *y01, + const opus_val16 *y02, + int N, + opus_val32 *xy1, + opus_val32 *xy2); + +#define dual_inner_prod(x, y01, y02, N, xy1, xy2, arch) \ + ((*DUAL_INNER_PROD_IMPL[(arch) & OPUS_ARCHMASK])(x, y01, y02, N, xy1, xy2)) + +extern void (*const COMB_FILTER_CONST_IMPL[OPUS_ARCHMASK + 1])( + opus_val32 *y, + opus_val32 *x, + int T, + int N, + opus_val16 g10, + opus_val16 g11, + opus_val16 g12); + +#define comb_filter_const(y, x, T, N, g10, g11, g12, arch) \ + ((*COMB_FILTER_CONST_IMPL[(arch) & OPUS_ARCHMASK])(y, x, T, N, g10, g11, g12)) + +#define NON_STATIC_COMB_FILTER_CONST_C + #endif - x0v=x4v; - _mm_storeu_ps(y+i, yi); - } -#ifdef CUSTOM_MODES - for (;i<N;i++) - { - y[i] = x[i] - + MULT16_32_Q15(g10,x[i-T]) - + MULT16_32_Q15(g11,ADD32(x[i-T+1],x[i-T-1])) - + MULT16_32_Q15(g12,ADD32(x[i-T+2],x[i-T-2])); - } #endif -} #endif diff --git a/drivers/opus/celt/x86/pitch_sse2.c b/drivers/opus/celt/x86/pitch_sse2.c new file mode 100644 index 0000000000..b5a78b4acd --- /dev/null +++ b/drivers/opus/celt/x86/pitch_sse2.c @@ -0,0 +1,92 @@ +/* Copyright (c) 2014, Cisco Systems, INC + Written by XiangMingZhu WeiZhou MinPeng YanWang + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#include "opus/opus_config.h" + +#include <xmmintrin.h> +#include <emmintrin.h> + +#include "opus/silk/macros.h" +#include "opus/celt/celt_lpc.h" +#include "opus/celt/stack_alloc.h" +#include "opus/celt/mathops.h" +#include "opus/celt/pitch.h" + +#if defined(OPUS_X86_MAY_HAVE_SSE2) && defined(FIXED_POINT) +opus_val32 celt_inner_prod_sse2(const opus_val16 *x, const opus_val16 *y, + int N) +{ + opus_int i, dataSize16; + opus_int32 sum; + + __m128i inVec1_76543210, inVec1_FEDCBA98, acc1; + __m128i inVec2_76543210, inVec2_FEDCBA98, acc2; + + sum = 0; + dataSize16 = N & ~15; + + acc1 = _mm_setzero_si128(); + acc2 = _mm_setzero_si128(); + + for (i=0;i<dataSize16;i+=16) + { + inVec1_76543210 = _mm_loadu_si128((__m128i *)(&x[i + 0])); + inVec2_76543210 = _mm_loadu_si128((__m128i *)(&y[i + 0])); + + inVec1_FEDCBA98 = _mm_loadu_si128((__m128i *)(&x[i + 8])); + inVec2_FEDCBA98 = _mm_loadu_si128((__m128i *)(&y[i + 8])); + + inVec1_76543210 = _mm_madd_epi16(inVec1_76543210, inVec2_76543210); + inVec1_FEDCBA98 = _mm_madd_epi16(inVec1_FEDCBA98, inVec2_FEDCBA98); + + acc1 = _mm_add_epi32(acc1, inVec1_76543210); + acc2 = _mm_add_epi32(acc2, inVec1_FEDCBA98); + } + + acc1 = _mm_add_epi32( acc1, acc2 ); + + if (N - i >= 8) + { + inVec1_76543210 = _mm_loadu_si128((__m128i *)(&x[i + 0])); + inVec2_76543210 = _mm_loadu_si128((__m128i *)(&y[i + 0])); + + inVec1_76543210 = _mm_madd_epi16(inVec1_76543210, inVec2_76543210); + + acc1 = _mm_add_epi32(acc1, inVec1_76543210); + i += 8; + } + + acc1 = _mm_add_epi32(acc1, _mm_unpackhi_epi64( acc1, acc1)); + acc1 = _mm_add_epi32(acc1, _mm_shufflelo_epi16( acc1, 0x0E)); + sum += _mm_cvtsi128_si32(acc1); + + for (;i<N;i++) { + sum = silk_SMLABB(sum, x[i], y[i]); + } + + return sum; +} +#endif diff --git a/drivers/opus/celt/x86/pitch_sse4_1.c b/drivers/opus/celt/x86/pitch_sse4_1.c new file mode 100644 index 0000000000..57fb332210 --- /dev/null +++ b/drivers/opus/celt/x86/pitch_sse4_1.c @@ -0,0 +1,192 @@ +/* Copyright (c) 2014, Cisco Systems, INC + Written by XiangMingZhu WeiZhou MinPeng YanWang + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#include "opus/opus_config.h" + +#include <xmmintrin.h> +#include <emmintrin.h> + +#include "opus/silk/macros.h" +#include "opus/celt/celt_lpc.h" +#include "opus/celt/stack_alloc.h" +#include "opus/celt/mathops.h" +#include "opus/celt/pitch.h" + +#if defined(OPUS_X86_MAY_HAVE_SSE4_1) && defined(FIXED_POINT) +#include <smmintrin.h> +#include "opus/celt/x86/x86cpu.h" + +opus_val32 celt_inner_prod_sse4_1(const opus_val16 *x, const opus_val16 *y, + int N) +{ + opus_int i, dataSize16; + opus_int32 sum; + __m128i inVec1_76543210, inVec1_FEDCBA98, acc1; + __m128i inVec2_76543210, inVec2_FEDCBA98, acc2; + __m128i inVec1_3210, inVec2_3210; + + sum = 0; + dataSize16 = N & ~15; + + acc1 = _mm_setzero_si128(); + acc2 = _mm_setzero_si128(); + + for (i=0;i<dataSize16;i+=16) { + inVec1_76543210 = _mm_loadu_si128((__m128i *)(&x[i + 0])); + inVec2_76543210 = _mm_loadu_si128((__m128i *)(&y[i + 0])); + + inVec1_FEDCBA98 = _mm_loadu_si128((__m128i *)(&x[i + 8])); + inVec2_FEDCBA98 = _mm_loadu_si128((__m128i *)(&y[i + 8])); + + inVec1_76543210 = _mm_madd_epi16(inVec1_76543210, inVec2_76543210); + inVec1_FEDCBA98 = _mm_madd_epi16(inVec1_FEDCBA98, inVec2_FEDCBA98); + + acc1 = _mm_add_epi32(acc1, inVec1_76543210); + acc2 = _mm_add_epi32(acc2, inVec1_FEDCBA98); + } + + acc1 = _mm_add_epi32(acc1, acc2); + + if (N - i >= 8) + { + inVec1_76543210 = _mm_loadu_si128((__m128i *)(&x[i + 0])); + inVec2_76543210 = _mm_loadu_si128((__m128i *)(&y[i + 0])); + + inVec1_76543210 = _mm_madd_epi16(inVec1_76543210, inVec2_76543210); + + acc1 = _mm_add_epi32(acc1, inVec1_76543210); + i += 8; + } + + if (N - i >= 4) + { + inVec1_3210 = OP_CVTEPI16_EPI32_M64(&x[i + 0]); + inVec2_3210 = OP_CVTEPI16_EPI32_M64(&y[i + 0]); + + inVec1_3210 = _mm_mullo_epi32(inVec1_3210, inVec2_3210); + + acc1 = _mm_add_epi32(acc1, inVec1_3210); + i += 4; + } + + acc1 = _mm_add_epi32(acc1, _mm_unpackhi_epi64(acc1, acc1)); + acc1 = _mm_add_epi32(acc1, _mm_shufflelo_epi16(acc1, 0x0E)); + + sum += _mm_cvtsi128_si32(acc1); + + for (;i<N;i++) + { + sum = silk_SMLABB(sum, x[i], y[i]); + } + + return sum; +} + +void xcorr_kernel_sse4_1(const opus_val16 * x, const opus_val16 * y, opus_val32 sum[ 4 ], int len) +{ + int j; + + __m128i vecX, vecX0, vecX1, vecX2, vecX3; + __m128i vecY0, vecY1, vecY2, vecY3; + __m128i sum0, sum1, sum2, sum3, vecSum; + __m128i initSum; + + celt_assert(len >= 3); + + sum0 = _mm_setzero_si128(); + sum1 = _mm_setzero_si128(); + sum2 = _mm_setzero_si128(); + sum3 = _mm_setzero_si128(); + + for (j=0;j<(len-7);j+=8) + { + vecX = _mm_loadu_si128((__m128i *)(&x[j + 0])); + vecY0 = _mm_loadu_si128((__m128i *)(&y[j + 0])); + vecY1 = _mm_loadu_si128((__m128i *)(&y[j + 1])); + vecY2 = _mm_loadu_si128((__m128i *)(&y[j + 2])); + vecY3 = _mm_loadu_si128((__m128i *)(&y[j + 3])); + + sum0 = _mm_add_epi32(sum0, _mm_madd_epi16(vecX, vecY0)); + sum1 = _mm_add_epi32(sum1, _mm_madd_epi16(vecX, vecY1)); + sum2 = _mm_add_epi32(sum2, _mm_madd_epi16(vecX, vecY2)); + sum3 = _mm_add_epi32(sum3, _mm_madd_epi16(vecX, vecY3)); + } + + sum0 = _mm_add_epi32(sum0, _mm_unpackhi_epi64( sum0, sum0)); + sum0 = _mm_add_epi32(sum0, _mm_shufflelo_epi16( sum0, 0x0E)); + + sum1 = _mm_add_epi32(sum1, _mm_unpackhi_epi64( sum1, sum1)); + sum1 = _mm_add_epi32(sum1, _mm_shufflelo_epi16( sum1, 0x0E)); + + sum2 = _mm_add_epi32(sum2, _mm_unpackhi_epi64( sum2, sum2)); + sum2 = _mm_add_epi32(sum2, _mm_shufflelo_epi16( sum2, 0x0E)); + + sum3 = _mm_add_epi32(sum3, _mm_unpackhi_epi64( sum3, sum3)); + sum3 = _mm_add_epi32(sum3, _mm_shufflelo_epi16( sum3, 0x0E)); + + vecSum = _mm_unpacklo_epi64(_mm_unpacklo_epi32(sum0, sum1), + _mm_unpacklo_epi32(sum2, sum3)); + + for (;j<(len-3);j+=4) + { + vecX = OP_CVTEPI16_EPI32_M64(&x[j + 0]); + vecX0 = _mm_shuffle_epi32(vecX, 0x00); + vecX1 = _mm_shuffle_epi32(vecX, 0x55); + vecX2 = _mm_shuffle_epi32(vecX, 0xaa); + vecX3 = _mm_shuffle_epi32(vecX, 0xff); + + vecY0 = OP_CVTEPI16_EPI32_M64(&y[j + 0]); + vecY1 = OP_CVTEPI16_EPI32_M64(&y[j + 1]); + vecY2 = OP_CVTEPI16_EPI32_M64(&y[j + 2]); + vecY3 = OP_CVTEPI16_EPI32_M64(&y[j + 3]); + + sum0 = _mm_mullo_epi32(vecX0, vecY0); + sum1 = _mm_mullo_epi32(vecX1, vecY1); + sum2 = _mm_mullo_epi32(vecX2, vecY2); + sum3 = _mm_mullo_epi32(vecX3, vecY3); + + sum0 = _mm_add_epi32(sum0, sum1); + sum2 = _mm_add_epi32(sum2, sum3); + vecSum = _mm_add_epi32(vecSum, sum0); + vecSum = _mm_add_epi32(vecSum, sum2); + } + + for (;j<len;j++) + { + vecX = OP_CVTEPI16_EPI32_M64(&x[j + 0]); + vecX0 = _mm_shuffle_epi32(vecX, 0x00); + + vecY0 = OP_CVTEPI16_EPI32_M64(&y[j + 0]); + + sum0 = _mm_mullo_epi32(vecX0, vecY0); + vecSum = _mm_add_epi32(vecSum, sum0); + } + + initSum = _mm_loadu_si128((__m128i *)(&sum[0])); + initSum = _mm_add_epi32(initSum, vecSum); + _mm_storeu_si128((__m128i *)sum, initSum); +} +#endif diff --git a/drivers/opus/celt/x86/x86_celt_map.c b/drivers/opus/celt/x86/x86_celt_map.c new file mode 100644 index 0000000000..5146ea2b38 --- /dev/null +++ b/drivers/opus/celt/x86/x86_celt_map.c @@ -0,0 +1,152 @@ +/* Copyright (c) 2014, Cisco Systems, INC + Written by XiangMingZhu WeiZhou MinPeng YanWang + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#include "opus/opus_config.h" + +#include "opus/celt/x86/x86cpu.h" +#include "opus/celt/celt_lpc.h" +#include "opus/celt/pitch.h" +#include "opus/celt/x86/pitch_sse.h" + +#if defined(OPUS_HAVE_RTCD) + +# if defined(FIXED_POINT) + +#if defined(OPUS_X86_MAY_HAVE_SSE4_1) && !defined(OPUS_X86_PRESUME_SSE4_1) + +void (*const CELT_FIR_IMPL[OPUS_ARCHMASK + 1])( + const opus_val16 *x, + const opus_val16 *num, + opus_val16 *y, + int N, + int ord, + opus_val16 *mem, + int arch +) = { + celt_fir_c, /* non-sse */ + celt_fir_c, + celt_fir_c, + MAY_HAVE_SSE4_1(celt_fir), /* sse4.1 */ + MAY_HAVE_SSE4_1(celt_fir) /* avx */ +}; + +void (*const XCORR_KERNEL_IMPL[OPUS_ARCHMASK + 1])( + const opus_val16 *x, + const opus_val16 *y, + opus_val32 sum[4], + int len +) = { + xcorr_kernel_c, /* non-sse */ + xcorr_kernel_c, + xcorr_kernel_c, + MAY_HAVE_SSE4_1(xcorr_kernel), /* sse4.1 */ + MAY_HAVE_SSE4_1(xcorr_kernel) /* avx */ +}; + +#endif + +#if (defined(OPUS_X86_MAY_HAVE_SSE4_1) && !defined(OPUS_X86_PRESUME_SSE4_1)) || \ + (!defined(OPUS_X86_MAY_HAVE_SSE_4_1) && defined(OPUS_X86_MAY_HAVE_SSE2) && !defined(OPUS_X86_PRESUME_SSE2)) + +opus_val32 (*const CELT_INNER_PROD_IMPL[OPUS_ARCHMASK + 1])( + const opus_val16 *x, + const opus_val16 *y, + int N +) = { + celt_inner_prod_c, /* non-sse */ + celt_inner_prod_c, + MAY_HAVE_SSE2(celt_inner_prod), + MAY_HAVE_SSE4_1(celt_inner_prod), /* sse4.1 */ + MAY_HAVE_SSE4_1(celt_inner_prod) /* avx */ +}; + +#endif + +# else + +#if defined(OPUS_X86_MAY_HAVE_SSE) && !defined(OPUS_X86_PRESUME_SSE) + +void (*const XCORR_KERNEL_IMPL[OPUS_ARCHMASK + 1])( + const opus_val16 *x, + const opus_val16 *y, + opus_val32 sum[4], + int len +) = { + xcorr_kernel_c, /* non-sse */ + MAY_HAVE_SSE(xcorr_kernel), + MAY_HAVE_SSE(xcorr_kernel), + MAY_HAVE_SSE(xcorr_kernel), + MAY_HAVE_SSE(xcorr_kernel) +}; + +opus_val32 (*const CELT_INNER_PROD_IMPL[OPUS_ARCHMASK + 1])( + const opus_val16 *x, + const opus_val16 *y, + int N +) = { + celt_inner_prod_c, /* non-sse */ + MAY_HAVE_SSE(celt_inner_prod), + MAY_HAVE_SSE(celt_inner_prod), + MAY_HAVE_SSE(celt_inner_prod), + MAY_HAVE_SSE(celt_inner_prod) +}; + +void (*const DUAL_INNER_PROD_IMPL[OPUS_ARCHMASK + 1])( + const opus_val16 *x, + const opus_val16 *y01, + const opus_val16 *y02, + int N, + opus_val32 *xy1, + opus_val32 *xy2 +) = { + dual_inner_prod_c, /* non-sse */ + MAY_HAVE_SSE(dual_inner_prod), + MAY_HAVE_SSE(dual_inner_prod), + MAY_HAVE_SSE(dual_inner_prod), + MAY_HAVE_SSE(dual_inner_prod) +}; + +void (*const COMB_FILTER_CONST_IMPL[OPUS_ARCHMASK + 1])( + opus_val32 *y, + opus_val32 *x, + int T, + int N, + opus_val16 g10, + opus_val16 g11, + opus_val16 g12 +) = { + comb_filter_const_c, /* non-sse */ + MAY_HAVE_SSE(comb_filter_const), + MAY_HAVE_SSE(comb_filter_const), + MAY_HAVE_SSE(comb_filter_const), + MAY_HAVE_SSE(comb_filter_const) +}; + + +#endif + +#endif +#endif diff --git a/drivers/opus/celt/x86/x86cpu.c b/drivers/opus/celt/x86/x86cpu.c new file mode 100644 index 0000000000..91b9b185c2 --- /dev/null +++ b/drivers/opus/celt/x86/x86cpu.c @@ -0,0 +1,154 @@ +/* Copyright (c) 2014, Cisco Systems, INC + Written by XiangMingZhu WeiZhou MinPeng YanWang + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#include "opus/opus_config.h" + +#include "opus/celt/cpu_support.h" +#include "opus/silk/macros.h" +#include "opus/silk/main.h" +#include "opus/celt/pitch.h" +#include "opus/celt/x86/x86cpu.h" + +#if (defined(OPUS_X86_MAY_HAVE_SSE) && !defined(OPUS_X86_PRESUME_SSE)) || \ + (defined(OPUS_X86_MAY_HAVE_SSE2) && !defined(OPUS_X86_PRESUME_SSE2)) || \ + (defined(OPUS_X86_MAY_HAVE_SSE4_1) && !defined(OPUS_X86_PRESUME_SSE4_1)) || \ + (defined(OPUS_X86_MAY_HAVE_AVX) && !defined(OPUS_X86_PRESUME_AVX)) + + +#if defined(_MSC_VER) + +#include <intrin.h> +static _inline void cpuid(unsigned int CPUInfo[4], unsigned int InfoType) +{ + __cpuid((int*)CPUInfo, InfoType); +} + +#else + +#if defined(CPU_INFO_BY_C) +#include <cpuid.h> +#endif + +static void cpuid(unsigned int CPUInfo[4], unsigned int InfoType) +{ +#if defined(CPU_INFO_BY_ASM) +#if defined(__i386__) && defined(__PIC__) +/* %ebx is PIC register in 32-bit, so mustn't clobber it. */ + __asm__ __volatile__ ( + "xchg %%ebx, %1\n" + "cpuid\n" + "xchg %%ebx, %1\n": + "=a" (CPUInfo[0]), + "=r" (CPUInfo[1]), + "=c" (CPUInfo[2]), + "=d" (CPUInfo[3]) : + "0" (InfoType) + ); +#else + __asm__ __volatile__ ( + "cpuid": + "=a" (CPUInfo[0]), + "=b" (CPUInfo[1]), + "=c" (CPUInfo[2]), + "=d" (CPUInfo[3]) : + "0" (InfoType) + ); +#endif +#elif defined(CPU_INFO_BY_C) + __get_cpuid(InfoType, &(CPUInfo[0]), &(CPUInfo[1]), &(CPUInfo[2]), &(CPUInfo[3])); +#endif +} + +#endif + +typedef struct CPU_Feature{ + /* SIMD: 128-bit */ + int HW_SSE; + int HW_SSE2; + int HW_SSE41; + /* SIMD: 256-bit */ + int HW_AVX; +} CPU_Feature; + +static void opus_cpu_feature_check(CPU_Feature *cpu_feature) +{ + unsigned int info[4] = {0}; + unsigned int nIds = 0; + + cpuid(info, 0); + nIds = info[0]; + + if (nIds >= 1){ + cpuid(info, 1); + cpu_feature->HW_SSE = (info[3] & (1 << 25)) != 0; + cpu_feature->HW_SSE2 = (info[3] & (1 << 26)) != 0; + cpu_feature->HW_SSE41 = (info[2] & (1 << 19)) != 0; + cpu_feature->HW_AVX = (info[2] & (1 << 28)) != 0; + } + else { + cpu_feature->HW_SSE = 0; + cpu_feature->HW_SSE2 = 0; + cpu_feature->HW_SSE41 = 0; + cpu_feature->HW_AVX = 0; + } +} + +int opus_select_arch(void) +{ + CPU_Feature cpu_feature; + int arch; + + opus_cpu_feature_check(&cpu_feature); + + arch = 0; + if (!cpu_feature.HW_SSE) + { + return arch; + } + arch++; + + if (!cpu_feature.HW_SSE2) + { + return arch; + } + arch++; + + if (!cpu_feature.HW_SSE41) + { + return arch; + } + arch++; + + if (!cpu_feature.HW_AVX) + { + return arch; + } + arch++; + + return arch; +} + +#endif diff --git a/drivers/opus/celt/x86/x86cpu.h b/drivers/opus/celt/x86/x86cpu.h new file mode 100644 index 0000000000..04fd48aac4 --- /dev/null +++ b/drivers/opus/celt/x86/x86cpu.h @@ -0,0 +1,93 @@ +/* Copyright (c) 2014, Cisco Systems, INC + Written by XiangMingZhu WeiZhou MinPeng YanWang + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#if !defined(X86CPU_H) +# define X86CPU_H + +# if defined(OPUS_X86_MAY_HAVE_SSE) +# define MAY_HAVE_SSE(name) name ## _sse +# else +# define MAY_HAVE_SSE(name) name ## _c +# endif + +# if defined(OPUS_X86_MAY_HAVE_SSE2) +# define MAY_HAVE_SSE2(name) name ## _sse2 +# else +# define MAY_HAVE_SSE2(name) name ## _c +# endif + +# if defined(OPUS_X86_MAY_HAVE_SSE4_1) +# define MAY_HAVE_SSE4_1(name) name ## _sse4_1 +# else +# define MAY_HAVE_SSE4_1(name) name ## _c +# endif + +# if defined(OPUS_X86_MAY_HAVE_AVX) +# define MAY_HAVE_AVX(name) name ## _avx +# else +# define MAY_HAVE_AVX(name) name ## _c +# endif + +# if defined(OPUS_HAVE_RTCD) +int opus_select_arch(void); +# endif + +/*gcc appears to emit MOVDQA's to load the argument of an _mm_cvtepi8_epi32() + or _mm_cvtepi16_epi32() when optimizations are disabled, even though the + actual PMOVSXWD instruction takes an m32 or m64. Unlike a normal memory + reference, these require 16-byte alignment and load a full 16 bytes (instead + of 4 or 8), possibly reading out of bounds. + + We can insert an explicit MOVD or MOVQ using _mm_cvtsi32_si128() or + _mm_loadl_epi64(), which should have the same semantics as an m32 or m64 + reference in the PMOVSXWD instruction itself, but gcc is not smart enough to + optimize this out when optimizations ARE enabled. + + Clang, in contrast, requires us to do this always for _mm_cvtepi8_epi32 + (which is fair, since technically the compiler is always allowed to do the + dereference before invoking the function implementing the intrinsic). + However, it is smart enough to eliminate the extra MOVD instruction. + For _mm_cvtepi16_epi32, it does the right thing, though does *not* optimize out + the extra MOVQ if it's specified explicitly */ + +# if defined(__clang__) || !defined(__OPTIMIZE__) +# define OP_CVTEPI8_EPI32_M32(x) \ + (_mm_cvtepi8_epi32(_mm_cvtsi32_si128(*(int *)(x)))) +# else +# define OP_CVTEPI8_EPI32_M32(x) \ + (_mm_cvtepi8_epi32(*(__m128i *)(x))) +#endif + +# if !defined(__OPTIMIZE__) +# define OP_CVTEPI16_EPI32_M64(x) \ + (_mm_cvtepi16_epi32(_mm_loadl_epi64((__m128i *)(x)))) +# else +# define OP_CVTEPI16_EPI32_M64(x) \ + (_mm_cvtepi16_epi32(*(__m128i *)(x))) +# endif + +#endif diff --git a/drivers/opus/http.c b/drivers/opus/http.c index 24991b0401..602d514f6e 100644 --- a/drivers/opus/http.c +++ b/drivers/opus/http.c @@ -9,9 +9,7 @@ * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * * * ********************************************************************/ -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/internal.h" #include <ctype.h> @@ -721,7 +719,7 @@ static struct addrinfo *op_resolve(const char *_host,unsigned _port){ char service[6]; memset(&hints,0,sizeof(hints)); hints.ai_socktype=SOCK_STREAM; -#if !defined(_WIN32) +#if defined(AI_NUMERICSERV) hints.ai_flags=AI_NUMERICSERV; #endif OP_ASSERT(_port<=65535U); @@ -3273,8 +3271,22 @@ static void *op_url_stream_create_impl(OpusFileCallbacks *_cb,const char *_url, #endif } -void *op_url_stream_vcreate(OpusFileCallbacks *_cb, - const char *_url,va_list _ap){ +/*The actual implementation of op_url_stream_vcreate(). + We have to do a careful dance here to avoid potential memory leaks if + OpusServerInfo is requested, since this function is also used by + op_vopen_url() and op_vtest_url(). + Even if this function succeeds, those functions might ultimately fail. + If they do, they should return without having touched the OpusServerInfo + passed by the application. + Therefore, if this function succeeds and OpusServerInfo is requested, the + actual info will be stored in *_info and a pointer to the application's + storage will be placed in *_pinfo. + If this function fails or if the application did not request OpusServerInfo, + *_pinfo will be NULL. + Our caller is responsible for copying *_info to **_pinfo if it ultimately + succeeds, or for clearing *_info if it ultimately fails.*/ +void *op_url_stream_vcreate_impl(OpusFileCallbacks *_cb, + const char *_url,OpusServerInfo *_info,OpusServerInfo **_pinfo,va_list _ap){ int skip_certificate_check; const char *proxy_host; opus_int32 proxy_port; @@ -3318,20 +3330,30 @@ void *op_url_stream_vcreate(OpusFileCallbacks *_cb, } /*If the caller has requested server information, proxy it to a local copy to simplify error handling.*/ + *_pinfo=NULL; if(pinfo!=NULL){ - OpusServerInfo info; - void *ret; - opus_server_info_init(&info); + void *ret; + opus_server_info_init(_info); ret=op_url_stream_create_impl(_cb,_url,skip_certificate_check, - proxy_host,proxy_port,proxy_user,proxy_pass,&info); - if(ret!=NULL)*pinfo=*&info; - else opus_server_info_clear(&info); + proxy_host,proxy_port,proxy_user,proxy_pass,_info); + if(ret!=NULL)*_pinfo=pinfo; + else opus_server_info_clear(_info); return ret; } return op_url_stream_create_impl(_cb,_url,skip_certificate_check, proxy_host,proxy_port,proxy_user,proxy_pass,NULL); } +void *op_url_stream_vcreate(OpusFileCallbacks *_cb, + const char *_url,va_list _ap){ + OpusServerInfo info; + OpusServerInfo *pinfo; + void *ret; + ret=op_url_stream_vcreate_impl(_cb,_url,&info,&pinfo,_ap); + if(pinfo!=NULL)*pinfo=*&info; + return ret; +} + void *op_url_stream_create(OpusFileCallbacks *_cb, const char *_url,...){ va_list ap; @@ -3347,14 +3369,21 @@ void *op_url_stream_create(OpusFileCallbacks *_cb, OggOpusFile *op_vopen_url(const char *_url,int *_error,va_list _ap){ OpusFileCallbacks cb; OggOpusFile *of; + OpusServerInfo info; + OpusServerInfo *pinfo; void *source; - source=op_url_stream_vcreate(&cb,_url,_ap); + source=op_url_stream_vcreate_impl(&cb,_url,&info,&pinfo,_ap); if(OP_UNLIKELY(source==NULL)){ + OP_ASSERT(pinfo==NULL); if(_error!=NULL)*_error=OP_EFAULT; return NULL; } of=op_open_callbacks(source,&cb,NULL,0,_error); - if(OP_UNLIKELY(of==NULL))(*cb.close)(source); + if(OP_UNLIKELY(of==NULL)){ + if(pinfo!=NULL)opus_server_info_clear(&info); + (*cb.close)(source); + } + else if(pinfo!=NULL)*pinfo=*&info; return of; } @@ -3370,14 +3399,21 @@ OggOpusFile *op_open_url(const char *_url,int *_error,...){ OggOpusFile *op_vtest_url(const char *_url,int *_error,va_list _ap){ OpusFileCallbacks cb; OggOpusFile *of; + OpusServerInfo info; + OpusServerInfo *pinfo; void *source; - source=op_url_stream_vcreate(&cb,_url,_ap); + source=op_url_stream_vcreate_impl(&cb,_url,&info,&pinfo,_ap); if(OP_UNLIKELY(source==NULL)){ + OP_ASSERT(pinfo==NULL); if(_error!=NULL)*_error=OP_EFAULT; return NULL; } of=op_test_callbacks(source,&cb,NULL,0,_error); - if(OP_UNLIKELY(of==NULL))(*cb.close)(source); + if(OP_UNLIKELY(of==NULL)){ + if(pinfo!=NULL)opus_server_info_clear(&info); + (*cb.close)(source); + } + else if(pinfo!=NULL)*pinfo=*&info; return of; } diff --git a/drivers/opus/info.c b/drivers/opus/info.c index 8175a013ac..b94393351e 100644 --- a/drivers/opus/info.c +++ b/drivers/opus/info.c @@ -9,9 +9,7 @@ * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * * * ********************************************************************/ -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/internal.h" #include <limits.h> @@ -92,8 +90,11 @@ void opus_tags_init(OpusTags *_tags){ } void opus_tags_clear(OpusTags *_tags){ + int ncomments; int ci; - for(ci=_tags->comments;ci-->0;)_ogg_free(_tags->user_comments[ci]); + ncomments=_tags->comments; + if(_tags->user_comments!=NULL)ncomments++; + for(ci=ncomments;ci-->0;)_ogg_free(_tags->user_comments[ci]); _ogg_free(_tags->user_comments); _ogg_free(_tags->comment_lengths); _ogg_free(_tags->vendor); @@ -103,19 +104,27 @@ void opus_tags_clear(OpusTags *_tags){ static int op_tags_ensure_capacity(OpusTags *_tags,size_t _ncomments){ char **user_comments; int *comment_lengths; + int cur_ncomments; + char *binary_suffix_data; + int binary_suffix_len; size_t size; if(OP_UNLIKELY(_ncomments>=(size_t)INT_MAX))return OP_EFAULT; size=sizeof(*_tags->comment_lengths)*(_ncomments+1); if(size/sizeof(*_tags->comment_lengths)!=_ncomments+1)return OP_EFAULT; + cur_ncomments=_tags->comments; + comment_lengths=_tags->comment_lengths; + binary_suffix_len=comment_lengths==NULL?0:comment_lengths[cur_ncomments]; comment_lengths=(int *)_ogg_realloc(_tags->comment_lengths,size); if(OP_UNLIKELY(comment_lengths==NULL))return OP_EFAULT; - comment_lengths[_ncomments]=0; + comment_lengths[_ncomments]=binary_suffix_len; _tags->comment_lengths=comment_lengths; size=sizeof(*_tags->user_comments)*(_ncomments+1); if(size/sizeof(*_tags->user_comments)!=_ncomments+1)return OP_EFAULT; + user_comments=_tags->user_comments; + binary_suffix_data=user_comments==NULL?NULL:user_comments[cur_ncomments]; user_comments=(char **)_ogg_realloc(_tags->user_comments,size); if(OP_UNLIKELY(user_comments==NULL))return OP_EFAULT; - user_comments[_ncomments]=NULL; + user_comments[_ncomments]=binary_suffix_data; _tags->user_comments=user_comments; return 0; } @@ -192,6 +201,13 @@ static int opus_tags_parse_impl(OpusTags *_tags, _data+=count; len-=count; } + if(len>0&&(_data[0]&1)){ + if(len>(opus_uint32)INT_MAX)return OP_EFAULT; + _tags->user_comments[ncomments]=(char *)_ogg_malloc(len); + if(OP_UNLIKELY(_tags->user_comments[ncomments]==NULL))return OP_EFAULT; + memcpy(_tags->user_comments[ncomments],_data,len); + _tags->comment_lengths[ncomments]=(int)len; + } return 0; } @@ -232,6 +248,16 @@ static int opus_tags_copy_impl(OpusTags *_dst,const OpusTags *_src){ _dst->comment_lengths[ci]=len; _dst->comments=ci+1; } + if(_src->comment_lengths!=NULL){ + int len; + len=_src->comment_lengths[ncomments]; + if(len>0){ + _dst->user_comments[ncomments]=(char *)_ogg_malloc(len); + if(OP_UNLIKELY(_dst->user_comments[ncomments]==NULL))return OP_EFAULT; + memcpy(_dst->user_comments[ncomments],_src->user_comments[ncomments],len); + _dst->comment_lengths[ncomments]=len; + } + } return 0; } @@ -257,34 +283,52 @@ int opus_tags_add(OpusTags *_tags,const char *_tag,const char *_value){ tag_len=strlen(_tag); value_len=strlen(_value); /*+2 for '=' and '\0'.*/ - _tags->comment_lengths[ncomments]=0; - _tags->user_comments[ncomments]=comment= - (char *)_ogg_malloc(sizeof(*comment)*(tag_len+value_len+2)); + comment=(char *)_ogg_malloc(sizeof(*comment)*(tag_len+value_len+2)); if(OP_UNLIKELY(comment==NULL))return OP_EFAULT; memcpy(comment,_tag,sizeof(*comment)*tag_len); comment[tag_len]='='; memcpy(comment+tag_len+1,_value,sizeof(*comment)*(value_len+1)); + _tags->user_comments[ncomments]=comment; _tags->comment_lengths[ncomments]=tag_len+value_len+1; _tags->comments=ncomments+1; return 0; } int opus_tags_add_comment(OpusTags *_tags,const char *_comment){ - int comment_len; - int ncomments; - int ret; + char *comment; + int comment_len; + int ncomments; + int ret; ncomments=_tags->comments; ret=op_tags_ensure_capacity(_tags,ncomments+1); if(OP_UNLIKELY(ret<0))return ret; comment_len=(int)strlen(_comment); - _tags->comment_lengths[ncomments]=0; - _tags->user_comments[ncomments]=op_strdup_with_len(_comment,comment_len); + comment=op_strdup_with_len(_comment,comment_len); if(OP_UNLIKELY(_tags->user_comments[ncomments]==NULL))return OP_EFAULT; + _tags->user_comments[ncomments]=comment; _tags->comment_lengths[ncomments]=comment_len; _tags->comments=ncomments+1; return 0; } +int opus_tags_set_binary_suffix(OpusTags *_tags, + const unsigned char *_data,int _len){ + unsigned char *binary_suffix_data; + int ncomments; + int ret; + if(_len<0||_len>0&&(_data==NULL||!(_data[0]&1)))return OP_EINVAL; + ncomments=_tags->comments; + ret=op_tags_ensure_capacity(_tags,ncomments); + if(OP_UNLIKELY(ret<0))return ret; + binary_suffix_data= + (unsigned char *)_ogg_realloc(_tags->user_comments[ncomments],_len); + if(OP_UNLIKELY(binary_suffix_data==NULL))return OP_EFAULT; + memcpy(binary_suffix_data,_data,_len); + _tags->user_comments[ncomments]=(char *)binary_suffix_data; + _tags->comment_lengths[ncomments]=_len; + return 0; +} + int opus_tagcompare(const char *_tag_name,const char *_comment){ return opus_tagncompare(_tag_name,strlen(_tag_name),_comment); } @@ -332,19 +376,31 @@ int opus_tags_query_count(const OpusTags *_tags,const char *_tag){ return found; } -int opus_tags_get_track_gain(const OpusTags *_tags,int *_gain_q8){ +const unsigned char *opus_tags_get_binary_suffix(const OpusTags *_tags, + int *_len){ + int ncomments; + int len; + ncomments=_tags->comments; + len=_tags->comment_lengths==NULL?0:_tags->comment_lengths[ncomments]; + *_len=len; + OP_ASSERT(len==0||_tags->user_comments!=NULL); + return len>0?(const unsigned char *)_tags->user_comments[ncomments]:NULL; +} + +static int opus_tags_get_gain(const OpusTags *_tags,int *_gain_q8, + const char *_tag_name,size_t _tag_len){ char **comments; int ncomments; int ci; comments=_tags->user_comments; ncomments=_tags->comments; - /*Look for the first valid R128_TRACK_GAIN tag and use that.*/ + /*Look for the first valid tag with the name _tag_name and use that.*/ for(ci=0;ci<ncomments;ci++){ - if(opus_tagncompare("R128_TRACK_GAIN",15,comments[ci])==0){ + if(opus_tagncompare(_tag_name,_tag_len,comments[ci])==0){ char *p; opus_int32 gain_q8; int negative; - p=comments[ci]+16; + p=comments[ci]+_tag_len+1; negative=0; if(*p=='-'){ negative=-1; @@ -358,7 +414,7 @@ int opus_tags_get_track_gain(const OpusTags *_tags,int *_gain_q8){ p++; } /*This didn't look like a signed 16-bit decimal integer. - Not a valid R128_TRACK_GAIN tag.*/ + Not a valid gain tag.*/ if(*p!='\0')continue; *_gain_q8=(int)(gain_q8+negative^negative); return 0; @@ -367,6 +423,14 @@ int opus_tags_get_track_gain(const OpusTags *_tags,int *_gain_q8){ return OP_FALSE; } +int opus_tags_get_album_gain(const OpusTags *_tags,int *_gain_q8){ + return opus_tags_get_gain(_tags,_gain_q8,"R128_ALBUM_GAIN",15); +} + +int opus_tags_get_track_gain(const OpusTags *_tags,int *_gain_q8){ + return opus_tags_get_gain(_tags,_gain_q8,"R128_TRACK_GAIN",15); +} + static int op_is_jpeg(const unsigned char *_buf,size_t _buf_sz){ return _buf_sz>=11&&memcmp(_buf,"\xFF\xD8\xFF\xE0",4)==0 &&(_buf[4]<<8|_buf[5])>=16&&memcmp(_buf+6,"JFIF",5)==0; diff --git a/drivers/opus/internal.c b/drivers/opus/internal.c index d73628ec53..bd7d2ee4bb 100644 --- a/drivers/opus/internal.c +++ b/drivers/opus/internal.c @@ -9,9 +9,7 @@ * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * * * ********************************************************************/ -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/internal.h" diff --git a/drivers/opus/internal.h b/drivers/opus/internal.h index cb4089fd4d..f7a5bd8c74 100644 --- a/drivers/opus/internal.h +++ b/drivers/opus/internal.h @@ -29,11 +29,11 @@ # endif # include <stdlib.h> -# include <opus/opusfile.h> +# include "opus/opusfile.h" typedef struct OggOpusLink OggOpusLink; -# if defined(OPUS_FIXED_POINT) +# if defined(OP_FIXED_POINT) typedef opus_int16 op_sample; @@ -186,6 +186,11 @@ struct OggOpusFile{ opus_int32 cur_discard_count; /*The granule position of the previous packet (current packet start time).*/ ogg_int64_t prev_packet_gp; + /*The stream offset of the most recent page with completed packets, or -1. + This is only needed to recover continued packet data in the seeking logic, + when we use the current position as one of our bounds, only to later + discover it was the correct starting point.*/ + opus_int64 prev_page_offset; /*The number of bytes read since the last bitrate query, including framing.*/ opus_int64 bytes_tracked; /*The number of samples decoded since the last bitrate query.*/ @@ -227,7 +232,7 @@ struct OggOpusFile{ /*The offset to apply to the gain.*/ opus_int32 gain_offset_q8; /*Internal state for soft clipping and dithering float->short output.*/ -#if !defined(OPUS_FIXED_POINT) +#if !defined(OP_FIXED_POINT) # if defined(OP_SOFT_CLIP) float clip_state[OP_NCHANNELS_MAX]; # endif diff --git a/drivers/opus/mlp.c b/drivers/opus/mlp.c index d4d4971796..125106e882 100644 --- a/drivers/opus/mlp.c +++ b/drivers/opus/mlp.c @@ -24,10 +24,7 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/opus_types.h" #include "opus/opus_defines.h" @@ -41,77 +38,82 @@ #if 0 static OPUS_INLINE opus_val16 tansig_approx(opus_val32 _x) /* Q19 */ { - int i; - opus_val16 xx; /* Q11 */ - /*double x, y;*/ - opus_val16 dy, yy; /* Q14 */ - /*x = 1.9073e-06*_x;*/ - if (_x>=QCONST32(8,19)) - return QCONST32(1.,14); - if (_x<=-QCONST32(8,19)) - return -QCONST32(1.,14); - xx = EXTRACT16(SHR32(_x, 8)); - /*i = lrint(25*x);*/ - i = SHR32(ADD32(1024,MULT16_16(25, xx)),11); - /*x -= .04*i;*/ - xx -= EXTRACT16(SHR32(MULT16_16(20972,i),8)); - /*x = xx*(1./2048);*/ - /*y = tansig_table[250+i];*/ - yy = tansig_table[250+i]; - /*y = yy*(1./16384);*/ - dy = 16384-MULT16_16_Q14(yy,yy); - yy = yy + MULT16_16_Q14(MULT16_16_Q11(xx,dy),(16384 - MULT16_16_Q11(yy,xx))); - return yy; + int i; + opus_val16 xx; /* Q11 */ + /*double x, y;*/ + opus_val16 dy, yy; /* Q14 */ + /*x = 1.9073e-06*_x;*/ + if (_x>=QCONST32(8,19)) + return QCONST32(1.,14); + if (_x<=-QCONST32(8,19)) + return -QCONST32(1.,14); + xx = EXTRACT16(SHR32(_x, 8)); + /*i = lrint(25*x);*/ + i = SHR32(ADD32(1024,MULT16_16(25, xx)),11); + /*x -= .04*i;*/ + xx -= EXTRACT16(SHR32(MULT16_16(20972,i),8)); + /*x = xx*(1./2048);*/ + /*y = tansig_table[250+i];*/ + yy = tansig_table[250+i]; + /*y = yy*(1./16384);*/ + dy = 16384-MULT16_16_Q14(yy,yy); + yy = yy + MULT16_16_Q14(MULT16_16_Q11(xx,dy),(16384 - MULT16_16_Q11(yy,xx))); + return yy; } #else /*extern const float tansig_table[501];*/ static OPUS_INLINE float tansig_approx(float x) { - int i; - float y, dy; - float sign=1; - /* Tests are reversed to catch NaNs */ + int i; + float y, dy; + float sign=1; + /* Tests are reversed to catch NaNs */ if (!(x<8)) return 1; if (!(x>-8)) return -1; - if (x<0) - { - x=-x; - sign=-1; - } - i = (int)floor(.5f+25*x); - x -= .04f*i; - y = tansig_table[i]; - dy = 1-y*y; - y = y + x*dy*(1 - y*x); - return sign*y; +#ifndef OPUS_FIXED_POINT + /* Another check in case of -ffast-math */ + if (celt_isnan(x)) + return 0; +#endif + if (x<0) + { + x=-x; + sign=-1; + } + i = (int)floor(.5f+25*x); + x -= .04f*i; + y = tansig_table[i]; + dy = 1-y*y; + y = y + x*dy*(1 - y*x); + return sign*y; } #endif #if 0 void mlp_process(const MLP *m, const opus_val16 *in, opus_val16 *out) { - int j; - opus_val16 hidden[MAX_NEURONS]; - const opus_val16 *W = m->weights; - /* Copy to tmp_in */ - for (j=0;j<m->topo[1];j++) - { - int k; - opus_val32 sum = SHL32(EXTEND32(*W++),8); - for (k=0;k<m->topo[0];k++) - sum = MAC16_16(sum, in[k],*W++); - hidden[j] = tansig_approx(sum); - } - for (j=0;j<m->topo[2];j++) - { - int k; - opus_val32 sum = SHL32(EXTEND32(*W++),14); - for (k=0;k<m->topo[1];k++) - sum = MAC16_16(sum, hidden[k], *W++); - out[j] = tansig_approx(EXTRACT16(PSHR32(sum,17))); - } + int j; + opus_val16 hidden[MAX_NEURONS]; + const opus_val16 *W = m->weights; + /* Copy to tmp_in */ + for (j=0;j<m->topo[1];j++) + { + int k; + opus_val32 sum = SHL32(EXTEND32(*W++),8); + for (k=0;k<m->topo[0];k++) + sum = MAC16_16(sum, in[k],*W++); + hidden[j] = tansig_approx(sum); + } + for (j=0;j<m->topo[2];j++) + { + int k; + opus_val32 sum = SHL32(EXTEND32(*W++),14); + for (k=0;k<m->topo[1];k++) + sum = MAC16_16(sum, hidden[k], *W++); + out[j] = tansig_approx(EXTRACT16(PSHR32(sum,17))); + } } #else void mlp_process(const MLP *m, const float *in, float *out) diff --git a/drivers/opus/mlp.h b/drivers/opus/mlp.h index 3f9ca73bb0..2b4962625d 100644 --- a/drivers/opus/mlp.h +++ b/drivers/opus/mlp.h @@ -31,11 +31,13 @@ #include "opus/celt/arch.h" typedef struct { - int layers; - const int *topo; - const float *weights; + int layers; + const int *topo; + const float *weights; } MLP; +extern const MLP net; + void mlp_process(const MLP *m, const float *in, float *out); #endif /* _MLP_H_ */ diff --git a/drivers/opus/mlp_data.c b/drivers/opus/mlp_data.c index 127c62ce8c..c542a509cf 100644 --- a/drivers/opus/mlp_data.c +++ b/drivers/opus/mlp_data.c @@ -1,5 +1,6 @@ /* The contents of this file was automatically generated by mlp_train.c It contains multi-layer perceptron (MLP) weights. */ +#include "opus/opus_config.h" #include "opus/mlp.h" diff --git a/drivers/opus/opus.c b/drivers/opus/opus.c index 5af71b478d..762a9d7469 100644 --- a/drivers/opus/opus.c +++ b/drivers/opus/opus.c @@ -24,10 +24,7 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/opus.h" #include "opus/opus_private.h" @@ -166,6 +163,27 @@ static int parse_size(const unsigned char *data, opus_int32 len, opus_int16 *siz } } +int opus_packet_get_samples_per_frame(const unsigned char *data, + opus_int32 Fs) +{ + int audiosize; + if (data[0]&0x80) + { + audiosize = ((data[0]>>3)&0x3); + audiosize = (Fs<<audiosize)/400; + } else if ((data[0]&0x60) == 0x60) + { + audiosize = (data[0]&0x08) ? Fs/50 : Fs/100; + } else { + audiosize = ((data[0]>>3)&0x3); + if (audiosize == 3) + audiosize = Fs*60/1000; + else + audiosize = (Fs<<audiosize)/100; + } + return audiosize; +} + int opus_packet_parse_impl(const unsigned char *data, opus_int32 len, int self_delimited, unsigned char *out_toc, const unsigned char *frames[48], opus_int16 size[48], diff --git a/drivers/opus/opus.h b/drivers/opus/opus.h index b99f553016..4cb171378b 100644 --- a/drivers/opus/opus.h +++ b/drivers/opus/opus.h @@ -616,7 +616,10 @@ OPUS_EXPORT void opus_pcm_soft_clip(float *pcm, int frame_size, int channels, fl * merged. Splitting valid Opus packets is always guaranteed to succeed, * whereas merging valid packets only succeeds if all frames have the same * mode, bandwidth, and frame size, and when the total duration of the merged - * packet is no more than 120 ms. + * packet is no more than 120 ms. The 120 ms limit comes from the + * specification and limits decoder memory requirements at a point where + * framing overhead becomes negligible. + * * The repacketizer currently only operates on elementary Opus * streams. It will not manipualte multistream packets successfully, except in * the degenerate case where they consist of data from a single stream. diff --git a/drivers/opus/opus_config.h b/drivers/opus/opus_config.h index 98c3e87cc6..7b9c92c6a8 100644 --- a/drivers/opus/opus_config.h +++ b/drivers/opus/opus_config.h @@ -103,6 +103,10 @@ #define USE_ALLOCA 1 #endif +#ifndef OPUS_FIXED_POINT +#define FLOAT_APPROX 1 +#endif + /* Define to `__inline__' or `__inline' if that's what the C compiler calls it, or to nothing if 'inline' is not supported under any name. */ diff --git a/drivers/opus/opus_decoder.c b/drivers/opus/opus_decoder.c index dea56015ce..b954b98f02 100644 --- a/drivers/opus/opus_decoder.c +++ b/drivers/opus/opus_decoder.c @@ -24,16 +24,13 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifdef OPUS_ENABLED -# include "opus/opus_config.h" -#endif +#include "opus/opus_config.h" #ifndef OPUS_BUILD # error "OPUS_BUILD _MUST_ be defined to build Opus. This probably means you need other defines as well, as in a config.h. See the included build files for details." #endif -#if defined(__GNUC__) && (__GNUC__ >= 2) && !defined(__OPTIMIZE__) +#if defined(__GNUC__) && (__GNUC__ >= 2) && !defined(__OPTIMIZE__) && !defined(OPUS_WILL_BE_SLOW) # pragma message "You appear to be compiling without optimization, if so opus will be very slow." #endif @@ -41,7 +38,7 @@ #include "opus/celt/celt.h" #include "opus/opus.h" #include "opus/celt/entdec.h" -#include "opus/celt/opus_modes.h" +#include "opus/celt/modes.h" #include "opus/silk/API.h" #include "opus/celt/stack_alloc.h" #include "opus/celt/float_cast.h" @@ -59,6 +56,7 @@ struct OpusDecoder { opus_int32 Fs; /** Sampling rate (at the API level) */ silk_DecControlStruct DecControl; int decode_gain; + int arch; /* Everything beyond this point gets cleared on a reset */ #define OPUS_DECODER_RESET_START stream_channels @@ -77,12 +75,6 @@ struct OpusDecoder { opus_uint32 rangeFinal; }; -#ifdef OPUS_FIXED_POINT -static OPUS_INLINE opus_int16 SAT16(opus_int32 x) { - return x > 32767 ? 32767 : x < -32768 ? -32768 : (opus_int16)x; -} -#endif - int opus_decoder_get_size(int channels) { @@ -137,6 +129,7 @@ int opus_decoder_init(OpusDecoder *st, opus_int32 Fs, int channels) st->prev_mode = 0; st->frame_size = Fs/400; + st->arch = opus_select_arch(); return OPUS_OK; } @@ -215,7 +208,7 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data, VARDECL(opus_val16, pcm_transition_silk); int pcm_transition_celt_size; VARDECL(opus_val16, pcm_transition_celt); - opus_val16 *pcm_transition; + opus_val16 *pcm_transition=NULL; int redundant_audio_size; VARDECL(opus_val16, redundant_audio); @@ -230,6 +223,7 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data, int F2_5, F5, F10, F20; const opus_val16 *window; opus_uint32 redundant_rng = 0; + int celt_accum; ALLOC_STACK; silk_dec = (char*)st+st->silk_dec_offset; @@ -295,6 +289,14 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data, } } + /* In fixed-point, we can tell CELT to do the accumulation on top of the + SILK PCM buffer. This saves some stack space. */ +#ifdef OPUS_FIXED_POINT + celt_accum = (mode != MODE_CELT_ONLY) && (frame_size >= F10); +#else + celt_accum = 0; +#endif + pcm_transition_silk_size = ALLOC_NONE; pcm_transition_celt_size = ALLOC_NONE; if (data!=NULL && st->prev_mode > 0 && ( @@ -325,14 +327,20 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data, } /* Don't allocate any memory when in CELT-only mode */ - pcm_silk_size = (mode != MODE_CELT_ONLY) ? IMAX(F10, frame_size)*st->channels : ALLOC_NONE; + pcm_silk_size = (mode != MODE_CELT_ONLY && !celt_accum) ? IMAX(F10, frame_size)*st->channels : ALLOC_NONE; ALLOC(pcm_silk, pcm_silk_size, opus_int16); /* SILK processing */ if (mode != MODE_CELT_ONLY) { int lost_flag, decoded_samples; - opus_int16 *pcm_ptr = pcm_silk; + opus_int16 *pcm_ptr; +#ifdef OPUS_FIXED_POINT + if (celt_accum) + pcm_ptr = pcm; + else +#endif + pcm_ptr = pcm_silk; if (st->prev_mode==MODE_CELT_ONLY) silk_InitDecoder( silk_dec ); @@ -366,7 +374,7 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data, /* Call SILK decoder */ int first_frame = decoded_samples == 0; silk_ret = silk_Decode( silk_dec, &st->DecControl, - lost_flag, first_frame, &dec, pcm_ptr, &silk_frame_size ); + lost_flag, first_frame, &dec, pcm_ptr, &silk_frame_size, st->arch ); if( silk_ret ) { if (lost_flag) { /* PLC failure should not be fatal */ @@ -462,7 +470,7 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data, { celt_decoder_ctl(celt_dec, CELT_SET_START_BAND(0)); celt_decode_with_ec(celt_dec, data+len, redundancy_bytes, - redundant_audio, F5, NULL); + redundant_audio, F5, NULL, 0); celt_decoder_ctl(celt_dec, OPUS_GET_FINAL_RANGE(&redundant_rng)); } @@ -477,25 +485,28 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data, celt_decoder_ctl(celt_dec, OPUS_RESET_STATE); /* Decode CELT */ celt_ret = celt_decode_with_ec(celt_dec, decode_fec ? NULL : data, - len, pcm, celt_frame_size, &dec); + len, pcm, celt_frame_size, &dec, celt_accum); } else { unsigned char silence[2] = {0xFF, 0xFF}; - for (i=0;i<frame_size*st->channels;i++) - pcm[i] = 0; + if (!celt_accum) + { + for (i=0;i<frame_size*st->channels;i++) + pcm[i] = 0; + } /* For hybrid -> SILK transitions, we let the CELT MDCT do a fade-out by decoding a silence frame */ if (st->prev_mode == MODE_HYBRID && !(redundancy && celt_to_silk && st->prev_redundancy) ) { celt_decoder_ctl(celt_dec, CELT_SET_START_BAND(0)); - celt_decode_with_ec(celt_dec, silence, 2, pcm, F2_5, NULL); + celt_decode_with_ec(celt_dec, silence, 2, pcm, F2_5, NULL, celt_accum); } } - if (mode != MODE_CELT_ONLY) + if (mode != MODE_CELT_ONLY && !celt_accum) { #ifdef OPUS_FIXED_POINT for (i=0;i<frame_size*st->channels;i++) - pcm[i] = SAT16(pcm[i] + pcm_silk[i]); + pcm[i] = SAT16(ADD32(pcm[i], pcm_silk[i])); #else for (i=0;i<frame_size*st->channels;i++) pcm[i] = pcm[i] + (opus_val16)((1.f/32768.f)*pcm_silk[i]); @@ -514,7 +525,7 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data, celt_decoder_ctl(celt_dec, OPUS_RESET_STATE); celt_decoder_ctl(celt_dec, CELT_SET_START_BAND(0)); - celt_decode_with_ec(celt_dec, data+len, redundancy_bytes, redundant_audio, F5, NULL); + celt_decode_with_ec(celt_dec, data+len, redundancy_bytes, redundant_audio, F5, NULL, 0); celt_decoder_ctl(celt_dec, OPUS_GET_FINAL_RANGE(&redundant_rng)); smooth_fade(pcm+st->channels*(frame_size-F2_5), redundant_audio+st->channels*F2_5, pcm+st->channels*(frame_size-F2_5), F2_5, st->channels, window, st->Fs); @@ -710,6 +721,7 @@ int opus_decode_float(OpusDecoder *st, const unsigned char *data, { VARDECL(opus_int16, out); int ret, i; + int nb_samples; ALLOC_STACK; if(frame_size<=0) @@ -717,6 +729,14 @@ int opus_decode_float(OpusDecoder *st, const unsigned char *data, RESTORE_STACK; return OPUS_BAD_ARG; } + if (data != NULL && len > 0 && !decode_fec) + { + nb_samples = opus_decoder_get_nb_samples(st, data, len); + if (nb_samples>0) + frame_size = IMIN(frame_size, nb_samples); + else + return OPUS_INVALID_PACKET; + } ALLOC(out, frame_size*st->channels, opus_int16); ret = opus_decode_native(st, data, len, out, frame_size, decode_fec, 0, NULL, 0); @@ -737,6 +757,7 @@ int opus_decode(OpusDecoder *st, const unsigned char *data, { VARDECL(float, out); int ret, i; + int nb_samples; ALLOC_STACK; if(frame_size<=0) @@ -745,6 +766,14 @@ int opus_decode(OpusDecoder *st, const unsigned char *data, return OPUS_BAD_ARG; } + if (data != NULL && len > 0 && !decode_fec) + { + nb_samples = opus_decoder_get_nb_samples(st, data, len); + if (nb_samples>0) + frame_size = IMIN(frame_size, nb_samples); + else + return OPUS_INVALID_PACKET; + } ALLOC(out, frame_size*st->channels, float); ret = opus_decode_native(st, data, len, out, frame_size, decode_fec, 0, NULL, 1); @@ -904,27 +933,6 @@ int opus_packet_get_bandwidth(const unsigned char *data) return bandwidth; } -int opus_packet_get_samples_per_frame(const unsigned char *data, - opus_int32 Fs) -{ - int audiosize; - if (data[0]&0x80) - { - audiosize = ((data[0]>>3)&0x3); - audiosize = (Fs<<audiosize)/400; - } else if ((data[0]&0x60) == 0x60) - { - audiosize = (data[0]&0x08) ? Fs/50 : Fs/100; - } else { - audiosize = ((data[0]>>3)&0x3); - if (audiosize == 3) - audiosize = Fs*60/1000; - else - audiosize = (Fs<<audiosize)/100; - } - return audiosize; -} - int opus_packet_get_nb_channels(const unsigned char *data) { return (data[0]&0x4) ? 2 : 1; diff --git a/drivers/opus/opus_defines.h b/drivers/opus/opus_defines.h index 9d089d8391..b972ce0eb9 100644 --- a/drivers/opus/opus_defines.h +++ b/drivers/opus/opus_defines.h @@ -46,7 +46,7 @@ extern "C" { #define OPUS_OK 0 /** One or more invalid/out of range arguments @hideinitializer*/ #define OPUS_BAD_ARG -1 -/** The mode struct passed is invalid @hideinitializer*/ +/** Not enough bytes allocated in the buffer @hideinitializer*/ #define OPUS_BUFFER_TOO_SMALL -2 /** An internal error was detected @hideinitializer*/ #define OPUS_INTERNAL_ERROR -3 @@ -274,7 +274,6 @@ extern "C" { /** Enables or disables variable bitrate (VBR) in the encoder. * The configured bitrate may not be met exactly because frames must * be an integer number of bytes in length. - * @warning Only the MDCT mode of Opus can provide hard CBR behavior. * @see OPUS_GET_VBR * @see OPUS_SET_VBR_CONSTRAINT * @param[in] x <tt>opus_int32</tt>: Allowed values: @@ -454,14 +453,6 @@ extern "C" { * @hideinitializer */ #define OPUS_GET_APPLICATION(x) OPUS_GET_APPLICATION_REQUEST, __opus_check_int_ptr(x) -/** Gets the sampling rate the encoder or decoder was initialized with. - * This simply returns the <code>Fs</code> value passed to opus_encoder_init() - * or opus_decoder_init(). - * @param[out] x <tt>opus_int32 *</tt>: Sampling rate of encoder or decoder. - * @hideinitializer - */ -#define OPUS_GET_SAMPLE_RATE(x) OPUS_GET_SAMPLE_RATE_REQUEST, __opus_check_int_ptr(x) - /** Gets the total samples of delay added by the entire codec. * This can be queried by the encoder and then the provided number of samples can be * skipped on from the start of the decoder's output to provide time aligned input @@ -498,9 +489,9 @@ extern "C" { #define OPUS_GET_INBAND_FEC(x) OPUS_GET_INBAND_FEC_REQUEST, __opus_check_int_ptr(x) /** Configures the encoder's expected packet loss percentage. - * Higher values with trigger progressively more loss resistant behavior in the encoder - * at the expense of quality at a given bitrate in the lossless case, but greater quality - * under loss. + * Higher values trigger progressively more loss resistant behavior in the encoder + * at the expense of quality at a given bitrate in the absence of packet loss, but + * greater quality under loss. * @see OPUS_GET_PACKET_LOSS_PERC * @param[in] x <tt>opus_int32</tt>: Loss percentage in the range 0-100, inclusive (default: 0). * @hideinitializer */ @@ -532,7 +523,19 @@ extern "C" { * @hideinitializer */ #define OPUS_GET_DTX(x) OPUS_GET_DTX_REQUEST, __opus_check_int_ptr(x) /** Configures the depth of signal being encoded. + * * This is a hint which helps the encoder identify silence and near-silence. + * It represents the number of significant bits of linear intensity below + * which the signal contains ignorable quantization or other noise. + * + * For example, OPUS_SET_LSB_DEPTH(14) would be an appropriate setting + * for G.711 u-law input. OPUS_SET_LSB_DEPTH(16) would be appropriate + * for 16-bit linear pcm input with opus_encode_float(). + * + * When using opus_encode() instead of opus_encode_float(), or when libopus + * is compiled for fixed-point, the encoder uses the minimum of the value + * set here and the value 16. + * * @see OPUS_GET_LSB_DEPTH * @param[in] x <tt>opus_int32</tt>: Input precision in bits, between 8 and 24 * (default: 24). @@ -545,11 +548,6 @@ extern "C" { * @hideinitializer */ #define OPUS_GET_LSB_DEPTH(x) OPUS_GET_LSB_DEPTH_REQUEST, __opus_check_int_ptr(x) -/** Gets the duration (in samples) of the last packet successfully decoded or concealed. - * @param[out] x <tt>opus_int32 *</tt>: Number of samples (at current sampling rate). - * @hideinitializer */ -#define OPUS_GET_LAST_PACKET_DURATION(x) OPUS_GET_LAST_PACKET_DURATION_REQUEST, __opus_check_int_ptr(x) - /** Configures the encoder's use of variable duration frames. * When variable duration is enabled, the encoder is free to use a shorter frame * size than the one requested in the opus_encode*() call. @@ -558,12 +556,12 @@ extern "C" { * packet. The part of the audio that was not encoded needs to be resent to the * encoder for the next call. Do not use this option unless you <b>really</b> * know what you are doing. - * @see OPUS_GET_EXPERT_VARIABLE_DURATION + * @see OPUS_GET_EXPERT_FRAME_DURATION * @param[in] x <tt>opus_int32</tt>: Allowed values: * <dl> * <dt>OPUS_FRAMESIZE_ARG</dt><dd>Select frame size from the argument (default).</dd> * <dt>OPUS_FRAMESIZE_2_5_MS</dt><dd>Use 2.5 ms frames.</dd> - * <dt>OPUS_FRAMESIZE_5_MS</dt><dd>Use 2.5 ms frames.</dd> + * <dt>OPUS_FRAMESIZE_5_MS</dt><dd>Use 5 ms frames.</dd> * <dt>OPUS_FRAMESIZE_10_MS</dt><dd>Use 10 ms frames.</dd> * <dt>OPUS_FRAMESIZE_20_MS</dt><dd>Use 20 ms frames.</dd> * <dt>OPUS_FRAMESIZE_40_MS</dt><dd>Use 40 ms frames.</dd> @@ -573,12 +571,12 @@ extern "C" { * @hideinitializer */ #define OPUS_SET_EXPERT_FRAME_DURATION(x) OPUS_SET_EXPERT_FRAME_DURATION_REQUEST, __opus_check_int(x) /** Gets the encoder's configured use of variable duration frames. - * @see OPUS_SET_EXPERT_VARIABLE_DURATION + * @see OPUS_SET_EXPERT_FRAME_DURATION * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: * <dl> * <dt>OPUS_FRAMESIZE_ARG</dt><dd>Select frame size from the argument (default).</dd> * <dt>OPUS_FRAMESIZE_2_5_MS</dt><dd>Use 2.5 ms frames.</dd> - * <dt>OPUS_FRAMESIZE_5_MS</dt><dd>Use 2.5 ms frames.</dd> + * <dt>OPUS_FRAMESIZE_5_MS</dt><dd>Use 5 ms frames.</dd> * <dt>OPUS_FRAMESIZE_10_MS</dt><dd>Use 10 ms frames.</dd> * <dt>OPUS_FRAMESIZE_20_MS</dt><dd>Use 20 ms frames.</dd> * <dt>OPUS_FRAMESIZE_40_MS</dt><dd>Use 40 ms frames.</dd> @@ -589,10 +587,22 @@ extern "C" { #define OPUS_GET_EXPERT_FRAME_DURATION(x) OPUS_GET_EXPERT_FRAME_DURATION_REQUEST, __opus_check_int_ptr(x) /** If set to 1, disables almost all use of prediction, making frames almost - completely independent. This reduces quality. (default : 0) + * completely independent. This reduces quality. + * @see OPUS_GET_PREDICTION_DISABLED + * @param[in] x <tt>opus_int32</tt>: Allowed values: + * <dl> + * <dt>0</dt><dd>Enable prediction (default).</dd> + * <dt>1</dt><dd>Disable prediction.</dd> + * </dl> * @hideinitializer */ #define OPUS_SET_PREDICTION_DISABLED(x) OPUS_SET_PREDICTION_DISABLED_REQUEST, __opus_check_int(x) /** Gets the encoder's configured prediction status. + * @see OPUS_SET_PREDICTION_DISABLED + * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: + * <dl> + * <dt>0</dt><dd>Prediction enabled (default).</dd> + * <dt>1</dt><dd>Prediction disabled.</dd> + * </dl> * @hideinitializer */ #define OPUS_GET_PREDICTION_DISABLED(x) OPUS_GET_PREDICTION_DISABLED_REQUEST, __opus_check_int_ptr(x) @@ -649,18 +659,6 @@ extern "C" { * @hideinitializer */ #define OPUS_GET_FINAL_RANGE(x) OPUS_GET_FINAL_RANGE_REQUEST, __opus_check_uint_ptr(x) -/** Gets the pitch of the last decoded frame, if available. - * This can be used for any post-processing algorithm requiring the use of pitch, - * e.g. time stretching/shortening. If the last frame was not voiced, or if the - * pitch was not coded in the frame, then zero is returned. - * - * This CTL is only implemented for decoder instances. - * - * @param[out] x <tt>opus_int32 *</tt>: pitch period at 48 kHz (or 0 if not available) - * - * @hideinitializer */ -#define OPUS_GET_PITCH(x) OPUS_GET_PITCH_REQUEST, __opus_check_int_ptr(x) - /** Gets the encoder's configured bandpass or the decoder's last bandpass. * @see OPUS_SET_BANDWIDTH * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: @@ -675,6 +673,14 @@ extern "C" { * @hideinitializer */ #define OPUS_GET_BANDWIDTH(x) OPUS_GET_BANDWIDTH_REQUEST, __opus_check_int_ptr(x) +/** Gets the sampling rate the encoder or decoder was initialized with. + * This simply returns the <code>Fs</code> value passed to opus_encoder_init() + * or opus_decoder_init(). + * @param[out] x <tt>opus_int32 *</tt>: Sampling rate of encoder or decoder. + * @hideinitializer + */ +#define OPUS_GET_SAMPLE_RATE(x) OPUS_GET_SAMPLE_RATE_REQUEST, __opus_check_int_ptr(x) + /**@}*/ /** @defgroup opus_decoderctls Decoder related CTLs @@ -699,6 +705,23 @@ extern "C" { * @hideinitializer */ #define OPUS_GET_GAIN(x) OPUS_GET_GAIN_REQUEST, __opus_check_int_ptr(x) +/** Gets the duration (in samples) of the last packet successfully decoded or concealed. + * @param[out] x <tt>opus_int32 *</tt>: Number of samples (at current sampling rate). + * @hideinitializer */ +#define OPUS_GET_LAST_PACKET_DURATION(x) OPUS_GET_LAST_PACKET_DURATION_REQUEST, __opus_check_int_ptr(x) + +/** Gets the pitch of the last decoded frame, if available. + * This can be used for any post-processing algorithm requiring the use of pitch, + * e.g. time stretching/shortening. If the last frame was not voiced, or if the + * pitch was not coded in the frame, then zero is returned. + * + * This CTL is only implemented for decoder instances. + * + * @param[out] x <tt>opus_int32 *</tt>: pitch period at 48 kHz (or 0 if not available) + * + * @hideinitializer */ +#define OPUS_GET_PITCH(x) OPUS_GET_PITCH_REQUEST, __opus_check_int_ptr(x) + /**@}*/ /** @defgroup opus_libinfo Opus library information functions @@ -714,6 +737,10 @@ OPUS_EXPORT const char *opus_strerror(int error); /** Gets the libopus version string. * + * Applications may look for the substring "-fixed" in the version string to + * determine whether they have a fixed-point or floating-point build at + * runtime. + * * @returns Version string */ OPUS_EXPORT const char *opus_get_version_string(void); diff --git a/drivers/opus/opus_demo.c b/drivers/opus/opus_demo.c deleted file mode 100644 index a0c5a5f862..0000000000 --- a/drivers/opus/opus_demo.c +++ /dev/null @@ -1,885 +0,0 @@ -/* Copyright (c) 2007-2008 CSIRO - Copyright (c) 2007-2009 Xiph.Org Foundation - Written by Jean-Marc Valin */ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER - OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifdef OPUS_ENABLED -#include "opus/opus_config.h" -#endif - -#include <stdio.h> -#include <stdlib.h> -#include <math.h> -#include <string.h> -#include "opus/opus.h" -#include "opus/silk/debug.h" -#include "opus/opus_types.h" -#include "opus/opus_private.h" -#include "opus/opus_multistream.h" - -#define MAX_PACKET 1500 - -void print_usage( char* argv[] ) -{ - fprintf(stderr, "Usage: %s [-e] <application> <sampling rate (Hz)> <channels (1/2)> " - "<bits per second> [options] <input> <output>\n", argv[0]); - fprintf(stderr, " %s -d <sampling rate (Hz)> <channels (1/2)> " - "[options] <input> <output>\n\n", argv[0]); - fprintf(stderr, "mode: voip | audio | restricted-lowdelay\n" ); - fprintf(stderr, "options:\n" ); - fprintf(stderr, "-e : only runs the encoder (output the bit-stream)\n" ); - fprintf(stderr, "-d : only runs the decoder (reads the bit-stream as input)\n" ); - fprintf(stderr, "-cbr : enable constant bitrate; default: variable bitrate\n" ); - fprintf(stderr, "-cvbr : enable constrained variable bitrate; default: unconstrained\n" ); - fprintf(stderr, "-variable-duration : enable frames of variable duration (experts only); default: disabled\n" ); - fprintf(stderr, "-bandwidth <NB|MB|WB|SWB|FB> : audio bandwidth (from narrowband to fullband); default: sampling rate\n" ); - fprintf(stderr, "-framesize <2.5|5|10|20|40|60> : frame size in ms; default: 20 \n" ); - fprintf(stderr, "-max_payload <bytes> : maximum payload size in bytes, default: 1024\n" ); - fprintf(stderr, "-complexity <comp> : complexity, 0 (lowest) ... 10 (highest); default: 10\n" ); - fprintf(stderr, "-inbandfec : enable SILK inband FEC\n" ); - fprintf(stderr, "-forcemono : force mono encoding, even for stereo input\n" ); - fprintf(stderr, "-dtx : enable SILK DTX\n" ); - fprintf(stderr, "-loss <perc> : simulate packet loss, in percent (0-100); default: 0\n" ); -} - -static void int_to_char(opus_uint32 i, unsigned char ch[4]) -{ - ch[0] = i>>24; - ch[1] = (i>>16)&0xFF; - ch[2] = (i>>8)&0xFF; - ch[3] = i&0xFF; -} - -static opus_uint32 char_to_int(unsigned char ch[4]) -{ - return ((opus_uint32)ch[0]<<24) | ((opus_uint32)ch[1]<<16) - | ((opus_uint32)ch[2]<< 8) | (opus_uint32)ch[3]; -} - -static void check_encoder_option(int decode_only, const char *opt) -{ - if (decode_only) - { - fprintf(stderr, "option %s is only for encoding\n", opt); - exit(EXIT_FAILURE); - } -} - -static const int silk8_test[][4] = { - {MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 960*3, 1}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 960*2, 1}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 960, 1}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 480, 1}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 960*3, 2}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 960*2, 2}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 960, 2}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 480, 2} -}; - -static const int silk12_test[][4] = { - {MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 960*3, 1}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 960*2, 1}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 960, 1}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 480, 1}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 960*3, 2}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 960*2, 2}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 960, 2}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 480, 2} -}; - -static const int silk16_test[][4] = { - {MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 960*3, 1}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 960*2, 1}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 960, 1}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 480, 1}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 960*3, 2}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 960*2, 2}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 960, 2}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 480, 2} -}; - -static const int hybrid24_test[][4] = { - {MODE_SILK_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 960, 1}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 480, 1}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 960, 2}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 480, 2} -}; - -static const int hybrid48_test[][4] = { - {MODE_SILK_ONLY, OPUS_BANDWIDTH_FULLBAND, 960, 1}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_FULLBAND, 480, 1}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_FULLBAND, 960, 2}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_FULLBAND, 480, 2} -}; - -static const int celt_test[][4] = { - {MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 960, 1}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 960, 1}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_WIDEBAND, 960, 1}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_NARROWBAND, 960, 1}, - - {MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 480, 1}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 480, 1}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_WIDEBAND, 480, 1}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_NARROWBAND, 480, 1}, - - {MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 240, 1}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 240, 1}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_WIDEBAND, 240, 1}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_NARROWBAND, 240, 1}, - - {MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 120, 1}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 120, 1}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_WIDEBAND, 120, 1}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_NARROWBAND, 120, 1}, - - {MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 960, 2}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 960, 2}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_WIDEBAND, 960, 2}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_NARROWBAND, 960, 2}, - - {MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 480, 2}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 480, 2}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_WIDEBAND, 480, 2}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_NARROWBAND, 480, 2}, - - {MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 240, 2}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 240, 2}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_WIDEBAND, 240, 2}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_NARROWBAND, 240, 2}, - - {MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 120, 2}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 120, 2}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_WIDEBAND, 120, 2}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_NARROWBAND, 120, 2}, - -}; - -static const int celt_hq_test[][4] = { - {MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 960, 2}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 480, 2}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 240, 2}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 120, 2}, -}; - -#if 0 /* This is a hack that replaces the normal encoder/decoder with the multistream version */ -#define OpusEncoder OpusMSEncoder -#define OpusDecoder OpusMSDecoder -#define opus_encode opus_multistream_encode -#define opus_decode opus_multistream_decode -#define opus_encoder_ctl opus_multistream_encoder_ctl -#define opus_decoder_ctl opus_multistream_decoder_ctl -#define opus_encoder_create ms_opus_encoder_create -#define opus_decoder_create ms_opus_decoder_create -#define opus_encoder_destroy opus_multistream_encoder_destroy -#define opus_decoder_destroy opus_multistream_decoder_destroy - -static OpusEncoder *ms_opus_encoder_create(opus_int32 Fs, int channels, int application, int *error) -{ - int streams, coupled_streams; - unsigned char mapping[256]; - return (OpusEncoder *)opus_multistream_surround_encoder_create(Fs, channels, 1, &streams, &coupled_streams, mapping, application, error); -} -static OpusDecoder *ms_opus_decoder_create(opus_int32 Fs, int channels, int *error) -{ - int streams; - int coupled_streams; - unsigned char mapping[256]={0,1}; - streams = 1; - coupled_streams = channels==2; - return (OpusDecoder *)opus_multistream_decoder_create(Fs, channels, streams, coupled_streams, mapping, error); -} -#endif - -int main(int argc, char *argv[]) -{ - int err; - char *inFile, *outFile; - FILE *fin, *fout; - OpusEncoder *enc=NULL; - OpusDecoder *dec=NULL; - int args; - int len[2]; - int frame_size, channels; - opus_int32 bitrate_bps=0; - unsigned char *data[2]; - unsigned char *fbytes; - opus_int32 sampling_rate; - int use_vbr; - int max_payload_bytes; - int complexity; - int use_inbandfec; - int use_dtx; - int forcechannels; - int cvbr = 0; - int packet_loss_perc; - opus_int32 count=0, count_act=0; - int k; - opus_int32 skip=0; - int stop=0; - short *in, *out; - int application=OPUS_APPLICATION_AUDIO; - double bits=0.0, bits_max=0.0, bits_act=0.0, bits2=0.0, nrg; - double tot_samples=0; - opus_uint64 tot_in, tot_out; - int bandwidth=-1; - const char *bandwidth_string; - int lost = 0, lost_prev = 1; - int toggle = 0; - opus_uint32 enc_final_range[2]; - opus_uint32 dec_final_range; - int encode_only=0, decode_only=0; - int max_frame_size = 960*6; - int curr_read=0; - int sweep_bps = 0; - int random_framesize=0, newsize=0, delayed_celt=0; - int sweep_max=0, sweep_min=0; - int random_fec=0; - const int (*mode_list)[4]=NULL; - int nb_modes_in_list=0; - int curr_mode=0; - int curr_mode_count=0; - int mode_switch_time = 48000; - int nb_encoded=0; - int remaining=0; - int variable_duration=OPUS_FRAMESIZE_ARG; - int delayed_decision=0; - - if (argc < 5 ) - { - print_usage( argv ); - return EXIT_FAILURE; - } - - tot_in=tot_out=0; - fprintf(stderr, "%s\n", opus_get_version_string()); - - args = 1; - if (strcmp(argv[args], "-e")==0) - { - encode_only = 1; - args++; - } else if (strcmp(argv[args], "-d")==0) - { - decode_only = 1; - args++; - } - if (!decode_only && argc < 7 ) - { - print_usage( argv ); - return EXIT_FAILURE; - } - - if (!decode_only) - { - if (strcmp(argv[args], "voip")==0) - application = OPUS_APPLICATION_VOIP; - else if (strcmp(argv[args], "restricted-lowdelay")==0) - application = OPUS_APPLICATION_RESTRICTED_LOWDELAY; - else if (strcmp(argv[args], "audio")!=0) { - fprintf(stderr, "unknown application: %s\n", argv[args]); - print_usage(argv); - return EXIT_FAILURE; - } - args++; - } - sampling_rate = (opus_int32)atol(argv[args]); - args++; - - if (sampling_rate != 8000 && sampling_rate != 12000 - && sampling_rate != 16000 && sampling_rate != 24000 - && sampling_rate != 48000) - { - fprintf(stderr, "Supported sampling rates are 8000, 12000, " - "16000, 24000 and 48000.\n"); - return EXIT_FAILURE; - } - frame_size = sampling_rate/50; - - channels = atoi(argv[args]); - args++; - - if (channels < 1 || channels > 2) - { - fprintf(stderr, "Opus_demo supports only 1 or 2 channels.\n"); - return EXIT_FAILURE; - } - - if (!decode_only) - { - bitrate_bps = (opus_int32)atol(argv[args]); - args++; - } - - /* defaults: */ - use_vbr = 1; - bandwidth = OPUS_AUTO; - max_payload_bytes = MAX_PACKET; - complexity = 10; - use_inbandfec = 0; - forcechannels = OPUS_AUTO; - use_dtx = 0; - packet_loss_perc = 0; - max_frame_size = 2*48000; - curr_read=0; - - while( args < argc - 2 ) { - /* process command line options */ - if( strcmp( argv[ args ], "-cbr" ) == 0 ) { - check_encoder_option(decode_only, "-cbr"); - use_vbr = 0; - args++; - } else if( strcmp( argv[ args ], "-bandwidth" ) == 0 ) { - check_encoder_option(decode_only, "-bandwidth"); - if (strcmp(argv[ args + 1 ], "NB")==0) - bandwidth = OPUS_BANDWIDTH_NARROWBAND; - else if (strcmp(argv[ args + 1 ], "MB")==0) - bandwidth = OPUS_BANDWIDTH_MEDIUMBAND; - else if (strcmp(argv[ args + 1 ], "WB")==0) - bandwidth = OPUS_BANDWIDTH_WIDEBAND; - else if (strcmp(argv[ args + 1 ], "SWB")==0) - bandwidth = OPUS_BANDWIDTH_SUPERWIDEBAND; - else if (strcmp(argv[ args + 1 ], "FB")==0) - bandwidth = OPUS_BANDWIDTH_FULLBAND; - else { - fprintf(stderr, "Unknown bandwidth %s. " - "Supported are NB, MB, WB, SWB, FB.\n", - argv[ args + 1 ]); - return EXIT_FAILURE; - } - args += 2; - } else if( strcmp( argv[ args ], "-framesize" ) == 0 ) { - check_encoder_option(decode_only, "-framesize"); - if (strcmp(argv[ args + 1 ], "2.5")==0) - frame_size = sampling_rate/400; - else if (strcmp(argv[ args + 1 ], "5")==0) - frame_size = sampling_rate/200; - else if (strcmp(argv[ args + 1 ], "10")==0) - frame_size = sampling_rate/100; - else if (strcmp(argv[ args + 1 ], "20")==0) - frame_size = sampling_rate/50; - else if (strcmp(argv[ args + 1 ], "40")==0) - frame_size = sampling_rate/25; - else if (strcmp(argv[ args + 1 ], "60")==0) - frame_size = 3*sampling_rate/50; - else { - fprintf(stderr, "Unsupported frame size: %s ms. " - "Supported are 2.5, 5, 10, 20, 40, 60.\n", - argv[ args + 1 ]); - return EXIT_FAILURE; - } - args += 2; - } else if( strcmp( argv[ args ], "-max_payload" ) == 0 ) { - check_encoder_option(decode_only, "-max_payload"); - max_payload_bytes = atoi( argv[ args + 1 ] ); - args += 2; - } else if( strcmp( argv[ args ], "-complexity" ) == 0 ) { - check_encoder_option(decode_only, "-complexity"); - complexity = atoi( argv[ args + 1 ] ); - args += 2; - } else if( strcmp( argv[ args ], "-inbandfec" ) == 0 ) { - use_inbandfec = 1; - args++; - } else if( strcmp( argv[ args ], "-forcemono" ) == 0 ) { - check_encoder_option(decode_only, "-forcemono"); - forcechannels = 1; - args++; - } else if( strcmp( argv[ args ], "-cvbr" ) == 0 ) { - check_encoder_option(decode_only, "-cvbr"); - cvbr = 1; - args++; - } else if( strcmp( argv[ args ], "-variable-duration" ) == 0 ) { - check_encoder_option(decode_only, "-variable-duration"); - variable_duration = OPUS_FRAMESIZE_VARIABLE; - args++; - } else if( strcmp( argv[ args ], "-delayed-decision" ) == 0 ) { - check_encoder_option(decode_only, "-delayed-decision"); - delayed_decision = 1; - args++; - } else if( strcmp( argv[ args ], "-dtx") == 0 ) { - check_encoder_option(decode_only, "-dtx"); - use_dtx = 1; - args++; - } else if( strcmp( argv[ args ], "-loss" ) == 0 ) { - packet_loss_perc = atoi( argv[ args + 1 ] ); - args += 2; - } else if( strcmp( argv[ args ], "-sweep" ) == 0 ) { - check_encoder_option(decode_only, "-sweep"); - sweep_bps = atoi( argv[ args + 1 ] ); - args += 2; - } else if( strcmp( argv[ args ], "-random_framesize" ) == 0 ) { - check_encoder_option(decode_only, "-random_framesize"); - random_framesize = 1; - args++; - } else if( strcmp( argv[ args ], "-sweep_max" ) == 0 ) { - check_encoder_option(decode_only, "-sweep_max"); - sweep_max = atoi( argv[ args + 1 ] ); - args += 2; - } else if( strcmp( argv[ args ], "-random_fec" ) == 0 ) { - check_encoder_option(decode_only, "-random_fec"); - random_fec = 1; - args++; - } else if( strcmp( argv[ args ], "-silk8k_test" ) == 0 ) { - check_encoder_option(decode_only, "-silk8k_test"); - mode_list = silk8_test; - nb_modes_in_list = 8; - args++; - } else if( strcmp( argv[ args ], "-silk12k_test" ) == 0 ) { - check_encoder_option(decode_only, "-silk12k_test"); - mode_list = silk12_test; - nb_modes_in_list = 8; - args++; - } else if( strcmp( argv[ args ], "-silk16k_test" ) == 0 ) { - check_encoder_option(decode_only, "-silk16k_test"); - mode_list = silk16_test; - nb_modes_in_list = 8; - args++; - } else if( strcmp( argv[ args ], "-hybrid24k_test" ) == 0 ) { - check_encoder_option(decode_only, "-hybrid24k_test"); - mode_list = hybrid24_test; - nb_modes_in_list = 4; - args++; - } else if( strcmp( argv[ args ], "-hybrid48k_test" ) == 0 ) { - check_encoder_option(decode_only, "-hybrid48k_test"); - mode_list = hybrid48_test; - nb_modes_in_list = 4; - args++; - } else if( strcmp( argv[ args ], "-celt_test" ) == 0 ) { - check_encoder_option(decode_only, "-celt_test"); - mode_list = celt_test; - nb_modes_in_list = 32; - args++; - } else if( strcmp( argv[ args ], "-celt_hq_test" ) == 0 ) { - check_encoder_option(decode_only, "-celt_hq_test"); - mode_list = celt_hq_test; - nb_modes_in_list = 4; - args++; - } else { - printf( "Error: unrecognized setting: %s\n\n", argv[ args ] ); - print_usage( argv ); - return EXIT_FAILURE; - } - } - - if (sweep_max) - sweep_min = bitrate_bps; - - if (max_payload_bytes < 0 || max_payload_bytes > MAX_PACKET) - { - fprintf (stderr, "max_payload_bytes must be between 0 and %d\n", - MAX_PACKET); - return EXIT_FAILURE; - } - - inFile = argv[argc-2]; - fin = fopen(inFile, "rb"); - if (!fin) - { - fprintf (stderr, "Could not open input file %s\n", argv[argc-2]); - return EXIT_FAILURE; - } - if (mode_list) - { - int size; - fseek(fin, 0, SEEK_END); - size = ftell(fin); - fprintf(stderr, "File size is %d bytes\n", size); - fseek(fin, 0, SEEK_SET); - mode_switch_time = size/sizeof(short)/channels/nb_modes_in_list; - fprintf(stderr, "Switching mode every %d samples\n", mode_switch_time); - } - - outFile = argv[argc-1]; - fout = fopen(outFile, "wb+"); - if (!fout) - { - fprintf (stderr, "Could not open output file %s\n", argv[argc-1]); - fclose(fin); - return EXIT_FAILURE; - } - - if (!decode_only) - { - enc = opus_encoder_create(sampling_rate, channels, application, &err); - if (err != OPUS_OK) - { - fprintf(stderr, "Cannot create encoder: %s\n", opus_strerror(err)); - fclose(fin); - fclose(fout); - return EXIT_FAILURE; - } - opus_encoder_ctl(enc, OPUS_SET_BITRATE(bitrate_bps)); - opus_encoder_ctl(enc, OPUS_SET_BANDWIDTH(bandwidth)); - opus_encoder_ctl(enc, OPUS_SET_VBR(use_vbr)); - opus_encoder_ctl(enc, OPUS_SET_VBR_CONSTRAINT(cvbr)); - opus_encoder_ctl(enc, OPUS_SET_COMPLEXITY(complexity)); - opus_encoder_ctl(enc, OPUS_SET_INBAND_FEC(use_inbandfec)); - opus_encoder_ctl(enc, OPUS_SET_FORCE_CHANNELS(forcechannels)); - opus_encoder_ctl(enc, OPUS_SET_DTX(use_dtx)); - opus_encoder_ctl(enc, OPUS_SET_PACKET_LOSS_PERC(packet_loss_perc)); - - opus_encoder_ctl(enc, OPUS_GET_LOOKAHEAD(&skip)); - opus_encoder_ctl(enc, OPUS_SET_LSB_DEPTH(16)); - opus_encoder_ctl(enc, OPUS_SET_EXPERT_FRAME_DURATION(variable_duration)); - } - if (!encode_only) - { - dec = opus_decoder_create(sampling_rate, channels, &err); - if (err != OPUS_OK) - { - fprintf(stderr, "Cannot create decoder: %s\n", opus_strerror(err)); - fclose(fin); - fclose(fout); - return EXIT_FAILURE; - } - } - - - switch(bandwidth) - { - case OPUS_BANDWIDTH_NARROWBAND: - bandwidth_string = "narrowband"; - break; - case OPUS_BANDWIDTH_MEDIUMBAND: - bandwidth_string = "mediumband"; - break; - case OPUS_BANDWIDTH_WIDEBAND: - bandwidth_string = "wideband"; - break; - case OPUS_BANDWIDTH_SUPERWIDEBAND: - bandwidth_string = "superwideband"; - break; - case OPUS_BANDWIDTH_FULLBAND: - bandwidth_string = "fullband"; - break; - case OPUS_AUTO: - bandwidth_string = "auto"; - break; - default: - bandwidth_string = "unknown"; - break; - } - - if (decode_only) - fprintf(stderr, "Decoding with %ld Hz output (%d channels)\n", - (long)sampling_rate, channels); - else - fprintf(stderr, "Encoding %ld Hz input at %.3f kb/s " - "in %s mode with %d-sample frames.\n", - (long)sampling_rate, bitrate_bps*0.001, - bandwidth_string, frame_size); - - in = (short*)malloc(max_frame_size*channels*sizeof(short)); - out = (short*)malloc(max_frame_size*channels*sizeof(short)); - fbytes = (unsigned char*)malloc(max_frame_size*channels*sizeof(short)); - data[0] = (unsigned char*)calloc(max_payload_bytes,sizeof(char)); - if ( use_inbandfec ) { - data[1] = (unsigned char*)calloc(max_payload_bytes,sizeof(char)); - } - if(delayed_decision) - { - if (variable_duration!=OPUS_FRAMESIZE_VARIABLE) - { - if (frame_size==sampling_rate/400) - variable_duration = OPUS_FRAMESIZE_2_5_MS; - else if (frame_size==sampling_rate/200) - variable_duration = OPUS_FRAMESIZE_5_MS; - else if (frame_size==sampling_rate/100) - variable_duration = OPUS_FRAMESIZE_10_MS; - else if (frame_size==sampling_rate/50) - variable_duration = OPUS_FRAMESIZE_20_MS; - else if (frame_size==sampling_rate/25) - variable_duration = OPUS_FRAMESIZE_40_MS; - else - variable_duration = OPUS_FRAMESIZE_60_MS; - opus_encoder_ctl(enc, OPUS_SET_EXPERT_FRAME_DURATION(variable_duration)); - } - frame_size = 2*48000; - } - while (!stop) - { - if (delayed_celt) - { - frame_size = newsize; - delayed_celt = 0; - } else if (random_framesize && rand()%20==0) - { - newsize = rand()%6; - switch(newsize) - { - case 0: newsize=sampling_rate/400; break; - case 1: newsize=sampling_rate/200; break; - case 2: newsize=sampling_rate/100; break; - case 3: newsize=sampling_rate/50; break; - case 4: newsize=sampling_rate/25; break; - case 5: newsize=3*sampling_rate/50; break; - } - while (newsize < sampling_rate/25 && bitrate_bps-fabs(sweep_bps) <= 3*12*sampling_rate/newsize) - newsize*=2; - if (newsize < sampling_rate/100 && frame_size >= sampling_rate/100) - { - opus_encoder_ctl(enc, OPUS_SET_FORCE_MODE(MODE_CELT_ONLY)); - delayed_celt=1; - } else { - frame_size = newsize; - } - } - if (random_fec && rand()%30==0) - { - opus_encoder_ctl(enc, OPUS_SET_INBAND_FEC(rand()%4==0)); - } - if (decode_only) - { - unsigned char ch[4]; - err = fread(ch, 1, 4, fin); - if (feof(fin)) - break; - len[toggle] = char_to_int(ch); - if (len[toggle]>max_payload_bytes || len[toggle]<0) - { - fprintf(stderr, "Invalid payload length: %d\n",len[toggle]); - break; - } - err = fread(ch, 1, 4, fin); - enc_final_range[toggle] = char_to_int(ch); - err = fread(data[toggle], 1, len[toggle], fin); - if (err<len[toggle]) - { - fprintf(stderr, "Ran out of input, " - "expecting %d bytes got %d\n", - len[toggle],err); - break; - } - } else { - int i; - if (mode_list!=NULL) - { - opus_encoder_ctl(enc, OPUS_SET_BANDWIDTH(mode_list[curr_mode][1])); - opus_encoder_ctl(enc, OPUS_SET_FORCE_MODE(mode_list[curr_mode][0])); - opus_encoder_ctl(enc, OPUS_SET_FORCE_CHANNELS(mode_list[curr_mode][3])); - frame_size = mode_list[curr_mode][2]; - } - err = fread(fbytes, sizeof(short)*channels, frame_size-remaining, fin); - curr_read = err; - tot_in += curr_read; - for(i=0;i<curr_read*channels;i++) - { - opus_int32 s; - s=fbytes[2*i+1]<<8|fbytes[2*i]; - s=((s&0xFFFF)^0x8000)-0x8000; - in[i+remaining*channels]=s; - } - if (curr_read+remaining < frame_size) - { - for (i=(curr_read+remaining)*channels;i<frame_size*channels;i++) - in[i] = 0; - if (encode_only || decode_only) - stop = 1; - } - len[toggle] = opus_encode(enc, in, frame_size, data[toggle], max_payload_bytes); - nb_encoded = opus_packet_get_samples_per_frame(data[toggle], sampling_rate)*opus_packet_get_nb_frames(data[toggle], len[toggle]); - remaining = frame_size-nb_encoded; - for(i=0;i<remaining*channels;i++) - in[i] = in[nb_encoded*channels+i]; - if (sweep_bps!=0) - { - bitrate_bps += sweep_bps; - if (sweep_max) - { - if (bitrate_bps > sweep_max) - sweep_bps = -sweep_bps; - else if (bitrate_bps < sweep_min) - sweep_bps = -sweep_bps; - } - /* safety */ - if (bitrate_bps<1000) - bitrate_bps = 1000; - opus_encoder_ctl(enc, OPUS_SET_BITRATE(bitrate_bps)); - } - opus_encoder_ctl(enc, OPUS_GET_FINAL_RANGE(&enc_final_range[toggle])); - if (len[toggle] < 0) - { - fprintf (stderr, "opus_encode() returned %d\n", len[toggle]); - fclose(fin); - fclose(fout); - return EXIT_FAILURE; - } - curr_mode_count += frame_size; - if (curr_mode_count > mode_switch_time && curr_mode < nb_modes_in_list-1) - { - curr_mode++; - curr_mode_count = 0; - } - } - -#if 0 /* This is for testing the padding code, do not enable by default */ - if (len[toggle]<1275) - { - int new_len = len[toggle]+rand()%(max_payload_bytes-len[toggle]); - if ((err = opus_packet_pad(data[toggle], len[toggle], new_len)) != OPUS_OK) - { - fprintf(stderr, "padding failed: %s\n", opus_strerror(err)); - return EXIT_FAILURE; - } - len[toggle] = new_len; - } -#endif - if (encode_only) - { - unsigned char int_field[4]; - int_to_char(len[toggle], int_field); - if (fwrite(int_field, 1, 4, fout) != 4) { - fprintf(stderr, "Error writing.\n"); - return EXIT_FAILURE; - } - int_to_char(enc_final_range[toggle], int_field); - if (fwrite(int_field, 1, 4, fout) != 4) { - fprintf(stderr, "Error writing.\n"); - return EXIT_FAILURE; - } - if (fwrite(data[toggle], 1, len[toggle], fout) != (unsigned)len[toggle]) { - fprintf(stderr, "Error writing.\n"); - return EXIT_FAILURE; - } - tot_samples += nb_encoded; - } else { - int output_samples; - lost = len[toggle]==0 || (packet_loss_perc>0 && rand()%100 < packet_loss_perc); - if (lost) - opus_decoder_ctl(dec, OPUS_GET_LAST_PACKET_DURATION(&output_samples)); - else - output_samples = max_frame_size; - if( count >= use_inbandfec ) { - /* delay by one packet when using in-band FEC */ - if( use_inbandfec ) { - if( lost_prev ) { - /* attempt to decode with in-band FEC from next packet */ - opus_decoder_ctl(dec, OPUS_GET_LAST_PACKET_DURATION(&output_samples)); - output_samples = opus_decode(dec, lost ? NULL : data[toggle], len[toggle], out, output_samples, 1); - } else { - /* regular decode */ - output_samples = max_frame_size; - output_samples = opus_decode(dec, data[1-toggle], len[1-toggle], out, output_samples, 0); - } - } else { - output_samples = opus_decode(dec, lost ? NULL : data[toggle], len[toggle], out, output_samples, 0); - } - if (output_samples>0) - { - if (!decode_only && tot_out + output_samples > tot_in) - { - stop=1; - output_samples = tot_in-tot_out; - } - if (output_samples>skip) { - int i; - for(i=0;i<(output_samples-skip)*channels;i++) - { - short s; - s=out[i+(skip*channels)]; - fbytes[2*i]=s&0xFF; - fbytes[2*i+1]=(s>>8)&0xFF; - } - if (fwrite(fbytes, sizeof(short)*channels, output_samples-skip, fout) != (unsigned)(output_samples-skip)){ - fprintf(stderr, "Error writing.\n"); - return EXIT_FAILURE; - } - tot_out += output_samples-skip; - } - if (output_samples<skip) skip -= output_samples; - else skip = 0; - } else { - fprintf(stderr, "error decoding frame: %s\n", - opus_strerror(output_samples)); - } - tot_samples += output_samples; - } - } - - if (!encode_only) - opus_decoder_ctl(dec, OPUS_GET_FINAL_RANGE(&dec_final_range)); - /* compare final range encoder rng values of encoder and decoder */ - if( enc_final_range[toggle^use_inbandfec]!=0 && !encode_only - && !lost && !lost_prev - && dec_final_range != enc_final_range[toggle^use_inbandfec] ) { - fprintf (stderr, "Error: Range coder state mismatch " - "between encoder and decoder " - "in frame %ld: 0x%8lx vs 0x%8lx\n", - (long)count, - (unsigned long)enc_final_range[toggle^use_inbandfec], - (unsigned long)dec_final_range); - fclose(fin); - fclose(fout); - return EXIT_FAILURE; - } - - lost_prev = lost; - - /* count bits */ - bits += len[toggle]*8; - bits_max = ( len[toggle]*8 > bits_max ) ? len[toggle]*8 : bits_max; - if( count >= use_inbandfec ) { - nrg = 0.0; - if (!decode_only) - { - for ( k = 0; k < frame_size * channels; k++ ) { - nrg += in[ k ] * (double)in[ k ]; - } - } - if ( ( nrg / ( frame_size * channels ) ) > 1e5 ) { - bits_act += len[toggle]*8; - count_act++; - } - /* Variance */ - bits2 += len[toggle]*len[toggle]*64; - } - count++; - toggle = (toggle + use_inbandfec) & 1; - } - fprintf (stderr, "average bitrate: %7.3f kb/s\n", - 1e-3*bits*sampling_rate/tot_samples); - fprintf (stderr, "maximum bitrate: %7.3f kb/s\n", - 1e-3*bits_max*sampling_rate/frame_size); - if (!decode_only) - fprintf (stderr, "active bitrate: %7.3f kb/s\n", - 1e-3*bits_act*sampling_rate/(frame_size*(double)count_act)); - fprintf (stderr, "bitrate standard deviation: %7.3f kb/s\n", - 1e-3*sqrt(bits2/count - bits*bits/(count*(double)count))*sampling_rate/frame_size); - /* Close any files to which intermediate results were stored */ - SILK_DEBUG_STORE_CLOSE_FILES - silk_TimerSave("opus_timing.txt"); - opus_encoder_destroy(enc); - opus_decoder_destroy(dec); - free(data[0]); - if (use_inbandfec) - free(data[1]); - fclose(fin); - fclose(fout); - free(in); - free(out); - free(fbytes); - return EXIT_SUCCESS; -} diff --git a/drivers/opus/opus_encoder.c b/drivers/opus/opus_encoder.c index 890a2514de..5c6af5a199 100644 --- a/drivers/opus/opus_encoder.c +++ b/drivers/opus/opus_encoder.c @@ -24,20 +24,18 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include <stdarg.h> #include "opus/celt/celt.h" #include "opus/celt/entenc.h" -#include "opus/celt/opus_modes.h" +#include "opus/celt/modes.h" #include "opus/silk/API.h" #include "opus/celt/stack_alloc.h" #include "opus/celt/float_cast.h" #include "opus/opus.h" #include "opus/celt/arch.h" +#include "opus/celt/pitch.h" #include "opus/opus_private.h" #include "opus/celt/os_support.h" #include "opus/celt/cpu_support.h" @@ -80,6 +78,10 @@ struct OpusEncoder { int lsb_depth; int encoder_buffer; int lfe; + int arch; +#ifndef DISABLE_FLOAT_API + TonalityAnalysisState analysis; +#endif #define OPUS_ENCODER_RESET_START stream_channels int stream_channels; @@ -99,12 +101,9 @@ struct OpusEncoder { StereoWidthState width_mem; opus_val16 delay_buffer[MAX_ENCODER_BUFFER*2]; #ifndef DISABLE_FLOAT_API - TonalityAnalysisState analysis; int detected_bandwidth; - int analysis_offset; #endif opus_uint32 rangeFinal; - int arch; }; /* Transition tables for the voice and music. First column is the @@ -231,7 +230,7 @@ int opus_encoder_init(OpusEncoder* st, opus_int32 Fs, int channels, int applicat st->lsb_depth = 24; st->variable_duration = OPUS_FRAMESIZE_ARG; - /* Delay compensation of 4 ms (2.5 ms for SILK's extra look-ahead + /* Delay compensation of 4 ms (2.5 ms for SILK's extra look-ahead + 1.5 ms for SILK resamplers and stereo prediction) */ st->delay_compensation = st->Fs/250; @@ -242,6 +241,10 @@ int opus_encoder_init(OpusEncoder* st, opus_int32 Fs, int channels, int applicat st->mode = MODE_HYBRID; st->bandwidth = OPUS_BANDWIDTH_FULLBAND; +#ifndef DISABLE_FLOAT_API + tonality_analysis_init(&st->analysis); +#endif + return OPUS_OK; } @@ -648,7 +651,7 @@ static int transient_viterbi(const float *E, const float *E_1, int N, int frame_ return best_state; } -int optimize_framesize(const opus_val16 *x, int len, int C, opus_int32 Fs, +static int optimize_framesize(const void *x, int len, int C, opus_int32 Fs, int bitrate, opus_val16 tonality, float *mem, int buffering, downmix_func downmix) { @@ -660,6 +663,7 @@ int optimize_framesize(const opus_val16 *x, int len, int C, opus_int32 Fs, int bestLM=0; int subframe; int pos; + int offset; VARDECL(opus_val32, sub); subframe = Fs/400; @@ -670,9 +674,8 @@ int optimize_framesize(const opus_val16 *x, int len, int C, opus_int32 Fs, { /* Consider the CELT delay when not in restricted-lowdelay */ /* We assume the buffering is between 2.5 and 5 ms */ - int offset = 2*subframe - buffering; + offset = 2*subframe - buffering; celt_assert(offset>=0 && offset <= subframe); - x += C*offset; len -= offset; e[1]=mem[1]; e_1[1]=1.f/(EPSILON+mem[1]); @@ -681,6 +684,7 @@ int optimize_framesize(const opus_val16 *x, int len, int C, opus_int32 Fs, pos = 3; } else { pos=1; + offset=0; } N=IMIN(len/subframe, MAX_DYNAMIC_FRAMESIZE); /* Just silencing a warning, it's really initialized later */ @@ -692,7 +696,7 @@ int optimize_framesize(const opus_val16 *x, int len, int C, opus_int32 Fs, int j; tmp=EPSILON; - downmix(x, sub, subframe, i*subframe, 0, -2, C); + downmix(x, sub, subframe, i*subframe+offset, 0, -2, C); if (i==0) memx = sub[0]; for (j=0;j<subframe;j++) @@ -836,6 +840,12 @@ opus_int32 compute_frame_size(const void *analysis_pcm, int frame_size, LM--; frame_size = (Fs/400<<LM); } else +#else + (void)analysis_pcm; + (void)C; + (void)bitrate_bps; + (void)delay_compensation; + (void)downmix; #endif { frame_size = frame_size_select(frame_size, variable_duration, Fs); @@ -924,7 +934,8 @@ opus_val16 compute_stereo_width(const opus_val16 *pcm, int frame_size, opus_int3 opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_size, unsigned char *data, opus_int32 out_data_bytes, int lsb_depth, - const void *analysis_pcm, opus_int32 analysis_size, int c1, int c2, int analysis_channels, downmix_func downmix) + const void *analysis_pcm, opus_int32 analysis_size, int c1, int c2, + int analysis_channels, downmix_func downmix, int float_api) { void *silk_enc; CELTEncoder *celt_enc; @@ -954,9 +965,11 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_ int total_buffer; opus_val16 stereo_width; const CELTMode *celt_mode; +#ifndef DISABLE_FLOAT_API AnalysisInfo analysis_info; int analysis_read_pos_bak=-1; int analysis_read_subframe_bak=-1; +#endif VARDECL(opus_val16, tmp_prefill); ALLOC_STACK; @@ -982,9 +995,9 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_ lsb_depth = IMIN(lsb_depth, st->lsb_depth); - analysis_info.valid = 0; celt_encoder_ctl(celt_enc, CELT_GET_MODE(&celt_mode)); #ifndef DISABLE_FLOAT_API + analysis_info.valid = 0; #ifdef OPUS_FIXED_POINT if (st->silk_mode.complexity >= 10 && st->Fs==48000) #else @@ -997,6 +1010,9 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_ c1, c2, analysis_channels, st->Fs, lsb_depth, downmix, &analysis_info); } +#else + (void)analysis_pcm; + (void)analysis_size; #endif st->voice_ratio = -1; @@ -1377,7 +1393,7 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_ st->user_forced_mode = MODE_CELT_ONLY; tmp_len = opus_encode_native(st, pcm+i*(st->channels*st->Fs/50), st->Fs/50, tmp_data+i*bytes_per_frame, bytes_per_frame, lsb_depth, - NULL, 0, c1, c2, analysis_channels, downmix); + NULL, 0, c1, c2, analysis_channels, downmix, float_api); if (tmp_len<0) { RESTORE_STACK; @@ -1424,8 +1440,7 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_ ec_enc_init(&enc, data, max_data_bytes-1); ALLOC(pcm_buf, (total_buffer+frame_size)*st->channels, opus_val16); - for (i=0;i<total_buffer*st->channels;i++) - pcm_buf[i] = st->delay_buffer[(st->encoder_buffer-total_buffer)*st->channels+i]; + OPUS_COPY(pcm_buf, &st->delay_buffer[(st->encoder_buffer-total_buffer)*st->channels], total_buffer*st->channels); if (st->mode == MODE_CELT_ONLY) hp_freq_smth1 = silk_LSHIFT( silk_lin2log( VARIABLE_HP_MIN_CUTOFF_HZ ), 8 ); @@ -1444,7 +1459,20 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_ } else { dc_reject(pcm, 3, &pcm_buf[total_buffer*st->channels], st->hp_mem, frame_size, st->channels, st->Fs); } - +#ifndef OPUS_FIXED_POINT + if (float_api) + { + opus_val32 sum; + sum = celt_inner_prod(&pcm_buf[total_buffer*st->channels], &pcm_buf[total_buffer*st->channels], frame_size*st->channels, st->arch); + /* This should filter out both NaNs and ridiculous signals that could + cause NaNs further down. */ + if (!(sum < 1e9f) || celt_isnan(sum)) + { + OPUS_CLEAR(&pcm_buf[total_buffer*st->channels], frame_size*st->channels); + st->hp_mem[0] = st->hp_mem[1] = st->hp_mem[2] = st->hp_mem[3] = 0; + } + } +#endif /* SILK processing */ @@ -1599,8 +1627,7 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_ prefill_offset = st->channels*(st->encoder_buffer-st->delay_compensation-st->Fs/400); gain_fade(st->delay_buffer+prefill_offset, st->delay_buffer+prefill_offset, 0, Q15ONE, celt_mode->overlap, st->Fs/400, st->channels, celt_mode->window, st->Fs); - for(i=0;i<prefill_offset;i++) - st->delay_buffer[i]=0; + OPUS_CLEAR(st->delay_buffer, prefill_offset); #ifdef OPUS_FIXED_POINT pcm_silk = st->delay_buffer; #else @@ -1727,15 +1754,18 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_ ALLOC(tmp_prefill, st->channels*st->Fs/400, opus_val16); if (st->mode != MODE_SILK_ONLY && st->mode != st->prev_mode && st->prev_mode > 0) { - for (i=0;i<st->channels*st->Fs/400;i++) - tmp_prefill[i] = st->delay_buffer[(st->encoder_buffer-total_buffer-st->Fs/400)*st->channels + i]; + OPUS_COPY(tmp_prefill, &st->delay_buffer[(st->encoder_buffer-total_buffer-st->Fs/400)*st->channels], st->channels*st->Fs/400); } - for (i=0;i<st->channels*(st->encoder_buffer-(frame_size+total_buffer));i++) - st->delay_buffer[i] = st->delay_buffer[i+st->channels*frame_size]; - for (;i<st->encoder_buffer*st->channels;i++) - st->delay_buffer[i] = pcm_buf[(frame_size+total_buffer-st->encoder_buffer)*st->channels+i]; - + if (st->channels*(st->encoder_buffer-(frame_size+total_buffer)) > 0) + { + OPUS_MOVE(st->delay_buffer, &st->delay_buffer[st->channels*frame_size], st->channels*(st->encoder_buffer-frame_size-total_buffer)); + OPUS_COPY(&st->delay_buffer[st->channels*(st->encoder_buffer-frame_size-total_buffer)], + &pcm_buf[0], + (frame_size+total_buffer)*st->channels); + } else { + OPUS_COPY(st->delay_buffer, &pcm_buf[(frame_size+total_buffer-st->encoder_buffer)*st->channels], st->encoder_buffer*st->channels); + } /* gain_fade() and stereo_fade() need to be after the buffer copying because we don't want any of this to affect the SILK part */ if( st->prev_HB_gain < Q15ONE || HB_gain < Q15ONE ) { @@ -1955,7 +1985,8 @@ opus_int32 opus_encode_float(OpusEncoder *st, const float *pcm, int analysis_fra for (i=0;i<frame_size*st->channels;i++) in[i] = FLOAT2INT16(pcm[i]); - ret = opus_encode_native(st, in, frame_size, data, max_data_bytes, 16, pcm, analysis_frame_size, 0, -2, st->channels, downmix_float); + ret = opus_encode_native(st, in, frame_size, data, max_data_bytes, 16, + pcm, analysis_frame_size, 0, -2, st->channels, downmix_float, 1); RESTORE_STACK; return ret; } @@ -1977,7 +2008,8 @@ opus_int32 opus_encode(OpusEncoder *st, const opus_int16 *pcm, int analysis_fram , st->analysis.subframe_mem #endif ); - return opus_encode_native(st, pcm, frame_size, data, out_data_bytes, 16, pcm, analysis_frame_size, 0, -2, st->channels, downmix_int); + return opus_encode_native(st, pcm, frame_size, data, out_data_bytes, 16, + pcm, analysis_frame_size, 0, -2, st->channels, downmix_int, 0); } #else @@ -2002,7 +2034,8 @@ opus_int32 opus_encode(OpusEncoder *st, const opus_int16 *pcm, int analysis_fram for (i=0;i<frame_size*st->channels;i++) in[i] = (1.0f/32768)*pcm[i]; - ret = opus_encode_native(st, in, frame_size, data, max_data_bytes, 16, pcm, analysis_frame_size, 0, -2, st->channels, downmix_int); + ret = opus_encode_native(st, in, frame_size, data, max_data_bytes, 16, + pcm, analysis_frame_size, 0, -2, st->channels, downmix_int, 0); RESTORE_STACK; return ret; } @@ -2019,7 +2052,7 @@ opus_int32 opus_encode_float(OpusEncoder *st, const float *pcm, int analysis_fra st->variable_duration, st->channels, st->Fs, st->bitrate_bps, delay_compensation, downmix_float, st->analysis.subframe_mem); return opus_encode_native(st, pcm, frame_size, data, out_data_bytes, 24, - pcm, analysis_frame_size, 0, -2, st->channels, downmix_float); + pcm, analysis_frame_size, 0, -2, st->channels, downmix_float, 1); } #endif @@ -2108,7 +2141,7 @@ int opus_encoder_ctl(OpusEncoder *st, int request, ...) case OPUS_SET_MAX_BANDWIDTH_REQUEST: { opus_int32 value = va_arg(ap, opus_int32); - if (value < OPUS_BANDWIDTH_NARROWBAND || value > OPUS_BANDWIDTH_FULLBAND) + if (value < OPUS_BANDWIDTH_NARROWBAND || value > OPUS_BANDWIDTH_FULLBAND) { goto bad_arg; } @@ -2418,11 +2451,14 @@ int opus_encoder_ctl(OpusEncoder *st, int request, ...) { void *silk_enc; silk_EncControlStruct dummy; + char *start; silk_enc = (char*)st+st->silk_enc_offset; +#ifndef DISABLE_FLOAT_API + tonality_analysis_reset(&st->analysis); +#endif - OPUS_CLEAR((char*)&st->OPUS_ENCODER_RESET_START, - sizeof(OpusEncoder)- - ((char*)&st->OPUS_ENCODER_RESET_START - (char*)st)); + start = (char*)&st->OPUS_ENCODER_RESET_START; + OPUS_CLEAR(start, sizeof(OpusEncoder) - (start - (char*)st)); celt_encoder_ctl(celt_enc, OPUS_RESET_STATE); silk_InitEncoder( silk_enc, st->arch, &dummy ); diff --git a/drivers/opus/opus_multistream.c b/drivers/opus/opus_multistream.c index 10c42dd56d..aa94803779 100644 --- a/drivers/opus/opus_multistream.c +++ b/drivers/opus/opus_multistream.c @@ -24,10 +24,7 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/opus_multistream.h" #include "opus/opus.h" diff --git a/drivers/opus/opus_multistream.h b/drivers/opus/opus_multistream.h index f736c99c88..5519c46a9f 100644 --- a/drivers/opus/opus_multistream.h +++ b/drivers/opus/opus_multistream.h @@ -111,9 +111,9 @@ extern "C" { * duration, can be computed without any special negotiation. * * The format for multistream Opus packets is defined in the - * <a href="http://tools.ietf.org/html/draft-terriberry-oggopus">Ogg + * <a href="https://tools.ietf.org/html/draft-ietf-codec-oggopus">Ogg * encapsulation specification</a> and is based on the self-delimited Opus - * framing described in Appendix B of <a href="http://tools.ietf.org/html/rfc6716">RFC 6716</a>. + * framing described in Appendix B of <a href="https://tools.ietf.org/html/rfc6716">RFC 6716</a>. * Normal Opus packets are just a degenerate case of multistream Opus packets, * and can be encoded or decoded with the multistream API by setting * <code>streams</code> to <code>1</code> when initializing the encoder or @@ -140,7 +140,7 @@ extern "C" { * * The output channels specified by the encoder * should use the - * <a href="http://www.xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-800004.3.9">Vorbis + * <a href="https://www.xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-810004.3.9">Vorbis * channel ordering</a>. A decoder may wish to apply an additional permutation * to the mapping the encoder used to achieve a different output channel * order (e.g. for outputing in WAV order). diff --git a/drivers/opus/opus_multistream_decoder.c b/drivers/opus/opus_multistream_decoder.c index 43c695d815..25100edba2 100644 --- a/drivers/opus/opus_multistream_decoder.c +++ b/drivers/opus/opus_multistream_decoder.c @@ -24,10 +24,7 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/opus_multistream.h" #include "opus/opus.h" @@ -75,7 +72,7 @@ int opus_multistream_decoder_init( char *ptr; if ((channels>255) || (channels<1) || (coupled_streams>streams) || - (coupled_streams+streams>255) || (streams<1) || (coupled_streams<0)) + (streams<1) || (coupled_streams<0) || (streams>255-coupled_streams)) return OPUS_BAD_ARG; st->layout.nb_channels = channels; @@ -119,7 +116,7 @@ OpusMSDecoder *opus_multistream_decoder_create( int ret; OpusMSDecoder *st; if ((channels>255) || (channels<1) || (coupled_streams>streams) || - (coupled_streams+streams>255) || (streams<1) || (coupled_streams<0)) + (streams<1) || (coupled_streams<0) || (streams>255-coupled_streams)) { if (error) *error = OPUS_BAD_ARG; @@ -317,7 +314,7 @@ static void opus_copy_channel_out_float( if (src != NULL) { for (i=0;i<frame_size;i++) -#if defined(OPUS_FIXED_POINT) +#if defined(FIXED_POINT) float_dst[i*dst_stride+dst_channel] = (1/32768.f)*src[i*src_stride]; #else float_dst[i*dst_stride+dst_channel] = src[i*src_stride]; @@ -346,7 +343,7 @@ static void opus_copy_channel_out_short( if (src != NULL) { for (i=0;i<frame_size;i++) -#if defined(OPUS_FIXED_POINT) +#if defined(FIXED_POINT) short_dst[i*dst_stride+dst_channel] = src[i*src_stride]; #else short_dst[i*dst_stride+dst_channel] = FLOAT2INT16(src[i*src_stride]); diff --git a/drivers/opus/opus_multistream_encoder.c b/drivers/opus/opus_multistream_encoder.c index 685d2de277..426c72e997 100644 --- a/drivers/opus/opus_multistream_encoder.c +++ b/drivers/opus/opus_multistream_encoder.c @@ -24,10 +24,7 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/opus_multistream.h" #include "opus/opus.h" @@ -38,9 +35,10 @@ #include "opus/celt/os_support.h" #include "opus/celt/mathops.h" #include "opus/celt/mdct.h" -#include "opus/celt/opus_modes.h" +#include "opus/celt/modes.h" #include "opus/celt/bands.h" #include "opus/celt/quant_bands.h" +#include "opus/celt/pitch.h" typedef struct { int nb_streams; @@ -71,6 +69,7 @@ typedef void (*opus_copy_channel_in_func)( struct OpusMSEncoder { ChannelLayout layout; + int arch; int lfe_stream; int application; int variable_duration; @@ -98,7 +97,8 @@ static opus_val32 *ms_get_preemph_mem(OpusMSEncoder *st) else ptr += align(mono_size); } - return (opus_val32*)(ptr+st->layout.nb_channels*120*sizeof(opus_val32)); + /* void* cast avoids clang -Wcast-align warning */ + return (opus_val32*)(void*)(ptr+st->layout.nb_channels*120*sizeof(opus_val32)); } static opus_val32 *ms_get_window_mem(OpusMSEncoder *st) @@ -117,7 +117,8 @@ static opus_val32 *ms_get_window_mem(OpusMSEncoder *st) else ptr += align(mono_size); } - return (opus_val32*)ptr; + /* void* cast avoids clang -Wcast-align warning */ + return (opus_val32*)(void*)ptr; } static int validate_encoder_layout(const ChannelLayout *layout) @@ -199,7 +200,7 @@ static opus_val16 logSum(opus_val16 a, opus_val16 b) max = b; diff = SUB32(EXTEND32(b),EXTEND32(a)); } - if (diff >= QCONST16(8.f, DB_SHIFT)) + if (!(diff < QCONST16(8.f, DB_SHIFT))) /* inverted to catch NaNs */ return max; #ifdef OPUS_FIXED_POINT low = SHR32(diff, DB_SHIFT-1); @@ -218,7 +219,7 @@ opus_val16 logSum(opus_val16 a, opus_val16 b) #endif void surround_analysis(const CELTMode *celt_mode, const void *pcm, opus_val16 *bandLogE, opus_val32 *mem, opus_val32 *preemph_mem, - int len, int overlap, int channels, int rate, opus_copy_channel_in_func copy_channel_in + int len, int overlap, int channels, int rate, opus_copy_channel_in_func copy_channel_in, int arch ) { int c; @@ -257,7 +258,21 @@ void surround_analysis(const CELTMode *celt_mode, const void *pcm, opus_val16 *b OPUS_COPY(in, mem+c*overlap, overlap); (*copy_channel_in)(x, 1, pcm, channels, c, len); celt_preemphasis(x, in+overlap, frame_size, 1, upsample, celt_mode->preemph, preemph_mem+c, 0); - clt_mdct_forward(&celt_mode->mdct, in, freq, celt_mode->window, overlap, celt_mode->maxLM-LM, 1); +#ifndef OPUS_FIXED_POINT + { + opus_val32 sum; + sum = celt_inner_prod(in, in, frame_size+overlap, 0); + /* This should filter out both NaNs and ridiculous signals that could + cause NaNs further down. */ + if (!(sum < 1e9f) || celt_isnan(sum)) + { + OPUS_CLEAR(in, frame_size+overlap); + preemph_mem[c] = 0; + } + } +#endif + clt_mdct_forward(&celt_mode->mdct, in, freq, celt_mode->window, + overlap, celt_mode->maxLM-LM, 1, arch); if (upsample != 1) { int bound = len; @@ -267,7 +282,7 @@ void surround_analysis(const CELTMode *celt_mode, const void *pcm, opus_val16 *b freq[i] = 0; } - compute_band_energies(celt_mode, freq, bandE, 21, 1, 1<<LM); + compute_band_energies(celt_mode, freq, bandE, 21, 1, LM); amp2Log2(celt_mode, 21, 21, bandE, bandLogE+21*c, 1); /* Apply spreading function with -6 dB/band going up and -12 dB/band going down. */ for (i=1;i<21;i++) @@ -408,9 +423,10 @@ static int opus_multistream_encoder_init_impl( char *ptr; if ((channels>255) || (channels<1) || (coupled_streams>streams) || - (coupled_streams+streams>255) || (streams<1) || (coupled_streams<0)) + (streams<1) || (coupled_streams<0) || (streams>255-coupled_streams)) return OPUS_BAD_ARG; + st->arch = opus_select_arch(); st->layout.nb_channels = channels; st->layout.nb_streams = streams; st->layout.nb_coupled_streams = coupled_streams; @@ -530,7 +546,7 @@ OpusMSEncoder *opus_multistream_encoder_create( int ret; OpusMSEncoder *st; if ((channels>255) || (channels<1) || (coupled_streams>streams) || - (coupled_streams+streams>255) || (streams<1) || (coupled_streams<0)) + (streams<1) || (coupled_streams<0) || (streams>255-coupled_streams)) { if (error) *error = OPUS_BAD_ARG; @@ -566,6 +582,7 @@ OpusMSEncoder *opus_multistream_surround_encoder_create( ) { int ret; + opus_int32 size; OpusMSEncoder *st; if ((channels>255) || (channels<1)) { @@ -573,7 +590,14 @@ OpusMSEncoder *opus_multistream_surround_encoder_create( *error = OPUS_BAD_ARG; return NULL; } - st = (OpusMSEncoder *)opus_alloc(opus_multistream_surround_encoder_get_size(channels, mapping_family)); + size = opus_multistream_surround_encoder_get_size(channels, mapping_family); + if (!size) + { + if (error) + *error = OPUS_UNIMPLEMENTED; + return NULL; + } + st = (OpusMSEncoder *)opus_alloc(size); if (st==NULL) { if (error) @@ -591,7 +615,7 @@ OpusMSEncoder *opus_multistream_surround_encoder_create( return st; } -static void surround_rate_allocation( +static opus_int32 surround_rate_allocation( OpusMSEncoder *st, opus_int32 *rate, int frame_size @@ -605,6 +629,7 @@ static void surround_rate_allocation( int lfe_offset; int coupled_ratio; /* Q8 */ int lfe_ratio; /* Q8 */ + opus_int32 rate_sum=0; ptr = (char*)st + align(sizeof(OpusMSEncoder)); opus_encoder_ctl((OpusEncoder*)ptr, OPUS_GET_SAMPLE_RATE(&Fs)); @@ -660,7 +685,10 @@ static void surround_rate_allocation( rate[i] = stream_offset+channel_rate; else rate[i] = lfe_offset+(channel_rate*lfe_ratio>>8); + rate[i] = IMAX(rate[i], 500); + rate_sum += rate[i]; } + return rate_sum; } /* Max size in case the encoder decides to return three frames */ @@ -674,7 +702,8 @@ static int opus_multistream_encode_native unsigned char *data, opus_int32 max_data_bytes, int lsb_depth, - downmix_func downmix + downmix_func downmix, + int float_api ) { opus_int32 Fs; @@ -694,6 +723,8 @@ static int opus_multistream_encode_native opus_val32 *mem = NULL; opus_val32 *preemph_mem=NULL; int frame_size; + opus_int32 rate_sum; + opus_int32 smallest_packet; ALLOC_STACK; if (st->surround) @@ -737,6 +768,14 @@ static int opus_multistream_encode_native RESTORE_STACK; return OPUS_BAD_ARG; } + + /* Smallest packet the encoder can produce. */ + smallest_packet = st->layout.nb_streams*2-1; + if (max_data_bytes < smallest_packet) + { + RESTORE_STACK; + return OPUS_BUFFER_TOO_SMALL; + } ALLOC(buf, 2*frame_size, opus_val16); coupled_size = opus_encoder_get_size(2); mono_size = opus_encoder_get_size(1); @@ -744,21 +783,23 @@ static int opus_multistream_encode_native ALLOC(bandSMR, 21*st->layout.nb_channels, opus_val16); if (st->surround) { - surround_analysis(celt_mode, pcm, bandSMR, mem, preemph_mem, frame_size, 120, st->layout.nb_channels, Fs, copy_channel_in); - } - - if (max_data_bytes < 4*st->layout.nb_streams-1) - { - RESTORE_STACK; - return OPUS_BUFFER_TOO_SMALL; + surround_analysis(celt_mode, pcm, bandSMR, mem, preemph_mem, frame_size, 120, st->layout.nb_channels, Fs, copy_channel_in, st->arch); } /* Compute bitrate allocation between streams (this could be a lot better) */ - surround_rate_allocation(st, bitrates, frame_size); + rate_sum = surround_rate_allocation(st, bitrates, frame_size); if (!vbr) - max_data_bytes = IMIN(max_data_bytes, 3*st->bitrate_bps/(3*8*Fs/frame_size)); - + { + if (st->bitrate_bps == OPUS_AUTO) + { + max_data_bytes = IMIN(max_data_bytes, 3*rate_sum/(3*8*Fs/frame_size)); + } else if (st->bitrate_bps != OPUS_BITRATE_MAX) + { + max_data_bytes = IMIN(max_data_bytes, IMAX(smallest_packet, + 3*st->bitrate_bps/(3*8*Fs/frame_size))); + } + } ptr = (char*)st + align(sizeof(OpusMSEncoder)); for (s=0;s<st->layout.nb_streams;s++) { @@ -843,13 +884,15 @@ static int opus_multistream_encode_native opus_encoder_ctl(enc, OPUS_SET_ENERGY_MASK(bandLogE)); /* number of bytes left (+Toc) */ curr_max = max_data_bytes - tot_size; - /* Reserve three bytes for the last stream and four for the others */ - curr_max -= IMAX(0,4*(st->layout.nb_streams-s-1)-1); + /* Reserve one byte for the last stream and two for the others */ + curr_max -= IMAX(0,2*(st->layout.nb_streams-s-1)-1); curr_max = IMIN(curr_max,MS_FRAME_TMP); + /* Repacketizer will add one or two bytes for self-delimited frames */ + if (s != st->layout.nb_streams-1) curr_max -= curr_max>253 ? 2 : 1; if (!vbr && s == st->layout.nb_streams-1) opus_encoder_ctl(enc, OPUS_SET_BITRATE(curr_max*(8*Fs/frame_size))); len = opus_encode_native(enc, buf, frame_size, tmp_data, curr_max, lsb_depth, - pcm, analysis_frame_size, c1, c2, st->layout.nb_channels, downmix); + pcm, analysis_frame_size, c1, c2, st->layout.nb_channels, downmix, float_api); if (len<0) { RESTORE_STACK; @@ -883,7 +926,7 @@ static void opus_copy_channel_in_float( opus_int32 i; float_src = (const float *)src; for (i=0;i<frame_size;i++) -#if defined(OPUS_FIXED_POINT) +#if defined(FIXED_POINT) dst[i*dst_stride] = FLOAT2INT16(float_src[i*src_stride+src_channel]); #else dst[i*dst_stride] = float_src[i*src_stride+src_channel]; @@ -904,7 +947,7 @@ static void opus_copy_channel_in_short( opus_int32 i; short_src = (const opus_int16 *)src; for (i=0;i<frame_size;i++) -#if defined(OPUS_FIXED_POINT) +#if defined(FIXED_POINT) dst[i*dst_stride] = short_src[i*src_stride+src_channel]; #else dst[i*dst_stride] = (1/32768.f)*short_src[i*src_stride+src_channel]; @@ -922,7 +965,7 @@ int opus_multistream_encode( ) { return opus_multistream_encode_native(st, opus_copy_channel_in_short, - pcm, frame_size, data, max_data_bytes, 16, downmix_int); + pcm, frame_size, data, max_data_bytes, 16, downmix_int, 0); } #ifndef DISABLE_FLOAT_API @@ -935,7 +978,7 @@ int opus_multistream_encode_float( ) { return opus_multistream_encode_native(st, opus_copy_channel_in_float, - pcm, frame_size, data, max_data_bytes, 16, downmix_float); + pcm, frame_size, data, max_data_bytes, 16, downmix_float, 1); } #endif @@ -951,7 +994,7 @@ int opus_multistream_encode_float ) { return opus_multistream_encode_native(st, opus_copy_channel_in_float, - pcm, frame_size, data, max_data_bytes, 24, downmix_float); + pcm, frame_size, data, max_data_bytes, 24, downmix_float, 1); } int opus_multistream_encode( @@ -963,7 +1006,7 @@ int opus_multistream_encode( ) { return opus_multistream_encode_native(st, opus_copy_channel_in_short, - pcm, frame_size, data, max_data_bytes, 16, downmix_int); + pcm, frame_size, data, max_data_bytes, 16, downmix_int, 0); } #endif diff --git a/drivers/opus/opus_private.h b/drivers/opus/opus_private.h index d63ed4f051..129977ed11 100644 --- a/drivers/opus/opus_private.h +++ b/drivers/opus/opus_private.h @@ -33,6 +33,8 @@ #include "opus/opus.h" #include "opus/celt/celt.h" +#include <stddef.h> /* offsetof */ + struct OpusRepacketizer { unsigned char toc; int nb_frames; @@ -86,10 +88,6 @@ typedef void (*downmix_func)(const void *, opus_val32 *, int, int, int, int, int void downmix_float(const void *_x, opus_val32 *sub, int subframe, int offset, int c1, int c2, int C); void downmix_int(const void *_x, opus_val32 *sub, int subframe, int offset, int c1, int c2, int C); -int optimize_framesize(const opus_val16 *x, int len, int C, opus_int32 Fs, - int bitrate, opus_val16 tonality, float *mem, int buffering, - downmix_func downmix); - int encode_size(int size, unsigned char *data); opus_int32 frame_size_select(opus_int32 frame_size, int variable_duration, opus_int32 Fs); @@ -104,16 +102,23 @@ opus_int32 compute_frame_size(const void *analysis_pcm, int frame_size, opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_size, unsigned char *data, opus_int32 out_data_bytes, int lsb_depth, - const void *analysis_pcm, opus_int32 analysis_size, int c1, int c2, int analysis_channels, downmix_func downmix); + const void *analysis_pcm, opus_int32 analysis_size, int c1, int c2, + int analysis_channels, downmix_func downmix, int float_api); int opus_decode_native(OpusDecoder *st, const unsigned char *data, opus_int32 len, opus_val16 *pcm, int frame_size, int decode_fec, int self_delimited, opus_int32 *packet_offset, int soft_clip); -/* Make sure everything's aligned to sizeof(void *) bytes */ +/* Make sure everything is properly aligned. */ static OPUS_INLINE int align(int i) { - return (i+(int)sizeof(void *)-1)&-(int)sizeof(void *); + struct foo {char c; union { void* p; opus_int32 i; opus_val32 v; } u;}; + + unsigned int alignment = offsetof(struct foo, u); + + /* Optimizing compilers should optimize div and multiply into and + for all sensible alignment values. */ + return ((i + alignment - 1) / alignment) * alignment; } int opus_packet_parse_impl(const unsigned char *data, opus_int32 len, diff --git a/drivers/opus/opusfile.c b/drivers/opus/opusfile.c index a38e8cd5ad..a9d6cc4d63 100644 --- a/drivers/opus/opusfile.c +++ b/drivers/opus/opusfile.c @@ -14,9 +14,7 @@ last mod: $Id: vorbisfile.c 17573 2010-10-27 14:53:59Z xiphmont $ ********************************************************************/ -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/internal.h" #include <stdio.h> @@ -237,7 +235,9 @@ static int op_add_serialno(const ogg_page *_og, nserialnos=*_nserialnos; cserialnos=*_cserialnos; if(OP_UNLIKELY(nserialnos>=cserialnos)){ - if(OP_UNLIKELY(cserialnos>INT_MAX-1>>1))return OP_EFAULT; + if(OP_UNLIKELY(cserialnos>INT_MAX/(int)sizeof(*serialnos)-1>>1)){ + return OP_EFAULT; + } cserialnos=2*cserialnos+1; OP_ASSERT(nserialnos<cserialnos); serialnos=(ogg_uint32_t *)_ogg_realloc(serialnos, @@ -825,6 +825,7 @@ static opus_int32 op_collect_audio_packets(OggOpusFile *_of, static int op_find_initial_pcm_offset(OggOpusFile *_of, OggOpusLink *_link,ogg_page *_og){ ogg_page og; + opus_int64 page_offset; ogg_int64_t pcm_start; ogg_int64_t prev_packet_gp; ogg_int64_t cur_page_gp; @@ -842,13 +843,12 @@ static int op_find_initial_pcm_offset(OggOpusFile *_of, least once.*/ total_duration=0; do{ - opus_int64 llret; - llret=op_get_next_page(_of,_og,_of->end); + page_offset=op_get_next_page(_of,_og,_of->end); /*We should get a page unless the file is truncated or mangled. Otherwise there are no audio data packets in the whole logical stream.*/ - if(OP_UNLIKELY(llret<0)){ + if(OP_UNLIKELY(page_offset<0)){ /*Fail if there was a read error.*/ - if(llret<OP_FALSE)return (int)llret; + if(page_offset<OP_FALSE)return (int)page_offset; /*Fail if the pre-skip is non-zero, since it's asking us to skip more samples than exist.*/ if(_link->head.pre_skip>0)return OP_EBADTIMESTAMP; @@ -949,6 +949,7 @@ static int op_find_initial_pcm_offset(OggOpusFile *_of, _of->op_count=pi; _of->cur_discard_count=_link->head.pre_skip; _of->prev_packet_gp=_link->pcm_start=pcm_start; + _of->prev_page_offset=page_offset; return 0; } @@ -1304,13 +1305,20 @@ static void op_update_gain(OggOpusFile *_of){ track gain must lie in the range [-32768,32767], and the user-supplied offset has been pre-clamped to [-98302,98303].*/ switch(_of->gain_type){ + case OP_ALBUM_GAIN:{ + int album_gain_q8; + album_gain_q8=0; + opus_tags_get_album_gain(&_of->links[li].tags,&album_gain_q8); + gain_q8+=album_gain_q8; + gain_q8+=head->output_gain; + }break; case OP_TRACK_GAIN:{ int track_gain_q8; track_gain_q8=0; opus_tags_get_track_gain(&_of->links[li].tags,&track_gain_q8); gain_q8+=track_gain_q8; - } - /*Fall through.*/ + gain_q8+=head->output_gain; + }break; case OP_HEADER_GAIN:gain_q8+=head->output_gain;break; case OP_ABSOLUTE_GAIN:break; default:OP_ASSERT(0); @@ -1361,7 +1369,7 @@ static int op_make_decode_ready(OggOpusFile *_of){ _of->ready_state=OP_INITSET; _of->bytes_tracked=0; _of->samples_tracked=0; -#if !defined(OPUS_FIXED_POINT) +#if !defined(OP_FIXED_POINT) _of->state_channel_count=0; /*Use the serial number for the PRNG seed to get repeatable output for straight play-throughs.*/ @@ -1402,6 +1410,7 @@ static int op_open_seekable2(OggOpusFile *_of){ ogg_sync_state oy_start; ogg_stream_state os_start; ogg_packet *op_start; + opus_int64 prev_page_offset; opus_int64 start_offset; int start_op_count; int ret; @@ -1421,6 +1430,7 @@ static int op_open_seekable2(OggOpusFile *_of){ if(op_start==NULL)return OP_EFAULT; *&oy_start=_of->oy; *&os_start=_of->os; + prev_page_offset=_of->prev_page_offset; start_offset=_of->offset; memcpy(op_start,_of->op,sizeof(*op_start)*start_op_count); OP_ASSERT((*_of->callbacks.tell)(_of->source)==op_position(_of)); @@ -1437,6 +1447,7 @@ static int op_open_seekable2(OggOpusFile *_of){ memcpy(_of->op,op_start,sizeof(*_of->op)*start_op_count); _ogg_free(op_start); _of->prev_packet_gp=_of->links[0].pcm_start; + _of->prev_page_offset=prev_page_offset; _of->cur_discard_count=_of->links[0].head.pre_skip; if(OP_UNLIKELY(ret<0))return ret; /*And restore the position indicator.*/ @@ -1451,6 +1462,7 @@ static void op_decode_clear(OggOpusFile *_of){ _of->op_count=0; _of->od_buffer_size=0; _of->prev_packet_gp=-1; + _of->prev_page_offset=-1; if(!_of->seekable){ OP_ASSERT(_of->ready_state>=OP_INITSET); opus_tags_clear(&_of->links[0].tags); @@ -1815,7 +1827,8 @@ opus_int32 op_bitrate_instant(OggOpusFile *_of){ 0) Need more data (only if _readp==0). 1) Got at least one audio data packet.*/ static int op_fetch_and_process_page(OggOpusFile *_of, - ogg_page *_og,opus_int64 _page_pos,int _readp,int _spanp,int _ignore_holes){ + ogg_page *_og,opus_int64 _page_offset, + int _readp,int _spanp,int _ignore_holes){ OggOpusLink *links; ogg_uint32_t cur_serialno; int seekable; @@ -1843,9 +1856,9 @@ static int op_fetch_and_process_page(OggOpusFile *_of, _og=NULL; } /*Keep reading until we get a page with the correct serialno.*/ - else _page_pos=op_get_next_page(_of,&og,_of->end); + else _page_offset=op_get_next_page(_of,&og,_of->end); /*EOF: Leave uninitialized.*/ - if(_page_pos<0)return _page_pos<OP_FALSE?(int)_page_pos:OP_EOF; + if(_page_offset<0)return _page_offset<OP_FALSE?(int)_page_offset:OP_EOF; if(OP_LIKELY(_of->ready_state>=OP_STREAMSET)){ if(cur_serialno!=(ogg_uint32_t)ogg_page_serialno(&og)){ /*Two possibilities: @@ -1890,8 +1903,9 @@ static int op_fetch_and_process_page(OggOpusFile *_of, _of->ready_state=OP_STREAMSET; /*If we're at the start of this link, initialize the granule position and pre-skip tracking.*/ - if(_page_pos<=links[cur_link].data_offset){ + if(_page_offset<=links[cur_link].data_offset){ _of->prev_packet_gp=links[cur_link].pcm_start; + _of->prev_page_offset=-1; _of->cur_discard_count=links[cur_link].head.pre_skip; /*Ignore a hole at the start of a new link (this is common for streams joined in the middle) or after seeking.*/ @@ -2039,7 +2053,8 @@ static int op_fetch_and_process_page(OggOpusFile *_of, op_granpos_add(&prev_packet_gp,prev_packet_gp,total_duration) should succeed and give prev_packet_gp==cur_page_gp. But we don't bother to check that, as there isn't much we can do - if it's not true. + if it's not true, and it actually will not be true on the first + page after a seek, if there was a continued packet. The only thing we guarantee is that the start and end granule positions of the packets are valid, and that they are monotonic within a page. @@ -2068,6 +2083,7 @@ static int op_fetch_and_process_page(OggOpusFile *_of, OP_ASSERT(total_duration==0); } _of->prev_packet_gp=prev_packet_gp; + _of->prev_page_offset=_page_offset; _of->op_count=pi; /*If end-trimming didn't trim all the packets, we're done.*/ if(OP_LIKELY(pi>0))return 1; @@ -2141,6 +2157,27 @@ static ogg_int64_t op_get_granulepos(const OggOpusFile *_of, return -1; } +/*A small helper to determine if an Ogg page contains data that continues onto + a subsequent page.*/ +static int op_page_continues(const ogg_page *_og){ + int nlacing; + OP_ASSERT(_og->header_len>=27); + nlacing=_og->header[26]; + OP_ASSERT(_og->header_len>=27+nlacing); + /*This also correctly handles the (unlikely) case of nlacing==0, because + 0!=255.*/ + return _og->header[27+nlacing-1]==255; +} + +/*A small helper to buffer the continued packet data from a page.*/ +static void op_buffer_continued_data(OggOpusFile *_of,ogg_page *_og){ + ogg_packet op; + ogg_stream_pagein(&_of->os,_og); + /*Drain any packets that did end on this page (and ignore holes). + We only care about the continued packet data.*/ + while(ogg_stream_packetout(&_of->os,&op)); +} + /*This controls how close the target has to be to use the current stream position to subdivide the initial range. Two minutes seems to be a good default.*/ @@ -2172,11 +2209,13 @@ static int op_pcm_seek_page(OggOpusFile *_of, opus_int64 end; opus_int64 boundary; opus_int64 best; + opus_int64 best_start; opus_int64 page_offset; opus_int64 d0; opus_int64 d1; opus_int64 d2; int force_bisect; + int buffering; int ret; _of->bytes_tracked=0; _of->samples_tracked=0; @@ -2184,8 +2223,9 @@ static int op_pcm_seek_page(OggOpusFile *_of, best_gp=pcm_start=link->pcm_start; pcm_end=link->pcm_end; serialno=link->serialno; - best=begin=link->data_offset; + best=best_start=begin=link->data_offset; page_offset=-1; + buffering=0; /*We discard the first 80 ms of data after a seek, so seek back that much farther. If we can't, simply seek to the beginning of the link.*/ @@ -2231,6 +2271,18 @@ static int op_pcm_seek_page(OggOpusFile *_of, if(offset-begin>=end-begin>>1||diff>-OP_CUR_TIME_THRESH){ best=begin=offset; best_gp=pcm_start=gp; + /*If we have buffered data from a continued packet, remember the + offset of the previous page's start, so that if we do wind up + having to seek back here later, we can prime the stream with + the continued packet data. + With no continued packet, we remember the end of the page.*/ + best_start=_of->os.body_returned<_of->os.body_fill? + _of->prev_page_offset:best; + /*If there's completed packets and data in the stream state, + prev_page_offset should always be set.*/ + OP_ASSERT(best_start>=0); + /*Buffer any continued packet data starting from here.*/ + buffering=1; } } else{ @@ -2242,13 +2294,14 @@ static int op_pcm_seek_page(OggOpusFile *_of, generally 1 second or less), we can loop them continuously without seeking at all.*/ OP_ALWAYS_TRUE(!op_granpos_add(&prev_page_gp,_of->op[0].granulepos, - op_get_packet_duration(_of->op[0].packet,_of->op[0].bytes))); + -op_get_packet_duration(_of->op[0].packet,_of->op[0].bytes))); if(op_granpos_cmp(prev_page_gp,_target_gp)<=0){ /*Don't call op_decode_clear(), because it will dump our packets.*/ _of->op_pos=0; _of->od_buffer_size=0; _of->prev_packet_gp=prev_page_gp; + /*_of->prev_page_offset already points to the right place.*/ _of->ready_state=OP_STREAMSET; return op_make_decode_ready(_of); } @@ -2269,6 +2322,9 @@ static int op_pcm_seek_page(OggOpusFile *_of, Vinen)" from libvorbisfile. It has been modified substantially since.*/ op_decode_clear(_of); + if(!buffering)ogg_stream_reset_serialno(&_of->os,serialno); + _of->cur_link=_li; + _of->ready_state=OP_STREAMSET; /*Initialize the interval size history.*/ d2=d1=d0=end-begin; force_bisect=0; @@ -2294,12 +2350,23 @@ static int op_pcm_seek_page(OggOpusFile *_of, force_bisect=0; } if(bisect!=_of->offset){ + /*Discard any buffered continued packet data.*/ + if(buffering)ogg_stream_reset(&_of->os); + buffering=0; page_offset=-1; ret=op_seek_helper(_of,bisect); if(OP_UNLIKELY(ret<0))return ret; } chunk_size=OP_CHUNK_SIZE; next_boundary=boundary; + /*Now scan forward and figure out where we landed. + In the ideal case, we will see a page with a granule position at or + before our target, followed by a page with a granule position after our + target (or the end of the search interval). + Then we can just drop out and will have all of the data we need with no + additional seeking. + If we landed too far before, or after, we'll break out and do another + bisection.*/ while(begin<end){ page_offset=op_get_next_page(_of,&og,boundary); if(page_offset<0){ @@ -2309,7 +2376,10 @@ static int op_pcm_seek_page(OggOpusFile *_of, /*If we scanned the whole interval, we're done.*/ if(bisect<=begin+1)end=begin; else{ - /*Otherwise, back up one chunk.*/ + /*Otherwise, back up one chunk. + First, discard any data from a continued packet.*/ + if(buffering)ogg_stream_reset(&_of->os); + buffering=0; bisect=OP_MAX(bisect-chunk_size,begin); ret=op_seek_helper(_of,bisect); if(OP_UNLIKELY(ret<0))return ret; @@ -2322,12 +2392,32 @@ static int op_pcm_seek_page(OggOpusFile *_of, } else{ ogg_int64_t gp; + int has_packets; /*Save the offset of the first page we found after the seek, regardless of the stream it came from or whether or not it has a timestamp.*/ next_boundary=OP_MIN(page_offset,next_boundary); if(serialno!=(ogg_uint32_t)ogg_page_serialno(&og))continue; - gp=ogg_page_granulepos(&og); - if(gp==-1)continue; + has_packets=ogg_page_packets(&og)>0; + /*Force the gp to -1 (as it should be per spec) if no packets end on + this page. + Otherwise we might get confused when we try to pull out a packet + with that timestamp and can't find it.*/ + gp=has_packets?ogg_page_granulepos(&og):-1; + if(gp==-1){ + if(buffering){ + if(OP_LIKELY(!has_packets))ogg_stream_pagein(&_of->os,&og); + else{ + /*If packets did end on this page, but we still didn't have a + valid granule position (in violation of the spec!), stop + buffering continued packet data. + Otherwise we might continue past the packet we actually + wanted.*/ + ogg_stream_reset(&_of->os); + buffering=0; + } + } + continue; + } if(op_granpos_cmp(gp,_target_gp)<0){ /*We found a page that ends before our target. Advance to the raw offset of the next page.*/ @@ -2340,7 +2430,22 @@ static int op_pcm_seek_page(OggOpusFile *_of, } /*Save the byte offset of the end of the page with this granule position.*/ - best=begin; + best=best_start=begin; + /*Buffer any data from a continued packet, if necessary. + This avoids the need to seek back here if the next timestamp we + encounter while scanning forward lies after our target.*/ + if(buffering)ogg_stream_reset(&_of->os); + if(op_page_continues(&og)){ + op_buffer_continued_data(_of,&og); + /*If we have a continued packet, remember the offset of this + page's start, so that if we do wind up having to seek back here + later, we can prime the stream with the continued packet data. + With no continued packet, we remember the end of the page.*/ + best_start=page_offset; + } + /*Then force buffering on, so that if a packet starts (but does not + end) on the next page, we still avoid the extra seek back.*/ + buffering=1; best_gp=pcm_start=gp; OP_ALWAYS_TRUE(!op_granpos_diff(&diff,_target_gp,pcm_start)); /*If we're more than a second away from our target, break out and @@ -2372,28 +2477,40 @@ static int op_pcm_seek_page(OggOpusFile *_of, } } } - /*Found our page. - Seek to the end of it and update prev_packet_gp. - Our caller will set cur_discard_count. - This is an easier case than op_raw_seek(), as we don't need to keep any - packets from the page we found.*/ - /*Seek, if necessary.*/ - if(best!=page_offset){ - page_offset=-1; - ret=op_seek_helper(_of,best); - if(OP_UNLIKELY(ret<0))return ret; - } + /*Found our page.*/ OP_ASSERT(op_granpos_cmp(best_gp,pcm_start)>=0); - _of->cur_link=_li; - _of->ready_state=OP_STREAMSET; + /*Seek, if necessary. + If we were buffering data from a continued packet, we should be able to + continue to scan forward to get the rest of the data (even if + page_offset==-1). + Otherwise, we need to seek back to best_start.*/ + if(!buffering){ + if(best_start!=page_offset){ + page_offset=-1; + ret=op_seek_helper(_of,best_start); + if(OP_UNLIKELY(ret<0))return ret; + } + if(best_start<best){ + /*Retrieve the page at best_start, if we do not already have it.*/ + if(page_offset<0){ + page_offset=op_get_next_page(_of,&og,link->end_offset); + if(OP_UNLIKELY(page_offset<OP_FALSE))return (int)page_offset; + if(OP_UNLIKELY(page_offset!=best_start))return OP_EBADLINK; + } + op_buffer_continued_data(_of,&og); + page_offset=-1; + } + } + /*Update prev_packet_gp to allow per-packet granule position assignment.*/ _of->prev_packet_gp=best_gp; - ogg_stream_reset_serialno(&_of->os,serialno); + _of->prev_page_offset=best_start; ret=op_fetch_and_process_page(_of,page_offset<0?NULL:&og,page_offset,1,0,1); if(OP_UNLIKELY(ret<=0))return OP_EBADLINK; /*Verify result.*/ if(OP_UNLIKELY(op_granpos_cmp(_of->prev_packet_gp,_target_gp)>0)){ return OP_EBADLINK; } + /*Our caller will set cur_discard_count to handle pre-roll.*/ return 0; } @@ -2554,8 +2671,8 @@ void op_set_decode_callback(OggOpusFile *_of, int op_set_gain_offset(OggOpusFile *_of, int _gain_type,opus_int32 _gain_offset_q8){ - if(_gain_type!=OP_HEADER_GAIN&&_gain_type!=OP_TRACK_GAIN - &&_gain_type!=OP_ABSOLUTE_GAIN){ + if(_gain_type!=OP_HEADER_GAIN&&_gain_type!=OP_ALBUM_GAIN + &&_gain_type!=OP_TRACK_GAIN&&_gain_type!=OP_ABSOLUTE_GAIN){ return OP_EINVAL; } _of->gain_type=_gain_type; @@ -2568,7 +2685,7 @@ int op_set_gain_offset(OggOpusFile *_of, } void op_set_dither_enabled(OggOpusFile *_of,int _enabled){ -#if !defined(OPUS_FIXED_POINT) +#if !defined(OP_FIXED_POINT) _of->dither_disabled=!_enabled; if(!_enabled)_of->dither_mute=65; #endif @@ -2603,7 +2720,7 @@ static int op_decode(OggOpusFile *_of,op_sample *_pcm, int ret; /*First we try using the application-provided decode callback.*/ if(_of->decode_cb!=NULL){ -#if defined(OPUS_FIXED_POINT) +#if defined(OP_FIXED_POINT) ret=(*_of->decode_cb)(_of->decode_cb_ctx,_of->od,_pcm,_op, _nsamples,_nchannels,OP_DEC_FORMAT_SHORT,_of->cur_link); #else @@ -2614,7 +2731,7 @@ static int op_decode(OggOpusFile *_of,op_sample *_pcm, else ret=OP_DEC_USE_DEFAULT; /*If the application didn't want to handle decoding, do it ourselves.*/ if(ret==OP_DEC_USE_DEFAULT){ -#if defined(OPUS_FIXED_POINT) +#if defined(OP_FIXED_POINT) ret=opus_multistream_decode(_of->od, _op->packet,_op->bytes,_pcm,_nsamples,0); #else @@ -2776,7 +2893,7 @@ static int op_filter_read_native(OggOpusFile *_of,void *_dst,int _dst_sz, return ret; } -#if !defined(OPUS_FIXED_POINT)||!defined(OP_DISABLE_FLOAT_API) +#if !defined(OP_FIXED_POINT)||!defined(OP_DISABLE_FLOAT_API) /*Matrices for downmixing from the supported channel counts to stereo. The matrices with 5 or more channels are normalized to a total volume of 2.0, @@ -2815,7 +2932,7 @@ static const float OP_STEREO_DOWNMIX[OP_NCHANNELS_MAX-2][OP_NCHANNELS_MAX][2]={ #endif -#if defined(OPUS_FIXED_POINT) +#if defined(OP_FIXED_POINT) /*Matrices for downmixing from the supported channel counts to stereo. The matrices with 5 or more channels are normalized to a total volume of 2.0, diff --git a/drivers/opus/opusfile.h b/drivers/opus/opusfile.h index 91d06aa9ba..da31a29769 100644 --- a/drivers/opus/opusfile.h +++ b/drivers/opus/opusfile.h @@ -107,7 +107,7 @@ extern "C" { # include <stdarg.h> # include <stdio.h> # include <ogg/ogg.h> -# include <opus/opus_multistream.h> +# include "opus/opus_multistream.h" /**@cond PRIVATE*/ @@ -503,6 +503,22 @@ int opus_tags_add(OpusTags *_tags,const char *_tag,const char *_value) int opus_tags_add_comment(OpusTags *_tags,const char *_comment) OP_ARG_NONNULL(1) OP_ARG_NONNULL(2); +/**Replace the binary suffix data at the end of the packet (if any). + \param _tags An initialized #OpusTags structure. + \param _data A buffer of binary data to append after the encoded user + comments. + The least significant bit of the first byte of this data must + be set (to ensure the data is preserved by other editors). + \param _len The number of bytes of binary data to append. + This may be zero to remove any existing binary suffix data. + \return 0 on success, or a negative value on error. + \retval #OP_EINVAL \a _len was negative, or \a _len was positive but + \a _data was <code>NULL</code> or the least significant + bit of the first byte was not set. + \retval #OP_EFAULT An internal memory allocation failed.*/ +int opus_tags_set_binary_suffix(OpusTags *_tags, + const unsigned char *_data,int _len) OP_ARG_NONNULL(1); + /**Look up a comment value by its tag. \param _tags An initialized #OpusTags structure. \param _tag The tag to look up. @@ -531,6 +547,32 @@ const char *opus_tags_query(const OpusTags *_tags,const char *_tag,int _count) int opus_tags_query_count(const OpusTags *_tags,const char *_tag) OP_ARG_NONNULL(1) OP_ARG_NONNULL(2); +/**Retrieve the binary suffix data at the end of the packet (if any). + \param _tags An initialized #OpusTags structure. + \param[out] _len Returns the number of bytes of binary suffix data returned. + \return A pointer to the binary suffix data, or <code>NULL</code> if none + was present.*/ +const unsigned char *opus_tags_get_binary_suffix(const OpusTags *_tags, + int *_len) OP_ARG_NONNULL(1) OP_ARG_NONNULL(2); + +/**Get the album gain from an R128_ALBUM_GAIN tag, if one was specified. + This searches for the first R128_ALBUM_GAIN tag with a valid signed, + 16-bit decimal integer value and returns the value. + This routine is exposed merely for convenience for applications which wish + to do something special with the album gain (i.e., display it). + If you simply wish to apply the album gain instead of the header gain, you + can use op_set_gain_offset() with an #OP_ALBUM_GAIN type and no offset. + \param _tags An initialized #OpusTags structure. + \param[out] _gain_q8 The album gain, in 1/256ths of a dB. + This will lie in the range [-32768,32767], and should + be applied in <em>addition</em> to the header gain. + On error, no value is returned, and the previous + contents remain unchanged. + \return 0 on success, or a negative value on error. + \retval #OP_FALSE There was no album gain available in the given tags.*/ +int opus_tags_get_album_gain(const OpusTags *_tags,int *_gain_q8) + OP_ARG_NONNULL(1) OP_ARG_NONNULL(2); + /**Get the track gain from an R128_TRACK_GAIN tag, if one was specified. This searches for the first R128_TRACK_GAIN tag with a valid signed, 16-bit decimal integer value and returns the value. @@ -1763,6 +1805,10 @@ void op_set_decode_callback(OggOpusFile *_of, #define OP_HEADER_GAIN (0) /**Gain offset type that indicates that the provided offset is relative to the + R128_ALBUM_GAIN value (if any), in addition to the header gain.*/ +#define OP_ALBUM_GAIN (3007) + +/**Gain offset type that indicates that the provided offset is relative to the R128_TRACK_GAIN value (if any), in addition to the header gain.*/ #define OP_TRACK_GAIN (3008) @@ -1782,8 +1828,8 @@ void op_set_decode_callback(OggOpusFile *_of, It is meant for setting a target volume level, rather than applying smooth fades, etc. \param _of The \c OggOpusFile on which to set the gain offset. - \param _gain_type One of #OP_HEADER_GAIN, #OP_TRACK_GAIN, or - #OP_ABSOLUTE_GAIN. + \param _gain_type One of #OP_HEADER_GAIN, #OP_ALBUM_GAIN, + #OP_TRACK_GAIN, or #OP_ABSOLUTE_GAIN. \param _gain_offset_q8 The gain offset to apply, in 1/256ths of a dB. \return 0 on success or a negative value on error. \retval #OP_EINVAL The \a _gain_type was unrecognized.*/ diff --git a/drivers/opus/repacketizer.c b/drivers/opus/repacketizer.c index eb0c0c7376..3822f9c86f 100644 --- a/drivers/opus/repacketizer.c +++ b/drivers/opus/repacketizer.c @@ -24,10 +24,7 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/opus.h" #include "opus/opus_private.h" @@ -219,8 +216,9 @@ opus_int32 opus_repacketizer_out_range_impl(OpusRepacketizer *rp, int begin, int } if (pad) { - for (i=ptr-data;i<maxlen;i++) - data[i] = 0; + /* Fill padding with zeros. */ + while (ptr<data+maxlen) + *ptr++=0; } return tot_size; } diff --git a/drivers/opus/repacketizer_demo.c b/drivers/opus/repacketizer_demo.c index 5df4f26958..57acf6a53f 100644 --- a/drivers/opus/repacketizer_demo.c +++ b/drivers/opus/repacketizer_demo.c @@ -24,10 +24,7 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/opus.h" #include <stdio.h> diff --git a/drivers/opus/silk/A2NLSF.c b/drivers/opus/silk/A2NLSF.c index 18b0e3092d..38dbefc3bf 100644 --- a/drivers/opus/silk/A2NLSF.c +++ b/drivers/opus/silk/A2NLSF.c @@ -30,10 +30,7 @@ POSSIBILITY OF SUCH DAMAGE. /* A piecewise linear approximation maps LSF <-> cos(LSF) */ /* Therefore the result is not accurate NLSFs, but the two */ /* functions are accurate inverses of each other */ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/SigProc_FIX.h" #include "opus/silk/tables.h" @@ -71,8 +68,23 @@ static OPUS_INLINE opus_int32 silk_A2NLSF_eval_poly( /* return the polynomial ev y32 = p[ dd ]; /* Q16 */ x_Q16 = silk_LSHIFT( x, 4 ); - for( n = dd - 1; n >= 0; n-- ) { - y32 = silk_SMLAWW( p[ n ], y32, x_Q16 ); /* Q16 */ + + if ( opus_likely( 8 == dd ) ) + { + y32 = silk_SMLAWW( p[ 7 ], y32, x_Q16 ); + y32 = silk_SMLAWW( p[ 6 ], y32, x_Q16 ); + y32 = silk_SMLAWW( p[ 5 ], y32, x_Q16 ); + y32 = silk_SMLAWW( p[ 4 ], y32, x_Q16 ); + y32 = silk_SMLAWW( p[ 3 ], y32, x_Q16 ); + y32 = silk_SMLAWW( p[ 2 ], y32, x_Q16 ); + y32 = silk_SMLAWW( p[ 1 ], y32, x_Q16 ); + y32 = silk_SMLAWW( p[ 0 ], y32, x_Q16 ); + } + else + { + for( n = dd - 1; n >= 0; n-- ) { + y32 = silk_SMLAWW( p[ n ], y32, x_Q16 ); /* Q16 */ + } } return y32; } diff --git a/drivers/opus/silk/API.h b/drivers/opus/silk/API.h index 70f81a0c44..ce868c0c99 100644 --- a/drivers/opus/silk/API.h +++ b/drivers/opus/silk/API.h @@ -111,7 +111,8 @@ opus_int silk_Decode( /* O Returns error co opus_int newPacketFlag, /* I Indicates first decoder call for this packet */ ec_dec *psRangeDec, /* I/O Compressor data structure */ opus_int16 *samplesOut, /* O Decoded output speech vector */ - opus_int32 *nSamplesOut /* O Number of samples decoded */ + opus_int32 *nSamplesOut, /* O Number of samples decoded */ + int arch /* I Run-time architecture */ ); #if 0 diff --git a/drivers/opus/silk/CNG.c b/drivers/opus/silk/CNG.c index 253ae7db4c..595a288865 100644 --- a/drivers/opus/silk/CNG.c +++ b/drivers/opus/silk/CNG.c @@ -24,17 +24,14 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" #include "opus/celt/stack_alloc.h" /* Generates excitation for CNG LPC synthesis */ static OPUS_INLINE void silk_CNG_exc( - opus_int32 residual_Q10[], /* O CNG residual signal Q10 */ + opus_int32 exc_Q10[], /* O CNG excitation signal Q10 */ opus_int32 exc_buf_Q14[], /* I Random samples buffer Q10 */ opus_int32 Gain_Q16, /* I Gain to apply */ opus_int length, /* I Length */ @@ -55,7 +52,7 @@ static OPUS_INLINE void silk_CNG_exc( idx = (opus_int)( silk_RSHIFT( seed, 24 ) & exc_mask ); silk_assert( idx >= 0 ); silk_assert( idx <= CNG_BUF_MASK_MAX ); - residual_Q10[ i ] = (opus_int16)silk_SAT16( silk_SMULWW( exc_buf_Q14[ idx ], Gain_Q16 >> 4 ) ); + exc_Q10[ i ] = (opus_int16)silk_SAT16( silk_SMULWW( exc_buf_Q14[ idx ], Gain_Q16 >> 4 ) ); } *rand_seed = seed; } @@ -85,7 +82,7 @@ void silk_CNG( ) { opus_int i, subfr; - opus_int32 sum_Q6, max_Gain_Q16; + opus_int32 sum_Q6, max_Gain_Q16, gain_Q16; opus_int16 A_Q12[ MAX_LPC_ORDER ]; silk_CNG_struct *psCNG = &psDec->sCNG; SAVE_STACK; @@ -125,11 +122,20 @@ void silk_CNG( /* Add CNG when packet is lost or during DTX */ if( psDec->lossCnt ) { VARDECL( opus_int32, CNG_sig_Q10 ); - ALLOC( CNG_sig_Q10, length + MAX_LPC_ORDER, opus_int32 ); /* Generate CNG excitation */ - silk_CNG_exc( CNG_sig_Q10 + MAX_LPC_ORDER, psCNG->CNG_exc_buf_Q14, psCNG->CNG_smth_Gain_Q16, length, &psCNG->rand_seed ); + gain_Q16 = silk_SMULWW( psDec->sPLC.randScale_Q14, psDec->sPLC.prevGain_Q16[1] ); + if( gain_Q16 >= (1 << 21) || psCNG->CNG_smth_Gain_Q16 > (1 << 23) ) { + gain_Q16 = silk_SMULTT( gain_Q16, gain_Q16 ); + gain_Q16 = silk_SUB_LSHIFT32(silk_SMULTT( psCNG->CNG_smth_Gain_Q16, psCNG->CNG_smth_Gain_Q16 ), gain_Q16, 5 ); + gain_Q16 = silk_LSHIFT32( silk_SQRT_APPROX( gain_Q16 ), 16 ); + } else { + gain_Q16 = silk_SMULWW( gain_Q16, gain_Q16 ); + gain_Q16 = silk_SUB_LSHIFT32(silk_SMULWW( psCNG->CNG_smth_Gain_Q16, psCNG->CNG_smth_Gain_Q16 ), gain_Q16, 5 ); + gain_Q16 = silk_LSHIFT32( silk_SQRT_APPROX( gain_Q16 ), 8 ); + } + silk_CNG_exc( CNG_sig_Q10 + MAX_LPC_ORDER, psCNG->CNG_exc_buf_Q14, gain_Q16, length, &psCNG->rand_seed ); /* Convert CNG NLSF to filter representation */ silk_NLSF2A( A_Q12, psCNG->CNG_smth_NLSF_Q15, psDec->LPC_order ); @@ -162,7 +168,7 @@ void silk_CNG( /* Update states */ CNG_sig_Q10[ MAX_LPC_ORDER + i ] = silk_ADD_LSHIFT( CNG_sig_Q10[ MAX_LPC_ORDER + i ], sum_Q6, 4 ); - frame[ i ] = silk_ADD_SAT16( frame[ i ], silk_RSHIFT_ROUND( sum_Q6, 6 ) ); + frame[ i ] = silk_ADD_SAT16( frame[ i ], silk_RSHIFT_ROUND( CNG_sig_Q10[ MAX_LPC_ORDER + i ], 10 ) ); } silk_memcpy( psCNG->CNG_synth_state, &CNG_sig_Q10[ length ], MAX_LPC_ORDER * sizeof( opus_int32 ) ); } else { diff --git a/drivers/opus/silk/HP_variable_cutoff.c b/drivers/opus/silk/HP_variable_cutoff.c index 9da2032869..6b93fdb5a3 100644 --- a/drivers/opus/silk/HP_variable_cutoff.c +++ b/drivers/opus/silk/HP_variable_cutoff.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #ifdef OPUS_FIXED_POINT #include "opus/silk/fixed/main_FIX.h" #else diff --git a/drivers/opus/silk/LPC_analysis_filter.c b/drivers/opus/silk/LPC_analysis_filter.c index 4976d9d3c5..f3c34b5482 100644 --- a/drivers/opus/silk/LPC_analysis_filter.c +++ b/drivers/opus/silk/LPC_analysis_filter.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/SigProc_FIX.h" #include "opus/celt/celt_lpc.h" @@ -44,7 +41,8 @@ void silk_LPC_analysis_filter( const opus_int16 *in, /* I Input signal */ const opus_int16 *B, /* I MA prediction coefficients, Q12 [order] */ const opus_int32 len, /* I Signal length */ - const opus_int32 d /* I Filter order */ + const opus_int32 d, /* I Filter order */ + int arch /* I Run-time architecture */ ) { opus_int j; @@ -69,11 +67,12 @@ void silk_LPC_analysis_filter( for (j=0;j<d;j++) { mem[ j ] = in[ d - j - 1 ]; } - celt_fir( in + d, num, out + d, len - d, d, mem ); + celt_fir( in + d, num, out + d, len - d, d, mem, arch ); for ( j = 0; j < d; j++ ) { out[ j ] = 0; } #else + (void)arch; for( ix = d; ix < len; ix++ ) { in_ptr = &in[ ix - 1 ]; diff --git a/drivers/opus/silk/LPC_inv_pred_gain.c b/drivers/opus/silk/LPC_inv_pred_gain.c index aa67875759..8ace51500c 100644 --- a/drivers/opus/silk/LPC_inv_pred_gain.c +++ b/drivers/opus/silk/LPC_inv_pred_gain.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/SigProc_FIX.h" diff --git a/drivers/opus/silk/LP_variable_cutoff.c b/drivers/opus/silk/LP_variable_cutoff.c index 65c4a6b06a..b39497c4d9 100644 --- a/drivers/opus/silk/LP_variable_cutoff.c +++ b/drivers/opus/silk/LP_variable_cutoff.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif /* Elliptic/Cauer filters designed with 0.1 dB passband ripple, @@ -35,7 +32,7 @@ POSSIBILITY OF SUCH DAMAGE. [0.95 : 0.15 : 0.35] normalized cut off frequencies. */ -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" /* Helper function, interpolates the filter taps */ static OPUS_INLINE void silk_LP_interpolate_filter_taps( diff --git a/drivers/opus/silk/NLSF2A.c b/drivers/opus/silk/NLSF2A.c index c3b8568a0c..09db1c1c3f 100644 --- a/drivers/opus/silk/NLSF2A.c +++ b/drivers/opus/silk/NLSF2A.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif /* conversion between prediction filter coefficients and LSFs */ /* order should be even */ diff --git a/drivers/opus/silk/NLSF_VQ.c b/drivers/opus/silk/NLSF_VQ.c index 9420f5bfb9..99a37d4e0d 100644 --- a/drivers/opus/silk/NLSF_VQ.c +++ b/drivers/opus/silk/NLSF_VQ.c @@ -24,12 +24,9 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" /* Compute quantization errors for an LPC_order element input vector for a VQ codebook */ void silk_NLSF_VQ( diff --git a/drivers/opus/silk/NLSF_VQ_weights_laroia.c b/drivers/opus/silk/NLSF_VQ_weights_laroia.c index d3b4fd6401..5743a4dee9 100644 --- a/drivers/opus/silk/NLSF_VQ_weights_laroia.c +++ b/drivers/opus/silk/NLSF_VQ_weights_laroia.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/define.h" #include "opus/silk/SigProc_FIX.h" diff --git a/drivers/opus/silk/NLSF_decode.c b/drivers/opus/silk/NLSF_decode.c index 6868a93858..6b922f3eee 100644 --- a/drivers/opus/silk/NLSF_decode.c +++ b/drivers/opus/silk/NLSF_decode.c @@ -24,12 +24,9 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" /* Predictive dequantizer for NLSF residuals */ static OPUS_INLINE void silk_NLSF_residual_dequant( /* O Returns RD value in Q30 */ diff --git a/drivers/opus/silk/NLSF_del_dec_quant.c b/drivers/opus/silk/NLSF_del_dec_quant.c index 9caeb0a23b..3f81b2028c 100644 --- a/drivers/opus/silk/NLSF_del_dec_quant.c +++ b/drivers/opus/silk/NLSF_del_dec_quant.c @@ -24,12 +24,9 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" /* Delayed-decision quantizer for NLSF residuals */ opus_int32 silk_NLSF_del_dec_quant( /* O Returns RD value in Q25 */ @@ -56,6 +53,28 @@ opus_int32 silk_NLSF_del_dec_quant( /* O Returns opus_int32 RD_max_Q25[ NLSF_QUANT_DEL_DEC_STATES ]; const opus_uint8 *rates_Q5; + opus_int out0_Q10_table[2 * NLSF_QUANT_MAX_AMPLITUDE_EXT]; + opus_int out1_Q10_table[2 * NLSF_QUANT_MAX_AMPLITUDE_EXT]; + + for (i = -NLSF_QUANT_MAX_AMPLITUDE_EXT; i <= NLSF_QUANT_MAX_AMPLITUDE_EXT-1; i++) + { + out0_Q10 = silk_LSHIFT( i, 10 ); + out1_Q10 = silk_ADD16( out0_Q10, 1024 ); + if( i > 0 ) { + out0_Q10 = silk_SUB16( out0_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) ); + out1_Q10 = silk_SUB16( out1_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) ); + } else if( i == 0 ) { + out1_Q10 = silk_SUB16( out1_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) ); + } else if( i == -1 ) { + out0_Q10 = silk_ADD16( out0_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) ); + } else { + out0_Q10 = silk_ADD16( out0_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) ); + out1_Q10 = silk_ADD16( out1_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) ); + } + out0_Q10_table[ i + NLSF_QUANT_MAX_AMPLITUDE_EXT ] = silk_SMULWB( (opus_int32)out0_Q10, quant_step_size_Q16 ); + out1_Q10_table[ i + NLSF_QUANT_MAX_AMPLITUDE_EXT ] = silk_SMULWB( (opus_int32)out1_Q10, quant_step_size_Q16 ); + } + silk_assert( (NLSF_QUANT_DEL_DEC_STATES & (NLSF_QUANT_DEL_DEC_STATES-1)) == 0 ); /* must be power of two */ nStates = 1; @@ -73,21 +92,9 @@ opus_int32 silk_NLSF_del_dec_quant( /* O Returns ind[ j ][ i ] = (opus_int8)ind_tmp; /* compute outputs for ind_tmp and ind_tmp + 1 */ - out0_Q10 = silk_LSHIFT( ind_tmp, 10 ); - out1_Q10 = silk_ADD16( out0_Q10, 1024 ); - if( ind_tmp > 0 ) { - out0_Q10 = silk_SUB16( out0_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) ); - out1_Q10 = silk_SUB16( out1_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) ); - } else if( ind_tmp == 0 ) { - out1_Q10 = silk_SUB16( out1_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) ); - } else if( ind_tmp == -1 ) { - out0_Q10 = silk_ADD16( out0_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) ); - } else { - out0_Q10 = silk_ADD16( out0_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) ); - out1_Q10 = silk_ADD16( out1_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) ); - } - out0_Q10 = silk_SMULWB( (opus_int32)out0_Q10, quant_step_size_Q16 ); - out1_Q10 = silk_SMULWB( (opus_int32)out1_Q10, quant_step_size_Q16 ); + out0_Q10 = out0_Q10_table[ ind_tmp + NLSF_QUANT_MAX_AMPLITUDE_EXT ]; + out1_Q10 = out1_Q10_table[ ind_tmp + NLSF_QUANT_MAX_AMPLITUDE_EXT ]; + out0_Q10 = silk_ADD16( out0_Q10, pred_Q10 ); out1_Q10 = silk_ADD16( out1_Q10, pred_Q10 ); prev_out_Q10[ j ] = out0_Q10; diff --git a/drivers/opus/silk/NLSF_encode.c b/drivers/opus/silk/NLSF_encode.c index 157c0c8ff6..9efb3e5158 100644 --- a/drivers/opus/silk/NLSF_encode.c +++ b/drivers/opus/silk/NLSF_encode.c @@ -24,12 +24,9 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" #include "opus/celt/stack_alloc.h" /***********************/ diff --git a/drivers/opus/silk/NLSF_stabilize.c b/drivers/opus/silk/NLSF_stabilize.c index caeeed9754..1a45e16925 100644 --- a/drivers/opus/silk/NLSF_stabilize.c +++ b/drivers/opus/silk/NLSF_stabilize.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif /* NLSF stabilizer: */ /* */ diff --git a/drivers/opus/silk/NLSF_unpack.c b/drivers/opus/silk/NLSF_unpack.c index 20d3020f9b..c958f4a6ef 100644 --- a/drivers/opus/silk/NLSF_unpack.c +++ b/drivers/opus/silk/NLSF_unpack.c @@ -24,12 +24,9 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" /* Unpack predictor values and indices for entropy coding tables */ void silk_NLSF_unpack( diff --git a/drivers/opus/silk/NSQ.c b/drivers/opus/silk/NSQ.c index 6092498a1b..e41e533bde 100644 --- a/drivers/opus/silk/NSQ.c +++ b/drivers/opus/silk/NSQ.c @@ -24,12 +24,9 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" #include "opus/celt/stack_alloc.h" static OPUS_INLINE void silk_nsq_scale_states( @@ -46,6 +43,7 @@ static OPUS_INLINE void silk_nsq_scale_states( const opus_int signal_type /* I Signal type */ ); +#if !defined(OPUS_X86_MAY_HAVE_SSE4_1) static OPUS_INLINE void silk_noise_shape_quantizer( silk_nsq_state *NSQ, /* I/O NSQ state */ opus_int signalType, /* I Signal type */ @@ -67,8 +65,10 @@ static OPUS_INLINE void silk_noise_shape_quantizer( opus_int shapingLPCOrder, /* I Noise shaping AR filter order */ opus_int predictLPCOrder /* I Prediction filter order */ ); +#endif -void silk_NSQ( +void silk_NSQ_c +( const silk_encoder_state *psEncC, /* I/O Encoder State */ silk_nsq_state *NSQ, /* I/O NSQ state */ SideInfoIndices *psIndices, /* I/O Quantization Indices */ @@ -141,7 +141,7 @@ void silk_NSQ( silk_assert( start_idx > 0 ); silk_LPC_analysis_filter( &sLTP[ start_idx ], &NSQ->xq[ start_idx + k * psEncC->subfr_length ], - A_Q12, psEncC->ltp_mem_length - start_idx, psEncC->predictLPCOrder ); + A_Q12, psEncC->ltp_mem_length - start_idx, psEncC->predictLPCOrder, psEncC->arch ); NSQ->rewhite_flag = 1; NSQ->sLTP_buf_idx = psEncC->ltp_mem_length; @@ -172,7 +172,11 @@ void silk_NSQ( /***********************************/ /* silk_noise_shape_quantizer */ /***********************************/ -static OPUS_INLINE void silk_noise_shape_quantizer( + +#if !defined(OPUS_X86_MAY_HAVE_SSE4_1) +static OPUS_INLINE +#endif +void silk_noise_shape_quantizer( silk_nsq_state *NSQ, /* I/O NSQ state */ opus_int signalType, /* I Signal type */ const opus_int32 x_sc_Q10[], /* I */ diff --git a/drivers/opus/silk/NSQ_del_dec.c b/drivers/opus/silk/NSQ_del_dec.c index 4aa730ed6a..28b385e415 100644 --- a/drivers/opus/silk/NSQ_del_dec.c +++ b/drivers/opus/silk/NSQ_del_dec.c @@ -24,12 +24,9 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" #include "opus/celt/stack_alloc.h" typedef struct { @@ -57,6 +54,9 @@ typedef struct { typedef NSQ_sample_struct NSQ_sample_pair[ 2 ]; +#if defined(MIPSr1_ASM) +#include "opus/silk/mips/NSQ_del_dec_mipsr1.h" +#endif static OPUS_INLINE void silk_nsq_del_dec_scale_states( const silk_encoder_state *psEncC, /* I Encoder State */ silk_nsq_state *NSQ, /* I/O NSQ state */ @@ -106,7 +106,7 @@ static OPUS_INLINE void silk_noise_shape_quantizer_del_dec( opus_int decisionDelay /* I */ ); -void silk_NSQ_del_dec( +void silk_NSQ_del_dec_c( const silk_encoder_state *psEncC, /* I/O Encoder State */ silk_nsq_state *NSQ, /* I/O NSQ state */ SideInfoIndices *psIndices, /* I/O Quantization Indices */ @@ -244,7 +244,7 @@ void silk_NSQ_del_dec( silk_assert( start_idx > 0 ); silk_LPC_analysis_filter( &sLTP[ start_idx ], &NSQ->xq[ start_idx + k * psEncC->subfr_length ], - A_Q12, psEncC->ltp_mem_length - start_idx, psEncC->predictLPCOrder ); + A_Q12, psEncC->ltp_mem_length - start_idx, psEncC->predictLPCOrder, psEncC->arch ); NSQ->sLTP_buf_idx = psEncC->ltp_mem_length; NSQ->rewhite_flag = 1; @@ -303,6 +303,7 @@ void silk_NSQ_del_dec( /******************************************/ /* Noise shape quantizer for one subframe */ /******************************************/ +#ifndef OVERRIDE_silk_noise_shape_quantizer_del_dec static OPUS_INLINE void silk_noise_shape_quantizer_del_dec( silk_nsq_state *NSQ, /* I/O NSQ state */ NSQ_del_dec_struct psDelDec[], /* I/O Delayed decision states */ @@ -629,6 +630,7 @@ static OPUS_INLINE void silk_noise_shape_quantizer_del_dec( } RESTORE_STACK; } +#endif /* OVERRIDE_silk_noise_shape_quantizer_del_dec */ static OPUS_INLINE void silk_nsq_del_dec_scale_states( const silk_encoder_state *psEncC, /* I Encoder State */ diff --git a/drivers/opus/silk/PLC.c b/drivers/opus/silk/PLC.c index 1f5ce09927..4007112c5a 100644 --- a/drivers/opus/silk/PLC.c +++ b/drivers/opus/silk/PLC.c @@ -24,12 +24,9 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" #include "opus/celt/stack_alloc.h" #include "opus/silk/PLC.h" @@ -46,7 +43,8 @@ static OPUS_INLINE void silk_PLC_update( static OPUS_INLINE void silk_PLC_conceal( silk_decoder_state *psDec, /* I/O Decoder state */ silk_decoder_control *psDecCtrl, /* I/O Decoder control */ - opus_int16 frame[] /* O LPC residual signal */ + opus_int16 frame[], /* O LPC residual signal */ + int arch /* I Run-time architecture */ ); @@ -65,7 +63,8 @@ void silk_PLC( silk_decoder_state *psDec, /* I/O Decoder state */ silk_decoder_control *psDecCtrl, /* I/O Decoder control */ opus_int16 frame[], /* I/O signal */ - opus_int lost /* I Loss flag */ + opus_int lost, /* I Loss flag */ + int arch /* I Run-time architecture */ ) { /* PLC control function */ @@ -78,7 +77,7 @@ void silk_PLC( /****************************/ /* Generate Signal */ /****************************/ - silk_PLC_conceal( psDec, psDecCtrl, frame ); + silk_PLC_conceal( psDec, psDecCtrl, frame, arch ); psDec->lossCnt++; } else { @@ -165,10 +164,35 @@ static OPUS_INLINE void silk_PLC_update( psPLC->nb_subfr = psDec->nb_subfr; } +static OPUS_INLINE void silk_PLC_energy(opus_int32 *energy1, opus_int *shift1, opus_int32 *energy2, opus_int *shift2, + const opus_int32 *exc_Q14, const opus_int32 *prevGain_Q10, int subfr_length, int nb_subfr) +{ + int i, k; + VARDECL( opus_int16, exc_buf ); + opus_int16 *exc_buf_ptr; + SAVE_STACK; + ALLOC( exc_buf, 2*subfr_length, opus_int16 ); + /* Find random noise component */ + /* Scale previous excitation signal */ + exc_buf_ptr = exc_buf; + for( k = 0; k < 2; k++ ) { + for( i = 0; i < subfr_length; i++ ) { + exc_buf_ptr[ i ] = (opus_int16)silk_SAT16( silk_RSHIFT( + silk_SMULWW( exc_Q14[ i + ( k + nb_subfr - 2 ) * subfr_length ], prevGain_Q10[ k ] ), 8 ) ); + } + exc_buf_ptr += subfr_length; + } + /* Find the subframe with lowest energy of the last two and use that as random noise generator */ + silk_sum_sqr_shift( energy1, shift1, exc_buf, subfr_length ); + silk_sum_sqr_shift( energy2, shift2, &exc_buf[ subfr_length ], subfr_length ); + RESTORE_STACK; +} + static OPUS_INLINE void silk_PLC_conceal( silk_decoder_state *psDec, /* I/O Decoder state */ silk_decoder_control *psDecCtrl, /* I/O Decoder control */ - opus_int16 frame[] /* O LPC residual signal */ + opus_int16 frame[], /* O LPC residual signal */ + int arch /* I Run-time architecture */ ) { opus_int i, j, k; @@ -177,19 +201,26 @@ static OPUS_INLINE void silk_PLC_conceal( opus_int32 energy1, energy2, *rand_ptr, *pred_lag_ptr; opus_int32 LPC_pred_Q10, LTP_pred_Q12; opus_int16 rand_scale_Q14; - opus_int16 *B_Q14, *exc_buf_ptr; + opus_int16 *B_Q14; opus_int32 *sLPC_Q14_ptr; - VARDECL( opus_int16, exc_buf ); opus_int16 A_Q12[ MAX_LPC_ORDER ]; +#ifdef SMALL_FOOTPRINT + opus_int16 *sLTP; +#else VARDECL( opus_int16, sLTP ); +#endif VARDECL( opus_int32, sLTP_Q14 ); silk_PLC_struct *psPLC = &psDec->sPLC; opus_int32 prevGain_Q10[2]; SAVE_STACK; - ALLOC( exc_buf, 2*psPLC->subfr_length, opus_int16 ); - ALLOC( sLTP, psDec->ltp_mem_length, opus_int16 ); ALLOC( sLTP_Q14, psDec->ltp_mem_length + psDec->frame_length, opus_int32 ); +#ifdef SMALL_FOOTPRINT + /* Ugly hack that breaks aliasing rules to save stack: put sLTP at the very end of sLTP_Q14. */ + sLTP = ((opus_int16*)&sLTP_Q14[psDec->ltp_mem_length + psDec->frame_length])-psDec->ltp_mem_length; +#else + ALLOC( sLTP, psDec->ltp_mem_length, opus_int16 ); +#endif prevGain_Q10[0] = silk_RSHIFT( psPLC->prevGain_Q16[ 0 ], 6); prevGain_Q10[1] = silk_RSHIFT( psPLC->prevGain_Q16[ 1 ], 6); @@ -198,19 +229,7 @@ static OPUS_INLINE void silk_PLC_conceal( silk_memset( psPLC->prevLPC_Q12, 0, sizeof( psPLC->prevLPC_Q12 ) ); } - /* Find random noise component */ - /* Scale previous excitation signal */ - exc_buf_ptr = exc_buf; - for( k = 0; k < 2; k++ ) { - for( i = 0; i < psPLC->subfr_length; i++ ) { - exc_buf_ptr[ i ] = (opus_int16)silk_SAT16( silk_RSHIFT( - silk_SMULWW( psDec->exc_Q14[ i + ( k + psPLC->nb_subfr - 2 ) * psPLC->subfr_length ], prevGain_Q10[ k ] ), 8 ) ); - } - exc_buf_ptr += psPLC->subfr_length; - } - /* Find the subframe with lowest energy of the last two and use that as random noise generator */ - silk_sum_sqr_shift( &energy1, &shift1, exc_buf, psPLC->subfr_length ); - silk_sum_sqr_shift( &energy2, &shift2, &exc_buf[ psPLC->subfr_length ], psPLC->subfr_length ); + silk_PLC_energy(&energy1, &shift1, &energy2, &shift2, psDec->exc_Q14, prevGain_Q10, psDec->subfr_length, psDec->nb_subfr); if( silk_RSHIFT( energy1, shift2 ) < silk_RSHIFT( energy2, shift1 ) ) { /* First sub-frame has lowest energy */ @@ -270,7 +289,7 @@ static OPUS_INLINE void silk_PLC_conceal( /* Rewhiten LTP state */ idx = psDec->ltp_mem_length - lag - psDec->LPC_order - LTP_ORDER / 2; silk_assert( idx > 0 ); - silk_LPC_analysis_filter( &sLTP[ idx ], &psDec->outBuf[ idx ], A_Q12, psDec->ltp_mem_length - idx, psDec->LPC_order ); + silk_LPC_analysis_filter( &sLTP[ idx ], &psDec->outBuf[ idx ], A_Q12, psDec->ltp_mem_length - idx, psDec->LPC_order, arch ); /* Scale LTP state */ inv_gain_Q30 = silk_INVERSE32_varQ( psPLC->prevGain_Q16[ 1 ], 46 ); inv_gain_Q30 = silk_min( inv_gain_Q30, silk_int32_MAX >> 1 ); diff --git a/drivers/opus/silk/PLC.h b/drivers/opus/silk/PLC.h index ae573fc00c..209c2de48f 100644 --- a/drivers/opus/silk/PLC.h +++ b/drivers/opus/silk/PLC.h @@ -28,7 +28,7 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef SILK_PLC_H #define SILK_PLC_H -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" #define BWE_COEF 0.99 #define V_PITCH_GAIN_START_MIN_Q14 11469 /* 0.7 in Q14 */ @@ -48,7 +48,8 @@ void silk_PLC( silk_decoder_state *psDec, /* I/O Decoder state */ silk_decoder_control *psDecCtrl, /* I/O Decoder control */ opus_int16 frame[], /* I/O signal */ - opus_int lost /* I Loss flag */ + opus_int lost, /* I Loss flag */ + int arch /* I Run-time architecture */ ); void silk_PLC_glue_frames( diff --git a/drivers/opus/silk/SigProc_FIX.h b/drivers/opus/silk/SigProc_FIX.h index f4db0fa9a4..743cf7800c 100644 --- a/drivers/opus/silk/SigProc_FIX.h +++ b/drivers/opus/silk/SigProc_FIX.h @@ -41,7 +41,11 @@ extern "C" #include "opus/silk/typedef.h" #include "opus/silk/resampler_structs.h" #include "opus/silk/macros.h" +#include "opus/celt/cpu_support.h" +#if defined(OPUS_X86_MAY_HAVE_SSE4_1) +#include "opus/silk/x86/SigProc_FIX_sse.h" +#endif /********************************************************************/ /* SIGNAL PROCESSING FUNCTIONS */ @@ -108,7 +112,8 @@ void silk_LPC_analysis_filter( const opus_int16 *in, /* I Input signal */ const opus_int16 *B, /* I MA prediction coefficients, Q12 [order] */ const opus_int32 len, /* I Signal length */ - const opus_int32 d /* I Filter order */ + const opus_int32 d, /* I Filter order */ + int arch /* I Run-time architecture */ ); /* Chirp (bandwidth expand) LP AR filter */ @@ -303,7 +308,7 @@ void silk_NLSF_VQ_weights_laroia( ); /* Compute reflection coefficients from input signal */ -void silk_burg_modified( +void silk_burg_modified_c( opus_int32 *res_nrg, /* O Residual energy */ opus_int *res_nrg_Q, /* O Residual energy Q value */ opus_int32 A_Q16[], /* O Prediction coefficients (length order) */ @@ -335,12 +340,15 @@ void silk_scale_vector32_Q26_lshift_18( /********************************************************************/ /* return sum( inVec1[i] * inVec2[i] ) */ + opus_int32 silk_inner_prod_aligned( const opus_int16 *const inVec1, /* I input vector 1 */ const opus_int16 *const inVec2, /* I input vector 2 */ - const opus_int len /* I vector lengths */ + const opus_int len, /* I vector lengths */ + int arch /* I Run-time architecture */ ); + opus_int32 silk_inner_prod_aligned_scale( const opus_int16 *const inVec1, /* I input vector 1 */ const opus_int16 *const inVec2, /* I input vector 2 */ @@ -348,7 +356,7 @@ opus_int32 silk_inner_prod_aligned_scale( const opus_int len /* I vector lengths */ ); -opus_int64 silk_inner_prod16_aligned_64( +opus_int64 silk_inner_prod16_aligned_64_c( const opus_int16 *inVec1, /* I input vector 1 */ const opus_int16 *inVec2, /* I input vector 2 */ const opus_int len /* I vector lengths */ @@ -575,18 +583,31 @@ static OPUS_INLINE opus_int64 silk_max_64(opus_int64 a, opus_int64 b) /* the following seems faster on x86 */ #define silk_SMMUL(a32, b32) (opus_int32)silk_RSHIFT64(silk_SMULL((a32), (b32)), 32) +#if !defined(OPUS_X86_MAY_HAVE_SSE4_1) +#define silk_burg_modified(res_nrg, res_nrg_Q, A_Q16, x, minInvGain_Q30, subfr_length, nb_subfr, D, arch) \ + ((void)(arch), silk_burg_modified_c(res_nrg, res_nrg_Q, A_Q16, x, minInvGain_Q30, subfr_length, nb_subfr, D, arch)) + +#define silk_inner_prod16_aligned_64(inVec1, inVec2, len, arch) \ + ((void)(arch),silk_inner_prod16_aligned_64_c(inVec1, inVec2, len)) +#endif + #include "opus/silk/Inlines.h" #include "opus/silk/MacroCount.h" #include "opus/silk/MacroDebug.h" #ifdef OPUS_ARM_INLINE_ASM -#include "arm/SigProc_FIX_armv4.h" +#include "opus/silk/arm/SigProc_FIX_armv4.h" #endif #ifdef OPUS_ARM_INLINE_EDSP -#include "arm/SigProc_FIX_armv5e.h" +#include "opus/silk/arm/SigProc_FIX_armv5e.h" #endif +#if defined(MIPSr1_ASM) +#include "opus/silk/mips/sigproc_fix_mipsr1.h" +#endif + + #ifdef __cplusplus } #endif diff --git a/drivers/opus/silk/VAD.c b/drivers/opus/silk/VAD.c index a789a13d32..bb664cff87 100644 --- a/drivers/opus/silk/VAD.c +++ b/drivers/opus/silk/VAD.c @@ -24,19 +24,18 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" #include "opus/celt/stack_alloc.h" /* Silk VAD noise level estimation */ +# if !defined(OPUS_X86_MAY_HAVE_SSE4_1) static OPUS_INLINE void silk_VAD_GetNoiseLevels( const opus_int32 pX[ VAD_N_BANDS ], /* I subband energies */ silk_VAD_state *psSilk_VAD /* I/O Pointer to Silk VAD state */ ); +#endif /**********************************/ /* Initialization of the Silk VAD */ @@ -77,7 +76,7 @@ static const opus_int32 tiltWeights[ VAD_N_BANDS ] = { 30000, 6000, -12000, -120 /***************************************/ /* Get the speech activity level in Q8 */ /***************************************/ -opus_int silk_VAD_GetSA_Q8( /* O Return value, 0 if success */ +opus_int silk_VAD_GetSA_Q8_c( /* O Return value, 0 if success */ silk_encoder_state *psEncC, /* I/O Encoder state */ const opus_int16 pIn[] /* I PCM input */ ) @@ -296,7 +295,10 @@ opus_int silk_VAD_GetSA_Q8( /* O Return v /**************************/ /* Noise level estimation */ /**************************/ -static OPUS_INLINE void silk_VAD_GetNoiseLevels( +# if !defined(OPUS_X86_MAY_HAVE_SSE4_1) +static OPUS_INLINE +#endif +void silk_VAD_GetNoiseLevels( const opus_int32 pX[ VAD_N_BANDS ], /* I subband energies */ silk_VAD_state *psSilk_VAD /* I/O Pointer to Silk VAD state */ ) diff --git a/drivers/opus/silk/VQ_WMat_EC.c b/drivers/opus/silk/VQ_WMat_EC.c index a35b84ef14..fec9ee8dde 100644 --- a/drivers/opus/silk/VQ_WMat_EC.c +++ b/drivers/opus/silk/VQ_WMat_EC.c @@ -24,15 +24,12 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" /* Entropy constrained matrix-weighted VQ, hard-coded to 5-element vectors, for a single input data vector */ -void silk_VQ_WMat_EC( +void silk_VQ_WMat_EC_c( opus_int8 *ind, /* O index of best codebook vector */ opus_int32 *rate_dist_Q14, /* O best weighted quant error + mu * rate */ opus_int *gain_Q7, /* O sum of absolute LTP coefficients */ @@ -55,7 +52,7 @@ void silk_VQ_WMat_EC( *rate_dist_Q14 = silk_int32_MAX; cb_row_Q7 = cb_Q7; for( k = 0; k < L; k++ ) { - gain_tmp_Q7 = cb_gain_Q7[k]; + gain_tmp_Q7 = cb_gain_Q7[k]; diff_Q14[ 0 ] = in_Q14[ 0 ] - silk_LSHIFT( cb_row_Q7[ 0 ], 7 ); diff_Q14[ 1 ] = in_Q14[ 1 ] - silk_LSHIFT( cb_row_Q7[ 1 ], 7 ); @@ -66,8 +63,8 @@ void silk_VQ_WMat_EC( /* Weighted rate */ sum1_Q14 = silk_SMULBB( mu_Q9, cl_Q5[ k ] ); - /* Penalty for too large gain */ - sum1_Q14 = silk_ADD_LSHIFT32( sum1_Q14, silk_max( silk_SUB32( gain_tmp_Q7, max_gain_Q7 ), 0 ), 10 ); + /* Penalty for too large gain */ + sum1_Q14 = silk_ADD_LSHIFT32( sum1_Q14, silk_max( silk_SUB32( gain_tmp_Q7, max_gain_Q7 ), 0 ), 10 ); silk_assert( sum1_Q14 >= 0 ); @@ -111,7 +108,7 @@ void silk_VQ_WMat_EC( if( sum1_Q14 < *rate_dist_Q14 ) { *rate_dist_Q14 = sum1_Q14; *ind = (opus_int8)k; - *gain_Q7 = gain_tmp_Q7; + *gain_Q7 = gain_tmp_Q7; } /* Go to next cbk vector */ diff --git a/drivers/opus/silk/ana_filt_bank_1.c b/drivers/opus/silk/ana_filt_bank_1.c index a2fa720bd0..b49bdd90be 100644 --- a/drivers/opus/silk/ana_filt_bank_1.c +++ b/drivers/opus/silk/ana_filt_bank_1.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/SigProc_FIX.h" diff --git a/drivers/opus/silk/biquad_alt.c b/drivers/opus/silk/biquad_alt.c index 85708167de..f797d1e709 100644 --- a/drivers/opus/silk/biquad_alt.c +++ b/drivers/opus/silk/biquad_alt.c @@ -31,10 +31,7 @@ POSSIBILITY OF SUCH DAMAGE. * Second order ARMA filter * * Can handle slowly varying filter coefficients * * */ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/SigProc_FIX.h" diff --git a/drivers/opus/silk/bwexpander.c b/drivers/opus/silk/bwexpander.c index 7f81a2af99..e7cc448520 100644 --- a/drivers/opus/silk/bwexpander.c +++ b/drivers/opus/silk/bwexpander.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/SigProc_FIX.h" diff --git a/drivers/opus/silk/bwexpander_32.c b/drivers/opus/silk/bwexpander_32.c index 58dfe1f8d6..dedd213b3e 100644 --- a/drivers/opus/silk/bwexpander_32.c +++ b/drivers/opus/silk/bwexpander_32.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/SigProc_FIX.h" diff --git a/drivers/opus/silk/check_control_input.c b/drivers/opus/silk/check_control_input.c index 9c882334c3..61a7cc1f33 100644 --- a/drivers/opus/silk/check_control_input.c +++ b/drivers/opus/silk/check_control_input.c @@ -24,12 +24,9 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" #include "opus/silk/control.h" #include "opus/silk/errors.h" diff --git a/drivers/opus/silk/code_signs.c b/drivers/opus/silk/code_signs.c index e2f671d7ca..79c1893514 100644 --- a/drivers/opus/silk/code_signs.c +++ b/drivers/opus/silk/code_signs.c @@ -24,12 +24,9 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" /*#define silk_enc_map(a) ((a) > 0 ? 1 : 0)*/ /*#define silk_dec_map(a) ((a) > 0 ? 1 : -1)*/ @@ -74,7 +71,7 @@ void silk_encode_signs( /* Decodes signs of excitation */ void silk_decode_signs( ec_dec *psRangeDec, /* I/O Compressor data structure */ - opus_int pulses[], /* I/O pulse signal */ + opus_int16 pulses[], /* I/O pulse signal */ opus_int length, /* I length of input */ const opus_int signalType, /* I Signal type */ const opus_int quantOffsetType, /* I Quantization offset type */ @@ -83,7 +80,7 @@ void silk_decode_signs( { opus_int i, j, p; opus_uint8 icdf[ 2 ]; - opus_int *q_ptr; + opus_int16 *q_ptr; const opus_uint8 *icdf_ptr; icdf[ 1 ] = 0; diff --git a/drivers/opus/silk/control_SNR.c b/drivers/opus/silk/control_SNR.c index e3983d5039..5aebfcf385 100644 --- a/drivers/opus/silk/control_SNR.c +++ b/drivers/opus/silk/control_SNR.c @@ -24,12 +24,9 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" #include "opus/silk/tuning_parameters.h" /* Control SNR of redidual quantizer */ @@ -70,11 +67,6 @@ opus_int silk_control_SNR( break; } } - - /* Reduce coding quality whenever LBRR is enabled, to free up some bits */ - if( psEncC->LBRR_enabled ) { - psEncC->SNR_dB_Q7 = silk_SMLABB( psEncC->SNR_dB_Q7, 12 - psEncC->LBRR_GainIncreases, SILK_FIX_CONST( -0.25, 7 ) ); - } } return ret; diff --git a/drivers/opus/silk/control_audio_bandwidth.c b/drivers/opus/silk/control_audio_bandwidth.c index 846a7baa59..04640f53fe 100644 --- a/drivers/opus/silk/control_audio_bandwidth.c +++ b/drivers/opus/silk/control_audio_bandwidth.c @@ -24,12 +24,9 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" #include "opus/silk/tuning_parameters.h" /* Control internal sampling rate */ diff --git a/drivers/opus/silk/control_codec.c b/drivers/opus/silk/control_codec.c index beb6dfe6cd..03caab36a9 100644 --- a/drivers/opus/silk/control_codec.c +++ b/drivers/opus/silk/control_codec.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #ifdef OPUS_FIXED_POINT #include "opus/silk/fixed/main_FIX.h" #define silk_encoder_state_Fxx silk_encoder_state_FIX @@ -397,9 +394,10 @@ static OPUS_INLINE opus_int silk_setup_LBRR( const opus_int32 TargetRate_bps /* I */ ) { - opus_int ret = SILK_NO_ERROR; + opus_int LBRR_in_previous_packet, ret = SILK_NO_ERROR; opus_int32 LBRR_rate_thres_bps; + LBRR_in_previous_packet = psEncC->LBRR_enabled; psEncC->LBRR_enabled = 0; if( psEncC->useInBandFEC && psEncC->PacketLoss_perc > 0 ) { if( psEncC->fs_kHz == 8 ) { @@ -413,8 +411,13 @@ static OPUS_INLINE opus_int silk_setup_LBRR( if( TargetRate_bps > LBRR_rate_thres_bps ) { /* Set gain increase for coding LBRR excitation */ + if( LBRR_in_previous_packet == 0 ) { + /* Previous packet did not have LBRR, and was therefore coded at a higher bitrate */ + psEncC->LBRR_GainIncreases = 7; + } else { + psEncC->LBRR_GainIncreases = silk_max_int( 7 - silk_SMULWB( (opus_int32)psEncC->PacketLoss_perc, SILK_FIX_CONST( 0.4, 16 ) ), 2 ); + } psEncC->LBRR_enabled = 1; - psEncC->LBRR_GainIncreases = silk_max_int( 7 - silk_SMULWB( (opus_int32)psEncC->PacketLoss_perc, SILK_FIX_CONST( 0.4, 16 ) ), 2 ); } } diff --git a/drivers/opus/silk/debug.c b/drivers/opus/silk/debug.c index 9f31b68f76..ffb3f811a1 100644 --- a/drivers/opus/silk/debug.c +++ b/drivers/opus/silk/debug.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/debug.h" #include "opus/silk/SigProc_FIX.h" diff --git a/drivers/opus/silk/dec_API.c b/drivers/opus/silk/dec_API.c index 43aeb4faff..2fd681c0d2 100644 --- a/drivers/opus/silk/dec_API.c +++ b/drivers/opus/silk/dec_API.c @@ -24,13 +24,11 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/API.h" -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" #include "opus/celt/stack_alloc.h" +#include "opus/celt/os_support.h" /************************/ /* Decoder Super Struct */ @@ -84,13 +82,15 @@ opus_int silk_Decode( /* O Returns error co opus_int newPacketFlag, /* I Indicates first decoder call for this packet */ ec_dec *psRangeDec, /* I/O Compressor data structure */ opus_int16 *samplesOut, /* O Decoded output speech vector */ - opus_int32 *nSamplesOut /* O Number of samples decoded */ + opus_int32 *nSamplesOut, /* O Number of samples decoded */ + int arch /* I Run-time architecture */ ) { opus_int i, n, decode_only_middle = 0, ret = SILK_NO_ERROR; opus_int32 nSamplesOutDec, LBRR_symbol; opus_int16 *samplesOut1_tmp[ 2 ]; - VARDECL( opus_int16, samplesOut1_tmp_storage ); + VARDECL( opus_int16, samplesOut1_tmp_storage1 ); + VARDECL( opus_int16, samplesOut1_tmp_storage2 ); VARDECL( opus_int16, samplesOut2_tmp ); opus_int32 MS_pred_Q13[ 2 ] = { 0 }; opus_int16 *resample_out_ptr; @@ -98,6 +98,7 @@ opus_int silk_Decode( /* O Returns error co silk_decoder_state *channel_state = psDec->channel_state; opus_int has_side; opus_int stereo_to_mono; + int delay_stack_alloc; SAVE_STACK; silk_assert( decControl->nChannelsInternal == 1 || decControl->nChannelsInternal == 2 ); @@ -196,7 +197,7 @@ opus_int silk_Decode( /* O Returns error co for( i = 0; i < channel_state[ 0 ].nFramesPerPacket; i++ ) { for( n = 0; n < decControl->nChannelsInternal; n++ ) { if( channel_state[ n ].LBRR_flags[ i ] ) { - opus_int pulses[ MAX_FRAME_LENGTH ]; + opus_int16 pulses[ MAX_FRAME_LENGTH ]; opus_int condCoding; if( decControl->nChannelsInternal == 2 && n == 0 ) { @@ -251,13 +252,22 @@ opus_int silk_Decode( /* O Returns error co psDec->channel_state[ 1 ].first_frame_after_reset = 1; } - ALLOC( samplesOut1_tmp_storage, - decControl->nChannelsInternal*( - channel_state[ 0 ].frame_length + 2 ), + /* Check if the temp buffer fits into the output PCM buffer. If it fits, + we can delay allocating the temp buffer until after the SILK peak stack + usage. We need to use a < and not a <= because of the two extra samples. */ + delay_stack_alloc = decControl->internalSampleRate*decControl->nChannelsInternal + < decControl->API_sampleRate*decControl->nChannelsAPI; + ALLOC( samplesOut1_tmp_storage1, delay_stack_alloc ? ALLOC_NONE + : decControl->nChannelsInternal*(channel_state[ 0 ].frame_length + 2 ), opus_int16 ); - samplesOut1_tmp[ 0 ] = samplesOut1_tmp_storage; - samplesOut1_tmp[ 1 ] = samplesOut1_tmp_storage - + channel_state[ 0 ].frame_length + 2; + if ( delay_stack_alloc ) + { + samplesOut1_tmp[ 0 ] = samplesOut; + samplesOut1_tmp[ 1 ] = samplesOut + channel_state[ 0 ].frame_length + 2; + } else { + samplesOut1_tmp[ 0 ] = samplesOut1_tmp_storage1; + samplesOut1_tmp[ 1 ] = samplesOut1_tmp_storage1 + channel_state[ 0 ].frame_length + 2; + } if( lostFlag == FLAG_DECODE_NORMAL ) { has_side = !decode_only_middle; @@ -284,7 +294,7 @@ opus_int silk_Decode( /* O Returns error co } else { condCoding = CODE_CONDITIONALLY; } - ret += silk_decode_frame( &channel_state[ n ], psRangeDec, &samplesOut1_tmp[ n ][ 2 ], &nSamplesOutDec, lostFlag, condCoding); + ret += silk_decode_frame( &channel_state[ n ], psRangeDec, &samplesOut1_tmp[ n ][ 2 ], &nSamplesOutDec, lostFlag, condCoding, arch); } else { silk_memset( &samplesOut1_tmp[ n ][ 2 ], 0, nSamplesOutDec * sizeof( opus_int16 ) ); } @@ -312,6 +322,15 @@ opus_int silk_Decode( /* O Returns error co resample_out_ptr = samplesOut; } + ALLOC( samplesOut1_tmp_storage2, delay_stack_alloc + ? decControl->nChannelsInternal*(channel_state[ 0 ].frame_length + 2 ) + : ALLOC_NONE, + opus_int16 ); + if ( delay_stack_alloc ) { + OPUS_COPY(samplesOut1_tmp_storage2, samplesOut, decControl->nChannelsInternal*(channel_state[ 0 ].frame_length + 2)); + samplesOut1_tmp[ 0 ] = samplesOut1_tmp_storage2; + samplesOut1_tmp[ 1 ] = samplesOut1_tmp_storage2 + channel_state[ 0 ].frame_length + 2; + } for( n = 0; n < silk_min( decControl->nChannelsAPI, decControl->nChannelsInternal ); n++ ) { /* Resample decoded signal to API_sampleRate */ diff --git a/drivers/opus/silk/decode_core.c b/drivers/opus/silk/decode_core.c index f7cd8db7c9..8ca1adffdd 100644 --- a/drivers/opus/silk/decode_core.c +++ b/drivers/opus/silk/decode_core.c @@ -24,12 +24,9 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" #include "opus/celt/stack_alloc.h" /**********************************************************/ @@ -39,7 +36,8 @@ void silk_decode_core( silk_decoder_state *psDec, /* I/O Decoder state */ silk_decoder_control *psDecCtrl, /* I Decoder control */ opus_int16 xq[], /* O Decoded speech */ - const opus_int pulses[ MAX_FRAME_LENGTH ] /* I Pulse signal */ + const opus_int16 pulses[ MAX_FRAME_LENGTH ], /* I Pulse signal */ + int arch /* I Run-time architecture */ ) { opus_int i, k, lag = 0, start_idx, sLTP_buf_idx, NLSF_interpolation_flag, signalType; @@ -147,7 +145,7 @@ void silk_decode_core( } silk_LPC_analysis_filter( &sLTP[ start_idx ], &psDec->outBuf[ start_idx + k * psDec->subfr_length ], - A_Q12, psDec->ltp_mem_length - start_idx, psDec->LPC_order ); + A_Q12, psDec->ltp_mem_length - start_idx, psDec->LPC_order, arch ); /* After rewhitening the LTP state is unscaled */ if( k == 0 ) { diff --git a/drivers/opus/silk/decode_frame.c b/drivers/opus/silk/decode_frame.c index f166019455..18e2bc9b1a 100644 --- a/drivers/opus/silk/decode_frame.c +++ b/drivers/opus/silk/decode_frame.c @@ -24,12 +24,9 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" #include "opus/celt/stack_alloc.h" #include "opus/silk/PLC.h" @@ -42,18 +39,16 @@ opus_int silk_decode_frame( opus_int16 pOut[], /* O Pointer to output speech frame */ opus_int32 *pN, /* O Pointer to size of output frame */ opus_int lostFlag, /* I 0: no loss, 1 loss, 2 decode fec */ - opus_int condCoding /* I The type of conditional coding to use */ + opus_int condCoding, /* I The type of conditional coding to use */ + int arch /* I Run-time architecture */ ) { VARDECL( silk_decoder_control, psDecCtrl ); opus_int L, mv_len, ret = 0; - VARDECL( opus_int, pulses ); SAVE_STACK; L = psDec->frame_length; ALLOC( psDecCtrl, 1, silk_decoder_control ); - ALLOC( pulses, (L + SHELL_CODEC_FRAME_LENGTH - 1) & - ~(SHELL_CODEC_FRAME_LENGTH - 1), opus_int ); psDecCtrl->LTP_scale_Q14 = 0; /* Safety checks */ @@ -62,6 +57,9 @@ opus_int silk_decode_frame( if( lostFlag == FLAG_DECODE_NORMAL || ( lostFlag == FLAG_DECODE_LBRR && psDec->LBRR_flags[ psDec->nFramesDecoded ] == 1 ) ) { + VARDECL( opus_int16, pulses ); + ALLOC( pulses, (L + SHELL_CODEC_FRAME_LENGTH - 1) & + ~(SHELL_CODEC_FRAME_LENGTH - 1), opus_int16 ); /*********************************************/ /* Decode quantization indices of side info */ /*********************************************/ @@ -81,12 +79,12 @@ opus_int silk_decode_frame( /********************************************************/ /* Run inverse NSQ */ /********************************************************/ - silk_decode_core( psDec, psDecCtrl, pOut, pulses ); + silk_decode_core( psDec, psDecCtrl, pOut, pulses, arch ); /********************************************************/ /* Update PLC state */ /********************************************************/ - silk_PLC( psDec, psDecCtrl, pOut, 0 ); + silk_PLC( psDec, psDecCtrl, pOut, 0, arch ); psDec->lossCnt = 0; psDec->prevSignalType = psDec->indices.signalType; @@ -96,7 +94,7 @@ opus_int silk_decode_frame( psDec->first_frame_after_reset = 0; } else { /* Handle packet loss by extrapolation */ - silk_PLC( psDec, psDecCtrl, pOut, 1 ); + silk_PLC( psDec, psDecCtrl, pOut, 1, arch ); } /*************************/ @@ -107,16 +105,16 @@ opus_int silk_decode_frame( silk_memmove( psDec->outBuf, &psDec->outBuf[ psDec->frame_length ], mv_len * sizeof(opus_int16) ); silk_memcpy( &psDec->outBuf[ mv_len ], pOut, psDec->frame_length * sizeof( opus_int16 ) ); - /****************************************************************/ - /* Ensure smooth connection of extrapolated and good frames */ - /****************************************************************/ - silk_PLC_glue_frames( psDec, pOut, L ); - /************************************************/ /* Comfort noise generation / estimation */ /************************************************/ silk_CNG( psDec, psDecCtrl, pOut, L ); + /****************************************************************/ + /* Ensure smooth connection of extrapolated and good frames */ + /****************************************************************/ + silk_PLC_glue_frames( psDec, pOut, L ); + /* Update some decoder state variables */ psDec->lagPrev = psDecCtrl->pitchL[ psDec->nb_subfr - 1 ]; diff --git a/drivers/opus/silk/decode_indices.c b/drivers/opus/silk/decode_indices.c index 3e09fb416b..fa8066e5f7 100644 --- a/drivers/opus/silk/decode_indices.c +++ b/drivers/opus/silk/decode_indices.c @@ -24,12 +24,9 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" /* Decode side-information parameters from payload */ void silk_decode_indices( diff --git a/drivers/opus/silk/decode_parameters.c b/drivers/opus/silk/decode_parameters.c index 7f4cbeec29..d17cb8a3df 100644 --- a/drivers/opus/silk/decode_parameters.c +++ b/drivers/opus/silk/decode_parameters.c @@ -24,12 +24,9 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" /* Decode parameters from payload */ void silk_decode_parameters( diff --git a/drivers/opus/silk/decode_pitch.c b/drivers/opus/silk/decode_pitch.c index 73e94b4ee2..1d98ee7f33 100644 --- a/drivers/opus/silk/decode_pitch.c +++ b/drivers/opus/silk/decode_pitch.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif /*********************************************************** * Pitch analyser function diff --git a/drivers/opus/silk/decode_pulses.c b/drivers/opus/silk/decode_pulses.c index 24f841881d..c687d3bfa8 100644 --- a/drivers/opus/silk/decode_pulses.c +++ b/drivers/opus/silk/decode_pulses.c @@ -24,19 +24,16 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" /*********************************************/ /* Decode quantization indices of excitation */ /*********************************************/ void silk_decode_pulses( ec_dec *psRangeDec, /* I/O Compressor data structure */ - opus_int pulses[], /* O Excitation signal */ + opus_int16 pulses[], /* O Excitation signal */ const opus_int signalType, /* I Sigtype */ const opus_int quantOffsetType, /* I quantOffsetType */ const opus_int frame_length /* I Frame length */ @@ -44,7 +41,7 @@ void silk_decode_pulses( { opus_int i, j, k, iter, abs_q, nLS, RateLevelIndex; opus_int sum_pulses[ MAX_NB_SHELL_BLOCKS ], nLshifts[ MAX_NB_SHELL_BLOCKS ]; - opus_int *pulses_ptr; + opus_int16 *pulses_ptr; const opus_uint8 *cdf_ptr; /*********************/ @@ -69,9 +66,9 @@ void silk_decode_pulses( sum_pulses[ i ] = ec_dec_icdf( psRangeDec, cdf_ptr, 8 ); /* LSB indication */ - while( sum_pulses[ i ] == MAX_PULSES + 1 ) { + while( sum_pulses[ i ] == SILK_MAX_PULSES + 1 ) { nLshifts[ i ]++; - /* When we've already got 10 LSBs, we shift the table to not allow (MAX_PULSES + 1) */ + /* When we've already got 10 LSBs, we shift the table to not allow (SILK_MAX_PULSES + 1) */ sum_pulses[ i ] = ec_dec_icdf( psRangeDec, silk_pulses_per_block_iCDF[ N_RATE_LEVELS - 1] + ( nLshifts[ i ] == 10 ), 8 ); } @@ -84,7 +81,7 @@ void silk_decode_pulses( if( sum_pulses[ i ] > 0 ) { silk_shell_decoder( &pulses[ silk_SMULBB( i, SHELL_CODEC_FRAME_LENGTH ) ], psRangeDec, sum_pulses[ i ] ); } else { - silk_memset( &pulses[ silk_SMULBB( i, SHELL_CODEC_FRAME_LENGTH ) ], 0, SHELL_CODEC_FRAME_LENGTH * sizeof( opus_int ) ); + silk_memset( &pulses[ silk_SMULBB( i, SHELL_CODEC_FRAME_LENGTH ) ], 0, SHELL_CODEC_FRAME_LENGTH * sizeof( pulses[0] ) ); } } diff --git a/drivers/opus/silk/decoder_set_fs.c b/drivers/opus/silk/decoder_set_fs.c index 97ecd8afd1..0079a506ee 100644 --- a/drivers/opus/silk/decoder_set_fs.c +++ b/drivers/opus/silk/decoder_set_fs.c @@ -24,12 +24,9 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" /* Set decoder sampling rate */ opus_int silk_decoder_set_fs( diff --git a/drivers/opus/silk/define.h b/drivers/opus/silk/define.h index a38564c835..c6165e3cff 100644 --- a/drivers/opus/silk/define.h +++ b/drivers/opus/silk/define.h @@ -169,7 +169,7 @@ extern "C" #define N_RATE_LEVELS 10 /* Maximum sum of pulses per shell coding frame */ -#define MAX_PULSES 16 +#define SILK_MAX_PULSES 16 #define MAX_MATRIX_SIZE MAX_LPC_ORDER /* Max of LPC Order and LTP order */ diff --git a/drivers/opus/silk/enc_API.c b/drivers/opus/silk/enc_API.c index ac1a7854f0..beb46214d8 100644 --- a/drivers/opus/silk/enc_API.c +++ b/drivers/opus/silk/enc_API.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/define.h" #include "opus/silk/API.h" #include "opus/silk/control.h" @@ -165,7 +162,7 @@ opus_int silk_Encode( /* O Returns error co psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded = psEnc->state_Fxx[ 1 ].sCmn.nFramesEncoded = 0; /* Check values in encoder control structure */ - if( ( ret = check_control_input( encControl ) != 0 ) ) { + if( ( ret = check_control_input( encControl ) ) != 0 ) { silk_assert( 0 ); RESTORE_STACK; return ret; @@ -376,26 +373,33 @@ opus_int silk_Encode( /* O Returns error co for( n = 0; n < encControl->nChannelsInternal; n++ ) { silk_memset( psEnc->state_Fxx[ n ].sCmn.LBRR_flags, 0, sizeof( psEnc->state_Fxx[ n ].sCmn.LBRR_flags ) ); } + + psEnc->nBitsUsedLBRR = ec_tell( psRangeEnc ); } silk_HP_variable_cutoff( psEnc->state_Fxx ); /* Total target bits for packet */ nBits = silk_DIV32_16( silk_MUL( encControl->bitRate, encControl->payloadSize_ms ), 1000 ); - /* Subtract half of the bits already used */ + /* Subtract bits used for LBRR */ if( !prefillFlag ) { - nBits -= ec_tell( psRangeEnc ) >> 1; + nBits -= psEnc->nBitsUsedLBRR; } /* Divide by number of uncoded frames left in packet */ - nBits = silk_DIV32_16( nBits, psEnc->state_Fxx[ 0 ].sCmn.nFramesPerPacket - psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded ); + nBits = silk_DIV32_16( nBits, psEnc->state_Fxx[ 0 ].sCmn.nFramesPerPacket ); /* Convert to bits/second */ if( encControl->payloadSize_ms == 10 ) { TargetRate_bps = silk_SMULBB( nBits, 100 ); } else { TargetRate_bps = silk_SMULBB( nBits, 50 ); } - /* Subtract fraction of bits in excess of target in previous packets */ + /* Subtract fraction of bits in excess of target in previous frames and packets */ TargetRate_bps -= silk_DIV32_16( silk_MUL( psEnc->nBitsExceeded, 1000 ), BITRESERVOIR_DECAY_TIME_MS ); + if( !prefillFlag && psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded > 0 ) { + /* Compare actual vs target bits so far in this packet */ + opus_int32 bitsBalance = ec_tell( psRangeEnc ) - psEnc->nBitsUsedLBRR - nBits * psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded; + TargetRate_bps -= silk_DIV32_16( silk_MUL( bitsBalance, 1000 ), BITRESERVOIR_DECAY_TIME_MS ); + } /* Never exceed input bitrate */ TargetRate_bps = silk_LIMIT( TargetRate_bps, encControl->bitRate, 5000 ); diff --git a/drivers/opus/silk/encode_indices.c b/drivers/opus/silk/encode_indices.c index 7150325d49..72fc6a80e8 100644 --- a/drivers/opus/silk/encode_indices.c +++ b/drivers/opus/silk/encode_indices.c @@ -24,12 +24,9 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" /* Encode side-information parameters to payload */ void silk_encode_indices( diff --git a/drivers/opus/silk/encode_pulses.c b/drivers/opus/silk/encode_pulses.c index f9fe39eeb8..238eec1e42 100644 --- a/drivers/opus/silk/encode_pulses.c +++ b/drivers/opus/silk/encode_pulses.c @@ -24,12 +24,9 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" #include "opus/celt/stack_alloc.h" /*********************************************/ @@ -142,7 +139,7 @@ void silk_encode_pulses( sumBits_Q5 = silk_rate_levels_BITS_Q5[ signalType >> 1 ][ k ]; for( i = 0; i < iter; i++ ) { if( nRshifts[ i ] > 0 ) { - sumBits_Q5 += nBits_ptr[ MAX_PULSES + 1 ]; + sumBits_Q5 += nBits_ptr[ SILK_MAX_PULSES + 1 ]; } else { sumBits_Q5 += nBits_ptr[ sum_pulses[ i ] ]; } @@ -162,9 +159,9 @@ void silk_encode_pulses( if( nRshifts[ i ] == 0 ) { ec_enc_icdf( psRangeEnc, sum_pulses[ i ], cdf_ptr, 8 ); } else { - ec_enc_icdf( psRangeEnc, MAX_PULSES + 1, cdf_ptr, 8 ); + ec_enc_icdf( psRangeEnc, SILK_MAX_PULSES + 1, cdf_ptr, 8 ); for( k = 0; k < nRshifts[ i ] - 1; k++ ) { - ec_enc_icdf( psRangeEnc, MAX_PULSES + 1, silk_pulses_per_block_iCDF[ N_RATE_LEVELS - 1 ], 8 ); + ec_enc_icdf( psRangeEnc, SILK_MAX_PULSES + 1, silk_pulses_per_block_iCDF[ N_RATE_LEVELS - 1 ], 8 ); } ec_enc_icdf( psRangeEnc, sum_pulses[ i ], silk_pulses_per_block_iCDF[ N_RATE_LEVELS - 1 ], 8 ); } diff --git a/drivers/opus/silk/fixed/LTP_analysis_filter_FIX.c b/drivers/opus/silk/fixed/LTP_analysis_filter_FIX.c index 19d5defc7a..041e85f0b9 100644 --- a/drivers/opus/silk/fixed/LTP_analysis_filter_FIX.c +++ b/drivers/opus/silk/fixed/LTP_analysis_filter_FIX.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/fixed/main_FIX.h" @@ -45,7 +42,7 @@ void silk_LTP_analysis_filter_FIX( const opus_int16 *x_ptr, *x_lag_ptr; opus_int16 Btmp_Q14[ LTP_ORDER ]; opus_int16 *LTP_res_ptr; - opus_int k, i, j; + opus_int k, i; opus_int32 LTP_est; x_ptr = x; @@ -53,9 +50,12 @@ void silk_LTP_analysis_filter_FIX( for( k = 0; k < nb_subfr; k++ ) { x_lag_ptr = x_ptr - pitchL[ k ]; - for( i = 0; i < LTP_ORDER; i++ ) { - Btmp_Q14[ i ] = LTPCoef_Q14[ k * LTP_ORDER + i ]; - } + + Btmp_Q14[ 0 ] = LTPCoef_Q14[ k * LTP_ORDER ]; + Btmp_Q14[ 1 ] = LTPCoef_Q14[ k * LTP_ORDER + 1 ]; + Btmp_Q14[ 2 ] = LTPCoef_Q14[ k * LTP_ORDER + 2 ]; + Btmp_Q14[ 3 ] = LTPCoef_Q14[ k * LTP_ORDER + 3 ]; + Btmp_Q14[ 4 ] = LTPCoef_Q14[ k * LTP_ORDER + 4 ]; /* LTP analysis FIR filter */ for( i = 0; i < subfr_length + pre_length; i++ ) { @@ -63,9 +63,11 @@ void silk_LTP_analysis_filter_FIX( /* Long-term prediction */ LTP_est = silk_SMULBB( x_lag_ptr[ LTP_ORDER / 2 ], Btmp_Q14[ 0 ] ); - for( j = 1; j < LTP_ORDER; j++ ) { - LTP_est = silk_SMLABB_ovflw( LTP_est, x_lag_ptr[ LTP_ORDER / 2 - j ], Btmp_Q14[ j ] ); - } + LTP_est = silk_SMLABB_ovflw( LTP_est, x_lag_ptr[ 1 ], Btmp_Q14[ 1 ] ); + LTP_est = silk_SMLABB_ovflw( LTP_est, x_lag_ptr[ 0 ], Btmp_Q14[ 2 ] ); + LTP_est = silk_SMLABB_ovflw( LTP_est, x_lag_ptr[ -1 ], Btmp_Q14[ 3 ] ); + LTP_est = silk_SMLABB_ovflw( LTP_est, x_lag_ptr[ -2 ], Btmp_Q14[ 4 ] ); + LTP_est = silk_RSHIFT_ROUND( LTP_est, 14 ); /* round and -> Q0*/ /* Subtract long-term prediction */ diff --git a/drivers/opus/silk/fixed/LTP_scale_ctrl_FIX.c b/drivers/opus/silk/fixed/LTP_scale_ctrl_FIX.c index 0887fd03f7..dac1fbc08a 100644 --- a/drivers/opus/silk/fixed/LTP_scale_ctrl_FIX.c +++ b/drivers/opus/silk/fixed/LTP_scale_ctrl_FIX.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/fixed/main_FIX.h" diff --git a/drivers/opus/silk/fixed/apply_sine_window_FIX.c b/drivers/opus/silk/fixed/apply_sine_window_FIX.c index 5b4d8ebfdc..9d63e7bce2 100644 --- a/drivers/opus/silk/fixed/apply_sine_window_FIX.c +++ b/drivers/opus/silk/fixed/apply_sine_window_FIX.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/SigProc_FIX.h" diff --git a/drivers/opus/silk/fixed/autocorr_FIX.c b/drivers/opus/silk/fixed/autocorr_FIX.c index 88a849e12c..db39a0335b 100644 --- a/drivers/opus/silk/fixed/autocorr_FIX.c +++ b/drivers/opus/silk/fixed/autocorr_FIX.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/SigProc_FIX.h" #include "opus/celt/celt_lpc.h" diff --git a/drivers/opus/silk/fixed/burg_modified_FIX.c b/drivers/opus/silk/fixed/burg_modified_FIX.c index 5ef3ad2c38..48d64eccc5 100644 --- a/drivers/opus/silk/fixed/burg_modified_FIX.c +++ b/drivers/opus/silk/fixed/burg_modified_FIX.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/SigProc_FIX.h" #include "opus/silk/define.h" @@ -42,7 +39,7 @@ POSSIBILITY OF SUCH DAMAGE. #define MAX_RSHIFTS (32 - QA) /* Compute reflection coefficients from input signal */ -void silk_burg_modified( +void silk_burg_modified_c( opus_int32 *res_nrg, /* O Residual energy */ opus_int *res_nrg_Q, /* O Residual energy Q value */ opus_int32 A_Q16[], /* O Prediction coefficients (length order) */ @@ -54,7 +51,7 @@ void silk_burg_modified( int arch /* I Run-time architecture */ ) { - opus_int k, n, s, lz, rshifts, rshifts_extra, reached_max_gain; + opus_int k, n, s, lz, rshifts, reached_max_gain; opus_int32 C0, num, nrg, rc_Q31, invGain_Q30, Atmp_QA, Atmp1, tmp1, tmp2, x1, x2; const opus_int16 *x_ptr; opus_int32 C_first_row[ SILK_MAX_ORDER_LPC ]; @@ -63,27 +60,23 @@ void silk_burg_modified( opus_int32 CAf[ SILK_MAX_ORDER_LPC + 1 ]; opus_int32 CAb[ SILK_MAX_ORDER_LPC + 1 ]; opus_int32 xcorr[ SILK_MAX_ORDER_LPC ]; + opus_int64 C0_64; silk_assert( subfr_length * nb_subfr <= MAX_FRAME_SIZE ); /* Compute autocorrelations, added over subframes */ - silk_sum_sqr_shift( &C0, &rshifts, x, nb_subfr * subfr_length ); - if( rshifts > MAX_RSHIFTS ) { - C0 = silk_LSHIFT32( C0, rshifts - MAX_RSHIFTS ); - silk_assert( C0 > 0 ); - rshifts = MAX_RSHIFTS; + C0_64 = silk_inner_prod16_aligned_64( x, x, subfr_length*nb_subfr, arch ); + lz = silk_CLZ64(C0_64); + rshifts = 32 + 1 + N_BITS_HEAD_ROOM - lz; + if (rshifts > MAX_RSHIFTS) rshifts = MAX_RSHIFTS; + if (rshifts < MIN_RSHIFTS) rshifts = MIN_RSHIFTS; + + if (rshifts > 0) { + C0 = (opus_int32)silk_RSHIFT64(C0_64, rshifts ); } else { - lz = silk_CLZ32( C0 ) - 1; - rshifts_extra = N_BITS_HEAD_ROOM - lz; - if( rshifts_extra > 0 ) { - rshifts_extra = silk_min( rshifts_extra, MAX_RSHIFTS - rshifts ); - C0 = silk_RSHIFT32( C0, rshifts_extra ); - } else { - rshifts_extra = silk_max( rshifts_extra, MIN_RSHIFTS - rshifts ); - C0 = silk_LSHIFT32( C0, -rshifts_extra ); - } - rshifts += rshifts_extra; + C0 = silk_LSHIFT32((opus_int32)C0_64, -rshifts ); } + CAb[ 0 ] = CAf[ 0 ] = C0 + silk_SMMUL( SILK_FIX_CONST( FIND_LPC_COND_FAC, 32 ), C0 ) + 1; /* Q(-rshifts) */ silk_memset( C_first_row, 0, SILK_MAX_ORDER_LPC * sizeof( opus_int32 ) ); if( rshifts > 0 ) { @@ -91,7 +84,7 @@ void silk_burg_modified( x_ptr = x + s * subfr_length; for( n = 1; n < D + 1; n++ ) { C_first_row[ n - 1 ] += (opus_int32)silk_RSHIFT64( - silk_inner_prod16_aligned_64( x_ptr, x_ptr + n, subfr_length - n ), rshifts ); + silk_inner_prod16_aligned_64( x_ptr, x_ptr + n, subfr_length - n, arch ), rshifts ); } } } else { @@ -252,12 +245,12 @@ void silk_burg_modified( if( rshifts > 0 ) { for( s = 0; s < nb_subfr; s++ ) { x_ptr = x + s * subfr_length; - C0 -= (opus_int32)silk_RSHIFT64( silk_inner_prod16_aligned_64( x_ptr, x_ptr, D ), rshifts ); + C0 -= (opus_int32)silk_RSHIFT64( silk_inner_prod16_aligned_64( x_ptr, x_ptr, D, arch ), rshifts ); } } else { for( s = 0; s < nb_subfr; s++ ) { x_ptr = x + s * subfr_length; - C0 -= silk_LSHIFT32( silk_inner_prod_aligned( x_ptr, x_ptr, D ), -rshifts ); + C0 -= silk_LSHIFT32( silk_inner_prod_aligned( x_ptr, x_ptr, D, arch), -rshifts); } } /* Approximate residual energy */ diff --git a/drivers/opus/silk/fixed/corrMatrix_FIX.c b/drivers/opus/silk/fixed/corrMatrix_FIX.c index 9f50153dcc..ac5331fe57 100644 --- a/drivers/opus/silk/fixed/corrMatrix_FIX.c +++ b/drivers/opus/silk/fixed/corrMatrix_FIX.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif /********************************************************************** * Correlation Matrix Computations for LS estimate. @@ -42,7 +39,8 @@ void silk_corrVector_FIX( const opus_int L, /* I Length of vectors */ const opus_int order, /* I Max lag for correlation */ opus_int32 *Xt, /* O Pointer to X'*t correlation vector [order] */ - const opus_int rshifts /* I Right shifts of correlations */ + const opus_int rshifts, /* I Right shifts of correlations */ + int arch /* I Run-time architecture */ ) { opus_int lag, i; @@ -65,7 +63,7 @@ void silk_corrVector_FIX( } else { silk_assert( rshifts == 0 ); for( lag = 0; lag < order; lag++ ) { - Xt[ lag ] = silk_inner_prod_aligned( ptr1, ptr2, L ); /* X[:,lag]'*t */ + Xt[ lag ] = silk_inner_prod_aligned( ptr1, ptr2, L, arch ); /* X[:,lag]'*t */ ptr1--; /* Go to next column of X */ } } @@ -78,7 +76,8 @@ void silk_corrMatrix_FIX( const opus_int order, /* I Max lag for correlation */ const opus_int head_room, /* I Desired headroom */ opus_int32 *XX, /* O Pointer to X'*X correlation matrix [ order x order ] */ - opus_int *rshifts /* I/O Right shifts of correlations */ + opus_int *rshifts, /* I/O Right shifts of correlations */ + int arch /* I Run-time architecture */ ) { opus_int i, j, lag, rshifts_local, head_room_rshifts; @@ -138,7 +137,7 @@ void silk_corrMatrix_FIX( } else { for( lag = 1; lag < order; lag++ ) { /* Inner product of column 0 and column lag: X[:,0]'*X[:,lag] */ - energy = silk_inner_prod_aligned( ptr1, ptr2, L ); + energy = silk_inner_prod_aligned( ptr1, ptr2, L, arch ); matrix_ptr( XX, lag, 0, order ) = energy; matrix_ptr( XX, 0, lag, order ) = energy; /* Calculate remaining off diagonal: X[:,j]'*X[:,j + lag] */ diff --git a/drivers/opus/silk/fixed/encode_frame_FIX.c b/drivers/opus/silk/fixed/encode_frame_FIX.c index 27944729f8..e4ead0afef 100644 --- a/drivers/opus/silk/fixed/encode_frame_FIX.c +++ b/drivers/opus/silk/fixed/encode_frame_FIX.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/fixed/main_FIX.h" #include "opus/celt/stack_alloc.h" @@ -48,7 +45,7 @@ void silk_encode_do_VAD_FIX( /****************************/ /* Voice Activity Detection */ /****************************/ - silk_VAD_GetSA_Q8( &psEnc->sCmn, psEnc->sCmn.inputBuf + 1 ); + silk_VAD_GetSA_Q8( &psEnc->sCmn, psEnc->sCmn.inputBuf + 1, psEnc->sCmn.arch ); /**************************************************/ /* Convert speech activity into VAD and DTX flags */ @@ -196,11 +193,13 @@ opus_int silk_encode_frame_FIX( if( psEnc->sCmn.nStatesDelayedDecision > 1 || psEnc->sCmn.warping_Q16 > 0 ) { silk_NSQ_del_dec( &psEnc->sCmn, &psEnc->sCmn.sNSQ, &psEnc->sCmn.indices, xfw_Q3, psEnc->sCmn.pulses, sEncCtrl.PredCoef_Q12[ 0 ], sEncCtrl.LTPCoef_Q14, sEncCtrl.AR2_Q13, sEncCtrl.HarmShapeGain_Q14, - sEncCtrl.Tilt_Q14, sEncCtrl.LF_shp_Q14, sEncCtrl.Gains_Q16, sEncCtrl.pitchL, sEncCtrl.Lambda_Q10, sEncCtrl.LTP_scale_Q14 ); + sEncCtrl.Tilt_Q14, sEncCtrl.LF_shp_Q14, sEncCtrl.Gains_Q16, sEncCtrl.pitchL, sEncCtrl.Lambda_Q10, sEncCtrl.LTP_scale_Q14, + psEnc->sCmn.arch ); } else { silk_NSQ( &psEnc->sCmn, &psEnc->sCmn.sNSQ, &psEnc->sCmn.indices, xfw_Q3, psEnc->sCmn.pulses, sEncCtrl.PredCoef_Q12[ 0 ], sEncCtrl.LTPCoef_Q14, sEncCtrl.AR2_Q13, sEncCtrl.HarmShapeGain_Q14, - sEncCtrl.Tilt_Q14, sEncCtrl.LF_shp_Q14, sEncCtrl.Gains_Q16, sEncCtrl.pitchL, sEncCtrl.Lambda_Q10, sEncCtrl.LTP_scale_Q14 ); + sEncCtrl.Tilt_Q14, sEncCtrl.LF_shp_Q14, sEncCtrl.Gains_Q16, sEncCtrl.pitchL, sEncCtrl.Lambda_Q10, sEncCtrl.LTP_scale_Q14, + psEnc->sCmn.arch); } /****************************************/ @@ -287,7 +286,7 @@ opus_int silk_encode_frame_FIX( for( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) { sEncCtrl.Gains_Q16[ i ] = silk_LSHIFT_SAT32( silk_SMULWB( sEncCtrl.GainsUnq_Q16[ i ], gainMult_Q8 ), 8 ); } - + /* Quantize gains */ psEnc->sShape.LastGainIndex = sEncCtrl.lastGainIndexPrev; silk_gains_quant( psEnc->sCmn.indices.GainsIndices, sEncCtrl.Gains_Q16, @@ -371,12 +370,12 @@ static OPUS_INLINE void silk_LBRR_encode_FIX( silk_NSQ_del_dec( &psEnc->sCmn, &sNSQ_LBRR, psIndices_LBRR, xfw_Q3, psEnc->sCmn.pulses_LBRR[ psEnc->sCmn.nFramesEncoded ], psEncCtrl->PredCoef_Q12[ 0 ], psEncCtrl->LTPCoef_Q14, psEncCtrl->AR2_Q13, psEncCtrl->HarmShapeGain_Q14, psEncCtrl->Tilt_Q14, psEncCtrl->LF_shp_Q14, - psEncCtrl->Gains_Q16, psEncCtrl->pitchL, psEncCtrl->Lambda_Q10, psEncCtrl->LTP_scale_Q14 ); + psEncCtrl->Gains_Q16, psEncCtrl->pitchL, psEncCtrl->Lambda_Q10, psEncCtrl->LTP_scale_Q14, psEnc->sCmn.arch ); } else { silk_NSQ( &psEnc->sCmn, &sNSQ_LBRR, psIndices_LBRR, xfw_Q3, psEnc->sCmn.pulses_LBRR[ psEnc->sCmn.nFramesEncoded ], psEncCtrl->PredCoef_Q12[ 0 ], psEncCtrl->LTPCoef_Q14, psEncCtrl->AR2_Q13, psEncCtrl->HarmShapeGain_Q14, psEncCtrl->Tilt_Q14, psEncCtrl->LF_shp_Q14, - psEncCtrl->Gains_Q16, psEncCtrl->pitchL, psEncCtrl->Lambda_Q10, psEncCtrl->LTP_scale_Q14 ); + psEncCtrl->Gains_Q16, psEncCtrl->pitchL, psEncCtrl->Lambda_Q10, psEncCtrl->LTP_scale_Q14, psEnc->sCmn.arch ); } /* Restore original gains */ diff --git a/drivers/opus/silk/fixed/find_LPC_FIX.c b/drivers/opus/silk/fixed/find_LPC_FIX.c index df76e17ca2..5b56c41702 100644 --- a/drivers/opus/silk/fixed/find_LPC_FIX.c +++ b/drivers/opus/silk/fixed/find_LPC_FIX.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/fixed/main_FIX.h" #include "opus/celt/stack_alloc.h" @@ -95,7 +92,7 @@ void silk_find_LPC_FIX( silk_NLSF2A( a_tmp_Q12, NLSF0_Q15, psEncC->predictLPCOrder ); /* Calculate residual energy with NLSF interpolation */ - silk_LPC_analysis_filter( LPC_res, x, a_tmp_Q12, 2 * subfr_length, psEncC->predictLPCOrder ); + silk_LPC_analysis_filter( LPC_res, x, a_tmp_Q12, 2 * subfr_length, psEncC->predictLPCOrder, psEncC->arch ); silk_sum_sqr_shift( &res_nrg0, &rshift0, LPC_res + psEncC->predictLPCOrder, subfr_length - psEncC->predictLPCOrder ); silk_sum_sqr_shift( &res_nrg1, &rshift1, LPC_res + psEncC->predictLPCOrder + subfr_length, subfr_length - psEncC->predictLPCOrder ); diff --git a/drivers/opus/silk/fixed/find_LTP_FIX.c b/drivers/opus/silk/fixed/find_LTP_FIX.c index d556371ffa..a5a253516d 100644 --- a/drivers/opus/silk/fixed/find_LTP_FIX.c +++ b/drivers/opus/silk/fixed/find_LTP_FIX.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/fixed/main_FIX.h" #include "opus/silk/tuning_parameters.h" @@ -50,7 +47,8 @@ void silk_find_LTP_FIX( const opus_int subfr_length, /* I subframe length */ const opus_int nb_subfr, /* I number of subframes */ const opus_int mem_offset, /* I number of samples in LTP memory */ - opus_int corr_rshifts[ MAX_NB_SUBFR ] /* O right shifts applied to correlations */ + opus_int corr_rshifts[ MAX_NB_SUBFR ], /* O right shifts applied to correlations */ + int arch /* I Run-time architecture */ ) { opus_int i, k, lshift; @@ -84,10 +82,10 @@ void silk_find_LTP_FIX( rr_shifts += ( LTP_CORRS_HEAD_ROOM - LZs ); } corr_rshifts[ k ] = rr_shifts; - silk_corrMatrix_FIX( lag_ptr, subfr_length, LTP_ORDER, LTP_CORRS_HEAD_ROOM, WLTP_ptr, &corr_rshifts[ k ] ); /* WLTP_fix_ptr in Q( -corr_rshifts[ k ] ) */ + silk_corrMatrix_FIX( lag_ptr, subfr_length, LTP_ORDER, LTP_CORRS_HEAD_ROOM, WLTP_ptr, &corr_rshifts[ k ], arch ); /* WLTP_fix_ptr in Q( -corr_rshifts[ k ] ) */ /* The correlation vector always has lower max abs value than rr and/or RR so head room is assured */ - silk_corrVector_FIX( lag_ptr, r_ptr, subfr_length, LTP_ORDER, Rr, corr_rshifts[ k ] ); /* Rr_fix_ptr in Q( -corr_rshifts[ k ] ) */ + silk_corrVector_FIX( lag_ptr, r_ptr, subfr_length, LTP_ORDER, Rr, corr_rshifts[ k ], arch ); /* Rr_fix_ptr in Q( -corr_rshifts[ k ] ) */ if( corr_rshifts[ k ] > rr_shifts ) { rr[ k ] = silk_RSHIFT( rr[ k ], corr_rshifts[ k ] - rr_shifts ); /* rr[ k ] in Q( -corr_rshifts[ k ] ) */ } diff --git a/drivers/opus/silk/fixed/find_pitch_lags_FIX.c b/drivers/opus/silk/fixed/find_pitch_lags_FIX.c index 0d00b3edf6..bfd2c1b2d2 100644 --- a/drivers/opus/silk/fixed/find_pitch_lags_FIX.c +++ b/drivers/opus/silk/fixed/find_pitch_lags_FIX.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/fixed/main_FIX.h" #include "opus/celt/stack_alloc.h" @@ -112,7 +109,7 @@ void silk_find_pitch_lags_FIX( /*****************************************/ /* LPC analysis filtering */ /*****************************************/ - silk_LPC_analysis_filter( res, x_buf, A_Q12, buf_len, psEnc->sCmn.pitchEstimationLPCOrder ); + silk_LPC_analysis_filter( res, x_buf, A_Q12, buf_len, psEnc->sCmn.pitchEstimationLPCOrder, psEnc->sCmn.arch ); if( psEnc->sCmn.indices.signalType != TYPE_NO_VOICE_ACTIVITY && psEnc->sCmn.first_frame_after_reset == 0 ) { /* Threshold for pitch estimator */ diff --git a/drivers/opus/silk/fixed/find_pred_coefs_FIX.c b/drivers/opus/silk/fixed/find_pred_coefs_FIX.c index 93b506b523..d0280963bd 100644 --- a/drivers/opus/silk/fixed/find_pred_coefs_FIX.c +++ b/drivers/opus/silk/fixed/find_pred_coefs_FIX.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/fixed/main_FIX.h" #include "opus/celt/stack_alloc.h" @@ -89,11 +86,12 @@ void silk_find_pred_coefs_FIX( /* LTP analysis */ silk_find_LTP_FIX( psEncCtrl->LTPCoef_Q14, WLTP, &psEncCtrl->LTPredCodGain_Q7, res_pitch, psEncCtrl->pitchL, Wght_Q15, psEnc->sCmn.subfr_length, - psEnc->sCmn.nb_subfr, psEnc->sCmn.ltp_mem_length, LTP_corrs_rshift ); + psEnc->sCmn.nb_subfr, psEnc->sCmn.ltp_mem_length, LTP_corrs_rshift, psEnc->sCmn.arch ); /* Quantize LTP gain parameters */ silk_quant_LTP_gains( psEncCtrl->LTPCoef_Q14, psEnc->sCmn.indices.LTPIndex, &psEnc->sCmn.indices.PERIndex, - &psEnc->sCmn.sum_log_gain_Q7, WLTP, psEnc->sCmn.mu_LTP_Q9, psEnc->sCmn.LTPQuantLowComplexity, psEnc->sCmn.nb_subfr); + &psEnc->sCmn.sum_log_gain_Q7, WLTP, psEnc->sCmn.mu_LTP_Q9, psEnc->sCmn.LTPQuantLowComplexity, psEnc->sCmn.nb_subfr, + psEnc->sCmn.arch); /* Control LTP scaling */ silk_LTP_scale_ctrl_FIX( psEnc, psEncCtrl, condCoding ); @@ -118,16 +116,16 @@ void silk_find_pred_coefs_FIX( silk_memset( psEncCtrl->LTPCoef_Q14, 0, psEnc->sCmn.nb_subfr * LTP_ORDER * sizeof( opus_int16 ) ); psEncCtrl->LTPredCodGain_Q7 = 0; - psEnc->sCmn.sum_log_gain_Q7 = 0; + psEnc->sCmn.sum_log_gain_Q7 = 0; } /* Limit on total predictive coding gain */ if( psEnc->sCmn.first_frame_after_reset ) { minInvGain_Q30 = SILK_FIX_CONST( 1.0f / MAX_PREDICTION_POWER_GAIN_AFTER_RESET, 30 ); - } else { + } else { minInvGain_Q30 = silk_log2lin( silk_SMLAWB( 16 << 7, (opus_int32)psEncCtrl->LTPredCodGain_Q7, SILK_FIX_CONST( 1.0 / 3, 16 ) ) ); /* Q16 */ - minInvGain_Q30 = silk_DIV32_varQ( minInvGain_Q30, - silk_SMULWW( SILK_FIX_CONST( MAX_PREDICTION_POWER_GAIN, 0 ), + minInvGain_Q30 = silk_DIV32_varQ( minInvGain_Q30, + silk_SMULWW( SILK_FIX_CONST( MAX_PREDICTION_POWER_GAIN, 0 ), silk_SMLAWB( SILK_FIX_CONST( 0.25, 18 ), SILK_FIX_CONST( 0.75, 18 ), psEncCtrl->coding_quality_Q14 ) ), 14 ); } @@ -139,7 +137,7 @@ void silk_find_pred_coefs_FIX( /* Calculate residual energy using quantized LPC coefficients */ silk_residual_energy_FIX( psEncCtrl->ResNrg, psEncCtrl->ResNrgQ, LPC_in_pre, psEncCtrl->PredCoef_Q12, local_gains, - psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr, psEnc->sCmn.predictLPCOrder ); + psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr, psEnc->sCmn.predictLPCOrder, psEnc->sCmn.arch ); /* Copy to prediction struct for use in next frame for interpolation */ silk_memcpy( psEnc->sCmn.prev_NLSFq_Q15, NLSF_Q15, sizeof( psEnc->sCmn.prev_NLSFq_Q15 ) ); diff --git a/drivers/opus/silk/fixed/k2a_FIX.c b/drivers/opus/silk/fixed/k2a_FIX.c index 7d5808f190..64771f370c 100644 --- a/drivers/opus/silk/fixed/k2a_FIX.c +++ b/drivers/opus/silk/fixed/k2a_FIX.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/SigProc_FIX.h" diff --git a/drivers/opus/silk/fixed/k2a_Q16_FIX.c b/drivers/opus/silk/fixed/k2a_Q16_FIX.c index 8df61dc3f6..49d90a862e 100644 --- a/drivers/opus/silk/fixed/k2a_Q16_FIX.c +++ b/drivers/opus/silk/fixed/k2a_Q16_FIX.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/SigProc_FIX.h" diff --git a/drivers/opus/silk/fixed/main_FIX.h b/drivers/opus/silk/fixed/main_FIX.h index 71a560ef0e..f824c47653 100644 --- a/drivers/opus/silk/fixed/main_FIX.h +++ b/drivers/opus/silk/fixed/main_FIX.h @@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "opus/silk/SigProc_FIX.h" #include "opus/silk/fixed/structs_FIX.h" #include "opus/silk/control.h" -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" #include "opus/silk/PLC.h" #include "opus/silk/debug.h" #include "opus/celt/entenc.h" @@ -97,6 +97,17 @@ void silk_prefilter_FIX( const opus_int16 x[] /* I Speech signal */ ); +void silk_warped_LPC_analysis_filter_FIX_c( + opus_int32 state[], /* I/O State [order + 1] */ + opus_int32 res_Q2[], /* O Residual signal [length] */ + const opus_int16 coef_Q13[], /* I Coefficients [order] */ + const opus_int16 input[], /* I Input signal [length] */ + const opus_int16 lambda_Q16, /* I Warping factor */ + const opus_int length, /* I Length of input signal */ + const opus_int order /* I Filter order (even) */ +); + + /**************************/ /* Noise shaping analysis */ /**************************/ @@ -166,7 +177,8 @@ void silk_find_LTP_FIX( const opus_int subfr_length, /* I subframe length */ const opus_int nb_subfr, /* I number of subframes */ const opus_int mem_offset, /* I number of samples in LTP memory */ - opus_int corr_rshifts[ MAX_NB_SUBFR ] /* O right shifts applied to correlations */ + opus_int corr_rshifts[ MAX_NB_SUBFR ], /* O right shifts applied to correlations */ + int arch /* I Run-time architecture */ ); void silk_LTP_analysis_filter_FIX( @@ -190,7 +202,8 @@ void silk_residual_energy_FIX( const opus_int32 gains[ MAX_NB_SUBFR ], /* I Quantization gains */ const opus_int subfr_length, /* I Subframe length */ const opus_int nb_subfr, /* I Number of subframes */ - const opus_int LPC_order /* I LPC order */ + const opus_int LPC_order, /* I LPC order */ + int arch /* I Run-time architecture */ ); /* Residual energy: nrg = wxx - 2 * wXx * c + c' * wXX * c */ @@ -220,7 +233,8 @@ void silk_corrMatrix_FIX( const opus_int order, /* I Max lag for correlation */ const opus_int head_room, /* I Desired headroom */ opus_int32 *XX, /* O Pointer to X'*X correlation matrix [ order x order ] */ - opus_int *rshifts /* I/O Right shifts of correlations */ + opus_int *rshifts, /* I/O Right shifts of correlations */ + int arch /* I Run-time architecture */ ); /* Calculates correlation vector X'*t */ @@ -230,7 +244,8 @@ void silk_corrVector_FIX( const opus_int L, /* I Length of vectors */ const opus_int order, /* I Max lag for correlation */ opus_int32 *Xt, /* O Pointer to X'*t correlation vector [order] */ - const opus_int rshifts /* I Right shifts of correlations */ + const opus_int rshifts, /* I Right shifts of correlations */ + int arch /* I Run-time architecture */ ); /* Add noise to matrix diagonal */ diff --git a/drivers/opus/silk/fixed/mips/noise_shape_analysis_FIX_mipsr1.h b/drivers/opus/silk/fixed/mips/noise_shape_analysis_FIX_mipsr1.h new file mode 100644 index 0000000000..c30481e437 --- /dev/null +++ b/drivers/opus/silk/fixed/mips/noise_shape_analysis_FIX_mipsr1.h @@ -0,0 +1,336 @@ +/*********************************************************************** +Copyright (c) 2006-2011, Skype Limited. All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +- Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. +- Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. +- Neither the name of Internet Society, IETF or IETF Trust, nor the +names of specific contributors, may be used to endorse or promote +products derived from this software without specific prior written +permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +***********************************************************************/ + + +/**************************************************************/ +/* Compute noise shaping coefficients and initial gain values */ +/**************************************************************/ +#define OVERRIDE_silk_noise_shape_analysis_FIX + +void silk_noise_shape_analysis_FIX( + silk_encoder_state_FIX *psEnc, /* I/O Encoder state FIX */ + silk_encoder_control_FIX *psEncCtrl, /* I/O Encoder control FIX */ + const opus_int16 *pitch_res, /* I LPC residual from pitch analysis */ + const opus_int16 *x, /* I Input signal [ frame_length + la_shape ] */ + int arch /* I Run-time architecture */ +) +{ + silk_shape_state_FIX *psShapeSt = &psEnc->sShape; + opus_int k, i, nSamples, Qnrg, b_Q14, warping_Q16, scale = 0; + opus_int32 SNR_adj_dB_Q7, HarmBoost_Q16, HarmShapeGain_Q16, Tilt_Q16, tmp32; + opus_int32 nrg, pre_nrg_Q30, log_energy_Q7, log_energy_prev_Q7, energy_variation_Q7; + opus_int32 delta_Q16, BWExp1_Q16, BWExp2_Q16, gain_mult_Q16, gain_add_Q16, strength_Q16, b_Q8; + opus_int32 auto_corr[ MAX_SHAPE_LPC_ORDER + 1 ]; + opus_int32 refl_coef_Q16[ MAX_SHAPE_LPC_ORDER ]; + opus_int32 AR1_Q24[ MAX_SHAPE_LPC_ORDER ]; + opus_int32 AR2_Q24[ MAX_SHAPE_LPC_ORDER ]; + VARDECL( opus_int16, x_windowed ); + const opus_int16 *x_ptr, *pitch_res_ptr; + SAVE_STACK; + + /* Point to start of first LPC analysis block */ + x_ptr = x - psEnc->sCmn.la_shape; + + /****************/ + /* GAIN CONTROL */ + /****************/ + SNR_adj_dB_Q7 = psEnc->sCmn.SNR_dB_Q7; + + /* Input quality is the average of the quality in the lowest two VAD bands */ + psEncCtrl->input_quality_Q14 = ( opus_int )silk_RSHIFT( (opus_int32)psEnc->sCmn.input_quality_bands_Q15[ 0 ] + + psEnc->sCmn.input_quality_bands_Q15[ 1 ], 2 ); + + /* Coding quality level, between 0.0_Q0 and 1.0_Q0, but in Q14 */ + psEncCtrl->coding_quality_Q14 = silk_RSHIFT( silk_sigm_Q15( silk_RSHIFT_ROUND( SNR_adj_dB_Q7 - + SILK_FIX_CONST( 20.0, 7 ), 4 ) ), 1 ); + + /* Reduce coding SNR during low speech activity */ + if( psEnc->sCmn.useCBR == 0 ) { + b_Q8 = SILK_FIX_CONST( 1.0, 8 ) - psEnc->sCmn.speech_activity_Q8; + b_Q8 = silk_SMULWB( silk_LSHIFT( b_Q8, 8 ), b_Q8 ); + SNR_adj_dB_Q7 = silk_SMLAWB( SNR_adj_dB_Q7, + silk_SMULBB( SILK_FIX_CONST( -BG_SNR_DECR_dB, 7 ) >> ( 4 + 1 ), b_Q8 ), /* Q11*/ + silk_SMULWB( SILK_FIX_CONST( 1.0, 14 ) + psEncCtrl->input_quality_Q14, psEncCtrl->coding_quality_Q14 ) ); /* Q12*/ + } + + if( psEnc->sCmn.indices.signalType == TYPE_VOICED ) { + /* Reduce gains for periodic signals */ + SNR_adj_dB_Q7 = silk_SMLAWB( SNR_adj_dB_Q7, SILK_FIX_CONST( HARM_SNR_INCR_dB, 8 ), psEnc->LTPCorr_Q15 ); + } else { + /* For unvoiced signals and low-quality input, adjust the quality slower than SNR_dB setting */ + SNR_adj_dB_Q7 = silk_SMLAWB( SNR_adj_dB_Q7, + silk_SMLAWB( SILK_FIX_CONST( 6.0, 9 ), -SILK_FIX_CONST( 0.4, 18 ), psEnc->sCmn.SNR_dB_Q7 ), + SILK_FIX_CONST( 1.0, 14 ) - psEncCtrl->input_quality_Q14 ); + } + + /*************************/ + /* SPARSENESS PROCESSING */ + /*************************/ + /* Set quantizer offset */ + if( psEnc->sCmn.indices.signalType == TYPE_VOICED ) { + /* Initially set to 0; may be overruled in process_gains(..) */ + psEnc->sCmn.indices.quantOffsetType = 0; + psEncCtrl->sparseness_Q8 = 0; + } else { + /* Sparseness measure, based on relative fluctuations of energy per 2 milliseconds */ + nSamples = silk_LSHIFT( psEnc->sCmn.fs_kHz, 1 ); + energy_variation_Q7 = 0; + log_energy_prev_Q7 = 0; + pitch_res_ptr = pitch_res; + for( k = 0; k < silk_SMULBB( SUB_FRAME_LENGTH_MS, psEnc->sCmn.nb_subfr ) / 2; k++ ) { + silk_sum_sqr_shift( &nrg, &scale, pitch_res_ptr, nSamples ); + nrg += silk_RSHIFT( nSamples, scale ); /* Q(-scale)*/ + + log_energy_Q7 = silk_lin2log( nrg ); + if( k > 0 ) { + energy_variation_Q7 += silk_abs( log_energy_Q7 - log_energy_prev_Q7 ); + } + log_energy_prev_Q7 = log_energy_Q7; + pitch_res_ptr += nSamples; + } + + psEncCtrl->sparseness_Q8 = silk_RSHIFT( silk_sigm_Q15( silk_SMULWB( energy_variation_Q7 - + SILK_FIX_CONST( 5.0, 7 ), SILK_FIX_CONST( 0.1, 16 ) ) ), 7 ); + + /* Set quantization offset depending on sparseness measure */ + if( psEncCtrl->sparseness_Q8 > SILK_FIX_CONST( SPARSENESS_THRESHOLD_QNT_OFFSET, 8 ) ) { + psEnc->sCmn.indices.quantOffsetType = 0; + } else { + psEnc->sCmn.indices.quantOffsetType = 1; + } + + /* Increase coding SNR for sparse signals */ + SNR_adj_dB_Q7 = silk_SMLAWB( SNR_adj_dB_Q7, SILK_FIX_CONST( SPARSE_SNR_INCR_dB, 15 ), psEncCtrl->sparseness_Q8 - SILK_FIX_CONST( 0.5, 8 ) ); + } + + /*******************************/ + /* Control bandwidth expansion */ + /*******************************/ + /* More BWE for signals with high prediction gain */ + strength_Q16 = silk_SMULWB( psEncCtrl->predGain_Q16, SILK_FIX_CONST( FIND_PITCH_WHITE_NOISE_FRACTION, 16 ) ); + BWExp1_Q16 = BWExp2_Q16 = silk_DIV32_varQ( SILK_FIX_CONST( BANDWIDTH_EXPANSION, 16 ), + silk_SMLAWW( SILK_FIX_CONST( 1.0, 16 ), strength_Q16, strength_Q16 ), 16 ); + delta_Q16 = silk_SMULWB( SILK_FIX_CONST( 1.0, 16 ) - silk_SMULBB( 3, psEncCtrl->coding_quality_Q14 ), + SILK_FIX_CONST( LOW_RATE_BANDWIDTH_EXPANSION_DELTA, 16 ) ); + BWExp1_Q16 = silk_SUB32( BWExp1_Q16, delta_Q16 ); + BWExp2_Q16 = silk_ADD32( BWExp2_Q16, delta_Q16 ); + /* BWExp1 will be applied after BWExp2, so make it relative */ + BWExp1_Q16 = silk_DIV32_16( silk_LSHIFT( BWExp1_Q16, 14 ), silk_RSHIFT( BWExp2_Q16, 2 ) ); + + if( psEnc->sCmn.warping_Q16 > 0 ) { + /* Slightly more warping in analysis will move quantization noise up in frequency, where it's better masked */ + warping_Q16 = silk_SMLAWB( psEnc->sCmn.warping_Q16, (opus_int32)psEncCtrl->coding_quality_Q14, SILK_FIX_CONST( 0.01, 18 ) ); + } else { + warping_Q16 = 0; + } + + /********************************************/ + /* Compute noise shaping AR coefs and gains */ + /********************************************/ + ALLOC( x_windowed, psEnc->sCmn.shapeWinLength, opus_int16 ); + for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) { + /* Apply window: sine slope followed by flat part followed by cosine slope */ + opus_int shift, slope_part, flat_part; + flat_part = psEnc->sCmn.fs_kHz * 3; + slope_part = silk_RSHIFT( psEnc->sCmn.shapeWinLength - flat_part, 1 ); + + silk_apply_sine_window( x_windowed, x_ptr, 1, slope_part ); + shift = slope_part; + silk_memcpy( x_windowed + shift, x_ptr + shift, flat_part * sizeof(opus_int16) ); + shift += flat_part; + silk_apply_sine_window( x_windowed + shift, x_ptr + shift, 2, slope_part ); + + /* Update pointer: next LPC analysis block */ + x_ptr += psEnc->sCmn.subfr_length; + + if( psEnc->sCmn.warping_Q16 > 0 ) { + /* Calculate warped auto correlation */ + silk_warped_autocorrelation_FIX( auto_corr, &scale, x_windowed, warping_Q16, psEnc->sCmn.shapeWinLength, psEnc->sCmn.shapingLPCOrder ); + } else { + /* Calculate regular auto correlation */ + silk_autocorr( auto_corr, &scale, x_windowed, psEnc->sCmn.shapeWinLength, psEnc->sCmn.shapingLPCOrder + 1, arch ); + } + + /* Add white noise, as a fraction of energy */ + auto_corr[0] = silk_ADD32( auto_corr[0], silk_max_32( silk_SMULWB( silk_RSHIFT( auto_corr[ 0 ], 4 ), + SILK_FIX_CONST( SHAPE_WHITE_NOISE_FRACTION, 20 ) ), 1 ) ); + + /* Calculate the reflection coefficients using schur */ + nrg = silk_schur64( refl_coef_Q16, auto_corr, psEnc->sCmn.shapingLPCOrder ); + silk_assert( nrg >= 0 ); + + /* Convert reflection coefficients to prediction coefficients */ + silk_k2a_Q16( AR2_Q24, refl_coef_Q16, psEnc->sCmn.shapingLPCOrder ); + + Qnrg = -scale; /* range: -12...30*/ + silk_assert( Qnrg >= -12 ); + silk_assert( Qnrg <= 30 ); + + /* Make sure that Qnrg is an even number */ + if( Qnrg & 1 ) { + Qnrg -= 1; + nrg >>= 1; + } + + tmp32 = silk_SQRT_APPROX( nrg ); + Qnrg >>= 1; /* range: -6...15*/ + + psEncCtrl->Gains_Q16[ k ] = (silk_LSHIFT32( silk_LIMIT( (tmp32), silk_RSHIFT32( silk_int32_MIN, (16 - Qnrg) ), \ + silk_RSHIFT32( silk_int32_MAX, (16 - Qnrg) ) ), (16 - Qnrg) )); + + if( psEnc->sCmn.warping_Q16 > 0 ) { + /* Adjust gain for warping */ + gain_mult_Q16 = warped_gain( AR2_Q24, warping_Q16, psEnc->sCmn.shapingLPCOrder ); + silk_assert( psEncCtrl->Gains_Q16[ k ] >= 0 ); + if ( silk_SMULWW( silk_RSHIFT_ROUND( psEncCtrl->Gains_Q16[ k ], 1 ), gain_mult_Q16 ) >= ( silk_int32_MAX >> 1 ) ) { + psEncCtrl->Gains_Q16[ k ] = silk_int32_MAX; + } else { + psEncCtrl->Gains_Q16[ k ] = silk_SMULWW( psEncCtrl->Gains_Q16[ k ], gain_mult_Q16 ); + } + } + + /* Bandwidth expansion for synthesis filter shaping */ + silk_bwexpander_32( AR2_Q24, psEnc->sCmn.shapingLPCOrder, BWExp2_Q16 ); + + /* Compute noise shaping filter coefficients */ + silk_memcpy( AR1_Q24, AR2_Q24, psEnc->sCmn.shapingLPCOrder * sizeof( opus_int32 ) ); + + /* Bandwidth expansion for analysis filter shaping */ + silk_assert( BWExp1_Q16 <= SILK_FIX_CONST( 1.0, 16 ) ); + silk_bwexpander_32( AR1_Q24, psEnc->sCmn.shapingLPCOrder, BWExp1_Q16 ); + + /* Ratio of prediction gains, in energy domain */ + pre_nrg_Q30 = silk_LPC_inverse_pred_gain_Q24( AR2_Q24, psEnc->sCmn.shapingLPCOrder ); + nrg = silk_LPC_inverse_pred_gain_Q24( AR1_Q24, psEnc->sCmn.shapingLPCOrder ); + + /*psEncCtrl->GainsPre[ k ] = 1.0f - 0.7f * ( 1.0f - pre_nrg / nrg ) = 0.3f + 0.7f * pre_nrg / nrg;*/ + pre_nrg_Q30 = silk_LSHIFT32( silk_SMULWB( pre_nrg_Q30, SILK_FIX_CONST( 0.7, 15 ) ), 1 ); + psEncCtrl->GainsPre_Q14[ k ] = ( opus_int ) SILK_FIX_CONST( 0.3, 14 ) + silk_DIV32_varQ( pre_nrg_Q30, nrg, 14 ); + + /* Convert to monic warped prediction coefficients and limit absolute values */ + limit_warped_coefs( AR2_Q24, AR1_Q24, warping_Q16, SILK_FIX_CONST( 3.999, 24 ), psEnc->sCmn.shapingLPCOrder ); + + /* Convert from Q24 to Q13 and store in int16 */ + for( i = 0; i < psEnc->sCmn.shapingLPCOrder; i++ ) { + psEncCtrl->AR1_Q13[ k * MAX_SHAPE_LPC_ORDER + i ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( AR1_Q24[ i ], 11 ) ); + psEncCtrl->AR2_Q13[ k * MAX_SHAPE_LPC_ORDER + i ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( AR2_Q24[ i ], 11 ) ); + } + } + + /*****************/ + /* Gain tweaking */ + /*****************/ + /* Increase gains during low speech activity and put lower limit on gains */ + gain_mult_Q16 = silk_log2lin( -silk_SMLAWB( -SILK_FIX_CONST( 16.0, 7 ), SNR_adj_dB_Q7, SILK_FIX_CONST( 0.16, 16 ) ) ); + gain_add_Q16 = silk_log2lin( silk_SMLAWB( SILK_FIX_CONST( 16.0, 7 ), SILK_FIX_CONST( MIN_QGAIN_DB, 7 ), SILK_FIX_CONST( 0.16, 16 ) ) ); + silk_assert( gain_mult_Q16 > 0 ); + for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) { + psEncCtrl->Gains_Q16[ k ] = silk_SMULWW( psEncCtrl->Gains_Q16[ k ], gain_mult_Q16 ); + silk_assert( psEncCtrl->Gains_Q16[ k ] >= 0 ); + psEncCtrl->Gains_Q16[ k ] = silk_ADD_POS_SAT32( psEncCtrl->Gains_Q16[ k ], gain_add_Q16 ); + } + + gain_mult_Q16 = SILK_FIX_CONST( 1.0, 16 ) + silk_RSHIFT_ROUND( silk_MLA( SILK_FIX_CONST( INPUT_TILT, 26 ), + psEncCtrl->coding_quality_Q14, SILK_FIX_CONST( HIGH_RATE_INPUT_TILT, 12 ) ), 10 ); + for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) { + psEncCtrl->GainsPre_Q14[ k ] = silk_SMULWB( gain_mult_Q16, psEncCtrl->GainsPre_Q14[ k ] ); + } + + /************************************************/ + /* Control low-frequency shaping and noise tilt */ + /************************************************/ + /* Less low frequency shaping for noisy inputs */ + strength_Q16 = silk_MUL( SILK_FIX_CONST( LOW_FREQ_SHAPING, 4 ), silk_SMLAWB( SILK_FIX_CONST( 1.0, 12 ), + SILK_FIX_CONST( LOW_QUALITY_LOW_FREQ_SHAPING_DECR, 13 ), psEnc->sCmn.input_quality_bands_Q15[ 0 ] - SILK_FIX_CONST( 1.0, 15 ) ) ); + strength_Q16 = silk_RSHIFT( silk_MUL( strength_Q16, psEnc->sCmn.speech_activity_Q8 ), 8 ); + if( psEnc->sCmn.indices.signalType == TYPE_VOICED ) { + /* Reduce low frequencies quantization noise for periodic signals, depending on pitch lag */ + /*f = 400; freqz([1, -0.98 + 2e-4 * f], [1, -0.97 + 7e-4 * f], 2^12, Fs); axis([0, 1000, -10, 1])*/ + opus_int fs_kHz_inv = silk_DIV32_16( SILK_FIX_CONST( 0.2, 14 ), psEnc->sCmn.fs_kHz ); + for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) { + b_Q14 = fs_kHz_inv + silk_DIV32_16( SILK_FIX_CONST( 3.0, 14 ), psEncCtrl->pitchL[ k ] ); + /* Pack two coefficients in one int32 */ + psEncCtrl->LF_shp_Q14[ k ] = silk_LSHIFT( SILK_FIX_CONST( 1.0, 14 ) - b_Q14 - silk_SMULWB( strength_Q16, b_Q14 ), 16 ); + psEncCtrl->LF_shp_Q14[ k ] |= (opus_uint16)( b_Q14 - SILK_FIX_CONST( 1.0, 14 ) ); + } + silk_assert( SILK_FIX_CONST( HARM_HP_NOISE_COEF, 24 ) < SILK_FIX_CONST( 0.5, 24 ) ); /* Guarantees that second argument to SMULWB() is within range of an opus_int16*/ + Tilt_Q16 = - SILK_FIX_CONST( HP_NOISE_COEF, 16 ) - + silk_SMULWB( SILK_FIX_CONST( 1.0, 16 ) - SILK_FIX_CONST( HP_NOISE_COEF, 16 ), + silk_SMULWB( SILK_FIX_CONST( HARM_HP_NOISE_COEF, 24 ), psEnc->sCmn.speech_activity_Q8 ) ); + } else { + b_Q14 = silk_DIV32_16( 21299, psEnc->sCmn.fs_kHz ); /* 1.3_Q0 = 21299_Q14*/ + /* Pack two coefficients in one int32 */ + psEncCtrl->LF_shp_Q14[ 0 ] = silk_LSHIFT( SILK_FIX_CONST( 1.0, 14 ) - b_Q14 - + silk_SMULWB( strength_Q16, silk_SMULWB( SILK_FIX_CONST( 0.6, 16 ), b_Q14 ) ), 16 ); + psEncCtrl->LF_shp_Q14[ 0 ] |= (opus_uint16)( b_Q14 - SILK_FIX_CONST( 1.0, 14 ) ); + for( k = 1; k < psEnc->sCmn.nb_subfr; k++ ) { + psEncCtrl->LF_shp_Q14[ k ] = psEncCtrl->LF_shp_Q14[ 0 ]; + } + Tilt_Q16 = -SILK_FIX_CONST( HP_NOISE_COEF, 16 ); + } + + /****************************/ + /* HARMONIC SHAPING CONTROL */ + /****************************/ + /* Control boosting of harmonic frequencies */ + HarmBoost_Q16 = silk_SMULWB( silk_SMULWB( SILK_FIX_CONST( 1.0, 17 ) - silk_LSHIFT( psEncCtrl->coding_quality_Q14, 3 ), + psEnc->LTPCorr_Q15 ), SILK_FIX_CONST( LOW_RATE_HARMONIC_BOOST, 16 ) ); + + /* More harmonic boost for noisy input signals */ + HarmBoost_Q16 = silk_SMLAWB( HarmBoost_Q16, + SILK_FIX_CONST( 1.0, 16 ) - silk_LSHIFT( psEncCtrl->input_quality_Q14, 2 ), SILK_FIX_CONST( LOW_INPUT_QUALITY_HARMONIC_BOOST, 16 ) ); + + if( USE_HARM_SHAPING && psEnc->sCmn.indices.signalType == TYPE_VOICED ) { + /* More harmonic noise shaping for high bitrates or noisy input */ + HarmShapeGain_Q16 = silk_SMLAWB( SILK_FIX_CONST( HARMONIC_SHAPING, 16 ), + SILK_FIX_CONST( 1.0, 16 ) - silk_SMULWB( SILK_FIX_CONST( 1.0, 18 ) - silk_LSHIFT( psEncCtrl->coding_quality_Q14, 4 ), + psEncCtrl->input_quality_Q14 ), SILK_FIX_CONST( HIGH_RATE_OR_LOW_QUALITY_HARMONIC_SHAPING, 16 ) ); + + /* Less harmonic noise shaping for less periodic signals */ + HarmShapeGain_Q16 = silk_SMULWB( silk_LSHIFT( HarmShapeGain_Q16, 1 ), + silk_SQRT_APPROX( silk_LSHIFT( psEnc->LTPCorr_Q15, 15 ) ) ); + } else { + HarmShapeGain_Q16 = 0; + } + + /*************************/ + /* Smooth over subframes */ + /*************************/ + for( k = 0; k < MAX_NB_SUBFR; k++ ) { + psShapeSt->HarmBoost_smth_Q16 = + silk_SMLAWB( psShapeSt->HarmBoost_smth_Q16, HarmBoost_Q16 - psShapeSt->HarmBoost_smth_Q16, SILK_FIX_CONST( SUBFR_SMTH_COEF, 16 ) ); + psShapeSt->HarmShapeGain_smth_Q16 = + silk_SMLAWB( psShapeSt->HarmShapeGain_smth_Q16, HarmShapeGain_Q16 - psShapeSt->HarmShapeGain_smth_Q16, SILK_FIX_CONST( SUBFR_SMTH_COEF, 16 ) ); + psShapeSt->Tilt_smth_Q16 = + silk_SMLAWB( psShapeSt->Tilt_smth_Q16, Tilt_Q16 - psShapeSt->Tilt_smth_Q16, SILK_FIX_CONST( SUBFR_SMTH_COEF, 16 ) ); + + psEncCtrl->HarmBoost_Q14[ k ] = ( opus_int )silk_RSHIFT_ROUND( psShapeSt->HarmBoost_smth_Q16, 2 ); + psEncCtrl->HarmShapeGain_Q14[ k ] = ( opus_int )silk_RSHIFT_ROUND( psShapeSt->HarmShapeGain_smth_Q16, 2 ); + psEncCtrl->Tilt_Q14[ k ] = ( opus_int )silk_RSHIFT_ROUND( psShapeSt->Tilt_smth_Q16, 2 ); + } + RESTORE_STACK; +} diff --git a/drivers/opus/silk/fixed/mips/prefilter_FIX_mipsr1.h b/drivers/opus/silk/fixed/mips/prefilter_FIX_mipsr1.h new file mode 100644 index 0000000000..c7f04279a0 --- /dev/null +++ b/drivers/opus/silk/fixed/mips/prefilter_FIX_mipsr1.h @@ -0,0 +1,181 @@ +/*********************************************************************** +Copyright (c) 2006-2011, Skype Limited. All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +- Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. +- Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. +- Neither the name of Internet Society, IETF or IETF Trust, nor the +names of specific contributors, may be used to endorse or promote +products derived from this software without specific prior written +permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +***********************************************************************/ +#ifndef __PREFILTER_FIX_MIPSR1_H__ +#define __PREFILTER_FIX_MIPSR1_H__ +#include "opus/opus_config.h" + +#include "opus/silk/fixed/main_FIX.h" +#include "opus/celt/stack_alloc.h" +#include "opus/silk/tuning_parameters.h" + +#define OVERRIDE_silk_warped_LPC_analysis_filter_FIX +void silk_warped_LPC_analysis_filter_FIX( + opus_int32 state[], /* I/O State [order + 1] */ + opus_int32 res_Q2[], /* O Residual signal [length] */ + const opus_int16 coef_Q13[], /* I Coefficients [order] */ + const opus_int16 input[], /* I Input signal [length] */ + const opus_int16 lambda_Q16, /* I Warping factor */ + const opus_int length, /* I Length of input signal */ + const opus_int order, /* I Filter order (even) */ + int arch +) +{ + opus_int n, i; + opus_int32 acc_Q11, acc_Q22, tmp1, tmp2, tmp3, tmp4; + opus_int32 state_cur, state_next; + + (void)arch; + + /* Order must be even */ + /* Length must be even */ + + silk_assert( ( order & 1 ) == 0 ); + silk_assert( ( length & 1 ) == 0 ); + + for( n = 0; n < length; n+=2 ) { + /* Output of lowpass section */ + tmp2 = silk_SMLAWB( state[ 0 ], state[ 1 ], lambda_Q16 ); + state_cur = silk_LSHIFT( input[ n ], 14 ); + /* Output of allpass section */ + tmp1 = silk_SMLAWB( state[ 1 ], state[ 2 ] - tmp2, lambda_Q16 ); + state_next = tmp2; + acc_Q11 = silk_RSHIFT( order, 1 ); + acc_Q11 = silk_SMLAWB( acc_Q11, tmp2, coef_Q13[ 0 ] ); + + + /* Output of lowpass section */ + tmp4 = silk_SMLAWB( state_cur, state_next, lambda_Q16 ); + state[ 0 ] = silk_LSHIFT( input[ n+1 ], 14 ); + /* Output of allpass section */ + tmp3 = silk_SMLAWB( state_next, tmp1 - tmp4, lambda_Q16 ); + state[ 1 ] = tmp4; + acc_Q22 = silk_RSHIFT( order, 1 ); + acc_Q22 = silk_SMLAWB( acc_Q22, tmp4, coef_Q13[ 0 ] ); + + /* Loop over allpass sections */ + for( i = 2; i < order; i += 2 ) { + /* Output of allpass section */ + tmp2 = silk_SMLAWB( state[ i ], state[ i + 1 ] - tmp1, lambda_Q16 ); + state_cur = tmp1; + acc_Q11 = silk_SMLAWB( acc_Q11, tmp1, coef_Q13[ i - 1 ] ); + /* Output of allpass section */ + tmp1 = silk_SMLAWB( state[ i + 1 ], state[ i + 2 ] - tmp2, lambda_Q16 ); + state_next = tmp2; + acc_Q11 = silk_SMLAWB( acc_Q11, tmp2, coef_Q13[ i ] ); + + + /* Output of allpass section */ + tmp4 = silk_SMLAWB( state_cur, state_next - tmp3, lambda_Q16 ); + state[ i ] = tmp3; + acc_Q22 = silk_SMLAWB( acc_Q22, tmp3, coef_Q13[ i - 1 ] ); + /* Output of allpass section */ + tmp3 = silk_SMLAWB( state_next, tmp1 - tmp4, lambda_Q16 ); + state[ i + 1 ] = tmp4; + acc_Q22 = silk_SMLAWB( acc_Q22, tmp4, coef_Q13[ i ] ); + } + acc_Q11 = silk_SMLAWB( acc_Q11, tmp1, coef_Q13[ order - 1 ] ); + res_Q2[ n ] = silk_LSHIFT( (opus_int32)input[ n ], 2 ) - silk_RSHIFT_ROUND( acc_Q11, 9 ); + + state[ order ] = tmp3; + acc_Q22 = silk_SMLAWB( acc_Q22, tmp3, coef_Q13[ order - 1 ] ); + res_Q2[ n+1 ] = silk_LSHIFT( (opus_int32)input[ n+1 ], 2 ) - silk_RSHIFT_ROUND( acc_Q22, 9 ); + } +} + + + +/* Prefilter for finding Quantizer input signal */ +#define OVERRIDE_silk_prefilt_FIX +static inline void silk_prefilt_FIX( + silk_prefilter_state_FIX *P, /* I/O state */ + opus_int32 st_res_Q12[], /* I short term residual signal */ + opus_int32 xw_Q3[], /* O prefiltered signal */ + opus_int32 HarmShapeFIRPacked_Q12, /* I Harmonic shaping coeficients */ + opus_int Tilt_Q14, /* I Tilt shaping coeficient */ + opus_int32 LF_shp_Q14, /* I Low-frequancy shaping coeficients */ + opus_int lag, /* I Lag for harmonic shaping */ + opus_int length /* I Length of signals */ +) +{ + opus_int i, idx, LTP_shp_buf_idx; + opus_int32 n_LTP_Q12, n_Tilt_Q10, n_LF_Q10; + opus_int32 sLF_MA_shp_Q12, sLF_AR_shp_Q12; + opus_int16 *LTP_shp_buf; + + /* To speed up use temp variables instead of using the struct */ + LTP_shp_buf = P->sLTP_shp; + LTP_shp_buf_idx = P->sLTP_shp_buf_idx; + sLF_AR_shp_Q12 = P->sLF_AR_shp_Q12; + sLF_MA_shp_Q12 = P->sLF_MA_shp_Q12; + + if( lag > 0 ) { + for( i = 0; i < length; i++ ) { + /* unrolled loop */ + silk_assert( HARM_SHAPE_FIR_TAPS == 3 ); + idx = lag + LTP_shp_buf_idx; + n_LTP_Q12 = silk_SMULBB( LTP_shp_buf[ ( idx - HARM_SHAPE_FIR_TAPS / 2 - 1) & LTP_MASK ], HarmShapeFIRPacked_Q12 ); + n_LTP_Q12 = silk_SMLABT( n_LTP_Q12, LTP_shp_buf[ ( idx - HARM_SHAPE_FIR_TAPS / 2 ) & LTP_MASK ], HarmShapeFIRPacked_Q12 ); + n_LTP_Q12 = silk_SMLABB( n_LTP_Q12, LTP_shp_buf[ ( idx - HARM_SHAPE_FIR_TAPS / 2 + 1) & LTP_MASK ], HarmShapeFIRPacked_Q12 ); + + n_Tilt_Q10 = silk_SMULWB( sLF_AR_shp_Q12, Tilt_Q14 ); + n_LF_Q10 = silk_SMLAWB( silk_SMULWT( sLF_AR_shp_Q12, LF_shp_Q14 ), sLF_MA_shp_Q12, LF_shp_Q14 ); + + sLF_AR_shp_Q12 = silk_SUB32( st_res_Q12[ i ], silk_LSHIFT( n_Tilt_Q10, 2 ) ); + sLF_MA_shp_Q12 = silk_SUB32( sLF_AR_shp_Q12, silk_LSHIFT( n_LF_Q10, 2 ) ); + + LTP_shp_buf_idx = ( LTP_shp_buf_idx - 1 ) & LTP_MASK; + LTP_shp_buf[ LTP_shp_buf_idx ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( sLF_MA_shp_Q12, 12 ) ); + + xw_Q3[i] = silk_RSHIFT_ROUND( silk_SUB32( sLF_MA_shp_Q12, n_LTP_Q12 ), 9 ); + } + } + else + { + for( i = 0; i < length; i++ ) { + + n_LTP_Q12 = 0; + + n_Tilt_Q10 = silk_SMULWB( sLF_AR_shp_Q12, Tilt_Q14 ); + n_LF_Q10 = silk_SMLAWB( silk_SMULWT( sLF_AR_shp_Q12, LF_shp_Q14 ), sLF_MA_shp_Q12, LF_shp_Q14 ); + + sLF_AR_shp_Q12 = silk_SUB32( st_res_Q12[ i ], silk_LSHIFT( n_Tilt_Q10, 2 ) ); + sLF_MA_shp_Q12 = silk_SUB32( sLF_AR_shp_Q12, silk_LSHIFT( n_LF_Q10, 2 ) ); + + LTP_shp_buf_idx = ( LTP_shp_buf_idx - 1 ) & LTP_MASK; + LTP_shp_buf[ LTP_shp_buf_idx ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( sLF_MA_shp_Q12, 12 ) ); + + xw_Q3[i] = silk_RSHIFT_ROUND( sLF_MA_shp_Q12, 9 ); + } + } + + /* Copy temp variable back to state */ + P->sLF_AR_shp_Q12 = sLF_AR_shp_Q12; + P->sLF_MA_shp_Q12 = sLF_MA_shp_Q12; + P->sLTP_shp_buf_idx = LTP_shp_buf_idx; +} + +#endif /* __PREFILTER_FIX_MIPSR1_H__ */ diff --git a/drivers/opus/silk/fixed/mips/warped_autocorrelation_FIX_mipsr1.h b/drivers/opus/silk/fixed/mips/warped_autocorrelation_FIX_mipsr1.h new file mode 100644 index 0000000000..eba7711db7 --- /dev/null +++ b/drivers/opus/silk/fixed/mips/warped_autocorrelation_FIX_mipsr1.h @@ -0,0 +1,162 @@ +/*********************************************************************** +Copyright (c) 2006-2011, Skype Limited. All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +- Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. +- Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. +- Neither the name of Internet Society, IETF or IETF Trust, nor the +names of specific contributors, may be used to endorse or promote +products derived from this software without specific prior written +permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +***********************************************************************/ + +#ifndef __WARPED_AUTOCORRELATION_FIX_MIPSR1_H__ +#define __WARPED_AUTOCORRELATION_FIX_MIPSR1_H__ +#include "opus/opus_config.h" + +#include "opus/silk/fixed/main_FIX.h" + +#undef QC +#define QC 10 + +#undef QS +#define QS 14 + +/* Autocorrelations for a warped frequency axis */ +#define OVERRIDE_silk_warped_autocorrelation_FIX +void silk_warped_autocorrelation_FIX( + opus_int32 *corr, /* O Result [order + 1] */ + opus_int *scale, /* O Scaling of the correlation vector */ + const opus_int16 *input, /* I Input data to correlate */ + const opus_int warping_Q16, /* I Warping coefficient */ + const opus_int length, /* I Length of input */ + const opus_int order /* I Correlation order (even) */ +) +{ + opus_int n, i, lsh; + opus_int32 tmp1_QS=0, tmp2_QS=0, tmp3_QS=0, tmp4_QS=0, tmp5_QS=0, tmp6_QS=0, tmp7_QS=0, tmp8_QS=0, start_1=0, start_2=0, start_3=0; + opus_int32 state_QS[ MAX_SHAPE_LPC_ORDER + 1 ] = { 0 }; + opus_int64 corr_QC[ MAX_SHAPE_LPC_ORDER + 1 ] = { 0 }; + opus_int64 temp64; + + opus_int32 val; + val = 2 * QS - QC; + + /* Order must be even */ + silk_assert( ( order & 1 ) == 0 ); + silk_assert( 2 * QS - QC >= 0 ); + + /* Loop over samples */ + for( n = 0; n < length; n=n+4 ) { + + tmp1_QS = silk_LSHIFT32( (opus_int32)input[ n ], QS ); + start_1 = tmp1_QS; + tmp3_QS = silk_LSHIFT32( (opus_int32)input[ n+1], QS ); + start_2 = tmp3_QS; + tmp5_QS = silk_LSHIFT32( (opus_int32)input[ n+2], QS ); + start_3 = tmp5_QS; + tmp7_QS = silk_LSHIFT32( (opus_int32)input[ n+3], QS ); + + /* Loop over allpass sections */ + for( i = 0; i < order; i += 2 ) { + /* Output of allpass section */ + tmp2_QS = silk_SMLAWB( state_QS[ i ], state_QS[ i + 1 ] - tmp1_QS, warping_Q16 ); + corr_QC[ i ] = __builtin_mips_madd( corr_QC[ i ], tmp1_QS, start_1); + + tmp4_QS = silk_SMLAWB( tmp1_QS, tmp2_QS - tmp3_QS, warping_Q16 ); + corr_QC[ i ] = __builtin_mips_madd( corr_QC[ i ], tmp3_QS, start_2); + + tmp6_QS = silk_SMLAWB( tmp3_QS, tmp4_QS - tmp5_QS, warping_Q16 ); + corr_QC[ i ] = __builtin_mips_madd( corr_QC[ i ], tmp5_QS, start_3); + + tmp8_QS = silk_SMLAWB( tmp5_QS, tmp6_QS - tmp7_QS, warping_Q16 ); + state_QS[ i ] = tmp7_QS; + corr_QC[ i ] = __builtin_mips_madd( corr_QC[ i ], tmp7_QS, state_QS[0]); + + /* Output of allpass section */ + tmp1_QS = silk_SMLAWB( state_QS[ i + 1 ], state_QS[ i + 2 ] - tmp2_QS, warping_Q16 ); + corr_QC[ i+1 ] = __builtin_mips_madd( corr_QC[ i+1 ], tmp2_QS, start_1); + + tmp3_QS = silk_SMLAWB( tmp2_QS, tmp1_QS - tmp4_QS, warping_Q16 ); + corr_QC[ i+1 ] = __builtin_mips_madd( corr_QC[ i+1 ], tmp4_QS, start_2); + + tmp5_QS = silk_SMLAWB( tmp4_QS, tmp3_QS - tmp6_QS, warping_Q16 ); + corr_QC[ i+1 ] = __builtin_mips_madd( corr_QC[ i+1 ], tmp6_QS, start_3); + + tmp7_QS = silk_SMLAWB( tmp6_QS, tmp5_QS - tmp8_QS, warping_Q16 ); + state_QS[ i + 1 ] = tmp8_QS; + corr_QC[ i+1 ] = __builtin_mips_madd( corr_QC[ i+1 ], tmp8_QS, state_QS[ 0 ]); + + } + state_QS[ order ] = tmp7_QS; + + corr_QC[ order ] = __builtin_mips_madd( corr_QC[ order ], tmp1_QS, start_1); + corr_QC[ order ] = __builtin_mips_madd( corr_QC[ order ], tmp3_QS, start_2); + corr_QC[ order ] = __builtin_mips_madd( corr_QC[ order ], tmp5_QS, start_3); + corr_QC[ order ] = __builtin_mips_madd( corr_QC[ order ], tmp7_QS, state_QS[ 0 ]); + } + + for(;n< length; n++ ) { + + tmp1_QS = silk_LSHIFT32( (opus_int32)input[ n ], QS ); + + /* Loop over allpass sections */ + for( i = 0; i < order; i += 2 ) { + + /* Output of allpass section */ + tmp2_QS = silk_SMLAWB( state_QS[ i ], state_QS[ i + 1 ] - tmp1_QS, warping_Q16 ); + state_QS[ i ] = tmp1_QS; + corr_QC[ i ] = __builtin_mips_madd( corr_QC[ i ], tmp1_QS, state_QS[ 0 ]); + + /* Output of allpass section */ + tmp1_QS = silk_SMLAWB( state_QS[ i + 1 ], state_QS[ i + 2 ] - tmp2_QS, warping_Q16 ); + state_QS[ i + 1 ] = tmp2_QS; + corr_QC[ i+1 ] = __builtin_mips_madd( corr_QC[ i+1 ], tmp2_QS, state_QS[ 0 ]); + } + state_QS[ order ] = tmp1_QS; + corr_QC[ order ] = __builtin_mips_madd( corr_QC[ order ], tmp1_QS, state_QS[ 0 ]); + } + + temp64 = corr_QC[ 0 ]; + temp64 = __builtin_mips_shilo(temp64, val); + + lsh = silk_CLZ64( temp64 ) - 35; + lsh = silk_LIMIT( lsh, -12 - QC, 30 - QC ); + *scale = -( QC + lsh ); + silk_assert( *scale >= -30 && *scale <= 12 ); + if( lsh >= 0 ) { + for( i = 0; i < order + 1; i++ ) { + temp64 = corr_QC[ i ]; + //temp64 = __builtin_mips_shilo(temp64, val); + temp64 = (val >= 0) ? (temp64 >> val) : (temp64 << -val); + corr[ i ] = (opus_int32)silk_CHECK_FIT32( __builtin_mips_shilo( temp64, -lsh ) ); + } + } else { + for( i = 0; i < order + 1; i++ ) { + temp64 = corr_QC[ i ]; + //temp64 = __builtin_mips_shilo(temp64, val); + temp64 = (val >= 0) ? (temp64 >> val) : (temp64 << -val); + corr[ i ] = (opus_int32)silk_CHECK_FIT32( __builtin_mips_shilo( temp64, -lsh ) ); + } + } + + corr_QC[ 0 ] = __builtin_mips_shilo(corr_QC[ 0 ], val); + + silk_assert( corr_QC[ 0 ] >= 0 ); /* If breaking, decrease QC*/ +} +#endif /* __WARPED_AUTOCORRELATION_FIX_MIPSR1_H__ */ diff --git a/drivers/opus/silk/fixed/noise_shape_analysis_FIX.c b/drivers/opus/silk/fixed/noise_shape_analysis_FIX.c index 862640d2c8..6f1dc3ddd5 100644 --- a/drivers/opus/silk/fixed/noise_shape_analysis_FIX.c +++ b/drivers/opus/silk/fixed/noise_shape_analysis_FIX.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/fixed/main_FIX.h" #include "opus/celt/stack_alloc.h" @@ -138,9 +135,14 @@ static OPUS_INLINE void limit_warped_coefs( silk_assert( 0 ); } +#if defined(MIPSr1_ASM) +#include "opus/silk/fixed/mips/noise_shape_analysis_FIX_mipsr1.h" +#endif + /**************************************************************/ /* Compute noise shaping coefficients and initial gain values */ /**************************************************************/ +#ifndef OVERRIDE_silk_noise_shape_analysis_FIX void silk_noise_shape_analysis_FIX( silk_encoder_state_FIX *psEnc, /* I/O Encoder state FIX */ silk_encoder_control_FIX *psEncCtrl, /* I/O Encoder control FIX */ @@ -443,3 +445,4 @@ void silk_noise_shape_analysis_FIX( } RESTORE_STACK; } +#endif /* OVERRIDE_silk_noise_shape_analysis_FIX */ diff --git a/drivers/opus/silk/fixed/pitch_analysis_core_FIX.c b/drivers/opus/silk/fixed/pitch_analysis_core_FIX.c index 2acd51db6a..cf421c9612 100644 --- a/drivers/opus/silk/fixed/pitch_analysis_core_FIX.c +++ b/drivers/opus/silk/fixed/pitch_analysis_core_FIX.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif /*********************************************************** * Pitch analyser function @@ -72,7 +69,8 @@ static void silk_P_Ana_calc_energy_st3( opus_int start_lag, /* I lag offset to search around */ opus_int sf_length, /* I length of one 5 ms subframe */ opus_int nb_subfr, /* I number of subframes */ - opus_int complexity /* I Complexity setting */ + opus_int complexity, /* I Complexity setting */ + int arch /* I Run-time architecture */ ); /*************************************************************/ @@ -195,8 +193,8 @@ opus_int silk_pitch_analysis_core( /* O Voicing estimate: 0 /* Calculate first vector products before loop */ cross_corr = xcorr32[ MAX_LAG_4KHZ - MIN_LAG_4KHZ ]; - normalizer = silk_inner_prod_aligned( target_ptr, target_ptr, SF_LENGTH_8KHZ ); - normalizer = silk_ADD32( normalizer, silk_inner_prod_aligned( basis_ptr, basis_ptr, SF_LENGTH_8KHZ ) ); + normalizer = silk_inner_prod_aligned( target_ptr, target_ptr, SF_LENGTH_8KHZ, arch ); + normalizer = silk_ADD32( normalizer, silk_inner_prod_aligned( basis_ptr, basis_ptr, SF_LENGTH_8KHZ, arch ) ); normalizer = silk_ADD32( normalizer, silk_SMULBB( SF_LENGTH_8KHZ, 4000 ) ); matrix_ptr( C, k, 0, CSTRIDE_4KHZ ) = @@ -334,7 +332,7 @@ opus_int silk_pitch_analysis_core( /* O Voicing estimate: 0 silk_assert( target_ptr >= frame_8kHz ); silk_assert( target_ptr + SF_LENGTH_8KHZ <= frame_8kHz + frame_length_8kHz ); - energy_target = silk_ADD32( silk_inner_prod_aligned( target_ptr, target_ptr, SF_LENGTH_8KHZ ), 1 ); + energy_target = silk_ADD32( silk_inner_prod_aligned( target_ptr, target_ptr, SF_LENGTH_8KHZ, arch ), 1 ); for( j = 0; j < length_d_comp; j++ ) { d = d_comp[ j ]; basis_ptr = target_ptr - d; @@ -343,9 +341,9 @@ opus_int silk_pitch_analysis_core( /* O Voicing estimate: 0 silk_assert( basis_ptr >= frame_8kHz ); silk_assert( basis_ptr + SF_LENGTH_8KHZ <= frame_8kHz + frame_length_8kHz ); - cross_corr = silk_inner_prod_aligned( target_ptr, basis_ptr, SF_LENGTH_8KHZ ); + cross_corr = silk_inner_prod_aligned( target_ptr, basis_ptr, SF_LENGTH_8KHZ, arch ); if( cross_corr > 0 ) { - energy_basis = silk_inner_prod_aligned( basis_ptr, basis_ptr, SF_LENGTH_8KHZ ); + energy_basis = silk_inner_prod_aligned( basis_ptr, basis_ptr, SF_LENGTH_8KHZ, arch ); matrix_ptr( C, k, d - ( MIN_LAG_8KHZ - 2 ), CSTRIDE_8KHZ ) = (opus_int16)silk_DIV32_varQ( cross_corr, silk_ADD32( energy_target, @@ -519,14 +517,14 @@ opus_int silk_pitch_analysis_core( /* O Voicing estimate: 0 ALLOC( energies_st3, nb_subfr * nb_cbk_search, silk_pe_stage3_vals ); ALLOC( cross_corr_st3, nb_subfr * nb_cbk_search, silk_pe_stage3_vals ); silk_P_Ana_calc_corr_st3( cross_corr_st3, input_frame_ptr, start_lag, sf_length, nb_subfr, complexity, arch ); - silk_P_Ana_calc_energy_st3( energies_st3, input_frame_ptr, start_lag, sf_length, nb_subfr, complexity ); + silk_P_Ana_calc_energy_st3( energies_st3, input_frame_ptr, start_lag, sf_length, nb_subfr, complexity, arch ); lag_counter = 0; silk_assert( lag == silk_SAT16( lag ) ); contour_bias_Q15 = silk_DIV32_16( SILK_FIX_CONST( PE_FLATCONTOUR_BIAS, 15 ), lag ); target_ptr = &input_frame_ptr[ PE_LTP_MEM_LENGTH_MS * Fs_kHz ]; - energy_target = silk_ADD32( silk_inner_prod_aligned( target_ptr, target_ptr, nb_subfr * sf_length ), 1 ); + energy_target = silk_ADD32( silk_inner_prod_aligned( target_ptr, target_ptr, nb_subfr * sf_length, arch ), 1 ); for( d = start_lag; d <= end_lag; d++ ) { for( j = 0; j < nb_cbk_search; j++ ) { cross_corr = 0; @@ -671,7 +669,8 @@ static void silk_P_Ana_calc_energy_st3( opus_int start_lag, /* I lag offset to search around */ opus_int sf_length, /* I length of one 5 ms subframe */ opus_int nb_subfr, /* I number of subframes */ - opus_int complexity /* I Complexity setting */ + opus_int complexity, /* I Complexity setting */ + int arch /* I Run-time architecture */ ) { const opus_int16 *target_ptr, *basis_ptr; @@ -705,7 +704,7 @@ static void silk_P_Ana_calc_energy_st3( /* Calculate the energy for first lag */ basis_ptr = target_ptr - ( start_lag + matrix_ptr( Lag_range_ptr, k, 0, 2 ) ); - energy = silk_inner_prod_aligned( basis_ptr, basis_ptr, sf_length ); + energy = silk_inner_prod_aligned( basis_ptr, basis_ptr, sf_length, arch ); silk_assert( energy >= 0 ); scratch_mem[ lag_counter ] = energy; lag_counter++; diff --git a/drivers/opus/silk/fixed/prefilter_FIX.c b/drivers/opus/silk/fixed/prefilter_FIX.c index 195df3da75..344be2badd 100644 --- a/drivers/opus/silk/fixed/prefilter_FIX.c +++ b/drivers/opus/silk/fixed/prefilter_FIX.c @@ -24,15 +24,22 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/fixed/main_FIX.h" #include "opus/celt/stack_alloc.h" #include "opus/silk/tuning_parameters.h" +#if defined(MIPSr1_ASM) +#include "opus/silk/fixed/mips/prefilter_FIX_mipsr1.h" +#endif + + +#if !defined(OVERRIDE_silk_warped_LPC_analysis_filter_FIX) +#define silk_warped_LPC_analysis_filter_FIX(state, res_Q2, coef_Q13, input, lambda_Q16, length, order, arch) \ + ((void)(arch),silk_warped_LPC_analysis_filter_FIX_c(state, res_Q2, coef_Q13, input, lambda_Q16, length, order)) +#endif + /* Prefilter for finding Quantizer input signal */ static OPUS_INLINE void silk_prefilt_FIX( silk_prefilter_state_FIX *P, /* I/O state */ @@ -45,7 +52,7 @@ static OPUS_INLINE void silk_prefilt_FIX( opus_int length /* I Length of signals */ ); -void silk_warped_LPC_analysis_filter_FIX( +void silk_warped_LPC_analysis_filter_FIX_c( opus_int32 state[], /* I/O State [order + 1] */ opus_int32 res_Q2[], /* O Residual signal [length] */ const opus_int16 coef_Q13[], /* I Coefficients [order] */ @@ -130,7 +137,7 @@ void silk_prefilter_FIX( /* Short term FIR filtering*/ silk_warped_LPC_analysis_filter_FIX( P->sAR_shp, st_res_Q2, AR1_shp_Q13, px, - psEnc->sCmn.warping_Q16, psEnc->sCmn.subfr_length, psEnc->sCmn.shapingLPCOrder ); + psEnc->sCmn.warping_Q16, psEnc->sCmn.subfr_length, psEnc->sCmn.shapingLPCOrder, psEnc->sCmn.arch ); /* Reduce (mainly) low frequencies during harmonic emphasis */ B_Q10[ 0 ] = silk_RSHIFT_ROUND( psEncCtrl->GainsPre_Q14[ k ], 4 ); @@ -155,6 +162,7 @@ void silk_prefilter_FIX( RESTORE_STACK; } +#ifndef OVERRIDE_silk_prefilt_FIX /* Prefilter for finding Quantizer input signal */ static OPUS_INLINE void silk_prefilt_FIX( silk_prefilter_state_FIX *P, /* I/O state */ @@ -207,3 +215,4 @@ static OPUS_INLINE void silk_prefilt_FIX( P->sLF_MA_shp_Q12 = sLF_MA_shp_Q12; P->sLTP_shp_buf_idx = LTP_shp_buf_idx; } +#endif /* OVERRIDE_silk_prefilt_FIX */ diff --git a/drivers/opus/silk/fixed/process_gains_FIX.c b/drivers/opus/silk/fixed/process_gains_FIX.c index 2c501a2010..c0d591210b 100644 --- a/drivers/opus/silk/fixed/process_gains_FIX.c +++ b/drivers/opus/silk/fixed/process_gains_FIX.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/fixed/main_FIX.h" #include "opus/silk/tuning_parameters.h" diff --git a/drivers/opus/silk/fixed/regularize_correlations_FIX.c b/drivers/opus/silk/fixed/regularize_correlations_FIX.c index af34da68fa..c38a5589b6 100644 --- a/drivers/opus/silk/fixed/regularize_correlations_FIX.c +++ b/drivers/opus/silk/fixed/regularize_correlations_FIX.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/fixed/main_FIX.h" diff --git a/drivers/opus/silk/fixed/residual_energy16_FIX.c b/drivers/opus/silk/fixed/residual_energy16_FIX.c index 9b6e103a52..39bc96fd90 100644 --- a/drivers/opus/silk/fixed/residual_energy16_FIX.c +++ b/drivers/opus/silk/fixed/residual_energy16_FIX.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/fixed/main_FIX.h" diff --git a/drivers/opus/silk/fixed/residual_energy_FIX.c b/drivers/opus/silk/fixed/residual_energy_FIX.c index 468bfbab48..0e51f4baa1 100644 --- a/drivers/opus/silk/fixed/residual_energy_FIX.c +++ b/drivers/opus/silk/fixed/residual_energy_FIX.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/fixed/main_FIX.h" #include "opus/celt/stack_alloc.h" @@ -42,7 +39,8 @@ void silk_residual_energy_FIX( const opus_int32 gains[ MAX_NB_SUBFR ], /* I Quantization gains */ const opus_int subfr_length, /* I Subframe length */ const opus_int nb_subfr, /* I Number of subframes */ - const opus_int LPC_order /* I LPC order */ + const opus_int LPC_order, /* I LPC order */ + int arch /* I Run-time architecture */ ) { opus_int offset, i, j, rshift, lz1, lz2; @@ -60,7 +58,7 @@ void silk_residual_energy_FIX( silk_assert( ( nb_subfr >> 1 ) * ( MAX_NB_SUBFR >> 1 ) == nb_subfr ); for( i = 0; i < nb_subfr >> 1; i++ ) { /* Calculate half frame LPC residual signal including preceding samples */ - silk_LPC_analysis_filter( LPC_res, x_ptr, a_Q12[ i ], ( MAX_NB_SUBFR >> 1 ) * offset, LPC_order ); + silk_LPC_analysis_filter( LPC_res, x_ptr, a_Q12[ i ], ( MAX_NB_SUBFR >> 1 ) * offset, LPC_order, arch ); /* Point to first subframe of the just calculated LPC residual signal */ LPC_res_ptr = LPC_res + LPC_order; diff --git a/drivers/opus/silk/fixed/schur64_FIX.c b/drivers/opus/silk/fixed/schur64_FIX.c index fe1278e062..69ef76e028 100644 --- a/drivers/opus/silk/fixed/schur64_FIX.c +++ b/drivers/opus/silk/fixed/schur64_FIX.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/SigProc_FIX.h" diff --git a/drivers/opus/silk/fixed/schur_FIX.c b/drivers/opus/silk/fixed/schur_FIX.c index b0a36e5ad2..9effa59daf 100644 --- a/drivers/opus/silk/fixed/schur_FIX.c +++ b/drivers/opus/silk/fixed/schur_FIX.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/SigProc_FIX.h" diff --git a/drivers/opus/silk/fixed/solve_LS_FIX.c b/drivers/opus/silk/fixed/solve_LS_FIX.c index 6e8afaaa88..4ff97497be 100644 --- a/drivers/opus/silk/fixed/solve_LS_FIX.c +++ b/drivers/opus/silk/fixed/solve_LS_FIX.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/fixed/main_FIX.h" #include "opus/celt/stack_alloc.h" diff --git a/drivers/opus/silk/fixed/structs_FIX.h b/drivers/opus/silk/fixed/structs_FIX.h index 21eab05f0f..36ddff0a9e 100644 --- a/drivers/opus/silk/fixed/structs_FIX.h +++ b/drivers/opus/silk/fixed/structs_FIX.h @@ -29,7 +29,7 @@ POSSIBILITY OF SUCH DAMAGE. #define SILK_STRUCTS_FIX_H #include "opus/silk/typedef.h" -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" #include "opus/silk/structs.h" #ifdef __cplusplus @@ -116,6 +116,7 @@ typedef struct { typedef struct { silk_encoder_state_FIX state_Fxx[ ENCODER_NUM_CHANNELS ]; stereo_enc_state sStereo; + opus_int32 nBitsUsedLBRR; opus_int32 nBitsExceeded; opus_int nChannelsAPI; opus_int nChannelsInternal; diff --git a/drivers/opus/silk/fixed/vector_ops_FIX.c b/drivers/opus/silk/fixed/vector_ops_FIX.c index c2725194ec..1e8fdec0cb 100644 --- a/drivers/opus/silk/fixed/vector_ops_FIX.c +++ b/drivers/opus/silk/fixed/vector_ops_FIX.c @@ -24,12 +24,10 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/SigProc_FIX.h" +#include "opus/celt/pitch.h" /* Copy and multiply a vector by a constant */ void silk_scale_copy_vector16( @@ -70,18 +68,23 @@ void silk_scale_vector32_Q26_lshift_18( opus_int32 silk_inner_prod_aligned( const opus_int16 *const inVec1, /* I input vector 1 */ const opus_int16 *const inVec2, /* I input vector 2 */ - const opus_int len /* I vector lengths */ + const opus_int len, /* I vector lengths */ + int arch /* I Run-time architecture */ ) { +#ifdef OPUS_FIXED_POINT + return celt_inner_prod(inVec1, inVec2, len, arch); +#else opus_int i; opus_int32 sum = 0; for( i = 0; i < len; i++ ) { sum = silk_SMLABB( sum, inVec1[ i ], inVec2[ i ] ); } return sum; +#endif } -opus_int64 silk_inner_prod16_aligned_64( +opus_int64 silk_inner_prod16_aligned_64_c( const opus_int16 *inVec1, /* I input vector 1 */ const opus_int16 *inVec2, /* I input vector 2 */ const opus_int len /* I vector lengths */ diff --git a/drivers/opus/silk/fixed/warped_autocorrelation_FIX.c b/drivers/opus/silk/fixed/warped_autocorrelation_FIX.c index 4e5a7fee58..3b8d52d5c6 100644 --- a/drivers/opus/silk/fixed/warped_autocorrelation_FIX.c +++ b/drivers/opus/silk/fixed/warped_autocorrelation_FIX.c @@ -24,16 +24,19 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/fixed/main_FIX.h" #define QC 10 #define QS 14 +#if defined(MIPSr1_ASM) +#include "opus/silk/fixed/mips/warped_autocorrelation_FIX_mipsr1.h" +#endif + + +#ifndef OVERRIDE_silk_warped_autocorrelation_FIX /* Autocorrelations for a warped frequency axis */ void silk_warped_autocorrelation_FIX( opus_int32 *corr, /* O Result [order + 1] */ @@ -86,3 +89,4 @@ void silk_warped_autocorrelation_FIX( } silk_assert( corr_QC[ 0 ] >= 0 ); /* If breaking, decrease QC*/ } +#endif /* OVERRIDE_silk_warped_autocorrelation_FIX */ diff --git a/drivers/opus/silk/fixed/x86/burg_modified_FIX_sse.c b/drivers/opus/silk/fixed/x86/burg_modified_FIX_sse.c new file mode 100644 index 0000000000..f7d46487df --- /dev/null +++ b/drivers/opus/silk/fixed/x86/burg_modified_FIX_sse.c @@ -0,0 +1,372 @@ +/* Copyright (c) 2014, Cisco Systems, INC + Written by XiangMingZhu WeiZhou MinPeng YanWang + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#include "opus/opus_config.h" + +#include <xmmintrin.h> +#include <emmintrin.h> +#include <smmintrin.h> + +#include "opus/silk/SigProc_FIX.h" +#include "opus/silk/define.h" +#include "opus/silk/tuning_parameters.h" +#include "opus/celt/pitch.h" +#include "opus/celt/x86/x86cpu.h" + +#define MAX_FRAME_SIZE 384 /* subfr_length * nb_subfr = ( 0.005 * 16000 + 16 ) * 4 = 384 */ + +#define QA 25 +#define N_BITS_HEAD_ROOM 2 +#define MIN_RSHIFTS -16 +#define MAX_RSHIFTS (32 - QA) + +/* Compute reflection coefficients from input signal */ +void silk_burg_modified_sse4_1( + opus_int32 *res_nrg, /* O Residual energy */ + opus_int *res_nrg_Q, /* O Residual energy Q value */ + opus_int32 A_Q16[], /* O Prediction coefficients (length order) */ + const opus_int16 x[], /* I Input signal, length: nb_subfr * ( D + subfr_length ) */ + const opus_int32 minInvGain_Q30, /* I Inverse of max prediction gain */ + const opus_int subfr_length, /* I Input signal subframe length (incl. D preceding samples) */ + const opus_int nb_subfr, /* I Number of subframes stacked in x */ + const opus_int D, /* I Order */ + int arch /* I Run-time architecture */ +) +{ + opus_int k, n, s, lz, rshifts, rshifts_extra, reached_max_gain; + opus_int32 C0, num, nrg, rc_Q31, invGain_Q30, Atmp_QA, Atmp1, tmp1, tmp2, x1, x2; + const opus_int16 *x_ptr; + opus_int32 C_first_row[ SILK_MAX_ORDER_LPC ]; + opus_int32 C_last_row[ SILK_MAX_ORDER_LPC ]; + opus_int32 Af_QA[ SILK_MAX_ORDER_LPC ]; + opus_int32 CAf[ SILK_MAX_ORDER_LPC + 1 ]; + opus_int32 CAb[ SILK_MAX_ORDER_LPC + 1 ]; + opus_int32 xcorr[ SILK_MAX_ORDER_LPC ]; + + __m128i FIRST_3210, LAST_3210, ATMP_3210, TMP1_3210, TMP2_3210, T1_3210, T2_3210, PTR_3210, SUBFR_3210, X1_3210, X2_3210; + __m128i CONST1 = _mm_set1_epi32(1); + + silk_assert( subfr_length * nb_subfr <= MAX_FRAME_SIZE ); + + /* Compute autocorrelations, added over subframes */ + silk_sum_sqr_shift( &C0, &rshifts, x, nb_subfr * subfr_length ); + if( rshifts > MAX_RSHIFTS ) { + C0 = silk_LSHIFT32( C0, rshifts - MAX_RSHIFTS ); + silk_assert( C0 > 0 ); + rshifts = MAX_RSHIFTS; + } else { + lz = silk_CLZ32( C0 ) - 1; + rshifts_extra = N_BITS_HEAD_ROOM - lz; + if( rshifts_extra > 0 ) { + rshifts_extra = silk_min( rshifts_extra, MAX_RSHIFTS - rshifts ); + C0 = silk_RSHIFT32( C0, rshifts_extra ); + } else { + rshifts_extra = silk_max( rshifts_extra, MIN_RSHIFTS - rshifts ); + C0 = silk_LSHIFT32( C0, -rshifts_extra ); + } + rshifts += rshifts_extra; + } + CAb[ 0 ] = CAf[ 0 ] = C0 + silk_SMMUL( SILK_FIX_CONST( FIND_LPC_COND_FAC, 32 ), C0 ) + 1; /* Q(-rshifts) */ + silk_memset( C_first_row, 0, SILK_MAX_ORDER_LPC * sizeof( opus_int32 ) ); + if( rshifts > 0 ) { + for( s = 0; s < nb_subfr; s++ ) { + x_ptr = x + s * subfr_length; + for( n = 1; n < D + 1; n++ ) { + C_first_row[ n - 1 ] += (opus_int32)silk_RSHIFT64( + silk_inner_prod16_aligned_64( x_ptr, x_ptr + n, subfr_length - n, arch ), rshifts ); + } + } + } else { + for( s = 0; s < nb_subfr; s++ ) { + int i; + opus_int32 d; + x_ptr = x + s * subfr_length; + celt_pitch_xcorr(x_ptr, x_ptr + 1, xcorr, subfr_length - D, D, arch ); + for( n = 1; n < D + 1; n++ ) { + for ( i = n + subfr_length - D, d = 0; i < subfr_length; i++ ) + d = MAC16_16( d, x_ptr[ i ], x_ptr[ i - n ] ); + xcorr[ n - 1 ] += d; + } + for( n = 1; n < D + 1; n++ ) { + C_first_row[ n - 1 ] += silk_LSHIFT32( xcorr[ n - 1 ], -rshifts ); + } + } + } + silk_memcpy( C_last_row, C_first_row, SILK_MAX_ORDER_LPC * sizeof( opus_int32 ) ); + + /* Initialize */ + CAb[ 0 ] = CAf[ 0 ] = C0 + silk_SMMUL( SILK_FIX_CONST( FIND_LPC_COND_FAC, 32 ), C0 ) + 1; /* Q(-rshifts) */ + + invGain_Q30 = (opus_int32)1 << 30; + reached_max_gain = 0; + for( n = 0; n < D; n++ ) { + /* Update first row of correlation matrix (without first element) */ + /* Update last row of correlation matrix (without last element, stored in reversed order) */ + /* Update C * Af */ + /* Update C * flipud(Af) (stored in reversed order) */ + if( rshifts > -2 ) { + for( s = 0; s < nb_subfr; s++ ) { + x_ptr = x + s * subfr_length; + x1 = -silk_LSHIFT32( (opus_int32)x_ptr[ n ], 16 - rshifts ); /* Q(16-rshifts) */ + x2 = -silk_LSHIFT32( (opus_int32)x_ptr[ subfr_length - n - 1 ], 16 - rshifts ); /* Q(16-rshifts) */ + tmp1 = silk_LSHIFT32( (opus_int32)x_ptr[ n ], QA - 16 ); /* Q(QA-16) */ + tmp2 = silk_LSHIFT32( (opus_int32)x_ptr[ subfr_length - n - 1 ], QA - 16 ); /* Q(QA-16) */ + for( k = 0; k < n; k++ ) { + C_first_row[ k ] = silk_SMLAWB( C_first_row[ k ], x1, x_ptr[ n - k - 1 ] ); /* Q( -rshifts ) */ + C_last_row[ k ] = silk_SMLAWB( C_last_row[ k ], x2, x_ptr[ subfr_length - n + k ] ); /* Q( -rshifts ) */ + Atmp_QA = Af_QA[ k ]; + tmp1 = silk_SMLAWB( tmp1, Atmp_QA, x_ptr[ n - k - 1 ] ); /* Q(QA-16) */ + tmp2 = silk_SMLAWB( tmp2, Atmp_QA, x_ptr[ subfr_length - n + k ] ); /* Q(QA-16) */ + } + tmp1 = silk_LSHIFT32( -tmp1, 32 - QA - rshifts ); /* Q(16-rshifts) */ + tmp2 = silk_LSHIFT32( -tmp2, 32 - QA - rshifts ); /* Q(16-rshifts) */ + for( k = 0; k <= n; k++ ) { + CAf[ k ] = silk_SMLAWB( CAf[ k ], tmp1, x_ptr[ n - k ] ); /* Q( -rshift ) */ + CAb[ k ] = silk_SMLAWB( CAb[ k ], tmp2, x_ptr[ subfr_length - n + k - 1 ] ); /* Q( -rshift ) */ + } + } + } else { + for( s = 0; s < nb_subfr; s++ ) { + x_ptr = x + s * subfr_length; + x1 = -silk_LSHIFT32( (opus_int32)x_ptr[ n ], -rshifts ); /* Q( -rshifts ) */ + x2 = -silk_LSHIFT32( (opus_int32)x_ptr[ subfr_length - n - 1 ], -rshifts ); /* Q( -rshifts ) */ + tmp1 = silk_LSHIFT32( (opus_int32)x_ptr[ n ], 17 ); /* Q17 */ + tmp2 = silk_LSHIFT32( (opus_int32)x_ptr[ subfr_length - n - 1 ], 17 ); /* Q17 */ + + X1_3210 = _mm_set1_epi32( x1 ); + X2_3210 = _mm_set1_epi32( x2 ); + TMP1_3210 = _mm_setzero_si128(); + TMP2_3210 = _mm_setzero_si128(); + for( k = 0; k < n - 3; k += 4 ) { + PTR_3210 = OP_CVTEPI16_EPI32_M64( &x_ptr[ n - k - 1 - 3 ] ); + SUBFR_3210 = OP_CVTEPI16_EPI32_M64( &x_ptr[ subfr_length - n + k ] ); + FIRST_3210 = _mm_loadu_si128( (__m128i *)&C_first_row[ k ] ); + PTR_3210 = _mm_shuffle_epi32( PTR_3210, _MM_SHUFFLE( 0, 1, 2, 3 ) ); + LAST_3210 = _mm_loadu_si128( (__m128i *)&C_last_row[ k ] ); + ATMP_3210 = _mm_loadu_si128( (__m128i *)&Af_QA[ k ] ); + + T1_3210 = _mm_mullo_epi32( PTR_3210, X1_3210 ); + T2_3210 = _mm_mullo_epi32( SUBFR_3210, X2_3210 ); + + ATMP_3210 = _mm_srai_epi32( ATMP_3210, 7 ); + ATMP_3210 = _mm_add_epi32( ATMP_3210, CONST1 ); + ATMP_3210 = _mm_srai_epi32( ATMP_3210, 1 ); + + FIRST_3210 = _mm_add_epi32( FIRST_3210, T1_3210 ); + LAST_3210 = _mm_add_epi32( LAST_3210, T2_3210 ); + + PTR_3210 = _mm_mullo_epi32( ATMP_3210, PTR_3210 ); + SUBFR_3210 = _mm_mullo_epi32( ATMP_3210, SUBFR_3210 ); + + _mm_storeu_si128( (__m128i *)&C_first_row[ k ], FIRST_3210 ); + _mm_storeu_si128( (__m128i *)&C_last_row[ k ], LAST_3210 ); + + TMP1_3210 = _mm_add_epi32( TMP1_3210, PTR_3210 ); + TMP2_3210 = _mm_add_epi32( TMP2_3210, SUBFR_3210 ); + } + + TMP1_3210 = _mm_add_epi32( TMP1_3210, _mm_unpackhi_epi64(TMP1_3210, TMP1_3210 ) ); + TMP2_3210 = _mm_add_epi32( TMP2_3210, _mm_unpackhi_epi64(TMP2_3210, TMP2_3210 ) ); + TMP1_3210 = _mm_add_epi32( TMP1_3210, _mm_shufflelo_epi16(TMP1_3210, 0x0E ) ); + TMP2_3210 = _mm_add_epi32( TMP2_3210, _mm_shufflelo_epi16(TMP2_3210, 0x0E ) ); + + tmp1 += _mm_cvtsi128_si32( TMP1_3210 ); + tmp2 += _mm_cvtsi128_si32( TMP2_3210 ); + + for( ; k < n; k++ ) { + C_first_row[ k ] = silk_MLA( C_first_row[ k ], x1, x_ptr[ n - k - 1 ] ); /* Q( -rshifts ) */ + C_last_row[ k ] = silk_MLA( C_last_row[ k ], x2, x_ptr[ subfr_length - n + k ] ); /* Q( -rshifts ) */ + Atmp1 = silk_RSHIFT_ROUND( Af_QA[ k ], QA - 17 ); /* Q17 */ + tmp1 = silk_MLA( tmp1, x_ptr[ n - k - 1 ], Atmp1 ); /* Q17 */ + tmp2 = silk_MLA( tmp2, x_ptr[ subfr_length - n + k ], Atmp1 ); /* Q17 */ + } + + tmp1 = -tmp1; /* Q17 */ + tmp2 = -tmp2; /* Q17 */ + + { + __m128i xmm_tmp1, xmm_tmp2; + __m128i xmm_x_ptr_n_k_x2x0, xmm_x_ptr_n_k_x3x1; + __m128i xmm_x_ptr_sub_x2x0, xmm_x_ptr_sub_x3x1; + + xmm_tmp1 = _mm_set1_epi32( tmp1 ); + xmm_tmp2 = _mm_set1_epi32( tmp2 ); + + for( k = 0; k <= n - 3; k += 4 ) { + xmm_x_ptr_n_k_x2x0 = OP_CVTEPI16_EPI32_M64( &x_ptr[ n - k - 3 ] ); + xmm_x_ptr_sub_x2x0 = OP_CVTEPI16_EPI32_M64( &x_ptr[ subfr_length - n + k - 1 ] ); + + xmm_x_ptr_n_k_x2x0 = _mm_shuffle_epi32( xmm_x_ptr_n_k_x2x0, _MM_SHUFFLE( 0, 1, 2, 3 ) ); + + xmm_x_ptr_n_k_x2x0 = _mm_slli_epi32( xmm_x_ptr_n_k_x2x0, -rshifts - 1 ); + xmm_x_ptr_sub_x2x0 = _mm_slli_epi32( xmm_x_ptr_sub_x2x0, -rshifts - 1 ); + + /* equal shift right 4 bytes, xmm_x_ptr_n_k_x3x1 = _mm_srli_si128(xmm_x_ptr_n_k_x2x0, 4)*/ + xmm_x_ptr_n_k_x3x1 = _mm_shuffle_epi32( xmm_x_ptr_n_k_x2x0, _MM_SHUFFLE( 0, 3, 2, 1 ) ); + xmm_x_ptr_sub_x3x1 = _mm_shuffle_epi32( xmm_x_ptr_sub_x2x0, _MM_SHUFFLE( 0, 3, 2, 1 ) ); + + xmm_x_ptr_n_k_x2x0 = _mm_mul_epi32( xmm_x_ptr_n_k_x2x0, xmm_tmp1 ); + xmm_x_ptr_n_k_x3x1 = _mm_mul_epi32( xmm_x_ptr_n_k_x3x1, xmm_tmp1 ); + xmm_x_ptr_sub_x2x0 = _mm_mul_epi32( xmm_x_ptr_sub_x2x0, xmm_tmp2 ); + xmm_x_ptr_sub_x3x1 = _mm_mul_epi32( xmm_x_ptr_sub_x3x1, xmm_tmp2 ); + + xmm_x_ptr_n_k_x2x0 = _mm_srli_epi64( xmm_x_ptr_n_k_x2x0, 16 ); + xmm_x_ptr_n_k_x3x1 = _mm_slli_epi64( xmm_x_ptr_n_k_x3x1, 16 ); + xmm_x_ptr_sub_x2x0 = _mm_srli_epi64( xmm_x_ptr_sub_x2x0, 16 ); + xmm_x_ptr_sub_x3x1 = _mm_slli_epi64( xmm_x_ptr_sub_x3x1, 16 ); + + xmm_x_ptr_n_k_x2x0 = _mm_blend_epi16( xmm_x_ptr_n_k_x2x0, xmm_x_ptr_n_k_x3x1, 0xCC ); + xmm_x_ptr_sub_x2x0 = _mm_blend_epi16( xmm_x_ptr_sub_x2x0, xmm_x_ptr_sub_x3x1, 0xCC ); + + X1_3210 = _mm_loadu_si128( (__m128i *)&CAf[ k ] ); + PTR_3210 = _mm_loadu_si128( (__m128i *)&CAb[ k ] ); + + X1_3210 = _mm_add_epi32( X1_3210, xmm_x_ptr_n_k_x2x0 ); + PTR_3210 = _mm_add_epi32( PTR_3210, xmm_x_ptr_sub_x2x0 ); + + _mm_storeu_si128( (__m128i *)&CAf[ k ], X1_3210 ); + _mm_storeu_si128( (__m128i *)&CAb[ k ], PTR_3210 ); + } + + for( ; k <= n; k++ ) { + CAf[ k ] = silk_SMLAWW( CAf[ k ], tmp1, + silk_LSHIFT32( (opus_int32)x_ptr[ n - k ], -rshifts - 1 ) ); /* Q( -rshift ) */ + CAb[ k ] = silk_SMLAWW( CAb[ k ], tmp2, + silk_LSHIFT32( (opus_int32)x_ptr[ subfr_length - n + k - 1 ], -rshifts - 1 ) ); /* Q( -rshift ) */ + } + } + } + } + + /* Calculate nominator and denominator for the next order reflection (parcor) coefficient */ + tmp1 = C_first_row[ n ]; /* Q( -rshifts ) */ + tmp2 = C_last_row[ n ]; /* Q( -rshifts ) */ + num = 0; /* Q( -rshifts ) */ + nrg = silk_ADD32( CAb[ 0 ], CAf[ 0 ] ); /* Q( 1-rshifts ) */ + for( k = 0; k < n; k++ ) { + Atmp_QA = Af_QA[ k ]; + lz = silk_CLZ32( silk_abs( Atmp_QA ) ) - 1; + lz = silk_min( 32 - QA, lz ); + Atmp1 = silk_LSHIFT32( Atmp_QA, lz ); /* Q( QA + lz ) */ + + tmp1 = silk_ADD_LSHIFT32( tmp1, silk_SMMUL( C_last_row[ n - k - 1 ], Atmp1 ), 32 - QA - lz ); /* Q( -rshifts ) */ + tmp2 = silk_ADD_LSHIFT32( tmp2, silk_SMMUL( C_first_row[ n - k - 1 ], Atmp1 ), 32 - QA - lz ); /* Q( -rshifts ) */ + num = silk_ADD_LSHIFT32( num, silk_SMMUL( CAb[ n - k ], Atmp1 ), 32 - QA - lz ); /* Q( -rshifts ) */ + nrg = silk_ADD_LSHIFT32( nrg, silk_SMMUL( silk_ADD32( CAb[ k + 1 ], CAf[ k + 1 ] ), + Atmp1 ), 32 - QA - lz ); /* Q( 1-rshifts ) */ + } + CAf[ n + 1 ] = tmp1; /* Q( -rshifts ) */ + CAb[ n + 1 ] = tmp2; /* Q( -rshifts ) */ + num = silk_ADD32( num, tmp2 ); /* Q( -rshifts ) */ + num = silk_LSHIFT32( -num, 1 ); /* Q( 1-rshifts ) */ + + /* Calculate the next order reflection (parcor) coefficient */ + if( silk_abs( num ) < nrg ) { + rc_Q31 = silk_DIV32_varQ( num, nrg, 31 ); + } else { + rc_Q31 = ( num > 0 ) ? silk_int32_MAX : silk_int32_MIN; + } + + /* Update inverse prediction gain */ + tmp1 = ( (opus_int32)1 << 30 ) - silk_SMMUL( rc_Q31, rc_Q31 ); + tmp1 = silk_LSHIFT( silk_SMMUL( invGain_Q30, tmp1 ), 2 ); + if( tmp1 <= minInvGain_Q30 ) { + /* Max prediction gain exceeded; set reflection coefficient such that max prediction gain is exactly hit */ + tmp2 = ( (opus_int32)1 << 30 ) - silk_DIV32_varQ( minInvGain_Q30, invGain_Q30, 30 ); /* Q30 */ + rc_Q31 = silk_SQRT_APPROX( tmp2 ); /* Q15 */ + /* Newton-Raphson iteration */ + rc_Q31 = silk_RSHIFT32( rc_Q31 + silk_DIV32( tmp2, rc_Q31 ), 1 ); /* Q15 */ + rc_Q31 = silk_LSHIFT32( rc_Q31, 16 ); /* Q31 */ + if( num < 0 ) { + /* Ensure adjusted reflection coefficients has the original sign */ + rc_Q31 = -rc_Q31; + } + invGain_Q30 = minInvGain_Q30; + reached_max_gain = 1; + } else { + invGain_Q30 = tmp1; + } + + /* Update the AR coefficients */ + for( k = 0; k < (n + 1) >> 1; k++ ) { + tmp1 = Af_QA[ k ]; /* QA */ + tmp2 = Af_QA[ n - k - 1 ]; /* QA */ + Af_QA[ k ] = silk_ADD_LSHIFT32( tmp1, silk_SMMUL( tmp2, rc_Q31 ), 1 ); /* QA */ + Af_QA[ n - k - 1 ] = silk_ADD_LSHIFT32( tmp2, silk_SMMUL( tmp1, rc_Q31 ), 1 ); /* QA */ + } + Af_QA[ n ] = silk_RSHIFT32( rc_Q31, 31 - QA ); /* QA */ + + if( reached_max_gain ) { + /* Reached max prediction gain; set remaining coefficients to zero and exit loop */ + for( k = n + 1; k < D; k++ ) { + Af_QA[ k ] = 0; + } + break; + } + + /* Update C * Af and C * Ab */ + for( k = 0; k <= n + 1; k++ ) { + tmp1 = CAf[ k ]; /* Q( -rshifts ) */ + tmp2 = CAb[ n - k + 1 ]; /* Q( -rshifts ) */ + CAf[ k ] = silk_ADD_LSHIFT32( tmp1, silk_SMMUL( tmp2, rc_Q31 ), 1 ); /* Q( -rshifts ) */ + CAb[ n - k + 1 ] = silk_ADD_LSHIFT32( tmp2, silk_SMMUL( tmp1, rc_Q31 ), 1 ); /* Q( -rshifts ) */ + } + } + + if( reached_max_gain ) { + for( k = 0; k < D; k++ ) { + /* Scale coefficients */ + A_Q16[ k ] = -silk_RSHIFT_ROUND( Af_QA[ k ], QA - 16 ); + } + /* Subtract energy of preceding samples from C0 */ + if( rshifts > 0 ) { + for( s = 0; s < nb_subfr; s++ ) { + x_ptr = x + s * subfr_length; + C0 -= (opus_int32)silk_RSHIFT64( silk_inner_prod16_aligned_64( x_ptr, x_ptr, D, arch ), rshifts ); + } + } else { + for( s = 0; s < nb_subfr; s++ ) { + x_ptr = x + s * subfr_length; + C0 -= silk_LSHIFT32( silk_inner_prod_aligned( x_ptr, x_ptr, D, arch ), -rshifts ); + } + } + /* Approximate residual energy */ + *res_nrg = silk_LSHIFT( silk_SMMUL( invGain_Q30, C0 ), 2 ); + *res_nrg_Q = -rshifts; + } else { + /* Return residual energy */ + nrg = CAf[ 0 ]; /* Q( -rshifts ) */ + tmp1 = (opus_int32)1 << 16; /* Q16 */ + for( k = 0; k < D; k++ ) { + Atmp1 = silk_RSHIFT_ROUND( Af_QA[ k ], QA - 16 ); /* Q16 */ + nrg = silk_SMLAWW( nrg, CAf[ k + 1 ], Atmp1 ); /* Q( -rshifts ) */ + tmp1 = silk_SMLAWW( tmp1, Atmp1, Atmp1 ); /* Q16 */ + A_Q16[ k ] = -Atmp1; + } + *res_nrg = silk_SMLAWW( nrg, silk_SMMUL( SILK_FIX_CONST( FIND_LPC_COND_FAC, 32 ), C0 ), -tmp1 );/* Q( -rshifts ) */ + *res_nrg_Q = -rshifts; + } +} diff --git a/drivers/opus/silk/fixed/x86/prefilter_FIX_sse.c b/drivers/opus/silk/fixed/x86/prefilter_FIX_sse.c new file mode 100644 index 0000000000..febb105645 --- /dev/null +++ b/drivers/opus/silk/fixed/x86/prefilter_FIX_sse.c @@ -0,0 +1,157 @@ +/* Copyright (c) 2014, Cisco Systems, INC + Written by XiangMingZhu WeiZhou MinPeng YanWang + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#include "opus/opus_config.h" + +#include <xmmintrin.h> +#include <emmintrin.h> +#include <smmintrin.h> +#include "opus/silk/main.h" +#include "opus/celt/x86/x86cpu.h" + +void silk_warped_LPC_analysis_filter_FIX_sse4_1( + opus_int32 state[], /* I/O State [order + 1] */ + opus_int32 res_Q2[], /* O Residual signal [length] */ + const opus_int16 coef_Q13[], /* I Coefficients [order] */ + const opus_int16 input[], /* I Input signal [length] */ + const opus_int16 lambda_Q16, /* I Warping factor */ + const opus_int length, /* I Length of input signal */ + const opus_int order /* I Filter order (even) */ +) +{ + opus_int n, i; + opus_int32 acc_Q11, tmp1, tmp2; + + /* Order must be even */ + silk_assert( ( order & 1 ) == 0 ); + + if (order == 10) + { + if (0 == lambda_Q16) + { + __m128i coef_Q13_3210, coef_Q13_7654; + __m128i coef_Q13_0123, coef_Q13_4567; + __m128i state_0123, state_4567; + __m128i xmm_product1, xmm_product2; + __m128i xmm_tempa, xmm_tempb; + + register opus_int32 sum; + register opus_int32 state_8, state_9, state_a; + register opus_int64 coef_Q13_8, coef_Q13_9; + + silk_assert( length > 0 ); + + coef_Q13_3210 = OP_CVTEPI16_EPI32_M64( &coef_Q13[ 0 ] ); + coef_Q13_7654 = OP_CVTEPI16_EPI32_M64( &coef_Q13[ 4 ] ); + + coef_Q13_0123 = _mm_shuffle_epi32( coef_Q13_3210, _MM_SHUFFLE( 0, 1, 2, 3 ) ); + coef_Q13_4567 = _mm_shuffle_epi32( coef_Q13_7654, _MM_SHUFFLE( 0, 1, 2, 3 ) ); + + coef_Q13_8 = (opus_int64) coef_Q13[ 8 ]; + coef_Q13_9 = (opus_int64) coef_Q13[ 9 ]; + + state_0123 = _mm_loadu_si128( (__m128i *)(&state[ 0 ] ) ); + state_4567 = _mm_loadu_si128( (__m128i *)(&state[ 4 ] ) ); + + state_0123 = _mm_shuffle_epi32( state_0123, _MM_SHUFFLE( 0, 1, 2, 3 ) ); + state_4567 = _mm_shuffle_epi32( state_4567, _MM_SHUFFLE( 0, 1, 2, 3 ) ); + + state_8 = state[ 8 ]; + state_9 = state[ 9 ]; + state_a = 0; + + for( n = 0; n < length; n++ ) + { + xmm_product1 = _mm_mul_epi32( coef_Q13_0123, state_0123 ); /* 64-bit multiply, only 2 pairs */ + xmm_product2 = _mm_mul_epi32( coef_Q13_4567, state_4567 ); + + xmm_tempa = _mm_shuffle_epi32( state_0123, _MM_SHUFFLE( 0, 1, 2, 3 ) ); + xmm_tempb = _mm_shuffle_epi32( state_4567, _MM_SHUFFLE( 0, 1, 2, 3 ) ); + + xmm_product1 = _mm_srli_epi64( xmm_product1, 16 ); /* >> 16, zero extending works */ + xmm_product2 = _mm_srli_epi64( xmm_product2, 16 ); + + xmm_tempa = _mm_mul_epi32( coef_Q13_3210, xmm_tempa ); + xmm_tempb = _mm_mul_epi32( coef_Q13_7654, xmm_tempb ); + + xmm_tempa = _mm_srli_epi64( xmm_tempa, 16 ); + xmm_tempb = _mm_srli_epi64( xmm_tempb, 16 ); + + xmm_tempa = _mm_add_epi32( xmm_tempa, xmm_product1 ); + xmm_tempb = _mm_add_epi32( xmm_tempb, xmm_product2 ); + xmm_tempa = _mm_add_epi32( xmm_tempa, xmm_tempb ); + + sum = (coef_Q13_8 * state_8) >> 16; + sum += (coef_Q13_9 * state_9) >> 16; + + xmm_tempa = _mm_add_epi32( xmm_tempa, _mm_shuffle_epi32( xmm_tempa, _MM_SHUFFLE( 0, 0, 0, 2 ) ) ); + sum += _mm_cvtsi128_si32( xmm_tempa); + res_Q2[ n ] = silk_LSHIFT( (opus_int32)input[ n ], 2 ) - silk_RSHIFT_ROUND( ( 5 + sum ), 9); + + /* move right */ + state_a = state_9; + state_9 = state_8; + state_8 = _mm_cvtsi128_si32( state_4567 ); + state_4567 = _mm_alignr_epi8( state_0123, state_4567, 4 ); + + state_0123 = _mm_alignr_epi8( _mm_cvtsi32_si128( silk_LSHIFT( input[ n ], 14 ) ), state_0123, 4 ); + } + + _mm_storeu_si128( (__m128i *)( &state[ 0 ] ), _mm_shuffle_epi32( state_0123, _MM_SHUFFLE( 0, 1, 2, 3 ) ) ); + _mm_storeu_si128( (__m128i *)( &state[ 4 ] ), _mm_shuffle_epi32( state_4567, _MM_SHUFFLE( 0, 1, 2, 3 ) ) ); + state[ 8 ] = state_8; + state[ 9 ] = state_9; + state[ 10 ] = state_a; + + return; + } + } + + for( n = 0; n < length; n++ ) { + /* Output of lowpass section */ + tmp2 = silk_SMLAWB( state[ 0 ], state[ 1 ], lambda_Q16 ); + state[ 0 ] = silk_LSHIFT( input[ n ], 14 ); + /* Output of allpass section */ + tmp1 = silk_SMLAWB( state[ 1 ], state[ 2 ] - tmp2, lambda_Q16 ); + state[ 1 ] = tmp2; + acc_Q11 = silk_RSHIFT( order, 1 ); + acc_Q11 = silk_SMLAWB( acc_Q11, tmp2, coef_Q13[ 0 ] ); + /* Loop over allpass sections */ + for( i = 2; i < order; i += 2 ) { + /* Output of allpass section */ + tmp2 = silk_SMLAWB( state[ i ], state[ i + 1 ] - tmp1, lambda_Q16 ); + state[ i ] = tmp1; + acc_Q11 = silk_SMLAWB( acc_Q11, tmp1, coef_Q13[ i - 1 ] ); + /* Output of allpass section */ + tmp1 = silk_SMLAWB( state[ i + 1 ], state[ i + 2 ] - tmp2, lambda_Q16 ); + state[ i + 1 ] = tmp2; + acc_Q11 = silk_SMLAWB( acc_Q11, tmp2, coef_Q13[ i ] ); + } + state[ order ] = tmp1; + acc_Q11 = silk_SMLAWB( acc_Q11, tmp1, coef_Q13[ order - 1 ] ); + res_Q2[ n ] = silk_LSHIFT( (opus_int32)input[ n ], 2 ) - silk_RSHIFT_ROUND( acc_Q11, 9 ); + } +} diff --git a/drivers/opus/silk/fixed/x86/vector_ops_FIX_sse.c b/drivers/opus/silk/fixed/x86/vector_ops_FIX_sse.c new file mode 100644 index 0000000000..920d58cebc --- /dev/null +++ b/drivers/opus/silk/fixed/x86/vector_ops_FIX_sse.c @@ -0,0 +1,85 @@ +/* Copyright (c) 2014, Cisco Systems, INC + Written by XiangMingZhu WeiZhou MinPeng YanWang + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#include "opus/opus_config.h" + +#include <xmmintrin.h> +#include <emmintrin.h> +#include <smmintrin.h> +#include "opus/silk/main.h" + +#include "opus/silk/SigProc_FIX.h" +#include "opus/celt/pitch.h" + +opus_int64 silk_inner_prod16_aligned_64_sse4_1( + const opus_int16 *inVec1, /* I input vector 1 */ + const opus_int16 *inVec2, /* I input vector 2 */ + const opus_int len /* I vector lengths */ +) +{ + opus_int i, dataSize8; + opus_int64 sum; + + __m128i xmm_tempa; + __m128i inVec1_76543210, acc1; + __m128i inVec2_76543210, acc2; + + sum = 0; + dataSize8 = len & ~7; + + acc1 = _mm_setzero_si128(); + acc2 = _mm_setzero_si128(); + + for( i = 0; i < dataSize8; i += 8 ) { + inVec1_76543210 = _mm_loadu_si128( (__m128i *)(&inVec1[i + 0] ) ); + inVec2_76543210 = _mm_loadu_si128( (__m128i *)(&inVec2[i + 0] ) ); + + /* only when all 4 operands are -32768 (0x8000), this results in wrap around */ + inVec1_76543210 = _mm_madd_epi16( inVec1_76543210, inVec2_76543210 ); + + xmm_tempa = _mm_cvtepi32_epi64( inVec1_76543210 ); + /* equal shift right 8 bytes */ + inVec1_76543210 = _mm_shuffle_epi32( inVec1_76543210, _MM_SHUFFLE( 0, 0, 3, 2 ) ); + inVec1_76543210 = _mm_cvtepi32_epi64( inVec1_76543210 ); + + acc1 = _mm_add_epi64( acc1, xmm_tempa ); + acc2 = _mm_add_epi64( acc2, inVec1_76543210 ); + } + + acc1 = _mm_add_epi64( acc1, acc2 ); + + /* equal shift right 8 bytes */ + acc2 = _mm_shuffle_epi32( acc1, _MM_SHUFFLE( 0, 0, 3, 2 ) ); + acc1 = _mm_add_epi64( acc1, acc2 ); + + _mm_storel_epi64( (__m128i *)&sum, acc1 ); + + for( ; i < len; i++ ) { + sum = silk_SMLABB( sum, inVec1[ i ], inVec2[ i ] ); + } + + return sum; +} diff --git a/drivers/opus/silk/float/LPC_analysis_filter_FLP.c b/drivers/opus/silk/float/LPC_analysis_filter_FLP.c index 438b704fe9..344e52ade2 100644 --- a/drivers/opus/silk/float/LPC_analysis_filter_FLP.c +++ b/drivers/opus/silk/float/LPC_analysis_filter_FLP.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include <stdlib.h> #include "opus/silk/float/main_FLP.h" diff --git a/drivers/opus/silk/float/LPC_inv_pred_gain_FLP.c b/drivers/opus/silk/float/LPC_inv_pred_gain_FLP.c index 2e86e269eb..f99a427623 100644 --- a/drivers/opus/silk/float/LPC_inv_pred_gain_FLP.c +++ b/drivers/opus/silk/float/LPC_inv_pred_gain_FLP.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/SigProc_FIX.h" #include "opus/silk/float/SigProc_FLP.h" diff --git a/drivers/opus/silk/float/LTP_analysis_filter_FLP.c b/drivers/opus/silk/float/LTP_analysis_filter_FLP.c index 5919ceb928..853040d160 100644 --- a/drivers/opus/silk/float/LTP_analysis_filter_FLP.c +++ b/drivers/opus/silk/float/LTP_analysis_filter_FLP.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/float/main_FLP.h" diff --git a/drivers/opus/silk/float/LTP_scale_ctrl_FLP.c b/drivers/opus/silk/float/LTP_scale_ctrl_FLP.c index c952d810af..4219c14c5b 100644 --- a/drivers/opus/silk/float/LTP_scale_ctrl_FLP.c +++ b/drivers/opus/silk/float/LTP_scale_ctrl_FLP.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/float/main_FLP.h" diff --git a/drivers/opus/silk/float/apply_sine_window_FLP.c b/drivers/opus/silk/float/apply_sine_window_FLP.c index e8aa197bb0..0d9c894cd8 100644 --- a/drivers/opus/silk/float/apply_sine_window_FLP.c +++ b/drivers/opus/silk/float/apply_sine_window_FLP.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/float/main_FLP.h" diff --git a/drivers/opus/silk/float/autocorrelation_FLP.c b/drivers/opus/silk/float/autocorrelation_FLP.c index f4b90ff32d..0b78b0230d 100644 --- a/drivers/opus/silk/float/autocorrelation_FLP.c +++ b/drivers/opus/silk/float/autocorrelation_FLP.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/typedef.h" #include "opus/silk/float/SigProc_FLP.h" diff --git a/drivers/opus/silk/float/burg_modified_FLP.c b/drivers/opus/silk/float/burg_modified_FLP.c index 5a16334240..567990b850 100644 --- a/drivers/opus/silk/float/burg_modified_FLP.c +++ b/drivers/opus/silk/float/burg_modified_FLP.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/float/SigProc_FLP.h" #include "opus/silk/tuning_parameters.h" diff --git a/drivers/opus/silk/float/bwexpander_FLP.c b/drivers/opus/silk/float/bwexpander_FLP.c index b3de4f6453..c47bfa9433 100644 --- a/drivers/opus/silk/float/bwexpander_FLP.c +++ b/drivers/opus/silk/float/bwexpander_FLP.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/float/SigProc_FLP.h" diff --git a/drivers/opus/silk/float/corrMatrix_FLP.c b/drivers/opus/silk/float/corrMatrix_FLP.c index 551f8578d7..e34b42b541 100644 --- a/drivers/opus/silk/float/corrMatrix_FLP.c +++ b/drivers/opus/silk/float/corrMatrix_FLP.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif /********************************************************************** * Correlation matrix computations for LS estimate. diff --git a/drivers/opus/silk/float/encode_frame_FLP.c b/drivers/opus/silk/float/encode_frame_FLP.c index c5973b8922..4e46a52ee8 100644 --- a/drivers/opus/silk/float/encode_frame_FLP.c +++ b/drivers/opus/silk/float/encode_frame_FLP.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/float/main_FLP.h" #include "opus/silk/tuning_parameters.h" @@ -47,7 +44,7 @@ void silk_encode_do_VAD_FLP( /****************************/ /* Voice Activity Detection */ /****************************/ - silk_VAD_GetSA_Q8( &psEnc->sCmn, psEnc->sCmn.inputBuf + 1 ); + silk_VAD_GetSA_Q8( &psEnc->sCmn, psEnc->sCmn.inputBuf + 1, psEnc->sCmn.arch ); /**************************************************/ /* Convert speech activity into VAD and DTX flags */ diff --git a/drivers/opus/silk/float/energy_FLP.c b/drivers/opus/silk/float/energy_FLP.c index 9c6fad48d7..443f52bb16 100644 --- a/drivers/opus/silk/float/energy_FLP.c +++ b/drivers/opus/silk/float/energy_FLP.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/float/SigProc_FLP.h" diff --git a/drivers/opus/silk/float/find_LPC_FLP.c b/drivers/opus/silk/float/find_LPC_FLP.c index 2b8c54388f..162a490d1d 100644 --- a/drivers/opus/silk/float/find_LPC_FLP.c +++ b/drivers/opus/silk/float/find_LPC_FLP.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/define.h" #include "opus/silk/float/main_FLP.h" @@ -99,6 +96,6 @@ void silk_find_LPC_FLP( silk_A2NLSF_FLP( NLSF_Q15, a, psEncC->predictLPCOrder ); } - silk_assert( psEncC->indices.NLSFInterpCoef_Q2 == 4 || + silk_assert( psEncC->indices.NLSFInterpCoef_Q2 == 4 || ( psEncC->useInterpolatedNLSFs && !psEncC->first_frame_after_reset && psEncC->nb_subfr == MAX_NB_SUBFR ) ); } diff --git a/drivers/opus/silk/float/find_LTP_FLP.c b/drivers/opus/silk/float/find_LTP_FLP.c index 2f66de4684..9c03eeb6a7 100644 --- a/drivers/opus/silk/float/find_LTP_FLP.c +++ b/drivers/opus/silk/float/find_LTP_FLP.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/float/main_FLP.h" #include "opus/silk/tuning_parameters.h" diff --git a/drivers/opus/silk/float/find_pitch_lags_FLP.c b/drivers/opus/silk/float/find_pitch_lags_FLP.c index a2d582c734..bb7ef8ec2e 100644 --- a/drivers/opus/silk/float/find_pitch_lags_FLP.c +++ b/drivers/opus/silk/float/find_pitch_lags_FLP.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include <stdlib.h> #include "opus/silk/float/main_FLP.h" diff --git a/drivers/opus/silk/float/find_pred_coefs_FLP.c b/drivers/opus/silk/float/find_pred_coefs_FLP.c index 61eead7573..c0496ff1b5 100644 --- a/drivers/opus/silk/float/find_pred_coefs_FLP.c +++ b/drivers/opus/silk/float/find_pred_coefs_FLP.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/float/main_FLP.h" @@ -67,7 +64,8 @@ void silk_find_pred_coefs_FLP( /* Quantize LTP gain parameters */ silk_quant_LTP_gains_FLP( psEncCtrl->LTPCoef, psEnc->sCmn.indices.LTPIndex, &psEnc->sCmn.indices.PERIndex, - &psEnc->sCmn.sum_log_gain_Q7, WLTP, psEnc->sCmn.mu_LTP_Q9, psEnc->sCmn.LTPQuantLowComplexity, psEnc->sCmn.nb_subfr ); + &psEnc->sCmn.sum_log_gain_Q7, WLTP, psEnc->sCmn.mu_LTP_Q9, psEnc->sCmn.LTPQuantLowComplexity, psEnc->sCmn.nb_subfr, + psEnc->sCmn.arch ); /* Control LTP scaling */ silk_LTP_scale_ctrl_FLP( psEnc, psEncCtrl, condCoding ); @@ -90,13 +88,13 @@ void silk_find_pred_coefs_FLP( } silk_memset( psEncCtrl->LTPCoef, 0, psEnc->sCmn.nb_subfr * LTP_ORDER * sizeof( silk_float ) ); psEncCtrl->LTPredCodGain = 0.0f; - psEnc->sCmn.sum_log_gain_Q7 = 0; + psEnc->sCmn.sum_log_gain_Q7 = 0; } /* Limit on total predictive coding gain */ if( psEnc->sCmn.first_frame_after_reset ) { minInvGain = 1.0f / MAX_PREDICTION_POWER_GAIN_AFTER_RESET; - } else { + } else { minInvGain = (silk_float)pow( 2, psEncCtrl->LTPredCodGain / 3 ) / MAX_PREDICTION_POWER_GAIN; minInvGain /= 0.25f + 0.75f * psEncCtrl->coding_quality; } diff --git a/drivers/opus/silk/float/inner_product_FLP.c b/drivers/opus/silk/float/inner_product_FLP.c index e5f0308448..0586c4d7fb 100644 --- a/drivers/opus/silk/float/inner_product_FLP.c +++ b/drivers/opus/silk/float/inner_product_FLP.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/float/SigProc_FLP.h" diff --git a/drivers/opus/silk/float/k2a_FLP.c b/drivers/opus/silk/float/k2a_FLP.c index 71dc4c3c44..26ba94e610 100644 --- a/drivers/opus/silk/float/k2a_FLP.c +++ b/drivers/opus/silk/float/k2a_FLP.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/float/SigProc_FLP.h" diff --git a/drivers/opus/silk/float/levinsondurbin_FLP.c b/drivers/opus/silk/float/levinsondurbin_FLP.c index 8fbca230a5..7e3c9d6531 100644 --- a/drivers/opus/silk/float/levinsondurbin_FLP.c +++ b/drivers/opus/silk/float/levinsondurbin_FLP.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/float/SigProc_FLP.h" diff --git a/drivers/opus/silk/float/main_FLP.h b/drivers/opus/silk/float/main_FLP.h index 4ec8ddeefc..8f35177549 100644 --- a/drivers/opus/silk/float/main_FLP.h +++ b/drivers/opus/silk/float/main_FLP.h @@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "opus/silk/float/SigProc_FLP.h" #include "opus/silk/SigProc_FIX.h" #include "opus/silk/float/structs_FLP.h" -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" #include "opus/silk/define.h" #include "opus/silk/debug.h" #include "opus/celt/entenc.h" @@ -205,7 +205,8 @@ void silk_quant_LTP_gains_FLP( const silk_float W[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* I Error weights */ const opus_int mu_Q10, /* I Mu value (R/D tradeoff) */ const opus_int lowComplexity, /* I Flag for low complexity */ - const opus_int nb_subfr /* I number of subframes */ + const opus_int nb_subfr, /* I number of subframes */ + int arch /* I Run-time architecture */ ); /* Residual energy: nrg = wxx - 2 * wXx * c + c' * wXX * c */ diff --git a/drivers/opus/silk/float/noise_shape_analysis_FLP.c b/drivers/opus/silk/float/noise_shape_analysis_FLP.c index 5d8bc6332a..cbb8ba4470 100644 --- a/drivers/opus/silk/float/noise_shape_analysis_FLP.c +++ b/drivers/opus/silk/float/noise_shape_analysis_FLP.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/float/main_FLP.h" #include "opus/silk/tuning_parameters.h" diff --git a/drivers/opus/silk/float/pitch_analysis_core_FLP.c b/drivers/opus/silk/float/pitch_analysis_core_FLP.c index 2689c5008b..6a48ae498c 100644 --- a/drivers/opus/silk/float/pitch_analysis_core_FLP.c +++ b/drivers/opus/silk/float/pitch_analysis_core_FLP.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif /***************************************************************************** * Pitch analyser function @@ -182,8 +179,8 @@ opus_int silk_pitch_analysis_core_FLP( /* O Voicing estimate: 0 voiced, /* Calculate first vector products before loop */ cross_corr = xcorr[ max_lag_4kHz - min_lag_4kHz ]; - normalizer = silk_energy_FLP( target_ptr, sf_length_8kHz ) + - silk_energy_FLP( basis_ptr, sf_length_8kHz ) + + normalizer = silk_energy_FLP( target_ptr, sf_length_8kHz ) + + silk_energy_FLP( basis_ptr, sf_length_8kHz ) + sf_length_8kHz * 4000.0f; C[ 0 ][ min_lag_4kHz ] += (silk_float)( 2 * cross_corr / normalizer ); diff --git a/drivers/opus/silk/float/prefilter_FLP.c b/drivers/opus/silk/float/prefilter_FLP.c index 0298ef2f8e..0857888b91 100644 --- a/drivers/opus/silk/float/prefilter_FLP.c +++ b/drivers/opus/silk/float/prefilter_FLP.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/float/main_FLP.h" #include "opus/silk/tuning_parameters.h" diff --git a/drivers/opus/silk/float/process_gains_FLP.c b/drivers/opus/silk/float/process_gains_FLP.c index bd5e7ee7a2..3a1e46f096 100644 --- a/drivers/opus/silk/float/process_gains_FLP.c +++ b/drivers/opus/silk/float/process_gains_FLP.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/float/main_FLP.h" #include "opus/silk/tuning_parameters.h" diff --git a/drivers/opus/silk/float/regularize_correlations_FLP.c b/drivers/opus/silk/float/regularize_correlations_FLP.c index 397e45b10b..20e9074a0b 100644 --- a/drivers/opus/silk/float/regularize_correlations_FLP.c +++ b/drivers/opus/silk/float/regularize_correlations_FLP.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/float/main_FLP.h" diff --git a/drivers/opus/silk/float/residual_energy_FLP.c b/drivers/opus/silk/float/residual_energy_FLP.c index 50bc728b71..cc462a9e54 100644 --- a/drivers/opus/silk/float/residual_energy_FLP.c +++ b/drivers/opus/silk/float/residual_energy_FLP.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/float/main_FLP.h" diff --git a/drivers/opus/silk/float/scale_copy_vector_FLP.c b/drivers/opus/silk/float/scale_copy_vector_FLP.c index 8c5bfadb3a..2656963e88 100644 --- a/drivers/opus/silk/float/scale_copy_vector_FLP.c +++ b/drivers/opus/silk/float/scale_copy_vector_FLP.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/float/SigProc_FLP.h" diff --git a/drivers/opus/silk/float/scale_vector_FLP.c b/drivers/opus/silk/float/scale_vector_FLP.c index 191b3d6041..ea2aa0e330 100644 --- a/drivers/opus/silk/float/scale_vector_FLP.c +++ b/drivers/opus/silk/float/scale_vector_FLP.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/float/SigProc_FLP.h" diff --git a/drivers/opus/silk/float/schur_FLP.c b/drivers/opus/silk/float/schur_FLP.c index 631dbe093a..f2071db214 100644 --- a/drivers/opus/silk/float/schur_FLP.c +++ b/drivers/opus/silk/float/schur_FLP.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/float/SigProc_FLP.h" diff --git a/drivers/opus/silk/float/solve_LS_FLP.c b/drivers/opus/silk/float/solve_LS_FLP.c index b3757ce03f..9d625c695d 100644 --- a/drivers/opus/silk/float/solve_LS_FLP.c +++ b/drivers/opus/silk/float/solve_LS_FLP.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/float/main_FLP.h" #include "opus/silk/tuning_parameters.h" diff --git a/drivers/opus/silk/float/sort_FLP.c b/drivers/opus/silk/float/sort_FLP.c index f2570503a5..ed212c63c9 100644 --- a/drivers/opus/silk/float/sort_FLP.c +++ b/drivers/opus/silk/float/sort_FLP.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif /* Insertion sort (fast for already almost sorted arrays): */ /* Best case: O(n) for an already sorted array */ diff --git a/drivers/opus/silk/float/structs_FLP.h b/drivers/opus/silk/float/structs_FLP.h index 798aec2f43..9eb5eb05eb 100644 --- a/drivers/opus/silk/float/structs_FLP.h +++ b/drivers/opus/silk/float/structs_FLP.h @@ -29,7 +29,7 @@ POSSIBILITY OF SUCH DAMAGE. #define SILK_STRUCTS_FLP_H #include "opus/silk/typedef.h" -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" #include "opus/silk/structs.h" #ifdef __cplusplus @@ -115,6 +115,7 @@ typedef struct { typedef struct { silk_encoder_state_FLP state_Fxx[ ENCODER_NUM_CHANNELS ]; stereo_enc_state sStereo; + opus_int32 nBitsUsedLBRR; opus_int32 nBitsExceeded; opus_int nChannelsAPI; opus_int nChannelsInternal; diff --git a/drivers/opus/silk/float/warped_autocorrelation_FLP.c b/drivers/opus/silk/float/warped_autocorrelation_FLP.c index 092b998d93..b814661b92 100644 --- a/drivers/opus/silk/float/warped_autocorrelation_FLP.c +++ b/drivers/opus/silk/float/warped_autocorrelation_FLP.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/float/main_FLP.h" diff --git a/drivers/opus/silk/float/wrappers_FLP.c b/drivers/opus/silk/float/wrappers_FLP.c index 31586cf2a9..c80c618a92 100644 --- a/drivers/opus/silk/float/wrappers_FLP.c +++ b/drivers/opus/silk/float/wrappers_FLP.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/float/main_FLP.h" @@ -161,10 +158,10 @@ void silk_NSQ_wrapper_FLP( /* Call NSQ */ if( psEnc->sCmn.nStatesDelayedDecision > 1 || psEnc->sCmn.warping_Q16 > 0 ) { silk_NSQ_del_dec( &psEnc->sCmn, psNSQ, psIndices, x_Q3, pulses, PredCoef_Q12[ 0 ], LTPCoef_Q14, - AR2_Q13, HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, psEncCtrl->pitchL, Lambda_Q10, LTP_scale_Q14 ); + AR2_Q13, HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, psEncCtrl->pitchL, Lambda_Q10, LTP_scale_Q14, psEnc->sCmn.arch ); } else { silk_NSQ( &psEnc->sCmn, psNSQ, psIndices, x_Q3, pulses, PredCoef_Q12[ 0 ], LTPCoef_Q14, - AR2_Q13, HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, psEncCtrl->pitchL, Lambda_Q10, LTP_scale_Q14 ); + AR2_Q13, HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, psEncCtrl->pitchL, Lambda_Q10, LTP_scale_Q14, psEnc->sCmn.arch ); } } @@ -179,7 +176,8 @@ void silk_quant_LTP_gains_FLP( const silk_float W[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* I Error weights */ const opus_int mu_Q10, /* I Mu value (R/D tradeoff) */ const opus_int lowComplexity, /* I Flag for low complexity */ - const opus_int nb_subfr /* I number of subframes */ + const opus_int nb_subfr, /* I number of subframes */ + int arch /* I Run-time architecture */ ) { opus_int i; @@ -193,7 +191,7 @@ void silk_quant_LTP_gains_FLP( W_Q18[ i ] = (opus_int32)silk_float2int( W[ i ] * 262144.0f ); } - silk_quant_LTP_gains( B_Q14, cbk_index, periodicity_index, sum_log_gain_Q7, W_Q18, mu_Q10, lowComplexity, nb_subfr ); + silk_quant_LTP_gains( B_Q14, cbk_index, periodicity_index, sum_log_gain_Q7, W_Q18, mu_Q10, lowComplexity, nb_subfr, arch ); for( i = 0; i < nb_subfr * LTP_ORDER; i++ ) { B[ i ] = (silk_float)B_Q14[ i ] * ( 1.0f / 16384.0f ); diff --git a/drivers/opus/silk/gain_quant.c b/drivers/opus/silk/gain_quant.c index e1d9b91126..7b7a65d674 100644 --- a/drivers/opus/silk/gain_quant.c +++ b/drivers/opus/silk/gain_quant.c @@ -24,12 +24,9 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" #define OFFSET ( ( MIN_QGAIN_DB * 128 ) / 6 + 16 * 128 ) #define SCALE_Q16 ( ( 65536 * ( N_LEVELS_QGAIN - 1 ) ) / ( ( ( MAX_QGAIN_DB - MIN_QGAIN_DB ) * 128 ) / 6 ) ) diff --git a/drivers/opus/silk/init_decoder.c b/drivers/opus/silk/init_decoder.c index 43fa1f1c38..c8f694c9d7 100644 --- a/drivers/opus/silk/init_decoder.c +++ b/drivers/opus/silk/init_decoder.c @@ -24,12 +24,9 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" /************************/ /* Init Decoder State */ diff --git a/drivers/opus/silk/init_encoder.c b/drivers/opus/silk/init_encoder.c index 9ba4524b73..1c63edb4b8 100644 --- a/drivers/opus/silk/init_encoder.c +++ b/drivers/opus/silk/init_encoder.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #ifdef OPUS_FIXED_POINT #include "opus/silk/fixed/main_FIX.h" #else diff --git a/drivers/opus/silk/inner_prod_aligned.c b/drivers/opus/silk/inner_prod_aligned.c index 86ecf463ad..7bd7297c7d 100644 --- a/drivers/opus/silk/inner_prod_aligned.c +++ b/drivers/opus/silk/inner_prod_aligned.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/SigProc_FIX.h" diff --git a/drivers/opus/silk/interpolate.c b/drivers/opus/silk/interpolate.c index 26c44de493..25091b4fa6 100644 --- a/drivers/opus/silk/interpolate.c +++ b/drivers/opus/silk/interpolate.c @@ -24,12 +24,9 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" /* Interpolate two vectors */ void silk_interpolate( diff --git a/drivers/opus/silk/lin2log.c b/drivers/opus/silk/lin2log.c index ea11f33dd0..694eb1e876 100644 --- a/drivers/opus/silk/lin2log.c +++ b/drivers/opus/silk/lin2log.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/SigProc_FIX.h" /* Approximation of 128 * log2() (very close inverse of silk_log2lin()) */ diff --git a/drivers/opus/silk/log2lin.c b/drivers/opus/silk/log2lin.c index 0a33ca48fb..8d14150a41 100644 --- a/drivers/opus/silk/log2lin.c +++ b/drivers/opus/silk/log2lin.c @@ -24,16 +24,13 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/SigProc_FIX.h" /* Approximation of 2^() (very close inverse of silk_lin2log()) */ /* Convert input to a linear scale */ -opus_int32 silk_log2lin( +opus_int32 silk_log2lin( const opus_int32 inLog_Q7 /* I input on log scale */ ) { @@ -42,8 +39,8 @@ opus_int32 silk_log2lin( if( inLog_Q7 < 0 ) { return 0; } else if ( inLog_Q7 >= 3967 ) { - return silk_int32_MAX; - } + return silk_int32_MAX; + } out = silk_LSHIFT( 1, silk_RSHIFT( inLog_Q7, 7 ) ); frac_Q7 = inLog_Q7 & 0x7F; diff --git a/drivers/opus/silk/macros.h b/drivers/opus/silk/macros.h index 8986dc8f82..29efd11ace 100644 --- a/drivers/opus/silk/macros.h +++ b/drivers/opus/silk/macros.h @@ -27,25 +27,47 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef SILK_MACROS_H #define SILK_MACROS_H - #include "opus/opus_config.h" #include "opus/opus_types.h" #include "opus/opus_defines.h" +#if OPUS_GNUC_PREREQ(3, 0) +#define opus_likely(x) (__builtin_expect(!!(x), 1)) +#define opus_unlikely(x) (__builtin_expect(!!(x), 0)) +#else +#define opus_likely(x) (!!(x)) +#define opus_unlikely(x) (!!(x)) +#endif + +/* Set this if opus_int64 is a native type of the CPU. */ +#define OPUS_FAST_INT64 (defined(__x86_64__) || defined(__LP64__) || defined(_WIN64)) + /* This is an OPUS_INLINE header file for general platform. */ /* (a32 * (opus_int32)((opus_int16)(b32))) >> 16 output have to be 32bit int */ +#if OPUS_FAST_INT64 +#define silk_SMULWB(a32, b32) (((a32) * (opus_int64)((opus_int16)(b32))) >> 16) +#else #define silk_SMULWB(a32, b32) ((((a32) >> 16) * (opus_int32)((opus_int16)(b32))) + ((((a32) & 0x0000FFFF) * (opus_int32)((opus_int16)(b32))) >> 16)) +#endif /* a32 + (b32 * (opus_int32)((opus_int16)(c32))) >> 16 output have to be 32bit int */ +#if OPUS_FAST_INT64 +#define silk_SMLAWB(a32, b32, c32) ((a32) + (((b32) * (opus_int64)((opus_int16)(c32))) >> 16)) +#else #define silk_SMLAWB(a32, b32, c32) ((a32) + ((((b32) >> 16) * (opus_int32)((opus_int16)(c32))) + ((((b32) & 0x0000FFFF) * (opus_int32)((opus_int16)(c32))) >> 16))) +#endif /* (a32 * (b32 >> 16)) >> 16 */ #define silk_SMULWT(a32, b32) (((a32) >> 16) * ((b32) >> 16) + ((((a32) & 0x0000FFFF) * ((b32) >> 16)) >> 16)) /* a32 + (b32 * (c32 >> 16)) >> 16 */ +#if OPUS_FAST_INT64 +#define silk_SMLAWT(a32, b32, c32) ((a32) + (((b32) * ((opus_int64)(c32) >> 16)) >> 16)) +#else #define silk_SMLAWT(a32, b32, c32) ((a32) + (((b32) >> 16) * ((c32) >> 16)) + ((((b32) & 0x0000FFFF) * ((c32) >> 16)) >> 16)) +#endif /* (opus_int32)((opus_int16)(a3))) * (opus_int32)((opus_int16)(b32)) output have to be 32bit int */ #define silk_SMULBB(a32, b32) ((opus_int32)((opus_int16)(a32)) * (opus_int32)((opus_int16)(b32))) @@ -63,10 +85,18 @@ POSSIBILITY OF SUCH DAMAGE. #define silk_SMLAL(a64, b32, c32) (silk_ADD64((a64), ((opus_int64)(b32) * (opus_int64)(c32)))) /* (a32 * b32) >> 16 */ +#if OPUS_FAST_INT64 +#define silk_SMULWW(a32, b32) (((opus_int64)(a32) * (b32)) >> 16) +#else #define silk_SMULWW(a32, b32) silk_MLA(silk_SMULWB((a32), (b32)), (a32), silk_RSHIFT_ROUND((b32), 16)) +#endif /* a32 + ((b32 * c32) >> 16) */ +#if OPUS_FAST_INT64 +#define silk_SMLAWW(a32, b32, c32) ((a32) + (((opus_int64)(b32) * (c32)) >> 16)) +#else #define silk_SMLAWW(a32, b32, c32) silk_MLA(silk_SMLAWB((a32), (b32), (c32)), (b32), silk_RSHIFT_ROUND((c32), 16)) +#endif /* add/subtract with output saturated */ #define silk_ADD_SAT32(a, b) ((((opus_uint32)(a) + (opus_uint32)(b)) & 0x80000000) == 0 ? \ @@ -77,17 +107,24 @@ POSSIBILITY OF SUCH DAMAGE. (( (a) & ((b)^0x80000000) & 0x80000000) ? silk_int32_MIN : (a)-(b)) : \ ((((a)^0x80000000) & (b) & 0x80000000) ? silk_int32_MAX : (a)-(b)) ) -#include "opus/celt/ecintrin.h" +#if defined(MIPSr1_ASM) +#include "opus/silk/mips/macros_mipsr1.h" +#endif +#include "opus/celt/ecintrin.h" +#ifndef OVERRIDE_silk_CLZ16 static OPUS_INLINE opus_int32 silk_CLZ16(opus_int16 in16) { return 32 - EC_ILOG(in16<<16|0x8000); } +#endif +#ifndef OVERRIDE_silk_CLZ32 static OPUS_INLINE opus_int32 silk_CLZ32(opus_int32 in32) { return in32 ? 32 - EC_ILOG(in32) : 32; } +#endif /* Row based */ #define matrix_ptr(Matrix_base_adr, row, column, N) \ @@ -102,11 +139,11 @@ static OPUS_INLINE opus_int32 silk_CLZ32(opus_int32 in32) #endif #ifdef OPUS_ARM_INLINE_ASM -#include "arm/macros_armv4.h" +#include "opus/silk/arm/macros_armv4.h" #endif #ifdef OPUS_ARM_INLINE_EDSP -#include "arm/macros_armv5e.h" +#include "opus/silk/arm/macros_armv5e.h" #endif #endif /* SILK_MACROS_H */ diff --git a/drivers/opus/silk/silk_main.h b/drivers/opus/silk/main.h index 14671dcf72..a6ec2d7e4c 100644 --- a/drivers/opus/silk/silk_main.h +++ b/drivers/opus/silk/main.h @@ -38,6 +38,10 @@ POSSIBILITY OF SUCH DAMAGE. #include "opus/celt/entenc.h" #include "opus/celt/entdec.h" +#if defined(OPUS_X86_MAY_HAVE_SSE4_1) +#include "opus/silk/x86/main_sse.h" +#endif + /* Convert Left/Right stereo signal to adaptive Mid/Side representation */ void silk_stereo_LR_to_MS( stereo_enc_state *state, /* I/O State */ @@ -116,7 +120,7 @@ void silk_encode_signs( /* Decodes signs of excitation */ void silk_decode_signs( ec_dec *psRangeDec, /* I/O Compressor data structure */ - opus_int pulses[], /* I/O pulse signal */ + opus_int16 pulses[], /* I/O pulse signal */ opus_int length, /* I length of input */ const opus_int signalType, /* I Signal type */ const opus_int quantOffsetType, /* I Quantization offset type */ @@ -161,7 +165,7 @@ void silk_shell_encoder( /* Shell decoder, operates on one shell code frame of 16 pulses */ void silk_shell_decoder( - opus_int *pulses0, /* O data: nonnegative pulse amplitudes */ + opus_int16 *pulses0, /* O data: nonnegative pulse amplitudes */ ec_dec *psRangeDec, /* I/O Compressor data structure */ const opus_int pulses4 /* I number of pulses per pulse-subframe */ ); @@ -204,15 +208,16 @@ void silk_quant_LTP_gains( opus_int16 B_Q14[ MAX_NB_SUBFR * LTP_ORDER ], /* I/O (un)quantized LTP gains */ opus_int8 cbk_index[ MAX_NB_SUBFR ], /* O Codebook Index */ opus_int8 *periodicity_index, /* O Periodicity Index */ - opus_int32 *sum_gain_dB_Q7, /* I/O Cumulative max prediction gain */ + opus_int32 *sum_gain_dB_Q7, /* I/O Cumulative max prediction gain */ const opus_int32 W_Q18[ MAX_NB_SUBFR*LTP_ORDER*LTP_ORDER ], /* I Error Weights in Q18 */ opus_int mu_Q9, /* I Mu value (R/D tradeoff) */ opus_int lowComplexity, /* I Flag for low complexity */ - const opus_int nb_subfr /* I number of subframes */ + const opus_int nb_subfr, /* I number of subframes */ + int arch /* I Run-time architecture */ ); /* Entropy constrained matrix-weighted VQ, for a single input data vector */ -void silk_VQ_WMat_EC( +void silk_VQ_WMat_EC_c( opus_int8 *ind, /* O index of best codebook vector */ opus_int32 *rate_dist_Q14, /* O best weighted quant error + mu * rate */ opus_int *gain_Q7, /* O sum of absolute LTP coefficients */ @@ -226,10 +231,18 @@ void silk_VQ_WMat_EC( opus_int L /* I number of vectors in codebook */ ); +#if !defined(OVERRIDE_silk_VQ_WMat_EC) +#define silk_VQ_WMat_EC(ind, rate_dist_Q14, gain_Q7, in_Q14, W_Q18, cb_Q7, cb_gain_Q7, cl_Q5, \ + mu_Q9, max_gain_Q7, L, arch) \ + ((void)(arch),silk_VQ_WMat_EC_c(ind, rate_dist_Q14, gain_Q7, in_Q14, W_Q18, cb_Q7, cb_gain_Q7, cl_Q5, \ + mu_Q9, max_gain_Q7, L)) +#endif + /************************************/ /* Noise shaping quantization (NSQ) */ /************************************/ -void silk_NSQ( + +void silk_NSQ_c( const silk_encoder_state *psEncC, /* I/O Encoder State */ silk_nsq_state *NSQ, /* I/O NSQ state */ SideInfoIndices *psIndices, /* I/O Quantization Indices */ @@ -247,8 +260,15 @@ void silk_NSQ( const opus_int LTP_scale_Q14 /* I LTP state scaling */ ); +#if !defined(OVERRIDE_silk_NSQ) +#define silk_NSQ(psEncC, NSQ, psIndices, x_Q3, pulses, PredCoef_Q12, LTPCoef_Q14, AR2_Q13, \ + HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, pitchL, Lambda_Q10, LTP_scale_Q14, arch) \ + ((void)(arch),silk_NSQ_c(psEncC, NSQ, psIndices, x_Q3, pulses, PredCoef_Q12, LTPCoef_Q14, AR2_Q13, \ + HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, pitchL, Lambda_Q10, LTP_scale_Q14)) +#endif + /* Noise shaping using delayed decision */ -void silk_NSQ_del_dec( +void silk_NSQ_del_dec_c( const silk_encoder_state *psEncC, /* I/O Encoder State */ silk_nsq_state *NSQ, /* I/O NSQ state */ SideInfoIndices *psIndices, /* I/O Quantization Indices */ @@ -266,6 +286,13 @@ void silk_NSQ_del_dec( const opus_int LTP_scale_Q14 /* I LTP state scaling */ ); +#if !defined(OVERRIDE_silk_NSQ_del_dec) +#define silk_NSQ_del_dec(psEncC, NSQ, psIndices, x_Q3, pulses, PredCoef_Q12, LTPCoef_Q14, AR2_Q13, \ + HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, pitchL, Lambda_Q10, LTP_scale_Q14, arch) \ + ((void)(arch),silk_NSQ_del_dec_c(psEncC, NSQ, psIndices, x_Q3, pulses, PredCoef_Q12, LTPCoef_Q14, AR2_Q13, \ + HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, pitchL, Lambda_Q10, LTP_scale_Q14)) +#endif + /************/ /* Silk VAD */ /************/ @@ -275,11 +302,15 @@ opus_int silk_VAD_Init( /* O Return v ); /* Get speech activity level in Q8 */ -opus_int silk_VAD_GetSA_Q8( /* O Return value, 0 if success */ +opus_int silk_VAD_GetSA_Q8_c( /* O Return value, 0 if success */ silk_encoder_state *psEncC, /* I/O Encoder state */ const opus_int16 pIn[] /* I PCM input */ ); +#if !defined(OVERRIDE_silk_VAD_GetSA_Q8) +#define silk_VAD_GetSA_Q8(psEnC, pIn, arch) ((void)(arch),silk_VAD_GetSA_Q8_c(psEnC, pIn)) +#endif + /* Low-pass filter with variable cutoff frequency based on */ /* piece-wise linear interpolation between elliptic filters */ /* Start by setting transition_frame_no = 1; */ @@ -373,7 +404,8 @@ opus_int silk_decode_frame( opus_int16 pOut[], /* O Pointer to output speech frame */ opus_int32 *pN, /* O Pointer to size of output frame */ opus_int lostFlag, /* I 0: no loss, 1 loss, 2 decode fec */ - opus_int condCoding /* I The type of conditional coding to use */ + opus_int condCoding, /* I The type of conditional coding to use */ + int arch /* I Run-time architecture */ ); /* Decode indices from bitstream */ @@ -397,13 +429,14 @@ void silk_decode_core( silk_decoder_state *psDec, /* I/O Decoder state */ silk_decoder_control *psDecCtrl, /* I Decoder control */ opus_int16 xq[], /* O Decoded speech */ - const opus_int pulses[ MAX_FRAME_LENGTH ] /* I Pulse signal */ + const opus_int16 pulses[ MAX_FRAME_LENGTH ], /* I Pulse signal */ + int arch /* I Run-time architecture */ ); /* Decode quantization indices of excitation (Shell coding) */ void silk_decode_pulses( ec_dec *psRangeDec, /* I/O Compressor data structure */ - opus_int pulses[], /* O Excitation signal */ + opus_int16 pulses[], /* O Excitation signal */ const opus_int signalType, /* I Sigtype */ const opus_int quantOffsetType, /* I quantOffsetType */ const opus_int frame_length /* I Frame length */ diff --git a/drivers/opus/silk/mips/NSQ_del_dec_mipsr1.h b/drivers/opus/silk/mips/NSQ_del_dec_mipsr1.h new file mode 100644 index 0000000000..5cecca28b7 --- /dev/null +++ b/drivers/opus/silk/mips/NSQ_del_dec_mipsr1.h @@ -0,0 +1,402 @@ +/*********************************************************************** +Copyright (c) 2006-2011, Skype Limited. All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +- Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. +- Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. +- Neither the name of Internet Society, IETF or IETF Trust, nor the +names of specific contributors, may be used to endorse or promote +products derived from this software without specific prior written +permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +***********************************************************************/ + +#ifndef __NSQ_DEL_DEC_MIPSR1_H__ +#define __NSQ_DEL_DEC_MIPSR1_H__ +#include "opus/opus_config.h" + +#include "opus/silk/main.h" +#include "opus/celt/stack_alloc.h" + +#define OVERRIDE_silk_noise_shape_quantizer_del_dec +static inline void silk_noise_shape_quantizer_del_dec( + silk_nsq_state *NSQ, /* I/O NSQ state */ + NSQ_del_dec_struct psDelDec[], /* I/O Delayed decision states */ + opus_int signalType, /* I Signal type */ + const opus_int32 x_Q10[], /* I */ + opus_int8 pulses[], /* O */ + opus_int16 xq[], /* O */ + opus_int32 sLTP_Q15[], /* I/O LTP filter state */ + opus_int32 delayedGain_Q10[], /* I/O Gain delay buffer */ + const opus_int16 a_Q12[], /* I Short term prediction coefs */ + const opus_int16 b_Q14[], /* I Long term prediction coefs */ + const opus_int16 AR_shp_Q13[], /* I Noise shaping coefs */ + opus_int lag, /* I Pitch lag */ + opus_int32 HarmShapeFIRPacked_Q14, /* I */ + opus_int Tilt_Q14, /* I Spectral tilt */ + opus_int32 LF_shp_Q14, /* I */ + opus_int32 Gain_Q16, /* I */ + opus_int Lambda_Q10, /* I */ + opus_int offset_Q10, /* I */ + opus_int length, /* I Input length */ + opus_int subfr, /* I Subframe number */ + opus_int shapingLPCOrder, /* I Shaping LPC filter order */ + opus_int predictLPCOrder, /* I Prediction filter order */ + opus_int warping_Q16, /* I */ + opus_int nStatesDelayedDecision, /* I Number of states in decision tree */ + opus_int *smpl_buf_idx, /* I Index to newest samples in buffers */ + opus_int decisionDelay /* I */ +) +{ + opus_int i, j, k, Winner_ind, RDmin_ind, RDmax_ind, last_smple_idx; + opus_int32 Winner_rand_state; + opus_int32 LTP_pred_Q14, LPC_pred_Q14, n_AR_Q14, n_LTP_Q14; + opus_int32 n_LF_Q14, r_Q10, rr_Q10, rd1_Q10, rd2_Q10, RDmin_Q10, RDmax_Q10; + opus_int32 q1_Q0, q1_Q10, q2_Q10, exc_Q14, LPC_exc_Q14, xq_Q14, Gain_Q10; + opus_int32 tmp1, tmp2, sLF_AR_shp_Q14; + opus_int32 *pred_lag_ptr, *shp_lag_ptr, *psLPC_Q14; + NSQ_sample_struct psSampleState[ MAX_DEL_DEC_STATES ][ 2 ]; + NSQ_del_dec_struct *psDD; + NSQ_sample_struct *psSS; + opus_int16 b_Q14_0, b_Q14_1, b_Q14_2, b_Q14_3, b_Q14_4; + opus_int16 a_Q12_0, a_Q12_1, a_Q12_2, a_Q12_3, a_Q12_4, a_Q12_5, a_Q12_6; + opus_int16 a_Q12_7, a_Q12_8, a_Q12_9, a_Q12_10, a_Q12_11, a_Q12_12, a_Q12_13; + opus_int16 a_Q12_14, a_Q12_15; + + opus_int32 cur, prev, next; + + //Intialize b_Q14 variables + b_Q14_0 = b_Q14[ 0 ]; + b_Q14_1 = b_Q14[ 1 ]; + b_Q14_2 = b_Q14[ 2 ]; + b_Q14_3 = b_Q14[ 3 ]; + b_Q14_4 = b_Q14[ 4 ]; + + //Intialize a_Q12 variables + a_Q12_0 = a_Q12[0]; + a_Q12_1 = a_Q12[1]; + a_Q12_2 = a_Q12[2]; + a_Q12_3 = a_Q12[3]; + a_Q12_4 = a_Q12[4]; + a_Q12_5 = a_Q12[5]; + a_Q12_6 = a_Q12[6]; + a_Q12_7 = a_Q12[7]; + a_Q12_8 = a_Q12[8]; + a_Q12_9 = a_Q12[9]; + a_Q12_10 = a_Q12[10]; + a_Q12_11 = a_Q12[11]; + a_Q12_12 = a_Q12[12]; + a_Q12_13 = a_Q12[13]; + a_Q12_14 = a_Q12[14]; + a_Q12_15 = a_Q12[15]; + + long long temp64; + + silk_assert( nStatesDelayedDecision > 0 ); + + shp_lag_ptr = &NSQ->sLTP_shp_Q14[ NSQ->sLTP_shp_buf_idx - lag + HARM_SHAPE_FIR_TAPS / 2 ]; + pred_lag_ptr = &sLTP_Q15[ NSQ->sLTP_buf_idx - lag + LTP_ORDER / 2 ]; + Gain_Q10 = silk_RSHIFT( Gain_Q16, 6 ); + + for( i = 0; i < length; i++ ) { + /* Perform common calculations used in all states */ + + /* Long-term prediction */ + if( signalType == TYPE_VOICED ) { + /* Unrolled loop */ + /* Avoids introducing a bias because silk_SMLAWB() always rounds to -inf */ + temp64 = __builtin_mips_mult(pred_lag_ptr[ 0 ], b_Q14_0 ); + temp64 = __builtin_mips_madd( temp64, pred_lag_ptr[ -1 ], b_Q14_1 ); + temp64 = __builtin_mips_madd( temp64, pred_lag_ptr[ -2 ], b_Q14_2 ); + temp64 = __builtin_mips_madd( temp64, pred_lag_ptr[ -3 ], b_Q14_3 ); + temp64 = __builtin_mips_madd( temp64, pred_lag_ptr[ -4 ], b_Q14_4 ); + temp64 += 32768; + LTP_pred_Q14 = __builtin_mips_extr_w(temp64, 16); + LTP_pred_Q14 = silk_LSHIFT( LTP_pred_Q14, 1 ); /* Q13 -> Q14 */ + pred_lag_ptr++; + } else { + LTP_pred_Q14 = 0; + } + + /* Long-term shaping */ + if( lag > 0 ) { + /* Symmetric, packed FIR coefficients */ + n_LTP_Q14 = silk_SMULWB( silk_ADD32( shp_lag_ptr[ 0 ], shp_lag_ptr[ -2 ] ), HarmShapeFIRPacked_Q14 ); + n_LTP_Q14 = silk_SMLAWT( n_LTP_Q14, shp_lag_ptr[ -1 ], HarmShapeFIRPacked_Q14 ); + n_LTP_Q14 = silk_SUB_LSHIFT32( LTP_pred_Q14, n_LTP_Q14, 2 ); /* Q12 -> Q14 */ + shp_lag_ptr++; + } else { + n_LTP_Q14 = 0; + } + + for( k = 0; k < nStatesDelayedDecision; k++ ) { + /* Delayed decision state */ + psDD = &psDelDec[ k ]; + + /* Sample state */ + psSS = psSampleState[ k ]; + + /* Generate dither */ + psDD->Seed = silk_RAND( psDD->Seed ); + + /* Pointer used in short term prediction and shaping */ + psLPC_Q14 = &psDD->sLPC_Q14[ NSQ_LPC_BUF_LENGTH - 1 + i ]; + /* Short-term prediction */ + silk_assert( predictLPCOrder == 10 || predictLPCOrder == 16 ); + temp64 = __builtin_mips_mult(psLPC_Q14[ 0 ], a_Q12_0 ); + temp64 = __builtin_mips_madd( temp64, psLPC_Q14[ -1 ], a_Q12_1 ); + temp64 = __builtin_mips_madd( temp64, psLPC_Q14[ -2 ], a_Q12_2 ); + temp64 = __builtin_mips_madd( temp64, psLPC_Q14[ -3 ], a_Q12_3 ); + temp64 = __builtin_mips_madd( temp64, psLPC_Q14[ -4 ], a_Q12_4 ); + temp64 = __builtin_mips_madd( temp64, psLPC_Q14[ -5 ], a_Q12_5 ); + temp64 = __builtin_mips_madd( temp64, psLPC_Q14[ -6 ], a_Q12_6 ); + temp64 = __builtin_mips_madd( temp64, psLPC_Q14[ -7 ], a_Q12_7 ); + temp64 = __builtin_mips_madd( temp64, psLPC_Q14[ -8 ], a_Q12_8 ); + temp64 = __builtin_mips_madd( temp64, psLPC_Q14[ -9 ], a_Q12_9 ); + if( predictLPCOrder == 16 ) { + temp64 = __builtin_mips_madd( temp64, psLPC_Q14[ -10 ], a_Q12_10 ); + temp64 = __builtin_mips_madd( temp64, psLPC_Q14[ -11 ], a_Q12_11 ); + temp64 = __builtin_mips_madd( temp64, psLPC_Q14[ -12 ], a_Q12_12 ); + temp64 = __builtin_mips_madd( temp64, psLPC_Q14[ -13 ], a_Q12_13 ); + temp64 = __builtin_mips_madd( temp64, psLPC_Q14[ -14 ], a_Q12_14 ); + temp64 = __builtin_mips_madd( temp64, psLPC_Q14[ -15 ], a_Q12_15 ); + } + temp64 += 32768; + LPC_pred_Q14 = __builtin_mips_extr_w(temp64, 16); + + LPC_pred_Q14 = silk_LSHIFT( LPC_pred_Q14, 4 ); /* Q10 -> Q14 */ + + /* Noise shape feedback */ + silk_assert( ( shapingLPCOrder & 1 ) == 0 ); /* check that order is even */ + /* Output of lowpass section */ + tmp2 = silk_SMLAWB( psLPC_Q14[ 0 ], psDD->sAR2_Q14[ 0 ], warping_Q16 ); + /* Output of allpass section */ + tmp1 = silk_SMLAWB( psDD->sAR2_Q14[ 0 ], psDD->sAR2_Q14[ 1 ] - tmp2, warping_Q16 ); + psDD->sAR2_Q14[ 0 ] = tmp2; + + temp64 = __builtin_mips_mult(tmp2, AR_shp_Q13[ 0 ] ); + + prev = psDD->sAR2_Q14[ 1 ]; + + /* Loop over allpass sections */ + for( j = 2; j < shapingLPCOrder; j += 2 ) { + cur = psDD->sAR2_Q14[ j ]; + next = psDD->sAR2_Q14[ j+1 ]; + /* Output of allpass section */ + tmp2 = silk_SMLAWB( prev, cur - tmp1, warping_Q16 ); + psDD->sAR2_Q14[ j - 1 ] = tmp1; + temp64 = __builtin_mips_madd( temp64, tmp1, AR_shp_Q13[ j - 1 ] ); + temp64 = __builtin_mips_madd( temp64, tmp2, AR_shp_Q13[ j ] ); + /* Output of allpass section */ + tmp1 = silk_SMLAWB( cur, next - tmp2, warping_Q16 ); + psDD->sAR2_Q14[ j + 0 ] = tmp2; + prev = next; + } + psDD->sAR2_Q14[ shapingLPCOrder - 1 ] = tmp1; + temp64 = __builtin_mips_madd( temp64, tmp1, AR_shp_Q13[ shapingLPCOrder - 1 ] ); + temp64 += 32768; + n_AR_Q14 = __builtin_mips_extr_w(temp64, 16); + n_AR_Q14 = silk_LSHIFT( n_AR_Q14, 1 ); /* Q11 -> Q12 */ + n_AR_Q14 = silk_SMLAWB( n_AR_Q14, psDD->LF_AR_Q14, Tilt_Q14 ); /* Q12 */ + n_AR_Q14 = silk_LSHIFT( n_AR_Q14, 2 ); /* Q12 -> Q14 */ + + n_LF_Q14 = silk_SMULWB( psDD->Shape_Q14[ *smpl_buf_idx ], LF_shp_Q14 ); /* Q12 */ + n_LF_Q14 = silk_SMLAWT( n_LF_Q14, psDD->LF_AR_Q14, LF_shp_Q14 ); /* Q12 */ + n_LF_Q14 = silk_LSHIFT( n_LF_Q14, 2 ); /* Q12 -> Q14 */ + + /* Input minus prediction plus noise feedback */ + /* r = x[ i ] - LTP_pred - LPC_pred + n_AR + n_Tilt + n_LF + n_LTP */ + tmp1 = silk_ADD32( n_AR_Q14, n_LF_Q14 ); /* Q14 */ + tmp2 = silk_ADD32( n_LTP_Q14, LPC_pred_Q14 ); /* Q13 */ + tmp1 = silk_SUB32( tmp2, tmp1 ); /* Q13 */ + tmp1 = silk_RSHIFT_ROUND( tmp1, 4 ); /* Q10 */ + + r_Q10 = silk_SUB32( x_Q10[ i ], tmp1 ); /* residual error Q10 */ + + /* Flip sign depending on dither */ + if ( psDD->Seed < 0 ) { + r_Q10 = -r_Q10; + } + r_Q10 = silk_LIMIT_32( r_Q10, -(31 << 10), 30 << 10 ); + + /* Find two quantization level candidates and measure their rate-distortion */ + q1_Q10 = silk_SUB32( r_Q10, offset_Q10 ); + q1_Q0 = silk_RSHIFT( q1_Q10, 10 ); + if( q1_Q0 > 0 ) { + q1_Q10 = silk_SUB32( silk_LSHIFT( q1_Q0, 10 ), QUANT_LEVEL_ADJUST_Q10 ); + q1_Q10 = silk_ADD32( q1_Q10, offset_Q10 ); + q2_Q10 = silk_ADD32( q1_Q10, 1024 ); + rd1_Q10 = silk_SMULBB( q1_Q10, Lambda_Q10 ); + rd2_Q10 = silk_SMULBB( q2_Q10, Lambda_Q10 ); + } else if( q1_Q0 == 0 ) { + q1_Q10 = offset_Q10; + q2_Q10 = silk_ADD32( q1_Q10, 1024 - QUANT_LEVEL_ADJUST_Q10 ); + rd1_Q10 = silk_SMULBB( q1_Q10, Lambda_Q10 ); + rd2_Q10 = silk_SMULBB( q2_Q10, Lambda_Q10 ); + } else if( q1_Q0 == -1 ) { + q2_Q10 = offset_Q10; + q1_Q10 = silk_SUB32( q2_Q10, 1024 - QUANT_LEVEL_ADJUST_Q10 ); + rd1_Q10 = silk_SMULBB( -q1_Q10, Lambda_Q10 ); + rd2_Q10 = silk_SMULBB( q2_Q10, Lambda_Q10 ); + } else { /* q1_Q0 < -1 */ + q1_Q10 = silk_ADD32( silk_LSHIFT( q1_Q0, 10 ), QUANT_LEVEL_ADJUST_Q10 ); + q1_Q10 = silk_ADD32( q1_Q10, offset_Q10 ); + q2_Q10 = silk_ADD32( q1_Q10, 1024 ); + rd1_Q10 = silk_SMULBB( -q1_Q10, Lambda_Q10 ); + rd2_Q10 = silk_SMULBB( -q2_Q10, Lambda_Q10 ); + } + rr_Q10 = silk_SUB32( r_Q10, q1_Q10 ); + rd1_Q10 = silk_RSHIFT( silk_SMLABB( rd1_Q10, rr_Q10, rr_Q10 ), 10 ); + rr_Q10 = silk_SUB32( r_Q10, q2_Q10 ); + rd2_Q10 = silk_RSHIFT( silk_SMLABB( rd2_Q10, rr_Q10, rr_Q10 ), 10 ); + + if( rd1_Q10 < rd2_Q10 ) { + psSS[ 0 ].RD_Q10 = silk_ADD32( psDD->RD_Q10, rd1_Q10 ); + psSS[ 1 ].RD_Q10 = silk_ADD32( psDD->RD_Q10, rd2_Q10 ); + psSS[ 0 ].Q_Q10 = q1_Q10; + psSS[ 1 ].Q_Q10 = q2_Q10; + } else { + psSS[ 0 ].RD_Q10 = silk_ADD32( psDD->RD_Q10, rd2_Q10 ); + psSS[ 1 ].RD_Q10 = silk_ADD32( psDD->RD_Q10, rd1_Q10 ); + psSS[ 0 ].Q_Q10 = q2_Q10; + psSS[ 1 ].Q_Q10 = q1_Q10; + } + + /* Update states for best quantization */ + + /* Quantized excitation */ + exc_Q14 = silk_LSHIFT32( psSS[ 0 ].Q_Q10, 4 ); + if ( psDD->Seed < 0 ) { + exc_Q14 = -exc_Q14; + } + + /* Add predictions */ + LPC_exc_Q14 = silk_ADD32( exc_Q14, LTP_pred_Q14 ); + xq_Q14 = silk_ADD32( LPC_exc_Q14, LPC_pred_Q14 ); + + /* Update states */ + sLF_AR_shp_Q14 = silk_SUB32( xq_Q14, n_AR_Q14 ); + psSS[ 0 ].sLTP_shp_Q14 = silk_SUB32( sLF_AR_shp_Q14, n_LF_Q14 ); + psSS[ 0 ].LF_AR_Q14 = sLF_AR_shp_Q14; + psSS[ 0 ].LPC_exc_Q14 = LPC_exc_Q14; + psSS[ 0 ].xq_Q14 = xq_Q14; + + /* Update states for second best quantization */ + + /* Quantized excitation */ + exc_Q14 = silk_LSHIFT32( psSS[ 1 ].Q_Q10, 4 ); + if ( psDD->Seed < 0 ) { + exc_Q14 = -exc_Q14; + } + + + /* Add predictions */ + LPC_exc_Q14 = silk_ADD32( exc_Q14, LTP_pred_Q14 ); + xq_Q14 = silk_ADD32( LPC_exc_Q14, LPC_pred_Q14 ); + + /* Update states */ + sLF_AR_shp_Q14 = silk_SUB32( xq_Q14, n_AR_Q14 ); + psSS[ 1 ].sLTP_shp_Q14 = silk_SUB32( sLF_AR_shp_Q14, n_LF_Q14 ); + psSS[ 1 ].LF_AR_Q14 = sLF_AR_shp_Q14; + psSS[ 1 ].LPC_exc_Q14 = LPC_exc_Q14; + psSS[ 1 ].xq_Q14 = xq_Q14; + } + + *smpl_buf_idx = ( *smpl_buf_idx - 1 ) & DECISION_DELAY_MASK; /* Index to newest samples */ + last_smple_idx = ( *smpl_buf_idx + decisionDelay ) & DECISION_DELAY_MASK; /* Index to decisionDelay old samples */ + + /* Find winner */ + RDmin_Q10 = psSampleState[ 0 ][ 0 ].RD_Q10; + Winner_ind = 0; + for( k = 1; k < nStatesDelayedDecision; k++ ) { + if( psSampleState[ k ][ 0 ].RD_Q10 < RDmin_Q10 ) { + RDmin_Q10 = psSampleState[ k ][ 0 ].RD_Q10; + Winner_ind = k; + } + } + + /* Increase RD values of expired states */ + Winner_rand_state = psDelDec[ Winner_ind ].RandState[ last_smple_idx ]; + for( k = 0; k < nStatesDelayedDecision; k++ ) { + if( psDelDec[ k ].RandState[ last_smple_idx ] != Winner_rand_state ) { + psSampleState[ k ][ 0 ].RD_Q10 = silk_ADD32( psSampleState[ k ][ 0 ].RD_Q10, silk_int32_MAX >> 4 ); + psSampleState[ k ][ 1 ].RD_Q10 = silk_ADD32( psSampleState[ k ][ 1 ].RD_Q10, silk_int32_MAX >> 4 ); + silk_assert( psSampleState[ k ][ 0 ].RD_Q10 >= 0 ); + } + } + + /* Find worst in first set and best in second set */ + RDmax_Q10 = psSampleState[ 0 ][ 0 ].RD_Q10; + RDmin_Q10 = psSampleState[ 0 ][ 1 ].RD_Q10; + RDmax_ind = 0; + RDmin_ind = 0; + for( k = 1; k < nStatesDelayedDecision; k++ ) { + /* find worst in first set */ + if( psSampleState[ k ][ 0 ].RD_Q10 > RDmax_Q10 ) { + RDmax_Q10 = psSampleState[ k ][ 0 ].RD_Q10; + RDmax_ind = k; + } + /* find best in second set */ + if( psSampleState[ k ][ 1 ].RD_Q10 < RDmin_Q10 ) { + RDmin_Q10 = psSampleState[ k ][ 1 ].RD_Q10; + RDmin_ind = k; + } + } + + /* Replace a state if best from second set outperforms worst in first set */ + if( RDmin_Q10 < RDmax_Q10 ) { + silk_memcpy( ( (opus_int32 *)&psDelDec[ RDmax_ind ] ) + i, + ( (opus_int32 *)&psDelDec[ RDmin_ind ] ) + i, sizeof( NSQ_del_dec_struct ) - i * sizeof( opus_int32) ); + silk_memcpy( &psSampleState[ RDmax_ind ][ 0 ], &psSampleState[ RDmin_ind ][ 1 ], sizeof( NSQ_sample_struct ) ); + } + + /* Write samples from winner to output and long-term filter states */ + psDD = &psDelDec[ Winner_ind ]; + if( subfr > 0 || i >= decisionDelay ) { + pulses[ i - decisionDelay ] = (opus_int8)silk_RSHIFT_ROUND( psDD->Q_Q10[ last_smple_idx ], 10 ); + xq[ i - decisionDelay ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( + silk_SMULWW( psDD->Xq_Q14[ last_smple_idx ], delayedGain_Q10[ last_smple_idx ] ), 8 ) ); + NSQ->sLTP_shp_Q14[ NSQ->sLTP_shp_buf_idx - decisionDelay ] = psDD->Shape_Q14[ last_smple_idx ]; + sLTP_Q15[ NSQ->sLTP_buf_idx - decisionDelay ] = psDD->Pred_Q15[ last_smple_idx ]; + } + NSQ->sLTP_shp_buf_idx++; + NSQ->sLTP_buf_idx++; + + /* Update states */ + for( k = 0; k < nStatesDelayedDecision; k++ ) { + psDD = &psDelDec[ k ]; + psSS = &psSampleState[ k ][ 0 ]; + psDD->LF_AR_Q14 = psSS->LF_AR_Q14; + psDD->sLPC_Q14[ NSQ_LPC_BUF_LENGTH + i ] = psSS->xq_Q14; + psDD->Xq_Q14[ *smpl_buf_idx ] = psSS->xq_Q14; + psDD->Q_Q10[ *smpl_buf_idx ] = psSS->Q_Q10; + psDD->Pred_Q15[ *smpl_buf_idx ] = silk_LSHIFT32( psSS->LPC_exc_Q14, 1 ); + psDD->Shape_Q14[ *smpl_buf_idx ] = psSS->sLTP_shp_Q14; + psDD->Seed = silk_ADD32_ovflw( psDD->Seed, silk_RSHIFT_ROUND( psSS->Q_Q10, 10 ) ); + psDD->RandState[ *smpl_buf_idx ] = psDD->Seed; + psDD->RD_Q10 = psSS->RD_Q10; + } + delayedGain_Q10[ *smpl_buf_idx ] = Gain_Q10; + } + /* Update LPC states */ + for( k = 0; k < nStatesDelayedDecision; k++ ) { + psDD = &psDelDec[ k ]; + silk_memcpy( psDD->sLPC_Q14, &psDD->sLPC_Q14[ length ], NSQ_LPC_BUF_LENGTH * sizeof( opus_int32 ) ); + } +} + +#endif /* __NSQ_DEL_DEC_MIPSR1_H__ */ diff --git a/drivers/opus/silk/mips/macros_mipsr1.h b/drivers/opus/silk/mips/macros_mipsr1.h new file mode 100644 index 0000000000..12ed981a6e --- /dev/null +++ b/drivers/opus/silk/mips/macros_mipsr1.h @@ -0,0 +1,92 @@ +/*********************************************************************** +Copyright (c) 2006-2011, Skype Limited. All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +- Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. +- Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. +- Neither the name of Internet Society, IETF or IETF Trust, nor the +names of specific contributors, may be used to endorse or promote +products derived from this software without specific prior written +permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +***********************************************************************/ + + +#ifndef __SILK_MACROS_MIPSR1_H__ +#define __SILK_MACROS_MIPSR1_H__ + +#define mips_clz(x) __builtin_clz(x) + +#undef silk_SMULWB +static inline int silk_SMULWB(int a, int b) +{ + long long ac; + int c; + + ac = __builtin_mips_mult(a, (opus_int32)(opus_int16)b); + c = __builtin_mips_extr_w(ac, 16); + + return c; +} + +#undef silk_SMLAWB +#define silk_SMLAWB(a32, b32, c32) ((a32) + silk_SMULWB(b32, c32)) + +#undef silk_SMULWW +static inline int silk_SMULWW(int a, int b) +{ + long long ac; + int c; + + ac = __builtin_mips_mult(a, b); + c = __builtin_mips_extr_w(ac, 16); + + return c; +} + +#undef silk_SMLAWW +static inline int silk_SMLAWW(int a, int b, int c) +{ + long long ac; + int res; + + ac = __builtin_mips_mult(b, c); + res = __builtin_mips_extr_w(ac, 16); + res += a; + + return res; +} + +#define OVERRIDE_silk_CLZ16 +static inline opus_int32 silk_CLZ16(opus_int16 in16) +{ + int re32; + opus_int32 in32 = (opus_int32 )in16; + re32 = mips_clz(in32); + re32-=16; + return re32; +} + +#define OVERRIDE_silk_CLZ32 +static inline opus_int32 silk_CLZ32(opus_int32 in32) +{ + int re32; + re32 = mips_clz(in32); + return re32; +} + +#endif /* __SILK_MACROS_MIPSR1_H__ */ diff --git a/drivers/opus/silk/mips/sigproc_fix_mipsr1.h b/drivers/opus/silk/mips/sigproc_fix_mipsr1.h new file mode 100644 index 0000000000..3b0a695365 --- /dev/null +++ b/drivers/opus/silk/mips/sigproc_fix_mipsr1.h @@ -0,0 +1,65 @@ +/*********************************************************************** +Copyright (c) 2006-2011, Skype Limited. All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +- Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. +- Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. +- Neither the name of Internet Society, IETF or IETF Trust, nor the +names of specific contributors, may be used to endorse or promote +products derived from this software without specific prior written +permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +***********************************************************************/ + +#ifndef SILK_SIGPROC_FIX_MIPSR1_H +#define SILK_SIGPROC_FIX_MIPSR1_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#undef silk_SAT16 +static inline short int silk_SAT16(int a) +{ + int c; + c = __builtin_mips_shll_s_w(a, 16); + c = c>>16; + + return c; +} + +#undef silk_LSHIFT_SAT32 +static inline int silk_LSHIFT_SAT32(int a, int shift) +{ + int r; + + r = __builtin_mips_shll_s_w(a, shift); + + return r; +} + +#undef silk_RSHIFT_ROUND +static inline int silk_RSHIFT_ROUND(int a, int shift) +{ + int r; + + r = __builtin_mips_shra_r_w(a, shift); + return r; +} + +#endif /* SILK_SIGPROC_FIX_MIPSR1_H */ diff --git a/drivers/opus/silk/pitch_est_tables.c b/drivers/opus/silk/pitch_est_tables.c index 7555f5b04b..eb17bf0b26 100644 --- a/drivers/opus/silk/pitch_est_tables.c +++ b/drivers/opus/silk/pitch_est_tables.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/typedef.h" #include "opus/silk/pitch_est_defines.h" diff --git a/drivers/opus/silk/process_NLSFs.c b/drivers/opus/silk/process_NLSFs.c index 9e6ebf827c..9d8f96d7b7 100644 --- a/drivers/opus/silk/process_NLSFs.c +++ b/drivers/opus/silk/process_NLSFs.c @@ -24,12 +24,9 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" /* Limit, stabilize, convert and quantize NLSFs */ void silk_process_NLSFs( diff --git a/drivers/opus/silk/quant_LTP_gains.c b/drivers/opus/silk/quant_LTP_gains.c index f6fff470f4..ffc3cb24ab 100644 --- a/drivers/opus/silk/quant_LTP_gains.c +++ b/drivers/opus/silk/quant_LTP_gains.c @@ -24,23 +24,21 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" #include "opus/silk/tuning_parameters.h" void silk_quant_LTP_gains( opus_int16 B_Q14[ MAX_NB_SUBFR * LTP_ORDER ], /* I/O (un)quantized LTP gains */ opus_int8 cbk_index[ MAX_NB_SUBFR ], /* O Codebook Index */ opus_int8 *periodicity_index, /* O Periodicity Index */ - opus_int32 *sum_log_gain_Q7, /* I/O Cumulative max prediction gain */ + opus_int32 *sum_log_gain_Q7, /* I/O Cumulative max prediction gain */ const opus_int32 W_Q18[ MAX_NB_SUBFR*LTP_ORDER*LTP_ORDER ], /* I Error Weights in Q18 */ opus_int mu_Q9, /* I Mu value (R/D tradeoff) */ opus_int lowComplexity, /* I Flag for low complexity */ - const opus_int nb_subfr /* I number of subframes */ + const opus_int nb_subfr, /* I number of subframes */ + int arch /* I Run-time architecture */ ) { opus_int j, k, cbk_size; @@ -51,7 +49,7 @@ void silk_quant_LTP_gains( const opus_int16 *b_Q14_ptr; const opus_int32 *W_Q18_ptr; opus_int32 rate_dist_Q14_subfr, rate_dist_Q14, min_rate_dist_Q14; - opus_int32 sum_log_gain_tmp_Q7, best_sum_log_gain_Q7, max_gain_Q7, gain_Q7; + opus_int32 sum_log_gain_tmp_Q7, best_sum_log_gain_Q7, max_gain_Q7, gain_Q7; /***************************************************/ /* iterate over different codebooks with different */ @@ -74,23 +72,24 @@ void silk_quant_LTP_gains( b_Q14_ptr = B_Q14; rate_dist_Q14 = 0; - sum_log_gain_tmp_Q7 = *sum_log_gain_Q7; + sum_log_gain_tmp_Q7 = *sum_log_gain_Q7; for( j = 0; j < nb_subfr; j++ ) { - max_gain_Q7 = silk_log2lin( ( SILK_FIX_CONST( MAX_SUM_LOG_GAIN_DB / 6.0, 7 ) - sum_log_gain_tmp_Q7 ) - + SILK_FIX_CONST( 7, 7 ) ) - gain_safety; + max_gain_Q7 = silk_log2lin( ( SILK_FIX_CONST( MAX_SUM_LOG_GAIN_DB / 6.0, 7 ) - sum_log_gain_tmp_Q7 ) + + SILK_FIX_CONST( 7, 7 ) ) - gain_safety; silk_VQ_WMat_EC( &temp_idx[ j ], /* O index of best codebook vector */ &rate_dist_Q14_subfr, /* O best weighted quantization error + mu * rate */ - &gain_Q7, /* O sum of absolute LTP coefficients */ + &gain_Q7, /* O sum of absolute LTP coefficients */ b_Q14_ptr, /* I input vector to be quantized */ W_Q18_ptr, /* I weighting matrix */ cbk_ptr_Q7, /* I codebook */ cbk_gain_ptr_Q7, /* I codebook effective gains */ cl_ptr_Q5, /* I code length for each codebook vector */ mu_Q9, /* I tradeoff between weighted error and rate */ - max_gain_Q7, /* I maximum sum of absolute LTP coefficients */ - cbk_size /* I number of vectors in codebook */ + max_gain_Q7, /* I maximum sum of absolute LTP coefficients */ + cbk_size, /* I number of vectors in codebook */ + arch /* I Run-time architecture */ ); rate_dist_Q14 = silk_ADD_POS_SAT32( rate_dist_Q14, rate_dist_Q14_subfr ); @@ -108,7 +107,7 @@ void silk_quant_LTP_gains( min_rate_dist_Q14 = rate_dist_Q14; *periodicity_index = (opus_int8)k; silk_memcpy( cbk_index, temp_idx, nb_subfr * sizeof( opus_int8 ) ); - best_sum_log_gain_Q7 = sum_log_gain_tmp_Q7; + best_sum_log_gain_Q7 = sum_log_gain_tmp_Q7; } /* Break early in low-complexity mode if rate distortion is below threshold */ @@ -123,6 +122,5 @@ void silk_quant_LTP_gains( B_Q14[ j * LTP_ORDER + k ] = silk_LSHIFT( cbk_ptr_Q7[ cbk_index[ j ] * LTP_ORDER + k ], 7 ); } } - *sum_log_gain_Q7 = best_sum_log_gain_Q7; + *sum_log_gain_Q7 = best_sum_log_gain_Q7; } - diff --git a/drivers/opus/silk/resampler.c b/drivers/opus/silk/resampler.c index dde8fcddb1..12b2f92060 100644 --- a/drivers/opus/silk/resampler.c +++ b/drivers/opus/silk/resampler.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif /* * Matrix of resampling methods used: diff --git a/drivers/opus/silk/resampler_down2.c b/drivers/opus/silk/resampler_down2.c index dbc962c5ef..20a42c98a6 100644 --- a/drivers/opus/silk/resampler_down2.c +++ b/drivers/opus/silk/resampler_down2.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/SigProc_FIX.h" #include "opus/silk/resampler_rom.h" diff --git a/drivers/opus/silk/resampler_down2_3.c b/drivers/opus/silk/resampler_down2_3.c index 6ff32ff336..e01dd2bc72 100644 --- a/drivers/opus/silk/resampler_down2_3.c +++ b/drivers/opus/silk/resampler_down2_3.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/SigProc_FIX.h" #include "opus/silk/resampler_private.h" diff --git a/drivers/opus/silk/resampler_private_AR2.c b/drivers/opus/silk/resampler_private_AR2.c index e04319da4d..cc753ea704 100644 --- a/drivers/opus/silk/resampler_private_AR2.c +++ b/drivers/opus/silk/resampler_private_AR2.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/SigProc_FIX.h" #include "opus/silk/resampler_private.h" diff --git a/drivers/opus/silk/resampler_private_IIR_FIR.c b/drivers/opus/silk/resampler_private_IIR_FIR.c index 1d71ebd891..9a8733fbbb 100644 --- a/drivers/opus/silk/resampler_private_IIR_FIR.c +++ b/drivers/opus/silk/resampler_private_IIR_FIR.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/SigProc_FIX.h" #include "opus/silk/resampler_private.h" diff --git a/drivers/opus/silk/resampler_private_down_FIR.c b/drivers/opus/silk/resampler_private_down_FIR.c index 739c91db29..fb9acc60a7 100644 --- a/drivers/opus/silk/resampler_private_down_FIR.c +++ b/drivers/opus/silk/resampler_private_down_FIR.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/SigProc_FIX.h" #include "opus/silk/resampler_private.h" diff --git a/drivers/opus/silk/resampler_private_up2_HQ.c b/drivers/opus/silk/resampler_private_up2_HQ.c index a2b6ad432e..0b23c16dab 100644 --- a/drivers/opus/silk/resampler_private_up2_HQ.c +++ b/drivers/opus/silk/resampler_private_up2_HQ.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/SigProc_FIX.h" #include "opus/silk/resampler_private.h" diff --git a/drivers/opus/silk/resampler_rom.c b/drivers/opus/silk/resampler_rom.c index d564087051..7079efe1dc 100644 --- a/drivers/opus/silk/resampler_rom.c +++ b/drivers/opus/silk/resampler_rom.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif /* Filter coefficients for IIR/FIR polyphase resampling * * Total size: 179 Words (358 Bytes) */ @@ -41,36 +38,36 @@ POSSIBILITY OF SUCH DAMAGE. /* Tables with IIR and FIR coefficients for fractional downsamplers (123 Words) */ silk_DWORD_ALIGN const opus_int16 silk_Resampler_3_4_COEFS[ 2 + 3 * RESAMPLER_DOWN_ORDER_FIR0 / 2 ] = { - -20694, -13867, - -49, 64, 17, -157, 353, -496, 163, 11047, 22205, - -39, 6, 91, -170, 186, 23, -896, 6336, 19928, - -19, -36, 102, -89, -24, 328, -951, 2568, 15909, + -20694, -13867, + -49, 64, 17, -157, 353, -496, 163, 11047, 22205, + -39, 6, 91, -170, 186, 23, -896, 6336, 19928, + -19, -36, 102, -89, -24, 328, -951, 2568, 15909, }; silk_DWORD_ALIGN const opus_int16 silk_Resampler_2_3_COEFS[ 2 + 2 * RESAMPLER_DOWN_ORDER_FIR0 / 2 ] = { - -14457, -14019, - 64, 128, -122, 36, 310, -768, 584, 9267, 17733, - 12, 128, 18, -142, 288, -117, -865, 4123, 14459, + -14457, -14019, + 64, 128, -122, 36, 310, -768, 584, 9267, 17733, + 12, 128, 18, -142, 288, -117, -865, 4123, 14459, }; silk_DWORD_ALIGN const opus_int16 silk_Resampler_1_2_COEFS[ 2 + RESAMPLER_DOWN_ORDER_FIR1 / 2 ] = { - 616, -14323, - -10, 39, 58, -46, -84, 120, 184, -315, -541, 1284, 5380, 9024, + 616, -14323, + -10, 39, 58, -46, -84, 120, 184, -315, -541, 1284, 5380, 9024, }; silk_DWORD_ALIGN const opus_int16 silk_Resampler_1_3_COEFS[ 2 + RESAMPLER_DOWN_ORDER_FIR2 / 2 ] = { - 16102, -15162, - -13, 0, 20, 26, 5, -31, -43, -4, 65, 90, 7, -157, -248, -44, 593, 1583, 2612, 3271, + 16102, -15162, + -13, 0, 20, 26, 5, -31, -43, -4, 65, 90, 7, -157, -248, -44, 593, 1583, 2612, 3271, }; silk_DWORD_ALIGN const opus_int16 silk_Resampler_1_4_COEFS[ 2 + RESAMPLER_DOWN_ORDER_FIR2 / 2 ] = { - 22500, -15099, - 3, -14, -20, -15, 2, 25, 37, 25, -16, -71, -107, -79, 50, 292, 623, 982, 1288, 1464, + 22500, -15099, + 3, -14, -20, -15, 2, 25, 37, 25, -16, -71, -107, -79, 50, 292, 623, 982, 1288, 1464, }; silk_DWORD_ALIGN const opus_int16 silk_Resampler_1_6_COEFS[ 2 + RESAMPLER_DOWN_ORDER_FIR2 / 2 ] = { - 27540, -15257, - 17, 12, 8, 1, -10, -22, -30, -32, -22, 3, 44, 100, 168, 243, 317, 381, 429, 455, + 27540, -15257, + 17, 12, 8, 1, -10, -22, -30, -32, -22, 3, 44, 100, 168, 243, 317, 381, 429, 455, }; silk_DWORD_ALIGN const opus_int16 silk_Resampler_2_3_COEFS_LQ[ 2 + 2 * 2 ] = { @@ -81,16 +78,16 @@ silk_DWORD_ALIGN const opus_int16 silk_Resampler_2_3_COEFS_LQ[ 2 + 2 * 2 ] = { /* Table with interplation fractions of 1/24, 3/24, 5/24, ... , 23/24 : 23/24 (46 Words) */ silk_DWORD_ALIGN const opus_int16 silk_resampler_frac_FIR_12[ 12 ][ RESAMPLER_ORDER_FIR_12 / 2 ] = { - { 189, -600, 617, 30567 }, - { 117, -159, -1070, 29704 }, - { 52, 221, -2392, 28276 }, - { -4, 529, -3350, 26341 }, - { -48, 758, -3956, 23973 }, - { -80, 905, -4235, 21254 }, - { -99, 972, -4222, 18278 }, - { -107, 967, -3957, 15143 }, - { -103, 896, -3487, 11950 }, - { -91, 773, -2865, 8798 }, - { -71, 611, -2143, 5784 }, - { -46, 425, -1375, 2996 }, + { 189, -600, 617, 30567 }, + { 117, -159, -1070, 29704 }, + { 52, 221, -2392, 28276 }, + { -4, 529, -3350, 26341 }, + { -48, 758, -3956, 23973 }, + { -80, 905, -4235, 21254 }, + { -99, 972, -4222, 18278 }, + { -107, 967, -3957, 15143 }, + { -103, 896, -3487, 11950 }, + { -91, 773, -2865, 8798 }, + { -71, 611, -2143, 5784 }, + { -46, 425, -1375, 2996 }, }; diff --git a/drivers/opus/silk/shell_coder.c b/drivers/opus/silk/shell_coder.c index cd18ed638b..67a5446927 100644 --- a/drivers/opus/silk/shell_coder.c +++ b/drivers/opus/silk/shell_coder.c @@ -24,12 +24,9 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" /* shell coder; pulse-subframe length is hardcoded */ @@ -58,8 +55,8 @@ static OPUS_INLINE void encode_split( } static OPUS_INLINE void decode_split( - opus_int *p_child1, /* O pulse amplitude of first child subframe */ - opus_int *p_child2, /* O pulse amplitude of second child subframe */ + opus_int16 *p_child1, /* O pulse amplitude of first child subframe */ + opus_int16 *p_child2, /* O pulse amplitude of second child subframe */ ec_dec *psRangeDec, /* I/O Compressor data structure */ const opus_int p, /* I pulse amplitude of current subframe */ const opus_uint8 *shell_table /* I table of shell cdfs */ @@ -117,12 +114,12 @@ void silk_shell_encoder( /* Shell decoder, operates on one shell code frame of 16 pulses */ void silk_shell_decoder( - opus_int *pulses0, /* O data: nonnegative pulse amplitudes */ + opus_int16 *pulses0, /* O data: nonnegative pulse amplitudes */ ec_dec *psRangeDec, /* I/O Compressor data structure */ const opus_int pulses4 /* I number of pulses per pulse-subframe */ ) { - opus_int pulses3[ 2 ], pulses2[ 4 ], pulses1[ 8 ]; + opus_int16 pulses3[ 2 ], pulses2[ 4 ], pulses1[ 8 ]; /* this function operates on one shell code frame of 16 pulses */ silk_assert( SHELL_CODEC_FRAME_LENGTH == 16 ); diff --git a/drivers/opus/silk/sigm_Q15.c b/drivers/opus/silk/sigm_Q15.c index 4c78250472..3171d15f4a 100644 --- a/drivers/opus/silk/sigm_Q15.c +++ b/drivers/opus/silk/sigm_Q15.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif /* Approximate sigmoid function */ diff --git a/drivers/opus/silk/sort.c b/drivers/opus/silk/sort.c index 495292ad51..dd2988e5b8 100644 --- a/drivers/opus/silk/sort.c +++ b/drivers/opus/silk/sort.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif /* Insertion sort (fast for already almost sorted arrays): */ /* Best case: O(n) for an already sorted array */ diff --git a/drivers/opus/silk/stereo_LR_to_MS.c b/drivers/opus/silk/stereo_LR_to_MS.c index e17a36046e..cf8affa90b 100644 --- a/drivers/opus/silk/stereo_LR_to_MS.c +++ b/drivers/opus/silk/stereo_LR_to_MS.c @@ -24,12 +24,9 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" #include "opus/celt/stack_alloc.h" /* Convert Left/Right stereo signal to adaptive Mid/Side representation */ diff --git a/drivers/opus/silk/stereo_MS_to_LR.c b/drivers/opus/silk/stereo_MS_to_LR.c index dddb62c788..4f553eb694 100644 --- a/drivers/opus/silk/stereo_MS_to_LR.c +++ b/drivers/opus/silk/stereo_MS_to_LR.c @@ -24,12 +24,9 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" /* Convert adaptive Mid/Side representation to Left/Right stereo signal */ void silk_stereo_MS_to_LR( diff --git a/drivers/opus/silk/stereo_decode_pred.c b/drivers/opus/silk/stereo_decode_pred.c index d54faf137e..9e8abf39d0 100644 --- a/drivers/opus/silk/stereo_decode_pred.c +++ b/drivers/opus/silk/stereo_decode_pred.c @@ -24,12 +24,9 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" /* Decode mid/side predictors */ void silk_stereo_decode_pred( diff --git a/drivers/opus/silk/stereo_encode_pred.c b/drivers/opus/silk/stereo_encode_pred.c index d68922cf01..a864d404f6 100644 --- a/drivers/opus/silk/stereo_encode_pred.c +++ b/drivers/opus/silk/stereo_encode_pred.c @@ -24,12 +24,9 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" /* Entropy code the mid/side quantization indices */ void silk_stereo_encode_pred( diff --git a/drivers/opus/silk/stereo_find_predictor.c b/drivers/opus/silk/stereo_find_predictor.c index 1f529b28d0..c7fa3ac555 100644 --- a/drivers/opus/silk/stereo_find_predictor.c +++ b/drivers/opus/silk/stereo_find_predictor.c @@ -24,12 +24,9 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" /* Find least-squares prediction gain for one signal based on another and quantize it */ opus_int32 silk_stereo_find_predictor( /* O Returns predictor in Q13 */ diff --git a/drivers/opus/silk/stereo_quant_pred.c b/drivers/opus/silk/stereo_quant_pred.c index 3a4d9b31da..ff2971e7c1 100644 --- a/drivers/opus/silk/stereo_quant_pred.c +++ b/drivers/opus/silk/stereo_quant_pred.c @@ -24,12 +24,9 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif -#include "opus/silk/silk_main.h" +#include "opus/silk/main.h" /* Quantize mid/side predictors */ void silk_stereo_quant_pred( diff --git a/drivers/opus/silk/structs.h b/drivers/opus/silk/structs.h index c8c5dae844..a2876b62a2 100644 --- a/drivers/opus/silk/structs.h +++ b/drivers/opus/silk/structs.h @@ -171,7 +171,7 @@ typedef struct { opus_int32 pitchEstimationThreshold_Q16; /* Threshold for pitch estimator */ opus_int LTPQuantLowComplexity; /* Flag for low complexity LTP quantization */ opus_int mu_LTP_Q9; /* Rate-distortion tradeoff in LTP quantization */ - opus_int32 sum_log_gain_Q7; /* Cumulative max prediction gain */ + opus_int32 sum_log_gain_Q7; /* Cumulative max prediction gain */ opus_int NLSF_MSVQ_Survivors; /* Number of survivors in NLSF MSVQ */ opus_int first_frame_after_reset; /* Flag for deactivating NLSF interpolation, pitch prediction */ opus_int controlled_since_last_payload; /* Flag for ensuring codec_control only runs once per packet */ diff --git a/drivers/opus/silk/sum_sqr_shift.c b/drivers/opus/silk/sum_sqr_shift.c index 7e2a97b530..1d1da449f4 100644 --- a/drivers/opus/silk/sum_sqr_shift.c +++ b/drivers/opus/silk/sum_sqr_shift.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/SigProc_FIX.h" @@ -53,6 +50,7 @@ void silk_sum_sqr_shift( /* Scale down */ nrg = (opus_int32)silk_RSHIFT_uint( (opus_uint32)nrg, 2 ); shft = 2; + i+=2; break; } } diff --git a/drivers/opus/silk/table_LSF_cos.c b/drivers/opus/silk/table_LSF_cos.c index 818a532c28..d350df9add 100644 --- a/drivers/opus/silk/table_LSF_cos.c +++ b/drivers/opus/silk/table_LSF_cos.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/tables.h" diff --git a/drivers/opus/silk/tables.h b/drivers/opus/silk/tables.h index 0dc7c37545..2ad69eec80 100644 --- a/drivers/opus/silk/tables.h +++ b/drivers/opus/silk/tables.h @@ -47,8 +47,8 @@ extern const opus_uint8 silk_pitch_contour_NB_iCDF[ 11 ]; extern const opus_uint8 silk_pitch_contour_10_ms_iCDF[ 12 ]; /* 12 */ extern const opus_uint8 silk_pitch_contour_10_ms_NB_iCDF[ 3 ]; /* 3 */ -extern const opus_uint8 silk_pulses_per_block_iCDF[ N_RATE_LEVELS ][ MAX_PULSES + 2 ]; /* 180 */ -extern const opus_uint8 silk_pulses_per_block_BITS_Q5[ N_RATE_LEVELS - 1 ][ MAX_PULSES + 2 ]; /* 162 */ +extern const opus_uint8 silk_pulses_per_block_iCDF[ N_RATE_LEVELS ][ SILK_MAX_PULSES + 2 ]; /* 180 */ +extern const opus_uint8 silk_pulses_per_block_BITS_Q5[ N_RATE_LEVELS - 1 ][ SILK_MAX_PULSES + 2 ]; /* 162 */ extern const opus_uint8 silk_rate_levels_iCDF[ 2 ][ N_RATE_LEVELS - 1 ]; /* 18 */ extern const opus_uint8 silk_rate_levels_BITS_Q5[ 2 ][ N_RATE_LEVELS - 1 ]; /* 18 */ @@ -59,7 +59,7 @@ extern const opus_uint8 silk_shell_code_table0[ 152 ]; extern const opus_uint8 silk_shell_code_table1[ 152 ]; /* 152 */ extern const opus_uint8 silk_shell_code_table2[ 152 ]; /* 152 */ extern const opus_uint8 silk_shell_code_table3[ 152 ]; /* 152 */ -extern const opus_uint8 silk_shell_code_table_offsets[ MAX_PULSES + 1 ]; /* 17 */ +extern const opus_uint8 silk_shell_code_table_offsets[ SILK_MAX_PULSES + 1 ]; /* 17 */ extern const opus_uint8 silk_lsb_iCDF[ 2 ]; /* 2 */ diff --git a/drivers/opus/silk/tables_LTP.c b/drivers/opus/silk/tables_LTP.c index 6a05698252..9f500b25f2 100644 --- a/drivers/opus/silk/tables_LTP.c +++ b/drivers/opus/silk/tables_LTP.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/tables.h" diff --git a/drivers/opus/silk/tables_NLSF_CB_NB_MB.c b/drivers/opus/silk/tables_NLSF_CB_NB_MB.c index 66c2fd4036..d1cf99356d 100644 --- a/drivers/opus/silk/tables_NLSF_CB_NB_MB.c +++ b/drivers/opus/silk/tables_NLSF_CB_NB_MB.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/tables.h" diff --git a/drivers/opus/silk/tables_NLSF_CB_WB.c b/drivers/opus/silk/tables_NLSF_CB_WB.c index 366f1bc887..5ee6e880c4 100644 --- a/drivers/opus/silk/tables_NLSF_CB_WB.c +++ b/drivers/opus/silk/tables_NLSF_CB_WB.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/tables.h" diff --git a/drivers/opus/silk/tables_gain.c b/drivers/opus/silk/tables_gain.c index efb5b899b8..e1e4319d7d 100644 --- a/drivers/opus/silk/tables_gain.c +++ b/drivers/opus/silk/tables_gain.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/tables.h" diff --git a/drivers/opus/silk/tables_other.c b/drivers/opus/silk/tables_other.c index 5e588fbf0c..3713ff8227 100644 --- a/drivers/opus/silk/tables_other.c +++ b/drivers/opus/silk/tables_other.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/structs.h" #include "opus/silk/define.h" diff --git a/drivers/opus/silk/tables_pitch_lag.c b/drivers/opus/silk/tables_pitch_lag.c index e1c4617d0a..f435b7e016 100644 --- a/drivers/opus/silk/tables_pitch_lag.c +++ b/drivers/opus/silk/tables_pitch_lag.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/tables.h" diff --git a/drivers/opus/silk/tables_pulses_per_block.c b/drivers/opus/silk/tables_pulses_per_block.c index a1e2fb03d8..21f430791a 100644 --- a/drivers/opus/silk/tables_pulses_per_block.c +++ b/drivers/opus/silk/tables_pulses_per_block.c @@ -24,10 +24,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/silk/tables.h" diff --git a/drivers/opus/silk/tuning_parameters.h b/drivers/opus/silk/tuning_parameters.h index e1057bbaae..5b8f404235 100644 --- a/drivers/opus/silk/tuning_parameters.h +++ b/drivers/opus/silk/tuning_parameters.h @@ -64,7 +64,7 @@ extern "C" #define MU_LTP_QUANT_WB 0.02f /* Max cumulative LTP gain */ -#define MAX_SUM_LOG_GAIN_DB 250.0f +#define MAX_SUM_LOG_GAIN_DB 250.0f /***********************/ /* High pass filtering */ diff --git a/drivers/opus/silk/x86/NSQ_del_dec_sse.c b/drivers/opus/silk/x86/NSQ_del_dec_sse.c new file mode 100644 index 0000000000..e9afbba01b --- /dev/null +++ b/drivers/opus/silk/x86/NSQ_del_dec_sse.c @@ -0,0 +1,854 @@ +/* Copyright (c) 2014, Cisco Systems, INC + Written by XiangMingZhu WeiZhou MinPeng YanWang + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#include "opus/opus_config.h" + +#include <xmmintrin.h> +#include <emmintrin.h> +#include <smmintrin.h> +#include "opus/silk/main.h" +#include "opus/celt/x86/x86cpu.h" + +#include "opus/celt/stack_alloc.h" + +typedef struct { + opus_int32 sLPC_Q14[ MAX_SUB_FRAME_LENGTH + NSQ_LPC_BUF_LENGTH ]; + opus_int32 RandState[ DECISION_DELAY ]; + opus_int32 Q_Q10[ DECISION_DELAY ]; + opus_int32 Xq_Q14[ DECISION_DELAY ]; + opus_int32 Pred_Q15[ DECISION_DELAY ]; + opus_int32 Shape_Q14[ DECISION_DELAY ]; + opus_int32 sAR2_Q14[ MAX_SHAPE_LPC_ORDER ]; + opus_int32 LF_AR_Q14; + opus_int32 Seed; + opus_int32 SeedInit; + opus_int32 RD_Q10; +} NSQ_del_dec_struct; + +typedef struct { + opus_int32 Q_Q10; + opus_int32 RD_Q10; + opus_int32 xq_Q14; + opus_int32 LF_AR_Q14; + opus_int32 sLTP_shp_Q14; + opus_int32 LPC_exc_Q14; +} NSQ_sample_struct; + +typedef NSQ_sample_struct NSQ_sample_pair[ 2 ]; + +static OPUS_INLINE void silk_nsq_del_dec_scale_states_sse4_1( + const silk_encoder_state *psEncC, /* I Encoder State */ + silk_nsq_state *NSQ, /* I/O NSQ state */ + NSQ_del_dec_struct psDelDec[], /* I/O Delayed decision states */ + const opus_int32 x_Q3[], /* I Input in Q3 */ + opus_int32 x_sc_Q10[], /* O Input scaled with 1/Gain in Q10 */ + const opus_int16 sLTP[], /* I Re-whitened LTP state in Q0 */ + opus_int32 sLTP_Q15[], /* O LTP state matching scaled input */ + opus_int subfr, /* I Subframe number */ + opus_int nStatesDelayedDecision, /* I Number of del dec states */ + const opus_int LTP_scale_Q14, /* I LTP state scaling */ + const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */ + const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag */ + const opus_int signal_type, /* I Signal type */ + const opus_int decisionDelay /* I Decision delay */ +); + +/******************************************/ +/* Noise shape quantizer for one subframe */ +/******************************************/ +static OPUS_INLINE void silk_noise_shape_quantizer_del_dec_sse4_1( + silk_nsq_state *NSQ, /* I/O NSQ state */ + NSQ_del_dec_struct psDelDec[], /* I/O Delayed decision states */ + opus_int signalType, /* I Signal type */ + const opus_int32 x_Q10[], /* I */ + opus_int8 pulses[], /* O */ + opus_int16 xq[], /* O */ + opus_int32 sLTP_Q15[], /* I/O LTP filter state */ + opus_int32 delayedGain_Q10[], /* I/O Gain delay buffer */ + const opus_int16 a_Q12[], /* I Short term prediction coefs */ + const opus_int16 b_Q14[], /* I Long term prediction coefs */ + const opus_int16 AR_shp_Q13[], /* I Noise shaping coefs */ + opus_int lag, /* I Pitch lag */ + opus_int32 HarmShapeFIRPacked_Q14, /* I */ + opus_int Tilt_Q14, /* I Spectral tilt */ + opus_int32 LF_shp_Q14, /* I */ + opus_int32 Gain_Q16, /* I */ + opus_int Lambda_Q10, /* I */ + opus_int offset_Q10, /* I */ + opus_int length, /* I Input length */ + opus_int subfr, /* I Subframe number */ + opus_int shapingLPCOrder, /* I Shaping LPC filter order */ + opus_int predictLPCOrder, /* I Prediction filter order */ + opus_int warping_Q16, /* I */ + opus_int nStatesDelayedDecision, /* I Number of states in decision tree */ + opus_int *smpl_buf_idx, /* I Index to newest samples in buffers */ + opus_int decisionDelay /* I */ +); + +void silk_NSQ_del_dec_sse4_1( + const silk_encoder_state *psEncC, /* I/O Encoder State */ + silk_nsq_state *NSQ, /* I/O NSQ state */ + SideInfoIndices *psIndices, /* I/O Quantization Indices */ + const opus_int32 x_Q3[], /* I Prefiltered input signal */ + opus_int8 pulses[], /* O Quantized pulse signal */ + const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */ + const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */ + const opus_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */ + const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */ + const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */ + const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */ + const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */ + const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */ + const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */ + const opus_int LTP_scale_Q14 /* I LTP state scaling */ +) +{ + opus_int i, k, lag, start_idx, LSF_interpolation_flag, Winner_ind, subfr; + opus_int last_smple_idx, smpl_buf_idx, decisionDelay; + const opus_int16 *A_Q12, *B_Q14, *AR_shp_Q13; + opus_int16 *pxq; + VARDECL( opus_int32, sLTP_Q15 ); + VARDECL( opus_int16, sLTP ); + opus_int32 HarmShapeFIRPacked_Q14; + opus_int offset_Q10; + opus_int32 RDmin_Q10, Gain_Q10; + VARDECL( opus_int32, x_sc_Q10 ); + VARDECL( opus_int32, delayedGain_Q10 ); + VARDECL( NSQ_del_dec_struct, psDelDec ); + NSQ_del_dec_struct *psDD; + SAVE_STACK; + + /* Set unvoiced lag to the previous one, overwrite later for voiced */ + lag = NSQ->lagPrev; + + silk_assert( NSQ->prev_gain_Q16 != 0 ); + + /* Initialize delayed decision states */ + ALLOC( psDelDec, psEncC->nStatesDelayedDecision, NSQ_del_dec_struct ); + silk_memset( psDelDec, 0, psEncC->nStatesDelayedDecision * sizeof( NSQ_del_dec_struct ) ); + for( k = 0; k < psEncC->nStatesDelayedDecision; k++ ) { + psDD = &psDelDec[ k ]; + psDD->Seed = ( k + psIndices->Seed ) & 3; + psDD->SeedInit = psDD->Seed; + psDD->RD_Q10 = 0; + psDD->LF_AR_Q14 = NSQ->sLF_AR_shp_Q14; + psDD->Shape_Q14[ 0 ] = NSQ->sLTP_shp_Q14[ psEncC->ltp_mem_length - 1 ]; + silk_memcpy( psDD->sLPC_Q14, NSQ->sLPC_Q14, NSQ_LPC_BUF_LENGTH * sizeof( opus_int32 ) ); + silk_memcpy( psDD->sAR2_Q14, NSQ->sAR2_Q14, sizeof( NSQ->sAR2_Q14 ) ); + } + + offset_Q10 = silk_Quantization_Offsets_Q10[ psIndices->signalType >> 1 ][ psIndices->quantOffsetType ]; + smpl_buf_idx = 0; /* index of oldest samples */ + + decisionDelay = silk_min_int( DECISION_DELAY, psEncC->subfr_length ); + + /* For voiced frames limit the decision delay to lower than the pitch lag */ + if( psIndices->signalType == TYPE_VOICED ) { + for( k = 0; k < psEncC->nb_subfr; k++ ) { + decisionDelay = silk_min_int( decisionDelay, pitchL[ k ] - LTP_ORDER / 2 - 1 ); + } + } else { + if( lag > 0 ) { + decisionDelay = silk_min_int( decisionDelay, lag - LTP_ORDER / 2 - 1 ); + } + } + + if( psIndices->NLSFInterpCoef_Q2 == 4 ) { + LSF_interpolation_flag = 0; + } else { + LSF_interpolation_flag = 1; + } + + ALLOC( sLTP_Q15, + psEncC->ltp_mem_length + psEncC->frame_length, opus_int32 ); + ALLOC( sLTP, psEncC->ltp_mem_length + psEncC->frame_length, opus_int16 ); + ALLOC( x_sc_Q10, psEncC->subfr_length, opus_int32 ); + ALLOC( delayedGain_Q10, DECISION_DELAY, opus_int32 ); + /* Set up pointers to start of sub frame */ + pxq = &NSQ->xq[ psEncC->ltp_mem_length ]; + NSQ->sLTP_shp_buf_idx = psEncC->ltp_mem_length; + NSQ->sLTP_buf_idx = psEncC->ltp_mem_length; + subfr = 0; + for( k = 0; k < psEncC->nb_subfr; k++ ) { + A_Q12 = &PredCoef_Q12[ ( ( k >> 1 ) | ( 1 - LSF_interpolation_flag ) ) * MAX_LPC_ORDER ]; + B_Q14 = <PCoef_Q14[ k * LTP_ORDER ]; + AR_shp_Q13 = &AR2_Q13[ k * MAX_SHAPE_LPC_ORDER ]; + + /* Noise shape parameters */ + silk_assert( HarmShapeGain_Q14[ k ] >= 0 ); + HarmShapeFIRPacked_Q14 = silk_RSHIFT( HarmShapeGain_Q14[ k ], 2 ); + HarmShapeFIRPacked_Q14 |= silk_LSHIFT( (opus_int32)silk_RSHIFT( HarmShapeGain_Q14[ k ], 1 ), 16 ); + + NSQ->rewhite_flag = 0; + if( psIndices->signalType == TYPE_VOICED ) { + /* Voiced */ + lag = pitchL[ k ]; + + /* Re-whitening */ + if( ( k & ( 3 - silk_LSHIFT( LSF_interpolation_flag, 1 ) ) ) == 0 ) { + if( k == 2 ) { + /* RESET DELAYED DECISIONS */ + /* Find winner */ + RDmin_Q10 = psDelDec[ 0 ].RD_Q10; + Winner_ind = 0; + for( i = 1; i < psEncC->nStatesDelayedDecision; i++ ) { + if( psDelDec[ i ].RD_Q10 < RDmin_Q10 ) { + RDmin_Q10 = psDelDec[ i ].RD_Q10; + Winner_ind = i; + } + } + for( i = 0; i < psEncC->nStatesDelayedDecision; i++ ) { + if( i != Winner_ind ) { + psDelDec[ i ].RD_Q10 += ( silk_int32_MAX >> 4 ); + silk_assert( psDelDec[ i ].RD_Q10 >= 0 ); + } + } + + /* Copy final part of signals from winner state to output and long-term filter states */ + psDD = &psDelDec[ Winner_ind ]; + last_smple_idx = smpl_buf_idx + decisionDelay; + for( i = 0; i < decisionDelay; i++ ) { + last_smple_idx = ( last_smple_idx - 1 ) & DECISION_DELAY_MASK; + pulses[ i - decisionDelay ] = (opus_int8)silk_RSHIFT_ROUND( psDD->Q_Q10[ last_smple_idx ], 10 ); + pxq[ i - decisionDelay ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( + silk_SMULWW( psDD->Xq_Q14[ last_smple_idx ], Gains_Q16[ 1 ] ), 14 ) ); + NSQ->sLTP_shp_Q14[ NSQ->sLTP_shp_buf_idx - decisionDelay + i ] = psDD->Shape_Q14[ last_smple_idx ]; + } + + subfr = 0; + } + + /* Rewhiten with new A coefs */ + start_idx = psEncC->ltp_mem_length - lag - psEncC->predictLPCOrder - LTP_ORDER / 2; + silk_assert( start_idx > 0 ); + + silk_LPC_analysis_filter( &sLTP[ start_idx ], &NSQ->xq[ start_idx + k * psEncC->subfr_length ], + A_Q12, psEncC->ltp_mem_length - start_idx, psEncC->predictLPCOrder, psEncC->arch ); + + NSQ->sLTP_buf_idx = psEncC->ltp_mem_length; + NSQ->rewhite_flag = 1; + } + } + + silk_nsq_del_dec_scale_states_sse4_1( psEncC, NSQ, psDelDec, x_Q3, x_sc_Q10, sLTP, sLTP_Q15, k, + psEncC->nStatesDelayedDecision, LTP_scale_Q14, Gains_Q16, pitchL, psIndices->signalType, decisionDelay ); + + silk_noise_shape_quantizer_del_dec_sse4_1( NSQ, psDelDec, psIndices->signalType, x_sc_Q10, pulses, pxq, sLTP_Q15, + delayedGain_Q10, A_Q12, B_Q14, AR_shp_Q13, lag, HarmShapeFIRPacked_Q14, Tilt_Q14[ k ], LF_shp_Q14[ k ], + Gains_Q16[ k ], Lambda_Q10, offset_Q10, psEncC->subfr_length, subfr++, psEncC->shapingLPCOrder, + psEncC->predictLPCOrder, psEncC->warping_Q16, psEncC->nStatesDelayedDecision, &smpl_buf_idx, decisionDelay ); + + x_Q3 += psEncC->subfr_length; + pulses += psEncC->subfr_length; + pxq += psEncC->subfr_length; + } + + /* Find winner */ + RDmin_Q10 = psDelDec[ 0 ].RD_Q10; + Winner_ind = 0; + for( k = 1; k < psEncC->nStatesDelayedDecision; k++ ) { + if( psDelDec[ k ].RD_Q10 < RDmin_Q10 ) { + RDmin_Q10 = psDelDec[ k ].RD_Q10; + Winner_ind = k; + } + } + + /* Copy final part of signals from winner state to output and long-term filter states */ + psDD = &psDelDec[ Winner_ind ]; + psIndices->Seed = psDD->SeedInit; + last_smple_idx = smpl_buf_idx + decisionDelay; + Gain_Q10 = silk_RSHIFT32( Gains_Q16[ psEncC->nb_subfr - 1 ], 6 ); + for( i = 0; i < decisionDelay; i++ ) { + last_smple_idx = ( last_smple_idx - 1 ) & DECISION_DELAY_MASK; + pulses[ i - decisionDelay ] = (opus_int8)silk_RSHIFT_ROUND( psDD->Q_Q10[ last_smple_idx ], 10 ); + pxq[ i - decisionDelay ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( + silk_SMULWW( psDD->Xq_Q14[ last_smple_idx ], Gain_Q10 ), 8 ) ); + NSQ->sLTP_shp_Q14[ NSQ->sLTP_shp_buf_idx - decisionDelay + i ] = psDD->Shape_Q14[ last_smple_idx ]; + } + silk_memcpy( NSQ->sLPC_Q14, &psDD->sLPC_Q14[ psEncC->subfr_length ], NSQ_LPC_BUF_LENGTH * sizeof( opus_int32 ) ); + silk_memcpy( NSQ->sAR2_Q14, psDD->sAR2_Q14, sizeof( psDD->sAR2_Q14 ) ); + + /* Update states */ + NSQ->sLF_AR_shp_Q14 = psDD->LF_AR_Q14; + NSQ->lagPrev = pitchL[ psEncC->nb_subfr - 1 ]; + + /* Save quantized speech signal */ + /* DEBUG_STORE_DATA( enc.pcm, &NSQ->xq[psEncC->ltp_mem_length], psEncC->frame_length * sizeof( opus_int16 ) ) */ + silk_memmove( NSQ->xq, &NSQ->xq[ psEncC->frame_length ], psEncC->ltp_mem_length * sizeof( opus_int16 ) ); + silk_memmove( NSQ->sLTP_shp_Q14, &NSQ->sLTP_shp_Q14[ psEncC->frame_length ], psEncC->ltp_mem_length * sizeof( opus_int32 ) ); + RESTORE_STACK; +} + +/******************************************/ +/* Noise shape quantizer for one subframe */ +/******************************************/ +static OPUS_INLINE void silk_noise_shape_quantizer_del_dec_sse4_1( + silk_nsq_state *NSQ, /* I/O NSQ state */ + NSQ_del_dec_struct psDelDec[], /* I/O Delayed decision states */ + opus_int signalType, /* I Signal type */ + const opus_int32 x_Q10[], /* I */ + opus_int8 pulses[], /* O */ + opus_int16 xq[], /* O */ + opus_int32 sLTP_Q15[], /* I/O LTP filter state */ + opus_int32 delayedGain_Q10[], /* I/O Gain delay buffer */ + const opus_int16 a_Q12[], /* I Short term prediction coefs */ + const opus_int16 b_Q14[], /* I Long term prediction coefs */ + const opus_int16 AR_shp_Q13[], /* I Noise shaping coefs */ + opus_int lag, /* I Pitch lag */ + opus_int32 HarmShapeFIRPacked_Q14, /* I */ + opus_int Tilt_Q14, /* I Spectral tilt */ + opus_int32 LF_shp_Q14, /* I */ + opus_int32 Gain_Q16, /* I */ + opus_int Lambda_Q10, /* I */ + opus_int offset_Q10, /* I */ + opus_int length, /* I Input length */ + opus_int subfr, /* I Subframe number */ + opus_int shapingLPCOrder, /* I Shaping LPC filter order */ + opus_int predictLPCOrder, /* I Prediction filter order */ + opus_int warping_Q16, /* I */ + opus_int nStatesDelayedDecision, /* I Number of states in decision tree */ + opus_int *smpl_buf_idx, /* I Index to newest samples in buffers */ + opus_int decisionDelay /* I */ +) +{ + opus_int i, j, k, Winner_ind, RDmin_ind, RDmax_ind, last_smple_idx; + opus_int32 Winner_rand_state; + opus_int32 LTP_pred_Q14, LPC_pred_Q14, n_AR_Q14, n_LTP_Q14; + opus_int32 n_LF_Q14, r_Q10, rr_Q10, rd1_Q10, rd2_Q10, RDmin_Q10, RDmax_Q10; + opus_int32 q1_Q0, q1_Q10, q2_Q10, exc_Q14, LPC_exc_Q14, xq_Q14, Gain_Q10; + opus_int32 tmp1, tmp2, sLF_AR_shp_Q14; + opus_int32 *pred_lag_ptr, *shp_lag_ptr, *psLPC_Q14; + VARDECL( NSQ_sample_pair, psSampleState ); + NSQ_del_dec_struct *psDD; + NSQ_sample_struct *psSS; + + __m128i a_Q12_0123, a_Q12_4567, a_Q12_89AB, a_Q12_CDEF; + __m128i b_Q12_0123, b_sr_Q12_0123; + SAVE_STACK; + + silk_assert( nStatesDelayedDecision > 0 ); + ALLOC( psSampleState, nStatesDelayedDecision, NSQ_sample_pair ); + + shp_lag_ptr = &NSQ->sLTP_shp_Q14[ NSQ->sLTP_shp_buf_idx - lag + HARM_SHAPE_FIR_TAPS / 2 ]; + pred_lag_ptr = &sLTP_Q15[ NSQ->sLTP_buf_idx - lag + LTP_ORDER / 2 ]; + Gain_Q10 = silk_RSHIFT( Gain_Q16, 6 ); + + a_Q12_0123 = OP_CVTEPI16_EPI32_M64( a_Q12 ); + a_Q12_4567 = OP_CVTEPI16_EPI32_M64( a_Q12 + 4 ); + + if( opus_likely( predictLPCOrder == 16 ) ) { + a_Q12_89AB = OP_CVTEPI16_EPI32_M64( a_Q12 + 8 ); + a_Q12_CDEF = OP_CVTEPI16_EPI32_M64( a_Q12 + 12 ); + } + + if( signalType == TYPE_VOICED ){ + b_Q12_0123 = OP_CVTEPI16_EPI32_M64( b_Q14 ); + b_sr_Q12_0123 = _mm_shuffle_epi32( b_Q12_0123, _MM_SHUFFLE( 0, 3, 2, 1 ) ); /* equal shift right 4 bytes */ + } + for( i = 0; i < length; i++ ) { + /* Perform common calculations used in all states */ + + /* Long-term prediction */ + if( signalType == TYPE_VOICED ) { + /* Unrolled loop */ + /* Avoids introducing a bias because silk_SMLAWB() always rounds to -inf */ + LTP_pred_Q14 = 2; + { + __m128i tmpa, tmpb, pred_lag_ptr_tmp; + pred_lag_ptr_tmp = _mm_loadu_si128( (__m128i *)(&pred_lag_ptr[ -3 ] ) ); + pred_lag_ptr_tmp = _mm_shuffle_epi32( pred_lag_ptr_tmp, 0x1B ); + tmpa = _mm_mul_epi32( pred_lag_ptr_tmp, b_Q12_0123 ); + tmpa = _mm_srli_si128( tmpa, 2 ); + + pred_lag_ptr_tmp = _mm_shuffle_epi32( pred_lag_ptr_tmp, _MM_SHUFFLE( 0, 3, 2, 1 ) );/* equal shift right 4 bytes */ + pred_lag_ptr_tmp = _mm_mul_epi32( pred_lag_ptr_tmp, b_sr_Q12_0123 ); + pred_lag_ptr_tmp = _mm_srli_si128( pred_lag_ptr_tmp, 2 ); + pred_lag_ptr_tmp = _mm_add_epi32( pred_lag_ptr_tmp, tmpa ); + + tmpb = _mm_shuffle_epi32( pred_lag_ptr_tmp, _MM_SHUFFLE( 0, 0, 3, 2 ) );/* equal shift right 8 bytes */ + pred_lag_ptr_tmp = _mm_add_epi32( pred_lag_ptr_tmp, tmpb ); + LTP_pred_Q14 += _mm_cvtsi128_si32( pred_lag_ptr_tmp ); + + LTP_pred_Q14 = silk_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ -4 ], b_Q14[ 4 ] ); + LTP_pred_Q14 = silk_LSHIFT( LTP_pred_Q14, 1 ); /* Q13 -> Q14 */ + pred_lag_ptr++; + } + } else { + LTP_pred_Q14 = 0; + } + + /* Long-term shaping */ + if( lag > 0 ) { + /* Symmetric, packed FIR coefficients */ + n_LTP_Q14 = silk_SMULWB( silk_ADD32( shp_lag_ptr[ 0 ], shp_lag_ptr[ -2 ] ), HarmShapeFIRPacked_Q14 ); + n_LTP_Q14 = silk_SMLAWT( n_LTP_Q14, shp_lag_ptr[ -1 ], HarmShapeFIRPacked_Q14 ); + n_LTP_Q14 = silk_SUB_LSHIFT32( LTP_pred_Q14, n_LTP_Q14, 2 ); /* Q12 -> Q14 */ + shp_lag_ptr++; + } else { + n_LTP_Q14 = 0; + } + { + __m128i tmpa, tmpb, psLPC_Q14_tmp, a_Q12_tmp; + + for( k = 0; k < nStatesDelayedDecision; k++ ) { + /* Delayed decision state */ + psDD = &psDelDec[ k ]; + + /* Sample state */ + psSS = psSampleState[ k ]; + + /* Generate dither */ + psDD->Seed = silk_RAND( psDD->Seed ); + + /* Pointer used in short term prediction and shaping */ + psLPC_Q14 = &psDD->sLPC_Q14[ NSQ_LPC_BUF_LENGTH - 1 + i ]; + /* Short-term prediction */ + silk_assert( predictLPCOrder == 10 || predictLPCOrder == 16 ); + /* Avoids introducing a bias because silk_SMLAWB() always rounds to -inf */ + LPC_pred_Q14 = silk_RSHIFT( predictLPCOrder, 1 ); + + tmpb = _mm_setzero_si128(); + + /* step 1 */ + psLPC_Q14_tmp = _mm_loadu_si128( (__m128i *)(&psLPC_Q14[ -3 ] ) ); /* -3, -2 , -1, 0 */ + psLPC_Q14_tmp = _mm_shuffle_epi32( psLPC_Q14_tmp, 0x1B ); /* 0, -1, -2, -3 */ + tmpa = _mm_mul_epi32( psLPC_Q14_tmp, a_Q12_0123 ); /* 0, -1, -2, -3 * 0123 -> 0*0, 2*-2 */ + + tmpa = _mm_srli_epi64( tmpa, 16 ); + tmpb = _mm_add_epi32( tmpb, tmpa ); + + psLPC_Q14_tmp = _mm_shuffle_epi32( psLPC_Q14_tmp, _MM_SHUFFLE( 0, 3, 2, 1 ) ); /* equal shift right 4 bytes */ + a_Q12_tmp = _mm_shuffle_epi32( a_Q12_0123, _MM_SHUFFLE(0, 3, 2, 1 ) ); /* equal shift right 4 bytes */ + psLPC_Q14_tmp = _mm_mul_epi32( psLPC_Q14_tmp, a_Q12_tmp ); /* 1*-1, 3*-3 */ + psLPC_Q14_tmp = _mm_srli_epi64( psLPC_Q14_tmp, 16 ); + tmpb = _mm_add_epi32( tmpb, psLPC_Q14_tmp ); + + /* step 2 */ + psLPC_Q14_tmp = _mm_loadu_si128( (__m128i *)(&psLPC_Q14[ -7 ] ) ); + psLPC_Q14_tmp = _mm_shuffle_epi32( psLPC_Q14_tmp, 0x1B ); + tmpa = _mm_mul_epi32( psLPC_Q14_tmp, a_Q12_4567 ); + tmpa = _mm_srli_epi64( tmpa, 16 ); + tmpb = _mm_add_epi32( tmpb, tmpa ); + + psLPC_Q14_tmp = _mm_shuffle_epi32( psLPC_Q14_tmp, _MM_SHUFFLE( 0, 3, 2, 1 ) ); /* equal shift right 4 bytes */ + a_Q12_tmp = _mm_shuffle_epi32( a_Q12_4567, _MM_SHUFFLE(0, 3, 2, 1 ) ); /* equal shift right 4 bytes */ + psLPC_Q14_tmp = _mm_mul_epi32( psLPC_Q14_tmp, a_Q12_tmp ); + psLPC_Q14_tmp = _mm_srli_epi64( psLPC_Q14_tmp, 16 ); + tmpb = _mm_add_epi32( tmpb, psLPC_Q14_tmp ); + + if ( opus_likely( predictLPCOrder == 16 ) ) + { + /* step 3 */ + psLPC_Q14_tmp = _mm_loadu_si128( (__m128i *)(&psLPC_Q14[ -11 ] ) ); + psLPC_Q14_tmp = _mm_shuffle_epi32( psLPC_Q14_tmp, 0x1B ); + tmpa = _mm_mul_epi32( psLPC_Q14_tmp, a_Q12_89AB ); + tmpa = _mm_srli_epi64( tmpa, 16 ); + tmpb = _mm_add_epi32( tmpb, tmpa ); + + psLPC_Q14_tmp = _mm_shuffle_epi32( psLPC_Q14_tmp, _MM_SHUFFLE( 0, 3, 2, 1 ) ); /* equal shift right 4 bytes */ + a_Q12_tmp = _mm_shuffle_epi32( a_Q12_89AB, _MM_SHUFFLE(0, 3, 2, 1 ) );/* equal shift right 4 bytes */ + psLPC_Q14_tmp = _mm_mul_epi32( psLPC_Q14_tmp, a_Q12_tmp ); + psLPC_Q14_tmp = _mm_srli_epi64( psLPC_Q14_tmp, 16 ); + tmpb = _mm_add_epi32( tmpb, psLPC_Q14_tmp ); + + /* setp 4 */ + psLPC_Q14_tmp = _mm_loadu_si128( (__m128i *)(&psLPC_Q14[ -15 ] ) ); + psLPC_Q14_tmp = _mm_shuffle_epi32( psLPC_Q14_tmp, 0x1B ); + tmpa = _mm_mul_epi32( psLPC_Q14_tmp, a_Q12_CDEF ); + tmpa = _mm_srli_epi64( tmpa, 16 ); + tmpb = _mm_add_epi32( tmpb, tmpa ); + + psLPC_Q14_tmp = _mm_shuffle_epi32( psLPC_Q14_tmp, _MM_SHUFFLE( 0, 3, 2, 1 ) ); /* equal shift right 4 bytes */ + a_Q12_tmp = _mm_shuffle_epi32( a_Q12_CDEF, _MM_SHUFFLE(0, 3, 2, 1 ) ); /* equal shift right 4 bytes */ + psLPC_Q14_tmp = _mm_mul_epi32( psLPC_Q14_tmp, a_Q12_tmp ); + psLPC_Q14_tmp = _mm_srli_epi64( psLPC_Q14_tmp, 16 ); + tmpb = _mm_add_epi32( tmpb, psLPC_Q14_tmp ); + + /* add at last */ + /* equal shift right 8 bytes*/ + tmpa = _mm_shuffle_epi32( tmpb, _MM_SHUFFLE( 0, 0, 3, 2 ) ); + tmpb = _mm_add_epi32( tmpb, tmpa ); + LPC_pred_Q14 += _mm_cvtsi128_si32( tmpb ); + } + else + { + /* add at last */ + tmpa = _mm_shuffle_epi32( tmpb, _MM_SHUFFLE( 0, 0, 3, 2 ) ); /* equal shift right 8 bytes*/ + tmpb = _mm_add_epi32( tmpb, tmpa ); + LPC_pred_Q14 += _mm_cvtsi128_si32( tmpb ); + + LPC_pred_Q14 = silk_SMLAWB( LPC_pred_Q14, psLPC_Q14[ -8 ], a_Q12[ 8 ] ); + LPC_pred_Q14 = silk_SMLAWB( LPC_pred_Q14, psLPC_Q14[ -9 ], a_Q12[ 9 ] ); + } + + LPC_pred_Q14 = silk_LSHIFT( LPC_pred_Q14, 4 ); /* Q10 -> Q14 */ + + /* Noise shape feedback */ + silk_assert( ( shapingLPCOrder & 1 ) == 0 ); /* check that order is even */ + /* Output of lowpass section */ + tmp2 = silk_SMLAWB( psLPC_Q14[ 0 ], psDD->sAR2_Q14[ 0 ], warping_Q16 ); + /* Output of allpass section */ + tmp1 = silk_SMLAWB( psDD->sAR2_Q14[ 0 ], psDD->sAR2_Q14[ 1 ] - tmp2, warping_Q16 ); + psDD->sAR2_Q14[ 0 ] = tmp2; + n_AR_Q14 = silk_RSHIFT( shapingLPCOrder, 1 ); + n_AR_Q14 = silk_SMLAWB( n_AR_Q14, tmp2, AR_shp_Q13[ 0 ] ); + /* Loop over allpass sections */ + for( j = 2; j < shapingLPCOrder; j += 2 ) { + /* Output of allpass section */ + tmp2 = silk_SMLAWB( psDD->sAR2_Q14[ j - 1 ], psDD->sAR2_Q14[ j + 0 ] - tmp1, warping_Q16 ); + psDD->sAR2_Q14[ j - 1 ] = tmp1; + n_AR_Q14 = silk_SMLAWB( n_AR_Q14, tmp1, AR_shp_Q13[ j - 1 ] ); + /* Output of allpass section */ + tmp1 = silk_SMLAWB( psDD->sAR2_Q14[ j + 0 ], psDD->sAR2_Q14[ j + 1 ] - tmp2, warping_Q16 ); + psDD->sAR2_Q14[ j + 0 ] = tmp2; + n_AR_Q14 = silk_SMLAWB( n_AR_Q14, tmp2, AR_shp_Q13[ j ] ); + } + psDD->sAR2_Q14[ shapingLPCOrder - 1 ] = tmp1; + n_AR_Q14 = silk_SMLAWB( n_AR_Q14, tmp1, AR_shp_Q13[ shapingLPCOrder - 1 ] ); + + n_AR_Q14 = silk_LSHIFT( n_AR_Q14, 1 ); /* Q11 -> Q12 */ + n_AR_Q14 = silk_SMLAWB( n_AR_Q14, psDD->LF_AR_Q14, Tilt_Q14 ); /* Q12 */ + n_AR_Q14 = silk_LSHIFT( n_AR_Q14, 2 ); /* Q12 -> Q14 */ + + n_LF_Q14 = silk_SMULWB( psDD->Shape_Q14[ *smpl_buf_idx ], LF_shp_Q14 ); /* Q12 */ + n_LF_Q14 = silk_SMLAWT( n_LF_Q14, psDD->LF_AR_Q14, LF_shp_Q14 ); /* Q12 */ + n_LF_Q14 = silk_LSHIFT( n_LF_Q14, 2 ); /* Q12 -> Q14 */ + + /* Input minus prediction plus noise feedback */ + /* r = x[ i ] - LTP_pred - LPC_pred + n_AR + n_Tilt + n_LF + n_LTP */ + tmp1 = silk_ADD32( n_AR_Q14, n_LF_Q14 ); /* Q14 */ + tmp2 = silk_ADD32( n_LTP_Q14, LPC_pred_Q14 ); /* Q13 */ + tmp1 = silk_SUB32( tmp2, tmp1 ); /* Q13 */ + tmp1 = silk_RSHIFT_ROUND( tmp1, 4 ); /* Q10 */ + + r_Q10 = silk_SUB32( x_Q10[ i ], tmp1 ); /* residual error Q10 */ + + /* Flip sign depending on dither */ + if ( psDD->Seed < 0 ) { + r_Q10 = -r_Q10; + } + r_Q10 = silk_LIMIT_32( r_Q10, -(31 << 10), 30 << 10 ); + + /* Find two quantization level candidates and measure their rate-distortion */ + q1_Q10 = silk_SUB32( r_Q10, offset_Q10 ); + q1_Q0 = silk_RSHIFT( q1_Q10, 10 ); + if( q1_Q0 > 0 ) { + q1_Q10 = silk_SUB32( silk_LSHIFT( q1_Q0, 10 ), QUANT_LEVEL_ADJUST_Q10 ); + q1_Q10 = silk_ADD32( q1_Q10, offset_Q10 ); + q2_Q10 = silk_ADD32( q1_Q10, 1024 ); + rd1_Q10 = silk_SMULBB( q1_Q10, Lambda_Q10 ); + rd2_Q10 = silk_SMULBB( q2_Q10, Lambda_Q10 ); + } else if( q1_Q0 == 0 ) { + q1_Q10 = offset_Q10; + q2_Q10 = silk_ADD32( q1_Q10, 1024 - QUANT_LEVEL_ADJUST_Q10 ); + rd1_Q10 = silk_SMULBB( q1_Q10, Lambda_Q10 ); + rd2_Q10 = silk_SMULBB( q2_Q10, Lambda_Q10 ); + } else if( q1_Q0 == -1 ) { + q2_Q10 = offset_Q10; + q1_Q10 = silk_SUB32( q2_Q10, 1024 - QUANT_LEVEL_ADJUST_Q10 ); + rd1_Q10 = silk_SMULBB( -q1_Q10, Lambda_Q10 ); + rd2_Q10 = silk_SMULBB( q2_Q10, Lambda_Q10 ); + } else { /* q1_Q0 < -1 */ + q1_Q10 = silk_ADD32( silk_LSHIFT( q1_Q0, 10 ), QUANT_LEVEL_ADJUST_Q10 ); + q1_Q10 = silk_ADD32( q1_Q10, offset_Q10 ); + q2_Q10 = silk_ADD32( q1_Q10, 1024 ); + rd1_Q10 = silk_SMULBB( -q1_Q10, Lambda_Q10 ); + rd2_Q10 = silk_SMULBB( -q2_Q10, Lambda_Q10 ); + } + rr_Q10 = silk_SUB32( r_Q10, q1_Q10 ); + rd1_Q10 = silk_RSHIFT( silk_SMLABB( rd1_Q10, rr_Q10, rr_Q10 ), 10 ); + rr_Q10 = silk_SUB32( r_Q10, q2_Q10 ); + rd2_Q10 = silk_RSHIFT( silk_SMLABB( rd2_Q10, rr_Q10, rr_Q10 ), 10 ); + + if( rd1_Q10 < rd2_Q10 ) { + psSS[ 0 ].RD_Q10 = silk_ADD32( psDD->RD_Q10, rd1_Q10 ); + psSS[ 1 ].RD_Q10 = silk_ADD32( psDD->RD_Q10, rd2_Q10 ); + psSS[ 0 ].Q_Q10 = q1_Q10; + psSS[ 1 ].Q_Q10 = q2_Q10; + } else { + psSS[ 0 ].RD_Q10 = silk_ADD32( psDD->RD_Q10, rd2_Q10 ); + psSS[ 1 ].RD_Q10 = silk_ADD32( psDD->RD_Q10, rd1_Q10 ); + psSS[ 0 ].Q_Q10 = q2_Q10; + psSS[ 1 ].Q_Q10 = q1_Q10; + } + + /* Update states for best quantization */ + + /* Quantized excitation */ + exc_Q14 = silk_LSHIFT32( psSS[ 0 ].Q_Q10, 4 ); + if ( psDD->Seed < 0 ) { + exc_Q14 = -exc_Q14; + } + + /* Add predictions */ + LPC_exc_Q14 = silk_ADD32( exc_Q14, LTP_pred_Q14 ); + xq_Q14 = silk_ADD32( LPC_exc_Q14, LPC_pred_Q14 ); + + /* Update states */ + sLF_AR_shp_Q14 = silk_SUB32( xq_Q14, n_AR_Q14 ); + psSS[ 0 ].sLTP_shp_Q14 = silk_SUB32( sLF_AR_shp_Q14, n_LF_Q14 ); + psSS[ 0 ].LF_AR_Q14 = sLF_AR_shp_Q14; + psSS[ 0 ].LPC_exc_Q14 = LPC_exc_Q14; + psSS[ 0 ].xq_Q14 = xq_Q14; + + /* Update states for second best quantization */ + + /* Quantized excitation */ + exc_Q14 = silk_LSHIFT32( psSS[ 1 ].Q_Q10, 4 ); + if ( psDD->Seed < 0 ) { + exc_Q14 = -exc_Q14; + } + + + /* Add predictions */ + LPC_exc_Q14 = silk_ADD32( exc_Q14, LTP_pred_Q14 ); + xq_Q14 = silk_ADD32( LPC_exc_Q14, LPC_pred_Q14 ); + + /* Update states */ + sLF_AR_shp_Q14 = silk_SUB32( xq_Q14, n_AR_Q14 ); + psSS[ 1 ].sLTP_shp_Q14 = silk_SUB32( sLF_AR_shp_Q14, n_LF_Q14 ); + psSS[ 1 ].LF_AR_Q14 = sLF_AR_shp_Q14; + psSS[ 1 ].LPC_exc_Q14 = LPC_exc_Q14; + psSS[ 1 ].xq_Q14 = xq_Q14; + } + } + *smpl_buf_idx = ( *smpl_buf_idx - 1 ) & DECISION_DELAY_MASK; /* Index to newest samples */ + last_smple_idx = ( *smpl_buf_idx + decisionDelay ) & DECISION_DELAY_MASK; /* Index to decisionDelay old samples */ + + /* Find winner */ + RDmin_Q10 = psSampleState[ 0 ][ 0 ].RD_Q10; + Winner_ind = 0; + for( k = 1; k < nStatesDelayedDecision; k++ ) { + if( psSampleState[ k ][ 0 ].RD_Q10 < RDmin_Q10 ) { + RDmin_Q10 = psSampleState[ k ][ 0 ].RD_Q10; + Winner_ind = k; + } + } + + /* Increase RD values of expired states */ + Winner_rand_state = psDelDec[ Winner_ind ].RandState[ last_smple_idx ]; + for( k = 0; k < nStatesDelayedDecision; k++ ) { + if( psDelDec[ k ].RandState[ last_smple_idx ] != Winner_rand_state ) { + psSampleState[ k ][ 0 ].RD_Q10 = silk_ADD32( psSampleState[ k ][ 0 ].RD_Q10, silk_int32_MAX >> 4 ); + psSampleState[ k ][ 1 ].RD_Q10 = silk_ADD32( psSampleState[ k ][ 1 ].RD_Q10, silk_int32_MAX >> 4 ); + silk_assert( psSampleState[ k ][ 0 ].RD_Q10 >= 0 ); + } + } + + /* Find worst in first set and best in second set */ + RDmax_Q10 = psSampleState[ 0 ][ 0 ].RD_Q10; + RDmin_Q10 = psSampleState[ 0 ][ 1 ].RD_Q10; + RDmax_ind = 0; + RDmin_ind = 0; + for( k = 1; k < nStatesDelayedDecision; k++ ) { + /* find worst in first set */ + if( psSampleState[ k ][ 0 ].RD_Q10 > RDmax_Q10 ) { + RDmax_Q10 = psSampleState[ k ][ 0 ].RD_Q10; + RDmax_ind = k; + } + /* find best in second set */ + if( psSampleState[ k ][ 1 ].RD_Q10 < RDmin_Q10 ) { + RDmin_Q10 = psSampleState[ k ][ 1 ].RD_Q10; + RDmin_ind = k; + } + } + + /* Replace a state if best from second set outperforms worst in first set */ + if( RDmin_Q10 < RDmax_Q10 ) { + silk_memcpy( ( (opus_int32 *)&psDelDec[ RDmax_ind ] ) + i, + ( (opus_int32 *)&psDelDec[ RDmin_ind ] ) + i, sizeof( NSQ_del_dec_struct ) - i * sizeof( opus_int32) ); + silk_memcpy( &psSampleState[ RDmax_ind ][ 0 ], &psSampleState[ RDmin_ind ][ 1 ], sizeof( NSQ_sample_struct ) ); + } + + /* Write samples from winner to output and long-term filter states */ + psDD = &psDelDec[ Winner_ind ]; + if( subfr > 0 || i >= decisionDelay ) { + pulses[ i - decisionDelay ] = (opus_int8)silk_RSHIFT_ROUND( psDD->Q_Q10[ last_smple_idx ], 10 ); + xq[ i - decisionDelay ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( + silk_SMULWW( psDD->Xq_Q14[ last_smple_idx ], delayedGain_Q10[ last_smple_idx ] ), 8 ) ); + NSQ->sLTP_shp_Q14[ NSQ->sLTP_shp_buf_idx - decisionDelay ] = psDD->Shape_Q14[ last_smple_idx ]; + sLTP_Q15[ NSQ->sLTP_buf_idx - decisionDelay ] = psDD->Pred_Q15[ last_smple_idx ]; + } + NSQ->sLTP_shp_buf_idx++; + NSQ->sLTP_buf_idx++; + + /* Update states */ + for( k = 0; k < nStatesDelayedDecision; k++ ) { + psDD = &psDelDec[ k ]; + psSS = &psSampleState[ k ][ 0 ]; + psDD->LF_AR_Q14 = psSS->LF_AR_Q14; + psDD->sLPC_Q14[ NSQ_LPC_BUF_LENGTH + i ] = psSS->xq_Q14; + psDD->Xq_Q14[ *smpl_buf_idx ] = psSS->xq_Q14; + psDD->Q_Q10[ *smpl_buf_idx ] = psSS->Q_Q10; + psDD->Pred_Q15[ *smpl_buf_idx ] = silk_LSHIFT32( psSS->LPC_exc_Q14, 1 ); + psDD->Shape_Q14[ *smpl_buf_idx ] = psSS->sLTP_shp_Q14; + psDD->Seed = silk_ADD32_ovflw( psDD->Seed, silk_RSHIFT_ROUND( psSS->Q_Q10, 10 ) ); + psDD->RandState[ *smpl_buf_idx ] = psDD->Seed; + psDD->RD_Q10 = psSS->RD_Q10; + } + delayedGain_Q10[ *smpl_buf_idx ] = Gain_Q10; + } + /* Update LPC states */ + for( k = 0; k < nStatesDelayedDecision; k++ ) { + psDD = &psDelDec[ k ]; + silk_memcpy( psDD->sLPC_Q14, &psDD->sLPC_Q14[ length ], NSQ_LPC_BUF_LENGTH * sizeof( opus_int32 ) ); + } + RESTORE_STACK; +} + +static OPUS_INLINE void silk_nsq_del_dec_scale_states_sse4_1( + const silk_encoder_state *psEncC, /* I Encoder State */ + silk_nsq_state *NSQ, /* I/O NSQ state */ + NSQ_del_dec_struct psDelDec[], /* I/O Delayed decision states */ + const opus_int32 x_Q3[], /* I Input in Q3 */ + opus_int32 x_sc_Q10[], /* O Input scaled with 1/Gain in Q10 */ + const opus_int16 sLTP[], /* I Re-whitened LTP state in Q0 */ + opus_int32 sLTP_Q15[], /* O LTP state matching scaled input */ + opus_int subfr, /* I Subframe number */ + opus_int nStatesDelayedDecision, /* I Number of del dec states */ + const opus_int LTP_scale_Q14, /* I LTP state scaling */ + const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */ + const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag */ + const opus_int signal_type, /* I Signal type */ + const opus_int decisionDelay /* I Decision delay */ +) +{ + opus_int i, k, lag; + opus_int32 gain_adj_Q16, inv_gain_Q31, inv_gain_Q23; + NSQ_del_dec_struct *psDD; + __m128i xmm_inv_gain_Q23, xmm_x_Q3_x2x0, xmm_x_Q3_x3x1; + + lag = pitchL[ subfr ]; + inv_gain_Q31 = silk_INVERSE32_varQ( silk_max( Gains_Q16[ subfr ], 1 ), 47 ); + + silk_assert( inv_gain_Q31 != 0 ); + + /* Calculate gain adjustment factor */ + if( Gains_Q16[ subfr ] != NSQ->prev_gain_Q16 ) { + gain_adj_Q16 = silk_DIV32_varQ( NSQ->prev_gain_Q16, Gains_Q16[ subfr ], 16 ); + } else { + gain_adj_Q16 = (opus_int32)1 << 16; + } + + /* Scale input */ + inv_gain_Q23 = silk_RSHIFT_ROUND( inv_gain_Q31, 8 ); + + /* prepare inv_gain_Q23 in packed 4 32-bits */ + xmm_inv_gain_Q23 = _mm_set1_epi32(inv_gain_Q23); + + for( i = 0; i < psEncC->subfr_length - 3; i += 4 ) { + xmm_x_Q3_x2x0 = _mm_loadu_si128( (__m128i *)(&(x_Q3[ i ] ) ) ); + /* equal shift right 4 bytes*/ + xmm_x_Q3_x3x1 = _mm_shuffle_epi32( xmm_x_Q3_x2x0, _MM_SHUFFLE( 0, 3, 2, 1 ) ); + + xmm_x_Q3_x2x0 = _mm_mul_epi32( xmm_x_Q3_x2x0, xmm_inv_gain_Q23 ); + xmm_x_Q3_x3x1 = _mm_mul_epi32( xmm_x_Q3_x3x1, xmm_inv_gain_Q23 ); + + xmm_x_Q3_x2x0 = _mm_srli_epi64( xmm_x_Q3_x2x0, 16 ); + xmm_x_Q3_x3x1 = _mm_slli_epi64( xmm_x_Q3_x3x1, 16 ); + + xmm_x_Q3_x2x0 = _mm_blend_epi16( xmm_x_Q3_x2x0, xmm_x_Q3_x3x1, 0xCC ); + + _mm_storeu_si128( (__m128i *)(&(x_sc_Q10[ i ])), xmm_x_Q3_x2x0 ); + } + + for( ; i < psEncC->subfr_length; i++ ) { + x_sc_Q10[ i ] = silk_SMULWW( x_Q3[ i ], inv_gain_Q23 ); + } + + /* Save inverse gain */ + NSQ->prev_gain_Q16 = Gains_Q16[ subfr ]; + + /* After rewhitening the LTP state is un-scaled, so scale with inv_gain_Q16 */ + if( NSQ->rewhite_flag ) { + if( subfr == 0 ) { + /* Do LTP downscaling */ + inv_gain_Q31 = silk_LSHIFT( silk_SMULWB( inv_gain_Q31, LTP_scale_Q14 ), 2 ); + } + for( i = NSQ->sLTP_buf_idx - lag - LTP_ORDER / 2; i < NSQ->sLTP_buf_idx; i++ ) { + silk_assert( i < MAX_FRAME_LENGTH ); + sLTP_Q15[ i ] = silk_SMULWB( inv_gain_Q31, sLTP[ i ] ); + } + } + + /* Adjust for changing gain */ + if( gain_adj_Q16 != (opus_int32)1 << 16 ) { + /* Scale long-term shaping state */ + { + __m128i xmm_gain_adj_Q16, xmm_sLTP_shp_Q14_x2x0, xmm_sLTP_shp_Q14_x3x1; + + /* prepare gain_adj_Q16 in packed 4 32-bits */ + xmm_gain_adj_Q16 = _mm_set1_epi32( gain_adj_Q16 ); + + for( i = NSQ->sLTP_shp_buf_idx - psEncC->ltp_mem_length; i < NSQ->sLTP_shp_buf_idx - 3; i += 4 ) + { + xmm_sLTP_shp_Q14_x2x0 = _mm_loadu_si128( (__m128i *)(&(NSQ->sLTP_shp_Q14[ i ] ) ) ); + /* equal shift right 4 bytes*/ + xmm_sLTP_shp_Q14_x3x1 = _mm_shuffle_epi32( xmm_sLTP_shp_Q14_x2x0, _MM_SHUFFLE( 0, 3, 2, 1 ) ); + + xmm_sLTP_shp_Q14_x2x0 = _mm_mul_epi32( xmm_sLTP_shp_Q14_x2x0, xmm_gain_adj_Q16 ); + xmm_sLTP_shp_Q14_x3x1 = _mm_mul_epi32( xmm_sLTP_shp_Q14_x3x1, xmm_gain_adj_Q16 ); + + xmm_sLTP_shp_Q14_x2x0 = _mm_srli_epi64( xmm_sLTP_shp_Q14_x2x0, 16 ); + xmm_sLTP_shp_Q14_x3x1 = _mm_slli_epi64( xmm_sLTP_shp_Q14_x3x1, 16 ); + + xmm_sLTP_shp_Q14_x2x0 = _mm_blend_epi16( xmm_sLTP_shp_Q14_x2x0, xmm_sLTP_shp_Q14_x3x1, 0xCC ); + + _mm_storeu_si128( (__m128i *)(&(NSQ->sLTP_shp_Q14[ i ] ) ), xmm_sLTP_shp_Q14_x2x0 ); + } + + for( ; i < NSQ->sLTP_shp_buf_idx; i++ ) { + NSQ->sLTP_shp_Q14[ i ] = silk_SMULWW( gain_adj_Q16, NSQ->sLTP_shp_Q14[ i ] ); + } + + /* Scale long-term prediction state */ + if( signal_type == TYPE_VOICED && NSQ->rewhite_flag == 0 ) { + for( i = NSQ->sLTP_buf_idx - lag - LTP_ORDER / 2; i < NSQ->sLTP_buf_idx - decisionDelay; i++ ) { + sLTP_Q15[ i ] = silk_SMULWW( gain_adj_Q16, sLTP_Q15[ i ] ); + } + } + + for( k = 0; k < nStatesDelayedDecision; k++ ) { + psDD = &psDelDec[ k ]; + + /* Scale scalar states */ + psDD->LF_AR_Q14 = silk_SMULWW( gain_adj_Q16, psDD->LF_AR_Q14 ); + + /* Scale short-term prediction and shaping states */ + for( i = 0; i < NSQ_LPC_BUF_LENGTH; i++ ) { + psDD->sLPC_Q14[ i ] = silk_SMULWW( gain_adj_Q16, psDD->sLPC_Q14[ i ] ); + } + for( i = 0; i < MAX_SHAPE_LPC_ORDER; i++ ) { + psDD->sAR2_Q14[ i ] = silk_SMULWW( gain_adj_Q16, psDD->sAR2_Q14[ i ] ); + } + for( i = 0; i < DECISION_DELAY; i++ ) { + psDD->Pred_Q15[ i ] = silk_SMULWW( gain_adj_Q16, psDD->Pred_Q15[ i ] ); + psDD->Shape_Q14[ i ] = silk_SMULWW( gain_adj_Q16, psDD->Shape_Q14[ i ] ); + } + } + } + } +} diff --git a/drivers/opus/silk/x86/NSQ_sse.c b/drivers/opus/silk/x86/NSQ_sse.c new file mode 100644 index 0000000000..ac0fa1ab04 --- /dev/null +++ b/drivers/opus/silk/x86/NSQ_sse.c @@ -0,0 +1,717 @@ +/* Copyright (c) 2014, Cisco Systems, INC + Written by XiangMingZhu WeiZhou MinPeng YanWang + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#include "opus/opus_config.h" + +#include <xmmintrin.h> +#include <emmintrin.h> +#include <smmintrin.h> +#include "opus/silk/main.h" +#include "opus/celt/x86/x86cpu.h" +#include "opus/celt/stack_alloc.h" + +static OPUS_INLINE void silk_nsq_scale_states_sse4_1( + const silk_encoder_state *psEncC, /* I Encoder State */ + silk_nsq_state *NSQ, /* I/O NSQ state */ + const opus_int32 x_Q3[], /* I input in Q3 */ + opus_int32 x_sc_Q10[], /* O input scaled with 1/Gain */ + const opus_int16 sLTP[], /* I re-whitened LTP state in Q0 */ + opus_int32 sLTP_Q15[], /* O LTP state matching scaled input */ + opus_int subfr, /* I subframe number */ + const opus_int LTP_scale_Q14, /* I */ + const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */ + const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag */ + const opus_int signal_type /* I Signal type */ +); + +static OPUS_INLINE void silk_noise_shape_quantizer_10_16_sse4_1( + silk_nsq_state *NSQ, /* I/O NSQ state */ + opus_int signalType, /* I Signal type */ + const opus_int32 x_sc_Q10[], /* I */ + opus_int8 pulses[], /* O */ + opus_int16 xq[], /* O */ + opus_int32 sLTP_Q15[], /* I/O LTP state */ + const opus_int16 a_Q12[], /* I Short term prediction coefs */ + const opus_int16 b_Q14[], /* I Long term prediction coefs */ + const opus_int16 AR_shp_Q13[], /* I Noise shaping AR coefs */ + opus_int lag, /* I Pitch lag */ + opus_int32 HarmShapeFIRPacked_Q14, /* I */ + opus_int Tilt_Q14, /* I Spectral tilt */ + opus_int32 LF_shp_Q14, /* I */ + opus_int32 Gain_Q16, /* I */ + opus_int offset_Q10, /* I */ + opus_int length, /* I Input length */ + opus_int32 table[][4] /* I */ +); + +void silk_NSQ_sse4_1( + const silk_encoder_state *psEncC, /* I/O Encoder State */ + silk_nsq_state *NSQ, /* I/O NSQ state */ + SideInfoIndices *psIndices, /* I/O Quantization Indices */ + const opus_int32 x_Q3[], /* I Prefiltered input signal */ + opus_int8 pulses[], /* O Quantized pulse signal */ + const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */ + const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */ + const opus_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */ + const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */ + const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */ + const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */ + const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */ + const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */ + const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */ + const opus_int LTP_scale_Q14 /* I LTP state scaling */ +) +{ + opus_int k, lag, start_idx, LSF_interpolation_flag; + const opus_int16 *A_Q12, *B_Q14, *AR_shp_Q13; + opus_int16 *pxq; + VARDECL( opus_int32, sLTP_Q15 ); + VARDECL( opus_int16, sLTP ); + opus_int32 HarmShapeFIRPacked_Q14; + opus_int offset_Q10; + VARDECL( opus_int32, x_sc_Q10 ); + + opus_int32 table[ 64 ][ 4 ]; + opus_int32 tmp1; + opus_int32 q1_Q10, q2_Q10, rd1_Q20, rd2_Q20; + + SAVE_STACK; + + NSQ->rand_seed = psIndices->Seed; + + /* Set unvoiced lag to the previous one, overwrite later for voiced */ + lag = NSQ->lagPrev; + + silk_assert( NSQ->prev_gain_Q16 != 0 ); + + offset_Q10 = silk_Quantization_Offsets_Q10[ psIndices->signalType >> 1 ][ psIndices->quantOffsetType ]; + + /* 0 */ + q1_Q10 = offset_Q10; + q2_Q10 = offset_Q10 + ( 1024 - QUANT_LEVEL_ADJUST_Q10 ); + rd1_Q20 = q1_Q10 * Lambda_Q10; + rd2_Q20 = q2_Q10 * Lambda_Q10; + + table[ 32 ][ 0 ] = q1_Q10; + table[ 32 ][ 1 ] = q2_Q10; + table[ 32 ][ 2 ] = 2 * (q1_Q10 - q2_Q10); + table[ 32 ][ 3 ] = (rd1_Q20 - rd2_Q20) + (q1_Q10 * q1_Q10 - q2_Q10 * q2_Q10); + + /* -1 */ + q1_Q10 = offset_Q10 - ( 1024 - QUANT_LEVEL_ADJUST_Q10 ); + q2_Q10 = offset_Q10; + rd1_Q20 = - q1_Q10 * Lambda_Q10; + rd2_Q20 = q2_Q10 * Lambda_Q10; + + table[ 31 ][ 0 ] = q1_Q10; + table[ 31 ][ 1 ] = q2_Q10; + table[ 31 ][ 2 ] = 2 * (q1_Q10 - q2_Q10); + table[ 31 ][ 3 ] = (rd1_Q20 - rd2_Q20) + (q1_Q10 * q1_Q10 - q2_Q10 * q2_Q10); + + /* > 0 */ + for (k = 1; k <= 31; k++) + { + tmp1 = offset_Q10 + silk_LSHIFT( k, 10 ); + + q1_Q10 = tmp1 - QUANT_LEVEL_ADJUST_Q10; + q2_Q10 = tmp1 - QUANT_LEVEL_ADJUST_Q10 + 1024; + rd1_Q20 = q1_Q10 * Lambda_Q10; + rd2_Q20 = q2_Q10 * Lambda_Q10; + + table[ 32 + k ][ 0 ] = q1_Q10; + table[ 32 + k ][ 1 ] = q2_Q10; + table[ 32 + k ][ 2 ] = 2 * (q1_Q10 - q2_Q10); + table[ 32 + k ][ 3 ] = (rd1_Q20 - rd2_Q20) + (q1_Q10 * q1_Q10 - q2_Q10 * q2_Q10); + } + + /* < -1 */ + for (k = -32; k <= -2; k++) + { + tmp1 = offset_Q10 + silk_LSHIFT( k, 10 ); + + q1_Q10 = tmp1 + QUANT_LEVEL_ADJUST_Q10; + q2_Q10 = tmp1 + QUANT_LEVEL_ADJUST_Q10 + 1024; + rd1_Q20 = - q1_Q10 * Lambda_Q10; + rd2_Q20 = - q2_Q10 * Lambda_Q10; + + table[ 32 + k ][ 0 ] = q1_Q10; + table[ 32 + k ][ 1 ] = q2_Q10; + table[ 32 + k ][ 2 ] = 2 * (q1_Q10 - q2_Q10); + table[ 32 + k ][ 3 ] = (rd1_Q20 - rd2_Q20) + (q1_Q10 * q1_Q10 - q2_Q10 * q2_Q10); + } + + if( psIndices->NLSFInterpCoef_Q2 == 4 ) { + LSF_interpolation_flag = 0; + } else { + LSF_interpolation_flag = 1; + } + + ALLOC( sLTP_Q15, + psEncC->ltp_mem_length + psEncC->frame_length, opus_int32 ); + ALLOC( sLTP, psEncC->ltp_mem_length + psEncC->frame_length, opus_int16 ); + ALLOC( x_sc_Q10, psEncC->subfr_length, opus_int32 ); + /* Set up pointers to start of sub frame */ + NSQ->sLTP_shp_buf_idx = psEncC->ltp_mem_length; + NSQ->sLTP_buf_idx = psEncC->ltp_mem_length; + pxq = &NSQ->xq[ psEncC->ltp_mem_length ]; + for( k = 0; k < psEncC->nb_subfr; k++ ) { + A_Q12 = &PredCoef_Q12[ (( k >> 1 ) | ( 1 - LSF_interpolation_flag )) * MAX_LPC_ORDER ]; + B_Q14 = <PCoef_Q14[ k * LTP_ORDER ]; + AR_shp_Q13 = &AR2_Q13[ k * MAX_SHAPE_LPC_ORDER ]; + + /* Noise shape parameters */ + silk_assert( HarmShapeGain_Q14[ k ] >= 0 ); + HarmShapeFIRPacked_Q14 = silk_RSHIFT( HarmShapeGain_Q14[ k ], 2 ); + HarmShapeFIRPacked_Q14 |= silk_LSHIFT( (opus_int32)silk_RSHIFT( HarmShapeGain_Q14[ k ], 1 ), 16 ); + + NSQ->rewhite_flag = 0; + if( psIndices->signalType == TYPE_VOICED ) { + /* Voiced */ + lag = pitchL[ k ]; + + /* Re-whitening */ + if( ( k & ( 3 - silk_LSHIFT( LSF_interpolation_flag, 1 ) ) ) == 0 ) { + /* Rewhiten with new A coefs */ + start_idx = psEncC->ltp_mem_length - lag - psEncC->predictLPCOrder - LTP_ORDER / 2; + silk_assert( start_idx > 0 ); + + silk_LPC_analysis_filter( &sLTP[ start_idx ], &NSQ->xq[ start_idx + k * psEncC->subfr_length ], + A_Q12, psEncC->ltp_mem_length - start_idx, psEncC->predictLPCOrder, psEncC->arch ); + + NSQ->rewhite_flag = 1; + NSQ->sLTP_buf_idx = psEncC->ltp_mem_length; + } + } + + silk_nsq_scale_states_sse4_1( psEncC, NSQ, x_Q3, x_sc_Q10, sLTP, sLTP_Q15, k, LTP_scale_Q14, Gains_Q16, pitchL, psIndices->signalType ); + + if ( opus_likely( ( 10 == psEncC->shapingLPCOrder ) && ( 16 == psEncC->predictLPCOrder) ) ) + { + silk_noise_shape_quantizer_10_16_sse4_1( NSQ, psIndices->signalType, x_sc_Q10, pulses, pxq, sLTP_Q15, A_Q12, B_Q14, + AR_shp_Q13, lag, HarmShapeFIRPacked_Q14, Tilt_Q14[ k ], LF_shp_Q14[ k ], Gains_Q16[ k ], + offset_Q10, psEncC->subfr_length, &(table[32]) ); + } + else + { + silk_noise_shape_quantizer( NSQ, psIndices->signalType, x_sc_Q10, pulses, pxq, sLTP_Q15, A_Q12, B_Q14, + AR_shp_Q13, lag, HarmShapeFIRPacked_Q14, Tilt_Q14[ k ], LF_shp_Q14[ k ], Gains_Q16[ k ], Lambda_Q10, + offset_Q10, psEncC->subfr_length, psEncC->shapingLPCOrder, psEncC->predictLPCOrder ); + } + + x_Q3 += psEncC->subfr_length; + pulses += psEncC->subfr_length; + pxq += psEncC->subfr_length; + } + + /* Update lagPrev for next frame */ + NSQ->lagPrev = pitchL[ psEncC->nb_subfr - 1 ]; + + /* Save quantized speech and noise shaping signals */ + /* DEBUG_STORE_DATA( enc.pcm, &NSQ->xq[ psEncC->ltp_mem_length ], psEncC->frame_length * sizeof( opus_int16 ) ) */ + silk_memmove( NSQ->xq, &NSQ->xq[ psEncC->frame_length ], psEncC->ltp_mem_length * sizeof( opus_int16 ) ); + silk_memmove( NSQ->sLTP_shp_Q14, &NSQ->sLTP_shp_Q14[ psEncC->frame_length ], psEncC->ltp_mem_length * sizeof( opus_int32 ) ); + RESTORE_STACK; +} + +/***********************************/ +/* silk_noise_shape_quantizer_10_16 */ +/***********************************/ +static OPUS_INLINE void silk_noise_shape_quantizer_10_16_sse4_1( + silk_nsq_state *NSQ, /* I/O NSQ state */ + opus_int signalType, /* I Signal type */ + const opus_int32 x_sc_Q10[], /* I */ + opus_int8 pulses[], /* O */ + opus_int16 xq[], /* O */ + opus_int32 sLTP_Q15[], /* I/O LTP state */ + const opus_int16 a_Q12[], /* I Short term prediction coefs */ + const opus_int16 b_Q14[], /* I Long term prediction coefs */ + const opus_int16 AR_shp_Q13[], /* I Noise shaping AR coefs */ + opus_int lag, /* I Pitch lag */ + opus_int32 HarmShapeFIRPacked_Q14, /* I */ + opus_int Tilt_Q14, /* I Spectral tilt */ + opus_int32 LF_shp_Q14, /* I */ + opus_int32 Gain_Q16, /* I */ + opus_int offset_Q10, /* I */ + opus_int length, /* I Input length */ + opus_int32 table[][4] /* I */ +) +{ + opus_int i; + opus_int32 LTP_pred_Q13, LPC_pred_Q10, n_AR_Q12, n_LTP_Q13; + opus_int32 n_LF_Q12, r_Q10, q1_Q0, q1_Q10, q2_Q10; + opus_int32 exc_Q14, LPC_exc_Q14, xq_Q14, Gain_Q10; + opus_int32 tmp1, tmp2, sLF_AR_shp_Q14; + opus_int32 *psLPC_Q14, *shp_lag_ptr, *pred_lag_ptr; + + __m128i xmm_tempa, xmm_tempb; + + __m128i xmm_one; + + __m128i psLPC_Q14_hi_01234567, psLPC_Q14_hi_89ABCDEF; + __m128i psLPC_Q14_lo_01234567, psLPC_Q14_lo_89ABCDEF; + __m128i a_Q12_01234567, a_Q12_89ABCDEF; + + __m128i sAR2_Q14_hi_76543210, sAR2_Q14_lo_76543210; + __m128i AR_shp_Q13_76543210; + + shp_lag_ptr = &NSQ->sLTP_shp_Q14[ NSQ->sLTP_shp_buf_idx - lag + HARM_SHAPE_FIR_TAPS / 2 ]; + pred_lag_ptr = &sLTP_Q15[ NSQ->sLTP_buf_idx - lag + LTP_ORDER / 2 ]; + Gain_Q10 = silk_RSHIFT( Gain_Q16, 6 ); + + /* Set up short term AR state */ + psLPC_Q14 = &NSQ->sLPC_Q14[ NSQ_LPC_BUF_LENGTH - 1 ]; + + sLF_AR_shp_Q14 = NSQ->sLF_AR_shp_Q14; + xq_Q14 = psLPC_Q14[ 0 ]; + LTP_pred_Q13 = 0; + + /* load a_Q12 */ + xmm_one = _mm_set_epi8( 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14 ); + + /* load a_Q12[0] - a_Q12[7] */ + a_Q12_01234567 = _mm_loadu_si128( (__m128i *)(&a_Q12[ 0 ] ) ); + /* load a_Q12[ 8 ] - a_Q12[ 15 ] */ + a_Q12_89ABCDEF = _mm_loadu_si128( (__m128i *)(&a_Q12[ 8 ] ) ); + + a_Q12_01234567 = _mm_shuffle_epi8( a_Q12_01234567, xmm_one ); + a_Q12_89ABCDEF = _mm_shuffle_epi8( a_Q12_89ABCDEF, xmm_one ); + + /* load AR_shp_Q13 */ + AR_shp_Q13_76543210 = _mm_loadu_si128( (__m128i *)(&AR_shp_Q13[0] ) ); + + /* load psLPC_Q14 */ + xmm_one = _mm_set_epi8(15, 14, 11, 10, 7, 6, 3, 2, 13, 12, 9, 8, 5, 4, 1, 0 ); + + xmm_tempa = _mm_loadu_si128( (__m128i *)(&psLPC_Q14[-16]) ); + xmm_tempb = _mm_loadu_si128( (__m128i *)(&psLPC_Q14[-12]) ); + + xmm_tempa = _mm_shuffle_epi8( xmm_tempa, xmm_one ); + xmm_tempb = _mm_shuffle_epi8( xmm_tempb, xmm_one ); + + psLPC_Q14_hi_89ABCDEF = _mm_unpackhi_epi64( xmm_tempa, xmm_tempb ); + psLPC_Q14_lo_89ABCDEF = _mm_unpacklo_epi64( xmm_tempa, xmm_tempb ); + + xmm_tempa = _mm_loadu_si128( (__m128i *)(&psLPC_Q14[ -8 ]) ); + xmm_tempb = _mm_loadu_si128( (__m128i *)(&psLPC_Q14[ -4 ]) ); + + xmm_tempa = _mm_shuffle_epi8( xmm_tempa, xmm_one ); + xmm_tempb = _mm_shuffle_epi8( xmm_tempb, xmm_one ); + + psLPC_Q14_hi_01234567 = _mm_unpackhi_epi64( xmm_tempa, xmm_tempb ); + psLPC_Q14_lo_01234567 = _mm_unpacklo_epi64( xmm_tempa, xmm_tempb ); + + /* load sAR2_Q14 */ + xmm_tempa = _mm_loadu_si128( (__m128i *)(&(NSQ->sAR2_Q14[ 0 ]) ) ); + xmm_tempb = _mm_loadu_si128( (__m128i *)(&(NSQ->sAR2_Q14[ 4 ]) ) ); + + xmm_tempa = _mm_shuffle_epi8( xmm_tempa, xmm_one ); + xmm_tempb = _mm_shuffle_epi8( xmm_tempb, xmm_one ); + + sAR2_Q14_hi_76543210 = _mm_unpackhi_epi64( xmm_tempa, xmm_tempb ); + sAR2_Q14_lo_76543210 = _mm_unpacklo_epi64( xmm_tempa, xmm_tempb ); + + /* prepare 1 in 8 * 16bit */ + xmm_one = _mm_set1_epi16(1); + + for( i = 0; i < length; i++ ) + { + /* Short-term prediction */ + __m128i xmm_hi_07, xmm_hi_8F, xmm_lo_07, xmm_lo_8F; + + /* Avoids introducing a bias because silk_SMLAWB() always rounds to -inf */ + LPC_pred_Q10 = 8; /* silk_RSHIFT( predictLPCOrder, 1 ); */ + + /* shift psLPC_Q14 */ + psLPC_Q14_hi_89ABCDEF = _mm_alignr_epi8( psLPC_Q14_hi_01234567, psLPC_Q14_hi_89ABCDEF, 2 ); + psLPC_Q14_lo_89ABCDEF = _mm_alignr_epi8( psLPC_Q14_lo_01234567, psLPC_Q14_lo_89ABCDEF, 2 ); + + psLPC_Q14_hi_01234567 = _mm_srli_si128( psLPC_Q14_hi_01234567, 2 ); + psLPC_Q14_lo_01234567 = _mm_srli_si128( psLPC_Q14_lo_01234567, 2 ); + + psLPC_Q14_hi_01234567 = _mm_insert_epi16( psLPC_Q14_hi_01234567, (xq_Q14 >> 16), 7 ); + psLPC_Q14_lo_01234567 = _mm_insert_epi16( psLPC_Q14_lo_01234567, (xq_Q14), 7 ); + + /* high part, use pmaddwd, results in 4 32-bit */ + xmm_hi_07 = _mm_madd_epi16( psLPC_Q14_hi_01234567, a_Q12_01234567 ); + xmm_hi_8F = _mm_madd_epi16( psLPC_Q14_hi_89ABCDEF, a_Q12_89ABCDEF ); + + /* low part, use pmulhw, results in 8 16-bit, note we need simulate unsigned * signed, _mm_srai_epi16(psLPC_Q14_lo_01234567, 15) */ + xmm_tempa = _mm_cmpgt_epi16( _mm_setzero_si128(), psLPC_Q14_lo_01234567 ); + xmm_tempb = _mm_cmpgt_epi16( _mm_setzero_si128(), psLPC_Q14_lo_89ABCDEF ); + + xmm_tempa = _mm_and_si128( xmm_tempa, a_Q12_01234567 ); + xmm_tempb = _mm_and_si128( xmm_tempb, a_Q12_89ABCDEF ); + + xmm_lo_07 = _mm_mulhi_epi16( psLPC_Q14_lo_01234567, a_Q12_01234567 ); + xmm_lo_8F = _mm_mulhi_epi16( psLPC_Q14_lo_89ABCDEF, a_Q12_89ABCDEF ); + + xmm_lo_07 = _mm_add_epi16( xmm_lo_07, xmm_tempa ); + xmm_lo_8F = _mm_add_epi16( xmm_lo_8F, xmm_tempb ); + + xmm_lo_07 = _mm_madd_epi16( xmm_lo_07, xmm_one ); + xmm_lo_8F = _mm_madd_epi16( xmm_lo_8F, xmm_one ); + + /* accumulate */ + xmm_hi_07 = _mm_add_epi32( xmm_hi_07, xmm_hi_8F ); + xmm_lo_07 = _mm_add_epi32( xmm_lo_07, xmm_lo_8F ); + + xmm_hi_07 = _mm_add_epi32( xmm_hi_07, xmm_lo_07 ); + + xmm_hi_07 = _mm_add_epi32( xmm_hi_07, _mm_unpackhi_epi64(xmm_hi_07, xmm_hi_07 ) ); + xmm_hi_07 = _mm_add_epi32( xmm_hi_07, _mm_shufflelo_epi16(xmm_hi_07, 0x0E ) ); + + LPC_pred_Q10 += _mm_cvtsi128_si32( xmm_hi_07 ); + + /* Long-term prediction */ + if ( opus_likely( signalType == TYPE_VOICED ) ) { + /* Unrolled loop */ + /* Avoids introducing a bias because silk_SMLAWB() always rounds to -inf */ + LTP_pred_Q13 = 2; + { + __m128i b_Q14_3210, b_Q14_0123, pred_lag_ptr_0123; + + b_Q14_3210 = OP_CVTEPI16_EPI32_M64( b_Q14 ); + b_Q14_0123 = _mm_shuffle_epi32( b_Q14_3210, 0x1B ); + + /* loaded: [0] [-1] [-2] [-3] */ + pred_lag_ptr_0123 = _mm_loadu_si128( (__m128i *)(&pred_lag_ptr[ -3 ] ) ); + /* shuffle to [-3] [-2] [-1] [0] and to new xmm */ + xmm_tempa = _mm_shuffle_epi32( pred_lag_ptr_0123, 0x1B ); + /*64-bit multiply, a[2] * b[-2], a[0] * b[0] */ + xmm_tempa = _mm_mul_epi32( xmm_tempa, b_Q14_3210 ); + /* right shift 2 bytes (16 bits), zero extended */ + xmm_tempa = _mm_srli_si128( xmm_tempa, 2 ); + + /* a[1] * b[-1], a[3] * b[-3] */ + pred_lag_ptr_0123 = _mm_mul_epi32( pred_lag_ptr_0123, b_Q14_0123 ); + pred_lag_ptr_0123 = _mm_srli_si128( pred_lag_ptr_0123, 2 ); + + pred_lag_ptr_0123 = _mm_add_epi32( pred_lag_ptr_0123, xmm_tempa ); + /* equal shift right 8 bytes*/ + xmm_tempa = _mm_shuffle_epi32( pred_lag_ptr_0123, _MM_SHUFFLE( 0, 0, 3, 2 ) ); + xmm_tempa = _mm_add_epi32( xmm_tempa, pred_lag_ptr_0123 ); + + LTP_pred_Q13 += _mm_cvtsi128_si32( xmm_tempa ); + + LTP_pred_Q13 = silk_SMLAWB( LTP_pred_Q13, pred_lag_ptr[ -4 ], b_Q14[ 4 ] ); + pred_lag_ptr++; + } + } + + /* Noise shape feedback */ + NSQ->sAR2_Q14[ 9 ] = NSQ->sAR2_Q14[ 8 ]; + NSQ->sAR2_Q14[ 8 ] = _mm_cvtsi128_si32( _mm_srli_si128(_mm_unpackhi_epi16( sAR2_Q14_lo_76543210, sAR2_Q14_hi_76543210 ), 12 ) ); + + sAR2_Q14_hi_76543210 = _mm_slli_si128( sAR2_Q14_hi_76543210, 2 ); + sAR2_Q14_lo_76543210 = _mm_slli_si128( sAR2_Q14_lo_76543210, 2 ); + + sAR2_Q14_hi_76543210 = _mm_insert_epi16( sAR2_Q14_hi_76543210, (xq_Q14 >> 16), 0 ); + sAR2_Q14_lo_76543210 = _mm_insert_epi16( sAR2_Q14_lo_76543210, (xq_Q14), 0 ); + + /* high part, use pmaddwd, results in 4 32-bit */ + xmm_hi_07 = _mm_madd_epi16( sAR2_Q14_hi_76543210, AR_shp_Q13_76543210 ); + + /* low part, use pmulhw, results in 8 16-bit, note we need simulate unsigned * signed,_mm_srai_epi16(sAR2_Q14_lo_76543210, 15) */ + xmm_tempa = _mm_cmpgt_epi16( _mm_setzero_si128(), sAR2_Q14_lo_76543210 ); + xmm_tempa = _mm_and_si128( xmm_tempa, AR_shp_Q13_76543210 ); + + xmm_lo_07 = _mm_mulhi_epi16( sAR2_Q14_lo_76543210, AR_shp_Q13_76543210 ); + xmm_lo_07 = _mm_add_epi16( xmm_lo_07, xmm_tempa ); + + xmm_lo_07 = _mm_madd_epi16( xmm_lo_07, xmm_one ); + + /* accumulate */ + xmm_hi_07 = _mm_add_epi32( xmm_hi_07, xmm_lo_07 ); + + xmm_hi_07 = _mm_add_epi32( xmm_hi_07, _mm_unpackhi_epi64(xmm_hi_07, xmm_hi_07 ) ); + xmm_hi_07 = _mm_add_epi32( xmm_hi_07, _mm_shufflelo_epi16(xmm_hi_07, 0x0E ) ); + + n_AR_Q12 = 5 + _mm_cvtsi128_si32( xmm_hi_07 ); + + n_AR_Q12 = silk_SMLAWB( n_AR_Q12, NSQ->sAR2_Q14[ 8 ], AR_shp_Q13[ 8 ] ); + n_AR_Q12 = silk_SMLAWB( n_AR_Q12, NSQ->sAR2_Q14[ 9 ], AR_shp_Q13[ 9 ] ); + + n_AR_Q12 = silk_LSHIFT32( n_AR_Q12, 1 ); /* Q11 -> Q12 */ + n_AR_Q12 = silk_SMLAWB( n_AR_Q12, sLF_AR_shp_Q14, Tilt_Q14 ); + + n_LF_Q12 = silk_SMULWB( NSQ->sLTP_shp_Q14[ NSQ->sLTP_shp_buf_idx - 1 ], LF_shp_Q14 ); + n_LF_Q12 = silk_SMLAWT( n_LF_Q12, sLF_AR_shp_Q14, LF_shp_Q14 ); + + silk_assert( lag > 0 || signalType != TYPE_VOICED ); + + /* Combine prediction and noise shaping signals */ + tmp1 = silk_SUB32( silk_LSHIFT32( LPC_pred_Q10, 2 ), n_AR_Q12 ); /* Q12 */ + tmp1 = silk_SUB32( tmp1, n_LF_Q12 ); /* Q12 */ + if( lag > 0 ) { + /* Symmetric, packed FIR coefficients */ + n_LTP_Q13 = silk_SMULWB( silk_ADD32( shp_lag_ptr[ 0 ], shp_lag_ptr[ -2 ] ), HarmShapeFIRPacked_Q14 ); + n_LTP_Q13 = silk_SMLAWT( n_LTP_Q13, shp_lag_ptr[ -1 ], HarmShapeFIRPacked_Q14 ); + n_LTP_Q13 = silk_LSHIFT( n_LTP_Q13, 1 ); + shp_lag_ptr++; + + tmp2 = silk_SUB32( LTP_pred_Q13, n_LTP_Q13 ); /* Q13 */ + tmp1 = silk_ADD_LSHIFT32( tmp2, tmp1, 1 ); /* Q13 */ + tmp1 = silk_RSHIFT_ROUND( tmp1, 3 ); /* Q10 */ + } else { + tmp1 = silk_RSHIFT_ROUND( tmp1, 2 ); /* Q10 */ + } + + r_Q10 = silk_SUB32( x_sc_Q10[ i ], tmp1 ); /* residual error Q10 */ + + /* Generate dither */ + NSQ->rand_seed = silk_RAND( NSQ->rand_seed ); + + /* Flip sign depending on dither */ + tmp2 = -r_Q10; + if ( NSQ->rand_seed < 0 ) r_Q10 = tmp2; + + r_Q10 = silk_LIMIT_32( r_Q10, -(31 << 10), 30 << 10 ); + + /* Find two quantization level candidates and measure their rate-distortion */ + q1_Q10 = silk_SUB32( r_Q10, offset_Q10 ); + q1_Q0 = silk_RSHIFT( q1_Q10, 10 ); + + q1_Q10 = table[q1_Q0][0]; + q2_Q10 = table[q1_Q0][1]; + + if (r_Q10 * table[q1_Q0][2] - table[q1_Q0][3] < 0) + { + q1_Q10 = q2_Q10; + } + + pulses[ i ] = (opus_int8)silk_RSHIFT_ROUND( q1_Q10, 10 ); + + /* Excitation */ + exc_Q14 = silk_LSHIFT( q1_Q10, 4 ); + + tmp2 = -exc_Q14; + if ( NSQ->rand_seed < 0 ) exc_Q14 = tmp2; + + /* Add predictions */ + LPC_exc_Q14 = silk_ADD_LSHIFT32( exc_Q14, LTP_pred_Q13, 1 ); + xq_Q14 = silk_ADD_LSHIFT32( LPC_exc_Q14, LPC_pred_Q10, 4 ); + + /* Update states */ + psLPC_Q14++; + *psLPC_Q14 = xq_Q14; + sLF_AR_shp_Q14 = silk_SUB_LSHIFT32( xq_Q14, n_AR_Q12, 2 ); + + NSQ->sLTP_shp_Q14[ NSQ->sLTP_shp_buf_idx ] = silk_SUB_LSHIFT32( sLF_AR_shp_Q14, n_LF_Q12, 2 ); + sLTP_Q15[ NSQ->sLTP_buf_idx ] = silk_LSHIFT( LPC_exc_Q14, 1 ); + NSQ->sLTP_shp_buf_idx++; + NSQ->sLTP_buf_idx++; + + /* Make dither dependent on quantized signal */ + NSQ->rand_seed = silk_ADD32_ovflw( NSQ->rand_seed, pulses[ i ] ); + } + + NSQ->sLF_AR_shp_Q14 = sLF_AR_shp_Q14; + + /* Scale XQ back to normal level before saving */ + psLPC_Q14 = &NSQ->sLPC_Q14[ NSQ_LPC_BUF_LENGTH ]; + + /* write back sAR2_Q14 */ + xmm_tempa = _mm_unpackhi_epi16( sAR2_Q14_lo_76543210, sAR2_Q14_hi_76543210 ); + xmm_tempb = _mm_unpacklo_epi16( sAR2_Q14_lo_76543210, sAR2_Q14_hi_76543210 ); + _mm_storeu_si128( (__m128i *)(&NSQ->sAR2_Q14[ 4 ]), xmm_tempa ); + _mm_storeu_si128( (__m128i *)(&NSQ->sAR2_Q14[ 0 ]), xmm_tempb ); + + /* xq[ i ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( silk_SMULWW( psLPC_Q14[ i ], Gain_Q10 ), 8 ) ); */ + { + __m128i xmm_Gain_Q10; + __m128i xmm_xq_Q14_3210, xmm_xq_Q14_x3x1, xmm_xq_Q14_7654, xmm_xq_Q14_x7x5; + + /* prepare (1 << 7) in packed 4 32-bits */ + xmm_tempa = _mm_set1_epi32( (1 << 7) ); + + /* prepare Gain_Q10 in packed 4 32-bits */ + xmm_Gain_Q10 = _mm_set1_epi32( Gain_Q10 ); + + /* process xq */ + for (i = 0; i < length - 7; i += 8) + { + xmm_xq_Q14_3210 = _mm_loadu_si128( (__m128i *)(&(psLPC_Q14[ i + 0 ] ) ) ); + xmm_xq_Q14_7654 = _mm_loadu_si128( (__m128i *)(&(psLPC_Q14[ i + 4 ] ) ) ); + + /* equal shift right 4 bytes*/ + xmm_xq_Q14_x3x1 = _mm_shuffle_epi32( xmm_xq_Q14_3210, _MM_SHUFFLE( 0, 3, 2, 1 ) ); + /* equal shift right 4 bytes*/ + xmm_xq_Q14_x7x5 = _mm_shuffle_epi32( xmm_xq_Q14_7654, _MM_SHUFFLE( 0, 3, 2, 1 ) ); + + xmm_xq_Q14_3210 = _mm_mul_epi32( xmm_xq_Q14_3210, xmm_Gain_Q10 ); + xmm_xq_Q14_x3x1 = _mm_mul_epi32( xmm_xq_Q14_x3x1, xmm_Gain_Q10 ); + xmm_xq_Q14_7654 = _mm_mul_epi32( xmm_xq_Q14_7654, xmm_Gain_Q10 ); + xmm_xq_Q14_x7x5 = _mm_mul_epi32( xmm_xq_Q14_x7x5, xmm_Gain_Q10 ); + + xmm_xq_Q14_3210 = _mm_srli_epi64( xmm_xq_Q14_3210, 16 ); + xmm_xq_Q14_x3x1 = _mm_slli_epi64( xmm_xq_Q14_x3x1, 16 ); + xmm_xq_Q14_7654 = _mm_srli_epi64( xmm_xq_Q14_7654, 16 ); + xmm_xq_Q14_x7x5 = _mm_slli_epi64( xmm_xq_Q14_x7x5, 16 ); + + xmm_xq_Q14_3210 = _mm_blend_epi16( xmm_xq_Q14_3210, xmm_xq_Q14_x3x1, 0xCC ); + xmm_xq_Q14_7654 = _mm_blend_epi16( xmm_xq_Q14_7654, xmm_xq_Q14_x7x5, 0xCC ); + + /* silk_RSHIFT_ROUND(xq, 8) */ + xmm_xq_Q14_3210 = _mm_add_epi32( xmm_xq_Q14_3210, xmm_tempa ); + xmm_xq_Q14_7654 = _mm_add_epi32( xmm_xq_Q14_7654, xmm_tempa ); + + xmm_xq_Q14_3210 = _mm_srai_epi32( xmm_xq_Q14_3210, 8 ); + xmm_xq_Q14_7654 = _mm_srai_epi32( xmm_xq_Q14_7654, 8 ); + + /* silk_SAT16 */ + xmm_xq_Q14_3210 = _mm_packs_epi32( xmm_xq_Q14_3210, xmm_xq_Q14_7654 ); + + /* save to xq */ + _mm_storeu_si128( (__m128i *)(&xq[ i ] ), xmm_xq_Q14_3210 ); + } + } + for ( ; i < length; i++) + { + xq[i] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( silk_SMULWW( psLPC_Q14[ i ], Gain_Q10 ), 8 ) ); + } + + /* Update LPC synth buffer */ + silk_memcpy( NSQ->sLPC_Q14, &NSQ->sLPC_Q14[ length ], NSQ_LPC_BUF_LENGTH * sizeof( opus_int32 ) ); +} + +static OPUS_INLINE void silk_nsq_scale_states_sse4_1( + const silk_encoder_state *psEncC, /* I Encoder State */ + silk_nsq_state *NSQ, /* I/O NSQ state */ + const opus_int32 x_Q3[], /* I input in Q3 */ + opus_int32 x_sc_Q10[], /* O input scaled with 1/Gain */ + const opus_int16 sLTP[], /* I re-whitened LTP state in Q0 */ + opus_int32 sLTP_Q15[], /* O LTP state matching scaled input */ + opus_int subfr, /* I subframe number */ + const opus_int LTP_scale_Q14, /* I */ + const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */ + const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag */ + const opus_int signal_type /* I Signal type */ +) +{ + opus_int i, lag; + opus_int32 gain_adj_Q16, inv_gain_Q31, inv_gain_Q23; + __m128i xmm_inv_gain_Q23, xmm_x_Q3_x2x0, xmm_x_Q3_x3x1; + + lag = pitchL[ subfr ]; + inv_gain_Q31 = silk_INVERSE32_varQ( silk_max( Gains_Q16[ subfr ], 1 ), 47 ); + silk_assert( inv_gain_Q31 != 0 ); + + /* Calculate gain adjustment factor */ + if( Gains_Q16[ subfr ] != NSQ->prev_gain_Q16 ) { + gain_adj_Q16 = silk_DIV32_varQ( NSQ->prev_gain_Q16, Gains_Q16[ subfr ], 16 ); + } else { + gain_adj_Q16 = (opus_int32)1 << 16; + } + + /* Scale input */ + inv_gain_Q23 = silk_RSHIFT_ROUND( inv_gain_Q31, 8 ); + + /* prepare inv_gain_Q23 in packed 4 32-bits */ + xmm_inv_gain_Q23 = _mm_set1_epi32(inv_gain_Q23); + + for( i = 0; i < psEncC->subfr_length - 3; i += 4 ) { + xmm_x_Q3_x2x0 = _mm_loadu_si128( (__m128i *)(&(x_Q3[ i ] ) ) ); + + /* equal shift right 4 bytes*/ + xmm_x_Q3_x3x1 = _mm_shuffle_epi32( xmm_x_Q3_x2x0, _MM_SHUFFLE( 0, 3, 2, 1 ) ); + + xmm_x_Q3_x2x0 = _mm_mul_epi32( xmm_x_Q3_x2x0, xmm_inv_gain_Q23 ); + xmm_x_Q3_x3x1 = _mm_mul_epi32( xmm_x_Q3_x3x1, xmm_inv_gain_Q23 ); + + xmm_x_Q3_x2x0 = _mm_srli_epi64( xmm_x_Q3_x2x0, 16 ); + xmm_x_Q3_x3x1 = _mm_slli_epi64( xmm_x_Q3_x3x1, 16 ); + + xmm_x_Q3_x2x0 = _mm_blend_epi16( xmm_x_Q3_x2x0, xmm_x_Q3_x3x1, 0xCC ); + + _mm_storeu_si128( (__m128i *)(&(x_sc_Q10[ i ] ) ), xmm_x_Q3_x2x0 ); + } + + for( ; i < psEncC->subfr_length; i++ ) { + x_sc_Q10[ i ] = silk_SMULWW( x_Q3[ i ], inv_gain_Q23 ); + } + + /* Save inverse gain */ + NSQ->prev_gain_Q16 = Gains_Q16[ subfr ]; + + /* After rewhitening the LTP state is un-scaled, so scale with inv_gain_Q16 */ + if( NSQ->rewhite_flag ) { + if( subfr == 0 ) { + /* Do LTP downscaling */ + inv_gain_Q31 = silk_LSHIFT( silk_SMULWB( inv_gain_Q31, LTP_scale_Q14 ), 2 ); + } + for( i = NSQ->sLTP_buf_idx - lag - LTP_ORDER / 2; i < NSQ->sLTP_buf_idx; i++ ) { + silk_assert( i < MAX_FRAME_LENGTH ); + sLTP_Q15[ i ] = silk_SMULWB( inv_gain_Q31, sLTP[ i ] ); + } + } + + /* Adjust for changing gain */ + if( gain_adj_Q16 != (opus_int32)1 << 16 ) { + /* Scale long-term shaping state */ + __m128i xmm_gain_adj_Q16, xmm_sLTP_shp_Q14_x2x0, xmm_sLTP_shp_Q14_x3x1; + + /* prepare gain_adj_Q16 in packed 4 32-bits */ + xmm_gain_adj_Q16 = _mm_set1_epi32(gain_adj_Q16); + + for( i = NSQ->sLTP_shp_buf_idx - psEncC->ltp_mem_length; i < NSQ->sLTP_shp_buf_idx - 3; i += 4 ) + { + xmm_sLTP_shp_Q14_x2x0 = _mm_loadu_si128( (__m128i *)(&(NSQ->sLTP_shp_Q14[ i ] ) ) ); + /* equal shift right 4 bytes*/ + xmm_sLTP_shp_Q14_x3x1 = _mm_shuffle_epi32( xmm_sLTP_shp_Q14_x2x0, _MM_SHUFFLE( 0, 3, 2, 1 ) ); + + xmm_sLTP_shp_Q14_x2x0 = _mm_mul_epi32( xmm_sLTP_shp_Q14_x2x0, xmm_gain_adj_Q16 ); + xmm_sLTP_shp_Q14_x3x1 = _mm_mul_epi32( xmm_sLTP_shp_Q14_x3x1, xmm_gain_adj_Q16 ); + + xmm_sLTP_shp_Q14_x2x0 = _mm_srli_epi64( xmm_sLTP_shp_Q14_x2x0, 16 ); + xmm_sLTP_shp_Q14_x3x1 = _mm_slli_epi64( xmm_sLTP_shp_Q14_x3x1, 16 ); + + xmm_sLTP_shp_Q14_x2x0 = _mm_blend_epi16( xmm_sLTP_shp_Q14_x2x0, xmm_sLTP_shp_Q14_x3x1, 0xCC ); + + _mm_storeu_si128( (__m128i *)(&(NSQ->sLTP_shp_Q14[ i ] ) ), xmm_sLTP_shp_Q14_x2x0 ); + } + + for( ; i < NSQ->sLTP_shp_buf_idx; i++ ) { + NSQ->sLTP_shp_Q14[ i ] = silk_SMULWW( gain_adj_Q16, NSQ->sLTP_shp_Q14[ i ] ); + } + + /* Scale long-term prediction state */ + if( signal_type == TYPE_VOICED && NSQ->rewhite_flag == 0 ) { + for( i = NSQ->sLTP_buf_idx - lag - LTP_ORDER / 2; i < NSQ->sLTP_buf_idx; i++ ) { + sLTP_Q15[ i ] = silk_SMULWW( gain_adj_Q16, sLTP_Q15[ i ] ); + } + } + + NSQ->sLF_AR_shp_Q14 = silk_SMULWW( gain_adj_Q16, NSQ->sLF_AR_shp_Q14 ); + + /* Scale short-term prediction and shaping states */ + for( i = 0; i < NSQ_LPC_BUF_LENGTH; i++ ) { + NSQ->sLPC_Q14[ i ] = silk_SMULWW( gain_adj_Q16, NSQ->sLPC_Q14[ i ] ); + } + for( i = 0; i < MAX_SHAPE_LPC_ORDER; i++ ) { + NSQ->sAR2_Q14[ i ] = silk_SMULWW( gain_adj_Q16, NSQ->sAR2_Q14[ i ] ); + } + } +} diff --git a/drivers/opus/silk/x86/SigProc_FIX_sse.h b/drivers/opus/silk/x86/SigProc_FIX_sse.h new file mode 100644 index 0000000000..67ab30fd78 --- /dev/null +++ b/drivers/opus/silk/x86/SigProc_FIX_sse.h @@ -0,0 +1,91 @@ +/* Copyright (c) 2014, Cisco Systems, INC + Written by XiangMingZhu WeiZhou MinPeng YanWang + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef SIGPROC_FIX_SSE_H +#define SIGPROC_FIX_SSE_H +#include "opus/opus_config.h" + +#if defined(OPUS_X86_MAY_HAVE_SSE4_1) +void silk_burg_modified_sse4_1( + opus_int32 *res_nrg, /* O Residual energy */ + opus_int *res_nrg_Q, /* O Residual energy Q value */ + opus_int32 A_Q16[], /* O Prediction coefficients (length order) */ + const opus_int16 x[], /* I Input signal, length: nb_subfr * ( D + subfr_length ) */ + const opus_int32 minInvGain_Q30, /* I Inverse of max prediction gain */ + const opus_int subfr_length, /* I Input signal subframe length (incl. D preceding samples) */ + const opus_int nb_subfr, /* I Number of subframes stacked in x */ + const opus_int D, /* I Order */ + int arch /* I Run-time architecture */ +); + +#if defined(OPUS_X86_PRESUME_SSE4_1) +#define silk_burg_modified(res_nrg, res_nrg_Q, A_Q16, x, minInvGain_Q30, subfr_length, nb_subfr, D, arch) \ + ((void)(arch), silk_burg_modified_sse4_1(res_nrg, res_nrg_Q, A_Q16, x, minInvGain_Q30, subfr_length, nb_subfr, D, arch)) + +#else + +extern void (*const SILK_BURG_MODIFIED_IMPL[OPUS_ARCHMASK + 1])( + opus_int32 *res_nrg, /* O Residual energy */ + opus_int *res_nrg_Q, /* O Residual energy Q value */ + opus_int32 A_Q16[], /* O Prediction coefficients (length order) */ + const opus_int16 x[], /* I Input signal, length: nb_subfr * ( D + subfr_length ) */ + const opus_int32 minInvGain_Q30, /* I Inverse of max prediction gain */ + const opus_int subfr_length, /* I Input signal subframe length (incl. D preceding samples) */ + const opus_int nb_subfr, /* I Number of subframes stacked in x */ + const opus_int D, /* I Order */ + int arch /* I Run-time architecture */); + +# define silk_burg_modified(res_nrg, res_nrg_Q, A_Q16, x, minInvGain_Q30, subfr_length, nb_subfr, D, arch) \ + ((*SILK_BURG_MODIFIED_IMPL[(arch) & OPUS_ARCHMASK])(res_nrg, res_nrg_Q, A_Q16, x, minInvGain_Q30, subfr_length, nb_subfr, D, arch)) + +#endif + +opus_int64 silk_inner_prod16_aligned_64_sse4_1( + const opus_int16 *inVec1, + const opus_int16 *inVec2, + const opus_int len +); + + +#if defined(OPUS_X86_PRESUME_SSE4_1) + +#define silk_inner_prod16_aligned_64(inVec1, inVec2, len, arch) \ + ((void)(arch),silk_inner_prod16_aligned_64_sse4_1(inVec1, inVec2, len)) + +#else + +extern opus_int64 (*const SILK_INNER_PROD16_ALIGNED_64_IMPL[OPUS_ARCHMASK + 1])( + const opus_int16 *inVec1, + const opus_int16 *inVec2, + const opus_int len); + +# define silk_inner_prod16_aligned_64(inVec1, inVec2, len, arch) \ + ((*SILK_INNER_PROD16_ALIGNED_64_IMPL[(arch) & OPUS_ARCHMASK])(inVec1, inVec2, len)) + +#endif +#endif +#endif diff --git a/drivers/opus/silk/x86/VAD_sse.c b/drivers/opus/silk/x86/VAD_sse.c new file mode 100644 index 0000000000..5db2c86aa9 --- /dev/null +++ b/drivers/opus/silk/x86/VAD_sse.c @@ -0,0 +1,274 @@ +/* Copyright (c) 2014, Cisco Systems, INC + Written by XiangMingZhu WeiZhou MinPeng YanWang + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#include "opus/opus_config.h" + +#include <xmmintrin.h> +#include <emmintrin.h> +#include <smmintrin.h> + +#include "opus/silk/main.h" +#include "opus/celt/stack_alloc.h" + +/* Weighting factors for tilt measure */ +static const opus_int32 tiltWeights[ VAD_N_BANDS ] = { 30000, 6000, -12000, -12000 }; + +/***************************************/ +/* Get the speech activity level in Q8 */ +/***************************************/ +opus_int silk_VAD_GetSA_Q8_sse4_1( /* O Return value, 0 if success */ + silk_encoder_state *psEncC, /* I/O Encoder state */ + const opus_int16 pIn[] /* I PCM input */ +) +{ + opus_int SA_Q15, pSNR_dB_Q7, input_tilt; + opus_int decimated_framelength1, decimated_framelength2; + opus_int decimated_framelength; + opus_int dec_subframe_length, dec_subframe_offset, SNR_Q7, i, b, s; + opus_int32 sumSquared, smooth_coef_Q16; + opus_int16 HPstateTmp; + VARDECL( opus_int16, X ); + opus_int32 Xnrg[ VAD_N_BANDS ]; + opus_int32 NrgToNoiseRatio_Q8[ VAD_N_BANDS ]; + opus_int32 speech_nrg, x_tmp; + opus_int X_offset[ VAD_N_BANDS ]; + opus_int ret = 0; + silk_VAD_state *psSilk_VAD = &psEncC->sVAD; + + SAVE_STACK; + + /* Safety checks */ + silk_assert( VAD_N_BANDS == 4 ); + silk_assert( MAX_FRAME_LENGTH >= psEncC->frame_length ); + silk_assert( psEncC->frame_length <= 512 ); + silk_assert( psEncC->frame_length == 8 * silk_RSHIFT( psEncC->frame_length, 3 ) ); + + /***********************/ + /* Filter and Decimate */ + /***********************/ + decimated_framelength1 = silk_RSHIFT( psEncC->frame_length, 1 ); + decimated_framelength2 = silk_RSHIFT( psEncC->frame_length, 2 ); + decimated_framelength = silk_RSHIFT( psEncC->frame_length, 3 ); + /* Decimate into 4 bands: + 0 L 3L L 3L 5L + - -- - -- -- + 8 8 2 4 4 + + [0-1 kHz| temp. |1-2 kHz| 2-4 kHz | 4-8 kHz | + + They're arranged to allow the minimal ( frame_length / 4 ) extra + scratch space during the downsampling process */ + X_offset[ 0 ] = 0; + X_offset[ 1 ] = decimated_framelength + decimated_framelength2; + X_offset[ 2 ] = X_offset[ 1 ] + decimated_framelength; + X_offset[ 3 ] = X_offset[ 2 ] + decimated_framelength2; + ALLOC( X, X_offset[ 3 ] + decimated_framelength1, opus_int16 ); + + /* 0-8 kHz to 0-4 kHz and 4-8 kHz */ + silk_ana_filt_bank_1( pIn, &psSilk_VAD->AnaState[ 0 ], + X, &X[ X_offset[ 3 ] ], psEncC->frame_length ); + + /* 0-4 kHz to 0-2 kHz and 2-4 kHz */ + silk_ana_filt_bank_1( X, &psSilk_VAD->AnaState1[ 0 ], + X, &X[ X_offset[ 2 ] ], decimated_framelength1 ); + + /* 0-2 kHz to 0-1 kHz and 1-2 kHz */ + silk_ana_filt_bank_1( X, &psSilk_VAD->AnaState2[ 0 ], + X, &X[ X_offset[ 1 ] ], decimated_framelength2 ); + + /*********************************************/ + /* HP filter on lowest band (differentiator) */ + /*********************************************/ + X[ decimated_framelength - 1 ] = silk_RSHIFT( X[ decimated_framelength - 1 ], 1 ); + HPstateTmp = X[ decimated_framelength - 1 ]; + for( i = decimated_framelength - 1; i > 0; i-- ) { + X[ i - 1 ] = silk_RSHIFT( X[ i - 1 ], 1 ); + X[ i ] -= X[ i - 1 ]; + } + X[ 0 ] -= psSilk_VAD->HPstate; + psSilk_VAD->HPstate = HPstateTmp; + + /*************************************/ + /* Calculate the energy in each band */ + /*************************************/ + for( b = 0; b < VAD_N_BANDS; b++ ) { + /* Find the decimated framelength in the non-uniformly divided bands */ + decimated_framelength = silk_RSHIFT( psEncC->frame_length, silk_min_int( VAD_N_BANDS - b, VAD_N_BANDS - 1 ) ); + + /* Split length into subframe lengths */ + dec_subframe_length = silk_RSHIFT( decimated_framelength, VAD_INTERNAL_SUBFRAMES_LOG2 ); + dec_subframe_offset = 0; + + /* Compute energy per sub-frame */ + /* initialize with summed energy of last subframe */ + Xnrg[ b ] = psSilk_VAD->XnrgSubfr[ b ]; + for( s = 0; s < VAD_INTERNAL_SUBFRAMES; s++ ) { + __m128i xmm_X, xmm_acc; + sumSquared = 0; + + xmm_acc = _mm_setzero_si128(); + + for( i = 0; i < dec_subframe_length - 7; i += 8 ) + { + xmm_X = _mm_loadu_si128( (__m128i *)&(X[ X_offset[ b ] + i + dec_subframe_offset ] ) ); + xmm_X = _mm_srai_epi16( xmm_X, 3 ); + xmm_X = _mm_madd_epi16( xmm_X, xmm_X ); + xmm_acc = _mm_add_epi32( xmm_acc, xmm_X ); + } + + xmm_acc = _mm_add_epi32( xmm_acc, _mm_unpackhi_epi64( xmm_acc, xmm_acc ) ); + xmm_acc = _mm_add_epi32( xmm_acc, _mm_shufflelo_epi16( xmm_acc, 0x0E ) ); + + sumSquared += _mm_cvtsi128_si32( xmm_acc ); + + for( ; i < dec_subframe_length; i++ ) { + /* The energy will be less than dec_subframe_length * ( silk_int16_MIN / 8 ) ^ 2. */ + /* Therefore we can accumulate with no risk of overflow (unless dec_subframe_length > 128) */ + x_tmp = silk_RSHIFT( + X[ X_offset[ b ] + i + dec_subframe_offset ], 3 ); + sumSquared = silk_SMLABB( sumSquared, x_tmp, x_tmp ); + + /* Safety check */ + silk_assert( sumSquared >= 0 ); + } + + /* Add/saturate summed energy of current subframe */ + if( s < VAD_INTERNAL_SUBFRAMES - 1 ) { + Xnrg[ b ] = silk_ADD_POS_SAT32( Xnrg[ b ], sumSquared ); + } else { + /* Look-ahead subframe */ + Xnrg[ b ] = silk_ADD_POS_SAT32( Xnrg[ b ], silk_RSHIFT( sumSquared, 1 ) ); + } + + dec_subframe_offset += dec_subframe_length; + } + psSilk_VAD->XnrgSubfr[ b ] = sumSquared; + } + + /********************/ + /* Noise estimation */ + /********************/ + silk_VAD_GetNoiseLevels( &Xnrg[ 0 ], psSilk_VAD ); + + /***********************************************/ + /* Signal-plus-noise to noise ratio estimation */ + /***********************************************/ + sumSquared = 0; + input_tilt = 0; + for( b = 0; b < VAD_N_BANDS; b++ ) { + speech_nrg = Xnrg[ b ] - psSilk_VAD->NL[ b ]; + if( speech_nrg > 0 ) { + /* Divide, with sufficient resolution */ + if( ( Xnrg[ b ] & 0xFF800000 ) == 0 ) { + NrgToNoiseRatio_Q8[ b ] = silk_DIV32( silk_LSHIFT( Xnrg[ b ], 8 ), psSilk_VAD->NL[ b ] + 1 ); + } else { + NrgToNoiseRatio_Q8[ b ] = silk_DIV32( Xnrg[ b ], silk_RSHIFT( psSilk_VAD->NL[ b ], 8 ) + 1 ); + } + + /* Convert to log domain */ + SNR_Q7 = silk_lin2log( NrgToNoiseRatio_Q8[ b ] ) - 8 * 128; + + /* Sum-of-squares */ + sumSquared = silk_SMLABB( sumSquared, SNR_Q7, SNR_Q7 ); /* Q14 */ + + /* Tilt measure */ + if( speech_nrg < ( (opus_int32)1 << 20 ) ) { + /* Scale down SNR value for small subband speech energies */ + SNR_Q7 = silk_SMULWB( silk_LSHIFT( silk_SQRT_APPROX( speech_nrg ), 6 ), SNR_Q7 ); + } + input_tilt = silk_SMLAWB( input_tilt, tiltWeights[ b ], SNR_Q7 ); + } else { + NrgToNoiseRatio_Q8[ b ] = 256; + } + } + + /* Mean-of-squares */ + sumSquared = silk_DIV32_16( sumSquared, VAD_N_BANDS ); /* Q14 */ + + /* Root-mean-square approximation, scale to dBs, and write to output pointer */ + pSNR_dB_Q7 = (opus_int16)( 3 * silk_SQRT_APPROX( sumSquared ) ); /* Q7 */ + + /*********************************/ + /* Speech Probability Estimation */ + /*********************************/ + SA_Q15 = silk_sigm_Q15( silk_SMULWB( VAD_SNR_FACTOR_Q16, pSNR_dB_Q7 ) - VAD_NEGATIVE_OFFSET_Q5 ); + + /**************************/ + /* Frequency Tilt Measure */ + /**************************/ + psEncC->input_tilt_Q15 = silk_LSHIFT( silk_sigm_Q15( input_tilt ) - 16384, 1 ); + + /**************************************************/ + /* Scale the sigmoid output based on power levels */ + /**************************************************/ + speech_nrg = 0; + for( b = 0; b < VAD_N_BANDS; b++ ) { + /* Accumulate signal-without-noise energies, higher frequency bands have more weight */ + speech_nrg += ( b + 1 ) * silk_RSHIFT( Xnrg[ b ] - psSilk_VAD->NL[ b ], 4 ); + } + + /* Power scaling */ + if( speech_nrg <= 0 ) { + SA_Q15 = silk_RSHIFT( SA_Q15, 1 ); + } else if( speech_nrg < 32768 ) { + if( psEncC->frame_length == 10 * psEncC->fs_kHz ) { + speech_nrg = silk_LSHIFT_SAT32( speech_nrg, 16 ); + } else { + speech_nrg = silk_LSHIFT_SAT32( speech_nrg, 15 ); + } + + /* square-root */ + speech_nrg = silk_SQRT_APPROX( speech_nrg ); + SA_Q15 = silk_SMULWB( 32768 + speech_nrg, SA_Q15 ); + } + + /* Copy the resulting speech activity in Q8 */ + psEncC->speech_activity_Q8 = silk_min_int( silk_RSHIFT( SA_Q15, 7 ), silk_uint8_MAX ); + + /***********************************/ + /* Energy Level and SNR estimation */ + /***********************************/ + /* Smoothing coefficient */ + smooth_coef_Q16 = silk_SMULWB( VAD_SNR_SMOOTH_COEF_Q18, silk_SMULWB( (opus_int32)SA_Q15, SA_Q15 ) ); + + if( psEncC->frame_length == 10 * psEncC->fs_kHz ) { + smooth_coef_Q16 >>= 1; + } + + for( b = 0; b < VAD_N_BANDS; b++ ) { + /* compute smoothed energy-to-noise ratio per band */ + psSilk_VAD->NrgRatioSmth_Q8[ b ] = silk_SMLAWB( psSilk_VAD->NrgRatioSmth_Q8[ b ], + NrgToNoiseRatio_Q8[ b ] - psSilk_VAD->NrgRatioSmth_Q8[ b ], smooth_coef_Q16 ); + + /* signal to noise ratio in dB per band */ + SNR_Q7 = 3 * ( silk_lin2log( psSilk_VAD->NrgRatioSmth_Q8[b] ) - 8 * 128 ); + /* quality = sigmoid( 0.25 * ( SNR_dB - 16 ) ); */ + psEncC->input_quality_bands_Q15[ b ] = silk_sigm_Q15( silk_RSHIFT( SNR_Q7 - 16 * 128, 4 ) ); + } + + RESTORE_STACK; + return( ret ); +} diff --git a/drivers/opus/silk/x86/VQ_WMat_EC_sse.c b/drivers/opus/silk/x86/VQ_WMat_EC_sse.c new file mode 100644 index 0000000000..3afa42a6e5 --- /dev/null +++ b/drivers/opus/silk/x86/VQ_WMat_EC_sse.c @@ -0,0 +1,139 @@ +/* Copyright (c) 2014, Cisco Systems, INC + Written by XiangMingZhu WeiZhou MinPeng YanWang + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#include "opus/opus_config.h" + +#include <xmmintrin.h> +#include <emmintrin.h> +#include <smmintrin.h> +#include "opus/silk/main.h" +#include "opus/celt/x86/x86cpu.h" + +/* Entropy constrained matrix-weighted VQ, hard-coded to 5-element vectors, for a single input data vector */ +void silk_VQ_WMat_EC_sse4_1( + opus_int8 *ind, /* O index of best codebook vector */ + opus_int32 *rate_dist_Q14, /* O best weighted quant error + mu * rate */ + opus_int *gain_Q7, /* O sum of absolute LTP coefficients */ + const opus_int16 *in_Q14, /* I input vector to be quantized */ + const opus_int32 *W_Q18, /* I weighting matrix */ + const opus_int8 *cb_Q7, /* I codebook */ + const opus_uint8 *cb_gain_Q7, /* I codebook effective gain */ + const opus_uint8 *cl_Q5, /* I code length for each codebook vector */ + const opus_int mu_Q9, /* I tradeoff betw. weighted error and rate */ + const opus_int32 max_gain_Q7, /* I maximum sum of absolute LTP coefficients */ + opus_int L /* I number of vectors in codebook */ +) +{ + opus_int k, gain_tmp_Q7; + const opus_int8 *cb_row_Q7; + opus_int16 diff_Q14[ 5 ]; + opus_int32 sum1_Q14, sum2_Q16; + + __m128i C_tmp1, C_tmp2, C_tmp3, C_tmp4, C_tmp5; + /* Loop over codebook */ + *rate_dist_Q14 = silk_int32_MAX; + cb_row_Q7 = cb_Q7; + for( k = 0; k < L; k++ ) { + gain_tmp_Q7 = cb_gain_Q7[k]; + + diff_Q14[ 0 ] = in_Q14[ 0 ] - silk_LSHIFT( cb_row_Q7[ 0 ], 7 ); + + C_tmp1 = OP_CVTEPI16_EPI32_M64( &in_Q14[ 1 ] ); + C_tmp2 = OP_CVTEPI8_EPI32_M32( &cb_row_Q7[ 1 ] ); + C_tmp2 = _mm_slli_epi32( C_tmp2, 7 ); + C_tmp1 = _mm_sub_epi32( C_tmp1, C_tmp2 ); + + diff_Q14[ 1 ] = _mm_extract_epi16( C_tmp1, 0 ); + diff_Q14[ 2 ] = _mm_extract_epi16( C_tmp1, 2 ); + diff_Q14[ 3 ] = _mm_extract_epi16( C_tmp1, 4 ); + diff_Q14[ 4 ] = _mm_extract_epi16( C_tmp1, 6 ); + + /* Weighted rate */ + sum1_Q14 = silk_SMULBB( mu_Q9, cl_Q5[ k ] ); + + /* Penalty for too large gain */ + sum1_Q14 = silk_ADD_LSHIFT32( sum1_Q14, silk_max( silk_SUB32( gain_tmp_Q7, max_gain_Q7 ), 0 ), 10 ); + + silk_assert( sum1_Q14 >= 0 ); + + /* first row of W_Q18 */ + C_tmp3 = _mm_loadu_si128( (__m128i *)(&W_Q18[ 1 ] ) ); + C_tmp4 = _mm_mul_epi32( C_tmp3, C_tmp1 ); + C_tmp4 = _mm_srli_si128( C_tmp4, 2 ); + + C_tmp1 = _mm_shuffle_epi32( C_tmp1, _MM_SHUFFLE( 0, 3, 2, 1 ) ); /* shift right 4 bytes */ + C_tmp3 = _mm_shuffle_epi32( C_tmp3, _MM_SHUFFLE( 0, 3, 2, 1 ) ); /* shift right 4 bytes */ + + C_tmp5 = _mm_mul_epi32( C_tmp3, C_tmp1 ); + C_tmp5 = _mm_srli_si128( C_tmp5, 2 ); + + C_tmp5 = _mm_add_epi32( C_tmp4, C_tmp5 ); + C_tmp5 = _mm_slli_epi32( C_tmp5, 1 ); + + C_tmp5 = _mm_add_epi32( C_tmp5, _mm_shuffle_epi32( C_tmp5, _MM_SHUFFLE( 0, 0, 0, 2 ) ) ); + sum2_Q16 = _mm_cvtsi128_si32( C_tmp5 ); + + sum2_Q16 = silk_SMLAWB( sum2_Q16, W_Q18[ 0 ], diff_Q14[ 0 ] ); + sum1_Q14 = silk_SMLAWB( sum1_Q14, sum2_Q16, diff_Q14[ 0 ] ); + + /* second row of W_Q18 */ + sum2_Q16 = silk_SMULWB( W_Q18[ 7 ], diff_Q14[ 2 ] ); + sum2_Q16 = silk_SMLAWB( sum2_Q16, W_Q18[ 8 ], diff_Q14[ 3 ] ); + sum2_Q16 = silk_SMLAWB( sum2_Q16, W_Q18[ 9 ], diff_Q14[ 4 ] ); + sum2_Q16 = silk_LSHIFT( sum2_Q16, 1 ); + sum2_Q16 = silk_SMLAWB( sum2_Q16, W_Q18[ 6 ], diff_Q14[ 1 ] ); + sum1_Q14 = silk_SMLAWB( sum1_Q14, sum2_Q16, diff_Q14[ 1 ] ); + + /* third row of W_Q18 */ + sum2_Q16 = silk_SMULWB( W_Q18[ 13 ], diff_Q14[ 3 ] ); + sum2_Q16 = silk_SMLAWB( sum2_Q16, W_Q18[ 14 ], diff_Q14[ 4 ] ); + sum2_Q16 = silk_LSHIFT( sum2_Q16, 1 ); + sum2_Q16 = silk_SMLAWB( sum2_Q16, W_Q18[ 12 ], diff_Q14[ 2 ] ); + sum1_Q14 = silk_SMLAWB( sum1_Q14, sum2_Q16, diff_Q14[ 2 ] ); + + /* fourth row of W_Q18 */ + sum2_Q16 = silk_SMULWB( W_Q18[ 19 ], diff_Q14[ 4 ] ); + sum2_Q16 = silk_LSHIFT( sum2_Q16, 1 ); + sum2_Q16 = silk_SMLAWB( sum2_Q16, W_Q18[ 18 ], diff_Q14[ 3 ] ); + sum1_Q14 = silk_SMLAWB( sum1_Q14, sum2_Q16, diff_Q14[ 3 ] ); + + /* last row of W_Q18 */ + sum2_Q16 = silk_SMULWB( W_Q18[ 24 ], diff_Q14[ 4 ] ); + sum1_Q14 = silk_SMLAWB( sum1_Q14, sum2_Q16, diff_Q14[ 4 ] ); + + silk_assert( sum1_Q14 >= 0 ); + + /* find best */ + if( sum1_Q14 < *rate_dist_Q14 ) { + *rate_dist_Q14 = sum1_Q14; + *ind = (opus_int8)k; + *gain_Q7 = gain_tmp_Q7; + } + + /* Go to next cbk vector */ + cb_row_Q7 += LTP_ORDER; + } +} diff --git a/drivers/opus/silk/x86/main_sse.h b/drivers/opus/silk/x86/main_sse.h new file mode 100644 index 0000000000..6fef1b358b --- /dev/null +++ b/drivers/opus/silk/x86/main_sse.h @@ -0,0 +1,273 @@ +/* Copyright (c) 2014, Cisco Systems, INC + Written by XiangMingZhu WeiZhou MinPeng YanWang + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef MAIN_SSE_H +#define MAIN_SSE_H +#include "opus/opus_config.h" + +# if defined(OPUS_X86_MAY_HAVE_SSE4_1) + +# define OVERRIDE_silk_VQ_WMat_EC + +void silk_VQ_WMat_EC_sse4_1( + opus_int8 *ind, /* O index of best codebook vector */ + opus_int32 *rate_dist_Q14, /* O best weighted quant error + mu * rate */ + opus_int *gain_Q7, /* O sum of absolute LTP coefficients */ + const opus_int16 *in_Q14, /* I input vector to be quantized */ + const opus_int32 *W_Q18, /* I weighting matrix */ + const opus_int8 *cb_Q7, /* I codebook */ + const opus_uint8 *cb_gain_Q7, /* I codebook effective gain */ + const opus_uint8 *cl_Q5, /* I code length for each codebook vector */ + const opus_int mu_Q9, /* I tradeoff betw. weighted error and rate */ + const opus_int32 max_gain_Q7, /* I maximum sum of absolute LTP coefficients */ + opus_int L /* I number of vectors in codebook */ +); + +#if defined OPUS_X86_PRESUME_SSE4_1 + +#define silk_VQ_WMat_EC(ind, rate_dist_Q14, gain_Q7, in_Q14, W_Q18, cb_Q7, cb_gain_Q7, cl_Q5, \ + mu_Q9, max_gain_Q7, L, arch) \ + ((void)(arch),silk_VQ_WMat_EC_sse4_1(ind, rate_dist_Q14, gain_Q7, in_Q14, W_Q18, cb_Q7, cb_gain_Q7, cl_Q5, \ + mu_Q9, max_gain_Q7, L)) + +#else + +extern void (*const SILK_VQ_WMAT_EC_IMPL[OPUS_ARCHMASK + 1])( + opus_int8 *ind, /* O index of best codebook vector */ + opus_int32 *rate_dist_Q14, /* O best weighted quant error + mu * rate */ + opus_int *gain_Q7, /* O sum of absolute LTP coefficients */ + const opus_int16 *in_Q14, /* I input vector to be quantized */ + const opus_int32 *W_Q18, /* I weighting matrix */ + const opus_int8 *cb_Q7, /* I codebook */ + const opus_uint8 *cb_gain_Q7, /* I codebook effective gain */ + const opus_uint8 *cl_Q5, /* I code length for each codebook vector */ + const opus_int mu_Q9, /* I tradeoff betw. weighted error and rate */ + const opus_int32 max_gain_Q7, /* I maximum sum of absolute LTP coefficients */ + opus_int L /* I number of vectors in codebook */ +); + +# define silk_VQ_WMat_EC(ind, rate_dist_Q14, gain_Q7, in_Q14, W_Q18, cb_Q7, cb_gain_Q7, cl_Q5, \ + mu_Q9, max_gain_Q7, L, arch) \ + ((*SILK_VQ_WMAT_EC_IMPL[(arch) & OPUS_ARCHMASK])(ind, rate_dist_Q14, gain_Q7, in_Q14, W_Q18, cb_Q7, cb_gain_Q7, cl_Q5, \ + mu_Q9, max_gain_Q7, L)) + +#endif + +# define OVERRIDE_silk_NSQ + +void silk_NSQ_sse4_1( + const silk_encoder_state *psEncC, /* I/O Encoder State */ + silk_nsq_state *NSQ, /* I/O NSQ state */ + SideInfoIndices *psIndices, /* I/O Quantization Indices */ + const opus_int32 x_Q3[], /* I Prefiltered input signal */ + opus_int8 pulses[], /* O Quantized pulse signal */ + const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */ + const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */ + const opus_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */ + const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */ + const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */ + const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */ + const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */ + const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */ + const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */ + const opus_int LTP_scale_Q14 /* I LTP state scaling */ +); + +#if defined OPUS_X86_PRESUME_SSE4_1 + +#define silk_NSQ(psEncC, NSQ, psIndices, x_Q3, pulses, PredCoef_Q12, LTPCoef_Q14, AR2_Q13, \ + HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, pitchL, Lambda_Q10, LTP_scale_Q14, arch) \ + ((void)(arch),silk_NSQ_sse4_1(psEncC, NSQ, psIndices, x_Q3, pulses, PredCoef_Q12, LTPCoef_Q14, AR2_Q13, \ + HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, pitchL, Lambda_Q10, LTP_scale_Q14)) + +#else + +extern void (*const SILK_NSQ_IMPL[OPUS_ARCHMASK + 1])( + const silk_encoder_state *psEncC, /* I/O Encoder State */ + silk_nsq_state *NSQ, /* I/O NSQ state */ + SideInfoIndices *psIndices, /* I/O Quantization Indices */ + const opus_int32 x_Q3[], /* I Prefiltered input signal */ + opus_int8 pulses[], /* O Quantized pulse signal */ + const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */ + const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */ + const opus_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */ + const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */ + const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */ + const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */ + const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */ + const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */ + const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */ + const opus_int LTP_scale_Q14 /* I LTP state scaling */ +); + +# define silk_NSQ(psEncC, NSQ, psIndices, x_Q3, pulses, PredCoef_Q12, LTPCoef_Q14, AR2_Q13, \ + HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, pitchL, Lambda_Q10, LTP_scale_Q14, arch) \ + ((*SILK_NSQ_IMPL[(arch) & OPUS_ARCHMASK])(psEncC, NSQ, psIndices, x_Q3, pulses, PredCoef_Q12, LTPCoef_Q14, AR2_Q13, \ + HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, pitchL, Lambda_Q10, LTP_scale_Q14)) + +#endif + +# define OVERRIDE_silk_NSQ_del_dec + +void silk_NSQ_del_dec_sse4_1( + const silk_encoder_state *psEncC, /* I/O Encoder State */ + silk_nsq_state *NSQ, /* I/O NSQ state */ + SideInfoIndices *psIndices, /* I/O Quantization Indices */ + const opus_int32 x_Q3[], /* I Prefiltered input signal */ + opus_int8 pulses[], /* O Quantized pulse signal */ + const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */ + const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */ + const opus_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */ + const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */ + const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */ + const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */ + const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */ + const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */ + const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */ + const opus_int LTP_scale_Q14 /* I LTP state scaling */ +); + +#if defined OPUS_X86_PRESUME_SSE4_1 + +#define silk_NSQ_del_dec(psEncC, NSQ, psIndices, x_Q3, pulses, PredCoef_Q12, LTPCoef_Q14, AR2_Q13, \ + HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, pitchL, Lambda_Q10, LTP_scale_Q14, arch) \ + ((void)(arch),silk_NSQ_del_dec_sse4_1(psEncC, NSQ, psIndices, x_Q3, pulses, PredCoef_Q12, LTPCoef_Q14, AR2_Q13, \ + HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, pitchL, Lambda_Q10, LTP_scale_Q14)) + +#else + +extern void (*const SILK_NSQ_DEL_DEC_IMPL[OPUS_ARCHMASK + 1])( + const silk_encoder_state *psEncC, /* I/O Encoder State */ + silk_nsq_state *NSQ, /* I/O NSQ state */ + SideInfoIndices *psIndices, /* I/O Quantization Indices */ + const opus_int32 x_Q3[], /* I Prefiltered input signal */ + opus_int8 pulses[], /* O Quantized pulse signal */ + const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */ + const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */ + const opus_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */ + const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */ + const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */ + const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */ + const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */ + const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */ + const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */ + const opus_int LTP_scale_Q14 /* I LTP state scaling */ +); + +# define silk_NSQ_del_dec(psEncC, NSQ, psIndices, x_Q3, pulses, PredCoef_Q12, LTPCoef_Q14, AR2_Q13, \ + HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, pitchL, Lambda_Q10, LTP_scale_Q14, arch) \ + ((*SILK_NSQ_DEL_DEC_IMPL[(arch) & OPUS_ARCHMASK])(psEncC, NSQ, psIndices, x_Q3, pulses, PredCoef_Q12, LTPCoef_Q14, AR2_Q13, \ + HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, pitchL, Lambda_Q10, LTP_scale_Q14)) + +#endif + +void silk_noise_shape_quantizer( + silk_nsq_state *NSQ, /* I/O NSQ state */ + opus_int signalType, /* I Signal type */ + const opus_int32 x_sc_Q10[], /* I */ + opus_int8 pulses[], /* O */ + opus_int16 xq[], /* O */ + opus_int32 sLTP_Q15[], /* I/O LTP state */ + const opus_int16 a_Q12[], /* I Short term prediction coefs */ + const opus_int16 b_Q14[], /* I Long term prediction coefs */ + const opus_int16 AR_shp_Q13[], /* I Noise shaping AR coefs */ + opus_int lag, /* I Pitch lag */ + opus_int32 HarmShapeFIRPacked_Q14, /* I */ + opus_int Tilt_Q14, /* I Spectral tilt */ + opus_int32 LF_shp_Q14, /* I */ + opus_int32 Gain_Q16, /* I */ + opus_int Lambda_Q10, /* I */ + opus_int offset_Q10, /* I */ + opus_int length, /* I Input length */ + opus_int shapingLPCOrder, /* I Noise shaping AR filter order */ + opus_int predictLPCOrder /* I Prediction filter order */ +); + +/**************************/ +/* Noise level estimation */ +/**************************/ +void silk_VAD_GetNoiseLevels( + const opus_int32 pX[ VAD_N_BANDS ], /* I subband energies */ + silk_VAD_state *psSilk_VAD /* I/O Pointer to Silk VAD state */ +); + +# define OVERRIDE_silk_VAD_GetSA_Q8 + +opus_int silk_VAD_GetSA_Q8_sse4_1( + silk_encoder_state *psEnC, + const opus_int16 pIn[] +); + +#if defined(OPUS_X86_PRESUME_SSE4_1) +#define silk_VAD_GetSA_Q8(psEnC, pIn, arch) ((void)(arch),silk_VAD_GetSA_Q8_sse4_1(psEnC, pIn)) + +#else + +# define silk_VAD_GetSA_Q8(psEnC, pIn, arch) \ + ((*SILK_VAD_GETSA_Q8_IMPL[(arch) & OPUS_ARCHMASK])(psEnC, pIn)) + +extern opus_int (*const SILK_VAD_GETSA_Q8_IMPL[OPUS_ARCHMASK + 1])( + silk_encoder_state *psEnC, + const opus_int16 pIn[]); + +# define OVERRIDE_silk_warped_LPC_analysis_filter_FIX + +#endif + +void silk_warped_LPC_analysis_filter_FIX_sse4_1( + opus_int32 state[], /* I/O State [order + 1] */ + opus_int32 res_Q2[], /* O Residual signal [length] */ + const opus_int16 coef_Q13[], /* I Coefficients [order] */ + const opus_int16 input[], /* I Input signal [length] */ + const opus_int16 lambda_Q16, /* I Warping factor */ + const opus_int length, /* I Length of input signal */ + const opus_int order /* I Filter order (even) */ +); + +#if defined(OPUS_X86_PRESUME_SSE4_1) +#define silk_warped_LPC_analysis_filter_FIX(state, res_Q2, coef_Q13, input, lambda_Q16, length, order, arch) \ + ((void)(arch),silk_warped_LPC_analysis_filter_FIX_c(state, res_Q2, coef_Q13, input, lambda_Q16, length, order)) + +#else + +extern void (*const SILK_WARPED_LPC_ANALYSIS_FILTER_FIX_IMPL[OPUS_ARCHMASK + 1])( + opus_int32 state[], /* I/O State [order + 1] */ + opus_int32 res_Q2[], /* O Residual signal [length] */ + const opus_int16 coef_Q13[], /* I Coefficients [order] */ + const opus_int16 input[], /* I Input signal [length] */ + const opus_int16 lambda_Q16, /* I Warping factor */ + const opus_int length, /* I Length of input signal */ + const opus_int order /* I Filter order (even) */ +); + +# define silk_warped_LPC_analysis_filter_FIX(state, res_Q2, coef_Q13, input, lambda_Q16, length, order, arch) \ + ((*SILK_WARPED_LPC_ANALYSIS_FILTER_FIX_IMPL[(arch) & OPUS_ARCHMASK])(state, res_Q2, coef_Q13, input, lambda_Q16, length, order)) + +#endif + +# endif +#endif diff --git a/drivers/opus/silk/x86/x86_silk_map.c b/drivers/opus/silk/x86/x86_silk_map.c new file mode 100644 index 0000000000..c3502114d1 --- /dev/null +++ b/drivers/opus/silk/x86/x86_silk_map.c @@ -0,0 +1,171 @@ +/* Copyright (c) 2014, Cisco Systems, INC + Written by XiangMingZhu WeiZhou MinPeng YanWang + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#include "opus/opus_config.h" + +#include "opus/celt/x86/x86cpu.h" +#include "opus/silk/structs.h" +#include "opus/silk/SigProc_FIX.h" +#include "opus/celt/pitch.h" +#include "opus/silk/main.h" + +#if !defined(OPUS_X86_PRESUME_SSE4_1) + +#if defined(FIXED_POINT) + +#include "opus/silk/fixed/main_FIX.h" + +opus_int64 (*const SILK_INNER_PROD16_ALIGNED_64_IMPL[ OPUS_ARCHMASK + 1 ] )( + const opus_int16 *inVec1, + const opus_int16 *inVec2, + const opus_int len +) = { + silk_inner_prod16_aligned_64_c, /* non-sse */ + silk_inner_prod16_aligned_64_c, + silk_inner_prod16_aligned_64_c, + MAY_HAVE_SSE4_1( silk_inner_prod16_aligned_64 ), /* sse4.1 */ + MAY_HAVE_SSE4_1( silk_inner_prod16_aligned_64 ) /* avx */ +}; + +#endif + +opus_int (*const SILK_VAD_GETSA_Q8_IMPL[ OPUS_ARCHMASK + 1 ] )( + silk_encoder_state *psEncC, + const opus_int16 pIn[] +) = { + silk_VAD_GetSA_Q8_c, /* non-sse */ + silk_VAD_GetSA_Q8_c, + silk_VAD_GetSA_Q8_c, + MAY_HAVE_SSE4_1( silk_VAD_GetSA_Q8 ), /* sse4.1 */ + MAY_HAVE_SSE4_1( silk_VAD_GetSA_Q8 ) /* avx */ +}; + +void (*const SILK_NSQ_IMPL[ OPUS_ARCHMASK + 1 ] )( + const silk_encoder_state *psEncC, /* I/O Encoder State */ + silk_nsq_state *NSQ, /* I/O NSQ state */ + SideInfoIndices *psIndices, /* I/O Quantization Indices */ + const opus_int32 x_Q3[], /* I Prefiltered input signal */ + opus_int8 pulses[], /* O Quantized pulse signal */ + const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */ + const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */ + const opus_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */ + const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */ + const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */ + const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */ + const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */ + const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */ + const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */ + const opus_int LTP_scale_Q14 /* I LTP state scaling */ +) = { + silk_NSQ_c, /* non-sse */ + silk_NSQ_c, + silk_NSQ_c, + MAY_HAVE_SSE4_1( silk_NSQ ), /* sse4.1 */ + MAY_HAVE_SSE4_1( silk_NSQ ) /* avx */ +}; + +void (*const SILK_VQ_WMAT_EC_IMPL[ OPUS_ARCHMASK + 1 ] )( + opus_int8 *ind, /* O index of best codebook vector */ + opus_int32 *rate_dist_Q14, /* O best weighted quant error + mu * rate */ + opus_int *gain_Q7, /* O sum of absolute LTP coefficients */ + const opus_int16 *in_Q14, /* I input vector to be quantized */ + const opus_int32 *W_Q18, /* I weighting matrix */ + const opus_int8 *cb_Q7, /* I codebook */ + const opus_uint8 *cb_gain_Q7, /* I codebook effective gain */ + const opus_uint8 *cl_Q5, /* I code length for each codebook vector */ + const opus_int mu_Q9, /* I tradeoff betw. weighted error and rate */ + const opus_int32 max_gain_Q7, /* I maximum sum of absolute LTP coefficients */ + opus_int L /* I number of vectors in codebook */ +) = { + silk_VQ_WMat_EC_c, /* non-sse */ + silk_VQ_WMat_EC_c, + silk_VQ_WMat_EC_c, + MAY_HAVE_SSE4_1( silk_VQ_WMat_EC ), /* sse4.1 */ + MAY_HAVE_SSE4_1( silk_VQ_WMat_EC ) /* avx */ +}; + +void (*const SILK_NSQ_DEL_DEC_IMPL[ OPUS_ARCHMASK + 1 ] )( + const silk_encoder_state *psEncC, /* I/O Encoder State */ + silk_nsq_state *NSQ, /* I/O NSQ state */ + SideInfoIndices *psIndices, /* I/O Quantization Indices */ + const opus_int32 x_Q3[], /* I Prefiltered input signal */ + opus_int8 pulses[], /* O Quantized pulse signal */ + const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */ + const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */ + const opus_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */ + const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */ + const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */ + const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */ + const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */ + const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */ + const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */ + const opus_int LTP_scale_Q14 /* I LTP state scaling */ +) = { + silk_NSQ_del_dec_c, /* non-sse */ + silk_NSQ_del_dec_c, + silk_NSQ_del_dec_c, + MAY_HAVE_SSE4_1( silk_NSQ_del_dec ), /* sse4.1 */ + MAY_HAVE_SSE4_1( silk_NSQ_del_dec ) /* avx */ +}; + +#if defined(FIXED_POINT) + +void (*const SILK_WARPED_LPC_ANALYSIS_FILTER_FIX_IMPL[ OPUS_ARCHMASK + 1 ] )( + opus_int32 state[], /* I/O State [order + 1] */ + opus_int32 res_Q2[], /* O Residual signal [length] */ + const opus_int16 coef_Q13[], /* I Coefficients [order] */ + const opus_int16 input[], /* I Input signal [length] */ + const opus_int16 lambda_Q16, /* I Warping factor */ + const opus_int length, /* I Length of input signal */ + const opus_int order /* I Filter order (even) */ +) = { + silk_warped_LPC_analysis_filter_FIX_c, /* non-sse */ + silk_warped_LPC_analysis_filter_FIX_c, + silk_warped_LPC_analysis_filter_FIX_c, + MAY_HAVE_SSE4_1( silk_warped_LPC_analysis_filter_FIX ), /* sse4.1 */ + MAY_HAVE_SSE4_1( silk_warped_LPC_analysis_filter_FIX ) /* avx */ +}; + +void (*const SILK_BURG_MODIFIED_IMPL[ OPUS_ARCHMASK + 1 ] )( + opus_int32 *res_nrg, /* O Residual energy */ + opus_int *res_nrg_Q, /* O Residual energy Q value */ + opus_int32 A_Q16[], /* O Prediction coefficients (length order) */ + const opus_int16 x[], /* I Input signal, length: nb_subfr * ( D + subfr_length ) */ + const opus_int32 minInvGain_Q30, /* I Inverse of max prediction gain */ + const opus_int subfr_length, /* I Input signal subframe length (incl. D preceding samples) */ + const opus_int nb_subfr, /* I Number of subframes stacked in x */ + const opus_int D, /* I Order */ + int arch /* I Run-time architecture */ +) = { + silk_burg_modified_c, /* non-sse */ + silk_burg_modified_c, + silk_burg_modified_c, + MAY_HAVE_SSE4_1( silk_burg_modified ), /* sse4.1 */ + MAY_HAVE_SSE4_1( silk_burg_modified ) /* avx */ +}; + +#endif +#endif diff --git a/drivers/opus/stream.c b/drivers/opus/stream.c index 8dd23e88e7..2ac12642dd 100644 --- a/drivers/opus/stream.c +++ b/drivers/opus/stream.c @@ -14,9 +14,7 @@ last mod: $Id: vorbisfile.c 17573 2010-10-27 14:53:59Z xiphmont $ ********************************************************************/ -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/internal.h" #include <sys/types.h> diff --git a/drivers/opus/wincerts.c b/drivers/opus/wincerts.c index 2a04eab6d1..1a5b634063 100644 --- a/drivers/opus/wincerts.c +++ b/drivers/opus/wincerts.c @@ -15,10 +15,7 @@ action, so I'm giving up and re-implementing it locally. [1] <http://rt.openssl.org/Ticket/Display.html?id=2158>*/ - -#ifdef OPUS_ENABLED #include "opus/opus_config.h" -#endif #include "opus/internal.h" #if defined(OP_ENABLE_HTTP)&&defined(_WIN32) diff --git a/main/input_default.cpp b/main/input_default.cpp index 226656d8f4..c8b8062eee 100644 --- a/main/input_default.cpp +++ b/main/input_default.cpp @@ -509,6 +509,7 @@ static const char *s_ControllerMappings [] = "05000000362800000100000003010000,OUYA Game Controller,leftx:a0,lefty:a1,dpdown:b9,rightstick:b7,rightshoulder:b5,rightx:a3,start:b16,righty:a4,dpleft:b10,lefttrigger:b12,x:b1,dpup:b8,back:b14,leftstick:b6,leftshoulder:b4,y:b2,a:b0,dpright:b11,righttrigger:b13,b:b3,", "05000000362800000100000004010000,OUYA Game Controller,leftx:a0,lefty:a1,dpdown:b9,rightstick:b7,rightshoulder:b5,rightx:a3,start:b16,righty:a4,dpleft:b10,lefttrigger:b12,x:b1,dpup:b8,back:b14,leftstick:b6,leftshoulder:b4,y:b2,a:b0,dpright:b11,righttrigger:b13,b:b3,", "0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", + "050000004c0500006802000000010000,PS3 Controller (Bluetooth),a:b14,b:b13,y:b12,x:b15,start:b3,guide:b16,back:b0,leftstick:b1,rightstick:b2,leftshoulder:b10,rightshoulder:b11,dpup:b4,dpleft:b7,dpdown:b6,dpright:b5,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b8,righttrigger:b9,", "050000004c050000c405000000010000,PS4 Controller (Bluetooth),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "050000007e0500003003000001000000,Nintendo Wii U Pro Controller,a:b0,b:b1,x:b3,y:b2,back:b8,start:b9,guide:b10,leftshoulder:b4,rightshoulder:b5,leftstick:b11,rightstick:b12,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,dpup:b13,dpleft:b15,dpdown:b14,dpright:b16,", "05000000d6200000ad0d000001000000,Moga Pro,a:b0,b:b1,y:b3,x:b2,start:b6,leftstick:b7,rightstick:b8,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a5,righttrigger:a4,", diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index d0453f0d8e..352b7d645f 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -1479,7 +1479,7 @@ void OS_Windows::set_window_resizable(bool p_enabled){ if (p_enabled) { SetWindowLongPtr(hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW | WS_VISIBLE); } else { - SetWindowLongPtr(hWnd, GWL_STYLE, WS_CAPTION | WS_POPUPWINDOW | WS_VISIBLE); + SetWindowLongPtr(hWnd, GWL_STYLE, WS_CAPTION | WS_MINIMIZEBOX | WS_POPUPWINDOW | WS_VISIBLE); } diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 2912dcb3ae..86ec31a9c2 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -652,8 +652,24 @@ bool Control::has_point(const Point2& p_point) const { return Rect2( Point2(), get_size() ).has_point(p_point); } +void Control::set_drag_forwarding(Control* p_target) { + + if (p_target) + data.drag_owner=p_target->get_instance_ID(); + else + data.drag_owner=0; +} + Variant Control::get_drag_data(const Point2& p_point) { + if (data.drag_owner) { + Object *obj = ObjectDB::get_instance(data.drag_owner); + if (obj) { + Control *c = obj->cast_to<Control>(); + return c->call("get_drag_data_fw",p_point,this); + } + } + if (get_script_instance()) { Variant v=p_point; const Variant *p=&v; @@ -669,6 +685,14 @@ Variant Control::get_drag_data(const Point2& p_point) { bool Control::can_drop_data(const Point2& p_point,const Variant& p_data) const { + if (data.drag_owner) { + Object *obj = ObjectDB::get_instance(data.drag_owner); + if (obj) { + Control *c = obj->cast_to<Control>(); + return c->call("can_drop_data_fw",p_point,p_data,this); + } + } + if (get_script_instance()) { Variant v=p_point; const Variant *p[2]={&v,&p_data}; @@ -683,6 +707,15 @@ bool Control::can_drop_data(const Point2& p_point,const Variant& p_data) const { } void Control::drop_data(const Point2& p_point,const Variant& p_data){ + if (data.drag_owner) { + Object *obj = ObjectDB::get_instance(data.drag_owner); + if (obj) { + Control *c = obj->cast_to<Control>(); + c->call("drop_data_fw",p_point,p_data,this); + return; + } + } + if (get_script_instance()) { Variant v=p_point; const Variant *p[2]={&v,&p_data}; @@ -711,7 +744,6 @@ void Control::set_drag_preview(Control *p_control) { - bool Control::is_window_modal_on_top() const { if (!is_inside_tree()) @@ -2273,6 +2305,7 @@ void Control::_bind_methods() { ObjectTypeDB::bind_method(_MD("grab_click_focus"),&Control::grab_click_focus); + ObjectTypeDB::bind_method(_MD("set_drag_forwarding;","target:Control"),&Control::set_drag_forwarding); ObjectTypeDB::bind_method(_MD("set_drag_preview","control:Control"),&Control::set_drag_preview); ObjectTypeDB::bind_method(_MD("warp_mouse","to_pos"),&Control::warp_mouse); @@ -2380,6 +2413,7 @@ Control::Control() { data.rotation=0; data.parent_canvas_item=NULL; data.scale=Vector2(1,1); + data.drag_owner=0; for (int i=0;i<4;i++) { diff --git a/scene/gui/control.h b/scene/gui/control.h index 1e2db7a575..aa9a7612a5 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -129,6 +129,7 @@ private: bool stop_mouse; Control *parent; + ObjectID drag_owner; bool modal; bool modal_exclusive; Ref<Theme> theme; @@ -229,6 +230,7 @@ public: virtual Size2 get_combined_minimum_size() const; virtual bool has_point(const Point2& p_point) const; virtual bool clips_input() const; + virtual void set_drag_forwarding(Control* p_target); virtual Variant get_drag_data(const Point2& p_point); virtual bool can_drop_data(const Point2& p_point,const Variant& p_data) const; virtual void drop_data(const Point2& p_point,const Variant& p_data); diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h index c9c575fd54..2c3f8a5a01 100644 --- a/scene/gui/item_list.h +++ b/scene/gui/item_list.h @@ -69,6 +69,7 @@ protected: static void _bind_methods(); public: + void add_item(const String& p_item,const Ref<Texture>& p_texture=Ref<Texture>(),bool p_selectable=true); void add_icon_item(const Ref<Texture>& p_item,bool p_selectable=true); diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 41d546c6f7..05f7725a92 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -3926,6 +3926,10 @@ void TextEdit::_update_completion_candidates() { int ci_match=0; for(int i=0;i<completion_strings.size();i++) { if (completion_strings[i].begins_with(s)) { + // don't remove duplicates if no input is provided + if (completion_options.find(completion_strings[i]) != -1 && s != "") { + continue; + } completion_options.push_back(completion_strings[i]); int m=0; int max=MIN(completion_current.length(),completion_strings[i].length()); diff --git a/tools/doc/doc_data.cpp b/tools/doc/doc_data.cpp index 2d0d7617c2..4232a6480d 100644 --- a/tools/doc/doc_data.cpp +++ b/tools/doc/doc_data.cpp @@ -61,6 +61,26 @@ void DocData::merge_from(const DocData& p_data) { continue; if (cf.methods[j].arguments.size()!=m.arguments.size()) continue; + // since polymorphic functions are allowed we need to check the type of + // the arguments so we make sure they are different. + int arg_count = cf.methods[j].arguments.size(); + bool arg_used[arg_count]; + for (int l = 0; l < arg_count; ++l) arg_used[l] = false; + // also there is no guarantee that argument ordering will match, so we + // have to check one by one so we make sure we have an exact match + for (int k = 0; k < arg_count; ++k) { + for (int l = 0; l < arg_count; ++l) + if (cf.methods[j].arguments[k].type == m.arguments[l].type && !arg_used[l]) { + arg_used[l] = true; + break; + } + } + bool not_the_same = false; + for (int l = 0; l < arg_count; ++l) + if (!arg_used[l]) // at least one of the arguments was different + not_the_same = true; + if (not_the_same) + continue; const MethodDoc &mf = cf.methods[j]; diff --git a/tools/editor/addon_editor_plugin.cpp b/tools/editor/addon_editor_plugin.cpp index 4dfb8ff553..3b74330c1e 100644 --- a/tools/editor/addon_editor_plugin.cpp +++ b/tools/editor/addon_editor_plugin.cpp @@ -257,7 +257,7 @@ EditorAddonLibraryItemDescription::EditorAddonLibraryItemDescription() { previews->add_child(preview_hb); get_ok()->set_text("Install"); - get_cancel()->set_text("Close"); + get_cancel()->set_text(TTR("Close")); @@ -1085,24 +1085,24 @@ EditorAddonLibrary::EditorAddonLibrary() { - search_hb->add_child( memnew( Label("Search: "))); + search_hb->add_child( memnew( Label(TTR("Search: ")))); filter =memnew( LineEdit ); search_hb->add_child(filter); filter->set_h_size_flags(SIZE_EXPAND_FILL); filter->connect("text_entered",this,"_search"); - search = memnew( Button("Search")); + search = memnew( Button(TTR("Search"))); search->connect("pressed",this,"_search"); search_hb->add_child(search); search_hb->add_child(memnew( VSeparator )); Button * open_asset = memnew( Button ); - open_asset->set_text("Import"); + open_asset->set_text(TTR("Import")); search_hb->add_child(open_asset); open_asset->connect("pressed",this,"_asset_open"); Button * plugins = memnew( Button ); - plugins->set_text("Plugins"); + plugins->set_text(TTR("Plugins")); search_hb->add_child(plugins); plugins->connect("pressed",this,"_manage_plugins"); @@ -1142,7 +1142,7 @@ EditorAddonLibrary::EditorAddonLibrary() { search_hb2->add_child( memnew( Label("Site: "))); repository = memnew( OptionButton ); - repository->add_item("Godot"); + repository->add_item(TTR("Godot")); search_hb2->add_child(repository); repository->set_h_size_flags(SIZE_EXPAND_FILL); diff --git a/tools/editor/animation_editor.cpp b/tools/editor/animation_editor.cpp index 091bc701cc..f4fda7ba6e 100644 --- a/tools/editor/animation_editor.cpp +++ b/tools/editor/animation_editor.cpp @@ -148,9 +148,9 @@ private: String txt=String::num(exp,2); if (mode==MODE_DISABLED) { - txt="Disabled"; + txt=TTR("Disabled"); } else if (mode==MODE_MULTIPLE) { - txt+=" - All Selection"; + txt+=" - "+TTR("All Selection"); } f->draw(ci,Point2(10,10+f->get_ascent()),txt,color); @@ -317,7 +317,7 @@ public: int existing = animation->track_find_key(track,new_time,true); setting=true; - undo_redo->create_action("Move Add Key",false); + undo_redo->create_action(TTR("Move Add Key"),false); Variant val = animation->track_get_key_value(track,key); float trans = animation->track_get_key_transition(track,key); @@ -345,7 +345,7 @@ public: float val = p_value; float prev_val = animation->track_get_key_transition(track,key); setting=true; - undo_redo->create_action("Anim Change Transition",true); + undo_redo->create_action(TTR("Anim Change Transition"),true); undo_redo->add_do_method(animation.ptr(),"track_set_key_transition",track,key,val); undo_redo->add_undo_method(animation.ptr(),"track_set_key_transition",track,key,prev_val); undo_redo->add_do_method(this,"_update_obj",animation); @@ -366,7 +366,7 @@ public: Dictionary d_new = d_old; d_new[p_name]=p_value; setting=true; - undo_redo->create_action("Anim Change Transform"); + undo_redo->create_action(TTR("Anim Change Transform")); undo_redo->add_do_method(animation.ptr(),"track_set_key_value",track,key,d_new); undo_redo->add_undo_method(animation.ptr(),"track_set_key_value",track,key,d_old); undo_redo->add_do_method(this,"_update_obj",animation); @@ -388,7 +388,7 @@ public: } setting=true; - undo_redo->create_action("Anim Change Value",true); + undo_redo->create_action(TTR("Anim Change Value"),true); Variant prev = animation->track_get_key_value(track,key); undo_redo->add_do_method(animation.ptr(),"track_set_key_value",track,key,value); undo_redo->add_undo_method(animation.ptr(),"track_set_key_value",track,key,prev); @@ -464,7 +464,7 @@ public: } } - undo_redo->create_action("Anim Change Call",mergeable); + undo_redo->create_action(TTR("Anim Change Call"),mergeable); Variant prev = animation->track_get_key_value(track,key); setting=true; undo_redo->add_do_method(animation.ptr(),"track_set_key_value",track,key,d_new); @@ -683,7 +683,7 @@ void AnimationKeyEditor::_menu_add_track(int p_type) { case ADD_TRACK_MENU_ADD_VALUE_TRACK: case ADD_TRACK_MENU_ADD_TRANSFORM_TRACK: { - undo_redo->create_action("Anim Add Track"); + undo_redo->create_action(TTR("Anim Add Track")); undo_redo->add_do_method(animation.ptr(),"add_track",p_type); undo_redo->add_do_method(animation.ptr(),"track_set_path",animation->get_track_count(),"."); undo_redo->add_undo_method(animation.ptr(),"remove_track",animation->get_track_count()); @@ -711,7 +711,7 @@ void AnimationKeyEditor::_menu_track(int p_type) { int idx=selected_track; if (idx>0 && idx<animation->get_track_count()) { - undo_redo->create_action("Move Anim Track Up"); + undo_redo->create_action(TTR("Move Anim Track Up")); undo_redo->add_do_method(animation.ptr(),"track_move_down",idx); undo_redo->add_undo_method(animation.ptr(),"track_move_up",idx-1); undo_redo->commit_action(); @@ -724,7 +724,7 @@ void AnimationKeyEditor::_menu_track(int p_type) { int idx=selected_track; if (idx>=0 && idx<animation->get_track_count()-1) { - undo_redo->create_action("Move Anim Track Down"); + undo_redo->create_action(TTR("Move Anim Track Down")); undo_redo->add_do_method(animation.ptr(),"track_move_up",idx); undo_redo->add_undo_method(animation.ptr(),"track_move_down",idx+1); undo_redo->commit_action(); @@ -736,7 +736,7 @@ void AnimationKeyEditor::_menu_track(int p_type) { int idx=selected_track; if (idx>=0 && idx<animation->get_track_count()) { - undo_redo->create_action("Remove Anim Track"); + undo_redo->create_action(TTR("Remove Anim Track")); undo_redo->add_do_method(animation.ptr(),"remove_track",idx); undo_redo->add_undo_method(animation.ptr(),"add_track",animation->track_get_type(idx),idx); undo_redo->add_undo_method(animation.ptr(),"track_set_path",idx,animation->track_get_path(idx)); @@ -792,7 +792,7 @@ void AnimationKeyEditor::_menu_track(int p_type) { int start_track = p_type==TRACK_MENU_DUPLICATE_TRANSPOSE ? selected_track : top_track; - undo_redo->create_action("Anim Duplicate Keys"); + undo_redo->create_action(TTR("Anim Duplicate Keys")); List<Pair<int,float> > new_selection_values; @@ -889,7 +889,7 @@ void AnimationKeyEditor::_menu_track(int p_type) { case TRACK_MENU_SET_ALL_TRANS_OUTIN: t=-2.0; break; } - undo_redo->create_action("Set Transitions to: "+rtos(t)); + undo_redo->create_action(TTR("Set Transitions to: ")+rtos(t)); for(Map<SelectedKey,KeyInfo>::Element *E=selection.back();E;E=E->prev()) { @@ -1045,7 +1045,7 @@ void AnimationKeyEditor::_cleanup_animation(Ref<Animation> p_animation) { void AnimationKeyEditor::_animation_optimize() { - print_line("OPTIMIZE!"); + animation->optimize(optimize_linear_error->get_val(),optimize_angular_error->get_val(),optimize_max_angle->get_val()); track_editor->update(); undo_redo->clear_history(); @@ -1599,7 +1599,7 @@ void AnimationKeyEditor::_track_editor_draw() { void AnimationKeyEditor::_track_name_changed(const String& p_name) { ERR_FAIL_COND(!animation.is_valid()); - undo_redo->create_action("Anim Track Rename"); + undo_redo->create_action(TTR("Anim Track Rename")); undo_redo->add_do_method(animation.ptr(),"track_set_path",track_name_editing,p_name); undo_redo->add_undo_method(animation.ptr(),"track_set_path",track_name_editing,animation->track_get_path(track_name_editing)); undo_redo->commit_action(); @@ -1615,7 +1615,7 @@ void AnimationKeyEditor::_track_menu_selected(int p_idx) { if (interp_editing!=-1) { ERR_FAIL_INDEX(interp_editing,animation->get_track_count()); - undo_redo->create_action("Anim Track Change Interpolation"); + undo_redo->create_action(TTR("Anim Track Change Interpolation")); undo_redo->add_do_method(animation.ptr(),"track_set_interpolation_type",interp_editing,p_idx); undo_redo->add_undo_method(animation.ptr(),"track_set_interpolation_type",interp_editing,animation->track_get_interpolation_type(interp_editing)); undo_redo->commit_action(); @@ -1625,7 +1625,7 @@ void AnimationKeyEditor::_track_menu_selected(int p_idx) { ERR_FAIL_INDEX(cont_editing,animation->get_track_count()); - undo_redo->create_action("Anim Track Change Value Mode"); + undo_redo->create_action(TTR("Anim Track Change Value Mode")); undo_redo->add_do_method(animation.ptr(),"value_track_set_continuous",cont_editing,p_idx); undo_redo->add_undo_method(animation.ptr(),"value_track_set_continuous",cont_editing,animation->value_track_is_continuous(cont_editing)); undo_redo->commit_action(); @@ -1717,9 +1717,9 @@ void AnimationKeyEditor::_curve_transition_changed(float p_what) { if (selection.size()==0) return; if (selection.size()==1) - undo_redo->create_action("Edit Node Curve",true); + undo_redo->create_action(TTR("Edit Node Curve"),true); else - undo_redo->create_action("Edit Selection Curve",true); + undo_redo->create_action(TTR("Edit Selection Curve"),true); for(Map<SelectedKey,KeyInfo>::Element *E=selection.front();E;E=E->next()) { @@ -1862,7 +1862,7 @@ void AnimationKeyEditor::_track_editor_input_event(const InputEvent& p_input) { } else if (p_input.key.scancode==KEY_DELETE && p_input.key.pressed && click.click==ClickOver::CLICK_NONE) { if (selection.size()) { - undo_redo->create_action("Anim Delete Keys"); + undo_redo->create_action(TTR("Anim Delete Keys")); for(Map<SelectedKey,KeyInfo>::Element *E=selection.back();E;E=E->prev()) { @@ -2096,7 +2096,7 @@ void AnimationKeyEditor::_track_editor_input_event(const InputEvent& p_input) { /* if (ofsx < remove_icon->get_width()) { - undo_redo->create_action("Remove Anim Track"); + undo_redo->create_action(TTR("Remove Anim Track")); undo_redo->add_do_method(animation.ptr(),"remove_track",idx); undo_redo->add_undo_method(animation.ptr(),"add_track",animation->track_get_type(idx),idx); undo_redo->add_undo_method(animation.ptr(),"track_set_path",idx,animation->track_get_path(idx)); @@ -2129,7 +2129,7 @@ void AnimationKeyEditor::_track_editor_input_event(const InputEvent& p_input) { if (ofsx < move_down_icon->get_width()) { if (idx < animation->get_track_count() -1) { - undo_redo->create_action("Move Anim Track Down"); + undo_redo->create_action(TTR("Move Anim Track Down")); undo_redo->add_do_method(animation.ptr(),"track_move_up",idx); undo_redo->add_undo_method(animation.ptr(),"track_move_down",idx+1); undo_redo->commit_action(); @@ -2142,7 +2142,7 @@ void AnimationKeyEditor::_track_editor_input_event(const InputEvent& p_input) { if (ofsx < move_up_icon->get_width()) { if (idx >0) { - undo_redo->create_action("Move Anim Track Up"); + undo_redo->create_action(TTR("Move Anim Track Up")); undo_redo->add_do_method(animation.ptr(),"track_move_down",idx); undo_redo->add_undo_method(animation.ptr(),"track_move_up",idx-1); undo_redo->commit_action(); @@ -2254,7 +2254,7 @@ void AnimationKeyEditor::_track_editor_input_event(const InputEvent& p_input) { } - undo_redo->create_action("Anim Add Key"); + undo_redo->create_action(TTR("Anim Add Key")); undo_redo->add_do_method(animation.ptr(),"track_insert_key",idx,pos,newval,1); undo_redo->add_undo_method(animation.ptr(),"track_remove_key_at_pos",idx,pos); @@ -2419,7 +2419,7 @@ void AnimationKeyEditor::_track_editor_input_event(const InputEvent& p_input) { - undo_redo->create_action("Anim Move Keys"); + undo_redo->create_action(TTR("Anim Move Keys")); List<_AnimMoveRestore> to_restore; @@ -2872,31 +2872,31 @@ void AnimationKeyEditor::_notification(int p_what) { menu_add_track->get_popup()->add_icon_item(get_icon("KeyCall","EditorIcons"),"Add Call Func Track",ADD_TRACK_MENU_ADD_CALL_TRACK); menu_track->set_icon(get_icon("Tools","EditorIcons")); - menu_track->get_popup()->add_item("Scale Selection",TRACK_MENU_SCALE); - menu_track->get_popup()->add_item("Scale From Cursor",TRACK_MENU_SCALE_PIVOT); + menu_track->get_popup()->add_item(TTR("Scale Selection"),TRACK_MENU_SCALE); + menu_track->get_popup()->add_item(TTR("Scale From Cursor"),TRACK_MENU_SCALE_PIVOT); menu_track->get_popup()->add_separator(); - menu_track->get_popup()->add_item("Duplicate Selection",TRACK_MENU_DUPLICATE); - menu_track->get_popup()->add_item("Duplicate Transposed",TRACK_MENU_DUPLICATE_TRANSPOSE); + menu_track->get_popup()->add_item(TTR("Duplicate Selection"),TRACK_MENU_DUPLICATE); + menu_track->get_popup()->add_item(TTR("Duplicate Transposed"),TRACK_MENU_DUPLICATE_TRANSPOSE); menu_track->get_popup()->add_separator(); - menu_track->get_popup()->add_item("Goto Next Step",TRACK_MENU_NEXT_STEP,KEY_MASK_CMD|KEY_RIGHT); - menu_track->get_popup()->add_item("Goto Prev Step",TRACK_MENU_PREV_STEP,KEY_MASK_CMD|KEY_LEFT); + menu_track->get_popup()->add_item(TTR("Goto Next Step"),TRACK_MENU_NEXT_STEP,KEY_MASK_CMD|KEY_RIGHT); + menu_track->get_popup()->add_item(TTR("Goto Prev Step"),TRACK_MENU_PREV_STEP,KEY_MASK_CMD|KEY_LEFT); menu_track->get_popup()->add_separator(); PopupMenu *tpp = memnew( PopupMenu ); - tpp->add_item("Linear",TRACK_MENU_SET_ALL_TRANS_LINEAR); - tpp->add_item("Constant",TRACK_MENU_SET_ALL_TRANS_CONSTANT); - tpp->add_item("In",TRACK_MENU_SET_ALL_TRANS_IN); - tpp->add_item("Out",TRACK_MENU_SET_ALL_TRANS_OUT); - tpp->add_item("In-Out",TRACK_MENU_SET_ALL_TRANS_INOUT); - tpp->add_item("Out-In",TRACK_MENU_SET_ALL_TRANS_OUTIN); - tpp->set_name("Transitions"); + tpp->add_item(TTR("Linear"),TRACK_MENU_SET_ALL_TRANS_LINEAR); + tpp->add_item(TTR("Constant"),TRACK_MENU_SET_ALL_TRANS_CONSTANT); + tpp->add_item(TTR("In"),TRACK_MENU_SET_ALL_TRANS_IN); + tpp->add_item(TTR("Out"),TRACK_MENU_SET_ALL_TRANS_OUT); + tpp->add_item(TTR("In-Out"),TRACK_MENU_SET_ALL_TRANS_INOUT); + tpp->add_item(TTR("Out-In"),TRACK_MENU_SET_ALL_TRANS_OUTIN); + tpp->set_name(TTR("Transitions")); tpp->connect("item_pressed",this,"_menu_track"); optimize_dialog->connect("confirmed",this,"_animation_optimize"); menu_track->get_popup()->add_child(tpp); - //menu_track->get_popup()->add_submenu_item("Set Transitions..","Transitions"); + //menu_track->get_popup()->add_submenu_item(TTR("Set Transitions.."),"Transitions"); //menu_track->get_popup()->add_separator(); - menu_track->get_popup()->add_item("Optimize Animation",TRACK_MENU_OPTIMIZE); - menu_track->get_popup()->add_item("Clean-Up Animation",TRACK_MENU_CLEAN_UP); + menu_track->get_popup()->add_item(TTR("Optimize Animation"),TRACK_MENU_OPTIMIZE); + menu_track->get_popup()->add_item(TTR("Clean-Up Animation"),TRACK_MENU_CLEAN_UP); curve_linear->set_icon(get_icon("CurveLinear","EditorIcons")); curve_in->set_icon(get_icon("CurveIn","EditorIcons")); @@ -3113,11 +3113,11 @@ void AnimationKeyEditor::_query_insert(const InsertData& p_id) { if (bool(EDITOR_DEF("animation/confirm_insert_track",true))) { //potential new key, does not exist if (insert_data.size()==1) - insert_confirm->set_text("Create NEW track for "+p_id.query+" and insert key?"); + insert_confirm->set_text(TTR("Create NEW track for ")+p_id.query+TTR(" and insert key?")); else - insert_confirm->set_text("Create "+itos(insert_data.size())+" NEW tracks and insert keys?"); + insert_confirm->set_text(TTR("Create ")+itos(insert_data.size())+TTR(" NEW tracks and insert keys?")); - insert_confirm->get_ok()->set_text("Create"); + insert_confirm->get_ok()->set_text(TTR("Create")); insert_confirm->popup_centered_minsize(); insert_query=true; } else { @@ -3289,7 +3289,7 @@ void AnimationKeyEditor::insert_value_key(const String& p_property,const Variant void AnimationKeyEditor::_confirm_insert_list() { - undo_redo->create_action("Anim Create & Insert"); + undo_redo->create_action(TTR("Anim Create & Insert")); int last_track = animation->get_track_count(); while(insert_data.size()) { @@ -3310,7 +3310,7 @@ int AnimationKeyEditor::_confirm_insert(InsertData p_id,int p_last_track) { if (p_id.track_idx<0) { created=true; - undo_redo->create_action("Anim Insert Track & Key"); + undo_redo->create_action(TTR("Anim Insert Track & Key")); bool continuous=false; if (p_id.type==Animation::TYPE_VALUE) { @@ -3345,7 +3345,7 @@ int AnimationKeyEditor::_confirm_insert(InsertData p_id,int p_last_track) { undo_redo->add_do_method(animation.ptr(),"value_track_set_continuous",p_id.track_idx,continuous); } else { - undo_redo->create_action("Anim Insert Key"); + undo_redo->create_action(TTR("Anim Insert Key")); } float time = timeline_pos; @@ -3422,7 +3422,7 @@ void AnimationKeyEditor::_animation_len_changed(float p_len) { if (!animation.is_null()) { - undo_redo->create_action("Change Anim Len"); + undo_redo->create_action(TTR("Change Anim Len")); undo_redo->add_do_method(animation.ptr(),"set_length",p_len); undo_redo->add_undo_method(animation.ptr(),"set_length",animation->get_length()); undo_redo->add_do_method(this,"_animation_len_update"); @@ -3451,7 +3451,7 @@ void AnimationKeyEditor::_animation_loop_changed() { if (!animation.is_null()) { - undo_redo->create_action("Change Anim Loop"); + undo_redo->create_action(TTR("Change Anim Loop")); undo_redo->add_do_method(animation.ptr(),"set_loop",loop->is_pressed()); undo_redo->add_undo_method(animation.ptr(),"set_loop",!loop->is_pressed()); undo_redo->commit_action(); @@ -3462,7 +3462,7 @@ void AnimationKeyEditor::_animation_loop_changed() { void AnimationKeyEditor::_create_value_item(int p_type) { - undo_redo->create_action("Anim Create Typed Value Key"); + undo_redo->create_action(TTR("Anim Create Typed Value Key")); Variant::CallError ce; Variant v = Variant::construct(Variant::Type(p_type),NULL,0,ce); @@ -3510,7 +3510,7 @@ void AnimationKeyEditor::_insert_delay() { return; } - undo_redo->create_action("Anim Insert"); + undo_redo->create_action(TTR("Anim Insert")); int last_track = animation->get_track_count(); bool advance=false; @@ -3589,7 +3589,7 @@ void AnimationKeyEditor::_scale() { - undo_redo->create_action("Anim Scale Keys"); + undo_redo->create_action(TTR("Anim Scale Keys")); List<_AnimMoveRestore> to_restore; @@ -3685,7 +3685,7 @@ void AnimationKeyEditor::_scale() { void AnimationKeyEditor::_add_call_track(const NodePath& p_base) { - print_line("BASE IS "+String(p_base)); + Node* base = EditorNode::get_singleton()->get_edited_scene(); if (!base) return; @@ -3698,7 +3698,7 @@ void AnimationKeyEditor::_add_call_track(const NodePath& p_base) { //print_line("root: "+String(root->get_path())); //print_line("path: "+String(path)); - undo_redo->create_action("Anim Add Call Track"); + undo_redo->create_action(TTR("Anim Add Call Track")); undo_redo->add_do_method(animation.ptr(),"add_track",Animation::TYPE_METHOD); undo_redo->add_do_method(animation.ptr(),"track_set_path",animation->get_track_count(),path); undo_redo->add_undo_method(animation.ptr(),"remove_track",animation->get_track_count()); @@ -3801,7 +3801,7 @@ AnimationKeyEditor::AnimationKeyEditor() { zoomicon = memnew( TextureFrame ); hb->add_child(zoomicon); - zoomicon->set_tooltip("Animation zoom."); + zoomicon->set_tooltip(TTR("Animation zoom.")); zoom = memnew( HSlider ); //hb->add_child(zoom); @@ -3813,12 +3813,12 @@ AnimationKeyEditor::AnimationKeyEditor() { zoom->set_stretch_ratio(2); hb->add_child(zoom); zoom->connect("value_changed",this,"_scroll_changed"); - zoom->set_tooltip("Animation zoom."); + zoom->set_tooltip(TTR("Animation zoom.")); hb->add_child( memnew( VSeparator ) ); Label *l = memnew( Label ); - l->set_text("Len(s):"); + l->set_text(TTR("Len(s):")); hb->add_child(l); length = memnew( SpinBox ); @@ -3827,13 +3827,13 @@ AnimationKeyEditor::AnimationKeyEditor() { length->set_step(0.01); length->set_h_size_flags(SIZE_EXPAND_FILL); length->set_stretch_ratio(1); - length->set_tooltip("Animation length (in seconds)."); + length->set_tooltip(TTR("Animation length (in seconds).")); hb->add_child(length); length->connect("value_changed",this,"_animation_len_changed"); l = memnew( Label ); - l->set_text("Step(s):"); + l->set_text(TTR("Step(s):")); hb->add_child(l); step = memnew( SpinBox ); @@ -3843,7 +3843,7 @@ AnimationKeyEditor::AnimationKeyEditor() { step->set_val(0.0); step->set_h_size_flags(SIZE_EXPAND_FILL); step->set_stretch_ratio(1); - step->set_tooltip("Cursor step snap (in seconds)."); + step->set_tooltip(TTR("Cursor step snap (in seconds).")); hb->add_child(step); step->connect("value_changed",this,"_step_changed"); @@ -3852,42 +3852,42 @@ AnimationKeyEditor::AnimationKeyEditor() { loop->set_toggle_mode(true); loop->connect("pressed",this,"_animation_loop_changed"); hb->add_child(loop); - loop->set_tooltip("Enable/Disable looping in animation."); + loop->set_tooltip(TTR("Enable/Disable looping in animation.")); hb->add_child( memnew( VSeparator ) ); menu_add_track = memnew( MenuButton ); hb->add_child(menu_add_track); menu_add_track->get_popup()->connect("item_pressed",this,"_menu_add_track"); - menu_add_track->set_tooltip("Add new tracks."); + menu_add_track->set_tooltip(TTR("Add new tracks.")); move_up_button = memnew( ToolButton ); hb->add_child(move_up_button); move_up_button->connect("pressed",this,"_menu_track",make_binds(TRACK_MENU_MOVE_UP)); move_up_button->set_focus_mode(FOCUS_NONE); move_up_button->set_disabled(true); - move_up_button->set_tooltip("Move current track up."); + move_up_button->set_tooltip(TTR("Move current track up.")); move_down_button = memnew( ToolButton ); hb->add_child(move_down_button); move_down_button->connect("pressed",this,"_menu_track",make_binds(TRACK_MENU_MOVE_DOWN)); move_down_button->set_focus_mode(FOCUS_NONE); move_down_button->set_disabled(true); - move_down_button->set_tooltip("Move current track down."); + move_down_button->set_tooltip(TTR("Move current track down.")); remove_button = memnew( ToolButton ); hb->add_child(remove_button); remove_button->connect("pressed",this,"_menu_track",make_binds(TRACK_MENU_REMOVE)); remove_button->set_focus_mode(FOCUS_NONE); remove_button->set_disabled(true); - remove_button->set_tooltip("Remove selected track."); + remove_button->set_tooltip(TTR("Remove selected track.")); hb->add_child(memnew( VSeparator )); menu_track = memnew( MenuButton ); hb->add_child(menu_track); menu_track->get_popup()->connect("item_pressed",this,"_menu_track"); - menu_track->set_tooltip("Track tools"); + menu_track->set_tooltip(TTR("Track tools")); edit_button = memnew( ToolButton ); edit_button->set_toggle_mode(true); @@ -3895,11 +3895,11 @@ AnimationKeyEditor::AnimationKeyEditor() { edit_button->set_disabled(true); hb->add_child(edit_button); - edit_button->set_tooltip("Enable editing of individual keys by clicking them."); + edit_button->set_tooltip(TTR("Enable editing of individual keys by clicking them.")); optimize_dialog = memnew( ConfirmationDialog ); add_child(optimize_dialog); - optimize_dialog->set_title("Anim. Optimizer"); + optimize_dialog->set_title(TTR("Anim. Optimizer")); VBoxContainer *optimize_vb = memnew( VBoxContainer ); optimize_dialog->add_child(optimize_vb); optimize_dialog->set_child_rect(optimize_vb); @@ -3908,28 +3908,28 @@ AnimationKeyEditor::AnimationKeyEditor() { optimize_linear_error->set_min(0.001); optimize_linear_error->set_step(0.001); optimize_linear_error->set_val(0.05); - optimize_vb->add_margin_child("Max. Linear Error:",optimize_linear_error); + optimize_vb->add_margin_child(TTR("Max. Linear Error:"),optimize_linear_error); optimize_angular_error = memnew( SpinBox ); optimize_angular_error->set_max(1.0); optimize_angular_error->set_min(0.001); optimize_angular_error->set_step(0.001); optimize_angular_error->set_val(0.01); - optimize_vb->add_margin_child("Max. Angular Error:",optimize_angular_error); + optimize_vb->add_margin_child(TTR("Max. Angular Error:"),optimize_angular_error); optimize_max_angle = memnew( SpinBox ); - optimize_vb->add_margin_child("Max Optimizable Angle:",optimize_max_angle); + optimize_vb->add_margin_child(TTR("Max Optimizable Angle:"),optimize_max_angle); optimize_max_angle->set_max(360.0); optimize_max_angle->set_min(0.0); optimize_max_angle->set_step(0.1); optimize_max_angle->set_val(22); - optimize_dialog->get_ok()->set_text("Optimize"); + optimize_dialog->get_ok()->set_text(TTR("Optimize")); /*keying = memnew( Button ); keying->set_toggle_mode(true); - //keying->set_text("Keys"); + //keying->set_text(TTR("Keys")); keying->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_END,60); keying->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,10); keying->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_BEGIN,55); @@ -3939,7 +3939,7 @@ AnimationKeyEditor::AnimationKeyEditor() { */ /* l = memnew( Label ); - l->set_text("Base: "); + l->set_text(TTR("Base: ")); l->set_pos(Point2(0,3)); // dr_panel->add_child(l);*/ @@ -3978,7 +3978,7 @@ AnimationKeyEditor::AnimationKeyEditor() { key_editor = memnew( PropertyEditor ); key_editor->set_area_as_parent_rect(); key_editor->hide_top_label(); - key_editor->set_name("Key"); + key_editor->set_name(TTR("Key")); key_editor_tab->add_child(key_editor); key_edit = memnew( AnimationKeyEdit ); @@ -3992,7 +3992,7 @@ AnimationKeyEditor::AnimationKeyEditor() { type_menu->connect("item_pressed",this,"_create_value_item"); VBoxContainer *curve_vb = memnew( VBoxContainer ); - curve_vb->set_name("Transition"); + curve_vb->set_name(TTR("Transition")); HBoxContainer *curve_hb = memnew( HBoxContainer ); curve_vb->add_child(curve_hb); @@ -4065,13 +4065,13 @@ AnimationKeyEditor::AnimationKeyEditor() { scale->set_min(-99999); scale->set_max(99999); scale->set_step(0.001); - vbc->add_margin_child("Scale Ratio:",scale); + vbc->add_margin_child(TTR("Scale Ratio:"),scale); scale_dialog->connect("confirmed",this,"_scale"); add_child(scale_dialog); call_select = memnew( SceneTreeDialog ); add_child(call_select); - call_select->set_title("Call Functions in Which Node?"); + call_select->set_title(TTR("Call Functions in Which Node?")); cleanup_dialog = memnew( ConfirmationDialog ); add_child(cleanup_dialog); @@ -4079,21 +4079,21 @@ AnimationKeyEditor::AnimationKeyEditor() { cleanup_dialog->add_child(cleanup_vb); cleanup_dialog->set_child_rect(cleanup_vb); cleanup_keys = memnew( CheckButton ); - cleanup_keys->set_text("Remove invalid keys"); + cleanup_keys->set_text(TTR("Remove invalid keys")); cleanup_keys->set_pressed(true); cleanup_vb->add_child(cleanup_keys); cleanup_tracks = memnew( CheckButton ); - cleanup_tracks->set_text("Remove unresolved and empty tracks"); + cleanup_tracks->set_text(TTR("Remove unresolved and empty tracks")); cleanup_tracks->set_pressed(true); cleanup_vb->add_child(cleanup_tracks); cleanup_all = memnew( CheckButton ); - cleanup_all->set_text("Clean-Up all animations"); + cleanup_all->set_text(TTR("Clean-Up all animations")); cleanup_vb->add_child(cleanup_all); - cleanup_dialog->set_title("Clean up Animation(s) (NO UNDO!)"); - cleanup_dialog->get_ok()->set_text("Clean-Up"); + cleanup_dialog->set_title(TTR("Clean up Animation(s) (NO UNDO!)")); + cleanup_dialog->get_ok()->set_text(TTR("Clean-Up")); cleanup_dialog->connect("confirmed",this,"_menu_track",varray(TRACK_MENU_CLEAN_UP_CONFIRM)); diff --git a/tools/editor/array_property_edit.cpp b/tools/editor/array_property_edit.cpp index 66c2782da5..1ff6e644d7 100644 --- a/tools/editor/array_property_edit.cpp +++ b/tools/editor/array_property_edit.cpp @@ -64,7 +64,7 @@ bool ArrayPropertyEdit::_set(const StringName& p_name, const Variant& p_value){ return true; UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); - ur->create_action("Resize Array"); + ur->create_action(TTR("Resize Array")); ur->add_do_method(this,"_set_size",newsize); ur->add_undo_method(this,"_set_size",size); if (newsize<size) { @@ -109,7 +109,7 @@ bool ArrayPropertyEdit::_set(const StringName& p_name, const Variant& p_value){ Variant new_value=Variant::construct(Variant::Type(type),NULL,0,ce); UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); - ur->create_action("Change Array Value Type"); + ur->create_action(TTR("Change Array Value Type")); ur->add_do_method(this,"_set_value",idx,new_value); ur->add_undo_method(this,"_set_value",idx,value); ur->add_do_method(this,"_notif_change"); @@ -126,7 +126,7 @@ bool ArrayPropertyEdit::_set(const StringName& p_name, const Variant& p_value){ Variant value = arr.get(idx); UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); - ur->create_action("Change Array Value"); + ur->create_action(TTR("Change Array Value")); ur->add_do_method(this,"_set_value",idx,p_value); ur->add_undo_method(this,"_set_value",idx,value); ur->add_do_method(this,"_notif_changev",p_name); diff --git a/tools/editor/call_dialog.cpp b/tools/editor/call_dialog.cpp index c5e9cdfa0d..2ab9a79d3b 100644 --- a/tools/editor/call_dialog.cpp +++ b/tools/editor/call_dialog.cpp @@ -239,7 +239,7 @@ void CallDialog::set_object(Object *p_object,StringName p_selected) { return_value->clear(); _update_method_list(); - method_label->set_text("Method List For ' "+p_object->get_type()+" ':"); + method_label->set_text(TTR("Method List For ' ")+p_object->get_type()+" ':"); } CallDialog::CallDialog() { @@ -253,7 +253,7 @@ CallDialog::CallDialog() { call->set_anchor( MARGIN_BOTTOM, ANCHOR_END ); call->set_begin( Point2( 70, 29 ) ); call->set_end( Point2( 15, 15 ) ); - call->set_text("Call"); + call->set_text(TTR("Call")); add_child(call); @@ -262,7 +262,7 @@ CallDialog::CallDialog() { cancel->set_anchor( MARGIN_BOTTOM, ANCHOR_END ); cancel->set_begin( Point2( 15, 29 ) ); cancel->set_end( Point2( 70, 15 ) ); - cancel->set_text("Close"); + cancel->set_text(TTR("Close")); add_child(cancel); @@ -291,21 +291,21 @@ CallDialog::CallDialog() { add_child(property_editor); method_label = memnew( Label ); method_label->set_pos( Point2( 15,25) ); - method_label->set_text("Method List:"); + method_label->set_text(TTR("Method List:")); add_child(method_label); Label *label = memnew( Label ); label->set_anchor_and_margin( MARGIN_LEFT, ANCHOR_RATIO, 0.53 ); label->set_anchor_and_margin( MARGIN_TOP, ANCHOR_BEGIN, 25 ); - label->set_text("Arguments:"); + label->set_text(TTR("Arguments:")); add_child(label); return_label = memnew( Label ); return_label->set_anchor_and_margin( MARGIN_LEFT, ANCHOR_RATIO, 0.53 ); return_label->set_anchor_and_margin( MARGIN_TOP, ANCHOR_END, 85 ); - return_label->set_text("Return:"); + return_label->set_text(TTR("Return:")); add_child(return_label); @@ -323,7 +323,7 @@ CallDialog::CallDialog() { label->set_begin( Point2( 15,54) ); label->set_end( Point2( 16,44) ); - label->set_text("Parameters:"); + label->set_text(TTR("Parameters:")); add_child(label); */ diff --git a/tools/editor/code_editor.cpp b/tools/editor/code_editor.cpp index cf8f40430b..970a0477c1 100644 --- a/tools/editor/code_editor.cpp +++ b/tools/editor/code_editor.cpp @@ -58,9 +58,9 @@ void GotoLineDialog::ok_pressed() { GotoLineDialog::GotoLineDialog() { - set_title("Go to Line"); + set_title(TTR("Go to Line")); Label *l = memnew(Label); - l->set_text("Line Number:"); + l->set_text(TTR("Line Number:")); l->set_pos(Point2(5,5)); add_child(l); @@ -78,13 +78,13 @@ GotoLineDialog::GotoLineDialog() { void FindReplaceDialog::popup_search() { - set_title("Search"); + set_title(TTR("Search")); replace_mc->hide(); replace_label->hide(); replace_vb->hide(); skip->hide(); popup_centered(Point2(300,190)); - get_ok()->set_text("Find"); + get_ok()->set_text(TTR("Find")); search_text->grab_focus(); if (text_edit->is_selection_active() && ( text_edit->get_selection_from_line() == text_edit->get_selection_to_line())) { @@ -98,7 +98,7 @@ void FindReplaceDialog::popup_search() { void FindReplaceDialog::popup_replace() { - set_title("Replace"); + set_title(TTR("Replace")); bool do_selection=(text_edit->is_selection_active() && text_edit->get_selection_from_line() < text_edit->get_selection_to_line()); set_replace_selection_only(do_selection); @@ -121,12 +121,12 @@ void FindReplaceDialog::popup_replace() { if (prompt->is_pressed()) { skip->show(); - get_ok()->set_text("Next"); + get_ok()->set_text(TTR("Next")); selection_only->set_disabled(true); } else { skip->hide(); - get_ok()->set_text("Replace"); + get_ok()->set_text(TTR("Replace")); selection_only->set_disabled(false); } @@ -216,7 +216,7 @@ void FindReplaceDialog::_replace() { text_edit->set_v_scroll(vsval); // text_edit->set_h_scroll(hsval); - error_label->set_text("Replaced "+itos(rc)+" ocurrence(s)."); + error_label->set_text(TTR("Replaced ")+itos(rc)+TTR(" ocurrence(s).")); //hide(); @@ -274,7 +274,7 @@ bool FindReplaceDialog::_search() { return true; } else { - set_error("Not Found!"); + set_error(TTR("Not Found!")); return false; } @@ -284,12 +284,12 @@ void FindReplaceDialog::_prompt_changed() { if (prompt->is_pressed()) { skip->show(); - get_ok()->set_text("Next"); + get_ok()->set_text(TTR("Next")); selection_only->set_disabled(true); } else { skip->hide(); - get_ok()->set_text("Replace"); + get_ok()->set_text(TTR("Replace")); selection_only->set_disabled(false); } } @@ -404,14 +404,14 @@ FindReplaceDialog::FindReplaceDialog() { search_text = memnew( LineEdit ); - vb->add_margin_child("Search",search_text); + vb->add_margin_child(TTR("Search"),search_text); search_text->connect("text_entered", this,"_search_text_entered"); //search_text->set_self_opacity(0.7); replace_label = memnew( Label); - replace_label->set_text("Replace By"); + replace_label->set_text(TTR("Replace By")); vb->add_child(replace_label); replace_mc= memnew( MarginContainer); vb->add_child(replace_mc); @@ -436,15 +436,15 @@ FindReplaceDialog::FindReplaceDialog() { svb ->add_child(memnew(Label)); whole_words = memnew( CheckButton ); - whole_words->set_text("Whole Words"); + whole_words->set_text(TTR("Whole Words")); svb->add_child(whole_words); case_sensitive = memnew( CheckButton ); - case_sensitive->set_text("Case Sensitive"); + case_sensitive->set_text(TTR("Case Sensitive")); svb->add_child(case_sensitive); backwards = memnew( CheckButton ); - backwards->set_text("Backwards"); + backwards->set_text(TTR("Backwards")); svb->add_child(backwards); opt_mg = memnew( MarginContainer ); @@ -456,12 +456,12 @@ FindReplaceDialog::FindReplaceDialog() { rvb ->add_child(memnew(Label)); prompt = memnew( CheckButton ); - prompt->set_text("Prompt On Replace"); + prompt->set_text(TTR("Prompt On Replace")); rvb->add_child(prompt); prompt->connect("pressed", this,"_prompt_changed"); selection_only = memnew( CheckButton ); - selection_only->set_text("Selection Only"); + selection_only->set_text(TTR("Selection Only")); rvb->add_child(selection_only); @@ -475,7 +475,7 @@ FindReplaceDialog::FindReplaceDialog() { skip->set_anchor( MARGIN_BOTTOM, ANCHOR_END ); skip->set_begin( Point2( 70, button_margin ) ); skip->set_end( Point2( 10, margin ) ); - skip->set_text("Skip"); + skip->set_text(TTR("Skip")); add_child(skip); skip->connect("pressed", this,"_skip_pressed"); @@ -498,7 +498,7 @@ FindReplaceDialog::FindReplaceDialog() { void CodeTextEditor::_line_col_changed() { - String text = String()+"Line: "+itos(text_editor->cursor_get_line()+1)+", Col: "+itos(text_editor->cursor_get_column()); + String text = String()+TTR("Line: ")+itos(text_editor->cursor_get_line()+1)+TTR(", Col: ")+itos(text_editor->cursor_get_column()); line_col->set_text(text); } diff --git a/tools/editor/connections_dialog.cpp b/tools/editor/connections_dialog.cpp index 962062ae01..3795860472 100644 --- a/tools/editor/connections_dialog.cpp +++ b/tools/editor/connections_dialog.cpp @@ -176,7 +176,7 @@ void ConnectDialog::ok_pressed() { if (dst_method->get_text()=="") { - error->set_text("Method in target Node must be specified!"); + error->set_text(TTR("Method in target Node must be specified!")); error->popup_centered_minsize(); return; } @@ -294,20 +294,20 @@ void ConnectDialog::_bind_methods() { ConnectDialog::ConnectDialog() { - int margin = get_constant("margin","Dialogs"); - int button_margin = get_constant("button_margin","Dialogs"); + int margin = get_constant("margin",TTR("Dialogs")); + int button_margin = get_constant("button_margin",TTR("Dialogs")); Label * label = memnew( Label ); label->set_pos( Point2( 8,11) ); - label->set_text("Connect To Node:"); + label->set_text(TTR("Connect To Node:")); add_child(label); label = memnew( Label ); label->set_anchor( MARGIN_LEFT, ANCHOR_RATIO ); label->set_pos( Point2( 0.5,11) ); - label->set_text("Binds (Extra Params):"); + label->set_text(TTR("Binds (Extra Params):")); add_child(label); @@ -360,7 +360,7 @@ ConnectDialog::ConnectDialog() { add_bind->set_anchor( MARGIN_LEFT, ANCHOR_RATIO ); add_bind->set_begin( Point2( 0.76,32) ); add_bind->set_end( Point2( 0.84,33 ) ); - add_bind->set_text("Add"); + add_bind->set_text(TTR("Add")); add_child(add_bind); add_bind->connect("pressed",this,"_add_bind"); @@ -369,7 +369,7 @@ ConnectDialog::ConnectDialog() { del_bind->set_anchor( MARGIN_LEFT, ANCHOR_RATIO ); del_bind->set_begin( Point2( 0.85,32) ); del_bind->set_end( Point2( 15,33 ) ); - del_bind->set_text("Remove"); + del_bind->set_text(TTR("Remove")); add_child(del_bind); del_bind->connect("pressed",this,"_remove_bind"); @@ -378,7 +378,7 @@ ConnectDialog::ConnectDialog() { label->set_anchor( MARGIN_TOP, ANCHOR_END ); label->set_begin( Point2( 8,124) ); label->set_end( Point2( 15,99) ); - label->set_text("Path To Node:"); + label->set_text(TTR("Path To Node:")); add_child(label); @@ -397,7 +397,7 @@ ConnectDialog::ConnectDialog() { label->set_anchor( MARGIN_BOTTOM, ANCHOR_END ); label->set_begin( Point2( 8,78 ) ); label->set_end( Point2( 15,52 ) ); - label->set_text("Method In Node:"); + label->set_text(TTR("Method In Node:")); add_child(label); @@ -416,7 +416,7 @@ ConnectDialog::ConnectDialog() { /*dst_method_list = memnew( MenuButton ); - dst_method_list->set_text("List.."); + dst_method_list->set_text(TTR("List..")); dst_method_list->set_anchor( MARGIN_RIGHT, ANCHOR_END ); dst_method_list->set_anchor( MARGIN_LEFT, ANCHOR_END ); dst_method_list->set_anchor( MARGIN_TOP, ANCHOR_END ); @@ -429,15 +429,15 @@ ConnectDialog::ConnectDialog() { make_callback = memnew( CheckButton ); make_callback->set_toggle_mode(true); make_callback->set_pressed( EDITOR_DEF("text_editor/create_signal_callbacks",true)); - make_callback->set_text("Make Function "); + make_callback->set_text(TTR("Make Function ")); dstm_hb->add_child(make_callback); deferred = memnew( CheckButton ); - deferred->set_text("Deferred"); + deferred->set_text(TTR("Deferred")); dstm_hb->add_child(deferred); oneshot = memnew( CheckButton ); - oneshot->set_text("Oneshot"); + oneshot->set_text(TTR("Oneshot")); dstm_hb->add_child(oneshot); /* @@ -447,7 +447,7 @@ ConnectDialog::ConnectDialog() { realtime->set_anchor( MARGIN_RIGHT, ANCHOR_END ); realtime->set_begin( Point2( 120, button_margin-10 ) ); realtime->set_end( Point2( 80, margin ) ); - realtime->set_text("Realtime"); + realtime->set_text(TTR("Realtime")); add_child(realtime); */ @@ -463,9 +463,9 @@ ConnectDialog::ConnectDialog() { error = memnew( ConfirmationDialog ); add_child(error); - error->get_ok()->set_text("Close"); - get_ok()->set_text("Connect"); -// error->get_cancel()->set_text("Close"); + error->get_ok()->set_text(TTR("Close")); + get_ok()->set_text(TTR("Connect")); +// error->get_cancel()->set_text(TTR("Close")); @@ -511,7 +511,7 @@ void ConnectionsDialog::_connect() { StringArray args = it->get_metadata(0).operator Dictionary()["args"]; int flags = CONNECT_PERSIST | (defer?CONNECT_DEFERRED:0) | (oshot?CONNECT_ONESHOT:0); - undo_redo->create_action("Connect '"+signal+"' to '"+String(dst_method)+"'"); + undo_redo->create_action(TTR("Connect '")+signal+"' to '"+String(dst_method)+"'"); undo_redo->add_do_method(node,"connect",signal,target,dst_method,binds,flags); undo_redo->add_undo_method(node,"disconnect",signal,target,dst_method); undo_redo->add_do_method(this,"update_tree"); @@ -572,7 +572,7 @@ void ConnectionsDialog::ok_pressed() { Connection c=item->get_metadata(0); ERR_FAIL_COND(c.source!=node); //shouldn't happen but...bugcheck - undo_redo->create_action("Create Subscription"); + undo_redo->create_action(TTR("Create Subscription")); undo_redo->add_do_method(node,"disconnect",c.signal,c.target,c.method); undo_redo->add_undo_method(node,"connect",c.signal,c.target,c.method,Vector<Variant>(),c.flags); undo_redo->add_do_method(this,"update_tree"); @@ -610,7 +610,7 @@ void ConnectionsDialog::_remove_confirm() { Dictionary meta=selected->get_metadata(0); - undo_redo->create_action("Remove Subscription"); + undo_redo->create_action(TTR("Remove Subscription")); undo_redo->add_do_method(node,"unsubscribe_path_event",meta["from_event"].operator String(),meta["from_path"].operator NodePath(),meta["to_method"].operator String()); undo_redo->add_undo_method(node,"subscribe_path_event_persist",meta["from_event"].operator String(),meta["from_path"].operator NodePath(),meta["to_method"].operator String(),Array(),false); undo_redo->add_do_method(this,"update_tree"); @@ -773,7 +773,7 @@ void ConnectionsDialog::update_tree() { } } - get_ok()->set_text("Connect"); + get_ok()->set_text(TTR("Connect")); get_ok()->set_disabled(true); } @@ -789,17 +789,17 @@ void ConnectionsDialog::_something_selected() { TreeItem *item = tree->get_selected(); if (!item) { //no idea how this happened, but disable - get_ok()->set_text("Connect.."); + get_ok()->set_text(TTR("Connect..")); get_ok()->set_disabled(true); } else if (item->get_parent()==tree->get_root() || item->get_parent()->get_parent()==tree->get_root()) { //a signal - connect - get_ok()->set_text("Connect.."); + get_ok()->set_text(TTR("Connect..")); get_ok()->set_disabled(false); } else { //a slot- disconnect - get_ok()->set_text("Disconnect"); + get_ok()->set_text(TTR("Disconnect")); get_ok()->set_disabled(false); } @@ -820,7 +820,7 @@ void ConnectionsDialog::_bind_methods() { ConnectionsDialog::ConnectionsDialog(EditorNode *p_editor) { editor=p_editor; - set_title("Edit Connections.."); + set_title(TTR("Edit Connections..")); set_hide_on_ok(false); VBoxContainer *vbc = memnew( VBoxContainer ); @@ -833,7 +833,7 @@ ConnectionsDialog::ConnectionsDialog(EditorNode *p_editor) { tree->set_columns(1); tree->set_select_mode(Tree::SELECT_ROW); tree->set_hide_root(true); - vbc->add_margin_child("Connections:",tree,true); + vbc->add_margin_child(TTR("Connections:"),tree,true); // add_child(tree); @@ -858,7 +858,7 @@ ConnectionsDialog::ConnectionsDialog(EditorNode *p_editor) { remove_confirm->connect("confirmed", this,"_remove_confirm"); connect_dialog->connect("connected", this,"_connect"); tree->connect("item_selected", this,"_something_selected"); - get_cancel()->set_text("Close"); + get_cancel()->set_text(TTR("Close")); } diff --git a/tools/editor/create_dialog.cpp b/tools/editor/create_dialog.cpp index 35688917fb..c156b1b2de 100644 --- a/tools/editor/create_dialog.cpp +++ b/tools/editor/create_dialog.cpp @@ -251,7 +251,7 @@ void CreateDialog::_notification(int p_what) { void CreateDialog::set_base_type(const String& p_base) { base_type=p_base; - set_title("Create New "+p_base); + set_title(TTR("Create New ")+p_base); _update_search(); } @@ -316,12 +316,12 @@ CreateDialog::CreateDialog() { add_child(vbc); set_child_rect(vbc); search_box = memnew( LineEdit ); - vbc->add_margin_child("Search:",search_box); + vbc->add_margin_child(TTR("Search:"),search_box); search_box->connect("text_changed",this,"_text_changed"); search_box->connect("input_event",this,"_sbox_input"); search_options = memnew( Tree ); - vbc->add_margin_child("Matches:",search_options,true); - get_ok()->set_text("Create"); + vbc->add_margin_child(TTR("Matches:"),search_options,true); + get_ok()->set_text(TTR("Create")); get_ok()->set_disabled(true); register_text_enter(search_box); set_hide_on_ok(false); @@ -541,7 +541,7 @@ void CreateDialog::_bind_methods() { void CreateDialog::set_base_type(const String& p_base) { - set_title("Create "+p_base+" Type"); + set_title(TTR("Create ")+p_base+" Type"); if (base==p_base) return; @@ -562,14 +562,14 @@ CreateDialog::CreateDialog() { add_child(vbc); set_child_rect(vbc); - get_ok()->set_text("Create"); + get_ok()->set_text(TTR("Create")); tree = memnew( Tree ); - vbc->add_margin_child("Type:",tree,true); + vbc->add_margin_child(TTR("Type:"),tree,true); //tree->set_hide_root(true); filter = memnew( LineEdit ); - vbc->add_margin_child("Filter:",filter); + vbc->add_margin_child(TTR("Filter:"),filter); base="Node"; set_as_toplevel(true); diff --git a/tools/editor/dependency_editor.cpp b/tools/editor/dependency_editor.cpp index 7e63cfb1b4..784315522c 100644 --- a/tools/editor/dependency_editor.cpp +++ b/tools/editor/dependency_editor.cpp @@ -27,7 +27,7 @@ void DependencyEditor::_load_pressed(Object* p_item,int p_cell,int p_button){ String fname = ti->get_text(0); replacing = ti->get_text(1); - search->set_title("Search Replacement For: "+replacing.get_file()); + search->set_title(TTR("Search Replacement For: ")+replacing.get_file()); search->clear_filters(); List<String> ext; @@ -180,7 +180,7 @@ void DependencyEditor::_update_list() { String name = path.get_file(); Ref<Texture> icon; - if (has_icon(type,"EditorIcons")) { + if (has_icon(type,TTR("EditorIcons"))) { icon=get_icon(type,"EditorIcons"); } else { icon=get_icon("Object","EditorIcons"); @@ -209,15 +209,15 @@ void DependencyEditor::edit(const String& p_path) { editing=p_path; - set_title("Dependencies For: "+p_path.get_file()); + set_title(TTR("Dependencies For: ")+p_path.get_file()); _update_list(); popup_centered_ratio(); if (EditorNode::get_singleton()->is_scene_open(p_path)) { - EditorNode::get_singleton()->show_warning("Scene '"+p_path.get_file()+"' is currently being edited.\nChanges will not take effect unless reloaded."); + EditorNode::get_singleton()->show_warning(TTR("Scene '")+p_path.get_file()+"' is currently being edited.\nChanges will not take effect unless reloaded."); } else if (ResourceCache::has(p_path)) { - EditorNode::get_singleton()->show_warning("Resource '"+p_path.get_file()+"' is in use.\nChanges will take effect when reloaded."); + EditorNode::get_singleton()->show_warning(TTR("Resource '")+p_path.get_file()+"' is in use.\nChanges will take effect when reloaded."); } } @@ -233,7 +233,7 @@ void DependencyEditor::_bind_methods() { DependencyEditor::DependencyEditor() { VBoxContainer *vb = memnew( VBoxContainer ); - vb->set_name("Dependencies"); + vb->set_name(TTR("Dependencies")); add_child(vb); set_child_rect(vb); @@ -246,10 +246,10 @@ DependencyEditor::DependencyEditor() { tree->connect("button_pressed",this,"_load_pressed"); HBoxContainer *hbc = memnew( HBoxContainer ); - Label *label = memnew( Label("Dependencies:")); + Label *label = memnew( Label(TTR("Dependencies:"))); hbc->add_child(label); hbc->add_spacer(); - fixdeps = memnew( Button("Fix Broken")); + fixdeps = memnew( Button(TTR("Fix Broken"))); hbc->add_child(fixdeps); fixdeps->connect("pressed",this,"_fix_all"); @@ -261,11 +261,11 @@ DependencyEditor::DependencyEditor() { mc->add_child(tree); vb->add_child(mc); - set_title("Dependency Editor"); + set_title(TTR("Dependency Editor")); search = memnew( EditorFileDialog ); search->connect("file_selected",this,"_searched"); search->set_mode(EditorFileDialog::MODE_OPEN_FILE); - search->set_title("Search Replacement Resource:"); + search->set_title(TTR("Search Replacement Resource:")); add_child(search); } @@ -301,7 +301,7 @@ void DependencyEditorOwners::_fill_owners(EditorFileSystemDirectory *efsd) { Ref<Texture> icon; String type=efsd->get_file_type(i); - if (!has_icon(type,"EditorIcons")) { + if (!has_icon(type,TTR("EditorIcons"))) { icon=get_icon("Object","EditorIcons"); } else { icon=get_icon(type,"EditorIcons"); @@ -319,7 +319,7 @@ void DependencyEditorOwners::show(const String& p_path) { _fill_owners(EditorFileSystem::get_singleton()->get_filesystem()); popup_centered_ratio(); - set_title("Owners Of: "+p_path.get_file()); + set_title(TTR("Owners Of: ")+p_path.get_file()); } @@ -362,7 +362,7 @@ void DependencyRemoveDialog::_fill_owners(EditorFileSystemDirectory *efsd) { Ref<Texture> icon; String type=efsd->get_file_type(i); - if (!has_icon(type,"EditorIcons")) { + if (!has_icon(type,TTR("EditorIcons"))) { icon=get_icon("Object","EditorIcons"); } else { icon=get_icon(type,"EditorIcons"); @@ -405,7 +405,7 @@ void DependencyRemoveDialog::show(const Vector<String> &to_erase) { popup_centered_minsize(Size2(500,220)); } else { owners->hide(); - text->set_text("Remove selected files from the project? (no undo)"); + text->set_text(TTR("Remove selected files from the project? (no undo)")); popup_centered_minsize(Size2(400,100)); } @@ -437,7 +437,7 @@ DependencyRemoveDialog::DependencyRemoveDialog() { owners->set_hide_root(true); vb->add_child(owners); owners->set_v_size_flags(SIZE_EXPAND_FILL); - get_ok()->set_text("Remove"); + get_ok()->set_text(TTR("Remove")); } @@ -448,7 +448,7 @@ void DependencyErrorDialog::show(const String& p_for_file,const Vector<String> & for_file=p_for_file; - set_title("Error loading: "+p_for_file.get_file()); + set_title(TTR("Error loading: ")+p_for_file.get_file()); files->clear(); TreeItem *root = files->create_item(NULL); @@ -461,7 +461,7 @@ void DependencyErrorDialog::show(const String& p_for_file,const Vector<String> & type=report[i].get_slice("::",1); Ref<Texture> icon; - if (!has_icon(type,"EditorIcons")) { + if (!has_icon(type,TTR("EditorIcons"))) { icon=get_icon("Object","EditorIcons"); } else { icon=get_icon(type,"EditorIcons"); @@ -496,18 +496,18 @@ DependencyErrorDialog::DependencyErrorDialog() { files = memnew( Tree ); files->set_hide_root(true); - vb->add_margin_child("Scene failed to load due to missing dependencies:",files,true); + vb->add_margin_child(TTR("Scene failed to load due to missing dependencies:"),files,true); files->set_v_size_flags(SIZE_EXPAND_FILL); - get_ok()->set_text("Open Anyway"); + get_ok()->set_text(TTR("Open Anyway")); text = memnew( Label ); vb->add_child(text); - text->set_text("Which action should be taken?"); + text->set_text(TTR("Which action should be taken?")); - fdep=add_button("Fix Dependencies",true,"fixdeps"); + fdep=add_button(TTR("Fix Dependencies"),true,"fixdeps"); - set_title("Errors loading!"); + set_title(TTR("Errors loading!")); } @@ -523,7 +523,7 @@ void OrphanResourcesDialog::ok_pressed() { if (paths.empty()) return; - delete_confirm->set_text("Permanently Delete "+itos(paths.size())+" Item(s) ? (No Undo!!)"); + delete_confirm->set_text(TTR("Permanently Delete ")+itos(paths.size())+" Item(s) ? (No Undo!!)"); delete_confirm->popup_centered_minsize(); } @@ -580,7 +580,7 @@ bool OrphanResourcesDialog::_fill_owners(EditorFileSystemDirectory *efsd,HashMap String type=efsd->get_file_type(i); Ref<Texture> icon; - if (has_icon(type,"EditorIcons")) { + if (has_icon(type,TTR("EditorIcons"))) { icon=get_icon(type,"EditorIcons"); } else { icon=get_icon("Object","EditorIcons"); @@ -676,13 +676,13 @@ OrphanResourcesDialog::OrphanResourcesDialog(){ files->set_column_expand(0,true); files->set_column_expand(1,false); files->set_column_title(0,"Resource"); - files->set_column_title(1,"Owns"); + files->set_column_title(1,TTR("Owns")); files->set_hide_root(true); - vbc->add_margin_child("Resources Without Explicit Ownership:",files,true); - set_title("Orphan Resource Explorer"); + vbc->add_margin_child(TTR("Resources Without Explicit Ownership:"),files,true); + set_title(TTR("Orphan Resource Explorer")); delete_confirm = memnew( ConfirmationDialog ); - delete_confirm->set_text("Delete selected files?"); - get_ok()->set_text("Delete"); + delete_confirm->set_text(TTR("Delete selected files?")); + get_ok()->set_text(TTR("Delete")); add_child(delete_confirm); dep_edit = memnew( DependencyEditor ); add_child(dep_edit); diff --git a/tools/editor/editor_data.cpp b/tools/editor/editor_data.cpp index 8bb2d60cab..4c4fecdd83 100644 --- a/tools/editor/editor_data.cpp +++ b/tools/editor/editor_data.cpp @@ -569,12 +569,12 @@ bool EditorData::check_and_update_scene(int p_idx) { Ref<PackedScene> pscene; pscene.instance(); - EditorProgress ep("update_scene","Updating Scene",2); - ep.step("Storing local changes..",0); + EditorProgress ep("update_scene",TTR("Updating Scene"),2); + ep.step(TTR("Storing local changes.."),0); //pack first, so it stores diffs to previous version of saved scene Error err = pscene->pack(edited_scene[p_idx].root); ERR_FAIL_COND_V(err!=OK,false); - ep.step("Updating scene..",1); + ep.step(TTR("Updating scene.."),1); Node *new_scene = pscene->instance(true); ERR_FAIL_COND_V(!new_scene,false); diff --git a/tools/editor/editor_dir_dialog.cpp b/tools/editor/editor_dir_dialog.cpp index 1a92a61882..395c4ba680 100644 --- a/tools/editor/editor_dir_dialog.cpp +++ b/tools/editor/editor_dir_dialog.cpp @@ -208,7 +208,7 @@ EditorDirDialog::EditorDirDialog() { updating=false; - set_title("Choose a Directory"); + set_title(TTR("Choose a Directory")); set_hide_on_ok(false); tree = memnew( Tree ); @@ -216,11 +216,11 @@ EditorDirDialog::EditorDirDialog() { set_child_rect(tree); tree->connect("item_activated",this,"_ok"); - makedir = add_button("Create Folder",OS::get_singleton()->get_swap_ok_cancel()?true:false,"makedir"); + makedir = add_button(TTR("Create Folder"),OS::get_singleton()->get_swap_ok_cancel()?true:false,"makedir"); makedir->connect("pressed",this,"_make_dir"); makedialog = memnew( ConfirmationDialog ); - makedialog->set_title("Create Folder"); + makedialog->set_title(TTR("Create Folder")); add_child(makedialog); VBoxContainer *makevb= memnew( VBoxContainer ); @@ -228,14 +228,14 @@ EditorDirDialog::EditorDirDialog() { makedialog->set_child_rect(makevb); makedirname = memnew( LineEdit ); - makevb->add_margin_child("Name:",makedirname); + makevb->add_margin_child(TTR("Name:"),makedirname); makedialog->register_text_enter(makedirname); makedialog->connect("confirmed",this,"_make_dir_confirm"); mkdirerr = memnew( AcceptDialog ); - mkdirerr->set_text("Could not create folder."); + mkdirerr->set_text(TTR("Could not create folder.")); add_child(mkdirerr); - get_ok()->set_text("Choose"); + get_ok()->set_text(TTR("Choose")); } diff --git a/tools/editor/editor_file_dialog.cpp b/tools/editor/editor_file_dialog.cpp index a889c76a69..8c16955d9f 100644 --- a/tools/editor/editor_file_dialog.cpp +++ b/tools/editor/editor_file_dialog.cpp @@ -353,7 +353,7 @@ void EditorFileDialog::_action_pressed() { } if (dir_access->file_exists(f)) { - confirm_save->set_text("File Exists, Overwrite?"); + confirm_save->set_text(TTR("File Exists, Overwrite?")); confirm_save->popup_centered(Size2(200,80)); } else { @@ -677,7 +677,7 @@ void EditorFileDialog::update_filters() { if (max_filters<filters.size()) all_filters+=", ..."; - filter->add_item("All Recognized ( "+all_filters+" )"); + filter->add_item(TTR("All Recognized ( ")+all_filters+" )"); } for(int i=0;i<filters.size();i++) { @@ -689,7 +689,7 @@ void EditorFileDialog::update_filters() { filter->add_item("( "+flt+" )"); } - filter->add_item("All Files (*)"); + filter->add_item(TTR("All Files (*)")); } @@ -767,11 +767,11 @@ void EditorFileDialog::set_mode(Mode p_mode) { mode=p_mode; switch(mode) { - case MODE_OPEN_FILE: get_ok()->set_text("Open"); set_title("Open a File"); makedir->hide(); break; - case MODE_OPEN_FILES: get_ok()->set_text("Open"); set_title("Open File(s)"); makedir->hide(); break; - case MODE_OPEN_DIR: get_ok()->set_text("Open"); set_title("Open a Directory"); makedir->show(); break; - case MODE_OPEN_ANY: get_ok()->set_text("Open"); set_title("Open a File or Directory"); makedir->show(); break; - case MODE_SAVE_FILE: get_ok()->set_text("Save"); set_title("Save a File"); makedir->show(); break; + case MODE_OPEN_FILE: get_ok()->set_text(TTR("Open")); set_title("Open a File"); makedir->hide(); break; + case MODE_OPEN_FILES: get_ok()->set_text(TTR("Open")); set_title("Open File(s)"); makedir->hide(); break; + case MODE_OPEN_DIR: get_ok()->set_text(TTR("Open")); set_title("Open a Directory"); makedir->show(); break; + case MODE_OPEN_ANY: get_ok()->set_text(TTR("Open")); set_title("Open a File or Directory"); makedir->show(); break; + case MODE_SAVE_FILE: get_ok()->set_text(TTR("Save")); set_title("Save a File"); makedir->show(); break; } if (mode==MODE_OPEN_FILES) { @@ -1212,7 +1212,7 @@ EditorFileDialog::EditorFileDialog() { set_child_rect(vbc); mode=MODE_SAVE_FILE; - set_title("Save a File"); + set_title(TTR("Save a File")); HBoxContainer *pathhb = memnew( HBoxContainer ); @@ -1258,13 +1258,13 @@ EditorFileDialog::EditorFileDialog() { drives->connect("item_selected",this,"_select_drive"); makedir = memnew( Button ); - makedir->set_text("Create Folder"); + makedir->set_text(TTR("Create Folder")); makedir->connect("pressed",this,"_make_dir"); pathhb->add_child(makedir); list_hb = memnew( HBoxContainer ); - vbc->add_margin_child("Path:",pathhb); + vbc->add_margin_child(TTR("Path:"),pathhb); vbc->add_child(list_hb); list_hb->set_v_size_flags(SIZE_EXPAND_FILL); @@ -1272,7 +1272,7 @@ EditorFileDialog::EditorFileDialog() { list_hb->add_child(fav_vb); HBoxContainer *fav_hb = memnew( HBoxContainer ); fav_vb->add_child(fav_hb); - fav_hb->add_child(memnew(Label("Favorites:"))); + fav_hb->add_child(memnew(Label(TTR("Favorites:")))); fav_hb->add_spacer(); fav_up = memnew( ToolButton ); fav_hb->add_child(fav_up); @@ -1292,7 +1292,7 @@ EditorFileDialog::EditorFileDialog() { favorites->connect("item_selected",this,"_favorite_selected"); recent = memnew( ItemList ); - fav_vb->add_margin_child("Recent:",recent,true); + fav_vb->add_margin_child(TTR("Recent:"),recent,true); recent->connect("item_selected",this,"_recent_selected"); VBoxContainer *item_vb = memnew( VBoxContainer ); @@ -1301,7 +1301,7 @@ EditorFileDialog::EditorFileDialog() { item_list = memnew( ItemList ); item_list->set_v_size_flags(SIZE_EXPAND_FILL); - item_vb->add_margin_child("Directories & Files:",item_list,true); + item_vb->add_margin_child(TTR("Directories & Files:"),item_list,true); HBoxContainer* filter_hb = memnew( HBoxContainer ); item_vb->add_child(filter_hb); @@ -1313,7 +1313,7 @@ EditorFileDialog::EditorFileDialog() { preview_vb = memnew( VBoxContainer ); filter_hb->add_child(preview_vb); CenterContainer *prev_cc = memnew( CenterContainer ); - preview_vb->add_margin_child("Preview:",prev_cc); + preview_vb->add_margin_child(TTR("Preview:"),prev_cc); preview = memnew( TextureFrame ); prev_cc->add_child(preview); preview_vb->hide(); @@ -1321,12 +1321,12 @@ EditorFileDialog::EditorFileDialog() { file = memnew(LineEdit); //add_child(file); - filter_vb->add_margin_child("File:",file); + filter_vb->add_margin_child(TTR("File:"),file); filter = memnew( OptionButton ); //add_child(filter); - filter_vb->add_margin_child("Filter:",filter); + filter_vb->add_margin_child(TTR("Filter:"),filter); filter->set_clip_text(true);//too many extensions overflow it dir_access = DirAccess::create(DirAccess::ACCESS_RESOURCES); @@ -1351,21 +1351,21 @@ EditorFileDialog::EditorFileDialog() { confirm_save->connect("confirmed", this,"_save_confirm_pressed"); makedialog = memnew( ConfirmationDialog ); - makedialog->set_title("Create Folder"); + makedialog->set_title(TTR("Create Folder")); VBoxContainer *makevb= memnew( VBoxContainer ); makedialog->add_child(makevb); makedialog->set_child_rect(makevb); makedirname = memnew( LineEdit ); - makevb->add_margin_child("Name:",makedirname); + makevb->add_margin_child(TTR("Name:"),makedirname); add_child(makedialog); makedialog->register_text_enter(makedirname); makedialog->connect("confirmed",this,"_make_dir_confirm"); mkdirerr = memnew( AcceptDialog ); - mkdirerr->set_text("Could not create folder."); + mkdirerr->set_text(TTR("Could not create folder.")); add_child(mkdirerr); exterr = memnew( AcceptDialog ); - exterr->set_text("Must use a valid extension."); + exterr->set_text(TTR("Must use a valid extension.")); add_child(exterr); diff --git a/tools/editor/editor_file_system.cpp b/tools/editor/editor_file_system.cpp index 05e8a559b7..9b30436507 100644 --- a/tools/editor/editor_file_system.cpp +++ b/tools/editor/editor_file_system.cpp @@ -314,7 +314,7 @@ void EditorFileSystem::_scan_filesystem() { - EditorProgressBG scan_progress("efs","ScanFS",1000); + EditorProgressBG scan_progress("efs",TTR("ScanFS"),1000); ScanProgress sp; sp.low=0; @@ -609,7 +609,7 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir,DirAccess da->change_dir(".."); } else { - ERR_PRINTS("Can't go into subdir: "+E->get()); + ERR_PRINTS(TTR("Can't go into subdir: ")+E->get()); } p_progress.update(idx,total); @@ -823,7 +823,7 @@ void EditorFileSystem::_thread_func_sources(void *_userdata) { EditorFileSystem *efs = (EditorFileSystem*)_userdata; if (efs->filesystem) { - EditorProgressBG pr("sources","ScanSources",1000); + EditorProgressBG pr("sources",TTR("ScanSources"),1000); ScanProgress sp; sp.progress=≺ sp.hi=1; @@ -851,7 +851,7 @@ void EditorFileSystem::scan_sources() { if (!use_threads) { if (filesystem) { - EditorProgressBG pr("sources","ScanSources",1000); + EditorProgressBG pr("sources",TTR("ScanSources"),1000); ScanProgress sp; sp.progress=≺ sp.hi=1; @@ -873,7 +873,7 @@ void EditorFileSystem::scan_sources() { s.priority=Thread::PRIORITY_LOW; thread_sources = Thread::create(_thread_func_sources,this,s); //tree->hide(); - //print_line("SCAN BEGIN!"); + //print_line(TTR("SCAN BEGIN!")); //progress->show(); } @@ -900,7 +900,7 @@ void EditorFileSystem::_notification(int p_what) { Thread::wait_to_finish(thread); memdelete(thread); thread=NULL; - WARN_PRINT("Scan thread aborted..."); + WARN_PRINTS(TTR("Scan thread aborted...")); set_process(false); } @@ -1247,7 +1247,7 @@ void EditorFileSystem::update_file(const String& p_file) { } - //print_line("UPDATING: "+p_file); + //print_line(TTR("UPDATING: ")+p_file); fs->files[cpos]->type=type; fs->files[cpos]->modified_time=FileAccess::get_modified_time(p_file); fs->files[cpos]->meta=_get_meta(p_file); diff --git a/tools/editor/editor_help.cpp b/tools/editor/editor_help.cpp index 7a8805a5a1..1439209faa 100644 --- a/tools/editor/editor_help.cpp +++ b/tools/editor/editor_help.cpp @@ -318,20 +318,20 @@ EditorHelpSearch::EditorHelpSearch() { search_box = memnew( LineEdit ); sb_hb->add_child(search_box); search_box->set_h_size_flags(SIZE_EXPAND_FILL); - Button *sb = memnew( Button("Search")); + Button *sb = memnew( Button(TTR("Search"))); sb->connect("pressed",this,"_update_search"); sb_hb->add_child(sb); - vbc->add_margin_child("Search:",sb_hb); + vbc->add_margin_child(TTR("Search:"),sb_hb); search_box->connect("text_changed",this,"_text_changed"); search_box->connect("input_event",this,"_sbox_input"); search_options = memnew( Tree ); - vbc->add_margin_child("Matches:",search_options,true); - get_ok()->set_text("Open"); + vbc->add_margin_child(TTR("Matches:"),search_options,true); + get_ok()->set_text(TTR("Open")); get_ok()->set_disabled(true); register_text_enter(search_box); set_hide_on_ok(false); search_options->connect("item_activated",this,"_confirmed"); - set_title("Search Classes"); + set_title(TTR("Search Classes")); // search_options->set_hide_root(true); @@ -510,7 +510,7 @@ EditorHelpIndex::EditorHelpIndex() { set_child_rect(vbc); search_box = memnew( LineEdit ); - vbc->add_margin_child("Search:", search_box); + vbc->add_margin_child(TTR("Search:"), search_box); search_box->set_h_size_flags(SIZE_EXPAND_FILL); register_text_enter(search_box); @@ -519,12 +519,12 @@ EditorHelpIndex::EditorHelpIndex() { search_box->connect("input_event", this, "_sbox_input"); class_list = memnew( Tree ); - vbc->add_margin_child("Class List: ", class_list, true); + vbc->add_margin_child(TTR("Class List: "), class_list, true); class_list->set_v_size_flags(SIZE_EXPAND_FILL); class_list->connect("item_activated",this,"_tree_item_selected"); - get_ok()->set_text("Open"); + get_ok()->set_text(TTR("Open")); } @@ -618,7 +618,7 @@ void EditorHelp::_class_desc_select(const String& p_select) { -// print_line("LINK: "+p_select); +// print_line(TTR("LINK: ")+p_select); if (p_select.begins_with("#")) { //_goto_desc(p_select.substr(1,p_select.length())); emit_signal("go_to_help","class_name:"+p_select.substr(1,p_select.length())); @@ -710,7 +710,7 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) { class_desc->push_font(doc_title_font); class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/keyword_color")); - class_desc->add_text("Class: "); + class_desc->add_text(TTR("Class: ")); class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/base_type_color")); _add_text(p_class); class_desc->pop(); @@ -722,7 +722,7 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) { class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/keyword_color")); class_desc->push_font(doc_title_font); - class_desc->add_text("Inherits: "); + class_desc->add_text(TTR("Inherits: ")); class_desc->pop(); class_desc->pop(); @@ -787,7 +787,7 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) { class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/keyword_color")); class_desc->push_font(doc_title_font); - class_desc->add_text("Brief Description:"); + class_desc->add_text(TTR("Brief Description:")); class_desc->pop(); class_desc->pop(); @@ -810,7 +810,7 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) { class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/keyword_color")); class_desc->push_font(doc_title_font); - class_desc->add_text("Public Methods:"); + class_desc->add_text(TTR("Public Methods:")); class_desc->pop(); class_desc->pop(); @@ -895,7 +895,7 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) { class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/keyword_color")); class_desc->push_font(doc_title_font); - class_desc->add_text("Members:"); + class_desc->add_text(TTR("Members:")); class_desc->pop(); class_desc->pop(); class_desc->add_newline(); @@ -939,7 +939,7 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) { class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/keyword_color")); class_desc->push_font(doc_title_font); - class_desc->add_text("GUI Theme Items:"); + class_desc->add_text(TTR("GUI Theme Items:")); class_desc->pop(); class_desc->pop(); class_desc->add_newline(); @@ -981,7 +981,7 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) { class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/keyword_color")); class_desc->push_font(doc_title_font); - class_desc->add_text("Signals:"); + class_desc->add_text(TTR("Signals:")); class_desc->pop(); class_desc->pop(); @@ -1046,7 +1046,7 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) { class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/keyword_color")); class_desc->push_font(doc_title_font); - class_desc->add_text("Constants:"); + class_desc->add_text(TTR("Constants:")); class_desc->pop(); class_desc->pop(); class_desc->push_indent(1); @@ -1091,7 +1091,7 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) { description_line=class_desc->get_line_count()-2; class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/keyword_color")); class_desc->push_font(doc_title_font); - class_desc->add_text("Description:"); + class_desc->add_text(TTR("Description:")); class_desc->pop(); class_desc->pop(); @@ -1112,7 +1112,7 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) { class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/keyword_color")); class_desc->push_font(doc_title_font); - class_desc->add_text("Method Description:"); + class_desc->add_text(TTR("Method Description:")); class_desc->pop(); class_desc->pop(); @@ -1650,8 +1650,8 @@ EditorHelp::EditorHelp() { search_dialog->set_child_rect(search_vb); search = memnew( LineEdit ); search_dialog->register_text_enter(search); - search_vb->add_margin_child("Search Text",search); - search_dialog->get_ok()->set_text("Find"); + search_vb->add_margin_child(TTR("Search Text"),search); + search_dialog->get_ok()->set_text(TTR("Find")); search_dialog->connect("confirmed",this,"_search_cbk"); search_dialog->set_hide_on_ok(false); search_dialog->set_self_opacity(0.8); diff --git a/tools/editor/editor_import_export.cpp b/tools/editor/editor_import_export.cpp index bdf1726d85..2b14d80521 100644 --- a/tools/editor/editor_import_export.cpp +++ b/tools/editor/editor_import_export.cpp @@ -220,7 +220,7 @@ static void _edit_files_with_filter(DirAccess *da,const List<String>& p_filters, String f = da->get_next(); while(f!="") { - print_line("HOHO: "+f); + print_line(TTR("HOHO: ")+f); if (da->current_is_dir()) dirs.push_back(f); else @@ -233,19 +233,19 @@ static void _edit_files_with_filter(DirAccess *da,const List<String>& p_filters, if (!r.ends_with("/")) r+="/"; - print_line("AT: "+r); + print_line(TTR("AT: ")+r); for(List<String>::Element *E=files.front();E;E=E->next()) { String fullpath=r+E->get(); for(const List<String>::Element *F=p_filters.front();F;F=F->next()) { if (fullpath.matchn(F->get())) { - String act = "Added: "; + String act = TTR("Added: "); if (!exclude) { r_list.insert(fullpath); } else { - act = "Removed: "; + act = TTR("Removed: "); r_list.erase(fullpath); } @@ -410,15 +410,15 @@ Vector<StringName> EditorExportPlatform::get_dependencies(bool p_bundles) const EditorImportExport::get_singleton()->get_export_file_list(&toexport); - print_line("TO EXPORT: "+itos(toexport.size())); + print_line(TTR("TO EXPORT: ")+itos(toexport.size())); for (List<StringName>::Element *E=toexport.front();E;E=E->next()) { - print_line("DEP: "+String(E->get())); + print_line(TTR("DEP: ")+String(E->get())); exported.insert(E->get()); if (p_bundles && EditorImportExport::get_singleton()->get_export_file_action(E->get())==EditorImportExport::ACTION_BUNDLE) { - print_line("NO BECAUSE OF BUNDLE!"); + print_line(TTR("NO BECAUSE OF BUNDLE!")); continue; //no dependencies needed to be copied } @@ -747,7 +747,7 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func FileAccess *f=NULL; if (!FileAccess::exists(EditorSettings::get_singleton()->get_settings_path()+"/tmp/atlas-"+md5)) { - print_line("NO MD5 INVALID"); + print_line(TTR("NO MD5 INVALID")); atlas_valid=false; } @@ -766,7 +766,7 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func atlas_valid=false; if (!atlas_valid) - print_line("JSON INVALID"); + print_line(TTR("JSON INVALID")); } @@ -775,7 +775,7 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func //check md5 of list of image /names/ if (f->get_line().strip_edges()!=image_list_md5) { atlas_valid=false; - print_line("IMAGE MD5 INVALID!"); + print_line(TTR("IMAGE MD5 INVALID!")); } } @@ -792,7 +792,7 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func if (slices.size()!=10) { atlas_valid=false; - print_line("CANT SLICE IN 10"); + print_line(TTR("CANT SLICE IN 10")); break; } uint64_t mod_time = slices[0].to_int64(); @@ -804,7 +804,7 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func if (image_md5!=file_md5) { atlas_valid=false; - print_line("IMAGE INVALID "+slices[0]); + print_line(TTR("IMAGE INVALID ")+slices[0]); break; } else { resave_deps=true; @@ -825,7 +825,7 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func f=NULL; } - print_line("ATLAS VALID? "+itos(atlas_valid)+" RESAVE DEPS? "+itos(resave_deps)); + print_line(TTR("ATLAS VALID? ")+itos(atlas_valid)+" RESAVE DEPS? "+itos(resave_deps)); if (!atlas_valid) { rects.clear(); //oh well, atlas is not valid. need to make new one.... @@ -866,7 +866,7 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func Error err = plugin->import2(dst_file,imd,get_image_compression(),true); if (err) { - EditorNode::add_io_error("Error saving atlas! "+dst_file.get_file()); + EditorNode::add_io_error(TTR("Error saving atlas! ")+dst_file.get_file()); return ERR_CANT_CREATE; } @@ -916,7 +916,7 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func String path = EditorSettings::get_singleton()->get_settings_path()+"/tmp/tmpatlas.atex"; Error err = ResourceSaver::save(path,atex); if (err!=OK) { - EditorNode::add_io_error("Could not save atlas subtexture: "+path); + EditorNode::add_io_error(TTR("Could not save atlas subtexture: ")+path); return ERR_CANT_CREATE; } Vector<uint8_t> data = FileAccess::get_file_as_array(path); @@ -1016,7 +1016,7 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func if (remap_files.size()) { Vector<String> remapsprop; for(Map<StringName,StringName>::Element *E=remap_files.front();E;E=E->next()) { - print_line("REMAP: "+String(E->key())+" -> "+E->get()); + print_line(TTR("REMAP: ")+String(E->key())+" -> "+E->get()); remapsprop.push_back(E->key()); remapsprop.push_back(E->get()); } @@ -1157,7 +1157,7 @@ Error EditorExportPlatform::save_pack_file(void *p_userdata,const String& p_path MD5Final(&ctx); pd->f->store_buffer(ctx.digest,16); } - pd->ep->step("Storing File: "+p_path,2+p_file*100/p_total,false); + pd->ep->step(TTR("Storing File: ")+p_path,2+p_file*100/p_total,false); pd->count++; pd->ftmp->store_buffer(p_data.ptr(),p_data.size()); if (pd->alignment > 1) { @@ -1195,7 +1195,7 @@ Error EditorExportPlatform::save_zip_file(void *p_userdata,const String& p_path, zipWriteInFileInZip(zip,p_data.ptr(),p_data.size()); zipCloseFileInZip(zip); - zd->ep->step("Storing File: "+p_path,2+p_file*100/p_total,false); + zd->ep->step(TTR("Storing File: ")+p_path,2+p_file*100/p_total,false); zd->count++; return OK; @@ -1203,7 +1203,7 @@ Error EditorExportPlatform::save_zip_file(void *p_userdata,const String& p_path, Error EditorExportPlatform::save_zip(const String& p_path, bool p_make_bundles) { - EditorProgress ep("savezip","Packing",102); + EditorProgress ep("savezip",TTR("Packing"),102); //FileAccess *tmp = FileAccess::open(tmppath,FileAccess::WRITE); @@ -1226,7 +1226,7 @@ Error EditorExportPlatform::save_zip(const String& p_path, bool p_make_bundles) Error EditorExportPlatform::save_pack(FileAccess *dst,bool p_make_bundles, int p_alignment) { - EditorProgress ep("savepack","Packing",102); + EditorProgress ep("savepack",TTR("Packing"),102); String tmppath = EditorSettings::get_singleton()->get_settings_path()+"/tmp/packtmp"; FileAccess *tmp = FileAccess::open(tmppath,FileAccess::WRITE); @@ -1309,13 +1309,13 @@ Error EditorExportPlatformPC::export_project(const String& p_path, bool p_debug, - EditorProgress ep("export","Exporting for "+get_name(),102); + EditorProgress ep("export",TTR("Exporting for ")+get_name(),102); const int BUFSIZE = 32768; - ep.step("Setting Up..",0); + ep.step(TTR("Setting Up.."),0); String exe_path=""; diff --git a/tools/editor/editor_log.cpp b/tools/editor/editor_log.cpp index bcdafbb06a..8d977b881b 100644 --- a/tools/editor/editor_log.cpp +++ b/tools/editor/editor_log.cpp @@ -185,7 +185,7 @@ EditorLog::EditorLog() { clearbutton = memnew( Button ); hb->add_child(clearbutton); - clearbutton->set_text("Clear"); + clearbutton->set_text(TTR("Clear")); clearbutton->connect("pressed", this,"_clear_request"); ec = memnew( Control); diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index f7608a6b9d..e7ace943ae 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -432,13 +432,13 @@ void EditorNode::_rebuild_import_menu() { PopupMenu* p = import_menu->get_popup(); p->clear(); - p->add_item("Node from scene", FILE_IMPORT_SUBSCENE); + p->add_item(TTR("Node from scene"), FILE_IMPORT_SUBSCENE); p->add_separator(); for (int i = 0; i < editor_import_export->get_import_plugin_count(); i++) { p->add_item(editor_import_export->get_import_plugin(i)->get_visible_name(), IMPORT_PLUGIN_BASE + i); } p->add_separator(); - p->add_item("Re-Import..", SETTINGS_IMPORT); + p->add_item(TTR("Re-Import.."), SETTINGS_IMPORT); } void EditorNode::_node_renamed() { @@ -503,7 +503,7 @@ void EditorNode::save_resource_in_path(const Ref<Resource>& p_resource,const Str Error err = ResourceSaver::save(path,p_resource,flg|ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS); if (err!=OK) { - accept->set_text("Error saving resource!"); + accept->set_text(TTR("Error saving resource!")); accept->popup_centered_minsize(); return; } @@ -564,7 +564,7 @@ void EditorNode::save_resource_as(const Ref<Resource>& p_resource) { } file->popup_centered_ratio(); - file->set_title("Save Resource As.."); + file->set_title(TTR("Save Resource As..")); } @@ -586,21 +586,21 @@ void EditorNode::_dialog_display_file_error(String p_file,Error p_error) { current_option=-1; //accept->"()->hide(); - accept->get_ok()->set_text("I see.."); + accept->get_ok()->set_text(TTR("I see..")); switch(p_error) { case ERR_FILE_CANT_WRITE: { - accept->set_text("Can't open file for writing: "+p_file.extension()); + accept->set_text(TTR("Can't open file for writing: ")+p_file.extension()); } break; case ERR_FILE_UNRECOGNIZED: { - accept->set_text("File format requested unknown: "+p_file.extension()); + accept->set_text(TTR("File format requested unknown: ")+p_file.extension()); } break; default: { - accept->set_text("Error Saving."); + accept->set_text(TTR("Error Saving.")); }break; } @@ -788,7 +788,7 @@ bool EditorNode::_find_and_save_resource(RES res,Map<RES,bool>& processed,int32_ if (res->get_path().is_resource_file()) { if (changed || subchanged) { //save - print_line("Also saving modified external resource: "+res->get_path()); + print_line(TTR("Also saving modified external resource: ")+res->get_path()); Error err = ResourceSaver::save(res->get_path(),res,flags); } @@ -896,8 +896,8 @@ void EditorNode::_save_scene_with_preview(String p_file) { int c2d=0; int c3d=0; - EditorProgress save("save","Saving Scene",4); - save.step("Analyzing",0); + EditorProgress save("save",TTR("Saving Scene"),4); + save.step(TTR("Analyzing"),0); _find_node_types(editor_data.get_edited_scene_root(),c2d,c3d); RID viewport; @@ -910,7 +910,7 @@ void EditorNode::_save_scene_with_preview(String p_file) { is2d=false; } - save.step("Creating Thumbnail",1); + save.step(TTR("Creating Thumbnail"),1); //current view? int screen =-1; for(int i=0;i<editor_table.size();i++) { @@ -923,8 +923,8 @@ void EditorNode::_save_scene_with_preview(String p_file) { _editor_select(is2d?EDITOR_2D:EDITOR_3D); VS::get_singleton()->viewport_queue_screen_capture(viewport); - save.step("Creating Thumbnail",2); - save.step("Creating Thumbnail",3); + save.step(TTR("Creating Thumbnail"),2); + save.step(TTR("Creating Thumbnail"),3); Image img = VS::get_singleton()->viewport_get_screen_capture(viewport); int preview_size = EditorSettings::get_singleton()->get("file_dialog/thumbnail_size");; int width,height; @@ -959,7 +959,7 @@ void EditorNode::_save_scene_with_preview(String p_file) { if (screen!=-1) { _editor_select(screen); } - save.step("Saving Scene",4); + save.step(TTR("Saving Scene"),4); _save_scene(p_file); } @@ -973,7 +973,7 @@ void EditorNode::_save_scene(String p_file) { current_option=-1; //accept->get_cancel()->hide(); - accept->get_ok()->set_text("I see.."); + accept->get_ok()->set_text(TTR("I see..")); accept->set_text("This operation can't be done without a tree root."); accept->popup_centered_minsize(); return; @@ -1006,8 +1006,8 @@ void EditorNode::_save_scene(String p_file) { current_option=-1; //accept->get_cancel()->hide(); - accept->get_ok()->set_text("I see.."); - accept->set_text("Couldn't save scene. Likely dependencies (instances) couldn't be satisfied."); + accept->get_ok()->set_text(TTR("I see..")); + accept->set_text(TTR("Couldn't save scene. Likely dependencies (instances) couldn't be satisfied.")); accept->popup_centered_minsize(); return; } @@ -1057,8 +1057,8 @@ void EditorNode::_import_action(const String& p_action) { current_option=-1; //accept->get_cancel()->hide(); - accept->get_ok()->set_text("Ugh"); - accept->set_text("Error importing scene."); + accept->get_ok()->set_text(TTR("Ugh")); + accept->set_text(TTR("Error importing scene.")); accept->popup_centered(Size2(300,70));; return; } @@ -1073,8 +1073,8 @@ void EditorNode::_import_action(const String& p_action) { memdelete(src); //accept->get_cancel()->hide(); - accept->get_ok()->set_text("Ugh"); - accept->set_text("Error load scene to update."); + accept->get_ok()->set_text(TTR("Ugh")); + accept->set_text(TTR("Error load scene to update.")); accept->popup_centered(Size2(300,70));; return; } @@ -1114,8 +1114,8 @@ void EditorNode::_import(const String &p_file) { current_option=-1; //accept->get_cancel()->hide(); - accept->get_ok()->set_text("Ugh"); - accept->set_text("Error importing scene."); + accept->get_ok()->set_text(TTR("Ugh")); + accept->set_text(TTR("Error importing scene.")); accept->popup_centered(Size2(300,70));; return; } @@ -1156,7 +1156,7 @@ void EditorNode::_dialog_action(String p_file) { current_option=-1; //accept->get_cancel()->hide(); accept->get_ok()->set_text("ok :("); - accept->set_text("Failed to load resource."); + accept->set_text(TTR("Failed to load resource.")); return; }; @@ -1181,7 +1181,7 @@ void EditorNode::_dialog_action(String p_file) { } break; case FILE_RUN_SCRIPT: { - print_line("RUN: "+p_file); + print_line(TTR("RUN: ")+p_file); Ref<Script> scr = ResourceLoader::load(p_file,"Script",true); if (scr.is_null()) { add_io_error("Script Failed to Load:\n"+p_file); @@ -1236,8 +1236,8 @@ void EditorNode::_dialog_action(String p_file) { if (ml.is_null()) { current_option=-1; //accept->get_cancel()->hide(); - accept->get_ok()->set_text("I see.."); - accept->set_text("Can't load MeshLibrary for merging!."); + accept->get_ok()->set_text(TTR("I see..")); + accept->set_text(TTR("Can't load MeshLibrary for merging!.")); accept->popup_centered_minsize(); return; } @@ -1253,8 +1253,8 @@ void EditorNode::_dialog_action(String p_file) { Error err = ResourceSaver::save(p_file,ml); if (err) { - accept->get_ok()->set_text("I see.."); - accept->set_text("Error saving MeshLibrary!."); + accept->get_ok()->set_text(TTR("I see..")); + accept->set_text(TTR("Error saving MeshLibrary!.")); accept->popup_centered_minsize(); return; } @@ -1271,8 +1271,8 @@ void EditorNode::_dialog_action(String p_file) { if (file_export_lib_merge->is_pressed()) { current_option=-1; //accept->get_cancel()->hide(); - accept->get_ok()->set_text("I see.."); - accept->set_text("Can't load TileSet for merging!."); + accept->get_ok()->set_text(TTR("I see..")); + accept->set_text(TTR("Can't load TileSet for merging!.")); accept->popup_centered_minsize(); return; } @@ -1289,8 +1289,8 @@ void EditorNode::_dialog_action(String p_file) { Error err = ResourceSaver::save(p_file,ml); if (err) { - accept->get_ok()->set_text("I see.."); - accept->set_text("Error saving TileSet!."); + accept->get_ok()->set_text(TTR("I see..")); + accept->set_text(TTR("Error saving TileSet!.")); accept->popup_centered_minsize(); return; } @@ -1306,8 +1306,8 @@ void EditorNode::_dialog_action(String p_file) { current_option=-1; //confirmation->get_cancel()->hide(); - accept->get_ok()->set_text("I see.."); - accept->set_text("Can't open export templates zip."); + accept->get_ok()->set_text(TTR("I see..")); + accept->set_text(TTR("Can't open export templates zip.")); accept->popup_centered_minsize(); return; @@ -1324,7 +1324,7 @@ void EditorNode::_dialog_action(String p_file) { ret = unzGoToFirstFile(pkg); - EditorProgress p("ltask","Loading Export Templates",fc); + EditorProgress p("ltask",TTR("Loading Export Templates"),fc); print_line("BEGIN IMPORT"); fc=0; @@ -1354,7 +1354,7 @@ void EditorNode::_dialog_action(String p_file) { file=file.get_file(); - p.step("Importing: "+file,fc); + p.step(TTR("Importing: ")+file,fc); print_line("IMPORT "+file); FileAccess *f = FileAccess::open(EditorSettings::get_singleton()->get_settings_path()+"/templates/"+file,FileAccess::WRITE); @@ -1397,7 +1397,7 @@ void EditorNode::_dialog_action(String p_file) { if (err==ERR_CANT_OPEN) { config.instance(); // new config } else if (err!=OK) { - show_warning("Error trying to save layout!"); + show_warning(TTR("Error trying to save layout!")); return; } @@ -1409,7 +1409,7 @@ void EditorNode::_dialog_action(String p_file) { _update_layouts_menu(); if (p_file=="Default") { - show_warning("Default editor layout overridden."); + show_warning(TTR("Default editor layout overridden.")); } } break; @@ -1423,7 +1423,7 @@ void EditorNode::_dialog_action(String p_file) { Error err = config->load(EditorSettings::get_singleton()->get_settings_path().plus_file("editor_layouts.cfg")); if (err!=OK || !config->has_section(p_file)) { - show_warning("Layout name not found!"); + show_warning(TTR("Layout name not found!")); return; } @@ -1440,7 +1440,7 @@ void EditorNode::_dialog_action(String p_file) { _update_layouts_menu(); if (p_file=="Default") { - show_warning("Restored Default layout to base settings."); + show_warning(TTR("Restored Default layout to base settings.")); } } break; @@ -1719,16 +1719,16 @@ void EditorNode::_edit_current() { PopupMenu *p=object_menu->get_popup(); p->clear(); - p->add_item("Copy Params",OBJECT_COPY_PARAMS); - p->add_item("Set Params",OBJECT_PASTE_PARAMS); + p->add_item(TTR("Copy Params"),OBJECT_COPY_PARAMS); + p->add_item(TTR("Set Params"),OBJECT_PASTE_PARAMS); p->add_separator(); - p->add_item("Paste Resource",RESOURCE_PASTE); + p->add_item(TTR("Paste Resource"),RESOURCE_PASTE); if (is_resource) { - p->add_item("Copy Resource",RESOURCE_COPY); - p->add_item("Make Built-In",RESOURCE_UNREF); + p->add_item(TTR("Copy Resource"),RESOURCE_COPY); + p->add_item(TTR("Make Built-In"),RESOURCE_UNREF); } p->add_separator(); - p->add_item("Make Sub-Resources Unique",OBJECT_UNIQUE_RESOURCES); + p->add_item(TTR("Make Sub-Resources Unique"),OBJECT_UNIQUE_RESOURCES); p->add_separator(); p->add_icon_item(gui_base->get_icon("Help","EditorIcons"),"Class Reference",OBJECT_REQUEST_HELP); List<MethodInfo> methods; @@ -1755,7 +1755,7 @@ void EditorNode::_edit_current() { } //p->add_separator(); - //p->add_item("All Methods",OBJECT_CALL_METHOD); + //p->add_item(TTR("All Methods"),OBJECT_CALL_METHOD); update_keying(); @@ -1817,8 +1817,8 @@ void EditorNode::_run(bool p_current,const String& p_custom) { if (!scene) { current_option=-1; //accept->get_cancel()->hide(); - accept->get_ok()->set_text("I see.."); - accept->set_text("No scene to run exists."); + accept->get_ok()->set_text(TTR("I see..")); + accept->set_text(TTR("No scene to run exists.")); accept->popup_centered_minsize(); return; } @@ -1860,7 +1860,7 @@ void EditorNode::_run(bool p_current,const String& p_custom) { current_option=-1; //accept->get_cancel()->hide(); - accept->get_ok()->set_text("I see.."); + accept->get_ok()->set_text(TTR("I see..")); accept->set_text("No main scene has ever been defined.\nSelect one from \"Project Settings\" under the 'application' category."); accept->popup_centered_minsize(); return; @@ -1881,8 +1881,8 @@ void EditorNode::_run(bool p_current,const String& p_custom) { current_option=-1; //accept->get_cancel()->hide(); - accept->get_ok()->set_text("I see.."); - accept->set_text("Current scene was never saved, please save scene before running."); + accept->get_ok()->set_text(TTR("I see..")); + accept->set_text(TTR("Current scene was never saved, please save scene before running.")); accept->popup_centered_minsize(); return; } @@ -1909,8 +1909,8 @@ void EditorNode::_run(bool p_current,const String& p_custom) { current_option=-1; //confirmation->get_cancel()->hide(); - accept->get_ok()->set_text("I see.."); - accept->set_text("Could not start subprocess!"); + accept->get_ok()->set_text(TTR("I see..")); + accept->set_text(TTR("Could not start subprocess!")); accept->popup_centered_minsize(); return; @@ -1986,9 +1986,9 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { /* if (!p_confirmed) { - confirmation->get_ok()->set_text("Yes"); + confirmation->get_ok()->set_text(TTR("Yes")); //confirmation->get_cancel()->show(); - confirmation->set_text("Start a New Scene? (Current will be lost)"); + confirmation->set_text(TTR("Start a New Scene? (Current will be lost)")); confirmation->popup_centered_minsize(); break; }*/ @@ -2023,28 +2023,28 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { if (scene) { file->set_current_path(scene->get_filename()); }; - file->set_title(p_option==FILE_OPEN_SCENE?"Open Scene":"Open Base Scene"); + file->set_title(p_option==FILE_OPEN_SCENE?TTR("Open Scene"):"Open Base Scene"); file->popup_centered_ratio(); } break; case FILE_QUICK_OPEN_SCENE: { quick_open->popup("PackedScene", true); - quick_open->set_title("Quick Open Scene.."); + quick_open->set_title(TTR("Quick Open Scene..")); } break; case FILE_QUICK_OPEN_SCRIPT: { quick_open->popup("Script", true); - quick_open->set_title("Quick Open Script.."); + quick_open->set_title(TTR("Quick Open Script..")); } break; case FILE_QUICK_OPEN_FILE: { quick_open->popup("Resource", false, true); - quick_open->set_title("Quick Search File.."); + quick_open->set_title(TTR("Quick Search File..")); } break; case FILE_RUN_SCRIPT: { @@ -2062,9 +2062,9 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { case FILE_CLOSE: { if (!p_confirmed && unsaved_cache) { - confirmation->get_ok()->set_text("Yes"); + confirmation->get_ok()->set_text(TTR("Yes")); //confirmation->get_cancel()->show(); - confirmation->set_text("Close scene? (Unsaved changes will be lost)"); + confirmation->set_text(TTR("Close scene? (Unsaved changes will be lost)")); confirmation->popup_centered_minsize(); break; } @@ -2103,7 +2103,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { current_option=-1; //confirmation->get_cancel()->hide(); - accept->get_ok()->set_text("I see.."); + accept->get_ok()->set_text(TTR("I see..")); accept->set_text("This operation can't be done without a tree root."); accept->popup_centered_minsize(); break; @@ -2141,14 +2141,14 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { } file->popup_centered_ratio(); - file->set_title("Save Scene As.."); + file->set_title(TTR("Save Scene As..")); } break; case FILE_SAVE_BEFORE_RUN: { if (!p_confirmed) { - accept->get_ok()->set_text("Yes"); - accept->set_text("This scene has never been saved. Save before running?"); + accept->get_ok()->set_text(TTR("Yes")); + accept->set_text(TTR("This scene has never been saved. Save before running?")); accept->popup_centered_minsize(); break; } @@ -2165,7 +2165,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { current_option=-1; //confirmation->get_cancel()->hide(); - accept->get_ok()->set_text("I see.."); + accept->get_ok()->set_text(TTR("I see..")); accept->set_text("This operation can't be done without a tree root."); accept->popup_centered_minsize(); break; @@ -2183,8 +2183,8 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { } else { current_option=-1; //confirmation->get_cancel()->hide(); - accept->get_ok()->set_text("I see.."); - accept->set_text("Please save the scene first."); + accept->get_ok()->set_text(TTR("I see..")); + accept->set_text(TTR("Please save the scene first.")); accept->popup_centered_minsize(); break; @@ -2195,7 +2195,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { file->set_mode(EditorFileDialog::MODE_SAVE_FILE); file->set_current_path(cpath); - file->set_title("Save Translatable Strings"); + file->set_title(TTR("Save Translatable Strings")); file->popup_centered_ratio(); } break; @@ -2206,7 +2206,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { current_option=-1; //confirmation->get_cancel()->hide(); - accept->get_ok()->set_text("I see.."); + accept->get_ok()->set_text(TTR("I see..")); accept->set_text("This operation can't be done without a tree root."); accept->popup_centered(Size2(300,70));; break; @@ -2228,8 +2228,8 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { } else { current_option=-1; //confirmation->get_cancel()->hide(); - accept->get_ok()->set_text("I see.."); - accept->set_text("Please save the scene first."); + accept->get_ok()->set_text(TTR("I see..")); + accept->set_text(TTR("Please save the scene first.")); accept->popup_centered(Size2(300,70));; break; @@ -2244,7 +2244,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { String target = export_db->get_current_platform(); Ref<EditorExporter> exporter = export_db->get_exporter(target); if (exporter.is_null()) { - accept->set_text("No exporter for platform '"+target+"' yet."); + accept->set_text(TTR("No exporter for platform '")+target+"' yet."); accept->popup_centered(Size2(300,70));; return; } @@ -2266,7 +2266,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { current_option=-1; //confirmation->get_cancel()->hide(); - accept->get_ok()->set_text("I see.."); + accept->get_ok()->set_text(TTR("I see..")); accept->set_text("This operation can't be done without a scene."); accept->popup_centered_minsize(); break; @@ -2281,7 +2281,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { } file_export_lib->popup_centered_ratio(); - file_export_lib->set_title("Export Mesh Library"); + file_export_lib->set_title(TTR("Export Mesh Library")); } break; case FILE_EXPORT_TILESET: { @@ -2295,7 +2295,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { } file_export_lib->popup_centered_ratio(); - file_export_lib->set_title("Export Tile Set"); + file_export_lib->set_title(TTR("Export Tile Set")); } break; @@ -2311,7 +2311,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { current_option=-1; //accept->get_cancel()->hide(); - accept->get_ok()->set_text("I see.."); + accept->get_ok()->set_text(TTR("I see..")); accept->set_text("This operation can't be done without a selected node."); accept->popup_centered_minsize(); break; @@ -2326,9 +2326,9 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { if (!p_confirmed) { - confirmation->get_ok()->set_text("Quit"); + confirmation->get_ok()->set_text(TTR("Quit")); //confirmation->get_cancel()->show(); - confirmation->set_text("Exit the Editor?"); + confirmation->set_text(TTR("Exit the Editor?")); confirmation->popup_centered(Size2(180,70)); break; } @@ -2342,9 +2342,9 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { if (unsaved_cache && !p_confirmed) { - confirmation->get_ok()->set_text("Open"); + confirmation->get_ok()->set_text(TTR("Open")); //confirmation->get_cancel()->show(); - confirmation->set_text("Current scene not saved. Open anyway?"); + confirmation->set_text(TTR("Current scene not saved. Open anyway?")); confirmation->popup_centered_minsize(); break; @@ -2396,13 +2396,13 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { String filename = scene->get_filename(); if (filename==String()) { - show_warning("Can't reload a scene that was never saved.."); + show_warning(TTR("Can't reload a scene that was never saved..")); break; } if (unsaved_cache && !p_confirmed) { - confirmation->get_ok()->set_text("Revert"); - confirmation->set_text("This action cannot be undone. Revert anyway?"); + confirmation->get_ok()->set_text(TTR("Revert")); + confirmation->set_text(TTR("This action cannot be undone. Revert anyway?")); confirmation->popup_centered_minsize(); break; } @@ -2425,7 +2425,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { current_option=-1; //accept->get_cancel()->hide(); - accept->get_ok()->set_text("I see.."); + accept->get_ok()->set_text(TTR("I see..")); accept->set_text("This operation can't be done without a selected node."); accept->popup_centered(Size2(300,70));; break; @@ -2437,7 +2437,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { current_option=-1; //confirmation->get_cancel()->hide(); - accept->get_ok()->set_text("I see.."); + accept->get_ok()->set_text(TTR("I see..")); accept->set_text("This operation can't be done without a selected node."); accept->popup_centered(Size2(300,70));; break; @@ -2449,8 +2449,8 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { current_option=-1; //accept->get_cancel()->hide(); - accept->get_ok()->set_text("Ugh"); - accept->set_text(String("Error loading scene from ")+external_file); + accept->get_ok()->set_text(TTR("Ugh")); + accept->set_text(String(TTR("Error loading scene from "))+external_file); accept->popup_centered(Size2(300,70));; return; } @@ -2458,7 +2458,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { instanced_scene->generate_instance_state(); instanced_scene->set_filename( Globals::get_singleton()->localize_path(external_file) ); - editor_data.get_undo_redo().create_action("Instance Scene"); + editor_data.get_undo_redo().create_action(TTR("Instance Scene")); editor_data.get_undo_redo().add_do_method(parent,"add_child",instanced_scene); editor_data.get_undo_redo().add_do_method(instanced_scene,"set_owner",edited_scene); editor_data.get_undo_redo().add_do_reference(instanced_scene); @@ -2612,7 +2612,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { if (run_custom_filename.empty() || editor_run.get_status()==EditorRun::STATUS_STOP) { _menu_option_confirm(RUN_STOP,true); quick_run->popup("PackedScene",true); - quick_run->set_title("Quick Run Scene.."); + quick_run->set_title(TTR("Quick Run Scene..")); play_custom_scene_button->set_pressed(false); } else { String last_custom_scene=run_custom_filename; @@ -2666,7 +2666,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { case RUN_PROJECT_MANAGER: { if (!p_confirmed) { - confirmation->get_ok()->set_text("Yes"); + confirmation->get_ok()->set_text(TTR("Yes")); confirmation->set_text("Open Project Manager? \n(Unsaved changes will be lost)"); confirmation->popup_centered_minsize(); break; @@ -2693,11 +2693,11 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { if (ischecked) { file_server->stop(); //debug_button->set_icon(gui_base->get_icon("FileServer","EditorIcons")); - //debug_button->get_popup()->set_item_text( debug_button->get_popup()->get_item_index(RUN_FILE_SERVER),"Enable File Server"); + //debug_button->get_popup()->set_item_text( debug_button->get_popup()->get_item_index(RUN_FILE_SERVER),TTR("Enable File Server")); } else { file_server->start(); //debug_button->set_icon(gui_base->get_icon("FileServerActive","EditorIcons")); - //debug_button->get_popup()->set_item_text( debug_button->get_popup()->get_item_index(RUN_FILE_SERVER),"Disable File Server"); + //debug_button->get_popup()->set_item_text( debug_button->get_popup()->get_item_index(RUN_FILE_SERVER),TTR("Disable File Server")); } debug_button->get_popup()->set_item_checked( debug_button->get_popup()->get_item_index(RUN_FILE_SERVER),!ischecked); @@ -2809,9 +2809,9 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { if (!p_confirmed) { - confirmation->get_ok()->set_text("Open"); + confirmation->get_ok()->set_text(TTR("Open")); //confirmation->get_cancel()->show(); - confirmation->set_text("Current scene changed, save and re-import ?"); + confirmation->set_text(TTR("Current scene changed, save and re-import ?")); confirmation->popup_centered(Size2(300,70)); break; @@ -2824,8 +2824,8 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { current_option=-1; //accept->get_cancel()->hide(); - accept->get_ok()->set_text("I see.."); - accept->set_text("Can't import if edited scene was not saved."); //i dont think this code will ever run + accept->get_ok()->set_text(TTR("I see..")); + accept->set_text(TTR("Can't import if edited scene was not saved.")); //i dont think this code will ever run accept->popup_centered(Size2(300,70));; break; @@ -3241,7 +3241,7 @@ Error EditorNode::save_optimized_copy(const String& p_scene,const String& p_pres if (!get_edited_scene()) { get_scene()->quit(); - ERR_EXPLAIN("No scene to optimize (loading failed?"); + ERR_EXPLAIN(TTR("No scene to optimize (loading failed?")); ERR_FAIL_V(ERR_FILE_NOT_FOUND); } @@ -3266,10 +3266,10 @@ Error EditorNode::save_optimized_copy(const String& p_scene,const String& p_pres if (!Globals::get_singleton()->has(preset)) { //accept->"()->hide(); - accept->get_ok()->set_text("I see.."); - accept->set_text("Optimizer preset not found: "+p_preset); + accept->get_ok()->set_text(TTR("I see..")); + accept->set_text(TTR("Optimizer preset not found: ")+p_preset); accept->popup_centered(Size2(300,70));; - ERR_EXPLAIN("Optimizer preset not found: "+p_preset); + ERR_EXPLAIN(TTR("Optimizer preset not found: ")+p_preset); ERR_FAIL_V(ERR_INVALID_PARAMETER); } @@ -3289,7 +3289,7 @@ Error EditorNode::save_optimized_copy(const String& p_scene,const String& p_pres } } - ERR_EXPLAIN("Preset '"+p_preset+"' references nonexistent saver: "+type); + ERR_EXPLAIN(TTR("Preset '")+p_preset+"' references nonexistent saver: "+type); ERR_FAIL_COND_V(saver.is_null(),ERR_INVALID_DATA); List<Variant> keys; @@ -3324,8 +3324,8 @@ Error EditorNode::save_optimized_copy(const String& p_scene,const String& p_pres current_option=-1; //accept->get_cancel()->hide(); - accept->get_ok()->set_text("I see.."); - accept->set_text("Couldn't save scene. Likely dependencies (instances) couldn't be satisfied."); + accept->get_ok()->set_text(TTR("I see..")); + accept->set_text(TTR("Couldn't save scene. Likely dependencies (instances) couldn't be satisfied.")); accept->popup_centered(Size2(300,70));; return ERR_INVALID_DATA; @@ -3335,8 +3335,8 @@ Error EditorNode::save_optimized_copy(const String& p_scene,const String& p_pres if (err) { //accept->"()->hide(); - accept->get_ok()->set_text("I see.."); - accept->set_text("Error saving optimized scene: "+path); + accept->get_ok()->set_text(TTR("I see..")); + accept->set_text(TTR("Error saving optimized scene: ")+path); accept->popup_centered(Size2(300,70));; ERR_FAIL_COND_V(err,err); @@ -3559,8 +3559,8 @@ Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps,bo current_option=-1; //accept->get_cancel()->hide(); - accept->get_ok()->set_text("Ugh"); - accept->set_text("Error loading scene, it must be inside the project path. Use 'Import' to open the scene, then save it inside the project path."); + accept->get_ok()->set_text(TTR("Ugh")); + accept->set_text(TTR("Error loading scene, it must be inside the project path. Use 'Import' to open the scene, then save it inside the project path.")); accept->popup_centered_minsize(); opening_prev=false; return ERR_FILE_NOT_FOUND; @@ -3588,8 +3588,8 @@ Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps,bo current_option=-1; //accept->get_cancel()->hide(); - accept->get_ok()->set_text("Ugh"); - accept->set_text("Error loading scene."); + accept->get_ok()->set_text(TTR("Ugh")); + accept->set_text(TTR("Error loading scene.")); accept->popup_centered_minsize(); opening_prev=false; @@ -3622,7 +3622,7 @@ Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps,bo for (Map<String,Set<String> >::Element *E=dependency_errors.front();E;E=E->next()) { - String txt="Scene '"+E->key()+"' has broken dependencies:\n"; + String txt=TTR("Scene '")+E->key()+"' has broken dependencies:\n"; for(Set<String>::Element *F=E->get().front();F;F=F->next()) { txt+="\t"+F->get()+"\n"; } @@ -3649,8 +3649,8 @@ Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps,bo sdata.unref(); current_option=-1; //accept->get_cancel()->hide(); - accept->get_ok()->set_text("Ugh"); - accept->set_text("Error loading scene."); + accept->get_ok()->set_text(TTR("Ugh")); + accept->set_text(TTR("Error loading scene.")); accept->popup_centered_minsize(); opening_prev=false; if (prev!=-1) { @@ -3758,7 +3758,7 @@ void EditorNode::_transform_keyed(Object *sp,const String& p_sub,const Transform void EditorNode::update_keying() { - //print_line("KR: "+itos(p_enabled)); + //print_line(TTR("KR: ")+itos(p_enabled)); bool valid=false; @@ -3904,8 +3904,8 @@ void EditorNode::_save_optimized() { if (err) { //accept->"()->hide(); - accept->get_ok()->set_text("I see.."); - accept->set_text("Error saving optimized scene: "+path); + accept->get_ok()->set_text(TTR("I see..")); + accept->set_text(TTR("Error saving optimized scene: ")+path); accept->popup_centered(Size2(300,70));; return; @@ -4589,10 +4589,10 @@ void EditorNode::_update_layouts_menu() { overridden_default_layout=-1; editor_layouts->set_size(Vector2()); - editor_layouts->add_item("Save Layout", SETTINGS_LAYOUT_SAVE); - editor_layouts->add_item("Delete Layout", SETTINGS_LAYOUT_DELETE); + editor_layouts->add_item(TTR("Save Layout"), SETTINGS_LAYOUT_SAVE); + editor_layouts->add_item(TTR("Delete Layout"), SETTINGS_LAYOUT_DELETE); editor_layouts->add_separator(); - editor_layouts->add_item("Default", SETTINGS_LAYOUT_DEFAULT); + editor_layouts->add_item(TTR("Default"), SETTINGS_LAYOUT_DEFAULT); Ref<ConfigFile> config; config.instance(); @@ -4608,7 +4608,7 @@ void EditorNode::_update_layouts_menu() { String layout=E->get(); - if (layout=="Default") { + if (layout==TTR("Default")) { editor_layouts->remove_item(editor_layouts->get_item_index(SETTINGS_LAYOUT_DEFAULT)); overridden_default_layout=editor_layouts->get_item_count(); } @@ -4625,15 +4625,15 @@ void EditorNode::_layout_menu_option(int p_id) { case SETTINGS_LAYOUT_SAVE: { current_option=p_id; - layout_dialog->set_title("Save Layout"); - layout_dialog->get_ok()->set_text("Save"); + layout_dialog->set_title(TTR("Save Layout")); + layout_dialog->get_ok()->set_text(TTR("Save")); layout_dialog->popup_centered(); } break; case SETTINGS_LAYOUT_DELETE: { current_option=p_id; - layout_dialog->set_title("Delete Layout"); - layout_dialog->get_ok()->set_text("Delete"); + layout_dialog->set_title(TTR("Delete Layout")); + layout_dialog->get_ok()->set_text(TTR("Delete")); layout_dialog->popup_centered(); } break; case SETTINGS_LAYOUT_DEFAULT: { @@ -4673,9 +4673,10 @@ void EditorNode::_scene_tab_closed(int p_tab) { saved_version!=editor_data.get_undo_redo().get_version() : editor_data.get_scene_version(p_tab)!=0; if (unsaved) { - confirmation->get_ok()->set_text("Yes"); + confirmation->get_ok()->set_text(TTR("Yes")); + //confirmation->get_cancel()->show(); - confirmation->set_text("Close scene? (Unsaved changes will be lost)"); + confirmation->set_text(TTR("Close scene? (Unsaved changes will be lost)")); confirmation->popup_centered_minsize(); } else { @@ -4701,7 +4702,7 @@ void EditorNode::_scene_tab_changed(int p_tab) { //print_line("scene tab changed???"); - editor_data.get_undo_redo().create_action("Switch Scene Tab"); + editor_data.get_undo_redo().create_action(TTR("Switch Scene Tab")); editor_data.get_undo_redo().add_do_method(this,"set_current_version",unsaved?saved_version:0); editor_data.get_undo_redo().add_do_method(this,"set_current_scene",p_tab); //editor_data.get_undo_redo().add_do_method(scene_tabs,"set_current_tab",p_tab); @@ -5036,7 +5037,7 @@ EditorNode::EditorNode() { ObjectTypeDB::set_type_enabled("CollisionShape",true); ObjectTypeDB::set_type_enabled("CollisionShape2D",true); ObjectTypeDB::set_type_enabled("CollisionPolygon2D",true); - //ObjectTypeDB::set_type_enabled("BodyVolumeConvexPolygon",true); + //ObjectTypeDB::set_type_enabled(TTR("BodyVolumeConvexPolygon"),true); gui_base = memnew( Panel ); add_child(gui_base); @@ -5309,13 +5310,13 @@ EditorNode::EditorNode() { file_menu = memnew( MenuButton ); - file_menu->set_text("Scene"); + file_menu->set_text(TTR("Scene")); //file_menu->set_icon(gui_base->get_icon("Save","EditorIcons")); left_menu_hb->add_child( file_menu ); prev_scene = memnew( ToolButton ); prev_scene->set_icon(gui_base->get_icon("PrevScene","EditorIcons")); - prev_scene->set_tooltip("Go to previously opened scene."); + prev_scene->set_tooltip(TTR("Go to previously opened scene.")); prev_scene->set_disabled(true); //left_menu_hb->add_child( prev_scene ); prev_scene->connect("pressed",this,"_menu_option",make_binds(FILE_OPEN_PREV)); @@ -5326,51 +5327,51 @@ EditorNode::EditorNode() { Separator *vs=NULL; - file_menu->set_tooltip("Operations with scene files."); + file_menu->set_tooltip(TTR("Operations with scene files.")); p=file_menu->get_popup(); - p->add_item("New Scene",FILE_NEW_SCENE); - p->add_item("New Inherited Scene..",FILE_NEW_INHERITED_SCENE); - p->add_item("Open Scene..",FILE_OPEN_SCENE,KEY_MASK_CMD+KEY_O); + p->add_item(TTR("New Scene"),FILE_NEW_SCENE); + p->add_item(TTR("New Inherited Scene.."),FILE_NEW_INHERITED_SCENE); + p->add_item(TTR("Open Scene.."),FILE_OPEN_SCENE,KEY_MASK_CMD+KEY_O); p->add_separator(); - p->add_item("Save Scene",FILE_SAVE_SCENE,KEY_MASK_CMD+KEY_S); - p->add_item("Save Scene As..",FILE_SAVE_AS_SCENE,KEY_MASK_SHIFT+KEY_MASK_CMD+KEY_S); + p->add_item(TTR("Save Scene"),FILE_SAVE_SCENE,KEY_MASK_CMD+KEY_S); + p->add_item(TTR("Save Scene As.."),FILE_SAVE_AS_SCENE,KEY_MASK_SHIFT+KEY_MASK_CMD+KEY_S); p->add_separator(); - p->add_item("Close Scene",FILE_CLOSE,KEY_MASK_SHIFT+KEY_MASK_CTRL+KEY_W); + p->add_item(TTR("Close Scene"),FILE_CLOSE,KEY_MASK_SHIFT+KEY_MASK_CTRL+KEY_W); p->add_separator(); - p->add_item("Close Goto Prev. Scene",FILE_OPEN_PREV,KEY_MASK_SHIFT+KEY_MASK_CMD+KEY_P); - p->add_submenu_item("Open Recent","RecentScenes",FILE_OPEN_RECENT); + p->add_item(TTR("Close Goto Prev. Scene"),FILE_OPEN_PREV,KEY_MASK_SHIFT+KEY_MASK_CMD+KEY_P); + p->add_submenu_item(TTR("Open Recent"),"RecentScenes",FILE_OPEN_RECENT); p->add_separator(); - p->add_item("Quick Open Scene..",FILE_QUICK_OPEN_SCENE,KEY_MASK_SHIFT+KEY_MASK_CMD+KEY_O); - p->add_item("Quick Open Script..",FILE_QUICK_OPEN_SCRIPT,KEY_MASK_ALT+KEY_MASK_CMD+KEY_O); - p->add_item("Quick Search File..",FILE_QUICK_OPEN_FILE,KEY_MASK_ALT+KEY_MASK_CMD+KEY_P); + p->add_item(TTR("Quick Open Scene.."),FILE_QUICK_OPEN_SCENE,KEY_MASK_SHIFT+KEY_MASK_CMD+KEY_O); + p->add_item(TTR("Quick Open Script.."),FILE_QUICK_OPEN_SCRIPT,KEY_MASK_ALT+KEY_MASK_CMD+KEY_O); + p->add_item(TTR("Quick Search File.."),FILE_QUICK_OPEN_FILE,KEY_MASK_ALT+KEY_MASK_CMD+KEY_P); p->add_separator(); PopupMenu *pm_export = memnew(PopupMenu ); pm_export->set_name("Export"); p->add_child(pm_export); - p->add_submenu_item("Convert To..","Export"); - pm_export->add_item("Translatable Strings..",FILE_DUMP_STRINGS); + p->add_submenu_item(TTR("Convert To.."),"Export"); + pm_export->add_item(TTR("Translatable Strings.."),FILE_DUMP_STRINGS); pm_export->add_separator(); - pm_export->add_item("MeshLibrary..",FILE_EXPORT_MESH_LIBRARY); - pm_export->add_item("TileSet..",FILE_EXPORT_TILESET); + pm_export->add_item(TTR("MeshLibrary.."),FILE_EXPORT_MESH_LIBRARY); + pm_export->add_item(TTR("TileSet.."),FILE_EXPORT_TILESET); pm_export->connect("item_pressed",this,"_menu_option"); p->add_separator(); - p->add_item("Undo",EDIT_UNDO,KEY_MASK_CMD+KEY_Z); - p->add_item("Redo",EDIT_REDO,KEY_MASK_CMD+KEY_MASK_SHIFT+KEY_Z); + p->add_item(TTR("Undo"),EDIT_UNDO,KEY_MASK_CMD+KEY_Z); + p->add_item(TTR("Redo"),EDIT_REDO,KEY_MASK_CMD+KEY_MASK_SHIFT+KEY_Z); p->add_separator(); - p->add_item("Run Script",FILE_RUN_SCRIPT,KEY_MASK_SHIFT+KEY_MASK_CMD+KEY_R); + p->add_item(TTR("Run Script"),FILE_RUN_SCRIPT,KEY_MASK_SHIFT+KEY_MASK_CMD+KEY_R); p->add_separator(); - p->add_item("Project Settings",RUN_SETTINGS); + p->add_item(TTR("Project Settings"),RUN_SETTINGS); p->add_separator(); - p->add_item("Revert Scene",EDIT_REVERT); + p->add_item(TTR("Revert Scene"),EDIT_REVERT); p->add_separator(); #ifdef OSX_ENABLED - p->add_item("Quit to Project List",RUN_PROJECT_MANAGER,KEY_MASK_SHIFT+KEY_MASK_ALT+KEY_Q); + p->add_item(TTR("Quit to Project List"),RUN_PROJECT_MANAGER,KEY_MASK_SHIFT+KEY_MASK_ALT+KEY_Q); #else - p->add_item("Quit to Project List",RUN_PROJECT_MANAGER,KEY_MASK_SHIFT+KEY_MASK_CTRL+KEY_Q); + p->add_item(TTR("Quit to Project List"),RUN_PROJECT_MANAGER,KEY_MASK_SHIFT+KEY_MASK_CTRL+KEY_Q); #endif - p->add_item("Quit",FILE_QUIT,KEY_MASK_CMD+KEY_Q); + p->add_item(TTR("Quit"),FILE_QUIT,KEY_MASK_CMD+KEY_Q); recent_scenes = memnew( PopupMenu ); recent_scenes->set_name("RecentScenes"); @@ -5397,20 +5398,20 @@ EditorNode::EditorNode() { menu_panel->add_child( node_menu ); p=node_menu->get_popup(); - p->add_item("Create",NODE_CREATE); - p->add_item("Instance",NODE_INSTANCE); + p->add_item(TTR("Create"),NODE_CREATE); + p->add_item(TTR("Instance"),NODE_INSTANCE); p->add_separator(); - p->add_item("Reparent",NODE_REPARENT); - p->add_item("Move Up",NODE_MOVE_UP); - p->add_item("Move Down",NODE_MOVE_DOWN); + p->add_item(TTR("Reparent"),NODE_REPARENT); + p->add_item(TTR("Move Up"),NODE_MOVE_UP); + p->add_item(TTR("Move Down"),NODE_MOVE_DOWN); p->add_separator(); - p->add_item("Duplicate",NODE_DUPLICATE); + p->add_item(TTR("Duplicate"),NODE_DUPLICATE); p->add_separator(); - p->add_item("Remove (Branch)",NODE_REMOVE_BRANCH); - p->add_item("Remove (Element)",NODE_REMOVE_ELEMENT); + p->add_item(TTR("Remove (Branch)"),NODE_REMOVE_BRANCH); + p->add_item(TTR("Remove (Element)"),NODE_REMOVE_ELEMENT); p->add_separator(); - p->add_item("Edit Subscriptions..",NODE_CONNECTIONS); - p->add_item("Edit Groups..",NODE_GROUPS); + p->add_item(TTR("Edit Subscriptions.."),NODE_CONNECTIONS); + p->add_item(TTR("Edit Groups.."),NODE_GROUPS); resource_menu = memnew( MenuButton ); resource_menu->set_text("Resource"); @@ -5419,8 +5420,8 @@ EditorNode::EditorNode() { #endif import_menu = memnew( MenuButton ); - import_menu->set_tooltip("Import assets to the project."); - import_menu->set_text("Import"); + import_menu->set_tooltip(TTR("Import assets to the project.")); + import_menu->set_text(TTR("Import")); //import_menu->set_icon(gui_base->get_icon("Save","EditorIcons")); left_menu_hb->add_child( import_menu ); @@ -5428,19 +5429,19 @@ EditorNode::EditorNode() { p->connect("item_pressed",this,"_menu_option"); tool_menu = memnew( MenuButton ); - tool_menu->set_tooltip("Miscelaneous project or scene wide tools."); - tool_menu->set_text("Tools"); + tool_menu->set_tooltip(TTR("Miscelaneous project or scene wide tools.")); + tool_menu->set_text(TTR("Tools")); //tool_menu->set_icon(gui_base->get_icon("Save","EditorIcons")); left_menu_hb->add_child( tool_menu ); p=tool_menu->get_popup(); p->connect("item_pressed",this,"_menu_option"); - p->add_item("Orphan Resource Explorer",TOOLS_ORPHAN_RESOURCES); + p->add_item(TTR("Orphan Resource Explorer"),TOOLS_ORPHAN_RESOURCES); export_button = memnew( ToolButton ); - export_button->set_tooltip("Export the project to many platforms."); - export_button->set_text("Export"); + export_button->set_tooltip(TTR("Export the project to many platforms.")); + export_button->set_text(TTR("Export")); export_button->connect("pressed",this,"_menu_option",varray(FILE_EXPORT_PROJECT)); export_button->set_focus_mode(Control::FOCUS_NONE); left_menu_hb->add_child(export_button); @@ -5473,7 +5474,7 @@ EditorNode::EditorNode() { play_button->set_icon(gui_base->get_icon("MainPlay","EditorIcons")); play_button->set_focus_mode(Control::FOCUS_NONE); play_button->connect("pressed", this,"_menu_option",make_binds(RUN_PLAY)); - play_button->set_tooltip("Play the project (F5)."); + play_button->set_tooltip(TTR("Play the project (F5).")); @@ -5483,7 +5484,7 @@ EditorNode::EditorNode() { pause_button->set_icon(gui_base->get_icon("Pause","EditorIcons")); pause_button->set_focus_mode(Control::FOCUS_NONE); pause_button->connect("pressed", this,"_menu_option",make_binds(RUN_PAUSE)); - pause_button->set_tooltip("Pause the scene (F7)."); + pause_button->set_tooltip(TTR("Pause the scene (F7).")); */ stop_button = memnew( ToolButton ); play_hb->add_child(stop_button); @@ -5491,7 +5492,7 @@ EditorNode::EditorNode() { stop_button->set_focus_mode(Control::FOCUS_NONE); stop_button->set_icon(gui_base->get_icon("MainStop","EditorIcons")); stop_button->connect("pressed", this,"_menu_option",make_binds(RUN_STOP)); - stop_button->set_tooltip("Stop the scene (F8)."); + stop_button->set_tooltip(TTR("Stop the scene (F8).")); run_native = memnew( EditorRunNative); play_hb->add_child(run_native); @@ -5511,7 +5512,7 @@ EditorNode::EditorNode() { play_scene_button->set_focus_mode(Control::FOCUS_NONE); play_scene_button->set_icon(gui_base->get_icon("PlayScene","EditorIcons")); play_scene_button->connect("pressed", this,"_menu_option",make_binds(RUN_PLAY_SCENE)); - play_scene_button->set_tooltip("Play the edited scene (F6)."); + play_scene_button->set_tooltip(TTR("Play the edited scene (F6).")); play_custom_scene_button = memnew( ToolButton ); play_hb->add_child(play_custom_scene_button); @@ -5519,7 +5520,7 @@ EditorNode::EditorNode() { play_custom_scene_button->set_focus_mode(Control::FOCUS_NONE); play_custom_scene_button->set_icon(gui_base->get_icon("PlayCustom","EditorIcons")); play_custom_scene_button->connect("pressed", this,"_menu_option",make_binds(RUN_PLAY_CUSTOM_SCENE)); - play_custom_scene_button->set_tooltip("Play custom scene ("+keycode_get_string(KEY_MASK_CMD|KEY_MASK_SHIFT|KEY_F5)+")."); + play_custom_scene_button->set_tooltip(TTR("Play custom scene (")+keycode_get_string(KEY_MASK_CMD|KEY_MASK_SHIFT|KEY_F5)+")."); debug_button = memnew( MenuButton ); debug_button->set_flat(true); @@ -5528,17 +5529,17 @@ EditorNode::EditorNode() { debug_button->set_focus_mode(Control::FOCUS_NONE); debug_button->set_icon(gui_base->get_icon("Remote","EditorIcons")); //debug_button->connect("pressed", this,"_menu_option",make_binds(RUN_LIVE_DEBUG)); - debug_button->set_tooltip("Debug Options"); + debug_button->set_tooltip(TTR("Debug Options")); p=debug_button->get_popup(); - p->add_check_item("Live Editing",RUN_LIVE_DEBUG); - p->add_check_item("File Server",RUN_FILE_SERVER); + p->add_check_item(TTR("Live Editing"),RUN_LIVE_DEBUG); + p->add_check_item(TTR("File Server"),RUN_FILE_SERVER); p->add_separator(); - p->add_check_item("Deploy Remote Debug",RUN_DEPLOY_REMOTE_DEBUG); - p->add_check_item("Deploy File Server Clients",RUN_DEPLOY_DUMB_CLIENTS); + p->add_check_item(TTR("Deploy Remote Debug"),RUN_DEPLOY_REMOTE_DEBUG); + p->add_check_item(TTR("Deploy File Server Clients"),RUN_DEPLOY_DUMB_CLIENTS); p->add_separator(); - p->add_check_item("Visible Collision Shapes",RUN_DEBUG_COLLISONS); - p->add_check_item("Visible Navigation",RUN_DEBUG_NAVIGATION); + p->add_check_item(TTR("Visible Collision Shapes"),RUN_DEBUG_COLLISONS); + p->add_check_item(TTR("Visible Navigation"),RUN_DEBUG_NAVIGATION); p->connect("item_pressed",this,"_menu_option"); /* @@ -5601,24 +5602,24 @@ EditorNode::EditorNode() { settings_menu = memnew( MenuButton ); - settings_menu->set_text("Settings"); + settings_menu->set_text(TTR("Settings")); //settings_menu->set_anchor(MARGIN_RIGHT,ANCHOR_END); right_menu_hb->add_child( settings_menu ); p=settings_menu->get_popup(); - //p->add_item("Export Settings",SETTINGS_EXPORT_PREFERENCES); - p->add_item("Editor Settings",SETTINGS_PREFERENCES); - //p->add_item("Optimization Presets",SETTINGS_OPTIMIZED_PRESETS); + //p->add_item(TTR("Export Settings"),SETTINGS_EXPORT_PREFERENCES); + p->add_item(TTR("Editor Settings"),SETTINGS_PREFERENCES); + //p->add_item(TTR("Optimization Presets"),SETTINGS_OPTIMIZED_PRESETS); p->add_separator(); editor_layouts = memnew( PopupMenu ); editor_layouts->set_name("Layouts"); p->add_child(editor_layouts); editor_layouts->connect("item_pressed",this,"_layout_menu_option"); - p->add_submenu_item("Editor Layout", "Layouts"); + p->add_submenu_item(TTR("Editor Layout"), "Layouts"); p->add_separator(); - p->add_item("Install Export Templates",SETTINGS_LOAD_EXPORT_TEMPLATES); + p->add_item(TTR("Install Export Templates"),SETTINGS_LOAD_EXPORT_TEMPLATES); p->add_separator(); - p->add_item("About",SETTINGS_ABOUT); + p->add_item(TTR("About"),SETTINGS_ABOUT); layout_dialog = memnew( EditorNameDialog ); gui_base->add_child(layout_dialog); @@ -5630,15 +5631,15 @@ EditorNode::EditorNode() { right_menu_hb->add_child(sources_button); sources_button->set_icon(gui_base->get_icon("DependencyOk","EditorIcons")); sources_button->connect("pressed",this,"_menu_option",varray(SOURCES_REIMPORT)); - sources_button->set_tooltip("Alerts when an external resource has changed."); + sources_button->set_tooltip(TTR("Alerts when an external resource has changed.")); update_menu = memnew( MenuButton ); - update_menu->set_tooltip("Spins when the editor window repaints!"); + update_menu->set_tooltip(TTR("Spins when the editor window repaints!")); right_menu_hb->add_child(update_menu); update_menu->set_icon(gui_base->get_icon("Progress1","EditorIcons")); p=update_menu->get_popup(); - p->add_check_item("Update Always",SETTINGS_UPDATE_ALWAYS); - p->add_check_item("Update Changes",SETTINGS_UPDATE_CHANGES); + p->add_check_item(TTR("Update Always"),SETTINGS_UPDATE_ALWAYS); + p->add_check_item(TTR("Update Changes"),SETTINGS_UPDATE_CHANGES); p->set_item_checked(1,true); //sources_button->connect(); @@ -5661,12 +5662,12 @@ EditorNode::EditorNode() { //top_pallete = memnew( TabContainer ); scene_tree_dock = memnew( SceneTreeDock(this,scene_root,editor_selection,editor_data) ); - scene_tree_dock->set_name("Scene"); + scene_tree_dock->set_name(TTR("Scene")); //top_pallete->add_child(scene_tree_dock); dock_slot[DOCK_SLOT_LEFT_UR]->add_child(scene_tree_dock); #if 0 resources_dock = memnew( ResourcesDock(this) ); - resources_dock->set_name("Resources"); + resources_dock->set_name(TTR("Resources")); //top_pallete->add_child(resources_dock); dock_slot[DOCK_SLOT_RIGHT_BL]->add_child(resources_dock); //top_pallete->set_v_size_flags(Control::SIZE_EXPAND_FILL); @@ -5692,7 +5693,7 @@ EditorNode::EditorNode() { prop_pallete->set_area_as_parent_rect();*/ VBoxContainer *prop_editor_base = memnew( VBoxContainer ); - prop_editor_base->set_name("Inspector"); // Properties? + prop_editor_base->set_name(TTR("Inspector")); // Properties? dock_slot[DOCK_SLOT_RIGHT_UL]->add_child(prop_editor_base); HBoxContainer *prop_editor_hb = memnew( HBoxContainer ); @@ -5700,25 +5701,25 @@ EditorNode::EditorNode() { prop_editor_base->add_child(prop_editor_hb); resource_new_button = memnew( ToolButton ); - resource_new_button->set_tooltip("Create a new resource in memory and edit it"); + resource_new_button->set_tooltip(TTR("Create a new resource in memory and edit it")); resource_new_button->set_icon(gui_base->get_icon("New","EditorIcons")); prop_editor_hb->add_child(resource_new_button); resource_new_button->connect("pressed",this,"_menu_option",varray(RESOURCE_NEW)); resource_new_button->set_focus_mode(Control::FOCUS_NONE); resource_load_button = memnew( ToolButton ); - resource_load_button->set_tooltip("Load an existing resource from disk and edit it"); + resource_load_button->set_tooltip(TTR("Load an existing resource from disk and edit it")); resource_load_button->set_icon(gui_base->get_icon("Load","EditorIcons")); prop_editor_hb->add_child(resource_load_button); resource_load_button->connect("pressed",this,"_menu_option",varray(RESOURCE_LOAD)); resource_load_button->set_focus_mode(Control::FOCUS_NONE); resource_save_button = memnew( MenuButton ); - resource_save_button->set_tooltip("Save the currently edited resource"); + resource_save_button->set_tooltip(TTR("Save the currently edited resource")); resource_save_button->set_icon(gui_base->get_icon("Save","EditorIcons")); prop_editor_hb->add_child(resource_save_button); - resource_save_button->get_popup()->add_item("Save",RESOURCE_SAVE); - resource_save_button->get_popup()->add_item("Save As..",RESOURCE_SAVE_AS); + resource_save_button->get_popup()->add_item(TTR("Save"),RESOURCE_SAVE); + resource_save_button->get_popup()->add_item(TTR("Save As.."),RESOURCE_SAVE_AS); resource_save_button->get_popup()->connect("item_pressed",this,"_menu_option"); resource_save_button->set_focus_mode(Control::FOCUS_NONE); resource_save_button->set_disabled(true); @@ -5728,7 +5729,7 @@ EditorNode::EditorNode() { property_back = memnew( ToolButton ); property_back->set_icon( gui_base->get_icon("Back","EditorIcons") ); property_back->set_flat(true); - property_back->set_tooltip("Go to the previous edited object in history."); + property_back->set_tooltip(TTR("Go to the previous edited object in history.")); property_back->set_disabled(true); prop_editor_hb->add_child( property_back ); @@ -5736,14 +5737,14 @@ EditorNode::EditorNode() { property_forward = memnew( ToolButton ); property_forward->set_icon( gui_base->get_icon("Forward","EditorIcons") ); property_forward->set_flat(true); - property_forward->set_tooltip("Go to the next edited object in history."); + property_forward->set_tooltip(TTR("Go to the next edited object in history.")); property_forward->set_disabled(true); prop_editor_hb->add_child( property_forward ); editor_history_menu = memnew( MenuButton ); - editor_history_menu->set_tooltip("History of recently edited objects"); + editor_history_menu->set_tooltip(TTR("History of recently edited objects")); editor_history_menu->set_icon( gui_base->get_icon("History","EditorIcons")); prop_editor_hb->add_child(editor_history_menu); editor_history_menu->connect("about_to_show",this,"_prepare_history"); @@ -5767,7 +5768,7 @@ EditorNode::EditorNode() { object_menu = memnew( MenuButton ); object_menu->set_icon(gui_base->get_icon("Tools","EditorIcons")); prop_editor_hb->add_child( object_menu ); - object_menu->set_tooltip("Object properties."); + object_menu->set_tooltip(TTR("Object properties.")); create_dialog = memnew( CreateDialog ); gui_base->add_child(create_dialog); @@ -5779,7 +5780,7 @@ EditorNode::EditorNode() { prop_editor_base->add_child(search_bar); search_bar->hide(); - Label *l = memnew( Label("Search: ") ); + Label *l = memnew( Label(TTR("Search: ")) ); search_bar->add_child(l); search_box = memnew( LineEdit ); @@ -5805,7 +5806,7 @@ EditorNode::EditorNode() { scenes_dock = memnew( ScenesDock(this) ); - scenes_dock->set_name("FileSystem"); + scenes_dock->set_name(TTR("FileSystem")); scenes_dock->set_use_thumbnails(int(EditorSettings::get_singleton()->get("file_dialog/display_mode"))==EditorFileDialog::DISPLAY_THUMBNAILS); dock_slot[DOCK_SLOT_LEFT_BR]->add_child(scenes_dock); //prop_pallete->add_child(scenes_dock); @@ -5816,9 +5817,9 @@ EditorNode::EditorNode() { overridden_default_layout=-1; default_layout.instance(); - default_layout->set_value(docks_section, "dock_3", "Scene"); - default_layout->set_value(docks_section, "dock_4", "FileSystem"); - default_layout->set_value(docks_section, "dock_5", "Inspector"); + default_layout->set_value(docks_section, "dock_3", TTR("Scene")); + default_layout->set_value(docks_section, "dock_4", TTR("FileSystem")); + default_layout->set_value(docks_section, "dock_5", TTR("Inspector")); for(int i=0;i<DOCK_SLOT_MAX/2;i++) default_layout->set_value(docks_section, "dock_hsplit_"+itos(i+1), 0); @@ -5843,7 +5844,7 @@ EditorNode::EditorNode() { log = memnew( EditorLog ); - add_bottom_panel_item("Output",log); + add_bottom_panel_item(TTR("Output"),log); //left_split->set_dragger_visible(false); @@ -5944,8 +5945,8 @@ EditorNode::EditorNode() { gui_base->add_child(project_settings); import_confirmation = memnew( ConfirmationDialog ); - import_confirmation->get_ok()->set_text("Re-Import"); - import_confirmation->add_button("Update",!OS::get_singleton()->get_swap_ok_cancel(),"update"); + import_confirmation->get_ok()->set_text(TTR("Re-Import")); + import_confirmation->add_button(TTR("Update"),!OS::get_singleton()->get_swap_ok_cancel(),"update"); import_confirmation->get_label()->set_align(Label::ALIGN_CENTER); import_confirmation->connect("confirmed",this,"_import_action",make_binds("re-import")); import_confirmation->connect("custom_action",this,"_import_action"); @@ -5964,9 +5965,9 @@ EditorNode::EditorNode() { about = memnew( AcceptDialog ); - about->set_title("Thanks so Much!"); + about->set_title(TTR("Thanks so Much!")); //about->get_cancel()->hide(); - about->get_ok()->set_text("Thanks!"); + about->get_ok()->set_text(TTR("Thanks!")); about->set_hide_on_ok(true); Label *about_text = memnew( Label ); about_text->set_text(VERSION_FULL_NAME"\n(c) 2008-2016 Juan Linietsky, Ariel Manzur.\n"); @@ -5984,7 +5985,7 @@ EditorNode::EditorNode() { file_templates = memnew( FileDialog ); - file_templates->set_title("Import Templates from ZIP file"); + file_templates->set_title(TTR("Import Templates from ZIP file")); gui_base->add_child( file_templates ); file_templates->set_mode(FileDialog::MODE_OPEN_FILE); @@ -6000,15 +6001,15 @@ EditorNode::EditorNode() { file_export = memnew( FileDialog ); file_export->set_access(FileDialog::ACCESS_FILESYSTEM); gui_base->add_child(file_export); - file_export->set_title("Export Project"); + file_export->set_title(TTR("Export Project")); file_export->connect("file_selected", this,"_dialog_action"); file_export_lib = memnew( FileDialog ); - file_export_lib->set_title("Export Library"); + file_export_lib->set_title(TTR("Export Library")); file_export_lib->set_mode(FileDialog::MODE_SAVE_FILE); file_export_lib->connect("file_selected", this,"_dialog_action"); file_export_lib_merge = memnew( CheckButton ); - file_export_lib_merge->set_text("Merge With Existing"); + file_export_lib_merge->set_text(TTR("Merge With Existing")); file_export_lib_merge->set_pressed(true); file_export_lib->get_vbox()->add_child(file_export_lib_merge); gui_base->add_child(file_export_lib); @@ -6019,11 +6020,11 @@ EditorNode::EditorNode() { file_export_password = memnew( LineEdit ); file_export_password->set_secret(true); file_export_password->set_editable(false); - file_export->get_vbox()->add_margin_child("Password:",file_export_password); + file_export->get_vbox()->add_margin_child(TTR("Password:"),file_export_password); file_script = memnew( FileDialog ); - file_script->set_title("Open & Run a Script"); + file_script->set_title(TTR("Open & Run a Script")); file_script->set_access(FileDialog::ACCESS_FILESYSTEM); file_script->set_mode(FileDialog::MODE_OPEN_FILE); List<String> sexts; @@ -6220,7 +6221,7 @@ EditorNode::EditorNode() { load_errors->set_readonly(true); load_error_dialog = memnew( AcceptDialog ); load_error_dialog->add_child(load_errors); - load_error_dialog->set_title("Load Errors"); + load_error_dialog->set_title(TTR("Load Errors")); load_error_dialog->set_child_rect(load_errors); add_child(load_error_dialog); diff --git a/tools/editor/editor_plugin_settings.cpp b/tools/editor/editor_plugin_settings.cpp index d78e43c578..3eefe10448 100644 --- a/tools/editor/editor_plugin_settings.cpp +++ b/tools/editor/editor_plugin_settings.cpp @@ -152,7 +152,7 @@ EditorPluginSettings::EditorPluginSettings() { HBoxContainer *title_hb = memnew( HBoxContainer ); title_hb->add_child(memnew( Label("Installed Plugins:"))); title_hb->add_spacer(); - update_list = memnew( Button("Update") ); + update_list = memnew( Button(TTR("Update")) ); update_list->connect("pressed",this,"update_plugins"); title_hb->add_child(update_list); add_child(title_hb); @@ -161,7 +161,7 @@ EditorPluginSettings::EditorPluginSettings() { plugin_list->set_v_size_flags(SIZE_EXPAND_FILL); plugin_list->set_columns(4); plugin_list->set_column_titles_visible(true); - plugin_list->set_column_title(0,"Name:"); + plugin_list->set_column_title(0,TTR("Name:")); plugin_list->set_column_title(1,"Version:"); plugin_list->set_column_title(2,"Author:"); plugin_list->set_column_title(3,"Status:"); diff --git a/tools/editor/editor_reimport_dialog.cpp b/tools/editor/editor_reimport_dialog.cpp index eab5a5e32d..244642b7a6 100644 --- a/tools/editor/editor_reimport_dialog.cpp +++ b/tools/editor/editor_reimport_dialog.cpp @@ -32,7 +32,7 @@ void EditorReImportDialog::popup_reimport() { if (EditorFileSystem::get_singleton()->is_scanning()) { - error->set_text("Please wait for scan to complete"); + error->set_text(TTR("Please wait for scan to complete")); error->popup_centered_minsize(); return; } @@ -69,17 +69,17 @@ void EditorReImportDialog::popup_reimport() { if (scene_must_save) { if (EditorNode::get_singleton()->get_edited_scene() && EditorNode::get_singleton()->get_edited_scene()->get_filename()=="") { - error->set_text("Current scene must be saved to re-import."); + error->set_text(TTR("Current scene must be saved to re-import.")); error->popup_centered_minsize(); - get_ok()->set_text("Re-Import"); + get_ok()->set_text(TTR("Re-Import")); get_ok()->set_disabled(true); return; } get_ok()->set_disabled(false); - get_ok()->set_text("Save & Re-Import"); + get_ok()->set_text(TTR("Save & Re-Import")); } else { - get_ok()->set_text("Re-Import"); + get_ok()->set_text(TTR("Re-Import")); get_ok()->set_disabled(false); } @@ -92,14 +92,14 @@ void EditorReImportDialog::popup_reimport() { void EditorReImportDialog::ok_pressed() { if (EditorFileSystem::get_singleton()->is_scanning()) { - error->set_text("Please wait for scan to complete"); + error->set_text(TTR("Please wait for scan to complete")); error->popup_centered_minsize(); return; } - EditorProgress ep("reimport","Re-Importing",items.size()); + EditorProgress ep("reimport",TTR("Re-Importing"),items.size()); String reload_fname; if (scene_must_save && EditorNode::get_singleton()->get_edited_scene()) { reload_fname = EditorNode::get_singleton()->get_edited_scene()->get_filename(); @@ -136,7 +136,7 @@ EditorReImportDialog::EditorReImportDialog() { add_child(tree); tree->set_hide_root(true); set_child_rect(tree); - set_title("Re-Import Changed Resources"); + set_title(TTR("Re-Import Changed Resources")); error = memnew( AcceptDialog); add_child(error); scene_must_save=false; diff --git a/tools/editor/editor_run_script.cpp b/tools/editor/editor_run_script.cpp index 90581374f6..65aaf3d734 100644 --- a/tools/editor/editor_run_script.cpp +++ b/tools/editor/editor_run_script.cpp @@ -9,12 +9,12 @@ void EditorScript::add_root_node(Node *p_node) { if (!editor) { - EditorNode::add_io_error("EditorScript::add_root_node : Write your logic in the _run() method."); + EditorNode::add_io_error(TTR("EditorScript::add_root_node : Write your logic in the _run() method.")); return; } if (editor->get_edited_scene()) { - EditorNode::add_io_error("EditorScript::add_root_node : There is an edited scene already."); + EditorNode::add_io_error(TTR("EditorScript::add_root_node : There is an edited scene already.")); return; } @@ -24,7 +24,7 @@ void EditorScript::add_root_node(Node *p_node) { Node *EditorScript::get_scene() { if (!editor) { - EditorNode::add_io_error("EditorScript::get_scene : Write your logic in the _run() method."); + EditorNode::add_io_error(TTR("EditorScript::get_scene : Write your logic in the _run() method.")); return NULL; } diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp index cf9353a857..5a58288822 100644 --- a/tools/editor/editor_settings.cpp +++ b/tools/editor/editor_settings.cpp @@ -257,13 +257,13 @@ void EditorSettings::create() { if (!dir->file_exists(config_file)) { memdelete(dir); - WARN_PRINT("Config file does not exist, creating.") + WARN_PRINT("Config file does not exist, creating."); goto fail; } memdelete(dir); - singleton = ResourceLoader::load(config_file_path,"EditorSettings"); + singleton = ResourceLoader::load(config_file_path,TTR("EditorSettings")); if (singleton.is_null()) { WARN_PRINT("Could not open config file."); goto fail; @@ -275,7 +275,7 @@ void EditorSettings::create() { if (OS::get_singleton()->is_stdout_verbose()) { - print_line("EditorSettings: Load OK!"); + print_line(TTR("EditorSettings: Load OK!")); } singleton->setup_network(); @@ -365,7 +365,7 @@ void EditorSettings::save() { } if (OS::get_singleton()->is_stdout_verbose()) { - print_line("EditorSettings Save OK!"); + print_line(TTR("EditorSettings Save OK!")); } } @@ -462,7 +462,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { set("game_window_placement/rect",0); hints["game_window_placement/rect"]=PropertyInfo(Variant::INT,"game_window_placement/rect",PROPERTY_HINT_ENUM,"Default,Centered,Custom Position,Force Maximized,Force Full Screen"); - String screen_hints="Default (Same as Editor)"; + String screen_hints=TTR("Default (Same as Editor)"); for(int i=0;i<OS::get_singleton()->get_screen_count();i++) { screen_hints+=",Monitor "+itos(i+1); } @@ -498,7 +498,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { #else hints["import/pvrtc_texture_tool"]=PropertyInfo(Variant::STRING,"import/pvrtc_texture_tool",PROPERTY_HINT_GLOBAL_FILE,""); #endif - set("PVRTC/fast_conversion",false); + set(TTR("PVRTC/fast_conversion"),false); set("run/auto_save_before_running",true); diff --git a/tools/editor/editor_sub_scene.cpp b/tools/editor/editor_sub_scene.cpp index c5a4f6d58b..941ff6be1c 100644 --- a/tools/editor/editor_sub_scene.cpp +++ b/tools/editor/editor_sub_scene.cpp @@ -198,7 +198,7 @@ EditorSubScene::EditorSubScene() { scene=NULL; - set_title("Select Sub-Scene.."); + set_title(TTR("Select Sub-Scene..")); set_hide_on_ok(false); VBoxContainer *vb = memnew( VBoxContainer ); @@ -214,11 +214,11 @@ EditorSubScene::EditorSubScene() { b->set_text(" .. "); hb->add_child(b); b->connect("pressed",this,"_path_browse"); - vb->add_margin_child("Scene Path:",hb); + vb->add_margin_child(TTR("Scene Path:"),hb); tree = memnew( Tree ); tree->set_v_size_flags(SIZE_EXPAND_FILL); - vb->add_margin_child("Import From Node:",tree,true); + vb->add_margin_child(TTR("Import From Node:"),tree,true); tree->connect("item_activated",this,"_ok",make_binds(),CONNECT_DEFERRED); file_dialog = memnew( EditorFileDialog ); diff --git a/tools/editor/file_type_cache.cpp b/tools/editor/file_type_cache.cpp index 7044a9900c..8a47f49b03 100644 --- a/tools/editor/file_type_cache.cpp +++ b/tools/editor/file_type_cache.cpp @@ -85,7 +85,7 @@ void FileTypeCache::save() { FileAccess *f =FileAccess::open(project+"/file_type_cache.cch",FileAccess::WRITE); if (!f) { - ERR_EXPLAIN("Can't open file_type_cache.cch for writing, not saving file type cache!"); + ERR_EXPLAIN(TTR("Can't open file_type_cache.cch for writing, not saving file type cache!")); ERR_FAIL(); } diff --git a/tools/editor/fileserver/editor_file_server.cpp b/tools/editor/fileserver/editor_file_server.cpp index ea95e4da1c..82dcd7819b 100644 --- a/tools/editor/fileserver/editor_file_server.cpp +++ b/tools/editor/fileserver/editor_file_server.cpp @@ -124,13 +124,13 @@ void EditorFileServer::_subthread_start(void*s) { s.parse_utf8(fileutf8.ptr()); if (cmd==FileAccessNetwork::COMMAND_FILE_EXISTS) { - print_line("FILE EXISTS: "+s); + print_line(TTR("FILE EXISTS: ")+s); } if (cmd==FileAccessNetwork::COMMAND_GET_MODTIME) { - print_line("MOD TIME: "+s); + print_line(TTR("MOD TIME: ")+s); } if (cmd==FileAccessNetwork::COMMAND_OPEN_FILE) { - print_line("OPEN: "+s); + print_line(TTR("OPEN: ")+s); } if ( !s.begins_with("res://")) { @@ -218,7 +218,7 @@ void EditorFileServer::_subthread_start(void*s) { int read = cd->files[id]->get_buffer(buf.ptr(),blocklen); ERR_CONTINUE(read<0); - print_line("GET BLOCK - offset: "+itos(offset)+", blocklen: "+itos(blocklen)); + print_line(TTR("GET BLOCK - offset: ")+itos(offset)+", blocklen: "+itos(blocklen)); //not found, continue encode_uint32(id,buf4); @@ -235,7 +235,7 @@ void EditorFileServer::_subthread_start(void*s) { } break; case FileAccessNetwork::COMMAND_CLOSE: { - print_line("CLOSED"); + print_line(TTR("CLOSED")); ERR_CONTINUE(!cd->files.has(id)); memdelete(cd->files[id]); cd->files.erase(id); diff --git a/tools/editor/groups_editor.cpp b/tools/editor/groups_editor.cpp index 4b1096148a..906ee27d1b 100644 --- a/tools/editor/groups_editor.cpp +++ b/tools/editor/groups_editor.cpp @@ -43,7 +43,7 @@ void GroupsEditor::_add_group(const String& p_group) { if (node->is_in_group(name)) return; - undo_redo->create_action("Add to Group"); + undo_redo->create_action(TTR("Add to Group")); undo_redo->add_do_method(node,"add_to_group",name,true); undo_redo->add_do_method(this,"update_tree"); @@ -66,7 +66,7 @@ void GroupsEditor::_remove_group(Object *p_item, int p_column, int p_id) { String name = ti->get_text(0); - undo_redo->create_action("Remove from Group"); + undo_redo->create_action(TTR("Remove from Group")); undo_redo->add_do_method(node,"remove_from_group",name); undo_redo->add_do_method(this,"update_tree"); @@ -125,14 +125,14 @@ GroupsEditor::GroupsEditor() { node=NULL; - set_title("Group Editor"); + set_title(TTR("Group Editor")); VBoxContainer *vbc = memnew( VBoxContainer ); add_child(vbc); set_child_rect(vbc); HBoxContainer *hbc = memnew( HBoxContainer ); - vbc->add_margin_child("Group", hbc); + vbc->add_margin_child(TTR("Group"), hbc); group_name = memnew( LineEdit ); group_name->set_h_size_flags(SIZE_EXPAND_FILL); @@ -140,17 +140,17 @@ GroupsEditor::GroupsEditor() { group_name->connect("text_entered",this,"_add_group"); add = memnew( Button ); - add->set_text("Add"); + add->set_text(TTR("Add")); hbc->add_child(add); add->connect("pressed", this,"_add_group", varray(String())); tree = memnew( Tree ); tree->set_hide_root(true); tree->set_v_size_flags(SIZE_EXPAND_FILL); - vbc->add_margin_child("Node Group(s)", tree, true); + vbc->add_margin_child(TTR("Node Group(s)"), tree, true); tree->connect("button_pressed",this,"_remove_group"); - get_ok()->set_text("Close"); + get_ok()->set_text(TTR("Close")); } GroupsEditor::~GroupsEditor() diff --git a/tools/editor/import_settings.cpp b/tools/editor/import_settings.cpp index 2bbd1e3805..057c94fad4 100644 --- a/tools/editor/import_settings.cpp +++ b/tools/editor/import_settings.cpp @@ -99,7 +99,7 @@ void ImportSettingsDialog::_button_pressed(Object *p_button, int p_col, int p_id if (!ti) return; String path = ti->get_metadata(0); - print_line("PATH: "+path); + print_line(TTR("PATH: ")+path); Ref<ResourceImportMetadata> rimd = ResourceLoader::load_import_metadata(path); ERR_FAIL_COND(rimd.is_null()); Ref<EditorImportPlugin> rimp = EditorImportExport::get_singleton()->get_import_plugin_by_name(rimd->get_editor()); @@ -256,7 +256,7 @@ void ImportSettingsDialog::ok_pressed() { return; String path = ti->get_metadata(0); - print_line("PATH: "+path); + print_line(TTR("PATH: ")+path); Ref<ResourceImportMetadata> rimd = ResourceLoader::load_import_metadata(path); ERR_FAIL_COND(rimd.is_null()); Ref<EditorImportPlugin> rimp = EditorImportExport::get_singleton()->get_import_plugin_by_name(rimd->get_editor()); @@ -271,14 +271,14 @@ ImportSettingsDialog::ImportSettingsDialog(EditorNode *p_editor) { editor=p_editor; - get_ok()->set_text("Close"); + get_ok()->set_text(TTR("Close")); tree = memnew( Tree ); add_child(tree); set_child_rect(tree); - set_title("Imported Resources"); + set_title(TTR("Imported Resources")); - texformat="Keep,None,Disk,VRAM"; + texformat=TTR("Keep,None,Disk,VRAM"); tree->set_hide_root(true); tree->set_columns(2); @@ -288,9 +288,9 @@ ImportSettingsDialog::ImportSettingsDialog(EditorNode *p_editor) { tree->connect("item_edited",this,"_item_edited"); tree->connect("button_pressed",this,"_button_pressed"); -// add_button("Re-Import","reimport"); - get_ok()->set_text("Re-Import"); - get_cancel()->set_text("Close"); +// add_button(TTR("Re-Import"),"reimport"); + get_ok()->set_text(TTR("Re-Import")); + get_cancel()->set_text(TTR("Close")); updating=false; edited=NULL; diff --git a/tools/editor/io_plugins/editor_font_import_plugin.cpp b/tools/editor/io_plugins/editor_font_import_plugin.cpp index ec251c546e..8cfa9ab6b4 100644 --- a/tools/editor/io_plugins/editor_font_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_font_import_plugin.cpp @@ -509,13 +509,13 @@ class EditorFontImportDialog : public ConfirmationDialog { void _import() { if (source->get_line_edit()->get_text()=="") { - error_dialog->set_text("No source font file!"); + error_dialog->set_text(TTR("No source font file!")); error_dialog->popup_centered(Size2(200,100)); return; } if (dest->get_line_edit()->get_text()=="") { - error_dialog->set_text("No target font resource!"); + error_dialog->set_text(TTR("No target font resource!")); error_dialog->popup_centered(Size2(200,100)); return; } @@ -527,7 +527,7 @@ class EditorFontImportDialog : public ConfirmationDialog { Ref<ResourceImportMetadata> rimd = get_rimd(); if (rimd.is_null()) { - error_dialog->set_text("Can't load/process source font"); + error_dialog->set_text(TTR("Can't load/process source font")); error_dialog->popup_centered(Size2(200,100)); return; } @@ -535,7 +535,7 @@ class EditorFontImportDialog : public ConfirmationDialog { Error err = plugin->import(dest->get_line_edit()->get_text(),rimd); if (err!=OK) { - error_dialog->set_text("Couldn't save font."); + error_dialog->set_text(TTR("Couldn't save font.")); error_dialog->popup_centered(Size2(200,100)); return; } @@ -624,9 +624,9 @@ public: source->get_file_dialog()->add_filter("*.fnt;BMFont"); source->get_line_edit()->connect("text_entered",this,"_src_changed"); - vbl->add_margin_child("Source Font:",source); + vbl->add_margin_child(TTR("Source Font:"),source); font_size = memnew( SpinBox ); - vbl->add_margin_child("Source Font Size:",font_size); + vbl->add_margin_child(TTR("Source Font Size:"),font_size); font_size->set_min(3); font_size->set_max(256); font_size->set_val(16); @@ -641,10 +641,10 @@ public: // dest->get_file_dialog()->add_filter("*."+E->get()); //} - vbl->add_margin_child("Dest Resource:",dest); + vbl->add_margin_child(TTR("Dest Resource:"),dest); HBoxContainer *testhb = memnew( HBoxContainer ); test_string = memnew( LineEdit ); - test_string->set_text("The quick brown fox jumps over the lazy dog."); + test_string->set_text(TTR("The quick brown fox jumps over the lazy dog.")); test_string->set_h_size_flags(SIZE_EXPAND_FILL); test_string->set_stretch_ratio(5); @@ -657,19 +657,19 @@ public: testhb->add_child(test_color); vbl->add_spacer(); - vbl->add_margin_child("Test: ",testhb); + vbl->add_margin_child(TTR("Test: "),testhb); /* HBoxContainer *upd_hb = memnew( HBoxContainer ); // vbl->add_child(upd_hb); upd_hb->add_spacer(); Button *update = memnew( Button); upd_hb->add_child(update); - update->set_text("Update"); + update->set_text(TTR("Update")); update->connect("pressed",this,"_update"); */ options = memnew( _EditorFontImportOptions ); prop_edit = memnew( PropertyEditor() ); - vbr->add_margin_child("Options:",prop_edit,true); + vbr->add_margin_child(TTR("Options:"),prop_edit,true); options->connect("changed",this,"_prop_changed"); prop_edit->hide_top_label(); @@ -682,7 +682,7 @@ public: test_label->set_area_as_parent_rect(); panel->set_v_size_flags(SIZE_EXPAND_FILL); test_string->connect("text_changed",this,"_update_text2"); - set_title("Font Import"); + set_title(TTR("Font Import")); timer = memnew( Timer ); add_child(timer); timer->connect("timeout",this,"_update"); @@ -690,11 +690,11 @@ public: timer->set_one_shot(true); get_ok()->connect("pressed", this,"_import"); - get_ok()->set_text("Import"); + get_ok()->set_text(TTR("Import")); error_dialog = memnew ( ConfirmationDialog ); add_child(error_dialog); - error_dialog->get_ok()->set_text("Accept"); + error_dialog->get_ok()->set_text(TTR("Accept")); set_hide_on_ok(false); @@ -887,7 +887,7 @@ Ref<BitmapFont> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMe if (src_path.extension().to_lower()=="fnt") { if (ResourceLoader::load(src_path).is_valid()) { - EditorNode::get_singleton()->show_warning("Path: "+src_path+"\nIs a Godot font file, please supply a BMFont type file instead."); + EditorNode::get_singleton()->show_warning(TTR("Path: ")+src_path+"\nIs a Godot font file, please supply a BMFont type file instead."); return Ref<BitmapFont>(); } @@ -895,7 +895,7 @@ Ref<BitmapFont> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMe font.instance(); Error err = font->create_from_fnt(src_path); if (err) { - EditorNode::get_singleton()->show_warning("Path: "+src_path+"\nFailed opening as BMFont file."); + EditorNode::get_singleton()->show_warning(TTR("Path: ")+src_path+"\nFailed opening as BMFont file."); return Ref<BitmapFont>(); } @@ -912,18 +912,18 @@ Ref<BitmapFont> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMe int error = FT_Init_FreeType( &library ); - ERR_EXPLAIN("Error initializing FreeType."); + ERR_EXPLAIN(TTR("Error initializing FreeType.")); ERR_FAIL_COND_V( error !=0, Ref<BitmapFont>() ); print_line("loadfrom: "+src_path); error = FT_New_Face( library, src_path.utf8().get_data(),0,&face ); if ( error == FT_Err_Unknown_File_Format ) { - ERR_EXPLAIN("Unknown font format."); + ERR_EXPLAIN(TTR("Unknown font format.")); FT_Done_FreeType( library ); } else if ( error ) { - ERR_EXPLAIN("Error loading font."); + ERR_EXPLAIN(TTR("Error loading font.")); FT_Done_FreeType( library ); } @@ -939,7 +939,7 @@ Ref<BitmapFont> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMe if ( error ) { FT_Done_FreeType( library ); - ERR_EXPLAIN("Invalid font size. "); + ERR_EXPLAIN(TTR("Invalid font size. ")); ERR_FAIL_COND_V( error,Ref<BitmapFont>() ); } @@ -986,7 +986,7 @@ Ref<BitmapFont> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMe if ( !fa ) { FT_Done_FreeType( library ); - ERR_EXPLAIN("Invalid font custom source. "); + ERR_EXPLAIN(TTR("Invalid font custom source. ")); ERR_FAIL_COND_V( !fa,Ref<BitmapFont>() ); } @@ -1506,7 +1506,7 @@ Ref<BitmapFont> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMe EditorAtlas::fit(sizes,res,res_size); res_size.x=nearest_power_of_2(res_size.x); res_size.y=nearest_power_of_2(res_size.y); - print_line("Atlas size: "+res_size); + print_line(TTR("Atlas size: ")+res_size); Image atlas(res_size.x,res_size.y,0,Image::FORMAT_RGBA); diff --git a/tools/editor/io_plugins/editor_mesh_import_plugin.cpp b/tools/editor/io_plugins/editor_mesh_import_plugin.cpp index b32ab8cb0b..e628bed2dd 100644 --- a/tools/editor/io_plugins/editor_mesh_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_mesh_import_plugin.cpp @@ -202,7 +202,7 @@ public: Vector<String> meshes = import_path->get_text().split(","); if (meshes.size()==0) { - error_dialog->set_text("No meshes to import!"); + error_dialog->set_text(TTR("No meshes to import!")); error_dialog->popup_centered_minsize(); return; } @@ -226,7 +226,7 @@ public: String dst = save_path->get_text(); if (dst=="") { - error_dialog->set_text("Save path is empty!"); + error_dialog->set_text(TTR("Save path is empty!")); error_dialog->popup_centered_minsize(); return; } @@ -261,7 +261,7 @@ public: plugin=p_plugin; - set_title("Single Mesh Import"); + set_title(TTR("Single Mesh Import")); set_hide_on_ok(false); VBoxContainer *vbc = memnew( VBoxContainer ); @@ -269,7 +269,7 @@ public: set_child_rect(vbc); HBoxContainer *hbc = memnew( HBoxContainer ); - vbc->add_margin_child("Source Mesh(es):",hbc); + vbc->add_margin_child(TTR("Source Mesh(es):"),hbc); import_path = memnew( LineEdit ); import_path->set_h_size_flags(SIZE_EXPAND_FILL); @@ -282,7 +282,7 @@ public: import_choose->connect("pressed", this,"_browse"); hbc = memnew( HBoxContainer ); - vbc->add_margin_child("Target Path:",hbc); + vbc->add_margin_child(TTR("Target Path:"),hbc); save_path = memnew( LineEdit ); save_path->set_h_size_flags(SIZE_EXPAND_FILL); @@ -306,7 +306,7 @@ public: save_select->connect("dir_selected", this,"_choose_save_dir"); get_ok()->connect("pressed", this,"_import"); - get_ok()->set_text("Import"); + get_ok()->set_text(TTR("Import")); error_dialog = memnew( AcceptDialog ); add_child(error_dialog); @@ -315,7 +315,7 @@ public: option_editor = memnew( PropertyEditor ); option_editor->hide_top_label(); - vbc->add_margin_child("Options:",option_editor,true); + vbc->add_margin_child(TTR("Options:"),option_editor,true); } ~EditorMeshImportDialog() { @@ -362,7 +362,7 @@ Error EditorMeshImportPlugin::import(const String& p_path, const Ref<ResourceImp if (mesh->surface_get_name(i)!="") name=mesh->surface_get_name(i); else - name="Surface "+itos(i+1); + name=TTR("Surface ")+itos(i+1); name_map[name]=mesh->surface_get_material(i); } @@ -498,7 +498,7 @@ Error EditorMeshImportPlugin::import(const String& p_path, const Ref<ResourceImp surf_tool->index(); mesh = surf_tool->commit(mesh); if (name=="") - name="Surface "+itos(mesh->get_surface_count()-1); + name=TTR("Surface ")+itos(mesh->get_surface_count()-1); mesh->surface_set_name(mesh->get_surface_count()-1,name); name=""; surf_tool->clear(); diff --git a/tools/editor/io_plugins/editor_sample_import_plugin.cpp b/tools/editor/io_plugins/editor_sample_import_plugin.cpp index 5408e43e1a..116c5f874e 100644 --- a/tools/editor/io_plugins/editor_sample_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_sample_import_plugin.cpp @@ -251,24 +251,24 @@ public: Vector<String> samples = import_path->get_text().split(","); if (samples.size()==0) { - error_dialog->set_text("No samples to import!"); + error_dialog->set_text(TTR("No samples to import!")); error_dialog->popup_centered(Size2(200,100)); } if (save_path->get_text().strip_edges()=="") { - error_dialog->set_text("Target path is empty."); + error_dialog->set_text(TTR("Target path is empty.")); error_dialog->popup_centered_minsize(); return; } if (!save_path->get_text().begins_with("res://")) { - error_dialog->set_text("Target path must be full resource path."); + error_dialog->set_text(TTR("Target path must be full resource path.")); error_dialog->popup_centered_minsize(); return; } if (!DirAccess::exists(save_path->get_text())) { - error_dialog->set_text("Target path must exist."); + error_dialog->set_text(TTR("Target path must exist.")); error_dialog->popup_centered_minsize(); return; } @@ -292,7 +292,7 @@ public: String dst = save_path->get_text(); if (dst=="") { - error_dialog->set_text("Save path is empty!"); + error_dialog->set_text(TTR("Save path is empty!")); error_dialog->popup_centered(Size2(200,100)); } @@ -331,7 +331,7 @@ public: plugin=p_plugin; - set_title("Import Audio Samples"); + set_title(TTR("Import Audio Samples")); VBoxContainer *vbc = memnew( VBoxContainer ); add_child(vbc); @@ -339,7 +339,7 @@ public: HBoxContainer *hbc = memnew( HBoxContainer ); - vbc->add_margin_child("Source Sample(s):",hbc); + vbc->add_margin_child(TTR("Source Sample(s):"),hbc); import_path = memnew( LineEdit ); import_path->set_h_size_flags(SIZE_EXPAND_FILL); @@ -352,7 +352,7 @@ public: import_choose->connect("pressed", this,"_browse"); hbc = memnew( HBoxContainer ); - vbc->add_margin_child("Target Path:",hbc); + vbc->add_margin_child(TTR("Target Path:"),hbc); save_path = memnew( LineEdit ); save_path->set_h_size_flags(SIZE_EXPAND_FILL); @@ -377,12 +377,12 @@ public: save_select->connect("dir_selected", this,"_choose_save_dir"); get_ok()->connect("pressed", this,"_import"); - get_ok()->set_text("Import"); + get_ok()->set_text(TTR("Import")); error_dialog = memnew ( ConfirmationDialog ); add_child(error_dialog); - error_dialog->get_ok()->set_text("Accept"); + error_dialog->get_ok()->set_text(TTR("Accept")); // error_dialog->get_cancel()->hide(); set_hide_on_ok(false); @@ -390,7 +390,7 @@ public: option_editor = memnew( PropertyEditor ); option_editor->hide_top_label(); - vbc->add_margin_child("Options:",option_editor,true); + vbc->add_margin_child(TTR("Options:"),option_editor,true); } ~EditorSampleImportDialog() { @@ -406,7 +406,7 @@ String EditorSampleImportPlugin::get_name() const { } String EditorSampleImportPlugin::get_visible_name() const{ - return "Audio Sample"; + return TTR("Audio Sample"); } void EditorSampleImportPlugin::import_dialog(const String& p_from){ @@ -431,7 +431,7 @@ Error EditorSampleImportPlugin::import(const String& p_path, const Ref<ResourceI int loop_beg = smp->get_loop_begin(); int loop_end = smp->get_loop_end(); - print_line("Input Sample: "); + print_line(TTR("Input Sample: ")); print_line("\tlen: "+itos(len)); print_line("\tchans: "+itos(chans)); print_line("\t16bits: "+itos(is16)); @@ -612,7 +612,7 @@ Error EditorSampleImportPlugin::import(const String& p_path, const Ref<ResourceI _compress_ima_adpcm(data,dst_data); } else { - print_line("INTERLEAAVE!"); + print_line(TTR("INTERLEAAVE!")); diff --git a/tools/editor/io_plugins/editor_scene_import_plugin.cpp b/tools/editor/io_plugins/editor_scene_import_plugin.cpp index af6ae561df..33d3a7cdee 100644 --- a/tools/editor/io_plugins/editor_scene_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_scene_import_plugin.cpp @@ -317,7 +317,7 @@ void EditorImportAnimationOptions::_item_edited() { String name = item->get_text(0); name=name.replace("/","_").replace(":","_").strip_edges(); if (name=="") - name="New Clip"; + name=TTR("New Clip"); if (clips.size()>2) { int index=1; @@ -441,12 +441,12 @@ EditorImportAnimationOptions::EditorImportAnimationOptions() { validating=false; TabContainer *tab= memnew(TabContainer); - add_margin_child("Animation Options",tab,true); + add_margin_child(TTR("Animation Options"),tab,true); flags = memnew( Tree ); flags->set_hide_root(true); tab->add_child(flags); - flags->set_name("Flags"); + flags->set_name(TTR("Flags")); TreeItem *root = flags->create_item(); const char ** fname=anim_flag_names; @@ -466,7 +466,7 @@ EditorImportAnimationOptions::EditorImportAnimationOptions() { TreeItem *fps_base = flags->create_item(root); - fps_base->set_text(0,"Bake FPS:"); + fps_base->set_text(0,TTR("Bake FPS:")); fps_base->set_editable(0,false); fps = flags->create_item(fps_base); fps->set_cell_mode(0,TreeItem::CELL_MODE_RANGE); @@ -477,7 +477,7 @@ EditorImportAnimationOptions::EditorImportAnimationOptions() { optimization_tree = memnew( Tree ); optimization_tree->set_columns(2); tab->add_child(optimization_tree); - optimization_tree->set_name("Optimizer"); + optimization_tree->set_name(TTR("Optimizer")); optimization_tree->set_column_expand(0,true); optimization_tree->set_column_expand(1,false); optimization_tree->set_column_min_width(1,80); @@ -487,21 +487,21 @@ EditorImportAnimationOptions::EditorImportAnimationOptions() { TreeItem *optimize_root = optimization_tree->create_item(); optimize_linear_error = optimization_tree->create_item(optimize_root); - optimize_linear_error->set_text(0,"Max Linear Error"); + optimize_linear_error->set_text(0,TTR("Max Linear Error")); optimize_linear_error->set_cell_mode(1,TreeItem::CELL_MODE_RANGE); optimize_linear_error->set_editable(1,true); optimize_linear_error->set_range_config(1,0,1,0.001); optimize_linear_error->set_range(1,0.05); optimize_angular_error = optimization_tree->create_item(optimize_root); - optimize_angular_error->set_text(0,"Max Angular Error"); + optimize_angular_error->set_text(0,TTR("Max Angular Error")); optimize_angular_error->set_cell_mode(1,TreeItem::CELL_MODE_RANGE); optimize_angular_error->set_editable(1,true); optimize_angular_error->set_range_config(1,0,1,0.001); optimize_angular_error->set_range(1,0.01); optimize_max_angle = optimization_tree->create_item(optimize_root); - optimize_max_angle->set_text(0,"Max Angle"); + optimize_max_angle->set_text(0,TTR("Max Angle")); optimize_max_angle->set_cell_mode(1,TreeItem::CELL_MODE_RANGE); optimize_max_angle->set_editable(1,true); optimize_max_angle->set_range_config(1,0,360,0.001); @@ -510,7 +510,7 @@ EditorImportAnimationOptions::EditorImportAnimationOptions() { clips_tree = memnew( Tree ); clips_tree->set_hide_root(true); tab->add_child(clips_tree); - clips_tree->set_name("Clips"); + clips_tree->set_name(TTR("Clips")); clips_tree->set_columns(4); clips_tree->set_column_expand(0,1); @@ -521,10 +521,10 @@ EditorImportAnimationOptions::EditorImportAnimationOptions() { clips_tree->set_column_min_width(2,60); clips_tree->set_column_min_width(3,40); clips_tree->set_column_titles_visible(true); - clips_tree->set_column_title(0,"Name"); - clips_tree->set_column_title(1,"Start(s)"); - clips_tree->set_column_title(2,"End(s)"); - clips_tree->set_column_title(3,"Loop"); + clips_tree->set_column_title(0,TTR("Name")); + clips_tree->set_column_title(1,TTR("Start(s)")); + clips_tree->set_column_title(2,TTR("End(s)")); + clips_tree->set_column_title(3,TTR("Loop")); clips_base =clips_tree->create_item(0); @@ -533,7 +533,7 @@ EditorImportAnimationOptions::EditorImportAnimationOptions() { filters = memnew( TextEdit ); tab->add_child(filters); - filters->set_name("Filters"); + filters->set_name(TTR("Filters")); } @@ -674,25 +674,25 @@ void EditorSceneImportDialog::_import(bool p_and_open) { if (import_path->get_text().strip_edges()=="") { - error_dialog->set_text("Source path is empty."); + error_dialog->set_text(TTR("Source path is empty.")); error_dialog->popup_centered_minsize(); return; } if (save_path->get_text().strip_edges()=="") { - error_dialog->set_text("Target path is empty."); + error_dialog->set_text(TTR("Target path is empty.")); error_dialog->popup_centered_minsize(); return; } if (!save_path->get_text().begins_with("res://")) { - error_dialog->set_text("Target path must be full resource path."); + error_dialog->set_text(TTR("Target path must be full resource path.")); error_dialog->popup_centered_minsize(); return; } if (!DirAccess::exists(save_path->get_text())) { - error_dialog->set_text("Target path must exist."); + error_dialog->set_text(TTR("Target path must exist.")); error_dialog->popup_centered_minsize(); return; } @@ -721,7 +721,7 @@ void EditorSceneImportDialog::_import(bool p_and_open) { if (script_path->get_text()!="") { Ref<Script> scr = ResourceLoader::load(script_path->get_text()); if (!scr.is_valid()) { - error_dialog->set_text("Couldn't load Post-Import Script."); + error_dialog->set_text(TTR("Couldn't load Post-Import Script.")); error_dialog->popup_centered(Size2(200,100)); return; } @@ -730,7 +730,7 @@ void EditorSceneImportDialog::_import(bool p_and_open) { pi->set_script(scr.get_ref_ptr()); if (!pi->get_script_instance()) { - error_dialog->set_text("Invalid/Broken Script for Post-Import."); + error_dialog->set_text(TTR("Invalid/Broken Script for Post-Import.")); error_dialog->popup_centered(Size2(200,100)); return; } @@ -739,7 +739,7 @@ void EditorSceneImportDialog::_import(bool p_and_open) { String save_file = save_path->get_text().plus_file(import_path->get_text().get_file().basename()+".scn"); - print_line("Saving to: "+save_file); + print_line(TTR("Saving to: ")+save_file); @@ -752,7 +752,7 @@ void EditorSceneImportDialog::_import(bool p_and_open) { rim->add_source(EditorImportPlugin::validate_source_path(import_path->get_text())); rim->set_option("flags",flags); - print_line("GET FLAGS: "+itos(texture_options->get_flags())); + print_line(TTR("GET FLAGS: ")+itos(texture_options->get_flags())); rim->set_option("texture_flags",texture_options->get_flags()); rim->set_option("texture_format",texture_options->get_format()); rim->set_option("texture_quality",texture_options->get_quality()); @@ -773,7 +773,7 @@ void EditorSceneImportDialog::_import(bool p_and_open) { if (err || !scene) { - error_dialog->set_text("Error importing scene."); + error_dialog->set_text(TTR("Error importing scene.")); error_dialog->popup_centered(Size2(200,100)); return; } @@ -798,7 +798,7 @@ void EditorSceneImportDialog::_import(bool p_and_open) { if (err) { - error_dialog->set_text("Error importing scene."); + error_dialog->set_text(TTR("Error importing scene.")); error_dialog->popup_centered(Size2(200,100)); return; } @@ -816,7 +816,7 @@ void EditorSceneImportDialog::_import(bool p_and_open) { if (err) { - error_dialog->set_text("Error importing scene."); + error_dialog->set_text(TTR("Error importing scene.")); error_dialog->popup_centered(Size2(200,100)); return; } @@ -842,7 +842,7 @@ void EditorSceneImportDialog::_import_confirm() { if (err) { wip_save_file=""; - error_dialog->set_text("Error importing scene."); + error_dialog->set_text(TTR("Error importing scene.")); error_dialog->popup_centered(Size2(200,100)); return; } @@ -973,7 +973,7 @@ void EditorSceneImportDialog::_dialog_hid() { if (wip_blocked) return; - print_line("DIALOGHID!"); + print_line(TTR("DIALOGHID!")); if (wip_import) { memdelete(wip_import); wip_import=NULL; @@ -1005,26 +1005,26 @@ void EditorSceneImportDialog::_bind_methods() { const EditorSceneImportDialog::FlagInfo EditorSceneImportDialog::scene_flag_names[]={ - {EditorSceneImportPlugin::SCENE_FLAG_REMOVE_NOIMP,"Actions","Remove Nodes (-noimp)",true}, - {EditorSceneImportPlugin::SCENE_FLAG_IMPORT_ANIMATIONS,"Actions","Import Animations",true}, - {EditorSceneImportPlugin::SCENE_FLAG_COMPRESS_GEOMETRY,"Actions","Compress Geometry",false}, - {EditorSceneImportPlugin::SCENE_FLAG_GENERATE_TANGENT_ARRAYS,"Actions","Force Generation of Tangent Arrays",false}, - {EditorSceneImportPlugin::SCENE_FLAG_DETECT_ALPHA,"Materials","Set Alpha in Materials (-alpha)",true}, - {EditorSceneImportPlugin::SCENE_FLAG_DETECT_VCOLOR,"Materials","Set Vert. Color in Materials (-vcol)",true}, - {EditorSceneImportPlugin::SCENE_FLAG_LINEARIZE_DIFFUSE_TEXTURES,"Actions","SRGB->Linear Of Diffuse Textures",false}, - {EditorSceneImportPlugin::SCENE_FLAG_CONVERT_NORMALMAPS_TO_XY,"Actions","Convert Normal Maps to XY",true}, - {EditorSceneImportPlugin::SCENE_FLAG_SET_LIGHTMAP_TO_UV2_IF_EXISTS,"Actions","Set Material Lightmap to UV2 if Tex2Array Exists",true}, - {EditorSceneImportPlugin::SCENE_FLAG_CREATE_COLLISIONS,"Create","Create Collisions (-col},-colonly)",true}, - {EditorSceneImportPlugin::SCENE_FLAG_CREATE_PORTALS,"Create","Create Portals (-portal)",true}, - {EditorSceneImportPlugin::SCENE_FLAG_CREATE_ROOMS,"Create","Create Rooms (-room)",true}, - {EditorSceneImportPlugin::SCENE_FLAG_SIMPLIFY_ROOMS,"Create","Simplify Rooms",false}, - {EditorSceneImportPlugin::SCENE_FLAG_CREATE_BILLBOARDS,"Create","Create Billboards (-bb)",true}, - {EditorSceneImportPlugin::SCENE_FLAG_CREATE_IMPOSTORS,"Create","Create Impostors (-imp:dist)",true}, - {EditorSceneImportPlugin::SCENE_FLAG_CREATE_LODS,"Create","Create LODs (-lod:dist)",true}, - {EditorSceneImportPlugin::SCENE_FLAG_CREATE_CARS,"Create","Create Vehicles (-vehicle)",true}, - {EditorSceneImportPlugin::SCENE_FLAG_CREATE_WHEELS,"Create","Create Vehicle Wheels (-wheel)",true}, - {EditorSceneImportPlugin::SCENE_FLAG_CREATE_NAVMESH,"Create","Create Navigation Meshes (-navmesh)",true}, - {EditorSceneImportPlugin::SCENE_FLAG_DETECT_LIGHTMAP_LAYER,"Create","Detect LightMap Layer (-lm:<int>).",true}, + {EditorSceneImportPlugin::SCENE_FLAG_REMOVE_NOIMP,("Actions"),"Remove Nodes (-noimp)",true}, + {EditorSceneImportPlugin::SCENE_FLAG_IMPORT_ANIMATIONS,("Actions"),"Import Animations",true}, + {EditorSceneImportPlugin::SCENE_FLAG_COMPRESS_GEOMETRY,("Actions"),"Compress Geometry",false}, + {EditorSceneImportPlugin::SCENE_FLAG_GENERATE_TANGENT_ARRAYS,("Actions"),"Force Generation of Tangent Arrays",false}, + {EditorSceneImportPlugin::SCENE_FLAG_DETECT_ALPHA,("Materials"),"Set Alpha in Materials (-alpha)",true}, + {EditorSceneImportPlugin::SCENE_FLAG_DETECT_VCOLOR,("Materials"),"Set Vert. Color in Materials (-vcol)",true}, + {EditorSceneImportPlugin::SCENE_FLAG_LINEARIZE_DIFFUSE_TEXTURES,("Actions"),"SRGB->Linear Of Diffuse Textures",false}, + {EditorSceneImportPlugin::SCENE_FLAG_CONVERT_NORMALMAPS_TO_XY,("Actions"),"Convert Normal Maps to XY",true}, + {EditorSceneImportPlugin::SCENE_FLAG_SET_LIGHTMAP_TO_UV2_IF_EXISTS,("Actions"),"Set Material Lightmap to UV2 if Tex2Array Exists",true}, + {EditorSceneImportPlugin::SCENE_FLAG_CREATE_COLLISIONS,("Create"),"Create Collisions (-col},-colonly)",true}, + {EditorSceneImportPlugin::SCENE_FLAG_CREATE_PORTALS,("Create"),"Create Portals (-portal)",true}, + {EditorSceneImportPlugin::SCENE_FLAG_CREATE_ROOMS,("Create"),"Create Rooms (-room)",true}, + {EditorSceneImportPlugin::SCENE_FLAG_SIMPLIFY_ROOMS,("Create"),"Simplify Rooms",false}, + {EditorSceneImportPlugin::SCENE_FLAG_CREATE_BILLBOARDS,("Create"),"Create Billboards (-bb)",true}, + {EditorSceneImportPlugin::SCENE_FLAG_CREATE_IMPOSTORS,("Create"),"Create Impostors (-imp:dist)",true}, + {EditorSceneImportPlugin::SCENE_FLAG_CREATE_LODS,("Create"),"Create LODs (-lod:dist)",true}, + {EditorSceneImportPlugin::SCENE_FLAG_CREATE_CARS,("Create"),"Create Vehicles (-vehicle)",true}, + {EditorSceneImportPlugin::SCENE_FLAG_CREATE_WHEELS,("Create"),"Create Vehicle Wheels (-wheel)",true}, + {EditorSceneImportPlugin::SCENE_FLAG_CREATE_NAVMESH,("Create"),"Create Navigation Meshes (-navmesh)",true}, + {EditorSceneImportPlugin::SCENE_FLAG_DETECT_LIGHTMAP_LAYER,("Create"),"Detect LightMap Layer (-lm:<int>).",true}, {-1,NULL,NULL,false} }; @@ -1035,7 +1035,7 @@ EditorSceneImportDialog::EditorSceneImportDialog(EditorNode *p_editor, EditorSce editor=p_editor; plugin=p_plugin; - set_title("Import 3D Scene"); + set_title(TTR("Import 3D Scene")); HBoxContainer *import_hb = memnew( HBoxContainer ); add_child(import_hb); set_child_rect(import_hb); @@ -1045,7 +1045,7 @@ EditorSceneImportDialog::EditorSceneImportDialog(EditorNode *p_editor, EditorSce vbc->set_h_size_flags(SIZE_EXPAND_FILL); HBoxContainer *hbc = memnew( HBoxContainer ); - vbc->add_margin_child("Source Scene:",hbc); + vbc->add_margin_child(TTR("Source Scene:"),hbc); import_path = memnew( LineEdit ); import_path->set_h_size_flags(SIZE_EXPAND_FILL); @@ -1058,7 +1058,7 @@ EditorSceneImportDialog::EditorSceneImportDialog(EditorNode *p_editor, EditorSce import_choose->connect("pressed", this,"_browse"); hbc = memnew( HBoxContainer ); - vbc->add_margin_child("Target Path:",hbc); + vbc->add_margin_child(TTR("Target Path:"),hbc); save_path = memnew( LineEdit ); save_path->set_h_size_flags(SIZE_EXPAND_FILL); @@ -1071,14 +1071,14 @@ EditorSceneImportDialog::EditorSceneImportDialog(EditorNode *p_editor, EditorSce save_choose->connect("pressed", this,"_browse_target"); texture_action = memnew( OptionButton ); - texture_action->add_item("Same as Target Scene"); - texture_action->add_item("Shared"); + texture_action->add_item(TTR("Same as Target Scene")); + texture_action->add_item(TTR("Shared")); texture_action->select(0); - vbc->add_margin_child("Target Texture Folder:",texture_action); + vbc->add_margin_child(TTR("Target Texture Folder:"),texture_action); import_options = memnew( Tree ); vbc->set_v_size_flags(SIZE_EXPAND_FILL); - vbc->add_margin_child("Options:",import_options,true); + vbc->add_margin_child(TTR("Options:"),import_options,true); file_select = memnew(EditorFileDialog); file_select->set_access(EditorFileDialog::ACCESS_FILESYSTEM); @@ -1096,7 +1096,7 @@ EditorSceneImportDialog::EditorSceneImportDialog(EditorNode *p_editor, EditorSce save_select->connect("dir_selected", this,"_choose_save_file"); get_ok()->connect("pressed", this,"_import"); - get_ok()->set_text("Import"); + get_ok()->set_text(TTR("Import")); TreeItem *root = import_options->create_item(NULL); import_options->set_hide_root(true); @@ -1129,7 +1129,7 @@ EditorSceneImportDialog::EditorSceneImportDialog(EditorNode *p_editor, EditorSce } hbc = memnew( HBoxContainer ); - vbc->add_margin_child("Post-Process Script:",hbc); + vbc->add_margin_child(TTR("Post-Process Script:"),hbc); script_path = memnew( LineEdit ); script_path->set_h_size_flags(SIZE_EXPAND_FILL); @@ -1159,22 +1159,22 @@ EditorSceneImportDialog::EditorSceneImportDialog(EditorNode *p_editor, EditorSce error_dialog = memnew ( ConfirmationDialog ); add_child(error_dialog); - error_dialog->get_ok()->set_text("Accept"); + error_dialog->get_ok()->set_text(TTR("Accept")); // error_dialog->get_cancel()->hide(); this_import = memnew( OptionButton ); - this_import->add_item("Overwrite Existing Scene"); + this_import->add_item(TTR("Overwrite Existing Scene")); this_import->add_item("Overwrite Existing, Keep Materials"); - this_import->add_item("Keep Existing, Merge with New"); - this_import->add_item("Keep Existing, Ignore New"); - vbc->add_margin_child("This Time:",this_import); + this_import->add_item(TTR("Keep Existing, Merge with New")); + this_import->add_item(TTR("Keep Existing, Ignore New")); + vbc->add_margin_child(TTR("This Time:"),this_import); next_import = memnew( OptionButton ); - next_import->add_item("Overwrite Existing Scene"); + next_import->add_item(TTR("Overwrite Existing Scene")); next_import->add_item("Overwrite Existing, Keep Materials"); - next_import->add_item("Keep Existing, Merge with New"); - next_import->add_item("Keep Existing, Ignore New"); - vbc->add_margin_child("Next Time:",next_import); + next_import->add_item(TTR("Keep Existing, Merge with New")); + next_import->add_item(TTR("Keep Existing, Ignore New")); + vbc->add_margin_child(TTR("Next Time:"),next_import); set_hide_on_ok(false); @@ -1211,19 +1211,19 @@ EditorSceneImportDialog::EditorSceneImportDialog(EditorNode *p_editor, EditorSce pc->add_style_override("panel",get_stylebox("normal","TextEdit")); //ec->add_child(pc); missing_files = memnew( RichTextLabel ); - cvb->add_margin_child("The Following Files are Missing:",pc,true); + cvb->add_margin_child(TTR("The Following Files are Missing:"),pc,true); pc->add_child(missing_files); - confirm_import->get_ok()->set_text("Import Anyway"); - confirm_import->get_cancel()->set_text("Cancel"); + confirm_import->get_ok()->set_text(TTR("Import Anyway")); + confirm_import->get_cancel()->set_text(TTR("Cancel")); confirm_import->connect("popup_hide",this,"_dialog_hid"); confirm_import->connect("confirmed",this,"_import_confirm"); confirm_import->set_hide_on_ok(false); - add_button("Import & Open",!OS::get_singleton()->get_swap_ok_cancel())->connect("pressed",this,"_open_and_import"); + add_button(TTR("Import & Open"),!OS::get_singleton()->get_swap_ok_cancel())->connect("pressed",this,"_open_and_import"); confirm_open = memnew( ConfirmationDialog ); add_child(confirm_open); - confirm_open->set_text("Edited scene has not been saved, open imported scene anyway?"); + confirm_open->set_text(TTR("Edited scene has not been saved, open imported scene anyway?")); confirm_open->connect("confirmed",this,"_import",varray(true)); @@ -2285,11 +2285,11 @@ void EditorSceneImportPlugin::_merge_materials(Node *p_node,Node *p_imported) { _scan_materials(p_node,p_node,mesh_materials,override_materials); for (Map<String,Ref<Material> >::Element *E=mesh_materials.front();E;E=E->next()) { - print_line("Mats: "+String(E->key())); + print_line(TTR("Mats: ")+String(E->key())); } for (Map<String,Ref<Material> >::Element *E=override_materials.front();E;E=E->next()) { - print_line("Overrides: "+String(E->key())); + print_line(TTR("Overrides: ")+String(E->key())); } Set<Ref<Mesh> > mp; @@ -2339,8 +2339,8 @@ Error EditorSceneImportPlugin::import1(const Ref<ResourceImportMetadata>& p_from String ext=src_path.extension().to_lower(); - EditorProgress progress("import","Import Scene",104); - progress.step("Importing Scene..",0); + EditorProgress progress("import",TTR("Import Scene"),104); + progress.step(TTR("Importing Scene.."),0); for(int i=0;i<importers.size();i++) { @@ -2517,7 +2517,7 @@ void EditorSceneImportPlugin::_filter_anim_tracks(Ref<Animation> anim,Set<String Ref<Animation> a = anim; ERR_FAIL_COND(!a.is_valid()); - print_line("From Anim "+anim->get_name()+":"); + print_line(TTR("From Anim ")+anim->get_name()+":"); for(int j=0;j<a->get_track_count();j++) { @@ -2525,7 +2525,7 @@ void EditorSceneImportPlugin::_filter_anim_tracks(Ref<Animation> anim,Set<String if (!keep.has(path)) { - print_line("Remove: "+path); + print_line(TTR("Remove: ")+path); a->remove_track(j); j--; } @@ -2639,10 +2639,10 @@ void EditorSceneImportPlugin::_filter_tracks(Node *scene, const String& p_text) for(Set<String>::Element *F=keep_local.front();F;F=F->next()) { keep.insert(F->get()); } - print_line("FILTERING ANIM: "+String(E->get())); + print_line(TTR("FILTERING ANIM: ")+String(E->get())); _filter_anim_tracks(anim->get_animation(name),keep); } else { - print_line("NOT FILTERING ANIM: "+String(E->get())); + print_line(TTR("NOT FILTERING ANIM: ")+String(E->get())); } @@ -2692,8 +2692,8 @@ Error EditorSceneImportPlugin::import2(Node *scene, const String& p_dest_path, c if (from->has_option("animation_optimizer_max_angle")) anim_optimizer_maxang=from->get_option("animation_optimizer_max_angle"); - EditorProgress progress("import","Import Scene",104); - progress.step("Importing Scene..",2); + EditorProgress progress("import",TTR("Import Scene"),104); + progress.step(TTR("Importing Scene.."),2); bool reimport = bool(from->get_option("reimport")); @@ -2726,7 +2726,7 @@ Error EditorSceneImportPlugin::import2(Node *scene, const String& p_dest_path, c /// BEFORE ANYTHING, RUN SCRIPT - progress.step("Running Custom Script..",2); + progress.step(TTR("Running Custom Script.."),2); String post_import_script_path = from->get_option("post_import_script"); Ref<EditorScenePostImport> post_import_script; @@ -2735,13 +2735,13 @@ Error EditorSceneImportPlugin::import2(Node *scene, const String& p_dest_path, c post_import_script_path = post_import_script_path; Ref<Script> scr = ResourceLoader::load(post_import_script_path); if (!scr.is_valid()) { - EditorNode::add_io_error("Couldn't load post-import script: '"+post_import_script_path); + EditorNode::add_io_error(TTR("Couldn't load post-import script: '")+post_import_script_path); } else { post_import_script = Ref<EditorScenePostImport>( memnew( EditorScenePostImport ) ); post_import_script->set_script(scr.get_ref_ptr()); if (!post_import_script->get_script_instance()) { - EditorNode::add_io_error("Invalid/Broken Script for Post-Import: '"+post_import_script_path); + EditorNode::add_io_error(TTR("Invalid/Broken Script for Post-Import: '")+post_import_script_path); post_import_script.unref(); } } @@ -2751,7 +2751,7 @@ Error EditorSceneImportPlugin::import2(Node *scene, const String& p_dest_path, c if (post_import_script.is_valid()) { scene = post_import_script->post_import(scene); if (!scene) { - EditorNode::add_io_error("Error running Post-Import script: '"+post_import_script_path); + EditorNode::add_io_error(TTR("Error running Post-Import script: '")+post_import_script_path); return err; } @@ -2780,18 +2780,18 @@ Error EditorSceneImportPlugin::import2(Node *scene, const String& p_dest_path, c String path = texture->get_path(); String fname= path.get_file(); String target_path = Globals::get_singleton()->localize_path(target_res_path.plus_file(fname)); - progress.step("Import Img: "+fname,3+(idx)*100/imagemap.size()); + progress.step(TTR("Import Img: ")+fname,3+(idx)*100/imagemap.size()); idx++; if (path==target_path) { - EditorNode::add_io_error("Can't import a file over itself: '"+target_path); + EditorNode::add_io_error(TTR("Can't import a file over itself: '")+target_path); continue; } if (!target_path.begins_with("res://")) { - EditorNode::add_io_error("Couldn't localize path: '"+target_path+"' (already local)"); + EditorNode::add_io_error(TTR("Couldn't localize path: '")+target_path+"' (already local)"); continue; } @@ -2851,7 +2851,7 @@ Error EditorSceneImportPlugin::import2(Node *scene, const String& p_dest_path, c if (import_action!=SCENE_UPDATE_REPLACE_WITH_NEW) { - progress.step("Merging..",103); + progress.step(TTR("Merging.."),103); FileAccess *fa = FileAccess::create(FileAccess::ACCESS_RESOURCES); @@ -2900,14 +2900,14 @@ Error EditorSceneImportPlugin::import2(Node *scene, const String& p_dest_path, c } - progress.step("Saving..",104); + progress.step(TTR("Saving.."),104); Ref<PackedScene> packer = memnew( PackedScene ); packer->pack(scene); packer->set_path(p_dest_path); packer->set_import_metadata(from); - print_line("SAVING TO: "+p_dest_path); + print_line(TTR("SAVING TO: ")+p_dest_path); err = ResourceSaver::save(p_dest_path,packer,ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS); //EditorFileSystem::get_singleton()->update_resource(packer); diff --git a/tools/editor/io_plugins/editor_scene_importer_fbxconv.cpp b/tools/editor/io_plugins/editor_scene_importer_fbxconv.cpp index 0c388b91ca..fadb486d20 100644 --- a/tools/editor/io_plugins/editor_scene_importer_fbxconv.cpp +++ b/tools/editor/io_plugins/editor_scene_importer_fbxconv.cpp @@ -160,7 +160,7 @@ void EditorSceneImporterFBXConv::_detect_bones_in_nodes(State& state,const Array if (d.has("isBone") && bool(d["isBone"])) { String bone_name=_id(d["id"]); - print_line("IS BONE: "+bone_name); + print_line(TTR("IS BONE: ")+bone_name); if (!state.bones.has(bone_name)) { state.bones.insert(bone_name,BoneInfo()); } @@ -367,14 +367,14 @@ Error EditorSceneImporterFBXConv::_parse_nodes(State& state,const Array &p_nodes id=_id(n["id"]); } - print_line("ID: "+id); + print_line(TTR("ID: ")+id); if (state.skeletons.has(id)) { Skeleton *skeleton = state.skeletons[id]; node=skeleton; skeleton->localize_rests(); - print_line("IS SKELETON! "); + print_line(TTR("IS SKELETON! ")); } else if (state.bones.has(id)) { if (p_base) node=p_base->cast_to<Spatial>(); @@ -507,15 +507,15 @@ void EditorSceneImporterFBXConv::_parse_materials(State& state) { if (tex.is_valid() && texture.has("type")) { String type=texture["type"]; - if (type=="DIFFUSE") + if (type==TTR("DIFFUSE")) mat->set_texture(FixedMaterial::PARAM_DIFFUSE,tex); - else if (type=="SPECULAR") + else if (type==TTR("SPECULAR")) mat->set_texture(FixedMaterial::PARAM_SPECULAR,tex); - else if (type=="SHININESS") + else if (type==TTR("SHININESS")) mat->set_texture(FixedMaterial::PARAM_SPECULAR_EXP,tex); else if (type=="NORMAL") mat->set_texture(FixedMaterial::PARAM_NORMAL,tex); - else if (type=="EMISSIVE") + else if (type==TTR("EMISSIVE")) mat->set_texture(FixedMaterial::PARAM_EMISSION,tex); } @@ -538,7 +538,7 @@ void EditorSceneImporterFBXConv::_parse_surfaces(State& state) { ERR_CONTINUE(!mesh.has("vertices")); ERR_CONTINUE(!mesh.has("parts")); - print_line("MESH #"+itos(i)); + print_line(TTR("MESH #")+itos(i)); Array attrlist=mesh["attributes"]; Array vertices=mesh["vertices"]; @@ -570,13 +570,13 @@ void EditorSceneImporterFBXConv::_parse_surfaces(State& state) { exists[Mesh::ARRAY_COLOR]=true; ofs[Mesh::ARRAY_COLOR]=stride; stride+=4; - } else if (attr=="COLORPACKED") { + } else if (attr==TTR("COLORPACKED")) { stride+=1; //ignore - } else if (attr=="TANGENT") { + } else if (attr==TTR("TANGENT")) { exists[Mesh::ARRAY_TANGENT]=true; ofs[Mesh::ARRAY_TANGENT]=stride; stride+=3; - } else if (attr=="BINORMAL") { + } else if (attr==TTR("BINORMAL")) { binormal_ofs=stride; stride+=3; } else if (attr=="TEXCOORD0") { @@ -587,10 +587,10 @@ void EditorSceneImporterFBXConv::_parse_surfaces(State& state) { exists[Mesh::ARRAY_TEX_UV2]=true; ofs[Mesh::ARRAY_TEX_UV2]=stride; stride+=2; - } else if (attr.begins_with("TEXCOORD")) { + } else if (attr.begins_with(TTR("TEXCOORD"))) { stride+=2; - } else if (attr.begins_with("BLENDWEIGHT")) { - int idx=attr.replace("BLENDWEIGHT","").to_int(); + } else if (attr.begins_with(TTR("BLENDWEIGHT"))) { + int idx=attr.replace(TTR("BLENDWEIGHT"),"").to_int(); if (idx==0) { exists[Mesh::ARRAY_BONES]=true; ofs[Mesh::ARRAY_BONES]=stride; @@ -604,7 +604,7 @@ void EditorSceneImporterFBXConv::_parse_surfaces(State& state) { stride+=2; } - print_line("ATTR "+attr+" OFS: "+itos(stride)); + print_line(TTR("ATTR ")+attr+" OFS: "+itos(stride)); } @@ -618,7 +618,7 @@ void EditorSceneImporterFBXConv::_parse_surfaces(State& state) { ERR_CONTINUE(!part.has("indices")); ERR_CONTINUE(!part.has("id")); - print_line("PART: "+String(part["id"])); + print_line(TTR("PART: ")+String(part["id"])); Array indices=part["indices"]; Map<int,int> iarray; Map<int,int> array; @@ -799,13 +799,13 @@ void EditorSceneImporterFBXConv::_parse_surfaces(State& state) { if (part.has("type")) { String type=part["type"]; - if (type=="LINES") + if (type==TTR("LINES")) pt=Mesh::PRIMITIVE_LINES; - else if (type=="POINTS") + else if (type==TTR("POINTS")) pt=Mesh::PRIMITIVE_POINTS; - else if (type=="TRIANGLE_STRIP") + else if (type==TTR("TRIANGLE_STRIP")) pt=Mesh::PRIMITIVE_TRIANGLE_STRIP; - else if (type=="LINE_STRIP") + else if (type==TTR("LINE_STRIP")) pt=Mesh::PRIMITIVE_LINE_STRIP; } @@ -903,7 +903,7 @@ Error EditorSceneImporterFBXConv::_parse_animations(State& state) { } - print_line("BONE XFD "+String(Variant(xform_dict))); + print_line(TTR("BONE XFD ")+String(Variant(xform_dict))); Array keyframes=bone_track["keyframes"]; @@ -1022,7 +1022,7 @@ Error EditorSceneImporterFBXConv::_parse_json(State& state, const String &p_path return err; } - print_line("JSON PARSED O-K!"); + print_line(TTR("JSON PARSED O-K!")); return OK; } @@ -1056,7 +1056,7 @@ Error EditorSceneImporterFBXConv::_parse_fbx(State& state,const String& p_path) } args.push_back("-o"); - args.push_back("G3DJ"); + args.push_back(TTR("G3DJ")); args.push_back(path); int res; diff --git a/tools/editor/io_plugins/editor_texture_import_plugin.cpp b/tools/editor/io_plugins/editor_texture_import_plugin.cpp index ea7242c185..f1bece83e5 100644 --- a/tools/editor/io_plugins/editor_texture_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_texture_import_plugin.cpp @@ -37,33 +37,33 @@ #include "globals.h" static const char *flag_names[]={ - "Streaming Format", - "Fix Border Alpha", - "Alpha Bit Hint", - "Compress Extra (PVRTC2)", - "No MipMaps", - "Repeat", - "Filter (Magnifying)", - "Premultiply Alpha", - "Convert SRGB->Linear", - "Convert NormalMap to XY", - "Use Anisotropy", + ("Streaming Format"), + ("Fix Border Alpha"), + ("Alpha Bit Hint"), + ("Compress Extra (PVRTC2)"), + ("No MipMaps"), + ("Repeat"), + ("Filter (Magnifying)"), + ("Premultiply Alpha"), + ("Convert SRGB->Linear"), + ("Convert NormalMap to XY"), + ("Use Anisotropy"), NULL }; #if 0 // not used static const char *flag_short_names[]={ - "Stream", - "FixBorder", - "AlphBit", - "ExtComp", - "NoMipMap", - "Repeat", - "Filter", - "PMAlpha", - "ToLinear", - "ToRG", - "Anisoropic", + TTR("Stream"), + TTR("FixBorder"), + TTR("AlphBit"), + TTR("ExtComp"), + TTR("NoMipMap"), + TTR("Repeat"), + TTR("Filter"), + TTR("PMAlpha"), + TTR("ToLinear"), + TTR("ToRG"), + TTR("Anisoropic"), NULL }; #endif @@ -173,13 +173,13 @@ EditorImportTextureOptions::EditorImportTextureOptions() { updating=false; format = memnew( OptionButton ); - format->add_item("Uncompressed",EditorTextureImportPlugin::IMAGE_FORMAT_UNCOMPRESSED); - format->add_item("Compress Lossless (PNG)",EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_DISK_LOSSLESS); - format->add_item("Compress Lossy (WebP)",EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_DISK_LOSSY); - format->add_item("Compress (VRAM)",EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_RAM); + format->add_item(TTR("Uncompressed"),EditorTextureImportPlugin::IMAGE_FORMAT_UNCOMPRESSED); + format->add_item(TTR("Compress Lossless (PNG)"),EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_DISK_LOSSLESS); + format->add_item(TTR("Compress Lossy (WebP)"),EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_DISK_LOSSY); + format->add_item(TTR("Compress (VRAM)"),EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_RAM); - add_margin_child("Texture Format",format); + add_margin_child(TTR("Texture Format"),format); quality_vb = memnew( VBoxContainer ); @@ -199,7 +199,7 @@ EditorImportTextureOptions::EditorImportTextureOptions() { hs->set_step(0.01); hs->set_val(0.7); quality=hs; - quality_vb->add_margin_child("Texture Compression Quality (WebP):",quality_hb); + quality_vb->add_margin_child(TTR("Texture Compression Quality (WebP):"),quality_hb); add_child(quality_vb); @@ -221,10 +221,10 @@ EditorImportTextureOptions::EditorImportTextureOptions() { fname++; } - add_margin_child("Texture Options",flags,true); + add_margin_child(TTR("Texture Options"),flags,true); notice_for_2d = memnew( Label ); - notice_for_2d->set_text("NOTICE: You are not forced to import textures for 2D projects. Just copy your .jpg or .png files to your project, and change export options later. Atlases can be generated on export too."); + notice_for_2d->set_text(TTR("NOTICE: You are not forced to import textures for 2D projects. Just copy your .jpg or .png files to your project, and change export options later. Atlases can be generated on export too.")); notice_for_2d->set_custom_minimum_size(Size2(0,50)); notice_for_2d->set_autowrap(true); add_child(notice_for_2d); @@ -329,7 +329,7 @@ void EditorTextureImportDialog::_import() { if (!files.size()) { - error_dialog->set_text("Please specify some files!"); + error_dialog->set_text(TTR("Please specify some files!")); error_dialog->popup_centered(Size2(200,100)); return; } @@ -337,20 +337,20 @@ void EditorTextureImportDialog::_import() { String dst_path=save_path->get_text(); if (save_path->get_text().strip_edges()=="") { - error_dialog->set_text("Target path is empty."); + error_dialog->set_text(TTR("Target path is empty.")); error_dialog->popup_centered_minsize(); return; } if (!save_path->get_text().begins_with("res://")) { - error_dialog->set_text("Target path must be full resource path."); + error_dialog->set_text(TTR("Target path must be full resource path.")); error_dialog->popup_centered_minsize(); return; } if (!atlas && !large && !DirAccess::exists(save_path->get_text())) { - error_dialog->set_text("Target path must exist."); + error_dialog->set_text(TTR("Target path must exist.")); error_dialog->popup_centered_minsize(); return; } @@ -359,7 +359,7 @@ void EditorTextureImportDialog::_import() { if (files.size()==0) { - error_dialog->set_text("At least one file needed for Atlas."); + error_dialog->set_text(TTR("At least one file needed for Atlas.")); error_dialog->popup_centered(Size2(200,100)); return; @@ -382,7 +382,7 @@ void EditorTextureImportDialog::_import() { Error err = plugin->import(dst_file,imd); if (err) { - error_dialog->set_text("Error importing: "+dst_file.get_file()); + error_dialog->set_text(TTR("Error importing: ")+dst_file.get_file()); error_dialog->popup_centered(Size2(200,100)); return; @@ -391,7 +391,7 @@ void EditorTextureImportDialog::_import() { if (files.size()!=1) { - error_dialog->set_text("Only one file is required for large texture"); + error_dialog->set_text(TTR("Only one file is required for large texture")); error_dialog->popup_centered(Size2(200,100)); return; @@ -414,7 +414,7 @@ void EditorTextureImportDialog::_import() { Error err = plugin->import(dst_file,imd); if (err) { - error_dialog->set_text("Error importing: "+dst_file.get_file()); + error_dialog->set_text(TTR("Error importing: ")+dst_file.get_file()); error_dialog->popup_centered(Size2(200,100)); return; @@ -438,7 +438,7 @@ void EditorTextureImportDialog::_import() { Error err = plugin->import(dst_file,imd); if (err) { - error_dialog->set_text("Error importing: "+dst_file.get_file()); + error_dialog->set_text(TTR("Error importing: ")+dst_file.get_file()); error_dialog->popup_centered(Size2(200,100)); return; @@ -499,7 +499,7 @@ void EditorTextureImportDialog::_notification(int p_what) { List<String> extensions; ImageLoader::get_recognized_extensions(&extensions); - // ResourceLoader::get_recognized_extensions_for_type("PackedTexture",&extensions); + // ResourceLoader::get_recognized_extensions_for_type(TTR("PackedTexture"),&extensions); file_select->clear_filters(); for(int i=0;i<extensions.size();i++) { @@ -536,7 +536,7 @@ EditorTextureImportDialog::EditorTextureImportDialog(EditorTextureImportPlugin* atlas=p_atlas; large=p_large; plugin=p_plugin; - set_title("Import Textures"); + set_title(TTR("Import Textures")); VBoxContainer *vbc = memnew(VBoxContainer); @@ -546,9 +546,9 @@ EditorTextureImportDialog::EditorTextureImportDialog(EditorTextureImportPlugin* VBoxContainer *source_vb=memnew(VBoxContainer); if (large) - vbc->add_margin_child("Source Texture:",source_vb); + vbc->add_margin_child(TTR("Source Texture:"),source_vb); else - vbc->add_margin_child("Source Texture(s):",source_vb); + vbc->add_margin_child(TTR("Source Texture(s):"),source_vb); HBoxContainer *hbc = memnew( HBoxContainer ); source_vb->add_child(hbc); @@ -559,7 +559,7 @@ EditorTextureImportDialog::EditorTextureImportDialog(EditorTextureImportPlugin* crop_source = memnew( CheckButton ); crop_source->set_pressed(true); source_vb->add_child(crop_source); - crop_source->set_text("Crop empty space."); + crop_source->set_text(TTR("Crop empty space.")); if (!p_atlas) crop_source->hide(); @@ -571,7 +571,7 @@ EditorTextureImportDialog::EditorTextureImportDialog(EditorTextureImportPlugin* import_choose->connect("pressed", this,"_browse"); hbc = memnew( HBoxContainer ); - vbc->add_margin_child("Target Path:",hbc); + vbc->add_margin_child(TTR("Target Path:"),hbc); size = memnew( SpinBox ); size->set_min(128); @@ -579,10 +579,10 @@ EditorTextureImportDialog::EditorTextureImportDialog(EditorTextureImportPlugin* if (p_atlas) { size->set_val(2048); - vbc->add_margin_child("Max Texture size:",size); + vbc->add_margin_child(TTR("Max Texture size:"),size); } else { size->set_val(256); - vbc->add_margin_child("Cell Size:",size); + vbc->add_margin_child(TTR("Cell Size:"),size); } @@ -624,7 +624,7 @@ EditorTextureImportDialog::EditorTextureImportDialog(EditorTextureImportPlugin* save_select->connect("dir_selected", this,"_choose_save_dir"); get_ok()->connect("pressed", this,"_import"); - get_ok()->set_text("Import"); + get_ok()->set_text(TTR("Import")); //move stuff up //for(int i=0;i<4;i++) @@ -632,7 +632,7 @@ EditorTextureImportDialog::EditorTextureImportDialog(EditorTextureImportPlugin* error_dialog = memnew ( ConfirmationDialog ); add_child(error_dialog); - error_dialog->get_ok()->set_text("Accept"); + error_dialog->get_ok()->set_text(TTR("Accept")); // error_dialog->get_cancel()->hide(); set_hide_on_ok(false); @@ -647,14 +647,14 @@ EditorTextureImportDialog::EditorTextureImportDialog(EditorTextureImportPlugin* texture_options->set_quality(0.7); texture_options->set_format(EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_DISK_LOSSY); //texture_options->show_2d_notice(); - set_title("Import Textures for Atlas (2D)"); + set_title(TTR("Import Textures for Atlas (2D)")); } else if (large) { texture_options->set_flags(EditorTextureImportPlugin::IMAGE_FLAG_FIX_BORDER_ALPHA|EditorTextureImportPlugin::IMAGE_FLAG_NO_MIPMAPS|EditorTextureImportPlugin::IMAGE_FLAG_FILTER); texture_options->set_quality(0.7); texture_options->set_format(EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_DISK_LOSSLESS); texture_options->show_2d_notice(); - set_title("Import Large Textures (2D)"); + set_title(TTR("Import Large Textures (2D)")); } else if (p_2d) { @@ -662,14 +662,14 @@ EditorTextureImportDialog::EditorTextureImportDialog(EditorTextureImportPlugin* texture_options->set_quality(0.7); texture_options->set_format(EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_DISK_LOSSY); texture_options->show_2d_notice(); - set_title("Import Textures for 2D"); + set_title(TTR("Import Textures for 2D")); } else { //texture_options->set_flags(EditorTextureImportPlugin::IMAGE_FLAG_); //texture_options->set_flags(EditorTextureImportPlugin::IMAGE_FLAG_NO_MIPMAPS); texture_options->set_flags(EditorTextureImportPlugin::IMAGE_FLAG_FIX_BORDER_ALPHA|EditorTextureImportPlugin::IMAGE_FLAG_FILTER|EditorTextureImportPlugin::IMAGE_FLAG_REPEAT); texture_options->set_format(EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_RAM); - set_title("Import Textures for 3D"); + set_title(TTR("Import Textures for 3D")); } @@ -918,7 +918,7 @@ Error EditorTextureImportPlugin::_process_texture_data(Ref<ImageTexture> &textur //if ((image.get_format()==Image::FORMAT_RGB || image.get_format()==Image::FORMAT_RGBA) && flags&IMAGE_FLAG_CONVERT_TO_LINEAR) { // - // print_line("CONVERT BECAUSE: "+itos(flags)); + // print_line(TTR("CONVERT BECAUSE: ")+itos(flags)); // image.srgb_to_linear(); //} @@ -1000,16 +1000,16 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc int cell_size=from->get_option("large_cell_size"); ERR_FAIL_COND_V(cell_size<128 || cell_size>16384,ERR_CANT_OPEN); - EditorProgress pg("ltex","Import Large Texture",3); + EditorProgress pg("ltex",TTR("Import Large Texture"),3); - pg.step("Load Source Image",0); + pg.step(TTR("Load Source Image"),0); Image img; Error err = ImageLoader::load_image(src_path,&img); if (err) { return err; } - pg.step("Slicing",1); + pg.step(TTR("Slicing"),1); Map<Vector2,Image> pieces; for(int i=0;i<img.get_width();i+=cell_size) { @@ -1021,7 +1021,7 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc piece.blit_rect(img,Rect2(i,j,w,h),Point2(0,0)); if (!piece.is_invisible()) { pieces[Vector2(i,j)]=piece; - //print_line("ADDING PIECE AT "+Vector2(i,j)); + //print_line(TTR("ADDING PIECE AT ")+Vector2(i,j)); } } } @@ -1038,7 +1038,7 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc } existing->set_size(Size2(img.get_width(),img.get_height())); - pg.step("Inserting",2); + pg.step(TTR("Inserting"),2); for (Map<Vector2,Image>::Element *E=pieces.front();E;E=E->next()) { @@ -1053,11 +1053,11 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc existing->set_path(p_path); existing->set_import_metadata(from); } - pg.step("Saving",3); + pg.step(TTR("Saving"),3); err = ResourceSaver::save(p_path,existing); if (err!=OK) { - EditorNode::add_io_error("Couldn't save large texture: "+p_path); + EditorNode::add_io_error(TTR("Couldn't save large texture: ")+p_path); return err; } @@ -1072,7 +1072,7 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc bool alpha=false; bool crop = from->get_option("crop"); - EditorProgress ep("make_atlas","Build Atlas For: "+p_path.get_file(),from->get_source_count()+3); + EditorProgress ep("make_atlas",TTR("Build Atlas For: ")+p_path.get_file(),from->get_source_count()+3); print_line("sources: "+itos(from->get_source_count())); @@ -1081,12 +1081,12 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc String path = EditorImportPlugin::expand_source_path(from->get_source_path(i)); String md5 = FileAccess::get_md5(path); from->set_source_md5(i,FileAccess::get_md5(path)); - ep.step("Loading Image: "+path,i); + ep.step(TTR("Loading Image: ")+path,i); print_line("source path: "+path+" md5 "+md5); Image src; Error err = ImageLoader::load_image(path,&src); if (err) { - EditorNode::add_io_error("Couldn't load image: "+path); + EditorNode::add_io_error(TTR("Couldn't load image: ")+path); return err; } @@ -1095,7 +1095,7 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc tsources.push_back(src); } - ep.step("Converting Images",sources.size()); + ep.step(TTR("Converting Images"),sources.size()); int base_index=0; @@ -1131,7 +1131,7 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc if (source_md5.has(*cmp)) { int sidx=source_md5[*cmp]; source_map[sidx].push_back(i); - print_line("REUSING "+from->get_source_path(i)); + print_line(TTR("REUSING ")+from->get_source_path(i)); } else { int sidx=sources.size(); @@ -1154,14 +1154,14 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc Vector<Size2i> src_sizes; Vector<Rect2> crops; - ep.step("Cropping Images",sources.size()+1); + ep.step(TTR("Cropping Images"),sources.size()+1); for(int j=0;j<sources.size();j++) { Size2i s; if (crop) { Rect2 crop = sources[j].get_used_rect(); - print_line("CROP: "+crop); + print_line(TTR("CROP: ")+crop); s=crop.size; crops.push_back(crop); } else { @@ -1178,7 +1178,7 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc print_line("size that workeD: "+itos(dst_size.width)+","+itos(dst_size.height)); - ep.step("Blitting Images",sources.size()+2); + ep.step(TTR("Blitting Images"),sources.size()+2); bool blit_to_po2=tex_flags&Texture::FLAG_MIPMAPS; int atlas_w=dst_size.width; @@ -1231,7 +1231,7 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc at->set_margin(margin); at->set_path(apath); atlases[E->get()]=at; - print_line("Atlas Tex: "+apath); + print_line(TTR("Atlas Tex: ")+apath); } } if (ResourceCache::has(p_path)) { @@ -1291,7 +1291,7 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc atlases[i]->set_atlas(texture); Error err = ResourceSaver::save(apath,atlases[i]); if (err) { - EditorNode::add_io_error("Couldn't save atlas image: "+apath); + EditorNode::add_io_error(TTR("Couldn't save atlas image: ")+apath); return err; } //from->set_source_md5(i,FileAccess::get_md5(apath)); @@ -1391,7 +1391,7 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc //if ((image.get_format()==Image::FORMAT_RGB || image.get_format()==Image::FORMAT_RGBA) && flags&IMAGE_FLAG_CONVERT_TO_LINEAR) { // - // print_line("CONVERT BECAUSE: "+itos(flags)); + // print_line(TTR("CONVERT BECAUSE: ")+itos(flags)); // image.srgb_to_linear(); //} @@ -1433,7 +1433,7 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc Error err = ResourceSaver::save(p_path,texture,save_flags); if (err!=OK) { - EditorNode::add_io_error("Couldn't save converted texture: "+p_path); + EditorNode::add_io_error(TTR("Couldn't save converted texture: ")+p_path); return err; } diff --git a/tools/editor/io_plugins/editor_translation_import_plugin.cpp b/tools/editor/io_plugins/editor_translation_import_plugin.cpp index 1edfe697b6..03abc3a82b 100644 --- a/tools/editor/io_plugins/editor_translation_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_translation_import_plugin.cpp @@ -64,7 +64,7 @@ public: FileAccess *f = FileAccess::open(p_path,FileAccess::READ); if (!f) { - error_dialog->set_text("Invalid source!"); + error_dialog->set_text(TTR("Invalid source!")); error_dialog->popup_centered(Size2(200,100)); return; @@ -75,7 +75,7 @@ public: if (csvh.size()<2) { - error_dialog->set_text("Invalid translation source!"); + error_dialog->set_text(TTR("Invalid translation source!")); error_dialog->popup_centered(Size2(200,100)); return; @@ -86,8 +86,8 @@ public: TreeItem *root = columns->create_item(); columns->set_hide_root(true); columns->set_column_titles_visible(true); - columns->set_column_title(0,"Column"); - columns->set_column_title(1,"Language"); + columns->set_column_title(0,TTR("Column")); + columns->set_column_title(1,TTR("Language")); Vector<String> langs = TranslationServer::get_all_locales(); Vector<String> names = TranslationServer::get_all_locale_names(); if (csvh[0]=="") @@ -231,16 +231,16 @@ public: if (items.size()==0) { - error_dialog->set_text("No items to import!"); + error_dialog->set_text(TTR("No items to import!")); error_dialog->popup_centered(Size2(200,100)); } if (!save_path->get_text().begins_with("res://")) { - error_dialog->set_text("No target path!!"); + error_dialog->set_text(TTR("No target path!!")); error_dialog->popup_centered(Size2(200,100)); } - EditorProgress progress("import_xl","Import Translations",items.size()); + EditorProgress progress("import_xl",TTR("Import Translations"),items.size()); for(int i=0;i<items.size();i++) { progress.step(items[i]->get_metadata(1),i); @@ -258,7 +258,7 @@ public: String savefile = save_path->get_text().plus_file(import_path->get_text().get_file().basename()+"."+locale+".xl"); Error err = plugin->import(savefile,imd); if (err!=OK) { - error_dialog->set_text("Couldnt import!"); + error_dialog->set_text(TTR("Couldnt import!")); error_dialog->popup_centered(Size2(200,100)); } else if (add_to_project->is_pressed()) { @@ -295,7 +295,7 @@ public: plugin=p_plugin; - set_title("Import Translation"); + set_title(TTR("Import Translation")); VBoxContainer *vbc = memnew( VBoxContainer ); add_child(vbc); @@ -307,13 +307,13 @@ public: HBoxContainer *hbc = memnew( HBoxContainer ); csvb->add_child(hbc); - vbc->add_margin_child("Source CSV:",csvb); + vbc->add_margin_child(TTR("Source CSV:"),csvb); import_path = memnew( LineEdit ); import_path->set_h_size_flags(SIZE_EXPAND_FILL); hbc->add_child(import_path); ignore_first = memnew( CheckButton ); - ignore_first->set_text("Ignore First Row"); + ignore_first->set_text(TTR("Ignore First Row")); csvb->add_child(ignore_first); Button * import_choose = memnew( Button ); @@ -325,7 +325,7 @@ public: VBoxContainer *tcomp = memnew( VBoxContainer); hbc = memnew( HBoxContainer ); tcomp->add_child(hbc); - vbc->add_margin_child("Target Path:",tcomp); + vbc->add_margin_child(TTR("Target Path:"),tcomp); save_path = memnew( LineEdit ); save_path->set_h_size_flags(SIZE_EXPAND_FILL); @@ -339,12 +339,12 @@ public: compress = memnew( CheckButton); compress->set_pressed(true); - compress->set_text("Compress"); + compress->set_text(TTR("Compress")); tcomp->add_child(compress); add_to_project = memnew( CheckButton); add_to_project->set_pressed(true); - add_to_project->set_text("Add to Project (engine.cfg)"); + add_to_project->set_text(TTR("Add to Project (engine.cfg)")); tcomp->add_child(add_to_project); file_select = memnew(EditorFileDialog); @@ -360,18 +360,18 @@ public: save_select->connect("dir_selected", this,"_choose_save_dir"); get_ok()->connect("pressed", this,"_import"); - get_ok()->set_text("Import"); + get_ok()->set_text(TTR("Import")); error_dialog = memnew ( ConfirmationDialog ); add_child(error_dialog); - error_dialog->get_ok()->set_text("Accept"); + error_dialog->get_ok()->set_text(TTR("Accept")); // error_dialog->get_cancel()->hide(); set_hide_on_ok(false); columns = memnew( Tree ); - vbc->add_margin_child("Import Languages:",columns,true); + vbc->add_margin_child(TTR("Import Languages:"),columns,true); } ~EditorTranslationImportDialog() { diff --git a/tools/editor/multi_node_edit.cpp b/tools/editor/multi_node_edit.cpp index cfa998bee9..54697d41ab 100644 --- a/tools/editor/multi_node_edit.cpp +++ b/tools/editor/multi_node_edit.cpp @@ -9,7 +9,7 @@ bool MultiNodeEdit::_set(const StringName& p_name, const Variant& p_value){ UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo(); - ur->create_action("MultiNode Set "+String(p_name)); + ur->create_action(TTR("MultiNode Set ")+String(p_name)); for (const List<NodePath>::Element *E=nodes.front();E;E=E->next()) { if (!es->has_node(E->get())) diff --git a/tools/editor/plugins/animation_player_editor_plugin.cpp b/tools/editor/plugins/animation_player_editor_plugin.cpp index da7c083c5a..745266e19a 100644 --- a/tools/editor/plugins/animation_player_editor_plugin.cpp +++ b/tools/editor/plugins/animation_player_editor_plugin.cpp @@ -144,7 +144,7 @@ void AnimationPlayerEditor::_autoplay_pressed() { String current = animation->get_item_text( animation->get_selected() ); if (player->get_autoplay()==current) { //unset - undo_redo->create_action("Toggle Autoplay"); + undo_redo->create_action(TTR("Toggle Autoplay")); undo_redo->add_do_method(player,"set_autoplay",""); undo_redo->add_undo_method(player,"set_autoplay",player->get_autoplay()); undo_redo->add_do_method(this,"_animation_player_changed",player); @@ -154,7 +154,7 @@ void AnimationPlayerEditor::_autoplay_pressed() { } else { //set - undo_redo->create_action("Toggle Autoplay"); + undo_redo->create_action(TTR("Toggle Autoplay")); undo_redo->add_do_method(player,"set_autoplay",current); undo_redo->add_undo_method(player,"set_autoplay",player->get_autoplay()); undo_redo->add_do_method(this,"_animation_player_changed",player); @@ -317,10 +317,10 @@ void AnimationPlayerEditor::_animation_selected(int p_which) { void AnimationPlayerEditor::_animation_new() { renaming=false; - name_title->set_text("New Animation Name:"); + name_title->set_text(TTR("New Animation Name:")); int count=1; - String base="New Anim"; + String base=TTR("New Anim"); while(true) { String attempt = base; if (count>1) @@ -345,7 +345,7 @@ void AnimationPlayerEditor::_animation_rename() { int selected = animation->get_selected(); String selected_name = animation->get_item_text(selected); - name_title->set_text("Change Animation Name:"); + name_title->set_text(TTR("Change Animation Name:")); name->set_text(selected_name); renaming=true; name_dialog->popup_centered(Size2(300,90)); @@ -383,7 +383,7 @@ void AnimationPlayerEditor::_animation_save_in_path(const Ref<Resource>& p_resou Error err = ResourceSaver::save(path, p_resource, flg | ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS); if (err != OK) { - accept->set_text("Error saving resource!"); + accept->set_text(TTR("Error saving resource!")); accept->popup_centered_minsize(); return; } @@ -437,7 +437,7 @@ void AnimationPlayerEditor::_animation_save_as(const Ref<Resource>& p_resource) } file->popup_centered_ratio(); - file->set_title("Save Resource As.."); + file->set_title(TTR("Save Resource As..")); current_option = RESOURCE_SAVE; } void AnimationPlayerEditor::_animation_remove() { @@ -449,7 +449,7 @@ void AnimationPlayerEditor::_animation_remove() { Ref<Animation> anim = player->get_animation(current); - undo_redo->create_action("Remove Animation"); + undo_redo->create_action(TTR("Remove Animation")); undo_redo->add_do_method(player,"remove_animation",current); undo_redo->add_undo_method(player,"add_animation",current,anim); undo_redo->add_do_method(this,"_animation_player_changed",player); @@ -485,7 +485,7 @@ void AnimationPlayerEditor::_animation_name_edited() { String new_name = name->get_text(); if (new_name=="" || new_name.find(":")!=-1 || new_name.find("/")!=-1) { - error_dialog->set_text("ERROR: Invalid animation name!"); + error_dialog->set_text(TTR("ERROR: Invalid animation name!")); error_dialog->popup_centered_minsize(); return; } @@ -496,7 +496,7 @@ void AnimationPlayerEditor::_animation_name_edited() { } if (player->has_animation(new_name)) { - error_dialog->set_text("ERROR: Animation Name Already Exists!"); + error_dialog->set_text(TTR("ERROR: Animation Name Already Exists!")); error_dialog->popup_centered_minsize(); return; } @@ -505,7 +505,7 @@ void AnimationPlayerEditor::_animation_name_edited() { String current = animation->get_item_text(animation->get_selected()); Ref<Animation> anim = player->get_animation(current); - undo_redo->create_action("Rename Animation"); + undo_redo->create_action(TTR("Rename Animation")); undo_redo->add_do_method(player,"rename_animation",current,new_name); undo_redo->add_do_method(anim.ptr(),"set_name",new_name); undo_redo->add_undo_method(player,"rename_animation",new_name,current); @@ -521,7 +521,7 @@ void AnimationPlayerEditor::_animation_name_edited() { Ref<Animation> new_anim = Ref<Animation>(memnew( Animation )); new_anim->set_name(new_name); - undo_redo->create_action("Add Animation"); + undo_redo->create_action(TTR("Add Animation")); undo_redo->add_do_method(player,"add_animation",new_name,new_anim); undo_redo->add_undo_method(player,"remove_animation",new_name); undo_redo->add_do_method(this,"_animation_player_changed",player); @@ -605,7 +605,7 @@ void AnimationPlayerEditor::_blend_edited() { float blend_time = selected->get_range(1); float prev_blend_time = player->get_blend_time(current,to); - undo_redo->create_action("Change Blend Time"); + undo_redo->create_action(TTR("Change Blend Time")); undo_redo->add_do_method(player,"set_blend_time",current,to,blend_time); undo_redo->add_undo_method(player,"set_blend_time",current,to,prev_blend_time); undo_redo->add_do_method(this,"_animation_player_changed",player); @@ -717,7 +717,7 @@ void AnimationPlayerEditor::_dialog_action(String p_file) { if (p_file.find(".") != -1) p_file = p_file.substr(0, p_file.find(".")); - undo_redo->create_action("Load Animation"); + undo_redo->create_action(TTR("Load Animation")); undo_redo->add_do_method(player, "add_animation", p_file, res); undo_redo->add_undo_method(player, "remove_animation", p_file); if (player->has_animation(p_file)) { @@ -910,7 +910,7 @@ void AnimationPlayerEditor::_animation_duplicate() { } - undo_redo->create_action("Duplicate Animation"); + undo_redo->create_action(TTR("Duplicate Animation")); undo_redo->add_do_method(player,"add_animation",new_name,new_anim); undo_redo->add_undo_method(player,"remove_animation",new_name); undo_redo->add_do_method(this,"_animation_player_changed",player); @@ -1000,7 +1000,7 @@ void AnimationPlayerEditor::_editor_store() { return; //already there - undo_redo->create_action("Store anim in editor"); + undo_redo->create_action(TTR("Store anim in editor")); undo_redo->add_do_method(key_editor,"set_animation",anim); undo_redo->add_undo_method(key_editor,"remove_animation",anim); undo_redo->commit_action(); @@ -1022,7 +1022,7 @@ void AnimationPlayerEditor::_editor_load(){ String base=anim->get_name(); bool noname=false; if (base=="") { - base="New Anim"; + base=TTR("New Anim"); noname=true; } @@ -1041,7 +1041,7 @@ void AnimationPlayerEditor::_editor_load(){ if (noname) anim->set_name(base); - undo_redo->create_action("Add Animation From Editor"); + undo_redo->create_action(TTR("Add Animation From Editor")); undo_redo->add_do_method(player,"add_animation",base,anim); undo_redo->add_undo_method(player,"remove_animation",base); undo_redo->add_do_method(this,"_animation_player_changed",player); @@ -1108,7 +1108,7 @@ void AnimationPlayerEditor::_animation_tool_menu(int p_option) { case TOOL_COPY_ANIM: { if (!animation->get_item_count()) { - error_dialog->set_text("ERROR: No animation to copy!"); + error_dialog->set_text(TTR("ERROR: No animation to copy!")); error_dialog->popup_centered_minsize(); return; } @@ -1123,14 +1123,14 @@ void AnimationPlayerEditor::_animation_tool_menu(int p_option) { Ref<Animation> anim = EditorSettings::get_singleton()->get_resource_clipboard(); if (!anim.is_valid()) { - error_dialog->set_text("ERROR: No animation resource on clipboard!"); + error_dialog->set_text(TTR("ERROR: No animation resource on clipboard!")); error_dialog->popup_centered_minsize(); return; } String name = anim->get_name(); if (name=="") { - name="Pasted Animation"; + name=TTR("Pasted Animation"); } int idx=1; @@ -1141,7 +1141,7 @@ void AnimationPlayerEditor::_animation_tool_menu(int p_option) { name=base+" "+itos(idx); } - undo_redo->create_action("Paste Animation"); + undo_redo->create_action(TTR("Paste Animation")); undo_redo->add_do_method(player,"add_animation",name,anim); undo_redo->add_undo_method(player,"remove_animation",name); undo_redo->add_do_method(this,"_animation_player_changed",player); @@ -1155,7 +1155,7 @@ void AnimationPlayerEditor::_animation_tool_menu(int p_option) { case TOOL_EDIT_RESOURCE: { if (!animation->get_item_count()) { - error_dialog->set_text("ERROR: No animation to edit!"); + error_dialog->set_text(TTR("ERROR: No animation to edit!")); error_dialog->popup_centered_minsize(); return; } @@ -1276,7 +1276,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) { Label * l; /*l= memnew( Label ); - l->set_text("Animation Player:"); + l->set_text(TTR("Animation Player:")); add_child(l);*/ HBoxContainer *hb = memnew( HBoxContainer ); @@ -1284,25 +1284,25 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) { play_bw_from = memnew( ToolButton ); - play_bw_from->set_tooltip("Play backwards selected animation from current pos. (A)"); + play_bw_from->set_tooltip(TTR("Play backwards selected animation from current pos. (A)")); hb->add_child(play_bw_from); play_bw = memnew( ToolButton ); - play_bw->set_tooltip("Play backwards selected animation from end. (Shift+A)"); + play_bw->set_tooltip(TTR("Play backwards selected animation from end. (Shift+A)")); hb->add_child(play_bw); stop = memnew( ToolButton ); stop->set_toggle_mode(true); hb->add_child(stop); - stop->set_tooltip("Stop animation playback. (S)"); + stop->set_tooltip(TTR("Stop animation playback. (S)")); play = memnew( ToolButton ); - play->set_tooltip("Play selected animation from start. (Shift+D)"); + play->set_tooltip(TTR("Play selected animation from start. (Shift+D)")); hb->add_child(play); play_from = memnew( ToolButton ); - play_from->set_tooltip("Play selected animation from current pos. (D)"); + play_from->set_tooltip(TTR("Play selected animation from current pos. (D)")); hb->add_child(play_from); @@ -1315,7 +1315,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) { hb->add_child(frame); frame->set_custom_minimum_size(Size2(60,0)); frame->set_stretch_ratio(2); - frame->set_tooltip("Animation position (in seconds)."); + frame->set_tooltip(TTR("Animation position (in seconds).")); hb->add_child( memnew( VSeparator)); @@ -1323,24 +1323,24 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) { hb->add_child(scale); scale->set_h_size_flags(SIZE_EXPAND_FILL); scale->set_stretch_ratio(1); - scale->set_tooltip("Scale animation playback globally for the node."); + scale->set_tooltip(TTR("Scale animation playback globally for the node.")); scale->hide(); add_anim = memnew( ToolButton ); - add_anim->set_tooltip("Create new animation in player."); + add_anim->set_tooltip(TTR("Create new animation in player.")); hb->add_child(add_anim); load_anim = memnew( ToolButton ); - load_anim->set_tooltip("Load an animation from disk."); + load_anim->set_tooltip(TTR("Load an animation from disk.")); hb->add_child(load_anim); save_anim = memnew(MenuButton); - save_anim->set_tooltip("Save the current animation"); - save_anim->get_popup()->add_item("Save", ANIM_SAVE); - save_anim->get_popup()->add_item("Save As..", ANIM_SAVE_AS); + save_anim->set_tooltip(TTR("Save the current animation")); + save_anim->get_popup()->add_item(TTR("Save"), ANIM_SAVE); + save_anim->get_popup()->add_item(TTR("Save As.."), ANIM_SAVE_AS); save_anim->set_focus_mode(Control::FOCUS_NONE); hb->add_child(save_anim); @@ -1350,40 +1350,40 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) { duplicate_anim = memnew( ToolButton ); hb->add_child(duplicate_anim); - duplicate_anim->set_tooltip("Duplicate Animation"); + duplicate_anim->set_tooltip(TTR("Duplicate Animation")); rename_anim = memnew( ToolButton ); hb->add_child(rename_anim); - rename_anim->set_tooltip("Rename Animation"); + rename_anim->set_tooltip(TTR("Rename Animation")); remove_anim = memnew( ToolButton ); hb->add_child(remove_anim); - remove_anim->set_tooltip("Remove Animation"); + remove_anim->set_tooltip(TTR("Remove Animation")); animation = memnew( OptionButton ); hb->add_child(animation); animation->set_h_size_flags(SIZE_EXPAND_FILL); - animation->set_tooltip("Display list of animations in player."); + animation->set_tooltip(TTR("Display list of animations in player.")); autoplay = memnew( ToolButton ); hb->add_child(autoplay); - autoplay->set_tooltip("Autoplay On Load"); + autoplay->set_tooltip(TTR("Autoplay On Load")); blend_anim = memnew( ToolButton ); hb->add_child(blend_anim); - blend_anim->set_tooltip("Edit Target Blend Times"); + blend_anim->set_tooltip(TTR("Edit Target Blend Times")); tool_anim = memnew( MenuButton); //tool_anim->set_flat(false); - tool_anim->set_tooltip("Animation Tools"); - tool_anim->get_popup()->add_item("Copy Animation",TOOL_COPY_ANIM); - tool_anim->get_popup()->add_item("Paste Animation",TOOL_PASTE_ANIM); + tool_anim->set_tooltip(TTR("Animation Tools")); + tool_anim->get_popup()->add_item(TTR("Copy Animation"),TOOL_COPY_ANIM); + tool_anim->get_popup()->add_item(TTR("Paste Animation"),TOOL_PASTE_ANIM); //tool_anim->get_popup()->add_separator(); - //tool_anim->get_popup()->add_item("Edit Anim Resource",TOOL_PASTE_ANIM); + //tool_anim->get_popup()->add_item(TTR("Edit Anim Resource"),TOOL_PASTE_ANIM); hb->add_child(tool_anim); nodename = memnew( Button ); @@ -1403,7 +1403,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) { add_child(file); name_dialog = memnew( ConfirmationDialog ); - name_dialog->set_title("Create New Animation"); + name_dialog->set_title(TTR("Create New Animation")); name_dialog->set_hide_on_ok(false); add_child(name_dialog); name = memnew( LineEdit ); @@ -1414,33 +1414,33 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) { l = memnew( Label ); - l->set_text("Animation Name:"); + l->set_text(TTR("Animation Name:")); l->set_pos( Point2(10,10) ); name_dialog->add_child(l); name_title=l; error_dialog = memnew( ConfirmationDialog ); - error_dialog->get_ok()->set_text("Close"); - //error_dialog->get_cancel()->set_text("Close"); - error_dialog->set_text("Error!"); + error_dialog->get_ok()->set_text(TTR("Close")); + //error_dialog->get_cancel()->set_text(TTR("Close")); + error_dialog->set_text(TTR("Error!")); add_child(error_dialog); name_dialog->connect("confirmed", this,"_animation_name_edited"); blend_editor.dialog = memnew( AcceptDialog ); add_child(blend_editor.dialog); - blend_editor.dialog->get_ok()->set_text("Close"); + blend_editor.dialog->get_ok()->set_text(TTR("Close")); blend_editor.dialog->set_hide_on_ok(true); VBoxContainer *blend_vb = memnew( VBoxContainer); blend_editor.dialog->add_child(blend_vb); blend_editor.dialog->set_child_rect(blend_vb); blend_editor.tree = memnew( Tree ); blend_editor.tree->set_columns(2); - blend_vb->add_margin_child("Blend Times: ",blend_editor.tree,true); + blend_vb->add_margin_child(TTR("Blend Times: "),blend_editor.tree,true); blend_editor.next = memnew( LineEdit ); - blend_vb->add_margin_child("Next (Auto Queue):",blend_editor.next); - blend_editor.dialog->set_title("Cross-Animation Blend Times"); + blend_vb->add_margin_child(TTR("Next (Auto Queue):"),blend_editor.next); + blend_editor.dialog->set_title(TTR("Cross-Animation Blend Times")); updating_blends=false; blend_editor.tree->connect("item_edited",this,"_blend_edited"); diff --git a/tools/editor/plugins/animation_player_editor_plugin.h b/tools/editor/plugins/animation_player_editor_plugin.h index 0ad849c2f9..5f3c8ec49b 100644 --- a/tools/editor/plugins/animation_player_editor_plugin.h +++ b/tools/editor/plugins/animation_player_editor_plugin.h @@ -203,7 +203,7 @@ public: virtual Dictionary get_state() const { return anim_editor->get_state(); } virtual void set_state(const Dictionary& p_state) { anim_editor->set_state(p_state); } - virtual String get_name() const { return "Anim"; } + virtual String get_name() const { return TTR("Anim"); } bool has_main_screen() const { return false; } virtual void edit(Object *p_node); virtual bool handles(Object *p_node) const; diff --git a/tools/editor/plugins/animation_tree_editor_plugin.cpp b/tools/editor/plugins/animation_tree_editor_plugin.cpp index 7e1214ec83..dc857bfacb 100644 --- a/tools/editor/plugins/animation_tree_editor_plugin.cpp +++ b/tools/editor/plugins/animation_tree_editor_plugin.cpp @@ -274,7 +274,7 @@ void AnimationTreeEditor::_popup_edit_dialog() { if (renaming_edit) { - edit_label[0]->set_text("New name:"); + edit_label[0]->set_text(TTR("New name:")); edit_label[0]->set_pos(Point2(5,5)); edit_label[0]->show(); edit_line[0]->set_begin(Point2(15,25)); @@ -314,7 +314,7 @@ void AnimationTreeEditor::_popup_edit_dialog() { } return; case AnimationTreePlayer::NODE_TIMESCALE: - edit_label[0]->set_text("Scale:"); + edit_label[0]->set_text(TTR("Scale:")); edit_label[0]->set_pos(Point2(5,5)); edit_label[0]->show(); edit_line[0]->set_begin(Point2(15,25)); @@ -323,13 +323,13 @@ void AnimationTreeEditor::_popup_edit_dialog() { edit_dialog->set_size(Size2(150,50)); break; case AnimationTreePlayer::NODE_ONESHOT: - edit_label[0]->set_text("Fade In (s):"); + edit_label[0]->set_text(TTR("Fade In (s):")); edit_label[0]->set_pos(Point2(5,5)); edit_label[0]->show(); edit_line[0]->set_begin(Point2(15,25)); edit_line[0]->set_text(rtos(anim_tree->oneshot_node_get_fadein_time(edited_node))); edit_line[0]->show(); - edit_label[1]->set_text("Fade Out (s):"); + edit_label[1]->set_text(TTR("Fade Out (s):")); edit_label[1]->set_pos(Point2(5,55)); edit_label[1]->show(); edit_line[1]->set_begin(Point2(15,75)); @@ -337,25 +337,25 @@ void AnimationTreeEditor::_popup_edit_dialog() { edit_line[1]->show(); edit_option->clear(); - edit_option->add_item("Blend",0); - edit_option->add_item("Mix",1); + edit_option->add_item(TTR("Blend"),0); + edit_option->add_item(TTR("Mix"),1); edit_option->set_begin(Point2(15,105)); edit_option->select( anim_tree->oneshot_node_get_mix_mode(edited_node)); edit_option->show(); - edit_check->set_text("Auto Restart:"); + edit_check->set_text(TTR("Auto Restart:")); edit_check->set_begin(Point2(15,125)); edit_check->set_pressed(anim_tree->oneshot_node_has_autorestart(edited_node)); edit_check->show(); - edit_label[2]->set_text("Restart (s):"); + edit_label[2]->set_text(TTR("Restart (s):")); edit_label[2]->set_pos(Point2(5,145)); edit_label[2]->show(); edit_line[2]->set_begin(Point2(15,165)); edit_line[2]->set_text(rtos(anim_tree->oneshot_node_get_autorestart_delay(edited_node))); edit_line[2]->show(); - edit_label[3]->set_text("Random Restart (s):"); + edit_label[3]->set_text(TTR("Random Restart (s):")); edit_label[3]->set_pos(Point2(5,195)); edit_label[3]->show(); edit_line[3]->set_begin(Point2(15,215)); @@ -366,7 +366,7 @@ void AnimationTreeEditor::_popup_edit_dialog() { filter_button->show(); edit_button->set_begin(Point2(10,268)); - edit_button->set_text("Start!"); + edit_button->set_text(TTR("Start!")); edit_button->show(); @@ -376,7 +376,7 @@ void AnimationTreeEditor::_popup_edit_dialog() { case AnimationTreePlayer::NODE_MIX: - edit_label[0]->set_text("Amount:"); + edit_label[0]->set_text(TTR("Amount:")); edit_label[0]->set_pos(Point2(5,5)); edit_label[0]->show(); edit_scroll[0]->set_min(0); @@ -388,7 +388,7 @@ void AnimationTreeEditor::_popup_edit_dialog() { break; case AnimationTreePlayer::NODE_BLEND2: - edit_label[0]->set_text("Blend:"); + edit_label[0]->set_text(TTR("Blend:")); edit_label[0]->set_pos(Point2(5,5)); edit_label[0]->show(); edit_scroll[0]->set_min(0); @@ -403,7 +403,7 @@ void AnimationTreeEditor::_popup_edit_dialog() { break; case AnimationTreePlayer::NODE_BLEND3: - edit_label[0]->set_text("Blend:"); + edit_label[0]->set_text(TTR("Blend:")); edit_label[0]->set_pos(Point2(5,5)); edit_label[0]->show(); edit_scroll[0]->set_min(-1); @@ -416,7 +416,7 @@ void AnimationTreeEditor::_popup_edit_dialog() { break; case AnimationTreePlayer::NODE_BLEND4: - edit_label[0]->set_text("Blend 0:"); + edit_label[0]->set_text(TTR("Blend 0:")); edit_label[0]->set_pos(Point2(5,5)); edit_label[0]->show(); edit_scroll[0]->set_min(0); @@ -424,7 +424,7 @@ void AnimationTreeEditor::_popup_edit_dialog() { edit_scroll[0]->set_val(anim_tree->blend4_node_get_amount(edited_node).x); edit_scroll[0]->set_begin(Point2(15,25)); edit_scroll[0]->show(); - edit_label[1]->set_text("Blend 1:"); + edit_label[1]->set_text(TTR("Blend 1:")); edit_label[1]->set_pos(Point2(5,55)); edit_label[1]->show(); edit_scroll[1]->set_min(0); @@ -439,14 +439,14 @@ void AnimationTreeEditor::_popup_edit_dialog() { case AnimationTreePlayer::NODE_TRANSITION: { - edit_label[0]->set_text("X-Fade Time (s):"); + edit_label[0]->set_text(TTR("X-Fade Time (s):")); edit_label[0]->set_pos(Point2(5,5)); edit_label[0]->show(); edit_line[0]->set_begin(Point2(15,25)); edit_line[0]->set_text(rtos(anim_tree->transition_node_get_xfade_time(edited_node))); edit_line[0]->show(); - edit_label[1]->set_text("Current:"); + edit_label[1]->set_text(TTR("Current:")); edit_label[1]->set_pos(Point2(5,55)); edit_label[1]->show(); edit_option->set_begin(Point2(15,75)); @@ -812,15 +812,15 @@ void AnimationTreeEditor::_input_event(InputEvent p_event) { if (rclick_type==CLICK_INPUT_SLOT || rclick_type==CLICK_OUTPUT_SLOT) { node_popup->clear(); - node_popup->add_item("Disconnect",NODE_DISCONNECT); + node_popup->add_item(TTR("Disconnect"),NODE_DISCONNECT); if (anim_tree->node_get_type(rclick_node)==AnimationTreePlayer::NODE_TRANSITION) { - node_popup->add_item("Add Input",NODE_ADD_INPUT); + node_popup->add_item(TTR("Add Input"),NODE_ADD_INPUT); if (rclick_type==CLICK_INPUT_SLOT) { if (anim_tree->transition_node_has_input_auto_advance(rclick_node,rclick_slot)) - node_popup->add_item("Clear Auto-Advance",NODE_CLEAR_AUTOADVANCE); + node_popup->add_item(TTR("Clear Auto-Advance"),NODE_CLEAR_AUTOADVANCE); else - node_popup->add_item("Set Auto-Advance",NODE_SET_AUTOADVANCE); - node_popup->add_item("Delete Input",NODE_DELETE_INPUT); + node_popup->add_item(TTR("Set Auto-Advance"),NODE_SET_AUTOADVANCE); + node_popup->add_item(TTR("Delete Input"),NODE_DELETE_INPUT); } } @@ -832,10 +832,10 @@ void AnimationTreeEditor::_input_event(InputEvent p_event) { if (rclick_type==CLICK_NODE) { node_popup->clear(); - node_popup->add_item("Rename",NODE_RENAME); - node_popup->add_item("Remove",NODE_ERASE); + node_popup->add_item(TTR("Rename"),NODE_RENAME); + node_popup->add_item(TTR("Remove"),NODE_ERASE); if (anim_tree->node_get_type(rclick_node)==AnimationTreePlayer::NODE_TRANSITION) - node_popup->add_item("Add Input",NODE_ADD_INPUT); + node_popup->add_item(TTR("Add Input"),NODE_ADD_INPUT); node_popup->set_pos(rclick_pos+get_global_pos()); node_popup->popup(); } @@ -990,12 +990,12 @@ void AnimationTreeEditor::_notification(int p_what) { case AnimationTreePlayer::CONNECT_OK: { Ref<Font> f = get_font("font","Label"); - f->draw(get_canvas_item(),Point2(5,25+f->get_ascent()),"Animation Tree is Valid.",Color(0,1,0.6,0.8)); + f->draw(get_canvas_item(),Point2(5,25+f->get_ascent()),TTR("Animation Tree is Valid."),Color(0,1,0.6,0.8)); } break; default: { Ref<Font> f = get_font("font","Label"); - f->draw(get_canvas_item(),Point2(5,25+f->get_ascent()),"Animation Tree is Invalid.",Color(1,0.6,0.0,0.8)); + f->draw(get_canvas_item(),Point2(5,25+f->get_ascent()),TTR("Animation Tree is Invalid."),Color(1,0.6,0.0,0.8)); } break; } @@ -1359,19 +1359,19 @@ AnimationTreeEditor::AnimationTreeEditor() { add_child( add_menu ); p=add_menu->get_popup(); - p->add_item("Animation Node",AnimationTreePlayer::NODE_ANIMATION); - p->add_item("OneShot Node",AnimationTreePlayer::NODE_ONESHOT); - p->add_item("Mix Node",AnimationTreePlayer::NODE_MIX); - p->add_item("Blend2 Node",AnimationTreePlayer::NODE_BLEND2); - p->add_item("Blend3 Node",AnimationTreePlayer::NODE_BLEND3); - p->add_item("Blend4 Node",AnimationTreePlayer::NODE_BLEND4); - p->add_item("TimeScale Node",AnimationTreePlayer::NODE_TIMESCALE); - p->add_item("TimeSeek Node",AnimationTreePlayer::NODE_TIMESEEK); - p->add_item("Transition Node",AnimationTreePlayer::NODE_TRANSITION); + p->add_item(TTR("Animation Node"),AnimationTreePlayer::NODE_ANIMATION); + p->add_item(TTR("OneShot Node"),AnimationTreePlayer::NODE_ONESHOT); + p->add_item(TTR("Mix Node"),AnimationTreePlayer::NODE_MIX); + p->add_item(TTR("Blend2 Node"),AnimationTreePlayer::NODE_BLEND2); + p->add_item(TTR("Blend3 Node"),AnimationTreePlayer::NODE_BLEND3); + p->add_item(TTR("Blend4 Node"),AnimationTreePlayer::NODE_BLEND4); + p->add_item(TTR("TimeScale Node"),AnimationTreePlayer::NODE_TIMESCALE); + p->add_item(TTR("TimeSeek Node"),AnimationTreePlayer::NODE_TIMESEEK); + p->add_item(TTR("Transition Node"),AnimationTreePlayer::NODE_TRANSITION); p->add_separator(); - p->add_item("Import Animations...", MENU_IMPORT_ANIMATIONS); // wtf + p->add_item(TTR("Import Animations..."), MENU_IMPORT_ANIMATIONS); // wtf p->add_separator(); - p->add_item("Clear",MENU_GRAPH_CLEAR); + p->add_item(TTR("Clear"),MENU_GRAPH_CLEAR); p->connect("item_pressed", this,"_add_menu_item"); @@ -1471,7 +1471,7 @@ AnimationTreeEditor::AnimationTreeEditor() { file_dialog->connect("file_selected", this, "_file_dialog_selected"); filter_dialog = memnew( AcceptDialog ); - filter_dialog->set_title("Edit Node Filters"); + filter_dialog->set_title(TTR("Edit Node Filters")); add_child(filter_dialog); filter = memnew( Tree ); @@ -1484,7 +1484,7 @@ AnimationTreeEditor::AnimationTreeEditor() { filter_button->set_margin(MARGIN_RIGHT, 10); edit_dialog->add_child(filter_button); filter_button->hide();; - filter_button->set_text("Filters.."); + filter_button->set_text(TTR("Filters..")); filter_button->connect("pressed", this,"_edit_filters"); } @@ -1524,7 +1524,7 @@ AnimationTreeEditorPlugin::AnimationTreeEditorPlugin(EditorNode *p_node) { anim_tree_editor = memnew( AnimationTreeEditor ); anim_tree_editor->set_custom_minimum_size(Size2(0,300)); - button=editor->add_bottom_panel_item("AnimationTree",anim_tree_editor); + button=editor->add_bottom_panel_item(TTR("AnimationTree"),anim_tree_editor); button->hide(); diff --git a/tools/editor/plugins/animation_tree_editor_plugin.h b/tools/editor/plugins/animation_tree_editor_plugin.h index 4884a22d90..989a6b0b04 100644 --- a/tools/editor/plugins/animation_tree_editor_plugin.h +++ b/tools/editor/plugins/animation_tree_editor_plugin.h @@ -180,7 +180,7 @@ class AnimationTreeEditorPlugin : public EditorPlugin { public: - virtual String get_name() const { return "AnimTree"; } + virtual String get_name() const { return TTR("AnimTree"); } bool has_main_screen() const { return false; } virtual void edit(Object *p_node); virtual bool handles(Object *p_node) const; diff --git a/tools/editor/plugins/baked_light_baker.cpp b/tools/editor/plugins/baked_light_baker.cpp index 4599dbfb54..a37bbce6fe 100644 --- a/tools/editor/plugins/baked_light_baker.cpp +++ b/tools/editor/plugins/baked_light_baker.cpp @@ -728,14 +728,14 @@ void BakedLightBaker::_make_octree() { for(int i=0;i<8;i++) root->children[i]=0; - EditorProgress ep("bake_octree","Parsing "+itos(triangles.size())+" Triangles:",triangles.size()); + EditorProgress ep("bake_octree",TTR("Parsing ")+itos(triangles.size())+" Triangles:",triangles.size()); for(int i=0;i<triangles.size();i++) { _octree_insert(0,&triangles[i],octree_depth-1); if ((i%1000)==0) { - ep.step("Triangle# "+itos(i),i); + ep.step(TTR("Triangle# ")+itos(i),i); } } @@ -1533,7 +1533,7 @@ void BakedLightBaker::_make_octree_texture() { baked_octree_texture_h=nearest_power_of_2(baked_octree_texture_h); - print_line("RESULT! "+itos(baked_octree_texture_w)+","+itos(baked_octree_texture_h)); + print_line(TTR("RESULT! ")+itos(baked_octree_texture_w)+","+itos(baked_octree_texture_h)); } @@ -1716,7 +1716,7 @@ void BakedLightBaker::bake(const Ref<BakedLight> &p_light, Node* p_node) { cell_count=0; base_inv=p_node->cast_to<Spatial>()->get_global_transform().affine_inverse(); - EditorProgress ep("bake","Light Baker Setup:",5); + EditorProgress ep("bake",TTR("Light Baker Setup:"),5); baked_light=p_light; lattice_size=baked_light->get_initial_lattice_subdiv(); octree_depth=baked_light->get_cell_subdivision(); @@ -1743,18 +1743,18 @@ void BakedLightBaker::bake(const Ref<BakedLight> &p_light, Node* p_node) { } - ep.step("Parsing Geometry",0); + ep.step(TTR("Parsing Geometry"),0); _parse_geometry(p_node); mat_map.clear(); tex_map.clear(); print_line("\ttotal triangles: "+itos(triangles.size())); - ep.step("Fixing Lights",1); + ep.step(TTR("Fixing Lights"),1); _fix_lights(); - ep.step("Making BVH",2); + ep.step(TTR("Making BVH"),2); _make_bvh(); - ep.step("Creating Light Octree",3); + ep.step(TTR("Creating Light Octree"),3); _make_octree(); - ep.step("Creating Octree Texture",4); + ep.step(TTR("Creating Octree Texture"),4); _make_octree_texture(); baking=true; _start_thread(); @@ -1810,7 +1810,7 @@ void BakedLightBaker::update_octree_sampler(DVector<int> &p_sampler) { if (octant.children[j]) { tmp_smp.push_back(octants[octant.children[j]].sampler_ofs); if (octants[octant.children[j]].sampler_ofs==0) { - print_line("FUUUUUUUUCK"); + print_line(TTR("FUUUUUUUUCK")); } } } @@ -2357,7 +2357,7 @@ Error BakedLightBaker::transfer_to_lightmaps() { if (!triangles.size() || baked_textures.size()==0) return ERR_UNCONFIGURED; - EditorProgress ep("transfer_to_lightmaps","Transfer to Lightmaps:",baked_textures.size()*2+triangles.size()); + EditorProgress ep("transfer_to_lightmaps",TTR("Transfer to Lightmaps:"),baked_textures.size()*2+triangles.size()); for(int i=0;i<baked_textures.size();i++) { @@ -2365,7 +2365,7 @@ Error BakedLightBaker::transfer_to_lightmaps() { baked_textures[i].data.resize( baked_textures[i].width*baked_textures[i].height*4 ); zeromem(baked_textures[i].data.ptr(),baked_textures[i].data.size()); - ep.step("Allocating Texture #"+itos(i+1),i); + ep.step(TTR("Allocating Texture #")+itos(i+1),i); } Vector<double> norm_arr; @@ -2382,7 +2382,7 @@ Error BakedLightBaker::transfer_to_lightmaps() { for(int i=0;i<triangles.size();i++) { if (i%200==0) { - ep.step("Baking Triangle #"+itos(i),i+baked_textures.size()); + ep.step(TTR("Baking Triangle #")+itos(i),i+baked_textures.size()); } Triangle &t=triangles[i]; if (t.baked_texture<0 || t.baked_texture>=baked_textures.size()) @@ -2505,7 +2505,7 @@ Error BakedLightBaker::transfer_to_lightmaps() { { - ep.step("Post-Processing Texture #"+itos(i),i+baked_textures.size()+triangles.size()); + ep.step(TTR("Post-Processing Texture #")+itos(i),i+baked_textures.size()+triangles.size()); BakeTexture &bt=baked_textures[i]; diff --git a/tools/editor/plugins/baked_light_editor_plugin.cpp b/tools/editor/plugins/baked_light_editor_plugin.cpp index 56aabaf6d9..690b2cd55e 100644 --- a/tools/editor/plugins/baked_light_editor_plugin.cpp +++ b/tools/editor/plugins/baked_light_editor_plugin.cpp @@ -97,7 +97,7 @@ void BakedLightEditor::_notification(int p_option) { } } - print_line("MSCOL: "+itos(OS::get_singleton()->get_ticks_msec()-t)); + print_line(TTR("MSCOL: ")+itos(OS::get_singleton()->get_ticks_msec()-t)); t = OS::get_singleton()->get_ticks_msec(); Array a; @@ -132,14 +132,14 @@ void BakedLightEditor::_notification(int p_option) { bake_info->set_text("rays/s: "+itos(rays_sec)); update_timeout=1; - print_line("MSUPDATE: "+itos(OS::get_singleton()->get_ticks_msec()-t)); + print_line(TTR("MSUPDATE: ")+itos(OS::get_singleton()->get_ticks_msec()-t)); t=OS::get_singleton()->get_ticks_msec(); node->get_baked_light()->set_octree(octree_texture); node->get_baked_light()->set_light(light_texture); node->get_baked_light()->set_sampler_octree(octree_sampler); node->get_baked_light()->set_edited(true); - print_line("MSSET: "+itos(OS::get_singleton()->get_ticks_msec()-t)); + print_line(TTR("MSSET: ")+itos(OS::get_singleton()->get_ticks_msec()-t)); @@ -179,7 +179,7 @@ void BakedLightEditor::_bake_pressed() { ERR_FAIL_COND(!node); if (node->get_baked_light().is_null()) { - err_dialog->set_text("BakedLightInstance does not contain a BakedLight resource."); + err_dialog->set_text(TTR("BakedLightInstance does not contain a BakedLight resource.")); err_dialog->popup_centered_minsize(); button_bake->set_pressed(false); return; @@ -264,7 +264,7 @@ BakedLightEditor::BakedLightEditor() { bake_hbox = memnew( HBoxContainer ); button_bake = memnew( ToolButton ); - button_bake->set_text("Bake!"); + button_bake->set_text(TTR("Bake!")); button_bake->set_toggle_mode(true); button_reset = memnew( Button ); button_make_lightmaps = memnew( Button ); @@ -289,7 +289,7 @@ BakedLightEditor::BakedLightEditor() { button_reset->connect("pressed",this,"_clear_pressed"); button_make_lightmaps->connect("pressed",this,"_bake_lightmaps"); button_reset->hide(); - button_reset->set_tooltip("Reset the lightmap octree baking process (start over)."); + button_reset->set_tooltip(TTR("Reset the lightmap octree baking process (start over).")); update_timeout=0; diff --git a/tools/editor/plugins/camera_editor_plugin.cpp b/tools/editor/plugins/camera_editor_plugin.cpp index 7433264b16..9c25de695c 100644 --- a/tools/editor/plugins/camera_editor_plugin.cpp +++ b/tools/editor/plugins/camera_editor_plugin.cpp @@ -87,7 +87,7 @@ CameraEditor::CameraEditor() { preview = memnew( Button ); add_child(preview); - preview->set_text("Preview"); + preview->set_text(TTR("Preview")); preview->set_toggle_mode(true); preview->set_anchor(MARGIN_LEFT,Control::ANCHOR_END); preview->set_anchor(MARGIN_RIGHT,Control::ANCHOR_END); diff --git a/tools/editor/plugins/canvas_item_editor_plugin.cpp b/tools/editor/plugins/canvas_item_editor_plugin.cpp index 31f50b65f5..76fa1ef8e2 100644 --- a/tools/editor/plugins/canvas_item_editor_plugin.cpp +++ b/tools/editor/plugins/canvas_item_editor_plugin.cpp @@ -62,8 +62,8 @@ public: VBoxContainer *container; GridContainer *child_container; - set_title("Configure Snap"); - get_ok()->set_text("Close"); + set_title(TTR("Configure Snap")); + get_ok()->set_text(TTR("Close")); container = memnew( VBoxContainer ); add_child(container); @@ -74,7 +74,7 @@ public: container->add_child(child_container); label = memnew( Label ); - label->set_text("Grid Offset:"); + label->set_text(TTR("Grid Offset:")); child_container->add_child(label); label->set_h_size_flags(SIZE_EXPAND_FILL); @@ -91,7 +91,7 @@ public: child_container->add_child(grid_offset_y); label = memnew( Label ); - label->set_text("Grid Step:"); + label->set_text(TTR("Grid Step:")); child_container->add_child(label); label->set_h_size_flags(SIZE_EXPAND_FILL); @@ -114,7 +114,7 @@ public: container->add_child(child_container); label = memnew( Label ); - label->set_text("Rotation Offset:"); + label->set_text(TTR("Rotation Offset:")); child_container->add_child(label); label->set_h_size_flags(SIZE_EXPAND_FILL); @@ -125,7 +125,7 @@ public: child_container->add_child(rotation_offset); label = memnew( Label ); - label->set_text("Rotation Step:"); + label->set_text(TTR("Rotation Step:")); child_container->add_child(label); label->set_h_size_flags(SIZE_EXPAND_FILL); @@ -158,7 +158,7 @@ public: void CanvasItemEditor::_edit_set_pivot(const Vector2& mouse_pos) { List<Node*> &selection = editor_selection->get_selected_node_list(); - undo_redo->create_action("Move Pivot"); + undo_redo->create_action(TTR("Move Pivot")); for(List<Node*>::Element *E=selection.front();E;E=E->next()) { @@ -645,7 +645,7 @@ void CanvasItemEditor::_key_move(const Vector2& p_dir, bool p_snap, KeyMoveMODE if (editor_selection->get_selected_node_list().empty()) return; - undo_redo->create_action("Move Action",true); + undo_redo->create_action(TTR("Move Action"),true); List<Node*> &selection = editor_selection->get_selected_node_list(); @@ -1193,7 +1193,7 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) { if (bone_ik_list.size()) { - undo_redo->create_action("Edit IK Chain"); + undo_redo->create_action(TTR("Edit IK Chain")); for(List<BoneIK>::Element *E=bone_ik_list.back();E;E=E->prev()) { @@ -1209,7 +1209,7 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) { undo_redo->commit_action(); } else { - undo_redo->create_action("Edit CanvasItem"); + undo_redo->create_action(TTR("Edit CanvasItem")); List<Node*> &selection = editor_selection->get_selected_node_list(); @@ -1730,7 +1730,7 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) { if ((leaf_pos.distance_to(root_pos)) > total_len) { //oops dude you went too far - //print_line("TOO FAR!"); + //print_line(TTR("TOO FAR!")); Vector2 rel = leaf_pos - root_pos; rel = rel.normalized() * total_len; leaf_pos=root_pos+rel; @@ -1739,7 +1739,7 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) { bone_ik_list.front()->get().pos=leaf_pos; - //print_line("BONE IK LIST "+itos(bone_ik_list.size())); + //print_line(TTR("BONE IK LIST ")+itos(bone_ik_list.size())); if (bone_ik_list.size()>2) { @@ -1764,22 +1764,22 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) { //print_line("back"); Vector2 rel = E->get().pos - E->next()->get().pos; - //print_line("PREV "+E->get().pos); + //print_line(TTR("PREV ")+E->get().pos); Vector2 desired = E->next()->get().pos+rel.normalized()*len; - //print_line("DESIRED "+desired); + //print_line(TTR("DESIRED ")+desired); E->get().pos=E->get().pos.linear_interpolate(desired,solver_k); - //print_line("POST "+E->get().pos); + //print_line(TTR("POST ")+E->get().pos); } else if (E==bone_ik_list.front()) { //only adjust parent //print_line("front"); Vector2 rel = E->next()->get().pos - E->get().pos; - //print_line("PREV "+E->next()->get().pos); + //print_line(TTR("PREV ")+E->next()->get().pos); Vector2 desired = E->get().pos+rel.normalized()*len; - //print_line("DESIRED "+desired); + //print_line(TTR("DESIRED ")+desired); E->next()->get().pos=E->next()->get().pos.linear_interpolate(desired,solver_k); - //print_line("POST "+E->next()->get().pos); + //print_line(TTR("POST ")+E->next()->get().pos); } else { Vector2 rel = E->next()->get().pos - E->get().pos; @@ -1904,7 +1904,7 @@ void CanvasItemEditor::_viewport_draw() { if (h_scroll->is_visible()) size.height-=h_scroll->get_size().height; - get_stylebox("EditorFocus","EditorStyles")->draw(ci,Rect2(Point2(),size)); + get_stylebox(TTR("EditorFocus"),"EditorStyles")->draw(ci,Rect2(Point2(),size)); } Ref<Texture> lock = get_icon("Lock","EditorIcons"); @@ -2227,7 +2227,7 @@ void CanvasItemEditor::_notification(int p_what) { key_insert_button->set_icon(get_icon("Key","EditorIcons")); - //anchor_menu->add_icon_override("Align Top Left"); + //anchor_menu->add_icon_override(TTR("Align Top Left")); anchor_menu->set_icon(get_icon("Anchor","EditorIcons")); PopupMenu *p=anchor_menu->get_popup(); @@ -2462,7 +2462,7 @@ void CanvasItemEditor::_update_scroll(float) { void CanvasItemEditor::_set_anchor(Control::AnchorType p_left,Control::AnchorType p_top,Control::AnchorType p_right,Control::AnchorType p_bottom) { List<Node*> &selection = editor_selection->get_selected_node_list(); - undo_redo->create_action("Change Anchors"); + undo_redo->create_action(TTR("Change Anchors")); for(List<Node*>::Element *E=selection.front();E;E=E->next()) { Control *c = E->get()->cast_to<Control>(); @@ -2541,7 +2541,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { updating_value_dialog=true; - dialog_label->set_text("Zoom (%):"); + dialog_label->set_text(TTR("Zoom (%):")); dialog_val->set_min(0.1); dialog_val->set_step(0.1); dialog_val->set_max(800); @@ -2896,7 +2896,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { if (!pose_clipboard.size()) break; - undo_redo->create_action("Paste Pose"); + undo_redo->create_action(TTR("Paste Pose")); for (List<PoseClipboard>::Element *E=pose_clipboard.front();E;E=E->next()) { Object *o = ObjectDB::get_instance(E->get().id); @@ -3145,7 +3145,7 @@ void CanvasItemEditor::end_drag() { if (undo_redo) { - undo_redo->create_action("Edit CanvasItem"); + undo_redo->create_action(TTR("Edit CanvasItem")); for(CanvasItemMap::Element *E=canvas_items.front();E;E=E->next()) { CanvasItem *canvas_item = E->key(); Variant state=canvas_item->edit_get_state(); @@ -3290,13 +3290,13 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { move_button->set_toggle_mode(true); hb->add_child(move_button); move_button->connect("pressed",this,"_tool_select",make_binds(TOOL_MOVE)); - move_button->set_tooltip("Move Mode (W)"); + move_button->set_tooltip(TTR("Move Mode (W)")); rotate_button = memnew( ToolButton ); rotate_button->set_toggle_mode(true); hb->add_child(rotate_button); rotate_button->connect("pressed",this,"_tool_select",make_binds(TOOL_ROTATE)); - rotate_button->set_tooltip("Rotate Mode (E)"); + rotate_button->set_tooltip(TTR("Rotate Mode (E)")); hb->add_child(memnew(VSeparator)); @@ -3310,13 +3310,13 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { pivot_button->set_toggle_mode(true); hb->add_child(pivot_button); pivot_button->connect("pressed",this,"_tool_select",make_binds(TOOL_EDIT_PIVOT)); - pivot_button->set_tooltip("Click to change object's rotation pivot"); + pivot_button->set_tooltip(TTR("Click to change object's rotation pivot")); pan_button = memnew( ToolButton ); pan_button->set_toggle_mode(true); hb->add_child(pan_button); pan_button->connect("pressed",this,"_tool_select",make_binds(TOOL_PAN)); - pan_button->set_tooltip("Pan Mode"); + pan_button->set_tooltip(TTR("Pan Mode")); hb->add_child(memnew(VSeparator)); @@ -3329,7 +3329,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { unlock_button = memnew( ToolButton ); hb->add_child(unlock_button); unlock_button->connect("pressed",this,"_popup_callback",varray(UNLOCK_SELECTED)); - unlock_button->set_tooltip("Unlock the selected object (can be moved)."); + unlock_button->set_tooltip(TTR("Unlock the selected object (can be moved).")); group_button = memnew( ToolButton ); hb->add_child(group_button); @@ -3344,57 +3344,57 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { hb->add_child(memnew(VSeparator)); edit_menu = memnew( MenuButton ); - edit_menu->set_text("Edit"); + edit_menu->set_text(TTR("Edit")); hb->add_child(edit_menu); edit_menu->get_popup()->connect("item_pressed", this,"_popup_callback"); PopupMenu *p; p = edit_menu->get_popup(); - p->add_check_item("Use Snap",SNAP_USE); - p->add_check_item("Show Grid",SNAP_SHOW_GRID); - p->add_check_item("Use Rotation Snap",SNAP_USE_ROTATION); - p->add_check_item("Snap Relative",SNAP_RELATIVE); - p->add_item("Configure Snap..",SNAP_CONFIGURE); + p->add_check_item(TTR("Use Snap"),SNAP_USE); + p->add_check_item(TTR("Show Grid"),SNAP_SHOW_GRID); + p->add_check_item(TTR("Use Rotation Snap"),SNAP_USE_ROTATION); + p->add_check_item(TTR("Snap Relative"),SNAP_RELATIVE); + p->add_item(TTR("Configure Snap.."),SNAP_CONFIGURE); p->add_separator(); - p->add_check_item("Use Pixel Snap",SNAP_USE_PIXEL); + p->add_check_item(TTR("Use Pixel Snap"),SNAP_USE_PIXEL); p->add_separator(); - p->add_item("Expand to Parent",EXPAND_TO_PARENT,KEY_MASK_CMD|KEY_P); + p->add_item(TTR("Expand to Parent"),EXPAND_TO_PARENT,KEY_MASK_CMD|KEY_P); p->add_separator(); - p->add_submenu_item("Skeleton..","skeleton"); + p->add_submenu_item(TTR("Skeleton.."),"skeleton"); PopupMenu *p2 = memnew(PopupMenu); p->add_child(p2); p2->set_name("skeleton"); - p2->add_item("Make Bones",SKELETON_MAKE_BONES,KEY_MASK_CMD|KEY_MASK_SHIFT|KEY_B); - p2->add_item("Clear Bones",SKELETON_CLEAR_BONES); + p2->add_item(TTR("Make Bones"),SKELETON_MAKE_BONES,KEY_MASK_CMD|KEY_MASK_SHIFT|KEY_B); + p2->add_item(TTR("Clear Bones"),SKELETON_CLEAR_BONES); p2->add_separator(); - p2->add_item("Make IK Chain",SKELETON_SET_IK_CHAIN); - p2->add_item("Clear IK Chain",SKELETON_CLEAR_IK_CHAIN); + p2->add_item(TTR("Make IK Chain"),SKELETON_SET_IK_CHAIN); + p2->add_item(TTR("Clear IK Chain"),SKELETON_CLEAR_IK_CHAIN); p2->connect("item_pressed", this,"_popup_callback"); /* - p->add_item("Align Horizontal",ALIGN_HORIZONTAL); - p->add_item("Align Vertical",ALIGN_VERTICAL); - p->add_item("Space Horizontal",SPACE_HORIZONTAL); - p->add_item("Space Vertical",SPACE_VERTICAL);*/ + p->add_item(TTR("Align Horizontal"),ALIGN_HORIZONTAL); + p->add_item(TTR("Align Vertical"),ALIGN_VERTICAL); + p->add_item(TTR("Space Horizontal"),SPACE_HORIZONTAL); + p->add_item(TTR("Space Vertical"),SPACE_VERTICAL);*/ view_menu = memnew( MenuButton ); - view_menu->set_text("View"); + view_menu->set_text(TTR("View")); hb->add_child(view_menu); view_menu->get_popup()->connect("item_pressed", this,"_popup_callback"); p = view_menu->get_popup(); - p->add_item("Zoom In",ZOOM_IN); - p->add_item("Zoom Out",ZOOM_OUT); - p->add_item("Zoom Reset",ZOOM_RESET); - p->add_item("Zoom Set..",ZOOM_SET); + p->add_item(TTR("Zoom In"),ZOOM_IN); + p->add_item(TTR("Zoom Out"),ZOOM_OUT); + p->add_item(TTR("Zoom Reset"),ZOOM_RESET); + p->add_item(TTR("Zoom Set.."),ZOOM_SET); p->add_separator(); - p->add_item("Center Selection", VIEW_CENTER_TO_SELECTION, KEY_F); - p->add_item("Frame Selection", VIEW_FRAME_TO_SELECTION, KEY_MASK_CMD|KEY_F); + p->add_item(TTR("Center Selection"), VIEW_CENTER_TO_SELECTION, KEY_F); + p->add_item(TTR("Frame Selection"), VIEW_FRAME_TO_SELECTION, KEY_MASK_CMD|KEY_F); anchor_menu = memnew( MenuButton ); - anchor_menu->set_text("Anchor"); + anchor_menu->set_text(TTR("Anchor")); hb->add_child(anchor_menu); anchor_menu->get_popup()->connect("item_pressed", this,"_popup_callback"); anchor_menu->hide(); @@ -3434,7 +3434,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { key_insert_button = memnew( Button ); key_insert_button->set_focus_mode(FOCUS_NONE); key_insert_button->connect("pressed",this,"_popup_callback",varray(ANIM_INSERT_KEY)); - key_insert_button->set_tooltip("Insert Keys (Insert)"); + key_insert_button->set_tooltip(TTR("Insert Keys (Insert)")); animation_hb->add_child(key_insert_button); @@ -3445,24 +3445,24 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { p = animation_menu->get_popup(); - p->add_item("Insert Key",ANIM_INSERT_KEY,KEY_INSERT); - p->add_item("Insert Key (Existing Tracks)",ANIM_INSERT_KEY_EXISTING,KEY_MASK_CMD+KEY_INSERT); + p->add_item(TTR("Insert Key"),ANIM_INSERT_KEY,KEY_INSERT); + p->add_item(TTR("Insert Key (Existing Tracks)"),ANIM_INSERT_KEY_EXISTING,KEY_MASK_CMD+KEY_INSERT); p->add_separator(); - p->add_item("Copy Pose",ANIM_COPY_POSE); - p->add_item("Paste Pose",ANIM_PASTE_POSE); - p->add_item("Clear Pose",ANIM_CLEAR_POSE,KEY_MASK_SHIFT|KEY_K); + p->add_item(TTR("Copy Pose"),ANIM_COPY_POSE); + p->add_item(TTR("Paste Pose"),ANIM_PASTE_POSE); + p->add_item(TTR("Clear Pose"),ANIM_CLEAR_POSE,KEY_MASK_SHIFT|KEY_K); snap_dialog = memnew( SnapDialog ); snap_dialog->connect("confirmed",this,"_snap_changed"); add_child(snap_dialog); value_dialog = memnew( AcceptDialog ); - value_dialog->set_title("Set a Value"); - value_dialog->get_ok()->set_text("Close"); + value_dialog->set_title(TTR("Set a Value")); + value_dialog->get_ok()->set_text(TTR("Close")); add_child(value_dialog); Label *l = memnew(Label); - l->set_text("Snap (Pixels):"); + l->set_text(TTR("Snap (Pixels):")); l->set_pos(Point2(5,5)); value_dialog->add_child(l); dialog_label=l; diff --git a/tools/editor/plugins/collision_polygon_2d_editor_plugin.cpp b/tools/editor/plugins/collision_polygon_2d_editor_plugin.cpp index 8eea723126..8abb51159e 100644 --- a/tools/editor/plugins/collision_polygon_2d_editor_plugin.cpp +++ b/tools/editor/plugins/collision_polygon_2d_editor_plugin.cpp @@ -57,7 +57,7 @@ void CollisionPolygon2DEditor::_menu_option(int p_option) { void CollisionPolygon2DEditor::_wip_close() { - undo_redo->create_action("Create Poly"); + undo_redo->create_action(TTR("Create Poly")); undo_redo->add_undo_method(node,"set_polygon",node->get_polygon()); undo_redo->add_do_method(node,"set_polygon",wip); undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update"); @@ -149,7 +149,7 @@ bool CollisionPolygon2DEditor::forward_input_event(const InputEvent& p_event) { if (poly.size() < 3) { - undo_redo->create_action("Edit Poly"); + undo_redo->create_action(TTR("Edit Poly")); undo_redo->add_undo_method(node,"set_polygon",poly); poly.push_back(cpoint); undo_redo->add_do_method(node,"set_polygon",poly); @@ -229,7 +229,7 @@ bool CollisionPolygon2DEditor::forward_input_event(const InputEvent& p_event) { ERR_FAIL_INDEX_V(edited_point,poly.size(),false); poly[edited_point]=edited_point_pos; - undo_redo->create_action("Edit Poly"); + undo_redo->create_action(TTR("Edit Poly")); undo_redo->add_do_method(node,"set_polygon",poly); undo_redo->add_undo_method(node,"set_polygon",pre_move_edit); undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update"); @@ -263,7 +263,7 @@ bool CollisionPolygon2DEditor::forward_input_event(const InputEvent& p_event) { if (closest_idx>=0) { - undo_redo->create_action("Edit Poly (Remove Point)"); + undo_redo->create_action(TTR("Edit Poly (Remove Point)")); undo_redo->add_undo_method(node,"set_polygon",poly); poly.remove(closest_idx); undo_redo->add_do_method(node,"set_polygon",poly); @@ -390,7 +390,7 @@ CollisionPolygon2DEditor::CollisionPolygon2DEditor(EditorNode *p_editor) { add_child(button_create); button_create->connect("pressed",this,"_menu_option",varray(MODE_CREATE)); button_create->set_toggle_mode(true); - button_create->set_tooltip("Create a new polygon from scratch"); + button_create->set_tooltip(TTR("Create a new polygon from scratch")); button_edit = memnew( ToolButton ); add_child(button_edit); @@ -404,8 +404,8 @@ CollisionPolygon2DEditor::CollisionPolygon2DEditor(EditorNode *p_editor) { options = memnew( MenuButton ); add_child(options); options->set_area_as_parent_rect(); - options->set_text("Polygon"); - //options->get_popup()->add_item("Parse BBCODE",PARSE_BBCODE); + options->set_text(TTR("Polygon")); + //options->get_popup()->add_item(TTR("Parse BBCODE"),PARSE_BBCODE); options->get_popup()->connect("item_pressed", this,"_menu_option"); #endif diff --git a/tools/editor/plugins/collision_polygon_editor_plugin.cpp b/tools/editor/plugins/collision_polygon_editor_plugin.cpp index 44854e655f..5cd09f1a93 100644 --- a/tools/editor/plugins/collision_polygon_editor_plugin.cpp +++ b/tools/editor/plugins/collision_polygon_editor_plugin.cpp @@ -92,7 +92,7 @@ void CollisionPolygonEditor::_menu_option(int p_option) { void CollisionPolygonEditor::_wip_close() { - undo_redo->create_action("Create Poly3D"); + undo_redo->create_action(TTR("Create Poly3D")); undo_redo->add_undo_method(node,"set_polygon",node->get_polygon()); undo_redo->add_do_method(node,"set_polygon",wip); undo_redo->add_do_method(this,"_polygon_draw"); @@ -200,7 +200,7 @@ bool CollisionPolygonEditor::forward_spatial_input_event(Camera* p_camera,const if (poly.size() < 3) { - undo_redo->create_action("Edit Poly"); + undo_redo->create_action(TTR("Edit Poly")); undo_redo->add_undo_method(node,"set_polygon",poly); poly.push_back(cpoint); undo_redo->add_do_method(node,"set_polygon",poly); @@ -282,7 +282,7 @@ bool CollisionPolygonEditor::forward_spatial_input_event(Camera* p_camera,const ERR_FAIL_INDEX_V(edited_point,poly.size(),false); poly[edited_point]=edited_point_pos; - undo_redo->create_action("Edit Poly"); + undo_redo->create_action(TTR("Edit Poly")); undo_redo->add_do_method(node,"set_polygon",poly); undo_redo->add_undo_method(node,"set_polygon",pre_move_edit); undo_redo->add_do_method(this,"_polygon_draw"); @@ -316,7 +316,7 @@ bool CollisionPolygonEditor::forward_spatial_input_event(Camera* p_camera,const if (closest_idx>=0) { - undo_redo->create_action("Edit Poly (Remove Point)"); + undo_redo->create_action(TTR("Edit Poly (Remove Point)")); undo_redo->add_undo_method(node,"set_polygon",poly); poly.remove(closest_idx); undo_redo->add_do_method(node,"set_polygon",poly); @@ -559,8 +559,8 @@ CollisionPolygonEditor::CollisionPolygonEditor(EditorNode *p_editor) { options = memnew( MenuButton ); add_child(options); options->set_area_as_parent_rect(); - options->set_text("Polygon"); - //options->get_popup()->add_item("Parse BBCODE",PARSE_BBCODE); + options->set_text(TTR("Polygon")); + //options->get_popup()->add_item(TTR("Parse BBCODE"),PARSE_BBCODE); options->get_popup()->connect("item_pressed", this,"_menu_option"); #endif diff --git a/tools/editor/plugins/collision_shape_2d_editor_plugin.cpp b/tools/editor/plugins/collision_shape_2d_editor_plugin.cpp index 1916d55ee1..296362447f 100644 --- a/tools/editor/plugins/collision_shape_2d_editor_plugin.cpp +++ b/tools/editor/plugins/collision_shape_2d_editor_plugin.cpp @@ -180,7 +180,7 @@ void CollisionShape2DEditor::set_handle(int idx, Point2& p_point) { void CollisionShape2DEditor::commit_handle(int idx, Variant& p_org) { Control* c = canvas_item_editor->get_viewport_control(); - undo_redo->create_action("Set Handle"); + undo_redo->create_action(TTR("Set Handle")); switch ( shape_type ) { case CAPSULE_SHAPE: { diff --git a/tools/editor/plugins/color_ramp_editor_plugin.cpp b/tools/editor/plugins/color_ramp_editor_plugin.cpp index 133775115d..854a0149a5 100644 --- a/tools/editor/plugins/color_ramp_editor_plugin.cpp +++ b/tools/editor/plugins/color_ramp_editor_plugin.cpp @@ -63,9 +63,9 @@ void ColorRampEditorPlugin::_ramp_changed() { Vector<Color> old_colors=color_ramp_ref->get_colors(); if (old_offsets.size()!=new_offsets.size()) - ur->create_action("Add/Remove Color Ramp Point"); + ur->create_action(TTR("Add/Remove Color Ramp Point")); else - ur->create_action("Modify Color Ramp",true); + ur->create_action(TTR("Modify Color Ramp"),true); ur->add_do_method(this,"undo_redo_color_ramp",new_offsets,new_colors); ur->add_undo_method(this,"undo_redo_color_ramp",old_offsets,old_colors); ur->commit_action(); diff --git a/tools/editor/plugins/control_editor_plugin.cpp b/tools/editor/plugins/control_editor_plugin.cpp index 9dff5e6ce4..0958343f2c 100644 --- a/tools/editor/plugins/control_editor_plugin.cpp +++ b/tools/editor/plugins/control_editor_plugin.cpp @@ -112,7 +112,7 @@ void ControlEditor::_key_move(const Vector2& p_dir, bool p_snap) { if (p_snap) motion*=snap_val->get_text().to_double(); - undo_redo->create_action("Edit Control"); + undo_redo->create_action(TTR("Edit Control")); for(ControlMap::Element *E=controls.front();E;E=E->next()) { Control *control = E->key(); undo_redo->add_do_method(control,"set_pos",control->get_pos()+motion); @@ -156,7 +156,7 @@ void ControlEditor::_input_event(InputEvent p_event) { if (undo_redo) { - undo_redo->create_action("Edit Control"); + undo_redo->create_action(TTR("Edit Control")); for(ControlMap::Element *E=controls.front();E;E=E->next()) { Control *control = E->key(); undo_redo->add_do_method(control,"set_pos",control->get_pos()); @@ -752,17 +752,17 @@ ControlEditor::ControlEditor(EditorNode *p_editor) { handle_len=10; popup=memnew( PopupMenu ); - popup->add_check_item("Use Snap"); - popup->add_item("Configure Snap.."); + popup->add_check_item(TTR("Use Snap")); + popup->add_item(TTR("Configure Snap..")); add_child(popup); snap_dialog = memnew( ConfirmationDialog ); snap_dialog->get_ok()->hide(); - snap_dialog->get_cancel()->set_text("Close"); + snap_dialog->get_cancel()->set_text(TTR("Close")); add_child(snap_dialog); Label *l = memnew(Label); - l->set_text("Snap:"); + l->set_text(TTR("Snap:")); l->set_pos(Point2(5,5)); snap_dialog->add_child(l); diff --git a/tools/editor/plugins/control_editor_plugin.h b/tools/editor/plugins/control_editor_plugin.h index 6234698ee8..67db981c0d 100644 --- a/tools/editor/plugins/control_editor_plugin.h +++ b/tools/editor/plugins/control_editor_plugin.h @@ -125,7 +125,7 @@ class ControlEditorPlugin : public EditorPlugin { public: - virtual String get_name() const { return "GUI"; } + virtual String get_name() const { return TTR("GUI"); } bool has_main_screen() const { return true; } virtual void edit(Object *p_object); virtual bool handles(Object *p_object) const; diff --git a/tools/editor/plugins/cube_grid_theme_editor_plugin.cpp b/tools/editor/plugins/cube_grid_theme_editor_plugin.cpp index 4d6ea5dfb0..3c9f1886b7 100644 --- a/tools/editor/plugins/cube_grid_theme_editor_plugin.cpp +++ b/tools/editor/plugins/cube_grid_theme_editor_plugin.cpp @@ -165,7 +165,7 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library, VS::get_singleton()->camera_set_orthogonal(cam,1.0,0.01,1000.0); - EditorProgress ep("mlib","Creating Mesh Library",ids.size()); + EditorProgress ep("mlib",TTR("Creating Mesh Library"),ids.size()); for(int i=0;i<ids.size();i++) { @@ -193,7 +193,7 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library, xform.origin.z-=rot_aabb.size.z*2; RID inst = VS::get_singleton()->instance_create2(mesh->get_rid(),scen); VS::get_singleton()->instance_set_transform(inst,xform); - ep.step("Thumbnail..",i); + ep.step(TTR("Thumbnail.."),i); VS::get_singleton()->viewport_queue_screen_capture(vp); Main::iteration(); Image img = VS::get_singleton()->viewport_get_screen_capture(vp); @@ -220,7 +220,7 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library, void MeshLibraryEditor::_import_scene_cbk(const String& p_str) { - print_line("Impot Callback!"); + print_line(TTR("Impot Callback!")); Ref<PackedScene> ps = ResourceLoader::load(p_str,"PackedScene"); ERR_FAIL_COND(ps.is_null()); @@ -256,7 +256,7 @@ void MeshLibraryEditor::_menu_cbk(int p_option) { if (p.begins_with("/MeshLibrary/item") && p.get_slice_count("/")>=3) { to_erase = p.get_slice("/",3).to_int(); - cd->set_text("Remove Item "+itos(to_erase)+"?"); + cd->set_text(TTR("Remove Item ")+itos(to_erase)+"?"); cd->popup_centered(Size2(300,60)); } } break; @@ -288,7 +288,7 @@ MeshLibraryEditor::MeshLibraryEditor(EditorNode *p_editor) { List<String> extensions; ResourceLoader::get_recognized_extensions_for_type("PackedScene",&extensions); file->clear_filters(); - file->set_title("Import Scene"); + file->set_title(TTR("Import Scene")); for(int i=0;i<extensions.size();i++) { file->add_filter("*."+extensions[i]+" ; "+extensions[i].to_upper()); @@ -303,11 +303,11 @@ MeshLibraryEditor::MeshLibraryEditor(EditorNode *p_editor) { panel->add_child(options); options->set_pos(Point2(1,1)); options->set_text("Theme"); - options->get_popup()->add_item("Add Item",MENU_OPTION_ADD_ITEM); - options->get_popup()->add_item("Remove Selected Item",MENU_OPTION_REMOVE_ITEM); + options->get_popup()->add_item(TTR("Add Item"),MENU_OPTION_ADD_ITEM); + options->get_popup()->add_item(TTR("Remove Selected Item"),MENU_OPTION_REMOVE_ITEM); options->get_popup()->add_separator(); - options->get_popup()->add_item("Import from Scene",MENU_OPTION_IMPORT_FROM_SCENE); - options->get_popup()->add_item("Update from Scene",MENU_OPTION_UPDATE_FROM_SCENE); + options->get_popup()->add_item(TTR("Import from Scene"),MENU_OPTION_IMPORT_FROM_SCENE); + options->get_popup()->add_item(TTR("Update from Scene"),MENU_OPTION_UPDATE_FROM_SCENE); options->get_popup()->set_item_disabled(options->get_popup()->get_item_index(MENU_OPTION_UPDATE_FROM_SCENE),true); options->get_popup()->connect("item_pressed", this,"_menu_cbk"); menu=options; diff --git a/tools/editor/plugins/item_list_editor_plugin.cpp b/tools/editor/plugins/item_list_editor_plugin.cpp index 08af1a0643..9f47d26492 100644 --- a/tools/editor/plugins/item_list_editor_plugin.cpp +++ b/tools/editor/plugins/item_list_editor_plugin.cpp @@ -129,7 +129,7 @@ int ItemListOptionButtonPlugin::get_flags() const { void ItemListOptionButtonPlugin::add_item() { - ob->add_item( "Item "+itos(ob->get_item_count())); + ob->add_item( TTR("Item ")+itos(ob->get_item_count())); _change_notify(); } @@ -171,7 +171,7 @@ int ItemListPopupMenuPlugin::get_flags() const { void ItemListPopupMenuPlugin::add_item() { - pp->add_item( "Item "+itos(pp->get_item_count())); + pp->add_item( TTR("Item ")+itos(pp->get_item_count())); _change_notify(); } @@ -299,12 +299,12 @@ ItemListEditor::ItemListEditor() { add_child( memnew( VSeparator ) ); toolbar_button = memnew( ToolButton ); - toolbar_button->set_text("Items"); + toolbar_button->set_text(TTR("Items")); add_child(toolbar_button); toolbar_button->connect("pressed",this,"_edit_items"); dialog = memnew( AcceptDialog ); - dialog->set_title("Item List Editor"); + dialog->set_title(TTR("Item List Editor")); add_child( dialog ); VBoxContainer *vbc = memnew( VBoxContainer ); @@ -316,14 +316,14 @@ ItemListEditor::ItemListEditor() { vbc->add_child(hbc); add_button = memnew( Button ); - add_button->set_text("Add"); + add_button->set_text(TTR("Add")); hbc->add_child(add_button); add_button->connect("pressed",this,"_add_button"); hbc->add_spacer(); del_button = memnew( Button ); - del_button->set_text("Delete"); + del_button->set_text(TTR("Delete")); hbc->add_child(del_button); del_button->connect("pressed",this,"_delete_button"); diff --git a/tools/editor/plugins/light_occluder_2d_editor_plugin.cpp b/tools/editor/plugins/light_occluder_2d_editor_plugin.cpp index 757b5327dd..fe031d1657 100644 --- a/tools/editor/plugins/light_occluder_2d_editor_plugin.cpp +++ b/tools/editor/plugins/light_occluder_2d_editor_plugin.cpp @@ -57,7 +57,7 @@ void LightOccluder2DEditor::_menu_option(int p_option) { void LightOccluder2DEditor::_wip_close(bool p_closed) { - undo_redo->create_action("Create Poly"); + undo_redo->create_action(TTR("Create Poly")); undo_redo->add_undo_method(node->get_occluder_polygon().ptr(),"set_polygon",node->get_occluder_polygon()->get_polygon()); undo_redo->add_do_method(node->get_occluder_polygon().ptr(),"set_polygon",wip); undo_redo->add_undo_method(node->get_occluder_polygon().ptr(),"set_closed",node->get_occluder_polygon()->is_closed()); @@ -164,7 +164,7 @@ bool LightOccluder2DEditor::forward_input_event(const InputEvent& p_event) { if (poly.size() < 3) { - undo_redo->create_action("Edit Poly"); + undo_redo->create_action(TTR("Edit Poly")); undo_redo->add_undo_method(node->get_occluder_polygon().ptr(),"set_polygon",poly); poly.push_back(cpoint); undo_redo->add_do_method(node->get_occluder_polygon().ptr(),"set_polygon",poly); @@ -244,7 +244,7 @@ bool LightOccluder2DEditor::forward_input_event(const InputEvent& p_event) { ERR_FAIL_INDEX_V(edited_point,poly.size(),false); poly[edited_point]=edited_point_pos; - undo_redo->create_action("Edit Poly"); + undo_redo->create_action(TTR("Edit Poly")); undo_redo->add_do_method(node->get_occluder_polygon().ptr(),"set_polygon",poly); undo_redo->add_undo_method(node->get_occluder_polygon().ptr(),"set_polygon",pre_move_edit); undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update"); @@ -278,7 +278,7 @@ bool LightOccluder2DEditor::forward_input_event(const InputEvent& p_event) { if (closest_idx>=0) { - undo_redo->create_action("Edit Poly (Remove Point)"); + undo_redo->create_action(TTR("Edit Poly (Remove Point)")); undo_redo->add_undo_method(node->get_occluder_polygon().ptr(),"set_polygon",poly); poly.remove(closest_idx); undo_redo->add_do_method(node->get_occluder_polygon().ptr(),"set_polygon",poly); @@ -393,7 +393,7 @@ void LightOccluder2DEditor::_create_poly() { if (!node) return; - undo_redo->create_action("Create Occluder Polygon"); + undo_redo->create_action(TTR("Create Occluder Polygon")); undo_redo->add_do_method(node,"set_occluder_polygon",Ref<OccluderPolygon2D>(memnew( OccluderPolygon2D))); undo_redo->add_undo_method(node,"set_occluder_polygon",Variant(REF())); undo_redo->commit_action(); @@ -421,7 +421,7 @@ LightOccluder2DEditor::LightOccluder2DEditor(EditorNode *p_editor) { add_child(button_create); button_create->connect("pressed",this,"_menu_option",varray(MODE_CREATE)); button_create->set_toggle_mode(true); - button_create->set_tooltip("Create a new polygon from scratch"); + button_create->set_tooltip(TTR("Create a new polygon from scratch")); button_edit = memnew( ToolButton ); add_child(button_edit); @@ -431,7 +431,7 @@ LightOccluder2DEditor::LightOccluder2DEditor(EditorNode *p_editor) { create_poly = memnew( ConfirmationDialog ); add_child(create_poly); - create_poly->get_ok()->set_text("Create"); + create_poly->get_ok()->set_text(TTR("Create")); //add_constant_override("separation",0); @@ -440,8 +440,8 @@ LightOccluder2DEditor::LightOccluder2DEditor(EditorNode *p_editor) { options = memnew( MenuButton ); add_child(options); options->set_area_as_parent_rect(); - options->set_text("Polygon"); - //options->get_popup()->add_item("Parse BBCODE",PARSE_BBCODE); + options->set_text(TTR("Polygon")); + //options->get_popup()->add_item(TTR("Parse BBCODE"),PARSE_BBCODE); options->get_popup()->connect("item_pressed", this,"_menu_option"); #endif diff --git a/tools/editor/plugins/mesh_editor_plugin.cpp b/tools/editor/plugins/mesh_editor_plugin.cpp index 5314529a23..8671734c25 100644 --- a/tools/editor/plugins/mesh_editor_plugin.cpp +++ b/tools/editor/plugins/mesh_editor_plugin.cpp @@ -27,7 +27,7 @@ void MeshInstanceEditor::_menu_option(int p_option) { Ref<Mesh> mesh = node->get_mesh(); if (mesh.is_null()) { - err_dialog->set_text("Mesh is empty!"); + err_dialog->set_text(TTR("Mesh is empty!")); err_dialog->popup_centered_minsize(); return; } @@ -56,9 +56,9 @@ void MeshInstanceEditor::_menu_option(int p_option) { Node *owner = node==get_tree()->get_edited_scene_root() ? node : node->get_owner(); if (trimesh_shape) - ur->create_action("Create Static Trimesh Body"); + ur->create_action(TTR("Create Static Trimesh Body")); else - ur->create_action("Create Static Convex Body"); + ur->create_action(TTR("Create Static Convex Body")); ur->add_do_method(node,"add_child",body); ur->add_do_method(body,"set_owner",owner); @@ -70,9 +70,9 @@ void MeshInstanceEditor::_menu_option(int p_option) { } if (trimesh_shape) - ur->create_action("Create Static Trimesh Body"); + ur->create_action(TTR("Create Static Trimesh Body")); else - ur->create_action("Create Static Convex Body"); + ur->create_action(TTR("Create Static Convex Body")); for (List<Node*>::Element *E=selection.front();E;E=E->next()) { @@ -110,7 +110,7 @@ void MeshInstanceEditor::_menu_option(int p_option) { case MENU_OPTION_CREATE_CONVEX_COLLISION_SHAPE: { if (node==get_tree()->get_edited_scene_root()) { - err_dialog->set_text("This doesn't work on scene root!"); + err_dialog->set_text(TTR("This doesn't work on scene root!")); err_dialog->popup_centered_minsize(); return; } @@ -129,9 +129,9 @@ void MeshInstanceEditor::_menu_option(int p_option) { UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); if (trimesh_shape) - ur->create_action("Create Trimesh Shape"); + ur->create_action(TTR("Create Trimesh Shape")); else - ur->create_action("Create Convex Shape"); + ur->create_action(TTR("Create Convex Shape")); ur->add_do_method(node->get_parent(),"add_child",cshape); ur->add_do_method(node->get_parent(),"move_child",cshape,node->get_index()+1); @@ -156,7 +156,7 @@ void MeshInstanceEditor::_menu_option(int p_option) { Node *owner = node==get_tree()->get_edited_scene_root() ? node : node->get_owner(); UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); - ur->create_action("Create Navigation Mesh"); + ur->create_action(TTR("Create Navigation Mesh")); ur->add_do_method(node,"add_child",nmi); ur->add_do_method(nmi,"set_owner",owner); @@ -178,7 +178,7 @@ void MeshInstanceEditor::_create_outline_mesh() { Ref<Mesh> mesh = node->get_mesh(); if (mesh.is_null()) { - err_dialog->set_text("MeshInstance lacks a Mesh!"); + err_dialog->set_text(TTR("MeshInstance lacks a Mesh!")); err_dialog->popup_centered_minsize(); return; } @@ -186,7 +186,7 @@ void MeshInstanceEditor::_create_outline_mesh() { Ref<Mesh> mesho = mesh->create_outline(outline_size->get_val()); if (mesho.is_null()) { - err_dialog->set_text("Could not create outline!"); + err_dialog->set_text(TTR("Could not create outline!")); err_dialog->popup_centered_minsize(); return; } @@ -200,7 +200,7 @@ void MeshInstanceEditor::_create_outline_mesh() { UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); - ur->create_action("Create Outline"); + ur->create_action(TTR("Create Outline")); ur->add_do_method(node,"add_child",mi); ur->add_do_method(mi,"set_owner",owner); @@ -225,21 +225,21 @@ MeshInstanceEditor::MeshInstanceEditor() { options->set_text("Mesh"); options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("MeshInstance","EditorIcons")); - options->get_popup()->add_item("Create Trimesh Static Body",MENU_OPTION_CREATE_STATIC_TRIMESH_BODY); - options->get_popup()->add_item("Create Convex Static Body",MENU_OPTION_CREATE_STATIC_CONVEX_BODY); + options->get_popup()->add_item(TTR("Create Trimesh Static Body"),MENU_OPTION_CREATE_STATIC_TRIMESH_BODY); + options->get_popup()->add_item(TTR("Create Convex Static Body"),MENU_OPTION_CREATE_STATIC_CONVEX_BODY); options->get_popup()->add_separator(); - options->get_popup()->add_item("Create Trimesh Collision Sibling",MENU_OPTION_CREATE_TRIMESH_COLLISION_SHAPE); - options->get_popup()->add_item("Create Convex Collision Sibling",MENU_OPTION_CREATE_CONVEX_COLLISION_SHAPE); + options->get_popup()->add_item(TTR("Create Trimesh Collision Sibling"),MENU_OPTION_CREATE_TRIMESH_COLLISION_SHAPE); + options->get_popup()->add_item(TTR("Create Convex Collision Sibling"),MENU_OPTION_CREATE_CONVEX_COLLISION_SHAPE); options->get_popup()->add_separator(); - options->get_popup()->add_item("Create Navigation Mesh",MENU_OPTION_CREATE_NAVMESH); + options->get_popup()->add_item(TTR("Create Navigation Mesh"),MENU_OPTION_CREATE_NAVMESH); options->get_popup()->add_separator(); - options->get_popup()->add_item("Create Outline Mesh..",MENU_OPTION_CREATE_OUTLINE_MESH); + options->get_popup()->add_item(TTR("Create Outline Mesh.."),MENU_OPTION_CREATE_OUTLINE_MESH); options->get_popup()->connect("item_pressed", this,"_menu_option"); outline_dialog = memnew( ConfirmationDialog ); - outline_dialog->set_title("Create Outline Mesh"); - outline_dialog->get_ok()->set_text("Create"); + outline_dialog->set_title(TTR("Create Outline Mesh")); + outline_dialog->get_ok()->set_text(TTR("Create")); VBoxContainer *outline_dialog_vbc = memnew( VBoxContainer ); outline_dialog->add_child(outline_dialog_vbc); @@ -250,7 +250,7 @@ MeshInstanceEditor::MeshInstanceEditor() { outline_size->set_max(1024); outline_size->set_step(0.001); outline_size->set_val(0.05); - outline_dialog_vbc->add_margin_child("Outline Size:",outline_size); + outline_dialog_vbc->add_margin_child(TTR("Outline Size:"),outline_size); add_child(outline_dialog); outline_dialog->connect("confirmed",this,"_create_outline_mesh"); diff --git a/tools/editor/plugins/multimesh_editor_plugin.cpp b/tools/editor/plugins/multimesh_editor_plugin.cpp index 15df9a6262..e22dfb3d13 100644 --- a/tools/editor/plugins/multimesh_editor_plugin.cpp +++ b/tools/editor/plugins/multimesh_editor_plugin.cpp @@ -55,13 +55,13 @@ void MultiMeshEditor::_populate() { multimesh = node->get_multimesh(); if (multimesh.is_null()) { - err_dialog->set_text("No mesh source specified (and no MultiMesh set in node)."); + err_dialog->set_text(TTR("No mesh source specified (and no MultiMesh set in node).")); err_dialog->popup_centered_minsize(); return; } if (multimesh->get_mesh().is_null()) { - err_dialog->set_text("No mesh source specified (and MultiMesh contains no Mesh)."); + err_dialog->set_text(TTR("No mesh source specified (and MultiMesh contains no Mesh).")); err_dialog->popup_centered_minsize(); return; } @@ -73,7 +73,7 @@ void MultiMeshEditor::_populate() { if (!ms_node) { - err_dialog->set_text("Mesh source is invalid (Invalid Path)."); + err_dialog->set_text(TTR("Mesh source is invalid (Invalid Path).")); err_dialog->popup_centered_minsize(); return; } @@ -82,7 +82,7 @@ void MultiMeshEditor::_populate() { if (!ms_instance) { - err_dialog->set_text("Mesh source is invalid (Not a MeshInstance)."); + err_dialog->set_text(TTR("Mesh source is invalid (Not a MeshInstance).")); err_dialog->popup_centered_minsize(); return; } @@ -91,7 +91,7 @@ void MultiMeshEditor::_populate() { if (mesh.is_null()) { - err_dialog->set_text("Mesh source is invalid (Contains no Mesh resource)."); + err_dialog->set_text(TTR("Mesh source is invalid (Contains no Mesh resource).")); err_dialog->popup_centered_minsize(); return; } @@ -100,7 +100,7 @@ void MultiMeshEditor::_populate() { if (surface_source->get_text()=="") { - err_dialog->set_text("No surface source specified."); + err_dialog->set_text(TTR("No surface source specified.")); err_dialog->popup_centered_minsize(); return; } @@ -109,7 +109,7 @@ void MultiMeshEditor::_populate() { if (!ss_node) { - err_dialog->set_text("Surface source is invalid (Invalid Path)."); + err_dialog->set_text(TTR("Surface source is invalid (Invalid Path).")); err_dialog->popup_centered_minsize(); return; } @@ -118,7 +118,7 @@ void MultiMeshEditor::_populate() { if (!ss_instance) { - err_dialog->set_text("Surface source is invalid (Not Geometry)."); + err_dialog->set_text(TTR("Surface source is invalid (Not Geometry).")); err_dialog->popup_centered_minsize(); return; } @@ -129,7 +129,7 @@ void MultiMeshEditor::_populate() { if (geometry.size()==0) { - err_dialog->set_text("Surface source is invalid (No Faces)."); + err_dialog->set_text(TTR("Surface source is invalid (No Faces).")); err_dialog->popup_centered_minsize(); return; } @@ -153,10 +153,10 @@ void MultiMeshEditor::_populate() { node->populate_parent(populate_rotate_random->get_val(),populate_tilt_random->get_val(),populate_scale_random->get_val(),populate_scale->get_val()); - ERR_EXPLAIN("Parent is not of type VisualInstance."); + ERR_EXPLAIN(TTR("Parent is not of type VisualInstance.")); ERR_FAIL_COND(!get_parent() || !get_parent()->is_type("VisualInstance")); - ERR_EXPLAIN("Multimesh not present"); + ERR_EXPLAIN(TTR("Multimesh not present")); ERR_FAIL_COND(multimesh.is_null()); VisualInstance *vi = get_parent()->cast_to<VisualInstance>(); @@ -165,7 +165,7 @@ void MultiMeshEditor::_populate() { #endif DVector<Face3> faces = geometry; - ERR_EXPLAIN("Parent has no solid faces to populate."); + ERR_EXPLAIN(TTR("Parent has no solid faces to populate.")); int facecount=faces.size(); ERR_FAIL_COND(!facecount); @@ -184,9 +184,9 @@ void MultiMeshEditor::_populate() { area_accum+=area; } - ERR_EXPLAIN("Couldn't map area"); + ERR_EXPLAIN(TTR("Couldn't map area")); ERR_FAIL_COND(triangle_area_map.size()==0); - ERR_EXPLAIN("Couldn't map area"); + ERR_EXPLAIN(TTR("Couldn't map area")); ERR_FAIL_COND(area_accum==0); @@ -308,9 +308,9 @@ void MultiMeshEditor::_browse(bool p_source) { std->get_scene_tree()->set_marked(node,false); std->popup_centered_ratio(); if (p_source) - std->set_title("Select a Source Mesh:"); + std->set_title(TTR("Select a Source Mesh:")); else - std->set_title("Select a Target Surface:"); + std->set_title(TTR("Select a Target Surface:")); } void MultiMeshEditor::_bind_methods() { @@ -330,11 +330,11 @@ MultiMeshEditor::MultiMeshEditor() { options->set_text("MultiMesh"); options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("MultiMeshInstance","EditorIcons")); - options->get_popup()->add_item("Populate Surface"); + options->get_popup()->add_item(TTR("Populate Surface")); options->get_popup()->connect("item_pressed", this,"_menu_option"); populate_dialog = memnew( ConfirmationDialog ); - populate_dialog->set_title("Populate MultiMesh"); + populate_dialog->set_title(TTR("Populate MultiMesh")); add_child(populate_dialog); VBoxContainer *vbc = memnew( VBoxContainer ); @@ -351,7 +351,7 @@ MultiMeshEditor::MultiMeshEditor() { b->set_text(".."); b->connect("pressed",this,"_browse",make_binds(false)); - vbc->add_margin_child("Target Surface:",hbc); + vbc->add_margin_child(TTR("Target Surface:"),hbc); hbc = memnew( HBoxContainer ); mesh_source = memnew( LineEdit ); @@ -360,26 +360,26 @@ MultiMeshEditor::MultiMeshEditor() { b = memnew( Button ); hbc->add_child(b); b->set_text(".."); - vbc->add_margin_child("Source Mesh:",hbc); + vbc->add_margin_child(TTR("Source Mesh:"),hbc); b->connect("pressed",this,"_browse",make_binds(true)); populate_axis = memnew( OptionButton ); - populate_axis->add_item("X-Axis"); - populate_axis->add_item("Y-Axis"); - populate_axis->add_item("Z-Axis"); + populate_axis->add_item(TTR("X-Axis")); + populate_axis->add_item(TTR("Y-Axis")); + populate_axis->add_item(TTR("Z-Axis")); populate_axis->select(2); - vbc->add_margin_child("Mesh Up Axis:",populate_axis); + vbc->add_margin_child(TTR("Mesh Up Axis:"),populate_axis); populate_rotate_random = memnew( HSlider ); populate_rotate_random->set_max(1); populate_rotate_random->set_step(0.01); - vbc->add_margin_child("Random Rotation:",populate_rotate_random); + vbc->add_margin_child(TTR("Random Rotation:"),populate_rotate_random); populate_tilt_random = memnew( HSlider ); populate_tilt_random->set_max(1); populate_tilt_random->set_step(0.01); - vbc->add_margin_child("Random Tilt:",populate_tilt_random); + vbc->add_margin_child(TTR("Random Tilt:"),populate_tilt_random); populate_scale_random = memnew( SpinBox ); @@ -387,14 +387,14 @@ MultiMeshEditor::MultiMeshEditor() { populate_scale_random->set_max(1); populate_scale_random->set_val(0); - vbc->add_margin_child("Random Scale:",populate_scale_random); + vbc->add_margin_child(TTR("Random Scale:"),populate_scale_random); populate_scale = memnew( SpinBox ); populate_scale->set_min(0.001); populate_scale->set_max(4096); populate_scale->set_val(1); - vbc->add_margin_child("Scale:",populate_scale); + vbc->add_margin_child(TTR("Scale:"),populate_scale); populate_amount = memnew( SpinBox ); @@ -404,9 +404,9 @@ MultiMeshEditor::MultiMeshEditor() { populate_amount->set_min(1); populate_amount->set_max(65536); populate_amount->set_val(128); - vbc->add_margin_child("Amount:",populate_amount); + vbc->add_margin_child(TTR("Amount:"),populate_amount); - populate_dialog->get_ok()->set_text("Populate"); + populate_dialog->get_ok()->set_text(TTR("Populate")); populate_dialog->get_ok()->connect("pressed", this,"_populate"); std = memnew( SceneTreeDialog ); diff --git a/tools/editor/plugins/navigation_polygon_editor_plugin.cpp b/tools/editor/plugins/navigation_polygon_editor_plugin.cpp index fa1f614413..038c1d48a7 100644 --- a/tools/editor/plugins/navigation_polygon_editor_plugin.cpp +++ b/tools/editor/plugins/navigation_polygon_editor_plugin.cpp @@ -39,7 +39,7 @@ void NavigationPolygonEditor::_create_nav() { if (!node) return; - undo_redo->create_action("Create Navigation Polygon"); + undo_redo->create_action(TTR("Create Navigation Polygon")); undo_redo->add_do_method(node,"set_navigation_polygon",Ref<NavigationPolygon>(memnew( NavigationPolygon))); undo_redo->add_undo_method(node,"set_navigation_polygon",Variant(REF())); undo_redo->commit_action(); @@ -70,7 +70,7 @@ void NavigationPolygonEditor::_wip_close() { if (wip.size()>=3) { - undo_redo->create_action("Create Poly"); + undo_redo->create_action(TTR("Create Poly")); undo_redo->add_undo_method(node->get_navigation_polygon().ptr(),"remove_outline",node->get_navigation_polygon()->get_outline_count()); undo_redo->add_do_method(node->get_navigation_polygon().ptr(),"add_outline",wip); undo_redo->add_do_method(node->get_navigation_polygon().ptr(),"make_polygons_from_outlines"); @@ -271,7 +271,7 @@ bool NavigationPolygonEditor::forward_input_event(const InputEvent& p_event) { DVector<Vector2> poly = node->get_navigation_polygon()->get_outline(edited_outline); ERR_FAIL_INDEX_V(edited_point,poly.size(),false); poly.set(edited_point,edited_point_pos); - undo_redo->create_action("Edit Poly"); + undo_redo->create_action(TTR("Edit Poly")); undo_redo->add_do_method(node->get_navigation_polygon().ptr(),"set_outline",edited_outline,poly); undo_redo->add_undo_method(node->get_navigation_polygon().ptr(),"set_outline",edited_outline,pre_move_edit); undo_redo->add_do_method(node->get_navigation_polygon().ptr(),"make_polygons_from_outlines"); @@ -320,7 +320,7 @@ bool NavigationPolygonEditor::forward_input_event(const InputEvent& p_event) { DVector<Vector2> poly = node->get_navigation_polygon()->get_outline(closest_outline); if (poly.size()>3) { - undo_redo->create_action("Edit Poly (Remove Point)"); + undo_redo->create_action(TTR("Edit Poly (Remove Point)")); undo_redo->add_undo_method(node->get_navigation_polygon().ptr(),"set_outline",closest_outline,poly); poly.remove(closest_idx); undo_redo->add_do_method(node->get_navigation_polygon().ptr(),"set_outline",closest_outline,poly); @@ -331,7 +331,7 @@ bool NavigationPolygonEditor::forward_input_event(const InputEvent& p_event) { undo_redo->commit_action(); } else { - undo_redo->create_action("Remove Poly And Point"); + undo_redo->create_action(TTR("Remove Poly And Point")); undo_redo->add_undo_method(node->get_navigation_polygon().ptr(),"add_outline_at_index",poly,closest_outline); poly.remove(closest_idx); undo_redo->add_do_method(node->get_navigation_polygon().ptr(),"remove_outline",closest_outline); @@ -469,7 +469,7 @@ NavigationPolygonEditor::NavigationPolygonEditor(EditorNode *p_editor) { add_child(button_create); button_create->connect("pressed",this,"_menu_option",varray(MODE_CREATE)); button_create->set_toggle_mode(true); - button_create->set_tooltip("Create a new polygon from scratch"); + button_create->set_tooltip(TTR("Create a new polygon from scratch")); button_edit = memnew( ToolButton ); add_child(button_edit); @@ -478,7 +478,7 @@ NavigationPolygonEditor::NavigationPolygonEditor(EditorNode *p_editor) { button_edit->set_tooltip("Edit existing polygon:\nLMB: Move Point.\nCtrl+LMB: Split Segment.\nRMB: Erase Point."); create_nav = memnew( ConfirmationDialog ); add_child(create_nav); - create_nav->get_ok()->set_text("Create"); + create_nav->get_ok()->set_text(TTR("Create")); //add_constant_override("separation",0); @@ -487,8 +487,8 @@ NavigationPolygonEditor::NavigationPolygonEditor(EditorNode *p_editor) { options = memnew( MenuButton ); add_child(options); options->set_area_as_parent_rect(); - options->set_text("Polygon"); - //options->get_popup()->add_item("Parse BBCODE",PARSE_BBCODE); + options->set_text(TTR("Polygon")); + //options->get_popup()->add_item(TTR("Parse BBCODE"),PARSE_BBCODE); options->get_popup()->connect("item_pressed", this,"_menu_option"); #endif diff --git a/tools/editor/plugins/particles_2d_editor_plugin.cpp b/tools/editor/plugins/particles_2d_editor_plugin.cpp index 297145f408..8892950feb 100644 --- a/tools/editor/plugins/particles_2d_editor_plugin.cpp +++ b/tools/editor/plugins/particles_2d_editor_plugin.cpp @@ -66,7 +66,7 @@ void Particles2DEditorPlugin::_file_selected(const String& p_file) { Image img; Error err = ImageLoader::load_image(p_file,&img); - ERR_EXPLAIN("Error loading image: "+p_file); + ERR_EXPLAIN(TTR("Error loading image: ")+p_file); ERR_FAIL_COND(err!=OK); img.convert(Image::FORMAT_GRAYSCALE_ALPHA); @@ -92,7 +92,7 @@ void Particles2DEditorPlugin::_file_selected(const String& p_file) { valid_positions.resize(vpc); - ERR_EXPLAIN("No pixels with transparency > 128 in image.."); + ERR_EXPLAIN(TTR("No pixels with transparency > 128 in image..")); ERR_FAIL_COND(valid_positions.size()==0); DVector<Point2> epoints; @@ -110,7 +110,7 @@ void Particles2DEditorPlugin::_file_selected(const String& p_file) { w = DVector<Point2>::Write(); - undo_redo->create_action("Set Emission Mask"); + undo_redo->create_action(TTR("Set Emission Mask")); undo_redo->add_do_method(particles,"set_emission_points",epoints); undo_redo->add_do_method(particles,"set_emission_half_extents",extents); undo_redo->add_undo_method(particles,"set_emission_points",particles->get_emission_points()); @@ -130,7 +130,7 @@ void Particles2DEditorPlugin::_menu_callback(int p_idx) { } break; case MENU_CLEAR_EMISSION_MASK: { - undo_redo->create_action("Clear Emission Mask"); + undo_redo->create_action(TTR("Clear Emission Mask")); undo_redo->add_do_method(particles,"set_emission_points",DVector<Vector2>()); undo_redo->add_undo_method(particles,"set_emission_points",particles->get_emission_points()); undo_redo->commit_action(); @@ -171,8 +171,8 @@ Particles2DEditorPlugin::Particles2DEditorPlugin(EditorNode *p_node) { toolbar->add_child( memnew( VSeparator ) ); menu = memnew( MenuButton ); - menu->get_popup()->add_item("Load Emission Mask",MENU_LOAD_EMISSION_MASK); - menu->get_popup()->add_item("Clear Emission Mask",MENU_CLEAR_EMISSION_MASK); + menu->get_popup()->add_item(TTR("Load Emission Mask"),MENU_LOAD_EMISSION_MASK); + menu->get_popup()->add_item(TTR("Clear Emission Mask"),MENU_CLEAR_EMISSION_MASK); menu->set_text("Particles"); toolbar->add_child(menu); @@ -190,7 +190,7 @@ Particles2DEditorPlugin::Particles2DEditorPlugin(EditorNode *p_node) { epoints->set_max(8192); epoints->set_step(1); epoints->set_val(512); - file->get_vbox()->add_margin_child("Generated Point Count:",epoints); + file->get_vbox()->add_margin_child(TTR("Generated Point Count:"),epoints); } Particles2DEditorPlugin::~Particles2DEditorPlugin() diff --git a/tools/editor/plugins/particles_editor_plugin.cpp b/tools/editor/plugins/particles_editor_plugin.cpp index 2df6d3ea90..b7ba987622 100644 --- a/tools/editor/plugins/particles_editor_plugin.cpp +++ b/tools/editor/plugins/particles_editor_plugin.cpp @@ -57,7 +57,7 @@ void ParticlesEditor::_node_selected(const NodePath& p_path){ VisualInstance *vi = sel->cast_to<VisualInstance>(); if (!vi) { - err_dialog->set_text("Node does not contain geometry."); + err_dialog->set_text(TTR("Node does not contain geometry.")); err_dialog->popup_centered_minsize(); return; } @@ -66,7 +66,7 @@ void ParticlesEditor::_node_selected(const NodePath& p_path){ if (geometry.size()==0) { - err_dialog->set_text("Node does not contain geometry (faces)."); + err_dialog->set_text(TTR("Node does not contain geometry (faces).")); err_dialog->popup_centered_minsize(); return; @@ -219,7 +219,7 @@ void ParticlesEditor::_generate_emission_points() { if (!triangle_area_map.size() || area_accum==0) { - err_dialog->set_text("Faces contain no area!"); + err_dialog->set_text(TTR("Faces contain no area!")); err_dialog->popup_centered_minsize(); return; } @@ -249,7 +249,7 @@ void ParticlesEditor::_generate_emission_points() { if (gcount==0) { - err_dialog->set_text("No Faces!"); + err_dialog->set_text(TTR("No Faces!")); err_dialog->popup_centered_minsize(); return; } @@ -349,20 +349,20 @@ ParticlesEditor::ParticlesEditor() { particles_editor_hb->hide(); options->set_text("Particles"); - options->get_popup()->add_item("Generate AABB",MENU_OPTION_GENERATE_AABB); + options->get_popup()->add_item(TTR("Generate AABB"),MENU_OPTION_GENERATE_AABB); options->get_popup()->add_separator(); - options->get_popup()->add_item("Create Emitter From Mesh",MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_MESH); - options->get_popup()->add_item("Create Emitter From Node",MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE); - options->get_popup()->add_item("Clear Emitter",MENU_OPTION_CLEAR_EMISSION_VOLUME); + options->get_popup()->add_item(TTR("Create Emitter From Mesh"),MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_MESH); + options->get_popup()->add_item(TTR("Create Emitter From Node"),MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE); + options->get_popup()->add_item(TTR("Clear Emitter"),MENU_OPTION_CLEAR_EMISSION_VOLUME); options->get_popup()->connect("item_pressed", this,"_menu_option"); emission_dialog = memnew( ConfirmationDialog ); - emission_dialog->set_title("Create Emitter"); + emission_dialog->set_title(TTR("Create Emitter")); add_child(emission_dialog); Label *l = memnew(Label); l->set_pos(Point2(5,5)); - l->set_text("Emission Positions:"); + l->set_text(TTR("Emission Positions:")); emission_dialog->add_child(l); @@ -374,20 +374,20 @@ ParticlesEditor::ParticlesEditor() { emission_amount->set_max(65536); emission_amount->set_val(512); emission_dialog->add_child(emission_amount); - emission_dialog->get_ok()->set_text("Create"); + emission_dialog->get_ok()->set_text(TTR("Create")); emission_dialog->connect("confirmed",this,"_generate_emission_points"); l = memnew(Label); l->set_pos(Point2(5,50)); - l->set_text("Emission Fill:"); + l->set_text(TTR("Emission Fill:")); emission_dialog->add_child(l); emission_fill = memnew( OptionButton ); emission_fill->set_anchor(MARGIN_RIGHT,ANCHOR_END); emission_fill->set_begin( Point2(20,70)); emission_fill->set_end( Point2(5,75)); - emission_fill->add_item("Surface"); - emission_fill->add_item("Volume"); + emission_fill->add_item(TTR("Surface")); + emission_fill->add_item(TTR("Volume")); emission_dialog->add_child(emission_fill); err_dialog = memnew( ConfirmationDialog ); diff --git a/tools/editor/plugins/path_2d_editor_plugin.cpp b/tools/editor/plugins/path_2d_editor_plugin.cpp index 509edbe5f8..079ca3a339 100644 --- a/tools/editor/plugins/path_2d_editor_plugin.cpp +++ b/tools/editor/plugins/path_2d_editor_plugin.cpp @@ -113,7 +113,7 @@ bool Path2DEditor::forward_input_event(const InputEvent& p_event) { return true; } else if ((mb.button_index==BUTTON_RIGHT && mode==MODE_EDIT) || (mb.button_index==BUTTON_LEFT && mode==MODE_DELETE)) { - undo_redo->create_action("Remove Point from Curve"); + undo_redo->create_action(TTR("Remove Point from Curve")); undo_redo->add_do_method(curve.ptr(),"remove_point",i); undo_redo->add_undo_method(curve.ptr(),"add_point",curve->get_point_pos(i),curve->get_point_in(i),curve->get_point_out(i),i); undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update"); @@ -162,7 +162,7 @@ bool Path2DEditor::forward_input_event(const InputEvent& p_event) { Ref<Curve2D> curve = node->get_curve(); - undo_redo->create_action("Add Point to Curve"); + undo_redo->create_action(TTR("Add Point to Curve")); undo_redo->add_do_method(curve.ptr(),"add_point",cpoint); undo_redo->add_undo_method(curve.ptr(),"remove_point",curve->get_point_count()); undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update"); @@ -190,7 +190,7 @@ bool Path2DEditor::forward_input_event(const InputEvent& p_event) { case ACTION_MOVING_POINT: { - undo_redo->create_action("Move Point in Curve"); + undo_redo->create_action(TTR("Move Point in Curve")); undo_redo->add_do_method(curve.ptr(),"set_point_pos",action_point,cpoint); undo_redo->add_undo_method(curve.ptr(),"set_point_pos",action_point,moving_from); undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update"); @@ -200,7 +200,7 @@ bool Path2DEditor::forward_input_event(const InputEvent& p_event) { } break; case ACTION_MOVING_IN: { - undo_redo->create_action("Move In-Control in Curve"); + undo_redo->create_action(TTR("Move In-Control in Curve")); undo_redo->add_do_method(curve.ptr(),"set_point_in",action_point,new_pos); undo_redo->add_undo_method(curve.ptr(),"set_point_in",action_point,moving_from); undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update"); @@ -210,7 +210,7 @@ bool Path2DEditor::forward_input_event(const InputEvent& p_event) { } break; case ACTION_MOVING_OUT: { - undo_redo->create_action("Move Out-Control in Curve"); + undo_redo->create_action(TTR("Move Out-Control in Curve")); undo_redo->add_do_method(curve.ptr(),"set_point_out",action_point,new_pos); undo_redo->add_undo_method(curve.ptr(),"set_point_out",action_point,moving_from); undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update"); @@ -280,7 +280,7 @@ bool Path2DEditor::forward_input_event(const InputEvent& p_event) { if (poly.size() < 3) { - undo_redo->create_action("Edit Poly"); + undo_redo->create_action(TTR("Edit Poly")); undo_redo->add_undo_method(node,"set_polygon",poly); poly.push_back(cpoint); undo_redo->add_do_method(node,"set_polygon",poly); @@ -360,7 +360,7 @@ bool Path2DEditor::forward_input_event(const InputEvent& p_event) { ERR_FAIL_INDEX_V(edited_point,poly.size(),false); poly[edited_point]=edited_point_pos; - undo_redo->create_action("Edit Poly"); + undo_redo->create_action(TTR("Edit Poly")); undo_redo->add_do_method(node,"set_polygon",poly); undo_redo->add_undo_method(node,"set_polygon",pre_move_edit); undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update"); @@ -394,7 +394,7 @@ bool Path2DEditor::forward_input_event(const InputEvent& p_event) { if (closest_idx>=0) { - undo_redo->create_action("Edit Poly (Remove Point)"); + undo_redo->create_action(TTR("Edit Poly (Remove Point)")); undo_redo->add_undo_method(node,"set_polygon",poly); poly.remove(closest_idx); undo_redo->add_do_method(node,"set_polygon",poly); @@ -596,7 +596,7 @@ void Path2DEditor::_mode_selected(int p_mode) { if (begin.distance_to(end)<CMP_EPSILON) return; - undo_redo->create_action("Remove Point from Curve"); + undo_redo->create_action(TTR("Remove Point from Curve")); undo_redo->add_do_method(node->get_curve().ptr(),"add_point",begin); undo_redo->add_undo_method(node->get_curve().ptr(),"remove_point",node->get_curve()->get_point_count()); undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update"); @@ -622,8 +622,8 @@ Path2DEditor::Path2DEditor(EditorNode *p_editor) { options = memnew( MenuButton ); add_child(options); options->set_area_as_parent_rect(); - options->set_text("Polygon"); - //options->get_popup()->add_item("Parse BBCODE",PARSE_BBCODE); + options->set_text(TTR("Polygon")); + //options->get_popup()->add_item(TTR("Parse BBCODE"),PARSE_BBCODE); options->get_popup()->connect("item_pressed", this,"_menu_option"); #endif @@ -643,7 +643,7 @@ Path2DEditor::Path2DEditor(EditorNode *p_editor) { curve_edit_curve->set_icon(CanvasItemEditor::get_singleton()->get_icon("CurveCurve","EditorIcons")); curve_edit_curve->set_toggle_mode(true); curve_edit_curve->set_focus_mode(Control::FOCUS_NONE); - curve_edit_curve->set_tooltip("Select Control Points (Shift+Drag)"); + curve_edit_curve->set_tooltip(TTR("Select Control Points (Shift+Drag)")); curve_edit_curve->connect("pressed",this,"_mode_selected",varray(MODE_EDIT_CURVE)); base_hb->add_child(curve_edit_curve); curve_create = memnew( ToolButton ); @@ -657,13 +657,13 @@ Path2DEditor::Path2DEditor(EditorNode *p_editor) { curve_del->set_icon(CanvasItemEditor::get_singleton()->get_icon("CurveDelete","EditorIcons")); curve_del->set_toggle_mode(true); curve_del->set_focus_mode(Control::FOCUS_NONE); - curve_del->set_tooltip("Delete Point."); + curve_del->set_tooltip(TTR("Delete Point.")); curve_del->connect("pressed",this,"_mode_selected",varray(MODE_DELETE)); base_hb->add_child(curve_del); curve_close = memnew( ToolButton ); curve_close->set_icon(CanvasItemEditor::get_singleton()->get_icon("CurveClose","EditorIcons")); curve_close->set_focus_mode(Control::FOCUS_NONE); - curve_close->set_tooltip("Close Curve"); + curve_close->set_tooltip(TTR("Close Curve")); curve_close->connect("pressed",this,"_mode_selected",varray(ACTION_CLOSE)); base_hb->add_child(curve_close); base_hb->hide(); diff --git a/tools/editor/plugins/path_editor_plugin.cpp b/tools/editor/plugins/path_editor_plugin.cpp index 3c4428bdb0..6820eed297 100644 --- a/tools/editor/plugins/path_editor_plugin.cpp +++ b/tools/editor/plugins/path_editor_plugin.cpp @@ -39,14 +39,14 @@ String PathSpatialGizmo::get_handle_name(int p_idx) const { if (p_idx<c->get_point_count()) { - return "Curve Point #"+itos(p_idx); + return TTR("Curve Point #")+itos(p_idx); } p_idx=p_idx-c->get_point_count()+1; int idx=p_idx/2; int t=p_idx%2; - String n = "Curve Point #"+itos(idx); + String n = TTR("Curve Point #")+itos(idx); if (t==0) n+=" In"; else @@ -148,7 +148,7 @@ void PathSpatialGizmo::commit_handle(int p_idx,const Variant& p_restore,bool p_c c->set_point_pos(p_idx,p_restore); return; } - ur->create_action("Set Curve Point Pos"); + ur->create_action(TTR("Set Curve Point Pos")); ur->add_do_method(c.ptr(),"set_point_pos",p_idx,c->get_point_pos(p_idx)); ur->add_undo_method(c.ptr(),"set_point_pos",p_idx,p_restore); ur->commit_action(); @@ -179,7 +179,7 @@ void PathSpatialGizmo::commit_handle(int p_idx,const Variant& p_restore,bool p_c c->set_point_in(p_idx,p_restore); return; } - ur->create_action("Set Curve In Pos"); + ur->create_action(TTR("Set Curve In Pos")); ur->add_do_method(c.ptr(),"set_point_in",idx,c->get_point_in(idx)); ur->add_undo_method(c.ptr(),"set_point_in",idx,p_restore); ur->commit_action(); @@ -191,7 +191,7 @@ void PathSpatialGizmo::commit_handle(int p_idx,const Variant& p_restore,bool p_c c->set_point_out(idx,p_restore); return; } - ur->create_action("Set Curve Out Pos"); + ur->create_action(TTR("Set Curve Out Pos")); ur->add_do_method(c.ptr(),"set_point_out",idx,c->get_point_out(idx)); ur->add_undo_method(c.ptr(),"set_point_out",idx,p_restore); ur->commit_action(); @@ -366,7 +366,7 @@ bool PathEditorPlugin::forward_spatial_input_event(Camera* p_camera,const InputE if (closest_seg!=-1) { //subdivide - ur->create_action("Split Path"); + ur->create_action(TTR("Split Path")); ur->add_do_method(c.ptr(),"add_point",closest_seg_point,Vector3(),Vector3(),closest_seg+1); ur->add_undo_method(c.ptr(),"remove_point",closest_seg+1); ur->commit_action();; @@ -386,7 +386,7 @@ bool PathEditorPlugin::forward_spatial_input_event(Camera* p_camera,const InputE Vector3 inters; if (p.intersects_ray(ray_from,ray_dir,&inters)) { - ur->create_action("Add Point to Curve"); + ur->create_action(TTR("Add Point to Curve")); ur->add_do_method(c.ptr(),"add_point",it.xform(inters),Vector3(),Vector3(),-1); ur->add_undo_method(c.ptr(),"remove_point",c->get_point_count()); ur->commit_action();; @@ -411,7 +411,7 @@ bool PathEditorPlugin::forward_spatial_input_event(Camera* p_camera,const InputE if (erase_idx!=-1) { UndoRedo *ur = editor->get_undo_redo(); - ur->create_action("Remove Path Point"); + ur->create_action(TTR("Remove Path Point")); ur->add_do_method(c.ptr(),"remove_point",erase_idx); ur->add_undo_method(c.ptr(),"add_point",c->get_point_pos(erase_idx),c->get_point_in(erase_idx),c->get_point_out(erase_idx),erase_idx); ur->commit_action(); @@ -560,13 +560,13 @@ PathEditorPlugin::PathEditorPlugin(EditorNode *p_node) { curve_del->set_toggle_mode(true); curve_del->hide(); curve_del->set_focus_mode(Control::FOCUS_NONE); - curve_del->set_tooltip("Delete Point."); + curve_del->set_tooltip(TTR("Delete Point.")); SpatialEditor::get_singleton()->add_control_to_menu_panel(curve_del); curve_close = memnew( ToolButton ); curve_close->set_icon(SpatialEditor::get_singleton()->get_icon("CurveClose","EditorIcons")); curve_close->hide(); curve_close->set_focus_mode(Control::FOCUS_NONE); - curve_close->set_tooltip("Close Curve"); + curve_close->set_tooltip(TTR("Close Curve")); SpatialEditor::get_singleton()->add_control_to_menu_panel(curve_close); diff --git a/tools/editor/plugins/polygon_2d_editor_plugin.cpp b/tools/editor/plugins/polygon_2d_editor_plugin.cpp index 849fe82645..f07c43b8e4 100644 --- a/tools/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/tools/editor/plugins/polygon_2d_editor_plugin.cpp @@ -105,7 +105,7 @@ void Polygon2DEditor::_menu_option(int p_option) { DVector<Vector2> points = node->get_polygon(); DVector<Vector2> uvs = node->get_uv(); if (uvs.size()!=points.size()) { - undo_redo->create_action("Create UV Map"); + undo_redo->create_action(TTR("Create UV Map")); undo_redo->add_do_method(node,"set_uv",points); undo_redo->add_undo_method(node,"set_uv",uvs); undo_redo->add_do_method(uv_edit_draw,"update"); @@ -123,7 +123,7 @@ void Polygon2DEditor::_menu_option(int p_option) { if (points.size()==0) break; DVector<Vector2> uvs = node->get_uv(); - undo_redo->create_action("Create UV Map"); + undo_redo->create_action(TTR("Create UV Map")); undo_redo->add_do_method(node,"set_uv",points); undo_redo->add_undo_method(node,"set_uv",uvs); undo_redo->add_do_method(uv_edit_draw,"update"); @@ -139,7 +139,7 @@ void Polygon2DEditor::_menu_option(int p_option) { if (uvs.size()==0) break; - undo_redo->create_action("Create UV Map"); + undo_redo->create_action(TTR("Create UV Map")); undo_redo->add_do_method(node,"set_polygon",uvs); undo_redo->add_undo_method(node,"set_polygon",points); undo_redo->add_do_method(uv_edit_draw,"update"); @@ -152,7 +152,7 @@ void Polygon2DEditor::_menu_option(int p_option) { DVector<Vector2> uvs = node->get_uv(); if (uvs.size()==0) break; - undo_redo->create_action("Create UV Map"); + undo_redo->create_action(TTR("Create UV Map")); undo_redo->add_do_method(node,"set_uv",DVector<Vector2>()); undo_redo->add_undo_method(node,"set_uv",uvs); undo_redo->add_do_method(uv_edit_draw,"update"); @@ -202,7 +202,7 @@ void Polygon2DEditor::_set_snap_step_y(float p_val) void Polygon2DEditor::_wip_close() { - undo_redo->create_action("Create Poly"); + undo_redo->create_action(TTR("Create Poly")); undo_redo->add_undo_method(node,"set_polygon",node->get_polygon()); undo_redo->add_do_method(node,"set_polygon",wip); undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update"); @@ -294,7 +294,7 @@ bool Polygon2DEditor::forward_input_event(const InputEvent& p_event) { if (poly.size() < 3) { - undo_redo->create_action("Edit Poly"); + undo_redo->create_action(TTR("Edit Poly")); undo_redo->add_undo_method(node,"set_polygon",poly); poly.push_back(cpoint); undo_redo->add_do_method(node,"set_polygon",poly); @@ -374,7 +374,7 @@ bool Polygon2DEditor::forward_input_event(const InputEvent& p_event) { ERR_FAIL_INDEX_V(edited_point,poly.size(),false); poly[edited_point]=edited_point_pos-node->get_offset(); - undo_redo->create_action("Edit Poly"); + undo_redo->create_action(TTR("Edit Poly")); undo_redo->add_do_method(node,"set_polygon",poly); undo_redo->add_undo_method(node,"set_polygon",pre_move_edit); undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update"); @@ -408,7 +408,7 @@ bool Polygon2DEditor::forward_input_event(const InputEvent& p_event) { if (closest_idx>=0) { - undo_redo->create_action("Edit Poly (Remove Point)"); + undo_redo->create_action(TTR("Edit Poly (Remove Point)")); undo_redo->add_undo_method(node,"set_polygon",poly); poly.remove(closest_idx); undo_redo->add_do_method(node,"set_polygon",poly); @@ -548,7 +548,7 @@ void Polygon2DEditor::_uv_input(const InputEvent& p_input) { } } else if (uv_drag) { - undo_redo->create_action("Transform UV Map"); + undo_redo->create_action(TTR("Transform UV Map")); undo_redo->add_do_method(node,"set_uv",node->get_uv()); undo_redo->add_undo_method(node,"set_uv",uv_prev); undo_redo->add_do_method(uv_edit_draw,"update"); @@ -840,8 +840,8 @@ Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) { options = memnew( MenuButton ); add_child(options); options->set_area_as_parent_rect(); - options->set_text("Polygon"); - //options->get_popup()->add_item("Parse BBCODE",PARSE_BBCODE); + options->set_text(TTR("Polygon")); + //options->get_popup()->add_item(TTR("Parse BBCODE"),PARSE_BBCODE); options->get_popup()->connect("item_pressed", this,"_menu_option"); #endif @@ -851,7 +851,7 @@ Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) { uv_mode=UV_MODE_EDIT_POINT; uv_edit = memnew( AcceptDialog ); add_child(uv_edit); - uv_edit->set_title("Polygon 2D UV Editor"); + uv_edit->set_title(TTR("Polygon 2D UV Editor")); uv_edit->set_self_opacity(0.9); VBoxContainer *uv_main_vb = memnew( VBoxContainer ); @@ -869,9 +869,9 @@ Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) { } uv_button[0]->set_tooltip("Move Point\nCtrl: Rotate\nShift: Move All\n:Shift+Ctrl: Scale"); - uv_button[1]->set_tooltip("Move Polygon"); - uv_button[2]->set_tooltip("Rotate Polygon"); - uv_button[3]->set_tooltip("Scale Polygon"); + uv_button[1]->set_tooltip(TTR("Move Polygon")); + uv_button[2]->set_tooltip(TTR("Rotate Polygon")); + uv_button[3]->set_tooltip(TTR("Scale Polygon")); uv_button[0]->set_pressed(true); HBoxContainer *uv_main_hb = memnew( HBoxContainer ); @@ -882,35 +882,35 @@ Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) { uv_edit_draw->set_h_size_flags(SIZE_EXPAND_FILL); uv_menu = memnew( MenuButton ); uv_mode_hb->add_child(uv_menu); - uv_menu->set_text("Edit"); - uv_menu->get_popup()->add_item("Polygon->UV",UVEDIT_POLYGON_TO_UV); - uv_menu->get_popup()->add_item("UV->Polygon",UVEDIT_UV_TO_POLYGON); + uv_menu->set_text(TTR("Edit")); + uv_menu->get_popup()->add_item(TTR("Polygon->UV"),UVEDIT_POLYGON_TO_UV); + uv_menu->get_popup()->add_item(TTR("UV->Polygon"),UVEDIT_UV_TO_POLYGON); uv_menu->get_popup()->add_separator(); - uv_menu->get_popup()->add_item("Clear UV",UVEDIT_UV_CLEAR); + uv_menu->get_popup()->add_item(TTR("Clear UV"),UVEDIT_UV_CLEAR); uv_menu->get_popup()->connect("item_pressed",this,"_menu_option"); uv_mode_hb->add_child( memnew( VSeparator )); b_snap_enable = memnew( ToolButton ); uv_mode_hb->add_child(b_snap_enable); - b_snap_enable->set_text("Snap"); + b_snap_enable->set_text(TTR("Snap")); b_snap_enable->set_focus_mode(FOCUS_NONE); b_snap_enable->set_toggle_mode(true); b_snap_enable->set_pressed(use_snap); - b_snap_enable->set_tooltip("Enable Snap"); + b_snap_enable->set_tooltip(TTR("Enable Snap")); b_snap_enable->connect("toggled",this,"_set_use_snap"); b_snap_grid = memnew( ToolButton ); uv_mode_hb->add_child(b_snap_grid); - b_snap_grid->set_text("Grid"); + b_snap_grid->set_text(TTR("Grid")); b_snap_grid->set_focus_mode(FOCUS_NONE); b_snap_grid->set_toggle_mode(true); b_snap_grid->set_pressed(snap_show_grid); - b_snap_grid->set_tooltip("Show Grid"); + b_snap_grid->set_tooltip(TTR("Show Grid")); b_snap_grid->connect("toggled",this,"_set_show_grid"); uv_mode_hb->add_child( memnew( VSeparator )); - uv_mode_hb->add_child( memnew( Label("Grid Offset:") ) ); + uv_mode_hb->add_child( memnew( Label(TTR("Grid Offset:")) ) ); SpinBox *sb_off_x = memnew( SpinBox ); sb_off_x->set_min(-256); @@ -931,7 +931,7 @@ Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) { uv_mode_hb->add_child(sb_off_y); uv_mode_hb->add_child( memnew( VSeparator )); - uv_mode_hb->add_child( memnew( Label("Grid Step:") ) ); + uv_mode_hb->add_child( memnew( Label(TTR("Grid Step:")) ) ); SpinBox *sb_step_x = memnew( SpinBox ); sb_step_x->set_min(-256); diff --git a/tools/editor/plugins/resource_preloader_editor_plugin.cpp b/tools/editor/plugins/resource_preloader_editor_plugin.cpp index 0459ed85bd..01bb82834d 100644 --- a/tools/editor/plugins/resource_preloader_editor_plugin.cpp +++ b/tools/editor/plugins/resource_preloader_editor_plugin.cpp @@ -70,10 +70,10 @@ void ResourcePreloaderEditor::_files_load_request(const Vector<String>& p_paths) resource = ResourceLoader::load(path); if (resource.is_null()) { - dialog->set_text("ERROR: Couldn't load resource!"); - dialog->set_title("Error!"); - //dialog->get_cancel()->set_text("Close"); - dialog->get_ok()->set_text("Close"); + dialog->set_text(TTR("ERROR: Couldn't load resource!")); + dialog->set_title(TTR("Error!")); + //dialog->get_cancel()->set_text(TTR("Close")); + dialog->get_ok()->set_text(TTR("Close")); dialog->popup_centered_minsize(); return; ///beh should show an error i guess } @@ -87,7 +87,7 @@ void ResourcePreloaderEditor::_files_load_request(const Vector<String>& p_paths) name=basename+" "+itos(counter); } - undo_redo->create_action("Add Resource"); + undo_redo->create_action(TTR("Add Resource")); undo_redo->add_do_method(preloader,"add_resource",name,resource); undo_redo->add_undo_method(preloader,"remove_resource",name); undo_redo->add_do_method(this,"_update_library"); @@ -134,7 +134,7 @@ void ResourcePreloaderEditor::_item_edited() { } RES samp = preloader->get_resource(old_name); - undo_redo->create_action("Rename Resource"); + undo_redo->create_action(TTR("Rename Resource")); undo_redo->add_do_method(preloader,"remove_resource",old_name); undo_redo->add_do_method(preloader,"add_resource",new_name,samp); undo_redo->add_undo_method(preloader,"remove_resource",new_name); @@ -154,7 +154,7 @@ void ResourcePreloaderEditor::_delete_confirm_pressed() { return; String to_remove = tree->get_selected()->get_text(0); - undo_redo->create_action("Delete Resource"); + undo_redo->create_action(TTR("Delete Resource")); undo_redo->add_do_method(preloader,"remove_resource",to_remove); undo_redo->add_undo_method(preloader,"add_resource",to_remove,preloader->get_resource(to_remove)); undo_redo->add_do_method(this,"_update_library"); @@ -167,10 +167,10 @@ void ResourcePreloaderEditor::_paste_pressed() { RES r=EditorSettings::get_singleton()->get_resource_clipboard(); if (!r.is_valid()) { - dialog->set_text("Resource clipboard is empty!"); - dialog->set_title("Error!"); - //dialog->get_cancel()->set_text("Close"); - dialog->get_ok()->set_text("Close"); + dialog->set_text(TTR("Resource clipboard is empty!")); + dialog->set_title(TTR("Error!")); + //dialog->get_cancel()->set_text(TTR("Close")); + dialog->get_ok()->set_text(TTR("Close")); dialog->popup_centered_minsize(); return; ///beh should show an error i guess } @@ -188,7 +188,7 @@ void ResourcePreloaderEditor::_paste_pressed() { name=basename+" "+itos(counter); } - undo_redo->create_action("Paste Resource"); + undo_redo->create_action(TTR("Paste Resource")); undo_redo->add_do_method(preloader,"add_resource",name,r); undo_redo->add_undo_method(preloader,"remove_resource",name); undo_redo->add_do_method(this,"_update_library"); @@ -206,11 +206,11 @@ void ResourcePreloaderEditor::_delete_pressed() { _delete_confirm_pressed(); //it has undo.. why bother with a dialog.. /* - dialog->set_title("Confirm..."); - dialog->set_text("Remove Resource '"+tree->get_selected()->get_text(0)+"' ?"); - //dialog->get_cancel()->set_text("Cancel"); + dialog->set_title(TTR("Confirm...")); + dialog->set_text(TTR("Remove Resource '")+tree->get_selected()->get_text(0)+"' ?"); + //dialog->get_cancel()->set_text(TTR("Cancel")); //dialog->get_ok()->show(); - dialog->get_ok()->set_text("Remove"); + dialog->get_ok()->set_text(TTR("Remove")); dialog->popup_centered(Size2(300,60));*/ } @@ -302,7 +302,7 @@ ResourcePreloaderEditor::ResourcePreloaderEditor() { vbc->add_child(hbc); load = memnew( Button ); - load->set_tooltip("Load Resource"); + load->set_tooltip(TTR("Load Resource")); hbc->add_child(load); @@ -311,7 +311,7 @@ ResourcePreloaderEditor::ResourcePreloaderEditor() { hbc->add_child(_delete); paste = memnew( Button ); - paste->set_text("Paste"); + paste->set_text(TTR("Paste")); hbc->add_child(paste); file = memnew( EditorFileDialog ); diff --git a/tools/editor/plugins/rich_text_editor_plugin.cpp b/tools/editor/plugins/rich_text_editor_plugin.cpp index 08374d6624..99d75dff1d 100644 --- a/tools/editor/plugins/rich_text_editor_plugin.cpp +++ b/tools/editor/plugins/rich_text_editor_plugin.cpp @@ -106,9 +106,9 @@ RichTextEditor::RichTextEditor() { CanvasItemEditor::get_singleton()->add_control_to_menu_panel(options); options->set_area_as_parent_rect(); - options->set_text("RichText"); - options->get_popup()->add_item("Parse BBCODE",PARSE_BBCODE); - options->get_popup()->add_item("Clear",CLEAR); + options->set_text(TTR("RichText")); + options->get_popup()->add_item(TTR("Parse BBCODE"),PARSE_BBCODE); + options->get_popup()->add_item(TTR("Clear"),CLEAR); options->get_popup()->connect("item_pressed", this,"_menu_option"); file_dialog = memnew( EditorFileDialog ); diff --git a/tools/editor/plugins/rich_text_editor_plugin.h b/tools/editor/plugins/rich_text_editor_plugin.h index ae1d04be01..0196a30332 100644 --- a/tools/editor/plugins/rich_text_editor_plugin.h +++ b/tools/editor/plugins/rich_text_editor_plugin.h @@ -77,7 +77,7 @@ class RichTextEditorPlugin : public EditorPlugin { public: - virtual String get_name() const { return "RichText"; } + virtual String get_name() const { return TTR("RichText"); } bool has_main_screen() const { return false; } virtual void edit(Object *p_node); virtual bool handles(Object *p_node) const; diff --git a/tools/editor/plugins/sample_editor_plugin.cpp b/tools/editor/plugins/sample_editor_plugin.cpp index ffa39bd010..8c5036b424 100644 --- a/tools/editor/plugins/sample_editor_plugin.cpp +++ b/tools/editor/plugins/sample_editor_plugin.cpp @@ -328,7 +328,7 @@ void SampleEditor::_update_sample() { return; //bye or unsupported generate_preview_texture(sample,peakdisplay); - info_label->set_text("Length: "+itos(sample->get_length())+" frames ("+String::num(sample->get_length()/(float)sample->get_mix_rate(),2)+" s), "+(sample->get_format()==Sample::FORMAT_PCM16?"16 Bits, ":"8 bits, ")+(sample->is_stereo()?"Stereo.":"Mono.")); + info_label->set_text(TTR("Length: ")+itos(sample->get_length())+" frames ("+String::num(sample->get_length()/(float)sample->get_mix_rate(),2)+" s), "+(sample->get_format()==Sample::FORMAT_PCM16?"16 Bits, ":"8 bits, ")+(sample->is_stereo()?"Stereo.":"Mono.")); library->add_sample("default",sample); } diff --git a/tools/editor/plugins/sample_library_editor_plugin.cpp b/tools/editor/plugins/sample_library_editor_plugin.cpp index f15a2834ca..0ab45b45c4 100644 --- a/tools/editor/plugins/sample_library_editor_plugin.cpp +++ b/tools/editor/plugins/sample_library_editor_plugin.cpp @@ -53,7 +53,7 @@ void SampleLibraryEditor::_notification(int p_what) { if (p_what==NOTIFICATION_ENTER_TREE) { load->set_icon( get_icon("Folder","EditorIcons") ); - load->set_tooltip("Open Sample File(s)"); + load->set_tooltip(TTR("Open Sample File(s)")); } if (p_what==NOTIFICATION_READY) { @@ -74,10 +74,10 @@ void SampleLibraryEditor::_file_load_request(const DVector<String>& p_path) { String path = p_path[i]; Ref<Sample> sample = ResourceLoader::load(path,"Sample"); if (sample.is_null()) { - dialog->set_text("ERROR: Couldn't load sample!"); - dialog->set_title("Error!"); - //dialog->get_cancel()->set_text("Close"); - dialog->get_ok()->set_text("Close"); + dialog->set_text(TTR("ERROR: Couldn't load sample!")); + dialog->set_title(TTR("Error!")); + //dialog->get_cancel()->set_text(TTR("Close")); + dialog->get_ok()->set_text(TTR("Close")); dialog->popup_centered_minsize(); return; ///beh should show an error i guess } @@ -89,7 +89,7 @@ void SampleLibraryEditor::_file_load_request(const DVector<String>& p_path) { name=basename+"_"+itos(counter); } - undo_redo->create_action("Add Sample"); + undo_redo->create_action(TTR("Add Sample")); undo_redo->add_do_method(sample_library.operator->(),"add_sample",name,sample); undo_redo->add_undo_method(sample_library.operator->(),"remove_sample",name); undo_redo->add_do_method(this,"_update_library"); @@ -114,7 +114,7 @@ void SampleLibraryEditor::_button_pressed(Object *p_item,int p_column, int p_id) String btn_type; if(!is_playing) { is_playing = true; - btn_type = "Stop"; + btn_type = TTR("Stop"); player->play(name,true); last_sample_playing = p_item; set_process(true); @@ -123,11 +123,11 @@ void SampleLibraryEditor::_button_pressed(Object *p_item,int p_column, int p_id) if(last_sample_playing != p_item){ TreeItem *tl=last_sample_playing->cast_to<TreeItem>(); tl->set_button(p_column,0,get_icon("Play","EditorIcons")); - btn_type = "Stop"; + btn_type = TTR("Stop"); player->play(name,true); last_sample_playing = p_item; } else { - btn_type = "Play"; + btn_type = TTR("Play"); is_playing = false; } } @@ -169,7 +169,7 @@ void SampleLibraryEditor::_item_edited() { } Ref<Sample> samp = sample_library->get_sample(old_name); - undo_redo->create_action("Rename Sample"); + undo_redo->create_action(TTR("Rename Sample")); undo_redo->add_do_method(sample_library.operator->(),"remove_sample",old_name); undo_redo->add_do_method(sample_library.operator->(),"add_sample",new_name,samp); undo_redo->add_undo_method(sample_library.operator->(),"remove_sample",new_name); @@ -199,7 +199,7 @@ void SampleLibraryEditor::_delete_pressed() { return; String to_remove = tree->get_selected()->get_text(0); - undo_redo->create_action("Delete Sample"); + undo_redo->create_action(TTR("Delete Sample")); undo_redo->add_do_method(sample_library.operator->(),"remove_sample",to_remove); undo_redo->add_undo_method(sample_library.operator->(),"add_sample",to_remove,sample_library->get_sample(to_remove)); undo_redo->add_do_method(this,"_update_library"); @@ -248,7 +248,7 @@ void SampleLibraryEditor::_update_library() { ti->set_cell_mode(2,TreeItem::CELL_MODE_STRING); ti->set_editable(2,false); ti->set_selectable(2,false); - ti->set_text(2,String()+/*itos(smp->get_length())+" frames ("+String::num(smp->get_length()/(float)smp->get_mix_rate(),2)+" smp), "+*/(smp->get_format()==Sample::FORMAT_PCM16?"16 Bits, ":(smp->get_format()==Sample::FORMAT_PCM8?"8 bits, ":"IMA-ADPCM,"))+(smp->is_stereo()?"Stereo":"Mono")); + ti->set_text(2,String()+/*itos(smp->get_length())+" frames ("+String::num(smp->get_length()/(float)smp->get_mix_rate(),2)+" smp), "+*/(smp->get_format()==Sample::FORMAT_PCM16?"16 Bits, ":(smp->get_format()==Sample::FORMAT_PCM8?"8 bits, ":TTR("IMA-ADPCM,")))+(smp->is_stereo()?"Stereo":"Mono")); // Volume dB ti->set_cell_mode(3,TreeItem::CELL_MODE_RANGE); @@ -331,9 +331,9 @@ SampleLibraryEditor::SampleLibraryEditor() { tree->set_anchor_and_margin(MARGIN_TOP,ANCHOR_BEGIN,30); tree->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END,5); tree->set_column_titles_visible(true); - tree->set_column_title(0,"Name"); - tree->set_column_title(1,"Preview"); - tree->set_column_title(2,"Format"); + tree->set_column_title(0,TTR("Name")); + tree->set_column_title(1,TTR("Preview")); + tree->set_column_title(2,TTR("Format")); tree->set_column_title(3,"dB"); tree->set_column_title(4,"Pitch"); tree->set_column_title(5,""); diff --git a/tools/editor/plugins/sample_player_editor_plugin.cpp b/tools/editor/plugins/sample_player_editor_plugin.cpp index 3085ad87d8..fd6e800b42 100644 --- a/tools/editor/plugins/sample_player_editor_plugin.cpp +++ b/tools/editor/plugins/sample_player_editor_plugin.cpp @@ -76,7 +76,7 @@ void SamplePlayerEditor::_stop() { return; node->call("stop_all"); - print_line("STOP ALL!!"); + print_line(TTR("STOP ALL!!")); stop->set_pressed(true); play->set_pressed(false); diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index 6515b9b69e..eaf08ca1c0 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -223,12 +223,12 @@ ScriptEditorQuickOpen::ScriptEditorQuickOpen() { add_child(vbc); set_child_rect(vbc); search_box = memnew( LineEdit ); - vbc->add_margin_child("Search:",search_box); + vbc->add_margin_child(TTR("Search:"),search_box); search_box->connect("text_changed",this,"_text_changed"); search_box->connect("input_event",this,"_sbox_input"); search_options = memnew( Tree ); - vbc->add_margin_child("Matches:",search_options,true); - get_ok()->set_text("Open"); + vbc->add_margin_child(TTR("Matches:"),search_options,true); + get_ok()->set_text(TTR("Open")); get_ok()->set_disabled(true); register_text_enter(search_box); set_hide_on_ok(false); @@ -2214,7 +2214,6 @@ void ScriptEditor::get_window_layout(Ref<ConfigFile> p_layout) { p_layout->set_value("ScriptEditor","open_scripts",scripts); p_layout->set_value("ScriptEditor","open_help",helps); p_layout->set_value("ScriptEditor","split_offset",script_split->get_split_offset()); - } @@ -2400,82 +2399,82 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { file_menu = memnew( MenuButton ); menu_hb->add_child(file_menu); - file_menu->set_text("File"); - file_menu->get_popup()->add_item("New",FILE_NEW); - file_menu->get_popup()->add_item("Open",FILE_OPEN); + file_menu->set_text(TTR("File")); + file_menu->get_popup()->add_item(TTR("New"),FILE_NEW); + file_menu->get_popup()->add_item(TTR("Open"),FILE_OPEN); file_menu->get_popup()->add_separator(); - file_menu->get_popup()->add_item("Save",FILE_SAVE,KEY_MASK_ALT|KEY_MASK_CMD|KEY_S); - file_menu->get_popup()->add_item("Save As..",FILE_SAVE_AS); - file_menu->get_popup()->add_item("Save All",FILE_SAVE_ALL,KEY_MASK_CMD|KEY_MASK_SHIFT|KEY_S); + file_menu->get_popup()->add_item(TTR("Save"),FILE_SAVE,KEY_MASK_ALT|KEY_MASK_CMD|KEY_S); + file_menu->get_popup()->add_item(TTR("Save As.."),FILE_SAVE_AS); + file_menu->get_popup()->add_item(TTR("Save All"),FILE_SAVE_ALL,KEY_MASK_CMD|KEY_MASK_SHIFT|KEY_S); file_menu->get_popup()->add_separator(); - file_menu->get_popup()->add_item("History Prev",WINDOW_PREV,KEY_MASK_CTRL|KEY_MASK_ALT|KEY_LEFT); - file_menu->get_popup()->add_item("History Next",WINDOW_NEXT,KEY_MASK_CTRL|KEY_MASK_ALT|KEY_RIGHT); + file_menu->get_popup()->add_item(TTR("History Prev"),WINDOW_PREV,KEY_MASK_CTRL|KEY_MASK_ALT|KEY_LEFT); + file_menu->get_popup()->add_item(TTR("History Next"),WINDOW_NEXT,KEY_MASK_CTRL|KEY_MASK_ALT|KEY_RIGHT); file_menu->get_popup()->add_separator(); - file_menu->get_popup()->add_item("Close",FILE_CLOSE,KEY_MASK_CMD|KEY_W); + file_menu->get_popup()->add_item(TTR("Close"),FILE_CLOSE,KEY_MASK_CMD|KEY_W); file_menu->get_popup()->connect("item_pressed", this,"_menu_option"); edit_menu = memnew( MenuButton ); menu_hb->add_child(edit_menu); - edit_menu->set_text("Edit"); - edit_menu->get_popup()->add_item("Undo",EDIT_UNDO,KEY_MASK_CMD|KEY_Z); - edit_menu->get_popup()->add_item("Redo",EDIT_REDO,KEY_MASK_CMD|KEY_Y); + edit_menu->set_text(TTR("Edit")); + edit_menu->get_popup()->add_item(TTR("Undo"),EDIT_UNDO,KEY_MASK_CMD|KEY_Z); + edit_menu->get_popup()->add_item(TTR("Redo"),EDIT_REDO,KEY_MASK_CMD|KEY_Y); edit_menu->get_popup()->add_separator(); - edit_menu->get_popup()->add_item("Cut",EDIT_CUT,KEY_MASK_CMD|KEY_X); - edit_menu->get_popup()->add_item("Copy",EDIT_COPY,KEY_MASK_CMD|KEY_C); - edit_menu->get_popup()->add_item("Paste",EDIT_PASTE,KEY_MASK_CMD|KEY_V); + edit_menu->get_popup()->add_item(TTR("Cut"),EDIT_CUT,KEY_MASK_CMD|KEY_X); + edit_menu->get_popup()->add_item(TTR("Copy"),EDIT_COPY,KEY_MASK_CMD|KEY_C); + edit_menu->get_popup()->add_item(TTR("Paste"),EDIT_PASTE,KEY_MASK_CMD|KEY_V); edit_menu->get_popup()->add_separator(); - edit_menu->get_popup()->add_item("Select All",EDIT_SELECT_ALL,KEY_MASK_CMD|KEY_A); + edit_menu->get_popup()->add_item(TTR("Select All"),EDIT_SELECT_ALL,KEY_MASK_CMD|KEY_A); edit_menu->get_popup()->add_separator(); - edit_menu->get_popup()->add_item("Move Up",EDIT_MOVE_LINE_UP,KEY_MASK_ALT|KEY_UP); - edit_menu->get_popup()->add_item("Move Down",EDIT_MOVE_LINE_DOWN,KEY_MASK_ALT|KEY_DOWN); - edit_menu->get_popup()->add_item("Indent Left",EDIT_INDENT_LEFT,KEY_MASK_ALT|KEY_LEFT); - edit_menu->get_popup()->add_item("Indent Right",EDIT_INDENT_RIGHT,KEY_MASK_ALT|KEY_RIGHT); - edit_menu->get_popup()->add_item("Toggle Comment",EDIT_TOGGLE_COMMENT,KEY_MASK_CMD|KEY_K); - edit_menu->get_popup()->add_item("Clone Down",EDIT_CLONE_DOWN,KEY_MASK_CMD|KEY_B); + edit_menu->get_popup()->add_item(TTR("Move Up"),EDIT_MOVE_LINE_UP,KEY_MASK_ALT|KEY_UP); + edit_menu->get_popup()->add_item(TTR("Move Down"),EDIT_MOVE_LINE_DOWN,KEY_MASK_ALT|KEY_DOWN); + edit_menu->get_popup()->add_item(TTR("Indent Left"),EDIT_INDENT_LEFT,KEY_MASK_ALT|KEY_LEFT); + edit_menu->get_popup()->add_item(TTR("Indent Right"),EDIT_INDENT_RIGHT,KEY_MASK_ALT|KEY_RIGHT); + edit_menu->get_popup()->add_item(TTR("Toggle Comment"),EDIT_TOGGLE_COMMENT,KEY_MASK_CMD|KEY_K); + edit_menu->get_popup()->add_item(TTR("Clone Down"),EDIT_CLONE_DOWN,KEY_MASK_CMD|KEY_B); edit_menu->get_popup()->add_separator(); #ifdef OSX_ENABLED - edit_menu->get_popup()->add_item("Complete Symbol",EDIT_COMPLETE,KEY_MASK_CTRL|KEY_SPACE); + edit_menu->get_popup()->add_item(TTR("Complete Symbol"),EDIT_COMPLETE,KEY_MASK_CTRL|KEY_SPACE); #else - edit_menu->get_popup()->add_item("Complete Symbol",EDIT_COMPLETE,KEY_MASK_CMD|KEY_SPACE); + edit_menu->get_popup()->add_item(TTR("Complete Symbol"),EDIT_COMPLETE,KEY_MASK_CMD|KEY_SPACE); #endif edit_menu->get_popup()->add_item("Trim Trailing Whitespace", EDIT_TRIM_TRAILING_WHITESAPCE, KEY_MASK_CTRL|KEY_MASK_ALT|KEY_T); - edit_menu->get_popup()->add_item("Auto Indent",EDIT_AUTO_INDENT,KEY_MASK_CMD|KEY_I); + edit_menu->get_popup()->add_item(TTR("Auto Indent"),EDIT_AUTO_INDENT,KEY_MASK_CMD|KEY_I); edit_menu->get_popup()->connect("item_pressed", this,"_menu_option"); search_menu = memnew( MenuButton ); menu_hb->add_child(search_menu); - search_menu->set_text("Search"); - search_menu->get_popup()->add_item("Find..",SEARCH_FIND,KEY_MASK_CMD|KEY_F); - search_menu->get_popup()->add_item("Find Next",SEARCH_FIND_NEXT,KEY_F3); - search_menu->get_popup()->add_item("Replace..",SEARCH_REPLACE,KEY_MASK_CMD|KEY_R); + search_menu->set_text(TTR("Search")); + search_menu->get_popup()->add_item(TTR("Find.."),SEARCH_FIND,KEY_MASK_CMD|KEY_F); + search_menu->get_popup()->add_item(TTR("Find Next"),SEARCH_FIND_NEXT,KEY_F3); + search_menu->get_popup()->add_item(TTR("Replace.."),SEARCH_REPLACE,KEY_MASK_CMD|KEY_R); search_menu->get_popup()->add_separator(); - search_menu->get_popup()->add_item("Goto Function..",SEARCH_LOCATE_FUNCTION,KEY_MASK_SHIFT|KEY_MASK_CMD|KEY_F); - search_menu->get_popup()->add_item("Goto Line..",SEARCH_GOTO_LINE,KEY_MASK_CMD|KEY_L); + search_menu->get_popup()->add_item(TTR("Goto Function.."),SEARCH_LOCATE_FUNCTION,KEY_MASK_SHIFT|KEY_MASK_CMD|KEY_F); + search_menu->get_popup()->add_item(TTR("Goto Line.."),SEARCH_GOTO_LINE,KEY_MASK_CMD|KEY_L); search_menu->get_popup()->connect("item_pressed", this,"_menu_option"); script_search_menu = memnew( MenuButton ); menu_hb->add_child(script_search_menu); - script_search_menu->set_text("Search"); - script_search_menu->get_popup()->add_item("Find..",SEARCH_FIND,KEY_MASK_CMD|KEY_F); - script_search_menu->get_popup()->add_item("Find Next",SEARCH_FIND_NEXT,KEY_F3); + script_search_menu->set_text(TTR("Search")); + script_search_menu->get_popup()->add_item(TTR("Find.."),SEARCH_FIND,KEY_MASK_CMD|KEY_F); + script_search_menu->get_popup()->add_item(TTR("Find Next"),SEARCH_FIND_NEXT,KEY_F3); script_search_menu->get_popup()->connect("item_pressed", this,"_menu_option"); script_search_menu->hide(); debug_menu = memnew( MenuButton ); menu_hb->add_child(debug_menu); - debug_menu->set_text("Debug"); - debug_menu->get_popup()->add_item("Toggle Breakpoint",DEBUG_TOGGLE_BREAKPOINT,KEY_F9); + debug_menu->set_text(TTR("Debug")); + debug_menu->get_popup()->add_item(TTR("Toggle Breakpoint"),DEBUG_TOGGLE_BREAKPOINT,KEY_F9); debug_menu->get_popup()->add_separator(); - debug_menu->get_popup()->add_item("Step Over",DEBUG_NEXT,KEY_F10); - debug_menu->get_popup()->add_item("Step Into",DEBUG_STEP,KEY_F11); + debug_menu->get_popup()->add_item(TTR("Step Over"),DEBUG_NEXT,KEY_F10); + debug_menu->get_popup()->add_item(TTR("Step Into"),DEBUG_STEP,KEY_F11); debug_menu->get_popup()->add_separator(); - debug_menu->get_popup()->add_item("Break",DEBUG_BREAK); - debug_menu->get_popup()->add_item("Continue",DEBUG_CONTINUE); + debug_menu->get_popup()->add_item(TTR("Break"),DEBUG_BREAK); + debug_menu->get_popup()->add_item(TTR("Continue"),DEBUG_CONTINUE); debug_menu->get_popup()->add_separator(); - //debug_menu->get_popup()->add_check_item("Show Debugger",DEBUG_SHOW); - debug_menu->get_popup()->add_check_item("Keep Debugger Open",DEBUG_SHOW_KEEP_OPEN); + //debug_menu->get_popup()->add_check_item(TTR("Show Debugger"),DEBUG_SHOW); + debug_menu->get_popup()->add_check_item(TTR("Keep Debugger Open"),DEBUG_SHOW_KEEP_OPEN); debug_menu->get_popup()->connect("item_pressed", this,"_menu_option"); debug_menu->get_popup()->set_item_disabled( debug_menu->get_popup()->get_item_index(DEBUG_NEXT), true); @@ -2487,11 +2486,11 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { #if 0 window_menu = memnew( MenuButton ); menu_hb->add_child(window_menu); - window_menu->set_text("Window"); - window_menu->get_popup()->add_item("Close",WINDOW_CLOSE,KEY_MASK_CMD|KEY_W); + window_menu->set_text(TTR("Window")); + window_menu->get_popup()->add_item(TTR("Close"),WINDOW_CLOSE,KEY_MASK_CMD|KEY_W); window_menu->get_popup()->add_separator(); - window_menu->get_popup()->add_item("Move Left",WINDOW_MOVE_LEFT,KEY_MASK_CMD|KEY_LEFT); - window_menu->get_popup()->add_item("Move Right",WINDOW_MOVE_RIGHT,KEY_MASK_CMD|KEY_RIGHT); + window_menu->get_popup()->add_item(TTR("Move Left"),WINDOW_MOVE_LEFT,KEY_MASK_CMD|KEY_LEFT); + window_menu->get_popup()->add_item(TTR("Move Right"),WINDOW_MOVE_RIGHT,KEY_MASK_CMD|KEY_RIGHT); window_menu->get_popup()->add_separator(); window_menu->get_popup()->connect("item_pressed", this,"_menu_option"); @@ -2499,8 +2498,8 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { help_menu = memnew( MenuButton ); menu_hb->add_child(help_menu); - help_menu->set_text("Help"); - help_menu->get_popup()->add_item("Contextual", HELP_CONTEXTUAL, KEY_MASK_SHIFT|KEY_F1); + help_menu->set_text(TTR("Help")); + help_menu->get_popup()->add_item(TTR("Contextual"), HELP_CONTEXTUAL, KEY_MASK_SHIFT|KEY_F1); help_menu->get_popup()->connect("item_pressed", this,"_menu_option"); menu_hb->add_spacer(); @@ -2517,22 +2516,22 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { menu_hb->add_spacer(); site_search = memnew( ToolButton ); - site_search->set_text("Tutorials"); + site_search->set_text(TTR("Tutorials")); site_search->connect("pressed",this,"_menu_option",varray(SEARCH_WEBSITE)); menu_hb->add_child(site_search); - site_search->set_tooltip("Open http://www.godotengine.org at tutorials section."); + site_search->set_tooltip(TTR("Open http://www.godotengine.org at tutorials section.")); class_search = memnew( ToolButton ); - class_search->set_text("Classes"); + class_search->set_text(TTR("Classes")); class_search->connect("pressed",this,"_menu_option",varray(SEARCH_CLASSES)); menu_hb->add_child(class_search); - class_search->set_tooltip("Search the class hierarchy."); + class_search->set_tooltip(TTR("Search the class hierarchy.")); help_search = memnew( ToolButton ); - help_search->set_text("Search Help"); + help_search->set_text(TTR("Search Help")); help_search->connect("pressed",this,"_menu_option",varray(SEARCH_HELP)); menu_hb->add_child(help_search); - help_search->set_tooltip("Search the reference documentation."); + help_search->set_tooltip(TTR("Search the reference documentation.")); menu_hb->add_child( memnew( VSeparator) ); @@ -2540,13 +2539,13 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { script_back->connect("pressed",this,"_history_back"); menu_hb->add_child(script_back); script_back->set_disabled(true); - script_back->set_tooltip("Go to previous edited document."); + script_back->set_tooltip(TTR("Go to previous edited document.")); script_forward = memnew( ToolButton ); script_forward->connect("pressed",this,"_history_forward"); menu_hb->add_child(script_forward); script_forward->set_disabled(true); - script_forward->set_tooltip("Go to next edited document."); + script_forward->set_tooltip(TTR("Go to next edited document.")); @@ -2560,7 +2559,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { erase_tab_confirm->connect("confirmed", this,"_close_current_tab"); script_create_dialog = memnew(ScriptCreateDialog); - script_create_dialog->set_title("Create Script"); + script_create_dialog->set_title(TTR("Create Script")); add_child(script_create_dialog); script_create_dialog->connect("script_created", this, "_script_created"); @@ -2586,9 +2585,9 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { disk_changed_list->set_v_size_flags(SIZE_EXPAND_FILL); disk_changed->connect("confirmed",this,"_reload_scripts"); - disk_changed->get_ok()->set_text("Reload"); + disk_changed->get_ok()->set_text(TTR("Reload")); - disk_changed->add_button("Resave",!OS::get_singleton()->get_swap_ok_cancel(),"resave"); + disk_changed->add_button(TTR("Resave"),!OS::get_singleton()->get_swap_ok_cancel(),"resave"); disk_changed->connect("custom_action",this,"_resave_scripts"); @@ -2604,7 +2603,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { quick_open->connect("goto_line",this,"_goto_script_line2"); - Button *db = EditorNode::get_singleton()->add_bottom_panel_item("Debugger",debugger); + Button *db = EditorNode::get_singleton()->add_bottom_panel_item(TTR("Debugger"),debugger); debugger->set_tool_button(db); diff --git a/tools/editor/plugins/shader_editor_plugin.cpp b/tools/editor/plugins/shader_editor_plugin.cpp index d1e892a513..3399114402 100644 --- a/tools/editor/plugins/shader_editor_plugin.cpp +++ b/tools/editor/plugins/shader_editor_plugin.cpp @@ -481,28 +481,28 @@ ShaderEditor::ShaderEditor() { edit_menu = memnew( MenuButton ); add_child(edit_menu); edit_menu->set_pos(Point2(5,-1)); - edit_menu->set_text("Edit"); - edit_menu->get_popup()->add_item("Undo",EDIT_UNDO,KEY_MASK_CMD|KEY_Z); - edit_menu->get_popup()->add_item("Redo",EDIT_REDO,KEY_MASK_CMD|KEY_MASK_SHIFT|KEY_Z); + edit_menu->set_text(TTR("Edit")); + edit_menu->get_popup()->add_item(TTR("Undo"),EDIT_UNDO,KEY_MASK_CMD|KEY_Z); + edit_menu->get_popup()->add_item(TTR("Redo"),EDIT_REDO,KEY_MASK_CMD|KEY_MASK_SHIFT|KEY_Z); edit_menu->get_popup()->add_separator(); - edit_menu->get_popup()->add_item("Cut",EDIT_CUT,KEY_MASK_CMD|KEY_X); - edit_menu->get_popup()->add_item("Copy",EDIT_COPY,KEY_MASK_CMD|KEY_C); - edit_menu->get_popup()->add_item("Paste",EDIT_PASTE,KEY_MASK_CMD|KEY_V); + edit_menu->get_popup()->add_item(TTR("Cut"),EDIT_CUT,KEY_MASK_CMD|KEY_X); + edit_menu->get_popup()->add_item(TTR("Copy"),EDIT_COPY,KEY_MASK_CMD|KEY_C); + edit_menu->get_popup()->add_item(TTR("Paste"),EDIT_PASTE,KEY_MASK_CMD|KEY_V); edit_menu->get_popup()->add_separator(); - edit_menu->get_popup()->add_item("Select All",EDIT_SELECT_ALL,KEY_MASK_CMD|KEY_A); + edit_menu->get_popup()->add_item(TTR("Select All"),EDIT_SELECT_ALL,KEY_MASK_CMD|KEY_A); edit_menu->get_popup()->connect("item_pressed", this,"_menu_option"); search_menu = memnew( MenuButton ); add_child(search_menu); search_menu->set_pos(Point2(38,-1)); - search_menu->set_text("Search"); - search_menu->get_popup()->add_item("Find..",SEARCH_FIND,KEY_MASK_CMD|KEY_F); - search_menu->get_popup()->add_item("Find Next",SEARCH_FIND_NEXT,KEY_F3); - search_menu->get_popup()->add_item("Replace..",SEARCH_REPLACE,KEY_MASK_CMD|KEY_R); + search_menu->set_text(TTR("Search")); + search_menu->get_popup()->add_item(TTR("Find.."),SEARCH_FIND,KEY_MASK_CMD|KEY_F); + search_menu->get_popup()->add_item(TTR("Find Next"),SEARCH_FIND_NEXT,KEY_F3); + search_menu->get_popup()->add_item(TTR("Replace.."),SEARCH_REPLACE,KEY_MASK_CMD|KEY_R); search_menu->get_popup()->add_separator(); -// search_menu->get_popup()->add_item("Locate Symbol..",SEARCH_LOCATE_SYMBOL,KEY_MASK_CMD|KEY_K); - search_menu->get_popup()->add_item("Goto Line..",SEARCH_GOTO_LINE,KEY_MASK_CMD|KEY_G); +// search_menu->get_popup()->add_item(TTR("Locate Symbol.."),SEARCH_LOCATE_SYMBOL,KEY_MASK_CMD|KEY_K); + search_menu->get_popup()->add_item(TTR("Goto Line.."),SEARCH_GOTO_LINE,KEY_MASK_CMD|KEY_G); search_menu->get_popup()->connect("item_pressed", this,"_menu_option"); @@ -521,15 +521,15 @@ ShaderEditor::ShaderEditor() { vertex_editor = memnew( ShaderTextEditor ); tab_container->add_child(vertex_editor); - vertex_editor->set_name("Vertex"); + vertex_editor->set_name(TTR("Vertex")); fragment_editor = memnew( ShaderTextEditor ); tab_container->add_child(fragment_editor); - fragment_editor->set_name("Fragment"); + fragment_editor->set_name(TTR("Fragment")); light_editor = memnew( ShaderTextEditor ); tab_container->add_child(light_editor); - light_editor->set_name("Lighting"); + light_editor->set_name(TTR("Lighting")); tab_container->set_current_tab(1); diff --git a/tools/editor/plugins/shader_graph_editor_plugin.cpp b/tools/editor/plugins/shader_graph_editor_plugin.cpp index 36a8c79b84..f618f41cf8 100644 --- a/tools/editor/plugins/shader_graph_editor_plugin.cpp +++ b/tools/editor/plugins/shader_graph_editor_plugin.cpp @@ -674,7 +674,7 @@ GraphCurveMapEdit::GraphCurveMapEdit(){ void ShaderGraphView::_scalar_const_changed(double p_value,int p_id) { UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo(); - ur->create_action("Change Scalar Constant",true); + ur->create_action(TTR("Change Scalar Constant"),true); ur->add_do_method(graph.ptr(),"scalar_const_node_set_value",type,p_id,p_value); ur->add_undo_method(graph.ptr(),"scalar_const_node_set_value",type,p_id,graph->scalar_const_node_get_value(type,p_id)); ur->add_do_method(this,"_update_graph"); @@ -692,7 +692,7 @@ void ShaderGraphView::_vec_const_changed(double p_value, int p_id,Array p_arr){ } UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo(); - ur->create_action("Change Vec Constant",true); + ur->create_action(TTR("Change Vec Constant"),true); ur->add_do_method(graph.ptr(),"vec_const_node_set_value",type,p_id,val); ur->add_undo_method(graph.ptr(),"vec_const_node_set_value",type,p_id,graph->vec_const_node_get_value(type,p_id)); ur->add_do_method(this,"_update_graph"); @@ -705,7 +705,7 @@ void ShaderGraphView::_vec_const_changed(double p_value, int p_id,Array p_arr){ void ShaderGraphView::_rgb_const_changed(const Color& p_color, int p_id){ UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo(); - ur->create_action("Change RGB Constant",true); + ur->create_action(TTR("Change RGB Constant"),true); ur->add_do_method(graph.ptr(),"rgb_const_node_set_value",type,p_id,p_color); ur->add_undo_method(graph.ptr(),"rgb_const_node_set_value",type,p_id,graph->rgb_const_node_get_value(type,p_id)); ur->add_do_method(this,"_update_graph"); @@ -718,7 +718,7 @@ void ShaderGraphView::_rgb_const_changed(const Color& p_color, int p_id){ void ShaderGraphView::_scalar_op_changed(int p_op, int p_id){ UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo(); - ur->create_action("Change Scalar Operator"); + ur->create_action(TTR("Change Scalar Operator")); ur->add_do_method(graph.ptr(),"scalar_op_node_set_op",type,p_id,p_op); ur->add_undo_method(graph.ptr(),"scalar_op_node_set_op",type,p_id,graph->scalar_op_node_get_op(type,p_id)); ur->add_do_method(this,"_update_graph"); @@ -731,7 +731,7 @@ void ShaderGraphView::_scalar_op_changed(int p_op, int p_id){ void ShaderGraphView::_vec_op_changed(int p_op, int p_id){ UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo(); - ur->create_action("Change Vec Operator"); + ur->create_action(TTR("Change Vec Operator")); ur->add_do_method(graph.ptr(),"vec_op_node_set_op",type,p_id,p_op); ur->add_undo_method(graph.ptr(),"vec_op_node_set_op",type,p_id,graph->vec_op_node_get_op(type,p_id)); ur->add_do_method(this,"_update_graph"); @@ -743,7 +743,7 @@ void ShaderGraphView::_vec_op_changed(int p_op, int p_id){ void ShaderGraphView::_vec_scalar_op_changed(int p_op, int p_id){ UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo(); - ur->create_action("Change VecxScalar Operator"); + ur->create_action(TTR("Change VecxScalar Operator")); ur->add_do_method(graph.ptr(),"vec_scalar_op_node_set_op",type,p_id,p_op); ur->add_undo_method(graph.ptr(),"vec_scalar_op_node_set_op",type,p_id,graph->vec_scalar_op_node_get_op(type,p_id)); ur->add_do_method(this,"_update_graph"); @@ -756,7 +756,7 @@ void ShaderGraphView::_vec_scalar_op_changed(int p_op, int p_id){ void ShaderGraphView::_rgb_op_changed(int p_op, int p_id){ UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo(); - ur->create_action("Change RGB Operator"); + ur->create_action(TTR("Change RGB Operator")); ur->add_do_method(graph.ptr(),"rgb_op_node_set_op",type,p_id,p_op); ur->add_undo_method(graph.ptr(),"rgb_op_node_set_op",type,p_id,graph->rgb_op_node_get_op(type,p_id)); ur->add_do_method(this,"_update_graph"); @@ -768,7 +768,7 @@ void ShaderGraphView::_rgb_op_changed(int p_op, int p_id){ void ShaderGraphView::_xform_inv_rev_changed(bool p_enabled, int p_id){ UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo(); - ur->create_action("Toggle Rot Only"); + ur->create_action(TTR("Toggle Rot Only")); ur->add_do_method(graph.ptr(),"xform_vec_mult_node_set_no_translation",type,p_id,p_enabled); ur->add_undo_method(graph.ptr(),"xform_vec_mult_node_set_no_translation",type,p_id,graph->xform_vec_mult_node_get_no_translation(type,p_id)); ur->add_do_method(this,"_update_graph"); @@ -781,7 +781,7 @@ void ShaderGraphView::_scalar_func_changed(int p_func, int p_id){ UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo(); - ur->create_action("Change Scalar Function"); + ur->create_action(TTR("Change Scalar Function")); ur->add_do_method(graph.ptr(),"scalar_func_node_set_function",type,p_id,p_func); ur->add_undo_method(graph.ptr(),"scalar_func_node_set_function",type,p_id,graph->scalar_func_node_get_function(type,p_id)); ur->add_do_method(this,"_update_graph"); @@ -793,7 +793,7 @@ void ShaderGraphView::_scalar_func_changed(int p_func, int p_id){ void ShaderGraphView::_vec_func_changed(int p_func, int p_id){ UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo(); - ur->create_action("Change Vec Function"); + ur->create_action(TTR("Change Vec Function")); ur->add_do_method(graph.ptr(),"vec_func_node_set_function",type,p_id,p_func); ur->add_undo_method(graph.ptr(),"vec_func_node_set_function",type,p_id,graph->vec_func_node_get_function(type,p_id)); ur->add_do_method(this,"_update_graph"); @@ -806,7 +806,7 @@ void ShaderGraphView::_vec_func_changed(int p_func, int p_id){ void ShaderGraphView::_scalar_input_changed(double p_value,int p_id){ UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo(); - ur->create_action("Change Scalar Uniform",true); + ur->create_action(TTR("Change Scalar Uniform"),true); ur->add_do_method(graph.ptr(),"scalar_input_node_set_value",type,p_id,p_value); ur->add_undo_method(graph.ptr(),"scalar_input_node_set_value",type,p_id,graph->scalar_input_node_get_value(type,p_id)); ur->add_do_method(this,"_update_graph"); @@ -824,7 +824,7 @@ void ShaderGraphView::_vec_input_changed(double p_value, int p_id,Array p_arr){ } UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo(); - ur->create_action("Change Vec Uniform",true); + ur->create_action(TTR("Change Vec Uniform"),true); ur->add_do_method(graph.ptr(),"vec_input_node_set_value",type,p_id,val); ur->add_undo_method(graph.ptr(),"vec_input_node_set_value",type,p_id,graph->vec_input_node_get_value(type,p_id)); ur->add_do_method(this,"_update_graph"); @@ -862,7 +862,7 @@ void ShaderGraphView::_rgb_input_changed(const Color& p_color, int p_id){ UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo(); - ur->create_action("Change RGB Uniform",true); + ur->create_action(TTR("Change RGB Uniform"),true); ur->add_do_method(graph.ptr(),"rgb_input_node_set_value",type,p_id,p_color); ur->add_undo_method(graph.ptr(),"rgb_input_node_set_value",type,p_id,graph->rgb_input_node_get_value(type,p_id)); ur->add_do_method(this,"_update_graph"); @@ -902,7 +902,7 @@ void ShaderGraphView::_variant_edited() { break; } UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo(); - ur->create_action("Change default value"); + ur->create_action(TTR("Change default value")); ur->add_do_method(graph.ptr(),"default_set_value",type,edited_id,edited_def, v); ur->add_undo_method(graph.ptr(),"default_set_value",type,edited_id,edited_def, v2); ur->add_do_method(this,"_update_graph"); @@ -914,7 +914,7 @@ void ShaderGraphView::_variant_edited() { if (graph->node_get_type(type,edited_id)==ShaderGraph::NODE_XFORM_CONST) { UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo(); - ur->create_action("Change XForm Uniform"); + ur->create_action(TTR("Change XForm Uniform")); ur->add_do_method(graph.ptr(),"xform_const_node_set_value",type,edited_id,ped_popup->get_variant()); ur->add_undo_method(graph.ptr(),"xform_const_node_set_value",type,edited_id,graph->xform_const_node_get_value(type,edited_id)); ur->add_do_method(this,"_update_graph"); @@ -926,7 +926,7 @@ void ShaderGraphView::_variant_edited() { if (graph->node_get_type(type,edited_id)==ShaderGraph::NODE_XFORM_INPUT) { UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo(); - ur->create_action("Change XForm Uniform"); + ur->create_action(TTR("Change XForm Uniform")); ur->add_do_method(graph.ptr(),"xform_input_node_set_value",type,edited_id,ped_popup->get_variant()); ur->add_undo_method(graph.ptr(),"xform_input_node_set_value",type,edited_id,graph->xform_input_node_get_value(type,edited_id)); ur->add_do_method(this,"_update_graph"); @@ -937,7 +937,7 @@ void ShaderGraphView::_variant_edited() { if (graph->node_get_type(type,edited_id)==ShaderGraph::NODE_TEXTURE_INPUT) { UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo(); - ur->create_action("Change Texture Uniform"); + ur->create_action(TTR("Change Texture Uniform")); ur->add_do_method(graph.ptr(),"texture_input_node_set_value",type,edited_id,ped_popup->get_variant()); ur->add_undo_method(graph.ptr(),"texture_input_node_set_value",type,edited_id,graph->texture_input_node_get_value(type,edited_id)); ur->add_do_method(this,"_update_graph"); @@ -948,7 +948,7 @@ void ShaderGraphView::_variant_edited() { if (graph->node_get_type(type,edited_id)==ShaderGraph::NODE_CUBEMAP_INPUT) { UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo(); - ur->create_action("Change Cubemap Uniform"); + ur->create_action(TTR("Change Cubemap Uniform")); ur->add_do_method(graph.ptr(),"cubemap_input_node_set_value",type,edited_id,ped_popup->get_variant()); ur->add_undo_method(graph.ptr(),"cubemap_input_node_set_value",type,edited_id,graph->cubemap_input_node_get_value(type,edited_id)); ur->add_do_method(this,"_update_graph"); @@ -962,7 +962,7 @@ void ShaderGraphView::_comment_edited(int p_id,Node* p_button) { UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo(); TextEdit *te=p_button->cast_to<TextEdit>(); - ur->create_action("Change Comment",true); + ur->create_action(TTR("Change Comment"),true); ur->add_do_method(graph.ptr(),"comment_node_set_text",type,p_id,te->get_text()); ur->add_undo_method(graph.ptr(),"comment_node_set_text",type,p_id,graph->comment_node_get_text(type,p_id)); ur->add_do_method(this,"_update_graph"); @@ -1002,9 +1002,9 @@ void ShaderGraphView::_color_ramp_changed(int p_id,Node* p_ramp) { DVector<Color> old_colors=graph->color_ramp_node_get_colors(type,p_id); if (old_offsets.size()!=new_offsets.size()) - ur->create_action("Add/Remove to Color Ramp"); + ur->create_action(TTR("Add/Remove to Color Ramp")); else - ur->create_action("Modify Color Ramp",true); + ur->create_action(TTR("Modify Color Ramp"),true); ur->add_do_method(graph.ptr(),"color_ramp_node_set_ramp",type,p_id,new_colors,new_offsets); ur->add_undo_method(graph.ptr(),"color_ramp_node_set_ramp",type,p_id,old_colors,old_offsets); @@ -1038,9 +1038,9 @@ void ShaderGraphView::_curve_changed(int p_id,Node* p_curve) { DVector<Vector2> old_points=graph->curve_map_node_get_points(type,p_id); if (old_points.size()!=new_points.size()) - ur->create_action("Add/Remove to Curve Map"); + ur->create_action(TTR("Add/Remove to Curve Map")); else - ur->create_action("Modify Curve Map",true); + ur->create_action(TTR("Modify Curve Map"),true); ur->add_do_method(graph.ptr(),"curve_map_node_set_points",type,p_id,new_points); ur->add_undo_method(graph.ptr(),"curve_map_node_set_points",type,p_id,old_points); @@ -1058,7 +1058,7 @@ void ShaderGraphView::_input_name_changed(const String& p_name, int p_id, Node * ERR_FAIL_COND(!le); UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo(); - ur->create_action("Change Input Name"); + ur->create_action(TTR("Change Input Name")); ur->add_do_method(graph.ptr(),"input_node_set_name",type,p_id,p_name); ur->add_undo_method(graph.ptr(),"input_node_set_name",type,p_id,graph->input_node_get_name(type,p_id)); ur->add_do_method(this,"_update_graph"); @@ -1110,7 +1110,7 @@ void ShaderGraphView::_connection_request(const String& p_from, int p_from_slot, ERR_FAIL_COND(from_idx==-1); ERR_FAIL_COND(to_idx==-1); - ur->create_action("Connect Graph Nodes"); + ur->create_action(TTR("Connect Graph Nodes")); List<ShaderGraph::Connection> conns; @@ -1152,7 +1152,7 @@ void ShaderGraphView::_disconnection_request(const String& p_from, int p_from_sl if (!graph->is_node_connected(type,from_idx,p_from_slot,to_idx,p_to_slot)) return; //nothing to disconnect - ur->create_action("Disconnect Graph Nodes"); + ur->create_action(TTR("Disconnect Graph Nodes")); List<ShaderGraph::Connection> conns; @@ -1170,7 +1170,7 @@ void ShaderGraphView::_disconnection_request(const String& p_from, int p_from_sl void ShaderGraphView::_node_removed(int p_id) { UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo(); - ur->create_action("Remove Shader Graph Node"); + ur->create_action(TTR("Remove Shader Graph Node")); ur->add_do_method(graph.ptr(),"node_remove",type,p_id); ur->add_undo_method(graph.ptr(),"node_add",type,graph->node_get_type(type,p_id),p_id); @@ -1193,7 +1193,7 @@ void ShaderGraphView::_node_removed(int p_id) { void ShaderGraphView::_begin_node_move() { UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo(); - ur->create_action("Move Shader Graph Node"); + ur->create_action(TTR("Move Shader Graph Node")); } void ShaderGraphView::_node_moved(const Vector2& p_from, const Vector2& p_to,int p_id) { @@ -1235,7 +1235,7 @@ void ShaderGraphView::_duplicate_nodes_request() return; UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo(); - ur->create_action("Duplicate Graph Node(s)"); + ur->create_action(TTR("Duplicate Graph Node(s)")); ur->add_do_method(this,"_duplicate_nodes",s_id); List<int> n_ids = graph->generate_ids(type, s_id.size()); for (List<int>::Element *E=n_ids.front();E;E=E->next()) @@ -1272,7 +1272,7 @@ void ShaderGraphView::_delete_nodes_request() return; UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo(); - ur->create_action("Delete Shader Graph Node(s)"); + ur->create_action(TTR("Delete Shader Graph Node(s)")); for (List<int>::Element *N=s_id.front();N;N=N->next()) { ur->add_do_method(graph.ptr(),"node_remove",type,N->get()); @@ -1427,7 +1427,7 @@ void ShaderGraphView::_create_node(int p_id) { } break; // all inputs (case Shader type dependent) case ShaderGraph::NODE_SCALAR_CONST: { - gn->set_title("Scalar"); + gn->set_title(TTR("Scalar")); SpinBox *sb = memnew( SpinBox ); sb->set_min(-100000); sb->set_max(100000); @@ -1440,7 +1440,7 @@ void ShaderGraphView::_create_node(int p_id) { } break; //scalar constant case ShaderGraph::NODE_VEC_CONST: { - gn->set_title("Vector"); + gn->set_title(TTR("Vector")); Array v3p(true); for(int i=0;i<3;i++) { HBoxContainer *hbc = memnew( HBoxContainer ); @@ -1469,11 +1469,11 @@ void ShaderGraphView::_create_node(int p_id) { cpb->connect("color_changed",this,"_rgb_const_changed",varray(p_id)); gn->add_child(cpb); Label *l = memnew( Label ); - l->set_text("RGB"); + l->set_text(TTR("RGB")); l->set_align(Label::ALIGN_RIGHT); gn->add_child(l); l = memnew( Label ); - l->set_text("Alpha"); + l->set_text(TTR("Alpha")); l->set_align(Label::ALIGN_RIGHT); gn->add_child(l); @@ -1482,7 +1482,7 @@ void ShaderGraphView::_create_node(int p_id) { } break; //rgb constant (shows a color picker instead) case ShaderGraph::NODE_XFORM_CONST: { - gn->set_title("XForm"); + gn->set_title(TTR("XForm")); ToolButton *edit = memnew( ToolButton ); edit->set_text("edit.."); edit->connect("pressed",this,"_xform_const_changed",varray(p_id,edit)); @@ -1492,7 +1492,7 @@ void ShaderGraphView::_create_node(int p_id) { } break; // 4x4 matrix constant case ShaderGraph::NODE_TIME: { - gn->set_title("Time"); + gn->set_title(TTR("Time")); Label *l = memnew( Label ); l->set_text("(s)"); l->set_align(Label::ALIGN_RIGHT); @@ -1502,34 +1502,34 @@ void ShaderGraphView::_create_node(int p_id) { } break; // time in seconds case ShaderGraph::NODE_SCREEN_TEX: { - gn->set_title("ScreenTex"); + gn->set_title(TTR("ScreenTex")); HBoxContainer *hbc = memnew( HBoxContainer ); hbc->add_constant_override("separation",0); if (!graph->is_slot_connected(type,p_id,0)) { Vector3 v = graph->default_get_value(type, p_id, 0); - hbc->add_child(make_editor("UV: " + v,gn,p_id,0,Variant::VECTOR3)); + hbc->add_child(make_editor(TTR("UV: ") + v,gn,p_id,0,Variant::VECTOR3)); } else { - hbc->add_child(make_label("UV",Variant::VECTOR3)); + hbc->add_child(make_label(TTR("UV"),Variant::VECTOR3)); } hbc->add_spacer(); - hbc->add_child( memnew(Label("RGB"))); + hbc->add_child( memnew(Label(TTR("RGB")))); gn->add_child(hbc); gn->set_slot(0,true,ShaderGraph::SLOT_TYPE_VEC,typecol[ShaderGraph::SLOT_TYPE_VEC],true,ShaderGraph::SLOT_TYPE_VEC,typecol[ShaderGraph::SLOT_TYPE_VEC]); } break; // screen texture sampler (takes UV) (only usable in fragment case Shader) case ShaderGraph::NODE_SCALAR_OP: { - gn->set_title("ScalarOp"); + gn->set_title(TTR("ScalarOp")); static const char* op_name[ShaderGraph::SCALAR_MAX_OP]={ - "Add", - "Sub", - "Mul", - "Div", - "Mod", - "Pow", - "Max", - "Min", - "Atan2" + ("Add"), + ("Sub"), + ("Mul"), + ("Div"), + ("Mod"), + ("Pow"), + ("Max"), + ("Min"), + ("Atan2") }; OptionButton *ob = memnew( OptionButton ); @@ -1567,17 +1567,17 @@ void ShaderGraphView::_create_node(int p_id) { } break; // scalar vs scalar op (mul: { } break; add: { } break; div: { } break; etc) case ShaderGraph::NODE_VEC_OP: { - gn->set_title("VecOp"); + gn->set_title(TTR("VecOp")); static const char* op_name[ShaderGraph::VEC_MAX_OP]={ - "Add", - "Sub", - "Mul", - "Div", - "Mod", - "Pow", - "Max", - "Min", - "Cross" + ("Add"), + ("Sub"), + ("Mul"), + ("Div"), + ("Mod"), + ("Pow"), + ("Max"), + ("Min"), + ("Cross") }; OptionButton *ob = memnew( OptionButton ); @@ -1615,11 +1615,11 @@ void ShaderGraphView::_create_node(int p_id) { } break; // vec3 vs vec3 op (mul: { } break;ad: { } break;div: { } break;crossprod: { } break;etc) case ShaderGraph::NODE_VEC_SCALAR_OP: { - gn->set_title("VecScalarOp"); + gn->set_title(TTR("VecScalarOp")); static const char* op_name[ShaderGraph::VEC_SCALAR_MAX_OP]={ - "Mul", - "Div", - "Pow", + ("Mul"), + ("Div"), + ("Pow"), }; OptionButton *ob = memnew( OptionButton ); @@ -1657,17 +1657,17 @@ void ShaderGraphView::_create_node(int p_id) { } break; // vec3 vs scalar op (mul: { } break; add: { } break; div: { } break; etc) case ShaderGraph::NODE_RGB_OP: { - gn->set_title("RGB Op"); + gn->set_title(TTR("RGB Op")); static const char* op_name[ShaderGraph::RGB_MAX_OP]={ - "Screen", - "Difference", - "Darken", - "Lighten", - "Overlay", - "Dodge", - "Burn", - "SoftLight", - "HardLight" + ("Screen"), + ("Difference"), + ("Darken"), + ("Lighten"), + ("Overlay"), + ("Dodge"), + ("Burn"), + ("SoftLight"), + ("HardLight") }; OptionButton *ob = memnew( OptionButton ); @@ -1702,7 +1702,7 @@ void ShaderGraphView::_create_node(int p_id) { } break; // vec3 vs vec3 rgb op (with scalar amount): { } break; like brighten: { } break; darken: { } break; burn: { } break; dodge: { } break; multiply: { } break; etc. case ShaderGraph::NODE_XFORM_MULT: { - gn->set_title("XFMult"); + gn->set_title(TTR("XFMult")); HBoxContainer *hbc = memnew( HBoxContainer ); if (graph->is_slot_connected(type, p_id, 0)) { hbc->add_child(make_label("a",Variant::TRANSFORM)); @@ -1725,9 +1725,9 @@ void ShaderGraphView::_create_node(int p_id) { } break; // mat4 x mat4 case ShaderGraph::NODE_XFORM_VEC_MULT: { - gn->set_title("XFVecMult"); + gn->set_title(TTR("XFVecMult")); - CheckBox *button = memnew (CheckBox("RotOnly")); + CheckBox *button = memnew (CheckBox(TTR("RotOnly"))); button->set_pressed(graph->xform_vec_mult_node_get_no_translation(type,p_id)); button->connect("toggled",this,"_xform_inv_rev_changed",varray(p_id)); @@ -1758,10 +1758,10 @@ void ShaderGraphView::_create_node(int p_id) { } break; case ShaderGraph::NODE_XFORM_VEC_INV_MULT: { - gn->set_title("XFVecInvMult"); + gn->set_title(TTR("XFVecInvMult")); - CheckBox *button = memnew( CheckBox("RotOnly")); + CheckBox *button = memnew( CheckBox(TTR("RotOnly"))); button->set_pressed(graph->xform_vec_mult_node_get_no_translation(type,p_id)); button->connect("toggled",this,"_xform_inv_rev_changed",varray(p_id)); @@ -1793,28 +1793,28 @@ void ShaderGraphView::_create_node(int p_id) { } break; // mat4 x vec3 inverse mult (with no-translation option) case ShaderGraph::NODE_SCALAR_FUNC: { - gn->set_title("ScalarFunc"); + gn->set_title(TTR("ScalarFunc")); static const char* func_name[ShaderGraph::SCALAR_MAX_FUNC]={ - "Sin", - "Cos", - "Tan", - "ASin", - "ACos", - "ATan", - "SinH", - "CosH", - "TanH", - "Log", - "Exp", - "Sqrt", - "Abs", - "Sign", - "Floor", - "Round", - "Ceil", - "Frac", - "Satr", - "Neg" + ("Sin"), + ("Cos"), + ("Tan"), + ("ASin"), + ("ACos"), + ("ATan"), + ("SinH"), + ("CosH"), + ("TanH"), + ("Log"), + ("Exp"), + ("Sqrt"), + ("Abs"), + ("Sign"), + ("Floor"), + ("Round"), + ("Ceil"), + ("Frac"), + ("Satr"), + ("Neg") }; OptionButton *ob = memnew( OptionButton ); @@ -1846,14 +1846,14 @@ void ShaderGraphView::_create_node(int p_id) { - gn->set_title("VecFunc"); + gn->set_title(TTR("VecFunc")); static const char* func_name[ShaderGraph::VEC_MAX_FUNC]={ - "Normalize", - "Saturate", - "Negate", - "Reciprocal", - "RGB to HSV", - "HSV to RGB", + ("Normalize"), + ("Saturate"), + ("Negate"), + ("Reciprocal"), + ("RGB to HSV"), + ("HSV to RGB"), }; OptionButton *ob = memnew( OptionButton ); @@ -1882,7 +1882,7 @@ void ShaderGraphView::_create_node(int p_id) { } break; // vector function (normalize: { } break; negate: { } break; reciprocal: { } break; rgb2hsv: { } break; hsv2rgb: { } break; etc: { } break; etc) case ShaderGraph::NODE_VEC_LEN: { - gn->set_title("VecLength"); + gn->set_title(TTR("VecLength")); HBoxContainer *hbc = memnew( HBoxContainer ); if (graph->is_slot_connected(type, p_id, 0)) { hbc->add_child(make_label("in", Variant::VECTOR3)); @@ -1899,7 +1899,7 @@ void ShaderGraphView::_create_node(int p_id) { } break; // vec3 length case ShaderGraph::NODE_DOT_PROD: { - gn->set_title("DotProduct"); + gn->set_title(TTR("DotProduct")); HBoxContainer *hbc = memnew( HBoxContainer ); hbc->add_constant_override("separation",0); if (graph->is_slot_connected(type, p_id, 0)) { @@ -1924,7 +1924,7 @@ void ShaderGraphView::_create_node(int p_id) { } break; // vec3 . vec3 (dot product -> scalar output) case ShaderGraph::NODE_VEC_TO_SCALAR: { - gn->set_title("Vec2Scalar"); + gn->set_title(TTR("Vec2Scalar")); HBoxContainer *hbc = memnew( HBoxContainer ); hbc->add_constant_override("separation",0); if (graph->is_slot_connected(type, p_id, 0)) { @@ -1955,7 +1955,7 @@ void ShaderGraphView::_create_node(int p_id) { } break; // 1 vec3 input: { } break; 3 scalar outputs case ShaderGraph::NODE_SCALAR_TO_VEC: { - gn->set_title("Scalar2Vec"); + gn->set_title(TTR("Scalar2Vec")); HBoxContainer *hbc = memnew( HBoxContainer ); if (graph->is_slot_connected(type, p_id, 0)) { hbc->add_child(make_label("x", Variant::REAL)); @@ -1986,7 +1986,7 @@ void ShaderGraphView::_create_node(int p_id) { } break; // 3 scalar input: { } break; 1 vec3 output case ShaderGraph::NODE_VEC_TO_XFORM: { - gn->set_title("Vec2XForm"); + gn->set_title(TTR("Vec2XForm")); HBoxContainer *hbc = memnew( HBoxContainer ); hbc->add_constant_override("separation",0); if (graph->is_slot_connected(type, p_id, 0)) { @@ -2025,7 +2025,7 @@ void ShaderGraphView::_create_node(int p_id) { } break; // 3 vec input: { } break; 1 xform output case ShaderGraph::NODE_XFORM_TO_VEC: { - gn->set_title("XForm2Vec"); + gn->set_title(TTR("XForm2Vec")); HBoxContainer *hbc = memnew( HBoxContainer ); hbc->add_constant_override("separation",0); @@ -2057,7 +2057,7 @@ void ShaderGraphView::_create_node(int p_id) { } break; // 3 vec input: { } break; 1 xform output case ShaderGraph::NODE_SCALAR_INTERP: { - gn->set_title("ScalarInterp"); + gn->set_title(TTR("ScalarInterp")); HBoxContainer *hbc = memnew( HBoxContainer ); hbc->add_constant_override("separation",0); if (graph->is_slot_connected(type, p_id, 0)) { @@ -2090,7 +2090,7 @@ void ShaderGraphView::_create_node(int p_id) { } break; // scalar interpolation (with optional curve) case ShaderGraph::NODE_VEC_INTERP: { - gn->set_title("VecInterp"); + gn->set_title(TTR("VecInterp")); HBoxContainer *hbc = memnew( HBoxContainer ); if (graph->is_slot_connected(type, p_id, 0)) { hbc->add_child(make_label("a", Variant::VECTOR3)); @@ -2174,7 +2174,7 @@ void ShaderGraphView::_create_node(int p_id) { } break; // scalar interpolation (with optional curve) case ShaderGraph::NODE_CURVE_MAP: { - gn->set_title("CurveMap"); + gn->set_title(TTR("CurveMap")); GraphCurveMapEdit * map = memnew( GraphCurveMapEdit ); DVector<Vector2> points = graph->curve_map_node_get_points(type,p_id); @@ -2221,7 +2221,7 @@ void ShaderGraphView::_create_node(int p_id) { case ShaderGraph::NODE_SCALAR_INPUT: { - gn->set_title("ScalarUniform"); + gn->set_title(TTR("ScalarUniform")); LineEdit *le = memnew( LineEdit ); gn->add_child(le); le->set_text(graph->input_node_get_name(type,p_id)); @@ -2238,7 +2238,7 @@ void ShaderGraphView::_create_node(int p_id) { } break; // scalar uniform (assignable in material) case ShaderGraph::NODE_VEC_INPUT: { - gn->set_title("VectorUniform"); + gn->set_title(TTR("VectorUniform")); LineEdit *le = memnew( LineEdit ); gn->add_child(le); le->set_text(graph->input_node_get_name(type,p_id)); @@ -2265,7 +2265,7 @@ void ShaderGraphView::_create_node(int p_id) { } break; // vec3 uniform (assignable in material) case ShaderGraph::NODE_RGB_INPUT: { - gn->set_title("ColorUniform"); + gn->set_title(TTR("ColorUniform")); LineEdit *le = memnew( LineEdit ); gn->add_child(le); le->set_text(graph->input_node_get_name(type,p_id)); @@ -2275,11 +2275,11 @@ void ShaderGraphView::_create_node(int p_id) { cpb->connect("color_changed",this,"_rgb_input_changed",varray(p_id)); gn->add_child(cpb); Label *l = memnew( Label ); - l->set_text("RGB"); + l->set_text(TTR("RGB")); l->set_align(Label::ALIGN_RIGHT); gn->add_child(l); l = memnew( Label ); - l->set_text("Alpha"); + l->set_text(TTR("Alpha")); l->set_align(Label::ALIGN_RIGHT); gn->add_child(l); @@ -2289,7 +2289,7 @@ void ShaderGraphView::_create_node(int p_id) { } break; // color uniform (assignable in material) case ShaderGraph::NODE_XFORM_INPUT: { - gn->set_title("XFUniform"); + gn->set_title(TTR("XFUniform")); LineEdit *le = memnew( LineEdit ); gn->add_child(le); le->set_text(graph->input_node_get_name(type,p_id)); @@ -2303,7 +2303,7 @@ void ShaderGraphView::_create_node(int p_id) { } break; // mat4 uniform (assignable in material) case ShaderGraph::NODE_TEXTURE_INPUT: { - gn->set_title("TexUniform"); + gn->set_title(TTR("TexUniform")); LineEdit *le = memnew( LineEdit ); gn->add_child(le); le->set_text(graph->input_node_get_name(type,p_id)); @@ -2321,18 +2321,18 @@ void ShaderGraphView::_create_node(int p_id) { HBoxContainer *hbc = memnew( HBoxContainer ); hbc->add_constant_override("separation",0); if (graph->is_slot_connected(type, p_id, 0)) { - hbc->add_child(make_label("UV", Variant::VECTOR3)); + hbc->add_child(make_label(TTR("UV"), Variant::VECTOR3)); } else { Vector3 v = graph->default_get_value(type,p_id,0); - hbc->add_child(make_editor(String("UV: ")+v,gn,p_id,0,Variant::VECTOR3)); + hbc->add_child(make_editor(String(TTR("UV: "))+v,gn,p_id,0,Variant::VECTOR3)); } hbc->add_spacer(); - Label *l=memnew(Label("RGB")); + Label *l=memnew(Label(TTR("RGB"))); l->set_align(Label::ALIGN_RIGHT); hbc->add_child(l); gn->add_child(hbc); l = memnew( Label ); - l->set_text("Alpha"); + l->set_text(TTR("Alpha")); l->set_align(Label::ALIGN_RIGHT); gn->add_child(l); @@ -2342,7 +2342,7 @@ void ShaderGraphView::_create_node(int p_id) { } break; // texture input (assignable in material) case ShaderGraph::NODE_CUBEMAP_INPUT: { - gn->set_title("TexUniform"); + gn->set_title(TTR("TexUniform")); LineEdit *le = memnew( LineEdit ); gn->add_child(le); le->set_text(graph->input_node_get_name(type,p_id)); @@ -2357,18 +2357,18 @@ void ShaderGraphView::_create_node(int p_id) { HBoxContainer *hbc = memnew( HBoxContainer ); hbc->add_constant_override("separation",0); if (graph->is_slot_connected(type, p_id, 0)) { - hbc->add_child(make_label("UV", Variant::VECTOR3)); + hbc->add_child(make_label(TTR("UV"), Variant::VECTOR3)); } else { Vector3 v = graph->default_get_value(type,p_id,0); - hbc->add_child(make_editor(String("UV: ")+v,gn,p_id,0,Variant::VECTOR3)); + hbc->add_child(make_editor(String(TTR("UV: "))+v,gn,p_id,0,Variant::VECTOR3)); } hbc->add_spacer(); - Label *l=memnew(Label("RGB")); + Label *l=memnew(Label(TTR("RGB"))); l->set_align(Label::ALIGN_RIGHT); hbc->add_child(l); gn->add_child(hbc); l = memnew( Label ); - l->set_text("Alpha"); + l->set_text(TTR("Alpha")); l->set_align(Label::ALIGN_RIGHT); gn->add_child(l); @@ -2378,22 +2378,22 @@ void ShaderGraphView::_create_node(int p_id) { } break; // cubemap input (assignable in material) case ShaderGraph::NODE_DEFAULT_TEXTURE: { - gn->set_title("CanvasItemTex"); + gn->set_title(TTR("CanvasItemTex")); HBoxContainer *hbc = memnew( HBoxContainer ); hbc->add_constant_override("separation",0); if (graph->is_slot_connected(type, p_id, 0)) { - hbc->add_child(make_label("UV", Variant::VECTOR3)); + hbc->add_child(make_label(TTR("UV"), Variant::VECTOR3)); } else { Vector3 v = graph->default_get_value(type,p_id,0); - hbc->add_child(make_editor(String("UV: ")+v,gn,p_id,0,Variant::VECTOR3)); + hbc->add_child(make_editor(String(TTR("UV: "))+v,gn,p_id,0,Variant::VECTOR3)); } hbc->add_spacer(); - Label *l=memnew(Label("RGB")); + Label *l=memnew(Label(TTR("RGB"))); l->set_align(Label::ALIGN_RIGHT); hbc->add_child(l); gn->add_child(hbc); l = memnew( Label ); - l->set_text("Alpha"); + l->set_text(TTR("Alpha")); l->set_align(Label::ALIGN_RIGHT); gn->add_child(l); @@ -2404,7 +2404,7 @@ void ShaderGraphView::_create_node(int p_id) { } break; // screen texture sampler (takes UV) (only usable in fragment case Shader) case ShaderGraph::NODE_OUTPUT: { - gn->set_title("Output"); + gn->set_title(TTR("Output")); gn->set_show_close_button(false); List<ShaderGraph::SlotInfo> si; @@ -2412,22 +2412,22 @@ void ShaderGraphView::_create_node(int p_id) { Array colors; colors.push_back("Color"); - colors.push_back("LightColor"); + colors.push_back(TTR("LightColor")); colors.push_back("Light"); - colors.push_back("Diffuse"); - colors.push_back("Specular"); - colors.push_back("Emmision"); + colors.push_back(TTR("Diffuse")); + colors.push_back(TTR("Specular")); + colors.push_back(TTR("Emmision")); Array reals; - reals.push_back("Alpha"); - reals.push_back("DiffuseAlpha"); - reals.push_back("NormalMapDepth"); - reals.push_back("SpecExp"); - reals.push_back("Glow"); - reals.push_back("ShadeParam"); - reals.push_back("SpecularExp"); - reals.push_back("LightAlpha"); - reals.push_back("PointSize"); - reals.push_back("Discard"); + reals.push_back(TTR("Alpha")); + reals.push_back(TTR("DiffuseAlpha")); + reals.push_back(TTR("NormalMapDepth")); + reals.push_back(TTR("SpecExp")); + reals.push_back(TTR("Glow")); + reals.push_back(TTR("ShadeParam")); + reals.push_back(TTR("SpecularExp")); + reals.push_back(TTR("LightAlpha")); + reals.push_back(TTR("PointSize")); + reals.push_back(TTR("Discard")); int idx=0; for (List<ShaderGraph::SlotInfo>::Element *E=si.front();E;E=E->next()) { @@ -2448,7 +2448,7 @@ void ShaderGraphView::_create_node(int p_id) { } break; // output (case Shader type dependent) case ShaderGraph::NODE_COMMENT: { - gn->set_title("Comment"); + gn->set_title(TTR("Comment")); TextEdit *te = memnew(TextEdit); te->set_custom_minimum_size(Size2(100,100)); gn->add_child(te); @@ -2512,8 +2512,8 @@ void ShaderGraphView::_sg_updated() { return; switch(graph->get_graph_error(type)) { case ShaderGraph::GRAPH_OK: status->set_text(""); break; - case ShaderGraph::GRAPH_ERROR_CYCLIC: status->set_text("Error: Cyclic Connection Link"); break; - case ShaderGraph::GRAPH_ERROR_MISSING_CONNECTIONS: status->set_text("Error: Missing Input Connections"); break; + case ShaderGraph::GRAPH_ERROR_CYCLIC: status->set_text(TTR("Error: Cyclic Connection Link")); break; + case ShaderGraph::GRAPH_ERROR_MISSING_CONNECTIONS: status->set_text(TTR("Error: Missing Input Connections")); break; } } @@ -2573,7 +2573,7 @@ void ShaderGraphView::add_node(int p_type, const Vector2 &location) { break; } UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo(); - ur->create_action("Add Shader Graph Node"); + ur->create_action(TTR("Add Shader Graph Node")); ur->add_do_method(graph.ptr(),"node_add",type,p_type,newid); ur->add_do_method(graph.ptr(),"node_set_pos",type,newid,init_ofs); ur->add_undo_method(graph.ptr(),"node_remove",type,newid); @@ -2707,41 +2707,41 @@ void ShaderGraphEditor::_bind_methods() { const char* ShaderGraphEditor::node_names[ShaderGraph::NODE_TYPE_MAX]={ - "GraphInput:Input", // all inputs (shader type dependent) - "GraphScalar:Scalar Constant", //scalar constant - "GraphVector:Vector Constant", //vec3 constant - "GraphRgb:RGB Constant", //rgb constant (shows a color picker instead) - "GraphXform:XForm Constant", // 4x4 matrix constant - "GraphTime:Time:", // time in seconds - "GraphTexscreen:Screen Sample", // screen texture sampler (takes uv) (only usable in fragment shader) - "GraphScalarOp:Scalar Operator", // scalar vs scalar op (mul", add", div", etc) - "GraphVecOp:Vector Operator", // vec3 vs vec3 op (mul",ad",div",crossprod",etc) - "GraphVecScalarOp:Scalar+Vector Operator", // vec3 vs scalar op (mul", add", div", etc) - "GraphRgbOp:RGB Operator:", // vec3 vs vec3 rgb op (with scalar amount)", like brighten", darken", burn", dodge", multiply", etc. - "GraphXformMult:XForm Multiply", // mat4 x mat4 - "GraphXformVecMult:XForm+Vector Multiply", // mat4 x vec3 mult (with no-translation option) - "GraphXformVecImult:Form+Vector InvMultiply:", // mat4 x vec3 inverse mult (with no-translation option) - "GraphXformScalarFunc:Scalar Function", // scalar function (sin", cos", etc) - "GraphXformVecFunc:Vector Function", // vector function (normalize", negate", reciprocal", rgb2hsv", hsv2rgb", etc", etc) - "GraphVecLength:Vector Length", // vec3 length - "GraphVecDp:Dot Product:", // vec3 . vec3 (dot product -> scalar output) - "GraphVecToScalars:Vector -> Scalars", // 1 vec3 input", 3 scalar outputs - "GraphScalarsToVec:Scalars -> Vector", // 3 scalar input", 1 vec3 output - "GraphXformToVecs:XForm -> Vectors", // 3 vec input", 1 xform output - "GraphVecsToXform:Vectors -> XForm:", // 3 vec input", 1 xform output - "GraphScalarInterp:Scalar Interpolate", // scalar interpolation (with optional curve) - "GraphVecInterp:Vector Interpolate:", // vec3 interpolation (with optional curve) - "GraphColorRamp:Color Ramp", // vec3 interpolation (with optional curve) - "GraphCurveMap:Curve Remap:", // vec3 interpolation (with optional curve) - "GraphScalarUniform:Scalar Uniform", // scalar uniform (assignable in material) - "GraphVectorUniform:Vector Uniform", // vec3 uniform (assignable in material) - "GraphRgbUniform:RGB Uniform", // color uniform (assignable in material) - "GraphXformUniform:XForm Uniform", // mat4 uniform (assignable in material) - "GraphTextureUniform:Texture Uniform", // texture input (assignable in material) - "GraphCubeUniform:CubeMap Uniform:", // cubemap input (assignable in material) - "GraphDefaultTexture:CanvasItem Texture:", // cubemap input (assignable in material) - "Output", // output (shader type dependent) - "GraphComment:Comment", // comment + ("GraphInput:Input"), // all inputs (shader type dependent) + ("GraphScalar:Scalar Constant"), //scalar constant + ("GraphVector:Vector Constant"), //vec3 constant + ("GraphRgb:RGB Constant"), //rgb constant (shows a color picker instead) + ("GraphXform:XForm Constant"), // 4x4 matrix constant + ("GraphTime:Time:"), // time in seconds + ("GraphTexscreen:Screen Sample"), // screen texture sampler (takes uv) (only usable in fragment shader) + ("GraphScalarOp:Scalar Operator"), // scalar vs scalar op (mul", add", div", etc) + ("GraphVecOp:Vector Operator"), // vec3 vs vec3 op (mul",ad",div",crossprod",etc) + ("GraphVecScalarOp:Scalar+Vector Operator"), // vec3 vs scalar op (mul", add", div", etc) + ("GraphRgbOp:RGB Operator:"), // vec3 vs vec3 rgb op (with scalar amount)", like brighten", darken", burn", dodge", multiply", etc. + ("GraphXformMult:XForm Multiply"), // mat4 x mat4 + ("GraphXformVecMult:XForm+Vector Multiply"), // mat4 x vec3 mult (with no-translation option) + ("GraphXformVecImult:Form+Vector InvMultiply:"), // mat4 x vec3 inverse mult (with no-translation option) + ("GraphXformScalarFunc:Scalar Function"), // scalar function (sin", cos", etc) + ("GraphXformVecFunc:Vector Function"), // vector function (normalize", negate", reciprocal", rgb2hsv", hsv2rgb", etc", etc) + ("GraphVecLength:Vector Length"), // vec3 length + ("GraphVecDp:Dot Product:"), // vec3 . vec3 (dot product -> scalar output) + ("GraphVecToScalars:Vector -> Scalars"), // 1 vec3 input", 3 scalar outputs + ("GraphScalarsToVec:Scalars -> Vector"), // 3 scalar input", 1 vec3 output + ("GraphXformToVecs:XForm -> Vectors"), // 3 vec input", 1 xform output + ("GraphVecsToXform:Vectors -> XForm:"), // 3 vec input", 1 xform output + ("GraphScalarInterp:Scalar Interpolate"), // scalar interpolation (with optional curve) + ("GraphVecInterp:Vector Interpolate:"), // vec3 interpolation (with optional curve) + ("GraphColorRamp:Color Ramp"), // vec3 interpolation (with optional curve) + ("GraphCurveMap:Curve Remap:"), // vec3 interpolation (with optional curve) + ("GraphScalarUniform:Scalar Uniform"), // scalar uniform (assignable in material) + ("GraphVectorUniform:Vector Uniform"), // vec3 uniform (assignable in material) + ("GraphRgbUniform:RGB Uniform"), // color uniform (assignable in material) + ("GraphXformUniform:XForm Uniform"), // mat4 uniform (assignable in material) + ("GraphTextureUniform:Texture Uniform"), // texture input (assignable in material) + ("GraphCubeUniform:CubeMap Uniform:"), // cubemap input (assignable in material) + ("GraphDefaultTexture:CanvasItem Texture:"), // cubemap input (assignable in material) + ("Output"), // output (shader type dependent) + ("GraphComment:Comment"), // comment }; diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp index c4d3f7282e..331cf6309c 100644 --- a/tools/editor/plugins/spatial_editor_plugin.cpp +++ b/tools/editor/plugins/spatial_editor_plugin.cpp @@ -561,7 +561,7 @@ void SpatialEditorViewport::_select_region() { void SpatialEditorViewport::_update_name() { - String ortho = orthogonal?"Orthogonal":"Perspective"; + String ortho = orthogonal?TTR("Orthogonal"):"Perspective"; if (name!="") view_menu->set_text("[ "+name+" "+ortho+" ]"); @@ -984,7 +984,7 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { } surface->update(); //VisualServer::get_singleton()->poly_clear(indicators); - set_message("Transform Aborted.",3); + set_message(TTR("Transform Aborted."),3); } } break; case BUTTON_MIDDLE: { @@ -996,26 +996,26 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { case TRANSFORM_VIEW: { _edit.plane=TRANSFORM_X_AXIS; - set_message("View Plane Transform.",2); + set_message(TTR("View Plane Transform."),2); name=""; _update_name(); } break; case TRANSFORM_X_AXIS: { _edit.plane=TRANSFORM_Y_AXIS; - set_message("X-Axis Transform.",2); + set_message(TTR("X-Axis Transform."),2); } break; case TRANSFORM_Y_AXIS: { _edit.plane=TRANSFORM_Z_AXIS; - set_message("Y-Axis Transform.",2); + set_message(TTR("Y-Axis Transform."),2); } break; case TRANSFORM_Z_AXIS: { _edit.plane=TRANSFORM_VIEW; - set_message("Z-Axis Transform.",2); + set_message(TTR("Z-Axis Transform."),2); } break; } @@ -1156,7 +1156,7 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { _edit.gizmo_handle=gizmo_handle; //_edit.gizmo_initial_pos=seg->get_handle_pos(gizmo_handle); _edit.gizmo_initial_value=seg->get_handle_value(gizmo_handle); - //print_line("GIZMO: "+itos(gizmo_handle)+" FROMPOS: "+_edit.orig_gizmo_pos); + //print_line(TTR("GIZMO: ")+itos(gizmo_handle)+" FROMPOS: "+_edit.orig_gizmo_pos); break; } @@ -1353,7 +1353,7 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { scale = Math::stepify(scale,spatial_editor->get_scale_snap()); } - set_message("Scaling to "+String::num(scale,1)+"%."); + set_message(TTR("Scaling to ")+String::num(scale,1)+"%."); scale/=100.0; Transform r; @@ -1431,7 +1431,7 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { motion.snap(snap); } - //set_message("Translating: "+motion); + //set_message(TTR("Translating: ")+motion); List<Node*> &selection = editor_selection->get_selected_node_list(); @@ -1493,13 +1493,13 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { if (snap) { angle=Math::rad2deg(angle)+snap*0.5; //else it wont reach +180 angle-=Math::fmod(angle,snap); - set_message("Rotating "+rtos(angle)+" degrees."); + set_message(TTR("Rotating ")+rtos(angle)+" degrees."); angle=Math::deg2rad(angle); } else - set_message("Rotating "+rtos(Math::rad2deg(angle))+" degrees."); + set_message(TTR("Rotating ")+rtos(Math::rad2deg(angle))+" degrees."); } else { - set_message("Rotating "+rtos(Math::rad2deg(angle))+" degrees."); + set_message(TTR("Rotating ")+rtos(Math::rad2deg(angle))+" degrees."); } @@ -1681,14 +1681,14 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { cursor.y_rot=0; if (k.mod.shift) { cursor.x_rot=-Math_PI/2.0; - set_message("Bottom View.",2); - name="Bottom"; + set_message(TTR("Bottom View."),2); + name=TTR("Bottom"); _update_name(); } else { cursor.x_rot=Math_PI/2.0; - set_message("Top View.",2); - name="Top"; + set_message(TTR("Top View."),2); + name=TTR("Top"); _update_name(); } } break; @@ -1700,14 +1700,14 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { cursor.x_rot=0; if (k.mod.shift) { cursor.y_rot=Math_PI; - set_message("Rear View.",2); - name="Rear"; + set_message(TTR("Rear View."),2); + name=TTR("Rear"); _update_name(); } else { cursor.y_rot=0; - set_message("Front View.",2); - name="Front"; + set_message(TTR("Front View."),2); + name=TTR("Front"); _update_name(); } @@ -1720,13 +1720,13 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { cursor.x_rot=0; if (k.mod.shift) { cursor.y_rot=Math_PI/2.0; - set_message("Left View.",2); - name="Left"; + set_message(TTR("Left View."),2); + name=TTR("Left"); _update_name(); } else { cursor.y_rot=-Math_PI/2.0; - set_message("Right View.",2); - name="Right"; + set_message(TTR("Right View."),2); + name=TTR("Right"); _update_name(); } @@ -1749,7 +1749,7 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { break; if (!AnimationPlayerEditor::singleton->get_key_editor()->has_keying()) { - set_message("Keying is disabled (no key inserted)."); + set_message(TTR("Keying is disabled (no key inserted).")); break; } @@ -1765,7 +1765,7 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { } - set_message("Animation Key Inserted."); + set_message(TTR("Animation Key Inserted.")); @@ -1967,7 +1967,7 @@ void SpatialEditorViewport::_draw() { if (surface->has_focus()) { Size2 size = surface->get_size(); Rect2 r =Rect2(Point2(),size); - get_stylebox("EditorFocus","EditorStyles")->draw(surface->get_canvas_item(),r); + get_stylebox(TTR("EditorFocus"),"EditorStyles")->draw(surface->get_canvas_item(),r); } @@ -2041,14 +2041,14 @@ void SpatialEditorViewport::_menu_option(int p_option) { cursor.x_rot=Math_PI/2.0; cursor.y_rot=0; - name="Top"; + name=TTR("Top"); _update_name(); } break; case VIEW_BOTTOM: { cursor.x_rot=-Math_PI/2.0; cursor.y_rot=0; - name="Bottom"; + name=TTR("Bottom"); _update_name(); } break; @@ -2056,7 +2056,7 @@ void SpatialEditorViewport::_menu_option(int p_option) { cursor.y_rot=Math_PI/2.0; cursor.x_rot=0; - name="Left"; + name=TTR("Left"); _update_name(); } break; @@ -2064,7 +2064,7 @@ void SpatialEditorViewport::_menu_option(int p_option) { cursor.y_rot=-Math_PI/2.0; cursor.x_rot=0; - name="Right"; + name=TTR("Right"); _update_name(); } break; @@ -2072,7 +2072,7 @@ void SpatialEditorViewport::_menu_option(int p_option) { cursor.y_rot=0; cursor.x_rot=0; - name="Front"; + name=TTR("Front"); _update_name(); } break; @@ -2080,7 +2080,7 @@ void SpatialEditorViewport::_menu_option(int p_option) { cursor.y_rot=Math_PI; cursor.x_rot=0; - name="Rear"; + name=TTR("Rear"); _update_name(); } break; @@ -2123,7 +2123,7 @@ void SpatialEditorViewport::_menu_option(int p_option) { List<Node*> &selection = editor_selection->get_selected_node_list(); - undo_redo->create_action("Align with view"); + undo_redo->create_action(TTR("Align with view")); for(List<Node*>::Element *E=selection.front();E;E=E->next()) { Spatial *sp = E->get()->cast_to<Spatial>(); @@ -2420,7 +2420,7 @@ void SpatialEditorViewport::reset() { message_time=0; message=""; last_message=""; - name="Top"; + name=TTR("Top"); cursor.x_rot=0; cursor.y_rot=0; @@ -2471,28 +2471,28 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed view_menu->set_pos( Point2(4,4)); view_menu->set_self_opacity(0.5); - view_menu->get_popup()->add_item("Top (Num7)",VIEW_TOP); - view_menu->get_popup()->add_item("Bottom (Shift+Num7)",VIEW_BOTTOM); - view_menu->get_popup()->add_item("Left (Num3)",VIEW_LEFT); - view_menu->get_popup()->add_item("Right (Shift+Num3)",VIEW_RIGHT); - view_menu->get_popup()->add_item("Front (Num1)",VIEW_FRONT); - view_menu->get_popup()->add_item("Rear (Shift+Num1)",VIEW_REAR); + view_menu->get_popup()->add_item(TTR("Top (Num7)"),VIEW_TOP); + view_menu->get_popup()->add_item(TTR("Bottom (Shift+Num7)"),VIEW_BOTTOM); + view_menu->get_popup()->add_item(TTR("Left (Num3)"),VIEW_LEFT); + view_menu->get_popup()->add_item(TTR("Right (Shift+Num3)"),VIEW_RIGHT); + view_menu->get_popup()->add_item(TTR("Front (Num1)"),VIEW_FRONT); + view_menu->get_popup()->add_item(TTR("Rear (Shift+Num1)"),VIEW_REAR); view_menu->get_popup()->add_separator(); - view_menu->get_popup()->add_check_item("Perspective (Num5)",VIEW_PERSPECTIVE); - view_menu->get_popup()->add_check_item("Orthogonal (Num5)",VIEW_ORTHOGONAL); + view_menu->get_popup()->add_check_item(TTR("Perspective (Num5)"),VIEW_PERSPECTIVE); + view_menu->get_popup()->add_check_item(TTR("Orthogonal (Num5)"),VIEW_ORTHOGONAL); view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_PERSPECTIVE),true); view_menu->get_popup()->add_separator(); view_menu->get_popup()->add_check_item("Environment",VIEW_ENVIRONMENT); view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(VIEW_ENVIRONMENT),true); view_menu->get_popup()->add_separator(); - view_menu->get_popup()->add_check_item("Audio Listener",VIEW_AUDIO_LISTENER); + view_menu->get_popup()->add_check_item(TTR("Audio Listener"),VIEW_AUDIO_LISTENER); view_menu->get_popup()->add_separator(); - view_menu->get_popup()->add_check_item("Gizmos",VIEW_GIZMOS); + view_menu->get_popup()->add_check_item(TTR("Gizmos"),VIEW_GIZMOS); view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(VIEW_GIZMOS),true); view_menu->get_popup()->add_separator(); - view_menu->get_popup()->add_item("Selection (F)",VIEW_CENTER_TO_SELECTION); - view_menu->get_popup()->add_item("Align with view (Ctrl+Shift+F)",VIEW_ALIGN_SELECTION_WITH_VIEW); + view_menu->get_popup()->add_item(TTR("Selection (F)"),VIEW_CENTER_TO_SELECTION); + view_menu->get_popup()->add_item(TTR("Align with view (Ctrl+Shift+F)"),VIEW_ALIGN_SELECTION_WITH_VIEW); view_menu->get_popup()->connect("item_pressed",this,"_menu_option"); preview_camera = memnew( Button ); @@ -2519,7 +2519,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed } - name="Top"; + name=TTR("Top"); _update_name(); EditorSettings::get_singleton()->connect("settings_changed",this,"update_transform_gizmo_view"); @@ -2896,7 +2896,7 @@ void SpatialEditor::_xform_dialog_action() { } - undo_redo->create_action("XForm Dialog"); + undo_redo->create_action(TTR("XForm Dialog")); List<Node*> &selection = editor_selection->get_selected_node_list(); @@ -2941,7 +2941,7 @@ void SpatialEditor::_menu_item_pressed(int p_option) { tool_button[i]->set_pressed(i==p_option); tool_mode=(ToolMode)p_option; - static const char *_mode[]={"Selection Mode.","Translation Mode.","Rotation Mode.","Scale Mode.","List Selection Mode."}; + // static const char *_mode[]={"Selection Mode.","Translation Mode.","Rotation Mode.","Scale Mode.","List Selection Mode."}; // set_message(_mode[p_option],3); update_transform_gizmo(); @@ -3545,16 +3545,16 @@ void SpatialEditor::_instance_scene() { ERR_FAIL_COND(!en); String path = en->get_scenes_dock()->get_selected_path(); if (path=="") { - set_message("No scene selected to instance!"); + set_message(TTR("No scene selected to instance!")); return; } - undo_redo->create_action("Instance at Cursor"); + undo_redo->create_action(TTR("Instance at Cursor")); Node* scene = en->request_instance_scene(path); if (!scene) { - set_message("Could not instance scene!"); + set_message(TTR("Could not instance scene!")); undo_redo->commit_action(); //bleh return; } @@ -3912,7 +3912,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { tool_button[TOOL_MODE_MOVE]->set_flat(true); button_binds[0]=MENU_TOOL_MOVE; tool_button[TOOL_MODE_MOVE]->connect("pressed", this,"_menu_item_pressed",button_binds); - tool_button[TOOL_MODE_MOVE]->set_tooltip("Move Mode (W)"); + tool_button[TOOL_MODE_MOVE]->set_tooltip(TTR("Move Mode (W)")); tool_button[TOOL_MODE_ROTATE] = memnew( ToolButton ); hbc_menu->add_child( tool_button[TOOL_MODE_ROTATE] ); @@ -3920,7 +3920,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { tool_button[TOOL_MODE_ROTATE]->set_flat(true); button_binds[0]=MENU_TOOL_ROTATE; tool_button[TOOL_MODE_ROTATE]->connect("pressed", this,"_menu_item_pressed",button_binds); - tool_button[TOOL_MODE_ROTATE]->set_tooltip("Rotate Mode (E)"); + tool_button[TOOL_MODE_ROTATE]->set_tooltip(TTR("Rotate Mode (E)")); tool_button[TOOL_MODE_SCALE] = memnew( ToolButton ); hbc_menu->add_child( tool_button[TOOL_MODE_SCALE] ); @@ -3928,7 +3928,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { tool_button[TOOL_MODE_SCALE]->set_flat(true); button_binds[0]=MENU_TOOL_SCALE; tool_button[TOOL_MODE_SCALE]->connect("pressed", this,"_menu_item_pressed",button_binds); - tool_button[TOOL_MODE_SCALE]->set_tooltip("Scale Mode (R)"); + tool_button[TOOL_MODE_SCALE]->set_tooltip(TTR("Scale Mode (R)")); instance_button = memnew( Button ); hbc_menu->add_child( instance_button ); @@ -3958,25 +3958,25 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { hbc_menu->add_child( transform_menu ); p = transform_menu->get_popup(); - p->add_check_item("Use Snap",MENU_TRANSFORM_USE_SNAP); - p->add_item("Configure Snap..",MENU_TRANSFORM_CONFIGURE_SNAP); + p->add_check_item(TTR("Use Snap"),MENU_TRANSFORM_USE_SNAP); + p->add_item(TTR("Configure Snap.."),MENU_TRANSFORM_CONFIGURE_SNAP); p->add_separator(); - p->add_check_item("Local Coords",MENU_TRANSFORM_LOCAL_COORDS); + p->add_check_item(TTR("Local Coords"),MENU_TRANSFORM_LOCAL_COORDS); //p->set_item_checked(p->get_item_count()-1,true); p->add_separator(); - p->add_item("Transform Dialog..",MENU_TRANSFORM_DIALOG); + p->add_item(TTR("Transform Dialog.."),MENU_TRANSFORM_DIALOG); p->connect("item_pressed", this,"_menu_item_pressed"); view_menu = memnew( MenuButton ); - view_menu->set_text("View"); + view_menu->set_text(TTR("View")); view_menu->set_pos( Point2( 212,0) ); hbc_menu->add_child( view_menu ); p = view_menu->get_popup(); - p->add_check_item("Use Default Light",MENU_VIEW_USE_DEFAULT_LIGHT); - p->add_check_item("Use Default sRGB",MENU_VIEW_USE_DEFAULT_SRGB); + p->add_check_item(TTR("Use Default Light"),MENU_VIEW_USE_DEFAULT_LIGHT); + p->add_check_item(TTR("Use Default sRGB"),MENU_VIEW_USE_DEFAULT_SRGB); p->add_separator(); p->add_check_item("1 Viewport",MENU_VIEW_USE_1_VIEWPORT,KEY_MASK_CMD+KEY_1); @@ -3987,15 +3987,15 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { p->add_check_item("4 Viewports",MENU_VIEW_USE_4_VIEWPORTS,KEY_MASK_CMD+KEY_4); p->add_separator(); - p->add_check_item("Display Normal",MENU_VIEW_DISPLAY_NORMAL); - p->add_check_item("Display Wireframe",MENU_VIEW_DISPLAY_WIREFRAME); - p->add_check_item("Display Overdraw",MENU_VIEW_DISPLAY_OVERDRAW); - p->add_check_item("Display Shadeless",MENU_VIEW_DISPLAY_SHADELESS); + p->add_check_item(TTR("Display Normal"),MENU_VIEW_DISPLAY_NORMAL); + p->add_check_item(TTR("Display Wireframe"),MENU_VIEW_DISPLAY_WIREFRAME); + p->add_check_item(TTR("Display Overdraw"),MENU_VIEW_DISPLAY_OVERDRAW); + p->add_check_item(TTR("Display Shadeless"),MENU_VIEW_DISPLAY_SHADELESS); p->add_separator(); - p->add_check_item("View Origin",MENU_VIEW_ORIGIN); - p->add_check_item("View Grid",MENU_VIEW_GRID); + p->add_check_item(TTR("View Origin"),MENU_VIEW_ORIGIN); + p->add_check_item(TTR("View Grid"),MENU_VIEW_GRID); p->add_separator(); - p->add_item("Settings",MENU_VIEW_CAMERA_SETTINGS); + p->add_item(TTR("Settings"),MENU_VIEW_CAMERA_SETTINGS); p->set_item_checked( p->get_item_index(MENU_VIEW_USE_DEFAULT_LIGHT), true ); @@ -4033,7 +4033,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { /* SNAP DIALOG */ snap_dialog = memnew( ConfirmationDialog ); - snap_dialog->set_title("Snap Settings"); + snap_dialog->set_title(TTR("Snap Settings")); add_child(snap_dialog); VBoxContainer *snap_dialog_vbc = memnew( VBoxContainer ); @@ -4042,20 +4042,20 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { snap_translate = memnew( LineEdit ); snap_translate->set_text("1"); - snap_dialog_vbc->add_margin_child("Translate Snap:",snap_translate); + snap_dialog_vbc->add_margin_child(TTR("Translate Snap:"),snap_translate); snap_rotate = memnew( LineEdit ); snap_rotate->set_text("5"); - snap_dialog_vbc->add_margin_child("Rotate Snap (deg.):",snap_rotate); + snap_dialog_vbc->add_margin_child(TTR("Rotate Snap (deg.):"),snap_rotate); snap_scale = memnew( LineEdit ); snap_scale->set_text("5"); - snap_dialog_vbc->add_margin_child("Scale Snap (%):",snap_scale); + snap_dialog_vbc->add_margin_child(TTR("Scale Snap (%):"),snap_scale); /* SETTINGS DIALOG */ settings_dialog = memnew( ConfirmationDialog ); - settings_dialog->set_title("Viewport Settings"); + settings_dialog->set_title(TTR("Viewport Settings")); add_child(settings_dialog); settings_vbc = memnew( VBoxContainer ); settings_vbc->set_custom_minimum_size(Size2(200,0)); @@ -4067,7 +4067,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { settings_light_base = memnew( Control ); settings_light_base->set_custom_minimum_size(Size2(128,128)); settings_light_base->connect("input_event",this,"_default_light_angle_input"); - settings_vbc->add_margin_child("Default Light Normal:",settings_light_base); + settings_vbc->add_margin_child(TTR("Default Light Normal:"),settings_light_base); settings_light_vp = memnew( Viewport ); settings_light_vp->set_disable_input(true); settings_light_vp->set_use_own_world(true); @@ -4092,7 +4092,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { settings_ambient_color = memnew( ColorPickerButton ); - settings_vbc->add_margin_child("Ambient Light Color:",settings_ambient_color); + settings_vbc->add_margin_child(TTR("Ambient Light Color:"),settings_ambient_color); settings_ambient_color->connect("color_changed",this,"_update_ambient_light_color"); viewport_environment->set_enable_fx(Environment::FX_AMBIENT_LIGHT,true); @@ -4105,30 +4105,30 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { settings_fov->set_min(1); settings_fov->set_step(0.01); settings_fov->set_val(EDITOR_DEF("3d_editor/default_fov",60.0)); - settings_vbc->add_margin_child("Perspective FOV (deg.):",settings_fov); + settings_vbc->add_margin_child(TTR("Perspective FOV (deg.):"),settings_fov); settings_znear = memnew( SpinBox ); settings_znear->set_max(10000); settings_znear->set_min(0.1); settings_znear->set_step(0.01); settings_znear->set_val(EDITOR_DEF("3d_editor/default_z_near",0.1)); - settings_vbc->add_margin_child("View Z-Near:",settings_znear); + settings_vbc->add_margin_child(TTR("View Z-Near:"),settings_znear); settings_zfar = memnew( SpinBox ); settings_zfar->set_max(10000); settings_zfar->set_min(0.1); settings_zfar->set_step(0.01); settings_zfar->set_val(EDITOR_DEF("3d_editor/default_z_far",1500)); - settings_vbc->add_margin_child("View Z-Far:",settings_zfar); + settings_vbc->add_margin_child(TTR("View Z-Far:"),settings_zfar); //settings_dialog->get_cancel()->hide(); /* XFORM DIALOG */ xform_dialog = memnew( ConfirmationDialog ); - xform_dialog->set_title("Transform Change"); + xform_dialog->set_title(TTR("Transform Change")); add_child(xform_dialog); Label *l = memnew(Label); - l->set_text("Translate:"); + l->set_text(TTR("Translate:")); l->set_pos(Point2(5,5)); xform_dialog->add_child(l); @@ -4141,7 +4141,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { } l = memnew(Label); - l->set_text("Rotate (deg.):"); + l->set_text(TTR("Rotate (deg.):")); l->set_pos(Point2(5,45)); xform_dialog->add_child(l); @@ -4153,7 +4153,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { } l = memnew(Label); - l->set_text("Scale (ratio):"); + l->set_text(TTR("Scale (ratio):")); l->set_pos(Point2(5,85)); xform_dialog->add_child(l); @@ -4165,7 +4165,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { } l = memnew(Label); - l->set_text("Transform Type"); + l->set_text(TTR("Transform Type")); l->set_pos(Point2(5,125)); xform_dialog->add_child(l); @@ -4173,8 +4173,8 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { xform_type->set_anchor( MARGIN_RIGHT, ANCHOR_END ); xform_type->set_begin( Point2(15,142) ); xform_type->set_end( Point2(15,75) ); - xform_type->add_item("Pre"); - xform_type->add_item("Post"); + xform_type->add_item(TTR("Pre")); + xform_type->add_item(TTR("Post")); xform_dialog->add_child(xform_type); xform_dialog->connect("confirmed", this,"_xform_dialog_action"); diff --git a/tools/editor/plugins/sprite_frames_editor_plugin.cpp b/tools/editor/plugins/sprite_frames_editor_plugin.cpp index af73828b61..796fc23d9a 100644 --- a/tools/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/tools/editor/plugins/sprite_frames_editor_plugin.cpp @@ -72,10 +72,10 @@ void SpriteFramesEditor::_file_load_request(const DVector<String>& p_path) { resource = ResourceLoader::load(p_path[i]); if (resource.is_null()) { - dialog->set_text("ERROR: Couldn't load frame resource!"); - dialog->set_title("Error!"); - //dialog->get_cancel()->set_text("Close"); - dialog->get_ok()->set_text("Close"); + dialog->set_text(TTR("ERROR: Couldn't load frame resource!")); + dialog->set_title(TTR("Error!")); + //dialog->get_cancel()->set_text(TTR("Close")); + dialog->get_ok()->set_text(TTR("Close")); dialog->popup_centered_minsize(); return; ///beh should show an error i guess } @@ -89,7 +89,7 @@ void SpriteFramesEditor::_file_load_request(const DVector<String>& p_path) { return; } - undo_redo->create_action("Add Frame"); + undo_redo->create_action(TTR("Add Frame")); int fc=frames->get_frame_count(); for(List< Ref<Texture> >::Element *E=resources.front();E;E=E->next() ) { @@ -144,7 +144,7 @@ void SpriteFramesEditor::_item_edited() { } RES samp = frames->get_resource(old_name); - undo_redo->create_action("Rename Resource"); + undo_redo->create_action(TTR("Rename Resource")); undo_redo->add_do_method(frames,"remove_resource",old_name); undo_redo->add_do_method(frames,"add_resource",new_name,samp); undo_redo->add_undo_method(frames,"remove_resource",new_name); @@ -170,7 +170,7 @@ void SpriteFramesEditor::_delete_confirm_pressed() { int to_remove = tree->get_selected()->get_metadata(0); sel=to_remove; Ref<Texture> r = frames->get_frame(to_remove); - undo_redo->create_action("Delete Resource"); + undo_redo->create_action(TTR("Delete Resource")); undo_redo->add_do_method(frames,"remove_frame",to_remove); undo_redo->add_undo_method(frames,"add_frame",r,to_remove); undo_redo->add_do_method(this,"_update_library"); @@ -184,16 +184,16 @@ void SpriteFramesEditor::_paste_pressed() { Ref<Texture> r=EditorSettings::get_singleton()->get_resource_clipboard(); if (!r.is_valid()) { - dialog->set_text("Resource clipboard is empty or not a texture!"); - dialog->set_title("Error!"); - //dialog->get_cancel()->set_text("Close"); - dialog->get_ok()->set_text("Close"); + dialog->set_text(TTR("Resource clipboard is empty or not a texture!")); + dialog->set_title(TTR("Error!")); + //dialog->get_cancel()->set_text(TTR("Close")); + dialog->get_ok()->set_text(TTR("Close")); dialog->popup_centered_minsize(); return; ///beh should show an error i guess } - undo_redo->create_action("Paste Frame"); + undo_redo->create_action(TTR("Paste Frame")); undo_redo->add_do_method(frames,"add_frame",r); undo_redo->add_undo_method(frames,"remove_frame",frames->get_frame_count()); undo_redo->add_do_method(this,"_update_library"); @@ -220,7 +220,7 @@ void SpriteFramesEditor::_empty_pressed() { Ref<Texture> r; - undo_redo->create_action("Add Empty"); + undo_redo->create_action(TTR("Add Empty")); undo_redo->add_do_method(frames,"add_frame",r,from); undo_redo->add_undo_method(frames,"remove_frame",from); undo_redo->add_do_method(this,"_update_library"); @@ -247,7 +247,7 @@ void SpriteFramesEditor::_empty2_pressed() { Ref<Texture> r; - undo_redo->create_action("Add Empty"); + undo_redo->create_action(TTR("Add Empty")); undo_redo->add_do_method(frames,"add_frame",r,from+1); undo_redo->add_undo_method(frames,"remove_frame",from+1); undo_redo->add_do_method(this,"_update_library"); @@ -268,7 +268,7 @@ void SpriteFramesEditor::_up_pressed() { sel-=1; Ref<Texture> r = frames->get_frame(to_move); - undo_redo->create_action("Delete Resource"); + undo_redo->create_action(TTR("Delete Resource")); undo_redo->add_do_method(frames,"set_frame",to_move,frames->get_frame(to_move-1)); undo_redo->add_do_method(frames,"set_frame",to_move-1,frames->get_frame(to_move)); undo_redo->add_undo_method(frames,"set_frame",to_move,frames->get_frame(to_move)); @@ -291,7 +291,7 @@ void SpriteFramesEditor::_down_pressed() { sel+=1; Ref<Texture> r = frames->get_frame(to_move); - undo_redo->create_action("Delete Resource"); + undo_redo->create_action(TTR("Delete Resource")); undo_redo->add_do_method(frames,"set_frame",to_move,frames->get_frame(to_move+1)); undo_redo->add_do_method(frames,"set_frame",to_move+1,frames->get_frame(to_move)); undo_redo->add_undo_method(frames,"set_frame",to_move,frames->get_frame(to_move)); @@ -313,11 +313,11 @@ void SpriteFramesEditor::_delete_pressed() { _delete_confirm_pressed(); //it has undo.. why bother with a dialog.. /* - dialog->set_title("Confirm..."); - dialog->set_text("Remove Resource '"+tree->get_selected()->get_text(0)+"' ?"); - //dialog->get_cancel()->set_text("Cancel"); + dialog->set_title(TTR("Confirm...")); + dialog->set_text(TTR("Remove Resource '")+tree->get_selected()->get_text(0)+"' ?"); + //dialog->get_cancel()->set_text(TTR("Cancel")); //dialog->get_ok()->show(); - dialog->get_ok()->set_text("Remove"); + dialog->get_ok()->set_text(TTR("Remove")); dialog->popup_centered(Size2(300,60));*/ } @@ -342,10 +342,10 @@ void SpriteFramesEditor::_update_library() { if (frames->get_frame(i).is_null()) { - ti->set_text(0,"Frame "+itos(i)+" (empty)"); + ti->set_text(0,TTR("Frame ")+itos(i)+" (empty)"); } else { - ti->set_text(0,"Frame "+itos(i)+" ("+frames->get_frame(i)->get_name()+")"); + ti->set_text(0,TTR("Frame ")+itos(i)+" ("+frames->get_frame(i)->get_name()+")"); ti->set_icon(0,frames->get_frame(i)); } if (frames->get_frame(i).is_valid()) @@ -405,30 +405,30 @@ SpriteFramesEditor::SpriteFramesEditor() { vbc->add_child(hbc); load = memnew( Button ); - load->set_tooltip("Load Resource"); + load->set_tooltip(TTR("Load Resource")); hbc->add_child(load); paste = memnew( Button ); - paste->set_text("Paste"); + paste->set_text(TTR("Paste")); hbc->add_child(paste); empty = memnew( Button ); - empty->set_text("Insert Empty (Before)"); + empty->set_text(TTR("Insert Empty (Before)")); hbc->add_child(empty); empty2 = memnew( Button ); - empty2->set_text("Insert Empty (After)"); + empty2->set_text(TTR("Insert Empty (After)")); hbc->add_child(empty2); move_up = memnew( Button ); - move_up->set_text("Up"); + move_up->set_text(TTR("Up")); hbc->add_child(move_up); move_down = memnew( Button ); - move_down->set_text("Down"); + move_down->set_text(TTR("Down")); hbc->add_child(move_down); _delete = memnew( Button ); diff --git a/tools/editor/plugins/sprite_region_editor_plugin.cpp b/tools/editor/plugins/sprite_region_editor_plugin.cpp index 8dfa8a60a6..5e7816ffb5 100644 --- a/tools/editor/plugins/sprite_region_editor_plugin.cpp +++ b/tools/editor/plugins/sprite_region_editor_plugin.cpp @@ -173,7 +173,7 @@ void SpriteRegionEditor::_region_input(const InputEvent& p_input) } else if (drag) { - undo_redo->create_action("Set region_rect"); + undo_redo->create_action(TTR("Set region_rect")); undo_redo->add_do_method(node,"set_region_rect",node->get_region_rect()); undo_redo->add_undo_method(node,"set_region_rect",rect_prev); undo_redo->add_do_method(edit_draw,"update"); @@ -420,7 +420,7 @@ SpriteRegionEditor::SpriteRegionEditor(EditorNode* p_editor) dlg_editor = memnew( AcceptDialog ); add_child(dlg_editor); - dlg_editor->set_title("Sprite Region Editor"); + dlg_editor->set_title(TTR("Sprite Region Editor")); dlg_editor->set_self_opacity(0.9); VBoxContainer *main_vb = memnew( VBoxContainer ); @@ -431,24 +431,24 @@ SpriteRegionEditor::SpriteRegionEditor(EditorNode* p_editor) b_snap_enable = memnew( ToolButton ); hb_tools->add_child(b_snap_enable); - b_snap_enable->set_text("Snap"); + b_snap_enable->set_text(TTR("Snap")); b_snap_enable->set_focus_mode(FOCUS_NONE); b_snap_enable->set_toggle_mode(true); b_snap_enable->set_pressed(use_snap); - b_snap_enable->set_tooltip("Enable Snap"); + b_snap_enable->set_tooltip(TTR("Enable Snap")); b_snap_enable->connect("toggled",this,"_set_use_snap"); b_snap_grid = memnew( ToolButton ); hb_tools->add_child(b_snap_grid); - b_snap_grid->set_text("Grid"); + b_snap_grid->set_text(TTR("Grid")); b_snap_grid->set_focus_mode(FOCUS_NONE); b_snap_grid->set_toggle_mode(true); b_snap_grid->set_pressed(snap_show_grid); - b_snap_grid->set_tooltip("Show Grid"); + b_snap_grid->set_tooltip(TTR("Show Grid")); b_snap_grid->connect("toggled",this,"_set_show_grid"); hb_tools->add_child( memnew( VSeparator )); - hb_tools->add_child( memnew( Label("Grid Offset:") ) ); + hb_tools->add_child( memnew( Label(TTR("Grid Offset:")) ) ); sb_off_x = memnew( SpinBox ); sb_off_x->set_min(-256); @@ -469,7 +469,7 @@ SpriteRegionEditor::SpriteRegionEditor(EditorNode* p_editor) hb_tools->add_child(sb_off_y); hb_tools->add_child( memnew( VSeparator )); - hb_tools->add_child( memnew( Label("Grid Step:") ) ); + hb_tools->add_child( memnew( Label(TTR("Grid Step:")) ) ); sb_step_x = memnew( SpinBox ); sb_step_x->set_min(-256); diff --git a/tools/editor/plugins/sprite_region_editor_plugin.h b/tools/editor/plugins/sprite_region_editor_plugin.h index 47cb210863..6fe235c2ea 100644 --- a/tools/editor/plugins/sprite_region_editor_plugin.h +++ b/tools/editor/plugins/sprite_region_editor_plugin.h @@ -119,7 +119,7 @@ class SpriteRegionEditorPlugin : public EditorPlugin EditorNode *editor; public: - virtual String get_name() const { return "SpriteRegion"; } + virtual String get_name() const { return TTR("SpriteRegion"); } bool has_main_screen() const { return false; } virtual void edit(Object *p_node); virtual bool handles(Object *p_node) const; diff --git a/tools/editor/plugins/stream_editor_plugin.h b/tools/editor/plugins/stream_editor_plugin.h index 5730612d61..90046a5fdf 100644 --- a/tools/editor/plugins/stream_editor_plugin.h +++ b/tools/editor/plugins/stream_editor_plugin.h @@ -69,7 +69,7 @@ class StreamEditorPlugin : public EditorPlugin { public: - virtual String get_name() const { return "Stream"; } + virtual String get_name() const { return TTR("Stream"); } bool has_main_screen() const { return false; } virtual void edit(Object *p_node); virtual bool handles(Object *p_node) const; diff --git a/tools/editor/plugins/style_box_editor_plugin.cpp b/tools/editor/plugins/style_box_editor_plugin.cpp index f08d2a7376..d5c885bd55 100644 --- a/tools/editor/plugins/style_box_editor_plugin.cpp +++ b/tools/editor/plugins/style_box_editor_plugin.cpp @@ -61,7 +61,7 @@ StyleBoxEditor::StyleBoxEditor() { panel->set_area_as_parent_rect(); Label *l = memnew( Label ); - l->set_text("StyleBox Preview:"); + l->set_text(TTR("StyleBox Preview:")); l->set_pos(Point2(5,5)); panel->add_child(l); diff --git a/tools/editor/plugins/theme_editor_plugin.cpp b/tools/editor/plugins/theme_editor_plugin.cpp index e792a2a9e2..3c394ab6ac 100644 --- a/tools/editor/plugins/theme_editor_plugin.cpp +++ b/tools/editor/plugins/theme_editor_plugin.cpp @@ -199,7 +199,7 @@ void ThemeEditor::_save_template_cbk(String fname) { if (!file) { - ERR_EXPLAIN("Can't save theme to file: "+filename); + ERR_EXPLAIN(TTR("Can't save theme to file: ")+filename); return; } file->store_line("; ******************* "); @@ -473,16 +473,16 @@ void ThemeEditor::_theme_menu_cbk(int p_option) { if (p_option==POPUP_ADD) {//add - add_del_dialog->set_title("Add Item"); - add_del_dialog->get_ok()->set_text("Add"); + add_del_dialog->set_title(TTR("Add Item")); + add_del_dialog->get_ok()->set_text(TTR("Add")); add_del_dialog->popup_centered(Size2(490,85)); base_theme=Theme::get_default(); } else if (p_option==POPUP_CLASS_ADD) {//add - add_del_dialog->set_title("Add All Items"); - add_del_dialog->get_ok()->set_text("Add All"); + add_del_dialog->set_title(TTR("Add All Items")); + add_del_dialog->get_ok()->set_text(TTR("Add All")); add_del_dialog->popup_centered(Size2(240,85)); base_theme=Theme::get_default(); @@ -495,8 +495,8 @@ void ThemeEditor::_theme_menu_cbk(int p_option) { } else if (p_option==POPUP_REMOVE) { - add_del_dialog->set_title("Remove Item"); - add_del_dialog->get_ok()->set_text("Remove"); + add_del_dialog->set_title(TTR("Remove Item")); + add_del_dialog->get_ok()->set_text(TTR("Remove")); add_del_dialog->popup_centered(Size2(490,85)); base_theme=theme; @@ -596,12 +596,12 @@ ThemeEditor::ThemeEditor() { theme_menu = memnew( MenuButton ); theme_menu->set_text("Theme"); - theme_menu->get_popup()->add_item("Add Item",POPUP_ADD); - theme_menu->get_popup()->add_item("Add Class Items",POPUP_CLASS_ADD); - theme_menu->get_popup()->add_item("Remove Item",POPUP_REMOVE); + theme_menu->get_popup()->add_item(TTR("Add Item"),POPUP_ADD); + theme_menu->get_popup()->add_item(TTR("Add Class Items"),POPUP_CLASS_ADD); + theme_menu->get_popup()->add_item(TTR("Remove Item"),POPUP_REMOVE); theme_menu->get_popup()->add_item("Remove Class Items",POPUP_CLASS_REMOVE); theme_menu->get_popup()->add_separator(); - theme_menu->get_popup()->add_item("Create Template",POPUP_CREATE_TEMPLATE); + theme_menu->get_popup()->add_item(TTR("Create Template"),POPUP_CREATE_TEMPLATE); hb_menu->add_child(theme_menu); theme_menu->get_popup()->connect("item_pressed", this,"_theme_menu_cbk"); @@ -640,30 +640,30 @@ ThemeEditor::ThemeEditor() { VBoxContainer *gbvb = memnew( VBoxContainer ); gbvb->set_v_size_flags(SIZE_EXPAND_FILL); CheckBox *rbx1 = memnew( CheckBox ); - rbx1->set_text("CheckBox Radio1"); + rbx1->set_text(TTR("CheckBox Radio1")); rbx1->set_pressed(true); gbvb->add_child(rbx1); CheckBox *rbx2 = memnew( CheckBox ); - rbx2->set_text("CheckBox Radio2"); + rbx2->set_text(TTR("CheckBox Radio2")); gbvb->add_child(rbx2); bg->add_child(gbvb); first_vb->add_child(bg); MenuButton* test_menu_button = memnew( MenuButton ); test_menu_button->set_text("MenuButton"); - test_menu_button->get_popup()->add_item("Item"); + test_menu_button->get_popup()->add_item(TTR("Item")); test_menu_button->get_popup()->add_separator(); - test_menu_button->get_popup()->add_check_item("Check Item"); - test_menu_button->get_popup()->add_check_item("Checked Item"); + test_menu_button->get_popup()->add_check_item(TTR("Check Item")); + test_menu_button->get_popup()->add_check_item(TTR("Checked Item")); test_menu_button->get_popup()->set_item_checked(2,true); first_vb->add_child(test_menu_button); OptionButton *test_option_button = memnew( OptionButton ); test_option_button->add_item("OptionButton"); test_option_button->add_separator(); - test_option_button->add_item("Has"); - test_option_button->add_item("Many"); - test_option_button->add_item("Options"); + test_option_button->add_item(TTR("Has")); + test_option_button->add_item(TTR("Many")); + test_option_button->add_item(TTR("Options")); first_vb->add_child(test_option_button); ColorPickerButton *cpb = memnew( ColorPickerButton ); @@ -714,7 +714,7 @@ ThemeEditor::ThemeEditor() { item = test_tree->create_item( test_tree->get_root() ); item->set_cell_mode(0, TreeItem::CELL_MODE_RANGE); item->set_editable(0,true); - item->set_text(0,"Have,Many,Several,Options!"); + item->set_text(0,TTR("Have,Many,Several,Options!")); item->set_range(0,2); VBoxContainer *third_vb = memnew( VBoxContainer ); @@ -734,13 +734,13 @@ ThemeEditor::ThemeEditor() { third_vb->add_child(tc); tc->set_custom_minimum_size(Size2(0,160)); Control *tcc = memnew( Control ); - tcc->set_name("Tab 1"); + tcc->set_name(TTR("Tab 1")); tc->add_child(tcc); tcc = memnew( Control ); - tcc->set_name("Tab 2"); + tcc->set_name(TTR("Tab 2")); tc->add_child(tcc); tcc = memnew( Control ); - tcc->set_name("Tab 3"); + tcc->set_name(TTR("Tab 3")); tc->add_child(tcc); main_hb->add_constant_override("separation",20); @@ -757,7 +757,7 @@ ThemeEditor::ThemeEditor() { line_edit = memnew( LineEdit ); line_edit->set_pos( Point2( 25, 275 ) ); line_edit->set_size( Point2( 150, 5 ) ); - line_edit->set_text("Line Edit"); + line_edit->set_text(TTR("Line Edit")); panel->add_child(line_edit); test_v_scroll = memnew( VScrollBar ); @@ -786,12 +786,12 @@ ThemeEditor::ThemeEditor() { item = test_tree->create_item( test_tree->get_root() ); item->set_cell_mode(0, TreeItem::CELL_MODE_RANGE); item->set_editable(0,true); - item->set_text(0,"Have,Many,Several,Options!"); + item->set_text(0,TTR("Have,Many,Several,Options!")); item->set_range(0,2); Button *fd_button= memnew( Button ); fd_button->set_pos(Point2(300,275)); - fd_button->set_text("Open File Dialog"); + fd_button->set_text(TTR("Open File Dialog")); panel->add_child(fd_button); test_file_dialog = memnew( EditorFileDialog ); @@ -807,7 +807,7 @@ ThemeEditor::ThemeEditor() { Label *l = memnew( Label ); l->set_pos( Point2(5,5) ); - l->set_text("Type:"); + l->set_text(TTR("Type:")); add_del_dialog->add_child(l); dtype_select_label=l; @@ -826,7 +826,7 @@ ThemeEditor::ThemeEditor() { l = memnew( Label ); l->set_pos( Point2(200,5) ); - l->set_text("Name:"); + l->set_text(TTR("Name:")); add_del_dialog->add_child(l); name_select_label=l; @@ -846,15 +846,15 @@ ThemeEditor::ThemeEditor() { type_select_label= memnew( Label ); type_select_label->set_pos( Point2(400,5) ); - type_select_label->set_text("Data Type:"); + type_select_label->set_text(TTR("Data Type:")); add_del_dialog->add_child(type_select_label); type_select = memnew( OptionButton ); - type_select->add_item("Icon"); - type_select->add_item("Style"); + type_select->add_item(TTR("Icon")); + type_select->add_item(TTR("Style")); type_select->add_item("Font"); type_select->add_item("Color"); - type_select->add_item("Constant"); + type_select->add_item(TTR("Constant")); type_select->set_pos( Point2( 400,25 ) ); type_select->set_size( Point2( 80,5 ) ); diff --git a/tools/editor/plugins/tile_map_editor_plugin.cpp b/tools/editor/plugins/tile_map_editor_plugin.cpp index 30ec6c086c..843fc35d8b 100644 --- a/tools/editor/plugins/tile_map_editor_plugin.cpp +++ b/tools/editor/plugins/tile_map_editor_plugin.cpp @@ -581,7 +581,7 @@ bool TileMapEditor::forward_input_event(const InputEvent& p_event) { if (id!=TileMap::INVALID_CELL && paint_undo.size()) { - undo_redo->create_action("Paint TileMap"); + undo_redo->create_action(TTR("Paint TileMap")); for (Map<Point2i,CellOp>::Element *E=paint_undo.front();E;E=E->next()) { Point2 p=E->key(); @@ -630,7 +630,7 @@ bool TileMapEditor::forward_input_event(const InputEvent& p_event) { Point2 ofs = over_tile-rectangle.pos; - undo_redo->create_action("Duplicate"); + undo_redo->create_action(TTR("Duplicate")); for (List<TileData>::Element *E=copydata.front();E;E=E->next()) { _set_cell(E->get().pos+ofs,E->get().cell,E->get().flip_h,E->get().flip_v,E->get().transpose,true); @@ -725,7 +725,7 @@ bool TileMapEditor::forward_input_event(const InputEvent& p_event) { if (tool==TOOL_ERASING || tool==TOOL_RECTANGLE_ERASE || tool==TOOL_LINE_ERASE) { if (paint_undo.size()) { - undo_redo->create_action("Erase TileMap"); + undo_redo->create_action(TTR("Erase TileMap")); for (Map<Point2i,CellOp>::Element *E=paint_undo.front();E;E=E->next()) { Point2 p=E->key(); @@ -1323,7 +1323,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { p->add_item("Pick Tile", OPTION_PICK_TILE, KEY_CONTROL); p->add_separator(); p->add_item("Select", OPTION_SELECT, KEY_MASK_CMD+KEY_B); - p->add_item("Duplicate Selection", OPTION_DUPLICATE, KEY_MASK_CMD+KEY_D); + p->add_item(TTR("Duplicate Selection"), OPTION_DUPLICATE, KEY_MASK_CMD+KEY_D); p->add_item("Erase Selection", OPTION_ERASE_SELECTION, KEY_DELETE); p->connect("item_pressed", this, "_menu_option"); @@ -1334,19 +1334,19 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { transp = memnew( ToolButton ); transp->set_toggle_mode(true); - transp->set_tooltip("Transpose"); + transp->set_tooltip(TTR("Transpose")); transp->set_focus_mode(FOCUS_NONE); transp->connect("pressed", this, "_update_transform_buttons", make_binds(transp)); toolbar->add_child(transp); mirror_x = memnew( ToolButton ); mirror_x->set_toggle_mode(true); - mirror_x->set_tooltip("Mirror X (A)"); + mirror_x->set_tooltip(TTR("Mirror X (A)")); mirror_x->set_focus_mode(FOCUS_NONE); mirror_x->connect("pressed", this, "_update_transform_buttons", make_binds(mirror_x)); toolbar->add_child(mirror_x); mirror_y = memnew( ToolButton ); mirror_y->set_toggle_mode(true); - mirror_y->set_tooltip("Mirror Y (S)"); + mirror_y->set_tooltip(TTR("Mirror Y (S)")); mirror_y->set_focus_mode(FOCUS_NONE); mirror_y->connect("pressed", this, "_update_transform_buttons", make_binds(mirror_y)); toolbar->add_child(mirror_y); @@ -1355,25 +1355,25 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { rotate_0 = memnew( ToolButton ); rotate_0->set_toggle_mode(true); - rotate_0->set_tooltip("Rotate 0 degrees"); + rotate_0->set_tooltip(TTR("Rotate 0 degrees")); rotate_0->set_focus_mode(FOCUS_NONE); rotate_0->connect("pressed", this, "_update_transform_buttons", make_binds(rotate_0)); toolbar->add_child(rotate_0); rotate_90 = memnew( ToolButton ); rotate_90->set_toggle_mode(true); - rotate_90->set_tooltip("Rotate 90 degrees"); + rotate_90->set_tooltip(TTR("Rotate 90 degrees")); rotate_90->set_focus_mode(FOCUS_NONE); rotate_90->connect("pressed", this, "_update_transform_buttons", make_binds(rotate_90)); toolbar->add_child(rotate_90); rotate_180 = memnew( ToolButton ); rotate_180->set_toggle_mode(true); - rotate_180->set_tooltip("Rotate 180 degrees"); + rotate_180->set_tooltip(TTR("Rotate 180 degrees")); rotate_180->set_focus_mode(FOCUS_NONE); rotate_180->connect("pressed", this, "_update_transform_buttons", make_binds(rotate_180)); toolbar->add_child(rotate_180); rotate_270 = memnew( ToolButton ); rotate_270->set_toggle_mode(true); - rotate_270->set_tooltip("Rotate 270 degrees"); + rotate_270->set_tooltip(TTR("Rotate 270 degrees")); rotate_270->set_focus_mode(FOCUS_NONE); rotate_270->connect("pressed", this, "_update_transform_buttons", make_binds(rotate_270)); toolbar->add_child(rotate_270); diff --git a/tools/editor/plugins/tile_set_editor_plugin.cpp b/tools/editor/plugins/tile_set_editor_plugin.cpp index 06046b226a..b77d3fb5b3 100644 --- a/tools/editor/plugins/tile_set_editor_plugin.cpp +++ b/tools/editor/plugins/tile_set_editor_plugin.cpp @@ -175,7 +175,7 @@ void TileSetEditor::_name_dialog_confirm(const String& name) { if (tileset->has_tile(id)) { tileset->remove_tile(id); } else { - err_dialog->set_text("Could not find tile: " + name); + err_dialog->set_text(TTR("Could not find tile: ") + name); err_dialog->popup_centered(Size2(300, 60)); } } break; @@ -193,18 +193,18 @@ void TileSetEditor::_menu_cbk(int p_option) { } break; case MENU_OPTION_REMOVE_ITEM: { - nd->set_title("Remove Item"); - nd->set_text("Item name or ID:"); + nd->set_title(TTR("Remove Item")); + nd->set_text(TTR("Item name or ID:")); nd->popup_centered(Size2(300, 95)); } break; case MENU_OPTION_CREATE_FROM_SCENE: { - cd->set_text("Create from scene?"); + cd->set_text(TTR("Create from scene?")); cd->popup_centered(Size2(300,60)); } break; case MENU_OPTION_MERGE_FROM_SCENE: { - cd->set_text("Merge from scene?"); + cd->set_text(TTR("Merge from scene?")); cd->popup_centered(Size2(300,60)); } break; } @@ -235,11 +235,11 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) { panel->add_child(options); options->set_pos(Point2(1,1)); options->set_text("Theme"); - options->get_popup()->add_item("Add Item",MENU_OPTION_ADD_ITEM); - options->get_popup()->add_item("Remove Item",MENU_OPTION_REMOVE_ITEM); + options->get_popup()->add_item(TTR("Add Item"),MENU_OPTION_ADD_ITEM); + options->get_popup()->add_item(TTR("Remove Item"),MENU_OPTION_REMOVE_ITEM); options->get_popup()->add_separator(); - options->get_popup()->add_item("Create from Scene",MENU_OPTION_CREATE_FROM_SCENE); - options->get_popup()->add_item("Merge from Scene",MENU_OPTION_MERGE_FROM_SCENE); + options->get_popup()->add_item(TTR("Create from Scene"),MENU_OPTION_CREATE_FROM_SCENE); + options->get_popup()->add_item(TTR("Merge from Scene"),MENU_OPTION_MERGE_FROM_SCENE); options->get_popup()->connect("item_pressed", this,"_menu_cbk"); editor=p_editor; cd = memnew(ConfirmationDialog); @@ -254,7 +254,7 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) { err_dialog = memnew(AcceptDialog); add_child(err_dialog); - err_dialog->set_title("Error"); + err_dialog->set_title(TTR("Error")); } void TileSetEditorPlugin::edit(Object *p_node) { diff --git a/tools/editor/project_export.cpp b/tools/editor/project_export.cpp index 199d7646d4..c024336f27 100644 --- a/tools/editor/project_export.cpp +++ b/tools/editor/project_export.cpp @@ -258,7 +258,7 @@ void ProjectExportDialog::_script_edited(Variant v) { if (updating_script) return; updating_script=true; - EditorNode::get_undo_redo()->create_action("Edit Script Options"); + EditorNode::get_undo_redo()->create_action(TTR("Edit Script Options")); EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(),"script_set_action",script_mode->get_selected()); EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(),"script_set_action",EditorImportExport::get_singleton()->script_get_action()); EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(),"script_set_encryption_key",script_key->get_text()); @@ -454,10 +454,10 @@ void ProjectExportDialog::_export_action(const String& p_file) { while(true) { - print_line("TESTING: "+location.plus_file("engine.cfg")); + print_line(TTR("TESTING: ")+location.plus_file("engine.cfg")); if (FileAccess::exists(location.plus_file("engine.cfg"))) { - error->set_text("Please export outside the project folder!"); + error->set_text(TTR("Please export outside the project folder!")); error->popup_centered_minsize(); return; } @@ -484,7 +484,7 @@ void ProjectExportDialog::_export_action(const String& p_file) { bool debugging_enabled = EditorImportExport::get_singleton()->get_export_platform(platform)->is_debugging_enabled(); Error err = export_platform(platform,p_file,debugging_enabled,file_export_password->get_text(),false); if (err!=OK) { - error->set_text("Error exporting project!"); + error->set_text(TTR("Error exporting project!")); error->popup_centered_minsize(); } @@ -505,7 +505,7 @@ void ProjectExportDialog::_export_action_pck(const String& p_file) { if (p_file.ends_with(".pck")) { FileAccess *f = FileAccess::open(p_file,FileAccess::WRITE); if (!f) { - error->set_text("Error exporting project PCK! Can't write"); + error->set_text(TTR("Error exporting project PCK! Can't write")); error->popup_centered_minsize(); } ERR_FAIL_COND(!f); @@ -514,7 +514,7 @@ void ProjectExportDialog::_export_action_pck(const String& p_file) { memdelete(f); if (err!=OK) { - error->set_text("Error exporting project!"); + error->set_text(TTR("Error exporting project!")); error->popup_centered_minsize(); return; } @@ -523,7 +523,7 @@ void ProjectExportDialog::_export_action_pck(const String& p_file) { Error err = exporter->save_zip(p_file,false); if (err!=OK) { - error->set_text("Error exporting project!"); + error->set_text(TTR("Error exporting project!")); error->popup_centered_minsize(); return; } @@ -539,7 +539,7 @@ Error ProjectExportDialog::export_platform(const String& p_platform, const Strin List<StringName> platforms; EditorImportExport::get_singleton()->get_export_platforms(&platforms); - print_line("Valid export plaftorms are:"); + print_line(TTR("Valid export plaftorms are:")); for (List<StringName>::Element *E=platforms.front();E;E=E->next()) print_line(" \""+E->get()+"\""); @@ -552,7 +552,7 @@ Error ProjectExportDialog::export_platform(const String& p_platform, const Strin } Error err = exporter->export_project(p_path,p_debug); if (err!=OK) { - error->set_text("Error exporting project!"); + error->set_text(TTR("Error exporting project!")); error->popup_centered_minsize(); ERR_PRINT("Exporting failed!"); if (p_quit_after) { @@ -586,7 +586,7 @@ void ProjectExportDialog::custom_action(const String&) { Ref<EditorExportPlatform> exporter = EditorImportExport::get_singleton()->get_export_platform(platform); if (exporter.is_null()) { - error->set_text("No exporter for platform '"+platform+"' yet."); + error->set_text(TTR("No exporter for platform '")+platform+"' yet."); error->popup_centered_minsize(); return; } @@ -715,7 +715,7 @@ bool ProjectExportDialog::_update_group_treef(TreeItem *p_parent,EditorFileSyste String filter=group_images_filter->get_text(); StringName current_group = _get_selected_group(); - String check_text="Include"; + String check_text=TTR("Include"); for(int i=0;i<p_dir->get_file_count();i++) { @@ -805,7 +805,7 @@ void ProjectExportDialog::_group_changed(Variant v) { return; updating=true; StringName name = _get_selected_group(); - EditorNode::get_undo_redo()->create_action("Change Image Group"); + EditorNode::get_undo_redo()->create_action(TTR("Change Image Group")); EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(),"image_export_group_set_image_action",name,group_image_action->get_selected()); EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(),"image_export_group_set_make_atlas",name,group_atlas->is_pressed()); EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(),"image_export_group_set_shrink",name,group_shrink->get_val()); @@ -841,7 +841,7 @@ void ProjectExportDialog::_group_item_edited() { } print_line("changed "+path+" to group: "+group); - EditorNode::get_undo_redo()->create_action("Change Image Group"); + EditorNode::get_undo_redo()->create_action(TTR("Change Image Group")); EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(),"image_add_to_export_group",path,group); EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(),"image_add_to_export_group",path,EditorImportExport::get_singleton()->image_get_export_group(path)); EditorNode::get_undo_redo()->add_undo_method(this,"_update_group_tree"); @@ -858,17 +858,17 @@ void ProjectExportDialog::_group_add() { if (name=="") { group_new_name_error->show(); - group_new_name_error->set_text("Group Name Can't be Empty!"); + group_new_name_error->set_text(TTR("Group Name Can't be Empty!")); return; } if (name.find("/")!=-1 || name.find(":")!=-1 || name.find(",")!=-1 || name.find("-")!=-1) { - group_new_name_error->set_text("Invalid Character in Group Name!"); + group_new_name_error->set_text(TTR("Invalid Character in Group Name!")); group_new_name_error->show(); return; } if (EditorImportExport::get_singleton()->image_export_has_group(name)) { - group_new_name_error->set_text("Group Name Already Exists!"); + group_new_name_error->set_text(TTR("Group Name Already Exists!")); group_new_name_error->show(); return; } @@ -877,7 +877,7 @@ void ProjectExportDialog::_group_add() { String current=_get_selected_group(); - EditorNode::get_undo_redo()->create_action("Add Image Group"); + EditorNode::get_undo_redo()->create_action(TTR("Add Image Group")); EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(),"image_export_group_create",name); EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(),"image_export_group_remove",name); EditorNode::get_undo_redo()->add_do_method(this,"_update_group_list"); @@ -903,7 +903,7 @@ void ProjectExportDialog::_group_del(Object *p_item, int p_column, int p_button) return; String name = item->get_text(0); - EditorNode::get_undo_redo()->create_action("Delete Image Group"); + EditorNode::get_undo_redo()->create_action(TTR("Delete Image Group")); List<StringName> images_used; EditorImportExport::get_singleton()->image_export_get_images_in_group(name,&images_used); for (List<StringName>::Element*E=images_used.front();E;E=E->next()) { @@ -962,7 +962,7 @@ void ProjectExportDialog::_group_select_all() { if (items.size()==0) return; - EditorNode::get_undo_redo()->create_action("Select All"); + EditorNode::get_undo_redo()->create_action(TTR("Select All")); for (List<StringName>::Element *E=items.front();E;E=E->next()) { @@ -1001,7 +1001,7 @@ void ProjectExportDialog::_group_select_none(){ if (items.size()==0) return; - EditorNode::get_undo_redo()->create_action("Select All"); + EditorNode::get_undo_redo()->create_action(TTR("Select All")); for (List<StringName>::Element *E=items.front();E;E=E->next()) { @@ -1061,13 +1061,13 @@ void ProjectExportDialog::_group_atlas_preview() { Error err = plugin->import2(dst_file,imd,EditorExportPlatform::IMAGE_COMPRESSION_NONE,true); if (err) { - EditorNode::add_io_error("Error saving atlas! "+dst_file.get_file()); + EditorNode::add_io_error(TTR("Error saving atlas! ")+dst_file.get_file()); return; } Ref<Texture> tex = ResourceLoader::load(dst_file); atlas_preview_frame->set_texture(tex); //clear previous - atlas_preview_dialog->set_title("Atlas Preview ("+itos(tex->get_width())+"x"+itos(tex->get_height())+")"); + atlas_preview_dialog->set_title(TTR("Atlas Preview (")+itos(tex->get_width())+"x"+itos(tex->get_height())+")"); atlas_preview_dialog->popup_centered_ratio(0.9); } @@ -1136,7 +1136,7 @@ void ProjectExportDialog::_bind_methods() { ProjectExportDialog::ProjectExportDialog(EditorNode *p_editor) { editor=p_editor; - set_title("Project Export Settings"); + set_title(TTR("Project Export Settings")); sections = memnew( TabContainer ); add_child(sections); @@ -1144,7 +1144,7 @@ ProjectExportDialog::ProjectExportDialog(EditorNode *p_editor) { VBoxContainer *pvbox = memnew( VBoxContainer ); sections->add_child(pvbox); - pvbox->set_name("Target"); + pvbox->set_name(TTR("Target")); HBoxContainer *phbox = memnew( HBoxContainer ); pvbox->add_child(phbox); @@ -1162,7 +1162,7 @@ ProjectExportDialog::ProjectExportDialog(EditorNode *p_editor) { phbox->add_child(vb); platforms = memnew( Tree ); platforms->set_hide_root(true); - vb->add_margin_child("Export to Platform",platforms,true); + vb->add_margin_child(TTR("Export to Platform"),platforms,true); platforms->connect("cell_selected",this,"_platform_selected"); @@ -1173,7 +1173,7 @@ ProjectExportDialog::ProjectExportDialog(EditorNode *p_editor) { vb->set_v_size_flags(SIZE_EXPAND_FILL); platform_options = memnew( PropertyEditor() ); platform_options->hide_top_label(); - vb->add_margin_child("Options",platform_options,true); + vb->add_margin_child(TTR("Options"),platform_options,true); platform_options->connect("property_edited",this,"_prop_edited"); @@ -1181,16 +1181,16 @@ ProjectExportDialog::ProjectExportDialog(EditorNode *p_editor) { ////////////////// vb = memnew( VBoxContainer ); - vb->set_name("Resources"); + vb->set_name(TTR("Resources")); sections->add_child(vb); export_mode = memnew( OptionButton ); - export_mode->add_item("Export selected resources (including dependencies)."); - export_mode->add_item("Export all resources in the project."); - export_mode->add_item("Export all files in the project directory."); + export_mode->add_item(TTR("Export selected resources (including dependencies).")); + export_mode->add_item(TTR("Export all resources in the project.")); + export_mode->add_item(TTR("Export all files in the project directory.")); export_mode->connect("item_selected",this,"_export_mode_changed"); - vb->add_margin_child("Export Mode:",export_mode); + vb->add_margin_child(TTR("Export Mode:"),export_mode); @@ -1199,36 +1199,36 @@ ProjectExportDialog::ProjectExportDialog(EditorNode *p_editor) { tree_vb->set_v_size_flags(SIZE_EXPAND_FILL); tree = memnew( Tree ); - tree_vb->add_margin_child("Resources to Export:",tree,true); + tree_vb->add_margin_child(TTR("Resources to Export:"),tree,true); tree->set_v_size_flags(SIZE_EXPAND_FILL); tree->connect("item_edited",this,"_tree_changed"); tree->set_columns(2); tree->set_column_titles_visible(true); - tree->set_column_title(0,"File"); - tree->set_column_title(1,"Action"); + tree->set_column_title(0,TTR("File")); + tree->set_column_title(1,TTR("Action")); tree->set_column_expand(1,false); tree->set_column_min_width(1,90); filters = memnew( LineEdit ); - vb->add_margin_child("Filters to export non-resource files (Comma Separated, eg: *.json, *.txt):",filters); + vb->add_margin_child(TTR("Filters to export non-resource files (Comma Separated, eg: *.json, *.txt):"),filters); filters->connect("text_changed",this,"_filters_edited"); filters_exclude = memnew( LineEdit ); - vb->add_margin_child("Filters to exclude from export (Comma Separated, eg: *.json, *.txt):",filters_exclude); + vb->add_margin_child(TTR("Filters to exclude from export (Comma Separated, eg: *.json, *.txt):"),filters_exclude); filters_exclude->connect("text_changed",this,"_filters_exclude_edited"); convert_text_scenes = memnew( CheckButton ); - convert_text_scenes->set_text("Convert text scenes to binary on export"); + convert_text_scenes->set_text(TTR("Convert text scenes to binary on export")); vb->add_child(convert_text_scenes); convert_text_scenes->connect("toggled",this,"_export_mode_changed"); image_vb = memnew( VBoxContainer ); - image_vb->set_name("Images"); + image_vb->set_name(TTR("Images")); image_action = memnew( OptionButton ); - image_action->add_item("Keep Original"); - image_action->add_item("Compress for Disk (Lossy, WebP)"); - image_action->add_item("Compress for RAM (BC/PVRTC/ETC)"); - image_vb->add_margin_child("Convert Images (*.png):",image_action); + image_action->add_item(TTR("Keep Original")); + image_action->add_item(TTR("Compress for Disk (Lossy, WebP)")); + image_action->add_item(TTR("Compress for RAM (BC/PVRTC/ETC)")); + image_vb->add_margin_child(TTR("Convert Images (*.png):"),image_action); HBoxContainer *qhb = memnew( HBoxContainer ); image_quality = memnew( HSlider ); qhb->add_child(image_quality); @@ -1239,12 +1239,12 @@ ProjectExportDialog::ProjectExportDialog(EditorNode *p_editor) { image_quality->set_min(0); image_quality->set_max(1); image_quality->set_step(0.01); - image_vb->add_margin_child("Compress for Disk (Lossy) Quality:",qhb); + image_vb->add_margin_child(TTR("Compress for Disk (Lossy) Quality:"),qhb); image_shrink = memnew( SpinBox ); image_shrink->set_min(1); image_shrink->set_max(8); image_shrink->set_step(0.1); - image_vb->add_margin_child("Shrink All Images:",image_shrink); + image_vb->add_margin_child(TTR("Shrink All Images:"),image_shrink); sections->add_child(image_vb); image_formats=memnew(Tree); @@ -1260,11 +1260,11 @@ ProjectExportDialog::ProjectExportDialog(EditorNode *p_editor) { fmt->set_editable(0,true); formats.push_back(fmt); } - image_vb->add_margin_child("Compress Formats: ",image_formats,true); + image_vb->add_margin_child(TTR("Compress Formats: "),image_formats,true); /// groups HBoxContainer *group_hb = memnew( HBoxContainer ); - group_hb->set_name("Image Groups"); + group_hb->set_name(TTR("Image Groups")); sections->add_child(group_hb); VBoxContainer *group_vb_left = memnew( VBoxContainer); group_hb->add_child(group_vb_left); @@ -1293,18 +1293,18 @@ ProjectExportDialog::ProjectExportDialog(EditorNode *p_editor) { groups->set_hide_root(true); gvb->add_child(groups); - group_vb_left->add_margin_child("Groups:",gvb,true); + group_vb_left->add_margin_child(TTR("Groups:"),gvb,true); //group_vb_left->add_child( memnew( HSeparator)); group_options = memnew(VBoxContainer); group_vb_left->add_child(group_options); group_image_action = memnew(OptionButton); - group_image_action->add_item("Default"); - group_image_action->add_item("Compress Disk"); - group_image_action->add_item("Compress RAM"); - group_image_action->add_item("Keep Original"); - group_options->add_margin_child("Compress Mode:",group_image_action); + group_image_action->add_item(TTR("Default")); + group_image_action->add_item(TTR("Compress Disk")); + group_image_action->add_item(TTR("Compress RAM")); + group_image_action->add_item(TTR("Keep Original")); + group_options->add_margin_child(TTR("Compress Mode:"),group_image_action); group_image_action->connect("item_selected",this,"_group_changed"); group_lossy_quality = memnew( HSlider ); @@ -1312,12 +1312,12 @@ ProjectExportDialog::ProjectExportDialog(EditorNode *p_editor) { group_lossy_quality->set_max(1.0); group_lossy_quality->set_step(0.1); group_lossy_quality->set_val(0.7); - group_options->add_margin_child("Lossy Quality:",group_lossy_quality); + group_options->add_margin_child(TTR("Lossy Quality:"),group_lossy_quality); group_lossy_quality->connect("value_changed",this,"_quality_edited"); group_atlas = memnew(CheckButton); - group_atlas->set_pressed("Generate Atlas"); - group_options->add_margin_child("Atlas:",group_atlas); + group_atlas->set_pressed(true); + group_options->add_margin_child(TTR("Atlas:"),group_atlas); group_atlas->connect("toggled",this,"_group_changed"); group_shrink = memnew(SpinBox); @@ -1325,11 +1325,11 @@ ProjectExportDialog::ProjectExportDialog(EditorNode *p_editor) { group_shrink->set_max(8); group_shrink->set_val(1); group_shrink->set_step(0.001); - group_options->add_margin_child("Shrink By:",group_shrink); + group_options->add_margin_child(TTR("Shrink By:"),group_shrink); group_shrink->connect("value_changed",this,"_group_changed"); atlas_preview = memnew( Button ); - atlas_preview->set_text("Preview Atlas"); + atlas_preview->set_text(TTR("Preview Atlas")); group_options->add_child(atlas_preview); atlas_preview->show(); atlas_preview->connect("pressed",this,"_group_atlas_preview"); @@ -1344,21 +1344,21 @@ ProjectExportDialog::ProjectExportDialog(EditorNode *p_editor) { HBoxContainer *filter_hb = memnew (HBoxContainer); group_images_filter = memnew( LineEdit ); - group_vb_right->add_margin_child("Image Filter:",filter_hb); + group_vb_right->add_margin_child(TTR("Image Filter:"),filter_hb); filter_hb->add_child(group_images_filter); group_images_filter->set_h_size_flags(SIZE_EXPAND_FILL); group_images_filter->connect("text_changed",this,"_image_filter_changed"); group_images = memnew( Tree ); group_images->set_v_size_flags(SIZE_EXPAND_FILL); - group_vb_right->add_margin_child("Images:",group_images,true); + group_vb_right->add_margin_child(TTR("Images:"),group_images,true); Button *filt_select_all = memnew( Button ); - filt_select_all->set_text("Select All"); + filt_select_all->set_text(TTR("Select All")); filter_hb->add_child(filt_select_all); filt_select_all->connect("pressed",this,"_group_select_all"); Button *filt_select_none = memnew( Button ); - filt_select_none->set_text("Select None"); + filt_select_none->set_text(TTR("Select None")); filter_hb->add_child(filt_select_none); filt_select_none->connect("pressed",this,"_group_select_none"); @@ -1378,7 +1378,7 @@ ProjectExportDialog::ProjectExportDialog(EditorNode *p_editor) { group_images->set_column_min_width(1,100); group_images->set_column_titles_visible(true); group_images->set_column_title(0,"Image"); - group_images->set_column_title(1,"Group"); + group_images->set_column_title(1,TTR("Group")); group_images->connect("item_edited",this,"_group_item_edited",varray(),CONNECT_DEFERRED); /* SpinBox *group_shrink; @@ -1405,30 +1405,30 @@ ProjectExportDialog::ProjectExportDialog(EditorNode *p_editor) { sample_vbox = memnew( VBoxContainer ); - sample_vbox->set_name("Samples"); + sample_vbox->set_name(TTR("Samples")); sections->add_child(sample_vbox); sample_mode = memnew( OptionButton ); - sample_vbox->add_margin_child("Sample Conversion Mode: (.wav files):",sample_mode); - sample_mode->add_item("Keep"); - sample_mode->add_item("Compress (RAM - IMA-ADPCM)"); + sample_vbox->add_margin_child(TTR("Sample Conversion Mode: (.wav files):"),sample_mode); + sample_mode->add_item(TTR("Keep")); + sample_mode->add_item(TTR("Compress (RAM - IMA-ADPCM)")); sample_max_hz = memnew( SpinBox ); sample_max_hz->set_max(192000); sample_max_hz->set_min(8000); - sample_vbox->add_margin_child("Sampling Rate Limit: (hz)",sample_max_hz); + sample_vbox->add_margin_child(TTR("Sampling Rate Limit: (hz)"),sample_max_hz); sample_trim = memnew( CheckButton ); - sample_trim->set_text("Trim"); - sample_vbox->add_margin_child("Trailing Silence:",sample_trim); + sample_trim->set_text(TTR("Trim")); + sample_vbox->add_margin_child(TTR("Trailing Silence:"),sample_trim); script_vbox = memnew( VBoxContainer ); script_vbox->set_name("Script"); sections->add_child(script_vbox); script_mode = memnew( OptionButton ); - script_vbox->add_margin_child("Script Export Mode:",script_mode); - script_mode->add_item("Text"); - script_mode->add_item("Compiled"); - script_mode->add_item("Encrypted (Provide Key Below)"); + script_vbox->add_margin_child(TTR("Script Export Mode:"),script_mode); + script_mode->add_item(TTR("Text")); + script_mode->add_item(TTR("Compiled")); + script_mode->add_item(TTR("Encrypted (Provide Key Below)")); script_key = memnew( LineEdit ); - script_vbox->add_margin_child("Script Encryption Key (256-bits as hex):",script_key); + script_vbox->add_margin_child(TTR("Script Encryption Key (256-bits as hex):"),script_key); @@ -1441,7 +1441,7 @@ ProjectExportDialog::ProjectExportDialog(EditorNode *p_editor) { add_child(confirm); confirm->connect("confirmed",this,"_confirmed"); - get_ok()->set_text("Export PCK/Zip"); + get_ok()->set_text(TTR("Export PCK/Zip")); expopt="--,Export,Bundle"; @@ -1451,24 +1451,24 @@ ProjectExportDialog::ProjectExportDialog(EditorNode *p_editor) { file_export->set_access(EditorFileDialog::ACCESS_FILESYSTEM); file_export->set_current_dir( EditorSettings::get_singleton()->get("global/default_project_export_path") ); - file_export->set_title("Export Project"); + file_export->set_title(TTR("Export Project")); file_export->connect("file_selected", this,"_export_action"); file_export_password = memnew( LineEdit ); file_export_password->set_secret(true); file_export_password->set_editable(false); - file_export->get_vbox()->add_margin_child("Password:",file_export_password); + file_export->get_vbox()->add_margin_child(TTR("Password:"),file_export_password); pck_export = memnew( EditorFileDialog ); pck_export->set_access(EditorFileDialog::ACCESS_FILESYSTEM); pck_export->set_current_dir( EditorSettings::get_singleton()->get("global/default_project_export_path") ); - pck_export->set_title("Export Project PCK"); + pck_export->set_title(TTR("Export Project PCK")); pck_export->connect("file_selected", this,"_export_action_pck"); pck_export->add_filter("*.pck ; Data Pack"); pck_export->add_filter("*.zip ; Zip"); add_child(pck_export); - button_export = add_button("Export..",!OS::get_singleton()->get_swap_ok_cancel(),"export_pck"); + button_export = add_button(TTR("Export.."),!OS::get_singleton()->get_swap_ok_cancel(),"export_pck"); updating_script=false; ei="EditorIcons"; @@ -1522,7 +1522,7 @@ Error ProjectExport::export_project(const String& p_preset) { String preset_path=Globals::get_singleton()->get("export_presets_path/"+selected); if (preset_path=="") { - error->set_text("Export path empty, see export options"); + error->set_text(TTR("Export path empty, see export options")); error->popup_centered_minsize(Size2(300,100)); ERR_FAIL_V(ERR_INVALID_DATA); } @@ -1544,9 +1544,9 @@ Error ProjectExport::export_project(const String& p_preset) { } if (pc%3 != 0 ) { memdelete(d); - error->set_text("Corrupted export data.."); + error->set_text(TTR("Corrupted export data..")); error->popup_centered_minsize(Size2(300,100)); - ERR_EXPLAIN("Corrupted export data..."); + ERR_EXPLAIN(TTR("Corrupted export data...")); ERR_FAIL_V(ERR_INVALID_DATA); } @@ -1681,7 +1681,7 @@ Error ProjectExport::export_project(const String& p_preset) { else preset=names[E->get().action-2]; - print_line("Exporting "+itos(idx)+"/"+itos(export_action.size())+": "+path); + print_line(TTR("Exporting ")+itos(idx)+"/"+itos(export_action.size())+": "+path); String base_dir = Globals::get_singleton()->localize_path(path.get_base_dir()).replace("\\","/").replace("res://",""); DirAccess *da=DirAccess::create(DirAccess::ACCESS_FILESYSTEM); @@ -1699,7 +1699,7 @@ Error ProjectExport::export_project(const String& p_preset) { if (err!=OK) { memdelete(da); memdelete(d); - ERR_EXPLAIN("Cannot make dir: "+cwd+"/"+p); + ERR_EXPLAIN(TTR("Cannot make dir: ")+cwd+"/"+p); ERR_FAIL_V(ERR_CANT_CREATE); } @@ -1707,7 +1707,7 @@ Error ProjectExport::export_project(const String& p_preset) { memdelete(da); memdelete(d); - ERR_EXPLAIN("Cannot change to dir: "+cwd+"/"+p); + ERR_EXPLAIN(TTR("Cannot change to dir: ")+cwd+"/"+p); ERR_FAIL_V(ERR_CANT_CREATE); } @@ -1721,7 +1721,7 @@ Error ProjectExport::export_project(const String& p_preset) { String source_file; - print_line("Exporting: "+source_file); + print_line(TTR("Exporting: ")+source_file); bool delete_source=false; if (preset=="") { //just copy! @@ -1735,7 +1735,7 @@ Error ProjectExport::export_project(const String& p_preset) { if (!Globals::get_singleton()->has("optimizer_presets/"+preset)) { memdelete(d); - ERR_EXPLAIN("Unknown optimizer preset: "+preset); + ERR_EXPLAIN(TTR("Unknown optimizer preset: ")+preset); ERR_FAIL_V(ERR_INVALID_DATA); } @@ -1756,7 +1756,7 @@ Error ProjectExport::export_project(const String& p_preset) { if (saver.is_null()) { memdelete(d); - ERR_EXPLAIN("Preset '"+preset+"' references nonexistent saver: "+type); + ERR_EXPLAIN(TTR("Preset '")+preset+"' references nonexistent saver: "+type); ERR_FAIL_COND_V(saver.is_null(),ERR_INVALID_DATA); } @@ -1800,7 +1800,7 @@ Error ProjectExport::export_project(const String& p_preset) { if (res.is_null()) { memdelete(d); - ERR_EXPLAIN("Errr loading resource to optimize: "+path); + ERR_EXPLAIN(TTR("Errr loading resource to optimize: ")+path); ERR_FAIL_V(ERR_INVALID_DATA); } @@ -1819,11 +1819,11 @@ Error ProjectExport::export_project(const String& p_preset) { String write_file = path+".opt.res"; - print_line("DST RES FILE: "+write_file); + print_line(TTR("DST RES FILE: ")+write_file); Error err = ResourceSaver::save(write_file,res,flags,saver); if (err) { memdelete(d); - ERR_EXPLAIN("Errr saving optimized resource: "+write_file); + ERR_EXPLAIN(TTR("Errr saving optimized resource: ")+write_file); ERR_FAIL_COND_V(err,ERR_CANT_OPEN); } source_file=write_file; @@ -1846,7 +1846,7 @@ Error ProjectExport::export_project(const String& p_preset) { if (err) { - ERR_EXPLAIN("Error copying from: "+source_file+" to "+dst_file+"."); + ERR_EXPLAIN(TTR("Error copying from: ")+source_file+" to "+dst_file+"."); ERR_FAIL_COND_V(err,err); } @@ -1898,13 +1898,13 @@ ProjectExport::ProjectExport(EditorData* p_data) { VBoxContainer *vbc = memnew( VBoxContainer ); add_child(vbc); set_child_rect(vbc); - set_title("Project Export"); + set_title(TTR("Project Export")); label = memnew( Label ); - label->set_text("Export Preset:"); + label->set_text(TTR("Export Preset:")); vbc->add_child(label); export_preset = memnew (OptionButton); vbc->add_child(export_preset); - get_ok()->set_text("Export"); + get_ok()->set_text(TTR("Export")); set_hide_on_ok(false); error = memnew( AcceptDialog ); add_child(error); diff --git a/tools/editor/project_manager.cpp b/tools/editor/project_manager.cpp index 4386717c4c..368f952dc9 100644 --- a/tools/editor/project_manager.cpp +++ b/tools/editor/project_manager.cpp @@ -66,7 +66,7 @@ class NewProjectDialog : public ConfirmationDialog { get_ok()->set_disabled(true); DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); if (project_path->get_text() != "" && d->change_dir(project_path->get_text())!=OK) { - error->set_text("Invalid Path for Project, Path Must Exist!"); + error->set_text(TTR("Invalid Path for Project, Path Must Exist!")); memdelete(d); return false; } @@ -75,7 +75,7 @@ class NewProjectDialog : public ConfirmationDialog { if (d->file_exists("engine.cfg")) { - error->set_text("Invalid Project Path (engine.cfg must not exist)."); + error->set_text(TTR("Invalid Project Path (engine.cfg must not exist).")); memdelete(d); return false; } @@ -84,7 +84,7 @@ class NewProjectDialog : public ConfirmationDialog { if (project_path->get_text() != "" && !d->file_exists("engine.cfg")) { - error->set_text("Invalid Project Path (engine.cfg must exist)."); + error->set_text(TTR("Invalid Project Path (engine.cfg must exist).")); memdelete(d); return false; } @@ -109,7 +109,7 @@ class NewProjectDialog : public ConfirmationDialog { sp=sp.substr(lidx+1,sp.length()); } if (sp=="" && import_mode ) - sp="Imported Project"; + sp=TTR("Imported Project"); project_name->set_text(sp); } @@ -170,7 +170,7 @@ class NewProjectDialog : public ConfirmationDialog { DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); if (d->change_dir(project_path->get_text())!=OK) { - error->set_text("Invalid Path for Project (changed anything?)"); + error->set_text(TTR("Invalid Path for Project (changed anything?)")); memdelete(d); return; } @@ -180,7 +180,7 @@ class NewProjectDialog : public ConfirmationDialog { FileAccess *f = FileAccess::open(dir.plus_file("/engine.cfg"),FileAccess::WRITE); if (!f) { - error->set_text("Couldn't create engine.cfg in project path"); + error->set_text(TTR("Couldn't create engine.cfg in project path")); } else { f->store_line("; Engine configuration file."); @@ -245,20 +245,20 @@ public: project_name->clear(); if (import_mode) { - set_title("Import Existing Project"); - get_ok()->set_text("Import"); - pp->set_text("Project Path: (Must exist)"); - pn->set_text("Project Name:"); + set_title(TTR("Import Existing Project")); + get_ok()->set_text(TTR("Import")); + pp->set_text(TTR("Project Path: (Must exist)")); + pn->set_text(TTR("Project Name:")); pn->hide(); project_name->hide(); popup_centered(Size2(500,125)); } else { - set_title("Create New Project"); - get_ok()->set_text("Create"); - pp->set_text("Project Path:"); - pn->set_text("Project Name:"); + set_title(TTR("Create New Project")); + get_ok()->set_text(TTR("Create")); + pp->set_text(TTR("Project Path:")); + pn->set_text(TTR("Project Name:")); pn->show(); project_name->show(); @@ -278,7 +278,7 @@ public: set_child_rect(vb); Label* l = memnew(Label); - l->set_text("Project Path:"); + l->set_text(TTR("Project Path:")); vb->add_child(l); pp=l; @@ -292,11 +292,11 @@ public: Button* browse = memnew( Button ); pphb->add_child(browse); - browse->set_text("Browse"); + browse->set_text(TTR("Browse")); browse->connect("pressed", this,"_browse_path"); l = memnew(Label); - l->set_text("Project Name:"); + l->set_text(TTR("Project Name:")); l->set_pos(Point2(5,50)); vb->add_child(l); pn=l; @@ -305,11 +305,11 @@ public: mc = memnew( MarginContainer ); vb->add_child(mc); mc->add_child(project_name); - project_name->set_text("New Game Project"); + project_name->set_text(TTR("New Game Project")); l = memnew(Label); - l->set_text("That's a BINGO!"); + l->set_text(TTR("That's a BINGO!")); vb->add_child(l); error=l; l->add_color_override("font_color",Color(1,0.4,0.3,0.8)); @@ -536,7 +536,7 @@ void ProjectManager::_load_recent_projects() { ERR_CONTINUE(err!=OK); - String project_name="Unnamed Project"; + String project_name=TTR("Unnamed Project"); if (cf->has_section_key("application","name")) { project_name = static_cast<String>(cf->get_value("application","name")).xml_unescape(); @@ -622,7 +622,7 @@ void ProjectManager::_open_project_confirm() { for (Map<String,String>::Element *E=selected_list.front(); E; E=E->next()) { const String &selected = E->key(); String path = EditorSettings::get_singleton()->get("projects/"+selected); - print_line("OPENING: "+path+" ("+selected+")"); + print_line(TTR("OPENING: ")+path+" ("+selected+")"); List<String> args; @@ -648,7 +648,7 @@ void ProjectManager::_open_project() { } if (selected_list.size()>1) { - multi_open_ask->set_text("Are you sure to open more than one projects?"); + multi_open_ask->set_text(TTR("Are you sure to open more than one projects?")); multi_open_ask->popup_centered_minsize(); } else { _open_project_confirm(); @@ -664,7 +664,7 @@ void ProjectManager::_run_project_confirm() { const String &selected = E->key(); String path = EditorSettings::get_singleton()->get("projects/"+selected); - print_line("OPENING: "+path+" ("+selected+")"); + print_line(TTR("OPENING: ")+path+" ("+selected+")"); List<String> args; @@ -688,7 +688,7 @@ void ProjectManager::_run_project() { } if (selected_list.size()>1) { - multi_run_ask->set_text("Are you sure to run more than one projects?"); + multi_run_ask->set_text(TTR("Are you sure to run more than one projects?")); multi_run_ask->popup_centered_minsize(); } else { _run_project_confirm(); @@ -727,7 +727,7 @@ void ProjectManager::_scan_dir(DirAccess *da,float pos, float total,List<String> void ProjectManager::_scan_begin(const String& p_base) { - print_line("SCAN PROJECTS AT: "+p_base); + print_line(TTR("SCAN PROJECTS AT: ")+p_base); List<String> projects; DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); da->change_dir(p_base); @@ -788,7 +788,7 @@ void ProjectManager::_erase_project() { return; - erase_ask->set_text("Remove project from list?? (Folder contents will not be modified)"); + erase_ask->set_text(TTR("Remove project from list?? (Folder contents will not be modified)")); erase_ask->popup_centered_minsize(); } @@ -822,8 +822,8 @@ void ProjectManager::_bind_methods() { ProjectManager::ProjectManager() { - int margin = get_constant("margin","Dialogs"); - int button_margin = get_constant("button_margin","Dialogs"); + int margin = get_constant("margin",TTR("Dialogs")); + int button_margin = get_constant("button_margin",TTR("Dialogs")); // load settings if (!EditorSettings::get_singleton()) @@ -870,7 +870,7 @@ ProjectManager::ProjectManager() { HBoxContainer *tree_hb = memnew( HBoxContainer); - vb->add_margin_child("Recent Projects:",tree_hb,true); + vb->add_margin_child(TTR("Recent Projects:"),tree_hb,true); VBoxContainer *search_tree_vb = memnew(VBoxContainer); search_tree_vb->set_h_size_flags(SIZE_EXPAND_FILL); @@ -903,13 +903,13 @@ ProjectManager::ProjectManager() { //vb->add_child(hb); Button *open = memnew( Button ); - open->set_text("Edit"); + open->set_text(TTR("Edit")); tree_vb->add_child(open); open->connect("pressed", this,"_open_project"); open_btn=open; Button *run = memnew( Button ); - run->set_text("Run"); + run->set_text(TTR("Run")); tree_vb->add_child(run); run->connect("pressed", this,"_run_project"); run_btn=run; @@ -917,7 +917,7 @@ ProjectManager::ProjectManager() { tree_vb->add_child(memnew( HSeparator )); Button *scan = memnew( Button ); - scan->set_text("Scan"); + scan->set_text(TTR("Scan")); tree_vb->add_child(scan); scan->connect("pressed", this,"_scan_projects"); @@ -932,18 +932,18 @@ ProjectManager::ProjectManager() { Button* create = memnew( Button ); - create->set_text("New Project"); + create->set_text(TTR("New Project")); tree_vb->add_child(create); create->connect("pressed", this,"_new_project"); Button* import = memnew( Button ); - import->set_text("Import"); + import->set_text(TTR("Import")); tree_vb->add_child(import); import->connect("pressed", this,"_import_project"); Button* erase = memnew( Button ); - erase->set_text("Remove"); + erase->set_text(TTR("Remove")); tree_vb->add_child(erase); erase->connect("pressed", this,"_erase_project"); erase_btn=erase; @@ -952,7 +952,7 @@ ProjectManager::ProjectManager() { tree_vb->add_spacer(); Button * cancel = memnew( Button ); - cancel->set_text("Exit"); + cancel->set_text(TTR("Exit")); tree_vb->add_child(cancel); cancel->connect("pressed", this,"_exit_dialog"); @@ -970,19 +970,19 @@ ProjectManager::ProjectManager() { erase_ask = memnew( ConfirmationDialog ); - erase_ask->get_ok()->set_text("Remove"); + erase_ask->get_ok()->set_text(TTR("Remove")); erase_ask->get_ok()->connect("pressed", this,"_erase_project_confirm"); add_child(erase_ask); multi_open_ask = memnew( ConfirmationDialog ); - multi_open_ask->get_ok()->set_text("Edit"); + multi_open_ask->get_ok()->set_text(TTR("Edit")); multi_open_ask->get_ok()->connect("pressed", this, "_open_project_confirm"); add_child(multi_open_ask); multi_run_ask = memnew( ConfirmationDialog ); - multi_run_ask->get_ok()->set_text("Run"); + multi_run_ask->get_ok()->set_text(TTR("Run")); multi_run_ask->get_ok()->connect("pressed", this, "_run_project_confirm"); add_child(multi_run_ask); @@ -999,8 +999,8 @@ ProjectManager::ProjectManager() { _scan_begin( EditorSettings::get_singleton()->get("global/autoscan_project_path") ); } - //get_ok()->set_text("Open"); - //get_ok()->set_text("Exit"); + //get_ok()->set_text(TTR("Open")); + //get_ok()->set_text(TTR("Exit")); last_clicked = ""; } @@ -1015,7 +1015,7 @@ ProjectManager::~ProjectManager() { void ProjectListFilter::_setup_filters() { filter_option->clear(); - filter_option->add_item("Name"); + filter_option->add_item(TTR("Name")); filter_option->add_item("Path"); } diff --git a/tools/editor/project_settings.cpp b/tools/editor/project_settings.cpp index 179af051a9..d69d565795 100644 --- a/tools/editor/project_settings.cpp +++ b/tools/editor/project_settings.cpp @@ -139,7 +139,7 @@ void ProjectSettings::_action_edited() { ti->set_text(0,old_name); add_at="input/"+old_name; - message->set_text("Invalid Action (Anything goes but / or :)."); + message->set_text(TTR("Invalid Action (Anything goes but / or :).")); message->popup_centered(Size2(300,100)); return; } @@ -151,7 +151,7 @@ void ProjectSettings::_action_edited() { ti->set_text(0,old_name); add_at="input/"+old_name; - message->set_text("Action '"+new_name+"' already exists!."); + message->set_text(TTR("Action '")+new_name+"' already exists!."); message->popup_centered(Size2(300,100)); return; } @@ -161,7 +161,7 @@ void ProjectSettings::_action_edited() { bool persisting = Globals::get_singleton()->is_persisting(add_at); setting=true; - undo_redo->create_action("Rename Input Action Event"); + undo_redo->create_action(TTR("Rename Input Action Event")); undo_redo->add_do_method(Globals::get_singleton(),"clear",add_at); undo_redo->add_do_method(Globals::get_singleton(),"set",action_prop,va); undo_redo->add_do_method(Globals::get_singleton(),"set_persisting",action_prop,persisting); @@ -245,7 +245,7 @@ void ProjectSettings::_device_input_add() { arr.push_back(ie); - undo_redo->create_action("Add Input Action Event"); + undo_redo->create_action(TTR("Add Input Action Event")); undo_redo->add_do_method(Globals::get_singleton(),"set",name,arr); undo_redo->add_do_method(Globals::get_singleton(),"set_persisting",name,true); undo_redo->add_undo_method(Globals::get_singleton(),"set",name,old_val); @@ -283,7 +283,7 @@ void ProjectSettings::_press_a_key_confirm() { arr.push_back(ie); - undo_redo->create_action("Add Input Action Event"); + undo_redo->create_action(TTR("Add Input Action Event")); undo_redo->add_do_method(Globals::get_singleton(),"set",name,arr); undo_redo->add_do_method(Globals::get_singleton(),"set_persisting",name,true); undo_redo->add_undo_method(Globals::get_singleton(),"set",name,old_val); @@ -304,13 +304,13 @@ void ProjectSettings::_wait_for_key(const InputEvent& p_event) { last_wait_for_key=p_event; String str=keycode_get_string(p_event.key.scancode).capitalize(); if (p_event.key.mod.meta) - str="Meta+"+str; + str=TTR("Meta+")+str; if (p_event.key.mod.shift) - str="Shift+"+str; + str=TTR("Shift+")+str; if (p_event.key.mod.alt) - str="Alt+"+str; + str=TTR("Alt+")+str; if (p_event.key.mod.control) - str="Control+"+str; + str=TTR("Control+")+str; press_a_key_label->set_text(str); @@ -328,7 +328,7 @@ void ProjectSettings::_add_item(int p_item){ case InputEvent::KEY: { - press_a_key_label->set_text("Press a Key.."); + press_a_key_label->set_text(TTR("Press a Key..")); last_wait_for_key=InputEvent(); press_a_key->popup_centered(Size2(250,80)); press_a_key->grab_focus(); @@ -336,28 +336,28 @@ void ProjectSettings::_add_item(int p_item){ case InputEvent::MOUSE_BUTTON: { device_id->set_val(0); - device_index_label->set_text("Mouse Button Index:"); + device_index_label->set_text(TTR("Mouse Button Index:")); device_index->clear(); - device_index->add_item("Left Button"); - device_index->add_item("Right Button"); - device_index->add_item("Middle Button"); - device_index->add_item("Wheel Up Button"); - device_index->add_item("Wheel Down Button"); - device_index->add_item("Button 6"); - device_index->add_item("Button 7"); - device_index->add_item("Button 8"); - device_index->add_item("Button 9"); + device_index->add_item(TTR("Left Button")); + device_index->add_item(TTR("Right Button")); + device_index->add_item(TTR("Middle Button")); + device_index->add_item(TTR("Wheel Up Button")); + device_index->add_item(TTR("Wheel Down Button")); + device_index->add_item(TTR("Button 6")); + device_index->add_item(TTR("Button 7")); + device_index->add_item(TTR("Button 8")); + device_index->add_item(TTR("Button 9")); device_input->popup_centered(Size2(350,95)); } break; case InputEvent::JOYSTICK_MOTION: { device_id->set_val(0); - device_index_label->set_text("Joystick Axis Index:"); + device_index_label->set_text(TTR("Joystick Axis Index:")); device_index->clear(); for(int i=0;i<JOY_AXIS_MAX*2;i++) { String desc = _axis_names[i]; - device_index->add_item("Axis "+itos(i/2)+" "+(i&1?"+":"-")+desc); + device_index->add_item(TTR("Axis ")+itos(i/2)+" "+(i&1?"+":"-")+desc); } device_input->popup_centered(Size2(350,95)); @@ -365,7 +365,7 @@ void ProjectSettings::_add_item(int p_item){ case InputEvent::JOYSTICK_BUTTON: { device_id->set_val(0); - device_index_label->set_text("Joystick Button Index:"); + device_index_label->set_text(TTR("Joystick Button Index:")); device_index->clear(); for(int i=0;i<JOY_BUTTON_MAX;i++) { @@ -409,7 +409,7 @@ void ProjectSettings::_action_button_pressed(Object* p_obj, int p_column,int p_i Variant old_val = Globals::get_singleton()->get(name); int order=Globals::get_singleton()->get_order(name); - undo_redo->create_action("Add Input Action"); + undo_redo->create_action(TTR("Add Input Action")); undo_redo->add_do_method(Globals::get_singleton(),"clear",name); undo_redo->add_undo_method(Globals::get_singleton(),"set",name,old_val); undo_redo->add_undo_method(Globals::get_singleton(),"set_order",name,order); @@ -438,7 +438,7 @@ void ProjectSettings::_action_button_pressed(Object* p_obj, int p_column,int p_i va.resize(va.size()-1); - undo_redo->create_action("Erase Input Action Event"); + undo_redo->create_action(TTR("Erase Input Action Event")); undo_redo->add_do_method(Globals::get_singleton(),"set",name,va); undo_redo->add_undo_method(Globals::get_singleton(),"set",name,old_val); undo_redo->add_do_method(this,"_update_actions"); @@ -503,13 +503,13 @@ void ProjectSettings::_update_actions() { String str=keycode_get_string(ie.key.scancode).capitalize(); if (ie.key.mod.meta) - str="Meta+"+str; + str=TTR("Meta+")+str; if (ie.key.mod.shift) - str="Shift+"+str; + str=TTR("Shift+")+str; if (ie.key.mod.alt) - str="Alt+"+str; + str=TTR("Alt+")+str; if (ie.key.mod.control) - str="Control+"+str; + str=TTR("Control+")+str; action->set_text(0,str); action->set_icon(0,get_icon("Keyboard","EditorIcons")); @@ -517,7 +517,7 @@ void ProjectSettings::_update_actions() { } break; case InputEvent::JOYSTICK_BUTTON: { - String str = "Device "+itos(ie.device)+", Button "+itos(ie.joy_button.button_index); + String str = TTR("Device ")+itos(ie.device)+", Button "+itos(ie.joy_button.button_index); if (ie.joy_button.button_index>=0 && ie.joy_button.button_index<JOY_BUTTON_MAX) str+=String()+" ("+_button_names[ie.joy_button.button_index]+")."; else @@ -528,14 +528,14 @@ void ProjectSettings::_update_actions() { } break; case InputEvent::MOUSE_BUTTON: { - String str = "Device "+itos(ie.device)+", "; + String str = TTR("Device ")+itos(ie.device)+", "; switch (ie.mouse_button.button_index) { - case BUTTON_LEFT: str+="Left Button."; break; - case BUTTON_RIGHT: str+="Right Button."; break; - case BUTTON_MIDDLE: str+="Middle Button."; break; - case BUTTON_WHEEL_UP: str+="Wheel Up."; break; - case BUTTON_WHEEL_DOWN: str+="Wheel Down."; break; - default: str+="Button "+itos(ie.mouse_button.button_index)+"."; + case BUTTON_LEFT: str+=TTR("Left Button."); break; + case BUTTON_RIGHT: str+=TTR("Right Button."); break; + case BUTTON_MIDDLE: str+=TTR("Middle Button."); break; + case BUTTON_WHEEL_UP: str+=TTR("Wheel Up."); break; + case BUTTON_WHEEL_DOWN: str+=TTR("Wheel Down."); break; + default: str+=TTR("Button ")+itos(ie.mouse_button.button_index)+"."; } action->set_text(0,str); @@ -546,7 +546,7 @@ void ProjectSettings::_update_actions() { int ax = ie.joy_motion.axis; int n = 2*ax + (ie.joy_motion.axis_value<0 ? 0:1); String desc = _axis_names[n]; - String str = "Device "+itos(ie.device)+", Axis "+itos(ax)+" "+(ie.joy_motion.axis_value<0?"-":"+")+desc +"."; + String str = TTR("Device ")+itos(ie.device)+", Axis "+itos(ax)+" "+(ie.joy_motion.axis_value<0?"-":"+")+desc +"."; action->set_text(0,str); action->set_icon(0,get_icon("JoyAxis","EditorIcons")); } break; @@ -650,20 +650,20 @@ void ProjectSettings::_action_add() { String action = action_name->get_text(); if (action.find("/")!=-1 || action.find(":")!=-1 || action=="") { - message->set_text("Invalid Action (Anything goes but / or :)."); + message->set_text(TTR("Invalid Action (Anything goes but / or :).")); message->popup_centered(Size2(300,100)); return; } if (Globals::get_singleton()->has("input/"+action)) { - message->set_text("Action '"+action+"' already exists!."); + message->set_text(TTR("Action '")+action+"' already exists!."); message->popup_centered(Size2(300,100)); return; } Array va; String name = "input/"+action; - undo_redo->create_action("Add Input Action Event"); + undo_redo->create_action(TTR("Add Input Action Event")); undo_redo->add_do_method(Globals::get_singleton(),"set",name,va); undo_redo->add_do_method(Globals::get_singleton(),"set_persisting",name,true); undo_redo->add_undo_method(Globals::get_singleton(),"clear",name); @@ -693,7 +693,7 @@ void ProjectSettings::_action_add() { void ProjectSettings::_item_checked(const String& p_item, bool p_check) { - undo_redo->create_action("Toggle Persisting"); + undo_redo->create_action(TTR("Toggle Persisting")); String full_item = globals_editor->get_full_item_path(p_item); undo_redo->add_do_method(Globals::get_singleton(),"set_persisting",full_item,p_check); @@ -710,7 +710,7 @@ void ProjectSettings::_item_checked(const String& p_item, bool p_check) { void ProjectSettings::_save() { Error err = Globals::get_singleton()->save(); - message->set_text(err!=OK?"Error saving settings.":"Settings Saved OK."); + message->set_text(err!=OK?TTR("Error saving settings."):"Settings Saved OK."); message->popup_centered(Size2(300,100)); } @@ -794,7 +794,7 @@ void ProjectSettings::_translation_add(const String& p_path) { } translations.push_back(p_path); - undo_redo->create_action("Add Translation"); + undo_redo->create_action(TTR("Add Translation")); undo_redo->add_do_property(Globals::get_singleton(),"locale/translations",translations); undo_redo->add_undo_property(Globals::get_singleton(),"locale/translations",Globals::get_singleton()->get("locale/translations")); undo_redo->add_do_method(Globals::get_singleton(),"set_persisting","locale/translations",true); @@ -851,7 +851,7 @@ void ProjectSettings::_autoload_edited() { if (checked) path="*"+path; - undo_redo->create_action("Toggle Autoload GlobalVar"); + undo_redo->create_action(TTR("Toggle Autoload GlobalVar")); undo_redo->add_do_property(Globals::get_singleton(),base,path); undo_redo->add_undo_property(Globals::get_singleton(),base,Globals::get_singleton()->get(base)); undo_redo->add_do_method(Globals::get_singleton(),"set_order",base,order); // keep order, as config order matters for these @@ -877,7 +877,7 @@ void ProjectSettings::_autoload_add() { if (ObjectTypeDB::type_exists(name)) { - message->set_text("Invalid Name.Must not collide with an existing engine class name."); + message->set_text(TTR("Invalid Name.Must not collide with an existing engine class name.")); message->popup_centered(Size2(300,100)); return; @@ -886,7 +886,7 @@ void ProjectSettings::_autoload_add() { for(int i=0;i<Variant::VARIANT_MAX;i++) { if (Variant::get_type_name(Variant::Type(i))==name) { - message->set_text("Invalid Name.Must not collide with an existing buit-in type name."); + message->set_text(TTR("Invalid Name.Must not collide with an existing buit-in type name.")); message->popup_centered(Size2(300,100)); return; @@ -897,7 +897,7 @@ void ProjectSettings::_autoload_add() { if (GlobalConstants::get_global_constant_name(i)==name) { - message->set_text("Invalid Name.Must not collide with an existing global constant name."); + message->set_text(TTR("Invalid Name.Must not collide with an existing global constant name.")); message->popup_centered(Size2(300,100)); return; } @@ -918,7 +918,7 @@ void ProjectSettings::_autoload_add() { } - undo_redo->create_action("Add Autoload"); + undo_redo->create_action(TTR("Add Autoload")); name = "autoload/"+name; undo_redo->add_do_property(Globals::get_singleton(),name,"*"+path); if (Globals::get_singleton()->has(name)) @@ -948,7 +948,7 @@ void ProjectSettings::_autoload_delete(Object *p_item,int p_column, int p_button if (p_button==0) { //delete int order = Globals::get_singleton()->get_order(name); - undo_redo->create_action("Remove Autoload"); + undo_redo->create_action(TTR("Remove Autoload")); undo_redo->add_do_property(Globals::get_singleton(),name,Variant()); undo_redo->add_undo_property(Globals::get_singleton(),name,Globals::get_singleton()->get(name)); undo_redo->add_undo_method(Globals::get_singleton(),"set_persisting",name,true); @@ -975,7 +975,7 @@ void ProjectSettings::_autoload_delete(Object *p_item,int p_column, int p_button int order = Globals::get_singleton()->get_order(name); int swap_order = Globals::get_singleton()->get_order(swap_name); - undo_redo->create_action("Move Autoload"); + undo_redo->create_action(TTR("Move Autoload")); undo_redo->add_do_method(Globals::get_singleton(),"set_order",swap_name,order); undo_redo->add_do_method(Globals::get_singleton(),"set_order",name,swap_order); undo_redo->add_undo_method(Globals::get_singleton(),"set_order",swap_name,swap_order); @@ -1004,7 +1004,7 @@ void ProjectSettings::_translation_delete(Object *p_item,int p_column, int p_but translations.remove(idx); - undo_redo->create_action("Remove Translation"); + undo_redo->create_action(TTR("Remove Translation")); undo_redo->add_do_property(Globals::get_singleton(),"locale/translations",translations); undo_redo->add_undo_property(Globals::get_singleton(),"locale/translations",Globals::get_singleton()->get("locale/translations")); undo_redo->add_do_method(this,"_update_translations"); @@ -1037,7 +1037,7 @@ void ProjectSettings::_translation_res_add(const String& p_path){ remaps[p_path]=StringArray(); - undo_redo->create_action("Add Remapped Path"); + undo_redo->create_action(TTR("Add Remapped Path")); undo_redo->add_do_property(Globals::get_singleton(),"locale/translation_remaps",remaps); undo_redo->add_do_method(Globals::get_singleton(),"set_persisting","locale/translation_remaps",true); undo_redo->add_undo_property(Globals::get_singleton(),"locale/translation_remaps",prev); @@ -1071,7 +1071,7 @@ void ProjectSettings::_translation_res_option_add(const String& p_path) { remaps[key]=r; - undo_redo->create_action("Resource Remap Add Remap"); + undo_redo->create_action(TTR("Resource Remap Add Remap")); undo_redo->add_do_property(Globals::get_singleton(),"locale/translation_remaps",remaps); undo_redo->add_do_method(Globals::get_singleton(),"set_persisting","locale/translation_remaps",true); undo_redo->add_undo_property(Globals::get_singleton(),"locale/translation_remaps",Globals::get_singleton()->get("locale/translation_remaps")); @@ -1126,7 +1126,7 @@ void ProjectSettings::_translation_res_option_changed() { remaps[key]=r; updating_translations=true; - undo_redo->create_action("Change Resource Remap Language"); + undo_redo->create_action(TTR("Change Resource Remap Language")); undo_redo->add_do_property(Globals::get_singleton(),"locale/translation_remaps",remaps); undo_redo->add_do_method(Globals::get_singleton(),"set_persisting","locale/translation_remaps",true); undo_redo->add_undo_property(Globals::get_singleton(),"locale/translation_remaps",Globals::get_singleton()->get("locale/translation_remaps")); @@ -1158,7 +1158,7 @@ void ProjectSettings::_translation_res_delete(Object *p_item,int p_column, int p remaps.erase(key); - undo_redo->create_action("Remove Resource Remap"); + undo_redo->create_action(TTR("Remove Resource Remap")); undo_redo->add_do_property(Globals::get_singleton(),"locale/translation_remaps",remaps); undo_redo->add_do_method(Globals::get_singleton(),"set_persisting","locale/translation_remaps",true); undo_redo->add_undo_property(Globals::get_singleton(),"locale/translation_remaps",Globals::get_singleton()->get("locale/translation_remaps")); @@ -1194,7 +1194,7 @@ void ProjectSettings::_translation_res_option_delete(Object *p_item,int p_column remaps[key]=r; - undo_redo->create_action("Remove Resource Remap Option"); + undo_redo->create_action(TTR("Remove Resource Remap Option")); undo_redo->add_do_property(Globals::get_singleton(),"locale/translation_remaps",remaps); undo_redo->add_do_method(Globals::get_singleton(),"set_persisting","locale/translation_remaps",true); undo_redo->add_undo_property(Globals::get_singleton(),"locale/translation_remaps",Globals::get_singleton()->get("locale/translation_remaps")); @@ -1351,7 +1351,7 @@ void ProjectSettings::_update_autoload() { t->set_text(1,path); t->set_cell_mode(2,TreeItem::CELL_MODE_CHECK); t->set_editable(2,true); - t->set_text(2,"Enable"); + t->set_text(2,TTR("Enable")); t->set_checked(2,global); t->add_button(3,get_icon("MoveUp","EditorIcons"),1); t->add_button(3,get_icon("MoveDown","EditorIcons"),2); @@ -1446,7 +1446,7 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { singleton=this; - set_title("Project Settings (engine.cfg)"); + set_title(TTR("Project Settings (engine.cfg)")); undo_redo=&p_data->get_undo_redo(); data=p_data; @@ -1464,7 +1464,7 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { props_base->set_alignment(BoxContainer::ALIGN_BEGIN); props_base->set_v_size_flags(Control::SIZE_EXPAND_FILL); tab_container->add_child(props_base); - props_base->set_name("General"); + props_base->set_name(TTR("General")); HBoxContainer *hbc = memnew( HBoxContainer ); hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL); @@ -1473,7 +1473,7 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { search_button = memnew( ToolButton ); search_button->set_toggle_mode(true); search_button->set_pressed(false); - search_button->set_text("Search"); + search_button->set_text(TTR("Search")); hbc->add_child(search_button); search_button->connect("toggled",this,"_toggle_search_bar"); @@ -1485,7 +1485,7 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { Label *l = memnew( Label ); add_prop_bar->add_child(l); - l->set_text("Category:"); + l->set_text(TTR("Category:")); category = memnew( LineEdit ); category->set_h_size_flags(Control::SIZE_EXPAND_FILL); @@ -1494,7 +1494,7 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { l = memnew( Label ); add_prop_bar->add_child(l); - l->set_text("Property:"); + l->set_text(TTR("Property:")); property = memnew( LineEdit ); property->set_h_size_flags(Control::SIZE_EXPAND_FILL); @@ -1503,7 +1503,7 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { l = memnew( Label ); add_prop_bar->add_child(l); - l->set_text("Type:"); + l->set_text(TTR("Type:")); type = memnew( OptionButton ); type->set_h_size_flags(Control::SIZE_EXPAND_FILL); @@ -1515,12 +1515,12 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { Button *add = memnew( Button ); add_prop_bar->add_child(add); - add->set_text("Add"); + add->set_text(TTR("Add")); add->connect("pressed",this,"_item_add"); Button *del = memnew( Button ); add_prop_bar->add_child(del); - del->set_text("Del"); + del->set_text(TTR("Del")); del->connect("pressed",this,"_item_del"); search_bar = memnew( HBoxContainer ); @@ -1556,7 +1556,7 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { save->set_anchor(MARGIN_BOTTOM,ANCHOR_END); save->set_begin( Point2(80,28) ); save->set_end( Point2(10,20) ); - save->set_text("Save"); + save->set_text(TTR("Save")); save->connect("pressed",this,"_save"); */ @@ -1564,7 +1564,7 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { props_base->add_child(hbc); popup_platform = memnew( MenuButton ); - popup_platform->set_text("Copy To Platform.."); + popup_platform->set_text(TTR("Copy To Platform..")); popup_platform->set_disabled(true); hbc->add_child(popup_platform); @@ -1581,7 +1581,7 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { } popup_platform->get_popup()->connect("item_pressed",this,"_copy_to_platform"); - get_ok()->set_text("Close"); + get_ok()->set_text(TTR("Close")); set_hide_on_ok(true); message = memnew( ConfirmationDialog ); @@ -1590,14 +1590,14 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { message->set_hide_on_ok(true); Control *input_base = memnew( Control ); - input_base->set_name("Input Map"); + input_base->set_name(TTR("Input Map")); input_base->set_area_as_parent_rect();; tab_container->add_child(input_base); l = memnew( Label ); input_base->add_child(l); l->set_pos(Point2(6,5)); - l->set_text("Action:"); + l->set_text(TTR("Action:")); action_name = memnew( LineEdit ); action_name->set_anchor(MARGIN_RIGHT,ANCHOR_RATIO); @@ -1612,7 +1612,7 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { add->set_begin( Point2(0.86,25) ); add->set_anchor(MARGIN_RIGHT,ANCHOR_END); add->set_end( Point2(5,26) ); - add->set_text("Add"); + add->set_text(TTR("Add")); add->connect("pressed",this,"_action_add"); input_editor = memnew( Tree ); @@ -1634,7 +1634,7 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { add_child(press_a_key); l = memnew( Label ); - l->set_text("Press a Key.."); + l->set_text(TTR("Press a Key..")); l->set_area_as_parent_rect(); l->set_align(Label::ALIGN_CENTER); l->set_margin(MARGIN_TOP,20); @@ -1647,16 +1647,16 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { device_input=memnew( ConfirmationDialog ); add_child(device_input); - device_input->get_ok()->set_text("Add"); + device_input->get_ok()->set_text(TTR("Add")); device_input->connect("confirmed",this,"_device_input_add"); l = memnew( Label ); - l->set_text("Device:"); + l->set_text(TTR("Device:")); l->set_pos(Point2(15,10)); device_input->add_child(l); l = memnew( Label ); - l->set_text("Index:"); + l->set_text(TTR("Index:")); l->set_pos(Point2(90,10)); device_input->add_child(l); device_index_label=l; @@ -1684,26 +1684,26 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { save->set_anchor(MARGIN_BOTTOM,ANCHOR_END); save->set_begin( Point2(80,28) ); save->set_end( Point2(10,20) ); - save->set_text("Save"); + save->set_text(TTR("Save")); save->connect("pressed",this,"_save"); */ setting=false; //translations TabContainer *translations = memnew( TabContainer ); - translations->set_name("Localization"); + translations->set_name(TTR("Localization")); tab_container->add_child(translations); { VBoxContainer *tvb = memnew( VBoxContainer ); translations->add_child(tvb); - tvb->set_name("Translations"); + tvb->set_name(TTR("Translations")); HBoxContainer *thb = memnew( HBoxContainer); tvb->add_child(thb); - thb->add_child( memnew( Label("Translations:"))); + thb->add_child( memnew( Label(TTR("Translations:")))); thb->add_spacer(); - Button *addtr = memnew( Button("Add..") ); + Button *addtr = memnew( Button(TTR("Add..")) ); addtr->connect("pressed",this,"_translation_file_open"); thb->add_child(addtr); MarginContainer *tmc = memnew( MarginContainer ); @@ -1723,12 +1723,12 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { { VBoxContainer *tvb = memnew( VBoxContainer ); translations->add_child(tvb); - tvb->set_name("Remaps"); + tvb->set_name(TTR("Remaps")); HBoxContainer *thb = memnew( HBoxContainer); tvb->add_child(thb); - thb->add_child( memnew( Label("Resources:"))); + thb->add_child( memnew( Label(TTR("Resources:")))); thb->add_spacer(); - Button *addtr = memnew( Button("Add..") ); + Button *addtr = memnew( Button(TTR("Add..")) ); addtr->connect("pressed",this,"_translation_res_file_open"); thb->add_child(addtr); MarginContainer *tmc = memnew( MarginContainer ); @@ -1747,9 +1747,9 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { thb = memnew( HBoxContainer); tvb->add_child(thb); - thb->add_child( memnew( Label("Remaps by Locale:"))); + thb->add_child( memnew( Label(TTR("Remaps by Locale:")))); thb->add_spacer(); - addtr = memnew( Button("Add..") ); + addtr = memnew( Button(TTR("Add..")) ); addtr->connect("pressed",this,"_translation_res_option_file_open"); translation_res_option_add_button=addtr; thb->add_child(addtr); @@ -1762,7 +1762,7 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { translation_remap_options->set_columns(2); translation_remap_options->set_column_title(0,"Path"); - translation_remap_options->set_column_title(1,"Locale"); + translation_remap_options->set_column_title(1,TTR("Locale")); translation_remap_options->set_column_titles_visible(true); translation_remap_options->set_column_expand(0,true); translation_remap_options->set_column_expand(1,false); @@ -1781,7 +1781,7 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { { VBoxContainer *avb = memnew( VBoxContainer ); tab_container->add_child(avb); - avb->set_name("AutoLoad"); + avb->set_name(TTR("AutoLoad")); HBoxContainer *ahb = memnew( HBoxContainer); avb->add_child(ahb); @@ -1796,7 +1796,7 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { ahb_path->add_child(browseaa); browseaa->connect("pressed",this,"_autoload_file_open"); - avb_path->add_margin_child("Path:",ahb_path); + avb_path->add_margin_child(TTR("Path:"),ahb_path); ahb->add_child(avb_path); VBoxContainer *avb_name = memnew( VBoxContainer ); @@ -1806,8 +1806,8 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { autoload_add_name = memnew(LineEdit); autoload_add_name->set_h_size_flags(SIZE_EXPAND_FILL); ahb_name->add_child(autoload_add_name); - avb_name->add_margin_child("Node Name:",ahb_name); - Button *addaa = memnew( Button("Add") ); + avb_name->add_margin_child(TTR("Node Name:"),ahb_name); + Button *addaa = memnew( Button(TTR("Add")) ); ahb_name->add_child(addaa); addaa->connect("pressed",this,"_autoload_add"); @@ -1815,7 +1815,7 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { autoload_list = memnew( Tree ); autoload_list->set_v_size_flags(SIZE_EXPAND_FILL); - avb->add_margin_child("List:",autoload_list,true); + avb->add_margin_child(TTR("List:"),autoload_list,true); autoload_file_open=memnew( EditorFileDialog ); add_child(autoload_file_open); @@ -1824,13 +1824,13 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { autoload_list->set_columns(4); autoload_list->set_column_titles_visible(true); - autoload_list->set_column_title(0,"Name"); + autoload_list->set_column_title(0,TTR("Name")); autoload_list->set_column_expand(0,true); autoload_list->set_column_min_width(0,100); autoload_list->set_column_title(1,"Path"); autoload_list->set_column_expand(1,true); autoload_list->set_column_min_width(1,100); - autoload_list->set_column_title(2,"Singleton"); + autoload_list->set_column_title(2,TTR("Singleton")); autoload_list->set_column_expand(2,false); autoload_list->set_column_min_width(2,80); autoload_list->set_column_expand(3,false); @@ -1846,7 +1846,7 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { { plugin_settings = memnew( EditorPluginSettings ); - plugin_settings->set_name("Plugins"); + plugin_settings->set_name(TTR("Plugins")); tab_container->add_child(plugin_settings); } @@ -1861,7 +1861,7 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { /* Control * es = memnew( Control ); - es->set_name("Export"); + es->set_name(TTR("Export")); tab_container->add_child(es); export_settings = memnew( ProjectExportSettings ); es->add_child(export_settings); diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp index 110f5bb7f5..7c88870902 100644 --- a/tools/editor/property_editor.cpp +++ b/tools/editor/property_editor.cpp @@ -347,15 +347,15 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty type_button->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,3); type_button->set_anchor_and_margin(MARGIN_TOP,ANCHOR_END,25); type_button->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END,7); - type_button->set_text("Preset.."); + type_button->set_text(TTR("Preset..")); type_button->get_popup()->clear(); - type_button->get_popup()->add_item("Linear",EASING_LINEAR); - type_button->get_popup()->add_item("Ease In",EASING_EASE_IN); - type_button->get_popup()->add_item("Ease Out",EASING_EASE_OUT); + type_button->get_popup()->add_item(TTR("Linear"),EASING_LINEAR); + type_button->get_popup()->add_item(TTR("Ease In"),EASING_EASE_IN); + type_button->get_popup()->add_item(TTR("Ease Out"),EASING_EASE_OUT); if (hint_text!="attenuation") { - type_button->get_popup()->add_item("Zero",EASING_ZERO); - type_button->get_popup()->add_item("Easing In-Out",EASING_IN_OUT); - type_button->get_popup()->add_item("Easing Out-In",EASING_OUT_IN); + type_button->get_popup()->add_item(TTR("Zero"),EASING_ZERO); + type_button->get_popup()->add_item(TTR("Easing In-Out"),EASING_IN_OUT); + type_button->get_popup()->add_item(TTR("Easing Out-In"),EASING_OUT_IN); } type_button->show(); @@ -393,15 +393,15 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty if (hint==PROPERTY_HINT_FILE || hint==PROPERTY_HINT_GLOBAL_FILE) { List<String> names; - names.push_back("File.."); - names.push_back("Clear"); + names.push_back(TTR("File..")); + names.push_back(TTR("Clear")); config_action_buttons(names); } else if (hint==PROPERTY_HINT_DIR || hint==PROPERTY_HINT_GLOBAL_DIR) { List<String> names; - names.push_back("Dir.."); - names.push_back("Clear"); + names.push_back(TTR("Dir..")); + names.push_back(TTR("Clear")); config_action_buttons(names); } else if (hint==PROPERTY_HINT_ENUM) { @@ -414,8 +414,8 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty //action_buttons[0]; - int button_margin = get_constant("button_margin","Dialogs"); - int margin = get_constant("margin","Dialogs"); + int button_margin = get_constant("button_margin",TTR("Dialogs")); + int margin = get_constant("margin",TTR("Dialogs")); action_buttons[0]->set_anchor( MARGIN_LEFT, ANCHOR_END ); action_buttons[0]->set_anchor( MARGIN_TOP, ANCHOR_END ); @@ -423,7 +423,7 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty action_buttons[0]->set_anchor( MARGIN_BOTTOM, ANCHOR_END ); action_buttons[0]->set_begin( Point2( 70, button_margin-5 ) ); action_buttons[0]->set_end( Point2( margin, margin ) ); - action_buttons[0]->set_text("Close"); + action_buttons[0]->set_text(TTR("Close")); action_buttons[0]->show(); } else { @@ -634,17 +634,17 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty case Variant::IMAGE: { List<String> names; - names.push_back("New"); - names.push_back("Load"); - names.push_back("Clear"); + names.push_back(TTR("New")); + names.push_back(TTR("Load")); + names.push_back(TTR("Clear")); config_action_buttons(names); } break; case Variant::NODE_PATH: { List<String> names; - names.push_back("Assign"); - names.push_back("Clear"); + names.push_back(TTR("Assign")); + names.push_back(TTR("Clear")); config_action_buttons(names); } break; @@ -689,7 +689,7 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty menu->add_icon_item(get_icon(t,"EditorIcons"),"New "+t,id); } else { - menu->add_item("New "+t,id); + menu->add_item(TTR("New ")+t,id); } idx++; @@ -745,12 +745,12 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty if (!RES(v).is_null()) { - menu->add_item("Copy",OBJ_MENU_COPY); + menu->add_item(TTR("Copy"),OBJ_MENU_COPY); } if (paste_valid) { - menu->add_item("Paste",OBJ_MENU_PASTE); + menu->add_item(TTR("Paste"),OBJ_MENU_PASTE); } } @@ -830,7 +830,7 @@ void CustomPropertyEditor::_file_selected(String p_file) { RES res = ResourceLoader::load(p_file,type); if (res.is_null()) { - error->set_text("Error loading file: Not a resource!"); + error->set_text(TTR("Error loading file: Not a resource!")); error->popup_centered_minsize(); break; } @@ -842,7 +842,7 @@ void CustomPropertyEditor::_file_selected(String p_file) { Image image; Error err = ImageLoader::load_image(p_file,&image); - ERR_EXPLAIN("Couldn't load image"); + ERR_EXPLAIN(TTR("Couldn't load image")); ERR_FAIL_COND(err); v=image; emit_signal("variant_changed"); @@ -931,7 +931,7 @@ void CustomPropertyEditor::_node_path_selected(NodePath p_path) { if (owner->is_type("Node")) node = owner->cast_to<Node>(); - else if (owner->is_type("ArrayPropertyEdit")) + else if (owner->is_type(TTR("ArrayPropertyEdit"))) node = owner->cast_to<ArrayPropertyEdit>()->get_node(); if (!node) { @@ -1727,7 +1727,7 @@ CustomPropertyEditor::CustomPropertyEditor() { add_child(checks20[i]); checks20[i]->hide(); checks20[i]->connect("pressed",this,"_action_pressed",make_binds(i)); - checks20[i]->set_tooltip("Bit "+itos(i)+", val "+itos(1<<i)+"."); + checks20[i]->set_tooltip(TTR("Bit ")+itos(i)+", val "+itos(1<<i)+"."); } text_edit = memnew( TextEdit ); @@ -1767,7 +1767,7 @@ CustomPropertyEditor::CustomPropertyEditor() { file->connect("dir_selected", this,"_file_selected"); error = memnew( ConfirmationDialog ); - error->set_title("Error!"); + error->set_title(TTR("Error!")); add_child(error); //error->get_cancel()->hide(); @@ -2465,11 +2465,11 @@ void PropertyEditor::update_tree() { TreeItem *title = tree->create_item(root); title->set_custom_bg_color(0,get_color("prop_section","Editor")); - title->set_text(0,"Property"); // todo, fetch name if ID exists in database + title->set_text(0,TTR("Property")); // todo, fetch name if ID exists in database title->set_editable(0,false); title->set_selectable(0,false); title->set_custom_bg_color(1,get_color("prop_section","Editor")); - title->set_text(1,"Value"); // todo, fetch name if ID exists in database + title->set_text(1,TTR("Value")); // todo, fetch name if ID exists in database title->set_editable(1,false); title->set_selectable(1,false); */ @@ -2478,7 +2478,7 @@ void PropertyEditor::update_tree() { if (obj->cast_to<Node>() || obj->cast_to<Resource>()) { TreeItem *type = tree->create_item(root); - type->set_text(0,"Type"); // todo, fetch name if ID exists in database + type->set_text(0,TTR("Type")); // todo, fetch name if ID exists in database type->set_text(1,obj->get_type()); // todo, fetch name if ID exists in database if (has_icon(obj->get_type(),"EditorIcons")) type->set_icon(1,get_icon(obj->get_type(),"EditorIcons") ); @@ -2491,7 +2491,7 @@ void PropertyEditor::update_tree() { TreeItem *name = tree->create_item(root); - name->set_text(0,"Name"); // todo, fetch name if ID exists in database + name->set_text(0,TTR("Name")); // todo, fetch name if ID exists in database if (obj->is_type("Resource")) name->set_text(1,obj->cast_to<Resource>()->get_name()); else if (obj->is_type("Node")) @@ -2552,7 +2552,7 @@ void PropertyEditor::update_tree() { sep->set_icon(0,get_icon(type,"EditorIcons") ); else sep->set_icon(0,get_icon("Object","EditorIcons") ); - print_line("CATEGORY: "+type); + print_line(TTR("CATEGORY: ")+type); */ sep->set_text(0,type); sep->set_selectable(0,false); @@ -2574,7 +2574,7 @@ void PropertyEditor::update_tree() { } - sep->set_tooltip(0,"Class: "+p.name+":\n\n"+class_descr_cache[type]); + sep->set_tooltip(0,TTR("Class: ")+p.name+":\n\n"+class_descr_cache[type]); } //sep->set_custom_color(0,Color(1,1,1)); @@ -2671,7 +2671,7 @@ void PropertyEditor::update_tree() { descr_cache[type][setter]=descr; } - item->set_tooltip(0, "Property: "+p.name+"\n\n"+descr); + item->set_tooltip(0, TTR("Property: ")+p.name+"\n\n"+descr); } } //EditorHelp::get_doc_data(); @@ -2702,7 +2702,7 @@ void PropertyEditor::update_tree() { case Variant::BOOL: { item->set_cell_mode( 1, TreeItem::CELL_MODE_CHECK ); - item->set_text(1,"On"); + item->set_text(1,TTR("On")); item->set_checked( 1, obj->get( p.name ) ); if (show_type_icons) item->set_icon( 0, get_icon("Bool","EditorIcons") ); @@ -3240,7 +3240,7 @@ void PropertyEditor::_edit_set(const String& p_name, const Variant& p_value) { } else { - undo_redo->create_action("Set "+p_name,true); + undo_redo->create_action(TTR("Set ")+p_name,true); undo_redo->add_do_property(obj,p_name,p_value); undo_redo->add_undo_property(obj,p_name,obj->get(p_name)); undo_redo->add_do_method(this,"_changed_callback",obj,p_name); @@ -3752,7 +3752,7 @@ PropertyEditor::PropertyEditor() { update_tree_pending=false; top_label = memnew( Label ); - top_label->set_text("Properties:"); + top_label->set_text(TTR("Properties:")); top_label->set_anchor( MARGIN_RIGHT, ANCHOR_END ); top_label->set_begin( Point2( 10,0) ); top_label->set_end( Point2( 0,12) ); @@ -4003,7 +4003,7 @@ void SectionedPropertyEditor::update_category_list() { } else { if (!existing_sections.has("")) { existing_sections.insert(""); - sections->add_item("Global"); + sections->add_item(TTR("Global")); sections->set_item_metadata(sections->get_item_count()-1,""); } } @@ -4026,7 +4026,7 @@ SectionedPropertyEditor::SectionedPropertyEditor() { sections = memnew( ItemList ); sections->set_v_size_flags(SIZE_EXPAND_FILL); - left_vb->add_margin_child("Sections:",sections,true); + left_vb->add_margin_child(TTR("Sections:"),sections,true); VBoxContainer *right_vb = memnew( VBoxContainer); right_vb->set_h_size_flags(SIZE_EXPAND_FILL); @@ -4035,7 +4035,7 @@ SectionedPropertyEditor::SectionedPropertyEditor() { filter = memnew( SectionedPropertyEditorFilter ); editor = memnew( PropertyEditor ); editor->set_v_size_flags(SIZE_EXPAND_FILL); - right_vb->add_margin_child("Properties:",editor,true); + right_vb->add_margin_child(TTR("Properties:"),editor,true); editor->get_scene_tree()->set_column_titles_visible(false); diff --git a/tools/editor/pvrtc_compress.cpp b/tools/editor/pvrtc_compress.cpp index c30aedc1dc..fcb3c7abc8 100644 --- a/tools/editor/pvrtc_compress.cpp +++ b/tools/editor/pvrtc_compress.cpp @@ -82,7 +82,7 @@ static void _compress_image(Image::CompressMode p_mode,Image *p_image) { } - if (EditorSettings::get_singleton()->get("PVRTC/fast_conversion").operator bool()) { + if (EditorSettings::get_singleton()->get(TTR("PVRTC/fast_conversion")).operator bool()) { args.push_back("-pvrtcfast"); } if (p_image->get_mipmaps()>0) @@ -93,13 +93,13 @@ static void _compress_image(Image::CompressMode p_mode,Image *p_image) { ResourceSaver::save(src_img,t); Error err = OS::get_singleton()->execute(ttpath,args,true); - ERR_EXPLAIN("Could not execute PVRTC Tool: "+ttpath); + ERR_EXPLAIN(TTR("Could not execute PVRTC Tool: ")+ttpath); ERR_FAIL_COND(err!=OK); t=ResourceLoader::load(dst_img,"Texture"); - ERR_EXPLAIN("Can't load back converted image using PVRTC Tool: "+dst_img); + ERR_EXPLAIN(TTR("Can't load back converted image using PVRTC Tool: ")+dst_img); ERR_FAIL_COND(t.is_null()); *p_image=t->get_data(); diff --git a/tools/editor/quick_open.cpp b/tools/editor/quick_open.cpp index 828275340b..72059c264f 100644 --- a/tools/editor/quick_open.cpp +++ b/tools/editor/quick_open.cpp @@ -216,12 +216,12 @@ EditorQuickOpen::EditorQuickOpen() { add_child(vbc); set_child_rect(vbc); search_box = memnew( LineEdit ); - vbc->add_margin_child("Search:",search_box); + vbc->add_margin_child(TTR("Search:"),search_box); search_box->connect("text_changed",this,"_text_changed"); search_box->connect("input_event",this,"_sbox_input"); search_options = memnew( Tree ); - vbc->add_margin_child("Matches:",search_options,true); - get_ok()->set_text("Open"); + vbc->add_margin_child(TTR("Matches:"),search_options,true); + get_ok()->set_text(TTR("Open")); get_ok()->set_disabled(true); register_text_enter(search_box); set_hide_on_ok(false); diff --git a/tools/editor/reparent_dialog.cpp b/tools/editor/reparent_dialog.cpp index 2a886b85fa..7803208c89 100644 --- a/tools/editor/reparent_dialog.cpp +++ b/tools/editor/reparent_dialog.cpp @@ -84,7 +84,7 @@ void ReparentDialog::_bind_methods() { ReparentDialog::ReparentDialog() { - set_title("Reparent Node"); + set_title(TTR("Reparent Node")); VBoxContainer *vbc = memnew( VBoxContainer ); add_child(vbc); @@ -93,25 +93,25 @@ ReparentDialog::ReparentDialog() { tree = memnew( SceneTreeEditor(false) ); tree->set_show_enabled_subscene(true); - vbc->add_margin_child("Reparent Location (Select new Parent):",tree,true); + vbc->add_margin_child(TTR("Reparent Location (Select new Parent):"),tree,true); tree->get_scene_tree()->connect("item_activated",this,"_reparent"); //Label *label = memnew( Label ); //label->set_pos( Point2( 15,8) ); - //label->set_text("Reparent Location (Select new Parent):"); + //label->set_text(TTR("Reparent Location (Select new Parent):")); keep_transform = memnew( CheckBox ); - keep_transform->set_text("Keep Global Transform"); + keep_transform->set_text(TTR("Keep Global Transform")); keep_transform->set_pressed(true); vbc->add_child(keep_transform); - //vbc->add_margin_child("Options:",node_only);; + //vbc->add_margin_child(TTR("Options:"),node_only);; //cancel->connect("pressed", this,"_cancel"); - get_ok()->set_text("Reparent"); + get_ok()->set_text(TTR("Reparent")); } diff --git a/tools/editor/resources_dock.cpp b/tools/editor/resources_dock.cpp index 5e44162c93..10292ed10d 100644 --- a/tools/editor/resources_dock.cpp +++ b/tools/editor/resources_dock.cpp @@ -133,7 +133,7 @@ void ResourcesDock::save_resource(const String& p_path,const Ref<Resource>& p_re Error err = ResourceSaver::save(path,p_resource,flg|ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS); if (err!=OK) { - accept->set_text("Error saving resource!"); + accept->set_text(TTR("Error saving resource!")); accept->popup_centered_minsize(); return; } @@ -351,21 +351,21 @@ ResourcesDock::ResourcesDock(EditorNode *p_editor) { Button *b; b = memnew( ToolButton ); - b->set_tooltip("Create New Resource"); + b->set_tooltip(TTR("Create New Resource")); b->connect("pressed",this,"_tool_selected",make_binds(TOOL_NEW)); hbc->add_child( b ); button_new=b; b = memnew( ToolButton ); - b->set_tooltip("Open Resource"); + b->set_tooltip(TTR("Open Resource")); b->connect("pressed",this,"_tool_selected",make_binds(TOOL_OPEN)); hbc->add_child( b ); button_open=b; MenuButton *mb = memnew( MenuButton ); - mb->set_tooltip("Save Resource"); - mb->get_popup()->add_item("Save Resource",TOOL_SAVE); - mb->get_popup()->add_item("Save Resource As..",TOOL_SAVE_AS); + mb->set_tooltip(TTR("Save Resource")); + mb->get_popup()->add_item(TTR("Save Resource"),TOOL_SAVE); + mb->get_popup()->add_item(TTR("Save Resource As.."),TOOL_SAVE_AS); mb->get_popup()->connect("item_pressed",this,"_tool_selected" ); hbc->add_child( mb ); button_save=mb; @@ -373,10 +373,10 @@ ResourcesDock::ResourcesDock(EditorNode *p_editor) { hbc->add_spacer(); mb = memnew( MenuButton ); - mb->set_tooltip("Resource Tools"); - mb->get_popup()->add_item("Make Local",TOOL_MAKE_LOCAL); - mb->get_popup()->add_item("Copy",TOOL_COPY); - mb->get_popup()->add_item("Paste",TOOL_PASTE); + mb->set_tooltip(TTR("Resource Tools")); + mb->get_popup()->add_item(TTR("Make Local"),TOOL_MAKE_LOCAL); + mb->get_popup()->add_item(TTR("Copy"),TOOL_COPY); + mb->get_popup()->add_item(TTR("Paste"),TOOL_PASTE); mb->get_popup()->connect("item_pressed",this,"_tool_selected" ); hbc->add_child( mb ); button_tools=mb; diff --git a/tools/editor/run_settings_dialog.cpp b/tools/editor/run_settings_dialog.cpp index 9dc4d703fc..fd2e9f9759 100644 --- a/tools/editor/run_settings_dialog.cpp +++ b/tools/editor/run_settings_dialog.cpp @@ -79,20 +79,20 @@ RunSettingsDialog::RunSettingsDialog() { set_child_rect(vbc); run_mode = memnew( OptionButton ); - vbc->add_margin_child("Run Mode:",run_mode); - run_mode->add_item("Current Scene"); - run_mode->add_item("Main Scene"); + vbc->add_margin_child(TTR("Run Mode:"),run_mode); + run_mode->add_item(TTR("Current Scene")); + run_mode->add_item(TTR("Main Scene")); run_mode->connect("item_selected",this,"_run_mode_changed"); arguments = memnew( LineEdit ); - vbc->add_margin_child("Main Scene Arguments:",arguments); + vbc->add_margin_child(TTR("Main Scene Arguments:"),arguments); arguments->set_editable(false); - get_ok()->set_text("Close"); - //get_cancel()->set_text("Close"); + get_ok()->set_text(TTR("Close")); + //get_cancel()->set_text(TTR("Close")); arguments->set_text("-l $scene"); - set_title("Scene Run Settings"); + set_title(TTR("Scene Run Settings")); } diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp index c6115ba87a..113d18ea73 100644 --- a/tools/editor/scene_tree_dock.cpp +++ b/tools/editor/scene_tree_dock.cpp @@ -63,8 +63,8 @@ Node* SceneTreeDock::instance(const String& p_file) { current_option=-1; //accept->get_cancel()->hide(); - accept->get_ok()->set_text("Ok :( "); - accept->set_text("No parent to instance a child at."); + accept->get_ok()->set_text(TTR("Ok :( ")); + accept->set_text(TTR("No parent to instance a child at.")); accept->popup_centered_minsize(); return NULL; }; @@ -81,8 +81,8 @@ Node* SceneTreeDock::instance(const String& p_file) { current_option=-1; //accept->get_cancel()->hide(); - accept->get_ok()->set_text("Ugh"); - accept->set_text(String("Error loading scene from ")+p_file); + accept->get_ok()->set_text(TTR("Ugh")); + accept->set_text(String(TTR("Error loading scene from "))+p_file); accept->popup_centered_minsize(); return NULL; } @@ -92,8 +92,8 @@ Node* SceneTreeDock::instance(const String& p_file) { if (_cyclical_dependency_exists(edited_scene->get_filename(), instanced_scene)) { - accept->get_ok()->set_text("Ok"); - accept->set_text(String("Cannot instance the scene '")+p_file+String("' because the current scene exists within one of its' nodes.")); + accept->get_ok()->set_text(TTR("Ok")); + accept->set_text(String(TTR("Cannot instance the scene '"))+p_file+String("' because the current scene exists within one of its' nodes.")); accept->popup_centered_minsize(); return NULL; } @@ -102,7 +102,7 @@ Node* SceneTreeDock::instance(const String& p_file) { //instanced_scene->generate_instance_state(); instanced_scene->set_filename( Globals::get_singleton()->localize_path(p_file) ); - editor_data->get_undo_redo().create_action("Instance Scene"); + editor_data->get_undo_redo().create_action(TTR("Instance Scene")); editor_data->get_undo_redo().add_do_method(parent,"add_child",instanced_scene); editor_data->get_undo_redo().add_do_method(instanced_scene,"set_owner",edited_scene); editor_data->get_undo_redo().add_do_method(editor_selection,"clear"); @@ -173,7 +173,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { current_option=-1; //confirmation->get_cancel()->hide(); - accept->get_ok()->set_text("I see.."); + accept->get_ok()->set_text(TTR("I see..")); accept->set_text("This operation can't be done without a tree root."); accept->popup_centered_minsize(); break; @@ -254,7 +254,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { current_option=-1; //accept->get_cancel()->hide(); - accept->get_ok()->set_text("I see.."); + accept->get_ok()->set_text(TTR("I see..")); accept->set_text("This operation can't be done on the tree root."); accept->popup_centered_minsize(); break; @@ -288,8 +288,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (!common_parent || (MOVING_DOWN && highest_id >= common_parent->get_child_count() - MOVING_DOWN) || (MOVING_UP && lowest_id == 0)) break; // one or more nodes can not be moved - if (selection.size() == 1) editor_data->get_undo_redo().create_action("Move Node In Parent"); - if (selection.size() > 1) editor_data->get_undo_redo().create_action("Move Nodes In Parent"); + if (selection.size() == 1) editor_data->get_undo_redo().create_action(TTR("Move Node In Parent")); + if (selection.size() > 1) editor_data->get_undo_redo().create_action(TTR("Move Nodes In Parent")); for (int i = 0; i < selection.size(); i++) { Node *top_node = selection[i]; @@ -322,7 +322,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { current_option=-1; //accept->get_cancel()->hide(); - accept->get_ok()->set_text("I see.."); + accept->get_ok()->set_text(TTR("I see..")); accept->set_text("This operation can't be done on the tree root."); accept->popup_centered_minsize(); break; @@ -335,7 +335,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { List<Node*> reselect; - editor_data->get_undo_redo().create_action("Duplicate Node(s)"); + editor_data->get_undo_redo().create_action(TTR("Duplicate Node(s)")); editor_data->get_undo_redo().add_do_method(editor_selection,"clear"); Node *dupsingle=NULL; @@ -434,7 +434,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { current_option=-1; //confirmation->get_cancel()->hide(); - accept->get_ok()->set_text("I see.."); + accept->get_ok()->set_text(TTR("I see..")); accept->set_text("This operation can't be done on the tree root."); accept->popup_centered_minsize(); break; @@ -484,7 +484,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { editor->get_viewport_control()->update(); } else { - delete_dialog->set_text("Delete Node(s)?"); + delete_dialog->set_text(TTR("Delete Node(s)?")); delete_dialog->popup_centered_minsize(); } @@ -494,7 +494,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { Node *scene = editor_data->get_edited_scene_root(); if (!scene) { - accept->get_ok()->set_text("I see.."); + accept->get_ok()->set_text(TTR("I see..")); accept->set_text("This operation can't be done without a scene."); accept->popup_centered_minsize(); break; @@ -503,8 +503,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { List<Node*> selection = editor_selection->get_selected_node_list(); if (selection.size()!=1) { - accept->get_ok()->set_text("I see.."); - accept->set_text("This operation requires a single selected node."); + accept->get_ok()->set_text(TTR("I see..")); + accept->set_text(TTR("This operation requires a single selected node.")); accept->popup_centered_minsize(); break; } @@ -512,7 +512,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { Node *tocopy = selection.front()->get(); if (tocopy!=editor_data->get_edited_scene_root() && tocopy->get_filename()!="") { - accept->get_ok()->set_text("I see.."); + accept->get_ok()->set_text(TTR("I see..")); accept->set_text("This operation can't be done on instanced scenes."); accept->popup_centered_minsize(); break; @@ -535,7 +535,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { new_scene_from_dialog->set_current_path(existing); new_scene_from_dialog->popup_centered_ratio(); - new_scene_from_dialog->set_title("Save New Scene As.."); + new_scene_from_dialog->set_title(TTR("Save New Scene As..")); } break; @@ -919,8 +919,8 @@ bool SceneTreeDock::_validate_no_foreign() { if (E->get()!=edited_scene && E->get()->get_owner()!=edited_scene) { - accept->get_ok()->set_text("Makes Sense!"); - accept->set_text("Can't operate on nodes from a foreign scene!"); + accept->get_ok()->set_text(TTR("Makes Sense!")); + accept->set_text(TTR("Can't operate on nodes from a foreign scene!")); accept->popup_centered_minsize(); return false; @@ -928,8 +928,8 @@ bool SceneTreeDock::_validate_no_foreign() { if (edited_scene->get_scene_inherited_state().is_valid() && edited_scene->get_scene_inherited_state()->find_node_by_path(edited_scene->get_path_to(E->get()))>=0) { - accept->get_ok()->set_text("Makes Sense!"); - accept->set_text("Can't operate on nodes the current scene inherits from!"); + accept->get_ok()->set_text(TTR("Makes Sense!")); + accept->set_text(TTR("Can't operate on nodes the current scene inherits from!")); accept->popup_centered_minsize(); return false; @@ -970,7 +970,7 @@ void SceneTreeDock::_node_reparent(NodePath p_path,bool p_keep_global_xform) { //sort by tree order, so re-adding is easy selection.sort_custom<Node::Comparator>(); - editor_data->get_undo_redo().create_action("Reparent Node"); + editor_data->get_undo_redo().create_action(TTR("Reparent Node")); List<Pair<NodePath,NodePath> > path_renames; @@ -1100,7 +1100,7 @@ void SceneTreeDock::_delete_confirm() { editor->get_editor_plugins_over()->make_visible(false); - editor_data->get_undo_redo().create_action("Remove Node(s)"); + editor_data->get_undo_redo().create_action(TTR("Remove Node(s)")); bool entire_scene=false; @@ -1230,7 +1230,7 @@ void SceneTreeDock::_create() { Node *child=c->cast_to<Node>(); ERR_FAIL_COND(!child); - editor_data->get_undo_redo().create_action("Create Node"); + editor_data->get_undo_redo().create_action(TTR("Create Node")); if (edited_scene) { @@ -1368,7 +1368,7 @@ void SceneTreeDock::_import_subscene() { /* - editor_data->get_undo_redo().create_action("Import Subscene"); + editor_data->get_undo_redo().create_action(TTR("Import Subscene")); editor_data->get_undo_redo().add_do_method(parent,"add_child",ss); //editor_data->get_undo_redo().add_do_method(editor_selection,"clear"); //editor_data->get_undo_redo().add_do_method(editor_selection,"add_node",child); @@ -1383,8 +1383,8 @@ void SceneTreeDock::_new_scene_from(String p_file) { List<Node*> selection = editor_selection->get_selected_node_list(); if (selection.size()!=1) { - accept->get_ok()->set_text("I see.."); - accept->set_text("This operation requires a single selected node."); + accept->get_ok()->set_text(TTR("I see..")); + accept->set_text(TTR("This operation requires a single selected node.")); accept->popup_centered_minsize(); return; } @@ -1401,8 +1401,8 @@ void SceneTreeDock::_new_scene_from(String p_file) { memdelete(copy); if (err!=OK) { - accept->get_ok()->set_text("I see.."); - accept->set_text("Couldn't save new scene. Likely dependencies (instances) couldn't be satisfied."); + accept->get_ok()->set_text(TTR("I see..")); + accept->set_text(TTR("Couldn't save new scene. Likely dependencies (instances) couldn't be satisfied.")); accept->popup_centered_minsize(); return; } @@ -1416,15 +1416,15 @@ void SceneTreeDock::_new_scene_from(String p_file) { err = ResourceSaver::save(p_file,sdata,flg); if (err!=OK) { - accept->get_ok()->set_text("I see.."); - accept->set_text("Error saving scene."); + accept->get_ok()->set_text(TTR("I see..")); + accept->set_text(TTR("Error saving scene.")); accept->popup_centered_minsize(); return; } } else { - accept->get_ok()->set_text("I see.."); - accept->set_text("Error duplicating scene to save it."); + accept->get_ok()->set_text(TTR("I see..")); + accept->set_text(TTR("Error duplicating scene to save it.")); accept->popup_centered_minsize(); return; } @@ -1478,13 +1478,13 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelec tb = memnew( ToolButton ); tb->connect("pressed",this,"_tool_selected",make_binds(TOOL_INSTANCE, false)); - tb->set_tooltip("Instance a scene file as a Node."); + tb->set_tooltip(TTR("Instance a scene file as a Node.")); hbc_top->add_child(tb); tool_buttons[TOOL_INSTANCE]=tb; tb = memnew( ToolButton ); tb->connect("pressed",this,"_tool_selected",make_binds(TOOL_REPLACE, false)); - tb->set_tooltip("Replace a Node by Another Node Type"); + tb->set_tooltip(TTR("Replace a Node by Another Node Type")); hbc_top->add_child(tb); tool_buttons[TOOL_REPLACE]=tb; @@ -1492,19 +1492,19 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelec tb = memnew( ToolButton ); tb->connect("pressed",this,"_tool_selected",make_binds(TOOL_CONNECT, false)); - tb->set_tooltip("Edit the Node Connections"); + tb->set_tooltip(TTR("Edit the Node Connections")); hbc_top->add_child(tb); tool_buttons[TOOL_CONNECT]=tb; tb = memnew( ToolButton ); tb->connect("pressed",this,"_tool_selected",make_binds(TOOL_GROUP, false)); - tb->set_tooltip("Edit the Node Groups"); + tb->set_tooltip(TTR("Edit the Node Groups")); hbc_top->add_child(tb); tool_buttons[TOOL_GROUP]=tb; tb = memnew( ToolButton ); tb->connect("pressed",this,"_tool_selected",make_binds(TOOL_SCRIPT, false)); - tb->set_tooltip("Edit/Create the Node Script"); + tb->set_tooltip(TTR("Edit/Create the Node Script")); hbc_top->add_child(tb); tool_buttons[TOOL_SCRIPT]=tb; @@ -1546,7 +1546,7 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelec tb = memnew( ToolButton ); tb->connect("pressed",this,"_tool_selected",make_binds(TOOL_REPARENT, false)); - tb->set_tooltip("Reparent Selected Node(s)"); + tb->set_tooltip(TTR("Reparent Selected Node(s)")); hbc_bottom->add_child(tb); tool_buttons[TOOL_REPARENT]=tb; @@ -1554,19 +1554,19 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelec tb = memnew( ToolButton ); tb->connect("pressed",this,"_tool_selected",make_binds(TOOL_NEW_SCENE_FROM, false)); - tb->set_tooltip("Create New Scene From Node(s)"); + tb->set_tooltip(TTR("Create New Scene From Node(s)")); hbc_bottom->add_child(tb); tool_buttons[TOOL_NEW_SCENE_FROM]=tb; tb = memnew( ToolButton ); tb->connect("pressed",this,"_tool_selected",make_binds(TOOL_MULTI_EDIT, false)); - tb->set_tooltip("Multi-Edit Selected Nodes"); + tb->set_tooltip(TTR("Multi-Edit Selected Nodes")); hbc_bottom->add_child(tb); tool_buttons[TOOL_MULTI_EDIT]=tb; tb = memnew( ToolButton ); tb->connect("pressed",this,"_tool_selected",make_binds(TOOL_ERASE, false)); - tb->set_tooltip("Erase Selected Node(s)"); + tb->set_tooltip(TTR("Erase Selected Node(s)")); hbc_bottom->add_child(tb); tool_buttons[TOOL_ERASE]=tb; diff --git a/tools/editor/scene_tree_editor.cpp b/tools/editor/scene_tree_editor.cpp index c16152ae44..6d13f74e4d 100644 --- a/tools/editor/scene_tree_editor.cpp +++ b/tools/editor/scene_tree_editor.cpp @@ -168,13 +168,13 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item,int p_column,int p_id) Spatial *ci = n->cast_to<Spatial>(); if (!ci->is_visible() && ci->get_parent_spatial() && !ci->get_parent_spatial()->is_visible()) { - error->set_text("This item cannot be made visible because the parent is hidden. Unhide the parent first."); + error->set_text(TTR("This item cannot be made visible because the parent is hidden. Unhide the parent first.")); error->popup_centered_minsize(); return; } bool v = !bool(n->call("is_hidden")); - undo_redo->create_action("Toggle Spatial Visible"); + undo_redo->create_action(TTR("Toggle Spatial Visible")); undo_redo->add_do_method(n,"_set_visible_",!v); undo_redo->add_undo_method(n,"_set_visible_",v); undo_redo->commit_action(); @@ -182,12 +182,12 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item,int p_column,int p_id) CanvasItem *ci = n->cast_to<CanvasItem>(); if (!ci->is_visible() && ci->get_parent_item() && !ci->get_parent_item()->is_visible()) { - error->set_text("This item cannot be made visible because the parent is hidden. Unhide the parent first."); + error->set_text(TTR("This item cannot be made visible because the parent is hidden. Unhide the parent first.")); error->popup_centered_minsize(); return; } bool v = !bool(n->call("is_hidden")); - undo_redo->create_action("Toggle CanvasItem Visible"); + undo_redo->create_action(TTR("Toggle CanvasItem Visible")); undo_redo->add_do_method(n,v?"hide":"show"); undo_redo->add_undo_method(n,v?"show":"hide"); undo_redo->commit_action(); @@ -278,11 +278,11 @@ void SceneTreeEditor::_add_nodes(Node *p_node,TreeItem *p_parent) { if (p_node==get_scene_node() && p_node->get_scene_inherited_state().is_valid()) { item->add_button(0,get_icon("InstanceOptions","EditorIcons"),BUTTON_SUBSCENE); - item->set_tooltip(0,"Inherits: "+p_node->get_scene_inherited_state()->get_path()+"\nType: "+p_node->get_type()); + item->set_tooltip(0,TTR("Inherits: ")+p_node->get_scene_inherited_state()->get_path()+"\nType: "+p_node->get_type()); } else if (p_node!=get_scene_node() && p_node->get_filename()!="" && can_open_instance) { item->add_button(0,get_icon("InstanceOptions","EditorIcons"),BUTTON_SUBSCENE); - item->set_tooltip(0,"Instance: "+p_node->get_filename()+"\nType: "+p_node->get_type()); + item->set_tooltip(0,TTR("Instance: ")+p_node->get_filename()+"\nType: "+p_node->get_type()); } else { item->set_tooltip(0,String(p_node->get_name())+"\nType: "+p_node->get_type()); } @@ -666,7 +666,7 @@ void SceneTreeEditor::_renamed() { which->set_metadata(0,n->get_path()); emit_signal("node_renamed"); } else { - undo_redo->create_action("Rename Node"); + undo_redo->create_action(TTR("Rename Node")); emit_signal("node_prerename",n,new_name); undo_redo->add_do_method(this,"_rename_node",n->get_instance_ID(),new_name); undo_redo->add_undo_method(this,"_rename_node",n->get_instance_ID(),n->get_name()); @@ -833,7 +833,7 @@ SceneTreeEditor::SceneTreeEditor(bool p_label,bool p_can_rename, bool p_can_open if (p_label) { Label *label = memnew( Label ); label->set_pos( Point2(10, 0)); - label->set_text("Scene Tree (Nodes):"); + label->set_text(TTR("Scene Tree (Nodes):")); add_child(label); } @@ -863,24 +863,24 @@ SceneTreeEditor::SceneTreeEditor(bool p_label,bool p_can_rename, bool p_can_open blocked=0; instance_menu = memnew( PopupMenu ); - instance_menu->add_check_item("Editable Children",SCENE_MENU_EDITABLE_CHILDREN); - instance_menu->add_check_item("Load As Placeholder",SCENE_MENU_USE_PLACEHOLDER); + instance_menu->add_check_item(TTR("Editable Children"),SCENE_MENU_EDITABLE_CHILDREN); + instance_menu->add_check_item(TTR("Load As Placeholder"),SCENE_MENU_USE_PLACEHOLDER); instance_menu->add_separator(); - instance_menu->add_item("Open in Editor",SCENE_MENU_OPEN); + instance_menu->add_item(TTR("Open in Editor"),SCENE_MENU_OPEN); instance_menu->connect("item_pressed",this,"_subscene_option"); add_child(instance_menu); inheritance_menu = memnew( PopupMenu ); - inheritance_menu->add_item("Clear Inheritance",SCENE_MENU_CLEAR_INHERITANCE); + inheritance_menu->add_item(TTR("Clear Inheritance"),SCENE_MENU_CLEAR_INHERITANCE); inheritance_menu->add_separator(); - inheritance_menu->add_item("Open in Editor",SCENE_MENU_OPEN_INHERITED); + inheritance_menu->add_item(TTR("Open in Editor"),SCENE_MENU_OPEN_INHERITED); inheritance_menu->connect("item_pressed",this,"_subscene_option"); add_child(inheritance_menu); clear_inherit_confirm = memnew( ConfirmationDialog ); - clear_inherit_confirm->set_text("Clear Inheritance? (No Undo!)"); - clear_inherit_confirm->get_ok()->set_text("Clear!"); + clear_inherit_confirm->set_text(TTR("Clear Inheritance? (No Undo!)")); + clear_inherit_confirm->get_ok()->set_text(TTR("Clear!")); add_child(clear_inherit_confirm); @@ -946,7 +946,7 @@ void SceneTreeDialog::_bind_methods() { SceneTreeDialog::SceneTreeDialog() { - set_title("Select a Node"); + set_title(TTR("Select a Node")); tree = memnew( SceneTreeEditor(false,false) ); add_child(tree); diff --git a/tools/editor/scenes_dock.cpp b/tools/editor/scenes_dock.cpp index e2b17f5e64..7cb0a094b2 100644 --- a/tools/editor/scenes_dock.cpp +++ b/tools/editor/scenes_dock.cpp @@ -123,7 +123,7 @@ void ScenesDock::_update_tree() { TreeItem *root = tree->create_item(); TreeItem *favorites = tree->create_item(root); favorites->set_icon(0, get_icon("Favorites","EditorIcons") ); - favorites->set_text(0,"Favorites:"); + favorites->set_text(0,TTR("Favorites:")); favorites->set_selectable(0,false); Vector<String> faves = EditorSettings::get_singleton()->get_favorite_dirs(); for(int i=0;i<faves.size();i++) { @@ -451,7 +451,7 @@ void ScenesDock::_update_files(bool p_keep_selection) { img.resize(thumbnail_size,thumbnail_size); Ref<ImageTexture> resized_folder = Ref<ImageTexture>( memnew( ImageTexture)); resized_folder->create_from_image(img,0); - Theme::get_default()->set_icon("ResizedFolder","EditorIcons",resized_folder); + Theme::get_default()->set_icon(TTR("ResizedFolder"),"EditorIcons",resized_folder); } folder_thumbnail = get_icon("ResizedFolder","EditorIcons"); @@ -462,7 +462,7 @@ void ScenesDock::_update_files(bool p_keep_selection) { img.resize(thumbnail_size,thumbnail_size); Ref<ImageTexture> resized_file = Ref<ImageTexture>( memnew( ImageTexture)); resized_file->create_from_image(img,0); - Theme::get_default()->set_icon("ResizedFile","EditorIcons",resized_file); + Theme::get_default()->set_icon(TTR("ResizedFile"),"EditorIcons",resized_file); } file_thumbnail = get_icon("ResizedFile","EditorIcons"); @@ -715,7 +715,7 @@ void ScenesDock::_find_remaps(EditorFileSystemDirectory *efsd,Map<String,String> void ScenesDock::_rename_operation(const String& p_to_path) { if (move_files[0]==p_to_path) { - EditorNode::get_singleton()->show_warning("Same source and destination files, doing nothing."); + EditorNode::get_singleton()->show_warning(TTR("Same source and destination files, doing nothing.")); return; } if (FileAccess::exists(p_to_path)) { @@ -762,7 +762,7 @@ void ScenesDock::_rename_operation(const String& p_to_path) { void ScenesDock::_move_operation(const String& p_to_path) { if (p_to_path==path) { - EditorNode::get_singleton()->show_warning("Same source and destination paths, doing nothing."); + EditorNode::get_singleton()->show_warning(TTR("Same source and destination paths, doing nothing.")); return; } @@ -772,7 +772,7 @@ void ScenesDock::_move_operation(const String& p_to_path) { for(int i=0;i<move_dirs.size();i++) { if (p_to_path.begins_with(move_dirs[i])) { - EditorNode::get_singleton()->show_warning("Can't move directories to within themselves"); + EditorNode::get_singleton()->show_warning(TTR("Can't move directories to within themselves")); return; } @@ -876,7 +876,7 @@ void ScenesDock::_file_option(int p_option) { continue; if (files->get_item_text(i)=="..") { - EditorNode::get_singleton()->show_warning("Can't operate on '..'"); + EditorNode::get_singleton()->show_warning(TTR("Can't operate on '..'")); return; } @@ -895,7 +895,7 @@ void ScenesDock::_file_option(int p_option) { rename_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE); rename_dialog->set_current_path(move_files[0]); rename_dialog->popup_centered_ratio(); - rename_dialog->set_title("Pick New Name and Location For: "+move_files[0].get_file()); + rename_dialog->set_title(TTR("Pick New Name and Location For: ")+move_files[0].get_file()); } else { @@ -918,7 +918,7 @@ void ScenesDock::_file_option(int p_option) { } if (torem.empty()) { - EditorNode::get_singleton()->show_warning("No files selected!"); + EditorNode::get_singleton()->show_warning(TTR("No files selected!")); break; } @@ -1111,21 +1111,21 @@ ScenesDock::ScenesDock(EditorNode *p_editor) { button_hist_prev = memnew( ToolButton ); toolbar_hbc->add_child(button_hist_prev); button_hist_prev->set_disabled(true); - button_hist_prev->set_tooltip("Previous Directory"); + button_hist_prev->set_tooltip(TTR("Previous Directory")); button_hist_next = memnew( ToolButton ); toolbar_hbc->add_child(button_hist_next); button_hist_next->set_disabled(true); button_hist_prev->set_focus_mode(FOCUS_NONE); button_hist_next->set_focus_mode(FOCUS_NONE); - button_hist_next->set_tooltip("Next Directory"); + button_hist_next->set_tooltip(TTR("Next Directory")); button_reload = memnew( Button ); button_reload->set_flat(true); button_reload->connect("pressed",this,"_rescan"); toolbar_hbc->add_child(button_reload); button_reload->set_focus_mode(FOCUS_NONE); - button_reload->set_tooltip("Re-Scan Filesystem"); + button_reload->set_tooltip(TTR("Re-Scan Filesystem")); toolbar_hbc->add_spacer(); @@ -1134,21 +1134,21 @@ ScenesDock::ScenesDock(EditorNode *p_editor) { toolbar_hbc->add_child(button_fav_up); button_fav_up->set_disabled(true); button_fav_up->connect("pressed",this,"_fav_up_pressed"); - button_fav_up->set_tooltip("Move Favorite Up"); + button_fav_up->set_tooltip(TTR("Move Favorite Up")); button_fav_down = memnew( ToolButton ); button_fav_down->set_flat(true); toolbar_hbc->add_child(button_fav_down); button_fav_down->set_disabled(true); button_fav_down->connect("pressed",this,"_fav_down_pressed"); - button_fav_down->set_tooltip("Move Favorite Down"); + button_fav_down->set_tooltip(TTR("Move Favorite Down")); button_favorite = memnew( Button ); button_favorite->set_flat(true); button_favorite->set_toggle_mode(true); button_favorite->connect("pressed",this,"_favorites_pressed"); toolbar_hbc->add_child(button_favorite); - button_favorite->set_tooltip("Toggle folder status as Favorite"); + button_favorite->set_tooltip(TTR("Toggle folder status as Favorite")); button_favorite->set_focus_mode(FOCUS_NONE); button_fav_up->set_focus_mode(FOCUS_NONE); @@ -1170,20 +1170,20 @@ ScenesDock::ScenesDock(EditorNode *p_editor) { toolbar_hbc->add_child(button_instance); button_instance->hide(); button_instance->set_focus_mode(FOCUS_NONE); - button_instance->set_tooltip("Instance the selected scene(s) as child of the selected node."); + button_instance->set_tooltip(TTR("Instance the selected scene(s) as child of the selected node.")); file_options = memnew( MenuButton ); toolbar_hbc->add_child(file_options); - file_options->get_popup()->add_item("Rename or Move",FILE_MOVE); - file_options->get_popup()->add_item("Delete",FILE_REMOVE); + file_options->get_popup()->add_item(TTR("Rename or Move"),FILE_MOVE); + file_options->get_popup()->add_item(TTR("Delete"),FILE_REMOVE); file_options->get_popup()->add_separator(); - file_options->get_popup()->add_item("Edit Dependencies",FILE_DEPENDENCIES); - file_options->get_popup()->add_item("View Owners",FILE_OWNERS); - //file_options->get_popup()->add_item("Info",FILE_INFO); + file_options->get_popup()->add_item(TTR("Edit Dependencies"),FILE_DEPENDENCIES); + file_options->get_popup()->add_item(TTR("View Owners"),FILE_OWNERS); + //file_options->get_popup()->add_item(TTR("Info"),FILE_INFO); file_options->hide(); file_options->set_focus_mode(FOCUS_NONE); - file_options->set_tooltip("Miscenaneous options related to resources on disk."); + file_options->set_tooltip(TTR("Miscenaneous options related to resources on disk.")); tree = memnew( Tree ); @@ -1240,7 +1240,7 @@ ScenesDock::ScenesDock(EditorNode *p_editor) { move_dialog = memnew( EditorDirDialog ); add_child(move_dialog); move_dialog->connect("dir_selected",this,"_move_operation"); - move_dialog->get_ok()->set_text("Move"); + move_dialog->get_ok()->set_text(TTR("Move")); rename_dialog = memnew( EditorFileDialog ); rename_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE); diff --git a/tools/editor/script_create_dialog.cpp b/tools/editor/script_create_dialog.cpp index 34d9204061..8d410f6fa3 100644 --- a/tools/editor/script_create_dialog.cpp +++ b/tools/editor/script_create_dialog.cpp @@ -74,22 +74,22 @@ bool ScriptCreateDialog::_validate(const String& p_string) { void ScriptCreateDialog::_class_name_changed(const String& p_name) { if (!_validate(parent_name->get_text())) { - error_label->set_text("Invaild parent class name"); + error_label->set_text(TTR("Invaild parent class name")); error_label->add_color_override("font_color",Color(1,0.4,0.0,0.8)); } else if (class_name->is_editable()) { if (class_name->get_text()=="") { - error_label->set_text("Valid Chars: a-z A-Z 0-9 _"); + error_label->set_text(TTR("Valid Chars: a-z A-Z 0-9 _")); error_label->add_color_override("font_color",Color(1,1,1,0.6)); } else if (!_validate(class_name->get_text())) { - error_label->set_text("Invalid class name"); + error_label->set_text(TTR("Invalid class name")); error_label->add_color_override("font_color",Color(1,0.2,0.2,0.8)); } else { - error_label->set_text("Valid Name"); + error_label->set_text(TTR("Valid Name")); error_label->add_color_override("font_color",Color(0,1.0,0.8,0.8)); } } else { - error_label->set_text("N/A"); + error_label->set_text(TTR("N/A")); error_label->add_color_override("font_color",Color(0,1.0,0.8,0.8)); } } @@ -98,12 +98,12 @@ void ScriptCreateDialog::ok_pressed() { if (class_name->is_editable() && !_validate(class_name->get_text())) { - alert->set_text("Class Name is Invalid!"); + alert->set_text(TTR("Class Name is Invalid!")); alert->popup_centered_minsize(); return; } if (!_validate(parent_name->get_text())) { - alert->set_text("Parent Class Name is Invalid!"); + alert->set_text(TTR("Parent Class Name is Invalid!")); alert->popup_centered_minsize(); return; @@ -133,7 +133,7 @@ void ScriptCreateDialog::ok_pressed() { script->set_path(lpath); if (!path_valid) { - alert->set_text("Path is Invalid!"); + alert->set_text(TTR("Path is Invalid!")); alert->popup_centered_minsize(); return; @@ -141,7 +141,7 @@ void ScriptCreateDialog::ok_pressed() { Error err = ResourceSaver::save(lpath,scr,ResourceSaver::FLAG_CHANGE_PATH); if (err!=OK) { - alert->set_text("Could not create script in filesystem: "+String("")); + alert->set_text(TTR("Could not create script in filesystem: ")+String("")); alert->popup_centered_minsize(); return; } @@ -215,7 +215,7 @@ void ScriptCreateDialog::_path_changed(const String& p_path) { if (p=="") { - path_error_label->set_text("Path is Empty"); + path_error_label->set_text(TTR("Path is Empty")); path_error_label->add_color_override("font_color",Color(1,0.4,0.0,0.8)); return; @@ -224,7 +224,7 @@ void ScriptCreateDialog::_path_changed(const String& p_path) { p = Globals::get_singleton()->localize_path(p); if (!p.begins_with("res://")) { - path_error_label->set_text("Path is not local"); + path_error_label->set_text(TTR("Path is not local")); path_error_label->add_color_override("font_color",Color(1,0.4,0.0,0.8)); return; } @@ -234,7 +234,7 @@ void ScriptCreateDialog::_path_changed(const String& p_path) { if (d->change_dir(p.get_base_dir())!=OK) { - path_error_label->set_text("Base Path Invalid"); + path_error_label->set_text(TTR("Base Path Invalid")); path_error_label->add_color_override("font_color",Color(1,0.4,0.0,0.8)); memdelete(d); return; @@ -249,7 +249,7 @@ void ScriptCreateDialog::_path_changed(const String& p_path) { if (f->file_exists(p)) { - path_error_label->set_text("File Exists"); + path_error_label->set_text(TTR("File Exists")); path_error_label->add_color_override("font_color",Color(1,0.4,0.0,0.8)); memdelete(f); return; @@ -273,13 +273,13 @@ void ScriptCreateDialog::_path_changed(const String& p_path) { if (!found) { - path_error_label->set_text("Invalid Extension"); + path_error_label->set_text(TTR("Invalid Extension")); path_error_label->add_color_override("font_color",Color(1,0.4,0.0,0.8)); return; } - path_error_label->set_text("Path is Valid"); + path_error_label->set_text(TTR("Path is Valid")); path_error_label->add_color_override("font_color",Color(0,1.0,0.8,0.8)); path_valid=true; @@ -315,14 +315,14 @@ ScriptCreateDialog::ScriptCreateDialog() { error_label->set_text("valid chars: a-z A-Z 0-9 _"); error_label->set_align(Label::ALIGN_CENTER); vb2->add_child(error_label); - vb->add_margin_child("Class Name:",vb2); + vb->add_margin_child(TTR("Class Name:"),vb2); parent_name = memnew( LineEdit ); - vb->add_margin_child("Inherits:",parent_name); + vb->add_margin_child(TTR("Inherits:"),parent_name); parent_name->connect("text_changed", this,"_class_name_changed"); language_menu = memnew( OptionButton ); - vb->add_margin_child("Language",language_menu); + vb->add_margin_child(TTR("Language"),language_menu); for(int i=0;i<ScriptServer::get_language_count();i++) { @@ -350,25 +350,25 @@ ScriptCreateDialog::ScriptCreateDialog() { path_vb->add_child(hbc); path_error_label = memnew( Label ); path_vb->add_child( path_error_label ); - path_error_label->set_text("Error!"); + path_error_label->set_text(TTR("Error!")); path_error_label->set_align(Label::ALIGN_CENTER); internal = memnew( CheckButton ); - internal->set_text("Built-In Script"); + internal->set_text(TTR("Built-In Script")); vb2->add_child(internal); internal->connect("pressed",this,"_built_in_pressed"); - vb->add_margin_child("Path:",vb2); + vb->add_margin_child(TTR("Path:"),vb2); set_size(Size2(200,150)); set_hide_on_ok(false); - set_title("Create Script for Node"); + set_title(TTR("Create Script for Node")); file_browse = memnew( EditorFileDialog ); file_browse->connect("file_selected",this,"_file_selected"); add_child(file_browse); - get_ok()->set_text("Create"); + get_ok()->set_text(TTR("Create")); alert = memnew( AcceptDialog ); add_child(alert); _lang_changed(0); diff --git a/tools/editor/script_editor_debugger.cpp b/tools/editor/script_editor_debugger.cpp index 90d162c708..325eadc1e5 100644 --- a/tools/editor/script_editor_debugger.cpp +++ b/tools/editor/script_editor_debugger.cpp @@ -279,7 +279,7 @@ void ScriptEditorDebugger::_parse_message(const String& p_msg,const Array& p_dat it->set_icon(0,get_icon(type,"EditorIcons")); } - vmem_total->set_tooltip("Bytes: "+itos(total)); + vmem_total->set_tooltip(TTR("Bytes: ")+itos(total)); vmem_total->set_text(String::humanize_size(total)); } else if (p_msg=="stack_dump") { @@ -399,7 +399,7 @@ void ScriptEditorDebugger::_parse_message(const String& p_msg,const Array& p_dat String time = String("%d:%02d:%02d:%04d").sprintf(vals,&e); String txt=time+" - "+String(err[8]); - String tooltip="Type:"+String(warning?"Warning":"Error"); + String tooltip=TTR("Type:")+String(warning?"Warning":"Error"); tooltip+="\nDescription: "+String(err[8]); tooltip+="\nTime: "+time; tooltip+="\nC Error: "+String(err[7]); @@ -553,13 +553,13 @@ void ScriptEditorDebugger::_notification(int p_what) { if (error_count!=last_error_count) { if (error_count==0) { - error_split->set_name("Errors"); - debugger_button->set_text("Debugger"); + error_split->set_name(TTR("Errors")); + debugger_button->set_text(TTR("Debugger")); debugger_button->set_icon(Ref<Texture>()); tabs->set_tab_icon(error_split->get_index(),Ref<Texture>()); } else { - error_split->set_name("Errors ("+itos(error_count)+")"); - debugger_button->set_text("Debugger ("+itos(error_count)+")"); + error_split->set_name(TTR("Errors (")+itos(error_count)+")"); + debugger_button->set_text(TTR("Debugger (")+itos(error_count)+")"); debugger_button->set_icon(get_icon("Error","EditorIcons")); tabs->set_tab_icon(error_split->get_index(),get_icon("Error","EditorIcons")); } @@ -584,8 +584,8 @@ void ScriptEditorDebugger::_notification(int p_what) { dobreak->set_disabled(false); tabs->set_current_tab(0); - reason->set_text("Child Process Connected"); - reason->set_tooltip("Child Process Connected"); + reason->set_text(TTR("Child Process Connected")); + reason->set_tooltip(TTR("Child Process Connected")); scene_tree->clear(); le_set->set_disabled(true); le_clear->set_disabled(false); @@ -1151,7 +1151,7 @@ void ScriptEditorDebugger::_error_selected(int p_idx) { error_stack->add_item(str); error_stack->set_item_metadata(error_stack->get_item_count()-1,md); - error_stack->set_item_tooltip(error_stack->get_item_count()-1,"File: "+String(st[i])+"\nLine: "+itos(line)); + error_stack->set_item_tooltip(error_stack->get_item_count()-1,TTR("File: ")+String(st[i])+"\nLine: "+itos(line)); } } @@ -1217,7 +1217,7 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor){ VBoxContainer *vbc = memnew( VBoxContainer ); - vbc->set_name("Debugger"); + vbc->set_name(TTR("Debugger")); //tabs->add_child(vbc); Control *dbg=vbc; @@ -1237,35 +1237,35 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor){ step = memnew( Button ); hbc->add_child(step); - step->set_tooltip("Step Into"); + step->set_tooltip(TTR("Step Into")); step->connect("pressed",this,"debug_step"); next = memnew( Button ); hbc->add_child(next); - next->set_tooltip("Step Over"); + next->set_tooltip(TTR("Step Over")); next->connect("pressed",this,"debug_next"); hbc->add_child( memnew( VSeparator) ); dobreak = memnew( Button ); hbc->add_child(dobreak); - dobreak->set_tooltip("Break"); + dobreak->set_tooltip(TTR("Break")); dobreak->connect("pressed",this,"debug_break"); docontinue = memnew( Button ); hbc->add_child(docontinue); - docontinue->set_tooltip("Continue"); + docontinue->set_tooltip(TTR("Continue")); docontinue->connect("pressed",this,"debug_continue"); hbc->add_child( memnew( VSeparator) ); back = memnew( Button ); hbc->add_child(back); - back->set_tooltip("Inspect Previous Instance"); + back->set_tooltip(TTR("Inspect Previous Instance")); forward = memnew( Button ); hbc->add_child(forward); - back->set_tooltip("Inspect Next Instance"); + back->set_tooltip(TTR("Inspect Next Instance")); HSplitContainer *sc = memnew( HSplitContainer ); @@ -1275,7 +1275,7 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor){ stack_dump = memnew( Tree ); stack_dump->set_columns(1); stack_dump->set_column_titles_visible(true); - stack_dump->set_column_title(0,"Stack Frames"); + stack_dump->set_column_title(0,TTR("Stack Frames")); stack_dump->set_h_size_flags(SIZE_EXPAND_FILL); stack_dump->set_hide_root(true); stack_dump->connect("cell_selected",this,"_stack_dump_frame_selected"); @@ -1284,7 +1284,7 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor){ inspector = memnew( PropertyEditor ); inspector->set_h_size_flags(SIZE_EXPAND_FILL); inspector->hide_top_label(); - inspector->get_scene_tree()->set_column_title(0,"Variable"); + inspector->get_scene_tree()->set_column_title(0,TTR("Variable")); inspector->set_capitalize_paths(false); inspector->set_read_only(true); sc->add_child(inspector); @@ -1308,16 +1308,16 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor){ VBoxContainer *errvb = memnew( VBoxContainer ); errvb->set_h_size_flags(SIZE_EXPAND_FILL); error_list = memnew( ItemList ); - errvb->add_margin_child("Errors:",error_list,true); + errvb->add_margin_child(TTR("Errors:"),error_list,true); error_split->add_child(errvb); errvb = memnew( VBoxContainer ); errvb->set_h_size_flags(SIZE_EXPAND_FILL); error_stack = memnew( ItemList ); - errvb->add_margin_child("Stack Trace (if applies):",error_stack,true); + errvb->add_margin_child(TTR("Stack Trace (if applies):"),error_stack,true); error_split->add_child(errvb); - error_split->set_name("Errors"); + error_split->set_name(TTR("Errors")); tabs->add_child(error_split); @@ -1325,8 +1325,8 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor){ perf_monitors = memnew(Tree); perf_monitors->set_columns(2); - perf_monitors->set_column_title(0,"Monitor"); - perf_monitors->set_column_title(1,"Value"); + perf_monitors->set_column_title(0,TTR("Monitor")); + perf_monitors->set_column_title(1,TTR("Value")); perf_monitors->set_column_titles_visible(true); hsp->add_child(perf_monitors); perf_monitors->set_select_mode(Tree::SELECT_MULTI); @@ -1366,10 +1366,10 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor){ VBoxContainer *vmem_vb = memnew( VBoxContainer ); HBoxContainer *vmem_hb = memnew( HBoxContainer ); - Label *vmlb = memnew(Label("List of Video Memory Usage by Resource: ") ); + Label *vmlb = memnew(Label(TTR("List of Video Memory Usage by Resource: ")) ); vmlb->set_h_size_flags(SIZE_EXPAND_FILL); vmem_hb->add_child( vmlb ); - vmem_hb->add_child( memnew(Label("Total: ")) ); + vmem_hb->add_child( memnew(Label(TTR("Total: "))) ); vmem_total = memnew( LineEdit ); vmem_total->set_editable(false); vmem_total->set_custom_minimum_size(Size2(100,1)); @@ -1387,46 +1387,46 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor){ vmmc->set_v_size_flags(SIZE_EXPAND_FILL); vmem_vb->add_child(vmmc); - vmem_vb->set_name("Video Mem"); + vmem_vb->set_name(TTR("Video Mem")); vmem_tree->set_columns(4); vmem_tree->set_column_titles_visible(true); - vmem_tree->set_column_title(0,"Resource Path"); + vmem_tree->set_column_title(0,TTR("Resource Path")); vmem_tree->set_column_expand(0,true); vmem_tree->set_column_expand(1,false); - vmem_tree->set_column_title(1,"Type"); + vmem_tree->set_column_title(1,TTR("Type")); vmem_tree->set_column_min_width(1,100); vmem_tree->set_column_expand(2,false); - vmem_tree->set_column_title(2,"Format"); + vmem_tree->set_column_title(2,TTR("Format")); vmem_tree->set_column_min_width(2,150); vmem_tree->set_column_expand(3,false); - vmem_tree->set_column_title(3,"Usage"); + vmem_tree->set_column_title(3,TTR("Usage")); vmem_tree->set_column_min_width(3,80); vmem_tree->set_hide_root(true); tabs->add_child(vmem_vb); info = memnew( HSplitContainer ); - info->set_name("Info"); + info->set_name(TTR("Info")); tabs->add_child(info); VBoxContainer *info_left = memnew( VBoxContainer ); info_left->set_h_size_flags(SIZE_EXPAND_FILL); info->add_child(info_left); clicked_ctrl = memnew( LineEdit ); - info_left->add_margin_child("Clicked Control:",clicked_ctrl); + info_left->add_margin_child(TTR("Clicked Control:"),clicked_ctrl); clicked_ctrl_type = memnew( LineEdit ); - info_left->add_margin_child("Clicked Control Type:",clicked_ctrl_type); + info_left->add_margin_child(TTR("Clicked Control Type:"),clicked_ctrl_type); live_edit_root = memnew( LineEdit ); { HBoxContainer *lehb = memnew( HBoxContainer ); - Label *l = memnew( Label("Live Edit Root:") ); + Label *l = memnew( Label(TTR("Live Edit Root:")) ); lehb->add_child(l); l->set_h_size_flags(SIZE_EXPAND_FILL); - le_set = memnew( Button("Set From Tree") ); + le_set = memnew( Button(TTR("Set From Tree")) ); lehb->add_child(le_set); - le_clear = memnew( Button("Clear") ); + le_clear = memnew( Button(TTR("Clear")) ); lehb->add_child(le_clear); info_left->add_child(lehb); MarginContainer *mc = memnew( MarginContainer ); @@ -1441,7 +1441,7 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor){ info->add_child(info_right); HBoxContainer *inforhb = memnew( HBoxContainer ); info_right->add_child(inforhb); - Label *l2 = memnew( Label("Scene Tree:" ) ); + Label *l2 = memnew( Label(TTR("Scene Tree:") ) ); l2->set_h_size_flags(SIZE_EXPAND_FILL); inforhb->add_child( l2 ); Button *refresh = memnew( Button ); diff --git a/tools/editor/settings_config_dialog.cpp b/tools/editor/settings_config_dialog.cpp index 6b7c2eb9b7..2a871efb18 100644 --- a/tools/editor/settings_config_dialog.cpp +++ b/tools/editor/settings_config_dialog.cpp @@ -107,7 +107,7 @@ void EditorSettingsDialog::_bind_methods() { EditorSettingsDialog::EditorSettingsDialog() { - set_title("Editor Settings"); + set_title(TTR("Editor Settings")); tabs = memnew( TabContainer ); add_child(tabs); @@ -115,14 +115,14 @@ EditorSettingsDialog::EditorSettingsDialog() { VBoxContainer *vbc = memnew( VBoxContainer ); tabs->add_child(vbc); - vbc->set_name("General"); + vbc->set_name(TTR("General")); HBoxContainer *hbc = memnew( HBoxContainer ); hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL); vbc->add_child(hbc); Label *l = memnew( Label ); - l->set_text("Search: "); + l->set_text(TTR("Search: ")); hbc->add_child(l); search_box = memnew( LineEdit ); @@ -142,20 +142,20 @@ EditorSettingsDialog::EditorSettingsDialog() { vbc = memnew( VBoxContainer ); tabs->add_child(vbc); - vbc->set_name("Plugins"); + vbc->set_name(TTR("Plugins")); hbc = memnew( HBoxContainer ); vbc->add_child(hbc); - hbc->add_child( memnew( Label("Plugin List: "))); + hbc->add_child( memnew( Label(TTR("Plugin List: ")))); hbc->add_spacer(); //Button *load = memnew( Button ); - //load->set_text("Load.."); + //load->set_text(TTR("Load..")); //hbc->add_child(load); - //get_ok()->set_text("Apply"); + //get_ok()->set_text(TTR("Apply")); set_hide_on_ok(true); - //get_cancel()->set_text("Close"); + //get_cancel()->set_text(TTR("Close")); timer = memnew( Timer ); timer->set_wait_time(1.5); @@ -163,7 +163,7 @@ EditorSettingsDialog::EditorSettingsDialog() { timer->set_one_shot(true); add_child(timer); EditorSettings::get_singleton()->connect("settings_changed",this,"_settings_changed"); - get_ok()->set_text("Close"); + get_ok()->set_text(TTR("Close")); updating=false; diff --git a/tools/editor/spatial_editor_gizmos.cpp b/tools/editor/spatial_editor_gizmos.cpp index 3414e80482..b7fc722113 100644 --- a/tools/editor/spatial_editor_gizmos.cpp +++ b/tools/editor/spatial_editor_gizmos.cpp @@ -731,9 +731,9 @@ Vector3 EditorSpatialGizmo::get_handle_pos(int p_idx) const { String LightSpatialGizmo::get_handle_name(int p_idx) const { if (p_idx==0) - return "Radius"; + return TTR("Radius"); else - return "Aperture"; + return TTR("Aperture"); } @@ -830,14 +830,14 @@ void LightSpatialGizmo::commit_handle(int p_idx,const Variant& p_restore,bool p_ } else if (p_idx==0) { UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo(); - ur->create_action("Change Light Radius"); + ur->create_action(TTR("Change Light Radius")); ur->add_do_method(light,"set_parameter",Light::PARAM_RADIUS,light->get_parameter(Light::PARAM_RADIUS)); ur->add_undo_method(light,"set_parameter",Light::PARAM_RADIUS,p_restore); ur->commit_action(); } else if (p_idx==1) { UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo(); - ur->create_action("Change Light Radius"); + ur->create_action(TTR("Change Light Radius")); ur->add_do_method(light,"set_parameter",Light::PARAM_SPOT_ANGLE,light->get_parameter(Light::PARAM_SPOT_ANGLE)); ur->add_undo_method(light,"set_parameter",Light::PARAM_SPOT_ANGLE,p_restore); ur->commit_action(); @@ -1030,9 +1030,9 @@ LightSpatialGizmo::LightSpatialGizmo(Light* p_light){ String CameraSpatialGizmo::get_handle_name(int p_idx) const { if (camera->get_projection()==Camera::PROJECTION_PERSPECTIVE) { - return "FOV"; + return TTR("FOV"); } else { - return "Size"; + return TTR("Size"); } } Variant CameraSpatialGizmo::get_handle_value(int p_idx) const{ @@ -1080,7 +1080,7 @@ void CameraSpatialGizmo::commit_handle(int p_idx,const Variant& p_restore,bool p camera->set("fov",p_restore); } else { UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo(); - ur->create_action("Change Camera FOV"); + ur->create_action(TTR("Change Camera FOV")); ur->add_do_property(camera,"fov",camera->get_fov()); ur->add_undo_property(camera,"fov",p_restore); ur->commit_action(); @@ -1093,7 +1093,7 @@ void CameraSpatialGizmo::commit_handle(int p_idx,const Variant& p_restore,bool p camera->set("size",p_restore); } else { UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo(); - ur->create_action("Change Camera Size"); + ur->create_action(TTR("Change Camera Size")); ur->add_do_property(camera,"size",camera->get_size()); ur->add_undo_property(camera,"size",p_restore); ur->commit_action(); @@ -1695,22 +1695,22 @@ String CollisionShapeSpatialGizmo::get_handle_name(int p_idx) const { if (s->cast_to<SphereShape>()) { - return "Radius"; + return TTR("Radius"); } if (s->cast_to<BoxShape>()) { - return "Extents"; + return TTR("Extents"); } if (s->cast_to<CapsuleShape>()) { - return p_idx==0?"Radius":"Height"; + return p_idx==0?TTR("Radius"):"Height"; } if (s->cast_to<RayShape>()) { - return "Length"; + return TTR("Length"); } return ""; @@ -1838,7 +1838,7 @@ void CollisionShapeSpatialGizmo::commit_handle(int p_idx,const Variant& p_restor } UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo(); - ur->create_action("Change Sphere Shape Radius"); + ur->create_action(TTR("Change Sphere Shape Radius")); ur->add_do_method(ss.ptr(),"set_radius",ss->get_radius()); ur->add_undo_method(ss.ptr(),"set_radius",p_restore); ur->commit_action(); @@ -1854,7 +1854,7 @@ void CollisionShapeSpatialGizmo::commit_handle(int p_idx,const Variant& p_restor } UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo(); - ur->create_action("Change Box Shape Extents"); + ur->create_action(TTR("Change Box Shape Extents")); ur->add_do_method(ss.ptr(),"set_extents",ss->get_extents()); ur->add_undo_method(ss.ptr(),"set_extents",p_restore); ur->commit_action(); @@ -1873,11 +1873,11 @@ void CollisionShapeSpatialGizmo::commit_handle(int p_idx,const Variant& p_restor UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo(); if (p_idx==0) { - ur->create_action("Change Capsule Shape Radius"); + ur->create_action(TTR("Change Capsule Shape Radius")); ur->add_do_method(ss.ptr(),"set_radius",ss->get_radius()); ur->add_undo_method(ss.ptr(),"set_radius",p_restore); } else { - ur->create_action("Change Capsule Shape Height"); + ur->create_action(TTR("Change Capsule Shape Height")); ur->add_do_method(ss.ptr(),"set_height",ss->get_height()); ur->add_undo_method(ss.ptr(),"set_height",p_restore); @@ -1896,7 +1896,7 @@ void CollisionShapeSpatialGizmo::commit_handle(int p_idx,const Variant& p_restor } UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo(); - ur->create_action("Change Ray Shape Length"); + ur->create_action(TTR("Change Ray Shape Length")); ur->add_do_method(ss.ptr(),"set_length",ss->get_length()); ur->add_undo_method(ss.ptr(),"set_length",p_restore); ur->commit_action(); @@ -2243,7 +2243,7 @@ void VisibilityNotifierGizmo::commit_handle(int p_idx,const Variant& p_restore,b } UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo(); - ur->create_action("Change Notifier Extents"); + ur->create_action(TTR("Change Notifier Extents")); ur->add_do_method(notifier,"set_aabb",notifier->get_aabb()); ur->add_undo_method(notifier,"set_aabb",p_restore); ur->commit_action(); |