From e38a34084a820f4c2ca4b78b1e727bdcd9094c38 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Thu, 9 Apr 2015 23:57:13 +0200 Subject: [PATCH] [DEBUG] correct test --- audio/double_t.cpp | 18 ++++++------ audio/float_t.cpp | 18 ++++++------ audio/int24_32_t.cpp | 14 +++++----- audio/int32_64_t.cpp | 10 +++---- audio/int64_64_t.cpp | 12 ++++---- audio/int8_16_t.cpp | 14 +++++----- audio/int8_8_t.cpp | 16 +++++------ audio/types.h | 11 +------- test/test_double.cpp | 62 +++++++++++++++++++++++++++++++++++++----- test/test_float.cpp | 6 ++-- test/test_int16_16.cpp | 1 - test/test_int16_32.cpp | 1 - test/test_int24_24.cpp | 1 - test/test_int24_32.cpp | 5 ++-- test/test_int32_32.cpp | 1 - test/test_int32_64.cpp | 3 +- test/test_int64_64.cpp | 22 --------------- test/test_int8_16.cpp | 5 ++-- test/test_int8_8.cpp | 1 - 19 files changed, 115 insertions(+), 106 deletions(-) diff --git a/audio/double_t.cpp b/audio/double_t.cpp index d5441bf..c5a82ad 100644 --- a/audio/double_t.cpp +++ b/audio/double_t.cpp @@ -9,39 +9,39 @@ audio::double_t::double_t(const audio::int8_8_t& _val) { - m_data = double(_val.get()) / double(INT8_MAX); + m_data = double(_val.get()) / (double(INT8_MAX) + 1.0); } audio::double_t::double_t(const audio::int8_16_t& _val) { - m_data = double(_val.get()) / double(INT8_MAX); + m_data = double(_val.get()) / (double(INT8_MAX) * 2.0 + 1.0); } audio::double_t::double_t(const audio::int16_16_t& _val) { - m_data = double(_val.get()) / double(INT16_MAX); + m_data = double(_val.get()) / (double(INT16_MAX) + 1.0); } audio::double_t::double_t(const audio::int16_32_t& _val) { - m_data = double(_val.get()) / double(INT16_MAX); + m_data = double(_val.get()) / (double(INT16_MAX) * 2.0 + 1.0); } audio::double_t::double_t(const audio::int24_24_t& _val) { - m_data = double(_val.get()) / double(INT24_MAX); + m_data = double(_val.get()) / (double(INT24_MAX) + 1.0); } audio::double_t::double_t(const audio::int24_32_t& _val) { - m_data = double(_val.get()) / double(INT24_MAX); + m_data = double(_val.get()) / (double(INT24_MAX) * 2.0 + 1.0); } audio::double_t::double_t(const audio::int32_32_t& _val) { - m_data = double(_val.get()) / double(INT32_MAX); + m_data = double(_val.get()) / (double(INT32_MAX) + 1.0); } audio::double_t::double_t(const audio::int32_64_t& _val) { - m_data = double(_val.get()) / double(INT32_MAX); + m_data = double(_val.get()) / (double(INT32_MAX) * 2.0 + 1.0); } audio::double_t::double_t(const audio::int64_64_t& _val) { - m_data = double(_val.get()) / double(INT64_MAX); + m_data = double(_val.get()) / (double(INT64_MAX) + 1.0); } audio::double_t::double_t(const audio::float_t& _val) { diff --git a/audio/float_t.cpp b/audio/float_t.cpp index ce2f37a..b29c5a1 100644 --- a/audio/float_t.cpp +++ b/audio/float_t.cpp @@ -9,39 +9,39 @@ audio::float_t::float_t(const audio::int8_8_t& _val) { - m_data = float(_val.get()) / float(INT8_MAX); + m_data = float(_val.get()) / (float(INT8_MAX) + 1.0f); } audio::float_t::float_t(const audio::int8_16_t& _val) { - m_data = float(_val.get()) / float(INT8_MAX); + m_data = float(_val.get()) / (float(INT8_MAX) * 2.0f + 1.0f); } audio::float_t::float_t(const audio::int16_16_t& _val) { - m_data = float(_val.get()) / float(INT16_MAX); + m_data = float(_val.get()) / (float(INT16_MAX) + 1.0f); } audio::float_t::float_t(const audio::int16_32_t& _val) { - m_data = float(_val.get()) / float(INT16_MAX); + m_data = float(_val.get()) / (float(INT16_MAX) * 2.0f + 1.0f); } audio::float_t::float_t(const audio::int24_24_t& _val) { - m_data = float(_val.get()) / float(INT24_MAX); + m_data = float(_val.get()) / (float(INT24_MAX) + 1.0f); } audio::float_t::float_t(const audio::int24_32_t& _val) { - m_data = float(_val.get()) / float(INT24_MAX); + m_data = float(_val.get()) / (float(INT24_MAX) * 2.0f + 1.0f); } audio::float_t::float_t(const audio::int32_32_t& _val) { - m_data = float(_val.get()) / float(INT32_MAX); + m_data = float(_val.get()) / (float(INT32_MAX) + 1.0f); } audio::float_t::float_t(const audio::int32_64_t& _val) { - m_data = float(_val.get()) / float(INT32_MAX); + m_data = float(_val.get()) / (float(INT32_MAX) * 2.0f + 1.0f); } audio::float_t::float_t(const audio::int64_64_t& _val) { - m_data = float(_val.get()) / float(INT64_MAX); + m_data = float(_val.get()) / (float(INT64_MAX) + 1.0f); } audio::float_t::float_t(const audio::float_t& _val) { diff --git a/audio/int24_32_t.cpp b/audio/int24_32_t.cpp index 50b825c..9f53c5c 100644 --- a/audio/int24_32_t.cpp +++ b/audio/int24_32_t.cpp @@ -30,7 +30,7 @@ audio::int24_32_t::int24_32_t(const audio::int8_8_t& _val) { - m_data = int32_t(_val.get()) << 16; + m_data = int32_t(_val.get()) << 17; } audio::int24_32_t::int24_32_t(const audio::int8_16_t& _val) { @@ -38,7 +38,7 @@ audio::int24_32_t::int24_32_t(const audio::int8_16_t& _val) { } audio::int24_32_t::int24_32_t(const audio::int16_16_t& _val) { - m_data = _val.get() << 8; + m_data = _val.get() << 9; } audio::int24_32_t::int24_32_t(const audio::int16_32_t& _val) { @@ -50,7 +50,7 @@ audio::int24_32_t::int24_32_t(const audio::int16_32_t& _val) { } audio::int24_32_t::int24_32_t(const audio::int24_24_t& _val) { - m_data = _val.get(); + m_data = _val.get() << 1; } audio::int24_32_t::int24_32_t(const audio::int24_32_t& _val) { @@ -58,7 +58,7 @@ audio::int24_32_t::int24_32_t(const audio::int24_32_t& _val) { } audio::int24_32_t::int24_32_t(const audio::int32_32_t& _val) { - m_data = int32_t(_val.get() >> 8); + m_data = int32_t(_val.get() >> 7); } audio::int24_32_t::int24_32_t(const audio::int32_64_t& _val) { @@ -70,14 +70,14 @@ audio::int24_32_t::int24_32_t(const audio::int32_64_t& _val) { } audio::int24_32_t::int24_32_t(const audio::int64_64_t& _val) { - m_data = int32_t(_val.get() >> 40); + m_data = int32_t(_val.get() >> 39); } audio::int24_32_t::int24_32_t(const audio::float_t& _val) { m_data = int32_t(std::avg(float(INT8_MIN), _val.get(), float(INT8_MAX) - ) * float(INT24_MAX) * 2.0f + ) * (float(INT24_MAX) * 2.0f + 1.0f) ); } @@ -85,7 +85,7 @@ audio::int24_32_t::int24_32_t(const audio::double_t& _val) { m_data = int32_t(std::avg(-1.0, _val.get(), 1.0 - ) * double(INT24_MAX) * 2.0 + ) * (double(INT24_MAX) * 2.0 + 1.0) ); } diff --git a/audio/int32_64_t.cpp b/audio/int32_64_t.cpp index 32e14ce..611d080 100644 --- a/audio/int32_64_t.cpp +++ b/audio/int32_64_t.cpp @@ -30,7 +30,7 @@ audio::int32_64_t::int32_64_t(const audio::int8_8_t& _val) { - m_data = int64_t(_val.get()) << 24; + m_data = int64_t(_val.get()) << 25; } audio::int32_64_t::int32_64_t(const audio::int8_16_t& _val) { @@ -38,7 +38,7 @@ audio::int32_64_t::int32_64_t(const audio::int8_16_t& _val) { } audio::int32_64_t::int32_64_t(const audio::int16_16_t& _val) { - m_data = int64_t(_val.get()) << 16; + m_data = int64_t(_val.get()) << 17; } audio::int32_64_t::int32_64_t(const audio::int16_32_t& _val) { @@ -46,7 +46,7 @@ audio::int32_64_t::int32_64_t(const audio::int16_32_t& _val) { } audio::int32_64_t::int32_64_t(const audio::int24_24_t& _val) { - m_data = int64_t(_val.get()) << 8; + m_data = int64_t(_val.get()) << 9; } audio::int32_64_t::int32_64_t(const audio::int24_32_t& _val) { @@ -54,7 +54,7 @@ audio::int32_64_t::int32_64_t(const audio::int24_32_t& _val) { } audio::int32_64_t::int32_64_t(const audio::int32_32_t& _val) { - m_data = int64_t(_val.get()); + m_data = int64_t(_val.get()) << 1; } audio::int32_64_t::int32_64_t(const audio::int32_64_t& _val) { @@ -62,7 +62,7 @@ audio::int32_64_t::int32_64_t(const audio::int32_64_t& _val) { } audio::int32_64_t::int32_64_t(const audio::int64_64_t& _val) { - m_data = int64_t(_val.get() >> 32); + m_data = int64_t(_val.get() >> 31); } audio::int32_64_t::int32_64_t(const audio::float_t& _val) { diff --git a/audio/int64_64_t.cpp b/audio/int64_64_t.cpp index 3dfc577..fbbacac 100644 --- a/audio/int64_64_t.cpp +++ b/audio/int64_64_t.cpp @@ -34,9 +34,9 @@ audio::int64_64_t::int64_64_t(const audio::int8_8_t& _val) { } audio::int64_64_t::int64_64_t(const audio::int8_16_t& _val) { - m_data = int64_t(std::avg(int16_t(INT8_MIN), - _val.get(), - int16_t(INT8_MAX) + m_data = int64_t(std::avg(int32_t(INT8_MIN), + int32_t(_val.get())>>1, + int32_t(INT8_MAX) )) << 56; } @@ -46,7 +46,7 @@ audio::int64_64_t::int64_64_t(const audio::int16_16_t& _val) { audio::int64_64_t::int64_64_t(const audio::int16_32_t& _val) { m_data = int64_t(std::avg(int32_t(INT16_MIN), - _val.get(), + _val.get() >> 1, int32_t(INT16_MAX) )) << 48; } @@ -57,7 +57,7 @@ audio::int64_64_t::int64_64_t(const audio::int24_24_t& _val) { audio::int64_64_t::int64_64_t(const audio::int24_32_t& _val) { m_data = int64_t(std::avg(int32_t(INT24_MIN), - _val.get(), + _val.get()>>1, int32_t(INT24_MAX) )) << 40; } @@ -68,7 +68,7 @@ audio::int64_64_t::int64_64_t(const audio::int32_32_t& _val) { audio::int64_64_t::int64_64_t(const audio::int32_64_t& _val) { m_data = int64_t(std::avg(int64_t(INT32_MIN), - _val.get(), + _val.get()>>1, int64_t(INT32_MAX) )) << 32; } diff --git a/audio/int8_16_t.cpp b/audio/int8_16_t.cpp index d0b9a66..d5d30fd 100644 --- a/audio/int8_16_t.cpp +++ b/audio/int8_16_t.cpp @@ -30,7 +30,7 @@ audio::int8_16_t::int8_16_t(const audio::int8_8_t& _val) { - m_data = int16_t(_val.get()); + m_data = int16_t(_val.get())<<1; } audio::int8_16_t::int8_16_t(const audio::int8_16_t& _val) { @@ -38,7 +38,7 @@ audio::int8_16_t::int8_16_t(const audio::int8_16_t& _val) { } audio::int8_16_t::int8_16_t(const audio::int16_16_t& _val) { - m_data = int16_t(_val.get() >> 8); + m_data = int16_t(_val.get() >> 7); } audio::int8_16_t::int8_16_t(const audio::int16_32_t& _val) { @@ -50,7 +50,7 @@ audio::int8_16_t::int8_16_t(const audio::int16_32_t& _val) { } audio::int8_16_t::int8_16_t(const audio::int24_24_t& _val) { - m_data = int16_t(_val.get() >> 16); + m_data = int16_t(_val.get() >> 15); } audio::int8_16_t::int8_16_t(const audio::int24_32_t& _val) { @@ -58,7 +58,7 @@ audio::int8_16_t::int8_16_t(const audio::int24_32_t& _val) { } audio::int8_16_t::int8_16_t(const audio::int32_32_t& _val) { - m_data = int16_t(_val.get() >> 24); + m_data = int16_t(_val.get() >> 23); } audio::int8_16_t::int8_16_t(const audio::int32_64_t& _val) { @@ -70,14 +70,14 @@ audio::int8_16_t::int8_16_t(const audio::int32_64_t& _val) { } audio::int8_16_t::int8_16_t(const audio::int64_64_t& _val) { - m_data = int16_t(_val.get() >> 56); + m_data = int16_t(_val.get() >> 55); } audio::int8_16_t::int8_16_t(const audio::float_t& _val) { m_data = int16_t(std::avg(float(INT8_MIN), _val.get(), float(INT8_MAX) - ) * float(INT8_MAX) * 2.0f + ) * (float(INT8_MAX) * 2.0f + 1.0f) ); } @@ -85,7 +85,7 @@ audio::int8_16_t::int8_16_t(const audio::double_t& _val) { m_data = int16_t(std::avg(double(INT8_MIN), _val.get(), double(INT8_MAX) - ) * double(INT8_MAX) * 2.0 + ) * (double(INT8_MAX) * 2.0 + 1.0) ); } diff --git a/audio/int8_8_t.cpp b/audio/int8_8_t.cpp index 1902055..5850de2 100644 --- a/audio/int8_8_t.cpp +++ b/audio/int8_8_t.cpp @@ -34,9 +34,9 @@ audio::int8_8_t::int8_8_t(const audio::int8_8_t& _val) { } audio::int8_8_t::int8_8_t(const audio::int8_16_t& _val) { - m_data = int8_t(std::avg(int16_t(INT8_MIN), - _val.get(), - int16_t(INT8_MAX) + m_data = int8_t(std::avg(int32_t(INT8_MIN), + int32_t(_val.get())>>1, + int32_t(INT8_MAX) )); } @@ -46,7 +46,7 @@ audio::int8_8_t::int8_8_t(const audio::int16_16_t& _val) { audio::int8_8_t::int8_8_t(const audio::int16_32_t& _val) { m_data = int8_t(std::avg(int32_t(INT16_MIN), - _val.get(), + _val.get()>>1, int32_t(INT16_MAX) ) >> 8 ); @@ -58,7 +58,7 @@ audio::int8_8_t::int8_8_t(const audio::int24_24_t& _val) { audio::int8_8_t::int8_8_t(const audio::int24_32_t& _val) { m_data = int8_t(std::avg(int32_t(INT24_MIN), - _val.get(), + _val.get() >> 1, int32_t(INT24_MAX) ) >> 16); } @@ -69,7 +69,7 @@ audio::int8_8_t::int8_8_t(const audio::int32_32_t& _val) { audio::int8_8_t::int8_8_t(const audio::int32_64_t& _val) { m_data = int8_t(std::avg(int64_t(INT32_MIN), - _val.get(), + _val.get() >> 1, int64_t(INT32_MAX) ) >> 24 ); @@ -83,7 +83,7 @@ audio::int8_8_t::int8_8_t(const audio::float_t& _val) { m_data = int16_t(std::avg(-1.0f, _val.get(), 1.0f - ) * float(INT8_MAX) + ) * (float(INT8_MAX) + 1.0f) ); } @@ -91,7 +91,7 @@ audio::int8_8_t::int8_8_t(const audio::double_t& _val) { m_data = int16_t(std::avg(-1.0, _val.get(), 1.0 - ) * double(INT8_MAX) + ) * (double(INT8_MAX) + 1.0) ); } diff --git a/audio/types.h b/audio/types.h index 60e7697..fd4f557 100644 --- a/audio/types.h +++ b/audio/types.h @@ -20,16 +20,7 @@ namespace audio { class float_t; class double_t; } -/* -namespace audio { - const minInt64[65]; - const maxInt64[65]; - const minIntFloat[65]; - const maxIntFloat[65]; - const minIntDouble[65]; - const maxIntDouble[65]; -} -*/ + #define INT24_MIN 0xFFFFFFFFFF800000LL #define INT24_MAX 0x00000000007FFFFFLL diff --git a/test/test_double.cpp b/test/test_double.cpp index 1830e3e..e91565c 100644 --- a/test/test_double.cpp +++ b/test/test_double.cpp @@ -9,34 +9,34 @@ #include