Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
multipass
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
derf
multipass
Commits
252524c2
Commit
252524c2
authored
4 years ago
by
Birte Kristina Friesel
Browse files
Options
Downloads
Patches
Plain Diff
udeflate: add support for uncompressed blocks
parent
1a899839
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/lib/udeflate.h
+1
-0
1 addition, 0 deletions
include/lib/udeflate.h
src/lib/udeflate.cc
+30
-3
30 additions, 3 deletions
src/lib/udeflate.cc
with
31 additions
and
3 deletions
include/lib/udeflate.h
+
1
−
0
View file @
252524c2
...
...
@@ -13,6 +13,7 @@
#define UDEFLATE_ERR_CHECKSUM (-5)
#define UDEFLATE_ERR_OUTPUT_LENGTH (-6)
#define UDEFLATE_ERR_FCHECK (-7)
#define UDEFLATE_ERR_NLEN (-8)
int8_t
udeflate
(
unsigned
char
*
input_buf
,
uint16_t
input_len
,
unsigned
char
*
output_buf
,
uint16_t
output_len
);
...
...
This diff is collapsed.
Click to expand it.
src/lib/udeflate.cc
+
30
−
3
View file @
252524c2
...
...
@@ -279,6 +279,29 @@ static int8_t udeflate_huffman(uint8_t * ll_lengths, uint16_t ll_size,
}
}
static
int8_t
udeflate_uncompressed
()
{
udeflate_input_now
++
;
uint16_t
len
=
((
uint16_t
)
udeflate_input_now
[
1
]
<<
8
)
+
udeflate_input_now
[
0
];
uint16_t
nlen
=
((
uint16_t
)
udeflate_input_now
[
3
]
<<
8
)
+
udeflate_input_now
[
2
];
if
(
len
&
nlen
)
{
return
UDEFLATE_ERR_NLEN
;
}
udeflate_input_now
+=
4
;
if
(
udeflate_input_now
+
len
>
udeflate_input_end
)
{
return
UDEFLATE_ERR_INPUT_LENGTH
;
}
if
(
udeflate_output_now
+
len
>
udeflate_output_end
)
{
return
UDEFLATE_ERR_OUTPUT_LENGTH
;
}
for
(
uint16_t
i
=
0
;
i
<
len
;
i
++
)
{
*
(
udeflate_output_now
++
)
=
*
(
udeflate_input_now
++
);
}
return
0
;
}
static
int8_t
udeflate_static_huffman
()
{
uint16_t
i
;
...
...
@@ -389,6 +412,9 @@ int8_t udeflate(unsigned char *input_buf, uint16_t input_len,
udeflate_output_now
=
output_buf
;
udeflate_output_end
=
output_buf
+
output_len
;
if
(
block_type
==
0
)
{
return
udeflate_uncompressed
();
}
if
(
block_type
==
1
)
{
return
udeflate_static_huffman
();
}
...
...
@@ -406,12 +432,13 @@ int8_t udeflate_zlib(unsigned char *input_buf, uint16_t input_len,
return
UDEFLATE_ERR_INPUT_LENGTH
;
}
uint8_t
zlib_method
=
input_buf
[
0
]
&
0x0f
;
uint16_t
zlib_window_size
=
1
<<
(
8
+
((
input_buf
[
0
]
&
0xf0
)
>>
4
));
uint8_t
zlib_flags
=
input_buf
[
1
];
#ifdef UDEFLATE_DEBUG
kout
<<
"zlib_method="
<<
zlib_method
<<
endl
;
kout
<<
"zlib_window_size="
<<
zlib_window_size
<<
endl
;
kout
<<
"zlib_window_size="
<<
((
uint16_t
)
1
<<
(
8
+
((
input_buf
[
0
]
&
0xf0
)
>>
4
)))
<<
endl
;
#endif
if
(
zlib_method
!=
8
)
{
...
...
@@ -422,7 +449,7 @@ int8_t udeflate_zlib(unsigned char *input_buf, uint16_t input_len,
return
UDEFLATE_ERR_FDICT
;
}
if
((((
uint16_t
)
input_buf
[
0
]
<<
8
)
|
input_buf
[
1
])
%
31
)
{
if
((((
uint16_t
)
input_buf
[
0
]
<<
8
)
|
input_buf
[
1
])
%
31
)
{
return
UDEFLATE_ERR_FCHECK
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment