Commit 813973c1 authored by André Anjos's avatar André Anjos 💬
Browse files

Merge branch 'gcc421' into 'master'

Improve compatibility with gcc-4.2.1

See merge request !3
parents fb7a92c1 4e89097a
Pipeline #7062 passed with stages
in 17 minutes and 45 seconds
......@@ -7,6 +7,7 @@
#include "utils.h"
#include <map>
#include <boost/assign.hpp>
const double bob::io::audio::SOX_CONVERSION_COEF=2147483648.; /* 2^31 */
......@@ -15,36 +16,37 @@ void bob::io::audio::close_sox_file(sox_format_t* f) {
}
//requires c++11 for compiling
static const std::map<sox_encoding_t, std::string> ENC2STR = {
{SOX_ENCODING_SIGN2, "SIGN2"},
{SOX_ENCODING_UNSIGNED, "UNSIGNED"},
{SOX_ENCODING_FLOAT, "FLOAT"},
{SOX_ENCODING_FLOAT_TEXT, "FLOAT_TEXT"},
{SOX_ENCODING_FLAC, "FLAC"},
{SOX_ENCODING_HCOM, "HCOM"},
{SOX_ENCODING_WAVPACK, "WAVPACK"},
{SOX_ENCODING_WAVPACKF, "WAVPACKF"},
{SOX_ENCODING_ULAW, "ULAW"},
{SOX_ENCODING_ALAW, "ALAW"},
{SOX_ENCODING_G721, "G721"},
{SOX_ENCODING_G723, "G723"},
{SOX_ENCODING_CL_ADPCM, "CL_ADPCM"},
{SOX_ENCODING_CL_ADPCM16, "CL_ADPCM16"},
{SOX_ENCODING_MS_ADPCM, "MS_ADPCM"},
{SOX_ENCODING_IMA_ADPCM, "IMA_ADPCM"},
{SOX_ENCODING_OKI_ADPCM, "OKI_ADPCM"},
{SOX_ENCODING_DPCM, "DPCM"},
{SOX_ENCODING_DWVW, "DWVW"},
{SOX_ENCODING_DWVWN, "DWVWN"},
{SOX_ENCODING_GSM, "GSM"},
{SOX_ENCODING_MP3, "MP3"},
{SOX_ENCODING_VORBIS, "VORBIS"},
{SOX_ENCODING_AMR_WB, "AMR_WB"},
{SOX_ENCODING_AMR_NB, "AMR_NB"},
{SOX_ENCODING_CVSD, "CVSD"},
{SOX_ENCODING_LPC10, "LPC10"},
{SOX_ENCODING_UNKNOWN, "UNKNOWN"}
};
static const std::map<sox_encoding_t, std::string> ENC2STR = \
boost::assign::map_list_of
(SOX_ENCODING_SIGN2, "SIGN2")
(SOX_ENCODING_UNSIGNED, "UNSIGNED")
(SOX_ENCODING_FLOAT, "FLOAT")
(SOX_ENCODING_FLOAT_TEXT, "FLOAT_TEXT")
(SOX_ENCODING_FLAC, "FLAC")
(SOX_ENCODING_HCOM, "HCOM")
(SOX_ENCODING_WAVPACK, "WAVPACK")
(SOX_ENCODING_WAVPACKF, "WAVPACKF")
(SOX_ENCODING_ULAW, "ULAW")
(SOX_ENCODING_ALAW, "ALAW")
(SOX_ENCODING_G721, "G721")
(SOX_ENCODING_G723, "G723")
(SOX_ENCODING_CL_ADPCM, "CL_ADPCM")
(SOX_ENCODING_CL_ADPCM16, "CL_ADPCM16")
(SOX_ENCODING_MS_ADPCM, "MS_ADPCM")
(SOX_ENCODING_IMA_ADPCM, "IMA_ADPCM")
(SOX_ENCODING_OKI_ADPCM, "OKI_ADPCM")
(SOX_ENCODING_DPCM, "DPCM")
(SOX_ENCODING_DWVW, "DWVW")
(SOX_ENCODING_DWVWN, "DWVWN")
(SOX_ENCODING_GSM, "GSM")
(SOX_ENCODING_MP3, "MP3")
(SOX_ENCODING_VORBIS, "VORBIS")
(SOX_ENCODING_AMR_WB, "AMR_WB")
(SOX_ENCODING_AMR_NB, "AMR_NB")
(SOX_ENCODING_CVSD, "CVSD")
(SOX_ENCODING_LPC10, "LPC10")
(SOX_ENCODING_UNKNOWN, "UNKNOWN")
;
const char* bob::io::audio::encoding2string(sox_encoding_t e) {
auto it = ENC2STR.find(e);
......@@ -53,36 +55,37 @@ const char* bob::io::audio::encoding2string(sox_encoding_t e) {
}
//requires c++11 for compiling
static const std::map<std::string, sox_encoding_t> STR2ENC = {
{"SIGN2", SOX_ENCODING_SIGN2},
{"UNSIGNED", SOX_ENCODING_UNSIGNED},
{"FLOAT", SOX_ENCODING_FLOAT},
{"FLOAT_TEXT", SOX_ENCODING_FLOAT_TEXT},
{"FLAC", SOX_ENCODING_FLAC},
{"HCOM", SOX_ENCODING_HCOM},
{"WAVPACK", SOX_ENCODING_WAVPACK},
{"WAVPACKF", SOX_ENCODING_WAVPACKF},
{"ULAW", SOX_ENCODING_ULAW},
{"ALAW", SOX_ENCODING_ALAW},
{"G721", SOX_ENCODING_G721},
{"G723", SOX_ENCODING_G723},
{"CL_ADPCM", SOX_ENCODING_CL_ADPCM},
{"CL_ADPCM16", SOX_ENCODING_CL_ADPCM16},
{"MS_ADPCM", SOX_ENCODING_MS_ADPCM},
{"IMA_ADPCM", SOX_ENCODING_IMA_ADPCM},
{"OKI_ADPCM", SOX_ENCODING_OKI_ADPCM},
{"DPCM", SOX_ENCODING_DPCM},
{"DWVW", SOX_ENCODING_DWVW},
{"DWVWN", SOX_ENCODING_DWVWN},
{"GSM", SOX_ENCODING_GSM},
{"MP3", SOX_ENCODING_MP3},
{"VORBIS", SOX_ENCODING_VORBIS},
{"AMR_WB", SOX_ENCODING_AMR_WB},
{"AMR_NB", SOX_ENCODING_AMR_NB},
{"CVSD", SOX_ENCODING_CVSD},
{"LPC10", SOX_ENCODING_LPC10},
{"UNKNOWN", SOX_ENCODING_UNKNOWN}
};
static const std::map<std::string, sox_encoding_t> STR2ENC = \
boost::assign::map_list_of
("SIGN2", SOX_ENCODING_SIGN2)
("UNSIGNED", SOX_ENCODING_UNSIGNED)
("FLOAT", SOX_ENCODING_FLOAT)
("FLOAT_TEXT", SOX_ENCODING_FLOAT_TEXT)
("FLAC", SOX_ENCODING_FLAC)
("HCOM", SOX_ENCODING_HCOM)
("WAVPACK", SOX_ENCODING_WAVPACK)
("WAVPACKF", SOX_ENCODING_WAVPACKF)
("ULAW", SOX_ENCODING_ULAW)
("ALAW", SOX_ENCODING_ALAW)
("G721", SOX_ENCODING_G721)
("G723", SOX_ENCODING_G723)
("CL_ADPCM", SOX_ENCODING_CL_ADPCM)
("CL_ADPCM16", SOX_ENCODING_CL_ADPCM16)
("MS_ADPCM", SOX_ENCODING_MS_ADPCM)
("IMA_ADPCM", SOX_ENCODING_IMA_ADPCM)
("OKI_ADPCM", SOX_ENCODING_OKI_ADPCM)
("DPCM", SOX_ENCODING_DPCM)
("DWVW", SOX_ENCODING_DWVW)
("DWVWN", SOX_ENCODING_DWVWN)
("GSM", SOX_ENCODING_GSM)
("MP3", SOX_ENCODING_MP3)
("VORBIS", SOX_ENCODING_VORBIS)
("AMR_WB", SOX_ENCODING_AMR_WB)
("AMR_NB", SOX_ENCODING_AMR_NB)
("CVSD", SOX_ENCODING_CVSD)
("LPC10", SOX_ENCODING_LPC10)
("UNKNOWN", SOX_ENCODING_UNKNOWN)
;
sox_encoding_t bob::io::audio::string2encoding(const char* s) {
auto it = STR2ENC.find(s);
......
......@@ -11,53 +11,56 @@
#include <stdexcept>
#include <boost/format.hpp>
#include <boost/assign.hpp>
/* Until we can get a better handle (requires C++-11 initializers) */
const std::map<std::string, std::string> bob::io::audio::SUPPORTED_FORMATS = {
{".aifc", "AIFF-C (not compressed), defined in DAVIC 1.4 Part 9 Annex B"},
{".aiff", "AIFF files used on Apple IIc/IIgs and SGI"},
{".al", "Raw audio"},
{".au", "PCM file format used widely on Sun systems"},
{".avr", "Audio Visual Research format; used on the Mac"},
{".cdda", "Red Book Compact Disc Digital Audio"},
{".cvsd", "Headerless MIL Std 188 113 Continuously Variable Slope Delta modulation"},
{".cvu", "Headerless Continuously Variable Slope Delta modulation (unfiltered)"},
{".dat", "Textual representation of the sampled audio"},
{".dvms", "MIL Std 188 113 Continuously Variable Slope Delta modulation with header"},
{".f4", "Raw audio"},
{".f8", "Raw audio"},
{".gsrt", "Grandstream ring tone"},
{".hcom", "Mac FSSD files with Huffman compression"},
{".htk", "PCM format used for Hidden Markov Model speech processing"}, {".ima", "Raw IMA ADPCM"},
{".la", "Raw audio"},
{".lu", "Raw audio"},
{".maud", "Used with the ‘Toccata’ sound-card on the Amiga"},
{".prc", "Psion Record; used in EPOC devices (Series 5, Revo and similar)"},
{".raw", "Raw PCM, mu-law, or A-law"},
{".s1", "Raw audio"},
{".s2", "Raw audio"},
{".s3", "Raw audio"},
{".s4", "Raw audio"},
{".sf", "Institut de Recherche et Coordination Acoustique/Musique"},
{".sln", "Asterisk PBX headerless format"},
{".smp", "Turtle Beach SampleVision"},
{".sndr", "8-bit linear audio as used by Aaron Wallace's `Sounder' of 1991"},
{".sndt", "8-bit linear audio as used by Martin Hepperle's `SoundTool' of 1991/2"},
{".sox", "SoX native intermediate format"},
{".sph", "SPeech HEader Resources; defined by NIST"},
{".8svx", "Amiga audio format (a subformat of the Interchange File Format)"},
{".txw", "Yamaha TX-16W sampler"},
{".u1", "Raw audio"},
{".u2", "Raw audio"},
{".u3", "Raw audio"},
{".u4", "Raw audio"},
{".ul", "Raw audio"},
{".voc", "Creative Technology Sound Blaster format"},
{".vox", "Raw OKI/Dialogic ADPCM"},
{".wav", "Microsoft audio format"},
{".wve", "Psion 3 audio format"},
{".xa", "16-bit ADPCM audio files used by Maxis games"}
};
const std::map<std::string, std::string> bob::io::audio::SUPPORTED_FORMATS = \
boost::assign::map_list_of
(".aifc", "AIFF-C (not compressed), defined in DAVIC 1.4 Part 9 Annex B")
(".aiff", "AIFF files used on Apple IIc/IIgs and SGI")
(".al", "Raw audio")
(".au", "PCM file format used widely on Sun systems")
(".avr", "Audio Visual Research format; used on the Mac")
(".cdda", "Red Book Compact Disc Digital Audio")
(".cvsd", "Headerless MIL Std 188 113 Continuously Variable Slope Delta modulation")
(".cvu", "Headerless Continuously Variable Slope Delta modulation (unfiltered)")
(".dat", "Textual representation of the sampled audio")
(".dvms", "MIL Std 188 113 Continuously Variable Slope Delta modulation with header")
(".f4", "Raw audio")
(".f8", "Raw audio")
(".gsrt", "Grandstream ring tone")
(".hcom", "Mac FSSD files with Huffman compression")
(".htk", "PCM format used for Hidden Markov Model speech processing")
(".ima", "Raw IMA ADPCM")
(".la", "Raw audio")
(".lu", "Raw audio")
(".maud", "Used with the ‘Toccata’ sound-card on the Amiga")
(".prc", "Psion Record; used in EPOC devices (Series 5, Revo and similar)")
(".raw", "Raw PCM, mu-law, or A-law")
(".s1", "Raw audio")
(".s2", "Raw audio")
(".s3", "Raw audio")
(".s4", "Raw audio")
(".sf", "Institut de Recherche et Coordination Acoustique/Musique")
(".sln", "Asterisk PBX headerless format")
(".smp", "Turtle Beach SampleVision")
(".sndr", "8-bit linear audio as used by Aaron Wallace's `Sounder' of 1991")
(".sndt", "8-bit linear audio as used by Martin Hepperle's `SoundTool' of 1991/2")
(".sox", "SoX native intermediate format")
(".sph", "SPeech HEader Resources; defined by NIST")
(".8svx", "Amiga audio format (a subformat of the Interchange File Format)")
(".txw", "Yamaha TX-16W sampler")
(".u1", "Raw audio")
(".u2", "Raw audio")
(".u3", "Raw audio")
(".u4", "Raw audio")
(".ul", "Raw audio")
(".voc", "Creative Technology Sound Blaster format")
(".vox", "Raw OKI/Dialogic ADPCM")
(".wav", "Microsoft audio format")
(".wve", "Psion 3 audio format")
(".xa", "16-bit ADPCM audio files used by Maxis games")
;
bob::io::audio::Writer::Writer(const char* filename, double rate,
sox_encoding_t encoding, size_t bits_per_sample):
......
......@@ -37,7 +37,7 @@ BOB_TRY
char* filename = 0;
double rate = 8000.;
char* encoding = "UNKNOWN";
const char* encoding = "UNKNOWN";
Py_ssize_t bits_per_sample = 16;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|dsn", kwlist,
......
Markdown is supported
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