Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Mathis Rosenhauer
libaec
Commits
4add047d
Commit
4add047d
authored
Jul 12, 2017
by
Mathis Rosenhauer
Browse files
Limit scope
parent
6cd141a9
Changes
10
Hide whitespace changes
Inline
Side-by-side
Makefile.am
View file @
4add047d
ACLOCAL_AMFLAGS
=
-I
m4
SUBDIRS
=
src tests
EXTRA_DIST
=
doc/patent.txt CMakeLists.txt cmake/config.h.in
\
cmake/macros.cmake README.md README.SZIP CHANGELOG.
a
m Copyright.txt data
cmake/macros.cmake README.md README.SZIP CHANGELOG.m
d
Copyright.txt data
sampledata
=
121B2TestData
sampledata_url
=
http://cwe.ccsds.org/sls/docs/SLS-DC/BB121B2TestData/
$(sampledata)
.zip
...
...
src/decode.c
View file @
4add047d
...
...
@@ -213,10 +213,9 @@ static inline uint32_t direct_get(struct aec_stream *strm, int n)
*/
struct
internal_state
*
state
=
strm
->
state
;
int
b
;
if
(
state
->
bitp
<
n
)
{
b
=
(
63
-
state
->
bitp
)
>>
3
;
int
b
=
(
63
-
state
->
bitp
)
>>
3
;
if
(
b
==
6
)
{
state
->
acc
=
(
state
->
acc
<<
48
)
|
((
uint64_t
)
strm
->
next_in
[
0
]
<<
40
)
...
...
@@ -279,11 +278,6 @@ static inline uint32_t direct_get_fs(struct aec_stream *strm)
*/
uint32_t
fs
=
0
;
#if HAVE_BSR64
unsigned
long
i
;
#else
int
i
;
#endif
struct
internal_state
*
state
=
strm
->
state
;
if
(
state
->
bitp
)
...
...
@@ -313,11 +307,12 @@ static inline uint32_t direct_get_fs(struct aec_stream *strm)
#define __has_builtin(x) 0
/* Compatibility with non-clang compilers. */
#endif
#if HAVE_DECL___BUILTIN_CLZLL || __has_builtin(__builtin_clzll)
i
=
63
-
__builtin_clzll
(
state
->
acc
);
int
i
=
63
-
__builtin_clzll
(
state
->
acc
);
#elif HAVE_BSR64
unsigned
long
i
;
_BitScanReverse64
(
&
i
,
state
->
acc
);
#else
i
=
state
->
bitp
-
1
;
int
i
=
state
->
bitp
-
1
;
while
((
state
->
acc
&
(
UINT64_C
(
1
)
<<
i
))
==
0
)
i
--
;
#endif
...
...
@@ -437,7 +432,7 @@ static int m_split_output(struct aec_stream *strm)
state
->
rsip
++
;
strm
->
avail_out
-=
state
->
bytes_per_sample
;
bits_drop
(
strm
,
k
);
}
while
(
++
state
->
i
<
state
->
n
);
}
while
(
++
state
->
sample_counter
<
state
->
encoded_block_size
);
state
->
mode
=
m_next_cds
;
return
M_CONTINUE
;
...
...
@@ -451,11 +446,11 @@ static int m_split_fs(struct aec_stream *strm)
do
{
if
(
fs_ask
(
strm
)
==
0
)
return
M_EXIT
;
state
->
rsip
[
state
->
i
]
=
state
->
fs
<<
k
;
state
->
rsip
[
state
->
sample_counter
]
=
state
->
fs
<<
k
;
fs_drop
(
strm
);
}
while
(
++
state
->
i
<
state
->
n
);
}
while
(
++
state
->
sample_counter
<
state
->
encoded_block_size
);
state
->
i
=
0
;
state
->
sample_counter
=
0
;
state
->
mode
=
m_split_output
;
return
M_CONTINUE
;
...
...
@@ -463,26 +458,23 @@ static int m_split_fs(struct aec_stream *strm)
static
int
m_split
(
struct
aec_stream
*
strm
)
{
size_t
i
;
size_t
binary_part
;
int
k
;
struct
internal_state
*
state
=
strm
->
state
;
if
(
BUFFERSPACE
(
strm
))
{
k
=
state
->
id
-
1
;
binary_part
=
(
k
*
state
->
encoded_block_size
)
/
8
+
9
;
int
k
=
state
->
id
-
1
;
size_t
binary_part
=
(
k
*
state
->
encoded_block_size
)
/
8
+
9
;
if
(
state
->
ref
)
*
state
->
rsip
++
=
direct_get
(
strm
,
strm
->
bits_per_sample
);
for
(
i
=
0
;
i
<
state
->
encoded_block_size
;
i
++
)
for
(
size_t
i
=
0
;
i
<
state
->
encoded_block_size
;
i
++
)
state
->
rsip
[
i
]
=
direct_get_fs
(
strm
)
<<
k
;
if
(
k
)
{
if
(
strm
->
avail_in
<
binary_part
)
return
M_ERROR
;
for
(
i
=
0
;
i
<
state
->
encoded_block_size
;
i
++
)
for
(
size_t
i
=
0
;
i
<
state
->
encoded_block_size
;
i
++
)
*
state
->
rsip
++
+=
direct_get
(
strm
,
k
);
}
else
{
state
->
rsip
+=
state
->
encoded_block_size
;
...
...
@@ -493,8 +485,7 @@ static int m_split(struct aec_stream *strm)
}
else
{
if
(
state
->
ref
&&
(
copysample
(
strm
)
==
0
))
return
M_EXIT
;
state
->
n
=
state
->
encoded_block_size
;
state
->
i
=
0
;
state
->
sample_counter
=
0
;
state
->
mode
=
m_split_fs
;
}
return
M_CONTINUE
;
...
...
@@ -508,7 +499,7 @@ static int m_zero_output(struct aec_stream *strm)
if
(
strm
->
avail_out
<
state
->
bytes_per_sample
)
return
M_EXIT
;
put_sample
(
strm
,
0
);
}
while
(
--
state
->
i
);
}
while
(
--
state
->
sample_counter
);
state
->
mode
=
m_next_cds
;
return
M_CONTINUE
;
...
...
@@ -516,46 +507,48 @@ static int m_zero_output(struct aec_stream *strm)
static
int
m_zero_block
(
struct
aec_stream
*
strm
)
{
uint32_t
i
,
zero_blocks
,
b
,
zero_bytes
;
struct
internal_state
*
state
=
strm
->
state
;
uint32_t
zero_blocks
;
uint32_t
zero_samples
;
uint32_t
zero_bytes
;
if
(
fs_ask
(
strm
)
==
0
)
return
M_EXIT
;
zero_blocks
=
state
->
fs
+
1
;
fs_drop
(
strm
);
if
(
zero_blocks
==
ROS
)
{
b
=
(
int
)
RSI_USED_SIZE
(
state
)
/
strm
->
block_size
;
int
b
=
(
int
)
RSI_USED_SIZE
(
state
)
/
strm
->
block_size
;
zero_blocks
=
MIN
(
strm
->
rsi
-
b
,
64
-
(
b
%
64
));
}
else
if
(
zero_blocks
>
ROS
)
{
zero_blocks
--
;
}
i
=
zero_blocks
*
strm
->
block_size
-
state
->
ref
;
zero_bytes
=
i
*
state
->
bytes_per_sample
;
if
(
state
->
rsi_size
-
RSI_USED_SIZE
(
state
)
<
i
)
zero_samples
=
zero_blocks
*
strm
->
block_size
-
state
->
ref
;
if
(
state
->
rsi_size
-
RSI_USED_SIZE
(
state
)
<
zero_samples
)
return
M_ERROR
;
zero_bytes
=
zero_samples
*
state
->
bytes_per_sample
;
if
(
strm
->
avail_out
>=
zero_bytes
)
{
memset
(
state
->
rsip
,
0
,
i
*
sizeof
(
uint32_t
));
state
->
rsip
+=
i
;
memset
(
state
->
rsip
,
0
,
zero_samples
*
sizeof
(
uint32_t
));
state
->
rsip
+=
zero_samples
;
strm
->
avail_out
-=
zero_bytes
;
state
->
mode
=
m_next_cds
;
return
M_CONTINUE
;
}
else
{
state
->
sample_counter
=
zero_samples
;
state
->
mode
=
m_zero_output
;
}
state
->
i
=
i
;
state
->
mode
=
m_zero_output
;
return
M_CONTINUE
;
}
static
int
m_se_decode
(
struct
aec_stream
*
strm
)
{
int32_t
m
,
d1
;
struct
internal_state
*
state
=
strm
->
state
;
while
(
state
->
i
<
strm
->
block_size
)
{
while
(
state
->
sample_counter
<
strm
->
block_size
)
{
int32_t
m
;
int32_t
d1
;
if
(
fs_ask
(
strm
)
==
0
)
return
M_EXIT
;
m
=
state
->
fs
;
...
...
@@ -563,17 +556,17 @@ static int m_se_decode(struct aec_stream *strm)
return
M_ERROR
;
d1
=
m
-
state
->
se_table
[
2
*
m
+
1
];
if
((
state
->
i
&
1
)
==
0
)
{
if
((
state
->
sample_counter
&
1
)
==
0
)
{
if
(
strm
->
avail_out
<
state
->
bytes_per_sample
)
return
M_EXIT
;
put_sample
(
strm
,
state
->
se_table
[
2
*
m
]
-
d1
);
state
->
i
++
;
state
->
sample_counter
++
;
}
if
(
strm
->
avail_out
<
state
->
bytes_per_sample
)
return
M_EXIT
;
put_sample
(
strm
,
d1
);
state
->
i
++
;
state
->
sample_counter
++
;
fs_drop
(
strm
);
}
...
...
@@ -583,16 +576,14 @@ static int m_se_decode(struct aec_stream *strm)
static
int
m_se
(
struct
aec_stream
*
strm
)
{
uint32_t
i
;
uint32_t
m
;
int32_t
d1
;
struct
internal_state
*
state
=
strm
->
state
;
if
(
BUFFERSPACE
(
strm
))
{
i
=
state
->
ref
;
uint32_t
i
=
state
->
ref
;
while
(
i
<
strm
->
block_size
)
{
m
=
direct_get_fs
(
strm
);
uint32_t
m
=
direct_get_fs
(
strm
);
int32_t
d1
;
if
(
m
>
SE_TABLE_SIZE
)
return
M_ERROR
;
...
...
@@ -609,7 +600,7 @@ static int m_se(struct aec_stream *strm)
state
->
mode
=
m_next_cds
;
}
else
{
state
->
mode
=
m_se_decode
;
state
->
i
=
state
->
ref
;
state
->
sample_counter
=
state
->
ref
;
}
return
M_CONTINUE
;
}
...
...
@@ -621,12 +612,10 @@ static int m_low_entropy_ref(struct aec_stream *strm)
if
(
state
->
ref
&&
copysample
(
strm
)
==
0
)
return
M_EXIT
;
if
(
state
->
id
==
1
)
{
if
(
state
->
id
==
1
)
state
->
mode
=
m_se
;
return
M_CONTINUE
;
}
state
->
mode
=
m_zero_block
;
else
state
->
mode
=
m_zero_block
;
return
M_CONTINUE
;
}
...
...
@@ -649,7 +638,7 @@ static int m_uncomp_copy(struct aec_stream *strm)
do
{
if
(
copysample
(
strm
)
==
0
)
return
M_EXIT
;
}
while
(
--
state
->
i
);
}
while
(
--
state
->
sample_counter
);
state
->
mode
=
m_next_cds
;
return
M_CONTINUE
;
...
...
@@ -657,16 +646,15 @@ static int m_uncomp_copy(struct aec_stream *strm)
static
int
m_uncomp
(
struct
aec_stream
*
strm
)
{
size_t
i
;
struct
internal_state
*
state
=
strm
->
state
;
if
(
BUFFERSPACE
(
strm
))
{
for
(
i
=
0
;
i
<
strm
->
block_size
;
i
++
)
for
(
size_t
i
=
0
;
i
<
strm
->
block_size
;
i
++
)
*
state
->
rsip
++
=
direct_get
(
strm
,
strm
->
bits_per_sample
);
strm
->
avail_out
-=
state
->
out_blklen
;
state
->
mode
=
m_next_cds
;
}
else
{
state
->
i
=
strm
->
block_size
;
state
->
sample_counter
=
strm
->
block_size
;
state
->
mode
=
m_uncomp_copy
;
}
return
M_CONTINUE
;
...
...
@@ -674,12 +662,10 @@ static int m_uncomp(struct aec_stream *strm)
static
void
create_se_table
(
int
*
table
)
{
int
i
,
j
,
k
,
ms
;
k
=
0
;
for
(
i
=
0
;
i
<
13
;
i
++
)
{
ms
=
k
;
for
(
j
=
0
;
j
<=
i
;
j
++
)
{
int
k
=
0
;
for
(
int
i
=
0
;
i
<
13
;
i
++
)
{
int
ms
=
k
;
for
(
int
j
=
0
;
j
<=
i
;
j
++
)
{
table
[
2
*
k
]
=
i
;
table
[
2
*
k
+
1
]
=
ms
;
k
++
;
...
...
@@ -689,7 +675,6 @@ static void create_se_table(int *table)
int
aec_decode_init
(
struct
aec_stream
*
strm
)
{
int
i
,
modi
;
struct
internal_state
*
state
;
if
(
strm
->
bits_per_sample
>
32
||
strm
->
bits_per_sample
==
0
)
...
...
@@ -760,13 +745,13 @@ int aec_decode_init(struct aec_stream *strm)
state
->
in_blklen
=
(
strm
->
block_size
*
strm
->
bits_per_sample
+
state
->
id_len
)
/
8
+
16
;
modi
=
1UL
<<
state
->
id_len
;
int
modi
=
1UL
<<
state
->
id_len
;
state
->
id_table
=
malloc
(
modi
*
sizeof
(
int
(
*
)(
struct
aec_stream
*
)));
if
(
state
->
id_table
==
NULL
)
return
AEC_MEM_ERROR
;
state
->
id_table
[
0
]
=
m_low_entropy
;
for
(
i
=
1
;
i
<
modi
-
1
;
i
++
)
{
for
(
int
i
=
1
;
i
<
modi
-
1
;
i
++
)
{
state
->
id_table
[
i
]
=
m_split
;
}
state
->
id_table
[
modi
-
1
]
=
m_uncomp
;
...
...
@@ -806,12 +791,11 @@ int aec_decode(struct aec_stream *strm, int flush)
of the states are called. Inspired by zlib.
*/
struct
internal_state
*
state
=
strm
->
state
;
int
status
;
strm
->
total_in
+=
strm
->
avail_in
;
strm
->
total_out
+=
strm
->
avail_out
;
struct
internal_state
*
state
=
strm
->
state
;
int
status
;
do
{
status
=
state
->
mode
(
strm
);
}
while
(
status
==
M_CONTINUE
);
...
...
@@ -843,9 +827,7 @@ int aec_decode_end(struct aec_stream *strm)
int
aec_buffer_decode
(
struct
aec_stream
*
strm
)
{
int
status
;
status
=
aec_decode_init
(
strm
);
int
status
=
aec_decode_init
(
strm
);
if
(
status
!=
AEC_OK
)
return
status
;
...
...
src/decode.h
View file @
4add047d
...
...
@@ -97,8 +97,7 @@ struct internal_state {
/* length of output block in bytes */
uint32_t
out_blklen
;
/* counter for samples */
uint32_t
n
,
i
;
uint32_t
sample_counter
;
/* accumulator for currently used bit sequence */
uint64_t
acc
;
...
...
src/encode.c
View file @
4add047d
...
...
@@ -117,15 +117,12 @@ static inline void copy64(uint8_t *dst, uint64_t src)
static
inline
void
emitblock_fs
(
struct
aec_stream
*
strm
,
int
k
,
int
ref
)
{
size_t
i
;
uint32_t
used
;
/* used bits in 64 bit accumulator */
uint64_t
acc
;
/* accumulator */
struct
internal_state
*
state
=
strm
->
state
;
acc
=
(
uint64_t
)
*
state
->
cds
<<
56
;
used
=
7
-
state
->
bits
;
uint64_t
acc
=
(
uint64_t
)
*
state
->
cds
<<
56
;
uint32_t
used
=
7
-
state
->
bits
;
/* used bits in 64 bit accumulator */
for
(
i
=
ref
;
i
<
strm
->
block_size
;
i
++
)
{
for
(
size_t
i
=
ref
;
i
<
strm
->
block_size
;
i
++
)
{
used
+=
(
state
->
block
[
i
]
>>
k
)
+
1
;
while
(
used
>
63
)
{
copy64
(
state
->
cds
,
acc
);
...
...
@@ -147,16 +144,14 @@ static inline void emitblock(struct aec_stream *strm, int k, int ref)
Emit the k LSB of a whole block of input data.
*/
uint64_t
a
;
struct
internal_state
*
state
=
strm
->
state
;
uint32_t
*
in
=
state
->
block
+
ref
;
uint32_t
*
in_end
=
state
->
block
+
strm
->
block_size
;
uint64_t
mask
=
(
UINT64_C
(
1
)
<<
k
)
-
1
;
uint8_t
*
o
=
state
->
cds
;
uint64_t
a
=
*
o
;
int
p
=
state
->
bits
;
a
=
*
o
;
while
(
in
<
in_end
)
{
a
<<=
56
;
p
=
(
p
%
8
)
+
56
;
...
...
@@ -247,12 +242,11 @@ static void preprocess_unsigned(struct aec_stream *strm)
uint32_t
*
restrict
d
=
state
->
data_pp
;
uint32_t
xmax
=
state
->
xmax
;
uint32_t
rsi
=
strm
->
rsi
*
strm
->
block_size
-
1
;
size_t
i
;
state
->
ref
=
1
;
state
->
ref_sample
=
x
[
0
];
d
[
0
]
=
0
;
for
(
i
=
0
;
i
<
rsi
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
rsi
;
i
++
)
{
if
(
x
[
i
+
1
]
>=
x
[
i
])
{
D
=
x
[
i
+
1
]
-
x
[
i
];
if
(
D
<=
x
[
i
])
...
...
@@ -284,14 +278,13 @@ static void preprocess_signed(struct aec_stream *strm)
int32_t
xmin
=
(
int32_t
)
state
->
xmin
;
uint32_t
rsi
=
strm
->
rsi
*
strm
->
block_size
-
1
;
uint32_t
m
=
UINT64_C
(
1
)
<<
(
strm
->
bits_per_sample
-
1
);
size_t
i
;
state
->
ref
=
1
;
state
->
ref_sample
=
x
[
0
];
d
[
0
]
=
0
;
x
[
0
]
=
(
x
[
0
]
^
m
)
-
m
;
for
(
i
=
0
;
i
<
rsi
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
rsi
;
i
++
)
{
x
[
i
+
1
]
=
(
x
[
i
+
1
]
^
m
)
-
m
;
if
(
x
[
i
+
1
]
<
x
[
i
])
{
D
=
(
uint32_t
)(
x
[
i
]
-
x
[
i
+
1
]);
...
...
@@ -316,11 +309,10 @@ static inline uint64_t block_fs(struct aec_stream *strm, int k)
Sum FS of all samples in block for given splitting position.
*/
size_t
i
;
uint64_t
fs
=
0
;
struct
internal_state
*
state
=
strm
->
state
;
uint64_t
fs
=
0
;
for
(
i
=
0
;
i
<
strm
->
block_size
;
i
++
)
for
(
size_t
i
=
0
;
i
<
strm
->
block_size
;
i
++
)
fs
+=
(
uint64_t
)(
state
->
block
[
i
]
>>
k
);
return
fs
;
...
...
@@ -353,26 +345,29 @@ static uint32_t assess_splitting_option(struct aec_stream *strm)
analogue check can be done for decreasing k.
*/
int
k
;
int
k_min
;
int
this_bs
;
/* Block size of current block */
int
no_turn
;
/* 1 if we shouldn't reverse */
int
dir
;
/* Direction, 1 means increasing k, 0 decreasing k */
uint64_t
len
;
/* CDS length for current k */
uint64_t
len_min
;
/* CDS length minimum so far */
uint64_t
fs_len
;
/* Length of FS part (not including 1s) */
struct
internal_state
*
state
=
strm
->
state
;
this_bs
=
strm
->
block_size
-
state
->
ref
;
len_min
=
UINT64_MAX
;
k
=
k_min
=
state
->
k
;
no_turn
=
k
==
0
;
dir
=
1
;
/* Block size of current block */
int
this_bs
=
strm
->
block_size
-
state
->
ref
;
/* CDS length minimum so far */
uint64_t
len_min
=
UINT64_MAX
;
int
k
=
state
->
k
;
int
k_min
=
k
;
/* 1 if we shouldn't reverse */
int
no_turn
=
(
k
==
0
);
/* Direction, 1 means increasing k, 0 decreasing k */
int
dir
=
1
;
for
(;;)
{
fs_len
=
block_fs
(
strm
,
k
);
len
=
fs_len
+
this_bs
*
(
k
+
1
);
/* Length of FS part (not including 1s) */
uint64_t
fs_len
=
block_fs
(
strm
,
k
);
/* CDS length for current k */
uint64_t
len
=
fs_len
+
this_bs
*
(
k
+
1
);
if
(
len
<
len_min
)
{
if
(
len_min
<
UINT64_MAX
)
...
...
@@ -417,15 +412,12 @@ static uint32_t assess_se_option(struct aec_stream *strm)
If length is above limit just return UINT32_MAX.
*/
size_t
i
;
uint64_t
len
,
d
;
struct
internal_state
*
state
=
strm
->
state
;
uint32_t
*
block
=
state
->
block
;
uint64_t
len
=
1
;
len
=
1
;
for
(
i
=
0
;
i
<
strm
->
block_size
;
i
+=
2
)
{
d
=
(
uint64_t
)
block
[
i
]
+
(
uint64_t
)
block
[
i
+
1
];
for
(
size_t
i
=
0
;
i
<
strm
->
block_size
;
i
+=
2
)
{
uint64_t
d
=
(
uint64_t
)
block
[
i
]
+
(
uint64_t
)
block
[
i
+
1
];
len
+=
d
*
(
d
+
1
)
/
2
+
block
[
i
+
1
]
+
1
;
if
(
len
>
state
->
uncomp_len
)
return
UINT32_MAX
;
...
...
@@ -493,7 +485,6 @@ static int m_flush_block(struct aec_stream *strm)
Fall back to slow flushing if in buffered mode.
*/
int
n
;
struct
internal_state
*
state
=
strm
->
state
;
#ifdef ENABLE_RSI_PADDING
...
...
@@ -505,7 +496,7 @@ static int m_flush_block(struct aec_stream *strm)
#endif
if
(
state
->
direct_out
)
{
n
=
(
int
)(
state
->
cds
-
strm
->
next_out
);
int
n
=
(
int
)(
state
->
cds
-
strm
->
next_out
);
strm
->
next_out
+=
n
;
strm
->
avail_out
-=
n
;
state
->
mode
=
m_get_block
;
...
...
@@ -546,16 +537,14 @@ static int m_encode_uncomp(struct aec_stream *strm)
static
int
m_encode_se
(
struct
aec_stream
*
strm
)
{
size_t
i
;
uint32_t
d
;
struct
internal_state
*
state
=
strm
->
state
;
emit
(
state
,
1
,
state
->
id_len
+
1
);
if
(
state
->
ref
)
emit
(
state
,
state
->
ref_sample
,
strm
->
bits_per_sample
);
for
(
i
=
0
;
i
<
strm
->
block_size
;
i
+=
2
)
{
d
=
state
->
block
[
i
]
+
state
->
block
[
i
+
1
];
for
(
size_t
i
=
0
;
i
<
strm
->
block_size
;
i
+=
2
)
{
uint32_t
d
=
state
->
block
[
i
]
+
state
->
block
[
i
+
1
];
emitfs
(
state
,
d
*
(
d
+
1
)
/
2
+
state
->
block
[
i
+
1
]);
}
...
...
@@ -588,15 +577,14 @@ static int m_select_code_option(struct aec_stream *strm)
Decide which code option to use.
*/
uint32_t
split_len
;
uint32_t
se_len
;
struct
internal_state
*
state
=
strm
->
state
;
uint32_t
split_len
;
if
(
state
->
id_len
>
1
)
split_len
=
assess_splitting_option
(
strm
);
else
split_len
=
UINT32_MAX
;
se_len
=
assess_se_option
(
strm
);
uint32_t
se_len
=
assess_se_option
(
strm
);
if
(
split_len
<
state
->
uncomp_len
)
{
if
(
split_len
<
se_len
)
...
...
@@ -620,10 +608,10 @@ static int m_check_zero_block(struct aec_stream *strm)
end of a segment or RSI.
*/
size_t
i
;
struct
internal_state
*
state
=
strm
->
state
;
uint32_t
*
p
=
state
->
block
;
size_t
i
;
for
(
i
=
0
;
i
<
strm
->
block_size
;
i
++
)
if
(
p
[
i
]
!=
0
)
break
;
...
...
@@ -912,7 +900,6 @@ int aec_encode(struct aec_stream *strm, int flush)
Finite-state machine implementation of the adaptive entropy
encoder.
*/
int
n
;
struct
internal_state
*
state
=
strm
->
state
;
state
->
flush
=
flush
;
...
...
@@ -922,7 +909,7 @@ int aec_encode(struct aec_stream *strm, int flush)
while
(
state
->
mode
(
strm
)
==
M_CONTINUE
);
if
(
state
->
direct_out
)
{
n
=
(
int
)(
state
->
cds
-
strm
->
next_out
);
int
n
=
(
int
)(
state
->
cds
-
strm
->
next_out
);
strm
->
next_out
+=
n
;
strm
->
avail_out
-=
n
;
...
...
@@ -938,9 +925,8 @@ int aec_encode(struct aec_stream *strm, int flush)
int
aec_encode_end
(
struct
aec_stream
*
strm
)
{
struct
internal_state
*
state
=
strm
->
state
;
int
status
;
status
=
AEC_OK
;
int
status
=
AEC_OK
;
if
(
state
->
flush
==
AEC_FLUSH
&&
state
->
flushed
==
0
)
status
=
AEC_STREAM_ERROR
;
cleanup
(
strm
);
...
...
@@ -949,9 +935,7 @@ int aec_encode_end(struct aec_stream *strm)
int
aec_buffer_encode
(
struct
aec_stream
*
strm
)
{
int
status
;
status
=
aec_encode_init
(
strm
);
int
status
=
aec_encode_init
(
strm
);
if
(
status
!=
AEC_OK
)
return
status
;
status
=
aec_encode
(
strm
,
AEC_FLUSH
);
...
...
src/encode_accessors.c
View file @
4add047d
...
...
@@ -66,9 +66,7 @@ uint32_t aec_get_8(struct aec_stream *strm)
uint32_t
aec_get_lsb_16
(
struct
aec_stream
*
strm
)
{
uint32_t
data
;
data
=
((
uint32_t
)
strm
->
next_in
[
1
]
<<
8
)
uint32_t
data
=
((
uint32_t
)
strm
->
next_in
[
1
]
<<
8
)
|
(
uint32_t
)
strm
->
next_in
[
0
];
strm
->
next_in
+=
2
;
...
...
@@ -78,9 +76,7 @@ uint32_t aec_get_lsb_16(struct aec_stream *strm)
uint32_t
aec_get_msb_16
(
struct
aec_stream
*
strm
)
{
uint32_t
data
;
data
=
((
uint32_t
)
strm
->
next_in
[
0
]
<<
8
)
uint32_t
data
=
((
uint32_t
)
strm
->
next_in
[
0
]
<<
8
)
|
(
uint32_t
)
strm
->
next_in
[
1
];
strm
->
next_in
+=
2
;
...
...
@@ -90,9 +86,7 @@ uint32_t aec_get_msb_16(struct aec_stream *strm)
uint32_t
aec_get_lsb_24
(
struct
aec_stream
*
strm
)
{
uint32_t
data
;
data
=
((
uint32_t
)
strm
->
next_in
[
2
]
<<
16
)
uint32_t
data
=
((
uint32_t
)
strm
->
next_in
[
2
]
<<
16
)
|
((
uint32_t
)
strm
->
next_in
[
1
]
<<
8
)
|
(
uint32_t
)
strm
->
next_in
[
0
];
...
...
@@ -103,9 +97,7 @@ uint32_t aec_get_lsb_24(struct aec_stream *strm)
uint32_t
aec_get_msb_24
(
struct
aec_stream
*
strm
)