Optimize: Return the matrix reference directly instead of copying it.

This removes another copy of frame data, thereby improving the FPS
of the QZXingFilter example noticeably.
This commit is contained in:
Milian Wolff 2016-12-19 18:21:21 +01:00
parent 449a808972
commit 61508f461a
1 changed files with 4 additions and 4 deletions

View File

@ -58,16 +58,16 @@ ArrayRef<byte> GreyscaleLuminanceSource::getRow(int y, ArrayRef<byte> row) const
}
ArrayRef<byte> GreyscaleLuminanceSource::getMatrix() const {
int size = getWidth() * getHeight();
ArrayRef<byte> result (size);
if (left_ == 0 && top_ == 0 && dataWidth_ == getWidth() && dataHeight_ == getHeight()) {
memcpy(&result[0], &greyData_[0], size);
return greyData_;
} else {
int size = getWidth() * getHeight();
ArrayRef<byte> result (size);
for (int row = 0; row < getHeight(); row++) {
memcpy(&result[row * getWidth()], &greyData_[(top_ + row) * dataWidth_ + left_], getWidth());
}
return result;
}
return result;
}
Ref<LuminanceSource> GreyscaleLuminanceSource::rotateCounterClockwise() const {