/src/FreeImage/Source/LibRawLite/libraw/libraw_internal.h

https://bitbucket.org/cabalistic/ogredeps/ · C++ Header · 218 lines · 158 code · 40 blank · 20 comment · 14 complexity · f6bb770c69d585015687d587f6c8dacb MD5 · raw file

  1. /* -*- C++ -*-
  2. * File: libraw_internal.h
  3. * Copyright 2008-2010 LibRaw LLC (info@libraw.org)
  4. * Created: Sat Mar 8 , 2008
  5. *
  6. * LibRaw internal data structures (not visible outside)
  7. LibRaw is free software; you can redistribute it and/or modify
  8. it under the terms of the one of three licenses as you choose:
  9. 1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1
  10. (See file LICENSE.LGPL provided in LibRaw distribution archive for details).
  11. 2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
  12. (See file LICENSE.CDDL provided in LibRaw distribution archive for details).
  13. 3. LibRaw Software License 27032010
  14. (See file LICENSE.LibRaw.pdf provided in LibRaw distribution archive for details).
  15. */
  16. #ifndef _LIBRAW_INTERNAL_TYPES_H
  17. #define _LIBRAW_INTERNAL_TYPES_H
  18. #include <stdio.h>
  19. #ifdef __cplusplus
  20. #ifdef LIBRAW_LIBRARY_BUILD
  21. #ifndef CLASS
  22. #define CLASS LibRaw::
  23. #endif
  24. #endif
  25. #else
  26. #ifndef CLASS
  27. #define CLASS
  28. #endif
  29. #endif
  30. #ifdef __cplusplus
  31. #include "libraw_datastream.h"
  32. #include "libraw_types.h"
  33. class LibRaw_TLS
  34. {
  35. public:
  36. struct
  37. {
  38. unsigned bitbuf;
  39. int vbits, reset;
  40. }getbits;
  41. struct
  42. {
  43. UINT64 bitbuf;
  44. int vbits;
  45. }ph1_bits;
  46. struct
  47. {
  48. unsigned pad[128], p;
  49. }sony_decrypt;
  50. uchar jpeg_buffer[4096];
  51. struct
  52. {
  53. uchar buf[0x4000];
  54. int vbits, padding;
  55. }pana_bits;
  56. void init()
  57. {
  58. getbits.bitbuf = 0; getbits.vbits = getbits.reset = 0;
  59. ph1_bits.bitbuf = 0; ph1_bits.vbits = 0;
  60. pana_bits.vbits = 0;
  61. }
  62. };
  63. class LibRaw_constants
  64. {
  65. public:
  66. static const float d65_white[3];
  67. static const double xyz_rgb[3][3];
  68. };
  69. #endif /* __cplusplus */
  70. typedef struct
  71. {
  72. #ifndef __cplusplus
  73. struct
  74. #endif
  75. LibRaw_abstract_datastream *input;
  76. FILE *output;
  77. int input_internal;
  78. char *meta_data;
  79. INT64 profile_offset;
  80. INT64 toffset;
  81. } internal_data_t;
  82. #define LIBRAW_HISTOGRAM_SIZE 0x2000
  83. typedef struct
  84. {
  85. int (*histogram)[LIBRAW_HISTOGRAM_SIZE];
  86. unsigned *oprof;
  87. } output_data_t;
  88. typedef struct
  89. {
  90. unsigned olympus_exif_cfa;
  91. unsigned unique_id;
  92. unsigned tiff_nifds;
  93. int tiff_flip;
  94. }identify_data_t;
  95. typedef struct
  96. {
  97. short order;
  98. ushort sraw_mul[4],cr2_slice[3];
  99. unsigned kodak_cbpp;
  100. INT64 strip_offset, data_offset;
  101. INT64 meta_offset;
  102. unsigned data_size;
  103. unsigned meta_length;
  104. unsigned thumb_misc;
  105. unsigned fuji_layout;
  106. unsigned tiff_samples;
  107. unsigned tiff_bps;
  108. unsigned tiff_compress;
  109. unsigned zero_after_ff;
  110. unsigned tile_width, tile_length,load_flags;
  111. unsigned data_error;
  112. }unpacker_data_t;
  113. typedef struct
  114. {
  115. internal_data_t internal_data;
  116. libraw_internal_output_params_t internal_output_params;
  117. output_data_t output_data;
  118. identify_data_t identify_data;
  119. unpacker_data_t unpacker_data;
  120. } libraw_internal_data_t;
  121. struct decode
  122. {
  123. struct decode *branch[2];
  124. int leaf;
  125. };
  126. struct tiff_ifd_t
  127. {
  128. int t_width, t_height, bps, comp, phint, offset, t_flip, samples, bytes,tile_maxbytes;
  129. };
  130. struct jhead {
  131. int bits, high, wide, clrs, sraw, psv, restart, vpred[6];
  132. ushort *huff[6], *free[4], *row;
  133. };
  134. struct tiff_tag {
  135. ushort tag, type;
  136. int count;
  137. union { char c[4]; short s[2]; int i; } val;
  138. };
  139. struct tiff_hdr {
  140. ushort t_order, magic;
  141. int ifd;
  142. ushort pad, ntag;
  143. struct tiff_tag tag[23];
  144. int nextifd;
  145. ushort pad2, nexif;
  146. struct tiff_tag exif[4];
  147. ushort pad3, ngps;
  148. struct tiff_tag gpst[10];
  149. short bps[4];
  150. int rat[10];
  151. unsigned gps[26];
  152. char t_desc[512], t_make[64], t_model[64], soft[32], date[20], t_artist[64];
  153. };
  154. #ifdef DEBUG_STAGE_CHECKS
  155. #define CHECK_ORDER_HIGH(expected_stage) \
  156. do { if((imgdata.progress_flags & LIBRAW_PROGRESS_THUMB_MASK) >= expected_stage) {fprintf(stderr,"CHECK_HIGH: check %d >= %d\n",imgdata.progress_flags & LIBRAW_PROGRESS_THUMB_MASK,expected_stage);return LIBRAW_OUT_OF_ORDER_CALL;} } while(0)
  157. #define CHECK_ORDER_LOW(expected_stage) \
  158. do { printf("Checking LOW %d/%d : %d\n",imgdata.progress_flags,expected_stage,imgdata.progress_flags<expected_stage); if( (imgdata.progress_flags&LIBRAW_PROGRESS_THUMB_MASK) < expected_stage ) { printf("failed!\n"); return LIBRAW_OUT_OF_ORDER_CALL;} } while(0)
  159. #define CHECK_ORDER_BIT(expected_stage) \
  160. do { if(imgdata.progress_flags & expected_stage) return LIBRAW_OUT_OF_ORDER_CALL; } while(0)
  161. #define SET_PROC_FLAG(stage) do {imgdata.progress_flags |= stage; fprintf(stderr,"SET_FLAG: %d\n",stage); } while (0)
  162. #else
  163. #define CHECK_ORDER_HIGH(expected_stage) \
  164. do { if((imgdata.progress_flags & LIBRAW_PROGRESS_THUMB_MASK) >= expected_stage) \
  165. {return LIBRAW_OUT_OF_ORDER_CALL;} } while(0)
  166. #define CHECK_ORDER_LOW(expected_stage) \
  167. do { if((imgdata.progress_flags&LIBRAW_PROGRESS_THUMB_MASK) < expected_stage) \
  168. return LIBRAW_OUT_OF_ORDER_CALL; } while(0)
  169. #define CHECK_ORDER_BIT(expected_stage) \
  170. do { if(imgdata.progress_flags & expected_stage) return LIBRAW_OUT_OF_ORDER_CALL; } while(0)
  171. #define SET_PROC_FLAG(stage) do {imgdata.progress_flags |= stage;} while (0)
  172. #endif
  173. #endif