I am trying to use the built in RenderScript script for converting NV21 to RGBA8888, but even thoguh I checked the size of the buffer in the Allocation object I still got the following error:
Fatal signal 11 (SIGSEGV) at 0x4eb30000 (code=1), thread 18458 (epthsyncexample)
My code:
rs = RenderScript.create(context);
yuvToRgbIntrinsic = ScriptIntrinsicYuvToRGB.create(rs, Element.U8_4(rs));
Type.Builder yuvType = new Type.Builder(rs, Element.U8_4(rs))
.setX(1280).setY(720)
.setYuvFormat(android.graphics.ImageFormat.NV21);
Allocation in = Allocation.createTyped(rs, yuvType.create(), Allocation.USAGE_SCRIPT);
in.copyFrom(YUVArray); //<<<<<<<<<<<<<<<<<<<<<<<<<<
Type.Builder rgbaType = new Type.Builder(rs, Element.U8_4(rs))
.setX(W).setY(H);
Allocation out = Allocation.createTyped(rs, rgbaType.create(), Allocation.USAGE_SCRIPT);
byte[] RGBOut = new byte[W * H * 4];
//
yuvToRgbIntrinsic.setInput(in);
yuvToRgbIntrinsic.forEach(out);
out.copyTo(RGBOut);
return RGBOut;
The error itself is easy to understand, but why it happens I do not know. The byte array I use to represent the NV21 image is of size 1382400 bytes. The Allocation buffer is of 1280*720*1.5 = 1382400 bytes. I dont understand why the marked line of code caused a segmentation fault.
Any hints?
I have read some posts like this and this, but they are about completely different problems. The only question that might have something to do with it is this one. Where can I find out about this limit?