if(tjCompress2(handle, &srcBuf[y*actualPitch + x*tjPixelSize[pf]], width,
pitch, height, pf, &jpegBuf, &jpegSize, jpegSubsamp, jpegQual,
flags|TJFLAG_NOREALLOC)==-1)
- {
- (*env)->ReleasePrimitiveArrayCritical(env, dst, jpegBuf, 0);
- (*env)->ReleasePrimitiveArrayCritical(env, src, srcBuf, 0);
- jpegBuf=srcBuf=NULL;
_throw(tjGetErrorStr());
- }
bailout:
if(jpegBuf) (*env)->ReleasePrimitiveArrayCritical(env, dst, jpegBuf, 0);
if(tjCompress2(handle, &srcBuf[(y*actualStride + x)*sizeof(int)], width,
stride*sizeof(jint), height, pf, &jpegBuf, &jpegSize, jpegSubsamp,
jpegQual, flags|TJFLAG_NOREALLOC)==-1)
- {
- (*env)->ReleasePrimitiveArrayCritical(env, dst, jpegBuf, 0);
- (*env)->ReleasePrimitiveArrayCritical(env, src, srcBuf, 0);
- jpegBuf=srcBuf=NULL;
_throw(tjGetErrorStr());
- }
bailout:
if(jpegBuf) (*env)->ReleasePrimitiveArrayCritical(env, dst, jpegBuf, 0);
if(tjCompressFromYUV(handle, srcBuf, width, pad, height, subsamp, &jpegBuf,
&jpegSize, jpegQual, flags|TJFLAG_NOREALLOC)==-1)
- {
- (*env)->ReleasePrimitiveArrayCritical(env, dst, jpegBuf, 0);
- (*env)->ReleasePrimitiveArrayCritical(env, src, srcBuf, 0);
- jpegBuf=srcBuf=NULL;
_throw(tjGetErrorStr());
- }
bailout:
if(jpegBuf) (*env)->ReleasePrimitiveArrayCritical(env, dst, jpegBuf, 0);
if(tjEncodeYUV3(handle, &srcBuf[y*actualPitch + x*tjPixelSize[pf]], width,
pitch, height, pf, dstBuf, pad, subsamp, flags)==-1)
- {
- (*env)->ReleasePrimitiveArrayCritical(env, dst, dstBuf, 0);
- (*env)->ReleasePrimitiveArrayCritical(env, src, srcBuf, 0);
- dstBuf=srcBuf=NULL;
_throw(tjGetErrorStr());
- }
bailout:
if(dstBuf) (*env)->ReleasePrimitiveArrayCritical(env, dst, dstBuf, 0);
if(tjEncodeYUV3(handle, &srcBuf[(y*actualStride + x)*sizeof(int)], width,
stride*sizeof(jint), height, pf, dstBuf, pad, subsamp, flags)==-1)
- {
- (*env)->ReleasePrimitiveArrayCritical(env, dst, dstBuf, 0);
- (*env)->ReleasePrimitiveArrayCritical(env, src, srcBuf, 0);
- dstBuf=srcBuf=NULL;
_throw(tjGetErrorStr());
- }
bailout:
if(dstBuf) (*env)->ReleasePrimitiveArrayCritical(env, dst, dstBuf, 0);
if(tjDecompressHeader3(handle, jpegBuf, (unsigned long)jpegSize,
&width, &height, &jpegSubsamp, &jpegColorspace)==-1)
- {
- (*env)->ReleasePrimitiveArrayCritical(env, src, jpegBuf, 0);
_throw(tjGetErrorStr());
- }
+
(*env)->ReleasePrimitiveArrayCritical(env, src, jpegBuf, 0); jpegBuf=NULL;
bailif0(_fid=(*env)->GetFieldID(env, _cls, "srcSubsamp", "I"));
(*env)->SetIntField(env, obj, _fid, height);
bailout:
+ if(jpegBuf) (*env)->ReleasePrimitiveArrayCritical(env, src, jpegBuf, 0);
return;
}
if(tjDecompress2(handle, jpegBuf, (unsigned long)jpegSize,
&dstBuf[y*actualPitch + x*tjPixelSize[pf]], width, pitch, height, pf,
flags)==-1)
- {
- (*env)->ReleasePrimitiveArrayCritical(env, dst, dstBuf, 0);
- (*env)->ReleasePrimitiveArrayCritical(env, src, jpegBuf, 0);
- dstBuf=jpegBuf=NULL;
_throw(tjGetErrorStr());
- }
bailout:
if(dstBuf) (*env)->ReleasePrimitiveArrayCritical(env, dst, dstBuf, 0);
if(tjDecompress2(handle, jpegBuf, (unsigned long)jpegSize,
&dstBuf[(y*actualStride + x)*sizeof(int)], width, stride*sizeof(jint),
height, pf, flags)==-1)
- {
- (*env)->ReleasePrimitiveArrayCritical(env, dst, dstBuf, 0);
- (*env)->ReleasePrimitiveArrayCritical(env, src, jpegBuf, 0);
- dstBuf=jpegBuf=NULL;
_throw(tjGetErrorStr());
- }
bailout:
if(dstBuf) (*env)->ReleasePrimitiveArrayCritical(env, dst, dstBuf, 0);
if(tjDecompressToYUV2(handle, jpegBuf, (unsigned long)jpegSize, dstBuf,
desiredWidth, pad, desiredHeight, flags)==-1)
- {
- (*env)->ReleasePrimitiveArrayCritical(env, dst, dstBuf, 0);
- (*env)->ReleasePrimitiveArrayCritical(env, src, jpegBuf, 0);
- dstBuf=jpegBuf=NULL;
_throw(tjGetErrorStr());
- }
bailout:
if(dstBuf) (*env)->ReleasePrimitiveArrayCritical(env, dst, dstBuf, 0);
if(tjDecodeYUV(handle, srcBuf, pad, subsamp,
&dstBuf[y*actualPitch + x*tjPixelSize[pf]], width, pitch, height, pf,
flags)==-1)
- {
- (*env)->ReleasePrimitiveArrayCritical(env, dst, dstBuf, 0);
- (*env)->ReleasePrimitiveArrayCritical(env, src, srcBuf, 0);
- dstBuf=srcBuf=NULL;
_throw(tjGetErrorStr());
- }
bailout:
if(dstBuf) (*env)->ReleasePrimitiveArrayCritical(env, dst, dstBuf, 0);
if(tjDecodeYUV(handle, srcBuf, pad, subsamp,
&dstBuf[(y*actualStride + x)*sizeof(int)], width, stride*sizeof(jint),
height, pf, flags)==-1)
- {
- (*env)->ReleasePrimitiveArrayCritical(env, dst, dstBuf, 0);
- (*env)->ReleasePrimitiveArrayCritical(env, src, srcBuf, 0);
- dstBuf=srcBuf=NULL;
_throw(tjGetErrorStr());
- }
bailout:
if(dstBuf) (*env)->ReleasePrimitiveArrayCritical(env, dst, dstBuf, 0);
}
}
- bailif0(jpegBuf=(*env)->GetPrimitiveArrayCritical(env, jsrcBuf, 0));
for(i=0; i<n; i++)
{
int w=jpegWidth, h=jpegHeight;
if((unsigned long)(*env)->GetArrayLength(env, jdstBufs[i])
<tjBufSize(w, h, jpegSubsamp))
_throw("Destination buffer is not large enough");
- bailif0(dstBufs[i]=(*env)->GetPrimitiveArrayCritical(env, jdstBufs[i], 0));
}
+ bailif0(jpegBuf=(*env)->GetPrimitiveArrayCritical(env, jsrcBuf, 0));
+ for(i=0; i<n; i++)
+ bailif0(dstBufs[i]=(*env)->GetPrimitiveArrayCritical(env, jdstBufs[i], 0));
if(tjTransform(handle, jpegBuf, jpegSize, n, dstBufs, dstSizes, t,
flags|TJFLAG_NOREALLOC)==-1)
- {
- (*env)->ReleasePrimitiveArrayCritical(env, jsrcBuf, jpegBuf, 0);
- jpegBuf=NULL;
- for(i=0; i<n; i++)
- {
- (*env)->ReleasePrimitiveArrayCritical(env, jdstBufs[i], dstBufs[i], 0);
- dstBufs[i]=NULL;
- }
_throw(tjGetErrorStr());
+
+ for(i=0; i<n; i++)
+ {
+ (*env)->ReleasePrimitiveArrayCritical(env, jdstBufs[i], dstBufs[i], 0);
+ dstBufs[i]=NULL;
}
+ (*env)->ReleasePrimitiveArrayCritical(env, jsrcBuf, jpegBuf, 0);
+ jpegBuf=NULL;
jdstSizes=(*env)->NewIntArray(env, n);
bailif0(dstSizesi=(*env)->GetIntArrayElements(env, jdstSizes, 0));
for(i=0; i<n; i++) dstSizesi[i]=(int)dstSizes[i];
bailout:
- if(jpegBuf) (*env)->ReleasePrimitiveArrayCritical(env, jsrcBuf, jpegBuf, 0);
+ if(dstSizesi) (*env)->ReleaseIntArrayElements(env, jdstSizes, dstSizesi, 0);
if(dstBufs)
{
for(i=0; i<n; i++)
}
free(dstBufs);
}
+ if(jpegBuf) (*env)->ReleasePrimitiveArrayCritical(env, jsrcBuf, jpegBuf, 0);
if(jdstBufs) free(jdstBufs);
if(dstSizes) free(dstSizes);
- if(dstSizesi) (*env)->ReleaseIntArrayElements(env, jdstSizes, dstSizesi, 0);
if(t) free(t);
return jdstSizes;
}