/exiftags/casio.c

https://code.google.com/p/xee/ · C · 212 lines · 117 code · 40 blank · 55 comment · 1 complexity · e9c8bdc3fa7d49fa7015fadd1bad1e2f MD5 · raw file

  1. /*
  2. * Copyright (c) 2002, 2003, Eric M. Johnston <emj@postal.net>
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. * 3. All advertising materials mentioning features or use of this software
  14. * must display the following acknowledgement:
  15. * This product includes software developed by Eric M. Johnston.
  16. * 4. Neither the name of the author nor the names of any co-contributors
  17. * may be used to endorse or promote products derived from this software
  18. * without specific prior written permission.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  21. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  23. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  24. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  25. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  26. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  27. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  28. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  29. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. * SUCH DAMAGE.
  31. *
  32. * $Id: casio.c,v 1.11 2003/08/06 02:26:42 ejohnst Exp $
  33. */
  34. /*
  35. * Exif tag definitions for Casio maker notes.
  36. *
  37. */
  38. #include <stdio.h>
  39. #include <stdlib.h>
  40. #include <string.h>
  41. #include "makers.h"
  42. /* Recording mode. */
  43. static struct descrip casio_record[] = {
  44. { 1, "Single Shutter" },
  45. { 7, "Panorama" },
  46. { 10, "Night Scene" },
  47. { 15, "Portrait" },
  48. { 16, "Landscape" },
  49. { -1, "Unknown" },
  50. };
  51. /* Quality. */
  52. static struct descrip casio_qual[] = {
  53. { 1, "Economy" },
  54. { 2, "Normal" },
  55. { 3, "Fine" },
  56. { -1, "Unknown" },
  57. };
  58. /* Focus mode. */
  59. static struct descrip casio_focus[] = {
  60. { 2, "Macro" },
  61. { 3, "Auto" },
  62. { 4, "Manual" },
  63. { 5, "Infinity" },
  64. { -1, "Unknown" },
  65. };
  66. /* Flash mode. */
  67. static struct descrip casio_flash[] = {
  68. { 1, "Auto" },
  69. { 2, "On" },
  70. { 4, "Off" },
  71. { 5, "Red Eye Reduction" },
  72. { -1, "Unknown" },
  73. };
  74. /* Flash intensity. */
  75. static struct descrip casio_intense[] = {
  76. { 11, "Weak" },
  77. { 13, "Normal" },
  78. { 15, "Strong" },
  79. { -1, "Unknown" },
  80. };
  81. /* White balance. */
  82. static struct descrip casio_whiteb[] = {
  83. { 1, "Auto" },
  84. { 2, "Tungsten" },
  85. { 3, "Daylight" },
  86. { 4, "Fluorescent" },
  87. { 5, "Shade" },
  88. { 129, "Manual" },
  89. { -1, "Unknown" },
  90. };
  91. /* Sharpness. */
  92. static struct descrip casio_sharp[] = {
  93. { 0, "Normal" },
  94. { 1, "Soft" },
  95. { 2, "Hard" },
  96. { -1, "Unknown" },
  97. };
  98. /* Contrast & saturation. */
  99. static struct descrip casio_range[] = {
  100. { 0, "Normal" },
  101. { 1, "Low" },
  102. { 2, "High" },
  103. { -1, "Unknown" },
  104. };
  105. /* Sensitivity. */
  106. static struct descrip casio_sensitive[] = {
  107. { 64, "Normal" },
  108. { 80, "Normal" },
  109. { 100, "High" },
  110. { 125, "+1.0" },
  111. { 244, "+3.0" },
  112. { 250, "+2.0" },
  113. { -1, "Unknown" },
  114. };
  115. /* Maker note IFD tags. */
  116. static struct exiftag casio_tags0[] = {
  117. { 0x0001, TIFF_SHORT, 1, ED_IMG, "CasioRecord",
  118. "Recording Mode", casio_record },
  119. { 0x0002, TIFF_SHORT, 1, ED_IMG, "CasioQuality",
  120. "Quality Setting", casio_qual },
  121. { 0x0003, TIFF_SHORT, 1, ED_IMG, "CasioFocus",
  122. "Focusing Mode", casio_focus },
  123. { 0x0004, TIFF_SHORT, 1, ED_IMG, "CasioFlash",
  124. "Flash Mode", casio_flash },
  125. { 0x0005, TIFF_SHORT, 1, ED_IMG, "CasioIntensity",
  126. "Flash Intensity", casio_intense },
  127. { 0x0006, TIFF_LONG, 1, ED_VRB, "CasioDistance",
  128. "Object Distance", NULL },
  129. { 0x0007, TIFF_SHORT, 1, ED_IMG, "CasioWhiteB",
  130. "White Balance", casio_whiteb },
  131. { 0x000a, TIFF_LONG, 1, ED_UNK, "CasioDZoom",
  132. "Digital Zoom", NULL },
  133. { 0x000b, TIFF_SHORT, 1, ED_IMG, "CasioSharp",
  134. "Sharpness", casio_sharp },
  135. { 0x000c, TIFF_SHORT, 1, ED_IMG, "CasioContrast",
  136. "Contrast", casio_range },
  137. { 0x000d, TIFF_SHORT, 1, ED_IMG, "CasioSaturate",
  138. "Saturation", casio_range },
  139. { 0x0014, TIFF_SHORT, 1, ED_IMG, "CasioSensitive",
  140. "Sensitivity", casio_sensitive },
  141. { 0xffff, TIFF_UNKN, 0, ED_UNK, "CasioUnknown",
  142. "Casio Unknown", NULL },
  143. };
  144. static struct exiftag casio_tags1[] = {
  145. { 0x2001, TIFF_ASCII, 1, ED_UNK, "CasioASCII1",
  146. "Casio ASCII Val 1", NULL },
  147. { 0x2002, TIFF_ASCII, 1, ED_UNK, "CasioASCII2",
  148. "Casio ASCII Val 2", NULL },
  149. { 0x3006, TIFF_ASCII, 1, ED_UNK, "CasioASCII3",
  150. "Casio ASCII Val 3", NULL },
  151. { 0xffff, TIFF_UNKN, 0, ED_UNK, "CasioUnknown",
  152. "Casio Unknown", NULL },
  153. };
  154. /*
  155. * Try to read a Casio maker note IFD.
  156. */
  157. struct ifd *
  158. casio_ifd(u_int32_t offset, struct tiffmeta *md)
  159. {
  160. struct ifd *myifd;
  161. /*
  162. * It appears that there are two different types of maker notes
  163. * for Casio cameras: one, for older cameras, uses a standard IFD
  164. * format; the other starts at offset + 6 ("QVC\0\0\0").
  165. */
  166. if (!memcmp("QVC\0\0\0", md->btiff + offset, 6)) {
  167. readifd(offset + strlen("QVC") + 3, &myifd, casio_tags1, md);
  168. exifwarn("Casio maker note version not supported");
  169. } else
  170. readifd(offset, &myifd, casio_tags0, md);
  171. return (myifd);
  172. }