File indexing completed on 2025-01-19 03:55:03

0001 /*****************************************************************************/
0002 // Copyright 2006-2019 Adobe Systems Incorporated
0003 // All Rights Reserved.
0004 //
0005 // NOTICE:  Adobe permits you to use, modify, and distribute this file in
0006 // accordance with the terms of the Adobe license agreement accompanying it.
0007 /*****************************************************************************/
0008 
0009 /** \file
0010  * Class for holding top-level information about a DNG image.
0011  */
0012 
0013 /*****************************************************************************/
0014 
0015 #ifndef __dng_info__
0016 #define __dng_info__
0017 
0018 /*****************************************************************************/
0019 
0020 #include "dng_auto_ptr.h"
0021 #include "dng_classes.h"
0022 #include "dng_errors.h"
0023 #include "dng_exif.h"
0024 #include "dng_ifd.h"
0025 #include "dng_sdk_limits.h"
0026 #include "dng_shared.h"
0027 #include "dng_uncopyable.h"
0028 
0029 #include <vector>
0030 
0031 /*****************************************************************************/
0032 
0033 /// \brief Top-level structure of DNG file with access to metadata.
0034 ///
0035 /// See \ref spec_dng "DNG 1.1.0 specification" for information on member fields of this class.
0036 
0037 class dng_info: private dng_uncopyable
0038     {
0039 
0040     public:
0041 
0042         uint64 fTIFFBlockOffset;
0043 
0044         uint64 fTIFFBlockOriginalOffset;
0045 
0046         bool fBigEndian;
0047 
0048         uint32 fMagic;
0049 
0050         AutoPtr<dng_exif> fExif;
0051 
0052         AutoPtr<dng_shared> fShared;
0053 
0054         int32 fMainIndex;
0055 
0056         int32 fMaskIndex;
0057 
0058         int32 fDepthIndex;
0059 
0060         int32 fEnhancedIndex;
0061 
0062         std::vector <dng_ifd *> fIFD;
0063 
0064         std::vector <dng_ifd *> fChainedIFD;
0065 
0066         std::vector <std::vector <dng_ifd *> > fChainedSubIFD;
0067 
0068     protected:
0069 
0070         uint32 fMakerNoteNextIFD;
0071 
0072     public:
0073 
0074         dng_info ();
0075 
0076         virtual ~dng_info ();
0077 
0078         /// Returns the number of parsed SubIFDs (including the main IFD).
0079 
0080         uint32 IFDCount () const
0081             {
0082             return (uint32) fIFD.size ();
0083             }
0084 
0085         /// Returns the number of chained IFDs.
0086 
0087         uint32 ChainedIFDCount () const
0088             {
0089             return (uint32) fChainedIFD.size ();
0090             }
0091 
0092         /// Returns number SubIFDs for a chained IFD.
0093 
0094         uint32 ChainedSubIFDCount (uint32 chainIndex) const
0095             {
0096             if (chainIndex >= fChainedSubIFD.size ())
0097                 return 0;
0098             else
0099                 return (uint32) fChainedSubIFD [chainIndex].size ();
0100             }
0101 
0102         /// Read dng_info from a dng_stream
0103         /// \param host DNG host used for progress updating, abort testing, buffer allocation, etc.
0104         /// \param stream Stream to read DNG data from.
0105 
0106         virtual void Parse (dng_host &host,
0107                             dng_stream &stream);
0108 
0109         /// Must be called immediately after a successful Parse operation.
0110 
0111         virtual void PostParse (dng_host &host);
0112 
0113         /// Test validity of DNG data.
0114         /// \retval true if stream provided a valid DNG.
0115 
0116         virtual bool IsValidDNG ();
0117 
0118     protected:
0119 
0120         virtual void ValidateMagic ();
0121 
0122         virtual void ParseTag (dng_host &host,
0123                                dng_stream &stream,
0124                                dng_exif *exif,
0125                                dng_shared *shared,
0126                                dng_ifd *ifd,
0127                                uint32 parentCode,
0128                                uint32 tagCode,
0129                                uint32 tagType,
0130                                uint32 tagCount,
0131                                uint64 tagOffset,
0132                                int64 offsetDelta);
0133 
0134         virtual bool ValidateIFD (dng_stream &stream,
0135                                   uint64 ifdOffset,
0136                                   int64 offsetDelta);
0137 
0138         virtual void ParseIFD (dng_host &host,
0139                                dng_stream &stream,
0140                                dng_exif *exif,
0141                                dng_shared *shared,
0142                                dng_ifd *ifd,
0143                                uint64 ifdOffset,
0144                                int64 offsetDelta,
0145                                uint32 parentCode);
0146 
0147         virtual bool ParseMakerNoteIFD (dng_host &host,
0148                                         dng_stream &stream,
0149                                         uint64 ifdSize,
0150                                         uint64 ifdOffset,
0151                                         int64 offsetDelta,
0152                                         uint64 minOffset,
0153                                         uint64 maxOffset,
0154                                         uint32 parentCode);
0155 
0156         virtual void ParseMakerNote (dng_host &host,
0157                                      dng_stream &stream,
0158                                      uint32 makerNoteCount,
0159                                      uint64 makerNoteOffset,
0160                                      int64 offsetDelta,
0161                                      uint64 minOffset,
0162                                      uint64 maxOffset);
0163 
0164         virtual void ParseSonyPrivateData (dng_host &host,
0165                                            dng_stream &stream,
0166                                            uint64 count,
0167                                            uint64 oldOffset,
0168                                            uint64 newOffset);
0169 
0170         virtual void ParseDNGPrivateData (dng_host &host,
0171                                           dng_stream &stream);
0172 
0173     };
0174 
0175 /*****************************************************************************/
0176 
0177 #endif
0178 
0179 /*****************************************************************************/