- Timestamp:
- 2021-02-26T19:39:51+13:00 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/cpan/Image/ExifTool/MakerNotes.pm
r24107 r34921 18 18 sub ProcessCanon($$$); 19 19 sub ProcessGE2($$$); 20 sub ProcessKodakPatch($$$); 20 21 sub WriteUnknownOrPreview($$$); 21 22 sub FixLeicaBase($$;$); 22 23 23 $VERSION = ' 1.66';24 $VERSION = '2.10'; 24 25 25 26 my $debug; # set to 1 to enable debugging code … … 32 33 # - Put these in alphabetical order to make TagNames documentation nicer. 33 34 @Image::ExifTool::MakerNotes::Main = ( 34 # decide which MakerNotes to use (based on camera make/model) 35 # decide which MakerNotes to use (based on makernote header and camera make/model) 36 { 37 Name => 'MakerNoteApple', 38 Condition => '$$valPt =~ /^Apple iOS\0/', 39 SubDirectory => { 40 TagTable => 'Image::ExifTool::Apple::Main', 41 Start => '$valuePtr + 14', 42 Base => '$start - 14', 43 ByteOrder => 'Unknown', 44 }, 45 }, 46 { 47 # this maker notes starts with a standard TIFF header at offset 0x0a 48 # (must check Nikon signature first because Nikon Capture NX can generate 49 # NEF images containing Nikon maker notes from JPEG images of any camera model) 50 Name => 'MakerNoteNikon', 51 Condition => '$$valPt=~/^Nikon\x00\x02/', 52 SubDirectory => { 53 TagTable => 'Image::ExifTool::Nikon::Main', 54 Start => '$valuePtr + 18', 55 Base => '$start - 8', 56 ByteOrder => 'Unknown', 57 }, 58 }, 35 59 { 36 60 Name => 'MakerNoteCanon', … … 64 88 ByteOrder => 'Unknown', 65 89 FixBase => 1, # necessary for AVI and MOV videos 90 }, 91 }, 92 { 93 Name => 'MakerNoteDJI', 94 Condition => '$$self{Make} eq "DJI" and $$valPt !~ /^...\@AMBA/s', 95 SubDirectory => { 96 TagTable => 'Image::ExifTool::DJI::Main', 97 Start => '$valuePtr', 98 ByteOrder => 'Unknown', 99 }, 100 }, 101 { 102 Name => 'MakerNoteFLIR', 103 # (starts with IFD, Make is 'FLIR Systems AB' or 'FLIR Systems') 104 Condition => '$$self{Make} =~ /^FLIR Systems/', 105 SubDirectory => { 106 TagTable => 'Image::ExifTool::FLIR::Main', 107 Start => '$valuePtr', 108 ByteOrder => 'Unknown', 66 109 }, 67 110 }, … … 109 152 }, 110 153 }, 154 { 155 Name => 'MakerNoteHasselblad', 156 Condition => '$$self{Make} eq "Hasselblad"', 157 SubDirectory => { 158 TagTable => 'Image::ExifTool::Unknown::Main', 159 ByteOrder => 'Unknown', 160 Start => '$valuePtr', 161 Base => 0, # (avoids warnings since maker notes are not self-contained) 162 }, 163 # 0x0011 - sensor code (ref IB) 164 # 0x0012 - camera model id? 165 # 0x0015 - camera model name 166 # 0x0016 - coating code (ref IB) 167 }, 111 168 # (the GE X5 has really messed up EXIF-like maker notes starting with 112 169 # "GENIC\x0c\0" --> currently not decoded) … … 310 367 { 311 368 Name => 'MakerNoteKodak8b', 369 # these maker notes have an extra 2 bytes after the entry count 370 # (this is handled by the patch). Also, the IFD uses a Format 13, 371 # which is some 2-byte format (not Float, as decoded by ExifTool) 372 # - written by the PixPro AZ251, AZ361, AZ262, AZ521 373 Condition => q{ 374 $$self{Make}=~/Kodak/i and 375 $$valPt =~ /^MM\0\x2a\0\0\0\x08\0.\0\0/ 376 }, 377 SubDirectory => { 378 TagTable => 'Image::ExifTool::Kodak::Type8', 379 ProcessProc => \&ProcessKodakPatch, 380 ByteOrder => 'BigEndian', 381 Start => '$valuePtr + 8', 382 Base => '$start - 8', 383 }, 384 }, 385 { 386 Name => 'MakerNoteKodak8c', 312 387 # TIFF-format maker notes 313 388 Condition => q{ … … 347 422 ByteOrder => 'Unknown', 348 423 Start => '$valuePtr + 2', 424 }, 425 }, 426 { 427 Name => 'MakerNoteKodak11', 428 # these maker notes have a 4-byte entry count 429 # - written by the PixPro S-1 (Note: Make is "JK Imaging, Ltd.", so check Model for "Kodak") 430 Condition => q{ 431 $$self{Model}=~/(Kodak|PixPro)/i and 432 $$valPt =~ /^II\x2a\0\x08\0\0\0.\0\0\0/s 433 }, 434 SubDirectory => { 435 TagTable => 'Image::ExifTool::Kodak::Type11', 436 ProcessProc => \&ProcessKodakPatch, 437 ByteOrder => 'LittleEndian', 438 Start => '$valuePtr + 8', 439 Base => '$start - 8', 440 }, 441 }, 442 { 443 Name => 'MakerNoteKodak12', 444 # these maker notes have a 4-byte entry count 445 # - written by the PixPro AZ901 (Note: Make is "JK Imaging, Ltd.", so check Model for "Kodak") 446 Condition => q{ 447 $$self{Model}=~/(Kodak|PixPro)/i and 448 $$valPt =~ /^MM\0\x2a\0\0\0\x08\0\0\0./s 449 }, 450 SubDirectory => { 451 TagTable => 'Image::ExifTool::Kodak::Type11', 452 ProcessProc => \&ProcessKodakPatch, 453 ByteOrder => 'BigEndian', 454 Start => '$valuePtr + 8', 455 Base => '$start - 8', 349 456 }, 350 457 }, … … 404 511 }, 405 512 { 406 # this maker notes starts with a standard TIFF header at offset 0x0a 407 Name => 'MakerNoteNikon', 408 Condition => '$$self{Make}=~/^NIKON/i and $$valPt=~/^Nikon\x00\x02/', 409 SubDirectory => { 410 TagTable => 'Image::ExifTool::Nikon::Main', 411 Start => '$valuePtr + 18', 513 Name => 'MakerNoteMotorola', 514 Condition => '$$valPt=~/^MOT\0/', 515 SubDirectory => { 516 TagTable => 'Image::ExifTool::Motorola::Main', 517 Start => '$valuePtr + 8', 412 518 Base => '$start - 8', 413 519 ByteOrder => 'Unknown', … … 417 523 # older Nikon maker notes 418 524 Name => 'MakerNoteNikon2', 419 Condition => '$$ self{Make}=~/^NIKON/ and $$valPt=~/^Nikon\x00\x01/',525 Condition => '$$valPt=~/^Nikon\x00\x01/', 420 526 SubDirectory => { 421 527 TagTable => 'Image::ExifTool::Nikon::Type2', … … 431 537 TagTable => 'Image::ExifTool::Nikon::Main', 432 538 ByteOrder => 'Unknown', # most are little-endian, but D1 is big 539 }, 540 }, 541 { 542 Name => 'MakerNoteNintendo', 543 # (starts with an IFD) 544 Condition => '$$self{Make} eq "Nintendo"', 545 SubDirectory => { 546 TagTable => 'Image::ExifTool::Nintendo::Main', 547 ByteOrder => 'Unknown', 433 548 }, 434 549 }, … … 485 600 Name => 'MakerNoteLeica3', # used by the R8 and R9 486 601 # (starts with IFD) 487 Condition => '$$self{Make} =~ /^Leica Camera AG/ and $$valPt !~ /^LEICA/ and $$self{Model} ne "S2"', 602 Condition => q{ 603 $$self{Make} =~ /^Leica Camera AG/ and $$valPt !~ /^LEICA/ and 604 $$self{Model} ne "S2" and $$self{Model} ne "LEICA M (Typ 240)" 605 }, 488 606 SubDirectory => { 489 607 TagTable => 'Image::ExifTool::Panasonic::Leica3', … … 493 611 }, 494 612 { 495 Name => 'MakerNoteLeica4', # used by the M9 496 # (M9 startswith "LEICA0\x03\0")613 Name => 'MakerNoteLeica4', # used by the M9/M-Monochrom 614 # (M9 and M Monochrom start with "LEICA0\x03\0") 497 615 Condition => '$$self{Make} =~ /^Leica Camera AG/ and $$valPt =~ /^LEICA0/', 498 616 SubDirectory => { … … 504 622 }, 505 623 { 506 Name => 'MakerNoteLeica5', # used by the X1 624 Name => 'MakerNoteLeica5', # used by the X1/X2/X VARIO/T/X-U 507 625 # (X1 starts with "LEICA\0\x01\0", Make is "LEICA CAMERA AG") 508 Condition => '$$valPt =~ /^LEICA\0\x01\0/', 626 # (X2 starts with "LEICA\0\x05\0", Make is "LEICA CAMERA AG") 627 # (X VARIO starts with "LEICA\0\x04\0", Make is "LEICA CAMERA AG") 628 # (T (Typ 701) starts with "LEICA\0\0x6", Make is "LEICA CAMERA AG") 629 # (X (Typ 113) starts with "LEICA\0\0x7", Make is "LEICA CAMERA AG") 630 # (X-U (Typ 113) starts with "LEICA\0\x10\0", Make is "LEICA CAMERA AG") 631 Condition => '$$valPt =~ /^LEICA\0[\x01\x04\x05\x06\x07\x10\x1a]\0/', 509 632 SubDirectory => { 510 633 TagTable => 'Image::ExifTool::Panasonic::Leica5', … … 515 638 }, 516 639 { 517 Name => 'MakerNoteLeica6', # used by the S2 (CAUTION: this tag name is special cased in the code) 518 # (S2 starts with "LEICA\0\x02\xff", Make is "LEICA CAMERA AG", 519 # but maker notes aren't loaded at the time this is tested) 520 Condition => '$$self{Model} eq "S2"', 640 Name => 'MakerNoteLeica6', # used by the S2, M (Typ 240) and S (Typ 006) 641 # (starts with "LEICA\0\x02\xff", Make is "Leica Camera AG", but test the 642 # model names separately because the maker notes data may not be loaded 643 # at the time this is tested if they are in a JPEG trailer. Also, this 644 # header is used by the M Monochrom (Type 246), with different offsets.) 645 Condition => q{ 646 ($$self{Make} eq 'Leica Camera AG' and ($$self{Model} eq 'S2' or 647 $$self{Model} eq 'LEICA M (Typ 240)' or $$self{Model} eq 'LEICA S (Typ 006)')) 648 }, 521 649 DataTag => 'LeicaTrailer', # (generates fixup name for this tag) 650 LeicaTrailer => 1, # flag to special-case this tag in the Exif code 522 651 SubDirectory => { 523 652 TagTable => 'Image::ExifTool::Panasonic::Leica6', … … 527 656 # as a JPEG trailer -- this case is handled by ProcessLeicaTrailer in 528 657 # Panasonic.pm, and any "Base" defined here is ignored for this case. 529 # ExifTool may also create S2 maker notes inside the APP1 segment when658 # ExifTool may also create S2/M maker notes inside the APP1 segment when 530 659 # copying from other files, and for this the normal EXIF offsets are used, 531 660 # Base should not be defined! … … 533 662 }, 534 663 { 664 Name => 'MakerNoteLeica7', # used by the M Monochrom (Typ 246) 665 # (starts with "LEICA\0\x02\xff", Make is "Leica Camera AG") 666 Condition => '$$valPt =~ /^LEICA\0\x02\xff/', 667 DataTag => 'LeicaTrailer', # (generates fixup name for this tag) 668 LeicaTrailer => 1, # flag to special-case this tag in the Exif code 669 SubDirectory => { 670 TagTable => 'Image::ExifTool::Panasonic::Leica6', 671 Start => '$valuePtr + 8', 672 ByteOrder => 'Unknown', 673 Base => '-$base', # uses absolute file offsets (not based on TIFF header offset) 674 }, 675 }, 676 { 677 Name => 'MakerNoteLeica8', # used by the Q (Type 116) 678 # (Q (Typ 116) starts with "LEICA\0\x08\0", Make is "LEICA CAMERA AG") 679 # (SL (Typ 601) and CL start with "LEICA\0\x09\0", Make is "LEICA CAMERA AG") 680 Condition => '$$valPt =~ /^LEICA\0[\x08\x09]\0/', 681 SubDirectory => { 682 TagTable => 'Image::ExifTool::Panasonic::Leica5', 683 Start => '$valuePtr + 8', 684 ByteOrder => 'Unknown', 685 }, 686 }, 687 { 688 Name => 'MakerNoteLeica9', # used by the M10/S 689 # (M10 and S start with "LEICA0\x02\0") 690 Condition => '$$self{Make} =~ /^Leica Camera AG/ and $$valPt =~ /^LEICA\0\x02\0/', 691 SubDirectory => { 692 TagTable => 'Image::ExifTool::Panasonic::Leica9', 693 Start => '$valuePtr + 8', 694 ByteOrder => 'Unknown', 695 }, 696 }, 697 { 698 Name => 'MakerNoteLeica10', # used by the D-Lux7 699 Condition => '$$valPt =~ /^LEICA CAMERA AG\0/', 700 SubDirectory => { 701 TagTable => 'Image::ExifTool::Panasonic::Main', 702 Start => '$valuePtr + 18', 703 ByteOrder => 'Unknown', 704 }, 705 }, 706 { 535 707 Name => 'MakerNotePanasonic', 536 708 # (starts with "Panasonic\0") 537 Condition => '$$valPt=~/^Panasonic/ ',709 Condition => '$$valPt=~/^Panasonic/ and $$self{Model} ne "DC-FT7"', 538 710 SubDirectory => { 539 711 TagTable => 'Image::ExifTool::Panasonic::Main', … … 549 721 TagTable => 'Image::ExifTool::Panasonic::Type2', 550 722 ByteOrder => 'LittleEndian', 723 }, 724 }, 725 { 726 Name => 'MakerNotePanasonic3', # (DC-FT7) 727 # (starts with "Panasonic\0") 728 Condition => '$$valPt=~/^Panasonic/', 729 SubDirectory => { 730 TagTable => 'Image::ExifTool::Panasonic::Main', 731 Start => '$valuePtr + 12', 732 Base => 12, # crazy! 733 ByteOrder => 'Unknown', 551 734 }, 552 735 }, … … 609 792 Name => 'MakerNotePentax5', 610 793 # (starts with "PENTAX \0") 794 # used by cameras such as the Q, Optio S1, RS1500 and WG-1 611 795 Condition => '$$valPt=~/^PENTAX \0/', 612 796 SubDirectory => { … … 618 802 }, 619 803 { 804 Name => 'MakerNotePentax6', 805 # (starts with "S1\0\0\0\0\0\0\x0c\0\0\0") 806 Condition => '$$valPt=~/^S1\0{6}\x0c\0{3}/', 807 SubDirectory => { 808 TagTable => 'Image::ExifTool::Pentax::S1', 809 Start => '$valuePtr + 12', 810 Base => '$start - 12', 811 ByteOrder => 'Unknown', 812 }, 813 }, 814 { 620 815 Name => 'MakerNotePhaseOne', 621 816 # Starts with: 'IIIITwaR' or 'IIIICwaR' (have seen both written by P25) … … 627 822 }, 628 823 NotIFD => 1, 629 Binary => 1,630 PutFirst => 1, # place immediately after TIFF header631 Notes => 'the raw image data in PhaseOne IIQ images',824 IsPhaseOne => 1, # flag to rebuild these differently 825 SubDirectory => { TagTable => 'Image::ExifTool::PhaseOne::Main' }, 826 PutFirst => 1, # place immediately after TIFF header 632 827 }, 633 828 { 634 829 Name => 'MakerNoteReconyx', 635 Condition => '$$valPt =~ /^\x01\xf1[\x02\x03]\x00/', 830 Condition => q{ 831 $$valPt =~ /^\x01\xf1([\x02\x03]\x00)?/ and 832 ($1 or $$self{Make} eq "RECONYX") 833 }, 636 834 SubDirectory => { 637 835 TagTable => 'Image::ExifTool::Reconyx::Main', … … 640 838 }, 641 839 { 840 Name => 'MakerNoteReconyx2', 841 Condition => '$$valPt =~ /^RECONYXUF\0/', 842 SubDirectory => { 843 TagTable => 'Image::ExifTool::Reconyx::Type2', 844 ByteOrder => 'Little-endian', 845 }, 846 }, 847 { 848 Name => 'MakerNoteReconyx3', 849 Condition => '$$valPt =~ /^RECONYXH2\0/', 850 SubDirectory => { 851 TagTable => 'Image::ExifTool::Reconyx::Type3', 852 ByteOrder => 'Little-endian', 853 }, 854 }, 855 { 856 Name => 'MakerNoteRicohPentax', 857 # used by cameras such as the Ricoh GR III 858 Condition => '$$valPt=~/^RICOH\0(II|MM)/', 859 SubDirectory => { 860 TagTable => 'Image::ExifTool::Pentax::Main', 861 Start => '$valuePtr + 8', 862 Base => '$start - 8', 863 ByteOrder => 'Unknown', 864 }, 865 }, 866 { 642 867 Name => 'MakerNoteRicoh', 643 868 # (my test R50 image starts with " \x02\x01" - PH) 644 Condition => '$$self{Make}=~/^RICOH/ and $$valPt=~/^(Ricoh| )/i', 869 Condition => q{ 870 $$self{Make} =~ /^(PENTAX )?RICOH/ and 871 $$valPt =~ /^(Ricoh| |MM\0\x2a|II\x2a\0)/i and 872 $$valPt !~ /^(MM\0\x2a\0\0\0\x08\0.\0\0|II\x2a\0\x08\0\0\0.\0\0\0)/s and 873 $$self{Model} ne 'RICOH WG-M1' 874 }, 645 875 SubDirectory => { 646 876 TagTable => 'Image::ExifTool::Ricoh::Main', 647 877 Start => '$valuePtr + 8', 648 878 ByteOrder => 'Unknown', 879 }, 880 }, 881 { 882 Name => 'MakerNoteRicoh2', 883 # (the Ricoh HZ15 starts with "MM\0\x2a" and the Pentax XG-1 starts with "II\x2a\0", 884 # but an extra 2 bytes of padding after the IFD entry count prevents these from 885 # being processed as a standard IFD. Note that the offsets for the HZ15 are all 886 # zeros, but they seem to be mostly OK for the XG-1) 887 Condition => q{ 888 $$self{Make} =~ /^(PENTAX )?RICOH/ and ($$self{Model} eq 'RICOH WG-M1' or 889 $$valPt =~ /^(MM\0\x2a\0\0\0\x08\0.\0\0|II\x2a\0\x08\0\0\0.\0\0\0)/s) 890 }, 891 SubDirectory => { 892 TagTable => 'Image::ExifTool::Ricoh::Type2', 893 Start => '$valuePtr + 8', 894 Base => '$start - 8', 895 ByteOrder => 'Unknown', 896 ProcessProc => \&ProcessKodakPatch, 649 897 }, 650 898 }, … … 670 918 Condition => '$$valPt =~ /^STMN\d{3}/', 671 919 SubDirectory => { 672 TagTable => 'Image::ExifTool::Samsung:: Type1',920 TagTable => 'Image::ExifTool::Samsung::Main', 673 921 }, 674 922 }, 675 923 { 676 924 Name => 'MakerNoteSamsung2', 677 # Samsung EXIF-format maker notes 678 Condition => q{ 679 $$self{Make} eq 'SAMSUNG' and ($$self{TIFF_TYPE} eq 'SRW' or925 # Samsung EXIF-format maker notes ( 926 Condition => q{ 927 uc $$self{Make} eq 'SAMSUNG' and ($$self{TIFF_TYPE} eq 'SRW' or 680 928 $$valPt=~/^(\0.\0\x01\0\x07\0{3}\x04|.\0\x01\0\x07\0\x04\0{3})0100/s) 681 929 }, … … 726 974 { 727 975 Name => 'MakerNoteSigma', 728 # (starts with "SIGMA\0") 729 Condition => '$$self{Make}=~/^(SIGMA|FOVEON)/', 976 Condition => q{ 977 return undef unless $$self{Make}=~/^(SIGMA|FOVEON)/; 978 # save version number in "MakerNoteSigmaVer" member variable 979 $$self{MakerNoteSigmaVer} = $$valPt=~/^SIGMA\0\0\0\0(.)/ ? ord($1) : -1; 980 return 1; 981 }, 730 982 SubDirectory => { 731 983 TagTable => 'Image::ExifTool::Sigma::Main', … … 738 990 Name => 'MakerNoteSony', 739 991 # (starts with "SONY DSC \0" or "SONY CAM \0") 740 Condition => '$$self{Make}=~/^SONY/ and $$valPt=~/^SONY (DSC|CAM)/', 992 # (TF1 starts with "\0\0SONY PIC\0") 993 # (Hasselblad models start with "VHAB \0") 994 Condition => '$$valPt=~/^(SONY (DSC|CAM|MOBILE)|\0\0SONY PIC\0|VHAB \0)/', 741 995 SubDirectory => { 742 996 TagTable => 'Image::ExifTool::Sony::Main', … … 748 1002 Name => 'MakerNoteSony2', 749 1003 # (starts with "SONY PI\0" -- DSC-S650/S700/S750) 750 Condition => '$$ self{Make}=~/^SONY/ and $$valPt=~/^SONY PI\0/ and $$self{OlympusCAMER}=1',1004 Condition => '$$valPt=~/^SONY PI\0/ and $$self{OlympusCAMER}=1', 751 1005 SubDirectory => { 752 1006 TagTable => 'Image::ExifTool::Olympus::Main', … … 758 1012 Name => 'MakerNoteSony3', 759 1013 # (starts with "PREMI\0" -- DSC-S45/S500) 760 Condition => '$$ self{Make}=~/^SONY/ and $$valPt=~/^(PREMI)\0/ and $$self{OlympusCAMER}=1',1014 Condition => '$$valPt=~/^(PREMI)\0/ and $$self{OlympusCAMER}=1', 761 1015 SubDirectory => { 762 1016 TagTable => 'Image::ExifTool::Olympus::Main', … … 766 1020 }, 767 1021 { 768 Name => 'MakerNoteSony4', # used in SR2 and ARW images 1022 Name => 'MakerNoteSony4', 1023 # (starts with "SONY PIC\0" -- DSC-H200/J20/W370/W510, MHS-TS20) 1024 Condition => '$$valPt=~/^SONY PIC\0/', 1025 SubDirectory => { TagTable => 'Image::ExifTool::Sony::PIC' }, 1026 }, 1027 { 1028 Name => 'MakerNoteSony5', # used in SR2 and ARW images 769 1029 Condition => '$$self{Make}=~/^SONY/ and $$valPt!~/^\x01\x00/', 1030 Condition => q{ 1031 ($$self{Make}=~/^SONY/ or ($$self{Make}=~/^HASSELBLAD/ and 1032 $$self{Model}=~/^(HV|Stellar|Lusso|Lunar)/)) and $$valPt!~/^\x01\x00/ 1033 }, 770 1034 SubDirectory => { 771 1035 TagTable => 'Image::ExifTool::Sony::Main', … … 802 1066 }, 803 1067 { 1068 Name => 'MakerNoteUnknownBinary', 1069 # "LSI1\0" - SilverFast 1070 Condition => '$$valPt =~ /^LSI1\0/', 1071 Notes => 'unknown binary maker notes', 1072 Binary => 1, 1073 }, 1074 { 804 1075 Name => 'MakerNoteUnknown', 805 1076 PossiblePreview => 1, … … 818 1089 foreach $tagInfo (@Image::ExifTool::MakerNotes::Main) { 819 1090 $$tagInfo{Writable} = 'undef'; 1091 $$tagInfo{Format} = 'undef', # (make sure we don't convert this when reading) 820 1092 $$tagInfo{WriteGroup} = 'ExifIFD'; 821 1093 $$tagInfo{Groups} = { 1 => 'MakerNotes' }; … … 835 1107 sub GetMakerNoteOffset($) 836 1108 { 837 my $e xifTool= shift;1109 my $et = shift; 838 1110 # figure out where we expect the value data based on camera type 839 my $make = $ exifTool->{Make};840 my $model = $ exifTool->{Model};1111 my $make = $$et{Make}; 1112 my $model = $$et{Model}; 841 1113 my ($relative, @offsets); 842 1114 … … 855 1127 # except some models like the EX-S770,Z65,Z70,Z75 and Z700 which use 16, 856 1128 # and the EX-Z35 which uses 2 (grrrr...) 857 push @offsets, $$e xifTool{FILE_TYPE} =~ /^(RIFF|MOV)$/ ? 0 : (4, 16, 2);1129 push @offsets, $$et{FILE_TYPE} =~ /^(RIFF|MOV)$/ ? 0 : (4, 16, 2); 858 1130 } elsif ($make =~ /^(General Imaging Co.|GEDSC IMAGING CORP.)/i) { 859 1131 push @offsets, 0; … … 863 1135 if ($model eq 'S2') { 864 1136 # lots of empty space before first value in S2 images 865 push @offsets, 4, ($$exifTool{FILE_TYPE} eq 'JPEG' ? 286 : 274); 1137 push @offsets, 4, ($$et{FILE_TYPE} eq 'JPEG' ? 286 : 274); 1138 } elsif ($model eq 'LEICA M MONOCHROM (Typ 246)') { 1139 push @offsets, 4, 130; 1140 } elsif ($model eq 'LEICA M (Typ 240)') { 1141 push @offsets, 4, 118; 866 1142 } elsif ($model =~ /^(R8|R9|M8)\b/) { 867 1143 push @offsets, 6; … … 879 1155 push @offsets, 0; 880 1156 } elsif ($make =~ /^SONY/) { 881 # DSLR and "PREMI" models use an offset of 4 882 if ($model =~ /DSLR/ or $$exifTool{OlympusCAMER}) { 1157 # earlier DSLR and "PREMI" models use an offset of 4 1158 if ($model =~ /^(DSLR-.*|SLT-A(33|35|55V)|NEX-(3|5|C3|VG10E))$/ or 1159 $$et{OlympusCAMER}) 1160 { 883 1161 push @offsets, 4; 884 1162 } else { 885 1163 push @offsets, 0; 886 1164 } 1165 } elsif ($$et{TIFF_TYPE} eq 'SRW' and $make eq 'SAMSUNG' and $model eq 'EK-GN120') { 1166 push @offsets, 40; # patch to read most of the maker notes, but breaks PreviewIFD 887 1167 } elsif ($make eq 'FUJIFILM') { 888 1168 # some models have offset of 6, so allow that too (A345,A350,A360,A370) … … 961 1241 { 962 1242 local $_; 963 my ($e xifTool, $dirInfo) = @_;1243 my ($et, $dirInfo) = @_; 964 1244 # don't fix base if fixing offsets individually or if we don't want to fix them 965 1245 return 0 if $$dirInfo{FixOffsets} or $$dirInfo{NoFixBase}; … … 970 1250 my $entryBased = $$dirInfo{EntryBased}; 971 1251 my $dirName = $$dirInfo{DirName}; 972 my $fixBase = $e xifTool->Options('FixBase');1252 my $fixBase = $et->Options('FixBase'); 973 1253 my $setBase = (defined $fixBase and $fixBase ne '') ? 1 : 0; 974 1254 my ($fix, $fixedBy, %tagPtr); … … 982 1262 # handle special case of Canon maker notes with TIFF footer containing original offset 983 1263 # 984 if ($$e xifTool{Make} =~ /^Canon/ and $$dirInfo{DirLen} > 8) {1264 if ($$et{Make} =~ /^Canon/ and $$dirInfo{DirLen} > 8) { 985 1265 my $footerPos = $dirStart + $$dirInfo{DirLen} - 8; 986 1266 my $footer = substr($$dataPt, $footerPos, 8); … … 1004 1284 # (allow for possible padding byte, although I have never seen this) 1005 1285 if (not $endDiff or $endDiff == 1) { 1006 $e xifTool->Warn('Canon maker note footer may be invalid (ignored)',1);1286 $et->Warn('Canon maker note footer may be invalid (ignored)',1); 1007 1287 return 0; 1008 1288 } 1009 1289 } 1010 $e xifTool->Warn("Adjusted $dirName base by $fix",1);1290 $et->Warn("Adjusted $dirName base by $fix",1); 1011 1291 $$dirInfo{FixedBy} = $fix; 1012 1292 $$dirInfo{Base} += $fix; … … 1023 1303 my $ifdLen = 2 + 12 * Get16u($$dirInfo{DataPt}, $dirStart); 1024 1304 my $ifdEnd = $dirStart + $ifdLen; 1025 my ($relative, @offsets) = GetMakerNoteOffset($e xifTool);1305 my ($relative, @offsets) = GetMakerNoteOffset($et); 1026 1306 my $makeDiff = $offsets[0]; 1027 my $verbose = $e xifTool->Options('Verbose');1307 my $verbose = $et->Options('Verbose'); 1028 1308 my ($diff, $shift); 1029 1309 … … 1066 1346 # which have been correcting for individual entry position 1067 1347 $entryBased = 1; 1068 $verbose and $e xifTool->Warn("$dirName offsets are entry-based",1);1348 $verbose and $et->Warn("$dirName offsets are entry-based",1); 1069 1349 } else { 1070 1350 # calculate offset difference from end of IFD to first value 1071 1351 $diff = ($minPt - $dataPos) - $ifdEnd; 1072 1352 $shift = 0; 1073 $countOverlap and $e xifTool->Warn("Overlapping $dirName values",1);1353 $countOverlap and $et->Warn("Overlapping $dirName values",1); 1074 1354 if ($entryBased) { 1075 $e xifTool->Warn("$dirName offsets do NOT look entry-based",1);1355 $et->Warn("$dirName offsets do NOT look entry-based",1); 1076 1356 undef $entryBased; 1077 1357 undef $relative; … … 1087 1367 return 0 if $diff >=0 and $diff <= 24; 1088 1368 } 1089 # (used for testing to extract differences) 1090 # $exifTool->FoundTag('Diff', $diff); 1369 # ******** (used for testing to extract differences) ******** 1370 # $et->FoundTag('Diff', $diff); 1371 # $et->FoundTag('MakeDiff',$makeDiff); 1091 1372 } 1092 1373 # … … 1147 1428 # print warning unless difference looks reasonable 1148 1429 if ($diff < 0 or $diff > 16 or ($diff & 0x01)) { 1149 $e xifTool->Warn("Possibly incorrect maker notes offsets (fix by $fix?)",1);1430 $et->Warn("Possibly incorrect maker notes offsets (fix by $fix?)",1); 1150 1431 } 1151 1432 # don't do the fix (but we already adjusted base if entry-based) … … 1153 1434 } 1154 1435 if (defined $fixedBy) { 1155 $e xifTool->Warn("Adjusted $dirName base by $fixedBy",1);1436 $et->Warn("Adjusted $dirName base by $fixedBy",1); 1156 1437 $$dirInfo{FixedBy} = $fixedBy; 1157 1438 } … … 1171 1452 sub LocateIFD($$) 1172 1453 { 1173 my ($e xifTool, $dirInfo) = @_;1454 my ($et, $dirInfo) = @_; 1174 1455 my $dataPt = $$dirInfo{DataPt}; 1175 1456 my $dirStart = $$dirInfo{DirStart} || 0; 1176 1457 # (ignore MakerNotes DirLen since sometimes this is incorrect) 1177 1458 my $size = $$dirInfo{DataLen} - $dirStart; 1178 my $dirLen = $$dirInfo{DirLen} ||$size;1459 my $dirLen = defined $$dirInfo{DirLen} ? $$dirInfo{DirLen} : $size; 1179 1460 my $tagInfo = $$dirInfo{TagInfo}; 1180 1461 my $ifdOffsetPos; … … 1191 1472 if ($tagInfo and $$tagInfo{SubDirectory}) { 1192 1473 my $subdir = $$tagInfo{SubDirectory}; 1193 unless ($$subdir{ProcessProc} and 1474 unless ($$subdir{ProcessProc} and 1194 1475 ($$subdir{ProcessProc} eq \&ProcessUnknown or 1195 1476 $$subdir{ProcessProc} eq \&ProcessUnknownOrPreview)) … … 1220 1501 my $oldStart = $$dirInfo{DirStart}; 1221 1502 $$dirInfo{DirStart} = $newStart; 1222 FixLeicaBase($e xifTool, $dirInfo);1503 FixLeicaBase($et, $dirInfo); 1223 1504 $$dirInfo{DirStart} = $oldStart; 1224 1505 } … … 1298 1579 my $format = Get16u($dataPt, $entry+2); 1299 1580 my $count = Get32u($dataPt, $entry+4); 1300 # allow everything to be zero if not first entry 1301 # because some manufacturers pad with null entries 1302 next unless $format or $count or $index == 0; 1303 # patch for Canon EOS 40D firmware 1.0.4 bug: allow zero format for last entry 1304 next if $format==0 and $index==$num-1 and $$exifTool{Model}=~/EOS 40D/; 1581 unless ($format) { 1582 # patch for buggy Samsung NX200 JPEG MakerNotes entry count 1583 if ($num == 23 and $index == 21 and $$et{Make} eq 'SAMSUNG') { 1584 Set16u(21, $dataPt, $pos); # really 21 IFD entries! 1585 $et->Warn('Fixed incorrect Makernote entry count', 1); 1586 last; 1587 } 1588 # allow everything to be zero if not first entry 1589 # because some manufacturers pad with null entries 1590 next unless $count or $index == 0; 1591 # patch for Canon EOS 40D firmware 1.0.4 bug: allow zero format for last entry 1592 next if $index==$num-1 and $$et{Model}=~/EOS 40D/; 1593 } 1594 # patch for Sony cameras like the DSC-P10 that have invalid MakerNote entries 1595 next if $num == 12 and $$et{Make} eq 'SONY' and $index >= 8; 1305 1596 # (would like to verify tag ID, but some manufactures don't 1306 1597 # sort entries in order of tag ID so we don't have much of … … 1334 1625 sub FixLeicaBase($$;$) 1335 1626 { 1336 my ($e xifTool, $dirInfo, $tagTablePtr) = @_;1627 my ($et, $dirInfo, $tagTablePtr) = @_; 1337 1628 my $dataPt = $$dirInfo{DataPt}; 1338 1629 my $dirStart = $$dirInfo{DirStart} || 0; … … 1351 1642 my $success = 1; 1352 1643 if ($tagTablePtr) { 1353 $success = Image::ExifTool::Exif::ProcessExif($e xifTool, $dirInfo, $tagTablePtr);1644 $success = Image::ExifTool::Exif::ProcessExif($et, $dirInfo, $tagTablePtr); 1354 1645 } 1355 1646 return $success; … … 1362 1653 sub ProcessCanon($$$) 1363 1654 { 1364 my ($e xifTool, $dirInfo, $tagTablePtr) = @_;1655 my ($et, $dirInfo, $tagTablePtr) = @_; 1365 1656 # identify Canon MakerNote footer in HtmlDump 1366 1657 # (this code moved from FixBase so it also works for Adobe MakN in DNG images) 1367 if ($$e xifTool{HTML_DUMP} and $$dirInfo{DirLen} > 8) {1658 if ($$et{HTML_DUMP} and $$dirInfo{DirLen} > 8) { 1368 1659 my $dataPos = $$dirInfo{DataPos}; 1369 1660 my $dirStart = $$dirInfo{DirStart} || 0; … … 1378 1669 } 1379 1670 my $filePos = ($$dirInfo{Base} || 0) + $dataPos + $footerPos; 1380 $e xifTool->HDump($filePos, 8, '[Canon MakerNotes footer]', $str);1671 $et->HDump($filePos, 8, '[Canon MakerNotes footer]', $str); 1381 1672 } 1382 1673 } 1383 1674 # process as normal 1384 return Image::ExifTool::Exif::ProcessExif($e xifTool, $dirInfo, $tagTablePtr);1675 return Image::ExifTool::Exif::ProcessExif($et, $dirInfo, $tagTablePtr); 1385 1676 } 1386 1677 … … 1391 1682 sub ProcessGE2($$$) 1392 1683 { 1393 my ($e xifTool, $dirInfo, $tagTablePtr) = @_;1684 my ($et, $dirInfo, $tagTablePtr) = @_; 1394 1685 my $dataPt = $$dirInfo{DataPt} or return 0; 1395 1686 my $dirStart = $$dirInfo{DirStart} || 0; … … 1398 1689 # always have 25 entries, so write the entry count manually 1399 1690 Set16u(25, $dataPt, $dirStart); 1400 return Image::ExifTool::Exif::ProcessExif($exifTool, $dirInfo, $tagTablePtr); 1691 return Image::ExifTool::Exif::ProcessExif($et, $dirInfo, $tagTablePtr); 1692 } 1693 1694 #------------------------------------------------------------------------------ 1695 # Process broken Kodak type 8b maker notes 1696 # Inputs: 0) ExifTool object ref, 1) DirInfo ref, 2) tag table ref 1697 # Returns: 1 on success 1698 sub ProcessKodakPatch($$$) 1699 { 1700 my ($et, $dirInfo, $tagTablePtr) = @_; 1701 my $dataPt = $$dirInfo{DataPt} or return 0; 1702 my $dirStart = $$dirInfo{DirStart} || 0; 1703 1704 # these maker notes have an 2 extra null bytes either before or after the entry count, 1705 # so fix this by making a 2-byte entry count just before the first IFD entry 1706 return 0 unless $$dirInfo{DirLen} >= 4; 1707 my $t1 = Get16u($dataPt,$dirStart); 1708 my $t2 = Get16u($dataPt,$dirStart+2); 1709 Set16u($t1 || $t2, $dataPt, $dirStart+2); 1710 $$dirInfo{DirStart} += 2; 1711 return Image::ExifTool::Exif::ProcessExif($et, $dirInfo, $tagTablePtr); 1401 1712 } 1402 1713 … … 1407 1718 sub ProcessUnknownOrPreview($$$) 1408 1719 { 1409 my ($e xifTool, $dirInfo, $tagTablePtr) = @_;1720 my ($et, $dirInfo, $tagTablePtr) = @_; 1410 1721 my $dataPt = $$dirInfo{DataPt}; 1411 1722 my $dirStart = $$dirInfo{DirStart}; … … 1413 1724 # check to see if this is a preview image 1414 1725 if ($dirLen > 6 and substr($$dataPt, $dirStart, 3) eq "\xff\xd8\xff") { 1415 $e xifTool->VerboseDir('PreviewImage');1416 if ($$e xifTool{HTML_DUMP}) {1726 $et->VerboseDir('PreviewImage'); 1727 if ($$et{HTML_DUMP}) { 1417 1728 my $pos = $$dirInfo{DataPos} + $$dirInfo{Base} + $dirStart; 1418 $e xifTool->HDump($pos, $dirLen, '(MakerNotes:PreviewImage data)', "Size: $dirLen bytes")1419 } 1420 $e xifTool->FoundTag('PreviewImage', substr($$dataPt, $dirStart, $dirLen));1729 $et->HDump($pos, $dirLen, '(MakerNotes:PreviewImage data)', "Size: $dirLen bytes") 1730 } 1731 $et->FoundTag('PreviewImage', substr($$dataPt, $dirStart, $dirLen)); 1421 1732 return 1; 1422 1733 } 1423 return ProcessUnknown($e xifTool, $dirInfo, $tagTablePtr);1734 return ProcessUnknown($et, $dirInfo, $tagTablePtr); 1424 1735 } 1425 1736 … … 1430 1741 sub WriteUnknownOrPreview($$$) 1431 1742 { 1432 my ($e xifTool, $dirInfo, $tagTablePtr) = @_;1743 my ($et, $dirInfo, $tagTablePtr) = @_; 1433 1744 my $dataPt = $$dirInfo{DataPt}; 1434 1745 my $dirStart = $$dirInfo{DirStart}; … … 1437 1748 # check to see if this is a preview image 1438 1749 if ($dirLen > 6 and substr($$dataPt, $dirStart, 3) eq "\xff\xd8\xff") { 1439 if ($$e xifTool{NEW_VALUE}{$Image::ExifTool::Extra{PreviewImage}}) {1750 if ($$et{NEW_VALUE}{$Image::ExifTool::Extra{PreviewImage}}) { 1440 1751 # write or delete new preview (if deleted, it can't currently be added back again) 1441 $newVal = $e xifTool->GetNewValues('PreviewImage') || '';1442 if ($e xifTool->Options('Verbose') > 1) {1443 $e xifTool->VerboseValue("- MakerNotes:PreviewImage", substr($$dataPt, $dirStart, $dirLen));1444 $e xifTool->VerboseValue("+ MakerNotes:PreviewImage", $newVal) if $newVal;1752 $newVal = $et->GetNewValue('PreviewImage') || ''; 1753 if ($et->Options('Verbose') > 1) { 1754 $et->VerboseValue("- MakerNotes:PreviewImage", substr($$dataPt, $dirStart, $dirLen)); 1755 $et->VerboseValue("+ MakerNotes:PreviewImage", $newVal) if $newVal; 1445 1756 } 1446 ++$$e xifTool{CHANGED};1757 ++$$et{CHANGED}; 1447 1758 } else { 1448 1759 $newVal = substr($$dataPt, $dirStart, $dirLen); … … 1450 1761 } else { 1451 1762 # rewrite MakerNote IFD 1452 $newVal = Image::ExifTool::Exif::WriteExif($e xifTool, $dirInfo, $tagTablePtr);1763 $newVal = Image::ExifTool::Exif::WriteExif($et, $dirInfo, $tagTablePtr); 1453 1764 } 1454 1765 return $newVal; … … 1461 1772 sub ProcessUnknown($$$) 1462 1773 { 1463 my ($e xifTool, $dirInfo, $tagTablePtr) = @_;1774 my ($et, $dirInfo, $tagTablePtr) = @_; 1464 1775 my $success = 0; 1465 1776 1466 my $loc = LocateIFD($e xifTool, $dirInfo);1777 my $loc = LocateIFD($et, $dirInfo); 1467 1778 if (defined $loc) { 1468 $ exifTool->{UnknownByteOrder} = GetByteOrder();1469 if ($e xifTool->Options('Verbose') > 1) {1470 my $out = $e xifTool->Options('TextOut');1471 my $indent = $ exifTool->{INDENT};1779 $$et{UnknownByteOrder} = GetByteOrder(); 1780 if ($et->Options('Verbose') > 1) { 1781 my $out = $et->Options('TextOut'); 1782 my $indent = $$et{INDENT}; 1472 1783 $indent =~ s/\| $/ /; 1473 1784 printf $out "${indent}Found IFD at offset 0x%.4x in maker notes:\n", 1474 1785 $$dirInfo{DirStart} + $$dirInfo{DataPos} + $$dirInfo{Base}; 1475 1786 } 1476 $success = Image::ExifTool::Exif::ProcessExif($e xifTool, $dirInfo, $tagTablePtr);1787 $success = Image::ExifTool::Exif::ProcessExif($et, $dirInfo, $tagTablePtr); 1477 1788 } else { 1478 $ exifTool->{UnknownByteOrder} = ''; # indicates we tried but didn't set byte order1479 $e xifTool->Warn("Unrecognized $$dirInfo{DirName}", 1);1789 $$et{UnknownByteOrder} = ''; # indicates we tried but didn't set byte order 1790 $et->Warn("Unrecognized $$dirInfo{DirName}", 1); 1480 1791 } 1481 1792 return $success; … … 1502 1813 =head1 AUTHOR 1503 1814 1504 Copyright 2003-20 11, Phil Harvey (phil at owl.phy.queensu.ca)1815 Copyright 2003-2021, Phil Harvey (philharvey66 at gmail.com) 1505 1816 1506 1817 This library is free software; you can redistribute it and/or modify it
Note:
See TracChangeset
for help on using the changeset viewer.