github.com/cellofellow/gopkg@v0.0.0-20140722061823-eec0544a62ad/image/jxr/jxrlib/jxrgluelib/JXRGlue.h (about)

     1  //*@@@+++@@@@******************************************************************
     2  //
     3  // Copyright Microsoft Corp.
     4  // All rights reserved.
     5  // 
     6  // Redistribution and use in source and binary forms, with or without
     7  // modification, are permitted provided that the following conditions are met:
     8  // 
     9  // Redistributions of source code must retain the above copyright notice,
    10  //   this list of conditions and the following disclaimer.
    11  // Redistributions in binary form must reproduce the above copyright notice,
    12  //   this list of conditions and the following disclaimer in the documentation
    13  //   and/or other materials provided with the distribution.
    14  // 
    15  // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    16  // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    17  // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    18  // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
    19  // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    20  // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    21  // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    22  // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    23  // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    24  // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    25  // POSSIBILITY OF SUCH DAMAGE.
    26  //
    27  //*@@@---@@@@******************************************************************
    28  #pragma once
    29  
    30  #ifdef __cplusplus
    31  extern "C" {
    32  #endif
    33  
    34  #include <JXRMeta.h>
    35  #include <guiddef.h>
    36  
    37  //================================================================
    38  #define WMP_SDK_VERSION 0x0101
    39  #define PK_SDK_VERSION 0x0101
    40  
    41  #define sizeof2(array) (sizeof(array)/sizeof(*(array)))
    42  #ifndef max
    43  #define max(a,b) ((a) > (b) ? (a) : (b))
    44  #endif
    45  #ifndef min
    46  #define min(b,a) ((a) < (b) ? (a) : (b))
    47  #endif
    48  #ifdef __ANSI__
    49  #define STRCPY_SAFE(pszDest, cbDest, pszSrc)    (strncpy((pszDest), (pszSrc), (cbDest)) == (pszDest) ? 0 : 1)
    50  #else
    51  #define STRCPY_SAFE(pszDest, cbDest, pszSrc)    (strcpy_s((pszDest), (cbDest), (pszSrc)))
    52  #endif // __ANSI__
    53  
    54  //================================================================
    55  typedef struct tagPKRect
    56  {
    57      I32 X;
    58      I32 Y;
    59      I32 Width;
    60      I32 Height;
    61  } PKRect;
    62  
    63  //================================================================
    64  typedef U32 PKIID;
    65  
    66  EXTERN_C const PKIID IID_PKImageScanEncode;
    67  EXTERN_C const PKIID IID_PKImageFrameEncode;
    68  
    69  EXTERN_C const PKIID IID_PKImageWmpEncode;
    70  
    71  EXTERN_C const PKIID IID_PKImageWmpDecode;
    72  
    73  struct IFDEntry
    74  {
    75      U16 uTag;
    76      U16 uType;
    77      U32 uCount;
    78      U32 uValue;
    79  };
    80  EXTERN_C const U32 IFDEntryTypeSizes[13];
    81  EXTERN_C const U32 SizeofIFDEntry;
    82  
    83  //================================================================
    84  typedef float Float;
    85  
    86  typedef enum tagPKStreamFlags
    87  {
    88      PKStreamOpenRead = 0x00000000UL,
    89      PKStreamOpenWrite = 0x00000001UL,
    90      PKStreamOpenReadWrite = 0x00000002UL,
    91      PKStreamNoLock = 0x00010000UL,
    92      PKStreamNoSeek = 0x00020000UL,
    93      PKStreamCompress = 0x00040000UL,
    94  } PKStreamFlags;
    95  
    96  /* Undefined formats */
    97  #define GUID_PKPixelFormatUndefined GUID_PKPixelFormatDontCare
    98  
    99  DEFINE_GUID(GUID_PKPixelFormatDontCare, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x00);
   100  
   101  /* Indexed formats */
   102  //DEFINE_GUID(GUID_PKPixelFormat1bppIndexed, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x01);
   103  //DEFINE_GUID(GUID_PKPixelFormat2bppIndexed, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x02);
   104  //DEFINE_GUID(GUID_PKPixelFormat4bppIndexed, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x03);
   105  //DEFINE_GUID(GUID_PKPixelFormat8bppIndexed, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x04);
   106  
   107  DEFINE_GUID(GUID_PKPixelFormatBlackWhite, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x05);
   108  //DEFINE_GUID(GUID_PKPixelFormat2bppGray,   0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x06);
   109  //DEFINE_GUID(GUID_PKPixelFormat4bppGray,   0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x07);
   110  DEFINE_GUID(GUID_PKPixelFormat8bppGray,   0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x08);
   111  
   112  /* sRGB formats (gamma is approx. 2.2) */
   113  /* For a full definition, see the sRGB spec */
   114  
   115  /* 16bpp formats */
   116  DEFINE_GUID(GUID_PKPixelFormat16bppRGB555, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x09);
   117  DEFINE_GUID(GUID_PKPixelFormat16bppRGB565, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x0a);
   118  DEFINE_GUID(GUID_PKPixelFormat16bppGray,   0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x0b);
   119  
   120  /* 24bpp formats */
   121  DEFINE_GUID(GUID_PKPixelFormat24bppBGR, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x0c);
   122  DEFINE_GUID(GUID_PKPixelFormat24bppRGB, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x0d);
   123  
   124  /* 32bpp format */
   125  DEFINE_GUID(GUID_PKPixelFormat32bppBGR,   0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x0e);
   126  DEFINE_GUID(GUID_PKPixelFormat32bppBGRA,  0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x0f);
   127  DEFINE_GUID(GUID_PKPixelFormat32bppPBGRA, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x10);
   128  DEFINE_GUID(GUID_PKPixelFormat32bppGrayFloat,  0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x11);
   129  DEFINE_GUID(GUID_PKPixelFormat32bppRGB,   0xd98c6b95, 0x3efe, 0x47d6, 0xbb, 0x25, 0xeb, 0x17, 0x48, 0xab, 0x0c, 0xf1);
   130  DEFINE_GUID(GUID_PKPixelFormat32bppRGBA,  0xf5c7ad2d, 0x6a8d, 0x43dd, 0xa7, 0xa8, 0xa2, 0x99, 0x35, 0x26, 0x1a, 0xe9);
   131  DEFINE_GUID(GUID_PKPixelFormat32bppPRGBA, 0x3cc4a650, 0xa527, 0x4d37, 0xa9, 0x16, 0x31, 0x42, 0xc7, 0xeb, 0xed, 0xba);
   132  
   133  /* 48bpp format */
   134  DEFINE_GUID(GUID_PKPixelFormat48bppRGBFixedPoint, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x12);
   135  
   136  /* scRGB formats. Gamma is 1.0 */
   137  /* For a full definition, see the scRGB spec */
   138  
   139  /* 16bpp format */
   140  DEFINE_GUID(GUID_PKPixelFormat16bppGrayFixedPoint, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x13);
   141  
   142  /* 32bpp format */
   143  DEFINE_GUID(GUID_PKPixelFormat32bppRGB101010, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x14);
   144  
   145  /* 48bpp format */
   146  DEFINE_GUID(GUID_PKPixelFormat48bppRGB, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x15);
   147  
   148  /* 64bpp format */
   149  DEFINE_GUID(GUID_PKPixelFormat64bppRGBA,  0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x16);
   150  DEFINE_GUID(GUID_PKPixelFormat64bppPRGBA, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x17);
   151  
   152  /* 96bpp format */
   153  DEFINE_GUID(GUID_PKPixelFormat96bppRGBFixedPoint, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x18);
   154  DEFINE_GUID(GUID_PKPixelFormat96bppRGBFloat, 0xe3fed78f, 0xe8db, 0x4acf, 0x84, 0xc1, 0xe9, 0x7f, 0x61, 0x36, 0xb3, 0x27);
   155  
   156   /* Floating point scRGB formats */
   157  DEFINE_GUID(GUID_PKPixelFormat128bppRGBAFloat,  0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x19);
   158  DEFINE_GUID(GUID_PKPixelFormat128bppPRGBAFloat, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x1a);
   159  DEFINE_GUID(GUID_PKPixelFormat128bppRGBFloat,   0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x1b);
   160  
   161   /* CMYK formats. */
   162  DEFINE_GUID(GUID_PKPixelFormat32bppCMYK, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x1c);
   163  
   164   /* Photon formats */
   165  DEFINE_GUID(GUID_PKPixelFormat64bppRGBAFixedPoint, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x1d);
   166  DEFINE_GUID(GUID_PKPixelFormat64bppRGBFixedPoint, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x40);
   167  DEFINE_GUID(GUID_PKPixelFormat128bppRGBAFixedPoint, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x1e);
   168  DEFINE_GUID(GUID_PKPixelFormat128bppRGBFixedPoint, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x41);
   169  
   170  DEFINE_GUID(GUID_PKPixelFormat64bppRGBAHalf, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x3a);
   171  DEFINE_GUID(GUID_PKPixelFormat64bppRGBHalf, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x42);
   172  DEFINE_GUID(GUID_PKPixelFormat48bppRGBHalf, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x3b);
   173  
   174  DEFINE_GUID(GUID_PKPixelFormat32bppRGBE, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x3d);
   175  
   176  DEFINE_GUID(GUID_PKPixelFormat16bppGrayHalf, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x3e);
   177  DEFINE_GUID(GUID_PKPixelFormat32bppGrayFixedPoint, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x3f);
   178  
   179  
   180  /* More CMYK formats and n-Channel formats */
   181  DEFINE_GUID(GUID_PKPixelFormat64bppCMYK, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x1f);
   182  
   183  DEFINE_GUID(GUID_PKPixelFormat24bpp3Channels, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x20);
   184  DEFINE_GUID(GUID_PKPixelFormat32bpp4Channels, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x21);
   185  DEFINE_GUID(GUID_PKPixelFormat40bpp5Channels, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x22);
   186  DEFINE_GUID(GUID_PKPixelFormat48bpp6Channels, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x23);
   187  DEFINE_GUID(GUID_PKPixelFormat56bpp7Channels, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x24);
   188  DEFINE_GUID(GUID_PKPixelFormat64bpp8Channels, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x25);
   189  
   190  DEFINE_GUID(GUID_PKPixelFormat48bpp3Channels, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x26);
   191  DEFINE_GUID(GUID_PKPixelFormat64bpp4Channels, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x27);
   192  DEFINE_GUID(GUID_PKPixelFormat80bpp5Channels, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x28);
   193  DEFINE_GUID(GUID_PKPixelFormat96bpp6Channels, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x29);
   194  DEFINE_GUID(GUID_PKPixelFormat112bpp7Channels, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x2a);
   195  DEFINE_GUID(GUID_PKPixelFormat128bpp8Channels, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x2b);
   196  
   197  DEFINE_GUID(GUID_PKPixelFormat40bppCMYKAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x2c);
   198  DEFINE_GUID(GUID_PKPixelFormat80bppCMYKAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x2d);
   199  
   200  DEFINE_GUID(GUID_PKPixelFormat32bpp3ChannelsAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x2e);
   201  DEFINE_GUID(GUID_PKPixelFormat40bpp4ChannelsAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x2f);
   202  DEFINE_GUID(GUID_PKPixelFormat48bpp5ChannelsAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x30);
   203  DEFINE_GUID(GUID_PKPixelFormat56bpp6ChannelsAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x31);
   204  DEFINE_GUID(GUID_PKPixelFormat64bpp7ChannelsAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x32);
   205  DEFINE_GUID(GUID_PKPixelFormat72bpp8ChannelsAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x33);
   206  
   207  DEFINE_GUID(GUID_PKPixelFormat64bpp3ChannelsAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x34);
   208  DEFINE_GUID(GUID_PKPixelFormat80bpp4ChannelsAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x35);
   209  DEFINE_GUID(GUID_PKPixelFormat96bpp5ChannelsAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x36);
   210  DEFINE_GUID(GUID_PKPixelFormat112bpp6ChannelsAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x37);
   211  DEFINE_GUID(GUID_PKPixelFormat128bpp7ChannelsAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x38);
   212  DEFINE_GUID(GUID_PKPixelFormat144bpp8ChannelsAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x39);
   213  
   214  /* YCrCb  from Advanced Profile */
   215  DEFINE_GUID(GUID_PKPixelFormat12bppYCC420, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x44);
   216  DEFINE_GUID(GUID_PKPixelFormat16bppYCC422, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x45);
   217  DEFINE_GUID(GUID_PKPixelFormat20bppYCC422, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x46);
   218  DEFINE_GUID(GUID_PKPixelFormat32bppYCC422, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x47);
   219  DEFINE_GUID(GUID_PKPixelFormat24bppYCC444, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x48);
   220  DEFINE_GUID(GUID_PKPixelFormat30bppYCC444, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x49);
   221  DEFINE_GUID(GUID_PKPixelFormat48bppYCC444, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x4a);
   222  DEFINE_GUID(GUID_PKPixelFormat16bpp48bppYCC444FixedPoint, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x4b);
   223  DEFINE_GUID(GUID_PKPixelFormat20bppYCC420Alpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x4c);
   224  DEFINE_GUID(GUID_PKPixelFormat24bppYCC422Alpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x4d);
   225  DEFINE_GUID(GUID_PKPixelFormat30bppYCC422Alpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x4e);
   226  DEFINE_GUID(GUID_PKPixelFormat48bppYCC422Alpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x4f);
   227  DEFINE_GUID(GUID_PKPixelFormat32bppYCC444Alpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x50);
   228  DEFINE_GUID(GUID_PKPixelFormat40bppYCC444Alpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x51);
   229  DEFINE_GUID(GUID_PKPixelFormat64bppYCC444Alpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x52);
   230  DEFINE_GUID(GUID_PKPixelFormat64bppYCC444AlphaFixedPoint, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x53);
   231  
   232  //YUV
   233  #define GUID_PKPixelFormat12bppYUV420 GUID_PKPixelFormat12bppYCC420
   234  #define GUID_PKPixelFormat16bppYUV422 GUID_PKPixelFormat16bppYCC422
   235  #define GUID_PKPixelFormat24bppYUV444 GUID_PKPixelFormat24bppYCC444
   236  
   237  /* CMYKDIRECT from Advanced Profile */
   238  DEFINE_GUID(GUID_PKPixelFormat32bppCMYKDIRECT, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x54);
   239  DEFINE_GUID(GUID_PKPixelFormat64bppCMYKDIRECT, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x55);
   240  DEFINE_GUID(GUID_PKPixelFormat40bppCMYKDIRECTAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x56);
   241  DEFINE_GUID(GUID_PKPixelFormat80bppCMYKDIRECTAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x43);
   242  
   243  // PhotometricInterpretation
   244  #define PK_PI_W0 0 // WhiteIsZero
   245  #define PK_PI_B0 1 // BlackIsZero
   246  #define PK_PI_RGB 2
   247  #define PK_PI_RGBPalette 3
   248  #define PK_PI_TransparencyMask 4
   249  #define PK_PI_CMYK 5
   250  #define PK_PI_YCbCr 6
   251  #define PK_PI_CIELab 8
   252  
   253  #define PK_PI_NCH  100
   254  #define PK_PI_RGBE 101
   255  
   256  #define PK_pixfmtNul           0x00000000
   257  #define PK_pixfmtHasAlpha      0x00000010
   258  #define PK_pixfmtPreMul        0x00000020
   259  #define PK_pixfmtBGR           0x00000040
   260  #define PK_pixfmtNeedConvert   0x80000000
   261  
   262  #define LOOKUP_FORWARD         0
   263  #define LOOKUP_BACKWARD_TIF    1
   264  
   265  typedef unsigned long WMP_GRBIT;
   266  typedef GUID PKPixelFormatGUID;
   267  
   268  typedef struct tagPKPixelInfo
   269  {
   270      const PKPixelFormatGUID* pGUIDPixFmt;
   271  
   272      size_t cChannel;
   273      COLORFORMAT cfColorFormat;
   274      BITDEPTH_BITS bdBitDepth;
   275      U32 cbitUnit;
   276      
   277      WMP_GRBIT grBit;
   278  
   279      // TIFF
   280      U32 uInterpretation;
   281      U32 uSamplePerPixel;
   282      U32 uBitsPerSample;
   283      U32 uSampleFormat;
   284  } PKPixelInfo;
   285  
   286  //================================================================
   287  ERR PKAlloc(void** ppv, size_t cb);
   288  ERR PKFree(void** ppv);
   289  
   290  //----------------------------------------------------------------
   291  //ERR GetPixelInfo(PKPixelFormatGUID enPixelFormat, const PKPixelInfo** ppPI);
   292  ERR PixelFormatLookup(PKPixelInfo* pPI, U8 uLookupType);
   293  const PKPixelFormatGUID* GetPixelFormatFromHash(const U8 uPFHash);
   294  
   295  ERR GetImageEncodeIID(const char* szExt, const PKIID** ppIID);
   296  ERR GetImageDecodeIID(const char* szExt, const PKIID** ppIID);
   297  
   298  
   299  //================================================================
   300  #ifdef __ANSI__
   301  struct tagPKFactory;
   302  struct tagPKCodecFactory;
   303  struct tagPKImageDecode;
   304  struct tagPKImageEncode;
   305  struct tagPKFormatConverter;
   306  #define PKFactory           struct tagPKFactory
   307  #define PKCodecFactory      struct tagPKCodecFactory
   308  #define PKImageDecode       struct tagPKImageDecode
   309  #define PKImageEncode       struct tagPKImageEncode
   310  #define PKFormatConverter   struct tagPKFormatConverter
   311  #else // __ANSI__
   312  typedef struct tagPKFactory PKFactory;
   313  typedef struct tagPKCodecFactory PKCodecFactory;
   314  typedef struct tagPKImageDecode PKImageDecode;
   315  typedef struct tagPKImageEncode PKImageEncode;
   316  typedef struct tagPKFormatConverter PKFormatConverter;
   317  #endif // __ANSI__
   318  //================================================================
   319  typedef struct tagPKStream
   320  {
   321      ERR (*InitializeFromFilename)(const char*, ULong);
   322  
   323      ERR (*Release)(void);
   324  
   325      FILE* fp;
   326  } PKStream;
   327  
   328  
   329  //================================================================
   330  typedef struct tagPKFactory
   331  {
   332      ERR (*CreateStream)(PKStream**);
   333  
   334      ERR (*CreateStreamFromFilename)(struct WMPStream**, const char*, const char*);
   335      ERR (*CreateStreamFromMemory)(struct WMPStream**, void*, size_t);
   336  
   337      ERR (*Release)(PKFactory**);
   338  #ifdef __ANSI__
   339  #undef PKFactory
   340  #endif // __ANSI__
   341  } PKFactory;
   342  
   343  //----------------------------------------------------------------
   344  ERR PKCreateFactory_CreateStream(PKStream** ppStream);
   345  ERR PKCreateFactory_Release(PKFactory** ppFactory);
   346  
   347  EXTERN_C ERR PKCreateFactory(PKFactory**, U32);
   348  
   349  
   350  //================================================================
   351  typedef struct tagPKCodecFactory
   352  {
   353      ERR (*CreateCodec)(const PKIID*, void**);
   354      ERR (*CreateDecoderFromFile)(const char*, PKImageDecode**);
   355      ERR (*CreateFormatConverter)(PKFormatConverter**);
   356  
   357      ERR (*Release)(PKCodecFactory**);
   358  #ifdef __ANSI__
   359  #undef PKCodecFactory
   360  #endif // __ANSI__
   361  } PKCodecFactory;
   362  
   363  //----------------------------------------------------------------
   364  ERR PKCodecFactory_CreateCodec(const PKIID* iid, void** ppv);
   365  ERR PKCreateCodecFactory_Release(PKCodecFactory** ppCFactory);
   366  
   367  EXTERN_C ERR PKCreateCodecFactory(PKCodecFactory**, U32);
   368  
   369  //================================================================
   370  
   371  typedef enum BANDEDENCSTATE
   372  {
   373      BANDEDENCSTATE_UNINITIALIZED = 0,
   374      BANDEDENCSTATE_INIT,
   375      BANDEDENCSTATE_ENCODING,
   376      BANDEDENCSTATE_TERMINATED,
   377      BANDEDENCSTATE_NONBANDEDENCODE,
   378  } BANDEDENCSTATE;
   379  
   380  typedef struct tagPKImageEncode
   381  {
   382      //ERR (*GetPixelFormat)(MILPixelFormat*));
   383      ERR (*Initialize)(PKImageEncode*, struct WMPStream*, void*, size_t);
   384      ERR (*Terminate)(PKImageEncode*);
   385  
   386      ERR (*SetPixelFormat)(PKImageEncode*, PKPixelFormatGUID);
   387      ERR (*SetSize)(PKImageEncode*, I32, I32);
   388      ERR (*SetResolution)(PKImageEncode*, Float, Float);
   389      ERR (*SetColorContext)(PKImageEncode *pIE, const U8 *pbColorContext,
   390          U32 cbColorContext);
   391      ERR (*SetDescriptiveMetadata)(PKImageEncode *pIE,
   392          const DESCRIPTIVEMETADATA *pDescMetadata);
   393  
   394      ERR (*WritePixels)(PKImageEncode*, U32, U8*, U32);
   395      ERR (*WriteSource)(PKImageEncode*, PKFormatConverter*, PKRect*);
   396  
   397      // Banded encode API - currently only implemented for WMP encoder
   398      ERR (*WritePixelsBandedBegin)(PKImageEncode* pEncoder, struct WMPStream *pPlanarAlphaTempFile);
   399      ERR (*WritePixelsBanded)(PKImageEncode* pEncoder, U32 cLines, U8* pbPixels, U32 cbStride, Bool fLastCall);
   400      ERR (*WritePixelsBandedEnd)(PKImageEncode* pEncoder);
   401  #define TEMPFILE_COPYBUF_SIZE 8192  // Means when using tempfile for planar alpha banded encode, copy this many bytes at a time
   402  
   403      ERR (*Transcode)(PKImageEncode*, PKImageDecode*, CWMTranscodingParam*);
   404  
   405      ERR (*CreateNewFrame)(PKImageEncode*, void*, size_t);
   406  
   407      ERR (*Release)(PKImageEncode**);
   408  
   409      struct WMPStream* pStream;
   410      size_t offStart;
   411  
   412      PKPixelFormatGUID guidPixFormat;
   413  
   414      U32 uWidth;
   415      U32 uHeight;
   416      U32 idxCurrentLine;
   417  
   418      Float fResX;
   419      Float fResY;
   420  
   421      U32 cFrame;
   422  
   423      Bool fHeaderDone;
   424      size_t offPixel;
   425      size_t cbPixel;
   426      U8 *pbColorContext;
   427      U32 cbColorContext;
   428      U8 *pbEXIFMetadata;
   429      U32 cbEXIFMetadataByteCount;
   430      U8 *pbGPSInfoMetadata;
   431      U32 cbGPSInfoMetadataByteCount;
   432      U8 *pbIPTCNAAMetadata;
   433      U32 cbIPTCNAAMetadataByteCount;
   434      U8 *pbXMPMetadata;
   435      U32 cbXMPMetadataByteCount;
   436      U8 *pbPhotoshopMetadata;
   437      U32 cbPhotoshopMetadataByteCount;
   438      DESCRIPTIVEMETADATA sDescMetadata;
   439  
   440  	Bool bWMP;//for the encoder in decoding
   441  
   442      struct
   443      {
   444          WmpDEMisc wmiDEMisc;
   445          CWMImageInfo wmiI;
   446          CWMIStrCodecParam wmiSCP;
   447          CTXSTRCODEC ctxSC;
   448          CWMImageInfo wmiI_Alpha;
   449          CWMIStrCodecParam wmiSCP_Alpha;
   450          CTXSTRCODEC ctxSC_Alpha;
   451  
   452          Bool bHasAlpha;
   453          Long nOffImage;
   454          Long nCbImage;
   455          Long nOffAlpha;
   456          Long nCbAlpha;
   457  
   458          ORIENTATION oOrientation;
   459  
   460          // Banded encode state variables
   461          BANDEDENCSTATE      eBandedEncState;
   462          struct WMPStream   *pPATempFile;
   463      } WMP;
   464  
   465  #ifdef __ANSI__
   466  #undef PKImageEncode
   467  #endif // __ANSI__
   468  } PKImageEncode;
   469  
   470  //----------------------------------------------------------------
   471  ERR PKImageEncode_Create_WMP(PKImageEncode** ppIE);
   472  
   473  ERR PKImageEncode_Initialize(PKImageEncode* pIE, struct WMPStream* pStream, void* pvParam, size_t cbParam);
   474  ERR PKImageEncode_Terminate(PKImageEncode* pIE);
   475  ERR PKImageEncode_SetPixelFormat(PKImageEncode* pIE, PKPixelFormatGUID enPixelFormat);
   476  ERR PKImageEncode_SetSize(PKImageEncode* pIE, I32 iWidth, I32 iHeight);
   477  ERR PKImageEncode_SetResolution(PKImageEncode* pIE, Float rX, Float rY);
   478  ERR PKImageEncode_SetColorContext(PKImageEncode *pIE, const U8 *pbColorContext, U32 cbColorContext);
   479  ERR PKImageEncode_SetDescriptiveMetadata(PKImageEncode *pIE, const DESCRIPTIVEMETADATA *pDescMetadata);
   480  ERR PKImageEncode_WritePixels(PKImageEncode* pIE, U32 cLine, U8* pbPixel, U32 cbStride);
   481  ERR PKImageEncode_CreateNewFrame(PKImageEncode* pIE, void* pvParam, size_t cbParam);
   482  ERR PKImageEncode_Release(PKImageEncode** ppIE);
   483  
   484  ERR PKImageEncode_SetXMPMetadata_WMP(PKImageEncode *pIE, const U8 *pbXMPMetadata, U32 cbXMPMetadata);
   485  ERR PKImageEncode_SetEXIFMetadata_WMP(PKImageEncode *pIE, const U8 *pbEXIFMetadata, U32 cbEXIFMetadata);
   486  ERR PKImageEncode_SetGPSInfoMetadata_WMP(PKImageEncode *pIE, const U8 *pbGPSInfoMetadata, U32 cbGPSInfoMetadata);
   487  ERR PKImageEncode_SetIPTCNAAMetadata_WMP(PKImageEncode *pIE, const U8 *pbIPTCNAAMetadata, U32 cbIPTCNAAMetadata);
   488  ERR PKImageEncode_SetPhotoshopMetadata_WMP(PKImageEncode *pIE, const U8 *pbPhotoshopMetadata, U32 cbPhotoshopMetadata);
   489  
   490  void FreeDescMetadata(DPKPROPVARIANT *pvar);
   491  
   492  ERR PKImageEncode_Create(PKImageEncode** ppIE);
   493  
   494  //================================================================
   495  typedef struct tagPKImageDecode
   496  {
   497      ERR (*Initialize)(PKImageDecode*, struct WMPStream* pStream);
   498  
   499      ERR (*GetPixelFormat)(PKImageDecode*, PKPixelFormatGUID*);
   500      ERR (*GetSize)(PKImageDecode*, I32*, I32*);
   501      ERR (*GetResolution)(PKImageDecode*, Float*, Float*);
   502      ERR (*GetColorContext)(PKImageDecode *pID, U8 *pbColorContext,
   503          U32 *pcbColorContext);
   504      ERR (*GetDescriptiveMetadata)(PKImageDecode *pIE,
   505          DESCRIPTIVEMETADATA *pDescMetadata);
   506  
   507      ERR (*GetRawStream)(PKImageDecode*, struct WMPStream**);
   508  
   509      ERR (*Copy)(PKImageDecode*, const PKRect*, U8*, U32);
   510  
   511      ERR (*GetFrameCount)(PKImageDecode*, U32*);
   512      ERR (*SelectFrame)(PKImageDecode*, U32);
   513  
   514      ERR (*Release)(PKImageDecode**);
   515  
   516      struct WMPStream* pStream;
   517      Bool fStreamOwner;
   518      size_t offStart;
   519      
   520      PKPixelFormatGUID guidPixFormat;
   521  
   522      U32 uWidth;
   523      U32 uHeight;
   524      U32 idxCurrentLine;
   525  
   526      Float fResX;
   527      Float fResY;
   528  
   529      U32 cFrame;
   530  
   531      struct
   532      {
   533          WmpDEMisc wmiDEMisc;
   534          CWMImageInfo wmiI;
   535          CWMIStrCodecParam wmiSCP;
   536          CTXSTRCODEC ctxSC;
   537          CWMImageInfo wmiI_Alpha;
   538          CWMIStrCodecParam wmiSCP_Alpha;
   539          CTXSTRCODEC ctxSC_Alpha;
   540  
   541          Bool bHasAlpha;
   542          Long nOffImage;
   543          Long nCbImage;
   544          Long nOffAlpha;
   545          Long nCbAlpha;
   546          Bool bIgnoreOverlap;
   547          size_t DecoderCurrMBRow;
   548          size_t DecoderCurrAlphaMBRow;
   549          size_t cMarker;
   550          size_t cLinesDecoded;
   551          size_t cLinesCropped; // Lines may be cropped from the top - buffer for subsequent decodes must be adjusted
   552          Bool fFirstNonZeroDecode;
   553  
   554          Bool fOrientationFromContainer;
   555          ORIENTATION oOrientationFromContainer; // Tag 0xBC02 in HD Photo container
   556              
   557          DESCRIPTIVEMETADATA sDescMetadata;
   558      } WMP;
   559  
   560  #ifdef __ANSI__
   561  #undef PKImageDecode
   562  #endif // __ANSI__
   563  } PKImageDecode;
   564  
   565  //----------------------------------------------------------------
   566  ERR PKImageDecode_Create_WMP(PKImageDecode** ppID);
   567  
   568  ERR PKImageDecode_Initialize(PKImageDecode* pID, struct WMPStream* pStream);
   569  ERR PKImageDecode_GetPixelFormat(PKImageDecode* pID, PKPixelFormatGUID* pPF);
   570  ERR PKImageDecode_GetSize(PKImageDecode* pID, I32* piWidth, I32* piHeight);
   571  ERR PKImageDecode_GetResolution(PKImageDecode* pID, Float* pfrX, Float* pfrY);
   572  ERR PKImageDecode_GetColorContext(PKImageDecode *pID, U8 *pbColorContext, U32 *pcbColorContext);
   573  ERR PKImageDecode_GetDescriptiveMetadata(PKImageDecode *pID, DESCRIPTIVEMETADATA *pDescMetadata);
   574  ERR PKImageDecode_Copy(PKImageDecode* pID, const PKRect* pRect, U8* pb, U32 cbStride);
   575  ERR PKImageDecode_GetFrameCount(PKImageDecode* pID, U32* puCount);
   576  ERR PKImageDecode_SelectFrame(PKImageDecode* pID, U32 uFrame);
   577  ERR PKImageDecode_Release(PKImageDecode** ppID);
   578  
   579  ERR PKImageDecode_Create(PKImageDecode** ppID);
   580  ERR PKCodecFactory_CreateDecoderFromFile(const char* szFilename, PKImageDecode** ppDecoder);
   581  
   582  //================================================================
   583  typedef struct tagPKFormatConverter
   584  {
   585      ERR (*Initialize)(PKFormatConverter*, PKImageDecode*, char *pExt, PKPixelFormatGUID);
   586      ERR (*InitializeConvert)(PKFormatConverter* pFC, const PKPixelFormatGUID enPFFrom,
   587                               char *pExt, PKPixelFormatGUID enPFTTo);
   588  
   589      ERR (*GetPixelFormat)(PKFormatConverter*, PKPixelFormatGUID*);
   590      ERR (*GetSourcePixelFormat)(PKFormatConverter*, PKPixelFormatGUID*);
   591      ERR (*GetSize)(PKFormatConverter*, I32*, I32*);
   592      ERR (*GetResolution)(PKFormatConverter*, Float*, Float*);
   593  
   594      ERR (*Copy)(PKFormatConverter*, const PKRect*, U8*, U32);
   595      ERR (*Convert)(PKFormatConverter*, const PKRect*, U8*, U32);
   596  
   597      ERR (*Release)(PKFormatConverter**);
   598  
   599      PKImageDecode* pDecoder;
   600      PKPixelFormatGUID enPixelFormat;
   601  #ifdef __ANSI__
   602  #undef PKFormatConverter
   603  #endif // __ANSI__
   604  } PKFormatConverter;
   605  
   606  //----------------------------------------------------------------
   607  ERR PKImageEncode_Transcode(PKImageEncode* pIE, PKFormatConverter* pFC, PKRect* pRect);
   608  ERR PKImageEncode_WriteSource(PKImageEncode* pIE, PKFormatConverter* pFC, PKRect* pRect);
   609  ERR PKFormatConverter_Initialize(PKFormatConverter* pFC, PKImageDecode* pID, char *pExt, PKPixelFormatGUID enPF);
   610  ERR PKFormatConverter_InitializeConvert(PKFormatConverter* pFC, const PKPixelFormatGUID enPFFrom,
   611                                          char *pExt, PKPixelFormatGUID enPFTo);
   612  ERR PKFormatConverter_GetPixelFormat(PKFormatConverter* pFC, PKPixelFormatGUID* pPF);
   613  ERR PKFormatConverter_GetSourcePixelFormat(PKFormatConverter* pFC, PKPixelFormatGUID* pPF);
   614  ERR PKFormatConverter_GetSize(PKFormatConverter* pFC, I32* piWidth, I32* piHeight);
   615  ERR PKFormatConverter_GetResolution(PKFormatConverter* pFC, Float* pfrX, Float* pfrY);
   616  ERR PKFormatConverter_Copy(PKFormatConverter* pFC, const PKRect* pRect, U8* pb, U32 cbStride);
   617  ERR PKFormatConverter_Convert(PKFormatConverter* pFC, const PKRect* pRect, U8* pb, U32 cbStride);
   618  ERR PKFormatConverter_Release(PKFormatConverter** ppFC);
   619  
   620  // Think of this as static member of PKFormatConverter "class"
   621  ERR PKFormatConverter_EnumConversions(const PKPixelFormatGUID *pguidSourcePF,
   622                                        const U32 iIndex,
   623                                        const PKPixelFormatGUID **ppguidTargetPF);
   624  
   625  ERR PKCodecFactory_CreateFormatConverter(PKFormatConverter** ppFConverter);
   626  
   627  //----------------------------------------------------------------
   628  ERR PKAlloc(void** ppv, size_t cb);
   629  ERR PKFree(void** ppv);
   630  ERR PKAllocAligned(void** ppv, size_t cb, size_t iAlign);
   631  ERR PKFreeAligned(void** ppv);
   632  
   633  #ifdef __cplusplus
   634  } // extern "C"
   635  #endif
   636