OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Small jpeg decoder library (Internal header) |
| 3 * |
| 4 * Copyright (c) 2006, Luc Saillard <luc@saillard.org> |
| 5 * Copyright (c) 2012 Intel Corporation. |
| 6 * All rights reserved. |
| 7 * Redistribution and use in source and binary forms, with or without |
| 8 * modification, are permitted provided that the following conditions are met: |
| 9 * |
| 10 * - Redistributions of source code must retain the above copyright notice, |
| 11 * this list of conditions and the following disclaimer. |
| 12 * |
| 13 * - Redistributions in binary form must reproduce the above copyright notice, |
| 14 * this list of conditions and the following disclaimer in the documentation |
| 15 * and/or other materials provided with the distribution. |
| 16 * |
| 17 * - Neither the name of the author nor the names of its contributors may be |
| 18 * used to endorse or promote products derived from this software without |
| 19 * specific prior written permission. |
| 20 * |
| 21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
| 25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 31 * POSSIBILITY OF SUCH DAMAGE. |
| 32 * |
| 33 */ |
| 34 |
| 35 |
| 36 #ifndef __TINYJPEG_INTERNAL_H_ |
| 37 #define __TINYJPEG_INTERNAL_H_ |
| 38 |
| 39 #include <setjmp.h> |
| 40 |
| 41 #define SANITY_CHECK 1 |
| 42 |
| 43 struct jdec_private; |
| 44 |
| 45 #define HUFFMAN_BITS_SIZE 256 |
| 46 |
| 47 #define HUFFMAN_TABLES 4 |
| 48 #define COMPONENTS 4 |
| 49 #define JPEG_MAX_WIDTH 2048 |
| 50 #define JPEG_MAX_HEIGHT 2048 |
| 51 |
| 52 enum std_markers { |
| 53 DQT = 0xDB, /* Define Quantization Table */ |
| 54 SOF = 0xC0, /* Start of Frame (size information) */ |
| 55 DHT = 0xC4, /* Huffman Table */ |
| 56 SOI = 0xD8, /* Start of Image */ |
| 57 SOS = 0xDA, /* Start of Scan */ |
| 58 RST = 0xD0, /* Reset Marker d0 -> .. */ |
| 59 RST7 = 0xD7, /* Reset Marker .. -> d7 */ |
| 60 EOI = 0xD9, /* End of Image */ |
| 61 DRI = 0xDD, /* Define Restart Interval */ |
| 62 APP0 = 0xE0, |
| 63 }; |
| 64 |
| 65 |
| 66 struct huffman_table |
| 67 { |
| 68 /*bits and values*/ |
| 69 unsigned char bits[16]; |
| 70 unsigned char values[256]; |
| 71 }; |
| 72 |
| 73 struct component |
| 74 { |
| 75 unsigned int Hfactor; |
| 76 unsigned int Vfactor; |
| 77 unsigned char quant_table_index; |
| 78 unsigned int cid; |
| 79 }; |
| 80 |
| 81 |
| 82 typedef void (*decode_MCU_fct) (struct jdec_private *priv); |
| 83 typedef void (*convert_colorspace_fct) (struct jdec_private *priv); |
| 84 |
| 85 struct jpeg_sos |
| 86 { |
| 87 unsigned int nr_components; |
| 88 struct { |
| 89 unsigned int component_id; |
| 90 unsigned int dc_selector; |
| 91 unsigned int ac_selector; |
| 92 }components[4]; |
| 93 }; |
| 94 |
| 95 struct jdec_private |
| 96 { |
| 97 /* Public variables */ |
| 98 unsigned int width, height; /* Size of the image */ |
| 99 |
| 100 /* Private variables */ |
| 101 const unsigned char *stream_begin, *stream_end; |
| 102 unsigned int stream_length; |
| 103 |
| 104 const unsigned char *stream; /* Pointer to the current stream */ |
| 105 |
| 106 struct component component_infos[COMPONENTS]; |
| 107 unsigned int nf_components; |
| 108 unsigned char Q_tables[COMPONENTS][64]; /* quantization tables,
zigzag*/ |
| 109 struct huffman_table HTDC[HUFFMAN_TABLES]; /* DC huffman tables */ |
| 110 struct huffman_table HTAC[HUFFMAN_TABLES]; /* AC huffman tables */ |
| 111 struct jpeg_sos cur_sos; /* current sos values*/ |
| 112 int default_huffman_table_initialized; |
| 113 int restart_interval; |
| 114 }; |
| 115 |
| 116 #endif |
| 117 |
OLD | NEW |