Skip to content

Commit

Permalink
Replaced std::stable_sort with ska_sort.
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyaGrebnov committed Jan 8, 2022
1 parent 81718b4 commit 4255c0d
Show file tree
Hide file tree
Showing 8 changed files with 1,527 additions and 9 deletions.
3 changes: 2 additions & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

-- This program is based on (at least) the work of

Michael Maniscalco, Atsushi Komiya, Pochang Chen and Surya Kandau.
Michael Maniscalco, Atsushi Komiya, Pochang Chen,
Surya Kandau and Malte Skarupke.


3 changes: 3 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
* 2022-01-08 : Version 0.2.1
* Replaced std::stable_sort with ska_sort.

* 2022-01-05 : Version 0.2
* Improved compression.
* Reduced memory usage from 15x to 13x.
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Copyright (c) 2021-2022 Ilya Grebnov <[email protected]>
The libsais is released under the [GNU General Public License](LICENSE "GNU General Public License")

## Changes
* 2022-01-08 : Version 0.2.1
* Replaced std::stable_sort with ska_sort.
* 2022-01-05 : Version 0.2
* Improved compression.
* Reduced memory usage from 15x to 13x.
Expand Down
66 changes: 66 additions & 0 deletions THIRD-PARTY-NOTICES
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
The bsc-m03 uses third-party libraries or other resources that may
be distributed under licenses different than the bsc-m03 software.

The attached notices are provided for information only.

License notice for 'libbsc' library
-----------------------------------

Copyright (c) 2009-2021 Ilya Grebnov <[email protected]>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

License notice for 'hutucker' library
-------------------------------------

/*
* Linearithmic Hu-Tucker Coding.
* Copyright (C) 2018 Pochang Chen
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

License notice for 'libsais' library
------------------------------------

Copyright (c) 2021-2022 Ilya Grebnov <[email protected]>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

License notice for 'ska_sort' library
-------------------------------------

// Copyright Malte Skarupke 2016.
// Distributed under the Boost Software License, Version 1.0.
// (See http://www.boost.org/LICENSE_1_0.txt)
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.0
0.2.1
2 changes: 1 addition & 1 deletion bsc-m03.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ static int print_usage()

int main(int argc, const char * argv[])
{
fprintf(stdout, "bsc-m03 is experimental block sorting compressor. Version 0.2.0 (05 January 2022).\n");
fprintf(stdout, "bsc-m03 is experimental block sorting compressor. Version 0.2.1 (08 January 2022).\n");
fprintf(stdout, "Copyright (c) 2021-2022 Ilya Grebnov <[email protected]>. ABSOLUTELY NO WARRANTY.\n");
fprintf(stdout, "This program is based on (at least) the work of Michael Maniscalco (see AUTHORS).\n\n");

Expand Down
13 changes: 7 additions & 6 deletions m03_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ This file is a part of bsc-m03 project.
#include "common/rangecoder.h"

#include "hutucker/hu-tucker.h"
#include "ska_sort/ska_sort.hpp"

#include "m03_model.h"

Expand Down Expand Up @@ -68,7 +69,7 @@ typedef struct offset_queue

INLINE void reset() { this->count = 0; }

INLINE void sort() { std::stable_sort(this->offsets, this->offsets + this->count); }
INLINE void sort() { ska_sort(this->offsets, this->offsets + this->count); }

NOINLINE int32_t * resize()
{
Expand Down Expand Up @@ -479,7 +480,7 @@ class m03_parser: m03_model

if (this->mode == m03_mode::encoding)
{
if (left_interval_size <= parent_interval_size - left_interval_size)
if (left_interval_size <= right_interval_size)
{
int32_t parent_total_symbols = parent_interval_size;

Expand All @@ -495,9 +496,9 @@ class m03_parser: m03_model
assert(parent_total_symbols > 0); parent_context[0].count = parent_total_symbols;
left_frequencies[parent_context[0].symbol] = 0;

for (int32_t p = parent_context_offset; p < right_context_offset; ++p) { left_frequencies[L[p]]++; }

left_frequencies[0] -= ((uint32_t)(this->primary_index - parent_context_offset) < (uint32_t)left_interval_size);

for (int32_t p = parent_context_offset; p < parent_context_offset + left_interval_size; ++p) { left_frequencies[L[p]]++; }
}
else
{
Expand All @@ -515,9 +516,9 @@ class m03_parser: m03_model
assert(parent_total_symbols > 0); parent_context[0].count = parent_total_symbols;
left_frequencies[parent_context[0].symbol] = parent_total_symbols;

for (int32_t p = right_context_offset; p < parent_context_offset + parent_interval_size; ++p) { left_frequencies[L[p]]--; }

left_frequencies[0] += ((uint32_t)(this->primary_index - right_context_offset) < (uint32_t)right_interval_size);

for (int32_t p = right_context_offset; p < right_context_offset + right_interval_size; ++p) { left_frequencies[L[p]]--; }
}
}
else
Expand Down
Loading

0 comments on commit 4255c0d

Please sign in to comment.