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
24f6bb40
Commit
24f6bb40
authored
Jan 28, 2013
by
Mathis Rosenhauer
Committed by
Thomas Jahns
Feb 19, 2013
Browse files
turn emitblock_fs macro into function
parent
bd88807b
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/encode.c
View file @
24f6bb40
...
...
@@ -128,36 +128,31 @@ static inline void copy64(uint8_t *dst, uint64_t src)
dst
[
7
]
=
src
;
}
#define EMITBLOCK_FS(ref) \
static inline void emitblock_fs_##ref(struct aec_stream *strm, \
int k) \
{ \
int i; \
int 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; \
\
for (i = ref; i < strm->block_size; i++) { \
used += (state->block[i] >> k) + 1; \
if (used > 63) { \
copy64(state->cds, acc); \
state->cds += 8; \
acc = 0; \
used &= 0x3f; \
} \
acc |= 1ULL << (63 - used); \
} \
\
copy64(state->cds, acc); \
state->cds += used >> 3; \
state->bits = 7 - (used & 7); \
static
inline
void
emitblock_fs
(
struct
aec_stream
*
strm
,
int
k
,
int
ref
)
{
int
i
;
int
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
;
for
(
i
=
ref
;
i
<
strm
->
block_size
;
i
++
)
{
used
+=
(
state
->
block
[
i
]
>>
k
)
+
1
;
if
(
used
>
63
)
{
copy64
(
state
->
cds
,
acc
);
state
->
cds
+=
8
;
acc
=
0
;
used
&=
0x3f
;
}
acc
|=
1ULL
<<
(
63
-
used
);
}
EMITBLOCK_FS
(
0
);
EMITBLOCK_FS
(
1
);
copy64
(
state
->
cds
,
acc
);
state
->
cds
+=
used
>>
3
;
state
->
bits
=
7
-
(
used
&
7
);
}
static
inline
void
emitblock
(
struct
aec_stream
*
strm
,
int
k
,
int
ref
)
{
...
...
@@ -550,18 +545,11 @@ static int m_encode_splitting(struct aec_stream *strm)
emit
(
state
,
k
+
1
,
state
->
id_len
);
if
(
state
->
ref
)
{
emit
(
state
,
state
->
block
[
0
],
strm
->
bits_per_sample
);
emitblock_fs_1
(
strm
,
k
);
if
(
k
)
emitblock
(
strm
,
k
,
1
);
}
else
{
emitblock_fs_0
(
strm
,
k
);
if
(
k
)
emitblock
(
strm
,
k
,
0
);
}
emitblock_fs
(
strm
,
k
,
state
->
ref
);
if
(
k
)
emitblock
(
strm
,
k
,
state
->
ref
);
return
m_flush_block
(
strm
);
}
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment