OLD | NEW |
1 /* Copyright (C)2004 Landmark Graphics Corporation | 1 /* |
2 * Copyright (C)2005, 2006 Sun Microsystems, Inc. | 2 * Copyright (C)2009-2011 D. R. Commander. All Rights Reserved. |
3 * Copyright (C)2009 D. R. Commander | 3 * |
4 * | 4 * Redistribution and use in source and binary forms, with or without |
5 * This library is free software and may be redistributed and/or modified under | 5 * modification, are permitted provided that the following conditions are met: |
6 * the terms of the wxWindows Library License, Version 3.1 or (at your option) | 6 * |
7 * any later version. The full license is in the LICENSE.txt file included | 7 * - Redistributions of source code must retain the above copyright notice, |
8 * with this distribution. | 8 * this list of conditions and the following disclaimer. |
9 * | 9 * - Redistributions in binary form must reproduce the above copyright notice, |
10 * This library is distributed in the hope that it will be useful, | 10 * this list of conditions and the following disclaimer in the documentation |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * and/or other materials provided with the distribution. |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 * - Neither the name of the libjpeg-turbo Project nor the names of its |
13 * wxWindows Library License for more details. | 13 * contributors may be used to endorse or promote products derived from this |
14 */ | 14 * software without specific prior written permission. |
15 | 15 * |
16 #if (defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__)) && define
d(_WIN32) && defined(DLLDEFINE) | 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS", |
| 17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE |
| 20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 26 * POSSIBILITY OF SUCH DAMAGE. |
| 27 */ |
| 28 |
| 29 #ifndef __TURBOJPEG_H__ |
| 30 #define __TURBOJPEG_H__ |
| 31 |
| 32 #if defined(_WIN32) && defined(DLLDEFINE) |
17 #define DLLEXPORT __declspec(dllexport) | 33 #define DLLEXPORT __declspec(dllexport) |
18 #else | 34 #else |
19 #define DLLEXPORT | 35 #define DLLEXPORT |
20 #endif | 36 #endif |
21 | |
22 #define DLLCALL | 37 #define DLLCALL |
23 | 38 |
24 /* Subsampling */ | 39 |
25 #define NUMSUBOPT 4 | 40 /** |
26 | 41 * @addtogroup TurboJPEG |
27 enum {TJ_444=0, TJ_422, TJ_420, TJ_GRAYSCALE}; | 42 * TurboJPEG API. This API provides an interface for generating, decoding, and |
28 #define TJ_411 TJ_420 /* for backward compatibility with VirtualGL <= 2.1.x, | 43 * transforming planar YUV and JPEG images in memory. |
29 TurboVNC <= 0.6, and TurboJPEG/IPP */ | 44 * |
30 | 45 * @{ |
31 /* Flags */ | 46 */ |
32 #define TJ_BGR 1 | 47 |
33 /* The components of each pixel in the source/destination bitmap are stored | 48 |
34 in B,G,R order, not R,G,B */ | 49 /** |
35 #define TJ_BOTTOMUP 2 | 50 * The number of chrominance subsampling options |
36 /* The source/destination bitmap is stored in bottom-up (Windows, OpenGL) | 51 */ |
37 order, not top-down (X11) order */ | 52 #define TJ_NUMSAMP 5 |
38 #define TJ_FORCEMMX 8 | 53 |
39 /* Turn off CPU auto-detection and force TurboJPEG to use MMX code | 54 /** |
40 (IPP and 32-bit libjpeg-turbo versions only) */ | 55 * Chrominance subsampling options. |
41 #define TJ_FORCESSE 16 | 56 * When an image is converted from the RGB to the YCbCr colorspace as part of |
42 /* Turn off CPU auto-detection and force TurboJPEG to use SSE code | 57 * the JPEG compression process, some of the Cb and Cr (chrominance) components |
43 (32-bit IPP and 32-bit libjpeg-turbo versions only) */ | 58 * can be discarded or averaged together to produce a smaller image with little |
44 #define TJ_FORCESSE2 32 | 59 * perceptible loss of image clarity (the human eye is more sensitive to small |
45 /* Turn off CPU auto-detection and force TurboJPEG to use SSE2 code | 60 * changes in brightness than small changes in color.) This is called |
46 (32-bit IPP and 32-bit libjpeg-turbo versions only) */ | 61 * "chrominance subsampling". |
47 #define TJ_ALPHAFIRST 64 | 62 */ |
48 /* If the source/destination bitmap is 32 bpp, assume that each pixel is | 63 enum TJSAMP |
49 ARGB/XRGB (or ABGR/XBGR if TJ_BGR is also specified) */ | 64 { |
50 #define TJ_FORCESSE3 128 | 65 /** |
51 /* Turn off CPU auto-detection and force TurboJPEG to use SSE3 code | 66 * 4:4:4 chrominance subsampling (no chrominance subsampling). The JPEG or |
52 (64-bit IPP version only) */ | 67 * YUV image will contain one chrominance component for every pixel in the |
53 #define TJ_FASTUPSAMPLE 256 | 68 * source image. |
54 /* Use fast, inaccurate 4:2:2 and 4:2:0 YUV upsampling routines | 69 */ |
55 (libjpeg version only) */ | 70 TJSAMP_444=0, |
| 71 /** |
| 72 * 4:2:2 chrominance subsampling. The JPEG or YUV image will contain one |
| 73 * chrominance component for every 2x1 block of pixels in the source image. |
| 74 */ |
| 75 TJSAMP_422, |
| 76 /** |
| 77 * 4:2:0 chrominance subsampling. The JPEG or YUV image will contain one |
| 78 * chrominance component for every 2x2 block of pixels in the source image. |
| 79 */ |
| 80 TJSAMP_420, |
| 81 /** |
| 82 * Grayscale. The JPEG or YUV image will contain no chrominance components. |
| 83 */ |
| 84 TJSAMP_GRAY, |
| 85 /** |
| 86 * 4:4:0 chrominance subsampling. The JPEG or YUV image will contain one |
| 87 * chrominance component for every 1x2 block of pixels in the source image. |
| 88 */ |
| 89 TJSAMP_440 |
| 90 }; |
| 91 |
| 92 /** |
| 93 * MCU block width (in pixels) for a given level of chrominance subsampling. |
| 94 * MCU block sizes: |
| 95 * - 8x8 for no subsampling or grayscale |
| 96 * - 16x8 for 4:2:2 |
| 97 * - 8x16 for 4:4:0 |
| 98 * - 16x16 for 4:2:0 |
| 99 */ |
| 100 static const int tjMCUWidth[TJ_NUMSAMP] = {8, 16, 16, 8, 8}; |
| 101 |
| 102 /** |
| 103 * MCU block height (in pixels) for a given level of chrominance subsampling. |
| 104 * MCU block sizes: |
| 105 * - 8x8 for no subsampling or grayscale |
| 106 * - 16x8 for 4:2:2 |
| 107 * - 8x16 for 4:4:0 |
| 108 * - 16x16 for 4:2:0 |
| 109 */ |
| 110 static const int tjMCUHeight[TJ_NUMSAMP] = {8, 8, 16, 8, 16}; |
| 111 |
| 112 |
| 113 /** |
| 114 * The number of pixel formats |
| 115 */ |
| 116 #define TJ_NUMPF 7 |
| 117 |
| 118 /** |
| 119 * Pixel formats |
| 120 */ |
| 121 enum TJPF |
| 122 { |
| 123 /** |
| 124 * RGB pixel format. The red, green, and blue components in the image are |
| 125 * stored in 3-byte pixels in the order R, G, B from lowest to highest byte |
| 126 * address within each pixel. |
| 127 */ |
| 128 TJPF_RGB=0, |
| 129 /** |
| 130 * BGR pixel format. The red, green, and blue components in the image are |
| 131 * stored in 3-byte pixels in the order B, G, R from lowest to highest byte |
| 132 * address within each pixel. |
| 133 */ |
| 134 TJPF_BGR, |
| 135 /** |
| 136 * RGBX pixel format. The red, green, and blue components in the image are |
| 137 * stored in 4-byte pixels in the order R, G, B from lowest to highest byte |
| 138 * address within each pixel. |
| 139 */ |
| 140 TJPF_RGBX, |
| 141 /** |
| 142 * BGRX pixel format. The red, green, and blue components in the image are |
| 143 * stored in 4-byte pixels in the order B, G, R from lowest to highest byte |
| 144 * address within each pixel. |
| 145 */ |
| 146 TJPF_BGRX, |
| 147 /** |
| 148 * XBGR pixel format. The red, green, and blue components in the image are |
| 149 * stored in 4-byte pixels in the order R, G, B from highest to lowest byte |
| 150 * address within each pixel. |
| 151 */ |
| 152 TJPF_XBGR, |
| 153 /** |
| 154 * XRGB pixel format. The red, green, and blue components in the image are |
| 155 * stored in 4-byte pixels in the order B, G, R from highest to lowest byte |
| 156 * address within each pixel. |
| 157 */ |
| 158 TJPF_XRGB, |
| 159 /** |
| 160 * Grayscale pixel format. Each 1-byte pixel represents a luminance |
| 161 * (brightness) level from 0 to 255. |
| 162 */ |
| 163 TJPF_GRAY |
| 164 }; |
| 165 |
| 166 /** |
| 167 * Red offset (in bytes) for a given pixel format. This specifies the number |
| 168 * of bytes that the red component is offset from the start of the pixel. For |
| 169 * instance, if a pixel of format TJ_BGRX is stored in <tt>char pixel[]</tt>, |
| 170 * then the red component will be <tt>pixel[tjRedOffset[TJ_BGRX]]</tt>. |
| 171 */ |
| 172 static const int tjRedOffset[TJ_NUMPF] = {0, 2, 0, 2, 3, 1, 0}; |
| 173 /** |
| 174 * Green offset (in bytes) for a given pixel format. This specifies the number |
| 175 * of bytes that the green component is offset from the start of the pixel. |
| 176 * For instance, if a pixel of format TJ_BGRX is stored in |
| 177 * <tt>char pixel[]</tt>, then the green component will be |
| 178 * <tt>pixel[tjGreenOffset[TJ_BGRX]]</tt>. |
| 179 */ |
| 180 static const int tjGreenOffset[TJ_NUMPF] = {1, 1, 1, 1, 2, 2, 0}; |
| 181 /** |
| 182 * Blue offset (in bytes) for a given pixel format. This specifies the number |
| 183 * of bytes that the Blue component is offset from the start of the pixel. For |
| 184 * instance, if a pixel of format TJ_BGRX is stored in <tt>char pixel[]</tt>, |
| 185 * then the blue component will be <tt>pixel[tjBlueOffset[TJ_BGRX]]</tt>. |
| 186 */ |
| 187 static const int tjBlueOffset[TJ_NUMPF] = {2, 0, 2, 0, 1, 3, 0}; |
| 188 |
| 189 /** |
| 190 * Pixel size (in bytes) for a given pixel format. |
| 191 */ |
| 192 static const int tjPixelSize[TJ_NUMPF] = {3, 3, 4, 4, 4, 4, 1}; |
| 193 |
| 194 |
| 195 /** |
| 196 * The uncompressed source/destination image is stored in bottom-up (Windows, |
| 197 * OpenGL) order, not top-down (X11) order. |
| 198 */ |
| 199 #define TJFLAG_BOTTOMUP 2 |
| 200 /** |
| 201 * Turn off CPU auto-detection and force TurboJPEG to use MMX code (IPP and |
| 202 * 32-bit libjpeg-turbo versions only.) |
| 203 */ |
| 204 #define TJFLAG_FORCEMMX 8 |
| 205 /** |
| 206 * Turn off CPU auto-detection and force TurboJPEG to use SSE code (32-bit IPP |
| 207 * and 32-bit libjpeg-turbo versions only) |
| 208 */ |
| 209 #define TJFLAG_FORCESSE 16 |
| 210 /** |
| 211 * Turn off CPU auto-detection and force TurboJPEG to use SSE2 code (32-bit IPP |
| 212 * and 32-bit libjpeg-turbo versions only) |
| 213 */ |
| 214 #define TJFLAG_FORCESSE2 32 |
| 215 /** |
| 216 * Turn off CPU auto-detection and force TurboJPEG to use SSE3 code (64-bit IPP |
| 217 * version only) |
| 218 */ |
| 219 #define TJFLAG_FORCESSE3 128 |
| 220 /** |
| 221 * Use fast, inaccurate chrominance upsampling routines in the JPEG |
| 222 * decompressor (libjpeg and libjpeg-turbo versions only) |
| 223 */ |
| 224 #define TJFLAG_FASTUPSAMPLE 256 |
| 225 /** |
| 226 * Disable buffer (re)allocation. If passed to #tjCompress2() or |
| 227 * #tjTransform(), this flag will cause those functions to generate an error if |
| 228 * the JPEG image buffer is invalid or too small rather than attempting to |
| 229 * allocate or reallocate that buffer. This reproduces the behavior of earlier |
| 230 * versions of TurboJPEG. |
| 231 */ |
| 232 #define TJFLAG_NOREALLOC 1024 |
| 233 |
| 234 |
| 235 /** |
| 236 * Number of transform operations |
| 237 */ |
| 238 #define TJ_NUMXOP 8 |
| 239 |
| 240 /** |
| 241 * Transform operations for #tjTransform() |
| 242 */ |
| 243 enum TJXOP |
| 244 { |
| 245 /** |
| 246 * Do not transform the position of the image pixels |
| 247 */ |
| 248 TJXOP_NONE=0, |
| 249 /** |
| 250 * Flip (mirror) image horizontally. This transform is imperfect if there |
| 251 * are any partial MCU blocks on the right edge (see #TJXOPT_PERFECT.) |
| 252 */ |
| 253 TJXOP_HFLIP, |
| 254 /** |
| 255 * Flip (mirror) image vertically. This transform is imperfect if there are |
| 256 * any partial MCU blocks on the bottom edge (see #TJXOPT_PERFECT.) |
| 257 */ |
| 258 TJXOP_VFLIP, |
| 259 /** |
| 260 * Transpose image (flip/mirror along upper left to lower right axis.) This |
| 261 * transform is always perfect. |
| 262 */ |
| 263 TJXOP_TRANSPOSE, |
| 264 /** |
| 265 * Transverse transpose image (flip/mirror along upper right to lower left |
| 266 * axis.) This transform is imperfect if there are any partial MCU blocks in |
| 267 * the image (see #TJXOPT_PERFECT.) |
| 268 */ |
| 269 TJXOP_TRANSVERSE, |
| 270 /** |
| 271 * Rotate image clockwise by 90 degrees. This transform is imperfect if |
| 272 * there are any partial MCU blocks on the bottom edge (see |
| 273 * #TJXOPT_PERFECT.) |
| 274 */ |
| 275 TJXOP_ROT90, |
| 276 /** |
| 277 * Rotate image 180 degrees. This transform is imperfect if there are any |
| 278 * partial MCU blocks in the image (see #TJXOPT_PERFECT.) |
| 279 */ |
| 280 TJXOP_ROT180, |
| 281 /** |
| 282 * Rotate image counter-clockwise by 90 degrees. This transform is imperfect |
| 283 * if there are any partial MCU blocks on the right edge (see |
| 284 * #TJXOPT_PERFECT.) |
| 285 */ |
| 286 TJXOP_ROT270 |
| 287 }; |
| 288 |
| 289 |
| 290 /** |
| 291 * This option will cause #tjTransform() to return an error if the transform is |
| 292 * not perfect. Lossless transforms operate on MCU blocks, whose size depends |
| 293 * on the level of chrominance subsampling used (see #tjMCUWidth |
| 294 * and #tjMCUHeight.) If the image's width or height is not evenly divisible |
| 295 * by the MCU block size, then there will be partial MCU blocks on the right |
| 296 * and/or bottom edges. It is not possible to move these partial MCU blocks to |
| 297 * the top or left of the image, so any transform that would require that is |
| 298 * "imperfect." If this option is not specified, then any partial MCU blocks |
| 299 * that cannot be transformed will be left in place, which will create |
| 300 * odd-looking strips on the right or bottom edge of the image. |
| 301 */ |
| 302 #define TJXOPT_PERFECT 1 |
| 303 /** |
| 304 * This option will cause #tjTransform() to discard any partial MCU blocks that |
| 305 * cannot be transformed. |
| 306 */ |
| 307 #define TJXOPT_TRIM 2 |
| 308 /** |
| 309 * This option will enable lossless cropping. See #tjTransform() for more |
| 310 * information. |
| 311 */ |
| 312 #define TJXOPT_CROP 4 |
| 313 /** |
| 314 * This option will discard the color data in the input image and produce |
| 315 * a grayscale output image. |
| 316 */ |
| 317 #define TJXOPT_GRAY 8 |
| 318 |
| 319 |
| 320 /** |
| 321 * Scaling factor |
| 322 */ |
| 323 typedef struct |
| 324 { |
| 325 /** |
| 326 * Numerator |
| 327 */ |
| 328 int num; |
| 329 /** |
| 330 * Denominator |
| 331 */ |
| 332 int denom; |
| 333 } tjscalingfactor; |
| 334 |
| 335 /** |
| 336 * Cropping region |
| 337 */ |
| 338 typedef struct |
| 339 { |
| 340 /** |
| 341 * The left boundary of the cropping region. This must be evenly divisible |
| 342 * by the MCU block width (see #tjMCUWidth.) |
| 343 */ |
| 344 int x; |
| 345 /** |
| 346 * The upper boundary of the cropping region. This must be evenly divisible |
| 347 * by the MCU block height (see #tjMCUHeight.) |
| 348 */ |
| 349 int y; |
| 350 /** |
| 351 * The width of the cropping region. Setting this to 0 is the equivalent of |
| 352 * setting it to the width of the source JPEG image - x. |
| 353 */ |
| 354 int w; |
| 355 /** |
| 356 * The height of the cropping region. Setting this to 0 is the equivalent of |
| 357 * setting it to the height of the source JPEG image - y. |
| 358 */ |
| 359 int h; |
| 360 } tjregion; |
| 361 |
| 362 /** |
| 363 * Lossless transform |
| 364 */ |
| 365 typedef struct |
| 366 { |
| 367 /** |
| 368 * Cropping region |
| 369 */ |
| 370 tjregion r; |
| 371 /** |
| 372 * One of the @ref TJXOP "transform operations" |
| 373 */ |
| 374 int op; |
| 375 /** |
| 376 * The bitwise OR of one of more of the @ref TJXOPT_CROP "transform options" |
| 377 */ |
| 378 int options; |
| 379 } tjtransform; |
| 380 |
| 381 /** |
| 382 * TurboJPEG instance handle |
| 383 */ |
56 typedef void* tjhandle; | 384 typedef void* tjhandle; |
57 | 385 |
58 #define TJPAD(p) (((p)+3)&(~3)) | 386 |
59 #ifndef max | 387 /** |
60 #define max(a,b) ((a)>(b)?(a):(b)) | 388 * Pad the given width to the nearest 32-bit boundary |
61 #endif | 389 */ |
| 390 #define TJPAD(width) (((width)+3)&(~3)) |
| 391 |
| 392 /** |
| 393 * Compute the scaled value of <tt>dimension</tt> using the given scaling |
| 394 * factor. This macro performs the integer equivalent of <tt>ceil(dimension * |
| 395 * scalingFactor)</tt>. |
| 396 */ |
| 397 #define TJSCALED(dimension, scalingFactor) ((dimension * scalingFactor.num \ |
| 398 + scalingFactor.denom - 1) / scalingFactor.denom) |
| 399 |
62 | 400 |
63 #ifdef __cplusplus | 401 #ifdef __cplusplus |
64 extern "C" { | 402 extern "C" { |
65 #endif | 403 #endif |
66 | 404 |
67 /* API follows */ | 405 |
68 | 406 /** |
69 | 407 * Create a TurboJPEG compressor instance. |
70 /* | 408 * |
71 tjhandle tjInitCompress(void) | 409 * @return a handle to the newly-created instance, or NULL if an error |
72 | 410 * occurred (see #tjGetErrorStr().) |
73 Creates a new JPEG compressor instance, allocates memory for the structures, | 411 */ |
74 and returns a handle to the instance. Most applications will only | 412 DLLEXPORT tjhandle DLLCALL tjInitCompress(void); |
75 need to call this once at the beginning of the program or once for each | 413 |
76 concurrent thread. Don't try to create a new instance every time you | 414 |
77 compress an image, because this will cause performance to suffer. | 415 /** |
78 | 416 * Compress an RGB or grayscale image into a JPEG image. |
79 RETURNS: NULL on error | 417 * |
| 418 * @param handle a handle to a TurboJPEG compressor or transformer instance |
| 419 * @param srcBuf pointer to an image buffer containing RGB or grayscale pixels |
| 420 * to be compressed |
| 421 * @param width width (in pixels) of the source image |
| 422 * @param pitch bytes per line of the source image. Normally, this should be |
| 423 * <tt>width * #tjPixelSize[pixelFormat]</tt> if the image is unpadded, |
| 424 * or <tt>#TJPAD(width * #tjPixelSize[pixelFormat])</tt> if each line of |
| 425 * the image is padded to the nearest 32-bit boundary, as is the case |
| 426 * for Windows bitmaps. You can also be clever and use this parameter |
| 427 * to skip lines, etc. Setting this parameter to 0 is the equivalent of |
| 428 * setting it to <tt>width * #tjPixelSize[pixelFormat]</tt>. |
| 429 * @param height height (in pixels) of the source image |
| 430 * @param pixelFormat pixel format of the source image (see @ref TJPF |
| 431 * "Pixel formats".) |
| 432 * @param jpegBuf address of a pointer to an image buffer that will receive the |
| 433 * JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer |
| 434 * to accommodate the size of the JPEG image. Thus, you can choose to: |
| 435 * -# pre-allocate the JPEG buffer with an arbitrary size using |
| 436 * #tjAlloc() and let TurboJPEG grow the buffer as needed, |
| 437 * -# set <tt>*jpegBuf</tt> to NULL to tell TurboJPEG to allocate the |
| 438 * buffer for you, or |
| 439 * -# pre-allocate the buffer to a "worst case" size determined by |
| 440 * calling #tjBufSize(). This should ensure that the buffer never has |
| 441 * to be re-allocated (setting #TJFLAG_NOREALLOC guarantees this.) |
| 442 * . |
| 443 * If you choose option 1, <tt>*jpegSize</tt> should be set to the |
| 444 * size of your pre-allocated buffer. In any case, unless you have |
| 445 * set #TJFLAG_NOREALLOC, you should always check <tt>*jpegBuf</tt> upon |
| 446 * return from this function, as it may have changed. |
| 447 * @param jpegSize pointer to an unsigned long variable which holds the size of |
| 448 * the JPEG image buffer. If <tt>*jpegBuf</tt> points to a |
| 449 * pre-allocated buffer, then <tt>*jpegSize</tt> should be set to the |
| 450 * size of the buffer. Upon return, <tt>*jpegSize</tt> will contain the |
| 451 * size of the JPEG image (in bytes.) |
| 452 * @param jpegSubsamp the level of chrominance subsampling to be used when |
| 453 * generating the JPEG image (see @ref TJSAMP |
| 454 * "Chrominance subsampling options".) |
| 455 * @param jpegQual the image quality of the generated JPEG image (1 = worst, |
| 456 100 = best) |
| 457 * @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP |
| 458 * "flags". |
| 459 * |
| 460 * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().) |
80 */ | 461 */ |
81 DLLEXPORT tjhandle DLLCALL tjInitCompress(void); | 462 DLLEXPORT int DLLCALL tjCompress2(tjhandle handle, unsigned char *srcBuf, |
82 | 463 int width, int pitch, int height, int pixelFormat, unsigned char **jpegBuf, |
83 | 464 unsigned long *jpegSize, int jpegSubsamp, int jpegQual, int flags); |
84 /* | 465 |
85 int tjCompress(tjhandle j, | 466 |
86 unsigned char *srcbuf, int width, int pitch, int height, int pixelsize, | 467 /** |
87 unsigned char *dstbuf, unsigned long *size, | 468 * The maximum size of the buffer (in bytes) required to hold a JPEG image with |
88 int jpegsubsamp, int jpegqual, int flags) | 469 * the given parameters. The number of bytes returned by this function is |
89 | 470 * larger than the size of the uncompressed source image. The reason for this |
90 [INPUT] j = instance handle previously returned from a call to | 471 * is that the JPEG format uses 16-bit coefficients, and it is thus possible |
91 tjInitCompress() | 472 * for a very high-quality JPEG image with very high frequency content to |
92 [INPUT] srcbuf = pointer to user-allocated image buffer containing pixels in | 473 * expand rather than compress when converted to the JPEG format. Such images |
93 RGB(A) or BGR(A) form | 474 * represent a very rare corner case, but since there is no way to predict the |
94 [INPUT] width = width (in pixels) of the source image | 475 * size of a JPEG image prior to compression, the corner case has to be |
95 [INPUT] pitch = bytes per line of the source image (width*pixelsize if the | 476 * handled. |
96 bitmap is unpadded, else TJPAD(width*pixelsize) if each line of the bitmap | 477 * |
97 is padded to the nearest 32-bit boundary, such as is the case for Windows | 478 * @param width width of the image (in pixels) |
98 bitmaps. You can also be clever and use this parameter to skip lines, etc.
, | 479 * @param height height of the image (in pixels) |
99 as long as the pitch is greater than 0.) | 480 * @param jpegSubsamp the level of chrominance subsampling to be used when |
100 [INPUT] height = height (in pixels) of the source image | 481 * generating the JPEG image (see @ref TJSAMP |
101 [INPUT] pixelsize = size (in bytes) of each pixel in the source image | 482 * "Chrominance subsampling options".) |
102 RGBA and BGRA: 4, RGB and BGR: 3 | 483 * |
103 [INPUT] dstbuf = pointer to user-allocated image buffer which will receive | 484 * @return the maximum size of the buffer (in bytes) required to hold the |
104 the JPEG image. Use the macro TJBUFSIZE(width, height) to determine | 485 * image, or -1 if the arguments are out of bounds. |
105 the appropriate size for this buffer based on the image width and height. | 486 */ |
106 [OUTPUT] size = pointer to unsigned long which receives the size (in bytes) | 487 DLLEXPORT unsigned long DLLCALL tjBufSize(int width, int height, |
107 of the compressed image | 488 int jpegSubsamp); |
108 [INPUT] jpegsubsamp = Specifies either 4:2:0, 4:2:2, or 4:4:4 subsampling. | 489 |
109 When the image is converted from the RGB to YCbCr colorspace as part of the | 490 |
110 JPEG compression process, every other Cb and Cr (chrominance) pixel can be | 491 /** |
111 discarded to produce a smaller image with little perceptible loss of | 492 * The size of the buffer (in bytes) required to hold a YUV planar image with |
112 image clarity (the human eye is more sensitive to small changes in | 493 * the given parameters. |
113 brightness than small changes in color.) | 494 * |
114 | 495 * @param width width of the image (in pixels) |
115 TJ_420: 4:2:0 subsampling. Discards every other Cb, Cr pixel in both | 496 * @param height height of the image (in pixels) |
116 horizontal and vertical directions. | 497 * @param subsamp level of chrominance subsampling in the image (see |
117 TJ_422: 4:2:2 subsampling. Discards every other Cb, Cr pixel only in | 498 * @ref TJSAMP "Chrominance subsampling options".) |
118 the horizontal direction. | 499 * |
119 TJ_444: no subsampling. | 500 * @return the size of the buffer (in bytes) required to hold the image, or |
120 TJ_GRAYSCALE: Generate grayscale JPEG image | 501 * -1 if the arguments are out of bounds. |
121 | 502 */ |
122 [INPUT] jpegqual = JPEG quality (an integer between 0 and 100 inclusive.) | 503 DLLEXPORT unsigned long DLLCALL tjBufSizeYUV(int width, int height, |
123 [INPUT] flags = the bitwise OR of one or more of the flags described in the | 504 int subsamp); |
124 "Flags" section above. | 505 |
125 | 506 |
126 RETURNS: 0 on success, -1 on error | 507 /** |
| 508 * Encode an RGB or grayscale image into a YUV planar image. This function |
| 509 * uses the accelerated color conversion routines in TurboJPEG's underlying |
| 510 * codec to produce a planar YUV image that is suitable for X Video. |
| 511 * Specifically, if the chrominance components are subsampled along the |
| 512 * horizontal dimension, then the width of the luminance plane is padded to 2 |
| 513 * in the output image (same goes for the height of the luminance plane, if the |
| 514 * chrominance components are subsampled along the vertical dimension.) Also, |
| 515 * each line of each plane in the output image is padded to 4 bytes. Although |
| 516 * this will work with any subsampling option, it is really only useful in |
| 517 * combination with TJ_420, which produces an image compatible with the I420 |
| 518 * (AKA "YUV420P") format. |
| 519 * |
| 520 * @param handle a handle to a TurboJPEG compressor or transformer instance |
| 521 * @param srcBuf pointer to an image buffer containing RGB or grayscale pixels |
| 522 * to be encoded |
| 523 * @param width width (in pixels) of the source image |
| 524 * @param pitch bytes per line of the source image. Normally, this should be |
| 525 * <tt>width * #tjPixelSize[pixelFormat]</tt> if the image is unpadded, |
| 526 * or <tt>#TJPAD(width * #tjPixelSize[pixelFormat])</tt> if each line of |
| 527 * the image is padded to the nearest 32-bit boundary, as is the case |
| 528 * for Windows bitmaps. You can also be clever and use this parameter |
| 529 * to skip lines, etc. Setting this parameter to 0 is the equivalent of |
| 530 * setting it to <tt>width * #tjPixelSize[pixelFormat]</tt>. |
| 531 * @param height height (in pixels) of the source image |
| 532 * @param pixelFormat pixel format of the source image (see @ref TJPF |
| 533 * "Pixel formats".) |
| 534 * @param dstBuf pointer to an image buffer which will receive the YUV image. |
| 535 * Use #tjBufSizeYUV() to determine the appropriate size for this buffer |
| 536 * based on the image width, height, and level of chrominance |
| 537 * subsampling. |
| 538 * @param subsamp the level of chrominance subsampling to be used when |
| 539 * generating the YUV image (see @ref TJSAMP |
| 540 * "Chrominance subsampling options".) |
| 541 * @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP |
| 542 * "flags". |
| 543 * |
| 544 * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().) |
127 */ | 545 */ |
128 DLLEXPORT int DLLCALL tjCompress(tjhandle j, | 546 DLLEXPORT int DLLCALL tjEncodeYUV2(tjhandle handle, |
129 » unsigned char *srcbuf, int width, int pitch, int height, int pixelsize, | 547 unsigned char *srcBuf, int width, int pitch, int height, int pixelFormat, |
130 » unsigned char *dstbuf, unsigned long *size, | 548 unsigned char *dstBuf, int subsamp, int flags); |
131 » int jpegsubsamp, int jpegqual, int flags); | 549 |
132 | 550 |
133 DLLEXPORT unsigned long DLLCALL TJBUFSIZE(int width, int height); | 551 /** |
134 | 552 * Create a TurboJPEG decompressor instance. |
135 /* | 553 * |
136 tjhandle tjInitDecompress(void) | 554 * @return a handle to the newly-created instance, or NULL if an error |
137 | 555 * occurred (see #tjGetErrorStr().) |
138 Creates a new JPEG decompressor instance, allocates memory for the | |
139 structures, and returns a handle to the instance. Most applications will | |
140 only need to call this once at the beginning of the program or once for each | |
141 concurrent thread. Don't try to create a new instance every time you | |
142 decompress an image, because this will cause performance to suffer. | |
143 | |
144 RETURNS: NULL on error | |
145 */ | 556 */ |
146 DLLEXPORT tjhandle DLLCALL tjInitDecompress(void); | 557 DLLEXPORT tjhandle DLLCALL tjInitDecompress(void); |
147 | 558 |
148 | 559 |
149 /* | 560 /** |
150 int tjDecompressHeader(tjhandle j, | 561 * Retrieve information about a JPEG image without decompressing it. |
151 unsigned char *srcbuf, unsigned long size, | 562 * |
152 int *width, int *height) | 563 * @param handle a handle to a TurboJPEG decompressor or transformer instance |
153 | 564 * @param jpegBuf pointer to a buffer containing a JPEG image |
154 [INPUT] j = instance handle previously returned from a call to | 565 * @param jpegSize size of the JPEG image (in bytes) |
155 tjInitDecompress() | 566 * @param width pointer to an integer variable which will receive the width (in |
156 [INPUT] srcbuf = pointer to a user-allocated buffer containing the JPEG image | 567 * pixels) of the JPEG image |
157 to decompress | 568 * @param height pointer to an integer variable which will receive the height |
158 [INPUT] size = size of the JPEG image buffer (in bytes) | 569 * (in pixels) of the JPEG image |
159 [OUTPUT] width = width (in pixels) of the JPEG image | 570 * @param jpegSubsamp pointer to an integer variable which will receive the |
160 [OUTPUT] height = height (in pixels) of the JPEG image | 571 * level of chrominance subsampling used when compressing the JPEG image |
161 | 572 * (see @ref TJSAMP "Chrominance subsampling options".) |
162 RETURNS: 0 on success, -1 on error | 573 * |
| 574 * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().) |
163 */ | 575 */ |
164 DLLEXPORT int DLLCALL tjDecompressHeader(tjhandle j, | 576 DLLEXPORT int DLLCALL tjDecompressHeader2(tjhandle handle, |
165 » unsigned char *srcbuf, unsigned long size, | 577 unsigned char *jpegBuf, unsigned long jpegSize, int *width, int *height, |
166 » int *width, int *height); | 578 int *jpegSubsamp); |
167 | 579 |
168 | 580 |
169 /* | 581 /** |
170 int tjDecompress(tjhandle j, | 582 * Returns a list of fractional scaling factors that the JPEG decompressor in |
171 unsigned char *srcbuf, unsigned long size, | 583 * this implementation of TurboJPEG supports. |
172 unsigned char *dstbuf, int width, int pitch, int height, int pixelsize, | 584 * |
173 int flags) | 585 * @param numscalingfactors pointer to an integer variable that will receive |
174 | 586 * the number of elements in the list |
175 [INPUT] j = instance handle previously returned from a call to | 587 * |
176 tjInitDecompress() | 588 * @return a pointer to a list of fractional scaling factors, or NULL if an |
177 [INPUT] srcbuf = pointer to a user-allocated buffer containing the JPEG image | 589 * error is encountered (see #tjGetErrorStr().) |
178 to decompress | |
179 [INPUT] size = size of the JPEG image buffer (in bytes) | |
180 [INPUT] dstbuf = pointer to user-allocated image buffer which will receive | |
181 the bitmap image. This buffer should normally be pitch*height | |
182 bytes in size, although this pointer may also be used to decompress into | |
183 a specific region of a larger buffer. | |
184 [INPUT] width = width (in pixels) of the destination image | |
185 [INPUT] pitch = bytes per line of the destination image (width*pixelsize if th
e | |
186 bitmap is unpadded, else TJPAD(width*pixelsize) if each line of the bitmap | |
187 is padded to the nearest 32-bit boundary, such as is the case for Windows | |
188 bitmaps. You can also be clever and use this parameter to skip lines, etc.
, | |
189 as long as the pitch is greater than 0.) | |
190 [INPUT] height = height (in pixels) of the destination image | |
191 [INPUT] pixelsize = size (in bytes) of each pixel in the destination image | |
192 RGBA/RGBx and BGRA/BGRx: 4, RGB and BGR: 3 | |
193 [INPUT] flags = the bitwise OR of one or more of the flags described in the | |
194 "Flags" section above. | |
195 | |
196 RETURNS: 0 on success, -1 on error | |
197 */ | 590 */ |
198 DLLEXPORT int DLLCALL tjDecompress(tjhandle j, | 591 DLLEXPORT tjscalingfactor* DLLCALL tjGetScalingFactors(int *numscalingfactors); |
199 » unsigned char *srcbuf, unsigned long size, | 592 |
200 » unsigned char *dstbuf, int width, int pitch, int height, int pixelsize, | 593 |
201 » int flags); | 594 /** |
202 | 595 * Decompress a JPEG image to an RGB or grayscale image. |
203 | 596 * |
204 /* | 597 * @param handle a handle to a TurboJPEG decompressor or transformer instance |
205 int tjDestroy(tjhandle h) | 598 * @param jpegBuf pointer to a buffer containing the JPEG image to decompress |
206 | 599 * @param jpegSize size of the JPEG image (in bytes) |
207 Frees structures associated with a compression or decompression instance | 600 * @param dstBuf pointer to an image buffer which will receive the decompressed |
208 | 601 * image. This buffer should normally be <tt>pitch * scaledHeight</tt> |
209 [INPUT] h = instance handle (returned from a previous call to | 602 * bytes in size, where <tt>scaledHeight</tt> can be determined by |
210 tjInitCompress() or tjInitDecompress() | 603 * calling #TJSCALED() with the JPEG image height and one of the scaling |
211 | 604 * factors returned by #tjGetScalingFactors(). The dstBuf pointer may |
212 RETURNS: 0 on success, -1 on error | 605 * also be used to decompress into a specific region of a larger buffer. |
213 */ | 606 * @param width desired width (in pixels) of the destination image. If this is |
214 DLLEXPORT int DLLCALL tjDestroy(tjhandle h); | 607 * smaller than the width of the JPEG image being decompressed, then |
215 | 608 * TurboJPEG will use scaling in the JPEG decompressor to generate the |
216 | 609 * largest possible image that will fit within the desired width. If |
217 /* | 610 * width is set to 0, then only the height will be considered when |
218 char *tjGetErrorStr(void) | 611 * determining the scaled image size. |
219 | 612 * @param pitch bytes per line of the destination image. Normally, this is |
220 Returns a descriptive error message explaining why the last command failed | 613 * <tt>scaledWidth * #tjPixelSize[pixelFormat]</tt> if the decompressed |
221 */ | 614 * image is unpadded, else <tt>#TJPAD(scaledWidth * |
| 615 * #tjPixelSize[pixelFormat])</tt> if each line of the decompressed |
| 616 * image is padded to the nearest 32-bit boundary, as is the case for |
| 617 * Windows bitmaps. (NOTE: <tt>scaledWidth</tt> can be determined by |
| 618 * calling #TJSCALED() with the JPEG image width and one of the scaling |
| 619 * factors returned by #tjGetScalingFactors().) You can also be clever |
| 620 * and use the pitch parameter to skip lines, etc. Setting this |
| 621 * parameter to 0 is the equivalent of setting it to <tt>scaledWidth |
| 622 * * #tjPixelSize[pixelFormat]</tt>. |
| 623 * @param height desired height (in pixels) of the destination image. If this |
| 624 * is smaller than the height of the JPEG image being decompressed, then |
| 625 * TurboJPEG will use scaling in the JPEG decompressor to generate the |
| 626 * largest possible image that will fit within the desired height. If |
| 627 * height is set to 0, then only the width will be considered when |
| 628 * determining the scaled image size. |
| 629 * @param pixelFormat pixel format of the destination image (see @ref |
| 630 * TJPF "Pixel formats".) |
| 631 * @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP |
| 632 * "flags". |
| 633 * |
| 634 * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().) |
| 635 */ |
| 636 DLLEXPORT int DLLCALL tjDecompress2(tjhandle handle, |
| 637 unsigned char *jpegBuf, unsigned long jpegSize, unsigned char *dstBuf, |
| 638 int width, int pitch, int height, int pixelFormat, int flags); |
| 639 |
| 640 |
| 641 /** |
| 642 * Decompress a JPEG image to a YUV planar image. This function performs JPEG |
| 643 * decompression but leaves out the color conversion step, so a planar YUV |
| 644 * image is generated instead of an RGB image. The padding of the planes in |
| 645 * this image is the same as the images generated by #tjEncodeYUV2(). Note |
| 646 * that, if the width or height of the image is not an even multiple of the MCU |
| 647 * block size (see #tjMCUWidth and #tjMCUHeight), then an intermediate buffer |
| 648 * copy will be performed within TurboJPEG. |
| 649 * |
| 650 * @param handle a handle to a TurboJPEG decompressor or transformer instance |
| 651 * @param jpegBuf pointer to a buffer containing the JPEG image to decompress |
| 652 * @param jpegSize size of the JPEG image (in bytes) |
| 653 * @param dstBuf pointer to an image buffer which will receive the YUV image. |
| 654 * Use #tjBufSizeYUV to determine the appropriate size for this buffer |
| 655 * based on the image width, height, and level of subsampling. |
| 656 * @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP |
| 657 * "flags". |
| 658 * |
| 659 * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().) |
| 660 */ |
| 661 DLLEXPORT int DLLCALL tjDecompressToYUV(tjhandle handle, |
| 662 unsigned char *jpegBuf, unsigned long jpegSize, unsigned char *dstBuf, |
| 663 int flags); |
| 664 |
| 665 |
| 666 /** |
| 667 * Create a new TurboJPEG transformer instance. |
| 668 * |
| 669 * @return a handle to the newly-created instance, or NULL if an error |
| 670 * occurred (see #tjGetErrorStr().) |
| 671 */ |
| 672 DLLEXPORT tjhandle DLLCALL tjInitTransform(void); |
| 673 |
| 674 |
| 675 /** |
| 676 * Losslessly transform a JPEG image into another JPEG image. Lossless |
| 677 * transforms work by moving the raw coefficients from one JPEG image structure |
| 678 * to another without altering the values of the coefficients. While this is |
| 679 * typically faster than decompressing the image, transforming it, and |
| 680 * re-compressing it, lossless transforms are not free. Each lossless |
| 681 * transform requires reading and Huffman decoding all of the coefficients in |
| 682 * the source image, regardless of the size of the destination image. Thus, |
| 683 * this function provides a means of generating multiple transformed images |
| 684 * from the same source or of applying multiple transformations simultaneously, |
| 685 * in order to eliminate the need to read the source coefficients multiple |
| 686 * times. |
| 687 * |
| 688 * @param handle a handle to a TurboJPEG transformer instance |
| 689 * @param jpegBuf pointer to a buffer containing the JPEG image to transform |
| 690 * @param jpegSize size of the JPEG image (in bytes) |
| 691 * @param n the number of transformed JPEG images to generate |
| 692 * @param dstBufs pointer to an array of n image buffers. <tt>dstBufs[i]</tt> |
| 693 * will receive a JPEG image that has been transformed using the |
| 694 * parameters in <tt>transforms[i]</tt>. TurboJPEG has the ability to |
| 695 * reallocate the JPEG buffer to accommodate the size of the JPEG image. |
| 696 * Thus, you can choose to: |
| 697 * -# pre-allocate the JPEG buffer with an arbitrary size using |
| 698 * #tjAlloc() and let TurboJPEG grow the buffer as needed, |
| 699 * -# set <tt>dstBufs[i]</tt> to NULL to tell TurboJPEG to allocate the |
| 700 * buffer for you, or |
| 701 * -# pre-allocate the buffer to a "worst case" size determined by |
| 702 * calling #tjBufSize() with the cropped width and height. This should |
| 703 * ensure that the buffer never has to be re-allocated (setting |
| 704 * #TJFLAG_NOREALLOC guarantees this.) |
| 705 * . |
| 706 * If you choose option 1, <tt>dstSizes[i]</tt> should be set to |
| 707 * the size of your pre-allocated buffer. In any case, unless you have |
| 708 * set #TJFLAG_NOREALLOC, you should always check <tt>dstBufs[i]</tt> |
| 709 * upon return from this function, as it may have changed. |
| 710 * @param dstSizes pointer to an array of n unsigned long variables which will |
| 711 * receive the actual sizes (in bytes) of each transformed JPEG image. |
| 712 * If <tt>dstBufs[i]</tt> points to a pre-allocated buffer, then |
| 713 * <tt>dstSizes[i]</tt> should be set to the size of the buffer. Upon |
| 714 * return, <tt>dstSizes[i]</tt> will contain the size of the JPEG image |
| 715 * (in bytes.) |
| 716 * @param transforms pointer to an array of n tjtransform structures, each of |
| 717 * which specifies the transform parameters and/or cropping region for |
| 718 * the corresponding transformed output image. |
| 719 * @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP |
| 720 * "flags". |
| 721 * |
| 722 * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().) |
| 723 */ |
| 724 DLLEXPORT int DLLCALL tjTransform(tjhandle handle, unsigned char *jpegBuf, |
| 725 unsigned long jpegSize, int n, unsigned char **dstBufs, |
| 726 unsigned long *dstSizes, tjtransform *transforms, int flags); |
| 727 |
| 728 |
| 729 /** |
| 730 * Destroy a TurboJPEG compressor, decompressor, or transformer instance. |
| 731 * |
| 732 * @param handle a handle to a TurboJPEG compressor, decompressor or |
| 733 * transformer instance |
| 734 * |
| 735 * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().) |
| 736 */ |
| 737 DLLEXPORT int DLLCALL tjDestroy(tjhandle handle); |
| 738 |
| 739 |
| 740 /** |
| 741 * Allocate an image buffer for use with TurboJPEG. You should always use |
| 742 * this function to allocate the JPEG destination buffer(s) for #tjCompress2() |
| 743 * and #tjTransform() unless you are disabling automatic buffer |
| 744 * (re)allocation (by setting #TJFLAG_NOREALLOC.) |
| 745 * |
| 746 * @param bytes the number of bytes to allocate |
| 747 * |
| 748 * @return a pointer to a newly-allocated buffer with the specified number of |
| 749 * bytes |
| 750 * |
| 751 * @sa tjFree() |
| 752 */ |
| 753 DLLEXPORT unsigned char* DLLCALL tjAlloc(int bytes); |
| 754 |
| 755 |
| 756 /** |
| 757 * Free an image buffer previously allocated by TurboJPEG. You should always |
| 758 * use this function to free JPEG destination buffer(s) that were automatically |
| 759 * (re)allocated by #tjCompress2() or #tjTransform() or that were manually |
| 760 * allocated using #tjAlloc(). |
| 761 * |
| 762 * @param buffer address of the buffer to free |
| 763 * |
| 764 * @sa tjAlloc() |
| 765 */ |
| 766 DLLEXPORT void DLLCALL tjFree(unsigned char *buffer); |
| 767 |
| 768 |
| 769 /** |
| 770 * Returns a descriptive error message explaining why the last command failed. |
| 771 * |
| 772 * @return a descriptive error message explaining why the last command failed. |
| 773 */ |
222 DLLEXPORT char* DLLCALL tjGetErrorStr(void); | 774 DLLEXPORT char* DLLCALL tjGetErrorStr(void); |
223 | 775 |
| 776 |
| 777 /* Backward compatibility functions and macros (nothing to see here) */ |
| 778 #define NUMSUBOPT TJ_NUMSAMP |
| 779 #define TJ_444 TJSAMP_444 |
| 780 #define TJ_422 TJSAMP_422 |
| 781 #define TJ_420 TJSAMP_420 |
| 782 #define TJ_411 TJSAMP_420 |
| 783 #define TJ_GRAYSCALE TJSAMP_GRAY |
| 784 |
| 785 #define TJ_BGR 1 |
| 786 #define TJ_BOTTOMUP TJFLAG_BOTTOMUP |
| 787 #define TJ_FORCEMMX TJFLAG_FORCEMMX |
| 788 #define TJ_FORCESSE TJFLAG_FORCESSE |
| 789 #define TJ_FORCESSE2 TJFLAG_FORCESSE2 |
| 790 #define TJ_ALPHAFIRST 64 |
| 791 #define TJ_FORCESSE3 TJFLAG_FORCESSE3 |
| 792 #define TJ_FASTUPSAMPLE TJFLAG_FASTUPSAMPLE |
| 793 #define TJ_YUV 512 |
| 794 |
| 795 DLLEXPORT unsigned long DLLCALL TJBUFSIZE(int width, int height); |
| 796 |
| 797 DLLEXPORT unsigned long DLLCALL TJBUFSIZEYUV(int width, int height, |
| 798 int jpegSubsamp); |
| 799 |
| 800 DLLEXPORT int DLLCALL tjCompress(tjhandle handle, unsigned char *srcBuf, |
| 801 int width, int pitch, int height, int pixelSize, unsigned char *dstBuf, |
| 802 unsigned long *compressedSize, int jpegSubsamp, int jpegQual, int flags); |
| 803 |
| 804 DLLEXPORT int DLLCALL tjEncodeYUV(tjhandle handle, |
| 805 unsigned char *srcBuf, int width, int pitch, int height, int pixelSize, |
| 806 unsigned char *dstBuf, int subsamp, int flags); |
| 807 |
| 808 DLLEXPORT int DLLCALL tjDecompressHeader(tjhandle handle, |
| 809 unsigned char *jpegBuf, unsigned long jpegSize, int *width, int *height); |
| 810 |
| 811 DLLEXPORT int DLLCALL tjDecompress(tjhandle handle, |
| 812 unsigned char *jpegBuf, unsigned long jpegSize, unsigned char *dstBuf, |
| 813 int width, int pitch, int height, int pixelSize, int flags); |
| 814 |
| 815 |
| 816 /** |
| 817 * @} |
| 818 */ |
| 819 |
224 #ifdef __cplusplus | 820 #ifdef __cplusplus |
225 } | 821 } |
226 #endif | 822 #endif |
| 823 |
| 824 #endif |
OLD | NEW |