You should only be writing to out[0], and never to out[10]. The out pointer is advanced automatically and root() is run on each cell in your input/output allocations. Each individual cell has this function called with a valid in/out pointer pair that really maps to in[y][x], out[y][x] (or 1D as appropriate).
Android Render Script Error when assigning to Out paramaeter
-
12-10-2022 - |
Question
i am getting error
Fatal signal 11 (SIGSEGV) at 0x51b71000 (code=1), thread 3696 (sssist.magnitab)
Whenever i assign value to out parameter for send back the values main app , when i remove assignment error goes away , here is my code ,(below part the android code )
void root(const char *in, int *out, uint32_t x, uint32_t y) {\
int pixelData[size];
for (int i = 0; i <size ; i += 16)
{
//rsDebug("---------------:","3333");
int lumOne = in[i];
lumOne += 128;
pixelData[lumOne]=pixelData[lumOne]+1;
int lumTwo = in[i+2];
lumTwo += 128;
//pixelData[lumTwo]++;
pixelData[lumTwo]=pixelData[lumTwo]+1;
}
out[10]=23;
}
RenderScript mRS;
mRS = RenderScript.create(activity);
ScriptC_mono mScript;
// Convert to Bitmap
Allocation alloc = Allocation.createSized(mRS, Element.I8(mRS), array.length, Allocation.USAGE_SCRIPT);
alloc.copyFrom(array);
int[] ret = new int[array.length];
int[] ret2 = new int[array.length];
Allocation alloc_out = Allocation.createSized(mRS, Element.I32(mRS), array.length, Allocation.USAGE_SCRIPT);
alloc_out.copyFrom(ret2);
mScript = new ScriptC_mono(mRS, activity.getResources(),R.raw.mono);
mScript.set_size(array.length);
mScript.forEach_root(alloc, alloc_out);
alloc_out.copyTo(ret2);
//byte [] outarray = array;
// mOutPixelsAllocation.copyTo(outarray);
mRS.finish();
help me to correct this.
La solution
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow