渲染脚本致命信号11(代码= 1)

约翰·莫菲特

在我的项目中,我采用了15x15的随机颜色位图,并确定每个像素彼此之间的区别程度。

调用Distinct.start()时,出现以下错误:

A/libc(18416): Fatal signal 11 (SIGSEGV) at 0x00000038 (code=1), thread 18538 (AsyncTask #1)

根据我的发现,信号11表示我试图非法访问内存,但是我找不到可能在哪里。我什至尝试从脚本中删除除实例化结果外的所有内容并返回它。

不同的.rs:

#pragma version(1)
#pragma rs java_package_name(com.moffitj.horizon)
#pragma rs_fp_relaxed

rs_allocation image;
int imgSize;
int side;


float __attribute__((kernel)) root(float in, uint32_t x, uint32_t y){

    //where we'll store the cumulative distance for the current pixel
    float result = 0.0f;

    //Pull the current pixel and unpack it's componants
    const uchar4 current = *(const uchar4*)rsGetElementAt(image, (y * side) + x, 0);
    float4 currentPixel = rsUnpackColor8888(current);

    //find how distinct the current pixel is from all others (and self, to save a branch)
    for(int i = 0; i < imgSize; i++){

        //get the next pixel and uppack it
        const uchar4 pixel = *(const uchar4*)rsGetElementAt(image, i, 0);
        float4 unpackedPixel = rsUnpackColor8888(pixel);

        //compare the distance between the two pixels
        float4 temp = sqrt(pow(currentPixel - unpackedPixel,2));

        //add the difference to the running total
        result += (temp.w + temp.x + temp.y + temp.z);
    }

    result /= imgSize;

    return result;

}

与众不同的.java:

public class Distinct {

    private Allocation mBitmapAllocation;
    private Allocation mReferenceAllocation;
    private Allocation mResultAllocation;
    private int mImgSize;
    private int mNumBlocks;
    private RenderScript mRS;
    private Context mContext;
    private ScriptC_distinct mScript;
    private Bitmap mBitmap;

    /**
     * 
     * @param bitmap
     * @throws IllegalArgumentException if the bitmap is not square or divisible by 64
     */
    public Distinct(Bitmap bitmap, Context context) throws IllegalArgumentException {

        mBitmap = bitmap;
        mContext = context;
        mImgSize = bitmap.getHeight() * bitmap.getWidth();
        mRS = RenderScript.create(mContext);
        mBitmapAllocation = Allocation.createFromBitmap(mRS, bitmap, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);

        Type.Builder referenceBuilder = new Type.Builder(mRS, Element.F32(mRS));//Dummy data won't be used, just to get location once inside script
        referenceBuilder.setX(bitmap.getWidth());
        referenceBuilder.setY(bitmap.getHeight());
        Type type = referenceBuilder.create();

        mReferenceAllocation = Allocation.createTyped(mRS, type, Allocation.USAGE_SCRIPT);

        Type.Builder resultBuilder = new Type.Builder(mRS, Element.F32(mRS));
        resultBuilder.setX(bitmap.getWidth());
        resultBuilder.setY(bitmap.getHeight());
        Type resultType = resultBuilder.create();

        mResultAllocation = Allocation.createTyped(mRS, resultType, Allocation.USAGE_SCRIPT);       

        /*Type.Builder imgTypeBuilder = new Type.Builder(mRS, Element.I32(mRS));
        imgTypeBuilder.setX(mImgSize * mImgSize);
        imgTypeBuilder.setY(1);
        Type imgType = imgTypeBuilder.create();

        mBitmapAllocation = Allocation.createTyped(mRS, imgType, Allocation.USAGE_SCRIPT);*/

        mScript = new ScriptC_distinct(mRS, mContext.getResources(), R.raw.average);
        mScript.set_image(mBitmapAllocation);
        mScript.set_imgSize(mImgSize);
        mScript.set_side(bitmap.getHeight());

    }

    public void start(){

        mScript.forEach_root(mReferenceAllocation, mResultAllocation);

    }
约翰·莫菲特

匆忙中,我从另一个项目中复制了一个可行的解决方案,却错过了更新行的操作。

 mScript = new ScriptC_distinct(mRS, mContext.getResources(), R.raw.average);

应该已经更改为

mScript = new ScriptC_distinct(mRS, mContext.getResources(), R.raw.distinct);

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Android 6上的翻新+ Robospice本机崩溃-致命信号11(SIGSEGV),代码1

来自分类Dev

致命信号11(SIGSEGV)位于0x00000000(代码= 1),线程655(线程77)

来自分类Dev

致命信号11(SIGSEGV)位于0x0000001c(代码= 1),线程18178

来自分类Dev

0x756c66f2处的SQLCipher致命信号11(SIGSEGV)(代码= 1)

来自分类Dev

Android Libgdx致命信号11(SIGSEGV),代码1,故障加法器0x0

来自分类Dev

Android:movie.draw上的0x00000000(代码= 1)的致命信号11(SIGSEGV)

来自分类Dev

Android崩溃:致命信号11(SIGSEGV)位于0xdeadbaad(代码= 1)

来自分类Dev

使用Android NDK C ++时出现致命信号11(SIGSEGV),代码1错误

来自分类Dev

TID 29092中的Android致命信号11(SIGSEGV),代码1,故障加法器0x0

来自分类Dev

TID 5091中的致命信号11(SIGSEGV),代码1,故障加法器0x18

来自分类Dev

应用程序未运行,显示错误A / libc:致命信号11(SIGSEGV)位于0x00000e20(代码= 1),线程8068

来自分类Dev

Android从线程错误中调用jni方法(A / libc:致命信号11(SIGSEGV),代码1,在tid 13620(AsyncTask#3)中的故障加法器0xdeadbaad)

来自分类Dev

fs :: read_to_string上的unwrap()导致致命信号6(SIGABRT),代码-1(SI_QUEUE)在Android中

来自分类Dev

java.lang.Error:信号11(SIGSEGV),代码1(SEGV_MAPERR)Android应用

来自分类Dev

使用服务时出现致命信号11(SIGSEGV)代码= 2

来自分类Dev

TID 32190中的Android致命信号7(SIGBUS),代码1,故障加法器0xb8509ce1(com.example)

来自分类Dev

TID 32190中的Android致命信号7(SIGBUS),代码1,故障加法器0xb8509ce1(com.example)

来自分类Dev

在0xdeadd00d(code = 1),线程17729运行JNI android app A / libc:致命信号11(SIGSEGV)时收到错误消息

来自分类Dev

信号 11 (SIGSEGV),代码 1 (SEGV_MAPERR),故障地址 0x7d02bdb8

来自分类Dev

如何在Shell脚本中捕获退出1信号?

来自分类Dev

发出“ SIGUSR1”信号时发送退出代码

来自分类Dev

应用[unencrypted:0]通过信号[SIGINT]以代码[1]退出

来自分类Dev

为什么1 +'1'='11'但1 *'1'= 1

来自分类Dev

Android致命信号11(SIGSEGV)onFinish

来自分类Dev

加装本机崩溃致命信号11(SIGSEGV)

来自分类Dev

Android ffmpeg错误致命信号11

来自分类Dev

Android MediaCodec MediaMuxer致命信号11(SIGSEGV)

来自分类Dev

启用防护后的致命信号11

来自分类Dev

如何捕捉“致命的信号11(SIGSEGV)”?

Related 相关文章

  1. 1

    Android 6上的翻新+ Robospice本机崩溃-致命信号11(SIGSEGV),代码1

  2. 2

    致命信号11(SIGSEGV)位于0x00000000(代码= 1),线程655(线程77)

  3. 3

    致命信号11(SIGSEGV)位于0x0000001c(代码= 1),线程18178

  4. 4

    0x756c66f2处的SQLCipher致命信号11(SIGSEGV)(代码= 1)

  5. 5

    Android Libgdx致命信号11(SIGSEGV),代码1,故障加法器0x0

  6. 6

    Android:movie.draw上的0x00000000(代码= 1)的致命信号11(SIGSEGV)

  7. 7

    Android崩溃:致命信号11(SIGSEGV)位于0xdeadbaad(代码= 1)

  8. 8

    使用Android NDK C ++时出现致命信号11(SIGSEGV),代码1错误

  9. 9

    TID 29092中的Android致命信号11(SIGSEGV),代码1,故障加法器0x0

  10. 10

    TID 5091中的致命信号11(SIGSEGV),代码1,故障加法器0x18

  11. 11

    应用程序未运行,显示错误A / libc:致命信号11(SIGSEGV)位于0x00000e20(代码= 1),线程8068

  12. 12

    Android从线程错误中调用jni方法(A / libc:致命信号11(SIGSEGV),代码1,在tid 13620(AsyncTask#3)中的故障加法器0xdeadbaad)

  13. 13

    fs :: read_to_string上的unwrap()导致致命信号6(SIGABRT),代码-1(SI_QUEUE)在Android中

  14. 14

    java.lang.Error:信号11(SIGSEGV),代码1(SEGV_MAPERR)Android应用

  15. 15

    使用服务时出现致命信号11(SIGSEGV)代码= 2

  16. 16

    TID 32190中的Android致命信号7(SIGBUS),代码1,故障加法器0xb8509ce1(com.example)

  17. 17

    TID 32190中的Android致命信号7(SIGBUS),代码1,故障加法器0xb8509ce1(com.example)

  18. 18

    在0xdeadd00d(code = 1),线程17729运行JNI android app A / libc:致命信号11(SIGSEGV)时收到错误消息

  19. 19

    信号 11 (SIGSEGV),代码 1 (SEGV_MAPERR),故障地址 0x7d02bdb8

  20. 20

    如何在Shell脚本中捕获退出1信号?

  21. 21

    发出“ SIGUSR1”信号时发送退出代码

  22. 22

    应用[unencrypted:0]通过信号[SIGINT]以代码[1]退出

  23. 23

    为什么1 +'1'='11'但1 *'1'= 1

  24. 24

    Android致命信号11(SIGSEGV)onFinish

  25. 25

    加装本机崩溃致命信号11(SIGSEGV)

  26. 26

    Android ffmpeg错误致命信号11

  27. 27

    Android MediaCodec MediaMuxer致命信号11(SIGSEGV)

  28. 28

    启用防护后的致命信号11

  29. 29

    如何捕捉“致命的信号11(SIGSEGV)”?

热门标签

归档