分配给输出paramaeter时的Andr​​oid渲染脚本错误 [英] Android Render Script Error when assigning to Out paramaeter

查看:186
本文介绍了分配给输出paramaeter时的Andr​​oid渲染脚本错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到误差

Fatal signal 11 (SIGSEGV) at 0x51b71000 (code=1), thread 3696 (sssist.magnitab)

每当我将值分配给出来发回值主应用程序的参数,当我删除分配错误消失了,这是我的code,(下面部分的android code)

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();

帮我纠正。

推荐答案

您应该只写出来[0],并且永远不出来[10]。该出指针自动先进和根()在你的输入/输出分配每个单元上运行。每个单元有此功能输入/输出双指针调用一个有效的,真正映射到[Y] [X],OUT [Y] [X](或1D如适用)。

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).

这篇关于分配给输出paramaeter时的Andr​​oid渲染脚本错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆