Commit 4cea1061 authored by Stefan Westerfeld's avatar Stefan Westerfeld

Selectively enable -O3 for gcc for some functions (use auto vectorization).

Signed-off-by: Stefan Westerfeld's avatarStefan Westerfeld <stefan@space.twc.de>
parent 3285734a
...@@ -33,8 +33,8 @@ template<int BIT_DEPTH, RawFormat::Endian ENDIAN, RawFormat::Encoding ENCODING> ...@@ -33,8 +33,8 @@ template<int BIT_DEPTH, RawFormat::Endian ENDIAN, RawFormat::Encoding ENCODING>
class RawConverterImpl : public RawConverter class RawConverterImpl : public RawConverter
{ {
public: public:
void to_raw (const std::vector<float>& samples, std::vector<unsigned char>& bytes); void to_raw (const std::vector<float>& samples, std::vector<unsigned char>& bytes) AUDIOWMARK_EXTRA_OPT;
void from_raw (const std::vector<unsigned char>& bytes, std::vector<float>& samples); void from_raw (const std::vector<unsigned char>& bytes, std::vector<float>& samples) AUDIOWMARK_EXTRA_OPT;
}; };
template<int BIT_DEPTH, RawFormat::Endian ENDIAN> template<int BIT_DEPTH, RawFormat::Endian ENDIAN>
......
...@@ -155,7 +155,7 @@ SFInputStream::read_frames (vector<float>& samples, size_t count) ...@@ -155,7 +155,7 @@ SFInputStream::read_frames (vector<float>& samples, size_t count)
* used during read and write are identical * used during read and write are identical
*/ */
samples.resize (r_count * m_n_channels); samples.resize (r_count * m_n_channels);
const double norm = 1.0 / 0x80000000LL; const float norm = 1.0 / 0x80000000LL;
for (size_t i = 0; i < samples.size(); i++) for (size_t i = 0; i < samples.size(); i++)
samples[i] = isamples[i] * norm; samples[i] = isamples[i] * norm;
} }
......
...@@ -61,7 +61,7 @@ public: ...@@ -61,7 +61,7 @@ public:
Error open (const std::string& filename); Error open (const std::string& filename);
Error open (const std::vector<unsigned char> *data); Error open (const std::vector<unsigned char> *data);
Error read_frames (std::vector<float>& samples, size_t count) override; Error read_frames (std::vector<float>& samples, size_t count) override AUDIOWMARK_EXTRA_OPT;
void close(); void close();
int int
......
...@@ -39,8 +39,10 @@ bound (const T& min_value, const T& value, const T& max_value) ...@@ -39,8 +39,10 @@ bound (const T& min_value, const T& value, const T& max_value)
// detect compiler // detect compiler
#if __clang__ #if __clang__
#define AUDIOWMARK_COMP_CLANG #define AUDIOWMARK_COMP_CLANG
#define AUDIOWMARK_EXTRA_OPT
#elif __GNUC__ > 2 #elif __GNUC__ > 2
#define AUDIOWMARK_COMP_GCC #define AUDIOWMARK_COMP_GCC
#define AUDIOWMARK_EXTRA_OPT __attribute__((optimize("-O3"))) /* enable auto vectorization, some functions benefit a lot from this */
#else #else
#error "unsupported compiler" #error "unsupported compiler"
#endif #endif
......
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