Skip to content

Commit 4011388

Browse files
committed
Use CV.XorS instead of for loop in twos-comp to offset binary
- Tested in hardware appears to work well
1 parent b94f5bc commit 4011388

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

OpenEphys.Onix1/BreakoutAnalogOutput.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,9 @@ public override unsafe IObservable<Mat> Process(IObservable<Mat> source)
8989
var dataSize = outputBuffer.Step * outputBuffer.Rows;
9090

9191
// twos-complement to offset binary
92-
var dataPtr = (short *)outputBuffer.Data.ToPointer();
9392
const short Mask = -32768;
94-
for (int i = 0; i < dataSize / sizeof(short); i++)
95-
*(dataPtr + i) ^= Mask;
96-
97-
device.Write(outputBuffer.Data, dataSize);
93+
CV.XorS(outputBuffer, new Scalar(Mask, 0, 0), outputBuffer);
94+
device.Write(outputBuffer.Data, dataSize);
9895
});
9996
});
10097
}

0 commit comments

Comments
 (0)