Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
34e5a7cd
Commit
34e5a7cd
authored
Aug 29, 2021
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Zopfli is not always smaller
parent
7343c195
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
1 deletion
+16
-1
bootimg.cpp
native/jni/magiskboot/bootimg.cpp
+8
-0
compress.cpp
native/jni/magiskboot/compress.cpp
+3
-1
format.cpp
native/jni/magiskboot/format.cpp
+4
-0
format.hpp
native/jni/magiskboot/format.hpp
+1
-0
No files found.
native/jni/magiskboot/bootimg.cpp
View file @
34e5a7cd
...
...
@@ -541,6 +541,14 @@ void repack(const char *src_img, const char *out_img, bool skip_comp) {
}
else
{
hdr
->
kernel_size
()
=
xwrite
(
fd
,
raw_buf
,
raw_size
);
}
if
(
boot
.
flags
[
ZIMAGE_KERNEL
]
&&
boot
.
k_fmt
==
GZIP
&&
hdr
->
kernel_size
()
>
boot
.
hdr
->
kernel_size
())
{
// Revert and try zipfoli
ftruncate
(
fd
,
lseek
(
fd
,
-
hdr
->
kernel_size
(),
SEEK_CUR
));
hdr
->
kernel_size
()
=
compress
(
ZOPFLI
,
fd
,
raw_buf
,
raw_size
);
}
munmap
(
raw_buf
,
raw_size
);
}
if
(
boot
.
flags
[
ZIMAGE_KERNEL
])
{
...
...
native/jni/magiskboot/compress.cpp
View file @
34e5a7cd
...
...
@@ -624,8 +624,9 @@ stream_ptr get_encoder(format_t type, stream_ptr &&base) {
return
make_unique
<
LZ4_encoder
>
(
std
::
move
(
base
),
false
);
case
LZ4_LG
:
return
make_unique
<
LZ4_encoder
>
(
std
::
move
(
base
),
true
);
case
GZIP
:
case
ZOPFLI
:
return
make_unique
<
zopfli_encoder
>
(
std
::
move
(
base
));
case
GZIP
:
default:
return
make_unique
<
gz_encoder
>
(
std
::
move
(
base
));
}
...
...
@@ -643,6 +644,7 @@ stream_ptr get_decoder(format_t type, stream_ptr &&base) {
case
LZ4_LEGACY
:
case
LZ4_LG
:
return
make_unique
<
LZ4_decoder
>
(
std
::
move
(
base
));
case
ZOPFLI
:
case
GZIP
:
default:
return
make_unique
<
gz_decoder
>
(
std
::
move
(
base
));
...
...
native/jni/magiskboot/format.cpp
View file @
34e5a7cd
...
...
@@ -47,6 +47,8 @@ const char *Fmt2Name::operator[](format_t fmt) {
switch
(
fmt
)
{
case
GZIP
:
return
"gzip"
;
case
ZOPFLI
:
return
"zopfli"
;
case
LZOP
:
return
"lzop"
;
case
XZ
:
...
...
@@ -73,6 +75,7 @@ const char *Fmt2Name::operator[](format_t fmt) {
const
char
*
Fmt2Ext
::
operator
[](
format_t
fmt
)
{
switch
(
fmt
)
{
case
GZIP
:
case
ZOPFLI
:
return
".gz"
;
case
LZOP
:
return
".lzo"
;
...
...
@@ -96,6 +99,7 @@ const char *Fmt2Ext::operator[](format_t fmt) {
format_t
Name2Fmt
::
operator
[](
std
::
string_view
name
)
{
if
(
0
)
{}
CHECK
(
"gzip"
,
GZIP
)
CHECK
(
"zopfli"
,
ZOPFLI
)
CHECK
(
"xz"
,
XZ
)
CHECK
(
"lzma"
,
LZMA
)
CHECK
(
"bzip2"
,
BZIP2
)
...
...
native/jni/magiskboot/format.hpp
View file @
34e5a7cd
...
...
@@ -12,6 +12,7 @@ typedef enum {
BLOB
,
/* Compression formats */
GZIP
,
ZOPFLI
,
XZ
,
LZMA
,
BZIP2
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment