diff options
107 files changed, 9369 insertions, 12955 deletions
diff --git a/COPYRIGHT.txt b/COPYRIGHT.txt index 46dff251aa..7b212485ba 100644 --- a/COPYRIGHT.txt +++ b/COPYRIGHT.txt @@ -266,7 +266,7 @@ Copyright: lieff License: CC0-1.0 Files: ./thirdparty/miniupnpc/ -Comment: MiniUPnPc +Comment: MiniUPnP Project Copyright: 2005-2021, Thomas Bernard License: BSD-3-clause @@ -369,8 +369,8 @@ License: Apache-2.0 Files: ./thirdparty/pcre2/ Comment: PCRE2 -Copyright: 1997-2020, University of Cambridge - 2009-2020, Zoltan Herczeg +Copyright: 1997-2021, University of Cambridge + 2009-2021, Zoltan Herczeg License: BSD-3-clause Files: ./thirdparty/pvrtccompressor/ @@ -400,7 +400,7 @@ License: Expat Files: ./thirdparty/tinyexr/ Comment: TinyEXR -Copyright: 2014-2020, Syoyo Fujita +Copyright: 2014-2021, Syoyo Fujita 2002, Industrial Light & Magic, a division of Lucas Digital Ltd. LLC License: BSD-3-clause diff --git a/SConstruct b/SConstruct index fea0e0ab28..f7d589e799 100644 --- a/SConstruct +++ b/SConstruct @@ -16,7 +16,6 @@ from collections import OrderedDict import methods import glsl_builders import gles3_builders -from platform_methods import run_in_subprocess # Scan possible build platforms @@ -706,20 +705,14 @@ if selected_platform in platform_list: suffix="glsl.gen.h", src_suffix=".glsl", ), + "GLES3_GLSL": env.Builder( + action=env.Run(gles3_builders.build_gles3_headers, 'Building GLES3 GLSL header: "$TARGET"'), + suffix="glsl.gen.h", + src_suffix=".glsl", + ), } env.Append(BUILDERS=GLSL_BUILDERS) - if not env["platform"] == "server": - env.Append( - BUILDERS={ - "GLES3_GLSL": env.Builder( - action=run_in_subprocess(gles3_builders.build_gles3_headers), - suffix="glsl.gen.h", - src_suffix=".glsl", - ) - } - ) - scons_cache_path = os.environ.get("SCONS_CACHE") if scons_cache_path != None: CacheDir(scons_cache_path) diff --git a/core/os/os.h b/core/os/os.h index abfa7ac993..3042696cce 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -243,7 +243,7 @@ public: void set_stdout_enabled(bool p_enabled); void set_stderr_enabled(bool p_enabled); - bool is_single_window() const; + virtual bool is_single_window() const; virtual void disable_crash_handler() {} virtual bool is_disable_crash_handler() const { return false; } diff --git a/drivers/SCsub b/drivers/SCsub index 714d4110de..dd81fc645c 100644 --- a/drivers/SCsub +++ b/drivers/SCsub @@ -25,10 +25,9 @@ SConscript("winmidi/SCsub") # Graphics drivers if env["vulkan"]: SConscript("vulkan/SCsub") - SConscript("gles3/SCsub") +if env["opengl3"]: SConscript("gl_context/SCsub") -else: - SConscript("dummy/SCsub") + SConscript("gles3/SCsub") # Core dependencies SConscript("png/SCsub") diff --git a/drivers/gles3/rasterizer_gles3.cpp b/drivers/gles3/rasterizer_gles3.cpp index 10093d42a3..92c9dfb9ae 100644 --- a/drivers/gles3/rasterizer_gles3.cpp +++ b/drivers/gles3/rasterizer_gles3.cpp @@ -68,7 +68,7 @@ #endif #endif -#ifndef IPHONE_ENABLED +#if !defined(IPHONE_ENABLED) && !defined(JAVASCRIPT_ENABLED) // We include EGL below to get debug callback on GLES2 platforms, // but EGL is not available on iOS. #define CAN_DEBUG diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index ab3479b7ce..a25b694a60 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -1237,7 +1237,7 @@ void ResourceImporterScene::get_internal_import_options(InternalImportCategory p r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "use_external/path", PROPERTY_HINT_FILE, "*.material,*.res,*.tres"), "")); } break; case INTERNAL_IMPORT_CATEGORY_ANIMATION: { - r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "settings/loop_mode"), 0)); + r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "settings/loop_mode", PROPERTY_HINT_ENUM, "None,Linear,Pingpong"), 0)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "save_to_file/enabled", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), false)); r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "save_to_file/path", PROPERTY_HINT_SAVE_FILE, "*.res,*.tres"), "")); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "save_to_file/keep_custom_tracks"), "")); @@ -1259,7 +1259,7 @@ void ResourceImporterScene::get_internal_import_options(InternalImportCategory p r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "slice_" + itos(i + 1) + "/name"), "")); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "slice_" + itos(i + 1) + "/start_frame"), 0)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "slice_" + itos(i + 1) + "/end_frame"), 0)); - r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "slice_" + itos(i + 1) + "/loop_mode"), 0)); + r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "slice_" + itos(i + 1) + "/loop_mode", PROPERTY_HINT_ENUM, "None,Linear,Pingpong"), 0)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "slice_" + itos(i + 1) + "/save_to_file/enabled", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), false)); r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "slice_" + itos(i + 1) + "/save_to_file/path", PROPERTY_HINT_SAVE_FILE, ".res,*.tres"), "")); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "slice_" + itos(i + 1) + "/save_to_file/keep_custom_tracks"), false)); diff --git a/misc/dist/html/editor.html b/misc/dist/html/editor.html index 69e267f665..8b077a5725 100644 --- a/misc/dist/html/editor.html +++ b/misc/dist/html/editor.html @@ -281,8 +281,7 @@ <label for="videoMode" style="margin-right: 1rem">Video driver:</label> <select id="videoMode"> <option value="" selected="selected">Auto</option> - <option value="GLES2">WebGL</option> - <option value="GLES3">WebGL 2</option> + <option value="opengl3">WebGL 2</option> </select> <br /> <br /> @@ -562,8 +561,9 @@ const is_project_manager = args.filter(function(v) { return v == '--project-manager' }).length != 0; const is_game = !is_editor && !is_project_manager; if (video_driver) { - args.push('--video-driver', video_driver); + args.push('--rendering-driver', video_driver); } + if (is_game) { if (game) { console.error("A game is already running. Close it first"); @@ -651,9 +651,9 @@ selectVideoMode(); showTab('editor'); setLoaderEnabled(false); - const args = ['--project-manager']; + const args = ['--project-manager', '--single-window']; if (video_driver) { - args.push('--video-driver', video_driver); + args.push('--rendering-driver', video_driver); } editor.start({'args': args, 'persistentDrops': true}).then(function() { setStatusMode('hidden'); diff --git a/modules/bullet/area_bullet.cpp b/modules/bullet/area_bullet.cpp index 0d4982baba..1c49029570 100644 --- a/modules/bullet/area_bullet.cpp +++ b/modules/bullet/area_bullet.cpp @@ -59,8 +59,8 @@ AreaBullet::AreaBullet() : AreaBullet::~AreaBullet() { // signal are handled by godot, so just clear without notify - for (int i = overlappingObjects.size() - 1; 0 <= i; --i) { - overlappingObjects[i].object->on_exit_area(this); + for (int i = 0; i < overlapping_shapes.size(); i++) { + overlapping_shapes[i].other_object->on_exit_area(this); } } @@ -70,20 +70,26 @@ void AreaBullet::dispatch_callbacks() { } isScratched = false; - // Reverse order because I've to remove EXIT objects - for (int i = overlappingObjects.size() - 1; 0 <= i; --i) { - OverlappingObjectData &otherObj = overlappingObjects.write[i]; + // Reverse order so items can be removed. + for (int i = overlapping_shapes.size() - 1; i >= 0; i--) { + OverlappingShapeData &overlapping_shape = overlapping_shapes.write[i]; - switch (otherObj.state) { + switch (overlapping_shape.state) { case OVERLAP_STATE_ENTER: - otherObj.state = OVERLAP_STATE_INSIDE; - call_event(otherObj.object, PhysicsServer3D::AREA_BODY_ADDED); - otherObj.object->on_enter_area(this); + overlapping_shape.state = OVERLAP_STATE_INSIDE; + call_event(overlapping_shape, PhysicsServer3D::AREA_BODY_ADDED); + if (_overlapping_shape_count(overlapping_shape.other_object) == 1) { + // This object's first shape being added. + overlapping_shape.other_object->on_enter_area(this); + } break; case OVERLAP_STATE_EXIT: - call_event(otherObj.object, PhysicsServer3D::AREA_BODY_REMOVED); - otherObj.object->on_exit_area(this); - overlappingObjects.remove(i); // Remove after callback + call_event(overlapping_shape, PhysicsServer3D::AREA_BODY_REMOVED); + if (_overlapping_shape_count(overlapping_shape.other_object) == 1) { + // This object's last shape being removed. + overlapping_shape.other_object->on_exit_area(this); + } + overlapping_shapes.remove(i); // Remove after callback break; case OVERLAP_STATE_INSIDE: { if (otherObj.object->getType() == TYPE_RIGID_BODY) { @@ -98,8 +104,8 @@ void AreaBullet::dispatch_callbacks() { } } -void AreaBullet::call_event(CollisionObjectBullet *p_otherObject, PhysicsServer3D::AreaBodyStatus p_status) { - InOutEventCallback &event = eventsCallbacks[static_cast<int>(p_otherObject->getType())]; +void AreaBullet::call_event(const OverlappingShapeData &p_overlapping_shape, PhysicsServer3D::AreaBodyStatus p_status) { + InOutEventCallback &event = eventsCallbacks[static_cast<int>(p_overlapping_shape.other_object->getType())]; if (!event.event_callback.is_valid()) { event.event_callback = Callable(); @@ -107,54 +113,92 @@ void AreaBullet::call_event(CollisionObjectBullet *p_otherObject, PhysicsServer3 } call_event_res[0] = p_status; - call_event_res[1] = p_otherObject->get_self(); // Other body - call_event_res[2] = p_otherObject->get_instance_id(); // instance ID - call_event_res[3] = 0; // other_body_shape ID - call_event_res[4] = 0; // self_shape ID + call_event_res[1] = p_overlapping_shape.other_object->get_self(); // RID + call_event_res[2] = p_overlapping_shape.other_object->get_instance_id(); // Object ID + call_event_res[3] = p_overlapping_shape.other_shape_id; // Other object's shape ID + call_event_res[4] = p_overlapping_shape.our_shape_id; // This area's shape ID Callable::CallError outResp; Variant ret; event.event_callback.call((const Variant **)call_event_res, 5, ret, outResp); } -void AreaBullet::scratch() { - if (isScratched) { - return; +int AreaBullet::_overlapping_shape_count(CollisionObjectBullet *p_other_object) { + int count = 0; + for (int i = 0; i < overlapping_shapes.size(); i++) { + if (overlapping_shapes[i].other_object == p_other_object) { + count++; + } } - isScratched = true; + return count; } -void AreaBullet::clear_overlaps(bool p_notify) { - for (int i = overlappingObjects.size() - 1; 0 <= i; --i) { - if (p_notify) { - call_event(overlappingObjects[i].object, PhysicsServer3D::AREA_BODY_REMOVED); +int AreaBullet::_find_overlapping_shape(CollisionObjectBullet *p_other_object, uint32_t p_other_shape_id, uint32_t p_our_shape_id) { + for (int i = 0; i < overlapping_shapes.size(); i++) { + const OverlappingShapeData &overlapping_shape = overlapping_shapes[i]; + if (overlapping_shape.other_object == p_other_object && overlapping_shape.other_shape_id == p_other_shape_id && overlapping_shape.our_shape_id == p_our_shape_id) { + return i; } - overlappingObjects[i].object->on_exit_area(this); } - overlappingObjects.clear(); + return -1; } -void AreaBullet::remove_overlap(CollisionObjectBullet *p_object, bool p_notify) { - for (int i = overlappingObjects.size() - 1; 0 <= i; --i) { - if (overlappingObjects[i].object == p_object) { - if (p_notify) { - call_event(overlappingObjects[i].object, PhysicsServer3D::AREA_BODY_REMOVED); - } - overlappingObjects[i].object->on_exit_area(this); - overlappingObjects.remove(i); - break; +void AreaBullet::mark_all_overlaps_dirty() { + OverlappingShapeData *overlapping_shapes_w = overlapping_shapes.ptrw(); + for (int i = 0; i < overlapping_shapes.size(); i++) { + // Don't overwrite OVERLAP_STATE_ENTER state. + if (overlapping_shapes_w[i].state != OVERLAP_STATE_ENTER) { + overlapping_shapes_w[i].state = OVERLAP_STATE_DIRTY; } } } -int AreaBullet::find_overlapping_object(CollisionObjectBullet *p_colObj) { - const int size = overlappingObjects.size(); - for (int i = 0; i < size; ++i) { - if (overlappingObjects[i].object == p_colObj) { - return i; +void AreaBullet::mark_object_overlaps_inside(CollisionObjectBullet *p_other_object) { + OverlappingShapeData *overlapping_shapes_w = overlapping_shapes.ptrw(); + for (int i = 0; i < overlapping_shapes.size(); i++) { + if (overlapping_shapes_w[i].other_object == p_other_object && overlapping_shapes_w[i].state == OVERLAP_STATE_DIRTY) { + overlapping_shapes_w[i].state = OVERLAP_STATE_INSIDE; + } + } +} + +void AreaBullet::set_overlap(CollisionObjectBullet *p_other_object, uint32_t p_other_shape_id, uint32_t p_our_shape_id) { + int i = _find_overlapping_shape(p_other_object, p_other_shape_id, p_our_shape_id); + if (i == -1) { // Not found, create new one. + OverlappingShapeData overlapping_shape(p_other_object, OVERLAP_STATE_ENTER, p_other_shape_id, p_our_shape_id); + overlapping_shapes.push_back(overlapping_shape); + p_other_object->notify_new_overlap(this); + isScratched = true; + } else { + overlapping_shapes.ptrw()[i].state = OVERLAP_STATE_INSIDE; + } +} + +void AreaBullet::mark_all_dirty_overlaps_as_exit() { + OverlappingShapeData *overlapping_shapes_w = overlapping_shapes.ptrw(); + for (int i = 0; i < overlapping_shapes.size(); i++) { + if (overlapping_shapes[i].state == OVERLAP_STATE_DIRTY) { + overlapping_shapes_w[i].state = OVERLAP_STATE_EXIT; + isScratched = true; + } + } +} + +void AreaBullet::remove_object_overlaps(CollisionObjectBullet *p_object) { + // Reverse order so items can be removed. + for (int i = overlapping_shapes.size() - 1; i >= 0; i--) { + if (overlapping_shapes[i].other_object == p_object) { + overlapping_shapes.remove(i); } } - return -1; +} + +void AreaBullet::clear_overlaps() { + for (int i = 0; i < overlapping_shapes.size(); i++) { + call_event(overlapping_shapes[i], PhysicsServer3D::AREA_BODY_REMOVED); + overlapping_shapes[i].other_object->on_exit_area(this); + } + overlapping_shapes.clear(); } void AreaBullet::set_monitorable(bool p_monitorable) { @@ -182,7 +226,7 @@ void AreaBullet::reload_body() { void AreaBullet::set_space(SpaceBullet *p_space) { // Clear the old space if there is one if (space) { - clear_overlaps(false); + clear_overlaps(); isScratched = false; // Remove this object form the physics world @@ -203,24 +247,6 @@ void AreaBullet::on_collision_filters_change() { updated = true; } -void AreaBullet::add_overlap(CollisionObjectBullet *p_otherObject) { - scratch(); - overlappingObjects.push_back(OverlappingObjectData(p_otherObject, OVERLAP_STATE_ENTER)); - p_otherObject->notify_new_overlap(this); -} - -void AreaBullet::put_overlap_as_exit(int p_index) { - scratch(); - overlappingObjects.write[p_index].state = OVERLAP_STATE_EXIT; -} - -void AreaBullet::put_overlap_as_inside(int p_index) { - // This check is required to be sure this body was inside - if (OVERLAP_STATE_DIRTY == overlappingObjects[p_index].state) { - overlappingObjects.write[p_index].state = OVERLAP_STATE_INSIDE; - } -} - void AreaBullet::set_param(PhysicsServer3D::AreaParameter p_param, const Variant &p_value) { switch (p_param) { case PhysicsServer3D::AREA_PARAM_GRAVITY: diff --git a/modules/bullet/area_bullet.h b/modules/bullet/area_bullet.h index 4d9227c31a..3bff364cc1 100644 --- a/modules/bullet/area_bullet.h +++ b/modules/bullet/area_bullet.h @@ -43,8 +43,6 @@ class btGhostObject; class AreaBullet : public RigidCollisionObjectBullet { - friend void SpaceBullet::check_ghost_overlaps(); - public: struct InOutEventCallback { Callable event_callback; @@ -59,21 +57,19 @@ public: OVERLAP_STATE_EXIT // Mark ended overlaps }; - struct OverlappingObjectData { - CollisionObjectBullet *object = nullptr; - OverlapState state = OVERLAP_STATE_ENTER; - - OverlappingObjectData() {} - OverlappingObjectData(CollisionObjectBullet *p_object, OverlapState p_state) : - object(p_object), - state(p_state) {} - OverlappingObjectData(const OverlappingObjectData &other) { - operator=(other); - } - void operator=(const OverlappingObjectData &other) { - object = other.object; - state = other.state; - } + struct OverlappingShapeData { + CollisionObjectBullet *other_object = nullptr; + OverlapState state = OVERLAP_STATE_DIRTY; + uint32_t other_shape_id = 0; + uint32_t our_shape_id = 0; + + OverlappingShapeData() {} + + OverlappingShapeData(CollisionObjectBullet *p_other_object, OverlapState p_state, uint32_t p_other_shape_id, uint32_t p_our_shape_id) : + other_object(p_other_object), + state(p_state), + other_shape_id(p_other_shape_id), + our_shape_id(p_our_shape_id) {} }; private: @@ -82,7 +78,9 @@ private: Variant *call_event_res_ptr[5] = {}; btGhostObject *btGhost = nullptr; - Vector<OverlappingObjectData> overlappingObjects; + Vector<OverlappingShapeData> overlapping_shapes; + int _overlapping_shape_count(CollisionObjectBullet *p_other_object); + int _find_overlapping_shape(CollisionObjectBullet *p_other_object, uint32_t p_other_shape_id, uint32_t p_our_shape_id); bool monitorable = true; PhysicsServer3D::AreaSpaceOverrideMode spOv_mode = PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED; @@ -104,7 +102,6 @@ public: ~AreaBullet(); _FORCE_INLINE_ btGhostObject *get_bt_ghost() const { return btGhost; } - int find_overlapping_object(CollisionObjectBullet *p_colObj); void set_monitorable(bool p_monitorable); _FORCE_INLINE_ bool is_monitorable() const { return monitorable; } @@ -143,20 +140,18 @@ public: virtual void set_space(SpaceBullet *p_space); virtual void dispatch_callbacks(); - void call_event(CollisionObjectBullet *p_otherObject, PhysicsServer3D::AreaBodyStatus p_status); - void scratch(); - - void clear_overlaps(bool p_notify); - // Dispatch the callbacks and removes from overlapping list - void remove_overlap(CollisionObjectBullet *p_object, bool p_notify); + void call_event(const OverlappingShapeData &p_overlapping_shape, PhysicsServer3D::AreaBodyStatus p_status); virtual void on_collision_filters_change(); virtual void on_collision_checker_start() {} virtual void on_collision_checker_end() { updated = false; } - void add_overlap(CollisionObjectBullet *p_otherObject); - void put_overlap_as_exit(int p_index); - void put_overlap_as_inside(int p_index); + void mark_all_overlaps_dirty(); + void mark_object_overlaps_inside(CollisionObjectBullet *p_other_object); + void set_overlap(CollisionObjectBullet *p_other_object, uint32_t p_other_shape_id, uint32_t p_our_shape_id); + void mark_all_dirty_overlaps_as_exit(); + void remove_object_overlaps(CollisionObjectBullet *p_object); + void clear_overlaps(); void set_param(PhysicsServer3D::AreaParameter p_param, const Variant &p_value); Variant get_param(PhysicsServer3D::AreaParameter p_param) const; diff --git a/modules/bullet/collision_object_bullet.cpp b/modules/bullet/collision_object_bullet.cpp index afd8cf4bf4..987a45ad5f 100644 --- a/modules/bullet/collision_object_bullet.cpp +++ b/modules/bullet/collision_object_bullet.cpp @@ -93,11 +93,9 @@ CollisionObjectBullet::CollisionObjectBullet(Type p_type) : type(p_type) {} CollisionObjectBullet::~CollisionObjectBullet() { - // Remove all overlapping, notify is not required since godot take care of it - for (int i = areasOverlapped.size() - 1; 0 <= i; --i) { - areasOverlapped[i]->remove_overlap(this, /*Notify*/ false); + for (int i = 0; i < areasOverlapped.size(); i++) { + areasOverlapped[i]->remove_object_overlaps(this); } - destroyBulletCollisionObject(); } @@ -178,7 +176,9 @@ bool CollisionObjectBullet::is_collisions_response_enabled() { } void CollisionObjectBullet::notify_new_overlap(AreaBullet *p_area) { - areasOverlapped.push_back(p_area); + if (areasOverlapped.find(p_area) == -1) { + areasOverlapped.push_back(p_area); + } } void CollisionObjectBullet::on_exit_area(AreaBullet *p_area) { diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp index bf47127877..7aa3815c94 100644 --- a/modules/bullet/space_bullet.cpp +++ b/modules/bullet/space_bullet.cpp @@ -662,101 +662,77 @@ void SpaceBullet::destroy_world() { } void SpaceBullet::check_ghost_overlaps() { - /// Algorithm support variables - btCollisionShape *other_body_shape; - btConvexShape *area_shape; - btGjkPairDetector::ClosestPointInput gjk_input; - AreaBullet *area; - int x(-1), i(-1), y(-1), z(-1), indexOverlap(-1); - - /// For each areas - for (x = areas.size() - 1; 0 <= x; --x) { - area = areas[x]; - - btVector3 area_scale(area->get_bt_body_scale()); - + // For each area + for (int area_idx = 0; area_idx < areas.size(); area_idx++) { + AreaBullet *area = areas[area_idx]; if (!area->is_monitoring()) { continue; } - /// 1. Reset all states - for (i = area->overlappingObjects.size() - 1; 0 <= i; --i) { - AreaBullet::OverlappingObjectData &otherObj = area->overlappingObjects.write[i]; - // This check prevent the overwrite of ENTER state - // if this function is called more times before dispatchCallbacks - if (otherObj.state != AreaBullet::OVERLAP_STATE_ENTER) { - otherObj.state = AreaBullet::OVERLAP_STATE_DIRTY; - } - } + btGhostObject *bt_ghost = area->get_bt_ghost(); + const btTransform &area_transform = area->get_transform__bullet(); + const btVector3 &area_scale(area->get_bt_body_scale()); - /// 2. Check all overlapping objects using GJK + // Mark all current overlapping shapes dirty. + area->mark_all_overlaps_dirty(); - const btAlignedObjectArray<btCollisionObject *> ghostOverlaps = area->get_bt_ghost()->getOverlappingPairs(); + // Broadphase + const btAlignedObjectArray<btCollisionObject *> overlapping_pairs = bt_ghost->getOverlappingPairs(); + // Narrowphase + for (int pair_idx = 0; pair_idx < overlapping_pairs.size(); pair_idx++) { + btCollisionObject *other_bt_collision_object = overlapping_pairs[pair_idx]; + RigidCollisionObjectBullet *other_object = static_cast<RigidCollisionObjectBullet *>(other_bt_collision_object->getUserPointer()); + const btTransform &other_transform = other_object->get_transform__bullet(); + const btVector3 &other_scale(other_object->get_bt_body_scale()); - // For each overlapping - for (i = ghostOverlaps.size() - 1; 0 <= i; --i) { - bool hasOverlap = false; - btCollisionObject *overlapped_bt_co = ghostOverlaps[i]; - RigidCollisionObjectBullet *otherObject = static_cast<RigidCollisionObjectBullet *>(overlapped_bt_co->getUserPointer()); - btVector3 other_body_scale(otherObject->get_bt_body_scale()); - - if (!area->is_updated() && !otherObject->is_updated()) { - hasOverlap = -1 != area->find_overlapping_object(otherObject); - goto collision_found; + if (!area->is_updated() && !other_object->is_updated()) { + area->mark_object_overlaps_inside(other_object); + continue; } - if (overlapped_bt_co->getUserIndex() == CollisionObjectBullet::TYPE_AREA) { - if (!static_cast<AreaBullet *>(overlapped_bt_co->getUserPointer())->is_monitorable()) { + if (other_bt_collision_object->getUserIndex() == CollisionObjectBullet::TYPE_AREA) { + if (!static_cast<AreaBullet *>(other_bt_collision_object->getUserPointer())->is_monitorable()) { continue; } - } else if (overlapped_bt_co->getUserIndex() != CollisionObjectBullet::TYPE_RIGID_BODY) { + } else if (other_bt_collision_object->getUserIndex() != CollisionObjectBullet::TYPE_RIGID_BODY) { continue; } // For each area shape - for (y = area->get_shape_count() - 1; 0 <= y; --y) { - if (!area->get_bt_shape(y)->isConvex()) { + for (int our_shape_id = 0; our_shape_id < area->get_shape_count(); our_shape_id++) { + btCollisionShape *area_shape = area->get_bt_shape(our_shape_id); + if (!area_shape->isConvex()) { continue; } + btConvexShape *area_convex_shape = static_cast<btConvexShape *>(area_shape); - btTransform area_shape_treansform(area->get_bt_shape_transform(y)); - area_shape_treansform.getOrigin() *= area_scale; - - gjk_input.m_transformA = - area->get_transform__bullet() * - area_shape_treansform; - - area_shape = static_cast<btConvexShape *>(area->get_bt_shape(y)); + btTransform area_shape_transform(area->get_bt_shape_transform(our_shape_id)); + area_shape_transform.getOrigin() *= area_scale; + btGjkPairDetector::ClosestPointInput gjk_input; + gjk_input.m_transformA = area_transform * area_shape_transform; // For each other object shape - for (z = otherObject->get_shape_count() - 1; 0 <= z; --z) { - other_body_shape = static_cast<btCollisionShape *>(otherObject->get_bt_shape(z)); - - btTransform other_shape_transform(otherObject->get_bt_shape_transform(z)); - other_shape_transform.getOrigin() *= other_body_scale; - - gjk_input.m_transformB = - otherObject->get_transform__bullet() * - other_shape_transform; + for (int other_shape_id = 0; other_shape_id < other_object->get_shape_count(); other_shape_id++) { + btCollisionShape *other_shape = other_object->get_bt_shape(other_shape_id); + btTransform other_shape_transform(other_object->get_bt_shape_transform(other_shape_id)); + other_shape_transform.getOrigin() *= other_scale; + gjk_input.m_transformB = other_transform * other_shape_transform; - if (other_body_shape->isConvex()) { + if (other_shape->isConvex()) { btPointCollector result; btGjkPairDetector gjk_pair_detector( - area_shape, - static_cast<btConvexShape *>(other_body_shape), + area_convex_shape, + static_cast<btConvexShape *>(other_shape), gjk_simplex_solver, gjk_epa_pen_solver); - gjk_pair_detector.getClosestPoints(gjk_input, result, nullptr); - if (0 >= result.m_distance) { - hasOverlap = true; - goto collision_found; + gjk_pair_detector.getClosestPoints(gjk_input, result, nullptr); + if (result.m_distance <= 0) { + area->set_overlap(other_object, other_shape_id, our_shape_id); } - - } else { - btCollisionObjectWrapper obA(nullptr, area_shape, area->get_bt_ghost(), gjk_input.m_transformA, -1, y); - btCollisionObjectWrapper obB(nullptr, other_body_shape, otherObject->get_bt_collision_object(), gjk_input.m_transformB, -1, z); - + } else { // Other shape is not convex. + btCollisionObjectWrapper obA(nullptr, area_convex_shape, bt_ghost, gjk_input.m_transformA, -1, our_shape_id); + btCollisionObjectWrapper obB(nullptr, other_shape, other_bt_collision_object, gjk_input.m_transformB, -1, other_shape_id); btCollisionAlgorithm *algorithm = dispatcher->findAlgorithm(&obA, &obB, nullptr, BT_CONTACT_POINT_ALGORITHMS); if (!algorithm) { @@ -765,42 +741,20 @@ void SpaceBullet::check_ghost_overlaps() { GodotDeepPenetrationContactResultCallback contactPointResult(&obA, &obB); algorithm->processCollision(&obA, &obB, dynamicsWorld->getDispatchInfo(), &contactPointResult); - algorithm->~btCollisionAlgorithm(); dispatcher->freeCollisionAlgorithm(algorithm); if (contactPointResult.hasHit()) { - hasOverlap = true; - goto collision_found; + area->set_overlap(other_object, our_shape_id, other_shape_id); } } + } // End for each other object shape + } // End for each area shape + } // End for each overlapping pair - } // ~For each other object shape - } // ~For each area shape - - collision_found: - if (!hasOverlap) { - continue; - } - - indexOverlap = area->find_overlapping_object(otherObject); - if (-1 == indexOverlap) { - // Not found - area->add_overlap(otherObject); - } else { - // Found - area->put_overlap_as_inside(indexOverlap); - } - } - - /// 3. Remove not overlapping - for (i = area->overlappingObjects.size() - 1; 0 <= i; --i) { - // If the overlap has DIRTY state it means that it's no more overlapping - if (area->overlappingObjects[i].state == AreaBullet::OVERLAP_STATE_DIRTY) { - area->put_overlap_as_exit(i); - } - } - } + // All overlapping shapes still marked dirty must have exited. + area->mark_all_dirty_overlaps_as_exit(); + } // End for each area } void SpaceBullet::check_body_collision() { diff --git a/modules/tinyexr/SCsub b/modules/tinyexr/SCsub index 30bde96fb4..bf9242cc16 100644 --- a/modules/tinyexr/SCsub +++ b/modules/tinyexr/SCsub @@ -20,6 +20,9 @@ env_tinyexr.Prepend(CPPPATH=[thirdparty_dir]) # Enable threaded loading with C++11. env_tinyexr.Append(CPPDEFINES=["TINYEXR_USE_THREAD"]) +# miniz is an external dependency, we could add it but we can instead rely +# on our existing bundled zlib. +env_tinyexr.Append(CPPDEFINES=[("TINYEXR_USE_MINIZ", 0)]) env_thirdparty = env_tinyexr.Clone() env_thirdparty.disable_warnings() diff --git a/modules/tinyexr/image_loader_tinyexr.cpp b/modules/tinyexr/image_loader_tinyexr.cpp index eb7a8597e6..6c4c06aab0 100644 --- a/modules/tinyexr/image_loader_tinyexr.cpp +++ b/modules/tinyexr/image_loader_tinyexr.cpp @@ -33,6 +33,8 @@ #include "core/os/os.h" #include "core/string/print_string.h" +#include <zlib.h> // Should come before including tinyexr. + #include "thirdparty/tinyexr/tinyexr.h" Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale) { diff --git a/modules/tinyexr/image_saver_tinyexr.cpp b/modules/tinyexr/image_saver_tinyexr.cpp index 6a2fb0f666..f64acf8395 100644 --- a/modules/tinyexr/image_saver_tinyexr.cpp +++ b/modules/tinyexr/image_saver_tinyexr.cpp @@ -31,6 +31,8 @@ #include "image_saver_tinyexr.h" #include "core/math/math_funcs.h" +#include <zlib.h> // Should come before including tinyexr. + #include "thirdparty/tinyexr/tinyexr.h" static bool is_supported_format(Image::Format p_format) { diff --git a/modules/upnp/SCsub b/modules/upnp/SCsub index b2fed0cb23..4b385b820d 100644 --- a/modules/upnp/SCsub +++ b/modules/upnp/SCsub @@ -26,9 +26,9 @@ if env["builtin_miniupnpc"]: "receivedata.c", "addr_is_reserved.c", ] - thirdparty_sources = [thirdparty_dir + "miniupnpc/" + file for file in thirdparty_sources] + thirdparty_sources = [thirdparty_dir + "src/" + file for file in thirdparty_sources] - env_upnp.Prepend(CPPPATH=[thirdparty_dir]) + env_upnp.Prepend(CPPPATH=[thirdparty_dir + "include"]) env_upnp.Append(CPPDEFINES=["MINIUPNP_STATICLIB"]) env_upnp.Append(CPPDEFINES=["MINIUPNPC_SET_SOCKET_TIMEOUT"]) diff --git a/modules/upnp/upnp.cpp b/modules/upnp/upnp.cpp index 0e51822b01..88d92b0083 100644 --- a/modules/upnp/upnp.cpp +++ b/modules/upnp/upnp.cpp @@ -30,8 +30,8 @@ #include "upnp.h" -#include <miniupnpc/miniwget.h> -#include <miniupnpc/upnpcommands.h> +#include <miniwget.h> +#include <upnpcommands.h> #include <stdlib.h> diff --git a/modules/upnp/upnp.h b/modules/upnp/upnp.h index b961a9667f..67df187f8c 100644 --- a/modules/upnp/upnp.h +++ b/modules/upnp/upnp.h @@ -35,7 +35,7 @@ #include "upnp_device.h" -#include <miniupnpc/miniupnpc.h> +#include <miniupnpc.h> class UPNP : public RefCounted { GDCLASS(UPNP, RefCounted); diff --git a/modules/upnp/upnp_device.cpp b/modules/upnp/upnp_device.cpp index ddc66d593c..692a0f3509 100644 --- a/modules/upnp/upnp_device.cpp +++ b/modules/upnp/upnp_device.cpp @@ -32,7 +32,7 @@ #include "upnp.h" -#include <miniupnpc/upnpcommands.h> +#include <upnpcommands.h> String UPNPDevice::query_external_address() const { ERR_FAIL_COND_V_MSG(!is_valid_gateway(), "", "The Internet Gateway Device must be valid."); diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py index 891ae419bd..b57f3b3f16 100644 --- a/platform/javascript/detect.py +++ b/platform/javascript/detect.py @@ -180,6 +180,13 @@ def configure(env): env.Prepend(CPPPATH=["#platform/javascript"]) env.Append(CPPDEFINES=["JAVASCRIPT_ENABLED", "UNIX_ENABLED"]) + if env["opengl3"]: + env.AppendUnique(CPPDEFINES=["GLES3_ENABLED"]) + # This setting just makes WebGL 2 APIs available, it does NOT disable WebGL 1. + env.Append(LINKFLAGS=["-s", "USE_WEBGL2=1"]) + # Allow use to take control of swapping WebGL buffers. + env.Append(LINKFLAGS=["-s", "OFFSCREEN_FRAMEBUFFER=1"]) + if env["javascript_eval"]: env.Append(CPPDEFINES=["JAVASCRIPT_EVAL_ENABLED"]) @@ -218,25 +225,11 @@ def configure(env): # us since we don't know requirements at compile-time. env.Append(LINKFLAGS=["-s", "ALLOW_MEMORY_GROWTH=1"]) - # This setting just makes WebGL 2 APIs available, it does NOT disable WebGL 1. - env.Append(LINKFLAGS=["-s", "USE_WEBGL2=1"]) - # Do not call main immediately when the support code is ready. env.Append(LINKFLAGS=["-s", "INVOKE_RUN=0"]) - # Allow use to take control of swapping WebGL buffers. - env.Append(LINKFLAGS=["-s", "OFFSCREEN_FRAMEBUFFER=1"]) - # callMain for manual start, cwrap for the mono version. env.Append(LINKFLAGS=["-s", "EXPORTED_RUNTIME_METHODS=['callMain','cwrap']"]) # Add code that allow exiting runtime. env.Append(LINKFLAGS=["-s", "EXIT_RUNTIME=1"]) - - # TODO remove once we have GLES support back (temporary fix undefined symbols due to dead code elimination). - env.Append( - LINKFLAGS=[ - "-s", - "EXPORTED_FUNCTIONS=['_main', '_emscripten_webgl_get_current_context']", - ] - ) diff --git a/platform/javascript/display_server_javascript.cpp b/platform/javascript/display_server_javascript.cpp index d12e1aeee8..7648ddaf43 100644 --- a/platform/javascript/display_server_javascript.cpp +++ b/platform/javascript/display_server_javascript.cpp @@ -30,6 +30,9 @@ #include "platform/javascript/display_server_javascript.h" +#ifdef GLES3_ENABLED +#include "drivers/gles3/rasterizer_gles3.h" +#endif #include "platform/javascript/os_javascript.h" #include "servers/rendering/rasterizer_dummy.h" @@ -50,14 +53,6 @@ DisplayServerJavaScript *DisplayServerJavaScript::get_singleton() { } // Window (canvas) -void DisplayServerJavaScript::focus_canvas() { - godot_js_display_canvas_focus(); -} - -bool DisplayServerJavaScript::is_canvas_focused() { - return godot_js_display_canvas_is_focused() != 0; -} - bool DisplayServerJavaScript::check_size_force_redraw() { return godot_js_display_size_update() != 0; } @@ -141,11 +136,12 @@ void DisplayServerJavaScript::key_callback(int p_pressed, int p_repeat, int p_mo int DisplayServerJavaScript::mouse_button_callback(int p_pressed, int p_button, double p_x, double p_y, int p_modifiers) { DisplayServerJavaScript *ds = get_singleton(); + Point2 pos(p_x, p_y); + Input::get_singleton()->set_mouse_position(pos); Ref<InputEventMouseButton> ev; ev.instantiate(); - ev->set_pressed(p_pressed); - ev->set_position(Point2(p_x, p_y)); - ev->set_global_position(ev->get_position()); + ev->set_position(pos); + ev->set_global_position(pos); ev->set_pressed(p_pressed); dom2godot_mod(ev, p_modifiers); @@ -222,13 +218,15 @@ void DisplayServerJavaScript::mouse_move_callback(double p_x, double p_y, double return; } + Point2 pos(p_x, p_y); + Input::get_singleton()->set_mouse_position(pos); Ref<InputEventMouseMotion> ev; ev.instantiate(); dom2godot_mod(ev, p_modifiers); ev->set_button_mask(input_mask); - ev->set_position(Point2(p_x, p_y)); - ev->set_global_position(ev->get_position()); + ev->set_position(pos); + ev->set_global_position(pos); ev->set_relative(Vector2(p_rel_x, p_rel_y)); Input::get_singleton()->set_mouse_position(ev->get_position()); @@ -397,6 +395,10 @@ DisplayServer::MouseMode DisplayServerJavaScript::mouse_get_mode() const { return MOUSE_MODE_VISIBLE; } +Point2i DisplayServerJavaScript::mouse_get_position() const { + return Input::get_singleton()->get_mouse_position(); +} + // Wheel int DisplayServerJavaScript::mouse_wheel_callback(double p_delta_x, double p_delta_y) { if (!godot_js_display_canvas_is_focused()) { @@ -580,7 +582,9 @@ void DisplayServerJavaScript::process_joypads() { Vector<String> DisplayServerJavaScript::get_rendering_drivers_func() { Vector<String> drivers; - drivers.push_back("dummy"); +#ifdef GLES3_ENABLED + drivers.push_back("opengl3"); +#endif return drivers; } @@ -678,40 +682,34 @@ DisplayServerJavaScript::DisplayServerJavaScript(const String &p_rendering_drive // Expose method for requesting quit. godot_js_os_request_quit_cb(request_quit_callback); - RasterizerDummy::make_current(); // TODO OpenGL in Godot 4.0... or webgpu? -#if 0 - EmscriptenWebGLContextAttributes attributes; - emscripten_webgl_init_context_attributes(&attributes); - attributes.alpha = GLOBAL_GET("display/window/per_pixel_transparency/allowed"); - attributes.antialias = false; - ERR_FAIL_INDEX_V(p_video_driver, VIDEO_DRIVER_MAX, ERR_INVALID_PARAMETER); - - if (p_desired.layered) { - set_window_per_pixel_transparency_enabled(true); - } - - bool gl_initialization_error = false; - - if (RasterizerGLES3::is_viable() == OK) { - attributes.majorVersion = 1; - RasterizerGLES3::register_config(); - RasterizerGLES3::make_current(); - } else { - gl_initialization_error = true; - } - - EMSCRIPTEN_WEBGL_CONTEXT_HANDLE ctx = emscripten_webgl_create_context(canvas_id, &attributes); - if (emscripten_webgl_make_context_current(ctx) != EMSCRIPTEN_RESULT_SUCCESS) { - gl_initialization_error = true; +#ifdef GLES3_ENABLED + // TODO "vulkan" defaults to webgl2 for now. + bool wants_webgl2 = p_rendering_driver == "opengl3" || p_rendering_driver == "vulkan"; + bool webgl2_init_failed = wants_webgl2 && !godot_js_display_has_webgl(2); + if (wants_webgl2 && !webgl2_init_failed) { + EmscriptenWebGLContextAttributes attributes; + emscripten_webgl_init_context_attributes(&attributes); + //attributes.alpha = GLOBAL_GET("display/window/per_pixel_transparency/allowed"); + attributes.alpha = true; + attributes.antialias = false; + attributes.majorVersion = 2; + + webgl_ctx = emscripten_webgl_create_context(canvas_id, &attributes); + if (emscripten_webgl_make_context_current(webgl_ctx) != EMSCRIPTEN_RESULT_SUCCESS) { + webgl2_init_failed = true; + } else { + RasterizerGLES3::make_current(); + } } - - if (gl_initialization_error) { - OS::get_singleton()->alert("Your browser does not seem to support WebGL. Please update your browser version.", + if (webgl2_init_failed) { + OS::get_singleton()->alert("Your browser does not seem to support WebGL2. Please update your browser version.", "Unable to initialize video driver"); - return ERR_UNAVAILABLE; } - - video_driver_index = p_video_driver; + if (!wants_webgl2 || webgl2_init_failed) { + RasterizerDummy::make_current(); + } +#else + RasterizerDummy::make_current(); #endif // JS Input interface (js/libs/library_godot_input.js) @@ -738,8 +736,12 @@ DisplayServerJavaScript::DisplayServerJavaScript(const String &p_rendering_drive } DisplayServerJavaScript::~DisplayServerJavaScript() { - //emscripten_webgl_commit_frame(); - //emscripten_webgl_destroy_context(webgl_ctx); +#ifdef GLES3_ENABLED + if (webgl_ctx) { + emscripten_webgl_commit_frame(); + emscripten_webgl_destroy_context(webgl_ctx); + } +#endif } bool DisplayServerJavaScript::has_feature(Feature p_feature) const { @@ -968,5 +970,9 @@ bool DisplayServerJavaScript::get_swap_cancel_ok() { } void DisplayServerJavaScript::swap_buffers() { - //emscripten_webgl_commit_frame(); +#ifdef GLES3_ENABLED + if (webgl_ctx) { + emscripten_webgl_commit_frame(); + } +#endif } diff --git a/platform/javascript/display_server_javascript.h b/platform/javascript/display_server_javascript.h index 80ce772a79..843bb61984 100644 --- a/platform/javascript/display_server_javascript.h +++ b/platform/javascript/display_server_javascript.h @@ -51,6 +51,10 @@ private: }; JSKeyEvent key_event; +#ifdef GLES3_ENABLED + EMSCRIPTEN_WEBGL_CONTEXT_HANDLE webgl_ctx = 0; +#endif + WindowMode window_mode = WINDOW_MODE_WINDOWED; ObjectID window_attached_instance_id = {}; @@ -72,8 +76,6 @@ private: bool swap_cancel_ok = false; // utilities - static void focus_canvas(); - static bool is_canvas_focused(); static void dom2godot_mod(Ref<InputEventWithModifiers> ev, int p_mod); static const char *godot2dom_cursor(DisplayServer::CursorShape p_shape); @@ -121,6 +123,7 @@ public: // mouse virtual void mouse_set_mode(MouseMode p_mode) override; virtual MouseMode mouse_get_mode() const override; + virtual Point2i mouse_get_position() const override; // touch virtual bool screen_is_touchscreen(int p_screen = SCREEN_OF_MAIN_WINDOW) const override; diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h index aacf87e6c5..fbab95d33b 100644 --- a/platform/javascript/os_javascript.h +++ b/platform/javascript/os_javascript.h @@ -90,6 +90,7 @@ public: String get_user_data_dir() const override; bool is_userfs_persistent() const override; + bool is_single_window() const override { return true; } void alert(const String &p_alert, const String &p_title = "ALERT!") override; diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index 5ec2a81108..f0e51097db 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -1317,6 +1317,17 @@ void CharacterBody2D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo _snap_on_floor(p_was_on_floor, vel_dir_facing_up); + // Scales the horizontal velocity according to the wall slope. + if (is_on_wall_only() && motion_slide_up.dot(motion_results.get(0).collision_normal) < 0) { + Vector2 slide_motion = motion_velocity.slide(motion_results.get(0).collision_normal); + if (motion_slide_up.dot(slide_motion) < 0) { + motion_velocity = up_direction * up_direction.dot(motion_velocity); + } else { + // Keeps the vertical motion from motion_velocity and add the horizontal motion of the projection. + motion_velocity = up_direction * up_direction.dot(motion_velocity) + slide_motion.slide(up_direction); + } + } + // Reset the gravity accumulation when touching the ground. if (on_floor && !vel_dir_facing_up) { motion_velocity = motion_velocity.slide(up_direction); diff --git a/servers/physics_2d/godot_area_2d.cpp b/servers/physics_2d/godot_area_2d.cpp index fb9d38e7ea..c4060615c9 100644 --- a/servers/physics_2d/godot_area_2d.cpp +++ b/servers/physics_2d/godot_area_2d.cpp @@ -213,6 +213,7 @@ void GodotArea2D::set_monitorable(bool p_monitorable) { monitorable = p_monitorable; _set_static(!monitorable); + _shapes_changed(); } void GodotArea2D::call_queries() { diff --git a/servers/physics_2d/godot_area_pair_2d.cpp b/servers/physics_2d/godot_area_pair_2d.cpp index a98513004d..bde22aab11 100644 --- a/servers/physics_2d/godot_area_pair_2d.cpp +++ b/servers/physics_2d/godot_area_pair_2d.cpp @@ -128,7 +128,7 @@ bool GodotArea2Pair2D::setup(real_t p_step) { process_collision_a = false; if (result_a != colliding_a) { - if (area_a->has_area_monitor_callback() && area_b->is_monitorable()) { + if (area_a->has_area_monitor_callback() && area_b_monitorable) { process_collision_a = true; process_collision = true; } @@ -137,7 +137,7 @@ bool GodotArea2Pair2D::setup(real_t p_step) { process_collision_b = false; if (result_b != colliding_b) { - if (area_b->has_area_monitor_callback() && area_a->is_monitorable()) { + if (area_b->has_area_monitor_callback() && area_a_monitorable) { process_collision_b = true; process_collision = true; } @@ -176,19 +176,21 @@ GodotArea2Pair2D::GodotArea2Pair2D(GodotArea2D *p_area_a, int p_shape_a, GodotAr area_b = p_area_b; shape_a = p_shape_a; shape_b = p_shape_b; + area_a_monitorable = area_a->is_monitorable(); + area_b_monitorable = area_b->is_monitorable(); area_a->add_constraint(this); area_b->add_constraint(this); } GodotArea2Pair2D::~GodotArea2Pair2D() { if (colliding_a) { - if (area_a->has_area_monitor_callback()) { + if (area_a->has_area_monitor_callback() && area_b_monitorable) { area_a->remove_area_from_query(area_b, shape_b, shape_a); } } if (colliding_b) { - if (area_b->has_area_monitor_callback()) { + if (area_b->has_area_monitor_callback() && area_a_monitorable) { area_b->remove_area_from_query(area_a, shape_a, shape_b); } } diff --git a/servers/physics_2d/godot_area_pair_2d.h b/servers/physics_2d/godot_area_pair_2d.h index 45bd3df1ed..f1290a27d0 100644 --- a/servers/physics_2d/godot_area_pair_2d.h +++ b/servers/physics_2d/godot_area_pair_2d.h @@ -62,6 +62,8 @@ class GodotArea2Pair2D : public GodotConstraint2D { bool colliding_b = false; bool process_collision_a = false; bool process_collision_b = false; + bool area_a_monitorable; + bool area_b_monitorable; public: virtual bool setup(real_t p_step) override; diff --git a/servers/physics_3d/godot_area_3d.cpp b/servers/physics_3d/godot_area_3d.cpp index 9cdad069fe..d4e14b8d85 100644 --- a/servers/physics_3d/godot_area_3d.cpp +++ b/servers/physics_3d/godot_area_3d.cpp @@ -242,6 +242,7 @@ void GodotArea3D::set_monitorable(bool p_monitorable) { monitorable = p_monitorable; _set_static(!monitorable); + _shapes_changed(); } void GodotArea3D::call_queries() { diff --git a/servers/physics_3d/godot_area_pair_3d.cpp b/servers/physics_3d/godot_area_pair_3d.cpp index d3623178d5..58188565e3 100644 --- a/servers/physics_3d/godot_area_pair_3d.cpp +++ b/servers/physics_3d/godot_area_pair_3d.cpp @@ -129,7 +129,7 @@ bool GodotArea2Pair3D::setup(real_t p_step) { process_collision_a = false; if (result_a != colliding_a) { - if (area_a->has_area_monitor_callback() && area_b->is_monitorable()) { + if (area_a->has_area_monitor_callback() && area_b_monitorable) { process_collision_a = true; process_collision = true; } @@ -138,7 +138,7 @@ bool GodotArea2Pair3D::setup(real_t p_step) { process_collision_b = false; if (result_b != colliding_b) { - if (area_b->has_area_monitor_callback() && area_a->is_monitorable()) { + if (area_b->has_area_monitor_callback() && area_a_monitorable) { process_collision_b = true; process_collision = true; } @@ -177,19 +177,21 @@ GodotArea2Pair3D::GodotArea2Pair3D(GodotArea3D *p_area_a, int p_shape_a, GodotAr area_b = p_area_b; shape_a = p_shape_a; shape_b = p_shape_b; + area_a_monitorable = area_a->is_monitorable(); + area_b_monitorable = area_b->is_monitorable(); area_a->add_constraint(this); area_b->add_constraint(this); } GodotArea2Pair3D::~GodotArea2Pair3D() { if (colliding_a) { - if (area_a->has_area_monitor_callback()) { + if (area_a->has_area_monitor_callback() && area_b_monitorable) { area_a->remove_area_from_query(area_b, shape_b, shape_a); } } if (colliding_b) { - if (area_b->has_area_monitor_callback()) { + if (area_b->has_area_monitor_callback() && area_a_monitorable) { area_b->remove_area_from_query(area_a, shape_a, shape_b); } } diff --git a/servers/physics_3d/godot_area_pair_3d.h b/servers/physics_3d/godot_area_pair_3d.h index 16175e9fa8..4237e7722e 100644 --- a/servers/physics_3d/godot_area_pair_3d.h +++ b/servers/physics_3d/godot_area_pair_3d.h @@ -63,6 +63,8 @@ class GodotArea2Pair3D : public GodotConstraint3D { bool colliding_b = false; bool process_collision_a = false; bool process_collision_b = false; + bool area_a_monitorable; + bool area_b_monitorable; public: virtual bool setup(real_t p_step) override; diff --git a/thirdparty/README.md b/thirdparty/README.md index 588e3e9664..b922d89ab5 100644 --- a/thirdparty/README.md +++ b/thirdparty/README.md @@ -176,14 +176,14 @@ Files extracted from upstream source: ## graphite - Upstream: https://github.com/silnrsi/graphite -- Version: 1.3.14 (92f59dcc52f73ce747f1cdc831579ed2546884aa, 2020) +- Version: 1.3.14 (80c52493ef42e6fe605a69dcddd2a691cd8a1380, 2021) - License: MPL-2.0 Files extracted from upstream source: - the `include` folder -- the `src` folder -- `COPYING`, `ChangeLog` +- the `src` folder (minus `CMakeLists.txt` and `files.mk`) +- `COPYING` ## harfbuzz @@ -235,14 +235,14 @@ Files extracted from upstream source: ## libogg - Upstream: https://www.xiph.org/ogg -- Version: git (c8fca6b4a02d695b1ceea39b330d4406001c03ed, 2019) +- Version: 1.3.5 (e1774cd77f471443541596e09078e78fdc342e4f, 2021) - License: BSD-3-Clause Files extracted from upstream source: - `src/*.{c,h}` -- `include/ogg/*.h` in ogg/ -- COPYING +- `include/ogg/*.h` in `ogg/` (run `configure` to generate `config_types.h`) +- `COPYING` ## libpng @@ -350,22 +350,19 @@ found in the `patches` directory. ## miniupnpc - Upstream: https://github.com/miniupnp/miniupnp -- Version: 2.2.2 (81029a860baf1f727903e5b85307903b3f40cbc8, 2021) +- Version: 2.2.3 (2df8120326ed4246e049a7a6de707539604cd514, 2021) - License: BSD-3-Clause Files extracted from upstream source: -- All `*.c` and `*.h` files from `miniupnpc` to `thirdparty/miniupnpc/miniupnpc` +- Copy `miniupnpc/src` and `miniupnpc/include` to `thirdparty/miniupnpc` - Remove the following test or sample files: - `listdevices.c minihttptestserver.c miniupnpcmodule.c upnpc.c upnperrors.* test* wingenminiupnpcstrings.c` + `listdevices.c minihttptestserver.c miniupnpcmodule.c upnpc.c upnperrors.* test*` - `LICENSE` -The only modified file is `miniupnpcstrings.h`, which was created for Godot -(it is usually autogenerated by cmake). Bump the version number for miniupnpc in that -file when upgrading. - -Note: The following upstream patch has been applied, remove this notice on next update. -https://github.com/miniupnp/miniupnp/commit/3a08dd4b89af2e9effa22a136bac86f2f306fd79 +The only modified file is `src/miniupnpcstrings.h`, which was created for Godot +(it is usually autogenerated by cmake). Bump the version number for miniupnpc in +that file when upgrading. ## minizip @@ -506,7 +503,7 @@ Patch files are provided in `oidn/patches/`. ## pcre2 - Upstream: http://www.pcre.org -- Version: 10.36 (r1288, 2020) +- Version: 10.39 (35fee4193b852cb504892352bd0155de10809889, 2021) - License: BSD-3-Clause Files extracted from upstream source: @@ -599,18 +596,21 @@ comments and a patch is provided in the squish/ folder. ## tinyexr - Upstream: https://github.com/syoyo/tinyexr -- Version: 1.0.0 (e4b7840d9448b7d57a88384ce26143004f3c0c71, 2020) +- Version: 1.0.1 (67010eae802211202d0797f4df2b809f4ba7442c, 2021) - License: BSD-3-Clause Files extracted from upstream source: - `tinyexr.{cc,h}` +The `tinyexr.cc` file was modified to include `zlib.h` which we provide, +instead of `miniz.h` as an external dependency. + ## vhacd - Upstream: https://github.com/kmammou/v-hacd -- Version: git (b07958e18e01d504e3af80eeaeb9f033226533d7, 2019) +- Version: git (1a49edf29c69039df15286181f2f27e17ceb9aef, 2020) - License: BSD-3-Clause Files extracted from upstream source: @@ -683,12 +683,12 @@ File extracted from upstream release tarball: ## xatlas - Upstream: https://github.com/jpcy/xatlas -- Version: git (5571fc7ef0d06832947c0a935ccdcf083f7a9264, 2020) +- Version: git (ec707faeac3b95e6b416076a9509718cce105b6a, 2021) - License: MIT Files extracted from upstream source: -- `xatlas.{cpp,h}` +- `source/xatlas/xatlas.{cpp,h}` - `LICENSE` diff --git a/thirdparty/certs/ca-certificates.crt b/thirdparty/certs/ca-certificates.crt index 7d5ea3bef1..7f89e81d01 100644 --- a/thirdparty/certs/ca-certificates.crt +++ b/thirdparty/certs/ca-certificates.crt @@ -1,7 +1,7 @@ ## ## Bundle of CA Root Certificates ## -## Certificate data from Mozilla as of: Mon Jul 5 21:36:52 2021 GMT +## Certificate data from Mozilla as of: Mon Nov 1 15:39:58 2021 GMT ## ## This is a bundle of X.509 certificates of public Certificate Authorities ## (CA). These were automatically extracted from Mozilla's root certificates @@ -14,7 +14,7 @@ ## Just configure this file as the SSLCACertificateFile. ## ## Conversion done with mk-ca-bundle.pl version 1.28. -## SHA256: c8f6733d1ff4e6a4769c182971a1234f95ae079247a9c439a13423fe8ba5c24f +## SHA256: bb36818a81feaa4cca61101e6d6276cd09e972efcb08112dfed846918ca41d7f ## @@ -381,26 +381,6 @@ mNEVX58Svnw2Yzi9RKR/5CYrCsSXaQ3pjOLAEFe4yHYSkVXySGnYvCoCWw9E1CAx2/S6cCZdkGCe vEsXCS+0yx5DaMkHJ8HSXPfqIbloEpw8nL+e/IBcm2PN7EeqJSdnoDfzAIJ9VNep+OkuE6N36B9K -----END CERTIFICATE----- -DST Root CA X3 -============== ------BEGIN CERTIFICATE----- -MIIDSjCCAjKgAwIBAgIQRK+wgNajJ7qJMDmGLvhAazANBgkqhkiG9w0BAQUFADA/MSQwIgYDVQQK -ExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMTDkRTVCBSb290IENBIFgzMB4X -DTAwMDkzMDIxMTIxOVoXDTIxMDkzMDE0MDExNVowPzEkMCIGA1UEChMbRGlnaXRhbCBTaWduYXR1 -cmUgVHJ1c3QgQ28uMRcwFQYDVQQDEw5EU1QgUm9vdCBDQSBYMzCCASIwDQYJKoZIhvcNAQEBBQAD -ggEPADCCAQoCggEBAN+v6ZdQCINXtMxiZfaQguzH0yxrMMpb7NnDfcdAwRgUi+DoM3ZJKuM/IUmT -rE4Orz5Iy2Xu/NMhD2XSKtkyj4zl93ewEnu1lcCJo6m67XMuegwGMoOifooUMM0RoOEqOLl5CjH9 -UL2AZd+3UWODyOKIYepLYYHsUmu5ouJLGiifSKOeDNoJjj4XLh7dIN9bxiqKqy69cK3FCxolkHRy -xXtqqzTWMIn/5WgTe1QLyNau7Fqckh49ZLOMxt+/yUFw7BZy1SbsOFU5Q9D8/RhcQPGX69Wam40d -utolucbY38EVAjqr2m7xPi71XAicPNaDaeQQmxkqtilX4+U9m5/wAl0CAwEAAaNCMEAwDwYDVR0T -AQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFMSnsaR7LHH62+FLkHX/xBVghYkQ -MA0GCSqGSIb3DQEBBQUAA4IBAQCjGiybFwBcqR7uKGY3Or+Dxz9LwwmglSBd49lZRNI+DT69ikug -dB/OEIKcdBodfpga3csTS7MgROSR6cz8faXbauX+5v3gTt23ADq1cEmv8uXrAvHRAosZy5Q6XkjE -GB5YGV8eAlrwDPGxrancWYaLbumR9YbK+rlmM6pZW87ipxZzR8srzJmwN0jP41ZL9c8PDHIyh8bw -RLtTcm1D9SZImlJnt1ir/md2cXjbDaJWFBM5JDGFoqgCWjBH4d1QB7wCCZAA62RjYJsWvIjJEubS -fZGL+T0yjWW06XyxV3bqxbYoOb8VZRzI9neWagqNdwvYkQsEjgfbKbYK7p2CNTUQ ------END CERTIFICATE----- - SwissSign Gold CA - G2 ====================== -----BEGIN CERTIFICATE----- @@ -2713,7 +2693,8 @@ CBeQyh+KTOgNG3qxrdWBCUfvO6wIBHxcmbHtRwfSAjEAnbpV/KlK6O3t5nYBQnvI+GDZjVGLVTv7 jHvrZQnD+JbNR6iC8hZVdyR+EhCVBCyj -----END CERTIFICATE----- -# emSign Root CA - C1 +emSign Root CA - C1 +=================== -----BEGIN CERTIFICATE----- MIIDczCCAlugAwIBAgILAK7PALrEzzL4Q7IwDQYJKoZIhvcNAQELBQAwVjELMAkGA1UEBhMCVVMx EzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMRwwGgYDVQQDExNlbVNp @@ -2733,7 +2714,8 @@ wC68AivTxEDkigcxHpvOJpkT+xHqmiIMERnHXhuBUDDIlhJu58tBf5E7oke3VIAb3ADMmpDqw8NQ BmIMMMAVSKeoWXzhriKi4gp6D/piq1JM4fHfyr6DDUI= -----END CERTIFICATE----- -# emSign ECC Root CA - C3 +emSign ECC Root CA - C3 +======================= -----BEGIN CERTIFICATE----- MIICKzCCAbGgAwIBAgIKe3G2gla4EnycqDAKBggqhkjOPQQDAzBaMQswCQYDVQQGEwJVUzETMBEG A1UECxMKZW1TaWduIFBLSTEUMBIGA1UEChMLZU11ZGhyYSBJbmMxIDAeBgNVBAMTF2VtU2lnbiBF @@ -2747,7 +2729,8 @@ MGUCMQC02C8Cif22TGK6Q04ThHK1rt0c3ta13FaPWEBaLd4gTCKDypOofu4SQMfWh0/434UCMBwU ZOR8loMRnLDRWmFLpg9J0wD8ofzkpf9/rdcw0Md3f76BB1UwUCAU9Vc4CqgxUQ== -----END CERTIFICATE----- -# Hongkong Post Root CA 3 +Hongkong Post Root CA 3 +======================= -----BEGIN CERTIFICATE----- MIIFzzCCA7egAwIBAgIUCBZfikyl7ADJk0DfxMauI7gcWqQwDQYJKoZIhvcNAQELBQAwbzELMAkG A1UEBhMCSEsxEjAQBgNVBAgTCUhvbmcgS29uZzESMBAGA1UEBxMJSG9uZyBLb25nMRYwFAYDVQQK @@ -2778,7 +2761,8 @@ hcErulWuBurQB7Lcq9CClnXO0lD+mefPL5/ndtFhKvshuzHQqp9HpLIiyhY6UFfEW0NnxWViA0kB dBb9HxEGmpv0 -----END CERTIFICATE----- -# Entrust Root Certification Authority - G4 +Entrust Root Certification Authority - G4 +========================================= -----BEGIN CERTIFICATE----- MIIGSzCCBDOgAwIBAgIRANm1Q3+vqTkPAAAAAFVlrVgwDQYJKoZIhvcNAQELBQAwgb4xCzAJBgNV BAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3Qu @@ -2811,7 +2795,8 @@ JOgc47OlIQ6SwJAfzyBfyjs4x7dtOvPmRLgOMWuIjnDrnBdSqEGULoe256YSxXXfW8AKbnuk5F6G kcpG2om3PVODLAgfi49T3f+sHw== -----END CERTIFICATE----- -# Microsoft ECC Root Certificate Authority 2017 +Microsoft ECC Root Certificate Authority 2017 +============================================= -----BEGIN CERTIFICATE----- MIICWTCCAd+gAwIBAgIQZvI9r4fei7FK6gxXMQHC7DAKBggqhkjOPQQDAzBlMQswCQYDVQQGEwJV UzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYwNAYDVQQDEy1NaWNyb3NvZnQgRUND @@ -2826,7 +2811,8 @@ Xu5gKcs68tvWMoQZP3zVL8KxzJOuULsJMsbG7X7JNpQS5GiFBqIb0C8CMQCZ6Ra0DvpWSNSkMBaR eNtUjGUBiudQZsIxtzm6uBoiB078a1QWIP8rtedMDE2mT3M= -----END CERTIFICATE----- -# Microsoft RSA Root Certificate Authority 2017 +Microsoft RSA Root Certificate Authority 2017 +============================================= -----BEGIN CERTIFICATE----- MIIFqDCCA5CgAwIBAgIQHtOXCV/YtLNHcB6qvn9FszANBgkqhkiG9w0BAQwFADBlMQswCQYDVQQG EwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYwNAYDVQQDEy1NaWNyb3NvZnQg @@ -2856,7 +2842,8 @@ c0QWbej09+CVgI+WXTik9KveCjCHk9hNAHFiRSdLOkKEW39lt2c0Ui2cFmuqqNh7o0JMcccMyj6D 5KbvtwEwXlGjefVwaaZBRA+GsCyRxj3qrg+E -----END CERTIFICATE----- -# e-Szigno Root CA 2017 +e-Szigno Root CA 2017 +===================== -----BEGIN CERTIFICATE----- MIICQDCCAeWgAwIBAgIMAVRI7yH9l1kN9QQKMAoGCCqGSM49BAMCMHExCzAJBgNVBAYTAkhVMREw DwYDVQQHDAhCdWRhcGVzdDEWMBQGA1UECgwNTWljcm9zZWMgTHRkLjEXMBUGA1UEYQwOVkFUSFUt @@ -2871,7 +2858,8 @@ tVfd14pVCzbhhkT61NlojbjcI4qKDdQvfepz7L9NbKgCIQDLpbQS+ue16M9+k/zzNY9vTlp8tLxO svxyqltZ+efcMQ== -----END CERTIFICATE----- -# certSIGN Root CA G2 +certSIGN Root CA G2 +=================== -----BEGIN CERTIFICATE----- MIIFRzCCAy+gAwIBAgIJEQA0tk7GNi02MA0GCSqGSIb3DQEBCwUAMEExCzAJBgNVBAYTAlJPMRQw EgYDVQQKEwtDRVJUU0lHTiBTQTEcMBoGA1UECxMTY2VydFNJR04gUk9PVCBDQSBHMjAeFw0xNzAy @@ -2899,7 +2887,8 @@ NMn5X7azKFGnpyuqSfqNZSlO42sTp5SjLVFteAxEy9/eCG/Oo2Sr05WE1LlSVHJ7liXMvGnjSG4N 0MedJ5qq+BOS3R7fY581qRY27Iy4g/Q9iY/NtBde17MXQRBdJ3NghVdJIgc= -----END CERTIFICATE----- -# Trustwave Global Certification Authority +Trustwave Global Certification Authority +======================================== -----BEGIN CERTIFICATE----- MIIF2jCCA8KgAwIBAgIMBfcOhtpJ80Y1LrqyMA0GCSqGSIb3DQEBCwUAMIGIMQswCQYDVQQGEwJV UzERMA8GA1UECAwISWxsaW5vaXMxEDAOBgNVBAcMB0NoaWNhZ28xITAfBgNVBAoMGFRydXN0d2F2 @@ -2930,7 +2919,8 @@ Yj6RS8fZMXZC+fc8Y+wmjHMMfRod6qh8h6jCJ3zhM0EPz8/8AKAigJ5Kp28AsEFFtyLKaEjFQqKu 29FpHOTKyeC2nOnOcXHebD8WpHk= -----END CERTIFICATE----- -# Trustwave Global ECC P256 Certification Authority +Trustwave Global ECC P256 Certification Authority +================================================= -----BEGIN CERTIFICATE----- MIICYDCCAgegAwIBAgIMDWpfCD8oXD5Rld9dMAoGCCqGSM49BAMCMIGRMQswCQYDVQQGEwJVUzER MA8GA1UECBMISWxsaW5vaXMxEDAOBgNVBAcTB0NoaWNhZ28xITAfBgNVBAoTGFRydXN0d2F2ZSBI @@ -2945,7 +2935,8 @@ P62jQzBBMA8GA1UdEwEB/wQFMAMBAf8wDwYDVR0PAQH/BAUDAwcGADAdBgNVHQ4EFgQUo0EGrJBt RM4q3wghDDcCIC0mA6AFvWvR9lz4ZcyGbbOcNEhjhAnFjXca4syc4XR7 -----END CERTIFICATE----- -# Trustwave Global ECC P384 Certification Authority +Trustwave Global ECC P384 Certification Authority +================================================= -----BEGIN CERTIFICATE----- MIICnTCCAiSgAwIBAgIMCL2Fl2yZJ6SAaEc7MAoGCCqGSM49BAMDMIGRMQswCQYDVQQGEwJVUzER MA8GA1UECBMISWxsaW5vaXMxEDAOBgNVBAcTB0NoaWNhZ28xITAfBgNVBAoTGFRydXN0d2F2ZSBI @@ -2961,7 +2952,8 @@ ADBkAjA3AZKXRRJ+oPM+rRk6ct30UJMDEr5E0k9BpIycnR+j9sKS50gU/k6bpZFXrsY3crsCMGcl CrEMXu6pY5Jv5ZAL/mYiykf9ijH3g/56vxC+GCsej/YpHpRZ744hN8tRmKVuSw== -----END CERTIFICATE----- -# NAVER Global Root Certification Authority +NAVER Global Root Certification Authority +========================================= -----BEGIN CERTIFICATE----- MIIFojCCA4qgAwIBAgIUAZQwHqIL3fXFMyqxQ0Rx+NZQTQ0wDQYJKoZIhvcNAQEMBQAwaTELMAkG A1UEBhMCS1IxJjAkBgNVBAoMHU5BVkVSIEJVU0lORVNTIFBMQVRGT1JNIENvcnAuMTIwMAYDVQQD @@ -2991,7 +2983,8 @@ I/hGoiLtk/bdmuYqh7GYVPEi92tF4+KOdh2ajcQGjTa3FPOdVGm3jjzVpG2Tgbet9r1ke8LJaDmg kpzNNIaRkPpkUZ3+/uul9XXeifdy -----END CERTIFICATE----- -# AC RAIZ FNMT-RCM SERVIDORES SEGUROS +AC RAIZ FNMT-RCM SERVIDORES SEGUROS +=================================== -----BEGIN CERTIFICATE----- MIICbjCCAfOgAwIBAgIQYvYybOXE42hcG2LdnC6dlTAKBggqhkjOPQQDAzB4MQswCQYDVQQGEwJF UzERMA8GA1UECgwIRk5NVC1SQ00xDjAMBgNVBAsMBUNlcmVzMRgwFgYDVQRhDA9WQVRFUy1RMjgy @@ -3006,7 +2999,8 @@ SM49BAMDA2kAMGYCMQCuSuMrQMN0EfKVrRYj3k4MGuZdpSRea0R7/DjiT8ucRRcRTBQnJlU5dUoD zBOQn5ICMQD6SmxgiHPz7riYYqnOK8LZiqZwMR2vsJRM60/G49HzYqc8/5MuB1xJAWdpEgJyv+c= -----END CERTIFICATE----- -# GlobalSign Root R46 +GlobalSign Root R46 +=================== -----BEGIN CERTIFICATE----- MIIFWjCCA0KgAwIBAgISEdK7udcjGJ5AXwqdLdDfJWfRMA0GCSqGSIb3DQEBDAUAMEYxCzAJBgNV BAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMRwwGgYDVQQDExNHbG9iYWxTaWduIFJv @@ -3035,7 +3029,8 @@ DEJ4Y9HiD2971KE9dJeFt0g5QdYg/NA6s/rob8SKunE3vouXsXgxT7PntgMTzlSdriVZzH81Xwj3 QEUxeCp6 -----END CERTIFICATE----- -# GlobalSign Root E46 +GlobalSign Root E46 +=================== -----BEGIN CERTIFICATE----- MIICCzCCAZGgAwIBAgISEdK7ujNu1LzmJGjFDYQdmOhDMAoGCCqGSM49BAMDMEYxCzAJBgNVBAYT AkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMRwwGgYDVQQDExNHbG9iYWxTaWduIFJvb3Qg @@ -3049,7 +3044,8 @@ vLtoURMMA/cVi4RguYv/Uo7njLwcAjA8+RHUjE7AwWHCFUyqqx0LMV87HOIAl0Qx5v5zli/altP+ CAezNIm8BZ/3Hobui3A= -----END CERTIFICATE----- -# GLOBALTRUST 2020 +GLOBALTRUST 2020 +================ -----BEGIN CERTIFICATE----- MIIFgjCCA2qgAwIBAgILWku9WvtPilv6ZeUwDQYJKoZIhvcNAQELBQAwTTELMAkGA1UEBhMCQVQx IzAhBgNVBAoTGmUtY29tbWVyY2UgbW9uaXRvcmluZyBHbWJIMRkwFwYDVQQDExBHTE9CQUxUUlVT @@ -3078,7 +3074,8 @@ YqYK6miyeUcGbvJXqBUzxvd4Sj1Ce2t+/vdG6tHrju+IaFvowdlxfv1k7/9nR4hYJS8+hge9+6jl gqispdNpQ80xiEmEU5LAsTkbOYMBMMTyqfrQA71yN2BWHzZ8vTmR9W0Nv3vXkg== -----END CERTIFICATE----- -# ANF Secure Server Root CA +ANF Secure Server Root CA +========================= -----BEGIN CERTIFICATE----- MIIF7zCCA9egAwIBAgIIDdPjvGz5a7EwDQYJKoZIhvcNAQELBQAwgYQxEjAQBgNVBAUTCUc2MzI4 NzUxMDELMAkGA1UEBhMCRVMxJzAlBgNVBAoTHkFORiBBdXRvcmlkYWQgZGUgQ2VydGlmaWNhY2lv @@ -3109,7 +3106,8 @@ g77FGr8H6lnco4g175x2MjxNBiLOFeXdntiP2t7SxDnlF4HPOEfrf4htWRvfn0IUrn7PqLBmZdo3 r5+qPeoott7VMVgWglvquxl1AnMaykgaIZOQCo6ThKd9OyMYkomgjaw= -----END CERTIFICATE----- -# Certum EC-384 CA +Certum EC-384 CA +================ -----BEGIN CERTIFICATE----- MIICZTCCAeugAwIBAgIQeI8nXIESUiClBNAt3bpz9DAKBggqhkjOPQQDAzB0MQswCQYDVQQGEwJQ TDEhMB8GA1UEChMYQXNzZWNvIERhdGEgU3lzdGVtcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0gQ2Vy @@ -3124,7 +3122,8 @@ ADBlAjADVS2m5hjEfO/JUG7BJw+ch69u1RsIGL2SKcHvlJF40jocVYli5RsJHrpka/F2tNQCMQC0 QoSZ/6vnnvuRlydd3LBbMHHOXjgaatkl5+r3YZJW+OraNsKHZZYuciUvf9/DE8k= -----END CERTIFICATE----- -# Certum Trusted Root CA +Certum Trusted Root CA +====================== -----BEGIN CERTIFICATE----- MIIFwDCCA6igAwIBAgIQHr9ZULjJgDdMBvfrVU+17TANBgkqhkiG9w0BAQ0FADB6MQswCQYDVQQG EwJQTDEhMB8GA1UEChMYQXNzZWNvIERhdGEgU3lzdGVtcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0g @@ -3153,3 +3152,81 @@ WWRrJ8/vJ8HjJLWG965+Mk2weWjROeiQWMODvA8s1pfrzgzhIMfatz7DP78v3DSk+yshzWePS/Tj OPQD8rv7gmsHINFSH5pkAnuYZttcTVoP0ISVoDwUQwbKytu4QTbaakRnh6+v40URFWkIsr4WOZck bxJF0WddCajJFdr60qZfE2Efv4WstK2tBZQIgx51F9NxO5NQI1mg7TyRVJ12AMXDuDjb -----END CERTIFICATE----- + +TunTrust Root CA +================ +-----BEGIN CERTIFICATE----- +MIIFszCCA5ugAwIBAgIUEwLV4kBMkkaGFmddtLu7sms+/BMwDQYJKoZIhvcNAQELBQAwYTELMAkG +A1UEBhMCVE4xNzA1BgNVBAoMLkFnZW5jZSBOYXRpb25hbGUgZGUgQ2VydGlmaWNhdGlvbiBFbGVj +dHJvbmlxdWUxGTAXBgNVBAMMEFR1blRydXN0IFJvb3QgQ0EwHhcNMTkwNDI2MDg1NzU2WhcNNDQw +NDI2MDg1NzU2WjBhMQswCQYDVQQGEwJUTjE3MDUGA1UECgwuQWdlbmNlIE5hdGlvbmFsZSBkZSBD +ZXJ0aWZpY2F0aW9uIEVsZWN0cm9uaXF1ZTEZMBcGA1UEAwwQVHVuVHJ1c3QgUm9vdCBDQTCCAiIw +DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMPN0/y9BFPdDCA61YguBUtB9YOCfvdZn56eY+hz +2vYGqU8ftPkLHzmMmiDQfgbU7DTZhrx1W4eI8NLZ1KMKsmwb60ksPqxd2JQDoOw05TDENX37Jk0b +bjBU2PWARZw5rZzJJQRNmpA+TkBuimvNKWfGzC3gdOgFVwpIUPp6Q9p+7FuaDmJ2/uqdHYVy7BG7 +NegfJ7/Boce7SBbdVtfMTqDhuazb1YMZGoXRlJfXyqNlC/M4+QKu3fZnz8k/9YosRxqZbwUN/dAd +gjH8KcwAWJeRTIAAHDOFli/LQcKLEITDCSSJH7UP2dl3RxiSlGBcx5kDPP73lad9UKGAwqmDrViW +VSHbhlnUr8a83YFuB9tgYv7sEG7aaAH0gxupPqJbI9dkxt/con3YS7qC0lH4Zr8GRuR5KiY2eY8f +Tpkdso8MDhz/yV3A/ZAQprE38806JG60hZC/gLkMjNWb1sjxVj8agIl6qeIbMlEsPvLfe/ZdeikZ +juXIvTZxi11Mwh0/rViizz1wTaZQmCXcI/m4WEEIcb9PuISgjwBUFfyRbVinljvrS5YnzWuioYas +DXxU5mZMZl+QviGaAkYt5IPCgLnPSz7ofzwB7I9ezX/SKEIBlYrilz0QIX32nRzFNKHsLA4KUiwS +VXAkPcvCFDVDXSdOvsC9qnyW5/yeYa1E0wCXAgMBAAGjYzBhMB0GA1UdDgQWBBQGmpsfU33x9aTI +04Y+oXNZtPdEITAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFAaamx9TffH1pMjThj6hc1m0 +90QhMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsFAAOCAgEAqgVutt0Vyb+zxiD2BkewhpMl +0425yAA/l/VSJ4hxyXT968pk21vvHl26v9Hr7lxpuhbI87mP0zYuQEkHDVneixCwSQXi/5E/S7fd +Ao74gShczNxtr18UnH1YeA32gAm56Q6XKRm4t+v4FstVEuTGfbvE7Pi1HE4+Z7/FXxttbUcoqgRY +YdZ2vyJ/0Adqp2RT8JeNnYA/u8EH22Wv5psymsNUk8QcCMNE+3tjEUPRahphanltkE8pjkcFwRJp +adbGNjHh/PqAulxPxOu3Mqz4dWEX1xAZufHSCe96Qp1bWgvUxpVOKs7/B9dPfhgGiPEZtdmYu65x +xBzndFlY7wyJz4sfdZMaBBSSSFCp61cpABbjNhzI+L/wM9VBD8TMPN3pM0MBkRArHtG5Xc0yGYuP +jCB31yLEQtyEFpslbei0VXF/sHyz03FJuc9SpAQ/3D2gu68zngowYI7bnV2UqL1g52KAdoGDDIzM +MEZJ4gzSqK/rYXHv5yJiqfdcZGyfFoxnNidF9Ql7v/YQCvGwjVRDjAS6oz/v4jXH+XTgbzRB0L9z +ZVcg+ZtnemZoJE6AZb0QmQZZ8mWvuMZHu/2QeItBcy6vVR/cO5JyboTT0GFMDcx2V+IthSIVNg3r +AZ3r2OvEhJn7wAzMMujjd9qDRIueVSjAi1jTkD5OGwDxFa2DK5o= +-----END CERTIFICATE----- + +HARICA TLS RSA Root CA 2021 +=========================== +-----BEGIN CERTIFICATE----- +MIIFpDCCA4ygAwIBAgIQOcqTHO9D88aOk8f0ZIk4fjANBgkqhkiG9w0BAQsFADBsMQswCQYDVQQG +EwJHUjE3MDUGA1UECgwuSGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9u +cyBDQTEkMCIGA1UEAwwbSEFSSUNBIFRMUyBSU0EgUm9vdCBDQSAyMDIxMB4XDTIxMDIxOTEwNTUz +OFoXDTQ1MDIxMzEwNTUzN1owbDELMAkGA1UEBhMCR1IxNzA1BgNVBAoMLkhlbGxlbmljIEFjYWRl +bWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ0ExJDAiBgNVBAMMG0hBUklDQSBUTFMgUlNB +IFJvb3QgQ0EgMjAyMTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAIvC569lmwVnlskN +JLnQDmT8zuIkGCyEf3dRywQRNrhe7Wlxp57kJQmXZ8FHws+RFjZiPTgE4VGC/6zStGndLuwRo0Xu +a2s7TL+MjaQenRG56Tj5eg4MmOIjHdFOY9TnuEFE+2uva9of08WRiFukiZLRgeaMOVig1mlDqa2Y +Ulhu2wr7a89o+uOkXjpFc5gH6l8Cct4MpbOfrqkdtx2z/IpZ525yZa31MJQjB/OCFks1mJxTuy/K +5FrZx40d/JiZ+yykgmvwKh+OC19xXFyuQnspiYHLA6OZyoieC0AJQTPb5lh6/a6ZcMBaD9YThnEv +dmn8kN3bLW7R8pv1GmuebxWMevBLKKAiOIAkbDakO/IwkfN4E8/BPzWr8R0RI7VDIp4BkrcYAuUR +0YLbFQDMYTfBKnya4dC6s1BG7oKsnTH4+yPiAwBIcKMJJnkVU2DzOFytOOqBAGMUuTNe3QvboEUH +GjMJ+E20pwKmafTCWQWIZYVWrkvL4N48fS0ayOn7H6NhStYqE613TBoYm5EPWNgGVMWX+Ko/IIqm +haZ39qb8HOLubpQzKoNQhArlT4b4UEV4AIHrW2jjJo3Me1xR9BQsQL4aYB16cmEdH2MtiKrOokWQ +CPxrvrNQKlr9qEgYRtaQQJKQCoReaDH46+0N0x3GfZkYVVYnZS6NRcUk7M7jAgMBAAGjQjBAMA8G +A1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFApII6ZgpJIKM+qTW8VX6iVNvRLuMA4GA1UdDwEB/wQE +AwIBhjANBgkqhkiG9w0BAQsFAAOCAgEAPpBIqm5iFSVmewzVjIuJndftTgfvnNAUX15QvWiWkKQU +EapobQk1OUAJ2vQJLDSle1mESSmXdMgHHkdt8s4cUCbjnj1AUz/3f5Z2EMVGpdAgS1D0NTsY9FVq +QRtHBmg8uwkIYtlfVUKqrFOFrJVWNlar5AWMxajaH6NpvVMPxP/cyuN+8kyIhkdGGvMA9YCRotxD +QpSbIPDRzbLrLFPCU3hKTwSUQZqPJzLB5UkZv/HywouoCjkxKLR9YjYsTewfM7Z+d21+UPCfDtcR +j88YxeMn/ibvBZ3PzzfF0HvaO7AWhAw6k9a+F9sPPg4ZeAnHqQJyIkv3N3a6dcSFA1pj1bF1BcK5 +vZStjBWZp5N99sXzqnTPBIWUmAD04vnKJGW/4GKvyMX6ssmeVkjaef2WdhW+o45WxLM0/L5H9MG0 +qPzVMIho7suuyWPEdr6sOBjhXlzPrjoiUevRi7PzKzMHVIf6tLITe7pTBGIBnfHAT+7hOtSLIBD6 +Alfm78ELt5BGnBkpjNxvoEppaZS3JGWg/6w/zgH7IS79aPib8qXPMThcFarmlwDB31qlpzmq6YR/ +PFGoOtmUW4y/Twhx5duoXNTSpv4Ao8YWxw/ogM4cKGR0GQjTQuPOAF1/sdwTsOEFy9EgqoZ0njnn +kf3/W9b3raYvAwtt41dU63ZTGI0RmLo= +-----END CERTIFICATE----- + +HARICA TLS ECC Root CA 2021 +=========================== +-----BEGIN CERTIFICATE----- +MIICVDCCAdugAwIBAgIQZ3SdjXfYO2rbIvT/WeK/zjAKBggqhkjOPQQDAzBsMQswCQYDVQQGEwJH +UjE3MDUGA1UECgwuSGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9ucyBD +QTEkMCIGA1UEAwwbSEFSSUNBIFRMUyBFQ0MgUm9vdCBDQSAyMDIxMB4XDTIxMDIxOTExMDExMFoX +DTQ1MDIxMzExMDEwOVowbDELMAkGA1UEBhMCR1IxNzA1BgNVBAoMLkhlbGxlbmljIEFjYWRlbWlj +IGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ0ExJDAiBgNVBAMMG0hBUklDQSBUTFMgRUNDIFJv +b3QgQ0EgMjAyMTB2MBAGByqGSM49AgEGBSuBBAAiA2IABDgI/rGgltJ6rK9JOtDA4MM7KKrxcm1l +AEeIhPyaJmuqS7psBAqIXhfyVYf8MLA04jRYVxqEU+kw2anylnTDUR9YSTHMmE5gEYd103KUkE+b +ECUqqHgtvpBBWJAVcqeht6NCMEAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUyRtTgRL+BNUW +0aq8mm+3oJUZbsowDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMDA2cAMGQCMBHervjcToiwqfAi +rcJRQO9gcS3ujwLEXQNwSaSS6sUUiHCm0w2wqsosQJz76YJumgIwK0eaB8bRwoF8yguWGEEbo/Qw +CZ61IygNnxS2PFOiTAZpffpskcYqSUXm7LcT4Tps +-----END CERTIFICATE----- diff --git a/thirdparty/graphite/ChangeLog b/thirdparty/graphite/ChangeLog deleted file mode 100644 index e36110e1c1..0000000000 --- a/thirdparty/graphite/ChangeLog +++ /dev/null @@ -1,238 +0,0 @@ -1.3.14 - . Bug fixes - . Allow features to be hidden (for aliases) - . Move to python3 - . Rename doc files from .txt to .asc - -1.3.13 - . Resolve minor spacing issue in rtl non-overlap kerning - . python3 for graphite.py - . Better fuzzing - . Better building on windows - -1.3.12 - . Graphite no longer does dumb rendering for fonts with no smarts - . Segment caching code removed. Anything attempting to use the segment cache gets given a regular face instead - . Add libfuzzer support - . Builds now require C++11 - . Improvements to Windows 64 bit builds - . Support different versions of python including 32 bit and python 3 - . Various minor bug fixes - -1.3.11 - . Fixes due to security review - . Minor collision avoidance fixes - . Fix LZ4 decompressor against high compression - -1.3.10 - . Address floating point build parameters to give consistent positioning results across platforms - . Various bug fixes - -1.3.9 - . Add Collision COLL_ISSPACE to allow for visible spaces in collision avoidance - . Add segment and pass direction information to tracing output - . Bug fix rule length testing in 32-bit - . Increase slanted margin distances for collision avoidance - . Change kerning algorithm to simple outline expansion. Seems to make no visible difference. - . Add trace2svg to test tools - -1.3.8 - . Various bug fixes arising from fuzzing - . Fix regression that stopped piglatin from working - . Make collision avoidance kerning give more regular results - . Minor modification to clustering algorithm to handle variable width chars - -1.3.7 - . Bug fixes - . Start to deprecate SegCache. This will be going away in a later release. - -1.3.6 - . Bug fixes - -1.3.5 - . Bug fixes - . Security bug fix - . Fix ARM misalignment problem - . Track latest cmake - -1.3.4 - . Transition from Mercurial to Git - . Bug fixes - . Fix Collision Kerning ignoring some diacritics - . Handle pass bits 16-31 to speed up fonts with > 16 passes - . Various minor fuzz bug fixes - . Make Coverity happy - . Add GR_FALLTHROUGH macro for clang c++11 - -1.3.3 - . Slight speed up in Collision Avoidance - . Remove dead bidi code - . Bug fixes - . Between pass bidi reorderings and at the end - . Decompressor fuzz bugs - . Other fuzz bugs - -1.3.2 - . Remove full bidi. All segments are assumed to be single directioned. - . Bug fixes: - . Decompressor corner cases - . Various fuzz bugs - -1.3.1 - . Deprecation warning: Full bidi support is about to be deprecated. Make contact - if this impacts you. - . Change compression block format slightly to conform to LZ4 - . Bug fixes: - . Handle mono direction text with diacritics consistently. Fonts - now see the direction they expect consistently and bidi now - gives expected results. - . Fixed lots of fuzz bugs - . Coverity cleanups - . Build now works for clang and/or asan and/or afl etc. - -1.3.0 - . Add collision avoidance - . Shift Collider - . Kern Collider - . Octabox outlines and subboxes - . Add compressed Silf and Glat table support - . Bug fixes: - . Stop loops forming in the child, sibling tree - . Handle bidi mirroring correctly if no bidi occurring - -1.2.4 - . Face failure now has error code reporting via debug logging - . can now call gr_start_logging(NULL, fname) - . gr2fonttest --alltrace added - . Format 14 table support - . Not done. To be handled entirely in the compiler - . Bidi support for Unicode 6.3 Isolating direction controls - . Fonts no longer require a glyf/loca table. In such cases the bounding box is always 0. - . Clang ASAN build support added for testing. - . Handle out of memory sanely. - . Documentation improvements - . Bug fixes: - . Enforce fonts having to store glyph attributes by monotonically increasing attribute number - . zeropadding was not getting called on feature tags - . automatic associations for unassociated characters - . use direct engine on Mac - . various extreme case reading 1 past the end errors fixed - . remove tabs from sources so that it becomes readable again - -1.2.3 - . Bug fixes only: - . fix byte swapping when testing cmap subtable lengths - . work around armel compilation problems with conditional operators - . fix pseudoglyph support for advance and bbox - -1.2.2 - . Add support for passKeySlot (makes Charis 2x faster) up to 32 passes - . Add telemetry output to json if enabled in build GRAPHITE2_TELEMETRY - . Shrink font memory footprint particularly in the fsm - . Add -S to comparerenderer - . Bug fixes: - . Fix shift.x being reversed for rtl text - . Fix faulty fallback justification - . Fix bad cmap handling - . Support compiling on old Solaris where bidi attributes clash with register names - . Follow the crowd in using Windows.h - -1.2.1 - . Bug fixes: - . Allow glyph reattachment - . Allow signed glyph attributes - . Various build problems with MacOS, old gcc versions, etc. - . Various overrun read errors fixed - -1.2.0 - . API Changes: - . Added Windows friendly gr_start_logging and gr_stop_logging, now per face - . Added gr_make_face_with_ops, gr_make_face_with_seg_cache_and_ops - . Added gr_make_font_with_ops - . Added gr_face_is_char_supported - . Added gr_face_info to give info to apps about face capabilities - . Deprecated gr_make_face, gr_make_face_with_seg_cache, gr_make_font_with_advance_fn - . Deprecated graphite_start_logging and graphite_stop_logging - . These functions are stubbed now and do nothing, but do compile and link. - . Bump API version to 3 - . Add C# wrapper to contrib - . Handle justification information in a font and do something useful with it - . Builds clang clean (has done for a while) - . Bug fixes - . Windows build and bug fixes - . Add extra information to json debug output - . Added windows build documentation - . Added freetype sample code and test - -1.1.3 - . Default build has GRAPHITE2_COMPARE_RENDERER to OFF to reduce dependencies - . Builds on Mac with clang - . Debug output improvements - . Tidy up perl wrappers - . Fuzz tester improvements - . Various bug fixes for bad font handling - -1.1.2 - . Support feature ids < 4 chars when space padded for inclusion in FF 14. - . More fuzztesting and removal of causes of valgrind bad reads and sigabrts - . Remove contrib/android into its own repo (http://hg.palaso.org/grandroid) - . Update comparerenderer to latest harfbuzzng api - -1.1.1 - . Missing Log.h included - . perl wrappers updated - -1.1.0 - . Refactored debug output to use json - . Renamed VM_MACHINE_TYPE to GRAPHITE2_VM_TYPE - . Renamed DISABLE_SEGCACHE to GRAPHITE2_NSEGCACE - . Renamed DISBALE_FILE_FACE to GRAPHITE2_NFILEFACE - . Renamed ENABLE_COMPARE_RENDERER to GRAPHTIE2_COMPARE_RENDERER - . Renamed DOXYGEN_CONFIG to GRAPHITE2_DOXYGEN_CONFIG - . Renamed GR2_CUSTOM_HEADER to GRAPHITE2_CUSTOM_HEADER - . Renamed GR2_EXPORTING to GRAPHITE2_EXPORTING - . Added GRAPHITE2_STATIC for static only builds - . Added GRAPHITE2_NTRACING to compile out tracing code - . Documented GRAPHITE2_{EXPORTING,STATIC,NTRACING} in hacking.txt - . Bump libtool version to 2.1.0 - . dumb font rendering works - . slot user attributes are now signed rather than unsigned - . add support for long class maps - . Rename perl library to avoid nameclash on Windows - . Various robustness fixes - . Moved internal .h files into src/inc - . Parallelise fuzztest - . General build improvements, particularly on Windows - -1.0.3 - . Fix UTF16 surrogate support - . script and lang tags may be space padded or null padded - . Remove need for WORDS_BIGENDIAN, do it all automatically - . Remove all #include <new>. Use CLASS_NEW_DELETE instead. - . Fix comparerenderer to work with current hbng - . Add valgrind to fuzztest to ensure good memory use at all times - . Fix new fuzztest exposed bugs. - . Fix bugs exposed by Mozilla security review - . Add continuous integration build on Windows support - -1.0.2 - . Fix Windows build - . Comparerenderer uses hbng enforcing ot rendering - . Add Bidi .hasChar support and refactor mirroring code - . Make cmake default Release rather than debug - . Don't compile in a boat load of TtfUtil that isn't used, saving 15% of binary - . Chase the FSF around its latest office moves - . WORDS_BIGENDIAN is set at the top so tests now pass on ppc, etc. - . More words in the manual - -1.0.1 - . Release is the default build in cmake now. - . Refactor cmake build to not rebuild things so much. - . Include a missing file - . Remove -nostdlibs, making gcc happy everywhere - . Update comparerenderer to latest hbng interface - . Add changelog - -1.0.0 - . First major release of perfect code! - diff --git a/thirdparty/graphite/src/Pass.cpp b/thirdparty/graphite/src/Pass.cpp index db31c22d46..47ae2064f7 100644 --- a/thirdparty/graphite/src/Pass.cpp +++ b/thirdparty/graphite/src/Pass.cpp @@ -1056,12 +1056,17 @@ float Pass::resolveKern(Segment *seg, Slot *slotFix, GR_MAYBE_UNUSED Slot *start ymin = min(by + bbb.bl.y, ymin); for (nbor = slotFix->next(); nbor; nbor = nbor->next()) { - if (nbor->isChildOf(base)) - continue; if (!gc.check(nbor->gid())) return 0.; const Rect &bb = seg->theGlyphBBoxTemporary(nbor->gid()); SlotCollision *cNbor = seg->collisionInfo(nbor); + const float nby = nbor->origin().y + cNbor->shift().y; + if (nbor->isChildOf(base)) + { + ymax = max(nby + bb.tr.y, ymax); + ymin = min(nby + bb.bl.y, ymin); + continue; + } if ((bb.bl.y == 0.f && bb.tr.y == 0.f) || (cNbor->flags() & SlotCollision::COLL_ISSPACE)) { if (m_kernColls == InWord) diff --git a/thirdparty/libogg/framing.c b/thirdparty/libogg/framing.c index 83601199ad..724d116d7f 100644 --- a/thirdparty/libogg/framing.c +++ b/thirdparty/libogg/framing.c @@ -597,9 +597,14 @@ char *ogg_sync_buffer(ogg_sync_state *oy, long size){ if(size>oy->storage-oy->fill){ /* We need to extend the internal buffer */ - long newsize=size+oy->fill+4096; /* an extra page to be nice */ + long newsize; void *ret; + if(size>INT_MAX-4096-oy->fill){ + ogg_sync_clear(oy); + return NULL; + } + newsize=size+oy->fill+4096; /* an extra page to be nice */ if(oy->data) ret=_ogg_realloc(oy->data,newsize); else @@ -1564,7 +1569,7 @@ void test_pack(const int *pl, const int **headers, int byteskip, byteskipcount=byteskip; } - ogg_sync_wrote(&oy,next-buf); + ogg_sync_wrote(&oy,(long)(next-buf)); while(1){ int ret=ogg_sync_pageout(&oy,&og_de); diff --git a/thirdparty/libogg/ogg/config_types.h b/thirdparty/libogg/ogg/config_types.h index 4dc8393fdc..1a87df6423 100644 --- a/thirdparty/libogg/ogg/config_types.h +++ b/thirdparty/libogg/ogg/config_types.h @@ -1,7 +1,20 @@ #ifndef __CONFIG_TYPES_H__ #define __CONFIG_TYPES_H__ -#include <stdint.h> +/* these are filled in by configure or cmake*/ +#define INCLUDE_INTTYPES_H 1 +#define INCLUDE_STDINT_H 1 +#define INCLUDE_SYS_TYPES_H 1 + +#if INCLUDE_INTTYPES_H +# include <inttypes.h> +#endif +#if INCLUDE_STDINT_H +# include <stdint.h> +#endif +#if INCLUDE_SYS_TYPES_H +# include <sys/types.h> +#endif typedef int16_t ogg_int16_t; typedef uint16_t ogg_uint16_t; diff --git a/thirdparty/miniupnpc/LICENSE b/thirdparty/miniupnpc/LICENSE index 6ddd381baa..fe9118c07e 100644 --- a/thirdparty/miniupnpc/LICENSE +++ b/thirdparty/miniupnpc/LICENSE @@ -1,4 +1,4 @@ -MiniUPnPc +MiniUPnP Project Copyright (c) 2005-2020, Thomas BERNARD All rights reserved. @@ -24,4 +24,3 @@ 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. - diff --git a/thirdparty/miniupnpc/miniupnpc/igd_desc_parse.h b/thirdparty/miniupnpc/include/igd_desc_parse.h index 0de546b697..0de546b697 100644 --- a/thirdparty/miniupnpc/miniupnpc/igd_desc_parse.h +++ b/thirdparty/miniupnpc/include/igd_desc_parse.h diff --git a/thirdparty/miniupnpc/miniupnpc/miniupnpc.h b/thirdparty/miniupnpc/include/miniupnpc.h index 3aef8ea443..a10bd950a8 100644 --- a/thirdparty/miniupnpc/miniupnpc/miniupnpc.h +++ b/thirdparty/miniupnpc/include/miniupnpc.h @@ -1,4 +1,4 @@ -/* $Id: miniupnpc.h,v 1.58 2021/03/02 23:49:52 nanard Exp $ */ +/* $Id: miniupnpc.h,v 1.59 2021/09/28 21:39:17 nanard Exp $ */ /* vim: tabstop=4 shiftwidth=4 noexpandtab * Project: miniupnp * http://miniupnp.free.fr/ @@ -20,7 +20,7 @@ #define UPNPDISCOVER_MEMORY_ERROR (-102) /* versions : */ -#define MINIUPNPC_VERSION "2.2.2" +#define MINIUPNPC_VERSION "2.2.3" #define MINIUPNPC_API_VERSION 17 /* Source port: diff --git a/thirdparty/miniupnpc/miniupnpc/miniupnpc_declspec.h b/thirdparty/miniupnpc/include/miniupnpc_declspec.h index 40adb922ec..40adb922ec 100644 --- a/thirdparty/miniupnpc/miniupnpc/miniupnpc_declspec.h +++ b/thirdparty/miniupnpc/include/miniupnpc_declspec.h diff --git a/thirdparty/miniupnpc/miniupnpc/miniupnpctypes.h b/thirdparty/miniupnpc/include/miniupnpctypes.h index 307ce39699..26ed4f0059 100644 --- a/thirdparty/miniupnpc/miniupnpc/miniupnpctypes.h +++ b/thirdparty/miniupnpc/include/miniupnpctypes.h @@ -1,13 +1,15 @@ /* $Id: miniupnpctypes.h,v 1.1 2011/02/15 11:10:40 nanard Exp $ */ /* Miniupnp project : http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org * Author : Thomas Bernard - * Copyright (c) 2011 Thomas Bernard + * Copyright (c) 2021 Thomas Bernard * This software is subject to the conditions detailed in the * LICENCE file provided within this distribution */ #ifndef MINIUPNPCTYPES_H_INCLUDED #define MINIUPNPCTYPES_H_INCLUDED -#if (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L) +/* Use unsigned long long when available : + * strtoull is C99 */ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define UNSIGNED_INTEGER unsigned long long #define STRTOUI strtoull #else diff --git a/thirdparty/miniupnpc/miniupnpc/miniwget.h b/thirdparty/miniupnpc/include/miniwget.h index f5572c2544..f5572c2544 100644 --- a/thirdparty/miniupnpc/miniupnpc/miniwget.h +++ b/thirdparty/miniupnpc/include/miniwget.h diff --git a/thirdparty/miniupnpc/miniupnpc/portlistingparse.h b/thirdparty/miniupnpc/include/portlistingparse.h index e3957a3f4c..e3957a3f4c 100644 --- a/thirdparty/miniupnpc/miniupnpc/portlistingparse.h +++ b/thirdparty/miniupnpc/include/portlistingparse.h diff --git a/thirdparty/miniupnpc/miniupnpc/upnpcommands.h b/thirdparty/miniupnpc/include/upnpcommands.h index 1b6d447732..1b6d447732 100644 --- a/thirdparty/miniupnpc/miniupnpc/upnpcommands.h +++ b/thirdparty/miniupnpc/include/upnpcommands.h diff --git a/thirdparty/miniupnpc/miniupnpc/upnpdev.h b/thirdparty/miniupnpc/include/upnpdev.h index 9b2cb431ba..171d495be3 100644 --- a/thirdparty/miniupnpc/miniupnpc/upnpdev.h +++ b/thirdparty/miniupnpc/include/upnpdev.h @@ -1,8 +1,8 @@ -/* $Id: upnpdev.h,v 1.3 2020/05/29 15:57:42 nanard Exp $ */ +/* $Id: upnpdev.h,v 1.4 2021/08/21 09:45:01 nanard Exp $ */ /* Project : miniupnp * Web : http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/ * Author : Thomas BERNARD - * copyright (c) 2005-2020 Thomas Bernard + * copyright (c) 2005-2021 Thomas Bernard * This software is subjet to the conditions detailed in the * provided LICENSE file. */ #ifndef UPNPDEV_H_INCLUDED @@ -20,7 +20,7 @@ struct UPNPDev { char * st; char * usn; unsigned int scope_id; -#if defined(__STDC_VERSION) && __STDC_VERSION__ >= 199901L +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 flexible array member */ char buffer[]; #elif defined(__GNUC__) diff --git a/thirdparty/miniupnpc/miniupnpc/upnpreplyparse.h b/thirdparty/miniupnpc/include/upnpreplyparse.h index 6badd15b26..6badd15b26 100644 --- a/thirdparty/miniupnpc/miniupnpc/upnpreplyparse.h +++ b/thirdparty/miniupnpc/include/upnpreplyparse.h diff --git a/thirdparty/miniupnpc/miniupnpc/addr_is_reserved.c b/thirdparty/miniupnpc/src/addr_is_reserved.c index 7e586d7da2..18c6424201 100644 --- a/thirdparty/miniupnpc/miniupnpc/addr_is_reserved.c +++ b/thirdparty/miniupnpc/src/addr_is_reserved.c @@ -56,7 +56,7 @@ int addr_is_reserved(const char * addr_str) uint32_t addr_n, address; size_t i; -#if defined(_WIN32) && (!defined(_WIN32_WINNT_VISTA) || (_WIN32_WINNT < _WIN32_WINNT_VISTA)) +#if defined(_WIN32) && _WIN32_WINNT < 0x0600 // _WIN32_WINNT_VISTA addr_n = inet_addr(addr_str); if (addr_n == INADDR_NONE) return 1; diff --git a/thirdparty/miniupnpc/miniupnpc/addr_is_reserved.h b/thirdparty/miniupnpc/src/addr_is_reserved.h index f8b5d66a09..f8b5d66a09 100644 --- a/thirdparty/miniupnpc/miniupnpc/addr_is_reserved.h +++ b/thirdparty/miniupnpc/src/addr_is_reserved.h diff --git a/thirdparty/miniupnpc/miniupnpc/codelength.h b/thirdparty/miniupnpc/src/codelength.h index ea0b005ffe..ea0b005ffe 100644 --- a/thirdparty/miniupnpc/miniupnpc/codelength.h +++ b/thirdparty/miniupnpc/src/codelength.h diff --git a/thirdparty/miniupnpc/miniupnpc/connecthostport.c b/thirdparty/miniupnpc/src/connecthostport.c index 79f832b8db..79f832b8db 100644 --- a/thirdparty/miniupnpc/miniupnpc/connecthostport.c +++ b/thirdparty/miniupnpc/src/connecthostport.c diff --git a/thirdparty/miniupnpc/miniupnpc/connecthostport.h b/thirdparty/miniupnpc/src/connecthostport.h index 701816b5b6..701816b5b6 100644 --- a/thirdparty/miniupnpc/miniupnpc/connecthostport.h +++ b/thirdparty/miniupnpc/src/connecthostport.h diff --git a/thirdparty/miniupnpc/miniupnpc/igd_desc_parse.c b/thirdparty/miniupnpc/src/igd_desc_parse.c index d2999ad011..d2999ad011 100644 --- a/thirdparty/miniupnpc/miniupnpc/igd_desc_parse.c +++ b/thirdparty/miniupnpc/src/igd_desc_parse.c diff --git a/thirdparty/miniupnpc/miniupnpc/minisoap.c b/thirdparty/miniupnpc/src/minisoap.c index 78606672d5..78606672d5 100644 --- a/thirdparty/miniupnpc/miniupnpc/minisoap.c +++ b/thirdparty/miniupnpc/src/minisoap.c diff --git a/thirdparty/miniupnpc/miniupnpc/minisoap.h b/thirdparty/miniupnpc/src/minisoap.h index d6a45d03ba..d6a45d03ba 100644 --- a/thirdparty/miniupnpc/miniupnpc/minisoap.h +++ b/thirdparty/miniupnpc/src/minisoap.h diff --git a/thirdparty/miniupnpc/miniupnpc/minissdpc.c b/thirdparty/miniupnpc/src/minissdpc.c index 5d3a0fd049..edebb1600a 100644 --- a/thirdparty/miniupnpc/miniupnpc/minissdpc.c +++ b/thirdparty/miniupnpc/src/minissdpc.c @@ -1,4 +1,4 @@ -/* $Id: minissdpc.c,v 1.47 2021/03/02 23:38:30 nanard Exp $ */ +/* $Id: minissdpc.c,v 1.49 2021/05/13 11:00:36 nanard Exp $ */ /* vim: tabstop=4 shiftwidth=4 noexpandtab * Project : miniupnp * Web : http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/ @@ -460,7 +460,7 @@ parseMSEARCHReply(const char * reply, int size, static int upnp_gettimeofday(struct timeval * tv) { #if defined(_WIN32) -#if defined(_WIN32_WINNT_VISTA) && (_WIN32_WINNT >= _WIN32_WINNT_VISTA) +#if _WIN32_WINNT >= 0x0600 // _WIN32_WINNT_VISTA ULONGLONG ts = GetTickCount64(); #else DWORD ts = GetTickCount(); @@ -469,14 +469,29 @@ static int upnp_gettimeofday(struct timeval * tv) tv->tv_usec = (ts % 1000) * 1000; return 0; /* success */ #elif defined(CLOCK_MONOTONIC_FAST) || defined(CLOCK_MONOTONIC) - struct timespec ts; - int ret_code = clock_gettime(UPNP_CLOCKID, &ts); - if (ret_code == 0) +#if defined(__APPLE__) +#if defined(__clang__) + if (__builtin_available(macOS 10.12, iOS 10.0, tvOS 10.0, watchOS 3.0, *)) { +#else /* !defined(__clang__) */ + if (clock_gettime != NULL) { +#endif /* defined(__clang__) */ +#endif /* defined(__APPLE__) */ + struct timespec ts; + int ret_code = clock_gettime(UPNP_CLOCKID, &ts); + if (ret_code == 0) + { + tv->tv_sec = ts.tv_sec; + tv->tv_usec = ts.tv_nsec / 1000; + } + return ret_code; +#if defined(__APPLE__) + } + else { - tv->tv_sec = ts.tv_sec; - tv->tv_usec = ts.tv_nsec / 1000; + /* fall-back for earlier Apple platforms */ + return gettimeofday(tv, NULL); } - return ret_code; +#endif /* defined(__APPLE__) */ #else return gettimeofday(tv, NULL); #endif @@ -705,7 +720,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[], } } - if(multicastif) + if(multicastif && multicastif[0] != '\0') { if(ipv6) { #if !defined(_WIN32) @@ -732,7 +747,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[], } else { struct in_addr mc_if; #if defined(_WIN32) -#if defined(_WIN32_WINNT_VISTA) && (_WIN32_WINNT >= _WIN32_WINNT_VISTA) +#if _WIN32_WINNT >= 0x0600 // _WIN32_WINNT_VISTA InetPtonA(AF_INET, multicastif, &mc_if); #else mc_if.s_addr = inet_addr(multicastif); /* old Windows SDK do not support InetPtoA() */ diff --git a/thirdparty/miniupnpc/miniupnpc/minissdpc.h b/thirdparty/miniupnpc/src/minissdpc.h index c99f929b9e..c99f929b9e 100644 --- a/thirdparty/miniupnpc/miniupnpc/minissdpc.h +++ b/thirdparty/miniupnpc/src/minissdpc.h diff --git a/thirdparty/miniupnpc/miniupnpc/miniupnpc.c b/thirdparty/miniupnpc/src/miniupnpc.c index 696af93237..696af93237 100644 --- a/thirdparty/miniupnpc/miniupnpc/miniupnpc.c +++ b/thirdparty/miniupnpc/src/miniupnpc.c diff --git a/thirdparty/miniupnpc/miniupnpc/miniupnpc_socketdef.h b/thirdparty/miniupnpc/src/miniupnpc_socketdef.h index 5986e58c76..5986e58c76 100644 --- a/thirdparty/miniupnpc/miniupnpc/miniupnpc_socketdef.h +++ b/thirdparty/miniupnpc/src/miniupnpc_socketdef.h diff --git a/thirdparty/miniupnpc/miniupnpc/miniupnpcstrings.h b/thirdparty/miniupnpc/src/miniupnpcstrings.h index 7b3d04074a..eefbc8dbdd 100644 --- a/thirdparty/miniupnpc/miniupnpc/miniupnpcstrings.h +++ b/thirdparty/miniupnpc/src/miniupnpcstrings.h @@ -4,7 +4,7 @@ #include "core/version.h" #define OS_STRING VERSION_NAME "/1.0" -#define MINIUPNPC_VERSION_STRING "2.2.2" +#define MINIUPNPC_VERSION_STRING "2.2.3" #if 0 /* according to "UPnP Device Architecture 1.0" */ diff --git a/thirdparty/miniupnpc/miniupnpc/miniwget.c b/thirdparty/miniupnpc/src/miniwget.c index d5b7970632..d5b7970632 100644 --- a/thirdparty/miniupnpc/miniupnpc/miniwget.c +++ b/thirdparty/miniupnpc/src/miniwget.c diff --git a/thirdparty/miniupnpc/miniupnpc/miniwget_private.h b/thirdparty/miniupnpc/src/miniwget_private.h index e4eaac8085..e4eaac8085 100644 --- a/thirdparty/miniupnpc/miniupnpc/miniwget_private.h +++ b/thirdparty/miniupnpc/src/miniwget_private.h diff --git a/thirdparty/miniupnpc/miniupnpc/minixml.c b/thirdparty/miniupnpc/src/minixml.c index ed2d3c759c..ed2d3c759c 100644 --- a/thirdparty/miniupnpc/miniupnpc/minixml.c +++ b/thirdparty/miniupnpc/src/minixml.c diff --git a/thirdparty/miniupnpc/miniupnpc/minixml.h b/thirdparty/miniupnpc/src/minixml.h index 2e60397388..2e60397388 100644 --- a/thirdparty/miniupnpc/miniupnpc/minixml.h +++ b/thirdparty/miniupnpc/src/minixml.h diff --git a/thirdparty/miniupnpc/miniupnpc/minixmlvalid.c b/thirdparty/miniupnpc/src/minixmlvalid.c index dad1488122..dad1488122 100644 --- a/thirdparty/miniupnpc/miniupnpc/minixmlvalid.c +++ b/thirdparty/miniupnpc/src/minixmlvalid.c diff --git a/thirdparty/miniupnpc/miniupnpc/portlistingparse.c b/thirdparty/miniupnpc/src/portlistingparse.c index 162cf8b7ec..162cf8b7ec 100644 --- a/thirdparty/miniupnpc/miniupnpc/portlistingparse.c +++ b/thirdparty/miniupnpc/src/portlistingparse.c diff --git a/thirdparty/miniupnpc/miniupnpc/receivedata.c b/thirdparty/miniupnpc/src/receivedata.c index 7f187f6e56..7f187f6e56 100644 --- a/thirdparty/miniupnpc/miniupnpc/receivedata.c +++ b/thirdparty/miniupnpc/src/receivedata.c diff --git a/thirdparty/miniupnpc/miniupnpc/receivedata.h b/thirdparty/miniupnpc/src/receivedata.h index c9fdc561f8..c9fdc561f8 100644 --- a/thirdparty/miniupnpc/miniupnpc/receivedata.h +++ b/thirdparty/miniupnpc/src/receivedata.h diff --git a/thirdparty/miniupnpc/miniupnpc/upnpcommands.c b/thirdparty/miniupnpc/src/upnpcommands.c index 1e1ee6786f..1e1ee6786f 100644 --- a/thirdparty/miniupnpc/miniupnpc/upnpcommands.c +++ b/thirdparty/miniupnpc/src/upnpcommands.c diff --git a/thirdparty/miniupnpc/miniupnpc/upnpdev.c b/thirdparty/miniupnpc/src/upnpdev.c index d89a9934c3..d89a9934c3 100644 --- a/thirdparty/miniupnpc/miniupnpc/upnpdev.c +++ b/thirdparty/miniupnpc/src/upnpdev.c diff --git a/thirdparty/miniupnpc/miniupnpc/upnpreplyparse.c b/thirdparty/miniupnpc/src/upnpreplyparse.c index 4d06f0585d..4d06f0585d 100644 --- a/thirdparty/miniupnpc/miniupnpc/upnpreplyparse.c +++ b/thirdparty/miniupnpc/src/upnpreplyparse.c diff --git a/thirdparty/miniupnpc/miniupnpc/win32_snprintf.h b/thirdparty/miniupnpc/src/win32_snprintf.h index 1fc284ecff..1fc284ecff 100644 --- a/thirdparty/miniupnpc/miniupnpc/win32_snprintf.h +++ b/thirdparty/miniupnpc/src/win32_snprintf.h diff --git a/thirdparty/pcre2/AUTHORS b/thirdparty/pcre2/AUTHORS index f001cb770e..bec8a1e5ad 100644 --- a/thirdparty/pcre2/AUTHORS +++ b/thirdparty/pcre2/AUTHORS @@ -5,10 +5,10 @@ Written by: Philip Hazel Email local part: Philip.Hazel Email domain: gmail.com -University of Cambridge Computing Service, +Retired from University of Cambridge Computing Service, Cambridge, England. -Copyright (c) 1997-2020 University of Cambridge +Copyright (c) 1997-2021 University of Cambridge All rights reserved @@ -19,7 +19,7 @@ Written by: Zoltan Herczeg Email local part: hzmester Emain domain: freemail.hu -Copyright(c) 2010-2020 Zoltan Herczeg +Copyright(c) 2010-2021 Zoltan Herczeg All rights reserved. @@ -30,7 +30,7 @@ Written by: Zoltan Herczeg Email local part: hzmester Emain domain: freemail.hu -Copyright(c) 2009-2020 Zoltan Herczeg +Copyright(c) 2009-2021 Zoltan Herczeg All rights reserved. #### diff --git a/thirdparty/pcre2/LICENCE b/thirdparty/pcre2/LICENCE index 155d073127..b1ec61be44 100644 --- a/thirdparty/pcre2/LICENCE +++ b/thirdparty/pcre2/LICENCE @@ -23,10 +23,10 @@ Written by: Philip Hazel Email local part: Philip.Hazel Email domain: gmail.com -University of Cambridge Computing Service, +Retired from University of Cambridge Computing Service, Cambridge, England. -Copyright (c) 1997-2020 University of Cambridge +Copyright (c) 1997-2021 University of Cambridge All rights reserved. @@ -37,7 +37,7 @@ Written by: Zoltan Herczeg Email local part: hzmester Email domain: freemail.hu -Copyright(c) 2010-2020 Zoltan Herczeg +Copyright(c) 2010-2021 Zoltan Herczeg All rights reserved. @@ -48,7 +48,7 @@ Written by: Zoltan Herczeg Email local part: hzmester Email domain: freemail.hu -Copyright(c) 2009-2020 Zoltan Herczeg +Copyright(c) 2009-2021 Zoltan Herczeg All rights reserved. diff --git a/thirdparty/pcre2/src/config.h b/thirdparty/pcre2/src/config.h index 10f4104790..a13593715e 100644 --- a/thirdparty/pcre2/src/config.h +++ b/thirdparty/pcre2/src/config.h @@ -85,8 +85,8 @@ sure both macros are undefined; an emulation function will then be used. */ /* Define to 1 if you have the `memmove' function. */ /* #undef HAVE_MEMMOVE */ -/* Define to 1 if you have the <memory.h> header file. */ -/* #undef HAVE_MEMORY_H */ +/* Define to 1 if you have the <minix/config.h> header file. */ +/* #undef HAVE_MINIX_CONFIG_H */ /* Define to 1 if you have the `mkostemp' function. */ /* #undef HAVE_MKOSTEMP */ @@ -103,12 +103,18 @@ sure both macros are undefined; an emulation function will then be used. */ /* Define to 1 if you have the <readline/readline.h> header file. */ /* #undef HAVE_READLINE_READLINE_H */ +/* Define to 1 if you have the `realpath' function. */ +/* #undef HAVE_REALPATH */ + /* Define to 1 if you have the `secure_getenv' function. */ /* #undef HAVE_SECURE_GETENV */ /* Define to 1 if you have the <stdint.h> header file. */ /* #undef HAVE_STDINT_H */ +/* Define to 1 if you have the <stdio.h> header file. */ +/* #undef HAVE_STDIO_H */ + /* Define to 1 if you have the <stdlib.h> header file. */ /* #undef HAVE_STDLIB_H */ @@ -136,6 +142,9 @@ sure both macros are undefined; an emulation function will then be used. */ /* Define to 1 if the compiler supports simple visibility declarations. */ /* #undef HAVE_VISIBILITY */ +/* Define to 1 if you have the <wchar.h> header file. */ +/* #undef HAVE_WCHAR_H */ + /* Define to 1 if you have the <windows.h> header file. */ /* #undef HAVE_WINDOWS_H */ @@ -224,7 +233,7 @@ sure both macros are undefined; an emulation function will then be used. */ #define PACKAGE_NAME "PCRE2" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "PCRE2 10.36" +#define PACKAGE_STRING "PCRE2 10.39" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "pcre2" @@ -233,7 +242,7 @@ sure both macros are undefined; an emulation function will then be used. */ #define PACKAGE_URL "" /* Define to the version of this package. */ -#define PACKAGE_VERSION "10.36" +#define PACKAGE_VERSION "10.39" /* The value of PARENS_NEST_LIMIT specifies the maximum depth of nested parentheses (of any kind) in a pattern. This limits the amount of system @@ -286,7 +295,9 @@ sure both macros are undefined; an emulation function will then be used. */ unless SUPPORT_JIT is also defined. */ /* #undef SLJIT_PROT_EXECUTABLE_ALLOCATOR */ -/* Define to 1 if you have the ANSI C header files. */ +/* Define to 1 if all of the C90 standard headers exist (not just the ones + required in a freestanding environment). This macro is provided for + backward compatibility; new code need not use it. */ /* #undef STDC_HEADERS */ /* Define to any value to enable support for Just-In-Time compiling. */ @@ -340,35 +351,91 @@ sure both macros are undefined; an emulation function will then be used. */ #ifndef _ALL_SOURCE # define _ALL_SOURCE 1 #endif +/* Enable general extensions on macOS. */ +#ifndef _DARWIN_C_SOURCE +# define _DARWIN_C_SOURCE 1 +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# define __EXTENSIONS__ 1 +#endif /* Enable GNU extensions on systems that have them. */ #ifndef _GNU_SOURCE # define _GNU_SOURCE 1 #endif -/* Enable threading extensions on Solaris. */ +/* Enable X/Open compliant socket functions that do not require linking + with -lxnet on HP-UX 11.11. */ +#ifndef _HPUX_ALT_XOPEN_SOCKET_API +# define _HPUX_ALT_XOPEN_SOCKET_API 1 +#endif +/* Identify the host operating system as Minix. + This macro does not affect the system headers' behavior. + A future release of Autoconf may stop defining this macro. */ +#ifndef _MINIX +/* # undef _MINIX */ +#endif +/* Enable general extensions on NetBSD. + Enable NetBSD compatibility extensions on Minix. */ +#ifndef _NETBSD_SOURCE +# define _NETBSD_SOURCE 1 +#endif +/* Enable OpenBSD compatibility extensions on NetBSD. + Oddly enough, this does nothing on OpenBSD. */ +#ifndef _OPENBSD_SOURCE +# define _OPENBSD_SOURCE 1 +#endif +/* Define to 1 if needed for POSIX-compatible behavior. */ +#ifndef _POSIX_SOURCE +/* # undef _POSIX_SOURCE */ +#endif +/* Define to 2 if needed for POSIX-compatible behavior. */ +#ifndef _POSIX_1_SOURCE +/* # undef _POSIX_1_SOURCE */ +#endif +/* Enable POSIX-compatible threading on Solaris. */ #ifndef _POSIX_PTHREAD_SEMANTICS # define _POSIX_PTHREAD_SEMANTICS 1 #endif +/* Enable extensions specified by ISO/IEC TS 18661-5:2014. */ +#ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__ +# define __STDC_WANT_IEC_60559_ATTRIBS_EXT__ 1 +#endif +/* Enable extensions specified by ISO/IEC TS 18661-1:2014. */ +#ifndef __STDC_WANT_IEC_60559_BFP_EXT__ +# define __STDC_WANT_IEC_60559_BFP_EXT__ 1 +#endif +/* Enable extensions specified by ISO/IEC TS 18661-2:2015. */ +#ifndef __STDC_WANT_IEC_60559_DFP_EXT__ +# define __STDC_WANT_IEC_60559_DFP_EXT__ 1 +#endif +/* Enable extensions specified by ISO/IEC TS 18661-4:2015. */ +#ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__ +# define __STDC_WANT_IEC_60559_FUNCS_EXT__ 1 +#endif +/* Enable extensions specified by ISO/IEC TS 18661-3:2015. */ +#ifndef __STDC_WANT_IEC_60559_TYPES_EXT__ +# define __STDC_WANT_IEC_60559_TYPES_EXT__ 1 +#endif +/* Enable extensions specified by ISO/IEC TR 24731-2:2010. */ +#ifndef __STDC_WANT_LIB_EXT2__ +# define __STDC_WANT_LIB_EXT2__ 1 +#endif +/* Enable extensions specified by ISO/IEC 24747:2009. */ +#ifndef __STDC_WANT_MATH_SPEC_FUNCS__ +# define __STDC_WANT_MATH_SPEC_FUNCS__ 1 +#endif /* Enable extensions on HP NonStop. */ #ifndef _TANDEM_SOURCE # define _TANDEM_SOURCE 1 #endif -/* Enable general extensions on Solaris. */ -#ifndef __EXTENSIONS__ -# define __EXTENSIONS__ 1 +/* Enable X/Open extensions. Define to 500 only if necessary + to make mbstate_t available. */ +#ifndef _XOPEN_SOURCE +/* # undef _XOPEN_SOURCE */ #endif /* Version number of package */ -#define VERSION "10.36" - -/* Define to 1 if on MINIX. */ -/* #undef _MINIX */ - -/* Define to 2 if the system does not provide POSIX.1 features except with - this defined. */ -/* #undef _POSIX_1_SOURCE */ - -/* Define to 1 if you need to in order for `stat' and other things to work. */ -/* #undef _POSIX_SOURCE */ +#define VERSION "10.39" /* Define to empty if `const' does not conform to ANSI C. */ /* #undef const */ diff --git a/thirdparty/pcre2/src/pcre2.h b/thirdparty/pcre2/src/pcre2.h index f204ec8180..90a97d9cb7 100644 --- a/thirdparty/pcre2/src/pcre2.h +++ b/thirdparty/pcre2/src/pcre2.h @@ -5,7 +5,7 @@ /* This is the public header file for the PCRE library, second API, to be #included by applications that call PCRE2 functions. - Copyright (c) 2016-2020 University of Cambridge + Copyright (c) 2016-2021 University of Cambridge ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -42,9 +42,9 @@ POSSIBILITY OF SUCH DAMAGE. /* The current PCRE version information. */ #define PCRE2_MAJOR 10 -#define PCRE2_MINOR 36 +#define PCRE2_MINOR 39 #define PCRE2_PRERELEASE -#define PCRE2_DATE 2020-12-04 +#define PCRE2_DATE 2021-10-29 /* When an application links to a PCRE DLL in Windows, the symbols that are imported have to be identified as such. When building PCRE2, the appropriate @@ -84,8 +84,8 @@ set, we ensure here that it has no effect. */ /* Have to include limits.h, stdlib.h, and inttypes.h to ensure that size_t and uint8_t, UCHAR_MAX, etc are defined. Some systems that do have inttypes.h do not have stdint.h, which is why we use inttypes.h, which according to the C -standard is a superset of stdint.h. If none of these headers are available, -the relevant values must be provided by some other means. */ +standard is a superset of stdint.h. If inttypes.h is not available the build +will break and the relevant values must be provided by some other means. */ #include <limits.h> #include <stdlib.h> @@ -152,6 +152,7 @@ D is inspected during pcre2_dfa_match() execution #define PCRE2_EXTRA_MATCH_LINE 0x00000008u /* C */ #define PCRE2_EXTRA_ESCAPED_CR_IS_LF 0x00000010u /* C */ #define PCRE2_EXTRA_ALT_BSUX 0x00000020u /* C */ +#define PCRE2_EXTRA_ALLOW_LOOKAROUND_BSK 0x00000040u /* C */ /* These are for pcre2_jit_compile(). */ @@ -311,6 +312,7 @@ pcre2_pattern_convert(). */ #define PCRE2_ERROR_SCRIPT_RUN_NOT_AVAILABLE 196 #define PCRE2_ERROR_TOO_MANY_CAPTURES 197 #define PCRE2_ERROR_CONDITION_ATOMIC_ASSERTION_EXPECTED 198 +#define PCRE2_ERROR_BACKSLASH_K_IN_LOOKAROUND 199 /* "Expected" matching error codes: no match and partial match. */ diff --git a/thirdparty/pcre2/src/pcre2_auto_possess.c b/thirdparty/pcre2/src/pcre2_auto_possess.c index c64cf856d1..e5e0895682 100644 --- a/thirdparty/pcre2/src/pcre2_auto_possess.c +++ b/thirdparty/pcre2/src/pcre2_auto_possess.c @@ -7,7 +7,7 @@ and semantics are as close as possible to those of the Perl 5 language. Written by Philip Hazel Original API code Copyright (c) 1997-2012 University of Cambridge - New API code Copyright (c) 2016-2020 University of Cambridge + New API code Copyright (c) 2016-2021 University of Cambridge ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -490,6 +490,7 @@ switch(c) list[2] = (uint32_t)(end - code); return end; } + return NULL; /* Opcode not accepted */ } @@ -1186,12 +1187,16 @@ for (;;) c = *repeat_opcode; if (c >= OP_CRSTAR && c <= OP_CRMINRANGE) { - /* end must not be NULL. */ - end = get_chr_property_list(code, utf, ucp, cb->fcc, list); + /* The return from get_chr_property_list() will never be NULL when + *code (aka c) is one of the three class opcodes. However, gcc with + -fanalyzer notes that a NULL return is possible, and grumbles. Hence we + put in a check. */ + end = get_chr_property_list(code, utf, ucp, cb->fcc, list); list[1] = (c & 1) == 0; - if (compare_opcodes(end, utf, ucp, cb, list, end, &rec_limit)) + if (end != NULL && + compare_opcodes(end, utf, ucp, cb, list, end, &rec_limit)) { switch (c) { diff --git a/thirdparty/pcre2/src/pcre2_compile.c b/thirdparty/pcre2/src/pcre2_compile.c index e811f12f02..383159be76 100644 --- a/thirdparty/pcre2/src/pcre2_compile.c +++ b/thirdparty/pcre2/src/pcre2_compile.c @@ -7,7 +7,7 @@ and semantics are as close as possible to those of the Perl 5 language. Written by Philip Hazel Original API code Copyright (c) 1997-2012 University of Cambridge - New API code Copyright (c) 2016-2020 University of Cambridge + New API code Copyright (c) 2016-2021 University of Cambridge ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -137,7 +137,7 @@ static BOOL static int check_lookbehinds(uint32_t *, uint32_t **, parsed_recurse_check *, - compile_block *); + compile_block *, int *); /************************************************* @@ -782,12 +782,15 @@ are allowed. */ #define PUBLIC_COMPILE_EXTRA_OPTIONS \ (PUBLIC_LITERAL_COMPILE_EXTRA_OPTIONS| \ PCRE2_EXTRA_ALLOW_SURROGATE_ESCAPES|PCRE2_EXTRA_BAD_ESCAPE_IS_LITERAL| \ - PCRE2_EXTRA_ESCAPED_CR_IS_LF|PCRE2_EXTRA_ALT_BSUX) + PCRE2_EXTRA_ESCAPED_CR_IS_LF|PCRE2_EXTRA_ALT_BSUX| \ + PCRE2_EXTRA_ALLOW_LOOKAROUND_BSK) /* Compile time error code numbers. They are given names so that they can more easily be tracked. When a new number is added, the tables called eint1 and eint2 in pcre2posix.c may need to be updated, and a new error text must be -added to compile_error_texts in pcre2_error.c. */ +added to compile_error_texts in pcre2_error.c. Also, the error codes in +pcre2.h.in must be updated - their values are exactly 100 greater than these +values. */ enum { ERR0 = COMPILE_ERROR_BASE, ERR1, ERR2, ERR3, ERR4, ERR5, ERR6, ERR7, ERR8, ERR9, ERR10, @@ -799,7 +802,7 @@ enum { ERR0 = COMPILE_ERROR_BASE, ERR61, ERR62, ERR63, ERR64, ERR65, ERR66, ERR67, ERR68, ERR69, ERR70, ERR71, ERR72, ERR73, ERR74, ERR75, ERR76, ERR77, ERR78, ERR79, ERR80, ERR81, ERR82, ERR83, ERR84, ERR85, ERR86, ERR87, ERR88, ERR89, ERR90, - ERR91, ERR92, ERR93, ERR94, ERR95, ERR96, ERR97, ERR98 }; + ERR91, ERR92, ERR93, ERR94, ERR95, ERR96, ERR97, ERR98, ERR99 }; /* This is a table of start-of-pattern options such as (*UTF) and settings such as (*LIMIT_MATCH=nnnn) and (*CRLF). For completeness and backward @@ -1398,32 +1401,47 @@ static BOOL read_repeat_counts(PCRE2_SPTR *ptrptr, PCRE2_SPTR ptrend, uint32_t *minp, uint32_t *maxp, int *errorcodeptr) { -PCRE2_SPTR p = *ptrptr; +PCRE2_SPTR p; BOOL yield = FALSE; +BOOL had_comma = FALSE; int32_t min = 0; int32_t max = REPEAT_UNLIMITED; /* This value is larger than MAX_REPEAT_COUNT */ -/* NB read_number() initializes the error code to zero. The only error is for a -number that is too big. */ +/* Check the syntax */ + +*errorcodeptr = 0; +for (p = *ptrptr;; p++) + { + uint32_t c; + if (p >= ptrend) return FALSE; + c = *p; + if (IS_DIGIT(c)) continue; + if (c == CHAR_RIGHT_CURLY_BRACKET) break; + if (c == CHAR_COMMA) + { + if (had_comma) return FALSE; + had_comma = TRUE; + } + else return FALSE; + } + +/* The only error from read_number() is for a number that is too big. */ +p = *ptrptr; if (!read_number(&p, ptrend, -1, MAX_REPEAT_COUNT, ERR5, &min, errorcodeptr)) goto EXIT; -if (p >= ptrend) goto EXIT; - if (*p == CHAR_RIGHT_CURLY_BRACKET) { p++; max = min; } - else { - if (*p++ != CHAR_COMMA || p >= ptrend) goto EXIT; - if (*p != CHAR_RIGHT_CURLY_BRACKET) + if (*(++p) != CHAR_RIGHT_CURLY_BRACKET) { if (!read_number(&p, ptrend, -1, MAX_REPEAT_COUNT, ERR5, &max, - errorcodeptr) || p >= ptrend || *p != CHAR_RIGHT_CURLY_BRACKET) + errorcodeptr)) goto EXIT; if (max < min) { @@ -1438,11 +1456,10 @@ yield = TRUE; if (minp != NULL) *minp = (uint32_t)min; if (maxp != NULL) *maxp = (uint32_t)max; -/* Update the pattern pointer on success, or after an error, but not when -the result is "not a repeat quantifier". */ +/* Update the pattern pointer */ EXIT: -if (yield || *errorcodeptr != 0) *ptrptr = p; +*ptrptr = p; return yield; } @@ -1776,19 +1793,23 @@ else { oldptr = ptr; ptr--; /* Back to the digit */ - if (!read_number(&ptr, ptrend, -1, INT_MAX/10 - 1, ERR61, &s, - errorcodeptr)) - break; - /* \1 to \9 are always back references. \8x and \9x are too; \1x to \7x + /* As we know we are at a digit, the only possible error from + read_number() is a number that is too large to be a group number. In this + case we fall through handle this as not a group reference. If we have + read a small enough number, check for a back reference. + + \1 to \9 are always back references. \8x and \9x are too; \1x to \7x are octal escapes if there are not that many previous captures. */ - if (s < 10 || oldptr[-1] >= CHAR_8 || s <= (int)cb->bracount) + if (read_number(&ptr, ptrend, -1, INT_MAX/10 - 1, 0, &s, errorcodeptr) && + (s < 10 || oldptr[-1] >= CHAR_8 || s <= (int)cb->bracount)) { if (s > (int)MAX_GROUP_NUMBER) *errorcodeptr = ERR61; else escape = -s; /* Indicates a back reference */ break; } + ptr = oldptr; /* Put the pointer back and fall through */ } @@ -7781,6 +7802,16 @@ for (;; pptr++) } #endif + /* \K is forbidden in lookarounds since 10.38 because that's what Perl has + done. However, there's an option, in case anyone was relying on it. */ + + if (cb->assert_depth > 0 && meta_arg == ESC_K && + (cb->cx->extra_options & PCRE2_EXTRA_ALLOW_LOOKAROUND_BSK) == 0) + { + *errorcodeptr = ERR99; + return 0; + } + /* For the rest (including \X when Unicode is supported - if not it's faulted at parse time), the OP value is the escape value when PCRE2_UCP is not set; if it is set, these escapes do not show up here because they are @@ -9130,7 +9161,7 @@ for (;; pptr++) case META_LOOKAHEAD: case META_LOOKAHEADNOT: case META_LOOKAHEAD_NA: - *errcodeptr = check_lookbehinds(pptr + 1, &pptr, recurses, cb); + *errcodeptr = check_lookbehinds(pptr + 1, &pptr, recurses, cb, lcptr); if (*errcodeptr != 0) return -1; /* Ignore any qualifiers that follow a lookahead assertion. */ @@ -9470,16 +9501,16 @@ Arguments retptr if not NULL, return the ket pointer here recurses chain of recurse_check to catch mutual recursion cb points to the compile block + lcptr points to loop counter Returns: 0 on success, or an errorcode (cb->erroroffset will be set) */ static int check_lookbehinds(uint32_t *pptr, uint32_t **retptr, - parsed_recurse_check *recurses, compile_block *cb) + parsed_recurse_check *recurses, compile_block *cb, int *lcptr) { int errorcode = 0; -int loopcount = 0; int nestlevel = 0; cb->erroroffset = PCRE2_UNSET; @@ -9605,7 +9636,7 @@ for (; *pptr != META_END; pptr++) case META_LOOKBEHIND: case META_LOOKBEHINDNOT: case META_LOOKBEHIND_NA: - if (!set_lookbehind_lengths(&pptr, &errorcode, &loopcount, recurses, cb)) + if (!set_lookbehind_lengths(&pptr, &errorcode, lcptr, recurses, cb)) return errorcode; break; } @@ -10060,7 +10091,8 @@ lengths. */ if (has_lookbehind) { - errorcode = check_lookbehinds(cb.parsed_pattern, NULL, NULL, &cb); + int loopcount = 0; + errorcode = check_lookbehinds(cb.parsed_pattern, NULL, NULL, &cb, &loopcount); if (errorcode != 0) goto HAD_CB_ERROR; } diff --git a/thirdparty/pcre2/src/pcre2_dfa_match.c b/thirdparty/pcre2/src/pcre2_dfa_match.c index 625695b7cb..060dc7669a 100644 --- a/thirdparty/pcre2/src/pcre2_dfa_match.c +++ b/thirdparty/pcre2/src/pcre2_dfa_match.c @@ -7,7 +7,7 @@ and semantics are as close as possible to those of the Perl 5 language. Written by Philip Hazel Original API code Copyright (c) 1997-2012 University of Cambridge - New API code Copyright (c) 2016-2020 University of Cambridge + New API code Copyright (c) 2016-2021 University of Cambridge ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -3256,8 +3256,8 @@ BOOL has_first_cu = FALSE; BOOL has_req_cu = FALSE; #if PCRE2_CODE_UNIT_WIDTH == 8 -BOOL memchr_not_found_first_cu = FALSE; -BOOL memchr_not_found_first_cu2 = FALSE; +PCRE2_SPTR memchr_found_first_cu = NULL; +PCRE2_SPTR memchr_found_first_cu2 = NULL; #endif PCRE2_UCHAR first_cu = 0; @@ -3648,13 +3648,7 @@ for (;;) } } - /* Not anchored. Advance to a unique first code unit if there is one. In - 8-bit mode, the use of memchr() gives a big speed up, even though we have - to call it twice in caseless mode, in order to find the earliest occurrence - of the character in either of its cases. If a call to memchr() that - searches the rest of the subject fails to find one case, remember that in - order not to keep on repeating the search. This can make a huge difference - when the strings are very long and only one case is present. */ + /* Not anchored. Advance to a unique first code unit if there is one. */ else { @@ -3662,43 +3656,68 @@ for (;;) { if (first_cu != first_cu2) /* Caseless */ { + /* In 16-bit and 32_bit modes we have to do our own search, so can + look for both cases at once. */ + #if PCRE2_CODE_UNIT_WIDTH != 8 PCRE2_UCHAR smc; while (start_match < end_subject && (smc = UCHAR21TEST(start_match)) != first_cu && - smc != first_cu2) + smc != first_cu2) start_match++; +#else + /* In 8-bit mode, the use of memchr() gives a big speed up, even + though we have to call it twice in order to find the earliest + occurrence of the code unit in either of its cases. Caching is used + to remember the positions of previously found code units. This can + make a huge difference when the strings are very long and only one + case is actually present. */ -#else /* 8-bit code units */ PCRE2_SPTR pp1 = NULL; PCRE2_SPTR pp2 = NULL; - PCRE2_SIZE cu2size = end_subject - start_match; + PCRE2_SIZE searchlength = end_subject - start_match; - if (!memchr_not_found_first_cu) + /* If we haven't got a previously found position for first_cu, or if + the current starting position is later, we need to do a search. If + the code unit is not found, set it to the end. */ + + if (memchr_found_first_cu == NULL || + start_match > memchr_found_first_cu) { - pp1 = memchr(start_match, first_cu, end_subject - start_match); - if (pp1 == NULL) memchr_not_found_first_cu = TRUE; - else cu2size = pp1 - start_match; + pp1 = memchr(start_match, first_cu, searchlength); + memchr_found_first_cu = (pp1 == NULL)? end_subject : pp1; } - /* If pp1 is not NULL, we have arranged to search only as far as pp1, - to see if the other case is earlier, so we can set "not found" only - when both searches have returned NULL. */ + /* If the start is before a previously found position, use the + previous position, or NULL if a previous search failed. */ + + else pp1 = (memchr_found_first_cu == end_subject)? NULL : + memchr_found_first_cu; - if (!memchr_not_found_first_cu2) + /* Do the same thing for the other case. */ + + if (memchr_found_first_cu2 == NULL || + start_match > memchr_found_first_cu2) { - pp2 = memchr(start_match, first_cu2, cu2size); - memchr_not_found_first_cu2 = (pp2 == NULL && pp1 == NULL); + pp2 = memchr(start_match, first_cu2, searchlength); + memchr_found_first_cu2 = (pp2 == NULL)? end_subject : pp2; } + else pp2 = (memchr_found_first_cu2 == end_subject)? NULL : + memchr_found_first_cu2; + + /* Set the start to the end of the subject if neither case was found. + Otherwise, use the earlier found point. */ + if (pp1 == NULL) start_match = (pp2 == NULL)? end_subject : pp2; else start_match = (pp2 == NULL || pp1 < pp2)? pp1 : pp2; -#endif + +#endif /* 8-bit handling */ } - /* The caseful case */ + /* The caseful case is much simpler. */ else { diff --git a/thirdparty/pcre2/src/pcre2_error.c b/thirdparty/pcre2/src/pcre2_error.c index c61648cb7f..3dee63d0db 100644 --- a/thirdparty/pcre2/src/pcre2_error.c +++ b/thirdparty/pcre2/src/pcre2_error.c @@ -7,7 +7,7 @@ and semantics are as close as possible to those of the Perl 5 language. Written by Philip Hazel Original API code Copyright (c) 1997-2012 University of Cambridge - New API code Copyright (c) 2016-2019 University of Cambridge + New API code Copyright (c) 2016-2021 University of Cambridge ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -186,6 +186,7 @@ static const unsigned char compile_error_texts[] = "script runs require Unicode support, which this version of PCRE2 does not have\0" "too many capturing groups (maximum 65535)\0" "atomic assertion expected after (?( or (?(?C)\0" + "\\K is not allowed in lookarounds (but see PCRE2_EXTRA_ALLOW_LOOKAROUND_BSK)\0" ; /* Match-time and UTF error texts are in the same format. */ diff --git a/thirdparty/pcre2/src/pcre2_jit_compile.c b/thirdparty/pcre2/src/pcre2_jit_compile.c index 1977d28aa5..db2ce65598 100644 --- a/thirdparty/pcre2/src/pcre2_jit_compile.c +++ b/thirdparty/pcre2/src/pcre2_jit_compile.c @@ -1226,7 +1226,7 @@ while (cc < ccend) return TRUE; } -#define EARLY_FAIL_ENHANCE_MAX (1 + 1) +#define EARLY_FAIL_ENHANCE_MAX (1 + 3) /* start: @@ -1236,23 +1236,28 @@ start: return: current number of iterators enhanced with fast fail */ -static int detect_early_fail(compiler_common *common, PCRE2_SPTR cc, int *private_data_start, sljit_s32 depth, int start) +static int detect_early_fail(compiler_common *common, PCRE2_SPTR cc, int *private_data_start, + sljit_s32 depth, int start, BOOL fast_forward_allowed) { +PCRE2_SPTR begin = cc; PCRE2_SPTR next_alt; PCRE2_SPTR end; PCRE2_SPTR accelerated_start; +BOOL prev_fast_forward_allowed; int result = 0; int count; -BOOL fast_forward_allowed = TRUE; SLJIT_ASSERT(*cc == OP_ONCE || *cc == OP_BRA || *cc == OP_CBRA); SLJIT_ASSERT(*cc != OP_CBRA || common->optimized_cbracket[GET2(cc, 1 + LINK_SIZE)] != 0); SLJIT_ASSERT(start < EARLY_FAIL_ENHANCE_MAX); +next_alt = cc + GET(cc, 1); +if (*next_alt == OP_ALT) + fast_forward_allowed = FALSE; + do { count = start; - next_alt = cc + GET(cc, 1); cc += 1 + LINK_SIZE + ((*cc == OP_CBRA) ? IMM2_SIZE : 0); while (TRUE) @@ -1475,31 +1480,20 @@ do case OP_CBRA: end = cc + GET(cc, 1); - if (*end == OP_KET && PRIVATE_DATA(end) == 0) - { - if (*cc == OP_CBRA) - { - if (common->optimized_cbracket[GET2(cc, 1 + LINK_SIZE)] == 0) - break; - cc += IMM2_SIZE; - } - - cc += 1 + LINK_SIZE; - continue; - } - + prev_fast_forward_allowed = fast_forward_allowed; fast_forward_allowed = FALSE; if (depth >= 4) break; end = bracketend(cc) - (1 + LINK_SIZE); - if (*end != OP_KET || PRIVATE_DATA(end) != 0) + if (*end != OP_KET || (*cc == OP_CBRA && common->optimized_cbracket[GET2(cc, 1 + LINK_SIZE)] == 0)) break; - if (*cc == OP_CBRA && common->optimized_cbracket[GET2(cc, 1 + LINK_SIZE)] == 0) - break; + count = detect_early_fail(common, cc, private_data_start, depth + 1, count, prev_fast_forward_allowed); + + if (PRIVATE_DATA(cc) != 0) + common->private_data_ptrs[begin - common->start] = 1; - count = detect_early_fail(common, cc, private_data_start, depth + 1, count); if (count < EARLY_FAIL_ENHANCE_MAX) { cc = end + (1 + LINK_SIZE); @@ -1521,7 +1515,7 @@ do { count++; - if (fast_forward_allowed && *next_alt == OP_KET) + if (fast_forward_allowed) { common->fast_forward_bc_ptr = accelerated_start; common->private_data_ptrs[(accelerated_start + 1) - common->start] = ((*private_data_start) << 3) | type_skip; @@ -1555,6 +1549,8 @@ do return EARLY_FAIL_ENHANCE_MAX; } + /* Cannot be part of a repeat. */ + common->private_data_ptrs[begin - common->start] = 1; count++; if (count < EARLY_FAIL_ENHANCE_MAX) @@ -1569,8 +1565,8 @@ do else if (result < count) result = count; - fast_forward_allowed = FALSE; cc = next_alt; + next_alt = cc + GET(cc, 1); } while (*cc == OP_ALT); @@ -1620,11 +1616,12 @@ sljit_sw length = end - begin; sljit_s32 min, max, i; /* Detect fixed iterations first. */ -if (end[-(1 + LINK_SIZE)] != OP_KET) +if (end[-(1 + LINK_SIZE)] != OP_KET || PRIVATE_DATA(begin) != 0) return FALSE; -/* Already detected repeat. */ -if (common->private_data_ptrs[end - common->start - LINK_SIZE] != 0) +/* /(?:AB){4,6}/ is currently converted to /(?:AB){3}(?AB){1,3}/ + * Skip the check of the second part. */ +if (PRIVATE_DATA(end - LINK_SIZE) == 0) return TRUE; next = end; @@ -1763,6 +1760,7 @@ while (cc < ccend) if (private_data_ptr > SLJIT_MAX_LOCAL_SIZE) break; + /* When the bracket is prefixed by a zero iteration, skip the repeat check (at this point). */ if (repeat_check && (*cc == OP_ONCE || *cc == OP_BRA || *cc == OP_CBRA || *cc == OP_COND)) { if (detect_repeat(common, cc)) @@ -1813,6 +1811,7 @@ while (cc < ccend) case OP_COND: /* Might be a hidden SCOND. */ + common->private_data_ptrs[cc - common->start] = 0; alternative = cc + GET(cc, 1); if (*alternative == OP_KETRMAX || *alternative == OP_KETRMIN) { @@ -4203,9 +4202,6 @@ TMP2 is not used. Otherwise TMP2 must contain the start of the subject buffer, and it is destroyed. Does not modify STR_PTR for invalid character sequences. */ DEFINE_COMPILER; -SLJIT_UNUSED_ARG(backtracks); -SLJIT_UNUSED_ARG(must_be_valid); - #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 struct sljit_jump *jump; #endif @@ -4279,6 +4275,10 @@ if (common->invalid_utf && !must_be_valid) } #endif /* PCRE2_CODE_UNIT_WIDTH == [8|16|32] */ #endif /* SUPPORT_UNICODE */ + +SLJIT_UNUSED_ARG(backtracks); +SLJIT_UNUSED_ARG(must_be_valid); + OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); } @@ -8141,7 +8141,7 @@ switch(type) } else OP2(SLJIT_AND32 | SLJIT_SET_Z, SLJIT_UNUSED, 0, SLJIT_MEM1(ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, options), SLJIT_IMM, PCRE2_NOTEOL); - add_jump(compiler, backtracks, JUMP(SLJIT_NOT_ZERO32)); + add_jump(compiler, backtracks, JUMP(SLJIT_NOT_ZERO)); if (!common->endonly) compile_simple_assertion_matchingpath(common, OP_EODN, cc, backtracks); @@ -8161,7 +8161,7 @@ switch(type) } else OP2(SLJIT_AND32 | SLJIT_SET_Z, SLJIT_UNUSED, 0, SLJIT_MEM1(ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, options), SLJIT_IMM, PCRE2_NOTEOL); - add_jump(compiler, backtracks, JUMP(SLJIT_NOT_ZERO32)); + add_jump(compiler, backtracks, JUMP(SLJIT_NOT_ZERO)); check_partial(common, FALSE); jump[0] = JUMP(SLJIT_JUMP); JUMPHERE(jump[1]); @@ -8201,14 +8201,14 @@ switch(type) OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, begin)); add_jump(compiler, backtracks, CMP(SLJIT_GREATER, STR_PTR, 0, TMP1, 0)); OP2(SLJIT_AND32 | SLJIT_SET_Z, SLJIT_UNUSED, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, options), SLJIT_IMM, PCRE2_NOTBOL); - add_jump(compiler, backtracks, JUMP(SLJIT_NOT_ZERO32)); + add_jump(compiler, backtracks, JUMP(SLJIT_NOT_ZERO)); } else { OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, begin)); add_jump(compiler, backtracks, CMP(SLJIT_GREATER, STR_PTR, 0, TMP1, 0)); OP2(SLJIT_AND32 | SLJIT_SET_Z, SLJIT_UNUSED, 0, SLJIT_MEM1(ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, options), SLJIT_IMM, PCRE2_NOTBOL); - add_jump(compiler, backtracks, JUMP(SLJIT_NOT_ZERO32)); + add_jump(compiler, backtracks, JUMP(SLJIT_NOT_ZERO)); } return cc; @@ -8227,7 +8227,7 @@ switch(type) jump[1] = CMP(SLJIT_GREATER, STR_PTR, 0, TMP2, 0); OP2(SLJIT_AND32 | SLJIT_SET_Z, SLJIT_UNUSED, 0, SLJIT_MEM1(ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, options), SLJIT_IMM, PCRE2_NOTBOL); } - add_jump(compiler, backtracks, JUMP(SLJIT_NOT_ZERO32)); + add_jump(compiler, backtracks, JUMP(SLJIT_NOT_ZERO)); jump[0] = JUMP(SLJIT_JUMP); JUMPHERE(jump[1]); @@ -9581,11 +9581,11 @@ free_stack(common, callout_arg_size); /* Check return value. */ OP2(SLJIT_SUB32 | SLJIT_SET_Z | SLJIT_SET_SIG_GREATER, SLJIT_UNUSED, 0, SLJIT_RETURN_REG, 0, SLJIT_IMM, 0); -add_jump(compiler, &backtrack->topbacktracks, JUMP(SLJIT_SIG_GREATER32)); +add_jump(compiler, &backtrack->topbacktracks, JUMP(SLJIT_SIG_GREATER)); if (common->abort_label == NULL) - add_jump(compiler, &common->abort, JUMP(SLJIT_NOT_EQUAL32) /* SIG_LESS */); + add_jump(compiler, &common->abort, JUMP(SLJIT_NOT_EQUAL) /* SIG_LESS */); else - JUMPTO(SLJIT_NOT_EQUAL32 /* SIG_LESS */, common->abort_label); + JUMPTO(SLJIT_NOT_EQUAL /* SIG_LESS */, common->abort_label); return cc + callout_length; } @@ -11232,7 +11232,7 @@ early_fail_type = (early_fail_ptr & 0x7); early_fail_ptr >>= 3; /* During recursion, these optimizations are disabled. */ -if (common->early_fail_start_ptr == 0) +if (common->early_fail_start_ptr == 0 && common->fast_forward_bc_ptr == NULL) { early_fail_ptr = 0; early_fail_type = type_skip; @@ -13661,9 +13661,11 @@ if (!common->private_data_ptrs) memset(common->private_data_ptrs, 0, total_length * sizeof(sljit_s32)); private_data_size = common->cbra_ptr + (re->top_bracket + 1) * sizeof(sljit_sw); -set_private_data_ptrs(common, &private_data_size, ccend); + if ((re->overall_options & PCRE2_ANCHORED) == 0 && (re->overall_options & PCRE2_NO_START_OPTIMIZE) == 0 && !common->has_skip_in_assert_back) - detect_early_fail(common, common->start, &private_data_size, 0, 0); + detect_early_fail(common, common->start, &private_data_size, 0, 0, TRUE); + +set_private_data_ptrs(common, &private_data_size, ccend); SLJIT_ASSERT(common->early_fail_start_ptr <= common->early_fail_end_ptr); @@ -14130,6 +14132,10 @@ PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION pcre2_jit_compile(pcre2_code *code, uint32_t options) { pcre2_real_code *re = (pcre2_real_code *)code; +#ifdef SUPPORT_JIT +executable_functions *functions; +static int executable_allocator_is_working = 0; +#endif if (code == NULL) return PCRE2_ERROR_NULL; @@ -14164,8 +14170,7 @@ actions are needed: */ #ifdef SUPPORT_JIT -executable_functions *functions = (executable_functions *)re->executable_jit; -static int executable_allocator_is_working = 0; +functions = (executable_functions *)re->executable_jit; #endif if ((options & PCRE2_JIT_INVALID_UTF) != 0) diff --git a/thirdparty/pcre2/src/pcre2_jit_simd_inc.h b/thirdparty/pcre2/src/pcre2_jit_simd_inc.h index 5673d338c0..aa029cce38 100644 --- a/thirdparty/pcre2/src/pcre2_jit_simd_inc.h +++ b/thirdparty/pcre2/src/pcre2_jit_simd_inc.h @@ -39,7 +39,29 @@ POSSIBILITY OF SUCH DAMAGE. ----------------------------------------------------------------------------- */ -#if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86) && !(defined SUPPORT_VALGRIND) +#if !(defined SUPPORT_VALGRIND) + +#if ((defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86) \ + || (defined SLJIT_CONFIG_S390X && SLJIT_CONFIG_S390X)) + +typedef enum { + vector_compare_match1, + vector_compare_match1i, + vector_compare_match2, +} vector_compare_type; + +static SLJIT_INLINE sljit_u32 max_fast_forward_char_pair_offset(void) +{ +#if PCRE2_CODE_UNIT_WIDTH == 8 +return 15; +#elif PCRE2_CODE_UNIT_WIDTH == 16 +return 7; +#elif PCRE2_CODE_UNIT_WIDTH == 32 +return 3; +#else +#error "Unsupported unit width" +#endif +} #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 static struct sljit_jump *jump_if_utf_char_start(struct sljit_compiler *compiler, sljit_s32 reg) @@ -56,6 +78,10 @@ return CMP(SLJIT_NOT_EQUAL, reg, 0, SLJIT_IMM, 0xdc00); } #endif +#endif /* SLJIT_CONFIG_X86 || SLJIT_CONFIG_S390X */ + +#if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86) + static sljit_s32 character_to_int32(PCRE2_UCHAR chr) { sljit_u32 value = chr; @@ -97,13 +123,7 @@ instruction[4] = (sljit_u8)offset; sljit_emit_op_custom(compiler, instruction, 5); } -typedef enum { - sse2_compare_match1, - sse2_compare_match1i, - sse2_compare_match2, -} sse2_compare_type; - -static void fast_forward_char_pair_sse2_compare(struct sljit_compiler *compiler, sse2_compare_type compare_type, +static void fast_forward_char_pair_sse2_compare(struct sljit_compiler *compiler, vector_compare_type compare_type, int step, sljit_s32 dst_ind, sljit_s32 cmp1_ind, sljit_s32 cmp2_ind, sljit_s32 tmp_ind) { sljit_u8 instruction[4]; @@ -112,11 +132,11 @@ instruction[1] = 0x0f; SLJIT_ASSERT(step >= 0 && step <= 3); -if (compare_type != sse2_compare_match2) +if (compare_type != vector_compare_match2) { if (step == 0) { - if (compare_type == sse2_compare_match1i) + if (compare_type == vector_compare_match1i) { /* POR xmm1, xmm2/m128 */ /* instruction[0] = 0x66; */ @@ -185,14 +205,14 @@ switch (step) static void fast_forward_char_simd(compiler_common *common, PCRE2_UCHAR char1, PCRE2_UCHAR char2, sljit_s32 offset) { DEFINE_COMPILER; +sljit_u8 instruction[8]; struct sljit_label *start; #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 struct sljit_label *restart; #endif struct sljit_jump *quit; struct sljit_jump *partial_quit[2]; -sse2_compare_type compare_type = sse2_compare_match1; -sljit_u8 instruction[8]; +vector_compare_type compare_type = vector_compare_match1; sljit_s32 tmp1_reg_ind = sljit_get_register_index(TMP1); sljit_s32 str_ptr_reg_ind = sljit_get_register_index(STR_PTR); sljit_s32 data_ind = 0; @@ -207,12 +227,12 @@ SLJIT_UNUSED_ARG(offset); if (char1 != char2) { bit = char1 ^ char2; - compare_type = sse2_compare_match1i; + compare_type = vector_compare_match1i; if (!is_powerof2(bit)) { bit = 0; - compare_type = sse2_compare_match2; + compare_type = vector_compare_match2; } } @@ -349,11 +369,11 @@ if (common->utf && offset > 0) static jump_list *fast_requested_char_simd(compiler_common *common, PCRE2_UCHAR char1, PCRE2_UCHAR char2) { DEFINE_COMPILER; +sljit_u8 instruction[8]; struct sljit_label *start; struct sljit_jump *quit; jump_list *not_found = NULL; -sse2_compare_type compare_type = sse2_compare_match1; -sljit_u8 instruction[8]; +vector_compare_type compare_type = vector_compare_match1; sljit_s32 tmp1_reg_ind = sljit_get_register_index(TMP1); sljit_s32 str_ptr_reg_ind = sljit_get_register_index(STR_PTR); sljit_s32 data_ind = 0; @@ -366,12 +386,12 @@ int i; if (char1 != char2) { bit = char1 ^ char2; - compare_type = sse2_compare_match1i; + compare_type = vector_compare_match1i; if (!is_powerof2(bit)) { bit = 0; - compare_type = sse2_compare_match2; + compare_type = vector_compare_match2; } } @@ -476,27 +496,15 @@ return not_found; #ifndef _WIN64 -static SLJIT_INLINE sljit_u32 max_fast_forward_char_pair_offset(void) -{ -#if PCRE2_CODE_UNIT_WIDTH == 8 -return 15; -#elif PCRE2_CODE_UNIT_WIDTH == 16 -return 7; -#elif PCRE2_CODE_UNIT_WIDTH == 32 -return 3; -#else -#error "Unsupported unit width" -#endif -} - #define JIT_HAS_FAST_FORWARD_CHAR_PAIR_SIMD (sljit_has_cpu_feature(SLJIT_HAS_SSE2)) static void fast_forward_char_pair_simd(compiler_common *common, sljit_s32 offs1, PCRE2_UCHAR char1a, PCRE2_UCHAR char1b, sljit_s32 offs2, PCRE2_UCHAR char2a, PCRE2_UCHAR char2b) { DEFINE_COMPILER; -sse2_compare_type compare1_type = sse2_compare_match1; -sse2_compare_type compare2_type = sse2_compare_match1; +sljit_u8 instruction[8]; +vector_compare_type compare1_type = vector_compare_match1; +vector_compare_type compare2_type = vector_compare_match1; sljit_u32 bit1 = 0; sljit_u32 bit2 = 0; sljit_u32 diff = IN_UCHARS(offs1 - offs2); @@ -516,7 +524,6 @@ struct sljit_label *start; struct sljit_label *restart; #endif struct sljit_jump *jump[2]; -sljit_u8 instruction[8]; int i; SLJIT_ASSERT(common->mode == PCRE2_JIT_COMPLETE && offs1 > offs2); @@ -549,13 +556,13 @@ else bit1 = char1a ^ char1b; if (is_powerof2(bit1)) { - compare1_type = sse2_compare_match1i; + compare1_type = vector_compare_match1i; OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, character_to_int32(char1a | bit1)); OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, character_to_int32(bit1)); } else { - compare1_type = sse2_compare_match2; + compare1_type = vector_compare_match2; bit1 = 0; OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, character_to_int32(char1a)); OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, character_to_int32(char1b)); @@ -578,13 +585,13 @@ else bit2 = char2a ^ char2b; if (is_powerof2(bit2)) { - compare2_type = sse2_compare_match1i; + compare2_type = vector_compare_match1i; OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, character_to_int32(char2a | bit2)); OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, character_to_int32(bit2)); } else { - compare2_type = sse2_compare_match2; + compare2_type = vector_compare_match2; bit2 = 0; OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, character_to_int32(char2a)); OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, character_to_int32(char2b)); @@ -731,9 +738,6 @@ OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0); add_jump(compiler, &common->failed_match, CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0)); -if (common->match_end_ptr != 0) - OP1(SLJIT_MOV, STR_END, 0, SLJIT_MEM1(SLJIT_SP), common->match_end_ptr); - #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 if (common->utf) { @@ -760,7 +764,7 @@ if (common->match_end_ptr != 0) #undef SSE2_COMPARE_TYPE_INDEX -#endif /* SLJIT_CONFIG_X86 && !SUPPORT_VALGRIND */ +#endif /* SLJIT_CONFIG_X86 */ #if (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64 && (defined __ARM_NEON || defined __ARM_NEON__)) @@ -1121,3 +1125,734 @@ JUMPHERE(partial_quit); } #endif /* SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64 */ + +#if (defined SLJIT_CONFIG_S390X && SLJIT_CONFIG_S390X) + +#if PCRE2_CODE_UNIT_WIDTH == 8 +#define VECTOR_ELEMENT_SIZE 0 +#elif PCRE2_CODE_UNIT_WIDTH == 16 +#define VECTOR_ELEMENT_SIZE 1 +#elif PCRE2_CODE_UNIT_WIDTH == 32 +#define VECTOR_ELEMENT_SIZE 2 +#else +#error "Unsupported unit width" +#endif + +static void load_from_mem_vector(struct sljit_compiler *compiler, BOOL vlbb, sljit_s32 dst_vreg, + sljit_s32 base_reg, sljit_s32 index_reg) +{ +sljit_u16 instruction[3]; + +instruction[0] = (sljit_u16)(0xe700 | (dst_vreg << 4) | index_reg); +instruction[1] = (sljit_u16)(base_reg << 12); +instruction[2] = (sljit_u16)((0x8 << 8) | (vlbb ? 0x07 : 0x06)); + +sljit_emit_op_custom(compiler, instruction, 6); +} + +#if PCRE2_CODE_UNIT_WIDTH == 32 + +static void replicate_imm_vector(struct sljit_compiler *compiler, int step, sljit_s32 dst_vreg, + PCRE2_UCHAR chr, sljit_s32 tmp_general_reg) +{ +sljit_u16 instruction[3]; + +SLJIT_ASSERT(step >= 0 && step <= 1); + +if (chr < 0x7fff) + { + if (step == 1) + return; + + /* VREPI */ + instruction[0] = (sljit_u16)(0xe700 | (dst_vreg << 4)); + instruction[1] = (sljit_u16)chr; + instruction[2] = (sljit_u16)((VECTOR_ELEMENT_SIZE << 12) | (0x8 << 8) | 0x45); + sljit_emit_op_custom(compiler, instruction, 6); + return; + } + +if (step == 0) + { + OP1(SLJIT_MOV, tmp_general_reg, 0, SLJIT_IMM, chr); + + /* VLVG */ + instruction[0] = (sljit_u16)(0xe700 | (dst_vreg << 4) | sljit_get_register_index(tmp_general_reg)); + instruction[1] = 0; + instruction[2] = (sljit_u16)((VECTOR_ELEMENT_SIZE << 12) | (0x8 << 8) | 0x22); + sljit_emit_op_custom(compiler, instruction, 6); + return; + } + +/* VREP */ +instruction[0] = (sljit_u16)(0xe700 | (dst_vreg << 4) | dst_vreg); +instruction[1] = 0; +instruction[2] = (sljit_u16)((VECTOR_ELEMENT_SIZE << 12) | (0xc << 8) | 0x4d); +sljit_emit_op_custom(compiler, instruction, 6); +} + +#endif + +static void fast_forward_char_pair_sse2_compare(struct sljit_compiler *compiler, vector_compare_type compare_type, + int step, sljit_s32 dst_ind, sljit_s32 cmp1_ind, sljit_s32 cmp2_ind, sljit_s32 tmp_ind) +{ +sljit_u16 instruction[3]; + +SLJIT_ASSERT(step >= 0 && step <= 2); + +if (step == 1) + { + /* VCEQ */ + instruction[0] = (sljit_u16)(0xe700 | (dst_ind << 4) | dst_ind); + instruction[1] = (sljit_u16)(cmp1_ind << 12); + instruction[2] = (sljit_u16)((VECTOR_ELEMENT_SIZE << 12) | (0xe << 8) | 0xf8); + sljit_emit_op_custom(compiler, instruction, 6); + return; + } + +if (compare_type != vector_compare_match2) + { + if (step == 0 && compare_type == vector_compare_match1i) + { + /* VO */ + instruction[0] = (sljit_u16)(0xe700 | (dst_ind << 4) | dst_ind); + instruction[1] = (sljit_u16)(cmp2_ind << 12); + instruction[2] = (sljit_u16)((0xe << 8) | 0x6a); + sljit_emit_op_custom(compiler, instruction, 6); + } + return; + } + +switch (step) + { + case 0: + /* VCEQ */ + instruction[0] = (sljit_u16)(0xe700 | (tmp_ind << 4) | dst_ind); + instruction[1] = (sljit_u16)(cmp2_ind << 12); + instruction[2] = (sljit_u16)((VECTOR_ELEMENT_SIZE << 12) | (0xe << 8) | 0xf8); + sljit_emit_op_custom(compiler, instruction, 6); + return; + + case 2: + /* VO */ + instruction[0] = (sljit_u16)(0xe700 | (dst_ind << 4) | dst_ind); + instruction[1] = (sljit_u16)(tmp_ind << 12); + instruction[2] = (sljit_u16)((0xe << 8) | 0x6a); + sljit_emit_op_custom(compiler, instruction, 6); + return; + } +} + +#define JIT_HAS_FAST_FORWARD_CHAR_SIMD 1 + +static void fast_forward_char_simd(compiler_common *common, PCRE2_UCHAR char1, PCRE2_UCHAR char2, sljit_s32 offset) +{ +DEFINE_COMPILER; +sljit_u16 instruction[3]; +struct sljit_label *start; +#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 +struct sljit_label *restart; +#endif +struct sljit_jump *quit; +struct sljit_jump *partial_quit[2]; +vector_compare_type compare_type = vector_compare_match1; +sljit_s32 tmp1_reg_ind = sljit_get_register_index(TMP1); +sljit_s32 str_ptr_reg_ind = sljit_get_register_index(STR_PTR); +sljit_s32 data_ind = 0; +sljit_s32 tmp_ind = 1; +sljit_s32 cmp1_ind = 2; +sljit_s32 cmp2_ind = 3; +sljit_s32 zero_ind = 4; +sljit_u32 bit = 0; +int i; + +SLJIT_UNUSED_ARG(offset); + +if (char1 != char2) + { + bit = char1 ^ char2; + compare_type = vector_compare_match1i; + + if (!is_powerof2(bit)) + { + bit = 0; + compare_type = vector_compare_match2; + } + } + +partial_quit[0] = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0); +if (common->mode == PCRE2_JIT_COMPLETE) + add_jump(compiler, &common->failed_match, partial_quit[0]); + +/* First part (unaligned start) */ + +OP2(SLJIT_ADD, TMP2, 0, STR_PTR, 0, SLJIT_IMM, 16); + +#if PCRE2_CODE_UNIT_WIDTH != 32 + +/* VREPI */ +instruction[0] = (sljit_u16)(0xe700 | (cmp1_ind << 4)); +instruction[1] = (sljit_u16)(char1 | bit); +instruction[2] = (sljit_u16)((VECTOR_ELEMENT_SIZE << 12) | (0x8 << 8) | 0x45); +sljit_emit_op_custom(compiler, instruction, 6); + +if (char1 != char2) + { + /* VREPI */ + instruction[0] = (sljit_u16)(0xe700 | (cmp2_ind << 4)); + instruction[1] = (sljit_u16)(bit != 0 ? bit : char2); + /* instruction[2] = (sljit_u16)((VECTOR_ELEMENT_SIZE << 12) | (0x8 << 8) | 0x45); */ + sljit_emit_op_custom(compiler, instruction, 6); + } + +#else /* PCRE2_CODE_UNIT_WIDTH == 32 */ + +for (int i = 0; i < 2; i++) + { + replicate_imm_vector(compiler, i, cmp1_ind, char1 | bit, TMP1); + + if (char1 != char2) + replicate_imm_vector(compiler, i, cmp2_ind, bit != 0 ? bit : char2, TMP1); + } + +#endif /* PCRE2_CODE_UNIT_WIDTH != 32 */ + +if (compare_type == vector_compare_match2) + { + /* VREPI */ + instruction[0] = (sljit_u16)(0xe700 | (zero_ind << 4)); + instruction[1] = 0; + instruction[2] = (sljit_u16)((0x8 << 8) | 0x45); + sljit_emit_op_custom(compiler, instruction, 6); + } + +#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 +restart = LABEL(); +#endif + +load_from_mem_vector(compiler, TRUE, data_ind, str_ptr_reg_ind, 0); +OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, ~15); + +if (compare_type != vector_compare_match2) + { + if (compare_type == vector_compare_match1i) + fast_forward_char_pair_sse2_compare(compiler, compare_type, 0, data_ind, cmp1_ind, cmp2_ind, tmp_ind); + + /* VFEE */ + instruction[0] = (sljit_u16)(0xe700 | (data_ind << 4) | data_ind); + instruction[1] = (sljit_u16)((cmp1_ind << 12) | (1 << 4)); + instruction[2] = (sljit_u16)((VECTOR_ELEMENT_SIZE << 12) | (0xe << 8) | 0x80); + sljit_emit_op_custom(compiler, instruction, 6); + } +else + { + for (i = 0; i < 3; i++) + fast_forward_char_pair_sse2_compare(compiler, compare_type, i, data_ind, cmp1_ind, cmp2_ind, tmp_ind); + + /* VFENE */ + instruction[0] = (sljit_u16)(0xe700 | (data_ind << 4) | data_ind); + instruction[1] = (sljit_u16)((zero_ind << 12) | (1 << 4)); + instruction[2] = (sljit_u16)((0xe << 8) | 0x81); + sljit_emit_op_custom(compiler, instruction, 6); + } + +/* VLGVB */ +instruction[0] = (sljit_u16)(0xe700 | (tmp1_reg_ind << 4) | data_ind); +instruction[1] = 7; +instruction[2] = (sljit_u16)((0x4 << 8) | 0x21); +sljit_emit_op_custom(compiler, instruction, 6); + +OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0); +quit = CMP(SLJIT_LESS, STR_PTR, 0, TMP2, 0); + +OP2(SLJIT_SUB, STR_PTR, 0, TMP2, 0, SLJIT_IMM, 16); + +/* Second part (aligned) */ +start = LABEL(); + +OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 16); + +partial_quit[1] = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0); +if (common->mode == PCRE2_JIT_COMPLETE) + add_jump(compiler, &common->failed_match, partial_quit[1]); + +load_from_mem_vector(compiler, TRUE, data_ind, str_ptr_reg_ind, 0); + +if (compare_type != vector_compare_match2) + { + if (compare_type == vector_compare_match1i) + fast_forward_char_pair_sse2_compare(compiler, compare_type, 0, data_ind, cmp1_ind, cmp2_ind, tmp_ind); + + /* VFEE */ + instruction[0] = (sljit_u16)(0xe700 | (data_ind << 4) | data_ind); + instruction[1] = (sljit_u16)((cmp1_ind << 12) | (1 << 4)); + instruction[2] = (sljit_u16)((VECTOR_ELEMENT_SIZE << 12) | (0xe << 8) | 0x80); + sljit_emit_op_custom(compiler, instruction, 6); + } +else + { + for (i = 0; i < 3; i++) + fast_forward_char_pair_sse2_compare(compiler, compare_type, i, data_ind, cmp1_ind, cmp2_ind, tmp_ind); + + /* VFENE */ + instruction[0] = (sljit_u16)(0xe700 | (data_ind << 4) | data_ind); + instruction[1] = (sljit_u16)((zero_ind << 12) | (1 << 4)); + instruction[2] = (sljit_u16)((0xe << 8) | 0x81); + sljit_emit_op_custom(compiler, instruction, 6); + } + +sljit_set_current_flags(compiler, SLJIT_SET_OVERFLOW); +JUMPTO(SLJIT_OVERFLOW, start); + +/* VLGVB */ +instruction[0] = (sljit_u16)(0xe700 | (tmp1_reg_ind << 4) | data_ind); +instruction[1] = 7; +instruction[2] = (sljit_u16)((0x4 << 8) | 0x21); +sljit_emit_op_custom(compiler, instruction, 6); + +OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0); + +JUMPHERE(quit); + +if (common->mode != PCRE2_JIT_COMPLETE) + { + JUMPHERE(partial_quit[0]); + JUMPHERE(partial_quit[1]); + OP2(SLJIT_SUB | SLJIT_SET_GREATER, SLJIT_UNUSED, 0, STR_PTR, 0, STR_END, 0); + CMOV(SLJIT_GREATER, STR_PTR, STR_END, 0); + } +else + add_jump(compiler, &common->failed_match, CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0)); + +#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 +if (common->utf && offset > 0) + { + SLJIT_ASSERT(common->mode == PCRE2_JIT_COMPLETE); + + OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-offset)); + + quit = jump_if_utf_char_start(compiler, TMP1); + + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + add_jump(compiler, &common->failed_match, CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0)); + + OP2(SLJIT_ADD, TMP2, 0, STR_PTR, 0, SLJIT_IMM, 16); + JUMPTO(SLJIT_JUMP, restart); + + JUMPHERE(quit); + } +#endif +} + +#define JIT_HAS_FAST_REQUESTED_CHAR_SIMD 1 + +static jump_list *fast_requested_char_simd(compiler_common *common, PCRE2_UCHAR char1, PCRE2_UCHAR char2) +{ +DEFINE_COMPILER; +sljit_u16 instruction[3]; +struct sljit_label *start; +struct sljit_jump *quit; +jump_list *not_found = NULL; +vector_compare_type compare_type = vector_compare_match1; +sljit_s32 tmp1_reg_ind = sljit_get_register_index(TMP1); +sljit_s32 tmp3_reg_ind = sljit_get_register_index(TMP3); +sljit_s32 data_ind = 0; +sljit_s32 tmp_ind = 1; +sljit_s32 cmp1_ind = 2; +sljit_s32 cmp2_ind = 3; +sljit_s32 zero_ind = 4; +sljit_u32 bit = 0; +int i; + +if (char1 != char2) + { + bit = char1 ^ char2; + compare_type = vector_compare_match1i; + + if (!is_powerof2(bit)) + { + bit = 0; + compare_type = vector_compare_match2; + } + } + +add_jump(compiler, ¬_found, CMP(SLJIT_GREATER_EQUAL, TMP1, 0, STR_END, 0)); + +/* First part (unaligned start) */ + +OP2(SLJIT_ADD, TMP2, 0, TMP1, 0, SLJIT_IMM, 16); + +#if PCRE2_CODE_UNIT_WIDTH != 32 + +/* VREPI */ +instruction[0] = (sljit_u16)(0xe700 | (cmp1_ind << 4)); +instruction[1] = (sljit_u16)(char1 | bit); +instruction[2] = (sljit_u16)((VECTOR_ELEMENT_SIZE << 12) | (0x8 << 8) | 0x45); +sljit_emit_op_custom(compiler, instruction, 6); + +if (char1 != char2) + { + /* VREPI */ + instruction[0] = (sljit_u16)(0xe700 | (cmp2_ind << 4)); + instruction[1] = (sljit_u16)(bit != 0 ? bit : char2); + /* instruction[2] = (sljit_u16)((VECTOR_ELEMENT_SIZE << 12) | (0x8 << 8) | 0x45); */ + sljit_emit_op_custom(compiler, instruction, 6); + } + +#else /* PCRE2_CODE_UNIT_WIDTH == 32 */ + +for (int i = 0; i < 2; i++) + { + replicate_imm_vector(compiler, i, cmp1_ind, char1 | bit, TMP3); + + if (char1 != char2) + replicate_imm_vector(compiler, i, cmp2_ind, bit != 0 ? bit : char2, TMP3); + } + +#endif /* PCRE2_CODE_UNIT_WIDTH != 32 */ + +if (compare_type == vector_compare_match2) + { + /* VREPI */ + instruction[0] = (sljit_u16)(0xe700 | (zero_ind << 4)); + instruction[1] = 0; + instruction[2] = (sljit_u16)((0x8 << 8) | 0x45); + sljit_emit_op_custom(compiler, instruction, 6); + } + +load_from_mem_vector(compiler, TRUE, data_ind, tmp1_reg_ind, 0); +OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, ~15); + +if (compare_type != vector_compare_match2) + { + if (compare_type == vector_compare_match1i) + fast_forward_char_pair_sse2_compare(compiler, compare_type, 0, data_ind, cmp1_ind, cmp2_ind, tmp_ind); + + /* VFEE */ + instruction[0] = (sljit_u16)(0xe700 | (data_ind << 4) | data_ind); + instruction[1] = (sljit_u16)((cmp1_ind << 12) | (1 << 4)); + instruction[2] = (sljit_u16)((VECTOR_ELEMENT_SIZE << 12) | (0xe << 8) | 0x80); + sljit_emit_op_custom(compiler, instruction, 6); + } +else + { + for (i = 0; i < 3; i++) + fast_forward_char_pair_sse2_compare(compiler, compare_type, i, data_ind, cmp1_ind, cmp2_ind, tmp_ind); + + /* VFENE */ + instruction[0] = (sljit_u16)(0xe700 | (data_ind << 4) | data_ind); + instruction[1] = (sljit_u16)((zero_ind << 12) | (1 << 4)); + instruction[2] = (sljit_u16)((0xe << 8) | 0x81); + sljit_emit_op_custom(compiler, instruction, 6); + } + +/* VLGVB */ +instruction[0] = (sljit_u16)(0xe700 | (tmp3_reg_ind << 4) | data_ind); +instruction[1] = 7; +instruction[2] = (sljit_u16)((0x4 << 8) | 0x21); +sljit_emit_op_custom(compiler, instruction, 6); + +OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, TMP3, 0); +quit = CMP(SLJIT_LESS, TMP1, 0, TMP2, 0); + +OP2(SLJIT_SUB, TMP1, 0, TMP2, 0, SLJIT_IMM, 16); + +/* Second part (aligned) */ +start = LABEL(); + +OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 16); + +add_jump(compiler, ¬_found, CMP(SLJIT_GREATER_EQUAL, TMP1, 0, STR_END, 0)); + +load_from_mem_vector(compiler, TRUE, data_ind, tmp1_reg_ind, 0); + +if (compare_type != vector_compare_match2) + { + if (compare_type == vector_compare_match1i) + fast_forward_char_pair_sse2_compare(compiler, compare_type, 0, data_ind, cmp1_ind, cmp2_ind, tmp_ind); + + /* VFEE */ + instruction[0] = (sljit_u16)(0xe700 | (data_ind << 4) | data_ind); + instruction[1] = (sljit_u16)((cmp1_ind << 12) | (1 << 4)); + instruction[2] = (sljit_u16)((VECTOR_ELEMENT_SIZE << 12) | (0xe << 8) | 0x80); + sljit_emit_op_custom(compiler, instruction, 6); + } +else + { + for (i = 0; i < 3; i++) + fast_forward_char_pair_sse2_compare(compiler, compare_type, i, data_ind, cmp1_ind, cmp2_ind, tmp_ind); + + /* VFENE */ + instruction[0] = (sljit_u16)(0xe700 | (data_ind << 4) | data_ind); + instruction[1] = (sljit_u16)((zero_ind << 12) | (1 << 4)); + instruction[2] = (sljit_u16)((0xe << 8) | 0x81); + sljit_emit_op_custom(compiler, instruction, 6); + } + +sljit_set_current_flags(compiler, SLJIT_SET_OVERFLOW); +JUMPTO(SLJIT_OVERFLOW, start); + +/* VLGVB */ +instruction[0] = (sljit_u16)(0xe700 | (tmp3_reg_ind << 4) | data_ind); +instruction[1] = 7; +instruction[2] = (sljit_u16)((0x4 << 8) | 0x21); +sljit_emit_op_custom(compiler, instruction, 6); + +OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, TMP3, 0); + +JUMPHERE(quit); +add_jump(compiler, ¬_found, CMP(SLJIT_GREATER_EQUAL, TMP1, 0, STR_END, 0)); + +return not_found; +} + +#define JIT_HAS_FAST_FORWARD_CHAR_PAIR_SIMD 1 + +static void fast_forward_char_pair_simd(compiler_common *common, sljit_s32 offs1, + PCRE2_UCHAR char1a, PCRE2_UCHAR char1b, sljit_s32 offs2, PCRE2_UCHAR char2a, PCRE2_UCHAR char2b) +{ +DEFINE_COMPILER; +sljit_u16 instruction[3]; +struct sljit_label *start; +#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 +struct sljit_label *restart; +#endif +struct sljit_jump *quit; +struct sljit_jump *jump[2]; +vector_compare_type compare1_type = vector_compare_match1; +vector_compare_type compare2_type = vector_compare_match1; +sljit_u32 bit1 = 0; +sljit_u32 bit2 = 0; +sljit_s32 diff = IN_UCHARS(offs2 - offs1); +sljit_s32 tmp1_reg_ind = sljit_get_register_index(TMP1); +sljit_s32 tmp2_reg_ind = sljit_get_register_index(TMP2); +sljit_s32 str_ptr_reg_ind = sljit_get_register_index(STR_PTR); +sljit_s32 data1_ind = 0; +sljit_s32 data2_ind = 1; +sljit_s32 tmp1_ind = 2; +sljit_s32 tmp2_ind = 3; +sljit_s32 cmp1a_ind = 4; +sljit_s32 cmp1b_ind = 5; +sljit_s32 cmp2a_ind = 6; +sljit_s32 cmp2b_ind = 7; +sljit_s32 zero_ind = 8; +int i; + +SLJIT_ASSERT(common->mode == PCRE2_JIT_COMPLETE && offs1 > offs2); +SLJIT_ASSERT(-diff <= (sljit_s32)IN_UCHARS(max_fast_forward_char_pair_offset())); +SLJIT_ASSERT(tmp1_reg_ind != 0 && tmp2_reg_ind != 0); + +if (char1a != char1b) + { + bit1 = char1a ^ char1b; + compare1_type = vector_compare_match1i; + + if (!is_powerof2(bit1)) + { + bit1 = 0; + compare1_type = vector_compare_match2; + } + } + +if (char2a != char2b) + { + bit2 = char2a ^ char2b; + compare2_type = vector_compare_match1i; + + if (!is_powerof2(bit2)) + { + bit2 = 0; + compare2_type = vector_compare_match2; + } + } + +/* Initialize. */ +if (common->match_end_ptr != 0) + { + OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->match_end_ptr); + OP1(SLJIT_MOV, TMP3, 0, STR_END, 0); + OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, IN_UCHARS(offs1 + 1)); + + OP2(SLJIT_SUB | SLJIT_SET_LESS, SLJIT_UNUSED, 0, TMP1, 0, STR_END, 0); + CMOV(SLJIT_LESS, STR_END, TMP1, 0); + } + +OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(offs1)); +add_jump(compiler, &common->failed_match, CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0)); +OP2(SLJIT_AND, TMP2, 0, STR_PTR, 0, SLJIT_IMM, ~15); + +#if PCRE2_CODE_UNIT_WIDTH != 32 + +OP2(SLJIT_SUB, TMP1, 0, STR_PTR, 0, SLJIT_IMM, -diff); + +/* VREPI */ +instruction[0] = (sljit_u16)(0xe700 | (cmp1a_ind << 4)); +instruction[1] = (sljit_u16)(char1a | bit1); +instruction[2] = (sljit_u16)((VECTOR_ELEMENT_SIZE << 12) | (0x8 << 8) | 0x45); +sljit_emit_op_custom(compiler, instruction, 6); + +if (char1a != char1b) + { + /* VREPI */ + instruction[0] = (sljit_u16)(0xe700 | (cmp1b_ind << 4)); + instruction[1] = (sljit_u16)(bit1 != 0 ? bit1 : char1b); + /* instruction[2] = (sljit_u16)((VECTOR_ELEMENT_SIZE << 12) | (0x8 << 8) | 0x45); */ + sljit_emit_op_custom(compiler, instruction, 6); + } + +/* VREPI */ +instruction[0] = (sljit_u16)(0xe700 | (cmp2a_ind << 4)); +instruction[1] = (sljit_u16)(char2a | bit2); +/* instruction[2] = (sljit_u16)((VECTOR_ELEMENT_SIZE << 12) | (0x8 << 8) | 0x45); */ +sljit_emit_op_custom(compiler, instruction, 6); + +if (char2a != char2b) + { + /* VREPI */ + instruction[0] = (sljit_u16)(0xe700 | (cmp2b_ind << 4)); + instruction[1] = (sljit_u16)(bit2 != 0 ? bit2 : char2b); + /* instruction[2] = (sljit_u16)((VECTOR_ELEMENT_SIZE << 12) | (0x8 << 8) | 0x45); */ + sljit_emit_op_custom(compiler, instruction, 6); + } + +#else /* PCRE2_CODE_UNIT_WIDTH == 32 */ + +for (int i = 0; i < 2; i++) + { + replicate_imm_vector(compiler, i, cmp1a_ind, char1a | bit1, TMP1); + + if (char1a != char1b) + replicate_imm_vector(compiler, i, cmp1b_ind, bit1 != 0 ? bit1 : char1b, TMP1); + + replicate_imm_vector(compiler, i, cmp2a_ind, char2a | bit2, TMP1); + + if (char2a != char2b) + replicate_imm_vector(compiler, i, cmp2b_ind, bit2 != 0 ? bit2 : char2b, TMP1); + } + +OP2(SLJIT_SUB, TMP1, 0, STR_PTR, 0, SLJIT_IMM, -diff); + +#endif /* PCRE2_CODE_UNIT_WIDTH != 32 */ + +/* VREPI */ +instruction[0] = (sljit_u16)(0xe700 | (zero_ind << 4)); +instruction[1] = 0; +instruction[2] = (sljit_u16)((0x8 << 8) | 0x45); +sljit_emit_op_custom(compiler, instruction, 6); + +#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 +restart = LABEL(); +#endif + +jump[0] = CMP(SLJIT_LESS, TMP1, 0, TMP2, 0); +load_from_mem_vector(compiler, TRUE, data2_ind, tmp1_reg_ind, 0); +jump[1] = JUMP(SLJIT_JUMP); +JUMPHERE(jump[0]); +load_from_mem_vector(compiler, FALSE, data2_ind, tmp1_reg_ind, 0); +JUMPHERE(jump[1]); + +load_from_mem_vector(compiler, TRUE, data1_ind, str_ptr_reg_ind, 0); +OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, SLJIT_IMM, 16); + +for (i = 0; i < 3; i++) + { + fast_forward_char_pair_sse2_compare(compiler, compare1_type, i, data1_ind, cmp1a_ind, cmp1b_ind, tmp1_ind); + fast_forward_char_pair_sse2_compare(compiler, compare2_type, i, data2_ind, cmp2a_ind, cmp2b_ind, tmp2_ind); + } + +/* VN */ +instruction[0] = (sljit_u16)(0xe700 | (data1_ind << 4) | data1_ind); +instruction[1] = (sljit_u16)(data2_ind << 12); +instruction[2] = (sljit_u16)((0xe << 8) | 0x68); +sljit_emit_op_custom(compiler, instruction, 6); + +/* VFENE */ +instruction[0] = (sljit_u16)(0xe700 | (data1_ind << 4) | data1_ind); +instruction[1] = (sljit_u16)((zero_ind << 12) | (1 << 4)); +instruction[2] = (sljit_u16)((0xe << 8) | 0x81); +sljit_emit_op_custom(compiler, instruction, 6); + +/* VLGVB */ +instruction[0] = (sljit_u16)(0xe700 | (tmp1_reg_ind << 4) | data1_ind); +instruction[1] = 7; +instruction[2] = (sljit_u16)((0x4 << 8) | 0x21); +sljit_emit_op_custom(compiler, instruction, 6); + +OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0); +quit = CMP(SLJIT_LESS, STR_PTR, 0, TMP2, 0); + +OP2(SLJIT_SUB, STR_PTR, 0, TMP2, 0, SLJIT_IMM, 16); +OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, diff); + +/* Main loop. */ +start = LABEL(); + +OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 16); +add_jump(compiler, &common->failed_match, CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0)); + +load_from_mem_vector(compiler, FALSE, data1_ind, str_ptr_reg_ind, 0); +load_from_mem_vector(compiler, FALSE, data2_ind, str_ptr_reg_ind, tmp1_reg_ind); + +for (i = 0; i < 3; i++) + { + fast_forward_char_pair_sse2_compare(compiler, compare1_type, i, data1_ind, cmp1a_ind, cmp1b_ind, tmp1_ind); + fast_forward_char_pair_sse2_compare(compiler, compare2_type, i, data2_ind, cmp2a_ind, cmp2b_ind, tmp2_ind); + } + +/* VN */ +instruction[0] = (sljit_u16)(0xe700 | (data1_ind << 4) | data1_ind); +instruction[1] = (sljit_u16)(data2_ind << 12); +instruction[2] = (sljit_u16)((0xe << 8) | 0x68); +sljit_emit_op_custom(compiler, instruction, 6); + +/* VFENE */ +instruction[0] = (sljit_u16)(0xe700 | (data1_ind << 4) | data1_ind); +instruction[1] = (sljit_u16)((zero_ind << 12) | (1 << 4)); +instruction[2] = (sljit_u16)((0xe << 8) | 0x81); +sljit_emit_op_custom(compiler, instruction, 6); + +sljit_set_current_flags(compiler, SLJIT_SET_OVERFLOW); +JUMPTO(SLJIT_OVERFLOW, start); + +/* VLGVB */ +instruction[0] = (sljit_u16)(0xe700 | (tmp2_reg_ind << 4) | data1_ind); +instruction[1] = 7; +instruction[2] = (sljit_u16)((0x4 << 8) | 0x21); +sljit_emit_op_custom(compiler, instruction, 6); + +OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP2, 0); + +JUMPHERE(quit); + +add_jump(compiler, &common->failed_match, CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0)); + +#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 +if (common->utf) + { + SLJIT_ASSERT(common->mode == PCRE2_JIT_COMPLETE); + + OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-offs1)); + + quit = jump_if_utf_char_start(compiler, TMP1); + + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + add_jump(compiler, &common->failed_match, CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0)); + + /* TMP1 contains diff. */ + OP2(SLJIT_AND, TMP2, 0, STR_PTR, 0, SLJIT_IMM, ~15); + OP2(SLJIT_SUB, TMP1, 0, STR_PTR, 0, SLJIT_IMM, -diff); + JUMPTO(SLJIT_JUMP, restart); + + JUMPHERE(quit); + } +#endif + +OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(offs1)); + +if (common->match_end_ptr != 0) + OP1(SLJIT_MOV, STR_END, 0, TMP3, 0); +} + +#endif /* SLJIT_CONFIG_S390X */ + +#endif /* !SUPPORT_VALGRIND */ diff --git a/thirdparty/pcre2/src/pcre2_match.c b/thirdparty/pcre2/src/pcre2_match.c index e3f78c2ca3..f28cdbb47a 100644 --- a/thirdparty/pcre2/src/pcre2_match.c +++ b/thirdparty/pcre2/src/pcre2_match.c @@ -7,7 +7,7 @@ and semantics are as close as possible to those of the Perl 5 language. Written by Philip Hazel Original API code Copyright (c) 1997-2012 University of Cambridge - New API code Copyright (c) 2015-2020 University of Cambridge + New API code Copyright (c) 2015-2021 University of Cambridge ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -818,10 +818,12 @@ fprintf(stderr, "++ op=%d\n", *Fecode); /* N is now the frame of the recursion; the previous frame is at the OP_RECURSE position. Go back there, copying the current subject position - and mark, and move on past the OP_RECURSE. */ + and mark, and the start_match position (\K might have changed it), and + then move on past the OP_RECURSE. */ P->eptr = Feptr; P->mark = Fmark; + P->start_match = Fstart_match; F = P; Fecode += 1 + LINK_SIZE; continue; @@ -6115,8 +6117,8 @@ BOOL has_req_cu = FALSE; BOOL startline; #if PCRE2_CODE_UNIT_WIDTH == 8 -BOOL memchr_not_found_first_cu; -BOOL memchr_not_found_first_cu2; +PCRE2_SPTR memchr_found_first_cu; +PCRE2_SPTR memchr_found_first_cu2; #endif PCRE2_UCHAR first_cu = 0; @@ -6710,8 +6712,8 @@ start_partial = match_partial = NULL; mb->hitend = FALSE; #if PCRE2_CODE_UNIT_WIDTH == 8 -memchr_not_found_first_cu = FALSE; -memchr_not_found_first_cu2 = FALSE; +memchr_found_first_cu = NULL; +memchr_found_first_cu2 = NULL; #endif for(;;) @@ -6780,13 +6782,7 @@ for(;;) } } - /* Not anchored. Advance to a unique first code unit if there is one. In - 8-bit mode, the use of memchr() gives a big speed up, even though we have - to call it twice in caseless mode, in order to find the earliest occurrence - of the character in either of its cases. If a call to memchr() that - searches the rest of the subject fails to find one case, remember that in - order not to keep on repeating the search. This can make a huge difference - when the strings are very long and only one case is present. */ + /* Not anchored. Advance to a unique first code unit if there is one. */ else { @@ -6794,43 +6790,68 @@ for(;;) { if (first_cu != first_cu2) /* Caseless */ { + /* In 16-bit and 32_bit modes we have to do our own search, so can + look for both cases at once. */ + #if PCRE2_CODE_UNIT_WIDTH != 8 PCRE2_UCHAR smc; while (start_match < end_subject && (smc = UCHAR21TEST(start_match)) != first_cu && - smc != first_cu2) + smc != first_cu2) start_match++; +#else + /* In 8-bit mode, the use of memchr() gives a big speed up, even + though we have to call it twice in order to find the earliest + occurrence of the code unit in either of its cases. Caching is used + to remember the positions of previously found code units. This can + make a huge difference when the strings are very long and only one + case is actually present. */ -#else /* 8-bit code units */ PCRE2_SPTR pp1 = NULL; PCRE2_SPTR pp2 = NULL; - PCRE2_SIZE cu2size = end_subject - start_match; + PCRE2_SIZE searchlength = end_subject - start_match; - if (!memchr_not_found_first_cu) + /* If we haven't got a previously found position for first_cu, or if + the current starting position is later, we need to do a search. If + the code unit is not found, set it to the end. */ + + if (memchr_found_first_cu == NULL || + start_match > memchr_found_first_cu) { - pp1 = memchr(start_match, first_cu, end_subject - start_match); - if (pp1 == NULL) memchr_not_found_first_cu = TRUE; - else cu2size = pp1 - start_match; + pp1 = memchr(start_match, first_cu, searchlength); + memchr_found_first_cu = (pp1 == NULL)? end_subject : pp1; } - /* If pp1 is not NULL, we have arranged to search only as far as pp1, - to see if the other case is earlier, so we can set "not found" only - when both searches have returned NULL. */ + /* If the start is before a previously found position, use the + previous position, or NULL if a previous search failed. */ + + else pp1 = (memchr_found_first_cu == end_subject)? NULL : + memchr_found_first_cu; - if (!memchr_not_found_first_cu2) + /* Do the same thing for the other case. */ + + if (memchr_found_first_cu2 == NULL || + start_match > memchr_found_first_cu2) { - pp2 = memchr(start_match, first_cu2, cu2size); - memchr_not_found_first_cu2 = (pp2 == NULL && pp1 == NULL); + pp2 = memchr(start_match, first_cu2, searchlength); + memchr_found_first_cu2 = (pp2 == NULL)? end_subject : pp2; } + else pp2 = (memchr_found_first_cu2 == end_subject)? NULL : + memchr_found_first_cu2; + + /* Set the start to the end of the subject if neither case was found. + Otherwise, use the earlier found point. */ + if (pp1 == NULL) start_match = (pp2 == NULL)? end_subject : pp2; else start_match = (pp2 == NULL || pp1 < pp2)? pp1 : pp2; -#endif + +#endif /* 8-bit handling */ } - /* The caseful case */ + /* The caseful case is much simpler. */ else { diff --git a/thirdparty/pcre2/src/pcre2_tables.c b/thirdparty/pcre2/src/pcre2_tables.c index b10de45efb..c164e976e0 100644 --- a/thirdparty/pcre2/src/pcre2_tables.c +++ b/thirdparty/pcre2/src/pcre2_tables.c @@ -273,6 +273,7 @@ strings to make sure that UTF-8 support works on EBCDIC platforms. */ #define STRING_Cs0 STR_C STR_s "\0" #define STRING_Cuneiform0 STR_C STR_u STR_n STR_e STR_i STR_f STR_o STR_r STR_m "\0" #define STRING_Cypriot0 STR_C STR_y STR_p STR_r STR_i STR_o STR_t "\0" +#define STRING_Cypro_Minoan0 STR_C STR_y STR_p STR_r STR_o STR_UNDERSCORE STR_M STR_i STR_n STR_o STR_a STR_n "\0" #define STRING_Cyrillic0 STR_C STR_y STR_r STR_i STR_l STR_l STR_i STR_c "\0" #define STRING_Deseret0 STR_D STR_e STR_s STR_e STR_r STR_e STR_t "\0" #define STRING_Devanagari0 STR_D STR_e STR_v STR_a STR_n STR_a STR_g STR_a STR_r STR_i "\0" @@ -371,6 +372,7 @@ strings to make sure that UTF-8 support works on EBCDIC platforms. */ #define STRING_Old_Sogdian0 STR_O STR_l STR_d STR_UNDERSCORE STR_S STR_o STR_g STR_d STR_i STR_a STR_n "\0" #define STRING_Old_South_Arabian0 STR_O STR_l STR_d STR_UNDERSCORE STR_S STR_o STR_u STR_t STR_h STR_UNDERSCORE STR_A STR_r STR_a STR_b STR_i STR_a STR_n "\0" #define STRING_Old_Turkic0 STR_O STR_l STR_d STR_UNDERSCORE STR_T STR_u STR_r STR_k STR_i STR_c "\0" +#define STRING_Old_Uyghur0 STR_O STR_l STR_d STR_UNDERSCORE STR_U STR_y STR_g STR_h STR_u STR_r "\0" #define STRING_Oriya0 STR_O STR_r STR_i STR_y STR_a "\0" #define STRING_Osage0 STR_O STR_s STR_a STR_g STR_e "\0" #define STRING_Osmanya0 STR_O STR_s STR_m STR_a STR_n STR_y STR_a "\0" @@ -415,6 +417,7 @@ strings to make sure that UTF-8 support works on EBCDIC platforms. */ #define STRING_Tai_Viet0 STR_T STR_a STR_i STR_UNDERSCORE STR_V STR_i STR_e STR_t "\0" #define STRING_Takri0 STR_T STR_a STR_k STR_r STR_i "\0" #define STRING_Tamil0 STR_T STR_a STR_m STR_i STR_l "\0" +#define STRING_Tangsa0 STR_T STR_a STR_n STR_g STR_s STR_a "\0" #define STRING_Tangut0 STR_T STR_a STR_n STR_g STR_u STR_t "\0" #define STRING_Telugu0 STR_T STR_e STR_l STR_u STR_g STR_u "\0" #define STRING_Thaana0 STR_T STR_h STR_a STR_a STR_n STR_a "\0" @@ -422,9 +425,11 @@ strings to make sure that UTF-8 support works on EBCDIC platforms. */ #define STRING_Tibetan0 STR_T STR_i STR_b STR_e STR_t STR_a STR_n "\0" #define STRING_Tifinagh0 STR_T STR_i STR_f STR_i STR_n STR_a STR_g STR_h "\0" #define STRING_Tirhuta0 STR_T STR_i STR_r STR_h STR_u STR_t STR_a "\0" +#define STRING_Toto0 STR_T STR_o STR_t STR_o "\0" #define STRING_Ugaritic0 STR_U STR_g STR_a STR_r STR_i STR_t STR_i STR_c "\0" #define STRING_Unknown0 STR_U STR_n STR_k STR_n STR_o STR_w STR_n "\0" #define STRING_Vai0 STR_V STR_a STR_i "\0" +#define STRING_Vithkuqi0 STR_V STR_i STR_t STR_h STR_k STR_u STR_q STR_i "\0" #define STRING_Wancho0 STR_W STR_a STR_n STR_c STR_h STR_o "\0" #define STRING_Warang_Citi0 STR_W STR_a STR_r STR_a STR_n STR_g STR_UNDERSCORE STR_C STR_i STR_t STR_i "\0" #define STRING_Xan0 STR_X STR_a STR_n "\0" @@ -476,6 +481,7 @@ const char PRIV(utt_names)[] = STRING_Cs0 STRING_Cuneiform0 STRING_Cypriot0 + STRING_Cypro_Minoan0 STRING_Cyrillic0 STRING_Deseret0 STRING_Devanagari0 @@ -574,6 +580,7 @@ const char PRIV(utt_names)[] = STRING_Old_Sogdian0 STRING_Old_South_Arabian0 STRING_Old_Turkic0 + STRING_Old_Uyghur0 STRING_Oriya0 STRING_Osage0 STRING_Osmanya0 @@ -618,6 +625,7 @@ const char PRIV(utt_names)[] = STRING_Tai_Viet0 STRING_Takri0 STRING_Tamil0 + STRING_Tangsa0 STRING_Tangut0 STRING_Telugu0 STRING_Thaana0 @@ -625,9 +633,11 @@ const char PRIV(utt_names)[] = STRING_Tibetan0 STRING_Tifinagh0 STRING_Tirhuta0 + STRING_Toto0 STRING_Ugaritic0 STRING_Unknown0 STRING_Vai0 + STRING_Vithkuqi0 STRING_Wancho0 STRING_Warang_Citi0 STRING_Xan0 @@ -679,172 +689,177 @@ const ucp_type_table PRIV(utt)[] = { { 255, PT_PC, ucp_Cs }, { 258, PT_SC, ucp_Cuneiform }, { 268, PT_SC, ucp_Cypriot }, - { 276, PT_SC, ucp_Cyrillic }, - { 285, PT_SC, ucp_Deseret }, - { 293, PT_SC, ucp_Devanagari }, - { 304, PT_SC, ucp_Dives_Akuru }, - { 316, PT_SC, ucp_Dogra }, - { 322, PT_SC, ucp_Duployan }, - { 331, PT_SC, ucp_Egyptian_Hieroglyphs }, - { 352, PT_SC, ucp_Elbasan }, - { 360, PT_SC, ucp_Elymaic }, - { 368, PT_SC, ucp_Ethiopic }, - { 377, PT_SC, ucp_Georgian }, - { 386, PT_SC, ucp_Glagolitic }, - { 397, PT_SC, ucp_Gothic }, - { 404, PT_SC, ucp_Grantha }, - { 412, PT_SC, ucp_Greek }, - { 418, PT_SC, ucp_Gujarati }, - { 427, PT_SC, ucp_Gunjala_Gondi }, - { 441, PT_SC, ucp_Gurmukhi }, - { 450, PT_SC, ucp_Han }, - { 454, PT_SC, ucp_Hangul }, - { 461, PT_SC, ucp_Hanifi_Rohingya }, - { 477, PT_SC, ucp_Hanunoo }, - { 485, PT_SC, ucp_Hatran }, - { 492, PT_SC, ucp_Hebrew }, - { 499, PT_SC, ucp_Hiragana }, - { 508, PT_SC, ucp_Imperial_Aramaic }, - { 525, PT_SC, ucp_Inherited }, - { 535, PT_SC, ucp_Inscriptional_Pahlavi }, - { 557, PT_SC, ucp_Inscriptional_Parthian }, - { 580, PT_SC, ucp_Javanese }, - { 589, PT_SC, ucp_Kaithi }, - { 596, PT_SC, ucp_Kannada }, - { 604, PT_SC, ucp_Katakana }, - { 613, PT_SC, ucp_Kayah_Li }, - { 622, PT_SC, ucp_Kharoshthi }, - { 633, PT_SC, ucp_Khitan_Small_Script }, - { 653, PT_SC, ucp_Khmer }, - { 659, PT_SC, ucp_Khojki }, - { 666, PT_SC, ucp_Khudawadi }, - { 676, PT_GC, ucp_L }, - { 678, PT_LAMP, 0 }, - { 681, PT_SC, ucp_Lao }, - { 685, PT_SC, ucp_Latin }, - { 691, PT_SC, ucp_Lepcha }, - { 698, PT_SC, ucp_Limbu }, - { 704, PT_SC, ucp_Linear_A }, - { 713, PT_SC, ucp_Linear_B }, - { 722, PT_SC, ucp_Lisu }, - { 727, PT_PC, ucp_Ll }, - { 730, PT_PC, ucp_Lm }, - { 733, PT_PC, ucp_Lo }, - { 736, PT_PC, ucp_Lt }, - { 739, PT_PC, ucp_Lu }, - { 742, PT_SC, ucp_Lycian }, - { 749, PT_SC, ucp_Lydian }, - { 756, PT_GC, ucp_M }, - { 758, PT_SC, ucp_Mahajani }, - { 767, PT_SC, ucp_Makasar }, - { 775, PT_SC, ucp_Malayalam }, - { 785, PT_SC, ucp_Mandaic }, - { 793, PT_SC, ucp_Manichaean }, - { 804, PT_SC, ucp_Marchen }, - { 812, PT_SC, ucp_Masaram_Gondi }, - { 826, PT_PC, ucp_Mc }, - { 829, PT_PC, ucp_Me }, - { 832, PT_SC, ucp_Medefaidrin }, - { 844, PT_SC, ucp_Meetei_Mayek }, - { 857, PT_SC, ucp_Mende_Kikakui }, - { 871, PT_SC, ucp_Meroitic_Cursive }, - { 888, PT_SC, ucp_Meroitic_Hieroglyphs }, - { 909, PT_SC, ucp_Miao }, - { 914, PT_PC, ucp_Mn }, - { 917, PT_SC, ucp_Modi }, - { 922, PT_SC, ucp_Mongolian }, - { 932, PT_SC, ucp_Mro }, - { 936, PT_SC, ucp_Multani }, - { 944, PT_SC, ucp_Myanmar }, - { 952, PT_GC, ucp_N }, - { 954, PT_SC, ucp_Nabataean }, - { 964, PT_SC, ucp_Nandinagari }, - { 976, PT_PC, ucp_Nd }, - { 979, PT_SC, ucp_New_Tai_Lue }, - { 991, PT_SC, ucp_Newa }, - { 996, PT_SC, ucp_Nko }, - { 1000, PT_PC, ucp_Nl }, - { 1003, PT_PC, ucp_No }, - { 1006, PT_SC, ucp_Nushu }, - { 1012, PT_SC, ucp_Nyiakeng_Puachue_Hmong }, - { 1035, PT_SC, ucp_Ogham }, - { 1041, PT_SC, ucp_Ol_Chiki }, - { 1050, PT_SC, ucp_Old_Hungarian }, - { 1064, PT_SC, ucp_Old_Italic }, - { 1075, PT_SC, ucp_Old_North_Arabian }, - { 1093, PT_SC, ucp_Old_Permic }, - { 1104, PT_SC, ucp_Old_Persian }, - { 1116, PT_SC, ucp_Old_Sogdian }, - { 1128, PT_SC, ucp_Old_South_Arabian }, - { 1146, PT_SC, ucp_Old_Turkic }, - { 1157, PT_SC, ucp_Oriya }, - { 1163, PT_SC, ucp_Osage }, - { 1169, PT_SC, ucp_Osmanya }, - { 1177, PT_GC, ucp_P }, - { 1179, PT_SC, ucp_Pahawh_Hmong }, - { 1192, PT_SC, ucp_Palmyrene }, - { 1202, PT_SC, ucp_Pau_Cin_Hau }, - { 1214, PT_PC, ucp_Pc }, - { 1217, PT_PC, ucp_Pd }, - { 1220, PT_PC, ucp_Pe }, - { 1223, PT_PC, ucp_Pf }, - { 1226, PT_SC, ucp_Phags_Pa }, - { 1235, PT_SC, ucp_Phoenician }, - { 1246, PT_PC, ucp_Pi }, - { 1249, PT_PC, ucp_Po }, - { 1252, PT_PC, ucp_Ps }, - { 1255, PT_SC, ucp_Psalter_Pahlavi }, - { 1271, PT_SC, ucp_Rejang }, - { 1278, PT_SC, ucp_Runic }, - { 1284, PT_GC, ucp_S }, - { 1286, PT_SC, ucp_Samaritan }, - { 1296, PT_SC, ucp_Saurashtra }, - { 1307, PT_PC, ucp_Sc }, - { 1310, PT_SC, ucp_Sharada }, - { 1318, PT_SC, ucp_Shavian }, - { 1326, PT_SC, ucp_Siddham }, - { 1334, PT_SC, ucp_SignWriting }, - { 1346, PT_SC, ucp_Sinhala }, - { 1354, PT_PC, ucp_Sk }, - { 1357, PT_PC, ucp_Sm }, - { 1360, PT_PC, ucp_So }, - { 1363, PT_SC, ucp_Sogdian }, - { 1371, PT_SC, ucp_Sora_Sompeng }, - { 1384, PT_SC, ucp_Soyombo }, - { 1392, PT_SC, ucp_Sundanese }, - { 1402, PT_SC, ucp_Syloti_Nagri }, - { 1415, PT_SC, ucp_Syriac }, - { 1422, PT_SC, ucp_Tagalog }, - { 1430, PT_SC, ucp_Tagbanwa }, - { 1439, PT_SC, ucp_Tai_Le }, - { 1446, PT_SC, ucp_Tai_Tham }, - { 1455, PT_SC, ucp_Tai_Viet }, - { 1464, PT_SC, ucp_Takri }, - { 1470, PT_SC, ucp_Tamil }, - { 1476, PT_SC, ucp_Tangut }, - { 1483, PT_SC, ucp_Telugu }, - { 1490, PT_SC, ucp_Thaana }, - { 1497, PT_SC, ucp_Thai }, - { 1502, PT_SC, ucp_Tibetan }, - { 1510, PT_SC, ucp_Tifinagh }, - { 1519, PT_SC, ucp_Tirhuta }, - { 1527, PT_SC, ucp_Ugaritic }, - { 1536, PT_SC, ucp_Unknown }, - { 1544, PT_SC, ucp_Vai }, - { 1548, PT_SC, ucp_Wancho }, - { 1555, PT_SC, ucp_Warang_Citi }, - { 1567, PT_ALNUM, 0 }, - { 1571, PT_PXSPACE, 0 }, - { 1575, PT_SPACE, 0 }, - { 1579, PT_UCNC, 0 }, - { 1583, PT_WORD, 0 }, - { 1587, PT_SC, ucp_Yezidi }, - { 1594, PT_SC, ucp_Yi }, - { 1597, PT_GC, ucp_Z }, - { 1599, PT_SC, ucp_Zanabazar_Square }, - { 1616, PT_PC, ucp_Zl }, - { 1619, PT_PC, ucp_Zp }, - { 1622, PT_PC, ucp_Zs } + { 276, PT_SC, ucp_Cypro_Minoan }, + { 289, PT_SC, ucp_Cyrillic }, + { 298, PT_SC, ucp_Deseret }, + { 306, PT_SC, ucp_Devanagari }, + { 317, PT_SC, ucp_Dives_Akuru }, + { 329, PT_SC, ucp_Dogra }, + { 335, PT_SC, ucp_Duployan }, + { 344, PT_SC, ucp_Egyptian_Hieroglyphs }, + { 365, PT_SC, ucp_Elbasan }, + { 373, PT_SC, ucp_Elymaic }, + { 381, PT_SC, ucp_Ethiopic }, + { 390, PT_SC, ucp_Georgian }, + { 399, PT_SC, ucp_Glagolitic }, + { 410, PT_SC, ucp_Gothic }, + { 417, PT_SC, ucp_Grantha }, + { 425, PT_SC, ucp_Greek }, + { 431, PT_SC, ucp_Gujarati }, + { 440, PT_SC, ucp_Gunjala_Gondi }, + { 454, PT_SC, ucp_Gurmukhi }, + { 463, PT_SC, ucp_Han }, + { 467, PT_SC, ucp_Hangul }, + { 474, PT_SC, ucp_Hanifi_Rohingya }, + { 490, PT_SC, ucp_Hanunoo }, + { 498, PT_SC, ucp_Hatran }, + { 505, PT_SC, ucp_Hebrew }, + { 512, PT_SC, ucp_Hiragana }, + { 521, PT_SC, ucp_Imperial_Aramaic }, + { 538, PT_SC, ucp_Inherited }, + { 548, PT_SC, ucp_Inscriptional_Pahlavi }, + { 570, PT_SC, ucp_Inscriptional_Parthian }, + { 593, PT_SC, ucp_Javanese }, + { 602, PT_SC, ucp_Kaithi }, + { 609, PT_SC, ucp_Kannada }, + { 617, PT_SC, ucp_Katakana }, + { 626, PT_SC, ucp_Kayah_Li }, + { 635, PT_SC, ucp_Kharoshthi }, + { 646, PT_SC, ucp_Khitan_Small_Script }, + { 666, PT_SC, ucp_Khmer }, + { 672, PT_SC, ucp_Khojki }, + { 679, PT_SC, ucp_Khudawadi }, + { 689, PT_GC, ucp_L }, + { 691, PT_LAMP, 0 }, + { 694, PT_SC, ucp_Lao }, + { 698, PT_SC, ucp_Latin }, + { 704, PT_SC, ucp_Lepcha }, + { 711, PT_SC, ucp_Limbu }, + { 717, PT_SC, ucp_Linear_A }, + { 726, PT_SC, ucp_Linear_B }, + { 735, PT_SC, ucp_Lisu }, + { 740, PT_PC, ucp_Ll }, + { 743, PT_PC, ucp_Lm }, + { 746, PT_PC, ucp_Lo }, + { 749, PT_PC, ucp_Lt }, + { 752, PT_PC, ucp_Lu }, + { 755, PT_SC, ucp_Lycian }, + { 762, PT_SC, ucp_Lydian }, + { 769, PT_GC, ucp_M }, + { 771, PT_SC, ucp_Mahajani }, + { 780, PT_SC, ucp_Makasar }, + { 788, PT_SC, ucp_Malayalam }, + { 798, PT_SC, ucp_Mandaic }, + { 806, PT_SC, ucp_Manichaean }, + { 817, PT_SC, ucp_Marchen }, + { 825, PT_SC, ucp_Masaram_Gondi }, + { 839, PT_PC, ucp_Mc }, + { 842, PT_PC, ucp_Me }, + { 845, PT_SC, ucp_Medefaidrin }, + { 857, PT_SC, ucp_Meetei_Mayek }, + { 870, PT_SC, ucp_Mende_Kikakui }, + { 884, PT_SC, ucp_Meroitic_Cursive }, + { 901, PT_SC, ucp_Meroitic_Hieroglyphs }, + { 922, PT_SC, ucp_Miao }, + { 927, PT_PC, ucp_Mn }, + { 930, PT_SC, ucp_Modi }, + { 935, PT_SC, ucp_Mongolian }, + { 945, PT_SC, ucp_Mro }, + { 949, PT_SC, ucp_Multani }, + { 957, PT_SC, ucp_Myanmar }, + { 965, PT_GC, ucp_N }, + { 967, PT_SC, ucp_Nabataean }, + { 977, PT_SC, ucp_Nandinagari }, + { 989, PT_PC, ucp_Nd }, + { 992, PT_SC, ucp_New_Tai_Lue }, + { 1004, PT_SC, ucp_Newa }, + { 1009, PT_SC, ucp_Nko }, + { 1013, PT_PC, ucp_Nl }, + { 1016, PT_PC, ucp_No }, + { 1019, PT_SC, ucp_Nushu }, + { 1025, PT_SC, ucp_Nyiakeng_Puachue_Hmong }, + { 1048, PT_SC, ucp_Ogham }, + { 1054, PT_SC, ucp_Ol_Chiki }, + { 1063, PT_SC, ucp_Old_Hungarian }, + { 1077, PT_SC, ucp_Old_Italic }, + { 1088, PT_SC, ucp_Old_North_Arabian }, + { 1106, PT_SC, ucp_Old_Permic }, + { 1117, PT_SC, ucp_Old_Persian }, + { 1129, PT_SC, ucp_Old_Sogdian }, + { 1141, PT_SC, ucp_Old_South_Arabian }, + { 1159, PT_SC, ucp_Old_Turkic }, + { 1170, PT_SC, ucp_Old_Uyghur }, + { 1181, PT_SC, ucp_Oriya }, + { 1187, PT_SC, ucp_Osage }, + { 1193, PT_SC, ucp_Osmanya }, + { 1201, PT_GC, ucp_P }, + { 1203, PT_SC, ucp_Pahawh_Hmong }, + { 1216, PT_SC, ucp_Palmyrene }, + { 1226, PT_SC, ucp_Pau_Cin_Hau }, + { 1238, PT_PC, ucp_Pc }, + { 1241, PT_PC, ucp_Pd }, + { 1244, PT_PC, ucp_Pe }, + { 1247, PT_PC, ucp_Pf }, + { 1250, PT_SC, ucp_Phags_Pa }, + { 1259, PT_SC, ucp_Phoenician }, + { 1270, PT_PC, ucp_Pi }, + { 1273, PT_PC, ucp_Po }, + { 1276, PT_PC, ucp_Ps }, + { 1279, PT_SC, ucp_Psalter_Pahlavi }, + { 1295, PT_SC, ucp_Rejang }, + { 1302, PT_SC, ucp_Runic }, + { 1308, PT_GC, ucp_S }, + { 1310, PT_SC, ucp_Samaritan }, + { 1320, PT_SC, ucp_Saurashtra }, + { 1331, PT_PC, ucp_Sc }, + { 1334, PT_SC, ucp_Sharada }, + { 1342, PT_SC, ucp_Shavian }, + { 1350, PT_SC, ucp_Siddham }, + { 1358, PT_SC, ucp_SignWriting }, + { 1370, PT_SC, ucp_Sinhala }, + { 1378, PT_PC, ucp_Sk }, + { 1381, PT_PC, ucp_Sm }, + { 1384, PT_PC, ucp_So }, + { 1387, PT_SC, ucp_Sogdian }, + { 1395, PT_SC, ucp_Sora_Sompeng }, + { 1408, PT_SC, ucp_Soyombo }, + { 1416, PT_SC, ucp_Sundanese }, + { 1426, PT_SC, ucp_Syloti_Nagri }, + { 1439, PT_SC, ucp_Syriac }, + { 1446, PT_SC, ucp_Tagalog }, + { 1454, PT_SC, ucp_Tagbanwa }, + { 1463, PT_SC, ucp_Tai_Le }, + { 1470, PT_SC, ucp_Tai_Tham }, + { 1479, PT_SC, ucp_Tai_Viet }, + { 1488, PT_SC, ucp_Takri }, + { 1494, PT_SC, ucp_Tamil }, + { 1500, PT_SC, ucp_Tangsa }, + { 1507, PT_SC, ucp_Tangut }, + { 1514, PT_SC, ucp_Telugu }, + { 1521, PT_SC, ucp_Thaana }, + { 1528, PT_SC, ucp_Thai }, + { 1533, PT_SC, ucp_Tibetan }, + { 1541, PT_SC, ucp_Tifinagh }, + { 1550, PT_SC, ucp_Tirhuta }, + { 1558, PT_SC, ucp_Toto }, + { 1563, PT_SC, ucp_Ugaritic }, + { 1572, PT_SC, ucp_Unknown }, + { 1580, PT_SC, ucp_Vai }, + { 1584, PT_SC, ucp_Vithkuqi }, + { 1593, PT_SC, ucp_Wancho }, + { 1600, PT_SC, ucp_Warang_Citi }, + { 1612, PT_ALNUM, 0 }, + { 1616, PT_PXSPACE, 0 }, + { 1620, PT_SPACE, 0 }, + { 1624, PT_UCNC, 0 }, + { 1628, PT_WORD, 0 }, + { 1632, PT_SC, ucp_Yezidi }, + { 1639, PT_SC, ucp_Yi }, + { 1642, PT_GC, ucp_Z }, + { 1644, PT_SC, ucp_Zanabazar_Square }, + { 1661, PT_PC, ucp_Zl }, + { 1664, PT_PC, ucp_Zp }, + { 1667, PT_PC, ucp_Zs } }; const size_t PRIV(utt_size) = sizeof(PRIV(utt)) / sizeof(ucp_type_table); diff --git a/thirdparty/pcre2/src/pcre2_ucd.c b/thirdparty/pcre2/src/pcre2_ucd.c index 46e23ff06b..0b8ac75bd4 100644 --- a/thirdparty/pcre2/src/pcre2_ucd.c +++ b/thirdparty/pcre2/src/pcre2_ucd.c @@ -20,7 +20,7 @@ needed. */ /* Unicode character database. */ /* This file was autogenerated by the MultiStage2.py script. */ -/* Total size: 101044 bytes, block size: 128. */ +/* Total size: 102844 bytes, block size: 128. */ /* The tables herein are needed only when UCP support is built, and in PCRE2 that happens automatically with UTF support. @@ -39,7 +39,7 @@ const uint16_t PRIV(ucd_stage2)[] = {0}; const uint32_t PRIV(ucd_caseless_sets)[] = {0}; #else -const char *PRIV(unicode_version) = "13.0.0"; +const char *PRIV(unicode_version) = "14.0.0"; /* If the 32-bit library is run in non-32-bit mode, character values greater than 0x10ffff may be encountered. For these we set up a @@ -116,16 +116,16 @@ set of decimal digits. It is used to ensure that all the digits in a script run come from the same set. */ const uint32_t PRIV(ucd_digit_sets)[] = { - 65, /* Number of subsequent values */ + 66, /* Number of subsequent values */ 0x00039, 0x00669, 0x006f9, 0x007c9, 0x0096f, 0x009ef, 0x00a6f, 0x00aef, 0x00b6f, 0x00bef, 0x00c6f, 0x00cef, 0x00d6f, 0x00def, 0x00e59, 0x00ed9, 0x00f29, 0x01049, 0x01099, 0x017e9, 0x01819, 0x0194f, 0x019d9, 0x01a89, 0x01a99, 0x01b59, 0x01bb9, 0x01c49, 0x01c59, 0x0a629, 0x0a8d9, 0x0a909, 0x0a9d9, 0x0a9f9, 0x0aa59, 0x0abf9, 0x0ff19, 0x104a9, 0x10d39, 0x1106f, 0x110f9, 0x1113f, 0x111d9, 0x112f9, 0x11459, 0x114d9, 0x11659, 0x116c9, - 0x11739, 0x118e9, 0x11959, 0x11c59, 0x11d59, 0x11da9, 0x16a69, 0x16b59, - 0x1d7d7, 0x1d7e1, 0x1d7eb, 0x1d7f5, 0x1d7ff, 0x1e149, 0x1e2f9, 0x1e959, - 0x1fbf9, + 0x11739, 0x118e9, 0x11959, 0x11c59, 0x11d59, 0x11da9, 0x16a69, 0x16ac9, + 0x16b59, 0x1d7d7, 0x1d7e1, 0x1d7eb, 0x1d7f5, 0x1d7ff, 0x1e149, 0x1e2f9, + 0x1e959, 0x1fbf9, }; /* This vector is a list of lists of scripts for the Script Extension @@ -135,55 +135,59 @@ const uint8_t PRIV(ucd_script_sets)[] = { /* 0 */ 0, /* 1 */ 1, 11, 0, /* 4 */ 1, 144, 0, - /* 7 */ 1, 50, 0, - /* 10 */ 1, 56, 0, - /* 13 */ 3, 15, 0, - /* 16 */ 4, 23, 0, - /* 19 */ 6, 84, 0, - /* 22 */ 12, 36, 0, - /* 25 */ 13, 18, 0, - /* 28 */ 13, 34, 0, - /* 31 */ 13, 118, 0, - /* 34 */ 13, 50, 0, - /* 37 */ 15, 107, 0, - /* 40 */ 15, 150, 0, - /* 43 */ 15, 100, 0, - /* 46 */ 15, 54, 0, - /* 49 */ 17, 34, 0, - /* 52 */ 107, 54, 0, - /* 55 */ 21, 108, 0, - /* 58 */ 22, 129, 0, - /* 61 */ 23, 34, 0, - /* 64 */ 27, 30, 0, - /* 67 */ 29, 150, 0, - /* 70 */ 34, 38, 0, - /* 73 */ 38, 65, 0, - /* 76 */ 1, 50, 56, 0, - /* 80 */ 1, 56, 156, 0, - /* 84 */ 3, 96, 49, 0, - /* 88 */ 96, 39, 53, 0, - /* 92 */ 12, 110, 36, 0, - /* 96 */ 15, 107, 29, 0, - /* 100 */ 15, 107, 34, 0, - /* 104 */ 23, 27, 30, 0, - /* 108 */ 69, 34, 39, 0, - /* 112 */ 3, 15, 107, 29, 0, - /* 117 */ 7, 25, 52, 51, 0, - /* 122 */ 15, 142, 85, 111, 0, - /* 127 */ 1, 144, 50, 56, 156, 0, - /* 133 */ 4, 24, 23, 27, 30, 0, - /* 139 */ 4, 24, 23, 27, 30, 61, 0, - /* 146 */ 15, 29, 37, 44, 54, 55, 0, - /* 153 */ 132, 1, 95, 112, 121, 144, 148, 50, 0, - /* 162 */ 3, 15, 107, 29, 150, 44, 55, 124, 0, - /* 171 */ 15, 142, 21, 22, 108, 85, 111, 114, 109, 102, 124, 0, - /* 183 */ 3, 15, 107, 21, 22, 29, 34, 37, 44, 54, 55, 124, 0, - /* 196 */ 3, 15, 107, 21, 22, 29, 34, 37, 44, 100, 54, 55, 124, 0, - /* 210 */ 15, 142, 21, 22, 108, 29, 85, 111, 114, 150, 109, 102, 124, 0, - /* 224 */ 15, 142, 21, 22, 108, 29, 85, 111, 37, 114, 150, 109, 102, 124, 0, - /* 239 */ 3, 15, 142, 143, 138, 107, 21, 22, 29, 111, 37, 150, 44, 109, 48, 49, 102, 54, 55, 124, 0, - /* 260 */ 3, 15, 142, 143, 138, 107, 21, 22, 29, 35, 111, 37, 150, 44, 109, 48, 49, 102, 54, 55, 124, 0, - /* 282 */ + /* 7 */ 1, 64, 0, + /* 10 */ 1, 50, 0, + /* 13 */ 1, 56, 0, + /* 16 */ 3, 15, 0, + /* 19 */ 4, 23, 0, + /* 22 */ 6, 84, 0, + /* 25 */ 12, 36, 0, + /* 28 */ 13, 18, 0, + /* 31 */ 13, 34, 0, + /* 34 */ 13, 118, 0, + /* 37 */ 13, 50, 0, + /* 40 */ 15, 107, 0, + /* 43 */ 15, 150, 0, + /* 46 */ 15, 100, 0, + /* 49 */ 15, 54, 0, + /* 52 */ 17, 34, 0, + /* 55 */ 107, 54, 0, + /* 58 */ 21, 108, 0, + /* 61 */ 22, 129, 0, + /* 64 */ 23, 34, 0, + /* 67 */ 27, 30, 0, + /* 70 */ 29, 150, 0, + /* 73 */ 34, 38, 0, + /* 76 */ 112, 158, 0, + /* 79 */ 38, 65, 0, + /* 82 */ 1, 50, 56, 0, + /* 86 */ 1, 56, 156, 0, + /* 90 */ 3, 96, 49, 0, + /* 94 */ 96, 39, 53, 0, + /* 98 */ 157, 12, 36, 0, + /* 102 */ 12, 110, 36, 0, + /* 106 */ 15, 107, 29, 0, + /* 110 */ 15, 107, 34, 0, + /* 114 */ 23, 27, 30, 0, + /* 118 */ 69, 34, 39, 0, + /* 122 */ 3, 15, 107, 29, 0, + /* 127 */ 7, 25, 52, 51, 0, + /* 132 */ 15, 142, 85, 111, 0, + /* 137 */ 4, 24, 23, 27, 30, 0, + /* 143 */ 1, 64, 144, 50, 56, 156, 0, + /* 150 */ 4, 24, 23, 27, 30, 61, 0, + /* 157 */ 15, 29, 37, 44, 54, 55, 0, + /* 164 */ 132, 1, 64, 144, 50, 56, 156, 0, + /* 172 */ 3, 15, 107, 29, 150, 44, 55, 124, 0, + /* 181 */ 132, 1, 95, 112, 158, 121, 144, 148, 50, 0, + /* 191 */ 15, 142, 21, 22, 108, 85, 111, 114, 109, 102, 124, 0, + /* 203 */ 3, 15, 107, 21, 22, 29, 34, 37, 44, 54, 55, 124, 0, + /* 216 */ 3, 15, 107, 21, 22, 29, 34, 37, 44, 100, 54, 55, 124, 0, + /* 230 */ 15, 142, 21, 22, 108, 29, 85, 111, 114, 150, 109, 102, 124, 0, + /* 244 */ 15, 142, 21, 22, 108, 29, 85, 111, 37, 114, 150, 109, 102, 124, 0, + /* 259 */ 3, 15, 142, 143, 138, 107, 21, 22, 29, 111, 37, 150, 44, 109, 48, 49, 102, 54, 55, 124, 0, + /* 280 */ 3, 15, 142, 143, 138, 107, 21, 22, 29, 35, 111, 37, 150, 44, 109, 48, 49, 102, 54, 55, 124, 0, + /* 302 */ }; /* These are the main two-stage UCD tables. The fields in each record are: @@ -192,7 +196,7 @@ offset to multichar other cases or zero (8 bits), offset to other case or zero (32 bits, signed), script extension (16 bits, signed), and a dummy 16-bit field to make the whole thing a multiple of 4 bytes. */ -const ucd_record PRIV(ucd_records)[] = { /* 11700 bytes, record size 12 */ +const ucd_record PRIV(ucd_records)[] = { /* 11964 bytes, record size 12 */ { 10, 0, 2, 0, 0, 10, 256, }, /* 0 */ { 10, 0, 2, 0, 0, 10, 0, }, /* 1 */ { 10, 0, 1, 0, 0, 10, 0, }, /* 2 */ @@ -390,9 +394,9 @@ const ucd_record PRIV(ucd_records)[] = { /* 11700 bytes, record size 12 */ { 13, 9, 12, 88, 1, 13, 0, }, /* 194 */ { 13, 5, 12, 88, -1, 13, 0, }, /* 195 */ { 13, 26, 12, 0, 0, 13, 0, }, /* 196 */ - { 13, 12, 3, 0, 0, -31, 0, }, /* 197 */ - { 13, 12, 3, 0, 0, -25, 0, }, /* 198 */ - { 28, 12, 3, 0, 0, -28, 0, }, /* 199 */ + { 13, 12, 3, 0, 0, -34, 0, }, /* 197 */ + { 13, 12, 3, 0, 0, -28, 0, }, /* 198 */ + { 28, 12, 3, 0, 0, -31, 0, }, /* 199 */ { 13, 11, 3, 0, 0, 13, 0, }, /* 200 */ { 13, 9, 12, 0, 15, 13, 0, }, /* 201 */ { 13, 5, 12, 0, -15, 13, 0, }, /* 202 */ @@ -413,761 +417,783 @@ const ucd_record PRIV(ucd_records)[] = { /* 11700 bytes, record size 12 */ { 1, 25, 12, 0, 0, 1, 0, }, /* 217 */ { 1, 21, 12, 0, 0, 1, 0, }, /* 218 */ { 1, 23, 12, 0, 0, 1, 0, }, /* 219 */ - { 10, 21, 12, 0, 0, -127, 0, }, /* 220 */ + { 10, 21, 12, 0, 0, -143, 0, }, /* 220 */ { 1, 26, 12, 0, 0, 1, 0, }, /* 221 */ { 1, 12, 3, 0, 0, 1, 0, }, /* 222 */ - { 1, 1, 2, 0, 0, -76, 0, }, /* 223 */ - { 1, 7, 12, 0, 0, 1, 0, }, /* 224 */ - { 10, 6, 12, 0, 0, -153, 0, }, /* 225 */ - { 28, 12, 3, 0, 0, -7, 0, }, /* 226 */ - { 1, 13, 12, 0, 0, -80, 0, }, /* 227 */ - { 1, 21, 12, 0, 0, -4, 0, }, /* 228 */ - { 1, 6, 12, 0, 0, 1, 0, }, /* 229 */ - { 1, 13, 12, 0, 0, 1, 0, }, /* 230 */ - { 50, 21, 12, 0, 0, 50, 0, }, /* 231 */ - { 50, 1, 4, 0, 0, 50, 0, }, /* 232 */ - { 50, 7, 12, 0, 0, 50, 0, }, /* 233 */ - { 50, 12, 3, 0, 0, 50, 0, }, /* 234 */ - { 56, 7, 12, 0, 0, 56, 0, }, /* 235 */ - { 56, 12, 3, 0, 0, 56, 0, }, /* 236 */ - { 64, 13, 12, 0, 0, 64, 0, }, /* 237 */ - { 64, 7, 12, 0, 0, 64, 0, }, /* 238 */ - { 64, 12, 3, 0, 0, 64, 0, }, /* 239 */ - { 64, 6, 12, 0, 0, 64, 0, }, /* 240 */ - { 64, 26, 12, 0, 0, 64, 0, }, /* 241 */ - { 64, 21, 12, 0, 0, 64, 0, }, /* 242 */ - { 64, 23, 12, 0, 0, 64, 0, }, /* 243 */ - { 90, 7, 12, 0, 0, 90, 0, }, /* 244 */ - { 90, 12, 3, 0, 0, 90, 0, }, /* 245 */ - { 90, 6, 12, 0, 0, 90, 0, }, /* 246 */ - { 90, 21, 12, 0, 0, 90, 0, }, /* 247 */ - { 95, 7, 12, 0, 0, 95, 0, }, /* 248 */ - { 95, 12, 3, 0, 0, 95, 0, }, /* 249 */ - { 95, 21, 12, 0, 0, 95, 0, }, /* 250 */ - { 15, 12, 3, 0, 0, 15, 0, }, /* 251 */ - { 15, 10, 5, 0, 0, 15, 0, }, /* 252 */ - { 15, 7, 12, 0, 0, 15, 0, }, /* 253 */ - { 28, 12, 3, 0, 0, -196, 0, }, /* 254 */ - { 28, 12, 3, 0, 0, -183, 0, }, /* 255 */ - { 10, 21, 12, 0, 0, -239, 0, }, /* 256 */ - { 10, 21, 12, 0, 0, -260, 0, }, /* 257 */ - { 15, 13, 12, 0, 0, -122, 0, }, /* 258 */ - { 15, 21, 12, 0, 0, 15, 0, }, /* 259 */ - { 15, 6, 12, 0, 0, 15, 0, }, /* 260 */ - { 3, 7, 12, 0, 0, 3, 0, }, /* 261 */ - { 3, 12, 3, 0, 0, 3, 0, }, /* 262 */ - { 3, 10, 5, 0, 0, 3, 0, }, /* 263 */ - { 3, 10, 3, 0, 0, 3, 0, }, /* 264 */ - { 3, 13, 12, 0, 0, -84, 0, }, /* 265 */ - { 3, 23, 12, 0, 0, 3, 0, }, /* 266 */ - { 3, 15, 12, 0, 0, 3, 0, }, /* 267 */ - { 3, 26, 12, 0, 0, 3, 0, }, /* 268 */ - { 3, 21, 12, 0, 0, 3, 0, }, /* 269 */ - { 22, 12, 3, 0, 0, 22, 0, }, /* 270 */ - { 22, 10, 5, 0, 0, 22, 0, }, /* 271 */ - { 22, 7, 12, 0, 0, 22, 0, }, /* 272 */ - { 22, 13, 12, 0, 0, -58, 0, }, /* 273 */ - { 22, 21, 12, 0, 0, 22, 0, }, /* 274 */ - { 21, 12, 3, 0, 0, 21, 0, }, /* 275 */ - { 21, 10, 5, 0, 0, 21, 0, }, /* 276 */ - { 21, 7, 12, 0, 0, 21, 0, }, /* 277 */ - { 21, 13, 12, 0, 0, -55, 0, }, /* 278 */ - { 21, 21, 12, 0, 0, 21, 0, }, /* 279 */ - { 21, 23, 12, 0, 0, 21, 0, }, /* 280 */ - { 44, 12, 3, 0, 0, 44, 0, }, /* 281 */ - { 44, 10, 5, 0, 0, 44, 0, }, /* 282 */ - { 44, 7, 12, 0, 0, 44, 0, }, /* 283 */ - { 44, 10, 3, 0, 0, 44, 0, }, /* 284 */ - { 44, 13, 12, 0, 0, 44, 0, }, /* 285 */ - { 44, 26, 12, 0, 0, 44, 0, }, /* 286 */ - { 44, 15, 12, 0, 0, 44, 0, }, /* 287 */ - { 54, 12, 3, 0, 0, 54, 0, }, /* 288 */ - { 54, 7, 12, 0, 0, 54, 0, }, /* 289 */ - { 54, 10, 3, 0, 0, 54, 0, }, /* 290 */ - { 54, 10, 5, 0, 0, 54, 0, }, /* 291 */ - { 54, 13, 12, 0, 0, -52, 0, }, /* 292 */ - { 54, 15, 12, 0, 0, -52, 0, }, /* 293 */ - { 54, 26, 12, 0, 0, -52, 0, }, /* 294 */ - { 54, 26, 12, 0, 0, 54, 0, }, /* 295 */ - { 54, 23, 12, 0, 0, 54, 0, }, /* 296 */ - { 55, 12, 3, 0, 0, 55, 0, }, /* 297 */ - { 55, 10, 5, 0, 0, 55, 0, }, /* 298 */ - { 55, 7, 12, 0, 0, 55, 0, }, /* 299 */ - { 55, 13, 12, 0, 0, 55, 0, }, /* 300 */ - { 55, 21, 12, 0, 0, 55, 0, }, /* 301 */ - { 55, 15, 12, 0, 0, 55, 0, }, /* 302 */ - { 55, 26, 12, 0, 0, 55, 0, }, /* 303 */ - { 29, 7, 12, 0, 0, 29, 0, }, /* 304 */ - { 29, 12, 3, 0, 0, 29, 0, }, /* 305 */ - { 29, 10, 5, 0, 0, 29, 0, }, /* 306 */ - { 29, 21, 12, 0, 0, 29, 0, }, /* 307 */ - { 29, 10, 3, 0, 0, 29, 0, }, /* 308 */ - { 29, 13, 12, 0, 0, -67, 0, }, /* 309 */ - { 37, 12, 3, 0, 0, 37, 0, }, /* 310 */ - { 37, 10, 5, 0, 0, 37, 0, }, /* 311 */ - { 37, 7, 12, 0, 0, 37, 0, }, /* 312 */ - { 37, 10, 3, 0, 0, 37, 0, }, /* 313 */ - { 37, 7, 4, 0, 0, 37, 0, }, /* 314 */ - { 37, 26, 12, 0, 0, 37, 0, }, /* 315 */ - { 37, 15, 12, 0, 0, 37, 0, }, /* 316 */ - { 37, 13, 12, 0, 0, 37, 0, }, /* 317 */ - { 48, 12, 3, 0, 0, 48, 0, }, /* 318 */ - { 48, 10, 5, 0, 0, 48, 0, }, /* 319 */ - { 48, 7, 12, 0, 0, 48, 0, }, /* 320 */ - { 48, 10, 3, 0, 0, 48, 0, }, /* 321 */ - { 48, 13, 12, 0, 0, 48, 0, }, /* 322 */ - { 48, 21, 12, 0, 0, 48, 0, }, /* 323 */ - { 57, 7, 12, 0, 0, 57, 0, }, /* 324 */ - { 57, 12, 3, 0, 0, 57, 0, }, /* 325 */ - { 57, 7, 5, 0, 0, 57, 0, }, /* 326 */ - { 57, 6, 12, 0, 0, 57, 0, }, /* 327 */ - { 57, 21, 12, 0, 0, 57, 0, }, /* 328 */ - { 57, 13, 12, 0, 0, 57, 0, }, /* 329 */ - { 33, 7, 12, 0, 0, 33, 0, }, /* 330 */ - { 33, 12, 3, 0, 0, 33, 0, }, /* 331 */ - { 33, 7, 5, 0, 0, 33, 0, }, /* 332 */ - { 33, 6, 12, 0, 0, 33, 0, }, /* 333 */ - { 33, 13, 12, 0, 0, 33, 0, }, /* 334 */ - { 58, 7, 12, 0, 0, 58, 0, }, /* 335 */ - { 58, 26, 12, 0, 0, 58, 0, }, /* 336 */ - { 58, 21, 12, 0, 0, 58, 0, }, /* 337 */ - { 58, 12, 3, 0, 0, 58, 0, }, /* 338 */ - { 58, 13, 12, 0, 0, 58, 0, }, /* 339 */ - { 58, 15, 12, 0, 0, 58, 0, }, /* 340 */ - { 58, 22, 12, 0, 0, 58, 0, }, /* 341 */ - { 58, 18, 12, 0, 0, 58, 0, }, /* 342 */ - { 58, 10, 5, 0, 0, 58, 0, }, /* 343 */ - { 39, 7, 12, 0, 0, 39, 0, }, /* 344 */ - { 39, 10, 12, 0, 0, 39, 0, }, /* 345 */ - { 39, 12, 3, 0, 0, 39, 0, }, /* 346 */ - { 39, 10, 5, 0, 0, 39, 0, }, /* 347 */ - { 39, 13, 12, 0, 0, -88, 0, }, /* 348 */ - { 39, 21, 12, 0, 0, 39, 0, }, /* 349 */ - { 39, 13, 12, 0, 0, 39, 0, }, /* 350 */ - { 39, 26, 12, 0, 0, 39, 0, }, /* 351 */ - { 17, 9, 12, 0, 7264, 17, 0, }, /* 352 */ - { 17, 5, 12, 0, 3008, 17, 0, }, /* 353 */ - { 10, 21, 12, 0, 0, -49, 0, }, /* 354 */ - { 17, 6, 12, 0, 0, 17, 0, }, /* 355 */ - { 24, 7, 6, 0, 0, 24, 0, }, /* 356 */ - { 24, 7, 7, 0, 0, 24, 0, }, /* 357 */ - { 24, 7, 8, 0, 0, 24, 0, }, /* 358 */ - { 16, 7, 12, 0, 0, 16, 0, }, /* 359 */ - { 16, 12, 3, 0, 0, 16, 0, }, /* 360 */ - { 16, 21, 12, 0, 0, 16, 0, }, /* 361 */ - { 16, 15, 12, 0, 0, 16, 0, }, /* 362 */ - { 16, 26, 12, 0, 0, 16, 0, }, /* 363 */ - { 9, 9, 12, 0, 38864, 9, 0, }, /* 364 */ - { 9, 9, 12, 0, 8, 9, 0, }, /* 365 */ - { 9, 5, 12, 0, -8, 9, 0, }, /* 366 */ - { 8, 17, 12, 0, 0, 8, 0, }, /* 367 */ - { 8, 7, 12, 0, 0, 8, 0, }, /* 368 */ - { 8, 26, 12, 0, 0, 8, 0, }, /* 369 */ - { 8, 21, 12, 0, 0, 8, 0, }, /* 370 */ - { 41, 29, 12, 0, 0, 41, 0, }, /* 371 */ - { 41, 7, 12, 0, 0, 41, 0, }, /* 372 */ - { 41, 22, 12, 0, 0, 41, 0, }, /* 373 */ - { 41, 18, 12, 0, 0, 41, 0, }, /* 374 */ - { 46, 7, 12, 0, 0, 46, 0, }, /* 375 */ - { 46, 14, 12, 0, 0, 46, 0, }, /* 376 */ - { 51, 7, 12, 0, 0, 51, 0, }, /* 377 */ - { 51, 12, 3, 0, 0, 51, 0, }, /* 378 */ - { 25, 7, 12, 0, 0, 25, 0, }, /* 379 */ - { 25, 12, 3, 0, 0, 25, 0, }, /* 380 */ - { 10, 21, 12, 0, 0, -117, 0, }, /* 381 */ - { 7, 7, 12, 0, 0, 7, 0, }, /* 382 */ - { 7, 12, 3, 0, 0, 7, 0, }, /* 383 */ - { 52, 7, 12, 0, 0, 52, 0, }, /* 384 */ - { 52, 12, 3, 0, 0, 52, 0, }, /* 385 */ - { 32, 7, 12, 0, 0, 32, 0, }, /* 386 */ - { 32, 12, 3, 0, 0, 32, 0, }, /* 387 */ - { 32, 10, 5, 0, 0, 32, 0, }, /* 388 */ - { 32, 21, 12, 0, 0, 32, 0, }, /* 389 */ - { 32, 6, 12, 0, 0, 32, 0, }, /* 390 */ - { 32, 23, 12, 0, 0, 32, 0, }, /* 391 */ - { 32, 13, 12, 0, 0, 32, 0, }, /* 392 */ - { 32, 15, 12, 0, 0, 32, 0, }, /* 393 */ - { 38, 21, 12, 0, 0, 38, 0, }, /* 394 */ - { 10, 21, 12, 0, 0, -73, 0, }, /* 395 */ - { 38, 17, 12, 0, 0, 38, 0, }, /* 396 */ - { 38, 12, 3, 0, 0, 38, 0, }, /* 397 */ - { 38, 1, 2, 0, 0, 38, 0, }, /* 398 */ - { 38, 13, 12, 0, 0, 38, 0, }, /* 399 */ - { 38, 7, 12, 0, 0, 38, 0, }, /* 400 */ - { 38, 6, 12, 0, 0, 38, 0, }, /* 401 */ - { 35, 7, 12, 0, 0, 35, 0, }, /* 402 */ - { 35, 12, 3, 0, 0, 35, 0, }, /* 403 */ - { 35, 10, 5, 0, 0, 35, 0, }, /* 404 */ - { 35, 26, 12, 0, 0, 35, 0, }, /* 405 */ - { 35, 21, 12, 0, 0, 35, 0, }, /* 406 */ - { 35, 13, 12, 0, 0, 35, 0, }, /* 407 */ - { 53, 7, 12, 0, 0, 53, 0, }, /* 408 */ - { 40, 7, 12, 0, 0, 40, 0, }, /* 409 */ - { 40, 13, 12, 0, 0, 40, 0, }, /* 410 */ - { 40, 15, 12, 0, 0, 40, 0, }, /* 411 */ - { 40, 26, 12, 0, 0, 40, 0, }, /* 412 */ - { 32, 26, 12, 0, 0, 32, 0, }, /* 413 */ - { 6, 7, 12, 0, 0, 6, 0, }, /* 414 */ - { 6, 12, 3, 0, 0, 6, 0, }, /* 415 */ - { 6, 10, 5, 0, 0, 6, 0, }, /* 416 */ - { 6, 21, 12, 0, 0, 6, 0, }, /* 417 */ - { 91, 7, 12, 0, 0, 91, 0, }, /* 418 */ - { 91, 10, 5, 0, 0, 91, 0, }, /* 419 */ - { 91, 12, 3, 0, 0, 91, 0, }, /* 420 */ - { 91, 10, 12, 0, 0, 91, 0, }, /* 421 */ - { 91, 13, 12, 0, 0, 91, 0, }, /* 422 */ - { 91, 21, 12, 0, 0, 91, 0, }, /* 423 */ - { 91, 6, 12, 0, 0, 91, 0, }, /* 424 */ - { 28, 11, 3, 0, 0, 28, 0, }, /* 425 */ - { 62, 12, 3, 0, 0, 62, 0, }, /* 426 */ - { 62, 10, 5, 0, 0, 62, 0, }, /* 427 */ - { 62, 7, 12, 0, 0, 62, 0, }, /* 428 */ - { 62, 10, 3, 0, 0, 62, 0, }, /* 429 */ - { 62, 13, 12, 0, 0, 62, 0, }, /* 430 */ - { 62, 21, 12, 0, 0, 62, 0, }, /* 431 */ - { 62, 26, 12, 0, 0, 62, 0, }, /* 432 */ - { 76, 12, 3, 0, 0, 76, 0, }, /* 433 */ - { 76, 10, 5, 0, 0, 76, 0, }, /* 434 */ - { 76, 7, 12, 0, 0, 76, 0, }, /* 435 */ - { 76, 13, 12, 0, 0, 76, 0, }, /* 436 */ - { 93, 7, 12, 0, 0, 93, 0, }, /* 437 */ - { 93, 12, 3, 0, 0, 93, 0, }, /* 438 */ - { 93, 10, 5, 0, 0, 93, 0, }, /* 439 */ - { 93, 21, 12, 0, 0, 93, 0, }, /* 440 */ - { 70, 7, 12, 0, 0, 70, 0, }, /* 441 */ - { 70, 10, 5, 0, 0, 70, 0, }, /* 442 */ - { 70, 12, 3, 0, 0, 70, 0, }, /* 443 */ - { 70, 21, 12, 0, 0, 70, 0, }, /* 444 */ - { 70, 13, 12, 0, 0, 70, 0, }, /* 445 */ - { 73, 13, 12, 0, 0, 73, 0, }, /* 446 */ - { 73, 7, 12, 0, 0, 73, 0, }, /* 447 */ - { 73, 6, 12, 0, 0, 73, 0, }, /* 448 */ - { 73, 21, 12, 0, 0, 73, 0, }, /* 449 */ - { 13, 5, 12, 63, -6222, 13, 0, }, /* 450 */ - { 13, 5, 12, 67, -6221, 13, 0, }, /* 451 */ - { 13, 5, 12, 71, -6212, 13, 0, }, /* 452 */ - { 13, 5, 12, 75, -6210, 13, 0, }, /* 453 */ - { 13, 5, 12, 79, -6210, 13, 0, }, /* 454 */ - { 13, 5, 12, 79, -6211, 13, 0, }, /* 455 */ - { 13, 5, 12, 84, -6204, 13, 0, }, /* 456 */ - { 13, 5, 12, 88, -6180, 13, 0, }, /* 457 */ - { 13, 5, 12, 108, 35267, 13, 0, }, /* 458 */ - { 17, 9, 12, 0, -3008, 17, 0, }, /* 459 */ - { 76, 21, 12, 0, 0, 76, 0, }, /* 460 */ - { 28, 12, 3, 0, 0, -112, 0, }, /* 461 */ - { 28, 12, 3, 0, 0, 15, 0, }, /* 462 */ - { 10, 21, 12, 0, 0, -37, 0, }, /* 463 */ - { 28, 12, 3, 0, 0, -13, 0, }, /* 464 */ - { 28, 12, 3, 0, 0, -43, 0, }, /* 465 */ - { 28, 12, 3, 0, 0, -146, 0, }, /* 466 */ - { 10, 10, 5, 0, 0, -13, 0, }, /* 467 */ - { 10, 7, 12, 0, 0, -40, 0, }, /* 468 */ - { 10, 7, 12, 0, 0, -13, 0, }, /* 469 */ - { 10, 7, 12, 0, 0, 15, 0, }, /* 470 */ - { 10, 7, 12, 0, 0, -162, 0, }, /* 471 */ - { 10, 7, 12, 0, 0, -37, 0, }, /* 472 */ - { 28, 12, 3, 0, 0, -96, 0, }, /* 473 */ - { 10, 10, 5, 0, 0, 3, 0, }, /* 474 */ - { 28, 12, 3, 0, 0, -37, 0, }, /* 475 */ - { 10, 7, 12, 0, 0, 150, 0, }, /* 476 */ - { 13, 5, 12, 0, 0, 13, 0, }, /* 477 */ - { 13, 6, 12, 0, 0, 13, 0, }, /* 478 */ - { 34, 5, 12, 0, 35332, 34, 0, }, /* 479 */ - { 34, 5, 12, 0, 3814, 34, 0, }, /* 480 */ - { 34, 5, 12, 0, 35384, 34, 0, }, /* 481 */ - { 28, 12, 3, 0, 0, -34, 0, }, /* 482 */ - { 34, 9, 12, 92, 1, 34, 0, }, /* 483 */ - { 34, 5, 12, 92, -1, 34, 0, }, /* 484 */ - { 34, 5, 12, 92, -58, 34, 0, }, /* 485 */ - { 34, 9, 12, 0, -7615, 34, 0, }, /* 486 */ - { 20, 5, 12, 0, 8, 20, 0, }, /* 487 */ - { 20, 9, 12, 0, -8, 20, 0, }, /* 488 */ - { 20, 5, 12, 0, 74, 20, 0, }, /* 489 */ - { 20, 5, 12, 0, 86, 20, 0, }, /* 490 */ - { 20, 5, 12, 0, 100, 20, 0, }, /* 491 */ - { 20, 5, 12, 0, 128, 20, 0, }, /* 492 */ - { 20, 5, 12, 0, 112, 20, 0, }, /* 493 */ - { 20, 5, 12, 0, 126, 20, 0, }, /* 494 */ - { 20, 8, 12, 0, -8, 20, 0, }, /* 495 */ - { 20, 5, 12, 0, 9, 20, 0, }, /* 496 */ - { 20, 9, 12, 0, -74, 20, 0, }, /* 497 */ - { 20, 8, 12, 0, -9, 20, 0, }, /* 498 */ - { 20, 5, 12, 21, -7173, 20, 0, }, /* 499 */ - { 20, 9, 12, 0, -86, 20, 0, }, /* 500 */ - { 20, 9, 12, 0, -100, 20, 0, }, /* 501 */ - { 20, 9, 12, 0, -112, 20, 0, }, /* 502 */ - { 20, 9, 12, 0, -128, 20, 0, }, /* 503 */ - { 20, 9, 12, 0, -126, 20, 0, }, /* 504 */ - { 28, 1, 3, 0, 0, 28, 0, }, /* 505 */ - { 28, 1, 13, 0, 0, 28, 0, }, /* 506 */ - { 10, 27, 2, 0, 0, 10, 0, }, /* 507 */ - { 10, 28, 2, 0, 0, 10, 0, }, /* 508 */ - { 10, 29, 12, 0, 0, -70, 0, }, /* 509 */ - { 10, 21, 14, 0, 0, 10, 0, }, /* 510 */ - { 0, 2, 2, 0, 0, 0, 0, }, /* 511 */ - { 28, 12, 3, 0, 0, -100, 0, }, /* 512 */ - { 10, 9, 12, 0, 0, 10, 0, }, /* 513 */ - { 10, 5, 12, 0, 0, 10, 0, }, /* 514 */ - { 20, 9, 12, 96, -7517, 20, 0, }, /* 515 */ - { 34, 9, 12, 100, -8383, 34, 0, }, /* 516 */ - { 34, 9, 12, 104, -8262, 34, 0, }, /* 517 */ - { 34, 9, 12, 0, 28, 34, 0, }, /* 518 */ - { 10, 7, 12, 0, 0, 10, 0, }, /* 519 */ - { 10, 5, 14, 0, 0, 10, 0, }, /* 520 */ - { 34, 5, 12, 0, -28, 34, 0, }, /* 521 */ - { 34, 14, 12, 0, 16, 34, 0, }, /* 522 */ - { 34, 14, 12, 0, -16, 34, 0, }, /* 523 */ - { 34, 14, 12, 0, 0, 34, 0, }, /* 524 */ - { 10, 25, 14, 0, 0, 10, 0, }, /* 525 */ - { 10, 26, 12, 0, 26, 10, 0, }, /* 526 */ - { 10, 26, 14, 0, 26, 10, 0, }, /* 527 */ - { 10, 26, 12, 0, -26, 10, 0, }, /* 528 */ - { 5, 26, 12, 0, 0, 5, 0, }, /* 529 */ - { 18, 9, 12, 0, 48, 18, 0, }, /* 530 */ - { 18, 5, 12, 0, -48, 18, 0, }, /* 531 */ - { 34, 9, 12, 0, -10743, 34, 0, }, /* 532 */ - { 34, 9, 12, 0, -3814, 34, 0, }, /* 533 */ - { 34, 9, 12, 0, -10727, 34, 0, }, /* 534 */ - { 34, 5, 12, 0, -10795, 34, 0, }, /* 535 */ - { 34, 5, 12, 0, -10792, 34, 0, }, /* 536 */ - { 34, 9, 12, 0, -10780, 34, 0, }, /* 537 */ - { 34, 9, 12, 0, -10749, 34, 0, }, /* 538 */ - { 34, 9, 12, 0, -10783, 34, 0, }, /* 539 */ - { 34, 9, 12, 0, -10782, 34, 0, }, /* 540 */ - { 34, 9, 12, 0, -10815, 34, 0, }, /* 541 */ - { 11, 5, 12, 0, 0, 11, 0, }, /* 542 */ - { 11, 26, 12, 0, 0, 11, 0, }, /* 543 */ - { 11, 12, 3, 0, 0, 11, 0, }, /* 544 */ - { 11, 21, 12, 0, 0, 11, 0, }, /* 545 */ - { 11, 15, 12, 0, 0, 11, 0, }, /* 546 */ - { 17, 5, 12, 0, -7264, 17, 0, }, /* 547 */ - { 59, 7, 12, 0, 0, 59, 0, }, /* 548 */ - { 59, 6, 12, 0, 0, 59, 0, }, /* 549 */ - { 59, 21, 12, 0, 0, 59, 0, }, /* 550 */ - { 59, 12, 3, 0, 0, 59, 0, }, /* 551 */ - { 13, 12, 3, 0, 0, 13, 0, }, /* 552 */ - { 10, 21, 12, 0, 0, -25, 0, }, /* 553 */ - { 23, 26, 12, 0, 0, 23, 0, }, /* 554 */ - { 10, 21, 12, 0, 0, -139, 0, }, /* 555 */ - { 10, 21, 12, 0, 0, -133, 0, }, /* 556 */ - { 23, 6, 12, 0, 0, 23, 0, }, /* 557 */ - { 10, 7, 12, 0, 0, 23, 0, }, /* 558 */ - { 23, 14, 12, 0, 0, 23, 0, }, /* 559 */ - { 10, 22, 12, 0, 0, -139, 0, }, /* 560 */ - { 10, 18, 12, 0, 0, -139, 0, }, /* 561 */ - { 10, 26, 12, 0, 0, -133, 0, }, /* 562 */ - { 10, 17, 12, 0, 0, -133, 0, }, /* 563 */ - { 10, 22, 12, 0, 0, -133, 0, }, /* 564 */ - { 10, 18, 12, 0, 0, -133, 0, }, /* 565 */ - { 28, 12, 3, 0, 0, -16, 0, }, /* 566 */ - { 24, 10, 3, 0, 0, 24, 0, }, /* 567 */ - { 10, 17, 14, 0, 0, -133, 0, }, /* 568 */ - { 10, 6, 12, 0, 0, -64, 0, }, /* 569 */ - { 10, 7, 12, 0, 0, -104, 0, }, /* 570 */ - { 10, 21, 14, 0, 0, -104, 0, }, /* 571 */ - { 10, 26, 12, 0, 0, 23, 0, }, /* 572 */ - { 27, 7, 12, 0, 0, 27, 0, }, /* 573 */ - { 28, 12, 3, 0, 0, -64, 0, }, /* 574 */ - { 10, 24, 12, 0, 0, -64, 0, }, /* 575 */ - { 27, 6, 12, 0, 0, 27, 0, }, /* 576 */ - { 10, 17, 12, 0, 0, -64, 0, }, /* 577 */ - { 30, 7, 12, 0, 0, 30, 0, }, /* 578 */ - { 30, 6, 12, 0, 0, 30, 0, }, /* 579 */ - { 4, 7, 12, 0, 0, 4, 0, }, /* 580 */ - { 24, 7, 12, 0, 0, 24, 0, }, /* 581 */ - { 10, 15, 12, 0, 0, 23, 0, }, /* 582 */ - { 24, 26, 12, 0, 0, 24, 0, }, /* 583 */ - { 10, 26, 14, 0, 0, 23, 0, }, /* 584 */ - { 30, 26, 12, 0, 0, 30, 0, }, /* 585 */ - { 23, 7, 12, 0, 0, 23, 0, }, /* 586 */ - { 61, 7, 12, 0, 0, 61, 0, }, /* 587 */ - { 61, 6, 12, 0, 0, 61, 0, }, /* 588 */ - { 61, 26, 12, 0, 0, 61, 0, }, /* 589 */ - { 86, 7, 12, 0, 0, 86, 0, }, /* 590 */ - { 86, 6, 12, 0, 0, 86, 0, }, /* 591 */ - { 86, 21, 12, 0, 0, 86, 0, }, /* 592 */ - { 77, 7, 12, 0, 0, 77, 0, }, /* 593 */ - { 77, 6, 12, 0, 0, 77, 0, }, /* 594 */ - { 77, 21, 12, 0, 0, 77, 0, }, /* 595 */ - { 77, 13, 12, 0, 0, 77, 0, }, /* 596 */ - { 13, 9, 12, 108, 1, 13, 0, }, /* 597 */ - { 13, 5, 12, 108, -35267, 13, 0, }, /* 598 */ - { 13, 7, 12, 0, 0, 13, 0, }, /* 599 */ - { 13, 21, 12, 0, 0, 13, 0, }, /* 600 */ - { 79, 7, 12, 0, 0, 79, 0, }, /* 601 */ - { 79, 14, 12, 0, 0, 79, 0, }, /* 602 */ - { 79, 12, 3, 0, 0, 79, 0, }, /* 603 */ - { 79, 21, 12, 0, 0, 79, 0, }, /* 604 */ - { 10, 24, 12, 0, 0, -61, 0, }, /* 605 */ - { 34, 9, 12, 0, -35332, 34, 0, }, /* 606 */ - { 34, 9, 12, 0, -42280, 34, 0, }, /* 607 */ - { 34, 5, 12, 0, 48, 34, 0, }, /* 608 */ - { 34, 9, 12, 0, -42308, 34, 0, }, /* 609 */ - { 34, 9, 12, 0, -42319, 34, 0, }, /* 610 */ - { 34, 9, 12, 0, -42315, 34, 0, }, /* 611 */ - { 34, 9, 12, 0, -42305, 34, 0, }, /* 612 */ - { 34, 9, 12, 0, -42258, 34, 0, }, /* 613 */ - { 34, 9, 12, 0, -42282, 34, 0, }, /* 614 */ - { 34, 9, 12, 0, -42261, 34, 0, }, /* 615 */ - { 34, 9, 12, 0, 928, 34, 0, }, /* 616 */ - { 34, 9, 12, 0, -48, 34, 0, }, /* 617 */ - { 34, 9, 12, 0, -42307, 34, 0, }, /* 618 */ - { 34, 9, 12, 0, -35384, 34, 0, }, /* 619 */ - { 49, 7, 12, 0, 0, 49, 0, }, /* 620 */ - { 49, 12, 3, 0, 0, 49, 0, }, /* 621 */ - { 49, 10, 5, 0, 0, 49, 0, }, /* 622 */ - { 49, 26, 12, 0, 0, 49, 0, }, /* 623 */ - { 10, 15, 12, 0, 0, -224, 0, }, /* 624 */ - { 10, 15, 12, 0, 0, -210, 0, }, /* 625 */ - { 10, 26, 12, 0, 0, -171, 0, }, /* 626 */ - { 10, 23, 12, 0, 0, -171, 0, }, /* 627 */ - { 65, 7, 12, 0, 0, 65, 0, }, /* 628 */ - { 65, 21, 12, 0, 0, 65, 0, }, /* 629 */ - { 75, 10, 5, 0, 0, 75, 0, }, /* 630 */ - { 75, 7, 12, 0, 0, 75, 0, }, /* 631 */ - { 75, 12, 3, 0, 0, 75, 0, }, /* 632 */ - { 75, 21, 12, 0, 0, 75, 0, }, /* 633 */ - { 75, 13, 12, 0, 0, 75, 0, }, /* 634 */ - { 15, 12, 3, 0, 0, -13, 0, }, /* 635 */ - { 15, 7, 12, 0, 0, -46, 0, }, /* 636 */ - { 69, 13, 12, 0, 0, 69, 0, }, /* 637 */ - { 69, 7, 12, 0, 0, 69, 0, }, /* 638 */ - { 69, 12, 3, 0, 0, 69, 0, }, /* 639 */ - { 10, 21, 12, 0, 0, -108, 0, }, /* 640 */ - { 69, 21, 12, 0, 0, 69, 0, }, /* 641 */ - { 74, 7, 12, 0, 0, 74, 0, }, /* 642 */ - { 74, 12, 3, 0, 0, 74, 0, }, /* 643 */ - { 74, 10, 5, 0, 0, 74, 0, }, /* 644 */ - { 74, 21, 12, 0, 0, 74, 0, }, /* 645 */ - { 84, 12, 3, 0, 0, 84, 0, }, /* 646 */ - { 84, 10, 5, 0, 0, 84, 0, }, /* 647 */ - { 84, 7, 12, 0, 0, 84, 0, }, /* 648 */ - { 84, 21, 12, 0, 0, 84, 0, }, /* 649 */ - { 10, 6, 12, 0, 0, -19, 0, }, /* 650 */ - { 84, 13, 12, 0, 0, 84, 0, }, /* 651 */ - { 39, 6, 12, 0, 0, 39, 0, }, /* 652 */ - { 68, 7, 12, 0, 0, 68, 0, }, /* 653 */ - { 68, 12, 3, 0, 0, 68, 0, }, /* 654 */ - { 68, 10, 5, 0, 0, 68, 0, }, /* 655 */ - { 68, 13, 12, 0, 0, 68, 0, }, /* 656 */ - { 68, 21, 12, 0, 0, 68, 0, }, /* 657 */ - { 92, 7, 12, 0, 0, 92, 0, }, /* 658 */ - { 92, 12, 3, 0, 0, 92, 0, }, /* 659 */ - { 92, 6, 12, 0, 0, 92, 0, }, /* 660 */ - { 92, 21, 12, 0, 0, 92, 0, }, /* 661 */ - { 87, 7, 12, 0, 0, 87, 0, }, /* 662 */ - { 87, 10, 5, 0, 0, 87, 0, }, /* 663 */ - { 87, 12, 3, 0, 0, 87, 0, }, /* 664 */ - { 87, 21, 12, 0, 0, 87, 0, }, /* 665 */ - { 87, 6, 12, 0, 0, 87, 0, }, /* 666 */ - { 34, 5, 12, 0, -928, 34, 0, }, /* 667 */ - { 9, 5, 12, 0, -38864, 9, 0, }, /* 668 */ - { 87, 13, 12, 0, 0, 87, 0, }, /* 669 */ - { 24, 7, 9, 0, 0, 24, 0, }, /* 670 */ - { 24, 7, 10, 0, 0, 24, 0, }, /* 671 */ - { 0, 4, 12, 0, 0, 0, 0, }, /* 672 */ - { 0, 3, 12, 0, 0, 0, 0, }, /* 673 */ - { 26, 25, 12, 0, 0, 26, 0, }, /* 674 */ - { 1, 24, 12, 0, 0, 1, 0, }, /* 675 */ - { 1, 7, 12, 0, 0, -10, 0, }, /* 676 */ - { 1, 26, 12, 0, 0, -10, 0, }, /* 677 */ - { 10, 6, 3, 0, 0, -64, 0, }, /* 678 */ - { 36, 7, 12, 0, 0, 36, 0, }, /* 679 */ - { 10, 21, 12, 0, 0, -22, 0, }, /* 680 */ - { 10, 15, 12, 0, 0, -92, 0, }, /* 681 */ - { 10, 26, 12, 0, 0, -22, 0, }, /* 682 */ - { 20, 14, 12, 0, 0, 20, 0, }, /* 683 */ - { 20, 15, 12, 0, 0, 20, 0, }, /* 684 */ - { 20, 26, 12, 0, 0, 20, 0, }, /* 685 */ - { 71, 7, 12, 0, 0, 71, 0, }, /* 686 */ - { 67, 7, 12, 0, 0, 67, 0, }, /* 687 */ - { 28, 12, 3, 0, 0, -1, 0, }, /* 688 */ - { 10, 15, 12, 0, 0, -1, 0, }, /* 689 */ - { 42, 7, 12, 0, 0, 42, 0, }, /* 690 */ - { 42, 15, 12, 0, 0, 42, 0, }, /* 691 */ - { 19, 7, 12, 0, 0, 19, 0, }, /* 692 */ - { 19, 14, 12, 0, 0, 19, 0, }, /* 693 */ - { 118, 7, 12, 0, 0, 118, 0, }, /* 694 */ - { 118, 12, 3, 0, 0, 118, 0, }, /* 695 */ - { 60, 7, 12, 0, 0, 60, 0, }, /* 696 */ - { 60, 21, 12, 0, 0, 60, 0, }, /* 697 */ - { 43, 7, 12, 0, 0, 43, 0, }, /* 698 */ - { 43, 21, 12, 0, 0, 43, 0, }, /* 699 */ - { 43, 14, 12, 0, 0, 43, 0, }, /* 700 */ - { 14, 9, 12, 0, 40, 14, 0, }, /* 701 */ - { 14, 5, 12, 0, -40, 14, 0, }, /* 702 */ - { 47, 7, 12, 0, 0, 47, 0, }, /* 703 */ - { 45, 7, 12, 0, 0, 45, 0, }, /* 704 */ - { 45, 13, 12, 0, 0, 45, 0, }, /* 705 */ - { 136, 9, 12, 0, 40, 136, 0, }, /* 706 */ - { 136, 5, 12, 0, -40, 136, 0, }, /* 707 */ - { 106, 7, 12, 0, 0, 106, 0, }, /* 708 */ - { 104, 7, 12, 0, 0, 104, 0, }, /* 709 */ - { 104, 21, 12, 0, 0, 104, 0, }, /* 710 */ - { 110, 7, 12, 0, 0, 110, 0, }, /* 711 */ - { 12, 7, 12, 0, 0, 12, 0, }, /* 712 */ - { 81, 7, 12, 0, 0, 81, 0, }, /* 713 */ - { 81, 21, 12, 0, 0, 81, 0, }, /* 714 */ - { 81, 15, 12, 0, 0, 81, 0, }, /* 715 */ - { 120, 7, 12, 0, 0, 120, 0, }, /* 716 */ - { 120, 26, 12, 0, 0, 120, 0, }, /* 717 */ - { 120, 15, 12, 0, 0, 120, 0, }, /* 718 */ - { 116, 7, 12, 0, 0, 116, 0, }, /* 719 */ - { 116, 15, 12, 0, 0, 116, 0, }, /* 720 */ - { 128, 7, 12, 0, 0, 128, 0, }, /* 721 */ - { 128, 15, 12, 0, 0, 128, 0, }, /* 722 */ - { 66, 7, 12, 0, 0, 66, 0, }, /* 723 */ - { 66, 15, 12, 0, 0, 66, 0, }, /* 724 */ - { 66, 21, 12, 0, 0, 66, 0, }, /* 725 */ - { 72, 7, 12, 0, 0, 72, 0, }, /* 726 */ - { 72, 21, 12, 0, 0, 72, 0, }, /* 727 */ - { 98, 7, 12, 0, 0, 98, 0, }, /* 728 */ - { 97, 7, 12, 0, 0, 97, 0, }, /* 729 */ - { 97, 15, 12, 0, 0, 97, 0, }, /* 730 */ - { 31, 7, 12, 0, 0, 31, 0, }, /* 731 */ - { 31, 12, 3, 0, 0, 31, 0, }, /* 732 */ - { 31, 15, 12, 0, 0, 31, 0, }, /* 733 */ - { 31, 21, 12, 0, 0, 31, 0, }, /* 734 */ - { 88, 7, 12, 0, 0, 88, 0, }, /* 735 */ - { 88, 15, 12, 0, 0, 88, 0, }, /* 736 */ - { 88, 21, 12, 0, 0, 88, 0, }, /* 737 */ - { 117, 7, 12, 0, 0, 117, 0, }, /* 738 */ - { 117, 15, 12, 0, 0, 117, 0, }, /* 739 */ - { 112, 7, 12, 0, 0, 112, 0, }, /* 740 */ - { 112, 26, 12, 0, 0, 112, 0, }, /* 741 */ - { 112, 12, 3, 0, 0, 112, 0, }, /* 742 */ - { 112, 15, 12, 0, 0, 112, 0, }, /* 743 */ - { 112, 21, 12, 0, 0, 112, 0, }, /* 744 */ - { 78, 7, 12, 0, 0, 78, 0, }, /* 745 */ - { 78, 21, 12, 0, 0, 78, 0, }, /* 746 */ - { 83, 7, 12, 0, 0, 83, 0, }, /* 747 */ - { 83, 15, 12, 0, 0, 83, 0, }, /* 748 */ - { 82, 7, 12, 0, 0, 82, 0, }, /* 749 */ - { 82, 15, 12, 0, 0, 82, 0, }, /* 750 */ - { 121, 7, 12, 0, 0, 121, 0, }, /* 751 */ - { 121, 21, 12, 0, 0, 121, 0, }, /* 752 */ - { 121, 15, 12, 0, 0, 121, 0, }, /* 753 */ - { 89, 7, 12, 0, 0, 89, 0, }, /* 754 */ - { 130, 9, 12, 0, 64, 130, 0, }, /* 755 */ - { 130, 5, 12, 0, -64, 130, 0, }, /* 756 */ - { 130, 15, 12, 0, 0, 130, 0, }, /* 757 */ - { 144, 7, 12, 0, 0, 144, 0, }, /* 758 */ - { 144, 12, 3, 0, 0, 144, 0, }, /* 759 */ - { 144, 13, 12, 0, 0, 144, 0, }, /* 760 */ - { 1, 15, 12, 0, 0, 1, 0, }, /* 761 */ - { 156, 7, 12, 0, 0, 156, 0, }, /* 762 */ - { 156, 12, 3, 0, 0, 156, 0, }, /* 763 */ - { 156, 17, 12, 0, 0, 156, 0, }, /* 764 */ - { 147, 7, 12, 0, 0, 147, 0, }, /* 765 */ - { 147, 15, 12, 0, 0, 147, 0, }, /* 766 */ - { 148, 7, 12, 0, 0, 148, 0, }, /* 767 */ - { 148, 12, 3, 0, 0, 148, 0, }, /* 768 */ - { 148, 15, 12, 0, 0, 148, 0, }, /* 769 */ - { 148, 21, 12, 0, 0, 148, 0, }, /* 770 */ - { 153, 7, 12, 0, 0, 153, 0, }, /* 771 */ - { 153, 15, 12, 0, 0, 153, 0, }, /* 772 */ - { 149, 7, 12, 0, 0, 149, 0, }, /* 773 */ - { 94, 10, 5, 0, 0, 94, 0, }, /* 774 */ - { 94, 12, 3, 0, 0, 94, 0, }, /* 775 */ - { 94, 7, 12, 0, 0, 94, 0, }, /* 776 */ - { 94, 21, 12, 0, 0, 94, 0, }, /* 777 */ - { 94, 15, 12, 0, 0, 94, 0, }, /* 778 */ - { 94, 13, 12, 0, 0, 94, 0, }, /* 779 */ - { 85, 12, 3, 0, 0, 85, 0, }, /* 780 */ - { 85, 10, 5, 0, 0, 85, 0, }, /* 781 */ - { 85, 7, 12, 0, 0, 85, 0, }, /* 782 */ - { 85, 21, 12, 0, 0, 85, 0, }, /* 783 */ - { 85, 1, 4, 0, 0, 85, 0, }, /* 784 */ - { 101, 7, 12, 0, 0, 101, 0, }, /* 785 */ - { 101, 13, 12, 0, 0, 101, 0, }, /* 786 */ - { 96, 12, 3, 0, 0, 96, 0, }, /* 787 */ - { 96, 7, 12, 0, 0, 96, 0, }, /* 788 */ - { 96, 10, 5, 0, 0, 96, 0, }, /* 789 */ - { 96, 13, 12, 0, 0, 96, 0, }, /* 790 */ - { 96, 21, 12, 0, 0, 96, 0, }, /* 791 */ - { 111, 7, 12, 0, 0, 111, 0, }, /* 792 */ - { 111, 12, 3, 0, 0, 111, 0, }, /* 793 */ - { 111, 21, 12, 0, 0, 111, 0, }, /* 794 */ - { 100, 12, 3, 0, 0, 100, 0, }, /* 795 */ - { 100, 10, 5, 0, 0, 100, 0, }, /* 796 */ - { 100, 7, 12, 0, 0, 100, 0, }, /* 797 */ - { 100, 7, 4, 0, 0, 100, 0, }, /* 798 */ - { 100, 21, 12, 0, 0, 100, 0, }, /* 799 */ - { 100, 13, 12, 0, 0, 100, 0, }, /* 800 */ - { 48, 15, 12, 0, 0, 48, 0, }, /* 801 */ - { 108, 7, 12, 0, 0, 108, 0, }, /* 802 */ - { 108, 10, 5, 0, 0, 108, 0, }, /* 803 */ - { 108, 12, 3, 0, 0, 108, 0, }, /* 804 */ - { 108, 21, 12, 0, 0, 108, 0, }, /* 805 */ - { 129, 7, 12, 0, 0, 129, 0, }, /* 806 */ - { 129, 21, 12, 0, 0, 129, 0, }, /* 807 */ - { 109, 7, 12, 0, 0, 109, 0, }, /* 808 */ - { 109, 12, 3, 0, 0, 109, 0, }, /* 809 */ - { 109, 10, 5, 0, 0, 109, 0, }, /* 810 */ - { 109, 13, 12, 0, 0, 109, 0, }, /* 811 */ - { 107, 12, 3, 0, 0, 107, 0, }, /* 812 */ - { 107, 12, 3, 0, 0, -52, 0, }, /* 813 */ - { 107, 10, 5, 0, 0, 107, 0, }, /* 814 */ - { 107, 10, 5, 0, 0, -52, 0, }, /* 815 */ - { 107, 7, 12, 0, 0, 107, 0, }, /* 816 */ - { 28, 12, 3, 0, 0, -52, 0, }, /* 817 */ - { 107, 10, 3, 0, 0, 107, 0, }, /* 818 */ - { 135, 7, 12, 0, 0, 135, 0, }, /* 819 */ - { 135, 10, 5, 0, 0, 135, 0, }, /* 820 */ - { 135, 12, 3, 0, 0, 135, 0, }, /* 821 */ - { 135, 21, 12, 0, 0, 135, 0, }, /* 822 */ - { 135, 13, 12, 0, 0, 135, 0, }, /* 823 */ - { 124, 7, 12, 0, 0, 124, 0, }, /* 824 */ - { 124, 10, 3, 0, 0, 124, 0, }, /* 825 */ - { 124, 10, 5, 0, 0, 124, 0, }, /* 826 */ - { 124, 12, 3, 0, 0, 124, 0, }, /* 827 */ - { 124, 21, 12, 0, 0, 124, 0, }, /* 828 */ - { 124, 13, 12, 0, 0, 124, 0, }, /* 829 */ - { 123, 7, 12, 0, 0, 123, 0, }, /* 830 */ - { 123, 10, 3, 0, 0, 123, 0, }, /* 831 */ - { 123, 10, 5, 0, 0, 123, 0, }, /* 832 */ - { 123, 12, 3, 0, 0, 123, 0, }, /* 833 */ - { 123, 21, 12, 0, 0, 123, 0, }, /* 834 */ - { 114, 7, 12, 0, 0, 114, 0, }, /* 835 */ - { 114, 10, 5, 0, 0, 114, 0, }, /* 836 */ - { 114, 12, 3, 0, 0, 114, 0, }, /* 837 */ - { 114, 21, 12, 0, 0, 114, 0, }, /* 838 */ - { 114, 13, 12, 0, 0, 114, 0, }, /* 839 */ - { 102, 7, 12, 0, 0, 102, 0, }, /* 840 */ - { 102, 12, 3, 0, 0, 102, 0, }, /* 841 */ - { 102, 10, 5, 0, 0, 102, 0, }, /* 842 */ - { 102, 13, 12, 0, 0, 102, 0, }, /* 843 */ - { 126, 7, 12, 0, 0, 126, 0, }, /* 844 */ - { 126, 12, 3, 0, 0, 126, 0, }, /* 845 */ - { 126, 10, 5, 0, 0, 126, 0, }, /* 846 */ - { 126, 13, 12, 0, 0, 126, 0, }, /* 847 */ - { 126, 15, 12, 0, 0, 126, 0, }, /* 848 */ - { 126, 21, 12, 0, 0, 126, 0, }, /* 849 */ - { 126, 26, 12, 0, 0, 126, 0, }, /* 850 */ - { 142, 7, 12, 0, 0, 142, 0, }, /* 851 */ - { 142, 10, 5, 0, 0, 142, 0, }, /* 852 */ - { 142, 12, 3, 0, 0, 142, 0, }, /* 853 */ - { 142, 21, 12, 0, 0, 142, 0, }, /* 854 */ - { 125, 9, 12, 0, 32, 125, 0, }, /* 855 */ - { 125, 5, 12, 0, -32, 125, 0, }, /* 856 */ - { 125, 13, 12, 0, 0, 125, 0, }, /* 857 */ - { 125, 15, 12, 0, 0, 125, 0, }, /* 858 */ - { 125, 7, 12, 0, 0, 125, 0, }, /* 859 */ - { 154, 7, 12, 0, 0, 154, 0, }, /* 860 */ - { 154, 10, 3, 0, 0, 154, 0, }, /* 861 */ - { 154, 10, 5, 0, 0, 154, 0, }, /* 862 */ - { 154, 12, 3, 0, 0, 154, 0, }, /* 863 */ - { 154, 7, 4, 0, 0, 154, 0, }, /* 864 */ - { 154, 21, 12, 0, 0, 154, 0, }, /* 865 */ - { 154, 13, 12, 0, 0, 154, 0, }, /* 866 */ - { 150, 7, 12, 0, 0, 150, 0, }, /* 867 */ - { 150, 10, 5, 0, 0, 150, 0, }, /* 868 */ - { 150, 12, 3, 0, 0, 150, 0, }, /* 869 */ - { 150, 21, 12, 0, 0, 150, 0, }, /* 870 */ - { 141, 7, 12, 0, 0, 141, 0, }, /* 871 */ - { 141, 12, 3, 0, 0, 141, 0, }, /* 872 */ - { 141, 10, 5, 0, 0, 141, 0, }, /* 873 */ - { 141, 7, 4, 0, 0, 141, 0, }, /* 874 */ - { 141, 21, 12, 0, 0, 141, 0, }, /* 875 */ - { 140, 7, 12, 0, 0, 140, 0, }, /* 876 */ - { 140, 12, 3, 0, 0, 140, 0, }, /* 877 */ - { 140, 10, 5, 0, 0, 140, 0, }, /* 878 */ - { 140, 7, 4, 0, 0, 140, 0, }, /* 879 */ - { 140, 21, 12, 0, 0, 140, 0, }, /* 880 */ - { 122, 7, 12, 0, 0, 122, 0, }, /* 881 */ - { 133, 7, 12, 0, 0, 133, 0, }, /* 882 */ - { 133, 10, 5, 0, 0, 133, 0, }, /* 883 */ - { 133, 12, 3, 0, 0, 133, 0, }, /* 884 */ - { 133, 21, 12, 0, 0, 133, 0, }, /* 885 */ - { 133, 13, 12, 0, 0, 133, 0, }, /* 886 */ - { 133, 15, 12, 0, 0, 133, 0, }, /* 887 */ - { 134, 21, 12, 0, 0, 134, 0, }, /* 888 */ - { 134, 7, 12, 0, 0, 134, 0, }, /* 889 */ - { 134, 12, 3, 0, 0, 134, 0, }, /* 890 */ - { 134, 10, 5, 0, 0, 134, 0, }, /* 891 */ - { 138, 7, 12, 0, 0, 138, 0, }, /* 892 */ - { 138, 12, 3, 0, 0, 138, 0, }, /* 893 */ - { 138, 7, 4, 0, 0, 138, 0, }, /* 894 */ - { 138, 13, 12, 0, 0, 138, 0, }, /* 895 */ - { 143, 7, 12, 0, 0, 143, 0, }, /* 896 */ - { 143, 10, 5, 0, 0, 143, 0, }, /* 897 */ - { 143, 12, 3, 0, 0, 143, 0, }, /* 898 */ - { 143, 13, 12, 0, 0, 143, 0, }, /* 899 */ - { 145, 7, 12, 0, 0, 145, 0, }, /* 900 */ - { 145, 12, 3, 0, 0, 145, 0, }, /* 901 */ - { 145, 10, 5, 0, 0, 145, 0, }, /* 902 */ - { 145, 21, 12, 0, 0, 145, 0, }, /* 903 */ - { 54, 15, 12, 0, 0, 54, 0, }, /* 904 */ - { 54, 21, 12, 0, 0, 54, 0, }, /* 905 */ - { 63, 7, 12, 0, 0, 63, 0, }, /* 906 */ - { 63, 14, 12, 0, 0, 63, 0, }, /* 907 */ - { 63, 21, 12, 0, 0, 63, 0, }, /* 908 */ - { 80, 7, 12, 0, 0, 80, 0, }, /* 909 */ - { 80, 1, 2, 0, 0, 80, 0, }, /* 910 */ - { 127, 7, 12, 0, 0, 127, 0, }, /* 911 */ - { 115, 7, 12, 0, 0, 115, 0, }, /* 912 */ - { 115, 13, 12, 0, 0, 115, 0, }, /* 913 */ - { 115, 21, 12, 0, 0, 115, 0, }, /* 914 */ - { 103, 7, 12, 0, 0, 103, 0, }, /* 915 */ - { 103, 12, 3, 0, 0, 103, 0, }, /* 916 */ - { 103, 21, 12, 0, 0, 103, 0, }, /* 917 */ - { 119, 7, 12, 0, 0, 119, 0, }, /* 918 */ - { 119, 12, 3, 0, 0, 119, 0, }, /* 919 */ - { 119, 21, 12, 0, 0, 119, 0, }, /* 920 */ - { 119, 26, 12, 0, 0, 119, 0, }, /* 921 */ - { 119, 6, 12, 0, 0, 119, 0, }, /* 922 */ - { 119, 13, 12, 0, 0, 119, 0, }, /* 923 */ - { 119, 15, 12, 0, 0, 119, 0, }, /* 924 */ - { 146, 9, 12, 0, 32, 146, 0, }, /* 925 */ - { 146, 5, 12, 0, -32, 146, 0, }, /* 926 */ - { 146, 15, 12, 0, 0, 146, 0, }, /* 927 */ - { 146, 21, 12, 0, 0, 146, 0, }, /* 928 */ - { 99, 7, 12, 0, 0, 99, 0, }, /* 929 */ - { 99, 12, 3, 0, 0, 99, 0, }, /* 930 */ - { 99, 10, 5, 0, 0, 99, 0, }, /* 931 */ - { 99, 6, 12, 0, 0, 99, 0, }, /* 932 */ - { 137, 6, 12, 0, 0, 137, 0, }, /* 933 */ - { 139, 6, 12, 0, 0, 139, 0, }, /* 934 */ - { 155, 12, 3, 0, 0, 155, 0, }, /* 935 */ - { 23, 10, 5, 0, 0, 23, 0, }, /* 936 */ - { 137, 7, 12, 0, 0, 137, 0, }, /* 937 */ - { 155, 7, 12, 0, 0, 155, 0, }, /* 938 */ - { 139, 7, 12, 0, 0, 139, 0, }, /* 939 */ - { 105, 7, 12, 0, 0, 105, 0, }, /* 940 */ - { 105, 26, 12, 0, 0, 105, 0, }, /* 941 */ - { 105, 12, 3, 0, 0, 105, 0, }, /* 942 */ - { 105, 21, 12, 0, 0, 105, 0, }, /* 943 */ - { 10, 1, 2, 0, 0, 105, 0, }, /* 944 */ - { 10, 10, 3, 0, 0, 10, 0, }, /* 945 */ - { 10, 10, 5, 0, 0, 10, 0, }, /* 946 */ - { 20, 12, 3, 0, 0, 20, 0, }, /* 947 */ - { 131, 26, 12, 0, 0, 131, 0, }, /* 948 */ - { 131, 12, 3, 0, 0, 131, 0, }, /* 949 */ - { 131, 21, 12, 0, 0, 131, 0, }, /* 950 */ - { 18, 12, 3, 0, 0, 18, 0, }, /* 951 */ - { 151, 7, 12, 0, 0, 151, 0, }, /* 952 */ - { 151, 12, 3, 0, 0, 151, 0, }, /* 953 */ - { 151, 6, 12, 0, 0, 151, 0, }, /* 954 */ - { 151, 13, 12, 0, 0, 151, 0, }, /* 955 */ - { 151, 26, 12, 0, 0, 151, 0, }, /* 956 */ - { 152, 7, 12, 0, 0, 152, 0, }, /* 957 */ - { 152, 12, 3, 0, 0, 152, 0, }, /* 958 */ - { 152, 13, 12, 0, 0, 152, 0, }, /* 959 */ - { 152, 23, 12, 0, 0, 152, 0, }, /* 960 */ - { 113, 7, 12, 0, 0, 113, 0, }, /* 961 */ - { 113, 15, 12, 0, 0, 113, 0, }, /* 962 */ - { 113, 12, 3, 0, 0, 113, 0, }, /* 963 */ - { 132, 9, 12, 0, 34, 132, 0, }, /* 964 */ - { 132, 5, 12, 0, -34, 132, 0, }, /* 965 */ - { 132, 12, 3, 0, 0, 132, 0, }, /* 966 */ - { 132, 6, 12, 0, 0, 132, 0, }, /* 967 */ - { 132, 13, 12, 0, 0, 132, 0, }, /* 968 */ - { 132, 21, 12, 0, 0, 132, 0, }, /* 969 */ - { 0, 2, 14, 0, 0, 0, 0, }, /* 970 */ - { 10, 26, 11, 0, 0, 10, 0, }, /* 971 */ - { 27, 26, 12, 0, 0, 27, 0, }, /* 972 */ - { 10, 24, 3, 0, 0, 10, 0, }, /* 973 */ - { 10, 1, 3, 0, 0, 10, 0, }, /* 974 */ + { 1, 1, 2, 0, 0, -82, 0, }, /* 223 */ + { 10, 21, 12, 0, 0, -164, 0, }, /* 224 */ + { 1, 7, 12, 0, 0, 1, 0, }, /* 225 */ + { 10, 6, 12, 0, 0, -181, 0, }, /* 226 */ + { 28, 12, 3, 0, 0, -10, 0, }, /* 227 */ + { 1, 13, 12, 0, 0, -86, 0, }, /* 228 */ + { 1, 21, 12, 0, 0, -4, 0, }, /* 229 */ + { 1, 6, 12, 0, 0, 1, 0, }, /* 230 */ + { 1, 13, 12, 0, 0, 1, 0, }, /* 231 */ + { 50, 21, 12, 0, 0, 50, 0, }, /* 232 */ + { 50, 1, 4, 0, 0, 50, 0, }, /* 233 */ + { 50, 7, 12, 0, 0, 50, 0, }, /* 234 */ + { 50, 12, 3, 0, 0, 50, 0, }, /* 235 */ + { 56, 7, 12, 0, 0, 56, 0, }, /* 236 */ + { 56, 12, 3, 0, 0, 56, 0, }, /* 237 */ + { 64, 13, 12, 0, 0, 64, 0, }, /* 238 */ + { 64, 7, 12, 0, 0, 64, 0, }, /* 239 */ + { 64, 12, 3, 0, 0, 64, 0, }, /* 240 */ + { 64, 6, 12, 0, 0, 64, 0, }, /* 241 */ + { 64, 26, 12, 0, 0, 64, 0, }, /* 242 */ + { 64, 21, 12, 0, 0, 64, 0, }, /* 243 */ + { 64, 23, 12, 0, 0, 64, 0, }, /* 244 */ + { 90, 7, 12, 0, 0, 90, 0, }, /* 245 */ + { 90, 12, 3, 0, 0, 90, 0, }, /* 246 */ + { 90, 6, 12, 0, 0, 90, 0, }, /* 247 */ + { 90, 21, 12, 0, 0, 90, 0, }, /* 248 */ + { 95, 7, 12, 0, 0, 95, 0, }, /* 249 */ + { 95, 12, 3, 0, 0, 95, 0, }, /* 250 */ + { 95, 21, 12, 0, 0, 95, 0, }, /* 251 */ + { 1, 24, 12, 0, 0, 1, 0, }, /* 252 */ + { 15, 12, 3, 0, 0, 15, 0, }, /* 253 */ + { 15, 10, 5, 0, 0, 15, 0, }, /* 254 */ + { 15, 7, 12, 0, 0, 15, 0, }, /* 255 */ + { 28, 12, 3, 0, 0, -216, 0, }, /* 256 */ + { 28, 12, 3, 0, 0, -203, 0, }, /* 257 */ + { 10, 21, 12, 0, 0, -259, 0, }, /* 258 */ + { 10, 21, 12, 0, 0, -280, 0, }, /* 259 */ + { 15, 13, 12, 0, 0, -132, 0, }, /* 260 */ + { 15, 21, 12, 0, 0, 15, 0, }, /* 261 */ + { 15, 6, 12, 0, 0, 15, 0, }, /* 262 */ + { 3, 7, 12, 0, 0, 3, 0, }, /* 263 */ + { 3, 12, 3, 0, 0, 3, 0, }, /* 264 */ + { 3, 10, 5, 0, 0, 3, 0, }, /* 265 */ + { 3, 10, 3, 0, 0, 3, 0, }, /* 266 */ + { 3, 13, 12, 0, 0, -90, 0, }, /* 267 */ + { 3, 23, 12, 0, 0, 3, 0, }, /* 268 */ + { 3, 15, 12, 0, 0, 3, 0, }, /* 269 */ + { 3, 26, 12, 0, 0, 3, 0, }, /* 270 */ + { 3, 21, 12, 0, 0, 3, 0, }, /* 271 */ + { 22, 12, 3, 0, 0, 22, 0, }, /* 272 */ + { 22, 10, 5, 0, 0, 22, 0, }, /* 273 */ + { 22, 7, 12, 0, 0, 22, 0, }, /* 274 */ + { 22, 13, 12, 0, 0, -61, 0, }, /* 275 */ + { 22, 21, 12, 0, 0, 22, 0, }, /* 276 */ + { 21, 12, 3, 0, 0, 21, 0, }, /* 277 */ + { 21, 10, 5, 0, 0, 21, 0, }, /* 278 */ + { 21, 7, 12, 0, 0, 21, 0, }, /* 279 */ + { 21, 13, 12, 0, 0, -58, 0, }, /* 280 */ + { 21, 21, 12, 0, 0, 21, 0, }, /* 281 */ + { 21, 23, 12, 0, 0, 21, 0, }, /* 282 */ + { 44, 12, 3, 0, 0, 44, 0, }, /* 283 */ + { 44, 10, 5, 0, 0, 44, 0, }, /* 284 */ + { 44, 7, 12, 0, 0, 44, 0, }, /* 285 */ + { 44, 10, 3, 0, 0, 44, 0, }, /* 286 */ + { 44, 13, 12, 0, 0, 44, 0, }, /* 287 */ + { 44, 26, 12, 0, 0, 44, 0, }, /* 288 */ + { 44, 15, 12, 0, 0, 44, 0, }, /* 289 */ + { 54, 12, 3, 0, 0, 54, 0, }, /* 290 */ + { 54, 7, 12, 0, 0, 54, 0, }, /* 291 */ + { 54, 10, 3, 0, 0, 54, 0, }, /* 292 */ + { 54, 10, 5, 0, 0, 54, 0, }, /* 293 */ + { 54, 13, 12, 0, 0, -55, 0, }, /* 294 */ + { 54, 15, 12, 0, 0, -55, 0, }, /* 295 */ + { 54, 26, 12, 0, 0, -55, 0, }, /* 296 */ + { 54, 26, 12, 0, 0, 54, 0, }, /* 297 */ + { 54, 23, 12, 0, 0, 54, 0, }, /* 298 */ + { 55, 12, 3, 0, 0, 55, 0, }, /* 299 */ + { 55, 10, 5, 0, 0, 55, 0, }, /* 300 */ + { 55, 7, 12, 0, 0, 55, 0, }, /* 301 */ + { 55, 13, 12, 0, 0, 55, 0, }, /* 302 */ + { 55, 21, 12, 0, 0, 55, 0, }, /* 303 */ + { 55, 15, 12, 0, 0, 55, 0, }, /* 304 */ + { 55, 26, 12, 0, 0, 55, 0, }, /* 305 */ + { 29, 7, 12, 0, 0, 29, 0, }, /* 306 */ + { 29, 12, 3, 0, 0, 29, 0, }, /* 307 */ + { 29, 10, 5, 0, 0, 29, 0, }, /* 308 */ + { 29, 21, 12, 0, 0, 29, 0, }, /* 309 */ + { 29, 10, 3, 0, 0, 29, 0, }, /* 310 */ + { 29, 13, 12, 0, 0, -70, 0, }, /* 311 */ + { 37, 12, 3, 0, 0, 37, 0, }, /* 312 */ + { 37, 10, 5, 0, 0, 37, 0, }, /* 313 */ + { 37, 7, 12, 0, 0, 37, 0, }, /* 314 */ + { 37, 10, 3, 0, 0, 37, 0, }, /* 315 */ + { 37, 7, 4, 0, 0, 37, 0, }, /* 316 */ + { 37, 26, 12, 0, 0, 37, 0, }, /* 317 */ + { 37, 15, 12, 0, 0, 37, 0, }, /* 318 */ + { 37, 13, 12, 0, 0, 37, 0, }, /* 319 */ + { 48, 12, 3, 0, 0, 48, 0, }, /* 320 */ + { 48, 10, 5, 0, 0, 48, 0, }, /* 321 */ + { 48, 7, 12, 0, 0, 48, 0, }, /* 322 */ + { 48, 10, 3, 0, 0, 48, 0, }, /* 323 */ + { 48, 13, 12, 0, 0, 48, 0, }, /* 324 */ + { 48, 21, 12, 0, 0, 48, 0, }, /* 325 */ + { 57, 7, 12, 0, 0, 57, 0, }, /* 326 */ + { 57, 12, 3, 0, 0, 57, 0, }, /* 327 */ + { 57, 7, 5, 0, 0, 57, 0, }, /* 328 */ + { 57, 6, 12, 0, 0, 57, 0, }, /* 329 */ + { 57, 21, 12, 0, 0, 57, 0, }, /* 330 */ + { 57, 13, 12, 0, 0, 57, 0, }, /* 331 */ + { 33, 7, 12, 0, 0, 33, 0, }, /* 332 */ + { 33, 12, 3, 0, 0, 33, 0, }, /* 333 */ + { 33, 7, 5, 0, 0, 33, 0, }, /* 334 */ + { 33, 6, 12, 0, 0, 33, 0, }, /* 335 */ + { 33, 13, 12, 0, 0, 33, 0, }, /* 336 */ + { 58, 7, 12, 0, 0, 58, 0, }, /* 337 */ + { 58, 26, 12, 0, 0, 58, 0, }, /* 338 */ + { 58, 21, 12, 0, 0, 58, 0, }, /* 339 */ + { 58, 12, 3, 0, 0, 58, 0, }, /* 340 */ + { 58, 13, 12, 0, 0, 58, 0, }, /* 341 */ + { 58, 15, 12, 0, 0, 58, 0, }, /* 342 */ + { 58, 22, 12, 0, 0, 58, 0, }, /* 343 */ + { 58, 18, 12, 0, 0, 58, 0, }, /* 344 */ + { 58, 10, 5, 0, 0, 58, 0, }, /* 345 */ + { 39, 7, 12, 0, 0, 39, 0, }, /* 346 */ + { 39, 10, 12, 0, 0, 39, 0, }, /* 347 */ + { 39, 12, 3, 0, 0, 39, 0, }, /* 348 */ + { 39, 10, 5, 0, 0, 39, 0, }, /* 349 */ + { 39, 13, 12, 0, 0, -94, 0, }, /* 350 */ + { 39, 21, 12, 0, 0, 39, 0, }, /* 351 */ + { 39, 13, 12, 0, 0, 39, 0, }, /* 352 */ + { 39, 26, 12, 0, 0, 39, 0, }, /* 353 */ + { 17, 9, 12, 0, 7264, 17, 0, }, /* 354 */ + { 17, 5, 12, 0, 3008, 17, 0, }, /* 355 */ + { 10, 21, 12, 0, 0, -52, 0, }, /* 356 */ + { 17, 6, 12, 0, 0, 17, 0, }, /* 357 */ + { 24, 7, 6, 0, 0, 24, 0, }, /* 358 */ + { 24, 7, 7, 0, 0, 24, 0, }, /* 359 */ + { 24, 7, 8, 0, 0, 24, 0, }, /* 360 */ + { 16, 7, 12, 0, 0, 16, 0, }, /* 361 */ + { 16, 12, 3, 0, 0, 16, 0, }, /* 362 */ + { 16, 21, 12, 0, 0, 16, 0, }, /* 363 */ + { 16, 15, 12, 0, 0, 16, 0, }, /* 364 */ + { 16, 26, 12, 0, 0, 16, 0, }, /* 365 */ + { 9, 9, 12, 0, 38864, 9, 0, }, /* 366 */ + { 9, 9, 12, 0, 8, 9, 0, }, /* 367 */ + { 9, 5, 12, 0, -8, 9, 0, }, /* 368 */ + { 8, 17, 12, 0, 0, 8, 0, }, /* 369 */ + { 8, 7, 12, 0, 0, 8, 0, }, /* 370 */ + { 8, 26, 12, 0, 0, 8, 0, }, /* 371 */ + { 8, 21, 12, 0, 0, 8, 0, }, /* 372 */ + { 41, 29, 12, 0, 0, 41, 0, }, /* 373 */ + { 41, 7, 12, 0, 0, 41, 0, }, /* 374 */ + { 41, 22, 12, 0, 0, 41, 0, }, /* 375 */ + { 41, 18, 12, 0, 0, 41, 0, }, /* 376 */ + { 46, 7, 12, 0, 0, 46, 0, }, /* 377 */ + { 46, 14, 12, 0, 0, 46, 0, }, /* 378 */ + { 51, 7, 12, 0, 0, 51, 0, }, /* 379 */ + { 51, 12, 3, 0, 0, 51, 0, }, /* 380 */ + { 51, 10, 5, 0, 0, 51, 0, }, /* 381 */ + { 25, 7, 12, 0, 0, 25, 0, }, /* 382 */ + { 25, 12, 3, 0, 0, 25, 0, }, /* 383 */ + { 25, 10, 5, 0, 0, 25, 0, }, /* 384 */ + { 10, 21, 12, 0, 0, -127, 0, }, /* 385 */ + { 7, 7, 12, 0, 0, 7, 0, }, /* 386 */ + { 7, 12, 3, 0, 0, 7, 0, }, /* 387 */ + { 52, 7, 12, 0, 0, 52, 0, }, /* 388 */ + { 52, 12, 3, 0, 0, 52, 0, }, /* 389 */ + { 32, 7, 12, 0, 0, 32, 0, }, /* 390 */ + { 32, 12, 3, 0, 0, 32, 0, }, /* 391 */ + { 32, 10, 5, 0, 0, 32, 0, }, /* 392 */ + { 32, 21, 12, 0, 0, 32, 0, }, /* 393 */ + { 32, 6, 12, 0, 0, 32, 0, }, /* 394 */ + { 32, 23, 12, 0, 0, 32, 0, }, /* 395 */ + { 32, 13, 12, 0, 0, 32, 0, }, /* 396 */ + { 32, 15, 12, 0, 0, 32, 0, }, /* 397 */ + { 38, 21, 12, 0, 0, 38, 0, }, /* 398 */ + { 10, 21, 12, 0, 0, -79, 0, }, /* 399 */ + { 38, 17, 12, 0, 0, 38, 0, }, /* 400 */ + { 38, 12, 3, 0, 0, 38, 0, }, /* 401 */ + { 38, 1, 2, 0, 0, 38, 0, }, /* 402 */ + { 38, 13, 12, 0, 0, 38, 0, }, /* 403 */ + { 38, 7, 12, 0, 0, 38, 0, }, /* 404 */ + { 38, 6, 12, 0, 0, 38, 0, }, /* 405 */ + { 35, 7, 12, 0, 0, 35, 0, }, /* 406 */ + { 35, 12, 3, 0, 0, 35, 0, }, /* 407 */ + { 35, 10, 5, 0, 0, 35, 0, }, /* 408 */ + { 35, 26, 12, 0, 0, 35, 0, }, /* 409 */ + { 35, 21, 12, 0, 0, 35, 0, }, /* 410 */ + { 35, 13, 12, 0, 0, 35, 0, }, /* 411 */ + { 53, 7, 12, 0, 0, 53, 0, }, /* 412 */ + { 40, 7, 12, 0, 0, 40, 0, }, /* 413 */ + { 40, 13, 12, 0, 0, 40, 0, }, /* 414 */ + { 40, 15, 12, 0, 0, 40, 0, }, /* 415 */ + { 40, 26, 12, 0, 0, 40, 0, }, /* 416 */ + { 32, 26, 12, 0, 0, 32, 0, }, /* 417 */ + { 6, 7, 12, 0, 0, 6, 0, }, /* 418 */ + { 6, 12, 3, 0, 0, 6, 0, }, /* 419 */ + { 6, 10, 5, 0, 0, 6, 0, }, /* 420 */ + { 6, 21, 12, 0, 0, 6, 0, }, /* 421 */ + { 91, 7, 12, 0, 0, 91, 0, }, /* 422 */ + { 91, 10, 5, 0, 0, 91, 0, }, /* 423 */ + { 91, 12, 3, 0, 0, 91, 0, }, /* 424 */ + { 91, 10, 12, 0, 0, 91, 0, }, /* 425 */ + { 91, 13, 12, 0, 0, 91, 0, }, /* 426 */ + { 91, 21, 12, 0, 0, 91, 0, }, /* 427 */ + { 91, 6, 12, 0, 0, 91, 0, }, /* 428 */ + { 28, 11, 3, 0, 0, 28, 0, }, /* 429 */ + { 62, 12, 3, 0, 0, 62, 0, }, /* 430 */ + { 62, 10, 5, 0, 0, 62, 0, }, /* 431 */ + { 62, 7, 12, 0, 0, 62, 0, }, /* 432 */ + { 62, 10, 3, 0, 0, 62, 0, }, /* 433 */ + { 62, 13, 12, 0, 0, 62, 0, }, /* 434 */ + { 62, 21, 12, 0, 0, 62, 0, }, /* 435 */ + { 62, 26, 12, 0, 0, 62, 0, }, /* 436 */ + { 76, 12, 3, 0, 0, 76, 0, }, /* 437 */ + { 76, 10, 5, 0, 0, 76, 0, }, /* 438 */ + { 76, 7, 12, 0, 0, 76, 0, }, /* 439 */ + { 76, 13, 12, 0, 0, 76, 0, }, /* 440 */ + { 93, 7, 12, 0, 0, 93, 0, }, /* 441 */ + { 93, 12, 3, 0, 0, 93, 0, }, /* 442 */ + { 93, 10, 5, 0, 0, 93, 0, }, /* 443 */ + { 93, 21, 12, 0, 0, 93, 0, }, /* 444 */ + { 70, 7, 12, 0, 0, 70, 0, }, /* 445 */ + { 70, 10, 5, 0, 0, 70, 0, }, /* 446 */ + { 70, 12, 3, 0, 0, 70, 0, }, /* 447 */ + { 70, 21, 12, 0, 0, 70, 0, }, /* 448 */ + { 70, 13, 12, 0, 0, 70, 0, }, /* 449 */ + { 73, 13, 12, 0, 0, 73, 0, }, /* 450 */ + { 73, 7, 12, 0, 0, 73, 0, }, /* 451 */ + { 73, 6, 12, 0, 0, 73, 0, }, /* 452 */ + { 73, 21, 12, 0, 0, 73, 0, }, /* 453 */ + { 13, 5, 12, 63, -6222, 13, 0, }, /* 454 */ + { 13, 5, 12, 67, -6221, 13, 0, }, /* 455 */ + { 13, 5, 12, 71, -6212, 13, 0, }, /* 456 */ + { 13, 5, 12, 75, -6210, 13, 0, }, /* 457 */ + { 13, 5, 12, 79, -6210, 13, 0, }, /* 458 */ + { 13, 5, 12, 79, -6211, 13, 0, }, /* 459 */ + { 13, 5, 12, 84, -6204, 13, 0, }, /* 460 */ + { 13, 5, 12, 88, -6180, 13, 0, }, /* 461 */ + { 13, 5, 12, 108, 35267, 13, 0, }, /* 462 */ + { 17, 9, 12, 0, -3008, 17, 0, }, /* 463 */ + { 76, 21, 12, 0, 0, 76, 0, }, /* 464 */ + { 28, 12, 3, 0, 0, -122, 0, }, /* 465 */ + { 28, 12, 3, 0, 0, 15, 0, }, /* 466 */ + { 10, 21, 12, 0, 0, -40, 0, }, /* 467 */ + { 28, 12, 3, 0, 0, -16, 0, }, /* 468 */ + { 28, 12, 3, 0, 0, -46, 0, }, /* 469 */ + { 28, 12, 3, 0, 0, -157, 0, }, /* 470 */ + { 10, 10, 5, 0, 0, -16, 0, }, /* 471 */ + { 10, 7, 12, 0, 0, -43, 0, }, /* 472 */ + { 10, 7, 12, 0, 0, -16, 0, }, /* 473 */ + { 10, 7, 12, 0, 0, 15, 0, }, /* 474 */ + { 10, 7, 12, 0, 0, -172, 0, }, /* 475 */ + { 10, 7, 12, 0, 0, -40, 0, }, /* 476 */ + { 28, 12, 3, 0, 0, -106, 0, }, /* 477 */ + { 10, 10, 5, 0, 0, 3, 0, }, /* 478 */ + { 28, 12, 3, 0, 0, -40, 0, }, /* 479 */ + { 10, 7, 12, 0, 0, 150, 0, }, /* 480 */ + { 13, 5, 12, 0, 0, 13, 0, }, /* 481 */ + { 13, 6, 12, 0, 0, 13, 0, }, /* 482 */ + { 34, 5, 12, 0, 35332, 34, 0, }, /* 483 */ + { 34, 5, 12, 0, 3814, 34, 0, }, /* 484 */ + { 34, 5, 12, 0, 35384, 34, 0, }, /* 485 */ + { 28, 12, 3, 0, 0, -37, 0, }, /* 486 */ + { 28, 12, 3, 0, 0, 50, 0, }, /* 487 */ + { 34, 9, 12, 92, 1, 34, 0, }, /* 488 */ + { 34, 5, 12, 92, -1, 34, 0, }, /* 489 */ + { 34, 5, 12, 92, -58, 34, 0, }, /* 490 */ + { 34, 9, 12, 0, -7615, 34, 0, }, /* 491 */ + { 20, 5, 12, 0, 8, 20, 0, }, /* 492 */ + { 20, 9, 12, 0, -8, 20, 0, }, /* 493 */ + { 20, 5, 12, 0, 74, 20, 0, }, /* 494 */ + { 20, 5, 12, 0, 86, 20, 0, }, /* 495 */ + { 20, 5, 12, 0, 100, 20, 0, }, /* 496 */ + { 20, 5, 12, 0, 128, 20, 0, }, /* 497 */ + { 20, 5, 12, 0, 112, 20, 0, }, /* 498 */ + { 20, 5, 12, 0, 126, 20, 0, }, /* 499 */ + { 20, 8, 12, 0, -8, 20, 0, }, /* 500 */ + { 20, 5, 12, 0, 9, 20, 0, }, /* 501 */ + { 20, 9, 12, 0, -74, 20, 0, }, /* 502 */ + { 20, 8, 12, 0, -9, 20, 0, }, /* 503 */ + { 20, 5, 12, 21, -7173, 20, 0, }, /* 504 */ + { 20, 9, 12, 0, -86, 20, 0, }, /* 505 */ + { 20, 9, 12, 0, -100, 20, 0, }, /* 506 */ + { 20, 9, 12, 0, -112, 20, 0, }, /* 507 */ + { 20, 9, 12, 0, -128, 20, 0, }, /* 508 */ + { 20, 9, 12, 0, -126, 20, 0, }, /* 509 */ + { 28, 1, 3, 0, 0, 28, 0, }, /* 510 */ + { 28, 1, 13, 0, 0, 28, 0, }, /* 511 */ + { 10, 27, 2, 0, 0, 10, 0, }, /* 512 */ + { 10, 28, 2, 0, 0, 10, 0, }, /* 513 */ + { 10, 29, 12, 0, 0, -73, 0, }, /* 514 */ + { 10, 21, 14, 0, 0, 10, 0, }, /* 515 */ + { 0, 2, 2, 0, 0, 0, 0, }, /* 516 */ + { 28, 12, 3, 0, 0, -110, 0, }, /* 517 */ + { 10, 9, 12, 0, 0, 10, 0, }, /* 518 */ + { 10, 5, 12, 0, 0, 10, 0, }, /* 519 */ + { 20, 9, 12, 96, -7517, 20, 0, }, /* 520 */ + { 34, 9, 12, 100, -8383, 34, 0, }, /* 521 */ + { 34, 9, 12, 104, -8262, 34, 0, }, /* 522 */ + { 34, 9, 12, 0, 28, 34, 0, }, /* 523 */ + { 10, 7, 12, 0, 0, 10, 0, }, /* 524 */ + { 10, 5, 14, 0, 0, 10, 0, }, /* 525 */ + { 34, 5, 12, 0, -28, 34, 0, }, /* 526 */ + { 34, 14, 12, 0, 16, 34, 0, }, /* 527 */ + { 34, 14, 12, 0, -16, 34, 0, }, /* 528 */ + { 34, 14, 12, 0, 0, 34, 0, }, /* 529 */ + { 10, 25, 14, 0, 0, 10, 0, }, /* 530 */ + { 10, 26, 12, 0, 26, 10, 0, }, /* 531 */ + { 10, 26, 14, 0, 26, 10, 0, }, /* 532 */ + { 10, 26, 12, 0, -26, 10, 0, }, /* 533 */ + { 5, 26, 12, 0, 0, 5, 0, }, /* 534 */ + { 18, 9, 12, 0, 48, 18, 0, }, /* 535 */ + { 18, 5, 12, 0, -48, 18, 0, }, /* 536 */ + { 34, 9, 12, 0, -10743, 34, 0, }, /* 537 */ + { 34, 9, 12, 0, -3814, 34, 0, }, /* 538 */ + { 34, 9, 12, 0, -10727, 34, 0, }, /* 539 */ + { 34, 5, 12, 0, -10795, 34, 0, }, /* 540 */ + { 34, 5, 12, 0, -10792, 34, 0, }, /* 541 */ + { 34, 9, 12, 0, -10780, 34, 0, }, /* 542 */ + { 34, 9, 12, 0, -10749, 34, 0, }, /* 543 */ + { 34, 9, 12, 0, -10783, 34, 0, }, /* 544 */ + { 34, 9, 12, 0, -10782, 34, 0, }, /* 545 */ + { 34, 9, 12, 0, -10815, 34, 0, }, /* 546 */ + { 11, 5, 12, 0, 0, 11, 0, }, /* 547 */ + { 11, 26, 12, 0, 0, 11, 0, }, /* 548 */ + { 11, 12, 3, 0, 0, 11, 0, }, /* 549 */ + { 11, 21, 12, 0, 0, 11, 0, }, /* 550 */ + { 11, 15, 12, 0, 0, 11, 0, }, /* 551 */ + { 17, 5, 12, 0, -7264, 17, 0, }, /* 552 */ + { 59, 7, 12, 0, 0, 59, 0, }, /* 553 */ + { 59, 6, 12, 0, 0, 59, 0, }, /* 554 */ + { 59, 21, 12, 0, 0, 59, 0, }, /* 555 */ + { 59, 12, 3, 0, 0, 59, 0, }, /* 556 */ + { 13, 12, 3, 0, 0, 13, 0, }, /* 557 */ + { 10, 21, 12, 0, 0, -28, 0, }, /* 558 */ + { 23, 26, 12, 0, 0, 23, 0, }, /* 559 */ + { 10, 21, 12, 0, 0, -150, 0, }, /* 560 */ + { 10, 21, 12, 0, 0, -137, 0, }, /* 561 */ + { 23, 6, 12, 0, 0, 23, 0, }, /* 562 */ + { 10, 7, 12, 0, 0, 23, 0, }, /* 563 */ + { 23, 14, 12, 0, 0, 23, 0, }, /* 564 */ + { 10, 22, 12, 0, 0, -150, 0, }, /* 565 */ + { 10, 18, 12, 0, 0, -150, 0, }, /* 566 */ + { 10, 26, 12, 0, 0, -137, 0, }, /* 567 */ + { 10, 17, 12, 0, 0, -137, 0, }, /* 568 */ + { 10, 22, 12, 0, 0, -137, 0, }, /* 569 */ + { 10, 18, 12, 0, 0, -137, 0, }, /* 570 */ + { 28, 12, 3, 0, 0, -19, 0, }, /* 571 */ + { 24, 10, 3, 0, 0, 24, 0, }, /* 572 */ + { 10, 17, 14, 0, 0, -137, 0, }, /* 573 */ + { 10, 6, 12, 0, 0, -67, 0, }, /* 574 */ + { 10, 7, 12, 0, 0, -114, 0, }, /* 575 */ + { 10, 21, 14, 0, 0, -114, 0, }, /* 576 */ + { 10, 26, 12, 0, 0, 23, 0, }, /* 577 */ + { 27, 7, 12, 0, 0, 27, 0, }, /* 578 */ + { 28, 12, 3, 0, 0, -67, 0, }, /* 579 */ + { 10, 24, 12, 0, 0, -67, 0, }, /* 580 */ + { 27, 6, 12, 0, 0, 27, 0, }, /* 581 */ + { 10, 17, 12, 0, 0, -67, 0, }, /* 582 */ + { 30, 7, 12, 0, 0, 30, 0, }, /* 583 */ + { 30, 6, 12, 0, 0, 30, 0, }, /* 584 */ + { 4, 7, 12, 0, 0, 4, 0, }, /* 585 */ + { 24, 7, 12, 0, 0, 24, 0, }, /* 586 */ + { 10, 15, 12, 0, 0, 23, 0, }, /* 587 */ + { 24, 26, 12, 0, 0, 24, 0, }, /* 588 */ + { 10, 26, 14, 0, 0, 23, 0, }, /* 589 */ + { 30, 26, 12, 0, 0, 30, 0, }, /* 590 */ + { 23, 7, 12, 0, 0, 23, 0, }, /* 591 */ + { 61, 7, 12, 0, 0, 61, 0, }, /* 592 */ + { 61, 6, 12, 0, 0, 61, 0, }, /* 593 */ + { 61, 26, 12, 0, 0, 61, 0, }, /* 594 */ + { 86, 7, 12, 0, 0, 86, 0, }, /* 595 */ + { 86, 6, 12, 0, 0, 86, 0, }, /* 596 */ + { 86, 21, 12, 0, 0, 86, 0, }, /* 597 */ + { 77, 7, 12, 0, 0, 77, 0, }, /* 598 */ + { 77, 6, 12, 0, 0, 77, 0, }, /* 599 */ + { 77, 21, 12, 0, 0, 77, 0, }, /* 600 */ + { 77, 13, 12, 0, 0, 77, 0, }, /* 601 */ + { 13, 9, 12, 108, 1, 13, 0, }, /* 602 */ + { 13, 5, 12, 108, -35267, 13, 0, }, /* 603 */ + { 13, 7, 12, 0, 0, 13, 0, }, /* 604 */ + { 13, 21, 12, 0, 0, 13, 0, }, /* 605 */ + { 79, 7, 12, 0, 0, 79, 0, }, /* 606 */ + { 79, 14, 12, 0, 0, 79, 0, }, /* 607 */ + { 79, 12, 3, 0, 0, 79, 0, }, /* 608 */ + { 79, 21, 12, 0, 0, 79, 0, }, /* 609 */ + { 10, 24, 12, 0, 0, -64, 0, }, /* 610 */ + { 34, 9, 12, 0, -35332, 34, 0, }, /* 611 */ + { 34, 9, 12, 0, -42280, 34, 0, }, /* 612 */ + { 34, 5, 12, 0, 48, 34, 0, }, /* 613 */ + { 34, 9, 12, 0, -42308, 34, 0, }, /* 614 */ + { 34, 9, 12, 0, -42319, 34, 0, }, /* 615 */ + { 34, 9, 12, 0, -42315, 34, 0, }, /* 616 */ + { 34, 9, 12, 0, -42305, 34, 0, }, /* 617 */ + { 34, 9, 12, 0, -42258, 34, 0, }, /* 618 */ + { 34, 9, 12, 0, -42282, 34, 0, }, /* 619 */ + { 34, 9, 12, 0, -42261, 34, 0, }, /* 620 */ + { 34, 9, 12, 0, 928, 34, 0, }, /* 621 */ + { 34, 9, 12, 0, -48, 34, 0, }, /* 622 */ + { 34, 9, 12, 0, -42307, 34, 0, }, /* 623 */ + { 34, 9, 12, 0, -35384, 34, 0, }, /* 624 */ + { 49, 7, 12, 0, 0, 49, 0, }, /* 625 */ + { 49, 12, 3, 0, 0, 49, 0, }, /* 626 */ + { 49, 10, 5, 0, 0, 49, 0, }, /* 627 */ + { 49, 26, 12, 0, 0, 49, 0, }, /* 628 */ + { 10, 15, 12, 0, 0, -244, 0, }, /* 629 */ + { 10, 15, 12, 0, 0, -230, 0, }, /* 630 */ + { 10, 26, 12, 0, 0, -191, 0, }, /* 631 */ + { 10, 23, 12, 0, 0, -191, 0, }, /* 632 */ + { 65, 7, 12, 0, 0, 65, 0, }, /* 633 */ + { 65, 21, 12, 0, 0, 65, 0, }, /* 634 */ + { 75, 10, 5, 0, 0, 75, 0, }, /* 635 */ + { 75, 7, 12, 0, 0, 75, 0, }, /* 636 */ + { 75, 12, 3, 0, 0, 75, 0, }, /* 637 */ + { 75, 21, 12, 0, 0, 75, 0, }, /* 638 */ + { 75, 13, 12, 0, 0, 75, 0, }, /* 639 */ + { 15, 12, 3, 0, 0, -16, 0, }, /* 640 */ + { 15, 7, 12, 0, 0, -49, 0, }, /* 641 */ + { 69, 13, 12, 0, 0, 69, 0, }, /* 642 */ + { 69, 7, 12, 0, 0, 69, 0, }, /* 643 */ + { 69, 12, 3, 0, 0, 69, 0, }, /* 644 */ + { 10, 21, 12, 0, 0, -118, 0, }, /* 645 */ + { 69, 21, 12, 0, 0, 69, 0, }, /* 646 */ + { 74, 7, 12, 0, 0, 74, 0, }, /* 647 */ + { 74, 12, 3, 0, 0, 74, 0, }, /* 648 */ + { 74, 10, 5, 0, 0, 74, 0, }, /* 649 */ + { 74, 21, 12, 0, 0, 74, 0, }, /* 650 */ + { 84, 12, 3, 0, 0, 84, 0, }, /* 651 */ + { 84, 10, 5, 0, 0, 84, 0, }, /* 652 */ + { 84, 7, 12, 0, 0, 84, 0, }, /* 653 */ + { 84, 21, 12, 0, 0, 84, 0, }, /* 654 */ + { 10, 6, 12, 0, 0, -22, 0, }, /* 655 */ + { 84, 13, 12, 0, 0, 84, 0, }, /* 656 */ + { 39, 6, 12, 0, 0, 39, 0, }, /* 657 */ + { 68, 7, 12, 0, 0, 68, 0, }, /* 658 */ + { 68, 12, 3, 0, 0, 68, 0, }, /* 659 */ + { 68, 10, 5, 0, 0, 68, 0, }, /* 660 */ + { 68, 13, 12, 0, 0, 68, 0, }, /* 661 */ + { 68, 21, 12, 0, 0, 68, 0, }, /* 662 */ + { 92, 7, 12, 0, 0, 92, 0, }, /* 663 */ + { 92, 12, 3, 0, 0, 92, 0, }, /* 664 */ + { 92, 6, 12, 0, 0, 92, 0, }, /* 665 */ + { 92, 21, 12, 0, 0, 92, 0, }, /* 666 */ + { 87, 7, 12, 0, 0, 87, 0, }, /* 667 */ + { 87, 10, 5, 0, 0, 87, 0, }, /* 668 */ + { 87, 12, 3, 0, 0, 87, 0, }, /* 669 */ + { 87, 21, 12, 0, 0, 87, 0, }, /* 670 */ + { 87, 6, 12, 0, 0, 87, 0, }, /* 671 */ + { 34, 5, 12, 0, -928, 34, 0, }, /* 672 */ + { 9, 5, 12, 0, -38864, 9, 0, }, /* 673 */ + { 87, 13, 12, 0, 0, 87, 0, }, /* 674 */ + { 24, 7, 9, 0, 0, 24, 0, }, /* 675 */ + { 24, 7, 10, 0, 0, 24, 0, }, /* 676 */ + { 0, 4, 12, 0, 0, 0, 0, }, /* 677 */ + { 0, 3, 12, 0, 0, 0, 0, }, /* 678 */ + { 26, 25, 12, 0, 0, 26, 0, }, /* 679 */ + { 10, 18, 12, 0, 0, -7, 0, }, /* 680 */ + { 10, 22, 12, 0, 0, -7, 0, }, /* 681 */ + { 1, 7, 12, 0, 0, -13, 0, }, /* 682 */ + { 1, 26, 12, 0, 0, -13, 0, }, /* 683 */ + { 10, 6, 3, 0, 0, -67, 0, }, /* 684 */ + { 36, 7, 12, 0, 0, 36, 0, }, /* 685 */ + { 10, 21, 12, 0, 0, -98, 0, }, /* 686 */ + { 10, 21, 12, 0, 0, -25, 0, }, /* 687 */ + { 10, 15, 12, 0, 0, -102, 0, }, /* 688 */ + { 10, 26, 12, 0, 0, -25, 0, }, /* 689 */ + { 20, 14, 12, 0, 0, 20, 0, }, /* 690 */ + { 20, 15, 12, 0, 0, 20, 0, }, /* 691 */ + { 20, 26, 12, 0, 0, 20, 0, }, /* 692 */ + { 71, 7, 12, 0, 0, 71, 0, }, /* 693 */ + { 67, 7, 12, 0, 0, 67, 0, }, /* 694 */ + { 28, 12, 3, 0, 0, -1, 0, }, /* 695 */ + { 10, 15, 12, 0, 0, -1, 0, }, /* 696 */ + { 42, 7, 12, 0, 0, 42, 0, }, /* 697 */ + { 42, 15, 12, 0, 0, 42, 0, }, /* 698 */ + { 19, 7, 12, 0, 0, 19, 0, }, /* 699 */ + { 19, 14, 12, 0, 0, 19, 0, }, /* 700 */ + { 118, 7, 12, 0, 0, 118, 0, }, /* 701 */ + { 118, 12, 3, 0, 0, 118, 0, }, /* 702 */ + { 60, 7, 12, 0, 0, 60, 0, }, /* 703 */ + { 60, 21, 12, 0, 0, 60, 0, }, /* 704 */ + { 43, 7, 12, 0, 0, 43, 0, }, /* 705 */ + { 43, 21, 12, 0, 0, 43, 0, }, /* 706 */ + { 43, 14, 12, 0, 0, 43, 0, }, /* 707 */ + { 14, 9, 12, 0, 40, 14, 0, }, /* 708 */ + { 14, 5, 12, 0, -40, 14, 0, }, /* 709 */ + { 47, 7, 12, 0, 0, 47, 0, }, /* 710 */ + { 45, 7, 12, 0, 0, 45, 0, }, /* 711 */ + { 45, 13, 12, 0, 0, 45, 0, }, /* 712 */ + { 136, 9, 12, 0, 40, 136, 0, }, /* 713 */ + { 136, 5, 12, 0, -40, 136, 0, }, /* 714 */ + { 106, 7, 12, 0, 0, 106, 0, }, /* 715 */ + { 104, 7, 12, 0, 0, 104, 0, }, /* 716 */ + { 104, 21, 12, 0, 0, 104, 0, }, /* 717 */ + { 161, 9, 12, 0, 39, 161, 0, }, /* 718 */ + { 161, 5, 12, 0, -39, 161, 0, }, /* 719 */ + { 110, 7, 12, 0, 0, 110, 0, }, /* 720 */ + { 12, 7, 12, 0, 0, 12, 0, }, /* 721 */ + { 81, 7, 12, 0, 0, 81, 0, }, /* 722 */ + { 81, 21, 12, 0, 0, 81, 0, }, /* 723 */ + { 81, 15, 12, 0, 0, 81, 0, }, /* 724 */ + { 120, 7, 12, 0, 0, 120, 0, }, /* 725 */ + { 120, 26, 12, 0, 0, 120, 0, }, /* 726 */ + { 120, 15, 12, 0, 0, 120, 0, }, /* 727 */ + { 116, 7, 12, 0, 0, 116, 0, }, /* 728 */ + { 116, 15, 12, 0, 0, 116, 0, }, /* 729 */ + { 128, 7, 12, 0, 0, 128, 0, }, /* 730 */ + { 128, 15, 12, 0, 0, 128, 0, }, /* 731 */ + { 66, 7, 12, 0, 0, 66, 0, }, /* 732 */ + { 66, 15, 12, 0, 0, 66, 0, }, /* 733 */ + { 66, 21, 12, 0, 0, 66, 0, }, /* 734 */ + { 72, 7, 12, 0, 0, 72, 0, }, /* 735 */ + { 72, 21, 12, 0, 0, 72, 0, }, /* 736 */ + { 98, 7, 12, 0, 0, 98, 0, }, /* 737 */ + { 97, 7, 12, 0, 0, 97, 0, }, /* 738 */ + { 97, 15, 12, 0, 0, 97, 0, }, /* 739 */ + { 31, 7, 12, 0, 0, 31, 0, }, /* 740 */ + { 31, 12, 3, 0, 0, 31, 0, }, /* 741 */ + { 31, 15, 12, 0, 0, 31, 0, }, /* 742 */ + { 31, 21, 12, 0, 0, 31, 0, }, /* 743 */ + { 88, 7, 12, 0, 0, 88, 0, }, /* 744 */ + { 88, 15, 12, 0, 0, 88, 0, }, /* 745 */ + { 88, 21, 12, 0, 0, 88, 0, }, /* 746 */ + { 117, 7, 12, 0, 0, 117, 0, }, /* 747 */ + { 117, 15, 12, 0, 0, 117, 0, }, /* 748 */ + { 112, 7, 12, 0, 0, 112, 0, }, /* 749 */ + { 112, 26, 12, 0, 0, 112, 0, }, /* 750 */ + { 112, 12, 3, 0, 0, 112, 0, }, /* 751 */ + { 112, 15, 12, 0, 0, 112, 0, }, /* 752 */ + { 112, 21, 12, 0, 0, 112, 0, }, /* 753 */ + { 112, 21, 12, 0, 0, -76, 0, }, /* 754 */ + { 78, 7, 12, 0, 0, 78, 0, }, /* 755 */ + { 78, 21, 12, 0, 0, 78, 0, }, /* 756 */ + { 83, 7, 12, 0, 0, 83, 0, }, /* 757 */ + { 83, 15, 12, 0, 0, 83, 0, }, /* 758 */ + { 82, 7, 12, 0, 0, 82, 0, }, /* 759 */ + { 82, 15, 12, 0, 0, 82, 0, }, /* 760 */ + { 121, 7, 12, 0, 0, 121, 0, }, /* 761 */ + { 121, 21, 12, 0, 0, 121, 0, }, /* 762 */ + { 121, 15, 12, 0, 0, 121, 0, }, /* 763 */ + { 89, 7, 12, 0, 0, 89, 0, }, /* 764 */ + { 130, 9, 12, 0, 64, 130, 0, }, /* 765 */ + { 130, 5, 12, 0, -64, 130, 0, }, /* 766 */ + { 130, 15, 12, 0, 0, 130, 0, }, /* 767 */ + { 144, 7, 12, 0, 0, 144, 0, }, /* 768 */ + { 144, 12, 3, 0, 0, 144, 0, }, /* 769 */ + { 144, 13, 12, 0, 0, 144, 0, }, /* 770 */ + { 1, 15, 12, 0, 0, 1, 0, }, /* 771 */ + { 156, 7, 12, 0, 0, 156, 0, }, /* 772 */ + { 156, 12, 3, 0, 0, 156, 0, }, /* 773 */ + { 156, 17, 12, 0, 0, 156, 0, }, /* 774 */ + { 147, 7, 12, 0, 0, 147, 0, }, /* 775 */ + { 147, 15, 12, 0, 0, 147, 0, }, /* 776 */ + { 148, 7, 12, 0, 0, 148, 0, }, /* 777 */ + { 148, 12, 3, 0, 0, 148, 0, }, /* 778 */ + { 148, 15, 12, 0, 0, 148, 0, }, /* 779 */ + { 148, 21, 12, 0, 0, 148, 0, }, /* 780 */ + { 158, 7, 12, 0, 0, 158, 0, }, /* 781 */ + { 158, 12, 3, 0, 0, 158, 0, }, /* 782 */ + { 158, 21, 12, 0, 0, 158, 0, }, /* 783 */ + { 153, 7, 12, 0, 0, 153, 0, }, /* 784 */ + { 153, 15, 12, 0, 0, 153, 0, }, /* 785 */ + { 149, 7, 12, 0, 0, 149, 0, }, /* 786 */ + { 94, 10, 5, 0, 0, 94, 0, }, /* 787 */ + { 94, 12, 3, 0, 0, 94, 0, }, /* 788 */ + { 94, 7, 12, 0, 0, 94, 0, }, /* 789 */ + { 94, 21, 12, 0, 0, 94, 0, }, /* 790 */ + { 94, 15, 12, 0, 0, 94, 0, }, /* 791 */ + { 94, 13, 12, 0, 0, 94, 0, }, /* 792 */ + { 85, 12, 3, 0, 0, 85, 0, }, /* 793 */ + { 85, 10, 5, 0, 0, 85, 0, }, /* 794 */ + { 85, 7, 12, 0, 0, 85, 0, }, /* 795 */ + { 85, 21, 12, 0, 0, 85, 0, }, /* 796 */ + { 85, 1, 4, 0, 0, 85, 0, }, /* 797 */ + { 101, 7, 12, 0, 0, 101, 0, }, /* 798 */ + { 101, 13, 12, 0, 0, 101, 0, }, /* 799 */ + { 96, 12, 3, 0, 0, 96, 0, }, /* 800 */ + { 96, 7, 12, 0, 0, 96, 0, }, /* 801 */ + { 96, 10, 5, 0, 0, 96, 0, }, /* 802 */ + { 96, 13, 12, 0, 0, 96, 0, }, /* 803 */ + { 96, 21, 12, 0, 0, 96, 0, }, /* 804 */ + { 111, 7, 12, 0, 0, 111, 0, }, /* 805 */ + { 111, 12, 3, 0, 0, 111, 0, }, /* 806 */ + { 111, 21, 12, 0, 0, 111, 0, }, /* 807 */ + { 100, 12, 3, 0, 0, 100, 0, }, /* 808 */ + { 100, 10, 5, 0, 0, 100, 0, }, /* 809 */ + { 100, 7, 12, 0, 0, 100, 0, }, /* 810 */ + { 100, 7, 4, 0, 0, 100, 0, }, /* 811 */ + { 100, 21, 12, 0, 0, 100, 0, }, /* 812 */ + { 100, 13, 12, 0, 0, 100, 0, }, /* 813 */ + { 48, 15, 12, 0, 0, 48, 0, }, /* 814 */ + { 108, 7, 12, 0, 0, 108, 0, }, /* 815 */ + { 108, 10, 5, 0, 0, 108, 0, }, /* 816 */ + { 108, 12, 3, 0, 0, 108, 0, }, /* 817 */ + { 108, 21, 12, 0, 0, 108, 0, }, /* 818 */ + { 129, 7, 12, 0, 0, 129, 0, }, /* 819 */ + { 129, 21, 12, 0, 0, 129, 0, }, /* 820 */ + { 109, 7, 12, 0, 0, 109, 0, }, /* 821 */ + { 109, 12, 3, 0, 0, 109, 0, }, /* 822 */ + { 109, 10, 5, 0, 0, 109, 0, }, /* 823 */ + { 109, 13, 12, 0, 0, 109, 0, }, /* 824 */ + { 107, 12, 3, 0, 0, 107, 0, }, /* 825 */ + { 107, 12, 3, 0, 0, -55, 0, }, /* 826 */ + { 107, 10, 5, 0, 0, 107, 0, }, /* 827 */ + { 107, 10, 5, 0, 0, -55, 0, }, /* 828 */ + { 107, 7, 12, 0, 0, 107, 0, }, /* 829 */ + { 28, 12, 3, 0, 0, -55, 0, }, /* 830 */ + { 107, 10, 3, 0, 0, 107, 0, }, /* 831 */ + { 135, 7, 12, 0, 0, 135, 0, }, /* 832 */ + { 135, 10, 5, 0, 0, 135, 0, }, /* 833 */ + { 135, 12, 3, 0, 0, 135, 0, }, /* 834 */ + { 135, 21, 12, 0, 0, 135, 0, }, /* 835 */ + { 135, 13, 12, 0, 0, 135, 0, }, /* 836 */ + { 124, 7, 12, 0, 0, 124, 0, }, /* 837 */ + { 124, 10, 3, 0, 0, 124, 0, }, /* 838 */ + { 124, 10, 5, 0, 0, 124, 0, }, /* 839 */ + { 124, 12, 3, 0, 0, 124, 0, }, /* 840 */ + { 124, 21, 12, 0, 0, 124, 0, }, /* 841 */ + { 124, 13, 12, 0, 0, 124, 0, }, /* 842 */ + { 123, 7, 12, 0, 0, 123, 0, }, /* 843 */ + { 123, 10, 3, 0, 0, 123, 0, }, /* 844 */ + { 123, 10, 5, 0, 0, 123, 0, }, /* 845 */ + { 123, 12, 3, 0, 0, 123, 0, }, /* 846 */ + { 123, 21, 12, 0, 0, 123, 0, }, /* 847 */ + { 114, 7, 12, 0, 0, 114, 0, }, /* 848 */ + { 114, 10, 5, 0, 0, 114, 0, }, /* 849 */ + { 114, 12, 3, 0, 0, 114, 0, }, /* 850 */ + { 114, 21, 12, 0, 0, 114, 0, }, /* 851 */ + { 114, 13, 12, 0, 0, 114, 0, }, /* 852 */ + { 102, 7, 12, 0, 0, 102, 0, }, /* 853 */ + { 102, 12, 3, 0, 0, 102, 0, }, /* 854 */ + { 102, 10, 5, 0, 0, 102, 0, }, /* 855 */ + { 102, 21, 12, 0, 0, 102, 0, }, /* 856 */ + { 102, 13, 12, 0, 0, 102, 0, }, /* 857 */ + { 126, 7, 12, 0, 0, 126, 0, }, /* 858 */ + { 126, 12, 3, 0, 0, 126, 0, }, /* 859 */ + { 126, 10, 12, 0, 0, 126, 0, }, /* 860 */ + { 126, 10, 5, 0, 0, 126, 0, }, /* 861 */ + { 126, 13, 12, 0, 0, 126, 0, }, /* 862 */ + { 126, 15, 12, 0, 0, 126, 0, }, /* 863 */ + { 126, 21, 12, 0, 0, 126, 0, }, /* 864 */ + { 126, 26, 12, 0, 0, 126, 0, }, /* 865 */ + { 142, 7, 12, 0, 0, 142, 0, }, /* 866 */ + { 142, 10, 5, 0, 0, 142, 0, }, /* 867 */ + { 142, 12, 3, 0, 0, 142, 0, }, /* 868 */ + { 142, 21, 12, 0, 0, 142, 0, }, /* 869 */ + { 125, 9, 12, 0, 32, 125, 0, }, /* 870 */ + { 125, 5, 12, 0, -32, 125, 0, }, /* 871 */ + { 125, 13, 12, 0, 0, 125, 0, }, /* 872 */ + { 125, 15, 12, 0, 0, 125, 0, }, /* 873 */ + { 125, 7, 12, 0, 0, 125, 0, }, /* 874 */ + { 154, 7, 12, 0, 0, 154, 0, }, /* 875 */ + { 154, 10, 3, 0, 0, 154, 0, }, /* 876 */ + { 154, 10, 5, 0, 0, 154, 0, }, /* 877 */ + { 154, 12, 3, 0, 0, 154, 0, }, /* 878 */ + { 154, 7, 4, 0, 0, 154, 0, }, /* 879 */ + { 154, 21, 12, 0, 0, 154, 0, }, /* 880 */ + { 154, 13, 12, 0, 0, 154, 0, }, /* 881 */ + { 150, 7, 12, 0, 0, 150, 0, }, /* 882 */ + { 150, 10, 5, 0, 0, 150, 0, }, /* 883 */ + { 150, 12, 3, 0, 0, 150, 0, }, /* 884 */ + { 150, 21, 12, 0, 0, 150, 0, }, /* 885 */ + { 141, 7, 12, 0, 0, 141, 0, }, /* 886 */ + { 141, 12, 3, 0, 0, 141, 0, }, /* 887 */ + { 141, 10, 5, 0, 0, 141, 0, }, /* 888 */ + { 141, 7, 4, 0, 0, 141, 0, }, /* 889 */ + { 141, 21, 12, 0, 0, 141, 0, }, /* 890 */ + { 140, 7, 12, 0, 0, 140, 0, }, /* 891 */ + { 140, 12, 3, 0, 0, 140, 0, }, /* 892 */ + { 140, 10, 5, 0, 0, 140, 0, }, /* 893 */ + { 140, 7, 4, 0, 0, 140, 0, }, /* 894 */ + { 140, 21, 12, 0, 0, 140, 0, }, /* 895 */ + { 122, 7, 12, 0, 0, 122, 0, }, /* 896 */ + { 133, 7, 12, 0, 0, 133, 0, }, /* 897 */ + { 133, 10, 5, 0, 0, 133, 0, }, /* 898 */ + { 133, 12, 3, 0, 0, 133, 0, }, /* 899 */ + { 133, 21, 12, 0, 0, 133, 0, }, /* 900 */ + { 133, 13, 12, 0, 0, 133, 0, }, /* 901 */ + { 133, 15, 12, 0, 0, 133, 0, }, /* 902 */ + { 134, 21, 12, 0, 0, 134, 0, }, /* 903 */ + { 134, 7, 12, 0, 0, 134, 0, }, /* 904 */ + { 134, 12, 3, 0, 0, 134, 0, }, /* 905 */ + { 134, 10, 5, 0, 0, 134, 0, }, /* 906 */ + { 138, 7, 12, 0, 0, 138, 0, }, /* 907 */ + { 138, 12, 3, 0, 0, 138, 0, }, /* 908 */ + { 138, 7, 4, 0, 0, 138, 0, }, /* 909 */ + { 138, 13, 12, 0, 0, 138, 0, }, /* 910 */ + { 143, 7, 12, 0, 0, 143, 0, }, /* 911 */ + { 143, 10, 5, 0, 0, 143, 0, }, /* 912 */ + { 143, 12, 3, 0, 0, 143, 0, }, /* 913 */ + { 143, 13, 12, 0, 0, 143, 0, }, /* 914 */ + { 145, 7, 12, 0, 0, 145, 0, }, /* 915 */ + { 145, 12, 3, 0, 0, 145, 0, }, /* 916 */ + { 145, 10, 5, 0, 0, 145, 0, }, /* 917 */ + { 145, 21, 12, 0, 0, 145, 0, }, /* 918 */ + { 54, 15, 12, 0, 0, 54, 0, }, /* 919 */ + { 54, 21, 12, 0, 0, 54, 0, }, /* 920 */ + { 63, 7, 12, 0, 0, 63, 0, }, /* 921 */ + { 63, 14, 12, 0, 0, 63, 0, }, /* 922 */ + { 63, 21, 12, 0, 0, 63, 0, }, /* 923 */ + { 157, 7, 12, 0, 0, 157, 0, }, /* 924 */ + { 157, 21, 12, 0, 0, 157, 0, }, /* 925 */ + { 80, 7, 12, 0, 0, 80, 0, }, /* 926 */ + { 80, 1, 2, 0, 0, 80, 0, }, /* 927 */ + { 127, 7, 12, 0, 0, 127, 0, }, /* 928 */ + { 115, 7, 12, 0, 0, 115, 0, }, /* 929 */ + { 115, 13, 12, 0, 0, 115, 0, }, /* 930 */ + { 115, 21, 12, 0, 0, 115, 0, }, /* 931 */ + { 159, 7, 12, 0, 0, 159, 0, }, /* 932 */ + { 159, 13, 12, 0, 0, 159, 0, }, /* 933 */ + { 103, 7, 12, 0, 0, 103, 0, }, /* 934 */ + { 103, 12, 3, 0, 0, 103, 0, }, /* 935 */ + { 103, 21, 12, 0, 0, 103, 0, }, /* 936 */ + { 119, 7, 12, 0, 0, 119, 0, }, /* 937 */ + { 119, 12, 3, 0, 0, 119, 0, }, /* 938 */ + { 119, 21, 12, 0, 0, 119, 0, }, /* 939 */ + { 119, 26, 12, 0, 0, 119, 0, }, /* 940 */ + { 119, 6, 12, 0, 0, 119, 0, }, /* 941 */ + { 119, 13, 12, 0, 0, 119, 0, }, /* 942 */ + { 119, 15, 12, 0, 0, 119, 0, }, /* 943 */ + { 146, 9, 12, 0, 32, 146, 0, }, /* 944 */ + { 146, 5, 12, 0, -32, 146, 0, }, /* 945 */ + { 146, 15, 12, 0, 0, 146, 0, }, /* 946 */ + { 146, 21, 12, 0, 0, 146, 0, }, /* 947 */ + { 99, 7, 12, 0, 0, 99, 0, }, /* 948 */ + { 99, 12, 3, 0, 0, 99, 0, }, /* 949 */ + { 99, 10, 5, 0, 0, 99, 0, }, /* 950 */ + { 99, 6, 12, 0, 0, 99, 0, }, /* 951 */ + { 137, 6, 12, 0, 0, 137, 0, }, /* 952 */ + { 139, 6, 12, 0, 0, 139, 0, }, /* 953 */ + { 23, 21, 12, 0, 0, 23, 0, }, /* 954 */ + { 155, 12, 3, 0, 0, 155, 0, }, /* 955 */ + { 23, 10, 5, 0, 0, 23, 0, }, /* 956 */ + { 137, 7, 12, 0, 0, 137, 0, }, /* 957 */ + { 155, 7, 12, 0, 0, 155, 0, }, /* 958 */ + { 139, 7, 12, 0, 0, 139, 0, }, /* 959 */ + { 105, 7, 12, 0, 0, 105, 0, }, /* 960 */ + { 105, 26, 12, 0, 0, 105, 0, }, /* 961 */ + { 105, 12, 3, 0, 0, 105, 0, }, /* 962 */ + { 105, 21, 12, 0, 0, 105, 0, }, /* 963 */ + { 10, 1, 2, 0, 0, 105, 0, }, /* 964 */ + { 10, 10, 3, 0, 0, 10, 0, }, /* 965 */ + { 10, 10, 5, 0, 0, 10, 0, }, /* 966 */ + { 20, 12, 3, 0, 0, 20, 0, }, /* 967 */ + { 131, 26, 12, 0, 0, 131, 0, }, /* 968 */ + { 131, 12, 3, 0, 0, 131, 0, }, /* 969 */ + { 131, 21, 12, 0, 0, 131, 0, }, /* 970 */ + { 18, 12, 3, 0, 0, 18, 0, }, /* 971 */ + { 151, 7, 12, 0, 0, 151, 0, }, /* 972 */ + { 151, 12, 3, 0, 0, 151, 0, }, /* 973 */ + { 151, 6, 12, 0, 0, 151, 0, }, /* 974 */ + { 151, 13, 12, 0, 0, 151, 0, }, /* 975 */ + { 151, 26, 12, 0, 0, 151, 0, }, /* 976 */ + { 160, 7, 12, 0, 0, 160, 0, }, /* 977 */ + { 160, 12, 3, 0, 0, 160, 0, }, /* 978 */ + { 152, 7, 12, 0, 0, 152, 0, }, /* 979 */ + { 152, 12, 3, 0, 0, 152, 0, }, /* 980 */ + { 152, 13, 12, 0, 0, 152, 0, }, /* 981 */ + { 152, 23, 12, 0, 0, 152, 0, }, /* 982 */ + { 113, 7, 12, 0, 0, 113, 0, }, /* 983 */ + { 113, 15, 12, 0, 0, 113, 0, }, /* 984 */ + { 113, 12, 3, 0, 0, 113, 0, }, /* 985 */ + { 132, 9, 12, 0, 34, 132, 0, }, /* 986 */ + { 132, 5, 12, 0, -34, 132, 0, }, /* 987 */ + { 132, 12, 3, 0, 0, 132, 0, }, /* 988 */ + { 132, 6, 12, 0, 0, 132, 0, }, /* 989 */ + { 132, 13, 12, 0, 0, 132, 0, }, /* 990 */ + { 132, 21, 12, 0, 0, 132, 0, }, /* 991 */ + { 0, 2, 14, 0, 0, 0, 0, }, /* 992 */ + { 10, 26, 11, 0, 0, 10, 0, }, /* 993 */ + { 27, 26, 12, 0, 0, 27, 0, }, /* 994 */ + { 10, 24, 3, 0, 0, 10, 0, }, /* 995 */ + { 10, 1, 3, 0, 0, 10, 0, }, /* 996 */ }; const uint16_t PRIV(ucd_stage1)[] = { /* 17408 bytes */ @@ -1190,51 +1216,51 @@ const uint16_t PRIV(ucd_stage1)[] = { /* 17408 bytes */ 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, /* U+8000 */ 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, /* U+8800 */ 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, /* U+9000 */ - 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,100, /* U+9800 */ -101,102,102,102,102,102,102,102,102,103,104,104,105,106,107,108, /* U+A000 */ -109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,117, /* U+A800 */ -118,119,120,121,122,123,117,118,119,120,121,122,123,117,118,119, /* U+B000 */ -120,121,122,123,117,118,119,120,121,122,123,117,118,119,120,121, /* U+B800 */ -122,123,117,118,119,120,121,122,123,117,118,119,120,121,122,123, /* U+C000 */ -117,118,119,120,121,122,123,117,118,119,120,121,122,123,117,118, /* U+C800 */ -119,120,121,122,123,117,118,119,120,121,122,123,117,118,119,124, /* U+D000 */ -125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+D800 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+E000 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+E800 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+F000 */ -126,126, 98, 98,127,128,129,130,131,131,132,133,134,135,136,137, /* U+F800 */ -138,139,140,141,142,143,144,145,146,147,148,142,149,149,150,142, /* U+10000 */ -151,152,153,154,155,156,157,158,159,160,161,142,162,163,164,165, /* U+10800 */ -166,167,168,169,170,171,172,142,173,174,142,175,176,177,178,142, /* U+11000 */ -179,180,181,182,183,184,142,142,185,186,187,188,142,189,142,190, /* U+11800 */ -191,191,191,191,191,191,191,192,193,191,194,142,142,142,142,142, /* U+12000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+12800 */ -195,195,195,195,195,195,195,195,196,142,142,142,142,142,142,142, /* U+13000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+13800 */ -142,142,142,142,142,142,142,142,197,197,197,197,198,142,142,142, /* U+14000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+14800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+15000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+15800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+16000 */ -199,199,199,199,200,201,202,203,142,142,142,142,204,205,206,207, /* U+16800 */ -208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208, /* U+17000 */ -208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208, /* U+17800 */ -208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,209, /* U+18000 */ -208,208,208,208,208,208,210,210,210,211,212,142,142,142,142,142, /* U+18800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+19000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+19800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+1A000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+1A800 */ -213,214,215,216,216,217,142,142,142,142,142,142,142,142,142,142, /* U+1B000 */ -142,142,142,142,142,142,142,142,218,219,142,142,142,142,142,142, /* U+1B800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+1C000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+1C800 */ - 71,220,221,222,223,224,225,142,226,227,228,229,230,231,232,233, /* U+1D000 */ -234,234,234,234,235,236,142,142,142,142,142,142,142,142,142,142, /* U+1D800 */ -237,142,238,142,142,239,142,142,142,142,142,142,142,142,142,142, /* U+1E000 */ -240,241,242,142,142,142,142,142,243,244,245,142,246,247,142,142, /* U+1E800 */ -248,249,250,251,252,253,254,255,254,254,256,254,257,258,259,260, /* U+1F000 */ -261,262,263,264,265,266, 71,267,253,253,253,253,253,253,253,268, /* U+1F800 */ + 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, /* U+9800 */ +100,101,101,101,101,101,101,101,101,102,103,103,104,105,106,107, /* U+A000 */ +108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,116, /* U+A800 */ +117,118,119,120,121,122,116,117,118,119,120,121,122,116,117,118, /* U+B000 */ +119,120,121,122,116,117,118,119,120,121,122,116,117,118,119,120, /* U+B800 */ +121,122,116,117,118,119,120,121,122,116,117,118,119,120,121,122, /* U+C000 */ +116,117,118,119,120,121,122,116,117,118,119,120,121,122,116,117, /* U+C800 */ +118,119,120,121,122,116,117,118,119,120,121,122,116,117,118,123, /* U+D000 */ +124,124,124,124,124,124,124,124,124,124,124,124,124,124,124,124, /* U+D800 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+E000 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+E800 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+F000 */ +125,125, 98, 98,126,127,128,129,130,130,131,132,133,134,135,136, /* U+F800 */ +137,138,139,140,141,142,143,144,145,146,147,148,149,149,150,151, /* U+10000 */ +152,153,154,155,156,157,158,159,160,161,162,141,163,164,165,166, /* U+10800 */ +167,168,169,170,171,172,173,141,174,175,141,176,177,178,179,141, /* U+11000 */ +180,181,182,183,184,185,141,141,186,187,188,189,141,190,141,191, /* U+11800 */ +192,192,192,192,192,192,192,193,194,192,195,141,141,141,141,141, /* U+12000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,196, /* U+12800 */ +197,197,197,197,197,197,197,197,198,141,141,141,141,141,141,141, /* U+13000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+13800 */ +141,141,141,141,141,141,141,141,199,199,199,199,200,141,141,141, /* U+14000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+14800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+15000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+15800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+16000 */ +201,201,201,201,202,203,204,205,141,141,141,141,206,207,208,209, /* U+16800 */ +210,210,210,210,210,210,210,210,210,210,210,210,210,210,210,210, /* U+17000 */ +210,210,210,210,210,210,210,210,210,210,210,210,210,210,210,210, /* U+17800 */ +210,210,210,210,210,210,210,210,210,210,210,210,210,210,210,211, /* U+18000 */ +210,210,210,210,210,210,212,212,212,213,214,141,141,141,141,141, /* U+18800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+19000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+19800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+1A000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,215, /* U+1A800 */ +216,217,218,219,219,220,141,141,141,141,141,141,141,141,141,141, /* U+1B000 */ +141,141,141,141,141,141,141,141,221,222,141,141,141,141,141,141, /* U+1B800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+1C000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,223,224, /* U+1C800 */ + 71,225,226,227,228,229,230,141,231,232,233,234,235,236,237,238, /* U+1D000 */ +239,239,239,239,240,241,141,141,141,141,141,141,141,141,242,141, /* U+1D800 */ +243,141,244,141,141,245,141,141,141,141,141,141,141,141,141,246, /* U+1E000 */ +247,248,249,141,141,141,141,141,250,251,252,141,253,254,141,141, /* U+1E800 */ +255,256,257,258,259,260,261,262,261,261,263,261,264,265,266,267, /* U+1F000 */ +268,269,270,261,271,272, 71,273,260,260,260,260,260,260,260,274, /* U+1F800 */ 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, /* U+20000 */ 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, /* U+20800 */ 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, /* U+21000 */ @@ -1255,469 +1281,469 @@ const uint16_t PRIV(ucd_stage1)[] = { /* 17408 bytes */ 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, /* U+28800 */ 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, /* U+29000 */ 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, /* U+29800 */ - 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,269, 98, 98, /* U+2A000 */ + 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,275, 98, 98, /* U+2A000 */ 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, /* U+2A800 */ - 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,270, 98, /* U+2B000 */ -271, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, /* U+2B800 */ + 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,276, 98, /* U+2B000 */ +277, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, /* U+2B800 */ 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, /* U+2C000 */ - 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,272, 98, 98, /* U+2C800 */ + 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,278, 98, 98, /* U+2C800 */ 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, /* U+2D000 */ 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, /* U+2D800 */ 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, /* U+2E000 */ - 98, 98, 98, 98, 98, 98, 98,273,142,142,142,142,142,142,142,142, /* U+2E800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+2F000 */ - 98, 98, 98, 98,274,142,142,142,142,142,142,142,142,142,142,142, /* U+2F800 */ + 98, 98, 98, 98, 98, 98, 98,279,141,141,141,141,141,141,141,141, /* U+2E800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+2F000 */ + 98, 98, 98, 98,280,141,141,141,141,141,141,141,141,141,141,141, /* U+2F800 */ 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, /* U+30000 */ 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, /* U+30800 */ - 98, 98, 98, 98, 98, 98,275,142,142,142,142,142,142,142,142,142, /* U+31000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+31800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+32000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+32800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+33000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+33800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+34000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+34800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+35000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+35800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+36000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+36800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+37000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+37800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+38000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+38800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+39000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+39800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+3A000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+3A800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+3B000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+3B800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+3C000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+3C800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+3D000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+3D800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+3E000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+3E800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+3F000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+3F800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+40000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+40800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+41000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+41800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+42000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+42800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+43000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+43800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+44000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+44800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+45000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+45800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+46000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+46800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+47000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+47800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+48000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+48800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+49000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+49800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+4A000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+4A800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+4B000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+4B800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+4C000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+4C800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+4D000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+4D800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+4E000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+4E800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+4F000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+4F800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+50000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+50800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+51000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+51800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+52000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+52800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+53000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+53800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+54000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+54800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+55000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+55800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+56000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+56800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+57000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+57800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+58000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+58800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+59000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+59800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+5A000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+5A800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+5B000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+5B800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+5C000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+5C800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+5D000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+5D800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+5E000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+5E800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+5F000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+5F800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+60000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+60800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+61000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+61800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+62000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+62800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+63000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+63800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+64000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+64800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+65000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+65800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+66000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+66800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+67000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+67800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+68000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+68800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+69000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+69800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+6A000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+6A800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+6B000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+6B800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+6C000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+6C800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+6D000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+6D800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+6E000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+6E800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+6F000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+6F800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+70000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+70800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+71000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+71800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+72000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+72800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+73000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+73800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+74000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+74800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+75000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+75800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+76000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+76800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+77000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+77800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+78000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+78800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+79000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+79800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+7A000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+7A800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+7B000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+7B800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+7C000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+7C800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+7D000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+7D800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+7E000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+7E800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+7F000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+7F800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+80000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+80800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+81000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+81800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+82000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+82800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+83000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+83800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+84000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+84800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+85000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+85800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+86000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+86800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+87000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+87800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+88000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+88800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+89000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+89800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+8A000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+8A800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+8B000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+8B800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+8C000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+8C800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+8D000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+8D800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+8E000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+8E800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+8F000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+8F800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+90000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+90800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+91000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+91800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+92000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+92800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+93000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+93800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+94000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+94800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+95000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+95800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+96000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+96800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+97000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+97800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+98000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+98800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+99000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+99800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+9A000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+9A800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+9B000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+9B800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+9C000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+9C800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+9D000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+9D800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+9E000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+9E800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+9F000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+9F800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+A0000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+A0800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+A1000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+A1800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+A2000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+A2800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+A3000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+A3800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+A4000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+A4800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+A5000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+A5800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+A6000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+A6800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+A7000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+A7800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+A8000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+A8800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+A9000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+A9800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+AA000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+AA800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+AB000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+AB800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+AC000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+AC800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+AD000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+AD800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+AE000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+AE800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+AF000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+AF800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+B0000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+B0800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+B1000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+B1800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+B2000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+B2800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+B3000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+B3800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+B4000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+B4800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+B5000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+B5800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+B6000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+B6800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+B7000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+B7800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+B8000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+B8800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+B9000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+B9800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+BA000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+BA800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+BB000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+BB800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+BC000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+BC800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+BD000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+BD800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+BE000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+BE800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+BF000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+BF800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+C0000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+C0800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+C1000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+C1800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+C2000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+C2800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+C3000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+C3800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+C4000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+C4800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+C5000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+C5800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+C6000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+C6800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+C7000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+C7800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+C8000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+C8800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+C9000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+C9800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+CA000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+CA800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+CB000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+CB800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+CC000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+CC800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+CD000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+CD800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+CE000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+CE800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+CF000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+CF800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+D0000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+D0800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+D1000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+D1800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+D2000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+D2800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+D3000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+D3800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+D4000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+D4800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+D5000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+D5800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+D6000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+D6800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+D7000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+D7800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+D8000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+D8800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+D9000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+D9800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+DA000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+DA800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+DB000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+DB800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+DC000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+DC800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+DD000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+DD800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+DE000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+DE800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+DF000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+DF800 */ -276,277,278,279,277,277,277,277,277,277,277,277,277,277,277,277, /* U+E0000 */ -277,277,277,277,277,277,277,277,277,277,277,277,277,277,277,277, /* U+E0800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+E1000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+E1800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+E2000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+E2800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+E3000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+E3800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+E4000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+E4800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+E5000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+E5800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+E6000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+E6800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+E7000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+E7800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+E8000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+E8800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+E9000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+E9800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+EA000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+EA800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+EB000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+EB800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+EC000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+EC800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+ED000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+ED800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+EE000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+EE800 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+EF000 */ -142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+EF800 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+F0000 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+F0800 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+F1000 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+F1800 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+F2000 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+F2800 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+F3000 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+F3800 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+F4000 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+F4800 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+F5000 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+F5800 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+F6000 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+F6800 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+F7000 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+F7800 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+F8000 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+F8800 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+F9000 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+F9800 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+FA000 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+FA800 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+FB000 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+FB800 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+FC000 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+FC800 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+FD000 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+FD800 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+FE000 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+FE800 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+FF000 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,280, /* U+FF800 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+100000 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+100800 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+101000 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+101800 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+102000 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+102800 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+103000 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+103800 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+104000 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+104800 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+105000 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+105800 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+106000 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+106800 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+107000 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+107800 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+108000 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+108800 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+109000 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+109800 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+10A000 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+10A800 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+10B000 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+10B800 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+10C000 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+10C800 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+10D000 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+10D800 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+10E000 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+10E800 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+10F000 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,280, /* U+10F800 */ + 98, 98, 98, 98, 98, 98,281,141,141,141,141,141,141,141,141,141, /* U+31000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+31800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+32000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+32800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+33000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+33800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+34000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+34800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+35000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+35800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+36000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+36800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+37000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+37800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+38000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+38800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+39000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+39800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+3A000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+3A800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+3B000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+3B800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+3C000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+3C800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+3D000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+3D800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+3E000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+3E800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+3F000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+3F800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+40000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+40800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+41000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+41800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+42000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+42800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+43000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+43800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+44000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+44800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+45000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+45800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+46000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+46800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+47000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+47800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+48000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+48800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+49000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+49800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+4A000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+4A800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+4B000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+4B800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+4C000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+4C800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+4D000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+4D800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+4E000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+4E800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+4F000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+4F800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+50000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+50800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+51000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+51800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+52000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+52800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+53000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+53800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+54000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+54800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+55000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+55800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+56000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+56800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+57000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+57800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+58000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+58800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+59000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+59800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+5A000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+5A800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+5B000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+5B800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+5C000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+5C800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+5D000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+5D800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+5E000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+5E800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+5F000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+5F800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+60000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+60800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+61000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+61800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+62000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+62800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+63000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+63800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+64000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+64800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+65000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+65800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+66000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+66800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+67000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+67800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+68000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+68800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+69000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+69800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+6A000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+6A800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+6B000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+6B800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+6C000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+6C800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+6D000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+6D800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+6E000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+6E800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+6F000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+6F800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+70000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+70800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+71000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+71800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+72000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+72800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+73000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+73800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+74000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+74800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+75000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+75800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+76000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+76800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+77000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+77800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+78000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+78800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+79000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+79800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+7A000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+7A800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+7B000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+7B800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+7C000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+7C800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+7D000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+7D800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+7E000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+7E800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+7F000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+7F800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+80000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+80800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+81000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+81800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+82000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+82800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+83000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+83800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+84000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+84800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+85000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+85800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+86000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+86800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+87000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+87800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+88000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+88800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+89000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+89800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+8A000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+8A800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+8B000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+8B800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+8C000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+8C800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+8D000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+8D800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+8E000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+8E800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+8F000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+8F800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+90000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+90800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+91000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+91800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+92000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+92800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+93000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+93800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+94000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+94800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+95000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+95800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+96000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+96800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+97000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+97800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+98000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+98800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+99000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+99800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+9A000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+9A800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+9B000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+9B800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+9C000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+9C800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+9D000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+9D800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+9E000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+9E800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+9F000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+9F800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+A0000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+A0800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+A1000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+A1800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+A2000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+A2800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+A3000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+A3800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+A4000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+A4800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+A5000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+A5800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+A6000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+A6800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+A7000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+A7800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+A8000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+A8800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+A9000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+A9800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+AA000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+AA800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+AB000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+AB800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+AC000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+AC800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+AD000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+AD800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+AE000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+AE800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+AF000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+AF800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+B0000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+B0800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+B1000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+B1800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+B2000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+B2800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+B3000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+B3800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+B4000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+B4800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+B5000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+B5800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+B6000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+B6800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+B7000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+B7800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+B8000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+B8800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+B9000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+B9800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+BA000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+BA800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+BB000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+BB800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+BC000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+BC800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+BD000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+BD800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+BE000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+BE800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+BF000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+BF800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+C0000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+C0800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+C1000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+C1800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+C2000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+C2800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+C3000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+C3800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+C4000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+C4800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+C5000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+C5800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+C6000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+C6800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+C7000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+C7800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+C8000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+C8800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+C9000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+C9800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+CA000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+CA800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+CB000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+CB800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+CC000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+CC800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+CD000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+CD800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+CE000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+CE800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+CF000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+CF800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+D0000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+D0800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+D1000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+D1800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+D2000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+D2800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+D3000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+D3800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+D4000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+D4800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+D5000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+D5800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+D6000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+D6800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+D7000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+D7800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+D8000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+D8800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+D9000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+D9800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+DA000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+DA800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+DB000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+DB800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+DC000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+DC800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+DD000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+DD800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+DE000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+DE800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+DF000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+DF800 */ +282,283,284,285,283,283,283,283,283,283,283,283,283,283,283,283, /* U+E0000 */ +283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283, /* U+E0800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+E1000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+E1800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+E2000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+E2800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+E3000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+E3800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+E4000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+E4800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+E5000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+E5800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+E6000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+E6800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+E7000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+E7800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+E8000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+E8800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+E9000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+E9800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+EA000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+EA800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+EB000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+EB800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+EC000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+EC800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+ED000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+ED800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+EE000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+EE800 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+EF000 */ +141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, /* U+EF800 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+F0000 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+F0800 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+F1000 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+F1800 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+F2000 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+F2800 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+F3000 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+F3800 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+F4000 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+F4800 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+F5000 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+F5800 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+F6000 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+F6800 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+F7000 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+F7800 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+F8000 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+F8800 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+F9000 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+F9800 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+FA000 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+FA800 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+FB000 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+FB800 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+FC000 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+FC800 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+FD000 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+FD800 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+FE000 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+FE800 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+FF000 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,286, /* U+FF800 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+100000 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+100800 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+101000 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+101800 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+102000 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+102800 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+103000 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+103800 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+104000 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+104800 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+105000 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+105800 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+106000 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+106800 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+107000 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+107800 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+108000 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+108800 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+109000 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+109800 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+10A000 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+10A800 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+10B000 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+10B800 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+10C000 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+10C800 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+10D000 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+10D800 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+10E000 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+10E800 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125, /* U+10F000 */ +125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,286, /* U+10F800 */ }; -const uint16_t PRIV(ucd_stage2)[] = { /* 71936 bytes, block = 128 */ +const uint16_t PRIV(ucd_stage2)[] = { /* 73472 bytes, block = 128 */ /* block 0 */ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -1840,463 +1866,463 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 71936 bytes, block = 128 */ /* block 12 */ 215,215,215,215,215,216,217,217,217,218,218,219,220,218,221,221, -222,222,222,222,222,222,222,222,222,222,222,220,223,120,218,220, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -225,224,224,224,224,224,224,224,224,224,224,226,226,226,226,226, -226,226,226,226,226,226,222,222,222,222,222,222,222,222,222,222, -227,227,227,227,227,227,227,227,227,227,218,218,218,218,224,224, -226,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, +222,222,222,222,222,222,222,222,222,222,222,220,223,218,218,224, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +226,225,225,225,225,225,225,225,225,225,225,227,227,227,227,227, +227,227,227,227,227,227,222,222,222,222,222,222,222,222,222,222, +228,228,228,228,228,228,228,228,228,228,218,218,218,218,225,225, +227,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, /* block 13 */ -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,228,224,222,222,222,222,222,222,222,216,221,222, -222,222,222,222,222,229,229,222,222,221,222,222,222,222,224,224, -230,230,230,230,230,230,230,230,230,230,224,224,224,221,221,224, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,229,225,222,222,222,222,222,222,222,216,221,222, +222,222,222,222,222,230,230,222,222,221,222,222,222,222,225,225, +231,231,231,231,231,231,231,231,231,231,225,225,225,221,221,225, /* block 14 */ -231,231,231,231,231,231,231,231,231,231,231,231,231,231,120,232, -233,234,233,233,233,233,233,233,233,233,233,233,233,233,233,233, -233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233, +232,232,232,232,232,232,232,232,232,232,232,232,232,232,120,233, +234,235,234,234,234,234,234,234,234,234,234,234,234,234,234,234, 234,234,234,234,234,234,234,234,234,234,234,234,234,234,234,234, -234,234,234,234,234,234,234,234,234,234,234,120,120,233,233,233, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, +235,235,235,235,235,235,235,235,235,235,235,235,235,235,235,235, +235,235,235,235,235,235,235,235,235,235,235,120,120,234,234,234, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, /* block 15 */ -235,235,235,235,235,235,235,235,235,235,235,235,235,235,235,235, -235,235,235,235,235,235,235,235,235,235,235,235,235,235,235,235, -235,235,235,235,235,235,236,236,236,236,236,236,236,236,236,236, -236,235,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -237,237,237,237,237,237,237,237,237,237,238,238,238,238,238,238, -238,238,238,238,238,238,238,238,238,238,238,238,238,238,238,238, -238,238,238,238,238,238,238,238,238,238,238,239,239,239,239,239, -239,239,239,239,240,240,241,242,242,242,240,120,120,239,243,243, +236,236,236,236,236,236,236,236,236,236,236,236,236,236,236,236, +236,236,236,236,236,236,236,236,236,236,236,236,236,236,236,236, +236,236,236,236,236,236,237,237,237,237,237,237,237,237,237,237, +237,236,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +238,238,238,238,238,238,238,238,238,238,239,239,239,239,239,239, +239,239,239,239,239,239,239,239,239,239,239,239,239,239,239,239, +239,239,239,239,239,239,239,239,239,239,239,240,240,240,240,240, +240,240,240,240,241,241,242,243,243,243,241,120,120,240,244,244, /* block 16 */ -244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244, -244,244,244,244,244,244,245,245,245,245,246,245,245,245,245,245, -245,245,245,245,246,245,245,245,246,245,245,245,245,245,120,120, -247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,120, -248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248, -248,248,248,248,248,248,248,248,248,249,249,249,120,120,250,120, -233,233,233,233,233,233,233,233,233,233,233,120,120,120,120,120, -120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,245, +245,245,245,245,245,245,246,246,246,246,247,246,246,246,246,246, +246,246,246,246,247,246,246,246,247,246,246,246,246,246,120,120, +248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,120, +249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249, +249,249,249,249,249,249,249,249,249,250,250,250,120,120,251,120, +234,234,234,234,234,234,234,234,234,234,234,120,120,120,120,120, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, /* block 17 */ -120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,120,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,120,120,120,120,120,120,120,120, -120,120,120,222,222,222,222,222,222,222,222,222,222,222,222,222, +225,225,225,225,225,225,225,225,252,225,225,225,225,225,225,120, +215,215,120,120,120,120,120,120,222,222,222,222,222,222,222,222, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,230,222,222,222,222,222,222, +222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222, 222,222,216,222,222,222,222,222,222,222,222,222,222,222,222,222, 222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222, /* block 18 */ -251,251,251,252,253,253,253,253,253,253,253,253,253,253,253,253, -253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, -253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, -253,253,253,253,253,253,253,253,253,253,251,252,251,253,252,252, -252,251,251,251,251,251,251,251,251,252,252,252,252,251,252,252, -253,254,255,113,113,251,251,251,253,253,253,253,253,253,253,253, -253,253,251,251,256,257,258,258,258,258,258,258,258,258,258,258, -259,260,253,253,253,253,253,253,253,253,253,253,253,253,253,253, +253,253,253,254,255,255,255,255,255,255,255,255,255,255,255,255, +255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, +255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, +255,255,255,255,255,255,255,255,255,255,253,254,253,255,254,254, +254,253,253,253,253,253,253,253,253,254,254,254,254,253,254,254, +255,256,257,113,113,253,253,253,255,255,255,255,255,255,255,255, +255,255,253,253,258,259,260,260,260,260,260,260,260,260,260,260, +261,262,255,255,255,255,255,255,255,255,255,255,255,255,255,255, /* block 19 */ -261,262,263,263,120,261,261,261,261,261,261,261,261,120,120,261, -261,120,120,261,261,261,261,261,261,261,261,261,261,261,261,261, -261,261,261,261,261,261,261,261,261,120,261,261,261,261,261,261, -261,120,261,120,120,120,261,261,261,261,120,120,262,261,264,263, -263,262,262,262,262,120,120,263,263,120,120,263,263,262,261,120, -120,120,120,120,120,120,120,264,120,120,120,120,261,261,120,261, -261,261,262,262,120,120,265,265,265,265,265,265,265,265,265,265, -261,261,266,266,267,267,267,267,267,267,268,266,261,269,262,120, +263,264,265,265,120,263,263,263,263,263,263,263,263,120,120,263, +263,120,120,263,263,263,263,263,263,263,263,263,263,263,263,263, +263,263,263,263,263,263,263,263,263,120,263,263,263,263,263,263, +263,120,263,120,120,120,263,263,263,263,120,120,264,263,266,265, +265,264,264,264,264,120,120,265,265,120,120,265,265,264,263,120, +120,120,120,120,120,120,120,266,120,120,120,120,263,263,120,263, +263,263,264,264,120,120,267,267,267,267,267,267,267,267,267,267, +263,263,268,268,269,269,269,269,269,269,270,268,263,271,264,120, /* block 20 */ -120,270,270,271,120,272,272,272,272,272,272,120,120,120,120,272, -272,120,120,272,272,272,272,272,272,272,272,272,272,272,272,272, -272,272,272,272,272,272,272,272,272,120,272,272,272,272,272,272, -272,120,272,272,120,272,272,120,272,272,120,120,270,120,271,271, -271,270,270,120,120,120,120,270,270,120,120,270,270,270,120,120, -120,270,120,120,120,120,120,120,120,272,272,272,272,120,272,120, -120,120,120,120,120,120,273,273,273,273,273,273,273,273,273,273, -270,270,272,272,272,270,274,120,120,120,120,120,120,120,120,120, +120,272,272,273,120,274,274,274,274,274,274,120,120,120,120,274, +274,120,120,274,274,274,274,274,274,274,274,274,274,274,274,274, +274,274,274,274,274,274,274,274,274,120,274,274,274,274,274,274, +274,120,274,274,120,274,274,120,274,274,120,120,272,120,273,273, +273,272,272,120,120,120,120,272,272,120,120,272,272,272,120,120, +120,272,120,120,120,120,120,120,120,274,274,274,274,120,274,120, +120,120,120,120,120,120,275,275,275,275,275,275,275,275,275,275, +272,272,274,274,274,272,276,120,120,120,120,120,120,120,120,120, /* block 21 */ -120,275,275,276,120,277,277,277,277,277,277,277,277,277,120,277, -277,277,120,277,277,277,277,277,277,277,277,277,277,277,277,277, -277,277,277,277,277,277,277,277,277,120,277,277,277,277,277,277, -277,120,277,277,120,277,277,277,277,277,120,120,275,277,276,276, -276,275,275,275,275,275,120,275,275,276,120,276,276,275,120,120, -277,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -277,277,275,275,120,120,278,278,278,278,278,278,278,278,278,278, -279,280,120,120,120,120,120,120,120,277,275,275,275,275,275,275, +120,277,277,278,120,279,279,279,279,279,279,279,279,279,120,279, +279,279,120,279,279,279,279,279,279,279,279,279,279,279,279,279, +279,279,279,279,279,279,279,279,279,120,279,279,279,279,279,279, +279,120,279,279,120,279,279,279,279,279,120,120,277,279,278,278, +278,277,277,277,277,277,120,277,277,278,120,278,278,277,120,120, +279,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +279,279,277,277,120,120,280,280,280,280,280,280,280,280,280,280, +281,282,120,120,120,120,120,120,120,279,277,277,277,277,277,277, /* block 22 */ -120,281,282,282,120,283,283,283,283,283,283,283,283,120,120,283, -283,120,120,283,283,283,283,283,283,283,283,283,283,283,283,283, -283,283,283,283,283,283,283,283,283,120,283,283,283,283,283,283, -283,120,283,283,120,283,283,283,283,283,120,120,281,283,284,281, -282,281,281,281,281,120,120,282,282,120,120,282,282,281,120,120, -120,120,120,120,120,281,281,284,120,120,120,120,283,283,120,283, -283,283,281,281,120,120,285,285,285,285,285,285,285,285,285,285, -286,283,287,287,287,287,287,287,120,120,120,120,120,120,120,120, +120,283,284,284,120,285,285,285,285,285,285,285,285,120,120,285, +285,120,120,285,285,285,285,285,285,285,285,285,285,285,285,285, +285,285,285,285,285,285,285,285,285,120,285,285,285,285,285,285, +285,120,285,285,120,285,285,285,285,285,120,120,283,285,286,283, +284,283,283,283,283,120,120,284,284,120,120,284,284,283,120,120, +120,120,120,120,120,283,283,286,120,120,120,120,285,285,120,285, +285,285,283,283,120,120,287,287,287,287,287,287,287,287,287,287, +288,285,289,289,289,289,289,289,120,120,120,120,120,120,120,120, /* block 23 */ -120,120,288,289,120,289,289,289,289,289,289,120,120,120,289,289, -289,120,289,289,289,289,120,120,120,289,289,120,289,120,289,289, -120,120,120,289,289,120,120,120,289,289,289,120,120,120,289,289, -289,289,289,289,289,289,289,289,289,289,120,120,120,120,290,291, -288,291,291,120,120,120,291,291,291,120,291,291,291,288,120,120, -289,120,120,120,120,120,120,290,120,120,120,120,120,120,120,120, -120,120,120,120,120,120,292,292,292,292,292,292,292,292,292,292, -293,293,293,294,295,295,295,295,295,296,295,120,120,120,120,120, +120,120,290,291,120,291,291,291,291,291,291,120,120,120,291,291, +291,120,291,291,291,291,120,120,120,291,291,120,291,120,291,291, +120,120,120,291,291,120,120,120,291,291,291,120,120,120,291,291, +291,291,291,291,291,291,291,291,291,291,120,120,120,120,292,293, +290,293,293,120,120,120,293,293,293,120,293,293,293,290,120,120, +291,120,120,120,120,120,120,292,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,294,294,294,294,294,294,294,294,294,294, +295,295,295,296,297,297,297,297,297,298,297,120,120,120,120,120, /* block 24 */ -297,298,298,298,297,299,299,299,299,299,299,299,299,120,299,299, -299,120,299,299,299,299,299,299,299,299,299,299,299,299,299,299, -299,299,299,299,299,299,299,299,299,120,299,299,299,299,299,299, -299,299,299,299,299,299,299,299,299,299,120,120,120,299,297,297, -297,298,298,298,298,120,297,297,297,120,297,297,297,297,120,120, -120,120,120,120,120,297,297,120,299,299,299,120,120,120,120,120, -299,299,297,297,120,120,300,300,300,300,300,300,300,300,300,300, -120,120,120,120,120,120,120,301,302,302,302,302,302,302,302,303, +299,300,300,300,299,301,301,301,301,301,301,301,301,120,301,301, +301,120,301,301,301,301,301,301,301,301,301,301,301,301,301,301, +301,301,301,301,301,301,301,301,301,120,301,301,301,301,301,301, +301,301,301,301,301,301,301,301,301,301,120,120,299,301,299,299, +299,300,300,300,300,120,299,299,299,120,299,299,299,299,120,120, +120,120,120,120,120,299,299,120,301,301,301,120,120,301,120,120, +301,301,299,299,120,120,302,302,302,302,302,302,302,302,302,302, +120,120,120,120,120,120,120,303,304,304,304,304,304,304,304,305, /* block 25 */ -304,305,306,306,307,304,304,304,304,304,304,304,304,120,304,304, -304,120,304,304,304,304,304,304,304,304,304,304,304,304,304,304, -304,304,304,304,304,304,304,304,304,120,304,304,304,304,304,304, -304,304,304,304,120,304,304,304,304,304,120,120,305,304,306,305, -306,306,308,306,306,120,305,306,306,120,306,306,305,305,120,120, -120,120,120,120,120,308,308,120,120,120,120,120,120,120,304,120, -304,304,305,305,120,120,309,309,309,309,309,309,309,309,309,309, -120,304,304,120,120,120,120,120,120,120,120,120,120,120,120,120, +306,307,308,308,309,306,306,306,306,306,306,306,306,120,306,306, +306,120,306,306,306,306,306,306,306,306,306,306,306,306,306,306, +306,306,306,306,306,306,306,306,306,120,306,306,306,306,306,306, +306,306,306,306,120,306,306,306,306,306,120,120,307,306,308,307, +308,308,310,308,308,120,307,308,308,120,308,308,307,307,120,120, +120,120,120,120,120,310,310,120,120,120,120,120,120,306,306,120, +306,306,307,307,120,120,311,311,311,311,311,311,311,311,311,311, +120,306,306,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 26 */ -310,310,311,311,312,312,312,312,312,312,312,312,312,120,312,312, -312,120,312,312,312,312,312,312,312,312,312,312,312,312,312,312, -312,312,312,312,312,312,312,312,312,312,312,312,312,312,312,312, -312,312,312,312,312,312,312,312,312,312,312,310,310,312,313,311, -311,310,310,310,310,120,311,311,311,120,311,311,311,310,314,315, -120,120,120,120,312,312,312,313,316,316,316,316,316,316,316,312, -312,312,310,310,120,120,317,317,317,317,317,317,317,317,317,317, -316,316,316,316,316,316,316,316,316,315,312,312,312,312,312,312, +312,312,313,313,314,314,314,314,314,314,314,314,314,120,314,314, +314,120,314,314,314,314,314,314,314,314,314,314,314,314,314,314, +314,314,314,314,314,314,314,314,314,314,314,314,314,314,314,314, +314,314,314,314,314,314,314,314,314,314,314,312,312,314,315,313, +313,312,312,312,312,120,313,313,313,120,313,313,313,312,316,317, +120,120,120,120,314,314,314,315,318,318,318,318,318,318,318,314, +314,314,312,312,120,120,319,319,319,319,319,319,319,319,319,319, +318,318,318,318,318,318,318,318,318,317,314,314,314,314,314,314, /* block 27 */ -120,318,319,319,120,320,320,320,320,320,320,320,320,320,320,320, -320,320,320,320,320,320,320,120,120,120,320,320,320,320,320,320, -320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320, -320,320,120,320,320,320,320,320,320,320,320,320,120,320,120,120, -320,320,320,320,320,320,320,120,120,120,318,120,120,120,120,321, -319,319,318,318,318,120,318,120,319,319,319,319,319,319,319,321, -120,120,120,120,120,120,322,322,322,322,322,322,322,322,322,322, -120,120,319,319,323,120,120,120,120,120,120,120,120,120,120,120, +120,320,321,321,120,322,322,322,322,322,322,322,322,322,322,322, +322,322,322,322,322,322,322,120,120,120,322,322,322,322,322,322, +322,322,322,322,322,322,322,322,322,322,322,322,322,322,322,322, +322,322,120,322,322,322,322,322,322,322,322,322,120,322,120,120, +322,322,322,322,322,322,322,120,120,120,320,120,120,120,120,323, +321,321,320,320,320,120,320,120,321,321,321,321,321,321,321,323, +120,120,120,120,120,120,324,324,324,324,324,324,324,324,324,324, +120,120,321,321,325,120,120,120,120,120,120,120,120,120,120,120, /* block 28 */ -120,324,324,324,324,324,324,324,324,324,324,324,324,324,324,324, -324,324,324,324,324,324,324,324,324,324,324,324,324,324,324,324, -324,324,324,324,324,324,324,324,324,324,324,324,324,324,324,324, -324,325,324,326,325,325,325,325,325,325,325,120,120,120,120, 6, -324,324,324,324,324,324,327,325,325,325,325,325,325,325,325,328, -329,329,329,329,329,329,329,329,329,329,328,328,120,120,120,120, +120,326,326,326,326,326,326,326,326,326,326,326,326,326,326,326, +326,326,326,326,326,326,326,326,326,326,326,326,326,326,326,326, +326,326,326,326,326,326,326,326,326,326,326,326,326,326,326,326, +326,327,326,328,327,327,327,327,327,327,327,120,120,120,120, 6, +326,326,326,326,326,326,329,327,327,327,327,327,327,327,327,330, +331,331,331,331,331,331,331,331,331,331,330,330,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 29 */ -120,330,330,120,330,120,330,330,330,330,330,120,330,330,330,330, -330,330,330,330,330,330,330,330,330,330,330,330,330,330,330,330, -330,330,330,330,120,330,120,330,330,330,330,330,330,330,330,330, -330,331,330,332,331,331,331,331,331,331,331,331,331,330,120,120, -330,330,330,330,330,120,333,120,331,331,331,331,331,331,120,120, -334,334,334,334,334,334,334,334,334,334,120,120,330,330,330,330, +120,332,332,120,332,120,332,332,332,332,332,120,332,332,332,332, +332,332,332,332,332,332,332,332,332,332,332,332,332,332,332,332, +332,332,332,332,120,332,120,332,332,332,332,332,332,332,332,332, +332,333,332,334,333,333,333,333,333,333,333,333,333,332,120,120, +332,332,332,332,332,120,335,120,333,333,333,333,333,333,120,120, +336,336,336,336,336,336,336,336,336,336,120,120,332,332,332,332, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 30 */ -335,336,336,336,337,337,337,337,337,337,337,337,337,337,337,337, -337,337,337,336,337,336,336,336,338,338,336,336,336,336,336,336, -339,339,339,339,339,339,339,339,339,339,340,340,340,340,340,340, -340,340,340,340,336,338,336,338,336,338,341,342,341,342,343,343, -335,335,335,335,335,335,335,335,120,335,335,335,335,335,335,335, -335,335,335,335,335,335,335,335,335,335,335,335,335,335,335,335, -335,335,335,335,335,335,335,335,335,335,335,335,335,120,120,120, -120,338,338,338,338,338,338,338,338,338,338,338,338,338,338,343, +337,338,338,338,339,339,339,339,339,339,339,339,339,339,339,339, +339,339,339,338,339,338,338,338,340,340,338,338,338,338,338,338, +341,341,341,341,341,341,341,341,341,341,342,342,342,342,342,342, +342,342,342,342,338,340,338,340,338,340,343,344,343,344,345,345, +337,337,337,337,337,337,337,337,120,337,337,337,337,337,337,337, +337,337,337,337,337,337,337,337,337,337,337,337,337,337,337,337, +337,337,337,337,337,337,337,337,337,337,337,337,337,120,120,120, +120,340,340,340,340,340,340,340,340,340,340,340,340,340,340,345, /* block 31 */ -338,338,338,338,338,337,338,338,335,335,335,335,335,338,338,338, -338,338,338,338,338,338,338,338,120,338,338,338,338,338,338,338, -338,338,338,338,338,338,338,338,338,338,338,338,338,338,338,338, -338,338,338,338,338,338,338,338,338,338,338,338,338,120,336,336, -336,336,336,336,336,336,338,336,336,336,336,336,336,120,336,336, -337,337,337,337,337, 20, 20, 20, 20,337,337,120,120,120,120,120, +340,340,340,340,340,339,340,340,337,337,337,337,337,340,340,340, +340,340,340,340,340,340,340,340,120,340,340,340,340,340,340,340, +340,340,340,340,340,340,340,340,340,340,340,340,340,340,340,340, +340,340,340,340,340,340,340,340,340,340,340,340,340,120,338,338, +338,338,338,338,338,338,340,338,338,338,338,338,338,120,338,338, +339,339,339,339,339, 20, 20, 20, 20,339,339,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 32 */ -344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344, -344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344, -344,344,344,344,344,344,344,344,344,344,344,345,345,346,346,346, -346,347,346,346,346,346,346,346,345,346,346,347,347,346,346,344, -348,348,348,348,348,348,348,348,348,348,349,349,349,349,349,349, -344,344,344,344,344,344,347,347,346,346,344,344,344,344,346,346, -346,344,345,345,345,344,344,345,345,345,345,345,345,345,344,344, -344,346,346,346,346,344,344,344,344,344,344,344,344,344,344,344, +346,346,346,346,346,346,346,346,346,346,346,346,346,346,346,346, +346,346,346,346,346,346,346,346,346,346,346,346,346,346,346,346, +346,346,346,346,346,346,346,346,346,346,346,347,347,348,348,348, +348,349,348,348,348,348,348,348,347,348,348,349,349,348,348,346, +350,350,350,350,350,350,350,350,350,350,351,351,351,351,351,351, +346,346,346,346,346,346,349,349,348,348,346,346,346,346,348,348, +348,346,347,347,347,346,346,347,347,347,347,347,347,347,346,346, +346,348,348,348,348,346,346,346,346,346,346,346,346,346,346,346, /* block 33 */ -344,344,346,345,347,346,346,345,345,345,345,345,345,346,344,345, -350,350,350,350,350,350,350,350,350,350,345,345,345,346,351,351, -352,352,352,352,352,352,352,352,352,352,352,352,352,352,352,352, -352,352,352,352,352,352,352,352,352,352,352,352,352,352,352,352, -352,352,352,352,352,352,120,352,120,120,120,120,120,352,120,120, -353,353,353,353,353,353,353,353,353,353,353,353,353,353,353,353, -353,353,353,353,353,353,353,353,353,353,353,353,353,353,353,353, -353,353,353,353,353,353,353,353,353,353,353,354,355,353,353,353, +346,346,348,347,349,348,348,347,347,347,347,347,347,348,346,347, +352,352,352,352,352,352,352,352,352,352,347,347,347,348,353,353, +354,354,354,354,354,354,354,354,354,354,354,354,354,354,354,354, +354,354,354,354,354,354,354,354,354,354,354,354,354,354,354,354, +354,354,354,354,354,354,120,354,120,120,120,120,120,354,120,120, +355,355,355,355,355,355,355,355,355,355,355,355,355,355,355,355, +355,355,355,355,355,355,355,355,355,355,355,355,355,355,355,355, +355,355,355,355,355,355,355,355,355,355,355,356,357,355,355,355, /* block 34 */ -356,356,356,356,356,356,356,356,356,356,356,356,356,356,356,356, -356,356,356,356,356,356,356,356,356,356,356,356,356,356,356,356, -356,356,356,356,356,356,356,356,356,356,356,356,356,356,356,356, -356,356,356,356,356,356,356,356,356,356,356,356,356,356,356,356, -356,356,356,356,356,356,356,356,356,356,356,356,356,356,356,356, -356,356,356,356,356,356,356,356,356,356,356,356,356,356,356,356, -357,357,357,357,357,357,357,357,357,357,357,357,357,357,357,357, -357,357,357,357,357,357,357,357,357,357,357,357,357,357,357,357, - -/* block 35 */ -357,357,357,357,357,357,357,357,357,357,357,357,357,357,357,357, -357,357,357,357,357,357,357,357,357,357,357,357,357,357,357,357, -357,357,357,357,357,357,357,357,358,358,358,358,358,358,358,358, 358,358,358,358,358,358,358,358,358,358,358,358,358,358,358,358, 358,358,358,358,358,358,358,358,358,358,358,358,358,358,358,358, 358,358,358,358,358,358,358,358,358,358,358,358,358,358,358,358, 358,358,358,358,358,358,358,358,358,358,358,358,358,358,358,358, 358,358,358,358,358,358,358,358,358,358,358,358,358,358,358,358, - -/* block 36 */ -359,359,359,359,359,359,359,359,359,359,359,359,359,359,359,359, -359,359,359,359,359,359,359,359,359,359,359,359,359,359,359,359, +358,358,358,358,358,358,358,358,358,358,358,358,358,358,358,358, 359,359,359,359,359,359,359,359,359,359,359,359,359,359,359,359, 359,359,359,359,359,359,359,359,359,359,359,359,359,359,359,359, -359,359,359,359,359,359,359,359,359,120,359,359,359,359,120,120, -359,359,359,359,359,359,359,120,359,120,359,359,359,359,120,120, + +/* block 35 */ 359,359,359,359,359,359,359,359,359,359,359,359,359,359,359,359, 359,359,359,359,359,359,359,359,359,359,359,359,359,359,359,359, +359,359,359,359,359,359,359,359,360,360,360,360,360,360,360,360, +360,360,360,360,360,360,360,360,360,360,360,360,360,360,360,360, +360,360,360,360,360,360,360,360,360,360,360,360,360,360,360,360, +360,360,360,360,360,360,360,360,360,360,360,360,360,360,360,360, +360,360,360,360,360,360,360,360,360,360,360,360,360,360,360,360, +360,360,360,360,360,360,360,360,360,360,360,360,360,360,360,360, + +/* block 36 */ +361,361,361,361,361,361,361,361,361,361,361,361,361,361,361,361, +361,361,361,361,361,361,361,361,361,361,361,361,361,361,361,361, +361,361,361,361,361,361,361,361,361,361,361,361,361,361,361,361, +361,361,361,361,361,361,361,361,361,361,361,361,361,361,361,361, +361,361,361,361,361,361,361,361,361,120,361,361,361,361,120,120, +361,361,361,361,361,361,361,120,361,120,361,361,361,361,120,120, +361,361,361,361,361,361,361,361,361,361,361,361,361,361,361,361, +361,361,361,361,361,361,361,361,361,361,361,361,361,361,361,361, /* block 37 */ -359,359,359,359,359,359,359,359,359,120,359,359,359,359,120,120, -359,359,359,359,359,359,359,359,359,359,359,359,359,359,359,359, -359,359,359,359,359,359,359,359,359,359,359,359,359,359,359,359, -359,120,359,359,359,359,120,120,359,359,359,359,359,359,359,120, -359,120,359,359,359,359,120,120,359,359,359,359,359,359,359,359, -359,359,359,359,359,359,359,120,359,359,359,359,359,359,359,359, -359,359,359,359,359,359,359,359,359,359,359,359,359,359,359,359, -359,359,359,359,359,359,359,359,359,359,359,359,359,359,359,359, +361,361,361,361,361,361,361,361,361,120,361,361,361,361,120,120, +361,361,361,361,361,361,361,361,361,361,361,361,361,361,361,361, +361,361,361,361,361,361,361,361,361,361,361,361,361,361,361,361, +361,120,361,361,361,361,120,120,361,361,361,361,361,361,361,120, +361,120,361,361,361,361,120,120,361,361,361,361,361,361,361,361, +361,361,361,361,361,361,361,120,361,361,361,361,361,361,361,361, +361,361,361,361,361,361,361,361,361,361,361,361,361,361,361,361, +361,361,361,361,361,361,361,361,361,361,361,361,361,361,361,361, /* block 38 */ -359,359,359,359,359,359,359,359,359,359,359,359,359,359,359,359, -359,120,359,359,359,359,120,120,359,359,359,359,359,359,359,359, -359,359,359,359,359,359,359,359,359,359,359,359,359,359,359,359, -359,359,359,359,359,359,359,359,359,359,359,359,359,359,359,359, -359,359,359,359,359,359,359,359,359,359,359,359,359,359,359,359, -359,359,359,359,359,359,359,359,359,359,359,120,120,360,360,360, -361,361,361,361,361,361,361,361,361,362,362,362,362,362,362,362, -362,362,362,362,362,362,362,362,362,362,362,362,362,120,120,120, +361,361,361,361,361,361,361,361,361,361,361,361,361,361,361,361, +361,120,361,361,361,361,120,120,361,361,361,361,361,361,361,361, +361,361,361,361,361,361,361,361,361,361,361,361,361,361,361,361, +361,361,361,361,361,361,361,361,361,361,361,361,361,361,361,361, +361,361,361,361,361,361,361,361,361,361,361,361,361,361,361,361, +361,361,361,361,361,361,361,361,361,361,361,120,120,362,362,362, +363,363,363,363,363,363,363,363,363,364,364,364,364,364,364,364, +364,364,364,364,364,364,364,364,364,364,364,364,364,120,120,120, /* block 39 */ -359,359,359,359,359,359,359,359,359,359,359,359,359,359,359,359, -363,363,363,363,363,363,363,363,363,363,120,120,120,120,120,120, -364,364,364,364,364,364,364,364,364,364,364,364,364,364,364,364, -364,364,364,364,364,364,364,364,364,364,364,364,364,364,364,364, -364,364,364,364,364,364,364,364,364,364,364,364,364,364,364,364, -364,364,364,364,364,364,364,364,364,364,364,364,364,364,364,364, -364,364,364,364,364,364,364,364,364,364,364,364,364,364,364,364, -365,365,365,365,365,365,120,120,366,366,366,366,366,366,120,120, +361,361,361,361,361,361,361,361,361,361,361,361,361,361,361,361, +365,365,365,365,365,365,365,365,365,365,120,120,120,120,120,120, +366,366,366,366,366,366,366,366,366,366,366,366,366,366,366,366, +366,366,366,366,366,366,366,366,366,366,366,366,366,366,366,366, +366,366,366,366,366,366,366,366,366,366,366,366,366,366,366,366, +366,366,366,366,366,366,366,366,366,366,366,366,366,366,366,366, +366,366,366,366,366,366,366,366,366,366,366,366,366,366,366,366, +367,367,367,367,367,367,120,120,368,368,368,368,368,368,120,120, /* block 40 */ -367,368,368,368,368,368,368,368,368,368,368,368,368,368,368,368, -368,368,368,368,368,368,368,368,368,368,368,368,368,368,368,368, -368,368,368,368,368,368,368,368,368,368,368,368,368,368,368,368, -368,368,368,368,368,368,368,368,368,368,368,368,368,368,368,368, -368,368,368,368,368,368,368,368,368,368,368,368,368,368,368,368, -368,368,368,368,368,368,368,368,368,368,368,368,368,368,368,368, -368,368,368,368,368,368,368,368,368,368,368,368,368,368,368,368, -368,368,368,368,368,368,368,368,368,368,368,368,368,368,368,368, +369,370,370,370,370,370,370,370,370,370,370,370,370,370,370,370, +370,370,370,370,370,370,370,370,370,370,370,370,370,370,370,370, +370,370,370,370,370,370,370,370,370,370,370,370,370,370,370,370, +370,370,370,370,370,370,370,370,370,370,370,370,370,370,370,370, +370,370,370,370,370,370,370,370,370,370,370,370,370,370,370,370, +370,370,370,370,370,370,370,370,370,370,370,370,370,370,370,370, +370,370,370,370,370,370,370,370,370,370,370,370,370,370,370,370, +370,370,370,370,370,370,370,370,370,370,370,370,370,370,370,370, /* block 41 */ -368,368,368,368,368,368,368,368,368,368,368,368,368,368,368,368, -368,368,368,368,368,368,368,368,368,368,368,368,368,368,368,368, -368,368,368,368,368,368,368,368,368,368,368,368,368,368,368,368, -368,368,368,368,368,368,368,368,368,368,368,368,368,368,368,368, -368,368,368,368,368,368,368,368,368,368,368,368,368,368,368,368, -368,368,368,368,368,368,368,368,368,368,368,368,368,368,368,368, -368,368,368,368,368,368,368,368,368,368,368,368,368,368,368,368, -368,368,368,368,368,368,368,368,368,368,368,368,368,368,368,368, +370,370,370,370,370,370,370,370,370,370,370,370,370,370,370,370, +370,370,370,370,370,370,370,370,370,370,370,370,370,370,370,370, +370,370,370,370,370,370,370,370,370,370,370,370,370,370,370,370, +370,370,370,370,370,370,370,370,370,370,370,370,370,370,370,370, +370,370,370,370,370,370,370,370,370,370,370,370,370,370,370,370, +370,370,370,370,370,370,370,370,370,370,370,370,370,370,370,370, +370,370,370,370,370,370,370,370,370,370,370,370,370,370,370,370, +370,370,370,370,370,370,370,370,370,370,370,370,370,370,370,370, /* block 42 */ -368,368,368,368,368,368,368,368,368,368,368,368,368,368,368,368, -368,368,368,368,368,368,368,368,368,368,368,368,368,368,368,368, -368,368,368,368,368,368,368,368,368,368,368,368,368,368,368,368, -368,368,368,368,368,368,368,368,368,368,368,368,368,368,368,368, -368,368,368,368,368,368,368,368,368,368,368,368,368,368,368,368, -368,368,368,368,368,368,368,368,368,368,368,368,368,368,368,368, -368,368,368,368,368,368,368,368,368,368,368,368,368,369,370,368, -368,368,368,368,368,368,368,368,368,368,368,368,368,368,368,368, +370,370,370,370,370,370,370,370,370,370,370,370,370,370,370,370, +370,370,370,370,370,370,370,370,370,370,370,370,370,370,370,370, +370,370,370,370,370,370,370,370,370,370,370,370,370,370,370,370, +370,370,370,370,370,370,370,370,370,370,370,370,370,370,370,370, +370,370,370,370,370,370,370,370,370,370,370,370,370,370,370,370, +370,370,370,370,370,370,370,370,370,370,370,370,370,370,370,370, +370,370,370,370,370,370,370,370,370,370,370,370,370,371,372,370, +370,370,370,370,370,370,370,370,370,370,370,370,370,370,370,370, /* block 43 */ -371,372,372,372,372,372,372,372,372,372,372,372,372,372,372,372, -372,372,372,372,372,372,372,372,372,372,372,373,374,120,120,120, -375,375,375,375,375,375,375,375,375,375,375,375,375,375,375,375, -375,375,375,375,375,375,375,375,375,375,375,375,375,375,375,375, -375,375,375,375,375,375,375,375,375,375,375,375,375,375,375,375, -375,375,375,375,375,375,375,375,375,375,375,375,375,375,375,375, -375,375,375,375,375,375,375,375,375,375,375, 5, 5, 5,376,376, -376,375,375,375,375,375,375,375,375,120,120,120,120,120,120,120, +373,374,374,374,374,374,374,374,374,374,374,374,374,374,374,374, +374,374,374,374,374,374,374,374,374,374,374,375,376,120,120,120, +377,377,377,377,377,377,377,377,377,377,377,377,377,377,377,377, +377,377,377,377,377,377,377,377,377,377,377,377,377,377,377,377, +377,377,377,377,377,377,377,377,377,377,377,377,377,377,377,377, +377,377,377,377,377,377,377,377,377,377,377,377,377,377,377,377, +377,377,377,377,377,377,377,377,377,377,377, 5, 5, 5,378,378, +378,377,377,377,377,377,377,377,377,120,120,120,120,120,120,120, /* block 44 */ -377,377,377,377,377,377,377,377,377,377,377,377,377,120,377,377, -377,377,378,378,378,120,120,120,120,120,120,120,120,120,120,120, 379,379,379,379,379,379,379,379,379,379,379,379,379,379,379,379, -379,379,380,380,380,381,381,120,120,120,120,120,120,120,120,120, +379,379,380,380,380,381,120,120,120,120,120,120,120,120,120,379, 382,382,382,382,382,382,382,382,382,382,382,382,382,382,382,382, -382,382,383,383,120,120,120,120,120,120,120,120,120,120,120,120, -384,384,384,384,384,384,384,384,384,384,384,384,384,120,384,384, -384,120,385,385,120,120,120,120,120,120,120,120,120,120,120,120, +382,382,383,383,384,385,385,120,120,120,120,120,120,120,120,120, +386,386,386,386,386,386,386,386,386,386,386,386,386,386,386,386, +386,386,387,387,120,120,120,120,120,120,120,120,120,120,120,120, +388,388,388,388,388,388,388,388,388,388,388,388,388,120,388,388, +388,120,389,389,120,120,120,120,120,120,120,120,120,120,120,120, /* block 45 */ -386,386,386,386,386,386,386,386,386,386,386,386,386,386,386,386, -386,386,386,386,386,386,386,386,386,386,386,386,386,386,386,386, -386,386,386,386,386,386,386,386,386,386,386,386,386,386,386,386, -386,386,386,386,387,387,388,387,387,387,387,387,387,387,388,388, -388,388,388,388,388,388,387,388,388,387,387,387,387,387,387,387, -387,387,387,387,389,389,389,390,389,389,389,391,386,387,120,120, -392,392,392,392,392,392,392,392,392,392,120,120,120,120,120,120, -393,393,393,393,393,393,393,393,393,393,120,120,120,120,120,120, +390,390,390,390,390,390,390,390,390,390,390,390,390,390,390,390, +390,390,390,390,390,390,390,390,390,390,390,390,390,390,390,390, +390,390,390,390,390,390,390,390,390,390,390,390,390,390,390,390, +390,390,390,390,391,391,392,391,391,391,391,391,391,391,392,392, +392,392,392,392,392,392,391,392,392,391,391,391,391,391,391,391, +391,391,391,391,393,393,393,394,393,393,393,395,390,391,120,120, +396,396,396,396,396,396,396,396,396,396,120,120,120,120,120,120, +397,397,397,397,397,397,397,397,397,397,120,120,120,120,120,120, /* block 46 */ -394,394,395,395,394,395,396,394,394,394,394,397,397,397,398,120, -399,399,399,399,399,399,399,399,399,399,120,120,120,120,120,120, -400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400, -400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400, -400,400,400,401,400,400,400,400,400,400,400,400,400,400,400,400, -400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400, -400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400, -400,400,400,400,400,400,400,400,400,120,120,120,120,120,120,120, +398,398,399,399,398,399,400,398,398,398,398,401,401,401,402,401, +403,403,403,403,403,403,403,403,403,403,120,120,120,120,120,120, +404,404,404,404,404,404,404,404,404,404,404,404,404,404,404,404, +404,404,404,404,404,404,404,404,404,404,404,404,404,404,404,404, +404,404,404,405,404,404,404,404,404,404,404,404,404,404,404,404, +404,404,404,404,404,404,404,404,404,404,404,404,404,404,404,404, +404,404,404,404,404,404,404,404,404,404,404,404,404,404,404,404, +404,404,404,404,404,404,404,404,404,120,120,120,120,120,120,120, /* block 47 */ -400,400,400,400,400,397,397,400,400,400,400,400,400,400,400,400, -400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400, -400,400,400,400,400,400,400,400,400,397,400,120,120,120,120,120, -368,368,368,368,368,368,368,368,368,368,368,368,368,368,368,368, -368,368,368,368,368,368,368,368,368,368,368,368,368,368,368,368, -368,368,368,368,368,368,368,368,368,368,368,368,368,368,368,368, -368,368,368,368,368,368,368,368,368,368,368,368,368,368,368,368, -368,368,368,368,368,368,120,120,120,120,120,120,120,120,120,120, +404,404,404,404,404,401,401,404,404,404,404,404,404,404,404,404, +404,404,404,404,404,404,404,404,404,404,404,404,404,404,404,404, +404,404,404,404,404,404,404,404,404,401,404,120,120,120,120,120, +370,370,370,370,370,370,370,370,370,370,370,370,370,370,370,370, +370,370,370,370,370,370,370,370,370,370,370,370,370,370,370,370, +370,370,370,370,370,370,370,370,370,370,370,370,370,370,370,370, +370,370,370,370,370,370,370,370,370,370,370,370,370,370,370,370, +370,370,370,370,370,370,120,120,120,120,120,120,120,120,120,120, /* block 48 */ -402,402,402,402,402,402,402,402,402,402,402,402,402,402,402,402, -402,402,402,402,402,402,402,402,402,402,402,402,402,402,402,120, -403,403,403,404,404,404,404,403,403,404,404,404,120,120,120,120, -404,404,403,404,404,404,404,404,404,403,403,403,120,120,120,120, -405,120,120,120,406,406,407,407,407,407,407,407,407,407,407,407, -408,408,408,408,408,408,408,408,408,408,408,408,408,408,408,408, -408,408,408,408,408,408,408,408,408,408,408,408,408,408,120,120, -408,408,408,408,408,120,120,120,120,120,120,120,120,120,120,120, +406,406,406,406,406,406,406,406,406,406,406,406,406,406,406,406, +406,406,406,406,406,406,406,406,406,406,406,406,406,406,406,120, +407,407,407,408,408,408,408,407,407,408,408,408,120,120,120,120, +408,408,407,408,408,408,408,408,408,407,407,407,120,120,120,120, +409,120,120,120,410,410,411,411,411,411,411,411,411,411,411,411, +412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412, +412,412,412,412,412,412,412,412,412,412,412,412,412,412,120,120, +412,412,412,412,412,120,120,120,120,120,120,120,120,120,120,120, /* block 49 */ -409,409,409,409,409,409,409,409,409,409,409,409,409,409,409,409, -409,409,409,409,409,409,409,409,409,409,409,409,409,409,409,409, -409,409,409,409,409,409,409,409,409,409,409,409,120,120,120,120, -409,409,409,409,409,409,409,409,409,409,409,409,409,409,409,409, -409,409,409,409,409,409,409,409,409,409,120,120,120,120,120,120, -410,410,410,410,410,410,410,410,410,410,411,120,120,120,412,412, 413,413,413,413,413,413,413,413,413,413,413,413,413,413,413,413, 413,413,413,413,413,413,413,413,413,413,413,413,413,413,413,413, +413,413,413,413,413,413,413,413,413,413,413,413,120,120,120,120, +413,413,413,413,413,413,413,413,413,413,413,413,413,413,413,413, +413,413,413,413,413,413,413,413,413,413,120,120,120,120,120,120, +414,414,414,414,414,414,414,414,414,414,415,120,120,120,416,416, +417,417,417,417,417,417,417,417,417,417,417,417,417,417,417,417, +417,417,417,417,417,417,417,417,417,417,417,417,417,417,417,417, /* block 50 */ -414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414, -414,414,414,414,414,414,414,415,415,416,416,415,120,120,417,417, -418,418,418,418,418,418,418,418,418,418,418,418,418,418,418,418, -418,418,418,418,418,418,418,418,418,418,418,418,418,418,418,418, 418,418,418,418,418,418,418,418,418,418,418,418,418,418,418,418, -418,418,418,418,418,419,420,419,420,420,420,420,420,420,420,120, -420,421,420,421,421,420,420,420,420,420,420,420,420,419,419,419, -419,419,419,420,420,420,420,420,420,420,420,420,420,120,120,420, +418,418,418,418,418,418,418,419,419,420,420,419,120,120,421,421, +422,422,422,422,422,422,422,422,422,422,422,422,422,422,422,422, +422,422,422,422,422,422,422,422,422,422,422,422,422,422,422,422, +422,422,422,422,422,422,422,422,422,422,422,422,422,422,422,422, +422,422,422,422,422,423,424,423,424,424,424,424,424,424,424,120, +424,425,424,425,425,424,424,424,424,424,424,424,424,423,423,423, +423,423,423,424,424,424,424,424,424,424,424,424,424,120,120,424, /* block 51 */ -422,422,422,422,422,422,422,422,422,422,120,120,120,120,120,120, -422,422,422,422,422,422,422,422,422,422,120,120,120,120,120,120, -423,423,423,423,423,423,423,424,423,423,423,423,423,423,120,120, -113,113,113,113,113,113,113,113,113,113,113,113,113,113,425,113, -113,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +426,426,426,426,426,426,426,426,426,426,120,120,120,120,120,120, +426,426,426,426,426,426,426,426,426,426,120,120,120,120,120,120, +427,427,427,427,427,427,427,428,427,427,427,427,427,427,120,120, +113,113,113,113,113,113,113,113,113,113,113,113,113,113,429,113, +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 52 */ -426,426,426,426,427,428,428,428,428,428,428,428,428,428,428,428, -428,428,428,428,428,428,428,428,428,428,428,428,428,428,428,428, -428,428,428,428,428,428,428,428,428,428,428,428,428,428,428,428, -428,428,428,428,426,429,426,426,426,426,426,427,426,427,427,427, -427,427,426,427,427,428,428,428,428,428,428,428,120,120,120,120, -430,430,430,430,430,430,430,430,430,430,431,431,431,431,431,431, -431,432,432,432,432,432,432,432,432,432,432,426,426,426,426,426, -426,426,426,426,432,432,432,432,432,432,432,432,432,120,120,120, +430,430,430,430,431,432,432,432,432,432,432,432,432,432,432,432, +432,432,432,432,432,432,432,432,432,432,432,432,432,432,432,432, +432,432,432,432,432,432,432,432,432,432,432,432,432,432,432,432, +432,432,432,432,430,433,430,430,430,430,430,431,430,431,431,431, +431,431,430,431,431,432,432,432,432,432,432,432,432,120,120,120, +434,434,434,434,434,434,434,434,434,434,435,435,435,435,435,435, +435,436,436,436,436,436,436,436,436,436,436,430,430,430,430,430, +430,430,430,430,436,436,436,436,436,436,436,436,436,435,435,120, /* block 53 */ -433,433,434,435,435,435,435,435,435,435,435,435,435,435,435,435, -435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435, -435,434,433,433,433,433,434,434,433,433,434,433,433,433,435,435, -436,436,436,436,436,436,436,436,436,436,435,435,435,435,435,435, -437,437,437,437,437,437,437,437,437,437,437,437,437,437,437,437, -437,437,437,437,437,437,437,437,437,437,437,437,437,437,437,437, -437,437,437,437,437,437,438,439,438,438,439,439,439,438,439,438, -438,438,439,439,120,120,120,120,120,120,120,120,440,440,440,440, - -/* block 54 */ +437,437,438,439,439,439,439,439,439,439,439,439,439,439,439,439, +439,439,439,439,439,439,439,439,439,439,439,439,439,439,439,439, +439,438,437,437,437,437,438,438,437,437,438,437,437,437,439,439, +440,440,440,440,440,440,440,440,440,440,439,439,439,439,439,439, 441,441,441,441,441,441,441,441,441,441,441,441,441,441,441,441, 441,441,441,441,441,441,441,441,441,441,441,441,441,441,441,441, -441,441,441,441,442,442,442,442,442,442,442,442,443,443,443,443, -443,443,443,443,442,442,443,443,120,120,120,444,444,444,444,444, -445,445,445,445,445,445,445,445,445,445,120,120,120,441,441,441, -446,446,446,446,446,446,446,446,446,446,447,447,447,447,447,447, -447,447,447,447,447,447,447,447,447,447,447,447,447,447,447,447, -447,447,447,447,447,447,447,447,448,448,448,448,448,448,449,449, +441,441,441,441,441,441,442,443,442,442,443,443,443,442,443,442, +442,442,443,443,120,120,120,120,120,120,120,120,444,444,444,444, + +/* block 54 */ +445,445,445,445,445,445,445,445,445,445,445,445,445,445,445,445, +445,445,445,445,445,445,445,445,445,445,445,445,445,445,445,445, +445,445,445,445,446,446,446,446,446,446,446,446,447,447,447,447, +447,447,447,447,446,446,447,447,120,120,120,448,448,448,448,448, +449,449,449,449,449,449,449,449,449,449,120,120,120,445,445,445, +450,450,450,450,450,450,450,450,450,450,451,451,451,451,451,451, +451,451,451,451,451,451,451,451,451,451,451,451,451,451,451,451, +451,451,451,451,451,451,451,451,452,452,452,452,452,452,453,453, /* block 55 */ -450,451,452,453,454,455,456,457,458,120,120,120,120,120,120,120, -459,459,459,459,459,459,459,459,459,459,459,459,459,459,459,459, -459,459,459,459,459,459,459,459,459,459,459,459,459,459,459,459, -459,459,459,459,459,459,459,459,459,459,459,120,120,459,459,459, -460,460,460,460,460,460,460,460,120,120,120,120,120,120,120,120, -461,462,461,463,462,464,464,465,464,465,466,462,465,465,462,462, -465,467,462,462,462,462,462,462,462,468,469,470,470,464,470,470, -470,470,471,472,473,469,469,474,475,475,476,120,120,120,120,120, +454,455,456,457,458,459,460,461,462,120,120,120,120,120,120,120, +463,463,463,463,463,463,463,463,463,463,463,463,463,463,463,463, +463,463,463,463,463,463,463,463,463,463,463,463,463,463,463,463, +463,463,463,463,463,463,463,463,463,463,463,120,120,463,463,463, +464,464,464,464,464,464,464,464,120,120,120,120,120,120,120,120, +465,466,465,467,466,468,468,469,468,469,470,466,469,469,466,466, +469,471,466,466,466,466,466,466,466,472,473,474,474,468,474,474, +474,474,475,476,477,473,473,478,479,479,480,120,120,120,120,120, /* block 56 */ 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, - 35, 35, 35, 35, 35, 35,128,128,128,128,128,477,110,110,110,110, + 35, 35, 35, 35, 35, 35,128,128,128,128,128,481,110,110,110,110, 110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, 110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, 110,110,110,110,110,110,110,110,110,110,110,110,110,121,121,121, 121,121,110,110,110,110,121,121,121,121,121, 35, 35, 35, 35, 35, - 35, 35, 35, 35, 35, 35, 35, 35,478,479, 35, 35, 35,480, 35, 35, + 35, 35, 35, 35, 35, 35, 35, 35,482,483, 35, 35, 35,484, 35, 35, /* block 57 */ - 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,481, 35, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,485, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,110,110,110,110,110, 110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, 110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,121, 114,114,113,113,113,113,113,113,113,113,113,113,113,113,113,113, 113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, 113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, -113,113,113,113,113,113,113,113,482,113,120,113,113,113,113,113, +113,113,113,113,113,113,113,113,486,113,487,113,113,113,113,113, /* block 58 */ 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, @@ -2305,12 +2331,12 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 71936 bytes, block = 128 */ 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, -483,484, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, +488,489, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, /* block 59 */ 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, - 32, 33, 32, 33, 32, 33, 35, 35, 35, 35, 35,485, 35, 35,486, 35, + 32, 33, 32, 33, 32, 33, 35, 35, 35, 35, 35,490, 35, 35,491, 35, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, @@ -2319,33 +2345,33 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 71936 bytes, block = 128 */ 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, /* block 60 */ -487,487,487,487,487,487,487,487,488,488,488,488,488,488,488,488, -487,487,487,487,487,487,120,120,488,488,488,488,488,488,120,120, -487,487,487,487,487,487,487,487,488,488,488,488,488,488,488,488, -487,487,487,487,487,487,487,487,488,488,488,488,488,488,488,488, -487,487,487,487,487,487,120,120,488,488,488,488,488,488,120,120, -128,487,128,487,128,487,128,487,120,488,120,488,120,488,120,488, -487,487,487,487,487,487,487,487,488,488,488,488,488,488,488,488, -489,489,490,490,490,490,491,491,492,492,493,493,494,494,120,120, +492,492,492,492,492,492,492,492,493,493,493,493,493,493,493,493, +492,492,492,492,492,492,120,120,493,493,493,493,493,493,120,120, +492,492,492,492,492,492,492,492,493,493,493,493,493,493,493,493, +492,492,492,492,492,492,492,492,493,493,493,493,493,493,493,493, +492,492,492,492,492,492,120,120,493,493,493,493,493,493,120,120, +128,492,128,492,128,492,128,492,120,493,120,493,120,493,120,493, +492,492,492,492,492,492,492,492,493,493,493,493,493,493,493,493, +494,494,495,495,495,495,496,496,497,497,498,498,499,499,120,120, /* block 61 */ -487,487,487,487,487,487,487,487,495,495,495,495,495,495,495,495, -487,487,487,487,487,487,487,487,495,495,495,495,495,495,495,495, -487,487,487,487,487,487,487,487,495,495,495,495,495,495,495,495, -487,487,128,496,128,120,128,128,488,488,497,497,498,119,499,119, -119,119,128,496,128,120,128,128,500,500,500,500,498,119,119,119, -487,487,128,128,120,120,128,128,488,488,501,501,120,119,119,119, -487,487,128,128,128,169,128,128,488,488,502,502,174,119,119,119, -120,120,128,496,128,120,128,128,503,503,504,504,498,119,119,120, +492,492,492,492,492,492,492,492,500,500,500,500,500,500,500,500, +492,492,492,492,492,492,492,492,500,500,500,500,500,500,500,500, +492,492,492,492,492,492,492,492,500,500,500,500,500,500,500,500, +492,492,128,501,128,120,128,128,493,493,502,502,503,119,504,119, +119,119,128,501,128,120,128,128,505,505,505,505,503,119,119,119, +492,492,128,128,120,120,128,128,493,493,506,506,120,119,119,119, +492,492,128,128,128,169,128,128,493,493,507,507,174,119,119,119, +120,120,128,501,128,120,128,128,508,508,509,509,503,119,119,120, /* block 62 */ - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 24,505,506, 24, 24, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 24,510,511, 24, 24, 10, 10, 10, 10, 10, 10, 5, 5, 23, 27, 7, 23, 23, 27, 7, 23, - 5, 5, 5, 5, 5, 5, 5, 5,507,508, 24, 24, 24, 24, 24,509, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 23, 27, 5,510, 5, 5, 16, - 16, 5, 5, 5, 9, 7, 8, 5, 5,510, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5,512,513, 24, 24, 24, 24, 24,514, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 23, 27, 5,515, 5, 5, 16, + 16, 5, 5, 5, 9, 7, 8, 5, 5,515, 5, 5, 5, 5, 5, 5, 5, 5, 9, 5, 16, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, - 24, 24, 24, 24, 24,511, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24,516, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25,110,120,120, 25, 25, 25, 25, 25, 25, 9, 9, 9, 7, 8,110, /* block 63 */ @@ -2353,24 +2379,24 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 71936 bytes, block = 128 */ 110,110,110,110,110,110,110,110,110,110,110,110,110,120,120,120, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, -120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -113,113,113,113,113,113,113,113,113,113,113,113,113,425,425,425, -425,113,425,425,425,113,113,113,113,113,113,113,113,113,113,113, -512,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, + 6,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +113,113,113,113,113,113,113,113,113,113,113,113,113,429,429,429, +429,113,429,429,429,113,113,113,113,113,113,113,113,113,113,113, +517,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 64 */ - 20, 20,513, 20, 20, 20, 20,513, 20, 20,514,513,513,513,514,514, -513,513,513,514, 20,513, 20, 20, 9,513,513,513,513,513, 20, 20, - 20, 20, 21, 20,513, 20,515, 20,513, 20,516,517,513,513, 20,514, -513,513,518,513,514,519,519,519,519,520, 20, 20,514,514,513,513, - 9, 9, 9, 9, 9,513,514,514,514,514, 20, 9, 20, 20,521, 20, + 20, 20,518, 20, 20, 20, 20,518, 20, 20,519,518,518,518,519,519, +518,518,518,519, 20,518, 20, 20, 9,518,518,518,518,518, 20, 20, + 20, 20, 21, 20,518, 20,520, 20,518, 20,521,522,518,518, 20,519, +518,518,523,518,519,524,524,524,524,525, 20, 20,519,519,518,518, + 9, 9, 9, 9, 9,518,519,519,519,519, 20, 9, 20, 20,526, 20, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, -522,522,522,522,522,522,522,522,522,522,522,522,522,522,522,522, -523,523,523,523,523,523,523,523,523,523,523,523,523,523,523,523, +527,527,527,527,527,527,527,527,527,527,527,527,527,527,527,527, +528,528,528,528,528,528,528,528,528,528,528,528,528,528,528,528, /* block 65 */ -524,524,524, 32, 33,524,524,524,524, 25, 20, 20,120,120,120,120, - 9, 9, 9, 9,525, 21, 21, 21, 21, 21, 9, 9, 20, 20, 20, 20, +529,529,529, 32, 33,529,529,529,529, 25, 20, 20,120,120,120,120, + 9, 9, 9, 9,530, 21, 21, 21, 21, 21, 9, 9, 20, 20, 20, 20, 9, 20, 20, 9, 20, 20, 9, 20, 20, 21, 21, 20, 20, 20, 9, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 9, 9, @@ -2422,10 +2448,10 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 71936 bytes, block = 128 */ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20,526,526,526,526,526,526,526,526,526,526, -526,526,527,526,526,526,526,526,526,526,526,526,526,526,526,526, -528,528,528,528,528,528,528,528,528,528,528,528,528,528,528,528, -528,528,528,528,528,528,528,528,528,528, 25, 25, 25, 25, 25, 25, + 20, 20, 20, 20, 20, 20,531,531,531,531,531,531,531,531,531,531, +531,531,532,531,531,531,531,531,531,531,531,531,531,531,531,531, +533,533,533,533,533,533,533,533,533,533,533,533,533,533,533,533, +533,533,533,533,533,533,533,533,533,533, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, /* block 71 */ @@ -2446,7 +2472,7 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 71936 bytes, block = 128 */ 21, 9, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 9, 9, 9,525,525,525,525, 9, + 20, 20, 20, 20, 20, 20, 20, 20, 9, 9, 9,530,530,530,530, 9, /* block 73 */ 21, 21, 21, 21, 21, 21, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, @@ -2455,7 +2481,7 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 71936 bytes, block = 128 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,525, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,530, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, /* block 74 */ @@ -2489,20 +2515,20 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 71936 bytes, block = 128 */ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, /* block 77 */ -529,529,529,529,529,529,529,529,529,529,529,529,529,529,529,529, -529,529,529,529,529,529,529,529,529,529,529,529,529,529,529,529, -529,529,529,529,529,529,529,529,529,529,529,529,529,529,529,529, -529,529,529,529,529,529,529,529,529,529,529,529,529,529,529,529, -529,529,529,529,529,529,529,529,529,529,529,529,529,529,529,529, -529,529,529,529,529,529,529,529,529,529,529,529,529,529,529,529, -529,529,529,529,529,529,529,529,529,529,529,529,529,529,529,529, -529,529,529,529,529,529,529,529,529,529,529,529,529,529,529,529, +534,534,534,534,534,534,534,534,534,534,534,534,534,534,534,534, +534,534,534,534,534,534,534,534,534,534,534,534,534,534,534,534, +534,534,534,534,534,534,534,534,534,534,534,534,534,534,534,534, +534,534,534,534,534,534,534,534,534,534,534,534,534,534,534,534, +534,534,534,534,534,534,534,534,534,534,534,534,534,534,534,534, +534,534,534,534,534,534,534,534,534,534,534,534,534,534,534,534, +534,534,534,534,534,534,534,534,534,534,534,534,534,534,534,534, +534,534,534,534,534,534,534,534,534,534,534,534,534,534,534,534, /* block 78 */ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9,525,525, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9,530,530, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, @@ -2539,14 +2565,14 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 71936 bytes, block = 128 */ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, /* block 82 */ -530,530,530,530,530,530,530,530,530,530,530,530,530,530,530,530, -530,530,530,530,530,530,530,530,530,530,530,530,530,530,530,530, -530,530,530,530,530,530,530,530,530,530,530,530,530,530,530,120, -531,531,531,531,531,531,531,531,531,531,531,531,531,531,531,531, -531,531,531,531,531,531,531,531,531,531,531,531,531,531,531,531, -531,531,531,531,531,531,531,531,531,531,531,531,531,531,531,120, - 32, 33,532,533,534,535,536, 32, 33, 32, 33, 32, 33,537,538,539, -540, 35, 32, 33, 35, 32, 33, 35, 35, 35, 35, 35,110,110,541,541, +535,535,535,535,535,535,535,535,535,535,535,535,535,535,535,535, +535,535,535,535,535,535,535,535,535,535,535,535,535,535,535,535, +535,535,535,535,535,535,535,535,535,535,535,535,535,535,535,535, +536,536,536,536,536,536,536,536,536,536,536,536,536,536,536,536, +536,536,536,536,536,536,536,536,536,536,536,536,536,536,536,536, +536,536,536,536,536,536,536,536,536,536,536,536,536,536,536,536, + 32, 33,537,538,539,540,541, 32, 33, 32, 33, 32, 33,542,543,544, +545, 35, 32, 33, 35, 32, 33, 35, 35, 35, 35, 35,110,110,546,546, /* block 83 */ 165,166,165,166,165,166,165,166,165,166,165,166,165,166,165,166, @@ -2555,138 +2581,138 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 71936 bytes, block = 128 */ 165,166,165,166,165,166,165,166,165,166,165,166,165,166,165,166, 165,166,165,166,165,166,165,166,165,166,165,166,165,166,165,166, 165,166,165,166,165,166,165,166,165,166,165,166,165,166,165,166, -165,166,165,166,542,543,543,543,543,543,543,165,166,165,166,544, -544,544,165,166,120,120,120,120,120,545,545,545,545,546,545,545, +165,166,165,166,547,548,548,548,548,548,548,165,166,165,166,549, +549,549,165,166,120,120,120,120,120,550,550,550,550,551,550,550, /* block 84 */ -547,547,547,547,547,547,547,547,547,547,547,547,547,547,547,547, -547,547,547,547,547,547,547,547,547,547,547,547,547,547,547,547, -547,547,547,547,547,547,120,547,120,120,120,120,120,547,120,120, -548,548,548,548,548,548,548,548,548,548,548,548,548,548,548,548, -548,548,548,548,548,548,548,548,548,548,548,548,548,548,548,548, -548,548,548,548,548,548,548,548,548,548,548,548,548,548,548,548, -548,548,548,548,548,548,548,548,120,120,120,120,120,120,120,549, -550,120,120,120,120,120,120,120,120,120,120,120,120,120,120,551, - -/* block 85 */ -359,359,359,359,359,359,359,359,359,359,359,359,359,359,359,359, -359,359,359,359,359,359,359,120,120,120,120,120,120,120,120,120, -359,359,359,359,359,359,359,120,359,359,359,359,359,359,359,120, -359,359,359,359,359,359,359,120,359,359,359,359,359,359,359,120, -359,359,359,359,359,359,359,120,359,359,359,359,359,359,359,120, -359,359,359,359,359,359,359,120,359,359,359,359,359,359,359,120, 552,552,552,552,552,552,552,552,552,552,552,552,552,552,552,552, 552,552,552,552,552,552,552,552,552,552,552,552,552,552,552,552, +552,552,552,552,552,552,120,552,120,120,120,120,120,552,120,120, +553,553,553,553,553,553,553,553,553,553,553,553,553,553,553,553, +553,553,553,553,553,553,553,553,553,553,553,553,553,553,553,553, +553,553,553,553,553,553,553,553,553,553,553,553,553,553,553,553, +553,553,553,553,553,553,553,553,120,120,120,120,120,120,120,554, +555,120,120,120,120,120,120,120,120,120,120,120,120,120,120,556, + +/* block 85 */ +361,361,361,361,361,361,361,361,361,361,361,361,361,361,361,361, +361,361,361,361,361,361,361,120,120,120,120,120,120,120,120,120, +361,361,361,361,361,361,361,120,361,361,361,361,361,361,361,120, +361,361,361,361,361,361,361,120,361,361,361,361,361,361,361,120, +361,361,361,361,361,361,361,120,361,361,361,361,361,361,361,120, +361,361,361,361,361,361,361,120,361,361,361,361,361,361,361,120, +557,557,557,557,557,557,557,557,557,557,557,557,557,557,557,557, +557,557,557,557,557,557,557,557,557,557,557,557,557,557,557,557, /* block 86 */ 5, 5, 23, 27, 23, 27, 5, 5, 5, 23, 27, 5, 23, 27, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10, 5, 5, 10, 5, 23, 27, 5, 5, 23, 27, 7, 8, 7, 8, 7, 8, 7, 8, 5, 5, 5, 5, 5,111, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10, 10, 5, 5, 5, 5, - 10, 5, 7,553, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 20, 20, 5,120,120,120,120,120,120,120,120,120,120,120,120,120, + 10, 5, 7,558, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 20, 20, 5, 5, 5, 7, 8, 7, 8, 7, 8, 7, 8, 10,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 87 */ -554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554, -554,554,554,554,554,554,554,554,554,554,120,554,554,554,554,554, -554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554, -554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554, -554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554, -554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554, -554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554, -554,554,554,554,120,120,120,120,120,120,120,120,120,120,120,120, +559,559,559,559,559,559,559,559,559,559,559,559,559,559,559,559, +559,559,559,559,559,559,559,559,559,559,120,559,559,559,559,559, +559,559,559,559,559,559,559,559,559,559,559,559,559,559,559,559, +559,559,559,559,559,559,559,559,559,559,559,559,559,559,559,559, +559,559,559,559,559,559,559,559,559,559,559,559,559,559,559,559, +559,559,559,559,559,559,559,559,559,559,559,559,559,559,559,559, +559,559,559,559,559,559,559,559,559,559,559,559,559,559,559,559, +559,559,559,559,120,120,120,120,120,120,120,120,120,120,120,120, /* block 88 */ -554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554, -554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554, -554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554, -554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554, -554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554, -554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554, -554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554, -554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554, +559,559,559,559,559,559,559,559,559,559,559,559,559,559,559,559, +559,559,559,559,559,559,559,559,559,559,559,559,559,559,559,559, +559,559,559,559,559,559,559,559,559,559,559,559,559,559,559,559, +559,559,559,559,559,559,559,559,559,559,559,559,559,559,559,559, +559,559,559,559,559,559,559,559,559,559,559,559,559,559,559,559, +559,559,559,559,559,559,559,559,559,559,559,559,559,559,559,559, +559,559,559,559,559,559,559,559,559,559,559,559,559,559,559,559, +559,559,559,559,559,559,559,559,559,559,559,559,559,559,559,559, /* block 89 */ -554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554, -554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554, -554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554, -554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554, -554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554, -554,554,554,554,554,554,120,120,120,120,120,120,120,120,120,120, +559,559,559,559,559,559,559,559,559,559,559,559,559,559,559,559, +559,559,559,559,559,559,559,559,559,559,559,559,559,559,559,559, +559,559,559,559,559,559,559,559,559,559,559,559,559,559,559,559, +559,559,559,559,559,559,559,559,559,559,559,559,559,559,559,559, +559,559,559,559,559,559,559,559,559,559,559,559,559,559,559,559, +559,559,559,559,559,559,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,120,120,120,120, /* block 90 */ - 4,555,555,556, 20,557,558,559,560,561,560,561,560,561,560,561, -560,561, 20,562,560,561,560,561,560,561,560,561,563,564,565,565, - 20,559,559,559,559,559,559,559,559,559,566,566,566,566,567,567, -568,569,569,569,569,569, 20,562,559,559,559,557,570,571,572,572, -120,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, -573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, -573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, -573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, - -/* block 91 */ -573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, -573,573,573,573,573,573,573,120,120,574,574,575,575,576,576,573, -577,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, + 4,560,560,561, 20,562,563,564,565,566,565,566,565,566,565,566, +565,566, 20,567,565,566,565,566,565,566,565,566,568,569,570,570, + 20,564,564,564,564,564,564,564,564,564,571,571,571,571,572,572, +573,574,574,574,574,574, 20,567,564,564,564,562,575,576,577,577, +120,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, 578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, 578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, 578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, + +/* block 91 */ 578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, -578,578,578,578,578,578,578,578,578,578,578,555,569,579,579,578, +578,578,578,578,578,578,578,120,120,579,579,580,580,581,581,578, +582,583,583,583,583,583,583,583,583,583,583,583,583,583,583,583, +583,583,583,583,583,583,583,583,583,583,583,583,583,583,583,583, +583,583,583,583,583,583,583,583,583,583,583,583,583,583,583,583, +583,583,583,583,583,583,583,583,583,583,583,583,583,583,583,583, +583,583,583,583,583,583,583,583,583,583,583,583,583,583,583,583, +583,583,583,583,583,583,583,583,583,583,583,560,574,584,584,583, /* block 92 */ -120,120,120,120,120,580,580,580,580,580,580,580,580,580,580,580, -580,580,580,580,580,580,580,580,580,580,580,580,580,580,580,580, -580,580,580,580,580,580,580,580,580,580,580,580,580,580,580,580, -120,581,581,581,581,581,581,581,581,581,581,581,581,581,581,581, -581,581,581,581,581,581,581,581,581,581,581,581,581,581,581,581, -581,581,581,581,581,581,581,581,581,581,581,581,581,581,581,581, -581,581,581,581,581,581,581,581,581,581,581,581,581,581,581,581, -581,581,581,581,581,581,581,581,581,581,581,581,581,581,581,581, +120,120,120,120,120,585,585,585,585,585,585,585,585,585,585,585, +585,585,585,585,585,585,585,585,585,585,585,585,585,585,585,585, +585,585,585,585,585,585,585,585,585,585,585,585,585,585,585,585, +120,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, /* block 93 */ -581,581,581,581,581,581,581,581,581,581,581,581,581,581,581,120, -572,572,582,582,582,582,572,572,572,572,572,572,572,572,572,572, -580,580,580,580,580,580,580,580,580,580,580,580,580,580,580,580, -580,580,580,580,580,580,580,580,580,580,580,580,580,580,580,580, -572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572, -572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572, -572,572,572,572,120,120,120,120,120,120,120,120,120,120,120,120, -578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,120, +577,577,587,587,587,587,577,577,577,577,577,577,577,577,577,577, +585,585,585,585,585,585,585,585,585,585,585,585,585,585,585,585, +585,585,585,585,585,585,585,585,585,585,585,585,585,585,585,585, +577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, +577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, +577,577,577,577,120,120,120,120,120,120,120,120,120,120,120,120, +583,583,583,583,583,583,583,583,583,583,583,583,583,583,583,583, /* block 94 */ -583,583,583,583,583,583,583,583,583,583,583,583,583,583,583,583, -583,583,583,583,583,583,583,583,583,583,583,583,583,583,583,120, -582,582,582,582,582,582,582,582,582,582,572,572,572,572,572,572, -572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572, -572,572,572,572,572,572,572,572, 25, 25, 25, 25, 25, 25, 25, 25, +588,588,588,588,588,588,588,588,588,588,588,588,588,588,588,588, +588,588,588,588,588,588,588,588,588,588,588,588,588,588,588,120, +587,587,587,587,587,587,587,587,587,587,577,577,577,577,577,577, +577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, +577,577,577,577,577,577,577,577, 25, 25, 25, 25, 25, 25, 25, 25, 20, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, -583,583,583,583,583,583,583,583,583,583,583,583,583,583,583,583, -583,583,583,583,583,583,583,583,583,583,583,583,583,583,583, 20, +588,588,588,588,588,588,588,588,588,588,588,588,588,588,588,588, +588,588,588,588,588,588,588,588,588,588,588,588,588,588,588, 20, /* block 95 */ -582,582,582,582,582,582,582,582,582,582,572,572,572,572,572,572, -572,572,572,572,572,572,572,584,572,584,572,572,572,572,572,572, -572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572, -572, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, -572,572,572,572,572,572,572,572,572,572,572,572, 20, 20, 20, 20, -585,585,585,585,585,585,585,585,585,585,585,585,585,585,585,585, -585,585,585,585,585,585,585,585,585,585,585,585,585,585,585,585, -585,585,585,585,585,585,585,585,585,585,585,585,585,585,585,572, +587,587,587,587,587,587,587,587,587,587,577,577,577,577,577,577, +577,577,577,577,577,577,577,589,577,589,577,577,577,577,577,577, +577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, +577, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, +577,577,577,577,577,577,577,577,577,577,577,577, 20, 20, 20, 20, +590,590,590,590,590,590,590,590,590,590,590,590,590,590,590,590, +590,590,590,590,590,590,590,590,590,590,590,590,590,590,590,590, +590,590,590,590,590,590,590,590,590,590,590,590,590,590,590,577, /* block 96 */ -585,585,585,585,585,585,585,585,585,585,585,585,585,585,585,585, -585,585,585,585,585,585,585,585,585,585,585,585,585,585,585,585, -585,585,585,585,585,585,585,585,585,585,585,585,585,585,585,585, -585,585,585,585,585,585,585,585,585,585,585,585,585,585,585,585, -585,585,585,585,585,585,585,585,585,585,585,585,585,585,585,585, -585,585,585,585,585,585,585,585,572,572,572,572,572,572,572,572, -572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572, -572, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,572,572,572,572,572, +590,590,590,590,590,590,590,590,590,590,590,590,590,590,590,590, +590,590,590,590,590,590,590,590,590,590,590,590,590,590,590,590, +590,590,590,590,590,590,590,590,590,590,590,590,590,590,590,590, +590,590,590,590,590,590,590,590,590,590,590,590,590,590,590,590, +590,590,590,590,590,590,590,590,590,590,590,590,590,590,590,590, +590,590,590,590,590,590,590,590,577,577,577,577,577,577,577,577, +577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, +577, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,577,577,577,577,577, /* block 97 */ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, @@ -2695,450 +2721,440 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 71936 bytes, block = 128 */ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, -572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572, -572,572,572,572,572,572,572,572,572,572,572,572,572,572,572, 20, +577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, +577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, 20, /* block 98 */ -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, /* block 99 */ -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, /* block 100 */ -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,120,120,120, +592,592,592,592,592,592,592,592,592,592,592,592,592,592,592,592, +592,592,592,592,592,593,592,592,592,592,592,592,592,592,592,592, +592,592,592,592,592,592,592,592,592,592,592,592,592,592,592,592, +592,592,592,592,592,592,592,592,592,592,592,592,592,592,592,592, +592,592,592,592,592,592,592,592,592,592,592,592,592,592,592,592, +592,592,592,592,592,592,592,592,592,592,592,592,592,592,592,592, +592,592,592,592,592,592,592,592,592,592,592,592,592,592,592,592, +592,592,592,592,592,592,592,592,592,592,592,592,592,592,592,592, /* block 101 */ -587,587,587,587,587,587,587,587,587,587,587,587,587,587,587,587, -587,587,587,587,587,588,587,587,587,587,587,587,587,587,587,587, -587,587,587,587,587,587,587,587,587,587,587,587,587,587,587,587, -587,587,587,587,587,587,587,587,587,587,587,587,587,587,587,587, -587,587,587,587,587,587,587,587,587,587,587,587,587,587,587,587, -587,587,587,587,587,587,587,587,587,587,587,587,587,587,587,587, -587,587,587,587,587,587,587,587,587,587,587,587,587,587,587,587, -587,587,587,587,587,587,587,587,587,587,587,587,587,587,587,587, +592,592,592,592,592,592,592,592,592,592,592,592,592,592,592,592, +592,592,592,592,592,592,592,592,592,592,592,592,592,592,592,592, +592,592,592,592,592,592,592,592,592,592,592,592,592,592,592,592, +592,592,592,592,592,592,592,592,592,592,592,592,592,592,592,592, +592,592,592,592,592,592,592,592,592,592,592,592,592,592,592,592, +592,592,592,592,592,592,592,592,592,592,592,592,592,592,592,592, +592,592,592,592,592,592,592,592,592,592,592,592,592,592,592,592, +592,592,592,592,592,592,592,592,592,592,592,592,592,592,592,592, /* block 102 */ -587,587,587,587,587,587,587,587,587,587,587,587,587,587,587,587, -587,587,587,587,587,587,587,587,587,587,587,587,587,587,587,587, -587,587,587,587,587,587,587,587,587,587,587,587,587,587,587,587, -587,587,587,587,587,587,587,587,587,587,587,587,587,587,587,587, -587,587,587,587,587,587,587,587,587,587,587,587,587,587,587,587, -587,587,587,587,587,587,587,587,587,587,587,587,587,587,587,587, -587,587,587,587,587,587,587,587,587,587,587,587,587,587,587,587, -587,587,587,587,587,587,587,587,587,587,587,587,587,587,587,587, +592,592,592,592,592,592,592,592,592,592,592,592,592,120,120,120, +594,594,594,594,594,594,594,594,594,594,594,594,594,594,594,594, +594,594,594,594,594,594,594,594,594,594,594,594,594,594,594,594, +594,594,594,594,594,594,594,594,594,594,594,594,594,594,594,594, +594,594,594,594,594,594,594,120,120,120,120,120,120,120,120,120, +595,595,595,595,595,595,595,595,595,595,595,595,595,595,595,595, +595,595,595,595,595,595,595,595,595,595,595,595,595,595,595,595, +595,595,595,595,595,595,595,595,596,596,596,596,596,596,597,597, /* block 103 */ -587,587,587,587,587,587,587,587,587,587,587,587,587,120,120,120, -589,589,589,589,589,589,589,589,589,589,589,589,589,589,589,589, -589,589,589,589,589,589,589,589,589,589,589,589,589,589,589,589, -589,589,589,589,589,589,589,589,589,589,589,589,589,589,589,589, -589,589,589,589,589,589,589,120,120,120,120,120,120,120,120,120, -590,590,590,590,590,590,590,590,590,590,590,590,590,590,590,590, -590,590,590,590,590,590,590,590,590,590,590,590,590,590,590,590, -590,590,590,590,590,590,590,590,591,591,591,591,591,591,592,592, +598,598,598,598,598,598,598,598,598,598,598,598,598,598,598,598, +598,598,598,598,598,598,598,598,598,598,598,598,598,598,598,598, +598,598,598,598,598,598,598,598,598,598,598,598,598,598,598,598, +598,598,598,598,598,598,598,598,598,598,598,598,598,598,598,598, +598,598,598,598,598,598,598,598,598,598,598,598,598,598,598,598, +598,598,598,598,598,598,598,598,598,598,598,598,598,598,598,598, +598,598,598,598,598,598,598,598,598,598,598,598,598,598,598,598, +598,598,598,598,598,598,598,598,598,598,598,598,598,598,598,598, /* block 104 */ -593,593,593,593,593,593,593,593,593,593,593,593,593,593,593,593, -593,593,593,593,593,593,593,593,593,593,593,593,593,593,593,593, -593,593,593,593,593,593,593,593,593,593,593,593,593,593,593,593, -593,593,593,593,593,593,593,593,593,593,593,593,593,593,593,593, -593,593,593,593,593,593,593,593,593,593,593,593,593,593,593,593, -593,593,593,593,593,593,593,593,593,593,593,593,593,593,593,593, -593,593,593,593,593,593,593,593,593,593,593,593,593,593,593,593, -593,593,593,593,593,593,593,593,593,593,593,593,593,593,593,593, - -/* block 105 */ -593,593,593,593,593,593,593,593,593,593,593,593,594,595,595,595, -593,593,593,593,593,593,593,593,593,593,593,593,593,593,593,593, -596,596,596,596,596,596,596,596,596,596,593,593,120,120,120,120, +598,598,598,598,598,598,598,598,598,598,598,598,599,600,600,600, +598,598,598,598,598,598,598,598,598,598,598,598,598,598,598,598, +601,601,601,601,601,601,601,601,601,601,598,598,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -192,193,192,193,192,193,192,193,192,193,597,598,192,193,192,193, +192,193,192,193,192,193,192,193,192,193,602,603,192,193,192,193, 192,193,192,193,192,193,192,193,192,193,192,193,192,193,192,193, -192,193,192,193,192,193,192,193,192,193,192,193,192,193,599,198, -200,200,200,600,552,552,552,552,552,552,552,552,552,552,600,478, +192,193,192,193,192,193,192,193,192,193,192,193,192,193,604,198, +200,200,200,605,557,557,557,557,557,557,557,557,557,557,605,482, -/* block 106 */ +/* block 105 */ 192,193,192,193,192,193,192,193,192,193,192,193,192,193,192,193, -192,193,192,193,192,193,192,193,192,193,192,193,478,478,552,552, -601,601,601,601,601,601,601,601,601,601,601,601,601,601,601,601, -601,601,601,601,601,601,601,601,601,601,601,601,601,601,601,601, -601,601,601,601,601,601,601,601,601,601,601,601,601,601,601,601, -601,601,601,601,601,601,601,601,601,601,601,601,601,601,601,601, -601,601,601,601,601,601,602,602,602,602,602,602,602,602,602,602, -603,603,604,604,604,604,604,604,120,120,120,120,120,120,120,120, +192,193,192,193,192,193,192,193,192,193,192,193,482,482,557,557, +606,606,606,606,606,606,606,606,606,606,606,606,606,606,606,606, +606,606,606,606,606,606,606,606,606,606,606,606,606,606,606,606, +606,606,606,606,606,606,606,606,606,606,606,606,606,606,606,606, +606,606,606,606,606,606,606,606,606,606,606,606,606,606,606,606, +606,606,606,606,606,606,607,607,607,607,607,607,607,607,607,607, +608,608,609,609,609,609,609,609,120,120,120,120,120,120,120,120, -/* block 107 */ -605,605,605,605,605,605,605,605, 15, 15, 15, 15, 15, 15, 15, 15, +/* block 106 */ +610,610,610,610,610,610,610,610, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,111,111,111,111,111,111,111,111,111, 15, 15, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 35, 35, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, -110, 35, 35, 35, 35, 35, 35, 35, 35, 32, 33, 32, 33,606, 32, 33, +110, 35, 35, 35, 35, 35, 35, 35, 35, 32, 33, 32, 33,611, 32, 33, -/* block 108 */ - 32, 33, 32, 33, 32, 33, 32, 33,111, 15, 15, 32, 33,607, 35, 22, - 32, 33, 32, 33,608, 35, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, - 32, 33, 32, 33, 32, 33, 32, 33, 32, 33,609,610,611,612,609, 35, -613,614,615,616, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, -120,120, 32, 33,617,618,619, 32, 33, 32, 33,120,120,120,120,120, -120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +/* block 107 */ + 32, 33, 32, 33, 32, 33, 32, 33,111, 15, 15, 32, 33,612, 35, 22, + 32, 33, 32, 33,613, 35, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, + 32, 33, 32, 33, 32, 33, 32, 33, 32, 33,614,615,616,617,614, 35, +618,619,620,621, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, + 32, 33, 32, 33,622,623,624, 32, 33, 32, 33,120,120,120,120,120, + 32, 33,120, 35,120, 35, 32, 33, 32, 33,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -120,120,120,120,120, 32, 33, 22,110,110, 35, 22, 22, 22, 22, 22, +120,120,110,110,110, 32, 33, 22,110,110, 35, 22, 22, 22, 22, 22, + +/* block 108 */ +625,625,626,625,625,625,626,625,625,625,625,626,625,625,625,625, +625,625,625,625,625,625,625,625,625,625,625,625,625,625,625,625, +625,625,625,627,627,626,626,627,628,628,628,628,626,120,120,120, +629,629,629,630,630,630,631,631,632,631,120,120,120,120,120,120, +633,633,633,633,633,633,633,633,633,633,633,633,633,633,633,633, +633,633,633,633,633,633,633,633,633,633,633,633,633,633,633,633, +633,633,633,633,633,633,633,633,633,633,633,633,633,633,633,633, +633,633,633,633,634,634,634,634,120,120,120,120,120,120,120,120, /* block 109 */ -620,620,621,620,620,620,621,620,620,620,620,621,620,620,620,620, -620,620,620,620,620,620,620,620,620,620,620,620,620,620,620,620, -620,620,620,622,622,621,621,622,623,623,623,623,621,120,120,120, -624,624,624,625,625,625,626,626,627,626,120,120,120,120,120,120, -628,628,628,628,628,628,628,628,628,628,628,628,628,628,628,628, -628,628,628,628,628,628,628,628,628,628,628,628,628,628,628,628, -628,628,628,628,628,628,628,628,628,628,628,628,628,628,628,628, -628,628,628,628,629,629,629,629,120,120,120,120,120,120,120,120, +635,635,636,636,636,636,636,636,636,636,636,636,636,636,636,636, +636,636,636,636,636,636,636,636,636,636,636,636,636,636,636,636, +636,636,636,636,636,636,636,636,636,636,636,636,636,636,636,636, +636,636,636,636,635,635,635,635,635,635,635,635,635,635,635,635, +635,635,635,635,637,637,120,120,120,120,120,120,120,120,638,638, +639,639,639,639,639,639,639,639,639,639,120,120,120,120,120,120, +253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, +253,640,255,641,255,255,255,255,261,261,261,255,261,255,255,253, /* block 110 */ -630,630,631,631,631,631,631,631,631,631,631,631,631,631,631,631, -631,631,631,631,631,631,631,631,631,631,631,631,631,631,631,631, -631,631,631,631,631,631,631,631,631,631,631,631,631,631,631,631, -631,631,631,631,630,630,630,630,630,630,630,630,630,630,630,630, -630,630,630,630,632,632,120,120,120,120,120,120,120,120,633,633, -634,634,634,634,634,634,634,634,634,634,120,120,120,120,120,120, -251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251, -251,635,253,636,253,253,253,253,259,259,259,253,259,253,253,251, +642,642,642,642,642,642,642,642,642,642,643,643,643,643,643,643, +643,643,643,643,643,643,643,643,643,643,643,643,643,643,643,643, +643,643,643,643,643,643,644,644,644,644,644,644,644,644,645,646, +647,647,647,647,647,647,647,647,647,647,647,647,647,647,647,647, +647,647,647,647,647,647,647,648,648,648,648,648,648,648,648,648, +648,648,649,649,120,120,120,120,120,120,120,120,120,120,120,650, +358,358,358,358,358,358,358,358,358,358,358,358,358,358,358,358, +358,358,358,358,358,358,358,358,358,358,358,358,358,120,120,120, /* block 111 */ -637,637,637,637,637,637,637,637,637,637,638,638,638,638,638,638, -638,638,638,638,638,638,638,638,638,638,638,638,638,638,638,638, -638,638,638,638,638,638,639,639,639,639,639,639,639,639,640,641, -642,642,642,642,642,642,642,642,642,642,642,642,642,642,642,642, -642,642,642,642,642,642,642,643,643,643,643,643,643,643,643,643, -643,643,644,644,120,120,120,120,120,120,120,120,120,120,120,645, -356,356,356,356,356,356,356,356,356,356,356,356,356,356,356,356, -356,356,356,356,356,356,356,356,356,356,356,356,356,120,120,120, - -/* block 112 */ -646,646,646,647,648,648,648,648,648,648,648,648,648,648,648,648, -648,648,648,648,648,648,648,648,648,648,648,648,648,648,648,648, -648,648,648,648,648,648,648,648,648,648,648,648,648,648,648,648, -648,648,648,646,647,647,646,646,646,646,647,647,646,646,647,647, -647,649,649,649,649,649,649,649,649,649,649,649,649,649,120,650, -651,651,651,651,651,651,651,651,651,651,120,120,120,120,649,649, -344,344,344,344,344,346,652,344,344,344,344,344,344,344,344,344, -350,350,350,350,350,350,350,350,350,350,344,344,344,344,344,120, - -/* block 113 */ +651,651,651,652,653,653,653,653,653,653,653,653,653,653,653,653, 653,653,653,653,653,653,653,653,653,653,653,653,653,653,653,653, 653,653,653,653,653,653,653,653,653,653,653,653,653,653,653,653, -653,653,653,653,653,653,653,653,653,654,654,654,654,654,654,655, -655,654,654,655,655,654,654,120,120,120,120,120,120,120,120,120, -653,653,653,654,653,653,653,653,653,653,653,653,654,655,120,120, -656,656,656,656,656,656,656,656,656,656,120,120,657,657,657,657, -344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344, -652,344,344,344,344,344,344,351,351,351,344,345,346,345,344,344, +653,653,653,651,652,652,651,651,651,651,652,652,651,651,652,652, +652,654,654,654,654,654,654,654,654,654,654,654,654,654,120,655, +656,656,656,656,656,656,656,656,656,656,120,120,120,120,654,654, +346,346,346,346,346,348,657,346,346,346,346,346,346,346,346,346, +352,352,352,352,352,352,352,352,352,352,346,346,346,346,346,120, -/* block 114 */ -658,658,658,658,658,658,658,658,658,658,658,658,658,658,658,658, +/* block 112 */ 658,658,658,658,658,658,658,658,658,658,658,658,658,658,658,658, 658,658,658,658,658,658,658,658,658,658,658,658,658,658,658,658, -659,658,659,659,659,658,658,659,659,658,658,658,658,658,659,659, -658,659,658,120,120,120,120,120,120,120,120,120,120,120,120,120, -120,120,120,120,120,120,120,120,120,120,120,658,658,660,661,661, -662,662,662,662,662,662,662,662,662,662,662,663,664,664,663,663, -665,665,662,666,666,663,664,120,120,120,120,120,120,120,120,120, +658,658,658,658,658,658,658,658,658,659,659,659,659,659,659,660, +660,659,659,660,660,659,659,120,120,120,120,120,120,120,120,120, +658,658,658,659,658,658,658,658,658,658,658,658,659,660,120,120, +661,661,661,661,661,661,661,661,661,661,120,120,662,662,662,662, +346,346,346,346,346,346,346,346,346,346,346,346,346,346,346,346, +657,346,346,346,346,346,346,353,353,353,346,347,348,347,346,346, -/* block 115 */ -120,359,359,359,359,359,359,120,120,359,359,359,359,359,359,120, -120,359,359,359,359,359,359,120,120,120,120,120,120,120,120,120, -359,359,359,359,359,359,359,120,359,359,359,359,359,359,359,120, +/* block 113 */ +663,663,663,663,663,663,663,663,663,663,663,663,663,663,663,663, +663,663,663,663,663,663,663,663,663,663,663,663,663,663,663,663, +663,663,663,663,663,663,663,663,663,663,663,663,663,663,663,663, +664,663,664,664,664,663,663,664,664,663,663,663,663,663,664,664, +663,664,663,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,663,663,665,666,666, +667,667,667,667,667,667,667,667,667,667,667,668,669,669,668,668, +670,670,667,671,671,668,669,120,120,120,120,120,120,120,120,120, + +/* block 114 */ +120,361,361,361,361,361,361,120,120,361,361,361,361,361,361,120, +120,361,361,361,361,361,361,120,120,120,120,120,120,120,120,120, +361,361,361,361,361,361,361,120,361,361,361,361,361,361,361,120, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, - 35, 35, 35,667, 35, 35, 35, 35, 35, 35, 35, 15,110,110,110,110, + 35, 35, 35,672, 35, 35, 35, 35, 35, 35, 35, 15,110,110,110,110, 35, 35, 35, 35, 35,128, 35, 35, 35,110, 15, 15,120,120,120,120, -668,668,668,668,668,668,668,668,668,668,668,668,668,668,668,668, +673,673,673,673,673,673,673,673,673,673,673,673,673,673,673,673, + +/* block 115 */ +673,673,673,673,673,673,673,673,673,673,673,673,673,673,673,673, +673,673,673,673,673,673,673,673,673,673,673,673,673,673,673,673, +673,673,673,673,673,673,673,673,673,673,673,673,673,673,673,673, +673,673,673,673,673,673,673,673,673,673,673,673,673,673,673,673, +667,667,667,667,667,667,667,667,667,667,667,667,667,667,667,667, +667,667,667,667,667,667,667,667,667,667,667,667,667,667,667,667, +667,667,667,668,668,669,668,668,669,668,668,670,668,669,120,120, +674,674,674,674,674,674,674,674,674,674,120,120,120,120,120,120, /* block 116 */ -668,668,668,668,668,668,668,668,668,668,668,668,668,668,668,668, -668,668,668,668,668,668,668,668,668,668,668,668,668,668,668,668, -668,668,668,668,668,668,668,668,668,668,668,668,668,668,668,668, -668,668,668,668,668,668,668,668,668,668,668,668,668,668,668,668, -662,662,662,662,662,662,662,662,662,662,662,662,662,662,662,662, -662,662,662,662,662,662,662,662,662,662,662,662,662,662,662,662, -662,662,662,663,663,664,663,663,664,663,663,665,663,664,120,120, -669,669,669,669,669,669,669,669,669,669,120,120,120,120,120,120, +675,676,676,676,676,676,676,676,676,676,676,676,676,676,676,676, +676,676,676,676,676,676,676,676,676,676,676,676,675,676,676,676, +676,676,676,676,676,676,676,676,676,676,676,676,676,676,676,676, +676,676,676,676,676,676,676,676,675,676,676,676,676,676,676,676, +676,676,676,676,676,676,676,676,676,676,676,676,676,676,676,676, +676,676,676,676,675,676,676,676,676,676,676,676,676,676,676,676, +676,676,676,676,676,676,676,676,676,676,676,676,676,676,676,676, +675,676,676,676,676,676,676,676,676,676,676,676,676,676,676,676, /* block 117 */ -670,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, -671,671,671,671,671,671,671,671,671,671,671,671,670,671,671,671, -671,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, -671,671,671,671,671,671,671,671,670,671,671,671,671,671,671,671, -671,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, -671,671,671,671,670,671,671,671,671,671,671,671,671,671,671,671, -671,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, -670,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, +676,676,676,676,676,676,676,676,676,676,676,676,675,676,676,676, +676,676,676,676,676,676,676,676,676,676,676,676,676,676,676,676, +676,676,676,676,676,676,676,676,675,676,676,676,676,676,676,676, +676,676,676,676,676,676,676,676,676,676,676,676,676,676,676,676, +676,676,676,676,675,676,676,676,676,676,676,676,676,676,676,676, +676,676,676,676,676,676,676,676,676,676,676,676,676,676,676,676, +675,676,676,676,676,676,676,676,676,676,676,676,676,676,676,676, +676,676,676,676,676,676,676,676,676,676,676,676,675,676,676,676, /* block 118 */ -671,671,671,671,671,671,671,671,671,671,671,671,670,671,671,671, -671,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, -671,671,671,671,671,671,671,671,670,671,671,671,671,671,671,671, -671,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, -671,671,671,671,670,671,671,671,671,671,671,671,671,671,671,671, -671,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, -670,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, -671,671,671,671,671,671,671,671,671,671,671,671,670,671,671,671, +676,676,676,676,676,676,676,676,676,676,676,676,676,676,676,676, +676,676,676,676,676,676,676,676,675,676,676,676,676,676,676,676, +676,676,676,676,676,676,676,676,676,676,676,676,676,676,676,676, +676,676,676,676,675,676,676,676,676,676,676,676,676,676,676,676, +676,676,676,676,676,676,676,676,676,676,676,676,676,676,676,676, +675,676,676,676,676,676,676,676,676,676,676,676,676,676,676,676, +676,676,676,676,676,676,676,676,676,676,676,676,675,676,676,676, +676,676,676,676,676,676,676,676,676,676,676,676,676,676,676,676, /* block 119 */ -671,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, -671,671,671,671,671,671,671,671,670,671,671,671,671,671,671,671, -671,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, -671,671,671,671,670,671,671,671,671,671,671,671,671,671,671,671, -671,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, -670,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, -671,671,671,671,671,671,671,671,671,671,671,671,670,671,671,671, -671,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, +676,676,676,676,676,676,676,676,675,676,676,676,676,676,676,676, +676,676,676,676,676,676,676,676,676,676,676,676,676,676,676,676, +676,676,676,676,675,676,676,676,676,676,676,676,676,676,676,676, +676,676,676,676,676,676,676,676,676,676,676,676,676,676,676,676, +675,676,676,676,676,676,676,676,676,676,676,676,676,676,676,676, +676,676,676,676,676,676,676,676,676,676,676,676,675,676,676,676, +676,676,676,676,676,676,676,676,676,676,676,676,676,676,676,676, +676,676,676,676,676,676,676,676,675,676,676,676,676,676,676,676, /* block 120 */ -671,671,671,671,671,671,671,671,670,671,671,671,671,671,671,671, -671,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, -671,671,671,671,670,671,671,671,671,671,671,671,671,671,671,671, -671,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, -670,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, -671,671,671,671,671,671,671,671,671,671,671,671,670,671,671,671, -671,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, -671,671,671,671,671,671,671,671,670,671,671,671,671,671,671,671, +676,676,676,676,676,676,676,676,676,676,676,676,676,676,676,676, +676,676,676,676,675,676,676,676,676,676,676,676,676,676,676,676, +676,676,676,676,676,676,676,676,676,676,676,676,676,676,676,676, +675,676,676,676,676,676,676,676,676,676,676,676,676,676,676,676, +676,676,676,676,676,676,676,676,676,676,676,676,675,676,676,676, +676,676,676,676,676,676,676,676,676,676,676,676,676,676,676,676, +676,676,676,676,676,676,676,676,675,676,676,676,676,676,676,676, +676,676,676,676,676,676,676,676,676,676,676,676,676,676,676,676, /* block 121 */ -671,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, -671,671,671,671,670,671,671,671,671,671,671,671,671,671,671,671, -671,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, -670,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, -671,671,671,671,671,671,671,671,671,671,671,671,670,671,671,671, -671,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, -671,671,671,671,671,671,671,671,670,671,671,671,671,671,671,671, -671,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, +676,676,676,676,675,676,676,676,676,676,676,676,676,676,676,676, +676,676,676,676,676,676,676,676,676,676,676,676,676,676,676,676, +675,676,676,676,676,676,676,676,676,676,676,676,676,676,676,676, +676,676,676,676,676,676,676,676,676,676,676,676,675,676,676,676, +676,676,676,676,676,676,676,676,676,676,676,676,676,676,676,676, +676,676,676,676,676,676,676,676,675,676,676,676,676,676,676,676, +676,676,676,676,676,676,676,676,676,676,676,676,676,676,676,676, +676,676,676,676,675,676,676,676,676,676,676,676,676,676,676,676, /* block 122 */ -671,671,671,671,670,671,671,671,671,671,671,671,671,671,671,671, -671,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, -670,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, -671,671,671,671,671,671,671,671,671,671,671,671,670,671,671,671, -671,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, -671,671,671,671,671,671,671,671,670,671,671,671,671,671,671,671, -671,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, -671,671,671,671,670,671,671,671,671,671,671,671,671,671,671,671, +676,676,676,676,676,676,676,676,676,676,676,676,676,676,676,676, +675,676,676,676,676,676,676,676,676,676,676,676,676,676,676,676, +676,676,676,676,676,676,676,676,676,676,676,676,675,676,676,676, +676,676,676,676,676,676,676,676,676,676,676,676,676,676,676,676, +676,676,676,676,676,676,676,676,675,676,676,676,676,676,676,676, +676,676,676,676,676,676,676,676,676,676,676,676,676,676,676,676, +676,676,676,676,675,676,676,676,676,676,676,676,676,676,676,676, +676,676,676,676,676,676,676,676,676,676,676,676,676,676,676,676, /* block 123 */ -671,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, -670,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, -671,671,671,671,671,671,671,671,671,671,671,671,670,671,671,671, -671,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, -671,671,671,671,671,671,671,671,670,671,671,671,671,671,671,671, -671,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, -671,671,671,671,670,671,671,671,671,671,671,671,671,671,671,671, -671,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, +676,676,676,676,676,676,676,676,675,676,676,676,676,676,676,676, +676,676,676,676,676,676,676,676,676,676,676,676,676,676,676,676, +676,676,676,676,120,120,120,120,120,120,120,120,120,120,120,120, +359,359,359,359,359,359,359,359,359,359,359,359,359,359,359,359, +359,359,359,359,359,359,359,120,120,120,120,360,360,360,360,360, +360,360,360,360,360,360,360,360,360,360,360,360,360,360,360,360, +360,360,360,360,360,360,360,360,360,360,360,360,360,360,360,360, +360,360,360,360,360,360,360,360,360,360,360,360,120,120,120,120, /* block 124 */ -671,671,671,671,671,671,671,671,670,671,671,671,671,671,671,671, -671,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, -671,671,671,671,120,120,120,120,120,120,120,120,120,120,120,120, -357,357,357,357,357,357,357,357,357,357,357,357,357,357,357,357, -357,357,357,357,357,357,357,120,120,120,120,358,358,358,358,358, -358,358,358,358,358,358,358,358,358,358,358,358,358,358,358,358, -358,358,358,358,358,358,358,358,358,358,358,358,358,358,358,358, -358,358,358,358,358,358,358,358,358,358,358,358,120,120,120,120, +677,677,677,677,677,677,677,677,677,677,677,677,677,677,677,677, +677,677,677,677,677,677,677,677,677,677,677,677,677,677,677,677, +677,677,677,677,677,677,677,677,677,677,677,677,677,677,677,677, +677,677,677,677,677,677,677,677,677,677,677,677,677,677,677,677, +677,677,677,677,677,677,677,677,677,677,677,677,677,677,677,677, +677,677,677,677,677,677,677,677,677,677,677,677,677,677,677,677, +677,677,677,677,677,677,677,677,677,677,677,677,677,677,677,677, +677,677,677,677,677,677,677,677,677,677,677,677,677,677,677,677, /* block 125 */ -672,672,672,672,672,672,672,672,672,672,672,672,672,672,672,672, -672,672,672,672,672,672,672,672,672,672,672,672,672,672,672,672, -672,672,672,672,672,672,672,672,672,672,672,672,672,672,672,672, -672,672,672,672,672,672,672,672,672,672,672,672,672,672,672,672, -672,672,672,672,672,672,672,672,672,672,672,672,672,672,672,672, -672,672,672,672,672,672,672,672,672,672,672,672,672,672,672,672, -672,672,672,672,672,672,672,672,672,672,672,672,672,672,672,672, -672,672,672,672,672,672,672,672,672,672,672,672,672,672,672,672, +678,678,678,678,678,678,678,678,678,678,678,678,678,678,678,678, +678,678,678,678,678,678,678,678,678,678,678,678,678,678,678,678, +678,678,678,678,678,678,678,678,678,678,678,678,678,678,678,678, +678,678,678,678,678,678,678,678,678,678,678,678,678,678,678,678, +678,678,678,678,678,678,678,678,678,678,678,678,678,678,678,678, +678,678,678,678,678,678,678,678,678,678,678,678,678,678,678,678, +678,678,678,678,678,678,678,678,678,678,678,678,678,678,678,678, +678,678,678,678,678,678,678,678,678,678,678,678,678,678,678,678, /* block 126 */ -673,673,673,673,673,673,673,673,673,673,673,673,673,673,673,673, -673,673,673,673,673,673,673,673,673,673,673,673,673,673,673,673, -673,673,673,673,673,673,673,673,673,673,673,673,673,673,673,673, -673,673,673,673,673,673,673,673,673,673,673,673,673,673,673,673, -673,673,673,673,673,673,673,673,673,673,673,673,673,673,673,673, -673,673,673,673,673,673,673,673,673,673,673,673,673,673,673,673, -673,673,673,673,673,673,673,673,673,673,673,673,673,673,673,673, -673,673,673,673,673,673,673,673,673,673,673,673,673,673,673,673, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,120,120, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, /* block 127 */ -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,120,120, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, - -/* block 128 */ -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,120,120,120,120,120,120, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -/* block 129 */ +/* block 128 */ 35, 35, 35, 35, 35, 35, 35,120,120,120,120,120,120,120,120,120, 120,120,120,206,206,206,206,206,120,120,120,120,120,214,211,214, -214,214,214,214,214,214,214,214,214,674,214,214,214,214,214,214, +214,214,214,214,214,214,214,214,214,679,214,214,214,214,214,214, 214,214,214,214,214,214,214,120,214,214,214,214,214,120,214,120, 214,214,120,214,214,120,214,214,214,214,214,214,214,214,214,214, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, + +/* block 129 */ +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,252,252,252,252,252,252,252,252,252,252,252,252,252,252, +252,252,252,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, /* block 130 */ -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,675,675,675,675,675,675,675,675,675,675,675,675,675,675, -675,675,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -120,120,120,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, /* block 131 */ -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,680,681, +221,221,221,221,221,221,221,221,221,221,221,221,221,221,221,221, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, /* block 132 */ -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224, 8, 7, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +120,120,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,120,120,120,120,120,120,120,221, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, - -/* block 133 */ -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -120,120,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -224,224,676,224,224,224,224,224,224,224,224,224,219,677,120,120, +225,225,682,225,225,225,225,225,225,225,225,225,219,683,221,221, -/* block 134 */ +/* block 133 */ 113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, 5, 5, 5, 5, 5, 5, 5, 7, 8, 5,120,120,120,120,120,120, -113,113,113,113,113,113,113,113,113,113,113,113,113,113,552,552, +113,113,113,113,113,113,113,113,113,113,113,113,113,113,557,557, 5, 10, 10, 16, 16, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, - 8, 7, 8, 7, 8,556,556, 7, 8, 5, 5, 5, 5, 16, 16, 16, + 8, 7, 8, 7, 8,561,561, 7, 8, 5, 5, 5, 5, 16, 16, 16, 5, 5, 5,120, 5, 5, 5, 5, 10, 7, 8, 7, 8, 7, 8, 5, 5, 5, 9, 10, 9, 9, 9,120, 5, 6, 5, 5,120,120,120,120, -224,224,224,224,224,120,224,224,224,224,224,224,224,224,224,224, +225,225,225,225,225,120,225,225,225,225,225,225,225,225,225,225, -/* block 135 */ -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,120,120, 24, +/* block 134 */ +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,120,120, 24, -/* block 136 */ +/* block 135 */ 120, 5, 5, 5, 6, 5, 5, 5, 7, 8, 5, 9, 5, 10, 5, 5, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 5, 5, 9, 9, 9, 5, 5, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 7, 5, 8, 15, 16, 15, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 7, 9, 8, 9, 7, - 8,555,560,561,555,555,578,578,578,578,578,578,578,578,578,578, -569,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, + 8,560,565,566,560,560,583,583,583,583,583,583,583,583,583,583, +574,583,583,583,583,583,583,583,583,583,583,583,583,583,583,583, -/* block 137 */ -578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, -578,578,578,578,578,578,578,578,578,578,578,578,578,578,678,678, -581,581,581,581,581,581,581,581,581,581,581,581,581,581,581,581, -581,581,581,581,581,581,581,581,581,581,581,581,581,581,581,120, -120,120,581,581,581,581,581,581,120,120,581,581,581,581,581,581, -120,120,581,581,581,581,581,581,120,120,581,581,581,120,120,120, +/* block 136 */ +583,583,583,583,583,583,583,583,583,583,583,583,583,583,583,583, +583,583,583,583,583,583,583,583,583,583,583,583,583,583,684,684, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,120, +120,120,586,586,586,586,586,586,120,120,586,586,586,586,586,586, +120,120,586,586,586,586,586,586,120,120,586,586,586,120,120,120, 6, 6, 9, 15, 20, 6, 6,120, 20, 9, 9, 9, 9, 20, 20,120, -511,511,511,511,511,511,511,511,511, 24, 24, 24, 20, 20,120,120, +516,516,516,516,516,516,516,516,516, 24, 24, 24, 20, 20,120,120, -/* block 138 */ -679,679,679,679,679,679,679,679,679,679,679,679,120,679,679,679, -679,679,679,679,679,679,679,679,679,679,679,679,679,679,679,679, -679,679,679,679,679,679,679,120,679,679,679,679,679,679,679,679, -679,679,679,679,679,679,679,679,679,679,679,120,679,679,120,679, -679,679,679,679,679,679,679,679,679,679,679,679,679,679,120,120, -679,679,679,679,679,679,679,679,679,679,679,679,679,679,120,120, +/* block 137 */ +685,685,685,685,685,685,685,685,685,685,685,685,120,685,685,685, +685,685,685,685,685,685,685,685,685,685,685,685,685,685,685,685, +685,685,685,685,685,685,685,120,685,685,685,685,685,685,685,685, +685,685,685,685,685,685,685,685,685,685,685,120,685,685,120,685, +685,685,685,685,685,685,685,685,685,685,685,685,685,685,120,120, +685,685,685,685,685,685,685,685,685,685,685,685,685,685,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +/* block 138 */ +685,685,685,685,685,685,685,685,685,685,685,685,685,685,685,685, +685,685,685,685,685,685,685,685,685,685,685,685,685,685,685,685, +685,685,685,685,685,685,685,685,685,685,685,685,685,685,685,685, +685,685,685,685,685,685,685,685,685,685,685,685,685,685,685,685, +685,685,685,685,685,685,685,685,685,685,685,685,685,685,685,685, +685,685,685,685,685,685,685,685,685,685,685,685,685,685,685,685, +685,685,685,685,685,685,685,685,685,685,685,685,685,685,685,685, +685,685,685,685,685,685,685,685,685,685,685,120,120,120,120,120, + /* block 139 */ -679,679,679,679,679,679,679,679,679,679,679,679,679,679,679,679, -679,679,679,679,679,679,679,679,679,679,679,679,679,679,679,679, -679,679,679,679,679,679,679,679,679,679,679,679,679,679,679,679, -679,679,679,679,679,679,679,679,679,679,679,679,679,679,679,679, -679,679,679,679,679,679,679,679,679,679,679,679,679,679,679,679, -679,679,679,679,679,679,679,679,679,679,679,679,679,679,679,679, -679,679,679,679,679,679,679,679,679,679,679,679,679,679,679,679, -679,679,679,679,679,679,679,679,679,679,679,120,120,120,120,120, +686,686,687,120,120,120,120,688,688,688,688,688,688,688,688,688, +688,688,688,688,688,688,688,688,688,688,688,688,688,688,688,688, +688,688,688,688,688,688,688,688,688,688,688,688,688,688,688,688, +688,688,688,688,120,120,120,689,689,689,689,689,689,689,689,689, +690,690,690,690,690,690,690,690,690,690,690,690,690,690,690,690, +690,690,690,690,690,690,690,690,690,690,690,690,690,690,690,690, +690,690,690,690,690,690,690,690,690,690,690,690,690,690,690,690, +690,690,690,690,690,691,691,691,691,692,692,692,692,692,692,692, /* block 140 */ -680,680,680,120,120,120,120,681,681,681,681,681,681,681,681,681, -681,681,681,681,681,681,681,681,681,681,681,681,681,681,681,681, -681,681,681,681,681,681,681,681,681,681,681,681,681,681,681,681, -681,681,681,681,120,120,120,682,682,682,682,682,682,682,682,682, -683,683,683,683,683,683,683,683,683,683,683,683,683,683,683,683, -683,683,683,683,683,683,683,683,683,683,683,683,683,683,683,683, -683,683,683,683,683,683,683,683,683,683,683,683,683,683,683,683, -683,683,683,683,683,684,684,684,684,685,685,685,685,685,685,685, - -/* block 141 */ -685,685,685,685,685,685,685,685,685,685,684,684,685,685,685,120, +692,692,692,692,692,692,692,692,692,692,691,691,692,692,692,120, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,120,120,120, -685,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +692,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,113,120,120, -/* block 142 */ +/* block 141 */ 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, @@ -3148,499 +3164,519 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 71936 bytes, block = 128 */ 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -/* block 143 */ -686,686,686,686,686,686,686,686,686,686,686,686,686,686,686,686, -686,686,686,686,686,686,686,686,686,686,686,686,686,120,120,120, -687,687,687,687,687,687,687,687,687,687,687,687,687,687,687,687, -687,687,687,687,687,687,687,687,687,687,687,687,687,687,687,687, -687,687,687,687,687,687,687,687,687,687,687,687,687,687,687,687, -687,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -688,689,689,689,689,689,689,689,689,689,689,689,689,689,689,689, -689,689,689,689,689,689,689,689,689,689,689,689,120,120,120,120, - -/* block 144 */ -690,690,690,690,690,690,690,690,690,690,690,690,690,690,690,690, -690,690,690,690,690,690,690,690,690,690,690,690,690,690,690,690, -691,691,691,691,120,120,120,120,120,120,120,120,120,690,690,690, -692,692,692,692,692,692,692,692,692,692,692,692,692,692,692,692, -692,693,692,692,692,692,692,692,692,692,693,120,120,120,120,120, +/* block 142 */ +693,693,693,693,693,693,693,693,693,693,693,693,693,693,693,693, +693,693,693,693,693,693,693,693,693,693,693,693,693,120,120,120, 694,694,694,694,694,694,694,694,694,694,694,694,694,694,694,694, 694,694,694,694,694,694,694,694,694,694,694,694,694,694,694,694, -694,694,694,694,694,694,695,695,695,695,695,120,120,120,120,120, - -/* block 145 */ -696,696,696,696,696,696,696,696,696,696,696,696,696,696,696,696, -696,696,696,696,696,696,696,696,696,696,696,696,696,696,120,697, -698,698,698,698,698,698,698,698,698,698,698,698,698,698,698,698, -698,698,698,698,698,698,698,698,698,698,698,698,698,698,698,698, -698,698,698,698,120,120,120,120,698,698,698,698,698,698,698,698, -699,700,700,700,700,700,120,120,120,120,120,120,120,120,120,120, -120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +694,694,694,694,694,694,694,694,694,694,694,694,694,694,694,694, +694,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +695,696,696,696,696,696,696,696,696,696,696,696,696,696,696,696, +696,696,696,696,696,696,696,696,696,696,696,696,120,120,120,120, -/* block 146 */ +/* block 143 */ +697,697,697,697,697,697,697,697,697,697,697,697,697,697,697,697, +697,697,697,697,697,697,697,697,697,697,697,697,697,697,697,697, +698,698,698,698,120,120,120,120,120,120,120,120,120,697,697,697, +699,699,699,699,699,699,699,699,699,699,699,699,699,699,699,699, +699,700,699,699,699,699,699,699,699,699,700,120,120,120,120,120, 701,701,701,701,701,701,701,701,701,701,701,701,701,701,701,701, 701,701,701,701,701,701,701,701,701,701,701,701,701,701,701,701, -701,701,701,701,701,701,701,701,702,702,702,702,702,702,702,702, -702,702,702,702,702,702,702,702,702,702,702,702,702,702,702,702, -702,702,702,702,702,702,702,702,702,702,702,702,702,702,702,702, -703,703,703,703,703,703,703,703,703,703,703,703,703,703,703,703, -703,703,703,703,703,703,703,703,703,703,703,703,703,703,703,703, -703,703,703,703,703,703,703,703,703,703,703,703,703,703,703,703, +701,701,701,701,701,701,702,702,702,702,702,120,120,120,120,120, -/* block 147 */ -704,704,704,704,704,704,704,704,704,704,704,704,704,704,704,704, -704,704,704,704,704,704,704,704,704,704,704,704,704,704,120,120, -705,705,705,705,705,705,705,705,705,705,120,120,120,120,120,120, -706,706,706,706,706,706,706,706,706,706,706,706,706,706,706,706, -706,706,706,706,706,706,706,706,706,706,706,706,706,706,706,706, -706,706,706,706,120,120,120,120,707,707,707,707,707,707,707,707, -707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707, -707,707,707,707,707,707,707,707,707,707,707,707,120,120,120,120, +/* block 144 */ +703,703,703,703,703,703,703,703,703,703,703,703,703,703,703,703, +703,703,703,703,703,703,703,703,703,703,703,703,703,703,120,704, +705,705,705,705,705,705,705,705,705,705,705,705,705,705,705,705, +705,705,705,705,705,705,705,705,705,705,705,705,705,705,705,705, +705,705,705,705,120,120,120,120,705,705,705,705,705,705,705,705, +706,707,707,707,707,707,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -/* block 148 */ +/* block 145 */ 708,708,708,708,708,708,708,708,708,708,708,708,708,708,708,708, 708,708,708,708,708,708,708,708,708,708,708,708,708,708,708,708, -708,708,708,708,708,708,708,708,120,120,120,120,120,120,120,120, +708,708,708,708,708,708,708,708,709,709,709,709,709,709,709,709, 709,709,709,709,709,709,709,709,709,709,709,709,709,709,709,709, 709,709,709,709,709,709,709,709,709,709,709,709,709,709,709,709, -709,709,709,709,709,709,709,709,709,709,709,709,709,709,709,709, -709,709,709,709,120,120,120,120,120,120,120,120,120,120,120,710, +710,710,710,710,710,710,710,710,710,710,710,710,710,710,710,710, +710,710,710,710,710,710,710,710,710,710,710,710,710,710,710,710, +710,710,710,710,710,710,710,710,710,710,710,710,710,710,710,710, + +/* block 146 */ +711,711,711,711,711,711,711,711,711,711,711,711,711,711,711,711, +711,711,711,711,711,711,711,711,711,711,711,711,711,711,120,120, +712,712,712,712,712,712,712,712,712,712,120,120,120,120,120,120, +713,713,713,713,713,713,713,713,713,713,713,713,713,713,713,713, +713,713,713,713,713,713,713,713,713,713,713,713,713,713,713,713, +713,713,713,713,120,120,120,120,714,714,714,714,714,714,714,714, +714,714,714,714,714,714,714,714,714,714,714,714,714,714,714,714, +714,714,714,714,714,714,714,714,714,714,714,714,120,120,120,120, + +/* block 147 */ +715,715,715,715,715,715,715,715,715,715,715,715,715,715,715,715, +715,715,715,715,715,715,715,715,715,715,715,715,715,715,715,715, +715,715,715,715,715,715,715,715,120,120,120,120,120,120,120,120, +716,716,716,716,716,716,716,716,716,716,716,716,716,716,716,716, +716,716,716,716,716,716,716,716,716,716,716,716,716,716,716,716, +716,716,716,716,716,716,716,716,716,716,716,716,716,716,716,716, +716,716,716,716,120,120,120,120,120,120,120,120,120,120,120,717, +718,718,718,718,718,718,718,718,718,718,718,120,718,718,718,718, + +/* block 148 */ +718,718,718,718,718,718,718,718,718,718,718,120,718,718,718,718, +718,718,718,120,718,718,120,719,719,719,719,719,719,719,719,719, +719,719,120,719,719,719,719,719,719,719,719,719,719,719,719,719, +719,719,120,719,719,719,719,719,719,719,120,719,719,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 149 */ -711,711,711,711,711,711,711,711,711,711,711,711,711,711,711,711, -711,711,711,711,711,711,711,711,711,711,711,711,711,711,711,711, -711,711,711,711,711,711,711,711,711,711,711,711,711,711,711,711, -711,711,711,711,711,711,711,711,711,711,711,711,711,711,711,711, -711,711,711,711,711,711,711,711,711,711,711,711,711,711,711,711, -711,711,711,711,711,711,711,711,711,711,711,711,711,711,711,711, -711,711,711,711,711,711,711,711,711,711,711,711,711,711,711,711, -711,711,711,711,711,711,711,711,711,711,711,711,711,711,711,711, +720,720,720,720,720,720,720,720,720,720,720,720,720,720,720,720, +720,720,720,720,720,720,720,720,720,720,720,720,720,720,720,720, +720,720,720,720,720,720,720,720,720,720,720,720,720,720,720,720, +720,720,720,720,720,720,720,720,720,720,720,720,720,720,720,720, +720,720,720,720,720,720,720,720,720,720,720,720,720,720,720,720, +720,720,720,720,720,720,720,720,720,720,720,720,720,720,720,720, +720,720,720,720,720,720,720,720,720,720,720,720,720,720,720,720, +720,720,720,720,720,720,720,720,720,720,720,720,720,720,720,720, /* block 150 */ -711,711,711,711,711,711,711,711,711,711,711,711,711,711,711,711, -711,711,711,711,711,711,711,711,711,711,711,711,711,711,711,711, -711,711,711,711,711,711,711,711,711,711,711,711,711,711,711,711, -711,711,711,711,711,711,711,120,120,120,120,120,120,120,120,120, -711,711,711,711,711,711,711,711,711,711,711,711,711,711,711,711, -711,711,711,711,711,711,120,120,120,120,120,120,120,120,120,120, -711,711,711,711,711,711,711,711,120,120,120,120,120,120,120,120, +720,720,720,720,720,720,720,720,720,720,720,720,720,720,720,720, +720,720,720,720,720,720,720,720,720,720,720,720,720,720,720,720, +720,720,720,720,720,720,720,720,720,720,720,720,720,720,720,720, +720,720,720,720,720,720,720,120,120,120,120,120,120,120,120,120, +720,720,720,720,720,720,720,720,720,720,720,720,720,720,720,720, +720,720,720,720,720,720,120,120,120,120,120,120,120,120,120,120, +720,720,720,720,720,720,720,720,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 151 */ -712,712,712,712,712,712,120,120,712,120,712,712,712,712,712,712, -712,712,712,712,712,712,712,712,712,712,712,712,712,712,712,712, -712,712,712,712,712,712,712,712,712,712,712,712,712,712,712,712, -712,712,712,712,712,712,120,712,712,120,120,120,712,120,120,712, -713,713,713,713,713,713,713,713,713,713,713,713,713,713,713,713, -713,713,713,713,713,713,120,714,715,715,715,715,715,715,715,715, -716,716,716,716,716,716,716,716,716,716,716,716,716,716,716,716, -716,716,716,716,716,716,716,717,717,718,718,718,718,718,718,718, - -/* block 152 */ -719,719,719,719,719,719,719,719,719,719,719,719,719,719,719,719, -719,719,719,719,719,719,719,719,719,719,719,719,719,719,719,120, -120,120,120,120,120,120,120,720,720,720,720,720,720,720,720,720, +110,110,110,110,110,110,120,110,110,110,110,110,110,110,110,110, +110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, +110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, +110,120,110,110,110,110,110,110,110,110,110,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, + +/* block 152 */ +721,721,721,721,721,721,120,120,721,120,721,721,721,721,721,721, +721,721,721,721,721,721,721,721,721,721,721,721,721,721,721,721, 721,721,721,721,721,721,721,721,721,721,721,721,721,721,721,721, -721,721,721,120,721,721,120,120,120,120,120,722,722,722,722,722, +721,721,721,721,721,721,120,721,721,120,120,120,721,120,120,721, +722,722,722,722,722,722,722,722,722,722,722,722,722,722,722,722, +722,722,722,722,722,722,120,723,724,724,724,724,724,724,724,724, +725,725,725,725,725,725,725,725,725,725,725,725,725,725,725,725, +725,725,725,725,725,725,725,726,726,727,727,727,727,727,727,727, /* block 153 */ -723,723,723,723,723,723,723,723,723,723,723,723,723,723,723,723, -723,723,723,723,723,723,724,724,724,724,724,724,120,120,120,725, -726,726,726,726,726,726,726,726,726,726,726,726,726,726,726,726, -726,726,726,726,726,726,726,726,726,726,120,120,120,120,120,727, -120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +728,728,728,728,728,728,728,728,728,728,728,728,728,728,728,728, +728,728,728,728,728,728,728,728,728,728,728,728,728,728,728,120, +120,120,120,120,120,120,120,729,729,729,729,729,729,729,729,729, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +730,730,730,730,730,730,730,730,730,730,730,730,730,730,730,730, +730,730,730,120,730,730,120,120,120,120,120,731,731,731,731,731, /* block 154 */ -728,728,728,728,728,728,728,728,728,728,728,728,728,728,728,728, -728,728,728,728,728,728,728,728,728,728,728,728,728,728,728,728, -729,729,729,729,729,729,729,729,729,729,729,729,729,729,729,729, -729,729,729,729,729,729,729,729,120,120,120,120,730,730,729,729, -730,730,730,730,730,730,730,730,730,730,730,730,730,730,730,730, -120,120,730,730,730,730,730,730,730,730,730,730,730,730,730,730, -730,730,730,730,730,730,730,730,730,730,730,730,730,730,730,730, -730,730,730,730,730,730,730,730,730,730,730,730,730,730,730,730, +732,732,732,732,732,732,732,732,732,732,732,732,732,732,732,732, +732,732,732,732,732,732,733,733,733,733,733,733,120,120,120,734, +735,735,735,735,735,735,735,735,735,735,735,735,735,735,735,735, +735,735,735,735,735,735,735,735,735,735,120,120,120,120,120,736, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 155 */ -731,732,732,732,120,732,732,120,120,120,120,120,732,732,732,732, -731,731,731,731,120,731,731,731,120,731,731,731,731,731,731,731, -731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731, -731,731,731,731,731,731,120,120,732,732,732,120,120,120,120,732, -733,733,733,733,733,733,733,733,733,120,120,120,120,120,120,120, -734,734,734,734,734,734,734,734,734,120,120,120,120,120,120,120, -735,735,735,735,735,735,735,735,735,735,735,735,735,735,735,735, -735,735,735,735,735,735,735,735,735,735,735,735,735,736,736,737, +737,737,737,737,737,737,737,737,737,737,737,737,737,737,737,737, +737,737,737,737,737,737,737,737,737,737,737,737,737,737,737,737, +738,738,738,738,738,738,738,738,738,738,738,738,738,738,738,738, +738,738,738,738,738,738,738,738,120,120,120,120,739,739,738,738, +739,739,739,739,739,739,739,739,739,739,739,739,739,739,739,739, +120,120,739,739,739,739,739,739,739,739,739,739,739,739,739,739, +739,739,739,739,739,739,739,739,739,739,739,739,739,739,739,739, +739,739,739,739,739,739,739,739,739,739,739,739,739,739,739,739, /* block 156 */ -738,738,738,738,738,738,738,738,738,738,738,738,738,738,738,738, -738,738,738,738,738,738,738,738,738,738,738,738,738,739,739,739, -120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -740,740,740,740,740,740,740,740,741,740,740,740,740,740,740,740, +740,741,741,741,120,741,741,120,120,120,120,120,741,741,741,741, +740,740,740,740,120,740,740,740,120,740,740,740,740,740,740,740, 740,740,740,740,740,740,740,740,740,740,740,740,740,740,740,740, -740,740,740,740,740,742,742,120,120,120,120,743,743,743,743,743, -744,744,744,744,744,744,744,120,120,120,120,120,120,120,120,120, +740,740,740,740,740,740,120,120,741,741,741,120,120,120,120,741, +742,742,742,742,742,742,742,742,742,120,120,120,120,120,120,120, +743,743,743,743,743,743,743,743,743,120,120,120,120,120,120,120, +744,744,744,744,744,744,744,744,744,744,744,744,744,744,744,744, +744,744,744,744,744,744,744,744,744,744,744,744,744,745,745,746, /* block 157 */ -745,745,745,745,745,745,745,745,745,745,745,745,745,745,745,745, -745,745,745,745,745,745,745,745,745,745,745,745,745,745,745,745, -745,745,745,745,745,745,745,745,745,745,745,745,745,745,745,745, -745,745,745,745,745,745,120,120,120,746,746,746,746,746,746,746, 747,747,747,747,747,747,747,747,747,747,747,747,747,747,747,747, -747,747,747,747,747,747,120,120,748,748,748,748,748,748,748,748, +747,747,747,747,747,747,747,747,747,747,747,747,747,748,748,748, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +749,749,749,749,749,749,749,749,750,749,749,749,749,749,749,749, 749,749,749,749,749,749,749,749,749,749,749,749,749,749,749,749, -749,749,749,120,120,120,120,120,750,750,750,750,750,750,750,750, +749,749,749,749,749,751,751,120,120,120,120,752,752,752,752,752, +753,753,754,753,753,753,753,120,120,120,120,120,120,120,120,120, /* block 158 */ -751,751,751,751,751,751,751,751,751,751,751,751,751,751,751,751, -751,751,120,120,120,120,120,120,120,752,752,752,752,120,120,120, -120,120,120,120,120,120,120,120,120,753,753,753,753,753,753,753, +755,755,755,755,755,755,755,755,755,755,755,755,755,755,755,755, +755,755,755,755,755,755,755,755,755,755,755,755,755,755,755,755, +755,755,755,755,755,755,755,755,755,755,755,755,755,755,755,755, +755,755,755,755,755,755,120,120,120,756,756,756,756,756,756,756, +757,757,757,757,757,757,757,757,757,757,757,757,757,757,757,757, +757,757,757,757,757,757,120,120,758,758,758,758,758,758,758,758, +759,759,759,759,759,759,759,759,759,759,759,759,759,759,759,759, +759,759,759,120,120,120,120,120,760,760,760,760,760,760,760,760, + +/* block 159 */ +761,761,761,761,761,761,761,761,761,761,761,761,761,761,761,761, +761,761,120,120,120,120,120,120,120,762,762,762,762,120,120,120, +120,120,120,120,120,120,120,120,120,763,763,763,763,763,763,763, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -/* block 159 */ -754,754,754,754,754,754,754,754,754,754,754,754,754,754,754,754, -754,754,754,754,754,754,754,754,754,754,754,754,754,754,754,754, -754,754,754,754,754,754,754,754,754,754,754,754,754,754,754,754, -754,754,754,754,754,754,754,754,754,754,754,754,754,754,754,754, -754,754,754,754,754,754,754,754,754,120,120,120,120,120,120,120, +/* block 160 */ +764,764,764,764,764,764,764,764,764,764,764,764,764,764,764,764, +764,764,764,764,764,764,764,764,764,764,764,764,764,764,764,764, +764,764,764,764,764,764,764,764,764,764,764,764,764,764,764,764, +764,764,764,764,764,764,764,764,764,764,764,764,764,764,764,764, +764,764,764,764,764,764,764,764,764,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -/* block 160 */ -755,755,755,755,755,755,755,755,755,755,755,755,755,755,755,755, -755,755,755,755,755,755,755,755,755,755,755,755,755,755,755,755, -755,755,755,755,755,755,755,755,755,755,755,755,755,755,755,755, -755,755,755,120,120,120,120,120,120,120,120,120,120,120,120,120, -756,756,756,756,756,756,756,756,756,756,756,756,756,756,756,756, -756,756,756,756,756,756,756,756,756,756,756,756,756,756,756,756, -756,756,756,756,756,756,756,756,756,756,756,756,756,756,756,756, -756,756,756,120,120,120,120,120,120,120,757,757,757,757,757,757, - /* block 161 */ -758,758,758,758,758,758,758,758,758,758,758,758,758,758,758,758, -758,758,758,758,758,758,758,758,758,758,758,758,758,758,758,758, -758,758,758,758,759,759,759,759,120,120,120,120,120,120,120,120, -760,760,760,760,760,760,760,760,760,760,120,120,120,120,120,120, -120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765, +765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765, +765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765, +765,765,765,120,120,120,120,120,120,120,120,120,120,120,120,120, +766,766,766,766,766,766,766,766,766,766,766,766,766,766,766,766, +766,766,766,766,766,766,766,766,766,766,766,766,766,766,766,766, +766,766,766,766,766,766,766,766,766,766,766,766,766,766,766,766, +766,766,766,120,120,120,120,120,120,120,767,767,767,767,767,767, /* block 162 */ +768,768,768,768,768,768,768,768,768,768,768,768,768,768,768,768, +768,768,768,768,768,768,768,768,768,768,768,768,768,768,768,768, +768,768,768,768,769,769,769,769,120,120,120,120,120,120,120,120, +770,770,770,770,770,770,770,770,770,770,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -761,761,761,761,761,761,761,761,761,761,761,761,761,761,761,761, -761,761,761,761,761,761,761,761,761,761,761,761,761,761,761,120, /* block 163 */ -762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762, -762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762, -762,762,762,762,762,762,762,762,762,762,120,763,763,764,120,120, -762,762,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +771,771,771,771,771,771,771,771,771,771,771,771,771,771,771,771, +771,771,771,771,771,771,771,771,771,771,771,771,771,771,771,120, /* block 164 */ -765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765, -765,765,765,765,765,765,765,765,765,765,765,765,765,766,766,766, -766,766,766,766,766,766,766,765,120,120,120,120,120,120,120,120, -767,767,767,767,767,767,767,767,767,767,767,767,767,767,767,767, -767,767,767,767,767,767,768,768,768,768,768,768,768,768,768,768, -768,769,769,769,769,770,770,770,770,770,120,120,120,120,120,120, +772,772,772,772,772,772,772,772,772,772,772,772,772,772,772,772, +772,772,772,772,772,772,772,772,772,772,772,772,772,772,772,772, +772,772,772,772,772,772,772,772,772,772,120,773,773,774,120,120, +772,772,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 165 */ +775,775,775,775,775,775,775,775,775,775,775,775,775,775,775,775, +775,775,775,775,775,775,775,775,775,775,775,775,775,776,776,776, +776,776,776,776,776,776,776,775,120,120,120,120,120,120,120,120, +777,777,777,777,777,777,777,777,777,777,777,777,777,777,777,777, +777,777,777,777,777,777,778,778,778,778,778,778,778,778,778,778, +778,779,779,779,779,780,780,780,780,780,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +781,781,781,781,781,781,781,781,781,781,781,781,781,781,781,781, + +/* block 166 */ +781,781,782,782,782,782,783,783,783,783,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -771,771,771,771,771,771,771,771,771,771,771,771,771,771,771,771, -771,771,771,771,771,772,772,772,772,772,772,772,120,120,120,120, +784,784,784,784,784,784,784,784,784,784,784,784,784,784,784,784, +784,784,784,784,784,785,785,785,785,785,785,785,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -773,773,773,773,773,773,773,773,773,773,773,773,773,773,773,773, -773,773,773,773,773,773,773,120,120,120,120,120,120,120,120,120, - -/* block 166 */ -774,775,774,776,776,776,776,776,776,776,776,776,776,776,776,776, -776,776,776,776,776,776,776,776,776,776,776,776,776,776,776,776, -776,776,776,776,776,776,776,776,776,776,776,776,776,776,776,776, -776,776,776,776,776,776,776,776,775,775,775,775,775,775,775,775, -775,775,775,775,775,775,775,777,777,777,777,777,777,777,120,120, -120,120,778,778,778,778,778,778,778,778,778,778,778,778,778,778, -778,778,778,778,778,778,779,779,779,779,779,779,779,779,779,779, -120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,775, +786,786,786,786,786,786,786,786,786,786,786,786,786,786,786,786, +786,786,786,786,786,786,786,120,120,120,120,120,120,120,120,120, /* block 167 */ -780,780,781,782,782,782,782,782,782,782,782,782,782,782,782,782, -782,782,782,782,782,782,782,782,782,782,782,782,782,782,782,782, -782,782,782,782,782,782,782,782,782,782,782,782,782,782,782,782, -781,781,781,780,780,780,780,781,781,780,780,783,783,784,783,783, -783,783,120,120,120,120,120,120,120,120,120,120,120,784,120,120, -785,785,785,785,785,785,785,785,785,785,785,785,785,785,785,785, -785,785,785,785,785,785,785,785,785,120,120,120,120,120,120,120, -786,786,786,786,786,786,786,786,786,786,120,120,120,120,120,120, +787,788,787,789,789,789,789,789,789,789,789,789,789,789,789,789, +789,789,789,789,789,789,789,789,789,789,789,789,789,789,789,789, +789,789,789,789,789,789,789,789,789,789,789,789,789,789,789,789, +789,789,789,789,789,789,789,789,788,788,788,788,788,788,788,788, +788,788,788,788,788,788,788,790,790,790,790,790,790,790,120,120, +120,120,791,791,791,791,791,791,791,791,791,791,791,791,791,791, +791,791,791,791,791,791,792,792,792,792,792,792,792,792,792,792, +788,789,789,788,788,789,120,120,120,120,120,120,120,120,120,788, /* block 168 */ -787,787,787,788,788,788,788,788,788,788,788,788,788,788,788,788, -788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788, -788,788,788,788,788,788,788,787,787,787,787,787,789,787,787,787, -787,787,787,787,787,120,790,790,790,790,790,790,790,790,790,790, -791,791,791,791,788,789,789,788,120,120,120,120,120,120,120,120, -792,792,792,792,792,792,792,792,792,792,792,792,792,792,792,792, -792,792,792,792,792,792,792,792,792,792,792,792,792,792,792,792, -792,792,792,793,794,794,792,120,120,120,120,120,120,120,120,120, +793,793,794,795,795,795,795,795,795,795,795,795,795,795,795,795, +795,795,795,795,795,795,795,795,795,795,795,795,795,795,795,795, +795,795,795,795,795,795,795,795,795,795,795,795,795,795,795,795, +794,794,794,793,793,793,793,794,794,793,793,796,796,797,796,796, +796,796,793,120,120,120,120,120,120,120,120,120,120,797,120,120, +798,798,798,798,798,798,798,798,798,798,798,798,798,798,798,798, +798,798,798,798,798,798,798,798,798,120,120,120,120,120,120,120, +799,799,799,799,799,799,799,799,799,799,120,120,120,120,120,120, /* block 169 */ -795,795,796,797,797,797,797,797,797,797,797,797,797,797,797,797, -797,797,797,797,797,797,797,797,797,797,797,797,797,797,797,797, -797,797,797,797,797,797,797,797,797,797,797,797,797,797,797,797, -797,797,797,796,796,796,795,795,795,795,795,795,795,795,795,796, -796,797,798,798,797,799,799,799,799,795,795,795,795,799,796,795, -800,800,800,800,800,800,800,800,800,800,797,799,797,799,799,799, -120,801,801,801,801,801,801,801,801,801,801,801,801,801,801,801, -801,801,801,801,801,120,120,120,120,120,120,120,120,120,120,120, +800,800,800,801,801,801,801,801,801,801,801,801,801,801,801,801, +801,801,801,801,801,801,801,801,801,801,801,801,801,801,801,801, +801,801,801,801,801,801,801,800,800,800,800,800,802,800,800,800, +800,800,800,800,800,120,803,803,803,803,803,803,803,803,803,803, +804,804,804,804,801,802,802,801,120,120,120,120,120,120,120,120, +805,805,805,805,805,805,805,805,805,805,805,805,805,805,805,805, +805,805,805,805,805,805,805,805,805,805,805,805,805,805,805,805, +805,805,805,806,807,807,805,120,120,120,120,120,120,120,120,120, /* block 170 */ -802,802,802,802,802,802,802,802,802,802,802,802,802,802,802,802, -802,802,120,802,802,802,802,802,802,802,802,802,802,802,802,802, -802,802,802,802,802,802,802,802,802,802,802,802,803,803,803,804, -804,804,803,803,804,803,804,804,805,805,805,805,805,805,804,120, +808,808,809,810,810,810,810,810,810,810,810,810,810,810,810,810, +810,810,810,810,810,810,810,810,810,810,810,810,810,810,810,810, +810,810,810,810,810,810,810,810,810,810,810,810,810,810,810,810, +810,810,810,809,809,809,808,808,808,808,808,808,808,808,808,809, +809,810,811,811,810,812,812,812,812,808,808,808,808,812,809,808, +813,813,813,813,813,813,813,813,813,813,810,812,810,812,812,812, +120,814,814,814,814,814,814,814,814,814,814,814,814,814,814,814, +814,814,814,814,814,120,120,120,120,120,120,120,120,120,120,120, + +/* block 171 */ +815,815,815,815,815,815,815,815,815,815,815,815,815,815,815,815, +815,815,120,815,815,815,815,815,815,815,815,815,815,815,815,815, +815,815,815,815,815,815,815,815,815,815,815,815,816,816,816,817, +817,817,816,816,817,816,817,817,818,818,818,818,818,818,817,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -/* block 171 */ -806,806,806,806,806,806,806,120,806,120,806,806,806,806,120,806, -806,806,806,806,806,806,806,806,806,806,806,806,806,806,120,806, -806,806,806,806,806,806,806,806,806,807,120,120,120,120,120,120, -808,808,808,808,808,808,808,808,808,808,808,808,808,808,808,808, -808,808,808,808,808,808,808,808,808,808,808,808,808,808,808,808, -808,808,808,808,808,808,808,808,808,808,808,808,808,808,808,809, -810,810,810,809,809,809,809,809,809,809,809,120,120,120,120,120, -811,811,811,811,811,811,811,811,811,811,120,120,120,120,120,120, - /* block 172 */ -812,813,814,815,120,816,816,816,816,816,816,816,816,120,120,816, -816,120,120,816,816,816,816,816,816,816,816,816,816,816,816,816, -816,816,816,816,816,816,816,816,816,120,816,816,816,816,816,816, -816,120,816,816,120,816,816,816,816,816,120,817,813,816,818,814, -812,814,814,814,814,120,120,814,814,120,120,814,814,814,120,120, -816,120,120,120,120,120,120,818,120,120,120,120,120,816,816,816, -816,816,814,814,120,120,812,812,812,812,812,812,812,120,120,120, -812,812,812,812,812,120,120,120,120,120,120,120,120,120,120,120, +819,819,819,819,819,819,819,120,819,120,819,819,819,819,120,819, +819,819,819,819,819,819,819,819,819,819,819,819,819,819,120,819, +819,819,819,819,819,819,819,819,819,820,120,120,120,120,120,120, +821,821,821,821,821,821,821,821,821,821,821,821,821,821,821,821, +821,821,821,821,821,821,821,821,821,821,821,821,821,821,821,821, +821,821,821,821,821,821,821,821,821,821,821,821,821,821,821,822, +823,823,823,822,822,822,822,822,822,822,822,120,120,120,120,120, +824,824,824,824,824,824,824,824,824,824,120,120,120,120,120,120, /* block 173 */ -819,819,819,819,819,819,819,819,819,819,819,819,819,819,819,819, -819,819,819,819,819,819,819,819,819,819,819,819,819,819,819,819, -819,819,819,819,819,819,819,819,819,819,819,819,819,819,819,819, -819,819,819,819,819,820,820,820,821,821,821,821,821,821,821,821, -820,820,821,821,821,820,821,819,819,819,819,822,822,822,822,822, -823,823,823,823,823,823,823,823,823,823,822,822,120,822,821,819, -819,819,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +825,826,827,828,120,829,829,829,829,829,829,829,829,120,120,829, +829,120,120,829,829,829,829,829,829,829,829,829,829,829,829,829, +829,829,829,829,829,829,829,829,829,120,829,829,829,829,829,829, +829,120,829,829,120,829,829,829,829,829,120,830,826,829,831,827, +825,827,827,827,827,120,120,827,827,120,120,827,827,827,120,120, +829,120,120,120,120,120,120,831,120,120,120,120,120,829,829,829, +829,829,827,827,120,120,825,825,825,825,825,825,825,120,120,120, +825,825,825,825,825,120,120,120,120,120,120,120,120,120,120,120, /* block 174 */ -824,824,824,824,824,824,824,824,824,824,824,824,824,824,824,824, -824,824,824,824,824,824,824,824,824,824,824,824,824,824,824,824, -824,824,824,824,824,824,824,824,824,824,824,824,824,824,824,824, -825,826,826,827,827,827,827,827,827,826,827,826,826,825,826,827, -827,826,827,827,824,824,828,824,120,120,120,120,120,120,120,120, -829,829,829,829,829,829,829,829,829,829,120,120,120,120,120,120, -120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +832,832,832,832,832,832,832,832,832,832,832,832,832,832,832,832, +832,832,832,832,832,832,832,832,832,832,832,832,832,832,832,832, +832,832,832,832,832,832,832,832,832,832,832,832,832,832,832,832, +832,832,832,832,832,833,833,833,834,834,834,834,834,834,834,834, +833,833,834,834,834,833,834,832,832,832,832,835,835,835,835,835, +836,836,836,836,836,836,836,836,836,836,835,835,120,835,834,832, +832,832,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 175 */ -830,830,830,830,830,830,830,830,830,830,830,830,830,830,830,830, -830,830,830,830,830,830,830,830,830,830,830,830,830,830,830,830, -830,830,830,830,830,830,830,830,830,830,830,830,830,830,830,831, -832,832,833,833,833,833,120,120,832,832,832,832,833,833,832,833, -833,834,834,834,834,834,834,834,834,834,834,834,834,834,834,834, -834,834,834,834,834,834,834,834,830,830,830,830,833,833,120,120, +837,837,837,837,837,837,837,837,837,837,837,837,837,837,837,837, +837,837,837,837,837,837,837,837,837,837,837,837,837,837,837,837, +837,837,837,837,837,837,837,837,837,837,837,837,837,837,837,837, +838,839,839,840,840,840,840,840,840,839,840,839,839,838,839,840, +840,839,840,840,837,837,841,837,120,120,120,120,120,120,120,120, +842,842,842,842,842,842,842,842,842,842,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 176 */ -835,835,835,835,835,835,835,835,835,835,835,835,835,835,835,835, -835,835,835,835,835,835,835,835,835,835,835,835,835,835,835,835, -835,835,835,835,835,835,835,835,835,835,835,835,835,835,835,835, -836,836,836,837,837,837,837,837,837,837,837,836,836,837,836,837, -837,838,838,838,835,120,120,120,120,120,120,120,120,120,120,120, -839,839,839,839,839,839,839,839,839,839,120,120,120,120,120,120, -394,394,394,394,394,394,394,394,394,394,394,394,394,120,120,120, +843,843,843,843,843,843,843,843,843,843,843,843,843,843,843,843, +843,843,843,843,843,843,843,843,843,843,843,843,843,843,843,843, +843,843,843,843,843,843,843,843,843,843,843,843,843,843,843,844, +845,845,846,846,846,846,120,120,845,845,845,845,846,846,845,846, +846,847,847,847,847,847,847,847,847,847,847,847,847,847,847,847, +847,847,847,847,847,847,847,847,843,843,843,843,846,846,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 177 */ -840,840,840,840,840,840,840,840,840,840,840,840,840,840,840,840, -840,840,840,840,840,840,840,840,840,840,840,840,840,840,840,840, -840,840,840,840,840,840,840,840,840,840,840,841,842,841,842,842, -841,841,841,841,841,841,842,841,840,120,120,120,120,120,120,120, -843,843,843,843,843,843,843,843,843,843,120,120,120,120,120,120, -120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +848,848,848,848,848,848,848,848,848,848,848,848,848,848,848,848, +848,848,848,848,848,848,848,848,848,848,848,848,848,848,848,848, +848,848,848,848,848,848,848,848,848,848,848,848,848,848,848,848, +849,849,849,850,850,850,850,850,850,850,850,849,849,850,849,850, +850,851,851,851,848,120,120,120,120,120,120,120,120,120,120,120, +852,852,852,852,852,852,852,852,852,852,120,120,120,120,120,120, +398,398,398,398,398,398,398,398,398,398,398,398,398,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 178 */ -844,844,844,844,844,844,844,844,844,844,844,844,844,844,844,844, -844,844,844,844,844,844,844,844,844,844,844,120,120,845,845,845, -846,846,845,845,845,845,846,845,845,845,845,845,120,120,120,120, -847,847,847,847,847,847,847,847,847,847,848,848,849,849,849,850, -120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +853,853,853,853,853,853,853,853,853,853,853,853,853,853,853,853, +853,853,853,853,853,853,853,853,853,853,853,853,853,853,853,853, +853,853,853,853,853,853,853,853,853,853,853,854,855,854,855,855, +854,854,854,854,854,854,855,854,853,856,120,120,120,120,120,120, +857,857,857,857,857,857,857,857,857,857,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 179 */ -851,851,851,851,851,851,851,851,851,851,851,851,851,851,851,851, -851,851,851,851,851,851,851,851,851,851,851,851,851,851,851,851, -851,851,851,851,851,851,851,851,851,851,851,851,852,852,852,853, -853,853,853,853,853,853,853,853,852,853,853,854,120,120,120,120, -120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +858,858,858,858,858,858,858,858,858,858,858,858,858,858,858,858, +858,858,858,858,858,858,858,858,858,858,858,120,120,859,859,859, +860,860,859,859,859,859,861,859,859,859,859,859,120,120,120,120, +862,862,862,862,862,862,862,862,862,862,863,863,864,864,864,865, +858,858,858,858,858,858,858,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 180 */ +866,866,866,866,866,866,866,866,866,866,866,866,866,866,866,866, +866,866,866,866,866,866,866,866,866,866,866,866,866,866,866,866, +866,866,866,866,866,866,866,866,866,866,866,866,867,867,867,868, +868,868,868,868,868,868,868,868,867,868,868,869,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -855,855,855,855,855,855,855,855,855,855,855,855,855,855,855,855, -855,855,855,855,855,855,855,855,855,855,855,855,855,855,855,855, -856,856,856,856,856,856,856,856,856,856,856,856,856,856,856,856, -856,856,856,856,856,856,856,856,856,856,856,856,856,856,856,856, -857,857,857,857,857,857,857,857,857,857,858,858,858,858,858,858, -858,858,858,120,120,120,120,120,120,120,120,120,120,120,120,859, /* block 181 */ -860,860,860,860,860,860,860,120,120,860,120,120,860,860,860,860, -860,860,860,860,120,860,860,120,860,860,860,860,860,860,860,860, -860,860,860,860,860,860,860,860,860,860,860,860,860,860,860,860, -861,862,862,862,862,862,120,862,862,120,120,863,863,862,863,864, -862,864,862,863,865,865,865,120,120,120,120,120,120,120,120,120, -866,866,866,866,866,866,866,866,866,866,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +870,870,870,870,870,870,870,870,870,870,870,870,870,870,870,870, +870,870,870,870,870,870,870,870,870,870,870,870,870,870,870,870, +871,871,871,871,871,871,871,871,871,871,871,871,871,871,871,871, +871,871,871,871,871,871,871,871,871,871,871,871,871,871,871,871, +872,872,872,872,872,872,872,872,872,872,873,873,873,873,873,873, +873,873,873,120,120,120,120,120,120,120,120,120,120,120,120,874, /* block 182 */ +875,875,875,875,875,875,875,120,120,875,120,120,875,875,875,875, +875,875,875,875,120,875,875,120,875,875,875,875,875,875,875,875, +875,875,875,875,875,875,875,875,875,875,875,875,875,875,875,875, +876,877,877,877,877,877,120,877,877,120,120,878,878,877,878,879, +877,879,877,878,880,880,880,120,120,120,120,120,120,120,120,120, +881,881,881,881,881,881,881,881,881,881,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -867,867,867,867,867,867,867,867,120,120,867,867,867,867,867,867, -867,867,867,867,867,867,867,867,867,867,867,867,867,867,867,867, -867,867,867,867,867,867,867,867,867,867,867,867,867,867,867,867, -867,868,868,868,869,869,869,869,120,120,869,869,868,868,868,868, -869,867,870,867,868,120,120,120,120,120,120,120,120,120,120,120, -120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 183 */ -871,872,872,872,872,872,872,872,872,872,872,871,871,871,871,871, -871,871,871,871,871,871,871,871,871,871,871,871,871,871,871,871, -871,871,871,871,871,871,871,871,871,871,871,871,871,871,871,871, -871,871,871,872,872,872,872,872,872,873,874,872,872,872,872,875, -875,875,875,875,875,875,875,872,120,120,120,120,120,120,120,120, -876,877,877,877,877,877,877,878,878,877,877,877,876,876,876,876, -876,876,876,876,876,876,876,876,876,876,876,876,876,876,876,876, -876,876,876,876,876,876,876,876,876,876,876,876,876,876,876,876, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +882,882,882,882,882,882,882,882,120,120,882,882,882,882,882,882, +882,882,882,882,882,882,882,882,882,882,882,882,882,882,882,882, +882,882,882,882,882,882,882,882,882,882,882,882,882,882,882,882, +882,883,883,883,884,884,884,884,120,120,884,884,883,883,883,883, +884,882,885,882,883,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 184 */ -876,876,876,876,879,879,879,879,879,879,877,877,877,877,877,877, -877,877,877,877,877,877,877,878,877,877,880,880,880,876,880,880, -880,880,880,120,120,120,120,120,120,120,120,120,120,120,120,120, -120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -881,881,881,881,881,881,881,881,881,881,881,881,881,881,881,881, -881,881,881,881,881,881,881,881,881,881,881,881,881,881,881,881, -881,881,881,881,881,881,881,881,881,881,881,881,881,881,881,881, -881,881,881,881,881,881,881,881,881,120,120,120,120,120,120,120, +886,887,887,887,887,887,887,887,887,887,887,886,886,886,886,886, +886,886,886,886,886,886,886,886,886,886,886,886,886,886,886,886, +886,886,886,886,886,886,886,886,886,886,886,886,886,886,886,886, +886,886,886,887,887,887,887,887,887,888,889,887,887,887,887,890, +890,890,890,890,890,890,890,887,120,120,120,120,120,120,120,120, +891,892,892,892,892,892,892,893,893,892,892,892,891,891,891,891, +891,891,891,891,891,891,891,891,891,891,891,891,891,891,891,891, +891,891,891,891,891,891,891,891,891,891,891,891,891,891,891,891, /* block 185 */ -882,882,882,882,882,882,882,882,882,120,882,882,882,882,882,882, -882,882,882,882,882,882,882,882,882,882,882,882,882,882,882,882, -882,882,882,882,882,882,882,882,882,882,882,882,882,882,882,883, -884,884,884,884,884,884,884,120,884,884,884,884,884,884,883,884, -882,885,885,885,885,885,120,120,120,120,120,120,120,120,120,120, -886,886,886,886,886,886,886,886,886,886,887,887,887,887,887,887, -887,887,887,887,887,887,887,887,887,887,887,887,887,120,120,120, -888,888,889,889,889,889,889,889,889,889,889,889,889,889,889,889, +891,891,891,891,894,894,894,894,894,894,892,892,892,892,892,892, +892,892,892,892,892,892,892,893,892,892,895,895,895,891,895,895, +895,895,895,120,120,120,120,120,120,120,120,120,120,120,120,120, +370,370,370,370,370,370,370,370,370,370,370,370,370,370,370,370, +896,896,896,896,896,896,896,896,896,896,896,896,896,896,896,896, +896,896,896,896,896,896,896,896,896,896,896,896,896,896,896,896, +896,896,896,896,896,896,896,896,896,896,896,896,896,896,896,896, +896,896,896,896,896,896,896,896,896,120,120,120,120,120,120,120, /* block 186 */ -889,889,889,889,889,889,889,889,889,889,889,889,889,889,889,889, -120,120,890,890,890,890,890,890,890,890,890,890,890,890,890,890, -890,890,890,890,890,890,890,890,120,891,890,890,890,890,890,890, -890,891,890,890,891,890,890,120,120,120,120,120,120,120,120,120, +897,897,897,897,897,897,897,897,897,120,897,897,897,897,897,897, +897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897, +897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,898, +899,899,899,899,899,899,899,120,899,899,899,899,899,899,898,899, +897,900,900,900,900,900,120,120,120,120,120,120,120,120,120,120, +901,901,901,901,901,901,901,901,901,901,902,902,902,902,902,902, +902,902,902,902,902,902,902,902,902,902,902,902,902,120,120,120, +903,903,904,904,904,904,904,904,904,904,904,904,904,904,904,904, + +/* block 187 */ +904,904,904,904,904,904,904,904,904,904,904,904,904,904,904,904, +120,120,905,905,905,905,905,905,905,905,905,905,905,905,905,905, +905,905,905,905,905,905,905,905,120,906,905,905,905,905,905,905, +905,906,905,905,906,905,905,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -/* block 187 */ -892,892,892,892,892,892,892,120,892,892,120,892,892,892,892,892, -892,892,892,892,892,892,892,892,892,892,892,892,892,892,892,892, -892,892,892,892,892,892,892,892,892,892,892,892,892,892,892,892, -892,893,893,893,893,893,893,120,120,120,893,120,893,893,120,893, -893,893,893,893,893,893,894,893,120,120,120,120,120,120,120,120, -895,895,895,895,895,895,895,895,895,895,120,120,120,120,120,120, -896,896,896,896,896,896,120,896,896,120,896,896,896,896,896,896, -896,896,896,896,896,896,896,896,896,896,896,896,896,896,896,896, - /* block 188 */ -896,896,896,896,896,896,896,896,896,896,897,897,897,897,897,120, -898,898,120,897,897,898,897,898,896,120,120,120,120,120,120,120, -899,899,899,899,899,899,899,899,899,899,120,120,120,120,120,120, +907,907,907,907,907,907,907,120,907,907,120,907,907,907,907,907, +907,907,907,907,907,907,907,907,907,907,907,907,907,907,907,907, +907,907,907,907,907,907,907,907,907,907,907,907,907,907,907,907, +907,908,908,908,908,908,908,120,120,120,908,120,908,908,120,908, +908,908,908,908,908,908,909,908,120,120,120,120,120,120,120,120, +910,910,910,910,910,910,910,910,910,910,120,120,120,120,120,120, +911,911,911,911,911,911,120,911,911,120,911,911,911,911,911,911, +911,911,911,911,911,911,911,911,911,911,911,911,911,911,911,911, + +/* block 189 */ +911,911,911,911,911,911,911,911,911,911,912,912,912,912,912,120, +913,913,120,912,912,913,912,913,911,120,120,120,120,120,120,120, +914,914,914,914,914,914,914,914,914,914,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -/* block 189 */ +/* block 190 */ 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -900,900,900,900,900,900,900,900,900,900,900,900,900,900,900,900, -900,900,900,901,901,902,902,903,903,120,120,120,120,120,120,120, +915,915,915,915,915,915,915,915,915,915,915,915,915,915,915,915, +915,915,915,916,916,917,917,918,918,120,120,120,120,120,120,120, -/* block 190 */ +/* block 191 */ 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -590,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -904,904,904,904,904,904,904,904,904,904,904,904,904,904,904,904, -293,293,904,293,904,295,295,295,295,295,295,295,295,296,296,296, -296,295,295,295,295,295,295,295,295,295,295,295,295,295,295,295, -295,295,120,120,120,120,120,120,120,120,120,120,120,120,120,905, - -/* block 191 */ -906,906,906,906,906,906,906,906,906,906,906,906,906,906,906,906, -906,906,906,906,906,906,906,906,906,906,906,906,906,906,906,906, -906,906,906,906,906,906,906,906,906,906,906,906,906,906,906,906, -906,906,906,906,906,906,906,906,906,906,906,906,906,906,906,906, -906,906,906,906,906,906,906,906,906,906,906,906,906,906,906,906, -906,906,906,906,906,906,906,906,906,906,906,906,906,906,906,906, -906,906,906,906,906,906,906,906,906,906,906,906,906,906,906,906, -906,906,906,906,906,906,906,906,906,906,906,906,906,906,906,906, +595,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +919,919,919,919,919,919,919,919,919,919,919,919,919,919,919,919, +295,295,919,295,919,297,297,297,297,297,297,297,297,298,298,298, +298,297,297,297,297,297,297,297,297,297,297,297,297,297,297,297, +297,297,120,120,120,120,120,120,120,120,120,120,120,120,120,920, /* block 192 */ -906,906,906,906,906,906,906,906,906,906,906,906,906,906,906,906, -906,906,906,906,906,906,906,906,906,906,120,120,120,120,120,120, +921,921,921,921,921,921,921,921,921,921,921,921,921,921,921,921, +921,921,921,921,921,921,921,921,921,921,921,921,921,921,921,921, +921,921,921,921,921,921,921,921,921,921,921,921,921,921,921,921, +921,921,921,921,921,921,921,921,921,921,921,921,921,921,921,921, +921,921,921,921,921,921,921,921,921,921,921,921,921,921,921,921, +921,921,921,921,921,921,921,921,921,921,921,921,921,921,921,921, +921,921,921,921,921,921,921,921,921,921,921,921,921,921,921,921, +921,921,921,921,921,921,921,921,921,921,921,921,921,921,921,921, + +/* block 193 */ +921,921,921,921,921,921,921,921,921,921,921,921,921,921,921,921, +921,921,921,921,921,921,921,921,921,921,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, @@ -3648,108 +3684,118 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 71936 bytes, block = 128 */ 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -/* block 193 */ -907,907,907,907,907,907,907,907,907,907,907,907,907,907,907,907, -907,907,907,907,907,907,907,907,907,907,907,907,907,907,907,907, -907,907,907,907,907,907,907,907,907,907,907,907,907,907,907,907, -907,907,907,907,907,907,907,907,907,907,907,907,907,907,907,907, -907,907,907,907,907,907,907,907,907,907,907,907,907,907,907,907, -907,907,907,907,907,907,907,907,907,907,907,907,907,907,907,907, -907,907,907,907,907,907,907,907,907,907,907,907,907,907,907,120, -908,908,908,908,908,120,120,120,120,120,120,120,120,120,120,120, - /* block 194 */ -906,906,906,906,906,906,906,906,906,906,906,906,906,906,906,906, -906,906,906,906,906,906,906,906,906,906,906,906,906,906,906,906, -906,906,906,906,906,906,906,906,906,906,906,906,906,906,906,906, -906,906,906,906,906,906,906,906,906,906,906,906,906,906,906,906, -906,906,906,906,120,120,120,120,120,120,120,120,120,120,120,120, -120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +922,922,922,922,922,922,922,922,922,922,922,922,922,922,922,922, +922,922,922,922,922,922,922,922,922,922,922,922,922,922,922,922, +922,922,922,922,922,922,922,922,922,922,922,922,922,922,922,922, +922,922,922,922,922,922,922,922,922,922,922,922,922,922,922,922, +922,922,922,922,922,922,922,922,922,922,922,922,922,922,922,922, +922,922,922,922,922,922,922,922,922,922,922,922,922,922,922,922, +922,922,922,922,922,922,922,922,922,922,922,922,922,922,922,120, +923,923,923,923,923,120,120,120,120,120,120,120,120,120,120,120, /* block 195 */ -909,909,909,909,909,909,909,909,909,909,909,909,909,909,909,909, -909,909,909,909,909,909,909,909,909,909,909,909,909,909,909,909, -909,909,909,909,909,909,909,909,909,909,909,909,909,909,909,909, -909,909,909,909,909,909,909,909,909,909,909,909,909,909,909,909, -909,909,909,909,909,909,909,909,909,909,909,909,909,909,909,909, -909,909,909,909,909,909,909,909,909,909,909,909,909,909,909,909, -909,909,909,909,909,909,909,909,909,909,909,909,909,909,909,909, -909,909,909,909,909,909,909,909,909,909,909,909,909,909,909,909, - -/* block 196 */ -909,909,909,909,909,909,909,909,909,909,909,909,909,909,909,909, -909,909,909,909,909,909,909,909,909,909,909,909,909,909,909,909, -909,909,909,909,909,909,909,909,909,909,909,909,909,909,909,120, -910,910,910,910,910,910,910,910,910,120,120,120,120,120,120,120, +921,921,921,921,921,921,921,921,921,921,921,921,921,921,921,921, +921,921,921,921,921,921,921,921,921,921,921,921,921,921,921,921, +921,921,921,921,921,921,921,921,921,921,921,921,921,921,921,921, +921,921,921,921,921,921,921,921,921,921,921,921,921,921,921,921, +921,921,921,921,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, + +/* block 196 */ 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +924,924,924,924,924,924,924,924,924,924,924,924,924,924,924,924, +924,924,924,924,924,924,924,924,924,924,924,924,924,924,924,924, +924,924,924,924,924,924,924,924,924,924,924,924,924,924,924,924, +924,924,924,924,924,924,924,924,924,924,924,924,924,924,924,924, +924,924,924,924,924,924,924,924,924,924,924,924,924,924,924,924, +924,924,924,924,924,924,924,924,924,924,924,924,924,924,924,924, +924,925,925,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 197 */ -911,911,911,911,911,911,911,911,911,911,911,911,911,911,911,911, -911,911,911,911,911,911,911,911,911,911,911,911,911,911,911,911, -911,911,911,911,911,911,911,911,911,911,911,911,911,911,911,911, -911,911,911,911,911,911,911,911,911,911,911,911,911,911,911,911, -911,911,911,911,911,911,911,911,911,911,911,911,911,911,911,911, -911,911,911,911,911,911,911,911,911,911,911,911,911,911,911,911, -911,911,911,911,911,911,911,911,911,911,911,911,911,911,911,911, -911,911,911,911,911,911,911,911,911,911,911,911,911,911,911,911, +926,926,926,926,926,926,926,926,926,926,926,926,926,926,926,926, +926,926,926,926,926,926,926,926,926,926,926,926,926,926,926,926, +926,926,926,926,926,926,926,926,926,926,926,926,926,926,926,926, +926,926,926,926,926,926,926,926,926,926,926,926,926,926,926,926, +926,926,926,926,926,926,926,926,926,926,926,926,926,926,926,926, +926,926,926,926,926,926,926,926,926,926,926,926,926,926,926,926, +926,926,926,926,926,926,926,926,926,926,926,926,926,926,926,926, +926,926,926,926,926,926,926,926,926,926,926,926,926,926,926,926, /* block 198 */ -911,911,911,911,911,911,911,911,911,911,911,911,911,911,911,911, -911,911,911,911,911,911,911,911,911,911,911,911,911,911,911,911, -911,911,911,911,911,911,911,911,911,911,911,911,911,911,911,911, -911,911,911,911,911,911,911,911,911,911,911,911,911,911,911,911, -911,911,911,911,911,911,911,120,120,120,120,120,120,120,120,120, +926,926,926,926,926,926,926,926,926,926,926,926,926,926,926,926, +926,926,926,926,926,926,926,926,926,926,926,926,926,926,926,926, +926,926,926,926,926,926,926,926,926,926,926,926,926,926,926,120, +927,927,927,927,927,927,927,927,927,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 199 */ -601,601,601,601,601,601,601,601,601,601,601,601,601,601,601,601, -601,601,601,601,601,601,601,601,601,601,601,601,601,601,601,601, -601,601,601,601,601,601,601,601,601,601,601,601,601,601,601,601, -601,601,601,601,601,601,601,601,601,601,601,601,601,601,601,601, -601,601,601,601,601,601,601,601,601,601,601,601,601,601,601,601, -601,601,601,601,601,601,601,601,601,601,601,601,601,601,601,601, -601,601,601,601,601,601,601,601,601,601,601,601,601,601,601,601, -601,601,601,601,601,601,601,601,601,601,601,601,601,601,601,601, +928,928,928,928,928,928,928,928,928,928,928,928,928,928,928,928, +928,928,928,928,928,928,928,928,928,928,928,928,928,928,928,928, +928,928,928,928,928,928,928,928,928,928,928,928,928,928,928,928, +928,928,928,928,928,928,928,928,928,928,928,928,928,928,928,928, +928,928,928,928,928,928,928,928,928,928,928,928,928,928,928,928, +928,928,928,928,928,928,928,928,928,928,928,928,928,928,928,928, +928,928,928,928,928,928,928,928,928,928,928,928,928,928,928,928, +928,928,928,928,928,928,928,928,928,928,928,928,928,928,928,928, /* block 200 */ -601,601,601,601,601,601,601,601,601,601,601,601,601,601,601,601, -601,601,601,601,601,601,601,601,601,601,601,601,601,601,601,601, -601,601,601,601,601,601,601,601,601,601,601,601,601,601,601,601, -601,601,601,601,601,601,601,601,601,120,120,120,120,120,120,120, -912,912,912,912,912,912,912,912,912,912,912,912,912,912,912,912, -912,912,912,912,912,912,912,912,912,912,912,912,912,912,912,120, -913,913,913,913,913,913,913,913,913,913,120,120,120,120,914,914, -120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, - -/* block 201 */ +928,928,928,928,928,928,928,928,928,928,928,928,928,928,928,928, +928,928,928,928,928,928,928,928,928,928,928,928,928,928,928,928, +928,928,928,928,928,928,928,928,928,928,928,928,928,928,928,928, +928,928,928,928,928,928,928,928,928,928,928,928,928,928,928,928, +928,928,928,928,928,928,928,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -915,915,915,915,915,915,915,915,915,915,915,915,915,915,915,915, -915,915,915,915,915,915,915,915,915,915,915,915,915,915,120,120, -916,916,916,916,916,917,120,120,120,120,120,120,120,120,120,120, + +/* block 201 */ +606,606,606,606,606,606,606,606,606,606,606,606,606,606,606,606, +606,606,606,606,606,606,606,606,606,606,606,606,606,606,606,606, +606,606,606,606,606,606,606,606,606,606,606,606,606,606,606,606, +606,606,606,606,606,606,606,606,606,606,606,606,606,606,606,606, +606,606,606,606,606,606,606,606,606,606,606,606,606,606,606,606, +606,606,606,606,606,606,606,606,606,606,606,606,606,606,606,606, +606,606,606,606,606,606,606,606,606,606,606,606,606,606,606,606, +606,606,606,606,606,606,606,606,606,606,606,606,606,606,606,606, /* block 202 */ -918,918,918,918,918,918,918,918,918,918,918,918,918,918,918,918, -918,918,918,918,918,918,918,918,918,918,918,918,918,918,918,918, -918,918,918,918,918,918,918,918,918,918,918,918,918,918,918,918, -919,919,919,919,919,919,919,920,920,920,920,920,921,921,921,921, -922,922,922,922,920,921,120,120,120,120,120,120,120,120,120,120, -923,923,923,923,923,923,923,923,923,923,120,924,924,924,924,924, -924,924,120,918,918,918,918,918,918,918,918,918,918,918,918,918, -918,918,918,918,918,918,918,918,120,120,120,120,120,918,918,918, +606,606,606,606,606,606,606,606,606,606,606,606,606,606,606,606, +606,606,606,606,606,606,606,606,606,606,606,606,606,606,606,606, +606,606,606,606,606,606,606,606,606,606,606,606,606,606,606,606, +606,606,606,606,606,606,606,606,606,120,120,120,120,120,120,120, +929,929,929,929,929,929,929,929,929,929,929,929,929,929,929,929, +929,929,929,929,929,929,929,929,929,929,929,929,929,929,929,120, +930,930,930,930,930,930,930,930,930,930,120,120,120,120,931,931, +932,932,932,932,932,932,932,932,932,932,932,932,932,932,932,932, /* block 203 */ -918,918,918,918,918,918,918,918,918,918,918,918,918,918,918,918, +932,932,932,932,932,932,932,932,932,932,932,932,932,932,932,932, +932,932,932,932,932,932,932,932,932,932,932,932,932,932,932,932, +932,932,932,932,932,932,932,932,932,932,932,932,932,932,932,932, +932,932,932,932,932,932,932,932,932,932,932,932,932,932,932,120, +933,933,933,933,933,933,933,933,933,933,120,120,120,120,120,120, +934,934,934,934,934,934,934,934,934,934,934,934,934,934,934,934, +934,934,934,934,934,934,934,934,934,934,934,934,934,934,120,120, +935,935,935,935,935,936,120,120,120,120,120,120,120,120,120,120, + +/* block 204 */ +937,937,937,937,937,937,937,937,937,937,937,937,937,937,937,937, +937,937,937,937,937,937,937,937,937,937,937,937,937,937,937,937, +937,937,937,937,937,937,937,937,937,937,937,937,937,937,937,937, +938,938,938,938,938,938,938,939,939,939,939,939,940,940,940,940, +941,941,941,941,939,940,120,120,120,120,120,120,120,120,120,120, +942,942,942,942,942,942,942,942,942,942,120,943,943,943,943,943, +943,943,120,937,937,937,937,937,937,937,937,937,937,937,937,937, +937,937,937,937,937,937,937,937,120,120,120,120,120,937,937,937, + +/* block 205 */ +937,937,937,937,937,937,937,937,937,937,937,937,937,937,937,937, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, @@ -3758,19 +3804,19 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 71936 bytes, block = 128 */ 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -/* block 204 */ +/* block 206 */ 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -925,925,925,925,925,925,925,925,925,925,925,925,925,925,925,925, -925,925,925,925,925,925,925,925,925,925,925,925,925,925,925,925, -926,926,926,926,926,926,926,926,926,926,926,926,926,926,926,926, -926,926,926,926,926,926,926,926,926,926,926,926,926,926,926,926, +944,944,944,944,944,944,944,944,944,944,944,944,944,944,944,944, +944,944,944,944,944,944,944,944,944,944,944,944,944,944,944,944, +945,945,945,945,945,945,945,945,945,945,945,945,945,945,945,945, +945,945,945,945,945,945,945,945,945,945,945,945,945,945,945,945, -/* block 205 */ -927,927,927,927,927,927,927,927,927,927,927,927,927,927,927,927, -927,927,927,927,927,927,927,928,928,928,928,120,120,120,120,120, +/* block 207 */ +946,946,946,946,946,946,946,946,946,946,946,946,946,946,946,946, +946,946,946,946,946,946,946,947,947,947,947,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, @@ -3778,68 +3824,68 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 71936 bytes, block = 128 */ 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -/* block 206 */ -929,929,929,929,929,929,929,929,929,929,929,929,929,929,929,929, -929,929,929,929,929,929,929,929,929,929,929,929,929,929,929,929, -929,929,929,929,929,929,929,929,929,929,929,929,929,929,929,929, -929,929,929,929,929,929,929,929,929,929,929,929,929,929,929,929, -929,929,929,929,929,929,929,929,929,929,929,120,120,120,120,930, -929,931,931,931,931,931,931,931,931,931,931,931,931,931,931,931, -931,931,931,931,931,931,931,931,931,931,931,931,931,931,931,931, -931,931,931,931,931,931,931,931,931,931,931,931,931,931,931,931, +/* block 208 */ +948,948,948,948,948,948,948,948,948,948,948,948,948,948,948,948, +948,948,948,948,948,948,948,948,948,948,948,948,948,948,948,948, +948,948,948,948,948,948,948,948,948,948,948,948,948,948,948,948, +948,948,948,948,948,948,948,948,948,948,948,948,948,948,948,948, +948,948,948,948,948,948,948,948,948,948,948,120,120,120,120,949, +948,950,950,950,950,950,950,950,950,950,950,950,950,950,950,950, +950,950,950,950,950,950,950,950,950,950,950,950,950,950,950,950, +950,950,950,950,950,950,950,950,950,950,950,950,950,950,950,950, -/* block 207 */ -931,931,931,931,931,931,931,931,120,120,120,120,120,120,120,930, -930,930,930,932,932,932,932,932,932,932,932,932,932,932,932,932, +/* block 209 */ +950,950,950,950,950,950,950,950,120,120,120,120,120,120,120,949, +949,949,949,951,951,951,951,951,951,951,951,951,951,951,951,951, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -933,934, 5,111,935,120,120,120,120,120,120,120,120,120,120,120, -936,936,120,120,120,120,120,120,120,120,120,120,120,120,120,120, - -/* block 208 */ -937,937,937,937,937,937,937,937,937,937,937,937,937,937,937,937, -937,937,937,937,937,937,937,937,937,937,937,937,937,937,937,937, -937,937,937,937,937,937,937,937,937,937,937,937,937,937,937,937, -937,937,937,937,937,937,937,937,937,937,937,937,937,937,937,937, -937,937,937,937,937,937,937,937,937,937,937,937,937,937,937,937, -937,937,937,937,937,937,937,937,937,937,937,937,937,937,937,937, -937,937,937,937,937,937,937,937,937,937,937,937,937,937,937,937, -937,937,937,937,937,937,937,937,937,937,937,937,937,937,937,937, - -/* block 209 */ -937,937,937,937,937,937,937,937,937,937,937,937,937,937,937,937, -937,937,937,937,937,937,937,937,937,937,937,937,937,937,937,937, -937,937,937,937,937,937,937,937,937,937,937,937,937,937,937,937, -937,937,937,937,937,937,937,937,937,937,937,937,937,937,937,937, -937,937,937,937,937,937,937,937,937,937,937,937,937,937,937,937, -937,937,937,937,937,937,937,937,937,937,937,937,937,937,937,937, -937,937,937,937,937,937,937,937,937,937,937,937,937,937,937,937, -937,937,937,937,937,937,937,937,120,120,120,120,120,120,120,120, +952,953,954,562,955,120,120,120,120,120,120,120,120,120,120,120, +956,956,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 210 */ -938,938,938,938,938,938,938,938,938,938,938,938,938,938,938,938, -938,938,938,938,938,938,938,938,938,938,938,938,938,938,938,938, -938,938,938,938,938,938,938,938,938,938,938,938,938,938,938,938, -938,938,938,938,938,938,938,938,938,938,938,938,938,938,938,938, -938,938,938,938,938,938,938,938,938,938,938,938,938,938,938,938, -938,938,938,938,938,938,938,938,938,938,938,938,938,938,938,938, -938,938,938,938,938,938,938,938,938,938,938,938,938,938,938,938, -938,938,938,938,938,938,938,938,938,938,938,938,938,938,938,938, +957,957,957,957,957,957,957,957,957,957,957,957,957,957,957,957, +957,957,957,957,957,957,957,957,957,957,957,957,957,957,957,957, +957,957,957,957,957,957,957,957,957,957,957,957,957,957,957,957, +957,957,957,957,957,957,957,957,957,957,957,957,957,957,957,957, +957,957,957,957,957,957,957,957,957,957,957,957,957,957,957,957, +957,957,957,957,957,957,957,957,957,957,957,957,957,957,957,957, +957,957,957,957,957,957,957,957,957,957,957,957,957,957,957,957, +957,957,957,957,957,957,957,957,957,957,957,957,957,957,957,957, /* block 211 */ -938,938,938,938,938,938,938,938,938,938,938,938,938,938,938,938, -938,938,938,938,938,938,938,938,938,938,938,938,938,938,938,938, -938,938,938,938,938,938,938,938,938,938,938,938,938,938,938,938, -938,938,938,938,938,938,938,938,938,938,938,938,938,938,938,938, -938,938,938,938,938,938,938,938,938,938,938,938,938,938,938,938, -938,938,938,938,938,938,120,120,120,120,120,120,120,120,120,120, +957,957,957,957,957,957,957,957,957,957,957,957,957,957,957,957, +957,957,957,957,957,957,957,957,957,957,957,957,957,957,957,957, +957,957,957,957,957,957,957,957,957,957,957,957,957,957,957,957, +957,957,957,957,957,957,957,957,957,957,957,957,957,957,957,957, +957,957,957,957,957,957,957,957,957,957,957,957,957,957,957,957, +957,957,957,957,957,957,957,957,957,957,957,957,957,957,957,957, +957,957,957,957,957,957,957,957,957,957,957,957,957,957,957,957, +957,957,957,957,957,957,957,957,120,120,120,120,120,120,120,120, + +/* block 212 */ +958,958,958,958,958,958,958,958,958,958,958,958,958,958,958,958, +958,958,958,958,958,958,958,958,958,958,958,958,958,958,958,958, +958,958,958,958,958,958,958,958,958,958,958,958,958,958,958,958, +958,958,958,958,958,958,958,958,958,958,958,958,958,958,958,958, +958,958,958,958,958,958,958,958,958,958,958,958,958,958,958,958, +958,958,958,958,958,958,958,958,958,958,958,958,958,958,958,958, +958,958,958,958,958,958,958,958,958,958,958,958,958,958,958,958, +958,958,958,958,958,958,958,958,958,958,958,958,958,958,958,958, + +/* block 213 */ +958,958,958,958,958,958,958,958,958,958,958,958,958,958,958,958, +958,958,958,958,958,958,958,958,958,958,958,958,958,958,958,958, +958,958,958,958,958,958,958,958,958,958,958,958,958,958,958,958, +958,958,958,958,958,958,958,958,958,958,958,958,958,958,958,958, +958,958,958,958,958,958,958,958,958,958,958,958,958,958,958,958, +958,958,958,958,958,958,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -/* block 212 */ -937,937,937,937,937,937,937,937,937,120,120,120,120,120,120,120, +/* block 214 */ +957,957,957,957,957,957,957,957,957,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, @@ -3848,77 +3894,107 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 71936 bytes, block = 128 */ 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -/* block 213 */ -578,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, -573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, -573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, -573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, -573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, -573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, -573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, -573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, - -/* block 214 */ -573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, -573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, -573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, -573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, -573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, -573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, -573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, -573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, - /* block 215 */ -573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, -573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -573,573,573,120,120,120,120,120,120,120,120,120,120,120,120,120, -120,120,120,120,578,578,578,578,120,120,120,120,120,120,120,120, -939,939,939,939,939,939,939,939,939,939,939,939,939,939,939,939, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +584,584,584,584,120,584,584,584,584,584,584,584,120,584,584,120, /* block 216 */ -939,939,939,939,939,939,939,939,939,939,939,939,939,939,939,939, -939,939,939,939,939,939,939,939,939,939,939,939,939,939,939,939, -939,939,939,939,939,939,939,939,939,939,939,939,939,939,939,939, -939,939,939,939,939,939,939,939,939,939,939,939,939,939,939,939, -939,939,939,939,939,939,939,939,939,939,939,939,939,939,939,939, -939,939,939,939,939,939,939,939,939,939,939,939,939,939,939,939, -939,939,939,939,939,939,939,939,939,939,939,939,939,939,939,939, -939,939,939,939,939,939,939,939,939,939,939,939,939,939,939,939, +583,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, +578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, +578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, +578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, +578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, +578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, +578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, +578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, /* block 217 */ -939,939,939,939,939,939,939,939,939,939,939,939,939,939,939,939, -939,939,939,939,939,939,939,939,939,939,939,939,939,939,939,939, -939,939,939,939,939,939,939,939,939,939,939,939,939,939,939,939, -939,939,939,939,939,939,939,939,939,939,939,939,939,939,939,939, -939,939,939,939,939,939,939,939,939,939,939,939,939,939,939,939, -939,939,939,939,939,939,939,939,939,939,939,939,939,939,939,939, -939,939,939,939,939,939,939,939,939,939,939,939,939,939,939,939, -939,939,939,939,939,939,939,939,939,939,939,939,120,120,120,120, +578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, +578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, +578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, +578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, +578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, +578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, +578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, +578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, /* block 218 */ -940,940,940,940,940,940,940,940,940,940,940,940,940,940,940,940, -940,940,940,940,940,940,940,940,940,940,940,940,940,940,940,940, -940,940,940,940,940,940,940,940,940,940,940,940,940,940,940,940, -940,940,940,940,940,940,940,940,940,940,940,940,940,940,940,940, -940,940,940,940,940,940,940,940,940,940,940,940,940,940,940,940, -940,940,940,940,940,940,940,940,940,940,940,940,940,940,940,940, -940,940,940,940,940,940,940,940,940,940,940,120,120,120,120,120, -940,940,940,940,940,940,940,940,940,940,940,940,940,120,120,120, +578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, +578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, +583,583,583,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +578,578,578,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,583,583,583,583,120,120,120,120,120,120,120,120, +959,959,959,959,959,959,959,959,959,959,959,959,959,959,959,959, /* block 219 */ -940,940,940,940,940,940,940,940,940,120,120,120,120,120,120,120, -940,940,940,940,940,940,940,940,940,940,120,120,941,942,942,943, -944,944,944,944,120,120,120,120,120,120,120,120,120,120,120,120, +959,959,959,959,959,959,959,959,959,959,959,959,959,959,959,959, +959,959,959,959,959,959,959,959,959,959,959,959,959,959,959,959, +959,959,959,959,959,959,959,959,959,959,959,959,959,959,959,959, +959,959,959,959,959,959,959,959,959,959,959,959,959,959,959,959, +959,959,959,959,959,959,959,959,959,959,959,959,959,959,959,959, +959,959,959,959,959,959,959,959,959,959,959,959,959,959,959,959, +959,959,959,959,959,959,959,959,959,959,959,959,959,959,959,959, +959,959,959,959,959,959,959,959,959,959,959,959,959,959,959,959, + +/* block 220 */ +959,959,959,959,959,959,959,959,959,959,959,959,959,959,959,959, +959,959,959,959,959,959,959,959,959,959,959,959,959,959,959,959, +959,959,959,959,959,959,959,959,959,959,959,959,959,959,959,959, +959,959,959,959,959,959,959,959,959,959,959,959,959,959,959,959, +959,959,959,959,959,959,959,959,959,959,959,959,959,959,959,959, +959,959,959,959,959,959,959,959,959,959,959,959,959,959,959,959, +959,959,959,959,959,959,959,959,959,959,959,959,959,959,959,959, +959,959,959,959,959,959,959,959,959,959,959,959,120,120,120,120, + +/* block 221 */ +960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960, +960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960, +960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960, +960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960, +960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960, +960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960, +960,960,960,960,960,960,960,960,960,960,960,120,120,120,120,120, +960,960,960,960,960,960,960,960,960,960,960,960,960,120,120,120, + +/* block 222 */ +960,960,960,960,960,960,960,960,960,120,120,120,120,120,120,120, +960,960,960,960,960,960,960,960,960,960,120,120,961,962,962,963, +964,964,964,964,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -/* block 220 */ +/* block 223 */ +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, +113,113,113,113,113,113,113,113,113,113,113,113,113,113,120,120, +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, +113,113,113,113,113,113,113,120,120,120,120,120,120,120,120,120, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + +/* block 224 */ + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, + +/* block 225 */ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, @@ -3928,37 +4004,37 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 71936 bytes, block = 128 */ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,120,120,120,120,120,120,120,120,120,120, -/* block 221 */ +/* block 226 */ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,120,120, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20,945,946,113,113,113, 20, 20, 20,946,945,945, -945,945,945, 24, 24, 24, 24, 24, 24, 24, 24,113,113,113,113,113, + 20, 20, 20, 20, 20,965,966,113,113,113, 20, 20, 20,966,965,965, +965,965,965, 24, 24, 24, 24, 24, 24, 24, 24,113,113,113,113,113, -/* block 222 */ +/* block 227 */ 113,113,113, 20, 20,113,113,113,113,113,113,113, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,113,113,113,113, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20,120,120,120,120,120,120,120, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -/* block 223 */ -685,685,685,685,685,685,685,685,685,685,685,685,685,685,685,685, -685,685,685,685,685,685,685,685,685,685,685,685,685,685,685,685, -685,685,685,685,685,685,685,685,685,685,685,685,685,685,685,685, -685,685,685,685,685,685,685,685,685,685,685,685,685,685,685,685, -685,685,947,947,947,685,120,120,120,120,120,120,120,120,120,120, +/* block 228 */ +692,692,692,692,692,692,692,692,692,692,692,692,692,692,692,692, +692,692,692,692,692,692,692,692,692,692,692,692,692,692,692,692, +692,692,692,692,692,692,692,692,692,692,692,692,692,692,692,692, +692,692,692,692,692,692,692,692,692,692,692,692,692,692,692,692, +692,692,967,967,967,692,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -/* block 224 */ +/* block 229 */ 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, @@ -3968,187 +4044,207 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 71936 bytes, block = 128 */ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,120,120,120,120,120,120,120,120,120,120,120,120, -/* block 225 */ +/* block 230 */ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,120,120,120,120,120,120,120,120,120, -582,582,582,582,582,582,582,582,582,582,582,582,582,582,582,582, -582,582, 25, 25, 25, 25, 25, 25, 25,120,120,120,120,120,120,120, +587,587,587,587,587,587,587,587,587,587,587,587,587,587,587,587, +587,587, 25, 25, 25, 25, 25, 25, 25,120,120,120,120,120,120,120, -/* block 226 */ -513,513,513,513,513,513,513,513,513,513,513,513,513,513,513,513, -513,513,513,513,513,513,513,513,513,513,514,514,514,514,514,514, -514,514,514,514,514,514,514,514,514,514,514,514,514,514,514,514, -514,514,514,514,513,513,513,513,513,513,513,513,513,513,513,513, -513,513,513,513,513,513,513,513,513,513,513,513,513,513,514,514, -514,514,514,514,514,120,514,514,514,514,514,514,514,514,514,514, -514,514,514,514,514,514,514,514,513,513,513,513,513,513,513,513, -513,513,513,513,513,513,513,513,513,513,513,513,513,513,513,513, +/* block 231 */ +518,518,518,518,518,518,518,518,518,518,518,518,518,518,518,518, +518,518,518,518,518,518,518,518,518,518,519,519,519,519,519,519, +519,519,519,519,519,519,519,519,519,519,519,519,519,519,519,519, +519,519,519,519,518,518,518,518,518,518,518,518,518,518,518,518, +518,518,518,518,518,518,518,518,518,518,518,518,518,518,519,519, +519,519,519,519,519,120,519,519,519,519,519,519,519,519,519,519, +519,519,519,519,519,519,519,519,518,518,518,518,518,518,518,518, +518,518,518,518,518,518,518,518,518,518,518,518,518,518,518,518, -/* block 227 */ -513,513,514,514,514,514,514,514,514,514,514,514,514,514,514,514, -514,514,514,514,514,514,514,514,514,514,514,514,513,120,513,513, -120,120,513,120,120,513,513,120,120,513,513,513,513,120,513,513, -513,513,513,513,513,513,514,514,514,514,120,514,120,514,514,514, -514,514,514,514,120,514,514,514,514,514,514,514,514,514,514,514, -513,513,513,513,513,513,513,513,513,513,513,513,513,513,513,513, -513,513,513,513,513,513,513,513,513,513,514,514,514,514,514,514, -514,514,514,514,514,514,514,514,514,514,514,514,514,514,514,514, +/* block 232 */ +518,518,519,519,519,519,519,519,519,519,519,519,519,519,519,519, +519,519,519,519,519,519,519,519,519,519,519,519,518,120,518,518, +120,120,518,120,120,518,518,120,120,518,518,518,518,120,518,518, +518,518,518,518,518,518,519,519,519,519,120,519,120,519,519,519, +519,519,519,519,120,519,519,519,519,519,519,519,519,519,519,519, +518,518,518,518,518,518,518,518,518,518,518,518,518,518,518,518, +518,518,518,518,518,518,518,518,518,518,519,519,519,519,519,519, +519,519,519,519,519,519,519,519,519,519,519,519,519,519,519,519, -/* block 228 */ -514,514,514,514,513,513,120,513,513,513,513,120,120,513,513,513, -513,513,513,513,513,120,513,513,513,513,513,513,513,120,514,514, -514,514,514,514,514,514,514,514,514,514,514,514,514,514,514,514, -514,514,514,514,514,514,514,514,513,513,120,513,513,513,513,120, -513,513,513,513,513,120,513,120,120,120,513,513,513,513,513,513, -513,120,514,514,514,514,514,514,514,514,514,514,514,514,514,514, -514,514,514,514,514,514,514,514,514,514,514,514,513,513,513,513, -513,513,513,513,513,513,513,513,513,513,513,513,513,513,513,513, +/* block 233 */ +519,519,519,519,518,518,120,518,518,518,518,120,120,518,518,518, +518,518,518,518,518,120,518,518,518,518,518,518,518,120,519,519, +519,519,519,519,519,519,519,519,519,519,519,519,519,519,519,519, +519,519,519,519,519,519,519,519,518,518,120,518,518,518,518,120, +518,518,518,518,518,120,518,120,120,120,518,518,518,518,518,518, +518,120,519,519,519,519,519,519,519,519,519,519,519,519,519,519, +519,519,519,519,519,519,519,519,519,519,519,519,518,518,518,518, +518,518,518,518,518,518,518,518,518,518,518,518,518,518,518,518, -/* block 229 */ -513,513,513,513,513,513,514,514,514,514,514,514,514,514,514,514, -514,514,514,514,514,514,514,514,514,514,514,514,514,514,514,514, -513,513,513,513,513,513,513,513,513,513,513,513,513,513,513,513, -513,513,513,513,513,513,513,513,513,513,514,514,514,514,514,514, -514,514,514,514,514,514,514,514,514,514,514,514,514,514,514,514, -514,514,514,514,513,513,513,513,513,513,513,513,513,513,513,513, -513,513,513,513,513,513,513,513,513,513,513,513,513,513,514,514, -514,514,514,514,514,514,514,514,514,514,514,514,514,514,514,514, +/* block 234 */ +518,518,518,518,518,518,519,519,519,519,519,519,519,519,519,519, +519,519,519,519,519,519,519,519,519,519,519,519,519,519,519,519, +518,518,518,518,518,518,518,518,518,518,518,518,518,518,518,518, +518,518,518,518,518,518,518,518,518,518,519,519,519,519,519,519, +519,519,519,519,519,519,519,519,519,519,519,519,519,519,519,519, +519,519,519,519,518,518,518,518,518,518,518,518,518,518,518,518, +518,518,518,518,518,518,518,518,518,518,518,518,518,518,519,519, +519,519,519,519,519,519,519,519,519,519,519,519,519,519,519,519, -/* block 230 */ -514,514,514,514,514,514,514,514,513,513,513,513,513,513,513,513, -513,513,513,513,513,513,513,513,513,513,513,513,513,513,513,513, -513,513,514,514,514,514,514,514,514,514,514,514,514,514,514,514, -514,514,514,514,514,514,514,514,514,514,514,514,513,513,513,513, -513,513,513,513,513,513,513,513,513,513,513,513,513,513,513,513, -513,513,513,513,513,513,514,514,514,514,514,514,514,514,514,514, -514,514,514,514,514,514,514,514,514,514,514,514,514,514,514,514, -513,513,513,513,513,513,513,513,513,513,513,513,513,513,513,513, +/* block 235 */ +519,519,519,519,519,519,519,519,518,518,518,518,518,518,518,518, +518,518,518,518,518,518,518,518,518,518,518,518,518,518,518,518, +518,518,519,519,519,519,519,519,519,519,519,519,519,519,519,519, +519,519,519,519,519,519,519,519,519,519,519,519,518,518,518,518, +518,518,518,518,518,518,518,518,518,518,518,518,518,518,518,518, +518,518,518,518,518,518,519,519,519,519,519,519,519,519,519,519, +519,519,519,519,519,519,519,519,519,519,519,519,519,519,519,519, +518,518,518,518,518,518,518,518,518,518,518,518,518,518,518,518, -/* block 231 */ -513,513,513,513,513,513,513,513,513,513,514,514,514,514,514,514, -514,514,514,514,514,514,514,514,514,514,514,514,514,514,514,514, -514,514,514,514,514,514,120,120,513,513,513,513,513,513,513,513, -513,513,513,513,513,513,513,513,513,513,513,513,513,513,513,513, -513, 9,514,514,514,514,514,514,514,514,514,514,514,514,514,514, -514,514,514,514,514,514,514,514,514,514,514, 9,514,514,514,514, -514,514,513,513,513,513,513,513,513,513,513,513,513,513,513,513, -513,513,513,513,513,513,513,513,513,513,513, 9,514,514,514,514, +/* block 236 */ +518,518,518,518,518,518,518,518,518,518,519,519,519,519,519,519, +519,519,519,519,519,519,519,519,519,519,519,519,519,519,519,519, +519,519,519,519,519,519,120,120,518,518,518,518,518,518,518,518, +518,518,518,518,518,518,518,518,518,518,518,518,518,518,518,518, +518, 9,519,519,519,519,519,519,519,519,519,519,519,519,519,519, +519,519,519,519,519,519,519,519,519,519,519, 9,519,519,519,519, +519,519,518,518,518,518,518,518,518,518,518,518,518,518,518,518, +518,518,518,518,518,518,518,518,518,518,518, 9,519,519,519,519, -/* block 232 */ -514,514,514,514,514,514,514,514,514,514,514,514,514,514,514,514, -514,514,514,514,514, 9,514,514,514,514,514,514,513,513,513,513, -513,513,513,513,513,513,513,513,513,513,513,513,513,513,513,513, -513,513,513,513,513, 9,514,514,514,514,514,514,514,514,514,514, -514,514,514,514,514,514,514,514,514,514,514,514,514,514,514, 9, -514,514,514,514,514,514,513,513,513,513,513,513,513,513,513,513, -513,513,513,513,513,513,513,513,513,513,513,513,513,513,513, 9, -514,514,514,514,514,514,514,514,514,514,514,514,514,514,514,514, +/* block 237 */ +519,519,519,519,519,519,519,519,519,519,519,519,519,519,519,519, +519,519,519,519,519, 9,519,519,519,519,519,519,518,518,518,518, +518,518,518,518,518,518,518,518,518,518,518,518,518,518,518,518, +518,518,518,518,518, 9,519,519,519,519,519,519,519,519,519,519, +519,519,519,519,519,519,519,519,519,519,519,519,519,519,519, 9, +519,519,519,519,519,519,518,518,518,518,518,518,518,518,518,518, +518,518,518,518,518,518,518,518,518,518,518,518,518,518,518, 9, +519,519,519,519,519,519,519,519,519,519,519,519,519,519,519,519, -/* block 233 */ -514,514,514,514,514,514,514,514,514, 9,514,514,514,514,514,514, -513,513,513,513,513,513,513,513,513,513,513,513,513,513,513,513, -513,513,513,513,513,513,513,513,513, 9,514,514,514,514,514,514, -514,514,514,514,514,514,514,514,514,514,514,514,514,514,514,514, -514,514,514, 9,514,514,514,514,514,514,513,514,120,120, 11, 11, +/* block 238 */ +519,519,519,519,519,519,519,519,519, 9,519,519,519,519,519,519, +518,518,518,518,518,518,518,518,518,518,518,518,518,518,518,518, +518,518,518,518,518,518,518,518,518, 9,519,519,519,519,519,519, +519,519,519,519,519,519,519,519,519,519,519,519,519,519,519,519, +519,519,519, 9,519,519,519,519,519,519,518,519,120,120, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, -/* block 234 */ -948,948,948,948,948,948,948,948,948,948,948,948,948,948,948,948, -948,948,948,948,948,948,948,948,948,948,948,948,948,948,948,948, -948,948,948,948,948,948,948,948,948,948,948,948,948,948,948,948, -948,948,948,948,948,948,948,948,948,948,948,948,948,948,948,948, -948,948,948,948,948,948,948,948,948,948,948,948,948,948,948,948, -948,948,948,948,948,948,948,948,948,948,948,948,948,948,948,948, -948,948,948,948,948,948,948,948,948,948,948,948,948,948,948,948, -948,948,948,948,948,948,948,948,948,948,948,948,948,948,948,948, +/* block 239 */ +968,968,968,968,968,968,968,968,968,968,968,968,968,968,968,968, +968,968,968,968,968,968,968,968,968,968,968,968,968,968,968,968, +968,968,968,968,968,968,968,968,968,968,968,968,968,968,968,968, +968,968,968,968,968,968,968,968,968,968,968,968,968,968,968,968, +968,968,968,968,968,968,968,968,968,968,968,968,968,968,968,968, +968,968,968,968,968,968,968,968,968,968,968,968,968,968,968,968, +968,968,968,968,968,968,968,968,968,968,968,968,968,968,968,968, +968,968,968,968,968,968,968,968,968,968,968,968,968,968,968,968, -/* block 235 */ -949,949,949,949,949,949,949,949,949,949,949,949,949,949,949,949, -949,949,949,949,949,949,949,949,949,949,949,949,949,949,949,949, -949,949,949,949,949,949,949,949,949,949,949,949,949,949,949,949, -949,949,949,949,949,949,949,948,948,948,948,949,949,949,949,949, -949,949,949,949,949,949,949,949,949,949,949,949,949,949,949,949, -949,949,949,949,949,949,949,949,949,949,949,949,949,949,949,949, -949,949,949,949,949,949,949,949,949,949,949,949,949,948,948,948, -948,948,948,948,948,949,948,948,948,948,948,948,948,948,948,948, +/* block 240 */ +969,969,969,969,969,969,969,969,969,969,969,969,969,969,969,969, +969,969,969,969,969,969,969,969,969,969,969,969,969,969,969,969, +969,969,969,969,969,969,969,969,969,969,969,969,969,969,969,969, +969,969,969,969,969,969,969,968,968,968,968,969,969,969,969,969, +969,969,969,969,969,969,969,969,969,969,969,969,969,969,969,969, +969,969,969,969,969,969,969,969,969,969,969,969,969,969,969,969, +969,969,969,969,969,969,969,969,969,969,969,969,969,968,968,968, +968,968,968,968,968,969,968,968,968,968,968,968,968,968,968,968, -/* block 236 */ -948,948,948,948,949,948,948,950,950,950,950,950,120,120,120,120, -120,120,120,120,120,120,120,120,120,120,120,949,949,949,949,949, -120,949,949,949,949,949,949,949,949,949,949,949,949,949,949,949, +/* block 241 */ +968,968,968,968,969,968,968,970,970,970,970,970,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,969,969,969,969,969, +120,969,969,969,969,969,969,969,969,969,969,969,969,969,969,969, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -/* block 237 */ -951,951,951,951,951,951,951,120,951,951,951,951,951,951,951,951, -951,951,951,951,951,951,951,951,951,120,120,951,951,951,951,951, -951,951,120,951,951,120,951,951,951,951,951,120,120,120,120,120, +/* block 242 */ + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 22, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -/* block 238 */ -952,952,952,952,952,952,952,952,952,952,952,952,952,952,952,952, -952,952,952,952,952,952,952,952,952,952,952,952,952,952,952,952, -952,952,952,952,952,952,952,952,952,952,952,952,952,120,120,120, -953,953,953,953,953,953,953,954,954,954,954,954,954,954,120,120, -955,955,955,955,955,955,955,955,955,955,120,120,120,120,952,956, +/* block 243 */ +971,971,971,971,971,971,971,120,971,971,971,971,971,971,971,971, +971,971,971,971,971,971,971,971,971,120,120,971,971,971,971,971, +971,971,120,971,971,120,971,971,971,971,971,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -/* block 239 */ +/* block 244 */ +972,972,972,972,972,972,972,972,972,972,972,972,972,972,972,972, +972,972,972,972,972,972,972,972,972,972,972,972,972,972,972,972, +972,972,972,972,972,972,972,972,972,972,972,972,972,120,120,120, +973,973,973,973,973,973,973,974,974,974,974,974,974,974,120,120, +975,975,975,975,975,975,975,975,975,975,120,120,120,120,972,976, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, + +/* block 245 */ 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -957,957,957,957,957,957,957,957,957,957,957,957,957,957,957,957, -957,957,957,957,957,957,957,957,957,957,957,957,957,957,957,957, -957,957,957,957,957,957,957,957,957,957,957,957,958,958,958,958, -959,959,959,959,959,959,959,959,959,959,120,120,120,120,120,960, +977,977,977,977,977,977,977,977,977,977,977,977,977,977,977,977, +977,977,977,977,977,977,977,977,977,977,977,977,977,977,978,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +979,979,979,979,979,979,979,979,979,979,979,979,979,979,979,979, +979,979,979,979,979,979,979,979,979,979,979,979,979,979,979,979, +979,979,979,979,979,979,979,979,979,979,979,979,980,980,980,980, +981,981,981,981,981,981,981,981,981,981,120,120,120,120,120,982, -/* block 240 */ -961,961,961,961,961,961,961,961,961,961,961,961,961,961,961,961, -961,961,961,961,961,961,961,961,961,961,961,961,961,961,961,961, -961,961,961,961,961,961,961,961,961,961,961,961,961,961,961,961, -961,961,961,961,961,961,961,961,961,961,961,961,961,961,961,961, -961,961,961,961,961,961,961,961,961,961,961,961,961,961,961,961, -961,961,961,961,961,961,961,961,961,961,961,961,961,961,961,961, -961,961,961,961,961,961,961,961,961,961,961,961,961,961,961,961, -961,961,961,961,961,961,961,961,961,961,961,961,961,961,961,961, +/* block 246 */ +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +361,361,361,361,361,361,361,120,361,361,361,361,120,361,361,120, +361,361,361,361,361,361,361,361,361,361,361,361,361,361,361,120, -/* block 241 */ -961,961,961,961,961,961,961,961,961,961,961,961,961,961,961,961, -961,961,961,961,961,961,961,961,961,961,961,961,961,961,961,961, -961,961,961,961,961,961,961,961,961,961,961,961,961,961,961,961, -961,961,961,961,961,961,961,961,961,961,961,961,961,961,961,961, -961,961,961,961,961,120,120,962,962,962,962,962,962,962,962,962, -963,963,963,963,963,963,963,120,120,120,120,120,120,120,120,120, +/* block 247 */ +983,983,983,983,983,983,983,983,983,983,983,983,983,983,983,983, +983,983,983,983,983,983,983,983,983,983,983,983,983,983,983,983, +983,983,983,983,983,983,983,983,983,983,983,983,983,983,983,983, +983,983,983,983,983,983,983,983,983,983,983,983,983,983,983,983, +983,983,983,983,983,983,983,983,983,983,983,983,983,983,983,983, +983,983,983,983,983,983,983,983,983,983,983,983,983,983,983,983, +983,983,983,983,983,983,983,983,983,983,983,983,983,983,983,983, +983,983,983,983,983,983,983,983,983,983,983,983,983,983,983,983, + +/* block 248 */ +983,983,983,983,983,983,983,983,983,983,983,983,983,983,983,983, +983,983,983,983,983,983,983,983,983,983,983,983,983,983,983,983, +983,983,983,983,983,983,983,983,983,983,983,983,983,983,983,983, +983,983,983,983,983,983,983,983,983,983,983,983,983,983,983,983, +983,983,983,983,983,120,120,984,984,984,984,984,984,984,984,984, +985,985,985,985,985,985,985,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -/* block 242 */ -964,964,964,964,964,964,964,964,964,964,964,964,964,964,964,964, -964,964,964,964,964,964,964,964,964,964,964,964,964,964,964,964, -964,964,965,965,965,965,965,965,965,965,965,965,965,965,965,965, -965,965,965,965,965,965,965,965,965,965,965,965,965,965,965,965, -965,965,965,965,966,966,966,966,966,966,966,967,120,120,120,120, -968,968,968,968,968,968,968,968,968,968,120,120,120,120,969,969, +/* block 249 */ +986,986,986,986,986,986,986,986,986,986,986,986,986,986,986,986, +986,986,986,986,986,986,986,986,986,986,986,986,986,986,986,986, +986,986,987,987,987,987,987,987,987,987,987,987,987,987,987,987, +987,987,987,987,987,987,987,987,987,987,987,987,987,987,987,987, +987,987,987,987,988,988,988,988,988,988,988,989,120,120,120,120, +990,990,990,990,990,990,990,990,990,990,120,120,120,120,991,991, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -/* block 243 */ +/* block 250 */ 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, @@ -4158,7 +4254,7 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 71936 bytes, block = 128 */ 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, -/* block 244 */ +/* block 251 */ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 20, 25, 25, 25, @@ -4168,7 +4264,7 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 71936 bytes, block = 128 */ 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -/* block 245 */ +/* block 252 */ 120, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 20, 25, @@ -4178,47 +4274,47 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 71936 bytes, block = 128 */ 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -/* block 246 */ -224,224,224,224,120,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -120,224,224,120,224,120,120,224,120,224,224,224,224,224,224,224, -224,224,224,120,224,224,224,224,120,224,120,224,120,120,120,120, -120,120,224,120,120,120,120,224,120,224,120,224,120,224,224,224, -120,224,224,120,224,120,120,224,120,224,120,224,120,224,120,224, -120,224,224,120,224,120,120,224,224,224,224,120,224,224,224,224, -224,224,224,120,224,224,224,224,120,224,224,224,224,120,224,120, +/* block 253 */ +225,225,225,225,120,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +120,225,225,120,225,120,120,225,120,225,225,225,225,225,225,225, +225,225,225,120,225,225,225,225,120,225,120,225,120,120,120,120, +120,120,225,120,120,120,120,225,120,225,120,225,120,225,225,225, +120,225,225,120,225,120,120,225,120,225,120,225,120,225,120,225, +120,225,225,120,225,120,120,225,225,225,225,120,225,225,225,225, +225,225,225,120,225,225,225,225,120,225,225,225,225,120,225,120, -/* block 247 */ -224,224,224,224,224,224,224,224,224,224,120,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,120,120,120,120, -120,224,224,224,120,224,224,224,224,224,120,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,120,120,120,120, +/* block 254 */ +225,225,225,225,225,225,225,225,225,225,120,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,120,120,120,120, +120,225,225,225,120,225,225,225,225,225,120,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 217,217,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -/* block 248 */ +/* block 255 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,970,970,970,970, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,992,992,992,992, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, -/* block 249 */ +/* block 256 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21,970,970,970,970,970,970,970,970,970,970,970,970, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,970, -970, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, -970, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, -970, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21,992,992,992,992,992,992,992,992,992,992,992,992, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,992, +992, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, +992, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, +992, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21,970,970,970,970,970,970,970,970,970,970, + 21, 21, 21, 21, 21, 21,992,992,992,992,992,992,992,992,992,992, -/* block 250 */ +/* block 257 */ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 21, 21, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, @@ -4228,37 +4324,37 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 71936 bytes, block = 128 */ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, -/* block 251 */ +/* block 258 */ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21,970,970, -970,970,970,970,970,970,970,970,970,970,970,970,970,970,970,970, -970,970,970,970,970,970,970,970,970,970,970,970,970,970,970,970, -970,970,970,970,970,970,970,970,970,970,970,970,970,970,970,970, -970,970,970,970,970,970,971,971,971,971,971,971,971,971,971,971, -971,971,971,971,971,971,971,971,971,971,971,971,971,971,971,971, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21,992,992, +992,992,992,992,992,992,992,992,992,992,992,992,992,992,992,992, +992,992,992,992,992,992,992,992,992,992,992,992,992,992,992,992, +992,992,992,992,992,992,992,992,992,992,992,992,992,992,992,992, +992,992,992,992,992,992,993,993,993,993,993,993,993,993,993,993, +993,993,993,993,993,993,993,993,993,993,993,993,993,993,993,993, -/* block 252 */ -972, 21, 21,970,970,970,970,970,970,970,970,970,970,970,970,970, +/* block 259 */ +994, 21, 21,992,992,992,992,992,992,992,992,992,992,992,992,992, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, - 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 20,970,970,970,970, - 20, 20, 20, 20, 20, 20, 20, 20, 20,970,970,970,970,970,970,970, -584,584,970,970,970,970,970,970,970,970,970,970,970,970,970,970, - 21, 21, 21, 21, 21, 21,970,970,970,970,970,970,970,970,970,970, -970,970,970,970,970,970,970,970,970,970,970,970,970,970,970,970, + 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 20,992,992,992,992, + 20, 20, 20, 20, 20, 20, 20, 20, 20,992,992,992,992,992,992,992, +589,589,992,992,992,992,992,992,992,992,992,992,992,992,992,992, + 21, 21, 21, 21, 21, 21,992,992,992,992,992,992,992,992,992,992, +992,992,992,992,992,992,992,992,992,992,992,992,992,992,992,992, -/* block 253 */ -970,970,970,970,970,970,970,970,970,970,970,970,970,970,970,970, -970,970,970,970,970,970,970,970,970,970,970,970,970,970,970,970, -970,970,970,970,970,970,970,970,970,970,970,970,970,970,970,970, -970,970,970,970,970,970,970,970,970,970,970,970,970,970,970,970, -970,970,970,970,970,970,970,970,970,970,970,970,970,970,970,970, -970,970,970,970,970,970,970,970,970,970,970,970,970,970,970,970, -970,970,970,970,970,970,970,970,970,970,970,970,970,970,970,970, -970,970,970,970,970,970,970,970,970,970,970,970,970,970,970,970, +/* block 260 */ +992,992,992,992,992,992,992,992,992,992,992,992,992,992,992,992, +992,992,992,992,992,992,992,992,992,992,992,992,992,992,992,992, +992,992,992,992,992,992,992,992,992,992,992,992,992,992,992,992, +992,992,992,992,992,992,992,992,992,992,992,992,992,992,992,992, +992,992,992,992,992,992,992,992,992,992,992,992,992,992,992,992, +992,992,992,992,992,992,992,992,992,992,992,992,992,992,992,992, +992,992,992,992,992,992,992,992,992,992,992,992,992,992,992,992, +992,992,992,992,992,992,992,992,992,992,992,992,992,992,992,992, -/* block 254 */ +/* block 261 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, @@ -4268,7 +4364,7 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 71936 bytes, block = 128 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, -/* block 255 */ +/* block 262 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, @@ -4276,9 +4372,9 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 71936 bytes, block = 128 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,973,973,973,973,973, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,995,995,995,995,995, -/* block 256 */ +/* block 263 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, @@ -4288,7 +4384,7 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 71936 bytes, block = 128 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, -/* block 257 */ +/* block 264 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, @@ -4298,17 +4394,17 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 71936 bytes, block = 128 */ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, -/* block 258 */ +/* block 265 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21,970,970,970,970,970,970,970,970, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,970,970,970, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,970,970,970, + 21, 21, 21, 21, 21, 21, 21, 21,992,992,992,992,992, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,992,992,992, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,992,992,992, -/* block 259 */ +/* block 266 */ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, @@ -4316,39 +4412,39 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 71936 bytes, block = 128 */ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20,970,970,970,970,970,970,970,970,970,970,970,970, + 20, 20, 20, 20,992,992,992,992,992,992,992,992,992,992,992,992, -/* block 260 */ +/* block 267 */ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 21, 21, 21, 21,970,970,970,970,970,970,970, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,970,970,970,970, -970,970,970,970,970,970,970,970,970,970,970,970,970,970,970,970, + 20, 20, 20, 20, 20, 21, 21, 21, 21,992,992,992,992,992,992,992, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,992,992,992,992, + 21,992,992,992,992,992,992,992,992,992,992,992,992,992,992,992, -/* block 261 */ - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,970,970,970,970, +/* block 268 */ + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,992,992,992,992, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20,970,970,970,970,970,970,970,970, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,970,970,970,970,970,970, + 20, 20, 20, 20, 20, 20, 20, 20,992,992,992,992,992,992,992,992, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,992,992,992,992,992,992, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, -/* block 262 */ - 20, 20, 20, 20, 20, 20, 20, 20,970,970,970,970,970,970,970,970, +/* block 269 */ + 20, 20, 20, 20, 20, 20, 20, 20,992,992,992,992,992,992,992,992, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,970,970, - 21, 21,970,970,970,970,970,970,970,970,970,970,970,970,970,970, -970,970,970,970,970,970,970,970,970,970,970,970,970,970,970,970, -970,970,970,970,970,970,970,970,970,970,970,970,970,970,970,970, -970,970,970,970,970,970,970,970,970,970,970,970,970,970,970,970, -970,970,970,970,970,970,970,970,970,970,970,970,970,970,970,970, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,992,992, + 21, 21,992,992,992,992,992,992,992,992,992,992,992,992,992,992, +992,992,992,992,992,992,992,992,992,992,992,992,992,992,992,992, +992,992,992,992,992,992,992,992,992,992,992,992,992,992,992,992, +992,992,992,992,992,992,992,992,992,992,992,992,992,992,992,992, +992,992,992,992,992,992,992,992,992,992,992,992,992,992,992,992, -/* block 263 */ +/* block 270 */ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, @@ -4356,39 +4452,29 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 71936 bytes, block = 128 */ 21, 21, 21, 21, 21, 21, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21,970, 21, 21, 21, 21, 21, 21, - -/* block 264 */ - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,970, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, -/* block 265 */ +/* block 271 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21,970,970,970,970,970,970,970,970,970,970,970,970, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,970,970, - 21, 21, 21, 21, 21,970,970,970, 21, 21, 21,970,970,970,970,970, + 21, 21, 21, 21,992,992,992,992,992,992,992,992,992,992,992,992, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,992,992, + 21, 21, 21, 21, 21,992,992,992, 21, 21, 21, 21, 21,992,992,992, -/* block 266 */ - 21, 21, 21, 21, 21, 21, 21,970,970,970,970,970,970,970,970,970, +/* block 272 */ + 21, 21, 21, 21, 21, 21, 21,992,992,992,992,992,992,992,992,992, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21,970,970,970,970,970,970,970, - 21, 21, 21, 21, 21, 21, 21,970,970,970,970,970,970,970,970,970, - 21, 21, 21,970,970,970,970,970,970,970,970,970,970,970,970,970, - 21, 21, 21, 21, 21, 21, 21,970,970,970,970,970,970,970,970,970, -970,970,970,970,970,970,970,970,970,970,970,970,970,970,970,970, -970,970,970,970,970,970,970,970,970,970,970,970,970,970,970,970, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,992,992,992, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,992,992,992,992,992, + 21, 21, 21, 21, 21, 21,992,992,992,992,992,992,992,992,992,992, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,992,992,992,992,992,992, + 21, 21, 21, 21, 21, 21, 21, 21,992,992,992,992,992,992,992,992, + 21, 21, 21, 21, 21, 21, 21,992,992,992,992,992,992,992,992,992, -/* block 267 */ +/* block 273 */ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,120, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, @@ -4398,69 +4484,69 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 71936 bytes, block = 128 */ 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,120,120,120,120,120,120, -/* block 268 */ -970,970,970,970,970,970,970,970,970,970,970,970,970,970,970,970, -970,970,970,970,970,970,970,970,970,970,970,970,970,970,970,970, -970,970,970,970,970,970,970,970,970,970,970,970,970,970,970,970, -970,970,970,970,970,970,970,970,970,970,970,970,970,970,970,970, -970,970,970,970,970,970,970,970,970,970,970,970,970,970,970,970, -970,970,970,970,970,970,970,970,970,970,970,970,970,970,970,970, -970,970,970,970,970,970,970,970,970,970,970,970,970,970,970,970, -970,970,970,970,970,970,970,970,970,970,970,970,970,970,120,120, +/* block 274 */ +992,992,992,992,992,992,992,992,992,992,992,992,992,992,992,992, +992,992,992,992,992,992,992,992,992,992,992,992,992,992,992,992, +992,992,992,992,992,992,992,992,992,992,992,992,992,992,992,992, +992,992,992,992,992,992,992,992,992,992,992,992,992,992,992,992, +992,992,992,992,992,992,992,992,992,992,992,992,992,992,992,992, +992,992,992,992,992,992,992,992,992,992,992,992,992,992,992,992, +992,992,992,992,992,992,992,992,992,992,992,992,992,992,992,992, +992,992,992,992,992,992,992,992,992,992,992,992,992,992,120,120, -/* block 269 */ -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,120,120, +/* block 275 */ +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -/* block 270 */ -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,120,120,120,120,120,120,120,120,120,120,120, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +/* block 276 */ +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,120,120,120,120,120,120,120, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, -/* block 271 */ -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,120,120, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +/* block 277 */ +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,120,120, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, -/* block 272 */ -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +/* block 278 */ +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, -/* block 273 */ -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +/* block 279 */ +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -/* block 274 */ -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,120,120, +/* block 280 */ +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, @@ -4468,37 +4554,37 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 71936 bytes, block = 128 */ 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -/* block 275 */ -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, -586,586,586,586,586,586,586,586,586,586,586,120,120,120,120,120, +/* block 281 */ +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,591,591,591,591,591, +591,591,591,591,591,591,591,591,591,591,591,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -/* block 276 */ -511, 24,511,511,511,511,511,511,511,511,511,511,511,511,511,511, -511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511, -974,974,974,974,974,974,974,974,974,974,974,974,974,974,974,974, -974,974,974,974,974,974,974,974,974,974,974,974,974,974,974,974, -974,974,974,974,974,974,974,974,974,974,974,974,974,974,974,974, -974,974,974,974,974,974,974,974,974,974,974,974,974,974,974,974, -974,974,974,974,974,974,974,974,974,974,974,974,974,974,974,974, -974,974,974,974,974,974,974,974,974,974,974,974,974,974,974,974, +/* block 282 */ +516, 24,516,516,516,516,516,516,516,516,516,516,516,516,516,516, +516,516,516,516,516,516,516,516,516,516,516,516,516,516,516,516, +996,996,996,996,996,996,996,996,996,996,996,996,996,996,996,996, +996,996,996,996,996,996,996,996,996,996,996,996,996,996,996,996, +996,996,996,996,996,996,996,996,996,996,996,996,996,996,996,996, +996,996,996,996,996,996,996,996,996,996,996,996,996,996,996,996, +996,996,996,996,996,996,996,996,996,996,996,996,996,996,996,996, +996,996,996,996,996,996,996,996,996,996,996,996,996,996,996,996, -/* block 277 */ -511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511, -511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511, -511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511, -511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511, -511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511, -511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511, -511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511, -511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511, +/* block 283 */ +516,516,516,516,516,516,516,516,516,516,516,516,516,516,516,516, +516,516,516,516,516,516,516,516,516,516,516,516,516,516,516,516, +516,516,516,516,516,516,516,516,516,516,516,516,516,516,516,516, +516,516,516,516,516,516,516,516,516,516,516,516,516,516,516,516, +516,516,516,516,516,516,516,516,516,516,516,516,516,516,516,516, +516,516,516,516,516,516,516,516,516,516,516,516,516,516,516,516, +516,516,516,516,516,516,516,516,516,516,516,516,516,516,516,516, +516,516,516,516,516,516,516,516,516,516,516,516,516,516,516,516, -/* block 278 */ +/* block 284 */ 113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, 113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, 113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, @@ -4508,7 +4594,7 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 71936 bytes, block = 128 */ 113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, 113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, -/* block 279 */ +/* block 285 */ 113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, 113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, 113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, @@ -4516,17 +4602,17 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 71936 bytes, block = 128 */ 113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, 113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, 113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, -511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511, - -/* block 280 */ -673,673,673,673,673,673,673,673,673,673,673,673,673,673,673,673, -673,673,673,673,673,673,673,673,673,673,673,673,673,673,673,673, -673,673,673,673,673,673,673,673,673,673,673,673,673,673,673,673, -673,673,673,673,673,673,673,673,673,673,673,673,673,673,673,673, -673,673,673,673,673,673,673,673,673,673,673,673,673,673,673,673, -673,673,673,673,673,673,673,673,673,673,673,673,673,673,673,673, -673,673,673,673,673,673,673,673,673,673,673,673,673,673,673,673, -673,673,673,673,673,673,673,673,673,673,673,673,673,673,120,120, +516,516,516,516,516,516,516,516,516,516,516,516,516,516,516,516, + +/* block 286 */ +678,678,678,678,678,678,678,678,678,678,678,678,678,678,678,678, +678,678,678,678,678,678,678,678,678,678,678,678,678,678,678,678, +678,678,678,678,678,678,678,678,678,678,678,678,678,678,678,678, +678,678,678,678,678,678,678,678,678,678,678,678,678,678,678,678, +678,678,678,678,678,678,678,678,678,678,678,678,678,678,678,678, +678,678,678,678,678,678,678,678,678,678,678,678,678,678,678,678, +678,678,678,678,678,678,678,678,678,678,678,678,678,678,678,678, +678,678,678,678,678,678,678,678,678,678,678,678,678,678,120,120, }; diff --git a/thirdparty/pcre2/src/pcre2_ucp.h b/thirdparty/pcre2/src/pcre2_ucp.h index 9538062c71..d84f269e87 100644 --- a/thirdparty/pcre2/src/pcre2_ucp.h +++ b/thirdparty/pcre2/src/pcre2_ucp.h @@ -291,7 +291,13 @@ enum { ucp_Chorasmian, ucp_Dives_Akuru, ucp_Khitan_Small_Script, - ucp_Yezidi + ucp_Yezidi, + /* New for Unicode 14.0.0 */ + ucp_Cypro_Minoan, + ucp_Old_Uyghur, + ucp_Tangsa, + ucp_Toto, + ucp_Vithkuqi }; #endif /* PCRE2_UCP_H_IDEMPOTENT_GUARD */ diff --git a/thirdparty/pcre2/src/sljit/sljitConfigInternal.h b/thirdparty/pcre2/src/sljit/sljitConfigInternal.h index eb1132db30..7bb9990a59 100644 --- a/thirdparty/pcre2/src/sljit/sljitConfigInternal.h +++ b/thirdparty/pcre2/src/sljit/sljitConfigInternal.h @@ -158,6 +158,8 @@ extern "C" { #define SLJIT_CONFIG_MIPS_64 1 #elif defined(__sparc__) || defined(__sparc) #define SLJIT_CONFIG_SPARC_32 1 +#elif defined(__s390x__) +#define SLJIT_CONFIG_S390X 1 #else /* Unsupported architecture */ #define SLJIT_CONFIG_UNSUPPORTED 1 @@ -759,6 +761,18 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_sw sljit_exec_offset(void* ptr); #define SLJIT_NUMBER_OF_SCRATCH_FLOAT_REGISTERS \ (SLJIT_NUMBER_OF_FLOAT_REGISTERS - SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS) +/********************************/ +/* CPU status flags management. */ +/********************************/ + +#if (defined SLJIT_CONFIG_ARM_32 && SLJIT_CONFIG_ARM_32) \ + || (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \ + || (defined SLJIT_CONFIG_MIPS && SLJIT_CONFIG_MIPS) \ + || (defined SLJIT_CONFIG_SPARC && SLJIT_CONFIG_SPARC) \ + || (defined SLJIT_CONFIG_S390X && SLJIT_CONFIG_S390X) +#define SLJIT_HAS_STATUS_FLAGS_STATE 1 +#endif + /*************************************/ /* Debug and verbose related macros. */ /*************************************/ diff --git a/thirdparty/pcre2/src/sljit/sljitExecAllocator.c b/thirdparty/pcre2/src/sljit/sljitExecAllocator.c index 61a32f23e9..6e5bf78e45 100644 --- a/thirdparty/pcre2/src/sljit/sljitExecAllocator.c +++ b/thirdparty/pcre2/src/sljit/sljitExecAllocator.c @@ -79,6 +79,7 @@ */ #ifdef _WIN32 +#define SLJIT_UPDATE_WX_FLAGS(from, to, enable_exec) static SLJIT_INLINE void* alloc_chunk(sljit_uw size) { @@ -91,96 +92,108 @@ static SLJIT_INLINE void free_chunk(void *chunk, sljit_uw size) VirtualFree(chunk, 0, MEM_RELEASE); } -#else - -#ifdef __APPLE__ -#ifdef MAP_ANON -/* Configures TARGET_OS_OSX when appropriate */ -#include <TargetConditionals.h> - -#if TARGET_OS_OSX && defined(MAP_JIT) -#include <sys/utsname.h> -#endif /* TARGET_OS_OSX && MAP_JIT */ - -#ifdef MAP_JIT +#else /* POSIX */ +#if defined(__APPLE__) && defined(MAP_JIT) /* On macOS systems, returns MAP_JIT if it is defined _and_ we're running on a - version where it's OK to have more than one JIT block. + version where it's OK to have more than one JIT block or where MAP_JIT is + required. On non-macOS systems, returns MAP_JIT if it is defined. */ +#include <TargetConditionals.h> +#if TARGET_OS_OSX +#if defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86 +#ifdef MAP_ANON +#include <sys/utsname.h> +#include <stdlib.h> + +#define SLJIT_MAP_JIT (get_map_jit_flag()) + static SLJIT_INLINE int get_map_jit_flag() { -#if TARGET_OS_OSX - sljit_sw page_size = get_page_alignment() + 1; + sljit_sw page_size; void *ptr; + struct utsname name; static int map_jit_flag = -1; - /* - The following code is thread safe because multiple initialization - sets map_jit_flag to the same value and the code has no side-effects. - Changing the kernel version witout system restart is (very) unlikely. - */ - if (map_jit_flag == -1) { - struct utsname name; - + if (map_jit_flag < 0) { map_jit_flag = 0; uname(&name); - /* Kernel version for 10.14.0 (Mojave) */ + /* Kernel version for 10.14.0 (Mojave) or later */ if (atoi(name.release) >= 18) { + page_size = get_page_alignment() + 1; /* Only use MAP_JIT if a hardened runtime is used */ + ptr = mmap(NULL, page_size, PROT_WRITE | PROT_EXEC, + MAP_PRIVATE | MAP_ANON, -1, 0); - ptr = mmap(NULL, page_size, PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANON, -1, 0); - - if (ptr == MAP_FAILED) { - map_jit_flag = MAP_JIT; - } else { + if (ptr != MAP_FAILED) munmap(ptr, page_size); - } + else + map_jit_flag = MAP_JIT; } } - return map_jit_flag; -#else /* !TARGET_OS_OSX */ - return MAP_JIT; -#endif /* TARGET_OS_OSX */ } - -#endif /* MAP_JIT */ #endif /* MAP_ANON */ -#endif /* __APPLE__ */ +#else /* !SLJIT_CONFIG_X86 */ +#if !(defined SLJIT_CONFIG_ARM && SLJIT_CONFIG_ARM) +#error Unsupported architecture +#endif /* SLJIT_CONFIG_ARM */ +#include <pthread.h> + +#define SLJIT_MAP_JIT (MAP_JIT) +#define SLJIT_UPDATE_WX_FLAGS(from, to, enable_exec) \ + apple_update_wx_flags(enable_exec) + +static SLJIT_INLINE void apple_update_wx_flags(sljit_s32 enable_exec) +{ + pthread_jit_write_protect_np(enable_exec); +} +#endif /* SLJIT_CONFIG_X86 */ +#else /* !TARGET_OS_OSX */ +#define SLJIT_MAP_JIT (MAP_JIT) +#endif /* TARGET_OS_OSX */ +#endif /* __APPLE__ && MAP_JIT */ +#ifndef SLJIT_UPDATE_WX_FLAGS +#define SLJIT_UPDATE_WX_FLAGS(from, to, enable_exec) +#endif /* !SLJIT_UPDATE_WX_FLAGS */ +#ifndef SLJIT_MAP_JIT +#define SLJIT_MAP_JIT (0) +#endif /* !SLJIT_MAP_JIT */ static SLJIT_INLINE void* alloc_chunk(sljit_uw size) { void *retval; - const int prot = PROT_READ | PROT_WRITE | PROT_EXEC; - -#ifdef MAP_ANON + int prot = PROT_READ | PROT_WRITE | PROT_EXEC; + int flags = MAP_PRIVATE; + int fd = -1; - int flags = MAP_PRIVATE | MAP_ANON; - -#ifdef MAP_JIT - flags |= get_map_jit_flag(); +#ifdef PROT_MAX + prot |= PROT_MAX(prot); #endif - retval = mmap(NULL, size, prot, flags, -1, 0); +#ifdef MAP_ANON + flags |= MAP_ANON | SLJIT_MAP_JIT; #else /* !MAP_ANON */ if (SLJIT_UNLIKELY((dev_zero < 0) && open_dev_zero())) return NULL; - retval = mmap(NULL, size, prot, MAP_PRIVATE, dev_zero, 0); + fd = dev_zero; #endif /* MAP_ANON */ + retval = mmap(NULL, size, prot, flags, fd, 0); if (retval == MAP_FAILED) - retval = NULL; - else { - if (mprotect(retval, size, prot) < 0) { - munmap(retval, size); - retval = NULL; - } + return NULL; + + if (mprotect(retval, size, PROT_READ | PROT_WRITE | PROT_EXEC) < 0) { + munmap(retval, size); + return NULL; } + SLJIT_UPDATE_WX_FLAGS(retval, (uint8_t *)retval + size, 0); + return retval; } @@ -189,7 +202,7 @@ static SLJIT_INLINE void free_chunk(void *chunk, sljit_uw size) munmap(chunk, size); } -#endif +#endif /* windows */ /* --------------------------------------------------------------------- */ /* Common functions */ @@ -261,6 +274,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_malloc_exec(sljit_uw size) while (free_block) { if (free_block->size >= size) { chunk_size = free_block->size; + SLJIT_UPDATE_WX_FLAGS(NULL, NULL, 0); if (chunk_size > size + 64) { /* We just cut a block from the end of the free block. */ chunk_size -= size; @@ -326,6 +340,7 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_free_exec(void* ptr) allocated_size -= header->size; /* Connecting free blocks together if possible. */ + SLJIT_UPDATE_WX_FLAGS(NULL, NULL, 0); /* If header->prev_size == 0, free_block will equal to header. In this case, free_block->header.size will be > 0. */ @@ -358,6 +373,7 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_free_exec(void* ptr) } } + SLJIT_UPDATE_WX_FLAGS(NULL, NULL, 1); SLJIT_ALLOCATOR_UNLOCK(); } @@ -367,6 +383,7 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_free_unused_memory_exec(void) struct free_block* next_free_block; SLJIT_ALLOCATOR_LOCK(); + SLJIT_UPDATE_WX_FLAGS(NULL, NULL, 0); free_block = free_blocks; while (free_block) { @@ -381,5 +398,6 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_free_unused_memory_exec(void) } SLJIT_ASSERT((total_size && free_blocks) || (!total_size && !free_blocks)); + SLJIT_UPDATE_WX_FLAGS(NULL, NULL, 1); SLJIT_ALLOCATOR_UNLOCK(); } diff --git a/thirdparty/pcre2/src/sljit/sljitLir.c b/thirdparty/pcre2/src/sljit/sljitLir.c index d817c90b3a..a24a99ab87 100644 --- a/thirdparty/pcre2/src/sljit/sljitLir.c +++ b/thirdparty/pcre2/src/sljit/sljitLir.c @@ -532,13 +532,21 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_set_put_label(struct sljit_put_label *put_la put_label->label = label; } +#define SLJIT_CURRENT_FLAGS_ALL \ + (SLJIT_CURRENT_FLAGS_I32_OP | SLJIT_CURRENT_FLAGS_ADD_SUB | SLJIT_CURRENT_FLAGS_COMPARE) + SLJIT_API_FUNC_ATTRIBUTE void sljit_set_current_flags(struct sljit_compiler *compiler, sljit_s32 current_flags) { SLJIT_UNUSED_ARG(compiler); SLJIT_UNUSED_ARG(current_flags); +#if (defined SLJIT_HAS_STATUS_FLAGS_STATE && SLJIT_HAS_STATUS_FLAGS_STATE) + compiler->status_flags_state = current_flags; +#endif + #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS) - if ((current_flags & ~(VARIABLE_FLAG_MASK | SLJIT_I32_OP | SLJIT_SET_Z)) == 0) { + compiler->last_flags = 0; + if ((current_flags & ~(VARIABLE_FLAG_MASK | SLJIT_SET_Z | SLJIT_CURRENT_FLAGS_ALL)) == 0) { compiler->last_flags = GET_FLAG_TYPE(current_flags) | (current_flags & (SLJIT_I32_OP | SLJIT_SET_Z)); } #endif @@ -968,7 +976,7 @@ static const char* fop2_names[] = { }; #define JUMP_POSTFIX(type) \ - ((type & 0xff) <= SLJIT_MUL_NOT_OVERFLOW ? ((type & SLJIT_I32_OP) ? "32" : "") \ + ((type & 0xff) <= SLJIT_NOT_OVERFLOW ? ((type & SLJIT_I32_OP) ? "32" : "") \ : ((type & 0xff) <= SLJIT_ORDERED_F64 ? ((type & SLJIT_F32_OP) ? ".f32" : ".f64") : "")) static char* jump_names[] = { @@ -978,7 +986,6 @@ static char* jump_names[] = { (char*)"sig_less", (char*)"sig_greater_equal", (char*)"sig_greater", (char*)"sig_less_equal", (char*)"overflow", (char*)"not_overflow", - (char*)"mul_overflow", (char*)"mul_not_overflow", (char*)"carry", (char*)"", (char*)"equal", (char*)"not_equal", (char*)"less", (char*)"greater_equal", @@ -1278,7 +1285,7 @@ static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_op2(struct sljit_compiler case SLJIT_MUL: CHECK_ARGUMENT(!(op & SLJIT_SET_Z)); CHECK_ARGUMENT(!(op & VARIABLE_FLAG_MASK) - || GET_FLAG_TYPE(op) == SLJIT_MUL_OVERFLOW); + || GET_FLAG_TYPE(op) == SLJIT_OVERFLOW); break; case SLJIT_ADD: CHECK_ARGUMENT(!(op & VARIABLE_FLAG_MASK) @@ -1601,9 +1608,7 @@ static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_jump(struct sljit_compile CHECK_ARGUMENT(compiler->last_flags & SLJIT_SET_Z); else CHECK_ARGUMENT((type & 0xff) == (compiler->last_flags & 0xff) - || ((type & 0xff) == SLJIT_NOT_OVERFLOW && (compiler->last_flags & 0xff) == SLJIT_OVERFLOW) - || ((type & 0xff) == SLJIT_MUL_NOT_OVERFLOW && (compiler->last_flags & 0xff) == SLJIT_MUL_OVERFLOW)); - CHECK_ARGUMENT((type & SLJIT_I32_OP) == (compiler->last_flags & SLJIT_I32_OP)); + || ((type & 0xff) == SLJIT_NOT_OVERFLOW && (compiler->last_flags & 0xff) == SLJIT_OVERFLOW)); } #endif #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) @@ -1818,8 +1823,7 @@ static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_op_flags(struct sljit_com CHECK_ARGUMENT(compiler->last_flags & SLJIT_SET_Z); else CHECK_ARGUMENT((type & 0xff) == (compiler->last_flags & 0xff) - || ((type & 0xff) == SLJIT_NOT_OVERFLOW && (compiler->last_flags & 0xff) == SLJIT_OVERFLOW) - || ((type & 0xff) == SLJIT_MUL_NOT_OVERFLOW && (compiler->last_flags & 0xff) == SLJIT_MUL_OVERFLOW)); + || ((type & 0xff) == SLJIT_NOT_OVERFLOW && (compiler->last_flags & 0xff) == SLJIT_OVERFLOW)); FUNCTION_CHECK_DST(dst, dstw, 0); @@ -1858,8 +1862,7 @@ static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_cmov(struct sljit_compile CHECK_ARGUMENT(compiler->last_flags & SLJIT_SET_Z); else CHECK_ARGUMENT((type & 0xff) == (compiler->last_flags & 0xff) - || ((type & 0xff) == SLJIT_NOT_OVERFLOW && (compiler->last_flags & 0xff) == SLJIT_OVERFLOW) - || ((type & 0xff) == SLJIT_MUL_NOT_OVERFLOW && (compiler->last_flags & 0xff) == SLJIT_MUL_OVERFLOW)); + || ((type & 0xff) == SLJIT_NOT_OVERFLOW && (compiler->last_flags & 0xff) == SLJIT_OVERFLOW)); #endif #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) if (SLJIT_UNLIKELY(!!compiler->verbose)) { diff --git a/thirdparty/pcre2/src/sljit/sljitLir.h b/thirdparty/pcre2/src/sljit/sljitLir.h index 93d2804675..0eb62fc21b 100644 --- a/thirdparty/pcre2/src/sljit/sljitLir.h +++ b/thirdparty/pcre2/src/sljit/sljitLir.h @@ -412,6 +412,10 @@ struct sljit_compiler { /* Executable size for statistical purposes. */ sljit_uw executable_size; +#if (defined SLJIT_HAS_STATUS_FLAGS_STATE && SLJIT_HAS_STATUS_FLAGS_STATE) + sljit_s32 status_flags_state; +#endif + #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) sljit_s32 args; sljit_s32 locals_offset; @@ -460,7 +464,7 @@ struct sljit_compiler { #if (defined SLJIT_CONFIG_S390X && SLJIT_CONFIG_S390X) /* Need to allocate register save area to make calls. */ - sljit_s32 have_save_area; + sljit_s32 mode; #endif #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) @@ -996,7 +1000,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op1(struct sljit_compiler *compile #define SLJIT_SUBC (SLJIT_OP2_BASE + 3) #define SLJIT_SUBC32 (SLJIT_SUBC | SLJIT_I32_OP) /* Note: integer mul - Flags: MUL_OVERFLOW */ + Flags: OVERFLOW */ #define SLJIT_MUL (SLJIT_OP2_BASE + 4) #define SLJIT_MUL32 (SLJIT_MUL | SLJIT_I32_OP) /* Flags: Z */ @@ -1141,89 +1145,69 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compi /* Integer comparison types. */ #define SLJIT_EQUAL 0 -#define SLJIT_EQUAL32 (SLJIT_EQUAL | SLJIT_I32_OP) -#define SLJIT_ZERO 0 -#define SLJIT_ZERO32 (SLJIT_ZERO | SLJIT_I32_OP) +#define SLJIT_ZERO SLJIT_EQUAL #define SLJIT_NOT_EQUAL 1 -#define SLJIT_NOT_EQUAL32 (SLJIT_NOT_EQUAL | SLJIT_I32_OP) -#define SLJIT_NOT_ZERO 1 -#define SLJIT_NOT_ZERO32 (SLJIT_NOT_ZERO | SLJIT_I32_OP) +#define SLJIT_NOT_ZERO SLJIT_NOT_EQUAL #define SLJIT_LESS 2 -#define SLJIT_LESS32 (SLJIT_LESS | SLJIT_I32_OP) #define SLJIT_SET_LESS SLJIT_SET(SLJIT_LESS) #define SLJIT_GREATER_EQUAL 3 -#define SLJIT_GREATER_EQUAL32 (SLJIT_GREATER_EQUAL | SLJIT_I32_OP) #define SLJIT_SET_GREATER_EQUAL SLJIT_SET(SLJIT_GREATER_EQUAL) #define SLJIT_GREATER 4 -#define SLJIT_GREATER32 (SLJIT_GREATER | SLJIT_I32_OP) #define SLJIT_SET_GREATER SLJIT_SET(SLJIT_GREATER) #define SLJIT_LESS_EQUAL 5 -#define SLJIT_LESS_EQUAL32 (SLJIT_LESS_EQUAL | SLJIT_I32_OP) #define SLJIT_SET_LESS_EQUAL SLJIT_SET(SLJIT_LESS_EQUAL) #define SLJIT_SIG_LESS 6 -#define SLJIT_SIG_LESS32 (SLJIT_SIG_LESS | SLJIT_I32_OP) #define SLJIT_SET_SIG_LESS SLJIT_SET(SLJIT_SIG_LESS) #define SLJIT_SIG_GREATER_EQUAL 7 -#define SLJIT_SIG_GREATER_EQUAL32 (SLJIT_SIG_GREATER_EQUAL | SLJIT_I32_OP) #define SLJIT_SET_SIG_GREATER_EQUAL SLJIT_SET(SLJIT_SIG_GREATER_EQUAL) #define SLJIT_SIG_GREATER 8 -#define SLJIT_SIG_GREATER32 (SLJIT_SIG_GREATER | SLJIT_I32_OP) #define SLJIT_SET_SIG_GREATER SLJIT_SET(SLJIT_SIG_GREATER) #define SLJIT_SIG_LESS_EQUAL 9 -#define SLJIT_SIG_LESS_EQUAL32 (SLJIT_SIG_LESS_EQUAL | SLJIT_I32_OP) #define SLJIT_SET_SIG_LESS_EQUAL SLJIT_SET(SLJIT_SIG_LESS_EQUAL) #define SLJIT_OVERFLOW 10 -#define SLJIT_OVERFLOW32 (SLJIT_OVERFLOW | SLJIT_I32_OP) #define SLJIT_SET_OVERFLOW SLJIT_SET(SLJIT_OVERFLOW) #define SLJIT_NOT_OVERFLOW 11 -#define SLJIT_NOT_OVERFLOW32 (SLJIT_NOT_OVERFLOW | SLJIT_I32_OP) - -#define SLJIT_MUL_OVERFLOW 12 -#define SLJIT_MUL_OVERFLOW32 (SLJIT_MUL_OVERFLOW | SLJIT_I32_OP) -#define SLJIT_SET_MUL_OVERFLOW SLJIT_SET(SLJIT_MUL_OVERFLOW) -#define SLJIT_MUL_NOT_OVERFLOW 13 -#define SLJIT_MUL_NOT_OVERFLOW32 (SLJIT_MUL_NOT_OVERFLOW | SLJIT_I32_OP) /* There is no SLJIT_CARRY or SLJIT_NOT_CARRY. */ -#define SLJIT_SET_CARRY SLJIT_SET(14) +#define SLJIT_SET_CARRY SLJIT_SET(12) /* Floating point comparison types. */ -#define SLJIT_EQUAL_F64 16 +#define SLJIT_EQUAL_F64 14 #define SLJIT_EQUAL_F32 (SLJIT_EQUAL_F64 | SLJIT_F32_OP) #define SLJIT_SET_EQUAL_F SLJIT_SET(SLJIT_EQUAL_F64) -#define SLJIT_NOT_EQUAL_F64 17 +#define SLJIT_NOT_EQUAL_F64 15 #define SLJIT_NOT_EQUAL_F32 (SLJIT_NOT_EQUAL_F64 | SLJIT_F32_OP) #define SLJIT_SET_NOT_EQUAL_F SLJIT_SET(SLJIT_NOT_EQUAL_F64) -#define SLJIT_LESS_F64 18 +#define SLJIT_LESS_F64 16 #define SLJIT_LESS_F32 (SLJIT_LESS_F64 | SLJIT_F32_OP) #define SLJIT_SET_LESS_F SLJIT_SET(SLJIT_LESS_F64) -#define SLJIT_GREATER_EQUAL_F64 19 +#define SLJIT_GREATER_EQUAL_F64 17 #define SLJIT_GREATER_EQUAL_F32 (SLJIT_GREATER_EQUAL_F64 | SLJIT_F32_OP) #define SLJIT_SET_GREATER_EQUAL_F SLJIT_SET(SLJIT_GREATER_EQUAL_F64) -#define SLJIT_GREATER_F64 20 +#define SLJIT_GREATER_F64 18 #define SLJIT_GREATER_F32 (SLJIT_GREATER_F64 | SLJIT_F32_OP) #define SLJIT_SET_GREATER_F SLJIT_SET(SLJIT_GREATER_F64) -#define SLJIT_LESS_EQUAL_F64 21 +#define SLJIT_LESS_EQUAL_F64 19 #define SLJIT_LESS_EQUAL_F32 (SLJIT_LESS_EQUAL_F64 | SLJIT_F32_OP) #define SLJIT_SET_LESS_EQUAL_F SLJIT_SET(SLJIT_LESS_EQUAL_F64) -#define SLJIT_UNORDERED_F64 22 +#define SLJIT_UNORDERED_F64 20 #define SLJIT_UNORDERED_F32 (SLJIT_UNORDERED_F64 | SLJIT_F32_OP) #define SLJIT_SET_UNORDERED_F SLJIT_SET(SLJIT_UNORDERED_F64) -#define SLJIT_ORDERED_F64 23 +#define SLJIT_ORDERED_F64 21 #define SLJIT_ORDERED_F32 (SLJIT_ORDERED_F64 | SLJIT_F32_OP) #define SLJIT_SET_ORDERED_F SLJIT_SET(SLJIT_ORDERED_F64) /* Unconditional jump types. */ -#define SLJIT_JUMP 24 +#define SLJIT_JUMP 22 /* Fast calling method. See sljit_emit_fast_enter / SLJIT_FAST_RETURN. */ -#define SLJIT_FAST_CALL 25 +#define SLJIT_FAST_CALL 23 /* Called function must be declared with the SLJIT_FUNC attribute. */ -#define SLJIT_CALL 26 +#define SLJIT_CALL 24 /* Called function must be declared with cdecl attribute. This is the default attribute for C functions. */ -#define SLJIT_CALL_CDECL 27 +#define SLJIT_CALL_CDECL 25 /* The target can be changed during runtime (see: sljit_set_jump_addr). */ #define SLJIT_REWRITABLE_JUMP 0x1000 @@ -1534,8 +1518,22 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_get_float_register_index(sljit_s32 reg) SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op_custom(struct sljit_compiler *compiler, void *instruction, sljit_s32 size); -/* Define the currently available CPU status flags. It is usually used after an - sljit_emit_op_custom call to define which flags are set. */ +/* Flags were set by a 32 bit operation. */ +#define SLJIT_CURRENT_FLAGS_I32_OP SLJIT_I32_OP + +/* Flags were set by an ADD, ADDC, SUB, SUBC, or NEG operation. */ +#define SLJIT_CURRENT_FLAGS_ADD_SUB 0x01 + +/* Flags were set by a SUB with unused destination. + Must be combined with SLJIT_CURRENT_FLAGS_ADD_SUB. */ +#define SLJIT_CURRENT_FLAGS_COMPARE 0x02 + +/* Define the currently available CPU status flags. It is usually used after + an sljit_emit_label or sljit_emit_op_custom operations to define which CPU + status flags are available. + + The current_flags must be a valid combination of SLJIT_SET_* and + SLJIT_CURRENT_FLAGS_* constants. */ SLJIT_API_FUNC_ATTRIBUTE void sljit_set_current_flags(struct sljit_compiler *compiler, sljit_s32 current_flags); diff --git a/thirdparty/pcre2/src/sljit/sljitNativeARM_32.c b/thirdparty/pcre2/src/sljit/sljitNativeARM_32.c index ae8479f031..74cf55fcd2 100644 --- a/thirdparty/pcre2/src/sljit/sljitNativeARM_32.c +++ b/thirdparty/pcre2/src/sljit/sljitNativeARM_32.c @@ -1197,6 +1197,8 @@ static SLJIT_INLINE sljit_s32 emit_single_op(struct sljit_compiler *compiler, sl case SLJIT_ADD: SLJIT_ASSERT(!(flags & INV_IMM)); + compiler->status_flags_state = SLJIT_CURRENT_FLAGS_ADD_SUB; + if ((flags & (UNUSED_RETURN | SET_FLAGS)) == (UNUSED_RETURN | SET_FLAGS) && !(flags & ARGS_SWAPPED)) return push_inst(compiler, CMN | SET_FLAGS | RN(src1) | ((src2 & SRC2_IMM) ? src2 : RM(src2))); return push_inst(compiler, ADD | (flags & SET_FLAGS) | RD(dst) | RN(src1) | ((src2 & SRC2_IMM) ? src2 : RM(src2))); @@ -1207,6 +1209,8 @@ static SLJIT_INLINE sljit_s32 emit_single_op(struct sljit_compiler *compiler, sl case SLJIT_SUB: SLJIT_ASSERT(!(flags & INV_IMM)); + compiler->status_flags_state = SLJIT_CURRENT_FLAGS_ADD_SUB; + if ((flags & (UNUSED_RETURN | SET_FLAGS)) == (UNUSED_RETURN | SET_FLAGS) && !(flags & ARGS_SWAPPED)) return push_inst(compiler, CMP | SET_FLAGS | RN(src1) | ((src2 & SRC2_IMM) ? src2 : RM(src2))); return push_inst(compiler, (!(flags & ARGS_SWAPPED) ? SUB : RSB) | (flags & SET_FLAGS) @@ -1220,6 +1224,7 @@ static SLJIT_INLINE sljit_s32 emit_single_op(struct sljit_compiler *compiler, sl case SLJIT_MUL: SLJIT_ASSERT(!(flags & INV_IMM)); SLJIT_ASSERT(!(src2 & SRC2_IMM)); + compiler->status_flags_state = 0; if (!HAS_FLAGS(op)) return push_inst(compiler, MUL | (reg_map[dst] << 16) | (reg_map[src2] << 8) | reg_map[src1]); @@ -2153,16 +2158,14 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fast_enter(struct sljit_compiler * /* Conditional instructions */ /* --------------------------------------------------------------------- */ -static sljit_uw get_cc(sljit_s32 type) +static sljit_uw get_cc(struct sljit_compiler *compiler, sljit_s32 type) { switch (type) { case SLJIT_EQUAL: - case SLJIT_MUL_NOT_OVERFLOW: case SLJIT_EQUAL_F64: return 0x00000000; case SLJIT_NOT_EQUAL: - case SLJIT_MUL_OVERFLOW: case SLJIT_NOT_EQUAL_F64: return 0x10000000; @@ -2195,10 +2198,16 @@ static sljit_uw get_cc(sljit_s32 type) return 0xd0000000; case SLJIT_OVERFLOW: + if (!(compiler->status_flags_state & SLJIT_CURRENT_FLAGS_ADD_SUB)) + return 0x10000000; + case SLJIT_UNORDERED_F64: return 0x60000000; case SLJIT_NOT_OVERFLOW: + if (!(compiler->status_flags_state & SLJIT_CURRENT_FLAGS_ADD_SUB)) + return 0x00000000; + case SLJIT_ORDERED_F64: return 0x70000000; @@ -2242,7 +2251,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compile if (type >= SLJIT_FAST_CALL) PTR_FAIL_IF(prepare_blx(compiler)); PTR_FAIL_IF(push_inst_with_unique_literal(compiler, ((EMIT_DATA_TRANSFER(WORD_SIZE | LOAD_DATA, 1, - type <= SLJIT_JUMP ? TMP_PC : TMP_REG1, TMP_PC, 0)) & ~COND_MASK) | get_cc(type), 0)); + type <= SLJIT_JUMP ? TMP_PC : TMP_REG1, TMP_PC, 0)) & ~COND_MASK) | get_cc(compiler, type), 0)); if (jump->flags & SLJIT_REWRITABLE_JUMP) { jump->addr = compiler->size; @@ -2260,7 +2269,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compile if (type >= SLJIT_FAST_CALL) jump->flags |= IS_BL; PTR_FAIL_IF(emit_imm(compiler, TMP_REG1, 0)); - PTR_FAIL_IF(push_inst(compiler, (((type <= SLJIT_JUMP ? BX : BLX) | RM(TMP_REG1)) & ~COND_MASK) | get_cc(type))); + PTR_FAIL_IF(push_inst(compiler, (((type <= SLJIT_JUMP ? BX : BLX) | RM(TMP_REG1)) & ~COND_MASK) | get_cc(compiler, type))); jump->addr = compiler->size; #endif return jump; @@ -2589,7 +2598,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op_flags(struct sljit_compiler *co ADJUST_LOCAL_OFFSET(dst, dstw); op = GET_OPCODE(op); - cc = get_cc(type & 0xff); + cc = get_cc(compiler, type & 0xff); dst_reg = FAST_IS_REG(dst) ? dst : TMP_REG1; if (op < SLJIT_ADD) { @@ -2629,7 +2638,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_cmov(struct sljit_compiler *compil dst_reg &= ~SLJIT_I32_OP; - cc = get_cc(type & 0xff); + cc = get_cc(compiler, type & 0xff); if (SLJIT_UNLIKELY(src & SLJIT_IMM)) { tmp = get_imm(srcw); diff --git a/thirdparty/pcre2/src/sljit/sljitNativeARM_64.c b/thirdparty/pcre2/src/sljit/sljitNativeARM_64.c index 52267e7df7..3f0f5fcc30 100644 --- a/thirdparty/pcre2/src/sljit/sljitNativeARM_64.c +++ b/thirdparty/pcre2/src/sljit/sljitNativeARM_64.c @@ -644,6 +644,7 @@ static sljit_s32 emit_op_imm(struct sljit_compiler *compiler, sljit_s32 flags, s imm = -imm; /* Fall through. */ case SLJIT_ADD: + compiler->status_flags_state = SLJIT_CURRENT_FLAGS_ADD_SUB; if (imm == 0) { CHECK_FLAGS(1 << 29); return push_inst(compiler, ((op == SLJIT_ADD ? ADDI : SUBI) ^ inv_bits) | RD(dst) | RN(reg)); @@ -781,6 +782,7 @@ static sljit_s32 emit_op_imm(struct sljit_compiler *compiler, sljit_s32 flags, s break; /* Set flags. */ case SLJIT_NEG: SLJIT_ASSERT(arg1 == TMP_REG1); + compiler->status_flags_state = SLJIT_CURRENT_FLAGS_ADD_SUB; if (flags & SET_FLAGS) inv_bits |= 1 << 29; return push_inst(compiler, (SUB ^ inv_bits) | RD(dst) | RN(TMP_ZERO) | RM(arg2)); @@ -789,17 +791,20 @@ static sljit_s32 emit_op_imm(struct sljit_compiler *compiler, sljit_s32 flags, s return push_inst(compiler, (CLZ ^ inv_bits) | RD(dst) | RN(arg2)); case SLJIT_ADD: CHECK_FLAGS(1 << 29); + compiler->status_flags_state = SLJIT_CURRENT_FLAGS_ADD_SUB; return push_inst(compiler, (ADD ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2)); case SLJIT_ADDC: CHECK_FLAGS(1 << 29); return push_inst(compiler, (ADC ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2)); case SLJIT_SUB: CHECK_FLAGS(1 << 29); + compiler->status_flags_state = SLJIT_CURRENT_FLAGS_ADD_SUB; return push_inst(compiler, (SUB ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2)); case SLJIT_SUBC: CHECK_FLAGS(1 << 29); return push_inst(compiler, (SBC ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2)); case SLJIT_MUL: + compiler->status_flags_state = 0; if (!(flags & SET_FLAGS)) return push_inst(compiler, (MADD ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2) | RT2(TMP_ZERO)); if (flags & INT_OP) { @@ -1600,16 +1605,14 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fast_enter(struct sljit_compiler * /* Conditional instructions */ /* --------------------------------------------------------------------- */ -static sljit_uw get_cc(sljit_s32 type) +static sljit_uw get_cc(struct sljit_compiler *compiler, sljit_s32 type) { switch (type) { case SLJIT_EQUAL: - case SLJIT_MUL_NOT_OVERFLOW: case SLJIT_EQUAL_F64: return 0x1; case SLJIT_NOT_EQUAL: - case SLJIT_MUL_OVERFLOW: case SLJIT_NOT_EQUAL_F64: return 0x0; @@ -1642,10 +1645,16 @@ static sljit_uw get_cc(sljit_s32 type) return 0xc; case SLJIT_OVERFLOW: + if (!(compiler->status_flags_state & SLJIT_CURRENT_FLAGS_ADD_SUB)) + return 0x0; + case SLJIT_UNORDERED_F64: return 0x7; case SLJIT_NOT_OVERFLOW: + if (!(compiler->status_flags_state & SLJIT_CURRENT_FLAGS_ADD_SUB)) + return 0x1; + case SLJIT_ORDERED_F64: return 0x6; @@ -1685,7 +1694,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compile if (type < SLJIT_JUMP) { jump->flags |= IS_COND; - PTR_FAIL_IF(push_inst(compiler, B_CC | (6 << 5) | get_cc(type))); + PTR_FAIL_IF(push_inst(compiler, B_CC | (6 << 5) | get_cc(compiler, type))); } else if (type >= SLJIT_FAST_CALL) jump->flags |= IS_BL; @@ -1799,7 +1808,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op_flags(struct sljit_compiler *co CHECK(check_sljit_emit_op_flags(compiler, op, dst, dstw, type)); ADJUST_LOCAL_OFFSET(dst, dstw); - cc = get_cc(type & 0xff); + cc = get_cc(compiler, type & 0xff); dst_r = FAST_IS_REG(dst) ? dst : TMP_REG1; if (GET_OPCODE(op) < SLJIT_ADD) { @@ -1854,7 +1863,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_cmov(struct sljit_compiler *compil srcw = 0; } - cc = get_cc(type & 0xff); + cc = get_cc(compiler, type & 0xff); dst_reg &= ~SLJIT_I32_OP; return push_inst(compiler, (CSEL ^ inv_bits) | (cc << 12) | RD(dst_reg) | RN(dst_reg) | RM(src)); diff --git a/thirdparty/pcre2/src/sljit/sljitNativeARM_T2_32.c b/thirdparty/pcre2/src/sljit/sljitNativeARM_T2_32.c index 4624882f42..e35dbe99b3 100644 --- a/thirdparty/pcre2/src/sljit/sljitNativeARM_T2_32.c +++ b/thirdparty/pcre2/src/sljit/sljitNativeARM_T2_32.c @@ -610,6 +610,7 @@ static sljit_s32 emit_op_imm(struct sljit_compiler *compiler, sljit_s32 flags, s Although some clever things could be done here, "NOT IMM" does not worth the efforts. */ break; case SLJIT_ADD: + compiler->status_flags_state = SLJIT_CURRENT_FLAGS_ADD_SUB; nimm = -(sljit_sw)imm; if (IS_2_LO_REGS(reg, dst)) { if (imm <= 0x7) @@ -643,6 +644,7 @@ static sljit_s32 emit_op_imm(struct sljit_compiler *compiler, sljit_s32 flags, s break; case SLJIT_SUB: /* SUB operation can be replaced by ADD because of the negative carry flag. */ + compiler->status_flags_state = SLJIT_CURRENT_FLAGS_ADD_SUB; if (flags & ARG1_IMM) { if (imm == 0 && IS_2_LO_REGS(reg, dst)) return push_inst16(compiler, RSBSI | RD3(dst) | RN3(reg)); @@ -801,6 +803,7 @@ static sljit_s32 emit_op_imm(struct sljit_compiler *compiler, sljit_s32 flags, s FAIL_IF(push_inst32(compiler, CLZ | RN4(arg2) | RD4(dst) | RM4(arg2))); return SLJIT_SUCCESS; case SLJIT_ADD: + compiler->status_flags_state = SLJIT_CURRENT_FLAGS_ADD_SUB; if (IS_3_LO_REGS(dst, arg1, arg2)) return push_inst16(compiler, ADDS | RD3(dst) | RN3(arg1) | RM3(arg2)); if (dst == arg1 && !(flags & SET_FLAGS)) @@ -811,6 +814,7 @@ static sljit_s32 emit_op_imm(struct sljit_compiler *compiler, sljit_s32 flags, s return push_inst16(compiler, ADCS | RD3(dst) | RN3(arg2)); return push_inst32(compiler, ADC_W | (flags & SET_FLAGS) | RD4(dst) | RN4(arg1) | RM4(arg2)); case SLJIT_SUB: + compiler->status_flags_state = SLJIT_CURRENT_FLAGS_ADD_SUB; if (flags & UNUSED_RETURN) { if (IS_2_LO_REGS(arg1, arg2)) return push_inst16(compiler, CMP | RD3(arg1) | RN3(arg2)); @@ -824,6 +828,7 @@ static sljit_s32 emit_op_imm(struct sljit_compiler *compiler, sljit_s32 flags, s return push_inst16(compiler, SBCS | RD3(dst) | RN3(arg2)); return push_inst32(compiler, SBC_W | (flags & SET_FLAGS) | RD4(dst) | RN4(arg1) | RM4(arg2)); case SLJIT_MUL: + compiler->status_flags_state = 0; if (!(flags & SET_FLAGS)) return push_inst32(compiler, MUL | RD4(dst) | RN4(arg1) | RM4(arg2)); SLJIT_ASSERT(dst != TMP_REG2); @@ -1760,16 +1765,14 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fast_enter(struct sljit_compiler * /* Conditional instructions */ /* --------------------------------------------------------------------- */ -static sljit_uw get_cc(sljit_s32 type) +static sljit_uw get_cc(struct sljit_compiler *compiler, sljit_s32 type) { switch (type) { case SLJIT_EQUAL: - case SLJIT_MUL_NOT_OVERFLOW: case SLJIT_EQUAL_F64: return 0x0; case SLJIT_NOT_EQUAL: - case SLJIT_MUL_OVERFLOW: case SLJIT_NOT_EQUAL_F64: return 0x1; @@ -1802,10 +1805,16 @@ static sljit_uw get_cc(sljit_s32 type) return 0xd; case SLJIT_OVERFLOW: + if (!(compiler->status_flags_state & SLJIT_CURRENT_FLAGS_ADD_SUB)) + return 0x1; + case SLJIT_UNORDERED_F64: return 0x6; case SLJIT_NOT_OVERFLOW: + if (!(compiler->status_flags_state & SLJIT_CURRENT_FLAGS_ADD_SUB)) + return 0x0; + case SLJIT_ORDERED_F64: return 0x7; @@ -1847,7 +1856,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compile PTR_FAIL_IF(emit_imm32_const(compiler, TMP_REG1, 0)); if (type < SLJIT_JUMP) { jump->flags |= IS_COND; - cc = get_cc(type); + cc = get_cc(compiler, type); jump->flags |= cc << 8; PTR_FAIL_IF(push_inst16(compiler, IT | (cc << 4) | 0x8)); } @@ -2177,7 +2186,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op_flags(struct sljit_compiler *co ADJUST_LOCAL_OFFSET(dst, dstw); op = GET_OPCODE(op); - cc = get_cc(type & 0xff); + cc = get_cc(compiler, type & 0xff); dst_r = FAST_IS_REG(dst) ? dst : TMP_REG1; if (op < SLJIT_ADD) { @@ -2229,7 +2238,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_cmov(struct sljit_compiler *compil dst_reg &= ~SLJIT_I32_OP; - cc = get_cc(type & 0xff); + cc = get_cc(compiler, type & 0xff); if (!(src & SLJIT_IMM)) { FAIL_IF(push_inst16(compiler, IT | (cc << 4) | 0x8)); diff --git a/thirdparty/pcre2/src/sljit/sljitNativeMIPS_32.c b/thirdparty/pcre2/src/sljit/sljitNativeMIPS_32.c index f887ee1311..a90345f1f8 100644 --- a/thirdparty/pcre2/src/sljit/sljitNativeMIPS_32.c +++ b/thirdparty/pcre2/src/sljit/sljitNativeMIPS_32.c @@ -367,7 +367,7 @@ static SLJIT_INLINE sljit_s32 emit_single_op(struct sljit_compiler *compiler, sl case SLJIT_MUL: SLJIT_ASSERT(!(flags & SRC2_IMM)); - if (GET_FLAG_TYPE(op) != SLJIT_MUL_OVERFLOW) { + if (GET_FLAG_TYPE(op) != SLJIT_OVERFLOW) { #if (defined SLJIT_MIPS_REV && SLJIT_MIPS_REV >= 1) return push_inst(compiler, MUL | S(src1) | T(src2) | D(dst), DR(dst)); #else /* SLJIT_MIPS_REV < 1 */ diff --git a/thirdparty/pcre2/src/sljit/sljitNativeMIPS_64.c b/thirdparty/pcre2/src/sljit/sljitNativeMIPS_64.c index 5ab9b7d06b..1f22e49ed9 100644 --- a/thirdparty/pcre2/src/sljit/sljitNativeMIPS_64.c +++ b/thirdparty/pcre2/src/sljit/sljitNativeMIPS_64.c @@ -458,7 +458,7 @@ static SLJIT_INLINE sljit_s32 emit_single_op(struct sljit_compiler *compiler, sl case SLJIT_MUL: SLJIT_ASSERT(!(flags & SRC2_IMM)); - if (GET_FLAG_TYPE(op) != SLJIT_MUL_OVERFLOW) { + if (GET_FLAG_TYPE(op) != SLJIT_OVERFLOW) { #if (defined SLJIT_MIPS_REV && SLJIT_MIPS_REV >= 6) return push_inst(compiler, SELECT_OP(DMUL, MUL) | S(src1) | T(src2) | D(dst), DR(dst)); #elif (defined SLJIT_MIPS_REV && SLJIT_MIPS_REV >= 1) diff --git a/thirdparty/pcre2/src/sljit/sljitNativeMIPS_common.c b/thirdparty/pcre2/src/sljit/sljitNativeMIPS_common.c index ecf4dac4c8..fd747695a7 100644 --- a/thirdparty/pcre2/src/sljit/sljitNativeMIPS_common.c +++ b/thirdparty/pcre2/src/sljit/sljitNativeMIPS_common.c @@ -1377,6 +1377,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op1(struct sljit_compiler *compile return emit_op(compiler, op, flags, dst, dstw, TMP_REG1, 0, src, srcw); case SLJIT_NEG: + compiler->status_flags_state = SLJIT_CURRENT_FLAGS_ADD_SUB; return emit_op(compiler, SLJIT_SUB | GET_ALL_FLAGS(op), flags | IMM_OP, dst, dstw, SLJIT_IMM, 0, src, srcw); case SLJIT_CLZ: @@ -1424,13 +1425,16 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op2(struct sljit_compiler *compile switch (GET_OPCODE(op)) { case SLJIT_ADD: case SLJIT_ADDC: + compiler->status_flags_state = SLJIT_CURRENT_FLAGS_ADD_SUB; return emit_op(compiler, op, flags | CUMULATIVE_OP | IMM_OP, dst, dstw, src1, src1w, src2, src2w); case SLJIT_SUB: case SLJIT_SUBC: + compiler->status_flags_state = SLJIT_CURRENT_FLAGS_ADD_SUB; return emit_op(compiler, op, flags | IMM_OP, dst, dstw, src1, src1w, src2, src2w); case SLJIT_MUL: + compiler->status_flags_state = 0; return emit_op(compiler, op, flags | CUMULATIVE_OP, dst, dstw, src1, src1w, src2, src2w); case SLJIT_AND: @@ -1860,7 +1864,6 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compile case SLJIT_SIG_LESS: case SLJIT_SIG_GREATER: case SLJIT_OVERFLOW: - case SLJIT_MUL_OVERFLOW: BR_Z(OTHER_FLAG); break; case SLJIT_GREATER_EQUAL: @@ -1868,7 +1871,6 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compile case SLJIT_SIG_GREATER_EQUAL: case SLJIT_SIG_LESS_EQUAL: case SLJIT_NOT_OVERFLOW: - case SLJIT_MUL_NOT_OVERFLOW: BR_NZ(OTHER_FLAG); break; case SLJIT_NOT_EQUAL_F64: @@ -2127,8 +2129,12 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op_flags(struct sljit_compiler *co FAIL_IF(push_inst(compiler, SLTIU | SA(EQUAL_FLAG) | TA(dst_ar) | IMM(1), dst_ar)); src_ar = dst_ar; break; - case SLJIT_MUL_OVERFLOW: - case SLJIT_MUL_NOT_OVERFLOW: + case SLJIT_OVERFLOW: + case SLJIT_NOT_OVERFLOW: + if (compiler->status_flags_state & SLJIT_CURRENT_FLAGS_ADD_SUB) { + src_ar = OTHER_FLAG; + break; + } FAIL_IF(push_inst(compiler, SLTIU | SA(OTHER_FLAG) | TA(dst_ar) | IMM(1), dst_ar)); src_ar = dst_ar; type ^= 0x1; /* Flip type bit for the XORI below. */ @@ -2219,7 +2225,6 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_cmov(struct sljit_compiler *compil case SLJIT_SIG_LESS: case SLJIT_SIG_GREATER: case SLJIT_OVERFLOW: - case SLJIT_MUL_OVERFLOW: ins = MOVN | TA(OTHER_FLAG); break; case SLJIT_GREATER_EQUAL: @@ -2227,7 +2232,6 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_cmov(struct sljit_compiler *compil case SLJIT_SIG_GREATER_EQUAL: case SLJIT_SIG_LESS_EQUAL: case SLJIT_NOT_OVERFLOW: - case SLJIT_MUL_NOT_OVERFLOW: ins = MOVZ | TA(OTHER_FLAG); break; case SLJIT_EQUAL_F64: diff --git a/thirdparty/pcre2/src/sljit/sljitNativePPC_32.c b/thirdparty/pcre2/src/sljit/sljitNativePPC_32.c index 7d9ec5338f..6ddb5508ec 100644 --- a/thirdparty/pcre2/src/sljit/sljitNativePPC_32.c +++ b/thirdparty/pcre2/src/sljit/sljitNativePPC_32.c @@ -119,9 +119,10 @@ static SLJIT_INLINE sljit_s32 emit_single_op(struct sljit_compiler *compiler, sl SLJIT_ASSERT(src2 == TMP_REG2); return push_inst(compiler, ADDIC | D(dst) | A(src1) | compiler->imm); } + SLJIT_ASSERT(!(flags & ALT_FORM4)); if (!(flags & ALT_SET_FLAGS)) return push_inst(compiler, ADD | D(dst) | A(src1) | B(src2)); - if (flags & ALT_FORM4) + if (flags & ALT_FORM5) return push_inst(compiler, ADDC | RC(ALT_SET_FLAGS) | D(dst) | A(src1) | B(src2)); return push_inst(compiler, ADD | RC(flags) | D(dst) | A(src1) | B(src2)); @@ -143,24 +144,29 @@ static SLJIT_INLINE sljit_s32 emit_single_op(struct sljit_compiler *compiler, sl } if (flags & ALT_FORM2) { + if (flags & ALT_FORM3) { + FAIL_IF(push_inst(compiler, CMPI | CRD(0) | A(src1) | compiler->imm)); + if (!(flags & ALT_FORM4)) + return SLJIT_SUCCESS; + return push_inst(compiler, ADDI | D(dst) | A(src1) | (-compiler->imm & 0xffff)); + } + FAIL_IF(push_inst(compiler, CMP | CRD(0) | A(src1) | B(src2))); + if (!(flags & ALT_FORM4)) + return SLJIT_SUCCESS; + return push_inst(compiler, SUBF | D(dst) | A(src2) | B(src1)); + } + + if (flags & ALT_FORM3) { /* Setting XER SO is not enough, CR SO is also needed. */ return push_inst(compiler, SUBF | OE(ALT_SET_FLAGS) | RC(ALT_SET_FLAGS) | D(dst) | A(src2) | B(src1)); } - if (flags & ALT_FORM3) { + if (flags & ALT_FORM4) { /* Flags does not set: BIN_IMM_EXTS unnecessary. */ SLJIT_ASSERT(src2 == TMP_REG2); return push_inst(compiler, SUBFIC | D(dst) | A(src1) | compiler->imm); } - if (flags & ALT_FORM4) { - if (flags & ALT_FORM5) { - SLJIT_ASSERT(src2 == TMP_REG2); - return push_inst(compiler, CMPI | CRD(0) | A(src1) | compiler->imm); - } - return push_inst(compiler, CMP | CRD(0) | A(src1) | B(src2)); - } - if (!(flags & ALT_SET_FLAGS)) return push_inst(compiler, SUBF | D(dst) | A(src2) | B(src1)); if (flags & ALT_FORM5) diff --git a/thirdparty/pcre2/src/sljit/sljitNativePPC_64.c b/thirdparty/pcre2/src/sljit/sljitNativePPC_64.c index 92147d2a5d..cbdf2dd8a2 100644 --- a/thirdparty/pcre2/src/sljit/sljitNativePPC_64.c +++ b/thirdparty/pcre2/src/sljit/sljitNativePPC_64.c @@ -252,10 +252,17 @@ static SLJIT_INLINE sljit_s32 emit_single_op(struct sljit_compiler *compiler, sl BIN_IMM_EXTS(); return push_inst(compiler, ADDIC | D(dst) | A(src1) | compiler->imm); } + if (flags & ALT_FORM4) { + if (flags & ALT_FORM5) + FAIL_IF(push_inst(compiler, ADDI | D(dst) | A(src1) | compiler->imm)); + else + FAIL_IF(push_inst(compiler, ADD | D(dst) | A(src1) | B(src2))); + return push_inst(compiler, CMPI | A(dst) | 0); + } if (!(flags & ALT_SET_FLAGS)) return push_inst(compiler, ADD | D(dst) | A(src1) | B(src2)); BIN_EXTS(); - if (flags & ALT_FORM4) + if (flags & ALT_FORM5) return push_inst(compiler, ADDC | RC(ALT_SET_FLAGS) | D(dst) | A(src1) | B(src2)); return push_inst(compiler, ADD | RC(flags) | D(dst) | A(src1) | B(src2)); @@ -278,6 +285,19 @@ static SLJIT_INLINE sljit_s32 emit_single_op(struct sljit_compiler *compiler, sl } if (flags & ALT_FORM2) { + if (flags & ALT_FORM3) { + FAIL_IF(push_inst(compiler, CMPI | CRD(0 | ((flags & ALT_SIGN_EXT) ? 0 : 1)) | A(src1) | compiler->imm)); + if (!(flags & ALT_FORM4)) + return SLJIT_SUCCESS; + return push_inst(compiler, ADDI | D(dst) | A(src1) | (-compiler->imm & 0xffff)); + } + FAIL_IF(push_inst(compiler, CMP | CRD(0 | ((flags & ALT_SIGN_EXT) ? 0 : 1)) | A(src1) | B(src2))); + if (!(flags & ALT_FORM4)) + return SLJIT_SUCCESS; + return push_inst(compiler, SUBF | D(dst) | A(src2) | B(src1)); + } + + if (flags & ALT_FORM3) { if (flags & ALT_SIGN_EXT) { FAIL_IF(push_inst(compiler, RLDI(TMP_REG1, src1, 32, 31, 1))); src1 = TMP_REG1; @@ -291,20 +311,12 @@ static SLJIT_INLINE sljit_s32 emit_single_op(struct sljit_compiler *compiler, sl return SLJIT_SUCCESS; } - if (flags & ALT_FORM3) { + if (flags & ALT_FORM4) { /* Flags does not set: BIN_IMM_EXTS unnecessary. */ SLJIT_ASSERT(src2 == TMP_REG2); return push_inst(compiler, SUBFIC | D(dst) | A(src1) | compiler->imm); } - if (flags & ALT_FORM4) { - if (flags & ALT_FORM5) { - SLJIT_ASSERT(src2 == TMP_REG2); - return push_inst(compiler, CMPI | CRD(0 | ((flags & ALT_SIGN_EXT) ? 0 : 1)) | A(src1) | compiler->imm); - } - return push_inst(compiler, CMP | CRD(0 | ((flags & ALT_SIGN_EXT) ? 0 : 1)) | A(src1) | B(src2)); - } - if (!(flags & ALT_SET_FLAGS)) return push_inst(compiler, SUBF | D(dst) | A(src2) | B(src1)); BIN_EXTS(); diff --git a/thirdparty/pcre2/src/sljit/sljitNativePPC_common.c b/thirdparty/pcre2/src/sljit/sljitNativePPC_common.c index d84562ce09..2174dbb07b 100644 --- a/thirdparty/pcre2/src/sljit/sljitNativePPC_common.c +++ b/thirdparty/pcre2/src/sljit/sljitNativePPC_common.c @@ -1324,6 +1324,25 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op1(struct sljit_compiler *compile ((src) & SLJIT_IMM) #endif +#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) +#define TEST_ADD_FORM1(op) \ + (GET_FLAG_TYPE(op) == SLJIT_OVERFLOW \ + || (op & (SLJIT_I32_OP | SLJIT_SET_Z | VARIABLE_FLAG_MASK)) == (SLJIT_I32_OP | SLJIT_SET_Z | SLJIT_SET_CARRY)) +#define TEST_SUB_FORM2(op) \ + ((GET_FLAG_TYPE(op) >= SLJIT_SIG_LESS && GET_FLAG_TYPE(op) <= SLJIT_SIG_LESS_EQUAL) \ + || (op & (SLJIT_I32_OP | SLJIT_SET_Z | VARIABLE_FLAG_MASK)) == (SLJIT_I32_OP | SLJIT_SET_Z)) +#define TEST_SUB_FORM3(op) \ + (GET_FLAG_TYPE(op) == SLJIT_OVERFLOW \ + || (op & (SLJIT_I32_OP | SLJIT_SET_Z)) == (SLJIT_I32_OP | SLJIT_SET_Z)) +#else +#define TEST_ADD_FORM1(op) \ + (GET_FLAG_TYPE(op) == SLJIT_OVERFLOW) +#define TEST_SUB_FORM2(op) \ + (GET_FLAG_TYPE(op) >= SLJIT_SIG_LESS && GET_FLAG_TYPE(op) <= SLJIT_SIG_LESS_EQUAL) +#define TEST_SUB_FORM3(op) \ + (GET_FLAG_TYPE(op) == SLJIT_OVERFLOW) +#endif + SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op2(struct sljit_compiler *compiler, sljit_s32 op, sljit_s32 dst, sljit_sw dstw, sljit_s32 src1, sljit_sw src1w, @@ -1362,7 +1381,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op2(struct sljit_compiler *compile switch (GET_OPCODE(op)) { case SLJIT_ADD: - if (GET_FLAG_TYPE(op) == SLJIT_OVERFLOW) + if (TEST_ADD_FORM1(op)) return emit_op(compiler, SLJIT_ADD, flags | ALT_FORM1, dst, dstw, src1, src1w, src2, src2w); if (!HAS_FLAGS(op) && ((src1 | src2) & SLJIT_IMM)) { @@ -1392,6 +1411,20 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op2(struct sljit_compiler *compile return emit_op(compiler, SLJIT_ADD, flags | ALT_FORM2 | ALT_FORM4, dst, dstw, src2, src2w, TMP_REG2, 0); } } + +#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) + if ((op & (SLJIT_I32_OP | SLJIT_SET_Z)) == (SLJIT_I32_OP | SLJIT_SET_Z)) { + if (TEST_SL_IMM(src2, src2w)) { + compiler->imm = src2w & 0xffff; + return emit_op(compiler, SLJIT_ADD, flags | ALT_FORM4 | ALT_FORM5, dst, dstw, src1, src1w, TMP_REG2, 0); + } + if (TEST_SL_IMM(src1, src1w)) { + compiler->imm = src1w & 0xffff; + return emit_op(compiler, SLJIT_ADD, flags | ALT_FORM4 | ALT_FORM5, dst, dstw, src2, src2w, TMP_REG2, 0); + } + return emit_op(compiler, SLJIT_ADD, flags | ALT_FORM4, dst, dstw, src1, src1w, src2, src2w); + } +#endif if (HAS_FLAGS(op)) { if (TEST_SL_IMM(src2, src2w)) { compiler->imm = src2w & 0xffff; @@ -1402,7 +1435,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op2(struct sljit_compiler *compile return emit_op(compiler, SLJIT_ADD, flags | ALT_FORM3, dst, dstw, src2, src2w, TMP_REG2, 0); } } - return emit_op(compiler, SLJIT_ADD, flags | ((GET_FLAG_TYPE(op) == GET_FLAG_TYPE(SLJIT_SET_CARRY)) ? ALT_FORM4 : 0), dst, dstw, src1, src1w, src2, src2w); + return emit_op(compiler, SLJIT_ADD, flags | ((GET_FLAG_TYPE(op) == GET_FLAG_TYPE(SLJIT_SET_CARRY)) ? ALT_FORM5 : 0), dst, dstw, src1, src1w, src2, src2w); case SLJIT_ADDC: return emit_op(compiler, SLJIT_ADDC, flags, dst, dstw, src1, src1w, src2, src2w); @@ -1424,18 +1457,36 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op2(struct sljit_compiler *compile return emit_op(compiler, SLJIT_SUB, flags | ALT_FORM1 | ALT_FORM3, dst, dstw, src1, src1w, src2, src2w); } - if (GET_FLAG_TYPE(op) == SLJIT_OVERFLOW) + if (dst == SLJIT_UNUSED && GET_FLAG_TYPE(op) <= SLJIT_SIG_LESS_EQUAL) { + if (TEST_SL_IMM(src2, src2w)) { + compiler->imm = src2w & 0xffff; + return emit_op(compiler, SLJIT_SUB, flags | ALT_FORM2 | ALT_FORM3, dst, dstw, src1, src1w, TMP_REG2, 0); + } return emit_op(compiler, SLJIT_SUB, flags | ALT_FORM2, dst, dstw, src1, src1w, src2, src2w); + } - if (!HAS_FLAGS(op) && ((src1 | src2) & SLJIT_IMM)) { - if (TEST_SL_IMM(src2, -src2w)) { - compiler->imm = (-src2w) & 0xffff; - return emit_op(compiler, SLJIT_ADD, flags | ALT_FORM2, dst, dstw, src1, src1w, TMP_REG2, 0); - } - if (TEST_SL_IMM(src1, src1w)) { - compiler->imm = src1w & 0xffff; - return emit_op(compiler, SLJIT_SUB, flags | ALT_FORM3, dst, dstw, src2, src2w, TMP_REG2, 0); + if (TEST_SUB_FORM2(op)) { + if ((src2 & SLJIT_IMM) && src2w >= -SIMM_MAX && src2w <= SIMM_MAX) { + compiler->imm = src2w & 0xffff; + return emit_op(compiler, SLJIT_SUB, flags | ALT_FORM2 | ALT_FORM3 | ALT_FORM4, dst, dstw, src1, src1w, TMP_REG2, 0); } + return emit_op(compiler, SLJIT_SUB, flags | ALT_FORM2 | ALT_FORM4, dst, dstw, src1, src1w, src2, src2w); + } + + if (TEST_SUB_FORM3(op)) + return emit_op(compiler, SLJIT_SUB, flags | ALT_FORM3, dst, dstw, src1, src1w, src2, src2w); + + if (TEST_SL_IMM(src2, -src2w)) { + compiler->imm = (-src2w) & 0xffff; + return emit_op(compiler, SLJIT_ADD, flags | (!HAS_FLAGS(op) ? ALT_FORM2 : ALT_FORM3), dst, dstw, src1, src1w, TMP_REG2, 0); + } + + if (TEST_SL_IMM(src1, src1w) && !(op & SLJIT_SET_Z)) { + compiler->imm = src1w & 0xffff; + return emit_op(compiler, SLJIT_SUB, flags | ALT_FORM4, dst, dstw, src2, src2w, TMP_REG2, 0); + } + + if (!HAS_FLAGS(op)) { if (TEST_SH_IMM(src2, -src2w)) { compiler->imm = ((-src2w) >> 16) & 0xffff; return emit_op(compiler, SLJIT_ADD, flags | ALT_FORM2 | ALT_FORM3, dst, dstw, src1, src1w, TMP_REG2, 0); @@ -1447,18 +1498,6 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op2(struct sljit_compiler *compile } } - if (dst == SLJIT_UNUSED && GET_FLAG_TYPE(op) != GET_FLAG_TYPE(SLJIT_SET_CARRY)) { - if (TEST_SL_IMM(src2, src2w)) { - compiler->imm = src2w & 0xffff; - return emit_op(compiler, SLJIT_SUB, flags | ALT_FORM4 | ALT_FORM5, dst, dstw, src1, src1w, TMP_REG2, 0); - } - return emit_op(compiler, SLJIT_SUB, flags | ALT_FORM4, dst, dstw, src1, src1w, src2, src2w); - } - - if (TEST_SL_IMM(src2, -src2w)) { - compiler->imm = (-src2w) & 0xffff; - return emit_op(compiler, SLJIT_ADD, flags | ALT_FORM3, dst, dstw, src1, src1w, TMP_REG2, 0); - } /* We know ALT_SIGN_EXT is set if it is an SLJIT_I32_OP on 64 bit systems. */ return emit_op(compiler, SLJIT_SUB, flags | ((GET_FLAG_TYPE(op) == GET_FLAG_TYPE(SLJIT_SET_CARRY)) ? ALT_FORM5 : 0), dst, dstw, src1, src1w, src2, src2w); @@ -1536,6 +1575,10 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op2(struct sljit_compiler *compile return SLJIT_SUCCESS; } +#undef TEST_ADD_FORM1 +#undef TEST_SUB_FORM2 +#undef TEST_SUB_FORM3 + SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op_src(struct sljit_compiler *compiler, sljit_s32 op, sljit_s32 src, sljit_sw srcw) { @@ -1941,11 +1984,9 @@ static sljit_ins get_bo_bi_flags(sljit_s32 type) return (4 << 21) | ((4 + 1) << 16); case SLJIT_OVERFLOW: - case SLJIT_MUL_OVERFLOW: return (12 << 21) | (3 << 16); case SLJIT_NOT_OVERFLOW: - case SLJIT_MUL_NOT_OVERFLOW: return (4 << 21) | (3 << 16); case SLJIT_EQUAL_F64: @@ -2143,12 +2184,10 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op_flags(struct sljit_compiler *co break; case SLJIT_OVERFLOW: - case SLJIT_MUL_OVERFLOW: cr_bit = 3; break; case SLJIT_NOT_OVERFLOW: - case SLJIT_MUL_NOT_OVERFLOW: cr_bit = 3; invert = 1; break; diff --git a/thirdparty/pcre2/src/sljit/sljitNativeS390X.c b/thirdparty/pcre2/src/sljit/sljitNativeS390X.c index a8b65112d4..716491ec72 100644 --- a/thirdparty/pcre2/src/sljit/sljitNativeS390X.c +++ b/thirdparty/pcre2/src/sljit/sljitNativeS390X.c @@ -42,10 +42,10 @@ SLJIT_API_FUNC_ATTRIBUTE const char* sljit_get_platform_name(void) typedef sljit_uw sljit_ins; /* Instruction tags (most significant halfword). */ -const sljit_ins sljit_ins_const = (sljit_ins)1 << 48; +static const sljit_ins sljit_ins_const = (sljit_ins)1 << 48; static const sljit_u8 reg_map[SLJIT_NUMBER_OF_REGISTERS + 4] = { - 14, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 0, 1 + 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 0, 1 }; /* there are also a[2-15] available, but they are slower to access and @@ -66,22 +66,22 @@ typedef sljit_uw sljit_gpr; * will be retired ASAP (TODO: carenas) */ -const sljit_gpr r0 = 0; /* reg_map[SLJIT_NUMBER_OF_REGISTERS + 2]: 0 in address calculations; reserved */ -const sljit_gpr r1 = 1; /* reg_map[SLJIT_NUMBER_OF_REGISTERS + 3]: reserved */ -const sljit_gpr r2 = 2; /* reg_map[1]: 1st argument */ -const sljit_gpr r3 = 3; /* reg_map[2]: 2nd argument */ -const sljit_gpr r4 = 4; /* reg_map[3]: 3rd argument */ -const sljit_gpr r5 = 5; /* reg_map[4]: 4th argument */ -const sljit_gpr r6 = 6; /* reg_map[5]: 5th argument; 1st saved register */ -const sljit_gpr r7 = 7; /* reg_map[6] */ -const sljit_gpr r8 = 8; /* reg_map[7] */ -const sljit_gpr r9 = 9; /* reg_map[8] */ -const sljit_gpr r10 = 10; /* reg_map[9] */ -const sljit_gpr r11 = 11; /* reg_map[10] */ -const sljit_gpr r12 = 12; /* reg_map[11]: GOT */ -const sljit_gpr r13 = 13; /* reg_map[12]: Literal Pool pointer */ -const sljit_gpr r14 = 14; /* reg_map[0]: return address and flag register */ -const sljit_gpr r15 = 15; /* reg_map[SLJIT_NUMBER_OF_REGISTERS + 1]: stack pointer */ +static const sljit_gpr r0 = 0; /* reg_map[SLJIT_NUMBER_OF_REGISTERS + 2]: 0 in address calculations; reserved */ +static const sljit_gpr r1 = 1; /* reg_map[SLJIT_NUMBER_OF_REGISTERS + 3]: reserved */ +static const sljit_gpr r2 = 2; /* reg_map[1]: 1st argument */ +static const sljit_gpr r3 = 3; /* reg_map[2]: 2nd argument */ +static const sljit_gpr r4 = 4; /* reg_map[3]: 3rd argument */ +static const sljit_gpr r5 = 5; /* reg_map[4]: 4th argument */ +static const sljit_gpr r6 = 6; /* reg_map[5]: 5th argument; 1st saved register */ +static const sljit_gpr r7 = 7; /* reg_map[6] */ +static const sljit_gpr r8 = 8; /* reg_map[7] */ +static const sljit_gpr r9 = 9; /* reg_map[8] */ +static const sljit_gpr r10 = 10; /* reg_map[9] */ +static const sljit_gpr r11 = 11; /* reg_map[10] */ +static const sljit_gpr r12 = 12; /* reg_map[11]: GOT */ +static const sljit_gpr r13 = 13; /* reg_map[12]: Literal Pool pointer */ +static const sljit_gpr r14 = 14; /* reg_map[0]: return address and flag register */ +static const sljit_gpr r15 = 15; /* reg_map[SLJIT_NUMBER_OF_REGISTERS + 1]: stack pointer */ /* WARNING: r12 and r13 shouldn't be used as per ABI recommendation */ /* TODO(carenas): r12 might conflict in PIC code, reserve? */ @@ -100,8 +100,8 @@ const sljit_gpr r15 = 15; /* reg_map[SLJIT_NUMBER_OF_REGISTERS + 1]: stack point /* Link registers. The normal link register is r14, but since we use that for flags we need to use r0 instead to do fast calls so that flags are preserved. */ -const sljit_gpr link_r = 14; /* r14 */ -const sljit_gpr fast_link_r = 0; /* r0 */ +static const sljit_gpr link_r = 14; /* r14 */ +static const sljit_gpr fast_link_r = 0; /* r0 */ /* Flag register layout: @@ -110,7 +110,7 @@ const sljit_gpr fast_link_r = 0; /* r0 */ | ZERO | 0 | 0 | C C |///////| +---------------+---+---+-------+-------+ */ -const sljit_gpr flag_r = 14; /* r14 */ +static const sljit_gpr flag_r = 14; /* r14 */ struct sljit_s390x_const { struct sljit_const const_; /* must be first */ @@ -120,8 +120,7 @@ struct sljit_s390x_const { /* Convert SLJIT register to hardware register. */ static SLJIT_INLINE sljit_gpr gpr(sljit_s32 r) { - SLJIT_ASSERT(r != SLJIT_UNUSED); - SLJIT_ASSERT(r < (sljit_s32)(sizeof(reg_map) / sizeof(reg_map[0]))); + SLJIT_ASSERT(r >= 0 && r < (sljit_s32)(sizeof(reg_map) / sizeof(reg_map[0]))); return reg_map[r]; } @@ -172,51 +171,93 @@ static sljit_s32 encode_inst(void **ptr, sljit_ins ins) return SLJIT_SUCCESS; } +#define SLJIT_ADD_SUB_NO_COMPARE(status_flags_state) \ + (((status_flags_state) & (SLJIT_CURRENT_FLAGS_ADD_SUB | SLJIT_CURRENT_FLAGS_COMPARE)) == SLJIT_CURRENT_FLAGS_ADD_SUB) + /* Map the given type to a 4-bit condition code mask. */ -static SLJIT_INLINE sljit_u8 get_cc(sljit_s32 type) { - const sljit_u8 eq = 1 << 3; /* equal {,to zero} */ - const sljit_u8 lt = 1 << 2; /* less than {,zero} */ - const sljit_u8 gt = 1 << 1; /* greater than {,zero} */ - const sljit_u8 ov = 1 << 0; /* {overflow,NaN} */ +static SLJIT_INLINE sljit_u8 get_cc(struct sljit_compiler *compiler, sljit_s32 type) { + const sljit_u8 cc0 = 1 << 3; /* equal {,to zero} */ + const sljit_u8 cc1 = 1 << 2; /* less than {,zero} */ + const sljit_u8 cc2 = 1 << 1; /* greater than {,zero} */ + const sljit_u8 cc3 = 1 << 0; /* {overflow,NaN} */ switch (type) { case SLJIT_EQUAL: + if (SLJIT_ADD_SUB_NO_COMPARE(compiler->status_flags_state)) { + sljit_s32 type = GET_FLAG_TYPE(compiler->status_flags_state); + if (type >= SLJIT_SIG_LESS && type <= SLJIT_SIG_LESS_EQUAL) + return cc0; + if (type == SLJIT_OVERFLOW) + return (cc0 | cc3); + return (cc0 | cc2); + } + case SLJIT_EQUAL_F64: - return eq; + return cc0; case SLJIT_NOT_EQUAL: + if (SLJIT_ADD_SUB_NO_COMPARE(compiler->status_flags_state)) { + sljit_s32 type = GET_FLAG_TYPE(compiler->status_flags_state); + if (type >= SLJIT_SIG_LESS && type <= SLJIT_SIG_LESS_EQUAL) + return (cc1 | cc2 | cc3); + if (type == SLJIT_OVERFLOW) + return (cc1 | cc2); + return (cc1 | cc3); + } + case SLJIT_NOT_EQUAL_F64: - return ~eq; + return (cc1 | cc2 | cc3); case SLJIT_LESS: + return cc1; + + case SLJIT_GREATER_EQUAL: + return (cc0 | cc2 | cc3); + + case SLJIT_GREATER: + if (compiler->status_flags_state & SLJIT_CURRENT_FLAGS_COMPARE) + return cc2; + return cc3; + + case SLJIT_LESS_EQUAL: + if (compiler->status_flags_state & SLJIT_CURRENT_FLAGS_COMPARE) + return (cc0 | cc1); + return (cc0 | cc1 | cc2); + case SLJIT_SIG_LESS: case SLJIT_LESS_F64: - return lt; + return cc1; - case SLJIT_LESS_EQUAL: case SLJIT_SIG_LESS_EQUAL: case SLJIT_LESS_EQUAL_F64: - return (lt | eq); + return (cc0 | cc1); - case SLJIT_GREATER: case SLJIT_SIG_GREATER: - case SLJIT_GREATER_F64: - return gt; + /* Overflow is considered greater, see SLJIT_SUB. */ + return cc2 | cc3; - case SLJIT_GREATER_EQUAL: case SLJIT_SIG_GREATER_EQUAL: - case SLJIT_GREATER_EQUAL_F64: - return (gt | eq); + return (cc0 | cc2 | cc3); case SLJIT_OVERFLOW: - case SLJIT_MUL_OVERFLOW: + if (compiler->status_flags_state & SLJIT_SET_Z) + return (cc2 | cc3); + case SLJIT_UNORDERED_F64: - return ov; + return cc3; case SLJIT_NOT_OVERFLOW: - case SLJIT_MUL_NOT_OVERFLOW: + if (compiler->status_flags_state & SLJIT_SET_Z) + return (cc0 | cc1); + case SLJIT_ORDERED_F64: - return ~ov; + return (cc0 | cc1 | cc2); + + case SLJIT_GREATER_F64: + return cc2; + + case SLJIT_GREATER_EQUAL_F64: + return (cc0 | cc2); } SLJIT_UNREACHABLE(); @@ -346,19 +387,20 @@ HAVE_FACILITY(have_misc2, MISCELLANEOUS_INSTRUCTION_EXTENSIONS_2_FACILITY) #define is_u32(d) (0 <= (d) && (d) <= 0xffffffffL) #define CHECK_SIGNED(v, bitlen) \ - ((v) == (((v) << (sizeof(v) * 8 - bitlen)) >> (sizeof(v) * 8 - bitlen))) + ((v) >= -(1 << ((bitlen) - 1)) && (v) < (1 << ((bitlen) - 1))) +#define is_s8(d) CHECK_SIGNED((d), 8) #define is_s16(d) CHECK_SIGNED((d), 16) #define is_s20(d) CHECK_SIGNED((d), 20) -#define is_s32(d) CHECK_SIGNED((d), 32) +#define is_s32(d) ((d) == (sljit_s32)(d)) -static SLJIT_INLINE sljit_uw disp_s20(sljit_s32 d) +static SLJIT_INLINE sljit_ins disp_s20(sljit_s32 d) { + SLJIT_ASSERT(is_s20(d)); + sljit_uw dh = (d >> 12) & 0xff; sljit_uw dl = (d << 8) & 0xfff00; - - SLJIT_ASSERT(is_s20(d)); - return dh | dl; + return (dh | dl) << 8; } /* TODO(carenas): variadic macro is not strictly needed */ @@ -372,12 +414,6 @@ SLJIT_S390X_INSTRUCTION(name, sljit_gpr dst, sljit_gpr src) \ return (pattern) | ((dst & 0xf) << 4) | (src & 0xf); \ } -/* ADD */ -SLJIT_S390X_RR(ar, 0x1a00) - -/* ADD LOGICAL */ -SLJIT_S390X_RR(alr, 0x1e00) - /* AND */ SLJIT_S390X_RR(nr, 0x1400) @@ -387,12 +423,6 @@ SLJIT_S390X_RR(basr, 0x0d00) /* BRANCH ON CONDITION */ SLJIT_S390X_RR(bcr, 0x0700) /* TODO(mundaym): type for mask? */ -/* COMPARE */ -SLJIT_S390X_RR(cr, 0x1900) - -/* COMPARE LOGICAL */ -SLJIT_S390X_RR(clr, 0x1500) - /* DIVIDE */ SLJIT_S390X_RR(dr, 0x1d00) @@ -408,12 +438,6 @@ SLJIT_S390X_RR(lcr, 0x1300) /* OR */ SLJIT_S390X_RR(or, 0x1600) -/* SUBTRACT */ -SLJIT_S390X_RR(sr, 0x1b00) - -/* SUBTRACT LOGICAL */ -SLJIT_S390X_RR(slr, 0x1f00) - #undef SLJIT_S390X_RR /* RRE form instructions */ @@ -423,25 +447,9 @@ SLJIT_S390X_INSTRUCTION(name, sljit_gpr dst, sljit_gpr src) \ return (pattern) | ((dst & 0xf) << 4) | (src & 0xf); \ } -/* ADD */ -SLJIT_S390X_RRE(agr, 0xb9080000) - -/* ADD LOGICAL */ -SLJIT_S390X_RRE(algr, 0xb90a0000) - -/* ADD LOGICAL WITH CARRY */ -SLJIT_S390X_RRE(alcr, 0xb9980000) -SLJIT_S390X_RRE(alcgr, 0xb9880000) - /* AND */ SLJIT_S390X_RRE(ngr, 0xb9800000) -/* COMPARE */ -SLJIT_S390X_RRE(cgr, 0xb9200000) - -/* COMPARE LOGICAL */ -SLJIT_S390X_RRE(clgr, 0xb9210000) - /* DIVIDE LOGICAL */ SLJIT_S390X_RRE(dlr, 0xb9970000) SLJIT_S390X_RRE(dlgr, 0xb9870000) @@ -482,8 +490,6 @@ SLJIT_S390X_RRE(llghr, 0xb9850000) SLJIT_S390X_RRE(mlgr, 0xb9860000) /* MULTIPLY SINGLE */ -SLJIT_S390X_RRE(msr, 0xb2520000) -SLJIT_S390X_RRE(msgr, 0xb90c0000) SLJIT_S390X_RRE(msgfr, 0xb91c0000) /* OR */ @@ -492,13 +498,6 @@ SLJIT_S390X_RRE(ogr, 0xb9810000) /* SUBTRACT */ SLJIT_S390X_RRE(sgr, 0xb9090000) -/* SUBTRACT LOGICAL */ -SLJIT_S390X_RRE(slgr, 0xb90b0000) - -/* SUBTRACT LOGICAL WITH BORROW */ -SLJIT_S390X_RRE(slbr, 0xb9990000) -SLJIT_S390X_RRE(slbgr, 0xb9890000) - #undef SLJIT_S390X_RRE /* RI-a form instructions */ @@ -509,13 +508,8 @@ SLJIT_S390X_INSTRUCTION(name, sljit_gpr reg, imm_type imm) \ } /* ADD HALFWORD IMMEDIATE */ -SLJIT_S390X_RIA(ahi, 0xa70a0000, sljit_s16) SLJIT_S390X_RIA(aghi, 0xa70b0000, sljit_s16) -/* COMPARE HALFWORD IMMEDIATE */ -SLJIT_S390X_RIA(chi, 0xa70e0000, sljit_s16) -SLJIT_S390X_RIA(cghi, 0xa70f0000, sljit_s16) - /* LOAD HALFWORD IMMEDIATE */ SLJIT_S390X_RIA(lhi, 0xa7080000, sljit_s16) SLJIT_S390X_RIA(lghi, 0xa7090000, sljit_s16) @@ -533,9 +527,6 @@ SLJIT_S390X_RIA(mghi, 0xa70d0000, sljit_s16) /* OR IMMEDIATE */ SLJIT_S390X_RIA(oilh, 0xa50a0000, sljit_u16) -/* TEST UNDER MASK */ -SLJIT_S390X_RIA(tmlh, 0xa7000000, sljit_u16) - #undef SLJIT_S390X_RIA /* RIL-a form instructions (requires extended immediate facility) */ @@ -547,30 +538,13 @@ SLJIT_S390X_INSTRUCTION(name, sljit_gpr reg, imm_type imm) \ } /* ADD IMMEDIATE */ -SLJIT_S390X_RILA(afi, 0xc20900000000, sljit_s32) SLJIT_S390X_RILA(agfi, 0xc20800000000, sljit_s32) /* ADD IMMEDIATE HIGH */ SLJIT_S390X_RILA(aih, 0xcc0800000000, sljit_s32) /* TODO(mundaym): high-word facility? */ -/* ADD LOGICAL IMMEDIATE */ -SLJIT_S390X_RILA(alfi, 0xc20b00000000, sljit_u32) -SLJIT_S390X_RILA(algfi, 0xc20a00000000, sljit_u32) - /* AND IMMEDIATE */ SLJIT_S390X_RILA(nihf, 0xc00a00000000, sljit_u32) -SLJIT_S390X_RILA(nilf, 0xc00b00000000, sljit_u32) - -/* COMPARE IMMEDIATE */ -SLJIT_S390X_RILA(cfi, 0xc20d00000000, sljit_s32) -SLJIT_S390X_RILA(cgfi, 0xc20c00000000, sljit_s32) - -/* COMPARE IMMEDIATE HIGH */ -SLJIT_S390X_RILA(cih, 0xcc0d00000000, sljit_s32) /* TODO(mundaym): high-word facility? */ - -/* COMPARE LOGICAL IMMEDIATE */ -SLJIT_S390X_RILA(clfi, 0xc20f00000000, sljit_u32) -SLJIT_S390X_RILA(clgfi, 0xc20e00000000, sljit_u32) /* EXCLUSIVE OR IMMEDIATE */ SLJIT_S390X_RILA(xilf, 0xc00700000000, sljit_u32) @@ -586,8 +560,8 @@ SLJIT_S390X_RILA(lgfi, 0xc00100000000, sljit_s32) SLJIT_S390X_RILA(llihf, 0xc00e00000000, sljit_u32) SLJIT_S390X_RILA(llilf, 0xc00f00000000, sljit_u32) -/* OR IMMEDIATE */ -SLJIT_S390X_RILA(oilf, 0xc00d00000000, sljit_u32) +/* SUBTRACT LOGICAL IMMEDIATE */ +SLJIT_S390X_RILA(slfi, 0xc20500000000, sljit_u32) #undef SLJIT_S390X_RILA @@ -606,18 +580,6 @@ SLJIT_S390X_INSTRUCTION(name, sljit_gpr r, sljit_u16 d, sljit_gpr x, sljit_gpr b return (pattern) | ri | xi | bi | di; \ } -/* ADD */ -SLJIT_S390X_RXA(a, 0x5a000000) - -/* ADD LOGICAL */ -SLJIT_S390X_RXA(al, 0x5e000000) - -/* AND */ -SLJIT_S390X_RXA(n, 0x54000000) - -/* EXCLUSIVE OR */ -SLJIT_S390X_RXA(x, 0x57000000) - /* LOAD */ SLJIT_S390X_RXA(l, 0x58000000) @@ -630,9 +592,6 @@ SLJIT_S390X_RXA(lh, 0x48000000) /* MULTIPLY SINGLE */ SLJIT_S390X_RXA(ms, 0x71000000) -/* OR */ -SLJIT_S390X_RXA(o, 0x56000000) - /* STORE */ SLJIT_S390X_RXA(st, 0x50000000) @@ -642,12 +601,6 @@ SLJIT_S390X_RXA(stc, 0x42000000) /* STORE HALFWORD */ SLJIT_S390X_RXA(sth, 0x40000000) -/* SUBTRACT */ -SLJIT_S390X_RXA(s, 0x5b000000) - -/* SUBTRACT LOGICAL */ -SLJIT_S390X_RXA(sl, 0x5f000000) - #undef SLJIT_S390X_RXA /* RXY-a instructions */ @@ -660,31 +613,11 @@ SLJIT_S390X_INSTRUCTION(name, sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b ri = (sljit_ins)(r & 0xf) << 36; \ xi = (sljit_ins)(x & 0xf) << 32; \ bi = (sljit_ins)(b & 0xf) << 28; \ - di = (sljit_ins)disp_s20(d) << 8; \ + di = disp_s20(d); \ \ return (pattern) | ri | xi | bi | di; \ } -/* ADD */ -SLJIT_S390X_RXYA(ay, 0xe3000000005a, have_ldisp()) -SLJIT_S390X_RXYA(ag, 0xe30000000008, 1) - -/* ADD LOGICAL */ -SLJIT_S390X_RXYA(aly, 0xe3000000005e, have_ldisp()) -SLJIT_S390X_RXYA(alg, 0xe3000000000a, 1) - -/* ADD LOGICAL WITH CARRY */ -SLJIT_S390X_RXYA(alc, 0xe30000000098, 1) -SLJIT_S390X_RXYA(alcg, 0xe30000000088, 1) - -/* AND */ -SLJIT_S390X_RXYA(ny, 0xe30000000054, have_ldisp()) -SLJIT_S390X_RXYA(ng, 0xe30000000080, 1) - -/* EXCLUSIVE OR */ -SLJIT_S390X_RXYA(xy, 0xe30000000057, have_ldisp()) -SLJIT_S390X_RXYA(xg, 0xe30000000082, 1) - /* LOAD */ SLJIT_S390X_RXYA(ly, 0xe30000000058, have_ldisp()) SLJIT_S390X_RXYA(lg, 0xe30000000004, 1) @@ -713,10 +646,6 @@ SLJIT_S390X_RXYA(llgh, 0xe30000000091, 1) SLJIT_S390X_RXYA(msy, 0xe30000000051, have_ldisp()) SLJIT_S390X_RXYA(msg, 0xe3000000000c, 1) -/* OR */ -SLJIT_S390X_RXYA(oy, 0xe30000000056, have_ldisp()) -SLJIT_S390X_RXYA(og, 0xe30000000081, 1) - /* STORE */ SLJIT_S390X_RXYA(sty, 0xe30000000050, have_ldisp()) SLJIT_S390X_RXYA(stg, 0xe30000000024, 1) @@ -727,41 +656,8 @@ SLJIT_S390X_RXYA(stcy, 0xe30000000072, have_ldisp()) /* STORE HALFWORD */ SLJIT_S390X_RXYA(sthy, 0xe30000000070, have_ldisp()) -/* SUBTRACT */ -SLJIT_S390X_RXYA(sy, 0xe3000000005b, have_ldisp()) -SLJIT_S390X_RXYA(sg, 0xe30000000009, 1) - -/* SUBTRACT LOGICAL */ -SLJIT_S390X_RXYA(sly, 0xe3000000005f, have_ldisp()) -SLJIT_S390X_RXYA(slg, 0xe3000000000b, 1) - -/* SUBTRACT LOGICAL WITH BORROW */ -SLJIT_S390X_RXYA(slb, 0xe30000000099, 1) -SLJIT_S390X_RXYA(slbg, 0xe30000000089, 1) - #undef SLJIT_S390X_RXYA -/* RS-a instructions */ -#define SLJIT_S390X_RSA(name, pattern) \ -SLJIT_S390X_INSTRUCTION(name, sljit_gpr reg, sljit_sw d, sljit_gpr b) \ -{ \ - sljit_ins r1 = (sljit_ins)(reg & 0xf) << 20; \ - sljit_ins b2 = (sljit_ins)(b & 0xf) << 12; \ - sljit_ins d2 = (sljit_ins)(d & 0xfff); \ - return (pattern) | r1 | b2 | d2; \ -} - -/* SHIFT LEFT SINGLE LOGICAL */ -SLJIT_S390X_RSA(sll, 0x89000000) - -/* SHIFT RIGHT SINGLE */ -SLJIT_S390X_RSA(sra, 0x8a000000) - -/* SHIFT RIGHT SINGLE LOGICAL */ -SLJIT_S390X_RSA(srl, 0x88000000) - -#undef SLJIT_S390X_RSA - /* RSY-a instructions */ #define SLJIT_S390X_RSYA(name, pattern, cond) \ SLJIT_S390X_INSTRUCTION(name, sljit_gpr dst, sljit_gpr src, sljit_sw d, sljit_gpr b) \ @@ -772,7 +668,7 @@ SLJIT_S390X_INSTRUCTION(name, sljit_gpr dst, sljit_gpr src, sljit_sw d, sljit_gp r1 = (sljit_ins)(dst & 0xf) << 36; \ r3 = (sljit_ins)(src & 0xf) << 32; \ b2 = (sljit_ins)(b & 0xf) << 28; \ - d2 = (sljit_ins)disp_s20(d) << 8; \ + d2 = disp_s20(d); \ \ return (pattern) | r1 | r3 | b2 | d2; \ } @@ -786,9 +682,6 @@ SLJIT_S390X_RSYA(sllg, 0xeb000000000d, 1) /* SHIFT RIGHT SINGLE */ SLJIT_S390X_RSYA(srag, 0xeb000000000a, 1) -/* SHIFT RIGHT SINGLE LOGICAL */ -SLJIT_S390X_RSYA(srlg, 0xeb000000000c, 1) - /* STORE MULTIPLE */ SLJIT_S390X_RSYA(stmg, 0xeb0000000024, 1) @@ -831,26 +724,6 @@ SLJIT_S390X_RIEF(risbhg, 0xec000000005d) #undef SLJIT_S390X_RIEF -/* RRF-a instructions */ -#define SLJIT_S390X_RRFA(name, pattern, cond) \ -SLJIT_S390X_INSTRUCTION(name, sljit_gpr dst, sljit_gpr src1, sljit_gpr src2) \ -{ \ - sljit_ins r1, r2, r3; \ -\ - SLJIT_ASSERT(cond); \ - r1 = (sljit_ins)(dst & 0xf) << 4; \ - r2 = (sljit_ins)(src1 & 0xf); \ - r3 = (sljit_ins)(src2 & 0xf) << 12; \ -\ - return (pattern) | r3 | r1 | r2; \ -} - -/* MULTIPLY */ -SLJIT_S390X_RRFA(msrkc, 0xb9fd0000, have_misc2()) -SLJIT_S390X_RRFA(msgrkc, 0xb9ed0000, have_misc2()) - -#undef SLJIT_S390X_RRFA - /* RRF-c instructions (require load/store-on-condition 1 facility) */ #define SLJIT_S390X_RRFC(name, pattern) \ SLJIT_S390X_INSTRUCTION(name, sljit_gpr dst, sljit_gpr src, sljit_uw mask) \ @@ -919,6 +792,13 @@ SLJIT_S390X_INSTRUCTION(br, sljit_gpr target) return 0x07f0 | target; } +SLJIT_S390X_INSTRUCTION(brc, sljit_uw mask, sljit_sw target) +{ + sljit_ins m1 = (sljit_ins)(mask & 0xf) << 20; + sljit_ins ri2 = (sljit_ins)target & 0xffff; + return 0xa7040000L | m1 | ri2; +} + SLJIT_S390X_INSTRUCTION(brcl, sljit_uw mask, sljit_sw target) { sljit_ins m1 = (sljit_ins)(mask & 0xf) << 36; @@ -940,6 +820,12 @@ SLJIT_S390X_INSTRUCTION(ipm, sljit_gpr dst) return 0xb2220000 | ((sljit_ins)(dst & 0xf) << 4); } +/* SET PROGRAM MASK */ +SLJIT_S390X_INSTRUCTION(spm, sljit_gpr dst) +{ + return 0x0400 | ((sljit_ins)(dst & 0xf) << 4); +} + /* ROTATE THEN INSERT SELECTED BITS HIGH (ZERO) */ SLJIT_S390X_INSTRUCTION(risbhgz, sljit_gpr dst, sljit_gpr src, sljit_u8 start, sljit_u8 end, sljit_u8 rot) { @@ -948,30 +834,20 @@ SLJIT_S390X_INSTRUCTION(risbhgz, sljit_gpr dst, sljit_gpr src, sljit_u8 start, s #undef SLJIT_S390X_INSTRUCTION -/* load condition code as needed to match type */ -static sljit_s32 push_load_cc(struct sljit_compiler *compiler, sljit_s32 type) +static sljit_s32 update_zero_overflow(struct sljit_compiler *compiler, sljit_s32 op, sljit_gpr dst_r) { - type &= ~SLJIT_I32_OP; - switch (type) { - case SLJIT_ZERO: - case SLJIT_NOT_ZERO: - return push_inst(compiler, cih(flag_r, 0)); - break; - default: - return push_inst(compiler, tmlh(flag_r, 0x3000)); - break; - } - return SLJIT_SUCCESS; -} - -static sljit_s32 push_store_zero_flag(struct sljit_compiler *compiler, sljit_s32 op, sljit_gpr source) -{ - /* insert low 32-bits into high 32-bits of flag register */ - FAIL_IF(push_inst(compiler, risbhgz(flag_r, source, 0, 31, 32))); - if (!(op & SLJIT_I32_OP)) { - /* OR high 32-bits with high 32-bits of flag register */ - return push_inst(compiler, rosbg(flag_r, source, 0, 31, 0)); - } + /* Condition codes: bits 18 and 19. + Transformation: + 0 (zero and no overflow) : unchanged + 1 (non-zero and no overflow) : unchanged + 2 (zero and overflow) : decreased by 1 + 3 (non-zero and overflow) : decreased by 1 if non-zero */ + FAIL_IF(push_inst(compiler, brc(0xc, 2 + 2 + ((op & SLJIT_I32_OP) ? 1 : 2) + 2 + 3 + 1))); + FAIL_IF(push_inst(compiler, ipm(flag_r))); + FAIL_IF(push_inst(compiler, (op & SLJIT_I32_OP) ? or(dst_r, dst_r) : ogr(dst_r, dst_r))); + FAIL_IF(push_inst(compiler, brc(0x8, 2 + 3))); + FAIL_IF(push_inst(compiler, slfi(flag_r, 0x10000000))); + FAIL_IF(push_inst(compiler, spm(flag_r))); return SLJIT_SUCCESS; } @@ -1088,18 +964,19 @@ static sljit_s32 make_addr_bx(struct sljit_compiler *compiler, #define WHEN(cond, r, i1, i2, addr) \ (cond) ? EVAL(i1, r, addr) : EVAL(i2, r, addr) +/* May clobber tmp1. */ static sljit_s32 load_word(struct sljit_compiler *compiler, sljit_gpr dst, sljit_s32 src, sljit_sw srcw, - sljit_gpr tmp /* clobbered */, sljit_s32 is_32bit) + sljit_s32 is_32bit) { struct addr addr; sljit_ins ins; SLJIT_ASSERT(src & SLJIT_MEM); if (have_ldisp() || !is_32bit) - FAIL_IF(make_addr_bxy(compiler, &addr, src, srcw, tmp)); + FAIL_IF(make_addr_bxy(compiler, &addr, src, srcw, tmp1)); else - FAIL_IF(make_addr_bx(compiler, &addr, src, srcw, tmp)); + FAIL_IF(make_addr_bx(compiler, &addr, src, srcw, tmp1)); if (is_32bit) ins = WHEN(is_u12(addr.offset), dst, l, ly, addr); @@ -1109,18 +986,19 @@ static sljit_s32 load_word(struct sljit_compiler *compiler, sljit_gpr dst, return push_inst(compiler, ins); } +/* May clobber tmp1. */ static sljit_s32 store_word(struct sljit_compiler *compiler, sljit_gpr src, sljit_s32 dst, sljit_sw dstw, - sljit_gpr tmp /* clobbered */, sljit_s32 is_32bit) + sljit_s32 is_32bit) { struct addr addr; sljit_ins ins; SLJIT_ASSERT(dst & SLJIT_MEM); if (have_ldisp() || !is_32bit) - FAIL_IF(make_addr_bxy(compiler, &addr, dst, dstw, tmp)); + FAIL_IF(make_addr_bxy(compiler, &addr, dst, dstw, tmp1)); else - FAIL_IF(make_addr_bx(compiler, &addr, dst, dstw, tmp)); + FAIL_IF(make_addr_bx(compiler, &addr, dst, dstw, tmp1)); if (is_32bit) ins = WHEN(is_u12(addr.offset), src, st, sty, addr); @@ -1132,6 +1010,358 @@ static sljit_s32 store_word(struct sljit_compiler *compiler, sljit_gpr src, #undef WHEN +static sljit_s32 emit_move(struct sljit_compiler *compiler, + sljit_gpr dst_r, + sljit_s32 src, sljit_sw srcw) +{ + SLJIT_ASSERT(!SLOW_IS_REG(src) || dst_r != gpr(src & REG_MASK)); + + if (src & SLJIT_IMM) + return push_load_imm_inst(compiler, dst_r, srcw); + + if (src & SLJIT_MEM) + return load_word(compiler, dst_r, src, srcw, (compiler->mode & SLJIT_I32_OP) != 0); + + sljit_gpr src_r = gpr(src & REG_MASK); + return push_inst(compiler, (compiler->mode & SLJIT_I32_OP) ? lr(dst_r, src_r) : lgr(dst_r, src_r)); +} + +static sljit_s32 emit_rr(struct sljit_compiler *compiler, sljit_ins ins, + sljit_s32 dst, + sljit_s32 src1, sljit_sw src1w, + sljit_s32 src2, sljit_sw src2w) +{ + sljit_gpr dst_r = tmp0; + sljit_gpr src_r = tmp1; + sljit_s32 needs_move = 1; + + if (SLOW_IS_REG(dst)) { + dst_r = gpr(dst & REG_MASK); + + if (dst == src1) + needs_move = 0; + else if (dst == src2) { + dst_r = tmp0; + needs_move = 2; + } + } + + if (needs_move) + FAIL_IF(emit_move(compiler, dst_r, src1, src1w)); + + if (FAST_IS_REG(src2)) + src_r = gpr(src2 & REG_MASK); + else + FAIL_IF(emit_move(compiler, tmp1, src2, src2w)); + + FAIL_IF(push_inst(compiler, ins | (dst_r << 4) | src_r)); + + if (needs_move != 2) + return SLJIT_SUCCESS; + + dst_r = gpr(dst & REG_MASK); + return push_inst(compiler, (compiler->mode & SLJIT_I32_OP) ? lr(dst_r, tmp0) : lgr(dst_r, tmp0)); +} + +static sljit_s32 emit_rrf(struct sljit_compiler *compiler, sljit_ins ins, + sljit_s32 dst, + sljit_s32 src1, sljit_sw src1w, + sljit_s32 src2, sljit_sw src2w) +{ + sljit_gpr dst_r = SLOW_IS_REG(dst) ? gpr(dst & REG_MASK) : tmp0; + sljit_gpr src1_r = tmp0; + sljit_gpr src2_r = tmp1; + + if (FAST_IS_REG(src1)) + src1_r = gpr(src1 & REG_MASK); + else + FAIL_IF(emit_move(compiler, tmp0, src1, src1w)); + + if (FAST_IS_REG(src2)) + src2_r = gpr(src2 & REG_MASK); + else + FAIL_IF(emit_move(compiler, tmp1, src2, src2w)); + + return push_inst(compiler, ins | (dst_r << 4) | src1_r | (src2_r << 12)); +} + +typedef enum { + RI_A, + RIL_A, +} emit_ril_type; + +static sljit_s32 emit_ri(struct sljit_compiler *compiler, sljit_ins ins, + sljit_s32 dst, + sljit_s32 src1, sljit_sw src1w, + sljit_sw src2w, + emit_ril_type type) +{ + sljit_gpr dst_r = tmp0; + sljit_s32 needs_move = 1; + + if (SLOW_IS_REG(dst)) { + dst_r = gpr(dst & REG_MASK); + + if (dst == src1) + needs_move = 0; + } + + if (needs_move) + FAIL_IF(emit_move(compiler, dst_r, src1, src1w)); + + if (type == RIL_A) + return push_inst(compiler, ins | (dst_r << 36) | (src2w & 0xffffffff)); + return push_inst(compiler, ins | (dst_r << 20) | (src2w & 0xffff)); +} + +static sljit_s32 emit_rie_d(struct sljit_compiler *compiler, sljit_ins ins, + sljit_s32 dst, + sljit_s32 src1, sljit_sw src1w, + sljit_sw src2w) +{ + sljit_gpr dst_r = SLOW_IS_REG(dst) ? gpr(dst & REG_MASK) : tmp0; + sljit_gpr src_r = tmp0; + + if (!SLOW_IS_REG(src1)) + FAIL_IF(emit_move(compiler, tmp0, src1, src1w)); + else + src_r = gpr(src1 & REG_MASK); + + return push_inst(compiler, ins | (dst_r << 36) | (src_r << 32) | (src2w & 0xffff) << 16); +} + +typedef enum { + RX_A, + RXY_A, +} emit_rx_type; + +static sljit_s32 emit_rx(struct sljit_compiler *compiler, sljit_ins ins, + sljit_s32 dst, + sljit_s32 src1, sljit_sw src1w, + sljit_s32 src2, sljit_sw src2w, + emit_rx_type type) +{ + sljit_gpr dst_r = tmp0; + sljit_s32 needs_move = 1; + sljit_gpr base, index; + + SLJIT_ASSERT(src2 & SLJIT_MEM); + + if (SLOW_IS_REG(dst)) { + dst_r = gpr(dst); + + if (dst == src1) + needs_move = 0; + else if (dst == (src2 & REG_MASK) || (dst == OFFS_REG(src2))) { + dst_r = tmp0; + needs_move = 2; + } + } + + if (needs_move) + FAIL_IF(emit_move(compiler, dst_r, src1, src1w)); + + base = gpr(src2 & REG_MASK); + index = tmp0; + + if (src2 & OFFS_REG_MASK) { + index = gpr(OFFS_REG(src2)); + + if (src2w != 0) { + FAIL_IF(push_inst(compiler, sllg(tmp1, index, src2w & 0x3, 0))); + src2w = 0; + index = tmp1; + } + } else if ((type == RX_A && !is_u12(src2w)) || (type == RXY_A && !is_s20(src2w))) { + FAIL_IF(push_load_imm_inst(compiler, tmp1, src2w)); + + if (src2 & REG_MASK) + index = tmp1; + else + base = tmp1; + src2w = 0; + } + + if (type == RX_A) + ins |= (dst_r << 20) | (index << 16) | (base << 12) | src2w; + else + ins |= (dst_r << 36) | (index << 32) | (base << 28) | disp_s20(src2w); + + FAIL_IF(push_inst(compiler, ins)); + + if (needs_move != 2) + return SLJIT_SUCCESS; + + dst_r = gpr(dst); + return push_inst(compiler, (compiler->mode & SLJIT_I32_OP) ? lr(dst_r, tmp0) : lgr(dst_r, tmp0)); +} + +static sljit_s32 emit_siy(struct sljit_compiler *compiler, sljit_ins ins, + sljit_s32 dst, sljit_sw dstw, + sljit_sw srcw) +{ + SLJIT_ASSERT(dst & SLJIT_MEM); + + sljit_gpr dst_r = tmp1; + + if (dst & OFFS_REG_MASK) { + sljit_gpr index = tmp1; + + if ((dstw & 0x3) == 0) + index = gpr(OFFS_REG(dst)); + else + FAIL_IF(push_inst(compiler, sllg(tmp1, index, dstw & 0x3, 0))); + + FAIL_IF(push_inst(compiler, la(tmp1, 0, dst_r, index))); + dstw = 0; + } + else if (!is_s20(dstw)) { + FAIL_IF(push_load_imm_inst(compiler, tmp1, dstw)); + + if (dst & REG_MASK) + FAIL_IF(push_inst(compiler, la(tmp1, 0, dst_r, tmp1))); + + dstw = 0; + } + else + dst_r = gpr(dst & REG_MASK); + + return push_inst(compiler, ins | ((srcw & 0xff) << 32) | (dst_r << 28) | disp_s20(dstw)); +} + +struct ins_forms { + sljit_ins op_r; + sljit_ins op_gr; + sljit_ins op_rk; + sljit_ins op_grk; + sljit_ins op; + sljit_ins op_y; + sljit_ins op_g; +}; + +static sljit_s32 emit_commutative(struct sljit_compiler *compiler, const struct ins_forms *forms, + sljit_s32 dst, sljit_sw dstw, + sljit_s32 src1, sljit_sw src1w, + sljit_s32 src2, sljit_sw src2w) +{ + sljit_s32 mode = compiler->mode; + sljit_ins ins, ins_k; + + if ((src1 | src2) & SLJIT_MEM) { + sljit_ins ins12, ins20; + + if (mode & SLJIT_I32_OP) { + ins12 = forms->op; + ins20 = forms->op_y; + } + else { + ins12 = 0; + ins20 = forms->op_g; + } + + if (ins12 && ins20) { + /* Extra instructions needed for address computation can be executed independently. */ + if ((src2 & SLJIT_MEM) && (!(src1 & SLJIT_MEM) + || ((src1 & OFFS_REG_MASK) ? (src1w & 0x3) == 0 : is_s20(src1w)))) { + if ((src2 & OFFS_REG_MASK) || is_u12(src2w) || !is_s20(src2w)) + return emit_rx(compiler, ins12, dst, src1, src1w, src2, src2w, RX_A); + + return emit_rx(compiler, ins20, dst, src1, src1w, src2, src2w, RXY_A); + } + + if (src1 & SLJIT_MEM) { + if ((src1 & OFFS_REG_MASK) || is_u12(src1w) || !is_s20(src1w)) + return emit_rx(compiler, ins12, dst, src2, src2w, src1, src1w, RX_A); + + return emit_rx(compiler, ins20, dst, src2, src2w, src1, src1w, RXY_A); + } + } + else if (ins12 || ins20) { + emit_rx_type rx_type; + + if (ins12) { + rx_type = RX_A; + ins = ins12; + } + else { + rx_type = RXY_A; + ins = ins20; + } + + if ((src2 & SLJIT_MEM) && (!(src1 & SLJIT_MEM) + || ((src1 & OFFS_REG_MASK) ? (src1w & 0x3) == 0 : (rx_type == RX_A ? is_u12(src1w) : is_s20(src1w))))) + return emit_rx(compiler, ins, dst, src1, src1w, src2, src2w, rx_type); + + if (src1 & SLJIT_MEM) + return emit_rx(compiler, ins, dst, src2, src2w, src1, src1w, rx_type); + } + } + + if (mode & SLJIT_I32_OP) { + ins = forms->op_r; + ins_k = forms->op_rk; + } + else { + ins = forms->op_gr; + ins_k = forms->op_grk; + } + + SLJIT_ASSERT(ins != 0 || ins_k != 0); + + if (ins && SLOW_IS_REG(dst)) { + if (dst == src1) + return emit_rr(compiler, ins, dst, src1, src1w, src2, src2w); + + if (dst == src2) + return emit_rr(compiler, ins, dst, src2, src2w, src1, src1w); + } + + if (ins_k == 0) + return emit_rr(compiler, ins, dst, src1, src1w, src2, src2w); + + return emit_rrf(compiler, ins_k, dst, src1, src1w, src2, src2w); +} + +static sljit_s32 emit_non_commutative(struct sljit_compiler *compiler, const struct ins_forms *forms, + sljit_s32 dst, sljit_sw dstw, + sljit_s32 src1, sljit_sw src1w, + sljit_s32 src2, sljit_sw src2w) +{ + sljit_s32 mode = compiler->mode; + sljit_ins ins; + + if (src2 & SLJIT_MEM) { + sljit_ins ins12, ins20; + + if (mode & SLJIT_I32_OP) { + ins12 = forms->op; + ins20 = forms->op_y; + } + else { + ins12 = 0; + ins20 = forms->op_g; + } + + if (ins12 && ins20) { + if ((src2 & OFFS_REG_MASK) || is_u12(src2w) || !is_s20(src2w)) + return emit_rx(compiler, ins12, dst, src1, src1w, src2, src2w, RX_A); + + return emit_rx(compiler, ins20, dst, src1, src1w, src2, src2w, RXY_A); + } + else if (ins12) + return emit_rx(compiler, ins12, dst, src1, src1w, src2, src2w, RX_A); + else if (ins20) + return emit_rx(compiler, ins20, dst, src1, src1w, src2, src2w, RXY_A); + } + + ins = (mode & SLJIT_I32_OP) ? forms->op_rk : forms->op_grk; + + if (ins == 0 || (SLOW_IS_REG(dst) && dst == src1)) + return emit_rr(compiler, (mode & SLJIT_I32_OP) ? forms->op_r : forms->op_gr, dst, src1, src1w, src2, src2w); + + return emit_rrf(compiler, ins, dst, src1, src1w, src2, src2w); +} + SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compiler) { struct sljit_label *label; @@ -1465,7 +1695,8 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op0(struct sljit_compiler *compile op = GET_OPCODE(op) | (op & SLJIT_I32_OP); switch (op) { case SLJIT_BREAKPOINT: - /* TODO(mundaym): insert real breakpoint? */ + /* The following invalid instruction is emitted by gdb. */ + return push_inst(compiler, 0x0001 /* 2-byte trap */); case SLJIT_NOP: return push_inst(compiler, 0x0700 /* 2-byte nop */); case SLJIT_LMUL_UW: @@ -1559,6 +1790,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op1(struct sljit_compiler *compile /* TODO(carenas): implement prefetch? */ return SLJIT_SUCCESS; } + if (opcode >= SLJIT_MOV && opcode <= SLJIT_MOV_P) { /* LOAD REGISTER */ if (FAST_IS_REG(dst) && FAST_IS_REG(src)) { @@ -1609,11 +1841,6 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op1(struct sljit_compiler *compile SLJIT_UNREACHABLE(); } FAIL_IF(push_inst(compiler, ins)); - if (HAS_FLAGS(op)) { - /* only handle zero flag */ - SLJIT_ASSERT(!(op & VARIABLE_FLAG_MASK)); - return push_store_zero_flag(compiler, op, dst_r); - } return SLJIT_SUCCESS; } /* LOAD IMMEDIATE */ @@ -1690,11 +1917,6 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op1(struct sljit_compiler *compile SLJIT_UNREACHABLE(); } FAIL_IF(push_inst(compiler, ins)); - if (HAS_FLAGS(op)) { - /* only handle zero flag */ - SLJIT_ASSERT(!(op & VARIABLE_FLAG_MASK)); - return push_store_zero_flag(compiler, op, reg); - } return SLJIT_SUCCESS; } /* STORE and STORE IMMEDIATE */ @@ -1723,11 +1945,6 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op1(struct sljit_compiler *compile case SLJIT_MOV_P: case SLJIT_MOV: FAIL_IF(push_inst(compiler, LEVAL(stg))); - if (HAS_FLAGS(op)) { - /* only handle zero flag */ - SLJIT_ASSERT(!(op & VARIABLE_FLAG_MASK)); - return push_store_zero_flag(compiler, op, reg); - } return SLJIT_SUCCESS; default: SLJIT_UNREACHABLE(); @@ -1767,11 +1984,6 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op1(struct sljit_compiler *compile FAIL_IF(make_addr_bxy(compiler, &mem, dst, dstw, tmp1)); FAIL_IF(push_inst(compiler, EVAL(stg, tmp0, mem))); - if (HAS_FLAGS(op)) { - /* only handle zero flag */ - SLJIT_ASSERT(!(op & VARIABLE_FLAG_MASK)); - return push_store_zero_flag(compiler, op, tmp0); - } return SLJIT_SUCCESS; default: SLJIT_UNREACHABLE(); @@ -1785,7 +1997,9 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op1(struct sljit_compiler *compile dst_r = SLOW_IS_REG(dst) ? gpr(REG_MASK & dst) : tmp0; src_r = FAST_IS_REG(src) ? gpr(REG_MASK & src) : tmp0; if (src & SLJIT_MEM) - FAIL_IF(load_word(compiler, src_r, src, srcw, tmp1, src & SLJIT_I32_OP)); + FAIL_IF(load_word(compiler, src_r, src, srcw, src & SLJIT_I32_OP)); + + compiler->status_flags_state = op & (VARIABLE_FLAG_MASK | SLJIT_SET_Z); /* TODO(mundaym): optimize loads and stores */ switch (opcode | (op & SLJIT_I32_OP)) { @@ -1810,9 +2024,11 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op1(struct sljit_compiler *compile } break; case SLJIT_NEG: + compiler->status_flags_state |= SLJIT_CURRENT_FLAGS_ADD_SUB; FAIL_IF(push_inst(compiler, lcgr(dst_r, src_r))); break; case SLJIT_NEG32: + compiler->status_flags_state |= SLJIT_CURRENT_FLAGS_ADD_SUB; FAIL_IF(push_inst(compiler, lcr(dst_r, src_r))); break; case SLJIT_CLZ: @@ -1839,17 +2055,12 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op1(struct sljit_compiler *compile SLJIT_UNREACHABLE(); } - /* write condition code to emulated flag register */ - if (op & VARIABLE_FLAG_MASK) - FAIL_IF(push_inst(compiler, ipm(flag_r))); - - /* write zero flag to emulated flag register */ - if (op & SLJIT_SET_Z) - FAIL_IF(push_store_zero_flag(compiler, op, dst_r)); + if ((op & (SLJIT_SET_Z | VARIABLE_FLAG_MASK)) == (SLJIT_SET_Z | SLJIT_SET_OVERFLOW)) + FAIL_IF(update_zero_overflow(compiler, op, dst_r)); /* TODO(carenas): doesn't need FAIL_IF */ if ((dst != SLJIT_UNUSED) && (dst & SLJIT_MEM)) - FAIL_IF(store_word(compiler, dst_r, dst, dstw, tmp1, op & SLJIT_I32_OP)); + FAIL_IF(store_word(compiler, dst_r, dst, dstw, op & SLJIT_I32_OP)); return SLJIT_SUCCESS; } @@ -1887,530 +2098,554 @@ static SLJIT_INLINE int sets_signed_flag(sljit_s32 op) return 0; } -/* Report whether we have an instruction for: - op dst src imm - where dst and src are separate registers. */ -static int have_op_3_imm(sljit_s32 op, sljit_sw imm) { - return 0; /* TODO(mundaym): implement */ -} - -/* Report whether we have an instruction for: - op reg imm - where reg is both a source and the destination. */ -static int have_op_2_imm(sljit_s32 op, sljit_sw imm) { - switch (GET_OPCODE(op) | (op & SLJIT_I32_OP)) { - case SLJIT_ADD32: - case SLJIT_ADD: - if (!HAS_FLAGS(op) || sets_signed_flag(op)) - return have_eimm() ? is_s32(imm) : is_s16(imm); +static const struct ins_forms add_forms = { + 0x1a00, /* ar */ + 0xb9080000, /* agr */ + 0xb9f80000, /* ark */ + 0xb9e80000, /* agrk */ + 0x5a000000, /* a */ + 0xe3000000005a, /* ay */ + 0xe30000000008, /* ag */ +}; - return have_eimm() && is_u32(imm); - case SLJIT_MUL32: - case SLJIT_MUL: - /* TODO(mundaym): general extension check */ - /* for ms{,g}fi */ - if (op & VARIABLE_FLAG_MASK) - return 0; - - return have_genext() && is_s16(imm); - case SLJIT_OR32: - case SLJIT_XOR32: - case SLJIT_AND32: - /* only use if have extended immediate facility */ - /* this ensures flags are set correctly */ - return have_eimm(); - case SLJIT_AND: - case SLJIT_OR: - case SLJIT_XOR: - /* TODO(mundaym): make this more flexible */ - /* avoid using immediate variations, flags */ - /* won't be set correctly */ - return 0; - case SLJIT_ADDC32: - case SLJIT_ADDC: - /* no ADD LOGICAL WITH CARRY IMMEDIATE */ - return 0; - case SLJIT_SUB: - case SLJIT_SUB32: - case SLJIT_SUBC: - case SLJIT_SUBC32: - /* no SUBTRACT IMMEDIATE */ - /* TODO(mundaym): SUBTRACT LOGICAL IMMEDIATE */ - return 0; - } - return 0; -} +static const struct ins_forms logical_add_forms = { + 0x1e00, /* alr */ + 0xb90a0000, /* algr */ + 0xb9fa0000, /* alrk */ + 0xb9ea0000, /* algrk */ + 0x5e000000, /* al */ + 0xe3000000005e, /* aly */ + 0xe3000000000a, /* alg */ +}; -SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op2(struct sljit_compiler *compiler, sljit_s32 op, +static sljit_s32 sljit_emit_add(struct sljit_compiler *compiler, sljit_s32 op, sljit_s32 dst, sljit_sw dstw, sljit_s32 src1, sljit_sw src1w, sljit_s32 src2, sljit_sw src2w) { - CHECK_ERROR(); - CHECK(check_sljit_emit_op2(compiler, op, dst, dstw, src1, src1w, src2, src2w)); - ADJUST_LOCAL_OFFSET(dst, dstw); - ADJUST_LOCAL_OFFSET(src1, src1w); - ADJUST_LOCAL_OFFSET(src2, src2w); - - if (dst == SLJIT_UNUSED && !HAS_FLAGS(op)) - return SLJIT_SUCCESS; - - sljit_gpr dst_r = SLOW_IS_REG(dst) ? gpr(dst & REG_MASK) : tmp0; + int sets_overflow = (op & VARIABLE_FLAG_MASK) == SLJIT_SET_OVERFLOW; + int sets_zero_overflow = (op & (SLJIT_SET_Z | VARIABLE_FLAG_MASK)) == (SLJIT_SET_Z | SLJIT_SET_OVERFLOW); + const struct ins_forms *forms; + sljit_ins ins; - if (is_commutative(op)) { - #define SWAP_ARGS \ - do { \ - sljit_s32 t = src1; \ - sljit_sw tw = src1w; \ - src1 = src2; \ - src1w = src2w; \ - src2 = t; \ - src2w = tw; \ - } while(0); - - /* prefer immediate in src2 */ - if (src1 & SLJIT_IMM) { - SWAP_ARGS + if (src2 & SLJIT_IMM) { + if (!sets_zero_overflow && is_s8(src2w) && (src1 & SLJIT_MEM) && (dst == src1 && dstw == src1w)) { + if (sets_overflow) + ins = (op & SLJIT_I32_OP) ? 0xeb000000006a /* asi */ : 0xeb000000007a /* agsi */; + else + ins = (op & SLJIT_I32_OP) ? 0xeb000000006e /* alsi */ : 0xeb000000007e /* algsi */; + return emit_siy(compiler, ins, dst, dstw, src2w); } - /* prefer to have src1 use same register as dst */ - if (FAST_IS_REG(src2) && gpr(src2 & REG_MASK) == dst_r) { - SWAP_ARGS + if (is_s16(src2w)) { + if (sets_overflow) + ins = (op & SLJIT_I32_OP) ? 0xec00000000d8 /* ahik */ : 0xec00000000d9 /* aghik */; + else + ins = (op & SLJIT_I32_OP) ? 0xec00000000da /* alhsik */ : 0xec00000000db /* alghsik */; + FAIL_IF(emit_rie_d(compiler, ins, dst, src1, src1w, src2w)); + goto done; } - /* prefer memory argument in src2 */ - if (FAST_IS_REG(src2) && (src1 & SLJIT_MEM)) { - SWAP_ARGS + if (!sets_overflow) { + if ((op & SLJIT_I32_OP) || is_u32(src2w)) { + ins = (op & SLJIT_I32_OP) ? 0xc20b00000000 /* alfi */ : 0xc20a00000000 /* algfi */; + FAIL_IF(emit_ri(compiler, ins, dst, src1, src1w, src2w, RIL_A)); + goto done; + } + if (is_u32(-src2w)) { + FAIL_IF(emit_ri(compiler, 0xc20400000000 /* slgfi */, dst, src1, src1w, -src2w, RIL_A)); + goto done; + } + } + else if ((op & SLJIT_I32_OP) || is_s32(src2w)) { + ins = (op & SLJIT_I32_OP) ? 0xc20900000000 /* afi */ : 0xc20800000000 /* agfi */; + FAIL_IF(emit_ri(compiler, ins, dst, src1, src1w, src2w, RIL_A)); + goto done; } - #undef SWAP_ARGS } - /* src1 must be in a register */ - sljit_gpr src1_r = FAST_IS_REG(src1) ? gpr(src1 & REG_MASK) : tmp0; - if (src1 & SLJIT_IMM) - FAIL_IF(push_load_imm_inst(compiler, src1_r, src1w)); - - if (src1 & SLJIT_MEM) - FAIL_IF(load_word(compiler, src1_r, src1, src1w, tmp1, op & SLJIT_I32_OP)); - - /* emit comparison before subtract */ - if (GET_OPCODE(op) == SLJIT_SUB && (op & VARIABLE_FLAG_MASK)) { - sljit_sw cmp = 0; - switch (GET_FLAG_TYPE(op)) { - case SLJIT_LESS: - case SLJIT_LESS_EQUAL: - case SLJIT_GREATER: - case SLJIT_GREATER_EQUAL: - cmp = 1; /* unsigned */ - break; - case SLJIT_EQUAL: - case SLJIT_SIG_LESS: - case SLJIT_SIG_LESS_EQUAL: - case SLJIT_SIG_GREATER: - case SLJIT_SIG_GREATER_EQUAL: - cmp = -1; /* signed */ - break; - } - if (cmp) { - /* clear flags - no need to generate now */ - op &= ~VARIABLE_FLAG_MASK; - sljit_gpr src2_r = FAST_IS_REG(src2) ? gpr(src2 & REG_MASK) : tmp1; - if (src2 & SLJIT_IMM) { - #define LEVAL(i) i(src1_r, src2w) - if (cmp > 0 && is_u32(src2w)) { - /* unsigned */ - FAIL_IF(push_inst(compiler, - WHEN2(op & SLJIT_I32_OP, clfi, clgfi))); - } - else if (cmp < 0 && is_s16(src2w)) { - /* signed */ - FAIL_IF(push_inst(compiler, - WHEN2(op & SLJIT_I32_OP, chi, cghi))); - } - else if (cmp < 0 && is_s32(src2w)) { - /* signed */ - FAIL_IF(push_inst(compiler, - WHEN2(op & SLJIT_I32_OP, cfi, cgfi))); - } - #undef LEVAL - #define LEVAL(i) i(src1_r, src2_r) - else { - FAIL_IF(push_load_imm_inst(compiler, src2_r, src2w)); - if (cmp > 0) { - /* unsigned */ - FAIL_IF(push_inst(compiler, - WHEN2(op & SLJIT_I32_OP, clr, clgr))); - } - if (cmp < 0) { - /* signed */ - FAIL_IF(push_inst(compiler, - WHEN2(op & SLJIT_I32_OP, cr, cgr))); - } + forms = sets_overflow ? &add_forms : &logical_add_forms; + FAIL_IF(emit_commutative(compiler, forms, dst, dstw, src1, src1w, src2, src2w)); + +done: + if (sets_zero_overflow) + FAIL_IF(update_zero_overflow(compiler, op, SLOW_IS_REG(dst) ? gpr(dst & REG_MASK) : tmp0)); + + if (dst & SLJIT_MEM) + return store_word(compiler, tmp0, dst, dstw, op & SLJIT_I32_OP); + + return SLJIT_SUCCESS; +} + +static const struct ins_forms sub_forms = { + 0x1b00, /* sr */ + 0xb9090000, /* sgr */ + 0xb9f90000, /* srk */ + 0xb9e90000, /* sgrk */ + 0x5b000000, /* s */ + 0xe3000000005b, /* sy */ + 0xe30000000009, /* sg */ +}; + +static const struct ins_forms logical_sub_forms = { + 0x1f00, /* slr */ + 0xb90b0000, /* slgr */ + 0xb9fb0000, /* slrk */ + 0xb9eb0000, /* slgrk */ + 0x5f000000, /* sl */ + 0xe3000000005f, /* sly */ + 0xe3000000000b, /* slg */ +}; + +static sljit_s32 sljit_emit_sub(struct sljit_compiler *compiler, sljit_s32 op, + sljit_s32 dst, sljit_sw dstw, + sljit_s32 src1, sljit_sw src1w, + sljit_s32 src2, sljit_sw src2w) +{ + int sets_signed = sets_signed_flag(op); + int sets_zero_overflow = (op & (SLJIT_SET_Z | VARIABLE_FLAG_MASK)) == (SLJIT_SET_Z | SLJIT_SET_OVERFLOW); + const struct ins_forms *forms; + sljit_ins ins; + + if (dst == SLJIT_UNUSED && GET_FLAG_TYPE(op) <= SLJIT_SIG_LESS_EQUAL) { + int compare_signed = GET_FLAG_TYPE(op) >= SLJIT_SIG_LESS; + + compiler->status_flags_state |= SLJIT_CURRENT_FLAGS_COMPARE; + + if (src2 & SLJIT_IMM) { + if (compare_signed || ((op & VARIABLE_FLAG_MASK) == 0 && is_s32(src2w))) + { + if ((op & SLJIT_I32_OP) || is_s32(src2w)) { + ins = (op & SLJIT_I32_OP) ? 0xc20d00000000 /* cfi */ : 0xc20c00000000 /* cgfi */; + return emit_ri(compiler, ins, src1, src1, src1w, src2w, RIL_A); } } else { - if (src2 & SLJIT_MEM) { - /* TODO(mundaym): comparisons with memory */ - /* load src2 into register */ - FAIL_IF(load_word(compiler, src2_r, src2, src2w, tmp1, op & SLJIT_I32_OP)); + if ((op & SLJIT_I32_OP) || is_u32(src2w)) { + ins = (op & SLJIT_I32_OP) ? 0xc20f00000000 /* clfi */ : 0xc20e00000000 /* clgfi */; + return emit_ri(compiler, ins, src1, src1, src1w, src2w, RIL_A); } - if (cmp > 0) { - /* unsigned */ - FAIL_IF(push_inst(compiler, - WHEN2(op & SLJIT_I32_OP, clr, clgr))); - } - if (cmp < 0) { - /* signed */ - FAIL_IF(push_inst(compiler, - WHEN2(op & SLJIT_I32_OP, cr, cgr))); - } - #undef LEVAL + if (is_s16(src2w)) + return emit_rie_d(compiler, 0xec00000000db /* alghsik */, SLJIT_UNUSED, src1, src1w, src2w); } - FAIL_IF(push_inst(compiler, ipm(flag_r))); } - } + else if (src2 & SLJIT_MEM) { + if ((op & SLJIT_I32_OP) && ((src2 & OFFS_REG_MASK) || is_u12(src2w))) { + ins = compare_signed ? 0x59000000 /* c */ : 0x55000000 /* cl */; + return emit_rx(compiler, ins, src1, src1, src1w, src2, src2w, RX_A); + } - if (!HAS_FLAGS(op) && dst == SLJIT_UNUSED) - return SLJIT_SUCCESS; + if (compare_signed) + ins = (op & SLJIT_I32_OP) ? 0xe30000000059 /* cy */ : 0xe30000000020 /* cg */; + else + ins = (op & SLJIT_I32_OP) ? 0xe30000000055 /* cly */ : 0xe30000000021 /* clg */; + return emit_rx(compiler, ins, src1, src1, src1w, src2, src2w, RXY_A); + } - /* need to specify signed or logical operation */ - int signed_flags = sets_signed_flag(op); + if (compare_signed) + ins = (op & SLJIT_I32_OP) ? 0x1900 /* cr */ : 0xb9200000 /* cgr */; + else + ins = (op & SLJIT_I32_OP) ? 0x1500 /* clr */ : 0xb9210000 /* clgr */; + return emit_rr(compiler, ins, src1, src1, src1w, src2, src2w); + } - if (is_shift(op)) { - /* handle shifts first, they have more constraints than other operations */ - sljit_sw d = 0; - sljit_gpr b = FAST_IS_REG(src2) ? gpr(src2 & REG_MASK) : r0; - if (src2 & SLJIT_IMM) - d = src2w & ((op & SLJIT_I32_OP) ? 31 : 63); + if (src2 & SLJIT_IMM) { + sljit_sw neg_src2w = -src2w; - if (src2 & SLJIT_MEM) { - /* shift amount (b) cannot be in r0 (i.e. tmp0) */ - FAIL_IF(load_word(compiler, tmp1, src2, src2w, tmp1, op & SLJIT_I32_OP)); - b = tmp1; - } - /* src1 and dst share the same register in the base 32-bit ISA */ - /* TODO(mundaym): not needed when distinct-operand facility is available */ - int workaround_alias = op & SLJIT_I32_OP && src1_r != dst_r; - if (workaround_alias) { - /* put src1 into tmp0 so we can overwrite it */ - FAIL_IF(push_inst(compiler, lr(tmp0, src1_r))); - src1_r = tmp0; - } - switch (GET_OPCODE(op) | (op & SLJIT_I32_OP)) { - case SLJIT_SHL: - FAIL_IF(push_inst(compiler, sllg(dst_r, src1_r, d, b))); - break; - case SLJIT_SHL32: - FAIL_IF(push_inst(compiler, sll(src1_r, d, b))); - break; - case SLJIT_LSHR: - FAIL_IF(push_inst(compiler, srlg(dst_r, src1_r, d, b))); - break; - case SLJIT_LSHR32: - FAIL_IF(push_inst(compiler, srl(src1_r, d, b))); - break; - case SLJIT_ASHR: - FAIL_IF(push_inst(compiler, srag(dst_r, src1_r, d, b))); - break; - case SLJIT_ASHR32: - FAIL_IF(push_inst(compiler, sra(src1_r, d, b))); - break; - default: - SLJIT_UNREACHABLE(); + if (sets_signed || neg_src2w != 0 || (op & (SLJIT_SET_Z | VARIABLE_FLAG_MASK)) == 0) { + if (!sets_zero_overflow && is_s8(neg_src2w) && (src1 & SLJIT_MEM) && (dst == src1 && dstw == src1w)) { + if (sets_signed) + ins = (op & SLJIT_I32_OP) ? 0xeb000000006a /* asi */ : 0xeb000000007a /* agsi */; + else + ins = (op & SLJIT_I32_OP) ? 0xeb000000006e /* alsi */ : 0xeb000000007e /* algsi */; + return emit_siy(compiler, ins, dst, dstw, neg_src2w); + } + + if (is_s16(neg_src2w)) { + if (sets_signed) + ins = (op & SLJIT_I32_OP) ? 0xec00000000d8 /* ahik */ : 0xec00000000d9 /* aghik */; + else + ins = (op & SLJIT_I32_OP) ? 0xec00000000da /* alhsik */ : 0xec00000000db /* alghsik */; + FAIL_IF(emit_rie_d(compiler, ins, dst, src1, src1w, neg_src2w)); + goto done; + } } - if (workaround_alias && dst_r != src1_r) - FAIL_IF(push_inst(compiler, lr(dst_r, src1_r))); - } - else if ((GET_OPCODE(op) == SLJIT_MUL) && HAS_FLAGS(op)) { - /* multiply instructions do not generally set flags so we need to manually */ - /* detect overflow conditions */ - /* TODO(mundaym): 64-bit overflow */ - SLJIT_ASSERT(GET_FLAG_TYPE(op) == SLJIT_MUL_OVERFLOW || - GET_FLAG_TYPE(op) == SLJIT_MUL_NOT_OVERFLOW); - sljit_gpr src2_r = FAST_IS_REG(src2) ? gpr(src2 & REG_MASK) : tmp1; - if (src2 & SLJIT_IMM) { - /* load src2 into register */ - FAIL_IF(push_load_imm_inst(compiler, src2_r, src2w)); + if (!sets_signed) { + if ((op & SLJIT_I32_OP) || is_u32(src2w)) { + ins = (op & SLJIT_I32_OP) ? 0xc20500000000 /* slfi */ : 0xc20400000000 /* slgfi */; + FAIL_IF(emit_ri(compiler, ins, dst, src1, src1w, src2w, RIL_A)); + goto done; + } + if (is_u32(neg_src2w)) { + FAIL_IF(emit_ri(compiler, 0xc20a00000000 /* algfi */, dst, src1, src1w, neg_src2w, RIL_A)); + goto done; + } } - if (src2 & SLJIT_MEM) { - /* load src2 into register */ - FAIL_IF(load_word(compiler, src2_r, src2, src2w, tmp1, op & SLJIT_I32_OP)); + else if ((op & SLJIT_I32_OP) || is_s32(neg_src2w)) { + ins = (op & SLJIT_I32_OP) ? 0xc20900000000 /* afi */ : 0xc20800000000 /* agfi */; + FAIL_IF(emit_ri(compiler, ins, dst, src1, src1w, neg_src2w, RIL_A)); + goto done; } - if (have_misc2()) { - #define LEVAL(i) i(dst_r, src1_r, src2_r) - FAIL_IF(push_inst(compiler, - WHEN2(op & SLJIT_I32_OP, msrkc, msgrkc))); - #undef LEVAL + } + + forms = sets_signed ? &sub_forms : &logical_sub_forms; + FAIL_IF(emit_non_commutative(compiler, forms, dst, dstw, src1, src1w, src2, src2w)); + +done: + if (sets_signed) { + sljit_gpr dst_r = SLOW_IS_REG(dst) ? gpr(dst & REG_MASK) : tmp0; + + if ((op & VARIABLE_FLAG_MASK) != SLJIT_SET_OVERFLOW) { + /* In case of overflow, the sign bit of the two source operands must be different, and + - the first operand is greater if the sign bit of the result is set + - the first operand is less if the sign bit of the result is not set + The -result operation sets the corrent sign, because the result cannot be zero. + The overflow is considered greater, since the result must be equal to INT_MIN so its sign bit is set. */ + FAIL_IF(push_inst(compiler, brc(0xe, 2 + 2))); + FAIL_IF(push_inst(compiler, (op & SLJIT_I32_OP) ? lcr(tmp1, dst_r) : lcgr(tmp1, dst_r))); } - else if (op & SLJIT_I32_OP) { - op &= ~VARIABLE_FLAG_MASK; - FAIL_IF(push_inst(compiler, lgfr(tmp0, src1_r))); - FAIL_IF(push_inst(compiler, msgfr(tmp0, src2_r))); - if (dst_r != tmp0) { - FAIL_IF(push_inst(compiler, lr(dst_r, tmp0))); - } - FAIL_IF(push_inst(compiler, aih(tmp0, 1))); - FAIL_IF(push_inst(compiler, nihf(tmp0, ~1U))); - FAIL_IF(push_inst(compiler, ipm(flag_r))); - FAIL_IF(push_inst(compiler, oilh(flag_r, 0x2000))); + else if (op & SLJIT_SET_Z) + FAIL_IF(update_zero_overflow(compiler, op, dst_r)); + } + + if (dst & SLJIT_MEM) + return store_word(compiler, tmp0, dst, dstw, op & SLJIT_I32_OP); + + return SLJIT_SUCCESS; +} + +static const struct ins_forms multiply_forms = { + 0xb2520000, /* msr */ + 0xb90c0000, /* msgr */ + 0xb9fd0000, /* msrkc */ + 0xb9ed0000, /* msgrkc */ + 0x71000000, /* ms */ + 0xe30000000051, /* msy */ + 0xe3000000000c, /* msg */ +}; + +static const struct ins_forms multiply_overflow_forms = { + 0, + 0, + 0xb9fd0000, /* msrkc */ + 0xb9ed0000, /* msgrkc */ + 0, + 0xe30000000053, /* msc */ + 0xe30000000083, /* msgc */ +}; + +static sljit_s32 sljit_emit_multiply(struct sljit_compiler *compiler, sljit_s32 op, + sljit_s32 dst, sljit_sw dstw, + sljit_s32 src1, sljit_sw src1w, + sljit_s32 src2, sljit_sw src2w) +{ + sljit_ins ins; + + if (HAS_FLAGS(op)) { + /* if have_misc2 fails, this operation should be emulated. 32 bit emulation: + FAIL_IF(push_inst(compiler, lgfr(tmp0, src1_r))); + FAIL_IF(push_inst(compiler, msgfr(tmp0, src2_r))); + if (dst_r != tmp0) { + FAIL_IF(push_inst(compiler, lr(dst_r, tmp0))); } - else - return SLJIT_ERR_UNSUPPORTED; + FAIL_IF(push_inst(compiler, aih(tmp0, 1))); + FAIL_IF(push_inst(compiler, nihf(tmp0, ~1U))); + FAIL_IF(push_inst(compiler, ipm(flag_r))); + FAIL_IF(push_inst(compiler, oilh(flag_r, 0x2000))); */ + return emit_commutative(compiler, &multiply_overflow_forms, dst, dstw, src1, src1w, src2, src2w); } - else if ((GET_OPCODE(op) == SLJIT_SUB) && (op & SLJIT_SET_Z) && !signed_flags) { - /* subtract logical instructions do not set the right flags unfortunately */ - /* instead, negate src2 and issue an add logical */ - /* TODO(mundaym): distinct operand facility where needed */ - if (src1_r != dst_r && src1_r != tmp0) { - #define LEVAL(i) i(tmp0, src1_r) - FAIL_IF(push_inst(compiler, - WHEN2(op & SLJIT_I32_OP, lr, lgr))); - src1_r = tmp0; - #undef LEVAL - } - sljit_gpr src2_r = FAST_IS_REG(src2) ? gpr(src2 & REG_MASK) : tmp1; - if (src2 & SLJIT_IMM) { - /* load src2 into register */ - FAIL_IF(push_load_imm_inst(compiler, src2_r, src2w)); + + if (src2 & SLJIT_IMM) { + if (is_s16(src2w)) { + ins = (op & SLJIT_I32_OP) ? 0xa70c0000 /* mhi */ : 0xa70d0000 /* mghi */; + return emit_ri(compiler, ins, dst, src1, src1w, src2w, RI_A); } - if (src2 & SLJIT_MEM) { - /* load src2 into register */ - FAIL_IF(load_word(compiler, src2_r, src2, src2w, tmp1, op & SLJIT_I32_OP)); + + if (is_s32(src2w)) { + ins = (op & SLJIT_I32_OP) ? 0xc20100000000 /* msfi */ : 0xc20000000000 /* msgfi */; + return emit_ri(compiler, ins, dst, src1, src1w, src2w, RIL_A); } - if (op & SLJIT_I32_OP) { - FAIL_IF(push_inst(compiler, lcr(tmp1, src2_r))); - FAIL_IF(push_inst(compiler, alr(src1_r, tmp1))); - if (src1_r != dst_r) - FAIL_IF(push_inst(compiler, lr(dst_r, src1_r))); + } + + return emit_commutative(compiler, &multiply_forms, dst, dstw, src1, src1w, src2, src2w); +} + +static sljit_s32 sljit_emit_bitwise_imm(struct sljit_compiler *compiler, sljit_s32 type, + sljit_s32 dst, sljit_sw dstw, + sljit_s32 src1, sljit_sw src1w, + sljit_uw imm, sljit_s32 count16) +{ + sljit_s32 mode = compiler->mode; + sljit_gpr dst_r = tmp0; + sljit_s32 needs_move = 1; + + if (SLOW_IS_REG(dst)) { + dst_r = gpr(dst & REG_MASK); + if (dst == src1) + needs_move = 0; + } + + if (needs_move) + FAIL_IF(emit_move(compiler, dst_r, src1, src1w)); + + if (type == SLJIT_AND) { + if (!(mode & SLJIT_I32_OP)) + FAIL_IF(push_inst(compiler, 0xc00a00000000 /* nihf */ | (dst_r << 36) | (imm >> 32))); + return push_inst(compiler, 0xc00b00000000 /* nilf */ | (dst_r << 36) | (imm & 0xffffffff)); + } + else if (type == SLJIT_OR) { + if (count16 >= 3) { + FAIL_IF(push_inst(compiler, 0xc00c00000000 /* oihf */ | (dst_r << 36) | (imm >> 32))); + return push_inst(compiler, 0xc00d00000000 /* oilf */ | (dst_r << 36) | (imm & 0xffffffff)); } - else { - FAIL_IF(push_inst(compiler, lcgr(tmp1, src2_r))); - FAIL_IF(push_inst(compiler, algr(src1_r, tmp1))); - if (src1_r != dst_r) - FAIL_IF(push_inst(compiler, lgr(dst_r, src1_r))); + + if (count16 >= 2) { + if ((imm & 0x00000000ffffffffull) == 0) + return push_inst(compiler, 0xc00c00000000 /* oihf */ | (dst_r << 36) | (imm >> 32)); + if ((imm & 0xffffffff00000000ull) == 0) + return push_inst(compiler, 0xc00d00000000 /* oilf */ | (dst_r << 36) | (imm & 0xffffffff)); } + + if ((imm & 0xffff000000000000ull) != 0) + FAIL_IF(push_inst(compiler, 0xa5080000 /* oihh */ | (dst_r << 20) | (imm >> 48))); + if ((imm & 0x0000ffff00000000ull) != 0) + FAIL_IF(push_inst(compiler, 0xa5090000 /* oihl */ | (dst_r << 20) | ((imm >> 32) & 0xffff))); + if ((imm & 0x00000000ffff0000ull) != 0) + FAIL_IF(push_inst(compiler, 0xa50a0000 /* oilh */ | (dst_r << 20) | ((imm >> 16) & 0xffff))); + if ((imm & 0x000000000000ffffull) != 0 || imm == 0) + return push_inst(compiler, 0xa50b0000 /* oill */ | (dst_r << 20) | (imm & 0xffff)); + return SLJIT_SUCCESS; } - else if ((src2 & SLJIT_IMM) && (src1_r == dst_r) && have_op_2_imm(op, src2w)) { - switch (GET_OPCODE(op) | (op & SLJIT_I32_OP)) { - #define LEVAL(i) i(dst_r, src2w) - case SLJIT_ADD: - if (!HAS_FLAGS(op) || signed_flags) { - FAIL_IF(push_inst(compiler, - WHEN2(is_s16(src2w), aghi, agfi))); - } - else - FAIL_IF(push_inst(compiler, LEVAL(algfi))); - break; - case SLJIT_ADD32: - if (!HAS_FLAGS(op) || signed_flags) - FAIL_IF(push_inst(compiler, - WHEN2(is_s16(src2w), ahi, afi))); + if ((imm & 0xffffffff00000000ull) != 0) + FAIL_IF(push_inst(compiler, 0xc00600000000 /* xihf */ | (dst_r << 36) | (imm >> 32))); + if ((imm & 0x00000000ffffffffull) != 0 || imm == 0) + return push_inst(compiler, 0xc00700000000 /* xilf */ | (dst_r << 36) | (imm & 0xffffffff)); + return SLJIT_SUCCESS; +} + +static const struct ins_forms bitwise_and_forms = { + 0x1400, /* nr */ + 0xb9800000, /* ngr */ + 0xb9f40000, /* nrk */ + 0xb9e40000, /* ngrk */ + 0x54000000, /* n */ + 0xe30000000054, /* ny */ + 0xe30000000080, /* ng */ +}; + +static const struct ins_forms bitwise_or_forms = { + 0x1600, /* or */ + 0xb9810000, /* ogr */ + 0xb9f60000, /* ork */ + 0xb9e60000, /* ogrk */ + 0x56000000, /* o */ + 0xe30000000056, /* oy */ + 0xe30000000081, /* og */ +}; + +static const struct ins_forms bitwise_xor_forms = { + 0x1700, /* xr */ + 0xb9820000, /* xgr */ + 0xb9f70000, /* xrk */ + 0xb9e70000, /* xgrk */ + 0x57000000, /* x */ + 0xe30000000057, /* xy */ + 0xe30000000082, /* xg */ +}; + +static sljit_s32 sljit_emit_bitwise(struct sljit_compiler *compiler, sljit_s32 op, + sljit_s32 dst, sljit_sw dstw, + sljit_s32 src1, sljit_sw src1w, + sljit_s32 src2, sljit_sw src2w) +{ + sljit_s32 type = GET_OPCODE(op); + const struct ins_forms *forms; + + if ((src2 & SLJIT_IMM) && (!(op & SLJIT_SET_Z) || (type == SLJIT_AND && dst == SLJIT_UNUSED))) { + sljit_s32 count16 = 0; + sljit_uw imm = (sljit_uw)src2w; + + if (op & SLJIT_I32_OP) + imm &= 0xffffffffull; + + if ((imm & 0x000000000000ffffull) != 0 || imm == 0) + count16++; + if ((imm & 0x00000000ffff0000ull) != 0) + count16++; + if ((imm & 0x0000ffff00000000ull) != 0) + count16++; + if ((imm & 0xffff000000000000ull) != 0) + count16++; + + if (type == SLJIT_AND && dst == SLJIT_UNUSED && count16 == 1) { + sljit_gpr src_r = tmp0; + + if (FAST_IS_REG(src1)) + src_r = gpr(src1 & REG_MASK); else - FAIL_IF(push_inst(compiler, LEVAL(alfi))); - - break; - #undef LEVAL /* TODO(carenas): move down and refactor? */ - case SLJIT_MUL: - FAIL_IF(push_inst(compiler, mhi(dst_r, src2w))); - break; - case SLJIT_MUL32: - FAIL_IF(push_inst(compiler, mghi(dst_r, src2w))); - break; - case SLJIT_OR32: - FAIL_IF(push_inst(compiler, oilf(dst_r, src2w))); - break; - case SLJIT_XOR32: - FAIL_IF(push_inst(compiler, xilf(dst_r, src2w))); - break; - case SLJIT_AND32: - FAIL_IF(push_inst(compiler, nilf(dst_r, src2w))); - break; - default: - SLJIT_UNREACHABLE(); + FAIL_IF(emit_move(compiler, tmp0, src1, src1w)); + + if ((imm & 0x000000000000ffffull) != 0 || imm == 0) + return push_inst(compiler, 0xa7010000 | (src_r << 20) | imm); + if ((imm & 0x00000000ffff0000ull) != 0) + return push_inst(compiler, 0xa7000000 | (src_r << 20) | (imm >> 16)); + if ((imm & 0x0000ffff00000000ull) != 0) + return push_inst(compiler, 0xa7030000 | (src_r << 20) | (imm >> 32)); + return push_inst(compiler, 0xa7020000 | (src_r << 20) | (imm >> 48)); } + + if (!(op & SLJIT_SET_Z)) + return sljit_emit_bitwise_imm(compiler, type, dst, dstw, src1, src1w, imm, count16); } - else if ((src2 & SLJIT_IMM) && have_op_3_imm(op, src2w)) { - abort(); /* TODO(mundaym): implement */ + + if (type == SLJIT_AND) + forms = &bitwise_and_forms; + else if (type == SLJIT_OR) + forms = &bitwise_or_forms; + else + forms = &bitwise_xor_forms; + + return emit_commutative(compiler, forms, dst, dstw, src1, src1w, src2, src2w); +} + +static sljit_s32 sljit_emit_shift(struct sljit_compiler *compiler, sljit_s32 op, + sljit_s32 dst, sljit_sw dstw, + sljit_s32 src1, sljit_sw src1w, + sljit_s32 src2, sljit_sw src2w) +{ + sljit_s32 type = GET_OPCODE(op); + sljit_gpr dst_r = SLOW_IS_REG(dst) ? gpr(dst & REG_MASK) : tmp0; + sljit_gpr src_r = tmp0; + sljit_gpr base_r = tmp0; + sljit_ins imm = 0; + sljit_ins ins; + + if (FAST_IS_REG(src1)) + src_r = gpr(src1 & REG_MASK); + else + FAIL_IF(emit_move(compiler, tmp0, src1, src1w)); + + if (src2 & SLJIT_IMM) + imm = src2w & ((op & SLJIT_I32_OP) ? 0x1f : 0x3f); + else if (FAST_IS_REG(src2)) + base_r = gpr(src2 & REG_MASK); + else { + FAIL_IF(emit_move(compiler, tmp1, src2, src2w)); + base_r = tmp1; } - else if ((src2 & SLJIT_MEM) && (dst_r == src1_r)) { - /* most 32-bit instructions can only handle 12-bit immediate offsets */ - int need_u12 = !have_ldisp() && - (op & SLJIT_I32_OP) && - (GET_OPCODE(op) != SLJIT_ADDC) && - (GET_OPCODE(op) != SLJIT_SUBC); - struct addr mem; - if (need_u12) - FAIL_IF(make_addr_bx(compiler, &mem, src2, src2w, tmp1)); + + if ((op & SLJIT_I32_OP) && dst_r == src_r) { + if (type == SLJIT_SHL) + ins = 0x89000000 /* sll */; + else if (type == SLJIT_LSHR) + ins = 0x88000000 /* srl */; else - FAIL_IF(make_addr_bxy(compiler, &mem, src2, src2w, tmp1)); - - int can_u12 = is_u12(mem.offset) ? 1 : 0; - sljit_ins ins = 0; - switch (GET_OPCODE(op) | (op & SLJIT_I32_OP)) { - /* 64-bit ops */ - #define LEVAL(i) EVAL(i, dst_r, mem) - case SLJIT_ADD: - ins = WHEN2(signed_flags, ag, alg); - break; - case SLJIT_SUB: - ins = WHEN2(signed_flags, sg, slg); - break; - case SLJIT_ADDC: - ins = LEVAL(alcg); - break; - case SLJIT_SUBC: - ins = LEVAL(slbg); - break; - case SLJIT_MUL: - ins = LEVAL(msg); - break; - case SLJIT_OR: - ins = LEVAL(og); - break; - case SLJIT_XOR: - ins = LEVAL(xg); - break; - case SLJIT_AND: - ins = LEVAL(ng); - break; - /* 32-bit ops */ - case SLJIT_ADD32: - if (signed_flags) - ins = WHEN2(can_u12, a, ay); - else - ins = WHEN2(can_u12, al, aly); - break; - case SLJIT_SUB32: - if (signed_flags) - ins = WHEN2(can_u12, s, sy); - else - ins = WHEN2(can_u12, sl, sly); - break; - case SLJIT_ADDC32: - ins = LEVAL(alc); - break; - case SLJIT_SUBC32: - ins = LEVAL(slb); - break; - case SLJIT_MUL32: - ins = WHEN2(can_u12, ms, msy); - break; - case SLJIT_OR32: - ins = WHEN2(can_u12, o, oy); - break; - case SLJIT_XOR32: - ins = WHEN2(can_u12, x, xy); - break; - case SLJIT_AND32: - ins = WHEN2(can_u12, n, ny); - break; - #undef LEVAL - default: - SLJIT_UNREACHABLE(); - } - FAIL_IF(push_inst(compiler, ins)); + ins = 0x8a000000 /* sra */; + + FAIL_IF(push_inst(compiler, ins | (dst_r << 20) | (base_r << 12) | imm)); } else { - sljit_gpr src2_r = FAST_IS_REG(src2) ? gpr(src2 & REG_MASK) : tmp1; - if (src2 & SLJIT_IMM) { - /* load src2 into register */ - FAIL_IF(push_load_imm_inst(compiler, src2_r, src2w)); - } - if (src2 & SLJIT_MEM) { - /* load src2 into register */ - FAIL_IF(load_word(compiler, src2_r, src2, src2w, tmp1, op & SLJIT_I32_OP)); - } - /* TODO(mundaym): distinct operand facility where needed */ - #define LEVAL(i) i(tmp0, src1_r) - if (src1_r != dst_r && src1_r != tmp0) { - FAIL_IF(push_inst(compiler, - WHEN2(op & SLJIT_I32_OP, lr, lgr))); - src1_r = tmp0; - } - #undef LEVAL - sljit_ins ins = 0; - switch (GET_OPCODE(op) | (op & SLJIT_I32_OP)) { - #define LEVAL(i) i(src1_r, src2_r) - /* 64-bit ops */ - case SLJIT_ADD: - ins = WHEN2(signed_flags, agr, algr); - break; - case SLJIT_SUB: - ins = WHEN2(signed_flags, sgr, slgr); - break; - case SLJIT_ADDC: - ins = LEVAL(alcgr); - break; - case SLJIT_SUBC: - ins = LEVAL(slbgr); - break; - case SLJIT_MUL: - ins = LEVAL(msgr); - break; - case SLJIT_AND: - ins = LEVAL(ngr); - break; - case SLJIT_OR: - ins = LEVAL(ogr); - break; - case SLJIT_XOR: - ins = LEVAL(xgr); - break; - /* 32-bit ops */ - case SLJIT_ADD32: - ins = WHEN2(signed_flags, ar, alr); - break; - case SLJIT_SUB32: - ins = WHEN2(signed_flags, sr, slr); - break; - case SLJIT_ADDC32: - ins = LEVAL(alcr); - break; - case SLJIT_SUBC32: - ins = LEVAL(slbr); - break; - case SLJIT_MUL32: - ins = LEVAL(msr); - break; - case SLJIT_AND32: - ins = LEVAL(nr); - break; - case SLJIT_OR32: - ins = LEVAL(or); - break; - case SLJIT_XOR32: - ins = LEVAL(xr); - break; - #undef LEVAL - default: - SLJIT_UNREACHABLE(); - } - FAIL_IF(push_inst(compiler, ins)); - #define LEVAL(i) i(dst_r, src1_r) - if (src1_r != dst_r) - FAIL_IF(push_inst(compiler, - WHEN2(op & SLJIT_I32_OP, lr, lgr))); - #undef LEVAL + if (type == SLJIT_SHL) + ins = (op & SLJIT_I32_OP) ? 0xeb00000000df /* sllk */ : 0xeb000000000d /* sllg */; + else if (type == SLJIT_LSHR) + ins = (op & SLJIT_I32_OP) ? 0xeb00000000de /* srlk */ : 0xeb000000000c /* srlg */; + else + ins = (op & SLJIT_I32_OP) ? 0xeb00000000dc /* srak */ : 0xeb000000000a /* srag */; + + FAIL_IF(push_inst(compiler, ins | (dst_r << 36) | (src_r << 32) | (base_r << 28) | (imm << 16))); } - /* write condition code to emulated flag register */ - if (op & VARIABLE_FLAG_MASK) - FAIL_IF(push_inst(compiler, ipm(flag_r))); + if ((op & SLJIT_SET_Z) && type != SLJIT_ASHR) + return push_inst(compiler, (op & SLJIT_I32_OP) ? or(dst_r, dst_r) : ogr(dst_r, dst_r)); + + return SLJIT_SUCCESS; +} + +static const struct ins_forms addc_forms = { + 0xb9980000, /* alcr */ + 0xb9880000, /* alcgr */ + 0, + 0, + 0, + 0xe30000000098, /* alc */ + 0xe30000000088, /* alcg */ +}; + +static const struct ins_forms subc_forms = { + 0xb9990000, /* slbr */ + 0xb9890000, /* slbgr */ + 0, + 0, + 0, + 0xe30000000099, /* slb */ + 0xe30000000089, /* slbg */ +}; + +SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op2(struct sljit_compiler *compiler, sljit_s32 op, + sljit_s32 dst, sljit_sw dstw, + sljit_s32 src1, sljit_sw src1w, + sljit_s32 src2, sljit_sw src2w) +{ + CHECK_ERROR(); + CHECK(check_sljit_emit_op2(compiler, op, dst, dstw, src1, src1w, src2, src2w)); + ADJUST_LOCAL_OFFSET(dst, dstw); + ADJUST_LOCAL_OFFSET(src1, src1w); + ADJUST_LOCAL_OFFSET(src2, src2w); + + if (dst == SLJIT_UNUSED && !HAS_FLAGS(op)) + return SLJIT_SUCCESS; - /* write zero flag to emulated flag register */ - if (op & SLJIT_SET_Z) - FAIL_IF(push_store_zero_flag(compiler, op, dst_r)); + compiler->mode = op & SLJIT_I32_OP; + compiler->status_flags_state = op & (VARIABLE_FLAG_MASK | SLJIT_SET_Z); + + if (GET_OPCODE(op) >= SLJIT_ADD || GET_OPCODE(op) <= SLJIT_SUBC) + compiler->status_flags_state |= SLJIT_CURRENT_FLAGS_ADD_SUB; + + if (is_commutative(op) && (src1 & SLJIT_IMM) && !(src2 & SLJIT_IMM)) { + src1 ^= src2; + src2 ^= src1; + src1 ^= src2; + + src1w ^= src2w; + src2w ^= src1w; + src1w ^= src2w; + } - /* finally write the result to memory if required */ - if (dst & SLJIT_MEM) { - SLJIT_ASSERT(dst_r != tmp1); - /* TODO(carenas): s/FAIL_IF/ return */ - FAIL_IF(store_word(compiler, dst_r, dst, dstw, tmp1, op & SLJIT_I32_OP)); + switch (GET_OPCODE(op)) { + case SLJIT_ADD: + return sljit_emit_add(compiler, op, dst, dstw, src1, src1w, src2, src2w); + case SLJIT_ADDC: + FAIL_IF(emit_commutative(compiler, &addc_forms, dst, dstw, src1, src1w, src2, src2w)); + if (dst & SLJIT_MEM) + return store_word(compiler, tmp0, dst, dstw, op & SLJIT_I32_OP); + return SLJIT_SUCCESS; + case SLJIT_SUB: + return sljit_emit_sub(compiler, op, dst, dstw, src1, src1w, src2, src2w); + case SLJIT_SUBC: + FAIL_IF(emit_non_commutative(compiler, &subc_forms, dst, dstw, src1, src1w, src2, src2w)); + if (dst & SLJIT_MEM) + return store_word(compiler, tmp0, dst, dstw, op & SLJIT_I32_OP); + return SLJIT_SUCCESS; + case SLJIT_MUL: + FAIL_IF(sljit_emit_multiply(compiler, op, dst, dstw, src1, src1w, src2, src2w)); + break; + case SLJIT_AND: + case SLJIT_OR: + case SLJIT_XOR: + FAIL_IF(sljit_emit_bitwise(compiler, op, dst, dstw, src1, src1w, src2, src2w)); + break; + case SLJIT_SHL: + case SLJIT_LSHR: + case SLJIT_ASHR: + FAIL_IF(sljit_emit_shift(compiler, op, dst, dstw, src1, src1w, src2, src2w)); + break; } + if (dst & SLJIT_MEM) + return store_word(compiler, tmp0, dst, dstw, op & SLJIT_I32_OP); return SLJIT_SUCCESS; } @@ -2428,7 +2663,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op_src( case SLJIT_FAST_RETURN: src_r = FAST_IS_REG(src) ? gpr(src) : tmp1; if (src & SLJIT_MEM) - FAIL_IF(load_word(compiler, tmp1, src, srcw, tmp1, 0)); + FAIL_IF(load_word(compiler, tmp1, src, srcw, 0)); return push_inst(compiler, br(src_r)); case SLJIT_SKIP_FRAMES_BEFORE_FAST_RETURN: @@ -2507,7 +2742,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fast_enter(struct sljit_compiler * return push_inst(compiler, lgr(gpr(dst), fast_link_r)); /* memory */ - return store_word(compiler, fast_link_r, dst, dstw, tmp1, 0); + return store_word(compiler, fast_link_r, dst, dstw, 0); } /* --------------------------------------------------------------------- */ @@ -2532,15 +2767,11 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compi SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compiler *compiler, sljit_s32 type) { - sljit_u8 mask = ((type & 0xff) < SLJIT_JUMP) ? get_cc(type & 0xff) : 0xf; + sljit_u8 mask = ((type & 0xff) < SLJIT_JUMP) ? get_cc(compiler, type & 0xff) : 0xf; CHECK_ERROR_PTR(); CHECK_PTR(check_sljit_emit_jump(compiler, type)); - /* reload condition code */ - if (mask != 0xf) - PTR_FAIL_IF(push_load_cc(compiler, type & 0xff)); - /* record jump */ struct sljit_jump *jump = (struct sljit_jump *) ensure_abuf(compiler, sizeof(struct sljit_jump)); @@ -2585,7 +2816,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_ijump(struct sljit_compiler *compi FAIL_IF(push_load_imm_inst(compiler, src_r, srcw)); } else if (src & SLJIT_MEM) - FAIL_IF(load_word(compiler, src_r, src, srcw, tmp1, 0 /* 64-bit */)); + FAIL_IF(load_word(compiler, src_r, src, srcw, 0 /* 64-bit */)); /* emit jump instruction */ if (type >= SLJIT_FAST_CALL) @@ -2613,7 +2844,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op_flags(struct sljit_compiler *co sljit_s32 dst, sljit_sw dstw, sljit_s32 type) { - sljit_u8 mask = get_cc(type & 0xff); + sljit_u8 mask = get_cc(compiler, type & 0xff); CHECK_ERROR(); CHECK(check_sljit_emit_op_flags(compiler, op, dst, dstw, type)); @@ -2624,9 +2855,11 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op_flags(struct sljit_compiler *co case SLJIT_AND: case SLJIT_OR: case SLJIT_XOR: + compiler->status_flags_state = op & SLJIT_SET_Z; + /* dst is also source operand */ if (dst & SLJIT_MEM) - FAIL_IF(load_word(compiler, dst_r, dst, dstw, tmp1, op & SLJIT_I32_OP)); + FAIL_IF(load_word(compiler, dst_r, dst, dstw, op & SLJIT_I32_OP)); break; case SLJIT_MOV: @@ -2638,9 +2871,6 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op_flags(struct sljit_compiler *co SLJIT_UNREACHABLE(); } - if (mask != 0xf) - FAIL_IF(push_load_cc(compiler, type & 0xff)); - /* TODO(mundaym): fold into cmov helper function? */ #define LEVAL(i) i(loc_r, 1, mask) if (have_lscond2()) { @@ -2671,14 +2901,9 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op_flags(struct sljit_compiler *co #undef LEVAL } - /* set zero flag if needed */ - if (op & SLJIT_SET_Z) - FAIL_IF(push_store_zero_flag(compiler, op, dst_r)); - /* store result to memory if required */ - /* TODO(carenas): s/FAIL_IF/ return */ if (dst & SLJIT_MEM) - FAIL_IF(store_word(compiler, dst_r, dst, dstw, tmp1, op & SLJIT_I32_OP)); + return store_word(compiler, dst_r, dst, dstw, op & SLJIT_I32_OP); return SLJIT_SUCCESS; } @@ -2687,16 +2912,13 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_cmov(struct sljit_compiler *compil sljit_s32 dst_reg, sljit_s32 src, sljit_sw srcw) { - sljit_u8 mask = get_cc(type & 0xff); + sljit_u8 mask = get_cc(compiler, type & 0xff); sljit_gpr dst_r = gpr(dst_reg & ~SLJIT_I32_OP); sljit_gpr src_r = FAST_IS_REG(src) ? gpr(src) : tmp0; CHECK_ERROR(); CHECK(check_sljit_emit_cmov(compiler, type, dst_reg, src, srcw)); - if (mask != 0xf) - FAIL_IF(push_load_cc(compiler, type & 0xff)); - if (src & SLJIT_IMM) { /* TODO(mundaym): fast path with lscond2 */ FAIL_IF(push_load_imm_inst(compiler, src_r, srcw)); @@ -2750,7 +2972,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compi } if (dst & SLJIT_MEM) - PTR_FAIL_IF(store_word(compiler, dst_r, dst, dstw, tmp1, 0 /* always 64-bit */)); + PTR_FAIL_IF(store_word(compiler, dst_r, dst, dstw, 0 /* always 64-bit */)); return (struct sljit_const*)const_; } @@ -2797,7 +3019,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_put_label *sljit_emit_put_label( } if (dst & SLJIT_MEM) - PTR_FAIL_IF(store_word(compiler, dst_r, dst, dstw, tmp1, 0)); + PTR_FAIL_IF(store_word(compiler, dst_r, dst, dstw, 0)); return put_label; } diff --git a/thirdparty/pcre2/src/sljit/sljitNativeSPARC_32.c b/thirdparty/pcre2/src/sljit/sljitNativeSPARC_32.c index e5167f02ba..28886405af 100644 --- a/thirdparty/pcre2/src/sljit/sljitNativeSPARC_32.c +++ b/thirdparty/pcre2/src/sljit/sljitNativeSPARC_32.c @@ -93,18 +93,21 @@ static SLJIT_INLINE sljit_s32 emit_single_op(struct sljit_compiler *compiler, sl return push_inst(compiler, ADD | D(dst) | S1(dst) | IMM(1), UNMOVABLE_INS); case SLJIT_ADD: + compiler->status_flags_state = SLJIT_CURRENT_FLAGS_ADD_SUB; return push_inst(compiler, ADD | (flags & SET_FLAGS) | D(dst) | S1(src1) | ARG2(flags, src2), DR(dst) | (flags & SET_FLAGS)); case SLJIT_ADDC: return push_inst(compiler, ADDC | (flags & SET_FLAGS) | D(dst) | S1(src1) | ARG2(flags, src2), DR(dst) | (flags & SET_FLAGS)); case SLJIT_SUB: + compiler->status_flags_state = SLJIT_CURRENT_FLAGS_ADD_SUB; return push_inst(compiler, SUB | (flags & SET_FLAGS) | D(dst) | S1(src1) | ARG2(flags, src2), DR(dst) | (flags & SET_FLAGS)); case SLJIT_SUBC: return push_inst(compiler, SUBC | (flags & SET_FLAGS) | D(dst) | S1(src1) | ARG2(flags, src2), DR(dst) | (flags & SET_FLAGS)); case SLJIT_MUL: + compiler->status_flags_state = 0; FAIL_IF(push_inst(compiler, SMUL | D(dst) | S1(src1) | ARG2(flags, src2), DR(dst))); if (!(flags & SET_FLAGS)) return SLJIT_SUCCESS; diff --git a/thirdparty/pcre2/src/sljit/sljitNativeSPARC_common.c b/thirdparty/pcre2/src/sljit/sljitNativeSPARC_common.c index 544d80d028..e833f09d7a 100644 --- a/thirdparty/pcre2/src/sljit/sljitNativeSPARC_common.c +++ b/thirdparty/pcre2/src/sljit/sljitNativeSPARC_common.c @@ -1275,16 +1275,14 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compi return label; } -static sljit_ins get_cc(sljit_s32 type) +static sljit_ins get_cc(struct sljit_compiler *compiler, sljit_s32 type) { switch (type) { case SLJIT_EQUAL: - case SLJIT_MUL_NOT_OVERFLOW: case SLJIT_NOT_EQUAL_F64: /* Unordered. */ return DA(0x1); case SLJIT_NOT_EQUAL: - case SLJIT_MUL_OVERFLOW: case SLJIT_EQUAL_F64: return DA(0x9); @@ -1317,10 +1315,16 @@ static sljit_ins get_cc(sljit_s32 type) return DA(0x2); case SLJIT_OVERFLOW: + if (!(compiler->status_flags_state & SLJIT_CURRENT_FLAGS_ADD_SUB)) + return DA(0x9); + case SLJIT_UNORDERED_F64: return DA(0x7); case SLJIT_NOT_OVERFLOW: + if (!(compiler->status_flags_state & SLJIT_CURRENT_FLAGS_ADD_SUB)) + return DA(0x1); + case SLJIT_ORDERED_F64: return DA(0xf); @@ -1347,7 +1351,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compile if (((compiler->delay_slot & DST_INS_MASK) != UNMOVABLE_INS) && !(compiler->delay_slot & ICC_IS_SET)) jump->flags |= IS_MOVABLE; #if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32) - PTR_FAIL_IF(push_inst(compiler, BICC | get_cc(type ^ 1) | 5, UNMOVABLE_INS)); + PTR_FAIL_IF(push_inst(compiler, BICC | get_cc(compiler, type ^ 1) | 5, UNMOVABLE_INS)); #else #error "Implementation required" #endif @@ -1357,7 +1361,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compile if (((compiler->delay_slot & DST_INS_MASK) != UNMOVABLE_INS) && !(compiler->delay_slot & FCC_IS_SET)) jump->flags |= IS_MOVABLE; #if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32) - PTR_FAIL_IF(push_inst(compiler, FBFCC | get_cc(type ^ 1) | 5, UNMOVABLE_INS)); + PTR_FAIL_IF(push_inst(compiler, FBFCC | get_cc(compiler, type ^ 1) | 5, UNMOVABLE_INS)); #else #error "Implementation required" #endif @@ -1474,9 +1478,9 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op_flags(struct sljit_compiler *co type &= 0xff; if (type < SLJIT_EQUAL_F64) - FAIL_IF(push_inst(compiler, BICC | get_cc(type) | 3, UNMOVABLE_INS)); + FAIL_IF(push_inst(compiler, BICC | get_cc(compiler, type) | 3, UNMOVABLE_INS)); else - FAIL_IF(push_inst(compiler, FBFCC | get_cc(type) | 3, UNMOVABLE_INS)); + FAIL_IF(push_inst(compiler, FBFCC | get_cc(compiler, type) | 3, UNMOVABLE_INS)); FAIL_IF(push_inst(compiler, OR | D(reg) | S1(0) | IMM(1), UNMOVABLE_INS)); FAIL_IF(push_inst(compiler, OR | D(reg) | S1(0) | IMM(0), UNMOVABLE_INS)); diff --git a/thirdparty/pcre2/src/sljit/sljitNativeX86_common.c b/thirdparty/pcre2/src/sljit/sljitNativeX86_common.c index ddcc5ebf76..515d98aefd 100644 --- a/thirdparty/pcre2/src/sljit/sljitNativeX86_common.c +++ b/thirdparty/pcre2/src/sljit/sljitNativeX86_common.c @@ -411,11 +411,9 @@ static sljit_u8 get_jump_code(sljit_s32 type) return 0x8e /* jle */; case SLJIT_OVERFLOW: - case SLJIT_MUL_OVERFLOW: return 0x80 /* jo */; case SLJIT_NOT_OVERFLOW: - case SLJIT_MUL_NOT_OVERFLOW: return 0x81 /* jno */; case SLJIT_UNORDERED_F64: diff --git a/thirdparty/pcre2/src/sljit/sljitUtils.c b/thirdparty/pcre2/src/sljit/sljitUtils.c index 08ca35cf37..9bce714735 100644 --- a/thirdparty/pcre2/src/sljit/sljitUtils.c +++ b/thirdparty/pcre2/src/sljit/sljitUtils.c @@ -48,7 +48,7 @@ static HANDLE allocator_lock; static SLJIT_INLINE void allocator_grab_lock(void) { HANDLE lock; - if (SLJIT_UNLIKELY(!allocator_lock)) { + if (SLJIT_UNLIKELY(!InterlockedCompareExchangePointer(&allocator_lock, NULL, NULL))) { lock = CreateMutex(NULL, FALSE, NULL); if (InterlockedCompareExchangePointer(&allocator_lock, lock, NULL)) CloseHandle(lock); @@ -146,9 +146,13 @@ static SLJIT_INLINE sljit_sw get_page_alignment(void) { #include <unistd.h> static SLJIT_INLINE sljit_sw get_page_alignment(void) { - static sljit_sw sljit_page_align; - if (!sljit_page_align) { + static sljit_sw sljit_page_align = -1; + if (sljit_page_align < 0) { +#ifdef _SC_PAGESIZE sljit_page_align = sysconf(_SC_PAGESIZE); +#else + sljit_page_align = getpagesize(); +#endif /* Should never happen. */ if (sljit_page_align < 0) sljit_page_align = 4096; diff --git a/thirdparty/pcre2/src/sljit/sljitWXExecAllocator.c b/thirdparty/pcre2/src/sljit/sljitWXExecAllocator.c index 6ef71f7d83..72d5b8dd2b 100644 --- a/thirdparty/pcre2/src/sljit/sljitWXExecAllocator.c +++ b/thirdparty/pcre2/src/sljit/sljitWXExecAllocator.c @@ -121,14 +121,18 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_malloc_exec(sljit_uw size) static pthread_mutex_t se_lock = PTHREAD_MUTEX_INITIALIZER; #endif static int se_protected = !SLJIT_PROT_WX; + int prot = PROT_READ | PROT_WRITE | SLJIT_PROT_WX; sljit_uw* ptr; if (SLJIT_UNLIKELY(se_protected < 0)) return NULL; +#ifdef PROT_MAX + prot |= PROT_MAX(PROT_READ | PROT_WRITE | PROT_EXEC); +#endif + size += sizeof(sljit_uw); - ptr = (sljit_uw*)mmap(NULL, size, PROT_READ | PROT_WRITE | SLJIT_PROT_WX, - MAP_PRIVATE | MAP_ANON, -1, 0); + ptr = (sljit_uw*)mmap(NULL, size, prot, MAP_PRIVATE | MAP_ANON, -1, 0); if (ptr == MAP_FAILED) return NULL; diff --git a/thirdparty/tinyexr/tinyexr.cc b/thirdparty/tinyexr/tinyexr.cc index fef8f66c98..70115ea5c2 100644 --- a/thirdparty/tinyexr/tinyexr.cc +++ b/thirdparty/tinyexr/tinyexr.cc @@ -4,5 +4,9 @@ #endif #endif +// -- GODOT start -- +#include <zlib.h> // Should come before including tinyexr. +// -- GODOT end -- + #define TINYEXR_IMPLEMENTATION #include "tinyexr.h" diff --git a/thirdparty/tinyexr/tinyexr.h b/thirdparty/tinyexr/tinyexr.h index a3e7b23161..969f07ad79 100644 --- a/thirdparty/tinyexr/tinyexr.h +++ b/thirdparty/tinyexr/tinyexr.h @@ -1,7 +1,7 @@ #ifndef TINYEXR_H_ #define TINYEXR_H_ /* -Copyright (c) 2014 - 2020, Syoyo Fujita and many contributors. +Copyright (c) 2014 - 2021, Syoyo Fujita and many contributors. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -65,6 +65,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // End of OpenEXR license ------------------------------------------------- + // // // Do this: @@ -88,7 +89,21 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. extern "C" { #endif -// Use embedded miniz or not to decode ZIP format pixel. Linking with zlib +#if defined(_M_IX86) || defined(_M_X64) || defined(__i386__) || \ + defined(__i386) || defined(__i486__) || defined(__i486) || \ + defined(i386) || defined(__ia64__) || defined(__x86_64__) +#define TINYEXR_X86_OR_X64_CPU 1 +#else +#define TINYEXR_X86_OR_X64_CPU 0 +#endif + +#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || TINYEXR_X86_OR_X64_CPU +#define TINYEXR_LITTLE_ENDIAN 1 +#else +#define TINYEXR_LITTLE_ENDIAN 0 +#endif + +// Use miniz or not to decode ZIP format pixel. Linking with zlib // required if this flas is 0. #ifndef TINYEXR_USE_MINIZ #define TINYEXR_USE_MINIZ (1) @@ -162,9 +177,13 @@ extern "C" { typedef struct _EXRVersion { int version; // this must be 2 - int tiled; // tile format image + // tile format image; + // not zero for only a single-part "normal" tiled file (according to spec.) + int tiled; int long_name; // long name attribute - int non_image; // deep image(EXR 2.0) + // deep image(EXR 2.0); + // for a multi-part file, indicates that at least one part is of type deep* (according to spec.) + int non_image; int multipart; // multi-part(EXR 2.0) } EXRVersion; @@ -222,6 +241,8 @@ typedef struct _EXRHeader { int tile_rounding_mode; int long_name; + // for a single-part file, agree with the version field bit 11 + // for a multi-part file, it is consistent with the type of part int non_image; int multipart; unsigned int header_len; @@ -244,7 +265,11 @@ typedef struct _EXRHeader { // ParseEXRHeaderFrom(Meomory|File), then users // can edit it(only valid for HALF pixel type // channel) - + // name attribute required for multipart files; + // must be unique and non empty (according to spec.); + // use EXRSetNameAttr for setting value; + // max 255 character allowed - excluding terminating zero + char name[256]; } EXRHeader; typedef struct _EXRMultiPartHeader { @@ -256,6 +281,10 @@ typedef struct _EXRMultiPartHeader { typedef struct _EXRImage { EXRTile *tiles; // Tiled pixel data. The application must reconstruct image // from tiles manually. NULL if scanline format. + struct _EXRImage* next_level; // NULL if scanline format or image is the last level. + int level_x; // x level index + int level_y; // y level index + unsigned char **images; // image[channels][pixels]. NULL if tiled format. int width; @@ -339,9 +368,15 @@ extern int SaveEXR(const float *data, const int width, const int height, const int components, const int save_as_fp16, const char *filename, const char **err); +// Returns the number of resolution levels of the image (including the base) +extern int EXRNumLevels(const EXRImage* exr_image); + // Initialize EXRHeader struct extern void InitEXRHeader(EXRHeader *exr_header); +// Set name attribute of EXRHeader struct (it makes a copy) +extern void EXRSetNameAttr(EXRHeader *exr_header, const char* name); + // Initialize EXRImage struct extern void InitEXRImage(EXRImage *exr_image); @@ -465,6 +500,30 @@ extern size_t SaveEXRImageToMemory(const EXRImage *image, const EXRHeader *exr_header, unsigned char **memory, const char **err); +// Saves multi-channel, multi-frame OpenEXR image to a memory. +// Image is compressed using EXRImage.compression value. +// File global attributes (eg. display_window) must be set in the first header. +// Returns negative value and may set error string in `err` when there's an +// error +// When there was an error message, Application must free `err` with +// FreeEXRErrorMessage() +extern int SaveEXRMultipartImageToFile(const EXRImage *images, + const EXRHeader **exr_headers, + unsigned int num_parts, + const char *filename, const char **err); + +// Saves multi-channel, multi-frame OpenEXR image to a memory. +// Image is compressed using EXRImage.compression value. +// File global attributes (eg. display_window) must be set in the first header. +// Return the number of bytes if success. +// Return zero and will set error string in `err` when there's an +// error. +// When there was an error message, Application must free `err` with +// FreeEXRErrorMessage() +extern size_t SaveEXRMultipartImageToMemory(const EXRImage *images, + const EXRHeader **exr_headers, + unsigned int num_parts, + unsigned char **memory, const char **err); // Loads single-frame OpenEXR deep image. // Application must free memory of variables in DeepImage(image, offset_table) // Returns negative value and may set error string in `err` when there's an @@ -514,6 +573,9 @@ extern int LoadEXRFromMemory(float **out_rgba, int *width, int *height, #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif +#ifndef NOMINMAX +#define NOMINMAX +#endif #include <windows.h> // for UTF-8 #endif @@ -530,8 +592,11 @@ extern int LoadEXRFromMemory(float **out_rgba, int *width, int *height, #include <limits> #include <string> #include <vector> +#include <set> -#if __cplusplus > 199711L +// https://stackoverflow.com/questions/5047971/how-do-i-check-for-c11-support +#if __cplusplus > 199711L || (defined(_MSC_VER) && _MSC_VER >= 1900) +#define TINYEXR_HAS_CXX11 (1) // C++11 #include <cstdint> @@ -547,6 +612,7 @@ extern int LoadEXRFromMemory(float **out_rgba, int *width, int *height, #endif #if TINYEXR_USE_MINIZ +#include <miniz.h> #else // Issue #46. Please include your own zlib-compatible API header before // including `tinyexr.h` @@ -588,6467 +654,6 @@ typedef long long tinyexr_int64; #endif #endif -#if TINYEXR_USE_MINIZ - -namespace miniz { - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wc++11-long-long" -#pragma clang diagnostic ignored "-Wold-style-cast" -#pragma clang diagnostic ignored "-Wpadded" -#pragma clang diagnostic ignored "-Wsign-conversion" -#pragma clang diagnostic ignored "-Wc++11-extensions" -#pragma clang diagnostic ignored "-Wconversion" -#pragma clang diagnostic ignored "-Wunused-function" -#pragma clang diagnostic ignored "-Wc++98-compat-pedantic" -#pragma clang diagnostic ignored "-Wundef" - -#if __has_warning("-Wcomma") -#pragma clang diagnostic ignored "-Wcomma" -#endif - -#if __has_warning("-Wmacro-redefined") -#pragma clang diagnostic ignored "-Wmacro-redefined" -#endif - -#if __has_warning("-Wcast-qual") -#pragma clang diagnostic ignored "-Wcast-qual" -#endif - -#if __has_warning("-Wzero-as-null-pointer-constant") -#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" -#endif - -#if __has_warning("-Wtautological-constant-compare") -#pragma clang diagnostic ignored "-Wtautological-constant-compare" -#endif - -#if __has_warning("-Wextra-semi-stmt") -#pragma clang diagnostic ignored "-Wextra-semi-stmt" -#endif - -#endif - -/* miniz.c v1.15 - public domain deflate/inflate, zlib-subset, ZIP - reading/writing/appending, PNG writing - See "unlicense" statement at the end of this file. - Rich Geldreich <richgel99@gmail.com>, last updated Oct. 13, 2013 - Implements RFC 1950: http://www.ietf.org/rfc/rfc1950.txt and RFC 1951: - http://www.ietf.org/rfc/rfc1951.txt - - Most API's defined in miniz.c are optional. For example, to disable the - archive related functions just define - MINIZ_NO_ARCHIVE_APIS, or to get rid of all stdio usage define MINIZ_NO_STDIO - (see the list below for more macros). - - * Change History - 10/13/13 v1.15 r4 - Interim bugfix release while I work on the next major - release with Zip64 support (almost there!): - - Critical fix for the MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY bug - (thanks kahmyong.moon@hp.com) which could cause locate files to not find - files. This bug - would only have occurred in earlier versions if you explicitly used this - flag, OR if you used mz_zip_extract_archive_file_to_heap() or - mz_zip_add_mem_to_archive_file_in_place() - (which used this flag). If you can't switch to v1.15 but want to fix - this bug, just remove the uses of this flag from both helper funcs (and of - course don't use the flag). - - Bugfix in mz_zip_reader_extract_to_mem_no_alloc() from kymoon when - pUser_read_buf is not NULL and compressed size is > uncompressed size - - Fixing mz_zip_reader_extract_*() funcs so they don't try to extract - compressed data from directory entries, to account for weird zipfiles which - contain zero-size compressed data on dir entries. - Hopefully this fix won't cause any issues on weird zip archives, - because it assumes the low 16-bits of zip external attributes are DOS - attributes (which I believe they always are in practice). - - Fixing mz_zip_reader_is_file_a_directory() so it doesn't check the - internal attributes, just the filename and external attributes - - mz_zip_reader_init_file() - missing MZ_FCLOSE() call if the seek failed - - Added cmake support for Linux builds which builds all the examples, - tested with clang v3.3 and gcc v4.6. - - Clang fix for tdefl_write_image_to_png_file_in_memory() from toffaletti - - Merged MZ_FORCEINLINE fix from hdeanclark - - Fix <time.h> include before config #ifdef, thanks emil.brink - - Added tdefl_write_image_to_png_file_in_memory_ex(): supports Y flipping - (super useful for OpenGL apps), and explicit control over the compression - level (so you can - set it to 1 for real-time compression). - - Merged in some compiler fixes from paulharris's github repro. - - Retested this build under Windows (VS 2010, including static analysis), - tcc 0.9.26, gcc v4.6 and clang v3.3. - - Added example6.c, which dumps an image of the mandelbrot set to a PNG - file. - - Modified example2 to help test the - MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY flag more. - - In r3: Bugfix to mz_zip_writer_add_file() found during merge: Fix - possible src file fclose() leak if alignment bytes+local header file write - faiiled - - In r4: Minor bugfix to mz_zip_writer_add_from_zip_reader(): - Was pushing the wrong central dir header offset, appears harmless in this - release, but it became a problem in the zip64 branch - 5/20/12 v1.14 - MinGW32/64 GCC 4.6.1 compiler fixes: added MZ_FORCEINLINE, - #include <time.h> (thanks fermtect). - 5/19/12 v1.13 - From jason@cornsyrup.org and kelwert@mtu.edu - Fix - mz_crc32() so it doesn't compute the wrong CRC-32's when mz_ulong is 64-bit. - - Temporarily/locally slammed in "typedef unsigned long mz_ulong" and - re-ran a randomized regression test on ~500k files. - - Eliminated a bunch of warnings when compiling with GCC 32-bit/64. - - Ran all examples, miniz.c, and tinfl.c through MSVC 2008's /analyze - (static analysis) option and fixed all warnings (except for the silly - "Use of the comma-operator in a tested expression.." analysis warning, - which I purposely use to work around a MSVC compiler warning). - - Created 32-bit and 64-bit Codeblocks projects/workspace. Built and - tested Linux executables. The codeblocks workspace is compatible with - Linux+Win32/x64. - - Added miniz_tester solution/project, which is a useful little app - derived from LZHAM's tester app that I use as part of the regression test. - - Ran miniz.c and tinfl.c through another series of regression testing on - ~500,000 files and archives. - - Modified example5.c so it purposely disables a bunch of high-level - functionality (MINIZ_NO_STDIO, etc.). (Thanks to corysama for the - MINIZ_NO_STDIO bug report.) - - Fix ftell() usage in examples so they exit with an error on files which - are too large (a limitation of the examples, not miniz itself). - 4/12/12 v1.12 - More comments, added low-level example5.c, fixed a couple - minor level_and_flags issues in the archive API's. - level_and_flags can now be set to MZ_DEFAULT_COMPRESSION. Thanks to Bruce - Dawson <bruced@valvesoftware.com> for the feedback/bug report. - 5/28/11 v1.11 - Added statement from unlicense.org - 5/27/11 v1.10 - Substantial compressor optimizations: - - Level 1 is now ~4x faster than before. The L1 compressor's throughput - now varies between 70-110MB/sec. on a - - Core i7 (actual throughput varies depending on the type of data, and x64 - vs. x86). - - Improved baseline L2-L9 compression perf. Also, greatly improved - compression perf. issues on some file types. - - Refactored the compression code for better readability and - maintainability. - - Added level 10 compression level (L10 has slightly better ratio than - level 9, but could have a potentially large - drop in throughput on some files). - 5/15/11 v1.09 - Initial stable release. - - * Low-level Deflate/Inflate implementation notes: - - Compression: Use the "tdefl" API's. The compressor supports raw, static, - and dynamic blocks, lazy or - greedy parsing, match length filtering, RLE-only, and Huffman-only streams. - It performs and compresses - approximately as well as zlib. - - Decompression: Use the "tinfl" API's. The entire decompressor is - implemented as a single function - coroutine: see tinfl_decompress(). It supports decompression into a 32KB - (or larger power of 2) wrapping buffer, or into a memory - block large enough to hold the entire file. - - The low-level tdefl/tinfl API's do not make any use of dynamic memory - allocation. - - * zlib-style API notes: - - miniz.c implements a fairly large subset of zlib. There's enough - functionality present for it to be a drop-in - zlib replacement in many apps: - The z_stream struct, optional memory allocation callbacks - deflateInit/deflateInit2/deflate/deflateReset/deflateEnd/deflateBound - inflateInit/inflateInit2/inflate/inflateEnd - compress, compress2, compressBound, uncompress - CRC-32, Adler-32 - Using modern, minimal code size, CPU cache friendly - routines. - Supports raw deflate streams or standard zlib streams with adler-32 - checking. - - Limitations: - The callback API's are not implemented yet. No support for gzip headers or - zlib static dictionaries. - I've tried to closely emulate zlib's various flavors of stream flushing - and return status codes, but - there are no guarantees that miniz.c pulls this off perfectly. - - * PNG writing: See the tdefl_write_image_to_png_file_in_memory() function, - originally written by - Alex Evans. Supports 1-4 bytes/pixel images. - - * ZIP archive API notes: - - The ZIP archive API's where designed with simplicity and efficiency in - mind, with just enough abstraction to - get the job done with minimal fuss. There are simple API's to retrieve file - information, read files from - existing archives, create new archives, append new files to existing - archives, or clone archive data from - one archive to another. It supports archives located in memory or the heap, - on disk (using stdio.h), - or you can specify custom file read/write callbacks. - - - Archive reading: Just call this function to read a single file from a - disk archive: - - void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const - char *pArchive_name, - size_t *pSize, mz_uint zip_flags); - - For more complex cases, use the "mz_zip_reader" functions. Upon opening an - archive, the entire central - directory is located and read as-is into memory, and subsequent file access - only occurs when reading individual files. - - - Archives file scanning: The simple way is to use this function to scan a - loaded archive for a specific file: - - int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, - const char *pComment, mz_uint flags); - - The locate operation can optionally check file comments too, which (as one - example) can be used to identify - multiple versions of the same file in an archive. This function uses a - simple linear search through the central - directory, so it's not very fast. - - Alternately, you can iterate through all the files in an archive (using - mz_zip_reader_get_num_files()) and - retrieve detailed info on each file by calling mz_zip_reader_file_stat(). - - - Archive creation: Use the "mz_zip_writer" functions. The ZIP writer - immediately writes compressed file data - to disk and builds an exact image of the central directory in memory. The - central directory image is written - all at once at the end of the archive file when the archive is finalized. - - The archive writer can optionally align each file's local header and file - data to any power of 2 alignment, - which can be useful when the archive will be read from optical media. Also, - the writer supports placing - arbitrary data blobs at the very beginning of ZIP archives. Archives - written using either feature are still - readable by any ZIP tool. - - - Archive appending: The simple way to add a single file to an archive is - to call this function: - - mz_bool mz_zip_add_mem_to_archive_file_in_place(const char *pZip_filename, - const char *pArchive_name, - const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 - comment_size, mz_uint level_and_flags); - - The archive will be created if it doesn't already exist, otherwise it'll be - appended to. - Note the appending is done in-place and is not an atomic operation, so if - something goes wrong - during the operation it's possible the archive could be left without a - central directory (although the local - file headers and file data will be fine, so the archive will be - recoverable). - - For more complex archive modification scenarios: - 1. The safest way is to use a mz_zip_reader to read the existing archive, - cloning only those bits you want to - preserve into a new archive using using the - mz_zip_writer_add_from_zip_reader() function (which compiles the - compressed file data as-is). When you're done, delete the old archive and - rename the newly written archive, and - you're done. This is safe but requires a bunch of temporary disk space or - heap memory. - - 2. Or, you can convert an mz_zip_reader in-place to an mz_zip_writer using - mz_zip_writer_init_from_reader(), - append new files as needed, then finalize the archive which will write an - updated central directory to the - original archive. (This is basically what - mz_zip_add_mem_to_archive_file_in_place() does.) There's a - possibility that the archive's central directory could be lost with this - method if anything goes wrong, though. - - - ZIP archive support limitations: - No zip64 or spanning support. Extraction functions can only handle - unencrypted, stored or deflated files. - Requires streams capable of seeking. - - * This is a header file library, like stb_image.c. To get only a header file, - either cut and paste the - below header, or create miniz.h, #define MINIZ_HEADER_FILE_ONLY, and then - include miniz.c from it. - - * Important: For best perf. be sure to customize the below macros for your - target platform: - #define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 1 - #define MINIZ_LITTLE_ENDIAN 1 - #define MINIZ_HAS_64BIT_REGISTERS 1 - - * On platforms using glibc, Be sure to "#define _LARGEFILE64_SOURCE 1" before - including miniz.c to ensure miniz - uses the 64-bit variants: fopen64(), stat64(), etc. Otherwise you won't be - able to process large files - (i.e. 32-bit stat() fails for me on files > 0x7FFFFFFF bytes). -*/ - -#ifndef MINIZ_HEADER_INCLUDED -#define MINIZ_HEADER_INCLUDED - -//#include <stdlib.h> - -// Defines to completely disable specific portions of miniz.c: -// If all macros here are defined the only functionality remaining will be -// CRC-32, adler-32, tinfl, and tdefl. - -// Define MINIZ_NO_STDIO to disable all usage and any functions which rely on -// stdio for file I/O. -//#define MINIZ_NO_STDIO - -// If MINIZ_NO_TIME is specified then the ZIP archive functions will not be able -// to get the current time, or -// get/set file times, and the C run-time funcs that get/set times won't be -// called. -// The current downside is the times written to your archives will be from 1979. -#define MINIZ_NO_TIME - -// Define MINIZ_NO_ARCHIVE_APIS to disable all ZIP archive API's. -#define MINIZ_NO_ARCHIVE_APIS - -// Define MINIZ_NO_ARCHIVE_APIS to disable all writing related ZIP archive -// API's. -//#define MINIZ_NO_ARCHIVE_WRITING_APIS - -// Define MINIZ_NO_ZLIB_APIS to remove all ZLIB-style compression/decompression -// API's. -//#define MINIZ_NO_ZLIB_APIS - -// Define MINIZ_NO_ZLIB_COMPATIBLE_NAME to disable zlib names, to prevent -// conflicts against stock zlib. -//#define MINIZ_NO_ZLIB_COMPATIBLE_NAMES - -// Define MINIZ_NO_MALLOC to disable all calls to malloc, free, and realloc. -// Note if MINIZ_NO_MALLOC is defined then the user must always provide custom -// user alloc/free/realloc -// callbacks to the zlib and archive API's, and a few stand-alone helper API's -// which don't provide custom user -// functions (such as tdefl_compress_mem_to_heap() and -// tinfl_decompress_mem_to_heap()) won't work. -//#define MINIZ_NO_MALLOC - -#if defined(__TINYC__) && (defined(__linux) || defined(__linux__)) -// TODO: Work around "error: include file 'sys\utime.h' when compiling with tcc -// on Linux -#define MINIZ_NO_TIME -#endif - -#if !defined(MINIZ_NO_TIME) && !defined(MINIZ_NO_ARCHIVE_APIS) -//#include <time.h> -#endif - -#if defined(_M_IX86) || defined(_M_X64) || defined(__i386__) || \ - defined(__i386) || defined(__i486__) || defined(__i486) || \ - defined(i386) || defined(__ia64__) || defined(__x86_64__) -// MINIZ_X86_OR_X64_CPU is only used to help set the below macros. -#define MINIZ_X86_OR_X64_CPU 1 -#endif - -#if defined(__sparcv9) -// Big endian -#else -#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || MINIZ_X86_OR_X64_CPU -// Set MINIZ_LITTLE_ENDIAN to 1 if the processor is little endian. -#define MINIZ_LITTLE_ENDIAN 1 -#endif -#endif - -#if MINIZ_X86_OR_X64_CPU -// Set MINIZ_USE_UNALIGNED_LOADS_AND_STORES to 1 on CPU's that permit efficient -// integer loads and stores from unaligned addresses. -//#define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 1 -#define MINIZ_USE_UNALIGNED_LOADS_AND_STORES \ - 0 // disable to suppress compiler warnings -#endif - -#if defined(_M_X64) || defined(_WIN64) || defined(__MINGW64__) || \ - defined(_LP64) || defined(__LP64__) || defined(__ia64__) || \ - defined(__x86_64__) -// Set MINIZ_HAS_64BIT_REGISTERS to 1 if operations on 64-bit integers are -// reasonably fast (and don't involve compiler generated calls to helper -// functions). -#define MINIZ_HAS_64BIT_REGISTERS 1 -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -// ------------------- zlib-style API Definitions. - -// For more compatibility with zlib, miniz.c uses unsigned long for some -// parameters/struct members. Beware: mz_ulong can be either 32 or 64-bits! -typedef unsigned long mz_ulong; - -// mz_free() internally uses the MZ_FREE() macro (which by default calls free() -// unless you've modified the MZ_MALLOC macro) to release a block allocated from -// the heap. -void mz_free(void *p); - -#define MZ_ADLER32_INIT (1) -// mz_adler32() returns the initial adler-32 value to use when called with -// ptr==NULL. -mz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len); - -#define MZ_CRC32_INIT (0) -// mz_crc32() returns the initial CRC-32 value to use when called with -// ptr==NULL. -mz_ulong mz_crc32(mz_ulong crc, const unsigned char *ptr, size_t buf_len); - -// Compression strategies. -enum { - MZ_DEFAULT_STRATEGY = 0, - MZ_FILTERED = 1, - MZ_HUFFMAN_ONLY = 2, - MZ_RLE = 3, - MZ_FIXED = 4 -}; - -// Method -#define MZ_DEFLATED 8 - -#ifndef MINIZ_NO_ZLIB_APIS - -// Heap allocation callbacks. -// Note that mz_alloc_func parameter types purpsosely differ from zlib's: -// items/size is size_t, not unsigned long. -typedef void *(*mz_alloc_func)(void *opaque, size_t items, size_t size); -typedef void (*mz_free_func)(void *opaque, void *address); -typedef void *(*mz_realloc_func)(void *opaque, void *address, size_t items, - size_t size); - -#define MZ_VERSION "9.1.15" -#define MZ_VERNUM 0x91F0 -#define MZ_VER_MAJOR 9 -#define MZ_VER_MINOR 1 -#define MZ_VER_REVISION 15 -#define MZ_VER_SUBREVISION 0 - -// Flush values. For typical usage you only need MZ_NO_FLUSH and MZ_FINISH. The -// other values are for advanced use (refer to the zlib docs). -enum { - MZ_NO_FLUSH = 0, - MZ_PARTIAL_FLUSH = 1, - MZ_SYNC_FLUSH = 2, - MZ_FULL_FLUSH = 3, - MZ_FINISH = 4, - MZ_BLOCK = 5 -}; - -// Return status codes. MZ_PARAM_ERROR is non-standard. -enum { - MZ_OK = 0, - MZ_STREAM_END = 1, - MZ_NEED_DICT = 2, - MZ_ERRNO = -1, - MZ_STREAM_ERROR = -2, - MZ_DATA_ERROR = -3, - MZ_MEM_ERROR = -4, - MZ_BUF_ERROR = -5, - MZ_VERSION_ERROR = -6, - MZ_PARAM_ERROR = -10000 -}; - -// Compression levels: 0-9 are the standard zlib-style levels, 10 is best -// possible compression (not zlib compatible, and may be very slow), -// MZ_DEFAULT_COMPRESSION=MZ_DEFAULT_LEVEL. -enum { - MZ_NO_COMPRESSION = 0, - MZ_BEST_SPEED = 1, - MZ_BEST_COMPRESSION = 9, - MZ_UBER_COMPRESSION = 10, - MZ_DEFAULT_LEVEL = 6, - MZ_DEFAULT_COMPRESSION = -1 -}; - -// Window bits -#define MZ_DEFAULT_WINDOW_BITS 15 - -struct mz_internal_state; - -// Compression/decompression stream struct. -typedef struct mz_stream_s { - const unsigned char *next_in; // pointer to next byte to read - unsigned int avail_in; // number of bytes available at next_in - mz_ulong total_in; // total number of bytes consumed so far - - unsigned char *next_out; // pointer to next byte to write - unsigned int avail_out; // number of bytes that can be written to next_out - mz_ulong total_out; // total number of bytes produced so far - - char *msg; // error msg (unused) - struct mz_internal_state *state; // internal state, allocated by zalloc/zfree - - mz_alloc_func - zalloc; // optional heap allocation function (defaults to malloc) - mz_free_func zfree; // optional heap free function (defaults to free) - void *opaque; // heap alloc function user pointer - - int data_type; // data_type (unused) - mz_ulong adler; // adler32 of the source or uncompressed data - mz_ulong reserved; // not used -} mz_stream; - -typedef mz_stream *mz_streamp; - -// Returns the version string of miniz.c. -const char *mz_version(void); - -// mz_deflateInit() initializes a compressor with default options: -// Parameters: -// pStream must point to an initialized mz_stream struct. -// level must be between [MZ_NO_COMPRESSION, MZ_BEST_COMPRESSION]. -// level 1 enables a specially optimized compression function that's been -// optimized purely for performance, not ratio. -// (This special func. is currently only enabled when -// MINIZ_USE_UNALIGNED_LOADS_AND_STORES and MINIZ_LITTLE_ENDIAN are defined.) -// Return values: -// MZ_OK on success. -// MZ_STREAM_ERROR if the stream is bogus. -// MZ_PARAM_ERROR if the input parameters are bogus. -// MZ_MEM_ERROR on out of memory. -int mz_deflateInit(mz_streamp pStream, int level); - -// mz_deflateInit2() is like mz_deflate(), except with more control: -// Additional parameters: -// method must be MZ_DEFLATED -// window_bits must be MZ_DEFAULT_WINDOW_BITS (to wrap the deflate stream with -// zlib header/adler-32 footer) or -MZ_DEFAULT_WINDOW_BITS (raw deflate/no -// header or footer) -// mem_level must be between [1, 9] (it's checked but ignored by miniz.c) -int mz_deflateInit2(mz_streamp pStream, int level, int method, int window_bits, - int mem_level, int strategy); - -// Quickly resets a compressor without having to reallocate anything. Same as -// calling mz_deflateEnd() followed by mz_deflateInit()/mz_deflateInit2(). -int mz_deflateReset(mz_streamp pStream); - -// mz_deflate() compresses the input to output, consuming as much of the input -// and producing as much output as possible. -// Parameters: -// pStream is the stream to read from and write to. You must initialize/update -// the next_in, avail_in, next_out, and avail_out members. -// flush may be MZ_NO_FLUSH, MZ_PARTIAL_FLUSH/MZ_SYNC_FLUSH, MZ_FULL_FLUSH, or -// MZ_FINISH. -// Return values: -// MZ_OK on success (when flushing, or if more input is needed but not -// available, and/or there's more output to be written but the output buffer -// is full). -// MZ_STREAM_END if all input has been consumed and all output bytes have been -// written. Don't call mz_deflate() on the stream anymore. -// MZ_STREAM_ERROR if the stream is bogus. -// MZ_PARAM_ERROR if one of the parameters is invalid. -// MZ_BUF_ERROR if no forward progress is possible because the input and/or -// output buffers are empty. (Fill up the input buffer or free up some output -// space and try again.) -int mz_deflate(mz_streamp pStream, int flush); - -// mz_deflateEnd() deinitializes a compressor: -// Return values: -// MZ_OK on success. -// MZ_STREAM_ERROR if the stream is bogus. -int mz_deflateEnd(mz_streamp pStream); - -// mz_deflateBound() returns a (very) conservative upper bound on the amount of -// data that could be generated by deflate(), assuming flush is set to only -// MZ_NO_FLUSH or MZ_FINISH. -mz_ulong mz_deflateBound(mz_streamp pStream, mz_ulong source_len); - -// Single-call compression functions mz_compress() and mz_compress2(): -// Returns MZ_OK on success, or one of the error codes from mz_deflate() on -// failure. -int mz_compress(unsigned char *pDest, mz_ulong *pDest_len, - const unsigned char *pSource, mz_ulong source_len); -int mz_compress2(unsigned char *pDest, mz_ulong *pDest_len, - const unsigned char *pSource, mz_ulong source_len, int level); - -// mz_compressBound() returns a (very) conservative upper bound on the amount of -// data that could be generated by calling mz_compress(). -mz_ulong mz_compressBound(mz_ulong source_len); - -// Initializes a decompressor. -int mz_inflateInit(mz_streamp pStream); - -// mz_inflateInit2() is like mz_inflateInit() with an additional option that -// controls the window size and whether or not the stream has been wrapped with -// a zlib header/footer: -// window_bits must be MZ_DEFAULT_WINDOW_BITS (to parse zlib header/footer) or -// -MZ_DEFAULT_WINDOW_BITS (raw deflate). -int mz_inflateInit2(mz_streamp pStream, int window_bits); - -// Decompresses the input stream to the output, consuming only as much of the -// input as needed, and writing as much to the output as possible. -// Parameters: -// pStream is the stream to read from and write to. You must initialize/update -// the next_in, avail_in, next_out, and avail_out members. -// flush may be MZ_NO_FLUSH, MZ_SYNC_FLUSH, or MZ_FINISH. -// On the first call, if flush is MZ_FINISH it's assumed the input and output -// buffers are both sized large enough to decompress the entire stream in a -// single call (this is slightly faster). -// MZ_FINISH implies that there are no more source bytes available beside -// what's already in the input buffer, and that the output buffer is large -// enough to hold the rest of the decompressed data. -// Return values: -// MZ_OK on success. Either more input is needed but not available, and/or -// there's more output to be written but the output buffer is full. -// MZ_STREAM_END if all needed input has been consumed and all output bytes -// have been written. For zlib streams, the adler-32 of the decompressed data -// has also been verified. -// MZ_STREAM_ERROR if the stream is bogus. -// MZ_DATA_ERROR if the deflate stream is invalid. -// MZ_PARAM_ERROR if one of the parameters is invalid. -// MZ_BUF_ERROR if no forward progress is possible because the input buffer is -// empty but the inflater needs more input to continue, or if the output -// buffer is not large enough. Call mz_inflate() again -// with more input data, or with more room in the output buffer (except when -// using single call decompression, described above). -int mz_inflate(mz_streamp pStream, int flush); - -// Deinitializes a decompressor. -int mz_inflateEnd(mz_streamp pStream); - -// Single-call decompression. -// Returns MZ_OK on success, or one of the error codes from mz_inflate() on -// failure. -int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, - const unsigned char *pSource, mz_ulong source_len); - -// Returns a string description of the specified error code, or NULL if the -// error code is invalid. -const char *mz_error(int err); - -// Redefine zlib-compatible names to miniz equivalents, so miniz.c can be used -// as a drop-in replacement for the subset of zlib that miniz.c supports. -// Define MINIZ_NO_ZLIB_COMPATIBLE_NAMES to disable zlib-compatibility if you -// use zlib in the same project. -#ifndef MINIZ_NO_ZLIB_COMPATIBLE_NAMES -typedef unsigned char Byte; -typedef unsigned int uInt; -typedef mz_ulong uLong; -typedef Byte Bytef; -typedef uInt uIntf; -typedef char charf; -typedef int intf; -typedef void *voidpf; -typedef uLong uLongf; -typedef void *voidp; -typedef void *const voidpc; -#define Z_NULL 0 -#define Z_NO_FLUSH MZ_NO_FLUSH -#define Z_PARTIAL_FLUSH MZ_PARTIAL_FLUSH -#define Z_SYNC_FLUSH MZ_SYNC_FLUSH -#define Z_FULL_FLUSH MZ_FULL_FLUSH -#define Z_FINISH MZ_FINISH -#define Z_BLOCK MZ_BLOCK -#define Z_OK MZ_OK -#define Z_STREAM_END MZ_STREAM_END -#define Z_NEED_DICT MZ_NEED_DICT -#define Z_ERRNO MZ_ERRNO -#define Z_STREAM_ERROR MZ_STREAM_ERROR -#define Z_DATA_ERROR MZ_DATA_ERROR -#define Z_MEM_ERROR MZ_MEM_ERROR -#define Z_BUF_ERROR MZ_BUF_ERROR -#define Z_VERSION_ERROR MZ_VERSION_ERROR -#define Z_PARAM_ERROR MZ_PARAM_ERROR -#define Z_NO_COMPRESSION MZ_NO_COMPRESSION -#define Z_BEST_SPEED MZ_BEST_SPEED -#define Z_BEST_COMPRESSION MZ_BEST_COMPRESSION -#define Z_DEFAULT_COMPRESSION MZ_DEFAULT_COMPRESSION -#define Z_DEFAULT_STRATEGY MZ_DEFAULT_STRATEGY -#define Z_FILTERED MZ_FILTERED -#define Z_HUFFMAN_ONLY MZ_HUFFMAN_ONLY -#define Z_RLE MZ_RLE -#define Z_FIXED MZ_FIXED -#define Z_DEFLATED MZ_DEFLATED -#define Z_DEFAULT_WINDOW_BITS MZ_DEFAULT_WINDOW_BITS -#define alloc_func mz_alloc_func -#define free_func mz_free_func -#define internal_state mz_internal_state -#define z_stream mz_stream -#define deflateInit mz_deflateInit -#define deflateInit2 mz_deflateInit2 -#define deflateReset mz_deflateReset -#define deflate mz_deflate -#define deflateEnd mz_deflateEnd -#define deflateBound mz_deflateBound -#define compress mz_compress -#define compress2 mz_compress2 -#define compressBound mz_compressBound -#define inflateInit mz_inflateInit -#define inflateInit2 mz_inflateInit2 -#define inflate mz_inflate -#define inflateEnd mz_inflateEnd -#define uncompress mz_uncompress -#define crc32 mz_crc32 -#define adler32 mz_adler32 -#define MAX_WBITS 15 -#define MAX_MEM_LEVEL 9 -#define zError mz_error -#define ZLIB_VERSION MZ_VERSION -#define ZLIB_VERNUM MZ_VERNUM -#define ZLIB_VER_MAJOR MZ_VER_MAJOR -#define ZLIB_VER_MINOR MZ_VER_MINOR -#define ZLIB_VER_REVISION MZ_VER_REVISION -#define ZLIB_VER_SUBREVISION MZ_VER_SUBREVISION -#define zlibVersion mz_version -#define zlib_version mz_version() -#endif // #ifndef MINIZ_NO_ZLIB_COMPATIBLE_NAMES - -#endif // MINIZ_NO_ZLIB_APIS - -// ------------------- Types and macros - -typedef unsigned char mz_uint8; -typedef signed short mz_int16; -typedef unsigned short mz_uint16; -typedef unsigned int mz_uint32; -typedef unsigned int mz_uint; -typedef long long mz_int64; -typedef unsigned long long mz_uint64; -typedef int mz_bool; - -#define MZ_FALSE (0) -#define MZ_TRUE (1) - -// An attempt to work around MSVC's spammy "warning C4127: conditional -// expression is constant" message. -#ifdef _MSC_VER -#define MZ_MACRO_END while (0, 0) -#else -#define MZ_MACRO_END while (0) -#endif - -// ------------------- ZIP archive reading/writing - -#ifndef MINIZ_NO_ARCHIVE_APIS - -enum { - MZ_ZIP_MAX_IO_BUF_SIZE = 64 * 1024, - MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE = 260, - MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE = 256 -}; - -typedef struct { - mz_uint32 m_file_index; - mz_uint32 m_central_dir_ofs; - mz_uint16 m_version_made_by; - mz_uint16 m_version_needed; - mz_uint16 m_bit_flag; - mz_uint16 m_method; -#ifndef MINIZ_NO_TIME - time_t m_time; -#endif - mz_uint32 m_crc32; - mz_uint64 m_comp_size; - mz_uint64 m_uncomp_size; - mz_uint16 m_internal_attr; - mz_uint32 m_external_attr; - mz_uint64 m_local_header_ofs; - mz_uint32 m_comment_size; - char m_filename[MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE]; - char m_comment[MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE]; -} mz_zip_archive_file_stat; - -typedef size_t (*mz_file_read_func)(void *pOpaque, mz_uint64 file_ofs, - void *pBuf, size_t n); -typedef size_t (*mz_file_write_func)(void *pOpaque, mz_uint64 file_ofs, - const void *pBuf, size_t n); - -struct mz_zip_internal_state_tag; -typedef struct mz_zip_internal_state_tag mz_zip_internal_state; - -typedef enum { - MZ_ZIP_MODE_INVALID = 0, - MZ_ZIP_MODE_READING = 1, - MZ_ZIP_MODE_WRITING = 2, - MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED = 3 -} mz_zip_mode; - -typedef struct mz_zip_archive_tag { - mz_uint64 m_archive_size; - mz_uint64 m_central_directory_file_ofs; - mz_uint m_total_files; - mz_zip_mode m_zip_mode; - - mz_uint m_file_offset_alignment; - - mz_alloc_func m_pAlloc; - mz_free_func m_pFree; - mz_realloc_func m_pRealloc; - void *m_pAlloc_opaque; - - mz_file_read_func m_pRead; - mz_file_write_func m_pWrite; - void *m_pIO_opaque; - - mz_zip_internal_state *m_pState; - -} mz_zip_archive; - -typedef enum { - MZ_ZIP_FLAG_CASE_SENSITIVE = 0x0100, - MZ_ZIP_FLAG_IGNORE_PATH = 0x0200, - MZ_ZIP_FLAG_COMPRESSED_DATA = 0x0400, - MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY = 0x0800 -} mz_zip_flags; - -// ZIP archive reading - -// Inits a ZIP archive reader. -// These functions read and validate the archive's central directory. -mz_bool mz_zip_reader_init(mz_zip_archive *pZip, mz_uint64 size, - mz_uint32 flags); -mz_bool mz_zip_reader_init_mem(mz_zip_archive *pZip, const void *pMem, - size_t size, mz_uint32 flags); - -#ifndef MINIZ_NO_STDIO -mz_bool mz_zip_reader_init_file(mz_zip_archive *pZip, const char *pFilename, - mz_uint32 flags); -#endif - -// Returns the total number of files in the archive. -mz_uint mz_zip_reader_get_num_files(mz_zip_archive *pZip); - -// Returns detailed information about an archive file entry. -mz_bool mz_zip_reader_file_stat(mz_zip_archive *pZip, mz_uint file_index, - mz_zip_archive_file_stat *pStat); - -// Determines if an archive file entry is a directory entry. -mz_bool mz_zip_reader_is_file_a_directory(mz_zip_archive *pZip, - mz_uint file_index); -mz_bool mz_zip_reader_is_file_encrypted(mz_zip_archive *pZip, - mz_uint file_index); - -// Retrieves the filename of an archive file entry. -// Returns the number of bytes written to pFilename, or if filename_buf_size is -// 0 this function returns the number of bytes needed to fully store the -// filename. -mz_uint mz_zip_reader_get_filename(mz_zip_archive *pZip, mz_uint file_index, - char *pFilename, mz_uint filename_buf_size); - -// Attempts to locates a file in the archive's central directory. -// Valid flags: MZ_ZIP_FLAG_CASE_SENSITIVE, MZ_ZIP_FLAG_IGNORE_PATH -// Returns -1 if the file cannot be found. -int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, - const char *pComment, mz_uint flags); - -// Extracts a archive file to a memory buffer using no memory allocation. -mz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive *pZip, - mz_uint file_index, void *pBuf, - size_t buf_size, mz_uint flags, - void *pUser_read_buf, - size_t user_read_buf_size); -mz_bool mz_zip_reader_extract_file_to_mem_no_alloc( - mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, - mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size); - -// Extracts a archive file to a memory buffer. -mz_bool mz_zip_reader_extract_to_mem(mz_zip_archive *pZip, mz_uint file_index, - void *pBuf, size_t buf_size, - mz_uint flags); -mz_bool mz_zip_reader_extract_file_to_mem(mz_zip_archive *pZip, - const char *pFilename, void *pBuf, - size_t buf_size, mz_uint flags); - -// Extracts a archive file to a dynamically allocated heap buffer. -void *mz_zip_reader_extract_to_heap(mz_zip_archive *pZip, mz_uint file_index, - size_t *pSize, mz_uint flags); -void *mz_zip_reader_extract_file_to_heap(mz_zip_archive *pZip, - const char *pFilename, size_t *pSize, - mz_uint flags); - -// Extracts a archive file using a callback function to output the file's data. -mz_bool mz_zip_reader_extract_to_callback(mz_zip_archive *pZip, - mz_uint file_index, - mz_file_write_func pCallback, - void *pOpaque, mz_uint flags); -mz_bool mz_zip_reader_extract_file_to_callback(mz_zip_archive *pZip, - const char *pFilename, - mz_file_write_func pCallback, - void *pOpaque, mz_uint flags); - -#ifndef MINIZ_NO_STDIO -// Extracts a archive file to a disk file and sets its last accessed and -// modified times. -// This function only extracts files, not archive directory records. -mz_bool mz_zip_reader_extract_to_file(mz_zip_archive *pZip, mz_uint file_index, - const char *pDst_filename, mz_uint flags); -mz_bool mz_zip_reader_extract_file_to_file(mz_zip_archive *pZip, - const char *pArchive_filename, - const char *pDst_filename, - mz_uint flags); -#endif - -// Ends archive reading, freeing all allocations, and closing the input archive -// file if mz_zip_reader_init_file() was used. -mz_bool mz_zip_reader_end(mz_zip_archive *pZip); - -// ZIP archive writing - -#ifndef MINIZ_NO_ARCHIVE_WRITING_APIS - -// Inits a ZIP archive writer. -mz_bool mz_zip_writer_init(mz_zip_archive *pZip, mz_uint64 existing_size); -mz_bool mz_zip_writer_init_heap(mz_zip_archive *pZip, - size_t size_to_reserve_at_beginning, - size_t initial_allocation_size); - -#ifndef MINIZ_NO_STDIO -mz_bool mz_zip_writer_init_file(mz_zip_archive *pZip, const char *pFilename, - mz_uint64 size_to_reserve_at_beginning); -#endif - -// Converts a ZIP archive reader object into a writer object, to allow efficient -// in-place file appends to occur on an existing archive. -// For archives opened using mz_zip_reader_init_file, pFilename must be the -// archive's filename so it can be reopened for writing. If the file can't be -// reopened, mz_zip_reader_end() will be called. -// For archives opened using mz_zip_reader_init_mem, the memory block must be -// growable using the realloc callback (which defaults to realloc unless you've -// overridden it). -// Finally, for archives opened using mz_zip_reader_init, the mz_zip_archive's -// user provided m_pWrite function cannot be NULL. -// Note: In-place archive modification is not recommended unless you know what -// you're doing, because if execution stops or something goes wrong before -// the archive is finalized the file's central directory will be hosed. -mz_bool mz_zip_writer_init_from_reader(mz_zip_archive *pZip, - const char *pFilename); - -// Adds the contents of a memory buffer to an archive. These functions record -// the current local time into the archive. -// To add a directory entry, call this method with an archive name ending in a -// forwardslash with empty buffer. -// level_and_flags - compression level (0-10, see MZ_BEST_SPEED, -// MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or -// just set to MZ_DEFAULT_COMPRESSION. -mz_bool mz_zip_writer_add_mem(mz_zip_archive *pZip, const char *pArchive_name, - const void *pBuf, size_t buf_size, - mz_uint level_and_flags); -mz_bool mz_zip_writer_add_mem_ex(mz_zip_archive *pZip, - const char *pArchive_name, const void *pBuf, - size_t buf_size, const void *pComment, - mz_uint16 comment_size, - mz_uint level_and_flags, mz_uint64 uncomp_size, - mz_uint32 uncomp_crc32); - -#ifndef MINIZ_NO_STDIO -// Adds the contents of a disk file to an archive. This function also records -// the disk file's modified time into the archive. -// level_and_flags - compression level (0-10, see MZ_BEST_SPEED, -// MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or -// just set to MZ_DEFAULT_COMPRESSION. -mz_bool mz_zip_writer_add_file(mz_zip_archive *pZip, const char *pArchive_name, - const char *pSrc_filename, const void *pComment, - mz_uint16 comment_size, mz_uint level_and_flags); -#endif - -// Adds a file to an archive by fully cloning the data from another archive. -// This function fully clones the source file's compressed data (no -// recompression), along with its full filename, extra data, and comment fields. -mz_bool mz_zip_writer_add_from_zip_reader(mz_zip_archive *pZip, - mz_zip_archive *pSource_zip, - mz_uint file_index); - -// Finalizes the archive by writing the central directory records followed by -// the end of central directory record. -// After an archive is finalized, the only valid call on the mz_zip_archive -// struct is mz_zip_writer_end(). -// An archive must be manually finalized by calling this function for it to be -// valid. -mz_bool mz_zip_writer_finalize_archive(mz_zip_archive *pZip); -mz_bool mz_zip_writer_finalize_heap_archive(mz_zip_archive *pZip, void **pBuf, - size_t *pSize); - -// Ends archive writing, freeing all allocations, and closing the output file if -// mz_zip_writer_init_file() was used. -// Note for the archive to be valid, it must have been finalized before ending. -mz_bool mz_zip_writer_end(mz_zip_archive *pZip); - -// Misc. high-level helper functions: - -// mz_zip_add_mem_to_archive_file_in_place() efficiently (but not atomically) -// appends a memory blob to a ZIP archive. -// level_and_flags - compression level (0-10, see MZ_BEST_SPEED, -// MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or -// just set to MZ_DEFAULT_COMPRESSION. -mz_bool mz_zip_add_mem_to_archive_file_in_place( - const char *pZip_filename, const char *pArchive_name, const void *pBuf, - size_t buf_size, const void *pComment, mz_uint16 comment_size, - mz_uint level_and_flags); - -// Reads a single file from an archive into a heap block. -// Returns NULL on failure. -void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, - const char *pArchive_name, - size_t *pSize, mz_uint zip_flags); - -#endif // #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS - -#endif // #ifndef MINIZ_NO_ARCHIVE_APIS - -// ------------------- Low-level Decompression API Definitions - -// Decompression flags used by tinfl_decompress(). -// TINFL_FLAG_PARSE_ZLIB_HEADER: If set, the input has a valid zlib header and -// ends with an adler32 checksum (it's a valid zlib stream). Otherwise, the -// input is a raw deflate stream. -// TINFL_FLAG_HAS_MORE_INPUT: If set, there are more input bytes available -// beyond the end of the supplied input buffer. If clear, the input buffer -// contains all remaining input. -// TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF: If set, the output buffer is large -// enough to hold the entire decompressed stream. If clear, the output buffer is -// at least the size of the dictionary (typically 32KB). -// TINFL_FLAG_COMPUTE_ADLER32: Force adler-32 checksum computation of the -// decompressed bytes. -enum { - TINFL_FLAG_PARSE_ZLIB_HEADER = 1, - TINFL_FLAG_HAS_MORE_INPUT = 2, - TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF = 4, - TINFL_FLAG_COMPUTE_ADLER32 = 8 -}; - -// High level decompression functions: -// tinfl_decompress_mem_to_heap() decompresses a block in memory to a heap block -// allocated via malloc(). -// On entry: -// pSrc_buf, src_buf_len: Pointer and size of the Deflate or zlib source data -// to decompress. -// On return: -// Function returns a pointer to the decompressed data, or NULL on failure. -// *pOut_len will be set to the decompressed data's size, which could be larger -// than src_buf_len on uncompressible data. -// The caller must call mz_free() on the returned block when it's no longer -// needed. -void *tinfl_decompress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, - size_t *pOut_len, int flags); - -// tinfl_decompress_mem_to_mem() decompresses a block in memory to another block -// in memory. -// Returns TINFL_DECOMPRESS_MEM_TO_MEM_FAILED on failure, or the number of bytes -// written on success. -#define TINFL_DECOMPRESS_MEM_TO_MEM_FAILED ((size_t)(-1)) -size_t tinfl_decompress_mem_to_mem(void *pOut_buf, size_t out_buf_len, - const void *pSrc_buf, size_t src_buf_len, - int flags); - -// tinfl_decompress_mem_to_callback() decompresses a block in memory to an -// internal 32KB buffer, and a user provided callback function will be called to -// flush the buffer. -// Returns 1 on success or 0 on failure. -typedef int (*tinfl_put_buf_func_ptr)(const void *pBuf, int len, void *pUser); -int tinfl_decompress_mem_to_callback(const void *pIn_buf, size_t *pIn_buf_size, - tinfl_put_buf_func_ptr pPut_buf_func, - void *pPut_buf_user, int flags); - -struct tinfl_decompressor_tag; -typedef struct tinfl_decompressor_tag tinfl_decompressor; - -// Max size of LZ dictionary. -#define TINFL_LZ_DICT_SIZE 32768 - -// Return status. -typedef enum { - TINFL_STATUS_BAD_PARAM = -3, - TINFL_STATUS_ADLER32_MISMATCH = -2, - TINFL_STATUS_FAILED = -1, - TINFL_STATUS_DONE = 0, - TINFL_STATUS_NEEDS_MORE_INPUT = 1, - TINFL_STATUS_HAS_MORE_OUTPUT = 2 -} tinfl_status; - -// Initializes the decompressor to its initial state. -#define tinfl_init(r) \ - do { \ - (r)->m_state = 0; \ - } \ - MZ_MACRO_END -#define tinfl_get_adler32(r) (r)->m_check_adler32 - -// Main low-level decompressor coroutine function. This is the only function -// actually needed for decompression. All the other functions are just -// high-level helpers for improved usability. -// This is a universal API, i.e. it can be used as a building block to build any -// desired higher level decompression API. In the limit case, it can be called -// once per every byte input or output. -tinfl_status tinfl_decompress(tinfl_decompressor *r, - const mz_uint8 *pIn_buf_next, - size_t *pIn_buf_size, mz_uint8 *pOut_buf_start, - mz_uint8 *pOut_buf_next, size_t *pOut_buf_size, - const mz_uint32 decomp_flags); - -// Internal/private bits follow. -enum { - TINFL_MAX_HUFF_TABLES = 3, - TINFL_MAX_HUFF_SYMBOLS_0 = 288, - TINFL_MAX_HUFF_SYMBOLS_1 = 32, - TINFL_MAX_HUFF_SYMBOLS_2 = 19, - TINFL_FAST_LOOKUP_BITS = 10, - TINFL_FAST_LOOKUP_SIZE = 1 << TINFL_FAST_LOOKUP_BITS -}; - -typedef struct { - mz_uint8 m_code_size[TINFL_MAX_HUFF_SYMBOLS_0]; - mz_int16 m_look_up[TINFL_FAST_LOOKUP_SIZE], - m_tree[TINFL_MAX_HUFF_SYMBOLS_0 * 2]; -} tinfl_huff_table; - -#if MINIZ_HAS_64BIT_REGISTERS -#define TINFL_USE_64BIT_BITBUF 1 -#endif - -#if TINFL_USE_64BIT_BITBUF -typedef mz_uint64 tinfl_bit_buf_t; -#define TINFL_BITBUF_SIZE (64) -#else -typedef mz_uint32 tinfl_bit_buf_t; -#define TINFL_BITBUF_SIZE (32) -#endif - -struct tinfl_decompressor_tag { - mz_uint32 m_state, m_num_bits, m_zhdr0, m_zhdr1, m_z_adler32, m_final, m_type, - m_check_adler32, m_dist, m_counter, m_num_extra, - m_table_sizes[TINFL_MAX_HUFF_TABLES]; - tinfl_bit_buf_t m_bit_buf; - size_t m_dist_from_out_buf_start; - tinfl_huff_table m_tables[TINFL_MAX_HUFF_TABLES]; - mz_uint8 m_raw_header[4], - m_len_codes[TINFL_MAX_HUFF_SYMBOLS_0 + TINFL_MAX_HUFF_SYMBOLS_1 + 137]; -}; - -// ------------------- Low-level Compression API Definitions - -// Set TDEFL_LESS_MEMORY to 1 to use less memory (compression will be slightly -// slower, and raw/dynamic blocks will be output more frequently). -#define TDEFL_LESS_MEMORY 0 - -// tdefl_init() compression flags logically OR'd together (low 12 bits contain -// the max. number of probes per dictionary search): -// TDEFL_DEFAULT_MAX_PROBES: The compressor defaults to 128 dictionary probes -// per dictionary search. 0=Huffman only, 1=Huffman+LZ (fastest/crap -// compression), 4095=Huffman+LZ (slowest/best compression). -enum { - TDEFL_HUFFMAN_ONLY = 0, - TDEFL_DEFAULT_MAX_PROBES = 128, - TDEFL_MAX_PROBES_MASK = 0xFFF -}; - -// TDEFL_WRITE_ZLIB_HEADER: If set, the compressor outputs a zlib header before -// the deflate data, and the Adler-32 of the source data at the end. Otherwise, -// you'll get raw deflate data. -// TDEFL_COMPUTE_ADLER32: Always compute the adler-32 of the input data (even -// when not writing zlib headers). -// TDEFL_GREEDY_PARSING_FLAG: Set to use faster greedy parsing, instead of more -// efficient lazy parsing. -// TDEFL_NONDETERMINISTIC_PARSING_FLAG: Enable to decrease the compressor's -// initialization time to the minimum, but the output may vary from run to run -// given the same input (depending on the contents of memory). -// TDEFL_RLE_MATCHES: Only look for RLE matches (matches with a distance of 1) -// TDEFL_FILTER_MATCHES: Discards matches <= 5 chars if enabled. -// TDEFL_FORCE_ALL_STATIC_BLOCKS: Disable usage of optimized Huffman tables. -// TDEFL_FORCE_ALL_RAW_BLOCKS: Only use raw (uncompressed) deflate blocks. -// The low 12 bits are reserved to control the max # of hash probes per -// dictionary lookup (see TDEFL_MAX_PROBES_MASK). -enum { - TDEFL_WRITE_ZLIB_HEADER = 0x01000, - TDEFL_COMPUTE_ADLER32 = 0x02000, - TDEFL_GREEDY_PARSING_FLAG = 0x04000, - TDEFL_NONDETERMINISTIC_PARSING_FLAG = 0x08000, - TDEFL_RLE_MATCHES = 0x10000, - TDEFL_FILTER_MATCHES = 0x20000, - TDEFL_FORCE_ALL_STATIC_BLOCKS = 0x40000, - TDEFL_FORCE_ALL_RAW_BLOCKS = 0x80000 -}; - -// High level compression functions: -// tdefl_compress_mem_to_heap() compresses a block in memory to a heap block -// allocated via malloc(). -// On entry: -// pSrc_buf, src_buf_len: Pointer and size of source block to compress. -// flags: The max match finder probes (default is 128) logically OR'd against -// the above flags. Higher probes are slower but improve compression. -// On return: -// Function returns a pointer to the compressed data, or NULL on failure. -// *pOut_len will be set to the compressed data's size, which could be larger -// than src_buf_len on uncompressible data. -// The caller must free() the returned block when it's no longer needed. -void *tdefl_compress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, - size_t *pOut_len, int flags); - -// tdefl_compress_mem_to_mem() compresses a block in memory to another block in -// memory. -// Returns 0 on failure. -size_t tdefl_compress_mem_to_mem(void *pOut_buf, size_t out_buf_len, - const void *pSrc_buf, size_t src_buf_len, - int flags); - -// Compresses an image to a compressed PNG file in memory. -// On entry: -// pImage, w, h, and num_chans describe the image to compress. num_chans may be -// 1, 2, 3, or 4. -// The image pitch in bytes per scanline will be w*num_chans. The leftmost -// pixel on the top scanline is stored first in memory. -// level may range from [0,10], use MZ_NO_COMPRESSION, MZ_BEST_SPEED, -// MZ_BEST_COMPRESSION, etc. or a decent default is MZ_DEFAULT_LEVEL -// If flip is true, the image will be flipped on the Y axis (useful for OpenGL -// apps). -// On return: -// Function returns a pointer to the compressed data, or NULL on failure. -// *pLen_out will be set to the size of the PNG image file. -// The caller must mz_free() the returned heap block (which will typically be -// larger than *pLen_out) when it's no longer needed. -void *tdefl_write_image_to_png_file_in_memory_ex(const void *pImage, int w, - int h, int num_chans, - size_t *pLen_out, - mz_uint level, mz_bool flip); -void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, - int num_chans, size_t *pLen_out); - -// Output stream interface. The compressor uses this interface to write -// compressed data. It'll typically be called TDEFL_OUT_BUF_SIZE at a time. -typedef mz_bool (*tdefl_put_buf_func_ptr)(const void *pBuf, int len, - void *pUser); - -// tdefl_compress_mem_to_output() compresses a block to an output stream. The -// above helpers use this function internally. -mz_bool tdefl_compress_mem_to_output(const void *pBuf, size_t buf_len, - tdefl_put_buf_func_ptr pPut_buf_func, - void *pPut_buf_user, int flags); - -enum { - TDEFL_MAX_HUFF_TABLES = 3, - TDEFL_MAX_HUFF_SYMBOLS_0 = 288, - TDEFL_MAX_HUFF_SYMBOLS_1 = 32, - TDEFL_MAX_HUFF_SYMBOLS_2 = 19, - TDEFL_LZ_DICT_SIZE = 32768, - TDEFL_LZ_DICT_SIZE_MASK = TDEFL_LZ_DICT_SIZE - 1, - TDEFL_MIN_MATCH_LEN = 3, - TDEFL_MAX_MATCH_LEN = 258 -}; - -// TDEFL_OUT_BUF_SIZE MUST be large enough to hold a single entire compressed -// output block (using static/fixed Huffman codes). -#if TDEFL_LESS_MEMORY -enum { - TDEFL_LZ_CODE_BUF_SIZE = 24 * 1024, - TDEFL_OUT_BUF_SIZE = (TDEFL_LZ_CODE_BUF_SIZE * 13) / 10, - TDEFL_MAX_HUFF_SYMBOLS = 288, - TDEFL_LZ_HASH_BITS = 12, - TDEFL_LEVEL1_HASH_SIZE_MASK = 4095, - TDEFL_LZ_HASH_SHIFT = (TDEFL_LZ_HASH_BITS + 2) / 3, - TDEFL_LZ_HASH_SIZE = 1 << TDEFL_LZ_HASH_BITS -}; -#else -enum { - TDEFL_LZ_CODE_BUF_SIZE = 64 * 1024, - TDEFL_OUT_BUF_SIZE = (TDEFL_LZ_CODE_BUF_SIZE * 13) / 10, - TDEFL_MAX_HUFF_SYMBOLS = 288, - TDEFL_LZ_HASH_BITS = 15, - TDEFL_LEVEL1_HASH_SIZE_MASK = 4095, - TDEFL_LZ_HASH_SHIFT = (TDEFL_LZ_HASH_BITS + 2) / 3, - TDEFL_LZ_HASH_SIZE = 1 << TDEFL_LZ_HASH_BITS -}; -#endif - -// The low-level tdefl functions below may be used directly if the above helper -// functions aren't flexible enough. The low-level functions don't make any heap -// allocations, unlike the above helper functions. -typedef enum { - TDEFL_STATUS_BAD_PARAM = -2, - TDEFL_STATUS_PUT_BUF_FAILED = -1, - TDEFL_STATUS_OKAY = 0, - TDEFL_STATUS_DONE = 1 -} tdefl_status; - -// Must map to MZ_NO_FLUSH, MZ_SYNC_FLUSH, etc. enums -typedef enum { - TDEFL_NO_FLUSH = 0, - TDEFL_SYNC_FLUSH = 2, - TDEFL_FULL_FLUSH = 3, - TDEFL_FINISH = 4 -} tdefl_flush; - -// tdefl's compression state structure. -typedef struct { - tdefl_put_buf_func_ptr m_pPut_buf_func; - void *m_pPut_buf_user; - mz_uint m_flags, m_max_probes[2]; - int m_greedy_parsing; - mz_uint m_adler32, m_lookahead_pos, m_lookahead_size, m_dict_size; - mz_uint8 *m_pLZ_code_buf, *m_pLZ_flags, *m_pOutput_buf, *m_pOutput_buf_end; - mz_uint m_num_flags_left, m_total_lz_bytes, m_lz_code_buf_dict_pos, m_bits_in, - m_bit_buffer; - mz_uint m_saved_match_dist, m_saved_match_len, m_saved_lit, - m_output_flush_ofs, m_output_flush_remaining, m_finished, m_block_index, - m_wants_to_finish; - tdefl_status m_prev_return_status; - const void *m_pIn_buf; - void *m_pOut_buf; - size_t *m_pIn_buf_size, *m_pOut_buf_size; - tdefl_flush m_flush; - const mz_uint8 *m_pSrc; - size_t m_src_buf_left, m_out_buf_ofs; - mz_uint8 m_dict[TDEFL_LZ_DICT_SIZE + TDEFL_MAX_MATCH_LEN - 1]; - mz_uint16 m_huff_count[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS]; - mz_uint16 m_huff_codes[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS]; - mz_uint8 m_huff_code_sizes[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS]; - mz_uint8 m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE]; - mz_uint16 m_next[TDEFL_LZ_DICT_SIZE]; - mz_uint16 m_hash[TDEFL_LZ_HASH_SIZE]; - mz_uint8 m_output_buf[TDEFL_OUT_BUF_SIZE]; -} tdefl_compressor; - -// Initializes the compressor. -// There is no corresponding deinit() function because the tdefl API's do not -// dynamically allocate memory. -// pBut_buf_func: If NULL, output data will be supplied to the specified -// callback. In this case, the user should call the tdefl_compress_buffer() API -// for compression. -// If pBut_buf_func is NULL the user should always call the tdefl_compress() -// API. -// flags: See the above enums (TDEFL_HUFFMAN_ONLY, TDEFL_WRITE_ZLIB_HEADER, -// etc.) -tdefl_status tdefl_init(tdefl_compressor *d, - tdefl_put_buf_func_ptr pPut_buf_func, - void *pPut_buf_user, int flags); - -// Compresses a block of data, consuming as much of the specified input buffer -// as possible, and writing as much compressed data to the specified output -// buffer as possible. -tdefl_status tdefl_compress(tdefl_compressor *d, const void *pIn_buf, - size_t *pIn_buf_size, void *pOut_buf, - size_t *pOut_buf_size, tdefl_flush flush); - -// tdefl_compress_buffer() is only usable when the tdefl_init() is called with a -// non-NULL tdefl_put_buf_func_ptr. -// tdefl_compress_buffer() always consumes the entire input buffer. -tdefl_status tdefl_compress_buffer(tdefl_compressor *d, const void *pIn_buf, - size_t in_buf_size, tdefl_flush flush); - -tdefl_status tdefl_get_prev_return_status(tdefl_compressor *d); -mz_uint32 tdefl_get_adler32(tdefl_compressor *d); - -// Can't use tdefl_create_comp_flags_from_zip_params if MINIZ_NO_ZLIB_APIS isn't -// defined, because it uses some of its macros. -#ifndef MINIZ_NO_ZLIB_APIS -// Create tdefl_compress() flags given zlib-style compression parameters. -// level may range from [0,10] (where 10 is absolute max compression, but may be -// much slower on some files) -// window_bits may be -15 (raw deflate) or 15 (zlib) -// strategy may be either MZ_DEFAULT_STRATEGY, MZ_FILTERED, MZ_HUFFMAN_ONLY, -// MZ_RLE, or MZ_FIXED -mz_uint tdefl_create_comp_flags_from_zip_params(int level, int window_bits, - int strategy); -#endif // #ifndef MINIZ_NO_ZLIB_APIS - -#ifdef __cplusplus -} -#endif - -#endif // MINIZ_HEADER_INCLUDED - -// ------------------- End of Header: Implementation follows. (If you only want -// the header, define MINIZ_HEADER_FILE_ONLY.) - -#ifndef MINIZ_HEADER_FILE_ONLY - -typedef unsigned char mz_validate_uint16[sizeof(mz_uint16) == 2 ? 1 : -1]; -typedef unsigned char mz_validate_uint32[sizeof(mz_uint32) == 4 ? 1 : -1]; -typedef unsigned char mz_validate_uint64[sizeof(mz_uint64) == 8 ? 1 : -1]; - -//#include <assert.h> -//#include <string.h> - -#define MZ_ASSERT(x) assert(x) - -#ifdef MINIZ_NO_MALLOC -#define MZ_MALLOC(x) NULL -#define MZ_FREE(x) (void)x, ((void)0) -#define MZ_REALLOC(p, x) NULL -#else -#define MZ_MALLOC(x) malloc(x) -#define MZ_FREE(x) free(x) -#define MZ_REALLOC(p, x) realloc(p, x) -#endif - -#define MZ_MAX(a, b) (((a) > (b)) ? (a) : (b)) -#define MZ_MIN(a, b) (((a) < (b)) ? (a) : (b)) -#define MZ_CLEAR_OBJ(obj) memset(&(obj), 0, sizeof(obj)) - -#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN -#define MZ_READ_LE16(p) *((const mz_uint16 *)(p)) -#define MZ_READ_LE32(p) *((const mz_uint32 *)(p)) -#else -#define MZ_READ_LE16(p) \ - ((mz_uint32)(((const mz_uint8 *)(p))[0]) | \ - ((mz_uint32)(((const mz_uint8 *)(p))[1]) << 8U)) -#define MZ_READ_LE32(p) \ - ((mz_uint32)(((const mz_uint8 *)(p))[0]) | \ - ((mz_uint32)(((const mz_uint8 *)(p))[1]) << 8U) | \ - ((mz_uint32)(((const mz_uint8 *)(p))[2]) << 16U) | \ - ((mz_uint32)(((const mz_uint8 *)(p))[3]) << 24U)) -#endif - -#ifdef _MSC_VER -#define MZ_FORCEINLINE __forceinline -#elif defined(__GNUC__) -#define MZ_FORCEINLINE inline __attribute__((__always_inline__)) -#else -#define MZ_FORCEINLINE inline -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -// ------------------- zlib-style API's - -mz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len) { - mz_uint32 i, s1 = (mz_uint32)(adler & 0xffff), s2 = (mz_uint32)(adler >> 16); - size_t block_len = buf_len % 5552; - if (!ptr) return MZ_ADLER32_INIT; - while (buf_len) { - for (i = 0; i + 7 < block_len; i += 8, ptr += 8) { - s1 += ptr[0], s2 += s1; - s1 += ptr[1], s2 += s1; - s1 += ptr[2], s2 += s1; - s1 += ptr[3], s2 += s1; - s1 += ptr[4], s2 += s1; - s1 += ptr[5], s2 += s1; - s1 += ptr[6], s2 += s1; - s1 += ptr[7], s2 += s1; - } - for (; i < block_len; ++i) s1 += *ptr++, s2 += s1; - s1 %= 65521U, s2 %= 65521U; - buf_len -= block_len; - block_len = 5552; - } - return (s2 << 16) + s1; -} - -// Karl Malbrain's compact CRC-32. See "A compact CCITT crc16 and crc32 C -// implementation that balances processor cache usage against speed": -// http://www.geocities.com/malbrain/ -mz_ulong mz_crc32(mz_ulong crc, const mz_uint8 *ptr, size_t buf_len) { - static const mz_uint32 s_crc32[16] = { - 0, 0x1db71064, 0x3b6e20c8, 0x26d930ac, 0x76dc4190, 0x6b6b51f4, - 0x4db26158, 0x5005713c, 0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c, - 0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c}; - mz_uint32 crcu32 = (mz_uint32)crc; - if (!ptr) return MZ_CRC32_INIT; - crcu32 = ~crcu32; - while (buf_len--) { - mz_uint8 b = *ptr++; - crcu32 = (crcu32 >> 4) ^ s_crc32[(crcu32 & 0xF) ^ (b & 0xF)]; - crcu32 = (crcu32 >> 4) ^ s_crc32[(crcu32 & 0xF) ^ (b >> 4)]; - } - return ~crcu32; -} - -void mz_free(void *p) { MZ_FREE(p); } - -#ifndef MINIZ_NO_ZLIB_APIS - -static void *def_alloc_func(void *opaque, size_t items, size_t size) { - (void)opaque, (void)items, (void)size; - return MZ_MALLOC(items * size); -} -static void def_free_func(void *opaque, void *address) { - (void)opaque, (void)address; - MZ_FREE(address); -} -// static void *def_realloc_func(void *opaque, void *address, size_t items, -// size_t size) { -// (void)opaque, (void)address, (void)items, (void)size; -// return MZ_REALLOC(address, items * size); -//} - -const char *mz_version(void) { return MZ_VERSION; } - -int mz_deflateInit(mz_streamp pStream, int level) { - return mz_deflateInit2(pStream, level, MZ_DEFLATED, MZ_DEFAULT_WINDOW_BITS, 9, - MZ_DEFAULT_STRATEGY); -} - -int mz_deflateInit2(mz_streamp pStream, int level, int method, int window_bits, - int mem_level, int strategy) { - tdefl_compressor *pComp; - mz_uint comp_flags = - TDEFL_COMPUTE_ADLER32 | - tdefl_create_comp_flags_from_zip_params(level, window_bits, strategy); - - if (!pStream) return MZ_STREAM_ERROR; - if ((method != MZ_DEFLATED) || ((mem_level < 1) || (mem_level > 9)) || - ((window_bits != MZ_DEFAULT_WINDOW_BITS) && - (-window_bits != MZ_DEFAULT_WINDOW_BITS))) - return MZ_PARAM_ERROR; - - pStream->data_type = 0; - pStream->adler = MZ_ADLER32_INIT; - pStream->msg = NULL; - pStream->reserved = 0; - pStream->total_in = 0; - pStream->total_out = 0; - if (!pStream->zalloc) pStream->zalloc = def_alloc_func; - if (!pStream->zfree) pStream->zfree = def_free_func; - - pComp = (tdefl_compressor *)pStream->zalloc(pStream->opaque, 1, - sizeof(tdefl_compressor)); - if (!pComp) return MZ_MEM_ERROR; - - pStream->state = (struct mz_internal_state *)pComp; - - if (tdefl_init(pComp, NULL, NULL, comp_flags) != TDEFL_STATUS_OKAY) { - mz_deflateEnd(pStream); - return MZ_PARAM_ERROR; - } - - return MZ_OK; -} - -int mz_deflateReset(mz_streamp pStream) { - if ((!pStream) || (!pStream->state) || (!pStream->zalloc) || - (!pStream->zfree)) - return MZ_STREAM_ERROR; - pStream->total_in = pStream->total_out = 0; - tdefl_init((tdefl_compressor *)pStream->state, NULL, NULL, - ((tdefl_compressor *)pStream->state)->m_flags); - return MZ_OK; -} - -int mz_deflate(mz_streamp pStream, int flush) { - size_t in_bytes, out_bytes; - mz_ulong orig_total_in, orig_total_out; - int mz_status = MZ_OK; - - if ((!pStream) || (!pStream->state) || (flush < 0) || (flush > MZ_FINISH) || - (!pStream->next_out)) - return MZ_STREAM_ERROR; - if (!pStream->avail_out) return MZ_BUF_ERROR; - - if (flush == MZ_PARTIAL_FLUSH) flush = MZ_SYNC_FLUSH; - - if (((tdefl_compressor *)pStream->state)->m_prev_return_status == - TDEFL_STATUS_DONE) - return (flush == MZ_FINISH) ? MZ_STREAM_END : MZ_BUF_ERROR; - - orig_total_in = pStream->total_in; - orig_total_out = pStream->total_out; - for (;;) { - tdefl_status defl_status; - in_bytes = pStream->avail_in; - out_bytes = pStream->avail_out; - - defl_status = tdefl_compress((tdefl_compressor *)pStream->state, - pStream->next_in, &in_bytes, pStream->next_out, - &out_bytes, (tdefl_flush)flush); - pStream->next_in += (mz_uint)in_bytes; - pStream->avail_in -= (mz_uint)in_bytes; - pStream->total_in += (mz_uint)in_bytes; - pStream->adler = tdefl_get_adler32((tdefl_compressor *)pStream->state); - - pStream->next_out += (mz_uint)out_bytes; - pStream->avail_out -= (mz_uint)out_bytes; - pStream->total_out += (mz_uint)out_bytes; - - if (defl_status < 0) { - mz_status = MZ_STREAM_ERROR; - break; - } else if (defl_status == TDEFL_STATUS_DONE) { - mz_status = MZ_STREAM_END; - break; - } else if (!pStream->avail_out) - break; - else if ((!pStream->avail_in) && (flush != MZ_FINISH)) { - if ((flush) || (pStream->total_in != orig_total_in) || - (pStream->total_out != orig_total_out)) - break; - return MZ_BUF_ERROR; // Can't make forward progress without some input. - } - } - return mz_status; -} - -int mz_deflateEnd(mz_streamp pStream) { - if (!pStream) return MZ_STREAM_ERROR; - if (pStream->state) { - pStream->zfree(pStream->opaque, pStream->state); - pStream->state = NULL; - } - return MZ_OK; -} - -mz_ulong mz_deflateBound(mz_streamp pStream, mz_ulong source_len) { - (void)pStream; - // This is really over conservative. (And lame, but it's actually pretty - // tricky to compute a true upper bound given the way tdefl's blocking works.) - return MZ_MAX(128 + (source_len * 110) / 100, - 128 + source_len + ((source_len / (31 * 1024)) + 1) * 5); -} - -int mz_compress2(unsigned char *pDest, mz_ulong *pDest_len, - const unsigned char *pSource, mz_ulong source_len, int level) { - int status; - mz_stream stream; - memset(&stream, 0, sizeof(stream)); - - // In case mz_ulong is 64-bits (argh I hate longs). - if ((source_len | *pDest_len) > 0xFFFFFFFFU) return MZ_PARAM_ERROR; - - stream.next_in = pSource; - stream.avail_in = (mz_uint32)source_len; - stream.next_out = pDest; - stream.avail_out = (mz_uint32)*pDest_len; - - status = mz_deflateInit(&stream, level); - if (status != MZ_OK) return status; - - status = mz_deflate(&stream, MZ_FINISH); - if (status != MZ_STREAM_END) { - mz_deflateEnd(&stream); - return (status == MZ_OK) ? MZ_BUF_ERROR : status; - } - - *pDest_len = stream.total_out; - return mz_deflateEnd(&stream); -} - -int mz_compress(unsigned char *pDest, mz_ulong *pDest_len, - const unsigned char *pSource, mz_ulong source_len) { - return mz_compress2(pDest, pDest_len, pSource, source_len, - MZ_DEFAULT_COMPRESSION); -} - -mz_ulong mz_compressBound(mz_ulong source_len) { - return mz_deflateBound(NULL, source_len); -} - -typedef struct { - tinfl_decompressor m_decomp; - mz_uint m_dict_ofs, m_dict_avail, m_first_call, m_has_flushed; - int m_window_bits; - mz_uint8 m_dict[TINFL_LZ_DICT_SIZE]; - tinfl_status m_last_status; -} inflate_state; - -int mz_inflateInit2(mz_streamp pStream, int window_bits) { - inflate_state *pDecomp; - if (!pStream) return MZ_STREAM_ERROR; - if ((window_bits != MZ_DEFAULT_WINDOW_BITS) && - (-window_bits != MZ_DEFAULT_WINDOW_BITS)) - return MZ_PARAM_ERROR; - - pStream->data_type = 0; - pStream->adler = 0; - pStream->msg = NULL; - pStream->total_in = 0; - pStream->total_out = 0; - pStream->reserved = 0; - if (!pStream->zalloc) pStream->zalloc = def_alloc_func; - if (!pStream->zfree) pStream->zfree = def_free_func; - - pDecomp = (inflate_state *)pStream->zalloc(pStream->opaque, 1, - sizeof(inflate_state)); - if (!pDecomp) return MZ_MEM_ERROR; - - pStream->state = (struct mz_internal_state *)pDecomp; - - tinfl_init(&pDecomp->m_decomp); - pDecomp->m_dict_ofs = 0; - pDecomp->m_dict_avail = 0; - pDecomp->m_last_status = TINFL_STATUS_NEEDS_MORE_INPUT; - pDecomp->m_first_call = 1; - pDecomp->m_has_flushed = 0; - pDecomp->m_window_bits = window_bits; - - return MZ_OK; -} - -int mz_inflateInit(mz_streamp pStream) { - return mz_inflateInit2(pStream, MZ_DEFAULT_WINDOW_BITS); -} - -int mz_inflate(mz_streamp pStream, int flush) { - inflate_state *pState; - mz_uint n, first_call, decomp_flags = TINFL_FLAG_COMPUTE_ADLER32; - size_t in_bytes, out_bytes, orig_avail_in; - tinfl_status status; - - if ((!pStream) || (!pStream->state)) return MZ_STREAM_ERROR; - if (flush == MZ_PARTIAL_FLUSH) flush = MZ_SYNC_FLUSH; - if ((flush) && (flush != MZ_SYNC_FLUSH) && (flush != MZ_FINISH)) - return MZ_STREAM_ERROR; - - pState = (inflate_state *)pStream->state; - if (pState->m_window_bits > 0) decomp_flags |= TINFL_FLAG_PARSE_ZLIB_HEADER; - orig_avail_in = pStream->avail_in; - - first_call = pState->m_first_call; - pState->m_first_call = 0; - if (pState->m_last_status < 0) return MZ_DATA_ERROR; - - if (pState->m_has_flushed && (flush != MZ_FINISH)) return MZ_STREAM_ERROR; - pState->m_has_flushed |= (flush == MZ_FINISH); - - if ((flush == MZ_FINISH) && (first_call)) { - // MZ_FINISH on the first call implies that the input and output buffers are - // large enough to hold the entire compressed/decompressed file. - decomp_flags |= TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF; - in_bytes = pStream->avail_in; - out_bytes = pStream->avail_out; - status = tinfl_decompress(&pState->m_decomp, pStream->next_in, &in_bytes, - pStream->next_out, pStream->next_out, &out_bytes, - decomp_flags); - pState->m_last_status = status; - pStream->next_in += (mz_uint)in_bytes; - pStream->avail_in -= (mz_uint)in_bytes; - pStream->total_in += (mz_uint)in_bytes; - pStream->adler = tinfl_get_adler32(&pState->m_decomp); - pStream->next_out += (mz_uint)out_bytes; - pStream->avail_out -= (mz_uint)out_bytes; - pStream->total_out += (mz_uint)out_bytes; - - if (status < 0) - return MZ_DATA_ERROR; - else if (status != TINFL_STATUS_DONE) { - pState->m_last_status = TINFL_STATUS_FAILED; - return MZ_BUF_ERROR; - } - return MZ_STREAM_END; - } - // flush != MZ_FINISH then we must assume there's more input. - if (flush != MZ_FINISH) decomp_flags |= TINFL_FLAG_HAS_MORE_INPUT; - - if (pState->m_dict_avail) { - n = MZ_MIN(pState->m_dict_avail, pStream->avail_out); - memcpy(pStream->next_out, pState->m_dict + pState->m_dict_ofs, n); - pStream->next_out += n; - pStream->avail_out -= n; - pStream->total_out += n; - pState->m_dict_avail -= n; - pState->m_dict_ofs = (pState->m_dict_ofs + n) & (TINFL_LZ_DICT_SIZE - 1); - return ((pState->m_last_status == TINFL_STATUS_DONE) && - (!pState->m_dict_avail)) - ? MZ_STREAM_END - : MZ_OK; - } - - for (;;) { - in_bytes = pStream->avail_in; - out_bytes = TINFL_LZ_DICT_SIZE - pState->m_dict_ofs; - - status = tinfl_decompress( - &pState->m_decomp, pStream->next_in, &in_bytes, pState->m_dict, - pState->m_dict + pState->m_dict_ofs, &out_bytes, decomp_flags); - pState->m_last_status = status; - - pStream->next_in += (mz_uint)in_bytes; - pStream->avail_in -= (mz_uint)in_bytes; - pStream->total_in += (mz_uint)in_bytes; - pStream->adler = tinfl_get_adler32(&pState->m_decomp); - - pState->m_dict_avail = (mz_uint)out_bytes; - - n = MZ_MIN(pState->m_dict_avail, pStream->avail_out); - memcpy(pStream->next_out, pState->m_dict + pState->m_dict_ofs, n); - pStream->next_out += n; - pStream->avail_out -= n; - pStream->total_out += n; - pState->m_dict_avail -= n; - pState->m_dict_ofs = (pState->m_dict_ofs + n) & (TINFL_LZ_DICT_SIZE - 1); - - if (status < 0) - return MZ_DATA_ERROR; // Stream is corrupted (there could be some - // uncompressed data left in the output dictionary - - // oh well). - else if ((status == TINFL_STATUS_NEEDS_MORE_INPUT) && (!orig_avail_in)) - return MZ_BUF_ERROR; // Signal caller that we can't make forward progress - // without supplying more input or by setting flush - // to MZ_FINISH. - else if (flush == MZ_FINISH) { - // The output buffer MUST be large to hold the remaining uncompressed data - // when flush==MZ_FINISH. - if (status == TINFL_STATUS_DONE) - return pState->m_dict_avail ? MZ_BUF_ERROR : MZ_STREAM_END; - // status here must be TINFL_STATUS_HAS_MORE_OUTPUT, which means there's - // at least 1 more byte on the way. If there's no more room left in the - // output buffer then something is wrong. - else if (!pStream->avail_out) - return MZ_BUF_ERROR; - } else if ((status == TINFL_STATUS_DONE) || (!pStream->avail_in) || - (!pStream->avail_out) || (pState->m_dict_avail)) - break; - } - - return ((status == TINFL_STATUS_DONE) && (!pState->m_dict_avail)) - ? MZ_STREAM_END - : MZ_OK; -} - -int mz_inflateEnd(mz_streamp pStream) { - if (!pStream) return MZ_STREAM_ERROR; - if (pStream->state) { - pStream->zfree(pStream->opaque, pStream->state); - pStream->state = NULL; - } - return MZ_OK; -} - -int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, - const unsigned char *pSource, mz_ulong source_len) { - mz_stream stream; - int status; - memset(&stream, 0, sizeof(stream)); - - // In case mz_ulong is 64-bits (argh I hate longs). - if ((source_len | *pDest_len) > 0xFFFFFFFFU) return MZ_PARAM_ERROR; - - stream.next_in = pSource; - stream.avail_in = (mz_uint32)source_len; - stream.next_out = pDest; - stream.avail_out = (mz_uint32)*pDest_len; - - status = mz_inflateInit(&stream); - if (status != MZ_OK) return status; - - status = mz_inflate(&stream, MZ_FINISH); - if (status != MZ_STREAM_END) { - mz_inflateEnd(&stream); - return ((status == MZ_BUF_ERROR) && (!stream.avail_in)) ? MZ_DATA_ERROR - : status; - } - *pDest_len = stream.total_out; - - return mz_inflateEnd(&stream); -} - -const char *mz_error(int err) { - static struct { - int m_err; - const char *m_pDesc; - } s_error_descs[] = {{MZ_OK, ""}, - {MZ_STREAM_END, "stream end"}, - {MZ_NEED_DICT, "need dictionary"}, - {MZ_ERRNO, "file error"}, - {MZ_STREAM_ERROR, "stream error"}, - {MZ_DATA_ERROR, "data error"}, - {MZ_MEM_ERROR, "out of memory"}, - {MZ_BUF_ERROR, "buf error"}, - {MZ_VERSION_ERROR, "version error"}, - {MZ_PARAM_ERROR, "parameter error"}}; - mz_uint i; - for (i = 0; i < sizeof(s_error_descs) / sizeof(s_error_descs[0]); ++i) - if (s_error_descs[i].m_err == err) return s_error_descs[i].m_pDesc; - return NULL; -} - -#endif // MINIZ_NO_ZLIB_APIS - -// ------------------- Low-level Decompression (completely independent from all -// compression API's) - -#define TINFL_MEMCPY(d, s, l) memcpy(d, s, l) -#define TINFL_MEMSET(p, c, l) memset(p, c, l) - -#define TINFL_CR_BEGIN \ - switch (r->m_state) { \ - case 0: -#define TINFL_CR_RETURN(state_index, result) \ - do { \ - status = result; \ - r->m_state = state_index; \ - goto common_exit; \ - case state_index:; \ - } \ - MZ_MACRO_END -#define TINFL_CR_RETURN_FOREVER(state_index, result) \ - do { \ - for (;;) { \ - TINFL_CR_RETURN(state_index, result); \ - } \ - } \ - MZ_MACRO_END -#define TINFL_CR_FINISH } - -// TODO: If the caller has indicated that there's no more input, and we attempt -// to read beyond the input buf, then something is wrong with the input because -// the inflator never -// reads ahead more than it needs to. Currently TINFL_GET_BYTE() pads the end of -// the stream with 0's in this scenario. -#define TINFL_GET_BYTE(state_index, c) \ - do { \ - if (pIn_buf_cur >= pIn_buf_end) { \ - for (;;) { \ - if (decomp_flags & TINFL_FLAG_HAS_MORE_INPUT) { \ - TINFL_CR_RETURN(state_index, TINFL_STATUS_NEEDS_MORE_INPUT); \ - if (pIn_buf_cur < pIn_buf_end) { \ - c = *pIn_buf_cur++; \ - break; \ - } \ - } else { \ - c = 0; \ - break; \ - } \ - } \ - } else \ - c = *pIn_buf_cur++; \ - } \ - MZ_MACRO_END - -#define TINFL_NEED_BITS(state_index, n) \ - do { \ - mz_uint c; \ - TINFL_GET_BYTE(state_index, c); \ - bit_buf |= (((tinfl_bit_buf_t)c) << num_bits); \ - num_bits += 8; \ - } while (num_bits < (mz_uint)(n)) -#define TINFL_SKIP_BITS(state_index, n) \ - do { \ - if (num_bits < (mz_uint)(n)) { \ - TINFL_NEED_BITS(state_index, n); \ - } \ - bit_buf >>= (n); \ - num_bits -= (n); \ - } \ - MZ_MACRO_END -#define TINFL_GET_BITS(state_index, b, n) \ - do { \ - if (num_bits < (mz_uint)(n)) { \ - TINFL_NEED_BITS(state_index, n); \ - } \ - b = bit_buf & ((1 << (n)) - 1); \ - bit_buf >>= (n); \ - num_bits -= (n); \ - } \ - MZ_MACRO_END - -// TINFL_HUFF_BITBUF_FILL() is only used rarely, when the number of bytes -// remaining in the input buffer falls below 2. -// It reads just enough bytes from the input stream that are needed to decode -// the next Huffman code (and absolutely no more). It works by trying to fully -// decode a -// Huffman code by using whatever bits are currently present in the bit buffer. -// If this fails, it reads another byte, and tries again until it succeeds or -// until the -// bit buffer contains >=15 bits (deflate's max. Huffman code size). -#define TINFL_HUFF_BITBUF_FILL(state_index, pHuff) \ - do { \ - temp = (pHuff)->m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]; \ - if (temp >= 0) { \ - code_len = temp >> 9; \ - if ((code_len) && (num_bits >= code_len)) break; \ - } else if (num_bits > TINFL_FAST_LOOKUP_BITS) { \ - code_len = TINFL_FAST_LOOKUP_BITS; \ - do { \ - temp = (pHuff)->m_tree[~temp + ((bit_buf >> code_len++) & 1)]; \ - } while ((temp < 0) && (num_bits >= (code_len + 1))); \ - if (temp >= 0) break; \ - } \ - TINFL_GET_BYTE(state_index, c); \ - bit_buf |= (((tinfl_bit_buf_t)c) << num_bits); \ - num_bits += 8; \ - } while (num_bits < 15); - -// TINFL_HUFF_DECODE() decodes the next Huffman coded symbol. It's more complex -// than you would initially expect because the zlib API expects the decompressor -// to never read -// beyond the final byte of the deflate stream. (In other words, when this macro -// wants to read another byte from the input, it REALLY needs another byte in -// order to fully -// decode the next Huffman code.) Handling this properly is particularly -// important on raw deflate (non-zlib) streams, which aren't followed by a byte -// aligned adler-32. -// The slow path is only executed at the very end of the input buffer. -#define TINFL_HUFF_DECODE(state_index, sym, pHuff) \ - do { \ - int temp; \ - mz_uint code_len, c; \ - if (num_bits < 15) { \ - if ((pIn_buf_end - pIn_buf_cur) < 2) { \ - TINFL_HUFF_BITBUF_FILL(state_index, pHuff); \ - } else { \ - bit_buf |= (((tinfl_bit_buf_t)pIn_buf_cur[0]) << num_bits) | \ - (((tinfl_bit_buf_t)pIn_buf_cur[1]) << (num_bits + 8)); \ - pIn_buf_cur += 2; \ - num_bits += 16; \ - } \ - } \ - if ((temp = (pHuff)->m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]) >= \ - 0) \ - code_len = temp >> 9, temp &= 511; \ - else { \ - code_len = TINFL_FAST_LOOKUP_BITS; \ - do { \ - temp = (pHuff)->m_tree[~temp + ((bit_buf >> code_len++) & 1)]; \ - } while (temp < 0); \ - } \ - sym = temp; \ - bit_buf >>= code_len; \ - num_bits -= code_len; \ - } \ - MZ_MACRO_END - -tinfl_status tinfl_decompress(tinfl_decompressor *r, - const mz_uint8 *pIn_buf_next, - size_t *pIn_buf_size, mz_uint8 *pOut_buf_start, - mz_uint8 *pOut_buf_next, size_t *pOut_buf_size, - const mz_uint32 decomp_flags) { - static const int s_length_base[31] = { - 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, - 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; - static const int s_length_extra[31] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, - 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, - 4, 4, 5, 5, 5, 5, 0, 0, 0}; - static const int s_dist_base[32] = { - 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, - 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, - 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577, 0, 0}; - static const int s_dist_extra[32] = {0, 0, 0, 0, 1, 1, 2, 2, 3, 3, - 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, - 9, 9, 10, 10, 11, 11, 12, 12, 13, 13}; - static const mz_uint8 s_length_dezigzag[19] = { - 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; - static const int s_min_table_sizes[3] = {257, 1, 4}; - - tinfl_status status = TINFL_STATUS_FAILED; - mz_uint32 num_bits, dist, counter, num_extra; - tinfl_bit_buf_t bit_buf; - const mz_uint8 *pIn_buf_cur = pIn_buf_next, *const pIn_buf_end = - pIn_buf_next + *pIn_buf_size; - mz_uint8 *pOut_buf_cur = pOut_buf_next, *const pOut_buf_end = - pOut_buf_next + *pOut_buf_size; - size_t out_buf_size_mask = - (decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF) - ? (size_t)-1 - : ((pOut_buf_next - pOut_buf_start) + *pOut_buf_size) - 1, - dist_from_out_buf_start; - - // Ensure the output buffer's size is a power of 2, unless the output buffer - // is large enough to hold the entire output file (in which case it doesn't - // matter). - if (((out_buf_size_mask + 1) & out_buf_size_mask) || - (pOut_buf_next < pOut_buf_start)) { - *pIn_buf_size = *pOut_buf_size = 0; - return TINFL_STATUS_BAD_PARAM; - } - - num_bits = r->m_num_bits; - bit_buf = r->m_bit_buf; - dist = r->m_dist; - counter = r->m_counter; - num_extra = r->m_num_extra; - dist_from_out_buf_start = r->m_dist_from_out_buf_start; - TINFL_CR_BEGIN - - bit_buf = num_bits = dist = counter = num_extra = r->m_zhdr0 = r->m_zhdr1 = 0; - r->m_z_adler32 = r->m_check_adler32 = 1; - if (decomp_flags & TINFL_FLAG_PARSE_ZLIB_HEADER) { - TINFL_GET_BYTE(1, r->m_zhdr0); - TINFL_GET_BYTE(2, r->m_zhdr1); - counter = (((r->m_zhdr0 * 256 + r->m_zhdr1) % 31 != 0) || - (r->m_zhdr1 & 32) || ((r->m_zhdr0 & 15) != 8)); - if (!(decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF)) - counter |= (((1U << (8U + (r->m_zhdr0 >> 4))) > 32768U) || - ((out_buf_size_mask + 1) < - (size_t)(1ULL << (8U + (r->m_zhdr0 >> 4))))); - if (counter) { - TINFL_CR_RETURN_FOREVER(36, TINFL_STATUS_FAILED); - } - } - - do { - TINFL_GET_BITS(3, r->m_final, 3); - r->m_type = r->m_final >> 1; - if (r->m_type == 0) { - TINFL_SKIP_BITS(5, num_bits & 7); - for (counter = 0; counter < 4; ++counter) { - if (num_bits) - TINFL_GET_BITS(6, r->m_raw_header[counter], 8); - else - TINFL_GET_BYTE(7, r->m_raw_header[counter]); - } - if ((counter = (r->m_raw_header[0] | (r->m_raw_header[1] << 8))) != - (mz_uint)(0xFFFF ^ - (r->m_raw_header[2] | (r->m_raw_header[3] << 8)))) { - TINFL_CR_RETURN_FOREVER(39, TINFL_STATUS_FAILED); - } - while ((counter) && (num_bits)) { - TINFL_GET_BITS(51, dist, 8); - while (pOut_buf_cur >= pOut_buf_end) { - TINFL_CR_RETURN(52, TINFL_STATUS_HAS_MORE_OUTPUT); - } - *pOut_buf_cur++ = (mz_uint8)dist; - counter--; - } - while (counter) { - size_t n; - while (pOut_buf_cur >= pOut_buf_end) { - TINFL_CR_RETURN(9, TINFL_STATUS_HAS_MORE_OUTPUT); - } - while (pIn_buf_cur >= pIn_buf_end) { - if (decomp_flags & TINFL_FLAG_HAS_MORE_INPUT) { - TINFL_CR_RETURN(38, TINFL_STATUS_NEEDS_MORE_INPUT); - } else { - TINFL_CR_RETURN_FOREVER(40, TINFL_STATUS_FAILED); - } - } - n = MZ_MIN(MZ_MIN((size_t)(pOut_buf_end - pOut_buf_cur), - (size_t)(pIn_buf_end - pIn_buf_cur)), - counter); - TINFL_MEMCPY(pOut_buf_cur, pIn_buf_cur, n); - pIn_buf_cur += n; - pOut_buf_cur += n; - counter -= (mz_uint)n; - } - } else if (r->m_type == 3) { - TINFL_CR_RETURN_FOREVER(10, TINFL_STATUS_FAILED); - } else { - if (r->m_type == 1) { - mz_uint8 *p = r->m_tables[0].m_code_size; - mz_uint i; - r->m_table_sizes[0] = 288; - r->m_table_sizes[1] = 32; - TINFL_MEMSET(r->m_tables[1].m_code_size, 5, 32); - for (i = 0; i <= 143; ++i) *p++ = 8; - for (; i <= 255; ++i) *p++ = 9; - for (; i <= 279; ++i) *p++ = 7; - for (; i <= 287; ++i) *p++ = 8; - } else { - for (counter = 0; counter < 3; counter++) { - TINFL_GET_BITS(11, r->m_table_sizes[counter], "\05\05\04"[counter]); - r->m_table_sizes[counter] += s_min_table_sizes[counter]; - } - MZ_CLEAR_OBJ(r->m_tables[2].m_code_size); - for (counter = 0; counter < r->m_table_sizes[2]; counter++) { - mz_uint s; - TINFL_GET_BITS(14, s, 3); - r->m_tables[2].m_code_size[s_length_dezigzag[counter]] = (mz_uint8)s; - } - r->m_table_sizes[2] = 19; - } - for (; (int)r->m_type >= 0; r->m_type--) { - int tree_next, tree_cur; - tinfl_huff_table *pTable; - mz_uint i, j, used_syms, total, sym_index, next_code[17], - total_syms[16]; - pTable = &r->m_tables[r->m_type]; - MZ_CLEAR_OBJ(total_syms); - MZ_CLEAR_OBJ(pTable->m_look_up); - MZ_CLEAR_OBJ(pTable->m_tree); - for (i = 0; i < r->m_table_sizes[r->m_type]; ++i) - total_syms[pTable->m_code_size[i]]++; - used_syms = 0, total = 0; - next_code[0] = next_code[1] = 0; - for (i = 1; i <= 15; ++i) { - used_syms += total_syms[i]; - next_code[i + 1] = (total = ((total + total_syms[i]) << 1)); - } - if ((65536 != total) && (used_syms > 1)) { - TINFL_CR_RETURN_FOREVER(35, TINFL_STATUS_FAILED); - } - for (tree_next = -1, sym_index = 0; - sym_index < r->m_table_sizes[r->m_type]; ++sym_index) { - mz_uint rev_code = 0, l, cur_code, - code_size = pTable->m_code_size[sym_index]; - if (!code_size) continue; - cur_code = next_code[code_size]++; - for (l = code_size; l > 0; l--, cur_code >>= 1) - rev_code = (rev_code << 1) | (cur_code & 1); - if (code_size <= TINFL_FAST_LOOKUP_BITS) { - mz_int16 k = (mz_int16)((code_size << 9) | sym_index); - while (rev_code < TINFL_FAST_LOOKUP_SIZE) { - pTable->m_look_up[rev_code] = k; - rev_code += (1 << code_size); - } - continue; - } - if (0 == - (tree_cur = pTable->m_look_up[rev_code & - (TINFL_FAST_LOOKUP_SIZE - 1)])) { - pTable->m_look_up[rev_code & (TINFL_FAST_LOOKUP_SIZE - 1)] = - (mz_int16)tree_next; - tree_cur = tree_next; - tree_next -= 2; - } - rev_code >>= (TINFL_FAST_LOOKUP_BITS - 1); - for (j = code_size; j > (TINFL_FAST_LOOKUP_BITS + 1); j--) { - tree_cur -= ((rev_code >>= 1) & 1); - if (!pTable->m_tree[-tree_cur - 1]) { - pTable->m_tree[-tree_cur - 1] = (mz_int16)tree_next; - tree_cur = tree_next; - tree_next -= 2; - } else - tree_cur = pTable->m_tree[-tree_cur - 1]; - } - tree_cur -= ((rev_code >>= 1) & 1); - pTable->m_tree[-tree_cur - 1] = (mz_int16)sym_index; - } - if (r->m_type == 2) { - for (counter = 0; - counter < (r->m_table_sizes[0] + r->m_table_sizes[1]);) { - mz_uint s; - TINFL_HUFF_DECODE(16, dist, &r->m_tables[2]); - if (dist < 16) { - r->m_len_codes[counter++] = (mz_uint8)dist; - continue; - } - if ((dist == 16) && (!counter)) { - TINFL_CR_RETURN_FOREVER(17, TINFL_STATUS_FAILED); - } - num_extra = "\02\03\07"[dist - 16]; - TINFL_GET_BITS(18, s, num_extra); - s += "\03\03\013"[dist - 16]; - TINFL_MEMSET(r->m_len_codes + counter, - (dist == 16) ? r->m_len_codes[counter - 1] : 0, s); - counter += s; - } - if ((r->m_table_sizes[0] + r->m_table_sizes[1]) != counter) { - TINFL_CR_RETURN_FOREVER(21, TINFL_STATUS_FAILED); - } - TINFL_MEMCPY(r->m_tables[0].m_code_size, r->m_len_codes, - r->m_table_sizes[0]); - TINFL_MEMCPY(r->m_tables[1].m_code_size, - r->m_len_codes + r->m_table_sizes[0], - r->m_table_sizes[1]); - } - } - for (;;) { - mz_uint8 *pSrc; - for (;;) { - if (((pIn_buf_end - pIn_buf_cur) < 4) || - ((pOut_buf_end - pOut_buf_cur) < 2)) { - TINFL_HUFF_DECODE(23, counter, &r->m_tables[0]); - if (counter >= 256) break; - while (pOut_buf_cur >= pOut_buf_end) { - TINFL_CR_RETURN(24, TINFL_STATUS_HAS_MORE_OUTPUT); - } - *pOut_buf_cur++ = (mz_uint8)counter; - } else { - int sym2; - mz_uint code_len; -#if TINFL_USE_64BIT_BITBUF - if (num_bits < 30) { - bit_buf |= - (((tinfl_bit_buf_t)MZ_READ_LE32(pIn_buf_cur)) << num_bits); - pIn_buf_cur += 4; - num_bits += 32; - } -#else - if (num_bits < 15) { - bit_buf |= - (((tinfl_bit_buf_t)MZ_READ_LE16(pIn_buf_cur)) << num_bits); - pIn_buf_cur += 2; - num_bits += 16; - } -#endif - if ((sym2 = - r->m_tables[0] - .m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]) >= - 0) - code_len = sym2 >> 9; - else { - code_len = TINFL_FAST_LOOKUP_BITS; - do { - sym2 = r->m_tables[0] - .m_tree[~sym2 + ((bit_buf >> code_len++) & 1)]; - } while (sym2 < 0); - } - counter = sym2; - bit_buf >>= code_len; - num_bits -= code_len; - if (counter & 256) break; - -#if !TINFL_USE_64BIT_BITBUF - if (num_bits < 15) { - bit_buf |= - (((tinfl_bit_buf_t)MZ_READ_LE16(pIn_buf_cur)) << num_bits); - pIn_buf_cur += 2; - num_bits += 16; - } -#endif - if ((sym2 = - r->m_tables[0] - .m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]) >= - 0) - code_len = sym2 >> 9; - else { - code_len = TINFL_FAST_LOOKUP_BITS; - do { - sym2 = r->m_tables[0] - .m_tree[~sym2 + ((bit_buf >> code_len++) & 1)]; - } while (sym2 < 0); - } - bit_buf >>= code_len; - num_bits -= code_len; - - pOut_buf_cur[0] = (mz_uint8)counter; - if (sym2 & 256) { - pOut_buf_cur++; - counter = sym2; - break; - } - pOut_buf_cur[1] = (mz_uint8)sym2; - pOut_buf_cur += 2; - } - } - if ((counter &= 511) == 256) break; - - num_extra = s_length_extra[counter - 257]; - counter = s_length_base[counter - 257]; - if (num_extra) { - mz_uint extra_bits; - TINFL_GET_BITS(25, extra_bits, num_extra); - counter += extra_bits; - } - - TINFL_HUFF_DECODE(26, dist, &r->m_tables[1]); - num_extra = s_dist_extra[dist]; - dist = s_dist_base[dist]; - if (num_extra) { - mz_uint extra_bits; - TINFL_GET_BITS(27, extra_bits, num_extra); - dist += extra_bits; - } - - dist_from_out_buf_start = pOut_buf_cur - pOut_buf_start; - if ((dist > dist_from_out_buf_start) && - (decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF)) { - TINFL_CR_RETURN_FOREVER(37, TINFL_STATUS_FAILED); - } - - pSrc = pOut_buf_start + - ((dist_from_out_buf_start - dist) & out_buf_size_mask); - - if ((MZ_MAX(pOut_buf_cur, pSrc) + counter) > pOut_buf_end) { - while (counter--) { - while (pOut_buf_cur >= pOut_buf_end) { - TINFL_CR_RETURN(53, TINFL_STATUS_HAS_MORE_OUTPUT); - } - *pOut_buf_cur++ = - pOut_buf_start[(dist_from_out_buf_start++ - dist) & - out_buf_size_mask]; - } - continue; - } -#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES - else if ((counter >= 9) && (counter <= dist)) { - const mz_uint8 *pSrc_end = pSrc + (counter & ~7); - do { - ((mz_uint32 *)pOut_buf_cur)[0] = ((const mz_uint32 *)pSrc)[0]; - ((mz_uint32 *)pOut_buf_cur)[1] = ((const mz_uint32 *)pSrc)[1]; - pOut_buf_cur += 8; - } while ((pSrc += 8) < pSrc_end); - if ((counter &= 7) < 3) { - if (counter) { - pOut_buf_cur[0] = pSrc[0]; - if (counter > 1) pOut_buf_cur[1] = pSrc[1]; - pOut_buf_cur += counter; - } - continue; - } - } -#endif - do { - pOut_buf_cur[0] = pSrc[0]; - pOut_buf_cur[1] = pSrc[1]; - pOut_buf_cur[2] = pSrc[2]; - pOut_buf_cur += 3; - pSrc += 3; - } while ((int)(counter -= 3) > 2); - if ((int)counter > 0) { - pOut_buf_cur[0] = pSrc[0]; - if ((int)counter > 1) pOut_buf_cur[1] = pSrc[1]; - pOut_buf_cur += counter; - } - } - } - } while (!(r->m_final & 1)); - if (decomp_flags & TINFL_FLAG_PARSE_ZLIB_HEADER) { - TINFL_SKIP_BITS(32, num_bits & 7); - for (counter = 0; counter < 4; ++counter) { - mz_uint s; - if (num_bits) - TINFL_GET_BITS(41, s, 8); - else - TINFL_GET_BYTE(42, s); - r->m_z_adler32 = (r->m_z_adler32 << 8) | s; - } - } - TINFL_CR_RETURN_FOREVER(34, TINFL_STATUS_DONE); - TINFL_CR_FINISH - -common_exit: - r->m_num_bits = num_bits; - r->m_bit_buf = bit_buf; - r->m_dist = dist; - r->m_counter = counter; - r->m_num_extra = num_extra; - r->m_dist_from_out_buf_start = dist_from_out_buf_start; - *pIn_buf_size = pIn_buf_cur - pIn_buf_next; - *pOut_buf_size = pOut_buf_cur - pOut_buf_next; - if ((decomp_flags & - (TINFL_FLAG_PARSE_ZLIB_HEADER | TINFL_FLAG_COMPUTE_ADLER32)) && - (status >= 0)) { - const mz_uint8 *ptr = pOut_buf_next; - size_t buf_len = *pOut_buf_size; - mz_uint32 i, s1 = r->m_check_adler32 & 0xffff, - s2 = r->m_check_adler32 >> 16; - size_t block_len = buf_len % 5552; - while (buf_len) { - for (i = 0; i + 7 < block_len; i += 8, ptr += 8) { - s1 += ptr[0], s2 += s1; - s1 += ptr[1], s2 += s1; - s1 += ptr[2], s2 += s1; - s1 += ptr[3], s2 += s1; - s1 += ptr[4], s2 += s1; - s1 += ptr[5], s2 += s1; - s1 += ptr[6], s2 += s1; - s1 += ptr[7], s2 += s1; - } - for (; i < block_len; ++i) s1 += *ptr++, s2 += s1; - s1 %= 65521U, s2 %= 65521U; - buf_len -= block_len; - block_len = 5552; - } - r->m_check_adler32 = (s2 << 16) + s1; - if ((status == TINFL_STATUS_DONE) && - (decomp_flags & TINFL_FLAG_PARSE_ZLIB_HEADER) && - (r->m_check_adler32 != r->m_z_adler32)) - status = TINFL_STATUS_ADLER32_MISMATCH; - } - return status; -} - -// Higher level helper functions. -void *tinfl_decompress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, - size_t *pOut_len, int flags) { - tinfl_decompressor decomp; - void *pBuf = NULL, *pNew_buf; - size_t src_buf_ofs = 0, out_buf_capacity = 0; - *pOut_len = 0; - tinfl_init(&decomp); - for (;;) { - size_t src_buf_size = src_buf_len - src_buf_ofs, - dst_buf_size = out_buf_capacity - *pOut_len, new_out_buf_capacity; - tinfl_status status = tinfl_decompress( - &decomp, (const mz_uint8 *)pSrc_buf + src_buf_ofs, &src_buf_size, - (mz_uint8 *)pBuf, pBuf ? (mz_uint8 *)pBuf + *pOut_len : NULL, - &dst_buf_size, - (flags & ~TINFL_FLAG_HAS_MORE_INPUT) | - TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF); - if ((status < 0) || (status == TINFL_STATUS_NEEDS_MORE_INPUT)) { - MZ_FREE(pBuf); - *pOut_len = 0; - return NULL; - } - src_buf_ofs += src_buf_size; - *pOut_len += dst_buf_size; - if (status == TINFL_STATUS_DONE) break; - new_out_buf_capacity = out_buf_capacity * 2; - if (new_out_buf_capacity < 128) new_out_buf_capacity = 128; - pNew_buf = MZ_REALLOC(pBuf, new_out_buf_capacity); - if (!pNew_buf) { - MZ_FREE(pBuf); - *pOut_len = 0; - return NULL; - } - pBuf = pNew_buf; - out_buf_capacity = new_out_buf_capacity; - } - return pBuf; -} - -size_t tinfl_decompress_mem_to_mem(void *pOut_buf, size_t out_buf_len, - const void *pSrc_buf, size_t src_buf_len, - int flags) { - tinfl_decompressor decomp; - tinfl_status status; - tinfl_init(&decomp); - status = - tinfl_decompress(&decomp, (const mz_uint8 *)pSrc_buf, &src_buf_len, - (mz_uint8 *)pOut_buf, (mz_uint8 *)pOut_buf, &out_buf_len, - (flags & ~TINFL_FLAG_HAS_MORE_INPUT) | - TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF); - return (status != TINFL_STATUS_DONE) ? TINFL_DECOMPRESS_MEM_TO_MEM_FAILED - : out_buf_len; -} - -int tinfl_decompress_mem_to_callback(const void *pIn_buf, size_t *pIn_buf_size, - tinfl_put_buf_func_ptr pPut_buf_func, - void *pPut_buf_user, int flags) { - int result = 0; - tinfl_decompressor decomp; - mz_uint8 *pDict = (mz_uint8 *)MZ_MALLOC(TINFL_LZ_DICT_SIZE); - size_t in_buf_ofs = 0, dict_ofs = 0; - if (!pDict) return TINFL_STATUS_FAILED; - tinfl_init(&decomp); - for (;;) { - size_t in_buf_size = *pIn_buf_size - in_buf_ofs, - dst_buf_size = TINFL_LZ_DICT_SIZE - dict_ofs; - tinfl_status status = - tinfl_decompress(&decomp, (const mz_uint8 *)pIn_buf + in_buf_ofs, - &in_buf_size, pDict, pDict + dict_ofs, &dst_buf_size, - (flags & ~(TINFL_FLAG_HAS_MORE_INPUT | - TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF))); - in_buf_ofs += in_buf_size; - if ((dst_buf_size) && - (!(*pPut_buf_func)(pDict + dict_ofs, (int)dst_buf_size, pPut_buf_user))) - break; - if (status != TINFL_STATUS_HAS_MORE_OUTPUT) { - result = (status == TINFL_STATUS_DONE); - break; - } - dict_ofs = (dict_ofs + dst_buf_size) & (TINFL_LZ_DICT_SIZE - 1); - } - MZ_FREE(pDict); - *pIn_buf_size = in_buf_ofs; - return result; -} - -// ------------------- Low-level Compression (independent from all decompression -// API's) - -// Purposely making these tables static for faster init and thread safety. -static const mz_uint16 s_tdefl_len_sym[256] = { - 257, 258, 259, 260, 261, 262, 263, 264, 265, 265, 266, 266, 267, 267, 268, - 268, 269, 269, 269, 269, 270, 270, 270, 270, 271, 271, 271, 271, 272, 272, - 272, 272, 273, 273, 273, 273, 273, 273, 273, 273, 274, 274, 274, 274, 274, - 274, 274, 274, 275, 275, 275, 275, 275, 275, 275, 275, 276, 276, 276, 276, - 276, 276, 276, 276, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, - 277, 277, 277, 277, 277, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - 278, 278, 278, 278, 278, 278, 279, 279, 279, 279, 279, 279, 279, 279, 279, - 279, 279, 279, 279, 279, 279, 279, 280, 280, 280, 280, 280, 280, 280, 280, - 280, 280, 280, 280, 280, 280, 280, 280, 281, 281, 281, 281, 281, 281, 281, - 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, - 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 282, 282, 282, 282, 282, - 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, - 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 283, 283, 283, - 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, - 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 284, - 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, - 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, - 285}; - -static const mz_uint8 s_tdefl_len_extra[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0}; - -static const mz_uint8 s_tdefl_small_dist_sym[512] = { - 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, - 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, - 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17}; - -static const mz_uint8 s_tdefl_small_dist_extra[512] = { - 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}; - -static const mz_uint8 s_tdefl_large_dist_sym[128] = { - 0, 0, 18, 19, 20, 20, 21, 21, 22, 22, 22, 22, 23, 23, 23, 23, 24, 24, 24, - 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, - 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, - 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, - 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29}; - -static const mz_uint8 s_tdefl_large_dist_extra[128] = { - 0, 0, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13}; - -// Radix sorts tdefl_sym_freq[] array by 16-bit key m_key. Returns ptr to sorted -// values. -typedef struct { - mz_uint16 m_key, m_sym_index; -} tdefl_sym_freq; -static tdefl_sym_freq *tdefl_radix_sort_syms(mz_uint num_syms, - tdefl_sym_freq *pSyms0, - tdefl_sym_freq *pSyms1) { - mz_uint32 total_passes = 2, pass_shift, pass, i, hist[256 * 2]; - tdefl_sym_freq *pCur_syms = pSyms0, *pNew_syms = pSyms1; - MZ_CLEAR_OBJ(hist); - for (i = 0; i < num_syms; i++) { - mz_uint freq = pSyms0[i].m_key; - hist[freq & 0xFF]++; - hist[256 + ((freq >> 8) & 0xFF)]++; - } - while ((total_passes > 1) && (num_syms == hist[(total_passes - 1) * 256])) - total_passes--; - for (pass_shift = 0, pass = 0; pass < total_passes; pass++, pass_shift += 8) { - const mz_uint32 *pHist = &hist[pass << 8]; - mz_uint offsets[256], cur_ofs = 0; - for (i = 0; i < 256; i++) { - offsets[i] = cur_ofs; - cur_ofs += pHist[i]; - } - for (i = 0; i < num_syms; i++) - pNew_syms[offsets[(pCur_syms[i].m_key >> pass_shift) & 0xFF]++] = - pCur_syms[i]; - { - tdefl_sym_freq *t = pCur_syms; - pCur_syms = pNew_syms; - pNew_syms = t; - } - } - return pCur_syms; -} - -// tdefl_calculate_minimum_redundancy() originally written by: Alistair Moffat, -// alistair@cs.mu.oz.au, Jyrki Katajainen, jyrki@diku.dk, November 1996. -static void tdefl_calculate_minimum_redundancy(tdefl_sym_freq *A, int n) { - int root, leaf, next, avbl, used, dpth; - if (n == 0) - return; - else if (n == 1) { - A[0].m_key = 1; - return; - } - A[0].m_key += A[1].m_key; - root = 0; - leaf = 2; - for (next = 1; next < n - 1; next++) { - if (leaf >= n || A[root].m_key < A[leaf].m_key) { - A[next].m_key = A[root].m_key; - A[root++].m_key = (mz_uint16)next; - } else - A[next].m_key = A[leaf++].m_key; - if (leaf >= n || (root < next && A[root].m_key < A[leaf].m_key)) { - A[next].m_key = (mz_uint16)(A[next].m_key + A[root].m_key); - A[root++].m_key = (mz_uint16)next; - } else - A[next].m_key = (mz_uint16)(A[next].m_key + A[leaf++].m_key); - } - A[n - 2].m_key = 0; - for (next = n - 3; next >= 0; next--) - A[next].m_key = A[A[next].m_key].m_key + 1; - avbl = 1; - used = dpth = 0; - root = n - 2; - next = n - 1; - while (avbl > 0) { - while (root >= 0 && (int)A[root].m_key == dpth) { - used++; - root--; - } - while (avbl > used) { - A[next--].m_key = (mz_uint16)(dpth); - avbl--; - } - avbl = 2 * used; - dpth++; - used = 0; - } -} - -// Limits canonical Huffman code table's max code size. -enum { TDEFL_MAX_SUPPORTED_HUFF_CODESIZE = 32 }; -static void tdefl_huffman_enforce_max_code_size(int *pNum_codes, - int code_list_len, - int max_code_size) { - int i; - mz_uint32 total = 0; - if (code_list_len <= 1) return; - for (i = max_code_size + 1; i <= TDEFL_MAX_SUPPORTED_HUFF_CODESIZE; i++) - pNum_codes[max_code_size] += pNum_codes[i]; - for (i = max_code_size; i > 0; i--) - total += (((mz_uint32)pNum_codes[i]) << (max_code_size - i)); - while (total != (1UL << max_code_size)) { - pNum_codes[max_code_size]--; - for (i = max_code_size - 1; i > 0; i--) - if (pNum_codes[i]) { - pNum_codes[i]--; - pNum_codes[i + 1] += 2; - break; - } - total--; - } -} - -static void tdefl_optimize_huffman_table(tdefl_compressor *d, int table_num, - int table_len, int code_size_limit, - int static_table) { - int i, j, l, num_codes[1 + TDEFL_MAX_SUPPORTED_HUFF_CODESIZE]; - mz_uint next_code[TDEFL_MAX_SUPPORTED_HUFF_CODESIZE + 1]; - MZ_CLEAR_OBJ(num_codes); - if (static_table) { - for (i = 0; i < table_len; i++) - num_codes[d->m_huff_code_sizes[table_num][i]]++; - } else { - tdefl_sym_freq syms0[TDEFL_MAX_HUFF_SYMBOLS], syms1[TDEFL_MAX_HUFF_SYMBOLS], - *pSyms; - int num_used_syms = 0; - const mz_uint16 *pSym_count = &d->m_huff_count[table_num][0]; - for (i = 0; i < table_len; i++) - if (pSym_count[i]) { - syms0[num_used_syms].m_key = (mz_uint16)pSym_count[i]; - syms0[num_used_syms++].m_sym_index = (mz_uint16)i; - } - - pSyms = tdefl_radix_sort_syms(num_used_syms, syms0, syms1); - tdefl_calculate_minimum_redundancy(pSyms, num_used_syms); - - for (i = 0; i < num_used_syms; i++) num_codes[pSyms[i].m_key]++; - - tdefl_huffman_enforce_max_code_size(num_codes, num_used_syms, - code_size_limit); - - MZ_CLEAR_OBJ(d->m_huff_code_sizes[table_num]); - MZ_CLEAR_OBJ(d->m_huff_codes[table_num]); - for (i = 1, j = num_used_syms; i <= code_size_limit; i++) - for (l = num_codes[i]; l > 0; l--) - d->m_huff_code_sizes[table_num][pSyms[--j].m_sym_index] = (mz_uint8)(i); - } - - next_code[1] = 0; - for (j = 0, i = 2; i <= code_size_limit; i++) - next_code[i] = j = ((j + num_codes[i - 1]) << 1); - - for (i = 0; i < table_len; i++) { - mz_uint rev_code = 0, code, code_size; - if ((code_size = d->m_huff_code_sizes[table_num][i]) == 0) continue; - code = next_code[code_size]++; - for (l = code_size; l > 0; l--, code >>= 1) - rev_code = (rev_code << 1) | (code & 1); - d->m_huff_codes[table_num][i] = (mz_uint16)rev_code; - } -} - -#define TDEFL_PUT_BITS(b, l) \ - do { \ - mz_uint bits = b; \ - mz_uint len = l; \ - MZ_ASSERT(bits <= ((1U << len) - 1U)); \ - d->m_bit_buffer |= (bits << d->m_bits_in); \ - d->m_bits_in += len; \ - while (d->m_bits_in >= 8) { \ - if (d->m_pOutput_buf < d->m_pOutput_buf_end) \ - *d->m_pOutput_buf++ = (mz_uint8)(d->m_bit_buffer); \ - d->m_bit_buffer >>= 8; \ - d->m_bits_in -= 8; \ - } \ - } \ - MZ_MACRO_END - -#define TDEFL_RLE_PREV_CODE_SIZE() \ - { \ - if (rle_repeat_count) { \ - if (rle_repeat_count < 3) { \ - d->m_huff_count[2][prev_code_size] = (mz_uint16)( \ - d->m_huff_count[2][prev_code_size] + rle_repeat_count); \ - while (rle_repeat_count--) \ - packed_code_sizes[num_packed_code_sizes++] = prev_code_size; \ - } else { \ - d->m_huff_count[2][16] = (mz_uint16)(d->m_huff_count[2][16] + 1); \ - packed_code_sizes[num_packed_code_sizes++] = 16; \ - packed_code_sizes[num_packed_code_sizes++] = \ - (mz_uint8)(rle_repeat_count - 3); \ - } \ - rle_repeat_count = 0; \ - } \ - } - -#define TDEFL_RLE_ZERO_CODE_SIZE() \ - { \ - if (rle_z_count) { \ - if (rle_z_count < 3) { \ - d->m_huff_count[2][0] = \ - (mz_uint16)(d->m_huff_count[2][0] + rle_z_count); \ - while (rle_z_count--) packed_code_sizes[num_packed_code_sizes++] = 0; \ - } else if (rle_z_count <= 10) { \ - d->m_huff_count[2][17] = (mz_uint16)(d->m_huff_count[2][17] + 1); \ - packed_code_sizes[num_packed_code_sizes++] = 17; \ - packed_code_sizes[num_packed_code_sizes++] = \ - (mz_uint8)(rle_z_count - 3); \ - } else { \ - d->m_huff_count[2][18] = (mz_uint16)(d->m_huff_count[2][18] + 1); \ - packed_code_sizes[num_packed_code_sizes++] = 18; \ - packed_code_sizes[num_packed_code_sizes++] = \ - (mz_uint8)(rle_z_count - 11); \ - } \ - rle_z_count = 0; \ - } \ - } - -static mz_uint8 s_tdefl_packed_code_size_syms_swizzle[] = { - 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; - -static void tdefl_start_dynamic_block(tdefl_compressor *d) { - int num_lit_codes, num_dist_codes, num_bit_lengths; - mz_uint i, total_code_sizes_to_pack, num_packed_code_sizes, rle_z_count, - rle_repeat_count, packed_code_sizes_index; - mz_uint8 - code_sizes_to_pack[TDEFL_MAX_HUFF_SYMBOLS_0 + TDEFL_MAX_HUFF_SYMBOLS_1], - packed_code_sizes[TDEFL_MAX_HUFF_SYMBOLS_0 + TDEFL_MAX_HUFF_SYMBOLS_1], - prev_code_size = 0xFF; - - d->m_huff_count[0][256] = 1; - - tdefl_optimize_huffman_table(d, 0, TDEFL_MAX_HUFF_SYMBOLS_0, 15, MZ_FALSE); - tdefl_optimize_huffman_table(d, 1, TDEFL_MAX_HUFF_SYMBOLS_1, 15, MZ_FALSE); - - for (num_lit_codes = 286; num_lit_codes > 257; num_lit_codes--) - if (d->m_huff_code_sizes[0][num_lit_codes - 1]) break; - for (num_dist_codes = 30; num_dist_codes > 1; num_dist_codes--) - if (d->m_huff_code_sizes[1][num_dist_codes - 1]) break; - - memcpy(code_sizes_to_pack, &d->m_huff_code_sizes[0][0], num_lit_codes); - memcpy(code_sizes_to_pack + num_lit_codes, &d->m_huff_code_sizes[1][0], - num_dist_codes); - total_code_sizes_to_pack = num_lit_codes + num_dist_codes; - num_packed_code_sizes = 0; - rle_z_count = 0; - rle_repeat_count = 0; - - memset(&d->m_huff_count[2][0], 0, - sizeof(d->m_huff_count[2][0]) * TDEFL_MAX_HUFF_SYMBOLS_2); - for (i = 0; i < total_code_sizes_to_pack; i++) { - mz_uint8 code_size = code_sizes_to_pack[i]; - if (!code_size) { - TDEFL_RLE_PREV_CODE_SIZE(); - if (++rle_z_count == 138) { - TDEFL_RLE_ZERO_CODE_SIZE(); - } - } else { - TDEFL_RLE_ZERO_CODE_SIZE(); - if (code_size != prev_code_size) { - TDEFL_RLE_PREV_CODE_SIZE(); - d->m_huff_count[2][code_size] = - (mz_uint16)(d->m_huff_count[2][code_size] + 1); - packed_code_sizes[num_packed_code_sizes++] = code_size; - } else if (++rle_repeat_count == 6) { - TDEFL_RLE_PREV_CODE_SIZE(); - } - } - prev_code_size = code_size; - } - if (rle_repeat_count) { - TDEFL_RLE_PREV_CODE_SIZE(); - } else { - TDEFL_RLE_ZERO_CODE_SIZE(); - } - - tdefl_optimize_huffman_table(d, 2, TDEFL_MAX_HUFF_SYMBOLS_2, 7, MZ_FALSE); - - TDEFL_PUT_BITS(2, 2); - - TDEFL_PUT_BITS(num_lit_codes - 257, 5); - TDEFL_PUT_BITS(num_dist_codes - 1, 5); - - for (num_bit_lengths = 18; num_bit_lengths >= 0; num_bit_lengths--) - if (d->m_huff_code_sizes - [2][s_tdefl_packed_code_size_syms_swizzle[num_bit_lengths]]) - break; - num_bit_lengths = MZ_MAX(4, (num_bit_lengths + 1)); - TDEFL_PUT_BITS(num_bit_lengths - 4, 4); - for (i = 0; (int)i < num_bit_lengths; i++) - TDEFL_PUT_BITS( - d->m_huff_code_sizes[2][s_tdefl_packed_code_size_syms_swizzle[i]], 3); - - for (packed_code_sizes_index = 0; - packed_code_sizes_index < num_packed_code_sizes;) { - mz_uint code = packed_code_sizes[packed_code_sizes_index++]; - MZ_ASSERT(code < TDEFL_MAX_HUFF_SYMBOLS_2); - TDEFL_PUT_BITS(d->m_huff_codes[2][code], d->m_huff_code_sizes[2][code]); - if (code >= 16) - TDEFL_PUT_BITS(packed_code_sizes[packed_code_sizes_index++], - "\02\03\07"[code - 16]); - } -} - -static void tdefl_start_static_block(tdefl_compressor *d) { - mz_uint i; - mz_uint8 *p = &d->m_huff_code_sizes[0][0]; - - for (i = 0; i <= 143; ++i) *p++ = 8; - for (; i <= 255; ++i) *p++ = 9; - for (; i <= 279; ++i) *p++ = 7; - for (; i <= 287; ++i) *p++ = 8; - - memset(d->m_huff_code_sizes[1], 5, 32); - - tdefl_optimize_huffman_table(d, 0, 288, 15, MZ_TRUE); - tdefl_optimize_huffman_table(d, 1, 32, 15, MZ_TRUE); - - TDEFL_PUT_BITS(1, 2); -} - -static const mz_uint mz_bitmasks[17] = { - 0x0000, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F, 0x003F, 0x007F, 0x00FF, - 0x01FF, 0x03FF, 0x07FF, 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF}; - -#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN && \ - MINIZ_HAS_64BIT_REGISTERS -static mz_bool tdefl_compress_lz_codes(tdefl_compressor *d) { - mz_uint flags; - mz_uint8 *pLZ_codes; - mz_uint8 *pOutput_buf = d->m_pOutput_buf; - mz_uint8 *pLZ_code_buf_end = d->m_pLZ_code_buf; - mz_uint64 bit_buffer = d->m_bit_buffer; - mz_uint bits_in = d->m_bits_in; - -#define TDEFL_PUT_BITS_FAST(b, l) \ - { \ - bit_buffer |= (((mz_uint64)(b)) << bits_in); \ - bits_in += (l); \ - } - - flags = 1; - for (pLZ_codes = d->m_lz_code_buf; pLZ_codes < pLZ_code_buf_end; - flags >>= 1) { - if (flags == 1) flags = *pLZ_codes++ | 0x100; - - if (flags & 1) { - mz_uint s0, s1, n0, n1, sym, num_extra_bits; - mz_uint match_len = pLZ_codes[0], - match_dist = *(const mz_uint16 *)(pLZ_codes + 1); - pLZ_codes += 3; - - MZ_ASSERT(d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]); - TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][s_tdefl_len_sym[match_len]], - d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]); - TDEFL_PUT_BITS_FAST(match_len & mz_bitmasks[s_tdefl_len_extra[match_len]], - s_tdefl_len_extra[match_len]); - - // This sequence coaxes MSVC into using cmov's vs. jmp's. - s0 = s_tdefl_small_dist_sym[match_dist & 511]; - n0 = s_tdefl_small_dist_extra[match_dist & 511]; - s1 = s_tdefl_large_dist_sym[match_dist >> 8]; - n1 = s_tdefl_large_dist_extra[match_dist >> 8]; - sym = (match_dist < 512) ? s0 : s1; - num_extra_bits = (match_dist < 512) ? n0 : n1; - - MZ_ASSERT(d->m_huff_code_sizes[1][sym]); - TDEFL_PUT_BITS_FAST(d->m_huff_codes[1][sym], - d->m_huff_code_sizes[1][sym]); - TDEFL_PUT_BITS_FAST(match_dist & mz_bitmasks[num_extra_bits], - num_extra_bits); - } else { - mz_uint lit = *pLZ_codes++; - MZ_ASSERT(d->m_huff_code_sizes[0][lit]); - TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][lit], - d->m_huff_code_sizes[0][lit]); - - if (((flags & 2) == 0) && (pLZ_codes < pLZ_code_buf_end)) { - flags >>= 1; - lit = *pLZ_codes++; - MZ_ASSERT(d->m_huff_code_sizes[0][lit]); - TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][lit], - d->m_huff_code_sizes[0][lit]); - - if (((flags & 2) == 0) && (pLZ_codes < pLZ_code_buf_end)) { - flags >>= 1; - lit = *pLZ_codes++; - MZ_ASSERT(d->m_huff_code_sizes[0][lit]); - TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][lit], - d->m_huff_code_sizes[0][lit]); - } - } - } - - if (pOutput_buf >= d->m_pOutput_buf_end) return MZ_FALSE; - - *(mz_uint64 *)pOutput_buf = bit_buffer; - pOutput_buf += (bits_in >> 3); - bit_buffer >>= (bits_in & ~7); - bits_in &= 7; - } - -#undef TDEFL_PUT_BITS_FAST - - d->m_pOutput_buf = pOutput_buf; - d->m_bits_in = 0; - d->m_bit_buffer = 0; - - while (bits_in) { - mz_uint32 n = MZ_MIN(bits_in, 16); - TDEFL_PUT_BITS((mz_uint)bit_buffer & mz_bitmasks[n], n); - bit_buffer >>= n; - bits_in -= n; - } - - TDEFL_PUT_BITS(d->m_huff_codes[0][256], d->m_huff_code_sizes[0][256]); - - return (d->m_pOutput_buf < d->m_pOutput_buf_end); -} -#else -static mz_bool tdefl_compress_lz_codes(tdefl_compressor *d) { - mz_uint flags; - mz_uint8 *pLZ_codes; - - flags = 1; - for (pLZ_codes = d->m_lz_code_buf; pLZ_codes < d->m_pLZ_code_buf; - flags >>= 1) { - if (flags == 1) flags = *pLZ_codes++ | 0x100; - if (flags & 1) { - mz_uint sym, num_extra_bits; - mz_uint match_len = pLZ_codes[0], - match_dist = (pLZ_codes[1] | (pLZ_codes[2] << 8)); - pLZ_codes += 3; - - MZ_ASSERT(d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]); - TDEFL_PUT_BITS(d->m_huff_codes[0][s_tdefl_len_sym[match_len]], - d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]); - TDEFL_PUT_BITS(match_len & mz_bitmasks[s_tdefl_len_extra[match_len]], - s_tdefl_len_extra[match_len]); - - if (match_dist < 512) { - sym = s_tdefl_small_dist_sym[match_dist]; - num_extra_bits = s_tdefl_small_dist_extra[match_dist]; - } else { - sym = s_tdefl_large_dist_sym[match_dist >> 8]; - num_extra_bits = s_tdefl_large_dist_extra[match_dist >> 8]; - } - MZ_ASSERT(d->m_huff_code_sizes[1][sym]); - TDEFL_PUT_BITS(d->m_huff_codes[1][sym], d->m_huff_code_sizes[1][sym]); - TDEFL_PUT_BITS(match_dist & mz_bitmasks[num_extra_bits], num_extra_bits); - } else { - mz_uint lit = *pLZ_codes++; - MZ_ASSERT(d->m_huff_code_sizes[0][lit]); - TDEFL_PUT_BITS(d->m_huff_codes[0][lit], d->m_huff_code_sizes[0][lit]); - } - } - - TDEFL_PUT_BITS(d->m_huff_codes[0][256], d->m_huff_code_sizes[0][256]); - - return (d->m_pOutput_buf < d->m_pOutput_buf_end); -} -#endif // MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN && - // MINIZ_HAS_64BIT_REGISTERS - -static mz_bool tdefl_compress_block(tdefl_compressor *d, mz_bool static_block) { - if (static_block) - tdefl_start_static_block(d); - else - tdefl_start_dynamic_block(d); - return tdefl_compress_lz_codes(d); -} - -static int tdefl_flush_block(tdefl_compressor *d, int flush) { - mz_uint saved_bit_buf, saved_bits_in; - mz_uint8 *pSaved_output_buf; - mz_bool comp_block_succeeded = MZ_FALSE; - int n, use_raw_block = - ((d->m_flags & TDEFL_FORCE_ALL_RAW_BLOCKS) != 0) && - (d->m_lookahead_pos - d->m_lz_code_buf_dict_pos) <= d->m_dict_size; - mz_uint8 *pOutput_buf_start = - ((d->m_pPut_buf_func == NULL) && - ((*d->m_pOut_buf_size - d->m_out_buf_ofs) >= TDEFL_OUT_BUF_SIZE)) - ? ((mz_uint8 *)d->m_pOut_buf + d->m_out_buf_ofs) - : d->m_output_buf; - - d->m_pOutput_buf = pOutput_buf_start; - d->m_pOutput_buf_end = d->m_pOutput_buf + TDEFL_OUT_BUF_SIZE - 16; - - MZ_ASSERT(!d->m_output_flush_remaining); - d->m_output_flush_ofs = 0; - d->m_output_flush_remaining = 0; - - *d->m_pLZ_flags = (mz_uint8)(*d->m_pLZ_flags >> d->m_num_flags_left); - d->m_pLZ_code_buf -= (d->m_num_flags_left == 8); - - if ((d->m_flags & TDEFL_WRITE_ZLIB_HEADER) && (!d->m_block_index)) { - TDEFL_PUT_BITS(0x78, 8); - TDEFL_PUT_BITS(0x01, 8); - } - - TDEFL_PUT_BITS(flush == TDEFL_FINISH, 1); - - pSaved_output_buf = d->m_pOutput_buf; - saved_bit_buf = d->m_bit_buffer; - saved_bits_in = d->m_bits_in; - - if (!use_raw_block) - comp_block_succeeded = - tdefl_compress_block(d, (d->m_flags & TDEFL_FORCE_ALL_STATIC_BLOCKS) || - (d->m_total_lz_bytes < 48)); - - // If the block gets expanded, forget the current contents of the output - // buffer and send a raw block instead. - if (((use_raw_block) || - ((d->m_total_lz_bytes) && ((d->m_pOutput_buf - pSaved_output_buf + 1U) >= - d->m_total_lz_bytes))) && - ((d->m_lookahead_pos - d->m_lz_code_buf_dict_pos) <= d->m_dict_size)) { - mz_uint i; - d->m_pOutput_buf = pSaved_output_buf; - d->m_bit_buffer = saved_bit_buf, d->m_bits_in = saved_bits_in; - TDEFL_PUT_BITS(0, 2); - if (d->m_bits_in) { - TDEFL_PUT_BITS(0, 8 - d->m_bits_in); - } - for (i = 2; i; --i, d->m_total_lz_bytes ^= 0xFFFF) { - TDEFL_PUT_BITS(d->m_total_lz_bytes & 0xFFFF, 16); - } - for (i = 0; i < d->m_total_lz_bytes; ++i) { - TDEFL_PUT_BITS( - d->m_dict[(d->m_lz_code_buf_dict_pos + i) & TDEFL_LZ_DICT_SIZE_MASK], - 8); - } - } - // Check for the extremely unlikely (if not impossible) case of the compressed - // block not fitting into the output buffer when using dynamic codes. - else if (!comp_block_succeeded) { - d->m_pOutput_buf = pSaved_output_buf; - d->m_bit_buffer = saved_bit_buf, d->m_bits_in = saved_bits_in; - tdefl_compress_block(d, MZ_TRUE); - } - - if (flush) { - if (flush == TDEFL_FINISH) { - if (d->m_bits_in) { - TDEFL_PUT_BITS(0, 8 - d->m_bits_in); - } - if (d->m_flags & TDEFL_WRITE_ZLIB_HEADER) { - mz_uint i, a = d->m_adler32; - for (i = 0; i < 4; i++) { - TDEFL_PUT_BITS((a >> 24) & 0xFF, 8); - a <<= 8; - } - } - } else { - mz_uint i, z = 0; - TDEFL_PUT_BITS(0, 3); - if (d->m_bits_in) { - TDEFL_PUT_BITS(0, 8 - d->m_bits_in); - } - for (i = 2; i; --i, z ^= 0xFFFF) { - TDEFL_PUT_BITS(z & 0xFFFF, 16); - } - } - } - - MZ_ASSERT(d->m_pOutput_buf < d->m_pOutput_buf_end); - - memset(&d->m_huff_count[0][0], 0, - sizeof(d->m_huff_count[0][0]) * TDEFL_MAX_HUFF_SYMBOLS_0); - memset(&d->m_huff_count[1][0], 0, - sizeof(d->m_huff_count[1][0]) * TDEFL_MAX_HUFF_SYMBOLS_1); - - d->m_pLZ_code_buf = d->m_lz_code_buf + 1; - d->m_pLZ_flags = d->m_lz_code_buf; - d->m_num_flags_left = 8; - d->m_lz_code_buf_dict_pos += d->m_total_lz_bytes; - d->m_total_lz_bytes = 0; - d->m_block_index++; - - if ((n = (int)(d->m_pOutput_buf - pOutput_buf_start)) != 0) { - if (d->m_pPut_buf_func) { - *d->m_pIn_buf_size = d->m_pSrc - (const mz_uint8 *)d->m_pIn_buf; - if (!(*d->m_pPut_buf_func)(d->m_output_buf, n, d->m_pPut_buf_user)) - return (d->m_prev_return_status = TDEFL_STATUS_PUT_BUF_FAILED); - } else if (pOutput_buf_start == d->m_output_buf) { - int bytes_to_copy = (int)MZ_MIN( - (size_t)n, (size_t)(*d->m_pOut_buf_size - d->m_out_buf_ofs)); - memcpy((mz_uint8 *)d->m_pOut_buf + d->m_out_buf_ofs, d->m_output_buf, - bytes_to_copy); - d->m_out_buf_ofs += bytes_to_copy; - if ((n -= bytes_to_copy) != 0) { - d->m_output_flush_ofs = bytes_to_copy; - d->m_output_flush_remaining = n; - } - } else { - d->m_out_buf_ofs += n; - } - } - - return d->m_output_flush_remaining; -} - -#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES -#define TDEFL_READ_UNALIGNED_WORD(p) *(const mz_uint16 *)(p) -static MZ_FORCEINLINE void tdefl_find_match( - tdefl_compressor *d, mz_uint lookahead_pos, mz_uint max_dist, - mz_uint max_match_len, mz_uint *pMatch_dist, mz_uint *pMatch_len) { - mz_uint dist, pos = lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK, - match_len = *pMatch_len, probe_pos = pos, next_probe_pos, - probe_len; - mz_uint num_probes_left = d->m_max_probes[match_len >= 32]; - const mz_uint16 *s = (const mz_uint16 *)(d->m_dict + pos), *p, *q; - mz_uint16 c01 = TDEFL_READ_UNALIGNED_WORD(&d->m_dict[pos + match_len - 1]), - s01 = TDEFL_READ_UNALIGNED_WORD(s); - MZ_ASSERT(max_match_len <= TDEFL_MAX_MATCH_LEN); - if (max_match_len <= match_len) return; - for (;;) { - for (;;) { - if (--num_probes_left == 0) return; -#define TDEFL_PROBE \ - next_probe_pos = d->m_next[probe_pos]; \ - if ((!next_probe_pos) || \ - ((dist = (mz_uint16)(lookahead_pos - next_probe_pos)) > max_dist)) \ - return; \ - probe_pos = next_probe_pos & TDEFL_LZ_DICT_SIZE_MASK; \ - if (TDEFL_READ_UNALIGNED_WORD(&d->m_dict[probe_pos + match_len - 1]) == c01) \ - break; - TDEFL_PROBE; - TDEFL_PROBE; - TDEFL_PROBE; - } - if (!dist) break; - q = (const mz_uint16 *)(d->m_dict + probe_pos); - if (TDEFL_READ_UNALIGNED_WORD(q) != s01) continue; - p = s; - probe_len = 32; - do { - } while ( - (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && - (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && - (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && - (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && - (--probe_len > 0)); - if (!probe_len) { - *pMatch_dist = dist; - *pMatch_len = MZ_MIN(max_match_len, TDEFL_MAX_MATCH_LEN); - break; - } else if ((probe_len = ((mz_uint)(p - s) * 2) + - (mz_uint)(*(const mz_uint8 *)p == - *(const mz_uint8 *)q)) > match_len) { - *pMatch_dist = dist; - if ((*pMatch_len = match_len = MZ_MIN(max_match_len, probe_len)) == - max_match_len) - break; - c01 = TDEFL_READ_UNALIGNED_WORD(&d->m_dict[pos + match_len - 1]); - } - } -} -#else -static MZ_FORCEINLINE void tdefl_find_match( - tdefl_compressor *d, mz_uint lookahead_pos, mz_uint max_dist, - mz_uint max_match_len, mz_uint *pMatch_dist, mz_uint *pMatch_len) { - mz_uint dist, pos = lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK, - match_len = *pMatch_len, probe_pos = pos, next_probe_pos, - probe_len; - mz_uint num_probes_left = d->m_max_probes[match_len >= 32]; - const mz_uint8 *s = d->m_dict + pos, *p, *q; - mz_uint8 c0 = d->m_dict[pos + match_len], c1 = d->m_dict[pos + match_len - 1]; - MZ_ASSERT(max_match_len <= TDEFL_MAX_MATCH_LEN); - if (max_match_len <= match_len) return; - for (;;) { - for (;;) { - if (--num_probes_left == 0) return; -#define TDEFL_PROBE \ - next_probe_pos = d->m_next[probe_pos]; \ - if ((!next_probe_pos) || \ - ((dist = (mz_uint16)(lookahead_pos - next_probe_pos)) > max_dist)) \ - return; \ - probe_pos = next_probe_pos & TDEFL_LZ_DICT_SIZE_MASK; \ - if ((d->m_dict[probe_pos + match_len] == c0) && \ - (d->m_dict[probe_pos + match_len - 1] == c1)) \ - break; - TDEFL_PROBE; - TDEFL_PROBE; - TDEFL_PROBE; - } - if (!dist) break; - p = s; - q = d->m_dict + probe_pos; - for (probe_len = 0; probe_len < max_match_len; probe_len++) - if (*p++ != *q++) break; - if (probe_len > match_len) { - *pMatch_dist = dist; - if ((*pMatch_len = match_len = probe_len) == max_match_len) return; - c0 = d->m_dict[pos + match_len]; - c1 = d->m_dict[pos + match_len - 1]; - } - } -} -#endif // #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES - -#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN -static mz_bool tdefl_compress_fast(tdefl_compressor *d) { - // Faster, minimally featured LZRW1-style match+parse loop with better - // register utilization. Intended for applications where raw throughput is - // valued more highly than ratio. - mz_uint lookahead_pos = d->m_lookahead_pos, - lookahead_size = d->m_lookahead_size, dict_size = d->m_dict_size, - total_lz_bytes = d->m_total_lz_bytes, - num_flags_left = d->m_num_flags_left; - mz_uint8 *pLZ_code_buf = d->m_pLZ_code_buf, *pLZ_flags = d->m_pLZ_flags; - mz_uint cur_pos = lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK; - - while ((d->m_src_buf_left) || ((d->m_flush) && (lookahead_size))) { - const mz_uint TDEFL_COMP_FAST_LOOKAHEAD_SIZE = 4096; - mz_uint dst_pos = - (lookahead_pos + lookahead_size) & TDEFL_LZ_DICT_SIZE_MASK; - mz_uint num_bytes_to_process = (mz_uint)MZ_MIN( - d->m_src_buf_left, TDEFL_COMP_FAST_LOOKAHEAD_SIZE - lookahead_size); - d->m_src_buf_left -= num_bytes_to_process; - lookahead_size += num_bytes_to_process; - - while (num_bytes_to_process) { - mz_uint32 n = MZ_MIN(TDEFL_LZ_DICT_SIZE - dst_pos, num_bytes_to_process); - memcpy(d->m_dict + dst_pos, d->m_pSrc, n); - if (dst_pos < (TDEFL_MAX_MATCH_LEN - 1)) - memcpy(d->m_dict + TDEFL_LZ_DICT_SIZE + dst_pos, d->m_pSrc, - MZ_MIN(n, (TDEFL_MAX_MATCH_LEN - 1) - dst_pos)); - d->m_pSrc += n; - dst_pos = (dst_pos + n) & TDEFL_LZ_DICT_SIZE_MASK; - num_bytes_to_process -= n; - } - - dict_size = MZ_MIN(TDEFL_LZ_DICT_SIZE - lookahead_size, dict_size); - if ((!d->m_flush) && (lookahead_size < TDEFL_COMP_FAST_LOOKAHEAD_SIZE)) - break; - - while (lookahead_size >= 4) { - mz_uint cur_match_dist, cur_match_len = 1; - mz_uint8 *pCur_dict = d->m_dict + cur_pos; - mz_uint first_trigram = (*(const mz_uint32 *)pCur_dict) & 0xFFFFFF; - mz_uint hash = - (first_trigram ^ (first_trigram >> (24 - (TDEFL_LZ_HASH_BITS - 8)))) & - TDEFL_LEVEL1_HASH_SIZE_MASK; - mz_uint probe_pos = d->m_hash[hash]; - d->m_hash[hash] = (mz_uint16)lookahead_pos; - - if (((cur_match_dist = (mz_uint16)(lookahead_pos - probe_pos)) <= - dict_size) && - ((*(const mz_uint32 *)(d->m_dict + - (probe_pos &= TDEFL_LZ_DICT_SIZE_MASK)) & - 0xFFFFFF) == first_trigram)) { - const mz_uint16 *p = (const mz_uint16 *)pCur_dict; - const mz_uint16 *q = (const mz_uint16 *)(d->m_dict + probe_pos); - mz_uint32 probe_len = 32; - do { - } while ((TDEFL_READ_UNALIGNED_WORD(++p) == - TDEFL_READ_UNALIGNED_WORD(++q)) && - (TDEFL_READ_UNALIGNED_WORD(++p) == - TDEFL_READ_UNALIGNED_WORD(++q)) && - (TDEFL_READ_UNALIGNED_WORD(++p) == - TDEFL_READ_UNALIGNED_WORD(++q)) && - (TDEFL_READ_UNALIGNED_WORD(++p) == - TDEFL_READ_UNALIGNED_WORD(++q)) && - (--probe_len > 0)); - cur_match_len = ((mz_uint)(p - (const mz_uint16 *)pCur_dict) * 2) + - (mz_uint)(*(const mz_uint8 *)p == *(const mz_uint8 *)q); - if (!probe_len) - cur_match_len = cur_match_dist ? TDEFL_MAX_MATCH_LEN : 0; - - if ((cur_match_len < TDEFL_MIN_MATCH_LEN) || - ((cur_match_len == TDEFL_MIN_MATCH_LEN) && - (cur_match_dist >= 8U * 1024U))) { - cur_match_len = 1; - *pLZ_code_buf++ = (mz_uint8)first_trigram; - *pLZ_flags = (mz_uint8)(*pLZ_flags >> 1); - d->m_huff_count[0][(mz_uint8)first_trigram]++; - } else { - mz_uint32 s0, s1; - cur_match_len = MZ_MIN(cur_match_len, lookahead_size); - - MZ_ASSERT((cur_match_len >= TDEFL_MIN_MATCH_LEN) && - (cur_match_dist >= 1) && - (cur_match_dist <= TDEFL_LZ_DICT_SIZE)); - - cur_match_dist--; - - pLZ_code_buf[0] = (mz_uint8)(cur_match_len - TDEFL_MIN_MATCH_LEN); - *(mz_uint16 *)(&pLZ_code_buf[1]) = (mz_uint16)cur_match_dist; - pLZ_code_buf += 3; - *pLZ_flags = (mz_uint8)((*pLZ_flags >> 1) | 0x80); - - s0 = s_tdefl_small_dist_sym[cur_match_dist & 511]; - s1 = s_tdefl_large_dist_sym[cur_match_dist >> 8]; - d->m_huff_count[1][(cur_match_dist < 512) ? s0 : s1]++; - - d->m_huff_count[0][s_tdefl_len_sym[cur_match_len - - TDEFL_MIN_MATCH_LEN]]++; - } - } else { - *pLZ_code_buf++ = (mz_uint8)first_trigram; - *pLZ_flags = (mz_uint8)(*pLZ_flags >> 1); - d->m_huff_count[0][(mz_uint8)first_trigram]++; - } - - if (--num_flags_left == 0) { - num_flags_left = 8; - pLZ_flags = pLZ_code_buf++; - } - - total_lz_bytes += cur_match_len; - lookahead_pos += cur_match_len; - dict_size = MZ_MIN(dict_size + cur_match_len, TDEFL_LZ_DICT_SIZE); - cur_pos = (cur_pos + cur_match_len) & TDEFL_LZ_DICT_SIZE_MASK; - MZ_ASSERT(lookahead_size >= cur_match_len); - lookahead_size -= cur_match_len; - - if (pLZ_code_buf > &d->m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE - 8]) { - int n; - d->m_lookahead_pos = lookahead_pos; - d->m_lookahead_size = lookahead_size; - d->m_dict_size = dict_size; - d->m_total_lz_bytes = total_lz_bytes; - d->m_pLZ_code_buf = pLZ_code_buf; - d->m_pLZ_flags = pLZ_flags; - d->m_num_flags_left = num_flags_left; - if ((n = tdefl_flush_block(d, 0)) != 0) - return (n < 0) ? MZ_FALSE : MZ_TRUE; - total_lz_bytes = d->m_total_lz_bytes; - pLZ_code_buf = d->m_pLZ_code_buf; - pLZ_flags = d->m_pLZ_flags; - num_flags_left = d->m_num_flags_left; - } - } - - while (lookahead_size) { - mz_uint8 lit = d->m_dict[cur_pos]; - - total_lz_bytes++; - *pLZ_code_buf++ = lit; - *pLZ_flags = (mz_uint8)(*pLZ_flags >> 1); - if (--num_flags_left == 0) { - num_flags_left = 8; - pLZ_flags = pLZ_code_buf++; - } - - d->m_huff_count[0][lit]++; - - lookahead_pos++; - dict_size = MZ_MIN(dict_size + 1, TDEFL_LZ_DICT_SIZE); - cur_pos = (cur_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK; - lookahead_size--; - - if (pLZ_code_buf > &d->m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE - 8]) { - int n; - d->m_lookahead_pos = lookahead_pos; - d->m_lookahead_size = lookahead_size; - d->m_dict_size = dict_size; - d->m_total_lz_bytes = total_lz_bytes; - d->m_pLZ_code_buf = pLZ_code_buf; - d->m_pLZ_flags = pLZ_flags; - d->m_num_flags_left = num_flags_left; - if ((n = tdefl_flush_block(d, 0)) != 0) - return (n < 0) ? MZ_FALSE : MZ_TRUE; - total_lz_bytes = d->m_total_lz_bytes; - pLZ_code_buf = d->m_pLZ_code_buf; - pLZ_flags = d->m_pLZ_flags; - num_flags_left = d->m_num_flags_left; - } - } - } - - d->m_lookahead_pos = lookahead_pos; - d->m_lookahead_size = lookahead_size; - d->m_dict_size = dict_size; - d->m_total_lz_bytes = total_lz_bytes; - d->m_pLZ_code_buf = pLZ_code_buf; - d->m_pLZ_flags = pLZ_flags; - d->m_num_flags_left = num_flags_left; - return MZ_TRUE; -} -#endif // MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN - -static MZ_FORCEINLINE void tdefl_record_literal(tdefl_compressor *d, - mz_uint8 lit) { - d->m_total_lz_bytes++; - *d->m_pLZ_code_buf++ = lit; - *d->m_pLZ_flags = (mz_uint8)(*d->m_pLZ_flags >> 1); - if (--d->m_num_flags_left == 0) { - d->m_num_flags_left = 8; - d->m_pLZ_flags = d->m_pLZ_code_buf++; - } - d->m_huff_count[0][lit]++; -} - -static MZ_FORCEINLINE void tdefl_record_match(tdefl_compressor *d, - mz_uint match_len, - mz_uint match_dist) { - mz_uint32 s0, s1; - - MZ_ASSERT((match_len >= TDEFL_MIN_MATCH_LEN) && (match_dist >= 1) && - (match_dist <= TDEFL_LZ_DICT_SIZE)); - - d->m_total_lz_bytes += match_len; - - d->m_pLZ_code_buf[0] = (mz_uint8)(match_len - TDEFL_MIN_MATCH_LEN); - - match_dist -= 1; - d->m_pLZ_code_buf[1] = (mz_uint8)(match_dist & 0xFF); - d->m_pLZ_code_buf[2] = (mz_uint8)(match_dist >> 8); - d->m_pLZ_code_buf += 3; - - *d->m_pLZ_flags = (mz_uint8)((*d->m_pLZ_flags >> 1) | 0x80); - if (--d->m_num_flags_left == 0) { - d->m_num_flags_left = 8; - d->m_pLZ_flags = d->m_pLZ_code_buf++; - } - - s0 = s_tdefl_small_dist_sym[match_dist & 511]; - s1 = s_tdefl_large_dist_sym[(match_dist >> 8) & 127]; - d->m_huff_count[1][(match_dist < 512) ? s0 : s1]++; - - if (match_len >= TDEFL_MIN_MATCH_LEN) - d->m_huff_count[0][s_tdefl_len_sym[match_len - TDEFL_MIN_MATCH_LEN]]++; -} - -static mz_bool tdefl_compress_normal(tdefl_compressor *d) { - const mz_uint8 *pSrc = d->m_pSrc; - size_t src_buf_left = d->m_src_buf_left; - tdefl_flush flush = d->m_flush; - - while ((src_buf_left) || ((flush) && (d->m_lookahead_size))) { - mz_uint len_to_move, cur_match_dist, cur_match_len, cur_pos; - // Update dictionary and hash chains. Keeps the lookahead size equal to - // TDEFL_MAX_MATCH_LEN. - if ((d->m_lookahead_size + d->m_dict_size) >= (TDEFL_MIN_MATCH_LEN - 1)) { - mz_uint dst_pos = (d->m_lookahead_pos + d->m_lookahead_size) & - TDEFL_LZ_DICT_SIZE_MASK, - ins_pos = d->m_lookahead_pos + d->m_lookahead_size - 2; - mz_uint hash = (d->m_dict[ins_pos & TDEFL_LZ_DICT_SIZE_MASK] - << TDEFL_LZ_HASH_SHIFT) ^ - d->m_dict[(ins_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK]; - mz_uint num_bytes_to_process = (mz_uint)MZ_MIN( - src_buf_left, TDEFL_MAX_MATCH_LEN - d->m_lookahead_size); - const mz_uint8 *pSrc_end = pSrc + num_bytes_to_process; - src_buf_left -= num_bytes_to_process; - d->m_lookahead_size += num_bytes_to_process; - while (pSrc != pSrc_end) { - mz_uint8 c = *pSrc++; - d->m_dict[dst_pos] = c; - if (dst_pos < (TDEFL_MAX_MATCH_LEN - 1)) - d->m_dict[TDEFL_LZ_DICT_SIZE + dst_pos] = c; - hash = ((hash << TDEFL_LZ_HASH_SHIFT) ^ c) & (TDEFL_LZ_HASH_SIZE - 1); - d->m_next[ins_pos & TDEFL_LZ_DICT_SIZE_MASK] = d->m_hash[hash]; - d->m_hash[hash] = (mz_uint16)(ins_pos); - dst_pos = (dst_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK; - ins_pos++; - } - } else { - while ((src_buf_left) && (d->m_lookahead_size < TDEFL_MAX_MATCH_LEN)) { - mz_uint8 c = *pSrc++; - mz_uint dst_pos = (d->m_lookahead_pos + d->m_lookahead_size) & - TDEFL_LZ_DICT_SIZE_MASK; - src_buf_left--; - d->m_dict[dst_pos] = c; - if (dst_pos < (TDEFL_MAX_MATCH_LEN - 1)) - d->m_dict[TDEFL_LZ_DICT_SIZE + dst_pos] = c; - if ((++d->m_lookahead_size + d->m_dict_size) >= TDEFL_MIN_MATCH_LEN) { - mz_uint ins_pos = d->m_lookahead_pos + (d->m_lookahead_size - 1) - 2; - mz_uint hash = ((d->m_dict[ins_pos & TDEFL_LZ_DICT_SIZE_MASK] - << (TDEFL_LZ_HASH_SHIFT * 2)) ^ - (d->m_dict[(ins_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK] - << TDEFL_LZ_HASH_SHIFT) ^ - c) & - (TDEFL_LZ_HASH_SIZE - 1); - d->m_next[ins_pos & TDEFL_LZ_DICT_SIZE_MASK] = d->m_hash[hash]; - d->m_hash[hash] = (mz_uint16)(ins_pos); - } - } - } - d->m_dict_size = - MZ_MIN(TDEFL_LZ_DICT_SIZE - d->m_lookahead_size, d->m_dict_size); - if ((!flush) && (d->m_lookahead_size < TDEFL_MAX_MATCH_LEN)) break; - - // Simple lazy/greedy parsing state machine. - len_to_move = 1; - cur_match_dist = 0; - cur_match_len = - d->m_saved_match_len ? d->m_saved_match_len : (TDEFL_MIN_MATCH_LEN - 1); - cur_pos = d->m_lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK; - if (d->m_flags & (TDEFL_RLE_MATCHES | TDEFL_FORCE_ALL_RAW_BLOCKS)) { - if ((d->m_dict_size) && (!(d->m_flags & TDEFL_FORCE_ALL_RAW_BLOCKS))) { - mz_uint8 c = d->m_dict[(cur_pos - 1) & TDEFL_LZ_DICT_SIZE_MASK]; - cur_match_len = 0; - while (cur_match_len < d->m_lookahead_size) { - if (d->m_dict[cur_pos + cur_match_len] != c) break; - cur_match_len++; - } - if (cur_match_len < TDEFL_MIN_MATCH_LEN) - cur_match_len = 0; - else - cur_match_dist = 1; - } - } else { - tdefl_find_match(d, d->m_lookahead_pos, d->m_dict_size, - d->m_lookahead_size, &cur_match_dist, &cur_match_len); - } - if (((cur_match_len == TDEFL_MIN_MATCH_LEN) && - (cur_match_dist >= 8U * 1024U)) || - (cur_pos == cur_match_dist) || - ((d->m_flags & TDEFL_FILTER_MATCHES) && (cur_match_len <= 5))) { - cur_match_dist = cur_match_len = 0; - } - if (d->m_saved_match_len) { - if (cur_match_len > d->m_saved_match_len) { - tdefl_record_literal(d, (mz_uint8)d->m_saved_lit); - if (cur_match_len >= 128) { - tdefl_record_match(d, cur_match_len, cur_match_dist); - d->m_saved_match_len = 0; - len_to_move = cur_match_len; - } else { - d->m_saved_lit = d->m_dict[cur_pos]; - d->m_saved_match_dist = cur_match_dist; - d->m_saved_match_len = cur_match_len; - } - } else { - tdefl_record_match(d, d->m_saved_match_len, d->m_saved_match_dist); - len_to_move = d->m_saved_match_len - 1; - d->m_saved_match_len = 0; - } - } else if (!cur_match_dist) - tdefl_record_literal(d, - d->m_dict[MZ_MIN(cur_pos, sizeof(d->m_dict) - 1)]); - else if ((d->m_greedy_parsing) || (d->m_flags & TDEFL_RLE_MATCHES) || - (cur_match_len >= 128)) { - tdefl_record_match(d, cur_match_len, cur_match_dist); - len_to_move = cur_match_len; - } else { - d->m_saved_lit = d->m_dict[MZ_MIN(cur_pos, sizeof(d->m_dict) - 1)]; - d->m_saved_match_dist = cur_match_dist; - d->m_saved_match_len = cur_match_len; - } - // Move the lookahead forward by len_to_move bytes. - d->m_lookahead_pos += len_to_move; - MZ_ASSERT(d->m_lookahead_size >= len_to_move); - d->m_lookahead_size -= len_to_move; - d->m_dict_size = - MZ_MIN(d->m_dict_size + len_to_move, (mz_uint)TDEFL_LZ_DICT_SIZE); - // Check if it's time to flush the current LZ codes to the internal output - // buffer. - if ((d->m_pLZ_code_buf > &d->m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE - 8]) || - ((d->m_total_lz_bytes > 31 * 1024) && - (((((mz_uint)(d->m_pLZ_code_buf - d->m_lz_code_buf) * 115) >> 7) >= - d->m_total_lz_bytes) || - (d->m_flags & TDEFL_FORCE_ALL_RAW_BLOCKS)))) { - int n; - d->m_pSrc = pSrc; - d->m_src_buf_left = src_buf_left; - if ((n = tdefl_flush_block(d, 0)) != 0) - return (n < 0) ? MZ_FALSE : MZ_TRUE; - } - } - - d->m_pSrc = pSrc; - d->m_src_buf_left = src_buf_left; - return MZ_TRUE; -} - -static tdefl_status tdefl_flush_output_buffer(tdefl_compressor *d) { - if (d->m_pIn_buf_size) { - *d->m_pIn_buf_size = d->m_pSrc - (const mz_uint8 *)d->m_pIn_buf; - } - - if (d->m_pOut_buf_size) { - size_t n = MZ_MIN(*d->m_pOut_buf_size - d->m_out_buf_ofs, - d->m_output_flush_remaining); - memcpy((mz_uint8 *)d->m_pOut_buf + d->m_out_buf_ofs, - d->m_output_buf + d->m_output_flush_ofs, n); - d->m_output_flush_ofs += (mz_uint)n; - d->m_output_flush_remaining -= (mz_uint)n; - d->m_out_buf_ofs += n; - - *d->m_pOut_buf_size = d->m_out_buf_ofs; - } - - return (d->m_finished && !d->m_output_flush_remaining) ? TDEFL_STATUS_DONE - : TDEFL_STATUS_OKAY; -} - -tdefl_status tdefl_compress(tdefl_compressor *d, const void *pIn_buf, - size_t *pIn_buf_size, void *pOut_buf, - size_t *pOut_buf_size, tdefl_flush flush) { - if (!d) { - if (pIn_buf_size) *pIn_buf_size = 0; - if (pOut_buf_size) *pOut_buf_size = 0; - return TDEFL_STATUS_BAD_PARAM; - } - - d->m_pIn_buf = pIn_buf; - d->m_pIn_buf_size = pIn_buf_size; - d->m_pOut_buf = pOut_buf; - d->m_pOut_buf_size = pOut_buf_size; - d->m_pSrc = (const mz_uint8 *)(pIn_buf); - d->m_src_buf_left = pIn_buf_size ? *pIn_buf_size : 0; - d->m_out_buf_ofs = 0; - d->m_flush = flush; - - if (((d->m_pPut_buf_func != NULL) == - ((pOut_buf != NULL) || (pOut_buf_size != NULL))) || - (d->m_prev_return_status != TDEFL_STATUS_OKAY) || - (d->m_wants_to_finish && (flush != TDEFL_FINISH)) || - (pIn_buf_size && *pIn_buf_size && !pIn_buf) || - (pOut_buf_size && *pOut_buf_size && !pOut_buf)) { - if (pIn_buf_size) *pIn_buf_size = 0; - if (pOut_buf_size) *pOut_buf_size = 0; - return (d->m_prev_return_status = TDEFL_STATUS_BAD_PARAM); - } - d->m_wants_to_finish |= (flush == TDEFL_FINISH); - - if ((d->m_output_flush_remaining) || (d->m_finished)) - return (d->m_prev_return_status = tdefl_flush_output_buffer(d)); - -#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN - if (((d->m_flags & TDEFL_MAX_PROBES_MASK) == 1) && - ((d->m_flags & TDEFL_GREEDY_PARSING_FLAG) != 0) && - ((d->m_flags & (TDEFL_FILTER_MATCHES | TDEFL_FORCE_ALL_RAW_BLOCKS | - TDEFL_RLE_MATCHES)) == 0)) { - if (!tdefl_compress_fast(d)) return d->m_prev_return_status; - } else -#endif // #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN - { - if (!tdefl_compress_normal(d)) return d->m_prev_return_status; - } - - if ((d->m_flags & (TDEFL_WRITE_ZLIB_HEADER | TDEFL_COMPUTE_ADLER32)) && - (pIn_buf)) - d->m_adler32 = - (mz_uint32)mz_adler32(d->m_adler32, (const mz_uint8 *)pIn_buf, - d->m_pSrc - (const mz_uint8 *)pIn_buf); - - if ((flush) && (!d->m_lookahead_size) && (!d->m_src_buf_left) && - (!d->m_output_flush_remaining)) { - if (tdefl_flush_block(d, flush) < 0) return d->m_prev_return_status; - d->m_finished = (flush == TDEFL_FINISH); - if (flush == TDEFL_FULL_FLUSH) { - MZ_CLEAR_OBJ(d->m_hash); - MZ_CLEAR_OBJ(d->m_next); - d->m_dict_size = 0; - } - } - - return (d->m_prev_return_status = tdefl_flush_output_buffer(d)); -} - -tdefl_status tdefl_compress_buffer(tdefl_compressor *d, const void *pIn_buf, - size_t in_buf_size, tdefl_flush flush) { - MZ_ASSERT(d->m_pPut_buf_func); - return tdefl_compress(d, pIn_buf, &in_buf_size, NULL, NULL, flush); -} - -tdefl_status tdefl_init(tdefl_compressor *d, - tdefl_put_buf_func_ptr pPut_buf_func, - void *pPut_buf_user, int flags) { - d->m_pPut_buf_func = pPut_buf_func; - d->m_pPut_buf_user = pPut_buf_user; - d->m_flags = (mz_uint)(flags); - d->m_max_probes[0] = 1 + ((flags & 0xFFF) + 2) / 3; - d->m_greedy_parsing = (flags & TDEFL_GREEDY_PARSING_FLAG) != 0; - d->m_max_probes[1] = 1 + (((flags & 0xFFF) >> 2) + 2) / 3; - if (!(flags & TDEFL_NONDETERMINISTIC_PARSING_FLAG)) MZ_CLEAR_OBJ(d->m_hash); - d->m_lookahead_pos = d->m_lookahead_size = d->m_dict_size = - d->m_total_lz_bytes = d->m_lz_code_buf_dict_pos = d->m_bits_in = 0; - d->m_output_flush_ofs = d->m_output_flush_remaining = d->m_finished = - d->m_block_index = d->m_bit_buffer = d->m_wants_to_finish = 0; - d->m_pLZ_code_buf = d->m_lz_code_buf + 1; - d->m_pLZ_flags = d->m_lz_code_buf; - d->m_num_flags_left = 8; - d->m_pOutput_buf = d->m_output_buf; - d->m_pOutput_buf_end = d->m_output_buf; - d->m_prev_return_status = TDEFL_STATUS_OKAY; - d->m_saved_match_dist = d->m_saved_match_len = d->m_saved_lit = 0; - d->m_adler32 = 1; - d->m_pIn_buf = NULL; - d->m_pOut_buf = NULL; - d->m_pIn_buf_size = NULL; - d->m_pOut_buf_size = NULL; - d->m_flush = TDEFL_NO_FLUSH; - d->m_pSrc = NULL; - d->m_src_buf_left = 0; - d->m_out_buf_ofs = 0; - memset(&d->m_huff_count[0][0], 0, - sizeof(d->m_huff_count[0][0]) * TDEFL_MAX_HUFF_SYMBOLS_0); - memset(&d->m_huff_count[1][0], 0, - sizeof(d->m_huff_count[1][0]) * TDEFL_MAX_HUFF_SYMBOLS_1); - return TDEFL_STATUS_OKAY; -} - -tdefl_status tdefl_get_prev_return_status(tdefl_compressor *d) { - return d->m_prev_return_status; -} - -mz_uint32 tdefl_get_adler32(tdefl_compressor *d) { return d->m_adler32; } - -mz_bool tdefl_compress_mem_to_output(const void *pBuf, size_t buf_len, - tdefl_put_buf_func_ptr pPut_buf_func, - void *pPut_buf_user, int flags) { - tdefl_compressor *pComp; - mz_bool succeeded; - if (((buf_len) && (!pBuf)) || (!pPut_buf_func)) return MZ_FALSE; - pComp = (tdefl_compressor *)MZ_MALLOC(sizeof(tdefl_compressor)); - if (!pComp) return MZ_FALSE; - succeeded = (tdefl_init(pComp, pPut_buf_func, pPut_buf_user, flags) == - TDEFL_STATUS_OKAY); - succeeded = - succeeded && (tdefl_compress_buffer(pComp, pBuf, buf_len, TDEFL_FINISH) == - TDEFL_STATUS_DONE); - MZ_FREE(pComp); - return succeeded; -} - -typedef struct { - size_t m_size, m_capacity; - mz_uint8 *m_pBuf; - mz_bool m_expandable; -} tdefl_output_buffer; - -static mz_bool tdefl_output_buffer_putter(const void *pBuf, int len, - void *pUser) { - tdefl_output_buffer *p = (tdefl_output_buffer *)pUser; - size_t new_size = p->m_size + len; - if (new_size > p->m_capacity) { - size_t new_capacity = p->m_capacity; - mz_uint8 *pNew_buf; - if (!p->m_expandable) return MZ_FALSE; - do { - new_capacity = MZ_MAX(128U, new_capacity << 1U); - } while (new_size > new_capacity); - pNew_buf = (mz_uint8 *)MZ_REALLOC(p->m_pBuf, new_capacity); - if (!pNew_buf) return MZ_FALSE; - p->m_pBuf = pNew_buf; - p->m_capacity = new_capacity; - } - memcpy((mz_uint8 *)p->m_pBuf + p->m_size, pBuf, len); - p->m_size = new_size; - return MZ_TRUE; -} - -void *tdefl_compress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, - size_t *pOut_len, int flags) { - tdefl_output_buffer out_buf; - MZ_CLEAR_OBJ(out_buf); - if (!pOut_len) - return MZ_FALSE; - else - *pOut_len = 0; - out_buf.m_expandable = MZ_TRUE; - if (!tdefl_compress_mem_to_output( - pSrc_buf, src_buf_len, tdefl_output_buffer_putter, &out_buf, flags)) - return NULL; - *pOut_len = out_buf.m_size; - return out_buf.m_pBuf; -} - -size_t tdefl_compress_mem_to_mem(void *pOut_buf, size_t out_buf_len, - const void *pSrc_buf, size_t src_buf_len, - int flags) { - tdefl_output_buffer out_buf; - MZ_CLEAR_OBJ(out_buf); - if (!pOut_buf) return 0; - out_buf.m_pBuf = (mz_uint8 *)pOut_buf; - out_buf.m_capacity = out_buf_len; - if (!tdefl_compress_mem_to_output( - pSrc_buf, src_buf_len, tdefl_output_buffer_putter, &out_buf, flags)) - return 0; - return out_buf.m_size; -} - -#ifndef MINIZ_NO_ZLIB_APIS -static const mz_uint s_tdefl_num_probes[11] = {0, 1, 6, 32, 16, 32, - 128, 256, 512, 768, 1500}; - -// level may actually range from [0,10] (10 is a "hidden" max level, where we -// want a bit more compression and it's fine if throughput to fall off a cliff -// on some files). -mz_uint tdefl_create_comp_flags_from_zip_params(int level, int window_bits, - int strategy) { - mz_uint comp_flags = - s_tdefl_num_probes[(level >= 0) ? MZ_MIN(10, level) : MZ_DEFAULT_LEVEL] | - ((level <= 3) ? TDEFL_GREEDY_PARSING_FLAG : 0); - if (window_bits > 0) comp_flags |= TDEFL_WRITE_ZLIB_HEADER; - - if (!level) - comp_flags |= TDEFL_FORCE_ALL_RAW_BLOCKS; - else if (strategy == MZ_FILTERED) - comp_flags |= TDEFL_FILTER_MATCHES; - else if (strategy == MZ_HUFFMAN_ONLY) - comp_flags &= ~TDEFL_MAX_PROBES_MASK; - else if (strategy == MZ_FIXED) - comp_flags |= TDEFL_FORCE_ALL_STATIC_BLOCKS; - else if (strategy == MZ_RLE) - comp_flags |= TDEFL_RLE_MATCHES; - - return comp_flags; -} -#endif // MINIZ_NO_ZLIB_APIS - -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4204) // nonstandard extension used : non-constant - // aggregate initializer (also supported by GNU - // C and C99, so no big deal) -#pragma warning(disable : 4244) // 'initializing': conversion from '__int64' to - // 'int', possible loss of data -#pragma warning(disable : 4267) // 'argument': conversion from '__int64' to - // 'int', possible loss of data -#pragma warning(disable : 4996) // 'strdup': The POSIX name for this item is - // deprecated. Instead, use the ISO C and C++ - // conformant name: _strdup. -#endif - -// Simple PNG writer function by Alex Evans, 2011. Released into the public -// domain: https://gist.github.com/908299, more context at -// http://altdevblogaday.org/2011/04/06/a-smaller-jpg-encoder/. -// This is actually a modification of Alex's original code so PNG files -// generated by this function pass pngcheck. -void *tdefl_write_image_to_png_file_in_memory_ex(const void *pImage, int w, - int h, int num_chans, - size_t *pLen_out, - mz_uint level, mz_bool flip) { - // Using a local copy of this array here in case MINIZ_NO_ZLIB_APIS was - // defined. - static const mz_uint s_tdefl_png_num_probes[11] = { - 0, 1, 6, 32, 16, 32, 128, 256, 512, 768, 1500}; - tdefl_compressor *pComp = - (tdefl_compressor *)MZ_MALLOC(sizeof(tdefl_compressor)); - tdefl_output_buffer out_buf; - int i, bpl = w * num_chans, y, z; - mz_uint32 c; - *pLen_out = 0; - if (!pComp) return NULL; - MZ_CLEAR_OBJ(out_buf); - out_buf.m_expandable = MZ_TRUE; - out_buf.m_capacity = 57 + MZ_MAX(64, (1 + bpl) * h); - if (NULL == (out_buf.m_pBuf = (mz_uint8 *)MZ_MALLOC(out_buf.m_capacity))) { - MZ_FREE(pComp); - return NULL; - } - // write dummy header - for (z = 41; z; --z) tdefl_output_buffer_putter(&z, 1, &out_buf); - // compress image data - tdefl_init( - pComp, tdefl_output_buffer_putter, &out_buf, - s_tdefl_png_num_probes[MZ_MIN(10, level)] | TDEFL_WRITE_ZLIB_HEADER); - for (y = 0; y < h; ++y) { - tdefl_compress_buffer(pComp, &z, 1, TDEFL_NO_FLUSH); - tdefl_compress_buffer(pComp, - (mz_uint8 *)pImage + (flip ? (h - 1 - y) : y) * bpl, - bpl, TDEFL_NO_FLUSH); - } - if (tdefl_compress_buffer(pComp, NULL, 0, TDEFL_FINISH) != - TDEFL_STATUS_DONE) { - MZ_FREE(pComp); - MZ_FREE(out_buf.m_pBuf); - return NULL; - } - // write real header - *pLen_out = out_buf.m_size - 41; - { - static const mz_uint8 chans[] = {0x00, 0x00, 0x04, 0x02, 0x06}; - mz_uint8 pnghdr[41] = {0x89, - 0x50, - 0x4e, - 0x47, - 0x0d, - 0x0a, - 0x1a, - 0x0a, - 0x00, - 0x00, - 0x00, - 0x0d, - 0x49, - 0x48, - 0x44, - 0x52, - 0, - 0, - (mz_uint8)(w >> 8), - (mz_uint8)w, - 0, - 0, - (mz_uint8)(h >> 8), - (mz_uint8)h, - 8, - chans[num_chans], - 0, - 0, - 0, - 0, - 0, - 0, - 0, - (mz_uint8)(*pLen_out >> 24), - (mz_uint8)(*pLen_out >> 16), - (mz_uint8)(*pLen_out >> 8), - (mz_uint8)*pLen_out, - 0x49, - 0x44, - 0x41, - 0x54}; - c = (mz_uint32)mz_crc32(MZ_CRC32_INIT, pnghdr + 12, 17); - for (i = 0; i < 4; ++i, c <<= 8) - ((mz_uint8 *)(pnghdr + 29))[i] = (mz_uint8)(c >> 24); - memcpy(out_buf.m_pBuf, pnghdr, 41); - } - // write footer (IDAT CRC-32, followed by IEND chunk) - if (!tdefl_output_buffer_putter( - "\0\0\0\0\0\0\0\0\x49\x45\x4e\x44\xae\x42\x60\x82", 16, &out_buf)) { - *pLen_out = 0; - MZ_FREE(pComp); - MZ_FREE(out_buf.m_pBuf); - return NULL; - } - c = (mz_uint32)mz_crc32(MZ_CRC32_INIT, out_buf.m_pBuf + 41 - 4, - *pLen_out + 4); - for (i = 0; i < 4; ++i, c <<= 8) - (out_buf.m_pBuf + out_buf.m_size - 16)[i] = (mz_uint8)(c >> 24); - // compute final size of file, grab compressed data buffer and return - *pLen_out += 57; - MZ_FREE(pComp); - return out_buf.m_pBuf; -} -void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, - int num_chans, size_t *pLen_out) { - // Level 6 corresponds to TDEFL_DEFAULT_MAX_PROBES or MZ_DEFAULT_LEVEL (but we - // can't depend on MZ_DEFAULT_LEVEL being available in case the zlib API's - // where #defined out) - return tdefl_write_image_to_png_file_in_memory_ex(pImage, w, h, num_chans, - pLen_out, 6, MZ_FALSE); -} - -// ------------------- .ZIP archive reading - -#ifndef MINIZ_NO_ARCHIVE_APIS -#error "No arvhive APIs" - -#ifdef MINIZ_NO_STDIO -#define MZ_FILE void * -#else -#include <stdio.h> -#include <sys/stat.h> - -#if defined(_MSC_VER) || defined(__MINGW64__) -static FILE *mz_fopen(const char *pFilename, const char *pMode) { - FILE *pFile = NULL; - fopen_s(&pFile, pFilename, pMode); - return pFile; -} -static FILE *mz_freopen(const char *pPath, const char *pMode, FILE *pStream) { - FILE *pFile = NULL; - if (freopen_s(&pFile, pPath, pMode, pStream)) return NULL; - return pFile; -} -#ifndef MINIZ_NO_TIME -#include <sys/utime.h> -#endif -#define MZ_FILE FILE -#define MZ_FOPEN mz_fopen -#define MZ_FCLOSE fclose -#define MZ_FREAD fread -#define MZ_FWRITE fwrite -#define MZ_FTELL64 _ftelli64 -#define MZ_FSEEK64 _fseeki64 -#define MZ_FILE_STAT_STRUCT _stat -#define MZ_FILE_STAT _stat -#define MZ_FFLUSH fflush -#define MZ_FREOPEN mz_freopen -#define MZ_DELETE_FILE remove -#elif defined(__MINGW32__) -#ifndef MINIZ_NO_TIME -#include <sys/utime.h> -#endif -#define MZ_FILE FILE -#define MZ_FOPEN(f, m) fopen(f, m) -#define MZ_FCLOSE fclose -#define MZ_FREAD fread -#define MZ_FWRITE fwrite -#define MZ_FTELL64 ftello64 -#define MZ_FSEEK64 fseeko64 -#define MZ_FILE_STAT_STRUCT _stat -#define MZ_FILE_STAT _stat -#define MZ_FFLUSH fflush -#define MZ_FREOPEN(f, m, s) freopen(f, m, s) -#define MZ_DELETE_FILE remove -#elif defined(__TINYC__) -#ifndef MINIZ_NO_TIME -#include <sys/utime.h> -#endif -#define MZ_FILE FILE -#define MZ_FOPEN(f, m) fopen(f, m) -#define MZ_FCLOSE fclose -#define MZ_FREAD fread -#define MZ_FWRITE fwrite -#define MZ_FTELL64 ftell -#define MZ_FSEEK64 fseek -#define MZ_FILE_STAT_STRUCT stat -#define MZ_FILE_STAT stat -#define MZ_FFLUSH fflush -#define MZ_FREOPEN(f, m, s) freopen(f, m, s) -#define MZ_DELETE_FILE remove -#elif defined(__GNUC__) && defined(_LARGEFILE64_SOURCE) && _LARGEFILE64_SOURCE -#ifndef MINIZ_NO_TIME -#include <utime.h> -#endif -#define MZ_FILE FILE -#define MZ_FOPEN(f, m) fopen64(f, m) -#define MZ_FCLOSE fclose -#define MZ_FREAD fread -#define MZ_FWRITE fwrite -#define MZ_FTELL64 ftello64 -#define MZ_FSEEK64 fseeko64 -#define MZ_FILE_STAT_STRUCT stat64 -#define MZ_FILE_STAT stat64 -#define MZ_FFLUSH fflush -#define MZ_FREOPEN(p, m, s) freopen64(p, m, s) -#define MZ_DELETE_FILE remove -#else -#ifndef MINIZ_NO_TIME -#include <utime.h> -#endif -#define MZ_FILE FILE -#define MZ_FOPEN(f, m) fopen(f, m) -#define MZ_FCLOSE fclose -#define MZ_FREAD fread -#define MZ_FWRITE fwrite -#define MZ_FTELL64 ftello -#define MZ_FSEEK64 fseeko -#define MZ_FILE_STAT_STRUCT stat -#define MZ_FILE_STAT stat -#define MZ_FFLUSH fflush -#define MZ_FREOPEN(f, m, s) freopen(f, m, s) -#define MZ_DELETE_FILE remove -#endif // #ifdef _MSC_VER -#endif // #ifdef MINIZ_NO_STDIO - -#define MZ_TOLOWER(c) ((((c) >= 'A') && ((c) <= 'Z')) ? ((c) - 'A' + 'a') : (c)) - -// Various ZIP archive enums. To completely avoid cross platform compiler -// alignment and platform endian issues, miniz.c doesn't use structs for any of -// this stuff. -enum { - // ZIP archive identifiers and record sizes - MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG = 0x06054b50, - MZ_ZIP_CENTRAL_DIR_HEADER_SIG = 0x02014b50, - MZ_ZIP_LOCAL_DIR_HEADER_SIG = 0x04034b50, - MZ_ZIP_LOCAL_DIR_HEADER_SIZE = 30, - MZ_ZIP_CENTRAL_DIR_HEADER_SIZE = 46, - MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE = 22, - // Central directory header record offsets - MZ_ZIP_CDH_SIG_OFS = 0, - MZ_ZIP_CDH_VERSION_MADE_BY_OFS = 4, - MZ_ZIP_CDH_VERSION_NEEDED_OFS = 6, - MZ_ZIP_CDH_BIT_FLAG_OFS = 8, - MZ_ZIP_CDH_METHOD_OFS = 10, - MZ_ZIP_CDH_FILE_TIME_OFS = 12, - MZ_ZIP_CDH_FILE_DATE_OFS = 14, - MZ_ZIP_CDH_CRC32_OFS = 16, - MZ_ZIP_CDH_COMPRESSED_SIZE_OFS = 20, - MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS = 24, - MZ_ZIP_CDH_FILENAME_LEN_OFS = 28, - MZ_ZIP_CDH_EXTRA_LEN_OFS = 30, - MZ_ZIP_CDH_COMMENT_LEN_OFS = 32, - MZ_ZIP_CDH_DISK_START_OFS = 34, - MZ_ZIP_CDH_INTERNAL_ATTR_OFS = 36, - MZ_ZIP_CDH_EXTERNAL_ATTR_OFS = 38, - MZ_ZIP_CDH_LOCAL_HEADER_OFS = 42, - // Local directory header offsets - MZ_ZIP_LDH_SIG_OFS = 0, - MZ_ZIP_LDH_VERSION_NEEDED_OFS = 4, - MZ_ZIP_LDH_BIT_FLAG_OFS = 6, - MZ_ZIP_LDH_METHOD_OFS = 8, - MZ_ZIP_LDH_FILE_TIME_OFS = 10, - MZ_ZIP_LDH_FILE_DATE_OFS = 12, - MZ_ZIP_LDH_CRC32_OFS = 14, - MZ_ZIP_LDH_COMPRESSED_SIZE_OFS = 18, - MZ_ZIP_LDH_DECOMPRESSED_SIZE_OFS = 22, - MZ_ZIP_LDH_FILENAME_LEN_OFS = 26, - MZ_ZIP_LDH_EXTRA_LEN_OFS = 28, - // End of central directory offsets - MZ_ZIP_ECDH_SIG_OFS = 0, - MZ_ZIP_ECDH_NUM_THIS_DISK_OFS = 4, - MZ_ZIP_ECDH_NUM_DISK_CDIR_OFS = 6, - MZ_ZIP_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS = 8, - MZ_ZIP_ECDH_CDIR_TOTAL_ENTRIES_OFS = 10, - MZ_ZIP_ECDH_CDIR_SIZE_OFS = 12, - MZ_ZIP_ECDH_CDIR_OFS_OFS = 16, - MZ_ZIP_ECDH_COMMENT_SIZE_OFS = 20, -}; - -typedef struct { - void *m_p; - size_t m_size, m_capacity; - mz_uint m_element_size; -} mz_zip_array; - -struct mz_zip_internal_state_tag { - mz_zip_array m_central_dir; - mz_zip_array m_central_dir_offsets; - mz_zip_array m_sorted_central_dir_offsets; - MZ_FILE *m_pFile; - void *m_pMem; - size_t m_mem_size; - size_t m_mem_capacity; -}; - -#define MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(array_ptr, element_size) \ - (array_ptr)->m_element_size = element_size -#define MZ_ZIP_ARRAY_ELEMENT(array_ptr, element_type, index) \ - ((element_type *)((array_ptr)->m_p))[index] - -static MZ_FORCEINLINE void mz_zip_array_clear(mz_zip_archive *pZip, - mz_zip_array *pArray) { - pZip->m_pFree(pZip->m_pAlloc_opaque, pArray->m_p); - memset(pArray, 0, sizeof(mz_zip_array)); -} - -static mz_bool mz_zip_array_ensure_capacity(mz_zip_archive *pZip, - mz_zip_array *pArray, - size_t min_new_capacity, - mz_uint growing) { - void *pNew_p; - size_t new_capacity = min_new_capacity; - MZ_ASSERT(pArray->m_element_size); - if (pArray->m_capacity >= min_new_capacity) return MZ_TRUE; - if (growing) { - new_capacity = MZ_MAX(1, pArray->m_capacity); - while (new_capacity < min_new_capacity) new_capacity *= 2; - } - if (NULL == (pNew_p = pZip->m_pRealloc(pZip->m_pAlloc_opaque, pArray->m_p, - pArray->m_element_size, new_capacity))) - return MZ_FALSE; - pArray->m_p = pNew_p; - pArray->m_capacity = new_capacity; - return MZ_TRUE; -} - -static MZ_FORCEINLINE mz_bool mz_zip_array_reserve(mz_zip_archive *pZip, - mz_zip_array *pArray, - size_t new_capacity, - mz_uint growing) { - if (new_capacity > pArray->m_capacity) { - if (!mz_zip_array_ensure_capacity(pZip, pArray, new_capacity, growing)) - return MZ_FALSE; - } - return MZ_TRUE; -} - -static MZ_FORCEINLINE mz_bool mz_zip_array_resize(mz_zip_archive *pZip, - mz_zip_array *pArray, - size_t new_size, - mz_uint growing) { - if (new_size > pArray->m_capacity) { - if (!mz_zip_array_ensure_capacity(pZip, pArray, new_size, growing)) - return MZ_FALSE; - } - pArray->m_size = new_size; - return MZ_TRUE; -} - -static MZ_FORCEINLINE mz_bool mz_zip_array_ensure_room(mz_zip_archive *pZip, - mz_zip_array *pArray, - size_t n) { - return mz_zip_array_reserve(pZip, pArray, pArray->m_size + n, MZ_TRUE); -} - -static MZ_FORCEINLINE mz_bool mz_zip_array_push_back(mz_zip_archive *pZip, - mz_zip_array *pArray, - const void *pElements, - size_t n) { - size_t orig_size = pArray->m_size; - if (!mz_zip_array_resize(pZip, pArray, orig_size + n, MZ_TRUE)) - return MZ_FALSE; - memcpy((mz_uint8 *)pArray->m_p + orig_size * pArray->m_element_size, - pElements, n * pArray->m_element_size); - return MZ_TRUE; -} - -#ifndef MINIZ_NO_TIME -static time_t mz_zip_dos_to_time_t(int dos_time, int dos_date) { - struct tm tm; - memset(&tm, 0, sizeof(tm)); - tm.tm_isdst = -1; - tm.tm_year = ((dos_date >> 9) & 127) + 1980 - 1900; - tm.tm_mon = ((dos_date >> 5) & 15) - 1; - tm.tm_mday = dos_date & 31; - tm.tm_hour = (dos_time >> 11) & 31; - tm.tm_min = (dos_time >> 5) & 63; - tm.tm_sec = (dos_time << 1) & 62; - return mktime(&tm); -} - -static void mz_zip_time_to_dos_time(time_t time, mz_uint16 *pDOS_time, - mz_uint16 *pDOS_date) { -#ifdef _MSC_VER - struct tm tm_struct; - struct tm *tm = &tm_struct; - errno_t err = localtime_s(tm, &time); - if (err) { - *pDOS_date = 0; - *pDOS_time = 0; - return; - } -#else - struct tm *tm = localtime(&time); -#endif - *pDOS_time = (mz_uint16)(((tm->tm_hour) << 11) + ((tm->tm_min) << 5) + - ((tm->tm_sec) >> 1)); - *pDOS_date = (mz_uint16)(((tm->tm_year + 1900 - 1980) << 9) + - ((tm->tm_mon + 1) << 5) + tm->tm_mday); -} -#endif - -#ifndef MINIZ_NO_STDIO -static mz_bool mz_zip_get_file_modified_time(const char *pFilename, - mz_uint16 *pDOS_time, - mz_uint16 *pDOS_date) { -#ifdef MINIZ_NO_TIME - (void)pFilename; - *pDOS_date = *pDOS_time = 0; -#else - struct MZ_FILE_STAT_STRUCT file_stat; - // On Linux with x86 glibc, this call will fail on large files (>= 0x80000000 - // bytes) unless you compiled with _LARGEFILE64_SOURCE. Argh. - if (MZ_FILE_STAT(pFilename, &file_stat) != 0) return MZ_FALSE; - mz_zip_time_to_dos_time(file_stat.st_mtime, pDOS_time, pDOS_date); -#endif // #ifdef MINIZ_NO_TIME - return MZ_TRUE; -} - -#ifndef MINIZ_NO_TIME -static mz_bool mz_zip_set_file_times(const char *pFilename, time_t access_time, - time_t modified_time) { - struct utimbuf t; - t.actime = access_time; - t.modtime = modified_time; - return !utime(pFilename, &t); -} -#endif // #ifndef MINIZ_NO_TIME -#endif // #ifndef MINIZ_NO_STDIO - -static mz_bool mz_zip_reader_init_internal(mz_zip_archive *pZip, - mz_uint32 flags) { - (void)flags; - if ((!pZip) || (pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_INVALID)) - return MZ_FALSE; - - if (!pZip->m_pAlloc) pZip->m_pAlloc = def_alloc_func; - if (!pZip->m_pFree) pZip->m_pFree = def_free_func; - if (!pZip->m_pRealloc) pZip->m_pRealloc = def_realloc_func; - - pZip->m_zip_mode = MZ_ZIP_MODE_READING; - pZip->m_archive_size = 0; - pZip->m_central_directory_file_ofs = 0; - pZip->m_total_files = 0; - - if (NULL == (pZip->m_pState = (mz_zip_internal_state *)pZip->m_pAlloc( - pZip->m_pAlloc_opaque, 1, sizeof(mz_zip_internal_state)))) - return MZ_FALSE; - memset(pZip->m_pState, 0, sizeof(mz_zip_internal_state)); - MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir, - sizeof(mz_uint8)); - MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir_offsets, - sizeof(mz_uint32)); - MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_sorted_central_dir_offsets, - sizeof(mz_uint32)); - return MZ_TRUE; -} - -static MZ_FORCEINLINE mz_bool -mz_zip_reader_filename_less(const mz_zip_array *pCentral_dir_array, - const mz_zip_array *pCentral_dir_offsets, - mz_uint l_index, mz_uint r_index) { - const mz_uint8 *pL = &MZ_ZIP_ARRAY_ELEMENT( - pCentral_dir_array, mz_uint8, - MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32, - l_index)), - *pE; - const mz_uint8 *pR = &MZ_ZIP_ARRAY_ELEMENT( - pCentral_dir_array, mz_uint8, - MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32, r_index)); - mz_uint l_len = MZ_READ_LE16(pL + MZ_ZIP_CDH_FILENAME_LEN_OFS), - r_len = MZ_READ_LE16(pR + MZ_ZIP_CDH_FILENAME_LEN_OFS); - mz_uint8 l = 0, r = 0; - pL += MZ_ZIP_CENTRAL_DIR_HEADER_SIZE; - pR += MZ_ZIP_CENTRAL_DIR_HEADER_SIZE; - pE = pL + MZ_MIN(l_len, r_len); - while (pL < pE) { - if ((l = MZ_TOLOWER(*pL)) != (r = MZ_TOLOWER(*pR))) break; - pL++; - pR++; - } - return (pL == pE) ? (l_len < r_len) : (l < r); -} - -#define MZ_SWAP_UINT32(a, b) \ - do { \ - mz_uint32 t = a; \ - a = b; \ - b = t; \ - } \ - MZ_MACRO_END - -// Heap sort of lowercased filenames, used to help accelerate plain central -// directory searches by mz_zip_reader_locate_file(). (Could also use qsort(), -// but it could allocate memory.) -static void mz_zip_reader_sort_central_dir_offsets_by_filename( - mz_zip_archive *pZip) { - mz_zip_internal_state *pState = pZip->m_pState; - const mz_zip_array *pCentral_dir_offsets = &pState->m_central_dir_offsets; - const mz_zip_array *pCentral_dir = &pState->m_central_dir; - mz_uint32 *pIndices = &MZ_ZIP_ARRAY_ELEMENT( - &pState->m_sorted_central_dir_offsets, mz_uint32, 0); - const int size = pZip->m_total_files; - int start = (size - 2) >> 1, end; - while (start >= 0) { - int child, root = start; - for (;;) { - if ((child = (root << 1) + 1) >= size) break; - child += - (((child + 1) < size) && - (mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, - pIndices[child], pIndices[child + 1]))); - if (!mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, - pIndices[root], pIndices[child])) - break; - MZ_SWAP_UINT32(pIndices[root], pIndices[child]); - root = child; - } - start--; - } - - end = size - 1; - while (end > 0) { - int child, root = 0; - MZ_SWAP_UINT32(pIndices[end], pIndices[0]); - for (;;) { - if ((child = (root << 1) + 1) >= end) break; - child += - (((child + 1) < end) && - mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, - pIndices[child], pIndices[child + 1])); - if (!mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, - pIndices[root], pIndices[child])) - break; - MZ_SWAP_UINT32(pIndices[root], pIndices[child]); - root = child; - } - end--; - } -} - -static mz_bool mz_zip_reader_read_central_dir(mz_zip_archive *pZip, - mz_uint32 flags) { - mz_uint cdir_size, num_this_disk, cdir_disk_index; - mz_uint64 cdir_ofs; - mz_int64 cur_file_ofs; - const mz_uint8 *p; - mz_uint32 buf_u32[4096 / sizeof(mz_uint32)]; - mz_uint8 *pBuf = (mz_uint8 *)buf_u32; - mz_bool sort_central_dir = - ((flags & MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY) == 0); - // Basic sanity checks - reject files which are too small, and check the first - // 4 bytes of the file to make sure a local header is there. - if (pZip->m_archive_size < MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) - return MZ_FALSE; - // Find the end of central directory record by scanning the file from the end - // towards the beginning. - cur_file_ofs = - MZ_MAX((mz_int64)pZip->m_archive_size - (mz_int64)sizeof(buf_u32), 0); - for (;;) { - int i, - n = (int)MZ_MIN(sizeof(buf_u32), pZip->m_archive_size - cur_file_ofs); - if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pBuf, n) != (mz_uint)n) - return MZ_FALSE; - for (i = n - 4; i >= 0; --i) - if (MZ_READ_LE32(pBuf + i) == MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG) break; - if (i >= 0) { - cur_file_ofs += i; - break; - } - if ((!cur_file_ofs) || ((pZip->m_archive_size - cur_file_ofs) >= - (0xFFFF + MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE))) - return MZ_FALSE; - cur_file_ofs = MZ_MAX(cur_file_ofs - (sizeof(buf_u32) - 3), 0); - } - // Read and verify the end of central directory record. - if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pBuf, - MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) != - MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) - return MZ_FALSE; - if ((MZ_READ_LE32(pBuf + MZ_ZIP_ECDH_SIG_OFS) != - MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG) || - ((pZip->m_total_files = - MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_CDIR_TOTAL_ENTRIES_OFS)) != - MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS))) - return MZ_FALSE; - - num_this_disk = MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_NUM_THIS_DISK_OFS); - cdir_disk_index = MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_NUM_DISK_CDIR_OFS); - if (((num_this_disk | cdir_disk_index) != 0) && - ((num_this_disk != 1) || (cdir_disk_index != 1))) - return MZ_FALSE; - - if ((cdir_size = MZ_READ_LE32(pBuf + MZ_ZIP_ECDH_CDIR_SIZE_OFS)) < - pZip->m_total_files * MZ_ZIP_CENTRAL_DIR_HEADER_SIZE) - return MZ_FALSE; - - cdir_ofs = MZ_READ_LE32(pBuf + MZ_ZIP_ECDH_CDIR_OFS_OFS); - if ((cdir_ofs + (mz_uint64)cdir_size) > pZip->m_archive_size) return MZ_FALSE; - - pZip->m_central_directory_file_ofs = cdir_ofs; - - if (pZip->m_total_files) { - mz_uint i, n; - - // Read the entire central directory into a heap block, and allocate another - // heap block to hold the unsorted central dir file record offsets, and - // another to hold the sorted indices. - if ((!mz_zip_array_resize(pZip, &pZip->m_pState->m_central_dir, cdir_size, - MZ_FALSE)) || - (!mz_zip_array_resize(pZip, &pZip->m_pState->m_central_dir_offsets, - pZip->m_total_files, MZ_FALSE))) - return MZ_FALSE; - - if (sort_central_dir) { - if (!mz_zip_array_resize(pZip, - &pZip->m_pState->m_sorted_central_dir_offsets, - pZip->m_total_files, MZ_FALSE)) - return MZ_FALSE; - } - - if (pZip->m_pRead(pZip->m_pIO_opaque, cdir_ofs, - pZip->m_pState->m_central_dir.m_p, - cdir_size) != cdir_size) - return MZ_FALSE; - - // Now create an index into the central directory file records, do some - // basic sanity checking on each record, and check for zip64 entries (which - // are not yet supported). - p = (const mz_uint8 *)pZip->m_pState->m_central_dir.m_p; - for (n = cdir_size, i = 0; i < pZip->m_total_files; ++i) { - mz_uint total_header_size, comp_size, decomp_size, disk_index; - if ((n < MZ_ZIP_CENTRAL_DIR_HEADER_SIZE) || - (MZ_READ_LE32(p) != MZ_ZIP_CENTRAL_DIR_HEADER_SIG)) - return MZ_FALSE; - MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32, - i) = - (mz_uint32)(p - (const mz_uint8 *)pZip->m_pState->m_central_dir.m_p); - if (sort_central_dir) - MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_sorted_central_dir_offsets, - mz_uint32, i) = i; - comp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS); - decomp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS); - if (((!MZ_READ_LE32(p + MZ_ZIP_CDH_METHOD_OFS)) && - (decomp_size != comp_size)) || - (decomp_size && !comp_size) || (decomp_size == 0xFFFFFFFF) || - (comp_size == 0xFFFFFFFF)) - return MZ_FALSE; - disk_index = MZ_READ_LE16(p + MZ_ZIP_CDH_DISK_START_OFS); - if ((disk_index != num_this_disk) && (disk_index != 1)) return MZ_FALSE; - if (((mz_uint64)MZ_READ_LE32(p + MZ_ZIP_CDH_LOCAL_HEADER_OFS) + - MZ_ZIP_LOCAL_DIR_HEADER_SIZE + comp_size) > pZip->m_archive_size) - return MZ_FALSE; - if ((total_header_size = MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + - MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS) + - MZ_READ_LE16(p + MZ_ZIP_CDH_EXTRA_LEN_OFS) + - MZ_READ_LE16(p + MZ_ZIP_CDH_COMMENT_LEN_OFS)) > - n) - return MZ_FALSE; - n -= total_header_size; - p += total_header_size; - } - } - - if (sort_central_dir) - mz_zip_reader_sort_central_dir_offsets_by_filename(pZip); - - return MZ_TRUE; -} - -mz_bool mz_zip_reader_init(mz_zip_archive *pZip, mz_uint64 size, - mz_uint32 flags) { - if ((!pZip) || (!pZip->m_pRead)) return MZ_FALSE; - if (!mz_zip_reader_init_internal(pZip, flags)) return MZ_FALSE; - pZip->m_archive_size = size; - if (!mz_zip_reader_read_central_dir(pZip, flags)) { - mz_zip_reader_end(pZip); - return MZ_FALSE; - } - return MZ_TRUE; -} - -static size_t mz_zip_mem_read_func(void *pOpaque, mz_uint64 file_ofs, - void *pBuf, size_t n) { - mz_zip_archive *pZip = (mz_zip_archive *)pOpaque; - size_t s = (file_ofs >= pZip->m_archive_size) - ? 0 - : (size_t)MZ_MIN(pZip->m_archive_size - file_ofs, n); - memcpy(pBuf, (const mz_uint8 *)pZip->m_pState->m_pMem + file_ofs, s); - return s; -} - -mz_bool mz_zip_reader_init_mem(mz_zip_archive *pZip, const void *pMem, - size_t size, mz_uint32 flags) { - if (!mz_zip_reader_init_internal(pZip, flags)) return MZ_FALSE; - pZip->m_archive_size = size; - pZip->m_pRead = mz_zip_mem_read_func; - pZip->m_pIO_opaque = pZip; -#ifdef __cplusplus - pZip->m_pState->m_pMem = const_cast<void *>(pMem); -#else - pZip->m_pState->m_pMem = (void *)pMem; -#endif - pZip->m_pState->m_mem_size = size; - if (!mz_zip_reader_read_central_dir(pZip, flags)) { - mz_zip_reader_end(pZip); - return MZ_FALSE; - } - return MZ_TRUE; -} - -#ifndef MINIZ_NO_STDIO -static size_t mz_zip_file_read_func(void *pOpaque, mz_uint64 file_ofs, - void *pBuf, size_t n) { - mz_zip_archive *pZip = (mz_zip_archive *)pOpaque; - mz_int64 cur_ofs = MZ_FTELL64(pZip->m_pState->m_pFile); - if (((mz_int64)file_ofs < 0) || - (((cur_ofs != (mz_int64)file_ofs)) && - (MZ_FSEEK64(pZip->m_pState->m_pFile, (mz_int64)file_ofs, SEEK_SET)))) - return 0; - return MZ_FREAD(pBuf, 1, n, pZip->m_pState->m_pFile); -} - -mz_bool mz_zip_reader_init_file(mz_zip_archive *pZip, const char *pFilename, - mz_uint32 flags) { - mz_uint64 file_size; - MZ_FILE *pFile = MZ_FOPEN(pFilename, "rb"); - if (!pFile) return MZ_FALSE; - if (MZ_FSEEK64(pFile, 0, SEEK_END)) { - MZ_FCLOSE(pFile); - return MZ_FALSE; - } - file_size = MZ_FTELL64(pFile); - if (!mz_zip_reader_init_internal(pZip, flags)) { - MZ_FCLOSE(pFile); - return MZ_FALSE; - } - pZip->m_pRead = mz_zip_file_read_func; - pZip->m_pIO_opaque = pZip; - pZip->m_pState->m_pFile = pFile; - pZip->m_archive_size = file_size; - if (!mz_zip_reader_read_central_dir(pZip, flags)) { - mz_zip_reader_end(pZip); - return MZ_FALSE; - } - return MZ_TRUE; -} -#endif // #ifndef MINIZ_NO_STDIO - -mz_uint mz_zip_reader_get_num_files(mz_zip_archive *pZip) { - return pZip ? pZip->m_total_files : 0; -} - -static MZ_FORCEINLINE const mz_uint8 *mz_zip_reader_get_cdh( - mz_zip_archive *pZip, mz_uint file_index) { - if ((!pZip) || (!pZip->m_pState) || (file_index >= pZip->m_total_files) || - (pZip->m_zip_mode != MZ_ZIP_MODE_READING)) - return NULL; - return &MZ_ZIP_ARRAY_ELEMENT( - &pZip->m_pState->m_central_dir, mz_uint8, - MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32, - file_index)); -} - -mz_bool mz_zip_reader_is_file_encrypted(mz_zip_archive *pZip, - mz_uint file_index) { - mz_uint m_bit_flag; - const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index); - if (!p) return MZ_FALSE; - m_bit_flag = MZ_READ_LE16(p + MZ_ZIP_CDH_BIT_FLAG_OFS); - return (m_bit_flag & 1); -} - -mz_bool mz_zip_reader_is_file_a_directory(mz_zip_archive *pZip, - mz_uint file_index) { - mz_uint filename_len, external_attr; - const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index); - if (!p) return MZ_FALSE; - - // First see if the filename ends with a '/' character. - filename_len = MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS); - if (filename_len) { - if (*(p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + filename_len - 1) == '/') - return MZ_TRUE; - } - - // Bugfix: This code was also checking if the internal attribute was non-zero, - // which wasn't correct. - // Most/all zip writers (hopefully) set DOS file/directory attributes in the - // low 16-bits, so check for the DOS directory flag and ignore the source OS - // ID in the created by field. - // FIXME: Remove this check? Is it necessary - we already check the filename. - external_attr = MZ_READ_LE32(p + MZ_ZIP_CDH_EXTERNAL_ATTR_OFS); - if ((external_attr & 0x10) != 0) return MZ_TRUE; - - return MZ_FALSE; -} - -mz_bool mz_zip_reader_file_stat(mz_zip_archive *pZip, mz_uint file_index, - mz_zip_archive_file_stat *pStat) { - mz_uint n; - const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index); - if ((!p) || (!pStat)) return MZ_FALSE; - - // Unpack the central directory record. - pStat->m_file_index = file_index; - pStat->m_central_dir_ofs = MZ_ZIP_ARRAY_ELEMENT( - &pZip->m_pState->m_central_dir_offsets, mz_uint32, file_index); - pStat->m_version_made_by = MZ_READ_LE16(p + MZ_ZIP_CDH_VERSION_MADE_BY_OFS); - pStat->m_version_needed = MZ_READ_LE16(p + MZ_ZIP_CDH_VERSION_NEEDED_OFS); - pStat->m_bit_flag = MZ_READ_LE16(p + MZ_ZIP_CDH_BIT_FLAG_OFS); - pStat->m_method = MZ_READ_LE16(p + MZ_ZIP_CDH_METHOD_OFS); -#ifndef MINIZ_NO_TIME - pStat->m_time = - mz_zip_dos_to_time_t(MZ_READ_LE16(p + MZ_ZIP_CDH_FILE_TIME_OFS), - MZ_READ_LE16(p + MZ_ZIP_CDH_FILE_DATE_OFS)); -#endif - pStat->m_crc32 = MZ_READ_LE32(p + MZ_ZIP_CDH_CRC32_OFS); - pStat->m_comp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS); - pStat->m_uncomp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS); - pStat->m_internal_attr = MZ_READ_LE16(p + MZ_ZIP_CDH_INTERNAL_ATTR_OFS); - pStat->m_external_attr = MZ_READ_LE32(p + MZ_ZIP_CDH_EXTERNAL_ATTR_OFS); - pStat->m_local_header_ofs = MZ_READ_LE32(p + MZ_ZIP_CDH_LOCAL_HEADER_OFS); - - // Copy as much of the filename and comment as possible. - n = MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS); - n = MZ_MIN(n, MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE - 1); - memcpy(pStat->m_filename, p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE, n); - pStat->m_filename[n] = '\0'; - - n = MZ_READ_LE16(p + MZ_ZIP_CDH_COMMENT_LEN_OFS); - n = MZ_MIN(n, MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE - 1); - pStat->m_comment_size = n; - memcpy(pStat->m_comment, - p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + - MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS) + - MZ_READ_LE16(p + MZ_ZIP_CDH_EXTRA_LEN_OFS), - n); - pStat->m_comment[n] = '\0'; - - return MZ_TRUE; -} - -mz_uint mz_zip_reader_get_filename(mz_zip_archive *pZip, mz_uint file_index, - char *pFilename, mz_uint filename_buf_size) { - mz_uint n; - const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index); - if (!p) { - if (filename_buf_size) pFilename[0] = '\0'; - return 0; - } - n = MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS); - if (filename_buf_size) { - n = MZ_MIN(n, filename_buf_size - 1); - memcpy(pFilename, p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE, n); - pFilename[n] = '\0'; - } - return n + 1; -} - -static MZ_FORCEINLINE mz_bool mz_zip_reader_string_equal(const char *pA, - const char *pB, - mz_uint len, - mz_uint flags) { - mz_uint i; - if (flags & MZ_ZIP_FLAG_CASE_SENSITIVE) return 0 == memcmp(pA, pB, len); - for (i = 0; i < len; ++i) - if (MZ_TOLOWER(pA[i]) != MZ_TOLOWER(pB[i])) return MZ_FALSE; - return MZ_TRUE; -} - -static MZ_FORCEINLINE int mz_zip_reader_filename_compare( - const mz_zip_array *pCentral_dir_array, - const mz_zip_array *pCentral_dir_offsets, mz_uint l_index, const char *pR, - mz_uint r_len) { - const mz_uint8 *pL = &MZ_ZIP_ARRAY_ELEMENT( - pCentral_dir_array, mz_uint8, - MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32, - l_index)), - *pE; - mz_uint l_len = MZ_READ_LE16(pL + MZ_ZIP_CDH_FILENAME_LEN_OFS); - mz_uint8 l = 0, r = 0; - pL += MZ_ZIP_CENTRAL_DIR_HEADER_SIZE; - pE = pL + MZ_MIN(l_len, r_len); - while (pL < pE) { - if ((l = MZ_TOLOWER(*pL)) != (r = MZ_TOLOWER(*pR))) break; - pL++; - pR++; - } - return (pL == pE) ? (int)(l_len - r_len) : (l - r); -} - -static int mz_zip_reader_locate_file_binary_search(mz_zip_archive *pZip, - const char *pFilename) { - mz_zip_internal_state *pState = pZip->m_pState; - const mz_zip_array *pCentral_dir_offsets = &pState->m_central_dir_offsets; - const mz_zip_array *pCentral_dir = &pState->m_central_dir; - mz_uint32 *pIndices = &MZ_ZIP_ARRAY_ELEMENT( - &pState->m_sorted_central_dir_offsets, mz_uint32, 0); - const int size = pZip->m_total_files; - const mz_uint filename_len = (mz_uint)strlen(pFilename); - int l = 0, h = size - 1; - while (l <= h) { - int m = (l + h) >> 1, file_index = pIndices[m], - comp = - mz_zip_reader_filename_compare(pCentral_dir, pCentral_dir_offsets, - file_index, pFilename, filename_len); - if (!comp) - return file_index; - else if (comp < 0) - l = m + 1; - else - h = m - 1; - } - return -1; -} - -int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, - const char *pComment, mz_uint flags) { - mz_uint file_index; - size_t name_len, comment_len; - if ((!pZip) || (!pZip->m_pState) || (!pName) || - (pZip->m_zip_mode != MZ_ZIP_MODE_READING)) - return -1; - if (((flags & (MZ_ZIP_FLAG_IGNORE_PATH | MZ_ZIP_FLAG_CASE_SENSITIVE)) == 0) && - (!pComment) && (pZip->m_pState->m_sorted_central_dir_offsets.m_size)) - return mz_zip_reader_locate_file_binary_search(pZip, pName); - name_len = strlen(pName); - if (name_len > 0xFFFF) return -1; - comment_len = pComment ? strlen(pComment) : 0; - if (comment_len > 0xFFFF) return -1; - for (file_index = 0; file_index < pZip->m_total_files; file_index++) { - const mz_uint8 *pHeader = &MZ_ZIP_ARRAY_ELEMENT( - &pZip->m_pState->m_central_dir, mz_uint8, - MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32, - file_index)); - mz_uint filename_len = MZ_READ_LE16(pHeader + MZ_ZIP_CDH_FILENAME_LEN_OFS); - const char *pFilename = - (const char *)pHeader + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE; - if (filename_len < name_len) continue; - if (comment_len) { - mz_uint file_extra_len = MZ_READ_LE16(pHeader + MZ_ZIP_CDH_EXTRA_LEN_OFS), - file_comment_len = - MZ_READ_LE16(pHeader + MZ_ZIP_CDH_COMMENT_LEN_OFS); - const char *pFile_comment = pFilename + filename_len + file_extra_len; - if ((file_comment_len != comment_len) || - (!mz_zip_reader_string_equal(pComment, pFile_comment, - file_comment_len, flags))) - continue; - } - if ((flags & MZ_ZIP_FLAG_IGNORE_PATH) && (filename_len)) { - int ofs = filename_len - 1; - do { - if ((pFilename[ofs] == '/') || (pFilename[ofs] == '\\') || - (pFilename[ofs] == ':')) - break; - } while (--ofs >= 0); - ofs++; - pFilename += ofs; - filename_len -= ofs; - } - if ((filename_len == name_len) && - (mz_zip_reader_string_equal(pName, pFilename, filename_len, flags))) - return file_index; - } - return -1; -} - -mz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive *pZip, - mz_uint file_index, void *pBuf, - size_t buf_size, mz_uint flags, - void *pUser_read_buf, - size_t user_read_buf_size) { - int status = TINFL_STATUS_DONE; - mz_uint64 needed_size, cur_file_ofs, comp_remaining, - out_buf_ofs = 0, read_buf_size, read_buf_ofs = 0, read_buf_avail; - mz_zip_archive_file_stat file_stat; - void *pRead_buf; - mz_uint32 - local_header_u32[(MZ_ZIP_LOCAL_DIR_HEADER_SIZE + sizeof(mz_uint32) - 1) / - sizeof(mz_uint32)]; - mz_uint8 *pLocal_header = (mz_uint8 *)local_header_u32; - tinfl_decompressor inflator; - - if ((buf_size) && (!pBuf)) return MZ_FALSE; - - if (!mz_zip_reader_file_stat(pZip, file_index, &file_stat)) return MZ_FALSE; - - // Empty file, or a directory (but not always a directory - I've seen odd zips - // with directories that have compressed data which inflates to 0 bytes) - if (!file_stat.m_comp_size) return MZ_TRUE; - - // Entry is a subdirectory (I've seen old zips with dir entries which have - // compressed deflate data which inflates to 0 bytes, but these entries claim - // to uncompress to 512 bytes in the headers). - // I'm torn how to handle this case - should it fail instead? - if (mz_zip_reader_is_file_a_directory(pZip, file_index)) return MZ_TRUE; - - // Encryption and patch files are not supported. - if (file_stat.m_bit_flag & (1 | 32)) return MZ_FALSE; - - // This function only supports stored and deflate. - if ((!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) && (file_stat.m_method != 0) && - (file_stat.m_method != MZ_DEFLATED)) - return MZ_FALSE; - - // Ensure supplied output buffer is large enough. - needed_size = (flags & MZ_ZIP_FLAG_COMPRESSED_DATA) ? file_stat.m_comp_size - : file_stat.m_uncomp_size; - if (buf_size < needed_size) return MZ_FALSE; - - // Read and parse the local directory entry. - cur_file_ofs = file_stat.m_local_header_ofs; - if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pLocal_header, - MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != - MZ_ZIP_LOCAL_DIR_HEADER_SIZE) - return MZ_FALSE; - if (MZ_READ_LE32(pLocal_header) != MZ_ZIP_LOCAL_DIR_HEADER_SIG) - return MZ_FALSE; - - cur_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE + - MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_FILENAME_LEN_OFS) + - MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_EXTRA_LEN_OFS); - if ((cur_file_ofs + file_stat.m_comp_size) > pZip->m_archive_size) - return MZ_FALSE; - - if ((flags & MZ_ZIP_FLAG_COMPRESSED_DATA) || (!file_stat.m_method)) { - // The file is stored or the caller has requested the compressed data. - if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pBuf, - (size_t)needed_size) != needed_size) - return MZ_FALSE; - return ((flags & MZ_ZIP_FLAG_COMPRESSED_DATA) != 0) || - (mz_crc32(MZ_CRC32_INIT, (const mz_uint8 *)pBuf, - (size_t)file_stat.m_uncomp_size) == file_stat.m_crc32); - } - - // Decompress the file either directly from memory or from a file input - // buffer. - tinfl_init(&inflator); - - if (pZip->m_pState->m_pMem) { - // Read directly from the archive in memory. - pRead_buf = (mz_uint8 *)pZip->m_pState->m_pMem + cur_file_ofs; - read_buf_size = read_buf_avail = file_stat.m_comp_size; - comp_remaining = 0; - } else if (pUser_read_buf) { - // Use a user provided read buffer. - if (!user_read_buf_size) return MZ_FALSE; - pRead_buf = (mz_uint8 *)pUser_read_buf; - read_buf_size = user_read_buf_size; - read_buf_avail = 0; - comp_remaining = file_stat.m_comp_size; - } else { - // Temporarily allocate a read buffer. - read_buf_size = - MZ_MIN(file_stat.m_comp_size, (mz_uint)MZ_ZIP_MAX_IO_BUF_SIZE); -#ifdef _MSC_VER - if (((0, sizeof(size_t) == sizeof(mz_uint32))) && - (read_buf_size > 0x7FFFFFFF)) -#else - if (((sizeof(size_t) == sizeof(mz_uint32))) && (read_buf_size > 0x7FFFFFFF)) -#endif - return MZ_FALSE; - if (NULL == (pRead_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, - (size_t)read_buf_size))) - return MZ_FALSE; - read_buf_avail = 0; - comp_remaining = file_stat.m_comp_size; - } - - do { - size_t in_buf_size, - out_buf_size = (size_t)(file_stat.m_uncomp_size - out_buf_ofs); - if ((!read_buf_avail) && (!pZip->m_pState->m_pMem)) { - read_buf_avail = MZ_MIN(read_buf_size, comp_remaining); - if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pRead_buf, - (size_t)read_buf_avail) != read_buf_avail) { - status = TINFL_STATUS_FAILED; - break; - } - cur_file_ofs += read_buf_avail; - comp_remaining -= read_buf_avail; - read_buf_ofs = 0; - } - in_buf_size = (size_t)read_buf_avail; - status = tinfl_decompress( - &inflator, (mz_uint8 *)pRead_buf + read_buf_ofs, &in_buf_size, - (mz_uint8 *)pBuf, (mz_uint8 *)pBuf + out_buf_ofs, &out_buf_size, - TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF | - (comp_remaining ? TINFL_FLAG_HAS_MORE_INPUT : 0)); - read_buf_avail -= in_buf_size; - read_buf_ofs += in_buf_size; - out_buf_ofs += out_buf_size; - } while (status == TINFL_STATUS_NEEDS_MORE_INPUT); - - if (status == TINFL_STATUS_DONE) { - // Make sure the entire file was decompressed, and check its CRC. - if ((out_buf_ofs != file_stat.m_uncomp_size) || - (mz_crc32(MZ_CRC32_INIT, (const mz_uint8 *)pBuf, - (size_t)file_stat.m_uncomp_size) != file_stat.m_crc32)) - status = TINFL_STATUS_FAILED; - } - - if ((!pZip->m_pState->m_pMem) && (!pUser_read_buf)) - pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); - - return status == TINFL_STATUS_DONE; -} - -mz_bool mz_zip_reader_extract_file_to_mem_no_alloc( - mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, - mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size) { - int file_index = mz_zip_reader_locate_file(pZip, pFilename, NULL, flags); - if (file_index < 0) return MZ_FALSE; - return mz_zip_reader_extract_to_mem_no_alloc(pZip, file_index, pBuf, buf_size, - flags, pUser_read_buf, - user_read_buf_size); -} - -mz_bool mz_zip_reader_extract_to_mem(mz_zip_archive *pZip, mz_uint file_index, - void *pBuf, size_t buf_size, - mz_uint flags) { - return mz_zip_reader_extract_to_mem_no_alloc(pZip, file_index, pBuf, buf_size, - flags, NULL, 0); -} - -mz_bool mz_zip_reader_extract_file_to_mem(mz_zip_archive *pZip, - const char *pFilename, void *pBuf, - size_t buf_size, mz_uint flags) { - return mz_zip_reader_extract_file_to_mem_no_alloc(pZip, pFilename, pBuf, - buf_size, flags, NULL, 0); -} - -void *mz_zip_reader_extract_to_heap(mz_zip_archive *pZip, mz_uint file_index, - size_t *pSize, mz_uint flags) { - mz_uint64 comp_size, uncomp_size, alloc_size; - const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index); - void *pBuf; - - if (pSize) *pSize = 0; - if (!p) return NULL; - - comp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS); - uncomp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS); - - alloc_size = (flags & MZ_ZIP_FLAG_COMPRESSED_DATA) ? comp_size : uncomp_size; -#ifdef _MSC_VER - if (((0, sizeof(size_t) == sizeof(mz_uint32))) && (alloc_size > 0x7FFFFFFF)) -#else - if (((sizeof(size_t) == sizeof(mz_uint32))) && (alloc_size > 0x7FFFFFFF)) -#endif - return NULL; - if (NULL == - (pBuf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)alloc_size))) - return NULL; - - if (!mz_zip_reader_extract_to_mem(pZip, file_index, pBuf, (size_t)alloc_size, - flags)) { - pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); - return NULL; - } - - if (pSize) *pSize = (size_t)alloc_size; - return pBuf; -} - -void *mz_zip_reader_extract_file_to_heap(mz_zip_archive *pZip, - const char *pFilename, size_t *pSize, - mz_uint flags) { - int file_index = mz_zip_reader_locate_file(pZip, pFilename, NULL, flags); - if (file_index < 0) { - if (pSize) *pSize = 0; - return MZ_FALSE; - } - return mz_zip_reader_extract_to_heap(pZip, file_index, pSize, flags); -} - -mz_bool mz_zip_reader_extract_to_callback(mz_zip_archive *pZip, - mz_uint file_index, - mz_file_write_func pCallback, - void *pOpaque, mz_uint flags) { - int status = TINFL_STATUS_DONE; - mz_uint file_crc32 = MZ_CRC32_INIT; - mz_uint64 read_buf_size, read_buf_ofs = 0, read_buf_avail, comp_remaining, - out_buf_ofs = 0, cur_file_ofs; - mz_zip_archive_file_stat file_stat; - void *pRead_buf = NULL; - void *pWrite_buf = NULL; - mz_uint32 - local_header_u32[(MZ_ZIP_LOCAL_DIR_HEADER_SIZE + sizeof(mz_uint32) - 1) / - sizeof(mz_uint32)]; - mz_uint8 *pLocal_header = (mz_uint8 *)local_header_u32; - - if (!mz_zip_reader_file_stat(pZip, file_index, &file_stat)) return MZ_FALSE; - - // Empty file, or a directory (but not always a directory - I've seen odd zips - // with directories that have compressed data which inflates to 0 bytes) - if (!file_stat.m_comp_size) return MZ_TRUE; - - // Entry is a subdirectory (I've seen old zips with dir entries which have - // compressed deflate data which inflates to 0 bytes, but these entries claim - // to uncompress to 512 bytes in the headers). - // I'm torn how to handle this case - should it fail instead? - if (mz_zip_reader_is_file_a_directory(pZip, file_index)) return MZ_TRUE; - - // Encryption and patch files are not supported. - if (file_stat.m_bit_flag & (1 | 32)) return MZ_FALSE; - - // This function only supports stored and deflate. - if ((!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) && (file_stat.m_method != 0) && - (file_stat.m_method != MZ_DEFLATED)) - return MZ_FALSE; - - // Read and parse the local directory entry. - cur_file_ofs = file_stat.m_local_header_ofs; - if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pLocal_header, - MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != - MZ_ZIP_LOCAL_DIR_HEADER_SIZE) - return MZ_FALSE; - if (MZ_READ_LE32(pLocal_header) != MZ_ZIP_LOCAL_DIR_HEADER_SIG) - return MZ_FALSE; - - cur_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE + - MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_FILENAME_LEN_OFS) + - MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_EXTRA_LEN_OFS); - if ((cur_file_ofs + file_stat.m_comp_size) > pZip->m_archive_size) - return MZ_FALSE; - - // Decompress the file either directly from memory or from a file input - // buffer. - if (pZip->m_pState->m_pMem) { - pRead_buf = (mz_uint8 *)pZip->m_pState->m_pMem + cur_file_ofs; - read_buf_size = read_buf_avail = file_stat.m_comp_size; - comp_remaining = 0; - } else { - read_buf_size = - MZ_MIN(file_stat.m_comp_size, (mz_uint)MZ_ZIP_MAX_IO_BUF_SIZE); - if (NULL == (pRead_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, - (size_t)read_buf_size))) - return MZ_FALSE; - read_buf_avail = 0; - comp_remaining = file_stat.m_comp_size; - } - - if ((flags & MZ_ZIP_FLAG_COMPRESSED_DATA) || (!file_stat.m_method)) { - // The file is stored or the caller has requested the compressed data. - if (pZip->m_pState->m_pMem) { -#ifdef _MSC_VER - if (((0, sizeof(size_t) == sizeof(mz_uint32))) && - (file_stat.m_comp_size > 0xFFFFFFFF)) -#else - if (((sizeof(size_t) == sizeof(mz_uint32))) && - (file_stat.m_comp_size > 0xFFFFFFFF)) -#endif - return MZ_FALSE; - if (pCallback(pOpaque, out_buf_ofs, pRead_buf, - (size_t)file_stat.m_comp_size) != file_stat.m_comp_size) - status = TINFL_STATUS_FAILED; - else if (!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) - file_crc32 = - (mz_uint32)mz_crc32(file_crc32, (const mz_uint8 *)pRead_buf, - (size_t)file_stat.m_comp_size); - cur_file_ofs += file_stat.m_comp_size; - out_buf_ofs += file_stat.m_comp_size; - comp_remaining = 0; - } else { - while (comp_remaining) { - read_buf_avail = MZ_MIN(read_buf_size, comp_remaining); - if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pRead_buf, - (size_t)read_buf_avail) != read_buf_avail) { - status = TINFL_STATUS_FAILED; - break; - } - - if (!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) - file_crc32 = (mz_uint32)mz_crc32( - file_crc32, (const mz_uint8 *)pRead_buf, (size_t)read_buf_avail); - - if (pCallback(pOpaque, out_buf_ofs, pRead_buf, - (size_t)read_buf_avail) != read_buf_avail) { - status = TINFL_STATUS_FAILED; - break; - } - cur_file_ofs += read_buf_avail; - out_buf_ofs += read_buf_avail; - comp_remaining -= read_buf_avail; - } - } - } else { - tinfl_decompressor inflator; - tinfl_init(&inflator); - - if (NULL == (pWrite_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, - TINFL_LZ_DICT_SIZE))) - status = TINFL_STATUS_FAILED; - else { - do { - mz_uint8 *pWrite_buf_cur = - (mz_uint8 *)pWrite_buf + (out_buf_ofs & (TINFL_LZ_DICT_SIZE - 1)); - size_t in_buf_size, - out_buf_size = - TINFL_LZ_DICT_SIZE - (out_buf_ofs & (TINFL_LZ_DICT_SIZE - 1)); - if ((!read_buf_avail) && (!pZip->m_pState->m_pMem)) { - read_buf_avail = MZ_MIN(read_buf_size, comp_remaining); - if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pRead_buf, - (size_t)read_buf_avail) != read_buf_avail) { - status = TINFL_STATUS_FAILED; - break; - } - cur_file_ofs += read_buf_avail; - comp_remaining -= read_buf_avail; - read_buf_ofs = 0; - } - - in_buf_size = (size_t)read_buf_avail; - status = tinfl_decompress( - &inflator, (const mz_uint8 *)pRead_buf + read_buf_ofs, &in_buf_size, - (mz_uint8 *)pWrite_buf, pWrite_buf_cur, &out_buf_size, - comp_remaining ? TINFL_FLAG_HAS_MORE_INPUT : 0); - read_buf_avail -= in_buf_size; - read_buf_ofs += in_buf_size; - - if (out_buf_size) { - if (pCallback(pOpaque, out_buf_ofs, pWrite_buf_cur, out_buf_size) != - out_buf_size) { - status = TINFL_STATUS_FAILED; - break; - } - file_crc32 = - (mz_uint32)mz_crc32(file_crc32, pWrite_buf_cur, out_buf_size); - if ((out_buf_ofs += out_buf_size) > file_stat.m_uncomp_size) { - status = TINFL_STATUS_FAILED; - break; - } - } - } while ((status == TINFL_STATUS_NEEDS_MORE_INPUT) || - (status == TINFL_STATUS_HAS_MORE_OUTPUT)); - } - } - - if ((status == TINFL_STATUS_DONE) && - (!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA))) { - // Make sure the entire file was decompressed, and check its CRC. - if ((out_buf_ofs != file_stat.m_uncomp_size) || - (file_crc32 != file_stat.m_crc32)) - status = TINFL_STATUS_FAILED; - } - - if (!pZip->m_pState->m_pMem) pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); - if (pWrite_buf) pZip->m_pFree(pZip->m_pAlloc_opaque, pWrite_buf); - - return status == TINFL_STATUS_DONE; -} - -mz_bool mz_zip_reader_extract_file_to_callback(mz_zip_archive *pZip, - const char *pFilename, - mz_file_write_func pCallback, - void *pOpaque, mz_uint flags) { - int file_index = mz_zip_reader_locate_file(pZip, pFilename, NULL, flags); - if (file_index < 0) return MZ_FALSE; - return mz_zip_reader_extract_to_callback(pZip, file_index, pCallback, pOpaque, - flags); -} - -#ifndef MINIZ_NO_STDIO -static size_t mz_zip_file_write_callback(void *pOpaque, mz_uint64 ofs, - const void *pBuf, size_t n) { - (void)ofs; - return MZ_FWRITE(pBuf, 1, n, (MZ_FILE *)pOpaque); -} - -mz_bool mz_zip_reader_extract_to_file(mz_zip_archive *pZip, mz_uint file_index, - const char *pDst_filename, - mz_uint flags) { - mz_bool status; - mz_zip_archive_file_stat file_stat; - MZ_FILE *pFile; - if (!mz_zip_reader_file_stat(pZip, file_index, &file_stat)) return MZ_FALSE; - pFile = MZ_FOPEN(pDst_filename, "wb"); - if (!pFile) return MZ_FALSE; - status = mz_zip_reader_extract_to_callback( - pZip, file_index, mz_zip_file_write_callback, pFile, flags); - if (MZ_FCLOSE(pFile) == EOF) return MZ_FALSE; -#ifndef MINIZ_NO_TIME - if (status) - mz_zip_set_file_times(pDst_filename, file_stat.m_time, file_stat.m_time); -#endif - return status; -} -#endif // #ifndef MINIZ_NO_STDIO - -mz_bool mz_zip_reader_end(mz_zip_archive *pZip) { - if ((!pZip) || (!pZip->m_pState) || (!pZip->m_pAlloc) || (!pZip->m_pFree) || - (pZip->m_zip_mode != MZ_ZIP_MODE_READING)) - return MZ_FALSE; - - if (pZip->m_pState) { - mz_zip_internal_state *pState = pZip->m_pState; - pZip->m_pState = NULL; - mz_zip_array_clear(pZip, &pState->m_central_dir); - mz_zip_array_clear(pZip, &pState->m_central_dir_offsets); - mz_zip_array_clear(pZip, &pState->m_sorted_central_dir_offsets); - -#ifndef MINIZ_NO_STDIO - if (pState->m_pFile) { - MZ_FCLOSE(pState->m_pFile); - pState->m_pFile = NULL; - } -#endif // #ifndef MINIZ_NO_STDIO - - pZip->m_pFree(pZip->m_pAlloc_opaque, pState); - } - pZip->m_zip_mode = MZ_ZIP_MODE_INVALID; - - return MZ_TRUE; -} - -#ifndef MINIZ_NO_STDIO -mz_bool mz_zip_reader_extract_file_to_file(mz_zip_archive *pZip, - const char *pArchive_filename, - const char *pDst_filename, - mz_uint flags) { - int file_index = - mz_zip_reader_locate_file(pZip, pArchive_filename, NULL, flags); - if (file_index < 0) return MZ_FALSE; - return mz_zip_reader_extract_to_file(pZip, file_index, pDst_filename, flags); -} -#endif - -// ------------------- .ZIP archive writing - -#ifndef MINIZ_NO_ARCHIVE_WRITING_APIS - -static void mz_write_le16(mz_uint8 *p, mz_uint16 v) { - p[0] = (mz_uint8)v; - p[1] = (mz_uint8)(v >> 8); -} -static void mz_write_le32(mz_uint8 *p, mz_uint32 v) { - p[0] = (mz_uint8)v; - p[1] = (mz_uint8)(v >> 8); - p[2] = (mz_uint8)(v >> 16); - p[3] = (mz_uint8)(v >> 24); -} -#define MZ_WRITE_LE16(p, v) mz_write_le16((mz_uint8 *)(p), (mz_uint16)(v)) -#define MZ_WRITE_LE32(p, v) mz_write_le32((mz_uint8 *)(p), (mz_uint32)(v)) - -mz_bool mz_zip_writer_init(mz_zip_archive *pZip, mz_uint64 existing_size) { - if ((!pZip) || (pZip->m_pState) || (!pZip->m_pWrite) || - (pZip->m_zip_mode != MZ_ZIP_MODE_INVALID)) - return MZ_FALSE; - - if (pZip->m_file_offset_alignment) { - // Ensure user specified file offset alignment is a power of 2. - if (pZip->m_file_offset_alignment & (pZip->m_file_offset_alignment - 1)) - return MZ_FALSE; - } - - if (!pZip->m_pAlloc) pZip->m_pAlloc = def_alloc_func; - if (!pZip->m_pFree) pZip->m_pFree = def_free_func; - if (!pZip->m_pRealloc) pZip->m_pRealloc = def_realloc_func; - - pZip->m_zip_mode = MZ_ZIP_MODE_WRITING; - pZip->m_archive_size = existing_size; - pZip->m_central_directory_file_ofs = 0; - pZip->m_total_files = 0; - - if (NULL == (pZip->m_pState = (mz_zip_internal_state *)pZip->m_pAlloc( - pZip->m_pAlloc_opaque, 1, sizeof(mz_zip_internal_state)))) - return MZ_FALSE; - memset(pZip->m_pState, 0, sizeof(mz_zip_internal_state)); - MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir, - sizeof(mz_uint8)); - MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir_offsets, - sizeof(mz_uint32)); - MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_sorted_central_dir_offsets, - sizeof(mz_uint32)); - return MZ_TRUE; -} - -static size_t mz_zip_heap_write_func(void *pOpaque, mz_uint64 file_ofs, - const void *pBuf, size_t n) { - mz_zip_archive *pZip = (mz_zip_archive *)pOpaque; - mz_zip_internal_state *pState = pZip->m_pState; - mz_uint64 new_size = MZ_MAX(file_ofs + n, pState->m_mem_size); -#ifdef _MSC_VER - if ((!n) || - ((0, sizeof(size_t) == sizeof(mz_uint32)) && (new_size > 0x7FFFFFFF))) -#else - if ((!n) || - ((sizeof(size_t) == sizeof(mz_uint32)) && (new_size > 0x7FFFFFFF))) -#endif - return 0; - if (new_size > pState->m_mem_capacity) { - void *pNew_block; - size_t new_capacity = MZ_MAX(64, pState->m_mem_capacity); - while (new_capacity < new_size) new_capacity *= 2; - if (NULL == (pNew_block = pZip->m_pRealloc( - pZip->m_pAlloc_opaque, pState->m_pMem, 1, new_capacity))) - return 0; - pState->m_pMem = pNew_block; - pState->m_mem_capacity = new_capacity; - } - memcpy((mz_uint8 *)pState->m_pMem + file_ofs, pBuf, n); - pState->m_mem_size = (size_t)new_size; - return n; -} - -mz_bool mz_zip_writer_init_heap(mz_zip_archive *pZip, - size_t size_to_reserve_at_beginning, - size_t initial_allocation_size) { - pZip->m_pWrite = mz_zip_heap_write_func; - pZip->m_pIO_opaque = pZip; - if (!mz_zip_writer_init(pZip, size_to_reserve_at_beginning)) return MZ_FALSE; - if (0 != (initial_allocation_size = MZ_MAX(initial_allocation_size, - size_to_reserve_at_beginning))) { - if (NULL == (pZip->m_pState->m_pMem = pZip->m_pAlloc( - pZip->m_pAlloc_opaque, 1, initial_allocation_size))) { - mz_zip_writer_end(pZip); - return MZ_FALSE; - } - pZip->m_pState->m_mem_capacity = initial_allocation_size; - } - return MZ_TRUE; -} - -#ifndef MINIZ_NO_STDIO -static size_t mz_zip_file_write_func(void *pOpaque, mz_uint64 file_ofs, - const void *pBuf, size_t n) { - mz_zip_archive *pZip = (mz_zip_archive *)pOpaque; - mz_int64 cur_ofs = MZ_FTELL64(pZip->m_pState->m_pFile); - if (((mz_int64)file_ofs < 0) || - (((cur_ofs != (mz_int64)file_ofs)) && - (MZ_FSEEK64(pZip->m_pState->m_pFile, (mz_int64)file_ofs, SEEK_SET)))) - return 0; - return MZ_FWRITE(pBuf, 1, n, pZip->m_pState->m_pFile); -} - -mz_bool mz_zip_writer_init_file(mz_zip_archive *pZip, const char *pFilename, - mz_uint64 size_to_reserve_at_beginning) { - MZ_FILE *pFile; - pZip->m_pWrite = mz_zip_file_write_func; - pZip->m_pIO_opaque = pZip; - if (!mz_zip_writer_init(pZip, size_to_reserve_at_beginning)) return MZ_FALSE; - if (NULL == (pFile = MZ_FOPEN(pFilename, "wb"))) { - mz_zip_writer_end(pZip); - return MZ_FALSE; - } - pZip->m_pState->m_pFile = pFile; - if (size_to_reserve_at_beginning) { - mz_uint64 cur_ofs = 0; - char buf[4096]; - MZ_CLEAR_OBJ(buf); - do { - size_t n = (size_t)MZ_MIN(sizeof(buf), size_to_reserve_at_beginning); - if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_ofs, buf, n) != n) { - mz_zip_writer_end(pZip); - return MZ_FALSE; - } - cur_ofs += n; - size_to_reserve_at_beginning -= n; - } while (size_to_reserve_at_beginning); - } - return MZ_TRUE; -} -#endif // #ifndef MINIZ_NO_STDIO - -mz_bool mz_zip_writer_init_from_reader(mz_zip_archive *pZip, - const char *pFilename) { - mz_zip_internal_state *pState; - if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_READING)) - return MZ_FALSE; - // No sense in trying to write to an archive that's already at the support max - // size - if ((pZip->m_total_files == 0xFFFF) || - ((pZip->m_archive_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + - MZ_ZIP_LOCAL_DIR_HEADER_SIZE) > 0xFFFFFFFF)) - return MZ_FALSE; - - pState = pZip->m_pState; - - if (pState->m_pFile) { -#ifdef MINIZ_NO_STDIO - pFilename; - return MZ_FALSE; -#else - // Archive is being read from stdio - try to reopen as writable. - if (pZip->m_pIO_opaque != pZip) return MZ_FALSE; - if (!pFilename) return MZ_FALSE; - pZip->m_pWrite = mz_zip_file_write_func; - if (NULL == - (pState->m_pFile = MZ_FREOPEN(pFilename, "r+b", pState->m_pFile))) { - // The mz_zip_archive is now in a bogus state because pState->m_pFile is - // NULL, so just close it. - mz_zip_reader_end(pZip); - return MZ_FALSE; - } -#endif // #ifdef MINIZ_NO_STDIO - } else if (pState->m_pMem) { - // Archive lives in a memory block. Assume it's from the heap that we can - // resize using the realloc callback. - if (pZip->m_pIO_opaque != pZip) return MZ_FALSE; - pState->m_mem_capacity = pState->m_mem_size; - pZip->m_pWrite = mz_zip_heap_write_func; - } - // Archive is being read via a user provided read function - make sure the - // user has specified a write function too. - else if (!pZip->m_pWrite) - return MZ_FALSE; - - // Start writing new files at the archive's current central directory - // location. - pZip->m_archive_size = pZip->m_central_directory_file_ofs; - pZip->m_zip_mode = MZ_ZIP_MODE_WRITING; - pZip->m_central_directory_file_ofs = 0; - - return MZ_TRUE; -} - -mz_bool mz_zip_writer_add_mem(mz_zip_archive *pZip, const char *pArchive_name, - const void *pBuf, size_t buf_size, - mz_uint level_and_flags) { - return mz_zip_writer_add_mem_ex(pZip, pArchive_name, pBuf, buf_size, NULL, 0, - level_and_flags, 0, 0); -} - -typedef struct { - mz_zip_archive *m_pZip; - mz_uint64 m_cur_archive_file_ofs; - mz_uint64 m_comp_size; -} mz_zip_writer_add_state; - -static mz_bool mz_zip_writer_add_put_buf_callback(const void *pBuf, int len, - void *pUser) { - mz_zip_writer_add_state *pState = (mz_zip_writer_add_state *)pUser; - if ((int)pState->m_pZip->m_pWrite(pState->m_pZip->m_pIO_opaque, - pState->m_cur_archive_file_ofs, pBuf, - len) != len) - return MZ_FALSE; - pState->m_cur_archive_file_ofs += len; - pState->m_comp_size += len; - return MZ_TRUE; -} - -static mz_bool mz_zip_writer_create_local_dir_header( - mz_zip_archive *pZip, mz_uint8 *pDst, mz_uint16 filename_size, - mz_uint16 extra_size, mz_uint64 uncomp_size, mz_uint64 comp_size, - mz_uint32 uncomp_crc32, mz_uint16 method, mz_uint16 bit_flags, - mz_uint16 dos_time, mz_uint16 dos_date) { - (void)pZip; - memset(pDst, 0, MZ_ZIP_LOCAL_DIR_HEADER_SIZE); - MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_SIG_OFS, MZ_ZIP_LOCAL_DIR_HEADER_SIG); - MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_VERSION_NEEDED_OFS, method ? 20 : 0); - MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_BIT_FLAG_OFS, bit_flags); - MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_METHOD_OFS, method); - MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_FILE_TIME_OFS, dos_time); - MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_FILE_DATE_OFS, dos_date); - MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_CRC32_OFS, uncomp_crc32); - MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_COMPRESSED_SIZE_OFS, comp_size); - MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_DECOMPRESSED_SIZE_OFS, uncomp_size); - MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_FILENAME_LEN_OFS, filename_size); - MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_EXTRA_LEN_OFS, extra_size); - return MZ_TRUE; -} - -static mz_bool mz_zip_writer_create_central_dir_header( - mz_zip_archive *pZip, mz_uint8 *pDst, mz_uint16 filename_size, - mz_uint16 extra_size, mz_uint16 comment_size, mz_uint64 uncomp_size, - mz_uint64 comp_size, mz_uint32 uncomp_crc32, mz_uint16 method, - mz_uint16 bit_flags, mz_uint16 dos_time, mz_uint16 dos_date, - mz_uint64 local_header_ofs, mz_uint32 ext_attributes) { - (void)pZip; - memset(pDst, 0, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE); - MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_SIG_OFS, MZ_ZIP_CENTRAL_DIR_HEADER_SIG); - MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_VERSION_NEEDED_OFS, method ? 20 : 0); - MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_BIT_FLAG_OFS, bit_flags); - MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_METHOD_OFS, method); - MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_FILE_TIME_OFS, dos_time); - MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_FILE_DATE_OFS, dos_date); - MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_CRC32_OFS, uncomp_crc32); - MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS, comp_size); - MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS, uncomp_size); - MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_FILENAME_LEN_OFS, filename_size); - MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_EXTRA_LEN_OFS, extra_size); - MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_COMMENT_LEN_OFS, comment_size); - MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_EXTERNAL_ATTR_OFS, ext_attributes); - MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_LOCAL_HEADER_OFS, local_header_ofs); - return MZ_TRUE; -} - -static mz_bool mz_zip_writer_add_to_central_dir( - mz_zip_archive *pZip, const char *pFilename, mz_uint16 filename_size, - const void *pExtra, mz_uint16 extra_size, const void *pComment, - mz_uint16 comment_size, mz_uint64 uncomp_size, mz_uint64 comp_size, - mz_uint32 uncomp_crc32, mz_uint16 method, mz_uint16 bit_flags, - mz_uint16 dos_time, mz_uint16 dos_date, mz_uint64 local_header_ofs, - mz_uint32 ext_attributes) { - mz_zip_internal_state *pState = pZip->m_pState; - mz_uint32 central_dir_ofs = (mz_uint32)pState->m_central_dir.m_size; - size_t orig_central_dir_size = pState->m_central_dir.m_size; - mz_uint8 central_dir_header[MZ_ZIP_CENTRAL_DIR_HEADER_SIZE]; - - // No zip64 support yet - if ((local_header_ofs > 0xFFFFFFFF) || - (((mz_uint64)pState->m_central_dir.m_size + - MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + filename_size + extra_size + - comment_size) > 0xFFFFFFFF)) - return MZ_FALSE; - - if (!mz_zip_writer_create_central_dir_header( - pZip, central_dir_header, filename_size, extra_size, comment_size, - uncomp_size, comp_size, uncomp_crc32, method, bit_flags, dos_time, - dos_date, local_header_ofs, ext_attributes)) - return MZ_FALSE; - - if ((!mz_zip_array_push_back(pZip, &pState->m_central_dir, central_dir_header, - MZ_ZIP_CENTRAL_DIR_HEADER_SIZE)) || - (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pFilename, - filename_size)) || - (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pExtra, - extra_size)) || - (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pComment, - comment_size)) || - (!mz_zip_array_push_back(pZip, &pState->m_central_dir_offsets, - ¢ral_dir_ofs, 1))) { - // Try to push the central directory array back into its original state. - mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, - MZ_FALSE); - return MZ_FALSE; - } - - return MZ_TRUE; -} - -static mz_bool mz_zip_writer_validate_archive_name(const char *pArchive_name) { - // Basic ZIP archive filename validity checks: Valid filenames cannot start - // with a forward slash, cannot contain a drive letter, and cannot use - // DOS-style backward slashes. - if (*pArchive_name == '/') return MZ_FALSE; - while (*pArchive_name) { - if ((*pArchive_name == '\\') || (*pArchive_name == ':')) return MZ_FALSE; - pArchive_name++; - } - return MZ_TRUE; -} - -static mz_uint mz_zip_writer_compute_padding_needed_for_file_alignment( - mz_zip_archive *pZip) { - mz_uint32 n; - if (!pZip->m_file_offset_alignment) return 0; - n = (mz_uint32)(pZip->m_archive_size & (pZip->m_file_offset_alignment - 1)); - return (pZip->m_file_offset_alignment - n) & - (pZip->m_file_offset_alignment - 1); -} - -static mz_bool mz_zip_writer_write_zeros(mz_zip_archive *pZip, - mz_uint64 cur_file_ofs, mz_uint32 n) { - char buf[4096]; - memset(buf, 0, MZ_MIN(sizeof(buf), n)); - while (n) { - mz_uint32 s = MZ_MIN(sizeof(buf), n); - if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_file_ofs, buf, s) != s) - return MZ_FALSE; - cur_file_ofs += s; - n -= s; - } - return MZ_TRUE; -} - -mz_bool mz_zip_writer_add_mem_ex(mz_zip_archive *pZip, - const char *pArchive_name, const void *pBuf, - size_t buf_size, const void *pComment, - mz_uint16 comment_size, - mz_uint level_and_flags, mz_uint64 uncomp_size, - mz_uint32 uncomp_crc32) { - mz_uint16 method = 0, dos_time = 0, dos_date = 0; - mz_uint level, ext_attributes = 0, num_alignment_padding_bytes; - mz_uint64 local_dir_header_ofs = pZip->m_archive_size, - cur_archive_file_ofs = pZip->m_archive_size, comp_size = 0; - size_t archive_name_size; - mz_uint8 local_dir_header[MZ_ZIP_LOCAL_DIR_HEADER_SIZE]; - tdefl_compressor *pComp = NULL; - mz_bool store_data_uncompressed; - mz_zip_internal_state *pState; - - if ((int)level_and_flags < 0) level_and_flags = MZ_DEFAULT_LEVEL; - level = level_and_flags & 0xF; - store_data_uncompressed = - ((!level) || (level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA)); - - if ((!pZip) || (!pZip->m_pState) || - (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING) || ((buf_size) && (!pBuf)) || - (!pArchive_name) || ((comment_size) && (!pComment)) || - (pZip->m_total_files == 0xFFFF) || (level > MZ_UBER_COMPRESSION)) - return MZ_FALSE; - - pState = pZip->m_pState; - - if ((!(level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) && (uncomp_size)) - return MZ_FALSE; - // No zip64 support yet - if ((buf_size > 0xFFFFFFFF) || (uncomp_size > 0xFFFFFFFF)) return MZ_FALSE; - if (!mz_zip_writer_validate_archive_name(pArchive_name)) return MZ_FALSE; - -#ifndef MINIZ_NO_TIME - { - time_t cur_time; - time(&cur_time); - mz_zip_time_to_dos_time(cur_time, &dos_time, &dos_date); - } -#endif // #ifndef MINIZ_NO_TIME - - archive_name_size = strlen(pArchive_name); - if (archive_name_size > 0xFFFF) return MZ_FALSE; - - num_alignment_padding_bytes = - mz_zip_writer_compute_padding_needed_for_file_alignment(pZip); - - // no zip64 support yet - if ((pZip->m_total_files == 0xFFFF) || - ((pZip->m_archive_size + num_alignment_padding_bytes + - MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + - comment_size + archive_name_size) > 0xFFFFFFFF)) - return MZ_FALSE; - - if ((archive_name_size) && (pArchive_name[archive_name_size - 1] == '/')) { - // Set DOS Subdirectory attribute bit. - ext_attributes |= 0x10; - // Subdirectories cannot contain data. - if ((buf_size) || (uncomp_size)) return MZ_FALSE; - } - - // Try to do any allocations before writing to the archive, so if an - // allocation fails the file remains unmodified. (A good idea if we're doing - // an in-place modification.) - if ((!mz_zip_array_ensure_room( - pZip, &pState->m_central_dir, - MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + archive_name_size + comment_size)) || - (!mz_zip_array_ensure_room(pZip, &pState->m_central_dir_offsets, 1))) - return MZ_FALSE; - - if ((!store_data_uncompressed) && (buf_size)) { - if (NULL == (pComp = (tdefl_compressor *)pZip->m_pAlloc( - pZip->m_pAlloc_opaque, 1, sizeof(tdefl_compressor)))) - return MZ_FALSE; - } - - if (!mz_zip_writer_write_zeros( - pZip, cur_archive_file_ofs, - num_alignment_padding_bytes + sizeof(local_dir_header))) { - pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); - return MZ_FALSE; - } - local_dir_header_ofs += num_alignment_padding_bytes; - if (pZip->m_file_offset_alignment) { - MZ_ASSERT((local_dir_header_ofs & (pZip->m_file_offset_alignment - 1)) == - 0); - } - cur_archive_file_ofs += - num_alignment_padding_bytes + sizeof(local_dir_header); - - MZ_CLEAR_OBJ(local_dir_header); - if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pArchive_name, - archive_name_size) != archive_name_size) { - pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); - return MZ_FALSE; - } - cur_archive_file_ofs += archive_name_size; - - if (!(level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) { - uncomp_crc32 = - (mz_uint32)mz_crc32(MZ_CRC32_INIT, (const mz_uint8 *)pBuf, buf_size); - uncomp_size = buf_size; - if (uncomp_size <= 3) { - level = 0; - store_data_uncompressed = MZ_TRUE; - } - } - - if (store_data_uncompressed) { - if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pBuf, - buf_size) != buf_size) { - pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); - return MZ_FALSE; - } - - cur_archive_file_ofs += buf_size; - comp_size = buf_size; - - if (level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA) method = MZ_DEFLATED; - } else if (buf_size) { - mz_zip_writer_add_state state; - - state.m_pZip = pZip; - state.m_cur_archive_file_ofs = cur_archive_file_ofs; - state.m_comp_size = 0; - - if ((tdefl_init(pComp, mz_zip_writer_add_put_buf_callback, &state, - tdefl_create_comp_flags_from_zip_params( - level, -15, MZ_DEFAULT_STRATEGY)) != - TDEFL_STATUS_OKAY) || - (tdefl_compress_buffer(pComp, pBuf, buf_size, TDEFL_FINISH) != - TDEFL_STATUS_DONE)) { - pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); - return MZ_FALSE; - } - - comp_size = state.m_comp_size; - cur_archive_file_ofs = state.m_cur_archive_file_ofs; - - method = MZ_DEFLATED; - } - - pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); - pComp = NULL; - - // no zip64 support yet - if ((comp_size > 0xFFFFFFFF) || (cur_archive_file_ofs > 0xFFFFFFFF)) - return MZ_FALSE; - - if (!mz_zip_writer_create_local_dir_header( - pZip, local_dir_header, (mz_uint16)archive_name_size, 0, uncomp_size, - comp_size, uncomp_crc32, method, 0, dos_time, dos_date)) - return MZ_FALSE; - - if (pZip->m_pWrite(pZip->m_pIO_opaque, local_dir_header_ofs, local_dir_header, - sizeof(local_dir_header)) != sizeof(local_dir_header)) - return MZ_FALSE; - - if (!mz_zip_writer_add_to_central_dir( - pZip, pArchive_name, (mz_uint16)archive_name_size, NULL, 0, pComment, - comment_size, uncomp_size, comp_size, uncomp_crc32, method, 0, - dos_time, dos_date, local_dir_header_ofs, ext_attributes)) - return MZ_FALSE; - - pZip->m_total_files++; - pZip->m_archive_size = cur_archive_file_ofs; - - return MZ_TRUE; -} - -#ifndef MINIZ_NO_STDIO -mz_bool mz_zip_writer_add_file(mz_zip_archive *pZip, const char *pArchive_name, - const char *pSrc_filename, const void *pComment, - mz_uint16 comment_size, - mz_uint level_and_flags) { - mz_uint uncomp_crc32 = MZ_CRC32_INIT, level, num_alignment_padding_bytes; - mz_uint16 method = 0, dos_time = 0, dos_date = 0, ext_attributes = 0; - mz_uint64 local_dir_header_ofs = pZip->m_archive_size, - cur_archive_file_ofs = pZip->m_archive_size, uncomp_size = 0, - comp_size = 0; - size_t archive_name_size; - mz_uint8 local_dir_header[MZ_ZIP_LOCAL_DIR_HEADER_SIZE]; - MZ_FILE *pSrc_file = NULL; - - if ((int)level_and_flags < 0) level_and_flags = MZ_DEFAULT_LEVEL; - level = level_and_flags & 0xF; - - if ((!pZip) || (!pZip->m_pState) || - (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING) || (!pArchive_name) || - ((comment_size) && (!pComment)) || (level > MZ_UBER_COMPRESSION)) - return MZ_FALSE; - if (level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA) return MZ_FALSE; - if (!mz_zip_writer_validate_archive_name(pArchive_name)) return MZ_FALSE; - - archive_name_size = strlen(pArchive_name); - if (archive_name_size > 0xFFFF) return MZ_FALSE; - - num_alignment_padding_bytes = - mz_zip_writer_compute_padding_needed_for_file_alignment(pZip); - - // no zip64 support yet - if ((pZip->m_total_files == 0xFFFF) || - ((pZip->m_archive_size + num_alignment_padding_bytes + - MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + - comment_size + archive_name_size) > 0xFFFFFFFF)) - return MZ_FALSE; - - if (!mz_zip_get_file_modified_time(pSrc_filename, &dos_time, &dos_date)) - return MZ_FALSE; - - pSrc_file = MZ_FOPEN(pSrc_filename, "rb"); - if (!pSrc_file) return MZ_FALSE; - MZ_FSEEK64(pSrc_file, 0, SEEK_END); - uncomp_size = MZ_FTELL64(pSrc_file); - MZ_FSEEK64(pSrc_file, 0, SEEK_SET); - - if (uncomp_size > 0xFFFFFFFF) { - // No zip64 support yet - MZ_FCLOSE(pSrc_file); - return MZ_FALSE; - } - if (uncomp_size <= 3) level = 0; - - if (!mz_zip_writer_write_zeros( - pZip, cur_archive_file_ofs, - num_alignment_padding_bytes + sizeof(local_dir_header))) { - MZ_FCLOSE(pSrc_file); - return MZ_FALSE; - } - local_dir_header_ofs += num_alignment_padding_bytes; - if (pZip->m_file_offset_alignment) { - MZ_ASSERT((local_dir_header_ofs & (pZip->m_file_offset_alignment - 1)) == - 0); - } - cur_archive_file_ofs += - num_alignment_padding_bytes + sizeof(local_dir_header); - - MZ_CLEAR_OBJ(local_dir_header); - if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pArchive_name, - archive_name_size) != archive_name_size) { - MZ_FCLOSE(pSrc_file); - return MZ_FALSE; - } - cur_archive_file_ofs += archive_name_size; - - if (uncomp_size) { - mz_uint64 uncomp_remaining = uncomp_size; - void *pRead_buf = - pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, MZ_ZIP_MAX_IO_BUF_SIZE); - if (!pRead_buf) { - MZ_FCLOSE(pSrc_file); - return MZ_FALSE; - } - - if (!level) { - while (uncomp_remaining) { - mz_uint n = - (mz_uint)MZ_MIN((mz_uint)MZ_ZIP_MAX_IO_BUF_SIZE, uncomp_remaining); - if ((MZ_FREAD(pRead_buf, 1, n, pSrc_file) != n) || - (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pRead_buf, - n) != n)) { - pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); - MZ_FCLOSE(pSrc_file); - return MZ_FALSE; - } - uncomp_crc32 = - (mz_uint32)mz_crc32(uncomp_crc32, (const mz_uint8 *)pRead_buf, n); - uncomp_remaining -= n; - cur_archive_file_ofs += n; - } - comp_size = uncomp_size; - } else { - mz_bool result = MZ_FALSE; - mz_zip_writer_add_state state; - tdefl_compressor *pComp = (tdefl_compressor *)pZip->m_pAlloc( - pZip->m_pAlloc_opaque, 1, sizeof(tdefl_compressor)); - if (!pComp) { - pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); - MZ_FCLOSE(pSrc_file); - return MZ_FALSE; - } - - state.m_pZip = pZip; - state.m_cur_archive_file_ofs = cur_archive_file_ofs; - state.m_comp_size = 0; - - if (tdefl_init(pComp, mz_zip_writer_add_put_buf_callback, &state, - tdefl_create_comp_flags_from_zip_params( - level, -15, MZ_DEFAULT_STRATEGY)) != - TDEFL_STATUS_OKAY) { - pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); - pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); - MZ_FCLOSE(pSrc_file); - return MZ_FALSE; - } - - for (;;) { - size_t in_buf_size = (mz_uint32)MZ_MIN(uncomp_remaining, - (mz_uint)MZ_ZIP_MAX_IO_BUF_SIZE); - tdefl_status status; - - if (MZ_FREAD(pRead_buf, 1, in_buf_size, pSrc_file) != in_buf_size) - break; - - uncomp_crc32 = (mz_uint32)mz_crc32( - uncomp_crc32, (const mz_uint8 *)pRead_buf, in_buf_size); - uncomp_remaining -= in_buf_size; - - status = tdefl_compress_buffer( - pComp, pRead_buf, in_buf_size, - uncomp_remaining ? TDEFL_NO_FLUSH : TDEFL_FINISH); - if (status == TDEFL_STATUS_DONE) { - result = MZ_TRUE; - break; - } else if (status != TDEFL_STATUS_OKAY) - break; - } - - pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); - - if (!result) { - pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); - MZ_FCLOSE(pSrc_file); - return MZ_FALSE; - } - - comp_size = state.m_comp_size; - cur_archive_file_ofs = state.m_cur_archive_file_ofs; - - method = MZ_DEFLATED; - } - - pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); - } - - MZ_FCLOSE(pSrc_file); - pSrc_file = NULL; - - // no zip64 support yet - if ((comp_size > 0xFFFFFFFF) || (cur_archive_file_ofs > 0xFFFFFFFF)) - return MZ_FALSE; - - if (!mz_zip_writer_create_local_dir_header( - pZip, local_dir_header, (mz_uint16)archive_name_size, 0, uncomp_size, - comp_size, uncomp_crc32, method, 0, dos_time, dos_date)) - return MZ_FALSE; - - if (pZip->m_pWrite(pZip->m_pIO_opaque, local_dir_header_ofs, local_dir_header, - sizeof(local_dir_header)) != sizeof(local_dir_header)) - return MZ_FALSE; - - if (!mz_zip_writer_add_to_central_dir( - pZip, pArchive_name, (mz_uint16)archive_name_size, NULL, 0, pComment, - comment_size, uncomp_size, comp_size, uncomp_crc32, method, 0, - dos_time, dos_date, local_dir_header_ofs, ext_attributes)) - return MZ_FALSE; - - pZip->m_total_files++; - pZip->m_archive_size = cur_archive_file_ofs; - - return MZ_TRUE; -} -#endif // #ifndef MINIZ_NO_STDIO - -mz_bool mz_zip_writer_add_from_zip_reader(mz_zip_archive *pZip, - mz_zip_archive *pSource_zip, - mz_uint file_index) { - mz_uint n, bit_flags, num_alignment_padding_bytes; - mz_uint64 comp_bytes_remaining, local_dir_header_ofs; - mz_uint64 cur_src_file_ofs, cur_dst_file_ofs; - mz_uint32 - local_header_u32[(MZ_ZIP_LOCAL_DIR_HEADER_SIZE + sizeof(mz_uint32) - 1) / - sizeof(mz_uint32)]; - mz_uint8 *pLocal_header = (mz_uint8 *)local_header_u32; - mz_uint8 central_header[MZ_ZIP_CENTRAL_DIR_HEADER_SIZE]; - size_t orig_central_dir_size; - mz_zip_internal_state *pState; - void *pBuf; - const mz_uint8 *pSrc_central_header; - - if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING)) - return MZ_FALSE; - if (NULL == - (pSrc_central_header = mz_zip_reader_get_cdh(pSource_zip, file_index))) - return MZ_FALSE; - pState = pZip->m_pState; - - num_alignment_padding_bytes = - mz_zip_writer_compute_padding_needed_for_file_alignment(pZip); - - // no zip64 support yet - if ((pZip->m_total_files == 0xFFFF) || - ((pZip->m_archive_size + num_alignment_padding_bytes + - MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE) > - 0xFFFFFFFF)) - return MZ_FALSE; - - cur_src_file_ofs = - MZ_READ_LE32(pSrc_central_header + MZ_ZIP_CDH_LOCAL_HEADER_OFS); - cur_dst_file_ofs = pZip->m_archive_size; - - if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, - pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != - MZ_ZIP_LOCAL_DIR_HEADER_SIZE) - return MZ_FALSE; - if (MZ_READ_LE32(pLocal_header) != MZ_ZIP_LOCAL_DIR_HEADER_SIG) - return MZ_FALSE; - cur_src_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE; - - if (!mz_zip_writer_write_zeros(pZip, cur_dst_file_ofs, - num_alignment_padding_bytes)) - return MZ_FALSE; - cur_dst_file_ofs += num_alignment_padding_bytes; - local_dir_header_ofs = cur_dst_file_ofs; - if (pZip->m_file_offset_alignment) { - MZ_ASSERT((local_dir_header_ofs & (pZip->m_file_offset_alignment - 1)) == - 0); - } - - if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_dst_file_ofs, pLocal_header, - MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != - MZ_ZIP_LOCAL_DIR_HEADER_SIZE) - return MZ_FALSE; - cur_dst_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE; - - n = MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_FILENAME_LEN_OFS) + - MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_EXTRA_LEN_OFS); - comp_bytes_remaining = - n + MZ_READ_LE32(pSrc_central_header + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS); - - if (NULL == (pBuf = pZip->m_pAlloc( - pZip->m_pAlloc_opaque, 1, - (size_t)MZ_MAX(sizeof(mz_uint32) * 4, - MZ_MIN((mz_uint)MZ_ZIP_MAX_IO_BUF_SIZE, - comp_bytes_remaining))))) - return MZ_FALSE; - - while (comp_bytes_remaining) { - n = (mz_uint)MZ_MIN((mz_uint)MZ_ZIP_MAX_IO_BUF_SIZE, comp_bytes_remaining); - if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, pBuf, - n) != n) { - pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); - return MZ_FALSE; - } - cur_src_file_ofs += n; - - if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_dst_file_ofs, pBuf, n) != n) { - pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); - return MZ_FALSE; - } - cur_dst_file_ofs += n; - - comp_bytes_remaining -= n; - } - - bit_flags = MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_BIT_FLAG_OFS); - if (bit_flags & 8) { - // Copy data descriptor - if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, pBuf, - sizeof(mz_uint32) * 4) != sizeof(mz_uint32) * 4) { - pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); - return MZ_FALSE; - } - - n = sizeof(mz_uint32) * ((MZ_READ_LE32(pBuf) == 0x08074b50) ? 4 : 3); - if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_dst_file_ofs, pBuf, n) != n) { - pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); - return MZ_FALSE; - } - - cur_src_file_ofs += n; - cur_dst_file_ofs += n; - } - pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); - - // no zip64 support yet - if (cur_dst_file_ofs > 0xFFFFFFFF) return MZ_FALSE; - - orig_central_dir_size = pState->m_central_dir.m_size; - - memcpy(central_header, pSrc_central_header, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE); - MZ_WRITE_LE32(central_header + MZ_ZIP_CDH_LOCAL_HEADER_OFS, - local_dir_header_ofs); - if (!mz_zip_array_push_back(pZip, &pState->m_central_dir, central_header, - MZ_ZIP_CENTRAL_DIR_HEADER_SIZE)) - return MZ_FALSE; - - n = MZ_READ_LE16(pSrc_central_header + MZ_ZIP_CDH_FILENAME_LEN_OFS) + - MZ_READ_LE16(pSrc_central_header + MZ_ZIP_CDH_EXTRA_LEN_OFS) + - MZ_READ_LE16(pSrc_central_header + MZ_ZIP_CDH_COMMENT_LEN_OFS); - if (!mz_zip_array_push_back( - pZip, &pState->m_central_dir, - pSrc_central_header + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE, n)) { - mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, - MZ_FALSE); - return MZ_FALSE; - } - - if (pState->m_central_dir.m_size > 0xFFFFFFFF) return MZ_FALSE; - n = (mz_uint32)orig_central_dir_size; - if (!mz_zip_array_push_back(pZip, &pState->m_central_dir_offsets, &n, 1)) { - mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, - MZ_FALSE); - return MZ_FALSE; - } - - pZip->m_total_files++; - pZip->m_archive_size = cur_dst_file_ofs; - - return MZ_TRUE; -} - -mz_bool mz_zip_writer_finalize_archive(mz_zip_archive *pZip) { - mz_zip_internal_state *pState; - mz_uint64 central_dir_ofs, central_dir_size; - mz_uint8 hdr[MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE]; - - if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING)) - return MZ_FALSE; - - pState = pZip->m_pState; - - // no zip64 support yet - if ((pZip->m_total_files > 0xFFFF) || - ((pZip->m_archive_size + pState->m_central_dir.m_size + - MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) > 0xFFFFFFFF)) - return MZ_FALSE; - - central_dir_ofs = 0; - central_dir_size = 0; - if (pZip->m_total_files) { - // Write central directory - central_dir_ofs = pZip->m_archive_size; - central_dir_size = pState->m_central_dir.m_size; - pZip->m_central_directory_file_ofs = central_dir_ofs; - if (pZip->m_pWrite(pZip->m_pIO_opaque, central_dir_ofs, - pState->m_central_dir.m_p, - (size_t)central_dir_size) != central_dir_size) - return MZ_FALSE; - pZip->m_archive_size += central_dir_size; - } - - // Write end of central directory record - MZ_CLEAR_OBJ(hdr); - MZ_WRITE_LE32(hdr + MZ_ZIP_ECDH_SIG_OFS, - MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG); - MZ_WRITE_LE16(hdr + MZ_ZIP_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS, - pZip->m_total_files); - MZ_WRITE_LE16(hdr + MZ_ZIP_ECDH_CDIR_TOTAL_ENTRIES_OFS, pZip->m_total_files); - MZ_WRITE_LE32(hdr + MZ_ZIP_ECDH_CDIR_SIZE_OFS, central_dir_size); - MZ_WRITE_LE32(hdr + MZ_ZIP_ECDH_CDIR_OFS_OFS, central_dir_ofs); - - if (pZip->m_pWrite(pZip->m_pIO_opaque, pZip->m_archive_size, hdr, - sizeof(hdr)) != sizeof(hdr)) - return MZ_FALSE; -#ifndef MINIZ_NO_STDIO - if ((pState->m_pFile) && (MZ_FFLUSH(pState->m_pFile) == EOF)) return MZ_FALSE; -#endif // #ifndef MINIZ_NO_STDIO - - pZip->m_archive_size += sizeof(hdr); - - pZip->m_zip_mode = MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED; - return MZ_TRUE; -} - -mz_bool mz_zip_writer_finalize_heap_archive(mz_zip_archive *pZip, void **pBuf, - size_t *pSize) { - if ((!pZip) || (!pZip->m_pState) || (!pBuf) || (!pSize)) return MZ_FALSE; - if (pZip->m_pWrite != mz_zip_heap_write_func) return MZ_FALSE; - if (!mz_zip_writer_finalize_archive(pZip)) return MZ_FALSE; - - *pBuf = pZip->m_pState->m_pMem; - *pSize = pZip->m_pState->m_mem_size; - pZip->m_pState->m_pMem = NULL; - pZip->m_pState->m_mem_size = pZip->m_pState->m_mem_capacity = 0; - return MZ_TRUE; -} - -mz_bool mz_zip_writer_end(mz_zip_archive *pZip) { - mz_zip_internal_state *pState; - mz_bool status = MZ_TRUE; - if ((!pZip) || (!pZip->m_pState) || (!pZip->m_pAlloc) || (!pZip->m_pFree) || - ((pZip->m_zip_mode != MZ_ZIP_MODE_WRITING) && - (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED))) - return MZ_FALSE; - - pState = pZip->m_pState; - pZip->m_pState = NULL; - mz_zip_array_clear(pZip, &pState->m_central_dir); - mz_zip_array_clear(pZip, &pState->m_central_dir_offsets); - mz_zip_array_clear(pZip, &pState->m_sorted_central_dir_offsets); - -#ifndef MINIZ_NO_STDIO - if (pState->m_pFile) { - MZ_FCLOSE(pState->m_pFile); - pState->m_pFile = NULL; - } -#endif // #ifndef MINIZ_NO_STDIO - - if ((pZip->m_pWrite == mz_zip_heap_write_func) && (pState->m_pMem)) { - pZip->m_pFree(pZip->m_pAlloc_opaque, pState->m_pMem); - pState->m_pMem = NULL; - } - - pZip->m_pFree(pZip->m_pAlloc_opaque, pState); - pZip->m_zip_mode = MZ_ZIP_MODE_INVALID; - return status; -} - -#ifndef MINIZ_NO_STDIO -mz_bool mz_zip_add_mem_to_archive_file_in_place( - const char *pZip_filename, const char *pArchive_name, const void *pBuf, - size_t buf_size, const void *pComment, mz_uint16 comment_size, - mz_uint level_and_flags) { - mz_bool status, created_new_archive = MZ_FALSE; - mz_zip_archive zip_archive; - struct MZ_FILE_STAT_STRUCT file_stat; - MZ_CLEAR_OBJ(zip_archive); - if ((int)level_and_flags < 0) level_and_flags = MZ_DEFAULT_LEVEL; - if ((!pZip_filename) || (!pArchive_name) || ((buf_size) && (!pBuf)) || - ((comment_size) && (!pComment)) || - ((level_and_flags & 0xF) > MZ_UBER_COMPRESSION)) - return MZ_FALSE; - if (!mz_zip_writer_validate_archive_name(pArchive_name)) return MZ_FALSE; - if (MZ_FILE_STAT(pZip_filename, &file_stat) != 0) { - // Create a new archive. - if (!mz_zip_writer_init_file(&zip_archive, pZip_filename, 0)) - return MZ_FALSE; - created_new_archive = MZ_TRUE; - } else { - // Append to an existing archive. - if (!mz_zip_reader_init_file( - &zip_archive, pZip_filename, - level_and_flags | MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY)) - return MZ_FALSE; - if (!mz_zip_writer_init_from_reader(&zip_archive, pZip_filename)) { - mz_zip_reader_end(&zip_archive); - return MZ_FALSE; - } - } - status = - mz_zip_writer_add_mem_ex(&zip_archive, pArchive_name, pBuf, buf_size, - pComment, comment_size, level_and_flags, 0, 0); - // Always finalize, even if adding failed for some reason, so we have a valid - // central directory. (This may not always succeed, but we can try.) - if (!mz_zip_writer_finalize_archive(&zip_archive)) status = MZ_FALSE; - if (!mz_zip_writer_end(&zip_archive)) status = MZ_FALSE; - if ((!status) && (created_new_archive)) { - // It's a new archive and something went wrong, so just delete it. - int ignoredStatus = MZ_DELETE_FILE(pZip_filename); - (void)ignoredStatus; - } - return status; -} - -void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, - const char *pArchive_name, - size_t *pSize, mz_uint flags) { - int file_index; - mz_zip_archive zip_archive; - void *p = NULL; - - if (pSize) *pSize = 0; - - if ((!pZip_filename) || (!pArchive_name)) return NULL; - - MZ_CLEAR_OBJ(zip_archive); - if (!mz_zip_reader_init_file( - &zip_archive, pZip_filename, - flags | MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY)) - return NULL; - - if ((file_index = mz_zip_reader_locate_file(&zip_archive, pArchive_name, NULL, - flags)) >= 0) - p = mz_zip_reader_extract_to_heap(&zip_archive, file_index, pSize, flags); - - mz_zip_reader_end(&zip_archive); - return p; -} - -#endif // #ifndef MINIZ_NO_STDIO - -#endif // #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS - -#endif // #ifndef MINIZ_NO_ARCHIVE_APIS - -#ifdef __cplusplus -} -#endif - -#ifdef _MSC_VER -#pragma warning(pop) -#endif - -#endif // MINIZ_HEADER_FILE_ONLY - -/* - This is free and unencumbered software released into the public domain. - - Anyone is free to copy, modify, publish, use, compile, sell, or - distribute this software, either in source code form or as a compiled - binary, for any purpose, commercial or non-commercial, and by any - means. - - In jurisdictions that recognize copyright laws, the author or authors - of this software dedicate any and all copyright interest in the - software to the public domain. We make this dedication for the benefit - of the public at large and to the detriment of our heirs and - successors. We intend this dedication to be an overt act of - relinquishment in perpetuity of all present and future rights to this - software under copyright law. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR - OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - OTHER DEALINGS IN THE SOFTWARE. - - For more information, please refer to <http://unlicense.org/> -*/ - -// ---------------------- end of miniz ---------------------------------------- - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - -} // namespace miniz -#else - -// Reuse MINIZ_LITTE_ENDIAN macro - -#if defined(_M_IX86) || defined(_M_X64) || defined(__i386__) || \ - defined(__i386) || defined(__i486__) || defined(__i486) || \ - defined(i386) || defined(__ia64__) || defined(__x86_64__) -// MINIZ_X86_OR_X64_CPU is only used to help set the below macros. -#define MINIZ_X86_OR_X64_CPU 1 -#endif - -#if defined(__sparcv9) -// Big endian -#else -#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || MINIZ_X86_OR_X64_CPU -// Set MINIZ_LITTLE_ENDIAN to 1 if the processor is little endian. -#define MINIZ_LITTLE_ENDIAN 1 -#endif -#endif - -#endif // TINYEXR_USE_MINIZ - // static bool IsBigEndian(void) { // union { // unsigned int i; @@ -7079,7 +684,7 @@ static void cpy2(unsigned short *dst_val, const unsigned short *src_val) { } static void swap2(unsigned short *val) { -#ifdef MINIZ_LITTLE_ENDIAN +#ifdef TINYEXR_LITTLE_ENDIAN (void)val; #else unsigned short tmp = *val; @@ -7138,7 +743,7 @@ static void cpy4(float *dst_val, const float *src_val) { #endif static void swap4(unsigned int *val) { -#ifdef MINIZ_LITTLE_ENDIAN +#ifdef TINYEXR_LITTLE_ENDIAN (void)val; #else unsigned int tmp = *val; @@ -7153,7 +758,7 @@ static void swap4(unsigned int *val) { } static void swap4(int *val) { -#ifdef MINIZ_LITTLE_ENDIAN +#ifdef TINYEXR_LITTLE_ENDIAN (void)val; #else int tmp = *val; @@ -7168,7 +773,7 @@ static void swap4(int *val) { } static void swap4(float *val) { -#ifdef MINIZ_LITTLE_ENDIAN +#ifdef TINYEXR_LITTLE_ENDIAN (void)val; #else float tmp = *val; @@ -7199,7 +804,7 @@ static void cpy8(tinyexr::tinyexr_uint64 *dst_val, const tinyexr::tinyexr_uint64 #endif static void swap8(tinyexr::tinyexr_uint64 *val) { -#ifdef MINIZ_LITTLE_ENDIAN +#ifdef TINYEXR_LITTLE_ENDIAN (void)val; #else tinyexr::tinyexr_uint64 tmp = (*val); @@ -7218,12 +823,11 @@ static void swap8(tinyexr::tinyexr_uint64 *val) { } // https://gist.github.com/rygorous/2156668 -// Reuse MINIZ_LITTLE_ENDIAN flag from miniz. union FP32 { unsigned int u; float f; struct { -#if MINIZ_LITTLE_ENDIAN +#if TINYEXR_LITTLE_ENDIAN unsigned int Mantissa : 23; unsigned int Exponent : 8; unsigned int Sign : 1; @@ -7243,7 +847,7 @@ union FP32 { union FP16 { unsigned short u; struct { -#if MINIZ_LITTLE_ENDIAN +#if TINYEXR_LITTLE_ENDIAN unsigned int Mantissa : 10; unsigned int Exponent : 5; unsigned int Sign : 1; @@ -7351,7 +955,7 @@ static const char *ReadString(std::string *s, const char *ptr, size_t len) { } if (size_t(q - ptr) >= len) { - (*s) = std::string(); + (*s).clear(); return NULL; } @@ -7438,6 +1042,7 @@ static void WriteAttributeToMemory(std::vector<unsigned char> *out, typedef struct { std::string name; // less than 255 bytes long int pixel_type; + int requested_pixel_type; int x_sampling; int y_sampling; unsigned char p_linear; @@ -7465,6 +1070,7 @@ struct HeaderInfo { int chunk_count; // Tiled format + int tiled; // Non-zero if the part is tiled. int tile_size_x; int tile_size_y; int tile_level_mode; @@ -7474,6 +1080,11 @@ struct HeaderInfo { int compression_type; + // required for multi-part or non-image files + std::string name; + // required for multi-part or non-image files + std::string type; + void clear() { channels.clear(); attributes.clear(); @@ -7495,6 +1106,7 @@ struct HeaderInfo { chunk_count = 0; // Tiled format + tiled = 0; tile_size_x = 0; tile_size_y = 0; tile_level_mode = 0; @@ -7502,6 +1114,9 @@ struct HeaderInfo { header_len = 0; compression_type = 0; + + name.clear(); + type.clear(); } }; @@ -7558,7 +1173,7 @@ static void WriteChannelInfo(std::vector<unsigned char> &data, // Calculate total size. for (size_t c = 0; c < channels.size(); c++) { - sz += strlen(channels[c].name.c_str()) + 1; // +1 for \0 + sz += channels[c].name.length() + 1; // +1 for \0 sz += 16; // 4 * int } data.resize(sz + 1); @@ -7566,12 +1181,12 @@ static void WriteChannelInfo(std::vector<unsigned char> &data, unsigned char *p = &data.at(0); for (size_t c = 0; c < channels.size(); c++) { - memcpy(p, channels[c].name.c_str(), strlen(channels[c].name.c_str())); - p += strlen(channels[c].name.c_str()); + memcpy(p, channels[c].name.c_str(), channels[c].name.length()); + p += channels[c].name.length(); (*p) = '\0'; p++; - int pixel_type = channels[c].pixel_type; + int pixel_type = channels[c].requested_pixel_type; int x_sampling = channels[c].x_sampling; int y_sampling = channels[c].y_sampling; tinyexr::swap4(&pixel_type); @@ -7650,11 +1265,11 @@ static void CompressZip(unsigned char *dst, // Compress the data using miniz // - miniz::mz_ulong outSize = miniz::mz_compressBound(src_size); - int ret = miniz::mz_compress( + mz_ulong outSize = mz_compressBound(src_size); + int ret = mz_compress( dst, &outSize, static_cast<const unsigned char *>(&tmpBuf.at(0)), src_size); - assert(ret == miniz::MZ_OK); + assert(ret == MZ_OK); (void)ret; compressedSize = outSize; @@ -7687,8 +1302,8 @@ static bool DecompressZip(unsigned char *dst, #if TINYEXR_USE_MINIZ int ret = - miniz::mz_uncompress(&tmpBuf.at(0), uncompressed_size, src, src_size); - if (miniz::MZ_OK != ret) { + mz_uncompress(&tmpBuf.at(0), uncompressed_size, src, src_size); + if (MZ_OK != ret) { return false; } #else @@ -8989,7 +2604,8 @@ static bool getCode(int po, int rlc, long long &c, int &lc, const char *&in, if (po == rlc) { if (lc < 8) { /* TinyEXR issue 78 */ - if ((in + 1) >= in_end) { + /* TinyEXR issue 160. in + 1 -> in */ + if (in >= in_end) { return false; } @@ -9332,7 +2948,7 @@ static bool CompressPiz(unsigned char *outPtr, unsigned int *outSize, unsigned short minNonZero; unsigned short maxNonZero; -#if !MINIZ_LITTLE_ENDIAN +#if !TINYEXR_LITTLE_ENDIAN // @todo { PIZ compression on BigEndian architecture. } assert(0); return false; @@ -9355,7 +2971,7 @@ static bool CompressPiz(unsigned char *outPtr, unsigned int *outSize, // cd.ys = c.channel().ySampling; size_t pixelSize = sizeof(int); // UINT and FLOAT - if (channelInfo[c].pixel_type == TINYEXR_PIXELTYPE_HALF) { + if (channelInfo[c].requested_pixel_type == TINYEXR_PIXELTYPE_HALF) { pixelSize = sizeof(short); } @@ -9445,10 +3061,10 @@ static bool CompressPiz(unsigned char *outPtr, unsigned int *outSize, } static bool DecompressPiz(unsigned char *outPtr, const unsigned char *inPtr, - size_t tmpBufSize, size_t inLen, int num_channels, + size_t tmpBufSizeInBytes, size_t inLen, int num_channels, const EXRChannelInfo *channels, int data_width, int num_lines) { - if (inLen == tmpBufSize) { + if (inLen == tmpBufSizeInBytes) { // Data is not compressed(Issue 40). memcpy(outPtr, inPtr, inLen); return true; @@ -9458,7 +3074,7 @@ static bool DecompressPiz(unsigned char *outPtr, const unsigned char *inPtr, unsigned short minNonZero; unsigned short maxNonZero; -#if !MINIZ_LITTLE_ENDIAN +#if !TINYEXR_LITTLE_ENDIAN // @todo { PIZ compression on BigEndian architecture. } assert(0); return false; @@ -9501,7 +3117,7 @@ static bool DecompressPiz(unsigned char *outPtr, const unsigned char *inPtr, return false; } - std::vector<unsigned short> tmpBuffer(tmpBufSize); + std::vector<unsigned short> tmpBuffer(tmpBufSizeInBytes / sizeof(unsigned short)); hufUncompress(reinterpret_cast<const char *>(ptr), length, &tmpBuffer); // @@ -9543,7 +3159,7 @@ static bool DecompressPiz(unsigned char *outPtr, const unsigned char *inPtr, // Expand the pixel data to their original range // - applyLut(lut.data(), &tmpBuffer.at(0), static_cast<int>(tmpBufSize)); + applyLut(lut.data(), &tmpBuffer.at(0), static_cast<int>(tmpBufSizeInBytes / sizeof(unsigned short))); for (int y = 0; y < num_lines; y++) { for (size_t i = 0; i < channelData.size(); ++i) { @@ -9802,6 +3418,9 @@ static bool CompressZfp(std::vector<unsigned char> *outBuf, // ----------------------------------------------------------------- // +// heuristics +#define TINYEXR_DIMENSION_THRESHOLD (1024 * 8192) + // TODO(syoyo): Refactor function arguments. static bool DecodePixelData(/* out */ unsigned char **out_images, const int *requested_pixel_types, @@ -10432,8 +4051,8 @@ static bool DecodeTiledPixelData( const EXRAttribute *attributes, size_t num_channels, const EXRChannelInfo *channels, const std::vector<size_t> &channel_offset_list) { - if (tile_size_x > data_width || tile_size_y > data_height || - tile_size_x * tile_offset_x > data_width || + // Here, data_width and data_height are the dimensions of the current (sub)level. + if (tile_size_x * tile_offset_x > data_width || tile_size_y * tile_offset_y > data_height) { return false; } @@ -10541,6 +4160,7 @@ static inline std::wstring UTF8ToWchar(const std::string &str) { } #endif + static int ParseEXRHeader(HeaderInfo *info, bool *empty_header, const EXRVersion *version, std::string *err, const unsigned char *buf, size_t size) { @@ -10579,6 +4199,11 @@ static int ParseEXRHeader(HeaderInfo *info, bool *empty_header, bool has_pixel_aspect_ratio = false; bool has_screen_window_center = false; bool has_screen_window_width = false; + bool has_name = false; + bool has_type = false; + + info->name.clear(); + info->type.clear(); info->data_window.min_x = 0; info->data_window.min_y = 0; @@ -10594,6 +4219,7 @@ static int ParseEXRHeader(HeaderInfo *info, bool *empty_header, info->screen_window_width = -1.0f; info->pixel_aspect_ratio = -1.0f; + info->tiled = 0; info->tile_size_x = -1; info->tile_size_y = -1; info->tile_level_mode = -1; @@ -10628,7 +4254,8 @@ static int ParseEXRHeader(HeaderInfo *info, bool *empty_header, marker += marker_size; size -= marker_size; - if (version->tiled && attr_name.compare("tiles") == 0) { + // For a multipart file, the version field 9th bit is 0. + if ((version->tiled || version->multipart || version->non_image) && attr_name.compare("tiles") == 0) { unsigned int x_size, y_size; unsigned char tile_mode; assert(data.size() == 9); @@ -10652,7 +4279,7 @@ static int ParseEXRHeader(HeaderInfo *info, bool *empty_header, // mode = levelMode + roundingMode * 16 info->tile_level_mode = tile_mode & 0x3; info->tile_rounding_mode = (tile_mode >> 4) & 0x1; - + info->tiled = 1; } else if (attr_name.compare("compression") == 0) { bool ok = false; if (data[0] < TINYEXR_COMPRESSIONTYPE_PIZ) { @@ -10771,6 +4398,22 @@ static int ParseEXRHeader(HeaderInfo *info, bool *empty_header, memcpy(&info->chunk_count, &data.at(0), sizeof(int)); tinyexr::swap4(&info->chunk_count); } + } else if (attr_name.compare("name") == 0) { + if (!data.empty() && data[0]) { + data.push_back(0); + size_t len = strlen(reinterpret_cast<const char*>(&data[0])); + info->name.resize(len); + info->name.assign(reinterpret_cast<const char*>(&data[0]), len); + has_name = true; + } + } else if (attr_name.compare("type") == 0) { + if (!data.empty() && data[0]) { + data.push_back(0); + size_t len = strlen(reinterpret_cast<const char*>(&data[0])); + info->type.resize(len); + info->type.assign(reinterpret_cast<const char*>(&data[0]), len); + has_type = true; + } } else { // Custom attribute(up to TINYEXR_MAX_CUSTOM_ATTRIBUTES) if (info->attributes.size() < TINYEXR_MAX_CUSTOM_ATTRIBUTES) { @@ -10835,6 +4478,17 @@ static int ParseEXRHeader(HeaderInfo *info, bool *empty_header, << std::endl; } + if (version->multipart || version->non_image) { + if (!has_name) { + ss_err << "\"name\" attribute not found in the header." + << std::endl; + } + if (!has_type) { + ss_err << "\"type\" attribute not found in the header." + << std::endl; + } + } + if (!(ss_err.str().empty())) { if (err) { (*err) += ss_err.str(); @@ -10865,12 +4519,30 @@ static void ConvertHeader(EXRHeader *exr_header, const HeaderInfo &info) { exr_header->data_window.max_y = info.data_window.max_y; exr_header->line_order = info.line_order; exr_header->compression_type = info.compression_type; - + exr_header->tiled = info.tiled; exr_header->tile_size_x = info.tile_size_x; exr_header->tile_size_y = info.tile_size_y; exr_header->tile_level_mode = info.tile_level_mode; exr_header->tile_rounding_mode = info.tile_rounding_mode; + EXRSetNameAttr(exr_header, info.name.c_str()); + + if (!info.type.empty()) { + if (info.type == "scanlineimage") { + assert(!exr_header->tiled); + } else if (info.type == "tiledimage") { + assert(exr_header->tiled); + } else if (info.type == "deeptile") { + exr_header->non_image = 1; + assert(exr_header->tiled); + } else if (info.type == "deepscanline") { + exr_header->non_image = 1; + assert(!exr_header->tiled); + } else { + assert(false); + } + } + exr_header->num_channels = static_cast<int>(info.channels.size()); exr_header->channels = static_cast<EXRChannelInfo *>(malloc( @@ -10932,8 +4604,216 @@ static void ConvertHeader(EXRHeader *exr_header, const HeaderInfo &info) { exr_header->header_len = info.header_len; } +struct OffsetData { + OffsetData() : num_x_levels(0), num_y_levels(0) {} + std::vector<std::vector<std::vector <tinyexr::tinyexr_uint64> > > offsets; + int num_x_levels; + int num_y_levels; +}; + +int LevelIndex(int lx, int ly, int tile_level_mode, int num_x_levels) { + switch (tile_level_mode) { + case TINYEXR_TILE_ONE_LEVEL: + return 0; + + case TINYEXR_TILE_MIPMAP_LEVELS: + return lx; + + case TINYEXR_TILE_RIPMAP_LEVELS: + return lx + ly * num_x_levels; + + default: + assert(false); + } + return 0; +} + +static int LevelSize(int toplevel_size, int level, int tile_rounding_mode) { + assert(level >= 0); + + int b = (int)(1u << (unsigned)level); + int level_size = toplevel_size / b; + + if (tile_rounding_mode == TINYEXR_TILE_ROUND_UP && level_size * b < toplevel_size) + level_size += 1; + + return std::max(level_size, 1); +} + +static int DecodeTiledLevel(EXRImage* exr_image, const EXRHeader* exr_header, + const OffsetData& offset_data, + const std::vector<size_t>& channel_offset_list, + int pixel_data_size, + const unsigned char* head, const size_t size, + std::string* err) { + int num_channels = exr_header->num_channels; + + int level_index = LevelIndex(exr_image->level_x, exr_image->level_y, exr_header->tile_level_mode, offset_data.num_x_levels); + int num_y_tiles = (int)offset_data.offsets[level_index].size(); + assert(num_y_tiles); + int num_x_tiles = (int)offset_data.offsets[level_index][0].size(); + assert(num_x_tiles); + int num_tiles = num_x_tiles * num_y_tiles; + + int err_code = TINYEXR_SUCCESS; + + enum { + EF_SUCCESS = 0, + EF_INVALID_DATA = 1, + EF_INSUFFICIENT_DATA = 2, + EF_FAILED_TO_DECODE = 4 + }; +#if TINYEXR_HAS_CXX11 && (TINYEXR_USE_THREAD > 0) + std::atomic<unsigned> error_flag(EF_SUCCESS); +#else + unsigned error_flag(EF_SUCCESS); +#endif + + // Although the spec says : "...the data window is subdivided into an array of smaller rectangles...", + // the IlmImf library allows the dimensions of the tile to be larger (or equal) than the dimensions of the data window. +#if 0 + if ((exr_header->tile_size_x > exr_image->width || exr_header->tile_size_y > exr_image->height) && + exr_image->level_x == 0 && exr_image->level_y == 0) { + if (err) { + (*err) += "Failed to decode tile data.\n"; + } + err_code = TINYEXR_ERROR_INVALID_DATA; + } +#endif + exr_image->tiles = static_cast<EXRTile*>( + calloc(sizeof(EXRTile), static_cast<size_t>(num_tiles))); + +#if TINYEXR_HAS_CXX11 && (TINYEXR_USE_THREAD > 0) + std::vector<std::thread> workers; + std::atomic<int> tile_count(0); + + int num_threads = std::max(1, int(std::thread::hardware_concurrency())); + if (num_threads > int(num_tiles)) { + num_threads = int(num_tiles); + } + + for (int t = 0; t < num_threads; t++) { + workers.emplace_back(std::thread([&]() + { + int tile_idx = 0; + while ((tile_idx = tile_count++) < num_tiles) { + +#else +#if TINYEXR_USE_OPENMP +#pragma omp parallel for +#endif + for (int tile_idx = 0; tile_idx < num_tiles; tile_idx++) { +#endif + // Allocate memory for each tile. + exr_image->tiles[tile_idx].images = tinyexr::AllocateImage( + num_channels, exr_header->channels, + exr_header->requested_pixel_types, exr_header->tile_size_x, + exr_header->tile_size_y); + + int x_tile = tile_idx % num_x_tiles; + int y_tile = tile_idx / num_x_tiles; + // 16 byte: tile coordinates + // 4 byte : data size + // ~ : data(uncompressed or compressed) + tinyexr::tinyexr_uint64 offset = offset_data.offsets[level_index][y_tile][x_tile]; + if (offset + sizeof(int) * 5 > size) { + // Insufficient data size. + error_flag |= EF_INSUFFICIENT_DATA; + continue; + } + + size_t data_size = + size_t(size - (offset + sizeof(int) * 5)); + const unsigned char* data_ptr = + reinterpret_cast<const unsigned char*>(head + offset); + + int tile_coordinates[4]; + memcpy(tile_coordinates, data_ptr, sizeof(int) * 4); + tinyexr::swap4(&tile_coordinates[0]); + tinyexr::swap4(&tile_coordinates[1]); + tinyexr::swap4(&tile_coordinates[2]); + tinyexr::swap4(&tile_coordinates[3]); + + if (tile_coordinates[2] != exr_image->level_x) { + // Invalid data. + error_flag |= EF_INVALID_DATA; + continue; + } + if (tile_coordinates[3] != exr_image->level_y) { + // Invalid data. + error_flag |= EF_INVALID_DATA; + continue; + } + + int data_len; + memcpy(&data_len, data_ptr + 16, + sizeof(int)); // 16 = sizeof(tile_coordinates) + tinyexr::swap4(&data_len); + + if (data_len < 2 || size_t(data_len) > data_size) { + // Insufficient data size. + error_flag |= EF_INSUFFICIENT_DATA; + continue; + } + + // Move to data addr: 20 = 16 + 4; + data_ptr += 20; + bool ret = tinyexr::DecodeTiledPixelData( + exr_image->tiles[tile_idx].images, + &(exr_image->tiles[tile_idx].width), + &(exr_image->tiles[tile_idx].height), + exr_header->requested_pixel_types, data_ptr, + static_cast<size_t>(data_len), exr_header->compression_type, + exr_header->line_order, + exr_image->width, exr_image->height, + tile_coordinates[0], tile_coordinates[1], exr_header->tile_size_x, + exr_header->tile_size_y, static_cast<size_t>(pixel_data_size), + static_cast<size_t>(exr_header->num_custom_attributes), + exr_header->custom_attributes, + static_cast<size_t>(exr_header->num_channels), + exr_header->channels, channel_offset_list); + + if (!ret) { + // Failed to decode tile data. + error_flag |= EF_FAILED_TO_DECODE; + } + + exr_image->tiles[tile_idx].offset_x = tile_coordinates[0]; + exr_image->tiles[tile_idx].offset_y = tile_coordinates[1]; + exr_image->tiles[tile_idx].level_x = tile_coordinates[2]; + exr_image->tiles[tile_idx].level_y = tile_coordinates[3]; + +#if TINYEXR_HAS_CXX11 && (TINYEXR_USE_THREAD > 0) + } + })); + } // num_thread loop + + for (auto& t : workers) { + t.join(); + } + +#else + } // parallel for +#endif + + // Even in the event of an error, the reserved memory may be freed. + exr_image->num_channels = num_channels; + exr_image->num_tiles = static_cast<int>(num_tiles); + + if (error_flag) err_code = TINYEXR_ERROR_INVALID_DATA; + if (err) { + if (error_flag & EF_INSUFFICIENT_DATA) { + (*err) += "Insufficient data length.\n"; + } + if (error_flag & EF_FAILED_TO_DECODE) { + (*err) += "Failed to decode tile data.\n"; + } + } + return err_code; +} + static int DecodeChunk(EXRImage *exr_image, const EXRHeader *exr_header, - const std::vector<tinyexr::tinyexr_uint64> &offsets, + const OffsetData& offset_data, const unsigned char *head, const size_t size, std::string *err) { int num_channels = exr_header->num_channels; @@ -10971,8 +4851,7 @@ static int DecodeChunk(EXRImage *exr_image, const EXRHeader *exr_header, // Do not allow too large data_width and data_height. header invalid? { - const int threshold = 1024 * 8192; // heuristics - if ((data_width > threshold) || (data_height > threshold)) { + if ((data_width > TINYEXR_DIMENSION_THRESHOLD) || (data_height > TINYEXR_DIMENSION_THRESHOLD)) { if (err) { std::stringstream ss; ss << "data_with or data_height too large. data_width: " << data_width @@ -10982,8 +4861,21 @@ static int DecodeChunk(EXRImage *exr_image, const EXRHeader *exr_header, } return TINYEXR_ERROR_INVALID_DATA; } + if (exr_header->tiled) { + if ((exr_header->tile_size_x > TINYEXR_DIMENSION_THRESHOLD) || (exr_header->tile_size_y > TINYEXR_DIMENSION_THRESHOLD)) { + if (err) { + std::stringstream ss; + ss << "tile with or tile height too large. tile width: " << exr_header->tile_size_x + << ", " + << "tile height = " << exr_header->tile_size_y << std::endl; + (*err) += ss.str(); + } + return TINYEXR_ERROR_INVALID_DATA; + } + } } + const std::vector<tinyexr::tinyexr_uint64>& offsets = offset_data.offsets[0][0]; size_t num_blocks = offsets.size(); std::vector<size_t> channel_offset_list; @@ -10998,7 +4890,11 @@ static int DecodeChunk(EXRImage *exr_image, const EXRHeader *exr_header, return TINYEXR_ERROR_INVALID_DATA; } - bool invalid_data = false; // TODO(LTE): Use atomic lock for MT safety. +#if TINYEXR_HAS_CXX11 && (TINYEXR_USE_THREAD > 0) + std::atomic<bool> invalid_data(false); +#else + bool invalid_data(false); +#endif if (exr_header->tiled) { // value check @@ -11019,136 +4915,60 @@ static int DecodeChunk(EXRImage *exr_image, const EXRHeader *exr_header, } return TINYEXR_ERROR_INVALID_HEADER; } - - size_t num_tiles = offsets.size(); // = # of blocks - - exr_image->tiles = static_cast<EXRTile *>( - calloc(sizeof(EXRTile), static_cast<size_t>(num_tiles))); - - int err_code = TINYEXR_SUCCESS; - -#if (__cplusplus > 199711L) && (TINYEXR_USE_THREAD > 0) - - std::vector<std::thread> workers; - std::atomic<size_t> tile_count(0); - - int num_threads = std::max(1, int(std::thread::hardware_concurrency())); - if (num_threads > int(num_tiles)) { - num_threads = int(num_tiles); - } - - for (int t = 0; t < num_threads; t++) { - workers.emplace_back(std::thread([&]() { - size_t tile_idx = 0; - while ((tile_idx = tile_count++) < num_tiles) { - -#else - for (size_t tile_idx = 0; tile_idx < num_tiles; tile_idx++) { -#endif - // Allocate memory for each tile. - exr_image->tiles[tile_idx].images = tinyexr::AllocateImage( - num_channels, exr_header->channels, - exr_header->requested_pixel_types, exr_header->tile_size_x, - exr_header->tile_size_y); - - // 16 byte: tile coordinates - // 4 byte : data size - // ~ : data(uncompressed or compressed) - if (offsets[tile_idx] + sizeof(int) * 5 > size) { - // TODO(LTE): atomic - if (err) { - (*err) += "Insufficient data size.\n"; - } - err_code = TINYEXR_ERROR_INVALID_DATA; - break; - } - - size_t data_size = - size_t(size - (offsets[tile_idx] + sizeof(int) * 5)); - const unsigned char *data_ptr = - reinterpret_cast<const unsigned char *>(head + offsets[tile_idx]); - - int tile_coordinates[4]; - memcpy(tile_coordinates, data_ptr, sizeof(int) * 4); - tinyexr::swap4(&tile_coordinates[0]); - tinyexr::swap4(&tile_coordinates[1]); - tinyexr::swap4(&tile_coordinates[2]); - tinyexr::swap4(&tile_coordinates[3]); - - // @todo{ LoD } - if (tile_coordinates[2] != 0) { - err_code = TINYEXR_ERROR_UNSUPPORTED_FEATURE; - break; - } - if (tile_coordinates[3] != 0) { - err_code = TINYEXR_ERROR_UNSUPPORTED_FEATURE; - break; - } - - int data_len; - memcpy(&data_len, data_ptr + 16, - sizeof(int)); // 16 = sizeof(tile_coordinates) - tinyexr::swap4(&data_len); - - if (data_len < 4 || size_t(data_len) > data_size) { - // TODO(LTE): atomic - if (err) { - (*err) += "Insufficient data length.\n"; - } - err_code = TINYEXR_ERROR_INVALID_DATA; - break; - } - - // Move to data addr: 20 = 16 + 4; - data_ptr += 20; - - bool ret = tinyexr::DecodeTiledPixelData( - exr_image->tiles[tile_idx].images, - &(exr_image->tiles[tile_idx].width), - &(exr_image->tiles[tile_idx].height), - exr_header->requested_pixel_types, data_ptr, - static_cast<size_t>(data_len), exr_header->compression_type, - exr_header->line_order, data_width, data_height, - tile_coordinates[0], tile_coordinates[1], exr_header->tile_size_x, - exr_header->tile_size_y, static_cast<size_t>(pixel_data_size), - static_cast<size_t>(exr_header->num_custom_attributes), - exr_header->custom_attributes, - static_cast<size_t>(exr_header->num_channels), - exr_header->channels, channel_offset_list); - - if (!ret) { - // TODO(LTE): atomic - if (err) { - (*err) += "Failed to decode tile data.\n"; - } - err_code = TINYEXR_ERROR_INVALID_DATA; + if (exr_header->tile_level_mode != TINYEXR_TILE_RIPMAP_LEVELS) { + EXRImage* level_image = NULL; + for (int level = 0; level < offset_data.num_x_levels; ++level) { + if (!level_image) { + level_image = exr_image; + } else { + level_image->next_level = new EXRImage; + InitEXRImage(level_image->next_level); + level_image = level_image->next_level; + } + level_image->width = + LevelSize(exr_header->data_window.max_x - exr_header->data_window.min_x + 1, level, exr_header->tile_rounding_mode); + level_image->height = + LevelSize(exr_header->data_window.max_y - exr_header->data_window.min_y + 1, level, exr_header->tile_rounding_mode); + level_image->level_x = level; + level_image->level_y = level; + + int ret = DecodeTiledLevel(level_image, exr_header, + offset_data, + channel_offset_list, + pixel_data_size, + head, size, + err); + if (ret != TINYEXR_SUCCESS) return ret; + } + } else { + EXRImage* level_image = NULL; + for (int level_y = 0; level_y < offset_data.num_y_levels; ++level_y) + for (int level_x = 0; level_x < offset_data.num_x_levels; ++level_x) { + if (!level_image) { + level_image = exr_image; + } else { + level_image->next_level = new EXRImage; + InitEXRImage(level_image->next_level); + level_image = level_image->next_level; } - exr_image->tiles[tile_idx].offset_x = tile_coordinates[0]; - exr_image->tiles[tile_idx].offset_y = tile_coordinates[1]; - exr_image->tiles[tile_idx].level_x = tile_coordinates[2]; - exr_image->tiles[tile_idx].level_y = tile_coordinates[3]; - -#if (__cplusplus > 199711L) && (TINYEXR_USE_THREAD > 0) + level_image->width = + LevelSize(exr_header->data_window.max_x - exr_header->data_window.min_x + 1, level_x, exr_header->tile_rounding_mode); + level_image->height = + LevelSize(exr_header->data_window.max_y - exr_header->data_window.min_y + 1, level_y, exr_header->tile_rounding_mode); + level_image->level_x = level_x; + level_image->level_y = level_y; + + int ret = DecodeTiledLevel(level_image, exr_header, + offset_data, + channel_offset_list, + pixel_data_size, + head, size, + err); + if (ret != TINYEXR_SUCCESS) return ret; } - })); - } // num_thread loop - - for (auto &t : workers) { - t.join(); } - -#else - } -#endif - - if (err_code != TINYEXR_SUCCESS) { - return err_code; - } - - exr_image->num_tiles = static_cast<int>(num_tiles); } else { // scanline format - // Don't allow too large image(256GB * pixel_data_size or more). Workaround // for #104. size_t total_data_len = @@ -11170,7 +4990,7 @@ static int DecodeChunk(EXRImage *exr_image, const EXRHeader *exr_header, num_channels, exr_header->channels, exr_header->requested_pixel_types, data_width, data_height); -#if (__cplusplus > 199711L) && (TINYEXR_USE_THREAD > 0) +#if TINYEXR_HAS_CXX11 && (TINYEXR_USE_THREAD > 0) std::vector<std::thread> workers; std::atomic<int> y_count(0); @@ -11271,7 +5091,7 @@ static int DecodeChunk(EXRImage *exr_image, const EXRHeader *exr_header, } } -#if (__cplusplus > 199711L) && (TINYEXR_USE_THREAD > 0) +#if TINYEXR_HAS_CXX11 && (TINYEXR_USE_THREAD > 0) } })); } @@ -11286,7 +5106,6 @@ static int DecodeChunk(EXRImage *exr_image, const EXRHeader *exr_header, if (invalid_data) { if (err) { - std::stringstream ss; (*err) += "Invalid data found when decoding pixels.\n"; } return TINYEXR_ERROR_INVALID_DATA; @@ -11343,6 +5162,370 @@ static bool ReconstructLineOffsets( return true; } + +static int FloorLog2(unsigned x) { + // + // For x > 0, floorLog2(y) returns floor(log(x)/log(2)). + // + int y = 0; + while (x > 1) { + y += 1; + x >>= 1u; + } + return y; +} + + +static int CeilLog2(unsigned x) { + // + // For x > 0, ceilLog2(y) returns ceil(log(x)/log(2)). + // + int y = 0; + int r = 0; + while (x > 1) { + if (x & 1) + r = 1; + + y += 1; + x >>= 1u; + } + return y + r; +} + +static int RoundLog2(int x, int tile_rounding_mode) { + return (tile_rounding_mode == TINYEXR_TILE_ROUND_DOWN) ? FloorLog2(static_cast<unsigned>(x)) : CeilLog2(static_cast<unsigned>(x)); +} + +static int CalculateNumXLevels(const EXRHeader* exr_header) { + int min_x = exr_header->data_window.min_x; + int max_x = exr_header->data_window.max_x; + int min_y = exr_header->data_window.min_y; + int max_y = exr_header->data_window.max_y; + + int num = 0; + switch (exr_header->tile_level_mode) { + case TINYEXR_TILE_ONE_LEVEL: + + num = 1; + break; + + case TINYEXR_TILE_MIPMAP_LEVELS: + + { + int w = max_x - min_x + 1; + int h = max_y - min_y + 1; + num = RoundLog2(std::max(w, h), exr_header->tile_rounding_mode) + 1; + } + break; + + case TINYEXR_TILE_RIPMAP_LEVELS: + + { + int w = max_x - min_x + 1; + num = RoundLog2(w, exr_header->tile_rounding_mode) + 1; + } + break; + + default: + + assert(false); + } + + return num; +} + +static int CalculateNumYLevels(const EXRHeader* exr_header) { + int min_x = exr_header->data_window.min_x; + int max_x = exr_header->data_window.max_x; + int min_y = exr_header->data_window.min_y; + int max_y = exr_header->data_window.max_y; + int num = 0; + + switch (exr_header->tile_level_mode) { + case TINYEXR_TILE_ONE_LEVEL: + + num = 1; + break; + + case TINYEXR_TILE_MIPMAP_LEVELS: + + { + int w = max_x - min_x + 1; + int h = max_y - min_y + 1; + num = RoundLog2(std::max(w, h), exr_header->tile_rounding_mode) + 1; + } + break; + + case TINYEXR_TILE_RIPMAP_LEVELS: + + { + int h = max_y - min_y + 1; + num = RoundLog2(h, exr_header->tile_rounding_mode) + 1; + } + break; + + default: + + assert(false); + } + + return num; +} + +static void CalculateNumTiles(std::vector<int>& numTiles, + int toplevel_size, + int size, + int tile_rounding_mode) { + for (unsigned i = 0; i < numTiles.size(); i++) { + int l = LevelSize(toplevel_size, i, tile_rounding_mode); + assert(l <= std::numeric_limits<int>::max() - size + 1); + + numTiles[i] = (l + size - 1) / size; + } +} + +static void PrecalculateTileInfo(std::vector<int>& num_x_tiles, + std::vector<int>& num_y_tiles, + const EXRHeader* exr_header) { + int min_x = exr_header->data_window.min_x; + int max_x = exr_header->data_window.max_x; + int min_y = exr_header->data_window.min_y; + int max_y = exr_header->data_window.max_y; + + int num_x_levels = CalculateNumXLevels(exr_header); + int num_y_levels = CalculateNumYLevels(exr_header); + + num_x_tiles.resize(num_x_levels); + num_y_tiles.resize(num_y_levels); + + CalculateNumTiles(num_x_tiles, + max_x - min_x + 1, + exr_header->tile_size_x, + exr_header->tile_rounding_mode); + + CalculateNumTiles(num_y_tiles, + max_y - min_y + 1, + exr_header->tile_size_y, + exr_header->tile_rounding_mode); +} + +static void InitSingleResolutionOffsets(OffsetData& offset_data, size_t num_blocks) { + offset_data.offsets.resize(1); + offset_data.offsets[0].resize(1); + offset_data.offsets[0][0].resize(num_blocks); + offset_data.num_x_levels = 1; + offset_data.num_y_levels = 1; +} + +// Return sum of tile blocks. +static int InitTileOffsets(OffsetData& offset_data, + const EXRHeader* exr_header, + const std::vector<int>& num_x_tiles, + const std::vector<int>& num_y_tiles) { + int num_tile_blocks = 0; + offset_data.num_x_levels = static_cast<int>(num_x_tiles.size()); + offset_data.num_y_levels = static_cast<int>(num_y_tiles.size()); + switch (exr_header->tile_level_mode) { + case TINYEXR_TILE_ONE_LEVEL: + case TINYEXR_TILE_MIPMAP_LEVELS: + assert(offset_data.num_x_levels == offset_data.num_y_levels); + offset_data.offsets.resize(offset_data.num_x_levels); + + for (unsigned int l = 0; l < offset_data.offsets.size(); ++l) { + offset_data.offsets[l].resize(num_y_tiles[l]); + + for (unsigned int dy = 0; dy < offset_data.offsets[l].size(); ++dy) { + offset_data.offsets[l][dy].resize(num_x_tiles[l]); + num_tile_blocks += num_x_tiles[l]; + } + } + break; + + case TINYEXR_TILE_RIPMAP_LEVELS: + + offset_data.offsets.resize(static_cast<size_t>(offset_data.num_x_levels) * static_cast<size_t>(offset_data.num_y_levels)); + + for (int ly = 0; ly < offset_data.num_y_levels; ++ly) { + for (int lx = 0; lx < offset_data.num_x_levels; ++lx) { + int l = ly * offset_data.num_x_levels + lx; + offset_data.offsets[l].resize(num_y_tiles[ly]); + + for (size_t dy = 0; dy < offset_data.offsets[l].size(); ++dy) { + offset_data.offsets[l][dy].resize(num_x_tiles[lx]); + num_tile_blocks += num_x_tiles[lx]; + } + } + } + break; + + default: + assert(false); + } + return num_tile_blocks; +} + +static bool IsAnyOffsetsAreInvalid(const OffsetData& offset_data) { + for (unsigned int l = 0; l < offset_data.offsets.size(); ++l) + for (unsigned int dy = 0; dy < offset_data.offsets[l].size(); ++dy) + for (unsigned int dx = 0; dx < offset_data.offsets[l][dy].size(); ++dx) + if (reinterpret_cast<const tinyexr::tinyexr_int64&>(offset_data.offsets[l][dy][dx]) <= 0) + return true; + + return false; +} + +static bool isValidTile(const EXRHeader* exr_header, + const OffsetData& offset_data, + int dx, int dy, int lx, int ly) { + if (lx < 0 || ly < 0 || dx < 0 || dy < 0) return false; + int num_x_levels = offset_data.num_x_levels; + int num_y_levels = offset_data.num_y_levels; + switch (exr_header->tile_level_mode) { + case TINYEXR_TILE_ONE_LEVEL: + + if (lx == 0 && + ly == 0 && + offset_data.offsets.size() > 0 && + offset_data.offsets[0].size() > static_cast<size_t>(dy) && + offset_data.offsets[0][dy].size() > static_cast<size_t>(dx)) { + return true; + } + + break; + + case TINYEXR_TILE_MIPMAP_LEVELS: + + if (lx < num_x_levels && + ly < num_y_levels && + offset_data.offsets.size() > static_cast<size_t>(lx) && + offset_data.offsets[lx].size() > static_cast<size_t>(dy) && + offset_data.offsets[lx][dy].size() > static_cast<size_t>(dx)) { + return true; + } + + break; + + case TINYEXR_TILE_RIPMAP_LEVELS: + { + size_t idx = static_cast<size_t>(lx) + static_cast<size_t>(ly)* static_cast<size_t>(num_x_levels); + if (lx < num_x_levels && + ly < num_y_levels && + (offset_data.offsets.size() > idx) && + offset_data.offsets[idx].size() > static_cast<size_t>(dy) && + offset_data.offsets[idx][dy].size() > static_cast<size_t>(dx)) { + return true; + } + } + + break; + + default: + + return false; + } + + return false; +} + +static void ReconstructTileOffsets(OffsetData& offset_data, + const EXRHeader* exr_header, + const unsigned char* head, const unsigned char* marker, const size_t /*size*/, + bool isMultiPartFile, + bool isDeep) { + int numXLevels = offset_data.num_x_levels; + for (unsigned int l = 0; l < offset_data.offsets.size(); ++l) { + for (unsigned int dy = 0; dy < offset_data.offsets[l].size(); ++dy) { + for (unsigned int dx = 0; dx < offset_data.offsets[l][dy].size(); ++dx) { + tinyexr::tinyexr_uint64 tileOffset = marker - head; + + if (isMultiPartFile) { + //int partNumber; + marker += sizeof(int); + } + + int tileX; + memcpy(&tileX, marker, sizeof(int)); + tinyexr::swap4(&tileX); + marker += sizeof(int); + + int tileY; + memcpy(&tileY, marker, sizeof(int)); + tinyexr::swap4(&tileY); + marker += sizeof(int); + + int levelX; + memcpy(&levelX, marker, sizeof(int)); + tinyexr::swap4(&levelX); + marker += sizeof(int); + + int levelY; + memcpy(&levelY, marker, sizeof(int)); + tinyexr::swap4(&levelY); + marker += sizeof(int); + + if (isDeep) { + tinyexr::tinyexr_int64 packed_offset_table_size; + memcpy(&packed_offset_table_size, marker, sizeof(tinyexr::tinyexr_int64)); + tinyexr::swap8(reinterpret_cast<tinyexr::tinyexr_uint64*>(&packed_offset_table_size)); + marker += sizeof(tinyexr::tinyexr_int64); + + tinyexr::tinyexr_int64 packed_sample_size; + memcpy(&packed_sample_size, marker, sizeof(tinyexr::tinyexr_int64)); + tinyexr::swap8(reinterpret_cast<tinyexr::tinyexr_uint64*>(&packed_sample_size)); + marker += sizeof(tinyexr::tinyexr_int64); + + // next Int64 is unpacked sample size - skip that too + marker += packed_offset_table_size + packed_sample_size + 8; + + } else { + + int dataSize; + memcpy(&dataSize, marker, sizeof(int)); + tinyexr::swap4(&dataSize); + marker += sizeof(int); + marker += dataSize; + } + + if (!isValidTile(exr_header, offset_data, + tileX, tileY, levelX, levelY)) + return; + + int level_idx = LevelIndex(levelX, levelY, exr_header->tile_level_mode, numXLevels); + offset_data.offsets[level_idx][tileY][tileX] = tileOffset; + } + } + } +} + +// marker output is also +static int ReadOffsets(OffsetData& offset_data, + const unsigned char* head, + const unsigned char*& marker, + const size_t size, + const char** err) { + for (unsigned int l = 0; l < offset_data.offsets.size(); ++l) { + for (unsigned int dy = 0; dy < offset_data.offsets[l].size(); ++dy) { + for (unsigned int dx = 0; dx < offset_data.offsets[l][dy].size(); ++dx) { + tinyexr::tinyexr_uint64 offset; + if ((marker + sizeof(tinyexr_uint64)) >= (head + size)) { + tinyexr::SetErrorMessage("Insufficient data size in offset table.", err); + return TINYEXR_ERROR_INVALID_DATA; + } + + memcpy(&offset, marker, sizeof(tinyexr::tinyexr_uint64)); + tinyexr::swap8(&offset); + if (offset >= size) { + tinyexr::SetErrorMessage("Invalid offset value in DecodeEXRImage.", err); + return TINYEXR_ERROR_INVALID_DATA; + } + marker += sizeof(tinyexr::tinyexr_uint64); // = 8 + offset_data.offsets[l][dy][dx] = offset; + } + } + } + return TINYEXR_SUCCESS; +} + static int DecodeEXRImage(EXRImage *exr_image, const EXRHeader *exr_header, const unsigned char *head, const unsigned char *marker, const size_t size, @@ -11383,100 +5566,114 @@ static int DecodeEXRImage(EXRImage *exr_image, const EXRHeader *exr_header, // Do not allow too large data_width and data_height. header invalid? { - const int threshold = 1024 * 8192; // heuristics - if (data_width > threshold) { + if (data_width > TINYEXR_DIMENSION_THRESHOLD) { tinyexr::SetErrorMessage("data width too large.", err); return TINYEXR_ERROR_INVALID_DATA; } - if (data_height > threshold) { + if (data_height > TINYEXR_DIMENSION_THRESHOLD) { tinyexr::SetErrorMessage("data height too large.", err); return TINYEXR_ERROR_INVALID_DATA; } } - // Read offset tables. - size_t num_blocks = 0; - - if (exr_header->chunk_count > 0) { - // Use `chunkCount` attribute. - num_blocks = static_cast<size_t>(exr_header->chunk_count); - } else if (exr_header->tiled) { - // @todo { LoD } - if (exr_header->tile_size_x > data_width || exr_header->tile_size_x < 1 || - exr_header->tile_size_y > data_height || exr_header->tile_size_y < 1) { - tinyexr::SetErrorMessage("tile sizes are invalid.", err); + if (exr_header->tiled) { + if (exr_header->tile_size_x > TINYEXR_DIMENSION_THRESHOLD) { + tinyexr::SetErrorMessage("tile width too large.", err); return TINYEXR_ERROR_INVALID_DATA; } - - size_t num_x_tiles = static_cast<size_t>(data_width) / - static_cast<size_t>(exr_header->tile_size_x); - if (num_x_tiles * static_cast<size_t>(exr_header->tile_size_x) < - static_cast<size_t>(data_width)) { - num_x_tiles++; + if (exr_header->tile_size_y > TINYEXR_DIMENSION_THRESHOLD) { + tinyexr::SetErrorMessage("tile height too large.", err); + return TINYEXR_ERROR_INVALID_DATA; } - size_t num_y_tiles = static_cast<size_t>(data_height) / - static_cast<size_t>(exr_header->tile_size_y); - if (num_y_tiles * static_cast<size_t>(exr_header->tile_size_y) < - static_cast<size_t>(data_height)) { - num_y_tiles++; + } + + // Read offset tables. + OffsetData offset_data; + size_t num_blocks = 0; + // For a multi-resolution image, the size of the offset table will be calculated from the other attributes of the header. + // If chunk_count > 0 then chunk_count must be equal to the calculated tile count. + if (exr_header->tiled) { + { + std::vector<int> num_x_tiles, num_y_tiles; + PrecalculateTileInfo(num_x_tiles, num_y_tiles, exr_header); + num_blocks = InitTileOffsets(offset_data, exr_header, num_x_tiles, num_y_tiles); + if (exr_header->chunk_count > 0) { + if (exr_header->chunk_count != static_cast<int>(num_blocks)) { + tinyexr::SetErrorMessage("Invalid offset table size.", err); + return TINYEXR_ERROR_INVALID_DATA; + } + } } - num_blocks = num_x_tiles * num_y_tiles; + int ret = ReadOffsets(offset_data, head, marker, size, err); + if (ret != TINYEXR_SUCCESS) return ret; + if (IsAnyOffsetsAreInvalid(offset_data)) { + ReconstructTileOffsets(offset_data, exr_header, + head, marker, size, + exr_header->multipart, exr_header->non_image); + } + } else if (exr_header->chunk_count > 0) { + // Use `chunkCount` attribute. + num_blocks = static_cast<size_t>(exr_header->chunk_count); + InitSingleResolutionOffsets(offset_data, num_blocks); } else { num_blocks = static_cast<size_t>(data_height) / - static_cast<size_t>(num_scanline_blocks); + static_cast<size_t>(num_scanline_blocks); if (num_blocks * static_cast<size_t>(num_scanline_blocks) < - static_cast<size_t>(data_height)) { + static_cast<size_t>(data_height)) { num_blocks++; } - } - - std::vector<tinyexr::tinyexr_uint64> offsets(num_blocks); - - for (size_t y = 0; y < num_blocks; y++) { - tinyexr::tinyexr_uint64 offset; - // Issue #81 - if ((marker + sizeof(tinyexr_uint64)) >= (head + size)) { - tinyexr::SetErrorMessage("Insufficient data size in offset table.", err); - return TINYEXR_ERROR_INVALID_DATA; - } - memcpy(&offset, marker, sizeof(tinyexr::tinyexr_uint64)); - tinyexr::swap8(&offset); - if (offset >= size) { - tinyexr::SetErrorMessage("Invalid offset value in DecodeEXRImage.", err); - return TINYEXR_ERROR_INVALID_DATA; - } - marker += sizeof(tinyexr::tinyexr_uint64); // = 8 - offsets[y] = offset; + InitSingleResolutionOffsets(offset_data, num_blocks); } - // If line offsets are invalid, we try to reconstruct it. - // See OpenEXR/IlmImf/ImfScanLineInputFile.cpp::readLineOffsets() for details. - for (size_t y = 0; y < num_blocks; y++) { - if (offsets[y] <= 0) { - // TODO(syoyo) Report as warning? - // if (err) { - // stringstream ss; - // ss << "Incomplete lineOffsets." << std::endl; - // (*err) += ss.str(); - //} - bool ret = + if (!exr_header->tiled) { + std::vector<tinyexr::tinyexr_uint64>& offsets = offset_data.offsets[0][0]; + for (size_t y = 0; y < num_blocks; y++) { + tinyexr::tinyexr_uint64 offset; + // Issue #81 + if ((marker + sizeof(tinyexr_uint64)) >= (head + size)) { + tinyexr::SetErrorMessage("Insufficient data size in offset table.", err); + return TINYEXR_ERROR_INVALID_DATA; + } + + memcpy(&offset, marker, sizeof(tinyexr::tinyexr_uint64)); + tinyexr::swap8(&offset); + if (offset >= size) { + tinyexr::SetErrorMessage("Invalid offset value in DecodeEXRImage.", err); + return TINYEXR_ERROR_INVALID_DATA; + } + marker += sizeof(tinyexr::tinyexr_uint64); // = 8 + offsets[y] = offset; + } + + // If line offsets are invalid, we try to reconstruct it. + // See OpenEXR/IlmImf/ImfScanLineInputFile.cpp::readLineOffsets() for details. + for (size_t y = 0; y < num_blocks; y++) { + if (offsets[y] <= 0) { + // TODO(syoyo) Report as warning? + // if (err) { + // stringstream ss; + // ss << "Incomplete lineOffsets." << std::endl; + // (*err) += ss.str(); + //} + bool ret = ReconstructLineOffsets(&offsets, num_blocks, head, marker, size); - if (ret) { - // OK - break; - } else { - tinyexr::SetErrorMessage( + if (ret) { + // OK + break; + } else { + tinyexr::SetErrorMessage( "Cannot reconstruct lineOffset table in DecodeEXRImage.", err); - return TINYEXR_ERROR_INVALID_DATA; + return TINYEXR_ERROR_INVALID_DATA; + } } } } { std::string e; - int ret = DecodeChunk(exr_image, exr_header, offsets, head, size, &e); + int ret = DecodeChunk(exr_image, exr_header, offset_data, head, size, &e); if (ret != TINYEXR_SUCCESS) { if (!e.empty()) { @@ -11530,7 +5727,7 @@ struct LayerChannel { }; static void ChannelsInLayer(const EXRHeader &exr_header, - const std::string layer_name, + const std::string &layer_name, std::vector<LayerChannel> &channels) { channels.clear(); for (int c = 0; c < exr_header.num_channels; c++) { @@ -11881,8 +6078,8 @@ int ParseEXRHeaderFromMemory(EXRHeader *exr_header, const EXRVersion *version, ConvertHeader(exr_header, info); - // transfoer `tiled` from version. - exr_header->tiled = version->tiled; + exr_header->multipart = version->multipart ? 1 : 0; + exr_header->non_image = version->non_image ? 1 : 0; return ret; } @@ -12087,7 +6284,7 @@ int LoadEXRImageFromFile(EXRImage *exr_image, const EXRHeader *exr_header, FILE *fp = NULL; #ifdef _WIN32 -#if defined(_MSC_VER) || defined(__MINGW32__) // MSVC, MinGW gcc or clang +#if defined(_MSC_VER) || (defined(MINGW_HAS_SECURE_API) && MINGW_HAS_SECURE_API) // MSVC, MinGW GCC, or Clang. errno_t errcode = _wfopen_s(&fp, tinyexr::UTF8ToWchar(filename).c_str(), L"rb"); if (errcode != 0) { @@ -12096,7 +6293,7 @@ int LoadEXRImageFromFile(EXRImage *exr_image, const EXRHeader *exr_header, return TINYEXR_ERROR_CANT_OPEN_FILE; } #else - // Unknown compiler + // Unknown compiler or MinGW without MINGW_HAS_SECURE_API. fp = fopen(filename, "rb"); #endif #else @@ -12155,207 +6352,400 @@ int LoadEXRImageFromMemory(EXRImage *exr_image, const EXRHeader *exr_header, err); } -size_t SaveEXRImageToMemory(const EXRImage *exr_image, - const EXRHeader *exr_header, - unsigned char **memory_out, const char **err) { - if (exr_image == NULL || memory_out == NULL || - exr_header->compression_type < 0) { - tinyexr::SetErrorMessage("Invalid argument for SaveEXRImageToMemory", err); - return 0; - } +namespace tinyexr +{ -#if !TINYEXR_USE_PIZ - if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_PIZ) { - tinyexr::SetErrorMessage("PIZ compression is not supported in this build", - err); - return 0; - } -#endif +// out_data must be allocated initially with the block-header size +// of the current image(-part) type +static bool EncodePixelData(/* out */ std::vector<unsigned char>& out_data, + const unsigned char* const* images, + int compression_type, + int /*line_order*/, + int width, // for tiled : tile.width + int /*height*/, // for tiled : header.tile_size_y + int x_stride, // for tiled : header.tile_size_x + int line_no, // for tiled : 0 + int num_lines, // for tiled : tile.height + size_t pixel_data_size, + const std::vector<ChannelInfo>& channels, + const std::vector<size_t>& channel_offset_list, + const void* compression_param = 0) // zfp compression param +{ + size_t buf_size = static_cast<size_t>(width) * + static_cast<size_t>(num_lines) * + static_cast<size_t>(pixel_data_size); + //int last2bit = (buf_size & 3); + // buf_size must be multiple of four + //if(last2bit) buf_size += 4 - last2bit; + std::vector<unsigned char> buf(buf_size); -#if !TINYEXR_USE_ZFP - if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_ZFP) { - tinyexr::SetErrorMessage("ZFP compression is not supported in this build", - err); - return 0; - } -#endif + size_t start_y = static_cast<size_t>(line_no); + for (size_t c = 0; c < channels.size(); c++) { + if (channels[c].pixel_type == TINYEXR_PIXELTYPE_HALF) { + if (channels[c].requested_pixel_type == TINYEXR_PIXELTYPE_FLOAT) { + for (int y = 0; y < num_lines; y++) { + // Assume increasing Y + float *line_ptr = reinterpret_cast<float *>(&buf.at( + static_cast<size_t>(pixel_data_size * y * width) + + channel_offset_list[c] * + static_cast<size_t>(width))); + for (int x = 0; x < width; x++) { + tinyexr::FP16 h16; + h16.u = reinterpret_cast<const unsigned short * const *>( + images)[c][(y + start_y) * x_stride + x]; -#if TINYEXR_USE_ZFP - for (size_t i = 0; i < static_cast<size_t>(exr_header->num_channels); i++) { - if (exr_header->requested_pixel_types[i] != TINYEXR_PIXELTYPE_FLOAT) { - tinyexr::SetErrorMessage("Pixel type must be FLOAT for ZFP compression", - err); - return 0; + tinyexr::FP32 f32 = half_to_float(h16); + + tinyexr::swap4(&f32.f); + + // line_ptr[x] = f32.f; + tinyexr::cpy4(line_ptr + x, &(f32.f)); + } + } + } else if (channels[c].requested_pixel_type == TINYEXR_PIXELTYPE_HALF) { + for (int y = 0; y < num_lines; y++) { + // Assume increasing Y + unsigned short *line_ptr = reinterpret_cast<unsigned short *>( + &buf.at(static_cast<size_t>(pixel_data_size * y * + width) + + channel_offset_list[c] * + static_cast<size_t>(width))); + for (int x = 0; x < width; x++) { + unsigned short val = reinterpret_cast<const unsigned short * const *>( + images)[c][(y + start_y) * x_stride + x]; + + tinyexr::swap2(&val); + + // line_ptr[x] = val; + tinyexr::cpy2(line_ptr + x, &val); + } + } + } else { + assert(0); + } + + } else if (channels[c].pixel_type == TINYEXR_PIXELTYPE_FLOAT) { + if (channels[c].requested_pixel_type == TINYEXR_PIXELTYPE_HALF) { + for (int y = 0; y < num_lines; y++) { + // Assume increasing Y + unsigned short *line_ptr = reinterpret_cast<unsigned short *>( + &buf.at(static_cast<size_t>(pixel_data_size * y * + width) + + channel_offset_list[c] * + static_cast<size_t>(width))); + for (int x = 0; x < width; x++) { + tinyexr::FP32 f32; + f32.f = reinterpret_cast<const float * const *>( + images)[c][(y + start_y) * x_stride + x]; + + tinyexr::FP16 h16; + h16 = float_to_half_full(f32); + + tinyexr::swap2(reinterpret_cast<unsigned short *>(&h16.u)); + + // line_ptr[x] = h16.u; + tinyexr::cpy2(line_ptr + x, &(h16.u)); + } + } + } else if (channels[c].requested_pixel_type == TINYEXR_PIXELTYPE_FLOAT) { + for (int y = 0; y < num_lines; y++) { + // Assume increasing Y + float *line_ptr = reinterpret_cast<float *>(&buf.at( + static_cast<size_t>(pixel_data_size * y * width) + + channel_offset_list[c] * + static_cast<size_t>(width))); + for (int x = 0; x < width; x++) { + float val = reinterpret_cast<const float * const *>( + images)[c][(y + start_y) * x_stride + x]; + + tinyexr::swap4(&val); + + // line_ptr[x] = val; + tinyexr::cpy4(line_ptr + x, &val); + } + } + } else { + assert(0); + } + } else if (channels[c].pixel_type == TINYEXR_PIXELTYPE_UINT) { + for (int y = 0; y < num_lines; y++) { + // Assume increasing Y + unsigned int *line_ptr = reinterpret_cast<unsigned int *>(&buf.at( + static_cast<size_t>(pixel_data_size * y * width) + + channel_offset_list[c] * static_cast<size_t>(width))); + for (int x = 0; x < width; x++) { + unsigned int val = reinterpret_cast<const unsigned int * const *>( + images)[c][(y + start_y) * x_stride + x]; + + tinyexr::swap4(&val); + + // line_ptr[x] = val; + tinyexr::cpy4(line_ptr + x, &val); + } + } } } + + if (compression_type == TINYEXR_COMPRESSIONTYPE_NONE) { + // 4 byte: scan line + // 4 byte: data size + // ~ : pixel data(uncompressed) + out_data.insert(out_data.end(), buf.begin(), buf.end()); + + } else if ((compression_type == TINYEXR_COMPRESSIONTYPE_ZIPS) || + (compression_type == TINYEXR_COMPRESSIONTYPE_ZIP)) { +#if TINYEXR_USE_MINIZ + std::vector<unsigned char> block(mz_compressBound( + static_cast<unsigned long>(buf.size()))); +#else + std::vector<unsigned char> block( + compressBound(static_cast<uLong>(buf.size()))); #endif + tinyexr::tinyexr_uint64 outSize = block.size(); - std::vector<unsigned char> memory; + tinyexr::CompressZip(&block.at(0), outSize, + reinterpret_cast<const unsigned char *>(&buf.at(0)), + static_cast<unsigned long>(buf.size())); - // Header - { - const char header[] = {0x76, 0x2f, 0x31, 0x01}; - memory.insert(memory.end(), header, header + 4); - } + // 4 byte: scan line + // 4 byte: data size + // ~ : pixel data(compressed) + unsigned int data_len = static_cast<unsigned int>(outSize); // truncate - // Version, scanline. - { - char marker[] = {2, 0, 0, 0}; - /* @todo - if (exr_header->tiled) { - marker[1] |= 0x2; - } - if (exr_header->long_name) { - marker[1] |= 0x4; - } - if (exr_header->non_image) { - marker[1] |= 0x8; - } - if (exr_header->multipart) { - marker[1] |= 0x10; - } - */ - memory.insert(memory.end(), marker, marker + 4); - } + out_data.insert(out_data.end(), block.begin(), block.begin() + data_len); - int num_scanlines = 1; - if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_ZIP) { - num_scanlines = 16; - } else if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_PIZ) { - num_scanlines = 32; - } else if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_ZFP) { - num_scanlines = 16; - } + } else if (compression_type == TINYEXR_COMPRESSIONTYPE_RLE) { + // (buf.size() * 3) / 2 would be enough. + std::vector<unsigned char> block((buf.size() * 3) / 2); - // Write attributes. - std::vector<tinyexr::ChannelInfo> channels; - { - std::vector<unsigned char> data; + tinyexr::tinyexr_uint64 outSize = block.size(); - for (int c = 0; c < exr_header->num_channels; c++) { - tinyexr::ChannelInfo info; - info.p_linear = 0; - info.pixel_type = exr_header->requested_pixel_types[c]; - info.x_sampling = 1; - info.y_sampling = 1; - info.name = std::string(exr_header->channels[c].name); - channels.push_back(info); - } + tinyexr::CompressRle(&block.at(0), outSize, + reinterpret_cast<const unsigned char *>(&buf.at(0)), + static_cast<unsigned long>(buf.size())); - tinyexr::WriteChannelInfo(data, channels); + // 4 byte: scan line + // 4 byte: data size + // ~ : pixel data(compressed) + unsigned int data_len = static_cast<unsigned int>(outSize); // truncate + out_data.insert(out_data.end(), block.begin(), block.begin() + data_len); - tinyexr::WriteAttributeToMemory(&memory, "channels", "chlist", &data.at(0), - static_cast<int>(data.size())); - } + } else if (compression_type == TINYEXR_COMPRESSIONTYPE_PIZ) { +#if TINYEXR_USE_PIZ + unsigned int bufLen = + 8192 + static_cast<unsigned int>( + 2 * static_cast<unsigned int>( + buf.size())); // @fixme { compute good bound. } + std::vector<unsigned char> block(bufLen); + unsigned int outSize = static_cast<unsigned int>(block.size()); + + CompressPiz(&block.at(0), &outSize, + reinterpret_cast<const unsigned char *>(&buf.at(0)), + buf.size(), channels, width, num_lines); + + // 4 byte: scan line + // 4 byte: data size + // ~ : pixel data(compressed) + unsigned int data_len = outSize; + out_data.insert(out_data.end(), block.begin(), block.begin() + data_len); - { - int comp = exr_header->compression_type; - tinyexr::swap4(&comp); - tinyexr::WriteAttributeToMemory( - &memory, "compression", "compression", - reinterpret_cast<const unsigned char *>(&comp), 1); - } +#else + assert(0); +#endif + } else if (compression_type == TINYEXR_COMPRESSIONTYPE_ZFP) { +#if TINYEXR_USE_ZFP + const ZFPCompressionParam* zfp_compression_param = reinterpret_cast<const ZFPCompressionParam*>(compression_param); + std::vector<unsigned char> block; + unsigned int outSize; - { - int data[4] = {0, 0, exr_image->width - 1, exr_image->height - 1}; - tinyexr::swap4(&data[0]); - tinyexr::swap4(&data[1]); - tinyexr::swap4(&data[2]); - tinyexr::swap4(&data[3]); - tinyexr::WriteAttributeToMemory( - &memory, "dataWindow", "box2i", - reinterpret_cast<const unsigned char *>(data), sizeof(int) * 4); - tinyexr::WriteAttributeToMemory( - &memory, "displayWindow", "box2i", - reinterpret_cast<const unsigned char *>(data), sizeof(int) * 4); - } + tinyexr::CompressZfp( + &block, &outSize, reinterpret_cast<const float *>(&buf.at(0)), + width, num_lines, static_cast<int>(channels.size()), *zfp_compression_param); - { - unsigned char line_order = 0; // @fixme { read line_order from EXRHeader } - tinyexr::WriteAttributeToMemory(&memory, "lineOrder", "lineOrder", - &line_order, 1); - } + // 4 byte: scan line + // 4 byte: data size + // ~ : pixel data(compressed) + unsigned int data_len = outSize; + out_data.insert(out_data.end(), block.begin(), block.begin() + data_len); - { - float aspectRatio = 1.0f; - tinyexr::swap4(&aspectRatio); - tinyexr::WriteAttributeToMemory( - &memory, "pixelAspectRatio", "float", - reinterpret_cast<const unsigned char *>(&aspectRatio), sizeof(float)); +#else + (void)compression_param; + assert(0); +#endif + } else { + assert(0); + return false; } - { - float center[2] = {0.0f, 0.0f}; - tinyexr::swap4(¢er[0]); - tinyexr::swap4(¢er[1]); - tinyexr::WriteAttributeToMemory( - &memory, "screenWindowCenter", "v2f", - reinterpret_cast<const unsigned char *>(center), 2 * sizeof(float)); + return true; +} + +static int EncodeTiledLevel(const EXRImage* level_image, const EXRHeader* exr_header, + const std::vector<tinyexr::ChannelInfo>& channels, + std::vector<std::vector<unsigned char> >& data_list, + size_t start_index, // for data_list + int num_x_tiles, int num_y_tiles, + const std::vector<size_t>& channel_offset_list, + int pixel_data_size, + const void* compression_param, // must be set if zfp compression is enabled + std::string* err) { + int num_tiles = num_x_tiles * num_y_tiles; + assert(num_tiles == level_image->num_tiles); + + if ((exr_header->tile_size_x > level_image->width || exr_header->tile_size_y > level_image->height) && + level_image->level_x == 0 && level_image->level_y == 0) { + if (err) { + (*err) += "Failed to encode tile data.\n"; + } + return TINYEXR_ERROR_INVALID_DATA; } - { - float w = static_cast<float>(exr_image->width); - tinyexr::swap4(&w); - tinyexr::WriteAttributeToMemory(&memory, "screenWindowWidth", "float", - reinterpret_cast<const unsigned char *>(&w), - sizeof(float)); + +#if TINYEXR_HAS_CXX11 && (TINYEXR_USE_THREAD > 0) + std::atomic<bool> invalid_data(false); +#else + bool invalid_data(false); +#endif + +#if TINYEXR_HAS_CXX11 && (TINYEXR_USE_THREAD > 0) + std::vector<std::thread> workers; + std::atomic<int> tile_count(0); + + int num_threads = std::max(1, int(std::thread::hardware_concurrency())); + if (num_threads > int(num_tiles)) { + num_threads = int(num_tiles); } - // Custom attributes - if (exr_header->num_custom_attributes > 0) { - for (int i = 0; i < exr_header->num_custom_attributes; i++) { - tinyexr::WriteAttributeToMemory( - &memory, exr_header->custom_attributes[i].name, - exr_header->custom_attributes[i].type, - reinterpret_cast<const unsigned char *>( - exr_header->custom_attributes[i].value), - exr_header->custom_attributes[i].size); + for (int t = 0; t < num_threads; t++) { + workers.emplace_back(std::thread([&]() { + int i = 0; + while ((i = tile_count++) < num_tiles) { + +#else + // Use signed int since some OpenMP compiler doesn't allow unsigned type for + // `parallel for` +#if TINYEXR_USE_OPENMP +#pragma omp parallel for +#endif + for (int i = 0; i < num_tiles; i++) { + +#endif + size_t tile_idx = static_cast<size_t>(i); + size_t data_idx = tile_idx + start_index; + + int x_tile = i % num_x_tiles; + int y_tile = i / num_x_tiles; + + EXRTile& tile = level_image->tiles[tile_idx]; + + const unsigned char* const* images = + static_cast<const unsigned char* const*>(tile.images); + + data_list[data_idx].resize(5*sizeof(int)); + size_t data_header_size = data_list[data_idx].size(); + bool ret = EncodePixelData(data_list[data_idx], + images, + exr_header->compression_type, + 0, // increasing y + tile.width, + exr_header->tile_size_y, + exr_header->tile_size_x, + 0, + tile.height, + pixel_data_size, + channels, + channel_offset_list, + compression_param); + if (!ret) { + invalid_data = true; + continue; } + assert(data_list[data_idx].size() > data_header_size); + int data_len = static_cast<int>(data_list[data_idx].size() - data_header_size); + //tileX, tileY, levelX, levelY // pixel_data_size(int) + memcpy(&data_list[data_idx][0], &x_tile, sizeof(int)); + memcpy(&data_list[data_idx][4], &y_tile, sizeof(int)); + memcpy(&data_list[data_idx][8], &level_image->level_x, sizeof(int)); + memcpy(&data_list[data_idx][12], &level_image->level_y, sizeof(int)); + memcpy(&data_list[data_idx][16], &data_len, sizeof(int)); + + swap4(reinterpret_cast<int*>(&data_list[data_idx][0])); + swap4(reinterpret_cast<int*>(&data_list[data_idx][4])); + swap4(reinterpret_cast<int*>(&data_list[data_idx][8])); + swap4(reinterpret_cast<int*>(&data_list[data_idx][12])); + swap4(reinterpret_cast<int*>(&data_list[data_idx][16])); + +#if TINYEXR_HAS_CXX11 && (TINYEXR_USE_THREAD > 0) } +})); + } - { // end of header - unsigned char e = 0; - memory.push_back(e); + for (auto &t : workers) { + t.join(); + } +#else + } // omp parallel +#endif + + if (invalid_data) { + if (err) { + (*err) += "Failed to encode tile data.\n"; + } + return TINYEXR_ERROR_INVALID_DATA; } + return TINYEXR_SUCCESS; +} - int num_blocks = exr_image->height / num_scanlines; - if (num_blocks * num_scanlines < exr_image->height) { - num_blocks++; +static int NumScanlines(int compression_type) { + int num_scanlines = 1; + if (compression_type == TINYEXR_COMPRESSIONTYPE_ZIP) { + num_scanlines = 16; + } else if (compression_type == TINYEXR_COMPRESSIONTYPE_PIZ) { + num_scanlines = 32; + } else if (compression_type == TINYEXR_COMPRESSIONTYPE_ZFP) { + num_scanlines = 16; } + return num_scanlines; +} - std::vector<tinyexr::tinyexr_uint64> offsets(static_cast<size_t>(num_blocks)); +static int EncodeChunk(const EXRImage* exr_image, const EXRHeader* exr_header, + const std::vector<ChannelInfo>& channels, + int num_blocks, + tinyexr_uint64 chunk_offset, // starting offset of current chunk + bool is_multipart, + OffsetData& offset_data, // output block offsets, must be initialized + std::vector<std::vector<unsigned char> >& data_list, // output + tinyexr_uint64& total_size, // output: ending offset of current chunk + std::string* err) { + int num_scanlines = NumScanlines(exr_header->compression_type); - size_t headerSize = memory.size(); - tinyexr::tinyexr_uint64 offset = - headerSize + - static_cast<size_t>(num_blocks) * - sizeof( - tinyexr::tinyexr_int64); // sizeof(header) + sizeof(offsetTable) + data_list.resize(num_blocks); - std::vector<std::vector<unsigned char> > data_list( - static_cast<size_t>(num_blocks)); std::vector<size_t> channel_offset_list( - static_cast<size_t>(exr_header->num_channels)); + static_cast<size_t>(exr_header->num_channels)); int pixel_data_size = 0; - size_t channel_offset = 0; - for (size_t c = 0; c < static_cast<size_t>(exr_header->num_channels); c++) { - channel_offset_list[c] = channel_offset; - if (exr_header->requested_pixel_types[c] == TINYEXR_PIXELTYPE_HALF) { - pixel_data_size += sizeof(unsigned short); - channel_offset += sizeof(unsigned short); - } else if (exr_header->requested_pixel_types[c] == - TINYEXR_PIXELTYPE_FLOAT) { - pixel_data_size += sizeof(float); - channel_offset += sizeof(float); - } else if (exr_header->requested_pixel_types[c] == TINYEXR_PIXELTYPE_UINT) { - pixel_data_size += sizeof(unsigned int); - channel_offset += sizeof(unsigned int); - } else { - assert(0); + { + size_t channel_offset = 0; + for (size_t c = 0; c < static_cast<size_t>(exr_header->num_channels); c++) { + channel_offset_list[c] = channel_offset; + if (channels[c].requested_pixel_type == TINYEXR_PIXELTYPE_HALF) { + pixel_data_size += sizeof(unsigned short); + channel_offset += sizeof(unsigned short); + } else if (channels[c].requested_pixel_type == + TINYEXR_PIXELTYPE_FLOAT) { + pixel_data_size += sizeof(float); + channel_offset += sizeof(float); + } else if (channels[c].requested_pixel_type == TINYEXR_PIXELTYPE_UINT) { + pixel_data_size += sizeof(unsigned int); + channel_offset += sizeof(unsigned int); + } else { + assert(0); + } } } + const void* compression_param = 0; #if TINYEXR_USE_ZFP tinyexr::ZFPCompressionParam zfp_compression_param; @@ -12364,304 +6754,517 @@ size_t SaveEXRImageToMemory(const EXRImage *exr_image, { std::string e; bool ret = tinyexr::FindZFPCompressionParam( - &zfp_compression_param, exr_header->custom_attributes, - exr_header->num_custom_attributes, &e); + &zfp_compression_param, exr_header->custom_attributes, + exr_header->num_custom_attributes, &e); if (!ret) { // Use predefined compression parameter. zfp_compression_param.type = 0; zfp_compression_param.rate = 2; } + compression_param = &zfp_compression_param; } #endif - // TODO(LTE): C++11 thread + tinyexr_uint64 offset = chunk_offset; + tinyexr_uint64 doffset = is_multipart ? 4u : 0u; -// Use signed int since some OpenMP compiler doesn't allow unsigned type for -// `parallel for` -#if TINYEXR_USE_OPENMP -#pragma omp parallel for -#endif - for (int i = 0; i < num_blocks; i++) { - size_t ii = static_cast<size_t>(i); - int start_y = num_scanlines * i; - int endY = (std::min)(num_scanlines * (i + 1), exr_image->height); - int h = endY - start_y; - - std::vector<unsigned char> buf( - static_cast<size_t>(exr_image->width * h * pixel_data_size)); + if (exr_image->tiles) { + const EXRImage* level_image = exr_image; + size_t block_idx = 0; + tinyexr::tinyexr_uint64 block_data_size = 0; + int num_levels = (exr_header->tile_level_mode != TINYEXR_TILE_RIPMAP_LEVELS) ? + offset_data.num_x_levels : (offset_data.num_x_levels * offset_data.num_y_levels); + for (int level_index = 0; level_index < num_levels; ++level_index) { + if (!level_image) { + if (err) { + (*err) += "Invalid number of tiled levels for EncodeChunk\n"; + } + return TINYEXR_ERROR_INVALID_DATA; + } - for (size_t c = 0; c < static_cast<size_t>(exr_header->num_channels); c++) { - if (exr_header->pixel_types[c] == TINYEXR_PIXELTYPE_HALF) { - if (exr_header->requested_pixel_types[c] == TINYEXR_PIXELTYPE_FLOAT) { - for (int y = 0; y < h; y++) { - // Assume increasing Y - float *line_ptr = reinterpret_cast<float *>(&buf.at( - static_cast<size_t>(pixel_data_size * y * exr_image->width) + - channel_offset_list[c] * - static_cast<size_t>(exr_image->width))); - for (int x = 0; x < exr_image->width; x++) { - tinyexr::FP16 h16; - h16.u = reinterpret_cast<unsigned short **>( - exr_image->images)[c][(y + start_y) * exr_image->width + x]; - - tinyexr::FP32 f32 = half_to_float(h16); - - tinyexr::swap4(&f32.f); - - // line_ptr[x] = f32.f; - tinyexr::cpy4(line_ptr + x, &(f32.f)); - } - } - } else if (exr_header->requested_pixel_types[c] == - TINYEXR_PIXELTYPE_HALF) { - for (int y = 0; y < h; y++) { - // Assume increasing Y - unsigned short *line_ptr = reinterpret_cast<unsigned short *>( - &buf.at(static_cast<size_t>(pixel_data_size * y * - exr_image->width) + - channel_offset_list[c] * - static_cast<size_t>(exr_image->width))); - for (int x = 0; x < exr_image->width; x++) { - unsigned short val = reinterpret_cast<unsigned short **>( - exr_image->images)[c][(y + start_y) * exr_image->width + x]; - - tinyexr::swap2(&val); - - // line_ptr[x] = val; - tinyexr::cpy2(line_ptr + x, &val); - } - } - } else { - assert(0); + int level_index_from_image = LevelIndex(level_image->level_x, level_image->level_y, + exr_header->tile_level_mode, offset_data.num_x_levels); + if (level_index_from_image != level_index) { + if (err) { + (*err) += "Incorrect level ordering in tiled image\n"; } + return TINYEXR_ERROR_INVALID_DATA; + } + int num_y_tiles = (int)offset_data.offsets[level_index].size(); + assert(num_y_tiles); + int num_x_tiles = (int)offset_data.offsets[level_index][0].size(); + assert(num_x_tiles); + + std::string e; + int ret = EncodeTiledLevel(level_image, + exr_header, + channels, + data_list, + block_idx, + num_x_tiles, + num_y_tiles, + channel_offset_list, + pixel_data_size, + compression_param, + &e); + if (ret != TINYEXR_SUCCESS) { + if (!e.empty() && err) { + (*err) += e; + } + return ret; + } - } else if (exr_header->pixel_types[c] == TINYEXR_PIXELTYPE_FLOAT) { - if (exr_header->requested_pixel_types[c] == TINYEXR_PIXELTYPE_HALF) { - for (int y = 0; y < h; y++) { - // Assume increasing Y - unsigned short *line_ptr = reinterpret_cast<unsigned short *>( - &buf.at(static_cast<size_t>(pixel_data_size * y * - exr_image->width) + - channel_offset_list[c] * - static_cast<size_t>(exr_image->width))); - for (int x = 0; x < exr_image->width; x++) { - tinyexr::FP32 f32; - f32.f = reinterpret_cast<float **>( - exr_image->images)[c][(y + start_y) * exr_image->width + x]; - - tinyexr::FP16 h16; - h16 = float_to_half_full(f32); - - tinyexr::swap2(reinterpret_cast<unsigned short *>(&h16.u)); - - // line_ptr[x] = h16.u; - tinyexr::cpy2(line_ptr + x, &(h16.u)); - } - } - } else if (exr_header->requested_pixel_types[c] == - TINYEXR_PIXELTYPE_FLOAT) { - for (int y = 0; y < h; y++) { - // Assume increasing Y - float *line_ptr = reinterpret_cast<float *>(&buf.at( - static_cast<size_t>(pixel_data_size * y * exr_image->width) + - channel_offset_list[c] * - static_cast<size_t>(exr_image->width))); - for (int x = 0; x < exr_image->width; x++) { - float val = reinterpret_cast<float **>( - exr_image->images)[c][(y + start_y) * exr_image->width + x]; - - tinyexr::swap4(&val); - - // line_ptr[x] = val; - tinyexr::cpy4(line_ptr + x, &val); - } - } - } else { - assert(0); + for (size_t j = 0; j < static_cast<size_t>(num_y_tiles); ++j) + for (size_t i = 0; i < static_cast<size_t>(num_x_tiles); ++i) { + offset_data.offsets[level_index][j][i] = offset; + swap8(reinterpret_cast<tinyexr_uint64*>(&offset_data.offsets[level_index][j][i])); + offset += data_list[block_idx].size() + doffset; + block_data_size += data_list[block_idx].size(); + ++block_idx; } - } else if (exr_header->pixel_types[c] == TINYEXR_PIXELTYPE_UINT) { - for (int y = 0; y < h; y++) { - // Assume increasing Y - unsigned int *line_ptr = reinterpret_cast<unsigned int *>(&buf.at( - static_cast<size_t>(pixel_data_size * y * exr_image->width) + - channel_offset_list[c] * static_cast<size_t>(exr_image->width))); - for (int x = 0; x < exr_image->width; x++) { - unsigned int val = reinterpret_cast<unsigned int **>( - exr_image->images)[c][(y + start_y) * exr_image->width + x]; + level_image = level_image->next_level; + } + assert(static_cast<int>(block_idx) == num_blocks); + total_size = offset; + } else { // scanlines + std::vector<tinyexr::tinyexr_uint64>& offsets = offset_data.offsets[0][0]; - tinyexr::swap4(&val); +#if TINYEXR_HAS_CXX11 && (TINYEXR_USE_THREAD > 0) + std::atomic<bool> invalid_data(false); + std::vector<std::thread> workers; + std::atomic<int> block_count(0); - // line_ptr[x] = val; - tinyexr::cpy4(line_ptr + x, &val); - } - } + int num_threads = std::min(std::max(1, int(std::thread::hardware_concurrency())), num_blocks); + + for (int t = 0; t < num_threads; t++) { + workers.emplace_back(std::thread([&]() { + int i = 0; + while ((i = block_count++) < num_blocks) { + +#else + bool invalid_data(false); +#if TINYEXR_USE_OPENMP +#pragma omp parallel for +#endif + for (int i = 0; i < num_blocks; i++) { + +#endif + int start_y = num_scanlines * i; + int end_Y = (std::min)(num_scanlines * (i + 1), exr_image->height); + int num_lines = end_Y - start_y; + + const unsigned char* const* images = + static_cast<const unsigned char* const*>(exr_image->images); + + data_list[i].resize(2*sizeof(int)); + size_t data_header_size = data_list[i].size(); + + bool ret = EncodePixelData(data_list[i], + images, + exr_header->compression_type, + 0, // increasing y + exr_image->width, + exr_image->height, + exr_image->width, + start_y, + num_lines, + pixel_data_size, + channels, + channel_offset_list, + compression_param); + if (!ret) { + invalid_data = true; + continue; // "break" cannot be used with OpenMP } + assert(data_list[i].size() > data_header_size); + int data_len = static_cast<int>(data_list[i].size() - data_header_size); + memcpy(&data_list[i][0], &start_y, sizeof(int)); + memcpy(&data_list[i][4], &data_len, sizeof(int)); + + swap4(reinterpret_cast<int*>(&data_list[i][0])); + swap4(reinterpret_cast<int*>(&data_list[i][4])); +#if TINYEXR_HAS_CXX11 && (TINYEXR_USE_THREAD > 0) + } + })); } - if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_NONE) { - // 4 byte: scan line - // 4 byte: data size - // ~ : pixel data(uncompressed) - std::vector<unsigned char> header(8); - unsigned int data_len = static_cast<unsigned int>(buf.size()); - memcpy(&header.at(0), &start_y, sizeof(int)); - memcpy(&header.at(4), &data_len, sizeof(unsigned int)); + for (auto &t : workers) { + t.join(); + } +#else + } // omp parallel +#endif + + if (invalid_data) { + if (err) { + (*err) += "Failed to encode scanline data.\n"; + } + return TINYEXR_ERROR_INVALID_DATA; + } - tinyexr::swap4(reinterpret_cast<unsigned int *>(&header.at(0))); - tinyexr::swap4(reinterpret_cast<unsigned int *>(&header.at(4))); + for (size_t i = 0; i < static_cast<size_t>(num_blocks); i++) { + offsets[i] = offset; + tinyexr::swap8(reinterpret_cast<tinyexr::tinyexr_uint64 *>(&offsets[i])); + offset += data_list[i].size() + doffset; + } - data_list[ii].insert(data_list[ii].end(), header.begin(), header.end()); - data_list[ii].insert(data_list[ii].end(), buf.begin(), - buf.begin() + data_len); + total_size = static_cast<size_t>(offset); + } + return TINYEXR_SUCCESS; +} - } else if ((exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_ZIPS) || - (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_ZIP)) { -#if TINYEXR_USE_MINIZ - std::vector<unsigned char> block(tinyexr::miniz::mz_compressBound( - static_cast<unsigned long>(buf.size()))); +// can save a single or multi-part image (no deep* formats) +static size_t SaveEXRNPartImageToMemory(const EXRImage* exr_images, + const EXRHeader** exr_headers, + unsigned int num_parts, + unsigned char** memory_out, const char** err) { + if (exr_images == NULL || exr_headers == NULL || num_parts == 0 || + memory_out == NULL) { + SetErrorMessage("Invalid argument for SaveEXRNPartImageToMemory", + err); + return 0; + } + { + for (unsigned int i = 0; i < num_parts; ++i) { + if (exr_headers[i]->compression_type < 0) { + SetErrorMessage("Invalid argument for SaveEXRNPartImageToMemory", + err); + return 0; + } +#if !TINYEXR_USE_PIZ + if (exr_headers[i]->compression_type == TINYEXR_COMPRESSIONTYPE_PIZ) { + SetErrorMessage("PIZ compression is not supported in this build", + err); + return 0; + } +#endif +#if !TINYEXR_USE_ZFP + if (exr_headers[i]->compression_type == TINYEXR_COMPRESSIONTYPE_ZFP) { + SetErrorMessage("ZFP compression is not supported in this build", + err); + return 0; + } #else - std::vector<unsigned char> block( - compressBound(static_cast<uLong>(buf.size()))); + for (int c = 0; c < exr_header->num_channels; ++c) { + if (exr_headers[i]->requested_pixel_types[c] != TINYEXR_PIXELTYPE_FLOAT) { + SetErrorMessage("Pixel type must be FLOAT for ZFP compression", + err); + return 0; + } + } #endif - tinyexr::tinyexr_uint64 outSize = block.size(); - - tinyexr::CompressZip(&block.at(0), outSize, - reinterpret_cast<const unsigned char *>(&buf.at(0)), - static_cast<unsigned long>(buf.size())); + } + } - // 4 byte: scan line - // 4 byte: data size - // ~ : pixel data(compressed) - std::vector<unsigned char> header(8); - unsigned int data_len = static_cast<unsigned int>(outSize); // truncate - memcpy(&header.at(0), &start_y, sizeof(int)); - memcpy(&header.at(4), &data_len, sizeof(unsigned int)); + std::vector<unsigned char> memory; - tinyexr::swap4(reinterpret_cast<unsigned int *>(&header.at(0))); - tinyexr::swap4(reinterpret_cast<unsigned int *>(&header.at(4))); + // Header + { + const char header[] = { 0x76, 0x2f, 0x31, 0x01 }; + memory.insert(memory.end(), header, header + 4); + } - data_list[ii].insert(data_list[ii].end(), header.begin(), header.end()); - data_list[ii].insert(data_list[ii].end(), block.begin(), - block.begin() + data_len); + // Version + // using value from the first header + int long_name = exr_headers[0]->long_name; + { + char marker[] = { 2, 0, 0, 0 }; + /* @todo + if (exr_header->non_image) { + marker[1] |= 0x8; + } + */ + // tiled + if (num_parts == 1 && exr_images[0].tiles) { + marker[1] |= 0x2; + } + // long_name + if (long_name) { + marker[1] |= 0x4; + } + // multipart + if (num_parts > 1) { + marker[1] |= 0x10; + } + memory.insert(memory.end(), marker, marker + 4); + } - } else if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_RLE) { - // (buf.size() * 3) / 2 would be enough. - std::vector<unsigned char> block((buf.size() * 3) / 2); + int total_chunk_count = 0; + std::vector<int> chunk_count(num_parts); + std::vector<OffsetData> offset_data(num_parts); + for (unsigned int i = 0; i < num_parts; ++i) { + if (!exr_images[i].tiles) { + int num_scanlines = NumScanlines(exr_headers[i]->compression_type); + chunk_count[i] = + (exr_images[i].height + num_scanlines - 1) / num_scanlines; + InitSingleResolutionOffsets(offset_data[i], chunk_count[i]); + total_chunk_count += chunk_count[i]; + } else { + { + std::vector<int> num_x_tiles, num_y_tiles; + PrecalculateTileInfo(num_x_tiles, num_y_tiles, exr_headers[i]); + chunk_count[i] = + InitTileOffsets(offset_data[i], exr_headers[i], num_x_tiles, num_y_tiles); + total_chunk_count += chunk_count[i]; + } + } + } + // Write attributes to memory buffer. + std::vector< std::vector<tinyexr::ChannelInfo> > channels(num_parts); + { + std::set<std::string> partnames; + for (unsigned int i = 0; i < num_parts; ++i) { + //channels + { + std::vector<unsigned char> data; + + for (int c = 0; c < exr_headers[i]->num_channels; c++) { + tinyexr::ChannelInfo info; + info.p_linear = 0; + info.pixel_type = exr_headers[i]->pixel_types[c]; + info.requested_pixel_type = exr_headers[i]->requested_pixel_types[c]; + info.x_sampling = 1; + info.y_sampling = 1; + info.name = std::string(exr_headers[i]->channels[c].name); + channels[i].push_back(info); + } - tinyexr::tinyexr_uint64 outSize = block.size(); + tinyexr::WriteChannelInfo(data, channels[i]); - tinyexr::CompressRle(&block.at(0), outSize, - reinterpret_cast<const unsigned char *>(&buf.at(0)), - static_cast<unsigned long>(buf.size())); + tinyexr::WriteAttributeToMemory(&memory, "channels", "chlist", &data.at(0), + static_cast<int>(data.size())); + } - // 4 byte: scan line - // 4 byte: data size - // ~ : pixel data(compressed) - std::vector<unsigned char> header(8); - unsigned int data_len = static_cast<unsigned int>(outSize); // truncate - memcpy(&header.at(0), &start_y, sizeof(int)); - memcpy(&header.at(4), &data_len, sizeof(unsigned int)); + { + int comp = exr_headers[i]->compression_type; + swap4(&comp); + WriteAttributeToMemory( + &memory, "compression", "compression", + reinterpret_cast<const unsigned char*>(&comp), 1); + } - tinyexr::swap4(reinterpret_cast<unsigned int *>(&header.at(0))); - tinyexr::swap4(reinterpret_cast<unsigned int *>(&header.at(4))); + { + int data[4] = { 0, 0, exr_images[i].width - 1, exr_images[i].height - 1 }; + swap4(&data[0]); + swap4(&data[1]); + swap4(&data[2]); + swap4(&data[3]); + WriteAttributeToMemory( + &memory, "dataWindow", "box2i", + reinterpret_cast<const unsigned char*>(data), sizeof(int) * 4); + + int data0[4] = { 0, 0, exr_images[0].width - 1, exr_images[0].height - 1 }; + swap4(&data0[0]); + swap4(&data0[1]); + swap4(&data0[2]); + swap4(&data0[3]); + // Note: must be the same across parts (currently, using value from the first header) + WriteAttributeToMemory( + &memory, "displayWindow", "box2i", + reinterpret_cast<const unsigned char*>(data0), sizeof(int) * 4); + } - data_list[ii].insert(data_list[ii].end(), header.begin(), header.end()); - data_list[ii].insert(data_list[ii].end(), block.begin(), - block.begin() + data_len); + { + unsigned char line_order = 0; // @fixme { read line_order from EXRHeader } + WriteAttributeToMemory(&memory, "lineOrder", "lineOrder", + &line_order, 1); + } - } else if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_PIZ) { -#if TINYEXR_USE_PIZ - unsigned int bufLen = - 8192 + static_cast<unsigned int>( - 2 * static_cast<unsigned int>( - buf.size())); // @fixme { compute good bound. } - std::vector<unsigned char> block(bufLen); - unsigned int outSize = static_cast<unsigned int>(block.size()); - - CompressPiz(&block.at(0), &outSize, - reinterpret_cast<const unsigned char *>(&buf.at(0)), - buf.size(), channels, exr_image->width, h); - - // 4 byte: scan line - // 4 byte: data size - // ~ : pixel data(compressed) - std::vector<unsigned char> header(8); - unsigned int data_len = outSize; - memcpy(&header.at(0), &start_y, sizeof(int)); - memcpy(&header.at(4), &data_len, sizeof(unsigned int)); - - tinyexr::swap4(reinterpret_cast<unsigned int *>(&header.at(0))); - tinyexr::swap4(reinterpret_cast<unsigned int *>(&header.at(4))); - - data_list[ii].insert(data_list[ii].end(), header.begin(), header.end()); - data_list[ii].insert(data_list[ii].end(), block.begin(), - block.begin() + data_len); + { + // Note: must be the same across parts + float aspectRatio = 1.0f; + swap4(&aspectRatio); + WriteAttributeToMemory( + &memory, "pixelAspectRatio", "float", + reinterpret_cast<const unsigned char*>(&aspectRatio), sizeof(float)); + } -#else - assert(0); -#endif - } else if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_ZFP) { -#if TINYEXR_USE_ZFP - std::vector<unsigned char> block; - unsigned int outSize; + { + float center[2] = { 0.0f, 0.0f }; + swap4(¢er[0]); + swap4(¢er[1]); + WriteAttributeToMemory( + &memory, "screenWindowCenter", "v2f", + reinterpret_cast<const unsigned char*>(center), 2 * sizeof(float)); + } - tinyexr::CompressZfp( - &block, &outSize, reinterpret_cast<const float *>(&buf.at(0)), - exr_image->width, h, exr_header->num_channels, zfp_compression_param); + { + float w = 1.0f; + swap4(&w); + WriteAttributeToMemory(&memory, "screenWindowWidth", "float", + reinterpret_cast<const unsigned char*>(&w), + sizeof(float)); + } - // 4 byte: scan line - // 4 byte: data size - // ~ : pixel data(compressed) - std::vector<unsigned char> header(8); - unsigned int data_len = outSize; - memcpy(&header.at(0), &start_y, sizeof(int)); - memcpy(&header.at(4), &data_len, sizeof(unsigned int)); + if (exr_images[i].tiles) { + unsigned char tile_mode = static_cast<unsigned char>(exr_headers[i]->tile_level_mode & 0x3); + if (exr_headers[i]->tile_rounding_mode) tile_mode |= (1u << 4u); + //unsigned char data[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + unsigned int datai[3] = { 0, 0, 0 }; + unsigned char* data = reinterpret_cast<unsigned char*>(&datai[0]); + datai[0] = static_cast<unsigned int>(exr_headers[i]->tile_size_x); + datai[1] = static_cast<unsigned int>(exr_headers[i]->tile_size_y); + data[8] = tile_mode; + swap4(reinterpret_cast<unsigned int*>(&data[0])); + swap4(reinterpret_cast<unsigned int*>(&data[4])); + WriteAttributeToMemory( + &memory, "tiles", "tiledesc", + reinterpret_cast<const unsigned char*>(data), 9); + } - tinyexr::swap4(reinterpret_cast<unsigned int *>(&header.at(0))); - tinyexr::swap4(reinterpret_cast<unsigned int *>(&header.at(4))); + // must be present for multi-part files - according to spec. + if (num_parts > 1) { + // name + { + size_t len = 0; + if ((len = strlen(exr_headers[i]->name)) > 0) { + partnames.emplace(exr_headers[i]->name); + if (partnames.size() != i + 1) { + SetErrorMessage("'name' attributes must be unique for a multi-part file", err); + return 0; + } + WriteAttributeToMemory( + &memory, "name", "string", + reinterpret_cast<const unsigned char*>(exr_headers[i]->name), + static_cast<int>(len)); + } else { + SetErrorMessage("Invalid 'name' attribute for a multi-part file", err); + return 0; + } + } + // type + { + const char* type = "scanlineimage"; + if (exr_images[i].tiles) type = "tiledimage"; + WriteAttributeToMemory( + &memory, "type", "string", + reinterpret_cast<const unsigned char*>(type), + static_cast<int>(strlen(type))); + } + // chunkCount + { + WriteAttributeToMemory( + &memory, "chunkCount", "int", + reinterpret_cast<const unsigned char*>(&chunk_count[i]), + 4); + } + } - data_list[ii].insert(data_list[ii].end(), header.begin(), header.end()); - data_list[ii].insert(data_list[ii].end(), block.begin(), - block.begin() + data_len); + // Custom attributes + if (exr_headers[i]->num_custom_attributes > 0) { + for (int j = 0; j < exr_headers[i]->num_custom_attributes; j++) { + tinyexr::WriteAttributeToMemory( + &memory, exr_headers[i]->custom_attributes[j].name, + exr_headers[i]->custom_attributes[j].type, + reinterpret_cast<const unsigned char*>( + exr_headers[i]->custom_attributes[j].value), + exr_headers[i]->custom_attributes[j].size); + } + } -#else - assert(0); -#endif - } else { - assert(0); + { // end of header + memory.push_back(0); + } } - } // omp parallel - - for (size_t i = 0; i < static_cast<size_t>(num_blocks); i++) { - offsets[i] = offset; - tinyexr::swap8(reinterpret_cast<tinyexr::tinyexr_uint64 *>(&offsets[i])); - offset += data_list[i].size(); + } + if (num_parts > 1) { + // end of header list + memory.push_back(0); } - size_t totalSize = static_cast<size_t>(offset); - { - memory.insert( - memory.end(), reinterpret_cast<unsigned char *>(&offsets.at(0)), - reinterpret_cast<unsigned char *>(&offsets.at(0)) + - sizeof(tinyexr::tinyexr_uint64) * static_cast<size_t>(num_blocks)); + tinyexr_uint64 chunk_offset = memory.size() + size_t(total_chunk_count) * sizeof(tinyexr_uint64); + + tinyexr_uint64 total_size = 0; + std::vector< std::vector< std::vector<unsigned char> > > data_lists(num_parts); + for (unsigned int i = 0; i < num_parts; ++i) { + std::string e; + int ret = EncodeChunk(&exr_images[i], exr_headers[i], + channels[i], + chunk_count[i], + // starting offset of current chunk after part-number + chunk_offset, + num_parts > 1, + offset_data[i], // output: block offsets, must be initialized + data_lists[i], // output + total_size, // output + &e); + if (ret != TINYEXR_SUCCESS) { + if (!e.empty()) { + tinyexr::SetErrorMessage(e, err); + } + return 0; + } + chunk_offset = total_size; } - if (memory.size() == 0) { + // Allocating required memory + if (total_size == 0) { // something went wrong tinyexr::SetErrorMessage("Output memory size is zero", err); return 0; } - - (*memory_out) = static_cast<unsigned char *>(malloc(totalSize)); - memcpy((*memory_out), &memory.at(0), memory.size()); - unsigned char *memory_ptr = *memory_out + memory.size(); - - for (size_t i = 0; i < static_cast<size_t>(num_blocks); i++) { - memcpy(memory_ptr, &data_list[i].at(0), data_list[i].size()); - memory_ptr += data_list[i].size(); + (*memory_out) = static_cast<unsigned char*>(malloc(total_size)); + + // Writing header + memcpy((*memory_out), &memory[0], memory.size()); + unsigned char* memory_ptr = *memory_out + memory.size(); + size_t sum = memory.size(); + + // Writing offset data for chunks + for (unsigned int i = 0; i < num_parts; ++i) { + if (exr_images[i].tiles) { + const EXRImage* level_image = &exr_images[i]; + int num_levels = (exr_headers[i]->tile_level_mode != TINYEXR_TILE_RIPMAP_LEVELS) ? + offset_data[i].num_x_levels : (offset_data[i].num_x_levels * offset_data[i].num_y_levels); + for (int level_index = 0; level_index < num_levels; ++level_index) { + for (size_t j = 0; j < offset_data[i].offsets[level_index].size(); ++j) { + size_t num_bytes = sizeof(tinyexr_uint64) * offset_data[i].offsets[level_index][j].size(); + sum += num_bytes; + assert(sum <= total_size); + memcpy(memory_ptr, + reinterpret_cast<unsigned char*>(&offset_data[i].offsets[level_index][j][0]), + num_bytes); + memory_ptr += num_bytes; + } + level_image = level_image->next_level; + } + } else { + size_t num_bytes = sizeof(tinyexr::tinyexr_uint64) * static_cast<size_t>(chunk_count[i]); + sum += num_bytes; + assert(sum <= total_size); + std::vector<tinyexr::tinyexr_uint64>& offsets = offset_data[i].offsets[0][0]; + memcpy(memory_ptr, reinterpret_cast<unsigned char*>(&offsets[0]), num_bytes); + memory_ptr += num_bytes; + } + } + + // Writing chunk data + for (unsigned int i = 0; i < num_parts; ++i) { + for (size_t j = 0; j < static_cast<size_t>(chunk_count[i]); ++j) { + if (num_parts > 1) { + sum += 4; + assert(sum <= total_size); + unsigned int part_number = i; + swap4(&part_number); + memcpy(memory_ptr, &part_number, 4); + memory_ptr += 4; + } + sum += data_lists[i][j].size(); + assert(sum <= total_size); + memcpy(memory_ptr, &data_lists[i][j][0], data_lists[i][j].size()); + memory_ptr += data_lists[i][j].size(); + } } + assert(sum == total_size); + return total_size; // OK +} + +} // tinyexr - return totalSize; // OK +size_t SaveEXRImageToMemory(const EXRImage* exr_image, + const EXRHeader* exr_header, + unsigned char** memory_out, const char** err) { + return tinyexr::SaveEXRNPartImageToMemory(exr_image, &exr_header, 1, memory_out, err); } int SaveEXRImageToFile(const EXRImage *exr_image, const EXRHeader *exr_header, @@ -12690,7 +7293,7 @@ int SaveEXRImageToFile(const EXRImage *exr_image, const EXRHeader *exr_header, FILE *fp = NULL; #ifdef _WIN32 -#if defined(_MSC_VER) || defined(__MINGW32__) // MSVC, MinGW gcc or clang +#if defined(_MSC_VER) || (defined(MINGW_HAS_SECURE_API) && MINGW_HAS_SECURE_API) // MSVC, MinGW GCC, or Clang errno_t errcode = _wfopen_s(&fp, tinyexr::UTF8ToWchar(filename).c_str(), L"wb"); if (errcode != 0) { @@ -12699,7 +7302,7 @@ int SaveEXRImageToFile(const EXRImage *exr_image, const EXRHeader *exr_header, return TINYEXR_ERROR_CANT_WRITE_FILE; } #else - // Unknown compiler + // Unknown compiler or MinGW without MINGW_HAS_SECURE_API. fp = fopen(filename, "wb"); #endif #else @@ -12733,6 +7336,75 @@ int SaveEXRImageToFile(const EXRImage *exr_image, const EXRHeader *exr_header, return TINYEXR_SUCCESS; } +size_t SaveEXRMultipartImageToMemory(const EXRImage* exr_images, + const EXRHeader** exr_headers, + unsigned int num_parts, + unsigned char** memory_out, const char** err) { + if (exr_images == NULL || exr_headers == NULL || num_parts < 2 || + memory_out == NULL) { + tinyexr::SetErrorMessage("Invalid argument for SaveEXRNPartImageToMemory", + err); + return 0; + } + return tinyexr::SaveEXRNPartImageToMemory(exr_images, exr_headers, num_parts, memory_out, err); +} + +int SaveEXRMultipartImageToFile(const EXRImage* exr_images, + const EXRHeader** exr_headers, + unsigned int num_parts, + const char* filename, + const char** err) { + if (exr_images == NULL || exr_headers == NULL || num_parts < 2) { + tinyexr::SetErrorMessage("Invalid argument for SaveEXRMultipartImageToFile", + err); + return TINYEXR_ERROR_INVALID_ARGUMENT; + } + + FILE *fp = NULL; +#ifdef _WIN32 +#if defined(_MSC_VER) || (defined(MINGW_HAS_SECURE_API) && MINGW_HAS_SECURE_API) // MSVC, MinGW GCC, or Clang. + errno_t errcode = + _wfopen_s(&fp, tinyexr::UTF8ToWchar(filename).c_str(), L"wb"); + if (errcode != 0) { + tinyexr::SetErrorMessage("Cannot write a file: " + std::string(filename), + err); + return TINYEXR_ERROR_CANT_WRITE_FILE; + } +#else + // Unknown compiler or MinGW without MINGW_HAS_SECURE_API. + fp = fopen(filename, "wb"); +#endif +#else + fp = fopen(filename, "wb"); +#endif + if (!fp) { + tinyexr::SetErrorMessage("Cannot write a file: " + std::string(filename), + err); + return TINYEXR_ERROR_CANT_WRITE_FILE; + } + + unsigned char *mem = NULL; + size_t mem_size = SaveEXRMultipartImageToMemory(exr_images, exr_headers, num_parts, &mem, err); + if (mem_size == 0) { + return TINYEXR_ERROR_SERIALZATION_FAILED; + } + + size_t written_size = 0; + if ((mem_size > 0) && mem) { + written_size = fwrite(mem, 1, mem_size, fp); + } + free(mem); + + fclose(fp); + + if (written_size != mem_size) { + tinyexr::SetErrorMessage("Cannot write a file", err); + return TINYEXR_ERROR_CANT_WRITE_FILE; + } + + return TINYEXR_SUCCESS; +} + int LoadDeepEXR(DeepImage *deep_image, const char *filename, const char **err) { if (deep_image == NULL) { tinyexr::SetErrorMessage("Invalid argument for LoadDeepEXR", err); @@ -12741,7 +7413,7 @@ int LoadDeepEXR(DeepImage *deep_image, const char *filename, const char **err) { #ifdef _WIN32 FILE *fp = NULL; -#if defined(_MSC_VER) || defined(__MINGW32__) // MSVC, MinGW gcc or clang +#if defined(_MSC_VER) || (defined(MINGW_HAS_SECURE_API) && MINGW_HAS_SECURE_API) // MSVC, MinGW GCC, or Clang. errno_t errcode = _wfopen_s(&fp, tinyexr::UTF8ToWchar(filename).c_str(), L"rb"); if (errcode != 0) { @@ -12750,7 +7422,7 @@ int LoadDeepEXR(DeepImage *deep_image, const char *filename, const char **err) { return TINYEXR_ERROR_CANT_OPEN_FILE; } #else - // Unknown compiler + // Unknown compiler or MinGW without MINGW_HAS_SECURE_API. fp = fopen(filename, "rb"); #endif if (!fp) { @@ -12917,9 +7589,6 @@ int LoadDeepEXR(DeepImage *deep_image, const char *filename, const char **err) { int data_width = dw - dx + 1; int data_height = dh - dy + 1; - std::vector<float> image( - static_cast<size_t>(data_width * data_height * 4)); // 4 = RGBA - // Read offset tables. int num_blocks = data_height / num_scanline_blocks; if (num_blocks * num_scanline_blocks < data_height) { @@ -13138,6 +7807,9 @@ void InitEXRImage(EXRImage *exr_image) { exr_image->images = NULL; exr_image->tiles = NULL; + exr_image->next_level = NULL; + exr_image->level_x = 0; + exr_image->level_y = 0; exr_image->num_tiles = 0; } @@ -13184,14 +7856,43 @@ int FreeEXRHeader(EXRHeader *exr_header) { free(exr_header->custom_attributes); } + EXRSetNameAttr(exr_header, NULL); + return TINYEXR_SUCCESS; } +void EXRSetNameAttr(EXRHeader* exr_header, const char* name) { + if (exr_header == NULL) { + return; + } + memset(exr_header->name, 0, 256); + if (name != NULL) { + size_t len = std::min(strlen(name), (size_t)255); + if (len) { + memcpy(exr_header->name, name, len); + } + } +} + +int EXRNumLevels(const EXRImage* exr_image) { + if (exr_image == NULL) return 0; + if(exr_image->images) return 1; // scanlines + int levels = 1; + const EXRImage* level_image = exr_image; + while((level_image = level_image->next_level)) ++levels; + return levels; +} + int FreeEXRImage(EXRImage *exr_image) { if (exr_image == NULL) { return TINYEXR_ERROR_INVALID_ARGUMENT; } + if (exr_image->next_level) { + FreeEXRImage(exr_image->next_level); + delete exr_image->next_level; + } + for (int i = 0; i < exr_image->num_channels; i++) { if (exr_image->images && exr_image->images[i]) { free(exr_image->images[i]); @@ -13229,7 +7930,7 @@ int ParseEXRHeaderFromFile(EXRHeader *exr_header, const EXRVersion *exr_version, FILE *fp = NULL; #ifdef _WIN32 -#if defined(_MSC_VER) || defined(__MINGW32__) // MSVC, MinGW gcc or clang +#if defined(_MSC_VER) || (defined(MINGW_HAS_SECURE_API) && MINGW_HAS_SECURE_API) // MSVC, MinGW GCC, or Clang. errno_t errcode = _wfopen_s(&fp, tinyexr::UTF8ToWchar(filename).c_str(), L"rb"); if (errcode != 0) { @@ -13237,7 +7938,7 @@ int ParseEXRHeaderFromFile(EXRHeader *exr_header, const EXRVersion *exr_version, return TINYEXR_ERROR_INVALID_FILE; } #else - // Unknown compiler + // Unknown compiler or MinGW without MINGW_HAS_SECURE_API. fp = fopen(filename, "rb"); #endif #else @@ -13333,11 +8034,11 @@ int ParseEXRMultipartHeaderFromMemory(EXRHeader ***exr_headers, static_cast<EXRHeader **>(malloc(sizeof(EXRHeader *) * infos.size())); for (size_t i = 0; i < infos.size(); i++) { EXRHeader *exr_header = static_cast<EXRHeader *>(malloc(sizeof(EXRHeader))); + memset(exr_header, 0, sizeof(EXRHeader)); ConvertHeader(exr_header, infos[i]); - // transfoer `tiled` from version. - exr_header->tiled = exr_version->tiled; + exr_header->multipart = exr_version->multipart ? 1 : 0; (*exr_headers)[i] = exr_header; } @@ -13359,7 +8060,7 @@ int ParseEXRMultipartHeaderFromFile(EXRHeader ***exr_headers, int *num_headers, FILE *fp = NULL; #ifdef _WIN32 -#if defined(_MSC_VER) || defined(__MINGW32__) // MSVC, MinGW gcc or clang +#if defined(_MSC_VER) || (defined(MINGW_HAS_SECURE_API) && MINGW_HAS_SECURE_API) // MSVC, MinGW GCC, or Clang. errno_t errcode = _wfopen_s(&fp, tinyexr::UTF8ToWchar(filename).c_str(), L"rb"); if (errcode != 0) { @@ -13367,7 +8068,7 @@ int ParseEXRMultipartHeaderFromFile(EXRHeader ***exr_headers, int *num_headers, return TINYEXR_ERROR_INVALID_FILE; } #else - // Unknown compiler + // Unknown compiler or MinGW without MINGW_HAS_SECURE_API. fp = fopen(filename, "rb"); #endif #else @@ -13465,14 +8166,14 @@ int ParseEXRVersionFromFile(EXRVersion *version, const char *filename) { FILE *fp = NULL; #ifdef _WIN32 -#if defined(_MSC_VER) || defined(__MINGW32__) // MSVC, MinGW gcc or clang +#if defined(_MSC_VER) || (defined(MINGW_HAS_SECURE_API) && MINGW_HAS_SECURE_API) // MSVC, MinGW GCC, or Clang. errno_t err = _wfopen_s(&fp, tinyexr::UTF8ToWchar(filename).c_str(), L"rb"); if (err != 0) { // TODO(syoyo): return wfopen_s erro code return TINYEXR_ERROR_CANT_OPEN_FILE; } #else - // Unknown compiler + // Unknown compiler or MinGW without MINGW_HAS_SECURE_API. fp = fopen(filename, "rb"); #endif #else @@ -13543,51 +8244,82 @@ int LoadEXRMultipartImageFromMemory(EXRImage *exr_images, // http://www.openexr.com/openexrfilelayout.pdf // Load chunk offset table. - std::vector<std::vector<tinyexr::tinyexr_uint64> > chunk_offset_table_list; + std::vector<tinyexr::OffsetData> chunk_offset_table_list; + chunk_offset_table_list.reserve(num_parts); for (size_t i = 0; i < static_cast<size_t>(num_parts); i++) { - std::vector<tinyexr::tinyexr_uint64> offset_table( - static_cast<size_t>(exr_headers[i]->chunk_count)); - - for (size_t c = 0; c < offset_table.size(); c++) { - tinyexr::tinyexr_uint64 offset; - memcpy(&offset, marker, 8); - tinyexr::swap8(&offset); + chunk_offset_table_list.resize(chunk_offset_table_list.size() + 1); + tinyexr::OffsetData& offset_data = chunk_offset_table_list.back(); + if (!exr_headers[i]->tiled || exr_headers[i]->tile_level_mode == TINYEXR_TILE_ONE_LEVEL) { + tinyexr::InitSingleResolutionOffsets(offset_data, exr_headers[i]->chunk_count); + std::vector<tinyexr::tinyexr_uint64>& offset_table = offset_data.offsets[0][0]; + + for (size_t c = 0; c < offset_table.size(); c++) { + tinyexr::tinyexr_uint64 offset; + memcpy(&offset, marker, 8); + tinyexr::swap8(&offset); + + if (offset >= size) { + tinyexr::SetErrorMessage("Invalid offset size in EXR header chunks.", + err); + return TINYEXR_ERROR_INVALID_DATA; + } - if (offset >= size) { - tinyexr::SetErrorMessage("Invalid offset size in EXR header chunks.", - err); - return TINYEXR_ERROR_INVALID_DATA; + offset_table[c] = offset + 4; // +4 to skip 'part number' + marker += 8; + } + } else { + { + std::vector<int> num_x_tiles, num_y_tiles; + tinyexr::PrecalculateTileInfo(num_x_tiles, num_y_tiles, exr_headers[i]); + int num_blocks = InitTileOffsets(offset_data, exr_headers[i], num_x_tiles, num_y_tiles); + if (num_blocks != exr_headers[i]->chunk_count) { + tinyexr::SetErrorMessage("Invalid offset table size.", err); + return TINYEXR_ERROR_INVALID_DATA; + } + } + for (unsigned int l = 0; l < offset_data.offsets.size(); ++l) { + for (unsigned int dy = 0; dy < offset_data.offsets[l].size(); ++dy) { + for (unsigned int dx = 0; dx < offset_data.offsets[l][dy].size(); ++dx) { + tinyexr::tinyexr_uint64 offset; + memcpy(&offset, marker, sizeof(tinyexr::tinyexr_uint64)); + tinyexr::swap8(&offset); + if (offset >= size) { + tinyexr::SetErrorMessage("Invalid offset size in EXR header chunks.", + err); + return TINYEXR_ERROR_INVALID_DATA; + } + offset_data.offsets[l][dy][dx] = offset + 4; // +4 to skip 'part number' + marker += sizeof(tinyexr::tinyexr_uint64); // = 8 + } + } } - - offset_table[c] = offset + 4; // +4 to skip 'part number' - marker += 8; } - - chunk_offset_table_list.push_back(offset_table); } // Decode image. for (size_t i = 0; i < static_cast<size_t>(num_parts); i++) { - std::vector<tinyexr::tinyexr_uint64> &offset_table = - chunk_offset_table_list[i]; + tinyexr::OffsetData &offset_data = chunk_offset_table_list[i]; // First check 'part number' is identitical to 'i' - for (size_t c = 0; c < offset_table.size(); c++) { - const unsigned char *part_number_addr = - memory + offset_table[c] - 4; // -4 to move to 'part number' field. - unsigned int part_no; - memcpy(&part_no, part_number_addr, sizeof(unsigned int)); // 4 - tinyexr::swap4(&part_no); - - if (part_no != i) { - tinyexr::SetErrorMessage("Invalid `part number' in EXR header chunks.", - err); - return TINYEXR_ERROR_INVALID_DATA; - } - } + for (unsigned int l = 0; l < offset_data.offsets.size(); ++l) + for (unsigned int dy = 0; dy < offset_data.offsets[l].size(); ++dy) + for (unsigned int dx = 0; dx < offset_data.offsets[l][dy].size(); ++dx) { + + const unsigned char *part_number_addr = + memory + offset_data.offsets[l][dy][dx] - 4; // -4 to move to 'part number' field. + unsigned int part_no; + memcpy(&part_no, part_number_addr, sizeof(unsigned int)); // 4 + tinyexr::swap4(&part_no); + + if (part_no != i) { + tinyexr::SetErrorMessage("Invalid `part number' in EXR header chunks.", + err); + return TINYEXR_ERROR_INVALID_DATA; + } + } std::string e; - int ret = tinyexr::DecodeChunk(&exr_images[i], exr_headers[i], offset_table, + int ret = tinyexr::DecodeChunk(&exr_images[i], exr_headers[i], offset_data, memory, size, &e); if (ret != TINYEXR_SUCCESS) { if (!e.empty()) { @@ -13612,7 +8344,7 @@ int LoadEXRMultipartImageFromFile(EXRImage *exr_images, FILE *fp = NULL; #ifdef _WIN32 -#if defined(_MSC_VER) || defined(__MINGW32__) // MSVC, MinGW gcc or clang +#if defined(_MSC_VER) || (defined(MINGW_HAS_SECURE_API) && MINGW_HAS_SECURE_API) // MSVC, MinGW GCC, or Clang. errno_t errcode = _wfopen_s(&fp, tinyexr::UTF8ToWchar(filename).c_str(), L"rb"); if (errcode != 0) { @@ -13620,7 +8352,7 @@ int LoadEXRMultipartImageFromFile(EXRImage *exr_images, return TINYEXR_ERROR_CANT_OPEN_FILE; } #else - // Unknown compiler + // Unknown compiler or MinGW without MINGW_HAS_SECURE_API. fp = fopen(filename, "rb"); #endif #else diff --git a/thirdparty/xatlas/xatlas.cpp b/thirdparty/xatlas/xatlas.cpp index 9f66ae0067..d92ef1a83a 100644 --- a/thirdparty/xatlas/xatlas.cpp +++ b/thirdparty/xatlas/xatlas.cpp @@ -40,14 +40,14 @@ Copyright (c) 2012 Brandon Pelfrey #if XATLAS_C_API #include "xatlas_c.h" #endif -#include <assert.h> -#include <float.h> // FLT_MAX -#include <limits.h> -#include <math.h> #include <atomic> #include <condition_variable> #include <mutex> #include <thread> +#include <assert.h> +#include <float.h> // FLT_MAX +#include <limits.h> +#include <math.h> #define __STDC_LIMIT_MACROS #include <stdint.h> #include <stdio.h> @@ -76,10 +76,7 @@ Copyright (c) 2012 Brandon Pelfrey #define XA_XSTR(x) XA_STR(x) #ifndef XA_ASSERT -#define XA_ASSERT(exp) \ - if (!(exp)) { \ - XA_PRINT_WARNING("\rASSERT: %s %s %d\n", XA_XSTR(exp), __FILE__, __LINE__); \ - } +#define XA_ASSERT(exp) if (!(exp)) { XA_PRINT_WARNING("\rASSERT: %s %s %d\n", XA_XSTR(exp), __FILE__, __LINE__); } #endif #ifndef XA_DEBUG_ASSERT @@ -87,13 +84,13 @@ Copyright (c) 2012 Brandon Pelfrey #endif #ifndef XA_PRINT -#define XA_PRINT(...) \ +#define XA_PRINT(...) \ if (xatlas::internal::s_print && xatlas::internal::s_printVerbose) \ xatlas::internal::s_print(__VA_ARGS__); #endif #ifndef XA_PRINT_WARNING -#define XA_PRINT_WARNING(...) \ +#define XA_PRINT_WARNING(...) \ if (xatlas::internal::s_print) \ xatlas::internal::s_print(__VA_ARGS__); #endif @@ -145,14 +142,18 @@ Copyright (c) 2012 Brandon Pelfrey #define XA_DEBUG_EXPORT_OBJ_INVALID_PARAMETERIZATION 0 #define XA_DEBUG_EXPORT_OBJ_RECOMPUTED_CHARTS 0 -#define XA_DEBUG_EXPORT_OBJ (0 || XA_DEBUG_EXPORT_OBJ_FACE_GROUPS || XA_DEBUG_EXPORT_OBJ_CHART_GROUPS || XA_DEBUG_EXPORT_OBJ_PLANAR_REGIONS || XA_DEBUG_EXPORT_OBJ_CHARTS || XA_DEBUG_EXPORT_OBJ_TJUNCTION || XA_DEBUG_EXPORT_OBJ_CHARTS_AFTER_PARAMETERIZATION || XA_DEBUG_EXPORT_OBJ_INVALID_PARAMETERIZATION || XA_DEBUG_EXPORT_OBJ_RECOMPUTED_CHARTS) +#define XA_DEBUG_EXPORT_OBJ (0 \ + || XA_DEBUG_EXPORT_OBJ_FACE_GROUPS \ + || XA_DEBUG_EXPORT_OBJ_CHART_GROUPS \ + || XA_DEBUG_EXPORT_OBJ_PLANAR_REGIONS \ + || XA_DEBUG_EXPORT_OBJ_CHARTS \ + || XA_DEBUG_EXPORT_OBJ_TJUNCTION \ + || XA_DEBUG_EXPORT_OBJ_CHARTS_AFTER_PARAMETERIZATION \ + || XA_DEBUG_EXPORT_OBJ_INVALID_PARAMETERIZATION \ + || XA_DEBUG_EXPORT_OBJ_RECOMPUTED_CHARTS) #ifdef _MSC_VER -#define XA_FOPEN(_file, _filename, _mode) \ - { \ - if (fopen_s(&_file, _filename, _mode) != 0) \ - _file = NULL; \ - } +#define XA_FOPEN(_file, _filename, _mode) { if (fopen_s(&_file, _filename, _mode) != 0) _file = NULL; } #define XA_SPRINTF(_buffer, _size, _format, ...) sprintf_s(_buffer, _size, _format, __VA_ARGS__) #else #define XA_FOPEN(_file, _filename, _mode) _file = fopen(_filename, _mode) @@ -172,12 +173,11 @@ typedef uint64_t Duration; #define XA_PROFILE_START(var) const std::chrono::time_point<std::chrono::high_resolution_clock> var##Start = std::chrono::high_resolution_clock::now(); #define XA_PROFILE_END(var) internal::s_profile.var += uint64_t(std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - var##Start).count()); -#define XA_PROFILE_PRINT_AND_RESET(label, var) \ - XA_PRINT("%s%.2f seconds (%g ms)\n", label, internal::durationToSeconds(internal::s_profile.var), internal::durationToMs(internal::s_profile.var)); \ - internal::s_profile.var = 0u; +#define XA_PROFILE_PRINT_AND_RESET(label, var) XA_PRINT("%s%.2f seconds (%g ms)\n", label, internal::durationToSeconds(internal::s_profile.var), internal::durationToMs(internal::s_profile.var)); internal::s_profile.var = 0u; #define XA_PROFILE_ALLOC 0 -struct ProfileData { +struct ProfileData +{ #if XA_PROFILE_ALLOC std::atomic<Duration> alloc; #endif @@ -232,11 +232,13 @@ struct ProfileData { static ProfileData s_profile; -static double durationToMs(Duration c) { +static double durationToMs(Duration c) +{ return (double)c * 0.001; } -static double durationToSeconds(Duration c) { +static double durationToSeconds(Duration c) +{ return (double)c * 0.000001; } #else @@ -246,8 +248,10 @@ static double durationToSeconds(Duration c) { #define XA_PROFILE_ALLOC 0 #endif -struct MemTag { - enum { +struct MemTag +{ + enum + { Default, BitImage, BVH, @@ -270,7 +274,8 @@ struct MemTag { }; #if XA_DEBUG_HEAP -struct AllocHeader { +struct AllocHeader +{ size_t size; const char *file; int line; @@ -283,10 +288,11 @@ struct AllocHeader { static std::mutex s_allocMutex; static AllocHeader *s_allocRoot = nullptr; static size_t s_allocTotalCount = 0, s_allocTotalSize = 0, s_allocPeakSize = 0, s_allocCount[MemTag::Count] = { 0 }, s_allocTotalTagSize[MemTag::Count] = { 0 }, s_allocPeakTagSize[MemTag::Count] = { 0 }; -static uint32_t s_allocId = 0; +static uint32_t s_allocId =0 ; static constexpr uint32_t kAllocRedzone = 0x12345678; -static void *Realloc(void *ptr, size_t size, int tag, const char *file, int line) { +static void *Realloc(void *ptr, size_t size, int tag, const char *file, int line) +{ std::unique_lock<std::mutex> lock(s_allocMutex); if (!size && !ptr) return nullptr; @@ -347,7 +353,8 @@ static void *Realloc(void *ptr, size_t size, int tag, const char *file, int line return newPtr + sizeof(AllocHeader); } -static void ReportLeaks() { +static void ReportLeaks() +{ printf("Checking for memory leaks...\n"); bool anyLeaks = false; AllocHeader *header = s_allocRoot; @@ -375,7 +382,8 @@ static void ReportLeaks() { s_allocTotalTagSize[i] = s_allocPeakTagSize[i] = 0; } -static void PrintMemoryUsage() { +static void PrintMemoryUsage() +{ XA_PRINT("Total allocations: %zu\n", s_allocTotalCount); XA_PRINT("Memory usage: %0.2fMB current, %0.2fMB peak\n", internal::s_allocTotalSize / 1024.0f / 1024.0f, internal::s_allocPeakSize / 1024.0f / 1024.0f); static const char *labels[] = { // Sync with MemTag @@ -404,7 +412,8 @@ static void PrintMemoryUsage() { #define XA_PRINT_MEM_USAGE internal::PrintMemoryUsage(); #else -static void *Realloc(void *ptr, size_t size, int /*tag*/, const char * /*file*/, int /*line*/) { +static void *Realloc(void *ptr, size_t size, int /*tag*/, const char * /*file*/, int /*line*/) +{ if (size == 0 && !ptr) return nullptr; if (size == 0 && s_free) { @@ -430,75 +439,89 @@ static constexpr float kEpsilon = 0.0001f; static constexpr float kAreaEpsilon = FLT_EPSILON; static constexpr float kNormalEpsilon = 0.001f; -static int align(int x, int a) { +static int align(int x, int a) +{ return (x + a - 1) & ~(a - 1); } template <typename T> -static T max(const T &a, const T &b) { +static T max(const T &a, const T &b) +{ return a > b ? a : b; } template <typename T> -static T min(const T &a, const T &b) { +static T min(const T &a, const T &b) +{ return a < b ? a : b; } template <typename T> -static T max3(const T &a, const T &b, const T &c) { +static T max3(const T &a, const T &b, const T &c) +{ return max(a, max(b, c)); } /// Return the maximum of the three arguments. template <typename T> -static T min3(const T &a, const T &b, const T &c) { +static T min3(const T &a, const T &b, const T &c) +{ return min(a, min(b, c)); } /// Clamp between two values. template <typename T> -static T clamp(const T &x, const T &a, const T &b) { +static T clamp(const T &x, const T &a, const T &b) +{ return min(max(x, a), b); } template <typename T> -static void swap(T &a, T &b) { +static void swap(T &a, T &b) +{ T temp = a; a = b; b = temp; } -union FloatUint32 { +union FloatUint32 +{ float f; uint32_t u; }; -static bool isFinite(float f) { +static bool isFinite(float f) +{ FloatUint32 fu; fu.f = f; return fu.u != 0x7F800000u && fu.u != 0x7F800001u; } -static bool isNan(float f) { +static bool isNan(float f) +{ return f != f; } // Robust floating point comparisons: // http://realtimecollisiondetection.net/blog/?p=89 -static bool equal(const float f0, const float f1, const float epsilon) { +static bool equal(const float f0, const float f1, const float epsilon) +{ //return fabs(f0-f1) <= epsilon; return fabs(f0 - f1) <= epsilon * max3(1.0f, fabsf(f0), fabsf(f1)); } -static int ftoi_ceil(float val) { +static int ftoi_ceil(float val) +{ return (int)ceilf(val); } -static bool isZero(const float f, const float epsilon) { +static bool isZero(const float f, const float epsilon) +{ return fabs(f) <= epsilon; } -static float square(float f) { +static float square(float f) +{ return f * f; } @@ -508,8 +531,9 @@ static float square(float f) { * @note isPowerOfTwo(x) == true -> nextPowerOfTwo(x) == x * @note nextPowerOfTwo(x) = 2 << log2(x-1) */ -static uint32_t nextPowerOfTwo(uint32_t x) { - XA_DEBUG_ASSERT(x != 0); +static uint32_t nextPowerOfTwo(uint32_t x) +{ + XA_DEBUG_ASSERT( x != 0 ); // On modern CPUs this is supposed to be as fast as using the bsr instruction. x--; x |= x >> 1; @@ -520,34 +544,38 @@ static uint32_t nextPowerOfTwo(uint32_t x) { return x + 1; } -class Vector2 { +class Vector2 +{ public: Vector2() {} - explicit Vector2(float f) : - x(f), y(f) {} - Vector2(float _x, float _y) : - x(_x), y(_y) {} + explicit Vector2(float f) : x(f), y(f) {} + Vector2(float _x, float _y): x(_x), y(_y) {} - Vector2 operator-() const { + Vector2 operator-() const + { return Vector2(-x, -y); } - void operator+=(const Vector2 &v) { + void operator+=(const Vector2 &v) + { x += v.x; y += v.y; } - void operator-=(const Vector2 &v) { + void operator-=(const Vector2 &v) + { x -= v.x; y -= v.y; } - void operator*=(float s) { + void operator*=(float s) + { x *= s; y *= s; } - void operator*=(const Vector2 &v) { + void operator*=(const Vector2 &v) + { x *= v.x; y *= v.y; } @@ -555,11 +583,13 @@ public: float x, y; }; -static bool operator==(const Vector2 &a, const Vector2 &b) { +static bool operator==(const Vector2 &a, const Vector2 &b) +{ return a.x == b.x && a.y == b.y; } -static bool operator!=(const Vector2 &a, const Vector2 &b) { +static bool operator!=(const Vector2 &a, const Vector2 &b) +{ return a.x != b.x || a.y != b.y; } @@ -568,33 +598,40 @@ static bool operator!=(const Vector2 &a, const Vector2 &b) { return Vector2(a.x + b.x, a.y + b.y); }*/ -static Vector2 operator-(const Vector2 &a, const Vector2 &b) { +static Vector2 operator-(const Vector2 &a, const Vector2 &b) +{ return Vector2(a.x - b.x, a.y - b.y); } -static Vector2 operator*(const Vector2 &v, float s) { +static Vector2 operator*(const Vector2 &v, float s) +{ return Vector2(v.x * s, v.y * s); } -static float dot(const Vector2 &a, const Vector2 &b) { +static float dot(const Vector2 &a, const Vector2 &b) +{ return a.x * b.x + a.y * b.y; } -static float lengthSquared(const Vector2 &v) { +static float lengthSquared(const Vector2 &v) +{ return v.x * v.x + v.y * v.y; } -static float length(const Vector2 &v) { +static float length(const Vector2 &v) +{ return sqrtf(lengthSquared(v)); } #if XA_DEBUG -static bool isNormalized(const Vector2 &v, float epsilon = kNormalEpsilon) { +static bool isNormalized(const Vector2 &v, float epsilon = kNormalEpsilon) +{ return equal(length(v), 1, epsilon); } #endif -static Vector2 normalize(const Vector2 &v) { +static Vector2 normalize(const Vector2 &v) +{ const float l = length(v); XA_DEBUG_ASSERT(l > 0.0f); // Never negative. const Vector2 n = v * (1.0f / l); @@ -602,30 +639,36 @@ static Vector2 normalize(const Vector2 &v) { return n; } -static Vector2 normalizeSafe(const Vector2 &v, const Vector2 &fallback) { +static Vector2 normalizeSafe(const Vector2 &v, const Vector2 &fallback) +{ const float l = length(v); if (l > 0.0f) // Never negative. return v * (1.0f / l); return fallback; } -static bool equal(const Vector2 &v1, const Vector2 &v2, float epsilon) { +static bool equal(const Vector2 &v1, const Vector2 &v2, float epsilon) +{ return equal(v1.x, v2.x, epsilon) && equal(v1.y, v2.y, epsilon); } -static Vector2 min(const Vector2 &a, const Vector2 &b) { +static Vector2 min(const Vector2 &a, const Vector2 &b) +{ return Vector2(min(a.x, b.x), min(a.y, b.y)); } -static Vector2 max(const Vector2 &a, const Vector2 &b) { +static Vector2 max(const Vector2 &a, const Vector2 &b) +{ return Vector2(max(a.x, b.x), max(a.y, b.y)); } -static bool isFinite(const Vector2 &v) { +static bool isFinite(const Vector2 &v) +{ return isFinite(v.x) && isFinite(v.y); } -static float triangleArea(const Vector2 &a, const Vector2 &b, const Vector2 &c) { +static float triangleArea(const Vector2 &a, const Vector2 &b, const Vector2 &c) +{ // IC: While it may be appealing to use the following expression: //return (c.x * a.y + a.x * b.y + b.x * c.y - b.x * a.y - c.x * b.y - a.x * c.y) * 0.5f; // That's actually a terrible idea. Small triangles far from the origin can end up producing fairly large floating point @@ -639,7 +682,8 @@ static float triangleArea(const Vector2 &a, const Vector2 &b, const Vector2 &c) return (v0.x * v1.y - v0.y * v1.x) * 0.5f; } -static bool linesIntersect(const Vector2 &a1, const Vector2 &a2, const Vector2 &b1, const Vector2 &b2, float epsilon) { +static bool linesIntersect(const Vector2 &a1, const Vector2 &a2, const Vector2 &b1, const Vector2 &b2, float epsilon) +{ const Vector2 v0 = a2 - a1; const Vector2 v1 = b2 - b1; const float denom = -v1.x * v0.y + v0.x * v1.y; @@ -647,70 +691,76 @@ static bool linesIntersect(const Vector2 &a1, const Vector2 &a2, const Vector2 & return false; const float s = (-v0.y * (a1.x - b1.x) + v0.x * (a1.y - b1.y)) / denom; if (s > epsilon && s < 1.0f - epsilon) { - const float t = (v1.x * (a1.y - b1.y) - v1.y * (a1.x - b1.x)) / denom; + const float t = ( v1.x * (a1.y - b1.y) - v1.y * (a1.x - b1.x)) / denom; return t > epsilon && t < 1.0f - epsilon; } return false; } -struct Vector2i { +struct Vector2i +{ Vector2i() {} - Vector2i(int32_t _x, int32_t _y) : - x(_x), y(_y) {} + Vector2i(int32_t _x, int32_t _y) : x(_x), y(_y) {} int32_t x, y; }; -class Vector3 { +class Vector3 +{ public: Vector3() {} - explicit Vector3(float f) : - x(f), y(f), z(f) {} - Vector3(float _x, float _y, float _z) : - x(_x), y(_y), z(_z) {} - Vector3(const Vector2 &v, float _z) : - x(v.x), y(v.y), z(_z) {} - - Vector2 xy() const { + explicit Vector3(float f) : x(f), y(f), z(f) {} + Vector3(float _x, float _y, float _z) : x(_x), y(_y), z(_z) {} + Vector3(const Vector2 &v, float _z) : x(v.x), y(v.y), z(_z) {} + + Vector2 xy() const + { return Vector2(x, y); } - Vector3 operator-() const { + Vector3 operator-() const + { return Vector3(-x, -y, -z); } - void operator+=(const Vector3 &v) { + void operator+=(const Vector3 &v) + { x += v.x; y += v.y; z += v.z; } - void operator-=(const Vector3 &v) { + void operator-=(const Vector3 &v) + { x -= v.x; y -= v.y; z -= v.z; } - void operator*=(float s) { + void operator*=(float s) + { x *= s; y *= s; z *= s; } - void operator/=(float s) { + void operator/=(float s) + { float is = 1.0f / s; x *= is; y *= is; z *= is; } - void operator*=(const Vector3 &v) { + void operator*=(const Vector3 &v) + { x *= v.x; y *= v.y; z *= v.z; } - void operator/=(const Vector3 &v) { + void operator/=(const Vector3 &v) + { x /= v.x; y /= v.y; z /= v.z; @@ -719,47 +769,58 @@ public: float x, y, z; }; -static Vector3 operator+(const Vector3 &a, const Vector3 &b) { +static Vector3 operator+(const Vector3 &a, const Vector3 &b) +{ return Vector3(a.x + b.x, a.y + b.y, a.z + b.z); } -static Vector3 operator-(const Vector3 &a, const Vector3 &b) { +static Vector3 operator-(const Vector3 &a, const Vector3 &b) +{ return Vector3(a.x - b.x, a.y - b.y, a.z - b.z); } -static bool operator==(const Vector3 &a, const Vector3 &b) { +static bool operator==(const Vector3 &a, const Vector3 &b) +{ return a.x == b.x && a.y == b.y && a.z == b.z; } -static Vector3 cross(const Vector3 &a, const Vector3 &b) { +static Vector3 cross(const Vector3 &a, const Vector3 &b) +{ return Vector3(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x); } -static Vector3 operator*(const Vector3 &v, float s) { +static Vector3 operator*(const Vector3 &v, float s) +{ return Vector3(v.x * s, v.y * s, v.z * s); } -static Vector3 operator/(const Vector3 &v, float s) { +static Vector3 operator/(const Vector3 &v, float s) +{ return v * (1.0f / s); } -static float dot(const Vector3 &a, const Vector3 &b) { +static float dot(const Vector3 &a, const Vector3 &b) +{ return a.x * b.x + a.y * b.y + a.z * b.z; } -static float lengthSquared(const Vector3 &v) { +static float lengthSquared(const Vector3 &v) +{ return v.x * v.x + v.y * v.y + v.z * v.z; } -static float length(const Vector3 &v) { +static float length(const Vector3 &v) +{ return sqrtf(lengthSquared(v)); } -static bool isNormalized(const Vector3 &v, float epsilon = kNormalEpsilon) { +static bool isNormalized(const Vector3 &v, float epsilon = kNormalEpsilon) +{ return equal(length(v), 1.0f, epsilon); } -static Vector3 normalize(const Vector3 &v) { +static Vector3 normalize(const Vector3 &v) +{ const float l = length(v); XA_DEBUG_ASSERT(l > 0.0f); // Never negative. const Vector3 n = v * (1.0f / l); @@ -767,103 +828,116 @@ static Vector3 normalize(const Vector3 &v) { return n; } -static Vector3 normalizeSafe(const Vector3 &v, const Vector3 &fallback) { +static Vector3 normalizeSafe(const Vector3 &v, const Vector3 &fallback) +{ const float l = length(v); if (l > 0.0f) // Never negative. return v * (1.0f / l); return fallback; } -static bool equal(const Vector3 &v0, const Vector3 &v1, float epsilon) { +static bool equal(const Vector3 &v0, const Vector3 &v1, float epsilon) +{ return fabs(v0.x - v1.x) <= epsilon && fabs(v0.y - v1.y) <= epsilon && fabs(v0.z - v1.z) <= epsilon; } -static Vector3 min(const Vector3 &a, const Vector3 &b) { +static Vector3 min(const Vector3 &a, const Vector3 &b) +{ return Vector3(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z)); } -static Vector3 max(const Vector3 &a, const Vector3 &b) { +static Vector3 max(const Vector3 &a, const Vector3 &b) +{ return Vector3(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z)); } #if XA_DEBUG -bool isFinite(const Vector3 &v) { +bool isFinite(const Vector3 &v) +{ return isFinite(v.x) && isFinite(v.y) && isFinite(v.z); } #endif -struct Extents2 { +struct Extents2 +{ Vector2 min, max; Extents2() {} - Extents2(Vector2 p1, Vector2 p2) { + Extents2(Vector2 p1, Vector2 p2) + { min = xatlas::internal::min(p1, p2); max = xatlas::internal::max(p1, p2); } - void reset() { + void reset() + { min.x = min.y = FLT_MAX; max.x = max.y = -FLT_MAX; } - void add(Vector2 p) { + void add(Vector2 p) + { min = xatlas::internal::min(min, p); max = xatlas::internal::max(max, p); } - Vector2 midpoint() const { + Vector2 midpoint() const + { return Vector2(min.x + (max.x - min.x) * 0.5f, min.y + (max.y - min.y) * 0.5f); } - static bool intersect(const Extents2 &e1, const Extents2 &e2) { + static bool intersect(const Extents2 &e1, const Extents2 &e2) + { return e1.min.x <= e2.max.x && e1.max.x >= e2.min.x && e1.min.y <= e2.max.y && e1.max.y >= e2.min.y; } }; // From Fast-BVH -struct AABB { - AABB() : - min(FLT_MAX, FLT_MAX, FLT_MAX), max(-FLT_MAX, -FLT_MAX, -FLT_MAX) {} - AABB(const Vector3 &_min, const Vector3 &_max) : - min(_min), max(_max) {} - AABB(const Vector3 &p, float radius = 0.0f) : - min(p), max(p) { - if (radius > 0.0f) - expand(radius); - } - - bool intersect(const AABB &other) const { +struct AABB +{ + AABB() : min(FLT_MAX, FLT_MAX, FLT_MAX), max(-FLT_MAX, -FLT_MAX, -FLT_MAX) {} + AABB(const Vector3 &_min, const Vector3 &_max) : min(_min), max(_max) { } + AABB(const Vector3 &p, float radius = 0.0f) : min(p), max(p) { if (radius > 0.0f) expand(radius); } + + bool intersect(const AABB &other) const + { return min.x <= other.max.x && max.x >= other.min.x && min.y <= other.max.y && max.y >= other.min.y && min.z <= other.max.z && max.z >= other.min.z; } - void expandToInclude(const Vector3 &p) { + void expandToInclude(const Vector3 &p) + { min = internal::min(min, p); max = internal::max(max, p); } - void expandToInclude(const AABB &aabb) { + void expandToInclude(const AABB &aabb) + { min = internal::min(min, aabb.min); max = internal::max(max, aabb.max); } - void expand(float amount) { + void expand(float amount) + { min -= Vector3(amount); max += Vector3(amount); } - Vector3 centroid() const { + Vector3 centroid() const + { return min + (max - min) * 0.5f; } - uint32_t maxDimension() const { + uint32_t maxDimension() const + { const Vector3 extent = max - min; uint32_t result = 0; if (extent.y > extent.x) { result = 1; if (extent.z > extent.y) result = 2; - } else if (extent.z > extent.x) + } + else if(extent.z > extent.x) result = 2; return result; } @@ -871,9 +945,10 @@ struct AABB { Vector3 min, max; }; -struct ArrayBase { - ArrayBase(uint32_t _elementSize, int memTag = MemTag::Default) : - buffer(nullptr), elementSize(_elementSize), size(0), capacity(0) { +struct ArrayBase +{ + ArrayBase(uint32_t _elementSize, int memTag = MemTag::Default) : buffer(nullptr), elementSize(_elementSize), size(0), capacity(0) + { #if XA_DEBUG_HEAP this->memTag = memTag; #else @@ -881,15 +956,18 @@ struct ArrayBase { #endif } - ~ArrayBase() { + ~ArrayBase() + { XA_FREE(buffer); } - XA_INLINE void clear() { + XA_INLINE void clear() + { size = 0; } - void copyFrom(const uint8_t *data, uint32_t length) { + void copyFrom(const uint8_t *data, uint32_t length) + { XA_DEBUG_ASSERT(data); XA_DEBUG_ASSERT(length > 0); resize(length, true); @@ -897,7 +975,8 @@ struct ArrayBase { memcpy(buffer, data, length * elementSize); } - void copyTo(ArrayBase &other) const { + void copyTo(ArrayBase &other) const + { XA_DEBUG_ASSERT(elementSize == other.elementSize); XA_DEBUG_ASSERT(size > 0); other.resize(size, true); @@ -905,7 +984,8 @@ struct ArrayBase { memcpy(other.buffer, buffer, size * elementSize); } - void destroy() { + void destroy() + { size = 0; XA_FREE(buffer); buffer = nullptr; @@ -914,7 +994,8 @@ struct ArrayBase { } // Insert the given element at the given index shifting all the elements up. - void insertAt(uint32_t index, const uint8_t *value) { + void insertAt(uint32_t index, const uint8_t *value) + { XA_DEBUG_ASSERT(index >= 0 && index <= size); XA_DEBUG_ASSERT(value); resize(size + 1, false); @@ -925,7 +1006,8 @@ struct ArrayBase { memcpy(&buffer[index * elementSize], value, elementSize); } - void moveTo(ArrayBase &other) { + void moveTo(ArrayBase &other) + { XA_DEBUG_ASSERT(elementSize == other.elementSize); other.destroy(); other.buffer = buffer; @@ -939,12 +1021,14 @@ struct ArrayBase { elementSize = size = capacity = 0; } - void pop_back() { + void pop_back() + { XA_DEBUG_ASSERT(size > 0); resize(size - 1, false); } - void push_back(const uint8_t *value) { + void push_back(const uint8_t *value) + { XA_DEBUG_ASSERT(value < buffer || value >= buffer + size); XA_DEBUG_ASSERT(value); resize(size + 1, false); @@ -953,7 +1037,8 @@ struct ArrayBase { memcpy(&buffer[(size - 1) * elementSize], value, elementSize); } - void push_back(const ArrayBase &other) { + void push_back(const ArrayBase &other) + { XA_DEBUG_ASSERT(elementSize == other.elementSize); if (other.size > 0) { const uint32_t oldSize = size; @@ -965,7 +1050,8 @@ struct ArrayBase { } // Remove the element at the given index. This is an expensive operation! - void removeAt(uint32_t index) { + void removeAt(uint32_t index) + { XA_DEBUG_ASSERT(index >= 0 && index < size); XA_DEBUG_ASSERT(buffer); if (buffer) { @@ -977,7 +1063,8 @@ struct ArrayBase { } // Element at index is swapped with the last element, then the array length is decremented. - void removeAtFast(uint32_t index) { + void removeAtFast(uint32_t index) + { XA_DEBUG_ASSERT(index >= 0 && index < size); XA_DEBUG_ASSERT(buffer); if (buffer) { @@ -988,12 +1075,14 @@ struct ArrayBase { } } - void reserve(uint32_t desiredSize) { + void reserve(uint32_t desiredSize) + { if (desiredSize > capacity) setArrayCapacity(desiredSize); } - void resize(uint32_t newSize, bool exact) { + void resize(uint32_t newSize, bool exact) + { size = newSize; if (size > capacity) { // First allocation is always exact. Otherwise, following allocations grow array to 150% of desired size. @@ -1006,7 +1095,8 @@ struct ArrayBase { } } - void setArrayCapacity(uint32_t newCapacity) { + void setArrayCapacity(uint32_t newCapacity) + { XA_DEBUG_ASSERT(newCapacity >= size); if (newCapacity == 0) { // free the buffer. @@ -1026,7 +1116,8 @@ struct ArrayBase { } #if XA_DEBUG_HEAP - void setMemTag(int _memTag) { + void setMemTag(int _memTag) + { this->memTag = _memTag; } #endif @@ -1040,27 +1131,30 @@ struct ArrayBase { #endif }; -template <typename T> -class Array { +template<typename T> +class Array +{ public: - Array(int memTag = MemTag::Default) : - m_base(sizeof(T), memTag) {} - Array(const Array &) = delete; + Array(int memTag = MemTag::Default) : m_base(sizeof(T), memTag) {} + Array(const Array&) = delete; Array &operator=(const Array &) = delete; - XA_INLINE const T &operator[](uint32_t index) const { + XA_INLINE const T &operator[](uint32_t index) const + { XA_DEBUG_ASSERT(index < m_base.size); XA_DEBUG_ASSERT(m_base.buffer); return ((const T *)m_base.buffer)[index]; } - XA_INLINE T &operator[](uint32_t index) { + XA_INLINE T &operator[](uint32_t index) + { XA_DEBUG_ASSERT(index < m_base.size); XA_DEBUG_ASSERT(m_base.buffer); return ((T *)m_base.buffer)[index]; } - XA_INLINE const T &back() const { + XA_INLINE const T &back() const + { XA_DEBUG_ASSERT(!isEmpty()); return ((const T *)m_base.buffer)[m_base.size - 1]; } @@ -1068,7 +1162,8 @@ public: XA_INLINE T *begin() { return (T *)m_base.buffer; } XA_INLINE void clear() { m_base.clear(); } - bool contains(const T &value) const { + bool contains(const T &value) const + { for (uint32_t i = 0; i < m_base.size; i++) { if (((const T *)m_base.buffer)[i] == value) return true; @@ -1093,23 +1188,27 @@ public: void reserve(uint32_t desiredSize) { m_base.reserve(desiredSize); } void resize(uint32_t newSize) { m_base.resize(newSize, true); } - void runCtors() { + void runCtors() + { for (uint32_t i = 0; i < m_base.size; i++) new (&((T *)m_base.buffer)[i]) T; } - void runDtors() { + void runDtors() + { for (uint32_t i = 0; i < m_base.size; i++) ((T *)m_base.buffer)[i].~T(); } - void fill(const T &value) { + void fill(const T &value) + { auto buffer = (T *)m_base.buffer; for (uint32_t i = 0; i < m_base.size; i++) buffer[i] = value; } - void fillBytes(uint8_t value) { + void fillBytes(uint8_t value) + { if (m_base.buffer && m_base.size > 0) memset(m_base.buffer, (int)value, m_base.size * m_base.elementSize); } @@ -1120,7 +1219,8 @@ public: XA_INLINE uint32_t size() const { return m_base.size; } - XA_INLINE void zeroOutMemory() { + XA_INLINE void zeroOutMemory() + { if (m_base.buffer && m_base.size > 0) memset(m_base.buffer, 0, m_base.elementSize * m_base.size); } @@ -1129,57 +1229,37 @@ private: ArrayBase m_base; }; -template <typename T> -struct ArrayView { - ArrayView() : - data(nullptr), length(0) {} - ArrayView(Array<T> &a) : - data(a.data()), length(a.size()) {} - ArrayView(T *_data, uint32_t _length) : - data(_data), length(_length) {} - ArrayView &operator=(Array<T> &a) { - data = a.data(); - length = a.size(); - return *this; - } - XA_INLINE const T &operator[](uint32_t index) const { - XA_DEBUG_ASSERT(index < length); - return data[index]; - } - XA_INLINE T &operator[](uint32_t index) { - XA_DEBUG_ASSERT(index < length); - return data[index]; - } +template<typename T> +struct ArrayView +{ + ArrayView() : data(nullptr), length(0) {} + ArrayView(Array<T> &a) : data(a.data()), length(a.size()) {} + ArrayView(T *_data, uint32_t _length) : data(_data), length(_length) {} + ArrayView &operator=(Array<T> &a) { data = a.data(); length = a.size(); return *this; } + XA_INLINE const T &operator[](uint32_t index) const { XA_DEBUG_ASSERT(index < length); return data[index]; } + XA_INLINE T &operator[](uint32_t index) { XA_DEBUG_ASSERT(index < length); return data[index]; } T *data; uint32_t length; }; -template <typename T> -struct ConstArrayView { - ConstArrayView() : - data(nullptr), length(0) {} - ConstArrayView(const Array<T> &a) : - data(a.data()), length(a.size()) {} - ConstArrayView(ArrayView<T> av) : - data(av.data), length(av.length) {} - ConstArrayView(const T *_data, uint32_t _length) : - data(_data), length(_length) {} - ConstArrayView &operator=(const Array<T> &a) { - data = a.data(); - length = a.size(); - return *this; - } - XA_INLINE const T &operator[](uint32_t index) const { - XA_DEBUG_ASSERT(index < length); - return data[index]; - } +template<typename T> +struct ConstArrayView +{ + ConstArrayView() : data(nullptr), length(0) {} + ConstArrayView(const Array<T> &a) : data(a.data()), length(a.size()) {} + ConstArrayView(ArrayView<T> av) : data(av.data), length(av.length) {} + ConstArrayView(const T *_data, uint32_t _length) : data(_data), length(_length) {} + ConstArrayView &operator=(const Array<T> &a) { data = a.data(); length = a.size(); return *this; } + XA_INLINE const T &operator[](uint32_t index) const { XA_DEBUG_ASSERT(index < length); return data[index]; } const T *data; uint32_t length; }; /// Basis class to compute tangent space basis, ortogonalizations and to transform vectors from one space to another. -struct Basis { - XA_NODISCARD static Vector3 computeTangent(const Vector3 &normal) { +struct Basis +{ + XA_NODISCARD static Vector3 computeTangent(const Vector3 &normal) + { XA_ASSERT(isNormalized(normal)); // Choose minimum axis. Vector3 tangent; @@ -1195,7 +1275,8 @@ struct Basis { return tangent; } - XA_NODISCARD static Vector3 computeBitangent(const Vector3 &normal, const Vector3 &tangent) { + XA_NODISCARD static Vector3 computeBitangent(const Vector3 &normal, const Vector3 &tangent) + { return cross(normal, tangent); } @@ -1205,36 +1286,42 @@ struct Basis { }; // Simple bit array. -class BitArray { +class BitArray +{ public: - BitArray() : - m_size(0) {} + BitArray() : m_size(0) {} - BitArray(uint32_t sz) { + BitArray(uint32_t sz) + { resize(sz); } - void resize(uint32_t new_size) { + void resize(uint32_t new_size) + { m_size = new_size; m_wordArray.resize((m_size + 31) >> 5); } - bool get(uint32_t index) const { + bool get(uint32_t index) const + { XA_DEBUG_ASSERT(index < m_size); return (m_wordArray[index >> 5] & (1 << (index & 31))) != 0; } - void set(uint32_t index) { + void set(uint32_t index) + { XA_DEBUG_ASSERT(index < m_size); m_wordArray[index >> 5] |= (1 << (index & 31)); } - void unset(uint32_t index) { + void unset(uint32_t index) + { XA_DEBUG_ASSERT(index < m_size); m_wordArray[index >> 5] &= ~(1 << (index & 31)); } - void zeroOutMemory() { + void zeroOutMemory() + { m_wordArray.zeroOutMemory(); } @@ -1243,13 +1330,13 @@ private: Array<uint32_t> m_wordArray; }; -class BitImage { +class BitImage +{ public: - BitImage() : - m_width(0), m_height(0), m_rowStride(0), m_data(MemTag::BitImage) {} + BitImage() : m_width(0), m_height(0), m_rowStride(0), m_data(MemTag::BitImage) {} - BitImage(uint32_t w, uint32_t h) : - m_width(w), m_height(h), m_data(MemTag::BitImage) { + BitImage(uint32_t w, uint32_t h) : m_width(w), m_height(h), m_data(MemTag::BitImage) + { m_rowStride = (m_width + 63) >> 6; m_data.resize(m_rowStride * m_height); m_data.zeroOutMemory(); @@ -1260,14 +1347,16 @@ public: uint32_t width() const { return m_width; } uint32_t height() const { return m_height; } - void copyTo(BitImage &other) { + void copyTo(BitImage &other) + { other.m_width = m_width; other.m_height = m_height; other.m_rowStride = m_rowStride; m_data.copyTo(other.m_data); } - void resize(uint32_t w, uint32_t h, bool discard) { + void resize(uint32_t w, uint32_t h, bool discard) + { const uint32_t rowStride = (w + 63) >> 6; if (discard) { m_data.resize(rowStride * h); @@ -1291,24 +1380,28 @@ public: m_rowStride = rowStride; } - bool get(uint32_t x, uint32_t y) const { + bool get(uint32_t x, uint32_t y) const + { XA_DEBUG_ASSERT(x < m_width && y < m_height); const uint32_t index = (x >> 6) + y * m_rowStride; return (m_data[index] & (UINT64_C(1) << (uint64_t(x) & UINT64_C(63)))) != 0; } - void set(uint32_t x, uint32_t y) { + void set(uint32_t x, uint32_t y) + { XA_DEBUG_ASSERT(x < m_width && y < m_height); const uint32_t index = (x >> 6) + y * m_rowStride; m_data[index] |= UINT64_C(1) << (uint64_t(x) & UINT64_C(63)); XA_DEBUG_ASSERT(get(x, y)); } - void zeroOutMemory() { + void zeroOutMemory() + { m_data.zeroOutMemory(); } - bool canBlit(const BitImage &image, uint32_t offsetX, uint32_t offsetY) const { + bool canBlit(const BitImage &image, uint32_t offsetX, uint32_t offsetY) const + { for (uint32_t y = 0; y < image.m_height; y++) { const uint32_t thisY = y + offsetY; if (thisY >= m_height) @@ -1332,7 +1425,8 @@ public: return true; } - void dilate(uint32_t padding) { + void dilate(uint32_t padding) + { BitImage tmp(m_width, m_height); for (uint32_t p = 0; p < padding; p++) { tmp.zeroOutMemory(); @@ -1342,21 +1436,15 @@ public: if (!b) { if (x > 0) { b |= get(x - 1, y); - if (y > 0) - b |= get(x - 1, y - 1); - if (y < m_height - 1) - b |= get(x - 1, y + 1); + if (y > 0) b |= get(x - 1, y - 1); + if (y < m_height - 1) b |= get(x - 1, y + 1); } - if (y > 0) - b |= get(x, y - 1); - if (y < m_height - 1) - b |= get(x, y + 1); + if (y > 0) b |= get(x, y - 1); + if (y < m_height - 1) b |= get(x, y + 1); if (x < m_width - 1) { b |= get(x + 1, y); - if (y > 0) - b |= get(x + 1, y - 1); - if (y < m_height - 1) - b |= get(x + 1, y + 1); + if (y > 0) b |= get(x + 1, y - 1); + if (y < m_height - 1) b |= get(x + 1, y + 1); } } if (b) @@ -1375,10 +1463,11 @@ private: }; // From Fast-BVH -class BVH { +class BVH +{ public: - BVH(const Array<AABB> &objectAabbs, uint32_t leafSize = 4) : - m_objectIds(MemTag::BVH), m_nodes(MemTag::BVH) { + BVH(const Array<AABB> &objectAabbs, uint32_t leafSize = 4) : m_objectIds(MemTag::BVH), m_nodes(MemTag::BVH) + { m_objectAabbs = &objectAabbs; if (m_objectAabbs->isEmpty()) return; @@ -1398,7 +1487,7 @@ public: Node node; m_nodes.reserve(objectAabbs.size() * 2); uint32_t nNodes = 0; - while (stackptr > 0) { + while(stackptr > 0) { // Pop the next item off of the stack const BuildEntry &bnode = todo[--stackptr]; const uint32_t start = bnode.start; @@ -1411,7 +1500,7 @@ public: // Calculate the bounding box for this node AABB bb(objectAabbs[m_objectIds[start]]); AABB bc(objectAabbs[m_objectIds[start]].centroid()); - for (uint32_t p = start + 1; p < end; ++p) { + for(uint32_t p = start + 1; p < end; ++p) { bb.expandToInclude(objectAabbs[m_objectIds[p]]); bc.expandToInclude(objectAabbs[m_objectIds[p]].centroid()); } @@ -1427,7 +1516,7 @@ public: m_nodes[bnode.parent].rightOffset--; // When this is the second touch, this is the right child. // The right child sets up the offset for the flat tree. - if (m_nodes[bnode.parent].rightOffset == kTouchedTwice) + if (m_nodes[bnode.parent].rightOffset == kTouchedTwice ) m_nodes[bnode.parent].rightOffset = nNodes - 1 - bnode.parent; } // If this is a leaf, no need to subdivide. @@ -1462,20 +1551,21 @@ public: } } - void query(const AABB &queryAabb, Array<uint32_t> &result) const { + void query(const AABB &queryAabb, Array<uint32_t> &result) const + { result.clear(); // Working set uint32_t todo[64]; int32_t stackptr = 0; // "Push" on the root node to the working set todo[stackptr] = 0; - while (stackptr >= 0) { + while(stackptr >= 0) { // Pop off the next node to work on. const int ni = todo[stackptr--]; const Node &node = m_nodes[ni]; // Is leaf -> Intersect if (node.rightOffset == 0) { - for (uint32_t o = 0; o < node.nPrims; ++o) { + for(uint32_t o = 0; o < node.nPrims; ++o) { const uint32_t obj = node.start + o; if (queryAabb.intersect((*m_objectAabbs)[m_objectIds[obj]])) result.push_back(m_objectIds[obj]); @@ -1492,12 +1582,14 @@ public: } private: - struct BuildEntry { + struct BuildEntry + { uint32_t parent; // If non-zero then this is the index of the parent. (used in offsets) uint32_t start, end; // The range of objects in the object list covered by this node. }; - struct Node { + struct Node + { AABB aabb; uint32_t start, nPrims, rightOffset; }; @@ -1507,8 +1599,10 @@ private: Array<Node> m_nodes; }; -struct Fit { - static bool computeBasis(ConstArrayView<Vector3> points, Basis *basis) { +struct Fit +{ + static bool computeBasis(ConstArrayView<Vector3> points, Basis *basis) + { if (computeLeastSquaresNormal(points, &basis->normal)) { basis->tangent = Basis::computeTangent(basis->normal); basis->bitangent = Basis::computeBitangent(basis->normal, basis->tangent); @@ -1522,7 +1616,8 @@ private: // Fast, and accurate to within a few degrees. // Returns None if the points do not span a plane. // https://www.ilikebigbits.com/2015_03_04_plane_from_points.html - static bool computeLeastSquaresNormal(ConstArrayView<Vector3> points, Vector3 *normal) { + static bool computeLeastSquaresNormal(ConstArrayView<Vector3> points, Vector3 *normal) + { XA_DEBUG_ASSERT(points.length >= 3); if (points.length == 3) { *normal = normalize(cross(points[2] - points[0], points[1] - points[0])); @@ -1587,7 +1682,7 @@ private: // Pick path with best conditioning: Vector3 dir(0.0f); if (det_max == det_x) - dir = Vector3(det_x, xz * yz - xy * zz, xy * yz - xz * yy); + dir = Vector3(det_x,xz * yz - xy * zz,xy * yz - xz * yy); else if (det_max == det_y) dir = Vector3(xz * yz - xy * zz, det_y, xy * xz - yz * xx); else if (det_max == det_z) @@ -1600,7 +1695,8 @@ private: return isNormalized(*normal); } - static bool computeEigen(ConstArrayView<Vector3> points, Basis *basis) { + static bool computeEigen(ConstArrayView<Vector3> points, Basis *basis) + { float matrix[6]; computeCovariance(points, matrix); if (matrix[0] == 0 && matrix[3] == 0 && matrix[5] == 0) @@ -1615,7 +1711,8 @@ private: return true; } - static Vector3 computeCentroid(ConstArrayView<Vector3> points) { + static Vector3 computeCentroid(ConstArrayView<Vector3> points) + { Vector3 centroid(0.0f); for (uint32_t i = 0; i < points.length; i++) centroid += points[i]; @@ -1623,7 +1720,8 @@ private: return centroid; } - static Vector3 computeCovariance(ConstArrayView<Vector3> points, float *covariance) { + static Vector3 computeCovariance(ConstArrayView<Vector3> points, float * covariance) + { // compute the centroid Vector3 centroid = computeCentroid(points); // compute covariance matrix @@ -1645,7 +1743,8 @@ private: // Tridiagonal solver from Charles Bloom. // Householder transforms followed by QL decomposition. // Seems to be based on the code from Numerical Recipes in C. - static bool eigenSolveSymmetric3(const float matrix[6], float eigenValues[3], Vector3 eigenVectors[3]) { + static bool eigenSolveSymmetric3(const float matrix[6], float eigenValues[3], Vector3 eigenVectors[3]) + { XA_DEBUG_ASSERT(matrix != nullptr && eigenValues != nullptr && eigenVectors != nullptr); float subd[3]; float diag[3]; @@ -1670,7 +1769,7 @@ private: // eigenvectors are the columns; make them the rows : for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { - (&eigenVectors[j].x)[i] = (float)work[i][j]; + (&eigenVectors[j].x)[i] = (float) work[i][j]; } } // shuffle to sort by singular value : @@ -1692,7 +1791,8 @@ private: } private: - static void EigenSolver3_Tridiagonal(float mat[3][3], float *diag, float *subd) { + static void EigenSolver3_Tridiagonal(float mat[3][3], float *diag, float *subd) + { // Householder reduction T = Q^t M Q // Input: // mat, symmetric 3x3 matrix M @@ -1744,7 +1844,8 @@ private: } } - static bool EigenSolver3_QLAlgorithm(float mat[3][3], float *diag, float *subd) { + static bool EigenSolver3_QLAlgorithm(float mat[3][3], float *diag, float *subd) + { // QL iteration with implicit shifting to reduce matrix from tridiagonal // to diagonal const int maxiter = 32; @@ -1754,21 +1855,21 @@ private: int m; for (m = ell; m <= 1; m++) { float dd = fabsf(diag[m]) + fabsf(diag[m + 1]); - if (fabsf(subd[m]) + dd == dd) + if ( fabsf(subd[m]) + dd == dd ) break; } - if (m == ell) + if ( m == ell ) break; float g = (diag[ell + 1] - diag[ell]) / (2 * subd[ell]); float r = sqrtf(g * g + 1); - if (g < 0) + if ( g < 0 ) g = diag[m] - diag[ell] + subd[ell] / (g - r); else g = diag[m] - diag[ell] + subd[ell] / (g + r); float s = 1, c = 1, p = 0; for (int i = m - 1; i >= ell; i--) { float f = s * subd[i], b = c * subd[i]; - if (fabsf(f) >= fabsf(g)) { + if ( fabsf(f) >= fabsf(g) ) { c = g / f; r = sqrtf(c * c + 1); subd[i + 1] = f * r; @@ -1794,7 +1895,7 @@ private: subd[ell] = g; subd[m] = 0; } - if (iter == maxiter) + if ( iter == maxiter ) // should not get here under normal circumstances return false; } @@ -1802,48 +1903,56 @@ private: } }; -static uint32_t sdbmHash(const void *data_in, uint32_t size, uint32_t h = 5381) { - const uint8_t *data = (const uint8_t *)data_in; +static uint32_t sdbmHash(const void *data_in, uint32_t size, uint32_t h = 5381) +{ + const uint8_t *data = (const uint8_t *) data_in; uint32_t i = 0; while (i < size) { - h = (h << 16) + (h << 6) - h + (uint32_t)data[i++]; + h = (h << 16) + (h << 6) - h + (uint32_t ) data[i++]; } return h; } template <typename T> -static uint32_t hash(const T &t, uint32_t h = 5381) { +static uint32_t hash(const T &t, uint32_t h = 5381) +{ return sdbmHash(&t, sizeof(T), h); } template <typename Key> -struct Hash { +struct Hash +{ uint32_t operator()(const Key &k) const { return hash(k); } }; template <typename Key> -struct PassthroughHash { +struct PassthroughHash +{ uint32_t operator()(const Key &k) const { return (uint32_t)k; } }; template <typename Key> -struct Equal { +struct Equal +{ bool operator()(const Key &k0, const Key &k1) const { return k0 == k1; } }; -template <typename Key, typename H = Hash<Key>, typename E = Equal<Key>> -class HashMap { +template<typename Key, typename H = Hash<Key>, typename E = Equal<Key> > +class HashMap +{ public: - HashMap(int memTag, uint32_t size) : - m_memTag(memTag), m_size(size), m_numSlots(0), m_slots(nullptr), m_keys(memTag), m_next(memTag) { + HashMap(int memTag, uint32_t size) : m_memTag(memTag), m_size(size), m_numSlots(0), m_slots(nullptr), m_keys(memTag), m_next(memTag) + { } - ~HashMap() { + ~HashMap() + { if (m_slots) XA_FREE(m_slots); } - void destroy() { + void destroy() + { if (m_slots) { XA_FREE(m_slots); m_slots = nullptr; @@ -1852,7 +1961,8 @@ public: m_next.destroy(); } - uint32_t add(const Key &key) { + uint32_t add(const Key &key) + { if (!m_slots) alloc(); const uint32_t hash = computeHash(key); @@ -1862,18 +1972,21 @@ public: return m_keys.size() - 1; } - uint32_t get(const Key &key) const { + uint32_t get(const Key &key) const + { if (!m_slots) return UINT32_MAX; return find(key, m_slots[computeHash(key)]); } - uint32_t getNext(const Key &key, uint32_t current) const { + uint32_t getNext(const Key &key, uint32_t current) const + { return find(key, m_next[current]); } private: - void alloc() { + void alloc() + { XA_DEBUG_ASSERT(m_size > 0); m_numSlots = nextPowerOfTwo(m_size); auto minNumSlots = uint32_t(m_size * 1.3); @@ -1886,12 +1999,14 @@ private: m_next.reserve(m_size); } - uint32_t computeHash(const Key &key) const { + uint32_t computeHash(const Key &key) const + { H hash; return hash(key) & (m_numSlots - 1); } - uint32_t find(const Key &key, uint32_t current) const { + uint32_t find(const Key &key, uint32_t current) const + { E equal; while (current != UINT32_MAX) { if (equal(m_keys[current], key)) @@ -1909,8 +2024,9 @@ private: Array<uint32_t> m_next; }; -template <typename T> -static void insertionSort(T *data, uint32_t length) { +template<typename T> +static void insertionSort(T *data, uint32_t length) +{ for (int32_t i = 1; i < (int32_t)length; i++) { T x = data[i]; int32_t j = i - 1; @@ -1922,18 +2038,21 @@ static void insertionSort(T *data, uint32_t length) { } } -class KISSRng { +class KISSRng +{ public: KISSRng() { reset(); } - void reset() { + void reset() + { x = 123456789; y = 362436000; z = 521288629; c = 7654321; } - uint32_t getRange(uint32_t range) { + uint32_t getRange(uint32_t range) + { if (range == 0) return 0; x = 69069 * x + 12345; @@ -1952,9 +2071,11 @@ private: // Based on Pierre Terdiman's and Michael Herf's source code. // http://www.codercorner.com/RadixSortRevisited.htm // http://www.stereopsis.com/radix.html -class RadixSort { +class RadixSort +{ public: - void sort(ConstArrayView<float> input) { + void sort(ConstArrayView<float> input) + { if (input.length == 0) { m_buffer1.clear(); m_buffer2.clear(); @@ -1983,7 +2104,8 @@ public: } // Access to results. m_ranks is a list of indices in sorted order, i.e. in the order you may further process your data - const uint32_t *ranks() const { + const uint32_t *ranks() const + { XA_DEBUG_ASSERT(m_validRanks); return m_ranks; } @@ -1993,17 +2115,20 @@ private: Array<uint32_t> m_buffer1, m_buffer2; bool m_validRanks = false; - void floatFlip(uint32_t &f) { + void floatFlip(uint32_t &f) + { int32_t mask = (int32_t(f) >> 31) | 0x80000000; // Warren Hunt, Manchor Ko. f ^= mask; } - void ifloatFlip(uint32_t &f) { + void ifloatFlip(uint32_t &f) + { uint32_t mask = ((f >> 31) - 1) | 0x80000000; // Michael Herf. f ^= mask; } - void createHistograms(ConstArrayView<uint32_t> input, uint32_t *histogram) { + void createHistograms(ConstArrayView<uint32_t> input, uint32_t *histogram) + { const uint32_t bucketCount = sizeof(uint32_t); // Init bucket pointers. uint32_t *h[bucketCount]; @@ -2014,14 +2139,15 @@ private: memset(histogram, 0, 256 * bucketCount * sizeof(uint32_t)); // @@ Add support for signed integers. // Build histograms. - const uint8_t *p = (const uint8_t *)input.data; // @@ Does this break aliasing rules? + const uint8_t *p = (const uint8_t *)input.data; // @@ Does this break aliasing rules? const uint8_t *pe = p + input.length * sizeof(uint32_t); while (p != pe) { h[0][*p++]++, h[1][*p++]++, h[2][*p++]++, h[3][*p++]++; } } - void insertionSort(ConstArrayView<float> input) { + void insertionSort(ConstArrayView<float> input) + { if (!m_validRanks) { m_ranks[0] = 0; for (uint32_t i = 1; i != input.length; ++i) { @@ -2051,7 +2177,8 @@ private: } } - void radixSort(ConstArrayView<uint32_t> input) { + void radixSort(ConstArrayView<uint32_t> input) + { const uint32_t P = sizeof(uint32_t); // pass count // Allocate histograms & offsets on the stack uint32_t histogram[256 * P]; @@ -2069,8 +2196,7 @@ private: } // Create offsets link[0] = m_ranks2; - for (uint32_t i = 1; i < 256; i++) - link[i] = link[i - 1] + h[i - 1]; + for (uint32_t i = 1; i < 256; i++) link[i] = link[i - 1] + h[i - 1]; // Perform Radix Sort if (!m_validRanks) { for (uint32_t i = 0; i < input.length; i++) { @@ -2096,21 +2222,25 @@ private: }; // Wrapping this in a class allows temporary arrays to be re-used. -class BoundingBox2D { +class BoundingBox2D +{ public: Vector2 majorAxis, minorAxis, minCorner, maxCorner; - void clear() { + void clear() + { m_boundaryVertices.clear(); } - void appendBoundaryVertex(Vector2 v) { + void appendBoundaryVertex(Vector2 v) + { m_boundaryVertices.push_back(v); } // This should compute convex hull and use rotating calipers to find the best box. Currently it uses a brute force method. // If vertices are empty, the boundary vertices are used. - void compute(ConstArrayView<Vector2> vertices = ConstArrayView<Vector2>()) { + void compute(ConstArrayView<Vector2> vertices = ConstArrayView<Vector2>()) + { XA_DEBUG_ASSERT(!m_boundaryVertices.isEmpty()); if (vertices.length == 0) vertices = m_boundaryVertices; @@ -2157,7 +2287,8 @@ public: private: // Compute the convex hull using Graham Scan. - void convexHull(ConstArrayView<Vector2> input, Array<Vector2> &output, float epsilon) { + void convexHull(ConstArrayView<Vector2> input, Array<Vector2> &output, float epsilon) + { m_coords.resize(input.length); for (uint32_t i = 0; i < input.length; i++) m_coords[i] = input[i].x; @@ -2186,7 +2317,7 @@ private: XA_DEBUG_ASSERT(m_top.size() >= 2); output.push_back(m_top[0]); output.push_back(m_top[1]); - for (uint32_t i = 2; i < m_top.size();) { + for (uint32_t i = 2; i < m_top.size(); ) { Vector2 a = output[output.size() - 2]; Vector2 b = output[output.size() - 1]; Vector2 c = m_top[i]; @@ -2202,7 +2333,7 @@ private: XA_DEBUG_ASSERT(m_bottom.size() >= 2); output.push_back(m_bottom[1]); // Filter bottom list. - for (uint32_t i = 2; i < m_bottom.size();) { + for (uint32_t i = 2; i < m_bottom.size(); ) { Vector2 a = output[output.size() - 2]; Vector2 b = output[output.size() - 1]; Vector2 c = m_bottom[i]; @@ -2225,45 +2356,45 @@ private: RadixSort m_radix; }; -struct EdgeKey { - EdgeKey(const EdgeKey &k) : - v0(k.v0), v1(k.v1) {} - EdgeKey(uint32_t _v0, uint32_t _v1) : - v0(_v0), v1(_v1) {} +struct EdgeKey +{ + EdgeKey(const EdgeKey &k) : v0(k.v0), v1(k.v1) {} + EdgeKey(uint32_t _v0, uint32_t _v1) : v0(_v0), v1(_v1) {} bool operator==(const EdgeKey &k) const { return v0 == k.v0 && v1 == k.v1; } uint32_t v0; uint32_t v1; }; -struct EdgeHash { +struct EdgeHash +{ uint32_t operator()(const EdgeKey &k) const { return k.v0 * 32768u + k.v1; } }; -static uint32_t meshEdgeFace(uint32_t edge) { - return edge / 3; -} -static uint32_t meshEdgeIndex0(uint32_t edge) { - return edge; -} +static uint32_t meshEdgeFace(uint32_t edge) { return edge / 3; } +static uint32_t meshEdgeIndex0(uint32_t edge) { return edge; } -static uint32_t meshEdgeIndex1(uint32_t edge) { +static uint32_t meshEdgeIndex1(uint32_t edge) +{ const uint32_t faceFirstEdge = edge / 3 * 3; return faceFirstEdge + (edge - faceFirstEdge + 1) % 3; } -struct MeshFlags { - enum { - HasIgnoredFaces = 1 << 0, - HasNormals = 1 << 1, - HasMaterials = 1 << 2 +struct MeshFlags +{ + enum + { + HasIgnoredFaces = 1<<0, + HasNormals = 1<<1, + HasMaterials = 1<<2 }; }; -class Mesh { +class Mesh +{ public: - Mesh(float epsilon, uint32_t approxVertexCount, uint32_t approxFaceCount, uint32_t flags = 0, uint32_t id = UINT32_MAX) : - m_epsilon(epsilon), m_flags(flags), m_id(id), m_faceIgnore(MemTag::Mesh), m_faceMaterials(MemTag::Mesh), m_indices(MemTag::MeshIndices), m_positions(MemTag::MeshPositions), m_normals(MemTag::MeshNormals), m_texcoords(MemTag::MeshTexcoords), m_nextColocalVertex(MemTag::MeshColocals), m_firstColocalVertex(MemTag::MeshColocals), m_boundaryEdges(MemTag::MeshBoundaries), m_oppositeEdges(MemTag::MeshBoundaries), m_edgeMap(MemTag::MeshEdgeMap, approxFaceCount * 3) { + Mesh(float epsilon, uint32_t approxVertexCount, uint32_t approxFaceCount, uint32_t flags = 0, uint32_t id = UINT32_MAX) : m_epsilon(epsilon), m_flags(flags), m_id(id), m_faceIgnore(MemTag::Mesh), m_faceMaterials(MemTag::Mesh), m_indices(MemTag::MeshIndices), m_positions(MemTag::MeshPositions), m_normals(MemTag::MeshNormals), m_texcoords(MemTag::MeshTexcoords), m_nextColocalVertex(MemTag::MeshColocals), m_firstColocalVertex(MemTag::MeshColocals), m_boundaryEdges(MemTag::MeshBoundaries), m_oppositeEdges(MemTag::MeshBoundaries), m_edgeMap(MemTag::MeshEdgeMap, approxFaceCount * 3) + { m_indices.reserve(approxFaceCount * 3); m_positions.reserve(approxVertexCount); m_texcoords.reserve(approxVertexCount); @@ -2278,7 +2409,8 @@ public: uint32_t flags() const { return m_flags; } uint32_t id() const { return m_id; } - void addVertex(const Vector3 &pos, const Vector3 &normal = Vector3(0.0f), const Vector2 &texcoord = Vector2(0.0f)) { + void addVertex(const Vector3 &pos, const Vector3 &normal = Vector3(0.0f), const Vector2 &texcoord = Vector2(0.0f)) + { XA_DEBUG_ASSERT(isFinite(pos)); m_positions.push_back(pos); if (m_flags & MeshFlags::HasNormals) @@ -2286,7 +2418,8 @@ public: m_texcoords.push_back(texcoord); } - void addFace(const uint32_t *indices, bool ignore = false, uint32_t material = UINT32_MAX) { + void addFace(const uint32_t *indices, bool ignore = false, uint32_t material = UINT32_MAX) + { if (m_flags & MeshFlags::HasIgnoredFaces) m_faceIgnore.push_back(ignore); if (m_flags & MeshFlags::HasMaterials) @@ -2301,7 +2434,8 @@ public: } } - void createColocalsBVH() { + void createColocalsBVH() + { const uint32_t vertexCount = m_positions.size(); Array<AABB> aabbs(MemTag::BVH); aabbs.resize(vertexCount); @@ -2342,7 +2476,8 @@ public: } } - void createColocalsHash() { + void createColocalsHash() + { const uint32_t vertexCount = m_positions.size(); HashMap<Vector3> positionToVertexMap(MemTag::Default, vertexCount); for (uint32_t i = 0; i < vertexCount; i++) @@ -2380,14 +2515,16 @@ public: } } - void createColocals() { + void createColocals() + { if (m_epsilon <= FLT_EPSILON) createColocalsHash(); else createColocalsBVH(); } - void createBoundaries() { + void createBoundaries() + { const uint32_t edgeCount = m_indices.size(); const uint32_t vertexCount = m_positions.size(); m_oppositeEdges.resize(edgeCount); @@ -2418,7 +2555,8 @@ public: } /// Find edge, test all colocals. - uint32_t findEdge(uint32_t vertex0, uint32_t vertex1) const { + uint32_t findEdge(uint32_t vertex0, uint32_t vertex1) const + { // Try to find exact vertex match first. { EdgeKey key(vertex0, vertex1); @@ -2459,12 +2597,14 @@ public: // Edge map can be destroyed when no longer used to reduce memory usage. It's used by: // * Mesh::createBoundaries() // * Mesh::edgeMap() (used by MeshFaceGroups) - void destroyEdgeMap() { + void destroyEdgeMap() + { m_edgeMap.destroy(); } #if XA_DEBUG_EXPORT_OBJ - void writeObjVertices(FILE *file) const { + void writeObjVertices(FILE *file) const + { for (uint32_t i = 0; i < m_positions.size(); i++) fprintf(file, "v %g %g %g\n", m_positions[i].x, m_positions[i].y, m_positions[i].z); if (m_flags & MeshFlags::HasNormals) { @@ -2475,7 +2615,8 @@ public: fprintf(file, "vt %g %g\n", m_texcoords[i].x, m_texcoords[i].y); } - void writeObjFace(FILE *file, uint32_t face, uint32_t offset = 0) const { + void writeObjFace(FILE *file, uint32_t face, uint32_t offset = 0) const + { fprintf(file, "f "); for (uint32_t j = 0; j < 3; j++) { const uint32_t index = m_indices[face * 3 + j] + 1 + offset; // 1-indexed @@ -2483,7 +2624,8 @@ public: } } - void writeObjBoundaryEges(FILE *file) const { + void writeObjBoundaryEges(FILE *file) const + { if (m_oppositeEdges.isEmpty()) return; // Boundaries haven't been created. fprintf(file, "o boundary_edges\n"); @@ -2494,7 +2636,8 @@ public: } } - void writeObjFile(const char *filename) const { + void writeObjFile(const char *filename) const + { FILE *file; XA_FOPEN(file, filename, "w"); if (!file) @@ -2509,7 +2652,8 @@ public: } #endif - float computeSurfaceArea() const { + float computeSurfaceArea() const + { float area = 0; for (uint32_t f = 0; f < faceCount(); f++) area += computeFaceArea(f); @@ -2518,21 +2662,24 @@ public: } // Returned value is always positive, even if some triangles are flipped. - float computeParametricArea() const { + float computeParametricArea() const + { float area = 0; for (uint32_t f = 0; f < faceCount(); f++) area += fabsf(computeFaceParametricArea(f)); // May be negative, depends on texcoord winding. return area; } - float computeFaceArea(uint32_t face) const { + float computeFaceArea(uint32_t face) const + { const Vector3 &p0 = m_positions[m_indices[face * 3 + 0]]; const Vector3 &p1 = m_positions[m_indices[face * 3 + 1]]; const Vector3 &p2 = m_positions[m_indices[face * 3 + 2]]; return length(cross(p1 - p0, p2 - p0)) * 0.5f; } - Vector3 computeFaceCentroid(uint32_t face) const { + Vector3 computeFaceCentroid(uint32_t face) const + { Vector3 sum(0.0f); for (uint32_t i = 0; i < 3; i++) sum += m_positions[m_indices[face * 3 + i]]; @@ -2541,7 +2688,8 @@ public: // Average of the edge midpoints weighted by the edge length. // I want a point inside the triangle, but closer to the cirumcenter. - Vector3 computeFaceCenter(uint32_t face) const { + Vector3 computeFaceCenter(uint32_t face) const + { const Vector3 &p0 = m_positions[m_indices[face * 3 + 0]]; const Vector3 &p1 = m_positions[m_indices[face * 3 + 1]]; const Vector3 &p2 = m_positions[m_indices[face * 3 + 2]]; @@ -2554,7 +2702,8 @@ public: return m0 + m1 + m2; } - Vector3 computeFaceNormal(uint32_t face) const { + Vector3 computeFaceNormal(uint32_t face) const + { const Vector3 &p0 = m_positions[m_indices[face * 3 + 0]]; const Vector3 &p1 = m_positions[m_indices[face * 3 + 1]]; const Vector3 &p2 = m_positions[m_indices[face * 3 + 2]]; @@ -2564,7 +2713,8 @@ public: return normalizeSafe(normalAreaScaled, Vector3(0, 0, 1)); } - float computeFaceParametricArea(uint32_t face) const { + float computeFaceParametricArea(uint32_t face) const + { const Vector2 &t0 = m_texcoords[m_indices[face * 3 + 0]]; const Vector2 &t1 = m_texcoords[m_indices[face * 3 + 1]]; const Vector2 &t2 = m_texcoords[m_indices[face * 3 + 2]]; @@ -2572,7 +2722,8 @@ public: } // @@ This is not exactly accurate, we should compare the texture coordinates... - bool isSeam(uint32_t edge) const { + bool isSeam(uint32_t edge) const + { const uint32_t oppositeEdge = m_oppositeEdges[edge]; if (oppositeEdge == UINT32_MAX) return false; // boundary edge @@ -2583,7 +2734,8 @@ public: return m_indices[e0] != m_indices[oe1] || m_indices[e1] != m_indices[oe0]; } - bool isTextureSeam(uint32_t edge) const { + bool isTextureSeam(uint32_t edge) const + { const uint32_t oppositeEdge = m_oppositeEdges[edge]; if (oppositeEdge == UINT32_MAX) return false; // boundary edge @@ -2594,7 +2746,8 @@ public: return m_texcoords[m_indices[e0]] != m_texcoords[m_indices[oe1]] || m_texcoords[m_indices[e1]] != m_texcoords[m_indices[oe0]]; } - uint32_t firstColocalVertex(uint32_t vertex) const { + uint32_t firstColocalVertex(uint32_t vertex) const + { XA_DEBUG_ASSERT(m_firstColocalVertex.size() == m_positions.size()); return m_firstColocalVertex[vertex]; } @@ -2609,10 +2762,7 @@ public: XA_INLINE uint32_t vertexAt(uint32_t i) const { return m_indices[i]; } XA_INLINE const Vector3 &position(uint32_t vertex) const { return m_positions[vertex]; } XA_INLINE ConstArrayView<Vector3> positions() const { return m_positions; } - XA_INLINE const Vector3 &normal(uint32_t vertex) const { - XA_DEBUG_ASSERT(m_flags & MeshFlags::HasNormals); - return m_normals[vertex]; - } + XA_INLINE const Vector3 &normal(uint32_t vertex) const { XA_DEBUG_ASSERT(m_flags & MeshFlags::HasNormals); return m_normals[vertex]; } XA_INLINE const Vector2 &texcoord(uint32_t vertex) const { return m_texcoords[vertex]; } XA_INLINE Vector2 &texcoord(uint32_t vertex) { return m_texcoords[vertex]; } XA_INLINE const ConstArrayView<Vector2> texcoords() const { return m_texcoords; } @@ -2625,6 +2775,7 @@ public: XA_INLINE const HashMap<EdgeKey, EdgeHash> &edgeMap() const { return m_edgeMap; } private: + float m_epsilon; uint32_t m_flags; uint32_t m_id; @@ -2647,21 +2798,24 @@ private: HashMap<EdgeKey, EdgeHash> m_edgeMap; public: - class FaceEdgeIterator { + class FaceEdgeIterator + { public: - FaceEdgeIterator(const Mesh *mesh, uint32_t face) : - m_mesh(mesh), m_face(face), m_relativeEdge(0) { + FaceEdgeIterator (const Mesh *mesh, uint32_t face) : m_mesh(mesh), m_face(face), m_relativeEdge(0) + { m_edge = m_face * 3; } - void advance() { + void advance() + { if (m_relativeEdge < 3) { m_edge++; m_relativeEdge++; } } - bool isDone() const { + bool isDone() const + { return m_relativeEdge == 3; } @@ -2673,7 +2827,8 @@ public: uint32_t face() const { return m_face; } uint32_t oppositeEdge() const { return m_mesh->m_oppositeEdges[m_edge]; } - uint32_t oppositeFace() const { + uint32_t oppositeFace() const + { const uint32_t oedge = m_mesh->m_oppositeEdges[m_edge]; if (oedge == UINT32_MAX) return UINT32_MAX; @@ -2697,18 +2852,19 @@ public: }; }; -struct MeshFaceGroups { +struct MeshFaceGroups +{ typedef uint32_t Handle; static constexpr Handle kInvalid = UINT32_MAX; - MeshFaceGroups(const Mesh *mesh) : - m_mesh(mesh), m_groups(MemTag::Mesh), m_firstFace(MemTag::Mesh), m_nextFace(MemTag::Mesh), m_faceCount(MemTag::Mesh) {} + MeshFaceGroups(const Mesh *mesh) : m_mesh(mesh), m_groups(MemTag::Mesh), m_firstFace(MemTag::Mesh), m_nextFace(MemTag::Mesh), m_faceCount(MemTag::Mesh) {} XA_INLINE Handle groupAt(uint32_t face) const { return m_groups[face]; } XA_INLINE uint32_t groupCount() const { return m_faceCount.size(); } XA_INLINE uint32_t nextFace(uint32_t face) const { return m_nextFace[face]; } XA_INLINE uint32_t faceCount(uint32_t group) const { return m_faceCount[group]; } - void compute() { + void compute() + { m_groups.resize(m_mesh->faceCount()); m_groups.fillBytes(0xff); // Set all faces to kInvalid uint32_t firstUnassignedFace = 0; @@ -2767,23 +2923,27 @@ struct MeshFaceGroups { } } - class Iterator { + class Iterator + { public: - Iterator(const MeshFaceGroups *meshFaceGroups, Handle group) : - m_meshFaceGroups(meshFaceGroups) { + Iterator(const MeshFaceGroups *meshFaceGroups, Handle group) : m_meshFaceGroups(meshFaceGroups) + { XA_DEBUG_ASSERT(group != kInvalid); m_current = m_meshFaceGroups->m_firstFace[group]; } - void advance() { + void advance() + { m_current = m_meshFaceGroups->m_nextFace[m_current]; } - bool isDone() const { + bool isDone() const + { return m_current == UINT32_MAX; } - uint32_t face() const { + uint32_t face() const + { return m_current; } @@ -2803,7 +2963,8 @@ private: constexpr MeshFaceGroups::Handle MeshFaceGroups::kInvalid; #if XA_CHECK_T_JUNCTIONS -static bool lineIntersectsPoint(const Vector3 &point, const Vector3 &lineStart, const Vector3 &lineEnd, float *t, float epsilon) { +static bool lineIntersectsPoint(const Vector3 &point, const Vector3 &lineStart, const Vector3 &lineEnd, float *t, float epsilon) +{ float tt; if (!t) t = &tt; @@ -2821,7 +2982,8 @@ static bool lineIntersectsPoint(const Vector3 &point, const Vector3 &lineStart, } // Returns the number of T-junctions found. -static int meshCheckTJunctions(const Mesh &inputMesh) { +static int meshCheckTJunctions(const Mesh &inputMesh) +{ int count = 0; const uint32_t vertexCount = inputMesh.vertexCount(); const uint32_t edgeCount = inputMesh.edgeCount(); @@ -2845,10 +3007,12 @@ static int meshCheckTJunctions(const Mesh &inputMesh) { #endif // References invalid faces and vertices in a mesh. -struct InvalidMeshGeometry { +struct InvalidMeshGeometry +{ // If meshFaceGroups is not null, invalid faces have the face group MeshFaceGroups::kInvalid. // If meshFaceGroups is null, invalid faces are Mesh::isFaceIgnored. - void extract(const Mesh *mesh, const MeshFaceGroups *meshFaceGroups) { + void extract(const Mesh *mesh, const MeshFaceGroups *meshFaceGroups) + { // Copy invalid faces. m_faces.clear(); const uint32_t meshFaceCount = mesh->faceCount(); @@ -2886,28 +3050,32 @@ private: Array<uint32_t> m_vertexToSourceVertexMap; // Map face vertices to vertices of the source mesh. }; -struct Progress { - Progress(ProgressCategory category, ProgressFunc func, void *userData, uint32_t maxValue) : - cancel(false), m_category(category), m_func(func), m_userData(userData), m_value(0), m_maxValue(maxValue), m_percent(0) { +struct Progress +{ + Progress(ProgressCategory category, ProgressFunc func, void *userData, uint32_t maxValue) : cancel(false), m_category(category), m_func(func), m_userData(userData), m_value(0), m_maxValue(maxValue), m_percent(0) + { if (m_func) { if (!m_func(category, 0, userData)) cancel = true; } } - ~Progress() { + ~Progress() + { if (m_func) { if (!m_func(m_category, 100, m_userData)) cancel = true; } } - void increment(uint32_t value) { + void increment(uint32_t value) + { m_value += value; update(); } - void setMaxValue(uint32_t maxValue) { + void setMaxValue(uint32_t maxValue) + { m_maxValue = maxValue; update(); } @@ -2915,15 +3083,15 @@ struct Progress { std::atomic<bool> cancel; private: - void update() { + void update() + { if (!m_func) return; const uint32_t newPercent = uint32_t(ceilf(m_value.load() / (float)m_maxValue.load() * 100.0f)); if (newPercent != m_percent) { // Atomic max. uint32_t oldPercent = m_percent; - while (oldPercent < newPercent && !m_percent.compare_exchange_weak(oldPercent, newPercent)) { - } + while (oldPercent < newPercent && !m_percent.compare_exchange_weak(oldPercent, newPercent)) {} if (!m_func(m_category, m_percent, m_userData)) cancel = true; } @@ -2935,31 +3103,32 @@ private: std::atomic<uint32_t> m_value, m_maxValue, m_percent; }; -struct Spinlock { - void lock() { - while (m_lock.test_and_set(std::memory_order_acquire)) { - } - } +struct Spinlock +{ + void lock() { while(m_lock.test_and_set(std::memory_order_acquire)) {} } void unlock() { m_lock.clear(std::memory_order_release); } private: std::atomic_flag m_lock = ATOMIC_FLAG_INIT; }; -struct TaskGroupHandle { +struct TaskGroupHandle +{ uint32_t value = UINT32_MAX; }; -struct Task { +struct Task +{ void (*func)(void *groupUserData, void *taskUserData); void *userData; // Passed to func as taskUserData. }; #if XA_MULTITHREADED -class TaskScheduler { +class TaskScheduler +{ public: - TaskScheduler() : - m_shutdown(false) { + TaskScheduler() : m_shutdown(false) + { m_threadIndex = 0; // Max with current task scheduler usage is 1 per thread + 1 deep nesting, but allow for some slop. m_maxGroups = std::thread::hardware_concurrency() * 4; @@ -2978,7 +3147,8 @@ public: } } - ~TaskScheduler() { + ~TaskScheduler() + { m_shutdown = true; for (uint32_t i = 0; i < m_workers.size(); i++) { Worker &worker = m_workers[i]; @@ -2996,12 +3166,14 @@ public: XA_FREE(m_groups); } - uint32_t threadCount() const { + uint32_t threadCount() const + { return max(1u, std::thread::hardware_concurrency()); // Including the main thread. } // userData is passed to Task::func as groupUserData. - TaskGroupHandle createTaskGroup(void *userData = nullptr, uint32_t reserveSize = 0) { + TaskGroupHandle createTaskGroup(void *userData = nullptr, uint32_t reserveSize = 0) + { // Claim the first free group. for (uint32_t i = 0; i < m_maxGroups; i++) { TaskGroup &group = m_groups[i]; @@ -3025,7 +3197,8 @@ public: return handle; } - void run(TaskGroupHandle handle, const Task &task) { + void run(TaskGroupHandle handle, const Task &task) + { XA_DEBUG_ASSERT(handle.value != UINT32_MAX); TaskGroup &group = m_groups[handle.value]; group.queueLock.lock(); @@ -3039,7 +3212,8 @@ public: } } - void wait(TaskGroupHandle *handle) { + void wait(TaskGroupHandle *handle) + { if (handle->value == UINT32_MAX) { XA_DEBUG_ASSERT(false); return; @@ -3067,7 +3241,8 @@ public: static uint32_t currentThreadIndex() { return m_threadIndex; } private: - struct TaskGroup { + struct TaskGroup + { std::atomic<bool> free; Array<Task> queue; // Items are never removed. queueHead is incremented to pop items. uint32_t queueHead = 0; @@ -3076,7 +3251,8 @@ private: void *userData; }; - struct Worker { + struct Worker + { std::thread *thread = nullptr; std::mutex mutex; std::condition_variable cv; @@ -3089,11 +3265,12 @@ private: uint32_t m_maxGroups; static thread_local uint32_t m_threadIndex; - static void workerThread(TaskScheduler *scheduler, Worker *worker, uint32_t threadIndex) { + static void workerThread(TaskScheduler *scheduler, Worker *worker, uint32_t threadIndex) + { m_threadIndex = threadIndex; std::unique_lock<std::mutex> lock(worker->mutex); for (;;) { - worker->cv.wait(lock, [=] { return worker->wakeup.load(); }); + worker->cv.wait(lock, [=]{ return worker->wakeup.load(); }); worker->wakeup = false; for (;;) { if (scheduler->m_shutdown) @@ -3124,18 +3301,22 @@ private: thread_local uint32_t TaskScheduler::m_threadIndex; #else -class TaskScheduler { +class TaskScheduler +{ public: - ~TaskScheduler() { + ~TaskScheduler() + { for (uint32_t i = 0; i < m_groups.size(); i++) destroyGroup({ i }); } - uint32_t threadCount() const { + uint32_t threadCount() const + { return 1; } - TaskGroupHandle createTaskGroup(void *userData = nullptr, uint32_t reserveSize = 0) { + TaskGroupHandle createTaskGroup(void *userData = nullptr, uint32_t reserveSize = 0) + { TaskGroup *group = XA_NEW(MemTag::Default, TaskGroup); group->queue.reserve(reserveSize); group->userData = userData; @@ -3145,11 +3326,13 @@ public: return handle; } - void run(TaskGroupHandle handle, Task task) { + void run(TaskGroupHandle handle, Task task) + { m_groups[handle.value]->queue.push_back(task); } - void wait(TaskGroupHandle *handle) { + void wait(TaskGroupHandle *handle) + { if (handle->value == UINT32_MAX) { XA_DEBUG_ASSERT(false); return; @@ -3165,7 +3348,8 @@ public: static uint32_t currentThreadIndex() { return 0; } private: - void destroyGroup(TaskGroupHandle handle) { + void destroyGroup(TaskGroupHandle handle) + { TaskGroup *group = m_groups[handle.value]; if (group) { group->~TaskGroup(); @@ -3174,7 +3358,8 @@ private: } } - struct TaskGroup { + struct TaskGroup + { Array<Task> queue; void *userData; }; @@ -3188,7 +3373,8 @@ const uint8_t TGA_TYPE_RGB = 2; const uint8_t TGA_ORIGIN_UPPER = 0x20; #pragma pack(push, 1) -struct TgaHeader { +struct TgaHeader +{ uint8_t id_length; uint8_t colormap_type; uint8_t image_type; @@ -3205,7 +3391,8 @@ struct TgaHeader { }; #pragma pack(pop) -static void WriteTga(const char *filename, const uint8_t *data, uint32_t width, uint32_t height) { +static void WriteTga(const char *filename, const uint8_t *data, uint32_t width, uint32_t height) +{ XA_DEBUG_ASSERT(sizeof(TgaHeader) == TgaHeader::Size); FILE *f; XA_FOPEN(f, filename, "wb"); @@ -3230,10 +3417,12 @@ static void WriteTga(const char *filename, const uint8_t *data, uint32_t width, } #endif -template <typename T> -class ThreadLocal { +template<typename T> +class ThreadLocal +{ public: - ThreadLocal() { + ThreadLocal() + { #if XA_MULTITHREADED const uint32_t n = std::thread::hardware_concurrency(); #else @@ -3244,7 +3433,8 @@ public: new (&m_array[i]) T; } - ~ThreadLocal() { + ~ThreadLocal() + { #if XA_MULTITHREADED const uint32_t n = std::thread::hardware_concurrency(); #else @@ -3255,7 +3445,8 @@ public: XA_FREE(m_array); } - T &get() const { + T &get() const + { return m_array[TaskScheduler::currentThreadIndex()]; } @@ -3264,10 +3455,12 @@ private: }; // Implemented as a struct so the temporary arrays can be reused. -struct Triangulator { +struct Triangulator +{ // This is doing a simple ear-clipping algorithm that skips invalid triangles. Ideally, we should // also sort the ears by angle, start with the ones that have the smallest angle and proceed in order. - void triangulatePolygon(ConstArrayView<Vector3> vertices, ConstArrayView<uint32_t> inputIndices, Array<uint32_t> &outputIndices) { + void triangulatePolygon(ConstArrayView<Vector3> vertices, ConstArrayView<uint32_t> inputIndices, Array<uint32_t> &outputIndices) + { m_polygonVertices.clear(); m_polygonVertices.reserve(inputIndices.length); outputIndices.clear(); @@ -3276,7 +3469,8 @@ struct Triangulator { outputIndices.push_back(inputIndices[0]); outputIndices.push_back(inputIndices[1]); outputIndices.push_back(inputIndices[2]); - } else { + } + else { // Build 2D polygon projecting vertices onto normal plane. // Faces are not necesarily planar, this is for example the case, when the face comes from filling a hole. In such cases // it's much better to use the best fit plane. @@ -3348,7 +3542,8 @@ struct Triangulator { } private: - static bool pointInTriangle(const Vector2 &p, const Vector2 &a, const Vector2 &b, const Vector2 &c) { + static bool pointInTriangle(const Vector2 &p, const Vector2 &a, const Vector2 &b, const Vector2 &c) + { return triangleArea(a, b, p) >= kAreaEpsilon && triangleArea(b, c, p) >= kAreaEpsilon && triangleArea(c, a, p) >= kAreaEpsilon; } @@ -3357,10 +3552,12 @@ private: Array<Vector2> m_polygonPoints; }; -class UniformGrid2 { +class UniformGrid2 +{ public: // indices are optional. - void reset(ConstArrayView<Vector2> positions, ConstArrayView<uint32_t> indices = ConstArrayView<uint32_t>(), uint32_t reserveEdgeCount = 0) { + void reset(ConstArrayView<Vector2> positions, ConstArrayView<uint32_t> indices = ConstArrayView<uint32_t>(), uint32_t reserveEdgeCount = 0) + { m_edges.clear(); if (reserveEdgeCount > 0) m_edges.reserve(reserveEdgeCount); @@ -3369,12 +3566,14 @@ public: m_cellDataOffsets.clear(); } - void append(uint32_t edge) { + void append(uint32_t edge) + { XA_DEBUG_ASSERT(m_cellDataOffsets.isEmpty()); m_edges.push_back(edge); } - bool intersect(Vector2 v1, Vector2 v2, float epsilon) { + bool intersect(Vector2 v1, Vector2 v2, float epsilon) + { const uint32_t edgeCount = m_edges.size(); bool bruteForce = edgeCount <= 20; if (!bruteForce && m_cellDataOffsets.isEmpty()) @@ -3401,7 +3600,8 @@ public: } // If edges is empty, checks for intersection with all edges in the grid. - bool intersect(float epsilon, ConstArrayView<uint32_t> edges = ConstArrayView<uint32_t>(), ConstArrayView<uint32_t> ignoreEdges = ConstArrayView<uint32_t>()) { + bool intersect(float epsilon, ConstArrayView<uint32_t> edges = ConstArrayView<uint32_t>(), ConstArrayView<uint32_t> ignoreEdges = ConstArrayView<uint32_t>()) + { bool bruteForce = m_edges.size() <= 20; if (!bruteForce && m_cellDataOffsets.isEmpty()) bruteForce = !createGrid(); @@ -3471,7 +3671,8 @@ public: } #if XA_DEBUG_EXPORT_BOUNDARY_GRID - void debugExport(const char *filename) { + void debugExport(const char *filename) + { Array<uint8_t> image; image.resize(m_gridWidth * m_gridHeight * 3); for (uint32_t y = 0; y < m_gridHeight; y++) { @@ -3493,7 +3694,8 @@ public: #endif private: - bool createGrid() { + bool createGrid() + { // Compute edge extents. Min will be the grid origin. const uint32_t edgeCount = m_edges.size(); Extents2 edgeExtents; @@ -3545,7 +3747,8 @@ private: return true; } - void computePotentialEdges(Vector2 p1, Vector2 p2) { + void computePotentialEdges(Vector2 p1, Vector2 p2) + { m_potentialEdges.clear(); traverse(p1, p2); for (uint32_t j = 0; j < m_traversedCellOffsets.size(); j++) { @@ -3563,7 +3766,8 @@ private: } // "A Fast Voxel Traversal Algorithm for Ray Tracing" - void traverse(Vector2 p1, Vector2 p2) { + void traverse(Vector2 p1, Vector2 p2) + { const Vector2 dir = p2 - p1; const Vector2 normal = normalizeSafe(dir, Vector2(0.0f)); const int stepX = dir.x >= 0 ? 1 : -1; @@ -3584,12 +3788,14 @@ private: if (normal.x > kEpsilon || normal.x < -kEpsilon) { tMaxX = (distToNextCellX * stepX) / normal.x; tDeltaX = (m_cellSize * stepX) / normal.x; - } else + } + else tMaxX = tDeltaX = FLT_MAX; if (normal.y > kEpsilon || normal.y < -kEpsilon) { tMaxY = (distToNextCellY * stepY) / normal.y; tDeltaY = (m_cellSize * stepY) / normal.y; - } else + } + else tMaxY = tDeltaY = FLT_MAX; m_traversedCellOffsets.clear(); m_traversedCellOffsets.push_back(firstCell[0] + firstCell[1] * m_gridWidth); @@ -3616,23 +3822,28 @@ private: } } - uint32_t cellX(float x) const { + uint32_t cellX(float x) const + { return min((uint32_t)max(0.0f, (x - m_gridOrigin.x) / m_cellSize), m_gridWidth - 1u); } - uint32_t cellY(float y) const { + uint32_t cellY(float y) const + { return min((uint32_t)max(0.0f, (y - m_gridOrigin.y) / m_cellSize), m_gridHeight - 1u); } - Vector2 edgePosition0(uint32_t edge) const { + Vector2 edgePosition0(uint32_t edge) const + { return m_positions[vertexAt(meshEdgeIndex0(edge))]; } - Vector2 edgePosition1(uint32_t edge) const { + Vector2 edgePosition1(uint32_t edge) const + { return m_positions[vertexAt(meshEdgeIndex1(edge))]; } - uint32_t vertexAt(uint32_t index) const { + uint32_t vertexAt(uint32_t index) const + { return m_indices.length > 0 ? m_indices[index] : index; } @@ -3648,13 +3859,15 @@ private: Array<uint32_t> m_traversedCellOffsets; }; -struct UvMeshChart { +struct UvMeshChart +{ Array<uint32_t> faces; Array<uint32_t> indices; uint32_t material; }; -struct UvMesh { +struct UvMesh +{ UvMeshDecl decl; BitArray faceIgnore; Array<uint32_t> faceMaterials; @@ -3664,7 +3877,8 @@ struct UvMesh { Array<uint32_t> vertexToChartMap; }; -struct UvMeshInstance { +struct UvMeshInstance +{ UvMesh *mesh; Array<Vector2> texcoords; }; @@ -3712,30 +3926,27 @@ struct UvMeshInstance { * FRANCE */ namespace opennl { -#define NL_NEW(T) XA_ALLOC(MemTag::OpenNL, T) -#define NL_NEW_ARRAY(T, NB) XA_ALLOC_ARRAY(MemTag::OpenNL, T, NB) -#define NL_RENEW_ARRAY(T, x, NB) XA_REALLOC(MemTag::OpenNL, x, T, NB) -#define NL_DELETE(x) \ - XA_FREE(x); \ - x = nullptr -#define NL_DELETE_ARRAY(x) \ - XA_FREE(x); \ - x = nullptr -#define NL_CLEAR(x, T) memset(x, 0, sizeof(T)); -#define NL_CLEAR_ARRAY(T, x, NB) memset(x, 0, (size_t)(NB) * sizeof(T)) -#define NL_NEW_VECTOR(dim) XA_ALLOC_ARRAY(MemTag::OpenNL, double, dim) -#define NL_DELETE_VECTOR(ptr) XA_FREE(ptr) +#define NL_NEW(T) XA_ALLOC(MemTag::OpenNL, T) +#define NL_NEW_ARRAY(T,NB) XA_ALLOC_ARRAY(MemTag::OpenNL, T, NB) +#define NL_RENEW_ARRAY(T,x,NB) XA_REALLOC(MemTag::OpenNL, x, T, NB) +#define NL_DELETE(x) XA_FREE(x); x = nullptr +#define NL_DELETE_ARRAY(x) XA_FREE(x); x = nullptr +#define NL_CLEAR(x, T) memset(x, 0, sizeof(T)); +#define NL_CLEAR_ARRAY(T,x,NB) memset(x, 0, (size_t)(NB)*sizeof(T)) +#define NL_NEW_VECTOR(dim) XA_ALLOC_ARRAY(MemTag::OpenNL, double, dim) +#define NL_DELETE_VECTOR(ptr) XA_FREE(ptr) struct NLMatrixStruct; -typedef NLMatrixStruct *NLMatrix; +typedef NLMatrixStruct * NLMatrix; typedef void (*NLDestroyMatrixFunc)(NLMatrix M); -typedef void (*NLMultMatrixVectorFunc)(NLMatrix M, const double *x, double *y); +typedef void (*NLMultMatrixVectorFunc)(NLMatrix M, const double* x, double* y); #define NL_MATRIX_SPARSE_DYNAMIC 0x1001 -#define NL_MATRIX_CRS 0x1002 -#define NL_MATRIX_OTHER 0x1006 +#define NL_MATRIX_CRS 0x1002 +#define NL_MATRIX_OTHER 0x1006 -struct NLMatrixStruct { +struct NLMatrixStruct +{ uint32_t m; uint32_t n; uint32_t type; @@ -3745,35 +3956,39 @@ struct NLMatrixStruct { /* Dynamic arrays for sparse row/columns */ -struct NLCoeff { +struct NLCoeff +{ uint32_t index; double value; }; -struct NLRowColumn { +struct NLRowColumn +{ uint32_t size; uint32_t capacity; - NLCoeff *coeff; + NLCoeff* coeff; }; /* Compressed Row Storage */ -struct NLCRSMatrix { +struct NLCRSMatrix +{ uint32_t m; uint32_t n; uint32_t type; NLDestroyMatrixFunc destroy_func; NLMultMatrixVectorFunc mult_func; - double *val; - uint32_t *rowptr; - uint32_t *colind; + double* val; + uint32_t* rowptr; + uint32_t* colind; uint32_t nslices; - uint32_t *sliceptr; + uint32_t* sliceptr; }; /* SparseMatrix data structure */ -struct NLSparseMatrix { +struct NLSparseMatrix +{ uint32_t m; uint32_t n; uint32_t type; @@ -3781,23 +3996,25 @@ struct NLSparseMatrix { NLMultMatrixVectorFunc mult_func; uint32_t diag_size; uint32_t diag_capacity; - NLRowColumn *row; - NLRowColumn *column; - double *diag; + NLRowColumn* row; + NLRowColumn* column; + double* diag; uint32_t row_capacity; uint32_t column_capacity; }; /* NLContext data structure */ -struct NLBufferBinding { - void *base_address; +struct NLBufferBinding +{ + void* base_address; uint32_t stride; }; -#define NL_BUFFER_ITEM(B, i) *(double *)((void *)((char *)((B).base_address) + ((i) * (B).stride))) +#define NL_BUFFER_ITEM(B,i) *(double*)((void*)((char*)((B).base_address)+((i)*(B).stride))) -struct NLContext { +struct NLContext +{ NLBufferBinding *variable_buffer; double *variable_value; bool *variable_is_locked; @@ -3821,30 +4038,35 @@ struct NLContext { double error; }; -static void nlDeleteMatrix(NLMatrix M) { +static void nlDeleteMatrix(NLMatrix M) +{ if (!M) return; M->destroy_func(M); NL_DELETE(M); } -static void nlMultMatrixVector(NLMatrix M, const double *x, double *y) { +static void nlMultMatrixVector(NLMatrix M, const double* x, double* y) +{ M->mult_func(M, x, y); } -static void nlRowColumnConstruct(NLRowColumn *c) { +static void nlRowColumnConstruct(NLRowColumn* c) +{ c->size = 0; c->capacity = 0; c->coeff = nullptr; } -static void nlRowColumnDestroy(NLRowColumn *c) { +static void nlRowColumnDestroy(NLRowColumn* c) +{ NL_DELETE_ARRAY(c->coeff); c->size = 0; c->capacity = 0; } -static void nlRowColumnGrow(NLRowColumn *c) { +static void nlRowColumnGrow(NLRowColumn* c) +{ if (c->capacity != 0) { c->capacity = 2 * c->capacity; c->coeff = NL_RENEW_ARRAY(NLCoeff, c->coeff, c->capacity); @@ -3855,7 +4077,8 @@ static void nlRowColumnGrow(NLRowColumn *c) { } } -static void nlRowColumnAdd(NLRowColumn *c, uint32_t index, double value) { +static void nlRowColumnAdd(NLRowColumn* c, uint32_t index, double value) +{ for (uint32_t i = 0; i < c->size; i++) { if (c->coeff[i].index == index) { c->coeff[i].value += value; @@ -3870,7 +4093,8 @@ static void nlRowColumnAdd(NLRowColumn *c, uint32_t index, double value) { } /* Does not check whether the index already exists */ -static void nlRowColumnAppend(NLRowColumn *c, uint32_t index, double value) { +static void nlRowColumnAppend(NLRowColumn* c, uint32_t index, double value) +{ if (c->size == c->capacity) nlRowColumnGrow(c); c->coeff[c->size].index = index; @@ -3878,27 +4102,32 @@ static void nlRowColumnAppend(NLRowColumn *c, uint32_t index, double value) { c->size++; } -static void nlRowColumnZero(NLRowColumn *c) { +static void nlRowColumnZero(NLRowColumn* c) +{ c->size = 0; } -static void nlRowColumnClear(NLRowColumn *c) { +static void nlRowColumnClear(NLRowColumn* c) +{ c->size = 0; c->capacity = 0; NL_DELETE_ARRAY(c->coeff); } -static int nlCoeffCompare(const void *p1, const void *p2) { - return (((NLCoeff *)(p2))->index < ((NLCoeff *)(p1))->index); +static int nlCoeffCompare(const void* p1, const void* p2) +{ + return (((NLCoeff*)(p2))->index < ((NLCoeff*)(p1))->index); } -static void nlRowColumnSort(NLRowColumn *c) { +static void nlRowColumnSort(NLRowColumn* c) +{ qsort(c->coeff, c->size, sizeof(NLCoeff), nlCoeffCompare); } /* CRSMatrix data structure */ -static void nlCRSMatrixDestroy(NLCRSMatrix *M) { +static void nlCRSMatrixDestroy(NLCRSMatrix* M) +{ NL_DELETE_ARRAY(M->val); NL_DELETE_ARRAY(M->rowptr); NL_DELETE_ARRAY(M->colind); @@ -3908,7 +4137,8 @@ static void nlCRSMatrixDestroy(NLCRSMatrix *M) { M->nslices = 0; } -static void nlCRSMatrixMultSlice(NLCRSMatrix *M, const double *x, double *y, uint32_t Ibegin, uint32_t Iend) { +static void nlCRSMatrixMultSlice(NLCRSMatrix* M, const double* x, double* y, uint32_t Ibegin, uint32_t Iend) +{ for (uint32_t i = Ibegin; i < Iend; ++i) { double sum = 0.0; for (uint32_t j = M->rowptr[i]; j < M->rowptr[i + 1]; ++j) @@ -3917,13 +4147,15 @@ static void nlCRSMatrixMultSlice(NLCRSMatrix *M, const double *x, double *y, uin } } -static void nlCRSMatrixMult(NLCRSMatrix *M, const double *x, double *y) { +static void nlCRSMatrixMult(NLCRSMatrix* M, const double* x, double* y) +{ int nslices = (int)(M->nslices); for (int slice = 0; slice < nslices; ++slice) nlCRSMatrixMultSlice(M, x, y, M->sliceptr[slice], M->sliceptr[slice + 1]); } -static void nlCRSMatrixConstruct(NLCRSMatrix *M, uint32_t m, uint32_t n, uint32_t nnz, uint32_t nslices) { +static void nlCRSMatrixConstruct(NLCRSMatrix* M, uint32_t m, uint32_t n, uint32_t nnz, uint32_t nslices) +{ M->m = m; M->n = n; M->type = NL_MATRIX_CRS; @@ -3942,19 +4174,22 @@ static void nlCRSMatrixConstruct(NLCRSMatrix *M, uint32_t m, uint32_t n, uint32_ /* SparseMatrix data structure */ -static void nlSparseMatrixDestroyRowColumns(NLSparseMatrix *M) { +static void nlSparseMatrixDestroyRowColumns(NLSparseMatrix* M) +{ for (uint32_t i = 0; i < M->m; i++) nlRowColumnDestroy(&(M->row[i])); NL_DELETE_ARRAY(M->row); } -static void nlSparseMatrixDestroy(NLSparseMatrix *M) { +static void nlSparseMatrixDestroy(NLSparseMatrix* M) +{ XA_DEBUG_ASSERT(M->type == NL_MATRIX_SPARSE_DYNAMIC); nlSparseMatrixDestroyRowColumns(M); NL_DELETE_ARRAY(M->diag); } -static void nlSparseMatrixAdd(NLSparseMatrix *M, uint32_t i, uint32_t j, double value) { +static void nlSparseMatrixAdd(NLSparseMatrix* M, uint32_t i, uint32_t j, double value) +{ XA_DEBUG_ASSERT(i >= 0 && i <= M->m - 1); XA_DEBUG_ASSERT(j >= 0 && j <= M->n - 1); if (i == j) @@ -3963,21 +4198,24 @@ static void nlSparseMatrixAdd(NLSparseMatrix *M, uint32_t i, uint32_t j, double } /* Returns the number of non-zero coefficients */ -static uint32_t nlSparseMatrixNNZ(NLSparseMatrix *M) { +static uint32_t nlSparseMatrixNNZ(NLSparseMatrix* M) +{ uint32_t nnz = 0; for (uint32_t i = 0; i < M->m; i++) nnz += M->row[i].size; return nnz; } -static void nlSparseMatrixSort(NLSparseMatrix *M) { +static void nlSparseMatrixSort(NLSparseMatrix* M) +{ for (uint32_t i = 0; i < M->m; i++) nlRowColumnSort(&(M->row[i])); } /* SparseMatrix x Vector routines, internal helper routines */ -static void nlSparseMatrix_mult_rows(NLSparseMatrix *A, const double *x, double *y) { +static void nlSparseMatrix_mult_rows(NLSparseMatrix* A, const double* x, double* y) +{ /* * Note: OpenMP does not like unsigned ints * (causes some floating point exceptions), @@ -3985,8 +4223,8 @@ static void nlSparseMatrix_mult_rows(NLSparseMatrix *A, const double *x, double * indices. */ int m = (int)(A->m); - NLCoeff *c = nullptr; - NLRowColumn *Ri = nullptr; + NLCoeff* c = nullptr; + NLRowColumn* Ri = nullptr; for (int i = 0; i < m; i++) { Ri = &(A->row[i]); y[i] = 0; @@ -3997,12 +4235,14 @@ static void nlSparseMatrix_mult_rows(NLSparseMatrix *A, const double *x, double } } -static void nlSparseMatrixMult(NLSparseMatrix *A, const double *x, double *y) { +static void nlSparseMatrixMult(NLSparseMatrix* A, const double* x, double* y) +{ XA_DEBUG_ASSERT(A->type == NL_MATRIX_SPARSE_DYNAMIC); nlSparseMatrix_mult_rows(A, x, y); } -static void nlSparseMatrixConstruct(NLSparseMatrix *M, uint32_t m, uint32_t n) { +static void nlSparseMatrixConstruct(NLSparseMatrix* M, uint32_t m, uint32_t n) +{ M->m = m; M->n = n; M->type = NL_MATRIX_SPARSE_DYNAMIC; @@ -4022,23 +4262,24 @@ static void nlSparseMatrixConstruct(NLSparseMatrix *M, uint32_t m, uint32_t n) { NL_CLEAR_ARRAY(double, M->diag, M->diag_size); } -static NLMatrix nlCRSMatrixNewFromSparseMatrix(NLSparseMatrix *M) { +static NLMatrix nlCRSMatrixNewFromSparseMatrix(NLSparseMatrix* M) +{ uint32_t nnz = nlSparseMatrixNNZ(M); uint32_t nslices = 8; /* TODO: get number of cores */ uint32_t slice, cur_bound, cur_NNZ, cur_row; uint32_t k; uint32_t slice_size = nnz / nslices; - NLCRSMatrix *CRS = NL_NEW(NLCRSMatrix); + NLCRSMatrix* CRS = NL_NEW(NLCRSMatrix); NL_CLEAR(CRS, NLCRSMatrix); nlCRSMatrixConstruct(CRS, M->m, M->n, nnz, nslices); nlSparseMatrixSort(M); /* Convert matrix to CRS format */ k = 0; for (uint32_t i = 0; i < M->m; ++i) { - NLRowColumn *Ri = &(M->row[i]); + NLRowColumn* Ri = &(M->row[i]); CRS->rowptr[i] = k; for (uint32_t ij = 0; ij < Ri->size; ij++) { - NLCoeff *c = &(Ri->coeff[ij]); + NLCoeff* c = &(Ri->coeff[ij]); CRS->val[k] = c->value; CRS->colind[k] = c->index; ++k; @@ -4053,8 +4294,8 @@ static NLMatrix nlCRSMatrixNewFromSparseMatrix(NLSparseMatrix *M) { CRS->sliceptr[0] = 0; for (slice = 1; slice < nslices; ++slice) { while (cur_NNZ < cur_bound && cur_row < M->m) { - ++cur_row; cur_NNZ += CRS->rowptr[cur_row + 1] - CRS->rowptr[cur_row]; + ++cur_row; } CRS->sliceptr[slice] = cur_row; cur_bound += slice_size; @@ -4064,17 +4305,19 @@ static NLMatrix nlCRSMatrixNewFromSparseMatrix(NLSparseMatrix *M) { return (NLMatrix)CRS; } -static void nlMatrixCompress(NLMatrix *M) { +static void nlMatrixCompress(NLMatrix* M) +{ NLMatrix CRS = nullptr; if ((*M)->type != NL_MATRIX_SPARSE_DYNAMIC) return; - CRS = nlCRSMatrixNewFromSparseMatrix((NLSparseMatrix *)*M); + CRS = nlCRSMatrixNewFromSparseMatrix((NLSparseMatrix*)*M); nlDeleteMatrix(*M); *M = CRS; } -static NLContext *nlNewContext() { - NLContext *result = NL_NEW(NLContext); +static NLContext *nlNewContext() +{ + NLContext* result = NL_NEW(NLContext); NL_CLEAR(result, NLContext); result->max_iterations = 100; result->threshold = 1e-6; @@ -4083,7 +4326,8 @@ static NLContext *nlNewContext() { return result; } -static void nlDeleteContext(NLContext *context) { +static void nlDeleteContext(NLContext *context) +{ nlDeleteMatrix(context->M); context->M = nullptr; nlDeleteMatrix(context->P); @@ -4101,19 +4345,22 @@ static void nlDeleteContext(NLContext *context) { NL_DELETE(context); } -static double ddot(int n, const double *x, const double *y) { +static double ddot(int n, const double *x, const double *y) +{ double sum = 0.0; for (int i = 0; i < n; i++) sum += x[i] * y[i]; return sum; } -static void daxpy(int n, double a, const double *x, double *y) { +static void daxpy(int n, double a, const double *x, double *y) +{ for (int i = 0; i < n; i++) y[i] = a * x[i] + y[i]; } -static void dscal(int n, double a, double *x) { +static void dscal(int n, double a, double *x) +{ for (int i = 0; i < n; i++) x[i] *= a; } @@ -4136,16 +4383,17 @@ static void dscal(int n, double a, double *x) { * versions of matrix x vector product (CPU/GPU, sparse/dense ...) */ -static uint32_t nlSolveSystem_PRE_CG(NLMatrix M, NLMatrix P, double *b, double *x, double eps, uint32_t max_iter, double *sq_bnorm, double *sq_rnorm) { - int N = (int)M->n; - double *r = NL_NEW_VECTOR(N); - double *d = NL_NEW_VECTOR(N); - double *h = NL_NEW_VECTOR(N); +static uint32_t nlSolveSystem_PRE_CG(NLMatrix M, NLMatrix P, double* b, double* x, double eps, uint32_t max_iter, double *sq_bnorm, double *sq_rnorm) +{ + int N = (int)M->n; + double* r = NL_NEW_VECTOR(N); + double* d = NL_NEW_VECTOR(N); + double* h = NL_NEW_VECTOR(N); double *Ad = h; uint32_t its = 0; double rh, alpha, beta; double b_square = ddot(N, b, b); - double err = eps * eps * b_square; + double err = eps * eps*b_square; double curr_err; nlMultMatrixVector(M, x, r); daxpy(N, -1., b, r); @@ -4175,12 +4423,13 @@ static uint32_t nlSolveSystem_PRE_CG(NLMatrix M, NLMatrix P, double *b, double * return its; } -static uint32_t nlSolveSystemIterative(NLContext *context, NLMatrix M, NLMatrix P, double *b_in, double *x_in, double eps, uint32_t max_iter) { +static uint32_t nlSolveSystemIterative(NLContext *context, NLMatrix M, NLMatrix P, double* b_in, double* x_in, double eps, uint32_t max_iter) +{ uint32_t result = 0; double rnorm = 0.0; double bnorm = 0.0; - double *b = b_in; - double *x = x_in; + double* b = b_in; + double* x = x_in; XA_DEBUG_ASSERT(M->m == M->n); double sq_bnorm, sq_rnorm; result = nlSolveSystem_PRE_CG(M, P, b, x, eps, max_iter, &sq_bnorm, &sq_rnorm); @@ -4195,9 +4444,10 @@ static uint32_t nlSolveSystemIterative(NLContext *context, NLMatrix M, NLMatrix return result; } -static bool nlSolveIterative(NLContext *context) { - double *b = context->b; - double *x = context->x; +static bool nlSolveIterative(NLContext *context) +{ + double* b = context->b; + double* x = context->x; uint32_t n = context->n; NLMatrix M = context->M; NLMatrix P = context->P; @@ -4209,30 +4459,34 @@ static bool nlSolveIterative(NLContext *context) { return true; } -struct NLJacobiPreconditioner { +struct NLJacobiPreconditioner +{ uint32_t m; uint32_t n; uint32_t type; NLDestroyMatrixFunc destroy_func; NLMultMatrixVectorFunc mult_func; - double *diag_inv; + double* diag_inv; }; -static void nlJacobiPreconditionerDestroy(NLJacobiPreconditioner *M) { +static void nlJacobiPreconditionerDestroy(NLJacobiPreconditioner* M) +{ NL_DELETE_ARRAY(M->diag_inv); } -static void nlJacobiPreconditionerMult(NLJacobiPreconditioner *M, const double *x, double *y) { +static void nlJacobiPreconditionerMult(NLJacobiPreconditioner* M, const double* x, double* y) +{ for (uint32_t i = 0; i < M->n; ++i) y[i] = x[i] * M->diag_inv[i]; } -static NLMatrix nlNewJacobiPreconditioner(NLMatrix M_in) { - NLSparseMatrix *M = nullptr; - NLJacobiPreconditioner *result = nullptr; +static NLMatrix nlNewJacobiPreconditioner(NLMatrix M_in) +{ + NLSparseMatrix* M = nullptr; + NLJacobiPreconditioner* result = nullptr; XA_DEBUG_ASSERT(M_in->type == NL_MATRIX_SPARSE_DYNAMIC); XA_DEBUG_ASSERT(M_in->m == M_in->n); - M = (NLSparseMatrix *)M_in; + M = (NLSparseMatrix*)M_in; result = NL_NEW(NLJacobiPreconditioner); NL_CLEAR(result, NLJacobiPreconditioner); result->m = M->m; @@ -4250,7 +4504,8 @@ static NLMatrix nlNewJacobiPreconditioner(NLMatrix M_in) { #define NL_NB_VARIABLES 0x101 #define NL_MAX_ITERATIONS 0x103 -static void nlSolverParameteri(NLContext *context, uint32_t pname, int param) { +static void nlSolverParameteri(NLContext *context, uint32_t pname, int param) +{ if (pname == NL_NB_VARIABLES) { XA_DEBUG_ASSERT(param > 0); context->nb_variables = (uint32_t)param; @@ -4261,22 +4516,26 @@ static void nlSolverParameteri(NLContext *context, uint32_t pname, int param) { } } -static void nlSetVariable(NLContext *context, uint32_t index, double value) { +static void nlSetVariable(NLContext *context, uint32_t index, double value) +{ XA_DEBUG_ASSERT(index >= 0 && index <= context->nb_variables - 1); NL_BUFFER_ITEM(context->variable_buffer[0], index) = value; } -static double nlGetVariable(NLContext *context, uint32_t index) { +static double nlGetVariable(NLContext *context, uint32_t index) +{ XA_DEBUG_ASSERT(index >= 0 && index <= context->nb_variables - 1); return NL_BUFFER_ITEM(context->variable_buffer[0], index); } -static void nlLockVariable(NLContext *context, uint32_t index) { +static void nlLockVariable(NLContext *context, uint32_t index) +{ XA_DEBUG_ASSERT(index >= 0 && index <= context->nb_variables - 1); context->variable_is_locked[index] = true; } -static void nlVariablesToVector(NLContext *context) { +static void nlVariablesToVector(NLContext *context) +{ uint32_t n = context->n; XA_DEBUG_ASSERT(context->x); for (uint32_t k = 0; k < context->nb_systems; ++k) { @@ -4291,7 +4550,8 @@ static void nlVariablesToVector(NLContext *context) { } } -static void nlVectorToVariables(NLContext *context) { +static void nlVectorToVariables(NLContext *context) +{ uint32_t n = context->n; XA_DEBUG_ASSERT(context->x); for (uint32_t k = 0; k < context->nb_systems; ++k) { @@ -4306,7 +4566,8 @@ static void nlVectorToVariables(NLContext *context) { } } -static void nlCoefficient(NLContext *context, uint32_t index, double value) { +static void nlCoefficient(NLContext *context, uint32_t index, double value) +{ XA_DEBUG_ASSERT(index >= 0 && index <= context->nb_variables - 1); if (context->variable_is_locked[index]) { /* @@ -4323,11 +4584,12 @@ static void nlCoefficient(NLContext *context, uint32_t index, double value) { } } -#define NL_SYSTEM 0x0 -#define NL_MATRIX 0x1 -#define NL_ROW 0x2 +#define NL_SYSTEM 0x0 +#define NL_MATRIX 0x1 +#define NL_ROW 0x2 -static void nlBegin(NLContext *context, uint32_t prim) { +static void nlBegin(NLContext *context, uint32_t prim) +{ if (prim == NL_SYSTEM) { XA_DEBUG_ASSERT(context->nb_variables > 0); context->variable_buffer = NL_NEW_ARRAY(NLBufferBinding, context->nb_systems); @@ -4336,8 +4598,8 @@ static void nlBegin(NLContext *context, uint32_t prim) { NL_CLEAR_ARRAY(double, context->variable_value, context->nb_variables * context->nb_systems); for (uint32_t k = 0; k < context->nb_systems; ++k) { context->variable_buffer[k].base_address = - context->variable_value + - k * context->nb_variables; + context->variable_value + + k * context->nb_variables; context->variable_buffer[k].stride = sizeof(double); } context->variable_is_locked = NL_NEW_ARRAY(bool, context->nb_variables); @@ -4360,11 +4622,11 @@ static void nlBegin(NLContext *context, uint32_t prim) { context->max_iterations = n * 5; context->M = (NLMatrix)(NL_NEW(NLSparseMatrix)); NL_CLEAR(context->M, NLSparseMatrix); - nlSparseMatrixConstruct((NLSparseMatrix *)(context->M), n, n); - context->x = NL_NEW_ARRAY(double, n * context->nb_systems); - NL_CLEAR_ARRAY(double, context->x, n * context->nb_systems); - context->b = NL_NEW_ARRAY(double, n * context->nb_systems); - NL_CLEAR_ARRAY(double, context->b, n * context->nb_systems); + nlSparseMatrixConstruct((NLSparseMatrix*)(context->M), n, n); + context->x = NL_NEW_ARRAY(double, n*context->nb_systems); + NL_CLEAR_ARRAY(double, context->x, n*context->nb_systems); + context->b = NL_NEW_ARRAY(double, n*context->nb_systems); + NL_CLEAR_ARRAY(double, context->b, n*context->nb_systems); nlVariablesToVector(context); nlRowColumnConstruct(&context->af); nlRowColumnConstruct(&context->al); @@ -4375,15 +4637,16 @@ static void nlBegin(NLContext *context, uint32_t prim) { } } -static void nlEnd(NLContext *context, uint32_t prim) { +static void nlEnd(NLContext *context, uint32_t prim) +{ if (prim == NL_MATRIX) { nlRowColumnClear(&context->af); nlRowColumnClear(&context->al); } else if (prim == NL_ROW) { - NLRowColumn *af = &context->af; - NLRowColumn *al = &context->al; - NLSparseMatrix *M = (NLSparseMatrix *)context->M; - double *b = context->b; + NLRowColumn* af = &context->af; + NLRowColumn* al = &context->al; + NLSparseMatrix* M = (NLSparseMatrix*)context->M; + double* b = context->b; uint32_t nf = af->size; uint32_t nl = al->size; uint32_t n = context->n; @@ -4404,13 +4667,14 @@ static void nlEnd(NLContext *context, uint32_t prim) { S += al->coeff[jj].value * NL_BUFFER_ITEM(context->variable_buffer[k], j); } for (uint32_t jj = 0; jj < nf; jj++) - b[k * n + af->coeff[jj].index] -= af->coeff[jj].value * S; + b[k*n + af->coeff[jj].index] -= af->coeff[jj].value * S; } context->current_row++; } } -static bool nlSolve(NLContext *context) { +static bool nlSolve(NLContext *context) +{ nlDeleteMatrix(context->P); context->P = nlNewJacobiPreconditioner(context->M); nlMatrixCompress(&context->M); @@ -4421,9 +4685,11 @@ static bool nlSolve(NLContext *context) { } // namespace opennl namespace raster { -class ClippedTriangle { +class ClippedTriangle +{ public: - ClippedTriangle(const Vector2 &a, const Vector2 &b, const Vector2 &c) { + ClippedTriangle(const Vector2 &a, const Vector2 &b, const Vector2 &c) + { m_numVertices = 3; m_activeVertexBuffer = 0; m_verticesA[0] = a; @@ -4434,20 +4700,20 @@ public: m_area = 0; } - void clipHorizontalPlane(float offset, float clipdirection) { - Vector2 *v = m_vertexBuffers[m_activeVertexBuffer]; + void clipHorizontalPlane(float offset, float clipdirection) + { + Vector2 *v = m_vertexBuffers[m_activeVertexBuffer]; m_activeVertexBuffer ^= 1; Vector2 *v2 = m_vertexBuffers[m_activeVertexBuffer]; v[m_numVertices] = v[0]; - float dy2, dy1 = offset - v[0].y; - int dy2in, dy1in = clipdirection * dy1 >= 0; - uint32_t p = 0; + float dy2, dy1 = offset - v[0].y; + int dy2in, dy1in = clipdirection * dy1 >= 0; + uint32_t p = 0; for (uint32_t k = 0; k < m_numVertices; k++) { - dy2 = offset - v[k + 1].y; + dy2 = offset - v[k + 1].y; dy2in = clipdirection * dy2 >= 0; - if (dy1in) - v2[p++] = v[k]; - if (dy1in + dy2in == 1) { // not both in/out + if (dy1in) v2[p++] = v[k]; + if ( dy1in + dy2in == 1 ) { // not both in/out float dx = v[k + 1].x - v[k].x; float dy = v[k + 1].y - v[k].y; v2[p++] = Vector2(v[k].x + dy1 * (dx / dy), offset); @@ -4458,20 +4724,20 @@ public: m_numVertices = p; } - void clipVerticalPlane(float offset, float clipdirection) { - Vector2 *v = m_vertexBuffers[m_activeVertexBuffer]; + void clipVerticalPlane(float offset, float clipdirection) + { + Vector2 *v = m_vertexBuffers[m_activeVertexBuffer]; m_activeVertexBuffer ^= 1; Vector2 *v2 = m_vertexBuffers[m_activeVertexBuffer]; v[m_numVertices] = v[0]; - float dx2, dx1 = offset - v[0].x; - int dx2in, dx1in = clipdirection * dx1 >= 0; - uint32_t p = 0; + float dx2, dx1 = offset - v[0].x; + int dx2in, dx1in = clipdirection * dx1 >= 0; + uint32_t p = 0; for (uint32_t k = 0; k < m_numVertices; k++) { dx2 = offset - v[k + 1].x; dx2in = clipdirection * dx2 >= 0; - if (dx1in) - v2[p++] = v[k]; - if (dx1in + dx2in == 1) { // not both in/out + if (dx1in) v2[p++] = v[k]; + if ( dx1in + dx2in == 1 ) { // not both in/out float dx = v[k + 1].x - v[k].x; float dy = v[k + 1].y - v[k].y; v2[p++] = Vector2(offset, v[k].y + dx1 * (dy / dx)); @@ -4482,8 +4748,9 @@ public: m_numVertices = p; } - void computeArea() { - Vector2 *v = m_vertexBuffers[m_activeVertexBuffer]; + void computeArea() + { + Vector2 *v = m_vertexBuffers[m_activeVertexBuffer]; v[m_numVertices] = v[0]; m_area = 0; float centroidx = 0, centroidy = 0; @@ -4497,7 +4764,8 @@ public: m_area = 0.5f * fabsf(m_area); } - void clipAABox(float x0, float y0, float x1, float y1) { + void clipAABox(float x0, float y0, float x1, float y1) + { clipVerticalPlane(x0, -1); clipHorizontalPlane(y0, -1); clipVerticalPlane(x1, 1); @@ -4505,7 +4773,8 @@ public: computeArea(); } - float area() const { + float area() const + { return m_area; } @@ -4522,9 +4791,10 @@ private: typedef bool (*SamplingCallback)(void *param, int x, int y); /// A triangle for rasterization. -struct Triangle { - Triangle(const Vector2 &_v0, const Vector2 &_v1, const Vector2 &_v2) : - v1(_v0), v2(_v2), v3(_v1), n1(0.0f), n2(0.0f), n3(0.0f) { +struct Triangle +{ + Triangle(const Vector2 &_v0, const Vector2 &_v1, const Vector2 &_v2) : v1(_v0), v2(_v2), v3(_v1), n1(0.0f), n2(0.0f), n3(0.0f) + { // make sure every triangle is front facing. flipBackface(); // Compute deltas. @@ -4532,7 +4802,8 @@ struct Triangle { computeUnitInwardNormals(); } - bool isValid() { + bool isValid() + { const Vector2 e0 = v3 - v1; const Vector2 e1 = v2 - v1; const float area = e0.y * e1.x - e1.y * e0.x; @@ -4540,17 +4811,18 @@ struct Triangle { } // extents has to be multiple of BK_SIZE!! - bool drawAA(const Vector2 &extents, SamplingCallback cb, void *param) { - const float PX_INSIDE = 1.0f / sqrtf(2.0f); - const float PX_OUTSIDE = -1.0f / sqrtf(2.0f); + bool drawAA(const Vector2 &extents, SamplingCallback cb, void *param) + { + const float PX_INSIDE = 1.0f/sqrtf(2.0f); + const float PX_OUTSIDE = -1.0f/sqrtf(2.0f); const float BK_SIZE = 8; - const float BK_INSIDE = sqrtf(BK_SIZE * BK_SIZE / 2.0f); - const float BK_OUTSIDE = -sqrtf(BK_SIZE * BK_SIZE / 2.0f); + const float BK_INSIDE = sqrtf(BK_SIZE*BK_SIZE/2.0f); + const float BK_OUTSIDE = -sqrtf(BK_SIZE*BK_SIZE/2.0f); // Bounding rectangle float minx = floorf(max(min3(v1.x, v2.x, v3.x), 0.0f)); float miny = floorf(max(min3(v1.y, v2.y, v3.y), 0.0f)); - float maxx = ceilf(min(max3(v1.x, v2.x, v3.x), extents.x - 1.0f)); - float maxy = ceilf(min(max3(v1.y, v2.y, v3.y), extents.y - 1.0f)); + float maxx = ceilf( min(max3(v1.x, v2.x, v3.x), extents.x - 1.0f)); + float maxy = ceilf( min(max3(v1.y, v2.y, v3.y), extents.y - 1.0f)); // There's no reason to align the blocks to the viewport, instead we align them to the origin of the triangle bounds. minx = floorf(minx); miny = floorf(miny); @@ -4575,10 +4847,9 @@ struct Triangle { float bC = C2 + n2.x * xc + n2.y * yc; float cC = C3 + n3.x * xc + n3.y * yc; // Skip block when outside an edge - if ((aC <= BK_OUTSIDE) || (bC <= BK_OUTSIDE) || (cC <= BK_OUTSIDE)) - continue; + if ( (aC <= BK_OUTSIDE) || (bC <= BK_OUTSIDE) || (cC <= BK_OUTSIDE) ) continue; // Accept whole block when totally covered - if ((aC >= BK_INSIDE) && (bC >= BK_INSIDE) && (cC >= BK_INSIDE)) { + if ( (aC >= BK_INSIDE) && (bC >= BK_INSIDE) && (cC >= BK_INSIDE) ) { for (float y = y0; y < y0 + BK_SIZE; y++) { for (float x = x0; x < x0 + BK_SIZE; x++) { if (!cb(param, (int)x, (int)y)) @@ -4621,9 +4892,10 @@ struct Triangle { } private: - void flipBackface() { + void flipBackface() + { // check if triangle is backfacing, if so, swap two vertices - if (((v3.x - v1.x) * (v2.y - v1.y) - (v3.y - v1.y) * (v2.x - v1.x)) < 0) { + if ( ((v3.x - v1.x) * (v2.y - v1.y) - (v3.y - v1.y) * (v2.x - v1.x)) < 0 ) { Vector2 hv = v1; v1 = v2; v2 = hv; // swap pos @@ -4631,7 +4903,8 @@ private: } // compute unit inward normals for each edge. - void computeUnitInwardNormals() { + void computeUnitInwardNormals() + { n1 = v1 - v2; n1 = Vector2(-n1.y, n1.x); n1 = n1 * (1.0f / sqrtf(dot(n1, n1))); @@ -4649,7 +4922,8 @@ private: }; // Process the given triangle. Returns false if rasterization was interrupted by the callback. -static bool drawTriangle(const Vector2 &extents, const Vector2 v[3], SamplingCallback cb, void *param) { +static bool drawTriangle(const Vector2 &extents, const Vector2 v[3], SamplingCallback cb, void *param) +{ Triangle tri(v[0], v[1], v[2]); // @@ It would be nice to have a conservative drawing mode that enlarges the triangle extents by one texel and is able to handle degenerate triangles. // @@ Maybe the simplest thing to do would be raster triangle edges. @@ -4664,19 +4938,22 @@ namespace segment { // - Insertion is o(n) // - Smallest element goes at the end, so that popping it is o(1). -struct CostQueue { - CostQueue(uint32_t size = UINT32_MAX) : - m_maxSize(size), m_pairs(MemTag::SegmentAtlasChartCandidates) {} +struct CostQueue +{ + CostQueue(uint32_t size = UINT32_MAX) : m_maxSize(size), m_pairs(MemTag::SegmentAtlasChartCandidates) {} - float peekCost() const { + float peekCost() const + { return m_pairs.back().cost; } - uint32_t peekFace() const { + uint32_t peekFace() const + { return m_pairs.back().face; } - void push(float cost, uint32_t face) { + void push(float cost, uint32_t face) + { const Pair p = { cost, face }; if (m_pairs.isEmpty() || cost < peekCost()) m_pairs.push_back(p); @@ -4693,25 +4970,29 @@ struct CostQueue { } } - uint32_t pop() { + uint32_t pop() + { XA_DEBUG_ASSERT(!m_pairs.isEmpty()); uint32_t f = m_pairs.back().face; m_pairs.pop_back(); return f; } - XA_INLINE void clear() { + XA_INLINE void clear() + { m_pairs.clear(); } - XA_INLINE uint32_t count() const { + XA_INLINE uint32_t count() const + { return m_pairs.size(); } private: const uint32_t m_maxSize; - struct Pair { + struct Pair + { float cost; uint32_t face; }; @@ -4719,7 +5000,8 @@ private: Array<Pair> m_pairs; }; -struct AtlasData { +struct AtlasData +{ ChartOptions options; const Mesh *mesh = nullptr; Array<float> edgeDihedralAngles; @@ -4729,10 +5011,10 @@ struct AtlasData { Array<Vector3> faceNormals; BitArray isFaceInChart; - AtlasData() : - edgeDihedralAngles(MemTag::SegmentAtlasMeshData), edgeLengths(MemTag::SegmentAtlasMeshData), faceAreas(MemTag::SegmentAtlasMeshData), faceNormals(MemTag::SegmentAtlasMeshData) {} + AtlasData() : edgeDihedralAngles(MemTag::SegmentAtlasMeshData), edgeLengths(MemTag::SegmentAtlasMeshData), faceAreas(MemTag::SegmentAtlasMeshData), faceNormals(MemTag::SegmentAtlasMeshData) {} - void compute() { + void compute() + { const uint32_t faceCount = mesh->faceCount(); const uint32_t edgeCount = mesh->edgeCount(); edgeDihedralAngles.resize(edgeCount); @@ -4773,18 +5055,20 @@ struct AtlasData { }; // If MeshDecl::vertexUvData is set on input meshes, find charts by floodfilling faces in world/model space without crossing UV seams. -struct OriginalUvCharts { - OriginalUvCharts(AtlasData &data) : - m_data(data) {} +struct OriginalUvCharts +{ + OriginalUvCharts(AtlasData &data) : m_data(data) {} uint32_t chartCount() const { return m_charts.size(); } const Basis &chartBasis(uint32_t chartIndex) const { return m_chartBasis[chartIndex]; } - ConstArrayView<uint32_t> chartFaces(uint32_t chartIndex) const { + ConstArrayView<uint32_t> chartFaces(uint32_t chartIndex) const + { const Chart &chart = m_charts[chartIndex]; return ConstArrayView<uint32_t>(&m_chartFaces[chart.firstFace], chart.faceCount); } - void compute() { + void compute() + { m_charts.clear(); m_chartFaces.clear(); const Mesh *mesh = m_data.mesh; @@ -4805,7 +5089,8 @@ struct OriginalUvCharts { } // Compute basis for each chart. m_chartBasis.resize(m_charts.size()); - for (uint32_t c = 0; c < m_charts.size(); c++) { + for (uint32_t c = 0; c < m_charts.size(); c++) + { const Chart &chart = m_charts[c]; m_tempPoints.resize(chart.faceCount * 3); for (uint32_t f = 0; f < chart.faceCount; f++) { @@ -4818,11 +5103,13 @@ struct OriginalUvCharts { } private: - struct Chart { + struct Chart + { uint32_t firstFace, faceCount; }; - void floodfillFaces(Chart &chart) { + void floodfillFaces(Chart &chart) + { const bool isFaceAreaNegative = m_data.faceUvAreas[m_chartFaces[chart.firstFace]] < 0.0f; for (;;) { bool newFaceAdded = false; @@ -4868,13 +5155,14 @@ static uint32_t s_planarRegionsCurrentRegion; static uint32_t s_planarRegionsCurrentVertex; #endif -struct PlanarCharts { - PlanarCharts(AtlasData &data) : - m_data(data), m_nextRegionFace(MemTag::SegmentAtlasPlanarRegions), m_faceToRegionId(MemTag::SegmentAtlasPlanarRegions) {} +struct PlanarCharts +{ + PlanarCharts(AtlasData &data) : m_data(data), m_nextRegionFace(MemTag::SegmentAtlasPlanarRegions), m_faceToRegionId(MemTag::SegmentAtlasPlanarRegions) {} const Basis &chartBasis(uint32_t chartIndex) const { return m_chartBasis[chartIndex]; } uint32_t chartCount() const { return m_charts.size(); } - ConstArrayView<uint32_t> chartFaces(uint32_t chartIndex) const { + ConstArrayView<uint32_t> chartFaces(uint32_t chartIndex) const + { const Chart &chart = m_charts[chartIndex]; return ConstArrayView<uint32_t>(&m_chartFaces[chart.firstFace], chart.faceCount); } @@ -4883,7 +5171,8 @@ struct PlanarCharts { uint32_t nextRegionFace(uint32_t face) const { return m_nextRegionFace[face]; } float regionArea(uint32_t region) const { return m_regionAreas[region]; } - void compute() { + void compute() + { const uint32_t faceCount = m_data.mesh->faceCount(); // Precompute regions of coplanar incident faces. m_regionFirstFace.clear(); @@ -4983,7 +5272,8 @@ struct PlanarCharts { if (!createChart) break; face = m_nextRegionFace[face]; - } while (face != firstRegionFace); + } + while (face != firstRegionFace); // Create a chart. if (createChart) { Chart chart; @@ -4995,13 +5285,15 @@ struct PlanarCharts { m_chartFaces.push_back(face); chart.faceCount++; face = m_nextRegionFace[face]; - } while (face != firstRegionFace); + } + while (face != firstRegionFace); m_charts.push_back(chart); } } // Compute basis for each chart using the first face normal (all faces have the same normal). m_chartBasis.resize(m_charts.size()); - for (uint32_t c = 0; c < m_charts.size(); c++) { + for (uint32_t c = 0; c < m_charts.size(); c++) + { const uint32_t face = m_chartFaces[m_charts[c].firstFace]; Basis &basis = m_chartBasis[c]; basis.normal = m_data.faceNormals[face]; @@ -5011,7 +5303,8 @@ struct PlanarCharts { } private: - struct Chart { + struct Chart + { uint32_t firstFace, faceCount; }; @@ -5025,11 +5318,12 @@ private: Array<Basis> m_chartBasis; }; -struct ClusteredCharts { - ClusteredCharts(AtlasData &data, const PlanarCharts &planarCharts) : - m_data(data), m_planarCharts(planarCharts), m_texcoords(MemTag::SegmentAtlasMeshData), m_bestTriangles(10), m_placingSeeds(false) {} +struct ClusteredCharts +{ + ClusteredCharts(AtlasData &data, const PlanarCharts &planarCharts) : m_data(data), m_planarCharts(planarCharts), m_texcoords(MemTag::SegmentAtlasMeshData), m_bestTriangles(10), m_placingSeeds(false) {} - ~ClusteredCharts() { + ~ClusteredCharts() + { const uint32_t chartCount = m_charts.size(); for (uint32_t i = 0; i < chartCount; i++) { m_charts[i]->~Chart(); @@ -5041,7 +5335,8 @@ struct ClusteredCharts { ConstArrayView<uint32_t> chartFaces(uint32_t chartIndex) const { return m_charts[chartIndex]->faces; } const Basis &chartBasis(uint32_t chartIndex) const { return m_charts[chartIndex]->basis; } - void compute() { + void compute() + { const uint32_t faceCount = m_data.mesh->faceCount(); m_facesLeft = 0; for (uint32_t i = 0; i < faceCount; i++) { @@ -5087,9 +5382,9 @@ struct ClusteredCharts { } private: - struct Chart { - Chart() : - faces(MemTag::SegmentAtlasChartFaces) {} + struct Chart + { + Chart() : faces(MemTag::SegmentAtlasChartFaces) {} int id = -1; Basis basis; // Best fit normal. @@ -5103,7 +5398,8 @@ private: uint32_t seed; }; - void placeSeeds(float threshold) { + void placeSeeds(float threshold) + { XA_PROFILE_START(clusteredChartsPlaceSeeds) m_placingSeeds = true; // Instead of using a predefiened number of seeds: @@ -5119,7 +5415,8 @@ private: } // Returns true if any of the charts can grow more. - void growCharts(float threshold) { + void growCharts(float threshold) + { XA_PROFILE_START(clusteredChartsGrow) for (;;) { if (m_facesLeft == 0) @@ -5165,7 +5462,8 @@ private: XA_PROFILE_END(clusteredChartsGrow) } - void resetCharts() { + void resetCharts() + { XA_PROFILE_START(clusteredChartsReset) const uint32_t faceCount = m_data.mesh->faceCount(); for (uint32_t i = 0; i < faceCount; i++) { @@ -5196,7 +5494,8 @@ private: XA_PROFILE_END(clusteredChartsReset) } - bool relocateSeeds() { + bool relocateSeeds() + { XA_PROFILE_START(clusteredChartsRelocateSeeds) bool anySeedChanged = false; const uint32_t chartCount = m_charts.size(); @@ -5209,7 +5508,8 @@ private: return anySeedChanged; } - void fillHoles(float threshold) { + void fillHoles(float threshold) + { XA_PROFILE_START(clusteredChartsFillHoles) while (m_facesLeft > 0) createChart(threshold); @@ -5217,7 +5517,8 @@ private: } #if XA_MERGE_CHARTS - void mergeCharts() { + void mergeCharts() + { XA_PROFILE_START(clusteredChartsMerge) const uint32_t chartCount = m_charts.size(); // Merge charts progressively until there's none left to merge. @@ -5286,7 +5587,7 @@ private: if (m_sharedBoundaryLengthsNoSeams[cc] > 0.0f && equal(m_sharedBoundaryLengthsNoSeams[cc], chart2->boundaryLength, kEpsilon)) goto merge; if (m_sharedBoundaryLengths[cc] > 0.2f * max(0.0f, chart->boundaryLength - externalBoundaryLength) || - m_sharedBoundaryLengths[cc] > 0.75f * chart2->boundaryLength) + m_sharedBoundaryLengths[cc] > 0.75f * chart2->boundaryLength) goto merge; continue; merge: @@ -5324,7 +5625,8 @@ private: #endif private: - void createChart(float threshold) { + void createChart(float threshold) + { Chart *chart = XA_NEW(MemTag::Default, Chart); chart->id = (int)m_charts.size(); m_charts.push_back(chart); @@ -5355,13 +5657,15 @@ private: } } - bool isChartBoundaryEdge(const Chart *chart, uint32_t edge) const { + bool isChartBoundaryEdge(const Chart *chart, uint32_t edge) const + { const uint32_t oppositeEdge = m_data.mesh->oppositeEdge(edge); const uint32_t oppositeFace = meshEdgeFace(oppositeEdge); return oppositeEdge == UINT32_MAX || m_faceCharts[oppositeFace] != chart->id; } - bool computeChartBasis(Chart *chart, Basis *basis) { + bool computeChartBasis(Chart *chart, Basis *basis) + { const uint32_t faceCount = chart->faces.size(); m_tempPoints.resize(chart->faces.size() * 3); for (uint32_t i = 0; i < faceCount; i++) { @@ -5372,7 +5676,8 @@ private: return Fit::computeBasis(m_tempPoints, basis); } - bool isFaceFlipped(uint32_t face) const { + bool isFaceFlipped(uint32_t face) const + { const Vector2 &v1 = m_texcoords[face * 3 + 0]; const Vector2 &v2 = m_texcoords[face * 3 + 1]; const Vector2 &v3 = m_texcoords[face * 3 + 2]; @@ -5380,7 +5685,8 @@ private: return parametricArea < 0.0f; } - void parameterizeChart(const Chart *chart) { + void parameterizeChart(const Chart *chart) + { const uint32_t faceCount = chart->faces.size(); for (uint32_t i = 0; i < faceCount; i++) { const uint32_t face = chart->faces[i]; @@ -5393,7 +5699,8 @@ private: } // m_faceCharts for the chart faces must be set to the chart ID. Needed to compute boundary edges. - bool isChartParameterizationValid(const Chart *chart) { + bool isChartParameterizationValid(const Chart *chart) + { const uint32_t faceCount = chart->faces.size(); // Check for flipped faces in the parameterization. OK if all are flipped. uint32_t flippedFaceCount = 0; @@ -5427,7 +5734,8 @@ private: return true; } - bool addFaceToChart(Chart *chart, uint32_t face) { + bool addFaceToChart(Chart *chart, uint32_t face) + { XA_DEBUG_ASSERT(!m_data.isFaceInChart.get(face)); const uint32_t oldFaceCount = chart->faces.size(); const bool firstFace = oldFaceCount == 0; @@ -5505,7 +5813,8 @@ private: } // Returns true if the seed has changed. - bool relocateSeed(Chart *chart) { + bool relocateSeed(Chart *chart) + { // Find the first N triangles that fit the proxy best. const uint32_t faceCount = chart->faces.size(); m_bestTriangles.clear(); @@ -5535,7 +5844,8 @@ private: } // Cost is combined metrics * weights. - float computeCost(Chart *chart, uint32_t face) const { + float computeCost(Chart *chart, uint32_t face) const + { // Estimate boundary length and area: const float newChartArea = computeArea(chart, face); const float newBoundaryLength = computeBoundaryLength(chart, face); @@ -5571,20 +5881,23 @@ private: // Returns a value in [0-1]. // 0 if face normal is coplanar to the chart's best fit normal. // 1 if face normal is perpendicular. - float computeNormalDeviationMetric(Chart *chart, uint32_t face) const { + float computeNormalDeviationMetric(Chart *chart, uint32_t face) const + { // All faces in coplanar regions have the same normal, can use any face. const Vector3 faceNormal = m_data.faceNormals[face]; // Use plane fitting metric for now: return min(1.0f - dot(faceNormal, chart->basis.normal), 1.0f); // @@ normal deviations should be weighted by face area } - float computeRoundnessMetric(Chart *chart, float newBoundaryLength, float newChartArea) const { + float computeRoundnessMetric(Chart *chart, float newBoundaryLength, float newChartArea) const + { const float oldRoundness = square(chart->boundaryLength) / chart->area; const float newRoundness = square(newBoundaryLength) / newChartArea; return 1.0f - oldRoundness / newRoundness; } - float computeStraightnessMetric(Chart *chart, uint32_t firstFace) const { + float computeStraightnessMetric(Chart *chart, uint32_t firstFace) const + { float l_out = 0.0f; // Length of firstFace planar region boundary that doesn't border the chart. float l_in = 0.0f; // Length that does border the chart. const uint32_t planarRegionId = m_planarCharts.regionIdFromFace(firstFace); @@ -5613,7 +5926,8 @@ private: #endif } - bool isNormalSeam(uint32_t edge) const { + bool isNormalSeam(uint32_t edge) const + { const uint32_t oppositeEdge = m_data.mesh->oppositeEdge(edge); if (oppositeEdge == UINT32_MAX) return false; // boundary edge @@ -5633,7 +5947,8 @@ private: return !equal(m_data.faceNormals[f0], m_data.faceNormals[f1], kNormalEpsilon); } - float computeNormalSeamMetric(Chart *chart, uint32_t firstFace) const { + float computeNormalSeamMetric(Chart *chart, uint32_t firstFace) const + { float seamFactor = 0.0f, totalLength = 0.0f; uint32_t face = firstFace; for (;;) { @@ -5673,7 +5988,8 @@ private: return seamFactor / totalLength; } - float computeTextureSeamMetric(Chart *chart, uint32_t firstFace) const { + float computeTextureSeamMetric(Chart *chart, uint32_t firstFace) const + { float seamLength = 0.0f, totalLength = 0.0f; uint32_t face = firstFace; for (;;) { @@ -5699,7 +6015,8 @@ private: return seamLength / totalLength; } - float computeArea(Chart *chart, uint32_t firstFace) const { + float computeArea(Chart *chart, uint32_t firstFace) const + { float area = chart->area; uint32_t face = firstFace; for (;;) { @@ -5711,7 +6028,8 @@ private: return area; } - float computeBoundaryLength(Chart *chart, uint32_t firstFace) const { + float computeBoundaryLength(Chart *chart, uint32_t firstFace) const + { float boundaryLength = chart->boundaryLength; // Add new edges, subtract edges shared with the chart. const uint32_t planarRegionId = m_planarCharts.regionIdFromFace(firstFace); @@ -5732,10 +6050,11 @@ private: if (face == firstFace) break; } - return max(0.0f, boundaryLength); // @@ Hack! + return max(0.0f, boundaryLength); // @@ Hack! } - bool mergeChart(Chart *owner, Chart *chart, float sharedBoundaryLength) { + bool mergeChart(Chart *owner, Chart *chart, float sharedBoundaryLength) + { const uint32_t oldOwnerFaceCount = owner->faces.size(); const uint32_t chartFaceCount = chart->faces.size(); owner->faces.push_back(chart->faces); @@ -5793,8 +6112,10 @@ private: bool m_placingSeeds; }; -struct ChartGeneratorType { - enum Enum { +struct ChartGeneratorType +{ + enum Enum + { OriginalUv, Planar, Clustered, @@ -5802,15 +6123,17 @@ struct ChartGeneratorType { }; }; -struct Atlas { - Atlas() : - m_originalUvCharts(m_data), m_planarCharts(m_data), m_clusteredCharts(m_data, m_planarCharts) {} +struct Atlas +{ + Atlas() : m_originalUvCharts(m_data), m_planarCharts(m_data), m_clusteredCharts(m_data, m_planarCharts) {} - uint32_t chartCount() const { + uint32_t chartCount() const + { return m_originalUvCharts.chartCount() + m_planarCharts.chartCount() + m_clusteredCharts.chartCount(); } - ConstArrayView<uint32_t> chartFaces(uint32_t chartIndex) const { + ConstArrayView<uint32_t> chartFaces(uint32_t chartIndex) const + { if (chartIndex < m_originalUvCharts.chartCount()) return m_originalUvCharts.chartFaces(chartIndex); chartIndex -= m_originalUvCharts.chartCount(); @@ -5820,7 +6143,8 @@ struct Atlas { return m_clusteredCharts.chartFaces(chartIndex); } - const Basis &chartBasis(uint32_t chartIndex) const { + const Basis &chartBasis(uint32_t chartIndex) const + { if (chartIndex < m_originalUvCharts.chartCount()) return m_originalUvCharts.chartBasis(chartIndex); chartIndex -= m_originalUvCharts.chartCount(); @@ -5830,7 +6154,8 @@ struct Atlas { return m_clusteredCharts.chartBasis(chartIndex); } - ChartGeneratorType::Enum chartGeneratorType(uint32_t chartIndex) const { + ChartGeneratorType::Enum chartGeneratorType(uint32_t chartIndex) const + { if (chartIndex < m_originalUvCharts.chartCount()) return ChartGeneratorType::OriginalUv; chartIndex -= m_originalUvCharts.chartCount(); @@ -5839,7 +6164,8 @@ struct Atlas { return ChartGeneratorType::Clustered; } - void reset(const Mesh *mesh, const ChartOptions &options) { + void reset(const Mesh *mesh, const ChartOptions &options) + { XA_PROFILE_START(buildAtlasInit) m_data.options = options; m_data.mesh = mesh; @@ -5847,7 +6173,8 @@ struct Atlas { XA_PROFILE_END(buildAtlasInit) } - void compute() { + void compute() + { if (m_data.options.useInputMeshUvs) { XA_PROFILE_START(originalUvCharts) m_originalUvCharts.compute(); @@ -5868,17 +6195,19 @@ private: ClusteredCharts m_clusteredCharts; }; -struct ComputeUvMeshChartsTaskArgs { +struct ComputeUvMeshChartsTaskArgs +{ UvMesh *mesh; Progress *progress; }; // Charts are found by floodfilling faces without crossing UV seams. -struct ComputeUvMeshChartsTask { - ComputeUvMeshChartsTask(ComputeUvMeshChartsTaskArgs *args) : - m_mesh(args->mesh), m_progress(args->progress), m_uvToEdgeMap(MemTag::Default, m_mesh->indices.size()), m_faceAssigned(m_mesh->indices.size() / 3) {} +struct ComputeUvMeshChartsTask +{ + ComputeUvMeshChartsTask(ComputeUvMeshChartsTaskArgs *args) : m_mesh(args->mesh), m_progress(args->progress), m_uvToEdgeMap(MemTag::Default, m_mesh->indices.size()), m_faceAssigned(m_mesh->indices.size() / 3) {} - void run() { + void run() + { const uint32_t vertexCount = m_mesh->texcoords.size(); const uint32_t indexCount = m_mesh->indices.size(); const uint32_t faceCount = indexCount / 3; @@ -5932,7 +6261,8 @@ struct ComputeUvMeshChartsTask { private: // The chart at chartIndex doesn't have to exist yet. - bool canAddFaceToChart(uint32_t chartIndex, uint32_t face) const { + bool canAddFaceToChart(uint32_t chartIndex, uint32_t face) const + { if (m_faceAssigned.get(face)) return false; // Already assigned to a chart. if (m_mesh->faceIgnore.get(face)) @@ -5949,7 +6279,8 @@ private: return true; } - void addFaceToChart(uint32_t chartIndex, uint32_t face) { + void addFaceToChart(uint32_t chartIndex, uint32_t face) + { UvMeshChart *chart = m_mesh->charts[chartIndex]; m_faceAssigned.set(face); chart->faces.push_back(face); @@ -5960,20 +6291,22 @@ private: } } - UvMesh *const m_mesh; - Progress *const m_progress; + UvMesh * const m_mesh; + Progress * const m_progress; HashMap<Vector2> m_uvToEdgeMap; // Face is edge / 3. BitArray m_faceAssigned; }; -static void runComputeUvMeshChartsTask(void * /*groupUserData*/, void *taskUserData) { +static void runComputeUvMeshChartsTask(void * /*groupUserData*/, void *taskUserData) +{ XA_PROFILE_START(computeChartsThread) ComputeUvMeshChartsTask task((ComputeUvMeshChartsTaskArgs *)taskUserData); task.run(); XA_PROFILE_END(computeChartsThread) } -static bool computeUvMeshCharts(TaskScheduler *taskScheduler, ArrayView<UvMesh *> meshes, ProgressFunc progressFunc, void *progressUserData) { +static bool computeUvMeshCharts(TaskScheduler *taskScheduler, ArrayView<UvMesh *> meshes, ProgressFunc progressFunc, void *progressUserData) +{ uint32_t totalFaceCount = 0; for (uint32_t i = 0; i < meshes.length; i++) totalFaceCount += meshes[i]->indices.size() / 3; @@ -5981,7 +6314,8 @@ static bool computeUvMeshCharts(TaskScheduler *taskScheduler, ArrayView<UvMesh * TaskGroupHandle taskGroup = taskScheduler->createTaskGroup(nullptr, meshes.length); Array<ComputeUvMeshChartsTaskArgs> taskArgs; taskArgs.resize(meshes.length); - for (uint32_t i = 0; i < meshes.length; i++) { + for (uint32_t i = 0; i < meshes.length; i++) + { ComputeUvMeshChartsTaskArgs &args = taskArgs[i]; args.mesh = meshes[i]; args.progress = &progress; @@ -5999,7 +6333,8 @@ static bool computeUvMeshCharts(TaskScheduler *taskScheduler, ArrayView<UvMesh * namespace param { // Fast sweep in 3 directions -static bool findApproximateDiameterVertices(Mesh *mesh, uint32_t *a, uint32_t *b) { +static bool findApproximateDiameterVertices(Mesh *mesh, uint32_t *a, uint32_t *b) +{ XA_DEBUG_ASSERT(a != nullptr); XA_DEBUG_ASSERT(b != nullptr); const uint32_t vertexCount = mesh->vertexCount(); @@ -6056,7 +6391,8 @@ static bool findApproximateDiameterVertices(Mesh *mesh, uint32_t *a, uint32_t *b // From OpenNL LSCM example. // Computes the coordinates of the vertices of a triangle in a local 2D orthonormal basis of the triangle's plane. -static void projectTriangle(Vector3 p0, Vector3 p1, Vector3 p2, Vector2 *z0, Vector2 *z1, Vector2 *z2) { +static void projectTriangle(Vector3 p0, Vector3 p1, Vector3 p2, Vector2 *z0, Vector2 *z1, Vector2 *z2) +{ Vector3 X = normalize(p1 - p0); Vector3 Z = normalize(cross(X, p2 - p0)); Vector3 Y = cross(Z, X); @@ -6068,24 +6404,28 @@ static void projectTriangle(Vector3 p0, Vector3 p1, Vector3 p2, Vector2 *z0, Vec // Conformal relations from Brecht Van Lommel (based on ABF): -static float vec_angle_cos(const Vector3 &v1, const Vector3 &v2, const Vector3 &v3) { +static float vec_angle_cos(const Vector3 &v1, const Vector3 &v2, const Vector3 &v3) +{ Vector3 d1 = v1 - v2; Vector3 d2 = v3 - v2; return clamp(dot(d1, d2) / (length(d1) * length(d2)), -1.0f, 1.0f); } -static float vec_angle(const Vector3 &v1, const Vector3 &v2, const Vector3 &v3) { +static float vec_angle(const Vector3 &v1, const Vector3 &v2, const Vector3 &v3) +{ float dot = vec_angle_cos(v1, v2, v3); return acosf(dot); } -static void triangle_angles(const Vector3 &v1, const Vector3 &v2, const Vector3 &v3, float *a1, float *a2, float *a3) { +static void triangle_angles(const Vector3 &v1, const Vector3 &v2, const Vector3 &v3, float *a1, float *a2, float *a3) +{ *a1 = vec_angle(v3, v1, v2); *a2 = vec_angle(v1, v2, v3); *a3 = kPi - *a2 - *a1; } -static bool setup_abf_relations(opennl::NLContext *context, int id0, int id1, int id2, const Vector3 &p0, const Vector3 &p1, const Vector3 &p2) { +static bool setup_abf_relations(opennl::NLContext *context, int id0, int id1, int id2, const Vector3 &p0, const Vector3 &p1, const Vector3 &p2) +{ // @@ IC: Wouldn't it be more accurate to return cos and compute 1-cos^2? // It does indeed seem to be a little bit more robust. // @@ Need to revisit this more carefully! @@ -6142,7 +6482,8 @@ static bool setup_abf_relations(opennl::NLContext *context, int id0, int id1, in return true; } -static bool computeLeastSquaresConformalMap(Mesh *mesh) { +static bool computeLeastSquaresConformalMap(Mesh *mesh) +{ uint32_t lockedVertex0, lockedVertex1; if (!findApproximateDiameterVertices(mesh, &lockedVertex0, &lockedVertex1)) { // Mesh has no boundaries. @@ -6189,16 +6530,16 @@ static bool computeLeastSquaresConformalMap(Mesh *mesh) { // Note : b = 0 // Real part opennl::nlBegin(context, NL_ROW); - opennl::nlCoefficient(context, u0_id, -a + c); - opennl::nlCoefficient(context, v0_id, b - d); - opennl::nlCoefficient(context, u1_id, -c); - opennl::nlCoefficient(context, v1_id, d); + opennl::nlCoefficient(context, u0_id, -a+c) ; + opennl::nlCoefficient(context, v0_id, b-d) ; + opennl::nlCoefficient(context, u1_id, -c) ; + opennl::nlCoefficient(context, v1_id, d) ; opennl::nlCoefficient(context, u2_id, a); opennl::nlEnd(context, NL_ROW); // Imaginary part opennl::nlBegin(context, NL_ROW); - opennl::nlCoefficient(context, u0_id, -b + d); - opennl::nlCoefficient(context, v0_id, -a + c); + opennl::nlCoefficient(context, u0_id, -b+d); + opennl::nlCoefficient(context, v0_id, -a+c); opennl::nlCoefficient(context, u1_id, -d); opennl::nlCoefficient(context, v1_id, -c); opennl::nlCoefficient(context, v2_id, a); @@ -6222,8 +6563,10 @@ static bool computeLeastSquaresConformalMap(Mesh *mesh) { return true; } -struct PiecewiseParam { - void reset(const Mesh *mesh) { +struct PiecewiseParam +{ + void reset(const Mesh *mesh) + { m_mesh = mesh; const uint32_t faceCount = m_mesh->faceCount(); const uint32_t vertexCount = m_mesh->vertexCount(); @@ -6241,7 +6584,8 @@ struct PiecewiseParam { ConstArrayView<uint32_t> chartFaces() const { return m_patch; } ConstArrayView<Vector2> texcoords() const { return m_texcoords; } - bool computeChart() { + bool computeChart() + { // Clear per-patch state. m_patch.clear(); m_candidates.clear(); @@ -6370,7 +6714,8 @@ struct PiecewiseParam { } private: - struct Candidate { + struct Candidate + { uint32_t face, vertex; Candidate *prev, *next; // The previous/next candidate with the same vertex. Vector2 position; @@ -6380,14 +6725,10 @@ private: float patchVertexOrient; }; - struct CandidateIterator { - CandidateIterator(Candidate *head) : - m_current(head) { XA_DEBUG_ASSERT(!head->prev); } - void advance() { - if (m_current != nullptr) { - m_current = m_current->next; - } - } + struct CandidateIterator + { + CandidateIterator(Candidate *head) : m_current(head) { XA_DEBUG_ASSERT(!head->prev); } + void advance() { if (m_current != nullptr) { m_current = m_current->next; } } bool isDone() const { return !m_current; } Candidate *current() { return m_current; } @@ -6406,7 +6747,8 @@ private: UniformGrid2 m_boundaryGrid; Array<uint32_t> m_newBoundaryEdges, m_ignoreBoundaryEdges; // Temp arrays used when testing for boundary intersection. - void addFaceToPatch(uint32_t face) { + void addFaceToPatch(uint32_t face) + { XA_DEBUG_ASSERT(!m_faceInPatch.get(face)); XA_DEBUG_ASSERT(!m_faceInAnyPatch.get(face)); m_patch.push_back(face); @@ -6446,7 +6788,8 @@ private: } } - void addCandidateFace(uint32_t patchEdge, float patchVertexOrient, uint32_t face, uint32_t edge, uint32_t freeVertex) { + void addCandidateFace(uint32_t patchEdge, float patchVertexOrient, uint32_t face, uint32_t edge, uint32_t freeVertex) + { XA_DEBUG_ASSERT(!m_faceToCandidate[face]); Vector2 texcoords[3]; orthoProjectFace(face, texcoords); @@ -6549,7 +6892,8 @@ private: it.current()->maxCost = maxCost; } - Candidate *linkedCandidateHead(Candidate *candidate) { + Candidate *linkedCandidateHead(Candidate *candidate) + { Candidate *current = candidate; for (;;) { if (!current->prev) @@ -6559,7 +6903,8 @@ private: return current; } - void removeLinkedCandidates(Candidate *head) { + void removeLinkedCandidates(Candidate *head) + { XA_DEBUG_ASSERT(!head->prev); Candidate *current = head; while (current) { @@ -6576,7 +6921,8 @@ private: } } - void orthoProjectFace(uint32_t face, Vector2 *texcoords) const { + void orthoProjectFace(uint32_t face, Vector2 *texcoords) const + { const Vector3 normal = -m_mesh->computeFaceNormal(face); const Vector3 tangent = normalize(m_mesh->position(m_mesh->vertexAt(face * 3 + 1)) - m_mesh->position(m_mesh->vertexAt(face * 3 + 0))); const Vector3 bitangent = cross(normal, tangent); @@ -6586,14 +6932,16 @@ private: } } - float parametricArea(const Vector2 *texcoords) const { + float parametricArea(const Vector2 *texcoords) const + { const Vector2 &v1 = texcoords[0]; const Vector2 &v2 = texcoords[1]; const Vector2 &v3 = texcoords[2]; return ((v2.x - v1.x) * (v3.y - v1.y) - (v3.x - v1.x) * (v2.y - v1.y)) * 0.5f; } - float computeStretch(Vector3 p1, Vector3 p2, Vector3 p3, Vector2 t1, Vector2 t2, Vector2 t3) const { + float computeStretch(Vector3 p1, Vector3 p2, Vector3 p3, Vector2 t1, Vector2 t2, Vector2 t3) const + { float parametricArea = ((t2.y - t1.y) * (t3.x - t1.x) - (t3.y - t1.y) * (t2.x - t1.x)) * 0.5f; if (isZero(parametricArea, kAreaEpsilon)) return FLT_MAX; @@ -6607,13 +6955,15 @@ private: } // Return value is positive if the point is one side of the edge, negative if on the other side. - float orientToEdge(Vector2 edgeVertex0, Vector2 edgeVertex1, Vector2 point) const { + float orientToEdge(Vector2 edgeVertex0, Vector2 edgeVertex1, Vector2 point) const + { return (edgeVertex0.x - point.x) * (edgeVertex1.y - point.y) - (edgeVertex0.y - point.y) * (edgeVertex1.x - point.x); } }; // Estimate quality of existing parameterization. -struct Quality { +struct Quality +{ // computeBoundaryIntersection bool boundaryIntersection = false; @@ -6630,7 +6980,8 @@ struct Quality { float conformalMetric = 0.0f; float authalicMetric = 0.0f; - void computeBoundaryIntersection(const Mesh *mesh, UniformGrid2 &boundaryGrid) { + void computeBoundaryIntersection(const Mesh *mesh, UniformGrid2 &boundaryGrid) + { const Array<uint32_t> &boundaryEdges = mesh->boundaryEdges(); const uint32_t boundaryEdgeCount = boundaryEdges.size(); boundaryGrid.reset(mesh->texcoords(), mesh->indices(), boundaryEdgeCount); @@ -6646,7 +6997,8 @@ struct Quality { #endif } - void computeFlippedFaces(const Mesh *mesh, Array<uint32_t> *flippedFaces) { + void computeFlippedFaces(const Mesh *mesh, Array<uint32_t> *flippedFaces) + { totalTriangleCount = flippedTriangleCount = zeroAreaTriangleCount = 0; if (flippedFaces) flippedFaces->clear(); @@ -6682,7 +7034,8 @@ struct Quality { flippedFaces->clear(); flippedTriangleCount = 0; } - if (flippedTriangleCount > totalTriangleCount / 2) { + if (flippedTriangleCount > totalTriangleCount / 2) + { // If more than half the triangles are flipped, reverse the flipped / not flipped classification. flippedTriangleCount = totalTriangleCount - flippedTriangleCount; if (flippedFaces) { @@ -6704,7 +7057,8 @@ struct Quality { } } - void computeMetrics(const Mesh *mesh) { + void computeMetrics(const Mesh *mesh) + { totalGeometricArea = totalParametricArea = 0.0f; stretchMetric = maxStretchMetric = conformalMetric = authalicMetric = 0.0f; const uint32_t faceCount = mesh->faceCount(); @@ -6736,7 +7090,7 @@ struct Quality { const float a = dot(Ss, Ss); // E const float b = dot(Ss, St); // F const float c = dot(St, St); // G - // Compute eigen-values of the first fundamental form: + // Compute eigen-values of the first fundamental form: const float sigma1 = sqrtf(0.5f * max(0.0f, a + c - sqrtf(square(a - c) + 4 * square(b)))); // gamma uppercase, min eigenvalue. const float sigma2 = sqrtf(0.5f * max(0.0f, a + c + sqrtf(square(a - c) + 4 * square(b)))); // gamma lowercase, max eigenvalue. XA_ASSERT(sigma2 > sigma1 || equal(sigma1, sigma2, kEpsilon)); @@ -6767,22 +7121,24 @@ struct Quality { if (totalGeometricArea > 0.0f) { const float normFactor = sqrtf(totalParametricArea / totalGeometricArea); stretchMetric = sqrtf(stretchMetric / totalGeometricArea) * normFactor; - maxStretchMetric *= normFactor; + maxStretchMetric *= normFactor; conformalMetric = sqrtf(conformalMetric / totalGeometricArea); authalicMetric = sqrtf(authalicMetric / totalGeometricArea); } } }; -struct ChartCtorBuffers { +struct ChartCtorBuffers +{ Array<uint32_t> chartMeshIndices; Array<uint32_t> unifiedMeshIndices; }; -class Chart { +class Chart +{ public: - Chart(const Basis &basis, segment::ChartGeneratorType::Enum generatorType, ConstArrayView<uint32_t> faces, const Mesh *sourceMesh, uint32_t chartGroupId, uint32_t chartId) : - m_basis(basis), m_unifiedMesh(nullptr), m_type(ChartType::LSCM), m_generatorType(generatorType), m_tjunctionCount(0), m_originalVertexCount(0), m_isInvalid(false) { + Chart(const Basis &basis, segment::ChartGeneratorType::Enum generatorType, ConstArrayView<uint32_t> faces, const Mesh *sourceMesh, uint32_t chartGroupId, uint32_t chartId) : m_basis(basis), m_unifiedMesh(nullptr), m_type(ChartType::LSCM), m_generatorType(generatorType), m_tjunctionCount(0), m_originalVertexCount(0), m_isInvalid(false) + { XA_UNUSED(chartGroupId); XA_UNUSED(chartId); m_faceToSourceFaceMap.copyFrom(faces.data, faces.length); @@ -6813,8 +7169,7 @@ public: m_chartVertexToUnifiedVertexMap.push_back(unifiedVertex); m_originalVertexCount++; } - m_originalIndices[f * 3 + i] = sourceVertexToChartVertexMap.get(sourceVertex); - ; + m_originalIndices[f * 3 + i] = sourceVertexToChartVertexMap.get(sourceVertex);; XA_DEBUG_ASSERT(m_originalIndices[f * 3 + i] != UINT32_MAX); unifiedIndices[i] = sourceVertexToUnifiedVertexMap.get(sourceUnifiedVertex); XA_DEBUG_ASSERT(unifiedIndices[i] != UINT32_MAX); @@ -6838,8 +7193,8 @@ public: #endif } - Chart(ChartCtorBuffers &buffers, const Chart *parent, const Mesh *parentMesh, ConstArrayView<uint32_t> faces, ConstArrayView<Vector2> texcoords, const Mesh *sourceMesh) : - m_unifiedMesh(nullptr), m_type(ChartType::Piecewise), m_generatorType(segment::ChartGeneratorType::Piecewise), m_tjunctionCount(0), m_originalVertexCount(0), m_isInvalid(false) { + Chart(ChartCtorBuffers &buffers, const Chart *parent, const Mesh *parentMesh, ConstArrayView<uint32_t> faces, ConstArrayView<Vector2> texcoords, const Mesh *sourceMesh) : m_unifiedMesh(nullptr), m_type(ChartType::Piecewise), m_generatorType(segment::ChartGeneratorType::Piecewise), m_tjunctionCount(0), m_originalVertexCount(0), m_isInvalid(false) + { const uint32_t faceCount = faces.length; m_faceToSourceFaceMap.resize(faceCount); for (uint32_t i = 0; i < faceCount; i++) @@ -6886,7 +7241,8 @@ public: backupTexcoords(); } - ~Chart() { + ~Chart() + { if (m_unifiedMesh) { m_unifiedMesh->~Mesh(); XA_FREE(m_unifiedMesh); @@ -6914,7 +7270,8 @@ public: ConstArrayView<uint32_t> originalVertices() const { return m_originalIndices; } - void parameterize(const ChartOptions &options, UniformGrid2 &boundaryGrid) { + void parameterize(const ChartOptions &options, UniformGrid2 &boundaryGrid) + { const uint32_t unifiedVertexCount = m_unifiedMesh->vertexCount(); if (m_generatorType == segment::ChartGeneratorType::OriginalUv) { } else { @@ -6938,7 +7295,8 @@ public: XA_PROFILE_START(parameterizeChartsLSCM) if (options.paramFunc) { options.paramFunc(&m_unifiedMesh->position(0).x, &m_unifiedMesh->texcoord(0).x, m_unifiedMesh->vertexCount(), m_unifiedMesh->indices().data, m_unifiedMesh->indexCount()); - } else + } + else computeLeastSquaresConformalMap(m_unifiedMesh); XA_PROFILE_END(parameterizeChartsLSCM) XA_PROFILE_START(parameterizeChartsEvaluateQuality) @@ -6980,7 +7338,8 @@ public: backupTexcoords(); } - Vector2 computeParametricBounds() const { + Vector2 computeParametricBounds() const + { Vector2 minCorner(FLT_MAX, FLT_MAX); Vector2 maxCorner(-FLT_MAX, -FLT_MAX); const uint32_t vertexCount = m_unifiedMesh->vertexCount(); @@ -6992,7 +7351,8 @@ public: } #if XA_CHECK_PIECEWISE_CHART_QUALITY - void evaluateQuality(UniformGrid2 &boundaryGrid) { + void evaluateQuality(UniformGrid2 &boundaryGrid) + { m_quality.computeBoundaryIntersection(m_unifiedMesh, boundaryGrid); #if XA_DEBUG_EXPORT_OBJ_INVALID_PARAMETERIZATION m_quality.computeFlippedFaces(m_unifiedMesh, &m_paramFlippedFaces); @@ -7004,12 +7364,14 @@ public: } #endif - void restoreTexcoords() { + void restoreTexcoords() + { memcpy(m_unifiedMesh->texcoords().data, m_backupTexcoords.data(), m_unifiedMesh->vertexCount() * sizeof(Vector2)); } private: - void backupTexcoords() { + void backupTexcoords() + { m_backupTexcoords.resize(m_unifiedMesh->vertexCount()); memcpy(m_backupTexcoords.data(), m_unifiedMesh->texcoords().data, m_unifiedMesh->vertexCount() * sizeof(Vector2)); } @@ -7040,7 +7402,8 @@ private: bool m_isInvalid; }; -struct CreateAndParameterizeChartTaskGroupArgs { +struct CreateAndParameterizeChartTaskGroupArgs +{ Progress *progress; ThreadLocal<UniformGrid2> *boundaryGrid; ThreadLocal<ChartCtorBuffers> *chartBuffers; @@ -7048,7 +7411,8 @@ struct CreateAndParameterizeChartTaskGroupArgs { ThreadLocal<PiecewiseParam> *pp; }; -struct CreateAndParameterizeChartTaskArgs { +struct CreateAndParameterizeChartTaskArgs +{ const Basis *basis; Chart *chart; // output Array<Chart *> charts; // output (if more than one chart) @@ -7059,7 +7423,8 @@ struct CreateAndParameterizeChartTaskArgs { uint32_t chartId; }; -static void runCreateAndParameterizeChartTask(void *groupUserData, void *taskUserData) { +static void runCreateAndParameterizeChartTask(void *groupUserData, void *taskUserData) +{ XA_PROFILE_START(createChartMeshAndParameterizeThread) auto groupArgs = (CreateAndParameterizeChartTaskGroupArgs *)groupUserData; auto args = (CreateAndParameterizeChartTaskArgs *)taskUserData; @@ -7130,13 +7495,15 @@ static void runCreateAndParameterizeChartTask(void *groupUserData, void *taskUse } // Set of charts corresponding to mesh faces in the same face group. -class ChartGroup { +class ChartGroup +{ public: - ChartGroup(uint32_t id, const Mesh *sourceMesh, const MeshFaceGroups *sourceMeshFaceGroups, MeshFaceGroups::Handle faceGroup) : - m_id(id), m_sourceMesh(sourceMesh), m_sourceMeshFaceGroups(sourceMeshFaceGroups), m_faceGroup(faceGroup) { + ChartGroup(uint32_t id, const Mesh *sourceMesh, const MeshFaceGroups *sourceMeshFaceGroups, MeshFaceGroups::Handle faceGroup) : m_id(id), m_sourceMesh(sourceMesh), m_sourceMeshFaceGroups(sourceMeshFaceGroups), m_faceGroup(faceGroup) + { } - ~ChartGroup() { + ~ChartGroup() + { for (uint32_t i = 0; i < m_charts.size(); i++) { m_charts[i]->~Chart(); XA_FREE(m_charts[i]); @@ -7147,7 +7514,8 @@ public: Chart *chartAt(uint32_t i) const { return m_charts[i]; } uint32_t faceCount() const { return m_sourceMeshFaceGroups->faceCount(m_faceGroup); } - void computeCharts(TaskScheduler *taskScheduler, const ChartOptions &options, Progress *progress, segment::Atlas &atlas, ThreadLocal<UniformGrid2> *boundaryGrid, ThreadLocal<ChartCtorBuffers> *chartBuffers, ThreadLocal<PiecewiseParam> *piecewiseParam) { + void computeCharts(TaskScheduler *taskScheduler, const ChartOptions &options, Progress *progress, segment::Atlas &atlas, ThreadLocal<UniformGrid2> *boundaryGrid, ThreadLocal<ChartCtorBuffers> *chartBuffers, ThreadLocal<PiecewiseParam> *piecewiseParam) + { // This function may be called multiple times, so destroy existing charts. for (uint32_t i = 0; i < m_charts.size(); i++) { m_charts[i]->~Chart(); @@ -7291,7 +7659,8 @@ public: } private: - Mesh *createMesh() { + Mesh *createMesh() + { XA_DEBUG_ASSERT(m_faceGroup != MeshFaceGroups::kInvalid); // Create new mesh from the source mesh, using faces that belong to this group. m_faceToSourceFaceMap.reserve(m_sourceMeshFaceGroups->faceCount(m_faceGroup)); @@ -7345,14 +7714,15 @@ private: } const uint32_t m_id; - const Mesh *const m_sourceMesh; - const MeshFaceGroups *const m_sourceMeshFaceGroups; + const Mesh * const m_sourceMesh; + const MeshFaceGroups * const m_sourceMeshFaceGroups; const MeshFaceGroups::Handle m_faceGroup; Array<uint32_t> m_faceToSourceFaceMap; // List of faces of the source mesh that belong to this chart group. Array<Chart *> m_charts; }; -struct ChartGroupComputeChartsTaskGroupArgs { +struct ChartGroupComputeChartsTaskGroupArgs +{ ThreadLocal<segment::Atlas> *atlas; const ChartOptions *options; Progress *progress; @@ -7362,7 +7732,8 @@ struct ChartGroupComputeChartsTaskGroupArgs { ThreadLocal<PiecewiseParam> *piecewiseParam; }; -static void runChartGroupComputeChartsTask(void *groupUserData, void *taskUserData) { +static void runChartGroupComputeChartsTask(void *groupUserData, void *taskUserData) +{ auto args = (ChartGroupComputeChartsTaskGroupArgs *)groupUserData; auto chartGroup = (ChartGroup *)taskUserData; if (args->progress->cancel) @@ -7372,7 +7743,8 @@ static void runChartGroupComputeChartsTask(void *groupUserData, void *taskUserDa XA_PROFILE_END(chartGroupComputeChartsThread) } -struct MeshComputeChartsTaskGroupArgs { +struct MeshComputeChartsTaskGroupArgs +{ ThreadLocal<segment::Atlas> *atlas; const ChartOptions *options; Progress *progress; @@ -7382,7 +7754,8 @@ struct MeshComputeChartsTaskGroupArgs { ThreadLocal<PiecewiseParam> *piecewiseParam; }; -struct MeshComputeChartsTaskArgs { +struct MeshComputeChartsTaskArgs +{ const Mesh *sourceMesh; Array<ChartGroup *> *chartGroups; // output InvalidMeshGeometry *invalidMeshGeometry; // output @@ -7392,7 +7765,8 @@ struct MeshComputeChartsTaskArgs { static uint32_t s_faceGroupsCurrentVertex = 0; #endif -static void runMeshComputeChartsTask(void *groupUserData, void *taskUserData) { +static void runMeshComputeChartsTask(void *groupUserData, void *taskUserData) +{ auto groupArgs = (MeshComputeChartsTaskGroupArgs *)groupUserData; auto args = (MeshComputeChartsTaskArgs *)taskUserData; if (groupArgs->progress->cancel) @@ -7491,12 +7865,13 @@ cleanup: } /// An atlas is a set of chart groups. -class Atlas { +class Atlas +{ public: - Atlas() : - m_chartsComputed(false) {} + Atlas() : m_chartsComputed(false) {} - ~Atlas() { + ~Atlas() + { for (uint32_t i = 0; i < m_meshChartGroups.size(); i++) { for (uint32_t j = 0; j < m_meshChartGroups[i].size(); j++) { m_meshChartGroups[i][j]->~ChartGroup(); @@ -7513,11 +7888,13 @@ public: uint32_t chartGroupCount(uint32_t mesh) const { return m_meshChartGroups[mesh].size(); } const ChartGroup *chartGroupAt(uint32_t mesh, uint32_t group) const { return m_meshChartGroups[mesh][group]; } - void addMesh(const Mesh *mesh) { + void addMesh(const Mesh *mesh) + { m_meshes.push_back(mesh); } - bool computeCharts(TaskScheduler *taskScheduler, const ChartOptions &options, ProgressFunc progressFunc, void *progressUserData) { + bool computeCharts(TaskScheduler *taskScheduler, const ChartOptions &options, ProgressFunc progressFunc, void *progressUserData) + { XA_PROFILE_START(computeChartsReal) #if XA_DEBUG_EXPORT_OBJ_PLANAR_REGIONS segment::s_planarRegionsCurrentRegion = segment::s_planarRegionsCurrentVertex = 0; @@ -7591,7 +7968,7 @@ public: private: Array<const Mesh *> m_meshes; Array<InvalidMeshGeometry> m_invalidMeshGeometry; // 1 per mesh. - Array<Array<ChartGroup *>> m_meshChartGroups; + Array<Array<ChartGroup *> > m_meshChartGroups; bool m_chartsComputed; }; @@ -7599,15 +7976,17 @@ private: namespace pack { -class AtlasImage { +class AtlasImage +{ public: - AtlasImage(uint32_t width, uint32_t height) : - m_width(width), m_height(height) { + AtlasImage(uint32_t width, uint32_t height) : m_width(width), m_height(height) + { m_data.resize(m_width * m_height); memset(m_data.data(), 0, sizeof(uint32_t) * m_data.size()); } - void resize(uint32_t width, uint32_t height) { + void resize(uint32_t width, uint32_t height) + { Array<uint32_t> data; data.resize(width * height); memset(data.data(), 0, sizeof(uint32_t) * data.size()); @@ -7618,7 +7997,8 @@ public: data.moveTo(m_data); } - void addChart(uint32_t chartIndex, const BitImage *image, const BitImage *imageBilinear, const BitImage *imagePadding, int atlas_w, int atlas_h, int offset_x, int offset_y) { + void addChart(uint32_t chartIndex, const BitImage *image, const BitImage *imageBilinear, const BitImage *imagePadding, int atlas_w, int atlas_h, int offset_x, int offset_y) + { const int w = image->width(); const int h = image->height(); for (int y = 0; y < h; y++) { @@ -7644,13 +8024,15 @@ public: } } - void copyTo(uint32_t *dest, uint32_t destWidth, uint32_t destHeight, int padding) const { + void copyTo(uint32_t *dest, uint32_t destWidth, uint32_t destHeight, int padding) const + { for (uint32_t y = 0; y < destHeight; y++) memcpy(&dest[y * destWidth], &m_data[padding + (y + padding) * m_width], destWidth * sizeof(uint32_t)); } #if XA_DEBUG_EXPORT_ATLAS_IMAGES - void writeTga(const char *filename, uint32_t width, uint32_t height) const { + void writeTga(const char *filename, uint32_t width, uint32_t height) const + { Array<uint8_t> image; image.resize(width * height * 3); for (uint32_t y = 0; y < height; y++) { @@ -7692,7 +8074,8 @@ private: Array<uint32_t> m_data; }; -struct Chart { +struct Chart +{ int32_t atlasIndex; uint32_t material; ConstArrayView<uint32_t> indices; @@ -7711,12 +8094,14 @@ struct Chart { uint32_t uniqueVertexCount() const { return uniqueVertices.isEmpty() ? vertices.length : uniqueVertices.size(); } }; -struct AddChartTaskArgs { +struct AddChartTaskArgs +{ param::Chart *paramChart; Chart *chart; // out }; -static void runAddChartTask(void *groupUserData, void *taskUserData) { +static void runAddChartTask(void *groupUserData, void *taskUserData) +{ XA_PROFILE_START(packChartsAddChartsThread) auto boundingBox = (ThreadLocal<BoundingBox2D> *)groupUserData; auto args = (AddChartTaskArgs *)taskUserData; @@ -7753,8 +8138,10 @@ static void runAddChartTask(void *groupUserData, void *taskUserData) { XA_PROFILE_END(packChartsAddChartsThread) } -struct Atlas { - ~Atlas() { +struct Atlas +{ + ~Atlas() + { for (uint32_t i = 0; i < m_atlasImages.size(); i++) { m_atlasImages[i]->~AtlasImage(); XA_FREE(m_atlasImages[i]); @@ -7778,7 +8165,8 @@ struct Atlas { const Array<AtlasImage *> &getImages() const { return m_atlasImages; } float getUtilization(uint32_t atlas) const { return m_utilization[atlas]; } - void addCharts(TaskScheduler *taskScheduler, param::Atlas *paramAtlas) { + void addCharts(TaskScheduler *taskScheduler, param::Atlas *paramAtlas) + { // Count charts. uint32_t chartCount = 0; for (uint32_t i = 0; i < paramAtlas->meshCount(); i++) { @@ -7819,7 +8207,8 @@ struct Atlas { m_charts[i] = taskArgs[i].chart; } - void addUvMeshCharts(UvMeshInstance *mesh) { + void addUvMeshCharts(UvMeshInstance *mesh) + { // Copy texcoords from mesh. mesh->texcoords.resize(mesh->mesh->texcoords.size()); memcpy(mesh->texcoords.data(), mesh->mesh->texcoords.data(), mesh->texcoords.size() * sizeof(Vector2)); @@ -7882,7 +8271,8 @@ struct Atlas { } // Pack charts in the smallest possible rectangle. - bool packCharts(const PackOptions &options, ProgressFunc progressFunc, void *progressUserData) { + bool packCharts(const PackOptions &options, ProgressFunc progressFunc, void *progressUserData) + { if (progressFunc) { if (!progressFunc(ProgressCategory::PackCharts, 0, progressUserData)) return false; @@ -8116,7 +8506,8 @@ struct Atlas { int best_x = 0, best_y = 0; int best_cw = 0, best_ch = 0; int best_r = 0; - for (;;) { + for (;;) + { #if XA_DEBUG bool firstChartInBitImage = false; #endif @@ -8152,7 +8543,8 @@ struct Atlas { if (best_x + best_cw > atlasSizes[currentAtlas].x || best_y + best_ch > atlasSizes[currentAtlas].y) { for (uint32_t j = 0; j < chartStartPositions.size(); j++) chartStartPositions[j] = Vector2i(0, 0); - } else { + } + else { chartStartPositions[currentAtlas] = Vector2i(best_x, best_y); } } @@ -8240,7 +8632,8 @@ struct Atlas { } if (m_utilization.size() > 1) { XA_PRINT(" %u: %f%% utilization\n", i, m_utilization[i] * 100.0f); - } else { + } + else { XA_PRINT(" %f%% utilization\n", m_utilization[i] * 100.0f); } } @@ -8259,14 +8652,16 @@ struct Atlas { } private: - bool findChartLocation(const PackOptions &options, const Vector2i &startPosition, const BitImage *atlasBitImage, const BitImage *chartBitImage, const BitImage *chartBitImageRotated, int w, int h, int *best_x, int *best_y, int *best_w, int *best_h, int *best_r, uint32_t maxResolution) { + bool findChartLocation(const PackOptions &options, const Vector2i &startPosition, const BitImage *atlasBitImage, const BitImage *chartBitImage, const BitImage *chartBitImageRotated, int w, int h, int *best_x, int *best_y, int *best_w, int *best_h, int *best_r, uint32_t maxResolution) + { const int attempts = 4096; if (options.bruteForce || attempts >= w * h) return findChartLocation_bruteForce(options, startPosition, atlasBitImage, chartBitImage, chartBitImageRotated, w, h, best_x, best_y, best_w, best_h, best_r, maxResolution); return findChartLocation_random(options, atlasBitImage, chartBitImage, chartBitImageRotated, w, h, best_x, best_y, best_w, best_h, best_r, attempts, maxResolution); } - bool findChartLocation_bruteForce(const PackOptions &options, const Vector2i &startPosition, const BitImage *atlasBitImage, const BitImage *chartBitImage, const BitImage *chartBitImageRotated, int w, int h, int *best_x, int *best_y, int *best_w, int *best_h, int *best_r, uint32_t maxResolution) { + bool findChartLocation_bruteForce(const PackOptions &options, const Vector2i &startPosition, const BitImage *atlasBitImage, const BitImage *chartBitImage, const BitImage *chartBitImageRotated, int w, int h, int *best_x, int *best_y, int *best_w, int *best_h, int *best_r, uint32_t maxResolution) + { const int stepSize = options.blockAlign ? 4 : 1; int best_metric = INT_MAX; // Try two different orientations. @@ -8311,7 +8706,8 @@ private: return best_metric != INT_MAX; } - bool findChartLocation_random(const PackOptions &options, const BitImage *atlasBitImage, const BitImage *chartBitImage, const BitImage *chartBitImageRotated, int w, int h, int *best_x, int *best_y, int *best_w, int *best_h, int *best_r, int attempts, uint32_t maxResolution) { + bool findChartLocation_random(const PackOptions &options, const BitImage *atlasBitImage, const BitImage *chartBitImage, const BitImage *chartBitImageRotated, int w, int h, int *best_x, int *best_y, int *best_w, int *best_h, int *best_r, int attempts, uint32_t maxResolution) + { bool result = false; const int BLOCK_SIZE = 4; int best_metric = INT_MAX; @@ -8366,7 +8762,8 @@ private: return result; } - void addChart(BitImage *atlasBitImage, const BitImage *chartBitImage, const BitImage *chartBitImageRotated, int atlas_w, int atlas_h, int offset_x, int offset_y, int r) { + void addChart(BitImage *atlasBitImage, const BitImage *chartBitImage, const BitImage *chartBitImageRotated, int atlas_w, int atlas_h, int offset_x, int offset_y, int r) + { XA_DEBUG_ASSERT(r == 0 || r == 1); const BitImage *image = r == 0 ? chartBitImage : chartBitImageRotated; const int w = image->width(); @@ -8389,7 +8786,8 @@ private: } } - void bilinearExpand(const Chart *chart, BitImage *source, BitImage *dest, BitImage *destRotated, UniformGrid2 &boundaryEdgeGrid) const { + void bilinearExpand(const Chart *chart, BitImage *source, BitImage *dest, BitImage *destRotated, UniformGrid2 &boundaryEdgeGrid) const + { boundaryEdgeGrid.reset(chart->vertices, chart->indices); if (chart->boundaryEdges) { const uint32_t edgeCount = chart->boundaryEdges->size(); @@ -8444,11 +8842,13 @@ private: } } - struct DrawTriangleCallbackArgs { + struct DrawTriangleCallbackArgs + { BitImage *chartBitImage, *chartBitImageRotated; }; - static bool drawTriangleCallback(void *param, int x, int y) { + static bool drawTriangleCallback(void *param, int x, int y) + { auto args = (DrawTriangleCallbackArgs *)param; args->chartBitImage->set(x, y); if (args->chartBitImageRotated) @@ -8471,13 +8871,15 @@ private: } // namespace internal // Used to map triangulated polygons back to polygons. -struct MeshPolygonMapping { +struct MeshPolygonMapping +{ internal::Array<uint8_t> faceVertexCount; // Copied from MeshDecl::faceVertexCount. internal::Array<uint32_t> triangleToPolygonMap; // Triangle index (mesh face index) to polygon index. internal::Array<uint32_t> triangleToPolygonIndicesMap; // Triangle indices to polygon indices. }; -struct Context { +struct Context +{ Atlas atlas; internal::Progress *addMeshProgress = nullptr; internal::TaskGroupHandle addMeshTaskGroup; @@ -8492,14 +8894,16 @@ struct Context { bool uvMeshChartsComputed = false; }; -Atlas *Create() { +Atlas *Create() +{ Context *ctx = XA_NEW(internal::MemTag::Default, Context); memset(&ctx->atlas, 0, sizeof(Atlas)); ctx->taskScheduler = XA_NEW(internal::MemTag::Default, internal::TaskScheduler); return &ctx->atlas; } -static void DestroyOutputMeshes(Context *ctx) { +static void DestroyOutputMeshes(Context *ctx) +{ if (!ctx->atlas.meshes) return; for (int i = 0; i < (int)ctx->atlas.meshCount; i++) { @@ -8520,7 +8924,8 @@ static void DestroyOutputMeshes(Context *ctx) { ctx->atlas.meshes = nullptr; } -void Destroy(Atlas *atlas) { +void Destroy(Atlas *atlas) +{ XA_DEBUG_ASSERT(atlas); Context *ctx = (Context *)atlas; if (atlas->utilization) @@ -8567,14 +8972,15 @@ void Destroy(Atlas *atlas) { #endif } -static void runAddMeshTask(void *groupUserData, void *taskUserData) { +static void runAddMeshTask(void *groupUserData, void *taskUserData) +{ XA_PROFILE_START(addMeshThread) auto ctx = (Context *)groupUserData; auto mesh = (internal::Mesh *)taskUserData; internal::Progress *progress = ctx->addMeshProgress; if (progress->cancel) { XA_PROFILE_END(addMeshThread) - return; + return; } XA_PROFILE_START(addMeshCreateColocals) mesh->createColocals(); @@ -8587,32 +8993,37 @@ static void runAddMeshTask(void *groupUserData, void *taskUserData) { XA_PROFILE_END(addMeshThread) } -static internal::Vector3 DecodePosition(const MeshDecl &meshDecl, uint32_t index) { +static internal::Vector3 DecodePosition(const MeshDecl &meshDecl, uint32_t index) +{ XA_DEBUG_ASSERT(meshDecl.vertexPositionData); XA_DEBUG_ASSERT(meshDecl.vertexPositionStride > 0); return *((const internal::Vector3 *)&((const uint8_t *)meshDecl.vertexPositionData)[meshDecl.vertexPositionStride * index]); } -static internal::Vector3 DecodeNormal(const MeshDecl &meshDecl, uint32_t index) { +static internal::Vector3 DecodeNormal(const MeshDecl &meshDecl, uint32_t index) +{ XA_DEBUG_ASSERT(meshDecl.vertexNormalData); XA_DEBUG_ASSERT(meshDecl.vertexNormalStride > 0); return *((const internal::Vector3 *)&((const uint8_t *)meshDecl.vertexNormalData)[meshDecl.vertexNormalStride * index]); } -static internal::Vector2 DecodeUv(const MeshDecl &meshDecl, uint32_t index) { +static internal::Vector2 DecodeUv(const MeshDecl &meshDecl, uint32_t index) +{ XA_DEBUG_ASSERT(meshDecl.vertexUvData); XA_DEBUG_ASSERT(meshDecl.vertexUvStride > 0); return *((const internal::Vector2 *)&((const uint8_t *)meshDecl.vertexUvData)[meshDecl.vertexUvStride * index]); } -static uint32_t DecodeIndex(IndexFormat format, const void *indexData, int32_t offset, uint32_t i) { +static uint32_t DecodeIndex(IndexFormat format, const void *indexData, int32_t offset, uint32_t i) +{ XA_DEBUG_ASSERT(indexData); if (format == IndexFormat::UInt16) return uint16_t((int32_t)((const uint16_t *)indexData)[i] + offset); return uint32_t((int32_t)((const uint32_t *)indexData)[i] + offset); } -AddMeshError AddMesh(Atlas *atlas, const MeshDecl &meshDecl, uint32_t meshCountHint) { +AddMeshError AddMesh(Atlas *atlas, const MeshDecl &meshDecl, uint32_t meshCountHint) +{ XA_DEBUG_ASSERT(atlas); if (!atlas) { XA_PRINT_WARNING("AddMesh: atlas is null.\n"); @@ -8630,7 +9041,8 @@ AddMeshError AddMesh(Atlas *atlas, const MeshDecl &meshDecl, uint32_t meshCountH // Don't know how many times AddMesh will be called, so progress needs to adjusted each time. if (!ctx->addMeshProgress) { ctx->addMeshProgress = XA_NEW_ARGS(internal::MemTag::Default, internal::Progress, ProgressCategory::AddMesh, ctx->progressFunc, ctx->progressUserData, 1); - } else { + } + else { ctx->addMeshProgress->setMaxValue(internal::max(ctx->meshes.size() + 1, meshCountHint)); } XA_PROFILE_START(addMeshCopyData) @@ -8804,7 +9216,8 @@ AddMeshError AddMesh(Atlas *atlas, const MeshDecl &meshDecl, uint32_t meshCountH return AddMeshError::Success; } -void AddMeshJoin(Atlas *atlas) { +void AddMeshJoin(Atlas *atlas) +{ XA_DEBUG_ASSERT(atlas); if (!atlas) { XA_PRINT_WARNING("AddMeshJoin: atlas is null.\n"); @@ -8847,7 +9260,8 @@ void AddMeshJoin(Atlas *atlas) { } } -AddMeshError AddUvMesh(Atlas *atlas, const UvMeshDecl &decl) { +AddMeshError AddUvMesh(Atlas *atlas, const UvMeshDecl &decl) +{ XA_DEBUG_ASSERT(atlas); if (!atlas) { XA_PRINT_WARNING("AddUvMesh: atlas is null.\n"); @@ -8948,7 +9362,8 @@ AddMeshError AddUvMesh(Atlas *atlas, const UvMeshDecl &decl) { return AddMeshError::Success; } -void ComputeCharts(Atlas *atlas, ChartOptions options) { +void ComputeCharts(Atlas *atlas, ChartOptions options) +{ if (!atlas) { XA_PRINT_WARNING("ComputeCharts: atlas is null.\n"); return; @@ -9136,7 +9551,8 @@ void ComputeCharts(Atlas *atlas, ChartOptions options) { XA_PRINT_MEM_USAGE } -void PackCharts(Atlas *atlas, PackOptions packOptions) { +void PackCharts(Atlas *atlas, PackOptions packOptions) +{ // Validate arguments and context state. if (!atlas) { XA_PRINT_WARNING("PackCharts: atlas is null.\n"); @@ -9177,7 +9593,8 @@ void PackCharts(Atlas *atlas, PackOptions packOptions) { if (!ctx->uvMeshInstances.isEmpty()) { for (uint32_t i = 0; i < ctx->uvMeshInstances.size(); i++) packAtlas.addUvMeshCharts(ctx->uvMeshInstances[i]); - } else + } + else packAtlas.addCharts(ctx->taskScheduler, &ctx->paramAtlas); XA_PROFILE_END(packChartsAddCharts) XA_PROFILE_START(packCharts) @@ -9455,7 +9872,8 @@ void PackCharts(Atlas *atlas, PackOptions packOptions) { XA_PRINT_MEM_USAGE } -void Generate(Atlas *atlas, ChartOptions chartOptions, PackOptions packOptions) { +void Generate(Atlas *atlas, ChartOptions chartOptions, PackOptions packOptions) +{ if (!atlas) { XA_PRINT_WARNING("Generate: atlas is null.\n"); return; @@ -9469,7 +9887,8 @@ void Generate(Atlas *atlas, ChartOptions chartOptions, PackOptions packOptions) PackCharts(atlas, packOptions); } -void SetProgressCallback(Atlas *atlas, ProgressFunc progressFunc, void *progressUserData) { +void SetProgressCallback(Atlas *atlas, ProgressFunc progressFunc, void *progressUserData) +{ if (!atlas) { XA_PRINT_WARNING("SetProgressCallback: atlas is null.\n"); return; @@ -9479,17 +9898,20 @@ void SetProgressCallback(Atlas *atlas, ProgressFunc progressFunc, void *progress ctx->progressUserData = progressUserData; } -void SetAlloc(ReallocFunc reallocFunc, FreeFunc freeFunc) { +void SetAlloc(ReallocFunc reallocFunc, FreeFunc freeFunc) +{ internal::s_realloc = reallocFunc; internal::s_free = freeFunc; } -void SetPrint(PrintFunc print, bool verbose) { +void SetPrint(PrintFunc print, bool verbose) +{ internal::s_print = print; internal::s_printVerbose = verbose; } -const char *StringForEnum(AddMeshError error) { +const char *StringForEnum(AddMeshError error) +{ if (error == AddMeshError::Error) return "Unspecified error"; if (error == AddMeshError::IndexOutOfRange) @@ -9501,7 +9923,8 @@ const char *StringForEnum(AddMeshError error) { return "Success"; } -const char *StringForEnum(ProgressCategory category) { +const char *StringForEnum(ProgressCategory category) +{ if (category == ProgressCategory::AddMesh) return "Adding mesh(es)"; if (category == ProgressCategory::ComputeCharts) @@ -9529,76 +9952,93 @@ static_assert(sizeof(xatlas::PackOptions) == sizeof(xatlasPackOptions), "xatlasP extern "C" { #endif -xatlasAtlas *xatlasCreate() { +xatlasAtlas *xatlasCreate() +{ return (xatlasAtlas *)xatlas::Create(); } -void xatlasDestroy(xatlasAtlas *atlas) { +void xatlasDestroy(xatlasAtlas *atlas) +{ xatlas::Destroy((xatlas::Atlas *)atlas); } -xatlasAddMeshError xatlasAddMesh(xatlasAtlas *atlas, const xatlasMeshDecl *meshDecl, uint32_t meshCountHint) { +xatlasAddMeshError xatlasAddMesh(xatlasAtlas *atlas, const xatlasMeshDecl *meshDecl, uint32_t meshCountHint) +{ return (xatlasAddMeshError)xatlas::AddMesh((xatlas::Atlas *)atlas, *(const xatlas::MeshDecl *)meshDecl, meshCountHint); } -void xatlasAddMeshJoin(xatlasAtlas *atlas) { +void xatlasAddMeshJoin(xatlasAtlas *atlas) +{ xatlas::AddMeshJoin((xatlas::Atlas *)atlas); } -xatlasAddMeshError xatlasAddUvMesh(xatlasAtlas *atlas, const xatlasUvMeshDecl *decl) { +xatlasAddMeshError xatlasAddUvMesh(xatlasAtlas *atlas, const xatlasUvMeshDecl *decl) +{ return (xatlasAddMeshError)xatlas::AddUvMesh((xatlas::Atlas *)atlas, *(const xatlas::UvMeshDecl *)decl); } -void xatlasComputeCharts(xatlasAtlas *atlas, const xatlasChartOptions *chartOptions) { +void xatlasComputeCharts(xatlasAtlas *atlas, const xatlasChartOptions *chartOptions) +{ xatlas::ComputeCharts((xatlas::Atlas *)atlas, chartOptions ? *(xatlas::ChartOptions *)chartOptions : xatlas::ChartOptions()); } -void xatlasPackCharts(xatlasAtlas *atlas, const xatlasPackOptions *packOptions) { +void xatlasPackCharts(xatlasAtlas *atlas, const xatlasPackOptions *packOptions) +{ xatlas::PackCharts((xatlas::Atlas *)atlas, packOptions ? *(xatlas::PackOptions *)packOptions : xatlas::PackOptions()); } -void xatlasGenerate(xatlasAtlas *atlas, const xatlasChartOptions *chartOptions, const xatlasPackOptions *packOptions) { +void xatlasGenerate(xatlasAtlas *atlas, const xatlasChartOptions *chartOptions, const xatlasPackOptions *packOptions) +{ xatlas::Generate((xatlas::Atlas *)atlas, chartOptions ? *(xatlas::ChartOptions *)chartOptions : xatlas::ChartOptions(), packOptions ? *(xatlas::PackOptions *)packOptions : xatlas::PackOptions()); } -void xatlasSetProgressCallback(xatlasAtlas *atlas, xatlasProgressFunc progressFunc, void *progressUserData) { +void xatlasSetProgressCallback(xatlasAtlas *atlas, xatlasProgressFunc progressFunc, void *progressUserData) +{ xatlas::ProgressFunc pf; *(void **)&pf = (void *)progressFunc; xatlas::SetProgressCallback((xatlas::Atlas *)atlas, pf, progressUserData); } -void xatlasSetAlloc(xatlasReallocFunc reallocFunc, xatlasFreeFunc freeFunc) { +void xatlasSetAlloc(xatlasReallocFunc reallocFunc, xatlasFreeFunc freeFunc) +{ xatlas::SetAlloc((xatlas::ReallocFunc)reallocFunc, (xatlas::FreeFunc)freeFunc); } -void xatlasSetPrint(xatlasPrintFunc print, bool verbose) { +void xatlasSetPrint(xatlasPrintFunc print, bool verbose) +{ xatlas::SetPrint((xatlas::PrintFunc)print, verbose); } -const char *xatlasAddMeshErrorString(xatlasAddMeshError error) { +const char *xatlasAddMeshErrorString(xatlasAddMeshError error) +{ return xatlas::StringForEnum((xatlas::AddMeshError)error); } -const char *xatlasProgressCategoryString(xatlasProgressCategory category) { +const char *xatlasProgressCategoryString(xatlasProgressCategory category) +{ return xatlas::StringForEnum((xatlas::ProgressCategory)category); } -void xatlasMeshDeclInit(xatlasMeshDecl *meshDecl) { +void xatlasMeshDeclInit(xatlasMeshDecl *meshDecl) +{ xatlas::MeshDecl init; memcpy(meshDecl, &init, sizeof(init)); } -void xatlasUvMeshDeclInit(xatlasUvMeshDecl *uvMeshDecl) { +void xatlasUvMeshDeclInit(xatlasUvMeshDecl *uvMeshDecl) +{ xatlas::UvMeshDecl init; memcpy(uvMeshDecl, &init, sizeof(init)); } -void xatlasChartOptionsInit(xatlasChartOptions *chartOptions) { +void xatlasChartOptionsInit(xatlasChartOptions *chartOptions) +{ xatlas::ChartOptions init; memcpy(chartOptions, &init, sizeof(init)); } -void xatlasPackOptionsInit(xatlasPackOptions *packOptions) { +void xatlasPackOptionsInit(xatlasPackOptions *packOptions) +{ xatlas::PackOptions init; memcpy(packOptions, &init, sizeof(init)); } diff --git a/thirdparty/xatlas/xatlas.h b/thirdparty/xatlas/xatlas.h index fc40d9d49c..d66a96db21 100644 --- a/thirdparty/xatlas/xatlas.h +++ b/thirdparty/xatlas/xatlas.h @@ -36,7 +36,8 @@ Copyright NVIDIA Corporation 2006 -- Ignacio Castano <icastano@nvidia.com> namespace xatlas { -enum class ChartType { +enum class ChartType +{ Planar, Ortho, LSCM, @@ -45,7 +46,8 @@ enum class ChartType { }; // A group of connected faces, belonging to a single atlas. -struct Chart { +struct Chart +{ uint32_t *faceArray; uint32_t atlasIndex; // Sub-atlas index. uint32_t faceCount; @@ -54,7 +56,8 @@ struct Chart { }; // Output vertex. -struct Vertex { +struct Vertex +{ int32_t atlasIndex; // Sub-atlas index. -1 if the vertex doesn't exist in any atlas. int32_t chartIndex; // -1 if the vertex doesn't exist in any chart. float uv[2]; // Not normalized - values are in Atlas width and height range. @@ -62,7 +65,8 @@ struct Vertex { }; // Output mesh. -struct Mesh { +struct Mesh +{ Chart *chartArray; uint32_t *indexArray; Vertex *vertexArray; @@ -77,7 +81,8 @@ static const uint32_t kImageIsBilinearBit = 0x40000000; static const uint32_t kImageIsPaddingBit = 0x20000000; // Empty on creation. Populated after charts are packed. -struct Atlas { +struct Atlas +{ uint32_t *image; Mesh *meshes; // The output meshes, corresponding to each AddMesh call. float *utilization; // Normalized atlas texel utilization array. E.g. a value of 0.8 means 20% empty space. atlasCount in length. @@ -94,13 +99,15 @@ Atlas *Create(); void Destroy(Atlas *atlas); -enum class IndexFormat { +enum class IndexFormat +{ UInt16, UInt32 }; // Input mesh declaration. -struct MeshDecl { +struct MeshDecl +{ const void *vertexPositionData = nullptr; const void *vertexNormalData = nullptr; // optional const void *vertexUvData = nullptr; // optional. The input UVs are provided as a hint to the chart generator. @@ -131,7 +138,8 @@ struct MeshDecl { float epsilon = 1.192092896e-07F; }; -enum class AddMeshError { +enum class AddMeshError +{ Success, // No error. Error, // Unspecified error. IndexOutOfRange, // An index is >= MeshDecl vertexCount. @@ -145,7 +153,8 @@ AddMeshError AddMesh(Atlas *atlas, const MeshDecl &meshDecl, uint32_t meshCountH // Wait for AddMesh async processing to finish. ComputeCharts / Generate call this internally. void AddMeshJoin(Atlas *atlas); -struct UvMeshDecl { +struct UvMeshDecl +{ const void *vertexUvData = nullptr; const void *indexData = nullptr; // optional const uint32_t *faceMaterialData = nullptr; // Optional. Overlapping UVs should be assigned a different material. Must be indexCount / 3 in length. @@ -161,7 +170,8 @@ AddMeshError AddUvMesh(Atlas *atlas, const UvMeshDecl &decl); // Custom parameterization function. texcoords initial values are an orthogonal parameterization. typedef void (*ParameterizeFunc)(const float *positions, float *texcoords, uint32_t vertexCount, const uint32_t *indices, uint32_t indexCount); -struct ChartOptions { +struct ChartOptions +{ ParameterizeFunc paramFunc = nullptr; float maxChartArea = 0.0f; // Don't grow charts to be larger than this. 0 means no limit. @@ -184,7 +194,8 @@ struct ChartOptions { // Call after all AddMesh calls. Can be called multiple times to recompute charts with different options. void ComputeCharts(Atlas *atlas, ChartOptions options = ChartOptions()); -struct PackOptions { +struct PackOptions +{ // Charts larger than this will be scaled down. 0 means no limit. uint32_t maxChartSize = 0; @@ -227,7 +238,8 @@ void PackCharts(Atlas *atlas, PackOptions packOptions = PackOptions()); void Generate(Atlas *atlas, ChartOptions chartOptions = ChartOptions(), PackOptions packOptions = PackOptions()); // Progress tracking. -enum class ProgressCategory { +enum class ProgressCategory +{ AddMesh, ComputeCharts, PackCharts, |