Skip to content
Permalink
Browse files

Reading MP3 (using dr_libs)

  • Loading branch information
dlevin256 committed Nov 19, 2019
1 parent a38bef7 commit a7c7a5a715441b16fef0c1eddfaa4da88a654dd1
@@ -132,7 +132,7 @@ if (NOT IOS)
endif ()
endif ()
if (MSVC)
target_compile_options(kfr INTERFACE -bigobj)
target_compile_options(kfr INTERFACE -bigobj -EHsc)
else ()
target_link_libraries(kfr INTERFACE ${STD_LIB} ${PTHREAD_LIB} m)
endif ()
@@ -190,7 +190,6 @@ endif()

add_library(kfr_io ${KFR_IO_SRC})
target_link_libraries(kfr_io kfr)
target_compile_definitions(kfr_io PUBLIC KFR_ENABLE_FLAC=1)

install(TARGETS kfr kfr_io ARCHIVE DESTINATION lib LIBRARY DESTINATION lib)

@@ -10,7 +10,7 @@
path = os.path.dirname(os.path.realpath(__file__))

masks = ['*.hpp', '*.h', '*.cpp', '*.c', '*.cxx']
ignore = ['build/*', 'build-*', 'cmake-*', '.*']
ignore = ['build/*', 'build-*', 'cmake-*', '.*', 'include/kfr/io/dr']

filenames = []
for root, dirnames, files in os.walk(path, path):
@@ -113,8 +113,8 @@ KFR_INTRINSIC cvec<T, width> radix4_apply_twiddle(csize_t<width>, ctrue_t /*spli
const cvec<T, width>& w, const cvec<T, width>& tw)
{
vec<T, width> re1, im1, twre, twim;
split(w, re1, im1);
split(tw, twre, twim);
split<T, 2 * width>(w, re1, im1);
split<T, 2 * width>(tw, twre, twim);

const vec<T, width> b1re = re1 * twre;
const vec<T, width> b1im = im1 * twre;
@@ -136,10 +136,10 @@ KFR_INTRINSIC void radix4_body(size_t N, csize_t<width>, ctrue_t, cbool_t<splito

vec<T, width> re0, im0, re1, im1, re2, im2, re3, im3;

split(cread_split<width, aligned, read_split>(in + N4 * 0), re0, im0);
split(cread_split<width, aligned, read_split>(in + N4 * 1), re1, im1);
split(cread_split<width, aligned, read_split>(in + N4 * 2), re2, im2);
split(cread_split<width, aligned, read_split>(in + N4 * 3), re3, im3);
split<T, 2 * width>(cread_split<width, aligned, read_split>(in + N4 * 0), re0, im0);
split<T, 2 * width>(cread_split<width, aligned, read_split>(in + N4 * 1), re1, im1);
split<T, 2 * width>(cread_split<width, aligned, read_split>(in + N4 * 2), re2, im2);
split<T, 2 * width>(cread_split<width, aligned, read_split>(in + N4 * 3), re3, im3);

const vec<T, width> sum02re = re0 + re2;
const vec<T, width> sum02im = im0 + im2;
@@ -586,7 +586,7 @@ struct fft_specialization<T, 1> : dft_stage<T>
KFR_MEM_INTRINSIC void do_execute(complex<T>* out, const complex<T>* in, u8*)
{
cvec<T, 1> a0, a1;
split(cread<2, aligned>(in), a0, a1);
split<T, 4>(cread<2, aligned>(in), a0, a1);
cwrite<2, aligned>(out, concat(a0 + a1, a0 - a1));
}
};
@@ -602,7 +602,7 @@ struct fft_specialization<T, 2> : dft_stage<T>
KFR_MEM_INTRINSIC void do_execute(complex<T>* out, const complex<T>* in, u8*)
{
cvec<T, 1> a0, a1, a2, a3;
split(cread<4>(in), a0, a1, a2, a3);
split<T, 8>(cread<4>(in), a0, a1, a2, a3);
butterfly(cbool_t<inverse>(), a0, a1, a2, a3, a0, a1, a2, a3);
cwrite<4>(out, concat(concat(a0, a1), concat(a2, a3)));
}
@@ -222,7 +222,7 @@ inline void cwrite_split<8, false, true, f32>(complex<f32>* dest, const cvec<f32
concat(shuffle<0, 8 + 0, 1, 8 + 1>(low(x), high(x)), shuffle<2, 8 + 2, 3, 8 + 3>(low(x), high(x)));

cvec<f32, 2> a, b, c, d;
split(xx, a, b, c, d);
split<f32, 16>(xx, a, b, c, d);
cwrite<2>(dest, a);
cwrite<2>(dest + 4, b);
cwrite<2>(dest + 2, c);
@@ -235,7 +235,7 @@ inline void cwrite_split<8, true, true, f32>(complex<f32>* dest, const cvec<f32,
concat(shuffle<0, 8 + 0, 1, 8 + 1>(low(x), high(x)), shuffle<2, 8 + 2, 3, 8 + 3>(low(x), high(x)));

cvec<f32, 2> a, b, c, d;
split(xx, a, b, c, d);
split<f32, 16>(xx, a, b, c, d);
cwrite<2, true>(dest + 0, a);
cwrite<2, true>(dest + 4, b);
cwrite<2, true>(dest + 2, c);
@@ -415,10 +415,10 @@ KFR_INTRINSIC void transpose4(cvec<T, 16>& a, cvec<T, 16>& b, cvec<T, 16>& c, cv
cvec<T, 4> c0, c1, c2, c3;
cvec<T, 4> d0, d1, d2, d3;

split(a, a0, a1, a2, a3);
split(b, b0, b1, b2, b3);
split(c, c0, c1, c2, c3);
split(d, d0, d1, d2, d3);
split<T, 32>(a, a0, a1, a2, a3);
split<T, 32>(b, b0, b1, b2, b3);
split<T, 32>(c, c0, c1, c2, c3);
split<T, 32>(d, d0, d1, d2, d3);

a = concat(a0, b0, c0, d0);
b = concat(a1, b1, c1, d1);
@@ -434,10 +434,10 @@ KFR_INTRINSIC void transpose4(cvec<T, 16>& a, cvec<T, 16>& b, cvec<T, 16>& c, cv
cvec<T, 4> c0, c1, c2, c3;
cvec<T, 4> d0, d1, d2, d3;

split(a, a0, a1, a2, a3);
split(b, b0, b1, b2, b3);
split(c, c0, c1, c2, c3);
split(d, d0, d1, d2, d3);
split<T, 32>(a, a0, a1, a2, a3);
split<T, 32>(b, b0, b1, b2, b3);
split<T, 32>(c, c0, c1, c2, c3);
split<T, 32>(d, d0, d1, d2, d3);

aa = concat(a0, b0, c0, d0);
bb = concat(a1, b1, c1, d1);
@@ -662,7 +662,7 @@ KFR_INTRINSIC void butterfly8(cvec<T, 2>& a01, cvec<T, 2>& a23, cvec<T, 2>& a45,

cvec<T, 8> b01234567 = concat(b01, b23, b45, b67);
cvec<T, 8> b02461357 = concat(even<2>(b01234567), odd<2>(b01234567));
split(b02461357, b02, b46, b13, b57);
split<T, 16>(b02461357, b02, b46, b13, b57);

b13 = cmul(b13, fixed_twiddle<T, 2, 8, 0, 1, inverse>());
b57 = cmul(b57, fixed_twiddle<T, 2, 8, 2, 1, inverse>());
@@ -676,7 +676,7 @@ template <bool inverse = false, typename T>
KFR_INTRINSIC void butterfly8(cvec<T, 8>& v8)
{
cvec<T, 2> w0, w1, w2, w3;
split(v8, w0, w1, w2, w3);
split<T, 16>(v8, w0, w1, w2, w3);
butterfly8<inverse>(w0, w1, w2, w3);
v8 = concat(w0, w1, w2, w3);
}
@@ -685,7 +685,7 @@ template <bool inverse = false, typename T>
KFR_INTRINSIC void butterfly32(cvec<T, 32>& v32)
{
cvec<T, 4> w0, w1, w2, w3, w4, w5, w6, w7;
split(v32, w0, w1, w2, w3, w4, w5, w6, w7);
split<T, 64>(v32, w0, w1, w2, w3, w4, w5, w6, w7);
butterfly8<4, inverse>(w0, w1, w2, w3, w4, w5, w6, w7);

w1 = cmul(w1, fixed_twiddle<T, 4, 32, 0, 1, inverse>());
@@ -710,7 +710,7 @@ KFR_INTRINSIC void butterfly4(cvec<T, N * 4>& a0123)
cvec<T, N> a1;
cvec<T, N> a2;
cvec<T, N> a3;
split(a0123, a0, a1, a2, a3);
split<T, N * 4 * 2>(a0123, a0, a1, a2, a3);
butterfly4<N, inverse>(cfalse, a0, a1, a2, a3, a0, a1, a2, a3);
a0123 = concat(a0, a1, a2, a3);
}
@@ -731,8 +731,8 @@ KFR_INTRINSIC void apply_twiddle(const cvec<T, N>& a1, const cvec<T, N>& tw1, cv
if (split_format)
{
vec<T, N> re1, im1, tw1re, tw1im;
split(a1, re1, im1);
split(tw1, tw1re, tw1im);
split<T, 2 * N>(a1, re1, im1);
split<T, 2 * N>(tw1, tw1re, tw1im);
vec<T, N> b1re = re1 * tw1re;
vec<T, N> b1im = im1 * tw1re;
if (inverse)
@@ -821,7 +821,7 @@ KFR_INTRINSIC void apply_twiddles4(cvec<T, N * 4>& __restrict a0123)
cvec<T, N> a1;
cvec<T, N> a2;
cvec<T, N> a3;
split(a0123, a0, a1, a2, a3);
split<T, 2 * N * 4>(a0123, a0, a1, a2, a3);

cvec<T, N> tw1 = fixed_twiddle<T, N, 64, n2 * nnstep * 1, nnstep * 1, inverse>(),
tw2 = fixed_twiddle<T, N, 64, n2 * nnstep * 2, nnstep * 2, inverse>(),
@@ -1472,15 +1472,15 @@ KFR_INTRINSIC void cread_transposed(cbool_t<true>, const complex<f32>* ptr, cvec
cvec<f32, 4> w3;
cvec<f32, 16> v16 = concat(cread<4>(ptr), cread<4>(ptr + 3), cread<4>(ptr + 6), cread<4>(ptr + 9));
v16 = digitreverse4<2>(v16);
split(v16, w0, w1, w2, w3);
split<f32, 32>(v16, w0, w1, w2, w3);
}

KFR_INTRINSIC void cread_transposed(cbool_t<true>, const complex<f32>* ptr, cvec<f32, 4>& w0,
cvec<f32, 4>& w1, cvec<f32, 4>& w2, cvec<f32, 4>& w3, cvec<f32, 4>& w4)
{
cvec<f32, 16> v16 = concat(cread<4>(ptr), cread<4>(ptr + 5), cread<4>(ptr + 10), cread<4>(ptr + 15));
v16 = digitreverse4<2>(v16);
split(v16, w0, w1, w2, w3);
split<f32, 32>(v16, w0, w1, w2, w3);
w4 = cgather<4, 5>(ptr + 4);
}

0 comments on commit a7c7a5a

Please sign in to comment.
You can’t perform that action at this time.