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
019e874e
Commit
019e874e
authored
Feb 11, 2021
by
Mathis Rosenhauer
Browse files
Fix clang-tidy diagnostics
parent
1553de14
Changes
4
Show whitespace changes
Inline
Side-by-side
src/aec.c
View file @
019e874e
...
...
@@ -56,14 +56,33 @@ int get_param(unsigned int *param, int *iarg, char *argv[])
return
0
;
}
void
usage
(
void
)
{
fprintf
(
stderr
,
"NAME
\n\t
aec - encode or decode files "
);
fprintf
(
stderr
,
"with Adaptive Entropy Coding
\n\n
"
);
fprintf
(
stderr
,
"SYNOPSIS
\n\t
aec [OPTION]... SOURCE DEST
\n
"
);
fprintf
(
stderr
,
"
\n
OPTIONS
\n
"
);
fprintf
(
stderr
,
"
\t
-3
\n\t\t
24 bit samples are stored in 3 bytes
\n
"
);
fprintf
(
stderr
,
"
\t
-N
\n\t\t
disable pre/post processing
\n
"
);
fprintf
(
stderr
,
"
\t
-b size
\n\t\t
internal buffer size in bytes
\n
"
);
fprintf
(
stderr
,
"
\t
-d
\n\t\t
decode SOURCE. If -d is not used: encode.
\n
"
);
fprintf
(
stderr
,
"
\t
-j samples
\n\t\t
block size in samples
\n
"
);
fprintf
(
stderr
,
"
\t
-m
\n\t\t
samples are MSB first. Default is LSB
\n
"
);
fprintf
(
stderr
,
"
\t
-n bits
\n\t\t
bits per sample
\n
"
);
fprintf
(
stderr
,
"
\t
-p
\n\t\t
pad RSI to byte boundary
\n
"
);
fprintf
(
stderr
,
"
\t
-r blocks
\n\t\t
reference sample interval in blocks
\n
"
);
fprintf
(
stderr
,
"
\t
-s
\n\t\t
samples are signed. Default is unsigned
\n
"
);
fprintf
(
stderr
,
"
\t
-t
\n\t\t
use restricted set of code options
\n\n
"
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
struct
aec_stream
strm
;
unsigned
char
*
in
;
unsigned
char
*
out
;
unsigned
char
*
in
=
NULL
;
unsigned
char
*
out
=
NULL
;
size_t
total_out
;
unsigned
int
chunk
;
int
status
;
int
status
=
0
;
int
input_avail
,
output_avail
;
char
*
infn
,
*
outfn
;
FILE
*
infp
,
*
outfp
;
...
...
@@ -81,8 +100,10 @@ int main(int argc, char *argv[])
while
(
iarg
<
argc
-
2
)
{
opt
=
argv
[
iarg
];
if
(
opt
[
0
]
!=
'-'
)
goto
FAIL
;
if
(
opt
[
0
]
!=
'-'
)
{
usage
();
goto
DESTRUCT
;
}
switch
(
opt
[
1
])
{
case
'3'
:
strm
.
flags
|=
AEC_DATA_3BYTE
;
...
...
@@ -91,29 +112,37 @@ int main(int argc, char *argv[])
strm
.
flags
&=
~
AEC_DATA_PREPROCESS
;
break
;
case
'b'
:
if
(
get_param
(
&
chunk
,
&
iarg
,
argv
))
goto
FAIL
;
if
(
get_param
(
&
chunk
,
&
iarg
,
argv
))
{
usage
();
goto
DESTRUCT
;
}
break
;
case
'd'
:
dflag
=
1
;
break
;
case
'j'
:
if
(
get_param
(
&
strm
.
block_size
,
&
iarg
,
argv
))
goto
FAIL
;
if
(
get_param
(
&
strm
.
block_size
,
&
iarg
,
argv
))
{
usage
();
goto
DESTRUCT
;
}
break
;
case
'm'
:
strm
.
flags
|=
AEC_DATA_MSB
;
break
;
case
'n'
:
if
(
get_param
(
&
strm
.
bits_per_sample
,
&
iarg
,
argv
))
goto
FAIL
;
if
(
get_param
(
&
strm
.
bits_per_sample
,
&
iarg
,
argv
))
{
usage
();
goto
DESTRUCT
;
}
break
;
case
'p'
:
strm
.
flags
|=
AEC_PAD_RSI
;
break
;
case
'r'
:
if
(
get_param
(
&
strm
.
rsi
,
&
iarg
,
argv
))
goto
FAIL
;
if
(
get_param
(
&
strm
.
rsi
,
&
iarg
,
argv
))
{
usage
();
goto
DESTRUCT
;
}
break
;
case
's'
:
strm
.
flags
|=
AEC_DATA_SIGNED
;
...
...
@@ -122,13 +151,16 @@ int main(int argc, char *argv[])
strm
.
flags
|=
AEC_RESTRICTED
;
break
;
default:
goto
FAIL
;
usage
();
goto
DESTRUCT
;
}
iarg
++
;
}
if
(
argc
-
iarg
<
2
)
goto
FAIL
;
if
(
argc
-
iarg
<
2
)
{
usage
();
goto
DESTRUCT
;
}
infn
=
argv
[
iarg
];
outfn
=
argv
[
iarg
+
1
];
...
...
@@ -145,8 +177,10 @@ int main(int argc, char *argv[])
out
=
(
unsigned
char
*
)
malloc
(
chunk
);
in
=
(
unsigned
char
*
)
malloc
(
chunk
);
if
(
in
==
NULL
||
out
==
NULL
)
exit
(
-
1
);
if
(
in
==
NULL
||
out
==
NULL
)
{
status
=
99
;
goto
DESTRUCT
;
}
total_out
=
0
;
strm
.
avail_in
=
0
;
...
...
@@ -158,11 +192,13 @@ int main(int argc, char *argv[])
if
((
infp
=
fopen
(
infn
,
"rb"
))
==
NULL
)
{
fprintf
(
stderr
,
"ERROR: cannot open input file %s
\n
"
,
infn
);
return
1
;
status
=
99
;
goto
DESTRUCT
;
}
if
((
outfp
=
fopen
(
outfn
,
"wb"
))
==
NULL
)
{
fprintf
(
stderr
,
"ERROR: cannot open output file %s
\n
"
,
infn
);
return
1
;
status
=
99
;
goto
DESTRUCT
;
}
if
(
dflag
)
...
...
@@ -172,7 +208,7 @@ int main(int argc, char *argv[])
if
(
status
!=
AEC_OK
)
{
fprintf
(
stderr
,
"ERROR: initialization failed (%d)
\n
"
,
status
);
return
1
;
goto
DESTRUCT
;
}
while
(
input_avail
||
output_avail
)
{
...
...
@@ -190,7 +226,7 @@ int main(int argc, char *argv[])
if
(
status
!=
AEC_OK
)
{
fprintf
(
stderr
,
"ERROR: %i
\n
"
,
status
);
return
1
;
goto
DESTRUCT
;
}
if
(
strm
.
total_out
-
total_out
>
0
)
{
...
...
@@ -210,7 +246,7 @@ int main(int argc, char *argv[])
}
else
{
if
((
status
=
aec_encode
(
&
strm
,
AEC_FLUSH
))
!=
AEC_OK
)
{
fprintf
(
stderr
,
"ERROR: while flushing output (%i)
\n
"
,
status
);
return
1
;
goto
DESTRUCT
;
}
if
(
strm
.
total_out
-
total_out
>
0
)
...
...
@@ -221,25 +257,11 @@ int main(int argc, char *argv[])
fclose
(
infp
);
fclose
(
outfp
);
DESTRUCT:
if
(
in
)
free
(
in
);
if
(
out
)
free
(
out
);
return
0
;
FAIL:
fprintf
(
stderr
,
"NAME
\n\t
aec - encode or decode files "
);
fprintf
(
stderr
,
"with Adaptive Entropy Coding
\n\n
"
);
fprintf
(
stderr
,
"SYNOPSIS
\n\t
aec [OPTION]... SOURCE DEST
\n
"
);
fprintf
(
stderr
,
"
\n
OPTIONS
\n
"
);
fprintf
(
stderr
,
"
\t
-3
\n\t\t
24 bit samples are stored in 3 bytes
\n
"
);
fprintf
(
stderr
,
"
\t
-N
\n\t\t
disable pre/post processing
\n
"
);
fprintf
(
stderr
,
"
\t
-b size
\n\t\t
internal buffer size in bytes
\n
"
);
fprintf
(
stderr
,
"
\t
-d
\n\t\t
decode SOURCE. If -d is not used: encode.
\n
"
);
fprintf
(
stderr
,
"
\t
-j samples
\n\t\t
block size in samples
\n
"
);
fprintf
(
stderr
,
"
\t
-m
\n\t\t
samples are MSB first. Default is LSB
\n
"
);
fprintf
(
stderr
,
"
\t
-n bits
\n\t\t
bits per sample
\n
"
);
fprintf
(
stderr
,
"
\t
-p
\n\t\t
pad RSI to byte boundary
\n
"
);
fprintf
(
stderr
,
"
\t
-r blocks
\n\t\t
reference sample interval in blocks
\n
"
);
fprintf
(
stderr
,
"
\t
-s
\n\t\t
samples are signed. Default is unsigned
\n
"
);
fprintf
(
stderr
,
"
\t
-t
\n\t\t
use restricted set of code options
\n\n
"
);
return
1
;
return
status
;
}
tests/check_buffer_sizes.c
View file @
019e874e
...
...
@@ -87,7 +87,8 @@ int main (void)
if
(
!
state
.
ubuf
||
!
state
.
cbuf
||
!
state
.
obuf
)
{
printf
(
"Not enough memory.
\n
"
);
return
99
;
status
=
99
;
goto
DESTRUCT
;
}
strm
.
flags
=
AEC_DATA_PREPROCESS
;
...
...
@@ -100,8 +101,11 @@ int main (void)
goto
DESTRUCT
;
DESTRUCT:
if
(
state
.
ubuf
)
free
(
state
.
ubuf
);
if
(
state
.
cbuf
)
free
(
state
.
cbuf
);
if
(
state
.
obuf
)
free
(
state
.
obuf
);
return
status
;
...
...
tests/check_code_options.c
View file @
019e874e
...
...
@@ -303,7 +303,8 @@ int main(int argc, char *argv[])
if
(
!
state
.
ubuf
||
!
state
.
cbuf
||
!
state
.
obuf
)
{
printf
(
"Not enough memory.
\n
"
);
return
99
;
status
=
99
;
goto
DESTRUCT
;
}
strm
.
flags
=
0
;
...
...
@@ -324,8 +325,11 @@ int main(int argc, char *argv[])
status
=
check_byte_orderings
(
&
state
);
DESTRUCT:
if
(
state
.
ubuf
)
free
(
state
.
ubuf
);
if
(
state
.
cbuf
)
free
(
state
.
cbuf
);
if
(
state
.
obuf
)
free
(
state
.
obuf
);
return
status
;
...
...
tests/check_szcomp.c
View file @
019e874e
...
...
@@ -11,9 +11,11 @@
int
main
(
int
argc
,
char
*
argv
[])
{
int
status
;
int
status
=
0
;
SZ_com_t
sz_param
;
unsigned
char
*
source
,
*
dest
,
*
dest1
;
unsigned
char
*
source
=
NULL
;
unsigned
char
*
dest
=
NULL
;
unsigned
char
*
dest1
=
NULL
;
size_t
destLen
,
dest1Len
,
sourceLen
;
FILE
*
fp
;
...
...
@@ -40,27 +42,33 @@ int main(int argc, char *argv[])
dest
=
(
unsigned
char
*
)
malloc
(
destLen
);
dest1
=
(
unsigned
char
*
)
malloc
(
destLen
);
if
(
source
==
NULL
||
dest
==
NULL
||
dest1
==
NULL
)
return
1
;
if
(
source
==
NULL
||
dest
==
NULL
||
dest1
==
NULL
)
{
status
=
99
;
goto
DESTRUCT
;
}
sourceLen
=
fread
(
source
,
1
,
sourceLen
,
fp
);
status
=
SZ_BufftoBuffCompress
(
dest
,
&
destLen
,
source
,
sourceLen
,
&
sz_param
);
if
(
status
!=
SZ_OK
)
return
status
;
goto
DESTRUCT
;
dest1Len
=
sourceLen
;
status
=
SZ_BufftoBuffDecompress
(
dest1
,
&
dest1Len
,
dest
,
destLen
,
&
sz_param
);
if
(
status
!=
SZ_OK
)
return
status
;
goto
DESTRUCT
;
if
(
memcmp
(
source
,
dest1
,
sourceLen
)
!=
0
)
fprintf
(
stderr
,
"File %s Buffers differ
\n
"
,
argv
[
2
]);
DESTRUCT:
if
(
source
)
free
(
source
);
if
(
dest
)
free
(
dest
);
if
(
dest1
)
free
(
dest1
);
return
0
;
return
status
;
}
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