Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Stefan Strogin
flac
Commits
de72274e
Commit
de72274e
authored
Mar 16, 2001
by
Josh Coalson
Browse files
add analysis options, move analysis printout to analyze.c
parent
20f315da
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/flac/decode.c
View file @
de72274e
...
...
@@ -32,7 +32,7 @@ typedef struct {
FILE
*
fout
;
bool
abort_flag
;
bool
analysis_mode
;
bool
analyze_residual
;
analysis_options
aopts
;
bool
test_only
;
bool
is_wave_out
;
bool
is_big_endian
;
...
...
@@ -59,7 +59,7 @@ static void metadata_callback(const FLAC__FileDecoder *decoder, const FLAC__Stre
static
void
error_callback
(
const
FLAC__FileDecoder
*
decoder
,
FLAC__StreamDecoderErrorStatus
status
,
void
*
client_data
);
static
void
print_stats
(
const
stream_info_struct
*
stream_info
);
int
decode_wav
(
const
char
*
infile
,
const
char
*
outfile
,
bool
analysis_mode
,
bool
analyze_residual
,
bool
verbose
,
uint64
skip
)
int
decode_wav
(
const
char
*
infile
,
const
char
*
outfile
,
bool
analysis_mode
,
analysis_options
aopts
,
bool
verbose
,
uint64
skip
)
{
bool
md5_failure
=
false
;
stream_info_struct
stream_info
;
...
...
@@ -67,7 +67,7 @@ int decode_wav(const char *infile, const char *outfile, bool analysis_mode, bool
decoder
=
0
;
stream_info
.
abort_flag
=
false
;
stream_info
.
analysis_mode
=
analysis_mode
;
stream_info
.
a
nalyze_residual
=
analyze_residual
;
stream_info
.
a
opts
=
aopts
;
stream_info
.
test_only
=
(
outfile
==
0
);
stream_info
.
is_wave_out
=
true
;
stream_info
.
verbose
=
verbose
;
...
...
@@ -89,6 +89,9 @@ int decode_wav(const char *infile, const char *outfile, bool analysis_mode, bool
}
}
if
(
analysis_mode
)
analyze_init
();
if
(
!
init
(
infile
,
&
stream_info
))
goto
wav_abort_
;
...
...
@@ -136,6 +139,8 @@ int decode_wav(const char *infile, const char *outfile, bool analysis_mode, bool
if
(
verbose
)
printf
(
"
\n
"
);
fflush
(
stdout
);
if
(
analysis_mode
)
analyze_finish
();
if
(
md5_failure
)
{
fprintf
(
stderr
,
"%s: WARNING, MD5 signature mismatch
\n
"
,
infile
);
return
1
;
...
...
@@ -155,10 +160,12 @@ wav_abort_:
fclose
(
stream_info
.
fout
);
unlink
(
outfile
);
}
if
(
analysis_mode
)
analyze_finish
();
return
1
;
}
int
decode_raw
(
const
char
*
infile
,
const
char
*
outfile
,
bool
analysis_mode
,
bool
analyze_residual
,
bool
verbose
,
uint64
skip
,
bool
is_big_endian
,
bool
is_unsigned_samples
)
int
decode_raw
(
const
char
*
infile
,
const
char
*
outfile
,
bool
analysis_mode
,
analysis_options
aopts
,
bool
verbose
,
uint64
skip
,
bool
is_big_endian
,
bool
is_unsigned_samples
)
{
bool
md5_failure
=
false
;
stream_info_struct
stream_info
;
...
...
@@ -166,7 +173,7 @@ int decode_raw(const char *infile, const char *outfile, bool analysis_mode, bool
decoder
=
0
;
stream_info
.
abort_flag
=
false
;
stream_info
.
analysis_mode
=
analysis_mode
;
stream_info
.
a
nalyze_residual
=
analyze_residual
;
stream_info
.
a
opts
=
aopts
;
stream_info
.
test_only
=
(
outfile
==
0
);
stream_info
.
is_wave_out
=
false
;
stream_info
.
is_big_endian
=
is_big_endian
;
...
...
@@ -190,6 +197,9 @@ int decode_raw(const char *infile, const char *outfile, bool analysis_mode, bool
}
}
if
(
analysis_mode
)
analyze_init
();
if
(
!
init
(
infile
,
&
stream_info
))
goto
raw_abort_
;
...
...
@@ -237,6 +247,8 @@ int decode_raw(const char *infile, const char *outfile, bool analysis_mode, bool
if
(
verbose
)
printf
(
"
\n
"
);
fflush
(
stdout
);
if
(
analysis_mode
)
analyze_finish
();
if
(
md5_failure
)
{
fprintf
(
stderr
,
"%s: WARNING, MD5 signature mismatch
\n
"
,
infile
);
return
1
;
...
...
@@ -256,6 +268,8 @@ raw_abort_:
fclose
(
stream_info
.
fout
);
unlink
(
outfile
);
}
if
(
analysis_mode
)
analyze_finish
();
return
1
;
}
...
...
@@ -329,38 +343,7 @@ FLAC__StreamDecoderWriteStatus write_callback(const FLAC__FileDecoder *decoder,
print_stats
(
stream_info
);
if
(
stream_info
->
analysis_mode
)
{
unsigned
i
;
fprintf
(
fout
,
"frame=%u
\t
blocksize=%u
\t
sample_rate=%u
\t
channels=%u
\t
channel_assignment=%s
\n
"
,
stream_info
->
frame_counter
-
1
,
frame
->
header
.
blocksize
,
frame
->
header
.
sample_rate
,
frame
->
header
.
channels
,
FLAC__ChannelAssignmentString
[
frame
->
header
.
channel_assignment
]);
for
(
channel
=
0
;
channel
<
channels
;
channel
++
)
{
const
FLAC__Subframe
*
subframe
=
frame
->
subframes
+
channel
;
fprintf
(
fout
,
"
\t
subframe=%u
\t
type=%s"
,
channel
,
FLAC__SubframeTypeString
[
subframe
->
type
]);
switch
(
subframe
->
type
)
{
case
FLAC__SUBFRAME_TYPE_CONSTANT
:
fprintf
(
fout
,
"
\t
value=%d
\n
"
,
subframe
->
data
.
constant
.
value
);
break
;
case
FLAC__SUBFRAME_TYPE_FIXED
:
fprintf
(
fout
,
"
\t
order=%u
\t
partition_order=%u
\n
"
,
subframe
->
data
.
fixed
.
order
,
subframe
->
data
.
fixed
.
entropy_coding_method
.
data
.
partitioned_rice
.
order
);
/*@@@ assumes method is partitioned-rice */
for
(
i
=
0
;
i
<
subframe
->
data
.
fixed
.
order
;
i
++
)
fprintf
(
fout
,
"
\t\t
warmup[%u]=%d
\n
"
,
i
,
subframe
->
data
.
fixed
.
warmup
[
i
]);
if
(
stream_info
->
analyze_residual
)
{
for
(
i
=
0
;
i
<
frame
->
header
.
blocksize
-
subframe
->
data
.
fixed
.
order
;
i
++
)
fprintf
(
fout
,
"
\t\t
residual[%u]=%d
\n
"
,
i
,
subframe
->
data
.
fixed
.
residual
[
i
]);
}
break
;
case
FLAC__SUBFRAME_TYPE_LPC
:
fprintf
(
fout
,
"
\t
order=%u
\t
partition_order=%u
\t
qlp_coeff_precision=%u
\t
quantization_level=%d
\n
"
,
subframe
->
data
.
lpc
.
order
,
subframe
->
data
.
lpc
.
entropy_coding_method
.
data
.
partitioned_rice
.
order
,
subframe
->
data
.
lpc
.
qlp_coeff_precision
,
subframe
->
data
.
lpc
.
quantization_level
);
/*@@@ assumes method is partitioned-rice */
for
(
i
=
0
;
i
<
subframe
->
data
.
lpc
.
order
;
i
++
)
fprintf
(
fout
,
"
\t\t
warmup[%u]=%d
\n
"
,
i
,
subframe
->
data
.
lpc
.
warmup
[
i
]);
if
(
stream_info
->
analyze_residual
)
{
for
(
i
=
0
;
i
<
frame
->
header
.
blocksize
-
subframe
->
data
.
lpc
.
order
;
i
++
)
fprintf
(
fout
,
"
\t\t
residual[%u]=%d
\n
"
,
i
,
subframe
->
data
.
lpc
.
residual
[
i
]);
}
break
;
case
FLAC__SUBFRAME_TYPE_VERBATIM
:
fprintf
(
fout
,
"
\n
"
);
break
;
}
}
analyze_frame
(
frame
,
stream_info
->
frame_counter
-
1
,
stream_info
->
aopts
,
fout
);
}
else
if
(
!
stream_info
->
test_only
)
{
if
(
bps
==
8
)
{
...
...
Write
Preview
Supports
Markdown
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