diff options
author | hbono@chromium.org <hbono@chromium.org@4ff67af0-8c30-449e-8e8b-ad334ec8d88c> | 2012-07-19 06:04:44 +0000 |
---|---|---|
committer | hbono@chromium.org <hbono@chromium.org@4ff67af0-8c30-449e-8e8b-ad334ec8d88c> | 2012-07-19 06:04:44 +0000 |
commit | 11e6ee95ca9a40fe6b86a1cd23a9fbfd7d19c2bd (patch) | |
tree | 2eec0543260b716b3862c8c05100bcd7ab6f833c /turbojpeg-jni.c | |
parent | cd3e30f64064274b17a99bb93e20a7dad2703bf0 (diff) |
Update libjpeg-turbo to r856.
BUG=132952
TEST=none
Review URL: https://chromiumcodereview.appspot.com/10700197
git-svn-id: http://src.chromium.org/svn/trunk/deps/third_party/libjpeg_turbo@147403 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
Diffstat (limited to 'turbojpeg-jni.c')
-rw-r--r-- | turbojpeg-jni.c | 47 |
1 files changed, 34 insertions, 13 deletions
diff --git a/turbojpeg-jni.c b/turbojpeg-jni.c index 1ff9bba..c98845b 100644 --- a/turbojpeg-jni.c +++ b/turbojpeg-jni.c @@ -1,5 +1,5 @@ /* - * Copyright (C)2011 D. R. Commander. All Rights Reserved. + * Copyright (C)2011-2012 D. R. Commander. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -350,12 +350,12 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress return; } -JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress___3BI_3BIIIII +JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress___3BI_3BIIIIIII (JNIEnv *env, jobject obj, jbyteArray src, jint jpegSize, jbyteArray dst, - jint width, jint pitch, jint height, jint pf, jint flags) + jint x, jint y, jint width, jint pitch, jint height, jint pf, jint flags) { tjhandle handle=0; - jsize arraySize=0; + jsize arraySize=0, actualPitch; unsigned char *jpegBuf=NULL, *dstBuf=NULL; gethandle(); @@ -367,15 +367,17 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress if((*env)->GetArrayLength(env, src)<jpegSize) _throw("Source buffer is not large enough"); - arraySize=(pitch==0)? width*tjPixelSize[pf]*height:pitch*height; + actualPitch=(pitch==0)? width*tjPixelSize[pf]:pitch; + arraySize=(y+height-1)*actualPitch + (x+width)*tjPixelSize[pf]; if((*env)->GetArrayLength(env, dst)<arraySize) _throw("Destination buffer is not large enough"); bailif0(jpegBuf=(*env)->GetPrimitiveArrayCritical(env, src, 0)); bailif0(dstBuf=(*env)->GetPrimitiveArrayCritical(env, dst, 0)); - if(tjDecompress2(handle, jpegBuf, (unsigned long)jpegSize, dstBuf, width, - pitch, height, pf, flags)==-1) + 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); @@ -389,12 +391,20 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress return; } -JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress___3BI_3IIIIII - (JNIEnv *env, jobject obj, jbyteArray src, jint jpegSize, jintArray dst, +JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress___3BI_3BIIIII + (JNIEnv *env, jobject obj, jbyteArray src, jint jpegSize, jbyteArray dst, jint width, jint pitch, jint height, jint pf, jint flags) { + Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress___3BI_3BIIIIIII + (env, obj, src, jpegSize, dst, 0, 0, width, pitch, height, pf, flags); +} + +JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress___3BI_3IIIIIIII + (JNIEnv *env, jobject obj, jbyteArray src, jint jpegSize, jintArray dst, + jint x, jint y, jint width, jint stride, jint height, jint pf, jint flags) +{ tjhandle handle=0; - jsize arraySize=0; + jsize arraySize=0, actualStride; unsigned char *jpegBuf=NULL, *dstBuf=NULL; gethandle(); @@ -408,15 +418,17 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress if((*env)->GetArrayLength(env, src)<jpegSize) _throw("Source buffer is not large enough"); - arraySize=(pitch==0)? width*height:pitch*height; + actualStride=(stride==0)? width:stride; + arraySize=(y+height-1)*actualStride + x+width; if((*env)->GetArrayLength(env, dst)<arraySize) _throw("Destination buffer is not large enough"); bailif0(jpegBuf=(*env)->GetPrimitiveArrayCritical(env, src, 0)); bailif0(dstBuf=(*env)->GetPrimitiveArrayCritical(env, dst, 0)); - if(tjDecompress2(handle, jpegBuf, (unsigned long)jpegSize, dstBuf, width, - pitch*sizeof(jint), height, pf, flags)==-1) + 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); @@ -430,6 +442,15 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress return; } +JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress___3BI_3IIIIII + (JNIEnv *env, jobject obj, jbyteArray src, jint jpegSize, jintArray dst, + jint width, jint stride, jint height, jint pf, jint flags) +{ + Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress___3BI_3IIIIIIII + (env, obj, src, jpegSize, dst, 0, 0, width, stride, height, pf, flags); + +} + JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompressToYUV (JNIEnv *env, jobject obj, jbyteArray src, jint jpegSize, jbyteArray dst, jint flags) |