JXRMeta.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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. #include <windowsmediaphoto.h>
  30. #ifndef WIN32
  31. #include <wmspecstring.h>
  32. #endif
  33. #ifndef UNREFERENCED_PARAMETER
  34. #define UNREFERENCED_PARAMETER(P) { (P) = (P); }
  35. #endif
  36. //================================================================
  37. // Container
  38. //================================================================
  39. // Keep these in sort order so that we can easily confirm we are outputting tags in ascending order
  40. #define WMP_tagNull 0
  41. #define WMP_tagDocumentName 0x010d // Descriptive metadata tag
  42. #define WMP_tagImageDescription 0x010e // Descriptive metadata tag
  43. #define WMP_tagCameraMake 0x010f // Descriptive metadata tag
  44. #define WMP_tagCameraModel 0x0110 // Descriptive metadata tag
  45. #define WMP_tagPageName 0x011d // Descriptive metadata tag
  46. #define WMP_tagPageNumber 0x0129 // Descriptive metadata tag
  47. #define WMP_tagSoftware 0x0131 // Descriptive metadata tag
  48. #define WMP_tagDateTime 0x0132 // Descriptive metadata tag
  49. #define WMP_tagArtist 0x013b // Descriptive metadata tag
  50. #define WMP_tagHostComputer 0x013c // Descriptive metadata tag
  51. #define WMP_tagXMPMetadata 0x02bc
  52. #define WMP_tagRatingStars 0x4746 // Descriptive metadata tag
  53. #define WMP_tagRatingValue 0x4749 // Descriptive metadata tag
  54. #define WMP_tagCopyright 0x8298 // Descriptive metadata tag
  55. #define WMP_tagEXIFMetadata 0x8769
  56. #define WMP_tagGPSInfoMetadata 0x8825
  57. #define WMP_tagIPTCNAAMetadata 0x83bb
  58. #define WMP_tagPhotoshopMetadata 0x8649
  59. #define WMP_tagInteroperabilityIFD 0xa005
  60. #define WMP_tagIccProfile 0x8773 // Need to use same tag as TIFF!!
  61. #define WMP_tagCaption 0x9c9b // Descriptive metadata tag
  62. #define WMP_tagPixelFormat 0xbc01
  63. #define WMP_tagTransformation 0xbc02
  64. #define WMP_tagCompression 0xbc03
  65. #define WMP_tagImageType 0xbc04
  66. #define WMP_tagImageWidth 0xbc80
  67. #define WMP_tagImageHeight 0xbc81
  68. #define WMP_tagWidthResolution 0xbc82
  69. #define WMP_tagHeightResolution 0xbc83
  70. #define WMP_tagImageOffset 0xbcc0
  71. #define WMP_tagImageByteCount 0xbcc1
  72. #define WMP_tagAlphaOffset 0xbcc2
  73. #define WMP_tagAlphaByteCount 0xbcc3
  74. #define WMP_tagImageDataDiscard 0xbcc4
  75. #define WMP_tagAlphaDataDiscard 0xbcc5
  76. #define WMP_typBYTE 1
  77. #define WMP_typASCII 2
  78. #define WMP_typSHORT 3
  79. #define WMP_typLONG 4
  80. #define WMP_typRATIONAL 5
  81. #define WMP_typSBYTE 6
  82. #define WMP_typUNDEFINED 7
  83. #define WMP_typSSHORT 8
  84. #define WMP_typSLONG 9
  85. #define WMP_typSRATIONAL 10
  86. #define WMP_typFLOAT 11
  87. #define WMP_typDOUBLE 12
  88. #define WMP_valCompression 0xbc
  89. #define WMP_valWMPhotoID WMP_valCompression
  90. #ifdef WIN32
  91. #define __in_win
  92. #define __out_win
  93. #endif
  94. //================================================================
  95. typedef enum
  96. {
  97. DPKVT_EMPTY = 0,
  98. DPKVT_UI1 = 17,
  99. DPKVT_UI2 = 18,
  100. DPKVT_UI4 = 19,
  101. DPKVT_LPSTR = 30,
  102. DPKVT_LPWSTR = 31,
  103. DPKVT_BYREF = 0x4000,
  104. } DPKVARTYPE;
  105. typedef struct DPKPROPVARIANT
  106. {
  107. DPKVARTYPE vt;
  108. union
  109. {
  110. U8 bVal; // DPKVT_UI1
  111. U16 uiVal; // DPKVT_UI2
  112. U32 ulVal; // DPKVT_UI4
  113. char *pszVal; // DPKVT_LPSTR
  114. U16 *pwszVal; // DPKVT_LPWSTR
  115. U8 *pbVal; // DPKVT_BYREF | DPKVT_UI1
  116. } VT;
  117. } DPKPROPVARIANT;
  118. typedef struct DESCRIPTIVEMETADATA
  119. {
  120. DPKPROPVARIANT pvarImageDescription; // WMP_tagImageDescription
  121. DPKPROPVARIANT pvarCameraMake; // WMP_tagCameraMake
  122. DPKPROPVARIANT pvarCameraModel; // WMP_tagCameraModel
  123. DPKPROPVARIANT pvarSoftware; // WMP_tagSoftware
  124. DPKPROPVARIANT pvarDateTime; // WMP_tagDateTime
  125. DPKPROPVARIANT pvarArtist; // WMP_tagArtist
  126. DPKPROPVARIANT pvarCopyright; // WMP_tagCopyright
  127. DPKPROPVARIANT pvarRatingStars; // WMP_tagRatingStars
  128. DPKPROPVARIANT pvarRatingValue; // WMP_tagRatingValue
  129. DPKPROPVARIANT pvarCaption; // WMP_tagCaption
  130. DPKPROPVARIANT pvarDocumentName; // WMP_tagDocumentName
  131. DPKPROPVARIANT pvarPageName; // WMP_tagPageName
  132. DPKPROPVARIANT pvarPageNumber; // WMP_tagPageNumber
  133. DPKPROPVARIANT pvarHostComputer; // WMP_tagHostComputer
  134. } DESCRIPTIVEMETADATA;
  135. typedef struct tagWmpDE
  136. {
  137. U16 uTag;
  138. U16 uType;
  139. U32 uCount;
  140. U32 uValueOrOffset;
  141. } WmpDE;
  142. typedef struct tagWmpDEMisc
  143. {
  144. U32 uImageOffset;
  145. U32 uImageByteCount;
  146. U32 uAlphaOffset;
  147. U32 uAlphaByteCount;
  148. U32 uOffPixelFormat;
  149. U32 uOffImageByteCount;
  150. U32 uOffAlphaOffset;
  151. U32 uOffAlphaByteCount;
  152. U32 uColorProfileOffset;
  153. U32 uColorProfileByteCount;
  154. U32 uXMPMetadataOffset;
  155. U32 uXMPMetadataByteCount;
  156. U32 uEXIFMetadataOffset;
  157. U32 uEXIFMetadataByteCount;
  158. U32 uGPSInfoMetadataOffset;
  159. U32 uGPSInfoMetadataByteCount;
  160. U32 uIPTCNAAMetadataOffset;
  161. U32 uIPTCNAAMetadataByteCount;
  162. U32 uPhotoshopMetadataOffset;
  163. U32 uPhotoshopMetadataByteCount;
  164. U32 uDescMetadataOffset;
  165. U32 uDescMetadataByteCount;
  166. } WmpDEMisc;
  167. //================================================================
  168. EXTERN_C ERR GetUShort(
  169. __in_ecount(1) struct WMPStream* pWS,
  170. size_t offPos,
  171. __out_ecount(1) U16* puValue
  172. );
  173. EXTERN_C ERR PutUShort(
  174. __in_ecount(1) struct WMPStream* pWS,
  175. size_t offPos,
  176. U16 uValue
  177. );
  178. EXTERN_C ERR GetULong(
  179. __in_ecount(1) struct WMPStream* pWS,
  180. size_t offPos,
  181. __out_ecount(1) U32* puValue
  182. );
  183. EXTERN_C ERR PutULong(
  184. __in_ecount(1) struct WMPStream* pWS,
  185. size_t offPos,
  186. U32 uValue
  187. );
  188. EXTERN_C ERR WriteWmpDE(
  189. __in_ecount(1) struct WMPStream* pWS,
  190. size_t *pOffPos,
  191. const __in_ecount(1) WmpDE* pDE,
  192. const U8 *pbData,
  193. U32 *pcbDataWrittenToOffset
  194. );
  195. EXTERN_C ERR ReadPropvar(__in_ecount(1) struct WMPStream* pWS,
  196. const __in_win U16 uType,
  197. const __in_win U32 uCount,
  198. const __in_win U32 uValue,
  199. __out_win DPKPROPVARIANT *pvar);
  200. // read and write little endian words/dwords from a buffer on both big and little endian cpu's
  201. // with full buffer overflow checking
  202. #define WMP_INTEL_ENDIAN ('I')
  203. EXTERN_C ERR getbfcpy(U8* pbdest, const U8* pb, size_t cb, size_t ofs, U32 n);
  204. EXTERN_C ERR getbfw(const U8* pb, size_t cb, size_t ofs, U16* pw);
  205. EXTERN_C ERR getbfdw(const U8* pb, size_t cb, size_t ofs, U32* pdw);
  206. EXTERN_C ERR getbfwbig(const U8* pb, size_t cb, size_t ofs, U16* pw);
  207. EXTERN_C ERR getbfdwbig(const U8* pb, size_t cb, size_t ofs, U32* pdw);
  208. EXTERN_C ERR getbfwe(const U8* pb, size_t cb, size_t ofs, U16* pw, U8 endian);
  209. EXTERN_C ERR getbfdwe(const U8* pb, size_t cb, size_t ofs, U32* pdw, U8 endian);
  210. EXTERN_C ERR setbfcpy(U8* pb, size_t cb, size_t ofs, const U8* pbset, size_t cbset);
  211. EXTERN_C ERR setbfw(U8* pb, size_t cb, size_t ofs, U16 dw);
  212. EXTERN_C ERR setbfdw(U8* pb, size_t cb, size_t ofs, U32 dw);
  213. EXTERN_C ERR setbfwbig(U8* pb, size_t cb, size_t ofs, U16 dw);
  214. EXTERN_C ERR setbfdwbig(U8* pb, size_t cb, size_t ofs, U32 dw);
  215. EXTERN_C ERR BufferCalcIFDSize(const U8* pb, size_t cb, U32 uIFDOfs, U8 endian, U32 *pcbifd);
  216. EXTERN_C ERR StreamCalcIFDSize(struct WMPStream* pWS, U32 uIFDOfs, U32 *pcbifd);
  217. EXTERN_C ERR BufferCopyIFD(const U8* pbsrc, U32 cbsrc, U32 ofssrc, U8 endian, U8* pbdest, U32 cbdest, U32* pofsdest);
  218. EXTERN_C ERR StreamCopyIFD(struct WMPStream* pWS, U32 ofssrc, U8* pbdest, U32 cbdest, U32* pofsdest);