Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐞 get() method in Decoder::decompress s/b in->get #117

Closed
pete4abw opened this issue Apr 28, 2023 · 2 comments
Closed

🐞 get() method in Decoder::decompress s/b in->get #117

pete4abw opened this issue Apr 28, 2023 · 2 comments
Assignees
Labels

Comments

@pete4abw
Copy link
Owner

lrzip-next Version

ZPAQ 7.15 library

lrzip-next command line

N/A

What happened?

For the longest time, ZPAQ could not decompress using zpaq levels 1 and 2. Only 3,4, and 5 levels were set in util.c. ZPAQ Decoder would report an error on decompression

Decompressing...
ZPAQ Error: missing end of segment marker:

Even though the archive was compressed properly.

What was expected behavior?

ZPAQ compression should be able to utilize all 5 levels.

Steps to reproduce

Modify util.c setup_overhead() function to use all 5 zpaq levels. Recompile, then encode and try and decode using level 1.

diff --git a/src/util.c b/src/util.c
index b8ad6d3..bb84c98 100644
--- a/src/util.c
+++ b/src/util.c
@@ -141,8 +141,8 @@ void setup_overhead(rzip_control *control)
                 * where default is 16KB */
                control->overhead = ((i64)control->dictSize * 23 / 2) + (6 * ONE_MB) + 16384;
        } else if (ZPAQ_COMPRESS) {
-               control->zpaq_level = (control->compression_level < 4 ? 3 :
-                                       (control->compression_level < 8 ? 4 : 5));
+               control->zpaq_level = control->compression_level * 5 / 9;
+               if (!control->zpaq_level) control->zpaq_level = 1;
                if (control->zpaq_bs == 0) {
                        switch (control->compression_level) {
                        case 1:

The fix will be in libzpaq.cpp. A simple omission to utilize the custom Reader class used by lrzip-next.

diff --git a/src/lib/libzpaq/libzpaq.cpp b/src/lib/libzpaq/libzpaq.cpp
index 7bf3673..d343f93 100644
--- a/src/lib/libzpaq/libzpaq.cpp
+++ b/src/lib/libzpaq/libzpaq.cpp
@@ -2148,7 +2148,7 @@ int Decoder::decompress() {
   }
   else {
     if (curr==0) {
-      for (int i=0; i<4; ++i) curr=curr<<8|get();
+      for (int i=0; i<4; ++i) curr=curr<<8|in->get();
       if (curr==0) return -1;
     }
     --curr;

Relevant log output

No response

Please provide system details

OS Distro: Slackware
Kernel Version (uname -a): 6.3
System ram (free -h): lots

Additional Context

After the changes...

Decompressing...
100% 9870.00 / 9870.00 KB ZPAQ 1:100% 2:100%
Average DeCompression Speed: 9.000MB/s
SHA256:79e741a75ce4c259e0d72048a064829d34c691335a5adbf4588330c3b52e9307
[OK] - 10,106,880 bytes

Total time: 00:00:00.08

@pete4abw pete4abw added the bug label Apr 28, 2023
@pete4abw pete4abw self-assigned this Apr 28, 2023
@pete4abw
Copy link
Owner Author

Fixed in whats-next branch. Will migrate to main soon.

@pete4abw
Copy link
Owner Author

Fixed in lzma-22.01 v0.11.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant