我正在尝试使用一些本地代码来创建Gif.
我使用绘画绘制图像,创建几个笔划,单击保存,绘制的图像将保存为JPG格式.当我点击创建Gif时,它会获取所有图像并开始创建一个gif.这是当我得到致命信号11并且应用程序重新启动时.
我使用本机代码,所以我有崩溃的回溯:
I/DEBUG(95): backtrace:
I/DEBUG(95): #00 pc 00002a04 /lib/libgifflen.so (NeuQuant::learn()+239)
I/DEBUG(95): #01 pc 00002b9d /lib/libgifflen.so (NeuQuant::quantise(DIB*,DIB*,int,int)+84)
I/DEBUG(95): #02 pc 00002d41 lib/libgifflen.so (Java_com_stay_gif_GifEncoder_addFrame+208)
I/DEBUG(95): #03 pc 0001deb0 /system/lib/libdvm.so (dvmPlatformInvoke+112)
I/DEBUG(95): #04 pc 0004d103 /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*,JValue*,Method const*,Thread*)+394)
I/DEBUG(95): #05 pc 0004f21f /system/lib/libdvm.so (dvmResolveNativeMethod(unsigned int const*,Thread*)+174)
I/DEBUG(95): #06 pc 000272e0 /system/lib/libdvm.so
I/DEBUG(95): #07 pc 0002bbe8 /system/lib/libdvm.so (dvmInterpret(Thread*,JValue*)+180)
I/DEBUG(95): #08 pc 0005fb37 /system/lib/libdvm.so (dvmInvokeMethod(Object*,ArrayObject*,ClassObject*,bool)+374)
I/DEBUG(95): #09 pc 000670e5 /system/lib/libdvm.so
I/DEBUG(95): #10 pc 000272e0 /system/lib/libdvm.so
I/DEBUG(95): #11 pc 0002bbe8 /system/lib/libdvm.so (dvmInterpret(Thread*,JValue*)+180)
I/DEBUG(95): #12 pc 0005f871 /system/lib/libdvm.so (dvmCallMethodV(Thread*,Object*,bool,std::__va_list)+272)
I/DEBUG(95): #13 pc 000496f3 /system/lib/libdvm.so
I/DEBUG(95): #14 pc 00048581 /system/lib/libandroid_runtime.so
I/DEBUG(95): #15 pc 00049637 /system/lib/libandroid_runtime.so (android::AndroidRuntime::start(char const*,char const*)+390)
I/DEBUG(95): #16 pc 00000dcf /system/bin/app_process
崩溃的代码:
void NeuQuant::learn()
{
int i,j,b,g,r;
int radius,rad,alpha,step,delta,samplepixels;
//unsigned char *p;
int *p;
unsigned char *lim;
alphadec = 30 + ((samplefac-1)/3);
p = (int*)thepicture;
lim = thepicture + lengthcount;
samplepixels = lengthcount/samplefac;
delta = samplepixels/ncycles;
alpha = initalpha;
radius = initradius;
rad = radius >> radiusbiasshift;
if (rad <= 1) rad = 0;
for (i=0; i
向日志发现我发现错误发生在NeuQuant :: learn()中,做了一些调试,它在这个确切的行上崩溃了b =(((* p))& 0xff)<< netbiasshift ;. Crash并不总是发生,有时我得到一个gif并且一切正常,但有时它在b =(((* p))& 0xff)时崩溃<< netbiasshift ;. 我做了一些更多的调试,我发现当它在b =(((* p))& 0xff)上崩溃时<< netbiasshift;它在第一次进入时没有崩溃,它在b =(((* p))& 0xff)<<<< netbiasshift ;. 任何人都知道可能是什么问题?
最佳答案
我变了:
原文链接:https://www.f2er.com/android/430919.htmlif (p >= (int *)lim)
p -= lengthcount;
至:
if (p >= (unsigned int *)lim)
p = (unsigned int*)thepicture;
它似乎现在有效.