#include "FLAC/all.h"
#include "decode.h"
#include "file.h"
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
#include "ogg/ogg.h"
#endif
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
typedef struct {
ogg_sync_state oy;
ogg_stream_state os;
typedef struct {
const char *inbasefilename;
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
FILE *fin;
#endif
FILE *fout;
FLAC__bool skip_count_too_high;
FLAC__uint64 samples_processed;
unsigned frame_counter;
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
FLAC__bool is_ogg;
#endif
union {
FLAC__FileDecoder *file;
FLAC__StreamDecoder *stream;
} decoder;
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
ogg_info_struct ogg;
#endif
} stream_info_struct;
static FLAC__bool init(const char *infilename, stream_info_struct *stream_info);
static FLAC__bool write_little_endian_uint16(FILE *f, FLAC__uint16 val);
static FLAC__bool write_little_endian_uint32(FILE *f, FLAC__uint32 val);
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
static FLAC__StreamDecoderReadStatus read_callback(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
#endif
/*
stream_info.skip_count_too_high = false;
stream_info.samples_processed = 0;
stream_info.frame_counter = 0;
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
stream_info.is_ogg = options.common.is_ogg;
#endif
stream_info.decoder.file = 0; /* this zeroes stream_info.decoder.stream also */
}
}
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
if(stream_info.is_ogg) {
if (0 == strcmp(infilename, "-")) {
stream_info.fin = stdin;
goto wav_abort_;
if(stream_info.skip > 0) {
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
if(stream_info.is_ogg) { //@@@ (move this check into main.c)
fprintf(stderr, "%s: ERROR, can't skip when decoding Ogg-FLAC yet; convert to native-FLAC first\n", stream_info.inbasefilename);
goto wav_abort_;
}
}
else {
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
if(stream_info.is_ogg) {
if(!FLAC__stream_decoder_process_whole_stream(stream_info.decoder.stream)) {
if(stream_info.verbose) fprintf(stderr, "\n");
}
}
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
if(stream_info.is_ogg) {
if(stream_info.decoder.stream) {
if(FLAC__stream_decoder_get_state(stream_info.decoder.stream) != FLAC__STREAM_DECODER_UNINITIALIZED)
}
if(0 != stream_info.fout && stream_info.fout != stdout)
fclose(stream_info.fout);
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
if(stream_info.is_ogg) {
if(0 != stream_info.fin && stream_info.fin != stdin)
fclose(stream_info.fin);
}
return 0;
wav_abort_:
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
if(stream_info.is_ogg) {
if(stream_info.decoder.stream) {
if(FLAC__stream_decoder_get_state(stream_info.decoder.stream) != FLAC__STREAM_DECODER_UNINITIALIZED)
fclose(stream_info.fout);
unlink(outfilename);
}
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
if(stream_info.is_ogg) {
if(0 != stream_info.fin && stream_info.fin != stdin)
fclose(stream_info.fin);
stream_info.skip_count_too_high = false;
stream_info.samples_processed = 0;
stream_info.frame_counter = 0;
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
stream_info.is_ogg = options.common.is_ogg;
#endif
stream_info.decoder.file = 0; /* this zeroes stream_info.decoder.stream also */
}
}
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
if(stream_info.is_ogg) {
if (0 == strcmp(infilename, "-")) {
stream_info.fin = stdin;
goto raw_abort_;
if(stream_info.skip > 0) {
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
if(stream_info.is_ogg) { //@@@ (move this check into main.c)
fprintf(stderr, "%s: ERROR, can't skip when decoding Ogg-FLAC yet; convert to native-FLAC first\n", stream_info.inbasefilename);
goto raw_abort_;
}
}
else {
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
if(stream_info.is_ogg) {
if(!FLAC__stream_decoder_process_whole_stream(stream_info.decoder.stream)) {
if(stream_info.verbose) fprintf(stderr, "\n");
}
}
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
if(stream_info.is_ogg) {
if(stream_info.decoder.stream) {
if(FLAC__stream_decoder_get_state(stream_info.decoder.stream) != FLAC__STREAM_DECODER_UNINITIALIZED)
}
if(0 != stream_info.fout && stream_info.fout != stdout)
fclose(stream_info.fout);
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
if(stream_info.is_ogg) {
if(0 != stream_info.fin && stream_info.fin != stdin)
fclose(stream_info.fin);
}
return 0;
raw_abort_:
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
if(stream_info.is_ogg) {
if(stream_info.decoder.stream) {
if(FLAC__stream_decoder_get_state(stream_info.decoder.stream) != FLAC__STREAM_DECODER_UNINITIALIZED)
fclose(stream_info.fout);
unlink(outfilename);
}
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
if(stream_info.is_ogg) {
if(0 != stream_info.fin && stream_info.fin != stdin)
fclose(stream_info.fin);
is_big_endian_host = (*((FLAC__byte*)(&test)))? false : true;
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
if(stream_info->is_ogg) {
stream_info->decoder.stream = FLAC__stream_decoder_new();
return fwrite(b, 1, 4, f) == 4;
}
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
#define OGG_READ_BUFFER_SIZE 4096
FLAC__StreamDecoderReadStatus read_callback(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data)
{
typedef struct {
FLAC__bool verbose;
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
FLAC__bool is_ogg;
#endif
FLAC__uint64 skip;
#include "FLAC/all.h"
#include "encode.h"
#include "file.h"
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
#include "ogg/ogg.h"
#endif
FLAC__StreamDecoder *decoder;
} verify_fifo_struct;
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
typedef struct {
ogg_stream_state os;
ogg_page og;
FLAC__StreamMetaData_SeekTable seek_table;
unsigned first_seek_point_to_check;
FLAC__bool use_ogg;
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
ogg_info_struct ogg;
#endif
} encoder_wrapper_struct;
encoder_wrapper.outfilename = outfilename;
encoder_wrapper.seek_table.points = 0;
encoder_wrapper.first_seek_point_to_check = 0;
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
encoder_wrapper.use_ogg = options.common.use_ogg;
#endif
(void)infilesize;
if(FLAC__stream_encoder_get_state(encoder_wrapper.encoder) == FLAC__STREAM_ENCODER_OK)
FLAC__stream_encoder_finish(encoder_wrapper.encoder);
FLAC__stream_encoder_delete(encoder_wrapper.encoder);
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
if(encoder_wrapper.use_ogg)
ogg_stream_clear(&encoder_wrapper.ogg.os);
#endif
if(FLAC__stream_encoder_get_state(encoder_wrapper.encoder) == FLAC__STREAM_ENCODER_OK)
FLAC__stream_encoder_finish(encoder_wrapper.encoder);
FLAC__stream_encoder_delete(encoder_wrapper.encoder);
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
if(encoder_wrapper.use_ogg)
ogg_stream_clear(&encoder_wrapper.ogg.os);
#endif
encoder_wrapper.outfilename = outfilename;
encoder_wrapper.seek_table.points = 0;
encoder_wrapper.first_seek_point_to_check = 0;
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
encoder_wrapper.use_ogg = options.common.use_ogg;
#endif
if(FLAC__stream_encoder_get_state(encoder_wrapper.encoder) == FLAC__STREAM_ENCODER_OK)
FLAC__stream_encoder_finish(encoder_wrapper.encoder);
FLAC__stream_encoder_delete(encoder_wrapper.encoder);
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
if(encoder_wrapper.use_ogg)
ogg_stream_clear(&encoder_wrapper.ogg.os);
#endif
if(FLAC__stream_encoder_get_state(encoder_wrapper.encoder) == FLAC__STREAM_ENCODER_OK)
FLAC__stream_encoder_finish(encoder_wrapper.encoder);
FLAC__stream_encoder_delete(encoder_wrapper.encoder);
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
if(encoder_wrapper.use_ogg)
ogg_stream_clear(&encoder_wrapper.ogg.os);
#endif
return false;
}
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
if(encoder_wrapper->use_ogg) {
if(ogg_stream_init(&encoder_wrapper->ogg.os, 0) != 0) {
fprintf(stderr, "%s: ERROR initializing the Ogg stream\n", encoder_wrapper->inbasefilename);
}
}
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
if(encoder_wrapper->use_ogg) {
ogg_packet op;
FLAC__bool verbose;
FLAC__uint64 skip;
FLAC__bool verify;
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
FLAC__bool use_ogg;
#endif
FLAC__bool lax;
lax = true;
else if(0 == strcmp(argv[i], "--lax-"))
lax = false;
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
else if(0 == strcmp(argv[i], "--ogg"))
use_ogg = true;
else if(0 == strcmp(argv[i], "--ogg-"))
if(!mode_decode) {
fprintf(stderr,
"options:%s%s"
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
"%s"
#endif
"%s -P %u -b %u%s -l %u%s%s%s -q %u -r %u,%u -R %u%s\n",
delete_input?" --delete-input-file":"", sector_align?" --sector-align":"",
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
use_ogg?" --ogg":"",
#endif
lax?" --lax":"",
fprintf(out, " --a-rtext : include residual signal in text output\n");
fprintf(out, " --a-rgp : generate gnuplot files of residual distribution of each subframe\n");
fprintf(out, "encoding options:\n");
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
fprintf(out, " --ogg : output Ogg-FLAC stream instead of native FLAC\n");
#endif
fprintf(out, " --lax : allow encoder to generate non-Subset files\n");
fprintf(out, " -V : verify a correct encoding by decoding the output in parallel and\n");
fprintf(out, " comparing to the original\n");
fprintf(out, " -S-, -m-, -M-, -e-, -E-, -p-, -V-, --delete-input-file-,%s --lax-, --sector-align-\n",
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
" --ogg-,"
#else
""
common_options.verbose = verbose;
common_options.skip = skip;
common_options.verify = verify;
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
common_options.use_ogg = use_ogg;
#endif
common_options.lax = lax;
else
treat_as_ogg = false;
-#ifndef FLaC__HAS_OGG
+#ifndef FLAC__HAS_OGG
if(treat_as_ogg) {
fprintf(stderr, "%s: Ogg support has not been built into this copy of flac\n", infilename);
return 1;
#endif
common_options.verbose = verbose;
-#ifdef FLaC__HAS_OGG
+#ifdef FLAC__HAS_OGG
common_options.is_ogg = treat_as_ogg;
#endif
common_options.skip = skip;