001/* ***** BEGIN LICENSE BLOCK ***** 002 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 003 * 004 * The contents of this file are subject to the Mozilla Public License Version 005 * 1.1 (the "License"); you may not use this file except in compliance with 006 * the License. You may obtain a copy of the License at 007 * http://www.mozilla.org/MPL/ 008 * 009 * Software distributed under the License is distributed on an "AS IS" basis, 010 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 011 * for the specific language governing rights and limitations under the 012 * License. 013 * 014 * The Original Code is part of dcm4che, an implementation of DICOM(TM) in 015 * Java(TM), hosted at https://github.com/gunterze/dcm4che. 016 * 017 * The Initial Developer of the Original Code is 018 * Agfa Healthcare. 019 * Portions created by the Initial Developer are Copyright (C) 2013 020 * the Initial Developer. All Rights Reserved. 021 * 022 * Contributor(s): 023 * See @authors listed below 024 * 025 * Alternatively, the contents of this file may be used under the terms of 026 * either the GNU General Public License Version 2 or later (the "GPL"), or 027 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 028 * in which case the provisions of the GPL or the LGPL are applicable instead 029 * of those above. If you wish to allow use of your version of this file only 030 * under the terms of either the GPL or the LGPL, and not to allow others to 031 * use your version of this file under the terms of the MPL, indicate your 032 * decision by deleting the provisions above and replace them with the notice 033 * and other provisions required by the GPL or the LGPL. If you do not delete 034 * the provisions above, a recipient may use your version of this file under 035 * the terms of any one of the MPL, the GPL or the LGPL. 036 * 037 * ***** END LICENSE BLOCK ***** */ 038 039package org.dcm4che3.imageio.codec.jpeg; 040 041/** 042 * @author Gunter Zeilinger <gunterze@gmail.com> 043 * 044 */ 045public class JPEG { 046 047 /** For temporary use in arithmetic coding */ 048 public static final int TEM = 0x01; 049 050 // Codes 0x02 - 0xBF are reserved 051 052 // SOF markers for Nondifferential Huffman coding 053 /** Baseline DCT */ 054 public static final int SOF0 = 0xC0; 055 /** Extended Sequential DCT */ 056 public static final int SOF1 = 0xC1; 057 /** Progressive DCT */ 058 public static final int SOF2 = 0xC2; 059 /** Lossless Sequential */ 060 public static final int SOF3 = 0xC3; 061 062 /** Define Huffman Tables */ 063 public static final int DHT = 0xC4; 064 065 // SOF markers for Differential Huffman coding 066 /** Differential Sequential DCT */ 067 public static final int SOF5 = 0xC5; 068 /** Differential Progressive DCT */ 069 public static final int SOF6 = 0xC6; 070 /** Differential Lossless */ 071 public static final int SOF7 = 0xC7; 072 073 /** Reserved for JPEG extensions */ 074 public static final int JPG = 0xC8; 075 076 // SOF markers for Nondifferential arithmetic coding 077 /** Extended Sequential DCT, Arithmetic coding */ 078 public static final int SOF9 = 0xC9; 079 /** Progressive DCT, Arithmetic coding */ 080 public static final int SOF10 = 0xCA; 081 /** Lossless Sequential, Arithmetic coding */ 082 public static final int SOF11 = 0xCB; 083 084 /** Define Arithmetic conditioning tables */ 085 public static final int DAC = 0xCC; 086 087 // SOF markers for Differential arithmetic coding 088 /** Differential Sequential DCT, Arithmetic coding */ 089 public static final int SOF13 = 0xCD; 090 /** Differential Progressive DCT, Arithmetic coding */ 091 public static final int SOF14 = 0xCE; 092 /** Differential Lossless, Arithmetic coding */ 093 public static final int SOF15 = 0xCF; 094 095 // Restart Markers 096 public static final int RST0 = 0xD0; 097 public static final int RST1 = 0xD1; 098 public static final int RST2 = 0xD2; 099 public static final int RST3 = 0xD3; 100 public static final int RST4 = 0xD4; 101 public static final int RST5 = 0xD5; 102 public static final int RST6 = 0xD6; 103 public static final int RST7 = 0xD7; 104 /** Number of restart markers */ 105 public static final int RESTART_RANGE = 8; 106 107 /** Start of Image */ 108 public static final int SOI = 0xD8; 109 /** End of Image */ 110 public static final int EOI = 0xD9; 111 /** Start of Scan */ 112 public static final int SOS = 0xDA; 113 114 /** Define Quantization Tables */ 115 public static final int DQT = 0xDB; 116 117 /** Define Number of lines */ 118 public static final int DNL = 0xDC; 119 120 /** Define Restart Interval */ 121 public static final int DRI = 0xDD; 122 123 /** Define Hierarchical progression */ 124 public static final int DHP = 0xDE; 125 126 /** Expand reference image(s) */ 127 public static final int EXP = 0xDF; 128 129 // Application markers 130 /** APP0 used by JFIF */ 131 public static final int APP0 = 0xE0; 132 public static final int APP1 = 0xE1; 133 public static final int APP2 = 0xE2; 134 public static final int APP3 = 0xE3; 135 public static final int APP4 = 0xE4; 136 public static final int APP5 = 0xE5; 137 public static final int APP6 = 0xE6; 138 public static final int APP7 = 0xE7; 139 public static final int APP8 = 0xE8; 140 public static final int APP9 = 0xE9; 141 public static final int APP10 = 0xEA; 142 public static final int APP11 = 0xEB; 143 public static final int APP12 = 0xEC; 144 public static final int APP13 = 0xED; 145 /** APP14 used by Adobe */ 146 public static final int APP14 = 0xEE; 147 public static final int APP15 = 0xEF; 148 149 // codes 0xF0 to 0xFD are reserved 150 /** JPEG-LS coding */ 151 public static final int SOF55 = 0xF7; 152 /** JPEG-LS parameters */ 153 public static final int LSE = 0xF8; 154 155 /** Comment marker */ 156 public static final int COM = 0xFE; 157 158 public static boolean isStandalone(int marker) { 159 switch(marker) { 160 case TEM: 161 case RST0: 162 case RST1: 163 case RST2: 164 case RST3: 165 case RST4: 166 case RST5: 167 case RST6: 168 case RST7: 169 case SOI: 170 case EOI: 171 return true; 172 } 173 return false; 174 } 175 176 public static boolean isSOF(int marker) { 177 switch(marker) { 178 case SOF0: 179 case SOF1: 180 case SOF2: 181 case SOF3: 182 case SOF5: 183 case SOF6: 184 case SOF7: 185 case SOF9: 186 case SOF10: 187 case SOF11: 188 case SOF13: 189 case SOF14: 190 case SOF15: 191 case SOF55: 192 return true; 193 } 194 return false; 195 } 196 197 public static boolean isAPP(int marker) { 198 return (marker & APP0) == APP0; 199 } 200}