Commit aa07a760 authored by Josh Coalson's avatar Josh Coalson
Browse files

minor cosmetics with Ogg defines

parent 123f1e94
......@@ -28,11 +28,11 @@
#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;
......@@ -41,7 +41,7 @@ typedef struct {
typedef struct {
const char *inbasefilename;
#ifdef FLaC__HAS_OGG
#ifdef FLAC__HAS_OGG
FILE *fin;
#endif
FILE *fout;
......@@ -61,14 +61,14 @@ typedef struct {
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;
......@@ -79,7 +79,7 @@ static FLAC__bool is_big_endian_host;
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
/*
......@@ -108,7 +108,7 @@ int flac__decode_wav(const char *infilename, const char *outfilename, FLAC__bool
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 */
......@@ -129,7 +129,7 @@ int flac__decode_wav(const char *infilename, const char *outfilename, FLAC__bool
}
}
#ifdef FLaC__HAS_OGG
#ifdef FLAC__HAS_OGG
if(stream_info.is_ogg) {
if (0 == strcmp(infilename, "-")) {
stream_info.fin = stdin;
......@@ -151,7 +151,7 @@ int flac__decode_wav(const char *infilename, const char *outfilename, FLAC__bool
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_;
......@@ -181,7 +181,7 @@ int flac__decode_wav(const char *infilename, const char *outfilename, FLAC__bool
}
}
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");
......@@ -210,7 +210,7 @@ int flac__decode_wav(const char *infilename, const char *outfilename, FLAC__bool
}
}
#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)
......@@ -232,7 +232,7 @@ int flac__decode_wav(const char *infilename, const char *outfilename, FLAC__bool
}
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);
......@@ -249,7 +249,7 @@ int flac__decode_wav(const char *infilename, const char *outfilename, FLAC__bool
}
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)
......@@ -270,7 +270,7 @@ wav_abort_:
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);
......@@ -298,7 +298,7 @@ int flac__decode_raw(const char *infilename, const char *outfilename, FLAC__bool
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 */
......@@ -319,7 +319,7 @@ int flac__decode_raw(const char *infilename, const char *outfilename, FLAC__bool
}
}
#ifdef FLaC__HAS_OGG
#ifdef FLAC__HAS_OGG
if(stream_info.is_ogg) {
if (0 == strcmp(infilename, "-")) {
stream_info.fin = stdin;
......@@ -341,7 +341,7 @@ int flac__decode_raw(const char *infilename, const char *outfilename, FLAC__bool
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_;
......@@ -371,7 +371,7 @@ int flac__decode_raw(const char *infilename, const char *outfilename, FLAC__bool
}
}
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");
......@@ -400,7 +400,7 @@ int flac__decode_raw(const char *infilename, const char *outfilename, FLAC__bool
}
}
#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)
......@@ -422,7 +422,7 @@ int flac__decode_raw(const char *infilename, const char *outfilename, FLAC__bool
}
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);
......@@ -439,7 +439,7 @@ int flac__decode_raw(const char *infilename, const char *outfilename, FLAC__bool
}
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)
......@@ -460,7 +460,7 @@ raw_abort_:
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);
......@@ -477,7 +477,7 @@ FLAC__bool init(const char *infilename, stream_info_struct *stream_info)
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();
......@@ -557,7 +557,7 @@ FLAC__bool write_little_endian_uint32(FILE *f, FLAC__uint32 val)
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)
{
......
......@@ -23,7 +23,7 @@
typedef struct {
FLAC__bool verbose;
#ifdef FLaC__HAS_OGG
#ifdef FLAC__HAS_OGG
FLAC__bool is_ogg;
#endif
FLAC__uint64 skip;
......
......@@ -29,7 +29,7 @@
#include "FLAC/all.h"
#include "encode.h"
#include "file.h"
#ifdef FLaC__HAS_OGG
#ifdef FLAC__HAS_OGG
#include "ogg/ogg.h"
#endif
......@@ -65,7 +65,7 @@ typedef struct {
FLAC__StreamDecoder *decoder;
} verify_fifo_struct;
#ifdef FLaC__HAS_OGG
#ifdef FLAC__HAS_OGG
typedef struct {
ogg_stream_state os;
ogg_page og;
......@@ -89,7 +89,7 @@ typedef struct {
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;
......@@ -148,7 +148,7 @@ int flac__encode_wav(FILE *infile, long infilesize, const char *infilename, cons
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;
......@@ -448,7 +448,7 @@ int flac__encode_wav(FILE *infile, long infilesize, const char *infilename, cons
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
......@@ -481,7 +481,7 @@ wav_abort_:
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
......@@ -518,7 +518,7 @@ int flac__encode_raw(FILE *infile, long infilesize, const char *infilename, cons
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
......@@ -623,7 +623,7 @@ int flac__encode_raw(FILE *infile, long infilesize, const char *infilename, cons
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
......@@ -652,7 +652,7 @@ raw_abort_:
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
......@@ -689,7 +689,7 @@ FLAC__bool init(encoder_wrapper_struct *encoder_wrapper)
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);
......@@ -1027,7 +1027,7 @@ FLAC__StreamEncoderWriteStatus write_callback(const FLAC__StreamEncoder *encoder
}
}
#ifdef FLaC__HAS_OGG
#ifdef FLAC__HAS_OGG
if(encoder_wrapper->use_ogg) {
ogg_packet op;
......
......@@ -25,7 +25,7 @@ typedef struct {
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;
......
......@@ -115,7 +115,7 @@ int main(int argc, char *argv[])
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-"))
......@@ -382,12 +382,12 @@ int main(int argc, char *argv[])
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":"",
......@@ -540,7 +540,7 @@ int long_usage(const char *message, ...)
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");
......@@ -589,7 +589,7 @@ int long_usage(const char *message, ...)
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
""
......@@ -690,7 +690,7 @@ int encode_file(const char *infilename, const char *forced_outfilename, FLAC__bo
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;
......@@ -786,7 +786,7 @@ int decode_file(const char *infilename, const char *forced_outfilename)
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;
......@@ -794,7 +794,7 @@ int decode_file(const char *infilename, const char *forced_outfilename)
#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;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment