Correct misuse of the word "pitch" + more code formatting tweaks
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.3.x@970 632fc199-4ca6-4c93-a231-07263d6284db
This commit is contained in:
@@ -350,8 +350,7 @@ public final class TJ {
|
|||||||
* @return the size of the buffer (in bytes) required to hold a YUV planar
|
* @return the size of the buffer (in bytes) required to hold a YUV planar
|
||||||
* image with the given width, height, and level of chrominance subsampling
|
* image with the given width, height, and level of chrominance subsampling
|
||||||
*/
|
*/
|
||||||
public static native int bufSizeYUV(int width, int height,
|
public static native int bufSizeYUV(int width, int height, int subsamp)
|
||||||
int subsamp)
|
|
||||||
throws Exception;
|
throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -280,15 +280,15 @@ public class TJCompressor {
|
|||||||
if (intPixels) {
|
if (intPixels) {
|
||||||
SinglePixelPackedSampleModel sm =
|
SinglePixelPackedSampleModel sm =
|
||||||
(SinglePixelPackedSampleModel)srcImage.getSampleModel();
|
(SinglePixelPackedSampleModel)srcImage.getSampleModel();
|
||||||
int pitch = sm.getScanlineStride();
|
int stride = sm.getScanlineStride();
|
||||||
DataBufferInt db = (DataBufferInt)wr.getDataBuffer();
|
DataBufferInt db = (DataBufferInt)wr.getDataBuffer();
|
||||||
int[] buf = db.getData();
|
int[] buf = db.getData();
|
||||||
if (srcX >= 0 && srcY >= 0)
|
if (srcX >= 0 && srcY >= 0)
|
||||||
compressedSize = compress(buf, srcX, srcY, width, pitch, height,
|
compressedSize = compress(buf, srcX, srcY, width, stride, height,
|
||||||
pixelFormat, dstBuf, subsamp, jpegQuality,
|
pixelFormat, dstBuf, subsamp, jpegQuality,
|
||||||
flags);
|
flags);
|
||||||
else
|
else
|
||||||
compressedSize = compress(buf, width, pitch, height, pixelFormat,
|
compressedSize = compress(buf, width, stride, height, pixelFormat,
|
||||||
dstBuf, subsamp, jpegQuality, flags);
|
dstBuf, subsamp, jpegQuality, flags);
|
||||||
} else {
|
} else {
|
||||||
ComponentSampleModel sm =
|
ComponentSampleModel sm =
|
||||||
@@ -435,10 +435,10 @@ public class TJCompressor {
|
|||||||
if (intPixels) {
|
if (intPixels) {
|
||||||
SinglePixelPackedSampleModel sm =
|
SinglePixelPackedSampleModel sm =
|
||||||
(SinglePixelPackedSampleModel)srcImage.getSampleModel();
|
(SinglePixelPackedSampleModel)srcImage.getSampleModel();
|
||||||
int pitch = sm.getScanlineStride();
|
int stride = sm.getScanlineStride();
|
||||||
DataBufferInt db = (DataBufferInt)wr.getDataBuffer();
|
DataBufferInt db = (DataBufferInt)wr.getDataBuffer();
|
||||||
int[] buf = db.getData();
|
int[] buf = db.getData();
|
||||||
encodeYUV(buf, width, pitch, height, pixelFormat, dstBuf, subsamp,
|
encodeYUV(buf, width, stride, height, pixelFormat, dstBuf, subsamp,
|
||||||
flags);
|
flags);
|
||||||
} else {
|
} else {
|
||||||
ComponentSampleModel sm =
|
ComponentSampleModel sm =
|
||||||
@@ -511,7 +511,7 @@ public class TJCompressor {
|
|||||||
// JPEG size in bytes is returned
|
// JPEG size in bytes is returned
|
||||||
private native int compress(byte[] srcBuf, int width, int pitch,
|
private native int compress(byte[] srcBuf, int width, int pitch,
|
||||||
int height, int pixelFormat, byte[] dstBuf, int jpegSubsamp, int jpegQual,
|
int height, int pixelFormat, byte[] dstBuf, int jpegSubsamp, int jpegQual,
|
||||||
int flags) throws Exception;
|
int flags) throws Exception; // deprecated
|
||||||
|
|
||||||
private native int compress(byte[] srcBuf, int x, int y, int width,
|
private native int compress(byte[] srcBuf, int x, int y, int width,
|
||||||
int pitch, int height, int pixelFormat, byte[] dstBuf, int jpegSubsamp,
|
int pitch, int height, int pixelFormat, byte[] dstBuf, int jpegSubsamp,
|
||||||
@@ -519,7 +519,7 @@ public class TJCompressor {
|
|||||||
|
|
||||||
private native int compress(int[] srcBuf, int width, int stride,
|
private native int compress(int[] srcBuf, int width, int stride,
|
||||||
int height, int pixelFormat, byte[] dstBuf, int jpegSubsamp, int jpegQual,
|
int height, int pixelFormat, byte[] dstBuf, int jpegSubsamp, int jpegQual,
|
||||||
int flags) throws Exception;
|
int flags) throws Exception; // deprecated
|
||||||
|
|
||||||
private native int compress(int[] srcBuf, int x, int y, int width,
|
private native int compress(int[] srcBuf, int x, int y, int width,
|
||||||
int stride, int height, int pixelFormat, byte[] dstBuf, int jpegSubsamp,
|
int stride, int height, int pixelFormat, byte[] dstBuf, int jpegSubsamp,
|
||||||
@@ -529,7 +529,7 @@ public class TJCompressor {
|
|||||||
int height, int pixelFormat, byte[] dstBuf, int subsamp, int flags)
|
int height, int pixelFormat, byte[] dstBuf, int subsamp, int flags)
|
||||||
throws Exception;
|
throws Exception;
|
||||||
|
|
||||||
private native void encodeYUV(int[] srcBuf, int width, int pitch,
|
private native void encodeYUV(int[] srcBuf, int width, int stride,
|
||||||
int height, int pixelFormat, byte[] dstBuf, int subsamp, int flags)
|
int height, int pixelFormat, byte[] dstBuf, int subsamp, int flags)
|
||||||
throws Exception;
|
throws Exception;
|
||||||
|
|
||||||
|
|||||||
@@ -520,12 +520,12 @@ public class TJDecompressor {
|
|||||||
if (intPixels) {
|
if (intPixels) {
|
||||||
SinglePixelPackedSampleModel sm =
|
SinglePixelPackedSampleModel sm =
|
||||||
(SinglePixelPackedSampleModel)dstImage.getSampleModel();
|
(SinglePixelPackedSampleModel)dstImage.getSampleModel();
|
||||||
int pitch = sm.getScanlineStride();
|
int stride = sm.getScanlineStride();
|
||||||
DataBufferInt db = (DataBufferInt)wr.getDataBuffer();
|
DataBufferInt db = (DataBufferInt)wr.getDataBuffer();
|
||||||
int[] buf = db.getData();
|
int[] buf = db.getData();
|
||||||
if (jpegBuf == null)
|
if (jpegBuf == null)
|
||||||
throw new Exception(NO_ASSOC_ERROR);
|
throw new Exception(NO_ASSOC_ERROR);
|
||||||
decompress(jpegBuf, jpegBufSize, buf, scaledWidth, pitch, scaledHeight,
|
decompress(jpegBuf, jpegBufSize, buf, scaledWidth, stride, scaledHeight,
|
||||||
pixelFormat, flags);
|
pixelFormat, flags);
|
||||||
} else {
|
} else {
|
||||||
ComponentSampleModel sm =
|
ComponentSampleModel sm =
|
||||||
@@ -600,25 +600,22 @@ public class TJDecompressor {
|
|||||||
|
|
||||||
private native void decompress(byte[] srcBuf, int size, byte[] dstBuf,
|
private native void decompress(byte[] srcBuf, int size, byte[] dstBuf,
|
||||||
int desiredWidth, int pitch, int desiredHeight, int pixelFormat, int flags)
|
int desiredWidth, int pitch, int desiredHeight, int pixelFormat, int flags)
|
||||||
throws Exception;
|
throws Exception; // deprecated
|
||||||
|
|
||||||
private native void decompress(byte[] srcBuf, int size, byte[] dstBuf, int x,
|
private native void decompress(byte[] srcBuf, int size, byte[] dstBuf, int x,
|
||||||
int y, int desiredWidth, int pitch, int desiredHeight, int pixelFormat,
|
int y, int desiredWidth, int pitch, int desiredHeight, int pixelFormat,
|
||||||
int flags)
|
int flags) throws Exception;
|
||||||
throws Exception;
|
|
||||||
|
|
||||||
private native void decompress(byte[] srcBuf, int size, int[] dstBuf,
|
private native void decompress(byte[] srcBuf, int size, int[] dstBuf,
|
||||||
int desiredWidth, int stride, int desiredHeight, int pixelFormat, int flags)
|
int desiredWidth, int stride, int desiredHeight, int pixelFormat,
|
||||||
throws Exception;
|
int flags) throws Exception; // deprecated
|
||||||
|
|
||||||
private native void decompress(byte[] srcBuf, int size, int[] dstBuf, int x,
|
private native void decompress(byte[] srcBuf, int size, int[] dstBuf, int x,
|
||||||
int y, int desiredWidth, int stride, int desiredHeight, int pixelFormat,
|
int y, int desiredWidth, int stride, int desiredHeight, int pixelFormat,
|
||||||
int flags)
|
int flags) throws Exception;
|
||||||
throws Exception;
|
|
||||||
|
|
||||||
private native void decompressToYUV(byte[] srcBuf, int size, byte[] dstBuf,
|
private native void decompressToYUV(byte[] srcBuf, int size, byte[] dstBuf,
|
||||||
int flags)
|
int flags) throws Exception;
|
||||||
throws Exception;
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
TJLoader.load();
|
TJLoader.load();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C)2011-2012 D. R. Commander. All Rights Reserved.
|
* Copyright (C)2011-2013 D. R. Commander. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
@@ -249,7 +249,7 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___
|
|||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___3IIIII_3BII
|
JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___3IIIII_3BII
|
||||||
(JNIEnv *env, jobject obj, jintArray src, jint width, jint pitch,
|
(JNIEnv *env, jobject obj, jintArray src, jint width, jint stride,
|
||||||
jint height, jint pf, jbyteArray dst, jint subsamp, jint flags)
|
jint height, jint pf, jbyteArray dst, jint subsamp, jint flags)
|
||||||
{
|
{
|
||||||
tjhandle handle=0;
|
tjhandle handle=0;
|
||||||
@@ -259,14 +259,14 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___
|
|||||||
gethandle();
|
gethandle();
|
||||||
|
|
||||||
if(pf<0 || pf>=org_libjpegturbo_turbojpeg_TJ_NUMPF || width<1 || height<1
|
if(pf<0 || pf>=org_libjpegturbo_turbojpeg_TJ_NUMPF || width<1 || height<1
|
||||||
|| pitch<0)
|
|| stride<0)
|
||||||
_throw("Invalid argument in compress()");
|
_throw("Invalid argument in encodeYUV()");
|
||||||
if(org_libjpegturbo_turbojpeg_TJ_NUMPF!=TJ_NUMPF)
|
if(org_libjpegturbo_turbojpeg_TJ_NUMPF!=TJ_NUMPF)
|
||||||
_throw("Mismatch between Java and C API");
|
_throw("Mismatch between Java and C API");
|
||||||
if(tjPixelSize[pf]!=sizeof(jint))
|
if(tjPixelSize[pf]!=sizeof(jint))
|
||||||
_throw("Pixel format must be 32-bit when encoding from an integer buffer.");
|
_throw("Pixel format must be 32-bit when encoding from an integer buffer.");
|
||||||
|
|
||||||
arraySize=(pitch==0)? width*height:pitch*height;
|
arraySize=(stride==0)? width*height:stride*height;
|
||||||
if((*env)->GetArrayLength(env, src)<arraySize)
|
if((*env)->GetArrayLength(env, src)<arraySize)
|
||||||
_throw("Source buffer is not large enough");
|
_throw("Source buffer is not large enough");
|
||||||
if((*env)->GetArrayLength(env, dst)
|
if((*env)->GetArrayLength(env, dst)
|
||||||
@@ -276,7 +276,7 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___
|
|||||||
bailif0(srcBuf=(*env)->GetPrimitiveArrayCritical(env, src, 0));
|
bailif0(srcBuf=(*env)->GetPrimitiveArrayCritical(env, src, 0));
|
||||||
bailif0(dstBuf=(*env)->GetPrimitiveArrayCritical(env, dst, 0));
|
bailif0(dstBuf=(*env)->GetPrimitiveArrayCritical(env, dst, 0));
|
||||||
|
|
||||||
if(tjEncodeYUV2(handle, srcBuf, width, pitch*sizeof(jint), height, pf,
|
if(tjEncodeYUV2(handle, srcBuf, width, stride*sizeof(jint), height, pf,
|
||||||
dstBuf, subsamp, flags)==-1)
|
dstBuf, subsamp, flags)==-1)
|
||||||
{
|
{
|
||||||
(*env)->ReleasePrimitiveArrayCritical(env, dst, dstBuf, 0);
|
(*env)->ReleasePrimitiveArrayCritical(env, dst, dstBuf, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user