Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
libaec
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Mathis Rosenhauer
libaec
Commits
bd88807b
Commit
bd88807b
authored
12 years ago
by
Mathis Rosenhauer
Committed by
Thomas Jahns
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
turn emitblock macro into function
parent
2fbc4ad9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/encode.c
+91
-96
91 additions, 96 deletions
src/encode.c
with
91 additions
and
96 deletions
src/encode.c
+
91
−
96
View file @
bd88807b
...
@@ -159,101 +159,96 @@ static inline void copy64(uint8_t *dst, uint64_t src)
...
@@ -159,101 +159,96 @@ static inline void copy64(uint8_t *dst, uint64_t src)
EMITBLOCK_FS
(
0
);
EMITBLOCK_FS
(
0
);
EMITBLOCK_FS
(
1
);
EMITBLOCK_FS
(
1
);
#define EMITBLOCK(ref) \
static
inline
void
emitblock
(
struct
aec_stream
*
strm
,
int
k
,
int
ref
)
static inline void emitblock_##ref(struct aec_stream *strm, \
{
int k) \
/**
{ \
Emit the k LSB of a whole block of input data.
/** \
*/
Emit the k LSB of a whole block of input data. \
*/
\
uint64_t
a
;
\
struct
internal_state
*
state
=
strm
->
state
;
uint64_t a; \
uint32_t
*
in
=
state
->
block
+
ref
;
struct internal_state *state = strm->state; \
uint32_t
*
in_end
=
state
->
block
+
strm
->
block_size
;
uint32_t *in = state->block + ref; \
uint64_t
mask
=
(
1ULL
<<
k
)
-
1
;
uint32_t *in_end = state->block + strm->block_size; \
uint8_t
*
o
=
state
->
cds
;
uint64_t mask = (1ULL << k) - 1; \
int
p
=
state
->
bits
;
uint8_t *o = state->cds; \
int p = state->bits; \
a
=
*
o
;
\
a = *o; \
while
(
in
<
in_end
)
{
\
a
<<=
56
;
while(in < in_end) { \
p
=
(
p
%
8
)
+
56
;
a <<= 56; \
p = (p % 8) + 56; \
while
(
p
>
k
&&
in
<
in_end
)
{
\
p
-=
k
;
while (p > k && in < in_end) { \
a
+=
((
uint64_t
)(
*
in
++
)
&
mask
)
<<
p
;
p -= k; \
}
a += ((uint64_t)(*in++) & mask) << p; \
} \
switch
(
p
&
~
7
)
{
\
case
0
:
switch (p & ~ 7) { \
o
[
0
]
=
a
>>
56
;
case 0: \
o
[
1
]
=
a
>>
48
;
o[0] = a >> 56; \
o
[
2
]
=
a
>>
40
;
o[1] = a >> 48; \
o
[
3
]
=
a
>>
32
;
o[2] = a >> 40; \
o
[
4
]
=
a
>>
24
;
o[3] = a >> 32; \
o
[
5
]
=
a
>>
16
;
o[4] = a >> 24; \
o
[
6
]
=
a
>>
8
;
o[5] = a >> 16; \
o
+=
7
;
o[6] = a >> 8; \
break
;
o += 7; \
case
8
:
break; \
o
[
0
]
=
a
>>
56
;
case 8: \
o
[
1
]
=
a
>>
48
;
o[0] = a >> 56; \
o
[
2
]
=
a
>>
40
;
o[1] = a >> 48; \
o
[
3
]
=
a
>>
32
;
o[2] = a >> 40; \
o
[
4
]
=
a
>>
24
;
o[3] = a >> 32; \
o
[
5
]
=
a
>>
16
;
o[4] = a >> 24; \
a
>>=
8
;
o[5] = a >> 16; \
o
+=
6
;
a >>= 8; \
break
;
o += 6; \
case
16
:
break; \
o
[
0
]
=
a
>>
56
;
case 16: \
o
[
1
]
=
a
>>
48
;
o[0] = a >> 56; \
o
[
2
]
=
a
>>
40
;
o[1] = a >> 48; \
o
[
3
]
=
a
>>
32
;
o[2] = a >> 40; \
o
[
4
]
=
a
>>
24
;
o[3] = a >> 32; \
a
>>=
16
;
o[4] = a >> 24; \
o
+=
5
;
a >>= 16; \
break
;
o += 5; \
case
24
:
break; \
o
[
0
]
=
a
>>
56
;
case 24: \
o
[
1
]
=
a
>>
48
;
o[0] = a >> 56; \
o
[
2
]
=
a
>>
40
;
o[1] = a >> 48; \
o
[
3
]
=
a
>>
32
;
o[2] = a >> 40; \
a
>>=
24
;
o[3] = a >> 32; \
o
+=
4
;
a >>= 24; \
break
;
o += 4; \
case
32
:
break; \
o
[
0
]
=
a
>>
56
;
case 32: \
o
[
1
]
=
a
>>
48
;
o[0] = a >> 56; \
o
[
2
]
=
a
>>
40
;
o[1] = a >> 48; \
a
>>=
32
;
o[2] = a >> 40; \
o
+=
3
;
a >>= 32; \
break
;
o += 3; \
case
40
:
break; \
o
[
0
]
=
a
>>
56
;
case 40: \
o
[
1
]
=
a
>>
48
;
o[0] = a >> 56; \
a
>>=
40
;
o[1] = a >> 48; \
o
+=
2
;
a >>= 40; \
break
;
o += 2; \
case
48
:
break; \
*
o
++
=
a
>>
56
;
case 48: \
a
>>=
48
;
*o++ = a >> 56; \
break
;
a >>= 48; \
default:
break; \
a
>>=
56
;
default: \
break
;
a >>= 56; \
}
break; \
} \
} \
\
*o = a; \
state->cds = o; \
state->bits = p % 8; \
}
}
EMITBLOCK
(
0
);
*
o
=
a
;
EMITBLOCK
(
1
);
state
->
cds
=
o
;
state
->
bits
=
p
%
8
;
}
static
void
preprocess_unsigned
(
struct
aec_stream
*
strm
)
static
void
preprocess_unsigned
(
struct
aec_stream
*
strm
)
{
{
...
@@ -559,13 +554,13 @@ static int m_encode_splitting(struct aec_stream *strm)
...
@@ -559,13 +554,13 @@ static int m_encode_splitting(struct aec_stream *strm)
emit
(
state
,
state
->
block
[
0
],
strm
->
bits_per_sample
);
emit
(
state
,
state
->
block
[
0
],
strm
->
bits_per_sample
);
emitblock_fs_1
(
strm
,
k
);
emitblock_fs_1
(
strm
,
k
);
if
(
k
)
if
(
k
)
emitblock
_1
(
strm
,
k
);
emitblock
(
strm
,
k
,
1
);
}
}
else
else
{
{
emitblock_fs_0
(
strm
,
k
);
emitblock_fs_0
(
strm
,
k
);
if
(
k
)
if
(
k
)
emitblock
_0
(
strm
,
k
);
emitblock
(
strm
,
k
,
0
);
}
}
return
m_flush_block
(
strm
);
return
m_flush_block
(
strm
);
...
@@ -576,7 +571,7 @@ static int m_encode_uncomp(struct aec_stream *strm)
...
@@ -576,7 +571,7 @@ static int m_encode_uncomp(struct aec_stream *strm)
struct
internal_state
*
state
=
strm
->
state
;
struct
internal_state
*
state
=
strm
->
state
;
emit
(
state
,
(
1U
<<
state
->
id_len
)
-
1
,
state
->
id_len
);
emit
(
state
,
(
1U
<<
state
->
id_len
)
-
1
,
state
->
id_len
);
emitblock
_0
(
strm
,
strm
->
bits_per_sample
);
emitblock
(
strm
,
strm
->
bits_per_sample
,
0
);
return
m_flush_block
(
strm
);
return
m_flush_block
(
strm
);
}
}
...
...
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