-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocessor-perf.cpp
More file actions
33 lines (29 loc) · 1.1 KB
/
processor-perf.cpp
File metadata and controls
33 lines (29 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <emscripten.h>
#include <emscripten/bind.h>
using namespace emscripten;
const unsigned kRenderQuantumFrames = 128;
const unsigned kBytesPerChannel = kRenderQuantumFrames * sizeof(float);
class ProcessorPerf
{
public:
ProcessorPerf() {}
void processPerf(uintptr_t input_ptr, uintptr_t output_ptr, int channel_count)
{
float *input_buffer = reinterpret_cast<float *>(input_ptr);
float *output_buffer = reinterpret_cast<float *>(output_ptr);
// Bypasses the data. By design, the channel count will always be the same
// for |input_buffer| and |output_buffer|.
for (unsigned channel = 0; channel < channel_count; ++channel)
{
output_buffer = output_buffer + channel * kRenderQuantumFrames;
input_buffer = input_buffer + channel * kRenderQuantumFrames;
memcpy(output_buffer, input_buffer, kBytesPerChannel);
}
}
};
EMSCRIPTEN_BINDINGS(CLASS_ProcessorPerf)
{
class_<ProcessorPerf>("ProcessorPerf")
.constructor()
.function("processPerf", &ProcessorPerf::processPerf, allow_raw_pointers());
}