Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Mathis Rosenhauer
libaec
Commits
bccdb29d
Commit
bccdb29d
authored
Aug 31, 2012
by
Mathis Rosenhauer
Browse files
Additions from 121x0b2: option selection, larger blocks.
parent
4b97410f
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/Makefile
View file @
bccdb29d
...
@@ -40,12 +40,10 @@ clean:
...
@@ -40,12 +40,10 @@ clean:
*
.gcno
*
.gcda
*
.gcov gmon.out
*
.gcno
*
.gcda
*
.gcov gmon.out
check
:
encode decode test_szcomp
check
:
encode decode test_szcomp
./encode
-c
-b1
-B8
-R128
../data/example_data
>
../data/test.aee
./encode
-c
-b1
-B8
-R128
-J64
../data/example_data
>
../data/test.aee
./decode
-b1
-B8
-R128
../data/test.aee
./decode
-b1
-B8
-R128
-J64
../data/test.aee
diff ../data/test ../data/example_data
diff ../data/test ../data/example_data
./encode
-c
-b1024
-B8
-R128
../data/example_data
>
../data/test.aee
./encode
-c
-b1024
-B8
-R128
-J64
../data/example_data
>
../data/test.aee
./decode
-b1024
-B8
-R128
../data/test.aee
./decode
-b1024
-B8
-R128
-J64
../data/test.aee
diff ../data/test ../data/example_data
diff ../data/test ../data/example_data
./test_szcomp 65536 ../data/example_data_16
./test_szcomp 65536 ../data/example_data_16
src/aed.c
View file @
bccdb29d
...
@@ -42,7 +42,7 @@ typedef struct internal_state {
...
@@ -42,7 +42,7 @@ typedef struct internal_state {
}
decode_state
;
}
decode_state
;
/* decoding table for the second-extension option */
/* decoding table for the second-extension option */
static
const
int
second_extension
[
36
][
2
]
=
{
static
const
int
second_extension
[
92
][
2
]
=
{
{
0
,
0
},
{
0
,
0
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
},
{
2
,
3
},
{
2
,
3
},
{
2
,
3
},
{
2
,
3
},
{
2
,
3
},
{
2
,
3
},
...
@@ -50,7 +50,12 @@ static const int second_extension[36][2] = {
...
@@ -50,7 +50,12 @@ static const int second_extension[36][2] = {
{
4
,
10
},
{
4
,
10
},
{
4
,
10
},
{
4
,
10
},
{
4
,
10
},
{
4
,
10
},
{
4
,
10
},
{
4
,
10
},
{
4
,
10
},
{
4
,
10
},
{
5
,
15
},
{
5
,
15
},
{
5
,
15
},
{
5
,
15
},
{
5
,
15
},
{
5
,
15
},
{
5
,
15
},
{
5
,
15
},
{
5
,
15
},
{
5
,
15
},
{
5
,
15
},
{
5
,
15
},
{
6
,
21
},
{
6
,
21
},
{
6
,
21
},
{
6
,
21
},
{
6
,
21
},
{
6
,
21
},
{
6
,
21
},
{
6
,
21
},
{
6
,
21
},
{
6
,
21
},
{
6
,
21
},
{
6
,
21
},
{
6
,
21
},
{
6
,
21
},
{
7
,
28
},
{
7
,
28
},
{
7
,
28
},
{
7
,
28
},
{
7
,
28
},
{
7
,
28
},
{
7
,
28
},
{
7
,
28
}
{
7
,
28
},
{
7
,
28
},
{
7
,
28
},
{
7
,
28
},
{
7
,
28
},
{
7
,
28
},
{
7
,
28
},
{
7
,
28
},
{
8
,
36
},
{
8
,
36
},
{
8
,
36
},
{
8
,
36
},
{
8
,
36
},
{
8
,
36
},
{
8
,
36
},
{
8
,
36
},
{
8
,
36
},
{
9
,
45
},
{
9
,
45
},
{
9
,
45
},
{
9
,
45
},
{
9
,
45
},
{
9
,
45
},
{
9
,
45
},
{
9
,
45
},
{
9
,
45
},
{
9
,
45
},
{
10
,
55
},
{
10
,
55
},
{
10
,
55
},
{
10
,
55
},
{
10
,
55
},
{
10
,
55
},
{
10
,
55
},
{
10
,
55
},
{
10
,
55
},
{
10
,
55
},
{
10
,
55
},
{
11
,
66
},
{
11
,
66
},
{
11
,
66
},
{
11
,
66
},
{
11
,
66
},
{
11
,
66
},
{
11
,
66
},
{
11
,
66
},
{
11
,
66
},
{
11
,
66
},
{
11
,
66
},
{
11
,
66
},
{
12
,
78
},
{
12
,
78
},
{
12
,
78
},
{
12
,
78
},
{
12
,
78
},
{
12
,
78
},
{
12
,
78
},
{
12
,
78
},
{
12
,
78
},
{
12
,
78
},
{
12
,
78
},
{
12
,
78
},
{
12
,
78
}
};
};
enum
enum
...
...
src/aee.c
View file @
bccdb29d
...
@@ -336,7 +336,7 @@ static inline int m_check_zero_block(ae_streamp strm)
...
@@ -336,7 +336,7 @@ static inline int m_check_zero_block(ae_streamp strm)
static
inline
int
m_select_code_option
(
ae_streamp
strm
)
static
inline
int
m_select_code_option
(
ae_streamp
strm
)
{
{
int
i
,
k
,
this_bs
,
looked_bothways
,
direction
;
int
i
,
j
,
k
,
this_bs
,
looked_bothways
,
direction
;
int64_t
d
,
split_len
,
uncomp_len
;
int64_t
d
,
split_len
,
uncomp_len
;
int64_t
split_len_min
,
se_len
,
fs_len
;
int64_t
split_len_min
,
se_len
,
fs_len
;
encode_state
*
state
=
strm
->
state
;
encode_state
*
state
=
strm
->
state
;
...
@@ -365,15 +365,9 @@ static inline int m_select_code_option(ae_streamp strm)
...
@@ -365,15 +365,9 @@ static inline int m_select_code_option(ae_streamp strm)
if
(
state
->
ref
==
0
)
if
(
state
->
ref
==
0
)
fs_len
+=
(
state
->
in_block
[
0
]
>>
i
);
fs_len
+=
(
state
->
in_block
[
0
]
>>
i
);
if
(
strm
->
block_size
==
16
)
if
(
strm
->
block_size
>
8
)
fs_len
+=
(
state
->
in_block
[
8
]
>>
i
)
for
(
j
=
8
;
j
<
strm
->
block_size
;
j
++
)
+
(
state
->
in_block
[
9
]
>>
i
)
fs_len
+=
state
->
in_block
[
j
]
>>
i
;
+
(
state
->
in_block
[
10
]
>>
i
)
+
(
state
->
in_block
[
11
]
>>
i
)
+
(
state
->
in_block
[
12
]
>>
i
)
+
(
state
->
in_block
[
13
]
>>
i
)
+
(
state
->
in_block
[
14
]
>>
i
)
+
(
state
->
in_block
[
15
]
>>
i
);
split_len
=
fs_len
+
this_bs
*
(
i
+
1
);
split_len
=
fs_len
+
this_bs
*
(
i
+
1
);
...
@@ -480,7 +474,7 @@ static inline int m_select_code_option(ae_streamp strm)
...
@@ -480,7 +474,7 @@ static inline int m_select_code_option(ae_streamp strm)
/* Decide which option to use */
/* Decide which option to use */
if
(
split_len_min
<
uncomp_len
)
if
(
split_len_min
<
uncomp_len
)
{
{
if
(
split_len_min
<
=
se_len
)
if
(
split_len_min
<
se_len
)
{
{
/* Splitting won - the most common case. */
/* Splitting won - the most common case. */
return
m_encode_splitting
(
strm
);
return
m_encode_splitting
(
strm
);
...
@@ -622,9 +616,16 @@ int ae_encode_init(ae_streamp strm)
...
@@ -622,9 +616,16 @@ int ae_encode_init(ae_streamp strm)
/* Some sanity checks */
/* Some sanity checks */
if
(
strm
->
bit_per_sample
>
32
||
strm
->
bit_per_sample
==
0
)
if
(
strm
->
bit_per_sample
>
32
||
strm
->
bit_per_sample
==
0
)
{
return
AE_ERRNO
;
return
AE_ERRNO
;
}
if
(
strm
->
block_size
!=
8
&&
strm
->
block_size
!=
16
&&
strm
->
block_size
!=
32
&&
strm
->
block_size
!=
64
)
return
AE_ERRNO
;
if
(
strm
->
rsi
>
4096
)
return
AE_ERRNO
;
/* Internal state for encoder */
/* Internal state for encoder */
state
=
(
encode_state
*
)
malloc
(
sizeof
(
encode_state
));
state
=
(
encode_state
*
)
malloc
(
sizeof
(
encode_state
));
...
@@ -642,7 +643,10 @@ int ae_encode_init(ae_streamp strm)
...
@@ -642,7 +643,10 @@ int ae_encode_init(ae_streamp strm)
state
->
in_blklen
=
4
*
strm
->
block_size
;
state
->
in_blklen
=
4
*
strm
->
block_size
;
if
(
strm
->
flags
&
AE_DATA_MSB
)
if
(
strm
->
flags
&
AE_DATA_MSB
)
{
state
->
get_sample
=
get_msb_32
;
state
->
get_sample
=
get_msb_32
;
state
->
get_block
=
get_block_msb_32
;
}
else
else
state
->
get_sample
=
get_lsb_32
;
state
->
get_sample
=
get_lsb_32
;
}
}
...
@@ -659,7 +663,7 @@ int ae_encode_init(ae_streamp strm)
...
@@ -659,7 +663,7 @@ int ae_encode_init(ae_streamp strm)
if
(
strm
->
block_size
==
8
)
if
(
strm
->
block_size
==
8
)
state
->
get_block
=
get_block_msb_16_bs_8
;
state
->
get_block
=
get_block_msb_16_bs_8
;
else
else
state
->
get_block
=
get_block_msb_16
_bs_16
;
state
->
get_block
=
get_block_msb_16
;
}
}
else
else
state
->
get_sample
=
get_lsb_16
;
state
->
get_sample
=
get_lsb_16
;
...
@@ -675,7 +679,7 @@ int ae_encode_init(ae_streamp strm)
...
@@ -675,7 +679,7 @@ int ae_encode_init(ae_streamp strm)
if
(
strm
->
block_size
==
8
)
if
(
strm
->
block_size
==
8
)
state
->
get_block
=
get_block_8_bs_8
;
state
->
get_block
=
get_block_8_bs_8
;
else
else
state
->
get_block
=
get_block_8
_bs_16
;
state
->
get_block
=
get_block_8
;
}
}
if
(
strm
->
flags
&
AE_DATA_SIGNED
)
if
(
strm
->
flags
&
AE_DATA_SIGNED
)
...
@@ -696,7 +700,7 @@ int ae_encode_init(ae_streamp strm)
...
@@ -696,7 +700,7 @@ int ae_encode_init(ae_streamp strm)
}
}
/* Largest possible block according to specs */
/* Largest possible block according to specs */
state
->
out_blklen
=
(
5
+
1
6
*
32
)
/
8
+
3
;
state
->
out_blklen
=
(
5
+
6
4
*
32
)
/
8
+
3
;
state
->
out_block
=
(
uint8_t
*
)
malloc
(
state
->
out_blklen
);
state
->
out_block
=
(
uint8_t
*
)
malloc
(
state
->
out_blklen
);
if
(
state
->
out_block
==
NULL
)
if
(
state
->
out_block
==
NULL
)
{
{
...
...
src/aee_mutators.c
View file @
bccdb29d
...
@@ -82,7 +82,7 @@ void get_block_msb_16_bs_8(ae_streamp strm)
...
@@ -82,7 +82,7 @@ void get_block_msb_16_bs_8(ae_streamp strm)
strm
->
avail_in
-=
16
;
strm
->
avail_in
-=
16
;
}
}
void
get_block_msb_16
_bs_16
(
ae_streamp
strm
)
void
get_block_msb_16
(
ae_streamp
strm
)
{
{
int
i
;
int
i
;
int64_t
*
block
=
strm
->
state
->
in_block
;
int64_t
*
block
=
strm
->
state
->
in_block
;
...
@@ -92,9 +92,26 @@ void get_block_msb_16_bs_16(ae_streamp strm)
...
@@ -92,9 +92,26 @@ void get_block_msb_16_bs_16(ae_streamp strm)
block
[
i
]
=
(
strm
->
next_in
[
2
*
i
]
<<
8
)
block
[
i
]
=
(
strm
->
next_in
[
2
*
i
]
<<
8
)
|
strm
->
next_in
[
2
*
i
+
1
];
|
strm
->
next_in
[
2
*
i
+
1
];
}
}
strm
->
next_in
+=
32
;
strm
->
next_in
+=
2
*
strm
->
block_size
;
strm
->
total_in
+=
32
;
strm
->
total_in
+=
2
*
strm
->
block_size
;
strm
->
avail_in
-=
32
;
strm
->
avail_in
-=
2
*
strm
->
block_size
;
}
void
get_block_msb_32
(
ae_streamp
strm
)
{
int
i
;
int64_t
*
block
=
strm
->
state
->
in_block
;
for
(
i
=
0
;
i
<
strm
->
block_size
;
i
++
)
{
block
[
i
]
=
(
strm
->
next_in
[
4
*
i
]
<<
24
)
|
(
strm
->
next_in
[
4
*
i
+
1
]
<<
16
)
|
(
strm
->
next_in
[
4
*
i
+
2
]
<<
8
)
|
strm
->
next_in
[
4
*
i
+
3
];
}
strm
->
next_in
+=
4
*
strm
->
block_size
;
strm
->
total_in
+=
4
*
strm
->
block_size
;
strm
->
avail_in
-=
4
*
strm
->
block_size
;
}
}
void
get_block_8_bs_8
(
ae_streamp
strm
)
void
get_block_8_bs_8
(
ae_streamp
strm
)
...
@@ -115,28 +132,15 @@ void get_block_8_bs_8(ae_streamp strm)
...
@@ -115,28 +132,15 @@ void get_block_8_bs_8(ae_streamp strm)
strm
->
avail_in
-=
8
;
strm
->
avail_in
-=
8
;
}
}
void
get_block_8
_bs_16
(
ae_streamp
strm
)
void
get_block_8
(
ae_streamp
strm
)
{
{
int
i
;
int64_t
*
block
=
strm
->
state
->
in_block
;
int64_t
*
block
=
strm
->
state
->
in_block
;
block
[
0
]
=
strm
->
next_in
[
0
];
for
(
i
=
0
;
i
<
strm
->
block_size
;
i
++
)
block
[
1
]
=
strm
->
next_in
[
1
];
block
[
i
]
=
strm
->
next_in
[
i
];
block
[
2
]
=
strm
->
next_in
[
2
];
block
[
3
]
=
strm
->
next_in
[
3
];
block
[
4
]
=
strm
->
next_in
[
4
];
block
[
5
]
=
strm
->
next_in
[
5
];
block
[
6
]
=
strm
->
next_in
[
6
];
block
[
7
]
=
strm
->
next_in
[
7
];
block
[
8
]
=
strm
->
next_in
[
8
];
block
[
9
]
=
strm
->
next_in
[
9
];
block
[
10
]
=
strm
->
next_in
[
10
];
block
[
11
]
=
strm
->
next_in
[
11
];
block
[
12
]
=
strm
->
next_in
[
12
];
block
[
13
]
=
strm
->
next_in
[
13
];
block
[
14
]
=
strm
->
next_in
[
14
];
block
[
15
]
=
strm
->
next_in
[
15
];
strm
->
next_in
+=
16
;
strm
->
next_in
+=
strm
->
block_size
;
strm
->
total_in
+=
16
;
strm
->
total_in
+=
strm
->
block_size
;
strm
->
avail_in
-=
16
;
strm
->
avail_in
-=
strm
->
block_size
;
}
}
src/aee_mutators.h
View file @
bccdb29d
...
@@ -10,9 +10,10 @@ int64_t get_msb_32(ae_streamp);
...
@@ -10,9 +10,10 @@ int64_t get_msb_32(ae_streamp);
int64_t
get_msb_16
(
ae_streamp
);
int64_t
get_msb_16
(
ae_streamp
);
int64_t
get_8
(
ae_streamp
);
int64_t
get_8
(
ae_streamp
);
void
get_block_msb_32
(
ae_streamp
);
void
get_block_msb_16_bs_8
(
ae_streamp
);
void
get_block_msb_16_bs_8
(
ae_streamp
);
void
get_block_msb_16
_bs_16
(
ae_streamp
);
void
get_block_msb_16
(
ae_streamp
);
void
get_block_8_bs_8
(
ae_streamp
);
void
get_block_8_bs_8
(
ae_streamp
);
void
get_block_8
_bs_16
(
ae_streamp
);
void
get_block_8
(
ae_streamp
);
#endif
#endif
src/decode.c
View file @
bccdb29d
...
@@ -27,7 +27,7 @@ int main(int argc, char *argv[])
...
@@ -27,7 +27,7 @@ int main(int argc, char *argv[])
strm
.
flags
=
AE_DATA_MSB
|
AE_DATA_PREPROCESS
;
strm
.
flags
=
AE_DATA_MSB
|
AE_DATA_PREPROCESS
;
opterr
=
0
;
opterr
=
0
;
while
((
c
=
getopt
(
argc
,
argv
,
"cb:B:R:"
))
!=
-
1
)
while
((
c
=
getopt
(
argc
,
argv
,
"cb:B:
J:
R:"
))
!=
-
1
)
switch
(
c
)
switch
(
c
)
{
{
case
'b'
:
case
'b'
:
...
@@ -36,6 +36,9 @@ int main(int argc, char *argv[])
...
@@ -36,6 +36,9 @@ int main(int argc, char *argv[])
case
'B'
:
case
'B'
:
strm
.
bit_per_sample
=
atoi
(
optarg
);
strm
.
bit_per_sample
=
atoi
(
optarg
);
break
;
break
;
case
'J'
:
strm
.
block_size
=
atoi
(
optarg
);
break
;
case
'R'
:
case
'R'
:
strm
.
rsi
=
atoi
(
optarg
);
strm
.
rsi
=
atoi
(
optarg
);
break
;
break
;
...
...
src/encode.c
View file @
bccdb29d
...
@@ -27,7 +27,7 @@ int main(int argc, char *argv[])
...
@@ -27,7 +27,7 @@ int main(int argc, char *argv[])
strm
.
flags
=
AE_DATA_MSB
|
AE_DATA_PREPROCESS
;
strm
.
flags
=
AE_DATA_MSB
|
AE_DATA_PREPROCESS
;
opterr
=
0
;
opterr
=
0
;
while
((
c
=
getopt
(
argc
,
argv
,
"cb:B:R:"
))
!=
-
1
)
while
((
c
=
getopt
(
argc
,
argv
,
"cb:B:R:
J:
"
))
!=
-
1
)
switch
(
c
)
switch
(
c
)
{
{
case
'b'
:
case
'b'
:
...
@@ -36,6 +36,9 @@ int main(int argc, char *argv[])
...
@@ -36,6 +36,9 @@ int main(int argc, char *argv[])
case
'B'
:
case
'B'
:
strm
.
bit_per_sample
=
atoi
(
optarg
);
strm
.
bit_per_sample
=
atoi
(
optarg
);
break
;
break
;
case
'J'
:
strm
.
block_size
=
atoi
(
optarg
);
break
;
case
'R'
:
case
'R'
:
strm
.
rsi
=
atoi
(
optarg
);
strm
.
rsi
=
atoi
(
optarg
);
break
;
break
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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