From 4f4d87082250f18c5c0bc6193d444b3108726cf1 Mon Sep 17 00:00:00 2001 From: DRC Date: Wed, 29 Jan 2014 19:31:09 +0000 Subject: [PATCH 01/65] Include instructions for building iOS binaries using Xcode 4.6.x and Xcode 5.0. --- BUILDING.txt | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/BUILDING.txt b/BUILDING.txt index e8298a58..adf4eaab 100644 --- a/BUILDING.txt +++ b/BUILDING.txt @@ -333,31 +333,48 @@ examples accordingly. Additional build requirements: - gas-preprocessor.pl (https://github.com/yuvi/gas-preprocessor) should be - installed in your PATH. + gas-preprocessor.pl + (https://sourceforge.net/p/libjpeg-turbo/code/HEAD/tree/gas-preprocessor) + should be installed in your PATH. Set the following shell variables for simplicity: Xcode 3.2.x / iOS 4.3 SDK: - IOS_PLATFORMDIR="/Developer/Platforms/iPhoneOS.platform" - IOS_SYSROOT="$IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS4.3.sdk" - IOS_GCC="$IOS_PLATFORMDIR/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2" + IOS_PLATFORMDIR=/Developer/Platforms/iPhoneOS.platform + IOS_SYSROOT=$IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS4.3.sdk + IOS_GCC=$IOS_PLATFORMDIR/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2 Xcode 4.5.x / iOS 6.0 SDK: - IOS_PLATFORMDIR="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform" - IOS_SYSROOT="$IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS6.0.sdk" - IOS_GCC="$IOS_PLATFORMDIR/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2" + IOS_PLATFORMDIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform + IOS_SYSROOT=$IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS6.0.sdk + IOS_GCC=$IOS_PLATFORMDIR/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2 + + Xcode 4.6.x / iOS 6.1 SDK: + IOS_PLATFORMDIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform + IOS_SYSROOT=$IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS6.1.sdk + IOS_GCC=$IOS_PLATFORMDIR/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2 + + Xcode 5.0.x / iOS 7.0 SDK: + IOS_PLATFORMDIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform + IOS_SYSROOT=$IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS7.0.sdk + IOS_GCC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang ARM v6 only (up to and including iPhone 3G): [NOTE: Requires Xcode 4.4.x or earlier] IOS_CFLAGS="-march=armv6 -mcpu=arm1176jzf-s -mfpu=vfp" ARM v7 only (iPhone 3GS-4S, iPad 1st-3rd Generation): + GCC: IOS_CFLAGS="-march=armv7 -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon" + Clang: + IOS_CFLAGS="-arch armv7 -no-integrated-as" ARM v7s only (iPhone 5, iPad 4th Generation): [NOTE: Requires Xcode 4.5 or later] + GCC IOS_CFLAGS="-march=armv7s -mcpu=swift -mtune=swift -mfpu=neon" + Clang: + IOS_CFLAGS="-arch armv7s -no-integrated-as" Follow the procedure under "Building libjpeg-turbo" above, adding From 857564d0190d95d8152ca622d172c91685dadeae Mon Sep 17 00:00:00 2001 From: DRC Date: Fri, 31 Jan 2014 17:22:15 +0000 Subject: [PATCH 02/65] Some motion JPEG implementations generate "abbreviated JPEG streams" (JPEG images without the default tables included) for some or all of the video frames, in order to save space. When these are encountered, it is generally expected that they will be decompressed using the default Huffman tables, so libjpeg-turbo now does this unless the tables have been explicitly specified by an application. --- ChangeLog.txt | 8 +++ jcparam.c | 113 +----------------------------------------- jdhuff.c | 7 +++ jstdhuff.c | 133 ++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 150 insertions(+), 111 deletions(-) create mode 100644 jstdhuff.c diff --git a/ChangeLog.txt b/ChangeLog.txt index f44e0bb5..80253b52 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -23,6 +23,14 @@ and is out of scope for a codec library. [5] The TurboJPEG API can now be used to compress JPEG images from YUV planar source images. +[6] If an application attempts to decompress a Huffman-coded JPEG image whose +header does not contain Huffman tables, libjpeg-turbo will now insert the +default Huffman tables. In order to save space, many motion JPEG video frames +are encoded without the default Huffman tables, so these frames can now be +successfully decompressed by libjpeg-turbo without additional work on the part +of the application. An application can still override the Huffman tables, for +instance to re-use tables from a previous frame of the same video. + 1.3.1 ===== diff --git a/jcparam.c b/jcparam.c index 2b9a7408..f4e5eec8 100644 --- a/jcparam.c +++ b/jcparam.c @@ -16,6 +16,7 @@ #define JPEG_INTERNALS #include "jinclude.h" #include "jpeglib.h" +#include "jstdhuff.c" /* @@ -165,116 +166,6 @@ jpeg_set_quality (j_compress_ptr cinfo, int quality, boolean force_baseline) } -/* - * Huffman table setup routines - */ - -LOCAL(void) -add_huff_table (j_compress_ptr cinfo, - JHUFF_TBL **htblptr, const UINT8 *bits, const UINT8 *val) -/* Define a Huffman table */ -{ - int nsymbols, len; - - if (*htblptr == NULL) - *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); - - /* Copy the number-of-symbols-of-each-code-length counts */ - MEMCOPY((*htblptr)->bits, bits, SIZEOF((*htblptr)->bits)); - - /* Validate the counts. We do this here mainly so we can copy the right - * number of symbols from the val[] array, without risking marching off - * the end of memory. jchuff.c will do a more thorough test later. - */ - nsymbols = 0; - for (len = 1; len <= 16; len++) - nsymbols += bits[len]; - if (nsymbols < 1 || nsymbols > 256) - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - - MEMCOPY((*htblptr)->huffval, val, nsymbols * SIZEOF(UINT8)); - - /* Initialize sent_table FALSE so table will be written to JPEG file. */ - (*htblptr)->sent_table = FALSE; -} - - -LOCAL(void) -std_huff_tables (j_compress_ptr cinfo) -/* Set up the standard Huffman tables (cf. JPEG standard section K.3) */ -/* IMPORTANT: these are only valid for 8-bit data precision! */ -{ - static const UINT8 bits_dc_luminance[17] = - { /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 }; - static const UINT8 val_dc_luminance[] = - { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; - - static const UINT8 bits_dc_chrominance[17] = - { /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 }; - static const UINT8 val_dc_chrominance[] = - { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; - - static const UINT8 bits_ac_luminance[17] = - { /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d }; - static const UINT8 val_ac_luminance[] = - { 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, - 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, - 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08, - 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, - 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, - 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, - 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, - 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, - 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, - 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, - 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, - 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, - 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, - 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, - 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, - 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, - 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, - 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, - 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, - 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, - 0xf9, 0xfa }; - - static const UINT8 bits_ac_chrominance[17] = - { /* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 }; - static const UINT8 val_ac_chrominance[] = - { 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, - 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, - 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, - 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, - 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34, - 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26, - 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, - 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, - 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, - 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, - 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, - 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, - 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, - 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, - 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, - 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, - 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, - 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, - 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, - 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, - 0xf9, 0xfa }; - - add_huff_table(cinfo, &cinfo->dc_huff_tbl_ptrs[0], - bits_dc_luminance, val_dc_luminance); - add_huff_table(cinfo, &cinfo->ac_huff_tbl_ptrs[0], - bits_ac_luminance, val_ac_luminance); - add_huff_table(cinfo, &cinfo->dc_huff_tbl_ptrs[1], - bits_dc_chrominance, val_dc_chrominance); - add_huff_table(cinfo, &cinfo->ac_huff_tbl_ptrs[1], - bits_ac_chrominance, val_ac_chrominance); -} - - /* * Default parameter setup for compression. * @@ -313,7 +204,7 @@ jpeg_set_defaults (j_compress_ptr cinfo) /* Set up two quantization tables using default quality of 75 */ jpeg_set_quality(cinfo, 75, TRUE); /* Set up two Huffman tables */ - std_huff_tables(cinfo); + std_huff_tables((j_common_ptr) cinfo); /* Initialize default arithmetic coding conditioning */ for (i = 0; i < NUM_ARITH_TBLS; i++) { diff --git a/jdhuff.c b/jdhuff.c index dba5f18a..d21d3992 100644 --- a/jdhuff.c +++ b/jdhuff.c @@ -21,6 +21,7 @@ #include "jpeglib.h" #include "jdhuff.h" /* Declarations shared with jdphuff.c */ #include "jpegcomp.h" +#include "jstdhuff.c" /* @@ -795,6 +796,12 @@ jinit_huff_decoder (j_decompress_ptr cinfo) huff_entropy_ptr entropy; int i; + /* Motion JPEG frames typically do not include the Huffman tables if they + are the default tables. Thus, if the tables are not set by the time + the Huffman decoder is initialized (usually within the body of + jpeg_start_decompress()), we set them to default values. */ + std_huff_tables((j_common_ptr) cinfo); + entropy = (huff_entropy_ptr) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(huff_entropy_decoder)); diff --git a/jstdhuff.c b/jstdhuff.c new file mode 100644 index 00000000..1efc04bf --- /dev/null +++ b/jstdhuff.c @@ -0,0 +1,133 @@ +/* +* jstdhuff.c +* +* This file was part of the Independent JPEG Group's software: +* Copyright (C) 1991-1998, Thomas G. Lane. +* libjpeg-turbo Modifications: +* Copyright (C) 2013, D. R. Commander. +* For conditions of distribution and use, see the accompanying README file. +* +* This file contains routines to set the default Huffman tables, if they are +* not already set. +*/ + +/* + * Huffman table setup routines + */ + +LOCAL(void) +add_huff_table (j_common_ptr cinfo, + JHUFF_TBL **htblptr, const UINT8 *bits, const UINT8 *val) +/* Define a Huffman table */ +{ + int nsymbols, len; + + if (*htblptr == NULL) + *htblptr = jpeg_alloc_huff_table(cinfo); + else + return; + + /* Copy the number-of-symbols-of-each-code-length counts */ + MEMCOPY((*htblptr)->bits, bits, SIZEOF((*htblptr)->bits)); + + /* Validate the counts. We do this here mainly so we can copy the right + * number of symbols from the val[] array, without risking marching off + * the end of memory. jchuff.c will do a more thorough test later. + */ + nsymbols = 0; + for (len = 1; len <= 16; len++) + nsymbols += bits[len]; + if (nsymbols < 1 || nsymbols > 256) + ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); + + MEMCOPY((*htblptr)->huffval, val, nsymbols * SIZEOF(UINT8)); + + /* Initialize sent_table FALSE so table will be written to JPEG file. */ + (*htblptr)->sent_table = FALSE; +} + + +LOCAL(void) +std_huff_tables (j_common_ptr cinfo) +/* Set up the standard Huffman tables (cf. JPEG standard section K.3) */ +/* IMPORTANT: these are only valid for 8-bit data precision! */ +{ + JHUFF_TBL **dc_huff_tbl_ptrs, **ac_huff_tbl_ptrs; + + static const UINT8 bits_dc_luminance[17] = + { /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 }; + static const UINT8 val_dc_luminance[] = + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; + + static const UINT8 bits_dc_chrominance[17] = + { /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 }; + static const UINT8 val_dc_chrominance[] = + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; + + static const UINT8 bits_ac_luminance[17] = + { /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d }; + static const UINT8 val_ac_luminance[] = + { 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, + 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, + 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08, + 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, + 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, + 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, + 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, + 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, + 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, + 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, + 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, + 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, + 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, + 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, + 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, + 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, + 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, + 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, + 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, + 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, + 0xf9, 0xfa }; + + static const UINT8 bits_ac_chrominance[17] = + { /* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 }; + static const UINT8 val_ac_chrominance[] = + { 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, + 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, + 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, + 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, + 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34, + 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26, + 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, + 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, + 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, + 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, + 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, + 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, + 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, + 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, + 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, + 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, + 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, + 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, + 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, + 0xf9, 0xfa }; + + if (cinfo->is_decompressor) { + dc_huff_tbl_ptrs = ((j_decompress_ptr)cinfo)->dc_huff_tbl_ptrs; + ac_huff_tbl_ptrs = ((j_decompress_ptr)cinfo)->ac_huff_tbl_ptrs; + } else { + dc_huff_tbl_ptrs = ((j_compress_ptr)cinfo)->dc_huff_tbl_ptrs; + ac_huff_tbl_ptrs = ((j_compress_ptr)cinfo)->ac_huff_tbl_ptrs; + } + + add_huff_table(cinfo, &dc_huff_tbl_ptrs[0], bits_dc_luminance, + val_dc_luminance); + add_huff_table(cinfo, &ac_huff_tbl_ptrs[0], bits_ac_luminance, + val_ac_luminance); + add_huff_table(cinfo, &dc_huff_tbl_ptrs[1], bits_dc_chrominance, + val_dc_chrominance); + add_huff_table(cinfo, &ac_huff_tbl_ptrs[1], bits_ac_chrominance, + val_ac_chrominance); +} From 671fea53d1822be745244a93e4081ff0d42c8126 Mon Sep 17 00:00:00 2001 From: DRC Date: Sat, 1 Feb 2014 06:17:31 +0000 Subject: [PATCH 03/65] Remove trailing spaces --- jstdhuff.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jstdhuff.c b/jstdhuff.c index 1efc04bf..7fec6caf 100644 --- a/jstdhuff.c +++ b/jstdhuff.c @@ -9,7 +9,7 @@ * * This file contains routines to set the default Huffman tables, if they are * not already set. -*/ +*/ /* * Huffman table setup routines @@ -58,12 +58,12 @@ std_huff_tables (j_common_ptr cinfo) { /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 }; static const UINT8 val_dc_luminance[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; - + static const UINT8 bits_dc_chrominance[17] = { /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 }; static const UINT8 val_dc_chrominance[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; - + static const UINT8 bits_ac_luminance[17] = { /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d }; static const UINT8 val_ac_luminance[] = @@ -88,7 +88,7 @@ std_huff_tables (j_common_ptr cinfo) 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa }; - + static const UINT8 bits_ac_chrominance[17] = { /* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 }; static const UINT8 val_ac_chrominance[] = From abb6a513fa633f203ec364a4f1f2caa15db30ad3 Mon Sep 17 00:00:00 2001 From: DRC Date: Wed, 5 Feb 2014 07:39:38 +0000 Subject: [PATCH 04/65] Formatting tweaks --- simd/jsimd_arm_neon.S | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/simd/jsimd_arm_neon.S b/simd/jsimd_arm_neon.S index 9962b8a1..ac6c8607 100644 --- a/simd/jsimd_arm_neon.S +++ b/simd/jsimd_arm_neon.S @@ -1,5 +1,5 @@ /* - * ARM NEON optimizations for libjpeg-turbo + * ARMv7 NEON optimizations for libjpeg-turbo * * Copyright (C) 2009-2011 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. @@ -35,6 +35,7 @@ #define RESPECT_STRICT_ALIGNMENT 1 + /*****************************************************************************/ /* Supplementary macro for setting function attributes */ @@ -62,6 +63,7 @@ _\fname: vtrn.32 \x1, \x3 .endm + #define CENTERJSAMPLE 128 /*****************************************************************************/ @@ -670,6 +672,7 @@ asm_function jsimd_idct_islow_neon .unreq ROW7R .endfunc + /*****************************************************************************/ /* @@ -894,6 +897,7 @@ asm_function jsimd_idct_ifast_neon .unreq TMP4 .endfunc + /*****************************************************************************/ /* @@ -1108,6 +1112,7 @@ asm_function jsimd_idct_4x4_neon .purgem idct_helper + /*****************************************************************************/ /* @@ -1262,6 +1267,7 @@ asm_function jsimd_idct_2x2_neon .purgem idct_helper + /*****************************************************************************/ /* @@ -1561,6 +1567,7 @@ generate_jsimd_ycc_rgb_convert_neon extxrgb, 32, 1, 2, 3 .purgem do_load .purgem do_store + /*****************************************************************************/ /* @@ -1871,6 +1878,7 @@ generate_jsimd_rgb_ycc_convert_neon extxrgb, 32, 1, 2, 3 .purgem do_load .purgem do_store + /*****************************************************************************/ /* @@ -1934,6 +1942,7 @@ asm_function jsimd_convsamp_neon .unreq TMP4 .endfunc + /*****************************************************************************/ /* @@ -2057,6 +2066,7 @@ asm_function jsimd_fdct_ifast_neon .unreq TMP .endfunc + /*****************************************************************************/ /* @@ -2158,6 +2168,7 @@ asm_function jsimd_quantize_neon .unreq LOOP_COUNT .endfunc + /*****************************************************************************/ /* From 1bb1e691865a3534327c26f91fda0f0bf05a3a51 Mon Sep 17 00:00:00 2001 From: DRC Date: Wed, 5 Feb 2014 08:15:44 +0000 Subject: [PATCH 05/65] First pass at ARMv8 64-bit NEON SIMD support --- acinclude.m4 | 33 + configure.ac | 17 + simd/Makefile.am | 6 + simd/jsimd_arm_neon_64.S | 1832 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 1888 insertions(+) create mode 100644 simd/jsimd_arm_neon_64.S diff --git a/acinclude.m4 b/acinclude.m4 index 80311369..5f87a050 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -210,3 +210,36 @@ AC_DEFUN([AC_CHECK_COMPATIBLE_MIPSEL_ASSEMBLER_IFELSE],[ $2 fi ]) + +AC_DEFUN([AC_CHECK_COMPATIBLE_ARM64_ASSEMBLER_IFELSE],[ + ac_good_gnu_arm_assembler=no + ac_save_CC="$CC" + ac_save_CFLAGS="$CFLAGS" + CFLAGS="$CCASFLAGS -x assembler-with-cpp" + CC="$CCAS" + AC_COMPILE_IFELSE([[ + .text + movi v0.16b, #100]], ac_good_gnu_arm_assembler=yes) + + ac_use_gas_preprocessor=no + if test "x$ac_good_gnu_arm_assembler" = "xno" ; then + CC="gas-preprocessor.pl $CCAS" + AC_COMPILE_IFELSE([[ + .text + movi v0.16b, #100]], ac_use_gas_preprocessor=yes) + fi + CFLAGS="$ac_save_CFLAGS" + CC="$ac_save_CC" + + if test "x$ac_use_gas_preprocessor" = "xyes" ; then + CCAS="gas-preprocessor.pl $CCAS" + AC_SUBST([CCAS]) + ac_good_gnu_arm_assembler=yes + fi + + if test "x$ac_good_gnu_arm_assembler" = "xyes" ; then + $1 + else + $2 + fi +]) diff --git a/configure.ac b/configure.ac index c327db58..6234641f 100644 --- a/configure.ac +++ b/configure.ac @@ -430,7 +430,23 @@ if test "x${with_simd}" != "xno"; then AC_MSG_ERROR([SIMD support can't be enabled.]) else AC_MSG_WARN([SIMD support can't be enabled. Performance will suffer.]) + fi fi + ;; + aarch64*) + AC_MSG_RESULT([yes (arm64)]) + AC_MSG_CHECKING([if the assembler is GNU-compatible and can be used]) + AC_CHECK_COMPATIBLE_ARM64_ASSEMBLER_IFELSE( + [AC_MSG_RESULT([yes]) + simd_arch=aarch64], + [AC_MSG_RESULT([no]) + with_simd=no]) + if test "x${with_simd}" = "xno"; then + if test "x${require_simd}" = "xyes"; then + AC_MSG_ERROR([SIMD support can't be enabled.]) + else + AC_MSG_WARN([SIMD support can't be enabled. Performance will suffer.]) + fi fi ;; mipsel*) @@ -472,6 +488,7 @@ AM_CONDITIONAL([WITH_SSE_FLOAT_DCT], [test "x$simd_arch" = "xx86_64" -o "x$simd_ AM_CONDITIONAL([SIMD_I386], [test "x$simd_arch" = "xi386"]) AM_CONDITIONAL([SIMD_X86_64], [test "x$simd_arch" = "xx86_64"]) AM_CONDITIONAL([SIMD_ARM], [test "x$simd_arch" = "xarm"]) +AM_CONDITIONAL([SIMD_ARM_64], [test "x$simd_arch" = "xaarch64"]) AM_CONDITIONAL([SIMD_MIPSEL], [test "x$simd_arch" = "xmipsel"]) AM_CONDITIONAL([X86_64], [test "x$host_cpu" = "xx86_64" -o "x$host_cpu" = "xamd64"]) AM_CONDITIONAL([WITH_TURBOJPEG], [test "x$with_turbojpeg" != "xno"]) diff --git a/simd/Makefile.am b/simd/Makefile.am index 7b59298d..2504e761 100644 --- a/simd/Makefile.am +++ b/simd/Makefile.am @@ -58,6 +58,12 @@ libsimd_la_SOURCES = jsimd_arm.c jsimd_arm_neon.S endif +if SIMD_ARM_64 + +libsimd_la_SOURCES = jsimd_arm.c jsimd_arm_neon_64.S + +endif + if SIMD_MIPSEL libsimd_la_SOURCES = jsimd_mips.c jsimd_mips_dspr2_asm.h jsimd_mips_dspr2.S diff --git a/simd/jsimd_arm_neon_64.S b/simd/jsimd_arm_neon_64.S new file mode 100644 index 00000000..2d9e95ef --- /dev/null +++ b/simd/jsimd_arm_neon_64.S @@ -0,0 +1,1832 @@ +/* + * ARMv8 NEON optimizations for libjpeg-turbo + * + * Copyright (C) 2009-2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Author: Siarhei Siamashka + * Copyright (C) 2013, Linaro Limited + * Author: Ragesh Radhakrishnan + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + */ + +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits /* mark stack as non-executable */ +#endif + +.text +.arch armv8-a+fp+simd + + +#define RESPECT_STRICT_ALIGNMENT 1 + +#define RTSM_SQSHRN_SIM_ISSUE + + +/*****************************************************************************/ + +/* Supplementary macro for setting function attributes */ +.macro asm_function fname +#ifdef __APPLE__ + .func _\fname + .globl _\fname +_\fname: +#else + .func \fname + .global \fname +#ifdef __ELF__ + .hidden \fname + .type \fname, %function +#endif +\fname: +#endif +.endm + +/* Transpose elements of single 128 bit registers */ +.macro transpose_single x0,x1,xi,xilen,literal + ins \xi\xilen[0], \x0\xilen[0] + ins \x1\xilen[0], \x0\xilen[1] + trn1 \x0\literal, \x0\literal, \x1\literal + trn2 \x1\literal, \xi\literal, \x1\literal +.endm + +/* Transpose elements of 2 differnet registers */ +.macro transpose x0,x1,xi,xilen,literal + mov \xi\xilen, \x0\xilen + trn1 \x0\literal, \x0\literal, \x1\literal + trn2 \x1\literal, \xi\literal, \x1\literal +.endm + +/* Transpose a block of 4x4 coefficients in four 64-bit registers */ +.macro transpose_4x4_32 x0,x0len x1,x1len x2,x2len x3,x3len,xi,xilen + mov \xi\xilen, \x0\xilen + trn1 \x0\x0len, \x0\x0len, \x2\x2len + trn2 \x2\x2len, \xi\x0len, \x2\x2len + mov \xi\xilen, \x1\xilen + trn1 \x1\x1len, \x1\x1len, \x3\x3len + trn2 \x3\x3len, \xi\x1len, \x3\x3len +.endm + +.macro transpose_4x4_16 x0,x0len x1,x1len, x2,x2len, x3,x3len,xi,xilen + mov \xi\xilen, \x0\xilen + trn1 \x0\x0len, \x0\x0len, \x1\x1len + trn2 \x1\x2len, \xi\x0len, \x1\x2len + mov \xi\xilen, \x2\xilen + trn1 \x2\x2len, \x2\x2len, \x3\x3len + trn2 \x3\x2len, \xi\x1len, \x3\x3len +.endm + +.macro transpose_4x4 x0, x1, x2, x3,x5 + transpose_4x4_16 \x0,.4h, \x1,.4h, \x2,.4h,\x3,.4h,\x5,.16b + transpose_4x4_32 \x0,.2s, \x1,.2s, \x2,.2s,\x3,.2s,\x5,.16b +.endm + + +#define CENTERJSAMPLE 128 + +/*****************************************************************************/ + +/* + * Perform dequantization and inverse DCT on one block of coefficients. + * + * GLOBAL(void) + * jsimd_idct_islow_neon (void * dct_table, JCOEFPTR coef_block, + * JSAMPARRAY output_buf, JDIMENSION output_col) + */ + +#define FIX_0_298631336 (2446) +#define FIX_0_390180644 (3196) +#define FIX_0_541196100 (4433) +#define FIX_0_765366865 (6270) +#define FIX_0_899976223 (7373) +#define FIX_1_175875602 (9633) +#define FIX_1_501321110 (12299) +#define FIX_1_847759065 (15137) +#define FIX_1_961570560 (16069) +#define FIX_2_053119869 (16819) +#define FIX_2_562915447 (20995) +#define FIX_3_072711026 (25172) + +#define FIX_1_175875602_MINUS_1_961570560 (FIX_1_175875602 - FIX_1_961570560) +#define FIX_1_175875602_MINUS_0_390180644 (FIX_1_175875602 - FIX_0_390180644) +#define FIX_0_541196100_MINUS_1_847759065 (FIX_0_541196100 - FIX_1_847759065) +#define FIX_3_072711026_MINUS_2_562915447 (FIX_3_072711026 - FIX_2_562915447) +#define FIX_0_298631336_MINUS_0_899976223 (FIX_0_298631336 - FIX_0_899976223) +#define FIX_1_501321110_MINUS_0_899976223 (FIX_1_501321110 - FIX_0_899976223) +#define FIX_2_053119869_MINUS_2_562915447 (FIX_2_053119869 - FIX_2_562915447) +#define FIX_0_541196100_PLUS_0_765366865 (FIX_0_541196100 + FIX_0_765366865) + +/* + * Reference SIMD-friendly 1-D ISLOW iDCT C implementation. + * Uses some ideas from the comments in 'simd/jiss2int-64.asm' + */ +#define REF_1D_IDCT(xrow0, xrow1, xrow2, xrow3, xrow4, xrow5, xrow6, xrow7) \ +{ \ + DCTELEM row0, row1, row2, row3, row4, row5, row6, row7; \ + INT32 q1, q2, q3, q4, q5, q6, q7; \ + INT32 tmp11_plus_tmp2, tmp11_minus_tmp2; \ + \ + /* 1-D iDCT input data */ \ + row0 = xrow0; \ + row1 = xrow1; \ + row2 = xrow2; \ + row3 = xrow3; \ + row4 = xrow4; \ + row5 = xrow5; \ + row6 = xrow6; \ + row7 = xrow7; \ + \ + q5 = row7 + row3; \ + q4 = row5 + row1; \ + q6 = MULTIPLY(q5, FIX_1_175875602_MINUS_1_961570560) + \ + MULTIPLY(q4, FIX_1_175875602); \ + q7 = MULTIPLY(q5, FIX_1_175875602) + \ + MULTIPLY(q4, FIX_1_175875602_MINUS_0_390180644); \ + q2 = MULTIPLY(row2, FIX_0_541196100) + \ + MULTIPLY(row6, FIX_0_541196100_MINUS_1_847759065); \ + q4 = q6; \ + q3 = ((INT32) row0 - (INT32) row4) << 13; \ + q6 += MULTIPLY(row5, -FIX_2_562915447) + \ + MULTIPLY(row3, FIX_3_072711026_MINUS_2_562915447); \ + /* now we can use q1 (reloadable constants have been used up) */ \ + q1 = q3 + q2; \ + q4 += MULTIPLY(row7, FIX_0_298631336_MINUS_0_899976223) + \ + MULTIPLY(row1, -FIX_0_899976223); \ + q5 = q7; \ + q1 = q1 + q6; \ + q7 += MULTIPLY(row7, -FIX_0_899976223) + \ + MULTIPLY(row1, FIX_1_501321110_MINUS_0_899976223); \ + \ + /* (tmp11 + tmp2) has been calculated (out_row1 before descale) */ \ + tmp11_plus_tmp2 = q1; \ + row1 = 0; \ + \ + q1 = q1 - q6; \ + q5 += MULTIPLY(row5, FIX_2_053119869_MINUS_2_562915447) + \ + MULTIPLY(row3, -FIX_2_562915447); \ + q1 = q1 - q6; \ + q6 = MULTIPLY(row2, FIX_0_541196100_PLUS_0_765366865) + \ + MULTIPLY(row6, FIX_0_541196100); \ + q3 = q3 - q2; \ + \ + /* (tmp11 - tmp2) has been calculated (out_row6 before descale) */ \ + tmp11_minus_tmp2 = q1; \ + \ + q1 = ((INT32) row0 + (INT32) row4) << 13; \ + q2 = q1 + q6; \ + q1 = q1 - q6; \ + \ + /* pick up the results */ \ + tmp0 = q4; \ + tmp1 = q5; \ + tmp2 = (tmp11_plus_tmp2 - tmp11_minus_tmp2) / 2; \ + tmp3 = q7; \ + tmp10 = q2; \ + tmp11 = (tmp11_plus_tmp2 + tmp11_minus_tmp2) / 2; \ + tmp12 = q3; \ + tmp13 = q1; \ +} + +#define XFIX_0_899976223 v0.4h[0] +#define XFIX_0_541196100 v0.4h[1] +#define XFIX_2_562915447 v0.4h[2] +#define XFIX_0_298631336_MINUS_0_899976223 v0.4h[3] +#define XFIX_1_501321110_MINUS_0_899976223 v1.4h[0] +#define XFIX_2_053119869_MINUS_2_562915447 v1.4h[1] +#define XFIX_0_541196100_PLUS_0_765366865 v1.4h[2] +#define XFIX_1_175875602 v1.4h[3] +#define XFIX_1_175875602_MINUS_0_390180644 v2.4h[0] +#define XFIX_0_541196100_MINUS_1_847759065 v2.4h[1] +#define XFIX_3_072711026_MINUS_2_562915447 v2.4h[2] +#define XFIX_1_175875602_MINUS_1_961570560 v2.4h[3] + +.balign 16 +jsimd_idct_islow_neon_consts: + .short FIX_0_899976223 /* d0[0] */ + .short FIX_0_541196100 /* d0[1] */ + .short FIX_2_562915447 /* d0[2] */ + .short FIX_0_298631336_MINUS_0_899976223 /* d0[3] */ + .short FIX_1_501321110_MINUS_0_899976223 /* d1[0] */ + .short FIX_2_053119869_MINUS_2_562915447 /* d1[1] */ + .short FIX_0_541196100_PLUS_0_765366865 /* d1[2] */ + .short FIX_1_175875602 /* d1[3] */ + /* reloadable constants */ + .short FIX_1_175875602_MINUS_0_390180644 /* d2[0] */ + .short FIX_0_541196100_MINUS_1_847759065 /* d2[1] */ + .short FIX_3_072711026_MINUS_2_562915447 /* d2[2] */ + .short FIX_1_175875602_MINUS_1_961570560 /* d2[3] */ + +asm_function jsimd_idct_islow_neon + + DCT_TABLE .req x0 + COEF_BLOCK .req x1 + OUTPUT_BUF .req x2 + OUTPUT_COL .req x3 + TMP1 .req x0 + TMP2 .req x1 + TMP3 .req x2 + TMP4 .req x15 + + ROW0L .req v16 + ROW0R .req v17 + ROW1L .req v18 + ROW1R .req v19 + ROW2L .req v20 + ROW2R .req v21 + ROW3L .req v22 + ROW3R .req v23 + ROW4L .req v24 + ROW4R .req v25 + ROW5L .req v26 + ROW5R .req v27 + ROW6L .req v28 + ROW6R .req v29 + ROW7L .req v30 + ROW7R .req v31 + + adr x15, jsimd_idct_islow_neon_consts + ld1 {v16.4h, v17.4h, v18.4h, v19.4h}, [COEF_BLOCK], 32 + ld1 {v0.4h, v1.4h, v2.4h, v3.4h}, [DCT_TABLE], 32 + ld1 {v20.4h, v21.4h, v22.4h, v23.4h}, [COEF_BLOCK], 32 + mul v16.4h, v16.4h, v0.4h + mul v17.4h, v17.4h, v1.4h + ins v16.2d[1], v17.2d[0] /* 128 bit q8 */ + ld1 {v4.4h, v5.4h, v6.4h, v7.4h}, [DCT_TABLE], 32 + mul v18.4h, v18.4h, v2.4h + mul v19.4h, v19.4h, v3.4h + ins v18.2d[1], v19.2d[0] /* 128 bit q9 */ + ld1 {v24.4h, v25.4h, v26.4h, v27.4h}, [COEF_BLOCK], 32 + mul v20.4h, v20.4h, v4.4h + mul v21.4h, v21.4h, v5.4h + ins v20.2d[1], v21.2d[0] /* 128 bit q10 */ + ld1 {v0.4h, v1.4h, v2.4h, v3.4h}, [DCT_TABLE], 32 + mul v22.4h, v22.4h, v6.4h + mul v23.4h, v23.4h, v7.4h + ins v22.2d[1], v23.2d[0] /* 128 bit q11 */ + ld1 {v28.4h, v29.4h, v30.4h, v31.4h}, [COEF_BLOCK], 32 + mul v24.4h, v24.4h, v0.4h + mul v25.4h, v25.4h, v1.4h + ins v24.2d[1], v25.2d[0] /* 128 bit q12 */ + ld1 {v4.4h, v5.4h, v6.4h, v7.4h}, [DCT_TABLE], 32 + mul v28.4h, v28.4h, v4.4h + mul v29.4h, v29.4h, v5.4h + ins v28.2d[1], v29.2d[0] /* 128 bit q14 */ + mul v26.4h, v26.4h, v2.4h + mul v27.4h, v27.4h, v3.4h + ins v26.2d[1], v27.2d[0] /* 128 bit q13 */ + ld1 {v0.4h, v1.4h, v2.4h, v3.4h}, [x15] /* load constants */ + add x15, x15, #16 + mul v30.4h, v30.4h, v6.4h + mul v31.4h, v31.4h, v7.4h + ins v30.2d[1], v31.2d[0] /* 128 bit q15 */ + sub sp, sp, #32 + st1 {v8.4h-v11.4h}, [sp] /* save NEON registers */ + sub sp, sp, #32 + st1 {v12.4h-v15.4h}, [sp] + /* 1-D IDCT, pass 1, left 4x8 half */ + add v4.4h, ROW7L.4h, ROW3L.4h + add v5.4h, ROW5L.4h, ROW1L.4h + smull v12.4s, v4.4h, XFIX_1_175875602_MINUS_1_961570560 + smlal v12.4s, v5.4h, XFIX_1_175875602 + smull v14.4s, v4.4h, XFIX_1_175875602 + /* Check for the zero coefficients in the right 4x8 half */ + /* push {x4, x5} */ + stp x4, x5, [sp, -16]! + mov x5, #0 + smlal v14.4s, v5.4h, XFIX_1_175875602_MINUS_0_390180644 + ssubl v6.4s, ROW0L.4h, ROW4L.4h + ldr x4, [COEF_BLOCK, #(-96 + 2 * (4 + 1 * 8))] + smull v4.4s, ROW2L.4h, XFIX_0_541196100 + smlal v4.4s, ROW6L.4h, XFIX_0_541196100_MINUS_1_847759065 + orr x0, x4, x5 + mov v8.16b, v12.16b + smlsl v12.4s, ROW5L.4h, XFIX_2_562915447 + ldr x4, [COEF_BLOCK, #(-96 + 2 * (4 + 2 * 8))] + smlal v12.4s, ROW3L.4h, XFIX_3_072711026_MINUS_2_562915447 + shl v6.4s, v6.4s, #13 + orr x0, x0, x4 + smlsl v8.4s, ROW1L.4h, XFIX_0_899976223 + orr x0, x0 , x5 + add v2.4s, v6.4s, v4.4s + ldr x4, [COEF_BLOCK, #(-96 + 2 * (4 + 3 * 8))] + mov v10.16b, v14.16b + add v2.4s, v2.4s, v12.4s + orr x0, x0, x4 + smlsl v14.4s, ROW7L.4h, XFIX_0_899976223 + orr x0, x0, x5 + smlal v14.4s, ROW1L.4h, XFIX_1_501321110_MINUS_0_899976223 + rshrn ROW1L.4h, v2.4s, #11 + ldr x4, [COEF_BLOCK, #(-96 + 2 * (4 + 4 * 8))] + sub v2.4s, v2.4s, v12.4s + smlal v10.4s, ROW5L.4h, XFIX_2_053119869_MINUS_2_562915447 + orr x0, x0, x4 + smlsl v10.4s, ROW3L.4h, XFIX_2_562915447 + orr x0, x0, x5 + sub v2.4s, v2.4s, v12.4s + smull v12.4s, ROW2L.4h, XFIX_0_541196100_PLUS_0_765366865 + ldr x4, [COEF_BLOCK, #(-96 + 2 * (4 + 5 * 8))] + smlal v12.4s, ROW6L.4h, XFIX_0_541196100 + sub v6.4s, v6.4s, v4.4s + orr x0, x0, x4 + rshrn ROW6L.4h, v2.4s, #11 + orr x0, x0, x5 + add v2.4s, v6.4s, v10.4s + ldr x4, [COEF_BLOCK, #(-96 + 2 * (4 + 6 * 8))] + sub v6.4s, v6.4s, v10.4s + saddl v10.4s, ROW0L.4h, ROW4L.4h + orr x0, x0, x4 + rshrn ROW2L.4h, v2.4s, #11 + orr x0, x0, x5 + rshrn ROW5L.4h, v6.4s, #11 + ldr x4, [COEF_BLOCK, #(-96 + 2 * (4 + 7 * 8))] + shl v10.4s, v10.4s, #13 + smlal v8.4s, ROW7L.4h, XFIX_0_298631336_MINUS_0_899976223 + orr x0, x0, x4 + add v4.4s, v10.4s, v12.4s + orr x0, x0, x5 + sub v2.4s, v10.4s, v12.4s + add v12.4s, v4.4s, v14.4s + ldr x4, [COEF_BLOCK, #(-96 + 2 * (4 + 0 * 8))] + sub v4.4s, v4.4s, v14.4s + add v10.4s, v2.4s, v8.4s + orr x0, x4, x5 + sub v6.4s, v2.4s, v8.4s + /* pop {x4, x5} */ + ldp x4, x5, [sp], 16 + rshrn ROW7L.4h, v4.4s, #11 + rshrn ROW3L.4h, v10.4s, #11 + rshrn ROW0L.4h, v12.4s, #11 + rshrn ROW4L.4h, v6.4s, #11 + cmp x0, #0 /* orrs instruction removed */ + + beq 3f /* Go to do some special handling for the sparse right 4x8 half */ + + /* 1-D IDCT, pass 1, right 4x8 half */ + ld1 {v2.4h}, [x15] /* reload constants */ + add v10.4h, ROW7R.4h, ROW3R.4h + add v8.4h, ROW5R.4h, ROW1R.4h + /* Transpose ROW6L <-> ROW7L (v3 available free register) */ + transpose ROW6L, ROW7L, v3, .16b, .4h + smull v12.4s, v10.4h, XFIX_1_175875602_MINUS_1_961570560 + smlal v12.4s, v8.4h, XFIX_1_175875602 + /* Transpose ROW2L <-> ROW3L (v3 available free register) */ + transpose ROW2L, ROW3L, v3, .16b, .4h + smull v14.4s, v10.4h, XFIX_1_175875602 + smlal v14.4s, v8.4h, XFIX_1_175875602_MINUS_0_390180644 + /* Transpose ROW0L <-> ROW1L (v3 available free register) */ + transpose ROW0L, ROW1L, v3, .16b, .4h + ssubl v6.4s, ROW0R.4h, ROW4R.4h + smull v4.4s, ROW2R.4h, XFIX_0_541196100 + smlal v4.4s, ROW6R.4h, XFIX_0_541196100_MINUS_1_847759065 + /* Transpose ROW4L <-> ROW5L (v3 available free register) */ + transpose ROW4L, ROW5L, v3, .16b, .4h + mov v8.16b, v12.16b + smlsl v12.4s, ROW5R.4h, XFIX_2_562915447 + smlal v12.4s, ROW3R.4h, XFIX_3_072711026_MINUS_2_562915447 + /* Transpose ROW1L <-> ROW3L (v3 available free register) */ + transpose ROW1L, ROW3L, v3, .16b, .2s + shl v6.4s, v6.4s, #13 + smlsl v8.4s, ROW1R.4h, XFIX_0_899976223 + /* Transpose ROW4L <-> ROW6L (v3 available free register) */ + transpose ROW4L, ROW6L, v3, .16b, .2s + add v2.4s, v6.4s, v4.4s + mov v10.16b, v14.16b + add v2.4s, v2.4s, v12.4s + /* Transpose ROW0L <-> ROW2L (v3 available free register) */ + transpose ROW0L, ROW2L, v3, .16b, .2s + smlsl v14.4s, ROW7R.4h, XFIX_0_899976223 + smlal v14.4s, ROW1R.4h, XFIX_1_501321110_MINUS_0_899976223 + rshrn ROW1R.4h, v2.4s, #11 + /* Transpose ROW5L <-> ROW7L (v3 available free register) */ + transpose ROW5L, ROW7L, v3, .16b, .2s + sub v2.4s, v2.4s, v12.4s + smlal v10.4s, ROW5R.4h, XFIX_2_053119869_MINUS_2_562915447 + smlsl v10.4s, ROW3R.4h, XFIX_2_562915447 + sub v2.4s, v2.4s, v12.4s + smull v12.4s, ROW2R.4h, XFIX_0_541196100_PLUS_0_765366865 + smlal v12.4s, ROW6R.4h, XFIX_0_541196100 + sub v6.4s, v6.4s, v4.4s + rshrn ROW6R.4h, v2.4s, #11 + add v2.4s, v6.4s, v10.4s + sub v6.4s, v6.4s, v10.4s + saddl v10.4s, ROW0R.4h, ROW4R.4h + rshrn ROW2R.4h, v2.4s, #11 + rshrn ROW5R.4h, v6.4s, #11 + shl v10.4s, v10.4s, #13 + smlal v8.4s, ROW7R.4h, XFIX_0_298631336_MINUS_0_899976223 + add v4.4s, v10.4s, v12.4s + sub v2.4s, v10.4s, v12.4s + add v12.4s, v4.4s, v14.4s + sub v4.4s, v4.4s, v14.4s + add v10.4s, v2.4s, v8.4s + sub v12.4s, v2.4s, v8.4s + rshrn ROW7R.4h, v4.4s, #11 + rshrn ROW3R.4h, v10.4s, #11 + rshrn ROW0R.4h, v12.4s, #11 + rshrn ROW4R.4h, v6.4s, #11 + /* Transpose right 4x8 half */ + transpose ROW6R, ROW7R, v3, .16b, .4h + transpose ROW2R, ROW3R, v3, .16b, .4h + transpose ROW0R, ROW1R, v3, .16b, .4h + transpose ROW4R, ROW5R, v3, .16b, .4h + transpose ROW1R, ROW3R, v3, .16b, .2s + transpose ROW4R, ROW6R, v3, .16b, .2s + transpose ROW0R, ROW2R, v3, .16b, .2s + transpose ROW5R, ROW7R, v3, .16b, .2s + +1: /* 1-D IDCT, pass 2 (normal variant), left 4x8 half */ + ld1 {v2.4h}, [x15] /* reload constants */ + smull v12.4S, ROW1R.4h, XFIX_1_175875602 /* ROW5L.4h <-> ROW1R.4h */ + smlal v12.4s, ROW1L.4h, XFIX_1_175875602 + smlal v12.4s, ROW3R.4h, XFIX_1_175875602_MINUS_1_961570560 /* ROW7L.4h <-> ROW3R.4h */ + smlal v12.4s, ROW3L.4h, XFIX_1_175875602_MINUS_1_961570560 + smull v14.4s, ROW3R.4h, XFIX_1_175875602 /* ROW7L.4h <-> ROW3R.4h */ + smlal v14.4s, ROW3L.4h, XFIX_1_175875602 + smlal v14.4s, ROW1R.4h, XFIX_1_175875602_MINUS_0_390180644 /* ROW5L.4h <-> ROW1R.4h */ + smlal v14.4s, ROW1L.4h, XFIX_1_175875602_MINUS_0_390180644 + ssubl v6.4s, ROW0L.4h, ROW0R.4h /* ROW4L.4h <-> ROW0R.4h */ + smull v4.4s, ROW2L.4h, XFIX_0_541196100 + smlal v4.4s, ROW2R.4h, XFIX_0_541196100_MINUS_1_847759065 /* ROW6L.4h <-> ROW2R.4h */ + mov v8.16b, v12.16b + smlsl v12.4s, ROW1R.4h, XFIX_2_562915447 /* ROW5L.4h <-> ROW1R.4h */ + smlal v12.4s, ROW3L.4h, XFIX_3_072711026_MINUS_2_562915447 + shl v6.4s, v6.4s, #13 + smlsl v8.4s, ROW1L.4h, XFIX_0_899976223 + add v2.4s, v6.4s, v4.4s + mov v10.16b, v14.16b + add v2.4s, v2.4s, v12.4s + smlsl v14.4s, ROW3R.4h, XFIX_0_899976223 /* ROW7L.4h <-> ROW3R.4h */ + smlal v14.4s, ROW1L.4h, XFIX_1_501321110_MINUS_0_899976223 + shrn ROW1L.4h, v2.4s, #16 + sub v2.4s, v2.4s, v12.4s + smlal v10.4s, ROW1R.4h, XFIX_2_053119869_MINUS_2_562915447 /* ROW5L.4h <-> ROW1R.4h */ + smlsl v10.4s, ROW3L.4h, XFIX_2_562915447 + sub v2.4s, v2.4s, v12.4s + smull v12.4s, ROW2L.4h, XFIX_0_541196100_PLUS_0_765366865 + smlal v12.4s, ROW2R.4h, XFIX_0_541196100 /* ROW6L.4h <-> ROW2R.4h */ + sub v6.4s, v6.4s, v4.4s + shrn ROW2R.4h, v2.4s, #16 /* ROW6L.4h <-> ROW2R.4h */ + add v2.4s, v6.4s, v10.4s + sub v6.4s, v6.4s, v10.4s + saddl v10.4s, ROW0L.4h, ROW0R.4h /* ROW4L.4h <-> ROW0R.4h */ + shrn ROW2L.4h, v2.4s, #16 + shrn ROW1R.4h, v6.4s, #16 /* ROW5L.4h <-> ROW1R.4h */ + shl v10.4s, v10.4s, #13 + smlal v8.4s, ROW3R.4h, XFIX_0_298631336_MINUS_0_899976223 /* ROW7L.4h <-> ROW3R.4h */ + add v4.4s, v10.4s, v12.4s + sub v2.4s, v10.4s, v12.4s + add v12.4s, v4.4s, v14.4s + sub v4.4s, v4.4s, v14.4s + add v10.4s, v2.4s, v8.4s + sub v6.4s, v2.4s, v8.4s + shrn ROW3R.4h, v4.4s, #16 /* ROW7L.4h <-> ROW3R.4h */ + shrn ROW3L.4h, v10.4s, #16 + shrn ROW0L.4h, v12.4s, #16 + shrn ROW0R.4h, v6.4s, #16 /* ROW4L.4h <-> ROW0R.4h */ + /* 1-D IDCT, pass 2, right 4x8 half */ + ld1 {v2.4h}, [x15] /* reload constants */ + smull v12.4s, ROW5R.4h, XFIX_1_175875602 + smlal v12.4s, ROW5L.4h, XFIX_1_175875602 /* ROW5L.4h <-> ROW1R.4h */ + smlal v12.4s, ROW7R.4h, XFIX_1_175875602_MINUS_1_961570560 + smlal v12.4s, ROW7L.4h, XFIX_1_175875602_MINUS_1_961570560 /* ROW7L.4h <-> ROW3R.4h */ + smull v14.4s, ROW7R.4h, XFIX_1_175875602 + smlal v14.4s, ROW7L.4h, XFIX_1_175875602 /* ROW7L.4h <-> ROW3R.4h */ + smlal v14.4s, ROW5R.4h, XFIX_1_175875602_MINUS_0_390180644 + smlal v14.4s, ROW5L.4h, XFIX_1_175875602_MINUS_0_390180644 /* ROW5L.4h <-> ROW1R.4h */ + ssubl v6.4s, ROW4L.4h, ROW4R.4h /* ROW4L.4h <-> ROW0R.4h */ + smull v4.4s, ROW6L.4h, XFIX_0_541196100 /* ROW6L.4h <-> ROW2R.4h */ + smlal v4.4s, ROW6R.4h, XFIX_0_541196100_MINUS_1_847759065 + mov v8.16b, v12.16b + smlsl v12.4s, ROW5R.4h, XFIX_2_562915447 + smlal v12.4s, ROW7L.4h, XFIX_3_072711026_MINUS_2_562915447 /* ROW7L.4h <-> ROW3R.4h */ + shl v6.4s, v6.4s, #13 + smlsl v8.4s, ROW5L.4h, XFIX_0_899976223 /* ROW5L.4h <-> ROW1R.4h */ + add v2.4s, v6.4s, v4.4s + mov v10.16b, v14.16b + add v2.4s, v2.4s, v12.4s + smlsl v14.4s, ROW7R.4h, XFIX_0_899976223 + smlal v14.4s, ROW5L.4h, XFIX_1_501321110_MINUS_0_899976223 /* ROW5L.4h <-> ROW1R.4h */ + shrn ROW5L.4h, v2.4s, #16 /* ROW5L.4h <-> ROW1R.4h */ + sub v2.4s, v2.4s, v12.4s + smlal v10.4s, ROW5R.4h, XFIX_2_053119869_MINUS_2_562915447 + smlsl v10.4s, ROW7L.4h, XFIX_2_562915447 /* ROW7L.4h <-> ROW3R.4h */ + sub v2.4s, v2.4s, v12.4s + smull v12.4s, ROW6L.4h, XFIX_0_541196100_PLUS_0_765366865 /* ROW6L.4h <-> ROW2R.4h */ + smlal v12.4s, ROW6R.4h, XFIX_0_541196100 + sub v6.4s, v6.4s, v4.4s + shrn ROW6R.4h, v2.4s, #16 + add v2.4s, v6.4s, v10.4s + sub v6.4s, v6.4s, v10.4s + saddl v10.4s, ROW4L.4h, ROW4R.4h /* ROW4L.4h <-> ROW0R.4h */ + shrn ROW6L.4h, v2.4s, #16 /* ROW6L.4h <-> ROW2R.4h */ + shrn ROW5R.4h, v6.4s, #16 + shl v10.4s, v10.4s, #13 + smlal v8.4s, ROW7R.4h, XFIX_0_298631336_MINUS_0_899976223 + add v4.4s, v10.4s, v12.4s + sub v2.4s, v10.4s, v12.4s + add v12.4s, v4.4s, v14.4s + sub v4.4s, v4.4s, v14.4s + add v10.4s, v2.4s, v8.4s + sub v6.4s, v2.4s, v8.4s + shrn ROW7R.4h, v4.4s, #16 + shrn ROW7L.4h, v10.4s, #16 /* ROW7L.4h <-> ROW3R.4h */ + shrn ROW4L.4h, v12.4s, #16 /* ROW4L.4h <-> ROW0R.4h */ + shrn ROW4R.4h, v6.4s, #16 + +2: /* Descale to 8-bit and range limit */ + ins v16.2d[1], v17.2d[0] + ins v18.2d[1], v19.2d[0] + ins v20.2d[1], v21.2d[0] + ins v22.2d[1], v23.2d[0] +#ifdef RTSM_SQSHRN_SIM_ISSUE + sqrshrn v16.8b, v16.8h, #2 + sqrshrn2 v16.16b, v18.8h, #2 + sqrshrn v18.8b, v20.8h, #2 + sqrshrn2 v18.16b, v22.8h, #2 +#else + sqrshrn v16.4h, v16.4s, #2 + sqrshrn2 v16.8h, v18.4s, #2 + sqrshrn v18.4h, v20.4s, #2 + sqrshrn2 v18.8h, v22.4s, #2 +#endif + /* vpop {v8.4h-d15.4h} */ /* restore NEON registers */ + + ld1 {v12.4h-v15.4h}, [sp], 32 + ld1 {v8.4h-v11.4h}, [sp], 32 + ins v24.2d[1], v25.2d[0] +#ifdef RTSM_SQSHRN_SIM_ISSUE + + sqrshrn v20.8b, v24.8h, #2 +#else + + sqrshrn v20.4h, v24.4s, #2 +#endif + /* Transpose the final 8-bit samples and do signed->unsigned conversion */ + /* trn1 v16.8h, v16.8h, v18.8h */ + transpose v16, v18, v3, .16b, .8h + ins v26.2d[1], v27.2d[0] + ins v28.2d[1], v29.2d[0] + ins v30.2d[1], v31.2d[0] +#ifdef RTSM_SQSHRN_SIM_ISSUE + sqrshrn2 v20.16b, v26.8h, #2 + sqrshrn v22.8b, v28.8h, #2 +#else + sqrshrn2 v20.8h, v26.4s, #2 + sqrshrn v22.4h, v28.4s, #2 +#endif + movi v0.16b, #(CENTERJSAMPLE) +#ifdef RTSM_SQSHRN_SIM_ISSUE + sqrshrn2 v22.16b, v30.8h, #2 +#else + sqrshrn2 v22.8h, v30.4s, #2 +#endif + transpose_single v16, v17, v3, .2d, .8b + transpose_single v18, v19, v3, .2d, .8b + add v16.8b, v16.8b, v0.8b + add v17.8b, v17.8b, v0.8b + add v18.8b, v18.8b, v0.8b + add v19.8b, v19.8b, v0.8b + transpose v20, v22, v3, .16b, .8h + /* Store results to the output buffer */ + ldp TMP1, TMP2, [OUTPUT_BUF], 16 + add TMP1, TMP1, OUTPUT_COL + add TMP2, TMP2, OUTPUT_COL + st1 {v16.8b}, [TMP1] + transpose_single v20, v21, v3, .2d, .8b + st1 {v17.8b}, [TMP2] + ldp TMP1, TMP2, [OUTPUT_BUF], 16 + add TMP1, TMP1, OUTPUT_COL + add TMP2, TMP2, OUTPUT_COL + st1 {v18.8b}, [TMP1] + add v20.8b, v20.8b, v0.8b + add v21.8b, v21.8b, v0.8b + st1 {v19.8b}, [TMP2] + ldp TMP1, TMP2, [OUTPUT_BUF], 16 + ldp TMP3, TMP4, [OUTPUT_BUF] + add TMP1, TMP1, OUTPUT_COL + add TMP2, TMP2, OUTPUT_COL + add TMP3, TMP3, OUTPUT_COL + add TMP4, TMP4, OUTPUT_COL + transpose_single v22, v23, v3, .2d, .8b + st1 {v20.8b}, [TMP1] + add v22.8b, v22.8b, v0.8b + add v23.8b, v23.8b, v0.8b + st1 {v21.8b}, [TMP2] + st1 {v22.8b}, [TMP3] + st1 {v23.8b}, [TMP4] + blr x30 + +3: /* Left 4x8 half is done, right 4x8 half contains mostly zeros */ + + /* Transpose left 4x8 half */ + transpose ROW6L, ROW7L, v3, .16b, .4h + transpose ROW2L, ROW3L, v3, .16b, .4h + transpose ROW0L, ROW1L, v3, .16b, .4h + transpose ROW4L, ROW5L, v3, .16b, .4h + shl ROW0R.4h, ROW0R.4h, #2 /* PASS1_BITS */ + transpose ROW1L, ROW3L, v3, .16b, .2s + transpose ROW4L, ROW6L, v3, .16b, .2s + transpose ROW0L, ROW2L, v3, .16b, .2s + transpose ROW5L, ROW7L, v3, .16b, .2s + cmp x0, #0 + beq 4f /* Right 4x8 half has all zeros, go to 'sparse' second pass */ + + /* Only row 0 is non-zero for the right 4x8 half */ + dup ROW1R.4h, ROW0R.4h[1] + dup ROW2R.4h, ROW0R.4h[2] + dup ROW3R.4h, ROW0R.4h[3] + dup ROW4R.4h, ROW0R.4h[0] + dup ROW5R.4h, ROW0R.4h[1] + dup ROW6R.4h, ROW0R.4h[2] + dup ROW7R.4h, ROW0R.4h[3] + dup ROW0R.4h, ROW0R.4h[0] + b 1b /* Go to 'normal' second pass */ + +4: /* 1-D IDCT, pass 2 (sparse variant with zero rows 4-7), left 4x8 half */ + ld1 {v2.4h}, [x15] /* reload constants */ + smull v12.4s, ROW1L.4h, XFIX_1_175875602 + smlal v12.4s, ROW3L.4h, XFIX_1_175875602_MINUS_1_961570560 + smull v14.4s, ROW3L.4h, XFIX_1_175875602 + smlal v14.4s, ROW1L.4h, XFIX_1_175875602_MINUS_0_390180644 + smull v4.4s, ROW2L.4h, XFIX_0_541196100 + sshll v6.4s, ROW0L.4h, #13 + mov v8.16b, v12.16b + smlal v12.4s, ROW3L.4h, XFIX_3_072711026_MINUS_2_562915447 + smlsl v8.4s, ROW1L.4h, XFIX_0_899976223 + add v2.4s, v6.4s, v4.4s + mov v10.16b, v14.16b + smlal v14.4s, ROW1L.4h, XFIX_1_501321110_MINUS_0_899976223 + add v2.4s, v2.4s, v12.4s + add v12.4s, v12.4s, v12.4s + smlsl v10.4s, ROW3L.4h, XFIX_2_562915447 + shrn ROW1L.4h, v2.4s, #16 + sub v2.4s, v2.4s, v12.4s + smull v12.4s, ROW2L.4h, XFIX_0_541196100_PLUS_0_765366865 + sub v6.4s, v6.4s, v4.4s + shrn ROW2R.4h, v2.4s, #16 /* ROW6L.4h <-> ROW2R.4h */ + add v2.4s, v6.4s, v10.4s + sub v6.4s, v6.4s, v10.4s + sshll v10.4s, ROW0L.4h, #13 + shrn ROW2L.4h, v2.4s, #16 + shrn ROW1R.4h, v6.4s, #16 /* ROW5L.4h <-> ROW1R.4h */ + add v4.4s, v10.4s, v12.4s + sub v2.4s, v10.4s, v12.4s + add v12.4s, v4.4s, v14.4s + sub v4.4s, v4.4s, v14.4s + add v10.4s, v2.4s, v8.4s + sub v6.4s, v2.4s, v8.4s + shrn ROW3R.4h, v4.4s, #16 /* ROW7L.4h <-> ROW3R.4h */ + shrn ROW3L.4h, v10.4s, #16 + shrn ROW0L.4h, v12.4s, #16 + shrn ROW0R.4h, v6.4s, #16 /* ROW4L.4h <-> ROW0R.4h */ + /* 1-D IDCT, pass 2 (sparse variant with zero rows 4-7), right 4x8 half */ + ld1 {v2.4h}, [x15] /* reload constants */ + smull v12.4s, ROW5L.4h, XFIX_1_175875602 + smlal v12.4s, ROW7L.4h, XFIX_1_175875602_MINUS_1_961570560 + smull v14.4s, ROW7L.4h, XFIX_1_175875602 + smlal v14.4s, ROW5L.4h, XFIX_1_175875602_MINUS_0_390180644 + smull v4.4s, ROW6L.4h, XFIX_0_541196100 + sshll v6.4s, ROW4L.4h, #13 + mov v8.16b, v12.16b + smlal v12.4s, ROW7L.4h, XFIX_3_072711026_MINUS_2_562915447 + smlsl v8.4s, ROW5L.4h, XFIX_0_899976223 + add v2.4s, v6.4s, v4.4s + mov v10.16b, v14.16b + smlal v14.4s, ROW5L.4h, XFIX_1_501321110_MINUS_0_899976223 + add v2.4s, v2.4s, v12.4s + add v12.4s, v12.4s, v12.4s + smlsl v10.4s, ROW7L.4h, XFIX_2_562915447 + shrn ROW5L.4h, v2.4s, #16 /* ROW5L.4h <-> ROW1R.4h */ + sub v2.4s, v2.4s, v12.4s + smull v12.4s, ROW6L.4h, XFIX_0_541196100_PLUS_0_765366865 + sub v6.4s, v6.4s, v4.4s + shrn ROW6R.4h, v2.4s, #16 + add v2.4s, v6.4s, v10.4s + sub v6.4s, v6.4s, v10.4s + sshll v10.4s, ROW4L.4h, #13 + shrn ROW6L.4h, v2.4s, #16 /* ROW6L.4h <-> ROW2R.4h */ + shrn ROW5R.4h, v6.4s, #16 + add v4.4s, v10.4s, v12.4s + sub v2.4s, v10.4s, v12.4s + add v12.4s, v4.4s, v14.4s + sub v4.4s, v4.4s, v14.4s + add v10.4s, v2.4s, v8.4s + sub v6.4s, v2.4s, v8.4s + shrn ROW7R.4h, v4.4s, #16 + shrn ROW7L.4h, v10.4s, #16 /* ROW7L.4h <-> ROW3R.4h */ + shrn ROW4L.4h, v12.4s, #16 /* ROW4L.4h <-> ROW0R.4h */ + shrn ROW4R.4h, v6.4s, #16 + b 2b /* Go to epilogue */ + + .unreq DCT_TABLE + .unreq COEF_BLOCK + .unreq OUTPUT_BUF + .unreq OUTPUT_COL + .unreq TMP1 + .unreq TMP2 + .unreq TMP3 + .unreq TMP4 + + .unreq ROW0L + .unreq ROW0R + .unreq ROW1L + .unreq ROW1R + .unreq ROW2L + .unreq ROW2R + .unreq ROW3L + .unreq ROW3R + .unreq ROW4L + .unreq ROW4R + .unreq ROW5L + .unreq ROW5R + .unreq ROW6L + .unreq ROW6R + .unreq ROW7L + .unreq ROW7R +.endfunc + + +/*****************************************************************************/ + +/* + * jsimd_idct_ifast_neon + * + * This function contains a fast, not so accurate integer implementation of + * the inverse DCT (Discrete Cosine Transform). It uses the same calculations + * and produces exactly the same output as IJG's original 'jpeg_idct_ifast' + * function from jidctfst.c + * + * Normally 1-D AAN DCT needs 5 multiplications and 29 additions. + * But in ARM NEON case some extra additions are required because VQDMULH + * instruction can't handle the constants larger than 1. So the expressions + * like "x * 1.082392200" have to be converted to "x * 0.082392200 + x", + * which introduces an extra addition. Overall, there are 6 extra additions + * per 1-D IDCT pass, totalling to 5 VQDMULH and 35 VADD/VSUB instructions. + */ + +#define XFIX_1_082392200 v0.4h[0] +#define XFIX_1_414213562 v0.4h[1] +#define XFIX_1_847759065 v0.4h[2] +#define XFIX_2_613125930 v0.4h[3] + +.balign 16 +jsimd_idct_ifast_neon_consts: + .short (277 * 128 - 256 * 128) /* XFIX_1_082392200 */ + .short (362 * 128 - 256 * 128) /* XFIX_1_414213562 */ + .short (473 * 128 - 256 * 128) /* XFIX_1_847759065 */ + .short (669 * 128 - 512 * 128) /* XFIX_2_613125930 */ + +asm_function jsimd_idct_ifast_neon + + DCT_TABLE .req x0 + COEF_BLOCK .req x1 + OUTPUT_BUF .req x2 + OUTPUT_COL .req x3 + TMP1 .req x0 + TMP2 .req x1 + TMP3 .req x2 + TMP4 .req x15 + + /* Load and dequantize coefficients into NEON registers + * with the following allocation: + * 0 1 2 3 | 4 5 6 7 + * ---------+-------- + * 0 | d16 | d17 ( v8.8h ) + * 1 | d18 | d19 ( v9.8h ) + * 2 | d20 | d21 ( v10.8h ) + * 3 | d22 | d23 ( v11.8h ) + * 4 | d24 | d25 ( v12.8h ) + * 5 | d26 | d27 ( v13.8h ) + * 6 | d28 | d29 ( v14.8h ) + * 7 | d30 | d31 ( v15.8h ) + */ + adr x15, jsimd_idct_ifast_neon_consts + ld1 {v8.8h, v9.8h}, [COEF_BLOCK], 32 + ld1 {v0.8h, v1.8h}, [DCT_TABLE], 32 + ld1 {v10.8h, v11.8h}, [COEF_BLOCK], 32 + mul v8.8h, v8.8h, v0.8h + ld1 {v2.8h, v3.8h}, [DCT_TABLE], 32 + mul v9.8h, v9.8h, v1.8h + ld1 {v12.8h, v13.8h}, [COEF_BLOCK], 32 + mul v10.8h, v10.8h, v2.8h + ld1 {v0.8h, v1.8h}, [DCT_TABLE], 32 + mul v11.8h, v11.8h, v3.8h + ld1 {v14.8h, v15.8h}, [COEF_BLOCK], 32 + mul v12.8h, v12.8h, v0.8h + ld1 {v2.8h, v3.8h}, [DCT_TABLE], 32 + mul v14.8h, v14.8h, v2.8h + mul v13.8h, v13.8h, v1.8h + ld1 {v0.4h}, [x15] /* load constants */ + mul v15.8h, v15.8h, v3.8h + + /* vpush {v4.8h-v6.8h} */ /* save NEON registers */ + sub sp, sp, #32 + st1 {v4.8h-v5.8h}, [sp] /* save NEON registers */ + sub sp, sp, #16 + st1 {v6.8h}, [sp] + /* 1-D IDCT, pass 1 */ + sub v2.8h, v10.8h, v14.8h + add v14.8h, v10.8h, v14.8h + sub v1.8h, v11.8h, v13.8h + add v13.8h, v11.8h, v13.8h + sub v5.8h, v9.8h, v15.8h + add v15.8h, v9.8h, v15.8h + sqdmulh v4.8h, v2.8h, XFIX_1_414213562 + sqdmulh v6.8h, v1.8h, XFIX_2_613125930 + add v3.8h, v1.8h, v1.8h + sub v1.8h, v5.8h, v1.8h + add v10.8h, v2.8h, v4.8h + sqdmulh v4.8h, v1.8h, XFIX_1_847759065 + sub v2.8h, v15.8h, v13.8h + add v3.8h, v3.8h, v6.8h + sqdmulh v6.8h, v2.8h, XFIX_1_414213562 + add v1.8h, v1.8h, v4.8h + sqdmulh v4.8h, v5.8h, XFIX_1_082392200 + sub v10.8h, v10.8h, v14.8h + add v2.8h, v2.8h, v6.8h + sub v6.8h, v8.8h, v12.8h + add v12.8h, v8.8h, v12.8h + add v9.8h, v5.8h, v4.8h + add v5.8h, v6.8h, v10.8h + sub v10.8h, v6.8h, v10.8h + add v6.8h, v15.8h, v13.8h + add v8.8h, v12.8h, v14.8h + sub v3.8h, v6.8h, v3.8h + sub v12.8h, v12.8h, v14.8h + sub v3.8h, v3.8h, v1.8h + sub v1.8h, v9.8h, v1.8h + add v2.8h, v3.8h, v2.8h + sub v15.8h, v8.8h, v6.8h + add v1.8h, v1.8h, v2.8h + add v8.8h, v8.8h, v6.8h + add v14.8h, v5.8h, v3.8h + sub v9.8h, v5.8h, v3.8h + sub v13.8h, v10.8h, v2.8h + add v10.8h, v10.8h, v2.8h + /* Transpose q8-q9 */ + mov v18.16b, v8.16b + trn1 v8.8h, v8.8h, v9.8h + trn2 v9.8h, v18.8h, v9.8h + sub v11.8h, v12.8h, v1.8h + /* Transpose q14-q15 */ + mov v18.16b, v14.16b + trn1 v14.8h, v14.8h, v15.8h + trn2 v15.8h, v18.8h, v15.8h + add v12.8h, v12.8h, v1.8h + /* Transpose q10-q11 */ + mov v18.16b, v10.16b + trn1 v10.8h, v10.8h, v11.8h + trn2 v11.8h, v18.8h, v11.8h + /* Transpose q12-q13 */ + mov v18.16b, v12.16b + trn1 v12.8h, v12.8h, v13.8h + trn2 v13.8h, v18.8h, v13.8h + /* Transpose q9-q11 */ + mov v18.16b, v9.16b + trn1 v9.4s, v9.4s, v11.4s + trn2 v11.4s, v18.4s, v11.4s + /* Transpose q12-q14 */ + mov v18.16b, v12.16b + trn1 v12.4s, v12.4s, v14.4s + trn2 v14.4s, v18.4s, v14.4s + /* Transpose q8-q10 */ + mov v18.16b, v8.16b + trn1 v8.4s, v8.4s, v10.4s + trn2 v10.4s, v18.4s, v10.4s + /* Transpose q13-q15 */ + mov v18.16b, v13.16b + trn1 v13.4s, v13.4s, v15.4s + trn2 v15.4s, v18.4s, v15.4s + /* vswp v14.4h, v10-MSB.4h */ + umov x10, v14.d[0] + ins v14.2d[0], v10.2d[1] + ins v10.2d[1], x10 + /* vswp v13.4h, v9MSB.4h */ + + umov x10, v13.d[0] + ins v13.2d[0], v9.2d[1] + ins v9.2d[1], x10 + /* 1-D IDCT, pass 2 */ + sub v2.8h, v10.8h, v14.8h + /* vswp v15.4h, v11MSB.4h */ + umov x10, v15.d[0] + ins v15.2d[0], v11.2d[1] + ins v11.2d[1], x10 + add v14.8h, v10.8h, v14.8h + /* vswp v12.4h, v8-MSB.4h */ + umov x10, v12.d[0] + ins v12.2d[0], v8.2d[1] + ins v8.2d[1], x10 + sub v1.8h, v11.8h, v13.8h + add v13.8h, v11.8h, v13.8h + sub v5.8h, v9.8h, v15.8h + add v15.8h, v9.8h, v15.8h + sqdmulh v4.8h, v2.8h, XFIX_1_414213562 + sqdmulh v6.8h, v1.8h, XFIX_2_613125930 + add v3.8h, v1.8h, v1.8h + sub v1.8h, v5.8h, v1.8h + add v10.8h, v2.8h, v4.8h + sqdmulh v4.8h, v1.8h, XFIX_1_847759065 + sub v2.8h, v15.8h, v13.8h + add v3.8h, v3.8h, v6.8h + sqdmulh v6.8h, v2.8h, XFIX_1_414213562 + add v1.8h, v1.8h, v4.8h + sqdmulh v4.8h, v5.8h, XFIX_1_082392200 + sub v10.8h, v10.8h, v14.8h + add v2.8h, v2.8h, v6.8h + sub v6.8h, v8.8h, v12.8h + add v12.8h, v8.8h, v12.8h + add v9.8h, v5.8h, v4.8h + add v5.8h, v6.8h, v10.8h + sub v10.8h, v6.8h, v10.8h + add v6.8h, v15.8h, v13.8h + add v8.8h, v12.8h, v14.8h + sub v3.8h, v6.8h, v3.8h + sub v12.8h, v12.8h, v14.8h + sub v3.8h, v3.8h, v1.8h + sub v1.8h, v9.8h, v1.8h + add v2.8h, v3.8h, v2.8h + sub v15.8h, v8.8h, v6.8h + add v1.8h, v1.8h, v2.8h + add v8.8h, v8.8h, v6.8h + add v14.8h, v5.8h, v3.8h + sub v9.8h, v5.8h, v3.8h + sub v13.8h, v10.8h, v2.8h + /* vpop {v4.8h-v7.4h} */ /* restore NEON registers...not available */ + ld1 {v6.8h}, [sp], 16 + ld1 {v4.8h-v5.8h}, [sp], 32 + add v10.8h, v10.8h, v2.8h + sub v11.8h, v12.8h, v1.8h + add v12.8h, v12.8h, v1.8h + /* Descale to 8-bit and range limit */ + movi v0.16b, #0x80 +#ifdef RTSM_SQSHRN_SIM_ISSUE + sqshrn v8.8b, v8.8h, #5 + sqshrn2 v8.16b, v9.8h, #5 + sqshrn v9.8b, v10.8h, #5 + sqshrn2 v9.16b, v11.8h, #5 + sqshrn v10.8b, v12.8h, #5 + sqshrn2 v10.16b, v13.8h, #5 + sqshrn v11.8b, v14.8h, #5 + sqshrn2 v11.16b, v15.8h, #5 +#else + sqshrn v8.4h, v8.4s, #5 + sqshrn2 v8.8h, v9.4s, #5 + sqshrn v9.4h, v10.4s, #5 + sqshrn2 v9.8h, v11.4s, #5 + sqshrn v10.4h, v12.4s, #5 + sqshrn2 v10.8h, v13.4s, #5 + sqshrn v11.4h, v14.4s, #5 + sqshrn2 v11.8h, v15.4s, #5 +#endif + add v8.16b, v8.16b, v0.16b + add v9.16b, v9.16b, v0.16b + add v10.16b, v10.16b, v0.16b + add v11.16b, v11.16b, v0.16b + /* Transpose the final 8-bit samples */ + /* Transpose q8-q9 */ + mov v18.16b, v8.16b + trn1 v8.8h, v8.8h, v9.8h + trn2 v9.8h, v18.8h, v9.8h + /* Transpose q10-q11 */ + mov v18.16b, v10.16b + trn1 v10.8h, v10.8h, v11.8h + trn2 v11.8h, v18.8h, v11.8h + /* Transpose q8-q10 */ + mov v18.16b, v8.16b + trn1 v8.4s, v8.4s, v10.4s + trn2 v10.4s, v18.4s, v10.4s + /* Transpose q9-q11 */ + mov v18.16b, v9.16b + trn1 v9.4s, v9.4s, v11.4s + trn2 v11.4s, v18.4s, v11.4s + /* make copy */ + ins v17.2d[0], v8.2d[1] + /* Transpose d16-d17-msb */ + mov v18.16b, v8.16b + trn1 v8.8b, v8.8b, v17.8b + trn2 v17.8b, v18.8b, v17.8b + /* make copy */ + ins v19.2d[0], v9.2d[1] + mov v18.16b, v9.16b + trn1 v9.8b, v9.8b, v19.8b + trn2 v19.8b, v18.8b, v19.8b + /* Store results to the output buffer */ + ldp TMP1, TMP2, [OUTPUT_BUF], 16 + add TMP1, TMP1, OUTPUT_COL + add TMP2, TMP2, OUTPUT_COL + st1 {v8.8b}, [TMP1] + st1 {v17.8b}, [TMP2] + ldp TMP1, TMP2, [OUTPUT_BUF], 16 + add TMP1, TMP1, OUTPUT_COL + add TMP2, TMP2, OUTPUT_COL + st1 {v9.8b}, [TMP1] + /* make copy */ + ins v21.2d[0], v10.2d[1] + mov v18.16b, v10.16b + trn1 v10.8b, v10.8b, v21.8b + trn2 v21.8b, v18.8b, v21.8b + st1 {v19.8b}, [TMP2] + ldp TMP1, TMP2, [OUTPUT_BUF], 16 + ldp TMP3, TMP4, [OUTPUT_BUF] + add TMP1, TMP1, OUTPUT_COL + add TMP2, TMP2, OUTPUT_COL + add TMP3, TMP3, OUTPUT_COL + add TMP4, TMP4, OUTPUT_COL + st1 {v10.8b}, [TMP1] + /* make copy */ + ins v23.2d[0], v11.2d[1] + mov v18.16b, v11.16b + trn1 v11.8b, v11.8b, v23.8b + trn2 v23.8b, v18.8b, v23.8b + st1 {v21.8b}, [TMP2] + st1 {v11.8b}, [TMP3] + st1 {v23.8b}, [TMP4] + blr x30 + + .unreq DCT_TABLE + .unreq COEF_BLOCK + .unreq OUTPUT_BUF + .unreq OUTPUT_COL + .unreq TMP1 + .unreq TMP2 + .unreq TMP3 + .unreq TMP4 +.endfunc + + +/*****************************************************************************/ + +/* + * jsimd_idct_4x4_neon + * + * This function contains inverse-DCT code for getting reduced-size + * 4x4 pixels output from an 8x8 DCT block. It uses the same calculations + * and produces exactly the same output as IJG's original 'jpeg_idct_4x4' + * function from jpeg-6b (jidctred.c). + * + * NOTE: jpeg-8 has an improved implementation of 4x4 inverse-DCT, which + * requires much less arithmetic operations and hence should be faster. + * The primary purpose of this particular NEON optimized function is + * bit exact compatibility with jpeg-6b. + * + * TODO: a bit better instructions scheduling can be achieved by expanding + * idct_helper/transpose_4x4 macros and reordering instructions, + * but readability will suffer somewhat. + */ + +#define CONST_BITS 13 + +#define FIX_0_211164243 (1730) /* FIX(0.211164243) */ +#define FIX_0_509795579 (4176) /* FIX(0.509795579) */ +#define FIX_0_601344887 (4926) /* FIX(0.601344887) */ +#define FIX_0_720959822 (5906) /* FIX(0.720959822) */ +#define FIX_0_765366865 (6270) /* FIX(0.765366865) */ +#define FIX_0_850430095 (6967) /* FIX(0.850430095) */ +#define FIX_0_899976223 (7373) /* FIX(0.899976223) */ +#define FIX_1_061594337 (8697) /* FIX(1.061594337) */ +#define FIX_1_272758580 (10426) /* FIX(1.272758580) */ +#define FIX_1_451774981 (11893) /* FIX(1.451774981) */ +#define FIX_1_847759065 (15137) /* FIX(1.847759065) */ +#define FIX_2_172734803 (17799) /* FIX(2.172734803) */ +#define FIX_2_562915447 (20995) /* FIX(2.562915447) */ +#define FIX_3_624509785 (29692) /* FIX(3.624509785) */ + +.balign 16 +jsimd_idct_4x4_neon_consts: + .short FIX_1_847759065 /* v0.4h[0] */ + .short -FIX_0_765366865 /* v0.4h[1] */ + .short -FIX_0_211164243 /* v0.4h[2] */ + .short FIX_1_451774981 /* v0.4h[3] */ + .short -FIX_2_172734803 /* d1[0] */ + .short FIX_1_061594337 /* d1[1] */ + .short -FIX_0_509795579 /* d1[2] */ + .short -FIX_0_601344887 /* d1[3] */ + .short FIX_0_899976223 /* v2.4h[0] */ + .short FIX_2_562915447 /* v2.4h[1] */ + .short 1 << (CONST_BITS+1) /* v2.4h[2] */ + .short 0 /* v2.4h[3] */ + +.macro idct_helper x4, x6, x8, x10, x12, x14, x16, shift, y26, y27, y28, y29 + smull v28.4s, \x4, v2.4h[2] + smlal v28.4s, \x8, v0.4h[0] + smlal v28.4s, \x14, v0.4h[1] + + smull v26.4s, \x16, v1.4h[2] + smlal v26.4s, \x12, v1.4h[3] + smlal v26.4s, \x10, v2.4h[0] + smlal v26.4s, \x6, v2.4h[1] + + smull v30.4s, \x4, v2.4h[2] + smlsl v30.4s, \x8, v0.4h[0] + smlsl v30.4s, \x14, v0.4h[1] + + smull v24.4s, \x16, v0.4h[2] + smlal v24.4s, \x12, v0.4h[3] + smlal v24.4s, \x10, v1.4h[0] + smlal v24.4s, \x6, v1.4h[1] + + add v20.4s, v28.4s, v26.4s + sub v28.4s, v28.4s, v26.4s + +.if \shift > 16 + srshr v20.4s, v20.4s, #\shift + srshr v28.4s, v28.4s, #\shift + xtn \y26, v20.4s + xtn \y29, v28.4s +.else + rshrn \y26, v20.4s, #\shift + rshrn \y29, v28.4s, #\shift +.endif + + add v20.4s, v30.4s, v24.4s + sub v30.4s, v30.4s, v24.4s + +.if \shift > 16 + srshr v20.4s, v20.4s, #\shift + srshr v30.4s, v30.4s, #\shift + xtn \y27, v20.4s + xtn \y28, v30.4s +.else + rshrn \y27, v20.4s, #\shift + rshrn \y28, v30.4s, #\shift +.endif + +.endm + +asm_function jsimd_idct_4x4_neon + + DCT_TABLE .req x0 + COEF_BLOCK .req x1 + OUTPUT_BUF .req x2 + OUTPUT_COL .req x3 + TMP1 .req x0 + TMP2 .req x1 + TMP3 .req x2 + TMP4 .req x15 + + /* vpush {v8.4h-v15.4h} */ + sub sp, sp, #32 + st1 {v8.4h-v11.4h}, [sp] /* save NEON registers */ + sub sp, sp, #32 + st1 {v12.4h-v15.4h}, [sp] + + /* Load constants (v3.4h is just used for padding) */ + adr TMP4, jsimd_idct_4x4_neon_consts + ld1 {v0.4h, v1.4h, v2.4h, v3.4h}, [TMP4] + + /* Load all COEF_BLOCK into NEON registers with the following allocation: + * 0 1 2 3 | 4 5 6 7 + * ---------+-------- + * 0 | v4.4h | v5.4h + * 1 | v6.4h | v7.4h + * 2 | v8.4h | v9.4h + * 3 | v10.4h | v11.4h + * 4 | - | - + * 5 | v12.4h | v13.4h + * 6 | v14.4h | v15.4h + * 7 | v16.4h | v17.4h + */ + ld1 {v4.4h, v5.4h, v6.4h, v7.4h}, [COEF_BLOCK], 32 + ld1 {v8.4h, v9.4h, v10.4h, v11.4h}, [COEF_BLOCK], 32 + add COEF_BLOCK, COEF_BLOCK, #16 + ld1 {v12.4h, v13.4h, v14.4h, v15.4h}, [COEF_BLOCK], 32 + ld1 {v16.4h, v17.4h}, [COEF_BLOCK], 16 + /* dequantize */ + ld1 {v18.4h, v19.4h, v20.4h, v21.4h}, [DCT_TABLE], 32 + mul v4.4h, v4.4h, v18.4h + mul v5.4h, v5.4h, v19.4h + ins v4.2d[1], v5.2d[0] /* 128 bit q4 */ + ld1 {v22.4h, v23.4h, v24.4h, v25.4h}, [DCT_TABLE], 32 + mul v6.4h, v6.4h, v20.4h + mul v7.4h, v7.4h, v21.4h + ins v6.2d[1], v7.2d[0] /* 128 bit q6 */ + mul v8.4h, v8.4h, v22.4h + mul v9.4h, v9.4h, v23.4h + ins v8.2d[1], v9.2d[0] /* 128 bit q8 */ + add DCT_TABLE, DCT_TABLE, #16 + ld1 {v26.4h, v27.4h, v28.4h, v29.4h}, [DCT_TABLE], 32 + mul v10.4h, v10.4h, v24.4h + mul v11.4h, v11.4h, v25.4h + ins v10.2d[1], v11.2d[0] /* 128 bit q10 */ + mul v12.4h, v12.4h, v26.4h + mul v13.4h, v13.4h, v27.4h + ins v12.2d[1], v13.2d[0] /* 128 bit q12 */ + ld1 {v30.8h}, [DCT_TABLE], 16 + mul v14.4h, v14.4h, v28.4h + mul v15.4h, v15.4h, v29.4h + ins v14.2d[1], v15.2d[0] /* 128 bit q14 */ + mul v16.4h, v16.4h, v30.4h + mul v17.4h, v17.4h, v31.4h + ins v16.2d[1], v17.2d[0] /* 128 bit q16 */ + + /* Pass 1 */ + idct_helper v4.4h, v6.4h, v8.4h, v10.4h, v12.4h, v14.4h, v16.4h, 12, v4.4h, v6.4h, v8.4h, v10.4h + transpose_4x4 v4, v6, v8, v10, v3 + ins v10.2d[1], v11.2d[0] + idct_helper v5.4h, v7.4h, v9.4h, v11.4h, v13.4h, v15.4h, v17.4h, 12, v5.4h, v7.4h, v9.4h, v11.4h + transpose_4x4 v5, v7, v9, v11, v3 + ins v10.2d[1], v11.2d[0] + /* Pass 2 */ + idct_helper v4.4h, v6.4h, v8.4h, v10.4h, v7.4h, v9.4h, v11.4h, 19, v26.4h, v27.4h, v28.4h, v29.4h + transpose_4x4 v26, v27, v28, v29, v3 + + /* Range limit */ + movi v30.8h, #0x80 + ins v26.2d[1], v27.2d[0] + ins v28.2d[1], v29.2d[0] + add v26.8h, v26.8h, v30.8h + add v28.8h, v28.8h, v30.8h + sqxtun v26.8b, v26.8h + sqxtun v27.8b, v28.8h + + /* Store results to the output buffer */ + ldp TMP1, TMP2, [OUTPUT_BUF], 16 + ldp TMP3, TMP4, [OUTPUT_BUF] + add TMP1, TMP1, OUTPUT_COL + add TMP2, TMP2, OUTPUT_COL + add TMP3, TMP3, OUTPUT_COL + add TMP4, TMP4, OUTPUT_COL + +#if defined(__ARMEL__) && !RESPECT_STRICT_ALIGNMENT + /* We can use much less instructions on little endian systems if the + * OS kernel is not configured to trap unaligned memory accesses + */ + st1 {v26.s}[0], [TMP1], 4 + st1 {v27.s}[0], [TMP3], 4 + st1 {v26.s}[1], [TMP2], 4 + st1 {v27.s}[1], [TMP4], 4 +#else + st1 {v26.b}[0], [TMP1], 1 + st1 {v27.b}[0], [TMP3], 1 + st1 {v26.b}[1], [TMP1], 1 + st1 {v27.b}[1], [TMP3], 1 + st1 {v26.b}[2], [TMP1], 1 + st1 {v27.b}[2], [TMP3], 1 + st1 {v26.b}[3], [TMP1], 1 + st1 {v27.b}[3], [TMP3], 1 + + st1 {v26.b}[4], [TMP2], 1 + st1 {v27.b}[4], [TMP4], 1 + st1 {v26.b}[5], [TMP2], 1 + st1 {v27.b}[5], [TMP4], 1 + st1 {v26.b}[6], [TMP2], 1 + st1 {v27.b}[6], [TMP4], 1 + st1 {v26.b}[7], [TMP2], 1 + st1 {v27.b}[7], [TMP4], 1 +#endif + + /* vpop {v8.4h-v15.4h} ;not available */ + ld1 {v12.4h-v15.4h}, [sp], 32 + ld1 {v8.4h-v11.4h}, [sp], 32 + + blr x30 + + .unreq DCT_TABLE + .unreq COEF_BLOCK + .unreq OUTPUT_BUF + .unreq OUTPUT_COL + .unreq TMP1 + .unreq TMP2 + .unreq TMP3 + .unreq TMP4 +.endfunc + +.purgem idct_helper + + +/*****************************************************************************/ + +/* + * jsimd_idct_2x2_neon + * + * This function contains inverse-DCT code for getting reduced-size + * 2x2 pixels output from an 8x8 DCT block. It uses the same calculations + * and produces exactly the same output as IJG's original 'jpeg_idct_2x2' + * function from jpeg-6b (jidctred.c). + * + * NOTE: jpeg-8 has an improved implementation of 2x2 inverse-DCT, which + * requires much less arithmetic operations and hence should be faster. + * The primary purpose of this particular NEON optimized function is + * bit exact compatibility with jpeg-6b. + */ + +.balign 8 +jsimd_idct_2x2_neon_consts: + .short -FIX_0_720959822 /* d0[0] */ + .short FIX_0_850430095 /* d0[1] */ + .short -FIX_1_272758580 /* d0[2] */ + .short FIX_3_624509785 /* d0[3] */ + +.macro idct_helper x4, x6, x10, x12, x16, shift, y26, y27 + sshll v28.4s, \x4, #15 + smull v26.4s, \x6, v0.4h[3] + smlal v26.4s, \x10, v0.4h[2] + smlal v26.4s, \x12, v0.4h[1] + smlal v26.4s, \x16, v0.4h[0] + + add v20.4s, v28.4s, v26.4s + sub v28.4s, v28.4s, v26.4s + +.if \shift > 16 + srshr v20.4s, v20.4s, #\shift + srshr v28.4s, v28.4s, #\shift + xtn \y26, v20.4s + xtn \y27, v28.4s +.else + rshrn \y26, v20.4s, #\shift + rshrn \y27, v28.4s, #\shift +.endif + +.endm + +asm_function jsimd_idct_2x2_neon + + DCT_TABLE .req x0 + COEF_BLOCK .req x1 + OUTPUT_BUF .req x2 + OUTPUT_COL .req x3 + TMP1 .req x0 + TMP2 .req x15 + + /* vpush {v8.4h-v15.4h} ; not available */ + sub sp, sp, #32 + st1 {v8.4h-v11.4h}, [sp] /* save NEON registers */ + sub sp, sp, #32 + st1 {v12.4h-v15.4h}, [sp] + + /* Load constants */ + adr TMP2, jsimd_idct_2x2_neon_consts + ld1 {v0.4h}, [TMP2] + + /* Load all COEF_BLOCK into NEON registers with the following allocation: + * 0 1 2 3 | 4 5 6 7 + * ---------+-------- + * 0 | v4.4h | v5.4h + * 1 | v6.4h | v7.4h + * 2 | - | - + * 3 | v10.4h | v11.4h + * 4 | - | - + * 5 | v12.4h | v13.4h + * 6 | - | - + * 7 | v16.4h | v17.4h + */ + ld1 {v4.4h, v5.4h, v6.4h, v7.4h}, [COEF_BLOCK], 32 + add COEF_BLOCK, COEF_BLOCK, #16 + ld1 {v10.4h, v11.4h}, [COEF_BLOCK], 16 + add COEF_BLOCK, COEF_BLOCK, #16 + ld1 {v12.4h, v13.4h}, [COEF_BLOCK], 16 + add COEF_BLOCK, COEF_BLOCK, #16 + ld1 {v16.4h, v17.4h}, [COEF_BLOCK], 16 + /* Dequantize */ + ld1 {v18.4h, v19.4h, v20.4h, v21.4h}, [DCT_TABLE], 32 + mul v4.8h, v4.8h, v18.8h + mul v5.8h, v5.8h, v18.8h + ins v4.2d[1], v5.2d[0] + mul v6.8h, v6.8h, v20.8h + mul v7.8h, v7.8h, v21.8h + ins v6.2d[1], v7.2d[0] + add DCT_TABLE, DCT_TABLE, #16 + ld1 {v24.4h, v25.4h}, [DCT_TABLE], 16 + mul v10.8h, v10.8h, v24.8h + mul v11.8h, v11.8h, v25.8h + ins v10.2d[1], v11.2d[0] + add DCT_TABLE, DCT_TABLE, #16 + ld1 {v26.4h, v27.4h}, [DCT_TABLE], 16 + mul v12.8h, v12.8h, v26.8h + mul v13.8h, v13.8h, v27.8h + ins v12.2d[1], v13.2d[0] + add DCT_TABLE, DCT_TABLE, #16 + ld1 {v30.4h, v31.4h}, [DCT_TABLE], 16 + mul v16.8h, v16.8h, v30.8h + mul v17.8h, v17.8h, v31.8h + ins v16.2d[1], v17.2d[0] + + /* Pass 1 */ +#if 0 + idct_helper v4.4h, v6.4h, v10.4h, v12.4h, v16.4h, 13, v4.4h, v6.4h + transpose_4x4 v4.4h, v6.4h, v8.4h, v10.4h + idct_helper v5.4h, v7.4h, v11.4h, v13.4h, v17.4h, 13, v5.4h, v7.4h + transpose_4x4 v5.4h, v7.4h, v9.4h, v11.4h +#else + smull v26.4s, v6.4h, v0.4h[3] + smlal v26.4s, v10.4h, v0.4h[2] + smlal v26.4s, v12.4h, v0.4h[1] + smlal v26.4s, v16.4h, v0.4h[0] + smull v24.4s, v7.4h, v0.4h[3] + smlal v24.4s, v11.4h, v0.4h[2] + smlal v24.4s, v13.4h, v0.4h[1] + smlal v24.4s, v17.4h, v0.4h[0] + sshll v28.4s, v4.4h, #15 + sshll v30.4s, v5.4h, #15 + add v20.4s, v28.4s, v26.4s + sub v28.4s, v28.4s, v26.4s + rshrn v4.4h, v20.4s, #13 + rshrn v6.4h, v28.4s, #13 + add v20.4s, v30.4s, v24.4s + sub v28.4s, v30.4s, v24.4s + rshrn v5.4h, v20.4s, #13 + rshrn v7.4h, v28.4s, #13 + transpose v4, v6, v3, .16b, .8h + transpose v6, v10, v3, .16b, .4s +#endif + + /* Pass 2 */ + idct_helper v4.4h, v6.4h, v10.4h, v7.4h, v11.4h, 20, v26.4h, v27.4h + + /* Range limit */ + movi v30.8h, #0x80 + ins v26.2d[1], v27.2d[0] + add v26.8h, v26.8h, v30.8h + sqxtun v30.8b, v26.8h + ins v26.2d[0], v30.2d[0] + sqxtun v27.8b, v26.8h + + /* Store results to the output buffer */ + ldp TMP1, TMP2, [OUTPUT_BUF] + add TMP1, TMP1, OUTPUT_COL + add TMP2, TMP2, OUTPUT_COL + + st1 {v26.b}[0], [TMP1], 1 + st1 {v27.b}[4], [TMP1], 1 + st1 {v26.b}[1], [TMP2], 1 + st1 {v27.b}[5], [TMP2], 1 + + /* vpop {v8.4h-v15.4h} ;not available */ + + ld1 {v12.4h-v15.4h}, [sp], 32 + ld1 {v8.4h-v11.4h}, [sp], 32 + + blr x30 + + .unreq DCT_TABLE + .unreq COEF_BLOCK + .unreq OUTPUT_BUF + .unreq OUTPUT_COL + .unreq TMP1 + .unreq TMP2 +.endfunc + +.purgem idct_helper + + +/*****************************************************************************/ + +/* + * jsimd_ycc_extrgb_convert_neon + * jsimd_ycc_extbgr_convert_neon + * jsimd_ycc_extrgbx_convert_neon + * jsimd_ycc_extbgrx_convert_neon + * jsimd_ycc_extxbgr_convert_neon + * jsimd_ycc_extxrgb_convert_neon + * + * Colorspace conversion YCbCr -> RGB + */ + + +.macro do_load size + .if \size == 8 + ld1 {v4.8b}, [U], 8 + ld1 {v5.8b}, [V], 8 + ld1 {v0.8b}, [Y], 8 + prfm PLDL1KEEP, [U, #64] + prfm PLDL1KEEP, [V, #64] + prfm PLDL1KEEP, [Y, #64] + .elseif \size == 4 + ld1 {v4.b}[0], [U] + ld1 {v4.b}[1], [U] + ld1 {v4.b}[2], [U] + ld1 {v4.b}[3], [U] + ld1 {v5.b}[0], [V] + ld1 {v5.b}[1], [V], 1 + ld1 {v5.b}[2], [V], 1 + ld1 {v5.b}[3], [V], 1 + ld1 {v0.b}[0], [Y], 1 + ld1 {v0.b}[1], [Y], 1 + ld1 {v0.b}[2], [Y], 1 + ld1 {v0.b}[3], [Y], 1 + .elseif \size == 2 + ld1 {v4.b}[4], [U], 1 + ld1 {v4.b}[5], [U], 1 + ld1 {v5.b}[4], [V], 1 + ld1 {v5.b}[5], [V], 1 + ld1 {v0.b}[4], [Y], 1 + ld1 {v0.b}[5], [Y], 1 + .elseif \size == 1 + ld1 {v4.b}[6], [U], 1 + ld1 {v5.b}[6], [V], 1 + ld1 {v0.b}[6], [Y], 1 + .else + .error unsupported macroblock size + .endif +.endm + +.macro do_store bpp, size + .if \bpp == 24 + .if \size == 8 + st3 {v10.8b, v11.8b, v12.8b}, [RGB], 24 + .elseif \size == 4 + st3 {v10.b, v11.b, v12.b}[0], [RGB], 3 + st3 {v10.b, v11.b, v12.b}[1], [RGB], 3 + st3 {v10.b, v11.b, v12.b}[2], [RGB], 3 + st3 {v10.b, v11.b, v12.b}[3], [RGB], 3 + .elseif \size == 2 + st3 {v10.b, v11.b, v12.b}[4], [RGB], 3 + st3 {v10.b, v11.b, v12.b}[4], [RGB], 3 + .elseif \size == 1 + st3 {v10.b, v11.b, v12.b}[6], [RGB], 3 + .else + .error unsupported macroblock size + .endif + .elseif \bpp == 32 + .if \size == 8 + st4 {v10.8b, v11.8b, v12.8b, v13.8b}, [RGB], 32 + .elseif \size == 4 + st4 {v10.b, v11.b, v12.b, v13.b}[0], [RGB], 4 + st4 {v10.b, v11.b, v12.b, v13.b}[1], [RGB], 4 + st4 {v10.b, v11.b, v12.b, v13.b}[2], [RGB], 4 + st4 {v10.b, v11.b, v12.b, v13.b}[3], [RGB], 4 + .elseif \size == 2 + st4 {v10.b, v11.b, v12.b, v13.b}[4], [RGB], 4 + st4 {v10.b, v11.b, v12.b, v13.b}[5], [RGB], 4 + .elseif \size == 1 + st4 {v10.b, v11.b, v12.b, v13.b}[6], [RGB], 4 + .else + .error unsupported macroblock size + .endif + .else + .error unsupported bpp + .endif +.endm +#ifdef RTSM_SQSHRN_SIM_ISSUE +.macro generate_jsimd_ycc_rgb_convert_neon colorid, bpp, r_offs, rsize, g_offs, gsize, b_offs, bsize, defsize +#else +.macro generate_jsimd_ycc_rgb_convert_neon colorid, bpp, r_offs, rsize, g_offs, gsize, b_offs, bsize +#endif +/* + * 2 stage pipelined YCbCr->RGB conversion + */ + +.macro do_yuv_to_rgb_stage1 + uaddw v6.8h, v2.8h, v4.8b /* q3 = u - 128 */ + uaddw v8.8h, v2.8h, v5.8b /* q2 = v - 128 */ + smull v20.4s, v6.4h, v1.4h[1] /* multiply by -11277 */ + smlal v20.4s, v8.4h, v1.4h[2] /* multiply by -23401 */ + smull2 v22.4s, v6.8h, v1.4h[1] /* multiply by -11277 */ + smlal2 v22.4s, v8.8h, v1.4h[2] /* multiply by -23401 */ + smull v24.4s, v8.4h, v1.4h[0] /* multiply by 22971 */ + smull2 v26.4s, v8.8h, v1.4h[0] /* multiply by 22971 */ + smull v28.4s, v6.4h, v1.4h[3] /* multiply by 29033 */ + smull2 v30.4s, v6.8h, v1.4h[3] /* multiply by 29033 */ +.endm + +.macro do_yuv_to_rgb_stage2 + rshrn v20.4h, v20.4s, #15 + rshrn2 v20.8h, v22.4s, #15 + rshrn v24.4h, v24.4s, #14 + rshrn2 v24.8h, v26.4s, #14 + rshrn v28.4h, v28.4s, #14 + rshrn2 v28.8h, v30.4s, #14 + uaddw v20.8h, v20.8h, v0.8b + uaddw v24.8h, v24.8h, v0.8b + uaddw v28.8h, v28.8h, v0.8b +#ifdef RTSM_SQSHRN_SIM_ISSUE + sqxtun v1\g_offs\defsize, v20.8h + sqxtun v1\r_offs\defsize, v24.8h + sqxtun v1\b_offs\defsize, v28.8h + +#else + sqxtun v1\g_offs\gsize, v20.4s + sqxtun v1\r_offs\rsize, v24.4s + sqxtun v1\b_offs\bsize, v28.4s +#endif +.endm + +.macro do_yuv_to_rgb_stage2_store_load_stage1 + ld1 {v4.8b}, [U], 8 + rshrn v20.4h, v20.4s, #15 + rshrn2 v20.8h, v22.4s, #15 + rshrn v24.4h, v24.4s, #14 + rshrn2 v24.8h, v26.4s, #14 + rshrn v28.4h, v28.4s, #14 + ld1 {v5.8b}, [V], 8 + rshrn2 v28.8h, v30.4s, #14 + uaddw v20.8h, v20.8h, v0.8b + uaddw v24.8h, v24.8h, v0.8b + uaddw v28.8h, v28.8h, v0.8b +#ifdef RTSM_SQSHRN_SIM_ISSUE + sqxtun v1\g_offs\defsize, v20.8h +#else + sqxtun v1\g_offs\gsize, v20.4s +#endif + ld1 {v0.8b}, [Y], 8 +#ifdef RTSM_SQSHRN_SIM_ISSUE + sqxtun v1\r_offs\defsize, v24.8h +#else + sqxtun v1\r_offs\rsize, v24.4s +#endif + prfm PLDL1KEEP, [U, #64] + prfm PLDL1KEEP, [V, #64] + prfm PLDL1KEEP, [Y, #64] +#ifdef RTSM_SQSHRN_SIM_ISSUE + sqxtun v1\b_offs\defsize, v28.8h +#else + sqxtun v1\b_offs\gsize, v28.4s +#endif + uaddw v6.8h, v2.8h, v4.8b /* v6.16b = u - 128 */ + uaddw v8.8h, v2.8h, v5.8b /* q2 = v - 128 */ + do_store \bpp, 8 + smull v20.4s, v6.4h, v1.4h[1] /* multiply by -11277 */ + smlal v20.4s, v8.4h, v1.4h[2] /* multiply by -23401 */ + smull2 v22.4s, v6.8h, v1.4h[1] /* multiply by -11277 */ + smlal2 v22.4s, v8.8h, v1.4h[2] /* multiply by -23401 */ + smull v24.4s, v8.4h, v1.4h[0] /* multiply by 22971 */ + smull2 v26.4s, v8.8h, v1.4h[0] /* multiply by 22971 */ + smull v28.4s, v6.4h, v1.4h[3] /* multiply by 29033 */ + smull2 v30.4s, v6.8h, v1.4h[3] /* multiply by 29033 */ +.endm + +.macro do_yuv_to_rgb + do_yuv_to_rgb_stage1 + do_yuv_to_rgb_stage2 +.endm + +/* Apple gas crashes on adrl, work around that by using adr. + * But this requires a copy of these constants for each function. + */ + +.balign 16 +jsimd_ycc_\colorid\()_neon_consts: + .short 0, 0, 0, 0 + .short 22971, -11277, -23401, 29033 + .short -128, -128, -128, -128 + .short -128, -128, -128, -128 + +asm_function jsimd_ycc_\colorid\()_convert_neon + OUTPUT_WIDTH .req x0 + INPUT_BUF .req x1 + INPUT_ROW .req x2 + OUTPUT_BUF .req x3 + NUM_ROWS .req x4 + + INPUT_BUF0 .req x5 + INPUT_BUF1 .req x6 + INPUT_BUF2 .req INPUT_BUF + + RGB .req x7 + Y .req x8 + U .req x9 + V .req x10 + N .req x15 + + /* Load constants to d1, d2, d3 (v0.4h is just used for padding) */ + adr x15, jsimd_ycc_\colorid\()_neon_consts + ld1 {v0.4h, v1.4h}, [x15], 16 + ld1 {v2.8h}, [x15] + + /* Save ARM registers and handle input arguments */ + /* push {x4, x5, x6, x7, x8, x9, x10, x30} */ + stp x4, x5, [sp,-16]! + stp x6, x7, [sp,-16]! + stp x8, x9, [sp,-16]! + stp x10, x30, [sp,-16]! + ldr INPUT_BUF0, [INPUT_BUF] + ldr INPUT_BUF1, [INPUT_BUF, 8] + ldr INPUT_BUF2, [INPUT_BUF, 16] + .unreq INPUT_BUF + + /* Save NEON registers */ + /* vpush {v8.4h-v15.4h} */ + sub sp, sp, #32 + st1 {v8.4h-v11.4h}, [sp] + sub sp, sp, #32 + st1 {v12.4h-v15.4h}, [sp] + + /* Initially set v10, v11.4h, v12.8b, d13 to 0xFF */ + movi v10.16b, #255 + movi v12.16b, #255 + + /* Outer loop over scanlines */ + cmp NUM_ROWS, #1 + blt 9f +0: + lsl x16, INPUT_ROW, #3 + ldr Y, [INPUT_BUF0, x16] + ldr U, [INPUT_BUF1, x16] + mov N, OUTPUT_WIDTH + ldr V, [INPUT_BUF2, x16] + add INPUT_ROW, INPUT_ROW, #1 + ldr RGB, [OUTPUT_BUF], #8 + + /* Inner loop over pixels */ + subs N, N, #8 + blt 3f + do_load 8 + do_yuv_to_rgb_stage1 + subs N, N, #8 + blt 2f +1: + do_yuv_to_rgb_stage2_store_load_stage1 + subs N, N, #8 + bge 1b +2: + do_yuv_to_rgb_stage2 + do_store \bpp, 8 + tst N, #7 + beq 8f +3: + tst N, #4 + beq 3f + do_load 4 +3: + tst N, #2 + beq 4f + do_load 2 +4: + tst N, #1 + beq 5f + do_load 1 +5: + do_yuv_to_rgb + tst N, #4 + beq 6f + do_store \bpp, 4 +6: + tst N, #2 + beq 7f + do_store \bpp, 2 +7: + tst N, #1 + beq 8f + do_store \bpp, 1 +8: + subs NUM_ROWS, NUM_ROWS, #1 + bgt 0b +9: + /* Restore all registers and return */ + /* vpop {v8.4h-v15.4h} */ + ld1 {v12.4h-v15.4h}, [sp], #32 + ld1 {v8.4h-v11.4h}, [sp], #32 + /* pop {r4, r5, r6, r7, r8, r9, r10, pc} */ + ldp x10, x30, [sp], #16 + ldp x8, x9, [sp], #16 + ldp x6, x5, [sp], #16 + ldp x4, x5, [sp], #16 + br x30 + .unreq OUTPUT_WIDTH + .unreq INPUT_ROW + .unreq OUTPUT_BUF + .unreq NUM_ROWS + .unreq INPUT_BUF0 + .unreq INPUT_BUF1 + .unreq INPUT_BUF2 + .unreq RGB + .unreq Y + .unreq U + .unreq V + .unreq N +.endfunc + +.purgem do_yuv_to_rgb +.purgem do_yuv_to_rgb_stage1 +.purgem do_yuv_to_rgb_stage2 +.purgem do_yuv_to_rgb_stage2_store_load_stage1 +.endm + +/* RTSM simulator fix integer saturation works on 8b boundry add a new parameter + * as a workaround for the simulator fix + */ +#ifdef RTSM_SQSHRN_SIM_ISSUE +/*--------------------------------- id ----- bpp R rsize G gsize B bsize defsize */ +generate_jsimd_ycc_rgb_convert_neon extrgb, 24, 0, .4h, 1, .4h, 2, .4h, .8b +generate_jsimd_ycc_rgb_convert_neon extbgr, 24, 2, .4h, 1, .4h, 0, .4h, .8b +generate_jsimd_ycc_rgb_convert_neon extrgbx, 32, 0, .4h, 1, .4h, 2, .4h, .8b +generate_jsimd_ycc_rgb_convert_neon extbgrx, 32, 2, .4h, 1, .4h, 0, .4h, .8b +generate_jsimd_ycc_rgb_convert_neon extxbgr, 32, 3, .4h, 2, .4h, 1, .4h, .8b +generate_jsimd_ycc_rgb_convert_neon extxrgb, 32, 1, .4h, 2, .4h, 3, .4h, .8b +#else +/*--------------------------------- id ----- bpp R rsize G gsize B bsize */ +generate_jsimd_ycc_rgb_convert_neon extrgb, 24, 0, .4h, 1, .4h, 2, .4h +generate_jsimd_ycc_rgb_convert_neon extbgr, 24, 2, .4h, 1, .4h, 0, .4h +generate_jsimd_ycc_rgb_convert_neon extrgbx, 32, 0, .4h, 1, .4h, 2, .4h +generate_jsimd_ycc_rgb_convert_neon extbgrx, 32, 2, .4h, 1, .4h, 0, .4h +generate_jsimd_ycc_rgb_convert_neon extxbgr, 32, 3, .4h, 2, .4h, 1, .4h +generate_jsimd_ycc_rgb_convert_neon extxrgb, 32, 1, .4h, 2, .4h, 3, .4h +#endif + +.purgem do_load +.purgem do_store From 890f35098a5f467f22ea4edadcd4ff4f8908028e Mon Sep 17 00:00:00 2001 From: DRC Date: Wed, 5 Feb 2014 19:03:41 +0000 Subject: [PATCH 06/65] Create a separate stub file for 64-bit ARM, since it currently implements only the decompression-related functions. --- simd/Makefile.am | 2 +- simd/jsimd_arm64.c | 586 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 587 insertions(+), 1 deletion(-) create mode 100644 simd/jsimd_arm64.c diff --git a/simd/Makefile.am b/simd/Makefile.am index 2504e761..be2f0a5f 100644 --- a/simd/Makefile.am +++ b/simd/Makefile.am @@ -60,7 +60,7 @@ endif if SIMD_ARM_64 -libsimd_la_SOURCES = jsimd_arm.c jsimd_arm_neon_64.S +libsimd_la_SOURCES = jsimd_arm64.c jsimd_arm_neon_64.S endif diff --git a/simd/jsimd_arm64.c b/simd/jsimd_arm64.c new file mode 100644 index 00000000..d280d621 --- /dev/null +++ b/simd/jsimd_arm64.c @@ -0,0 +1,586 @@ +/* + * jsimd_arm64.c + * + * Copyright 2009 Pierre Ossman for Cendio AB + * Copyright 2009-2011, 2013-2014 D. R. Commander + * + * Based on the x86 SIMD extension for IJG JPEG library, + * Copyright (C) 1999-2006, MIYASAKA Masaru. + * For conditions of distribution and use, see copyright notice in jsimdext.inc + * + * This file contains the interface between the "normal" portions + * of the library and the SIMD implementations when running on + * ARM architecture. + * + * Based on the stubs from 'jsimd_none.c' + */ + +#define JPEG_INTERNALS +#include "../jinclude.h" +#include "../jpeglib.h" +#include "../jsimd.h" +#include "../jdct.h" +#include "../jsimddct.h" +#include "jsimd.h" + +#include +#include +#include + +static unsigned int simd_support = ~0; + +#if defined(__linux__) || defined(ANDROID) || defined(__ANDROID__) + +#define SOMEWHAT_SANE_PROC_CPUINFO_SIZE_LIMIT (1024 * 1024) + +LOCAL(int) +check_feature (char *buffer, char *feature) +{ + char *p; + if (*feature == 0) + return 0; + if (strncmp(buffer, "Features", 8) != 0) + return 0; + buffer += 8; + while (isspace(*buffer)) + buffer++; + + /* Check if 'feature' is present in the buffer as a separate word */ + while ((p = strstr(buffer, feature))) { + if (p > buffer && !isspace(*(p - 1))) { + buffer++; + continue; + } + p += strlen(feature); + if (*p != 0 && !isspace(*p)) { + buffer++; + continue; + } + return 1; + } + return 0; +} + +LOCAL(int) +parse_proc_cpuinfo (int bufsize) +{ + char *buffer = (char *)malloc(bufsize); + FILE *fd; + simd_support = 0; + + if (!buffer) + return 0; + + fd = fopen("/proc/cpuinfo", "r"); + if (fd) { + while (fgets(buffer, bufsize, fd)) { + if (!strchr(buffer, '\n') && !feof(fd)) { + /* "impossible" happened - insufficient size of the buffer! */ + fclose(fd); + free(buffer); + return 0; + } + if (check_feature(buffer, "neon")) + simd_support |= JSIMD_ARM_NEON; + } + fclose(fd); + } + free(buffer); + return 1; +} + +#endif + +/* + * Check what SIMD accelerations are supported. + * + * FIXME: This code is racy under a multi-threaded environment. + */ +LOCAL(void) +init_simd (void) +{ + char *env = NULL; +#if !defined(__ARM_NEON__) && defined(__linux__) || defined(ANDROID) || defined(__ANDROID__) + int bufsize = 1024; /* an initial guess for the line buffer size limit */ +#endif + + if (simd_support != ~0U) + return; + + simd_support = 0; + +#if defined(__ARM_NEON__) + simd_support |= JSIMD_ARM_NEON; +#elif defined(__linux__) || defined(ANDROID) || defined(__ANDROID__) + /* We still have a chance to use NEON regardless of globally used + * -mcpu/-mfpu options passed to gcc by performing runtime detection via + * /proc/cpuinfo parsing on linux/android */ + while (!parse_proc_cpuinfo(bufsize)) { + bufsize *= 2; + if (bufsize > SOMEWHAT_SANE_PROC_CPUINFO_SIZE_LIMIT) + break; + } +#endif + + /* Force different settings through environment variables */ + env = getenv("JSIMD_FORCENEON"); + if ((env != NULL) && (strcmp(env, "1") == 0)) + simd_support &= JSIMD_ARM_NEON; + env = getenv("JSIMD_FORCENONE"); + if ((env != NULL) && (strcmp(env, "1") == 0)) + simd_support = 0; +} + +GLOBAL(int) +jsimd_can_rgb_ycc (void) +{ + init_simd(); + + return 0; +} + +GLOBAL(int) +jsimd_can_rgb_gray (void) +{ + init_simd(); + + return 0; +} + +GLOBAL(int) +jsimd_can_ycc_rgb (void) +{ + init_simd(); + + /* The code is optimised for these values only */ + if (BITS_IN_JSAMPLE != 8) + return 0; + if (sizeof(JDIMENSION) != 4) + return 0; + if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4)) + return 0; + if (simd_support & JSIMD_ARM_NEON) + return 1; + + return 0; +} + +GLOBAL(void) +jsimd_rgb_ycc_convert (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPIMAGE output_buf, + JDIMENSION output_row, int num_rows) +{ +} + +GLOBAL(void) +jsimd_rgb_gray_convert (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPIMAGE output_buf, + JDIMENSION output_row, int num_rows) +{ +} + +GLOBAL(void) +jsimd_ycc_rgb_convert (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION input_row, + JSAMPARRAY output_buf, int num_rows) +{ + void (*neonfct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, int); + + switch(cinfo->out_color_space) + { + case JCS_EXT_RGB: + neonfct=jsimd_ycc_extrgb_convert_neon; + break; + case JCS_EXT_RGBX: + case JCS_EXT_RGBA: + neonfct=jsimd_ycc_extrgbx_convert_neon; + break; + case JCS_EXT_BGR: + neonfct=jsimd_ycc_extbgr_convert_neon; + break; + case JCS_EXT_BGRX: + case JCS_EXT_BGRA: + neonfct=jsimd_ycc_extbgrx_convert_neon; + break; + case JCS_EXT_XBGR: + case JCS_EXT_ABGR: + neonfct=jsimd_ycc_extxbgr_convert_neon; + break; + case JCS_EXT_XRGB: + case JCS_EXT_ARGB: + neonfct=jsimd_ycc_extxrgb_convert_neon; + break; + default: + neonfct=jsimd_ycc_extrgb_convert_neon; + break; + } + + if (simd_support & JSIMD_ARM_NEON) + neonfct(cinfo->output_width, input_buf, + input_row, output_buf, num_rows); +} + +GLOBAL(int) +jsimd_can_h2v2_downsample (void) +{ + init_simd(); + + return 0; +} + +GLOBAL(int) +jsimd_can_h2v1_downsample (void) +{ + init_simd(); + + return 0; +} + +GLOBAL(void) +jsimd_h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY output_data) +{ +} + +GLOBAL(void) +jsimd_h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY output_data) +{ +} + +GLOBAL(int) +jsimd_can_h2v2_upsample (void) +{ + init_simd(); + + return 0; +} + +GLOBAL(int) +jsimd_can_h2v1_upsample (void) +{ + init_simd(); + + return 0; +} + +GLOBAL(void) +jsimd_h2v2_upsample (j_decompress_ptr cinfo, + jpeg_component_info * compptr, + JSAMPARRAY input_data, + JSAMPARRAY * output_data_ptr) +{ +} + +GLOBAL(void) +jsimd_h2v1_upsample (j_decompress_ptr cinfo, + jpeg_component_info * compptr, + JSAMPARRAY input_data, + JSAMPARRAY * output_data_ptr) +{ +} + +GLOBAL(int) +jsimd_can_h2v2_fancy_upsample (void) +{ + init_simd(); + + return 0; +} + +GLOBAL(int) +jsimd_can_h2v1_fancy_upsample (void) +{ + init_simd(); + + return 0; +} + +GLOBAL(void) +jsimd_h2v2_fancy_upsample (j_decompress_ptr cinfo, + jpeg_component_info * compptr, + JSAMPARRAY input_data, + JSAMPARRAY * output_data_ptr) +{ +} + +GLOBAL(void) +jsimd_h2v1_fancy_upsample (j_decompress_ptr cinfo, + jpeg_component_info * compptr, + JSAMPARRAY input_data, + JSAMPARRAY * output_data_ptr) +{ +} + +GLOBAL(int) +jsimd_can_h2v2_merged_upsample (void) +{ + init_simd(); + + return 0; +} + +GLOBAL(int) +jsimd_can_h2v1_merged_upsample (void) +{ + init_simd(); + + return 0; +} + +GLOBAL(void) +jsimd_h2v2_merged_upsample (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, + JDIMENSION in_row_group_ctr, + JSAMPARRAY output_buf) +{ +} + +GLOBAL(void) +jsimd_h2v1_merged_upsample (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, + JDIMENSION in_row_group_ctr, + JSAMPARRAY output_buf) +{ +} + +GLOBAL(int) +jsimd_can_convsamp (void) +{ + init_simd(); + + return 0; +} + +GLOBAL(int) +jsimd_can_convsamp_float (void) +{ + init_simd(); + + return 0; +} + +GLOBAL(void) +jsimd_convsamp (JSAMPARRAY sample_data, JDIMENSION start_col, + DCTELEM * workspace) +{ +} + +GLOBAL(void) +jsimd_convsamp_float (JSAMPARRAY sample_data, JDIMENSION start_col, + FAST_FLOAT * workspace) +{ +} + +GLOBAL(int) +jsimd_can_fdct_islow (void) +{ + init_simd(); + + return 0; +} + +GLOBAL(int) +jsimd_can_fdct_ifast (void) +{ + init_simd(); + + return 0; +} + +GLOBAL(int) +jsimd_can_fdct_float (void) +{ + init_simd(); + + return 0; +} + +GLOBAL(void) +jsimd_fdct_islow (DCTELEM * data) +{ +} + +GLOBAL(void) +jsimd_fdct_ifast (DCTELEM * data) +{ +} + +GLOBAL(void) +jsimd_fdct_float (FAST_FLOAT * data) +{ +} + +GLOBAL(int) +jsimd_can_quantize (void) +{ + init_simd(); + + return 0; +} + +GLOBAL(int) +jsimd_can_quantize_float (void) +{ + init_simd(); + + return 0; +} + +GLOBAL(void) +jsimd_quantize (JCOEFPTR coef_block, DCTELEM * divisors, + DCTELEM * workspace) +{ +} + +GLOBAL(void) +jsimd_quantize_float (JCOEFPTR coef_block, FAST_FLOAT * divisors, + FAST_FLOAT * workspace) +{ +} + +GLOBAL(int) +jsimd_can_idct_2x2 (void) +{ + init_simd(); + + /* The code is optimised for these values only */ + if (DCTSIZE != 8) + return 0; + if (sizeof(JCOEF) != 2) + return 0; + if (BITS_IN_JSAMPLE != 8) + return 0; + if (sizeof(JDIMENSION) != 4) + return 0; + if (sizeof(ISLOW_MULT_TYPE) != 2) + return 0; + + if ((simd_support & JSIMD_ARM_NEON)) + return 1; + + return 0; +} + +GLOBAL(int) +jsimd_can_idct_4x4 (void) +{ + init_simd(); + + /* The code is optimised for these values only */ + if (DCTSIZE != 8) + return 0; + if (sizeof(JCOEF) != 2) + return 0; + if (BITS_IN_JSAMPLE != 8) + return 0; + if (sizeof(JDIMENSION) != 4) + return 0; + if (sizeof(ISLOW_MULT_TYPE) != 2) + return 0; + + if ((simd_support & JSIMD_ARM_NEON)) + return 1; + + return 0; +} + +GLOBAL(void) +jsimd_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, + JDIMENSION output_col) +{ + if ((simd_support & JSIMD_ARM_NEON)) + jsimd_idct_2x2_neon(compptr->dct_table, coef_block, output_buf, output_col); +} + +GLOBAL(void) +jsimd_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, + JDIMENSION output_col) +{ + if ((simd_support & JSIMD_ARM_NEON)) + jsimd_idct_4x4_neon(compptr->dct_table, coef_block, output_buf, output_col); +} + +GLOBAL(int) +jsimd_can_idct_islow (void) +{ + init_simd(); + + /* The code is optimised for these values only */ + if (DCTSIZE != 8) + return 0; + if (sizeof(JCOEF) != 2) + return 0; + if (BITS_IN_JSAMPLE != 8) + return 0; + if (sizeof(JDIMENSION) != 4) + return 0; + if (sizeof(ISLOW_MULT_TYPE) != 2) + return 0; + + if (simd_support & JSIMD_ARM_NEON) + return 1; + + return 0; +} + +GLOBAL(int) +jsimd_can_idct_ifast (void) +{ + init_simd(); + + /* The code is optimised for these values only */ + if (DCTSIZE != 8) + return 0; + if (sizeof(JCOEF) != 2) + return 0; + if (BITS_IN_JSAMPLE != 8) + return 0; + if (sizeof(JDIMENSION) != 4) + return 0; + if (sizeof(IFAST_MULT_TYPE) != 2) + return 0; + if (IFAST_SCALE_BITS != 2) + return 0; + + if ((simd_support & JSIMD_ARM_NEON)) + return 1; + + return 0; +} + +GLOBAL(int) +jsimd_can_idct_float (void) +{ + init_simd(); + + return 0; +} + +GLOBAL(void) +jsimd_idct_islow (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, + JDIMENSION output_col) +{ + if ((simd_support & JSIMD_ARM_NEON)) + jsimd_idct_islow_neon(compptr->dct_table, coef_block, output_buf, output_col); +} + +GLOBAL(void) +jsimd_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, + JDIMENSION output_col) +{ + if ((simd_support & JSIMD_ARM_NEON)) + jsimd_idct_ifast_neon(compptr->dct_table, coef_block, output_buf, output_col); +} + +GLOBAL(void) +jsimd_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, + JDIMENSION output_col) +{ +} + From bf417e56e038b3eb0d52105c92ae708314cf65d0 Mon Sep 17 00:00:00 2001 From: DRC Date: Thu, 6 Feb 2014 19:13:24 +0000 Subject: [PATCH 07/65] Remove trailing space --- simd/jsimd_arm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simd/jsimd_arm.c b/simd/jsimd_arm.c index a70db7eb..c6fa4caa 100644 --- a/simd/jsimd_arm.c +++ b/simd/jsimd_arm.c @@ -3,7 +3,7 @@ * * Copyright 2009 Pierre Ossman for Cendio AB * Copyright 2009-2011, 2013 D. R. Commander - * + * * Based on the x86 SIMD extension for IJG JPEG library, * Copyright (C) 1999-2006, MIYASAKA Masaru. * For conditions of distribution and use, see copyright notice in jsimdext.inc From 3317c65fb9c9ac33e5136722cee6adc8ff03dcf3 Mon Sep 17 00:00:00 2001 From: DRC Date: Thu, 6 Feb 2014 19:30:32 +0000 Subject: [PATCH 08/65] Fix several potential overflow issues identified by the community. --- jdmarker.c | 7 ++++--- jdphuff.c | 1 + jquant2.c | 2 ++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/jdmarker.c b/jdmarker.c index a19219fa..c8771bc0 100644 --- a/jdmarker.c +++ b/jdmarker.c @@ -478,14 +478,15 @@ get_dht (j_decompress_ptr cinfo) if (index & 0x10) { /* AC table definition */ index -= 0x10; + if (index < 0 || index >= NUM_HUFF_TBLS) + ERREXIT1(cinfo, JERR_DHT_INDEX, index); htblptr = &cinfo->ac_huff_tbl_ptrs[index]; } else { /* DC table definition */ + if (index < 0 || index >= NUM_HUFF_TBLS) + ERREXIT1(cinfo, JERR_DHT_INDEX, index); htblptr = &cinfo->dc_huff_tbl_ptrs[index]; } - if (index < 0 || index >= NUM_HUFF_TBLS) - ERREXIT1(cinfo, JERR_DHT_INDEX, index); - if (*htblptr == NULL) *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); diff --git a/jdphuff.c b/jdphuff.c index 22678099..fa97aab6 100644 --- a/jdphuff.c +++ b/jdphuff.c @@ -198,6 +198,7 @@ start_pass_phuff_decoder (j_decompress_ptr cinfo) * On some machines, a shift and add will be faster than a table lookup. */ +#define AVOID_TABLES #ifdef AVOID_TABLES #define HUFF_EXTEND(x,s) ((x) < (1<<((s)-1)) ? (x) + (((-1)<<(s)) + 1) : (x)) diff --git a/jquant2.c b/jquant2.c index 9b060e57..d9944705 100644 --- a/jquant2.c +++ b/jquant2.c @@ -513,6 +513,8 @@ compute_color (j_decompress_ptr cinfo, boxptr boxp, int icolor) } } + if (total == 0) + return; cinfo->colormap[0][icolor] = (JSAMPLE) ((c0total + (total>>1)) / total); cinfo->colormap[1][icolor] = (JSAMPLE) ((c1total + (total>>1)) / total); cinfo->colormap[2][icolor] = (JSAMPLE) ((c2total + (total>>1)) / total); From 7d8ed9833e11d2bc7a4a48e018c74bd5a56ccde9 Mon Sep 17 00:00:00 2001 From: DRC Date: Fri, 7 Feb 2014 19:05:07 +0000 Subject: [PATCH 09/65] Further examination of the code reveals that this change is unnecessary. The histogram stores a count of each color in the image, so it will always contain at least one non-zero element, and thus the total can never be zero. Since the histogram is generated from the image data and not read from the header, there is no chance that header corruption would affect it. --- jquant2.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/jquant2.c b/jquant2.c index d9944705..9b060e57 100644 --- a/jquant2.c +++ b/jquant2.c @@ -513,8 +513,6 @@ compute_color (j_decompress_ptr cinfo, boxptr boxp, int icolor) } } - if (total == 0) - return; cinfo->colormap[0][icolor] = (JSAMPLE) ((c0total + (total>>1)) / total); cinfo->colormap[1][icolor] = (JSAMPLE) ((c1total + (total>>1)) / total); cinfo->colormap[2][icolor] = (JSAMPLE) ((c2total + (total>>1)) / total); From d3d06f42c13dd108f994e58d0ed2167a68b53fc9 Mon Sep 17 00:00:00 2001 From: DRC Date: Sun, 9 Feb 2014 14:12:12 +0000 Subject: [PATCH 10/65] Update copyright notice to reflect recent SIMD contributions --- jversion.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/jversion.h b/jversion.h index 68b3743c..a05f12bc 100644 --- a/jversion.h +++ b/jversion.h @@ -28,5 +28,7 @@ #define JCOPYRIGHT "Copyright (C) 1991-2012 Thomas G. Lane, Guido Vollbeding\n" \ "Copyright (C) 1999-2006 MIYASAKA Masaru\n" \ "Copyright (C) 2009 Pierre Ossman for Cendio AB\n" \ - "Copyright (C) 2009-2013 D. R. Commander\n" \ - "Copyright (C) 2009-2011 Nokia Corporation and/or its subsidiary(-ies)" + "Copyright (C) 2009-2014 D. R. Commander\n" \ + "Copyright (C) 2009-2011 Nokia Corporation and/or its subsidiary(-ies)\n" \ + "Copyright (C) 2013 MIPS Technologies, Inc.\n" \ + "Copyright (C) 2013 Linaro Limited" From 040c688263bfeff5eac1df2a2aa9176f29fcb6dd Mon Sep 17 00:00:00 2001 From: DRC Date: Tue, 11 Feb 2014 09:45:18 +0000 Subject: [PATCH 11/65] Fix an issue that prevented tjEncodeYUV3() and TJCompressor.encodeYUV() from working properly if the source image was very tiny. Basically, jpeg_start_compress() was attempting to write the JPEG headers, which was overrunning the YUV buffer. This patch removes the call to jpeg_start_compress() in tjEncodeYUV3() and replaces it with calls to the individual routines that are necessary to initialize the color converter and downsampler. TJUnitTest has also been modified to test for this condition (the buffer size regression test now works in YUV mode.) --- ChangeLog.txt | 4 ++++ java/TJUnitTest.java | 28 ++++++++++++++++------ tjunittest.c | 55 +++++++++++++++++++++++++++++--------------- turbojpeg.c | 17 ++++++++++++-- 4 files changed, 76 insertions(+), 28 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 80253b52..2ca98395 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -56,6 +56,10 @@ omitted at compile time". [4] Fixed a couple of issues whereby malformed JPEG images would cause libjpeg-turbo to use uninitialized memory during decompression. +[5] Fixed an error ("Buffer passed to JPEG library is too small") that occurred +when calling the TurboJPEG YUV encoding function with a very small (< 5x5) +source image, and added a unit test to check for this error. + 1.3.0 ===== diff --git a/java/TJUnitTest.java b/java/TJUnitTest.java index 4d57f127..a6ee73eb 100644 --- a/java/TJUnitTest.java +++ b/java/TJUnitTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C)2011-2013 D. R. Commander. All Rights Reserved. + * Copyright (C)2011-2014 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: @@ -945,7 +945,7 @@ public class TJUnitTest { private static void bufSizeTest() throws Exception { int w, h, i, subsamp; - byte[] srcBuf, jpegBuf; + byte[] srcBuf, dstBuf; TJCompressor tjc = null; Random r = new Random(); @@ -959,22 +959,35 @@ public class TJUnitTest { if (h % 100 == 0) System.out.format("%04d x %04d\b\b\b\b\b\b\b\b\b\b\b", w, h); srcBuf = new byte[w * h * 4]; - jpegBuf = new byte[TJ.bufSize(w, h, subsamp)]; + if (yuv == YUVENCODE) + dstBuf = new byte[TJ.bufSizeYUV(w, pad, h, subsamp)]; + else + dstBuf = new byte[TJ.bufSize(w, h, subsamp)]; for (i = 0; i < w * h * 4; i++) { srcBuf[i] = (byte)(r.nextInt(2) * 255); } tjc.setSourceImage(srcBuf, w, 0, h, TJ.PF_BGRX); tjc.setSubsamp(subsamp); tjc.setJPEGQuality(100); - tjc.compress(jpegBuf, 0); + tjc.setYUVPad(pad); + if (yuv == YUVENCODE) + tjc.encodeYUV(dstBuf, 0); + else + tjc.compress(dstBuf, 0); srcBuf = new byte[h * w * 4]; - jpegBuf = new byte[TJ.bufSize(h, w, subsamp)]; + if (yuv == YUVENCODE) + dstBuf = new byte[TJ.bufSizeYUV(h, pad, w, subsamp)]; + else + dstBuf = new byte[TJ.bufSize(h, w, subsamp)]; for (i = 0; i < h * w * 4; i++) { srcBuf[i] = (byte)(r.nextInt(2) * 255); } tjc.setSourceImage(srcBuf, h, 0, w, TJ.PF_BGRX); - tjc.compress(jpegBuf, 0); + if (yuv == YUVENCODE) + tjc.encodeYUV(dstBuf, 0); + else + tjc.compress(dstBuf, 0); } } } @@ -1033,9 +1046,10 @@ public class TJUnitTest { _4byteFormats[4] = -1; doTest(35, 39, bi ? _4byteFormatsBI : _4byteFormats, TJ.SAMP_GRAY, testName); - if (!doyuv && !bi) + if (!bi) bufSizeTest(); if (doyuv && !bi) { + System.out.print("\n--------------------\n\n"); yuv = YUVDECODE; doTest(48, 48, onlyRGB, TJ.SAMP_444, "javatest_yuv0"); doTest(35, 39, onlyRGB, TJ.SAMP_444, "javatest_yuv1"); diff --git a/tjunittest.c b/tjunittest.c index 519686fc..8204153d 100644 --- a/tjunittest.c +++ b/tjunittest.c @@ -1,5 +1,5 @@ /* - * Copyright (C)2009-2013 D. R. Commander. All Rights Reserved. + * Copyright (C)2009-2014 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: @@ -667,9 +667,9 @@ void doTest(int w, int h, const int *formats, int nformats, int subsamp, void bufSizeTest(void) { int w, h, i, subsamp; - unsigned char *srcBuf=NULL, *jpegBuf=NULL; + unsigned char *srcBuf=NULL, *dstBuf=NULL; tjhandle handle=NULL; - unsigned long jpegSize=0; + unsigned long dstSize=0; if((handle=tjInitCompress())==NULL) _throwtj(); @@ -684,12 +684,12 @@ void bufSizeTest(void) if(h%100==0) printf("%.4d x %.4d\b\b\b\b\b\b\b\b\b\b\b", w, h); if((srcBuf=(unsigned char *)malloc(w*h*4))==NULL) _throw("Memory allocation failure"); - if(!alloc) + if(!alloc || yuv==YUVENCODE) { - if((jpegBuf=(unsigned char *)tjAlloc(tjBufSize(w, h, subsamp))) - ==NULL) + if(yuv==YUVENCODE) dstSize=tjBufSizeYUV2(w, pad, h, subsamp); + else dstSize=tjBufSize(w, h, subsamp); + if((dstBuf=(unsigned char *)tjAlloc(dstSize))==NULL) _throw("Memory allocation failure"); - jpegSize=tjBufSize(w, h, subsamp); } for(i=0; iglobal_state!=CSTATE_START) + _throw("tjEncodeYUV3(): libjpeg API is in the wrong state"); + (*cinfo->err->reset_error_mgr)((j_common_ptr)cinfo); + (*cinfo->dest->init_destination)(cinfo); + jinit_c_master_control(cinfo, FALSE); + jinit_color_converter(cinfo); + jinit_downsampler(cinfo); + jinit_c_prep_controller(cinfo, FALSE); + (*cinfo->mem->realize_virt_arrays)((j_common_ptr)cinfo); + pw=PAD(width, cinfo->max_h_samp_factor); ph=PAD(height, cinfo->max_v_samp_factor); From 9ba6976321bc5be090bec22fe4d72874a9ae14ec Mon Sep 17 00:00:00 2001 From: DRC Date: Tue, 11 Feb 2014 09:55:32 +0000 Subject: [PATCH 12/65] Update copyright year in file header as well --- jversion.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jversion.h b/jversion.h index a05f12bc..032fef0e 100644 --- a/jversion.h +++ b/jversion.h @@ -4,7 +4,7 @@ * This file was part of the Independent JPEG Group's software: * Copyright (C) 1991-2012, Thomas G. Lane, Guido Vollbeding. * Modifications: - * Copyright (C) 2010, 2012-2013, D. R. Commander. + * Copyright (C) 2010, 2012-2014, D. R. Commander. * For conditions of distribution and use, see the accompanying README file. * * This file contains software version identification. From 618fb42ff164b1036b3556775b422ca9107fb4f9 Mon Sep 17 00:00:00 2001 From: DRC Date: Sat, 15 Feb 2014 07:02:04 +0000 Subject: [PATCH 13/65] Fix autoconf warnings --- acinclude.m4 | 20 ++++++++++---------- configure.ac | 6 ++++-- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index 5f87a050..a02ad77f 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -144,26 +144,26 @@ AC_DEFUN([AC_CHECK_COMPATIBLE_ARM_ASSEMBLER_IFELSE],[ ac_save_CFLAGS="$CFLAGS" CFLAGS="$CCASFLAGS -x assembler-with-cpp" CC="$CCAS" - AC_COMPILE_IFELSE([[ + AC_COMPILE_IFELSE([AC_LANG_SOURCE([ .text .fpu neon .arch armv7a .object_arch armv4 .arm pld [r0] - vmovn.u16 d0, q0]], ac_good_gnu_arm_assembler=yes) + vmovn.u16 d0, q0])], ac_good_gnu_arm_assembler=yes) ac_use_gas_preprocessor=no if test "x$ac_good_gnu_arm_assembler" = "xno" ; then CC="gas-preprocessor.pl $CCAS" - AC_COMPILE_IFELSE([[ + AC_COMPILE_IFELSE([AC_LANG_SOURCE([ .text .fpu neon .arch armv7a .object_arch armv4 .arm pld [r0] - vmovn.u16 d0, q0]], ac_use_gas_preprocessor=yes) + vmovn.u16 d0, q0])], ac_use_gas_preprocessor=yes) fi CFLAGS="$ac_save_CFLAGS" CC="$ac_save_CC" @@ -189,7 +189,7 @@ AC_DEFUN([AC_CHECK_COMPATIBLE_MIPSEL_ASSEMBLER_IFELSE],[ ac_save_CFLAGS="$CFLAGS" CFLAGS="$CCASFLAGS -mdspr2" - AC_COMPILE_IFELSE([[ + AC_COMPILE_IFELSE([AC_LANG_SOURCE([ int main () { @@ -201,7 +201,7 @@ AC_DEFUN([AC_CHECK_COMPATIBLE_MIPSEL_ASSEMBLER_IFELSE],[ ); return c; } - ]], have_mips_dspr2=yes) + ])], have_mips_dspr2=yes) CFLAGS=$ac_save_CFLAGS if test "x$have_mips_dspr2" = "xyes" ; then @@ -217,16 +217,16 @@ AC_DEFUN([AC_CHECK_COMPATIBLE_ARM64_ASSEMBLER_IFELSE],[ ac_save_CFLAGS="$CFLAGS" CFLAGS="$CCASFLAGS -x assembler-with-cpp" CC="$CCAS" - AC_COMPILE_IFELSE([[ + AC_COMPILE_IFELSE([AC_LANG_SOURCE([ .text - movi v0.16b, #100]], ac_good_gnu_arm_assembler=yes) + movi v0.16b, [#100]])], ac_good_gnu_arm_assembler=yes) ac_use_gas_preprocessor=no if test "x$ac_good_gnu_arm_assembler" = "xno" ; then CC="gas-preprocessor.pl $CCAS" - AC_COMPILE_IFELSE([[ + AC_COMPILE_IFELSE([AC_LANG_SOURCE([ .text - movi v0.16b, #100]], ac_use_gas_preprocessor=yes) + movi v0.16b, [#100]])], ac_use_gas_preprocessor=yes) fi CFLAGS="$ac_save_CFLAGS" CC="$ac_save_CC" diff --git a/configure.ac b/configure.ac index 6234641f..01a2690b 100644 --- a/configure.ac +++ b/configure.ac @@ -16,7 +16,9 @@ SAVED_CFLAGS=${CFLAGS} SAVED_CPPFLAGS=${CPPFLAGS} AC_PROG_CPP AC_PROG_CC +AM_PROG_AR AM_PROG_AS +AM_PROG_CC_C_O AC_PROG_INSTALL AC_PROG_LIBTOOL AC_PROG_LN_S @@ -235,13 +237,13 @@ VERS_1 { global: *; }; EOF -AC_LINK_IFELSE(AC_LANG_PROGRAM([], []), +AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [VERSION_SCRIPT_FLAG=-Wl,--version-script,; AC_MSG_RESULT([yes (GNU style)])], []) if test "x$VERSION_SCRIPT_FLAG" = "x"; then LDFLAGS="$SAVED_LDFLAGS -Wl,-M,conftest.map" - AC_LINK_IFELSE(AC_LANG_PROGRAM([], []), + AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [VERSION_SCRIPT_FLAG=-Wl,-M,; AC_MSG_RESULT([yes (Sun style)])], []) From b9e72234e112dbe0d7215e5d950e4baeb819e631 Mon Sep 17 00:00:00 2001 From: DRC Date: Sat, 15 Feb 2014 07:14:58 +0000 Subject: [PATCH 14/65] Older versions of automake don't support AM_PROG_AR, so only execute that macro if it exists. --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 01a2690b..6d61018c 100644 --- a/configure.ac +++ b/configure.ac @@ -16,7 +16,7 @@ SAVED_CFLAGS=${CFLAGS} SAVED_CPPFLAGS=${CPPFLAGS} AC_PROG_CPP AC_PROG_CC -AM_PROG_AR +m4_ifdef([AM_PROG_AR], [AM_PROG_AR)]) AM_PROG_AS AM_PROG_CC_C_O AC_PROG_INSTALL From 005d7c52a76f96830838db130c2fc3cc6e5fb524 Mon Sep 17 00:00:00 2001 From: DRC Date: Thu, 20 Feb 2014 19:33:44 +0000 Subject: [PATCH 15/65] Oops --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 6d61018c..d0780c93 100644 --- a/configure.ac +++ b/configure.ac @@ -16,7 +16,7 @@ SAVED_CFLAGS=${CFLAGS} SAVED_CPPFLAGS=${CPPFLAGS} AC_PROG_CPP AC_PROG_CC -m4_ifdef([AM_PROG_AR], [AM_PROG_AR)]) +m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) AM_PROG_AS AM_PROG_CC_C_O AC_PROG_INSTALL From b7e14cbaca889a05b03205d542199676caa97cf4 Mon Sep 17 00:00:00 2001 From: DRC Date: Thu, 27 Feb 2014 21:22:54 +0000 Subject: [PATCH 16/65] Use C-style comments --- jcstest.c | 4 ++-- turbojpeg.c | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/jcstest.c b/jcstest.c index 98f16da6..358ed251 100644 --- a/jcstest.c +++ b/jcstest.c @@ -78,7 +78,7 @@ int main(void) jerr.pub.output_message = my_output_message; if(setjmp(jerr.jb)) { - // this will execute if libjpeg has an error + /* this will execute if libjpeg has an error */ jcs_valid = 0; goto done; } @@ -105,7 +105,7 @@ int main(void) #endif if(setjmp(jerr.jb)) { - // this will execute if libjpeg has an error + /* this will execute if libjpeg has an error */ jcs_alpha_valid = 0; goto done2; } diff --git a/turbojpeg.c b/turbojpeg.c index 3d0fa882..9775e9bc 100644 --- a/turbojpeg.c +++ b/turbojpeg.c @@ -538,9 +538,9 @@ DLLEXPORT unsigned long DLLCALL tjBufSize(int width, int height, if(width<1 || height<1 || jpegSubsamp<0 || jpegSubsamp>=NUMSUBOPT) _throw("tjBufSize(): Invalid argument"); - // This allows for rare corner cases in which a JPEG image can actually be - // larger than the uncompressed input (we wouldn't mention it if it hadn't - // happened before.) + /* This allows for rare corner cases in which a JPEG image can actually be + larger than the uncompressed input (we wouldn't mention it if it hadn't + happened before.) */ mcuw=tjMCUWidth[jpegSubsamp]; mcuh=tjMCUHeight[jpegSubsamp]; chromasf=jpegSubsamp==TJSAMP_GRAY? 0: 4*64/(mcuw*mcuh); @@ -556,9 +556,9 @@ DLLEXPORT unsigned long DLLCALL TJBUFSIZE(int width, int height) if(width<1 || height<1) _throw("TJBUFSIZE(): Invalid argument"); - // This allows for rare corner cases in which a JPEG image can actually be - // larger than the uncompressed input (we wouldn't mention it if it hadn't - // happened before.) + /* This allows for rare corner cases in which a JPEG image can actually be + larger than the uncompressed input (we wouldn't mention it if it hadn't + happened before.) */ retval=PAD(width, 16) * PAD(height, 16) * 6 + 2048; bailout: @@ -976,10 +976,10 @@ DLLEXPORT int DLLCALL tjCompressFromYUV(tjhandle handle, unsigned char *srcBuf, for(j=0; j Date: Fri, 28 Feb 2014 05:34:02 +0000 Subject: [PATCH 17/65] Remove unused code (the destination manager is not used during YUV encoding, there are no virtual arrays to realize, and jinit_c_prep_controller() is unnecessary because we are not using smoothing.) --- turbojpeg.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/turbojpeg.c b/turbojpeg.c index 9775e9bc..96a0fa98 100644 --- a/turbojpeg.c +++ b/turbojpeg.c @@ -756,7 +756,6 @@ DLLEXPORT int DLLCALL tjEncodeYUV3(tjhandle handle, unsigned char *srcBuf, else if(flags&TJFLAG_FORCESSE2) putenv("JSIMD_FORCESSE2=1"); yuvsize=tjBufSizeYUV2(width, pad, height, subsamp); - jpeg_mem_dest_tj(cinfo, &dstBuf, &yuvsize, 0); if(setCompDefaults(cinfo, pixelFormat, subsamp, -1, flags)==-1) return -1; /* Execute only the parts of jpeg_start_compress() that we need. If we @@ -766,12 +765,9 @@ DLLEXPORT int DLLCALL tjEncodeYUV3(tjhandle handle, unsigned char *srcBuf, if(cinfo->global_state!=CSTATE_START) _throw("tjEncodeYUV3(): libjpeg API is in the wrong state"); (*cinfo->err->reset_error_mgr)((j_common_ptr)cinfo); - (*cinfo->dest->init_destination)(cinfo); jinit_c_master_control(cinfo, FALSE); jinit_color_converter(cinfo); jinit_downsampler(cinfo); - jinit_c_prep_controller(cinfo, FALSE); - (*cinfo->mem->realize_virt_arrays)((j_common_ptr)cinfo); pw=PAD(width, cinfo->max_h_samp_factor); ph=PAD(height, cinfo->max_v_samp_factor); From 9961cd6aed3c1edfe9902ce53c6400d2542915b3 Mon Sep 17 00:00:00 2001 From: DRC Date: Fri, 28 Feb 2014 09:06:42 +0000 Subject: [PATCH 18/65] Remove benchmarks. They were originally intended as a way of measuring overhead for small compress/decompress operations, but using TJBench with a small image is a better way to accomplish that. --- tjunittest.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/tjunittest.c b/tjunittest.c index 8204153d..6b14db18 100644 --- a/tjunittest.c +++ b/tjunittest.c @@ -455,7 +455,6 @@ void compTest(tjhandle handle, unsigned char **dstBuf, const char *pfStr=(yuv==YUVDECODE)? "YUV":pixFormatStr[pf]; const char *buStrLong=(flags&TJFLAG_BOTTOMUP)? "Bottom-Up":"Top-Down "; const char *buStr=(flags&TJFLAG_BOTTOMUP)? "BU":"TD"; - double t; if(yuv==YUVDECODE) { @@ -480,7 +479,6 @@ void compTest(tjhandle handle, unsigned char **dstBuf, if(*dstBuf && *dstSize>0) memset(*dstBuf, 0, *dstSize); - t=gettime(); if(yuv==YUVENCODE) { _tj(tjEncodeYUV3(handle, srcBuf, w, 0, h, pf, *dstBuf, pad, subsamp, @@ -500,7 +498,6 @@ void compTest(tjhandle handle, unsigned char **dstBuf, jpegQual, flags)); } } - t=gettime()-t; if(yuv==YUVENCODE) snprintf(tempStr, 1024, "%s_enc_%s_%s_%s.yuv", basename, pfStr, buStr, @@ -516,7 +513,7 @@ void compTest(tjhandle handle, unsigned char **dstBuf, else printf("FAILED!"); } else printf("Done."); - printf(" %f ms\n Result in %s\n", t*1000., tempStr); + printf("\n Result in %s\n", tempStr); bailout: if(srcBuf) free(srcBuf); @@ -528,7 +525,7 @@ void _decompTest(tjhandle handle, unsigned char *jpegBuf, int flags, tjscalingfactor sf) { unsigned char *dstBuf=NULL; - int _hdrw=0, _hdrh=0, _hdrsubsamp=-1; double t; + int _hdrw=0, _hdrh=0, _hdrsubsamp=-1; int scaledWidth=TJSCALED(w, sf); int scaledHeight=TJSCALED(h, sf); unsigned long dstSize=0; @@ -556,7 +553,6 @@ void _decompTest(tjhandle handle, unsigned char *jpegBuf, _throw("Memory allocation failure"); memset(dstBuf, 0, dstSize); - t=gettime(); if(yuv==YUVDECODE) { _tj(tjDecompressToYUV2(handle, jpegBuf, jpegSize, dstBuf, scaledWidth, @@ -567,7 +563,6 @@ void _decompTest(tjhandle handle, unsigned char *jpegBuf, _tj(tjDecompress2(handle, jpegBuf, jpegSize, dstBuf, scaledWidth, 0, scaledHeight, pf, flags)); } - t=gettime()-t; if(yuv==YUVDECODE) { @@ -581,7 +576,7 @@ void _decompTest(tjhandle handle, unsigned char *jpegBuf, printf("Passed."); else printf("FAILED!"); } - printf(" %f ms\n", t*1000.); + printf("\n"); bailout: if(dstBuf) free(dstBuf); From 5c2f2cccb7f526aa6170efa1b517d0dc2aa50fa1 Mon Sep 17 00:00:00 2001 From: DRC Date: Fri, 28 Feb 2014 09:17:14 +0000 Subject: [PATCH 19/65] Implement a YUV decode function in the TurboJPEG API, to be symmetric with tjEncodeYUV(). --- ChangeLog.txt | 3 +- doc/html/group___turbo_j_p_e_g.html | 99 +++++++++++- doc/html/search/all_74.js | 1 + doc/html/search/functions_74.js | 1 + tjunittest.c | 241 +++++++++------------------- turbojpeg-mapfile | 1 + turbojpeg-mapfile.jni | 1 + turbojpeg.c | 214 ++++++++++++++++++++++++ turbojpeg.h | 58 ++++++- 9 files changed, 454 insertions(+), 165 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 2ca98395..ac3db638 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -21,7 +21,8 @@ images is not supported. Such conversion requires a color management system and is out of scope for a codec library. [5] The TurboJPEG API can now be used to compress JPEG images from YUV planar -source images. +source images and to decode YUV planar images into RGB, grayscale, or extended +RGB images. [6] If an application attempts to decompress a Huffman-coded JPEG image whose header does not contain Huffman tables, libjpeg-turbo will now insert the diff --git a/doc/html/group___turbo_j_p_e_g.html b/doc/html/group___turbo_j_p_e_g.html index 2c3395b7..28e4926e 100644 --- a/doc/html/group___turbo_j_p_e_g.html +++ b/doc/html/group___turbo_j_p_e_g.html @@ -255,6 +255,9 @@ Functions DLLEXPORT int DLLCALL tjDecompressToYUV2 (tjhandle handle, unsigned char *jpegBuf, unsigned long jpegSize, unsigned char *dstBuf, int width, int pad, int height, int flags)  Decompress a JPEG image to a YUV planar image. More...
  +DLLEXPORT int DLLCALL tjDecodeYUV (tjhandle handle, unsigned char *srcBuf, int pad, int subsamp, unsigned char *dstBuf, int width, int pitch, int height, int pixelFormat, int flags) + Decode a YUV planar image into an RGB or grayscale image. More...
+  DLLEXPORT tjhandle DLLCALL tjInitTransform (void)  Create a new TurboJPEG transformer instance. More...
  @@ -1086,6 +1089,100 @@ If you choose option 1, *jpegSize should be set to the size of your
Returns
0 if successful, or -1 if an error occurred (see tjGetErrorStr().)
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
DLLEXPORT int DLLCALL tjDecodeYUV (tjhandle handle,
unsigned char * srcBuf,
int pad,
int subsamp,
unsigned char * dstBuf,
int width,
int pitch,
int height,
int pixelFormat,
int flags 
)
+
+ +

Decode a YUV planar image into an RGB or grayscale image.

+

This function uses the accelerated color conversion routines in the underlying codec but does not execute any of the other steps in the JPEG decompression process. The Y, U (Cb), and V (Cr) image planes should be stored sequentially in the source buffer, and the size of each plane is determined by the width and height of the source image, as well as the specified padding and level of chrominance subsampling. If the chrominance components are subsampled along the horizontal dimension, then the width of the luminance plane should be padded to the nearest multiple of 2 in the input image (same goes for the height of the luminance plane, if the chrominance components are subsampled along the vertical dimension.)

+

NOTE: Technically, the JPEG format uses the YCbCr colorspace, but per the convention of the digital video community, the TurboJPEG API uses "YUV" to refer to an image format consisting of Y, Cb, and Cr image planes.

+
Parameters
+ + + + + + + + + + + +
handlea handle to a TurboJPEG decompressor or transformer instance
srcBufpointer to an image buffer containing a YUV planar image to be decoded. The size of this buffer should match the value returned by tjBufSizeYUV2() for the given image width, height, padding, and level of chrominance subsampling.
padUse this parameter to specify that the width of each line in each plane of the YUV source image is padded to the nearest multiple of this number of bytes (must be a power of 2.)
subsampthe level of chrominance subsampling used in the YUV source image (see Chrominance subsampling options.)
dstBufpointer to an image buffer that will receive the decoded image. This buffer should normally be pitch * height bytes in size, but the dstBuf pointer can also be used to decode into a specific region of a larger buffer.
widthwidth (in pixels) of the source and destination images
pitchbytes per line of the destination image. Normally, this should be width * tjPixelSize[pixelFormat] if the destination image is unpadded, or TJPAD(width * tjPixelSize[pixelFormat]) if each line of the destination image should be padded to the nearest 32-bit boundary, as is the case for Windows bitmaps. You can also be clever and use the pitch parameter to skip lines, etc. Setting this parameter to 0 is the equivalent of setting it to width * tjPixelSize[pixelFormat].
heightheight (in pixels) of the source and destination images
pixelFormatpixel format of the destination image (see Pixel formats.)
flagsthe bitwise OR of one or more of the flags.
+
+
+
Returns
0 if successful, or -1 if an error occurred (see tjGetErrorStr().)
+
@@ -1422,7 +1519,7 @@ If you choose option 1, *jpegSize should be set to the size of your

Encode an RGB or grayscale image into a YUV planar image.

-

This function uses the accelerated color conversion routines in TurboJPEG's underlying codec but does not execute any of the other steps in the JPEG compression process. The Y, U (Cb), and V (Cr) image planes are stored sequentially into the destination buffer, and the size of each plane is determined by the width and height of the source image, as well as the specified padding and level of chrominance subsampling. If the chrominance components are subsampled along the horizontal dimension, then the width of the luminance plane is padded to the nearest multiple of 2 in the output image (same goes for the height of the luminance plane, if the chrominance components are subsampled along the vertical dimension.)

+

This function uses the accelerated color conversion routines in the underlying codec but does not execute any of the other steps in the JPEG compression process. The Y, U (Cb), and V (Cr) image planes are stored sequentially into the destination buffer, and the size of each plane is determined by the width and height of the source image, as well as the specified padding and level of chrominance subsampling. If the chrominance components are subsampled along the horizontal dimension, then the width of the luminance plane is padded to the nearest multiple of 2 in the output image (same goes for the height of the luminance plane, if the chrominance components are subsampled along the vertical dimension.)

NOTE: Technically, the JPEG format uses the YCbCr colorspace, but per the convention of the digital video community, the TurboJPEG API uses "YUV" to refer to an image format consisting of Y, Cb, and Cr image planes.

Parameters
diff --git a/doc/html/search/all_74.js b/doc/html/search/all_74.js index 21e0ced8..435cec4d 100644 --- a/doc/html/search/all_74.js +++ b/doc/html/search/all_74.js @@ -16,6 +16,7 @@ var searchData= ['tjcs_5frgb',['TJCS_RGB',['../group___turbo_j_p_e_g.html#gga4f83ad3368e0e29d1957be0efa7c3720a677cb7ccb85c4038ac41964a2e09e555',1,'turbojpeg.h']]], ['tjcs_5fycbcr',['TJCS_YCbCr',['../group___turbo_j_p_e_g.html#gga4f83ad3368e0e29d1957be0efa7c3720a7389b8f65bb387ffedce3efd0d78ec75',1,'turbojpeg.h']]], ['tjcs_5fycck',['TJCS_YCCK',['../group___turbo_j_p_e_g.html#gga4f83ad3368e0e29d1957be0efa7c3720a53839e0fe867b76b58d16b0a1a7c598e',1,'turbojpeg.h']]], + ['tjdecodeyuv',['tjDecodeYUV',['../group___turbo_j_p_e_g.html#ga132ae2c2cadcf64c8bb0f3bdf69da3ed',1,'turbojpeg.h']]], ['tjdecompress2',['tjDecompress2',['../group___turbo_j_p_e_g.html#gada69cc6443d1bb493b40f1626259e5e9',1,'turbojpeg.h']]], ['tjdecompressheader3',['tjDecompressHeader3',['../group___turbo_j_p_e_g.html#gacd0fac3af74b3511d39b4781b7103086',1,'turbojpeg.h']]], ['tjdecompresstoyuv2',['tjDecompressToYUV2',['../group___turbo_j_p_e_g.html#ga7c08b340ad7f8e85d407bd9e81d44d07',1,'turbojpeg.h']]], diff --git a/doc/html/search/functions_74.js b/doc/html/search/functions_74.js index 4a42d2aa..0a0e6cdc 100644 --- a/doc/html/search/functions_74.js +++ b/doc/html/search/functions_74.js @@ -5,6 +5,7 @@ var searchData= ['tjbufsizeyuv2',['tjBufSizeYUV2',['../group___turbo_j_p_e_g.html#gaf451664a62c1f6c7cc5a6401f32908c9',1,'turbojpeg.h']]], ['tjcompress2',['tjCompress2',['../group___turbo_j_p_e_g.html#gaba62b7a98f960839b588579898495cf2',1,'turbojpeg.h']]], ['tjcompressfromyuv',['tjCompressFromYUV',['../group___turbo_j_p_e_g.html#ga0b931126c7a615ddc3bbd0cca6698d67',1,'turbojpeg.h']]], + ['tjdecodeyuv',['tjDecodeYUV',['../group___turbo_j_p_e_g.html#ga132ae2c2cadcf64c8bb0f3bdf69da3ed',1,'turbojpeg.h']]], ['tjdecompress2',['tjDecompress2',['../group___turbo_j_p_e_g.html#gada69cc6443d1bb493b40f1626259e5e9',1,'turbojpeg.h']]], ['tjdecompressheader3',['tjDecompressHeader3',['../group___turbo_j_p_e_g.html#gacd0fac3af74b3511d39b4781b7103086',1,'turbojpeg.h']]], ['tjdecompresstoyuv2',['tjDecompressToYUV2',['../group___turbo_j_p_e_g.html#ga7c08b340ad7f8e85d407bd9e81d44d07',1,'turbojpeg.h']]], diff --git a/tjunittest.c b/tjunittest.c index 6b14db18..8bdd7210 100644 --- a/tjunittest.c +++ b/tjunittest.c @@ -80,7 +80,7 @@ const int _onlyGray[]={TJPF_GRAY}; const int _onlyRGB[]={TJPF_RGB}; enum {YUVENCODE=1, YUVDECODE}; -int yuv=0, alloc=0, pad=4; +int doyuv=0, alloc=0, pad=4; int exitStatus=0; #define bailout() {exitStatus=-1; goto bailout;} @@ -295,60 +295,6 @@ int checkBuf(unsigned char *buf, int w, int h, int pf, int subsamp, #define PAD(v, p) ((v+(p)-1)&(~((p)-1))) -void initBufYUV(unsigned char *buf, int w, int pad, int h, int subsamp) -{ - int row, col; - int hsf=tjMCUWidth[subsamp]/8, vsf=tjMCUHeight[subsamp]/8; - int pw=PAD(w, hsf), ph=PAD(h, vsf); - int cw=pw/hsf, ch=ph/vsf; - int ypitch=PAD(pw, pad), uvpitch=PAD(cw, pad); - int halfway=16, blocksize=8; - - memset(buf, 0, tjBufSizeYUV2(w, pad, h, subsamp)); - - for(row=0; row JPEG Q%d ... ", subNameLong[subsamp], buStrLong, - jpegQual); - if((srcBuf=(unsigned char *)malloc(tjBufSizeYUV2(w, pad, h, subsamp))) - ==NULL) - _throw("Memory allocation failure"); - initBufYUV(srcBuf, w, pad, h, subsamp); - } - else - { - if(yuv==YUVENCODE) - printf("%s %s -> %s YUV ... ", pfStr, buStrLong, subNameLong[subsamp]); - else - printf("%s %s -> %s Q%d ... ", pfStr, buStrLong, subNameLong[subsamp], - jpegQual); - if((srcBuf=(unsigned char *)malloc(w*h*tjPixelSize[pf]))==NULL) - _throw("Memory allocation failure"); - initBuf(srcBuf, w, h, pf, flags); - } + if((srcBuf=(unsigned char *)malloc(w*h*tjPixelSize[pf]))==NULL) + _throw("Memory allocation failure"); + initBuf(srcBuf, w, h, pf, flags); if(*dstBuf && *dstSize>0) memset(*dstBuf, 0, *dstSize); - if(yuv==YUVENCODE) - { - _tj(tjEncodeYUV3(handle, srcBuf, w, 0, h, pf, *dstBuf, pad, subsamp, - flags)); - } - else - { - if(!alloc) flags|=TJFLAG_NOREALLOC; - if(yuv==YUVDECODE) - { - _tj(tjCompressFromYUV(handle, srcBuf, w, pad, h, subsamp, dstBuf, - dstSize, jpegQual, flags)); - } - else - { - _tj(tjCompress2(handle, srcBuf, w, 0, h, pf, dstBuf, dstSize, subsamp, - jpegQual, flags)); - } - } - if(yuv==YUVENCODE) + if(!alloc) flags|=TJFLAG_NOREALLOC; + if(doyuv) + { + unsigned long yuvSize=tjBufSizeYUV2(w, pad, h, subsamp); + tjscalingfactor sf={1, 1}; + + if((yuvBuf=(unsigned char *)malloc(yuvSize))==NULL) + _throw("Memory allocation failure"); + + printf("%s %s -> YUV %s ... ", pfStr, buStrLong, subNameLong[subsamp]); + _tj(tjEncodeYUV3(handle, srcBuf, w, 0, h, pf, yuvBuf, pad, subsamp, + flags)); snprintf(tempStr, 1024, "%s_enc_%s_%s_%s.yuv", basename, pfStr, buStr, subName[subsamp]); - else - snprintf(tempStr, 1024, "%s_enc_%s_%s_%s_Q%d.jpg", basename, pfStr, buStr, - subName[subsamp], jpegQual); - writeJPEG(*dstBuf, *dstSize, tempStr); - if(yuv==YUVENCODE) - { - tjscalingfactor sf={1, 1}; - if(checkBufYUV(*dstBuf, w, h, subsamp, sf)) printf("Passed."); - else printf("FAILED!"); + writeJPEG(yuvBuf, yuvSize, tempStr); + if(checkBufYUV(yuvBuf, w, h, subsamp, sf)) printf("Passed.\n"); + else printf("FAILED!\n"); + + printf("YUV %s %s -> JPEG Q%d ... ", subNameLong[subsamp], buStrLong, + jpegQual); + _tj(tjCompressFromYUV(handle, yuvBuf, w, pad, h, subsamp, dstBuf, + dstSize, jpegQual, flags)); } - else printf("Done."); - printf("\n Result in %s\n", tempStr); + else + { + printf("%s %s -> %s Q%d ... ", pfStr, buStrLong, subNameLong[subsamp], + jpegQual); + _tj(tjCompress2(handle, srcBuf, w, 0, h, pf, dstBuf, dstSize, subsamp, + jpegQual, flags)); + } + + snprintf(tempStr, 1024, "%s_enc_%s_%s_%s_Q%d.jpg", basename, pfStr, buStr, + subName[subsamp], jpegQual); + writeJPEG(*dstBuf, *dstSize, tempStr); + printf("Done.\n Result in %s\n", tempStr); bailout: + if(yuvBuf) free(yuvBuf); if(srcBuf) free(srcBuf); } @@ -524,61 +455,63 @@ void _decompTest(tjhandle handle, unsigned char *jpegBuf, unsigned long jpegSize, int w, int h, int pf, char *basename, int subsamp, int flags, tjscalingfactor sf) { - unsigned char *dstBuf=NULL; + unsigned char *dstBuf=NULL, *yuvBuf=NULL; int _hdrw=0, _hdrh=0, _hdrsubsamp=-1; int scaledWidth=TJSCALED(w, sf); int scaledHeight=TJSCALED(h, sf); unsigned long dstSize=0; - if(yuv==YUVENCODE) return; - - if(yuv==YUVDECODE) - printf("JPEG -> YUV %s ", subNameLong[subsamp]); - else - printf("JPEG -> %s %s ", pixFormatStr[pf], - (flags&TJFLAG_BOTTOMUP)? "Bottom-Up":"Top-Down "); - if(sf.num!=1 || sf.denom!=1) - printf("%d/%d ... ", sf.num, sf.denom); - else printf("... "); - _tj(tjDecompressHeader2(handle, jpegBuf, jpegSize, &_hdrw, &_hdrh, &_hdrsubsamp)); if(_hdrw!=w || _hdrh!=h || _hdrsubsamp!=subsamp) _throw("Incorrect JPEG header"); - if(yuv==YUVDECODE) - dstSize=tjBufSizeYUV2(scaledWidth, pad, scaledHeight, subsamp); - else dstSize=scaledWidth*scaledHeight*tjPixelSize[pf]; + dstSize=scaledWidth*scaledHeight*tjPixelSize[pf]; if((dstBuf=(unsigned char *)malloc(dstSize))==NULL) _throw("Memory allocation failure"); memset(dstBuf, 0, dstSize); - if(yuv==YUVDECODE) + if(doyuv) { - _tj(tjDecompressToYUV2(handle, jpegBuf, jpegSize, dstBuf, scaledWidth, + unsigned long yuvSize=tjBufSizeYUV2(scaledWidth, pad, scaledHeight, + subsamp); + + if((yuvBuf=(unsigned char *)malloc(yuvSize))==NULL) + _throw("Memory allocation failure"); + + printf("JPEG -> YUV %s ", subNameLong[subsamp]); + if(sf.num!=1 || sf.denom!=1) + printf("%d/%d ... ", sf.num, sf.denom); + else printf("... "); + _tj(tjDecompressToYUV2(handle, jpegBuf, jpegSize, yuvBuf, scaledWidth, pad, scaledHeight, flags)); + if(checkBufYUV(yuvBuf, scaledWidth, scaledHeight, subsamp, sf)) + printf("Passed.\n"); + else printf("FAILED!\n"); + + printf("YUV %s -> %s %s ... ", subNameLong[subsamp], pixFormatStr[pf], + (flags&TJFLAG_BOTTOMUP)? "Bottom-Up":"Top-Down "); + _tj(tjDecodeYUV(handle, yuvBuf, pad, subsamp, dstBuf, scaledWidth, 0, + scaledHeight, pf, flags)); } else { + printf("JPEG -> %s %s ", pixFormatStr[pf], + (flags&TJFLAG_BOTTOMUP)? "Bottom-Up":"Top-Down "); + if(sf.num!=1 || sf.denom!=1) + printf("%d/%d ... ", sf.num, sf.denom); + else printf("... "); _tj(tjDecompress2(handle, jpegBuf, jpegSize, dstBuf, scaledWidth, 0, scaledHeight, pf, flags)); } - if(yuv==YUVDECODE) - { - if(checkBufYUV(dstBuf, scaledWidth, scaledHeight, subsamp, sf)) - printf("Passed."); - else printf("FAILED!"); - } - else - { - if(checkBuf(dstBuf, scaledWidth, scaledHeight, pf, subsamp, sf, flags)) - printf("Passed."); - else printf("FAILED!"); - } + if(checkBuf(dstBuf, scaledWidth, scaledHeight, pf, subsamp, sf, flags)) + printf("Passed."); + else printf("FAILED!"); printf("\n"); bailout: + if(yuvBuf) free(yuvBuf); if(dstBuf) free(dstBuf); } @@ -614,9 +547,7 @@ void doTest(int w, int h, const int *formats, int nformats, int subsamp, unsigned char *dstBuf=NULL; unsigned long size=0; int pfi, pf, i; - if(yuv==YUVENCODE) - size=tjBufSizeYUV2(w, pad, h, subsamp); - else if(!alloc) + if(!alloc) size=tjBufSize(w, h, subsamp); if(size!=0) if((dstBuf=(unsigned char *)tjAlloc(size))==NULL) @@ -633,11 +564,7 @@ void doTest(int w, int h, const int *formats, int nformats, int subsamp, if(subsamp==TJSAMP_422 || subsamp==TJSAMP_420 || subsamp==TJSAMP_440 || subsamp==TJSAMP_411) flags|=TJFLAG_FASTUPSAMPLE; - if(i==1) - { - if(yuv==YUVDECODE) goto bailout; - else flags|=TJFLAG_BOTTOMUP; - } + if(i==1) flags|=TJFLAG_BOTTOMUP; pf=formats[pfi]; compTest(chandle, &dstBuf, &size, w, h, pf, basename, subsamp, 100, flags); @@ -679,9 +606,9 @@ void bufSizeTest(void) if(h%100==0) printf("%.4d x %.4d\b\b\b\b\b\b\b\b\b\b\b", w, h); if((srcBuf=(unsigned char *)malloc(w*h*4))==NULL) _throw("Memory allocation failure"); - if(!alloc || yuv==YUVENCODE) + if(!alloc || doyuv) { - if(yuv==YUVENCODE) dstSize=tjBufSizeYUV2(w, pad, h, subsamp); + if(doyuv) dstSize=tjBufSizeYUV2(w, pad, h, subsamp); else dstSize=tjBufSize(w, h, subsamp); if((dstBuf=(unsigned char *)tjAlloc(dstSize))==NULL) _throw("Memory allocation failure"); @@ -693,7 +620,7 @@ void bufSizeTest(void) else srcBuf[i]=255; } - if(yuv==YUVENCODE) + if(doyuv) { _tj(tjEncodeYUV3(handle, srcBuf, w, 0, h, TJPF_BGRX, dstBuf, pad, subsamp, 0)); @@ -708,9 +635,9 @@ void bufSizeTest(void) if((srcBuf=(unsigned char *)malloc(h*w*4))==NULL) _throw("Memory allocation failure"); - if(!alloc || yuv==YUVENCODE) + if(!alloc || doyuv) { - if(yuv==YUVENCODE) dstSize=tjBufSizeYUV2(h, pad, w, subsamp); + if(doyuv) dstSize=tjBufSizeYUV2(h, pad, w, subsamp); else dstSize=tjBufSize(h, w, subsamp); if((dstBuf=(unsigned char *)tjAlloc(dstSize))==NULL) _throw("Memory allocation failure"); @@ -722,7 +649,7 @@ void bufSizeTest(void) else srcBuf[i]=255; } - if(yuv==YUVENCODE) + if(doyuv) { _tj(tjEncodeYUV3(handle, srcBuf, h, 0, w, TJPF_BGRX, dstBuf, pad, subsamp, 0)); @@ -748,7 +675,7 @@ void bufSizeTest(void) int main(int argc, char *argv[]) { - int doyuv=0, i, num4bf=5; + int i, num4bf=5; #ifdef _WIN32 srand((unsigned int)time(NULL)); #endif @@ -764,7 +691,7 @@ int main(int argc, char *argv[]) } } if(alloc) printf("Testing automatic buffer allocation\n"); - if(doyuv) {yuv=YUVENCODE; num4bf=4;} + if(doyuv) num4bf=4; doTest(35, 39, _3byteFormats, 2, TJSAMP_444, "test"); doTest(39, 41, _4byteFormats, num4bf, TJSAMP_444, "test"); doTest(41, 35, _3byteFormats, 2, TJSAMP_422, "test"); @@ -782,21 +709,13 @@ int main(int argc, char *argv[]) if(doyuv) { printf("\n--------------------\n\n"); - yuv=YUVDECODE; doTest(48, 48, _onlyRGB, 1, TJSAMP_444, "test_yuv0"); - doTest(35, 39, _onlyRGB, 1, TJSAMP_444, "test_yuv1"); doTest(48, 48, _onlyRGB, 1, TJSAMP_422, "test_yuv0"); - doTest(39, 41, _onlyRGB, 1, TJSAMP_422, "test_yuv1"); doTest(48, 48, _onlyRGB, 1, TJSAMP_420, "test_yuv0"); - doTest(41, 35, _onlyRGB, 1, TJSAMP_420, "test_yuv1"); doTest(48, 48, _onlyRGB, 1, TJSAMP_440, "test_yuv0"); - doTest(35, 39, _onlyRGB, 1, TJSAMP_440, "test_yuv1"); doTest(48, 48, _onlyRGB, 1, TJSAMP_411, "test_yuv0"); - doTest(39, 41, _onlyRGB, 1, TJSAMP_411, "test_yuv1"); doTest(48, 48, _onlyRGB, 1, TJSAMP_GRAY, "test_yuv0"); - doTest(41, 35, _onlyRGB, 1, TJSAMP_GRAY, "test_yuv1"); doTest(48, 48, _onlyGray, 1, TJSAMP_GRAY, "test_yuv0"); - doTest(35, 39, _onlyGray, 1, TJSAMP_GRAY, "test_yuv1"); } return exitStatus; diff --git a/turbojpeg-mapfile b/turbojpeg-mapfile index d8cf41c3..7d174ca8 100755 --- a/turbojpeg-mapfile +++ b/turbojpeg-mapfile @@ -42,6 +42,7 @@ TURBOJPEG_1.4 global: tjBufSizeYUV2; tjCompressFromYUV; + tjDecodeYUV; tjDecompressHeader3; tjDecompressToYUV2; tjEncodeYUV3; diff --git a/turbojpeg-mapfile.jni b/turbojpeg-mapfile.jni index f90f9434..a1be1fd6 100755 --- a/turbojpeg-mapfile.jni +++ b/turbojpeg-mapfile.jni @@ -68,6 +68,7 @@ TURBOJPEG_1.4 global: tjBufSizeYUV2; tjCompressFromYUV; + tjDecodeYUV; tjDecompressHeader3; tjDecompressToYUV2; tjEncodeYUV3; diff --git a/turbojpeg.c b/turbojpeg.c index 96a0fa98..ee412c1c 100644 --- a/turbojpeg.c +++ b/turbojpeg.c @@ -1232,6 +1232,220 @@ DLLEXPORT int DLLCALL tjDecompress(tjhandle handle, unsigned char *jpegBuf, } +static int setDecodeDefaults(struct jpeg_decompress_struct *dinfo, + int pixelFormat, int subsamp, int flags) +{ + dinfo->scale_num=dinfo->scale_denom=1; + + if(subsamp==TJSAMP_GRAY) + { + dinfo->num_components=1; + dinfo->jpeg_color_space=JCS_GRAYSCALE; + } + else + { + dinfo->num_components=3; + dinfo->jpeg_color_space=JCS_YCbCr; + } + + dinfo->comp_info=(jpeg_component_info *) + (*dinfo->mem->alloc_small)((j_common_ptr)dinfo, JPOOL_IMAGE, + dinfo->num_components*SIZEOF(jpeg_component_info)); + + dinfo->comp_info[0].h_samp_factor=tjMCUWidth[subsamp]/8; + dinfo->comp_info[0].v_samp_factor=tjMCUHeight[subsamp]/8; + dinfo->cur_comp_info[0]=&dinfo->comp_info[0]; + if(dinfo->num_components==3) + { + dinfo->comp_info[1].h_samp_factor=1; + dinfo->comp_info[1].v_samp_factor=1; + dinfo->cur_comp_info[1]=&dinfo->comp_info[1]; + dinfo->comp_info[2].h_samp_factor=1; + dinfo->comp_info[2].v_samp_factor=1; + dinfo->cur_comp_info[2]=&dinfo->comp_info[2]; + } + + return 0; +} + + +int my_read_markers(j_decompress_ptr dinfo) +{ + return JPEG_REACHED_SOS; +} + +void my_reset_marker_reader(j_decompress_ptr dinfo) +{ +} + +DLLEXPORT int DLLCALL tjDecodeYUV(tjhandle handle, unsigned char *srcBuf, + int pad, int subsamp, unsigned char *dstBuf, int width, int pitch, + int height, int pixelFormat, int flags) +{ + int i, retval=0; JSAMPROW *row_pointer=NULL; + JSAMPLE *_tmpbuf[MAX_COMPONENTS]; + JSAMPROW *tmpbuf[MAX_COMPONENTS], *inbuf[MAX_COMPONENTS]; + int row, pw, ph, cw[MAX_COMPONENTS], ch[MAX_COMPONENTS], useMerged=0; + JSAMPLE *ptr=srcBuf; + unsigned long yuvsize=0; + jpeg_component_info *compptr; + #ifndef JCS_EXTENSIONS + unsigned char *rgbBuf=NULL; + #endif + JMETHOD(int, old_read_markers, (j_decompress_ptr)); + JMETHOD(void, old_reset_marker_reader, (j_decompress_ptr)); + + getinstance(handle); + + for(i=0; iinit&DECOMPRESS)==0) + _throw("tjDecodeYUV(): Instance has not been initialized for compression"); + + if(srcBuf==NULL || pad<0 || !isPow2(pad) || subsamp<0 || subsamp>=NUMSUBOPT + || dstBuf==NULL || width<=0 || pitch<0 || height<=0 || pixelFormat<0 + || pixelFormat>=TJ_NUMPF) + _throw("tjDecodeYUV(): Invalid argument"); + + if(setjmp(this->jerr.setjmp_buffer)) + { + /* If we get here, the JPEG code has signaled an error. */ + retval=-1; + goto bailout; + } + + if(pixelFormat==TJPF_CMYK) + _throw("tjDecodeYUV(): Cannot decode YUV images into CMYK pixels."); + + if(pitch==0) pitch=width*tjPixelSize[pixelFormat]; + + #ifndef JCS_EXTENSIONS + if(pixelFormat!=TJPF_GRAY) + { + rgbBuf=(unsigned char *)malloc(width*height*RGB_PIXELSIZE); + if(!rgbBuf) _throw("tjDecodeYUV(): Memory allocation failure"); + srcBuf=toRGB(srcBuf, width, pitch, height, pixelFormat, rgbBuf); + pitch=width*RGB_PIXELSIZE; + } + #endif + + dinfo->image_width=width; + dinfo->image_height=height; + + if(flags&TJFLAG_FORCEMMX) putenv("JSIMD_FORCEMMX=1"); + else if(flags&TJFLAG_FORCESSE) putenv("JSIMD_FORCESSE=1"); + else if(flags&TJFLAG_FORCESSE2) putenv("JSIMD_FORCESSE2=1"); + + yuvsize=tjBufSizeYUV2(width, pad, height, subsamp); + if(setDecodeDefaults(dinfo, pixelFormat, subsamp, flags)==-1) + { + retval=-1; goto bailout; + } + old_read_markers=dinfo->marker->read_markers; + dinfo->marker->read_markers=my_read_markers; + old_reset_marker_reader=dinfo->marker->reset_marker_reader; + dinfo->marker->reset_marker_reader=my_reset_marker_reader; + jpeg_read_header(dinfo, TRUE); + dinfo->marker->read_markers=old_read_markers; + dinfo->marker->reset_marker_reader=old_reset_marker_reader; + + if(setDecompDefaults(dinfo, pixelFormat, flags)==-1) + { + retval=-1; goto bailout; + } + jpeg_calc_output_dimensions(dinfo); + if(flags&TJFLAG_FASTUPSAMPLE) + { + dinfo->do_fancy_upsampling=FALSE; + if((subsamp==TJSAMP_422 || subsamp==TJSAMP_420) && pixelFormat!=TJPF_GRAY) + useMerged=1; + } + if(useMerged) + jinit_merged_upsampler(dinfo); + else + { + jinit_color_deconverter(dinfo); + jinit_upsampler(dinfo); + (*dinfo->cconvert->start_pass)(dinfo); + } + (*dinfo->upsample->start_pass)(dinfo); + + pw=PAD(width, dinfo->max_h_samp_factor); + ph=PAD(height, dinfo->max_v_samp_factor); + + if(pitch==0) pitch=dinfo->output_width*tjPixelSize[pixelFormat]; + + if((row_pointer=(JSAMPROW *)malloc(sizeof(JSAMPROW)*ph))==NULL) + _throw("tjDecodeYUV(): Memory allocation failure"); + for(i=0; inum_components; i++) + { + compptr=&dinfo->comp_info[i]; + _tmpbuf[i]=(JSAMPLE *)malloc(PAD(compptr->width_in_blocks*DCTSIZE, 16) + * compptr->v_samp_factor + 16); + if(!_tmpbuf[i]) _throw("tjDecodeYUV(): Memory allocation failure"); + tmpbuf[i]=(JSAMPROW *)malloc(sizeof(JSAMPROW)*compptr->v_samp_factor); + if(!tmpbuf[i]) _throw("tjDecodeYUV(): Memory allocation failure"); + for(row=0; rowv_samp_factor; row++) + { + unsigned char *_tmpbuf_aligned= + (unsigned char *)PAD((size_t)_tmpbuf[i], 16); + tmpbuf[i][row]=&_tmpbuf_aligned[ + PAD(compptr->width_in_blocks*DCTSIZE, 16) * row]; + } + cw[i]=pw*compptr->h_samp_factor/dinfo->max_h_samp_factor; + ch[i]=ph*compptr->v_samp_factor/dinfo->max_v_samp_factor; + inbuf[i]=(JSAMPROW *)malloc(sizeof(JSAMPROW)*ch[i]); + if(!inbuf[i]) _throw("tjDecodeYUV(): Memory allocation failure"); + for(row=0; rowmax_v_samp_factor) + { + JDIMENSION inrow=0, outrow=0; + for(i=0, compptr=dinfo->comp_info; inum_components; i++, compptr++) + jcopy_sample_rows(inbuf[i], + row*compptr->v_samp_factor/dinfo->max_v_samp_factor, tmpbuf[i], 0, + compptr->v_samp_factor, cw[i]); + (dinfo->upsample->upsample)(dinfo, tmpbuf, &inrow, + dinfo->max_v_samp_factor, &row_pointer[row], &outrow, + dinfo->max_v_samp_factor); + } + jpeg_abort_decompress(dinfo); + + bailout: + if(dinfo->global_state>DSTATE_START) jpeg_abort_decompress(dinfo); + #ifndef JCS_EXTENSIONS + if(rgbBuf) free(rgbBuf); + #endif + if(row_pointer) free(row_pointer); + for(i=0; i + * NOTE: Technically, the JPEG format uses the YCbCr colorspace, but per the + * convention of the digital video community, the TurboJPEG API uses "YUV" to + * refer to an image format consisting of Y, Cb, and Cr image planes. + * + * @param handle a handle to a TurboJPEG decompressor or transformer instance + * @param srcBuf pointer to an image buffer containing a YUV planar image to be + * decoded. The size of this buffer should match the value returned + * by #tjBufSizeYUV2() for the given image width, height, padding, and + * level of chrominance subsampling. + * @param pad Use this parameter to specify that the width of each line in each + * plane of the YUV source image is padded to the nearest multiple of + * this number of bytes (must be a power of 2.) + * @param subsamp the level of chrominance subsampling used in the YUV source + * image (see @ref TJSAMP "Chrominance subsampling options".) + * @param dstBuf pointer to an image buffer that will receive the decoded + * image. This buffer should normally be pitch * height + * bytes in size, but the dstBuf pointer can also be used to + * decode into a specific region of a larger buffer. + * @param width width (in pixels) of the source and destination images + * @param pitch bytes per line of the destination image. Normally, this should + * be width * #tjPixelSize[pixelFormat] if the destination + * image is unpadded, or #TJPAD(width * + * #tjPixelSize[pixelFormat]) if each line of the destination + * image should be padded to the nearest 32-bit boundary, as is the case + * for Windows bitmaps. You can also be clever and use the pitch + * parameter to skip lines, etc. Setting this parameter to 0 is the + * equivalent of setting it to width * + * #tjPixelSize[pixelFormat]. + * @param height height (in pixels) of the source and destination images + * @param pixelFormat pixel format of the destination image (see @ref TJPF + * "Pixel formats".) + * @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP + * "flags". + * + * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().) + */ +DLLEXPORT int DLLCALL tjDecodeYUV(tjhandle handle, unsigned char *srcBuf, + int pad, int subsamp, unsigned char *dstBuf, int width, int pitch, + int height, int pixelFormat, int flags); + + /** * Create a new TurboJPEG transformer instance. * From b861ef600c44aafbcc2db27d1d550bc4ad2cc2cf Mon Sep 17 00:00:00 2001 From: DRC Date: Fri, 28 Feb 2014 09:35:34 +0000 Subject: [PATCH 20/65] Fix unitialized value reported by valgrind (the upsampling routine used by 4:4:0 and 4:1:1 reads the value of component_index.) --- turbojpeg.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/turbojpeg.c b/turbojpeg.c index ee412c1c..0f0d1109 100644 --- a/turbojpeg.c +++ b/turbojpeg.c @@ -1235,6 +1235,8 @@ DLLEXPORT int DLLCALL tjDecompress(tjhandle handle, unsigned char *jpegBuf, static int setDecodeDefaults(struct jpeg_decompress_struct *dinfo, int pixelFormat, int subsamp, int flags) { + int i; + dinfo->scale_num=dinfo->scale_denom=1; if(subsamp==TJSAMP_GRAY) @@ -1254,15 +1256,14 @@ static int setDecodeDefaults(struct jpeg_decompress_struct *dinfo, dinfo->comp_info[0].h_samp_factor=tjMCUWidth[subsamp]/8; dinfo->comp_info[0].v_samp_factor=tjMCUHeight[subsamp]/8; + dinfo->comp_info[0].component_index=0; dinfo->cur_comp_info[0]=&dinfo->comp_info[0]; - if(dinfo->num_components==3) + for(i=1; inum_components; i++) { - dinfo->comp_info[1].h_samp_factor=1; - dinfo->comp_info[1].v_samp_factor=1; - dinfo->cur_comp_info[1]=&dinfo->comp_info[1]; - dinfo->comp_info[2].h_samp_factor=1; - dinfo->comp_info[2].v_samp_factor=1; - dinfo->cur_comp_info[2]=&dinfo->comp_info[2]; + dinfo->comp_info[i].h_samp_factor=1; + dinfo->comp_info[i].v_samp_factor=1; + dinfo->comp_info[i].component_index=i; + dinfo->cur_comp_info[i]=&dinfo->comp_info[i]; } return 0; From 89c9791c8e5cc8f52dbcc21be02e25933bcf14da Mon Sep 17 00:00:00 2001 From: DRC Date: Thu, 6 Mar 2014 09:26:49 +0000 Subject: [PATCH 21/65] Fix regression introduced in r1122 that caused SIMD detection to malfunction for ARM platforms (and probably ARM64 and MIPS as well.) --- acinclude.m4 | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index a02ad77f..40a9e52f 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -144,26 +144,26 @@ AC_DEFUN([AC_CHECK_COMPATIBLE_ARM_ASSEMBLER_IFELSE],[ ac_save_CFLAGS="$CFLAGS" CFLAGS="$CCASFLAGS -x assembler-with-cpp" CC="$CCAS" - AC_COMPILE_IFELSE([AC_LANG_SOURCE([ + AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ .text .fpu neon .arch armv7a .object_arch armv4 .arm pld [r0] - vmovn.u16 d0, q0])], ac_good_gnu_arm_assembler=yes) + vmovn.u16 d0, q0]])], ac_good_gnu_arm_assembler=yes) ac_use_gas_preprocessor=no if test "x$ac_good_gnu_arm_assembler" = "xno" ; then CC="gas-preprocessor.pl $CCAS" - AC_COMPILE_IFELSE([AC_LANG_SOURCE([ + AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ .text .fpu neon .arch armv7a .object_arch armv4 .arm pld [r0] - vmovn.u16 d0, q0])], ac_use_gas_preprocessor=yes) + vmovn.u16 d0, q0]])], ac_use_gas_preprocessor=yes) fi CFLAGS="$ac_save_CFLAGS" CC="$ac_save_CC" @@ -189,7 +189,7 @@ AC_DEFUN([AC_CHECK_COMPATIBLE_MIPSEL_ASSEMBLER_IFELSE],[ ac_save_CFLAGS="$CFLAGS" CFLAGS="$CCASFLAGS -mdspr2" - AC_COMPILE_IFELSE([AC_LANG_SOURCE([ + AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ int main () { @@ -201,7 +201,7 @@ AC_DEFUN([AC_CHECK_COMPATIBLE_MIPSEL_ASSEMBLER_IFELSE],[ ); return c; } - ])], have_mips_dspr2=yes) + ]])], have_mips_dspr2=yes) CFLAGS=$ac_save_CFLAGS if test "x$have_mips_dspr2" = "xyes" ; then @@ -217,16 +217,16 @@ AC_DEFUN([AC_CHECK_COMPATIBLE_ARM64_ASSEMBLER_IFELSE],[ ac_save_CFLAGS="$CFLAGS" CFLAGS="$CCASFLAGS -x assembler-with-cpp" CC="$CCAS" - AC_COMPILE_IFELSE([AC_LANG_SOURCE([ + AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ .text - movi v0.16b, [#100]])], ac_good_gnu_arm_assembler=yes) + movi v0.16b, #100]])], ac_good_gnu_arm_assembler=yes) ac_use_gas_preprocessor=no if test "x$ac_good_gnu_arm_assembler" = "xno" ; then CC="gas-preprocessor.pl $CCAS" - AC_COMPILE_IFELSE([AC_LANG_SOURCE([ + AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ .text - movi v0.16b, [#100]])], ac_use_gas_preprocessor=yes) + movi v0.16b, #100]])], ac_use_gas_preprocessor=yes) fi CFLAGS="$ac_save_CFLAGS" CC="$ac_save_CC" From 2409fb9d03ed88a68501d1c03e0243fba0c6a61c Mon Sep 17 00:00:00 2001 From: DRC Date: Thu, 6 Mar 2014 20:07:03 +0000 Subject: [PATCH 22/65] Oops. We need to call start_pass() on the color converter in order to allocate the conversion tables used by the plain C code. --- turbojpeg.c | 1 + 1 file changed, 1 insertion(+) diff --git a/turbojpeg.c b/turbojpeg.c index 0f0d1109..ec85eb54 100644 --- a/turbojpeg.c +++ b/turbojpeg.c @@ -768,6 +768,7 @@ DLLEXPORT int DLLCALL tjEncodeYUV3(tjhandle handle, unsigned char *srcBuf, jinit_c_master_control(cinfo, FALSE); jinit_color_converter(cinfo); jinit_downsampler(cinfo); + (*cinfo->cconvert->start_pass)(cinfo); pw=PAD(width, cinfo->max_h_samp_factor); ph=PAD(height, cinfo->max_v_samp_factor); From 897a525e3f9d3e9ec126e6a5a9583ac072c8f16d Mon Sep 17 00:00:00 2001 From: DRC Date: Fri, 7 Mar 2014 03:52:57 +0000 Subject: [PATCH 23/65] Go ahead and call jinit_master_decompress() rather than trying to reproduce its functionality. That function does a few things that we were missing, including allocating the range limit table used by the plain C color conversion code. --- turbojpeg.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/turbojpeg.c b/turbojpeg.c index ec85eb54..edcf882a 100644 --- a/turbojpeg.c +++ b/turbojpeg.c @@ -1255,16 +1255,15 @@ static int setDecodeDefaults(struct jpeg_decompress_struct *dinfo, (*dinfo->mem->alloc_small)((j_common_ptr)dinfo, JPOOL_IMAGE, dinfo->num_components*SIZEOF(jpeg_component_info)); - dinfo->comp_info[0].h_samp_factor=tjMCUWidth[subsamp]/8; - dinfo->comp_info[0].v_samp_factor=tjMCUHeight[subsamp]/8; - dinfo->comp_info[0].component_index=0; - dinfo->cur_comp_info[0]=&dinfo->comp_info[0]; - for(i=1; inum_components; i++) + for(i=0; inum_components; i++) { - dinfo->comp_info[i].h_samp_factor=1; - dinfo->comp_info[i].v_samp_factor=1; - dinfo->comp_info[i].component_index=i; - dinfo->cur_comp_info[i]=&dinfo->comp_info[i]; + jpeg_component_info *compptr=&dinfo->comp_info[i]; + compptr->h_samp_factor=(i==0)? tjMCUWidth[subsamp]/8:1; + compptr->v_samp_factor=(i==0)? tjMCUHeight[subsamp]/8:1; + compptr->component_index=i; + compptr->quant_tbl_no=compptr->dc_tbl_no=compptr->ac_tbl_no= + (i==0)? 0:1; + dinfo->cur_comp_info[i]=compptr; } return 0; @@ -1358,21 +1357,14 @@ DLLEXPORT int DLLCALL tjDecodeYUV(tjhandle handle, unsigned char *srcBuf, { retval=-1; goto bailout; } - jpeg_calc_output_dimensions(dinfo); if(flags&TJFLAG_FASTUPSAMPLE) { dinfo->do_fancy_upsampling=FALSE; if((subsamp==TJSAMP_422 || subsamp==TJSAMP_420) && pixelFormat!=TJPF_GRAY) useMerged=1; } - if(useMerged) - jinit_merged_upsampler(dinfo); - else - { - jinit_color_deconverter(dinfo); - jinit_upsampler(dinfo); - (*dinfo->cconvert->start_pass)(dinfo); - } + jinit_master_decompress(dinfo); + if(!useMerged) (*dinfo->cconvert->start_pass)(dinfo); (*dinfo->upsample->start_pass)(dinfo); pw=PAD(width, dinfo->max_h_samp_factor); From bac0f31e7c9b751e70beaf1ad64d0dbb9f6b122b Mon Sep 17 00:00:00 2001 From: DRC Date: Sat, 8 Mar 2014 20:32:37 +0000 Subject: [PATCH 24/65] Add a blank line before the alpha-enabled colorspace tests in order to improve readability --- tjunittest.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tjunittest.c b/tjunittest.c index 8bdd7210..bdb47b18 100644 --- a/tjunittest.c +++ b/tjunittest.c @@ -571,8 +571,11 @@ void doTest(int w, int h, const int *formats, int nformats, int subsamp, decompTest(dhandle, dstBuf, size, w, h, pf, basename, subsamp, flags); if(pf>=TJPF_RGBX && pf<=TJPF_XRGB) + { + printf("\n"); decompTest(dhandle, dstBuf, size, w, h, pf+(TJPF_RGBA-TJPF_RGBX), basename, subsamp, flags); + } printf("\n"); } } From 435f18d902c54a73630a9be971aae71d80e7e461 Mon Sep 17 00:00:00 2001 From: DRC Date: Sat, 8 Mar 2014 20:50:35 +0000 Subject: [PATCH 25/65] Silence valgrind false positives about uninitialized values. Even with this patch, valgrind still complains about uninitialized values when decompressing or decoding to a buffer with an alpha-enabled colorspace. Not sure why this happens, but it occurs in libjpeg-turbo 1.3 as well, and only when the x86/x86-64 SIMD code is being used. It is my belief that these remaining warnings are also false positives, because if the output buffer is memset to all 0's prior to invoking tjDecodeYUV()/tjDecompress(), no errors are reported. If any of the alpha channel bits were in fact not being initialized, then they would still be 0 after invoking tjDecodeYUV()/tjDecompress(), and TJUnitTest would report an error. --- tjunittest.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tjunittest.c b/tjunittest.c index bdb47b18..6920ea19 100644 --- a/tjunittest.c +++ b/tjunittest.c @@ -417,6 +417,7 @@ void compTest(tjhandle handle, unsigned char **dstBuf, if((yuvBuf=(unsigned char *)malloc(yuvSize))==NULL) _throw("Memory allocation failure"); + memset(yuvBuf, 0, yuvSize); printf("%s %s -> YUV %s ... ", pfStr, buStrLong, subNameLong[subsamp]); _tj(tjEncodeYUV3(handle, srcBuf, w, 0, h, pf, yuvBuf, pad, subsamp, @@ -478,6 +479,7 @@ void _decompTest(tjhandle handle, unsigned char *jpegBuf, if((yuvBuf=(unsigned char *)malloc(yuvSize))==NULL) _throw("Memory allocation failure"); + memset(yuvBuf, 0, yuvSize); printf("JPEG -> YUV %s ", subNameLong[subsamp]); if(sf.num!=1 || sf.denom!=1) From 8419f05afaaad037ab55aef5a226fecab2e52096 Mon Sep 17 00:00:00 2001 From: DRC Date: Mon, 10 Mar 2014 09:34:04 +0000 Subject: [PATCH 26/65] When tjDecodeYUV() is used with a "fresh" decompressor instance (one that hasn't been previously used to decompress a JPEG image), then it needs comps_in_scan, data_precision, and the quantization tables to be defined. This patch also extends TJUnitTest to check for this error. --- tjunittest.c | 10 ++++++++-- turbojpeg.c | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/tjunittest.c b/tjunittest.c index 6920ea19..d2d3e983 100644 --- a/tjunittest.c +++ b/tjunittest.c @@ -414,14 +414,17 @@ void compTest(tjhandle handle, unsigned char **dstBuf, { unsigned long yuvSize=tjBufSizeYUV2(w, pad, h, subsamp); tjscalingfactor sf={1, 1}; + tjhandle handle2=tjInitCompress(); + if(!handle2) _throwtj(); if((yuvBuf=(unsigned char *)malloc(yuvSize))==NULL) _throw("Memory allocation failure"); memset(yuvBuf, 0, yuvSize); printf("%s %s -> YUV %s ... ", pfStr, buStrLong, subNameLong[subsamp]); - _tj(tjEncodeYUV3(handle, srcBuf, w, 0, h, pf, yuvBuf, pad, subsamp, + _tj(tjEncodeYUV3(handle2, srcBuf, w, 0, h, pf, yuvBuf, pad, subsamp, flags)); + tjDestroy(handle2); snprintf(tempStr, 1024, "%s_enc_%s_%s_%s.yuv", basename, pfStr, buStr, subName[subsamp]); writeJPEG(yuvBuf, yuvSize, tempStr); @@ -476,6 +479,8 @@ void _decompTest(tjhandle handle, unsigned char *jpegBuf, { unsigned long yuvSize=tjBufSizeYUV2(scaledWidth, pad, scaledHeight, subsamp); + tjhandle handle2=tjInitDecompress(); + if(!handle2) _throwtj(); if((yuvBuf=(unsigned char *)malloc(yuvSize))==NULL) _throw("Memory allocation failure"); @@ -493,8 +498,9 @@ void _decompTest(tjhandle handle, unsigned char *jpegBuf, printf("YUV %s -> %s %s ... ", subNameLong[subsamp], pixFormatStr[pf], (flags&TJFLAG_BOTTOMUP)? "Bottom-Up":"Top-Down "); - _tj(tjDecodeYUV(handle, yuvBuf, pad, subsamp, dstBuf, scaledWidth, 0, + _tj(tjDecodeYUV(handle2, yuvBuf, pad, subsamp, dstBuf, scaledWidth, 0, scaledHeight, pf, flags)); + tjDestroy(handle2); } else { diff --git a/turbojpeg.c b/turbojpeg.c index edcf882a..8ccb15e8 100644 --- a/turbojpeg.c +++ b/turbojpeg.c @@ -1242,12 +1242,12 @@ static int setDecodeDefaults(struct jpeg_decompress_struct *dinfo, if(subsamp==TJSAMP_GRAY) { - dinfo->num_components=1; + dinfo->num_components=dinfo->comps_in_scan=1; dinfo->jpeg_color_space=JCS_GRAYSCALE; } else { - dinfo->num_components=3; + dinfo->num_components=dinfo->comps_in_scan=3; dinfo->jpeg_color_space=JCS_YCbCr; } @@ -1265,6 +1265,12 @@ static int setDecodeDefaults(struct jpeg_decompress_struct *dinfo, (i==0)? 0:1; dinfo->cur_comp_info[i]=compptr; } + dinfo->data_precision=8; + for(i=0; i<2; i++) + { + if(dinfo->quant_tbl_ptrs[i]==NULL) + dinfo->quant_tbl_ptrs[i]=jpeg_alloc_quant_table((j_common_ptr)dinfo); + } return 0; } From adb33bb1a44dfefef1b43a9637a923c96b59594d Mon Sep 17 00:00:00 2001 From: DRC Date: Mon, 10 Mar 2014 20:11:56 +0000 Subject: [PATCH 27/65] Fix additional uninitialized values reported by valgrind --- turbojpeg.c | 1 + 1 file changed, 1 insertion(+) diff --git a/turbojpeg.c b/turbojpeg.c index 8ccb15e8..41c8aac8 100644 --- a/turbojpeg.c +++ b/turbojpeg.c @@ -1261,6 +1261,7 @@ static int setDecodeDefaults(struct jpeg_decompress_struct *dinfo, compptr->h_samp_factor=(i==0)? tjMCUWidth[subsamp]/8:1; compptr->v_samp_factor=(i==0)? tjMCUHeight[subsamp]/8:1; compptr->component_index=i; + compptr->component_id=i+1; compptr->quant_tbl_no=compptr->dc_tbl_no=compptr->ac_tbl_no= (i==0)? 0:1; dinfo->cur_comp_info[i]=compptr; From 1cdf41108b7914bc723e61cb92f03c760a07392d Mon Sep 17 00:00:00 2001 From: DRC Date: Mon, 10 Mar 2014 20:14:53 +0000 Subject: [PATCH 28/65] For now, punt on trying to support fancy upsampling in tjDecodeYUV(). Fancy upsampling requires context rows and other refinements, which are difficult to implement correctly with the algorithm we're using. Longer-term, supporting fancy upsampling would probably require using the main buffer that libjpeg allocates. --- turbojpeg.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/turbojpeg.c b/turbojpeg.c index 41c8aac8..5aee2e81 100644 --- a/turbojpeg.c +++ b/turbojpeg.c @@ -1293,7 +1293,7 @@ DLLEXPORT int DLLCALL tjDecodeYUV(tjhandle handle, unsigned char *srcBuf, int i, retval=0; JSAMPROW *row_pointer=NULL; JSAMPLE *_tmpbuf[MAX_COMPONENTS]; JSAMPROW *tmpbuf[MAX_COMPONENTS], *inbuf[MAX_COMPONENTS]; - int row, pw, ph, cw[MAX_COMPONENTS], ch[MAX_COMPONENTS], useMerged=0; + int row, pw, ph, cw[MAX_COMPONENTS], ch[MAX_COMPONENTS]; JSAMPLE *ptr=srcBuf; unsigned long yuvsize=0; jpeg_component_info *compptr; @@ -1364,14 +1364,8 @@ DLLEXPORT int DLLCALL tjDecodeYUV(tjhandle handle, unsigned char *srcBuf, { retval=-1; goto bailout; } - if(flags&TJFLAG_FASTUPSAMPLE) - { - dinfo->do_fancy_upsampling=FALSE; - if((subsamp==TJSAMP_422 || subsamp==TJSAMP_420) && pixelFormat!=TJPF_GRAY) - useMerged=1; - } + dinfo->do_fancy_upsampling=FALSE; jinit_master_decompress(dinfo); - if(!useMerged) (*dinfo->cconvert->start_pass)(dinfo); (*dinfo->upsample->start_pass)(dinfo); pw=PAD(width, dinfo->max_h_samp_factor); From e4552b814329f1a52c4762319a642ba591899a41 Mon Sep 17 00:00:00 2001 From: DRC Date: Tue, 11 Mar 2014 06:24:46 +0000 Subject: [PATCH 29/65] Fix the build of the Java classes when using MSVC 2010 and later. Something in the recesses of my brain is telling me that I tried this before and it failed under some circumstances, but it must have been a bug in an older CMake implementation. CMake 2.8.8 and later seem to work fine with this patch. This patch also updates the minimum required version to 2.8.8, because 2.8.8 fixed another issue that was preventing the SIMD code from building under MSVC 2010 and later. --- CMakeLists.txt | 2 +- ChangeLog.txt | 3 +++ java/CMakeLists.txt | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 95677203..f88cf4fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ # Setup # -cmake_minimum_required(VERSION 2.6) +cmake_minimum_required(VERSION 2.8.8) project(libjpeg-turbo C) set(VERSION 1.3.80) diff --git a/ChangeLog.txt b/ChangeLog.txt index ac3db638..5c830163 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -61,6 +61,9 @@ libjpeg-turbo to use uninitialized memory during decompression. when calling the TurboJPEG YUV encoding function with a very small (< 5x5) source image, and added a unit test to check for this error. +[6] The Java classes should now build properly under Visual Studio 2010 and +later. + 1.3.0 ===== diff --git a/java/CMakeLists.txt b/java/CMakeLists.txt index 87db412e..19127e30 100644 --- a/java/CMakeLists.txt +++ b/java/CMakeLists.txt @@ -13,7 +13,7 @@ set(JAVA_CLASSNAMES org/libjpegturbo/turbojpeg/TJ TJBench) if(MSVC_IDE) - set(OBJDIR "${CMAKE_CURRENT_BINARY_DIR}/$(OutDir)") + set(OBJDIR "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}") else() set(OBJDIR ${CMAKE_CURRENT_BINARY_DIR}) endif() From 7f0bceb586ae888194cf28bc1e75391f2e625141 Mon Sep 17 00:00:00 2001 From: DRC Date: Tue, 11 Mar 2014 06:31:09 +0000 Subject: [PATCH 30/65] Silence warning in CMake 2.8.12 and later --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index f88cf4fe..d80933e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,7 @@ # cmake_minimum_required(VERSION 2.8.8) +cmake_policy(SET CMP0022 OLD) project(libjpeg-turbo C) set(VERSION 1.3.80) From 885da7cef956bb5d8d3eb03a8b6239015d01aacc Mon Sep 17 00:00:00 2001 From: DRC Date: Wed, 12 Mar 2014 06:17:12 +0000 Subject: [PATCH 31/65] Fix a segfault that would occur in decompress-only mode if -alloc was specified without -tile. --- tjbench.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tjbench.c b/tjbench.c index 7a7bc920..b412eddd 100644 --- a/tjbench.c +++ b/tjbench.c @@ -567,7 +567,7 @@ void dodecomptest(char *filename) _throwunix("allocating JPEG size array"); memset(jpegsize, 0, sizeof(unsigned long)*ntilesw*ntilesh); - if((flags&TJFLAG_NOREALLOC)!=0) + if((flags&TJFLAG_NOREALLOC)!=0 || !dotile) for(i=0; i Date: Wed, 12 Mar 2014 06:51:39 +0000 Subject: [PATCH 32/65] Since we now have a complete set of YUV functions, TJBench can be greatly simplified. It now tests YUV encoding/decoding as an intermediate step of JPEG compression/decompression, which eliminates the need for a separate YUV mode. Several other things have been streamlined in the process. --- tjbench.c | 549 +++++++++++++++++++++++------------------------------- 1 file changed, 237 insertions(+), 312 deletions(-) diff --git a/tjbench.c b/tjbench.c index b412eddd..1d1c504a 100644 --- a/tjbench.c +++ b/tjbench.c @@ -1,5 +1,5 @@ /* - * Copyright (C)2009-2013 D. R. Commander. All Rights Reserved. + * Copyright (C)2009-2014 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: @@ -45,9 +45,8 @@ #define _throwtj(m) _throw(m, tjGetErrorStr()) #define _throwbmp(m) _throw(m, bmpgeterr()) -enum {YUVENCODE=1, YUVDECODE, YUVCOMPRESS}; -int flags=TJFLAG_NOREALLOC, componly=0, decomponly=0, yuv=0, quiet=0, dotile=0, - pf=TJPF_BGR, yuvpad=1; +int flags=TJFLAG_NOREALLOC, componly=0, decomponly=0, doyuv=0, quiet=0, + dotile=0, pf=TJPF_BGR, yuvpad=1, warmup=1; char *ext="ppm"; const char *pixFormatStr[TJ_NUMPF]= { @@ -102,21 +101,20 @@ int dummyDCTFilter(short *coeffs, tjregion arrayRegion, tjregion planeRegion, /* Decompression test */ -int decomptest(unsigned char *srcbuf, unsigned char **jpegbuf, +int decomp(unsigned char *srcbuf, unsigned char **jpegbuf, unsigned long *jpegsize, unsigned char *dstbuf, int w, int h, int subsamp, int jpegqual, char *filename, int tilew, int tileh) { char tempstr[1024], sizestr[20]="\0", qualstr[6]="\0", *ptr; FILE *file=NULL; tjhandle handle=NULL; - int row, col, i, dstbufalloc=0, retval=0; - double start, elapsed; + int row, col, iter=0, dstbufalloc=0, retval=0; + double elapsed, elapsedDecode; int ps=tjPixelSize[pf]; int scaledw=TJSCALED(w, sf); int scaledh=TJSCALED(h, sf); - int yuvsize=tjBufSizeYUV2(scaledw, yuvpad, scaledh, subsamp), bufsize; int pitch=scaledw*ps; int ntilesw=(w+tilew-1)/tilew, ntilesh=(h+tileh-1)/tileh; - unsigned char *dstptr, *dstptr2; + unsigned char *dstptr, *dstptr2, *yuvbuf=NULL; if(jpegqual>0) { @@ -127,64 +125,92 @@ int decomptest(unsigned char *srcbuf, unsigned char **jpegbuf, if((handle=tjInitDecompress())==NULL) _throwtj("executing tjInitDecompress()"); - bufsize=(yuv==YUVDECODE? yuvsize:pitch*scaledh); if(dstbuf==NULL) { - if((dstbuf=(unsigned char *)malloc(bufsize)) == NULL) - _throwunix("allocating image buffer"); + if((dstbuf=(unsigned char *)malloc(pitch*scaledh))==NULL) + _throwunix("allocating destination buffer"); dstbufalloc=1; } /* Set the destination buffer to gray so we know whether the decompressor attempted to write to it */ - memset(dstbuf, 127, bufsize); + memset(dstbuf, 127, pitch*scaledh); - /* Execute once to preload cache */ - if(yuv==YUVDECODE) + if(doyuv) { - if(tjDecompressToYUV2(handle, jpegbuf[0], jpegsize[0], dstbuf, scaledw, - yuvpad, scaledh, flags)==-1) - _throwtj("executing tjDecompressToYUV2()"); + int width=dotile? tilew:scaledw; + int height=dotile? tileh:scaledh; + int yuvsize=tjBufSizeYUV2(width, yuvpad, height, subsamp); + if((yuvbuf=(unsigned char *)malloc(yuvsize))==NULL) + _throwunix("allocating YUV buffer"); + memset(yuvbuf, 127, yuvsize); } - else if(tjDecompress2(handle, jpegbuf[0], jpegsize[0], dstbuf, scaledw, - pitch, scaledh, pf, flags)==-1) - _throwtj("executing tjDecompress2()"); /* Benchmark */ - for(i=0, start=gettime(); (elapsed=gettime()-start)=0) elapsedDecode+=gettime()-startDecode; + } + else + if(tjDecompress2(handle, jpegbuf[tile], jpegsize[tile], dstptr2, + width, pitch, height, pf, flags)==-1) + _throwtj("executing tjDecompress2()"); } } + iter++; + if(iter>=1) + { + elapsed+=gettime()-start; + if(elapsed>=benchtime) break; + } } + if(doyuv) elapsed-=elapsedDecode; if(tjDestroy(handle)==-1) _throwtj("executing tjDestroy()"); handle=NULL; if(quiet) { - printf("%s\n", - sigfig((double)(w*h)/1000000.*(double)i/elapsed, 4, tempstr, 1024)); + printf("%-6s ", + sigfig((double)(w*h)/1000000.*(double)iter/elapsed, 4, tempstr, 1024)); + if(doyuv) + printf("%s", + sigfig((double)(w*h)/1000000.*(double)iter/elapsedDecode, 4, tempstr, + 1024)); + printf("\n"); } else { - printf("D--> Frame rate: %f fps\n", (double)i/elapsed); - printf(" Dest. throughput: %f Megapixels/sec\n", - (double)(w*h)/1000000.*(double)i/elapsed); + printf("%s --> Frame rate: %f fps\n", + doyuv? "Decomp to YUV":"Decompress ", (double)iter/elapsed); + printf(" Throughput: %f Megapixels/sec\n", + (double)(w*h)/1000000.*(double)iter/elapsed); + if(doyuv) + { + printf("YUV Decode --> Frame rate:  %f fps\n", + (double)iter/elapsedDecode); + printf(" Throughput: %f Megapixels/sec\n", + (double)(w*h)/1000000.*(double)iter/elapsedDecode); + } } if(sf.num!=1 || sf.denom!=1) snprintf(sizestr, 20, "%d_%d", sf.num, sf.denom); @@ -197,155 +223,68 @@ int decomptest(unsigned char *srcbuf, unsigned char **jpegbuf, snprintf(tempstr, 1024, "%s_%s%s_%s.%s", filename, subName[subsamp], qualstr, sizestr, ext); - if(yuv==YUVDECODE) + if(savebmp(tempstr, dstbuf, scaledw, scaledh, pf, + (flags&TJFLAG_BOTTOMUP)!=0)==-1) + _throwbmp("saving bitmap"); + ptr=strrchr(tempstr, '.'); + snprintf(ptr, 1024-(ptr-tempstr), "-err.%s", ext); + if(srcbuf && sf.num==1 && sf.denom==1) { - if((file=fopen(tempstr, "wb"))==NULL) - _throwunix("opening YUV image for output"); - if(fwrite(dstbuf, yuvsize, 1, file)!=1) - _throwunix("writing YUV image"); - fclose(file); file=NULL; - } - else - { - if(savebmp(tempstr, dstbuf, scaledw, scaledh, pf, + if(!quiet) printf("Compression error written to %s.\n", tempstr); + if(subsamp==TJ_GRAYSCALE) + { + int index, index2; + for(row=0, index=0; row255) y=255; if(y<0) y=0; + dstbuf[rindex]=abs(dstbuf[rindex]-y); + dstbuf[gindex]=abs(dstbuf[gindex]-y); + dstbuf[bindex]=abs(dstbuf[bindex]-y); + } + } + } + else + { + for(row=0; row255) y=255; if(y<0) y=0; - dstbuf[rindex]=abs(dstbuf[rindex]-y); - dstbuf[gindex]=abs(dstbuf[gindex]-y); - dstbuf[bindex]=abs(dstbuf[bindex]-y); - } - } - } - else - { - for(row=0; row>>>> %s (%s) <--> YUV %s <<<<<\n", pixFormatStr[pf], - (flags&TJFLAG_BOTTOMUP)? "Bottom-up":"Top-down", subNameLong[subsamp]); - - if(quiet==1) - printf("%s\t%s\t%s\tN/A\t", pixFormatStr[pf], - (flags&TJFLAG_BOTTOMUP)? "BU":"TD", subNameLong[subsamp]); - - if((handle=tjInitCompress())==NULL) - _throwtj("executing tjInitCompress()"); - - /* Execute once to preload cache */ - if(tjEncodeYUV2(handle, srcbuf, w, 0, h, pf, dstbuf, subsamp, flags)==-1) - _throwtj("executing tjEncodeYUV2()"); - - /* Benchmark */ - for(i=0, start=gettime(); (elapsed=gettime()-start) Frame rate: %f fps\n", (double)i/elapsed); - printf(" Output image size: %d bytes\n", yuvsize); - printf(" Compression ratio: %f:1\n", - (double)(w*h*ps)/(double)yuvsize); - printf(" Source throughput: %f Megapixels/sec\n", - (double)(w*h)/1000000.*(double)i/elapsed); - printf(" Output bit stream: %f Megabits/sec\n", - (double)yuvsize*8./1000000.*(double)i/elapsed); - } - snprintf(tempstr, 1024, "%s_%s.yuv", filename, subName[subsamp]); - if((file=fopen(tempstr, "wb"))==NULL) - _throwunix("opening reference image"); - if(fwrite(dstbuf, yuvsize, 1, file)!=1) - _throwunix("writing reference image"); - fclose(file); file=NULL; - if(!quiet) printf("Reference image written to %s\n", tempstr); - - bailout: - if(file) {fclose(file); file=NULL;} - if(dstbuf) {free(dstbuf); dstbuf=NULL;} - if(handle) {tjDestroy(handle); handle=NULL;} - return; -} - - -void dotest(unsigned char *srcbuf, int w, int h, int subsamp, int jpegqual, - char *filename) -{ - char tempstr[1024], tempstr2[80]; - FILE *file=NULL; tjhandle handle=NULL; - unsigned char **jpegbuf=NULL, *tmpbuf=NULL, *srcptr, *srcptr2; - double start, elapsed; + unsigned char **jpegbuf=NULL, *yuvbuf=NULL, *tmpbuf=NULL, *srcptr, *srcptr2; + double start, elapsed, elapsedEncode; int totaljpegsize=0, row, col, i, tilew=w, tileh=h, retval=0; + int iter, yuvsize=0; unsigned long *jpegsize=NULL; - int ps=(yuv==YUVCOMPRESS)? 3:tjPixelSize[pf]; + int ps=tjPixelSize[pf]; int ntilesw=1, ntilesh=1, pitch=w*ps; - const char *pfStr=(yuv==YUVCOMPRESS)? "YUV":pixFormatStr[pf]; - - if(yuv==YUVENCODE) {dotestyuv(srcbuf, w, h, subsamp, filename); return;} + const char *pfStr=pixFormatStr[pf]; if((tmpbuf=(unsigned char *)malloc(pitch*h)) == NULL) _throwunix("allocating temporary image buffer"); @@ -379,33 +318,27 @@ void dotest(unsigned char *srcbuf, int w, int h, int subsamp, int jpegqual, /* Compression test */ if(quiet==1) - printf("%s\t%s\t%s\t%d\t", pfStr, (flags&TJFLAG_BOTTOMUP)? "BU":"TD", - subNameLong[subsamp], jpegqual); - if(yuv!=YUVCOMPRESS) - for(i=0; i=0) elapsedEncode+=gettime()-startEncode; + if(tjCompressFromYUV(handle, yuvbuf, width, yuvpad, height, subsamp, &jpegbuf[tile], &jpegsize[tile], jpegqual, flags)==-1) _throwtj("executing tjCompressFromYUV()"); } @@ -428,32 +366,58 @@ void dotest(unsigned char *srcbuf, int w, int h, int subsamp, int jpegqual, totaljpegsize+=jpegsize[tile]; } } + iter++; + if(iter>=1) + { + elapsed+=gettime()-start; + if(elapsed>=benchtime) break; + } } + if(doyuv) elapsed-=elapsedEncode; if(tjDestroy(handle)==-1) _throwtj("executing tjDestroy()"); handle=NULL; - if(quiet==1) printf("%-4d %-4d\t", tilew, tileh); + if(quiet==1) printf("%-5d %-5d ", tilew, tileh); if(quiet) { - printf("%s%c%s%c", - sigfig((double)(w*h)/1000000.*(double)i/elapsed, 4, tempstr, 1024), - quiet==2? '\n':'\t', + if(doyuv) + printf("%-6s%s", + sigfig((double)(w*h)/1000000.*(double)iter/elapsedEncode, 4, tempstr, + 1024), quiet==2? "\n":" "); + printf("%-6s%s", + sigfig((double)(w*h)/1000000.*(double)iter/elapsed, 4, tempstr, 1024), + quiet==2? "\n":" "); + printf("%-6s%s", sigfig((double)(w*h*ps)/(double)totaljpegsize, 4, tempstr2, 80), - quiet==2? '\n':'\t'); + quiet==2? "\n":" "); } else { printf("\n%s size: %d x %d\n", dotile? "Tile":"Image", tilew, tileh); - printf("C--> Frame rate: %f fps\n", (double)i/elapsed); - printf(" Output image size: %d bytes\n", totaljpegsize); - printf(" Compression ratio: %f:1\n", + if(doyuv) + { + printf("Encode YUV --> Frame rate: %f fps\n", + (double)iter/elapsedEncode); + printf(" Output image size: %d bytes\n", yuvsize); + printf(" Compression ratio: %f:1\n", + (double)(w*h*ps)/(double)yuvsize); + printf(" Throughput: %f Megapixels/sec\n", + (double)(w*h)/1000000.*(double)iter/elapsedEncode); + printf(" Output bit stream: %f Megabits/sec\n", + (double)yuvsize*8./1000000.*(double)iter/elapsedEncode); + } + printf("%s --> Frame rate: %f fps\n", + doyuv? "Comp from YUV":"Compress ", (double)iter/elapsed); + printf(" Output image size: %d bytes\n", + totaljpegsize); + printf(" Compression ratio: %f:1\n", (double)(w*h*ps)/(double)totaljpegsize); - printf(" Source throughput: %f Megapixels/sec\n", - (double)(w*h)/1000000.*(double)i/elapsed); - printf(" Output bit stream: %f Megabits/sec\n", - (double)totaljpegsize*8./1000000.*(double)i/elapsed); + printf(" Throughput: %f Megapixels/sec\n", + (double)(w*h)/1000000.*(double)iter/elapsed); + printf(" Output bit stream: %f Megabits/sec\n", + (double)totaljpegsize*8./1000000.*(double)iter/elapsed); } if(tilew==w && tileh==h) { @@ -470,7 +434,7 @@ void dotest(unsigned char *srcbuf, int w, int h, int subsamp, int jpegqual, /* Decompression test */ if(!componly) { - if(decomptest(srcbuf, jpegbuf, jpegsize, tmpbuf, w, h, subsamp, jpegqual, + if(decomp(srcbuf, jpegbuf, jpegsize, tmpbuf, w, h, subsamp, jpegqual, filename, tilew, tileh)==-1) goto bailout; } @@ -481,6 +445,10 @@ void dotest(unsigned char *srcbuf, int w, int h, int subsamp, int jpegqual, } free(jpegbuf); jpegbuf=NULL; free(jpegsize); jpegsize=NULL; + if(doyuv) + { + free(yuvbuf); yuvbuf=NULL; + } if(tilew==w && tileh==h) break; } @@ -495,6 +463,7 @@ void dotest(unsigned char *srcbuf, int w, int h, int subsamp, int jpegqual, } free(jpegbuf); jpegbuf=NULL; } + if(yuvbuf) {free(yuvbuf); yuvbuf=NULL;} if(jpegsize) {free(jpegsize); jpegsize=NULL;} if(tmpbuf) {free(tmpbuf); tmpbuf=NULL;} if(handle) {tjDestroy(handle); handle=NULL;} @@ -502,7 +471,7 @@ void dotest(unsigned char *srcbuf, int w, int h, int subsamp, int jpegqual, } -void dodecomptest(char *filename) +void decompTest(char *filename) { FILE *file=NULL; tjhandle handle=NULL; unsigned char **jpegbuf=NULL, *srcbuf=NULL; @@ -538,20 +507,18 @@ void dodecomptest(char *filename) if(quiet==1) { printf("All performance values in Mpixels/sec\n\n"); - printf("Bitmap\tBitmap\tJPEG\tJPEG\t%s %s \tXform\tComp\tDecomp\n", + printf("Bitmap JPEG JPEG %s %s Xform Comp Decomp ", dotile? "Tile ":"Image", dotile? "Tile ":"Image"); - printf("Format\tOrder\tCS\tSubsamp\tWidth Height\tPerf \tRatio\tPerf\n\n"); + if(doyuv) printf("Decode"); + printf("\n"); + printf("Format CS Subsamp Width Height Perf Ratio Perf "); + if(doyuv) printf("Perf"); + printf("\n\n"); } else if(!quiet) - { - if(yuv==YUVDECODE) - printf(">>>>> JPEG %s --> YUV <<<<<\n", - formatName(subsamp, cs, tempstr)); - else - printf(">>>>> JPEG %s --> %s (%s) <<<<<\n", - formatName(subsamp, cs, tempstr), pixFormatStr[pf], - (flags&TJFLAG_BOTTOMUP)? "Bottom-up":"Top-down"); - } + printf(">>>>> JPEG %s --> %s (%s) <<<<<\n", + formatName(subsamp, cs, tempstr), pixFormatStr[pf], + (flags&TJFLAG_BOTTOMUP)? "Bottom-up":"Top-down"); for(tilew=dotile? 16:w, tileh=dotile? 16:h; ; tilew*=2, tileh*=2) { @@ -586,9 +553,9 @@ void dodecomptest(char *filename) } else if(quiet==1) { - printf("%s\t%s\t%s\t%s\t", pixFormatStr[pf], + printf("%-4s (%s) %-5s %-5s ", pixFormatStr[pf], (flags&TJFLAG_BOTTOMUP)? "BU":"TD", csName[cs], subNameLong[subsamp]); - printf("%-4d %-4d\t", tilew, tileh); + printf("%-5d %-5d ", tilew, tileh); } _subsamp=subsamp; @@ -647,27 +614,27 @@ void dodecomptest(char *filename) if(quiet) { - printf("%s%c%s%c", + printf("%-6s%s%-6s%s", sigfig((double)(w*h)/1000000./elapsed, 4, tempstr, 80), - quiet==2? '\n':'\t', + quiet==2? "\n":" ", sigfig((double)(w*h*ps)/(double)totaljpegsize, 4, tempstr2, 80), - quiet==2? '\n':'\t'); + quiet==2? "\n":" "); } else if(!quiet) { - printf("X--> Frame rate: %f fps\n", 1.0/elapsed); - printf(" Output image size: %lu bytes\n", totaljpegsize); - printf(" Compression ratio: %f:1\n", + printf("Transform --> Frame rate: %f fps\n", 1.0/elapsed); + printf(" Output image size: %lu bytes\n", totaljpegsize); + printf(" Compression ratio: %f:1\n", (double)(w*h*ps)/(double)totaljpegsize); - printf(" Source throughput: %f Megapixels/sec\n", + printf(" Throughput: %f Megapixels/sec\n", (double)(w*h)/1000000./elapsed); - printf(" Output bit stream: %f Megabits/sec\n", + printf(" Output bit stream: %f Megabits/sec\n", (double)totaljpegsize*8./1000000./elapsed); } } else { - if(quiet==1) printf("N/A\tN/A\t"); + if(quiet==1) printf("N/A N/A "); jpegsize[0]=srcsize; memcpy(jpegbuf[0], srcbuf, srcsize); } @@ -676,7 +643,7 @@ void dodecomptest(char *filename) if(h==tileh) _tileh=_h; if(!(xformopt&TJXOPT_NOOUTPUT)) { - if(decomptest(NULL, jpegbuf, jpegsize, NULL, _w, _h, _subsamp, 0, + if(decomp(NULL, jpegbuf, jpegsize, NULL, _w, _h, _subsamp, 0, filename, _tilew, _tileh)==-1) goto bailout; } @@ -714,7 +681,7 @@ void usage(char *progname) { int i; printf("USAGE: %s\n", progname); - printf(" [options]\n\n"); + printf(" [options]\n\n"); printf(" %s\n", progname); printf(" [options]\n\n"); printf("Options:\n\n"); @@ -731,22 +698,16 @@ void usage(char *progname) printf(" codec\n"); printf("-accuratedct = Use the most accurate DCT/IDCT algorithms available in the\n"); printf(" underlying codec\n"); - printf("-subsamp = if compressing a JPEG image from a YUV planar source image,\n"); - printf(" this specifies the level of chrominance subsampling used in the source\n"); - printf(" image. Otherwise, this specifies the level of chrominance subsampling\n"); - printf(" to use in the JPEG destination image. = 444, 422, 440, 420, 411,\n"); - printf(" or GRAY\n"); + printf("-subsamp = When testing JPEG compression, this option specifies the level\n"); + printf(" of chrominance subsampling to use ( = 444, 422, 440, 420, 411, or\n"); + printf(" GRAY). The default is to test Grayscale, 4:2:0, 4:2:2, and 4:4:4 in\n"); + printf(" sequence.\n"); printf("-quiet = Output results in tabular rather than verbose format\n"); - printf("-yuvencode = Encode RGB input as planar YUV rather than compressing as JPEG\n"); - printf("-yuvdecode = Decode JPEG image to planar YUV rather than RGB\n"); - printf("-yuvsize WxH = if compressing a JPEG image from a YUV planar source image, this\n"); - printf(" specifies the width and height of the source image.\n"); - printf("-yuvpad

= if compressing a JPEG image from a YUV planar source image, this\n"); - printf(" specifies the number of bytes to which each row of each plane in the\n"); - printf(" source image is padded. If decompressing a JPEG image to a YUV planar\n"); - printf(" destination image, this specifies the row padding for each plane of the\n"); - printf(" destination image. (default=1)\n"); - printf("-scale M/N = scale down the width/height of the decompressed JPEG image by a\n"); + printf("-yuv = Test YUV encoding/decoding functions\n"); + printf("-yuvpad

= If testing YUV encoding/decoding, this specifies the number of\n"); + printf(" bytes to which each row of each plane in the intermediate YUV image is\n"); + printf(" padded (default=1)\n"); + printf("-scale M/N = Scale down the width/height of the decompressed JPEG image by a\n"); printf(" factor of M/N (M/N = "); for(i=0; i = Run each benchmark for at least seconds (default = 5.0)\n"); + printf("-warmup = Execute each benchmark times to prime the cache before\n"); + printf(" taking performance measurements (default = 1.)\n"); printf("-componly = Stop after running compression tests. Do not test decompression.\n\n"); printf("NOTE: If the quality is specified as a range (e.g. 90-100), a separate\n"); printf("test will be performed for all quality values in the range.\n\n"); @@ -789,29 +752,11 @@ int main(int argc, char *argv[]) { if(!strcasecmp(temp, ".bmp")) ext="bmp"; if(!strcasecmp(temp, ".jpg") || !strcasecmp(temp, ".jpeg")) decomponly=1; - if(!strcasecmp(temp, ".yuv")) yuv=YUVCOMPRESS; } printf("\n"); - if(argc>minarg) - { - for(i=minarg; i0.0) benchtime=temp; else usage(argv[0]); } + if(!strcasecmp(argv[i], "-warmup") && i=0) + { + warmup=temp; + printf("Warmup runs = %d\n\n", warmup); + } + else usage(argv[0]); + } if(!strcmp(argv[i], "-?")) usage(argv[0]); if(!strcasecmp(argv[i], "-alloc")) flags&=(~TJFLAG_NOREALLOC); if(!strcasecmp(argv[i], "-bmp")) ext="bmp"; - if(!strcasecmp(argv[i], "-yuvsize") && i=1 - && temp2>=1) - { - w=temp1; h=temp2; - } - else usage(argv[0]); + printf("Testing YUV planar encoding/decoding\n\n"); + doyuv=1; } if(!strcasecmp(argv[i], "-yuvpad") && i=TJ_NUMSAMP) - _throw("opening YUV image file", - "YUV image size and/or subsampling not specified"); - if((file=fopen(argv[1], "rb"))==NULL) - _throwunix("opening YUV image file"); - if(fseek(file, 0, SEEK_END)<0 || - (srcsize=ftell(file))==(unsigned long)-1) - _throwunix("determining YUV image file size"); - if(srcsize!=tjBufSizeYUV2(w, yuvpad, h, subsamp)) - _throw("opening YUV image file", "YUV image file is the wrong size"); - if((srcbuf=(unsigned char *)malloc(srcsize))==NULL) - _throwunix("allocating memory for YUV image"); - if(fseek(file, 0, SEEK_SET)<0) - _throwunix("setting YUV image file position"); - if(fread(srcbuf, srcsize, 1, file)<1) - _throwunix("reading YUV data"); - fclose(file); file=NULL; - } - else - { - if(loadbmp(argv[1], &srcbuf, &w, &h, pf, (flags&TJFLAG_BOTTOMUP)!=0)==-1) - _throwbmp("loading bitmap"); - } + if(loadbmp(argv[1], &srcbuf, &w, &h, pf, (flags&TJFLAG_BOTTOMUP)!=0)==-1) + _throwbmp("loading bitmap"); temp=strrchr(argv[1], '.'); if(temp!=NULL) *temp='\0'; } @@ -982,36 +899,44 @@ int main(int argc, char *argv[]) if(quiet==1 && !decomponly) { printf("All performance values in Mpixels/sec\n\n"); - printf("Bitmap\tBitmap\tJPEG\tJPEG\t%s %s \tComp\tComp\tDecomp\n", + printf("Bitmap JPEG JPEG %s %s ", dotile? "Tile ":"Image", dotile? "Tile ":"Image"); - printf("Format\tOrder\tSubsamp\tQual\tWidth Height\tPerf \tRatio\tPerf\n\n"); + if(doyuv) printf("Encode "); + printf("Comp Comp Decomp "); + if(doyuv) printf("Decode"); + printf("\n"); + printf("Format Subsamp Qual Width Height "); + if(doyuv) printf("Perf "); + printf("Perf Ratio Perf "); + if(doyuv) printf("Perf"); + printf("\n\n"); } if(decomponly) { - dodecomptest(argv[1]); + decompTest(argv[1]); printf("\n"); goto bailout; } - if(yuv==YUVCOMPRESS || (subsamp>=0 && subsamp=0 && subsamp=minqual; i--) - dotest(srcbuf, w, h, subsamp, i, argv[1]); + fullTest(srcbuf, w, h, subsamp, i, argv[1]); printf("\n"); } else { for(i=maxqual; i>=minqual; i--) - dotest(srcbuf, w, h, TJSAMP_GRAY, i, argv[1]); + fullTest(srcbuf, w, h, TJSAMP_GRAY, i, argv[1]); printf("\n"); for(i=maxqual; i>=minqual; i--) - dotest(srcbuf, w, h, TJSAMP_420, i, argv[1]); + fullTest(srcbuf, w, h, TJSAMP_420, i, argv[1]); printf("\n"); for(i=maxqual; i>=minqual; i--) - dotest(srcbuf, w, h, TJSAMP_422, i, argv[1]); + fullTest(srcbuf, w, h, TJSAMP_422, i, argv[1]); printf("\n"); for(i=maxqual; i>=minqual; i--) - dotest(srcbuf, w, h, TJSAMP_444, i, argv[1]); + fullTest(srcbuf, w, h, TJSAMP_444, i, argv[1]); printf("\n"); } From 88ae091ca1ce3ef564ab81e6069ebc8908c5fc38 Mon Sep 17 00:00:00 2001 From: DRC Date: Wed, 12 Mar 2014 07:16:17 +0000 Subject: [PATCH 33/65] Fix a couple of output formatting issues --- tjbench.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tjbench.c b/tjbench.c index 1d1c504a..454faa5b 100644 --- a/tjbench.c +++ b/tjbench.c @@ -190,13 +190,14 @@ int decomp(unsigned char *srcbuf, unsigned char **jpegbuf, if(quiet) { - printf("%-6s ", - sigfig((double)(w*h)/1000000.*(double)iter/elapsed, 4, tempstr, 1024)); + printf("%-6s%s", + sigfig((double)(w*h)/1000000.*(double)iter/elapsed, 4, tempstr, 1024), + quiet==2? "\n":" "); if(doyuv) - printf("%s", + printf("%s\n", sigfig((double)(w*h)/1000000.*(double)iter/elapsedDecode, 4, tempstr, 1024)); - printf("\n"); + else if(quiet!=2) printf("\n"); } else { From 2ed71383904dd743a396aec487dfc68347abc82b Mon Sep 17 00:00:00 2001 From: DRC Date: Wed, 12 Mar 2014 07:17:23 +0000 Subject: [PATCH 34/65] Execute warmup runs with tjTransform() as well --- tjbench.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/tjbench.c b/tjbench.c index 454faa5b..707501d7 100644 --- a/tjbench.c +++ b/tjbench.c @@ -481,7 +481,7 @@ void decompTest(char *filename) int w=0, h=0, subsamp=-1, cs=-1, _w, _h, _tilew, _tileh, _ntilesw, _ntilesh, _subsamp; char *temp=NULL, tempstr[80], tempstr2[80]; - int row, col, i, tilew, tileh, ntilesw=1, ntilesh=1, retval=0; + int row, col, i, iter, tilew, tileh, ntilesw=1, ntilesh=1, retval=0; double start, elapsed; int ps=tjPixelSize[pf], tile; @@ -602,11 +602,21 @@ void decompTest(char *filename) } } - start=gettime(); - if(tjTransform(handle, srcbuf, srcsize, _ntilesw*_ntilesh, jpegbuf, - jpegsize, t, flags)==-1) - _throwtj("executing tjTransform()"); - elapsed=gettime()-start; + iter=-warmup; + elapsed=0.; + while(1) + { + start=gettime(); + if(tjTransform(handle, srcbuf, srcsize, _ntilesw*_ntilesh, jpegbuf, + jpegsize, t, flags)==-1) + _throwtj("executing tjTransform()"); + iter++; + if(iter>=1) + { + elapsed+=gettime()-start; + if(elapsed>=benchtime) break; + } + } free(t); t=NULL; From dbebf635b06ea6367a72798296c0a53cc3160096 Mon Sep 17 00:00:00 2001 From: DRC Date: Thu, 13 Mar 2014 08:32:20 +0000 Subject: [PATCH 35/65] Whitespace tweaks --- bmp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bmp.c b/bmp.c index 4caefb41..fa4479da 100644 --- a/bmp.c +++ b/bmp.c @@ -169,7 +169,7 @@ int loadbmp(char *filename, unsigned char **buf, int *w, int *h, nlines); } cinfo.next_scanline+=nlines; - } + } (*src->finish_input)(&cinfo, src); @@ -236,7 +236,7 @@ int savebmp(char *filename, unsigned char *buf, int w, int h, int srcpf, _throw("savebmp(): Could not initialize PPM writer"); } - dst->output_file=file; + dst->output_file=file; (*dst->start_output)(&dinfo, dst); (*dinfo.mem->realize_virt_arrays)((j_common_ptr)&dinfo); @@ -258,7 +258,7 @@ int savebmp(char *filename, unsigned char *buf, int w, int h, int srcpf, } (*dst->put_pixel_rows)(&dinfo, dst, nlines); dinfo.output_scanline+=nlines; - } + } (*dst->finish_output)(&dinfo, dst); From 593bb84e41e8fed8779379a2490c3d75bd2a3788 Mon Sep 17 00:00:00 2001 From: DRC Date: Thu, 13 Mar 2014 20:33:43 +0000 Subject: [PATCH 36/65] If we have transformed a 4:2:2 or 4:4:0 image in any way that transposes the horizontal and vertical dimensions, then we need to inform the decompression function that the subsampling type has changed. Otherwise, tjDecodeYUV() will not produce correct results. --- tjbench.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tjbench.c b/tjbench.c index 707501d7..4e28f06e 100644 --- a/tjbench.c +++ b/tjbench.c @@ -584,6 +584,13 @@ void decompTest(char *filename) _ntilesw=(_w+_tilew-1)/_tilew; _ntilesh=(_h+_tileh-1)/_tileh; + if(xformop==TJXOP_TRANSPOSE || xformop==TJXOP_TRANSVERSE + || xformop==TJXOP_ROT90 || xformop==TJXOP_ROT270) + { + if(_subsamp==TJSAMP_422) _subsamp=TJSAMP_440; + else if(_subsamp==TJSAMP_440) _subsamp=TJSAMP_422; + } + for(row=0, tile=0; row<_ntilesh; row++) { for(col=0; col<_ntilesw; col++, tile++) From 022952d37d0437061476cdcf38a1ebba6b824450 Mon Sep 17 00:00:00 2001 From: DRC Date: Thu, 13 Mar 2014 20:48:38 +0000 Subject: [PATCH 37/65] Add a mode to tjbenchtest for testing the YUV encoding/decoding functions --- Makefile.am | 1 + tjbenchtest.in | 97 ++++++++++++++++++++++++++++++++------------------ 2 files changed, 63 insertions(+), 35 deletions(-) diff --git a/Makefile.am b/Makefile.am index 2a68a968..0e0527a2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -327,6 +327,7 @@ testclean: tjtest: sh ./tjbenchtest + sh ./tjbenchtest -yuv if WITH_JAVA sh ./tjbenchtest.java endif diff --git a/tjbenchtest.in b/tjbenchtest.in index 72b93f8e..e143fcdd 100755 --- a/tjbenchtest.in +++ b/tjbenchtest.in @@ -25,6 +25,8 @@ IMGDIR=@srcdir@/testimages OUTDIR=__tjbenchtest_output EXEDIR=. BMPARG= +NSARG= +YUVARG= if [ "$EXT" = "bmp" ]; then BMPARG=-bmp; fi if [ -d $OUTDIR ]; then @@ -34,33 +36,58 @@ mkdir -p $OUTDIR exec >$EXEDIR/tjbenchtest.log +if [ $# -gt 0 ]; then + if [ "$1" = "-yuv" ]; then + NSARG=-nosmooth + YUVARG=-yuv + +# NOTE: The combination of tjEncodeYUV*() and tjCompressFromYUV*() does not +# always produce bitwise-identical results to tjCompress*() if subsampling is +# enabled. In both cases, if the image width or height are not evenly +# divisible by the MCU width/height, then the bottom and/or right edge are +# expanded. However, the libjpeg code performs this expansion prior to +# downsampling, and TurboJPEG performs it in tjCompressFromYUV*(), which is +# after downsampling. Thus, the two will agree only if the width/height along +# each downsampled dimension is an odd number or is evenly divisible by the MCU +# width/height. This disagreement basically amounts to a round-off error, but +# there is no easy way around it, so for now, we just test the only image that +# works. (NOTE: nightshot_iso_100 seems to exhibit a similar phenomenon when +# decompressing. If it is scaled by a factor, such as 7/8, that causes the +# scaled width to no longer be an even multiple of the MCU width, then the +# combination of tjDecompressToYUV*() and tjDecodeYUV*() do not produce +# bitwise-identical results to tjDecompress*(). This latter phenomenon is not +# yet fully understood.) + IMAGES="vgl_6548_0026a.${EXT}" + fi +fi + # Standard tests for image in $IMAGES; do cp $IMGDIR/$image $OUTDIR basename=`basename $image .${EXT}` - $EXEDIR/cjpeg -quality 95 -dct fast -grayscale $IMGDIR/${basename}.${EXT} >$OUTDIR/${basename}_GRAY_fast_cjpeg.jpg - $EXEDIR/cjpeg -quality 95 -dct fast -sample 2x2 $IMGDIR/${basename}.${EXT} >$OUTDIR/${basename}_420_fast_cjpeg.jpg - $EXEDIR/cjpeg -quality 95 -dct fast -sample 2x1 $IMGDIR/${basename}.${EXT} >$OUTDIR/${basename}_422_fast_cjpeg.jpg - $EXEDIR/cjpeg -quality 95 -dct fast -sample 1x1 $IMGDIR/${basename}.${EXT} >$OUTDIR/${basename}_444_fast_cjpeg.jpg - $EXEDIR/cjpeg -quality 95 -dct int -grayscale $IMGDIR/${basename}.${EXT} >$OUTDIR/${basename}_GRAY_accurate_cjpeg.jpg - $EXEDIR/cjpeg -quality 95 -dct int -sample 2x2 $IMGDIR/${basename}.${EXT} >$OUTDIR/${basename}_420_accurate_cjpeg.jpg - $EXEDIR/cjpeg -quality 95 -dct int -sample 2x1 $IMGDIR/${basename}.${EXT} >$OUTDIR/${basename}_422_accurate_cjpeg.jpg - $EXEDIR/cjpeg -quality 95 -dct int -sample 1x1 $IMGDIR/${basename}.${EXT} >$OUTDIR/${basename}_444_accurate_cjpeg.jpg + runme $EXEDIR/cjpeg -quality 95 -dct fast -grayscale -outfile $OUTDIR/${basename}_GRAY_fast_cjpeg.jpg $IMGDIR/${basename}.${EXT} + runme $EXEDIR/cjpeg -quality 95 -dct fast -sample 2x2 -outfile $OUTDIR/${basename}_420_fast_cjpeg.jpg $IMGDIR/${basename}.${EXT} + runme $EXEDIR/cjpeg -quality 95 -dct fast -sample 2x1 -outfile $OUTDIR/${basename}_422_fast_cjpeg.jpg $IMGDIR/${basename}.${EXT} + runme $EXEDIR/cjpeg -quality 95 -dct fast -sample 1x1 -outfile $OUTDIR/${basename}_444_fast_cjpeg.jpg $IMGDIR/${basename}.${EXT} + runme $EXEDIR/cjpeg -quality 95 -dct int -grayscale -outfile $OUTDIR/${basename}_GRAY_accurate_cjpeg.jpg $IMGDIR/${basename}.${EXT} + runme $EXEDIR/cjpeg -quality 95 -dct int -sample 2x2 -outfile $OUTDIR/${basename}_420_accurate_cjpeg.jpg $IMGDIR/${basename}.${EXT} + runme $EXEDIR/cjpeg -quality 95 -dct int -sample 2x1 -outfile $OUTDIR/${basename}_422_accurate_cjpeg.jpg $IMGDIR/${basename}.${EXT} + runme $EXEDIR/cjpeg -quality 95 -dct int -sample 1x1 -outfile $OUTDIR/${basename}_444_accurate_cjpeg.jpg $IMGDIR/${basename}.${EXT} for samp in GRAY 420 422 444; do - $EXEDIR/djpeg -rgb $BMPARG $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg >$OUTDIR/${basename}_${samp}_default_djpeg.${EXT} - $EXEDIR/djpeg -dct fast -rgb $BMPARG $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg >$OUTDIR/${basename}_${samp}_fast_djpeg.${EXT} - $EXEDIR/djpeg -dct int -rgb $BMPARG $OUTDIR/${basename}_${samp}_accurate_cjpeg.jpg >$OUTDIR/${basename}_${samp}_accurate_djpeg.${EXT} + runme $EXEDIR/djpeg -rgb $NSARG $BMPARG -outfile $OUTDIR/${basename}_${samp}_default_djpeg.${EXT} $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg + runme $EXEDIR/djpeg -dct fast -rgb $NSARG $BMPARG -outfile $OUTDIR/${basename}_${samp}_fast_djpeg.${EXT} $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg + runme $EXEDIR/djpeg -dct int -rgb $NSARG $BMPARG -outfile $OUTDIR/${basename}_${samp}_accurate_djpeg.${EXT} $OUTDIR/${basename}_${samp}_accurate_cjpeg.jpg done for samp in 420 422; do - $EXEDIR/djpeg -nosmooth $BMPARG $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg >$OUTDIR/${basename}_${samp}_default_nosmooth_djpeg.${EXT} - $EXEDIR/djpeg -dct fast -nosmooth $BMPARG $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg >$OUTDIR/${basename}_${samp}_fast_nosmooth_djpeg.${EXT} - $EXEDIR/djpeg -dct int -nosmooth $BMPARG $OUTDIR/${basename}_${samp}_accurate_cjpeg.jpg >$OUTDIR/${basename}_${samp}_accurate_nosmooth_djpeg.${EXT} + runme $EXEDIR/djpeg -nosmooth $BMPARG -outfile $OUTDIR/${basename}_${samp}_default_nosmooth_djpeg.${EXT} $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg + runme $EXEDIR/djpeg -dct fast -nosmooth $BMPARG -outfile $OUTDIR/${basename}_${samp}_fast_nosmooth_djpeg.${EXT} $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg + runme $EXEDIR/djpeg -dct int -nosmooth $BMPARG -outfile $OUTDIR/${basename}_${samp}_accurate_nosmooth_djpeg.${EXT} $OUTDIR/${basename}_${samp}_accurate_cjpeg.jpg done # Compression for dct in accurate fast; do - runme $EXEDIR/tjbench $OUTDIR/$image 95 -rgb -quiet -benchtime 0.01 -${dct}dct + runme $EXEDIR/tjbench $OUTDIR/$image 95 -rgb -quiet -benchtime 0.01 -warmup 0 -${dct}dct $YUVARG for samp in GRAY 420 422 444; do runme cmp $OUTDIR/${basename}_${samp}_Q95.jpg $OUTDIR/${basename}_${samp}_${dct}_cjpeg.jpg done @@ -73,7 +100,7 @@ for image in $IMAGES; do fi # Tiled compression & decompression - runme $EXEDIR/tjbench $OUTDIR/$image 95 -rgb -tile -quiet -benchtime 0.01 ${dctarg} + runme $EXEDIR/tjbench $OUTDIR/$image 95 -rgb -tile -quiet -benchtime 0.01 -warmup 0 ${dctarg} $YUVARG for samp in GRAY 444; do for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].${EXT} \ $OUTDIR/${basename}_${samp}_Q95_full.${EXT}; do @@ -81,7 +108,7 @@ for image in $IMAGES; do rm $i done done - runme $EXEDIR/tjbench $OUTDIR/$image 95 -rgb -tile -quiet -benchtime 0.01 -fastupsample ${dctarg} + runme $EXEDIR/tjbench $OUTDIR/$image 95 -rgb -tile -quiet -benchtime 0.01 -warmup 0 -fastupsample ${dctarg} $YUVARG for samp in 420 422; do for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].${EXT} \ $OUTDIR/${basename}_${samp}_Q95_full.${EXT}; do @@ -92,7 +119,7 @@ for image in $IMAGES; do # Tiled decompression for samp in GRAY 444; do - runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -tile -quiet -benchtime 0.01 ${dctarg} + runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -tile -quiet -benchtime 0.01 -warmup 0 ${dctarg} $YUVARG for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].${EXT} \ $OUTDIR/${basename}_${samp}_Q95_full.${EXT}; do runme cmp $i $OUTDIR/${basename}_${samp}_${dct}_djpeg.${EXT} @@ -100,7 +127,7 @@ for image in $IMAGES; do done done for samp in 420 422; do - runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -tile -quiet -benchtime 0.01 -fastupsample ${dctarg} + runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -tile -quiet -benchtime 0.01 -warmup 0 -fastupsample ${dctarg} $YUVARG for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].${EXT} \ $OUTDIR/${basename}_${samp}_Q95_full.${EXT}; do runme cmp $i $OUTDIR/${basename}_${samp}_${dct}_nosmooth_djpeg.${EXT} @@ -113,8 +140,8 @@ for image in $IMAGES; do for scale in 2_1 15_8 7_4 13_8 3_2 11_8 5_4 9_8 7_8 3_4 5_8 1_2 3_8 1_4 1_8; do scalearg=`echo $scale | sed s@_@/@g` for samp in GRAY 420 422 444; do - $EXEDIR/djpeg -rgb -scale ${scalearg} $BMPARG $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg >$OUTDIR/${basename}_${samp}_${scale}_djpeg.${EXT} - runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -scale ${scalearg} -quiet -benchtime 0.01 + runme $EXEDIR/djpeg -rgb -scale ${scalearg} $NSARG $BMPARG -outfile $OUTDIR/${basename}_${samp}_${scale}_djpeg.${EXT} $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg + runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -scale ${scalearg} -quiet -benchtime 0.01 -warmup 0 $YUVARG runme cmp $OUTDIR/${basename}_${samp}_Q95_${scale}.${EXT} $OUTDIR/${basename}_${samp}_${scale}_djpeg.${EXT} rm $OUTDIR/${basename}_${samp}_Q95_${scale}.${EXT} done @@ -122,18 +149,18 @@ for image in $IMAGES; do # Transforms for samp in GRAY 420 422 444; do - $EXEDIR/jpegtran -flip horizontal -trim $OUTDIR/${basename}_${samp}_Q95.jpg >$OUTDIR/${basename}_${samp}_hflip_jpegtran.jpg - $EXEDIR/jpegtran -flip vertical -trim $OUTDIR/${basename}_${samp}_Q95.jpg >$OUTDIR/${basename}_${samp}_vflip_jpegtran.jpg - $EXEDIR/jpegtran -transpose -trim $OUTDIR/${basename}_${samp}_Q95.jpg >$OUTDIR/${basename}_${samp}_transpose_jpegtran.jpg - $EXEDIR/jpegtran -transverse -trim $OUTDIR/${basename}_${samp}_Q95.jpg >$OUTDIR/${basename}_${samp}_transverse_jpegtran.jpg - $EXEDIR/jpegtran -rotate 90 -trim $OUTDIR/${basename}_${samp}_Q95.jpg >$OUTDIR/${basename}_${samp}_rot90_jpegtran.jpg - $EXEDIR/jpegtran -rotate 180 -trim $OUTDIR/${basename}_${samp}_Q95.jpg >$OUTDIR/${basename}_${samp}_rot180_jpegtran.jpg - $EXEDIR/jpegtran -rotate 270 -trim $OUTDIR/${basename}_${samp}_Q95.jpg >$OUTDIR/${basename}_${samp}_rot270_jpegtran.jpg + runme $EXEDIR/jpegtran -flip horizontal -trim -outfile $OUTDIR/${basename}_${samp}_hflip_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg + runme $EXEDIR/jpegtran -flip vertical -trim -outfile $OUTDIR/${basename}_${samp}_vflip_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg + runme $EXEDIR/jpegtran -transpose -trim -outfile $OUTDIR/${basename}_${samp}_transpose_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg + runme $EXEDIR/jpegtran -transverse -trim -outfile $OUTDIR/${basename}_${samp}_transverse_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg + runme $EXEDIR/jpegtran -rotate 90 -trim -outfile $OUTDIR/${basename}_${samp}_rot90_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg + runme $EXEDIR/jpegtran -rotate 180 -trim -outfile $OUTDIR/${basename}_${samp}_rot180_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg + runme $EXEDIR/jpegtran -rotate 270 -trim -outfile $OUTDIR/${basename}_${samp}_rot270_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg done for xform in hflip vflip transpose transverse rot90 rot180 rot270; do for samp in GRAY 444; do - $EXEDIR/djpeg -rgb $BMPARG $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg >$OUTDIR/${basename}_${samp}_${xform}_jpegtran.${EXT} - runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -$xform -tile -quiet -benchtime 0.01 + runme $EXEDIR/djpeg -rgb $BMPARG -outfile $OUTDIR/${basename}_${samp}_${xform}_jpegtran.${EXT} $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg + runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -$xform -tile -quiet -benchtime 0.01 -warmup 0 $YUVARG for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].${EXT} \ $OUTDIR/${basename}_${samp}_Q95_full.${EXT}; do runme cmp $i $OUTDIR/${basename}_${samp}_${xform}_jpegtran.${EXT} @@ -141,8 +168,8 @@ for image in $IMAGES; do done done for samp in 420 422; do - $EXEDIR/djpeg -nosmooth -rgb $BMPARG $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg >$OUTDIR/${basename}_${samp}_${xform}_jpegtran.${EXT} - runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -$xform -tile -quiet -benchtime 0.01 -fastupsample + runme $EXEDIR/djpeg -nosmooth -rgb $BMPARG -outfile $OUTDIR/${basename}_${samp}_${xform}_jpegtran.${EXT} $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg + runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -$xform -tile -quiet -benchtime 0.01 -warmup 0 -fastupsample $YUVARG for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].${EXT} \ $OUTDIR/${basename}_${samp}_Q95_full.${EXT}; do runme cmp $i $OUTDIR/${basename}_${samp}_${xform}_jpegtran.${EXT} @@ -154,7 +181,7 @@ for image in $IMAGES; do # Grayscale transform for xform in hflip vflip transpose transverse rot90 rot180 rot270; do for samp in GRAY 444 422 420; do - runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -$xform -tile -quiet -benchtime 0.01 -grayscale + runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -$xform -tile -quiet -benchtime 0.01 -warmup 0 -grayscale $YUVARG for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].${EXT} \ $OUTDIR/${basename}_${samp}_Q95_full.${EXT}; do runme cmp $i $OUTDIR/${basename}_GRAY_${xform}_jpegtran.${EXT} @@ -168,8 +195,8 @@ for image in $IMAGES; do for samp in GRAY 444 422 420; do for scale in 2_1 15_8 7_4 13_8 3_2 11_8 5_4 9_8 7_8 3_4 5_8 1_2 3_8 1_4 1_8; do scalearg=`echo $scale | sed s@_@/@g` - $EXEDIR/djpeg -rgb -scale ${scalearg} $BMPARG $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg >$OUTDIR/${basename}_${samp}_${xform}_${scale}_jpegtran.${EXT} - runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -$xform -scale ${scalearg} -quiet -benchtime 0.01 + runme $EXEDIR/djpeg -rgb -scale ${scalearg} $NSARG $BMPARG -outfile $OUTDIR/${basename}_${samp}_${xform}_${scale}_jpegtran.${EXT} $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg + runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -$xform -scale ${scalearg} -quiet -benchtime 0.01 -warmup 0 $YUVARG runme cmp $OUTDIR/${basename}_${samp}_Q95_${scale}.${EXT} $OUTDIR/${basename}_${samp}_${xform}_${scale}_jpegtran.${EXT} rm $OUTDIR/${basename}_${samp}_Q95_${scale}.${EXT} done From 3aa498b9e1d51ce04d748f68022678f72679c13f Mon Sep 17 00:00:00 2001 From: DRC Date: Thu, 13 Mar 2014 21:19:12 +0000 Subject: [PATCH 38/65] Actually, the issue with nightshot_iso_100 is unrelated to the image size. Reducing the size to 128x95, the same size as vgl_6548_0026, does not eliminate the problem. The issue seems to always occur when decompression scaling is enabled. It is unclear at this point whether this is a bug or expected behavior, but the pixels generated by the split decompression functions appear correct. They are just slightly different (but not visibly so) from the pixels generated by the monolithic decompression function. --- tjbenchtest.in | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tjbenchtest.in b/tjbenchtest.in index e143fcdd..1ebd0b8f 100755 --- a/tjbenchtest.in +++ b/tjbenchtest.in @@ -51,12 +51,12 @@ if [ $# -gt 0 ]; then # each downsampled dimension is an odd number or is evenly divisible by the MCU # width/height. This disagreement basically amounts to a round-off error, but # there is no easy way around it, so for now, we just test the only image that -# works. (NOTE: nightshot_iso_100 seems to exhibit a similar phenomenon when -# decompressing. If it is scaled by a factor, such as 7/8, that causes the -# scaled width to no longer be an even multiple of the MCU width, then the -# combination of tjDecompressToYUV*() and tjDecodeYUV*() do not produce -# bitwise-identical results to tjDecompress*(). This latter phenomenon is not -# yet fully understood.) +# works. (NOTE: nightshot_iso_100 does not suffer from the above issue, but +# it suffers from an unrelated problem whereby the combination of +# tjDecompressToYUV*() and tjDecodeYUV*() do not produce bitwise-identical +# results to tjDecompress*() if decompression scaling is enabled. This latter +# phenomenon is not yet fully understood but is also believed to be some sort +# of round-off error.) IMAGES="vgl_6548_0026a.${EXT}" fi fi From 5d4f2feeed8c05fcbbe8ae1c4e2883a68ba3d23f Mon Sep 17 00:00:00 2001 From: DRC Date: Fri, 14 Mar 2014 04:15:43 +0000 Subject: [PATCH 39/65] Oops. This code should not have been removed. It is necessary for generating the error images. --- tjbench.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tjbench.c b/tjbench.c index 4e28f06e..3c8f3463 100644 --- a/tjbench.c +++ b/tjbench.c @@ -321,6 +321,8 @@ void fullTest(unsigned char *srcbuf, int w, int h, int subsamp, int jpegqual, if(quiet==1) printf("%-4s (%s) %-5s %-3d ", pfStr, (flags&TJFLAG_BOTTOMUP)? "BU":"TD", subNameLong[subsamp], jpegqual); + for(i=0; i Date: Fri, 14 Mar 2014 04:27:03 +0000 Subject: [PATCH 40/65] Formatting tweak --- java/TJUnitTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/TJUnitTest.java b/java/TJUnitTest.java index a6ee73eb..39414407 100644 --- a/java/TJUnitTest.java +++ b/java/TJUnitTest.java @@ -1049,7 +1049,7 @@ public class TJUnitTest { if (!bi) bufSizeTest(); if (doyuv && !bi) { - System.out.print("\n--------------------\n\n"); + System.out.print("\n--------------------\n\n"); yuv = YUVDECODE; doTest(48, 48, onlyRGB, TJ.SAMP_444, "javatest_yuv0"); doTest(35, 39, onlyRGB, TJ.SAMP_444, "javatest_yuv1"); From b0073a2851b614aee283e2e6077261f51a1d6587 Mon Sep 17 00:00:00 2001 From: DRC Date: Fri, 14 Mar 2014 04:32:03 +0000 Subject: [PATCH 41/65] Remove benchmarks. They were originally intended as a way of measuring overhead for small compress/decompress operations, but using TJBench with a small image is a better way to accomplish that. --- java/TJUnitTest.java | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/java/TJUnitTest.java b/java/TJUnitTest.java index 39414407..f7eef663 100644 --- a/java/TJUnitTest.java +++ b/java/TJUnitTest.java @@ -152,10 +152,6 @@ public class TJUnitTest { return "Unknown"; } - private static double getTime() { - return (double)System.nanoTime() / 1.0e9; - } - private static void initBuf(byte[] buf, int w, int pitch, int h, int pf, int flags) throws Exception { int roffset = TJ.getRedOffset(pf); @@ -697,7 +693,6 @@ public class TJUnitTest { String buStrLong = (flags & TJ.FLAG_BOTTOMUP) != 0 ? "Bottom-Up" : "Top-Down "; String buStr = (flags & TJ.FLAG_BOTTOMUP) != 0 ? "BU" : "TD"; - double t; int size = 0, ps, imgType = pf; if (yuv == YUVDECODE) { @@ -738,7 +733,6 @@ public class TJUnitTest { } Arrays.fill(dstBuf, (byte)0); - t = getTime(); tjc.setSubsamp(subsamp); tjc.setJPEGQuality(jpegQual); tjc.setYUVPad(pad); @@ -758,7 +752,6 @@ public class TJUnitTest { tjc.compress(dstBuf, flags); } size = tjc.getCompressedSize(); - t = getTime() - t; if (yuv == YUVENCODE) tempstr = baseName + "_enc_" + pfStr + "_" + buStr + "_" + @@ -778,8 +771,7 @@ public class TJUnitTest { } } else System.out.print("Done."); - System.out.format(" %.6f ms\n", t * 1000.); - System.out.println(" Result in " + tempstr); + System.out.println("\n Result in " + tempstr); return size; } @@ -789,7 +781,6 @@ public class TJUnitTest { String baseName, int subsamp, int flags, TJScalingFactor sf) throws Exception { String pfStr, tempstr; - double t; int scaledWidth = sf.getScaled(w); int scaledHeight = sf.getScaled(h); int temp1, temp2, imgType = pf; @@ -821,7 +812,6 @@ public class TJUnitTest { else System.out.print("... "); - t = getTime(); tjd.setJPEGImage(jpegBuf, jpegSize); if (tjd.getWidth() != w || tjd.getHeight() != h || tjd.getSubsamp() != subsamp) @@ -842,7 +832,6 @@ public class TJUnitTest { else dstBuf = tjd.decompress(scaledWidth, 0, scaledHeight, pf, flags); } - t = getTime() - t; if (bi) { tempstr = baseName + "_dec_" + pfStr + "_" + @@ -871,7 +860,7 @@ public class TJUnitTest { exitStatus = -1; } } - System.out.format(" %.6f ms\n", t * 1000.); + System.out.print("\n"); } private static void decompTest(TJDecompressor tjd, byte[] jpegBuf, From 80d2fe24c88ccf0fcb117115c51ce3afe000ef95 Mon Sep 17 00:00:00 2001 From: DRC Date: Fri, 14 Mar 2014 08:53:33 +0000 Subject: [PATCH 42/65] Streamline the BufferedImage functionality in the compressor so that it works the same way as compressing a "normal" image, and deprecate the old BufferedImage methods and other redundant methods. Eliminate the use of deprecated features in the test programs. --- java/TJBench.java | 26 +- java/TJExample.java | 8 +- java/TJUnitTest.java | 29 +- java/doc/deprecated-list.html | 44 +++ java/doc/index-all.html | 29 +- .../libjpegturbo/turbojpeg/TJCompressor.html | 184 ++++++--- .../libjpegturbo/turbojpeg/TJCompressor.java | 360 ++++++++---------- 7 files changed, 373 insertions(+), 307 deletions(-) diff --git a/java/TJBench.java b/java/TJBench.java index 5257a1b5..50cbadfb 100644 --- a/java/TJBench.java +++ b/java/TJBench.java @@ -165,7 +165,7 @@ class TJBench { if (yuv == YUVDECODE) tjd.decompressToYUV(dstBuf, scaledw, yuvpad, scaledh, flags); else - tjd.decompress(dstBuf, scaledw, pitch, scaledh, pf, flags); + tjd.decompress(dstBuf, 0, 0, scaledw, pitch, scaledh, pf, flags); /* Benchmark */ for (i = 0, start = getTime(); (elapsed = getTime() - start) < benchTime; @@ -259,7 +259,7 @@ class TJBench { int ps = TJ.getPixelSize(pf), i; int yuvSize = 0; - yuvSize = TJ.bufSizeYUV(w, h, subsamp); + yuvSize = TJ.bufSizeYUV(w, yuvpad, h, subsamp); dstBuf = new byte[yuvSize]; if (quiet == 0) @@ -273,7 +273,7 @@ class TJBench { (flags & TJ.FLAG_BOTTOMUP) != 0 ? "BU" : "TD", subNameLong[subsamp]); - tjc = new TJCompressor(srcBuf, w, 0, h, pf); + tjc = new TJCompressor(srcBuf, 0, 0, w, 0, h, pf); tjc.setSubsamp(subsamp); /* Execute once to preload cache */ @@ -362,7 +362,7 @@ class TJBench { if (yuv == YUVCOMPRESS) tjc.setSourceImageYUV(srcBuf, tilew, yuvpad, tileh); else - tjc.setSourceImage(srcBuf, tilew, pitch, tileh, pf); + tjc.setSourceImage(srcBuf, 0, 0, tilew, pitch, tileh, pf); tjc.setJPEGQuality(jpegQual); tjc.setSubsamp(subsamp); @@ -618,8 +618,6 @@ class TJBench { System.out.println("-bottomup = Test bottom-up compression/decompression"); System.out.println("-tile = Test performance of the codec when the image is encoded as separate"); System.out.println(" tiles of varying sizes."); - System.out.println("-forcemmx, -forcesse, -forcesse2, -forcesse3 ="); - System.out.println(" Force MMX, SSE, SSE2, or SSE3 code paths in the underlying codec"); System.out.println("-rgb, -bgr, -rgbx, -bgrx, -xbgr, -xrgb ="); System.out.println(" Test the specified color conversion path in the codec (default: BGR)"); System.out.println("-fastupsample = Use the fastest chrominance upsampling algorithm available in"); @@ -729,22 +727,6 @@ class TJBench { if (argv[i].equalsIgnoreCase("-tile")) { doTile = true; xformOpt |= TJTransform.OPT_CROP; } - if (argv[i].equalsIgnoreCase("-forcesse3")) { - System.out.println("Forcing SSE3 code\n"); - flags |= TJ.FLAG_FORCESSE3; - } - if (argv[i].equalsIgnoreCase("-forcesse2")) { - System.out.println("Forcing SSE2 code\n"); - flags |= TJ.FLAG_FORCESSE2; - } - if (argv[i].equalsIgnoreCase("-forcesse")) { - System.out.println("Forcing SSE code\n"); - flags |= TJ.FLAG_FORCESSE; - } - if (argv[i].equalsIgnoreCase("-forcemmx")) { - System.out.println("Forcing MMX code\n"); - flags |= TJ.FLAG_FORCEMMX; - } if (argv[i].equalsIgnoreCase("-fastupsample")) { System.out.println("Using fast upsampling code\n"); flags |= TJ.FLAG_FASTUPSAMPLE; diff --git a/java/TJExample.java b/java/TJExample.java index a4971a46..75621143 100644 --- a/java/TJExample.java +++ b/java/TJExample.java @@ -1,5 +1,5 @@ /* - * Copyright (C)2011-2012 D. R. Commander. All Rights Reserved. + * Copyright (C)2011-2012, 2014 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: @@ -324,11 +324,11 @@ public class TJExample implements TJCustomFilter { tjc.setSubsamp(outSubsamp); tjc.setJPEGQuality(outQual); if (img != null) - jpegBuf = tjc.compress(img, flags); + tjc.setSourceImage(img, 0, 0, 0, 0); else { - tjc.setSourceImage(bmpBuf, width, 0, height, TJ.PF_BGRX); - jpegBuf = tjc.compress(flags); + tjc.setSourceImage(bmpBuf, 0, 0, width, 0, height, TJ.PF_BGRX); } + jpegBuf = tjc.compress(flags); jpegSize = tjc.getCompressedSize(); tjc.close(); diff --git a/java/TJUnitTest.java b/java/TJUnitTest.java index f7eef663..0bf8367b 100644 --- a/java/TJUnitTest.java +++ b/java/TJUnitTest.java @@ -736,21 +736,16 @@ public class TJUnitTest { tjc.setSubsamp(subsamp); tjc.setJPEGQuality(jpegQual); tjc.setYUVPad(pad); - if (bi) { - if (yuv == YUVENCODE) - tjc.encodeYUV(img, dstBuf, flags); - else - tjc.compress(img, dstBuf, flags); - } else { - if (yuv == YUVDECODE) - tjc.setSourceImageYUV(srcBuf, w, pad, h); - else - tjc.setSourceImage(srcBuf, w, 0, h, pf); - if (yuv == YUVENCODE) - tjc.encodeYUV(dstBuf, flags); - else - tjc.compress(dstBuf, flags); - } + if (yuv == YUVDECODE) + tjc.setSourceImageYUV(srcBuf, w, pad, h); + else if (bi) + tjc.setSourceImage(img, 0, 0, 0, 0); + else + tjc.setSourceImage(srcBuf, 0, 0, w, 0, h, pf); + if (yuv == YUVENCODE) + tjc.encodeYUV(dstBuf, flags); + else + tjc.compress(dstBuf, flags); size = tjc.getCompressedSize(); if (yuv == YUVENCODE) @@ -955,7 +950,7 @@ public class TJUnitTest { for (i = 0; i < w * h * 4; i++) { srcBuf[i] = (byte)(r.nextInt(2) * 255); } - tjc.setSourceImage(srcBuf, w, 0, h, TJ.PF_BGRX); + tjc.setSourceImage(srcBuf, 0, 0, w, 0, h, TJ.PF_BGRX); tjc.setSubsamp(subsamp); tjc.setJPEGQuality(100); tjc.setYUVPad(pad); @@ -972,7 +967,7 @@ public class TJUnitTest { for (i = 0; i < h * w * 4; i++) { srcBuf[i] = (byte)(r.nextInt(2) * 255); } - tjc.setSourceImage(srcBuf, h, 0, w, TJ.PF_BGRX); + tjc.setSourceImage(srcBuf, 0, 0, h, 0, w, TJ.PF_BGRX); if (yuv == YUVENCODE) tjc.encodeYUV(dstBuf, 0); else diff --git a/java/doc/deprecated-list.html b/java/doc/deprecated-list.html index 9f3b4fd3..bcf6858f 100644 --- a/java/doc/deprecated-list.html +++ b/java/doc/deprecated-list.html @@ -83,6 +83,7 @@ function windowTitle() Contents

@@ -126,6 +127,20 @@ function windowTitle()           Use TJ.bufSizeYUV(int, int, int, int) instead. 
+ + + + + + + + + + + +
org.libjpegturbo.turbojpeg.TJCompressor.compress(BufferedImage, byte[], int) +
+          Use + TJCompressor.setSourceImage(BufferedImage, int, int, int, int) and + TJCompressor.compress(byte[], int) instead. 
org.libjpegturbo.turbojpeg.TJCompressor.compress(BufferedImage, int) +
+          Use + TJCompressor.setSourceImage(BufferedImage, int, int, int, int) and + TJCompressor.compress(int) instead. 
org.libjpegturbo.turbojpeg.TJDecompressor.decompress(byte[], int, int, int, int, int)
          Use @@ -143,6 +158,20 @@ function windowTitle()           Use TJDecompressor.decompressToYUV(int, int, int, int) instead. 
org.libjpegturbo.turbojpeg.TJCompressor.encodeYUV(BufferedImage, byte[], int) +
+          Use + TJCompressor.setSourceImage(BufferedImage, int, int, int, int) and + TJCompressor.encodeYUV(byte[], int) instead. 
org.libjpegturbo.turbojpeg.TJCompressor.encodeYUV(BufferedImage, int) +
+          Use + TJCompressor.setSourceImage(BufferedImage, int, int, int, int) and + TJCompressor.encodeYUV(int) instead. 
org.libjpegturbo.turbojpeg.TJCompressor.setSourceImage(byte[], int, int, int, int)
          Use @@ -151,6 +180,21 @@ function windowTitle()
 

+ + + + + + + + +
+Deprecated Constructors
org.libjpegturbo.turbojpeg.TJCompressor(byte[], int, int, int, int) +
+          Use + TJCompressor.TJCompressor(byte[], int, int, int, int, int, int) instead. 
+  +


diff --git a/java/doc/index-all.html b/java/doc/index-all.html index 81d9b45a..9db10754 100644 --- a/java/doc/index-all.html +++ b/java/doc/index-all.html @@ -113,12 +113,14 @@ Method in class org.libjpegturbo.turbojpeg.compress(BufferedImage, byte[], int) - Method in class org.libjpegturbo.turbojpeg.TJCompressor -
Compress the uncompressed source image stored in srcImage - and output a JPEG image to the given destination buffer. +
Deprecated. Use + TJCompressor.setSourceImage(BufferedImage, int, int, int, int) and + TJCompressor.compress(byte[], int) instead.
compress(BufferedImage, int) - Method in class org.libjpegturbo.turbojpeg.TJCompressor -
Compress the uncompressed source image stored in srcImage - and return a buffer containing a JPEG image. +
Deprecated. Use + TJCompressor.setSourceImage(BufferedImage, int, int, int, int) and + TJCompressor.compress(int) instead.
CS_CMYK - Static variable in class org.libjpegturbo.turbojpeg.TJ
CMYK colorspace. @@ -200,12 +202,14 @@ Method in class org.libjpegturbo.turbojpeg.encodeYUV(BufferedImage, byte[], int) - Method in class org.libjpegturbo.turbojpeg.TJCompressor -
Encode the uncompressed source image stored in srcImage - and output a YUV planar image to the given destination buffer. +
Deprecated. Use + TJCompressor.setSourceImage(BufferedImage, int, int, int, int) and + TJCompressor.encodeYUV(byte[], int) instead.
encodeYUV(BufferedImage, int) - Method in class org.libjpegturbo.turbojpeg.TJCompressor -
Encode the uncompressed source image stored in srcImage - and return a buffer containing a YUV planar image. +
Deprecated. Use + TJCompressor.setSourceImage(BufferedImage, int, int, int, int) and + TJCompressor.encodeYUV(int) instead.
equals(TJScalingFactor) - Method in class org.libjpegturbo.turbojpeg.TJScalingFactor
Returns true or false, depending on whether this instance and @@ -521,6 +525,9 @@ Method in class org.libjpegturbo.turbojpeg.TJCompressor
Deprecated. Use TJCompressor.setSourceImage(byte[], int, int, int, int, int, int) instead. +
setSourceImage(BufferedImage, int, int, int, int) - +Method in class org.libjpegturbo.turbojpeg.TJCompressor +
Associate an uncompressed source image with this compressor instance.
setSourceImageYUV(byte[], int, int, int) - Method in class org.libjpegturbo.turbojpeg.TJCompressor
Associate an uncompressed YUV planar source image with this compressor @@ -545,10 +552,14 @@ Constructor for class org.libjpegturbo.turbojpeg.TJCompressor(byte[], int, int, int, int) - Constructor for class org.libjpegturbo.turbojpeg.TJCompressor +
Deprecated. Use + TJCompressor.TJCompressor(byte[], int, int, int, int, int, int) instead. +
TJCompressor(byte[], int, int, int, int, int, int) - +Constructor for class org.libjpegturbo.turbojpeg.TJCompressor
Create a TurboJPEG compressor instance and associate the uncompressed source image stored in srcImage with the newly-created instance. -
TJCompressor(byte[], int, int, int, int, int, int) - +
TJCompressor(BufferedImage, int, int, int, int) - Constructor for class org.libjpegturbo.turbojpeg.TJCompressor
Create a TurboJPEG compressor instance and associate the uncompressed source image stored in srcImage with the newly-created diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJCompressor.html b/java/doc/org/libjpegturbo/turbojpeg/TJCompressor.html index 35114c70..b6452f37 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/TJCompressor.html +++ b/java/doc/org/libjpegturbo/turbojpeg/TJCompressor.html @@ -120,6 +120,18 @@ TurboJPEG compressor           Create a TurboJPEG compressor instance. +TJCompressor(java.awt.image.BufferedImage srcImage, + int x, + int y, + int width, + int height) + +
+          Create a TurboJPEG compressor instance and associate the uncompressed + source image stored in srcImage with the newly-created + instance. + + TJCompressor(byte[] srcImage, int width, int pitch, @@ -127,9 +139,8 @@ TurboJPEG compressor int pixelFormat)
-          Create a TurboJPEG compressor instance and associate the uncompressed - source image stored in srcImage with the newly-created - instance. +          Deprecated. Use + TJCompressor(byte[], int, int, int, int, int, int) instead. TJCompressor(byte[] srcImage, @@ -171,8 +182,9 @@ TurboJPEG compressor int flags)
-          Compress the uncompressed source image stored in srcImage - and output a JPEG image to the given destination buffer. +          Deprecated. Use + setSourceImage(BufferedImage, int, int, int, int) and + compress(byte[], int) instead. @@ -181,8 +193,9 @@ TurboJPEG compressor int flags)
-          Compress the uncompressed source image stored in srcImage - and return a buffer containing a JPEG image. +          Deprecated. Use + setSourceImage(BufferedImage, int, int, int, int) and + compress(int) instead. @@ -211,8 +224,9 @@ TurboJPEG compressor int flags)
-          Encode the uncompressed source image stored in srcImage - and output a YUV planar image to the given destination buffer. +          Deprecated. Use + setSourceImage(BufferedImage, int, int, int, int) and + encodeYUV(byte[], int) instead. @@ -221,8 +235,9 @@ TurboJPEG compressor int flags)
-          Encode the uncompressed source image stored in srcImage - and return a buffer containing a YUV planar image. +          Deprecated. Use + setSourceImage(BufferedImage, int, int, int, int) and + encodeYUV(int) instead. @@ -271,6 +286,18 @@ TurboJPEG compressor  void +setSourceImage(java.awt.image.BufferedImage srcImage, + int x, + int y, + int width, + int height) + +
+          Associate an uncompressed source image with this compressor instance. + + + + void setSourceImage(byte[] srcImage, int width, int pitch, @@ -365,20 +392,19 @@ public TJCompressor()

TJCompressor

-public TJCompressor(byte[] srcImage,
-                    int width,
-                    int pitch,
-                    int height,
-                    int pixelFormat)
+@Deprecated
+public TJCompressor(byte[] srcImage,
+                               int width,
+                               int pitch,
+                               int height,
+                               int pixelFormat)
              throws java.lang.Exception
-
Create a TurboJPEG compressor instance and associate the uncompressed - source image stored in srcImage with the newly-created - instance. +
Deprecated. Use + TJCompressor(byte[], int, int, int, int, int, int) instead.

-
Parameters:
srcImage - see setSourceImage(byte[], int, int, int, int, int, int) for description
width - see setSourceImage(byte[], int, int, int, int, int, int) for description
pitch - see setSourceImage(byte[], int, int, int, int, int, int) for description
height - see setSourceImage(byte[], int, int, int, int, int, int) for description
pixelFormat - pixel format of the source image (one of - TJ.PF_*) +
Throws:
java.lang.Exception
@@ -406,6 +432,32 @@ public TJCompressor(byte[] srcImage,
Throws:
java.lang.Exception
+
+ +

+TJCompressor

+
+public TJCompressor(java.awt.image.BufferedImage srcImage,
+                    int x,
+                    int y,
+                    int width,
+                    int height)
+             throws java.lang.Exception
+
+
Create a TurboJPEG compressor instance and associate the uncompressed + source image stored in srcImage with the newly-created + instance. +

+

+
Parameters:
srcImage - see + setSourceImage(BufferedImage, int, int, int, int) for description
x - see + setSourceImage(BufferedImage, int, int, int, int) for description
y - see + setSourceImage(BufferedImage, int, int, int, int) for description
width - see + setSourceImage(BufferedImage, int, int, int, int) for description
height - see + setSourceImage(BufferedImage, int, int, int, int) for description +
Throws: +
java.lang.Exception
+
@@ -474,6 +526,31 @@ setSourceImage
+

+setSourceImage

+
+public void setSourceImage(java.awt.image.BufferedImage srcImage,
+                           int x,
+                           int y,
+                           int width,
+                           int height)
+                    throws java.lang.Exception
+
+
Associate an uncompressed source image with this compressor instance. +

+

+
Parameters:
srcImage - a BufferedImage instance containing RGB or + grayscale pixels to be compressed
x - x offset (in pixels) of the region in the source image from which + the JPEG image should be compressed
y - y offset (in pixels) of the region in the source image from which + the JPEG image should be compressed
width - width (in pixels) of the region in the source image from + which the JPEG image should be compressed (0 = compress the whole image)
height - height (in pixels) of the region in the source image from + which the JPEG image should be compressed (0 = compress the whole image) +
Throws: +
java.lang.Exception
+
+
+
+

setSourceImageYUV

@@ -593,19 +670,18 @@ public byte[] compress(int flags)
 

compress

-public void compress(java.awt.image.BufferedImage srcImage,
-                     byte[] dstBuf,
-                     int flags)
+@Deprecated
+public void compress(java.awt.image.BufferedImage srcImage,
+                                byte[] dstBuf,
+                                int flags)
               throws java.lang.Exception
-
Compress the uncompressed source image stored in srcImage - and output a JPEG image to the given destination buffer. +
Deprecated. Use + setSourceImage(BufferedImage, int, int, int, int) and + compress(byte[], int) instead.

-
Parameters:
srcImage - a BufferedImage instance containing RGB or - grayscale pixels to be compressed
dstBuf - buffer that will receive the JPEG image. Use - TJ.bufSize(int, int, int) to determine the maximum size for this buffer based on - the image width, height, and level of chrominance subsampling.
flags - the bitwise OR of one or more of TJ.FLAG_* +
Throws:
java.lang.Exception
@@ -615,18 +691,17 @@ public void compress(java.awt.image.BufferedImage srcImage,

compress

-public byte[] compress(java.awt.image.BufferedImage srcImage,
-                       int flags)
+@Deprecated
+public byte[] compress(java.awt.image.BufferedImage srcImage,
+                                  int flags)
                 throws java.lang.Exception
-
Compress the uncompressed source image stored in srcImage - and return a buffer containing a JPEG image. +
Deprecated. Use + setSourceImage(BufferedImage, int, int, int, int) and + compress(int) instead.

-
Parameters:
srcImage - a BufferedImage instance containing RGB or - grayscale pixels to be compressed
flags - the bitwise OR of one or more of TJ.FLAG_* -
Returns:
a buffer containing a JPEG image. The length of this buffer will - not be equal to the size of the JPEG image. Use getCompressedSize() to obtain the size of the JPEG image. +
Throws:
java.lang.Exception
@@ -708,20 +783,18 @@ public byte[] encodeYUV(int flags)

encodeYUV

-public void encodeYUV(java.awt.image.BufferedImage srcImage,
-                      byte[] dstBuf,
-                      int flags)
+@Deprecated
+public void encodeYUV(java.awt.image.BufferedImage srcImage,
+                                 byte[] dstBuf,
+                                 int flags)
                throws java.lang.Exception
-
Encode the uncompressed source image stored in srcImage - and output a YUV planar image to the given destination buffer. See - encodeYUV(byte[], int) for more detail. +
Deprecated. Use + setSourceImage(BufferedImage, int, int, int, int) and + encodeYUV(byte[], int) instead.

-
Parameters:
srcImage - a BufferedImage instance containing RGB or - grayscale pixels to be encoded
dstBuf - buffer that will receive the YUV planar image. Use - TJ.bufSizeYUV(int, int, int, int) to determine the appropriate size for this buffer - based on the image width, height, and level of chrominance subsampling.
flags - the bitwise OR of one or more of TJ.FLAG_* +
Throws:
java.lang.Exception
@@ -731,18 +804,17 @@ public void encodeYUV(java.awt.image.BufferedImage srcImage,

encodeYUV

-public byte[] encodeYUV(java.awt.image.BufferedImage srcImage,
-                        int flags)
+@Deprecated
+public byte[] encodeYUV(java.awt.image.BufferedImage srcImage,
+                                   int flags)
                  throws java.lang.Exception
-
Encode the uncompressed source image stored in srcImage - and return a buffer containing a YUV planar image. See - encodeYUV(byte[], int) for more detail. +
Deprecated. Use + setSourceImage(BufferedImage, int, int, int, int) and + encodeYUV(int) instead.

-
Parameters:
srcImage - a BufferedImage instance containing RGB or - grayscale pixels to be encoded
flags - the bitwise OR of one or more of TJ.FLAG_* -
Returns:
a buffer containing a YUV planar image +
Throws:
java.lang.Exception
diff --git a/java/org/libjpegturbo/turbojpeg/TJCompressor.java b/java/org/libjpegturbo/turbojpeg/TJCompressor.java index 63a7fa5c..ed8d8e10 100644 --- a/java/org/libjpegturbo/turbojpeg/TJCompressor.java +++ b/java/org/libjpegturbo/turbojpeg/TJCompressor.java @@ -1,5 +1,5 @@ /* - * Copyright (C)2011-2013 D. R. Commander. All Rights Reserved. + * Copyright (C)2011-2014 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: @@ -47,21 +47,10 @@ public class TJCompressor { } /** - * Create a TurboJPEG compressor instance and associate the uncompressed - * source image stored in srcImage with the newly-created - * instance. - * - * @param srcImage see {@link #setSourceImage} for description - * - * @param width see {@link #setSourceImage} for description - * - * @param pitch see {@link #setSourceImage} for description - * - * @param height see {@link #setSourceImage} for description - * - * @param pixelFormat pixel format of the source image (one of - * {@link TJ TJ.PF_*}) + * @deprecated Use + * {@link #TJCompressor(byte[], int, int, int, int, int, int)} instead. */ + @Deprecated public TJCompressor(byte[] srcImage, int width, int pitch, int height, int pixelFormat) throws Exception { setSourceImage(srcImage, width, pitch, height, pixelFormat); @@ -92,6 +81,31 @@ public class TJCompressor { setSourceImage(srcImage, x, y, width, pitch, height, pixelFormat); } + /** + * Create a TurboJPEG compressor instance and associate the uncompressed + * source image stored in srcImage with the newly-created + * instance. + * + * @param srcImage see + * {@link #setSourceImage(BufferedImage, int, int, int, int)} for description + * + * @param x see + * {@link #setSourceImage(BufferedImage, int, int, int, int)} for description + * + * @param y see + * {@link #setSourceImage(BufferedImage, int, int, int, int)} for description + * + * @param width see + * {@link #setSourceImage(BufferedImage, int, int, int, int)} for description + * + * @param height see + * {@link #setSourceImage(BufferedImage, int, int, int, int)} for description + */ + public TJCompressor(BufferedImage srcImage, int x, int y, int width, + int height) throws Exception { + setSourceImage(srcImage, x, y, width, height); + } + /** * Associate an uncompressed source image with this compressor instance. * @@ -139,6 +153,7 @@ public class TJCompressor { srcPixelFormat = pixelFormat; srcX = x; srcY = y; + srcBufInt = null; srcIsYUV = false; } @@ -153,6 +168,88 @@ public class TJCompressor { srcX = srcY = -1; } + /** + * Associate an uncompressed source image with this compressor instance. + * + * @param srcImage a BufferedImage instance containing RGB or + * grayscale pixels to be compressed + * + * @param x x offset (in pixels) of the region in the source image from which + * the JPEG image should be compressed + * + * @param y y offset (in pixels) of the region in the source image from which + * the JPEG image should be compressed + * + * @param width width (in pixels) of the region in the source image from + * which the JPEG image should be compressed (0 = compress the whole image) + * + * @param height height (in pixels) of the region in the source image from + * which the JPEG image should be compressed (0 = compress the whole image) + */ + public void setSourceImage(BufferedImage srcImage, int x, int y, int width, + int height) throws Exception { + if (handle == 0) init(); + if (srcImage == null || x < 0 || y < 0 || width < 0 || height < 0) + throw new Exception("Invalid argument in setSourceImage()"); + srcX = x; + srcY = y; + srcWidth = (width == 0) ? srcImage.getWidth(): width; + srcHeight = (height == 0) ? srcImage.getHeight() : height; + if (x + width > srcImage.getWidth() || y + height > srcImage.getHeight()) + throw new Exception("Compression region exceeds the bounds of the source image"); + + int pixelFormat; + boolean intPixels = false; + if (byteOrder == null) + byteOrder = ByteOrder.nativeOrder(); + switch(srcImage.getType()) { + case BufferedImage.TYPE_3BYTE_BGR: + pixelFormat = TJ.PF_BGR; break; + case BufferedImage.TYPE_4BYTE_ABGR: + case BufferedImage.TYPE_4BYTE_ABGR_PRE: + pixelFormat = TJ.PF_XBGR; break; + case BufferedImage.TYPE_BYTE_GRAY: + pixelFormat = TJ.PF_GRAY; break; + case BufferedImage.TYPE_INT_BGR: + if (byteOrder == ByteOrder.BIG_ENDIAN) + pixelFormat = TJ.PF_XBGR; + else + pixelFormat = TJ.PF_RGBX; + intPixels = true; break; + case BufferedImage.TYPE_INT_RGB: + case BufferedImage.TYPE_INT_ARGB: + case BufferedImage.TYPE_INT_ARGB_PRE: + if (byteOrder == ByteOrder.BIG_ENDIAN) + pixelFormat = TJ.PF_XRGB; + else + pixelFormat = TJ.PF_BGRX; + intPixels = true; break; + default: + throw new Exception("Unsupported BufferedImage format"); + } + srcPixelFormat = pixelFormat; + + WritableRaster wr = srcImage.getRaster(); + if (intPixels) { + SinglePixelPackedSampleModel sm = + (SinglePixelPackedSampleModel)srcImage.getSampleModel(); + srcStride = sm.getScanlineStride(); + DataBufferInt db = (DataBufferInt)wr.getDataBuffer(); + srcBufInt = db.getData(); + srcBuf = null; + } else { + ComponentSampleModel sm = + (ComponentSampleModel)srcImage.getSampleModel(); + int pixelSize = sm.getPixelStride(); + if (pixelSize != TJ.getPixelSize(pixelFormat)) + throw new Exception("Inconsistency between pixel format and pixel size in BufferedImage"); + srcPitch = sm.getScanlineStride(); + DataBufferByte db = (DataBufferByte)wr.getDataBuffer(); + srcBuf = db.getData(); + srcBufInt = null; + } + } + /** * Associate an uncompressed YUV planar source image with this compressor * instance. @@ -237,16 +334,17 @@ public class TJCompressor { public void compress(byte[] dstBuf, int flags) throws Exception { if (dstBuf == null || flags < 0) throw new Exception("Invalid argument in compress()"); - if (srcBuf == null) + if (srcBuf == null && (srcBufInt == null || srcIsYUV)) throw new Exception(NO_ASSOC_ERROR); if (jpegQuality < 0) throw new Exception("JPEG Quality not set"); if (subsamp < 0) throw new Exception("Subsampling level not set"); + if (srcIsYUV) compressedSize = compressFromYUV(srcBuf, srcWidth, srcYUVPad, srcHeight, subsamp, dstBuf, jpegQuality, flags); - else { + else if (srcBuf != null) { if (srcX >= 0 && srcY >= 0) compressedSize = compress(srcBuf, srcX, srcY, srcWidth, srcPitch, srcHeight, srcPixelFormat, dstBuf, subsamp, @@ -255,6 +353,15 @@ public class TJCompressor { compressedSize = compress(srcBuf, srcWidth, srcPitch, srcHeight, srcPixelFormat, dstBuf, subsamp, jpegQuality, flags); + } else if (srcBufInt != null) { + if (srcX >= 0 && srcY >= 0) + compressedSize = compress(srcBufInt, srcX, srcY, srcWidth, srcStride, + srcHeight, srcPixelFormat, dstBuf, subsamp, + jpegQuality, flags); + else + compressedSize = compress(srcBufInt, srcWidth, srcStride, srcHeight, + srcPixelFormat, dstBuf, subsamp, jpegQuality, + flags); } } @@ -277,109 +384,26 @@ public class TJCompressor { } /** - * Compress the uncompressed source image stored in srcImage - * and output a JPEG image to the given destination buffer. - * - * @param srcImage a BufferedImage instance containing RGB or - * grayscale pixels to be compressed - * - * @param dstBuf buffer that will receive the JPEG image. Use - * {@link TJ#bufSize} to determine the maximum size for this buffer based on - * the image width, height, and level of chrominance subsampling. - * - * @param flags the bitwise OR of one or more of {@link TJ TJ.FLAG_*} + * @deprecated Use + * {@link #setSourceImage(BufferedImage, int, int, int, int)} and + * {@link #compress(byte[], int)} instead. */ + @Deprecated public void compress(BufferedImage srcImage, byte[] dstBuf, int flags) throws Exception { - if (srcImage == null || dstBuf == null || flags < 0) - throw new Exception("Invalid argument in compress()"); - int width = srcImage.getWidth(); - int height = srcImage.getHeight(); - int pixelFormat; - boolean intPixels = false; - if (byteOrder == null) - byteOrder = ByteOrder.nativeOrder(); - switch(srcImage.getType()) { - case BufferedImage.TYPE_3BYTE_BGR: - pixelFormat = TJ.PF_BGR; break; - case BufferedImage.TYPE_4BYTE_ABGR: - case BufferedImage.TYPE_4BYTE_ABGR_PRE: - pixelFormat = TJ.PF_XBGR; break; - case BufferedImage.TYPE_BYTE_GRAY: - pixelFormat = TJ.PF_GRAY; break; - case BufferedImage.TYPE_INT_BGR: - if (byteOrder == ByteOrder.BIG_ENDIAN) - pixelFormat = TJ.PF_XBGR; - else - pixelFormat = TJ.PF_RGBX; - intPixels = true; break; - case BufferedImage.TYPE_INT_RGB: - case BufferedImage.TYPE_INT_ARGB: - case BufferedImage.TYPE_INT_ARGB_PRE: - if (byteOrder == ByteOrder.BIG_ENDIAN) - pixelFormat = TJ.PF_XRGB; - else - pixelFormat = TJ.PF_BGRX; - intPixels = true; break; - default: - throw new Exception("Unsupported BufferedImage format"); - } - WritableRaster wr = srcImage.getRaster(); - if (jpegQuality < 0) - throw new Exception("JPEG Quality not set"); - if (subsamp < 0) - throw new Exception("Subsampling level not set"); - if (intPixels) { - SinglePixelPackedSampleModel sm = - (SinglePixelPackedSampleModel)srcImage.getSampleModel(); - int stride = sm.getScanlineStride(); - DataBufferInt db = (DataBufferInt)wr.getDataBuffer(); - int[] buf = db.getData(); - if (srcX >= 0 && srcY >= 0) - compressedSize = compress(buf, srcX, srcY, width, stride, height, - pixelFormat, dstBuf, subsamp, jpegQuality, - flags); - else - compressedSize = compress(buf, width, stride, height, pixelFormat, - dstBuf, subsamp, jpegQuality, flags); - } else { - ComponentSampleModel sm = - (ComponentSampleModel)srcImage.getSampleModel(); - int pixelSize = sm.getPixelStride(); - if (pixelSize != TJ.getPixelSize(pixelFormat)) - throw new Exception("Inconsistency between pixel format and pixel size in BufferedImage"); - int pitch = sm.getScanlineStride(); - DataBufferByte db = (DataBufferByte)wr.getDataBuffer(); - byte[] buf = db.getData(); - if (srcX >= 0 && srcY >= 0) - compressedSize = compress(buf, srcX, srcY, width, pitch, height, - pixelFormat, dstBuf, subsamp, jpegQuality, - flags); - else - compressedSize = compress(buf, width, pitch, height, pixelFormat, - dstBuf, subsamp, jpegQuality, flags); - } + setSourceImage(srcImage, 0, 0, 0, 0); + compress(dstBuf, flags); } /** - * Compress the uncompressed source image stored in srcImage - * and return a buffer containing a JPEG image. - * - * @param srcImage a BufferedImage instance containing RGB or - * grayscale pixels to be compressed - * - * @param flags the bitwise OR of one or more of {@link TJ TJ.FLAG_*} - * - * @return a buffer containing a JPEG image. The length of this buffer will - * not be equal to the size of the JPEG image. Use {@link - * #getCompressedSize} to obtain the size of the JPEG image. + * @deprecated Use + * {@link #setSourceImage(BufferedImage, int, int, int, int)} and + * {@link #compress(int)} instead. */ + @Deprecated public byte[] compress(BufferedImage srcImage, int flags) throws Exception { - int width = srcImage.getWidth(); - int height = srcImage.getHeight(); - byte[] buf = new byte[TJ.bufSize(width, height, subsamp)]; - compress(srcImage, buf, flags); - return buf; + setSourceImage(srcImage, 0, 0, 0, 0); + return compress(flags); } @@ -424,12 +448,20 @@ public class TJCompressor { public void encodeYUV(byte[] dstBuf, int flags) throws Exception { if (dstBuf == null || flags < 0) throw new Exception("Invalid argument in compress()"); - if (srcBuf == null) + if (srcBuf == null && srcBufInt == null) throw new Exception(NO_ASSOC_ERROR); + if (srcIsYUV) + throw new Exception("Source image is not correct type"); if (subsamp < 0) throw new Exception("Subsampling level not set"); - encodeYUV(srcBuf, srcWidth, srcPitch, srcHeight, srcPixelFormat, dstBuf, - yuvPad, subsamp, flags); + + if (srcBufInt != null) { + encodeYUV(srcBufInt, srcWidth, srcStride, srcHeight, srcPixelFormat, + dstBuf, yuvPad, subsamp, flags); + } else { + encodeYUV(srcBuf, srcWidth, srcPitch, srcHeight, srcPixelFormat, dstBuf, + yuvPad, subsamp, flags); + } compressedSize = TJ.bufSizeYUV(srcWidth, yuvPad, srcHeight, subsamp); } @@ -453,98 +485,26 @@ public class TJCompressor { } /** - * Encode the uncompressed source image stored in srcImage - * and output a YUV planar image to the given destination buffer. See - * {@link #encodeYUV(byte[], int)} for more detail. - * - * @param srcImage a BufferedImage instance containing RGB or - * grayscale pixels to be encoded - * - * @param dstBuf buffer that will receive the YUV planar image. Use - * {@link TJ#bufSizeYUV} to determine the appropriate size for this buffer - * based on the image width, height, and level of chrominance subsampling. - * - * @param flags the bitwise OR of one or more of {@link TJ TJ.FLAG_*} + * @deprecated Use + * {@link #setSourceImage(BufferedImage, int, int, int, int)} and + * {@link #encodeYUV(byte[], int)} instead. */ + @Deprecated public void encodeYUV(BufferedImage srcImage, byte[] dstBuf, int flags) throws Exception { - if (srcImage == null || dstBuf == null || flags < 0) - throw new Exception("Invalid argument in encodeYUV()"); - int width = srcImage.getWidth(); - int height = srcImage.getHeight(); - int pixelFormat; boolean intPixels = false; - if (byteOrder == null) - byteOrder = ByteOrder.nativeOrder(); - switch(srcImage.getType()) { - case BufferedImage.TYPE_3BYTE_BGR: - pixelFormat = TJ.PF_BGR; break; - case BufferedImage.TYPE_4BYTE_ABGR: - case BufferedImage.TYPE_4BYTE_ABGR_PRE: - pixelFormat = TJ.PF_XBGR; break; - case BufferedImage.TYPE_BYTE_GRAY: - pixelFormat = TJ.PF_GRAY; break; - case BufferedImage.TYPE_INT_BGR: - if (byteOrder == ByteOrder.BIG_ENDIAN) - pixelFormat = TJ.PF_XBGR; - else - pixelFormat = TJ.PF_RGBX; - intPixels = true; break; - case BufferedImage.TYPE_INT_RGB: - case BufferedImage.TYPE_INT_ARGB: - case BufferedImage.TYPE_INT_ARGB_PRE: - if (byteOrder == ByteOrder.BIG_ENDIAN) - pixelFormat = TJ.PF_XRGB; - else - pixelFormat = TJ.PF_BGRX; - intPixels = true; break; - default: - throw new Exception("Unsupported BufferedImage format"); - } - WritableRaster wr = srcImage.getRaster(); - if (subsamp < 0) throw new Exception("Subsampling level not set"); - if (intPixels) { - SinglePixelPackedSampleModel sm = - (SinglePixelPackedSampleModel)srcImage.getSampleModel(); - int stride = sm.getScanlineStride(); - DataBufferInt db = (DataBufferInt)wr.getDataBuffer(); - int[] buf = db.getData(); - encodeYUV(buf, width, stride, height, pixelFormat, dstBuf, yuvPad, - subsamp, flags); - } else { - ComponentSampleModel sm = - (ComponentSampleModel)srcImage.getSampleModel(); - int pixelSize = sm.getPixelStride(); - if (pixelSize != TJ.getPixelSize(pixelFormat)) - throw new Exception("Inconsistency between pixel format and pixel size in BufferedImage"); - int pitch = sm.getScanlineStride(); - DataBufferByte db = (DataBufferByte)wr.getDataBuffer(); - byte[] buf = db.getData(); - encodeYUV(buf, width, pitch, height, pixelFormat, dstBuf, yuvPad, - subsamp, flags); - } - compressedSize = TJ.bufSizeYUV(width, yuvPad, height, subsamp); + setSourceImage(srcImage, 0, 0, 0, 0); + encodeYUV(dstBuf, flags); } /** - * Encode the uncompressed source image stored in srcImage - * and return a buffer containing a YUV planar image. See - * {@link #encodeYUV(byte[], int)} for more detail. - * - * @param srcImage a BufferedImage instance containing RGB or - * grayscale pixels to be encoded - * - * @param flags the bitwise OR of one or more of {@link TJ TJ.FLAG_*} - * - * @return a buffer containing a YUV planar image + * @deprecated Use + * {@link #setSourceImage(BufferedImage, int, int, int, int)} and + * {@link #encodeYUV(int)} instead. */ + @Deprecated public byte[] encodeYUV(BufferedImage srcImage, int flags) throws Exception { - if (subsamp < 0) - throw new Exception("Subsampling level not set"); - int width = srcImage.getWidth(); - int height = srcImage.getHeight(); - byte[] buf = new byte[TJ.bufSizeYUV(width, yuvPad, height, subsamp)]; - encodeYUV(srcImage, buf, flags); - return buf; + setSourceImage(srcImage, 0, 0, 0, 0); + return encodeYUV(flags); } /** @@ -621,11 +581,13 @@ public class TJCompressor { private long handle = 0; private byte[] srcBuf = null; + private int[] srcBufInt = null; private int srcWidth = 0; private int srcHeight = 0; private int srcX = -1; private int srcY = -1; private int srcPitch = 0; + private int srcStride = 0; private int srcPixelFormat = -1; private int srcYUVPad = -1; private boolean srcIsYUV; From d56079bc7e190f0ad43dd031fe576ba273e03099 Mon Sep 17 00:00:00 2001 From: DRC Date: Fri, 14 Mar 2014 08:59:27 +0000 Subject: [PATCH 43/65] Remove unneeded/unused code --- tjunittest.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tjunittest.c b/tjunittest.c index d2d3e983..dc84bbaa 100644 --- a/tjunittest.c +++ b/tjunittest.c @@ -79,7 +79,6 @@ const int _4byteFormats[]={TJPF_RGBX, TJPF_BGRX, TJPF_XBGR, TJPF_XRGB, const int _onlyGray[]={TJPF_GRAY}; const int _onlyRGB[]={TJPF_RGB}; -enum {YUVENCODE=1, YUVDECODE}; int doyuv=0, alloc=0, pad=4; int exitStatus=0; @@ -425,9 +424,6 @@ void compTest(tjhandle handle, unsigned char **dstBuf, _tj(tjEncodeYUV3(handle2, srcBuf, w, 0, h, pf, yuvBuf, pad, subsamp, flags)); tjDestroy(handle2); - snprintf(tempStr, 1024, "%s_enc_%s_%s_%s.yuv", basename, pfStr, buStr, - subName[subsamp]); - writeJPEG(yuvBuf, yuvSize, tempStr); if(checkBufYUV(yuvBuf, w, h, subsamp, sf)) printf("Passed.\n"); else printf("FAILED!\n"); From 960ea8fb6657b540565c5bcecd676e08a4f8e26e Mon Sep 17 00:00:00 2001 From: DRC Date: Sat, 15 Mar 2014 08:48:53 +0000 Subject: [PATCH 44/65] As with tjDecompressToYUV*(), tjCompressFromYUV() also conditionally uses an intermediate buffer if the source image dimensions do not fall on MCU boundaries. --- doc/html/group___turbo_j_p_e_g.html | 1 + turbojpeg.h | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/html/group___turbo_j_p_e_g.html b/doc/html/group___turbo_j_p_e_g.html index 28e4926e..6936e5df 100644 --- a/doc/html/group___turbo_j_p_e_g.html +++ b/doc/html/group___turbo_j_p_e_g.html @@ -1067,6 +1067,7 @@ If you choose option 1, *jpegSize should be set to the size of your

Compress a YUV planar image into a JPEG image.

+

Note that, if the width or height of the YUV image is not an even multiple of the MCU block size (see tjMCUWidth and tjMCUHeight), then an intermediate buffer copy will be performed within TurboJPEG.

Parameters
diff --git a/turbojpeg.h b/turbojpeg.h index a082fa36..6c13851a 100644 --- a/turbojpeg.h +++ b/turbojpeg.h @@ -636,7 +636,10 @@ DLLEXPORT int DLLCALL tjCompress2(tjhandle handle, unsigned char *srcBuf, /** - * Compress a YUV planar image into a JPEG image. + * Compress a YUV planar image into a JPEG image. Note that, if the width or + * height of the YUV image is not an even multiple of the MCU block size + * (see #tjMCUWidth and #tjMCUHeight), then an intermediate buffer copy will be + * performed within TurboJPEG. * * @param handle a handle to a TurboJPEG compressor or transformer instance * @param srcBuf pointer to an image buffer containing a YUV planar image From 9e9df116253bfed3ce21da3e24ad45cfb5ba871f Mon Sep 17 00:00:00 2001 From: DRC Date: Sun, 16 Mar 2014 22:56:26 +0000 Subject: [PATCH 45/65] Extend the YUV decode functionality to the TurboJPEG Java API, and port the TJUnitTest modifications that treat YUV encoding/decoding as an intermediate step of the JPEG compression/decompression pipeline rather than a separate test case; Add the ability to encode YUV images from an arbitrary position in a large image buffer; Significantly refactor the handling of YUV images; numerous doc tweaks; other Java API cleanup and usability improvements --- ChangeLog.txt | 39 +- java/Makefile.am | 2 + java/TJBench.java | 24 +- java/TJExample.java | 2 +- java/TJUnitTest.java | 310 +++------ java/doc/allclasses-frame.html | 2 + java/doc/allclasses-noframe.html | 2 + java/doc/deprecated-list.html | 28 +- java/doc/index-all.html | 215 ++++-- .../libjpegturbo/turbojpeg/TJCompressor.html | 266 +++---- .../turbojpeg/TJDecompressor.html | 609 ++++++++++------ .../libjpegturbo/turbojpeg/TJTransformer.html | 36 +- .../libjpegturbo/turbojpeg/package-frame.html | 4 +- .../turbojpeg/package-summary.html | 5 + .../libjpegturbo/turbojpeg/package-tree.html | 2 +- java/doc/overview-tree.html | 2 +- .../libjpegturbo/turbojpeg/TJCompressor.java | 276 ++++---- .../turbojpeg/TJDecompressor.java | 652 +++++++++++------- .../libjpegturbo/turbojpeg/TJTransformer.java | 32 +- java/org/libjpegturbo/turbojpeg/YUVImage.java | 193 ++++++ .../org_libjpegturbo_turbojpeg_TJCompressor.h | 12 +- ...rg_libjpegturbo_turbojpeg_TJDecompressor.h | 16 + turbojpeg-jni.c | 150 +++- turbojpeg-mapfile.jni | 6 +- 24 files changed, 1795 insertions(+), 1090 deletions(-) create mode 100644 java/org/libjpegturbo/turbojpeg/YUVImage.java diff --git a/ChangeLog.txt b/ChangeLog.txt index 5c830163..25f673e8 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,30 +1,31 @@ 1.4 pre-beta ============ -[1] The TurboJPEG API can now be used to generate YUV images with an arbitrary -line padding (previously, it only supported 4-byte padding, which was -compatible with X Video.) Also, the decompress-to-YUV function has been -extended to support image scaling. +[1] New features in the TurboJPEG API: +-- YUV planar images can now be generated with an arbitrary line padding +(previously only 4-byte padding, which was compatible with X Video, was +supported.) +-- The decompress-to-YUV function has been extended to support image scaling. +-- JPEG images can now be compressed from YUV planar source images. +-- YUV planar images can now be decoded into RGB or grayscale images. +-- 4:1:1 subsampling is now supported. This is mainly included for +compatibility, since 4:1:1 is not fully accelerated in libjpeg-turbo and has no +significant advantages relative to 4:2:0. +-- CMYK images are now supported. This feature allows CMYK source images to be +compressed to YCCK JPEGs and YCCK or CMYK JPEGs to be decompressed to CMYK +destination images. Conversion between CMYK and RGB or YUV images is not +supported. Such conversion requires a color management system and is out of +scope for a codec library. +-- The handling of YUV images in the Java API has been significantly refactored +and should now be much more intuitive. +-- The Java API now supports encoding a YUV image from an arbitrary position in +a large image buffer. [2] Added SIMD acceleration for DSPr2-capable MIPS platforms. This speeds up the compression of full-color JPEGs by 70-80% on such platforms and decompression by 25-35%. -[3] Added support for 4:1:1 subsampling to the TurboJPEG API. This is mainly -included for compatibility, since 4:1:1 is not fully accelerated in -libjpeg-turbo and has no significant advantages relative to 4:2:0. - -[4] Added support for CMYK images to the TurboJPEG API. This feature allows -CMYK source images to be compressed to YCCK JPEGs and YCCK or CMYK JPEGs to be -decompressed to CMYK destination images. Conversion between CMYK and RGB -images is not supported. Such conversion requires a color management system -and is out of scope for a codec library. - -[5] The TurboJPEG API can now be used to compress JPEG images from YUV planar -source images and to decode YUV planar images into RGB, grayscale, or extended -RGB images. - -[6] If an application attempts to decompress a Huffman-coded JPEG image whose +[3] If an application attempts to decompress a Huffman-coded JPEG image whose header does not contain Huffman tables, libjpeg-turbo will now insert the default Huffman tables. In order to save space, many motion JPEG video frames are encoded without the default Huffman tables, so these frames can now be diff --git a/java/Makefile.am b/java/Makefile.am index 1307d69a..23e34129 100644 --- a/java/Makefile.am +++ b/java/Makefile.am @@ -13,6 +13,7 @@ JAVASOURCES = org/libjpegturbo/turbojpeg/TJ.java \ org/libjpegturbo/turbojpeg/TJScalingFactor.java \ org/libjpegturbo/turbojpeg/TJTransform.java \ org/libjpegturbo/turbojpeg/TJTransformer.java \ + org/libjpegturbo/turbojpeg/YUVImage.java \ TJExample.java \ TJUnitTest.java \ TJBench.java @@ -34,6 +35,7 @@ JAVA_CLASSES = org/libjpegturbo/turbojpeg/TJ.class \ org/libjpegturbo/turbojpeg/TJScalingFactor.class \ org/libjpegturbo/turbojpeg/TJTransform.class \ org/libjpegturbo/turbojpeg/TJTransformer.class \ + org/libjpegturbo/turbojpeg/YUVImage.class \ TJExample.class \ TJUnitTest.class \ TJBench.class diff --git a/java/TJBench.java b/java/TJBench.java index 50cbadfb..7df0ce2d 100644 --- a/java/TJBench.java +++ b/java/TJBench.java @@ -146,6 +146,7 @@ class TJBench { int scaledh = sf.getScaled(h); int yuvSize = TJ.bufSizeYUV(scaledw, yuvpad, scaledh, subsamp), bufsize; int pitch = scaledw * ps; + YUVImage yuvImage = null; if (jpegQual > 0) qualStr = new String("_Q" + jpegQual); @@ -161,9 +162,11 @@ class TJBench { Arrays.fill(dstBuf, (byte)127); /* Execute once to preload cache */ - tjd.setJPEGImage(jpegBuf[0], jpegSize[0]); - if (yuv == YUVDECODE) - tjd.decompressToYUV(dstBuf, scaledw, yuvpad, scaledh, flags); + tjd.setSourceImage(jpegBuf[0], jpegSize[0]); + if (yuv == YUVDECODE) { + yuvImage = new YUVImage(dstBuf, scaledw, yuvpad, scaledh, subsamp); + tjd.decompressToYUV(yuvImage, flags); + } else tjd.decompress(dstBuf, 0, 0, scaledw, pitch, scaledh, pf, flags); @@ -172,13 +175,13 @@ class TJBench { i++) { int tile = 0; if (yuv == YUVDECODE) - tjd.decompressToYUV(dstBuf, scaledw, yuvpad, scaledh, flags); + tjd.decompressToYUV(yuvImage, flags); else { for (int y = 0; y < h; y += tileh) { for (int x = 0; x < w; x += tilew, tile++) { int width = doTile ? Math.min(tilew, w - x) : scaledw; int height = doTile ? Math.min(tileh, h - y) : scaledh; - tjd.setJPEGImage(jpegBuf[tile], jpegSize[tile]); + tjd.setSourceImage(jpegBuf[tile], jpegSize[tile]); tjd.decompress(dstBuf, x, y, width, pitch, height, pf, flags); } } @@ -258,6 +261,7 @@ class TJBench { double start, elapsed; int ps = TJ.getPixelSize(pf), i; int yuvSize = 0; + YUVImage yuvImage; yuvSize = TJ.bufSizeYUV(w, yuvpad, h, subsamp); dstBuf = new byte[yuvSize]; @@ -277,12 +281,13 @@ class TJBench { tjc.setSubsamp(subsamp); /* Execute once to preload cache */ - tjc.encodeYUV(dstBuf, flags); + yuvImage = new YUVImage(dstBuf, w, yuvpad, h, subsamp); + tjc.encodeYUV(yuvImage, flags); /* Benchmark */ for (i = 0, start = getTime(); (elapsed = getTime() - start) < benchTime; i++) - tjc.encodeYUV(dstBuf, flags); + tjc.encodeYUV(yuvImage, flags); if (quiet == 1) System.out.format("%-4d %-4d\t", w, h); @@ -360,7 +365,8 @@ class TJBench { for (i = 0; i < h; i++) System.arraycopy(srcBuf, w * ps * i, tmpBuf, pitch * i, w * ps); if (yuv == YUVCOMPRESS) - tjc.setSourceImageYUV(srcBuf, tilew, yuvpad, tileh); + tjc.setSourceImage(new YUVImage(srcBuf, tilew, yuvpad, tileh, + subsamp)); else tjc.setSourceImage(srcBuf, 0, 0, tilew, pitch, tileh, pf); tjc.setJPEGQuality(jpegQual); @@ -458,7 +464,7 @@ class TJBench { tjt = new TJTransformer(); - tjt.setJPEGImage(srcBuf, srcSize); + tjt.setSourceImage(srcBuf, srcSize); w = tjt.getWidth(); h = tjt.getHeight(); subsamp = tjt.getSubsamp(); diff --git a/java/TJExample.java b/java/TJExample.java index 75621143..2c6324dc 100644 --- a/java/TJExample.java +++ b/java/TJExample.java @@ -277,7 +277,7 @@ public class TJExample implements TJCustomFilter { scaleFactor.isOne()) { file = new File(argv[1]); FileOutputStream fos = new FileOutputStream(file); - fos.write(tjd.getJPEGBuf(), 0, tjd.getJPEGSize()); + fos.write(tjd.getSourceBuf(), 0, tjd.getSourceSize()); fos.close(); System.exit(0); } diff --git a/java/TJUnitTest.java b/java/TJUnitTest.java index 0bf8367b..d8b5c854 100644 --- a/java/TJUnitTest.java +++ b/java/TJUnitTest.java @@ -92,9 +92,7 @@ public class TJUnitTest { TJ.PF_RGB }; - private static final int YUVENCODE = 1; - private static final int YUVDECODE = 2; - private static int yuv = 0; + private static boolean doYUV = false; private static int pad = 4; private static boolean bi = false; @@ -534,54 +532,6 @@ public class TJUnitTest { return ((v + (p) - 1) & (~((p) - 1))); } - private static void initBufYUV(byte[] buf, int w, int pad, int h, - int subsamp) throws Exception { - int row, col; - int hsf = TJ.getMCUWidth(subsamp) / 8, vsf = TJ.getMCUHeight(subsamp) / 8; - int pw = PAD(w, hsf), ph = PAD(h, vsf); - int cw = pw / hsf, ch = ph / vsf; - int ypitch = PAD(pw, pad), uvpitch = PAD(cw, pad); - int halfway = 16, blockSize = 8; - - Arrays.fill(buf, (byte)0); - for (row = 0; row < ph; row++) { - for (col = 0; col < pw; col++) { - int index = ypitch * row + col; - if (((row / blockSize) + (col / blockSize)) % 2 == 0) { - if (row < halfway) - buf[index] = (byte)255; - else - buf[index] = 0; - } else { - if (row < halfway) - buf[index] = 76; - else - buf[index] = (byte)226; - } - } - } - if (subsamp != TJ.SAMP_GRAY) { - halfway = 16 / vsf; - for (row = 0; row < ch; row++) { - for (col = 0; col < cw; col++) { - int uindex = ypitch * ph + (uvpitch * row + col), - vindex = ypitch * ph + uvpitch * ch + (uvpitch * row + col); - if (((row * vsf / blockSize) + (col * hsf / blockSize)) % 2 == 0) { - buf[uindex] = buf[vindex] = (byte)128; - } else { - if (row < halfway) { - buf[uindex] = 85; - buf[vindex] = (byte)255; - } else { - buf[uindex] = 0; - buf[vindex] = (byte)149; - } - } - } - } - } - } - private static int checkBufYUV(byte[] buf, int size, int w, int h, int subsamp, TJScalingFactor sf) throws Exception { @@ -686,87 +636,68 @@ public class TJUnitTest { private static int compTest(TJCompressor tjc, byte[] dstBuf, int w, int h, int pf, String baseName, int subsamp, int jpegQual, int flags) throws Exception { - String tempstr; + String tempStr; byte[] srcBuf = null; BufferedImage img = null; - String pfStr; + String pfStr, pfStrLong; + String buStr = (flags & TJ.FLAG_BOTTOMUP) != 0 ? "BU" : "TD"; String buStrLong = (flags & TJ.FLAG_BOTTOMUP) != 0 ? "Bottom-Up" : "Top-Down "; - String buStr = (flags & TJ.FLAG_BOTTOMUP) != 0 ? "BU" : "TD"; int size = 0, ps, imgType = pf; - if (yuv == YUVDECODE) { - System.out.format("YUV %s %s --> JPEG Q%d ... ", subNameLong[subsamp], - buStrLong, jpegQual); - srcBuf = new byte[TJ.bufSizeYUV(w, pad, h, subsamp)]; - initBufYUV(srcBuf, w, pad, h, subsamp); - pfStr = "YUV"; + if (bi) { + pf = biTypePF(imgType); + pfStr = biTypeStr(imgType); + pfStrLong = pfStr + " (" + pixFormatStr[pf] + ")"; } else { - if (bi) { - pf = biTypePF(imgType); - pfStr = biTypeStr(imgType); - } else - pfStr = pixFormatStr[pf]; - ps = TJ.getPixelSize(pf); + pfStr = pixFormatStr[pf]; + pfStrLong = pfStr; + } + ps = TJ.getPixelSize(pf); - System.out.print(pfStr + " "); - if (bi) - System.out.print("(" + pixFormatStr[pf] + ") "); - if (yuv == YUVENCODE) - System.out.format("%s -> %s YUV ... ", buStrLong, - subNameLong[subsamp]); - else - System.out.format("%s -> %s Q%d ... ", buStrLong, subNameLong[subsamp], - jpegQual); - - if (bi) { - img = new BufferedImage(w, h, imgType); - initImg(img, pf, flags); - tempstr = baseName + "_enc_" + pfStr + "_" + buStr + "_" + - subName[subsamp] + "_Q" + jpegQual + ".png"; - File file = new File(tempstr); - ImageIO.write(img, "png", file); - } else { - srcBuf = new byte[w * h * ps + 1]; - initBuf(srcBuf, w, w * ps, h, pf, flags); - } + if (bi) { + img = new BufferedImage(w, h, imgType); + initImg(img, pf, flags); + tempStr = baseName + "_enc_" + pfStr + "_" + buStr + "_" + + subName[subsamp] + "_Q" + jpegQual + ".png"; + File file = new File(tempStr); + ImageIO.write(img, "png", file); + tjc.setSourceImage(img, 0, 0, 0, 0); + } else { + srcBuf = new byte[w * h * ps + 1]; + initBuf(srcBuf, w, w * ps, h, pf, flags); + tjc.setSourceImage(srcBuf, 0, 0, w, 0, h, pf); } Arrays.fill(dstBuf, (byte)0); tjc.setSubsamp(subsamp); tjc.setJPEGQuality(jpegQual); - tjc.setYUVPad(pad); - if (yuv == YUVDECODE) - tjc.setSourceImageYUV(srcBuf, w, pad, h); - else if (bi) - tjc.setSourceImage(img, 0, 0, 0, 0); - else - tjc.setSourceImage(srcBuf, 0, 0, w, 0, h, pf); - if (yuv == YUVENCODE) - tjc.encodeYUV(dstBuf, flags); - else - tjc.compress(dstBuf, flags); - size = tjc.getCompressedSize(); - - if (yuv == YUVENCODE) - tempstr = baseName + "_enc_" + pfStr + "_" + buStr + "_" + - subName[subsamp] + ".yuv"; - else - tempstr = baseName + "_enc_" + pfStr + "_" + buStr + "_" + - subName[subsamp] + "_Q" + jpegQual + ".jpg"; - writeJPEG(dstBuf, size, tempstr); - - if (yuv == YUVENCODE) { - if (checkBufYUV(dstBuf, size, w, h, subsamp, - new TJScalingFactor(1, 1)) == 1) - System.out.print("Passed."); + if (doYUV) { + System.out.format("%s %s -> YUV %s ... ", pfStrLong, buStrLong, + subNameLong[subsamp]); + YUVImage yuvImage = tjc.encodeYUV(pad, flags); + if (checkBufYUV(yuvImage.getBuf(), yuvImage.getSize(), w, h, subsamp, + new TJScalingFactor(1, 1)) == 1) + System.out.print("Passed.\n"); else { - System.out.print("FAILED!"); + System.out.print("FAILED!\n"); exitStatus = -1; } - } else - System.out.print("Done."); - System.out.println("\n Result in " + tempstr); + + System.out.format("YUV %s %s -> JPEG Q%d ... ", subNameLong[subsamp], + buStrLong, jpegQual); + tjc.setSourceImage(yuvImage); + } else { + System.out.format("%s %s -> %s Q%d ... ", pfStrLong, buStrLong, + subNameLong[subsamp], jpegQual); + } + tjc.compress(dstBuf, flags); + size = tjc.getCompressedSize(); + + tempStr = baseName + "_enc_" + pfStr + "_" + buStr + "_" + + subName[subsamp] + "_Q" + jpegQual + ".jpg"; + writeJPEG(dstBuf, size, tempStr); + System.out.println("Done.\n Result in " + tempStr); return size; } @@ -775,39 +706,25 @@ public class TJUnitTest { int jpegSize, int w, int h, int pf, String baseName, int subsamp, int flags, TJScalingFactor sf) throws Exception { - String pfStr, tempstr; + String pfStr, pfStrLong, tempStr; + String buStrLong = (flags & TJ.FLAG_BOTTOMUP) != 0 ? + "Bottom-Up" : "Top-Down "; int scaledWidth = sf.getScaled(w); int scaledHeight = sf.getScaled(h); int temp1, temp2, imgType = pf; BufferedImage img = null; byte[] dstBuf = null; - if (yuv == YUVENCODE) return; - if (bi) { pf = biTypePF(imgType); pfStr = biTypeStr(imgType); - } else + pfStrLong = pfStr + " (" + pixFormatStr[pf] + ")"; + } else { pfStr = pixFormatStr[pf]; - - System.out.print("JPEG -> "); - if (yuv == YUVDECODE) - System.out.print("YUV " + subNameLong[subsamp] + " "); - else { - System.out.print(pfStr + " "); - if (bi) - System.out.print("(" + pixFormatStr[pf] + ") "); - if ((flags & TJ.FLAG_BOTTOMUP) != 0) - System.out.print("Bottom-Up "); - else - System.out.print("Top-Down "); + pfStrLong = pfStr; } - if (!sf.isOne()) - System.out.print(sf.getNum() + "/" + sf.getDenom() + " ... "); - else - System.out.print("... "); - tjd.setJPEGImage(jpegBuf, jpegSize); + tjd.setSourceImage(jpegBuf, jpegSize); if (tjd.getWidth() != w || tjd.getHeight() != h || tjd.getSubsamp() != subsamp) throw new Exception("Incorrect JPEG header"); @@ -819,43 +736,52 @@ public class TJUnitTest { if (temp1 != scaledWidth || temp2 != scaledHeight) throw new Exception("Scaled size mismatch"); - if (yuv == YUVDECODE) - dstBuf = tjd.decompressToYUV(scaledWidth, pad, scaledHeight, flags); - else { - if (bi) - img = tjd.decompress(scaledWidth, scaledHeight, imgType, flags); - else - dstBuf = tjd.decompress(scaledWidth, 0, scaledHeight, pf, flags); + if (doYUV) { + System.out.format("JPEG -> YUV %s ", subNameLong[subsamp]); + if(!sf.isOne()) + System.out.format("%d/%d ... ", sf.getNum(), sf.getDenom()); + else System.out.print("... "); + YUVImage yuvImage = tjd.decompressToYUV(scaledWidth, pad, scaledHeight, + flags); + if (checkBufYUV(yuvImage.getBuf(), yuvImage.getSize(), scaledWidth, + scaledHeight, subsamp, sf) == 1) + System.out.print("Passed.\n"); + else { + System.out.print("FAILED!\n"); exitStatus = -1; + } + + System.out.format("YUV %s -> %s %s ... ", subNameLong[subsamp], + pfStrLong, buStrLong); + tjd.setSourceImage(yuvImage); + } else { + System.out.format("JPEG -> %s %s ", pfStrLong, buStrLong); + if(!sf.isOne()) + System.out.format("%d/%d ... ", sf.getNum(), sf.getDenom()); + else System.out.print("... "); } + if (bi) + img = tjd.decompress(scaledWidth, scaledHeight, imgType, flags); + else + dstBuf = tjd.decompress(scaledWidth, 0, scaledHeight, pf, flags); if (bi) { - tempstr = baseName + "_dec_" + pfStr + "_" + + tempStr = baseName + "_dec_" + pfStr + "_" + (((flags & TJ.FLAG_BOTTOMUP) != 0) ? "BU" : "TD") + "_" + subName[subsamp] + "_" + (double)sf.getNum() / (double)sf.getDenom() + "x" + ".png"; - File file = new File(tempstr); + File file = new File(tempStr); ImageIO.write(img, "png", file); } - if (yuv == YUVDECODE) { - if (checkBufYUV(dstBuf, dstBuf.length, scaledWidth, scaledHeight, - subsamp, sf) == 1) - System.out.print("Passed."); - else { - System.out.print("FAILED!"); exitStatus = -1; - } - } else { - if ((bi && checkImg(img, pf, subsamp, sf, flags) == 1) || - (!bi && checkBuf(dstBuf, scaledWidth, - scaledWidth * TJ.getPixelSize(pf), scaledHeight, pf, - subsamp, sf, flags) == 1)) - System.out.print("Passed."); - else { - System.out.print("FAILED!"); - exitStatus = -1; - } + if ((bi && checkImg(img, pf, subsamp, sf, flags) == 1) || + (!bi && checkBuf(dstBuf, scaledWidth, + scaledWidth * TJ.getPixelSize(pf), scaledHeight, pf, + subsamp, sf, flags) == 1)) + System.out.print("Passed.\n"); + else { + System.out.print("FAILED!\n"); + exitStatus = -1; } - System.out.print("\n"); } private static void decompTest(TJDecompressor tjd, byte[] jpegBuf, @@ -884,10 +810,7 @@ public class TJUnitTest { int size; byte[] dstBuf; - if (yuv == YUVENCODE) - dstBuf = new byte[TJ.bufSizeYUV(w, pad, h, subsamp)]; - else - dstBuf = new byte[TJ.bufSize(w, h, subsamp)]; + dstBuf = new byte[TJ.bufSize(w, h, subsamp)]; try { tjc = new TJCompressor(); @@ -900,20 +823,16 @@ public class TJUnitTest { if (subsamp == TJ.SAMP_422 || subsamp == TJ.SAMP_420 || subsamp == TJ.SAMP_440 || subsamp == TJ.SAMP_411) flags |= TJ.FLAG_FASTUPSAMPLE; - if (i == 1) { - if (yuv == YUVDECODE) { - tjc.close(); - tjd.close(); - return; - } else - flags |= TJ.FLAG_BOTTOMUP; - } + if (i == 1) + flags |= TJ.FLAG_BOTTOMUP; size = compTest(tjc, dstBuf, w, h, pf, baseName, subsamp, 100, flags); decompTest(tjd, dstBuf, size, w, h, pf, baseName, subsamp, flags); - if (pf >= TJ.PF_RGBX && pf <= TJ.PF_XRGB && !bi) + if (pf >= TJ.PF_RGBX && pf <= TJ.PF_XRGB && !bi) { + System.out.print("\n"); decompTest(tjd, dstBuf, size, w, h, pf + (TJ.PF_RGBA - TJ.PF_RGBX), baseName, subsamp, flags); + } System.out.print("\n"); } } @@ -929,7 +848,8 @@ public class TJUnitTest { private static void bufSizeTest() throws Exception { int w, h, i, subsamp; - byte[] srcBuf, dstBuf; + byte[] srcBuf, dstBuf = null; + YUVImage dstImage = null; TJCompressor tjc = null; Random r = new Random(); @@ -943,8 +863,8 @@ public class TJUnitTest { if (h % 100 == 0) System.out.format("%04d x %04d\b\b\b\b\b\b\b\b\b\b\b", w, h); srcBuf = new byte[w * h * 4]; - if (yuv == YUVENCODE) - dstBuf = new byte[TJ.bufSizeYUV(w, pad, h, subsamp)]; + if (doYUV) + dstImage = new YUVImage(w, pad, h, subsamp); else dstBuf = new byte[TJ.bufSize(w, h, subsamp)]; for (i = 0; i < w * h * 4; i++) { @@ -953,23 +873,22 @@ public class TJUnitTest { tjc.setSourceImage(srcBuf, 0, 0, w, 0, h, TJ.PF_BGRX); tjc.setSubsamp(subsamp); tjc.setJPEGQuality(100); - tjc.setYUVPad(pad); - if (yuv == YUVENCODE) - tjc.encodeYUV(dstBuf, 0); + if (doYUV) + tjc.encodeYUV(dstImage, 0); else tjc.compress(dstBuf, 0); srcBuf = new byte[h * w * 4]; - if (yuv == YUVENCODE) - dstBuf = new byte[TJ.bufSizeYUV(h, pad, w, subsamp)]; + if (doYUV) + dstImage = new YUVImage(h, pad, w, subsamp); else dstBuf = new byte[TJ.bufSize(h, w, subsamp)]; for (i = 0; i < h * w * 4; i++) { srcBuf[i] = (byte)(r.nextInt(2) * 255); } tjc.setSourceImage(srcBuf, 0, 0, h, 0, w, TJ.PF_BGRX); - if (yuv == YUVENCODE) - tjc.encodeYUV(dstBuf, 0); + if (doYUV) + tjc.encodeYUV(dstImage, 0); else tjc.compress(dstBuf, 0); } @@ -986,10 +905,9 @@ public class TJUnitTest { public static void main(String[] argv) { try { String testName = "javatest"; - boolean doyuv = false; for (int i = 0; i < argv.length; i++) { if (argv[i].equalsIgnoreCase("-yuv")) - doyuv = true; + doYUV = true; if (argv[i].equalsIgnoreCase("-noyuvpad")) pad = 1; if (argv[i].substring(0, 1).equalsIgnoreCase("-h") || @@ -1000,10 +918,8 @@ public class TJUnitTest { testName = "javabitest"; } } - if (doyuv) { - yuv = YUVENCODE; + if (doYUV) _4byteFormats[4] = -1; - } doTest(35, 39, bi ? _3byteFormatsBI : _3byteFormats, TJ.SAMP_444, testName); doTest(39, 41, bi ? _4byteFormatsBI : _4byteFormats, TJ.SAMP_444, @@ -1032,23 +948,15 @@ public class TJUnitTest { testName); if (!bi) bufSizeTest(); - if (doyuv && !bi) { + if (doYUV && !bi) { System.out.print("\n--------------------\n\n"); - yuv = YUVDECODE; doTest(48, 48, onlyRGB, TJ.SAMP_444, "javatest_yuv0"); - doTest(35, 39, onlyRGB, TJ.SAMP_444, "javatest_yuv1"); doTest(48, 48, onlyRGB, TJ.SAMP_422, "javatest_yuv0"); - doTest(39, 41, onlyRGB, TJ.SAMP_422, "javatest_yuv1"); doTest(48, 48, onlyRGB, TJ.SAMP_420, "javatest_yuv0"); - doTest(41, 35, onlyRGB, TJ.SAMP_420, "javatest_yuv1"); doTest(48, 48, onlyRGB, TJ.SAMP_440, "javatest_yuv0"); - doTest(35, 39, onlyRGB, TJ.SAMP_440, "javatest_yuv1"); doTest(48, 48, onlyRGB, TJ.SAMP_411, "javatest_yuv0"); - doTest(39, 41, onlyRGB, TJ.SAMP_411, "javatest_yuv1"); doTest(48, 48, onlyRGB, TJ.SAMP_GRAY, "javatest_yuv0"); - doTest(41, 35, onlyRGB, TJ.SAMP_GRAY, "javatest_yuv1"); doTest(48, 48, onlyGray, TJ.SAMP_GRAY, "javatest_yuv0"); - doTest(35, 39, onlyGray, TJ.SAMP_GRAY, "javatest_yuv1"); } } catch(Exception e) { e.printStackTrace(); diff --git a/java/doc/allclasses-frame.html b/java/doc/allclasses-frame.html index b2810b52..2183aa4e 100644 --- a/java/doc/allclasses-frame.html +++ b/java/doc/allclasses-frame.html @@ -33,6 +33,8 @@ All Classes
TJTransformer
+YUVImage +
handlea handle to a TurboJPEG compressor or transformer instance
diff --git a/java/doc/allclasses-noframe.html b/java/doc/allclasses-noframe.html index ddc3d633..41ed55e6 100644 --- a/java/doc/allclasses-noframe.html +++ b/java/doc/allclasses-noframe.html @@ -33,6 +33,8 @@ All Classes
TJTransformer
+YUVImage +
diff --git a/java/doc/deprecated-list.html b/java/doc/deprecated-list.html index bcf6858f..a0a67a6d 100644 --- a/java/doc/deprecated-list.html +++ b/java/doc/deprecated-list.html @@ -149,8 +149,7 @@ function windowTitle() org.libjpegturbo.turbojpeg.TJDecompressor.decompressToYUV(byte[], int)
-          Use TJDecompressor.decompressToYUV(byte[], int, int, int, int) - instead.  +          Use TJDecompressor.decompressToYUV(YUVImage, int) instead.  org.libjpegturbo.turbojpeg.TJDecompressor.decompressToYUV(int) @@ -172,6 +171,31 @@ function windowTitle() TJCompressor.encodeYUV(int) instead.  +org.libjpegturbo.turbojpeg.TJCompressor.encodeYUV(byte[], int) +
+          Use TJCompressor.encodeYUV(YUVImage, int) instead.  + + +org.libjpegturbo.turbojpeg.TJCompressor.encodeYUV(int) +
+          Use TJCompressor.encodeYUV(int, int) instead.  + + +org.libjpegturbo.turbojpeg.TJDecompressor.getJPEGBuf() +
+          Use TJDecompressor.getSourceBuf() instead.  + + +org.libjpegturbo.turbojpeg.TJDecompressor.getJPEGSize() +
+          Use TJDecompressor.getSourceSize() instead.  + + +org.libjpegturbo.turbojpeg.TJDecompressor.setJPEGImage(byte[], int) +
+          Use TJDecompressor.setSourceImage(byte[], int) instead.  + + org.libjpegturbo.turbojpeg.TJCompressor.setSourceImage(byte[], int, int, int, int)
          Use diff --git a/java/doc/index-all.html b/java/doc/index-all.html index 9db10754..df71bdee 100644 --- a/java/doc/index-all.html +++ b/java/doc/index-all.html @@ -74,7 +74,7 @@ function windowTitle() -B C D E F G H I J N O P S T
+B C D E F G H I J N O P S T Y

B

@@ -148,8 +148,9 @@ Method in interface org.libjpegturbo.turbojpeg.decompress(byte[], int, int, int, int, int, int, int) - Method in class org.libjpegturbo.turbojpeg.TJDecompressor -
Decompress the JPEG source image associated with this decompressor - instance and output a decompressed image to the given destination buffer. +
Decompress the JPEG source image or decode the YUV source image associated + with this decompressor instance and output a grayscale, RGB, or CMYK image + to the given destination buffer.
decompress(byte[], int, int, int, int, int) - Method in class org.libjpegturbo.turbojpeg.TJDecompressor
Deprecated. Use @@ -160,30 +161,32 @@ Method in class org.libjpegturbo.turbojpeg.decompress(int[], int, int, int, int, int, int, int) - Method in class org.libjpegturbo.turbojpeg.TJDecompressor -
Decompress the JPEG source image associated with this decompressor - instance and output a decompressed image to the given destination buffer. +
Decompress the JPEG source image or decode the YUV source image associated + with this decompressor instance and output a grayscale, RGB, or CMYK image + to the given destination buffer.
decompress(BufferedImage, int) - Method in class org.libjpegturbo.turbojpeg.TJDecompressor -
Decompress the JPEG source image associated with this decompressor - instance and output a decompressed image to the given - BufferedImage instance. +
Decompress the JPEG source image or decode the YUV source image associated + with this decompressor instance and output a decompressed/decoded image to + the given BufferedImage instance.
decompress(int, int, int, int) - Method in class org.libjpegturbo.turbojpeg.TJDecompressor -
Decompress the JPEG source image associated with this decompressor - instance and return a BufferedImage instance containing the - decompressed image. -
decompressToYUV(byte[], int, int, int, int) - +
Decompress the JPEG source image or decode the YUV source image associated + with this decompressor instance and return a BufferedImage + instance containing the decompressed/decoded image. +
decompressToYUV(YUVImage, int) - Method in class org.libjpegturbo.turbojpeg.TJDecompressor
Decompress the JPEG source image associated with this decompressor - instance and output a YUV planar image to the given destination buffer. + instance into a YUV planar image and store it in the given + YUVImage instance.
decompressToYUV(byte[], int) - Method in class org.libjpegturbo.turbojpeg.TJDecompressor -
Deprecated. Use TJDecompressor.decompressToYUV(byte[], int, int, int, int) - instead. +
Deprecated. Use TJDecompressor.decompressToYUV(YUVImage, int) instead.
decompressToYUV(int, int, int, int) - Method in class org.libjpegturbo.turbojpeg.TJDecompressor
Decompress the JPEG source image associated with this decompressor - instance and return a buffer containing a YUV planar image. + instance into a YUV planar image and return a YUVImage + instance containing the decompressed image.
decompressToYUV(int) - Method in class org.libjpegturbo.turbojpeg.TJDecompressor
Deprecated. Use TJDecompressor.decompressToYUV(int, int, int, int) instead. @@ -192,14 +195,22 @@ Method in class org.libjpegturbo.turbojpeg.

E

+
encodeYUV(YUVImage, int) - +Method in class org.libjpegturbo.turbojpeg.TJCompressor +
Encode the uncompressed source image associated with this compressor + instance into a YUV planar image and store it in the given + YUVImage instance.
encodeYUV(byte[], int) - Method in class org.libjpegturbo.turbojpeg.TJCompressor -
Encode the uncompressed source image associated with this compressor - instance and output a YUV planar image to the given destination buffer. -
encodeYUV(int) - +
Deprecated. Use TJCompressor.encodeYUV(YUVImage, int) instead. +
encodeYUV(int, int) - Method in class org.libjpegturbo.turbojpeg.TJCompressor
Encode the uncompressed source image associated with this compressor - instance and return a buffer containing a YUV planar image. + instance into a YUV planar image and return a YUVImage + instance containing the encoded image. +
encodeYUV(int) - +Method in class org.libjpegturbo.turbojpeg.TJCompressor +
Deprecated. Use TJCompressor.encodeYUV(int, int) instead.
encodeYUV(BufferedImage, byte[], int) - Method in class org.libjpegturbo.turbojpeg.TJCompressor
Deprecated. Use @@ -262,10 +273,13 @@ Static variable in class org.libjpegturbo.turbojpeg.TJ
For the given pixel format, returns the number of bytes that the blue component is offset from the start of the pixel. +
getBuf() - +Method in class org.libjpegturbo.turbojpeg.YUVImage +
Returns the YUV image buffer
getColorspace() - Method in class org.libjpegturbo.turbojpeg.TJDecompressor -
Returns the colorspace used in the JPEG image associated with this - decompressor instance. +
Returns the colorspace used in the source image (JPEG or YUV) associated + with this decompressor instance.
getCompressedSize() - Method in class org.libjpegturbo.turbojpeg.TJCompressor
Returns the size of the image (in bytes) generated by the most recent @@ -279,15 +293,17 @@ Static method in class org.libjpegturbo.turbojpeg.getHeight() - Method in class org.libjpegturbo.turbojpeg.TJDecompressor -
Returns the height of the JPEG image associated with this decompressor - instance. +
Returns the height of the source image (JPEG or YUV) associated with this + decompressor instance. +
getHeight() - +Method in class org.libjpegturbo.turbojpeg.YUVImage +
Returns the height of the YUV image.
getJPEGBuf() - Method in class org.libjpegturbo.turbojpeg.TJDecompressor -
Returns the JPEG image buffer associated with this decompressor instance. +
Deprecated. Use TJDecompressor.getSourceBuf() instead.
getJPEGSize() - Method in class org.libjpegturbo.turbojpeg.TJDecompressor -
Returns the size of the JPEG image (in bytes) associated with this - decompressor instance. +
Deprecated. Use TJDecompressor.getSourceSize() instead.
getMCUHeight(int) - Static method in class org.libjpegturbo.turbojpeg.TJ
Returns the MCU block height for the given level of chrominance @@ -299,6 +315,9 @@ Static method in class org.libjpegturbo.turbojpeg.getNum() - Method in class org.libjpegturbo.turbojpeg.TJScalingFactor
Returns numerator +
getPad() - +Method in class org.libjpegturbo.turbojpeg.YUVImage +
Returns the line padding used in the YUV image buffer.
getPixelSize(int) - Static method in class org.libjpegturbo.turbojpeg.TJ
Returns the pixel size (in bytes) for the given pixel format. @@ -323,18 +342,35 @@ Method in class org.libjpegturbo.turbojpeg.TJ
Returns a list of fractional scaling factors that the JPEG decompressor in this implementation of TurboJPEG supports. +
getSize() - +Method in class org.libjpegturbo.turbojpeg.YUVImage +
Returns the size (in bytes) of the YUV image buffer +
getSourceBuf() - +Method in class org.libjpegturbo.turbojpeg.TJDecompressor +
Returns the source image buffer associated with this decompressor + instance. +
getSourceSize() - +Method in class org.libjpegturbo.turbojpeg.TJDecompressor +
Returns the size of the source image (in bytes) associated with this + decompressor instance.
getSubsamp() - Method in class org.libjpegturbo.turbojpeg.TJDecompressor -
Returns the level of chrominance subsampling used in the JPEG image - associated with this decompressor instance. +
Returns the level of chrominance subsampling used in the source image + (JPEG or YUV) associated with this decompressor instance. +
getSubsamp() - +Method in class org.libjpegturbo.turbojpeg.YUVImage +
Returns the level of chrominance subsampling used in the YUV image.
getTransformedSizes() - Method in class org.libjpegturbo.turbojpeg.TJTransformer -
Returns an array containing the sizes of the transformed JPEG images from - the most recent call to transform(). +
Returns an array containing the sizes of the transformed JPEG images + generated by the most recent transform operation.
getWidth() - Method in class org.libjpegturbo.turbojpeg.TJDecompressor -
Returns the width of the JPEG image associated with this decompressor - instance. +
Returns the width of the source image (JPEG or YUV) associated with this + decompressor instance. +
getWidth() - +Method in class org.libjpegturbo.turbojpeg.YUVImage +
Returns the width of the YUV image.

@@ -343,6 +379,9 @@ Method in class org.libjpegturbo.turbojpeg.handle - Variable in class org.libjpegturbo.turbojpeg.TJDecompressor
  +
handle - +Variable in class org.libjpegturbo.turbojpeg.YUVImage +
 


@@ -363,18 +402,6 @@ Variable in class org.libjpegturbo.turbojpeg.jpegBufSize - Variable in class org.libjpegturbo.turbojpeg.TJDecompressor
  -
jpegColorspace - -Variable in class org.libjpegturbo.turbojpeg.TJDecompressor -
  -
jpegHeight - -Variable in class org.libjpegturbo.turbojpeg.TJDecompressor -
  -
jpegSubsamp - -Variable in class org.libjpegturbo.turbojpeg.TJDecompressor -
  -
jpegWidth - -Variable in class org.libjpegturbo.turbojpeg.TJDecompressor -
 


@@ -513,32 +540,50 @@ Static variable in class org.libjpegturbo.turbojpeg.setJPEGImage(byte[], int) - Method in class org.libjpegturbo.turbojpeg.TJDecompressor -
Associate the JPEG image of length imageSize bytes stored in - jpegImage with this decompressor instance. +
Deprecated. Use TJDecompressor.setSourceImage(byte[], int) instead.
setJPEGQuality(int) - Method in class org.libjpegturbo.turbojpeg.TJCompressor
Set the JPEG image quality level for subsequent compress operations.
setSourceImage(byte[], int, int, int, int, int, int) - Method in class org.libjpegturbo.turbojpeg.TJCompressor -
Associate an uncompressed source image with this compressor instance. +
Associate an uncompressed RGB, grayscale, or CMYK source image with this + compressor instance.
setSourceImage(byte[], int, int, int, int) - Method in class org.libjpegturbo.turbojpeg.TJCompressor
Deprecated. Use TJCompressor.setSourceImage(byte[], int, int, int, int, int, int) instead.
setSourceImage(BufferedImage, int, int, int, int) - Method in class org.libjpegturbo.turbojpeg.TJCompressor -
Associate an uncompressed source image with this compressor instance. -
setSourceImageYUV(byte[], int, int, int) - +
Associate an uncompressed RGB or grayscale source image with this + compressor instance. +
setSourceImage(YUVImage) - Method in class org.libjpegturbo.turbojpeg.TJCompressor
Associate an uncompressed YUV planar source image with this compressor instance. +
setSourceImage(byte[], int) - +Method in class org.libjpegturbo.turbojpeg.TJDecompressor +
Associate the JPEG image of length imageSize bytes stored in + srcImage with this decompressor instance. +
setSourceImage(YUVImage) - +Method in class org.libjpegturbo.turbojpeg.TJDecompressor +
Associate the specified YUV planar source image with this decompressor + instance.
setSubsamp(int) - Method in class org.libjpegturbo.turbojpeg.TJCompressor
Set the level of chrominance subsampling for subsequent compress/encode operations. -
setYUVPad(int) - -Method in class org.libjpegturbo.turbojpeg.TJCompressor -
Set the plane padding for subsequent YUV encode operations. +
srcColorspace - +Variable in class org.libjpegturbo.turbojpeg.TJDecompressor +
  +
srcHeight - +Variable in class org.libjpegturbo.turbojpeg.TJDecompressor +
  +
srcSubsamp - +Variable in class org.libjpegturbo.turbojpeg.TJDecompressor +
  +
srcWidth - +Variable in class org.libjpegturbo.turbojpeg.TJDecompressor +
 

@@ -550,32 +595,37 @@ Constructor for class org.libjpegturbo.turbojpeg.TJCompressor - Class in org.libjpegturbo.turbojpeg
TurboJPEG compressor
TJCompressor() - Constructor for class org.libjpegturbo.turbojpeg.TJCompressor
Create a TurboJPEG compressor instance. +
TJCompressor(byte[], int, int, int, int, int, int) - +Constructor for class org.libjpegturbo.turbojpeg.TJCompressor +
Create a TurboJPEG compressor instance and associate the uncompressed + source image stored in srcImage with the newly created + instance.
TJCompressor(byte[], int, int, int, int) - Constructor for class org.libjpegturbo.turbojpeg.TJCompressor
Deprecated. Use TJCompressor.TJCompressor(byte[], int, int, int, int, int, int) instead. -
TJCompressor(byte[], int, int, int, int, int, int) - -Constructor for class org.libjpegturbo.turbojpeg.TJCompressor -
Create a TurboJPEG compressor instance and associate the uncompressed - source image stored in srcImage with the newly-created - instance.
TJCompressor(BufferedImage, int, int, int, int) - Constructor for class org.libjpegturbo.turbojpeg.TJCompressor
Create a TurboJPEG compressor instance and associate the uncompressed - source image stored in srcImage with the newly-created + source image stored in srcImage with the newly created instance.
TJCustomFilter - Interface in org.libjpegturbo.turbojpeg
Custom filter callback interface
TJDecompressor - Class in org.libjpegturbo.turbojpeg
TurboJPEG decompressor
TJDecompressor() - Constructor for class org.libjpegturbo.turbojpeg.TJDecompressor
Create a TurboJPEG decompresssor instance.
TJDecompressor(byte[]) - Constructor for class org.libjpegturbo.turbojpeg.TJDecompressor -
Create a TurboJPEG decompressor instance and associate the JPEG image - stored in jpegImage with the newly-created instance. +
Create a TurboJPEG decompressor instance and associate the JPEG source + image stored in jpegImage with the newly created instance.
TJDecompressor(byte[], int) - Constructor for class org.libjpegturbo.turbojpeg.TJDecompressor -
Create a TurboJPEG decompressor instance and associate the JPEG image - of length imageSize bytes stored in jpegImage - with the newly-created instance. +
Create a TurboJPEG decompressor instance and associate the JPEG source + image of length imageSize bytes stored in + jpegImage with the newly created instance. +
TJDecompressor(YUVImage) - +Constructor for class org.libjpegturbo.turbojpeg.TJDecompressor +
Create a TurboJPEG decompressor instance and associate the YUV planar + source image stored in yuvImage with the newly created + instance.
TJScalingFactor - Class in org.libjpegturbo.turbojpeg
Fractional scaling factor
TJScalingFactor(int, int) - Constructor for class org.libjpegturbo.turbojpeg.TJScalingFactor
  @@ -594,12 +644,12 @@ Constructor for class org.libjpegturbo.turbojpeg.TJTransformer(byte[]) - Constructor for class org.libjpegturbo.turbojpeg.TJTransformer
Create a TurboJPEG lossless transformer instance and associate the JPEG - image stored in jpegImage with the newly-created instance. + image stored in jpegImage with the newly created instance.
TJTransformer(byte[], int) - Constructor for class org.libjpegturbo.turbojpeg.TJTransformer
Create a TurboJPEG lossless transformer instance and associate the JPEG image of length imageSize bytes stored in - jpegImage with the newly-created instance. + jpegImage with the newly created instance.
transform(byte[][], TJTransform[], int) - Method in class org.libjpegturbo.turbojpeg.TJTransformer
Losslessly transform the JPEG image associated with this transformer @@ -612,7 +662,38 @@ Method in class org.libjpegturbo.turbojpeg.B C D E F G H I J N O P S T +

+Y

+
+
yuvBuf - +Variable in class org.libjpegturbo.turbojpeg.YUVImage +
  +
yuvHeight - +Variable in class org.libjpegturbo.turbojpeg.YUVImage +
  +
yuvImage - +Variable in class org.libjpegturbo.turbojpeg.TJDecompressor +
  +
YUVImage - Class in org.libjpegturbo.turbojpeg
This class encapsulates a YUV planar image buffer and the metadata + associated with it.
YUVImage(int, int, int, int) - +Constructor for class org.libjpegturbo.turbojpeg.YUVImage +
Create a YUVImage instance with a new image buffer. +
YUVImage(byte[], int, int, int, int) - +Constructor for class org.libjpegturbo.turbojpeg.YUVImage +
Create a YUVImage instance from an existing YUV planar image + buffer. +
yuvPad - +Variable in class org.libjpegturbo.turbojpeg.YUVImage +
  +
yuvSubsamp - +Variable in class org.libjpegturbo.turbojpeg.YUVImage +
  +
yuvWidth - +Variable in class org.libjpegturbo.turbojpeg.YUVImage +
  +
+
+B C D E F G H I J N O P S T Y diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJCompressor.html b/java/doc/org/libjpegturbo/turbojpeg/TJCompressor.html index b6452f37..3c24544b 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/TJCompressor.html +++ b/java/doc/org/libjpegturbo/turbojpeg/TJCompressor.html @@ -128,7 +128,7 @@ TurboJPEG compressor
          Create a TurboJPEG compressor instance and associate the uncompressed - source image stored in srcImage with the newly-created + source image stored in srcImage with the newly created instance. @@ -153,7 +153,7 @@ TurboJPEG compressor
          Create a TurboJPEG compressor instance and associate the uncompressed - source image stored in srcImage with the newly-created + source image stored in srcImage with the newly created instance. @@ -246,17 +246,37 @@ TurboJPEG compressor int flags)

-          Encode the uncompressed source image associated with this compressor - instance and output a YUV planar image to the given destination buffer. +          Deprecated. Use encodeYUV(YUVImage, int) instead.  byte[] encodeYUV(int flags) +
+          Deprecated. Use encodeYUV(int, int) instead. + + + + YUVImage +encodeYUV(int pad, + int flags) +
          Encode the uncompressed source image associated with this compressor - instance and return a buffer containing a YUV planar image. + instance into a YUV planar image and return a YUVImage + instance containing the encoded image. + + + + void +encodeYUV(YUVImage dstImage, + int flags) + +
+          Encode the uncompressed source image associated with this compressor + instance into a YUV planar image and store it in the given + YUVImage instance. @@ -293,7 +313,8 @@ TurboJPEG compressor int height)
-          Associate an uncompressed source image with this compressor instance. +          Associate an uncompressed RGB or grayscale source image with this + compressor instance. @@ -320,15 +341,13 @@ TurboJPEG compressor int pixelFormat)
-          Associate an uncompressed source image with this compressor instance. +          Associate an uncompressed RGB, grayscale, or CMYK source image with this + compressor instance.  void -setSourceImageYUV(byte[] srcImage, - int width, - int pad, - int height) +setSourceImage(YUVImage srcImage)
          Associate an uncompressed YUV planar source image with this compressor @@ -343,14 +362,6 @@ TurboJPEG compressor           Set the level of chrominance subsampling for subsequent compress/encode operations. - - - void -setYUVPad(int pad) - -
-          Set the plane padding for subsequent YUV encode operations. -   @@ -389,6 +400,30 @@ public TJCompressor()
+

+TJCompressor

+
+public TJCompressor(byte[] srcImage,
+                    int x,
+                    int y,
+                    int width,
+                    int pitch,
+                    int height,
+                    int pixelFormat)
+             throws java.lang.Exception
+
+
Create a TurboJPEG compressor instance and associate the uncompressed + source image stored in srcImage with the newly created + instance. +

+

+
Parameters:
srcImage - see setSourceImage(byte[], int, int, int, int, int, int) for description
x - see setSourceImage(byte[], int, int, int, int, int, int) for description
y - see setSourceImage(byte[], int, int, int, int, int, int) for description
width - see setSourceImage(byte[], int, int, int, int, int, int) for description
pitch - see setSourceImage(byte[], int, int, int, int, int, int) for description
height - see setSourceImage(byte[], int, int, int, int, int, int) for description
pixelFormat - pixel format of the source image (one of + TJ.PF_*) +
Throws: +
java.lang.Exception
+
+
+

TJCompressor

@@ -410,30 +445,6 @@ TJCompressor
 
 
-

-TJCompressor

-
-public TJCompressor(byte[] srcImage,
-                    int x,
-                    int y,
-                    int width,
-                    int pitch,
-                    int height,
-                    int pixelFormat)
-             throws java.lang.Exception
-
-
Create a TurboJPEG compressor instance and associate the uncompressed - source image stored in srcImage with the newly-created - instance. -

-

-
Parameters:
srcImage - see setSourceImage(byte[], int, int, int, int, int, int) for description
x - see setSourceImage(byte[], int, int, int, int, int, int) for description
y - see setSourceImage(byte[], int, int, int, int, int, int) for description
width - see setSourceImage(byte[], int, int, int, int, int, int) for description
pitch - see setSourceImage(byte[], int, int, int, int, int, int) for description
height - see setSourceImage(byte[], int, int, int, int, int, int) for description
pixelFormat - pixel format of the source image (one of - TJ.PF_*) -
Throws: -
java.lang.Exception
-
-
-

TJCompressor

@@ -445,7 +456,7 @@ public TJCompressor(java.awt.image.BufferedImage srcImage,
              throws java.lang.Exception
Create a TurboJPEG compressor instance and associate the uncompressed - source image stored in srcImage with the newly-created + source image stored in srcImage with the newly created instance.

@@ -481,23 +492,24 @@ public void setSourceImage(byte[] srcImage, int pixelFormat) throws java.lang.Exception
-
Associate an uncompressed source image with this compressor instance. +
Associate an uncompressed RGB, grayscale, or CMYK source image with this + compressor instance.

Parameters:
srcImage - image buffer containing RGB, grayscale, or CMYK pixels to - be compressed
x - x offset (in pixels) of the region from which the JPEG image - should be compressed, relative to the start of srcImage.
y - y offset (in pixels) of the region from which the JPEG image - should be compressed, relative to the start of srcImage.
width - width (in pixels) of the region in the source image from - which the JPEG image should be compressed.
pitch - bytes per line of the source image. Normally, this should be + be compressed or encoded
x - x offset (in pixels) of the region in the source image from which + the JPEG or YUV image should be compressed/encoded
y - y offset (in pixels) of the region in the source image from which + the JPEG or YUV image should be compressed/encoded
width - width (in pixels) of the region in the source image from + which the JPEG or YUV image should be compressed/encoded
pitch - bytes per line of the source image. Normally, this should be width * TJ.pixelSize(pixelFormat) if the source image is unpadded, but you can use this parameter to, for instance, specify that the scanlines in the source image are padded to a 4-byte boundary or to - compress a JPEG image from a region of a larger source image. You can - also be clever and use this parameter to skip lines, etc. Setting this - parameter to 0 is the equivalent of setting it to width * - TJ.pixelSize(pixelFormat).
height - height (in pixels) of the region in the source image from - which the JPEG image should be compressed.
pixelFormat - pixel format of the source image (one of - TJ.PF_*) + compress/encode a JPEG or YUV image from a region of a larger source + image. You can also be clever and use this parameter to skip lines, etc. + Setting this parameter to 0 is the equivalent of setting it to + width * TJ.pixelSize(pixelFormat).
height - height (in pixels) of the region in the source image from + which the JPEG or YUV image should be compressed/encoded
pixelFormat - pixel format of the source image (one of + TJ.PF_*)
Throws:
java.lang.Exception
@@ -536,47 +548,35 @@ public void setSourceImage(java.awt.image.BufferedImage srcImage, int height) throws java.lang.Exception
-
Associate an uncompressed source image with this compressor instance. +
Associate an uncompressed RGB or grayscale source image with this + compressor instance.

Parameters:
srcImage - a BufferedImage instance containing RGB or - grayscale pixels to be compressed
x - x offset (in pixels) of the region in the source image from which - the JPEG image should be compressed
y - y offset (in pixels) of the region in the source image from which - the JPEG image should be compressed
width - width (in pixels) of the region in the source image from - which the JPEG image should be compressed (0 = compress the whole image)
height - height (in pixels) of the region in the source image from - which the JPEG image should be compressed (0 = compress the whole image) + grayscale pixels to be compressed or encoded
x - x offset (in pixels) of the region in the source image from which + the JPEG or YUV image should be compressed/encoded
y - y offset (in pixels) of the region in the source image from which + the JPEG or YUV image should be compressed/encoded
width - width (in pixels) of the region in the source image from + which the JPEG or YUV image should be compressed/encoded (0 = use the + width of the source image)
height - height (in pixels) of the region in the source image from + which the JPEG or YUV image should be compressed/encoded (0 = use the + height of the source image)
Throws:
java.lang.Exception

-

-setSourceImageYUV

+

+setSourceImage

-public void setSourceImageYUV(byte[] srcImage,
-                              int width,
-                              int pad,
-                              int height)
-                       throws java.lang.Exception
+public void setSourceImage(YUVImage srcImage) + throws java.lang.Exception
Associate an uncompressed YUV planar source image with this compressor instance.

-
Parameters:
srcImage - image buffer containing a YUV planar image to be - compressed. The Y, U (Cb), and V (Cr) image planes should be stored - sequentially in the buffer, and the size of each plane is determined by - the specified width, height, and padding, as well as the level of - chrominance subsampling (specified using setSubsamp(int).) If the - chrominance components are subsampled along the horizontal dimension, then - the width of the luminance plane should be padded to the nearest multiple - of 2 (same goes for the height of the luminance plane, if the chrominance - components are subsampled along the vertical dimension.) This is - irrespective of any additional padding specified in the pad - parameter.
width - width (in pixels) of the source image
pad - the line padding used in the source image. For instance, if - each line in each plane of the YUV image is padded to the nearest multiple - of 4 bytes, then pad should be set to 4.
height - height (in pixels) of the source image +
Parameters:
srcImage - YUV planar image to be compressed
Throws:
java.lang.Exception
@@ -598,13 +598,17 @@ public void setSubsamp(int newSubsamp) sensitive to small changes in brightness than to small changes in color.) This is called "chrominance subsampling".

- NOTE: When compressing a YUV planar image into a JPEG image, this method - also specifies the level of chrominance subsampling used in the source - image. + NOTE: This method has no effect when compressing a JPEG image from a YUV + planar source. In that case, the level of chrominance subsampling in + the JPEG image is determined by the source. Further, this method has no + effect when encoding to a pre-allocated YUVImage instance. In + that case, the level of chrominance subsampling is determined by the + destination.

-
Parameters:
newSubsamp - the new level of chrominance subsampling (one of - TJ.SAMP_*) +
Parameters:
newSubsamp - the level of chrominance subsampling to use in + subsequent compress/encode oeprations (one of + TJ.SAMP_*)
Throws:
java.lang.Exception
@@ -641,7 +645,9 @@ public void compress(byte[] dstBuf,
Parameters:
dstBuf - buffer that will receive the JPEG image. Use TJ.bufSize(int, int, int) to determine the maximum size for this buffer based on - the image width, height, and level of chrominance subsampling.
flags - the bitwise OR of one or more of TJ.FLAG_* + the source image's width and height and the desired level of chrominance + subsampling.
flags - the bitwise OR of one or more of + TJ.FLAG_*
Throws:
java.lang.Exception
@@ -658,7 +664,8 @@ public byte[] compress(int flags) instance and return a buffer containing a JPEG image.

-
Parameters:
flags - the bitwise OR of one or more of TJ.FLAG_* +
Parameters:
flags - the bitwise OR of one or more of + TJ.FLAG_*
Returns:
a buffer containing a JPEG image. The length of this buffer will not be equal to the size of the JPEG image. Use getCompressedSize() to obtain the size of the JPEG image.
Throws: @@ -708,19 +715,24 @@ compress

-

-setYUVPad

+

+encodeYUV

-public void setYUVPad(int pad)
+public void encodeYUV(YUVImage dstImage,
+                      int flags)
                throws java.lang.Exception
-
Set the plane padding for subsequent YUV encode operations. +
Encode the uncompressed source image associated with this compressor + instance into a YUV planar image and store it in the given + YUVImage instance. This method uses the accelerated color + conversion routines in TurboJPEG's underlying codec but does not execute + any of the other steps in the JPEG compression process. Encoding + CMYK source images to YUV is not supported.

-
Parameters:
pad - the width of each line in each plane of the YUV image will be - padded to the nearest multiple of this number of bytes (must be a - power of 2.) The default padding is 4 bytes, which generates - images suitable for direct video display. +
Parameters:
dstImage - YUVImage instance that will receive the YUV planar + image
flags - the bitwise OR of one or more of + TJ.FLAG_*
Throws:
java.lang.Exception
@@ -730,31 +742,41 @@ public void setYUVPad(int pad)

encodeYUV

-public void encodeYUV(byte[] dstBuf,
-                      int flags)
+@Deprecated
+public void encodeYUV(byte[] dstBuf,
+                                 int flags)
                throws java.lang.Exception
-
Encode the uncompressed source image associated with this compressor - instance and output a YUV planar image to the given destination buffer. - This method uses the accelerated color conversion routines in TurboJPEG's - underlying codec but does not execute any of the other steps in the JPEG - compression process. The Y, U (Cb), and V (Cr) image planes are stored - sequentially into the destination buffer, and the size of each plane is - determined by the width and height of the source image, as well as the - specified padding and level of chrominance subsampling. If the - chrominance components are subsampled along the horizontal dimension, then - the width of the luminance plane is padded to the nearest multiple of 2 in - the output image (same goes for the height of the luminance plane, if the - chrominance components are subsampled along the vertical dimension.) -

- NOTE: Technically, the JPEG format uses the YCbCr colorspace, but per the - convention of the digital video community, the TurboJPEG API uses "YUV" to - refer to an image format consisting of Y, Cb, and Cr image planes. +

Deprecated. Use encodeYUV(YUVImage, int) instead.

-
Parameters:
dstBuf - buffer that will receive the YUV planar image. Use - TJ.bufSizeYUV(int, int, int, int) to determine the appropriate size for this buffer - based on the image width, height, and level of chrominance subsampling.
flags - the bitwise OR of one or more of TJ.FLAG_* + +
Throws: +
java.lang.Exception
+
+
+
+ +

+encodeYUV

+
+public YUVImage encodeYUV(int pad,
+                          int flags)
+                   throws java.lang.Exception
+
+
Encode the uncompressed source image associated with this compressor + instance into a YUV planar image and return a YUVImage + instance containing the encoded image. This method uses the accelerated + color conversion routines in TurboJPEG's underlying codec but does not + execute any of the other steps in the JPEG compression process. Encoding + CMYK source images to YUV is not supported. +

+

+
Parameters:
pad - the width of each line in each plane of the YUV image will be + padded to the nearest multiple of this number of bytes (must be a power of + 2.)
flags - the bitwise OR of one or more of + TJ.FLAG_* +
Returns:
a YUV planar image
Throws:
java.lang.Exception
@@ -764,16 +786,14 @@ public void encodeYUV(byte[] dstBuf,

encodeYUV

-public byte[] encodeYUV(int flags)
+@Deprecated
+public byte[] encodeYUV(int flags)
                  throws java.lang.Exception
-
Encode the uncompressed source image associated with this compressor - instance and return a buffer containing a YUV planar image. See - encodeYUV(byte[], int) for more detail. +
Deprecated. Use encodeYUV(int, int) instead.

-
Parameters:
flags - the bitwise OR of one or more of TJ.FLAG_* -
Returns:
a buffer containing a YUV planar image +
Throws:
java.lang.Exception
diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html b/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html index 2dc3cc62..01007b36 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html +++ b/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html @@ -142,7 +142,7 @@ TurboJPEG decompressor
- @@ -150,7 +150,7 @@ TurboJPEG decompressor - @@ -158,7 +158,7 @@ TurboJPEG decompressor - @@ -166,7 +166,15 @@ TurboJPEG decompressor - + + + + @@ -191,17 +199,25 @@ TurboJPEG decompressor +          Create a TurboJPEG decompressor instance and associate the JPEG source + image stored in jpegImage with the newly created instance. +          Create a TurboJPEG decompressor instance and associate the JPEG source + image of length imageSize bytes stored in + jpegImage with the newly created instance. + + +
protected  intjpegColorspace +srcColorspace
           
protected  intjpegHeight +srcHeight
           
protected  intjpegSubsamp +srcSubsamp
           
protected  intjpegWidth +srcWidth + +
+           
+protected  YUVImageyuvImage
           
TJDecompressor(byte[] jpegImage)
-          Create a TurboJPEG decompressor instance and associate the JPEG image - stored in jpegImage with the newly-created instance.
TJDecompressor(byte[] jpegImage, int imageSize)
-          Create a TurboJPEG decompressor instance and associate the JPEG image - of length imageSize bytes stored in jpegImage - with the newly-created instance.
TJDecompressor(YUVImage yuvImage) + +
+          Create a TurboJPEG decompressor instance and associate the YUV planar + source image stored in yuvImage with the newly created + instance.
  @@ -228,9 +244,9 @@ TurboJPEG decompressor int flags)
-          Decompress the JPEG source image associated with this decompressor - instance and output a decompressed image to the given - BufferedImage instance. +          Decompress the JPEG source image or decode the YUV source image associated + with this decompressor instance and output a decompressed/decoded image to + the given BufferedImage instance. @@ -259,8 +275,9 @@ TurboJPEG decompressor int flags)
-          Decompress the JPEG source image associated with this decompressor - instance and output a decompressed image to the given destination buffer. +          Decompress the JPEG source image or decode the YUV source image associated + with this decompressor instance and output a grayscale, RGB, or CMYK image + to the given destination buffer. @@ -275,8 +292,9 @@ TurboJPEG decompressor int flags)
-          Decompress the JPEG source image associated with this decompressor - instance and output a decompressed image to the given destination buffer. +          Decompress the JPEG source image or decode the YUV source image associated + with this decompressor instance and output a grayscale, RGB, or CMYK image + to the given destination buffer. @@ -287,9 +305,9 @@ TurboJPEG decompressor int flags)
-          Decompress the JPEG source image associated with this decompressor - instance and return a BufferedImage instance containing the - decompressed image. +          Decompress the JPEG source image or decode the YUV source image associated + with this decompressor instance and return a BufferedImage + instance containing the decompressed/decoded image. @@ -311,21 +329,7 @@ TurboJPEG decompressor int flags)
-          Deprecated. Use decompressToYUV(byte[], int, int, int, int) - instead. - - - - void -decompressToYUV(byte[] dstBuf, - int desiredWidth, - int pad, - int desiredHeight, - int flags) - -
-          Decompress the JPEG source image associated with this decompressor - instance and output a YUV planar image to the given destination buffer. +          Deprecated. Use decompressToYUV(YUVImage, int) instead. @@ -337,7 +341,7 @@ TurboJPEG decompressor - byte[] + YUVImage decompressToYUV(int desiredWidth, int pad, int desiredHeight, @@ -345,7 +349,19 @@ TurboJPEG decompressor
          Decompress the JPEG source image associated with this decompressor - instance and return a buffer containing a YUV planar image. + instance into a YUV planar image and return a YUVImage + instance containing the decompressed image. + + + + void +decompressToYUV(YUVImage dstImage, + int flags) + +
+          Decompress the JPEG source image associated with this decompressor + instance into a YUV planar image and store it in the given + YUVImage instance. @@ -361,8 +377,8 @@ TurboJPEG decompressor getColorspace()
-          Returns the colorspace used in the JPEG image associated with this - decompressor instance. +          Returns the colorspace used in the source image (JPEG or YUV) associated + with this decompressor instance. @@ -370,8 +386,8 @@ TurboJPEG decompressor getHeight()
-          Returns the height of the JPEG image associated with this decompressor - instance. +          Returns the height of the source image (JPEG or YUV) associated with this + decompressor instance. @@ -379,7 +395,7 @@ TurboJPEG decompressor getJPEGBuf()
-          Returns the JPEG image buffer associated with this decompressor instance. +          Deprecated. Use getSourceBuf() instead. @@ -387,8 +403,7 @@ TurboJPEG decompressor getJPEGSize()
-          Returns the size of the JPEG image (in bytes) associated with this - decompressor instance. +          Deprecated. Use getSourceSize() instead. @@ -414,12 +429,30 @@ TurboJPEG decompressor + byte[] +getSourceBuf() + +
+          Returns the source image buffer associated with this decompressor + instance. + + + + int +getSourceSize() + +
+          Returns the size of the source image (in bytes) associated with this + decompressor instance. + + +  int getSubsamp()
-          Returns the level of chrominance subsampling used in the JPEG image - associated with this decompressor instance. +          Returns the level of chrominance subsampling used in the source image + (JPEG or YUV) associated with this decompressor instance. @@ -427,8 +460,8 @@ TurboJPEG decompressor getWidth()
-          Returns the width of the JPEG image associated with this decompressor - instance. +          Returns the width of the source image (JPEG or YUV) associated with this + decompressor instance. @@ -436,9 +469,27 @@ TurboJPEG decompressor setJPEGImage(byte[] jpegImage, int imageSize) +
+          Deprecated. Use setSourceImage(byte[], int) instead. + + + + void +setSourceImage(byte[] srcImage, + int imageSize) +
          Associate the JPEG image of length imageSize bytes stored in - jpegImage with this decompressor instance. + srcImage with this decompressor instance. + + + + void +setSourceImage(YUVImage srcImage) + +
+          Associate the specified YUV planar source image with this decompressor + instance.   @@ -493,40 +544,50 @@ protected int jpegBufSize
-

-jpegWidth

+

+yuvImage

-protected int jpegWidth
+protected YUVImage yuvImage

-

-jpegHeight

+

+srcWidth

-protected int jpegHeight
+protected int srcWidth

-

-jpegSubsamp

+

+srcHeight

-protected int jpegSubsamp
+protected int srcHeight

-

-jpegColorspace

+

+srcSubsamp

-protected int jpegColorspace
+protected int srcSubsamp +
+
+
+
+
+ +

+srcColorspace

+
+protected int srcColorspace
@@ -563,8 +624,8 @@ TJDecompressor

public TJDecompressor(byte[] jpegImage) throws java.lang.Exception
-
Create a TurboJPEG decompressor instance and associate the JPEG image - stored in jpegImage with the newly-created instance. +
Create a TurboJPEG decompressor instance and associate the JPEG source + image stored in jpegImage with the newly created instance.

Parameters:
jpegImage - JPEG image buffer (size of the JPEG image is assumed to @@ -581,15 +642,33 @@ public TJDecompressor(byte[] jpegImage, int imageSize) throws java.lang.Exception
-
Create a TurboJPEG decompressor instance and associate the JPEG image - of length imageSize bytes stored in jpegImage - with the newly-created instance. +
Create a TurboJPEG decompressor instance and associate the JPEG source + image of length imageSize bytes stored in + jpegImage with the newly created instance.

Parameters:
jpegImage - JPEG image buffer
imageSize - size of the JPEG image (in bytes)
Throws:
java.lang.Exception
+
+ +

+TJDecompressor

+
+public TJDecompressor(YUVImage yuvImage)
+               throws java.lang.Exception
+
+
Create a TurboJPEG decompressor instance and associate the YUV planar + source image stored in yuvImage with the newly created + instance. +

+

+
Parameters:
yuvImage - YUVImage instance containing a YUV planar + image to be decoded +
Throws: +
java.lang.Exception
+
@@ -601,19 +680,56 @@ public TJDecompressor(byte[] jpegImage, -

-setJPEGImage

+

+setSourceImage

-public void setJPEGImage(byte[] jpegImage,
-                         int imageSize)
-                  throws java.lang.Exception
+public void setSourceImage(byte[] srcImage, + int imageSize) + throws java.lang.Exception
Associate the JPEG image of length imageSize bytes stored in - jpegImage with this decompressor instance. This image will + srcImage with this decompressor instance. This image will be used as the source image for subsequent decompress operations.

-
Parameters:
jpegImage - JPEG image buffer
imageSize - size of the JPEG image (in bytes) +
Parameters:
srcImage - JPEG image buffer
imageSize - size of the JPEG image (in bytes) +
Throws: +
java.lang.Exception
+
+
+
+ +

+setJPEGImage

+
+@Deprecated
+public void setJPEGImage(byte[] jpegImage,
+                                    int imageSize)
+                  throws java.lang.Exception
+
+
Deprecated. Use setSourceImage(byte[], int) instead. +

+

+ +
Throws: +
java.lang.Exception
+
+
+
+ +

+setSourceImage

+
+public void setSourceImage(YUVImage srcImage)
+                    throws java.lang.Exception
+
+
Associate the specified YUV planar source image with this decompressor + instance. Subsequent decompress operations will decode this image into an + RGB or grayscale destination image. +

+

+
Parameters:
srcImage - YUVImage instance containing a YUV planar image to + be decoded
Throws:
java.lang.Exception
@@ -626,13 +742,13 @@ getWidth

public int getWidth() throws java.lang.Exception
-
Returns the width of the JPEG image associated with this decompressor - instance. +
Returns the width of the source image (JPEG or YUV) associated with this + decompressor instance.

-
Returns:
the width of the JPEG image associated with this decompressor - instance +
Returns:
the width of the source image (JPEG or YUV) associated with this + decompressor instance
Throws:
java.lang.Exception
@@ -645,13 +761,13 @@ getHeight public int getHeight() throws java.lang.Exception
-
Returns the height of the JPEG image associated with this decompressor - instance. +
Returns the height of the source image (JPEG or YUV) associated with this + decompressor instance.

-
Returns:
the height of the JPEG image associated with this decompressor - instance +
Returns:
the height of the source image (JPEG or YUV) associated with this + decompressor instance
Throws:
java.lang.Exception
@@ -664,13 +780,14 @@ getSubsamp public int getSubsamp() throws java.lang.Exception
-
Returns the level of chrominance subsampling used in the JPEG image - associated with this decompressor instance. See TJ.SAMP_*. +
Returns the level of chrominance subsampling used in the source image + (JPEG or YUV) associated with this decompressor instance. See + TJ.SAMP_*.

-
Returns:
the level of chrominance subsampling used in the JPEG image - associated with this decompressor instance +
Returns:
the level of chrominance subsampling used in the source image + (JPEG or YUV) associated with this decompressor instance
Throws:
java.lang.Exception
@@ -683,13 +800,32 @@ getColorspace public int getColorspace() throws java.lang.Exception
-
Returns the colorspace used in the JPEG image associated with this - decompressor instance. See TJ.CS_*. +
Returns the colorspace used in the source image (JPEG or YUV) associated + with this decompressor instance. See TJ.CS_*. If the + source image is YUV, then this always returns TJ.CS_YCbCr.

-
Returns:
the colorspace used in the JPEG image associated with this - decompressor instance +
Returns:
the colorspace used in the source image (JPEG or YUV) associated + with this decompressor instance +
Throws: +
java.lang.Exception
+
+
+
+ +

+getSourceBuf

+
+public byte[] getSourceBuf()
+                    throws java.lang.Exception
+
+
Returns the source image buffer associated with this decompressor + instance. +

+

+ +
Returns:
the source image buffer associated with this decompressor instance
Throws:
java.lang.Exception
@@ -699,14 +835,33 @@ public int getColorspace()

getJPEGBuf

-public byte[] getJPEGBuf()
+@Deprecated
+public byte[] getJPEGBuf()
                   throws java.lang.Exception
-
Returns the JPEG image buffer associated with this decompressor instance. +
Deprecated. Use getSourceBuf() instead.

-
Returns:
the JPEG image buffer associated with this decompressor instance +
Throws: +
java.lang.Exception
+
+
+
+ +

+getSourceSize

+
+public int getSourceSize()
+                  throws java.lang.Exception
+
+
Returns the size of the source image (in bytes) associated with this + decompressor instance. +

+

+ +
Returns:
the size of the source image (in bytes) associated with this + decompressor instance
Throws:
java.lang.Exception
@@ -716,16 +871,14 @@ public byte[] getJPEGBuf()

getJPEGSize

-public int getJPEGSize()
+@Deprecated
+public int getJPEGSize()
                 throws java.lang.Exception
-
Returns the size of the JPEG image (in bytes) associated with this - decompressor instance. +
Deprecated. Use getSourceSize() instead.

-
Returns:
the size of the JPEG image (in bytes) associated with this - decompressor instance
Throws:
java.lang.Exception
@@ -801,43 +954,54 @@ public void decompress(byte[] dstBuf, int flags) throws java.lang.Exception
-
Decompress the JPEG source image associated with this decompressor - instance and output a decompressed image to the given destination buffer. +
Decompress the JPEG source image or decode the YUV source image associated + with this decompressor instance and output a grayscale, RGB, or CMYK image + to the given destination buffer.

-
Parameters:
dstBuf - buffer that will receive the decompressed image. This - buffer should normally be pitch * scaledHeight bytes in size, - where scaledHeight can be determined by calling +
Parameters:
dstBuf - buffer that will receive the decompressed/decoded image. + If the source image is a JPEG image, then this buffer should normally be + pitch * scaledHeight bytes in size, where + scaledHeight can be determined by calling scalingFactor.getScaled(jpegHeight) - with one of the scaling factors returned from TJ.getScalingFactors() or by calling getScaledHeight(int, int). However, - the buffer may also be larger than the dimensions of the JPEG image, in - which case the x, y, and pitch - parameters can be used to specify the region into which the JPEG image - should be decompressed.
x - x offset (in pixels) of the region into which the JPEG image - should be decompressed, relative to the start of dstBuf.
y - y offset (in pixels) of the region into which the JPEG image - should be decompressed, relative to the start of dstBuf.
desiredWidth - desired width (in pixels) of the decompressed image - (or image region.) If the desired image dimensions are different than the - dimensions of the JPEG image being decompressed, then TurboJPEG will use - scaling in the JPEG decompressor to generate the largest possible image - that will fit within the desired dimensions. Setting this to 0 is the - same as setting it to the width of the JPEG image (in other words, the - width will not be considered when determining the scaled image size.)
pitch - bytes per line of the destination image. Normally, this + with one of the scaling factors returned from TJ.getScalingFactors() or by calling getScaledHeight(int, int). If the + source image is a YUV image, then this buffer should normally be + pitch * height bytes in size, where height is + the height of the YUV image. However, the buffer may also be larger than + the dimensions of the source image, in which case the x, + y, and pitch parameters can be used to specify + the region into which the source image should be decompressed/decoded.
x - x offset (in pixels) of the region in the destination image into + which the source image should be decompressed/decoded
y - y offset (in pixels) of the region in the destination image into + which the source image should be decompressed/decoded
desiredWidth - If the source image is a JPEG image, then this + specifies the desired width (in pixels) of the decompressed image (or + image region.) If the desired destination image dimensions are different + than the source image dimensions, then TurboJPEG will use scaling in the + JPEG decompressor to generate the largest possible image that will fit + within the desired dimensions. Setting this to 0 is the same as setting + it to the width of the JPEG image (in other words, the width will not be + considered when determining the scaled image size.) This parameter is + ignored if the source image is a YUV image.
pitch - bytes per line of the destination image. Normally, this should be set to scaledWidth * TJ.pixelSize(pixelFormat) if - the decompressed image is unpadded, but you can use this to, for instance, - pad each line of the decompressed image to a 4-byte boundary or to - decompress the JPEG image into a region of a larger image. NOTE: - scaledWidth can be determined by calling + the destination image is unpadded, but you can use this to, for instance, + pad each line of the destination image to a 4-byte boundary or to + decompress/decode the source image into a region of a larger image. NOTE: + if the source image is a JPEG image, then scaledWidth can be + determined by calling scalingFactor.getScaled(jpegWidth) - or by calling getScaledWidth(int, int). Setting this parameter to - 0 is the equivalent of setting it to scaledWidth * - TJ.pixelSize(pixelFormat).
desiredHeight - desired height (in pixels) of the decompressed image - (or image region.) If the desired image dimensions are different than the - dimensions of the JPEG image being decompressed, then TurboJPEG will use - scaling in the JPEG decompressor to generate the largest possible image - that will fit within the desired dimensions. Setting this to 0 is the - same as setting it to the height of the JPEG image (in other words, the - height will not be considered when determining the scaled image size.)
pixelFormat - pixel format of the decompressed image (one of - TJ.PF_*)
flags - the bitwise OR of one or more of TJ.FLAG_* + or by calling getScaledWidth(int, int). If the source image is a + YUV image, then scaledWidth is the width of the YUV image. + Setting this parameter to 0 is the equivalent of setting it to + scaledWidth * TJ.pixelSize(pixelFormat).
desiredHeight - If the source image is a JPEG image, then this + specifies the desired height (in pixels) of the decompressed image (or + image region.) If the desired destination image dimensions are different + than the source image dimensions, then TurboJPEG will use scaling in the + JPEG decompressor to generate the largest possible image that will fit + within the desired dimensions. Setting this to 0 is the same as setting + it to the height of the JPEG image (in other words, the height will not be + considered when determining the scaled image size.) This parameter is + ignored if the source image is a YUV image.
pixelFormat - pixel format of the decompressed/decoded image (one of + TJ.PF_*)
flags - the bitwise OR of one or more of + TJ.FLAG_*
Throws:
java.lang.Exception
@@ -888,7 +1052,8 @@ public byte[] decompress(int desiredWidth, for description
desiredHeight - see decompress(byte[], int, int, int, int, int, int, int) for description
pixelFormat - pixel format of the decompressed image (one of - TJ.PF_*)
flags - the bitwise OR of one or more of TJ.FLAG_* + TJ.PF_*)
flags - the bitwise OR of one or more of + TJ.FLAG_*
Returns:
a buffer containing the decompressed image
Throws:
java.lang.Exception
@@ -896,48 +1061,28 @@ public byte[] decompress(int desiredWidth,

-

+

decompressToYUV

-public void decompressToYUV(byte[] dstBuf,
-                            int desiredWidth,
-                            int pad,
-                            int desiredHeight,
+public void decompressToYUV(YUVImage dstImage,
                             int flags)
                      throws java.lang.Exception
Decompress the JPEG source image associated with this decompressor - instance and output a YUV planar image to the given destination buffer. - This method performs JPEG decompression but leaves out the color - conversion step, so a planar YUV image is generated instead of an RGB - image. The padding of the planes in this image is the same as in the - images generated by TJCompressor.encodeYUV(byte[], int). Note - that, if the width or height of the image is not an even multiple of the - MCU block size (see TJ.getMCUWidth(int) and TJ.getMCUHeight(int)), - then an intermediate buffer copy will be performed within TurboJPEG. -

- NOTE: Technically, the JPEG format uses the YCbCr colorspace, but per the - convention of the digital video community, the TurboJPEG API uses "YUV" to - refer to an image format consisting of Y, Cb, and Cr image planes. + instance into a YUV planar image and store it in the given + YUVImage instance. This method performs JPEG decompression + but leaves out the color conversion step, so a planar YUV image is + generated instead of an RGB or grayscale image. This method cannot be + used to decompress JPEG source images with the CMYK or YCCK colorspace.

-
Parameters:
dstBuf - buffer that will receive the YUV planar image. Use - TJ.bufSizeYUV(int, int, int, int) to determine the appropriate size for this buffer - based on the image width, height, and level of chrominance subsampling.
desiredWidth - desired width (in pixels) of the YUV image. If the - desired image dimensions are different than the dimensions of the JPEG - image being decompressed, then TurboJPEG will use scaling in the JPEG - decompressor to generate the largest possible image that will fit within - the desired dimensions. Setting this to 0 is the same as setting it to - the width of the JPEG image (in other words, the width will not be - considered when determining the scaled image size.)
pad - the width of each line in each plane of the YUV image will be - padded to the nearest multiple of this number of bytes (must be a power of - 2.)
desiredHeight - desired height (in pixels) of the YUV image. If the - desired image dimensions are different than the dimensions of the JPEG - image being decompressed, then TurboJPEG will use scaling in the JPEG - decompressor to generate the largest possible image that will fit within - the desired dimensions. Setting this to 0 is the same as setting it to - the height of the JPEG image (in other words, the height will not be - considered when determining the scaled image size.)
flags - the bitwise OR of one or more of TJ.FLAG_* +
Parameters:
dstImage - YUVImage instance that will receive the YUV planar + image. The level of subsampling specified in this YUVImage + instance must match that of the JPEG image, and the width and height + specified in the YUVImage instance must match one of the + scaled image sizes that TurboJPEG is capable of generating from the JPEG + source image.
flags - the bitwise OR of one or more of + TJ.FLAG_*
Throws:
java.lang.Exception
@@ -952,8 +1097,7 @@ decompressToYUV int flags) throws java.lang.Exception
-
Deprecated. Use decompressToYUV(byte[], int, int, int, int) - instead. +
Deprecated. Use decompressToYUV(YUVImage, int) instead.

@@ -966,20 +1110,38 @@ decompressToYUV

decompressToYUV

-public byte[] decompressToYUV(int desiredWidth,
-                              int pad,
-                              int desiredHeight,
-                              int flags)
-                       throws java.lang.Exception
+public YUVImage decompressToYUV(int desiredWidth, + int pad, + int desiredHeight, + int flags) + throws java.lang.Exception
Decompress the JPEG source image associated with this decompressor - instance and return a buffer containing a YUV planar image. See decompressToYUV(byte[], int, int, int, int) for more detail. + instance into a YUV planar image and return a YUVImage + instance containing the decompressed image. This method performs JPEG + decompression but leaves out the color conversion step, so a planar YUV + image is generated instead of an RGB or grayscale image. This method + cannot be used to decompress JPEG source images with the CMYK or YCCK + colorspace.

-
Parameters:
desiredWidth - see - decompressToYUV(byte[], int, int, int, int) for description
pad - see decompressToYUV(byte[], int, int, int, int) for - description
desiredHeight - see decompressToYUV(byte[], int, int, int, int) for description
flags - the bitwise OR of one or more of TJ.FLAG_* -
Returns:
a buffer containing a YUV planar image +
Parameters:
desiredWidth - desired width (in pixels) of the YUV image. If the + desired image dimensions are different than the dimensions of the JPEG + image being decompressed, then TurboJPEG will use scaling in the JPEG + decompressor to generate the largest possible image that will fit within + the desired dimensions. Setting this to 0 is the same as setting it to + the width of the JPEG image (in other words, the width will not be + considered when determining the scaled image size.)
pad - the width of each line in each plane of the YUV image will be + padded to the nearest multiple of this number of bytes (must be a power of + 2.)
desiredHeight - desired height (in pixels) of the YUV image. If the + desired image dimensions are different than the dimensions of the JPEG + image being decompressed, then TurboJPEG will use scaling in the JPEG + decompressor to generate the largest possible image that will fit within + the desired dimensions. Setting this to 0 is the same as setting it to + the height of the JPEG image (in other words, the height will not be + considered when determining the scaled image size.)
flags - the bitwise OR of one or more of + TJ.FLAG_* +
Returns:
a YUV planar image
Throws:
java.lang.Exception
@@ -1016,40 +1178,52 @@ public void decompress(int[] dstBuf, int flags) throws java.lang.Exception
-
Decompress the JPEG source image associated with this decompressor - instance and output a decompressed image to the given destination buffer. +
Decompress the JPEG source image or decode the YUV source image associated + with this decompressor instance and output a grayscale, RGB, or CMYK image + to the given destination buffer.

-
Parameters:
dstBuf - buffer that will receive the decompressed image. This - buffer should normally be stride * scaledHeight pixels in - size, where scaledHeight can be determined by calling +
Parameters:
dstBuf - buffer that will receive the decompressed/decoded image. + If the source image is a JPEG image, then this buffer should normally be + stride * scaledHeight pixels in size, where + scaledHeight can be determined by calling scalingFactor.getScaled(jpegHeight) - with one of the scaling factors returned from TJ.getScalingFactors() or by calling getScaledHeight(int, int). However, - the buffer may also be larger than the dimensions of the JPEG image, in - which case the x, y, and stride - parameters can be used to specify the region into which the JPEG image - should be decompressed.
x - x offset (in pixels) of the region into which the JPEG image - should be decompressed, relative to the start of dstBuf.
y - y offset (in pixels) of the region into which the JPEG image - should be decompressed, relative to the start of dstBuf.
desiredWidth - desired width (in pixels) of the decompressed image - (or image region.) If the desired image dimensions are different than the - dimensions of the JPEG image being decompressed, then TurboJPEG will use - scaling in the JPEG decompressor to generate the largest possible image - that will fit within the desired dimensions. Setting this to 0 is the - same as setting it to the width of the JPEG image (in other words, the - width will not be considered when determining the scaled image size.)
stride - pixels per line of the destination image. Normally, this + with one of the scaling factors returned from TJ.getScalingFactors() or by calling getScaledHeight(int, int). If the + source image is a YUV image, then this buffer should normally be + stride * height pixels in size, where height is + the height of the YUV image. However, the buffer may also be larger than + the dimensions of the JPEG image, in which case the x, + y, and stride parameters can be used to specify + the region into which the source image should be decompressed.
x - x offset (in pixels) of the region in the destination image into + which the source image should be decompressed/decoded
y - y offset (in pixels) of the region in the destination image into + which the source image should be decompressed/decoded
desiredWidth - If the source image is a JPEG image, then this + specifies the desired width (in pixels) of the decompressed image (or + image region.) If the desired destination image dimensions are different + than the source image dimensions, then TurboJPEG will use scaling in the + JPEG decompressor to generate the largest possible image that will fit + within the desired dimensions. Setting this to 0 is the same as setting + it to the width of the JPEG image (in other words, the width will not be + considered when determining the scaled image size.) This parameter is + ignored if the source image is a YUV image.
stride - pixels per line of the destination image. Normally, this should be set to scaledWidth, but you can use this to, for instance, decompress the JPEG image into a region of a larger image. - NOTE: scaledWidth can be determined by calling + NOTE: if the source image is a JPEG image, then scaledWidth + can be determined by calling scalingFactor.getScaled(jpegWidth) - or by calling getScaledWidth(int, int). Setting this parameter to - 0 is the equivalent of setting it to scaledWidth.
desiredHeight - desired height (in pixels) of the decompressed image - (or image region.) If the desired image dimensions are different than the - dimensions of the JPEG image being decompressed, then TurboJPEG will use - scaling in the JPEG decompressor to generate the largest possible image - that will fit within the desired dimensions. Setting this to 0 is the - same as setting it to the height of the JPEG image (in other words, the - height will not be considered when determining the scaled image size.)
pixelFormat - pixel format of the decompressed image (one of - TJ.PF_*)
flags - the bitwise OR of one or more of TJ.FLAG_* + or by calling getScaledWidth(int, int). If the source image is a + YUV image, then scaledWidth is the width of the YUV image. + Setting this parameter to 0 is the equivalent of setting it to + scaledWidth.
desiredHeight - If the source image is a JPEG image, then this + specifies the desired height (in pixels) of the decompressed image (or + image region.) If the desired destination image dimensions are different + than the source image dimensions, then TurboJPEG will use scaling in the + JPEG decompressor to generate the largest possible image that will fit + within the desired dimensions. Setting this to 0 is the same as setting + it to the height of the JPEG image (in other words, the height will not be + considered when determining the scaled image size.) This parameter is + ignored if the source image is a YUV image.
pixelFormat - pixel format of the decompressed image (one of + TJ.PF_*)
flags - the bitwise OR of one or more of + TJ.FLAG_*
Throws:
java.lang.Exception
@@ -1063,13 +1237,19 @@ public void decompress(java.awt.image.BufferedImage dstImage, int flags) throws java.lang.Exception
-
Decompress the JPEG source image associated with this decompressor - instance and output a decompressed image to the given - BufferedImage instance. +
Decompress the JPEG source image or decode the YUV source image associated + with this decompressor instance and output a decompressed/decoded image to + the given BufferedImage instance.

Parameters:
dstImage - a BufferedImage instance that will receive - the decompressed image
flags - the bitwise OR of one or more of TJ.FLAG_* + the decompressed/decoded image. If the source image is a JPEG image, then + the width and height of the BufferedImage instance must match + one of the scaled image sizes that TurboJPEG is capable of generating from + the JPEG image. If the source image is a YUV image, then the width and + height of the BufferedImage instance must match the width and + height of the YUV image.
flags - the bitwise OR of one or more of + TJ.FLAG_*
Throws:
java.lang.Exception
@@ -1085,20 +1265,21 @@ public java.awt.image.BufferedImage decompress(int desiredWidth, int flags) throws java.lang.Exception
-
Decompress the JPEG source image associated with this decompressor - instance and return a BufferedImage instance containing the - decompressed image. +
Decompress the JPEG source image or decode the YUV source image associated + with this decompressor instance and return a BufferedImage + instance containing the decompressed/decoded image.

Parameters:
desiredWidth - see decompress(byte[], int, int, int, int, int, int, int) for description
desiredHeight - see decompress(byte[], int, int, int, int, int, int, int) for - description
bufferedImageType - the image type of the newly-created - BufferedImage instance (for instance, - BufferedImage.TYPE_INT_RGB)
flags - the bitwise OR of one or more of TJ.FLAG_* + description
bufferedImageType - the image type of the BufferedImage + instance that will be created (for instance, + BufferedImage.TYPE_INT_RGB)
flags - the bitwise OR of one or more of + TJ.FLAG_*
Returns:
a BufferedImage instance containing the - decompressed image + decompressed/decoded image
Throws:
java.lang.Exception
diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJTransformer.html b/java/doc/org/libjpegturbo/turbojpeg/TJTransformer.html index 0811b51f..75fedf75 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/TJTransformer.html +++ b/java/doc/org/libjpegturbo/turbojpeg/TJTransformer.html @@ -52,7 +52,7 @@ function windowTitle()  PREV CLASS  - NEXT CLASSNEXT CLASS FRAMES    NO FRAMES   @@ -120,7 +120,7 @@ TurboJPEG lossless transformer Fields inherited from class org.libjpegturbo.turbojpeg.TJDecompressor -handle, jpegBuf, jpegBufSize, jpegColorspace, jpegHeight, jpegSubsamp, jpegWidth +handle, jpegBuf, jpegBufSize, srcColorspace, srcHeight, srcSubsamp, srcWidth, yuvImage   @@ -143,7 +143,7 @@ TurboJPEG lossless transformer
          Create a TurboJPEG lossless transformer instance and associate the JPEG - image stored in jpegImage with the newly-created instance. + image stored in jpegImage with the newly created instance. TJTransformer(byte[] jpegImage, @@ -152,7 +152,7 @@ TurboJPEG lossless transformer
          Create a TurboJPEG lossless transformer instance and associate the JPEG image of length imageSize bytes stored in - jpegImage with the newly-created instance. + jpegImage with the newly created instance.   @@ -170,8 +170,8 @@ TurboJPEG lossless transformer getTransformedSizes()
-          Returns an array containing the sizes of the transformed JPEG images from - the most recent call to transform(). +          Returns an array containing the sizes of the transformed JPEG images + generated by the most recent transform operation. @@ -203,7 +203,7 @@ TurboJPEG lossless transformer Methods inherited from class org.libjpegturbo.turbojpeg.TJDecompressor -close, decompress, decompress, decompress, decompress, decompress, decompress, decompressToYUV, decompressToYUV, decompressToYUV, decompressToYUV, finalize, getColorspace, getHeight, getJPEGBuf, getJPEGSize, getScaledHeight, getScaledWidth, getSubsamp, getWidth, setJPEGImage +close, decompress, decompress, decompress, decompress, decompress, decompress, decompressToYUV, decompressToYUV, decompressToYUV, decompressToYUV, finalize, getColorspace, getHeight, getJPEGBuf, getJPEGSize, getScaledHeight, getScaledWidth, getSourceBuf, getSourceSize, getSubsamp, getWidth, setJPEGImage, setSourceImage, setSourceImage   @@ -250,7 +250,7 @@ public TJTransformer(byte[] jpegImage) throws java.lang.Exception
Create a TurboJPEG lossless transformer instance and associate the JPEG - image stored in jpegImage with the newly-created instance. + image stored in jpegImage with the newly created instance.

Parameters:
jpegImage - JPEG image buffer (size of the JPEG image is assumed to @@ -269,7 +269,7 @@ public TJTransformer(byte[] jpegImage,
Create a TurboJPEG lossless transformer instance and associate the JPEG image of length imageSize bytes stored in - jpegImage with the newly-created instance. + jpegImage with the newly created instance.

Parameters:
jpegImage - JPEG image buffer
imageSize - size of the JPEG image (in bytes) @@ -313,9 +313,10 @@ public void transform(byte[][] dstBufs, receive a JPEG image that has been transformed using the parameters in transforms[i]. Use TJ.bufSize(int, int, int) to determine the maximum size for each buffer based on the transformed or cropped width and - height.
transforms - an array of TJTransform instances, each of + height and the level of subsampling used in the source image.
transforms - an array of TJTransform instances, each of which specifies the transform parameters and/or cropping region for the - corresponding transformed output image
flags - the bitwise OR of one or more of TJ.FLAG_* + corresponding transformed output image
flags - the bitwise OR of one or more of + TJ.FLAG_*
Throws:
java.lang.Exception
@@ -336,7 +337,8 @@ public TJTransform instances, each of which specifies the transform parameters and/or cropping region for the - corresponding transformed output image
flags - the bitwise OR of one or more of TJ.FLAG_* + corresponding transformed output image
flags - the bitwise OR of one or more of + TJ.FLAG_*
Returns:
an array of TJDecompressor instances, each of which has a transformed JPEG image associated with it
Throws: @@ -351,13 +353,13 @@ getTransformedSizes public int[] getTransformedSizes() throws java.lang.Exception
-
Returns an array containing the sizes of the transformed JPEG images from - the most recent call to transform(). +
Returns an array containing the sizes of the transformed JPEG images + generated by the most recent transform operation.

-
Returns:
an array containing the sizes of the transformed JPEG images from - the most recent call to transform() +
Returns:
an array containing the sizes of the transformed JPEG images + generated by the most recent transform operation
Throws:
java.lang.Exception
@@ -392,7 +394,7 @@ public int[] getTransformedSizes()  PREV CLASS  - NEXT CLASSNEXT CLASS
FRAMES    NO FRAMES   diff --git a/java/doc/org/libjpegturbo/turbojpeg/package-frame.html b/java/doc/org/libjpegturbo/turbojpeg/package-frame.html index f160418d..215bdeac 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/package-frame.html +++ b/java/doc/org/libjpegturbo/turbojpeg/package-frame.html @@ -42,7 +42,9 @@ Classes 
TJTransform
-TJTransformer
+TJTransformer +
+YUVImage diff --git a/java/doc/org/libjpegturbo/turbojpeg/package-summary.html b/java/doc/org/libjpegturbo/turbojpeg/package-summary.html index 505512c9..12c047b1 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/package-summary.html +++ b/java/doc/org/libjpegturbo/turbojpeg/package-summary.html @@ -122,6 +122,11 @@ Package org.libjpegturbo.turbojpeg TJTransformer TurboJPEG lossless transformer + +YUVImage +This class encapsulates a YUV planar image buffer and the metadata + associated with it. +   diff --git a/java/doc/org/libjpegturbo/turbojpeg/package-tree.html b/java/doc/org/libjpegturbo/turbojpeg/package-tree.html index e13143d8..59102783 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/package-tree.html +++ b/java/doc/org/libjpegturbo/turbojpeg/package-tree.html @@ -95,7 +95,7 @@ Class Hierarchy
  • org.libjpegturbo.turbojpeg.TJ
  • org.libjpegturbo.turbojpeg.TJCompressor
  • org.libjpegturbo.turbojpeg.TJDecompressor -
  • org.libjpegturbo.turbojpeg.TJScalingFactor +
  • org.libjpegturbo.turbojpeg.TJScalingFactor
  • org.libjpegturbo.turbojpeg.YUVImage

    Interface Hierarchy diff --git a/java/doc/overview-tree.html b/java/doc/overview-tree.html index 1c12b10e..563b5796 100644 --- a/java/doc/overview-tree.html +++ b/java/doc/overview-tree.html @@ -97,7 +97,7 @@ Class Hierarchy
  • org.libjpegturbo.turbojpeg.TJ
  • org.libjpegturbo.turbojpeg.TJCompressor
  • org.libjpegturbo.turbojpeg.TJDecompressor -
  • org.libjpegturbo.turbojpeg.TJScalingFactor +
  • org.libjpegturbo.turbojpeg.TJScalingFactor
  • org.libjpegturbo.turbojpeg.YUVImage

    Interface Hierarchy diff --git a/java/org/libjpegturbo/turbojpeg/TJCompressor.java b/java/org/libjpegturbo/turbojpeg/TJCompressor.java index ed8d8e10..0debf53e 100644 --- a/java/org/libjpegturbo/turbojpeg/TJCompressor.java +++ b/java/org/libjpegturbo/turbojpeg/TJCompressor.java @@ -46,19 +46,9 @@ public class TJCompressor { init(); } - /** - * @deprecated Use - * {@link #TJCompressor(byte[], int, int, int, int, int, int)} instead. - */ - @Deprecated - public TJCompressor(byte[] srcImage, int width, int pitch, int height, - int pixelFormat) throws Exception { - setSourceImage(srcImage, width, pitch, height, pixelFormat); - } - /** * Create a TurboJPEG compressor instance and associate the uncompressed - * source image stored in srcImage with the newly-created + * source image stored in srcImage with the newly created * instance. * * @param srcImage see {@link #setSourceImage} for description @@ -74,16 +64,26 @@ public class TJCompressor { * @param height see {@link #setSourceImage} for description * * @param pixelFormat pixel format of the source image (one of - * {@link TJ TJ.PF_*}) + * {@link TJ#PF_RGB TJ.PF_*}) */ public TJCompressor(byte[] srcImage, int x, int y, int width, int pitch, int height, int pixelFormat) throws Exception { setSourceImage(srcImage, x, y, width, pitch, height, pixelFormat); } + /** + * @deprecated Use + * {@link #TJCompressor(byte[], int, int, int, int, int, int)} instead. + */ + @Deprecated + public TJCompressor(byte[] srcImage, int width, int pitch, int height, + int pixelFormat) throws Exception { + setSourceImage(srcImage, width, pitch, height, pixelFormat); + } + /** * Create a TurboJPEG compressor instance and associate the uncompressed - * source image stored in srcImage with the newly-created + * source image stored in srcImage with the newly created * instance. * * @param srcImage see @@ -107,34 +107,35 @@ public class TJCompressor { } /** - * Associate an uncompressed source image with this compressor instance. + * Associate an uncompressed RGB, grayscale, or CMYK source image with this + * compressor instance. * * @param srcImage image buffer containing RGB, grayscale, or CMYK pixels to - * be compressed + * be compressed or encoded * - * @param x x offset (in pixels) of the region from which the JPEG image - * should be compressed, relative to the start of srcImage. + * @param x x offset (in pixels) of the region in the source image from which + * the JPEG or YUV image should be compressed/encoded * - * @param y y offset (in pixels) of the region from which the JPEG image - * should be compressed, relative to the start of srcImage. + * @param y y offset (in pixels) of the region in the source image from which + * the JPEG or YUV image should be compressed/encoded * * @param width width (in pixels) of the region in the source image from - * which the JPEG image should be compressed. + * which the JPEG or YUV image should be compressed/encoded * * @param pitch bytes per line of the source image. Normally, this should be * width * TJ.pixelSize(pixelFormat) if the source image is * unpadded, but you can use this parameter to, for instance, specify that * the scanlines in the source image are padded to a 4-byte boundary or to - * compress a JPEG image from a region of a larger source image. You can - * also be clever and use this parameter to skip lines, etc. Setting this - * parameter to 0 is the equivalent of setting it to width * - * TJ.pixelSize(pixelFormat). + * compress/encode a JPEG or YUV image from a region of a larger source + * image. You can also be clever and use this parameter to skip lines, etc. + * Setting this parameter to 0 is the equivalent of setting it to + * width * TJ.pixelSize(pixelFormat). * * @param height height (in pixels) of the region in the source image from - * which the JPEG image should be compressed. + * which the JPEG or YUV image should be compressed/encoded * * @param pixelFormat pixel format of the source image (one of - * {@link TJ TJ.PF_*}) + * {@link TJ#PF_RGB TJ.PF_*}) */ public void setSourceImage(byte[] srcImage, int x, int y, int width, int pitch, int height, int pixelFormat) @@ -154,7 +155,7 @@ public class TJCompressor { srcX = x; srcY = y; srcBufInt = null; - srcIsYUV = false; + srcYUVImage = null; } /** @@ -169,22 +170,25 @@ public class TJCompressor { } /** - * Associate an uncompressed source image with this compressor instance. + * Associate an uncompressed RGB or grayscale source image with this + * compressor instance. * * @param srcImage a BufferedImage instance containing RGB or - * grayscale pixels to be compressed + * grayscale pixels to be compressed or encoded * * @param x x offset (in pixels) of the region in the source image from which - * the JPEG image should be compressed + * the JPEG or YUV image should be compressed/encoded * * @param y y offset (in pixels) of the region in the source image from which - * the JPEG image should be compressed + * the JPEG or YUV image should be compressed/encoded * * @param width width (in pixels) of the region in the source image from - * which the JPEG image should be compressed (0 = compress the whole image) + * which the JPEG or YUV image should be compressed/encoded (0 = use the + * width of the source image) * * @param height height (in pixels) of the region in the source image from - * which the JPEG image should be compressed (0 = compress the whole image) + * which the JPEG or YUV image should be compressed/encoded (0 = use the + * height of the source image) */ public void setSourceImage(BufferedImage srcImage, int x, int y, int width, int height) throws Exception { @@ -248,42 +252,22 @@ public class TJCompressor { srcBuf = db.getData(); srcBufInt = null; } + srcYUVImage = null; } /** * Associate an uncompressed YUV planar source image with this compressor * instance. * - * @param srcImage image buffer containing a YUV planar image to be - * compressed. The Y, U (Cb), and V (Cr) image planes should be stored - * sequentially in the buffer, and the size of each plane is determined by - * the specified width, height, and padding, as well as the level of - * chrominance subsampling (specified using {@link #setSubsamp}.) If the - * chrominance components are subsampled along the horizontal dimension, then - * the width of the luminance plane should be padded to the nearest multiple - * of 2 (same goes for the height of the luminance plane, if the chrominance - * components are subsampled along the vertical dimension.) This is - * irrespective of any additional padding specified in the pad - * parameter. - * - * @param width width (in pixels) of the source image - * - * @param pad the line padding used in the source image. For instance, if - * each line in each plane of the YUV image is padded to the nearest multiple - * of 4 bytes, then pad should be set to 4. - * - * @param height height (in pixels) of the source image + * @param srcImage YUV planar image to be compressed */ - public void setSourceImageYUV(byte[] srcImage, int width, int pad, - int height) throws Exception { + public void setSourceImage(YUVImage srcImage) throws Exception { if (handle == 0) init(); - if (srcImage == null || width < 1 || pad < 1 || height < 1) - throw new Exception("Invalid argument in setSourceImageYUV()"); - srcBuf = srcImage; - srcWidth = width; - srcYUVPad = pad; - srcHeight = height; - srcIsYUV = true; + if (srcImage == null) + throw new Exception("Invalid argument in setSourceImage()"); + srcYUVImage = srcImage; + srcBuf = null; + srcBufInt = null; } /** @@ -296,12 +280,16 @@ public class TJCompressor { * sensitive to small changes in brightness than to small changes in color.) * This is called "chrominance subsampling". *

    - * NOTE: When compressing a YUV planar image into a JPEG image, this method - * also specifies the level of chrominance subsampling used in the source - * image. + * NOTE: This method has no effect when compressing a JPEG image from a YUV + * planar source. In that case, the level of chrominance subsampling in + * the JPEG image is determined by the source. Further, this method has no + * effect when encoding to a pre-allocated {@link YUVImage} instance. In + * that case, the level of chrominance subsampling is determined by the + * destination. * - * @param newSubsamp the new level of chrominance subsampling (one of - * {@link TJ TJ.SAMP_*}) + * @param newSubsamp the level of chrominance subsampling to use in + * subsequent compress/encode oeprations (one of + * {@link TJ#SAMP_444 TJ.SAMP_*}) */ public void setSubsamp(int newSubsamp) throws Exception { if (newSubsamp < 0 || newSubsamp >= TJ.NUMSAMP) @@ -327,23 +315,29 @@ public class TJCompressor { * * @param dstBuf buffer that will receive the JPEG image. Use * {@link TJ#bufSize} to determine the maximum size for this buffer based on - * the image width, height, and level of chrominance subsampling. + * the source image's width and height and the desired level of chrominance + * subsampling. * - * @param flags the bitwise OR of one or more of {@link TJ TJ.FLAG_*} + * @param flags the bitwise OR of one or more of + * {@link TJ#FLAG_BOTTOMUP TJ.FLAG_*} */ public void compress(byte[] dstBuf, int flags) throws Exception { if (dstBuf == null || flags < 0) throw new Exception("Invalid argument in compress()"); - if (srcBuf == null && (srcBufInt == null || srcIsYUV)) + if (srcBuf == null && srcBufInt == null && srcYUVImage == null) throw new Exception(NO_ASSOC_ERROR); if (jpegQuality < 0) throw new Exception("JPEG Quality not set"); - if (subsamp < 0) + if (subsamp < 0 && srcYUVImage == null) throw new Exception("Subsampling level not set"); - if (srcIsYUV) - compressedSize = compressFromYUV(srcBuf, srcWidth, srcYUVPad, srcHeight, - subsamp, dstBuf, jpegQuality, flags); + if (srcYUVImage != null) + compressedSize = compressFromYUV(srcYUVImage.getBuf(), + srcYUVImage.getWidth(), + srcYUVImage.getPad(), + srcYUVImage.getHeight(), + srcYUVImage.getSubsamp(), + dstBuf, jpegQuality, flags); else if (srcBuf != null) { if (srcX >= 0 && srcY >= 0) compressedSize = compress(srcBuf, srcX, srcY, srcWidth, srcPitch, @@ -369,7 +363,8 @@ public class TJCompressor { * Compress the uncompressed source image associated with this compressor * instance and return a buffer containing a JPEG image. * - * @param flags the bitwise OR of one or more of {@link TJ TJ.FLAG_*} + * @param flags the bitwise OR of one or more of + * {@link TJ#FLAG_BOTTOMUP TJ.FLAG_*} * * @return a buffer containing a JPEG image. The length of this buffer will * not be equal to the size of the JPEG image. Use {@link @@ -406,82 +401,100 @@ public class TJCompressor { return compress(flags); } - - /** - * Set the plane padding for subsequent YUV encode operations. - * - * @param pad the width of each line in each plane of the YUV image will be - * padded to the nearest multiple of this number of bytes (must be a - * power of 2.) The default padding is 4 bytes, which generates - * images suitable for direct video display. - */ - public void setYUVPad(int pad) throws Exception { - if(pad < 1 || ((pad & (pad - 1)) != 0)) - throw new Exception("Invalid argument in setYUVPad()"); - yuvPad = pad; - } - /** * Encode the uncompressed source image associated with this compressor - * instance and output a YUV planar image to the given destination buffer. - * This method uses the accelerated color conversion routines in TurboJPEG's - * underlying codec but does not execute any of the other steps in the JPEG - * compression process. The Y, U (Cb), and V (Cr) image planes are stored - * sequentially into the destination buffer, and the size of each plane is - * determined by the width and height of the source image, as well as the - * specified padding and level of chrominance subsampling. If the - * chrominance components are subsampled along the horizontal dimension, then - * the width of the luminance plane is padded to the nearest multiple of 2 in - * the output image (same goes for the height of the luminance plane, if the - * chrominance components are subsampled along the vertical dimension.) - *

    - * NOTE: Technically, the JPEG format uses the YCbCr colorspace, but per the - * convention of the digital video community, the TurboJPEG API uses "YUV" to - * refer to an image format consisting of Y, Cb, and Cr image planes. + * instance into a YUV planar image and store it in the given + * YUVImage instance. This method uses the accelerated color + * conversion routines in TurboJPEG's underlying codec but does not execute + * any of the other steps in the JPEG compression process. Encoding + * CMYK source images to YUV is not supported. * - * @param dstBuf buffer that will receive the YUV planar image. Use - * {@link TJ#bufSizeYUV} to determine the appropriate size for this buffer - * based on the image width, height, and level of chrominance subsampling. + * @param dstImage {@link YUVImage} instance that will receive the YUV planar + * image * - * @param flags the bitwise OR of one or more of {@link TJ TJ.FLAG_*} + * @param flags the bitwise OR of one or more of + * {@link TJ#FLAG_BOTTOMUP TJ.FLAG_*} */ - public void encodeYUV(byte[] dstBuf, int flags) throws Exception { - if (dstBuf == null || flags < 0) - throw new Exception("Invalid argument in compress()"); + public void encodeYUV(YUVImage dstImage, int flags) throws Exception { + if (dstImage == null || flags < 0) + throw new Exception("Invalid argument in encodeYUV()"); if (srcBuf == null && srcBufInt == null) throw new Exception(NO_ASSOC_ERROR); - if (srcIsYUV) + if (srcYUVImage != null) throw new Exception("Source image is not correct type"); if (subsamp < 0) throw new Exception("Subsampling level not set"); + if (srcWidth != dstImage.getWidth() || srcHeight != dstImage.getHeight()) + throw new Exception("Destination image is the wrong size"); if (srcBufInt != null) { - encodeYUV(srcBufInt, srcWidth, srcStride, srcHeight, srcPixelFormat, - dstBuf, yuvPad, subsamp, flags); + encodeYUV(srcBufInt, srcX, srcY, srcWidth, srcStride, srcHeight, + srcPixelFormat, dstImage.getBuf(), dstImage.getPad(), + dstImage.getSubsamp(), flags); } else { - encodeYUV(srcBuf, srcWidth, srcPitch, srcHeight, srcPixelFormat, dstBuf, - yuvPad, subsamp, flags); + encodeYUV(srcBuf, srcX, srcY, srcWidth, srcPitch, srcHeight, + srcPixelFormat, dstImage.getBuf(), dstImage.getPad(), + dstImage.getSubsamp(), flags); } - compressedSize = TJ.bufSizeYUV(srcWidth, yuvPad, srcHeight, subsamp); + compressedSize = dstImage.getSize(); + } + + /** + * @deprecated Use {@link #encodeYUV(YUVImage, int)} instead. + */ + @Deprecated + public void encodeYUV(byte[] dstBuf, int flags) throws Exception { + if(dstBuf == null) + throw new Exception("Invalid argument in encodeYUV()"); + if (srcWidth < 1 || srcHeight < 1) + throw new Exception(NO_ASSOC_ERROR); + if (subsamp < 0) + throw new Exception("Subsampling level not set"); + YUVImage yuvImage = new YUVImage(dstBuf, srcWidth, 4, srcHeight, subsamp); + encodeYUV(yuvImage, flags); } /** * Encode the uncompressed source image associated with this compressor - * instance and return a buffer containing a YUV planar image. See - * {@link #encodeYUV(byte[], int)} for more detail. + * instance into a YUV planar image and return a YUVImage + * instance containing the encoded image. This method uses the accelerated + * color conversion routines in TurboJPEG's underlying codec but does not + * execute any of the other steps in the JPEG compression process. Encoding + * CMYK source images to YUV is not supported. * - * @param flags the bitwise OR of one or more of {@link TJ TJ.FLAG_*} + * @param pad the width of each line in each plane of the YUV image will be + * padded to the nearest multiple of this number of bytes (must be a power of + * 2.) * - * @return a buffer containing a YUV planar image + * @param flags the bitwise OR of one or more of + * {@link TJ#FLAG_BOTTOMUP TJ.FLAG_*} + * + * @return a YUV planar image */ + public YUVImage encodeYUV(int pad, int flags) throws Exception { + if (srcWidth < 1 || srcHeight < 1) + throw new Exception(NO_ASSOC_ERROR); + if (subsamp < 0) + throw new Exception("Subsampling level not set"); + if(pad < 1 || ((pad & (pad - 1)) != 0)) + throw new Exception("Invalid argument in encodeYUV()"); + YUVImage yuvImage = new YUVImage(srcWidth, pad, srcHeight, subsamp); + encodeYUV(yuvImage, flags); + return yuvImage; + } + + /** + * @deprecated Use {@link #encodeYUV(int, int)} instead. + */ + @Deprecated public byte[] encodeYUV(int flags) throws Exception { if (srcWidth < 1 || srcHeight < 1) throw new Exception(NO_ASSOC_ERROR); if (subsamp < 0) throw new Exception("Subsampling level not set"); - byte[] buf = new byte[TJ.bufSizeYUV(srcWidth, yuvPad, srcHeight, subsamp)]; - encodeYUV(buf, flags); - return buf; + YUVImage yuvImage = new YUVImage(srcWidth, 4, srcHeight, subsamp); + encodeYUV(yuvImage, flags); + return yuvImage.getBuf(); } /** @@ -563,17 +576,17 @@ public class TJCompressor { int height, int pixelFormat, byte[] dstBuf, int subsamp, int flags) throws Exception; // deprecated - private native void encodeYUV(byte[] srcBuf, int width, int pitch, - int height, int pixelFormat, byte[] dstBuf, int pad, int subsamp, - int flags) throws Exception; + private native void encodeYUV(byte[] srcBuf, int x, int y, int width, + int pitch, int height, int pixelFormat, byte[] dstBuf, int pad, + int subsamp, int flags) throws Exception; private native void encodeYUV(int[] srcBuf, int width, int stride, int height, int pixelFormat, byte[] dstBuf, int subsamp, int flags) throws Exception; // deprecated - private native void encodeYUV(int[] srcBuf, int width, int pitch, - int height, int pixelFormat, byte[] dstBuf, int pad, int subsamp, - int flags) throws Exception; + private native void encodeYUV(int[] srcBuf, int x, int y, int width, + int pitch, int height, int pixelFormat, byte[] dstBuf, int pad, + int subsamp, int flags) throws Exception; static { TJLoader.load(); @@ -589,8 +602,7 @@ public class TJCompressor { private int srcPitch = 0; private int srcStride = 0; private int srcPixelFormat = -1; - private int srcYUVPad = -1; - private boolean srcIsYUV; + private YUVImage srcYUVImage = null; private int subsamp = -1; private int jpegQuality = -1; private int compressedSize = 0; diff --git a/java/org/libjpegturbo/turbojpeg/TJDecompressor.java b/java/org/libjpegturbo/turbojpeg/TJDecompressor.java index d14a9892..83057212 100644 --- a/java/org/libjpegturbo/turbojpeg/TJDecompressor.java +++ b/java/org/libjpegturbo/turbojpeg/TJDecompressor.java @@ -1,5 +1,5 @@ /* - * Copyright (C)2011-2013 D. R. Commander. All Rights Reserved. + * Copyright (C)2011-2014 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: @@ -37,7 +37,7 @@ import java.nio.*; public class TJDecompressor { private static final String NO_ASSOC_ERROR = - "No JPEG image is associated with this instance"; + "No source image is associated with this instance"; /** * Create a TurboJPEG decompresssor instance. @@ -47,21 +47,21 @@ public class TJDecompressor { } /** - * Create a TurboJPEG decompressor instance and associate the JPEG image - * stored in jpegImage with the newly-created instance. + * Create a TurboJPEG decompressor instance and associate the JPEG source + * image stored in jpegImage with the newly created instance. * * @param jpegImage JPEG image buffer (size of the JPEG image is assumed to * be the length of the array) */ public TJDecompressor(byte[] jpegImage) throws Exception { init(); - setJPEGImage(jpegImage, jpegImage.length); + setSourceImage(jpegImage, jpegImage.length); } /** - * Create a TurboJPEG decompressor instance and associate the JPEG image - * of length imageSize bytes stored in jpegImage - * with the newly-created instance. + * Create a TurboJPEG decompressor instance and associate the JPEG source + * image of length imageSize bytes stored in + * jpegImage with the newly created instance. * * @param jpegImage JPEG image buffer * @@ -69,87 +69,150 @@ public class TJDecompressor { */ public TJDecompressor(byte[] jpegImage, int imageSize) throws Exception { init(); - setJPEGImage(jpegImage, imageSize); + setSourceImage(jpegImage, imageSize); + } + + /** + * Create a TurboJPEG decompressor instance and associate the YUV planar + * source image stored in yuvImage with the newly created + * instance. + * + * @param yuvImage {@link YUVImage} instance containing a YUV planar + * image to be decoded + */ + public TJDecompressor(YUVImage yuvImage) throws Exception { + init(); + setSourceImage(yuvImage); } /** * Associate the JPEG image of length imageSize bytes stored in - * jpegImage with this decompressor instance. This image will + * srcImage with this decompressor instance. This image will * be used as the source image for subsequent decompress operations. * - * @param jpegImage JPEG image buffer + * @param srcImage JPEG image buffer * * @param imageSize size of the JPEG image (in bytes) */ - public void setJPEGImage(byte[] jpegImage, int imageSize) throws Exception { - if (jpegImage == null || imageSize < 1) - throw new Exception("Invalid argument in setJPEGImage()"); - jpegBuf = jpegImage; + public void setSourceImage(byte[] srcImage, int imageSize) + throws Exception { + if (srcImage == null || imageSize < 1) + throw new Exception("Invalid argument in setSourceImage()"); + jpegBuf = srcImage; jpegBufSize = imageSize; decompressHeader(jpegBuf, jpegBufSize); + yuvImage = null; } /** - * Returns the width of the JPEG image associated with this decompressor - * instance. - * - * @return the width of the JPEG image associated with this decompressor - * instance + * @deprecated Use {@link #setSourceImage(byte[], int)} instead. */ - public int getWidth() throws Exception { - if (jpegWidth < 1) - throw new Exception(NO_ASSOC_ERROR); - return jpegWidth; + @Deprecated + public void setJPEGImage(byte[] jpegImage, int imageSize) throws Exception { + setSourceImage(jpegImage, imageSize); } /** - * Returns the height of the JPEG image associated with this decompressor - * instance. + * Associate the specified YUV planar source image with this decompressor + * instance. Subsequent decompress operations will decode this image into an + * RGB or grayscale destination image. * - * @return the height of the JPEG image associated with this decompressor - * instance + * @param srcImage {@link YUVImage} instance containing a YUV planar image to + * be decoded */ - public int getHeight() throws Exception { - if (jpegHeight < 1) - throw new Exception(NO_ASSOC_ERROR); - return jpegHeight; + public void setSourceImage(YUVImage srcImage) throws Exception { + if (srcImage == null) + throw new Exception("Invalid argument in setSourceImage()"); + yuvImage = srcImage; + jpegBuf = null; + jpegBufSize = 0; } - /** - * Returns the level of chrominance subsampling used in the JPEG image - * associated with this decompressor instance. See {@link TJ TJ.SAMP_*}. - * - * @return the level of chrominance subsampling used in the JPEG image - * associated with this decompressor instance - */ - public int getSubsamp() throws Exception { - if (jpegSubsamp < 0) - throw new Exception(NO_ASSOC_ERROR); - if (jpegSubsamp >= TJ.NUMSAMP) - throw new Exception("JPEG header information is invalid"); - return jpegSubsamp; - } /** - * Returns the colorspace used in the JPEG image associated with this - * decompressor instance. See {@link TJ TJ.CS_*}. + * Returns the width of the source image (JPEG or YUV) associated with this + * decompressor instance. * - * @return the colorspace used in the JPEG image associated with this + * @return the width of the source image (JPEG or YUV) associated with this * decompressor instance */ - public int getColorspace() throws Exception { - if (jpegColorspace < 0) + public int getWidth() throws Exception { + if (yuvImage != null) + return yuvImage.getWidth(); + if (srcWidth < 1) throw new Exception(NO_ASSOC_ERROR); - if (jpegColorspace >= TJ.NUMCS) - throw new Exception("JPEG header information is invalid"); - return jpegColorspace; + return srcWidth; } /** - * Returns the JPEG image buffer associated with this decompressor instance. + * Returns the height of the source image (JPEG or YUV) associated with this + * decompressor instance. * - * @return the JPEG image buffer associated with this decompressor instance + * @return the height of the source image (JPEG or YUV) associated with this + * decompressor instance */ + public int getHeight() throws Exception { + if (yuvImage != null) + return yuvImage.getHeight(); + if (srcHeight < 1) + throw new Exception(NO_ASSOC_ERROR); + return srcHeight; + } + + /** + * Returns the level of chrominance subsampling used in the source image + * (JPEG or YUV) associated with this decompressor instance. See + * {@link TJ#SAMP_444 TJ.SAMP_*}. + * + * @return the level of chrominance subsampling used in the source image + * (JPEG or YUV) associated with this decompressor instance + */ + public int getSubsamp() throws Exception { + if (yuvImage != null) + return yuvImage.getSubsamp(); + if (srcSubsamp < 0) + throw new Exception(NO_ASSOC_ERROR); + if (srcSubsamp >= TJ.NUMSAMP) + throw new Exception("JPEG header information is invalid"); + return srcSubsamp; + } + + /** + * Returns the colorspace used in the source image (JPEG or YUV) associated + * with this decompressor instance. See {@link TJ#CS_RGB TJ.CS_*}. If the + * source image is YUV, then this always returns {@link TJ#CS_YCbCr}. + * + * @return the colorspace used in the source image (JPEG or YUV) associated + * with this decompressor instance + */ + public int getColorspace() throws Exception { + if (yuvImage != null) + return TJ.CS_YCbCr; + if (srcColorspace < 0) + throw new Exception(NO_ASSOC_ERROR); + if (srcColorspace >= TJ.NUMCS) + throw new Exception("JPEG header information is invalid"); + return srcColorspace; + } + + /** + * Returns the source image buffer associated with this decompressor + * instance. + * + * @return the source image buffer associated with this decompressor instance + */ + public byte[] getSourceBuf() throws Exception { + if (yuvImage != null) + return yuvImage.getBuf(); + if (jpegBuf == null) + throw new Exception(NO_ASSOC_ERROR); + return jpegBuf; + } + + /** + * @deprecated Use {@link #getSourceBuf} instead. + */ + @Deprecated public byte[] getJPEGBuf() throws Exception { if (jpegBuf == null) throw new Exception(NO_ASSOC_ERROR); @@ -157,18 +220,29 @@ public class TJDecompressor { } /** - * Returns the size of the JPEG image (in bytes) associated with this + * Returns the size of the source image (in bytes) associated with this * decompressor instance. * - * @return the size of the JPEG image (in bytes) associated with this + * @return the size of the source image (in bytes) associated with this * decompressor instance */ - public int getJPEGSize() throws Exception { + public int getSourceSize() throws Exception { + if (yuvImage != null) + return yuvImage.getSize(); if (jpegBufSize < 1) throw new Exception(NO_ASSOC_ERROR); return jpegBufSize; } + /** + * @deprecated Use {@link #getSourceSize} instead. + */ + @Deprecated + public int getJPEGSize() throws Exception { + if (jpegBufSize < 1) + throw new Exception(NO_ASSOC_ERROR); + return jpegBufSize; + } /** * Returns the width of the largest scaled-down image that the TurboJPEG @@ -191,19 +265,19 @@ public class TJDecompressor { */ public int getScaledWidth(int desiredWidth, int desiredHeight) throws Exception { - if (jpegWidth < 1 || jpegHeight < 1) + if (srcWidth < 1 || srcHeight < 1) throw new Exception(NO_ASSOC_ERROR); if (desiredWidth < 0 || desiredHeight < 0) throw new Exception("Invalid argument in getScaledWidth()"); TJScalingFactor[] sf = TJ.getScalingFactors(); if (desiredWidth == 0) - desiredWidth = jpegWidth; + desiredWidth = srcWidth; if (desiredHeight == 0) - desiredHeight = jpegHeight; - int scaledWidth = jpegWidth, scaledHeight = jpegHeight; + desiredHeight = srcHeight; + int scaledWidth = srcWidth, scaledHeight = srcHeight; for (int i = 0; i < sf.length; i++) { - scaledWidth = sf[i].getScaled(jpegWidth); - scaledHeight = sf[i].getScaled(jpegHeight); + scaledWidth = sf[i].getScaled(srcWidth); + scaledHeight = sf[i].getScaled(srcHeight); if (scaledWidth <= desiredWidth && scaledHeight <= desiredHeight) break; } @@ -233,19 +307,19 @@ public class TJDecompressor { */ public int getScaledHeight(int desiredWidth, int desiredHeight) throws Exception { - if (jpegWidth < 1 || jpegHeight < 1) + if (srcWidth < 1 || srcHeight < 1) throw new Exception(NO_ASSOC_ERROR); if (desiredWidth < 0 || desiredHeight < 0) throw new Exception("Invalid argument in getScaledHeight()"); TJScalingFactor[] sf = TJ.getScalingFactors(); if (desiredWidth == 0) - desiredWidth = jpegWidth; + desiredWidth = srcWidth; if (desiredHeight == 0) - desiredHeight = jpegHeight; - int scaledWidth = jpegWidth, scaledHeight = jpegHeight; + desiredHeight = srcHeight; + int scaledWidth = srcWidth, scaledHeight = srcHeight; for (int i = 0; i < sf.length; i++) { - scaledWidth = sf[i].getScaled(jpegWidth); - scaledHeight = sf[i].getScaled(jpegHeight); + scaledWidth = sf[i].getScaled(srcWidth); + scaledHeight = sf[i].getScaled(srcHeight); if (scaledWidth <= desiredWidth && scaledHeight <= desiredHeight) break; } @@ -255,73 +329,90 @@ public class TJDecompressor { } /** - * Decompress the JPEG source image associated with this decompressor - * instance and output a decompressed image to the given destination buffer. + * Decompress the JPEG source image or decode the YUV source image associated + * with this decompressor instance and output a grayscale, RGB, or CMYK image + * to the given destination buffer. * - * @param dstBuf buffer that will receive the decompressed image. This - * buffer should normally be pitch * scaledHeight bytes in size, - * where scaledHeight can be determined by calling + * @param dstBuf buffer that will receive the decompressed/decoded image. + * If the source image is a JPEG image, then this buffer should normally be + * pitch * scaledHeight bytes in size, where + * scaledHeight can be determined by calling * scalingFactor.{@link TJScalingFactor#getScaled getScaled}(jpegHeight) * with one of the scaling factors returned from {@link - * TJ#getScalingFactors} or by calling {@link #getScaledHeight}. However, - * the buffer may also be larger than the dimensions of the JPEG image, in - * which case the x, y, and pitch - * parameters can be used to specify the region into which the JPEG image - * should be decompressed. + * TJ#getScalingFactors} or by calling {@link #getScaledHeight}. If the + * source image is a YUV image, then this buffer should normally be + * pitch * height bytes in size, where height is + * the height of the YUV image. However, the buffer may also be larger than + * the dimensions of the source image, in which case the x, + * y, and pitch parameters can be used to specify + * the region into which the source image should be decompressed/decoded. * - * @param x x offset (in pixels) of the region into which the JPEG image - * should be decompressed, relative to the start of dstBuf. + * @param x x offset (in pixels) of the region in the destination image into + * which the source image should be decompressed/decoded * - * @param y y offset (in pixels) of the region into which the JPEG image - * should be decompressed, relative to the start of dstBuf. + * @param y y offset (in pixels) of the region in the destination image into + * which the source image should be decompressed/decoded * - * @param desiredWidth desired width (in pixels) of the decompressed image - * (or image region.) If the desired image dimensions are different than the - * dimensions of the JPEG image being decompressed, then TurboJPEG will use - * scaling in the JPEG decompressor to generate the largest possible image - * that will fit within the desired dimensions. Setting this to 0 is the - * same as setting it to the width of the JPEG image (in other words, the - * width will not be considered when determining the scaled image size.) + * @param desiredWidth If the source image is a JPEG image, then this + * specifies the desired width (in pixels) of the decompressed image (or + * image region.) If the desired destination image dimensions are different + * than the source image dimensions, then TurboJPEG will use scaling in the + * JPEG decompressor to generate the largest possible image that will fit + * within the desired dimensions. Setting this to 0 is the same as setting + * it to the width of the JPEG image (in other words, the width will not be + * considered when determining the scaled image size.) This parameter is + * ignored if the source image is a YUV image. * * @param pitch bytes per line of the destination image. Normally, this * should be set to scaledWidth * TJ.pixelSize(pixelFormat) if - * the decompressed image is unpadded, but you can use this to, for instance, - * pad each line of the decompressed image to a 4-byte boundary or to - * decompress the JPEG image into a region of a larger image. NOTE: - * scaledWidth can be determined by calling + * the destination image is unpadded, but you can use this to, for instance, + * pad each line of the destination image to a 4-byte boundary or to + * decompress/decode the source image into a region of a larger image. NOTE: + * if the source image is a JPEG image, then scaledWidth can be + * determined by calling * scalingFactor.{@link TJScalingFactor#getScaled getScaled}(jpegWidth) - * or by calling {@link #getScaledWidth}. Setting this parameter to - * 0 is the equivalent of setting it to scaledWidth * - * TJ.pixelSize(pixelFormat). + * or by calling {@link #getScaledWidth}. If the source image is a + * YUV image, then scaledWidth is the width of the YUV image. + * Setting this parameter to 0 is the equivalent of setting it to + * scaledWidth * TJ.pixelSize(pixelFormat). * - * @param desiredHeight desired height (in pixels) of the decompressed image - * (or image region.) If the desired image dimensions are different than the - * dimensions of the JPEG image being decompressed, then TurboJPEG will use - * scaling in the JPEG decompressor to generate the largest possible image - * that will fit within the desired dimensions. Setting this to 0 is the - * same as setting it to the height of the JPEG image (in other words, the - * height will not be considered when determining the scaled image size.) + * @param desiredHeight If the source image is a JPEG image, then this + * specifies the desired height (in pixels) of the decompressed image (or + * image region.) If the desired destination image dimensions are different + * than the source image dimensions, then TurboJPEG will use scaling in the + * JPEG decompressor to generate the largest possible image that will fit + * within the desired dimensions. Setting this to 0 is the same as setting + * it to the height of the JPEG image (in other words, the height will not be + * considered when determining the scaled image size.) This parameter is + * ignored if the source image is a YUV image. * - * @param pixelFormat pixel format of the decompressed image (one of - * {@link TJ TJ.PF_*}) + * @param pixelFormat pixel format of the decompressed/decoded image (one of + * {@link TJ#PF_RGB TJ.PF_*}) * - * @param flags the bitwise OR of one or more of {@link TJ TJ.FLAG_*} + * @param flags the bitwise OR of one or more of + * {@link TJ#FLAG_BOTTOMUP TJ.FLAG_*} */ public void decompress(byte[] dstBuf, int x, int y, int desiredWidth, int pitch, int desiredHeight, int pixelFormat, int flags) throws Exception { - if (jpegBuf == null) + if (jpegBuf == null && yuvImage == null) throw new Exception(NO_ASSOC_ERROR); - if (dstBuf == null || x < 0 || y < 0 || desiredWidth < 0 || pitch < 0 || - desiredHeight < 0 || pixelFormat < 0 || pixelFormat >= TJ.NUMPF || - flags < 0) + if (dstBuf == null || x < 0 || y < 0 || pitch < 0 || + (yuvImage != null && (desiredWidth < 0 || desiredHeight < 0)) || + pixelFormat < 0 || pixelFormat >= TJ.NUMPF || flags < 0) throw new Exception("Invalid argument in decompress()"); - if (x > 0 || y > 0) - decompress(jpegBuf, jpegBufSize, dstBuf, x, y, desiredWidth, pitch, - desiredHeight, pixelFormat, flags); - else - decompress(jpegBuf, jpegBufSize, dstBuf, desiredWidth, pitch, - desiredHeight, pixelFormat, flags); + if (yuvImage != null) + decodeYUV(yuvImage.getBuf(), yuvImage.getPad(), yuvImage.getSubsamp(), + dstBuf, x, y, yuvImage.getWidth(), pitch, yuvImage.getHeight(), + pixelFormat, flags); + else { + if (x > 0 || y > 0) + decompress(jpegBuf, jpegBufSize, dstBuf, x, y, desiredWidth, pitch, + desiredHeight, pixelFormat, flags); + else + decompress(jpegBuf, jpegBufSize, dstBuf, desiredWidth, pitch, + desiredHeight, pixelFormat, flags); + } } /** @@ -353,15 +444,17 @@ public class TJDecompressor { * for description * * @param pixelFormat pixel format of the decompressed image (one of - * {@link TJ TJ.PF_*}) + * {@link TJ#PF_RGB TJ.PF_*}) * - * @param flags the bitwise OR of one or more of {@link TJ TJ.FLAG_*} + * @param flags the bitwise OR of one or more of + * {@link TJ#FLAG_BOTTOMUP TJ.FLAG_*} * * @return a buffer containing the decompressed image */ public byte[] decompress(int desiredWidth, int pitch, int desiredHeight, int pixelFormat, int flags) throws Exception { - if (desiredWidth < 0 || pitch < 0 || desiredHeight < 0 || + if (pitch < 0 || + (yuvImage == null && (desiredWidth < 0 || desiredHeight < 0)) || pixelFormat < 0 || pixelFormat >= TJ.NUMPF || flags < 0) throw new Exception("Invalid argument in decompress()"); int pixelSize = TJ.getPixelSize(pixelFormat); @@ -376,22 +469,60 @@ public class TJDecompressor { /** * Decompress the JPEG source image associated with this decompressor - * instance and output a YUV planar image to the given destination buffer. - * This method performs JPEG decompression but leaves out the color - * conversion step, so a planar YUV image is generated instead of an RGB - * image. The padding of the planes in this image is the same as in the - * images generated by {@link TJCompressor#encodeYUV(byte[], int)}. Note - * that, if the width or height of the image is not an even multiple of the - * MCU block size (see {@link TJ#getMCUWidth} and {@link TJ#getMCUHeight}), - * then an intermediate buffer copy will be performed within TurboJPEG. - *

    - * NOTE: Technically, the JPEG format uses the YCbCr colorspace, but per the - * convention of the digital video community, the TurboJPEG API uses "YUV" to - * refer to an image format consisting of Y, Cb, and Cr image planes. + * instance into a YUV planar image and store it in the given + * YUVImage instance. This method performs JPEG decompression + * but leaves out the color conversion step, so a planar YUV image is + * generated instead of an RGB or grayscale image. This method cannot be + * used to decompress JPEG source images with the CMYK or YCCK colorspace. * - * @param dstBuf buffer that will receive the YUV planar image. Use - * {@link TJ#bufSizeYUV} to determine the appropriate size for this buffer - * based on the image width, height, and level of chrominance subsampling. + * @param dstImage {@link YUVImage} instance that will receive the YUV planar + * image. The level of subsampling specified in this YUVImage + * instance must match that of the JPEG image, and the width and height + * specified in the YUVImage instance must match one of the + * scaled image sizes that TurboJPEG is capable of generating from the JPEG + * source image. + * + * @param flags the bitwise OR of one or more of + * {@link TJ#FLAG_BOTTOMUP TJ.FLAG_*} + */ + public void decompressToYUV(YUVImage dstImage, int flags) throws Exception { + if (jpegBuf == null) + throw new Exception(NO_ASSOC_ERROR); + if (dstImage == null || flags < 0) + throw new Exception("Invalid argument in decompressToYUV()"); + int scaledWidth = getScaledWidth(dstImage.getWidth(), + dstImage.getHeight()); + int scaledHeight = getScaledHeight(dstImage.getWidth(), + dstImage.getHeight()); + if (scaledWidth != dstImage.getWidth() || + scaledHeight != dstImage.getHeight()) + throw new Exception("YUVImage dimensions do not match one of the scaled image sizes that TurboJPEG is capable of generating."); + if (srcSubsamp != dstImage.getSubsamp()) + throw new Exception("YUVImage subsampling level does not match that of the JPEG image"); + + decompressToYUV(jpegBuf, jpegBufSize, dstImage.getBuf(), + dstImage.getWidth(), dstImage.getPad(), + dstImage.getHeight(), flags); + } + + /** + * @deprecated Use {@link #decompressToYUV(YUVImage, int)} instead. + */ + @Deprecated + public void decompressToYUV(byte[] dstBuf, int flags) throws Exception { + YUVImage dstImage = new YUVImage(dstBuf, srcWidth, 4, srcHeight, + srcSubsamp); + decompressToYUV(dstImage, flags); + } + + /** + * Decompress the JPEG source image associated with this decompressor + * instance into a YUV planar image and return a YUVImage + * instance containing the decompressed image. This method performs JPEG + * decompression but leaves out the color conversion step, so a planar YUV + * image is generated instead of an RGB or grayscale image. This method + * cannot be used to decompress JPEG source images with the CMYK or YCCK + * colorspace. * * @param desiredWidth desired width (in pixels) of the YUV image. If the * desired image dimensions are different than the dimensions of the JPEG @@ -413,60 +544,28 @@ public class TJDecompressor { * the height of the JPEG image (in other words, the height will not be * considered when determining the scaled image size.) * - * @param flags the bitwise OR of one or more of {@link TJ TJ.FLAG_*} + * @param flags the bitwise OR of one or more of + * {@link TJ#FLAG_BOTTOMUP TJ.FLAG_*} + * + * @return a YUV planar image */ - public void decompressToYUV(byte[] dstBuf, int desiredWidth, int pad, - int desiredHeight, int flags) throws Exception { - if (jpegBuf == null) - throw new Exception(NO_ASSOC_ERROR); - if (dstBuf == null || desiredWidth < 0 || pad < 1 || - ((pad & (pad - 1)) != 0) || desiredHeight < 0 || flags < 0) - throw new Exception("Invalid argument in decompressToYUV()"); - decompressToYUV(jpegBuf, jpegBufSize, dstBuf, desiredWidth, pad, - desiredHeight, flags); - } - - /** - * @deprecated Use {@link #decompressToYUV(byte[], int, int, int, int)} - * instead. - */ - @Deprecated - public void decompressToYUV(byte[] dstBuf, int flags) throws Exception { - decompressToYUV(dstBuf, 0, 4, 0, flags); - } - - /** - * Decompress the JPEG source image associated with this decompressor - * instance and return a buffer containing a YUV planar image. See {@link - * #decompressToYUV(byte[], int, int, int, int)} for more detail. - * - * @param desiredWidth see - * {@link #decompressToYUV(byte[], int, int, int, int)} for description - * - * @param pad see {@link #decompressToYUV(byte[], int, int, int, int)} for - * description - * - * @param desiredHeight see {@link - * #decompressToYUV(byte[], int, int, int, int)} for description - * - * @param flags the bitwise OR of one or more of {@link TJ TJ.FLAG_*} - * - * @return a buffer containing a YUV planar image - */ - public byte[] decompressToYUV(int desiredWidth, int pad, int desiredHeight, - int flags) throws Exception { + public YUVImage decompressToYUV(int desiredWidth, int pad, int desiredHeight, + int flags) throws Exception { if (flags < 0) throw new Exception("Invalid argument in decompressToYUV()"); - if (jpegWidth < 1 || jpegHeight < 1 || jpegSubsamp < 0) + if (srcWidth < 1 || srcHeight < 1 || srcSubsamp < 0) throw new Exception(NO_ASSOC_ERROR); - if (jpegSubsamp >= TJ.NUMSAMP) + if (srcSubsamp >= TJ.NUMSAMP) throw new Exception("JPEG header information is invalid"); + if (yuvImage != null) + throw new Exception("Source image is the wrong type"); + int scaledWidth = getScaledWidth(desiredWidth, desiredHeight); int scaledHeight = getScaledHeight(desiredWidth, desiredHeight); - byte[] buf = new byte[TJ.bufSizeYUV(scaledWidth, pad, scaledHeight, - jpegSubsamp)]; - decompressToYUV(buf, desiredWidth, pad, desiredHeight, flags); - return buf; + YUVImage yuvImage = new YUVImage(scaledWidth, pad, scaledHeight, + srcSubsamp); + decompressToYUV(yuvImage, flags); + return yuvImage; } /** @@ -474,91 +573,126 @@ public class TJDecompressor { */ @Deprecated public byte[] decompressToYUV(int flags) throws Exception { - return decompressToYUV(0, 4, 0, flags); + YUVImage dstImage = new YUVImage(srcWidth, 4, srcHeight, srcSubsamp); + decompressToYUV(dstImage, flags); + return dstImage.getBuf(); } /** - * Decompress the JPEG source image associated with this decompressor - * instance and output a decompressed image to the given destination buffer. + * Decompress the JPEG source image or decode the YUV source image associated + * with this decompressor instance and output a grayscale, RGB, or CMYK image + * to the given destination buffer. * - * @param dstBuf buffer that will receive the decompressed image. This - * buffer should normally be stride * scaledHeight pixels in - * size, where scaledHeight can be determined by calling + * @param dstBuf buffer that will receive the decompressed/decoded image. + * If the source image is a JPEG image, then this buffer should normally be + * stride * scaledHeight pixels in size, where + * scaledHeight can be determined by calling * scalingFactor.{@link TJScalingFactor#getScaled getScaled}(jpegHeight) * with one of the scaling factors returned from {@link - * TJ#getScalingFactors} or by calling {@link #getScaledHeight}. However, - * the buffer may also be larger than the dimensions of the JPEG image, in - * which case the x, y, and stride - * parameters can be used to specify the region into which the JPEG image - * should be decompressed. + * TJ#getScalingFactors} or by calling {@link #getScaledHeight}. If the + * source image is a YUV image, then this buffer should normally be + * stride * height pixels in size, where height is + * the height of the YUV image. However, the buffer may also be larger than + * the dimensions of the JPEG image, in which case the x, + * y, and stride parameters can be used to specify + * the region into which the source image should be decompressed. * - * @param x x offset (in pixels) of the region into which the JPEG image - * should be decompressed, relative to the start of dstBuf. + * @param x x offset (in pixels) of the region in the destination image into + * which the source image should be decompressed/decoded * - * @param y y offset (in pixels) of the region into which the JPEG image - * should be decompressed, relative to the start of dstBuf. + * @param y y offset (in pixels) of the region in the destination image into + * which the source image should be decompressed/decoded * - * @param desiredWidth desired width (in pixels) of the decompressed image - * (or image region.) If the desired image dimensions are different than the - * dimensions of the JPEG image being decompressed, then TurboJPEG will use - * scaling in the JPEG decompressor to generate the largest possible image - * that will fit within the desired dimensions. Setting this to 0 is the - * same as setting it to the width of the JPEG image (in other words, the - * width will not be considered when determining the scaled image size.) + * @param desiredWidth If the source image is a JPEG image, then this + * specifies the desired width (in pixels) of the decompressed image (or + * image region.) If the desired destination image dimensions are different + * than the source image dimensions, then TurboJPEG will use scaling in the + * JPEG decompressor to generate the largest possible image that will fit + * within the desired dimensions. Setting this to 0 is the same as setting + * it to the width of the JPEG image (in other words, the width will not be + * considered when determining the scaled image size.) This parameter is + * ignored if the source image is a YUV image. * * @param stride pixels per line of the destination image. Normally, this * should be set to scaledWidth, but you can use this to, for * instance, decompress the JPEG image into a region of a larger image. - * NOTE: scaledWidth can be determined by calling + * NOTE: if the source image is a JPEG image, then scaledWidth + * can be determined by calling * scalingFactor.{@link TJScalingFactor#getScaled getScaled}(jpegWidth) - * or by calling {@link #getScaledWidth}. Setting this parameter to - * 0 is the equivalent of setting it to scaledWidth. + * or by calling {@link #getScaledWidth}. If the source image is a + * YUV image, then scaledWidth is the width of the YUV image. + * Setting this parameter to 0 is the equivalent of setting it to + * scaledWidth. * - * @param desiredHeight desired height (in pixels) of the decompressed image - * (or image region.) If the desired image dimensions are different than the - * dimensions of the JPEG image being decompressed, then TurboJPEG will use - * scaling in the JPEG decompressor to generate the largest possible image - * that will fit within the desired dimensions. Setting this to 0 is the - * same as setting it to the height of the JPEG image (in other words, the - * height will not be considered when determining the scaled image size.) + * @param desiredHeight If the source image is a JPEG image, then this + * specifies the desired height (in pixels) of the decompressed image (or + * image region.) If the desired destination image dimensions are different + * than the source image dimensions, then TurboJPEG will use scaling in the + * JPEG decompressor to generate the largest possible image that will fit + * within the desired dimensions. Setting this to 0 is the same as setting + * it to the height of the JPEG image (in other words, the height will not be + * considered when determining the scaled image size.) This parameter is + * ignored if the source image is a YUV image. * * @param pixelFormat pixel format of the decompressed image (one of - * {@link TJ TJ.PF_*}) + * {@link TJ#PF_RGB TJ.PF_*}) * - * @param flags the bitwise OR of one or more of {@link TJ TJ.FLAG_*} + * @param flags the bitwise OR of one or more of + * {@link TJ#FLAG_BOTTOMUP TJ.FLAG_*} */ public void decompress(int[] dstBuf, int x, int y, int desiredWidth, int stride, int desiredHeight, int pixelFormat, int flags) throws Exception { - if (jpegBuf == null) + if (jpegBuf == null && yuvImage == null) throw new Exception(NO_ASSOC_ERROR); - if (dstBuf == null || x < 0 || y < 0 || desiredWidth < 0 || stride < 0 || - desiredHeight < 0 || pixelFormat < 0 || pixelFormat >= TJ.NUMPF || - flags < 0) + if (dstBuf == null || x < 0 || y < 0 || stride < 0 || + (yuvImage != null && (desiredWidth < 0 || desiredHeight < 0)) || + pixelFormat < 0 || pixelFormat >= TJ.NUMPF || flags < 0) throw new Exception("Invalid argument in decompress()"); - decompress(jpegBuf, jpegBufSize, dstBuf, x, y, desiredWidth, stride, - desiredHeight, pixelFormat, flags); + if (yuvImage != null) + decodeYUV(yuvImage.getBuf(), yuvImage.getPad(), yuvImage.getSubsamp(), + dstBuf, x, y, yuvImage.getWidth(), stride, + yuvImage.getHeight(), pixelFormat, flags); + else + decompress(jpegBuf, jpegBufSize, dstBuf, x, y, desiredWidth, stride, + desiredHeight, pixelFormat, flags); } /** - * Decompress the JPEG source image associated with this decompressor - * instance and output a decompressed image to the given - * BufferedImage instance. + * Decompress the JPEG source image or decode the YUV source image associated + * with this decompressor instance and output a decompressed/decoded image to + * the given BufferedImage instance. * * @param dstImage a BufferedImage instance that will receive - * the decompressed image + * the decompressed/decoded image. If the source image is a JPEG image, then + * the width and height of the BufferedImage instance must match + * one of the scaled image sizes that TurboJPEG is capable of generating from + * the JPEG image. If the source image is a YUV image, then the width and + * height of the BufferedImage instance must match the width and + * height of the YUV image. * - * @param flags the bitwise OR of one or more of {@link TJ TJ.FLAG_*} + * @param flags the bitwise OR of one or more of + * {@link TJ#FLAG_BOTTOMUP TJ.FLAG_*} */ public void decompress(BufferedImage dstImage, int flags) throws Exception { if (dstImage == null || flags < 0) throw new Exception("Invalid argument in decompress()"); int desiredWidth = dstImage.getWidth(); int desiredHeight = dstImage.getHeight(); - int scaledWidth = getScaledWidth(desiredWidth, desiredHeight); - int scaledHeight = getScaledHeight(desiredWidth, desiredHeight); - if (scaledWidth != desiredWidth || scaledHeight != desiredHeight) - throw new Exception("BufferedImage dimensions do not match a scaled image size that TurboJPEG is capable of generating."); + int scaledWidth, scaledHeight; + + if (yuvImage != null) { + if (desiredWidth != yuvImage.getWidth() || + desiredHeight != yuvImage.getHeight()) + throw new Exception("BufferedImage dimensions do not match the dimensions of the source image."); + scaledWidth = yuvImage.getWidth(); + scaledHeight = yuvImage.getHeight(); + } else { + scaledWidth = getScaledWidth(desiredWidth, desiredHeight); + scaledHeight = getScaledHeight(desiredWidth, desiredHeight); + if (scaledWidth != desiredWidth || scaledHeight != desiredHeight) + throw new Exception("BufferedImage dimensions do not match one of the scaled image sizes that TurboJPEG is capable of generating."); + } int pixelFormat; boolean intPixels = false; if (byteOrder == null) byteOrder = ByteOrder.nativeOrder(); @@ -599,10 +733,16 @@ public class TJDecompressor { int stride = sm.getScanlineStride(); DataBufferInt db = (DataBufferInt)wr.getDataBuffer(); int[] buf = db.getData(); - if (jpegBuf == null) - throw new Exception(NO_ASSOC_ERROR); - decompress(jpegBuf, jpegBufSize, buf, scaledWidth, stride, scaledHeight, - pixelFormat, flags); + if (yuvImage != null) + decodeYUV(yuvImage.getBuf(), yuvImage.getPad(), yuvImage.getSubsamp(), + buf, 0, 0, yuvImage.getWidth(), stride, yuvImage.getHeight(), + pixelFormat, flags); + else { + if (jpegBuf == null) + throw new Exception(NO_ASSOC_ERROR); + decompress(jpegBuf, jpegBufSize, buf, 0, 0, scaledWidth, stride, + scaledHeight, pixelFormat, flags); + } } else { ComponentSampleModel sm = (ComponentSampleModel)dstImage.getSampleModel(); @@ -612,14 +752,15 @@ public class TJDecompressor { int pitch = sm.getScanlineStride(); DataBufferByte db = (DataBufferByte)wr.getDataBuffer(); byte[] buf = db.getData(); - decompress(buf, scaledWidth, pitch, scaledHeight, pixelFormat, flags); + decompress(buf, 0, 0, scaledWidth, pitch, scaledHeight, pixelFormat, + flags); } } /** - * Decompress the JPEG source image associated with this decompressor - * instance and return a BufferedImage instance containing the - * decompressed image. + * Decompress the JPEG source image or decode the YUV source image associated + * with this decompressor instance and return a BufferedImage + * instance containing the decompressed/decoded image. * * @param desiredWidth see * {@link #decompress(byte[], int, int, int, int, int, int, int)} for @@ -629,19 +770,21 @@ public class TJDecompressor { * {@link #decompress(byte[], int, int, int, int, int, int, int)} for * description * - * @param bufferedImageType the image type of the newly-created - * BufferedImage instance (for instance, + * @param bufferedImageType the image type of the BufferedImage + * instance that will be created (for instance, * BufferedImage.TYPE_INT_RGB) * - * @param flags the bitwise OR of one or more of {@link TJ TJ.FLAG_*} + * @param flags the bitwise OR of one or more of + * {@link TJ#FLAG_BOTTOMUP TJ.FLAG_*} * * @return a BufferedImage instance containing the - * decompressed image + * decompressed/decoded image */ public BufferedImage decompress(int desiredWidth, int desiredHeight, int bufferedImageType, int flags) throws Exception { - if (desiredWidth < 0 || desiredHeight < 0 || flags < 0) + if ((yuvImage == null && (desiredWidth < 0 || desiredHeight < 0)) || + flags < 0) throw new Exception("Invalid argument in decompress()"); int scaledWidth = getScaledWidth(desiredWidth, desiredHeight); int scaledHeight = getScaledHeight(desiredWidth, desiredHeight); @@ -696,6 +839,14 @@ public class TJDecompressor { private native void decompressToYUV(byte[] srcBuf, int size, byte[] dstBuf, int desiredWidth, int pad, int desiredheight, int flags) throws Exception; + private native void decodeYUV(byte[] srcBuf, int pad, int subsamp, + byte[] dstBuf, int x, int y, int width, int pitch, int height, + int pixelFormat, int flags) throws Exception; + + private native void decodeYUV(byte[] srcBuf, int pad, int subsamp, + int[] dstBuf, int x, int y, int width, int stride, int height, + int pixelFormat, int flags) throws Exception; + static { TJLoader.load(); } @@ -703,9 +854,10 @@ public class TJDecompressor { protected long handle = 0; protected byte[] jpegBuf = null; protected int jpegBufSize = 0; - protected int jpegWidth = 0; - protected int jpegHeight = 0; - protected int jpegSubsamp = -1; - protected int jpegColorspace = -1; + protected YUVImage yuvImage = null; + protected int srcWidth = 0; + protected int srcHeight = 0; + protected int srcSubsamp = -1; + protected int srcColorspace = -1; private ByteOrder byteOrder = null; }; diff --git a/java/org/libjpegturbo/turbojpeg/TJTransformer.java b/java/org/libjpegturbo/turbojpeg/TJTransformer.java index f84eaa12..ee1f6071 100644 --- a/java/org/libjpegturbo/turbojpeg/TJTransformer.java +++ b/java/org/libjpegturbo/turbojpeg/TJTransformer.java @@ -1,5 +1,5 @@ /* - * Copyright (C)2011, 2013 D. R. Commander. All Rights Reserved. + * Copyright (C)2011, 2013-2014 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: @@ -42,20 +42,20 @@ public class TJTransformer extends TJDecompressor { /** * Create a TurboJPEG lossless transformer instance and associate the JPEG - * image stored in jpegImage with the newly-created instance. + * image stored in jpegImage with the newly created instance. * * @param jpegImage JPEG image buffer (size of the JPEG image is assumed to * be the length of the array) */ public TJTransformer(byte[] jpegImage) throws Exception { init(); - setJPEGImage(jpegImage, jpegImage.length); + setSourceImage(jpegImage, jpegImage.length); } /** * Create a TurboJPEG lossless transformer instance and associate the JPEG * image of length imageSize bytes stored in - * jpegImage with the newly-created instance. + * jpegImage with the newly created instance. * * @param jpegImage JPEG image buffer * @@ -63,7 +63,7 @@ public class TJTransformer extends TJDecompressor { */ public TJTransformer(byte[] jpegImage, int imageSize) throws Exception { init(); - setJPEGImage(jpegImage, imageSize); + setSourceImage(jpegImage, imageSize); } /** @@ -84,13 +84,14 @@ public class TJTransformer extends TJDecompressor { * receive a JPEG image that has been transformed using the parameters in * transforms[i]. Use {@link TJ#bufSize} to determine the * maximum size for each buffer based on the transformed or cropped width and - * height. + * height and the level of subsampling used in the source image. * * @param transforms an array of {@link TJTransform} instances, each of * which specifies the transform parameters and/or cropping region for the * corresponding transformed output image * - * @param flags the bitwise OR of one or more of {@link TJ TJ.FLAG_*} + * @param flags the bitwise OR of one or more of + * {@link TJ#FLAG_BOTTOMUP TJ.FLAG_*} */ public void transform(byte[][] dstBufs, TJTransform[] transforms, int flags) throws Exception { @@ -112,20 +113,21 @@ public class TJTransformer extends TJDecompressor { * @return an array of {@link TJDecompressor} instances, each of * which has a transformed JPEG image associated with it * - * @param flags the bitwise OR of one or more of {@link TJ TJ.FLAG_*} + * @param flags the bitwise OR of one or more of + * {@link TJ#FLAG_BOTTOMUP TJ.FLAG_*} */ public TJDecompressor[] transform(TJTransform[] transforms, int flags) throws Exception { byte[][] dstBufs = new byte[transforms.length][]; - if (jpegWidth < 1 || jpegHeight < 1) + if (srcWidth < 1 || srcHeight < 1) throw new Exception("JPEG buffer not initialized"); for (int i = 0; i < transforms.length; i++) { - int w = jpegWidth, h = jpegHeight; + int w = srcWidth, h = srcHeight; if ((transforms[i].options & TJTransform.OPT_CROP) != 0) { if (transforms[i].width != 0) w = transforms[i].width; if (transforms[i].height != 0) h = transforms[i].height; } - dstBufs[i] = new byte[TJ.bufSize(w, h, jpegSubsamp)]; + dstBufs[i] = new byte[TJ.bufSize(w, h, srcSubsamp)]; } TJDecompressor[] tjd = new TJDecompressor[transforms.length]; transform(dstBufs, transforms, flags); @@ -135,11 +137,11 @@ public class TJTransformer extends TJDecompressor { } /** - * Returns an array containing the sizes of the transformed JPEG images from - * the most recent call to {@link #transform transform()}. + * Returns an array containing the sizes of the transformed JPEG images + * generated by the most recent transform operation. * - * @return an array containing the sizes of the transformed JPEG images from - * the most recent call to {@link #transform transform()} + * @return an array containing the sizes of the transformed JPEG images + * generated by the most recent transform operation */ public int[] getTransformedSizes() throws Exception { if (transformedSizes == null) diff --git a/java/org/libjpegturbo/turbojpeg/YUVImage.java b/java/org/libjpegturbo/turbojpeg/YUVImage.java new file mode 100644 index 00000000..67935936 --- /dev/null +++ b/java/org/libjpegturbo/turbojpeg/YUVImage.java @@ -0,0 +1,193 @@ +/* + * Copyright (C)2014 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: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - Neither the name of the libjpeg-turbo Project nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS", + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +package org.libjpegturbo.turbojpeg; + +/** + * This class encapsulates a YUV planar image buffer and the metadata + * associated with it. The TurboJPEG API allows both the JPEG compression and + * decompression pipelines to be split into stages: YUV encode, compress from + * YUV, decompress to YUV, and YUV decode. A YUVImage instance + * serves as the destination image for YUV encode and decompress-to-YUV + * operations and as the source image for compress-from-YUV and YUV decode + * operations. + *

    + * Technically, the JPEG format uses the YCbCr colorspace (which technically is + * not a "colorspace" but rather a "color transform"), but per the convention + * of the digital video community, the TurboJPEG API uses "YUV" to refer to an + * image format consisting of Y, Cb, and Cr image planes. In this image + * format, the Y, Cb (U), and Cr (V) planes are stored sequentially in the same + * image buffer, and the size of each plane is determined by the image width, + * height, line padding, and level of chrominance subsampling. If the + * chrominance components are subsampled along the horizontal dimension, then + * the width of the luminance plane would be padded to the nearest multiple of + * 2 (same goes for the height of the luminance plane, if the chrominance + * components are subsampled along the vertical dimension.) For instance, if + * the source image is 35 x 35 pixels and 4:2:2 subsampling is used, then the + * luminance plane would be 36 x 35 bytes, and each of the chrominance planes + * would be 18 x 35 bytes. If you specify, for instance, a line padding of 4 + * bytes on top of this, then the luminance plane would be 36 x 35 bytes, and + * each of the chrominance planes would be 20 x 35 bytes. + */ +public class YUVImage { + + private static final String NO_ASSOC_ERROR = + "No YUV buffer is associated with this instance"; + + /** + * Create a YUVImage instance with a new image buffer. + * + * @param width width (in pixels) of the YUV image + * + * @param pad Each line of each plane in the YUV image buffer will be padded + * to this number of bytes (must be a power of 2.) + * + * @param height height (in pixels) of the YUV image + * + * @param subsamp the level of chrominance subsampling to be used in the YUV + * image (one of {@link TJ#SAMP_444 TJ.SAMP_*}) + */ + public YUVImage(int width, int pad, int height, int subsamp) + throws Exception { + setBuffer(new byte[TJ.bufSizeYUV(width, pad, height, subsamp)], width, pad, + height, subsamp); + } + + /** + * Create a YUVImage instance from an existing YUV planar image + * buffer. + * + * @param yuvImage image buffer that contains or will contain YUV planar + * image data. See {@link YUVImage above} for a description of the image + * format. You can use {@link TJ#bufSizeYUV} to determine the appropriate + * size for this buffer. + * + * @param width width (in pixels) of the YUV image + * + * @param pad the line padding used in the YUV image buffer. For + * instance, if each line in each plane of the buffer is padded to the + * nearest multiple of 4 bytes, then pad should be set to 4. + * + * @param height height (in pixels) of the YUV image + * + * @param subsamp the level of chrominance subsampling used in the YUV + * image (one of {@link TJ#SAMP_444 TJ.SAMP_*}) + */ + public YUVImage(byte[] yuvImage, int width, int pad, int height, + int subsamp) throws Exception { + setBuffer(yuvImage, width, pad, height, subsamp); + } + + private void setBuffer(byte[] yuvImage, int width, int pad, int height, + int subsamp) throws Exception { + if (yuvImage == null || width < 1 || pad < 1 || ((pad & (pad - 1)) != 0) || + height < 1 || subsamp < 0 || subsamp >= TJ.NUMSAMP) + throw new Exception("Invalid argument in YUVImage()"); + if (yuvImage.length != TJ.bufSizeYUV(width, pad, height, subsamp)) + throw new Exception("YUV image buffer is the wrong size"); + yuvBuf = yuvImage; + yuvWidth = width; + yuvPad = pad; + yuvHeight = height; + yuvSubsamp = subsamp; + } + + /** + * Returns the width of the YUV image. + * + * @return the width of the YUV image + */ + public int getWidth() throws Exception { + if (yuvWidth < 1) + throw new Exception(NO_ASSOC_ERROR); + return yuvWidth; + } + + /** + * Returns the height of the YUV image. + * + * @return the height of the YUV image + */ + public int getHeight() throws Exception { + if (yuvHeight < 1) + throw new Exception(NO_ASSOC_ERROR); + return yuvHeight; + } + + /** + * Returns the line padding used in the YUV image buffer. + * + * @return the line padding used in the YUV image buffer + */ + public int getPad() throws Exception { + if (yuvPad < 1 || ((yuvPad & (yuvPad - 1)) != 0)) + throw new Exception(NO_ASSOC_ERROR); + return yuvPad; + } + + /** + * Returns the level of chrominance subsampling used in the YUV image. See + * {@link TJ#SAMP_444 TJ.SAMP_*}. + * + * @return the level of chrominance subsampling used in the YUV image + */ + public int getSubsamp() throws Exception { + if (yuvSubsamp < 0 || yuvSubsamp >= TJ.NUMSAMP) + throw new Exception(NO_ASSOC_ERROR); + return yuvSubsamp; + } + + /** + * Returns the YUV image buffer + * + * @return the YUV image buffer + */ + public byte[] getBuf() throws Exception { + if (yuvBuf == null) + throw new Exception(NO_ASSOC_ERROR); + return yuvBuf; + } + + /** + * Returns the size (in bytes) of the YUV image buffer + * + * @return the size (in bytes) of the YUV image buffer + */ + public int getSize() throws Exception { + if (yuvBuf == null) + throw new Exception(NO_ASSOC_ERROR); + return yuvBuf.length; + } + + protected long handle = 0; + protected byte[] yuvBuf = null; + protected int yuvPad = 0; + protected int yuvWidth = 0; + protected int yuvHeight = 0; + protected int yuvSubsamp = -1; +}; diff --git a/java/org_libjpegturbo_turbojpeg_TJCompressor.h b/java/org_libjpegturbo_turbojpeg_TJCompressor.h index 50070efa..edb23b4d 100644 --- a/java/org_libjpegturbo_turbojpeg_TJCompressor.h +++ b/java/org_libjpegturbo_turbojpeg_TJCompressor.h @@ -74,10 +74,10 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___ /* * Class: org_libjpegturbo_turbojpeg_TJCompressor * Method: encodeYUV - * Signature: ([BIIII[BIII)V + * Signature: ([BIIIIII[BIII)V */ -JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___3BIIII_3BIII - (JNIEnv *, jobject, jbyteArray, jint, jint, jint, jint, jbyteArray, jint, jint, jint); +JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___3BIIIIII_3BIII + (JNIEnv *, jobject, jbyteArray, jint, jint, jint, jint, jint, jint, jbyteArray, jint, jint, jint); /* * Class: org_libjpegturbo_turbojpeg_TJCompressor @@ -90,10 +90,10 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___ /* * Class: org_libjpegturbo_turbojpeg_TJCompressor * Method: encodeYUV - * Signature: ([IIIII[BIII)V + * Signature: ([IIIIIII[BIII)V */ -JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___3IIIII_3BIII - (JNIEnv *, jobject, jintArray, jint, jint, jint, jint, jbyteArray, jint, jint, jint); +JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___3IIIIIII_3BIII + (JNIEnv *, jobject, jintArray, jint, jint, jint, jint, jint, jint, jbyteArray, jint, jint, jint); #ifdef __cplusplus } diff --git a/java/org_libjpegturbo_turbojpeg_TJDecompressor.h b/java/org_libjpegturbo_turbojpeg_TJDecompressor.h index 203f0048..1d8205c5 100644 --- a/java/org_libjpegturbo_turbojpeg_TJDecompressor.h +++ b/java/org_libjpegturbo_turbojpeg_TJDecompressor.h @@ -79,6 +79,22 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompressToYUV___3BI_3BIIII (JNIEnv *, jobject, jbyteArray, jint, jbyteArray, jint, jint, jint, jint); +/* + * Class: org_libjpegturbo_turbojpeg_TJDecompressor + * Method: decodeYUV + * Signature: ([BII[BIIIIIII)V + */ +JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decodeYUV___3BII_3BIIIIIII + (JNIEnv *, jobject, jbyteArray, jint, jint, jbyteArray, jint, jint, jint, jint, jint, jint, jint); + +/* + * Class: org_libjpegturbo_turbojpeg_TJDecompressor + * Method: decodeYUV + * Signature: ([BII[IIIIIIII)V + */ +JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decodeYUV___3BII_3IIIIIIII + (JNIEnv *, jobject, jbyteArray, jint, jint, jintArray, jint, jint, jint, jint, jint, jint, jint); + #ifdef __cplusplus } #endif diff --git a/turbojpeg-jni.c b/turbojpeg-jni.c index efe55902..e796cc15 100644 --- a/turbojpeg-jni.c +++ b/turbojpeg-jni.c @@ -1,5 +1,5 @@ /* - * Copyright (C)2011-2013 D. R. Commander. All Rights Reserved. + * Copyright (C)2011-2014 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: @@ -250,12 +250,13 @@ JNIEXPORT jint JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_compressFrom return (jint)jpegSize; } -JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___3BIIII_3BIII - (JNIEnv *env, jobject obj, jbyteArray src, jint width, jint pitch, - jint height, jint pf, jbyteArray dst, jint pad, jint subsamp, jint flags) +JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___3BIIIIII_3BIII + (JNIEnv *env, jobject obj, jbyteArray src, jint x, jint y, jint width, + jint pitch, jint height, jint pf, jbyteArray dst, jint pad, jint subsamp, + jint flags) { tjhandle handle=0; - jsize arraySize=0, yuvSize; + jsize arraySize=0, actualPitch, yuvSize; unsigned char *srcBuf=NULL, *dstBuf=NULL; gethandle(); @@ -266,7 +267,8 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___ if(org_libjpegturbo_turbojpeg_TJ_NUMPF!=TJ_NUMPF) _throw("Mismatch between Java and C API"); - arraySize=(pitch==0)? width*tjPixelSize[pf]*height:pitch*height; + actualPitch=(pitch==0)? width*tjPixelSize[pf]:pitch; + arraySize=(y+height-1)*actualPitch + x+width; if((*env)->GetArrayLength(env, src)GetPrimitiveArrayCritical(env, src, 0)); bailif0(dstBuf=(*env)->GetPrimitiveArrayCritical(env, dst, 0)); - if(tjEncodeYUV3(handle, srcBuf, width, pitch, height, pf, dstBuf, pad, - subsamp, flags)==-1) + 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); @@ -297,16 +299,17 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___ (JNIEnv *env, jobject obj, jbyteArray src, jint width, jint pitch, jint height, jint pf, jbyteArray dst, jint subsamp, jint flags) { - Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___3BIIII_3BIII( - env, obj, src, width, pitch, height, pf, dst, 4, subsamp, flags); + Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___3BIIIIII_3BIII( + env, obj, src, 0, 0, width, pitch, height, pf, dst, 4, subsamp, flags); } -JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___3IIIII_3BIII - (JNIEnv *env, jobject obj, jintArray src, jint width, jint stride, - jint height, jint pf, jbyteArray dst, jint pad, jint subsamp, jint flags) +JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___3IIIIIII_3BIII + (JNIEnv *env, jobject obj, jintArray src, jint x, jint y, jint width, + jint stride, jint height, jint pf, jbyteArray dst, jint pad, jint subsamp, + jint flags) { tjhandle handle=0; - jsize arraySize=0, yuvSize; + jsize arraySize=0, actualStride, yuvSize; unsigned char *srcBuf=NULL, *dstBuf=NULL; gethandle(); @@ -319,7 +322,8 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___ if(tjPixelSize[pf]!=sizeof(jint)) _throw("Pixel format must be 32-bit when encoding from an integer buffer."); - arraySize=(stride==0)? width*height:stride*height; + actualStride=(stride==0)? width:stride; + arraySize=(y+height-1)*actualStride + x+width; if((*env)->GetArrayLength(env, src)GetPrimitiveArrayCritical(env, src, 0)); bailif0(dstBuf=(*env)->GetPrimitiveArrayCritical(env, dst, 0)); - if(tjEncodeYUV3(handle, srcBuf, width, stride*sizeof(jint), height, pf, - dstBuf, pad, subsamp, flags)==-1) + 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); @@ -350,8 +354,8 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___ (JNIEnv *env, jobject obj, jintArray src, jint width, jint pitch, jint height, jint pf, jbyteArray dst, jint subsamp, jint flags) { - Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___3IIIII_3BIII( - env, obj, src, width, pitch, height, pf, dst, 4, subsamp, flags); + Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___3IIIIIII_3BIII( + env, obj, src, 0, 0, width, pitch, height, pf, dst, 4, subsamp, flags); } JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_destroy @@ -435,13 +439,13 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress } (*env)->ReleasePrimitiveArrayCritical(env, src, jpegBuf, 0); jpegBuf=NULL; - bailif0(_fid=(*env)->GetFieldID(env, _cls, "jpegSubsamp", "I")); + bailif0(_fid=(*env)->GetFieldID(env, _cls, "srcSubsamp", "I")); (*env)->SetIntField(env, obj, _fid, jpegSubsamp); - bailif0(_fid=(*env)->GetFieldID(env, _cls, "jpegColorspace", "I")); + bailif0(_fid=(*env)->GetFieldID(env, _cls, "srcColorspace", "I")); (*env)->SetIntField(env, obj, _fid, jpegColorspace); - bailif0(_fid=(*env)->GetFieldID(env, _cls, "jpegWidth", "I")); + bailif0(_fid=(*env)->GetFieldID(env, _cls, "srcWidth", "I")); (*env)->SetIntField(env, obj, _fid, width); - bailif0(_fid=(*env)->GetFieldID(env, _cls, "jpegHeight", "I")); + bailif0(_fid=(*env)->GetFieldID(env, _cls, "srcHeight", "I")); (*env)->SetIntField(env, obj, _fid, height); bailout: @@ -562,11 +566,11 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress if((*env)->GetArrayLength(env, src)GetFieldID(env, _cls, "jpegSubsamp", "I")); + bailif0(_fid=(*env)->GetFieldID(env, _cls, "srcSubsamp", "I")); jpegSubsamp=(int)(*env)->GetIntField(env, obj, _fid); - bailif0(_fid=(*env)->GetFieldID(env, _cls, "jpegWidth", "I")); + bailif0(_fid=(*env)->GetFieldID(env, _cls, "srcWidth", "I")); jpegWidth=(int)(*env)->GetIntField(env, obj, _fid); - bailif0(_fid=(*env)->GetFieldID(env, _cls, "jpegHeight", "I")); + bailif0(_fid=(*env)->GetFieldID(env, _cls, "srcHeight", "I")); jpegHeight=(int)(*env)->GetIntField(env, obj, _fid); yuvSize=(jsize)tjBufSizeYUV2(desiredWidth==0? jpegWidth:desiredWidth, @@ -601,6 +605,94 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress env, obj, src, jpegSize, dst, 0, 4, 0, flags); } +JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decodeYUV___3BII_3BIIIIIII + (JNIEnv *env, jobject obj, jbyteArray src, jint pad, jint subsamp, + jbyteArray dst, jint x, jint y, jint width, jint pitch, jint height, + jint pf, jint flags) +{ + tjhandle handle=0; + jsize arraySize=0, actualPitch; + unsigned char *srcBuf=NULL, *dstBuf=NULL; + + gethandle(); + + if(pf<0 || pf>=org_libjpegturbo_turbojpeg_TJ_NUMPF) + _throw("Invalid argument in decodeYUV()"); + if(org_libjpegturbo_turbojpeg_TJ_NUMPF!=TJ_NUMPF) + _throw("Mismatch between Java and C API"); + + arraySize=tjBufSizeYUV2(width, pad, height, subsamp); + if((*env)->GetArrayLength(env, src)GetArrayLength(env, dst)GetPrimitiveArrayCritical(env, src, 0)); + bailif0(dstBuf=(*env)->GetPrimitiveArrayCritical(env, dst, 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(srcBuf) (*env)->ReleasePrimitiveArrayCritical(env, src, srcBuf, 0); + return; +} + +JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decodeYUV___3BII_3IIIIIIII + (JNIEnv *env, jobject obj, jbyteArray src, jint pad, jint subsamp, + jintArray dst, jint x, jint y, jint width, jint stride, jint height, + jint pf, jint flags) +{ + tjhandle handle=0; + jsize arraySize=0, actualStride; + unsigned char *srcBuf=NULL, *dstBuf=NULL; + + gethandle(); + + if(pf<0 || pf>=org_libjpegturbo_turbojpeg_TJ_NUMPF) + _throw("Invalid argument in decodeYUV()"); + if(org_libjpegturbo_turbojpeg_TJ_NUMPF!=TJ_NUMPF) + _throw("Mismatch between Java and C API"); + if(tjPixelSize[pf]!=sizeof(jint)) + _throw("Pixel format must be 32-bit when decoding to an integer buffer."); + + arraySize=tjBufSizeYUV2(width, pad, height, subsamp); + if((*env)->GetArrayLength(env, src)GetArrayLength(env, dst)GetPrimitiveArrayCritical(env, src, 0)); + bailif0(dstBuf=(*env)->GetPrimitiveArrayCritical(env, dst, 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); + if(srcBuf) (*env)->ReleasePrimitiveArrayCritical(env, src, srcBuf, 0); + return; +} + JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJTransformer_init (JNIEnv *env, jobject obj) { @@ -698,11 +790,11 @@ JNIEXPORT jintArray JNICALL Java_org_libjpegturbo_turbojpeg_TJTransformer_transf if((*env)->GetArrayLength(env, jsrcBuf)GetFieldID(env, _cls, "jpegWidth", "I")); + bailif0(_fid=(*env)->GetFieldID(env, _cls, "srcWidth", "I")); jpegWidth=(int)(*env)->GetIntField(env, obj, _fid); - bailif0(_fid=(*env)->GetFieldID(env, _cls, "jpegHeight", "I")); + bailif0(_fid=(*env)->GetFieldID(env, _cls, "srcHeight", "I")); jpegHeight=(int)(*env)->GetIntField(env, obj, _fid); - bailif0(_fid=(*env)->GetFieldID(env, _cls, "jpegSubsamp", "I")); + bailif0(_fid=(*env)->GetFieldID(env, _cls, "srcSubsamp", "I")); jpegSubsamp=(int)(*env)->GetIntField(env, obj, _fid); n=(*env)->GetArrayLength(env, dstobjs); diff --git a/turbojpeg-mapfile.jni b/turbojpeg-mapfile.jni index a1be1fd6..283e01f8 100755 --- a/turbojpeg-mapfile.jni +++ b/turbojpeg-mapfile.jni @@ -74,7 +74,9 @@ TURBOJPEG_1.4 tjEncodeYUV3; Java_org_libjpegturbo_turbojpeg_TJ_bufSizeYUV__IIII; Java_org_libjpegturbo_turbojpeg_TJCompressor_compressFromYUV___3BIIII_3BII; - Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___3BIIII_3BIII; - Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___3IIIII_3BIII; + Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___3BIIIIII_3BIII; + Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___3IIIIIII_3BIII; Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompressToYUV___3BI_3BIIII; + Java_org_libjpegturbo_turbojpeg_TJDecompressor_decodeYUV___3BII_3BIIIIIII; + Java_org_libjpegturbo_turbojpeg_TJDecompressor_decodeYUV___3BII_3IIIIIIII; } TURBOJPEG_1.3; From a35cc3acf8837504a59a35fcc2c2f090b41b2396 Mon Sep 17 00:00:00 2001 From: DRC Date: Sun, 16 Mar 2014 22:59:51 +0000 Subject: [PATCH 46/65] This should have been checked in with the previous commit. --- .../org/libjpegturbo/turbojpeg/YUVImage.html | 583 ++++++++++++++++++ 1 file changed, 583 insertions(+) create mode 100644 java/doc/org/libjpegturbo/turbojpeg/YUVImage.html diff --git a/java/doc/org/libjpegturbo/turbojpeg/YUVImage.html b/java/doc/org/libjpegturbo/turbojpeg/YUVImage.html new file mode 100644 index 00000000..5edc6b09 --- /dev/null +++ b/java/doc/org/libjpegturbo/turbojpeg/YUVImage.html @@ -0,0 +1,583 @@ + + + + + +YUVImage + + + + + + + + + + + +


    + + + + + + + + + + + + + + + + + + + +
    + +
    + + + +
    + +

    + +org.libjpegturbo.turbojpeg +
    +Class YUVImage

    +
    +java.lang.Object
    +  extended by org.libjpegturbo.turbojpeg.YUVImage
    +
    +
    +
    +
    public class YUVImage
    extends java.lang.Object
    + + +

    +This class encapsulates a YUV planar image buffer and the metadata + associated with it. The TurboJPEG API allows both the JPEG compression and + decompression pipelines to be split into stages: YUV encode, compress from + YUV, decompress to YUV, and YUV decode. A YUVImage instance + serves as the destination image for YUV encode and decompress-to-YUV + operations and as the source image for compress-from-YUV and YUV decode + operations. +

    + Technically, the JPEG format uses the YCbCr colorspace (which technically is + not a "colorspace" but rather a "color transform"), but per the convention + of the digital video community, the TurboJPEG API uses "YUV" to refer to an + image format consisting of Y, Cb, and Cr image planes. In this image + format, the Y, Cb (U), and Cr (V) planes are stored sequentially in the same + image buffer, and the size of each plane is determined by the image width, + height, line padding, and level of chrominance subsampling. If the + chrominance components are subsampled along the horizontal dimension, then + the width of the luminance plane would be padded to the nearest multiple of + 2 (same goes for the height of the luminance plane, if the chrominance + components are subsampled along the vertical dimension.) For instance, if + the source image is 35 x 35 pixels and 4:2:2 subsampling is used, then the + luminance plane would be 36 x 35 bytes, and each of the chrominance planes + would be 18 x 35 bytes. If you specify, for instance, a line padding of 4 + bytes on top of this, then the luminance plane would be 36 x 35 bytes, and + each of the chrominance planes would be 20 x 35 bytes. +

    + +

    +


    + +

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Field Summary
    +protected  longhandle + +
    +           
    +protected  byte[]yuvBuf + +
    +           
    +protected  intyuvHeight + +
    +           
    +protected  intyuvPad + +
    +           
    +protected  intyuvSubsamp + +
    +           
    +protected  intyuvWidth + +
    +           
    +  + + + + + + + + + + + + + +
    +Constructor Summary
    YUVImage(byte[] yuvImage, + int width, + int pad, + int height, + int subsamp) + +
    +          Create a YUVImage instance from an existing YUV planar image + buffer.
    YUVImage(int width, + int pad, + int height, + int subsamp) + +
    +          Create a YUVImage instance with a new image buffer.
    +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + byte[]getBuf() + +
    +          Returns the YUV image buffer
    + intgetHeight() + +
    +          Returns the height of the YUV image.
    + intgetPad() + +
    +          Returns the line padding used in the YUV image buffer.
    + intgetSize() + +
    +          Returns the size (in bytes) of the YUV image buffer
    + intgetSubsamp() + +
    +          Returns the level of chrominance subsampling used in the YUV image.
    + intgetWidth() + +
    +          Returns the width of the YUV image.
    + + + + + + + +
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    +  +

    + + + + + + + + +
    +Field Detail
    + +

    +handle

    +
    +protected long handle
    +
    +
    +
    +
    +
    + +

    +yuvBuf

    +
    +protected byte[] yuvBuf
    +
    +
    +
    +
    +
    + +

    +yuvPad

    +
    +protected int yuvPad
    +
    +
    +
    +
    +
    + +

    +yuvWidth

    +
    +protected int yuvWidth
    +
    +
    +
    +
    +
    + +

    +yuvHeight

    +
    +protected int yuvHeight
    +
    +
    +
    +
    +
    + +

    +yuvSubsamp

    +
    +protected int yuvSubsamp
    +
    +
    +
    +
    + + + + + + + + +
    +Constructor Detail
    + +

    +YUVImage

    +
    +public YUVImage(int width,
    +                int pad,
    +                int height,
    +                int subsamp)
    +         throws java.lang.Exception
    +
    +
    Create a YUVImage instance with a new image buffer. +

    +

    +
    Parameters:
    width - width (in pixels) of the YUV image
    pad - Each line of each plane in the YUV image buffer will be padded + to this number of bytes (must be a power of 2.)
    height - height (in pixels) of the YUV image
    subsamp - the level of chrominance subsampling to be used in the YUV + image (one of TJ.SAMP_*) +
    Throws: +
    java.lang.Exception
    +
    +
    + +

    +YUVImage

    +
    +public YUVImage(byte[] yuvImage,
    +                int width,
    +                int pad,
    +                int height,
    +                int subsamp)
    +         throws java.lang.Exception
    +
    +
    Create a YUVImage instance from an existing YUV planar image + buffer. +

    +

    +
    Parameters:
    yuvImage - image buffer that contains or will contain YUV planar + image data. See above for a description of the image + format. You can use TJ.bufSizeYUV(int, int, int, int) to determine the appropriate + size for this buffer.
    width - width (in pixels) of the YUV image
    pad - the line padding used in the YUV image buffer. For + instance, if each line in each plane of the buffer is padded to the + nearest multiple of 4 bytes, then pad should be set to 4.
    height - height (in pixels) of the YUV image
    subsamp - the level of chrominance subsampling used in the YUV + image (one of TJ.SAMP_*) +
    Throws: +
    java.lang.Exception
    +
    + + + + + + + + +
    +Method Detail
    + +

    +getWidth

    +
    +public int getWidth()
    +             throws java.lang.Exception
    +
    +
    Returns the width of the YUV image. +

    +

    + +
    Returns:
    the width of the YUV image +
    Throws: +
    java.lang.Exception
    +
    +
    +
    + +

    +getHeight

    +
    +public int getHeight()
    +              throws java.lang.Exception
    +
    +
    Returns the height of the YUV image. +

    +

    + +
    Returns:
    the height of the YUV image +
    Throws: +
    java.lang.Exception
    +
    +
    +
    + +

    +getPad

    +
    +public int getPad()
    +           throws java.lang.Exception
    +
    +
    Returns the line padding used in the YUV image buffer. +

    +

    + +
    Returns:
    the line padding used in the YUV image buffer +
    Throws: +
    java.lang.Exception
    +
    +
    +
    + +

    +getSubsamp

    +
    +public int getSubsamp()
    +               throws java.lang.Exception
    +
    +
    Returns the level of chrominance subsampling used in the YUV image. See + TJ.SAMP_*. +

    +

    + +
    Returns:
    the level of chrominance subsampling used in the YUV image +
    Throws: +
    java.lang.Exception
    +
    +
    +
    + +

    +getBuf

    +
    +public byte[] getBuf()
    +              throws java.lang.Exception
    +
    +
    Returns the YUV image buffer +

    +

    + +
    Returns:
    the YUV image buffer +
    Throws: +
    java.lang.Exception
    +
    +
    +
    + +

    +getSize

    +
    +public int getSize()
    +            throws java.lang.Exception
    +
    +
    Returns the size (in bytes) of the YUV image buffer +

    +

    + +
    Returns:
    the size (in bytes) of the YUV image buffer +
    Throws: +
    java.lang.Exception
    +
    +
    + +
    + + + + + + + + + + + + + + + + + + + +
    + +
    + + + +
    + + + From 821a20d0e85e51307e79365ec32bc9d2eca91e31 Mon Sep 17 00:00:00 2001 From: DRC Date: Sun, 16 Mar 2014 23:12:25 +0000 Subject: [PATCH 47/65] Generate the Java documentation using javadoc 7, to improve readability. --- java/doc/allclasses-frame.html | 64 +- java/doc/allclasses-noframe.html | 64 +- java/doc/constant-values.html | 913 +++---- java/doc/deprecated-list.html | 506 ++-- java/doc/help-doc.html | 385 ++- java/doc/index-all.html | 1604 ++++++----- java/doc/index.html | 44 +- java/doc/org/libjpegturbo/turbojpeg/TJ.html | 2322 ++++++++-------- .../libjpegturbo/turbojpeg/TJCompressor.html | 1718 ++++++------ .../turbojpeg/TJCustomFilter.html | 417 ++- .../turbojpeg/TJDecompressor.html | 2335 ++++++++--------- .../turbojpeg/TJScalingFactor.html | 650 +++-- .../libjpegturbo/turbojpeg/TJTransform.html | 1413 +++++----- .../libjpegturbo/turbojpeg/TJTransformer.html | 768 +++--- .../org/libjpegturbo/turbojpeg/YUVImage.html | 1026 ++++---- .../libjpegturbo/turbojpeg/package-frame.html | 78 +- .../turbojpeg/package-summary.html | 345 ++- .../libjpegturbo/turbojpeg/package-tree.html | 274 +- java/doc/overview-tree.html | 280 +- java/doc/resources/background.gif | Bin 0 -> 2313 bytes java/doc/resources/inherit.gif | Bin 57 -> 0 bytes java/doc/resources/tab.gif | Bin 0 -> 291 bytes java/doc/resources/titlebar.gif | Bin 0 -> 10701 bytes java/doc/resources/titlebar_end.gif | Bin 0 -> 849 bytes java/doc/serialized-form.html | 322 +-- java/doc/stylesheet.css | 501 +++- 26 files changed, 8007 insertions(+), 8022 deletions(-) create mode 100644 java/doc/resources/background.gif delete mode 100644 java/doc/resources/inherit.gif create mode 100644 java/doc/resources/tab.gif create mode 100644 java/doc/resources/titlebar.gif create mode 100644 java/doc/resources/titlebar_end.gif diff --git a/java/doc/allclasses-frame.html b/java/doc/allclasses-frame.html index 2183aa4e..509ea508 100644 --- a/java/doc/allclasses-frame.html +++ b/java/doc/allclasses-frame.html @@ -1,43 +1,23 @@ - - - - -All Classes - - - - - - - - - - -All Classes -
    - - - - - -
    TJ -
    -TJCompressor -
    -TJCustomFilter -
    -TJDecompressor -
    -TJScalingFactor -
    -TJTransform -
    -TJTransformer -
    -YUVImage -
    -
    - - - + + + +All Classes + + + +

    All Classes

    + + + diff --git a/java/doc/allclasses-noframe.html b/java/doc/allclasses-noframe.html index 41ed55e6..3eac18fa 100644 --- a/java/doc/allclasses-noframe.html +++ b/java/doc/allclasses-noframe.html @@ -1,43 +1,23 @@ - - - - -All Classes - - - - - - - - - - -All Classes -
    - - - - - -
    TJ -
    -TJCompressor -
    -TJCustomFilter -
    -TJDecompressor -
    -TJScalingFactor -
    -TJTransform -
    -TJTransformer -
    -YUVImage -
    -
    - - - + + + +All Classes + + + +

    All Classes

    + + + diff --git a/java/doc/constant-values.html b/java/doc/constant-values.html index 01f950f3..ec1b21d4 100644 --- a/java/doc/constant-values.html +++ b/java/doc/constant-values.html @@ -1,462 +1,479 @@ - - - - -Constant Field Values - - - - - - - - - - - -
    - - +//--> + + - - - - - - - - - - - - -
    - -
    - + +

  • + + + - -
    -
    -

    -Constant Field Values

    -
    -
    -Contents - - - - - - -
    -org.libjpegturbo.*
    - -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    org.libjpegturbo.turbojpeg.TJ
    -public static final intCS_CMYK3
    -public static final intCS_GRAY2
    -public static final intCS_RGB0
    -public static final intCS_YCbCr1
    -public static final intCS_YCCK4
    -public static final intFLAG_ACCURATEDCT4096
    -public static final intFLAG_BOTTOMUP2
    -public static final intFLAG_FASTDCT2048
    -public static final intFLAG_FASTUPSAMPLE256
    -public static final intFLAG_FORCEMMX8
    -public static final intFLAG_FORCESSE16
    -public static final intFLAG_FORCESSE232
    -public static final intFLAG_FORCESSE3128
    -public static final intNUMCS5
    -public static final intNUMPF12
    -public static final intNUMSAMP6
    -public static final intPF_ABGR9
    -public static final intPF_ARGB10
    -public static final intPF_BGR1
    -public static final intPF_BGRA8
    -public static final intPF_BGRX3
    -public static final intPF_CMYK11
    -public static final intPF_GRAY6
    -public static final intPF_RGB0
    -public static final intPF_RGBA7
    -public static final intPF_RGBX2
    -public static final intPF_XBGR4
    -public static final intPF_XRGB5
    -public static final intSAMP_4115
    -public static final intSAMP_4202
    -public static final intSAMP_4221
    -public static final intSAMP_4404
    -public static final intSAMP_4440
    -public static final intSAMP_GRAY3
    - -

    - -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    org.libjpegturbo.turbojpeg.TJTransform
    -public static final intNUMOP8
    -public static final intOP_HFLIP1
    -public static final intOP_NONE0
    -public static final intOP_ROT1806
    -public static final intOP_ROT2707
    -public static final intOP_ROT905
    -public static final intOP_TRANSPOSE3
    -public static final intOP_TRANSVERSE4
    -public static final intOP_VFLIP2
    -public static final intOPT_CROP4
    -public static final intOPT_GRAY8
    -public static final intOPT_NOOUTPUT16
    -public static final intOPT_PERFECT1
    -public static final intOPT_TRIM2
    - -

    - -

    -


    - - +
    +

    Constant Field Values

    +

    Contents

    + +
    +
    + + +

    org.libjpegturbo.*

    + +
    - - - - - - - - - - - - -
    - -
    - + + + + + - -
    - - - + + diff --git a/java/doc/deprecated-list.html b/java/doc/deprecated-list.html index a0a67a6d..79fd7ed9 100644 --- a/java/doc/deprecated-list.html +++ b/java/doc/deprecated-list.html @@ -1,276 +1,258 @@ - - - - -Deprecated List - - - - - - - - - - - -
    - - +//--> + + - - - - - - - - - - - - -
    - -
    - + + + + + - -
    -
    -

    -Deprecated API

    -
    -
    -Contents - - - - - - - - - - - - - - - - - - -
    -Deprecated Fields
    org.libjpegturbo.turbojpeg.TJ.FLAG_FORCEMMX -
    -           
    org.libjpegturbo.turbojpeg.TJ.FLAG_FORCESSE -
    -           
    org.libjpegturbo.turbojpeg.TJ.FLAG_FORCESSE2 -
    -           
    org.libjpegturbo.turbojpeg.TJ.FLAG_FORCESSE3 -
    -           
    -  -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -Deprecated Methods
    org.libjpegturbo.turbojpeg.TJ.bufSizeYUV(int, int, int) -
    -          Use TJ.bufSizeYUV(int, int, int, int) instead. 
    org.libjpegturbo.turbojpeg.TJCompressor.compress(BufferedImage, byte[], int) -
    -          Use - TJCompressor.setSourceImage(BufferedImage, int, int, int, int) and - TJCompressor.compress(byte[], int) instead. 
    org.libjpegturbo.turbojpeg.TJCompressor.compress(BufferedImage, int) -
    -          Use - TJCompressor.setSourceImage(BufferedImage, int, int, int, int) and - TJCompressor.compress(int) instead. 
    org.libjpegturbo.turbojpeg.TJDecompressor.decompress(byte[], int, int, int, int, int) -
    -          Use - TJDecompressor.decompress(byte[], int, int, int, int, int, int, int) instead. 
    org.libjpegturbo.turbojpeg.TJDecompressor.decompressToYUV(byte[], int) -
    -          Use TJDecompressor.decompressToYUV(YUVImage, int) instead. 
    org.libjpegturbo.turbojpeg.TJDecompressor.decompressToYUV(int) -
    -          Use TJDecompressor.decompressToYUV(int, int, int, int) instead. 
    org.libjpegturbo.turbojpeg.TJCompressor.encodeYUV(BufferedImage, byte[], int) -
    -          Use - TJCompressor.setSourceImage(BufferedImage, int, int, int, int) and - TJCompressor.encodeYUV(byte[], int) instead. 
    org.libjpegturbo.turbojpeg.TJCompressor.encodeYUV(BufferedImage, int) -
    -          Use - TJCompressor.setSourceImage(BufferedImage, int, int, int, int) and - TJCompressor.encodeYUV(int) instead. 
    org.libjpegturbo.turbojpeg.TJCompressor.encodeYUV(byte[], int) -
    -          Use TJCompressor.encodeYUV(YUVImage, int) instead. 
    org.libjpegturbo.turbojpeg.TJCompressor.encodeYUV(int) -
    -          Use TJCompressor.encodeYUV(int, int) instead. 
    org.libjpegturbo.turbojpeg.TJDecompressor.getJPEGBuf() -
    -          Use TJDecompressor.getSourceBuf() instead. 
    org.libjpegturbo.turbojpeg.TJDecompressor.getJPEGSize() -
    -          Use TJDecompressor.getSourceSize() instead. 
    org.libjpegturbo.turbojpeg.TJDecompressor.setJPEGImage(byte[], int) -
    -          Use TJDecompressor.setSourceImage(byte[], int) instead. 
    org.libjpegturbo.turbojpeg.TJCompressor.setSourceImage(byte[], int, int, int, int) -
    -          Use - TJCompressor.setSourceImage(byte[], int, int, int, int, int, int) instead. 
    -  -

    - - - - - - - - -
    -Deprecated Constructors
    org.libjpegturbo.turbojpeg.TJCompressor(byte[], int, int, int, int) -
    -          Use - TJCompressor.TJCompressor(byte[], int, int, int, int, int, int) instead. 
    -  -

    -


    - - + +
    + + + + + + + + + + + +
    - - - - - - - - - - - - -
    - -
    - + + + + + - -
    - - - + + diff --git a/java/doc/help-doc.html b/java/doc/help-doc.html index b919d0aa..ce749a93 100644 --- a/java/doc/help-doc.html +++ b/java/doc/help-doc.html @@ -1,207 +1,206 @@ - - - - -API Help - - - - - - - - - - - -
    - - +//--> + + - - - - - - - - - - - - -
    - -
    - + + + + + - -
    -
    -

    -How This API Document Is Organized

    -
    -This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.

    -Package

    -
    - -

    -Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain four categories:

      -
    • Interfaces (italic)
    • Classes
    • Enums
    • Exceptions
    • Errors
    • Annotation Types
    -
    -

    -Class/Interface

    -
    - -

    -Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:

      -
    • Class inheritance diagram
    • Direct Subclasses
    • All Known Subinterfaces
    • All Known Implementing Classes
    • Class/interface declaration
    • Class/interface description -

      -

    • Nested Class Summary
    • Field Summary
    • Constructor Summary
    • Method Summary -

      -

    • Field Detail
    • Constructor Detail
    • Method Detail
    -Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.
    - -

    -Annotation Type

    -
    - -

    -Each annotation type has its own separate page with the following sections:

      -
    • Annotation Type declaration
    • Annotation Type description
    • Required Element Summary
    • Optional Element Summary
    • Element Detail
    -
    - -

    -Enum

    -
    - -

    -Each enum has its own separate page with the following sections:

      -
    • Enum declaration
    • Enum description
    • Enum Constant Summary
    • Enum Constant Detail
    -
    -

    -Tree (Class Hierarchy)

    -
    -There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.
      -
    • When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
    • When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
    -
    -

    -Deprecated API

    -
    -The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.
    -

    -Index

    -
    -The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.
    -

    -Prev/Next

    -These links take you to the next or previous class, interface, package, or related page.

    -Frames/No Frames

    -These links show and hide the HTML frames. All pages are available with or without frames. -

    -

    -Serialized Form

    -Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description. -

    -

    -Constant Field Values

    -The Constant Field Values page lists the static final fields and their values. -

    - - -This help file applies to API documentation generated using the standard doclet. - -
    -


    - - +
    +

    How This API Document Is Organized

    +
    This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.
    +
    +
    +
      +
    • +

      Package

      +

      Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain six categories:

      +
        +
      • Interfaces (italic)
      • +
      • Classes
      • +
      • Enums
      • +
      • Exceptions
      • +
      • Errors
      • +
      • Annotation Types
      • +
      +
    • +
    • +

      Class/Interface

      +

      Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:

      +
        +
      • Class inheritance diagram
      • +
      • Direct Subclasses
      • +
      • All Known Subinterfaces
      • +
      • All Known Implementing Classes
      • +
      • Class/interface declaration
      • +
      • Class/interface description
      • +
      +
        +
      • Nested Class Summary
      • +
      • Field Summary
      • +
      • Constructor Summary
      • +
      • Method Summary
      • +
      +
        +
      • Field Detail
      • +
      • Constructor Detail
      • +
      • Method Detail
      • +
      +

      Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.

      +
    • +
    • +

      Annotation Type

      +

      Each annotation type has its own separate page with the following sections:

      +
        +
      • Annotation Type declaration
      • +
      • Annotation Type description
      • +
      • Required Element Summary
      • +
      • Optional Element Summary
      • +
      • Element Detail
      • +
      +
    • +
    • +

      Enum

      +

      Each enum has its own separate page with the following sections:

      +
        +
      • Enum declaration
      • +
      • Enum description
      • +
      • Enum Constant Summary
      • +
      • Enum Constant Detail
      • +
      +
    • +
    • +

      Tree (Class Hierarchy)

      +

      There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.

      +
        +
      • When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
      • +
      • When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
      • +
      +
    • +
    • +

      Deprecated API

      +

      The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.

      +
    • +
    • +

      Index

      +

      The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.

      +
    • +
    • +

      Prev/Next

      +

      These links take you to the next or previous class, interface, package, or related page.

      +
    • +
    • +

      Frames/No Frames

      +

      These links show and hide the HTML frames. All pages are available with or without frames.

      +
    • +
    • +

      All Classes

      +

      The All Classes link shows all classes and interfaces except non-static nested types.

      +
    • +
    • +

      Serialized Form

      +

      Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.

      +
    • +
    • +

      Constant Field Values

      +

      The Constant Field Values page lists the static final fields and their values.

      +
    • +
    +This help file applies to API documentation generated using the standard doclet.
    - - - - - - - - - - - - -
    - -
    - + + + + + - -
    - - - + + diff --git a/java/doc/index-all.html b/java/doc/index-all.html index df71bdee..c8a4f0c9 100644 --- a/java/doc/index-all.html +++ b/java/doc/index-all.html @@ -1,749 +1,919 @@ - - - - -Index - - - - - - - - - - - -
    - - +//--> + + - - - - - - - - - - - - -
    - -
    - + + + + + - -B C D E F G H I J N O P S T Y
    -

    -B

    -
    -
    bufSize(int, int, int) - -Static method in class org.libjpegturbo.turbojpeg.TJ -
    Returns the maximum size of the buffer (in bytes) required to hold a JPEG - image with the given width, height, and level of chrominance subsampling. -
    bufSizeYUV(int, int, int, int) - -Static method in class org.libjpegturbo.turbojpeg.TJ -
    Returns the size of the buffer (in bytes) required to hold a YUV planar - image with the given width, height, and level of chrominance subsampling. -
    bufSizeYUV(int, int, int) - -Static method in class org.libjpegturbo.turbojpeg.TJ -
    Deprecated. Use TJ.bufSizeYUV(int, int, int, int) instead. -
    -
    -

    -C

    -
    -
    cf - -Variable in class org.libjpegturbo.turbojpeg.TJTransform -
    Custom filter instance -
    close() - -Method in class org.libjpegturbo.turbojpeg.TJCompressor -
    Free the native structures associated with this compressor instance. -
    close() - -Method in class org.libjpegturbo.turbojpeg.TJDecompressor -
    Free the native structures associated with this decompressor instance. -
    compress(byte[], int) - -Method in class org.libjpegturbo.turbojpeg.TJCompressor -
    Compress the uncompressed source image associated with this compressor - instance and output a JPEG image to the given destination buffer. -
    compress(int) - -Method in class org.libjpegturbo.turbojpeg.TJCompressor -
    Compress the uncompressed source image associated with this compressor - instance and return a buffer containing a JPEG image. -
    compress(BufferedImage, byte[], int) - -Method in class org.libjpegturbo.turbojpeg.TJCompressor -
    Deprecated. Use - TJCompressor.setSourceImage(BufferedImage, int, int, int, int) and - TJCompressor.compress(byte[], int) instead. -
    compress(BufferedImage, int) - -Method in class org.libjpegturbo.turbojpeg.TJCompressor -
    Deprecated. Use - TJCompressor.setSourceImage(BufferedImage, int, int, int, int) and - TJCompressor.compress(int) instead. -
    CS_CMYK - -Static variable in class org.libjpegturbo.turbojpeg.TJ -
    CMYK colorspace. -
    CS_GRAY - -Static variable in class org.libjpegturbo.turbojpeg.TJ -
    Grayscale colorspace. -
    CS_RGB - -Static variable in class org.libjpegturbo.turbojpeg.TJ -
    RGB colorspace. -
    CS_YCbCr - -Static variable in class org.libjpegturbo.turbojpeg.TJ -
    YCbCr colorspace. -
    CS_YCCK - -Static variable in class org.libjpegturbo.turbojpeg.TJ -
    YCCK colorspace. -
    customFilter(ShortBuffer, Rectangle, Rectangle, int, int, TJTransform) - -Method in interface org.libjpegturbo.turbojpeg.TJCustomFilter -
    A callback function that can be used to modify the DCT coefficients after +
    B C D E F G H I J N O P S T Y  + + +

    B

    +
    +
    bufSize(int, int, int) - Static method in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    Returns the maximum size of the buffer (in bytes) required to hold a JPEG + image with the given width, height, and level of chrominance subsampling.
    +
    +
    bufSizeYUV(int, int, int, int) - Static method in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    Returns the size of the buffer (in bytes) required to hold a YUV planar + image with the given width, height, and level of chrominance subsampling.
    +
    +
    bufSizeYUV(int, int, int) - Static method in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    Deprecated. + +
    +
    +
    + + + +

    C

    +
    +
    cf - Variable in class org.libjpegturbo.turbojpeg.TJTransform
    +
    +
    Custom filter instance
    +
    +
    close() - Method in class org.libjpegturbo.turbojpeg.TJCompressor
    +
    +
    Free the native structures associated with this compressor instance.
    +
    +
    close() - Method in class org.libjpegturbo.turbojpeg.TJDecompressor
    +
    +
    Free the native structures associated with this decompressor instance.
    +
    +
    compress(byte[], int) - Method in class org.libjpegturbo.turbojpeg.TJCompressor
    +
    +
    Compress the uncompressed source image associated with this compressor + instance and output a JPEG image to the given destination buffer.
    +
    +
    compress(int) - Method in class org.libjpegturbo.turbojpeg.TJCompressor
    +
    +
    Compress the uncompressed source image associated with this compressor + instance and return a buffer containing a JPEG image.
    +
    +
    compress(BufferedImage, byte[], int) - Method in class org.libjpegturbo.turbojpeg.TJCompressor
    +
    + +
    +
    compress(BufferedImage, int) - Method in class org.libjpegturbo.turbojpeg.TJCompressor
    +
    + +
    +
    CS_CMYK - Static variable in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    CMYK colorspace.
    +
    +
    CS_GRAY - Static variable in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    Grayscale colorspace.
    +
    +
    CS_RGB - Static variable in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    RGB colorspace.
    +
    +
    CS_YCbCr - Static variable in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    YCbCr colorspace.
    +
    +
    CS_YCCK - Static variable in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    YCCK colorspace.
    +
    +
    customFilter(ShortBuffer, Rectangle, Rectangle, int, int, TJTransform) - Method in interface org.libjpegturbo.turbojpeg.TJCustomFilter
    +
    +
    A callback function that can be used to modify the DCT coefficients after they are losslessly transformed but before they are transcoded to a new - JPEG image. -
    -
    -

    -D

    -
    -
    decompress(byte[], int, int, int, int, int, int, int) - -Method in class org.libjpegturbo.turbojpeg.TJDecompressor -
    Decompress the JPEG source image or decode the YUV source image associated + JPEG image.
    +
    +
    + + + +

    D

    +
    +
    decompress(byte[], int, int, int, int, int, int, int) - Method in class org.libjpegturbo.turbojpeg.TJDecompressor
    +
    +
    Decompress the JPEG source image or decode the YUV source image associated with this decompressor instance and output a grayscale, RGB, or CMYK image - to the given destination buffer. -
    decompress(byte[], int, int, int, int, int) - -Method in class org.libjpegturbo.turbojpeg.TJDecompressor -
    Deprecated. Use - TJDecompressor.decompress(byte[], int, int, int, int, int, int, int) instead. -
    decompress(int, int, int, int, int) - -Method in class org.libjpegturbo.turbojpeg.TJDecompressor -
    Decompress the JPEG source image associated with this decompressor - instance and return a buffer containing the decompressed image. -
    decompress(int[], int, int, int, int, int, int, int) - -Method in class org.libjpegturbo.turbojpeg.TJDecompressor -
    Decompress the JPEG source image or decode the YUV source image associated + to the given destination buffer. +
    +
    decompress(byte[], int, int, int, int, int) - Method in class org.libjpegturbo.turbojpeg.TJDecompressor
    +
    + +
    +
    decompress(int, int, int, int, int) - Method in class org.libjpegturbo.turbojpeg.TJDecompressor
    +
    +
    Decompress the JPEG source image associated with this decompressor + instance and return a buffer containing the decompressed image.
    +
    +
    decompress(int[], int, int, int, int, int, int, int) - Method in class org.libjpegturbo.turbojpeg.TJDecompressor
    +
    +
    Decompress the JPEG source image or decode the YUV source image associated with this decompressor instance and output a grayscale, RGB, or CMYK image - to the given destination buffer. -
    decompress(BufferedImage, int) - -Method in class org.libjpegturbo.turbojpeg.TJDecompressor -
    Decompress the JPEG source image or decode the YUV source image associated + to the given destination buffer. +
    +
    decompress(BufferedImage, int) - Method in class org.libjpegturbo.turbojpeg.TJDecompressor
    +
    +
    Decompress the JPEG source image or decode the YUV source image associated with this decompressor instance and output a decompressed/decoded image to - the given BufferedImage instance. -
    decompress(int, int, int, int) - -Method in class org.libjpegturbo.turbojpeg.TJDecompressor -
    Decompress the JPEG source image or decode the YUV source image associated + the given BufferedImage instance. +
    +
    decompress(int, int, int, int) - Method in class org.libjpegturbo.turbojpeg.TJDecompressor
    +
    +
    Decompress the JPEG source image or decode the YUV source image associated with this decompressor instance and return a BufferedImage - instance containing the decompressed/decoded image. -
    decompressToYUV(YUVImage, int) - -Method in class org.libjpegturbo.turbojpeg.TJDecompressor -
    Decompress the JPEG source image associated with this decompressor + instance containing the decompressed/decoded image. +
    +
    decompressToYUV(YUVImage, int) - Method in class org.libjpegturbo.turbojpeg.TJDecompressor
    +
    +
    Decompress the JPEG source image associated with this decompressor instance into a YUV planar image and store it in the given - YUVImage instance. -
    decompressToYUV(byte[], int) - -Method in class org.libjpegturbo.turbojpeg.TJDecompressor -
    Deprecated. Use TJDecompressor.decompressToYUV(YUVImage, int) instead. -
    decompressToYUV(int, int, int, int) - -Method in class org.libjpegturbo.turbojpeg.TJDecompressor -
    Decompress the JPEG source image associated with this decompressor + YUVImage instance. +
    +
    decompressToYUV(byte[], int) - Method in class org.libjpegturbo.turbojpeg.TJDecompressor
    +
    + +
    +
    decompressToYUV(int, int, int, int) - Method in class org.libjpegturbo.turbojpeg.TJDecompressor
    +
    +
    Decompress the JPEG source image associated with this decompressor instance into a YUV planar image and return a YUVImage - instance containing the decompressed image. -
    decompressToYUV(int) - -Method in class org.libjpegturbo.turbojpeg.TJDecompressor -
    Deprecated. Use TJDecompressor.decompressToYUV(int, int, int, int) instead. -
    -
    -

    -E

    -
    -
    encodeYUV(YUVImage, int) - -Method in class org.libjpegturbo.turbojpeg.TJCompressor -
    Encode the uncompressed source image associated with this compressor + instance containing the decompressed image. +
    +
    decompressToYUV(int) - Method in class org.libjpegturbo.turbojpeg.TJDecompressor
    +
    + +
    +
    + + + +

    E

    +
    +
    encodeYUV(YUVImage, int) - Method in class org.libjpegturbo.turbojpeg.TJCompressor
    +
    +
    Encode the uncompressed source image associated with this compressor instance into a YUV planar image and store it in the given - YUVImage instance. -
    encodeYUV(byte[], int) - -Method in class org.libjpegturbo.turbojpeg.TJCompressor -
    Deprecated. Use TJCompressor.encodeYUV(YUVImage, int) instead. -
    encodeYUV(int, int) - -Method in class org.libjpegturbo.turbojpeg.TJCompressor -
    Encode the uncompressed source image associated with this compressor + YUVImage instance. +
    +
    encodeYUV(byte[], int) - Method in class org.libjpegturbo.turbojpeg.TJCompressor
    +
    +
    Deprecated. + +
    +
    +
    encodeYUV(int, int) - Method in class org.libjpegturbo.turbojpeg.TJCompressor
    +
    +
    Encode the uncompressed source image associated with this compressor instance into a YUV planar image and return a YUVImage - instance containing the encoded image. -
    encodeYUV(int) - -Method in class org.libjpegturbo.turbojpeg.TJCompressor -
    Deprecated. Use TJCompressor.encodeYUV(int, int) instead. -
    encodeYUV(BufferedImage, byte[], int) - -Method in class org.libjpegturbo.turbojpeg.TJCompressor -
    Deprecated. Use - TJCompressor.setSourceImage(BufferedImage, int, int, int, int) and - TJCompressor.encodeYUV(byte[], int) instead. -
    encodeYUV(BufferedImage, int) - -Method in class org.libjpegturbo.turbojpeg.TJCompressor -
    Deprecated. Use - TJCompressor.setSourceImage(BufferedImage, int, int, int, int) and - TJCompressor.encodeYUV(int) instead. -
    equals(TJScalingFactor) - -Method in class org.libjpegturbo.turbojpeg.TJScalingFactor -
    Returns true or false, depending on whether this instance and - other have the same numerator and denominator. -
    -
    -

    -F

    -
    -
    finalize() - -Method in class org.libjpegturbo.turbojpeg.TJCompressor -
      -
    finalize() - -Method in class org.libjpegturbo.turbojpeg.TJDecompressor -
      -
    FLAG_ACCURATEDCT - -Static variable in class org.libjpegturbo.turbojpeg.TJ -
    Use the most accurate DCT/IDCT algorithm available in the underlying - codec. -
    FLAG_BOTTOMUP - -Static variable in class org.libjpegturbo.turbojpeg.TJ -
    The uncompressed source/destination image is stored in bottom-up (Windows, - OpenGL) order, not top-down (X11) order. -
    FLAG_FASTDCT - -Static variable in class org.libjpegturbo.turbojpeg.TJ -
    Use the fastest DCT/IDCT algorithm available in the underlying codec. -
    FLAG_FASTUPSAMPLE - -Static variable in class org.libjpegturbo.turbojpeg.TJ -
    When decompressing an image that was compressed using chrominance + instance containing the encoded image. +
    +
    encodeYUV(int) - Method in class org.libjpegturbo.turbojpeg.TJCompressor
    +
    +
    Deprecated. + +
    +
    +
    encodeYUV(BufferedImage, byte[], int) - Method in class org.libjpegturbo.turbojpeg.TJCompressor
    +
    + +
    +
    encodeYUV(BufferedImage, int) - Method in class org.libjpegturbo.turbojpeg.TJCompressor
    +
    + +
    +
    equals(TJScalingFactor) - Method in class org.libjpegturbo.turbojpeg.TJScalingFactor
    +
    +
    Returns true or false, depending on whether this instance and + other have the same numerator and denominator.
    +
    +
    + + + +

    F

    +
    +
    finalize() - Method in class org.libjpegturbo.turbojpeg.TJCompressor
    +
     
    +
    finalize() - Method in class org.libjpegturbo.turbojpeg.TJDecompressor
    +
     
    +
    FLAG_ACCURATEDCT - Static variable in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    Use the most accurate DCT/IDCT algorithm available in the underlying + codec.
    +
    +
    FLAG_BOTTOMUP - Static variable in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    The uncompressed source/destination image is stored in bottom-up (Windows, + OpenGL) order, not top-down (X11) order.
    +
    +
    FLAG_FASTDCT - Static variable in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    Use the fastest DCT/IDCT algorithm available in the underlying codec.
    +
    +
    FLAG_FASTUPSAMPLE - Static variable in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    When decompressing an image that was compressed using chrominance subsampling, use the fastest chrominance upsampling algorithm available in - the underlying codec. -
    FLAG_FORCEMMX - -Static variable in class org.libjpegturbo.turbojpeg.TJ -
    Deprecated.  -
    FLAG_FORCESSE - -Static variable in class org.libjpegturbo.turbojpeg.TJ -
    Deprecated.  -
    FLAG_FORCESSE2 - -Static variable in class org.libjpegturbo.turbojpeg.TJ -
    Deprecated.  -
    FLAG_FORCESSE3 - -Static variable in class org.libjpegturbo.turbojpeg.TJ -
    Deprecated.  -
    -
    -

    -G

    -
    -
    getBlueOffset(int) - -Static method in class org.libjpegturbo.turbojpeg.TJ -
    For the given pixel format, returns the number of bytes that the blue - component is offset from the start of the pixel. -
    getBuf() - -Method in class org.libjpegturbo.turbojpeg.YUVImage -
    Returns the YUV image buffer -
    getColorspace() - -Method in class org.libjpegturbo.turbojpeg.TJDecompressor -
    Returns the colorspace used in the source image (JPEG or YUV) associated - with this decompressor instance. -
    getCompressedSize() - -Method in class org.libjpegturbo.turbojpeg.TJCompressor -
    Returns the size of the image (in bytes) generated by the most recent - compress/encode operation. -
    getDenom() - -Method in class org.libjpegturbo.turbojpeg.TJScalingFactor -
    Returns denominator -
    getGreenOffset(int) - -Static method in class org.libjpegturbo.turbojpeg.TJ -
    For the given pixel format, returns the number of bytes that the green - component is offset from the start of the pixel. -
    getHeight() - -Method in class org.libjpegturbo.turbojpeg.TJDecompressor -
    Returns the height of the source image (JPEG or YUV) associated with this - decompressor instance. -
    getHeight() - -Method in class org.libjpegturbo.turbojpeg.YUVImage -
    Returns the height of the YUV image. -
    getJPEGBuf() - -Method in class org.libjpegturbo.turbojpeg.TJDecompressor -
    Deprecated. Use TJDecompressor.getSourceBuf() instead. -
    getJPEGSize() - -Method in class org.libjpegturbo.turbojpeg.TJDecompressor -
    Deprecated. Use TJDecompressor.getSourceSize() instead. -
    getMCUHeight(int) - -Static method in class org.libjpegturbo.turbojpeg.TJ -
    Returns the MCU block height for the given level of chrominance - subsampling. -
    getMCUWidth(int) - -Static method in class org.libjpegturbo.turbojpeg.TJ -
    Returns the MCU block width for the given level of chrominance - subsampling. -
    getNum() - -Method in class org.libjpegturbo.turbojpeg.TJScalingFactor -
    Returns numerator -
    getPad() - -Method in class org.libjpegturbo.turbojpeg.YUVImage -
    Returns the line padding used in the YUV image buffer. -
    getPixelSize(int) - -Static method in class org.libjpegturbo.turbojpeg.TJ -
    Returns the pixel size (in bytes) for the given pixel format. -
    getRedOffset(int) - -Static method in class org.libjpegturbo.turbojpeg.TJ -
    For the given pixel format, returns the number of bytes that the red - component is offset from the start of the pixel. -
    getScaled(int) - -Method in class org.libjpegturbo.turbojpeg.TJScalingFactor -
    Returns the scaled value of dimension. -
    getScaledHeight(int, int) - -Method in class org.libjpegturbo.turbojpeg.TJDecompressor -
    Returns the height of the largest scaled-down image that the TurboJPEG + the underlying codec. +
    +
    FLAG_FORCEMMX - Static variable in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    Deprecated.
    +
    +
    FLAG_FORCESSE - Static variable in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    Deprecated.
    +
    +
    FLAG_FORCESSE2 - Static variable in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    Deprecated.
    +
    +
    FLAG_FORCESSE3 - Static variable in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    Deprecated.
    +
    +
    + + + +

    G

    +
    +
    getBlueOffset(int) - Static method in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    For the given pixel format, returns the number of bytes that the blue + component is offset from the start of the pixel.
    +
    +
    getBuf() - Method in class org.libjpegturbo.turbojpeg.YUVImage
    +
    +
    Returns the YUV image buffer
    +
    +
    getColorspace() - Method in class org.libjpegturbo.turbojpeg.TJDecompressor
    +
    +
    Returns the colorspace used in the source image (JPEG or YUV) associated + with this decompressor instance.
    +
    +
    getCompressedSize() - Method in class org.libjpegturbo.turbojpeg.TJCompressor
    +
    +
    Returns the size of the image (in bytes) generated by the most recent + compress/encode operation.
    +
    +
    getDenom() - Method in class org.libjpegturbo.turbojpeg.TJScalingFactor
    +
    +
    Returns denominator
    +
    +
    getGreenOffset(int) - Static method in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    For the given pixel format, returns the number of bytes that the green + component is offset from the start of the pixel.
    +
    +
    getHeight() - Method in class org.libjpegturbo.turbojpeg.TJDecompressor
    +
    +
    Returns the height of the source image (JPEG or YUV) associated with this + decompressor instance.
    +
    +
    getHeight() - Method in class org.libjpegturbo.turbojpeg.YUVImage
    +
    +
    Returns the height of the YUV image.
    +
    +
    getJPEGBuf() - Method in class org.libjpegturbo.turbojpeg.TJDecompressor
    +
    +
    Deprecated. + +
    +
    +
    getJPEGSize() - Method in class org.libjpegturbo.turbojpeg.TJDecompressor
    +
    +
    Deprecated. + +
    +
    +
    getMCUHeight(int) - Static method in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    Returns the MCU block height for the given level of chrominance + subsampling.
    +
    +
    getMCUWidth(int) - Static method in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    Returns the MCU block width for the given level of chrominance + subsampling.
    +
    +
    getNum() - Method in class org.libjpegturbo.turbojpeg.TJScalingFactor
    +
    +
    Returns numerator
    +
    +
    getPad() - Method in class org.libjpegturbo.turbojpeg.YUVImage
    +
    +
    Returns the line padding used in the YUV image buffer.
    +
    +
    getPixelSize(int) - Static method in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    Returns the pixel size (in bytes) for the given pixel format.
    +
    +
    getRedOffset(int) - Static method in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    For the given pixel format, returns the number of bytes that the red + component is offset from the start of the pixel.
    +
    +
    getScaled(int) - Method in class org.libjpegturbo.turbojpeg.TJScalingFactor
    +
    +
    Returns the scaled value of dimension.
    +
    +
    getScaledHeight(int, int) - Method in class org.libjpegturbo.turbojpeg.TJDecompressor
    +
    +
    Returns the height of the largest scaled-down image that the TurboJPEG decompressor can generate without exceeding the desired image width and - height. -
    getScaledWidth(int, int) - -Method in class org.libjpegturbo.turbojpeg.TJDecompressor -
    Returns the width of the largest scaled-down image that the TurboJPEG + height. +
    +
    getScaledWidth(int, int) - Method in class org.libjpegturbo.turbojpeg.TJDecompressor
    +
    +
    Returns the width of the largest scaled-down image that the TurboJPEG decompressor can generate without exceeding the desired image width and - height. -
    getScalingFactors() - -Static method in class org.libjpegturbo.turbojpeg.TJ -
    Returns a list of fractional scaling factors that the JPEG decompressor in - this implementation of TurboJPEG supports. -
    getSize() - -Method in class org.libjpegturbo.turbojpeg.YUVImage -
    Returns the size (in bytes) of the YUV image buffer -
    getSourceBuf() - -Method in class org.libjpegturbo.turbojpeg.TJDecompressor -
    Returns the source image buffer associated with this decompressor - instance. -
    getSourceSize() - -Method in class org.libjpegturbo.turbojpeg.TJDecompressor -
    Returns the size of the source image (in bytes) associated with this - decompressor instance. -
    getSubsamp() - -Method in class org.libjpegturbo.turbojpeg.TJDecompressor -
    Returns the level of chrominance subsampling used in the source image - (JPEG or YUV) associated with this decompressor instance. -
    getSubsamp() - -Method in class org.libjpegturbo.turbojpeg.YUVImage -
    Returns the level of chrominance subsampling used in the YUV image. -
    getTransformedSizes() - -Method in class org.libjpegturbo.turbojpeg.TJTransformer -
    Returns an array containing the sizes of the transformed JPEG images - generated by the most recent transform operation. -
    getWidth() - -Method in class org.libjpegturbo.turbojpeg.TJDecompressor -
    Returns the width of the source image (JPEG or YUV) associated with this - decompressor instance. -
    getWidth() - -Method in class org.libjpegturbo.turbojpeg.YUVImage -
    Returns the width of the YUV image. -
    -
    -

    -H

    -
    -
    handle - -Variable in class org.libjpegturbo.turbojpeg.TJDecompressor -
      -
    handle - -Variable in class org.libjpegturbo.turbojpeg.YUVImage -
      -
    -
    -

    -I

    -
    -
    isOne() - -Method in class org.libjpegturbo.turbojpeg.TJScalingFactor -
    Returns true or false, depending on whether this instance is equal to - 1/1. -
    -
    -

    -J

    -
    -
    jpegBuf - -Variable in class org.libjpegturbo.turbojpeg.TJDecompressor -
      -
    jpegBufSize - -Variable in class org.libjpegturbo.turbojpeg.TJDecompressor -
      -
    -
    -

    -N

    -
    -
    NUMCS - -Static variable in class org.libjpegturbo.turbojpeg.TJ -
    The number of JPEG colorspaces -
    NUMOP - -Static variable in class org.libjpegturbo.turbojpeg.TJTransform -
    The number of lossless transform operations -
    NUMPF - -Static variable in class org.libjpegturbo.turbojpeg.TJ -
    The number of pixel formats -
    NUMSAMP - -Static variable in class org.libjpegturbo.turbojpeg.TJ -
    The number of chrominance subsampling options -
    -
    -

    -O

    -
    -
    op - -Variable in class org.libjpegturbo.turbojpeg.TJTransform -
    Transform operation (one of OP_*) -
    OP_HFLIP - -Static variable in class org.libjpegturbo.turbojpeg.TJTransform -
    Flip (mirror) image horizontally. -
    OP_NONE - -Static variable in class org.libjpegturbo.turbojpeg.TJTransform -
    Do not transform the position of the image pixels. -
    OP_ROT180 - -Static variable in class org.libjpegturbo.turbojpeg.TJTransform -
    Rotate image 180 degrees. -
    OP_ROT270 - -Static variable in class org.libjpegturbo.turbojpeg.TJTransform -
    Rotate image counter-clockwise by 90 degrees. -
    OP_ROT90 - -Static variable in class org.libjpegturbo.turbojpeg.TJTransform -
    Rotate image clockwise by 90 degrees. -
    OP_TRANSPOSE - -Static variable in class org.libjpegturbo.turbojpeg.TJTransform -
    Transpose image (flip/mirror along upper left to lower right axis). -
    OP_TRANSVERSE - -Static variable in class org.libjpegturbo.turbojpeg.TJTransform -
    Transverse transpose image (flip/mirror along upper right to lower left - axis). -
    OP_VFLIP - -Static variable in class org.libjpegturbo.turbojpeg.TJTransform -
    Flip (mirror) image vertically. -
    OPT_CROP - -Static variable in class org.libjpegturbo.turbojpeg.TJTransform -
    This option will enable lossless cropping. -
    OPT_GRAY - -Static variable in class org.libjpegturbo.turbojpeg.TJTransform -
    This option will discard the color data in the input image and produce - a grayscale output image. -
    OPT_NOOUTPUT - -Static variable in class org.libjpegturbo.turbojpeg.TJTransform -
    This option will prevent TJTransformer.transform() from outputting a JPEG image for this - particular transform. -
    OPT_PERFECT - -Static variable in class org.libjpegturbo.turbojpeg.TJTransform -
    This option will cause TJTransformer.transform() to throw an exception if the transform is not - perfect. -
    OPT_TRIM - -Static variable in class org.libjpegturbo.turbojpeg.TJTransform -
    This option will discard any partial MCU blocks that cannot be - transformed. -
    options - -Variable in class org.libjpegturbo.turbojpeg.TJTransform -
    Transform options (bitwise OR of one or more of OPT_*) -
    org.libjpegturbo.turbojpeg - package org.libjpegturbo.turbojpeg
     
    -
    -

    -P

    -
    -
    PF_ABGR - -Static variable in class org.libjpegturbo.turbojpeg.TJ -
    ABGR pixel format. -
    PF_ARGB - -Static variable in class org.libjpegturbo.turbojpeg.TJ -
    ARGB pixel format. -
    PF_BGR - -Static variable in class org.libjpegturbo.turbojpeg.TJ -
    BGR pixel format. -
    PF_BGRA - -Static variable in class org.libjpegturbo.turbojpeg.TJ -
    BGRA pixel format. -
    PF_BGRX - -Static variable in class org.libjpegturbo.turbojpeg.TJ -
    BGRX pixel format. -
    PF_CMYK - -Static variable in class org.libjpegturbo.turbojpeg.TJ -
    CMYK pixel format. -
    PF_GRAY - -Static variable in class org.libjpegturbo.turbojpeg.TJ -
    Grayscale pixel format. -
    PF_RGB - -Static variable in class org.libjpegturbo.turbojpeg.TJ -
    RGB pixel format. -
    PF_RGBA - -Static variable in class org.libjpegturbo.turbojpeg.TJ -
    RGBA pixel format. -
    PF_RGBX - -Static variable in class org.libjpegturbo.turbojpeg.TJ -
    RGBX pixel format. -
    PF_XBGR - -Static variable in class org.libjpegturbo.turbojpeg.TJ -
    XBGR pixel format. -
    PF_XRGB - -Static variable in class org.libjpegturbo.turbojpeg.TJ -
    XRGB pixel format. -
    -
    -

    -S

    -
    -
    SAMP_411 - -Static variable in class org.libjpegturbo.turbojpeg.TJ -
    4:1:1 chrominance subsampling. -
    SAMP_420 - -Static variable in class org.libjpegturbo.turbojpeg.TJ -
    4:2:0 chrominance subsampling. -
    SAMP_422 - -Static variable in class org.libjpegturbo.turbojpeg.TJ -
    4:2:2 chrominance subsampling. -
    SAMP_440 - -Static variable in class org.libjpegturbo.turbojpeg.TJ -
    4:4:0 chrominance subsampling. -
    SAMP_444 - -Static variable in class org.libjpegturbo.turbojpeg.TJ -
    4:4:4 chrominance subsampling (no chrominance subsampling). -
    SAMP_GRAY - -Static variable in class org.libjpegturbo.turbojpeg.TJ -
    Grayscale. -
    setJPEGImage(byte[], int) - -Method in class org.libjpegturbo.turbojpeg.TJDecompressor -
    Deprecated. Use TJDecompressor.setSourceImage(byte[], int) instead. -
    setJPEGQuality(int) - -Method in class org.libjpegturbo.turbojpeg.TJCompressor -
    Set the JPEG image quality level for subsequent compress operations. -
    setSourceImage(byte[], int, int, int, int, int, int) - -Method in class org.libjpegturbo.turbojpeg.TJCompressor -
    Associate an uncompressed RGB, grayscale, or CMYK source image with this - compressor instance. -
    setSourceImage(byte[], int, int, int, int) - -Method in class org.libjpegturbo.turbojpeg.TJCompressor -
    Deprecated. Use - TJCompressor.setSourceImage(byte[], int, int, int, int, int, int) instead. -
    setSourceImage(BufferedImage, int, int, int, int) - -Method in class org.libjpegturbo.turbojpeg.TJCompressor -
    Associate an uncompressed RGB or grayscale source image with this - compressor instance. -
    setSourceImage(YUVImage) - -Method in class org.libjpegturbo.turbojpeg.TJCompressor -
    Associate an uncompressed YUV planar source image with this compressor - instance. -
    setSourceImage(byte[], int) - -Method in class org.libjpegturbo.turbojpeg.TJDecompressor -
    Associate the JPEG image of length imageSize bytes stored in - srcImage with this decompressor instance. -
    setSourceImage(YUVImage) - -Method in class org.libjpegturbo.turbojpeg.TJDecompressor -
    Associate the specified YUV planar source image with this decompressor - instance. -
    setSubsamp(int) - -Method in class org.libjpegturbo.turbojpeg.TJCompressor -
    Set the level of chrominance subsampling for subsequent compress/encode - operations. -
    srcColorspace - -Variable in class org.libjpegturbo.turbojpeg.TJDecompressor -
      -
    srcHeight - -Variable in class org.libjpegturbo.turbojpeg.TJDecompressor -
      -
    srcSubsamp - -Variable in class org.libjpegturbo.turbojpeg.TJDecompressor -
      -
    srcWidth - -Variable in class org.libjpegturbo.turbojpeg.TJDecompressor -
      -
    -
    -

    -T

    -
    -
    TJ - Class in org.libjpegturbo.turbojpeg
    TurboJPEG utility class (cannot be instantiated)
    TJ() - -Constructor for class org.libjpegturbo.turbojpeg.TJ -
      -
    TJCompressor - Class in org.libjpegturbo.turbojpeg
    TurboJPEG compressor
    TJCompressor() - -Constructor for class org.libjpegturbo.turbojpeg.TJCompressor -
    Create a TurboJPEG compressor instance. -
    TJCompressor(byte[], int, int, int, int, int, int) - -Constructor for class org.libjpegturbo.turbojpeg.TJCompressor -
    Create a TurboJPEG compressor instance and associate the uncompressed + height. +
    +
    getScalingFactors() - Static method in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    Returns a list of fractional scaling factors that the JPEG decompressor in + this implementation of TurboJPEG supports.
    +
    +
    getSize() - Method in class org.libjpegturbo.turbojpeg.YUVImage
    +
    +
    Returns the size (in bytes) of the YUV image buffer
    +
    +
    getSourceBuf() - Method in class org.libjpegturbo.turbojpeg.TJDecompressor
    +
    +
    Returns the source image buffer associated with this decompressor + instance.
    +
    +
    getSourceSize() - Method in class org.libjpegturbo.turbojpeg.TJDecompressor
    +
    +
    Returns the size of the source image (in bytes) associated with this + decompressor instance.
    +
    +
    getSubsamp() - Method in class org.libjpegturbo.turbojpeg.TJDecompressor
    +
    +
    Returns the level of chrominance subsampling used in the source image + (JPEG or YUV) associated with this decompressor instance.
    +
    +
    getSubsamp() - Method in class org.libjpegturbo.turbojpeg.YUVImage
    +
    +
    Returns the level of chrominance subsampling used in the YUV image.
    +
    +
    getTransformedSizes() - Method in class org.libjpegturbo.turbojpeg.TJTransformer
    +
    +
    Returns an array containing the sizes of the transformed JPEG images + generated by the most recent transform operation.
    +
    +
    getWidth() - Method in class org.libjpegturbo.turbojpeg.TJDecompressor
    +
    +
    Returns the width of the source image (JPEG or YUV) associated with this + decompressor instance.
    +
    +
    getWidth() - Method in class org.libjpegturbo.turbojpeg.YUVImage
    +
    +
    Returns the width of the YUV image.
    +
    +
    + + + +

    H

    +
    +
    handle - Variable in class org.libjpegturbo.turbojpeg.TJDecompressor
    +
     
    +
    handle - Variable in class org.libjpegturbo.turbojpeg.YUVImage
    +
     
    +
    + + + +

    I

    +
    +
    isOne() - Method in class org.libjpegturbo.turbojpeg.TJScalingFactor
    +
    +
    Returns true or false, depending on whether this instance is equal to + 1/1.
    +
    +
    + + + +

    J

    +
    +
    jpegBuf - Variable in class org.libjpegturbo.turbojpeg.TJDecompressor
    +
     
    +
    jpegBufSize - Variable in class org.libjpegturbo.turbojpeg.TJDecompressor
    +
     
    +
    + + + +

    N

    +
    +
    NUMCS - Static variable in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    The number of JPEG colorspaces
    +
    +
    NUMOP - Static variable in class org.libjpegturbo.turbojpeg.TJTransform
    +
    +
    The number of lossless transform operations
    +
    +
    NUMPF - Static variable in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    The number of pixel formats
    +
    +
    NUMSAMP - Static variable in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    The number of chrominance subsampling options
    +
    +
    + + + +

    O

    +
    +
    op - Variable in class org.libjpegturbo.turbojpeg.TJTransform
    +
    +
    Transform operation (one of OP_*)
    +
    +
    OP_HFLIP - Static variable in class org.libjpegturbo.turbojpeg.TJTransform
    +
    +
    Flip (mirror) image horizontally.
    +
    +
    OP_NONE - Static variable in class org.libjpegturbo.turbojpeg.TJTransform
    +
    +
    Do not transform the position of the image pixels.
    +
    +
    OP_ROT180 - Static variable in class org.libjpegturbo.turbojpeg.TJTransform
    +
    +
    Rotate image 180 degrees.
    +
    +
    OP_ROT270 - Static variable in class org.libjpegturbo.turbojpeg.TJTransform
    +
    +
    Rotate image counter-clockwise by 90 degrees.
    +
    +
    OP_ROT90 - Static variable in class org.libjpegturbo.turbojpeg.TJTransform
    +
    +
    Rotate image clockwise by 90 degrees.
    +
    +
    OP_TRANSPOSE - Static variable in class org.libjpegturbo.turbojpeg.TJTransform
    +
    +
    Transpose image (flip/mirror along upper left to lower right axis).
    +
    +
    OP_TRANSVERSE - Static variable in class org.libjpegturbo.turbojpeg.TJTransform
    +
    +
    Transverse transpose image (flip/mirror along upper right to lower left + axis).
    +
    +
    OP_VFLIP - Static variable in class org.libjpegturbo.turbojpeg.TJTransform
    +
    +
    Flip (mirror) image vertically.
    +
    +
    OPT_CROP - Static variable in class org.libjpegturbo.turbojpeg.TJTransform
    +
    +
    This option will enable lossless cropping.
    +
    +
    OPT_GRAY - Static variable in class org.libjpegturbo.turbojpeg.TJTransform
    +
    +
    This option will discard the color data in the input image and produce + a grayscale output image.
    +
    +
    OPT_NOOUTPUT - Static variable in class org.libjpegturbo.turbojpeg.TJTransform
    +
    +
    This option will prevent TJTransformer.transform() from outputting a JPEG image for this + particular transform.
    +
    +
    OPT_PERFECT - Static variable in class org.libjpegturbo.turbojpeg.TJTransform
    +
    +
    This option will cause TJTransformer.transform() to throw an exception if the transform is not + perfect.
    +
    +
    OPT_TRIM - Static variable in class org.libjpegturbo.turbojpeg.TJTransform
    +
    +
    This option will discard any partial MCU blocks that cannot be + transformed.
    +
    +
    options - Variable in class org.libjpegturbo.turbojpeg.TJTransform
    +
    +
    Transform options (bitwise OR of one or more of OPT_*)
    +
    +
    org.libjpegturbo.turbojpeg - package org.libjpegturbo.turbojpeg
    +
     
    +
    + + + +

    P

    +
    +
    PF_ABGR - Static variable in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    ABGR pixel format.
    +
    +
    PF_ARGB - Static variable in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    ARGB pixel format.
    +
    +
    PF_BGR - Static variable in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    BGR pixel format.
    +
    +
    PF_BGRA - Static variable in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    BGRA pixel format.
    +
    +
    PF_BGRX - Static variable in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    BGRX pixel format.
    +
    +
    PF_CMYK - Static variable in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    CMYK pixel format.
    +
    +
    PF_GRAY - Static variable in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    Grayscale pixel format.
    +
    +
    PF_RGB - Static variable in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    RGB pixel format.
    +
    +
    PF_RGBA - Static variable in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    RGBA pixel format.
    +
    +
    PF_RGBX - Static variable in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    RGBX pixel format.
    +
    +
    PF_XBGR - Static variable in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    XBGR pixel format.
    +
    +
    PF_XRGB - Static variable in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    XRGB pixel format.
    +
    +
    + + + +

    S

    +
    +
    SAMP_411 - Static variable in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    4:1:1 chrominance subsampling.
    +
    +
    SAMP_420 - Static variable in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    4:2:0 chrominance subsampling.
    +
    +
    SAMP_422 - Static variable in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    4:2:2 chrominance subsampling.
    +
    +
    SAMP_440 - Static variable in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    4:4:0 chrominance subsampling.
    +
    +
    SAMP_444 - Static variable in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    4:4:4 chrominance subsampling (no chrominance subsampling).
    +
    +
    SAMP_GRAY - Static variable in class org.libjpegturbo.turbojpeg.TJ
    +
    +
    Grayscale.
    +
    +
    setJPEGImage(byte[], int) - Method in class org.libjpegturbo.turbojpeg.TJDecompressor
    +
    +
    Deprecated. + +
    +
    +
    setJPEGQuality(int) - Method in class org.libjpegturbo.turbojpeg.TJCompressor
    +
    +
    Set the JPEG image quality level for subsequent compress operations.
    +
    +
    setSourceImage(byte[], int, int, int, int, int, int) - Method in class org.libjpegturbo.turbojpeg.TJCompressor
    +
    +
    Associate an uncompressed RGB, grayscale, or CMYK source image with this + compressor instance.
    +
    +
    setSourceImage(byte[], int, int, int, int) - Method in class org.libjpegturbo.turbojpeg.TJCompressor
    +
    + +
    +
    setSourceImage(BufferedImage, int, int, int, int) - Method in class org.libjpegturbo.turbojpeg.TJCompressor
    +
    +
    Associate an uncompressed RGB or grayscale source image with this + compressor instance.
    +
    +
    setSourceImage(YUVImage) - Method in class org.libjpegturbo.turbojpeg.TJCompressor
    +
    +
    Associate an uncompressed YUV planar source image with this compressor + instance.
    +
    +
    setSourceImage(byte[], int) - Method in class org.libjpegturbo.turbojpeg.TJDecompressor
    +
    +
    Associate the JPEG image of length imageSize bytes stored in + srcImage with this decompressor instance.
    +
    +
    setSourceImage(YUVImage) - Method in class org.libjpegturbo.turbojpeg.TJDecompressor
    +
    +
    Associate the specified YUV planar source image with this decompressor + instance.
    +
    +
    setSubsamp(int) - Method in class org.libjpegturbo.turbojpeg.TJCompressor
    +
    +
    Set the level of chrominance subsampling for subsequent compress/encode + operations.
    +
    +
    srcColorspace - Variable in class org.libjpegturbo.turbojpeg.TJDecompressor
    +
     
    +
    srcHeight - Variable in class org.libjpegturbo.turbojpeg.TJDecompressor
    +
     
    +
    srcSubsamp - Variable in class org.libjpegturbo.turbojpeg.TJDecompressor
    +
     
    +
    srcWidth - Variable in class org.libjpegturbo.turbojpeg.TJDecompressor
    +
     
    +
    + + + +

    T

    +
    +
    TJ - Class in org.libjpegturbo.turbojpeg
    +
    +
    TurboJPEG utility class (cannot be instantiated)
    +
    +
    TJ() - Constructor for class org.libjpegturbo.turbojpeg.TJ
    +
     
    +
    TJCompressor - Class in org.libjpegturbo.turbojpeg
    +
    +
    TurboJPEG compressor
    +
    +
    TJCompressor() - Constructor for class org.libjpegturbo.turbojpeg.TJCompressor
    +
    +
    Create a TurboJPEG compressor instance.
    +
    +
    TJCompressor(byte[], int, int, int, int, int, int) - Constructor for class org.libjpegturbo.turbojpeg.TJCompressor
    +
    +
    Create a TurboJPEG compressor instance and associate the uncompressed source image stored in srcImage with the newly created - instance. -
    TJCompressor(byte[], int, int, int, int) - -Constructor for class org.libjpegturbo.turbojpeg.TJCompressor -
    Deprecated. Use - TJCompressor.TJCompressor(byte[], int, int, int, int, int, int) instead. -
    TJCompressor(BufferedImage, int, int, int, int) - -Constructor for class org.libjpegturbo.turbojpeg.TJCompressor -
    Create a TurboJPEG compressor instance and associate the uncompressed + instance. +
    +
    TJCompressor(byte[], int, int, int, int) - Constructor for class org.libjpegturbo.turbojpeg.TJCompressor
    +
    + +
    +
    TJCompressor(BufferedImage, int, int, int, int) - Constructor for class org.libjpegturbo.turbojpeg.TJCompressor
    +
    +
    Create a TurboJPEG compressor instance and associate the uncompressed source image stored in srcImage with the newly created - instance. -
    TJCustomFilter - Interface in org.libjpegturbo.turbojpeg
    Custom filter callback interface
    TJDecompressor - Class in org.libjpegturbo.turbojpeg
    TurboJPEG decompressor
    TJDecompressor() - -Constructor for class org.libjpegturbo.turbojpeg.TJDecompressor -
    Create a TurboJPEG decompresssor instance. -
    TJDecompressor(byte[]) - -Constructor for class org.libjpegturbo.turbojpeg.TJDecompressor -
    Create a TurboJPEG decompressor instance and associate the JPEG source - image stored in jpegImage with the newly created instance. -
    TJDecompressor(byte[], int) - -Constructor for class org.libjpegturbo.turbojpeg.TJDecompressor -
    Create a TurboJPEG decompressor instance and associate the JPEG source + instance. +
    +
    TJCustomFilter - Interface in org.libjpegturbo.turbojpeg
    +
    +
    Custom filter callback interface
    +
    +
    TJDecompressor - Class in org.libjpegturbo.turbojpeg
    +
    +
    TurboJPEG decompressor
    +
    +
    TJDecompressor() - Constructor for class org.libjpegturbo.turbojpeg.TJDecompressor
    +
    +
    Create a TurboJPEG decompresssor instance.
    +
    +
    TJDecompressor(byte[]) - Constructor for class org.libjpegturbo.turbojpeg.TJDecompressor
    +
    +
    Create a TurboJPEG decompressor instance and associate the JPEG source + image stored in jpegImage with the newly created instance.
    +
    +
    TJDecompressor(byte[], int) - Constructor for class org.libjpegturbo.turbojpeg.TJDecompressor
    +
    +
    Create a TurboJPEG decompressor instance and associate the JPEG source image of length imageSize bytes stored in - jpegImage with the newly created instance. -
    TJDecompressor(YUVImage) - -Constructor for class org.libjpegturbo.turbojpeg.TJDecompressor -
    Create a TurboJPEG decompressor instance and associate the YUV planar + jpegImage with the newly created instance. +
    +
    TJDecompressor(YUVImage) - Constructor for class org.libjpegturbo.turbojpeg.TJDecompressor
    +
    +
    Create a TurboJPEG decompressor instance and associate the YUV planar source image stored in yuvImage with the newly created - instance. -
    TJScalingFactor - Class in org.libjpegturbo.turbojpeg
    Fractional scaling factor
    TJScalingFactor(int, int) - -Constructor for class org.libjpegturbo.turbojpeg.TJScalingFactor -
      -
    TJTransform - Class in org.libjpegturbo.turbojpeg
    Lossless transform parameters
    TJTransform() - -Constructor for class org.libjpegturbo.turbojpeg.TJTransform -
    Create a new lossless transform instance. -
    TJTransform(int, int, int, int, int, int, TJCustomFilter) - -Constructor for class org.libjpegturbo.turbojpeg.TJTransform -
    Create a new lossless transform instance with the given parameters. -
    TJTransform(Rectangle, int, int, TJCustomFilter) - -Constructor for class org.libjpegturbo.turbojpeg.TJTransform -
    Create a new lossless transform instance with the given parameters. -
    TJTransformer - Class in org.libjpegturbo.turbojpeg
    TurboJPEG lossless transformer
    TJTransformer() - -Constructor for class org.libjpegturbo.turbojpeg.TJTransformer -
    Create a TurboJPEG lossless transformer instance. -
    TJTransformer(byte[]) - -Constructor for class org.libjpegturbo.turbojpeg.TJTransformer -
    Create a TurboJPEG lossless transformer instance and associate the JPEG - image stored in jpegImage with the newly created instance. -
    TJTransformer(byte[], int) - -Constructor for class org.libjpegturbo.turbojpeg.TJTransformer -
    Create a TurboJPEG lossless transformer instance and associate the JPEG + instance. +
    +
    TJScalingFactor - Class in org.libjpegturbo.turbojpeg
    +
    +
    Fractional scaling factor
    +
    +
    TJScalingFactor(int, int) - Constructor for class org.libjpegturbo.turbojpeg.TJScalingFactor
    +
     
    +
    TJTransform - Class in org.libjpegturbo.turbojpeg
    +
    +
    Lossless transform parameters
    +
    +
    TJTransform() - Constructor for class org.libjpegturbo.turbojpeg.TJTransform
    +
    +
    Create a new lossless transform instance.
    +
    +
    TJTransform(int, int, int, int, int, int, TJCustomFilter) - Constructor for class org.libjpegturbo.turbojpeg.TJTransform
    +
    +
    Create a new lossless transform instance with the given parameters.
    +
    +
    TJTransform(Rectangle, int, int, TJCustomFilter) - Constructor for class org.libjpegturbo.turbojpeg.TJTransform
    +
    +
    Create a new lossless transform instance with the given parameters.
    +
    +
    TJTransformer - Class in org.libjpegturbo.turbojpeg
    +
    +
    TurboJPEG lossless transformer
    +
    +
    TJTransformer() - Constructor for class org.libjpegturbo.turbojpeg.TJTransformer
    +
    +
    Create a TurboJPEG lossless transformer instance.
    +
    +
    TJTransformer(byte[]) - Constructor for class org.libjpegturbo.turbojpeg.TJTransformer
    +
    +
    Create a TurboJPEG lossless transformer instance and associate the JPEG + image stored in jpegImage with the newly created instance.
    +
    +
    TJTransformer(byte[], int) - Constructor for class org.libjpegturbo.turbojpeg.TJTransformer
    +
    +
    Create a TurboJPEG lossless transformer instance and associate the JPEG image of length imageSize bytes stored in - jpegImage with the newly created instance. -
    transform(byte[][], TJTransform[], int) - -Method in class org.libjpegturbo.turbojpeg.TJTransformer -
    Losslessly transform the JPEG image associated with this transformer + jpegImage with the newly created instance. +
    +
    transform(byte[][], TJTransform[], int) - Method in class org.libjpegturbo.turbojpeg.TJTransformer
    +
    +
    Losslessly transform the JPEG image associated with this transformer instance into one or more JPEG images stored in the given destination - buffers. -
    transform(TJTransform[], int) - -Method in class org.libjpegturbo.turbojpeg.TJTransformer -
    Losslessly transform the JPEG image associated with this transformer - instance and return an array of TJDecompressor instances, each of - which has a transformed JPEG image associated with it. -
    -
    -

    -Y

    -
    -
    yuvBuf - -Variable in class org.libjpegturbo.turbojpeg.YUVImage -
      -
    yuvHeight - -Variable in class org.libjpegturbo.turbojpeg.YUVImage -
      -
    yuvImage - -Variable in class org.libjpegturbo.turbojpeg.TJDecompressor -
      -
    YUVImage - Class in org.libjpegturbo.turbojpeg
    This class encapsulates a YUV planar image buffer and the metadata - associated with it.
    YUVImage(int, int, int, int) - -Constructor for class org.libjpegturbo.turbojpeg.YUVImage -
    Create a YUVImage instance with a new image buffer. -
    YUVImage(byte[], int, int, int, int) - -Constructor for class org.libjpegturbo.turbojpeg.YUVImage -
    Create a YUVImage instance from an existing YUV planar image - buffer. -
    yuvPad - -Variable in class org.libjpegturbo.turbojpeg.YUVImage -
      -
    yuvSubsamp - -Variable in class org.libjpegturbo.turbojpeg.YUVImage -
      -
    yuvWidth - -Variable in class org.libjpegturbo.turbojpeg.YUVImage -
      -
    -
    -B C D E F G H I J N O P S T Y - + buffers. + +
    transform(TJTransform[], int) - Method in class org.libjpegturbo.turbojpeg.TJTransformer
    +
    +
    Losslessly transform the JPEG image associated with this transformer + instance and return an array of TJDecompressor instances, each of + which has a transformed JPEG image associated with it.
    +
    + + + + +

    Y

    +
    +
    yuvBuf - Variable in class org.libjpegturbo.turbojpeg.YUVImage
    +
     
    +
    yuvHeight - Variable in class org.libjpegturbo.turbojpeg.YUVImage
    +
     
    +
    yuvImage - Variable in class org.libjpegturbo.turbojpeg.TJDecompressor
    +
     
    +
    YUVImage - Class in org.libjpegturbo.turbojpeg
    +
    +
    This class encapsulates a YUV planar image buffer and the metadata + associated with it.
    +
    +
    YUVImage(int, int, int, int) - Constructor for class org.libjpegturbo.turbojpeg.YUVImage
    +
    +
    Create a YUVImage instance with a new image buffer.
    +
    +
    YUVImage(byte[], int, int, int, int) - Constructor for class org.libjpegturbo.turbojpeg.YUVImage
    +
    +
    Create a YUVImage instance from an existing YUV planar image + buffer.
    +
    +
    yuvPad - Variable in class org.libjpegturbo.turbojpeg.YUVImage
    +
     
    +
    yuvSubsamp - Variable in class org.libjpegturbo.turbojpeg.YUVImage
    +
     
    +
    yuvWidth - Variable in class org.libjpegturbo.turbojpeg.YUVImage
    +
     
    +
    +B C D E F G H I J N O P S T Y  - - - - - - - - - - - - -
    - -
    - + + + + + - -
    - - - + + diff --git a/java/doc/index.html b/java/doc/index.html index 356cd1d9..25a639d4 100644 --- a/java/doc/index.html +++ b/java/doc/index.html @@ -1,11 +1,9 @@ - - - - -Generated Documentation (Untitled) - - - - - - - - -<H2> -Frame Alert</H2> - -<P> -This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. -<BR> -Link to<A HREF="org/libjpegturbo/turbojpeg/package-summary.html">Non-frame version.</A> - - - + + + + + + +<noscript> +<div>JavaScript is disabled on your browser.</div> +</noscript> +<h2>Frame Alert</h2> +<p>This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to <a href="org/libjpegturbo/turbojpeg/package-summary.html">Non-frame version</a>.</p> + + + diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJ.html b/java/doc/org/libjpegturbo/turbojpeg/TJ.html index bad022e1..ee22e763 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/TJ.html +++ b/java/doc/org/libjpegturbo/turbojpeg/TJ.html @@ -1,809 +1,712 @@ - - - - -TJ - - - - - - - - - - - -
    - - +//--> + + - - - - - - - - - - - - - - - - -
    - -
    - + + +
    + + +
    + + + - -
    -

    - -org.libjpegturbo.turbojpeg -
    -Class TJ

    -
    -java.lang.Object
    -  extended by org.libjpegturbo.turbojpeg.TJ
    -
    -
    -
    -
    public final class TJ
    extends java.lang.Object
    - - -

    -TurboJPEG utility class (cannot be instantiated) -

    - -

    -


    - -

    +

    +
    org.libjpegturbo.turbojpeg
    +

    Class TJ

    +
    +
    +
      +
    • java.lang.Object
    • +
    • +
        +
      • org.libjpegturbo.turbojpeg.TJ
      • +
      +
    • +
    +
    +
      +
    • +
      +
      +
      public final class TJ
      +extends java.lang.Object
      +
      TurboJPEG utility class (cannot be instantiated)
      +
    • +
    +
    +
    +
      +
    • - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      -Field Summary
      -static intCS_CMYK - -
      -          CMYK colorspace.
      -static intCS_GRAY - -
      -          Grayscale colorspace.
      -static intCS_RGB - -
      -          RGB colorspace.
      -static intCS_YCbCr - -
      -          YCbCr colorspace.
      -static intCS_YCCK - -
      -          YCCK colorspace.
      -static intFLAG_ACCURATEDCT - -
      -          Use the most accurate DCT/IDCT algorithm available in the underlying - codec.
      -static intFLAG_BOTTOMUP - -
      -          The uncompressed source/destination image is stored in bottom-up (Windows, - OpenGL) order, not top-down (X11) order.
      -static intFLAG_FASTDCT - -
      -          Use the fastest DCT/IDCT algorithm available in the underlying codec.
      -static intFLAG_FASTUPSAMPLE - -
      -          When decompressing an image that was compressed using chrominance +
        +
      • + + +

        Field Summary

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        Fields 
        Modifier and TypeField and Description
        static intCS_CMYK +
        CMYK colorspace.
        +
        static intCS_GRAY +
        Grayscale colorspace.
        +
        static intCS_RGB +
        RGB colorspace.
        +
        static intCS_YCbCr +
        YCbCr colorspace.
        +
        static intCS_YCCK +
        YCCK colorspace.
        +
        static intFLAG_ACCURATEDCT +
        Use the most accurate DCT/IDCT algorithm available in the underlying + codec.
        +
        static intFLAG_BOTTOMUP +
        The uncompressed source/destination image is stored in bottom-up (Windows, + OpenGL) order, not top-down (X11) order.
        +
        static intFLAG_FASTDCT +
        Use the fastest DCT/IDCT algorithm available in the underlying codec.
        +
        static intFLAG_FASTUPSAMPLE +
        When decompressing an image that was compressed using chrominance subsampling, use the fastest chrominance upsampling algorithm available in - the underlying codec.
        -static intFLAG_FORCEMMX - -
        -          Deprecated. 
        -static intFLAG_FORCESSE - -
        -          Deprecated. 
        -static intFLAG_FORCESSE2 - -
        -          Deprecated. 
        -static intFLAG_FORCESSE3 - -
        -          Deprecated. 
        -static intNUMCS - -
        -          The number of JPEG colorspaces
        -static intNUMPF - -
        -          The number of pixel formats
        -static intNUMSAMP - -
        -          The number of chrominance subsampling options
        -static intPF_ABGR - -
        -          ABGR pixel format.
        -static intPF_ARGB - -
        -          ARGB pixel format.
        -static intPF_BGR - -
        -          BGR pixel format.
        -static intPF_BGRA - -
        -          BGRA pixel format.
        -static intPF_BGRX - -
        -          BGRX pixel format.
        -static intPF_CMYK - -
        -          CMYK pixel format.
        -static intPF_GRAY - -
        -          Grayscale pixel format.
        -static intPF_RGB - -
        -          RGB pixel format.
        -static intPF_RGBA - -
        -          RGBA pixel format.
        -static intPF_RGBX - -
        -          RGBX pixel format.
        -static intPF_XBGR - -
        -          XBGR pixel format.
        -static intPF_XRGB - -
        -          XRGB pixel format.
        -static intSAMP_411 - -
        -          4:1:1 chrominance subsampling.
        -static intSAMP_420 - -
        -          4:2:0 chrominance subsampling.
        -static intSAMP_422 - -
        -          4:2:2 chrominance subsampling.
        -static intSAMP_440 - -
        -          4:4:0 chrominance subsampling.
        -static intSAMP_444 - -
        -          4:4:4 chrominance subsampling (no chrominance subsampling).
        -static intSAMP_GRAY - -
        -          Grayscale.
        -  + the underlying codec. +
      static intFLAG_FORCEMMX +
      Deprecated. 
      +
      static intFLAG_FORCESSE +
      Deprecated. 
      +
      static intFLAG_FORCESSE2 +
      Deprecated. 
      +
      static intFLAG_FORCESSE3 +
      Deprecated. 
      +
      static intNUMCS +
      The number of JPEG colorspaces
      +
      static intNUMPF +
      The number of pixel formats
      +
      static intNUMSAMP +
      The number of chrominance subsampling options
      +
      static intPF_ABGR +
      ABGR pixel format.
      +
      static intPF_ARGB +
      ARGB pixel format.
      +
      static intPF_BGR +
      BGR pixel format.
      +
      static intPF_BGRA +
      BGRA pixel format.
      +
      static intPF_BGRX +
      BGRX pixel format.
      +
      static intPF_CMYK +
      CMYK pixel format.
      +
      static intPF_GRAY +
      Grayscale pixel format.
      +
      static intPF_RGB +
      RGB pixel format.
      +
      static intPF_RGBA +
      RGBA pixel format.
      +
      static intPF_RGBX +
      RGBX pixel format.
      +
      static intPF_XBGR +
      XBGR pixel format.
      +
      static intPF_XRGB +
      XRGB pixel format.
      +
      static intSAMP_411 +
      4:1:1 chrominance subsampling.
      +
      static intSAMP_420 +
      4:2:0 chrominance subsampling.
      +
      static intSAMP_422 +
      4:2:2 chrominance subsampling.
      +
      static intSAMP_440 +
      4:4:0 chrominance subsampling.
      +
      static intSAMP_444 +
      4:4:4 chrominance subsampling (no chrominance subsampling).
      +
      static intSAMP_GRAY +
      Grayscale.
      +
      +
    • +
    - - - - - - - - - -
    -Constructor Summary
    TJ() - -
    -           
    -  +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      TJ() 
      +
    • +
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -Method Summary
    -static intbufSize(int width, - int height, - int jpegSubsamp) - -
    -          Returns the maximum size of the buffer (in bytes) required to hold a JPEG - image with the given width, height, and level of chrominance subsampling.
    -static intbufSizeYUV(int width, - int height, - int subsamp) - -
    -          Deprecated. Use bufSizeYUV(int, int, int, int) instead.
    -static intbufSizeYUV(int width, - int pad, - int height, - int subsamp) - -
    -          Returns the size of the buffer (in bytes) required to hold a YUV planar - image with the given width, height, and level of chrominance subsampling.
    -static intgetBlueOffset(int pixelFormat) - -
    -          For the given pixel format, returns the number of bytes that the blue - component is offset from the start of the pixel.
    -static intgetGreenOffset(int pixelFormat) - -
    -          For the given pixel format, returns the number of bytes that the green - component is offset from the start of the pixel.
    -static intgetMCUHeight(int subsamp) - -
    -          Returns the MCU block height for the given level of chrominance - subsampling.
    -static intgetMCUWidth(int subsamp) - -
    -          Returns the MCU block width for the given level of chrominance - subsampling.
    -static intgetPixelSize(int pixelFormat) - -
    -          Returns the pixel size (in bytes) for the given pixel format.
    -static intgetRedOffset(int pixelFormat) - -
    -          For the given pixel format, returns the number of bytes that the red - component is offset from the start of the pixel.
    -static TJScalingFactor[]getScalingFactors() - -
    -          Returns a list of fractional scaling factors that the JPEG decompressor in - this implementation of TurboJPEG supports.
    - - - - - - - -
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    -  -

    - +

      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Methods 
      Modifier and TypeMethod and Description
      static intbufSize(int width, + int height, + int jpegSubsamp) +
      Returns the maximum size of the buffer (in bytes) required to hold a JPEG + image with the given width, height, and level of chrominance subsampling.
      +
      static intbufSizeYUV(int width, + int height, + int subsamp) +
      Deprecated.  + +
      +
      static intbufSizeYUV(int width, + int pad, + int height, + int subsamp) +
      Returns the size of the buffer (in bytes) required to hold a YUV planar + image with the given width, height, and level of chrominance subsampling.
      +
      static intgetBlueOffset(int pixelFormat) +
      For the given pixel format, returns the number of bytes that the blue + component is offset from the start of the pixel.
      +
      static intgetGreenOffset(int pixelFormat) +
      For the given pixel format, returns the number of bytes that the green + component is offset from the start of the pixel.
      +
      static intgetMCUHeight(int subsamp) +
      Returns the MCU block height for the given level of chrominance + subsampling.
      +
      static intgetMCUWidth(int subsamp) +
      Returns the MCU block width for the given level of chrominance + subsampling.
      +
      static intgetPixelSize(int pixelFormat) +
      Returns the pixel size (in bytes) for the given pixel format.
      +
      static intgetRedOffset(int pixelFormat) +
      For the given pixel format, returns the number of bytes that the red + component is offset from the start of the pixel.
      +
      static TJScalingFactor[]getScalingFactors() +
      Returns a list of fractional scaling factors that the JPEG decompressor in + this implementation of TurboJPEG supports.
      +
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • +
      +
    • +
    + + +
    +
    +
      +
    • - - - - - - -
      -Field Detail
      - -

      -NUMSAMP

      -
      -public static final int NUMSAMP
      -
      -
      The number of chrominance subsampling options -

      -

      -
      See Also:
      Constant Field Values
      -
      -
      - -

      -SAMP_444

      -
      -public static final int SAMP_444
      -
      -
      4:4:4 chrominance subsampling (no chrominance subsampling). The JPEG +
        +
      • + + +

        Field Detail

        + + + +
          +
        • +

          NUMSAMP

          +
          public static final int NUMSAMP
          +
          The number of chrominance subsampling options
          +
          See Also:
          Constant Field Values
          +
        • +
        + + + +
          +
        • +

          SAMP_444

          +
          public static final int SAMP_444
          +
          4:4:4 chrominance subsampling (no chrominance subsampling). The JPEG or YUV image will contain one chrominance component for every pixel in the - source image. -

          -

          -
          See Also:
          Constant Field Values
          -
      -
      - -

      -SAMP_422

      -
      -public static final int SAMP_422
      -
      -
      4:2:2 chrominance subsampling. The JPEG or YUV image will contain one - chrominance component for every 2x1 block of pixels in the source image. -

      -

      -
      See Also:
      Constant Field Values
      -
      -
      - -

      -SAMP_420

      -
      -public static final int SAMP_420
      -
      -
      4:2:0 chrominance subsampling. The JPEG or YUV image will contain one - chrominance component for every 2x2 block of pixels in the source image. -

      -

      -
      See Also:
      Constant Field Values
      -
      -
      - -

      -SAMP_GRAY

      -
      -public static final int SAMP_GRAY
      -
      -
      Grayscale. The JPEG or YUV image will contain no chrominance components. -

      -

      -
      See Also:
      Constant Field Values
      -
      -
      - -

      -SAMP_440

      -
      -public static final int SAMP_440
      -
      -
      4:4:0 chrominance subsampling. The JPEG or YUV image will contain one + source image.
    +
    See Also:
    Constant Field Values
    + + + + + +
      +
    • +

      SAMP_422

      +
      public static final int SAMP_422
      +
      4:2:2 chrominance subsampling. The JPEG or YUV image will contain one + chrominance component for every 2x1 block of pixels in the source image.
      +
      See Also:
      Constant Field Values
      +
    • +
    + + + +
      +
    • +

      SAMP_420

      +
      public static final int SAMP_420
      +
      4:2:0 chrominance subsampling. The JPEG or YUV image will contain one + chrominance component for every 2x2 block of pixels in the source image.
      +
      See Also:
      Constant Field Values
      +
    • +
    + + + +
      +
    • +

      SAMP_GRAY

      +
      public static final int SAMP_GRAY
      +
      Grayscale. The JPEG or YUV image will contain no chrominance components.
      +
      See Also:
      Constant Field Values
      +
    • +
    + + + +
      +
    • +

      SAMP_440

      +
      public static final int SAMP_440
      +
      4:4:0 chrominance subsampling. The JPEG or YUV image will contain one chrominance component for every 1x2 block of pixels in the source image. - Note that 4:4:0 subsampling is not fully accelerated in libjpeg-turbo. -

      -

      -
      See Also:
      Constant Field Values
      - -
      - -

      -SAMP_411

      -
      -public static final int SAMP_411
      -
      -
      4:1:1 chrominance subsampling. The JPEG or YUV image will contain one + Note that 4:4:0 subsampling is not fully accelerated in libjpeg-turbo.
      +
      See Also:
      Constant Field Values
      +
    • +
    + + + +
      +
    • +

      SAMP_411

      +
      public static final int SAMP_411
      +
      4:1:1 chrominance subsampling. The JPEG or YUV image will contain one chrominance component for every 4x1 block of pixels in the source image. JPEG images compressed with 4:1:1 subsampling will be almost exactly the same size as those compressed with 4:2:0 subsampling, and in the aggregate, both subsampling methods produce approximately the same perceptual quality. However, 4:1:1 is better able to reproduce sharp horizontal features. Note that 4:1:1 subsampling is not fully accelerated - in libjpeg-turbo. -

      -

      -
      See Also:
      Constant Field Values
      - -
      - -

      -NUMPF

      -
      -public static final int NUMPF
      -
      -
      The number of pixel formats -

      -

      -
      See Also:
      Constant Field Values
      -
      -
      - -

      -PF_RGB

      -
      -public static final int PF_RGB
      -
      -
      RGB pixel format. The red, green, and blue components in the image are + in libjpeg-turbo.
      +
      See Also:
      Constant Field Values
      +
    • +
    + + + +
      +
    • +

      NUMPF

      +
      public static final int NUMPF
      +
      The number of pixel formats
      +
      See Also:
      Constant Field Values
      +
    • +
    + + + +
      +
    • +

      PF_RGB

      +
      public static final int PF_RGB
      +
      RGB pixel format. The red, green, and blue components in the image are stored in 3-byte pixels in the order R, G, B from lowest to highest byte - address within each pixel. -

      -

      -
      See Also:
      Constant Field Values
      - -
      - -

      -PF_BGR

      -
      -public static final int PF_BGR
      -
      -
      BGR pixel format. The red, green, and blue components in the image are + address within each pixel.
      +
      See Also:
      Constant Field Values
      +
    • +
    + + + +
      +
    • +

      PF_BGR

      +
      public static final int PF_BGR
      +
      BGR pixel format. The red, green, and blue components in the image are stored in 3-byte pixels in the order B, G, R from lowest to highest byte - address within each pixel. -

      -

      -
      See Also:
      Constant Field Values
      - -
      - -

      -PF_RGBX

      -
      -public static final int PF_RGBX
      -
      -
      RGBX pixel format. The red, green, and blue components in the image are + address within each pixel.
      +
      See Also:
      Constant Field Values
      +
    • +
    + + + +
      +
    • +

      PF_RGBX

      +
      public static final int PF_RGBX
      +
      RGBX pixel format. The red, green, and blue components in the image are stored in 4-byte pixels in the order R, G, B from lowest to highest byte address within each pixel. The X component is ignored when compressing - and undefined when decompressing. -

      -

      -
      See Also:
      Constant Field Values
      - -
      - -

      -PF_BGRX

      -
      -public static final int PF_BGRX
      -
      -
      BGRX pixel format. The red, green, and blue components in the image are + and undefined when decompressing.
      +
      See Also:
      Constant Field Values
      +
    • +
    + + + +
      +
    • +

      PF_BGRX

      +
      public static final int PF_BGRX
      +
      BGRX pixel format. The red, green, and blue components in the image are stored in 4-byte pixels in the order B, G, R from lowest to highest byte address within each pixel. The X component is ignored when compressing - and undefined when decompressing. -

      -

      -
      See Also:
      Constant Field Values
      - -
      - -

      -PF_XBGR

      -
      -public static final int PF_XBGR
      -
      -
      XBGR pixel format. The red, green, and blue components in the image are + and undefined when decompressing.
      +
      See Also:
      Constant Field Values
      +
    • +
    + + + +
      +
    • +

      PF_XBGR

      +
      public static final int PF_XBGR
      +
      XBGR pixel format. The red, green, and blue components in the image are stored in 4-byte pixels in the order R, G, B from highest to lowest byte address within each pixel. The X component is ignored when compressing - and undefined when decompressing. -

      -

      -
      See Also:
      Constant Field Values
      - -
      - -

      -PF_XRGB

      -
      -public static final int PF_XRGB
      -
      -
      XRGB pixel format. The red, green, and blue components in the image are + and undefined when decompressing.
      +
      See Also:
      Constant Field Values
      +
    • +
    + + + +
      +
    • +

      PF_XRGB

      +
      public static final int PF_XRGB
      +
      XRGB pixel format. The red, green, and blue components in the image are stored in 4-byte pixels in the order B, G, R from highest to lowest byte address within each pixel. The X component is ignored when compressing - and undefined when decompressing. -

      -

      -
      See Also:
      Constant Field Values
      - -
      - -

      -PF_GRAY

      -
      -public static final int PF_GRAY
      -
      -
      Grayscale pixel format. Each 1-byte pixel represents a luminance - (brightness) level from 0 to 255. -

      -

      -
      See Also:
      Constant Field Values
      -
      -
      - -

      -PF_RGBA

      -
      -public static final int PF_RGBA
      -
      -
      RGBA pixel format. This is the same as PF_RGBX, except that when + and undefined when decompressing.
      +
      See Also:
      Constant Field Values
      +
    • +
    + + + +
      +
    • +

      PF_GRAY

      +
      public static final int PF_GRAY
      +
      Grayscale pixel format. Each 1-byte pixel represents a luminance + (brightness) level from 0 to 255.
      +
      See Also:
      Constant Field Values
      +
    • +
    + + + +
      +
    • +

      PF_RGBA

      +
      public static final int PF_RGBA
      +
      RGBA pixel format. This is the same as PF_RGBX, except that when decompressing, the X byte is guaranteed to be 0xFF, which can be - interpreted as an opaque alpha channel. -

      -

      -
      See Also:
      Constant Field Values
      - -
      - -

      -PF_BGRA

      -
      -public static final int PF_BGRA
      -
      -
      BGRA pixel format. This is the same as PF_BGRX, except that when + interpreted as an opaque alpha channel.
      +
      See Also:
      Constant Field Values
      +
    • +
    + + + +
      +
    • +

      PF_BGRA

      +
      public static final int PF_BGRA
      +
      BGRA pixel format. This is the same as PF_BGRX, except that when decompressing, the X byte is guaranteed to be 0xFF, which can be - interpreted as an opaque alpha channel. -

      -

      -
      See Also:
      Constant Field Values
      - -
      - -

      -PF_ABGR

      -
      -public static final int PF_ABGR
      -
      -
      ABGR pixel format. This is the same as PF_XBGR, except that when + interpreted as an opaque alpha channel.
      +
      See Also:
      Constant Field Values
      +
    • +
    + + + +
      +
    • +

      PF_ABGR

      +
      public static final int PF_ABGR
      +
      ABGR pixel format. This is the same as PF_XBGR, except that when decompressing, the X byte is guaranteed to be 0xFF, which can be - interpreted as an opaque alpha channel. -

      -

      -
      See Also:
      Constant Field Values
      - -
      - -

      -PF_ARGB

      -
      -public static final int PF_ARGB
      -
      -
      ARGB pixel format. This is the same as PF_XRGB, except that when + interpreted as an opaque alpha channel.
      +
      See Also:
      Constant Field Values
      +
    • +
    + + + +
      +
    • +

      PF_ARGB

      +
      public static final int PF_ARGB
      +
      ARGB pixel format. This is the same as PF_XRGB, except that when decompressing, the X byte is guaranteed to be 0xFF, which can be - interpreted as an opaque alpha channel. -

      -

      -
      See Also:
      Constant Field Values
      - -
      - -

      -PF_CMYK

      -
      -public static final int PF_CMYK
      -
      -
      CMYK pixel format. Unlike RGB, which is an additive color model used + interpreted as an opaque alpha channel.
      +
      See Also:
      Constant Field Values
      +
    • +
    + + + +
      +
    • +

      PF_CMYK

      +
      public static final int PF_CMYK
      +
      CMYK pixel format. Unlike RGB, which is an additive color model used primarily for display, CMYK (Cyan/Magenta/Yellow/Key) is a subtractive color model used primarily for printing. In the CMYK color model, the value of each color component typically corresponds to an amount of cyan, @@ -814,48 +717,45 @@ public static final int PF_CMYK vice versa, but the mapping is typically not 1:1 or reversible, nor can it be defined with a simple formula. Thus, such a conversion is out of scope for a codec library. However, the TurboJPEG API allows for compressing - CMYK pixels into a YCCK JPEG image (see CS_YCCK) and - decompressing YCCK JPEG images into CMYK pixels. -

      -

      -
      See Also:
      Constant Field Values
      - -
      - -

      -NUMCS

      -
      -public static final int NUMCS
      -
      -
      The number of JPEG colorspaces -

      -

      -
      See Also:
      Constant Field Values
      -
      -
      - -

      -CS_RGB

      -
      -public static final int CS_RGB
      -
      -
      RGB colorspace. When compressing the JPEG image, the R, G, and B + CMYK pixels into a YCCK JPEG image (see CS_YCCK) and + decompressing YCCK JPEG images into CMYK pixels.
      +
      See Also:
      Constant Field Values
      +
    • +
    + + + +
      +
    • +

      NUMCS

      +
      public static final int NUMCS
      +
      The number of JPEG colorspaces
      +
      See Also:
      Constant Field Values
      +
    • +
    + + + +
      +
    • +

      CS_RGB

      +
      public static final int CS_RGB
      +
      RGB colorspace. When compressing the JPEG image, the R, G, and B components in the source image are reordered into image planes, but no colorspace conversion or subsampling is performed. RGB JPEG images can be decompressed to any of the extended RGB pixel formats or grayscale, but - they cannot be decompressed to YUV images. -

      -

      -
      See Also:
      Constant Field Values
      - -
      - -

      -CS_YCbCr

      -
      -public static final int CS_YCbCr
      -
      -
      YCbCr colorspace. YCbCr is not an absolute colorspace but rather a + they cannot be decompressed to YUV images.
      +
      See Also:
      Constant Field Values
      +
    • +
    + + + +
      +
    • +

      CS_YCbCr

      +
      public static final int CS_YCbCr
      +
      YCbCr colorspace. YCbCr is not an absolute colorspace but rather a mathematical transformation of RGB designed solely for storage and transmission. YCbCr images must be converted to RGB before they can actually be displayed. In the YCbCr colorspace, the Y (luminance) @@ -867,457 +767,435 @@ public static final int CS_YCbCr optionally subsampled for the purposes of reducing bandwidth or disk space. YCbCr is the most common JPEG colorspace, and YCbCr JPEG images can be compressed from and decompressed to any of the extended RGB pixel - formats or grayscale, or they can be decompressed to YUV planar images. -

      -

      -
      See Also:
      Constant Field Values
      - -
      - -

      -CS_GRAY

      -
      -public static final int CS_GRAY
      -
      -
      Grayscale colorspace. The JPEG image retains only the luminance data (Y + formats or grayscale, or they can be decompressed to YUV planar images.
      +
      See Also:
      Constant Field Values
      +
    • +
    + + + +
      +
    • +

      CS_GRAY

      +
      public static final int CS_GRAY
      +
      Grayscale colorspace. The JPEG image retains only the luminance data (Y component), and any color data from the source image is discarded. Grayscale JPEG images can be compressed from and decompressed to any of the extended RGB pixel formats or grayscale, or they can be decompressed - to YUV planar images. -

      -

      -
      See Also:
      Constant Field Values
      - -
      - -

      -CS_CMYK

      -
      -public static final int CS_CMYK
      -
      -
      CMYK colorspace. When compressing the JPEG image, the C, M, Y, and K + to YUV planar images.
      +
      See Also:
      Constant Field Values
      +
    • +
    + + + +
      +
    • +

      CS_CMYK

      +
      public static final int CS_CMYK
      +
      CMYK colorspace. When compressing the JPEG image, the C, M, Y, and K components in the source image are reordered into image planes, but no colorspace conversion or subsampling is performed. CMYK JPEG images can - only be decompressed to CMYK pixels. -

      -

      -
      See Also:
      Constant Field Values
      - -
      - -

      -CS_YCCK

      -
      -public static final int CS_YCCK
      -
      -
      YCCK colorspace. YCCK (AKA "YCbCrK") is not an absolute colorspace but + only be decompressed to CMYK pixels.
      +
      See Also:
      Constant Field Values
      +
    • +
    + + + +
      +
    • +

      CS_YCCK

      +
      public static final int CS_YCCK
      +
      YCCK colorspace. YCCK (AKA "YCbCrK") is not an absolute colorspace but rather a mathematical transformation of CMYK designed solely for storage and transmission. It is to CMYK as YCbCr is to RGB. CMYK pixels can be reversibly transformed into YCCK, and as with YCbCr, the chrominance components in the YCCK pixels can be subsampled without incurring major perceptual loss. YCCK JPEG images can only be compressed from and - decompressed to CMYK pixels. -

      -

      -
      See Also:
      Constant Field Values
      - -
      - -

      -FLAG_BOTTOMUP

      -
      -public static final int FLAG_BOTTOMUP
      -
      -
      The uncompressed source/destination image is stored in bottom-up (Windows, - OpenGL) order, not top-down (X11) order. -

      -

      -
      See Also:
      Constant Field Values
      -
      -
      - -

      -FLAG_FORCEMMX

      -
      -@Deprecated
      -public static final int FLAG_FORCEMMX
      -
      -
      Deprecated. 
      -
      See Also:
      Constant Field Values
      -
      -
      - -

      -FLAG_FORCESSE

      -
      -@Deprecated
      -public static final int FLAG_FORCESSE
      -
      -
      Deprecated. 
      -
      See Also:
      Constant Field Values
      -
      -
      - -

      -FLAG_FORCESSE2

      -
      -@Deprecated
      -public static final int FLAG_FORCESSE2
      -
      -
      Deprecated. 
      -
      See Also:
      Constant Field Values
      -
      -
      - -

      -FLAG_FORCESSE3

      -
      -@Deprecated
      -public static final int FLAG_FORCESSE3
      -
      -
      Deprecated. 
      -
      See Also:
      Constant Field Values
      -
      -
      - -

      -FLAG_FASTUPSAMPLE

      -
      -public static final int FLAG_FASTUPSAMPLE
      -
      -
      When decompressing an image that was compressed using chrominance + decompressed to CMYK pixels.
      +
      See Also:
      Constant Field Values
      +
    • +
    + + + +
      +
    • +

      FLAG_BOTTOMUP

      +
      public static final int FLAG_BOTTOMUP
      +
      The uncompressed source/destination image is stored in bottom-up (Windows, + OpenGL) order, not top-down (X11) order.
      +
      See Also:
      Constant Field Values
      +
    • +
    + + + +
      +
    • +

      FLAG_FORCEMMX

      +
      @Deprecated
      +public static final int FLAG_FORCEMMX
      +
      Deprecated. 
      +
      See Also:
      Constant Field Values
      +
    • +
    + + + +
      +
    • +

      FLAG_FORCESSE

      +
      @Deprecated
      +public static final int FLAG_FORCESSE
      +
      Deprecated. 
      +
      See Also:
      Constant Field Values
      +
    • +
    + + + +
      +
    • +

      FLAG_FORCESSE2

      +
      @Deprecated
      +public static final int FLAG_FORCESSE2
      +
      Deprecated. 
      +
      See Also:
      Constant Field Values
      +
    • +
    + + + +
      +
    • +

      FLAG_FORCESSE3

      +
      @Deprecated
      +public static final int FLAG_FORCESSE3
      +
      Deprecated. 
      +
      See Also:
      Constant Field Values
      +
    • +
    + + + +
      +
    • +

      FLAG_FASTUPSAMPLE

      +
      public static final int FLAG_FASTUPSAMPLE
      +
      When decompressing an image that was compressed using chrominance subsampling, use the fastest chrominance upsampling algorithm available in the underlying codec. The default is to use smooth upsampling, which creates a smooth transition between neighboring chrominance components in - order to reduce upsampling artifacts in the decompressed image. -

      -

      -
      See Also:
      Constant Field Values
      - -
      - -

      -FLAG_FASTDCT

      -
      -public static final int FLAG_FASTDCT
      -
      -
      Use the fastest DCT/IDCT algorithm available in the underlying codec. The + order to reduce upsampling artifacts in the decompressed image.
      +
      See Also:
      Constant Field Values
      +
    • +
    + + + +
      +
    • +

      FLAG_FASTDCT

      +
      public static final int FLAG_FASTDCT
      +
      Use the fastest DCT/IDCT algorithm available in the underlying codec. The default if this flag is not specified is implementation-specific. For example, the implementation of TurboJPEG for libjpeg[-turbo] uses the fast algorithm by default when compressing, because this has been shown to have only a very slight effect on accuracy, but it uses the accurate algorithm - when decompressing, because this has been shown to have a larger effect. -

      -

      -
      See Also:
      Constant Field Values
      - -
      - -

      -FLAG_ACCURATEDCT

      -
      -public static final int FLAG_ACCURATEDCT
      -
      -
      Use the most accurate DCT/IDCT algorithm available in the underlying + when decompressing, because this has been shown to have a larger effect.
      +
      See Also:
      Constant Field Values
      +
    • +
    + + + +
      +
    • +

      FLAG_ACCURATEDCT

      +
      public static final int FLAG_ACCURATEDCT
      +
      Use the most accurate DCT/IDCT algorithm available in the underlying codec. The default if this flag is not specified is implementation-specific. For example, the implementation of TurboJPEG for libjpeg[-turbo] uses the fast algorithm by default when compressing, because this has been shown to have only a very slight effect on accuracy, but it uses the accurate algorithm when decompressing, because this has - been shown to have a larger effect. -

      -

      -
      See Also:
      Constant Field Values
      - - + been shown to have a larger effect.
      +
      See Also:
      Constant Field Values
      +
    • +
    + + - - - - - - -
    -Constructor Detail
    - -

    -TJ

    -
    -public TJ()
    -
    -
    - +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        TJ

        +
        public TJ()
        +
      • +
      +
    • +
    - - - - - - -
    -Method Detail
    - -

    -getMCUWidth

    -
    -public static int getMCUWidth(int subsamp)
    -                       throws java.lang.Exception
    -
    -
    Returns the MCU block width for the given level of chrominance - subsampling. -

    -

    -
    Parameters:
    subsamp - the level of chrominance subsampling (one of - SAMP_*) -
    Returns:
    the MCU block width for the given level of chrominance subsampling -
    Throws: -
    java.lang.Exception
    -
    -
    -
    - -

    -getMCUHeight

    -
    -public static int getMCUHeight(int subsamp)
    -                        throws java.lang.Exception
    -
    -
    Returns the MCU block height for the given level of chrominance - subsampling. -

    -

    -
    Parameters:
    subsamp - the level of chrominance subsampling (one of - SAMP_*) -
    Returns:
    the MCU block height for the given level of chrominance - subsampling -
    Throws: -
    java.lang.Exception
    -
    -
    -
    - -

    -getPixelSize

    -
    -public static int getPixelSize(int pixelFormat)
    -                        throws java.lang.Exception
    -
    -
    Returns the pixel size (in bytes) for the given pixel format. -

    -

    -
    Parameters:
    pixelFormat - the pixel format (one of PF_*) -
    Returns:
    the pixel size (in bytes) for the given pixel format -
    Throws: -
    java.lang.Exception
    -
    -
    -
    - -

    -getRedOffset

    -
    -public static int getRedOffset(int pixelFormat)
    -                        throws java.lang.Exception
    -
    -
    For the given pixel format, returns the number of bytes that the red +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getMCUWidth

        +
        public static int getMCUWidth(int subsamp)
        +                       throws java.lang.Exception
        +
        Returns the MCU block width for the given level of chrominance + subsampling.
        +
        Parameters:
        subsamp - the level of chrominance subsampling (one of + SAMP_*)
        +
        Returns:
        the MCU block width for the given level of chrominance subsampling
        +
        Throws:
        +
        java.lang.Exception
        +
      • +
      + + + +
        +
      • +

        getMCUHeight

        +
        public static int getMCUHeight(int subsamp)
        +                        throws java.lang.Exception
        +
        Returns the MCU block height for the given level of chrominance + subsampling.
        +
        Parameters:
        subsamp - the level of chrominance subsampling (one of + SAMP_*)
        +
        Returns:
        the MCU block height for the given level of chrominance + subsampling
        +
        Throws:
        +
        java.lang.Exception
        +
      • +
      + + + +
        +
      • +

        getPixelSize

        +
        public static int getPixelSize(int pixelFormat)
        +                        throws java.lang.Exception
        +
        Returns the pixel size (in bytes) for the given pixel format.
        +
        Parameters:
        pixelFormat - the pixel format (one of PF_*)
        +
        Returns:
        the pixel size (in bytes) for the given pixel format
        +
        Throws:
        +
        java.lang.Exception
        +
      • +
      + + + +
        +
      • +

        getRedOffset

        +
        public static int getRedOffset(int pixelFormat)
        +                        throws java.lang.Exception
        +
        For the given pixel format, returns the number of bytes that the red component is offset from the start of the pixel. For instance, if a pixel of format TJ.PF_BGRX is stored in char pixel[], then the red component will be - pixel[TJ.getRedOffset(TJ.PF_BGRX)]. -

        -

        -
        Parameters:
        pixelFormat - the pixel format (one of PF_*) -
        Returns:
        the red offset for the given pixel format -
        Throws: -
        java.lang.Exception
        -
        -
    -
    - -

    -getGreenOffset

    -
    -public static int getGreenOffset(int pixelFormat)
    -                          throws java.lang.Exception
    -
    -
    For the given pixel format, returns the number of bytes that the green + pixel[TJ.getRedOffset(TJ.PF_BGRX)].
    +
    Parameters:
    pixelFormat - the pixel format (one of PF_*)
    +
    Returns:
    the red offset for the given pixel format
    +
    Throws:
    +
    java.lang.Exception
    + + + + + +
      +
    • +

      getGreenOffset

      +
      public static int getGreenOffset(int pixelFormat)
      +                          throws java.lang.Exception
      +
      For the given pixel format, returns the number of bytes that the green component is offset from the start of the pixel. For instance, if a pixel of format TJ.PF_BGRX is stored in char pixel[], then the green component will be - pixel[TJ.getGreenOffset(TJ.PF_BGRX)]. -

      -

      -
      Parameters:
      pixelFormat - the pixel format (one of PF_*) -
      Returns:
      the green offset for the given pixel format -
      Throws: -
      java.lang.Exception
      -
      - -
      - -

      -getBlueOffset

      -
      -public static int getBlueOffset(int pixelFormat)
      -                         throws java.lang.Exception
      -
      -
      For the given pixel format, returns the number of bytes that the blue + pixel[TJ.getGreenOffset(TJ.PF_BGRX)].
      +
      Parameters:
      pixelFormat - the pixel format (one of PF_*)
      +
      Returns:
      the green offset for the given pixel format
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + +
      +
    • +

      getBlueOffset

      +
      public static int getBlueOffset(int pixelFormat)
      +                         throws java.lang.Exception
      +
      For the given pixel format, returns the number of bytes that the blue component is offset from the start of the pixel. For instance, if a pixel of format TJ.PF_BGRX is stored in char pixel[], then the blue component will be - pixel[TJ.getBlueOffset(TJ.PF_BGRX)]. -

      -

      -
      Parameters:
      pixelFormat - the pixel format (one of PF_*) -
      Returns:
      the blue offset for the given pixel format -
      Throws: -
      java.lang.Exception
      -
      - -
      - -

      -bufSize

      -
      -public static int bufSize(int width,
      -                          int height,
      -                          int jpegSubsamp)
      -                   throws java.lang.Exception
      -
      -
      Returns the maximum size of the buffer (in bytes) required to hold a JPEG - image with the given width, height, and level of chrominance subsampling. -

      -

      -
      Parameters:
      width - the width (in pixels) of the JPEG image
      height - the height (in pixels) of the JPEG image
      jpegSubsamp - the level of chrominance subsampling to be used when - generating the JPEG image (one of TJ.SAMP_*) -
      Returns:
      the maximum size of the buffer (in bytes) required to hold a JPEG - image with the given width, height, and level of chrominance subsampling -
      Throws: -
      java.lang.Exception
      -
      -
      -
      - -

      -bufSizeYUV

      -
      -public static int bufSizeYUV(int width,
      -                             int pad,
      -                             int height,
      -                             int subsamp)
      -                      throws java.lang.Exception
      -
      -
      Returns the size of the buffer (in bytes) required to hold a YUV planar - image with the given width, height, and level of chrominance subsampling. -

      -

      -
      Parameters:
      width - the width (in pixels) of the YUV image
      pad - the width of each line in each plane of the image is padded to + pixel[TJ.getBlueOffset(TJ.PF_BGRX)].
      +
      Parameters:
      pixelFormat - the pixel format (one of PF_*)
      +
      Returns:
      the blue offset for the given pixel format
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + +
      +
    • +

      bufSize

      +
      public static int bufSize(int width,
      +          int height,
      +          int jpegSubsamp)
      +                   throws java.lang.Exception
      +
      Returns the maximum size of the buffer (in bytes) required to hold a JPEG + image with the given width, height, and level of chrominance subsampling.
      +
      Parameters:
      width - the width (in pixels) of the JPEG image
      height - the height (in pixels) of the JPEG image
      jpegSubsamp - the level of chrominance subsampling to be used when + generating the JPEG image (one of TJ.SAMP_*)
      +
      Returns:
      the maximum size of the buffer (in bytes) required to hold a JPEG + image with the given width, height, and level of chrominance subsampling
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + +
      +
    • +

      bufSizeYUV

      +
      public static int bufSizeYUV(int width,
      +             int pad,
      +             int height,
      +             int subsamp)
      +                      throws java.lang.Exception
      +
      Returns the size of the buffer (in bytes) required to hold a YUV planar + image with the given width, height, and level of chrominance subsampling.
      +
      Parameters:
      width - the width (in pixels) of the YUV image
      pad - the width of each line in each plane of the image is padded to the nearest multiple of this number of bytes (must be a power of - 2.)
      height - the height (in pixels) of the YUV image
      subsamp - the level of chrominance subsampling used in the YUV - image (one of TJ.SAMP_*) -
      Returns:
      the size of the buffer (in bytes) required to hold a YUV planar - image with the given width, height, and level of chrominance subsampling -
      Throws: -
      java.lang.Exception
      - - -
      - -

      -bufSizeYUV

      -
      -@Deprecated
      -public static int bufSizeYUV(int width,
      -                                        int height,
      -                                        int subsamp)
      -                      throws java.lang.Exception
      -
      -
      Deprecated. Use bufSizeYUV(int, int, int, int) instead. -

      -

      - -
      Throws: -
      java.lang.Exception
      -
      -
      -
      - -

      -getScalingFactors

      -
      -public static TJScalingFactor[] getScalingFactors()
      -                                           throws java.lang.Exception
      -
      -
      Returns a list of fractional scaling factors that the JPEG decompressor in - this implementation of TurboJPEG supports. -

      -

      - -
      Returns:
      a list of fractional scaling factors that the JPEG decompressor in - this implementation of TurboJPEG supports -
      Throws: -
      java.lang.Exception
      -
      -
      + 2.)
      height - the height (in pixels) of the YUV image
      subsamp - the level of chrominance subsampling used in the YUV + image (one of TJ.SAMP_*)
      +
      Returns:
      the size of the buffer (in bytes) required to hold a YUV planar + image with the given width, height, and level of chrominance subsampling
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + +
      +
    • +

      bufSizeYUV

      +
      @Deprecated
      +public static int bufSizeYUV(int width,
      +                        int height,
      +                        int subsamp)
      +                      throws java.lang.Exception
      +
      Deprecated. Use bufSizeYUV(int, int, int, int) instead.
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + +
      +
    • +

      getScalingFactors

      +
      public static TJScalingFactor[] getScalingFactors()
      +                                           throws java.lang.Exception
      +
      Returns a list of fractional scaling factors that the JPEG decompressor in + this implementation of TurboJPEG supports.
      +
      Returns:
      a list of fractional scaling factors that the JPEG decompressor in + this implementation of TurboJPEG supports
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + + + + -
    - - - - - - - - - - - - - - - - - - -
    - -
    - + + +
    + + +
    + + + - -
    - - - + + diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJCompressor.html b/java/doc/org/libjpegturbo/turbojpeg/TJCompressor.html index 3c24544b..6c367a70 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/TJCompressor.html +++ b/java/doc/org/libjpegturbo/turbojpeg/TJCompressor.html @@ -1,597 +1,558 @@ - - - - -TJCompressor - - - - - - - - - - - -
    - - +//--> + + - - - - - - - - - - - - - - - - -
    - -
    - + + +
    + + +
    + + + - -
    -

    - -org.libjpegturbo.turbojpeg -
    -Class TJCompressor

    -
    -java.lang.Object
    -  extended by org.libjpegturbo.turbojpeg.TJCompressor
    -
    -
    -
    -
    public class TJCompressor
    extends java.lang.Object
    - - -

    -TurboJPEG compressor -

    - -

    -


    - -

    - +

    +
    org.libjpegturbo.turbojpeg
    +

    Class TJCompressor

    +
    +
    +
      +
    • java.lang.Object
    • +
    • +
        +
      • org.libjpegturbo.turbojpeg.TJCompressor
      • +
      +
    • +
    +
    +
      +
    • +
      +
      +
      public class TJCompressor
      +extends java.lang.Object
      +
      TurboJPEG compressor
      +
    • +
    +
    +
    +
      +
    • - - - - - - - - - - - + +
      -Constructor Summary
      TJCompressor() - -
      -          Create a TurboJPEG compressor instance.
      TJCompressor(java.awt.image.BufferedImage srcImage, - int x, - int y, - int width, - int height) - -
      -          Create a TurboJPEG compressor instance and associate the uncompressed +
        +
      • + + +

        Constructor Summary

        + + + + + + + + + + - - - - - - + + + + + + - -
        Constructors 
        Constructor and Description
        TJCompressor() +
        Create a TurboJPEG compressor instance.
        +
        TJCompressor(java.awt.image.BufferedImage srcImage, + int x, + int y, + int width, + int height) +
        Create a TurboJPEG compressor instance and associate the uncompressed source image stored in srcImage with the newly created - instance.
        TJCompressor(byte[] srcImage, - int width, - int pitch, - int height, - int pixelFormat) - -
        -          Deprecated. Use - TJCompressor(byte[], int, int, int, int, int, int) instead.
        TJCompressor(byte[] srcImage, - int x, - int y, - int width, - int pitch, - int height, - int pixelFormat) - -
        -          Create a TurboJPEG compressor instance and associate the uncompressed + instance. +
        TJCompressor(byte[] srcImage, + int width, + int pitch, + int height, + int pixelFormat) + +
        TJCompressor(byte[] srcImage, + int x, + int y, + int width, + int pitch, + int height, + int pixelFormat) +
        Create a TurboJPEG compressor instance and associate the uncompressed source image stored in srcImage with the newly created - instance.
        -  + instance. +
      +
    • +
    - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    -Method Summary
    - voidclose() - -
    -          Free the native structures associated with this compressor instance.
    - voidcompress(java.awt.image.BufferedImage srcImage, +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      Methods 
      Modifier and TypeMethod and Description
      voidclose() +
      Free the native structures associated with this compressor instance.
      +
      voidcompress(java.awt.image.BufferedImage srcImage, + byte[] dstBuf, + int flags) + +
      byte[]compress(java.awt.image.BufferedImage srcImage, + int flags) + +
      voidcompress(byte[] dstBuf, + int flags) +
      Compress the uncompressed source image associated with this compressor + instance and output a JPEG image to the given destination buffer.
      +
      byte[]compress(int flags) +
      Compress the uncompressed source image associated with this compressor + instance and return a buffer containing a JPEG image.
      +
      voidencodeYUV(java.awt.image.BufferedImage srcImage, byte[] dstBuf, - int flags) - -
      -          Deprecated. Use - setSourceImage(BufferedImage, int, int, int, int) and - compress(byte[], int) instead.
      - byte[]compress(java.awt.image.BufferedImage srcImage, - int flags) - -
      -          Deprecated. Use - setSourceImage(BufferedImage, int, int, int, int) and - compress(int) instead.
      - voidcompress(byte[] dstBuf, - int flags) - -
      -          Compress the uncompressed source image associated with this compressor - instance and output a JPEG image to the given destination buffer.
      - byte[]compress(int flags) - -
      -          Compress the uncompressed source image associated with this compressor - instance and return a buffer containing a JPEG image.
      - voidencodeYUV(java.awt.image.BufferedImage srcImage, - byte[] dstBuf, - int flags) - -
      -          Deprecated. Use - setSourceImage(BufferedImage, int, int, int, int) and - encodeYUV(byte[], int) instead.
      - byte[]encodeYUV(java.awt.image.BufferedImage srcImage, - int flags) - -
      -          Deprecated. Use - setSourceImage(BufferedImage, int, int, int, int) and - encodeYUV(int) instead.
      - voidencodeYUV(byte[] dstBuf, - int flags) - -
      -          Deprecated. Use encodeYUV(YUVImage, int) instead.
      - byte[]encodeYUV(int flags) - -
      -          Deprecated. Use encodeYUV(int, int) instead.
      - YUVImageencodeYUV(int pad, - int flags) - -
      -          Encode the uncompressed source image associated with this compressor + int flags) + +
      byte[]encodeYUV(java.awt.image.BufferedImage srcImage, + int flags) + +
      voidencodeYUV(byte[] dstBuf, + int flags) +
      Deprecated.  + +
      +
      byte[]encodeYUV(int flags) +
      Deprecated.  +
      Use encodeYUV(int, int) instead.
      +
      +
      YUVImageencodeYUV(int pad, + int flags) +
      Encode the uncompressed source image associated with this compressor instance into a YUV planar image and return a YUVImage - instance containing the encoded image.
      - voidencodeYUV(YUVImage dstImage, - int flags) - -
      -          Encode the uncompressed source image associated with this compressor + instance containing the encoded image. +
      voidencodeYUV(YUVImage dstImage, + int flags) +
      Encode the uncompressed source image associated with this compressor instance into a YUV planar image and store it in the given - YUVImage instance.
      -protected  voidfinalize() - -
      -           
      - intgetCompressedSize() - -
      -          Returns the size of the image (in bytes) generated by the most recent - compress/encode operation.
      - voidsetJPEGQuality(int quality) - -
      -          Set the JPEG image quality level for subsequent compress operations.
      - voidsetSourceImage(java.awt.image.BufferedImage srcImage, - int x, - int y, - int width, - int height) - -
      -          Associate an uncompressed RGB or grayscale source image with this - compressor instance.
      - voidsetSourceImage(byte[] srcImage, - int width, - int pitch, - int height, - int pixelFormat) - -
      -          Deprecated. Use - setSourceImage(byte[], int, int, int, int, int, int) instead.
      - voidsetSourceImage(byte[] srcImage, - int x, - int y, - int width, - int pitch, - int height, - int pixelFormat) - -
      -          Associate an uncompressed RGB, grayscale, or CMYK source image with this - compressor instance.
      - voidsetSourceImage(YUVImage srcImage) - -
      -          Associate an uncompressed YUV planar source image with this compressor - instance.
      - voidsetSubsamp(int newSubsamp) - -
      -          Set the level of chrominance subsampling for subsequent compress/encode - operations.
      - - - - - - - -
      Methods inherited from class java.lang.Object
      clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      -  -

      - + YUVImage instance. +

    protected voidfinalize() 
    intgetCompressedSize() +
    Returns the size of the image (in bytes) generated by the most recent + compress/encode operation.
    +
    voidsetJPEGQuality(int quality) +
    Set the JPEG image quality level for subsequent compress operations.
    +
    voidsetSourceImage(java.awt.image.BufferedImage srcImage, + int x, + int y, + int width, + int height) +
    Associate an uncompressed RGB or grayscale source image with this + compressor instance.
    +
    voidsetSourceImage(byte[] srcImage, + int width, + int pitch, + int height, + int pixelFormat) + +
    voidsetSourceImage(byte[] srcImage, + int x, + int y, + int width, + int pitch, + int height, + int pixelFormat) +
    Associate an uncompressed RGB, grayscale, or CMYK source image with this + compressor instance.
    +
    voidsetSourceImage(YUVImage srcImage) +
    Associate an uncompressed YUV planar source image with this compressor + instance.
    +
    voidsetSubsamp(int newSubsamp) +
    Set the level of chrominance subsampling for subsequent compress/encode + operations.
    +
    +
      +
    • + + +

      Methods inherited from class java.lang.Object

      +clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • +
    + + + + +
    +
    +
      +
    • - - - - - - -
      -Constructor Detail
      - -

      -TJCompressor

      -
      -public TJCompressor()
      -             throws java.lang.Exception
      -
      -
      Create a TurboJPEG compressor instance. -

      -

      - -
      Throws: -
      java.lang.Exception
      -
      -
      - -

      -TJCompressor

      -
      -public TJCompressor(byte[] srcImage,
      -                    int x,
      -                    int y,
      -                    int width,
      -                    int pitch,
      -                    int height,
      -                    int pixelFormat)
      -             throws java.lang.Exception
      -
      -
      Create a TurboJPEG compressor instance and associate the uncompressed +
      -
      - -

      -TJCompressor

      -
      -@Deprecated
      -public TJCompressor(byte[] srcImage,
      -                               int width,
      -                               int pitch,
      -                               int height,
      -                               int pixelFormat)
      -             throws java.lang.Exception
      -
      -
      Deprecated. Use - TJCompressor(byte[], int, int, int, int, int, int) instead. -

      -

      - -
      Throws: -
      java.lang.Exception
      -
      -
      - -

      -TJCompressor

      -
      -public TJCompressor(java.awt.image.BufferedImage srcImage,
      -                    int x,
      -                    int y,
      -                    int width,
      -                    int height)
      -             throws java.lang.Exception
      -
      -
      Create a TurboJPEG compressor instance and associate the uncompressed + instance.
    +
    Parameters:
    srcImage - see setSourceImage(byte[], int, int, int, int, int, int) for description
    x - see setSourceImage(byte[], int, int, int, int, int, int) for description
    y - see setSourceImage(byte[], int, int, int, int, int, int) for description
    width - see setSourceImage(byte[], int, int, int, int, int, int) for description
    pitch - see setSourceImage(byte[], int, int, int, int, int, int) for description
    height - see setSourceImage(byte[], int, int, int, int, int, int) for description
    pixelFormat - pixel format of the source image (one of + TJ.PF_*)
    +
    Throws:
    +
    java.lang.Exception
    + + + + + +
      +
    • +

      TJCompressor

      +
      @Deprecated
      +public TJCompressor(byte[] srcImage,
      +                       int width,
      +                       int pitch,
      +                       int height,
      +                       int pixelFormat)
      +             throws java.lang.Exception
      + +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + + + + - - - - - - -
    -Method Detail
    - -

    -setSourceImage

    -
    -public void setSourceImage(byte[] srcImage,
    -                           int x,
    -                           int y,
    -                           int width,
    -                           int pitch,
    -                           int height,
    -                           int pixelFormat)
    -                    throws java.lang.Exception
    -
    -
    Associate an uncompressed RGB, grayscale, or CMYK source image with this - compressor instance. -

    -

    -
    Parameters:
    srcImage - image buffer containing RGB, grayscale, or CMYK pixels to - be compressed or encoded
    x - x offset (in pixels) of the region in the source image from which - the JPEG or YUV image should be compressed/encoded
    y - y offset (in pixels) of the region in the source image from which - the JPEG or YUV image should be compressed/encoded
    width - width (in pixels) of the region in the source image from - which the JPEG or YUV image should be compressed/encoded
    pitch - bytes per line of the source image. Normally, this should be +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        setSourceImage

        +
        public void setSourceImage(byte[] srcImage,
        +                  int x,
        +                  int y,
        +                  int width,
        +                  int pitch,
        +                  int height,
        +                  int pixelFormat)
        +                    throws java.lang.Exception
        +
        Associate an uncompressed RGB, grayscale, or CMYK source image with this + compressor instance.
        +
        Parameters:
        srcImage - image buffer containing RGB, grayscale, or CMYK pixels to + be compressed or encoded
        x - x offset (in pixels) of the region in the source image from which + the JPEG or YUV image should be compressed/encoded
        y - y offset (in pixels) of the region in the source image from which + the JPEG or YUV image should be compressed/encoded
        width - width (in pixels) of the region in the source image from + which the JPEG or YUV image should be compressed/encoded
        pitch - bytes per line of the source image. Normally, this should be width * TJ.pixelSize(pixelFormat) if the source image is unpadded, but you can use this parameter to, for instance, specify that the scanlines in the source image are padded to a 4-byte boundary or to compress/encode a JPEG or YUV image from a region of a larger source image. You can also be clever and use this parameter to skip lines, etc. Setting this parameter to 0 is the equivalent of setting it to - width * TJ.pixelSize(pixelFormat).
        height - height (in pixels) of the region in the source image from - which the JPEG or YUV image should be compressed/encoded
        pixelFormat - pixel format of the source image (one of - TJ.PF_*) -
        Throws: -
        java.lang.Exception
        -
    -
    -
    - -

    -setSourceImage

    -
    -@Deprecated
    -public void setSourceImage(byte[] srcImage,
    -                                      int width,
    -                                      int pitch,
    -                                      int height,
    -                                      int pixelFormat)
    -                    throws java.lang.Exception
    -
    -
    Deprecated. Use - setSourceImage(byte[], int, int, int, int, int, int) instead. -

    -

    - -
    Throws: -
    java.lang.Exception
    -
    -
    -
    - -

    -setSourceImage

    -
    -public void setSourceImage(java.awt.image.BufferedImage srcImage,
    -                           int x,
    -                           int y,
    -                           int width,
    -                           int height)
    -                    throws java.lang.Exception
    -
    -
    Associate an uncompressed RGB or grayscale source image with this - compressor instance. -

    -

    -
    Parameters:
    srcImage - a BufferedImage instance containing RGB or - grayscale pixels to be compressed or encoded
    x - x offset (in pixels) of the region in the source image from which - the JPEG or YUV image should be compressed/encoded
    y - y offset (in pixels) of the region in the source image from which - the JPEG or YUV image should be compressed/encoded
    width - width (in pixels) of the region in the source image from + width * TJ.pixelSize(pixelFormat).
    height - height (in pixels) of the region in the source image from + which the JPEG or YUV image should be compressed/encoded
    pixelFormat - pixel format of the source image (one of + TJ.PF_*)
    +
    Throws:
    +
    java.lang.Exception
    + + + + + +
      +
    • +

      setSourceImage

      +
      @Deprecated
      +public void setSourceImage(byte[] srcImage,
      +                             int width,
      +                             int pitch,
      +                             int height,
      +                             int pixelFormat)
      +                    throws java.lang.Exception
      + +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + +
      +
    • +

      setSourceImage

      +
      public void setSourceImage(java.awt.image.BufferedImage srcImage,
      +                  int x,
      +                  int y,
      +                  int width,
      +                  int height)
      +                    throws java.lang.Exception
      +
      Associate an uncompressed RGB or grayscale source image with this + compressor instance.
      +
      Parameters:
      srcImage - a BufferedImage instance containing RGB or + grayscale pixels to be compressed or encoded
      x - x offset (in pixels) of the region in the source image from which + the JPEG or YUV image should be compressed/encoded
      y - y offset (in pixels) of the region in the source image from which + the JPEG or YUV image should be compressed/encoded
      width - width (in pixels) of the region in the source image from which the JPEG or YUV image should be compressed/encoded (0 = use the - width of the source image)
      height - height (in pixels) of the region in the source image from + width of the source image)
      height - height (in pixels) of the region in the source image from which the JPEG or YUV image should be compressed/encoded (0 = use the - height of the source image) -
      Throws: -
      java.lang.Exception
      -
    -
    -
    - -

    -setSourceImage

    -
    -public void setSourceImage(YUVImage srcImage)
    -                    throws java.lang.Exception
    -
    -
    Associate an uncompressed YUV planar source image with this compressor - instance. -

    -

    -
    Parameters:
    srcImage - YUV planar image to be compressed -
    Throws: -
    java.lang.Exception
    -
    -
    -
    - -

    -setSubsamp

    -
    -public void setSubsamp(int newSubsamp)
    -                throws java.lang.Exception
    -
    -
    Set the level of chrominance subsampling for subsequent compress/encode + height of the source image)
    +
    Throws:
    +
    java.lang.Exception
    + + + + + +
      +
    • +

      setSourceImage

      +
      public void setSourceImage(YUVImage srcImage)
      +                    throws java.lang.Exception
      +
      Associate an uncompressed YUV planar source image with this compressor + instance.
      +
      Parameters:
      srcImage - YUV planar image to be compressed
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + +
      +
    • +

      setSubsamp

      +
      public void setSubsamp(int newSubsamp)
      +                throws java.lang.Exception
      +
      Set the level of chrominance subsampling for subsequent compress/encode operations. When pixels are converted from RGB to YCbCr (see - TJ.CS_YCbCr) or from CMYK to YCCK (see TJ.CS_YCCK) as part + TJ.CS_YCbCr) or from CMYK to YCCK (see TJ.CS_YCCK) as part of the JPEG compression process, some of the Cb and Cr (chrominance) components can be discarded or averaged together to produce a smaller image with little perceptible loss of image clarity (the human eye is more @@ -601,352 +562,319 @@ public void setSubsamp(int newSubsamp) NOTE: This method has no effect when compressing a JPEG image from a YUV planar source. In that case, the level of chrominance subsampling in the JPEG image is determined by the source. Further, this method has no - effect when encoding to a pre-allocated YUVImage instance. In + effect when encoding to a pre-allocated YUVImage instance. In that case, the level of chrominance subsampling is determined by the - destination. -

      -

      -
      Parameters:
      newSubsamp - the level of chrominance subsampling to use in + destination.
      +
      Parameters:
      newSubsamp - the level of chrominance subsampling to use in subsequent compress/encode oeprations (one of - TJ.SAMP_*) -
      Throws: -
      java.lang.Exception
      -
    -
    -
    - -

    -setJPEGQuality

    -
    -public void setJPEGQuality(int quality)
    -                    throws java.lang.Exception
    -
    -
    Set the JPEG image quality level for subsequent compress operations. -

    -

    -
    Parameters:
    quality - the new JPEG image quality level (1 to 100, 1 = worst, - 100 = best) -
    Throws: -
    java.lang.Exception
    -
    -
    -
    - -

    -compress

    -
    -public void compress(byte[] dstBuf,
    -                     int flags)
    -              throws java.lang.Exception
    -
    -
    Compress the uncompressed source image associated with this compressor - instance and output a JPEG image to the given destination buffer. -

    -

    -
    Parameters:
    dstBuf - buffer that will receive the JPEG image. Use - TJ.bufSize(int, int, int) to determine the maximum size for this buffer based on + TJ.SAMP_*)
    +
    Throws:
    +
    java.lang.Exception
    + + + + + +
      +
    • +

      setJPEGQuality

      +
      public void setJPEGQuality(int quality)
      +                    throws java.lang.Exception
      +
      Set the JPEG image quality level for subsequent compress operations.
      +
      Parameters:
      quality - the new JPEG image quality level (1 to 100, 1 = worst, + 100 = best)
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + +
      +
    • +

      compress

      +
      public void compress(byte[] dstBuf,
      +            int flags)
      +              throws java.lang.Exception
      +
      Compress the uncompressed source image associated with this compressor + instance and output a JPEG image to the given destination buffer.
      +
      Parameters:
      dstBuf - buffer that will receive the JPEG image. Use + TJ.bufSize(int, int, int) to determine the maximum size for this buffer based on the source image's width and height and the desired level of chrominance - subsampling.
      flags - the bitwise OR of one or more of - TJ.FLAG_* -
      Throws: -
      java.lang.Exception
      -
    -
    -
    - -

    -compress

    -
    -public byte[] compress(int flags)
    -                throws java.lang.Exception
    -
    -
    Compress the uncompressed source image associated with this compressor - instance and return a buffer containing a JPEG image. -

    -

    -
    Parameters:
    flags - the bitwise OR of one or more of - TJ.FLAG_* -
    Returns:
    a buffer containing a JPEG image. The length of this buffer will - not be equal to the size of the JPEG image. Use getCompressedSize() to obtain the size of the JPEG image. -
    Throws: -
    java.lang.Exception
    -
    -
    -
    - -

    -compress

    -
    -@Deprecated
    -public void compress(java.awt.image.BufferedImage srcImage,
    -                                byte[] dstBuf,
    -                                int flags)
    -              throws java.lang.Exception
    -
    -
    Deprecated. Use - setSourceImage(BufferedImage, int, int, int, int) and - compress(byte[], int) instead. -

    -

    - -
    Throws: -
    java.lang.Exception
    -
    -
    -
    - -

    -compress

    -
    -@Deprecated
    -public byte[] compress(java.awt.image.BufferedImage srcImage,
    -                                  int flags)
    -                throws java.lang.Exception
    -
    -
    Deprecated. Use - setSourceImage(BufferedImage, int, int, int, int) and - compress(int) instead. -

    -

    - -
    Throws: -
    java.lang.Exception
    -
    -
    -
    - -

    -encodeYUV

    -
    -public void encodeYUV(YUVImage dstImage,
    -                      int flags)
    -               throws java.lang.Exception
    -
    -
    Encode the uncompressed source image associated with this compressor + subsampling.
    flags - the bitwise OR of one or more of + TJ.FLAG_*
    +
    Throws:
    +
    java.lang.Exception
    + + + + + +
      +
    • +

      compress

      +
      public byte[] compress(int flags)
      +                throws java.lang.Exception
      +
      Compress the uncompressed source image associated with this compressor + instance and return a buffer containing a JPEG image.
      +
      Parameters:
      flags - the bitwise OR of one or more of + TJ.FLAG_*
      +
      Returns:
      a buffer containing a JPEG image. The length of this buffer will + not be equal to the size of the JPEG image. Use getCompressedSize() to obtain the size of the JPEG image.
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + + + + + + + + + +
      +
    • +

      encodeYUV

      +
      public void encodeYUV(YUVImage dstImage,
      +             int flags)
      +               throws java.lang.Exception
      +
      Encode the uncompressed source image associated with this compressor instance into a YUV planar image and store it in the given YUVImage instance. This method uses the accelerated color conversion routines in TurboJPEG's underlying codec but does not execute any of the other steps in the JPEG compression process. Encoding - CMYK source images to YUV is not supported. -

      -

      -
      Parameters:
      dstImage - YUVImage instance that will receive the YUV planar - image
      flags - the bitwise OR of one or more of - TJ.FLAG_* -
      Throws: -
      java.lang.Exception
      -
      - -
      - -

      -encodeYUV

      -
      -@Deprecated
      -public void encodeYUV(byte[] dstBuf,
      -                                 int flags)
      -               throws java.lang.Exception
      -
      -
      Deprecated. Use encodeYUV(YUVImage, int) instead. -

      -

      - -
      Throws: -
      java.lang.Exception
      -
      -
      -
      - -

      -encodeYUV

      -
      -public YUVImage encodeYUV(int pad,
      -                          int flags)
      -                   throws java.lang.Exception
      -
      -
      Encode the uncompressed source image associated with this compressor + CMYK source images to YUV is not supported.
      +
      Parameters:
      dstImage - YUVImage instance that will receive the YUV planar + image
      flags - the bitwise OR of one or more of + TJ.FLAG_*
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + +
      +
    • +

      encodeYUV

      +
      @Deprecated
      +public void encodeYUV(byte[] dstBuf,
      +                        int flags)
      +               throws java.lang.Exception
      +
      Deprecated. Use encodeYUV(YUVImage, int) instead.
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + +
      +
    • +

      encodeYUV

      +
      public YUVImage encodeYUV(int pad,
      +                 int flags)
      +                   throws java.lang.Exception
      +
      Encode the uncompressed source image associated with this compressor instance into a YUV planar image and return a YUVImage instance containing the encoded image. This method uses the accelerated color conversion routines in TurboJPEG's underlying codec but does not execute any of the other steps in the JPEG compression process. Encoding - CMYK source images to YUV is not supported. -

      -

      -
      Parameters:
      pad - the width of each line in each plane of the YUV image will be + CMYK source images to YUV is not supported.
      +
      Parameters:
      pad - the width of each line in each plane of the YUV image will be padded to the nearest multiple of this number of bytes (must be a power of - 2.)
      flags - the bitwise OR of one or more of - TJ.FLAG_* -
      Returns:
      a YUV planar image -
      Throws: -
      java.lang.Exception
      - - -
      - -

      -encodeYUV

      -
      -@Deprecated
      -public byte[] encodeYUV(int flags)
      -                 throws java.lang.Exception
      -
      -
      Deprecated. Use encodeYUV(int, int) instead. -

      -

      - -
      Throws: -
      java.lang.Exception
      -
      -
      -
      - -

      -encodeYUV

      -
      -@Deprecated
      -public void encodeYUV(java.awt.image.BufferedImage srcImage,
      -                                 byte[] dstBuf,
      -                                 int flags)
      -               throws java.lang.Exception
      -
      -
      Deprecated. Use - setSourceImage(BufferedImage, int, int, int, int) and - encodeYUV(byte[], int) instead. -

      -

      - -
      Throws: -
      java.lang.Exception
      -
      -
      -
      - -

      -encodeYUV

      -
      -@Deprecated
      -public byte[] encodeYUV(java.awt.image.BufferedImage srcImage,
      -                                   int flags)
      -                 throws java.lang.Exception
      -
      -
      Deprecated. Use - setSourceImage(BufferedImage, int, int, int, int) and - encodeYUV(int) instead. -

      -

      - -
      Throws: -
      java.lang.Exception
      -
      -
      -
      - -

      -getCompressedSize

      -
      -public int getCompressedSize()
      -
      -
      Returns the size of the image (in bytes) generated by the most recent - compress/encode operation. -

      -

      - -
      Returns:
      the size of the image (in bytes) generated by the most recent - compress/encode operation
      -
      -
      -
      - -

      -close

      -
      -public void close()
      -           throws java.lang.Exception
      -
      -
      Free the native structures associated with this compressor instance. -

      -

      - -
      Throws: -
      java.lang.Exception
      -
      -
      -
      - -

      -finalize

      -
      -protected void finalize()
      -                 throws java.lang.Throwable
      -
      -
      -
      Overrides:
      finalize in class java.lang.Object
      -
      -
      - -
      Throws: -
      java.lang.Throwable
      -
      -
      + 2.)
      flags - the bitwise OR of one or more of + TJ.FLAG_*
      +
      Returns:
      a YUV planar image
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + +
      +
    • +

      encodeYUV

      +
      @Deprecated
      +public byte[] encodeYUV(int flags)
      +                 throws java.lang.Exception
      +
      Deprecated. Use encodeYUV(int, int) instead.
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + + + + + + + + + +
      +
    • +

      getCompressedSize

      +
      public int getCompressedSize()
      +
      Returns the size of the image (in bytes) generated by the most recent + compress/encode operation.
      +
      Returns:
      the size of the image (in bytes) generated by the most recent + compress/encode operation
      +
    • +
    + + + +
      +
    • +

      close

      +
      public void close()
      +           throws java.lang.Exception
      +
      Free the native structures associated with this compressor instance.
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + +
      +
    • +

      finalize

      +
      protected void finalize()
      +                 throws java.lang.Throwable
      +
      +
      Overrides:
      +
      finalize in class java.lang.Object
      +
      Throws:
      +
      java.lang.Throwable
      +
    • +
    + + + + +
    + -
    - - - - - - - - - - - - - - - - - - -
    - -
    - + + +
    + + +
    + + + - -
    - - - + + diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJCustomFilter.html b/java/doc/org/libjpegturbo/turbojpeg/TJCustomFilter.html index 3291c71f..bac519b9 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/TJCustomFilter.html +++ b/java/doc/org/libjpegturbo/turbojpeg/TJCustomFilter.html @@ -1,238 +1,237 @@ - - - - -TJCustomFilter - - - - - - - - - - - -
    - - +//--> + + - - - - - - - - - - - - - - - - -
    - -
    - + + +
    + + +
    + + + - -
    -

    - -org.libjpegturbo.turbojpeg -
    -Interface TJCustomFilter

    -
    -
    -
    public interface TJCustomFilter
    - - -

    -Custom filter callback interface -

    - -

    -


    - -

    - +

    +
    org.libjpegturbo.turbojpeg
    +

    Interface TJCustomFilter

    +
    +
    +
    +
      +
    • +
      +
      +
      public interface TJCustomFilter
      +
      Custom filter callback interface
      +
    • +
    +
    +
    +
      +
    • - - - - - - - - - + +
      -Method Summary
      - voidcustomFilter(java.nio.ShortBuffer coeffBuffer, - java.awt.Rectangle bufferRegion, - java.awt.Rectangle planeRegion, - int componentID, - int transformID, - TJTransform transform) - -
      -          A callback function that can be used to modify the DCT coefficients after +
        +
      • + + +

        Method Summary

        + + + + + + + + + - -
        Methods 
        Modifier and TypeMethod and Description
        voidcustomFilter(java.nio.ShortBuffer coeffBuffer, + java.awt.Rectangle bufferRegion, + java.awt.Rectangle planeRegion, + int componentID, + int transformID, + TJTransform transform) +
        A callback function that can be used to modify the DCT coefficients after they are losslessly transformed but before they are transcoded to a new - JPEG image.
        -  -

        - + JPEG image. +

      +
    • +
    + + +
    +
    +
      +
    • - - - - - - -
      -Method Detail
      - -

      -customFilter

      -
      -void customFilter(java.nio.ShortBuffer coeffBuffer,
      -                  java.awt.Rectangle bufferRegion,
      -                  java.awt.Rectangle planeRegion,
      -                  int componentID,
      -                  int transformID,
      -                  TJTransform transform)
      -                  throws java.lang.Exception
      -
      -
      A callback function that can be used to modify the DCT coefficients after +
        +
      • + + +

        Method Detail

        + + + +
          +
        • +

          customFilter

          +
          void customFilter(java.nio.ShortBuffer coeffBuffer,
          +                java.awt.Rectangle bufferRegion,
          +                java.awt.Rectangle planeRegion,
          +                int componentID,
          +                int transformID,
          +                TJTransform transform)
          +                  throws java.lang.Exception
          +
          A callback function that can be used to modify the DCT coefficients after they are losslessly transformed but before they are transcoded to a new JPEG image. This allows for custom filters or other transformations to be - applied in the frequency domain. -

          -

          -
          Parameters:
          coeffBuffer - a buffer containing transformed DCT coefficients. + applied in the frequency domain.
          +
          Parameters:
          coeffBuffer - a buffer containing transformed DCT coefficients. (NOTE: this buffer is not guaranteed to be valid once the callback returns, so applications wishing to hand off the DCT coefficients to another function or library should make a copy of them within the body of - the callback.)
          bufferRegion - rectangle containing the width and height of + the callback.)
          bufferRegion - rectangle containing the width and height of coeffBuffer as well as its offset relative to the component plane. TurboJPEG implementations may choose to split each component plane into multiple DCT coefficient buffers and call the callback function once - for each buffer.
          planeRegion - rectangle containing the width and height of the - component plane to which coeffBuffer belongs
          componentID - ID number of the component plane to which + for each buffer.
          planeRegion - rectangle containing the width and height of the + component plane to which coeffBuffer belongs
          componentID - ID number of the component plane to which coeffBuffer belongs (Y, Cb, and Cr have, respectively, ID's - of 0, 1, and 2 in typical JPEG images.)
          transformID - ID number of the transformed image to which + of 0, 1, and 2 in typical JPEG images.)
          transformID - ID number of the transformed image to which coeffBuffer belongs. This is the same as the index of the - transform in the transforms array that was passed to TJTransformer.transform().
          transform - a TJTransform instance that specifies the - parameters and/or cropping region for this transform -
          Throws: -
          java.lang.Exception
          -
      -
      + transform in the transforms array that was passed to TJTransformer.transform().
      transform - a TJTransform instance that specifies the + parameters and/or cropping region for this transform
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + + +
    +
    -
    - - - - - - - - - - - - - - - - - - -
    - -
    - + + +
    + + +
    + + + - -
    - - - + + diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html b/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html index 01007b36..af6a9020 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html +++ b/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html @@ -1,978 +1,862 @@ - - - - -TJDecompressor - - - - - - - - - - - -
    - - +//--> + + - - - - - - - - - - - - - - - - -
    - -
    - + + +
    + + +
    + + + - -
    -

    - -org.libjpegturbo.turbojpeg -
    -Class TJDecompressor

    -
    -java.lang.Object
    -  extended by org.libjpegturbo.turbojpeg.TJDecompressor
    -
    -
    -
    Direct Known Subclasses:
    TJTransformer
    -
    -
    -
    -
    public class TJDecompressor
    extends java.lang.Object
    - - -

    -TurboJPEG decompressor -

    - -

    -


    - -

    +

    +
    org.libjpegturbo.turbojpeg
    +

    Class TJDecompressor

    +
    +
    +
      +
    • java.lang.Object
    • +
    • +
        +
      • org.libjpegturbo.turbojpeg.TJDecompressor
      • +
      +
    • +
    +
    +
      +
    • +
      +
      Direct Known Subclasses:
      +
      TJTransformer
      +
      +
      +
      +
      public class TJDecompressor
      +extends java.lang.Object
      +
      TurboJPEG decompressor
      +
    • +
    +
    +
    +
      +
    • - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      -Field Summary
      -protected  longhandle - -
      -           
      -protected  byte[]jpegBuf - -
      -           
      -protected  intjpegBufSize - -
      -           
      -protected  intsrcColorspace - -
      -           
      -protected  intsrcHeight - -
      -           
      -protected  intsrcSubsamp - -
      -           
      -protected  intsrcWidth - -
      -           
      -protected  YUVImageyuvImage - -
      -           
      -  + - - - - - - - - - - - - - - + +
      -Constructor Summary
      TJDecompressor() - -
      -          Create a TurboJPEG decompresssor instance.
      TJDecompressor(byte[] jpegImage) - -
      -          Create a TurboJPEG decompressor instance and associate the JPEG source - image stored in jpegImage with the newly created instance.
      TJDecompressor(byte[] jpegImage, - int imageSize) - -
      -          Create a TurboJPEG decompressor instance and associate the JPEG source +
        +
      • + + +

        Constructor Summary

        + + + + + + + + + + + + + - - - + + + - -
        Constructors 
        Constructor and Description
        TJDecompressor() +
        Create a TurboJPEG decompresssor instance.
        +
        TJDecompressor(byte[] jpegImage) +
        Create a TurboJPEG decompressor instance and associate the JPEG source + image stored in jpegImage with the newly created instance.
        +
        TJDecompressor(byte[] jpegImage, + int imageSize) +
        Create a TurboJPEG decompressor instance and associate the JPEG source image of length imageSize bytes stored in - jpegImage with the newly created instance.
        TJDecompressor(YUVImage yuvImage) - -
        -          Create a TurboJPEG decompressor instance and associate the YUV planar + jpegImage with the newly created instance. +
        TJDecompressor(YUVImage yuvImage) +
        Create a TurboJPEG decompressor instance and associate the YUV planar source image stored in yuvImage with the newly created - instance.
        -  + instance. +
      +
    • +
    - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    -Method Summary
    - voidclose() - -
    -          Free the native structures associated with this decompressor instance.
    - voiddecompress(java.awt.image.BufferedImage dstImage, - int flags) - -
    -          Decompress the JPEG source image or decode the YUV source image associated +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + - - - - - - - - + + + + + + + + - - - - + + + + - - - - + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      Methods 
      Modifier and TypeMethod and Description
      voidclose() +
      Free the native structures associated with this decompressor instance.
      +
      voiddecompress(java.awt.image.BufferedImage dstImage, + int flags) +
      Decompress the JPEG source image or decode the YUV source image associated with this decompressor instance and output a decompressed/decoded image to - the given BufferedImage instance.
      - voiddecompress(byte[] dstBuf, - int desiredWidth, - int pitch, - int desiredHeight, - int pixelFormat, - int flags) - -
      -          Deprecated. Use - decompress(byte[], int, int, int, int, int, int, int) instead.
      - voiddecompress(byte[] dstBuf, - int x, - int y, - int desiredWidth, - int pitch, - int desiredHeight, - int pixelFormat, - int flags) - -
      -          Decompress the JPEG source image or decode the YUV source image associated + the given BufferedImage instance. +
      voiddecompress(byte[] dstBuf, + int desiredWidth, + int pitch, + int desiredHeight, + int pixelFormat, + int flags) + +
      voiddecompress(byte[] dstBuf, + int x, + int y, + int desiredWidth, + int pitch, + int desiredHeight, + int pixelFormat, + int flags) +
      Decompress the JPEG source image or decode the YUV source image associated with this decompressor instance and output a grayscale, RGB, or CMYK image - to the given destination buffer.
      - voiddecompress(int[] dstBuf, - int x, - int y, - int desiredWidth, - int stride, - int desiredHeight, - int pixelFormat, - int flags) - -
      -          Decompress the JPEG source image or decode the YUV source image associated + to the given destination buffer. +
      voiddecompress(int[] dstBuf, + int x, + int y, + int desiredWidth, + int stride, + int desiredHeight, + int pixelFormat, + int flags) +
      Decompress the JPEG source image or decode the YUV source image associated with this decompressor instance and output a grayscale, RGB, or CMYK image - to the given destination buffer.
      - java.awt.image.BufferedImagedecompress(int desiredWidth, - int desiredHeight, - int bufferedImageType, - int flags) - -
      -          Decompress the JPEG source image or decode the YUV source image associated + to the given destination buffer. +
      java.awt.image.BufferedImagedecompress(int desiredWidth, + int desiredHeight, + int bufferedImageType, + int flags) +
      Decompress the JPEG source image or decode the YUV source image associated with this decompressor instance and return a BufferedImage - instance containing the decompressed/decoded image.
      - byte[]decompress(int desiredWidth, - int pitch, - int desiredHeight, - int pixelFormat, - int flags) - -
      -          Decompress the JPEG source image associated with this decompressor - instance and return a buffer containing the decompressed image.
      - voiddecompressToYUV(byte[] dstBuf, - int flags) - -
      -          Deprecated. Use decompressToYUV(YUVImage, int) instead.
      - byte[]decompressToYUV(int flags) - -
      -          Deprecated. Use decompressToYUV(int, int, int, int) instead.
      - YUVImagedecompressToYUV(int desiredWidth, - int pad, - int desiredHeight, - int flags) - -
      -          Decompress the JPEG source image associated with this decompressor + instance containing the decompressed/decoded image. +
      byte[]decompress(int desiredWidth, + int pitch, + int desiredHeight, + int pixelFormat, + int flags) +
      Decompress the JPEG source image associated with this decompressor + instance and return a buffer containing the decompressed image.
      +
      voiddecompressToYUV(byte[] dstBuf, + int flags) +
      Deprecated.  + +
      +
      byte[]decompressToYUV(int flags) +
      Deprecated.  + +
      +
      YUVImagedecompressToYUV(int desiredWidth, + int pad, + int desiredHeight, + int flags) +
      Decompress the JPEG source image associated with this decompressor instance into a YUV planar image and return a YUVImage - instance containing the decompressed image.
      - voiddecompressToYUV(YUVImage dstImage, - int flags) - -
      -          Decompress the JPEG source image associated with this decompressor + instance containing the decompressed image. +
      voiddecompressToYUV(YUVImage dstImage, + int flags) +
      Decompress the JPEG source image associated with this decompressor instance into a YUV planar image and store it in the given - YUVImage instance.
      -protected  voidfinalize() - -
      -           
      - intgetColorspace() - -
      -          Returns the colorspace used in the source image (JPEG or YUV) associated - with this decompressor instance.
      - intgetHeight() - -
      -          Returns the height of the source image (JPEG or YUV) associated with this - decompressor instance.
      - byte[]getJPEGBuf() - -
      -          Deprecated. Use getSourceBuf() instead.
      - intgetJPEGSize() - -
      -          Deprecated. Use getSourceSize() instead.
      - intgetScaledHeight(int desiredWidth, - int desiredHeight) - -
      -          Returns the height of the largest scaled-down image that the TurboJPEG + YUVImage instance. +
      protected voidfinalize() 
      intgetColorspace() +
      Returns the colorspace used in the source image (JPEG or YUV) associated + with this decompressor instance.
      +
      intgetHeight() +
      Returns the height of the source image (JPEG or YUV) associated with this + decompressor instance.
      +
      byte[]getJPEGBuf() +
      Deprecated.  +
      Use getSourceBuf() instead.
      +
      +
      intgetJPEGSize() +
      Deprecated.  +
      Use getSourceSize() instead.
      +
      +
      intgetScaledHeight(int desiredWidth, + int desiredHeight) +
      Returns the height of the largest scaled-down image that the TurboJPEG decompressor can generate without exceeding the desired image width and - height.
      - intgetScaledWidth(int desiredWidth, - int desiredHeight) - -
      -          Returns the width of the largest scaled-down image that the TurboJPEG + height. +
      intgetScaledWidth(int desiredWidth, + int desiredHeight) +
      Returns the width of the largest scaled-down image that the TurboJPEG decompressor can generate without exceeding the desired image width and - height.
      - byte[]getSourceBuf() - -
      -          Returns the source image buffer associated with this decompressor - instance.
      - intgetSourceSize() - -
      -          Returns the size of the source image (in bytes) associated with this - decompressor instance.
      - intgetSubsamp() - -
      -          Returns the level of chrominance subsampling used in the source image - (JPEG or YUV) associated with this decompressor instance.
      - intgetWidth() - -
      -          Returns the width of the source image (JPEG or YUV) associated with this - decompressor instance.
      - voidsetJPEGImage(byte[] jpegImage, - int imageSize) - -
      -          Deprecated. Use setSourceImage(byte[], int) instead.
      - voidsetSourceImage(byte[] srcImage, - int imageSize) - -
      -          Associate the JPEG image of length imageSize bytes stored in - srcImage with this decompressor instance.
      - voidsetSourceImage(YUVImage srcImage) - -
      -          Associate the specified YUV planar source image with this decompressor - instance.
      - - - - - - - -
      Methods inherited from class java.lang.Object
      clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      -  -

      - + height. +

    byte[]getSourceBuf() +
    Returns the source image buffer associated with this decompressor + instance.
    +
    intgetSourceSize() +
    Returns the size of the source image (in bytes) associated with this + decompressor instance.
    +
    intgetSubsamp() +
    Returns the level of chrominance subsampling used in the source image + (JPEG or YUV) associated with this decompressor instance.
    +
    intgetWidth() +
    Returns the width of the source image (JPEG or YUV) associated with this + decompressor instance.
    +
    voidsetJPEGImage(byte[] jpegImage, + int imageSize) +
    Deprecated.  + +
    +
    voidsetSourceImage(byte[] srcImage, + int imageSize) +
    Associate the JPEG image of length imageSize bytes stored in + srcImage with this decompressor instance.
    +
    voidsetSourceImage(YUVImage srcImage) +
    Associate the specified YUV planar source image with this decompressor + instance.
    +
    +
      +
    • + + +

      Methods inherited from class java.lang.Object

      +clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • +
    + + + + +
    +
    +
      +
    • - - - - - - -
      -Field Detail
      - -

      -handle

      -
      -protected long handle
      -
      -
      -
      -
      -
      - -

      -jpegBuf

      -
      -protected byte[] jpegBuf
      -
      -
      -
      -
      -
      - -

      -jpegBufSize

      -
      -protected int jpegBufSize
      -
      -
      -
      -
      -
      - -

      -yuvImage

      -
      -protected YUVImage yuvImage
      -
      -
      -
      -
      -
      - -

      -srcWidth

      -
      -protected int srcWidth
      -
      -
      -
      -
      -
      - -

      -srcHeight

      -
      -protected int srcHeight
      -
      -
      -
      -
      -
      - -

      -srcSubsamp

      -
      -protected int srcSubsamp
      -
      -
      -
      -
      -
      - -

      -srcColorspace

      -
      -protected int srcColorspace
      -
      -
      -
      -
      - +
        +
      • + + +

        Field Detail

        + + + +
          +
        • +

          handle

          +
          protected long handle
          +
        • +
        + + + +
          +
        • +

          jpegBuf

          +
          protected byte[] jpegBuf
          +
        • +
        + + + +
          +
        • +

          jpegBufSize

          +
          protected int jpegBufSize
          +
        • +
        + + + +
          +
        • +

          yuvImage

          +
          protected YUVImage yuvImage
          +
        • +
        + + + +
          +
        • +

          srcWidth

          +
          protected int srcWidth
          +
        • +
        + + + +
          +
        • +

          srcHeight

          +
          protected int srcHeight
          +
        • +
        + + + +
          +
        • +

          srcSubsamp

          +
          protected int srcSubsamp
          +
        • +
        + + + +
          +
        • +

          srcColorspace

          +
          protected int srcColorspace
          +
        • +
        +
      • +
      - - - - - - -
      -Constructor Detail
      - -

      -TJDecompressor

      -
      -public TJDecompressor()
      -               throws java.lang.Exception
      -
      -
      Create a TurboJPEG decompresssor instance. -

      -

      - -
      Throws: -
      java.lang.Exception
      -
      -
      - -

      -TJDecompressor

      -
      -public TJDecompressor(byte[] jpegImage)
      -               throws java.lang.Exception
      -
      -
      Create a TurboJPEG decompressor instance and associate the JPEG source - image stored in jpegImage with the newly created instance. -

      -

      -
      Parameters:
      jpegImage - JPEG image buffer (size of the JPEG image is assumed to - be the length of the array) -
      Throws: -
      java.lang.Exception
      -
      -
      - -

      -TJDecompressor

      -
      -public TJDecompressor(byte[] jpegImage,
      -                      int imageSize)
      -               throws java.lang.Exception
      -
      -
      Create a TurboJPEG decompressor instance and associate the JPEG source +
        +
      • + + +

        Constructor Detail

        + + + +
          +
        • +

          TJDecompressor

          +
          public TJDecompressor()
          +               throws java.lang.Exception
          +
          Create a TurboJPEG decompresssor instance.
          +
          Throws:
          +
          java.lang.Exception
          +
        • +
        + + + +
          +
        • +

          TJDecompressor

          +
          public TJDecompressor(byte[] jpegImage)
          +               throws java.lang.Exception
          +
          Create a TurboJPEG decompressor instance and associate the JPEG source + image stored in jpegImage with the newly created instance.
          +
          Parameters:
          jpegImage - JPEG image buffer (size of the JPEG image is assumed to + be the length of the array)
          +
          Throws:
          +
          java.lang.Exception
          +
        • +
        + + + +
          +
        • +

          TJDecompressor

          +
          public TJDecompressor(byte[] jpegImage,
          +              int imageSize)
          +               throws java.lang.Exception
          +
          Create a TurboJPEG decompressor instance and associate the JPEG source image of length imageSize bytes stored in - jpegImage with the newly created instance. -

          -

          -
          Parameters:
          jpegImage - JPEG image buffer
          imageSize - size of the JPEG image (in bytes) -
          Throws: -
          java.lang.Exception
          -
      -
      - -

      -TJDecompressor

      -
      -public TJDecompressor(YUVImage yuvImage)
      -               throws java.lang.Exception
      -
      -
      Create a TurboJPEG decompressor instance and associate the YUV planar + jpegImage with the newly created instance.
    +
    Parameters:
    jpegImage - JPEG image buffer
    imageSize - size of the JPEG image (in bytes)
    +
    Throws:
    +
    java.lang.Exception
    + + + + + +
      +
    • +

      TJDecompressor

      +
      public TJDecompressor(YUVImage yuvImage)
      +               throws java.lang.Exception
      +
      Create a TurboJPEG decompressor instance and associate the YUV planar source image stored in yuvImage with the newly created - instance. -

      -

      -
      Parameters:
      yuvImage - YUVImage instance containing a YUV planar - image to be decoded -
      Throws: -
      java.lang.Exception
      - - + instance.
      +
      Parameters:
      yuvImage - YUVImage instance containing a YUV planar + image to be decoded
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + - - - - - - -
    -Method Detail
    - -

    -setSourceImage

    -
    -public void setSourceImage(byte[] srcImage,
    -                           int imageSize)
    -                    throws java.lang.Exception
    -
    -
    Associate the JPEG image of length imageSize bytes stored in +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        setSourceImage

        +
        public void setSourceImage(byte[] srcImage,
        +                  int imageSize)
        +                    throws java.lang.Exception
        +
        Associate the JPEG image of length imageSize bytes stored in srcImage with this decompressor instance. This image will - be used as the source image for subsequent decompress operations. -

        -

        -
        Parameters:
        srcImage - JPEG image buffer
        imageSize - size of the JPEG image (in bytes) -
        Throws: -
        java.lang.Exception
        -
        -
    -
    - -

    -setJPEGImage

    -
    -@Deprecated
    -public void setJPEGImage(byte[] jpegImage,
    -                                    int imageSize)
    -                  throws java.lang.Exception
    -
    -
    Deprecated. Use setSourceImage(byte[], int) instead. -

    -

    - -
    Throws: -
    java.lang.Exception
    -
    -
    -
    - -

    -setSourceImage

    -
    -public void setSourceImage(YUVImage srcImage)
    -                    throws java.lang.Exception
    -
    -
    Associate the specified YUV planar source image with this decompressor + be used as the source image for subsequent decompress operations.
    +
    Parameters:
    srcImage - JPEG image buffer
    imageSize - size of the JPEG image (in bytes)
    +
    Throws:
    +
    java.lang.Exception
    + + + + + +
      +
    • +

      setJPEGImage

      +
      @Deprecated
      +public void setJPEGImage(byte[] jpegImage,
      +                           int imageSize)
      +                  throws java.lang.Exception
      +
      Deprecated. Use setSourceImage(byte[], int) instead.
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + +
      +
    • +

      setSourceImage

      +
      public void setSourceImage(YUVImage srcImage)
      +                    throws java.lang.Exception
      +
      Associate the specified YUV planar source image with this decompressor instance. Subsequent decompress operations will decode this image into an - RGB or grayscale destination image. -

      -

      -
      Parameters:
      srcImage - YUVImage instance containing a YUV planar image to - be decoded -
      Throws: -
      java.lang.Exception
      -
      - -
      - -

      -getWidth

      -
      -public int getWidth()
      -             throws java.lang.Exception
      -
      -
      Returns the width of the source image (JPEG or YUV) associated with this - decompressor instance. -

      -

      - -
      Returns:
      the width of the source image (JPEG or YUV) associated with this - decompressor instance -
      Throws: -
      java.lang.Exception
      -
      -
      -
      - -

      -getHeight

      -
      -public int getHeight()
      -              throws java.lang.Exception
      -
      -
      Returns the height of the source image (JPEG or YUV) associated with this - decompressor instance. -

      -

      - -
      Returns:
      the height of the source image (JPEG or YUV) associated with this - decompressor instance -
      Throws: -
      java.lang.Exception
      -
      -
      -
      - -

      -getSubsamp

      -
      -public int getSubsamp()
      -               throws java.lang.Exception
      -
      -
      Returns the level of chrominance subsampling used in the source image + RGB or grayscale destination image.
      +
      Parameters:
      srcImage - YUVImage instance containing a YUV planar image to + be decoded
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + +
      +
    • +

      getWidth

      +
      public int getWidth()
      +             throws java.lang.Exception
      +
      Returns the width of the source image (JPEG or YUV) associated with this + decompressor instance.
      +
      Returns:
      the width of the source image (JPEG or YUV) associated with this + decompressor instance
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + +
      +
    • +

      getHeight

      +
      public int getHeight()
      +              throws java.lang.Exception
      +
      Returns the height of the source image (JPEG or YUV) associated with this + decompressor instance.
      +
      Returns:
      the height of the source image (JPEG or YUV) associated with this + decompressor instance
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + +
      +
    • +

      getSubsamp

      +
      public int getSubsamp()
      +               throws java.lang.Exception
      +
      Returns the level of chrominance subsampling used in the source image (JPEG or YUV) associated with this decompressor instance. See - TJ.SAMP_*. -

      -

      - -
      Returns:
      the level of chrominance subsampling used in the source image - (JPEG or YUV) associated with this decompressor instance -
      Throws: -
      java.lang.Exception
      -
      - -
      - -

      -getColorspace

      -
      -public int getColorspace()
      -                  throws java.lang.Exception
      -
      -
      Returns the colorspace used in the source image (JPEG or YUV) associated - with this decompressor instance. See TJ.CS_*. If the - source image is YUV, then this always returns TJ.CS_YCbCr. -

      -

      - -
      Returns:
      the colorspace used in the source image (JPEG or YUV) associated - with this decompressor instance -
      Throws: -
      java.lang.Exception
      -
      -
      -
      - -

      -getSourceBuf

      -
      -public byte[] getSourceBuf()
      -                    throws java.lang.Exception
      -
      -
      Returns the source image buffer associated with this decompressor - instance. -

      -

      - -
      Returns:
      the source image buffer associated with this decompressor instance -
      Throws: -
      java.lang.Exception
      -
      -
      -
      - -

      -getJPEGBuf

      -
      -@Deprecated
      -public byte[] getJPEGBuf()
      -                  throws java.lang.Exception
      -
      -
      Deprecated. Use getSourceBuf() instead. -

      -

      - -
      Throws: -
      java.lang.Exception
      -
      -
      -
      - -

      -getSourceSize

      -
      -public int getSourceSize()
      -                  throws java.lang.Exception
      -
      -
      Returns the size of the source image (in bytes) associated with this - decompressor instance. -

      -

      - -
      Returns:
      the size of the source image (in bytes) associated with this - decompressor instance -
      Throws: -
      java.lang.Exception
      -
      -
      -
      - -

      -getJPEGSize

      -
      -@Deprecated
      -public int getJPEGSize()
      -                throws java.lang.Exception
      -
      -
      Deprecated. Use getSourceSize() instead. -

      -

      - -
      Throws: -
      java.lang.Exception
      -
      -
      -
      - -

      -getScaledWidth

      -
      -public int getScaledWidth(int desiredWidth,
      -                          int desiredHeight)
      -                   throws java.lang.Exception
      -
      -
      Returns the width of the largest scaled-down image that the TurboJPEG + TJ.SAMP_*.
      +
      Returns:
      the level of chrominance subsampling used in the source image + (JPEG or YUV) associated with this decompressor instance
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + +
      +
    • +

      getColorspace

      +
      public int getColorspace()
      +                  throws java.lang.Exception
      +
      Returns the colorspace used in the source image (JPEG or YUV) associated + with this decompressor instance. See TJ.CS_*. If the + source image is YUV, then this always returns TJ.CS_YCbCr.
      +
      Returns:
      the colorspace used in the source image (JPEG or YUV) associated + with this decompressor instance
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + +
      +
    • +

      getSourceBuf

      +
      public byte[] getSourceBuf()
      +                    throws java.lang.Exception
      +
      Returns the source image buffer associated with this decompressor + instance.
      +
      Returns:
      the source image buffer associated with this decompressor instance
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + +
      +
    • +

      getJPEGBuf

      +
      @Deprecated
      +public byte[] getJPEGBuf()
      +                  throws java.lang.Exception
      +
      Deprecated. Use getSourceBuf() instead.
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + +
      +
    • +

      getSourceSize

      +
      public int getSourceSize()
      +                  throws java.lang.Exception
      +
      Returns the size of the source image (in bytes) associated with this + decompressor instance.
      +
      Returns:
      the size of the source image (in bytes) associated with this + decompressor instance
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + +
      +
    • +

      getJPEGSize

      +
      @Deprecated
      +public int getJPEGSize()
      +                throws java.lang.Exception
      +
      Deprecated. Use getSourceSize() instead.
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + +
      +
    • +

      getScaledWidth

      +
      public int getScaledWidth(int desiredWidth,
      +                 int desiredHeight)
      +                   throws java.lang.Exception
      +
      Returns the width of the largest scaled-down image that the TurboJPEG decompressor can generate without exceeding the desired image width and - height. -

      -

      -
      Parameters:
      desiredWidth - desired width (in pixels) of the decompressed image. + height.
      +
      Parameters:
      desiredWidth - desired width (in pixels) of the decompressed image. Setting this to 0 is the same as setting it to the width of the JPEG image (in other words, the width will not be considered when determining the - scaled image size.)
      desiredHeight - desired height (in pixels) of the decompressed image. + scaled image size.)
      desiredHeight - desired height (in pixels) of the decompressed image. Setting this to 0 is the same as setting it to the height of the JPEG image (in other words, the height will not be considered when determining - the scaled image size.) -
      Returns:
      the width of the largest scaled-down image that the TurboJPEG + the scaled image size.)
      +
      Returns:
      the width of the largest scaled-down image that the TurboJPEG decompressor can generate without exceeding the desired image width and - height -
      Throws: -
      java.lang.Exception
      - - -
      - -

      -getScaledHeight

      -
      -public int getScaledHeight(int desiredWidth,
      -                           int desiredHeight)
      -                    throws java.lang.Exception
      -
      -
      Returns the height of the largest scaled-down image that the TurboJPEG + height
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + +
      +
    • +

      getScaledHeight

      +
      public int getScaledHeight(int desiredWidth,
      +                  int desiredHeight)
      +                    throws java.lang.Exception
      +
      Returns the height of the largest scaled-down image that the TurboJPEG decompressor can generate without exceeding the desired image width and - height. -

      -

      -
      Parameters:
      desiredWidth - desired width (in pixels) of the decompressed image. + height.
      +
      Parameters:
      desiredWidth - desired width (in pixels) of the decompressed image. Setting this to 0 is the same as setting it to the width of the JPEG image (in other words, the width will not be considered when determining the - scaled image size.)
      desiredHeight - desired height (in pixels) of the decompressed image. + scaled image size.)
      desiredHeight - desired height (in pixels) of the decompressed image. Setting this to 0 is the same as setting it to the height of the JPEG image (in other words, the height will not be considered when determining - the scaled image size.) -
      Returns:
      the height of the largest scaled-down image that the TurboJPEG + the scaled image size.)
      +
      Returns:
      the height of the largest scaled-down image that the TurboJPEG decompressor can generate without exceeding the desired image width and - height -
      Throws: -
      java.lang.Exception
      - - -
      - -

      -decompress

      -
      -public void decompress(byte[] dstBuf,
      -                       int x,
      -                       int y,
      -                       int desiredWidth,
      -                       int pitch,
      -                       int desiredHeight,
      -                       int pixelFormat,
      -                       int flags)
      -                throws java.lang.Exception
      -
      -
      Decompress the JPEG source image or decode the YUV source image associated + height
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + +
      +
    • +

      decompress

      +
      public void decompress(byte[] dstBuf,
      +              int x,
      +              int y,
      +              int desiredWidth,
      +              int pitch,
      +              int desiredHeight,
      +              int pixelFormat,
      +              int flags)
      +                throws java.lang.Exception
      +
      Decompress the JPEG source image or decode the YUV source image associated with this decompressor instance and output a grayscale, RGB, or CMYK image - to the given destination buffer. -

      -

      -
      Parameters:
      dstBuf - buffer that will receive the decompressed/decoded image. + to the given destination buffer.
      +
      Parameters:
      dstBuf - buffer that will receive the decompressed/decoded image. If the source image is a JPEG image, then this buffer should normally be pitch * scaledHeight bytes in size, where scaledHeight can be determined by calling - scalingFactor.getScaled(jpegHeight) - with one of the scaling factors returned from TJ.getScalingFactors() or by calling getScaledHeight(int, int). If the + scalingFactor.getScaled(jpegHeight) + with one of the scaling factors returned from TJ.getScalingFactors() or by calling getScaledHeight(int, int). If the source image is a YUV image, then this buffer should normally be pitch * height bytes in size, where height is the height of the YUV image. However, the buffer may also be larger than the dimensions of the source image, in which case the x, y, and pitch parameters can be used to specify - the region into which the source image should be decompressed/decoded.
      x - x offset (in pixels) of the region in the destination image into - which the source image should be decompressed/decoded
      y - y offset (in pixels) of the region in the destination image into - which the source image should be decompressed/decoded
      desiredWidth - If the source image is a JPEG image, then this + the region into which the source image should be decompressed/decoded.
      x - x offset (in pixels) of the region in the destination image into + which the source image should be decompressed/decoded
      y - y offset (in pixels) of the region in the destination image into + which the source image should be decompressed/decoded
      desiredWidth - If the source image is a JPEG image, then this specifies the desired width (in pixels) of the decompressed image (or image region.) If the desired destination image dimensions are different than the source image dimensions, then TurboJPEG will use scaling in the @@ -980,18 +864,18 @@ public void decompress(byte[] dstBuf, within the desired dimensions. Setting this to 0 is the same as setting it to the width of the JPEG image (in other words, the width will not be considered when determining the scaled image size.) This parameter is - ignored if the source image is a YUV image.
      pitch - bytes per line of the destination image. Normally, this + ignored if the source image is a YUV image.
      pitch - bytes per line of the destination image. Normally, this should be set to scaledWidth * TJ.pixelSize(pixelFormat) if the destination image is unpadded, but you can use this to, for instance, pad each line of the destination image to a 4-byte boundary or to decompress/decode the source image into a region of a larger image. NOTE: if the source image is a JPEG image, then scaledWidth can be determined by calling - scalingFactor.getScaled(jpegWidth) - or by calling getScaledWidth(int, int). If the source image is a + scalingFactor.getScaled(jpegWidth) + or by calling getScaledWidth(int, int). If the source image is a YUV image, then scaledWidth is the width of the YUV image. Setting this parameter to 0 is the equivalent of setting it to - scaledWidth * TJ.pixelSize(pixelFormat).
      desiredHeight - If the source image is a JPEG image, then this + scaledWidth * TJ.pixelSize(pixelFormat).
      desiredHeight - If the source image is a JPEG image, then this specifies the desired height (in pixels) of the decompressed image (or image region.) If the desired destination image dimensions are different than the source image dimensions, then TurboJPEG will use scaling in the @@ -999,204 +883,187 @@ public void decompress(byte[] dstBuf, within the desired dimensions. Setting this to 0 is the same as setting it to the height of the JPEG image (in other words, the height will not be considered when determining the scaled image size.) This parameter is - ignored if the source image is a YUV image.
      pixelFormat - pixel format of the decompressed/decoded image (one of - TJ.PF_*)
      flags - the bitwise OR of one or more of - TJ.FLAG_* -
      Throws: -
      java.lang.Exception
      - - -
      - -

      -decompress

      -
      -@Deprecated
      -public void decompress(byte[] dstBuf,
      -                                  int desiredWidth,
      -                                  int pitch,
      -                                  int desiredHeight,
      -                                  int pixelFormat,
      -                                  int flags)
      -                throws java.lang.Exception
      -
      -
      Deprecated. Use - decompress(byte[], int, int, int, int, int, int, int) instead. -

      -

      - -
      Throws: -
      java.lang.Exception
      -
      -
      -
      - -

      -decompress

      -
      -public byte[] decompress(int desiredWidth,
      + ignored if the source image is a YUV image.
      pixelFormat - pixel format of the decompressed/decoded image (one of + TJ.PF_*)
      flags - the bitwise OR of one or more of + TJ.FLAG_*
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + + + + + + + + + +
      +
    • +

      decompressToYUV

      +
      public void decompressToYUV(YUVImage dstImage,
      +                   int flags)
      +                     throws java.lang.Exception
      +
      Decompress the JPEG source image associated with this decompressor instance into a YUV planar image and store it in the given YUVImage instance. This method performs JPEG decompression but leaves out the color conversion step, so a planar YUV image is generated instead of an RGB or grayscale image. This method cannot be - used to decompress JPEG source images with the CMYK or YCCK colorspace. -

      -

      -
      Parameters:
      dstImage - YUVImage instance that will receive the YUV planar + used to decompress JPEG source images with the CMYK or YCCK colorspace.
      +
      Parameters:
      dstImage - YUVImage instance that will receive the YUV planar image. The level of subsampling specified in this YUVImage instance must match that of the JPEG image, and the width and height specified in the YUVImage instance must match one of the scaled image sizes that TurboJPEG is capable of generating from the JPEG - source image.
      flags - the bitwise OR of one or more of - TJ.FLAG_* -
      Throws: -
      java.lang.Exception
      - - -
      - -

      -decompressToYUV

      -
      -@Deprecated
      -public void decompressToYUV(byte[] dstBuf,
      -                                       int flags)
      -                     throws java.lang.Exception
      -
      -
      Deprecated. Use decompressToYUV(YUVImage, int) instead. -

      -

      - -
      Throws: -
      java.lang.Exception
      -
      -
      -
      - -

      -decompressToYUV

      -
      -public YUVImage decompressToYUV(int desiredWidth,
      -                                int pad,
      -                                int desiredHeight,
      -                                int flags)
      -                         throws java.lang.Exception
      -
      -
      Decompress the JPEG source image associated with this decompressor + source image.
      flags - the bitwise OR of one or more of + TJ.FLAG_*
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + +
      +
    • +

      decompressToYUV

      +
      @Deprecated
      +public void decompressToYUV(byte[] dstBuf,
      +                              int flags)
      +                     throws java.lang.Exception
      +
      Deprecated. Use decompressToYUV(YUVImage, int) instead.
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + +
      +
    • +

      decompressToYUV

      +
      public YUVImage decompressToYUV(int desiredWidth,
      +                       int pad,
      +                       int desiredHeight,
      +                       int flags)
      +                         throws java.lang.Exception
      +
      Decompress the JPEG source image associated with this decompressor instance into a YUV planar image and return a YUVImage instance containing the decompressed image. This method performs JPEG decompression but leaves out the color conversion step, so a planar YUV image is generated instead of an RGB or grayscale image. This method cannot be used to decompress JPEG source images with the CMYK or YCCK - colorspace. -

      -

      -
      Parameters:
      desiredWidth - desired width (in pixels) of the YUV image. If the + colorspace.
      +
      Parameters:
      desiredWidth - desired width (in pixels) of the YUV image. If the desired image dimensions are different than the dimensions of the JPEG image being decompressed, then TurboJPEG will use scaling in the JPEG decompressor to generate the largest possible image that will fit within the desired dimensions. Setting this to 0 is the same as setting it to the width of the JPEG image (in other words, the width will not be - considered when determining the scaled image size.)
      pad - the width of each line in each plane of the YUV image will be + considered when determining the scaled image size.)
      pad - the width of each line in each plane of the YUV image will be padded to the nearest multiple of this number of bytes (must be a power of - 2.)
      desiredHeight - desired height (in pixels) of the YUV image. If the + 2.)
      desiredHeight - desired height (in pixels) of the YUV image. If the desired image dimensions are different than the dimensions of the JPEG image being decompressed, then TurboJPEG will use scaling in the JPEG decompressor to generate the largest possible image that will fit within the desired dimensions. Setting this to 0 is the same as setting it to the height of the JPEG image (in other words, the height will not be - considered when determining the scaled image size.)
      flags - the bitwise OR of one or more of - TJ.FLAG_* -
      Returns:
      a YUV planar image -
      Throws: -
      java.lang.Exception
      - - -
      - -

      -decompressToYUV

      -
      -@Deprecated
      -public byte[] decompressToYUV(int flags)
      -                       throws java.lang.Exception
      -
      -
      Deprecated. Use decompressToYUV(int, int, int, int) instead. -

      -

      - -
      Throws: -
      java.lang.Exception
      -
      -
      -
      - -

      -decompress

      -
      -public void decompress(int[] dstBuf,
      -                       int x,
      -                       int y,
      -                       int desiredWidth,
      -                       int stride,
      -                       int desiredHeight,
      -                       int pixelFormat,
      -                       int flags)
      -                throws java.lang.Exception
      -
      -
      Decompress the JPEG source image or decode the YUV source image associated + considered when determining the scaled image size.)
      flags - the bitwise OR of one or more of + TJ.FLAG_*
      +
      Returns:
      a YUV planar image
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + +
      +
    • +

      decompressToYUV

      +
      @Deprecated
      +public byte[] decompressToYUV(int flags)
      +                       throws java.lang.Exception
      +
      Deprecated. Use decompressToYUV(int, int, int, int) instead.
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + +
      +
    • +

      decompress

      +
      public void decompress(int[] dstBuf,
      +              int x,
      +              int y,
      +              int desiredWidth,
      +              int stride,
      +              int desiredHeight,
      +              int pixelFormat,
      +              int flags)
      +                throws java.lang.Exception
      +
      Decompress the JPEG source image or decode the YUV source image associated with this decompressor instance and output a grayscale, RGB, or CMYK image - to the given destination buffer. -

      -

      -
      Parameters:
      dstBuf - buffer that will receive the decompressed/decoded image. + to the given destination buffer.
      +
      Parameters:
      dstBuf - buffer that will receive the decompressed/decoded image. If the source image is a JPEG image, then this buffer should normally be stride * scaledHeight pixels in size, where scaledHeight can be determined by calling - scalingFactor.getScaled(jpegHeight) - with one of the scaling factors returned from TJ.getScalingFactors() or by calling getScaledHeight(int, int). If the + scalingFactor.getScaled(jpegHeight) + with one of the scaling factors returned from TJ.getScalingFactors() or by calling getScaledHeight(int, int). If the source image is a YUV image, then this buffer should normally be stride * height pixels in size, where height is the height of the YUV image. However, the buffer may also be larger than the dimensions of the JPEG image, in which case the x, y, and stride parameters can be used to specify - the region into which the source image should be decompressed.
      x - x offset (in pixels) of the region in the destination image into - which the source image should be decompressed/decoded
      y - y offset (in pixels) of the region in the destination image into - which the source image should be decompressed/decoded
      desiredWidth - If the source image is a JPEG image, then this + the region into which the source image should be decompressed.
      x - x offset (in pixels) of the region in the destination image into + which the source image should be decompressed/decoded
      y - y offset (in pixels) of the region in the destination image into + which the source image should be decompressed/decoded
      desiredWidth - If the source image is a JPEG image, then this specifies the desired width (in pixels) of the decompressed image (or image region.) If the desired destination image dimensions are different than the source image dimensions, then TurboJPEG will use scaling in the @@ -1204,16 +1071,16 @@ public void decompress(int[] dstBuf, within the desired dimensions. Setting this to 0 is the same as setting it to the width of the JPEG image (in other words, the width will not be considered when determining the scaled image size.) This parameter is - ignored if the source image is a YUV image.
      stride - pixels per line of the destination image. Normally, this + ignored if the source image is a YUV image.
      stride - pixels per line of the destination image. Normally, this should be set to scaledWidth, but you can use this to, for instance, decompress the JPEG image into a region of a larger image. NOTE: if the source image is a JPEG image, then scaledWidth can be determined by calling - scalingFactor.getScaled(jpegWidth) - or by calling getScaledWidth(int, int). If the source image is a + scalingFactor.getScaled(jpegWidth) + or by calling getScaledWidth(int, int). If the source image is a YUV image, then scaledWidth is the width of the YUV image. Setting this parameter to 0 is the equivalent of setting it to - scaledWidth.
      desiredHeight - If the source image is a JPEG image, then this + scaledWidth.
      desiredHeight - If the source image is a JPEG image, then this specifies the desired height (in pixels) of the decompressed image (or image region.) If the desired destination image dimensions are different than the source image dimensions, then TurboJPEG will use scaling in the @@ -1221,161 +1088,157 @@ public void decompress(int[] dstBuf, within the desired dimensions. Setting this to 0 is the same as setting it to the height of the JPEG image (in other words, the height will not be considered when determining the scaled image size.) This parameter is - ignored if the source image is a YUV image.
      pixelFormat - pixel format of the decompressed image (one of - TJ.PF_*)
      flags - the bitwise OR of one or more of - TJ.FLAG_* -
      Throws: -
      java.lang.Exception
      - - -
      - -

      -decompress

      -
      -public void decompress(java.awt.image.BufferedImage dstImage,
      -                       int flags)
      -                throws java.lang.Exception
      -
      -
      Decompress the JPEG source image or decode the YUV source image associated + ignored if the source image is a YUV image.
      pixelFormat - pixel format of the decompressed image (one of + TJ.PF_*)
      flags - the bitwise OR of one or more of + TJ.FLAG_*
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + +
      +
    • +

      decompress

      +
      public void decompress(java.awt.image.BufferedImage dstImage,
      +              int flags)
      +                throws java.lang.Exception
      +
      Decompress the JPEG source image or decode the YUV source image associated with this decompressor instance and output a decompressed/decoded image to - the given BufferedImage instance. -

      -

      -
      Parameters:
      dstImage - a BufferedImage instance that will receive + the given BufferedImage instance.
      +
      Parameters:
      dstImage - a BufferedImage instance that will receive the decompressed/decoded image. If the source image is a JPEG image, then the width and height of the BufferedImage instance must match one of the scaled image sizes that TurboJPEG is capable of generating from the JPEG image. If the source image is a YUV image, then the width and height of the BufferedImage instance must match the width and - height of the YUV image.
      flags - the bitwise OR of one or more of - TJ.FLAG_* -
      Throws: -
      java.lang.Exception
      - - -
      - -

      -decompress

      -
      -public java.awt.image.BufferedImage decompress(int desiredWidth,
      -                                               int desiredHeight,
      -                                               int bufferedImageType,
      -                                               int flags)
      -                                        throws java.lang.Exception
      -
      -
      Decompress the JPEG source image or decode the YUV source image associated + height of the YUV image.
      flags - the bitwise OR of one or more of + TJ.FLAG_*
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + +
      +
    • +

      decompress

      +
      public java.awt.image.BufferedImage decompress(int desiredWidth,
      +                                      int desiredHeight,
      +                                      int bufferedImageType,
      +                                      int flags)
      +                                        throws java.lang.Exception
      +
      Decompress the JPEG source image or decode the YUV source image associated with this decompressor instance and return a BufferedImage - instance containing the decompressed/decoded image. -

      -

      -
      Parameters:
      desiredWidth - see - decompress(byte[], int, int, int, int, int, int, int) for - description
      desiredHeight - see - decompress(byte[], int, int, int, int, int, int, int) for - description
      bufferedImageType - the image type of the BufferedImage + instance containing the decompressed/decoded image.
      +
      Parameters:
      desiredWidth - see + decompress(byte[], int, int, int, int, int, int, int) for + description
      desiredHeight - see + decompress(byte[], int, int, int, int, int, int, int) for + description
      bufferedImageType - the image type of the BufferedImage instance that will be created (for instance, - BufferedImage.TYPE_INT_RGB)
      flags - the bitwise OR of one or more of - TJ.FLAG_* -
      Returns:
      a BufferedImage instance containing the - decompressed/decoded image -
      Throws: -
      java.lang.Exception
      - - -
      - -

      -close

      -
      -public void close()
      -           throws java.lang.Exception
      -
      -
      Free the native structures associated with this decompressor instance. -

      -

      - -
      Throws: -
      java.lang.Exception
      -
      -
      -
      - -

      -finalize

      -
      -protected void finalize()
      -                 throws java.lang.Throwable
      -
      -
      -
      Overrides:
      finalize in class java.lang.Object
      -
      -
      - -
      Throws: -
      java.lang.Throwable
      -
      -
      + BufferedImage.TYPE_INT_RGB)
      flags - the bitwise OR of one or more of + TJ.FLAG_*
      +
      Returns:
      a BufferedImage instance containing the + decompressed/decoded image
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + +
      +
    • +

      close

      +
      public void close()
      +           throws java.lang.Exception
      +
      Free the native structures associated with this decompressor instance.
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + +
      +
    • +

      finalize

      +
      protected void finalize()
      +                 throws java.lang.Throwable
      +
      +
      Overrides:
      +
      finalize in class java.lang.Object
      +
      Throws:
      +
      java.lang.Throwable
      +
    • +
    + + + + + + -
    - - - - - - - - - - - - - - - - - - -
    - -
    - + + +
    + + +
    + + + - -
    - - - + + diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJScalingFactor.html b/java/doc/org/libjpegturbo/turbojpeg/TJScalingFactor.html index af29fc56..1b901477 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/TJScalingFactor.html +++ b/java/doc/org/libjpegturbo/turbojpeg/TJScalingFactor.html @@ -1,356 +1,336 @@ - - - - -TJScalingFactor - - - - - - - - - - - -
    - - +//--> + + - - - - - - - - - - - - - - - - -
    - -
    - + + +
    + + +
    + + + - -
    -

    - -org.libjpegturbo.turbojpeg -
    -Class TJScalingFactor

    -
    -java.lang.Object
    -  extended by org.libjpegturbo.turbojpeg.TJScalingFactor
    -
    -
    -
    -
    public class TJScalingFactor
    extends java.lang.Object
    - - -

    -Fractional scaling factor -

    - -

    -


    - -

    - +

    +
    org.libjpegturbo.turbojpeg
    +

    Class TJScalingFactor

    +
    +
    +
      +
    • java.lang.Object
    • +
    • +
        +
      • org.libjpegturbo.turbojpeg.TJScalingFactor
      • +
      +
    • +
    +
    +
      +
    • +
      +
      +
      public class TJScalingFactor
      +extends java.lang.Object
      +
      Fractional scaling factor
      +
    • +
    +
    +
    +
      +
    • - - - - - - - - - -
      -Constructor Summary
      TJScalingFactor(int num, - int denom) - -
      -           
      -  +
        +
      • + + +

        Constructor Summary

        + + + + + + + + +
        Constructors 
        Constructor and Description
        TJScalingFactor(int num, + int denom) 
        +
      • +
      - - - - - - - - - - - - - - - - - - - - - - - - - - -
      -Method Summary
      - booleanequals(TJScalingFactor other) - -
      -          Returns true or false, depending on whether this instance and - other have the same numerator and denominator.
      - intgetDenom() - -
      -          Returns denominator
      - intgetNum() - -
      -          Returns numerator
      - intgetScaled(int dimension) - -
      -          Returns the scaled value of dimension.
      - booleanisOne() - -
      -          Returns true or false, depending on whether this instance is equal to - 1/1.
      - - - - - - - -
      Methods inherited from class java.lang.Object
      clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      -  -

      - +

        +
      • + + +

        Method Summary

        + + + + + + + + + + + + + + + + + + + + + + + + + + +
        Methods 
        Modifier and TypeMethod and Description
        booleanequals(TJScalingFactor other) +
        Returns true or false, depending on whether this instance and + other have the same numerator and denominator.
        +
        intgetDenom() +
        Returns denominator
        +
        intgetNum() +
        Returns numerator
        +
        intgetScaled(int dimension) +
        Returns the scaled value of dimension.
        +
        booleanisOne() +
        Returns true or false, depending on whether this instance is equal to + 1/1.
        +
        +
          +
        • + + +

          Methods inherited from class java.lang.Object

          +clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
        • +
        +
      • +
      +
    • +
    +
    +
    +
      +
    • - - - - - - -
      -Constructor Detail
      - -

      -TJScalingFactor

      -
      -public TJScalingFactor(int num,
      -                       int denom)
      -                throws java.lang.Exception
      -
      -
      - -
      Throws: -
      java.lang.Exception
      -
      - +
        +
      • + + +

        Constructor Detail

        + + + +
          +
        • +

          TJScalingFactor

          +
          public TJScalingFactor(int num,
          +               int denom)
          +                throws java.lang.Exception
          +
          Throws:
          +
          java.lang.Exception
          +
        • +
        +
      • +
      - - - - - - -
      -Method Detail
      - -

      -getNum

      -
      -public int getNum()
      -
      -
      Returns numerator -

      -

      - -
      Returns:
      numerator
      -
      -
      -
      - -

      -getDenom

      -
      -public int getDenom()
      -
      -
      Returns denominator -

      -

      - -
      Returns:
      denominator
      -
      -
      -
      - -

      -getScaled

      -
      -public int getScaled(int dimension)
      -
      -
      Returns the scaled value of dimension. This function +
        +
      • + + +

        Method Detail

        + + + +
          +
        • +

          getNum

          +
          public int getNum()
          +
          Returns numerator
          +
          Returns:
          numerator
          +
        • +
        + + + +
          +
        • +

          getDenom

          +
          public int getDenom()
          +
          Returns denominator
          +
          Returns:
          denominator
          +
        • +
        + + + +
          +
        • +

          getScaled

          +
          public int getScaled(int dimension)
          +
          Returns the scaled value of dimension. This function performs the integer equivalent of - ceil(dimension * scalingFactor). -

          -

          - -
          Returns:
          the scaled value of dimension
          -
          -
      -
      - -

      -equals

      -
      -public boolean equals(TJScalingFactor other)
      -
      -
      Returns true or false, depending on whether this instance and - other have the same numerator and denominator. -

      -

      - -
      Returns:
      true or false, depending on whether this instance and - other have the same numerator and denominator
      -
      -
      -
      - -

      -isOne

      -
      -public boolean isOne()
      -
      -
      Returns true or false, depending on whether this instance is equal to - 1/1. -

      -

      - -
      Returns:
      true or false, depending on whether this instance is equal to - 1/1
      -
      -
      + ceil(dimension * scalingFactor).
    +
    Returns:
    the scaled value of dimension
    + + + + + +
      +
    • +

      equals

      +
      public boolean equals(TJScalingFactor other)
      +
      Returns true or false, depending on whether this instance and + other have the same numerator and denominator.
      +
      Returns:
      true or false, depending on whether this instance and + other have the same numerator and denominator
      +
    • +
    + + + +
      +
    • +

      isOne

      +
      public boolean isOne()
      +
      Returns true or false, depending on whether this instance is equal to + 1/1.
      +
      Returns:
      true or false, depending on whether this instance is equal to + 1/1
      +
    • +
    + + + + +
    + -
    - - - - - - - - - - - - - - - - - - -
    - -
    - + + +
    + + +
    + + + - -
    - - - + + diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJTransform.html b/java/doc/org/libjpegturbo/turbojpeg/TJTransform.html index 3a68c9f8..b4bd5cc7 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/TJTransform.html +++ b/java/doc/org/libjpegturbo/turbojpeg/TJTransform.html @@ -1,767 +1,712 @@ - - - - -TJTransform - - - - - - - - - - - -
    - - +//--> + + - - - - - - - - - - - - - - - - -
    - -
    - + + +
    + + +
    + + + - -
    -

    - -org.libjpegturbo.turbojpeg -
    -Class TJTransform

    -
    -java.lang.Object
    -  extended by java.awt.geom.RectangularShape
    -      extended by java.awt.geom.Rectangle2D
    -          extended by java.awt.Rectangle
    -              extended by org.libjpegturbo.turbojpeg.TJTransform
    -
    -
    -
    All Implemented Interfaces:
    java.awt.Shape, java.io.Serializable, java.lang.Cloneable
    -
    -
    -
    -
    public class TJTransform
    extends java.awt.Rectangle
    - - -

    -Lossless transform parameters -

    - -

    -

    -
    See Also:
    Serialized Form
    -
    - -

    +

    +
    org.libjpegturbo.turbojpeg
    +

    Class TJTransform

    +
    +
    +
      +
    • java.lang.Object
    • +
    • +
        +
      • java.awt.geom.RectangularShape
      • +
      • +
          +
        • java.awt.geom.Rectangle2D
        • +
        • +
            +
          • java.awt.Rectangle
          • +
          • +
              +
            • org.libjpegturbo.turbojpeg.TJTransform
            • +
            +
          • +
          +
        • +
        +
      • +
      +
    • +
    +
    +
      +
    • +
      +
      All Implemented Interfaces:
      +
      java.awt.Shape, java.io.Serializable, java.lang.Cloneable
      +
      +
      +
      +
      public class TJTransform
      +extends java.awt.Rectangle
      +
      Lossless transform parameters
      +
      See Also:
      Serialized Form
      +
    • +
    +
    +
    +
      +
    • - - - - - - -
      -Nested Class Summary
      - - - - - - - -
      Nested classes/interfaces inherited from class java.awt.geom.Rectangle2D
      java.awt.geom.Rectangle2D.Double, java.awt.geom.Rectangle2D.Float
      -  +
        +
      • + + +

        Nested Class Summary

        +
          +
        • + + +

          Nested classes/interfaces inherited from class java.awt.geom.Rectangle2D

          +java.awt.geom.Rectangle2D.Double, java.awt.geom.Rectangle2D.Float
        • +
        +
      • +
      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      -Field Summary
      - TJCustomFiltercf - -
      -          Custom filter instance
      -static intNUMOP - -
      -          The number of lossless transform operations
      - intop - -
      -          Transform operation (one of OP_*)
      -static intOP_HFLIP - -
      -          Flip (mirror) image horizontally.
      -static intOP_NONE - -
      -          Do not transform the position of the image pixels.
      -static intOP_ROT180 - -
      -          Rotate image 180 degrees.
      -static intOP_ROT270 - -
      -          Rotate image counter-clockwise by 90 degrees.
      -static intOP_ROT90 - -
      -          Rotate image clockwise by 90 degrees.
      -static intOP_TRANSPOSE - -
      -          Transpose image (flip/mirror along upper left to lower right axis).
      -static intOP_TRANSVERSE - -
      -          Transverse transpose image (flip/mirror along upper right to lower left - axis).
      -static intOP_VFLIP - -
      -          Flip (mirror) image vertically.
      -static intOPT_CROP - -
      -          This option will enable lossless cropping.
      -static intOPT_GRAY - -
      -          This option will discard the color data in the input image and produce - a grayscale output image.
      -static intOPT_NOOUTPUT - -
      -          This option will prevent TJTransformer.transform() from outputting a JPEG image for this - particular transform.
      -static intOPT_PERFECT - -
      -          This option will cause TJTransformer.transform() to throw an exception if the transform is not - perfect.
      -static intOPT_TRIM - -
      -          This option will discard any partial MCU blocks that cannot be - transformed.
      - intoptions - -
      -          Transform options (bitwise OR of one or more of OPT_*)
      - - - - - - - -
      Fields inherited from class java.awt.Rectangle
      height, width, x, y
      - - - - - - - -
      Fields inherited from class java.awt.geom.Rectangle2D
      OUT_BOTTOM, OUT_LEFT, OUT_RIGHT, OUT_TOP
      -  +
        +
      • + + +

        Field Summary

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        Fields 
        Modifier and TypeField and Description
        TJCustomFiltercf +
        Custom filter instance
        +
        static intNUMOP +
        The number of lossless transform operations
        +
        intop +
        Transform operation (one of OP_*)
        +
        static intOP_HFLIP +
        Flip (mirror) image horizontally.
        +
        static intOP_NONE +
        Do not transform the position of the image pixels.
        +
        static intOP_ROT180 +
        Rotate image 180 degrees.
        +
        static intOP_ROT270 +
        Rotate image counter-clockwise by 90 degrees.
        +
        static intOP_ROT90 +
        Rotate image clockwise by 90 degrees.
        +
        static intOP_TRANSPOSE +
        Transpose image (flip/mirror along upper left to lower right axis).
        +
        static intOP_TRANSVERSE +
        Transverse transpose image (flip/mirror along upper right to lower left + axis).
        +
        static intOP_VFLIP +
        Flip (mirror) image vertically.
        +
        static intOPT_CROP +
        This option will enable lossless cropping.
        +
        static intOPT_GRAY +
        This option will discard the color data in the input image and produce + a grayscale output image.
        +
        static intOPT_NOOUTPUT +
        This option will prevent TJTransformer.transform() from outputting a JPEG image for this + particular transform.
        +
        static intOPT_PERFECT +
        This option will cause TJTransformer.transform() to throw an exception if the transform is not + perfect.
        +
        static intOPT_TRIM +
        This option will discard any partial MCU blocks that cannot be + transformed.
        +
        intoptions +
        Transform options (bitwise OR of one or more of OPT_*)
        +
        +
          +
        • + + +

          Fields inherited from class java.awt.Rectangle

          +height, width, x, y
        • +
        +
          +
        • + + +

          Fields inherited from class java.awt.geom.Rectangle2D

          +OUT_BOTTOM, OUT_LEFT, OUT_RIGHT, OUT_TOP
        • +
        +
      • +
      - - - - - - - - - - - - - - - -
      -Constructor Summary
      TJTransform() - -
      -          Create a new lossless transform instance.
      TJTransform(int x, - int y, - int w, - int h, - int op, - int options, - TJCustomFilter cf) - -
      -          Create a new lossless transform instance with the given parameters.
      TJTransform(java.awt.Rectangle r, - int op, - int options, - TJCustomFilter cf) - -
      -          Create a new lossless transform instance with the given parameters.
      -  +
        +
      • + + +

        Constructor Summary

        + + + + + + + + + + + + + + +
        Constructors 
        Constructor and Description
        TJTransform() +
        Create a new lossless transform instance.
        +
        TJTransform(int x, + int y, + int w, + int h, + int op, + int options, + TJCustomFilter cf) +
        Create a new lossless transform instance with the given parameters.
        +
        TJTransform(java.awt.Rectangle r, + int op, + int options, + TJCustomFilter cf) +
        Create a new lossless transform instance with the given parameters.
        +
        +
      • +
      - - - - - - -
      -Method Summary
      - - - - - - - -
      Methods inherited from class java.awt.Rectangle
      add, add, add, contains, contains, contains, contains, createIntersection, createUnion, equals, getBounds, getBounds2D, getHeight, getLocation, getSize, getWidth, getX, getY, grow, inside, intersection, intersects, isEmpty, move, outcode, reshape, resize, setBounds, setBounds, setLocation, setLocation, setRect, setSize, setSize, toString, translate, union
      - - - - - - - -
      Methods inherited from class java.awt.geom.Rectangle2D
      add, add, add, contains, contains, getPathIterator, getPathIterator, hashCode, intersect, intersects, intersectsLine, intersectsLine, outcode, setFrame, setRect, union
      - - - - - - - -
      Methods inherited from class java.awt.geom.RectangularShape
      clone, contains, contains, getCenterX, getCenterY, getFrame, getMaxX, getMaxY, getMinX, getMinY, intersects, setFrame, setFrame, setFrameFromCenter, setFrameFromCenter, setFrameFromDiagonal, setFrameFromDiagonal
      - - - - - - - -
      Methods inherited from class java.lang.Object
      finalize, getClass, notify, notifyAll, wait, wait, wait
      - - - - - - - -
      Methods inherited from interface java.awt.Shape
      contains, contains, contains, contains, getPathIterator, getPathIterator, intersects, intersects
      -  -

      - +

        +
      • + + +

        Method Summary

        +
          +
        • + + +

          Methods inherited from class java.awt.Rectangle

          +add, add, add, contains, contains, contains, contains, createIntersection, createUnion, equals, getBounds, getBounds2D, getHeight, getLocation, getSize, getWidth, getX, getY, grow, inside, intersection, intersects, isEmpty, move, outcode, reshape, resize, setBounds, setBounds, setLocation, setLocation, setRect, setSize, setSize, toString, translate, union
        • +
        +
          +
        • + + +

          Methods inherited from class java.awt.geom.Rectangle2D

          +add, add, add, contains, contains, getPathIterator, getPathIterator, hashCode, intersect, intersects, intersectsLine, intersectsLine, outcode, setFrame, setRect, union
        • +
        +
          +
        • + + +

          Methods inherited from class java.awt.geom.RectangularShape

          +clone, contains, contains, getCenterX, getCenterY, getFrame, getMaxX, getMaxY, getMinX, getMinY, intersects, setFrame, setFrame, setFrameFromCenter, setFrameFromCenter, setFrameFromDiagonal, setFrameFromDiagonal
        • +
        +
          +
        • + + +

          Methods inherited from class java.lang.Object

          +finalize, getClass, notify, notifyAll, wait, wait, wait
        • +
        +
          +
        • + + +

          Methods inherited from interface java.awt.Shape

          +contains, contains, contains, contains, getPathIterator, getPathIterator, intersects, intersects
        • +
        +
      • +
      +
    • +
    +
    +
    +
      +
    • - - - - - - -
      -Field Detail
      - -

      -NUMOP

      -
      -public static final int NUMOP
      -
      -
      The number of lossless transform operations -

      -

      -
      See Also:
      Constant Field Values
      -
      -
      - -

      -OP_NONE

      -
      -public static final int OP_NONE
      -
      -
      Do not transform the position of the image pixels. -

      -

      -
      See Also:
      Constant Field Values
      -
      -
      - -

      -OP_HFLIP

      -
      -public static final int OP_HFLIP
      -
      -
      Flip (mirror) image horizontally. This transform is imperfect if there - are any partial MCU blocks on the right edge. -

      -

      -
      See Also:
      OPT_PERFECT, -Constant Field Values
      -
      -
      - -

      -OP_VFLIP

      -
      -public static final int OP_VFLIP
      -
      -
      Flip (mirror) image vertically. This transform is imperfect if there are - any partial MCU blocks on the bottom edge. -

      -

      -
      See Also:
      OPT_PERFECT, -Constant Field Values
      -
      -
      - -

      -OP_TRANSPOSE

      -
      -public static final int OP_TRANSPOSE
      -
      -
      Transpose image (flip/mirror along upper left to lower right axis). This - transform is always perfect. -

      -

      -
      See Also:
      OPT_PERFECT, -Constant Field Values
      -
      -
      - -

      -OP_TRANSVERSE

      -
      -public static final int OP_TRANSVERSE
      -
      -
      Transverse transpose image (flip/mirror along upper right to lower left +
        +
      • + + +

        Field Detail

        + + + +
          +
        • +

          NUMOP

          +
          public static final int NUMOP
          +
          The number of lossless transform operations
          +
          See Also:
          Constant Field Values
          +
        • +
        + + + +
          +
        • +

          OP_NONE

          +
          public static final int OP_NONE
          +
          Do not transform the position of the image pixels.
          +
          See Also:
          Constant Field Values
          +
        • +
        + + + +
          +
        • +

          OP_HFLIP

          +
          public static final int OP_HFLIP
          +
          Flip (mirror) image horizontally. This transform is imperfect if there + are any partial MCU blocks on the right edge.
          +
          See Also:
          OPT_PERFECT, +Constant Field Values
          +
        • +
        + + + +
          +
        • +

          OP_VFLIP

          +
          public static final int OP_VFLIP
          +
          Flip (mirror) image vertically. This transform is imperfect if there are + any partial MCU blocks on the bottom edge.
          +
          See Also:
          OPT_PERFECT, +Constant Field Values
          +
        • +
        + + + +
          +
        • +

          OP_TRANSPOSE

          +
          public static final int OP_TRANSPOSE
          +
          Transpose image (flip/mirror along upper left to lower right axis). This + transform is always perfect.
          +
          See Also:
          OPT_PERFECT, +Constant Field Values
          +
        • +
        + + + +
          +
        • +

          OP_TRANSVERSE

          +
          public static final int OP_TRANSVERSE
          +
          Transverse transpose image (flip/mirror along upper right to lower left axis). This transform is imperfect if there are any partial MCU blocks in - the image. -

          -

          -
          See Also:
          OPT_PERFECT, -Constant Field Values
          -
      -
      - -

      -OP_ROT90

      -
      -public static final int OP_ROT90
      -
      -
      Rotate image clockwise by 90 degrees. This transform is imperfect if - there are any partial MCU blocks on the bottom edge. -

      -

      -
      See Also:
      OPT_PERFECT, -Constant Field Values
      -
      -
      - -

      -OP_ROT180

      -
      -public static final int OP_ROT180
      -
      -
      Rotate image 180 degrees. This transform is imperfect if there are any - partial MCU blocks in the image. -

      -

      -
      See Also:
      OPT_PERFECT, -Constant Field Values
      -
      -
      - -

      -OP_ROT270

      -
      -public static final int OP_ROT270
      -
      -
      Rotate image counter-clockwise by 90 degrees. This transform is imperfect - if there are any partial MCU blocks on the right edge. -

      -

      -
      See Also:
      OPT_PERFECT, -Constant Field Values
      -
      -
      - -

      -OPT_PERFECT

      -
      -public static final int OPT_PERFECT
      -
      -
      This option will cause TJTransformer.transform() to throw an exception if the transform is not + the image.
    +
    See Also:
    OPT_PERFECT, +Constant Field Values
    + + + + + +
      +
    • +

      OP_ROT90

      +
      public static final int OP_ROT90
      +
      Rotate image clockwise by 90 degrees. This transform is imperfect if + there are any partial MCU blocks on the bottom edge.
      +
      See Also:
      OPT_PERFECT, +Constant Field Values
      +
    • +
    + + + +
      +
    • +

      OP_ROT180

      +
      public static final int OP_ROT180
      +
      Rotate image 180 degrees. This transform is imperfect if there are any + partial MCU blocks in the image.
      +
      See Also:
      OPT_PERFECT, +Constant Field Values
      +
    • +
    + + + +
      +
    • +

      OP_ROT270

      +
      public static final int OP_ROT270
      +
      Rotate image counter-clockwise by 90 degrees. This transform is imperfect + if there are any partial MCU blocks on the right edge.
      +
      See Also:
      OPT_PERFECT, +Constant Field Values
      +
    • +
    + + + +
      +
    • +

      OPT_PERFECT

      +
      public static final int OPT_PERFECT
      +
      This option will cause TJTransformer.transform() to throw an exception if the transform is not perfect. Lossless transforms operate on MCU blocks, whose size depends on the level of chrominance subsampling used. If the image's width or height - is not evenly divisible by the MCU block size (see TJ.getMCUWidth(int) - and TJ.getMCUHeight(int)), then there will be partial MCU blocks on the + is not evenly divisible by the MCU block size (see TJ.getMCUWidth(int) + and TJ.getMCUHeight(int)), then there will be partial MCU blocks on the right and/or bottom edges. It is not possible to move these partial MCU blocks to the top or left of the image, so any transform that would require that is "imperfect." If this option is not specified, then any partial MCU blocks that cannot be transformed will be left in place, which - will create odd-looking strips on the right or bottom edge of the image. -

      -

      -
      See Also:
      Constant Field Values
      - -
      - -

      -OPT_TRIM

      -
      -public static final int OPT_TRIM
      -
      -
      This option will discard any partial MCU blocks that cannot be - transformed. -

      -

      -
      See Also:
      Constant Field Values
      -
      -
      - -

      -OPT_CROP

      -
      -public static final int OPT_CROP
      -
      -
      This option will enable lossless cropping. -

      -

      -
      See Also:
      Constant Field Values
      -
      -
      - -

      -OPT_GRAY

      -
      -public static final int OPT_GRAY
      -
      -
      This option will discard the color data in the input image and produce - a grayscale output image. -

      -

      -
      See Also:
      Constant Field Values
      -
      -
      - -

      -OPT_NOOUTPUT

      -
      -public static final int OPT_NOOUTPUT
      -
      -
      This option will prevent TJTransformer.transform() from outputting a JPEG image for this + will create odd-looking strips on the right or bottom edge of the image.
      +
      See Also:
      Constant Field Values
      +
    • +
    + + + +
      +
    • +

      OPT_TRIM

      +
      public static final int OPT_TRIM
      +
      This option will discard any partial MCU blocks that cannot be + transformed.
      +
      See Also:
      Constant Field Values
      +
    • +
    + + + +
      +
    • +

      OPT_CROP

      +
      public static final int OPT_CROP
      +
      This option will enable lossless cropping.
      +
      See Also:
      Constant Field Values
      +
    • +
    + + + +
      +
    • +

      OPT_GRAY

      +
      public static final int OPT_GRAY
      +
      This option will discard the color data in the input image and produce + a grayscale output image.
      +
      See Also:
      Constant Field Values
      +
    • +
    + + + +
      +
    • +

      OPT_NOOUTPUT

      +
      public static final int OPT_NOOUTPUT
      +
      This option will prevent TJTransformer.transform() from outputting a JPEG image for this particular transform. This can be used in conjunction with a custom filter to capture the transformed DCT coefficients without transcoding - them. -

      -

      -
      See Also:
      Constant Field Values
      - -
      - -

      -op

      -
      -public int op
      -
      -
      Transform operation (one of OP_*) -

      -

      -
      -
      -
      - -

      -options

      -
      -public int options
      -
      -
      Transform options (bitwise OR of one or more of OPT_*) -

      -

      -
      -
      -
      - -

      -cf

      -
      -public TJCustomFilter cf
      -
      -
      Custom filter instance -

      -

      -
      -
      - + them.
      +
      See Also:
      Constant Field Values
      +
    • +
    + + + +
      +
    • +

      op

      +
      public int op
      +
      Transform operation (one of OP_*)
      +
    • +
    + + + +
      +
    • +

      options

      +
      public int options
      +
      Transform options (bitwise OR of one or more of OPT_*)
      +
    • +
    + + + + + + - - - - - - -
    -Constructor Detail
    - -

    -TJTransform

    -
    -public TJTransform()
    -
    -
    Create a new lossless transform instance. -

    -

    -
    - -

    -TJTransform

    -
    -public TJTransform(int x,
    -                   int y,
    -                   int w,
    -                   int h,
    -                   int op,
    -                   int options,
    -                   TJCustomFilter cf)
    -            throws java.lang.Exception
    -
    -
    Create a new lossless transform instance with the given parameters. -

    -

    -
    Parameters:
    x - the left boundary of the cropping region. This must be evenly - divisible by the MCU block width (see TJ.getMCUWidth(int))
    y - the upper boundary of the cropping region. This must be evenly - divisible by the MCU block height (see TJ.getMCUHeight(int))
    w - the width of the cropping region. Setting this to 0 is the +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        TJTransform

        +
        public TJTransform()
        +
        Create a new lossless transform instance.
        +
      • +
      + + + +
        +
      • +

        TJTransform

        +
        public TJTransform(int x,
        +           int y,
        +           int w,
        +           int h,
        +           int op,
        +           int options,
        +           TJCustomFilter cf)
        +            throws java.lang.Exception
        +
        Create a new lossless transform instance with the given parameters.
        +
        Parameters:
        x - the left boundary of the cropping region. This must be evenly + divisible by the MCU block width (see TJ.getMCUWidth(int))
        y - the upper boundary of the cropping region. This must be evenly + divisible by the MCU block height (see TJ.getMCUHeight(int))
        w - the width of the cropping region. Setting this to 0 is the equivalent of setting it to (width of the source JPEG image - - x).
        h - the height of the cropping region. Setting this to 0 is the + x).
        h - the height of the cropping region. Setting this to 0 is the equivalent of setting it to (height of the source JPEG image - - y).
        op - one of the transform operations (OP_*)
        options - the bitwise OR of one or more of the transform options - (OPT_*)
        cf - an instance of an object that implements the TJCustomFilter interface, or null if no custom filter is needed -
        Throws: -
        java.lang.Exception
        -
    -
    - -

    -TJTransform

    -
    -public TJTransform(java.awt.Rectangle r,
    -                   int op,
    -                   int options,
    -                   TJCustomFilter cf)
    -            throws java.lang.Exception
    -
    -
    Create a new lossless transform instance with the given parameters. -

    -

    -
    Parameters:
    r - a Rectangle instance that specifies the cropping - region. See TJTransform(int, int, int, int, int, int, TJCustomFilter) for more - detail.
    op - one of the transform operations (OP_*)
    options - the bitwise OR of one or more of the transform options - (OPT_*)
    cf - an instance of an object that implements the TJCustomFilter interface, or null if no custom filter is needed -
    Throws: -
    java.lang.Exception
    -
    + y).
    op - one of the transform operations (OP_*)
    options - the bitwise OR of one or more of the transform options + (OPT_*)
    cf - an instance of an object that implements the TJCustomFilter interface, or null if no custom filter is needed
    +
    Throws:
    +
    java.lang.Exception
    + + + + + +
      +
    • +

      TJTransform

      +
      public TJTransform(java.awt.Rectangle r,
      +           int op,
      +           int options,
      +           TJCustomFilter cf)
      +            throws java.lang.Exception
      +
      Create a new lossless transform instance with the given parameters.
      +
      Parameters:
      r - a Rectangle instance that specifies the cropping + region. See TJTransform(int, int, int, int, int, int, TJCustomFilter) for more + detail.
      op - one of the transform operations (OP_*)
      options - the bitwise OR of one or more of the transform options + (OPT_*)
      cf - an instance of an object that implements the TJCustomFilter interface, or null if no custom filter is needed
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + + +
    + -
    - - - - - - - - - - - - - - - - - - -
    - -
    - + + +
    + + +
    + + + - -
    - - - + + diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJTransformer.html b/java/doc/org/libjpegturbo/turbojpeg/TJTransformer.html index 75fedf75..3be18ec6 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/TJTransformer.html +++ b/java/doc/org/libjpegturbo/turbojpeg/TJTransformer.html @@ -1,301 +1,291 @@ - - - - -TJTransformer - - - - - - - - - - - -
    - - +//--> + + - - - - - - - - - - - - - - - - -
    - -
    - + + +
    + + +
    + + + - -
    -

    - -org.libjpegturbo.turbojpeg -
    -Class TJTransformer

    -
    -java.lang.Object
    -  extended by org.libjpegturbo.turbojpeg.TJDecompressor
    -      extended by org.libjpegturbo.turbojpeg.TJTransformer
    -
    -
    -
    -
    public class TJTransformer
    extends TJDecompressor
    - - -

    -TurboJPEG lossless transformer -

    - -

    -


    - -

    +

    +
    org.libjpegturbo.turbojpeg
    +

    Class TJTransformer

    +
    +
    + +
    +
      +
    • +
      +
      +
      public class TJTransformer
      +extends TJDecompressor
      +
      TurboJPEG lossless transformer
      +
    • +
    +
    +
    +
      +
    • - - - - - - -
      -Field Summary
      - - - - - - - -
      Fields inherited from class org.libjpegturbo.turbojpeg.TJDecompressor
      handle, jpegBuf, jpegBufSize, srcColorspace, srcHeight, srcSubsamp, srcWidth, yuvImage
      -  + - - - - - - - - - - - - - - + +
      -Constructor Summary
      TJTransformer() - -
      -          Create a TurboJPEG lossless transformer instance.
      TJTransformer(byte[] jpegImage) - -
      -          Create a TurboJPEG lossless transformer instance and associate the JPEG - image stored in jpegImage with the newly created instance.
      TJTransformer(byte[] jpegImage, - int imageSize) - -
      -          Create a TurboJPEG lossless transformer instance and associate the JPEG +
        +
      • + + +

        Constructor Summary

        + + + + + + + + + + + + + - -
        Constructors 
        Constructor and Description
        TJTransformer() +
        Create a TurboJPEG lossless transformer instance.
        +
        TJTransformer(byte[] jpegImage) +
        Create a TurboJPEG lossless transformer instance and associate the JPEG + image stored in jpegImage with the newly created instance.
        +
        TJTransformer(byte[] jpegImage, + int imageSize) +
        Create a TurboJPEG lossless transformer instance and associate the JPEG image of length imageSize bytes stored in - jpegImage with the newly created instance.
        -  + jpegImage with the newly created instance. +
      +
    • +
    - - - - - - - - - - - - - + + + + + +
    -Method Summary
    - int[]getTransformedSizes() - -
    -          Returns an array containing the sizes of the transformed JPEG images - generated by the most recent transform operation.
    - voidtransform(byte[][] dstBufs, - TJTransform[] transforms, - int flags) - -
    -          Losslessly transform the JPEG image associated with this transformer +
    TJDecompressor[]transform(TJTransform[] transforms, + int flags) +
    Losslessly transform the JPEG image associated with this transformer + instance and return an array of TJDecompressor instances, each of + which has a transformed JPEG image associated with it.
    +
    + +
      +
    • + + +

      Methods inherited from class java.lang.Object

      +clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • +
    + + + + +
    +
    +
      +
    • - - - - - - -
      -Constructor Detail
      - -

      -TJTransformer

      -
      -public TJTransformer()
      -              throws java.lang.Exception
      -
      -
      Create a TurboJPEG lossless transformer instance. -

      -

      - -
      Throws: -
      java.lang.Exception
      -
      -
      - -

      -TJTransformer

      -
      -public TJTransformer(byte[] jpegImage)
      -              throws java.lang.Exception
      -
      -
      Create a TurboJPEG lossless transformer instance and associate the JPEG - image stored in jpegImage with the newly created instance. -

      -

      -
      Parameters:
      jpegImage - JPEG image buffer (size of the JPEG image is assumed to - be the length of the array) -
      Throws: -
      java.lang.Exception
      -
      -
      - -

      -TJTransformer

      -
      -public TJTransformer(byte[] jpegImage,
      -                     int imageSize)
      -              throws java.lang.Exception
      -
      -
      Create a TurboJPEG lossless transformer instance and associate the JPEG +
        +
      • + + +

        Constructor Detail

        + + + +
          +
        • +

          TJTransformer

          +
          public TJTransformer()
          +              throws java.lang.Exception
          +
          Create a TurboJPEG lossless transformer instance.
          +
          Throws:
          +
          java.lang.Exception
          +
        • +
        + + + +
          +
        • +

          TJTransformer

          +
          public TJTransformer(byte[] jpegImage)
          +              throws java.lang.Exception
          +
          Create a TurboJPEG lossless transformer instance and associate the JPEG + image stored in jpegImage with the newly created instance.
          +
          Parameters:
          jpegImage - JPEG image buffer (size of the JPEG image is assumed to + be the length of the array)
          +
          Throws:
          +
          java.lang.Exception
          +
        • +
        + + + +
          +
        • +

          TJTransformer

          +
          public TJTransformer(byte[] jpegImage,
          +             int imageSize)
          +              throws java.lang.Exception
          +
          Create a TurboJPEG lossless transformer instance and associate the JPEG image of length imageSize bytes stored in - jpegImage with the newly created instance. -

          -

          -
          Parameters:
          jpegImage - JPEG image buffer
          imageSize - size of the JPEG image (in bytes) -
          Throws: -
          java.lang.Exception
          -
      - + jpegImage with the newly created instance.
    +
    Parameters:
    jpegImage - JPEG image buffer
    imageSize - size of the JPEG image (in bytes)
    +
    Throws:
    +
    java.lang.Exception
    + + + + - - - - - - -
    -Method Detail
    - -

    -transform

    -
    -public void transform(byte[][] dstBufs,
    -                      TJTransform[] transforms,
    -                      int flags)
    -               throws java.lang.Exception
    -
    -
    Losslessly transform the JPEG image associated with this transformer +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        transform

        +
        public void transform(byte[][] dstBufs,
        +             TJTransform[] transforms,
        +             int flags)
        +               throws java.lang.Exception
        +
        Losslessly transform the JPEG image associated with this transformer instance into one or more JPEG images stored in the given destination buffers. Lossless transforms work by moving the raw coefficients from one JPEG image structure to another without altering the values of the @@ -306,123 +296,121 @@ public void transform(byte[][] dstBufs, size of the destination image. Thus, this method provides a means of generating multiple transformed images from the same source or of applying multiple transformations simultaneously, in order to eliminate the need to - read the source coefficients multiple times. -

        -

        -
        Parameters:
        dstBufs - an array of image buffers. dstbufs[i] will + read the source coefficients multiple times.
        +
        Parameters:
        dstBufs - an array of image buffers. dstbufs[i] will receive a JPEG image that has been transformed using the parameters in - transforms[i]. Use TJ.bufSize(int, int, int) to determine the + transforms[i]. Use TJ.bufSize(int, int, int) to determine the maximum size for each buffer based on the transformed or cropped width and - height and the level of subsampling used in the source image.
        transforms - an array of TJTransform instances, each of + height and the level of subsampling used in the source image.
        transforms - an array of TJTransform instances, each of which specifies the transform parameters and/or cropping region for the - corresponding transformed output image
        flags - the bitwise OR of one or more of - TJ.FLAG_* -
        Throws: -
        java.lang.Exception
        -
    -
    -
    - -

    -transform

    -
    -public TJDecompressor[] transform(TJTransform[] transforms,
    -                                  int flags)
    -                           throws java.lang.Exception
    -
    -
    Losslessly transform the JPEG image associated with this transformer - instance and return an array of TJDecompressor instances, each of - which has a transformed JPEG image associated with it. -

    -

    -
    Parameters:
    transforms - an array of TJTransform instances, each of + corresponding transformed output image
    flags - the bitwise OR of one or more of + TJ.FLAG_*
    +
    Throws:
    +
    java.lang.Exception
    + + + + + +
      +
    • +

      transform

      +
      public TJDecompressor[] transform(TJTransform[] transforms,
      +                         int flags)
      +                           throws java.lang.Exception
      +
      Losslessly transform the JPEG image associated with this transformer + instance and return an array of TJDecompressor instances, each of + which has a transformed JPEG image associated with it.
      +
      Parameters:
      transforms - an array of TJTransform instances, each of which specifies the transform parameters and/or cropping region for the - corresponding transformed output image
      flags - the bitwise OR of one or more of - TJ.FLAG_* -
      Returns:
      an array of TJDecompressor instances, each of - which has a transformed JPEG image associated with it -
      Throws: -
      java.lang.Exception
      -
    -
    -
    - -

    -getTransformedSizes

    -
    -public int[] getTransformedSizes()
    -                          throws java.lang.Exception
    -
    -
    Returns an array containing the sizes of the transformed JPEG images - generated by the most recent transform operation. -

    -

    - -
    Returns:
    an array containing the sizes of the transformed JPEG images - generated by the most recent transform operation -
    Throws: -
    java.lang.Exception
    -
    -
    + corresponding transformed output image
    flags - the bitwise OR of one or more of + TJ.FLAG_*
    +
    Returns:
    an array of TJDecompressor instances, each of + which has a transformed JPEG image associated with it
    +
    Throws:
    +
    java.lang.Exception
    + + + + + +
      +
    • +

      getTransformedSizes

      +
      public int[] getTransformedSizes()
      +                          throws java.lang.Exception
      +
      Returns an array containing the sizes of the transformed JPEG images + generated by the most recent transform operation.
      +
      Returns:
      an array containing the sizes of the transformed JPEG images + generated by the most recent transform operation
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + + + +
    + -
    - - - - - - - - - - - - - - - - - - -
    - -
    - + + +
    + + +
    + + + - -
    - - - + + diff --git a/java/doc/org/libjpegturbo/turbojpeg/YUVImage.html b/java/doc/org/libjpegturbo/turbojpeg/YUVImage.html index 5edc6b09..8659aedc 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/YUVImage.html +++ b/java/doc/org/libjpegturbo/turbojpeg/YUVImage.html @@ -1,103 +1,100 @@ - - - - -YUVImage - - - - - - - - - - - -
    - - +//--> + + - - - - - - - - - - - - - - - - -
    - -
    - + + +
    + + +
    + + + - -
    -

    - -org.libjpegturbo.turbojpeg -
    -Class YUVImage

    -
    -java.lang.Object
    -  extended by org.libjpegturbo.turbojpeg.YUVImage
    -
    -
    -
    -
    public class YUVImage
    extends java.lang.Object
    - - -

    -This class encapsulates a YUV planar image buffer and the metadata +

    +
    org.libjpegturbo.turbojpeg
    +

    Class YUVImage

    +
    +
    +
      +
    • java.lang.Object
    • +
    • +
        +
      • org.libjpegturbo.turbojpeg.YUVImage
      • +
      +
    • +
    +
    +
      +
    • +
      +
      +
      public class YUVImage
      +extends java.lang.Object
      +
      This class encapsulates a YUV planar image buffer and the metadata associated with it. The TurboJPEG API allows both the JPEG compression and decompression pipelines to be split into stages: YUV encode, compress from YUV, decompress to YUV, and YUV decode. A YUVImage instance @@ -120,464 +117,417 @@ This class encapsulates a YUV planar image buffer and the metadata luminance plane would be 36 x 35 bytes, and each of the chrominance planes would be 18 x 35 bytes. If you specify, for instance, a line padding of 4 bytes on top of this, then the luminance plane would be 36 x 35 bytes, and - each of the chrominance planes would be 20 x 35 bytes. -

      - -

      -


      - -

      + each of the chrominance planes would be 20 x 35 bytes.

      +
    • +
    +
    +
    +
      +
    • - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      -Field Summary
      -protected  longhandle - -
      -           
      -protected  byte[]yuvBuf - -
      -           
      -protected  intyuvHeight - -
      -           
      -protected  intyuvPad - -
      -           
      -protected  intyuvSubsamp - -
      -           
      -protected  intyuvWidth - -
      -           
      -  +
        +
      • + + +

        Field Summary

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        Fields 
        Modifier and TypeField and Description
        protected longhandle 
        protected byte[]yuvBuf 
        protected intyuvHeight 
        protected intyuvPad 
        protected intyuvSubsamp 
        protected intyuvWidth 
        +
      • +
      - - - - - - - - - - - - -
      -Constructor Summary
      YUVImage(byte[] yuvImage, - int width, - int pad, - int height, - int subsamp) - -
      -          Create a YUVImage instance from an existing YUV planar image - buffer.
      YUVImage(int width, - int pad, - int height, - int subsamp) - -
      -          Create a YUVImage instance with a new image buffer.
      -  +
        +
      • + + +

        Constructor Summary

        + + + + + + + + + + + +
        Constructors 
        Constructor and Description
        YUVImage(byte[] yuvImage, + int width, + int pad, + int height, + int subsamp) +
        Create a YUVImage instance from an existing YUV planar image + buffer.
        +
        YUVImage(int width, + int pad, + int height, + int subsamp) +
        Create a YUVImage instance with a new image buffer.
        +
        +
      • +
      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      -Method Summary
      - byte[]getBuf() - -
      -          Returns the YUV image buffer
      - intgetHeight() - -
      -          Returns the height of the YUV image.
      - intgetPad() - -
      -          Returns the line padding used in the YUV image buffer.
      - intgetSize() - -
      -          Returns the size (in bytes) of the YUV image buffer
      - intgetSubsamp() - -
      -          Returns the level of chrominance subsampling used in the YUV image.
      - intgetWidth() - -
      -          Returns the width of the YUV image.
      - - - - - - - -
      Methods inherited from class java.lang.Object
      clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      -  -

      - +

        +
      • + + +

        Method Summary

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        Methods 
        Modifier and TypeMethod and Description
        byte[]getBuf() +
        Returns the YUV image buffer
        +
        intgetHeight() +
        Returns the height of the YUV image.
        +
        intgetPad() +
        Returns the line padding used in the YUV image buffer.
        +
        intgetSize() +
        Returns the size (in bytes) of the YUV image buffer
        +
        intgetSubsamp() +
        Returns the level of chrominance subsampling used in the YUV image.
        +
        intgetWidth() +
        Returns the width of the YUV image.
        +
        +
          +
        • + + +

          Methods inherited from class java.lang.Object

          +clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
        • +
        +
      • +
      +
    • +
    +
    +
    +
      +
    • - - - - - - -
      -Field Detail
      - -

      -handle

      -
      -protected long handle
      -
      -
      -
      -
      -
      - -

      -yuvBuf

      -
      -protected byte[] yuvBuf
      -
      -
      -
      -
      -
      - -

      -yuvPad

      -
      -protected int yuvPad
      -
      -
      -
      -
      -
      - -

      -yuvWidth

      -
      -protected int yuvWidth
      -
      -
      -
      -
      -
      - -

      -yuvHeight

      -
      -protected int yuvHeight
      -
      -
      -
      -
      -
      - -

      -yuvSubsamp

      -
      -protected int yuvSubsamp
      -
      -
      -
      -
      - +
        +
      • + + +

        Field Detail

        + + + +
          +
        • +

          handle

          +
          protected long handle
          +
        • +
        + + + +
          +
        • +

          yuvBuf

          +
          protected byte[] yuvBuf
          +
        • +
        + + + +
          +
        • +

          yuvPad

          +
          protected int yuvPad
          +
        • +
        + + + +
          +
        • +

          yuvWidth

          +
          protected int yuvWidth
          +
        • +
        + + + +
          +
        • +

          yuvHeight

          +
          protected int yuvHeight
          +
        • +
        + + + +
          +
        • +

          yuvSubsamp

          +
          protected int yuvSubsamp
          +
        • +
        +
      • +
      - - - - - - -
      -Constructor Detail
      - -

      -YUVImage

      -
      -public YUVImage(int width,
      -                int pad,
      -                int height,
      -                int subsamp)
      -         throws java.lang.Exception
      -
      -
      Create a YUVImage instance with a new image buffer. -

      -

      -
      Parameters:
      width - width (in pixels) of the YUV image
      pad - Each line of each plane in the YUV image buffer will be padded - to this number of bytes (must be a power of 2.)
      height - height (in pixels) of the YUV image
      subsamp - the level of chrominance subsampling to be used in the YUV - image (one of TJ.SAMP_*) -
      Throws: -
      java.lang.Exception
      -
      -
      - -

      -YUVImage

      -
      -public YUVImage(byte[] yuvImage,
      -                int width,
      -                int pad,
      -                int height,
      -                int subsamp)
      -         throws java.lang.Exception
      -
      -
      Create a YUVImage instance from an existing YUV planar image - buffer. -

      -

      -
      Parameters:
      yuvImage - image buffer that contains or will contain YUV planar - image data. See above for a description of the image - format. You can use TJ.bufSizeYUV(int, int, int, int) to determine the appropriate - size for this buffer.
      width - width (in pixels) of the YUV image
      pad - the line padding used in the YUV image buffer. For +
        +
      • + + +

        Constructor Detail

        + + + +
          +
        • +

          YUVImage

          +
          public YUVImage(int width,
          +        int pad,
          +        int height,
          +        int subsamp)
          +         throws java.lang.Exception
          +
          Create a YUVImage instance with a new image buffer.
          +
          Parameters:
          width - width (in pixels) of the YUV image
          pad - Each line of each plane in the YUV image buffer will be padded + to this number of bytes (must be a power of 2.)
          height - height (in pixels) of the YUV image
          subsamp - the level of chrominance subsampling to be used in the YUV + image (one of TJ.SAMP_*)
          +
          Throws:
          +
          java.lang.Exception
          +
        • +
        + + + +
          +
        • +

          YUVImage

          +
          public YUVImage(byte[] yuvImage,
          +        int width,
          +        int pad,
          +        int height,
          +        int subsamp)
          +         throws java.lang.Exception
          +
          Create a YUVImage instance from an existing YUV planar image + buffer.
          +
          Parameters:
          yuvImage - image buffer that contains or will contain YUV planar + image data. See above for a description of the image + format. You can use TJ.bufSizeYUV(int, int, int, int) to determine the appropriate + size for this buffer.
          width - width (in pixels) of the YUV image
          pad - the line padding used in the YUV image buffer. For instance, if each line in each plane of the buffer is padded to the - nearest multiple of 4 bytes, then pad should be set to 4.
          height - height (in pixels) of the YUV image
          subsamp - the level of chrominance subsampling used in the YUV - image (one of TJ.SAMP_*) -
          Throws: -
          java.lang.Exception
          -
      - + nearest multiple of 4 bytes, then pad should be set to 4.
      height - height (in pixels) of the YUV image
      subsamp - the level of chrominance subsampling used in the YUV + image (one of TJ.SAMP_*)
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    + + - - - - - - -
    -Method Detail
    - -

    -getWidth

    -
    -public int getWidth()
    -             throws java.lang.Exception
    -
    -
    Returns the width of the YUV image. -

    -

    - -
    Returns:
    the width of the YUV image -
    Throws: -
    java.lang.Exception
    -
    -
    -
    - -

    -getHeight

    -
    -public int getHeight()
    -              throws java.lang.Exception
    -
    -
    Returns the height of the YUV image. -

    -

    - -
    Returns:
    the height of the YUV image -
    Throws: -
    java.lang.Exception
    -
    -
    -
    - -

    -getPad

    -
    -public int getPad()
    -           throws java.lang.Exception
    -
    -
    Returns the line padding used in the YUV image buffer. -

    -

    - -
    Returns:
    the line padding used in the YUV image buffer -
    Throws: -
    java.lang.Exception
    -
    -
    -
    - -

    -getSubsamp

    -
    -public int getSubsamp()
    -               throws java.lang.Exception
    -
    -
    Returns the level of chrominance subsampling used in the YUV image. See - TJ.SAMP_*. -

    -

    - -
    Returns:
    the level of chrominance subsampling used in the YUV image -
    Throws: -
    java.lang.Exception
    -
    -
    -
    - -

    -getBuf

    -
    -public byte[] getBuf()
    -              throws java.lang.Exception
    -
    -
    Returns the YUV image buffer -

    -

    - -
    Returns:
    the YUV image buffer -
    Throws: -
    java.lang.Exception
    -
    -
    -
    - -

    -getSize

    -
    -public int getSize()
    -            throws java.lang.Exception
    -
    -
    Returns the size (in bytes) of the YUV image buffer -

    -

    - -
    Returns:
    the size (in bytes) of the YUV image buffer -
    Throws: -
    java.lang.Exception
    -
    -
    +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getWidth

        +
        public int getWidth()
        +             throws java.lang.Exception
        +
        Returns the width of the YUV image.
        +
        Returns:
        the width of the YUV image
        +
        Throws:
        +
        java.lang.Exception
        +
      • +
      + + + +
        +
      • +

        getHeight

        +
        public int getHeight()
        +              throws java.lang.Exception
        +
        Returns the height of the YUV image.
        +
        Returns:
        the height of the YUV image
        +
        Throws:
        +
        java.lang.Exception
        +
      • +
      + + + +
        +
      • +

        getPad

        +
        public int getPad()
        +           throws java.lang.Exception
        +
        Returns the line padding used in the YUV image buffer.
        +
        Returns:
        the line padding used in the YUV image buffer
        +
        Throws:
        +
        java.lang.Exception
        +
      • +
      + + + +
        +
      • +

        getSubsamp

        +
        public int getSubsamp()
        +               throws java.lang.Exception
        +
        Returns the level of chrominance subsampling used in the YUV image. See + TJ.SAMP_*.
        +
        Returns:
        the level of chrominance subsampling used in the YUV image
        +
        Throws:
        +
        java.lang.Exception
        +
      • +
      + + + +
        +
      • +

        getBuf

        +
        public byte[] getBuf()
        +              throws java.lang.Exception
        +
        Returns the YUV image buffer
        +
        Returns:
        the YUV image buffer
        +
        Throws:
        +
        java.lang.Exception
        +
      • +
      + + + +
        +
      • +

        getSize

        +
        public int getSize()
        +            throws java.lang.Exception
        +
        Returns the size (in bytes) of the YUV image buffer
        +
        Returns:
        the size (in bytes) of the YUV image buffer
        +
        Throws:
        +
        java.lang.Exception
        +
      • +
      +
    • +
    + + +
    +
    -
    - - - - - - - - - - - - - - - - - - -
    - -
    - + + +
    + + +
    + + + - -
    - - - + + diff --git a/java/doc/org/libjpegturbo/turbojpeg/package-frame.html b/java/doc/org/libjpegturbo/turbojpeg/package-frame.html index 215bdeac..7cb8fa0b 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/package-frame.html +++ b/java/doc/org/libjpegturbo/turbojpeg/package-frame.html @@ -1,53 +1,27 @@ - - - - -org.libjpegturbo.turbojpeg - - - - - - - - - - -org.libjpegturbo.turbojpeg - - - - -
    -Interfaces  - -
    -TJCustomFilter
    - - - - - - -
    -Classes  - -
    -TJ -
    -TJCompressor -
    -TJDecompressor -
    -TJScalingFactor -
    -TJTransform -
    -TJTransformer -
    -YUVImage
    - - - - + + + +org.libjpegturbo.turbojpeg + + + +

    org.libjpegturbo.turbojpeg

    + + + diff --git a/java/doc/org/libjpegturbo/turbojpeg/package-summary.html b/java/doc/org/libjpegturbo/turbojpeg/package-summary.html index 12c047b1..c5e2f7d8 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/package-summary.html +++ b/java/doc/org/libjpegturbo/turbojpeg/package-summary.html @@ -1,190 +1,183 @@ - - - - -org.libjpegturbo.turbojpeg - - - - - - - - - - - -
    - - +//--> + + - - - - - - - - - - - - -
    - -
    - + + + + + - -
    -

    -Package org.libjpegturbo.turbojpeg -

    - - - - - - - - - -
    -Interface Summary
    TJCustomFilterCustom filter callback interface
    -  - -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -Class Summary
    TJTurboJPEG utility class (cannot be instantiated)
    TJCompressorTurboJPEG compressor
    TJDecompressorTurboJPEG decompressor
    TJScalingFactorFractional scaling factor
    TJTransformLossless transform parameters
    TJTransformerTurboJPEG lossless transformer
    YUVImageThis class encapsulates a YUV planar image buffer and the metadata - associated with it.
    -  - -

    -

    -
    -
    - - +
    +

    Package org.libjpegturbo.turbojpeg

    +
    +
    +
      +
    • + + + + + + + + + + + + +
      Interface Summary 
      InterfaceDescription
      TJCustomFilter +
      Custom filter callback interface
      +
      +
    • +
    • + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Class Summary 
      ClassDescription
      TJ +
      TurboJPEG utility class (cannot be instantiated)
      +
      TJCompressor +
      TurboJPEG compressor
      +
      TJDecompressor +
      TurboJPEG decompressor
      +
      TJScalingFactor +
      Fractional scaling factor
      +
      TJTransform +
      Lossless transform parameters
      +
      TJTransformer +
      TurboJPEG lossless transformer
      +
      YUVImage +
      This class encapsulates a YUV planar image buffer and the metadata + associated with it.
      +
      +
    • +
    +
    - - - - - - - - - - - - -
    - -
    - + + + + + - -
    - - - + + diff --git a/java/doc/org/libjpegturbo/turbojpeg/package-tree.html b/java/doc/org/libjpegturbo/turbojpeg/package-tree.html index 59102783..1033ee56 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/package-tree.html +++ b/java/doc/org/libjpegturbo/turbojpeg/package-tree.html @@ -1,159 +1,143 @@ - - - - -org.libjpegturbo.turbojpeg Class Hierarchy - - - - - - - - - - - -
    - - +//--> + + - - - - - - - - - - - - -
    - -
    - + + + + + - -
    -
    -

    -Hierarchy For Package org.libjpegturbo.turbojpeg -

    -
    -

    -Class Hierarchy -

    -
      -
    • java.lang.Object
        -
      • java.awt.geom.RectangularShape (implements java.lang.Cloneable, java.awt.Shape) -
          -
        • java.awt.geom.Rectangle2D
            -
          • java.awt.Rectangle (implements java.io.Serializable, java.awt.Shape) - -
          -
        -
      • org.libjpegturbo.turbojpeg.TJ
      • org.libjpegturbo.turbojpeg.TJCompressor
      • org.libjpegturbo.turbojpeg.TJDecompressor -
      • org.libjpegturbo.turbojpeg.TJScalingFactor
      • org.libjpegturbo.turbojpeg.YUVImage
      -
    -

    -Interface Hierarchy -

    - -
    - - +
    +

    Hierarchy For Package org.libjpegturbo.turbojpeg

    +
    +
    +

    Class Hierarchy

    +
      +
    • java.lang.Object +
        +
      • java.awt.geom.RectangularShape (implements java.lang.Cloneable, java.awt.Shape) +
          +
        • java.awt.geom.Rectangle2D +
            +
          • java.awt.Rectangle (implements java.io.Serializable, java.awt.Shape) + +
          • +
          +
        • +
        +
      • +
      • org.libjpegturbo.turbojpeg.TJ
      • +
      • org.libjpegturbo.turbojpeg.TJCompressor
      • +
      • org.libjpegturbo.turbojpeg.TJDecompressor + +
      • +
      • org.libjpegturbo.turbojpeg.TJScalingFactor
      • +
      • org.libjpegturbo.turbojpeg.YUVImage
      • +
      +
    • +
    +

    Interface Hierarchy

    + +
    - - - - - - - - - - - - -
    - -
    - + + + + + - -
    - - - + + diff --git a/java/doc/overview-tree.html b/java/doc/overview-tree.html index 563b5796..eae18a13 100644 --- a/java/doc/overview-tree.html +++ b/java/doc/overview-tree.html @@ -1,161 +1,147 @@ - - - - -Class Hierarchy - - - - - - - - - - - -
    - - +//--> + + - - - - - - - - - - - - -
    - -
    - + + + + + - -
    -
    -

    -Hierarchy For All Packages

    -
    -
    -
    Package Hierarchies:
    org.libjpegturbo.turbojpeg
    -
    -

    -Class Hierarchy -

    -
      -
    • java.lang.Object
        -
      • java.awt.geom.RectangularShape (implements java.lang.Cloneable, java.awt.Shape) -
          -
        • java.awt.geom.Rectangle2D
            -
          • java.awt.Rectangle (implements java.io.Serializable, java.awt.Shape) - -
          -
        -
      • org.libjpegturbo.turbojpeg.TJ
      • org.libjpegturbo.turbojpeg.TJCompressor
      • org.libjpegturbo.turbojpeg.TJDecompressor -
      • org.libjpegturbo.turbojpeg.TJScalingFactor
      • org.libjpegturbo.turbojpeg.YUVImage
      -
    -

    -Interface Hierarchy -

    - -
    - - +
    +

    Hierarchy For All Packages

    +Package Hierarchies: + +
    +
    +

    Class Hierarchy

    +
      +
    • java.lang.Object +
        +
      • java.awt.geom.RectangularShape (implements java.lang.Cloneable, java.awt.Shape) +
          +
        • java.awt.geom.Rectangle2D +
            +
          • java.awt.Rectangle (implements java.io.Serializable, java.awt.Shape) + +
          • +
          +
        • +
        +
      • +
      • org.libjpegturbo.turbojpeg.TJ
      • +
      • org.libjpegturbo.turbojpeg.TJCompressor
      • +
      • org.libjpegturbo.turbojpeg.TJDecompressor + +
      • +
      • org.libjpegturbo.turbojpeg.TJScalingFactor
      • +
      • org.libjpegturbo.turbojpeg.YUVImage
      • +
      +
    • +
    +

    Interface Hierarchy

    + +
    - - - - - - - - - - - - -
    - -
    - + + + + + - -
    - - - + + diff --git a/java/doc/resources/background.gif b/java/doc/resources/background.gif new file mode 100644 index 0000000000000000000000000000000000000000..f471940fde2f39ef8943a6af9569bcf986b1579b GIT binary patch literal 2313 zcmV+k3HJ6!Nk%w1VKM-40OkMy00030|NlK(aXwsfKV5S}VtGJbbVOr%L0@%CZH88Q zl{{NzcR^uxNo<2iYk@pjY)*5FJz8x~bc{)B zfk z+1T6M-s9WdW8dcJ-wO*3@9+W*5AY543-j^$^!EPz_4eHZ2#>)41`h@dc!2OAgN6$a zCS2I?;lqgx6IR4nkpTe;1RN0f=zxMq2O=q`94V5d$&e>Unta)^<;;^G3>e7yp=ZvW z6DIW3xpSvaogXF?_4%`@(V;s}NR^5J!3hrtJV@1QRV&r5S*L!zYE|rss${iFkg&!? zTN5V#)~=bmMorwgZsEpdOE)iExo+FO-8;8Kga{=HbSQCnF=E6W3?o*|ID%uwi5**> zJXy127Y9m+=HQ|PhXWi+xNwoWv}n_%Pq%(e+H~mGqhq5kv4Mo|-n~g|7!F*xZ{xv< zCpXS~dGg^IGK?4@J-T%b(XnUHFul6n<@2&4)zzyO2) z3Q8`i0+UKY*`$}e9mmp;tg*))`|PsK1|hAo%u0K$vDwm4gaSkm0j{`26k#qAKmbuhxZ#cquDR>B zD{s8+&TH-uNg$C#68QG}1HMBHfrP&L@@w$F_!itRzXdCN@V|LDAu%3!IDtq1#1UV7 z#1RxvT=B(DWbCoU5l=ia$Pp`Hgb_?Mp@hmtxZDI2N-)v#$}PXVvdm1d>@v(v`0TUJ zF)Pu89(q`zv=w^nVTIF3@3BYIPA}c`(@ZCAwbNBEt@PDUKe5CTR8aB66IE1!w%Amt zy+jpcn~k>GZpVFg+H6x{_uOksvBlq0OyT$6TyQZ37k(cOxZr|JEx1sGm<(M9gH z-~PMqyn|tT=))UN`|-FFFUA#KToK0fUOaz=7}Z~KeHhVC&%O27cTfHQ^WBU8z4p&T zp#>D|V}XShTD;Hx745Iz{`>K-Z$A|7!*Boo{mY;G21vjH8t{M!OrQc6$iN0V@PQDF zpadsK!3tXNf*8!81~qnXWuHZ)kytd=_y+ADWvw31ouV;CdZ#ya*(l7-A-C-Y^+iit8O zBy3*`Ls$|5Hn4m_^I^|C7{m7EFn|5vTk;|oywIgCc9Bb*=L+Y$)M>9GC<|HGs@6NB zHLY%03!dDf=eDRt2O6lVSFRcsuWZEwU?=z$CZ0W?#VJfdN>HG(l%oKpyiftJc|Y)xkjSJYCrQal-0PC~()T9xwF!Jf zVi1UA#3BBbh(i8r5&v#Pz!cF41KjbCc?4u2@@Q~oKLirt2TM30;y6b+zyX2`Yl9u; z`0$3;v0-YUp&7IIT!9-C*e{wE9>Kx3D)-;0v)C; KYxQGgum%9JOA&7X diff --git a/java/doc/resources/tab.gif b/java/doc/resources/tab.gif new file mode 100644 index 0000000000000000000000000000000000000000..1a73a83be11dde2d0003b716ca778fafc6f34ad7 GIT binary patch literal 291 zcmZ?wbhEHbWM+_KxXJ(m|NsBLKh^ZZLaX-+EFVob+gGEtw?=DMmFBi`jWca}`|GrK zS84620CF`ibs3!R&_C0rf3ijIM6=$}M%|-Lx`!Hcc2;Oz>NdPT#q`cZlbij$jvbRk6R>8g*>}*b9E+WDwmpHAAxYzyT aU_pX{M6b8i>#Dq3onfZy}_nli%!Q$ZV%e&!tN2 zX3B0NWXQ443Eo1rUP86rLU>O>oTp%wt3Z{Tz&P*)Iraq^_@X;RtUFY!JxH|4U!>kw zxXwqo&R3Y=EsXaR!ng@y+y$%L1P3FZ4@N!j3m5MW74HcC->_JFuvlxLXiI=-OQ2|@ zpGc#>2-aN)<1RE9^`bB0`65VSK2>5m>CHs^YZCC)NX*NfbeT1%)Cxpu2_(6cCbLvjLY`hf1%*q}QO*%V4SfOu5Nqg~`-+(-76= za<`RA&(qDB^S!nIS^od5|Nk$KPXD8(qSB!f`M*{E?A^&yOW$08V^iNPK!%UNJ-@xmz>`pG2_%4I3QWk4UdtwP!GH$C%mo2K|$Ap=_)Y!#O($1@ohsUtR1k%wI*) z4*X&g==oWh`j{uP=HFm;Ye>0>UbDdtSp^~MaQ!L9I#)Ga?q}{@T#|qec*FkMLDenm zj^sCgk!^O^3o|vG!~2$$$7`C#4Ry zdQ!tui+J1*HyavK+4{`r+zvYHj9IsRt~@uEBOreWS8~2rXAR3!|7aTdr+x4|>@$Az z)b1t$gSB~6USxpfLmy^|_J_eNt*PI=ScO1SVH895N#`ef%IOh&o-2GIjK1s-JzkyZ z@r7O%hChz}kMHCM@Wqi^R-9t&%Fh^#9dVB0%ej@$=OjXA%XZdzCXf}c>SW26_z-Te z5b{}XWg&rELM=N*%aimp)k04t2c+`WAS>ZFIPWKvtyOI))HzpRA!T!b{tv?4NzF1v zNlP%#{&p@lFFEKvcroMAsI)mq?&`!e%l+-y&j9ZqhN}oG&dB=Pw09r+Q%m0cMujS# zs$a7!9VH`CC7k{!bV(J`rm%Jpj6&nLtWhPcy$onn$8G#ZdD9hxO<9k67Ya>K_7W~3 z&KYf14fq<{qHA7u6;>AOcomhdg?ianjr9uINt}*7w?g%z9{Q`(qRo@hDwSpGmxz&h&>%G%T(URL~=c>C{>y$K?+wLFp zy*M1@FTUKYV>8DeDIAIKM+!T5c-k&C4?Y~y^E zQCIc-=9~DiPtfVZB=_c3`qH3h|NXd^BcOQG`funSe)i5!NoA_r{b6PwzSDIXG+!(F z9CqJgo&~#7^VZHWj{u23q+NDCHn}GeWDC*(SW%{f4WMtP3l2jsO7*M)EX)#NLlsNnU4q@#jn0r#rsWsf^ngE0&ambG1f;Rj zfOk#_>1|25Z%?iI{0Yv8)DQfk>m1td?~}m0N%^k^u%EuUCc#ItmlY|epQ3YLWehYw zRU0qpPb#X&WU*UOU8et(s8x~WyYWYsgJCF+;U6@*nICY8)dk}IG+(#_Bz8zURd3HZ6qPE68U1%S{wL0 z;K{PDw2iRFIGG?(UiE9kT9?siuv4O{ z`dX2-eiXU3N)H2nT4V=AO^~J}sw+gr{&~qx%$$wlMv_JCWAMfcjYl}*Cfcf!adOY8 z8oLmJ{%49e+nLiVo#H9}wRk?UCzDz^>9TDxreVHzl~R*)?YU>Uu;J2eQ27O5`&X^8 z`94{)YWJQa#l0Fbz0N6B>j&8J;<%VuG6OYM9&QIdtueWjI3X;*dEtGiF@1AcvN4U> zG5SXIEXxB>)!mtQOztJLyeF78S*kLiU-!>PtQ_s~OMl~&y(hVVe$A5 zwo}E-DJ6${QP75?LsQ}Wl@MXwXMT4d>|?rD!g?jE>J^N*y;X}5FLe%d0_ zZ>eIBK6l@jkfw{p_YiDP;MS{jww{%j#?rk2z1J!HqE;Vd!TrCl_7UPef8;edI}wD6 zT&12Bxj&q}d4%$GHq+$~UYtWv`wI9k`89oKkCEK_E;-+O)(rhThjOM|kXDn{!W1Lo z`_?yQv=lp=-w()R<=0&c5%RWHY_fw@qb}uwFuPAGkl~@Kis}eE%MY@~6ZyWcF+llM zGyK`)(vn1F%%z=W7-Y=1$`w0Mv+-|#d};%JjCmw)Y1hOxwA|{}P%6LS4X`jQCGh`mR@=hGrr|cXa^Ipj;Mh)6mTqd1s_HmP0IxXT!w7YhoIHT>Hm#!;c@|L9OjV zsTlHE{Z;HWeM9^tPm-`|&nnl$%DRtNG1~?npUvgKPwKlaccEe4q!7YU3zykJnu6Sr z()LMXs_)^~u-ds7+wMff)RAJF?2?1H`_wDnt%MssYeB5;q~ojgVm6OHA6B>FG2erv z8&`|6<`=!EPKR^8Qlp5MiKwfxy4D`mN> ze$RKh_6*YJd4y0nnUZvwN%iY&^9xk@cM|5g#pZkc#N*(PH?^w&?ilTDMXFcd0`5!E zvgHS`=Lc|~1aO=L@L~eE*aP{90lc7qXY7GOs)3JH14T{(`K1D%tpvUT1-?F^1d4_S zJ#7yXkP3Q37bJlRQfv=mV-J3B8O*m5B%L3uW)S>|Jwy`|s6iK`sv0Z-3NcU(0knrG z5ChFXA@A9PUSdLI+(VU!!J1Mbw!~0VP^jZci2X|Nx0BF!24ObrAr>b=QtlyN4TAhn z!mQncJm~^m4MIafVLt_ewDUtO+e5w*!`(6A&H^F7i9s4t5&uBpNvh$nlTZjqTM5krNRRQ zqP)VR!|9@H>7qN_!+-)&_9s!^;gOvy5s~iEB&qP8{77&2NJMzZcsnJgSt_bYDzYU% zxQ#uuk3D*e7_*d5^?HW(^(WxICGf-mcmM((VStzIz%zFsm0;ZI3h=5OciJ#a%7I(IeGbFv+PP^?^sKBPrRBl<+qK^o%3fi=L9`la>-l4~p|hzAl~W zf=%(|NHgF7r5dJD+Cf08q-c(m;Epsldaz4cqHzTHT>)4xEe(cE0i~tf{Y0xs_1~Kv z+BYQ-TpEOch13;5YC9nHYEXhSv{ew=LV~nQL%UBQEgaDL2m?9u~v zEQmOvM=aB)Z$+eE38rs%AZR_)4>@2raqwH#Fji#xoLc&PS_TU^W8W(M0GqLdO~1yF z{sfHZ_sC#FX58(}d>RSkKZCz8%D7{cC3Z$Zh@52{31&V*W-@s~Z<8~aBeNcNW?e&O zsR(7fHOf}B&fsRqdZ(WK1e~s*o^uD6{YX9QJvqyWAqQXt*E>r$V94YK=X@8+{1cg> z*_i`a%alCJvbD~lCg&Q1Gk=|BzY)sejf9EHJ{s7lu4?ExCWR3jgTiET;exy{sW!Mg zuj*_YOf0@ScN~X0$7V6&KpL172rf|rA8?K<2+GelXw)NUk#@b4aT5MO%1ip4*ym}B-JI__S1R?CK z<4eW~bH;@H@tR55x}&JNSw_NvEPk)6E>XDt7*)4sgWuw+_vNZzmaS(tsi(57zcjA9 z@~XcHtzYq~IX|z*Md9mh>W~`sk3<^s7;EmyH4wcTdAo5NkUA2ofeG69{Gx7#i_*lt zQ7;N@xEo#nNRj&SbDHNnP0w#OE0{DZ$~7ySG%IN~zwd5Vu4&dnH>*OMb>&*VL^tbA zG;7y1t9dsYU$p3pw0x6mwGe6fjBYWsZ8e3q8f~-~cefgHxBangajI$kv(c*W-DZGp zbM$UgnP{_MYPXYX|6$u^deIhE(-xuGX2RVXqS+o~(iSV%;ZW1=Zqkut(r&xak^pT> zsp*I@X|-eOd^gb+sM(%3(E$|c47Y91mTU99Xe;4vFOTl5gmwVB+fvc3n2pwK?~Xd# zwrY{?CUj@~Msr?wXU0WKv2A$hq z`$V^gNq4(<*C=;4e4}$*uIC$5&uUHkM08J~N$>VV*VpdmLCuc!?!J9=-)VH;fo9)| zNN4m#^Kb9|`RF!^ZAT-z=bC8$do8~Tjc^o-aQjyc2(TW*d50E1#NW0pKb^~tf&OUlS+W}>0!m@!~1 z&TdSLhm`0u99c-z=oxYL8IFaGCDoFwFUP!1iJ%xF1UC4hhv*VR2451Pc0+kQGC)39C5 za81oV=$+xzZNYhn=RB-CTZ>Bevj)A3mi9|OS(dcy=N#Zm=Dza|z4Jd<=3IQ2CB>FiwH7{4Ej#+oa>M67 z!56)Km&2xJ|H7B;%~rJDuJ{rbZQiaX*e^$DEt~T$#h9(y#jg6>uX?boq!N}Q;EQth zYo1rjc15dETPw~*Ymu=lreoE9g^wb)ZcRe1yp1(Eo(rmqUYZXOU$BC_| zX{{&qE?E06wXm#v#cpKwE)jaydSaI`TkCCClr_lKMzPkyFT!R%VRn&sZSrchKx&4e~pJQcfViQxxl=T=7}#gYz7Pvoh`T#Jbab%2A2m zxh?A<`}A?8_GumBEcL;$x%gQb@PZ(If%ZE~D?ax#Km4a~+GV~!;Bb~qxxh@HHc|H6 zr%$^c9Dw~UQFWJv+81rCXS1vqqLfQ~-BtO63xCArGVA4T-}xPXYGHqB5h^+n5%$24 z(BROpi13J@*qFfR$oRMHel`=(zy zovs-UKHD3VkJ?hVeq!aA+8Fh4+NIlFhcC~UrR{4I#}K*u&z%68+P1*=q0B1r*2MY> z!9gYs*vlTO5v#8S>c#3goFmp>3iVKdU)NkjNV(s7tO4Wq?2M}o5Cj-*7;S=fEshOA zR*4$dm{ROvUamG%xL_tSW6}U$Nl=@91T;nC11o-iIVyVrfkd) zTCp;^tOy|_kuOFV$Nn=$AQJO9;&sZ&eDs^!r*m;Hw!)vpO1vcfj2EV{dJ?7ap0tq6 z$SwUVM*Vt+MS_`;bas-svPV|3POQi8G~?f^KOx4hg1He+Wd*s3Hl1{TfJS-+zv6vc zPoKiwr?7wECbub(IdB)9f_!kmUjBR*KY_z4E8_QA9xSr#G&@i5y^H`jB^I{|akh>W z%Cn3luOVY|8P>u>e^~#{$kmgX&-q>k{#pFbm2({(rtG<%nb0UCQ0%{Cy`F&~7}*we z@Of>ND_)V&XwN_+n~KjVorUQWZ*B6cld7ymQl{;rwlHl34K#}2YWxE+4CX@P&u6AfCda`&ZT1MOY69e-L@gNcAvwx8%1Z7lB4zc=_Cpt~&s ze%?;){1DB(PSK!^za967qF?lIjB~&06}Lf`cgh2qUiI^|$-VCTNE=hp&Ij}^A9&|* zQQrSqo3gn#_=z9j(y6f@T|OkJYv(fjwpz}$*U$|nLH2F zPNMuTS4g8 z*^hOlRh6~Mk}58;d477R>F^~aLO$dOXmhA*6zwIaHK()t2zKjo?j^NOJbh_=+71xg zO{Mgp7x?Z-1MKzoQ<+V2g#|e}|JawOPJZBL{o~PYdtWDX?jl##!Aiq|w>)vGJLipp zBK1xGhcvgSsQ;rn>+`>UmxlID{<~}7{y>SO^cyktN^Fsz!Z|B4?p*RKQG*8}SYBt{ zuFO{vJ?jgL{gUzYsnv(io}c0vlCp#*1vE?}KL^UZ&VF^TK+D;40CxX%j);%dCt;Z{ zAeMXC9JPWvKGwsCxx4w2iv_wNGG8l16AVI93rmc^c1>r(P||YE zpXa+=-&k995hfykL^J5S&vJF^ljR&`FE#ppNMM3%Omc!F)Mn{{&Ip#)JegbEJxud2 zn`wDVB~DMii5|H%m~51YeU1juNG3!+&?*uC#q@)z8q~`4yEL5I8}PtyA1IZ=52P$x zX)KhZt z7czUXBsy-8d`GVQ`90`wIh(Xt7v5j7h0t&ET~2M!Tb~4rN-xtK@8@mB*c(6QTwOS- z%9445_WY|cfm4?$nX$72&{~^mu}an^x^Da%=UU6YI;ur3+9L6I>raW5!=-Nzy(F2Z zwZlg7aM3NN5b{K|FB>s4R}|&Lr32_Ys{wwkECxo|rV@;5aHB25iUs7(6@dDpjN{Y%?C~UGp>*Q}K?)KKk64 zAn;@-dER}QG0L${jQ1cR75eM3-~ZTltTQ8%sm9x4Y`ve@ekMuvpA#Rh51@s6;6^&Q z!&M7^b%cea7FlZkPV9}@!bPBBfB&~XvGlE2T7V?IpM~OBmuK;OSt{~N`rL5c_I^de z9n*=@p|l;d`b_YIn8Aem1t7pp0=2-MCTIcJHlY z6x+mNLgi{JpwP)y(yzAFL2A#>bI&EwZE`PGvd*FQ!rx~6bUN&+Ij3)L;=595L#G;m8*^e?ap1`J5w7-q)*iUT_W9w8 z&xS-`i++HpWzY-a-)CWd0(pLW$A85P{Dy9r-=uPekNpN^yA}pJ7yWTZ>3iw4d6+IK zF%1XXkGcJm{0*vhSG5R1ySW;jctk9O==1-Mk?=Bl<{HE1p_@tx1s^+GoczYxj#B=i=kwQvEPrOt`<4W*pJw zbNjEqpr7B|Llc%m{V*QssV)im;pb00LUob=yFaU4`P_}ywU zt*QZl-bUsmh@L&zQaX4uHL&7YD(BOb9hH;;y;O-b-_O$4EFi1vCrMlz`dN|u?}HNO^aFQV{UZg_yy%nf>IXpulip!cR8|vNu7P*; zQye@}Qmj%(TB6`5E=c~w=LITF266XJ6X5xA7!OM1SE=~N*o3EP5Qqx!W<_+EMSLGo zqkC18AQ=0AK9=hgGQtrTovYc5^?Z^RLX?hlO-j&e1MXTTbfm>MS^=}!p>C>icUKdZ zBcNOb(6IJ!kq*e7N8Fx!!kPyn+2B2^2hd00+W^PUA&+S63jFE)bP5Tv+L5l~n(pu? zbeO|+K{{?pEow3?j0+dGVu)a6(0r{1Uj7{3 zxSsZ|BdMk>1-S}-;+`pk{Q5>H=tLRx+YqeenaSRsEX@gtPzz>j1A9g!C9kGtspY(- z%YL>NkVDE2z@}*;Q{=&5)yS;NupAmmibGUE4qte7aY6PcnXJgw>}ad(SW;@HtNurF ziV0_yHz=;Di%Tki6DW^tjkL`t%Ktct(ay zvuAOYoCu!Pm~@P5CIjk$bp`_iv{^l*Au{fB8mJK1>Macv?GL)**8*+JNvySIH5Y7i#1;!%NT!efc z;Z0*AOM&1VpR+6wIQxBM{xf`8T1V@#e<#QL}=YRwMkWG8%1(Fgj{iX)N zup{Txko(DqJWf=#Oi?Z!nra-?C{);TP`w|4>L+EKx1&P3swX<*#_50F!lD_$nQyuK??!UwA-{y)^QmMxoK1xIJ~uML{u;5!Z5tQyEL>;KaUd!_9FP zl2$QOI6V1`QdF|8gkdZsSpUqCjSBu(1H)r*vL#PEy)@Px>5TIk7_9o#Bj zzD&<1_k(ejk%qO6ak=GMmG5b7LTAA^KKq-Ey#z8(2wy2;Ot^oZI(MG@)~iY$RAnJt zu`ioyvR?Vws_tuK9hDqmel+)bP0kyxJV{7t=&3{b(@Hs1fs$9n45aq)IKknZa2H*7 z^P-ZDyOMdMj&-9{(-?dqo5I3Gy=K$!L%q>3^0N~o^2i0^_@^2nQv>S4B&=5_8^a^V zaY!NjyA5QgO&r#^CJcp&=!))MZ*CC&hvLEzWU*!IO=aYo{_yG+53H$XOAIQWnG`uD zLuuwTY6e8N^m5^AHQa}Y5Z#SdbEY;+x{oW?g;ie4CNYomRyQd2mv^L}T!>a5<*wTh>@>Qtwp~nejn`~DcZJI+QC-xU zoxz=5z0k%1;jBrGI%Th~FQElrAPr?E-Fv9|o09dPk=?>f)jFKL8PK|;w(cVDq>YWP zEfL7RGBv|<>f4IccND3wCi*V8`>#a$FPZu&a{V`W`me+Kuf_CJ)%IV%?5ByL^#3Q{ z&uBM5|34IKI>0_Tz{5OngXe#6w*N6;;5PH%9n%56%RaWA{wJ4%515Apdj`a62bp<> zM12OuV+QZ^55ATkViO(UWgg}%9C}kb^r~=BiDyWIXZWM&kb>Q?dd$#W`4KU|2#4qh zz;sZ>ZqS5h#Kdk$&1c9AHmDUdtmHE)CqH0RIAZEE;t(^+RXF+*FlJyk;?6Vn{&MsO zZ0HwY)b4Va!F1#s^N5$-s9(&mPa*Lu4>4SxXm~l|3?PR2jB1J!Q|(4#0i$lFME^-r zA~Q(2O+PHOdcVN((R8zqi>%+yx4PA5u&+jI zZ?)Fm8m-+`n!Bnrx0PvZE7!Q)Z+NTE@K(R!nO40sZF(n~bq_b_9H`UYU#q>pPJ3UC z_UeU>J7qcy%%`ks9)BNcS^GDOn z?oKkjHNoWO1e2?M#vd12e^_AscAnLnc~-CISiYWX`D%{k^H~<37unpMYJYdSv=Om2vbAM@`Qp{{SI=yP zj6WN*eEt0G$9EPX6FU%)-ho>hWTW!yzXBIo73<0umM-=@eG&niY^` zlG(|vuCl_x(X^Fob@=i{8+M5vWf7Bz=#aHGTNA;fZQyfbfueI8Z^639n`(DI%w^-^ zl`=@!u)r~Xf920-xd$Ab+S&PJY%K0H8a_J8uN3^_!K1_NV$*e#*Y*6|)XpiW=9H`*`Xx7W%v@7{XDma1?v0a%(K6rI&1!a YpWXKgmku8Vj|K)Vje`mzEKCg608Q#dYybcN literal 0 HcmV?d00001 diff --git a/java/doc/serialized-form.html b/java/doc/serialized-form.html index 8ba0661b..bbe18053 100644 --- a/java/doc/serialized-form.html +++ b/java/doc/serialized-form.html @@ -1,200 +1,150 @@ - - - - -Serialized Form - - - - - - - - - - - -
    - - +//--> + + - - - - - - - - - - - - -
    - -
    - + + + + + - -
    -
    -

    -Serialized Form

    -
    -
    - - - - - -
    -Package org.libjpegturbo.turbojpeg
    - -

    - - - - - -
    -Class org.libjpegturbo.turbojpeg.TJTransform extends java.awt.Rectangle implements Serializable
    - -

    -serialVersionUID: -127367705761430371L - -

    - - - - - -
    -Serialized Fields
    - -

    -op

    -
    -int op
    -
    -
    Transform operation (one of OP_*) -

    -

    -
    -
    -
    -

    -options

    -
    -int options
    -
    -
    Transform options (bitwise OR of one or more of OPT_*) -

    -

    -
    -
    -
    -

    -cf

    -
    -TJCustomFilter cf
    -
    -
    Custom filter instance -

    -

    -
    -
    - -

    -


    - - +
    +

    Serialized Form

    +
    +
    +
      +
    • +

      Package org.libjpegturbo.turbojpeg

      +
        +
      • + + +

        Class org.libjpegturbo.turbojpeg.TJTransform extends java.awt.Rectangle implements Serializable

        +
        +
        serialVersionUID:
        +
        -127367705761430371L
        +
        +
          +
        • + + +

          Serialized Fields

          +
            +
          • +

            op

            +
            int op
            +
            Transform operation (one of OP_*)
            +
          • +
          • +

            options

            +
            int options
            +
            Transform options (bitwise OR of one or more of OPT_*)
            +
          • +
          • +

            cf

            +
            TJCustomFilter cf
            +
            Custom filter instance
            +
          • +
          +
        • +
        +
      • +
      +
    • +
    +
    - - - - - - - - - - - - -
    - -
    - + + + + + - -
    - - - + + diff --git a/java/doc/stylesheet.css b/java/doc/stylesheet.css index 6ea9e516..0aeaa97f 100644 --- a/java/doc/stylesheet.css +++ b/java/doc/stylesheet.css @@ -1,29 +1,474 @@ /* Javadoc style sheet */ - -/* Define colors, fonts and other style attributes here to override the defaults */ - -/* Page background color */ -body { background-color: #FFFFFF; color:#000000 } - -/* Headings */ -h1 { font-size: 145% } - -/* Table colors */ -.TableHeadingColor { background: #CCCCFF; color:#000000 } /* Dark mauve */ -.TableSubHeadingColor { background: #EEEEFF; color:#000000 } /* Light mauve */ -.TableRowColor { background: #FFFFFF; color:#000000 } /* White */ - -/* Font used in left-hand frame lists */ -.FrameTitleFont { font-size: 100%; font-family: Helvetica, Arial, sans-serif; color:#000000 } -.FrameHeadingFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 } -.FrameItemFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 } - -/* Navigation bar fonts and colors */ -.NavBarCell1 { background-color:#EEEEFF; color:#000000} /* Light mauve */ -.NavBarCell1Rev { background-color:#00008B; color:#FFFFFF} /* Dark Blue */ -.NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;color:#000000;} -.NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;color:#FFFFFF;} - -.NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000} -.NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000} - +/* +Overall document style +*/ +body { + background-color:#ffffff; + color:#353833; + font-family:Arial, Helvetica, sans-serif; + font-size:76%; + margin:0; +} +a:link, a:visited { + text-decoration:none; + color:#4c6b87; +} +a:hover, a:focus { + text-decoration:none; + color:#bb7a2a; +} +a:active { + text-decoration:none; + color:#4c6b87; +} +a[name] { + color:#353833; +} +a[name]:hover { + text-decoration:none; + color:#353833; +} +pre { + font-size:1.3em; +} +h1 { + font-size:1.8em; +} +h2 { + font-size:1.5em; +} +h3 { + font-size:1.4em; +} +h4 { + font-size:1.3em; +} +h5 { + font-size:1.2em; +} +h6 { + font-size:1.1em; +} +ul { + list-style-type:disc; +} +code, tt { + font-size:1.2em; +} +dt code { + font-size:1.2em; +} +table tr td dt code { + font-size:1.2em; + vertical-align:top; +} +sup { + font-size:.6em; +} +/* +Document title and Copyright styles +*/ +.clear { + clear:both; + height:0px; + overflow:hidden; +} +.aboutLanguage { + float:right; + padding:0px 21px; + font-size:.8em; + z-index:200; + margin-top:-7px; +} +.legalCopy { + margin-left:.5em; +} +.bar a, .bar a:link, .bar a:visited, .bar a:active { + color:#FFFFFF; + text-decoration:none; +} +.bar a:hover, .bar a:focus { + color:#bb7a2a; +} +.tab { + background-color:#0066FF; + background-image:url(resources/titlebar.gif); + background-position:left top; + background-repeat:no-repeat; + color:#ffffff; + padding:8px; + width:5em; + font-weight:bold; +} +/* +Navigation bar styles +*/ +.bar { + background-image:url(resources/background.gif); + background-repeat:repeat-x; + color:#FFFFFF; + padding:.8em .5em .4em .8em; + height:auto;/*height:1.8em;*/ + font-size:1em; + margin:0; +} +.topNav { + background-image:url(resources/background.gif); + background-repeat:repeat-x; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; +} +.bottomNav { + margin-top:10px; + background-image:url(resources/background.gif); + background-repeat:repeat-x; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; +} +.subNav { + background-color:#dee3e9; + border-bottom:1px solid #9eadc0; + float:left; + width:100%; + overflow:hidden; +} +.subNav div { + clear:left; + float:left; + padding:0 0 5px 6px; +} +ul.navList, ul.subNavList { + float:left; + margin:0 25px 0 0; + padding:0; +} +ul.navList li{ + list-style:none; + float:left; + padding:3px 6px; +} +ul.subNavList li{ + list-style:none; + float:left; + font-size:90%; +} +.topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited { + color:#FFFFFF; + text-decoration:none; +} +.topNav a:hover, .bottomNav a:hover { + text-decoration:none; + color:#bb7a2a; +} +.navBarCell1Rev { + background-image:url(resources/tab.gif); + background-color:#a88834; + color:#FFFFFF; + margin: auto 5px; + border:1px solid #c9aa44; +} +/* +Page header and footer styles +*/ +.header, .footer { + clear:both; + margin:0 20px; + padding:5px 0 0 0; +} +.indexHeader { + margin:10px; + position:relative; +} +.indexHeader h1 { + font-size:1.3em; +} +.title { + color:#2c4557; + margin:10px 0; +} +.subTitle { + margin:5px 0 0 0; +} +.header ul { + margin:0 0 25px 0; + padding:0; +} +.footer ul { + margin:20px 0 5px 0; +} +.header ul li, .footer ul li { + list-style:none; + font-size:1.2em; +} +/* +Heading styles +*/ +div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 { + background-color:#dee3e9; + border-top:1px solid #9eadc0; + border-bottom:1px solid #9eadc0; + margin:0 0 6px -8px; + padding:2px 5px; +} +ul.blockList ul.blockList ul.blockList li.blockList h3 { + background-color:#dee3e9; + border-top:1px solid #9eadc0; + border-bottom:1px solid #9eadc0; + margin:0 0 6px -8px; + padding:2px 5px; +} +ul.blockList ul.blockList li.blockList h3 { + padding:0; + margin:15px 0; +} +ul.blockList li.blockList h2 { + padding:0px 0 20px 0; +} +/* +Page layout container styles +*/ +.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer { + clear:both; + padding:10px 20px; + position:relative; +} +.indexContainer { + margin:10px; + position:relative; + font-size:1.0em; +} +.indexContainer h2 { + font-size:1.1em; + padding:0 0 3px 0; +} +.indexContainer ul { + margin:0; + padding:0; +} +.indexContainer ul li { + list-style:none; +} +.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt { + font-size:1.1em; + font-weight:bold; + margin:10px 0 0 0; + color:#4E4E4E; +} +.contentContainer .description dl dd, .contentContainer .details dl dd, .serializedFormContainer dl dd { + margin:10px 0 10px 20px; +} +.serializedFormContainer dl.nameValue dt { + margin-left:1px; + font-size:1.1em; + display:inline; + font-weight:bold; +} +.serializedFormContainer dl.nameValue dd { + margin:0 0 0 1px; + font-size:1.1em; + display:inline; +} +/* +List styles +*/ +ul.horizontal li { + display:inline; + font-size:0.9em; +} +ul.inheritance { + margin:0; + padding:0; +} +ul.inheritance li { + display:inline; + list-style:none; +} +ul.inheritance li ul.inheritance { + margin-left:15px; + padding-left:15px; + padding-top:1px; +} +ul.blockList, ul.blockListLast { + margin:10px 0 10px 0; + padding:0; +} +ul.blockList li.blockList, ul.blockListLast li.blockList { + list-style:none; + margin-bottom:25px; +} +ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList { + padding:0px 20px 5px 10px; + border:1px solid #9eadc0; + background-color:#f9f9f9; +} +ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList { + padding:0 0 5px 8px; + background-color:#ffffff; + border:1px solid #9eadc0; + border-top:none; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockList { + margin-left:0; + padding-left:0; + padding-bottom:15px; + border:none; + border-bottom:1px solid #9eadc0; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast { + list-style:none; + border-bottom:none; + padding-bottom:0; +} +table tr td dl, table tr td dl dt, table tr td dl dd { + margin-top:0; + margin-bottom:1px; +} +/* +Table styles +*/ +.contentContainer table, .classUseContainer table, .constantValuesContainer table { + border-bottom:1px solid #9eadc0; + width:100%; +} +.contentContainer ul li table, .classUseContainer ul li table, .constantValuesContainer ul li table { + width:100%; +} +.contentContainer .description table, .contentContainer .details table { + border-bottom:none; +} +.contentContainer ul li table th.colOne, .contentContainer ul li table th.colFirst, .contentContainer ul li table th.colLast, .classUseContainer ul li table th, .constantValuesContainer ul li table th, .contentContainer ul li table td.colOne, .contentContainer ul li table td.colFirst, .contentContainer ul li table td.colLast, .classUseContainer ul li table td, .constantValuesContainer ul li table td{ + vertical-align:top; + padding-right:20px; +} +.contentContainer ul li table th.colLast, .classUseContainer ul li table th.colLast,.constantValuesContainer ul li table th.colLast, +.contentContainer ul li table td.colLast, .classUseContainer ul li table td.colLast,.constantValuesContainer ul li table td.colLast, +.contentContainer ul li table th.colOne, .classUseContainer ul li table th.colOne, +.contentContainer ul li table td.colOne, .classUseContainer ul li table td.colOne { + padding-right:3px; +} +.overviewSummary caption, .packageSummary caption, .contentContainer ul.blockList li.blockList caption, .summary caption, .classUseContainer caption, .constantValuesContainer caption { + position:relative; + text-align:left; + background-repeat:no-repeat; + color:#FFFFFF; + font-weight:bold; + clear:none; + overflow:hidden; + padding:0px; + margin:0px; +} +caption a:link, caption a:hover, caption a:active, caption a:visited { + color:#FFFFFF; +} +.overviewSummary caption span, .packageSummary caption span, .contentContainer ul.blockList li.blockList caption span, .summary caption span, .classUseContainer caption span, .constantValuesContainer caption span { + white-space:nowrap; + padding-top:8px; + padding-left:8px; + display:block; + float:left; + background-image:url(resources/titlebar.gif); + height:18px; +} +.overviewSummary .tabEnd, .packageSummary .tabEnd, .contentContainer ul.blockList li.blockList .tabEnd, .summary .tabEnd, .classUseContainer .tabEnd, .constantValuesContainer .tabEnd { + width:10px; + background-image:url(resources/titlebar_end.gif); + background-repeat:no-repeat; + background-position:top right; + position:relative; + float:left; +} +ul.blockList ul.blockList li.blockList table { + margin:0 0 12px 0px; + width:100%; +} +.tableSubHeadingColor { + background-color: #EEEEFF; +} +.altColor { + background-color:#eeeeef; +} +.rowColor { + background-color:#ffffff; +} +.overviewSummary td, .packageSummary td, .contentContainer ul.blockList li.blockList td, .summary td, .classUseContainer td, .constantValuesContainer td { + text-align:left; + padding:3px 3px 3px 7px; +} +th.colFirst, th.colLast, th.colOne, .constantValuesContainer th { + background:#dee3e9; + border-top:1px solid #9eadc0; + border-bottom:1px solid #9eadc0; + text-align:left; + padding:3px 3px 3px 7px; +} +td.colOne a:link, td.colOne a:active, td.colOne a:visited, td.colOne a:hover, td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover { + font-weight:bold; +} +td.colFirst, th.colFirst { + border-left:1px solid #9eadc0; + white-space:nowrap; +} +td.colLast, th.colLast { + border-right:1px solid #9eadc0; +} +td.colOne, th.colOne { + border-right:1px solid #9eadc0; + border-left:1px solid #9eadc0; +} +table.overviewSummary { + padding:0px; + margin-left:0px; +} +table.overviewSummary td.colFirst, table.overviewSummary th.colFirst, +table.overviewSummary td.colOne, table.overviewSummary th.colOne { + width:25%; + vertical-align:middle; +} +table.packageSummary td.colFirst, table.overviewSummary th.colFirst { + width:25%; + vertical-align:middle; +} +/* +Content styles +*/ +.description pre { + margin-top:0; +} +.deprecatedContent { + margin:0; + padding:10px 0; +} +.docSummary { + padding:0; +} +/* +Formatting effect styles +*/ +.sourceLineNo { + color:green; + padding:0 30px 0 0; +} +h1.hidden { + visibility:hidden; + overflow:hidden; + font-size:.9em; +} +.block { + display:block; + margin:3px 0 0 0; +} +.strong { + font-weight:bold; +} From b7d92501850e9274c3eb871b6df1c0e9aba245ac Mon Sep 17 00:00:00 2001 From: DRC Date: Mon, 17 Mar 2014 10:13:17 +0000 Subject: [PATCH 48/65] Move the garbage collection of the JPEG tiles into the decompression function to increase the chances that tiled decompression of large images will succeed without an OutOfMemoryError. --- java/TJBench.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/java/TJBench.java b/java/TJBench.java index 7df0ce2d..e0ca1487 100644 --- a/java/TJBench.java +++ b/java/TJBench.java @@ -189,6 +189,9 @@ class TJBench { } tjd = null; + for (i = 0; i < jpegBuf.length; i++) + jpegBuf[i] = null; + jpegBuf = null; jpegSize = null; System.gc(); if (quiet != 0) @@ -430,11 +433,6 @@ class TJBench { decompTest(srcBuf, jpegBuf, jpegSize, tmpBuf, w, h, subsamp, jpegQual, fileName, tilew, tileh); - for (i = 0; i < ntilesw * ntilesh; i++) - jpegBuf[i] = null; - jpegBuf = null; jpegSize = null; - System.gc(); - if (tilew == w && tileh == h) break; } } From 5bfddde8fd915133e35b1052a1f5a16c62bc1ad4 Mon Sep 17 00:00:00 2001 From: DRC Date: Mon, 17 Mar 2014 10:19:42 +0000 Subject: [PATCH 49/65] Fix an error that occurred when trying to use the lossless transform feature without specifying -quiet; formatting tweak --- java/TJBench.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/java/TJBench.java b/java/TJBench.java index e0ca1487..866a58f2 100644 --- a/java/TJBench.java +++ b/java/TJBench.java @@ -476,10 +476,10 @@ class TJBench { System.out.println("Format\tOrder\tCS\tSubsamp\tWidth Height\tPerf \tRatio\tPerf\n"); } else if (quiet == 0) { if (yuv == YUVDECODE) - System.out.format(">>>>> JPEG %s --> YUV <<<<<", + System.out.format(">>>>> JPEG %s --> YUV <<<<<\n", formatName(subsamp, cs)); else - System.out.format(">>>>> JPEG %s --> %s (%s) <<<<<", + System.out.format(">>>>> JPEG %s --> %s (%s) <<<<<\n", formatName(subsamp, cs), pixFormatStr[pf], (flags & TJ.FLAG_BOTTOMUP) != 0 ? "Bottom-up" : "Top-down"); } @@ -571,7 +571,7 @@ class TJBench { } else if (quiet == 0) { System.out.format("X--> Frame rate: %f fps\n", 1.0 / elapsed); - System.out.format(" Output image size: %lu bytes\n", + System.out.format(" Output image size: %d bytes\n", totalJpegSize); System.out.format(" Compression ratio: %f:1\n", (double)(w * h * ps) / (double)totalJpegSize); From 5e755737090459cf0a9cb83a20a42ff09a75460c Mon Sep 17 00:00:00 2001 From: DRC Date: Mon, 17 Mar 2014 10:40:10 +0000 Subject: [PATCH 50/65] formatting tweaks --- tjbench.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tjbench.c b/tjbench.c index 3c8f3463..b09cdaaf 100644 --- a/tjbench.c +++ b/tjbench.c @@ -706,12 +706,12 @@ void usage(char *progname) printf(" [options]\n\n"); printf("Options:\n\n"); printf("-alloc = Dynamically allocate JPEG image buffers\n"); - printf("-bmp = Generate output images in Windows Bitmap format (default=PPM)\n"); + printf("-bmp = Generate output images in Windows Bitmap format (default = PPM)\n"); printf("-bottomup = Test bottom-up compression/decompression\n"); printf("-tile = Test performance of the codec when the image is encoded as separate\n"); printf(" tiles of varying sizes.\n"); printf("-rgb, -bgr, -rgbx, -bgrx, -xbgr, -xrgb =\n"); - printf(" Test the specified color conversion path in the codec (default: BGR)\n"); + printf(" Test the specified color conversion path in the codec (default = BGR)\n"); printf("-fastupsample = Use the fastest chrominance upsampling algorithm available in\n"); printf(" the underlying codec\n"); printf("-fastdct = Use the fastest DCT/IDCT algorithms available in the underlying\n"); @@ -726,7 +726,7 @@ void usage(char *progname) printf("-yuv = Test YUV encoding/decoding functions\n"); printf("-yuvpad

    = If testing YUV encoding/decoding, this specifies the number of\n"); printf(" bytes to which each row of each plane in the intermediate YUV image is\n"); - printf(" padded (default=1)\n"); + printf(" padded (default = 1)\n"); printf("-scale M/N = Scale down the width/height of the decompressed JPEG image by a\n"); printf(" factor of M/N (M/N = "); for(i=0; i = Run each benchmark for at least seconds (default = 5.0)\n"); printf("-warmup = Execute each benchmark times to prime the cache before\n"); - printf(" taking performance measurements (default = 1.)\n"); + printf(" taking performance measurements (default = 1)\n"); printf("-componly = Stop after running compression tests. Do not test decompression.\n\n"); printf("NOTE: If the quality is specified as a range (e.g. 90-100), a separate\n"); printf("test will be performed for all quality values in the range.\n\n"); From c4f4d18352ba656ad060ff605535b743faeb272d Mon Sep 17 00:00:00 2001 From: DRC Date: Mon, 17 Mar 2014 11:14:52 +0000 Subject: [PATCH 51/65] Extend YUVImage class to allow reuse of the same buffer with different metadata; port TJBench changes that treat YUV encoding/decoding as an intermediate step of the JPEG compression/decompression pipeline rather than a separate test case; add YUV encode/decode tests to the Java version of tjbenchtest --- Makefile.am | 1 + java/TJBench.java | 562 +++++++++--------- java/doc/index-all.html | 5 + .../org/libjpegturbo/turbojpeg/YUVImage.html | 40 +- java/org/libjpegturbo/turbojpeg/YUVImage.java | 40 +- tjbenchtest.in | 2 +- tjbenchtest.java.in | 98 +-- 7 files changed, 404 insertions(+), 344 deletions(-) diff --git a/Makefile.am b/Makefile.am index 0e0527a2..0636b287 100644 --- a/Makefile.am +++ b/Makefile.am @@ -330,6 +330,7 @@ tjtest: sh ./tjbenchtest -yuv if WITH_JAVA sh ./tjbenchtest.java + sh ./tjbenchtest.java -yuv endif diff --git a/java/TJBench.java b/java/TJBench.java index 866a58f2..617d312d 100644 --- a/java/TJBench.java +++ b/java/TJBench.java @@ -1,5 +1,5 @@ /* - * Copyright (C)2009-2013 D. R. Commander. All Rights Reserved. + * Copyright (C)2009-2014 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: @@ -34,12 +34,8 @@ import org.libjpegturbo.turbojpeg.*; class TJBench { - static final int YUVENCODE = 1; - static final int YUVDECODE = 2; - static final int YUVCOMPRESS = 3; - - static int flags = 0, yuv = 0, quiet = 0, pf = TJ.PF_BGR, yuvpad = 1; - static boolean compOnly, decompOnly, doTile; + static int flags = 0, quiet = 0, pf = TJ.PF_BGR, yuvpad = 1, warmup = 1; + static boolean compOnly, decompOnly, doTile, doYUV; static final String[] pixFormatStr = { "RGB", "BGR", "RGBX", "BGRX", "XBGR", "XRGB", "GRAY" @@ -134,17 +130,15 @@ class TJBench { /* Decompression test */ - static void decompTest(byte[] srcBuf, byte[][] jpegBuf, int[] jpegSize, - byte[] dstBuf, int w, int h, int subsamp, - int jpegQual, String fileName, int tilew, int tileh) - throws Exception { + static void decomp(byte[] srcBuf, byte[][] jpegBuf, int[] jpegSize, + byte[] dstBuf, int w, int h, int subsamp, int jpegQual, + String fileName, int tilew, int tileh) throws Exception { String qualStr = new String(""), sizeStr, tempStr; TJDecompressor tjd; - double start, elapsed; - int ps = TJ.getPixelSize(pf), i; + double elapsed, elapsedDecode; + int ps = TJ.getPixelSize(pf), i, iter = 0; int scaledw = sf.getScaled(w); int scaledh = sf.getScaled(h); - int yuvSize = TJ.bufSizeYUV(scaledw, yuvpad, scaledh, subsamp), bufsize; int pitch = scaledw * ps; YUVImage yuvImage = null; @@ -153,40 +147,52 @@ class TJBench { tjd = new TJDecompressor(); - int bufSize = (yuv == YUVDECODE ? yuvSize : pitch * scaledh); if (dstBuf == null) - dstBuf = new byte[bufSize]; + dstBuf = new byte[pitch * scaledh]; /* Set the destination buffer to gray so we know whether the decompressor attempted to write to it */ Arrays.fill(dstBuf, (byte)127); - /* Execute once to preload cache */ - tjd.setSourceImage(jpegBuf[0], jpegSize[0]); - if (yuv == YUVDECODE) { - yuvImage = new YUVImage(dstBuf, scaledw, yuvpad, scaledh, subsamp); - tjd.decompressToYUV(yuvImage, flags); + if (doYUV) { + int width = doTile ? tilew : scaledw; + int height = doTile ? tileh : scaledh; + yuvImage = new YUVImage(width, yuvpad, height, subsamp); + Arrays.fill(yuvImage.getBuf(), (byte)127); } - else - tjd.decompress(dstBuf, 0, 0, scaledw, pitch, scaledh, pf, flags); /* Benchmark */ - for (i = 0, start = getTime(); (elapsed = getTime() - start) < benchTime; - i++) { + iter -= warmup; + elapsed = elapsedDecode = 0.0; + while (true) { int tile = 0; - if (yuv == YUVDECODE) - tjd.decompressToYUV(yuvImage, flags); - else { - for (int y = 0; y < h; y += tileh) { - for (int x = 0; x < w; x += tilew, tile++) { - int width = doTile ? Math.min(tilew, w - x) : scaledw; - int height = doTile ? Math.min(tileh, h - y) : scaledh; - tjd.setSourceImage(jpegBuf[tile], jpegSize[tile]); + double start = getTime(); + for (int y = 0; y < h; y += tileh) { + for (int x = 0; x < w; x += tilew, tile++) { + int width = doTile ? Math.min(tilew, w - x) : scaledw; + int height = doTile ? Math.min(tileh, h - y) : scaledh; + tjd.setSourceImage(jpegBuf[tile], jpegSize[tile]); + if (doYUV) { + yuvImage.setBuf(yuvImage.getBuf(), width, yuvpad, height, subsamp); + tjd.decompressToYUV(yuvImage, flags); + double startDecode = getTime(); + tjd.setSourceImage(yuvImage); + tjd.decompress(dstBuf, x, y, width, pitch, height, pf, flags); + if (iter >= 0) + elapsedDecode += getTime() - startDecode; + } else tjd.decompress(dstBuf, x, y, width, pitch, height, pf, flags); - } } } + iter++; + if (iter >= 1) { + elapsed += getTime() - start; + if (elapsed >= benchTime) + break; + } } + if(doYUV) + elapsed -= elapsedDecode; tjd = null; for (i = 0; i < jpegBuf.length; i++) @@ -194,14 +200,27 @@ class TJBench { jpegBuf = null; jpegSize = null; System.gc(); - if (quiet != 0) - System.out.println( - sigFig((double)(w * h) / 1000000. * (double)i / elapsed, 4)); - else { - System.out.format("D--> Frame rate: %f fps\n", - (double)i / elapsed); - System.out.format(" Dest. throughput: %f Megapixels/sec\n", - (double)(w * h) / 1000000. * (double)i / elapsed); + if (quiet != 0) { + System.out.format("%-6s%s", + sigFig((double)(w * h) / 1000000. * (double)iter / elapsed, 4), + quiet == 2 ? "\n" : " "); + if (doYUV) + System.out.format("%s\n", + sigFig((double)(w * h) / 1000000. * (double)iter / elapsedDecode, 4)); + else if (quiet != 2) + System.out.print("\n"); + } else { + System.out.format("%s --> Frame rate: %f fps\n", + (doYUV ? "Decomp to YUV":"Decompress "), + (double)iter / elapsed); + System.out.format(" Throughput: %f Megapixels/sec\n", + (double)(w * h) / 1000000. * (double)iter / elapsed); + if (doYUV) { + System.out.format("YUV Decode --> Frame rate: %f fps\n", + (double)iter / elapsedDecode); + System.out.format(" Throughput: %f Megapixels/sec\n", + (double)(w * h) / 1000000. * (double)iter / elapsedDecode); + } } if (sf.getNum() != 1 || sf.getDenom() != 1) @@ -211,132 +230,57 @@ class TJBench { else sizeStr = new String("full"); if (decompOnly) - tempStr = new String(fileName + "_" + sizeStr + - (yuv != 0 ? ".yuv" : ".bmp")); + tempStr = new String(fileName + "_" + sizeStr + ".bmp"); else tempStr = new String(fileName + "_" + subName[subsamp] + qualStr + - "_" + sizeStr + (yuv != 0 ? ".yuv" : ".bmp")); + "_" + sizeStr + ".bmp"); - if (yuv == YUVDECODE) { - FileOutputStream fos = new FileOutputStream(tempStr); - fos.write(dstBuf, 0, yuvSize); - fos.close(); - } else { - saveImage(tempStr, dstBuf, scaledw, scaledh, pf); - int ndx = tempStr.indexOf('.'); - tempStr = new String(tempStr.substring(0, ndx) + "-err.bmp"); - if (srcBuf != null && sf.getNum() == 1 && sf.getDenom() == 1) { - if (quiet == 0) - System.out.println("Compression error written to " + tempStr + "."); - if (subsamp == TJ.SAMP_GRAY) { - for (int y = 0, index = 0; y < h; y++, index += pitch) { - for (int x = 0, index2 = index; x < w; x++, index2 += ps) { - int rindex = index2 + TJ.getRedOffset(pf); - int gindex = index2 + TJ.getGreenOffset(pf); - int bindex = index2 + TJ.getBlueOffset(pf); - int lum = (int)((double)(srcBuf[rindex] & 0xff) * 0.299 + - (double)(srcBuf[gindex] & 0xff) * 0.587 + - (double)(srcBuf[bindex] & 0xff) * 0.114 + 0.5); - if (lum > 255) lum = 255; - if (lum < 0) lum = 0; - dstBuf[rindex] = (byte)Math.abs((dstBuf[rindex] & 0xff) - lum); - dstBuf[gindex] = (byte)Math.abs((dstBuf[gindex] & 0xff) - lum); - dstBuf[bindex] = (byte)Math.abs((dstBuf[bindex] & 0xff) - lum); - } + saveImage(tempStr, dstBuf, scaledw, scaledh, pf); + int ndx = tempStr.indexOf('.'); + tempStr = new String(tempStr.substring(0, ndx) + "-err.bmp"); + if (srcBuf != null && sf.getNum() == 1 && sf.getDenom() == 1) { + if (quiet == 0) + System.out.println("Compression error written to " + tempStr + "."); + if (subsamp == TJ.SAMP_GRAY) { + for (int y = 0, index = 0; y < h; y++, index += pitch) { + for (int x = 0, index2 = index; x < w; x++, index2 += ps) { + int rindex = index2 + TJ.getRedOffset(pf); + int gindex = index2 + TJ.getGreenOffset(pf); + int bindex = index2 + TJ.getBlueOffset(pf); + int lum = (int)((double)(srcBuf[rindex] & 0xff) * 0.299 + + (double)(srcBuf[gindex] & 0xff) * 0.587 + + (double)(srcBuf[bindex] & 0xff) * 0.114 + 0.5); + if (lum > 255) lum = 255; + if (lum < 0) lum = 0; + dstBuf[rindex] = (byte)Math.abs((dstBuf[rindex] & 0xff) - lum); + dstBuf[gindex] = (byte)Math.abs((dstBuf[gindex] & 0xff) - lum); + dstBuf[bindex] = (byte)Math.abs((dstBuf[bindex] & 0xff) - lum); } - } else { - for (int y = 0; y < h; y++) - for (int x = 0; x < w * ps; x++) - dstBuf[pitch * y + x] = - (byte)Math.abs((dstBuf[pitch * y + x] & 0xff) - - (srcBuf[pitch * y + x] & 0xff)); } - saveImage(tempStr, dstBuf, w, h, pf); + } else { + for (int y = 0; y < h; y++) + for (int x = 0; x < w * ps; x++) + dstBuf[pitch * y + x] = + (byte)Math.abs((dstBuf[pitch * y + x] & 0xff) - + (srcBuf[pitch * y + x] & 0xff)); } + saveImage(tempStr, dstBuf, w, h, pf); } } - static void doTestYUV(byte[] srcBuf, int w, int h, int subsamp, - String fileName) throws Exception { - TJCompressor tjc; - byte[] dstBuf; - double start, elapsed; - int ps = TJ.getPixelSize(pf), i; - int yuvSize = 0; - YUVImage yuvImage; - - yuvSize = TJ.bufSizeYUV(w, yuvpad, h, subsamp); - dstBuf = new byte[yuvSize]; - - if (quiet == 0) - System.out.format(">>>>> %s (%s) <--> YUV %s <<<<<\n", - pixFormatStr[pf], - (flags & TJ.FLAG_BOTTOMUP) != 0 ? "Bottom-up" : "Top-down", - subNameLong[subsamp]); - - if (quiet == 1) - System.out.format("%s\t%s\t%s\tN/A\t", pixFormatStr[pf], - (flags & TJ.FLAG_BOTTOMUP) != 0 ? "BU" : "TD", - subNameLong[subsamp]); - - tjc = new TJCompressor(srcBuf, 0, 0, w, 0, h, pf); - tjc.setSubsamp(subsamp); - - /* Execute once to preload cache */ - yuvImage = new YUVImage(dstBuf, w, yuvpad, h, subsamp); - tjc.encodeYUV(yuvImage, flags); - - /* Benchmark */ - for (i = 0, start = getTime(); - (elapsed = getTime() - start) < benchTime; i++) - tjc.encodeYUV(yuvImage, flags); - - if (quiet == 1) - System.out.format("%-4d %-4d\t", w, h); - if (quiet != 0) { - System.out.format("%s%c%s%c", - sigFig((double)(w * h) / 1000000. * (double) i / elapsed, 4), - quiet == 2 ? '\n' : '\t', - sigFig((double)(w * h * ps) / (double)yuvSize, 4), - quiet == 2 ? '\n' : '\t'); - } else { - System.out.format("\n%s size: %d x %d\n", "Image", w, h); - System.out.format("C--> Frame rate: %f fps\n", - (double)i / elapsed); - System.out.format(" Output image size: %d bytes\n", yuvSize); - System.out.format(" Compression ratio: %f:1\n", - (double)(w * h * ps) / (double)yuvSize); - System.out.format(" Source throughput: %f Megapixels/sec\n", - (double)(w * h) / 1000000. * (double)i / elapsed); - System.out.format(" Output bit stream: %f Megabits/sec\n", - (double)yuvSize * 8. / 1000000. * (double)i / elapsed); - } - String tempStr = fileName + "_" + subName[subsamp] + ".yuv"; - FileOutputStream fos = new FileOutputStream(tempStr); - fos.write(dstBuf, 0, yuvSize); - fos.close(); - if (quiet == 0) - System.out.println("Reference image written to " + tempStr); - } - - - static void doTest(byte[] srcBuf, int w, int h, int subsamp, int jpegQual, - String fileName) throws Exception { + static void fullTest(byte[] srcBuf, int w, int h, int subsamp, int jpegQual, + String fileName) throws Exception { TJCompressor tjc; byte[] tmpBuf; byte[][] jpegBuf; int[] jpegSize; - double start, elapsed; - int totalJpegSize = 0, tilew, tileh, i; - int ps = (yuv == YUVCOMPRESS ? 3 : TJ.getPixelSize(pf)); + double start, elapsed, elapsedEncode; + int totalJpegSize = 0, tilew, tileh, i, iter; + int ps = TJ.getPixelSize(pf); int ntilesw = 1, ntilesh = 1, pitch = w * ps; - String pfStr = (yuv == YUVCOMPRESS ? "YUV" : pixFormatStr[pf]); - - if (yuv == YUVENCODE) { - doTestYUV(srcBuf, w, h, subsamp, fileName); - return; - } + String pfStr = pixFormatStr[pf]; + YUVImage yuvImage = null; tmpBuf = new byte[pitch * h]; @@ -361,62 +305,94 @@ class TJBench { /* Compression test */ if (quiet == 1) - System.out.format("%s\t%s\t%s\t%d\t", pfStr, + System.out.format("%-4s (%s) %-5s %-3d ", pfStr, (flags & TJ.FLAG_BOTTOMUP) != 0 ? "BU" : "TD", subNameLong[subsamp], jpegQual); - if (yuv != YUVCOMPRESS) - for (i = 0; i < h; i++) - System.arraycopy(srcBuf, w * ps * i, tmpBuf, pitch * i, w * ps); - if (yuv == YUVCOMPRESS) - tjc.setSourceImage(new YUVImage(srcBuf, tilew, yuvpad, tileh, - subsamp)); - else - tjc.setSourceImage(srcBuf, 0, 0, tilew, pitch, tileh, pf); + for (i = 0; i < h; i++) + System.arraycopy(srcBuf, w * ps * i, tmpBuf, pitch * i, w * ps); tjc.setJPEGQuality(jpegQual); tjc.setSubsamp(subsamp); - /* Execute once to preload cache */ - tjc.compress(jpegBuf[0], flags); + if (doYUV) { + yuvImage = new YUVImage(tilew, yuvpad, tileh, subsamp); + Arrays.fill(yuvImage.getBuf(), (byte)127); + } /* Benchmark */ - for (i = 0, start = getTime(); - (elapsed = getTime() - start) < benchTime; i++) { + iter = -warmup; + elapsed = elapsedEncode = 0.0; + while (true) { int tile = 0; totalJpegSize = 0; + start = getTime(); for (int y = 0; y < h; y += tileh) { for (int x = 0; x < w; x += tilew, tile++) { int width = Math.min(tilew, w - x); int height = Math.min(tileh, h - y); - if (yuv != YUVCOMPRESS) - tjc.setSourceImage(srcBuf, x, y, width, pitch, height, pf); + tjc.setSourceImage(srcBuf, x, y, width, pitch, height, pf); + if (doYUV) { + double startEncode = getTime(); + yuvImage.setBuf(yuvImage.getBuf(), width, yuvpad, height, + subsamp); + tjc.encodeYUV(yuvImage, flags); + if (iter >= 0) + elapsedEncode += getTime() - startEncode; + tjc.setSourceImage(yuvImage); + } tjc.compress(jpegBuf[tile], flags); jpegSize[tile] = tjc.getCompressedSize(); totalJpegSize += jpegSize[tile]; } } + iter++; + if (iter >= 1) { + elapsed += getTime() - start; + if (elapsed >= benchTime) + break; + } } + if (doYUV) + elapsed -= elapsedEncode; if (quiet == 1) - System.out.format("%-4d %-4d\t", tilew, tileh); + System.out.format("%-5d %-5d ", tilew, tileh); if (quiet != 0) { - System.out.format("%s%c%s%c", - sigFig((double)(w * h) / 1000000. * (double) i / elapsed, 4), - quiet == 2 ? '\n' : '\t', + if (doYUV) + System.out.format("%-6s%s", + sigFig((double)(w * h) / 1000000. * (double)iter / elapsedEncode, 4), + quiet == 2 ? "\n" : " "); + System.out.format("%-6s%s", + sigFig((double)(w * h) / 1000000. * (double)iter / elapsed, 4), + quiet == 2 ? "\n" : " "); + System.out.format("%-6s%s", sigFig((double)(w * h * ps) / (double)totalJpegSize, 4), - quiet == 2 ? '\n' : '\t'); + quiet == 2 ? "\n" : " "); } else { System.out.format("\n%s size: %d x %d\n", doTile ? "Tile" : "Image", tilew, tileh); - System.out.format("C--> Frame rate: %f fps\n", - (double)i / elapsed); - System.out.format(" Output image size: %d bytes\n", + if (doYUV) { + System.out.format("Encode YUV --> Frame rate: %f fps\n", + (double)iter / elapsedEncode); + System.out.format(" Output image size: %d bytes\n", + yuvImage.getSize()); + System.out.format(" Compression ratio: %f:1\n", + (double)(w * h * ps) / (double)yuvImage.getSize()); + System.out.format(" Throughput: %f Megapixels/sec\n", + (double)(w * h) / 1000000. * (double)iter / elapsedEncode); + System.out.format(" Output bit stream: %f Megabits/sec\n", + (double)yuvImage.getSize() * 8. / 1000000. * (double)iter / elapsedEncode); + } + System.out.format("%s --> Frame rate: %f fps\n", + doYUV ? "Comp from YUV" : "Compress ", + (double)iter / elapsed); + System.out.format(" Output image size: %d bytes\n", totalJpegSize); - System.out.format(" Compression ratio: %f:1\n", + System.out.format(" Compression ratio: %f:1\n", (double)(w * h * ps) / (double)totalJpegSize); - System.out.format(" Source throughput: %f Megapixels/sec\n", - (double)(w * h) / 1000000. * (double)i / elapsed); - System.out.format(" Output bit stream: %f Megabits/sec\n", - (double)totalJpegSize * 8. / 1000000. * (double)i / elapsed); + System.out.format(" Throughput: %f Megapixels/sec\n", + (double)(w * h) / 1000000. * (double)iter / elapsed); + System.out.format(" Output bit stream: %f Megabits/sec\n", + (double)totalJpegSize * 8. / 1000000. * (double)iter / elapsed); } if (tilew == w && tileh == h) { String tempStr = fileName + "_" + subName[subsamp] + "_" + "Q" + @@ -430,22 +406,22 @@ class TJBench { /* Decompression test */ if (!compOnly) - decompTest(srcBuf, jpegBuf, jpegSize, tmpBuf, w, h, subsamp, jpegQual, - fileName, tilew, tileh); + decomp(srcBuf, jpegBuf, jpegSize, tmpBuf, w, h, subsamp, jpegQual, + fileName, tilew, tileh); if (tilew == w && tileh == h) break; } } - static void doDecompTest(String fileName) throws Exception { + static void decompTest(String fileName) throws Exception { TJTransformer tjt; - byte[][] jpegBuf; + byte[][] jpegBuf = null; byte[] srcBuf; - int[] jpegSize; + int[] jpegSize = null; int totalJpegSize; int w = 0, h = 0, subsamp = -1, cs = -1, _w, _h, _tilew, _tileh, - _ntilesw, _ntilesh, _subsamp, x, y; + _ntilesw, _ntilesh, _subsamp, x, y, iter; int ntilesw = 1, ntilesh = 1; double start, elapsed; int ps = TJ.getPixelSize(pf), tile; @@ -470,19 +446,20 @@ class TJBench { if (quiet == 1) { System.out.println("All performance values in Mpixels/sec\n"); - System.out.format("Bitmap\tBitmap\tJPEG\tJPEG\t%s %s \tXform\tComp\tDecomp\n", + System.out.format("Bitmap JPEG JPEG %s %s Xform Comp Decomp ", (doTile ? "Tile " : "Image"), (doTile ? "Tile " : "Image")); - System.out.println("Format\tOrder\tCS\tSubsamp\tWidth Height\tPerf \tRatio\tPerf\n"); - } else if (quiet == 0) { - if (yuv == YUVDECODE) - System.out.format(">>>>> JPEG %s --> YUV <<<<<\n", - formatName(subsamp, cs)); - else - System.out.format(">>>>> JPEG %s --> %s (%s) <<<<<\n", - formatName(subsamp, cs), pixFormatStr[pf], - (flags & TJ.FLAG_BOTTOMUP) != 0 ? "Bottom-up" : "Top-down"); - } + if (doYUV) + System.out.print("Decode"); + System.out.print("\n"); + System.out.print("Format CS Subsamp Width Height Perf Ratio Perf "); + if (doYUV) + System.out.print("Perf"); + System.out.println("\n"); + } else if (quiet == 0) + System.out.format(">>>>> JPEG %s --> %s (%s) <<<<<\n", + formatName(subsamp, cs), pixFormatStr[pf], + (flags & TJ.FLAG_BOTTOMUP) != 0 ? "Bottom-up" : "Top-down"); for (int tilew = doTile ? 16 : w, tileh = doTile ? 16 : h; ; tilew *= 2, tileh *= 2) { @@ -502,10 +479,10 @@ class TJBench { sf.getScaled(_h)); System.out.println(""); } else if (quiet == 1) { - System.out.format("%s\t%s\t%s\t%s\t", pixFormatStr[pf], + System.out.format("%-4s (%s) %-5s %-5s ", pixFormatStr[pf], (flags & TJ.FLAG_BOTTOMUP) != 0 ? "BU" : "TD", csName[cs], subNameLong[subsamp]); - System.out.format("%-4d %-4d\t", tilew, tileh); + System.out.format("%-5d %-5d ", tilew, tileh); } _subsamp = subsamp; @@ -534,6 +511,16 @@ class TJBench { _ntilesw = (_w + _tilew - 1) / _tilew; _ntilesh = (_h + _tileh - 1) / _tileh; + if (xformOp == TJTransform.OP_TRANSPOSE || + xformOp == TJTransform.OP_TRANSVERSE || + xformOp == TJTransform.OP_ROT90 || + xformOp == TJTransform.OP_ROT270) { + if (_subsamp == TJ.SAMP_422) + _subsamp = TJ.SAMP_440; + else if (_subsamp == TJ.SAMP_440) + _subsamp = TJ.SAMP_422; + } + TJTransform[] t = new TJTransform[_ntilesw * _ntilesh]; jpegBuf = new byte[_ntilesw * _ntilesh][TJ.bufSize(_tilew, _tileh, subsamp)]; @@ -552,37 +539,45 @@ class TJBench { } } - start = getTime(); - tjt.transform(jpegBuf, t, flags); - jpegSize = tjt.getTransformedSizes(); - elapsed = getTime() - start; - + iter = -warmup; + elapsed = 0.; + while (true) { + start = getTime(); + tjt.transform(jpegBuf, t, flags); + jpegSize = tjt.getTransformedSizes(); + iter++; + if (iter >= 1) { + elapsed += getTime() - start; + if (elapsed >= benchTime) + break; + } + } t = null; for (tile = 0, totalJpegSize = 0; tile < _ntilesw * _ntilesh; tile++) totalJpegSize += jpegSize[tile]; if (quiet != 0) { - System.out.format("%s%c%s%c", + System.out.format("%-6s%s%-6s%s", sigFig((double)(w * h) / 1000000. / elapsed, 4), - quiet == 2 ? '\n' : '\t', + quiet == 2 ? "\n" : " ", sigFig((double)(w * h * ps) / (double)totalJpegSize, 4), - quiet == 2 ? '\n' : '\t'); + quiet == 2 ? "\n" : " "); } else if (quiet == 0) { - System.out.format("X--> Frame rate: %f fps\n", + System.out.format("Transform --> Frame rate: %f fps\n", 1.0 / elapsed); - System.out.format(" Output image size: %d bytes\n", + System.out.format(" Output image size: %d bytes\n", totalJpegSize); - System.out.format(" Compression ratio: %f:1\n", + System.out.format(" Compression ratio: %f:1\n", (double)(w * h * ps) / (double)totalJpegSize); - System.out.format(" Source throughput: %f Megapixels/sec\n", + System.out.format(" Throughput: %f Megapixels/sec\n", (double)(w * h) / 1000000. / elapsed); - System.out.format(" Output bit stream: %f Megabits/sec\n", + System.out.format(" Output bit stream: %f Megabits/sec\n", (double)totalJpegSize * 8. / 1000000. / elapsed); } } else { if (quiet == 1) - System.out.print("N/A\tN/A\t"); + System.out.print("N/A N/A "); jpegBuf = new byte[1][TJ.bufSize(_tilew, _tileh, subsamp)]; jpegSize = new int[1]; jpegSize[0] = srcSize; @@ -594,8 +589,8 @@ class TJBench { if (h == tileh) _tileh = _h; if ((xformOpt & TJTransform.OPT_NOOUTPUT) == 0) - decompTest(null, jpegBuf, jpegSize, null, _w, _h, _subsamp, 0, - fileName, _tilew, _tileh); + decomp(null, jpegBuf, jpegSize, null, _w, _h, _subsamp, 0, + fileName, _tilew, _tileh); else if (quiet == 1) System.out.println("N/A"); @@ -614,7 +609,7 @@ class TJBench { String className = new TJBench().getClass().getName(); System.out.println("\nUSAGE: java " + className); - System.out.println(" [options]\n"); + System.out.println(" [options]\n"); System.out.println(" java " + className); System.out.println(" [options]\n"); System.out.println("Options:\n"); @@ -623,29 +618,23 @@ class TJBench { System.out.println("-tile = Test performance of the codec when the image is encoded as separate"); System.out.println(" tiles of varying sizes."); System.out.println("-rgb, -bgr, -rgbx, -bgrx, -xbgr, -xrgb ="); - System.out.println(" Test the specified color conversion path in the codec (default: BGR)"); + System.out.println(" Test the specified color conversion path in the codec (default = BGR)"); System.out.println("-fastupsample = Use the fastest chrominance upsampling algorithm available in"); System.out.println(" the underlying codec"); System.out.println("-fastdct = Use the fastest DCT/IDCT algorithms available in the underlying"); System.out.println(" codec"); System.out.println("-accuratedct = Use the most accurate DCT/IDCT algorithms available in the"); System.out.println(" underlying codec"); - System.out.println("-subsamp = if compressing a JPEG image from a YUV planar source image,"); - System.out.println(" this specifies the level of chrominance subsampling used in the source"); - System.out.println(" image. Otherwise, this specifies the level of chrominance subsampling"); - System.out.println(" to use in the JPEG destination image. = 444, 422, 440, 420, 411,"); - System.out.println(" or GRAY"); + System.out.println("-subsamp = When testing JPEG compression, this option specifies the level"); + System.out.println(" of chrominance subsampling to use ( = 444, 422, 440, 420, 411, or"); + System.out.println(" GRAY). The default is to test Grayscale, 4:2:0, 4:2:2, and 4:4:4 in"); + System.out.println(" sequence."); System.out.println("-quiet = Output results in tabular rather than verbose format"); - System.out.println("-yuvencode = Encode RGB input as planar YUV rather than compressing as JPEG"); - System.out.println("-yuvdecode = Decode JPEG image to planar YUV rather than RGB"); - System.out.println("-yuvsize WxH = if compressing a JPEG image from a YUV planar source image, this"); - System.out.println(" specifies the width and height of the source image."); - System.out.println("-yuvpad

    = if compressing a JPEG image from a YUV planar source image, this"); - System.out.println(" specifies the number of bytes to which each row of each plane in the"); - System.out.println(" source image is padded. If decompressing a JPEG image to a YUV planar"); - System.out.println(" destination image, this specifies the row padding for each plane of the"); - System.out.println(" destination image. (default=1)"); - System.out.println("-scale M/N = scale down the width/height of the decompressed JPEG image by a"); + System.out.println("-yuv = Test YUV encoding/decoding functions"); + System.out.println("-yuvpad

    = If testing YUV encoding/decoding, this specifies the number of"); + System.out.println(" bytes to which each row of each plane in the intermediate YUV image is"); + System.out.println(" padded (default = 1)"); + System.out.println("-scale M/N = Scale down the width/height of the decompressed JPEG image by a"); System.out.print (" factor of M/N (M/N = "); for (i = 0; i < nsf; i++) { System.out.format("%d/%d", scalingFactors[i].getNum(), @@ -668,7 +657,9 @@ class TJBench { System.out.println("-grayscale = Perform lossless grayscale conversion prior to decompression"); System.out.println(" test (can be combined with the other transforms above)"); System.out.println("-benchtime = Run each benchmark for at least seconds (default = 5.0)"); - System.out.println("-componly = Stop after running compression tests. Do not test decompression.\n"); + System.out.println("-warmup = Execute each benchmark times to prime the cache before"); + System.out.println(" taking performance measurements (default = 1)"); + System.out.println("-componly = Stop after running compression tests. Do not test decompression.\n"); System.out.println("NOTE: If the quality is specified as a range (e.g. 90-100), a separate"); System.out.println("test will be performed for all quality values in the range.\n"); System.exit(1); @@ -689,25 +680,10 @@ class TJBench { String tempStr = argv[0].toLowerCase(); if (tempStr.endsWith(".jpg") || tempStr.endsWith(".jpeg")) decompOnly = true; - if (tempStr.endsWith(".yuv")) - yuv = YUVCOMPRESS; System.out.println(""); - if (argv.length > minArg) { - for (int i = minArg; i < argv.length; i++) { - if (argv[i].equalsIgnoreCase("-yuvencode")) { - System.out.println("Testing YUV planar encoding\n"); - yuv = YUVENCODE; maxQual = minQual = 100; - } - if (argv[i].equalsIgnoreCase("-yuvdecode")) { - System.out.println("Testing YUV planar decoding\n"); - yuv = YUVDECODE; - } - } - } - - if (!decompOnly && yuv != YUVENCODE) { + if (!decompOnly) { minArg = 2; if (argv.length < minArg) usage(); @@ -812,18 +788,9 @@ class TJBench { else usage(); } - if (argv[i].equalsIgnoreCase("-yuvsize") && i < argv.length - 1) { - int temp1 = 0, temp2 = 0; - Scanner scanner = new Scanner(argv[++i]).useDelimiter("x"); - try { - temp1 = scanner.nextInt(); - temp2 = scanner.nextInt(); - } catch(Exception e) {} - if (temp1 >= 1 && temp2 >= 1) { - w = temp1; - h = temp2; - } else - usage(); + if (argv[i].equalsIgnoreCase("-yuv")) { + System.out.println("Testing YUV planar encoding/decoding\n"); + doYUV = true; } if (argv[i].equalsIgnoreCase("-yuvpad") && i < argv.length - 1) { int temp = 0; @@ -850,6 +817,16 @@ class TJBench { } if (argv[i].equalsIgnoreCase("-componly")) compOnly = true; + if (argv[i].equalsIgnoreCase("-warmup") && i < argv.length - 1) { + int temp = -1; + try { + temp = Integer.parseInt(argv[++i]); + } catch (NumberFormatException e) {} + if (temp >= 0) { + warmup = temp; + System.out.format("Warmup runs = %d\n\n", warmup); + } + } if (argv[i].equalsIgnoreCase("-?")) usage(); } @@ -864,67 +841,60 @@ class TJBench { doTile = false; } - if (yuv != 0 && doTile) { - System.out.println("Disabling tiled compression/decompression tests, because those tests do not"); - System.out.println("work when YUV encoding, compression, or decoding is enabled.\n"); - doTile = false; - } - if (!decompOnly) { - if(yuv == YUVCOMPRESS) { - if (w < 1 || h < 1 || subsamp < 0 || subsamp >= TJ.NUMSAMP) - throw new Exception("YUV image size and/or subsampling not specified"); - FileInputStream fis = new FileInputStream(argv[0]); - int srcSize = (int)fis.getChannel().size(); - if (srcSize != TJ.bufSizeYUV(w, yuvpad, h, subsamp)) - throw new Exception("YUV image file is the wrong size"); - srcBuf = new byte[srcSize]; - fis.read(srcBuf, 0, srcSize); - fis.close(); - } - else { - int[] width = new int[1], height = new int[1]; - srcBuf = loadImage(argv[0], width, height, pf); - w = width[0]; h = height[0]; - int index = -1; - if ((index = argv[0].indexOf('.')) >= 0) - argv[0] = argv[0].substring(0, index); - } + int[] width = new int[1], height = new int[1]; + srcBuf = loadImage(argv[0], width, height, pf); + w = width[0]; h = height[0]; + int index = -1; + if ((index = argv[0].indexOf('.')) >= 0) + argv[0] = argv[0].substring(0, index); } if (quiet == 1 && !decompOnly) { System.out.println("All performance values in Mpixels/sec\n"); - System.out.format("Bitmap\tBitmap\tJPEG\tJPEG\t%s %s \tComp\tComp\tDecomp\n", + System.out.format("Bitmap JPEG JPEG %s %s ", (doTile ? "Tile " : "Image"), (doTile ? "Tile " : "Image")); - System.out.println("Format\tOrder\tSubsamp\tQual\tWidth Height\tPerf \tRatio\tPerf\n"); + if (doYUV) + System.out.print("Encode "); + System.out.print("Comp Comp Decomp "); + if (doYUV) + System.out.print("Decode"); + System.out.print("\n"); + System.out.print("Format Subsamp Qual Width Height "); + if (doYUV) + System.out.print("Perf "); + System.out.print("Perf Ratio Perf "); + if (doYUV) + System.out.print("Perf"); + System.out.println("\n"); } if (decompOnly) { - doDecompTest(argv[0]); + decompTest(argv[0]); System.out.println(""); System.exit(retval); } System.gc(); - if (yuv == YUVCOMPRESS || (subsamp >= 0 && subsamp < TJ.NUMSAMP)) { + if (subsamp >= 0 && subsamp < TJ.NUMSAMP) { for (int i = maxQual; i >= minQual; i--) - doTest(srcBuf, w, h, subsamp, i, argv[0]); + fullTest(srcBuf, w, h, subsamp, i, argv[0]); System.out.println(""); } else { for (int i = maxQual; i >= minQual; i--) - doTest(srcBuf, w, h, TJ.SAMP_GRAY, i, argv[0]); + fullTest(srcBuf, w, h, TJ.SAMP_GRAY, i, argv[0]); System.out.println(""); System.gc(); for (int i = maxQual; i >= minQual; i--) - doTest(srcBuf, w, h, TJ.SAMP_420, i, argv[0]); + fullTest(srcBuf, w, h, TJ.SAMP_420, i, argv[0]); System.out.println(""); System.gc(); for (int i = maxQual; i >= minQual; i--) - doTest(srcBuf, w, h, TJ.SAMP_422, i, argv[0]); + fullTest(srcBuf, w, h, TJ.SAMP_422, i, argv[0]); System.out.println(""); System.gc(); for (int i = maxQual; i >= minQual; i--) - doTest(srcBuf, w, h, TJ.SAMP_444, i, argv[0]); + fullTest(srcBuf, w, h, TJ.SAMP_444, i, argv[0]); System.out.println(""); } diff --git a/java/doc/index-all.html b/java/doc/index-all.html index c8a4f0c9..fa92e3c9 100644 --- a/java/doc/index-all.html +++ b/java/doc/index-all.html @@ -662,6 +662,11 @@

    Grayscale.
    +
    setBuf(byte[], int, int, int, int) - Method in class org.libjpegturbo.turbojpeg.YUVImage
    +
    +
    Assign an existing YUV planar image buffer to this YUVImage + instance.
    +
    setJPEGImage(byte[], int) - Method in class org.libjpegturbo.turbojpeg.TJDecompressor
    Deprecated. diff --git a/java/doc/org/libjpegturbo/turbojpeg/YUVImage.html b/java/doc/org/libjpegturbo/turbojpeg/YUVImage.html index 8659aedc..13e6160c 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/YUVImage.html +++ b/java/doc/org/libjpegturbo/turbojpeg/YUVImage.html @@ -243,6 +243,17 @@ extends java.lang.Object
    Returns the width of the YUV image.
    + +void +setBuf(byte[] yuvImage, + int width, + int pad, + int height, + int subsamp) +
    Assign an existing YUV planar image buffer to this YUVImage + instance.
    + +
    Parameters:
    yuvImage - image buffer that contains or will contain YUV planar image data. See above for a description of the image - format. You can use TJ.bufSizeYUV(int, int, int, int) to determine the appropriate - size for this buffer.
    width - width (in pixels) of the YUV image
    pad - the line padding used in the YUV image buffer. For + format. Use TJ.bufSizeYUV(int, int, int, int) to determine the minimum size for this + buffer.
    width - width (in pixels) of the YUV image
    pad - the line padding used in the YUV image buffer. For instance, if each line in each plane of the buffer is padded to the nearest multiple of 4 bytes, then pad should be set to 4.
    height - height (in pixels) of the YUV image
    subsamp - the level of chrominance subsampling used in the YUV image (one of TJ.SAMP_*)
    @@ -379,6 +390,31 @@ extends java.lang.Object

    Method Detail

    + + + +
      +
    • +

      setBuf

      +
      public void setBuf(byte[] yuvImage,
      +          int width,
      +          int pad,
      +          int height,
      +          int subsamp)
      +            throws java.lang.Exception
      +
      Assign an existing YUV planar image buffer to this YUVImage + instance.
      +
      Parameters:
      yuvImage - image buffer that contains or will contain YUV planar + image data. See above for a description of the image + format. Use TJ.bufSizeYUV(int, int, int, int) to determine the minimum size for this + buffer.
      width - width (in pixels) of the YUV image
      pad - the line padding used in the YUV image buffer. For + instance, if each line in each plane of the buffer is padded to the + nearest multiple of 4 bytes, then pad should be set to 4.
      height - height (in pixels) of the YUV image
      subsamp - the level of chrominance subsampling used in the YUV + image (one of TJ.SAMP_*)
      +
      Throws:
      +
      java.lang.Exception
      +
    • +
    diff --git a/java/org/libjpegturbo/turbojpeg/YUVImage.java b/java/org/libjpegturbo/turbojpeg/YUVImage.java index 67935936..619b0c31 100644 --- a/java/org/libjpegturbo/turbojpeg/YUVImage.java +++ b/java/org/libjpegturbo/turbojpeg/YUVImage.java @@ -74,8 +74,8 @@ public class YUVImage { */ public YUVImage(int width, int pad, int height, int subsamp) throws Exception { - setBuffer(new byte[TJ.bufSizeYUV(width, pad, height, subsamp)], width, pad, - height, subsamp); + setBuf(new byte[TJ.bufSizeYUV(width, pad, height, subsamp)], width, pad, + height, subsamp); } /** @@ -84,8 +84,8 @@ public class YUVImage { * * @param yuvImage image buffer that contains or will contain YUV planar * image data. See {@link YUVImage above} for a description of the image - * format. You can use {@link TJ#bufSizeYUV} to determine the appropriate - * size for this buffer. + * format. Use {@link TJ#bufSizeYUV} to determine the minimum size for this + * buffer. * * @param width width (in pixels) of the YUV image * @@ -100,16 +100,36 @@ public class YUVImage { */ public YUVImage(byte[] yuvImage, int width, int pad, int height, int subsamp) throws Exception { - setBuffer(yuvImage, width, pad, height, subsamp); + setBuf(yuvImage, width, pad, height, subsamp); } - private void setBuffer(byte[] yuvImage, int width, int pad, int height, - int subsamp) throws Exception { + /** + * Assign an existing YUV planar image buffer to this YUVImage + * instance. + * + * @param yuvImage image buffer that contains or will contain YUV planar + * image data. See {@link YUVImage above} for a description of the image + * format. Use {@link TJ#bufSizeYUV} to determine the minimum size for this + * buffer. + * + * @param width width (in pixels) of the YUV image + * + * @param pad the line padding used in the YUV image buffer. For + * instance, if each line in each plane of the buffer is padded to the + * nearest multiple of 4 bytes, then pad should be set to 4. + * + * @param height height (in pixels) of the YUV image + * + * @param subsamp the level of chrominance subsampling used in the YUV + * image (one of {@link TJ#SAMP_444 TJ.SAMP_*}) + */ + public void setBuf(byte[] yuvImage, int width, int pad, int height, + int subsamp) throws Exception { if (yuvImage == null || width < 1 || pad < 1 || ((pad & (pad - 1)) != 0) || height < 1 || subsamp < 0 || subsamp >= TJ.NUMSAMP) throw new Exception("Invalid argument in YUVImage()"); - if (yuvImage.length != TJ.bufSizeYUV(width, pad, height, subsamp)) - throw new Exception("YUV image buffer is the wrong size"); + if (yuvImage.length < TJ.bufSizeYUV(width, pad, height, subsamp)) + throw new Exception("YUV image buffer is not large enough"); yuvBuf = yuvImage; yuvWidth = width; yuvPad = pad; @@ -181,7 +201,7 @@ public class YUVImage { public int getSize() throws Exception { if (yuvBuf == null) throw new Exception(NO_ASSOC_ERROR); - return yuvBuf.length; + return TJ.bufSizeYUV(yuvWidth, yuvPad, yuvHeight, yuvSubsamp); } protected long handle = 0; diff --git a/tjbenchtest.in b/tjbenchtest.in index 1ebd0b8f..5e08c9b3 100755 --- a/tjbenchtest.in +++ b/tjbenchtest.in @@ -159,7 +159,7 @@ for image in $IMAGES; do done for xform in hflip vflip transpose transverse rot90 rot180 rot270; do for samp in GRAY 444; do - runme $EXEDIR/djpeg -rgb $BMPARG -outfile $OUTDIR/${basename}_${samp}_${xform}_jpegtran.${EXT} $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg + runme $EXEDIR/djpeg -rgb $BMPARG -outfile $OUTDIR/${basename}_${samp}_${xform}_jpegtran.${EXT} $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -$xform -tile -quiet -benchtime 0.01 -warmup 0 $YUVARG for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].${EXT} \ $OUTDIR/${basename}_${samp}_Q95_full.${EXT}; do diff --git a/tjbenchtest.java.in b/tjbenchtest.java.in index ebff9c84..1869bca6 100755 --- a/tjbenchtest.java.in +++ b/tjbenchtest.java.in @@ -24,6 +24,9 @@ IMGDIR=@srcdir@/testimages OUTDIR=__tjbenchtest_java_output EXEDIR=. JAVA="@JAVA@ -cp java/turbojpeg.jar -Djava.library.path=.libs" +BMPARG= +NSARG= +YUVARG= if [ -d $OUTDIR ]; then rm -rf $OUTDIR @@ -32,33 +35,58 @@ mkdir -p $OUTDIR exec >$EXEDIR/tjbenchtest-java.log +if [ $# -gt 0 ]; then + if [ "$1" = "-yuv" ]; then + NSARG=-nosmooth + YUVARG=-yuv + +# NOTE: The combination of tjEncodeYUV*() and tjCompressFromYUV*() does not +# always produce bitwise-identical results to tjCompress*() if subsampling is +# enabled. In both cases, if the image width or height are not evenly +# divisible by the MCU width/height, then the bottom and/or right edge are +# expanded. However, the libjpeg code performs this expansion prior to +# downsampling, and TurboJPEG performs it in tjCompressFromYUV*(), which is +# after downsampling. Thus, the two will agree only if the width/height along +# each downsampled dimension is an odd number or is evenly divisible by the MCU +# width/height. This disagreement basically amounts to a round-off error, but +# there is no easy way around it, so for now, we just test the only image that +# works. (NOTE: nightshot_iso_100 does not suffer from the above issue, but +# it suffers from an unrelated problem whereby the combination of +# tjDecompressToYUV*() and tjDecodeYUV*() do not produce bitwise-identical +# results to tjDecompress*() if decompression scaling is enabled. This latter +# phenomenon is not yet fully understood but is also believed to be some sort +# of round-off error.) + IMAGES="vgl_6548_0026a.bmp" + fi +fi + # Standard tests for image in $IMAGES; do cp $IMGDIR/$image $OUTDIR basename=`basename $image .bmp` - $EXEDIR/cjpeg -quality 95 -dct fast -grayscale $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_GRAY_fast_cjpeg.jpg - $EXEDIR/cjpeg -quality 95 -dct fast -sample 2x2 $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_420_fast_cjpeg.jpg - $EXEDIR/cjpeg -quality 95 -dct fast -sample 2x1 $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_422_fast_cjpeg.jpg - $EXEDIR/cjpeg -quality 95 -dct fast -sample 1x1 $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_444_fast_cjpeg.jpg - $EXEDIR/cjpeg -quality 95 -dct int -grayscale $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_GRAY_accurate_cjpeg.jpg - $EXEDIR/cjpeg -quality 95 -dct int -sample 2x2 $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_420_accurate_cjpeg.jpg - $EXEDIR/cjpeg -quality 95 -dct int -sample 2x1 $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_422_accurate_cjpeg.jpg - $EXEDIR/cjpeg -quality 95 -dct int -sample 1x1 $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_444_accurate_cjpeg.jpg + runme $EXEDIR/cjpeg -quality 95 -dct fast -grayscale -outfile $OUTDIR/${basename}_GRAY_fast_cjpeg.jpg $IMGDIR/${basename}.bmp + runme $EXEDIR/cjpeg -quality 95 -dct fast -sample 2x2 -outfile $OUTDIR/${basename}_420_fast_cjpeg.jpg $IMGDIR/${basename}.bmp + runme $EXEDIR/cjpeg -quality 95 -dct fast -sample 2x1 -outfile $OUTDIR/${basename}_422_fast_cjpeg.jpg $IMGDIR/${basename}.bmp + runme $EXEDIR/cjpeg -quality 95 -dct fast -sample 1x1 -outfile $OUTDIR/${basename}_444_fast_cjpeg.jpg $IMGDIR/${basename}.bmp + runme $EXEDIR/cjpeg -quality 95 -dct int -grayscale -outfile $OUTDIR/${basename}_GRAY_accurate_cjpeg.jpg $IMGDIR/${basename}.bmp + runme $EXEDIR/cjpeg -quality 95 -dct int -sample 2x2 -outfile $OUTDIR/${basename}_420_accurate_cjpeg.jpg $IMGDIR/${basename}.bmp + runme $EXEDIR/cjpeg -quality 95 -dct int -sample 2x1 -outfile $OUTDIR/${basename}_422_accurate_cjpeg.jpg $IMGDIR/${basename}.bmp + runme $EXEDIR/cjpeg -quality 95 -dct int -sample 1x1 -outfile $OUTDIR/${basename}_444_accurate_cjpeg.jpg $IMGDIR/${basename}.bmp for samp in GRAY 420 422 444; do - $EXEDIR/djpeg -rgb -bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg >$OUTDIR/${basename}_${samp}_default_djpeg.bmp - $EXEDIR/djpeg -dct fast -rgb -bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg >$OUTDIR/${basename}_${samp}_fast_djpeg.bmp - $EXEDIR/djpeg -dct int -rgb -bmp $OUTDIR/${basename}_${samp}_accurate_cjpeg.jpg >$OUTDIR/${basename}_${samp}_accurate_djpeg.bmp + runme $EXEDIR/djpeg -rgb -bmp -outfile $OUTDIR/${basename}_${samp}_default_djpeg.bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg + runme $EXEDIR/djpeg -dct fast -rgb -bmp -outfile $OUTDIR/${basename}_${samp}_fast_djpeg.bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg + runme $EXEDIR/djpeg -dct int -rgb -bmp -outfile $OUTDIR/${basename}_${samp}_accurate_djpeg.bmp $OUTDIR/${basename}_${samp}_accurate_cjpeg.jpg done for samp in 420 422; do - $EXEDIR/djpeg -nosmooth -bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg >$OUTDIR/${basename}_${samp}_default_nosmooth_djpeg.bmp - $EXEDIR/djpeg -dct fast -nosmooth -bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg >$OUTDIR/${basename}_${samp}_fast_nosmooth_djpeg.bmp - $EXEDIR/djpeg -dct int -nosmooth -bmp $OUTDIR/${basename}_${samp}_accurate_cjpeg.jpg >$OUTDIR/${basename}_${samp}_accurate_nosmooth_djpeg.bmp + runme $EXEDIR/djpeg -nosmooth -bmp -outfile $OUTDIR/${basename}_${samp}_default_nosmooth_djpeg.bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg + runme $EXEDIR/djpeg -dct fast -nosmooth -bmp -outfile $OUTDIR/${basename}_${samp}_fast_nosmooth_djpeg.bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg + runme $EXEDIR/djpeg -dct int -nosmooth -bmp -outfile $OUTDIR/${basename}_${samp}_accurate_nosmooth_djpeg.bmp $OUTDIR/${basename}_${samp}_accurate_cjpeg.jpg done # Compression for dct in accurate fast; do - runme $JAVA TJBench $OUTDIR/$image 95 -rgb -quiet -benchtime 0.01 -${dct}dct + runme $JAVA TJBench $OUTDIR/$image 95 -rgb -quiet -benchtime 0.01 -warmup 0 -${dct}dct $YUVARG for samp in GRAY 420 422 444; do runme cmp $OUTDIR/${basename}_${samp}_Q95.jpg $OUTDIR/${basename}_${samp}_${dct}_cjpeg.jpg done @@ -71,7 +99,7 @@ for image in $IMAGES; do fi # Tiled compression & decompression - runme $JAVA TJBench $OUTDIR/$image 95 -rgb -tile -quiet -benchtime 0.01 ${dctarg} + runme $JAVA TJBench $OUTDIR/$image 95 -rgb -tile -quiet -benchtime 0.01 -warmup 0 ${dctarg} $YUVARG for samp in GRAY 444; do for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].bmp \ $OUTDIR/${basename}_${samp}_Q95_full.bmp; do @@ -79,7 +107,7 @@ for image in $IMAGES; do rm $i done done - runme $JAVA TJBench $OUTDIR/$image 95 -rgb -tile -quiet -benchtime 0.01 -fastupsample ${dctarg} + runme $JAVA TJBench $OUTDIR/$image 95 -rgb -tile -quiet -benchtime 0.01 -warmup 0 -fastupsample ${dctarg} $YUVARG for samp in 420 422; do for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].bmp \ $OUTDIR/${basename}_${samp}_Q95_full.bmp; do @@ -90,7 +118,7 @@ for image in $IMAGES; do # Tiled decompression for samp in GRAY 444; do - runme $JAVA TJBench $OUTDIR/${basename}_${samp}_Q95.jpg -tile -quiet -benchtime 0.01 ${dctarg} + runme $JAVA TJBench $OUTDIR/${basename}_${samp}_Q95.jpg -tile -quiet -benchtime 0.01 -warmup 0 ${dctarg} $YUVARG for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].bmp \ $OUTDIR/${basename}_${samp}_Q95_full.bmp; do runme cmp -i 54:54 $i $OUTDIR/${basename}_${samp}_${dct}_djpeg.bmp @@ -98,7 +126,7 @@ for image in $IMAGES; do done done for samp in 420 422; do - runme $JAVA TJBench $OUTDIR/${basename}_${samp}_Q95.jpg -tile -quiet -benchtime 0.01 -fastupsample ${dctarg} + runme $JAVA TJBench $OUTDIR/${basename}_${samp}_Q95.jpg -tile -quiet -benchtime 0.01 -warmup 0 -fastupsample ${dctarg} $YUVARG for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].bmp \ $OUTDIR/${basename}_${samp}_Q95_full.bmp; do runme cmp $i -i 54:54 $OUTDIR/${basename}_${samp}_${dct}_nosmooth_djpeg.bmp @@ -111,8 +139,8 @@ for image in $IMAGES; do for scale in 2_1 15_8 7_4 13_8 3_2 11_8 5_4 9_8 7_8 3_4 5_8 1_2 3_8 1_4 1_8; do scalearg=`echo $scale | sed s@_@/@g` for samp in GRAY 420 422 444; do - $EXEDIR/djpeg -rgb -scale ${scalearg} -bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg >$OUTDIR/${basename}_${samp}_${scale}_djpeg.bmp - runme $JAVA TJBench $OUTDIR/${basename}_${samp}_Q95.jpg -scale ${scalearg} -quiet -benchtime 0.01 + runme $EXEDIR/djpeg -rgb -scale ${scalearg} $NSARG -bmp -outfile $OUTDIR/${basename}_${samp}_${scale}_djpeg.bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg + runme $JAVA TJBench $OUTDIR/${basename}_${samp}_Q95.jpg -scale ${scalearg} -quiet -benchtime 0.01 -warmup 0 $YUVARG runme cmp -i 54:54 $OUTDIR/${basename}_${samp}_Q95_${scale}.bmp $OUTDIR/${basename}_${samp}_${scale}_djpeg.bmp rm $OUTDIR/${basename}_${samp}_Q95_${scale}.bmp done @@ -120,18 +148,18 @@ for image in $IMAGES; do # Transforms for samp in GRAY 420 422 444; do - $EXEDIR/jpegtran -flip horizontal -trim $OUTDIR/${basename}_${samp}_Q95.jpg >$OUTDIR/${basename}_${samp}_hflip_jpegtran.jpg - $EXEDIR/jpegtran -flip vertical -trim $OUTDIR/${basename}_${samp}_Q95.jpg >$OUTDIR/${basename}_${samp}_vflip_jpegtran.jpg - $EXEDIR/jpegtran -transpose -trim $OUTDIR/${basename}_${samp}_Q95.jpg >$OUTDIR/${basename}_${samp}_transpose_jpegtran.jpg - $EXEDIR/jpegtran -transverse -trim $OUTDIR/${basename}_${samp}_Q95.jpg >$OUTDIR/${basename}_${samp}_transverse_jpegtran.jpg - $EXEDIR/jpegtran -rotate 90 -trim $OUTDIR/${basename}_${samp}_Q95.jpg >$OUTDIR/${basename}_${samp}_rot90_jpegtran.jpg - $EXEDIR/jpegtran -rotate 180 -trim $OUTDIR/${basename}_${samp}_Q95.jpg >$OUTDIR/${basename}_${samp}_rot180_jpegtran.jpg - $EXEDIR/jpegtran -rotate 270 -trim $OUTDIR/${basename}_${samp}_Q95.jpg >$OUTDIR/${basename}_${samp}_rot270_jpegtran.jpg + runme $EXEDIR/jpegtran -flip horizontal -trim -outfile $OUTDIR/${basename}_${samp}_hflip_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg + runme $EXEDIR/jpegtran -flip vertical -trim -outfile $OUTDIR/${basename}_${samp}_vflip_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg + runme $EXEDIR/jpegtran -transpose -trim -outfile $OUTDIR/${basename}_${samp}_transpose_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg + runme $EXEDIR/jpegtran -transverse -trim -outfile $OUTDIR/${basename}_${samp}_transverse_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg + runme $EXEDIR/jpegtran -rotate 90 -trim -outfile $OUTDIR/${basename}_${samp}_rot90_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg + runme $EXEDIR/jpegtran -rotate 180 -trim -outfile $OUTDIR/${basename}_${samp}_rot180_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg + runme $EXEDIR/jpegtran -rotate 270 -trim -outfile $OUTDIR/${basename}_${samp}_rot270_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg done for xform in hflip vflip transpose transverse rot90 rot180 rot270; do for samp in GRAY 444; do - $EXEDIR/djpeg -rgb -bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg >$OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp - runme $JAVA TJBench $OUTDIR/${basename}_${samp}_Q95.jpg -$xform -tile -quiet -benchtime 0.01 + runme $EXEDIR/djpeg -rgb -bmp -outfile $OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg + runme $JAVA TJBench $OUTDIR/${basename}_${samp}_Q95.jpg -$xform -tile -quiet -benchtime 0.01 -warmup 0 $YUVARG for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].bmp \ $OUTDIR/${basename}_${samp}_Q95_full.bmp; do runme cmp -i 54:54 $i $OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp @@ -139,8 +167,8 @@ for image in $IMAGES; do done done for samp in 420 422; do - $EXEDIR/djpeg -nosmooth -rgb -bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg >$OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp - runme $JAVA TJBench $OUTDIR/${basename}_${samp}_Q95.jpg -$xform -tile -quiet -benchtime 0.01 -fastupsample + runme $EXEDIR/djpeg -nosmooth -rgb -bmp -outfile $OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg + runme $JAVA TJBench $OUTDIR/${basename}_${samp}_Q95.jpg -$xform -tile -quiet -benchtime 0.01 -warmup 0 -fastupsample $YUVARG for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].bmp \ $OUTDIR/${basename}_${samp}_Q95_full.bmp; do runme cmp -i 54:54 $i $OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp @@ -152,7 +180,7 @@ for image in $IMAGES; do # Grayscale transform for xform in hflip vflip transpose transverse rot90 rot180 rot270; do for samp in GRAY 444 422 420; do - runme $JAVA TJBench $OUTDIR/${basename}_${samp}_Q95.jpg -$xform -tile -quiet -benchtime 0.01 -grayscale + runme $JAVA TJBench $OUTDIR/${basename}_${samp}_Q95.jpg -$xform -tile -quiet -benchtime 0.01 -warmup 0 -grayscale $YUVARG for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].bmp \ $OUTDIR/${basename}_${samp}_Q95_full.bmp; do runme cmp -i 54:54 $i $OUTDIR/${basename}_GRAY_${xform}_jpegtran.bmp @@ -166,8 +194,8 @@ for image in $IMAGES; do for samp in GRAY 444 422 420; do for scale in 2_1 15_8 7_4 13_8 3_2 11_8 5_4 9_8 7_8 3_4 5_8 1_2 3_8 1_4 1_8; do scalearg=`echo $scale | sed s@_@/@g` - $EXEDIR/djpeg -rgb -scale ${scalearg} -bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg >$OUTDIR/${basename}_${samp}_${xform}_${scale}_jpegtran.bmp - runme $JAVA TJBench $OUTDIR/${basename}_${samp}_Q95.jpg -$xform -scale ${scalearg} -quiet -benchtime 0.01 + runme $EXEDIR/djpeg -rgb -scale ${scalearg} $NSARG -bmp -outfile $OUTDIR/${basename}_${samp}_${xform}_${scale}_jpegtran.bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg + runme $JAVA TJBench $OUTDIR/${basename}_${samp}_Q95.jpg -$xform -scale ${scalearg} -quiet -benchtime 0.01 -warmup 0 $YUVARG runme cmp -i 54:54 $OUTDIR/${basename}_${samp}_Q95_${scale}.bmp $OUTDIR/${basename}_${samp}_${xform}_${scale}_jpegtran.bmp rm $OUTDIR/${basename}_${samp}_Q95_${scale}.bmp done From 7bb4dbb81bad6bd1bac62f593cba8c158191f43c Mon Sep 17 00:00:00 2001 From: DRC Date: Fri, 21 Mar 2014 08:36:58 +0000 Subject: [PATCH 52/65] Enable silent build (can be overridden with 'make V=1') if the version of autotools being used is new enough. --- configure.ac | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configure.ac b/configure.ac index d0780c93..7ccd1b65 100644 --- a/configure.ac +++ b/configure.ac @@ -11,6 +11,8 @@ AC_PREFIX_DEFAULT(/opt/libjpeg-turbo) # Always build with prototypes AC_DEFINE([HAVE_PROTOTYPES], 1, [Define if your compiler supports prototypes]) +m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) + # Checks for programs. SAVED_CFLAGS=${CFLAGS} SAVED_CPPFLAGS=${CPPFLAGS} From 92c7ae89118f93276026fb6df1f0bfb040304fcc Mon Sep 17 00:00:00 2001 From: DRC Date: Fri, 21 Mar 2014 09:23:41 +0000 Subject: [PATCH 53/65] Fix compiler warning ("always_inline function might not be inlinable") when building with recent versions of GCC --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 7ccd1b65..4173f25d 100644 --- a/configure.ac +++ b/configure.ac @@ -266,7 +266,7 @@ AC_SUBST(VERSION_SCRIPT_FLAG) AC_MSG_CHECKING(for inline) ljt_cv_inline="" AC_TRY_COMPILE(, [} __attribute__((always_inline)) int foo() { return 0; } -int bar() { return foo();], ljt_cv_inline="__attribute__((always_inline))", +int bar() { return foo();], ljt_cv_inline="inline __attribute__((always_inline))", AC_TRY_COMPILE(, [} __inline__ int foo() { return 0; } int bar() { return foo();], ljt_cv_inline="__inline__", AC_TRY_COMPILE(, [} __inline int foo() { return 0; } From dd12a235c52e91b2bbddb427679ee8d531d65d72 Mon Sep 17 00:00:00 2001 From: DRC Date: Fri, 21 Mar 2014 09:35:02 +0000 Subject: [PATCH 54/65] Fix compiler warning about unused function when building with the libjpeg v6b API/ABI --- transupp.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/transupp.c b/transupp.c index 70e8c498..a16b20a5 100644 --- a/transupp.c +++ b/transupp.c @@ -1176,6 +1176,7 @@ transpose_critical_parameters (j_compress_ptr dstinfo) * We try to adjust the Tags ExifImageWidth and ExifImageHeight if possible. */ +#if JPEG_LIB_VERSION >= 70 LOCAL(void) adjust_exif_parameters (JOCTET FAR * data, unsigned int length, JDIMENSION new_width, JDIMENSION new_height) @@ -1325,6 +1326,7 @@ adjust_exif_parameters (JOCTET FAR * data, unsigned int length, offset += 12; } while (--number_of_tags); } +#endif /* Adjust output image parameters as needed. From 67599a5dc61cbe40fb504a20fa940faa0b4ce28d Mon Sep 17 00:00:00 2001 From: DRC Date: Fri, 21 Mar 2014 11:01:00 +0000 Subject: [PATCH 55/65] RHEL 6 (and probably other platforms as well) sets _defaultdocdir=%{_datadir}/doc, which screws things up, since we're overriding _datadir. Since we intend _defaultdocdir to be /usr/share/doc, just be explicit about it. --- release/libjpeg-turbo.spec.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/libjpeg-turbo.spec.in b/release/libjpeg-turbo.spec.in index 616618d5..23793cf5 100644 --- a/release/libjpeg-turbo.spec.in +++ b/release/libjpeg-turbo.spec.in @@ -8,7 +8,7 @@ %define _datadir %{__datadir} # Path under which docs should be installed -%define _docdir %{_defaultdocdir}/%{name}-%{version} +%define _docdir /usr/share/doc/%{name}-%{version} # Path under which headers should be installed %define _includedir %{__includedir} From d10edbc1eecd353185483f5630bf014bc38cb64e Mon Sep 17 00:00:00 2001 From: DRC Date: Sat, 22 Mar 2014 20:22:52 +0000 Subject: [PATCH 56/65] Fix 'make dist' --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 0636b287..c8c066dc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -154,7 +154,7 @@ dist_example_DATA = example.c EXTRA_DIST = win release $(DOCS) testimages CMakeLists.txt \ sharedlib/CMakeLists.txt cmakescripts libjpeg.map.in doc doxygen.config \ - jccolext.c jdcolext.c jdmrgext.c + jccolext.c jdcolext.c jdmrgext.c jstdhuff.c dist-hook: rm -rf `find $(distdir) -name .svn` From 1cf34093b992ded3541e216b68905969cb63f2ce Mon Sep 17 00:00:00 2001 From: DRC Date: Sat, 22 Mar 2014 20:43:03 +0000 Subject: [PATCH 57/65] --- ChangeLog.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index 25f673e8..fb148caa 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -65,6 +65,13 @@ source image, and added a unit test to check for this error. [6] The Java classes should now build properly under Visual Studio 2010 and later. +[7] Fixed an issue that prevented SRPMs generated using the in-tree packaging +tools from being rebuilt on certain newer Linux distributions. + +[8] Numerous minor fixes to eliminate compilation and build/packaging system +warnings, fix cosmetic issues, improve documentation clarity, and other general +source cleanup. + 1.3.0 ===== From 166227c3c7e2b2501f4ecd536e8b646dd00e0250 Mon Sep 17 00:00:00 2001 From: DRC Date: Sat, 22 Mar 2014 20:51:38 +0000 Subject: [PATCH 58/65] Since we're now maintaining our own Cygwin pseudo-repository directories instead of recommending that users install these packages from a local source, it makes more sense to name the packages according to Cygwin specs, so they can be copied as-is into the pseudo-repository. --- release/makecygwinpkg.in | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/release/makecygwinpkg.in b/release/makecygwinpkg.in index 5a5338a7..f3035469 100755 --- a/release/makecygwinpkg.in +++ b/release/makecygwinpkg.in @@ -17,19 +17,15 @@ onexit() PACKAGE_NAME=@PKGNAME@ VERSION=@VERSION@ +BUILD=@BUILD@ SRCDIR=@abs_top_srcdir@ -RPMARCH=@RPMARCH@ -PLATFORM=cygwin PREFIX=%{__prefix} DOCDIR=%{__docdir} LIBDIR=%{__libdir} umask 022 -if [ "$RPMARCH" = "x86_64" ]; then - PLATFORM=cygwin64 -fi -rm -f $PACKAGE_NAME-$VERSION-$PLATFORM.tar.bz2 +rm -f $PACKAGE_NAME-$VERSION-$BUILD.tar.bz2 TMPDIR=`mktemp -d /tmp/ljtbuild.XXXXXX` __PWD=`pwd` make install DESTDIR=$TMPDIR/pkg docdir=/usr/share/doc/$PACKAGE_NAME-$VERSION \ @@ -39,7 +35,7 @@ if [ "$PREFIX" = "/opt/libjpeg-turbo" -a "$DOCDIR" = "/opt/libjpeg-turbo/doc" ]; ln -fs /usr/share/doc/$PACKAGE_NAME-$VERSION $TMPDIR/pkg$DOCDIR fi cd $TMPDIR/pkg -tar cfj ../$PACKAGE_NAME-$VERSION-$PLATFORM.tar.bz2 * +tar cfj ../$PACKAGE_NAME-$VERSION-$BUILD.tar.bz2 * cd $__PWD mv $TMPDIR/*.tar.bz2 . From 87768cc42cb0a6aa0d94a36a4c6cbcca15437b83 Mon Sep 17 00:00:00 2001 From: DRC Date: Sat, 22 Mar 2014 23:03:03 +0000 Subject: [PATCH 59/65] Fix Windows build --- java/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/java/CMakeLists.txt b/java/CMakeLists.txt index 19127e30..f9f9e572 100644 --- a/java/CMakeLists.txt +++ b/java/CMakeLists.txt @@ -8,6 +8,7 @@ set(JAVA_CLASSNAMES org/libjpegturbo/turbojpeg/TJ org/libjpegturbo/turbojpeg/TJScalingFactor org/libjpegturbo/turbojpeg/TJTransform org/libjpegturbo/turbojpeg/TJTransformer + org/libjpegturbo/turbojpeg/YUVImage TJUnitTest TJExample TJBench) From fdc2954e7924b1bc528d0284f263bcada1c366cd Mon Sep 17 00:00:00 2001 From: DRC Date: Sun, 23 Mar 2014 15:21:20 +0000 Subject: [PATCH 60/65] Remove the sections about replacing libjpeg at run time and compile time. These were written before O/S distributions started shipping libjpeg-turbo, and they are either pedantic or no longer relevant. Also remove any text that assumes the use of our official project binaries. Notes specific to the official binaries have been moved into the project wiki. --- README-turbo.txt | 127 +---------------------------------------------- 1 file changed, 1 insertion(+), 126 deletions(-) diff --git a/README-turbo.txt b/README-turbo.txt index b81299f1..24e86ed2 100755 --- a/README-turbo.txt +++ b/README-turbo.txt @@ -81,131 +81,6 @@ JPEG images: There is no significant performance advantage to either API when both are used to perform similar operations. -====================== -Installation Directory -====================== - -This document assumes that libjpeg-turbo will be installed in the default -directory (/opt/libjpeg-turbo on Un*x and Mac systems and -c:\libjpeg-turbo[-gcc][64] on Windows systems. If your installation of -libjpeg-turbo resides in a different directory, then adjust the instructions -accordingly. - -============================= -Replacing libjpeg at Run Time -============================= - -Un*x ----- - -If a Un*x application is dynamically linked with libjpeg, then you can replace -libjpeg with libjpeg-turbo at run time by manipulating LD_LIBRARY_PATH. -For instance: - - [Using libjpeg] - > time cjpeg vgl_5674_0098.jpg - real 0m0.392s - user 0m0.074s - sys 0m0.020s - - [Using libjpeg-turbo] - > export LD_LIBRARY_PATH=/opt/libjpeg-turbo/{lib}:$LD_LIBRARY_PATH - > time cjpeg vgl_5674_0098.jpg - real 0m0.109s - user 0m0.029s - sys 0m0.010s - -({lib} = lib32 or lib64, depending on whether you wish to use the 32-bit or the -64-bit version of libjpeg-turbo.) - -System administrators can also replace the libjpeg symlinks in /usr/lib* with -links to the libjpeg-turbo dynamic library located in /opt/libjpeg-turbo/{lib}. -This will effectively accelerate every application that uses the libjpeg -dynamic library on the system. - -Windows -------- - -If a Windows application is dynamically linked with libjpeg, then you can -replace libjpeg with libjpeg-turbo at run time by backing up the application's -copy of jpeg62.dll, jpeg7.dll, or jpeg8.dll (assuming the application has its -own local copy of this library) and copying the corresponding DLL from -libjpeg-turbo into the application's install directory. The official -libjpeg-turbo binary packages only provide jpeg62.dll. If the application uses -jpeg7.dll or jpeg8.dll instead, then it will be necessary to build -libjpeg-turbo from source (see "libjpeg v7 and v8 API/ABI Emulation" below.) - -The following information is specific to the official libjpeg-turbo binary -packages for Visual C++: - --- jpeg62.dll requires the Visual C++ 2008 C run-time DLL (msvcr90.dll). -msvcr90.dll ships with more recent versions of Windows, but users of older -Windows releases can obtain it from the Visual C++ 2008 Redistributable -Package, which is available as a free download from Microsoft's web site. - --- Features of the libjpeg API that require passing a C run-time structure, -such as a file handle, from an application to the library will probably not -work with jpeg62.dll, unless the application is also built to use the Visual -C++ 2008 C run-time DLL. In particular, this affects jpeg_stdio_dest() and -jpeg_stdio_src(). - -Mac ---- - -Mac applications typically embed their own copies of the libjpeg dylib inside -the (hidden) application bundle, so it is not possible to globally replace -libjpeg on OS X systems. Replacing the application's version of the libjpeg -dylib would generally involve copying libjpeg.*.dylib from libjpeg-turbo into -the appropriate place in the application bundle and using install_name_tool to -repoint the libjpeg-turbo dylib to its new directory. This requires an -advanced knowledge of OS X and would not survive an upgrade or a re-install of -the application. Thus, it is not recommended for most users. - -======================================== -Using libjpeg-turbo in Your Own Programs -======================================== - -For the most part, libjpeg-turbo should work identically to libjpeg, so in -most cases, an application can be built against libjpeg and then run against -libjpeg-turbo. On Un*x systems and Cygwin, you can build against libjpeg-turbo -instead of libjpeg by setting - - CPATH=/opt/libjpeg-turbo/include - and - LIBRARY_PATH=/opt/libjpeg-turbo/{lib} - -({lib} = lib32 or lib64, depending on whether you are building a 32-bit or a -64-bit application.) - -If using MinGW, then set - - CPATH=/c/libjpeg-turbo-gcc[64]/include - and - LIBRARY_PATH=/c/libjpeg-turbo-gcc[64]/lib - -Building against libjpeg-turbo is useful, for instance, if you want to build an -application that leverages the libjpeg-turbo colorspace extensions (see below.) -On Un*x systems, you would still need to manipulate LD_LIBRARY_PATH or create -appropriate symlinks to use libjpeg-turbo at run time. On such systems, you -can pass -R /opt/libjpeg-turbo/{lib} to the linker to force the use of -libjpeg-turbo at run time rather than libjpeg (also useful if you want to -leverage the colorspace extensions), or you can link against the libjpeg-turbo -static library. - -To force a Un*x or MinGW application to link against the static version of -libjpeg-turbo, you can use the following linker options: - - -Wl,-Bstatic -ljpeg -Wl,-Bdynamic - -On OS X, simply add /opt/libjpeg-turbo/lib/libjpeg.a to the linker command -line. - -To build Visual C++ applications using libjpeg-turbo, add -c:\libjpeg-turbo[64]\include to the system or user INCLUDE environment -variable and c:\libjpeg-turbo[64]\lib to the system or user LIB environment -variable, and then link against either jpeg.lib (to use the DLL version of -libjpeg-turbo) or jpeg-static.lib (to use the static version of libjpeg-turbo.) - ===================== Colorspace Extensions ===================== @@ -265,7 +140,7 @@ compression and decompression structures. Unfortunately, due to the exposed nature of those structures, extending them also necessitated breaking backward ABI compatibility with previous libjpeg releases. Thus, programs that were built to use libjpeg v7 or v8 did not work with libjpeg-turbo, since it is -based on the libjpeg v6b code base. Although libjpeg v7 and v8 are still not +based on the libjpeg v6b code base. Although libjpeg v7 and v8 are not as widely used as v6b, enough programs (including a few Linux distros) made the switch that there was a demand to emulate the libjpeg v7 and v8 ABIs in libjpeg-turbo. It should be noted, however, that this feature was added From aa411b107f4c1d0bfc9d249db436f8fee98d36df Mon Sep 17 00:00:00 2001 From: DRC Date: Sun, 23 Mar 2014 17:53:07 +0000 Subject: [PATCH 61/65] Migrate Mac packaging system to pkgbuild, since PackageMaker is no longer supported. --- ChangeLog.txt | 6 +++++ configure.ac | 2 -- release/Description.plist.in | 12 ---------- release/Distribution.xml | 24 ++++++++++++++++++++ release/Info.plist.in | 44 ------------------------------------ release/ReadMe.rtf | 13 ----------- release/ReadMe.txt | 5 ++++ release/makemacpkg.in | 22 ++++++++---------- 8 files changed, 45 insertions(+), 83 deletions(-) delete mode 100644 release/Description.plist.in create mode 100644 release/Distribution.xml delete mode 100755 release/Info.plist.in delete mode 100644 release/ReadMe.rtf create mode 100644 release/ReadMe.txt diff --git a/ChangeLog.txt b/ChangeLog.txt index fb148caa..4b3db1ee 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -33,6 +33,12 @@ successfully decompressed by libjpeg-turbo without additional work on the part of the application. An application can still override the Huffman tables, for instance to re-use tables from a previous frame of the same video. +[4] The Mac packaging system now uses pkgbuild and productbuild rather than +PackageMaker (which is obsolete and no longer supported.) This means that +OS X 10.6 "Snow Leopard" or later must be used when packaging libjpeg-turbo, +although the packages produced can be installed on OS X 10.5 "Leopard" or +later. OS X 10.4 "Tiger" is no longer supported. + 1.3.1 ===== diff --git a/configure.ac b/configure.ac index 4173f25d..ff5cf668 100644 --- a/configure.ac +++ b/configure.ac @@ -530,8 +530,6 @@ AC_CONFIG_FILES([pkgscripts/libjpeg-turbo.spec.tmpl:release/libjpeg-turbo.spec.i AC_CONFIG_FILES([pkgscripts/makecygwinpkg.tmpl:release/makecygwinpkg.in]) AC_CONFIG_FILES([pkgscripts/makedpkg.tmpl:release/makedpkg.in]) AC_CONFIG_FILES([pkgscripts/makemacpkg.tmpl:release/makemacpkg.in]) -AC_CONFIG_FILES([pkgscripts/Description.plist:release/Description.plist.in]) -AC_CONFIG_FILES([pkgscripts/Info.plist:release/Info.plist.in]) AC_CONFIG_FILES([pkgscripts/uninstall.tmpl:release/uninstall.in]) if test "x$with_turbojpeg" != "xno"; then AC_CONFIG_FILES([tjbenchtest]) diff --git a/release/Description.plist.in b/release/Description.plist.in deleted file mode 100644 index 46a5bceb..00000000 --- a/release/Description.plist.in +++ /dev/null @@ -1,12 +0,0 @@ - - - - - IFPkgDescriptionDescription - A SIMD-accelerated JPEG codec that provides both the libjpeg and TurboJPEG APIs - IFPkgDescriptionTitle - @PACKAGE_NAME@ - IFPkgDescriptionVersion - @VERSION@ - - diff --git a/release/Distribution.xml b/release/Distribution.xml new file mode 100644 index 00000000..ee73ab00 --- /dev/null +++ b/release/Distribution.xml @@ -0,0 +1,24 @@ + + + libjpeg-turbo + + + + + + + + + + + + + + + libjpeg-turbo.pkg + diff --git a/release/Info.plist.in b/release/Info.plist.in deleted file mode 100755 index 05750791..00000000 --- a/release/Info.plist.in +++ /dev/null @@ -1,44 +0,0 @@ - - - - - CFBundleGetInfoString - @VERSION@, The libjpeg-turbo Project - CFBundleIdentifier - com.libjpeg-turbo.libjpeg-turbo - CFBundleShortVersionString - @VERSION@ - IFMajorVersion - 1 - IFMinorVersion - @BUILD@ - IFPkgFlagAllowBackRev - - IFPkgFlagAuthorizationAction - AdminAuthorization - IFPkgFlagBackgroundAlignment - topleft - IFPkgFlagBackgroundScaling - none - IFPkgFlagDefaultLocation - / - IFPkgFlagFollowLinks - - IFPkgFlagInstallFat - - IFPkgFlagIsRequired - - IFPkgFlagOverwritePermissions - - IFPkgFlagRelocatable - - IFPkgFlagRestartAction - NoRestart - IFPkgFlagRootVolumeOnly - - IFPkgFlagUpdateInstalledLanguages - - IFPkgFormatVersion - 0.10000000149011612 - - diff --git a/release/ReadMe.rtf b/release/ReadMe.rtf deleted file mode 100644 index 2ae48780..00000000 --- a/release/ReadMe.rtf +++ /dev/null @@ -1,13 +0,0 @@ -{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf360 -{\fonttbl\f0\fswiss\fcharset0 Helvetica;} -{\colortbl;\red255\green255\blue255;} -\margl1440\margr1440\vieww26380\viewh15840\viewkind0 -\deftab720 -\pard\pardeftab720\ql\qnatural - -\f0\fs24 \cf0 libjpeg-turbo is a JPEG image codec that uses SIMD instructions (MMX, SSE2, NEON) to accelerate baseline JPEG compression and decompression on x86, x86-64, and ARM systems. On such systems, libjpeg-turbo is generally 2-4x as fast as libjpeg, all else being equal. On other types of systems, libjpeg-turbo can still outperform libjpeg by a significant amount, by virtue of its highly-optimized Huffman coding routines. In many cases, the performance of libjpeg-turbo rivals that of proprietary high-speed JPEG codecs.\ -\ -libjpeg-turbo implements both the traditional libjpeg API as well as the less powerful but more straightforward TurboJPEG API. libjpeg-turbo also features colorspace extensions that allow it to compress from/decompress to 32-bit and big-endian pixel buffers (RGBX, XBGR, etc.), as well as a full-featured Java interface.\ -\ -libjpeg-turbo was originally based on libjpeg/SIMD, an MMX-accelerated derivative of libjpeg v6b developed by Miyasaka Masaru. The TigerVNC and VirtualGL projects made numerous enhancements to the codec in 2009, and in early 2010, libjpeg-turbo spun off into an independent project, with the goal of making high-speed JPEG compression/decompression technology available to a broader range of users and developers.\ -} \ No newline at end of file diff --git a/release/ReadMe.txt b/release/ReadMe.txt new file mode 100644 index 00000000..b9f6ca57 --- /dev/null +++ b/release/ReadMe.txt @@ -0,0 +1,5 @@ +libjpeg-turbo is a JPEG image codec that uses SIMD instructions (MMX, SSE2, NEON) to accelerate baseline JPEG compression and decompression on x86, x86-64, and ARM systems. On such systems, libjpeg-turbo is generally 2-4x as fast as libjpeg, all else being equal. On other types of systems, libjpeg-turbo can still outperform libjpeg by a significant amount, by virtue of its highly-optimized Huffman coding routines. In many cases, the performance of libjpeg-turbo rivals that of proprietary high-speed JPEG codecs. + +libjpeg-turbo implements both the traditional libjpeg API as well as the less powerful but more straightforward TurboJPEG API. libjpeg-turbo also features colorspace extensions that allow it to compress from/decompress to 32-bit and big-endian pixel buffers (RGBX, XBGR, etc.), as well as a full-featured Java interface. + +libjpeg-turbo was originally based on libjpeg/SIMD, an MMX-accelerated derivative of libjpeg v6b developed by Miyasaka Masaru. The TigerVNC and VirtualGL projects made numerous enhancements to the codec in 2009, and in early 2010, libjpeg-turbo spun off into an independent project, with the goal of making high-speed JPEG compression/decompression technology available to a broader range of users and developers. diff --git a/release/makemacpkg.in b/release/makemacpkg.in index 65abdefe..16c18deb 100644 --- a/release/makemacpkg.in +++ b/release/makemacpkg.in @@ -11,7 +11,7 @@ TMPDIR= onexit() { if [ ! "$TMPDIR" = "" ]; then - sudo rm -rf $TMPDIR + rm -rf $TMPDIR fi } @@ -78,7 +78,6 @@ while [ $# -gt 0 ]; do esac shift done -PACKAGEMAKER=/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker if [ -f $PACKAGE_NAME-$VERSION.dmg ]; then rm -f $PACKAGE_NAME-$VERSION.dmg @@ -245,21 +244,20 @@ if [ "$PREFIX" = "/opt/libjpeg-turbo" -a "$LIBDIR" = "/opt/libjpeg-turbo/lib" ]; fi fi -chmod 1775 $PKGROOT/Library -chmod 775 $PKGROOT/Library/Documentation -mkdir -p $TMPDIR/pkg/Resources +mkdir -p $TMPDIR/pkg -cp pkgscripts/Description.plist $TMPDIR/pkg/ -cp pkgscripts/Info.plist $TMPDIR/pkg/ install -m 755 pkgscripts/uninstall $PKGROOT/$BINDIR/ -sudo chown -R root:admin $PKGROOT -cp $SRCDIR/release/License.rtf $SRCDIR/release/Welcome.rtf $SRCDIR/release/ReadMe.rtf $TMPDIR/pkg/Resources/ +find $PKGROOT -type f | while read file; do xattr -c $file; done + +cp $SRCDIR/release/License.rtf $SRCDIR/release/Welcome.rtf $SRCDIR/release/ReadMe.txt $TMPDIR/pkg/ mkdir $TMPDIR/dmg -$PACKAGEMAKER -build -v -p $TMPDIR/dmg/$PACKAGE_NAME.pkg \ - -f $PKGROOT -r $TMPDIR/pkg/Resources \ - -i $TMPDIR/pkg/Info.plist -d $TMPDIR/pkg/Description.plist +pkgbuild --root $PKGROOT --version $VERSION.$BUILD \ + --identifier com.libjpeg-turbo.libjpeg-turbo $TMPDIR/pkg/$PACKAGE_NAME.pkg +productbuild --distribution $SRCDIR/release/Distribution.xml \ + --package-path $TMPDIR/pkg/ --resources $TMPDIR/pkg/ \ + $TMPDIR/dmg/$PACKAGE_NAME.pkg hdiutil create -fs HFS+ -volname $PACKAGE_NAME-$VERSION \ -srcfolder "$TMPDIR/dmg" $TMPDIR/$PACKAGE_NAME-$VERSION.dmg cp $TMPDIR/$PACKAGE_NAME-$VERSION.dmg . From af1966457180ed0793d80f7022664bdeccb90ab1 Mon Sep 17 00:00:00 2001 From: DRC Date: Sun, 23 Mar 2014 18:06:11 +0000 Subject: [PATCH 62/65] Remove any claims of support for OS X 10.4 "Tiger" (the packaging system overhaul produces packages that require Leopard or later, and I haven't been able to test Tiger for years anyhow.) Update TurboJPEG shared library version. --- BUILDING.txt | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/BUILDING.txt b/BUILDING.txt index adf4eaab..d50ad428 100644 --- a/BUILDING.txt +++ b/BUILDING.txt @@ -50,12 +50,12 @@ Build Requirements is suggested that you install Apple GCC v4.2 through MacPorts. -- If building the TurboJPEG Java wrapper, JDK or OpenJDK 1.5 or later is - required. Some systems, such as OS X 10.4, Solaris 10 and later, and Red - Hat Enterprise Linux 5 and later, have this pre-installed. On OS X 10.5 and - later, it will be necessary to install the Java Developer Package, which can - be downloaded from http://developer.apple.com/downloads (Apple ID required.) - For systems that do not have a JDK installed, you can obtain the Oracle Java - Development Kit from http://www.java.com. + required. Some systems, such as Solaris 10 and later and Red Hat Enterprise + Linux 5 and later, have this pre-installed. On OS X 10.5 and later, it will + be necessary to install the Java Developer Package, which can be downloaded + from http://developer.apple.com/downloads (Apple ID required.) For systems + that do not have a JDK installed, you can obtain the Oracle Java Development + Kit from http://www.java.com. ================== @@ -113,8 +113,8 @@ This will generate the following files under .libs/ libturbojpeg.a Static link library for the TurboJPEG API - libturbojpeg.so.0.0.0 (Linux, Unix) - libturbojpeg.0.0.0.dylib (OS X) + libturbojpeg.so.0.1.0 (Linux, Unix) + libturbojpeg.0.1.0.dylib (OS X) cygturbojpeg-0.dll (Cygwin) Shared library for the TurboJPEG API @@ -243,12 +243,12 @@ to the configure command line. Add --host x86_64-apple-darwin NASM=/opt/local/bin/nasm \ - CFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk \ - -mmacosx-version-min=10.4 -O3' \ - LDFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk \ - -mmacosx-version-min=10.4' + CFLAGS='-isysroot /Developer/SDKs/MacOSX10.5.sdk \ + -mmacosx-version-min=10.5 -O3' \ + LDFLAGS='-isysroot /Developer/SDKs/MacOSX10.5.sdk \ + -mmacosx-version-min=10.5' -to the configure command line. The OS X 10.4 SDK, and NASM 2.07 or later from +to the configure command line. The OS X 10.5 SDK, and NASM 2.07 or later from MacPorts, must be installed. @@ -258,12 +258,12 @@ MacPorts, must be installed. Add --host i686-apple-darwin \ - CFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk \ - -mmacosx-version-min=10.4 -O3 -m32' \ - LDFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk \ - -mmacosx-version-min=10.4 -m32' + CFLAGS='-isysroot /Developer/SDKs/MacOSX10.5.sdk \ + -mmacosx-version-min=10.5 -O3 -m32' \ + LDFLAGS='-isysroot /Developer/SDKs/MacOSX10.5.sdk \ + -mmacosx-version-min=10.5 -m32' -to the configure command line. The OS X 10.4 SDK must be installed. +to the configure command line. The OS X 10.5 SDK must be installed. 64-bit Library Build on 64-bit Solaris From 86612bf441f58e25471fd62df9ebb14ab34d1754 Mon Sep 17 00:00:00 2001 From: DRC Date: Tue, 25 Mar 2014 05:27:16 +0000 Subject: [PATCH 63/65] Update build instructions to reflect the use of pkgbuild/productbuild --- BUILDING.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/BUILDING.txt b/BUILDING.txt index d50ad428..7f1ea7af 100644 --- a/BUILDING.txt +++ b/BUILDING.txt @@ -712,11 +712,11 @@ make deb make dmg - Create Macintosh package/disk image. This requires the PackageMaker - application, which must be installed in /Developer/Applications/Utilities. - Note that PackageMaker is not included in recent releases of Xcode, but it - can be obtained by downloading the "Auxiliary Tools for Xcode" package from - http://developer.apple.com/downloads. + Create Macintosh package/disk image. This requires pkgbuild and + productbuild, which are installed by default on OS X 10.7 and later and which + can be obtained by installing Xcode 3.2.6 (with the "Unix Development" + option) on OS X 10.6. Packages built in this manner can be installed on OS X + 10.5 and later, but they must be built on OS X 10.6 or later. make udmg [BUILDDIR32={32-bit build directory}] From 5610bb1fec0ae821c8e86cc364964bbb74f8d49c Mon Sep 17 00:00:00 2001 From: DRC Date: Thu, 27 Mar 2014 03:35:21 +0000 Subject: [PATCH 64/65] Make iOS build instructions more generic and applicable to all versions of Xcode; modify iOS build procedure for Xcode 5.0 and later to fix a build issue with Xcode 5.1. --- BUILDING.txt | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/BUILDING.txt b/BUILDING.txt index 7f1ea7af..df26b1a2 100644 --- a/BUILDING.txt +++ b/BUILDING.txt @@ -339,24 +339,16 @@ Additional build requirements: Set the following shell variables for simplicity: - Xcode 3.2.x / iOS 4.3 SDK: + Xcode 4.2 and earlier: IOS_PLATFORMDIR=/Developer/Platforms/iPhoneOS.platform - IOS_SYSROOT=$IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS4.3.sdk - IOS_GCC=$IOS_PLATFORMDIR/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2 - - Xcode 4.5.x / iOS 6.0 SDK: + Xcode 4.3 and later: IOS_PLATFORMDIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform - IOS_SYSROOT=$IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS6.0.sdk - IOS_GCC=$IOS_PLATFORMDIR/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2 - Xcode 4.6.x / iOS 6.1 SDK: - IOS_PLATFORMDIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform - IOS_SYSROOT=$IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS6.1.sdk - IOS_GCC=$IOS_PLATFORMDIR/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2 + IOS_SYSROOT=$IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk - Xcode 5.0.x / iOS 7.0 SDK: - IOS_PLATFORMDIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform - IOS_SYSROOT=$IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS7.0.sdk + Xcode 4.6.x and earlier: + IOS_GCC=$IOS_PLATFORMDIR/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2 + Xcode 5.0.x and later: IOS_GCC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang ARM v6 only (up to and including iPhone 3G): @@ -364,17 +356,17 @@ Set the following shell variables for simplicity: IOS_CFLAGS="-march=armv6 -mcpu=arm1176jzf-s -mfpu=vfp" ARM v7 only (iPhone 3GS-4S, iPad 1st-3rd Generation): - GCC: + Xcode 4.6.x and earlier: IOS_CFLAGS="-march=armv7 -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon" - Clang: - IOS_CFLAGS="-arch armv7 -no-integrated-as" + Xcode 5.0.x and later: + IOS_CFLAGS="-arch armv7" ARM v7s only (iPhone 5, iPad 4th Generation): [NOTE: Requires Xcode 4.5 or later] - GCC + Xcode 4.6.x and earlier: IOS_CFLAGS="-march=armv7s -mcpu=swift -mtune=swift -mfpu=neon" - Clang: - IOS_CFLAGS="-arch armv7s -no-integrated-as" + Xcode 5.0.x and later: + IOS_CFLAGS="-arch armv7s" Follow the procedure under "Building libjpeg-turbo" above, adding @@ -383,8 +375,16 @@ Follow the procedure under "Building libjpeg-turbo" above, adding CFLAGS="-mfloat-abi=softfp -isysroot $IOS_SYSROOT -O3 $IOS_CFLAGS" \ LDFLAGS="-mfloat-abi=softfp -isysroot $IOS_SYSROOT $IOS_CFLAGS" +to the configure command line. If using Xcode 5.0.x or later, also add + + CCASFLAGS="-no-integrated-as $IOS_CFLAGS" + to the configure command line. +NOTE: You can also add -miphoneos-version-min={version} to $IOS_CFLAGS above +in order to support older versions of iOS than the default version supported by +the SDK. + Once built, lipo can be used to combine the ARM v6, v7, and/or v7s variants into a universal library. From a60728cb34ec5ad186b3115d26576de90323afda Mon Sep 17 00:00:00 2001 From: DRC Date: Fri, 28 Mar 2014 18:33:25 +0000 Subject: [PATCH 65/65] Use clz/bsr instructions on ARM for bit counting rather than the lookup table (reduces memory footprint and can improve performance in some cases.) --- ChangeLog.txt | 9 +++++++++ jchuff.c | 34 ++++++++++++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 4b3db1ee..36e8a5b6 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -39,6 +39,15 @@ OS X 10.6 "Snow Leopard" or later must be used when packaging libjpeg-turbo, although the packages produced can be installed on OS X 10.5 "Leopard" or later. OS X 10.4 "Tiger" is no longer supported. +[5] The Huffman encoder now uses clz and bsr instructions for bit counting on +ARM platforms rather than a lookup table. This reduces the memory footprint +by 64k, which may be important for some mobile applications. Out of four +Android devices that were tested, two demonstrated a small loss (~3-4% on +average) with ARMv6 code and a small gain (also ~3-4%) with ARMv7 code when +enabling this new feature, but the other two devices demonstrated a +significant performance gain across the board (~10-20%.) Actual mileage may +vary. + 1.3.1 ===== diff --git a/jchuff.c b/jchuff.c index 29bf3892..68e4e0e0 100644 --- a/jchuff.c +++ b/jchuff.c @@ -22,8 +22,36 @@ #include "jchuff.h" /* Declarations shared with jcphuff.c */ #include +/* + * NOTE: If USE_CLZ_INTRINSIC is defined, then clz/bsr instructions will be + * used for bit counting rather than the lookup table. This will reduce the + * memory footprint by 64k, which is important for some mobile applications + * that create many isolated instances of libjpeg-turbo (web browsers, for + * instance.) This may improve performance on some mobile platforms as well. + * This feature is enabled by default only on ARM processors, because some x86 + * chips have a slow implementation of bsr, and the use of clz/bsr cannot be + * shown to have a significant performance impact even on the x86 chips that + * have a fast implementation of it. When building for ARMv6, you can + * explicitly disable the use of clz/bsr by adding -mthumb to the compiler + * flags (this defines __thumb__). + */ + +/* NOTE: Both GCC and Clang define __GNUC__ */ +#if defined __GNUC__ && defined __arm__ +#if !defined __thumb__ || defined __thumb2__ +#define USE_CLZ_INTRINSIC +#endif +#endif + +#ifdef USE_CLZ_INTRINSIC +#define JPEG_NBITS_NONZERO(x) (32 - __builtin_clz(x)) +#define JPEG_NBITS(x) (x ? JPEG_NBITS_NONZERO(x) : 0) +#else static unsigned char jpeg_nbits_table[65536]; static int jpeg_nbits_table_init = 0; +#define JPEG_NBITS(x) (jpeg_nbits_table[x]) +#define JPEG_NBITS_NONZERO(x) JPEG_NBITS(x) +#endif #ifndef min #define min(a,b) ((a)<(b)?(a):(b)) @@ -272,6 +300,7 @@ jpeg_make_c_derived_tbl (j_compress_ptr cinfo, boolean isDC, int tblno, dtbl->ehufsi[i] = huffsize[p]; } +#ifndef USE_CLZ_INTRINSIC if(!jpeg_nbits_table_init) { for(i = 0; i < 65536; i++) { int nbits = 0, temp = i; @@ -280,6 +309,7 @@ jpeg_make_c_derived_tbl (j_compress_ptr cinfo, boolean isDC, int tblno, } jpeg_nbits_table_init = 1; } +#endif } @@ -482,7 +512,7 @@ encode_one_block (working_state * state, JCOEFPTR block, int last_dc_val, temp2 += temp3; /* Find the number of bits needed for the magnitude of the coefficient */ - nbits = jpeg_nbits_table[temp]; + nbits = JPEG_NBITS(temp); /* Emit the Huffman-coded symbol for the number of bits */ code = dctbl->ehufco[nbits]; @@ -516,7 +546,7 @@ encode_one_block (working_state * state, JCOEFPTR block, int last_dc_val, temp ^= temp3; \ temp -= temp3; \ temp2 += temp3; \ - nbits = jpeg_nbits_table[temp]; \ + nbits = JPEG_NBITS_NONZERO(temp); \ /* if run length > 15, must emit special run-length-16 codes (0xF0) */ \ while (r > 15) { \ EMIT_BITS(code_0xf0, size_0xf0) \