Changeset 15217 in josm for trunk/src/com/drew/metadata/jpeg


Ignore:
Timestamp:
2019-07-07T01:56:46+02:00 (6 years ago)
Author:
Don-vip
Message:

see #17848 - update to metadata-extractor 2.12.0

Location:
trunk/src/com/drew/metadata/jpeg
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/com/drew/metadata/jpeg/HuffmanTablesDescriptor.java

    r13061 r15217  
    11/*
    2  * Copyright 2002-2017 Drew Noakes
     2 * Copyright 2002-2019 Drew Noakes and contributors
    33 *
    44 *    Licensed under the Apache License, Version 2.0 (the "License");
     
    2828
    2929/**
    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}.
    3131 *
    3232 * <ul>
     
    6161    {
    6262        Integer value = _directory.getInteger(TAG_NUMBER_OF_TABLES);
    63         if (value==null)
     63        if (value == null)
    6464            return null;
    6565        return value + (value == 1 ? " Huffman table" : " Huffman tables");
  • trunk/src/com/drew/metadata/jpeg/HuffmanTablesDirectory.java

    r13061 r15217  
    11/*
    2  * Copyright 2002-2017 Drew Noakes
     2 * Copyright 2002-2019 Drew Noakes and contributors
    33 *
    44 *    Licensed under the Apache License, Version 2.0 (the "License");
     
    2525import java.util.HashMap;
    2626import java.util.List;
     27
    2728import com.drew.lang.annotations.NotNull;
    2829import com.drew.metadata.Directory;
     
    168169    /**
    169170     * @return The {@link List} of {@link HuffmanTable}s in this
    170      *         {@link Directory}.
     171     * {@link Directory}.
    171172     */
    172173    @NotNull
     
    227228     */
    228229    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             @NotNull HuffmanTableClass
    237             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,
    238239            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;
    247253        }
    248254
     
    251257         */
    252258        public int getTableLength() {
    253             return tableLength;
    254         }
    255 
     259            return _tableLength;
     260        }
    256261
    257262        /**
     
    259264         */
    260265        public HuffmanTableClass getTableClass() {
    261             return tableClass;
    262         }
    263 
     266            return _tableClass;
     267        }
    264268
    265269        /**
     
    267271         */
    268272        public int getTableDestinationId() {
    269             return tableDestinationId;
    270         }
    271 
     273            return _tableDestinationId;
     274        }
    272275
    273276        /**
    274277         * @return A byte array with the L values for this table.
    275278         */
     279        @NotNull
    276280        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);
    281283            return result;
    282284        }
    283285
    284 
    285286        /**
    286287         * @return A byte array with the V values for this table.
    287288         */
     289        @NotNull
    288290        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);
    293293            return result;
    294294        }
     
    318318         */
    319319        public boolean isTypical() {
    320             if (tableClass == HuffmanTableClass.DC) {
     320            if (_tableClass == HuffmanTableClass.DC) {
    321321                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) {
    327327                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);
    332332            }
    333333            return false;
     
    351351            public static HuffmanTableClass typeOf(int value) {
    352352                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;
    356359                }
    357360            }
  • trunk/src/com/drew/metadata/jpeg/JpegCommentDescriptor.java

    r13061 r15217  
    11/*
    2  * Copyright 2002-2017 Drew Noakes
     2 * Copyright 2002-2019 Drew Noakes and contributors
    33 *
    44 *    Licensed under the Apache License, Version 2.0 (the "License");
  • trunk/src/com/drew/metadata/jpeg/JpegCommentDirectory.java

    r13061 r15217  
    11/*
    2  * Copyright 2002-2017 Drew Noakes
     2 * Copyright 2002-2019 Drew Noakes and contributors
    33 *
    44 *    Licensed under the Apache License, Version 2.0 (the "License");
  • trunk/src/com/drew/metadata/jpeg/JpegCommentReader.java

    r13061 r15217  
    11/*
    2  * Copyright 2002-2017 Drew Noakes
     2 * Copyright 2002-2019 Drew Noakes and contributors
    33 *
    44 *    Licensed under the Apache License, Version 2.0 (the "License");
  • trunk/src/com/drew/metadata/jpeg/JpegComponent.java

    r13061 r15217  
    11/*
    2  * Copyright 2002-2017 Drew Noakes
     2 * Copyright 2002-2019 Drew Noakes and contributors
    33 *
    44 *    Licensed under the Apache License, Version 2.0 (the "License");
  • trunk/src/com/drew/metadata/jpeg/JpegDescriptor.java

    r13061 r15217  
    11/*
    2  * Copyright 2002-2017 Drew Noakes
     2 * Copyright 2002-2019 Drew Noakes and contributors
    33 *
    44 *    Licensed under the Apache License, Version 2.0 (the "License");
  • trunk/src/com/drew/metadata/jpeg/JpegDhtReader.java

    r13061 r15217  
    11/*
    2  * Copyright 2002-2017 Drew Noakes
     2 * Copyright 2002-2019 Drew Noakes and contributors
    33 *
    44 *    Licensed under the Apache License, Version 2.0 (the "License");
  • trunk/src/com/drew/metadata/jpeg/JpegDirectory.java

    r13061 r15217  
    11/*
    2  * Copyright 2002-2017 Drew Noakes
     2 * Copyright 2002-2019 Drew Noakes and contributors
    33 *
    44 *    Licensed under the Apache License, Version 2.0 (the "License");
  • trunk/src/com/drew/metadata/jpeg/JpegDnlReader.java

    r13061 r15217  
    11/*
    2  * Copyright 2002-2017 Drew Noakes
     2 * Copyright 2002-2019 Drew Noakes and contributors
    33 *
    44 *    Licensed under the Apache License, Version 2.0 (the "License");
     
    3030
    3131import java.io.IOException;
    32 import java.util.Arrays;
    3332import java.util.Collections;
    3433
  • trunk/src/com/drew/metadata/jpeg/JpegReader.java

    r13061 r15217  
    11/*
    2  * Copyright 2002-2017 Drew Noakes
     2 * Copyright 2002-2019 Drew Noakes and contributors
    33 *
    44 *    Licensed under the Apache License, Version 2.0 (the "License");
Note: See TracChangeset for help on using the changeset viewer.