FILE *fout;
bool abort_flag;
bool analysis_mode;
+ bool analyze_residual;
bool test_only;
bool is_wave_out;
bool is_big_endian;
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 verbose, uint64 skip)
+int decode_wav(const char *infile, const char *outfile, bool analysis_mode, bool analyze_residual, bool verbose, uint64 skip)
{
bool md5_failure = false;
stream_info_struct stream_info;
decoder = 0;
stream_info.abort_flag = false;
stream_info.analysis_mode = analysis_mode;
+ stream_info.analyze_residual = analyze_residual;
stream_info.test_only = (outfile == 0);
stream_info.is_wave_out = true;
stream_info.verbose = verbose;
return 1;
}
-int decode_raw(const char *infile, const char *outfile, bool analysis_mode, bool verbose, uint64 skip, bool is_big_endian, bool is_unsigned_samples)
+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)
{
bool md5_failure = false;
stream_info_struct stream_info;
decoder = 0;
stream_info.abort_flag = false;
stream_info.analysis_mode = analysis_mode;
+ stream_info.analyze_residual = analyze_residual;
stream_info.test_only = (outfile == 0);
stream_info.is_wave_out = false;
stream_info.is_big_endian = is_big_endian;
case FLAC__SUBFRAME_TYPE_FIXED:
fprintf(fout, "\torder=%u\tpartition_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, "\twarmup[%u]=%d\n", i, subframe->data.fixed.warmup[i]);
+ fprintf(fout, "\t\twarmup[%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\tresidual[%u]=%d\n", i, subframe->data.fixed.residual[i]);
+ }
break;
case FLAC__SUBFRAME_TYPE_LPC:
fprintf(fout, "\torder=%u\tpartition_order=%u\tqlp_coeff_precision=%u\tquantization_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, "\twarmup[%u]=%d\n", i, subframe->data.lpc.warmup[i]);
+ fprintf(fout, "\t\twarmup[%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\tresidual[%u]=%d\n", i, subframe->data.lpc.residual[i]);
+ }
break;
case FLAC__SUBFRAME_TYPE_VERBATIM:
fprintf(fout, "\n");
#define flac__decode_h
/* outfile == 0 => test only */
-int decode_wav(const char *infile, const char *outfile, bool analysis_mode, bool verbose, uint64 skip);
-int decode_raw(const char *infile, const char *outfile, bool analysis_mode, bool verbose, uint64 skip, bool is_big_endian, bool is_unsigned_samples);
+int decode_wav(const char *infile, const char *outfile, bool analysis_mode, bool analyze_residual, bool verbose, uint64 skip);
+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);
#endif
int i;
bool verify = false, verbose = true, lax = false, mode_decode = false, test_only = false, analyze = false;
bool do_mid_side = true, loose_mid_side = false, do_exhaustive_model_search = false, do_qlp_coeff_prec_search = false;
+ bool analyze_residual = false;
unsigned padding = 0;
unsigned max_lpc_order = 8;
unsigned qlp_coeff_precision = 0;
qlp_coeff_precision = atoi(argv[++i]);
else if(0 == strcmp(argv[i], "-r"))
rice_optimization_level = atoi(argv[++i]);
+ else if(0 == strcmp(argv[i], "-v"))
+ analyze_residual = true;
+ else if(0 == strcmp(argv[i], "-v-"))
+ analyze_residual = false;
else if(0 == strcmp(argv[i], "-V"))
verify = true;
else if(0 == strcmp(argv[i], "-V-"))
if(mode_decode)
if(format_is_wave)
- return decode_wav(argv[i], test_only? 0 : argv[i+1], analyze, verbose, skip);
+ return decode_wav(argv[i], test_only? 0 : argv[i+1], analyze, analyze_residual, verbose, skip);
else
- return decode_raw(argv[i], test_only? 0 : argv[i+1], analyze, verbose, skip, format_is_big_endian, format_is_unsigned_samples);
+ return decode_raw(argv[i], test_only? 0 : argv[i+1], analyze, analyze_residual, verbose, skip, format_is_big_endian, format_is_unsigned_samples);
else
if(format_is_wave)
return encode_wav(argv[i], argv[i+1], verbose, skip, verify, lax, do_mid_side, loose_mid_side, do_exhaustive_model_search, do_qlp_coeff_prec_search, rice_optimization_level, max_lpc_order, (unsigned)blocksize, qlp_coeff_precision, padding);
printf(" -a : analyze (same as -d except an analysis file is written)\n");
printf(" -s : silent (do not write runtime encode/decode statistics to stdout)\n");
printf(" --skip samples : can be used both for encoding and decoding\n");
+ printf("analyze options:\n");
+ printf(" -v : verbose (include residual signal in output)\n");
printf("encoding options:\n");
printf(" --lax : allow encoder to generate non-Subset files\n");
printf(" -P bytes : write a PADDING block of the given length (0 => no PADDING block, default is -P 0)\n");