266 Commits

Author SHA1 Message Date
DRC
d7932a2709 TJ doc: Density params require YCbCr or grayscale
Since libjpeg-turbo does not support Exif, the only way it can embed
density information in a JPEG image is by using the JFIF marker, which
is only written if the JPEG colorspace is YCbCr or grayscale.
(Referring to the conversation under #793, we may need to further
restrict that to 8-bit-per-sample JPEG images, because the JFIF spec
requires 8-bit data precision.)
2024-10-30 12:21:50 -04:00
DRC
1b1356a565 TJComp: Explicitly specify data precision
This is just a code readability thing.  The logic effectively caused the
data precision to default to 8 if -precision was not specified, but that
was not obvious.

This commit also modifies tjcomptest so that it tests TJComp with no
-precision argument, to ensure that the data precision defaults to 8.
2024-09-23 15:24:48 -04:00
DRC
0d58f09997 TJTran: ICC profiles are now supported 2024-09-14 13:23:36 -04:00
DRC
6d02718d9a JNI: Guard against int. overflow w/ ICC profiles 2024-09-14 13:23:36 -04:00
DRC
9b01f5a057 TJ: Add func/method for computing xformed buf size 2024-09-14 13:23:32 -04:00
DRC
6f1fe2d113 turbojpeg-jni.c: Fix int. conv. warnings w/ VC++ 2024-09-09 10:54:16 -04:00
DRC
a272858212 TurboJPEG: ICC profile support 2024-09-06 19:55:41 -04:00
DRC
c519d7b679 Don't ignore JPEG buf size with TJPARAM_NOREALLOC
Since the introduction of TJFLAG_NOREALLOC in libjpeg-turbo 1.2.x, the
TurboJPEG C API documentation has (confusingly) stated that:

- if the JPEG buffer pointer points to a pre-allocated buffer, then the
JPEG buffer size must be specified, and

- the JPEG buffer size should be specified if the JPEG buffer is
pre-allocated to an arbitrary size.

The documentation never explicitly stated that the JPEG buffer size
should be specified if the JPEG buffer is pre-allocated to a worst-case
size, but since focus does not imply exclusion, it also never explicitly
stated the reverse.  Furthermore, the documentation never stated that
this was contingent upon TJPARAM_NOREALLOC/TJFLAG_NOREALLOC.  However,
effectively the compression and lossless transformation functions
ignored the JPEG buffer size(s) passed to them, and assumed that the
JPEG buffer(s) had been allocated to a worst-case size, if
TJPARAM_NOREALLOC/TJFLAG_NOREALLOC was set.  This behavior was an
accidental and undocumented throwback to libjpeg-turbo 1.1.x, in which
the tjCompress() function provided no way to specify the JPEG buffer
size.  It was always a bad idea for applications to rely upon that
behavior (although our own TJBench application unfortunately did.)
However, if such applications exist in the wild, the new behavior would
constitute a breaking change, so it has been introduced only into
libjpeg-turbo 3.1.x and only into TurboJPEG 3 API functions.  The
previous behavior has been retained when calling functions from the
TurboJPEG 2.1.x API and prior versions.

Did I mention that APIs are hard?
2024-09-06 19:55:27 -04:00
DRC
5f05c75ac1 Merge branch 'main' into dev 2024-09-06 19:55:20 -04:00
DRC
b3f0abe377 TJ: Calc. xformed buf sizes based on dst. subsamp
With respect to tj3Transform(), this addresses an oversight from
bb1d540a807783a3db8b85bab2993d70b1330287.

Note to self: A convenience function/method for computing the worst-case
transformed JPEG size for a particular transform would be nice.
2024-09-06 19:04:28 -04:00
DRC
6d9591703f Minor TurboJPEG doc tweaks
- When transforming, the worst-case JPEG buffer size depends on the
  subsampling level used in the destination image, since a grayscale
  transform might have been applied.

- Parentheses Police
2024-09-05 22:31:40 -04:00
DRC
8db41dad22 Merge branch 'main' into dev 2024-09-05 15:15:08 -04:00
DRC
758e8a8e9f Java: Use Java-style method nomenclature
:: is a C++ thing.
2024-09-05 14:57:15 -04:00
DRC
e4c67aff50 TJBench: More argument consistification
-copynone --> -copy none

Add '-copy all', even though it's the default.

-rgb, -bgr, -rgbx, -bgrx, -xbgr, -xrgb, -gray, -cmyk -->
-pixelformat {rgb|bgr|rgbx|bgrx|xbgr|xrgb|gray|cmyk}
(This is mainly so -gray won't interfere with -grayscale.)

Fix an ArrayIndexOutOfBoundsException that occurred when passing -dct
to the Java version without specifying the DCT algorithm (oversight from
24fbf64d31a0758c63bcc27cf5d92fc5611717d0.)
2024-09-04 12:41:15 -04:00
DRC
d43ed7a1ff Merge branch 'main' into dev 2024-09-04 08:38:13 -04:00
DRC
5550c80fdc Doc: "compress operation"="compression operation"
(consistification)
2024-09-03 17:20:10 -04:00
DRC
37851a32c0 TurboJPEG: Add restart markers when transforming 2024-09-03 09:26:33 -04:00
DRC
debf57bc1d TJBench: Improve usage screen readability 2024-09-01 14:05:37 -04:00
DRC
fad6100704 Replace TJExample with IJG workalike programs 2024-09-01 14:05:15 -04:00
DRC
6d9f1f816c Merge branch 'main' into dev 2024-09-01 14:04:20 -04:00
DRC
797c6ccd98 Doc: Further clarify MCU definition 2024-09-01 11:25:29 -04:00
DRC
3e303e7235 TJBench: Allow British spellings in arguments 2024-08-31 18:42:19 -04:00
DRC
645673810f Merge branch 'main' into dev 2024-08-31 17:41:03 -04:00
DRC
8d76e4e550 Doc: "EXIF" = "Exif" 2024-08-31 15:33:55 -04:00
DRC
9983840eb6 TJ/xform: Check crop region against dest. image
Lossless cropping is performed after other lossless transform
operations, so the cropping region must be specified relative to the
destination image dimensions and level of chrominance subsampling, not
the source image dimensions and level of chrominance subsampling.

More specifically, if the lossless transform operation swaps the X and Y
axes, or if the image is converted to grayscale, then that changes the
cropping region requirements.
2024-08-31 15:04:30 -04:00
DRC
8456d2b98c Doc: "MCU block" = "iMCU" or "MCU"
The JPEG-1 spec never uses the term "MCU block".  That term is rarely
used in other literature to describe the equivalent of an MCU in an
interleaved JPEG image, but the libjpeg documentation uses "iMCU" to
describe the same thing.  "iMCU" is a better term, since the equivalent
of an interleaved MCU can contain multiple DCT blocks (or samples in
lossless mode) that are only grouped together if the image is
interleaved.

In the case of restart markers, "MCU block" was used in the libjpeg
documentation instead of "MCU", but "MCU" is more accurate and less
confusing.  (The restart interval is literally in MCUs, where one MCU
is one data unit in a non-interleaved JPEG image and multiple data units
in a multi-component interleaved JPEG image.)

In the case of 9b704f96b2dccc54363ad7a2fe8e378fc1a2893b, the issue was
actually with progressive JPEG images exactly two DCT blocks wide, not
two MCU blocks wide.

This commit also defines "MCU" and "MCU row" in the description of the
various restart marker options/parameters.  Although an MCU row is
technically always a row of samples in lossless mode, "sample row" was
confusing, since it is used in other places to describe a row of samples
for a single component (whereas an MCU row in a typical lossless JPEG
image consists of a row of interleaved samples for all components.)
2024-08-30 14:16:09 -04:00
DRC
2858783db5 JNI: Set srcX, srcY = 0 in loadSourceImage()
(oversight from 79b8d65f0f86af77afc5979ecc104b1fbc97c82d)
2024-08-28 18:58:27 -04:00
DRC
4ceaf8b700 TJBench: Allow 'X' in crop spec
(for consistency with djpeg and jpegtran)
2024-08-28 18:58:27 -04:00
DRC
fd9b21b69b Merge branch 'main' into dev 2024-08-28 18:58:21 -04:00
DRC
5cf7960678 Undocument TJ*PARAM_RESTARTBLOCKS for lossless
TJ*PARAM_RESTARTBLOCKS technically works with lossless compression, but
it is not useful, since the value must be equal to the number of samples
in a row.  (In other words, it is no different than
TJ*PARAM_RESTARTINROWS, except that it requires the user to do more
math.)
2024-08-28 18:36:37 -04:00
DRC
d62079717c TJBench: Don't override subsamp until args parsed
Otherwise, passing -subsamp after -lossless might cause the worst-case
JPEG buffer size to be too small.
2024-08-28 18:21:55 -04:00
DRC
6a9565ce6e Merge branch 'main' into dev 2024-08-26 16:45:41 -04:00
DRC
548f732432 TJBench: Usage screen tweak
Indicate that -maxmemory and -maxpixels take an integer argument.
2024-08-26 10:14:11 -04:00
DRC
de4bbac55e TJCompressor.compress(): Fix lossls buf size calc 2024-08-23 12:48:34 -04:00
DRC
acbb493759 JNI: Fix Windows CI build failure
(introduced by previous commit)

jint and int are technically the same thing, but certain compilers are a
bit pedantic.
2024-08-22 18:32:30 -04:00
DRC
79b8d65f0f Java: Add official packed-pixel image I/O methods 2024-08-22 18:19:09 -04:00
DRC
8088dfc08c TJUnitTest.java: Use boolean ret vals for check*() 2024-08-22 18:16:15 -04:00
DRC
b577504f1d JNI: Remove deprecated constants
(oversight from 07378442355e72a642e674d4fd901f64cc8291bf)
2024-08-22 17:14:45 -04:00
DRC
a98bc9a54f Merge branch 'main' into dev 2024-08-22 17:14:37 -04:00
DRC
d44fc54f94 Java: Unset srcBuf12/16 with BufferedImage/YUV src
Due to an oversight in the multi-precision feature,
TJCompressor.srcBuf12 and TJCompressor.srcBuf16 were not set to null
in TJCompressor.setSourceImage(YUVImage) or
TJCompressor.setSourceImage(BufferedImage, ...).  Thus, if an
application set a 12-bit or 16-bit packed-pixel buffer as the source
image then set a BufferedImage with integer pixels as the source image,
TJCompress.compress() would compress from the 12-bit or 16-bit
packed-pixel buffer instead of the BufferedImage.  The odds of an
application actually doing that are very slim, however.
2024-08-21 16:44:46 -04:00
DRC
ecf7c8b168 Merge branch 'main' into dev 2024-08-21 13:09:53 -04:00
DRC
24fbf64d31 TJBench: Consistify args with djpeg
-fastdct --> -dct fast
-fastupsample --> -nosmooth
2024-08-21 13:07:46 -04:00
DRC
d6ce7df352 TJBench: Consistify args with cjpeg/djpeg/jpegtran
-hflip --> -flip horizontal
-limitscans --> -maxscans N
-rot90 --> -rotate 90
-rot180 --> -rotate 180
-rot270 --> -rotate 270
-stoponwarning --> -strict
-vflip --> -flip vertical
2024-08-21 13:07:46 -04:00
DRC
ab203704dd TJBench: Allow abbreviated command-line options
... using the same matching algorithm as cjpeg/djpeg/jpegtran and, where
possible, the same abbreviations:

-a for -arithmetic
-b for -bmp
-cr for -crop
-g for -grayscale
-l for -lossless
-max for -maxmemory
-o for -optimize
-pre for -precision
-p for -progressive
-r for -restart
-s for -scale
-t for -transpose
-transv for -transverse
2024-08-21 13:07:46 -04:00
DRC
0737844235 Java: Remove deprecated constants and methods 2024-08-21 13:07:42 -04:00
DRC
8c2e7306cf Java doc: Minor formatting tweak 2024-08-21 13:03:41 -04:00
DRC
d55a051e20 Merge branch 'main' into dev 2024-08-20 15:11:34 -04:00
DRC
49f1b5807d TJBench.java: Explicitly set restartIntervalBlocks
This is just a readability thing.  Java initializes integer fields to 0
by default.
2024-08-20 15:11:20 -04:00
DRC
26d978b661 Merge branch 'main' into dev 2024-08-16 11:58:02 -04:00
DRC
0c23b0ad60 Various doc tweaks
- "Optimized baseline entropy coding" = "Huffman table optimization"

  "Optimized baseline entropy coding" was meant to emphasize that the
  feature is only useful when generating baseline (single-scan lossy
  8-bit-per-sample Huffman-coded) JPEG images, because it is
  automatically enabled when generating Huffman-coded progressive
  (multi-scan), 12-bit-per-sample, and lossless JPEG images.  However,
  Huffman table optimization isn't actually an integral part of those
  non-baseline modes.  You can forego Huffman table optimization with
  12-bit data precision if you supply your own Huffman tables.  The spec
  doesn't require it with progressive or lossless mode, either, although
  our implementation does.  Furthermore, "baseline" describes more than
  just the type of entropy coding used.  It was incorrect to say that
  optimized "baseline" entropy coding is automatically enabled for
  Huffman-coded progressive, 12-bit-per-sample, and lossless JPEG
  images, since those are clearly not baseline images.

- "Progressive entropy coding" = "Progressive JPEG"

  "Progressive" describes more than just the type of entropy coding
  used.  (In fact, both Huffman-coded and arithmetic-coded images can be
  progressive.)

- Mention that TJPARAM_OPTIMIZE/TJ.PARAM_OPTIMIZE can be used with
  lossless transformation as well.

- General wordsmithing

- Formatting tweaks
2024-08-16 11:49:00 -04:00