android - Allocation for RenderScript gives error even though the size should be adequate -


i trying use built in renderscript script converting nv21 rgba8888, thoguh checked size of buffer in allocation object still got following error: fatal signal 11 (sigsegv) @ 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 easy understand, why happens not know. byte array use represent nv21 image of size 1382400 bytes. allocation buffer of 1280*720*1.5 = 1382400 bytes. dont understand why marked line of code caused segmentation fault.

any hints?

i have read posts this , this, different problems. question might have this one. can find out limit?

after lot of meddling code realized causing problem. when debugging through code must have caused race conditions or because every time load data , unit had high chance of getting seg fault.

the code ended works if allowed run passed renderscript segment was:

public byte[] convertyuv2rgb(byte[] yuvarray, int h, int w){//w: 1280, h: 720      //convert using premade script here.     rs = renderscript.create(context);     yuvtorgbintrinsic = scriptintrinsicyuvtorgb.create(rs, element.u8_4(rs));      type.builder yuvtype = new type.builder(rs, element.u8(rs)).setx(yuvarray.length);      allocation in = allocation.createtyped(rs, yuvtype.create(), allocation.usage_script);      type.builder rgbatype = new type.builder(rs, element.rgba_8888(rs)).setx(w).sety(h);      allocation out = allocation.createtyped(rs, rgbatype.create(), allocation.usage_script);     in.copyfrom(yuvarray);     byte[] rgbout = new byte[w * h * 4];      yuvtorgbintrinsic.setinput(in);     yuvtorgbintrinsic.foreach(out);      out.copyto(rgbout);     return rgbout; } 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -