/exiftags/casio.c
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/* 36 * Exif tag definitions for Casio maker notes. 37 * 38 */ 39 40#include <stdio.h> 41#include <stdlib.h> 42#include <string.h> 43 44#include "makers.h" 45 46 47/* Recording mode. */ 48 49static struct descrip casio_record[] = { 50 { 1, "Single Shutter" }, 51 { 7, "Panorama" }, 52 { 10, "Night Scene" }, 53 { 15, "Portrait" }, 54 { 16, "Landscape" }, 55 { -1, "Unknown" }, 56}; 57 58 59/* Quality. */ 60 61static struct descrip casio_qual[] = { 62 { 1, "Economy" }, 63 { 2, "Normal" }, 64 { 3, "Fine" }, 65 { -1, "Unknown" }, 66}; 67 68 69/* Focus mode. */ 70 71static struct descrip casio_focus[] = { 72 { 2, "Macro" }, 73 { 3, "Auto" }, 74 { 4, "Manual" }, 75 { 5, "Infinity" }, 76 { -1, "Unknown" }, 77}; 78 79 80/* Flash mode. */ 81 82static struct descrip casio_flash[] = { 83 { 1, "Auto" }, 84 { 2, "On" }, 85 { 4, "Off" }, 86 { 5, "Red Eye Reduction" }, 87 { -1, "Unknown" }, 88}; 89 90 91/* Flash intensity. */ 92 93static struct descrip casio_intense[] = { 94 { 11, "Weak" }, 95 { 13, "Normal" }, 96 { 15, "Strong" }, 97 { -1, "Unknown" }, 98}; 99 100 101/* White balance. */ 102 103static struct descrip casio_whiteb[] = { 104 { 1, "Auto" }, 105 { 2, "Tungsten" }, 106 { 3, "Daylight" }, 107 { 4, "Fluorescent" }, 108 { 5, "Shade" }, 109 { 129, "Manual" }, 110 { -1, "Unknown" }, 111}; 112 113 114/* Sharpness. */ 115 116static struct descrip casio_sharp[] = { 117 { 0, "Normal" }, 118 { 1, "Soft" }, 119 { 2, "Hard" }, 120 { -1, "Unknown" }, 121}; 122 123 124/* Contrast & saturation. */ 125 126static struct descrip casio_range[] = { 127 { 0, "Normal" }, 128 { 1, "Low" }, 129 { 2, "High" }, 130 { -1, "Unknown" }, 131}; 132 133 134/* Sensitivity. */ 135 136static struct descrip casio_sensitive[] = { 137 { 64, "Normal" }, 138 { 80, "Normal" }, 139 { 100, "High" }, 140 { 125, "+1.0" }, 141 { 244, "+3.0" }, 142 { 250, "+2.0" }, 143 { -1, "Unknown" }, 144}; 145 146 147/* Maker note IFD tags. */ 148 149static struct exiftag casio_tags0[] = { 150 { 0x0001, TIFF_SHORT, 1, ED_IMG, "CasioRecord", 151 "Recording Mode", casio_record }, 152 { 0x0002, TIFF_SHORT, 1, ED_IMG, "CasioQuality", 153 "Quality Setting", casio_qual }, 154 { 0x0003, TIFF_SHORT, 1, ED_IMG, "CasioFocus", 155 "Focusing Mode", casio_focus }, 156 { 0x0004, TIFF_SHORT, 1, ED_IMG, "CasioFlash", 157 "Flash Mode", casio_flash }, 158 { 0x0005, TIFF_SHORT, 1, ED_IMG, "CasioIntensity", 159 "Flash Intensity", casio_intense }, 160 { 0x0006, TIFF_LONG, 1, ED_VRB, "CasioDistance", 161 "Object Distance", NULL }, 162 { 0x0007, TIFF_SHORT, 1, ED_IMG, "CasioWhiteB", 163 "White Balance", casio_whiteb }, 164 { 0x000a, TIFF_LONG, 1, ED_UNK, "CasioDZoom", 165 "Digital Zoom", NULL }, 166 { 0x000b, TIFF_SHORT, 1, ED_IMG, "CasioSharp", 167 "Sharpness", casio_sharp }, 168 { 0x000c, TIFF_SHORT, 1, ED_IMG, "CasioContrast", 169 "Contrast", casio_range }, 170 { 0x000d, TIFF_SHORT, 1, ED_IMG, "CasioSaturate", 171 "Saturation", casio_range }, 172 { 0x0014, TIFF_SHORT, 1, ED_IMG, "CasioSensitive", 173 "Sensitivity", casio_sensitive }, 174 { 0xffff, TIFF_UNKN, 0, ED_UNK, "CasioUnknown", 175 "Casio Unknown", NULL }, 176}; 177 178 179static struct exiftag casio_tags1[] = { 180 { 0x2001, TIFF_ASCII, 1, ED_UNK, "CasioASCII1", 181 "Casio ASCII Val 1", NULL }, 182 { 0x2002, TIFF_ASCII, 1, ED_UNK, "CasioASCII2", 183 "Casio ASCII Val 2", NULL }, 184 { 0x3006, TIFF_ASCII, 1, ED_UNK, "CasioASCII3", 185 "Casio ASCII Val 3", NULL }, 186 { 0xffff, TIFF_UNKN, 0, ED_UNK, "CasioUnknown", 187 "Casio Unknown", NULL }, 188}; 189 190 191/* 192 * Try to read a Casio maker note IFD. 193 */ 194struct ifd * 195casio_ifd(u_int32_t offset, struct tiffmeta *md) 196{ 197 struct ifd *myifd; 198 199 /* 200 * It appears that there are two different types of maker notes 201 * for Casio cameras: one, for older cameras, uses a standard IFD 202 * format; the other starts at offset + 6 ("QVC\0\0\0"). 203 */ 204 205 if (!memcmp("QVC\0\0\0", md->btiff + offset, 6)) { 206 readifd(offset + strlen("QVC") + 3, &myifd, casio_tags1, md); 207 exifwarn("Casio maker note version not supported"); 208 } else 209 readifd(offset, &myifd, casio_tags0, md); 210 211 return (myifd); 212}