Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
Heatshrink
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
Container 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
Grant Kim
Heatshrink
Commits
58aeb64a
Commit
58aeb64a
authored
11 years ago
by
Scott Vokes
Browse files
Options
Downloads
Patches
Plain Diff
Add comments for decoder_poll states
parent
4ac7e292
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
heatshrink_decoder.c
+12
-11
12 additions, 11 deletions
heatshrink_decoder.c
with
12 additions
and
11 deletions
heatshrink_decoder.c
+
12
−
11
View file @
58aeb64a
...
...
@@ -2,16 +2,17 @@
#include
<string.h>
#include
"heatshrink_decoder.h"
/* States for the polling state machine. */
typedef
enum
{
HSDS_EMPTY
,
HSDS_INPUT_AVAILABLE
,
HSDS_YIELD_LITERAL
,
HSDS_BACKREF_INDEX_MSB
,
HSDS_BACKREF_INDEX_LSB
,
HSDS_BACKREF_COUNT_MSB
,
HSDS_BACKREF_COUNT_LSB
,
HSDS_YIELD_BACKREF
,
HSDS_CHECK_FOR_MORE_INPUT
,
HSDS_EMPTY
,
/* no input to process */
HSDS_INPUT_AVAILABLE
,
/* new input, completely unprocessed */
HSDS_YIELD_LITERAL
,
/* ready to yield literal byte */
HSDS_BACKREF_INDEX_MSB
,
/* most significant byte of index */
HSDS_BACKREF_INDEX_LSB
,
/* least significant byte of index */
HSDS_BACKREF_COUNT_MSB
,
/* most significant byte of count */
HSDS_BACKREF_COUNT_LSB
,
/* least significant byte of count */
HSDS_YIELD_BACKREF
,
/* ready to yield back-reference */
HSDS_CHECK_FOR_MORE_INPUT
,
/* check if input is exhausted */
}
HSD_state
;
#include
<assert.h>
...
...
@@ -250,7 +251,7 @@ static HSD_state st_backref_count_msb(heatshrink_decoder *hsd) {
uint8_t
br_bit_ct
=
BACKREF_COUNT_BITS
(
hsd
);
ASSERT
(
br_bit_ct
>
8
);
uint32_t
bits
=
get_bits
(
hsd
,
br_bit_ct
-
8
);
LOG
(
"-- backref count, got 0x%04x (+1)
\n
"
,
bits
);
LOG
(
"-- backref count
(msb)
, got 0x%04x (+1)
\n
"
,
bits
);
if
(
bits
==
(
uint32_t
)
-
1
)
return
HSDS_BACKREF_COUNT_MSB
;
hsd
->
output_count
=
bits
<<
8
;
return
HSDS_BACKREF_COUNT_LSB
;
...
...
@@ -259,7 +260,7 @@ static HSD_state st_backref_count_msb(heatshrink_decoder *hsd) {
static
HSD_state
st_backref_count_lsb
(
heatshrink_decoder
*
hsd
)
{
uint8_t
br_bit_ct
=
BACKREF_COUNT_BITS
(
hsd
);
uint32_t
bits
=
get_bits
(
hsd
,
br_bit_ct
<
8
?
br_bit_ct
:
8
);
LOG
(
"-- backref count, got 0x%04x (+1)
\n
"
,
bits
);
LOG
(
"-- backref count
(lsb)
, got 0x%04x (+1)
\n
"
,
bits
);
if
(
bits
==
(
uint32_t
)
-
1
)
return
HSDS_BACKREF_COUNT_LSB
;
hsd
->
output_count
|=
bits
;
hsd
->
output_count
++
;
...
...
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