Changeset 15217 in josm for trunk/src/com/drew/metadata/jpeg
- Timestamp:
- 2019-07-07T01:56:46+02:00 (6 years ago)
- Location:
- trunk/src/com/drew/metadata/jpeg
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/com/drew/metadata/jpeg/HuffmanTablesDescriptor.java
r13061 r15217 1 1 /* 2 * Copyright 2002-201 7Drew Noakes2 * Copyright 2002-2019 Drew Noakes and contributors 3 3 * 4 4 * Licensed under the Apache License, Version 2.0 (the "License"); … … 28 28 29 29 /** 30 * Provides a human-readable string version of the tag stored in a HuffmanTableDirectory. 30 * Provides a human-readable string version of the tag stored in a {@link HuffmanTablesDirectory}. 31 31 * 32 32 * <ul> … … 61 61 { 62 62 Integer value = _directory.getInteger(TAG_NUMBER_OF_TABLES); 63 if (value ==null)63 if (value == null) 64 64 return null; 65 65 return value + (value == 1 ? " Huffman table" : " Huffman tables"); -
trunk/src/com/drew/metadata/jpeg/HuffmanTablesDirectory.java
r13061 r15217 1 1 /* 2 * Copyright 2002-201 7Drew Noakes2 * Copyright 2002-2019 Drew Noakes and contributors 3 3 * 4 4 * Licensed under the Apache License, Version 2.0 (the "License"); … … 25 25 import java.util.HashMap; 26 26 import java.util.List; 27 27 28 import com.drew.lang.annotations.NotNull; 28 29 import com.drew.metadata.Directory; … … 168 169 /** 169 170 * @return The {@link List} of {@link HuffmanTable}s in this 170 * 171 * {@link Directory}. 171 172 */ 172 173 @NotNull … … 227 228 */ 228 229 public static class HuffmanTable { 229 private final int tableLength; 230 private final HuffmanTableClass tableClass; 231 private final int tableDestinationId; 232 private final byte[] lengthBytes; 233 private final byte[] valueBytes; 234 235 public HuffmanTable (236 @NotNullHuffmanTableClass237 tableClass, 230 private final int _tableLength; 231 private final HuffmanTableClass _tableClass; 232 private final int _tableDestinationId; 233 private final byte[] _lengthBytes; 234 private final byte[] _valueBytes; 235 236 @SuppressWarnings("ConstantConditions") 237 public HuffmanTable( 238 @NotNull HuffmanTableClass tableClass, 238 239 int tableDestinationId, 239 @NotNull byte[] lBytes, 240 @NotNull byte[] vBytes 241 ) { 242 this.tableClass = tableClass; 243 this.tableDestinationId = tableDestinationId; 244 this.lengthBytes = lBytes; 245 this.valueBytes = vBytes; 246 this.tableLength = vBytes.length + 17; 240 @NotNull byte[] lengthBytes, 241 @NotNull byte[] valueBytes) 242 { 243 if (lengthBytes == null) 244 throw new IllegalArgumentException("lengthBytes cannot be null."); 245 if (valueBytes == null) 246 throw new IllegalArgumentException("valueBytes cannot be null."); 247 248 _tableClass = tableClass; 249 _tableDestinationId = tableDestinationId; 250 _lengthBytes = lengthBytes; 251 _valueBytes = valueBytes; 252 _tableLength = _valueBytes.length + 17; 247 253 } 248 254 … … 251 257 */ 252 258 public int getTableLength() { 253 return tableLength; 254 } 255 259 return _tableLength; 260 } 256 261 257 262 /** … … 259 264 */ 260 265 public HuffmanTableClass getTableClass() { 261 return tableClass; 262 } 263 266 return _tableClass; 267 } 264 268 265 269 /** … … 267 271 */ 268 272 public int getTableDestinationId() { 269 return tableDestinationId; 270 } 271 273 return _tableDestinationId; 274 } 272 275 273 276 /** 274 277 * @return A byte array with the L values for this table. 275 278 */ 279 @NotNull 276 280 public byte[] getLengthBytes() { 277 if (lengthBytes == null) 278 return null; 279 byte[] result = new byte[lengthBytes.length]; 280 System.arraycopy(lengthBytes, 0, result, 0, lengthBytes.length); 281 byte[] result = new byte[_lengthBytes.length]; 282 System.arraycopy(_lengthBytes, 0, result, 0, _lengthBytes.length); 281 283 return result; 282 284 } 283 285 284 285 286 /** 286 287 * @return A byte array with the V values for this table. 287 288 */ 289 @NotNull 288 290 public byte[] getValueBytes() { 289 if (valueBytes == null) 290 return null; 291 byte[] result = new byte[valueBytes.length]; 292 System.arraycopy(valueBytes, 0, result, 0, valueBytes.length); 291 byte[] result = new byte[_valueBytes.length]; 292 System.arraycopy(_valueBytes, 0, result, 0, _valueBytes.length); 293 293 return result; 294 294 } … … 318 318 */ 319 319 public boolean isTypical() { 320 if (tableClass == HuffmanTableClass.DC) { 320 if (_tableClass == HuffmanTableClass.DC) { 321 321 return 322 Arrays.equals(lengthBytes, TYPICAL_LUMINANCE_DC_LENGTHS) && 323 Arrays.equals(valueBytes, TYPICAL_LUMINANCE_DC_VALUES) || 324 Arrays.equals(lengthBytes, TYPICAL_CHROMINANCE_DC_LENGTHS) && 325 Arrays.equals(valueBytes, TYPICAL_CHROMINANCE_DC_VALUES); 326 } else if (tableClass == HuffmanTableClass.AC) { 322 Arrays.equals(_lengthBytes, TYPICAL_LUMINANCE_DC_LENGTHS) && 323 Arrays.equals(_valueBytes, TYPICAL_LUMINANCE_DC_VALUES) || 324 Arrays.equals(_lengthBytes, TYPICAL_CHROMINANCE_DC_LENGTHS) && 325 Arrays.equals(_valueBytes, TYPICAL_CHROMINANCE_DC_VALUES); 326 } else if (_tableClass == HuffmanTableClass.AC) { 327 327 return 328 Arrays.equals(lengthBytes, TYPICAL_LUMINANCE_AC_LENGTHS) && 329 Arrays.equals(valueBytes, TYPICAL_LUMINANCE_AC_VALUES) || 330 Arrays.equals(lengthBytes, TYPICAL_CHROMINANCE_AC_LENGTHS) && 331 Arrays.equals(valueBytes, TYPICAL_CHROMINANCE_AC_VALUES); 328 Arrays.equals(_lengthBytes, TYPICAL_LUMINANCE_AC_LENGTHS) && 329 Arrays.equals(_valueBytes, TYPICAL_LUMINANCE_AC_VALUES) || 330 Arrays.equals(_lengthBytes, TYPICAL_CHROMINANCE_AC_LENGTHS) && 331 Arrays.equals(_valueBytes, TYPICAL_CHROMINANCE_AC_VALUES); 332 332 } 333 333 return false; … … 351 351 public static HuffmanTableClass typeOf(int value) { 352 352 switch (value) { 353 case 0: return DC; 354 case 1 : return AC; 355 default: return UNKNOWN; 353 case 0: 354 return DC; 355 case 1: 356 return AC; 357 default: 358 return UNKNOWN; 356 359 } 357 360 } -
trunk/src/com/drew/metadata/jpeg/JpegCommentDescriptor.java
r13061 r15217 1 1 /* 2 * Copyright 2002-201 7Drew Noakes2 * Copyright 2002-2019 Drew Noakes and contributors 3 3 * 4 4 * Licensed under the Apache License, Version 2.0 (the "License"); -
trunk/src/com/drew/metadata/jpeg/JpegCommentDirectory.java
r13061 r15217 1 1 /* 2 * Copyright 2002-201 7Drew Noakes2 * Copyright 2002-2019 Drew Noakes and contributors 3 3 * 4 4 * Licensed under the Apache License, Version 2.0 (the "License"); -
trunk/src/com/drew/metadata/jpeg/JpegCommentReader.java
r13061 r15217 1 1 /* 2 * Copyright 2002-201 7Drew Noakes2 * Copyright 2002-2019 Drew Noakes and contributors 3 3 * 4 4 * Licensed under the Apache License, Version 2.0 (the "License"); -
trunk/src/com/drew/metadata/jpeg/JpegComponent.java
r13061 r15217 1 1 /* 2 * Copyright 2002-201 7Drew Noakes2 * Copyright 2002-2019 Drew Noakes and contributors 3 3 * 4 4 * Licensed under the Apache License, Version 2.0 (the "License"); -
trunk/src/com/drew/metadata/jpeg/JpegDescriptor.java
r13061 r15217 1 1 /* 2 * Copyright 2002-201 7Drew Noakes2 * Copyright 2002-2019 Drew Noakes and contributors 3 3 * 4 4 * Licensed under the Apache License, Version 2.0 (the "License"); -
trunk/src/com/drew/metadata/jpeg/JpegDhtReader.java
r13061 r15217 1 1 /* 2 * Copyright 2002-201 7Drew Noakes2 * Copyright 2002-2019 Drew Noakes and contributors 3 3 * 4 4 * Licensed under the Apache License, Version 2.0 (the "License"); -
trunk/src/com/drew/metadata/jpeg/JpegDirectory.java
r13061 r15217 1 1 /* 2 * Copyright 2002-201 7Drew Noakes2 * Copyright 2002-2019 Drew Noakes and contributors 3 3 * 4 4 * Licensed under the Apache License, Version 2.0 (the "License"); -
trunk/src/com/drew/metadata/jpeg/JpegDnlReader.java
r13061 r15217 1 1 /* 2 * Copyright 2002-201 7Drew Noakes2 * Copyright 2002-2019 Drew Noakes and contributors 3 3 * 4 4 * Licensed under the Apache License, Version 2.0 (the "License"); … … 30 30 31 31 import java.io.IOException; 32 import java.util.Arrays;33 32 import java.util.Collections; 34 33 -
trunk/src/com/drew/metadata/jpeg/JpegReader.java
r13061 r15217 1 1 /* 2 * Copyright 2002-201 7Drew Noakes2 * Copyright 2002-2019 Drew Noakes and contributors 3 3 * 4 4 * Licensed under the Apache License, Version 2.0 (the "License");
Note:
See TracChangeset
for help on using the changeset viewer.