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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « turbojpeg.c ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C)2011 D. R. Commander. All Rights Reserved. 2 * Copyright (C)2011-2012 D. R. Commander. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met: 5 * modification, are permitted provided that the following conditions are met:
6 * 6 *
7 * - Redistributions of source code must retain the above copyright notice, 7 * - Redistributions of source code must retain the above copyright notice,
8 * this list of conditions and the following disclaimer. 8 * this list of conditions and the following disclaimer.
9 * - Redistributions in binary form must reproduce the above copyright notice, 9 * - Redistributions in binary form must reproduce the above copyright notice,
10 * this list of conditions and the following disclaimer in the documentation 10 * this list of conditions and the following disclaimer in the documentation
11 * and/or other materials provided with the distribution. 11 * and/or other materials provided with the distribution.
12 * - Neither the name of the libjpeg-turbo Project nor the names of its 12 * - Neither the name of the libjpeg-turbo Project nor the names of its
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 (*env)->SetIntField(env, obj, _fid, jpegSubsamp); 343 (*env)->SetIntField(env, obj, _fid, jpegSubsamp);
344 bailif0(_fid=(*env)->GetFieldID(env, _cls, "jpegWidth", "I")); 344 bailif0(_fid=(*env)->GetFieldID(env, _cls, "jpegWidth", "I"));
345 (*env)->SetIntField(env, obj, _fid, width); 345 (*env)->SetIntField(env, obj, _fid, width);
346 bailif0(_fid=(*env)->GetFieldID(env, _cls, "jpegHeight", "I")); 346 bailif0(_fid=(*env)->GetFieldID(env, _cls, "jpegHeight", "I"));
347 (*env)->SetIntField(env, obj, _fid, height); 347 (*env)->SetIntField(env, obj, _fid, height);
348 348
349 bailout: 349 bailout:
350 return; 350 return;
351 } 351 }
352 352
353 JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress ___3BI_3BIIIII 353 JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress ___3BI_3BIIIIIII
354 (JNIEnv *env, jobject obj, jbyteArray src, jint jpegSize, jbyteArray dst , 354 (JNIEnv *env, jobject obj, jbyteArray src, jint jpegSize, jbyteArray dst ,
355 » » jint width, jint pitch, jint height, jint pf, jint flags) 355 » » jint x, jint y, jint width, jint pitch, jint height, jint pf, ji nt flags)
356 { 356 {
357 tjhandle handle=0; 357 tjhandle handle=0;
358 » jsize arraySize=0; 358 » jsize arraySize=0, actualPitch;
359 unsigned char *jpegBuf=NULL, *dstBuf=NULL; 359 unsigned char *jpegBuf=NULL, *dstBuf=NULL;
360 360
361 gethandle(); 361 gethandle();
362 362
363 if(pf<0 || pf>=org_libjpegturbo_turbojpeg_TJ_NUMPF) 363 if(pf<0 || pf>=org_libjpegturbo_turbojpeg_TJ_NUMPF)
364 _throw("Invalid argument in decompress()"); 364 _throw("Invalid argument in decompress()");
365 if(org_libjpegturbo_turbojpeg_TJ_NUMPF!=TJ_NUMPF) 365 if(org_libjpegturbo_turbojpeg_TJ_NUMPF!=TJ_NUMPF)
366 _throw("Mismatch between Java and C API"); 366 _throw("Mismatch between Java and C API");
367 367
368 if((*env)->GetArrayLength(env, src)<jpegSize) 368 if((*env)->GetArrayLength(env, src)<jpegSize)
369 _throw("Source buffer is not large enough"); 369 _throw("Source buffer is not large enough");
370 » arraySize=(pitch==0)? width*tjPixelSize[pf]*height:pitch*height; 370 » actualPitch=(pitch==0)? width*tjPixelSize[pf]:pitch;
371 » arraySize=(y+height-1)*actualPitch + (x+width)*tjPixelSize[pf];
371 if((*env)->GetArrayLength(env, dst)<arraySize) 372 if((*env)->GetArrayLength(env, dst)<arraySize)
372 _throw("Destination buffer is not large enough"); 373 _throw("Destination buffer is not large enough");
373 374
374 bailif0(jpegBuf=(*env)->GetPrimitiveArrayCritical(env, src, 0)); 375 bailif0(jpegBuf=(*env)->GetPrimitiveArrayCritical(env, src, 0));
375 bailif0(dstBuf=(*env)->GetPrimitiveArrayCritical(env, dst, 0)); 376 bailif0(dstBuf=(*env)->GetPrimitiveArrayCritical(env, dst, 0));
376 377
377 » if(tjDecompress2(handle, jpegBuf, (unsigned long)jpegSize, dstBuf, width , 378 » if(tjDecompress2(handle, jpegBuf, (unsigned long)jpegSize,
378 » » pitch, height, pf, flags)==-1) 379 » » &dstBuf[y*actualPitch + x*tjPixelSize[pf]], width, pitch, height , pf,
380 » » flags)==-1)
379 { 381 {
380 (*env)->ReleasePrimitiveArrayCritical(env, dst, dstBuf, 0); 382 (*env)->ReleasePrimitiveArrayCritical(env, dst, dstBuf, 0);
381 (*env)->ReleasePrimitiveArrayCritical(env, src, jpegBuf, 0); 383 (*env)->ReleasePrimitiveArrayCritical(env, src, jpegBuf, 0);
382 dstBuf=jpegBuf=NULL; 384 dstBuf=jpegBuf=NULL;
383 _throw(tjGetErrorStr()); 385 _throw(tjGetErrorStr());
384 } 386 }
385 387
386 bailout: 388 bailout:
387 if(dstBuf) (*env)->ReleasePrimitiveArrayCritical(env, dst, dstBuf, 0); 389 if(dstBuf) (*env)->ReleasePrimitiveArrayCritical(env, dst, dstBuf, 0);
388 if(jpegBuf) (*env)->ReleasePrimitiveArrayCritical(env, src, jpegBuf, 0); 390 if(jpegBuf) (*env)->ReleasePrimitiveArrayCritical(env, src, jpegBuf, 0);
389 return; 391 return;
390 } 392 }
391 393
392 JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress ___3BI_3IIIIII 394 JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress ___3BI_3BIIIII
393 » (JNIEnv *env, jobject obj, jbyteArray src, jint jpegSize, jintArray dst, 395 » (JNIEnv *env, jobject obj, jbyteArray src, jint jpegSize, jbyteArray dst ,
394 jint width, jint pitch, jint height, jint pf, jint flags) 396 jint width, jint pitch, jint height, jint pf, jint flags)
395 { 397 {
398 Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress___3BI_3BIIIIII I
399 (env, obj, src, jpegSize, dst, 0, 0, width, pitch, height, pf, f lags);
400 }
401
402 JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress ___3BI_3IIIIIIII
403 (JNIEnv *env, jobject obj, jbyteArray src, jint jpegSize, jintArray dst,
404 jint x, jint y, jint width, jint stride, jint height, jint pf, j int flags)
405 {
396 tjhandle handle=0; 406 tjhandle handle=0;
397 » jsize arraySize=0; 407 » jsize arraySize=0, actualStride;
398 unsigned char *jpegBuf=NULL, *dstBuf=NULL; 408 unsigned char *jpegBuf=NULL, *dstBuf=NULL;
399 409
400 gethandle(); 410 gethandle();
401 411
402 if(pf<0 || pf>=org_libjpegturbo_turbojpeg_TJ_NUMPF) 412 if(pf<0 || pf>=org_libjpegturbo_turbojpeg_TJ_NUMPF)
403 _throw("Invalid argument in decompress()"); 413 _throw("Invalid argument in decompress()");
404 if(org_libjpegturbo_turbojpeg_TJ_NUMPF!=TJ_NUMPF) 414 if(org_libjpegturbo_turbojpeg_TJ_NUMPF!=TJ_NUMPF)
405 _throw("Mismatch between Java and C API"); 415 _throw("Mismatch between Java and C API");
406 if(tjPixelSize[pf]!=sizeof(jint)) 416 if(tjPixelSize[pf]!=sizeof(jint))
407 _throw("Pixel format must be 32-bit when decompressing to an int eger buffer."); 417 _throw("Pixel format must be 32-bit when decompressing to an int eger buffer.");
408 418
409 if((*env)->GetArrayLength(env, src)<jpegSize) 419 if((*env)->GetArrayLength(env, src)<jpegSize)
410 _throw("Source buffer is not large enough"); 420 _throw("Source buffer is not large enough");
411 » arraySize=(pitch==0)? width*height:pitch*height; 421 » actualStride=(stride==0)? width:stride;
422 » arraySize=(y+height-1)*actualStride + x+width;
412 if((*env)->GetArrayLength(env, dst)<arraySize) 423 if((*env)->GetArrayLength(env, dst)<arraySize)
413 _throw("Destination buffer is not large enough"); 424 _throw("Destination buffer is not large enough");
414 425
415 bailif0(jpegBuf=(*env)->GetPrimitiveArrayCritical(env, src, 0)); 426 bailif0(jpegBuf=(*env)->GetPrimitiveArrayCritical(env, src, 0));
416 bailif0(dstBuf=(*env)->GetPrimitiveArrayCritical(env, dst, 0)); 427 bailif0(dstBuf=(*env)->GetPrimitiveArrayCritical(env, dst, 0));
417 428
418 » if(tjDecompress2(handle, jpegBuf, (unsigned long)jpegSize, dstBuf, width , 429 » if(tjDecompress2(handle, jpegBuf, (unsigned long)jpegSize,
419 » » pitch*sizeof(jint), height, pf, flags)==-1) 430 » » &dstBuf[(y*actualStride + x)*sizeof(int)], width, stride*sizeof( jint),
431 » » height, pf, flags)==-1)
420 { 432 {
421 (*env)->ReleasePrimitiveArrayCritical(env, dst, dstBuf, 0); 433 (*env)->ReleasePrimitiveArrayCritical(env, dst, dstBuf, 0);
422 (*env)->ReleasePrimitiveArrayCritical(env, src, jpegBuf, 0); 434 (*env)->ReleasePrimitiveArrayCritical(env, src, jpegBuf, 0);
423 dstBuf=jpegBuf=NULL; 435 dstBuf=jpegBuf=NULL;
424 _throw(tjGetErrorStr()); 436 _throw(tjGetErrorStr());
425 } 437 }
426 438
427 bailout: 439 bailout:
428 if(dstBuf) (*env)->ReleasePrimitiveArrayCritical(env, dst, dstBuf, 0); 440 if(dstBuf) (*env)->ReleasePrimitiveArrayCritical(env, dst, dstBuf, 0);
429 if(jpegBuf) (*env)->ReleasePrimitiveArrayCritical(env, src, jpegBuf, 0); 441 if(jpegBuf) (*env)->ReleasePrimitiveArrayCritical(env, src, jpegBuf, 0);
430 return; 442 return;
431 } 443 }
432 444
445 JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress ___3BI_3IIIIII
446 (JNIEnv *env, jobject obj, jbyteArray src, jint jpegSize, jintArray dst,
447 jint width, jint stride, jint height, jint pf, jint flags)
448 {
449 Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress___3BI_3IIIIIII I
450 (env, obj, src, jpegSize, dst, 0, 0, width, stride, height, pf, flags);
451
452 }
453
433 JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress ToYUV 454 JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress ToYUV
434 (JNIEnv *env, jobject obj, jbyteArray src, jint jpegSize, jbyteArray dst , 455 (JNIEnv *env, jobject obj, jbyteArray src, jint jpegSize, jbyteArray dst ,
435 jint flags) 456 jint flags)
436 { 457 {
437 tjhandle handle=0; 458 tjhandle handle=0;
438 unsigned char *jpegBuf=NULL, *dstBuf=NULL; 459 unsigned char *jpegBuf=NULL, *dstBuf=NULL;
439 int jpegSubsamp=-1, jpegWidth=0, jpegHeight=0; 460 int jpegSubsamp=-1, jpegWidth=0, jpegHeight=0;
440 461
441 gethandle(); 462 gethandle();
442 463
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 if(dstSizesi) (*env)->ReleaseIntArrayElements(env, jdstSizes, dstSizesi, 0); 695 if(dstSizesi) (*env)->ReleaseIntArrayElements(env, jdstSizes, dstSizesi, 0);
675 if(t) free(t); 696 if(t) free(t);
676 return jdstSizes; 697 return jdstSizes;
677 } 698 }
678 699
679 JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_destroy 700 JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_destroy
680 (JNIEnv *env, jobject obj) 701 (JNIEnv *env, jobject obj)
681 { 702 {
682 Java_org_libjpegturbo_turbojpeg_TJCompressor_destroy(env, obj); 703 Java_org_libjpegturbo_turbojpeg_TJCompressor_destroy(env, obj);
683 } 704 }
OLDNEW
« 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