in renderscript-toolkit/src/main/cpp/Histogram.cpp [263:295]
void RenderScriptToolkit::histogramDot(const uint8_t* in, int32_t* out, size_t sizeX, size_t sizeY,
size_t vectorSize, const float* coefficients,
const Restriction* restriction) {
#ifdef ANDROID_RENDERSCRIPT_TOOLKIT_VALIDATE
if (!validRestriction(LOG_TAG, sizeX, sizeY, restriction)) {
return;
}
if (vectorSize < 1 || vectorSize > 4) {
ALOGE("The vectorSize should be between 1 and 4. %zu provided.", vectorSize);
return;
}
if (coefficients != nullptr) {
float sum = 0.0f;
for (size_t i = 0; i < vectorSize; i++) {
if (coefficients[i] < 0.0f) {
ALOGE("histogramDot coefficients should not be negative. Coefficient %zu was %f.",
i, coefficients[i]);
return;
}
sum += coefficients[i];
}
if (sum > 1.0f) {
ALOGE("histogramDot coefficients should add to 1 or less. Their sum is %f.", sum);
return;
}
}
#endif
HistogramDotTask task(in, sizeX, sizeY, vectorSize, processor->getNumberOfThreads(),
coefficients, restriction);
processor->doTask(&task);
task.collateSums(out);
}