d791e001d8f379cde351f4382d07a035e7ee9a34
[platform/upstream/libjpeg-turbo.git] / java / org / libjpegturbo / turbojpeg / TJ.java
1 /*
2  * Copyright (C)2011-2013, 2017-2018, 2020-2021 D. R. Commander.
3  *                                              All Rights Reserved.
4  * Copyright (C)2015 Viktor Szathmáry.  All Rights Reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * - Redistributions of source code must retain the above copyright notice,
10  *   this list of conditions and the following disclaimer.
11  * - Redistributions in binary form must reproduce the above copyright notice,
12  *   this list of conditions and the following disclaimer in the documentation
13  *   and/or other materials provided with the distribution.
14  * - Neither the name of the libjpeg-turbo Project nor the names of its
15  *   contributors may be used to endorse or promote products derived from this
16  *   software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS",
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
22  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28  * POSSIBILITY OF SUCH DAMAGE.
29  */
30
31 package org.libjpegturbo.turbojpeg;
32
33 /**
34  * TurboJPEG utility class (cannot be instantiated)
35  */
36 public final class TJ {
37
38   private TJ() {}
39
40   /**
41    * The number of chrominance subsampling options
42    */
43   public static final int NUMSAMP   = 6;
44   /**
45    * 4:4:4 chrominance subsampling (no chrominance subsampling).  The JPEG
46    * or YUV image will contain one chrominance component for every pixel in the
47    * source image.
48    */
49   public static final int SAMP_444  = 0;
50   /**
51    * 4:2:2 chrominance subsampling.  The JPEG or YUV image will contain one
52    * chrominance component for every 2x1 block of pixels in the source image.
53    */
54   public static final int SAMP_422  = 1;
55   /**
56    * 4:2:0 chrominance subsampling.  The JPEG or YUV image will contain one
57    * chrominance component for every 2x2 block of pixels in the source image.
58    */
59   public static final int SAMP_420  = 2;
60   /**
61    * Grayscale.  The JPEG or YUV image will contain no chrominance components.
62    */
63   public static final int SAMP_GRAY = 3;
64   /**
65    * 4:4:0 chrominance subsampling.  The JPEG or YUV image will contain one
66    * chrominance component for every 1x2 block of pixels in the source image.
67    * Note that 4:4:0 subsampling is not fully accelerated in libjpeg-turbo.
68    */
69   public static final int SAMP_440  = 4;
70   /**
71    * 4:1:1 chrominance subsampling.  The JPEG or YUV image will contain one
72    * chrominance component for every 4x1 block of pixels in the source image.
73    * JPEG images compressed with 4:1:1 subsampling will be almost exactly the
74    * same size as those compressed with 4:2:0 subsampling, and in the
75    * aggregate, both subsampling methods produce approximately the same
76    * perceptual quality.  However, 4:1:1 is better able to reproduce sharp
77    * horizontal features.  Note that 4:1:1 subsampling is not fully accelerated
78    * in libjpeg-turbo.
79    */
80   public static final int SAMP_411  = 5;
81
82
83   /**
84    * Returns the MCU block width for the given level of chrominance
85    * subsampling.
86    *
87    * @param subsamp the level of chrominance subsampling (one of
88    * <code>SAMP_*</code>)
89    *
90    * @return the MCU block width for the given level of chrominance
91    * subsampling.
92    */
93   public static int getMCUWidth(int subsamp) {
94     checkSubsampling(subsamp);
95     return MCU_WIDTH[subsamp];
96   }
97
98   private static final int[] MCU_WIDTH = {
99     8, 16, 16, 8, 8, 32
100   };
101
102
103   /**
104    * Returns the MCU block height for the given level of chrominance
105    * subsampling.
106    *
107    * @param subsamp the level of chrominance subsampling (one of
108    * <code>SAMP_*</code>)
109    *
110    * @return the MCU block height for the given level of chrominance
111    * subsampling.
112    */
113   public static int getMCUHeight(int subsamp) {
114     checkSubsampling(subsamp);
115     return MCU_HEIGHT[subsamp];
116   }
117
118   private static final int[] MCU_HEIGHT = {
119     8, 8, 16, 8, 16, 8
120   };
121
122
123   /**
124    * The number of pixel formats
125    */
126   public static final int NUMPF   = 12;
127   /**
128    * RGB pixel format.  The red, green, and blue components in the image are
129    * stored in 3-byte pixels in the order R, G, B from lowest to highest byte
130    * address within each pixel.
131    */
132   public static final int PF_RGB  = 0;
133   /**
134    * BGR pixel format.  The red, green, and blue components in the image are
135    * stored in 3-byte pixels in the order B, G, R from lowest to highest byte
136    * address within each pixel.
137    */
138   public static final int PF_BGR  = 1;
139   /**
140    * RGBX pixel format.  The red, green, and blue components in the image are
141    * stored in 4-byte pixels in the order R, G, B from lowest to highest byte
142    * address within each pixel.  The X component is ignored when compressing
143    * and undefined when decompressing.
144    */
145   public static final int PF_RGBX = 2;
146   /**
147    * BGRX pixel format.  The red, green, and blue components in the image are
148    * stored in 4-byte pixels in the order B, G, R from lowest to highest byte
149    * address within each pixel.  The X component is ignored when compressing
150    * and undefined when decompressing.
151    */
152   public static final int PF_BGRX = 3;
153   /**
154    * XBGR pixel format.  The red, green, and blue components in the image are
155    * stored in 4-byte pixels in the order R, G, B from highest to lowest byte
156    * address within each pixel.  The X component is ignored when compressing
157    * and undefined when decompressing.
158    */
159   public static final int PF_XBGR = 4;
160   /**
161    * XRGB pixel format.  The red, green, and blue components in the image are
162    * stored in 4-byte pixels in the order B, G, R from highest to lowest byte
163    * address within each pixel.  The X component is ignored when compressing
164    * and undefined when decompressing.
165    */
166   public static final int PF_XRGB = 5;
167   /**
168    * Grayscale pixel format.  Each 1-byte pixel represents a luminance
169    * (brightness) level from 0 to 255.
170    */
171   public static final int PF_GRAY = 6;
172   /**
173    * RGBA pixel format.  This is the same as {@link #PF_RGBX}, except that when
174    * decompressing, the X byte is guaranteed to be 0xFF, which can be
175    * interpreted as an opaque alpha channel.
176    */
177   public static final int PF_RGBA = 7;
178   /**
179    * BGRA pixel format.  This is the same as {@link #PF_BGRX}, except that when
180    * decompressing, the X byte is guaranteed to be 0xFF, which can be
181    * interpreted as an opaque alpha channel.
182    */
183   public static final int PF_BGRA = 8;
184   /**
185    * ABGR pixel format.  This is the same as {@link #PF_XBGR}, except that when
186    * decompressing, the X byte is guaranteed to be 0xFF, which can be
187    * interpreted as an opaque alpha channel.
188    */
189   public static final int PF_ABGR = 9;
190   /**
191    * ARGB pixel format.  This is the same as {@link #PF_XRGB}, except that when
192    * decompressing, the X byte is guaranteed to be 0xFF, which can be
193    * interpreted as an opaque alpha channel.
194    */
195   public static final int PF_ARGB = 10;
196   /**
197    * CMYK pixel format.  Unlike RGB, which is an additive color model used
198    * primarily for display, CMYK (Cyan/Magenta/Yellow/Key) is a subtractive
199    * color model used primarily for printing.  In the CMYK color model, the
200    * value of each color component typically corresponds to an amount of cyan,
201    * magenta, yellow, or black ink that is applied to a white background.  In
202    * order to convert between CMYK and RGB, it is necessary to use a color
203    * management system (CMS.)  A CMS will attempt to map colors within the
204    * printer's gamut to perceptually similar colors in the display's gamut and
205    * vice versa, but the mapping is typically not 1:1 or reversible, nor can it
206    * be defined with a simple formula.  Thus, such a conversion is out of scope
207    * for a codec library.  However, the TurboJPEG API allows for compressing
208    * CMYK pixels into a YCCK JPEG image (see {@link #CS_YCCK}) and
209    * decompressing YCCK JPEG images into CMYK pixels.
210    */
211   public static final int PF_CMYK = 11;
212
213
214   /**
215    * Returns the pixel size (in bytes) for the given pixel format.
216    *
217    * @param pixelFormat the pixel format (one of <code>PF_*</code>)
218    *
219    * @return the pixel size (in bytes) for the given pixel format.
220    */
221   public static int getPixelSize(int pixelFormat) {
222     checkPixelFormat(pixelFormat);
223     return PIXEL_SIZE[pixelFormat];
224   }
225
226   private static final int[] PIXEL_SIZE = {
227     3, 3, 4, 4, 4, 4, 1, 4, 4, 4, 4, 4
228   };
229
230
231   /**
232    * For the given pixel format, returns the number of bytes that the red
233    * component is offset from the start of the pixel.  For instance, if a pixel
234    * of format <code>TJ.PF_BGRX</code> is stored in <code>char pixel[]</code>,
235    * then the red component will be
236    * <code>pixel[TJ.getRedOffset(TJ.PF_BGRX)]</code>.
237    *
238    * @param pixelFormat the pixel format (one of <code>PF_*</code>)
239    *
240    * @return the red offset for the given pixel format, or -1 if the pixel
241    * format does not have a red component.
242    */
243   public static int getRedOffset(int pixelFormat) {
244     checkPixelFormat(pixelFormat);
245     return RED_OFFSET[pixelFormat];
246   }
247
248   private static final int[] RED_OFFSET = {
249     0, 2, 0, 2, 3, 1, -1, 0, 2, 3, 1, -1
250   };
251
252
253   /**
254    * For the given pixel format, returns the number of bytes that the green
255    * component is offset from the start of the pixel.  For instance, if a pixel
256    * of format <code>TJ.PF_BGRX</code> is stored in <code>char pixel[]</code>,
257    * then the green component will be
258    * <code>pixel[TJ.getGreenOffset(TJ.PF_BGRX)]</code>.
259    *
260    * @param pixelFormat the pixel format (one of <code>PF_*</code>)
261    *
262    * @return the green offset for the given pixel format, or -1 if the pixel
263    * format does not have a green component.
264    */
265   public static int getGreenOffset(int pixelFormat) {
266     checkPixelFormat(pixelFormat);
267     return GREEN_OFFSET[pixelFormat];
268   }
269
270   private static final int[] GREEN_OFFSET = {
271     1, 1, 1, 1, 2, 2, -1, 1, 1, 2, 2, -1
272   };
273
274
275   /**
276    * For the given pixel format, returns the number of bytes that the blue
277    * component is offset from the start of the pixel.  For instance, if a pixel
278    * of format <code>TJ.PF_BGRX</code> is stored in <code>char pixel[]</code>,
279    * then the blue component will be
280    * <code>pixel[TJ.getBlueOffset(TJ.PF_BGRX)]</code>.
281    *
282    * @param pixelFormat the pixel format (one of <code>PF_*</code>)
283    *
284    * @return the blue offset for the given pixel format, or -1 if the pixel
285    * format does not have a blue component.
286    */
287   public static int getBlueOffset(int pixelFormat) {
288     checkPixelFormat(pixelFormat);
289     return BLUE_OFFSET[pixelFormat];
290   }
291
292   private static final int[] BLUE_OFFSET = {
293     2, 0, 2, 0, 1, 3, -1, 2, 0, 1, 3, -1
294   };
295
296
297   /**
298    * For the given pixel format, returns the number of bytes that the alpha
299    * component is offset from the start of the pixel.  For instance, if a pixel
300    * of format <code>TJ.PF_BGRA</code> is stored in <code>char pixel[]</code>,
301    * then the alpha component will be
302    * <code>pixel[TJ.getAlphaOffset(TJ.PF_BGRA)]</code>.
303    *
304    * @param pixelFormat the pixel format (one of <code>PF_*</code>)
305    *
306    * @return the alpha offset for the given pixel format, or -1 if the pixel
307    * format does not have a alpha component.
308    */
309   public static int getAlphaOffset(int pixelFormat) {
310     checkPixelFormat(pixelFormat);
311     return ALPHA_OFFSET[pixelFormat];
312   }
313
314   private static final int[] ALPHA_OFFSET = {
315     -1, -1, -1, -1, -1, -1, -1, 3, 3, 0, 0, -1
316   };
317
318
319   /**
320    * The number of JPEG colorspaces
321    */
322   public static final int NUMCS = 5;
323   /**
324    * RGB colorspace.  When compressing the JPEG image, the R, G, and B
325    * components in the source image are reordered into image planes, but no
326    * colorspace conversion or subsampling is performed.  RGB JPEG images can be
327    * decompressed to any of the extended RGB pixel formats or grayscale, but
328    * they cannot be decompressed to YUV images.
329    */
330   public static final int CS_RGB = 0;
331   /**
332    * YCbCr colorspace.  YCbCr is not an absolute colorspace but rather a
333    * mathematical transformation of RGB designed solely for storage and
334    * transmission.  YCbCr images must be converted to RGB before they can
335    * actually be displayed.  In the YCbCr colorspace, the Y (luminance)
336    * component represents the black &amp; white portion of the original image,
337    * and the Cb and Cr (chrominance) components represent the color portion of
338    * the original image.  Originally, the analog equivalent of this
339    * transformation allowed the same signal to drive both black &amp; white and
340    * color televisions, but JPEG images use YCbCr primarily because it allows
341    * the color data to be optionally subsampled for the purposes of reducing
342    * bandwidth or disk space.  YCbCr is the most common JPEG colorspace, and
343    * YCbCr JPEG images can be compressed from and decompressed to any of the
344    * extended RGB pixel formats or grayscale, or they can be decompressed to
345    * YUV planar images.
346    */
347   @SuppressWarnings("checkstyle:ConstantName")
348   public static final int CS_YCbCr = 1;
349   /**
350    * Grayscale colorspace.  The JPEG image retains only the luminance data (Y
351    * component), and any color data from the source image is discarded.
352    * Grayscale JPEG images can be compressed from and decompressed to any of
353    * the extended RGB pixel formats or grayscale, or they can be decompressed
354    * to YUV planar images.
355    */
356   public static final int CS_GRAY = 2;
357   /**
358    * CMYK colorspace.  When compressing the JPEG image, the C, M, Y, and K
359    * components in the source image are reordered into image planes, but no
360    * colorspace conversion or subsampling is performed.  CMYK JPEG images can
361    * only be decompressed to CMYK pixels.
362    */
363   public static final int CS_CMYK = 3;
364   /**
365    * YCCK colorspace.  YCCK (AKA "YCbCrK") is not an absolute colorspace but
366    * rather a mathematical transformation of CMYK designed solely for storage
367    * and transmission.  It is to CMYK as YCbCr is to RGB.  CMYK pixels can be
368    * reversibly transformed into YCCK, and as with YCbCr, the chrominance
369    * components in the YCCK pixels can be subsampled without incurring major
370    * perceptual loss.  YCCK JPEG images can only be compressed from and
371    * decompressed to CMYK pixels.
372    */
373   public static final int CS_YCCK = 4;
374
375
376   /**
377    * The uncompressed source/destination image is stored in bottom-up (Windows,
378    * OpenGL) order, not top-down (X11) order.
379    */
380   public static final int FLAG_BOTTOMUP      = 2;
381
382   @SuppressWarnings("checkstyle:JavadocVariable")
383   @Deprecated
384   public static final int FLAG_FORCEMMX      = 8;
385   @SuppressWarnings("checkstyle:JavadocVariable")
386   @Deprecated
387   public static final int FLAG_FORCESSE      = 16;
388   @SuppressWarnings("checkstyle:JavadocVariable")
389   @Deprecated
390   public static final int FLAG_FORCESSE2     = 32;
391   @SuppressWarnings("checkstyle:JavadocVariable")
392   @Deprecated
393   public static final int FLAG_FORCESSE3     = 128;
394
395   /**
396    * When decompressing an image that was compressed using chrominance
397    * subsampling, use the fastest chrominance upsampling algorithm available in
398    * the underlying codec.  The default is to use smooth upsampling, which
399    * creates a smooth transition between neighboring chrominance components in
400    * order to reduce upsampling artifacts in the decompressed image.
401    */
402   public static final int FLAG_FASTUPSAMPLE  = 256;
403   /**
404    * Use the fastest DCT/IDCT algorithm available in the underlying codec.  The
405    * default if this flag is not specified is implementation-specific.  For
406    * example, the implementation of TurboJPEG for libjpeg[-turbo] uses the fast
407    * algorithm by default when compressing, because this has been shown to have
408    * only a very slight effect on accuracy, but it uses the accurate algorithm
409    * when decompressing, because this has been shown to have a larger effect.
410    */
411   public static final int FLAG_FASTDCT       = 2048;
412   /**
413    * Use the most accurate DCT/IDCT algorithm available in the underlying
414    * codec.  The default if this flag is not specified is
415    * implementation-specific.  For example, the implementation of TurboJPEG for
416    * libjpeg[-turbo] uses the fast algorithm by default when compressing,
417    * because this has been shown to have only a very slight effect on accuracy,
418    * but it uses the accurate algorithm when decompressing, because this has
419    * been shown to have a larger effect.
420    */
421   public static final int FLAG_ACCURATEDCT   = 4096;
422   /**
423    * Immediately discontinue the current compression/decompression/transform
424    * operation if the underlying codec throws a warning (non-fatal error).  The
425    * default behavior is to allow the operation to complete unless a fatal
426    * error is encountered.
427    * <p>
428    * NOTE: due to the design of the TurboJPEG Java API, only certain methods
429    * (specifically, {@link TJDecompressor TJDecompressor.decompress*()} methods
430    * with a void return type) will complete and leave the output image in a
431    * fully recoverable state after a non-fatal error occurs.
432    */
433   public static final int FLAG_STOPONWARNING = 8192;
434   /**
435    * Use progressive entropy coding in JPEG images generated by compression and
436    * transform operations.  Progressive entropy coding will generally improve
437    * compression relative to baseline entropy coding (the default), but it will
438    * reduce compression and decompression performance considerably.
439    */
440   public static final int FLAG_PROGRESSIVE   = 16384;
441   /**
442    * Limit the number of progressive JPEG scans that the decompression and
443    * transform operations will process.  If a progressive JPEG image contains
444    * an unreasonably large number of scans, then this flag will cause the
445    * decompression and transform operations to throw an error.  The primary
446    * purpose of this is to allow security-critical applications to guard
447    * against an exploit of the progressive JPEG format described in
448    * <a href="https://libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf" target="_blank">this report</a>.
449    */
450   public static final int FLAG_LIMITSCANS    = 32768;
451
452
453   /**
454    * The number of error codes
455    */
456   public static final int NUMERR = 2;
457   /**
458    * The error was non-fatal and recoverable, but the image may still be
459    * corrupt.
460    * <p>
461    * NOTE: due to the design of the TurboJPEG Java API, only certain methods
462    * (specifically, {@link TJDecompressor TJDecompressor.decompress*()} methods
463    * with a void return type) will complete and leave the output image in a
464    * fully recoverable state after a non-fatal error occurs.
465    */
466   public static final int ERR_WARNING = 0;
467   /**
468    * The error was fatal and non-recoverable.
469    */
470   public static final int ERR_FATAL = 1;
471
472
473   /**
474    * Returns the maximum size of the buffer (in bytes) required to hold a JPEG
475    * image with the given width, height, and level of chrominance subsampling.
476    *
477    * @param width the width (in pixels) of the JPEG image
478    *
479    * @param height the height (in pixels) of the JPEG image
480    *
481    * @param jpegSubsamp the level of chrominance subsampling to be used when
482    * generating the JPEG image (one of {@link TJ TJ.SAMP_*})
483    *
484    * @return the maximum size of the buffer (in bytes) required to hold a JPEG
485    * image with the given width, height, and level of chrominance subsampling.
486    */
487   public static native int bufSize(int width, int height, int jpegSubsamp);
488
489   /**
490    * Returns the size of the buffer (in bytes) required to hold a YUV planar
491    * image with the given width, height, and level of chrominance subsampling.
492    *
493    * @param width the width (in pixels) of the YUV image
494    *
495    * @param pad the width of each line in each plane of the image is padded to
496    * the nearest multiple of this number of bytes (must be a power of 2.)
497    *
498    * @param height the height (in pixels) of the YUV image
499    *
500    * @param subsamp the level of chrominance subsampling used in the YUV
501    * image (one of {@link TJ TJ.SAMP_*})
502    *
503    * @return the size of the buffer (in bytes) required to hold a YUV planar
504    * image with the given width, height, and level of chrominance subsampling.
505    */
506   public static native int bufSizeYUV(int width, int pad, int height,
507                                       int subsamp);
508
509   /**
510    * @deprecated Use {@link #bufSizeYUV(int, int, int, int)} instead.
511    */
512   @SuppressWarnings("checkstyle:JavadocMethod")
513   @Deprecated
514   public static native int bufSizeYUV(int width, int height, int subsamp);
515
516   /**
517    * Returns the size of the buffer (in bytes) required to hold a YUV image
518    * plane with the given parameters.
519    *
520    * @param componentID ID number of the image plane (0 = Y, 1 = U/Cb,
521    * 2 = V/Cr)
522    *
523    * @param width width (in pixels) of the YUV image.  NOTE: this is the width
524    * of the whole image, not the plane width.
525    *
526    * @param stride bytes per line in the image plane.
527    *
528    * @param height height (in pixels) of the YUV image.  NOTE: this is the
529    * height of the whole image, not the plane height.
530    *
531    * @param subsamp the level of chrominance subsampling used in the YUV
532    * image (one of {@link TJ TJ.SAMP_*})
533    *
534    * @return the size of the buffer (in bytes) required to hold a YUV planar
535    * image with the given parameters.
536    */
537   public static native int planeSizeYUV(int componentID, int width, int stride,
538                                         int height, int subsamp);
539
540   /**
541    * Returns the plane width of a YUV image plane with the given parameters.
542    * Refer to {@link YUVImage YUVImage} for a description of plane width.
543    *
544    * @param componentID ID number of the image plane (0 = Y, 1 = U/Cb,
545    * 2 = V/Cr)
546    *
547    * @param width width (in pixels) of the YUV image
548    *
549    * @param subsamp the level of chrominance subsampling used in the YUV image
550    * (one of {@link TJ TJ.SAMP_*})
551    *
552    * @return the plane width of a YUV image plane with the given parameters.
553    */
554   public static native int planeWidth(int componentID, int width, int subsamp);
555
556   /**
557    * Returns the plane height of a YUV image plane with the given parameters.
558    * Refer to {@link YUVImage YUVImage} for a description of plane height.
559    *
560    * @param componentID ID number of the image plane (0 = Y, 1 = U/Cb,
561    * 2 = V/Cr)
562    *
563    * @param height height (in pixels) of the YUV image
564    *
565    * @param subsamp the level of chrominance subsampling used in the YUV image
566    * (one of {@link TJ TJ.SAMP_*})
567    *
568    * @return the plane height of a YUV image plane with the given parameters.
569    */
570   public static native int planeHeight(int componentID, int height,
571                                        int subsamp);
572
573   /**
574    * Returns a list of fractional scaling factors that the JPEG decompressor in
575    * this implementation of TurboJPEG supports.
576    *
577    * @return a list of fractional scaling factors that the JPEG decompressor in
578    * this implementation of TurboJPEG supports.
579    */
580   public static native TJScalingFactor[] getScalingFactors();
581
582   static {
583     TJLoader.load();
584   }
585
586   private static void checkPixelFormat(int pixelFormat) {
587     if (pixelFormat < 0 || pixelFormat >= NUMPF)
588       throw new IllegalArgumentException("Invalid pixel format");
589   }
590
591   private static void checkSubsampling(int subsamp) {
592     if (subsamp < 0 || subsamp >= NUMSAMP)
593       throw new IllegalArgumentException("Invalid subsampling type");
594   }
595
596 }