-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmaker_minolta.c
1610 lines (1559 loc) · 69.5 KB
/
maker_minolta.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
/* EXIFPROBE - TIFF/JPEG/EXIF image file probe */
/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
/* Copyright (C) 2002,2005 by Duane H. Hesser. All rights reserved. */
/* */
/* See the file LICENSE.EXIFPROBE for terms of use. */
/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
#ifndef lint
static char *ModuleId = "@(#) $Id: maker_minolta.c,v 1.28 2005/07/24 21:57:28 alex Exp $";
#endif
/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
/* minolta camera maker-specific routines */
/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
/* Most of the information used here is due to Dalibor Jelinek at: */
/* http://www.dalibor.cz/minolta/makernote.htm */
/* */
/* The F100 and "X" models *appear* to use the same MakerNote tagset */
/* as used for Sanyo models, as decoded by John Hawkins */
/* http://www.exif.org/makernotes/SanyoMakerNote.html */
/* */
/* NOTE that this is guesswork. Test images I have found for these */
/* models appear to decode properly using the tag numbers from */
/* Hawkinn's Sanyo data. Send mail if you can confirm or deny. */
/* */
/* The EX model MakerNote format is indecipherable. */
/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include "defs.h"
#include "datadefs.h"
#include "maker_datadefs.h"
#include "summary.h"
#include "maker.h"
#include "misc.h"
#include "tags.h"
#include "maker_extern.h"
#include "extern.h"
extern struct camera_id minolta_model_id[];
/* Find the identifying number assigned to known Minolta camera */
/* models, and record the noteversion and tagset assigned to that */
/* model. The noteversion is used to dispatch print and interpret */
/* routines approopriate to the current image. */
int
minolta_model_number(char *model,char *software)
{
struct camera_id *model_id;
int number = NO_MODEL;
for(model_id = &minolta_model_id[0]; model_id && model_id->name; ++model_id)
{
if(strncasecmp(model,model_id->name,model_id->namelen) == 0)
{
number = model_id->id;
setnoteversion(model_id->noteversion);
setnotetagset(model_id->notetagset); /* info only */
break;
}
}
return(number);
}
/* Dispatch a print routine based upon the noteversion which has been */
/* assigned. */
void
print_minolta_makervalue(struct ifd_entry *entry_ptr,int make, int model,
char *prefix)
{
int noteversion = 0;
noteversion = getnoteversion();
if(entry_ptr && (PRINT_VALUE))
{
switch(noteversion)
{
case 1:
print_minolta1_makervalue(entry_ptr,make,model,prefix);
minolta1_interpret_value(entry_ptr,model);
break;
default:
print_value(entry_ptr,PREFIX);
break;
}
}
}
/* Maker-specific print routine for minolta cameras. This routine is */
/* responsible for picking off any direct entry tags which are */
/* peculiar and might not be handled properly by print_value() */
/* (usually UNDEFINED values which fit in the 4-byte entry value). If */
/* there are no such entries, this function simply calls */
/* print_value(). */
void
print_minolta1_makervalue(struct ifd_entry *entry_ptr,int make, int model,
char *prefix)
{
int chpr = 0;
if(entry_ptr && (PRINT_VALUE))
{
switch(entry_ptr->tag)
{
case 0x0040: /* ImageByteSize */
chpr += printf("%lu ",entry_ptr->value);
if(entry_ptr->count > 1)
{
printred("# BAD COUNT");
setcharsprinted(chpr);
}
break;
default:
print_value(entry_ptr,PREFIX);
break;
}
}
}
/* Dispatch a routine to decode and print offset values for minolta */
/* cameras. */
void
print_minolta_offset_makervalue(FILE *inptr,unsigned short byteorder,
struct ifd_entry *entry_ptr,unsigned long fileoffset_base,
struct image_summary *summary_entry,char *parent_name,char*prefix,
int indent,int make,int model,int at_offset)
{
int noteversion = 0;
if(entry_ptr)
{
noteversion = getnoteversion();
switch(noteversion)
{
case 1:
minolta1_offset_makervalue(inptr,byteorder,entry_ptr,
fileoffset_base,summary_entry,
parent_name,prefix,indent,
make,model,at_offset);
minolta1_interpret_offset_makervalue(inptr,byteorder,entry_ptr,
fileoffset_base);
break;
default:
print_generic_offset_makervalue(inptr,byteorder,entry_ptr,
fileoffset_base,parent_name,prefix,indent,
make,model,at_offset);
break;
}
}
}
/* Maker-specific routine to print UNDEFINED values found at offsets */
/* in minolta makernotes. One of these may be supplied for each model */
/* with unique UNDEFINED tags. */
void
minolta1_offset_makervalue(FILE *inptr,unsigned short byteorder,
struct ifd_entry *entry_ptr,unsigned long fileoffset_base,
struct image_summary *summary_entry,char *parent_name,char*prefix,
int indent,int make,int model,int at_offset)
{
static unsigned long jpegthumbnailoffset = 0UL;
unsigned long value_offset;
unsigned long dumplength;
unsigned long count;
unsigned long max_offset = 0;
unsigned short marker;
char *nameoftag,*tagprefix;
char *fulldirname = NULL;
int status = 0;
int chpr = 0;
if(entry_ptr)
{
nameoftag = maker_tagname(entry_ptr->tag,make,model);
fulldirname = splice(parent_name,".",nameoftag);
value_offset = fileoffset_base + entry_ptr->value;
count = entry_ptr->count;
switch(entry_ptr->tag)
{
case 0x0001: /* Camera Settings, old */
case 0x0003: /* Camera Settings, new */
if(at_offset)
{
if((PRINT_SECTION))
{
print_tag_address(SECTION,value_offset,indent,prefix);
chpr += printf("<%s> ",nameoftag);
chpr += printf("%lu entries",count / 4);
}
}
else if(!at_offset && (PRINT_VALUE))
{
if(!(PRINT_OFFSET))
chpr += printf("@%lu",value_offset);
}
if((PRINT_LONGNAMES))
tagprefix = fulldirname;
else
tagprefix = nameoftag;
max_offset = minolta_camerasetting(inptr,byteorder,model,tagprefix,
entry_ptr,value_offset,indent + MEDIUMINDENT);
if(PRINT_SECTION)
{
chpr = newline(0);
print_tag_address(SECTION,max_offset - 1,indent,prefix);
chpr += printf("</%s> ",nameoftag);
}
setcharsprinted(chpr);
break;
case 0x0040: /* ImageByteSize */
break; /* should have a count of 1 */
case 0x0088: /* JpegThumbnailOffset */
/* It's not magic, there's a trick to it. The offset */
/* length will normally be the next entry tag in the */
/* IFD, and this will work iff it is. Remember the */
/* offset and handle it when the length tag is seen. */
/* This is necessary because we do not save entries. */
jpegthumbnailoffset = value_offset;
if(!at_offset && (PRINT_VALUE))
{
if(!(PRINT_OFFSET))
chpr += printf("@%lu",jpegthumbnailoffset);
}
break;
case 0x0089: /* JpegThumbnailLength */
if(jpegthumbnailoffset == 0UL)
{
printred("# WARNING: JpegThumbnailLength encountered with 0 offset");
break; /* must have the offset. */
}
value_offset = jpegthumbnailoffset;
count = entry_ptr->value;
jpegthumbnailoffset = 0L;
/* fall through */
case 0x0081: /* Jpeg Thumbnail */
/* Minolta seems to use EITHER 0x0088/0x0089 OR */
/* 0x0081, not both. */
if(at_offset && (PRINT_SECTION))
{
print_tag_address(VALUE_AT_OFFSET,value_offset,indent,
prefix);
chpr += printf("# Start of JPEG Thumbnail from MakerNote");
chpr += printf(" length %lu",count);
}
else if(!at_offset && (PRINT_VALUE) && (entry_ptr->tag == 0x0081))
{
if(!(PRINT_OFFSET))
chpr += printf("@%lu:%lu",value_offset,count);
else
chpr = printf(":%lu",count);
if(!(PRINT_VALUE_AT_OFFSET))
chpr += printf(" # UNDEFINED");
}
if((PRINT_SECTION) || (PRINT_SEGMENT))
chpr = newline(chpr);
marker = read_ushort(inptr,TIFF_MOTOROLA,value_offset);
max_offset = process_jpeg_segments(inptr,value_offset,marker,
count,summary_entry,fulldirname,
prefix,indent+SMALLINDENT);
if(at_offset)
{
if((PRINT_SECTION))
{
if((status = jpeg_status(0) == JPEG_EARLY_EOI))
chpr = newline(chpr);
jpeg_status(status);
print_tag_address(VALUE_AT_OFFSET,value_offset + count - 1,
indent,"-");
chpr += printf("# End of JPEG Thumbnail from MakerNote");
if((PRINT_ENTRY) && !(PRINT_VALUE))
chpr = newline(chpr);
}
}
print_jpeg_status();
if(marker && summary_entry)
{
/* The new one is on the end of the chain */
if((summary_entry = last_summary_entry(summary_entry)))
{
summary_entry->filesubformat |= FILESUBFMT_MNOTE;
summary_entry->datatype = MAKER_IFD;
summary_entry->subfiletype = THUMBNAIL_TYPE;
}
}
/* make certain we're at the end */
clearerr(inptr);
fseek(inptr,value_offset + count,SEEK_SET);
break;
case 0x0e00: /* PrintIM */
if(!at_offset && (PRINT_VALUE))
{
if(!(PRINT_OFFSET))
{
chpr += printf("@%lu:%lu",value_offset,count);
chpr = newline(chpr);
}
}
process_pim(inptr,byteorder,entry_ptr->value,fileoffset_base,
count,nameoftag,parent_name,prefix,indent);
break;
case 0x0f00: /* Data */
if(at_offset && (PRINT_ENTRY))
{
print_tag_address(ENTRY,value_offset,indent,prefix);
print_makertagid(entry_ptr,23," : ",make,model);
chpr += printf(" length %-9lu", count);
if(Max_undefined == 0)
{
if(chpr)
printred(" (not dumped, use -U)");
}
else
{
if((Max_undefined == DUMPALL) || (Max_undefined > count))
dumplength = count;
else
dumplength = Max_undefined;
chpr = newline(chpr);
hexdump(inptr,value_offset,count,dumplength,12,
indent,SUBINDENT);
chpr = newline(1);
}
}
else if(!at_offset && (PRINT_VALUE))
{
if(!(PRINT_OFFSET))
chpr += printf("@%lu:%lu",value_offset,count);
else
chpr += printf(":%lu", count);
if(!(PRINT_VALUE_AT_OFFSET))
chpr += printf(" # UNDEFINED");
}
/* make certain we're at the end */
fseek(inptr,value_offset + count,SEEK_SET);
break;
default:
print_generic_offset_makervalue(inptr,byteorder,entry_ptr,
fileoffset_base,fulldirname,prefix,indent,
make,model,at_offset);
break;
}
if(fulldirname)
free(fulldirname);
}
setcharsprinted(chpr);
}
/* Minolta-specific tagnames for makernotes. */
/* Minolta models sport at least 9 different MakerNote tagsets that I */
/* have seen. However, the various tagsets do not overlap (if a given */
/* tag number is used in more than 1 model, it is assigned the same */
/* meaning everywhere). This makes it possible to use a single */
/* routine for tagnames, values, interpretations, etc. */
char *
maker_minolta_tagname(unsigned short tag,int model)
{
char *tagname = (char *)0;
int noteversion = 0;
/* Should have to do this only once, and only for unrecognized */
/* models. If the model is recognized (or the user has forced a */
/* noteversion) noteversion will already be set. */
if((noteversion = getnoteversion()) == 0)
{
noteversion = 1;
setnoteversion(1);
}
switch(noteversion)
{
case 1:
tagname = maker_minolta1_tagname(tag,model);
break;
default:
break;
}
/* If no model-specific tag is found, check "generic" tags */
if(tagname == NULL)
{
switch(tag)
{
case 0x0e00: tagname = "PrintIM"; break;
default: break;
}
}
return(tagname);
}
/* Although several versions of Minolta MakerNotes have been seen in */
/* the wild, there appears to be no duplication of tag numbers (i.e. */
/* no tag number is used for different purposes in one note version */
/* than in another vesion. This makes it possible to treat the notes */
/* as a single version. */
/* For now... */
char *
maker_minolta1_tagname(unsigned short tag,int model)
{
char *tagname = CNULL;
/* The Minolta MakerNote of TIFF format images have a JPEG */
/* thumbnail with a defective SOI marker (0x00f8). In fact, */
/* Minolta JPEG_SOI is often missing the high "0xff". */
if(tagname == NULL)
{
switch(tag)
{
case 0x0000: tagname = "Version"; break;
case 0x0001: tagname = "CameraSettings"; break;
case 0x0003: tagname = "CameraSettings"; break;
case 0x0040: tagname = "ImageByteSize"; break;
case 0x0081: tagname = "JpegThumbnail"; break;
case 0x0088: tagname = "JpegThumbnailOffset"; break;
case 0x0089: tagname = "JpegThumbnailLength"; break;
case 0x0101: tagname = "ColorMode"; break;
case 0x0102: tagname = "ImageQuality"; break;
case 0x0103: if(model == MINOLTA_DIMAGE7Hi)
tagname = "ImageQuality";
else
tagname = "ImageSize";
break;
/* The following tagname appears valid for at least the */
/* F200, thanks to Harald Puhl ([email protected]) */
case 0x0104: tagname = "FlashCompensation"; break;
case 0x0200: tagname = "SpecialMode"; break;
/* The following tag names appear valid for the F100 and "X" but */
/* do not appear to be used for any other Minolta model. They are */
/* essentially the Sanyo tag set, used here based upon guesswork; */
/* some Minolta and Sanyo cameras are said to use the same chip, */
/* and some F100 and "X" images I've seen contain almost exactly */
/* this set of tags (as described by John Hawkins for Sanyo */
/* DSC-MZ2 notes). The Quality, Macro, SpecialMode and PrintIM */
/* tags are reasonably certain to be correct (they "decode" */
/* properly). The remaining names are less certain, and no */
/* attempt is made to decode them in minolta1_interpret_value()/ */
case 0x0201: tagname = "Quality"; break;
case 0x0202: tagname = "Macro"; break;
case 0x0204: tagname = "DigiZoom"; break;
case 0x0207: tagname = "SoftwareRelease"; break;
case 0x0208: tagname = "PictInfo"; break;
case 0x0209: tagname = "CameraID"; break;
case 0x020e: tagname = "SeqShotMethod"; break;
case 0x020f: tagname = "WideRange"; break;
case 0x0210: tagname = "ColorAdjMode"; break;
case 0x0213: tagname = "QuickShot"; break;
case 0x0214: tagname = "SelfTimer"; break;
case 0x0216: tagname = "VoiceMemo"; break;
case 0x0217: tagname = "RecordShutterRel"; break;
case 0x0218: tagname = "FlickerReduce"; break;
case 0x0219: tagname = "OpticalZoom"; break;
case 0x021b: tagname = "DigitalZoom"; break;
case 0x021d: tagname = "LightSourceSpecial"; break;
case 0x021e: tagname = "Resaved"; break;
case 0x021f: tagname = "SceneSelect"; break;
case 0x0223: tagname = "ManualFocusDist"; break; /* ###%%% not seen */
case 0x0224: tagname = "SeqShotIntvl"; break; /* ###%%% not seen */
case 0x0225: tagname = "FlashMode"; break; /* ###%%% not seen */
case 0x0e00: tagname = "PrintIM"; break;
case 0x0f00: tagname = "Data"; break;
default: break;
}
}
setnotetagset(1);
return(tagname);
}
void
minolta1_interpret_value(struct ifd_entry *entry_ptr,int model)
{
int chpr = 0;
if(entry_ptr && (PRINT_VALUE))
{
switch(entry_ptr->tag)
{
case 0x0101: /* ColorMode */
print_startvalue();
switch(entry_ptr->value)
{
case 0: chpr += printf("Natural"); break;
case 1: chpr += printf("Black/White*"); break;
case 2: chpr += printf("Vivid"); break;
case 3: chpr += printf("Solarize"); break;
case 4: chpr += printf("Adobe RGB"); break;
case 9: chpr += printf("unknown"); break;
case 132: chpr += printf("Adobe RGB Embedded Profile"); break;
default: printred("undefined"); break;
}
print_endvalue();
break;
case 0x0102: /* CameraSettings ImageQuality, 7, 7Hi, F300 */
minolta_7Hi_botch:
print_startvalue();
switch(entry_ptr->value)
{
/* ###%%% jpeg quality/compression? check this */
case 0: chpr += printf("Raw"); break;
case 1: chpr += printf("Uncompressed"); break; /* superfine, raw? tiff? */
case 2: chpr += printf("Fine(1/2)"); break;
case 3: chpr += printf("Normal(1/3)"); break; /* ###%%% */
case 4: chpr += printf("Economy(1/4)"); break; /* ###%%% */
case 5: chpr += printf("ExtraFine(1/1)"); break;
default: printred("undefined"); break;
}
print_endvalue();
break;
case 0x0103: /* CameraSettings ImageSize*, 7Hi, F300 */
/* The 7Hi appears to get this wrong, printing the same */
/* value for this as for 0x0102; the F300 seems to do it */
/* right. The ImageSize entry in "Camera Settings" */
/* appears correct in both cases. For the 7Hi, it would */
/* be wrong to report this as image size, so just don't */
/* do it. */
if(model == MINOLTA_DIMAGE7Hi)
goto minolta_7Hi_botch;
print_startvalue();
switch(entry_ptr->value)
{
case 1: chpr += printf("1600x1200"); break;
case 2: chpr += printf("unknown"); break; /* 1280x960? */
case 3: chpr += printf("640x480"); break;
case 4: chpr += printf("unknown"); break;
case 5: chpr += printf("2560x1920"); break;
case 6: chpr += printf("2272x1704"); break;
case 7: chpr += printf("2048x1536"); break;
case 13: chpr += printf("3264x2448"); break;
default: printred("undefined"); break;
}
print_endvalue();
break;
case 0x0201: /* Quality, X, F100 */
print_startvalue();
/* ###%%% jpeg quality/compression? check this, same as 0x0102? */
switch(entry_ptr->value)
{
case 0: chpr += printf("Raw*"); break;
case 1: chpr += printf("Economy(1/8)"); break;
case 2: chpr += printf("Normal(1/4)"); break;
case 3: chpr += printf("Fine(1/2)"); break;
case 4: chpr += printf("Uncompressed"); break;
default: printred("undefined"); break;
}
print_endvalue();
break;
case 0x0202: /* Macro */
print_startvalue();
switch(entry_ptr->value)
{
case 0: chpr += printf("Normal"); break;
case 1: chpr += printf("Macro"); break;
case 2: chpr += printf("View"); break;
default: printred("undefined"); break;
}
print_endvalue();
break;
default:
break;
}
}
setcharsprinted(chpr);
}
void
minolta1_interpret_offset_makervalue(FILE *inptr,unsigned short byteorder,
struct ifd_entry *entry_ptr,unsigned long fileoffset_base)
{
unsigned long offset,value;
int chpr = 0;
if(entry_ptr && (PRINT_VALUE))
{
offset = entry_ptr->value + fileoffset_base;
switch(entry_ptr->tag)
{
case 0x0200: /* SpecialMode */
value = read_ulong(inptr,byteorder,offset);
print_startvalue();
switch(value)
{
case 0: chpr += printf("Normal"); break;
case 1: chpr += printf("Unknown"); break;
case 2: chpr += printf("Fast"); break;
case 3: chpr += printf("Panorama,");
value = read_ulong(inptr,byteorder,HERE);
chpr += printf("#%lu,",value);
value = read_ulong(inptr,byteorder,HERE);
switch(value)
{
case 1: chpr += printf(" Left to Right"); break;
case 2: chpr += printf(" Right to Left"); break;
case 3: chpr += printf(" Bottom to Top"); break;
case 4: chpr += printf(" Top to Bottom"); break;
default: printred(" undefined"); break;
}
break;
default: printred("undefined"); break;
}
print_endvalue();
break;
default:
break;
}
}
setcharsprinted(chpr);
}
/* Interpret the "Camera Settings" tag data from Minolta MakerNotes. */
#include <math.h>
unsigned long
minolta_camerasetting(FILE *inptr,unsigned short byteorder,int model,
char *tagprefix,struct ifd_entry *entry_ptr,unsigned long offset,int indent)
{
unsigned long value,end_offset;
double fvalue;
int i,corr_i,entries;
signed char wcorr;
int chpr = 0;
end_offset = offset + entry_ptr->count;
if((PRINT_SECTION))
chpr += printf(" length %lu",entry_ptr->count);
if((PRINT_ENTRY))
{
entries = entry_ptr->count / 4;
for(i = 0; i < entries; ++i)
{
chpr = newline(chpr);
value = read_ulong(inptr,TIFF_MOTOROLA,offset);
print_tag_address(ENTRY,offset,indent,"@");
if((PRINT_TAGINFO))
chpr += printf("%s.",tagprefix);
offset += 4;
/* Very oddly new values are inserted after value 51. */
corr_i=i;
if((model != MINOLTA_DIMAGE7Hi) && (model != MINOLTA_DIMAGEA1))
{
if (i > 50)
corr_i++;
}
if((model != MINOLTA_DIMAGEA1) && (model != MINOLTA_DIMAGEA2) && (model != MINOLTA_DIMAGEA200))
{
if (i > 51)
corr_i++;
}
switch(corr_i)
{
case 0:
if((PRINT_TAGINFO))
chpr += printf("%02d:%-21.21s",i,"Unknown");
if((PRINT_VALUE))
chpr += printf(" = %lu",value);
break;
case 1:
if((PRINT_TAGINFO))
chpr += printf("%02d:%-21.21s",i,"ExposureMode");
if((PRINT_VALUE))
{
chpr += printf(" = %lu",value);
print_startvalue();
switch(value)
{
case 0: chpr += printf("Programmed Auto"); break;
case 1: chpr += printf("Aperture Priority Auto"); break;
case 2: chpr += printf("Shuttter Priority Auto"); break;
case 3: chpr += printf("Manual"); break;
default: printred("undefined"); break;
}
print_endvalue();
}
break;
case 2:
if((PRINT_TAGINFO))
chpr += printf("%02d:%-21.21s",i,"FlashMode");
if((PRINT_VALUE))
{
chpr += printf(" = %lu",value);
print_startvalue();
switch(value)
{
case 0: chpr += printf("Fill-Flash"); break;
case 1: chpr += printf("Red Eye Reduction"); break;
case 2: chpr += printf("Rear Flash Sync"); break;
case 3: chpr += printf("Wireless"); break;
default: printred("undefined"); break;
}
print_endvalue();
}
break;
case 3:
if((PRINT_TAGINFO))
chpr += printf("%02d:%-21.21s",i,"WhiteBalance");
if((PRINT_VALUE))
{
chpr += printf(" = %#lx",value);
print_startvalue();
if (value & 0x00ff0000)
{
/* New style white balance values */
switch(value >> 24)
{
case 0: printf("Auto"); break;
case 1: printf("Daylight"); break;
case 2: printf("Cloudy"); break;
case 3: printf("Incandescent"); break;
case 5: printf("Fluorescent"); break;
case 6: printf("Shadow"); break;
case 7: printf("Memory1"); break;
case 8: printf("Memory2"); break;
case 9: printf("Memory3"); break;
default: printred("unknown"); break;
}
wcorr = ((value & 0x00ffffff) >> 16) - 0x80;
switch(wcorr)
{
case 0: break;
default: printf(" %+hd", wcorr); break;
}
}
else
{
/* Old style white balance values */
switch(value)
{
case 0: chpr += printf("Auto"); break;
case 1: chpr += printf("Daylight"); break;
case 2: chpr += printf("Cloudy"); break;
case 3: chpr += printf("Incandescent"); break;
case 5: chpr += printf("Custom"); break;
case 7: chpr += printf("Fluorescent"); break;
case 8: chpr += printf("Fluorescent2"); break;
case 11: chpr += printf("Custom2"); break;
case 12: chpr += printf("Custom3"); break;
default: printred("unknown"); break;
}
}
print_endvalue();
}
break;
case 4:
if((PRINT_TAGINFO))
chpr += printf("%02d:%-21.21s",i,"ImageSize");
if((PRINT_VALUE))
{
chpr += printf(" = %lu",value);
print_startvalue();
switch(value)
{
/* ###%%% There should also be a */
/* 2080x1560 size, at least for the A1 */
case 0: switch(model)
{
case MINOLTA_DIMAGEA2:
chpr += printf("3264x2448");
break;
case MINOLTA_DIMAGES404:
case MINOLTA_DIMAGES414:
chpr += printf("2272x1704");
break;
case MINOLTA_DIMAGE5:
chpr += printf("2048x1536");
break;
case MINOLTA_DIMAGEA1:
case MINOLTA_DIMAGE7Hi:
case MINOLTA_DIMAGE7i:
default:
chpr += printf("2560x1920");
break;
}
break;
case 1: chpr += printf("1600x1200"); break;
case 2: chpr += printf("1280x960"); break;
case 3: chpr += printf("640x480"); break;
default: printred("undefined"); break;
}
print_endvalue();
}
break;
case 5:
if((PRINT_TAGINFO))
chpr += printf("%02d:%-21.21s",i,"ImageQuality");
if((PRINT_VALUE))
{
chpr += printf(" = %lu",value);
print_startvalue();
switch(value)
{
case 0: chpr += printf("RAW"); break;
case 1: chpr += printf("Super Fine"); break;
case 2: chpr += printf("Fine"); break;
case 3: chpr += printf("Standard"); break;
case 4: chpr += printf("Economy"); break;
case 5: chpr += printf("Extra Fine"); break;
default: printred("undefined"); break;
}
print_endvalue();
}
break;
case 6:
if((PRINT_TAGINFO))
chpr += printf("%02d:%-21.21s",i,"DriveMode");
if((PRINT_VALUE))
{
chpr += printf(" = %lu",value);
print_startvalue();
switch(value)
{
case 0: chpr += printf("Single"); break;
case 1: chpr += printf("Continuous"); break;
case 2: chpr += printf("Self Timer"); break;
case 4: chpr += printf("Bracketing"); break;
case 5: chpr += printf("Interval"); break;
case 6: chpr += printf("UHS Continuous"); break;
case 7: chpr += printf("HS Continuous"); break;
default: printred("undefined"); break;
}
print_endvalue();
}
break;
case 7:
if((PRINT_TAGINFO))
chpr += printf("%02d:%-21.21s",i,"MeteringMode");
if((PRINT_VALUE))
{
chpr += printf(" = %lu",value);
print_startvalue();
switch(value)
{
case 0: chpr += printf("Multi-Segment"); break;
case 1: chpr += printf("Center Weighted"); break;
case 2: chpr += printf("Spot"); break;
default: printred("undefined"); break;
}
print_endvalue();
}
break;
case 8:
if((PRINT_TAGINFO))
chpr += printf("%02d:%-21.21s",i,"CCDSentitivity");
if((PRINT_VALUE))
{
if(PRINT_RAW_VALUES)
chpr += printf(" = %lu",value);
fvalue = ((double)value/8.0) - 1.0;
chpr += printf(" = %.3g APEX",fvalue);
fvalue = pow(2.0,fvalue) * 3.125;
print_startvalue();
chpr += printf("%.3g ISO",fvalue);
print_endvalue();
}
break;
case 9:
if((PRINT_TAGINFO))
chpr += printf("%02d_%-21.21s",i,"ShutterSpeed");
if((PRINT_VALUE))
{
if(PRINT_RAW_VALUES)
chpr += printf(" = %lu",value);
if (value == 8)
fvalue = 30.0; /* Due to rounding error x=8 should be displayed as 30 sec. */
else
{
fvalue = ((double)value / 8.0) - 6.0;
chpr += printf(" = %.3g APEX",fvalue);
fvalue = pow(2.0,-fvalue);
}
print_startvalue();
chpr += printf("%.3g sec",fvalue);
print_endvalue();
}
break;
case 10:
if((PRINT_TAGINFO))
chpr += printf("%02d_%-21.21s",i,"Aperture");
if((PRINT_VALUE))
{
if(PRINT_RAW_VALUES)
chpr += printf(" = %lu",value);
fvalue = (double)value/8.0 - 1.0;
chpr += printf(" = %.3g APEX",fvalue);
fvalue = pow(2.0,fvalue/2.0);
print_startvalue();
chpr += printf("f%.2g",fvalue);
print_endvalue();
}
break;
case 11:
if((PRINT_TAGINFO))
chpr += printf("%02d_%-21.21s",i,"MacroMode");
if((PRINT_VALUE))
{
chpr += printf(" = %lu",value);
print_startvalue();
switch(value)
{
case 0: chpr += printf("On"); break;
case 1: chpr += printf("Off"); break;
default: printred("undefined"); break;
}
print_endvalue();
}
break;
case 12:
if((PRINT_TAGINFO))
chpr += printf("%02d_%-21.21s",i,"DigitalZoom");
if((PRINT_VALUE))
{
chpr += printf(" = %lu",value);
print_startvalue();
switch(value)
{
case 0: chpr += printf("Off"); break;
case 1: chpr += printf("Electronic"); break;
case 2: chpr += printf("2x"); break;
/* FIXME: http://www.dalibor.cz/minolta/makernote.htm says 2 */
case 0xffff: chpr += printf("2x"); break;
default: printred("Undefined"); break;
}
print_endvalue();
}
break;
case 13:
if((PRINT_TAGINFO))
chpr += printf("%02d_%-21.21s",i,"ExposureCompensation");
if((PRINT_VALUE))
{
chpr += printf(" = %lu",value);
print_startvalue();
chpr += printf("%g EV",(double)value/3.0 - 2);
print_endvalue();
}
break;
case 14:
if((PRINT_TAGINFO))
chpr += printf("%02d:%-21.21s",i,"BracketStep");
if((PRINT_VALUE))
{
chpr += printf(" = %lu",value);
print_startvalue();
switch(value)
{
case 0: chpr += printf("1/3"); break;
case 1: chpr += printf("2/3"); break;
case 2: chpr += printf("1"); break;
default: printred("undefined"); break;
}
print_endvalue();
}
break;
case 15:
if((PRINT_TAGINFO))
chpr += printf("%02d:%-21.21s",i,"Unknown");
if((PRINT_VALUE))
chpr += printf(" = %lu",value);
break;
case 16:
if((PRINT_TAGINFO))
/* FIXME: Values don't fit on A1 */
chpr += printf("%02d_%-21.21s",i,"IntervalLength");
if((PRINT_VALUE))
{
chpr += printf(" = %lu",value + 1);
chpr += printf(" minutes");
}
break;
case 17:
if((PRINT_TAGINFO))
chpr += printf("%02d:%-21.21s",i,"IntervalNumber");
if((PRINT_VALUE))
chpr += printf(" = %lu",value);
break;
case 18:
if((PRINT_TAGINFO))
chpr += printf("%02d:%-21.21s",i,"FocalLength");
if((PRINT_VALUE))
{
/* This value is not equal to FocalLength in public
EXIF as the public one is tweaked to get 7x zoom to