From 5bcc3897a390cc72556dc100481e799eebdb8ce9 Mon Sep 17 00:00:00 2001 From: Christoph Terasa Date: Fri, 28 Oct 2016 04:45:36 +0200 Subject: [PATCH 1/2] Makefile.mingw: Use current mingw-w64 compiler. --- Makefile.mingw | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile.mingw b/Makefile.mingw index 1d28b43..213c85a 100644 --- a/Makefile.mingw +++ b/Makefile.mingw @@ -1,8 +1,8 @@ CFLAGS=-std=c99 -pedantic -Wall -O CXXFLAGS=-static -pedantic -Wall -Weffc++ -Wextra -Wold-style-cast -O -STRIP=i586-mingw32msvc-strip -CC=i586-mingw32msvc-gcc -CXX=i586-mingw32msvc-g++ +STRIP=i686-w64-mingw32-strip +CC=i686-w64-mingw32-gcc +CXX=i686-w64-mingw32-g++ EXE_EXT=.exe include Makefile.common From 0704bc0241e2b88feb23e44b106bbcf9a476a882 Mon Sep 17 00:00:00 2001 From: Christoph Terasa Date: Fri, 28 Oct 2016 04:58:50 +0200 Subject: [PATCH 2/2] Added support for writing to stdout - Write everything which has been written to stdout to stderr. - Redirect ogg bitstream output to stdout --- src/ww2ogg.cpp | 51 +++++++++++++++++++++++++++++++++++--------------- src/wwriff.cpp | 48 +++++++++++++++++++++++------------------------ src/wwriff.h | 2 +- 3 files changed, 61 insertions(+), 40 deletions(-) diff --git a/src/ww2ogg.cpp b/src/ww2ogg.cpp index 6ac328e..6b996a7 100644 --- a/src/ww2ogg.cpp +++ b/src/ww2ogg.cpp @@ -5,6 +5,9 @@ #include "wwriff.h" #include "stdint.h" #include "errors.h" +#ifdef __MINGW32__ +#include +#endif using namespace std; @@ -16,13 +19,15 @@ class ww2ogg_options bool inline_codebooks; bool full_setup; ForcePacketFormat force_packet_format; + bool to_stdout; public: ww2ogg_options(void) : in_filename(""), out_filename(""), codebooks_filename("packed_codebooks.bin"), inline_codebooks(false), full_setup(false), - force_packet_format(kNoForcePacketFormat) + force_packet_format(kNoForcePacketFormat), + to_stdout(false) {} void parse_args(int argc, char **argv); const string& get_in_filename(void) const {return in_filename;} @@ -31,19 +36,20 @@ class ww2ogg_options bool get_inline_codebooks(void) const {return inline_codebooks;} bool get_full_setup(void) const {return full_setup;} ForcePacketFormat get_force_packet_format(void) const {return force_packet_format;} + bool get_to_stdout(void) const {return to_stdout;} }; void usage(void) { - cout << endl; - cout << "usage: ww2ogg input.wav [-o output.ogg] [--inline-codebooks] [--full-setup]" << endl << + cerr << endl; + cerr << "usage: ww2ogg input.wav [-o output.ogg] [--inline-codebooks] [--full-setup]" << endl << " [--mod-packets | --no-mod-packets]" << endl << - " [--pcb packed_codebooks.bin]" << endl << endl; + " [--pcb packed_codebooks.bin] [--stdout]" << endl << endl; } int main(int argc, char **argv) { - cout << "Audiokinetic Wwise RIFF/RIFX Vorbis to Ogg Vorbis converter " VERSION " by hcs" << endl << endl; + cerr << "Audiokinetic Wwise RIFF/RIFX Vorbis to Ogg Vorbis converter " VERSION " by hcs" << endl << endl; ww2ogg_options opt; @@ -53,7 +59,7 @@ int main(int argc, char **argv) } catch (const Argument_error& ae) { - cout << ae << endl; + cerr << ae << endl; usage(); return 1; @@ -61,7 +67,7 @@ int main(int argc, char **argv) try { - cout << "Input: " << opt.get_in_filename() << endl; + cerr << "Input: " << opt.get_in_filename() << endl; Wwise_RIFF_Vorbis ww(opt.get_in_filename(), opt.get_codebooks_filename(), opt.get_inline_codebooks(), @@ -70,22 +76,32 @@ int main(int argc, char **argv) ); ww.print_info(); - cout << "Output: " << opt.get_out_filename() << endl; - ofstream of(opt.get_out_filename().c_str(), ios::binary); - if (!of) throw File_open_error(opt.get_out_filename()); - - ww.generate_ogg(of); - cout << "Done!" << endl << endl; + if (!opt.get_to_stdout()) + { + cerr << "Output: " << opt.get_out_filename() << endl; + ofstream of(opt.get_out_filename().c_str(), ios::binary); + if (!of) throw File_open_error(opt.get_out_filename()); + ww.generate_ogg(of); + } + else + { +#ifdef __MINGW32__ + _setmode( _fileno( stdout ), _O_BINARY ); +#endif + ww.generate_ogg(cout); + } + cerr << "Output: stdout" << endl; + cerr << "Done!" << endl << endl; } catch (const File_open_error& fe) { - cout << fe << endl; + cerr << fe << endl; return 1; } catch (const Parse_error& pe) { - cout << pe << endl; + cerr << pe << endl; return 1; } @@ -150,6 +166,11 @@ void ww2ogg_options::parse_args(int argc, char ** argv) codebooks_filename = argv[++i]; } + else if (!strcmp(argv[i], "--stdout")) + { + // write to stdout + to_stdout = true; + } else { // assume anything else is an input file name diff --git a/src/wwriff.cpp b/src/wwriff.cpp index 2784319..1b69e64 100644 --- a/src/wwriff.cpp +++ b/src/wwriff.cpp @@ -459,73 +459,73 @@ void Wwise_RIFF_Vorbis::print_info(void) { if (_little_endian) { - cout << "RIFF WAVE"; + cerr << "RIFF WAVE"; } else { - cout << "RIFX WAVE"; + cerr << "RIFX WAVE"; } - cout << " " << _channels << " channel"; - if (_channels != 1) cout << "s"; - cout << " " << _sample_rate << " Hz " << _avg_bytes_per_second*8 << " bps" << endl; - cout << _sample_count << " samples" << endl; + cerr << " " << _channels << " channel"; + if (_channels != 1) cerr << "s"; + cerr << " " << _sample_rate << " Hz " << _avg_bytes_per_second*8 << " bps" << endl; + cerr << _sample_count << " samples" << endl; if (0 != _loop_count) { - cout << "loop from " << _loop_start << " to " << _loop_end << endl; + cerr << "loop from " << _loop_start << " to " << _loop_end << endl; } if (_old_packet_headers) { - cout << "- 8 byte (old) packet headers" << endl; + cerr << "- 8 byte (old) packet headers" << endl; } else if (_no_granule) { - cout << "- 2 byte packet headers, no granule" << endl; + cerr << "- 2 byte packet headers, no granule" << endl; } else { - cout << "- 6 byte packet headers" << endl; + cerr << "- 6 byte packet headers" << endl; } if (_header_triad_present) { - cout << "- Vorbis header triad present" << endl; + cerr << "- Vorbis header triad present" << endl; } if (_full_setup || _header_triad_present) { - cout << "- full setup header" << endl; + cerr << "- full setup header" << endl; } else { - cout << "- stripped setup header" << endl; + cerr << "- stripped setup header" << endl; } if (_inline_codebooks || _header_triad_present) { - cout << "- inline codebooks" << endl; + cerr << "- inline codebooks" << endl; } else { - cout << "- external codebooks (" << _codebooks_name << ")" << endl; + cerr << "- external codebooks (" << _codebooks_name << ")" << endl; } if (_mod_packets) { - cout << "- modified Vorbis packets" << endl; + cerr << "- modified Vorbis packets" << endl; } else { - cout << "- standard Vorbis packets" << endl; + cerr << "- standard Vorbis packets" << endl; } #if 0 if (0 != _cue_count) { - cout << _cue_count << " cue point"; - if (_cue_count != 1) cout << "s"; - cout << endl; + cerr << _cue_count << " cue point"; + if (_cue_count != 1) cerr << "s"; + cerr << endl; } #endif } @@ -646,7 +646,7 @@ void Wwise_RIFF_Vorbis::generate_ogg_header(Bit_oggstream& os, bool * & mode_blo unsigned int codebook_count = codebook_count_less1 + 1; os << codebook_count_less1; - //cout << codebook_count << " codebooks" << endl; + //cerr << codebook_count << " codebooks" << endl; // rebuild codebooks if (_inline_codebooks) @@ -675,7 +675,7 @@ void Wwise_RIFF_Vorbis::generate_ogg_header(Bit_oggstream& os, bool * & mode_blo { Bit_uint<10> codebook_id; ss >> codebook_id; - //cout << "Codebook " << i << " = " << codebook_id << endl; + //cerr << "Codebook " << i << " = " << codebook_id << endl; try { cbl.rebuild(codebook_id, os); @@ -983,7 +983,7 @@ void Wwise_RIFF_Vorbis::generate_ogg_header(Bit_oggstream& os, bool * & mode_blo mode_blockflag = new bool [mode_count]; mode_bits = ilog(mode_count-1); - //cout << mode_count << " modes" << endl; + //cerr << mode_count << " modes" << endl; for (unsigned int i = 0; i < mode_count; i++) { @@ -1017,7 +1017,7 @@ void Wwise_RIFF_Vorbis::generate_ogg_header(Bit_oggstream& os, bool * & mode_blo } } -void Wwise_RIFF_Vorbis::generate_ogg(ofstream& of) +void Wwise_RIFF_Vorbis::generate_ogg(ostream& of) { Bit_oggstream os(of); diff --git a/src/wwriff.h b/src/wwriff.h index 49e69f2..437838f 100644 --- a/src/wwriff.h +++ b/src/wwriff.h @@ -75,7 +75,7 @@ class Wwise_RIFF_Vorbis void print_info(void); - void generate_ogg(ofstream& of); + void generate_ogg(ostream& of); void generate_ogg_header(Bit_oggstream& os, bool * & mode_blockflag, int & mode_bits); void generate_ogg_header_with_triad(Bit_oggstream& os); };