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
480ceca5
Commit
480ceca5
authored
4 years ago
by
Birte Kristina Friesel
Browse files
Options
Downloads
Patches
Plain Diff
deflate: return number of bytes written to output
parent
9a8071e7
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/lib/deflate.h
+2
-2
2 additions, 2 deletions
include/lib/deflate.h
src/app/deflatetest/main.cc
+1
-1
1 addition, 1 deletion
src/app/deflatetest/main.cc
src/lib/deflate.cc
+21
-12
21 additions, 12 deletions
src/lib/deflate.cc
with
24 additions
and
15 deletions
include/lib/deflate.h
+
2
−
2
View file @
480ceca5
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
#define DEFLATE_ERR_FCHECK (-7)
#define DEFLATE_ERR_FCHECK (-7)
#define DEFLATE_ERR_NLEN (-8)
#define DEFLATE_ERR_NLEN (-8)
int
8
_t
deflate
(
unsigned
char
*
input_buf
,
uint16_t
input_len
,
int
16
_t
deflate
(
unsigned
char
*
input_buf
,
uint16_t
input_len
,
unsigned
char
*
output_buf
,
uint16_t
output_len
);
unsigned
char
*
output_buf
,
uint16_t
output_len
);
int
8
_t
deflate_zlib
(
unsigned
char
*
input_buf
,
uint16_t
input_len
,
int
16
_t
deflate_zlib
(
unsigned
char
*
input_buf
,
uint16_t
input_len
,
unsigned
char
*
output_buf
,
uint16_t
output_len
);
unsigned
char
*
output_buf
,
uint16_t
output_len
);
This diff is collapsed.
Click to expand it.
src/app/deflatetest/main.cc
+
1
−
1
View file @
480ceca5
...
@@ -51,7 +51,7 @@ int main(void)
...
@@ -51,7 +51,7 @@ int main(void)
for
(
uint8_t
i
=
0
;
i
<
5
;
i
++
)
{
for
(
uint8_t
i
=
0
;
i
<
5
;
i
++
)
{
counter
.
start
();
counter
.
start
();
int
8
_t
ret
=
deflate_zlib
((
unsigned
char
*
)
deflate_input
,
sizeof
(
deflate_input
),
deflate_output
,
sizeof
(
deflate_output
));
int
16
_t
ret
=
deflate_zlib
((
unsigned
char
*
)
deflate_input
,
sizeof
(
deflate_input
),
deflate_output
,
sizeof
(
deflate_output
));
counter
.
stop
();
counter
.
stop
();
kout
<<
"deflate returned "
<<
ret
<<
endl
;
kout
<<
"deflate returned "
<<
ret
<<
endl
;
kout
<<
"Output: "
<<
(
char
*
)
deflate_output
<<
endl
;
kout
<<
"Output: "
<<
(
char
*
)
deflate_output
<<
endl
;
...
...
This diff is collapsed.
Click to expand it.
src/lib/deflate.cc
+
21
−
12
View file @
480ceca5
...
@@ -400,11 +400,12 @@ static int8_t deflate_dynamic_huffman()
...
@@ -400,11 +400,12 @@ static int8_t deflate_dynamic_huffman()
deflate_lld_lengths
+
hlit
,
hdist
);
deflate_lld_lengths
+
hlit
,
hdist
);
}
}
int
8
_t
deflate
(
unsigned
char
*
input_buf
,
uint16_t
input_len
,
int
16
_t
deflate
(
unsigned
char
*
input_buf
,
uint16_t
input_len
,
unsigned
char
*
output_buf
,
uint16_t
output_len
)
unsigned
char
*
output_buf
,
uint16_t
output_len
)
{
{
uint8_t
is_final
=
input_buf
[
0
]
&
0x01
;
uint8_t
is_final
=
input_buf
[
0
]
&
0x01
;
uint8_t
block_type
=
(
input_buf
[
0
]
&
0x06
)
>>
1
;
uint8_t
block_type
=
(
input_buf
[
0
]
&
0x06
)
>>
1
;
int8_t
ret
;
#ifdef DEFLATE_DEBUG
#ifdef DEFLATE_DEBUG
kout
<<
"is_final="
<<
is_final
<<
" block_type="
<<
block_type
<<
endl
;
kout
<<
"is_final="
<<
is_final
<<
" block_type="
<<
block_type
<<
endl
;
#endif
#endif
...
@@ -416,20 +417,28 @@ int8_t deflate(unsigned char *input_buf, uint16_t input_len,
...
@@ -416,20 +417,28 @@ int8_t deflate(unsigned char *input_buf, uint16_t input_len,
deflate_output_now
=
output_buf
;
deflate_output_now
=
output_buf
;
deflate_output_end
=
output_buf
+
output_len
;
deflate_output_end
=
output_buf
+
output_len
;
if
(
block_type
==
0
)
{
switch
(
block_type
)
{
return
deflate_uncompressed
();
case
0
:
ret
=
deflate_uncompressed
();
break
;
case
1
:
ret
=
deflate_static_huffman
();
break
;
case
2
:
ret
=
deflate_dynamic_huffman
();
break
;
default:
return
DEFLATE_ERR_BLOCK
;
}
}
if
(
block_type
==
1
)
{
return
deflate_static_huffman
();
if
(
ret
<
0
)
{
}
return
ret
;
if
(
block_type
==
2
)
{
return
deflate_dynamic_huffman
();
}
}
return
DEFLATE_ERR_BLOCK
;
return
deflate_output_now
-
output_buf
;
}
}
int
8
_t
deflate_zlib
(
unsigned
char
*
input_buf
,
uint16_t
input_len
,
int
16
_t
deflate_zlib
(
unsigned
char
*
input_buf
,
uint16_t
input_len
,
unsigned
char
*
output_buf
,
uint16_t
output_len
)
unsigned
char
*
output_buf
,
uint16_t
output_len
)
{
{
if
(
input_len
<
4
)
{
if
(
input_len
<
4
)
{
...
@@ -457,11 +466,11 @@ int8_t deflate_zlib(unsigned char *input_buf, uint16_t input_len,
...
@@ -457,11 +466,11 @@ int8_t deflate_zlib(unsigned char *input_buf, uint16_t input_len,
return
DEFLATE_ERR_FCHECK
;
return
DEFLATE_ERR_FCHECK
;
}
}
u
int
8
_t
ret
=
int
16
_t
ret
=
deflate
(
input_buf
+
2
,
input_len
-
2
,
output_buf
,
output_len
);
deflate
(
input_buf
+
2
,
input_len
-
2
,
output_buf
,
output_len
);
#ifdef DEFLATE_CHECKSUM
#ifdef DEFLATE_CHECKSUM
if
(
ret
=
=
0
)
{
if
(
ret
>
=
0
)
{
uint16_t
deflate_s1
=
1
;
uint16_t
deflate_s1
=
1
;
uint16_t
deflate_s2
=
0
;
uint16_t
deflate_s2
=
0
;
...
...
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