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
6f2ffa17
Commit
6f2ffa17
authored
Aug 01, 2014
by
Mathis Rosenhauer
Browse files
More explicit casting to shup up VS.
parent
8e055aaa
Changes
10
Hide whitespace changes
Inline
Side-by-side
src/decode.c
View file @
6f2ffa17
...
...
@@ -86,7 +86,7 @@
/* Reference samples have to be sign extended */
\
state->last_out = (state->last_out ^ m) - m; \
} \
put_##KIND(strm, state->last_out);
\
put_##KIND(strm,
(uint32_t)
state->last_out); \
state->flush_start++; \
} \
\
...
...
@@ -122,7 +122,7 @@
data = xmax - d; \
} \
} \
put_##KIND(strm,
data);
\
put_##KIND(strm,
(uint32_t)data);
\
} \
state->last_out = data; \
} else { \
...
...
@@ -135,49 +135,49 @@
static
inline
void
put_msb_32
(
struct
aec_stream
*
strm
,
uint32_t
data
)
{
*
strm
->
next_out
++
=
data
>>
24
;
*
strm
->
next_out
++
=
data
>>
16
;
*
strm
->
next_out
++
=
data
>>
8
;
*
strm
->
next_out
++
=
data
;
*
strm
->
next_out
++
=
(
unsigned
char
)(
data
>>
24
)
;
*
strm
->
next_out
++
=
(
unsigned
char
)(
data
>>
16
)
;
*
strm
->
next_out
++
=
(
unsigned
char
)(
data
>>
8
)
;
*
strm
->
next_out
++
=
(
unsigned
char
)
data
;
}
static
inline
void
put_msb_24
(
struct
aec_stream
*
strm
,
uint32_t
data
)
{
*
strm
->
next_out
++
=
data
>>
16
;
*
strm
->
next_out
++
=
data
>>
8
;
*
strm
->
next_out
++
=
data
;
*
strm
->
next_out
++
=
(
unsigned
char
)(
data
>>
16
)
;
*
strm
->
next_out
++
=
(
unsigned
char
)(
data
>>
8
)
;
*
strm
->
next_out
++
=
(
unsigned
char
)
data
;
}
static
inline
void
put_msb_16
(
struct
aec_stream
*
strm
,
uint32_t
data
)
{
*
strm
->
next_out
++
=
data
>>
8
;
*
strm
->
next_out
++
=
data
;
*
strm
->
next_out
++
=
(
unsigned
char
)(
data
>>
8
)
;
*
strm
->
next_out
++
=
(
unsigned
char
)
data
;
}
static
inline
void
put_lsb_32
(
struct
aec_stream
*
strm
,
uint32_t
data
)
{
*
strm
->
next_out
++
=
data
;
*
strm
->
next_out
++
=
data
>>
8
;
*
strm
->
next_out
++
=
data
>>
16
;
*
strm
->
next_out
++
=
data
>>
24
;
*
strm
->
next_out
++
=
(
unsigned
char
)
data
;
*
strm
->
next_out
++
=
(
unsigned
char
)(
data
>>
8
)
;
*
strm
->
next_out
++
=
(
unsigned
char
)(
data
>>
16
)
;
*
strm
->
next_out
++
=
(
unsigned
char
)(
data
>>
24
)
;
}
static
inline
void
put_lsb_24
(
struct
aec_stream
*
strm
,
uint32_t
data
)
{
*
strm
->
next_out
++
=
data
;
*
strm
->
next_out
++
=
data
>>
8
;
*
strm
->
next_out
++
=
data
>>
16
;
*
strm
->
next_out
++
=
(
unsigned
char
)
data
;
*
strm
->
next_out
++
=
(
unsigned
char
)(
data
>>
8
)
;
*
strm
->
next_out
++
=
(
unsigned
char
)(
data
>>
16
)
;
}
static
inline
void
put_lsb_16
(
struct
aec_stream
*
strm
,
uint32_t
data
)
{
*
strm
->
next_out
++
=
data
;
*
strm
->
next_out
++
=
data
>>
8
;
*
strm
->
next_out
++
=
(
unsigned
char
)
data
;
*
strm
->
next_out
++
=
(
unsigned
char
)(
data
>>
8
)
;
}
static
inline
void
put_8
(
struct
aec_stream
*
strm
,
uint32_t
data
)
{
*
strm
->
next_out
++
=
data
;
*
strm
->
next_out
++
=
(
unsigned
char
)
data
;
}
FLUSH
(
msb_32
)
...
...
@@ -195,7 +195,7 @@ static inline void check_rsi_end(struct aec_stream *strm)
*/
struct
internal_state
*
state
=
strm
->
state
;
if
(
state
->
rsi
p
-
state
->
rsi_buffer
==
state
->
rsi_
size
)
{
if
(
state
->
rsi
_size
==
(
size_t
)(
state
->
rsip
-
state
->
rsi_
buffer
)
)
{
state
->
flush_output
(
strm
);
state
->
flush_start
=
state
->
rsi_buffer
;
state
->
rsip
=
state
->
rsi_buffer
;
...
...
@@ -237,7 +237,7 @@ static inline void fill_acc(struct aec_stream *strm)
}
static
inline
uint32_t
direct_get
(
struct
aec_stream
*
strm
,
unsigned
int
n
)
static
inline
uint32_t
direct_get
(
struct
aec_stream
*
strm
,
int
n
)
{
/**
Get n bit from input stream
...
...
@@ -264,8 +264,10 @@ static inline uint32_t direct_get_fs(struct aec_stream *strm)
*/
uint32_t
fs
=
0
;
#if HAVE_DECL___BUILTIN_CLZLL||HAVE_BSR64
uint32_t
lz
;
#if HAVE_DECL___BUILTIN_CLZLL
int
lz
;
#elif HAVE_BSR64
unsigned
long
lz
;
#endif
struct
internal_state
*
state
=
strm
->
state
;
...
...
@@ -413,7 +415,7 @@ static int m_split_fs(struct aec_stream *strm)
static
int
m_split
(
struct
aec_stream
*
strm
)
{
int
i
,
k
;
u
int
32_t
i
,
k
;
struct
internal_state
*
state
=
strm
->
state
;
if
(
BUFFERSPACE
(
strm
))
{
...
...
@@ -464,7 +466,7 @@ static int m_zero_output(struct aec_stream *strm)
static
int
m_zero_block
(
struct
aec_stream
*
strm
)
{
int
i
,
zero_blocks
,
b
,
zero_bytes
;
u
int
32_t
i
,
zero_blocks
,
b
,
zero_bytes
;
struct
internal_state
*
state
=
strm
->
state
;
if
(
fs_ask
(
strm
)
==
0
)
...
...
@@ -473,7 +475,7 @@ static int m_zero_block(struct aec_stream *strm)
fs_drop
(
strm
);
if
(
zero_blocks
==
ROS
)
{
b
=
(
state
->
rsip
-
state
->
rsi_buffer
)
/
strm
->
block_size
;
b
=
(
int
)
(
state
->
rsip
-
state
->
rsi_buffer
)
/
strm
->
block_size
;
zero_blocks
=
MIN
(
strm
->
rsi
-
b
,
64
-
(
b
%
64
));
}
else
if
(
zero_blocks
>
ROS
)
{
zero_blocks
--
;
...
...
@@ -535,7 +537,7 @@ static int m_se_decode(struct aec_stream *strm)
static
int
m_se
(
struct
aec_stream
*
strm
)
{
int
i
;
u
int
32_t
i
;
int32_t
m
,
d1
;
struct
internal_state
*
state
=
strm
->
state
;
...
...
@@ -605,7 +607,7 @@ static int m_uncomp_copy(struct aec_stream *strm)
static
int
m_uncomp
(
struct
aec_stream
*
strm
)
{
int
i
;
u
int
32_t
i
;
struct
internal_state
*
state
=
strm
->
state
;
if
(
BUFFERSPACE
(
strm
))
{
...
...
@@ -701,7 +703,7 @@ int aec_decode_init(struct aec_stream *strm)
}
if
(
strm
->
flags
&
AEC_DATA_SIGNED
)
{
state
->
xmin
=
-
(
1
U
LL
<<
(
strm
->
bits_per_sample
-
1
));
state
->
xmin
=
-
(
1LL
<<
(
strm
->
bits_per_sample
-
1
));
state
->
xmax
=
(
1ULL
<<
(
strm
->
bits_per_sample
-
1
))
-
1
;
}
else
{
state
->
xmin
=
0
;
...
...
src/decode.h
View file @
6f2ffa17
...
...
@@ -70,30 +70,69 @@
struct
internal_state
{
int
(
*
mode
)(
struct
aec_stream
*
);
int
id
;
/* option ID */
int
id_len
;
/* bit length of code option identification key */
int
(
**
id_table
)(
struct
aec_stream
*
);
/* table maps IDs to states */
/* option ID */
int
id
;
/* bit length of code option identification key */
int
id_len
;
/* table maps IDs to states */
int
(
**
id_table
)(
struct
aec_stream
*
);
void
(
*
flush_output
)(
struct
aec_stream
*
);
int64_t
last_out
;
/* previous output for post-processing */
int64_t
xmin
;
/* minimum integer for post-processing */
int64_t
xmax
;
/* maximum integer for post-processing */
int
in_blklen
;
/* length of uncompressed input block
should be the longest possible block */
int
out_blklen
;
/* length of output block in bytes */
int
n
,
i
;
/* counter for samples */
uint64_t
acc
;
/* accumulator for currently used bit sequence */
int
bitp
;
/* bit pointer to the next unused bit in
accumulator */
int
fs
;
/* last fundamental sequence in accumulator */
int
ref
;
/* 1 if current block has reference sample */
int
pp
;
/* 1 if postprocessor has to be used */
int
bytes_per_sample
;
/* storage size of samples in bytes */
uint32_t
*
rsi_buffer
;
/* output buffer holding one reference
sample interval */
uint32_t
*
rsip
;
/* current position of output in rsi_buffer */
size_t
rsi_size
;
/* rsi in bytes */
uint32_t
*
flush_start
;
/* first not yet flushed byte in rsi_buffer */
int
se_table
[
182
];
/* table for decoding second extension option */
/* previous output for post-processing */
int64_t
last_out
;
/* minimum integer for post-processing */
int64_t
xmin
;
/* maximum integer for post-processing */
int64_t
xmax
;
/* length of uncompressed input block should be the longest
possible block */
uint32_t
in_blklen
;
/* length of output block in bytes */
uint32_t
out_blklen
;
/* counter for samples */
uint32_t
n
,
i
;
/* accumulator for currently used bit sequence */
uint64_t
acc
;
/* bit pointer to the next unused bit in accumulator */
int
bitp
;
/* last fundamental sequence in accumulator */
int
fs
;
/* 1 if current block has reference sample */
int
ref
;
/* 1 if postprocessor has to be used */
int
pp
;
/* storage size of samples in bytes */
uint32_t
bytes_per_sample
;
/* output buffer holding one reference sample interval */
uint32_t
*
rsi_buffer
;
/* current position of output in rsi_buffer */
uint32_t
*
rsip
;
/* rsi in bytes */
size_t
rsi_size
;
/* first not yet flushed byte in rsi_buffer */
uint32_t
*
flush_start
;
/* table for decoding second extension option */
int
se_table
[
182
];
}
decode_state
;
#endif
/* DECODE_H */
src/encode.c
View file @
6f2ffa17
...
...
@@ -70,18 +70,18 @@ static inline void emit(struct internal_state *state,
if
(
bits
<=
state
->
bits
)
{
state
->
bits
-=
bits
;
*
state
->
cds
+=
data
<<
state
->
bits
;
*
state
->
cds
+=
(
uint8_t
)(
data
<<
state
->
bits
)
;
}
else
{
bits
-=
state
->
bits
;
*
state
->
cds
++
+=
(
uint64_t
)
data
>>
bits
;
*
state
->
cds
++
+=
(
uint8_t
)(
(
uint64_t
)
data
>>
bits
)
;
while
(
bits
>
8
)
{
bits
-=
8
;
*
state
->
cds
++
=
data
>>
bits
;
*
state
->
cds
++
=
(
uint8_t
)(
data
>>
bits
)
;
}
state
->
bits
=
8
-
bits
;
*
state
->
cds
=
data
<<
state
->
bits
;
*
state
->
cds
=
(
uint8_t
)(
data
<<
state
->
bits
)
;
}
}
...
...
@@ -108,20 +108,20 @@ static inline void emitfs(struct internal_state *state, int fs)
static
inline
void
copy64
(
uint8_t
*
dst
,
uint64_t
src
)
{
dst
[
0
]
=
src
>>
56
;
dst
[
1
]
=
src
>>
48
;
dst
[
2
]
=
src
>>
40
;
dst
[
3
]
=
src
>>
32
;
dst
[
4
]
=
src
>>
24
;
dst
[
5
]
=
src
>>
16
;
dst
[
6
]
=
src
>>
8
;
dst
[
7
]
=
src
;
dst
[
0
]
=
(
uint8_t
)(
src
>>
56
)
;
dst
[
1
]
=
(
uint8_t
)(
src
>>
48
)
;
dst
[
2
]
=
(
uint8_t
)(
src
>>
40
)
;
dst
[
3
]
=
(
uint8_t
)(
src
>>
32
)
;
dst
[
4
]
=
(
uint8_t
)(
src
>>
24
)
;
dst
[
5
]
=
(
uint8_t
)(
src
>>
16
)
;
dst
[
6
]
=
(
uint8_t
)(
src
>>
8
)
;
dst
[
7
]
=
(
uint8_t
)
src
;
}
static
inline
void
emitblock_fs
(
struct
aec_stream
*
strm
,
int
k
,
int
ref
)
{
int
i
;
int
used
;
/* used bits in 64 bit accumulator */
u
int
32_t
i
;
u
int
32_t
used
;
/* used bits in 64 bit accumulator */
uint64_t
acc
;
/* accumulator */
struct
internal_state
*
state
=
strm
->
state
;
...
...
@@ -171,57 +171,57 @@ static inline void emitblock(struct aec_stream *strm, int k, int ref)
switch
(
p
&
~
7
)
{
case
0
:
o
[
0
]
=
a
>>
56
;
o
[
1
]
=
a
>>
48
;
o
[
2
]
=
a
>>
40
;
o
[
3
]
=
a
>>
32
;
o
[
4
]
=
a
>>
24
;
o
[
5
]
=
a
>>
16
;
o
[
6
]
=
a
>>
8
;
o
[
0
]
=
(
uint8_t
)(
a
>>
56
)
;
o
[
1
]
=
(
uint8_t
)(
a
>>
48
)
;
o
[
2
]
=
(
uint8_t
)(
a
>>
40
)
;
o
[
3
]
=
(
uint8_t
)(
a
>>
32
)
;
o
[
4
]
=
(
uint8_t
)(
a
>>
24
)
;
o
[
5
]
=
(
uint8_t
)(
a
>>
16
)
;
o
[
6
]
=
(
uint8_t
)(
a
>>
8
)
;
o
+=
7
;
break
;
case
8
:
o
[
0
]
=
a
>>
56
;
o
[
1
]
=
a
>>
48
;
o
[
2
]
=
a
>>
40
;
o
[
3
]
=
a
>>
32
;
o
[
4
]
=
a
>>
24
;
o
[
5
]
=
a
>>
16
;
o
[
0
]
=
(
uint8_t
)(
a
>>
56
)
;
o
[
1
]
=
(
uint8_t
)(
a
>>
48
)
;
o
[
2
]
=
(
uint8_t
)(
a
>>
40
)
;
o
[
3
]
=
(
uint8_t
)(
a
>>
32
)
;
o
[
4
]
=
(
uint8_t
)(
a
>>
24
)
;
o
[
5
]
=
(
uint8_t
)(
a
>>
16
)
;
a
>>=
8
;
o
+=
6
;
break
;
case
16
:
o
[
0
]
=
a
>>
56
;
o
[
1
]
=
a
>>
48
;
o
[
2
]
=
a
>>
40
;
o
[
3
]
=
a
>>
32
;
o
[
4
]
=
a
>>
24
;
o
[
0
]
=
(
uint8_t
)(
a
>>
56
)
;
o
[
1
]
=
(
uint8_t
)(
a
>>
48
)
;
o
[
2
]
=
(
uint8_t
)(
a
>>
40
)
;
o
[
3
]
=
(
uint8_t
)(
a
>>
32
)
;
o
[
4
]
=
(
uint8_t
)(
a
>>
24
)
;
a
>>=
16
;
o
+=
5
;
break
;
case
24
:
o
[
0
]
=
a
>>
56
;
o
[
1
]
=
a
>>
48
;
o
[
2
]
=
a
>>
40
;
o
[
3
]
=
a
>>
32
;
o
[
0
]
=
(
uint8_t
)(
a
>>
56
)
;
o
[
1
]
=
(
uint8_t
)(
a
>>
48
)
;
o
[
2
]
=
(
uint8_t
)(
a
>>
40
)
;
o
[
3
]
=
(
uint8_t
)(
a
>>
32
)
;
a
>>=
24
;
o
+=
4
;
break
;
case
32
:
o
[
0
]
=
a
>>
56
;
o
[
1
]
=
a
>>
48
;
o
[
2
]
=
a
>>
40
;
o
[
0
]
=
(
uint8_t
)(
a
>>
56
)
;
o
[
1
]
=
(
uint8_t
)(
a
>>
48
)
;
o
[
2
]
=
(
uint8_t
)(
a
>>
40
)
;
a
>>=
32
;
o
+=
3
;
break
;
case
40
:
o
[
0
]
=
a
>>
56
;
o
[
1
]
=
a
>>
48
;
o
[
0
]
=
(
uint8_t
)(
a
>>
56
)
;
o
[
1
]
=
(
uint8_t
)(
a
>>
48
)
;
a
>>=
40
;
o
+=
2
;
break
;
case
48
:
*
o
++
=
a
>>
56
;
*
o
++
=
(
uint8_t
)(
a
>>
56
)
;
a
>>=
48
;
break
;
default:
...
...
@@ -230,7 +230,7 @@ static inline void emitblock(struct aec_stream *strm, int k, int ref)
}
}
*
o
=
a
;
*
o
=
(
uint8_t
)
a
;
state
->
cds
=
o
;
state
->
bits
=
p
%
8
;
}
...
...
@@ -248,9 +248,9 @@ static void preprocess_unsigned(struct aec_stream *strm)
struct
internal_state
*
state
=
strm
->
state
;
const
uint32_t
*
restrict
x
=
state
->
data_raw
;
uint32_t
*
restrict
d
=
state
->
data_pp
;
uint32_t
xmax
=
state
->
xmax
;
uint32_t
xmax
=
(
uint32_t
)
state
->
xmax
;
uint32_t
rsi
=
strm
->
rsi
*
strm
->
block_size
-
1
;
int
i
;
unsigned
int
i
;
d
[
0
]
=
x
[
0
];
for
(
i
=
0
;
i
<
rsi
;
i
++
)
{
...
...
@@ -282,11 +282,11 @@ static void preprocess_signed(struct aec_stream *strm)
struct
internal_state
*
state
=
strm
->
state
;
uint32_t
*
restrict
d
=
state
->
data_pp
;
int32_t
*
restrict
x
=
(
int32_t
*
)
state
->
data_raw
;
uint
64
_t
m
=
1ULL
<<
(
strm
->
bits_per_sample
-
1
);
uint
32
_t
m
=
1ULL
<<
(
strm
->
bits_per_sample
-
1
);
int64_t
xmax
=
state
->
xmax
;
int64_t
xmin
=
state
->
xmin
;
uint32_t
rsi
=
strm
->
rsi
*
strm
->
block_size
-
1
;
int
i
;
unsigned
int
i
;
d
[
0
]
=
(
uint32_t
)
x
[
0
];
x
[
0
]
=
(
x
[
0
]
^
m
)
-
m
;
...
...
@@ -296,15 +296,15 @@ static void preprocess_signed(struct aec_stream *strm)
if
(
x
[
i
+
1
]
<
x
[
i
])
{
D
=
(
int64_t
)
x
[
i
]
-
x
[
i
+
1
];
if
(
D
<=
xmax
-
x
[
i
])
d
[
i
+
1
]
=
2
*
D
-
1
;
d
[
i
+
1
]
=
2
*
(
uint32_t
)
D
-
1
;
else
d
[
i
+
1
]
=
xmax
-
x
[
i
+
1
];
d
[
i
+
1
]
=
(
uint32_t
)
xmax
-
x
[
i
+
1
];
}
else
{
D
=
(
int64_t
)
x
[
i
+
1
]
-
x
[
i
];
if
(
D
<=
x
[
i
]
-
xmin
)
d
[
i
+
1
]
=
2
*
D
;
d
[
i
+
1
]
=
2
*
(
uint32_t
)
D
;
else
d
[
i
+
1
]
=
x
[
i
+
1
]
-
xmin
;
d
[
i
+
1
]
=
x
[
i
+
1
]
-
(
uint32_t
)
xmin
;
}
}
state
->
ref
=
1
;
...
...
@@ -317,7 +317,7 @@ static inline uint64_t block_fs(struct aec_stream *strm, int k)
Sum FS of all samples in block for given splitting position.
*/
int
i
;
u
int
32_t
i
;
uint64_t
fs
=
0
;
struct
internal_state
*
state
=
strm
->
state
;
...
...
@@ -410,7 +410,7 @@ static uint32_t assess_splitting_option(struct aec_stream *strm)
}
state
->
k
=
k_min
;
return
len_min
;
return
(
uint32_t
)
len_min
;
}
static
uint32_t
assess_se_option
(
struct
aec_stream
*
strm
)
...
...
@@ -421,9 +421,9 @@ static uint32_t assess_se_option(struct aec_stream *strm)
If length is above limit just return UINT32_MAX.
*/
int
i
;
uint64_t
d
;
uint32_t
i
;
uint32_t
len
;
uint64_t
d
;
struct
internal_state
*
state
=
strm
->
state
;
len
=
1
;
...
...
@@ -439,7 +439,8 @@ static uint32_t assess_se_option(struct aec_stream *strm)
len
=
UINT32_MAX
;
break
;
}
else
{
len
+=
d
*
(
d
+
1
)
/
2
+
state
->
block
[
i
+
1
]
+
1
;
len
+=
(
uint32_t
)
d
*
((
uint32_t
)
d
+
1
)
/
2
+
state
->
block
[
i
+
1
]
+
1
;
}
}
return
len
;
...
...
@@ -483,7 +484,8 @@ static int m_flush_block_resumable(struct aec_stream *strm)
*/
struct
internal_state
*
state
=
strm
->
state
;
int
n
=
MIN
(
state
->
cds
-
state
->
cds_buf
-
state
->
i
,
strm
->
avail_out
);
int
n
=
(
int
)
MIN
((
size_t
)(
state
->
cds
-
state
->
cds_buf
-
state
->
i
),
strm
->
avail_out
);
memcpy
(
strm
->
next_out
,
state
->
cds_buf
+
state
->
i
,
n
);
strm
->
next_out
+=
n
;
strm
->
avail_out
-=
n
;
...
...
@@ -516,7 +518,7 @@ static int m_flush_block(struct aec_stream *strm)
#endif
if
(
state
->
direct_out
)
{
n
=
state
->
cds
-
strm
->
next_out
;
n
=
(
int
)(
state
->
cds
-
strm
->
next_out
)
;
strm
->
next_out
+=
n
;
strm
->
avail_out
-=
n
;
state
->
mode
=
m_get_block
;
...
...
@@ -555,7 +557,7 @@ static int m_encode_uncomp(struct aec_stream *strm)
static
int
m_encode_se
(
struct
aec_stream
*
strm
)
{
int
i
;
u
int
32_t
i
;
uint32_t
d
;
struct
internal_state
*
state
=
strm
->
state
;
...
...
@@ -631,7 +633,7 @@ static int m_check_zero_block(struct aec_stream *strm)
end of a segment or RSI.
*/
int
i
;
u
int
32_t
i
;
struct
internal_state
*
state
=
strm
->
state
;
uint32_t
*
p
=
state
->
block
;
...
...
@@ -861,7 +863,7 @@ int aec_encode_init(struct aec_stream *strm)
state
->
rsi_len
=
strm
->
rsi
*
strm
->
block_size
*
state
->
bytes_per_sample
;
if
(
strm
->
flags
&
AEC_DATA_SIGNED
)
{
state
->
xmin
=
-
(
1
U
LL
<<
(
strm
->
bits_per_sample
-
1
));
state
->
xmin
=
-
(
1LL
<<
(
strm
->
bits_per_sample
-
1
));
state
->
xmax
=
(
1ULL
<<
(
strm
->
bits_per_sample
-
1
))
-
1
;
state
->
preprocess
=
preprocess_signed
;
}
else
{
...
...
@@ -922,7 +924,7 @@ int aec_encode(struct aec_stream *strm, int flush)
while
(
state
->
mode
(
strm
)
==
M_CONTINUE
);
if
(
state
->
direct_out
)
{
n
=
state
->
cds
-
strm
->
next_out
;
n
=
(
int
)(
state
->
cds
-
strm
->
next_out
)
;
strm
->
next_out
+=
n
;
strm
->
avail_out
-=
n
;
...
...
src/encode.h
View file @
6f2ffa17
...
...
@@ -79,37 +79,79 @@ struct internal_state {
void
(
*
get_rsi
)(
struct
aec_stream
*
);
void
(
*
preprocess
)(
struct
aec_stream
*
);
int
id_len
;
/* bit length of code option identification key */
int64_t
xmin
;
/* minimum integer for preprocessing */
int64_t
xmax
;
/* maximum integer for preprocessing */
int
i
;
/* counter */
uint32_t
*
data_pp
;
/* RSI blocks of preprocessed input */
uint32_t
*
data_raw
;
/* RSI blocks of input */
int
blocks_avail
;
/* remaining blocks in buffer */
uint32_t
*
block
;
/* current (preprocessed) input block */
int
rsi_len
;
/* reference sample interval in byte */
uint8_t
*
cds
;
/* current Coded Data Set output */
uint8_t
cds_buf
[
CDSLEN
];
/* buffer for one CDS (only used if
* strm->next_out cannot hold full CDS) */
int
direct_out
;
/* cds points to strm->next_out (1)
* or cds_buf (0) */
int
bits
;
/* Free bits (LSB) in output buffer or
* accumulator */
int
ref
;
/* length of reference sample in current
* block i.e. 0 or 1 depending on whether
* the block has a reference sample or
* not */
int
zero_ref
;
/* current zero block has a reference sample */
uint32_t
zero_ref_sample
;
/* reference sample of zero block */
int
bytes_per_sample
;
/* storage size of samples in bytes */
int
zero_blocks
;
/* number of contiguous zero blocks */
int
block_nonzero
;
/* 1 if this is the first non-zero block
* after one or more zero blocks */
int
k
;
/* splitting position */
int
kmax
;
/* maximum number for k depending on id_len */
int
flush
;
/* flush option copied from argument */
int
flushed
;
/* 1 if flushing was successful */
uint32_t
uncomp_len
;
/* length of uncompressed CDS */
/* bit length of code option identification key */
int
id_len
;
/* minimum integer for preprocessing */
int64_t
xmin
;
/* maximum integer for preprocessing */
int64_t
xmax
;
uint32_t
i
;
/* RSI blocks of preprocessed input */
uint32_t
*
data_pp
;
/* RSI blocks of input */
uint32_t
*
data_raw
;
/* remaining blocks in buffer */
int
blocks_avail
;
/* current (preprocessed) input block */
uint32_t
*
block
;
/* reference sample interval in byte */
uint32_t
rsi_len
;
/* current Coded Data Set output */
uint8_t
*
cds
;
/* buffer for one CDS (only used if strm->next_out cannot hold
* full CDS) */
uint8_t
cds_buf
[
CDSLEN
];
/* cds points to strm->next_out (1) or cds_buf (0) */
int
direct_out
;
/* Free bits (LSB) in output buffer or accumulator */
int
bits
;