Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Unified Diff: turbojpeg-jni.c

Issue 10700197: Update libjpeg-turbo to r856. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libjpeg_turbo/
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « turbojpeg.c ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: turbojpeg-jni.c
===================================================================
--- turbojpeg-jni.c (revision 144411)
+++ turbojpeg-jni.c (working copy)
@@ -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 @@
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 @@
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 @@
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 @@
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 @@
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)
« no previous file with comments | « turbojpeg.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698